/* * PndLmdSensorAligner.h * * Created on: May 6, 2015 * Author: Roman Klasen, roklasen@uni-mainz.de or klasen@kph.uni-mainz.de * * This class gets HitPairs from PndLmdAlignManager and generates transformation matrices for ONE overlapping area. * It works in cm and gives the matrix between sensors, so the hit pairs MUST have valid x, y and z coordinates * in cm. * * One SensorAligner is responsible for one overlapping area alone, so 360 aligners are needed for the entire detector. * Therefore, only the PndLmdAlignManager should interact with this class. */ #ifndef LMD_LMDSENSORALIGNMENT_PNDLMDSENSORALIGNER_H_ #define LMD_LMDSENSORALIGNMENT_PNDLMDSENSORALIGNER_H_ #include "PndLmdHitPair.h" #include #include #include class PndLmdSensorAligner{ private: bool _forceInstant; int _maxNoOfPairs; std::string _inputFilename; int _moduleID, overlapID; int nonSanePairs, skippedPairs, swappedPairs, _verbose; int ID1, ID2; //complete Pairs std::vector pairs; //simple pairs old std::vector > simplePairsSensorOne; std::vector > simplePairsSensorTwo; //simple pairs new std::vector simpleSensorOneX; std::vector simpleSensorOneY; std::vector simpleSensorOneZ; std::vector simpleSensorTwoX; std::vector simpleSensorTwoY; std::vector simpleSensorTwoZ; bool _pairsNormal, _pairsSimple, _inCentimeters, _success, _numericCorrection, _zIsTimestamp; Matrix resultMatrix, _helperMatrix; public: PndLmdSensorAligner(); PndLmdSensorAligner(const PndLmdSensorAligner &other); virtual ~PndLmdSensorAligner(); //every constructor should call this, also resets aligner (even though that never happens in normale use) void init(); // add pair, make to vector void addPair(PndLmdHitPair &pair); // add simplified pair, for size and perfomance reasons void addSimplePair(PndLmdHitPair &pair); // add simplified pair, for size and perfomance reasons void addSimplePairOld(PndLmdHitPair &pair); bool writePairsToBinary(std::string directory); bool readPairsFromBinary(std::string directory); //set how many pairs the aligner should use, if higher than available in file, it will use all available void setMaximumNumberOfHitPairs(Int_t maxPais){ if(maxPais > 0){ _maxNoOfPairs=maxPais; //check vector capacity to avoid constant re-allocation, use max pairs } } void clearPairs(); //deactivate iterative part, use for debug only void forceInstant(Bool_t instant){ _forceInstant=instant; } void setModuleID(Int_t ID){ _moduleID=ID; } int getModuleID(){ return _moduleID; } int getNoOfPairs(){ if(_pairsSimple && !_pairsNormal){ return simpleSensorOneX.size(); } else if(!_pairsSimple && _pairsNormal){ return pairs.size(); } else{ return -1; } } void calculateMatrix(); int getOverlapId() const { return overlapID; } void setOverlapId(Int_t overlapId) { overlapID = overlapId; } void printAllPairs(); const Matrix& getResultMatrix() const { return resultMatrix; } void setHelperMatrix(const Matrix& helperMatrix) { _helperMatrix = helperMatrix; } //true in cm, false in pixels //FIXME: only works with non-simplified pairs, fix this! void setInCentimeters(bool inCentimeters) { _inCentimeters = inCentimeters; } void setId1(int id1) { ID1 = id1; } void setId2(int id2) { ID2 = id2; } int getId1() const { return ID1; } int getId2() const { return ID2; } bool isValid(double val); bool successful(){ return _success; } void setNumericCorrection(bool numericCorrection) { _numericCorrection = numericCorrection; } void setZasTimetamp(bool value){ _zIsTimestamp=value; } }; #endif /* LMD_LMDSENSORALIGNMENT_PNDLMDSENSORALIGNER_H_ */