61 : FairTask(name, iVerbose)
63 , fStsTrackBranchName(
"StsTrack")
64 , fGlobalTrackBranchName(
"GlobalTrack")
65 , fRichBranchName(
"RichRing")
66 , fTrdBranchName(
"TrdTrack")
67 , fTofBranchName(
"TofHit")
68 , fMuchTrackBranchName(
"MuchTrack")
69 , fMCTracksBranchName(
"MCTrack")
70 , fStsTrackMatchBranchName(
"StsTrackMatch")
71 , fRichRingMatchBranchName(
"RichRingMatch")
72 , fTrdTrackMatchBranchName(
"TrdTrackMatch")
73 , fTofHitMatchBranchName(
"TofHitMatch")
74 , fMuchTrackMatchBranchName(
"MuchTrackMatch")
82 , fStsTrackMatchArray(0)
85 , fOutFileName(outFileName)
90 TFile* curFile = gFile;
91 TDirectory* curDirectory = gDirectory;
102 gDirectory->mkdir(
"TimeHisto");
103 gDirectory->cd(
"TimeHisto");
105 TH1FParameters timeHisto[fNTimeHistos] = {
106 {
"NTracksVsTime",
"NTracksVsTime", 12100, -100.f, 12000.f},
107 {
"TracksTimeResidual",
"TracksTimeResidual", 300, -30.f, 30.f},
108 {
"TracksTimePull",
"TracksTimePull", 100, -10.f, 10.f},
109 {
"NHitsVsTime",
"NHitsVsTime", 12100, -100.f, 12000.f},
110 {
"HitsTimeResidual",
"HitsTimeResidual", 300, -30.f, 30.f},
111 {
"HitsTimePull",
"HitsTimePull", 100, -10.f, 10.f},
112 {
"NTracksInEventsVsTime",
"NTracksInEventsVsTime", 12100, -100.f, 12000.f},
113 {
"NHitsInEventsVsTime",
"NHitsInEventsVsTime", 12100, -100.f, 12000.f},
114 {
"NTracksVsMCTime",
"NTracksVsMCTime", 12100, -100.f, 12000.f},
115 {
"NHitsVsMCTime",
"NHitsVsMCTime", 12100, -100.f, 12000.f},
116 {
"dtDistribution",
"dtDistribution", 100, 0.f, 50.f},
117 {
"NTracksInEventsVsTime1",
"NTracksInEventsVsTime1", 120100, -100.f, 12000.f},
118 {
"NTracksInEventsVsTime2",
"NTracksInEventsVsTime2", 120100, -100.f, 12000.f},
119 {
"NTracksInEventsVsTime3",
"NTracksInEventsVsTime3", 120100, -100.f, 12000.f},
120 {
"NTracksInEventsVsTime4",
"NTracksInEventsVsTime4", 120100, -100.f, 12000.f},
121 {
"NTracksInEventsVsTime5",
"NTracksInEventsVsTime5", 120100, -100.f, 12000.f},
123 {
"NHitsInEventsVsTime1",
"NHitsInEventsVsTime1", 12100, -100.f, 12000.f},
124 {
"NHitsInEventsVsTime2",
"NHitsInEventsVsTime2", 12100, -100.f, 12000.f},
125 {
"NHitsInEventsVsTime3",
"NHitsInEventsVsTime3", 12100, -100.f, 12000.f},
126 {
"NHitsInEventsVsTime4",
"NHitsInEventsVsTime4", 12100, -100.f, 12000.f},
127 {
"NHitsInEventsVsTime5",
"NHitsInEventsVsTime5", 12100, -100.f, 12000.f},
129 {
"Number of merged events",
"Number of merged events", 6, -0.5f, 5.5f},
130 {
"Event length",
"Event length", 100, 0.f, 50.f},
131 {
"NTracksPerEvent",
"NTracksPerEvent", 250, 0.f, 250.f},
132 {
"TrackRecoTimePull",
"TrackRecoTimePull", 100, -10.f, 10.f},
133 {
"TrackTimeEvent",
"TrackTimeEvent", 100, -10.f, 10.f},
134 {
"TrackTimeNoEvent",
"TrackTimeNoEvent", 100, -10.f, 10.f}};
136 fTimeHisto[iH] =
new TH1F(timeHisto[iH].name.Data(), timeHisto[iH].title.Data(), timeHisto[iH].nbins,
137 timeHisto[iH].xMin, timeHisto[iH].xMax);
139 fTimeHisto[0]->GetXaxis()->SetTitle(
"Time, ns");
140 fTimeHisto[0]->GetYaxis()->SetTitle(
"Number of tracks");
141 fTimeHisto[16]->GetYaxis()->SetTitle(
"Number of Events");
142 fTimeHisto[16]->GetXaxis()->SetTitle(
"Number of MCEvents in Event");
166 gDirectory->cd(
"..");
170 gDirectory = curDirectory;
248 vector<vector<int>> mcHitMap(nMCEvents);
249 vector<CbmEbMCEvent> fMCEvents(nMCEvents);
253 UInt_t nHits =
fStsHits->GetEntriesFast();
256 for (UInt_t iHit = 0; iHit < nHits; iHit++) {
259 float hit_time = hit->
GetTime();
266 Float_t bestWeight = 0.f;
267 Float_t totalWeight = 0.f;
273 for (
int iLink = 0; iLink < stsHitMatch->
GetNofLinks(); iLink++) {
278 link = stsHitMatch->
GetLink(iLink);
282 if (bestWeight / totalWeight < 0.7 || iMCPoint < 0)
continue;
285 int iCol = (mcEvent) % 5;
287 if (iCol >= 0)
fTimeHisto[16 + iCol]->Fill(hit_time);
294 double residual = hit_time - mcTime;
295 double pull = residual / 5.;
302 UInt_t nTracks =
fStsTracks->GetEntriesFast();
304 vector<bool> IsTrackReconstructed(nTracks, 0);
305 vector<bool> IsTrackReconstructable(nTracks, 0);
307 const int iMCFile = 0;
310 for (
int iMCEvent = 0; iMCEvent < nMCEvents; iMCEvent++) {
311 const int nMCTracksInEvent =
fMCTracks->
Size(iMCFile, iMCEvent);
316 for (
unsigned int iStsPoint = 0; iStsPoint < nStsPoints; iStsPoint++) {
318 const int iMCTrack = point->GetTrackID();
324 for (
unsigned int iTrack = 0; iTrack < nTracks; iTrack++) {
333 for (UInt_t iHit = 0; iHit < NHits; iHit++) {
337 Float_t bestWeight = 0.f;
338 Float_t totalWeight = 0.f;
343 for (
int iLink = 0; iLink < stsHitMatch->
GetNofLinks(); iLink++) {
348 link = stsHitMatch->
GetLink(iLink);
351 if (bestWeight / totalWeight < 0.7 || iMCPoint < 0)
continue;
362 Float_t bestWeight = 0.f;
363 Float_t totalWeight = 0.f;
364 Int_t mcTrackId = -1;
367 for (
int iLink = 0; iLink < stsTrackMatch->
GetNofLinks(); iLink++) {
372 link = stsTrackMatch->
GetLink(iLink);
376 mcTrackId = iMCTrack;
379 if (bestWeight / totalWeight < 0.7 || mcTrackId < 0)
continue;
381 IsTrackReconstructed[iTrack] = 1;
393 vector<vector<int>> mcTrackMap(nMCEvents);
394 vector<CbmBuildEventMCTrack>
mcTracks;
400 for (
int iMCEvent = 0; iMCEvent < nMCEvents; iMCEvent++) {
409 int nReconstructableMCTracks = 0;
410 for (
unsigned int iMC = 0; iMC <
nMCTracks; iMC++) {
422 mcTrackMap[iMCEvent][iMC] =
mcTracks.size();
423 vector<int>& trackIds = fMCEvents[iMCEvent].GetMCTrackIds();
424 trackIds.push_back(
mcTracks.size());
435 if (nReconstructableMCTracks > 2) fMCEvents[iMCEvent].SetReconstructable(1);
441 Float_t bestWeight = 0.f;
442 Float_t totalWeight = 0.f;
443 Int_t mcTrackId = -1;
446 for (
int iLink = 0; iLink < stsTrackMatch->
GetNofLinks(); iLink++) {
451 link = stsTrackMatch->
GetLink(iLink);
453 mcTrackId = iMCTrack;
456 if (bestWeight / totalWeight < 0.7 || mcTrackId < 0)
continue;
458 fMCEvents[mcEvent].GetRecoTrackIds().push_back(iTrack);
461 vector<CbmEbEventMatch> eventMatches;
463 for (
int iEvent = 0; iEvent <
fEvents->GetEntriesFast(); iEvent++) {
467 vector<int> tracksId;
476 float tLastTrack = 0;
477 float tFirstTrack = 100000000000000;
479 for (
int iTr = 0; iTr < nEventTracks; iTr++) {
480 const int stsTrackIndex =
event->GetStsTrackIndex(iTr);
482 tracks.push_back(stsTrackIndex);
486 Float_t bestWeight = 0.f;
487 Float_t totalWeight = 0.f;
488 Int_t mcTrackId = -1;
491 for (
int iLink = 0; iLink < stsTrackMatch->
GetNofLinks(); iLink++) {
496 link = stsTrackMatch->
GetLink(iLink);
500 mcTrackId = iMCTrack;
503 if (bestWeight / totalWeight < 0.7 || mcTrackId < 0)
continue;
516 if (fMCEvents[mcEvent].IsReconstructable()) EventMatch.
AddTrack(mcEvent);
518 for (
int iTr1 = iTr + 1; iTr1 < nEventTracks; iTr1++) {
519 if (iTr1 == iTr)
continue;
520 const int stsTrackIndex1 =
event->GetStsTrackIndex(iTr1);
527 for (
int iEvent1 = 0; iEvent1 <
fEvents->GetEntriesFast(); iEvent1++) {
529 if (iEvent == iEvent1)
continue;
533 for (
int iTr1 = 0; iTr1 < nTracks1; iTr1++) {
546 fTimeHisto[22]->Fill(tLastTrack - tFirstTrack);
547 eventMatches.push_back(EventMatch);
549 for (std::map<int, int>::iterator it = EventMatch.
GetMCEvents().begin(); it != EventMatch.
GetMCEvents().end();
552 fMCEvents[it->first].AddRecoEvent(iEvent);
557 vector<SortEvents> Ev;
559 for (
int iMCEvent = 0; iMCEvent < nMCEvents; iMCEvent++) {
561 for (
int i = 0; i < nMcPoints; i++) {
569 int nEvents =
fEvents->GetEntriesFast();
571 for (
int k = 0; k < nEvents; k++) {
576 Event1.
Event = event;
579 Event1.
track = *track;
580 Ev.push_back(Event1);
586 for (
int k = 0; k < nEvents; k++) {
591 const int stsTrackIndex =
event->GetStsTrackIndex(i);
601 for (UInt_t iHit = 0; iHit < NHits; iHit++) {
612 for (
unsigned int iEvent = 0; iEvent < eventMatches.size(); iEvent++)
613 eventEfficiency.
AddGhost(eventMatches[iEvent].IsGhost());
615 for (
unsigned int iMCEvent = 0; iMCEvent < fMCEvents.size(); iMCEvent++) {
616 if (fMCEvents[iMCEvent].IsReconstructable() && fMCEvents[iMCEvent].NMCTracks() > 1) {
617 const vector<int>& recoEvents = fMCEvents[iMCEvent].GetRecoEvents();
619 if (recoEvents.size() == 1) reco = 1;
622 if (fMCEvents[iMCEvent].NClones() > 0) nclones = 1;
623 eventEfficiency.
Inc(reco, nclones,
"reconstructable");
626 if (fMCEvents[iMCEvent].GetRecoTrackIds().
size() > 2) {
627 const vector<int>& recoEvents = fMCEvents[iMCEvent].GetRecoEvents();
629 if (recoEvents.size() == 1) reco = 1;
632 if (fMCEvents[iMCEvent].NClones() > 0) nclones = 1;
633 eventEfficiency.
Inc(reco, nclones,
"reconstructed");
637 fEventEfficiency += eventEfficiency;
641 std::cout <<
"Event reconstruction efficiency" << std::endl;
647 for (
unsigned int iM = 0; iM < eventMatches.size(); iM++) {
650 fTimeHisto[21]->Fill(eventMatches[iM].NMCEvents());
662 f &= (mcTrack->
GetP() > 0.1);
667 int maxNSensorMC = 0;
675 int nMCContStations = 0;
676 int istaold = -1, ncont = 0;
677 int cur_maxNStaMC = 0, cur_maxNSensorMC = 0;
678 for (
unsigned int iH = 0; iH <
fPointsInTracks[iMCEvent][iMCTrack].size(); iH++) {
683 int currentStation = -1;
686 const float zStation = station->
GetZ();
688 if (fabs(point->GetZ() - zStation) < 2.5) {
689 currentStation = iStation;
693 if (currentStation < 0)
continue;
695 if (currentStation == lastSta)
698 if (cur_maxNStaMC > maxNStaMC) maxNStaMC = cur_maxNStaMC;
700 lastSta = currentStation;
704 if (point->GetZ() == lastz)
707 if (cur_maxNSensorMC > maxNSensorMC) maxNSensorMC = cur_maxNSensorMC;
708 cur_maxNSensorMC = 1;
709 lastz = point->GetZ();
712 int ista = currentStation;
713 if (ista - istaold == 1)
715 else if (ista - istaold > 1) {
716 if (nMCContStations < ncont) nMCContStations = ncont;
719 if (ista <= istaold)
continue;
723 if (nMCContStations < ncont) nMCContStations = ncont;
725 if (cur_maxNStaMC > maxNStaMC) maxNStaMC = cur_maxNStaMC;
726 if (cur_maxNSensorMC > maxNSensorMC) maxNSensorMC = cur_maxNSensorMC;
732 f &= (maxNStaMC <= 4);
734 bool isReconstructableTrack = f & (nMCContStations >= 4);
736 return (isReconstructableTrack);