16 #include "FairLogger.h"
18 #include "TClonesArray.h"
20 #include "TGeoManager.h"
44 , last_timebin(nof_timebins - 1)
46 , fTrdClusters(nullptr)
47 , fTrdDigiMatches(nullptr)
49 , fGlobalTracks(nullptr)
51 , fTrdMCPoints(nullptr)
60 FindGeoChild(TGeoNode* node,
const char* name, list<TGeoNode*>& results) {
61 Int_t nofChildren = node->GetNdaughters();
63 for (Int_t
i = 0;
i < nofChildren; ++
i) {
64 TGeoNode* child = node->GetDaughter(
i);
65 TString childName(child->GetName());
67 if (childName.Contains(name, TString::kIgnoreCase))
68 results.push_back(child);
73 Double_t localCoords[3] = {0., 0., 0.};
74 Double_t globalCoords[3];
75 TGeoNavigator* pNavigator = gGeoManager->GetCurrentNavigator();
76 gGeoManager->cd(
"/cave_1");
77 list<TGeoNode*> detectors;
78 FindGeoChild(gGeoManager->GetCurrentNode(),
"trd", detectors);
80 for (list<TGeoNode*>::iterator
i = detectors.begin();
i != detectors.end();
82 TGeoNode* detector = *
i;
83 pNavigator->CdDown(detector);
84 list<TGeoNode*> layers;
88 for (list<TGeoNode*>::iterator j = layers.begin(); j != layers.end(); ++j) {
90 pNavigator->CdDown(layer);
91 list<TGeoNode*> modules;
94 for (list<TGeoNode*>::iterator k = modules.begin(); k != modules.end();
96 TGeoNode* module = *k;
97 pNavigator->CdDown(module);
98 list<TGeoNode*> padCoppers;
101 for (list<TGeoNode*>::iterator l = padCoppers.begin();
102 l != padCoppers.end();
104 TGeoNode* padCopper = *l;
105 pNavigator->CdDown(padCopper);
107 static_cast<TGeoBBox*
>(padCopper->GetVolume()->GetShape());
109 gGeoManager->LocalToMaster(localCoords, globalCoords);
113 > globalCoords[1] - pBox->GetDY())
115 globalCoords[1] - pBox->GetDY();
118 < globalCoords[1] + pBox->GetDY())
120 globalCoords[1] + pBox->GetDY();
123 > globalCoords[0] - pBox->GetDX())
125 globalCoords[0] - pBox->GetDX();
128 < globalCoords[0] + pBox->GetDX())
130 globalCoords[0] + pBox->GetDX();
148 sprintf(fileName,
"%s.root", name);
150 TFile* curFile = TFile::CurrentFile();
151 TFile*
f =
new TFile(fileName);
153 if (!
f->IsZombie()) {
154 TH1F*
h =
static_cast<TH1F*
>(
f->Get(name));
155 retVal =
h->GetRMS();
160 TFile::CurrentFile() = curFile;
168 new TH1F(
"signalDistanceHisto",
"signalDistanceHisto", 200, 0., 800.);
172 pair<int, int> stSpatLimits[] = {{20, 20}, {20, 20}, {20, 20}, {20, 20}};
183 for (
int i = 0;
i < 4; ++
i) {
192 for (
int i = 1;
i < 4; ++
i) {
194 sprintf(name,
"trdDeltaThetaX_%d",
i);
195 Double_t deltaThetaX = 0;
197 if (!
GetHistoRMS(name, deltaThetaX))
return kFATAL;
200 sprintf(name,
"trdDeltaThetaY_%d",
i);
201 Double_t deltaThetaY = 0;
203 if (!
GetHistoRMS(name, deltaThetaY))
return kFATAL;
211 FairRootManager* ioman = FairRootManager::Instance();
213 if (0 == ioman) LOG(fatal) <<
"No FairRootManager";
215 Int_t nofEventsInFile = ioman->CheckMaxEventNo();
219 fTrdHits =
static_cast<TClonesArray*
>(ioman->GetObject(
"TrdHit"));
221 fTrdTracks =
new TClonesArray(
"CbmTrdTrack", 100);
222 LOG(info) <<
"IsOutputBranchPersistent(TrdTrack) is: "
223 << (IsOutputBranchPersistent(
"TrdTrack") ?
"true" :
"false");
225 "TrdTrack",
"Trd",
fTrdTracks, IsOutputBranchPersistent(
"TrdTrack"));
228 LOG(info) <<
"IsOutputBranchPersistent(GlobalTrack) is: "
229 << (IsOutputBranchPersistent(
"GlobalTrack") ?
"true" :
"false");
230 ioman->Register(
"GlobalTrack",
233 IsOutputBranchPersistent(
"GlobalTrack"));
239 fTrdClusters =
static_cast<TClonesArray*
>(ioman->GetObject(
"TrdCluster"));
241 static_cast<TClonesArray*
>(ioman->GetObject(
"TrdDigiMatch"));
246 fMCTracks.push_back(vector<TrackDataHolder>());
248 if (0 >= evSize)
continue;
250 vector<TrackDataHolder>& evTracks =
fMCTracks.back();
252 for (
int j = 0; j < evSize; ++j) {
257 evTracks.back().z = mcTrack->
GetStartZ();
266 evTracks.back().isSignal =
true;
273 fTrdPoints.push_back(vector<PointDataHolder>());
275 if (0 >= evSize)
continue;
277 vector<PointDataHolder>& evPoints =
fTrdPoints.back();
279 for (
int j = 0; j < evSize; ++j) {
290 trdPt.
trackId = pTrdPt->GetTrackID();
293 evPoints.push_back(trdPt);
301 for (vector<vector<TrackDataHolder>>::iterator
i =
fMCTracks.begin();
304 vector<TrackDataHolder>& evTracks = *
i;
305 list<TrackDataHolder*> eles;
306 list<TrackDataHolder*> poss;
308 for (vector<TrackDataHolder>::iterator j = evTracks.begin();
313 if (11 == track.
pdg && 15 > track.
z) {
323 if (use) eles.push_back(&track);
324 }
else if (-11 == track.
pdg && 15 > track.
z) {
334 if (use) poss.push_back(&track);
367 for (list<TrackDataHolder*>::const_iterator k = eles.begin();
372 for (list<TrackDataHolder*>::const_iterator l = poss.begin();
381 sqrt((posPt.
x - negPt.
x) * (posPt.
x - negPt.
x)
382 + (posPt.
y - negPt.
y) * (posPt.
y - negPt.
y)));
419 for (
int i = 0;
i <
fTrdHits->GetEntriesFast(); ++
i) {
444 for (Int_t j = 0; j < nDigis; ++j) {
449 for (Int_t k = 0; k < nMCs; ++k) {
453 const FairMCPoint* pMCPt =
static_cast<const FairMCPoint*
>(
455 Int_t trackId = pMCPt->GetTrackID();
457 point.
mcRefs.push_back(ptDesc);
476 int yInd = (
y - minY) / binSizeY;
480 else if (yInd > lastYBin)
484 int xInd = (
x - minX) / binSizeX;
488 else if (xInd > lastXBin)
492 xBin.
points.push_back(point);
512 for (list<LxTbBinnedFinder::Chain*>::const_iterator j =
513 recoTracksBin.begin();
514 j != recoTracksBin.end();
521 for (
int k = 0; k < chain->
nofPoints; ++k)
566 if (
x.eventId <
y.eventId)
return true;
568 return x.trackId <
y.trackId;
573 TFile* curFile = TFile::CurrentFile();
574 TString histoName = histo->GetName();
575 histoName +=
".root";
576 TFile fh(histoName.Data(),
"RECREATE");
580 TFile::CurrentFile() = curFile;
585 cout <<
"LxTbBinnedFinder::Reconstruct() the number of found tracks: "
586 << nofRecoTracks << endl;
588 static int nofSignalTracks = 0;
589 static int nofRecoSignalTracks = 0;
592 for (vector<vector<TrackDataHolder>>::iterator
i =
fMCTracks.begin();
595 vector<TrackDataHolder>& evTracks = *
i;
597 for (vector<TrackDataHolder>::iterator j = evTracks.begin();
606 int nofMatchPoints = 0;
608 for (list<LxTbBinnedFinder::Chain*>::const_iterator k =
615 bool pointsMatched =
false;
617 for (list<LxTbBinnedPoint::PointDesc>::const_iterator
m =
621 if (
m->eventId == eventN &&
m->pointId == track.
pointInds[l]) {
622 pointsMatched =
true;
627 if (pointsMatched) ++nofMatchPoints;
632 ++nofRecoSignalTracks;
641 0 == nofSignalTracks ? 100 : 100.0 * nofRecoSignalTracks / nofSignalTracks;
642 cout <<
"Reconstruction efficiency is: " << eff <<
"% [ "
643 << nofRecoSignalTracks <<
" / " << nofSignalTracks <<
" ]" << endl;
645 int nofRightRecoTracks = 0;
646 map<Int_t, pair<list<LxTbBinnedPoint*>, list<LxTbBinnedPoint*>>>
649 for (list<LxTbBinnedFinder::Chain*>::const_iterator
i =
recoTracks.begin();
653 map<RecoTrackData, int, RTDLess> nofTracks;
658 for (list<LxTbBinnedPoint::PointDesc>::const_iterator k =
663 map<RecoTrackData, int, RTDLess>::iterator nofTIter =
666 if (nofTIter != nofTracks.end())
667 nofTIter->second |= stMask;
669 nofTracks[st] = stMask;
676 for (map<RecoTrackData, int, RTDLess>::const_iterator j = nofTracks.begin();
677 j != nofTracks.end();
682 if (j->second & (1 << k)) ++nofp;
685 if (nofp > nofPoints) {
687 bestMCTrack = &j->first;
692 ++nofRightRecoTracks;
697 elecPositrons[bestMCTrack->
eventId].first.push_back(chain->
points[0]);
700 elecPositrons[bestMCTrack->
eventId].second.push_back(
707 0 ==
recoTracks.size() ? 100 : 100.0 * nofRightRecoTracks / nofRecoTracks;
708 cout <<
"Non ghosts are: " << eff <<
"% [ " << nofRightRecoTracks <<
" / "
709 << nofRecoTracks <<
" ]" << endl;
711 int nofTriggPairs = 0;
714 pair<list<LxTbBinnedPoint*>, list<LxTbBinnedPoint*>>>::iterator
i =
715 elecPositrons.begin();
716 i != elecPositrons.end();
718 list<LxTbBinnedPoint*>& evEls =
i->second.first;
719 list<LxTbBinnedPoint*>& evPos =
i->second.second;
720 bool trigPair =
false;
722 for (list<LxTbBinnedPoint*>::const_iterator j = evEls.begin();
729 for (list<LxTbBinnedPoint*>::const_iterator k = evPos.begin();
736 if (
sqrt((posX - negX) * (posX - negX) + (posY - negY) * (posY - negY))
742 if (trigPair) ++nofTriggPairs;
745 cout <<
"NOF triggering events: " << nofTriggPairs << endl;