/* * PndSttCellTrackletGenerator.h * * Created on: Jun 13, 2014 * Author: schumann */ #ifndef PNDSTTCELLTRACKLETGENERATOR_H_ #define PNDSTTCELLTRACKLETGENERATOR_H_ #include "PndSttCellTrackFinderData.h" #include "PndTrackCand.h" #include "PndRiemannTrack.h" #include "PndTrack.h" #include "FairLink.h" #include "MacrosForGPUComputing.h" class PndSttStrawMap; class FairHit; class PndSttSkewedHit; extern "C" int* EvaluateAllStates(int*, int*, int, int, int*); 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 << ", #hits: " << hitIDs.size() << ", numSkewed: " << numSkewed << std::endl; if (riemannTrack.getNumHits() != 0) { std::cout << ", RiemannTrack created error: " << error << ", #wrong hits: " << numErrHits << " "; //std::cout << riemannTrack; std::cout << std::endl; } } ; }; struct Combination_t { std::set tracklets; // status of combined tracklets TrackletInf_t trackletInf; // information about the resulting tracklet void Print() { std::cout << "combined tracklets: "; for (std::set::iterator it = tracklets.begin(); it != tracklets.end(); ++it) { std::cout << *it << ", "; } std::cout << std::endl; trackletInf.Print(); } }; class PndSttCellTrackletGenerator { public: PndSttCellTrackletGenerator(const PndSttCellTrackFinderData* data) : fTimeStamps(20),fVerbose(0), fBz(2.), fCalcFirstTrackletInf(false), fCalcWithCorrectedHits( false), fTUBE_RADIUS(0.5005), fUseGPU(false), fDev_tubeNeighborings(0), fHits(data->GetHits()), fCombinedSkewedHits(data->GetCombinedSkewedHits()), fStrawMap(data->GetStrawMap()), fMapTubeIdToHit(data->GetMapTubeIdToHit()), fMapTubeIdToPos(data->GetMapTubeIdToPos()), fMapHitToFairLink(data->GetMapHitToFairLink()), fHitNeighbors(data->GetHitNeighbors()), fSeparations(data->GetSeparations()) { } virtual ~PndSttCellTrackletGenerator() { } void SetUseGPU(Bool_t val) { fUseGPU = val; } void SetDevTubeNeighboringsPointer(int* dev_pointer) { fDev_tubeNeighborings = dev_pointer; } void FindTracks(); void SetCorrectedHits(std::map correctedHits); /* For refitting all RiemanTracks with correctedHits (if available)*/ void RefitTracks(); void PrintInfo(); void SetCalcWithCorrectedHits(bool calcWithCorrectedHits=true) { fCalcWithCorrectedHits = calcWithCorrectedHits; } int GetNumPrimaryTracklets() { return fStartTracklets.size(); } /* Get TrackCands of start-tracklets (before combination)*/ std::vector GetFirstTrackCands() { return fFirstTrackCand; } ; /* Get RiemannTracks before combination of tracklets*/ std::vector GetFirstRiemannTracks() { return fFirstRiemannTrack; } ; /* Get TrackCands of combinated start-tracklets*/ std::vector GetCombiTrackCands() { return fCombiTrackCand; } ; std::vector GetCombiTracks() { return fCombiTrack; } ; bool CalcWithCorrectedHits() { return fCalcWithCorrectedHits; } /* Get RiemannTracks of combinated tracklets*/ std::vector GetCombiRiemannTracks() { return fCombiRiemannTrack; } ; void SetCalcFirstTrackletInf(Bool_t val) { fCalcFirstTrackletInf = val; } ; void SetVerbose(Int_t val) { fVerbose = val; } ; void SetBz(Double_t val) { fBz = val; } ; std::vector GetTimeStamps() { return fTimeStamps; } ; private: std::vector fTimeStamps; Int_t fVerbose; Double_t fBz; bool fCalcFirstTrackletInf; bool fCalcWithCorrectedHits; double fTUBE_RADIUS; bool fUseGPU; int* fDev_tubeNeighborings; std::vector fHits; std::multimap fCombinedSkewedHits; //<(inner) Tube-ID of combined stt hits of skewed layers, corresponding hit> const PndSttStrawMap* fStrawMap; std::map fMapTubeIdToHit; std::map fMapTubeIdToPos; std::map fMapHitToFairLink; map > fHitNeighbors; map > fSeparations; map fStates; // map map > fMultiStates; // map fStartTracklets; // map map fShortTracklets; // set // 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 // 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 after combination of tracklets (uncombined too) std::vector fCombiRiemannTrack; //resulting riemanntracks std::vector fCombiTrack; // resulting PndTrack std::map fCorrectedHits; /* This Method creates PndTrackCands out of the entries in fCombinedData and * the not combined tracklets with more than 2 hits.*/ void CreatePndTrackCands(); /* Method creates the tracklets by the means of a cellular automaton.*/ void GenerateTracklets(); /* Method creates the tracklets by the means of a cellular automaton on the GPU.*/ void GenerateTrackletsGPU(); /* 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 searches for reasonable combination of the start-tracklets with a recursive algorithm. * They are stored in fCombinedData. */ void CombineTrackletsMultiStages(); /* Implementation of the recursive algorithm for finding combination of the start-tracklets.*/ void CombineTrackletsMultiStagesRecursive(int stateToCombine, std::set currentCombi); /* Method inserts a combination of states if not existing yet.*/ void InsertCombination(std::set combination); /* Method for calculating the trackletInf for a combination of tracklets.*/ TrackletInf_t GetTrackletInf(std::set tracklets); /* Method splits the start tracklets in uncombined and short tracklets*/ void SplitData(); void AssignAmbiguousHits(); /* Method adds the unassigned hits and trackCands with 1 and 2 hits to an * appropriate combination (if possible).*/ void AddRemainingHits(); /* 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); /* Method for creating a riemannTrack out of hits. * Hits of skewed tubes were ignored.*/ PndRiemannTrack CreateRiemannTrack(std::vector hitIDs); std::set > CreatePairCombis(int firstState, std::set values); /* 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); /* Method checks if a tubeID belongs to the end-tube of a tracklet.*/ bool IsEndTubeOfTracklet(int tubeID); ClassDef(PndSttCellTrackletGenerator,1) ; }; #endif /* PNDSTTCELLTRACKLETGENERATOR_H_ */