#ifndef PndSttCellTrackFinder_H_ #define PndSttCellTrackFinder_H_ #include "TClonesArray.h" #include "PndSttStrawMap.h" #include "PndTrackCand.h" #include "PndRiemannTrack.h" #include "PndTrack.h" #include "PndSttSkewedHit.h" #include #include #include class FairHit; class PndSttGeometryMap; struct TrackletInf_t { TrackletInf_t():numSkewed(0), startID(0), endID(0), maxID(0), straight(false), error(0.0), numErrHits(0){}; std::vector hitIDs; // vector int numSkewed; // number of skewed tubes int startID; // tube-ID of the first tube of the tracklet int endID; // tube-ID of the final tube of the tracklet int maxID; // max tube-ID of all hits of the tracklet bool straight;// indicates whether the tracklet runs straight from the center to border of the STT PndRiemannTrack riemannTrack; // riemannTrack of the tracklet double error; // sum of squared error int numErrHits; // number of hits that deviate from circle by more than radius of a straw tube void Print() { std::cout << "startId: " << startID << ", endId: " << endID<< ", maxId: " << maxID << ", straight: " << straight << ", numSkewed: " << numSkewed; if (riemannTrack.getNumHits() != 0) { std::cout << ", RiemannTrack created error: " << error << ", #wrong hits: " << numErrHits << " "; std::cout << riemannTrack << std::endl; } std::cout << std::endl; }; }; struct Combination_t { std::set tracklets; // status of combined tracklets TrackletInf_t trackletInf; // information about the resulting tracklet }; class PndSttCellTrackFinder { public: PndSttCellTrackFinder() : fVerbose(0), fCalcFirstTrackletInf(kFALSE) { }; virtual ~PndSttCellTrackFinder() { }; void FindTracks(); void AddHits(TClonesArray* hits, Int_t branchId); void SetSttTubeArray(TClonesArray* sttTubeArray); void SetStrawMap(PndSttStrawMap* map){fStrawMap = *map;} void SetGeometryMap(PndSttGeometryMap* map){fGeometryMap = map;} PndTrackCand GetFirstTrackCand(int i) { return fFirstTrackCand[i]; }; PndRiemannTrack GetFirstRiemannTrack(int i) { return fFirstRiemannTrack[i]; }; PndTrackCand GetCombiTrackCand(int i) { return fCombiTrackCand[i]; }; PndTrack GetCombiTrack(int i) { return fCombiTrack[i]; }; PndRiemannTrack GetCombiRiemannTrack(int i) { return fCombinedData[i].trackletInf.riemannTrack; }; std::map GetCorrectedIsochrones() { return fCorrectedIsochrones; } int NumFirstTrackCands() { return fFirstTrackCand.size(); }; int NumFirstRiemannTracks() { return fFirstRiemannTrack.size(); }; int NumCombinedTracks() { return fCombiTrackCand.size(); }; int NumCombinedRiemannTracks() { return fCombinedData.size(); }; void SetCalcFirstTrackletInf(Bool_t val) { fCalcFirstTrackletInf = val; }; void SetVerbose(Int_t val) { fVerbose = val; }; void Reset(){ fHits.clear(); fMapHitToFairLink.clear(); fMapTubeIdToHit.clear(); fFirstTrackCand.clear(); fFirstRiemannTrack.clear(); fStates.clear(); fMultiStates.clear(); fHitNeighbors.clear(); fSeparations.clear(); // check if clear is sufficient to delete vector in vector fStartTracklets.clear(); fShortTracklets.clear(); fCombinedData.clear(); fTrackletsWithoutCombi.clear(); fCombiTrackCand.clear(); fStateCombinations.clear(); fCombiTrack.clear(); fCorrectedIsochrones.clear(); } private: /* Method creates the first tracklets by the means of a cellular automaton.*/ void GenerateTracklets(); /* Method searchs for hit-neighbors of each cell.*/ void FindHitNeighbors(); /* Method grades the active cells according to the number of hit-neighbors.*/ void SeparateNeighbors(); /* Method update the states of each until no state change anymore.*/ void EvaluateState(); /* Method update the states of tubes with more than two neighbors until no state changes anymore. */ void EvaluateMultiState(); /* Method initialzises fStartTracklets with the states and trackletInf * of the generated tracklets.*/ void InitStartTracklets(); /* Method combines the tracklets generated by the first step. * Only tracklets with more than 2 hits of tubes that are not skewed were combined.*/ // void CombineTracklets(); std::set > CreatePairCombis(int firstState, std::set values); // void CombineTrackletsMultiStagesOld(); void CombineTrackletsMultiStages(); void CombineTrackletsMultiStagesRecursive(int stateToCombine, std::set currentCombi); void InsertCombination(std::set combination); /* Method search for the start-tracklets that were not combined.*/ void FindTrackletsWithoutCombi(); /* Method creates combination of 3 tracklets based on two-part-combinations.*/ // void CreateFurtherCombinations(); void AssignAmbiguousHits(); /* Method adds the unassigned hits and trackCands with 1 and 2 hits to an * appropriate combination (if possible).*/ void AddMissingHits(); /* Methods adds the uncared hits with 3 and 4 hit-neighbors to the best combination * of tracklets. If the nearest riemann-circle is found and the distance is * smaller than the radius of a tube, the hit is added.*/ bool AddHitToBestCombi(int hitID); /* This Method creates PndTrackCands out of the entries in fCombinedData and * the not combined tracklets with more than 2 hits.*/ void CreatePndTrackCands(); /* Method for calculating the trackletInf for a combination of tracklets.*/ TrackletInf_t GetTrackletInf(std::set tracklets); /* Method checks if a tubeID belongs to the end-tube of a tracklet.*/ bool IsEndTubeOfTracklet(int tubeID); /* Method for creating a riemannTrack out of hits. * Hits of skewed tubes were ignored.*/ PndRiemannTrack CreateRiemannTrack(std::vector hitIDs); /* Method calculates the mean squared deviation of the hits from the riemann-circle.*/ double CalcDeviationOfRiemannTrack(PndRiemannTrack& track); /* Method calculates the deviation of the hit from the riemann-circle.*/ double CalcDeviation(PndRiemannTrack& track, int hitID); /* Method counts the hits of the riemannTrack, that had a distance of more * than r (radius of a straw tube) to the riemann-circle.*/ int GetDeviationCount(PndRiemannTrack& track); void CorrectIsochrones(); std::vector CalculateTangentAngles(PndSttHit* tube1, PndSttHit* tube2); std::vector > CalcClassification(std::vector > > differences); Int_t fVerbose; Bool_t fCalcFirstTrackletInf;// if true, calculate riemannTracks for start-tracklets std::vector fHits; // vector with all hits of the current event PndSttStrawMap fStrawMap; // for getting more information about the tubes PndSttGeometryMap* fGeometryMap;// for initializing the neighbors of each tube map fMapHitToFairLink; // map< index of hit in fHit, FairLink of SttHit> map fMapTubeIdToHit; // map< id of straw tube, index of hit in fHit> map fMapTubeIdToPos; // map // for first step of trackfinding std::vector fFirstTrackCand;// for saving trackCands after the use of cellular automaton std::vector fFirstRiemannTrack;// for saving + plotting the riemann-tracks after the first step map fStates; // map map > fMultiStates; // map > fHitNeighbors; // map> map > fSeparations; // map<#active neighbors, vector> map fStartTracklets; // map map fShortTracklets; // set std::multimap fCombinedSkewedHits; //<(inner) Tube-ID of combined stt hits of skewed layers, corresponding hit> std::map fCorrectedIsochrones; //< Tube-ID, corrected hit position> // for second step of trackfinding std::vector > fStateCombinations; // vector< set > std::vector fCombinedData; // for storing combination of start-tracklets std::vector fTrackletsWithoutCombi; // state of tracklets that were not combined std::vector fCombiTrackCand; // resulting tracks of combined tracklets std::vector fCombiTrack; // resulting PndTrack ClassDef(PndSttCellTrackFinder,1); }; #endif /*PndSttCellTrackFinder_H_*/