14 #include "TClonesArray.h"
15 #include "TGeoManager.h"
19 #include "FairEventHeader.h"
20 #include "FairLogger.h"
37 using std::setprecision;
43 : FairTask(
"STSFindTracksQA", iVerbose)
55 , fTargetPos(0., 0., 0.)
60 , fhMomAccAll(new TH1F())
61 , fhMomRecAll(new TH1F())
62 , fhMomEffAll(new TH1F())
63 , fhMomAccPrim(new TH1F())
64 , fhMomRecPrim(new TH1F())
65 , fhMomEffPrim(new TH1F())
66 , fhMomAccSec(new TH1F())
67 , fhMomRecSec(new TH1F())
68 , fhMomEffSec(new TH1F())
69 , fhNpAccAll(new TH1F())
70 , fhNpRecAll(new TH1F())
71 , fhNpEffAll(new TH1F())
72 , fhNpAccPrim(new TH1F())
73 , fhNpRecPrim(new TH1F())
74 , fhNpEffPrim(new TH1F())
75 , fhNpAccSec(new TH1F())
76 , fhNpRecSec(new TH1F())
77 , fhNpEffSec(new TH1F())
78 , fhZAccSec(new TH1F())
79 , fhZRecSec(new TH1F())
80 , fhZEffSec(new TH1F())
81 , fhNhClones(new TH1F())
82 , fhNhGhosts(new TH1F())
83 , fHistoList(new TList())
106 : FairTask(
"STSFindTracksQA", iVerbose)
118 , fTargetPos(0., 0., 0.)
121 , fMinStations(minStations)
123 , fhMomAccAll(new TH1F())
124 , fhMomRecAll(new TH1F())
125 , fhMomEffAll(new TH1F())
126 , fhMomAccPrim(new TH1F())
127 , fhMomRecPrim(new TH1F())
128 , fhMomEffPrim(new TH1F())
129 , fhMomAccSec(new TH1F())
130 , fhMomRecSec(new TH1F())
131 , fhMomEffSec(new TH1F())
132 , fhNpAccAll(new TH1F())
133 , fhNpRecAll(new TH1F())
134 , fhNpEffAll(new TH1F())
135 , fhNpAccPrim(new TH1F())
136 , fhNpRecPrim(new TH1F())
137 , fhNpEffPrim(new TH1F())
138 , fhNpAccSec(new TH1F())
139 , fhNpRecSec(new TH1F())
140 , fhNpEffSec(new TH1F())
141 , fhZAccSec(new TH1F())
142 , fhZRecSec(new TH1F())
143 , fhZEffSec(new TH1F())
144 , fhNhClones(new TH1F())
145 , fhNhGhosts(new TH1F())
146 , fHistoList(new TList())
178 Int_t nEvents =
fEvents->GetEntriesFast();
179 LOG(debug) << GetName() <<
": found time slice with " << nEvents
182 for (Int_t iEvent = 0; iEvent < nEvents; iEvent++) {
205 LOG(info) <<
"\n\n====================================================";
206 LOG(info) << GetName() <<
": Initialising...";
209 FairRootManager* ioman = FairRootManager::Instance();
229 fEvents =
dynamic_cast<TClonesArray*
>(ioman->GetObject(
"Event"));
232 fStsHits = (TClonesArray*) ioman->GetObject(
"StsHit");
236 fStsHitMatch = (TClonesArray*) ioman->GetObject(
"StsHitMatch");
240 fStsTracks = (TClonesArray*) ioman->GetObject(
"StsTrack");
244 fMatches = (TClonesArray*) ioman->GetObject(
"StsTrackMatch");
250 if (geoStatus != kSUCCESS) {
251 LOG(error) << GetName() <<
"::Init: Error in reading geometry!";
260 LOG(info) <<
" Number of STS stations : " <<
fNStations;
261 LOG(info) <<
" Target position ( " <<
fTargetPos.X() <<
", "
263 LOG(info) <<
" Minimum number of STS stations : " <<
fMinStations;
264 LOG(info) <<
" Matching quota : " <<
fQuota;
265 LOG(info) <<
"====================================================";
275 LOG(info) <<
"\n\n====================================================";
276 LOG(info) << GetName() <<
": Re-initialising...";
280 if (geoStatus != kSUCCESS) {
281 LOG(error) << GetName() <<
"::Init: Error in reading geometry!";
286 LOG(info) <<
" Number of STS stations : " <<
fNStations;
287 LOG(info) <<
" Target position ( " <<
fTargetPos.X() <<
", "
289 LOG(info) <<
" Minimum number of STS stations : " <<
fMinStations;
290 LOG(info) <<
" Matching quota : " <<
fQuota;
291 LOG(info) <<
"====================================================";
303 (
event ?
event->GetNumber()
304 : FairRun::Instance()->GetEventHeader()->GetMCEntryNumber() - 1);
306 LOG(debug) << GetName() <<
": Process event " <<
eventNumber;
334 for (Int_t mcTrackId = 0; mcTrackId < nMcTracks; mcTrackId++) {
342 Int_t nStations =
fHitMap[mcTrackId].size();
350 Bool_t isPrim = kFALSE;
351 if (TMath::Abs(vertex.Z() -
fTargetPos.Z()) < 1.) {
359 Double_t mom = momentum.Mag();
360 Bool_t isRef = kFALSE;
361 if (mom > 1. && isPrim) {
396 assert(nTrue + nWrong + nFake == nAllHits);
399 LOG(debug1) << GetName() <<
": MCTrack " << mcTrackId <<
", stations "
400 << nStations <<
", hits " << nAllHits <<
", true hits "
411 if (isRef) nRecRef++;
425 Double_t effAll = Double_t(nRecAll) / Double_t(nAcc);
426 Double_t effPrim = Double_t(nRecPrim) / Double_t(nPrim);
427 Double_t effRef = Double_t(nRecRef) / Double_t(nRef);
428 Double_t effSec = Double_t(nRecSec) / Double_t(nSec);
434 LOG(info) <<
"+ " << setw(20) << GetName() <<
": Event " << setw(6) << right
435 <<
fNEvents <<
", real time " << fixed << setprecision(6)
436 <<
fTimer.RealTime() <<
" s, MC tracks: all " << nMcTracks
437 <<
", acc. " << nAcc <<
", rec. " << nRecAll <<
", eff. "
438 << setprecision(2) << 100. * effAll <<
" %";
439 if (FairLogger::GetLogger()->IsLogNeeded(fair::Severity::debug)) {
440 LOG(debug) <<
"---------- StsFindTracksQa : Event summary ------------";
441 LOG(debug) <<
"MCTracks : " << nAll <<
", reconstructible: " << nAcc
442 <<
", reconstructed: " << nRecAll;
443 LOG(debug) <<
"Vertex : reconstructible: " << nPrim
444 <<
", reconstructed: " << nRecPrim <<
", efficiency "
445 << effPrim * 100. <<
"%";
446 LOG(debug) <<
"Reference : reconstructible: " << nRef
447 <<
", reconstructed: " << nRecRef <<
", efficiency "
448 << effRef * 100. <<
"%";
449 LOG(debug) <<
"Non-vertex : reconstructible: " << nSec
450 <<
", reconstructed: " << nRecSec <<
", efficiency "
451 << effSec * 100. <<
"%";
452 LOG(debug) <<
"STSTracks " << nTracks <<
", ghosts " << nGhosts
453 <<
", clones " << nClones;
455 <<
"-----------------------------------------------------------\n";
503 std::cout << std::endl;
504 LOG(info) <<
"=====================================";
505 LOG(info) << fName <<
": Run summary ";
506 LOG(info) <<
"Events processed : " <<
fNEvents << setprecision(2);
507 LOG(info) <<
"Eff. all tracks : " << effAll * 100 <<
" % (" <<
fNRecAll
509 LOG(info) <<
"Eff. vertex tracks : " << effPrim * 100 <<
" % ("
511 LOG(info) <<
"Eff. reference tracks : " << effRef * 100 <<
" % (" <<
fNRecRef
513 LOG(info) <<
"Eff. secondary tracks : " << effSec * 100 <<
" % (" <<
fNRecSec
515 LOG(info) <<
"Ghost rate : " << rateGhosts <<
" per event";
516 LOG(info) <<
"Clone rate : " << rateClones <<
" per event";
517 LOG(info) <<
"Time per event : " << setprecision(6)
519 LOG(info) <<
"=====================================";
522 gDirectory->mkdir(
"STSFindTracksQA");
523 gDirectory->cd(
"STSFindTracksQA");
525 while (TH1* histo = ((TH1*) next()))
527 gDirectory->cd(
"..");
549 TGeoNode* target = NULL;
551 gGeoManager->CdTop();
552 TGeoNode* cave = gGeoManager->GetCurrentNode();
553 for (Int_t iNode1 = 0; iNode1 < cave->GetNdaughters(); iNode1++) {
554 TString name = cave->GetDaughter(iNode1)->GetName();
555 if (name.Contains(
"pipe", TString::kIgnoreCase)) {
556 LOG(debug) <<
"Found pipe node " << name;
557 gGeoManager->CdDown(iNode1);
561 for (Int_t iNode2 = 0;
562 iNode2 < gGeoManager->GetCurrentNode()->GetNdaughters();
565 gGeoManager->GetCurrentNode()->GetDaughter(iNode2)->GetName();
566 if (name.Contains(
"pipevac1", TString::kIgnoreCase)) {
567 LOG(debug) <<
"Found vacuum node " << name;
568 gGeoManager->CdDown(iNode2);
572 for (Int_t iNode3 = 0;
573 iNode3 < gGeoManager->GetCurrentNode()->GetNdaughters();
576 gGeoManager->GetCurrentNode()->GetDaughter(iNode3)->GetName();
577 if (name.Contains(
"target", TString::kIgnoreCase)) {
578 LOG(debug) <<
"Found target node " << name;
579 gGeoManager->CdDown(iNode3);
580 target = gGeoManager->GetCurrentNode();
589 TGeoHMatrix* glbMatrix = gGeoManager->GetCurrentMatrix();
590 Double_t*
pos = glbMatrix->GetTranslation();
596 gGeoManager->CdTop();
608 Double_t minMom = 0.;
609 Double_t maxMom = 10.;
612 "hMomAccAll",
"all reconstructable tracks", nBinsMom, minMom, maxMom);
614 "hMomRecAll",
"all reconstructed tracks", nBinsMom, minMom, maxMom);
616 new TH1F(
"hMomEffAll",
"efficiency all tracks", nBinsMom, minMom, maxMom);
618 "hMomAccPrim",
"reconstructable vertex tracks", nBinsMom, minMom, maxMom);
620 "hMomRecPrim",
"reconstructed vertex tracks", nBinsMom, minMom, maxMom);
622 "hMomEffPrim",
"efficiency vertex tracks", nBinsMom, minMom, maxMom);
624 "reconstructable non-vertex tracks",
629 "hMomRecSec",
"reconstructed non-vertex tracks", nBinsMom, minMom, maxMom);
631 "hMomEffSec",
"efficiency non-vertex tracks", nBinsMom, minMom, maxMom);
643 Double_t minNp = -0.5;
644 Double_t maxNp = 15.5;
647 new TH1F(
"hNpAccAll",
"all reconstructable tracks", nBinsNp, minNp, maxNp);
649 new TH1F(
"hNpRecAll",
"all reconstructed tracks", nBinsNp, minNp, maxNp);
651 new TH1F(
"hNpEffAll",
"efficiency all tracks", nBinsNp, minNp, maxNp);
653 "hNpAccPrim",
"reconstructable vertex tracks", nBinsNp, minNp, maxNp);
655 "hNpRecPrim",
"reconstructed vertex tracks", nBinsNp, minNp, maxNp);
657 new TH1F(
"hNpEffPrim",
"efficiency vertex tracks", nBinsNp, minNp, maxNp);
659 "hNpAccSec",
"reconstructable non-vertex tracks", nBinsNp, minNp, maxNp);
661 "hNpRecSec",
"reconstructed non-vertex tracks", nBinsNp, minNp, maxNp);
663 "hNpEffSec",
"efficiency non-vertex tracks", nBinsNp, minNp, maxNp);
679 "hZAccSec",
"reconstructable non-vertex tracks", nBinsZ, minZ, maxZ);
681 "hZRecSecl",
"reconstructed non-vertex tracks", nBinsZ, minZ, maxZ);
683 new TH1F(
"hZEffRec",
"efficiency non-vertex tracks", nBinsZ, minZ, maxZ);
690 new TH1F(
"hNhClones",
"number of hits for clones", nBinsNp, minNp, maxNp);
692 new TH1F(
"hNhGhosts",
"number of hits for ghosts", nBinsNp, minNp, maxNp);
703 while (TH1* histo = ((TH1*) next()))
718 (
event ?
event->GetNumber()
719 : FairRun::Instance()->GetEventHeader()->GetMCEntryNumber() - 1);
725 for (Int_t iHit = 0; iHit < nHits; iHit++) {
731 assert(pointIndex >= 0);
735 Int_t mcTrackIndex = stsPoint->GetTrackID();
737 fHitMap[mcTrackIndex][station]++;
739 LOG(debug) << GetName() <<
": Filled hit map from " << nHits
740 <<
" STS hits for " <<
fHitMap.size() <<
" MCTracks.";
761 for (Int_t iTrack = 0; iTrack < nTracks; iTrack++) {
776 Int_t mcTrackId = -1;
785 Double_t quali = Double_t(nTrue) / Double_t(nHits);
819 LOG(debug) << GetName() <<
": Filled match map for " << nRec
820 <<
" STS tracks. Ghosts " << nGhosts <<
" Clones " << nClones;
828 if (!histo1 || !histo2 || !histo3) {
829 LOG(fatal) << GetName() <<
"::DivideHistos: "
830 <<
"NULL histogram pointer";
833 Int_t nBins = histo1->GetNbinsX();
834 if (histo2->GetNbinsX() != nBins || histo3->GetNbinsX() != nBins) {
835 LOG(error) << GetName() <<
"::DivideHistos: "
836 <<
"Different bin numbers in histos";
837 LOG(error) << histo1->GetName() <<
" " << histo1->GetNbinsX();
838 LOG(error) << histo2->GetName() <<
" " << histo2->GetNbinsX();
839 LOG(error) << histo3->GetName() <<
" " << histo3->GetNbinsX();
843 Double_t c1, c2, c3, ce;
844 for (Int_t iBin = 0; iBin < nBins; iBin++) {
845 c1 = histo1->GetBinContent(iBin);
846 c2 = histo2->GetBinContent(iBin);
849 Double_t c4 = (c3 * (1. - c3) / c2);
851 ce = TMath::Sqrt(c3 * (1. - c3) / c2);
859 histo3->SetBinContent(iBin, c3);
860 histo3->SetBinError(iBin, ce);