/////////////////////////////////////////////////////////////////////////// // PairAnalysisEvent // // // // // /* Add Detailed description */ // // /////////////////////////////////////////////////////////////////////////// #include #include #include #include "FairRootManager.h" #include "FairMCPoint.h" #include "CbmDetectorList.h" #include "CbmVertex.h" #include "CbmGlobalTrack.h" #include "CbmStsTrack.h" #include "CbmMuchTrack.h" #include "CbmTrdTrack.h" #include "CbmRichRing.h" #include "CbmTofHit.h" #include "CbmMCTrack.h" #include "CbmTrackMatchNew.h" #include "PairAnalysisTrack.h" #include "PairAnalysisEvent.h" ClassImp(PairAnalysisEvent) PairAnalysisEvent::PairAnalysisEvent() : TNamed(), fMCTracks(0x0), //mc tracks fStsMatches(0x0), //STS matches fMuchMatches(0x0), //MUCH matches fTrdMatches(0x0), //TRD matches fRichMatches(0x0), //RICH matches fTofPoints(0x0), //TOF matches fGlobalTracks(0x0), //global tracks fTrdTracks(0x0), //TRD tracks fStsTracks(0x0), //STS tracks fMuchTracks(0x0), //MUCH tracks fRichRings(0x0), //RICH rings fStsHits(0x0), //STS hits fMuchHits(0x0), //MUCH hits fMuchHitsStraw(0x0), //MUCH hits fTrdHits(0x0), //TRD hits fRichHits(0x0), //RICH hits fTofHits(0x0), //TOF hits fTrdHitMatches(0x0), //TRD hits fTrdPoints(0x0), //TRD points fPrimVertex(0x0), //primary vertices fTracks(new TObjArray(1)), // array of papa tracks fMultiMatch(0) { // // Default Constructor // fTracks->SetOwner(kTRUE); } //______________________________________________ PairAnalysisEvent::PairAnalysisEvent(const char* name, const char* title) : TNamed(name, title), fMCTracks(0x0), //mc tracks fStsMatches(0x0), //STS matches fMuchMatches(0x0), //MUCH matches fTrdMatches(0x0), //TRD matches fRichMatches(0x0), //RICH matches fTofPoints(0x0), //TOF matches fGlobalTracks(0x0), //global tracks fTrdTracks(0x0), //TRD tracks fStsTracks(0x0), //STS tracks fMuchTracks(0x0), //MUCH tracks fRichRings(0x0), //RICH rings fStsHits(0x0), //STS hits fMuchHits(0x0), //MUCH hits fMuchHitsStraw(0x0), //MUCH hits fTrdHits(0x0), //TRD hits fRichHits(0x0), //RICH hits fTofHits(0x0), //TOF hits fTrdHitMatches(0x0), //TRD hits fTrdPoints(0x0), //TRD points fPrimVertex(0x0), //primary vertices fTracks(new TObjArray(1)), // array of papa tracks fMultiMatch(0) { // // Named Constructor // fTracks->SetOwner(kTRUE); } //______________________________________________ PairAnalysisEvent::~PairAnalysisEvent() { // // Default Destructor // fTracks->Clear("C"); fGlobalTracks->Delete(); //global tracks fMCTracks->Delete(); //mc tracks fTrdTracks->Delete(); //TRD tracks fStsTracks->Delete(); //STS tracks fMuchTracks->Delete(); //MUCH tracks fRichRings->Delete(); //RICH rings fStsMatches->Delete(); //STS matches fMuchMatches->Delete(); //MUCH matches fTrdMatches->Delete(); //TRD matches fRichMatches->Delete(); //RICH matches fTofPoints->Delete(); //TOF matches fStsHits->Delete(); //STS hits fMuchHits->Delete(); //MUCH hits fMuchHitsStraw->Delete(); //MUCH hits fTrdHits->Delete(); //TRD hits fRichHits->Delete(); //RICH hits fTofHits->Delete(); //TOF hits fTrdHitMatches->Delete(); //TRD hits fTrdPoints->Delete(); //TRD hits } //______________________________________________ void PairAnalysisEvent::SetInput(FairRootManager *man) { // // setup the track/hit branches // fGlobalTracks = (TClonesArray*) man->GetObject("GlobalTrack"); fTrdTracks = (TClonesArray*) man->GetObject("TrdTrack"); fStsTracks = (TClonesArray*) man->GetObject("StsTrack"); fMuchTracks = (TClonesArray*) man->GetObject("MuchTrack"); fRichRings = (TClonesArray*) man->GetObject("RichRing"); fPrimVertex = (CbmVertex*) man->GetObject("PrimaryVertex"); // MC matches and tracks fMCTracks = (TClonesArray*) man->GetObject("MCTrack"); fStsMatches = (TClonesArray*) man->GetObject("StsTrackMatch"); fMuchMatches = (TClonesArray*) man->GetObject("MuchTrackMatch"); fTrdMatches = (TClonesArray*) man->GetObject("TrdTrackMatch"); fRichMatches = (TClonesArray*) man->GetObject("RichRingMatch"); // hits fStsHits = (TClonesArray*) man->GetObject("StsHit"); fMuchHits = (TClonesArray*) man->GetObject("MuchPixelHit"); fMuchHitsStraw= (TClonesArray*) man->GetObject("MuchStrawHit"); fTrdHits = (TClonesArray*) man->GetObject("TrdHit"); fRichHits = (TClonesArray*) man->GetObject("RichHit"); fTofHits = (TClonesArray*) man->GetObject("TofHit"); fTrdHitMatches = (TClonesArray*) man->GetObject("TrdHitMatch"); // mc points fTrdPoints = (TClonesArray*) man->GetObject("TrdPoint"); fTofPoints = (TClonesArray*) man->GetObject("TofPoint"); // if(fMCTracks) printf("PairAnalysisEvent::SetInput: size of mc array: %04d \n",fMCTracks->GetSize()); } //______________________________________________ void PairAnalysisEvent::Init() { // // initialization of track arrays // fTracks->Clear("C"); if(!fGlobalTracks) return; TArrayS matches; if(fMCTracks) matches.Set(fMCTracks->GetEntriesFast()); // loop over all glbl tracks for (Int_t i=0; iGetEntriesFast(); i++) { // global track CbmGlobalTrack *gtrk=static_cast(fGlobalTracks->UncheckedAt(i)); if(!gtrk) continue; Int_t itrd = gtrk->GetTrdTrackIndex(); Int_t ists = gtrk->GetStsTrackIndex(); Int_t irich = gtrk->GetRichRingIndex(); Int_t itof = gtrk->GetTofHitIndex(); Int_t imuch = gtrk->GetMuchTrackIndex(); // reconstructed tracks CbmTrdTrack *trdTrack=0x0; if(fTrdTracks && itrd>=0) trdTrack=static_cast(fTrdTracks->At(itrd)); CbmStsTrack *stsTrack=0x0; if(fStsTracks && ists>=0) stsTrack=static_cast(fStsTracks->At(ists)); CbmRichRing *richRing=0x0; if(fRichRings && irich>=0) richRing=static_cast(fRichRings->At(irich)); CbmTofHit *tofHit=0x0; if(fTofHits && itof>=0) tofHit=static_cast(fTofHits->At(itof)); CbmMuchTrack *muchTrack=0x0; if(fMuchTracks && imuch>=0) muchTrack=static_cast(fMuchTracks->At(imuch)); // track matches CbmTrackMatchNew *stsMatch = 0x0; if(stsTrack) stsMatch = static_cast( fStsMatches->At(ists) ); //TODO: investigate why there could be 0xffffffffffffffe0 for stsMatch->GetMatchedLink() for these the fMatchedIndex is -1 and the number of hits is zero //if(stsMatch && stsMatch->GetMatchedIndex()==-1) Printf("matching index is -1: %d",stsMatch->GetNofHits()); Int_t istsMC = (stsMatch && stsMatch->GetNofHits()>0 ? stsMatch->GetMatchedLink().GetIndex() : -1 ); // Int_t istsMC = (stsMatch && stsMatch->GetMatchedIndex()>=0 ? stsMatch->GetMatchedLink().GetIndex() : -1 ); CbmTrackMatchNew *muchMatch = 0x0; if(muchTrack) muchMatch = static_cast( fMuchMatches->At(imuch) ); Int_t imuchMC = (muchMatch && muchMatch->GetNofHits()>0 ? muchMatch->GetMatchedLink().GetIndex() : -1 ); CbmTrackMatchNew *trdMatch = 0x0; if(trdTrack) trdMatch = static_cast( fTrdMatches->At(itrd) ); Int_t itrdMC = (trdMatch ? trdMatch->GetMatchedLink().GetIndex() : -1 ); CbmTrackMatchNew *richMatch = 0x0; if(richRing) richMatch = static_cast( fRichMatches->At(irich) ); Int_t irichMC = (richMatch ? richMatch->GetMatchedLink().GetIndex() : -1 ); FairMCPoint *tofPoint = 0x0; if(tofHit && tofHit->GetRefId()>0) tofPoint = static_cast( fTofPoints->At(tofHit->GetRefId()) ); Int_t itofMC = (tofPoint ? tofPoint->GetTrackID() : -1 ); // monte carlo track based on the STS match!!! Int_t iMC = istsMC; CbmMCTrack *mcTrack=0x0; if(fMCTracks && iMC>=0) mcTrack=static_cast(fMCTracks->At(iMC)); // increment position in matching array if(mcTrack && fMCTracks) matches[istsMC]++; // build papa track fTracks->AddAtAndExpand(new PairAnalysisTrack(gtrk, stsTrack,muchTrack,trdTrack,richRing,tofHit, mcTrack, stsMatch,muchMatch,trdMatch,richMatch), i); // set MC label and matching bits if(iMC>=0) { PairAnalysisTrack *tr = static_cast(fTracks->UncheckedAt(i)); tr->SetLabel(iMC); tr->SetBit(BIT(14+kTOF), (iMC==itofMC) ); tr->SetBit(BIT(14+kRICH), (iMC==irichMC) ); tr->SetBit(BIT(14+kTRD), (iMC==itrdMC) ); tr->SetBit(BIT(14+kSTS), (iMC==istsMC) ); tr->SetBit(BIT(14+kMUCH), (iMC==imuchMC) ); } } // number of multiple matched tracks for(Int_t i=0; i 1 ? matches[i] : 0); } PairAnalysisTrack *PairAnalysisEvent::GetTrack(UInt_t pos) { // // intialize the papa track and return it // // check intitialisation if(fTracks->GetSize()<=pos || !fTracks->At(pos)) Fatal("PairAnalysisEvent::GetTrack","Event initialisation failed somehow !!!"); return static_cast(fTracks->At(pos)); } //______________________________________________ Int_t PairAnalysisEvent::GetNumberOfMatches(DetectorId det) const { // // number of track matches // switch(det) { case kSTS: return (fStsMatches ? fStsMatches->GetEntriesFast() : 0); case kMUCH: return (fMuchMatches ? fMuchMatches->GetEntriesFast() : 0); case kTRD: return (fTrdMatches ? fTrdMatches->GetEntriesFast() : 0); case kRICH: return (fRichMatches ? fRichMatches->GetEntriesFast() : 0); default: return 0; } } //______________________________________________ TClonesArray *PairAnalysisEvent::GetHits(DetectorId det) const { // // get hits array for certain detector // //TODO: add much straw hits switch(det) { case kSTS: return fStsHits; case kMUCH:return fMuchHits; //pixel case kTRD: return fTrdHits; case kRICH:return fRichHits; case kTOF: return fTofHits; default: return 0x0; } } //______________________________________________ void PairAnalysisEvent::Clear(Option_t *opt) { // // clear arrays // fTracks->Clear("C"); // fGlobalTracks->Delete(); //global tracks // fTrdTracks->Delete(); //TRD tracks // fStsTracks->Delete(); //STS tracks // fMCTracks->Delete(); //mc tracks // fStsMatches->Delete(); //STS matches }