18#include "TClonesArray.h"
19#include "TGeoManager.h"
23#include "FairEventHeader.h"
42#include "FairRunAna.h"
46using std::setprecision;
58 : FairTask(
"STSFindTracksQA", iVerbose)
59 , fMinStations(minStations)
80 LOG(debug) << GetName() <<
": Process event ";
98 Int_t nRecRefLong = 0;
110 std::sort(events.begin(), events.end());
112 for (uint iLink = 0; iLink < events.size(); iLink++) {
115 for (Int_t iTr = 0; iTr <
nMCTracks; iTr++) {
131 const CbmLink& link = itTrack->first;
138 Int_t nStations = info.
fHitMap.size();
141 int nContStations = 0;
145 for (
auto itSta = info.
fHitMap.begin(); itSta != info.
fHitMap.end(); itSta++) {
146 if (len == 0 || itSta->first == istaprev + 1) {
152 if (nContStations < len) {
155 istaprev = itSta->first;
166 Bool_t isPrim = kFALSE;
167 if (TMath::Abs(vertex.Z() -
fTargetPos.Z()) < 1.) {
176 Double_t mom = momentum.Mag();
177 Bool_t isRef = kFALSE;
178 if (mom > 1. && isPrim) {
183 Bool_t isRefLong = kFALSE;
204 Double_t quali = info.
fQuali;
221 assert(nTrue + nWrong + nFake == nAllHits);
223 LOG(debug1) << GetName() <<
": MCTrack " << iMcTrack <<
", stations " << nStations <<
", hits " << nAllHits
224 <<
", true hits " << nTrue;
241 if (isRef) nRecRef++;
242 if (isRefLong) nRecRefLong++;
249 Double_t effAll = Double_t(nRecAll) / Double_t(nAcc);
250 Double_t effPrim = Double_t(nRecPrim) / Double_t(nPrim);
251 Double_t effRef = Double_t(nRecRef) / Double_t(nRef);
252 Double_t effRefLong = Double_t(nRecRefLong) / Double_t(nRefLong);
253 Double_t effSec = Double_t(nRecSec) / Double_t(nSec);
259 LOG(info) <<
"+ " << setw(20) << GetName() <<
": Event " << setw(6) << right <<
fNEvents <<
", real time " << fixed
260 << setprecision(6) <<
fTimer.RealTime() <<
" s, MC tracks: all " << nMcTracks <<
", acc. " << nAcc
261 <<
", rec. " << nRecAll <<
", eff. " << setprecision(2) << 100. * effAll <<
" %";
262 if (fair::Logger::Logging(fair::Severity::debug)) {
263 LOG(debug) <<
"---------- StsFindTracksQa : Event summary ------------";
264 LOG(debug) <<
"MCTracks : " << nAll <<
", reconstructible: " << nAcc <<
", reconstructed: " << nRecAll;
265 LOG(debug) <<
"Vertex : reconstructible: " << nPrim <<
", reconstructed: " << nRecPrim <<
", efficiency "
266 << effPrim * 100. <<
"%";
267 LOG(debug) <<
"Reference : reconstructible: " << nRef <<
", reconstructed: " << nRecRef <<
", efficiency "
268 << effRef * 100. <<
"%";
269 LOG(debug) <<
"Reference long : reconstructible: " << nRefLong <<
", reconstructed: " << nRecRefLong
270 <<
", efficiency " << effRefLong * 100. <<
"%";
271 LOG(debug) <<
"Non-vertex : reconstructible: " << nSec <<
", reconstructed: " << nRecSec <<
", efficiency "
272 << effSec * 100. <<
"%";
273 LOG(debug) <<
"STSTracks " << nTracks <<
", ghosts " << nGhosts <<
", clones " << nClones;
274 LOG(debug) <<
"-----------------------------------------------------------\n";
307 LOG(info) <<
"\n\n====================================================";
308 LOG(info) << GetName() <<
": Initialising...";
317 fManager = FairRootManager::Instance();
327 LOG(fatal) <<
"CbmStsFindTracksQa: No time slice object";
340 if (geoStatus != kSUCCESS) {
341 LOG(error) << GetName() <<
"::Init: Error in reading geometry!";
355 LOG(warning) <<
"CbmStsFindTracksQa: MVD hits are missing, MVD will not be "
356 "included to the STS track match";
397 LOG(info) <<
" Minimum number of STS stations : " <<
fMinStations;
398 LOG(info) <<
" Matching quota : " <<
fQuota;
399 LOG(info) <<
"====================================================";
410 LOG(info) <<
"\n\n====================================================";
411 LOG(info) << GetName() <<
": Re-initialising...";
415 if (geoStatus != kSUCCESS) {
416 LOG(error) << GetName() <<
"::Init: Error in reading geometry!";
423 LOG(info) <<
" Minimum number of STS stations : " <<
fMinStations;
424 LOG(info) <<
" Matching quota : " <<
fQuota;
425 LOG(info) <<
"====================================================";
461 std::cout << std::endl;
462 LOG(info) <<
"=====================================";
463 LOG(info) << fName <<
": Run summary ";
464 LOG(info) <<
"Events processed : " <<
fNEvents << setprecision(2);
465 LOG(info) <<
"Eff. all tracks : " << effAll * 100 <<
" % (" <<
fNRecAll <<
"/" <<
fNAccAll <<
")";
466 LOG(info) <<
"Eff. vertex tracks : " << effPrim * 100 <<
" % (" <<
fNRecPrim <<
"/" <<
fNAccPrim <<
")";
467 LOG(info) <<
"Eff. reference tracks : " << effRef * 100 <<
" % (" <<
fNRecRef <<
"/" <<
fNAccRef <<
")";
470 LOG(info) <<
"Eff. secondary tracks : " << effSec * 100 <<
" % (" <<
fNRecSec <<
"/" <<
fNAccSec <<
")";
471 LOG(info) <<
"Ghost rate : " << rateGhosts * 100 <<
" % (" <<
fNGhosts <<
"/" <<
fNRecAll <<
")";
472 LOG(info) <<
"Clone rate : " << rateClones * 100 <<
" % (" <<
fNClones <<
"/" <<
fNRecAll <<
")";
474 LOG(info) <<
"Time per event : " << setprecision(6) <<
fTime / Double_t(
fNEvents) <<
" s";
477 LOG(warning) <<
"CbmStsFindTracksQa: MVD hits are missing, MVD is not "
478 "included to the STS track match";
481 LOG(info) <<
"=====================================";
492 FairSink* sink = FairRootManager::Instance()->GetSink();
507 if (
fManager->GetObject(
"MvdHit")) {
511 assert(mvdStationPar);
526 TGeoNode* target = NULL;
528 gGeoManager->CdTop();
529 TGeoNode* cave = gGeoManager->GetCurrentNode();
530 for (Int_t iNode1 = 0; iNode1 < cave->GetNdaughters(); iNode1++) {
531 TString name = cave->GetDaughter(iNode1)->GetName();
532 if (name.Contains(
"pipe", TString::kIgnoreCase)) {
533 LOG(debug) <<
"Found pipe node " << name;
534 gGeoManager->CdDown(iNode1);
538 for (Int_t iNode2 = 0; iNode2 < gGeoManager->GetCurrentNode()->GetNdaughters(); iNode2++) {
539 TString name = gGeoManager->GetCurrentNode()->GetDaughter(iNode2)->GetName();
540 if (name.Contains(
"pipevac1", TString::kIgnoreCase)) {
541 LOG(debug) <<
"Found vacuum node " << name;
542 gGeoManager->CdDown(iNode2);
546 for (Int_t iNode3 = 0; iNode3 < gGeoManager->GetCurrentNode()->GetNdaughters(); iNode3++) {
547 TString name = gGeoManager->GetCurrentNode()->GetDaughter(iNode3)->GetName();
548 if (name.Contains(
"target", TString::kIgnoreCase)) {
549 LOG(debug) <<
"Found target node " << name;
550 gGeoManager->CdDown(iNode3);
551 target = gGeoManager->GetCurrentNode();
561 TGeoHMatrix* glbMatrix = gGeoManager->GetCurrentMatrix();
562 Double_t*
pos = glbMatrix->GetTranslation();
568 gGeoManager->CdTop();
583 Double_t minMom = 0.;
584 Double_t maxMom = 10.;
586 fhMomAccAll =
new TH1F(
"hMomAccAll",
"all reconstructable tracks", nBinsMom, minMom, maxMom);
587 fhMomRecAll =
new TH1F(
"hMomRecAll",
"all reconstructed tracks", nBinsMom, minMom, maxMom);
588 fhMomEffAll =
new TH1F(
"hMomEffAll",
"efficiency all tracks", nBinsMom, minMom, maxMom);
589 fhMomAccPrim =
new TH1F(
"hMomAccPrim",
"reconstructable vertex tracks", nBinsMom, minMom, maxMom);
590 fhMomRecPrim =
new TH1F(
"hMomRecPrim",
"reconstructed vertex tracks", nBinsMom, minMom, maxMom);
591 fhMomEffPrim =
new TH1F(
"hMomEffPrim",
"efficiency vertex tracks", nBinsMom, minMom, maxMom);
592 fhMomAccSec =
new TH1F(
"hMomAccSec",
"reconstructable non-vertex tracks", nBinsMom, minMom, maxMom);
593 fhMomRecSec =
new TH1F(
"hMomRecSec",
"reconstructed non-vertex tracks", nBinsMom, minMom, maxMom);
594 fhMomEffSec =
new TH1F(
"hMomEffSec",
"efficiency non-vertex tracks", nBinsMom, minMom, maxMom);
606 Double_t minNp = -0.5;
607 Double_t maxNp = 15.5;
609 fhNpAccAll =
new TH1F(
"hNpAccAll",
"all reconstructable tracks", nBinsNp, minNp, maxNp);
610 fhNpRecAll =
new TH1F(
"hNpRecAll",
"all reconstructed tracks", nBinsNp, minNp, maxNp);
611 fhNpEffAll =
new TH1F(
"hNpEffAll",
"efficiency all tracks", nBinsNp, minNp, maxNp);
612 fhNpAccPrim =
new TH1F(
"hNpAccPrim",
"reconstructable vertex tracks", nBinsNp, minNp, maxNp);
613 fhNpRecPrim =
new TH1F(
"hNpRecPrim",
"reconstructed vertex tracks", nBinsNp, minNp, maxNp);
614 fhNpEffPrim =
new TH1F(
"hNpEffPrim",
"efficiency vertex tracks", nBinsNp, minNp, maxNp);
615 fhNpAccSec =
new TH1F(
"hNpAccSec",
"reconstructable non-vertex tracks", nBinsNp, minNp, maxNp);
616 fhNpRecSec =
new TH1F(
"hNpRecSec",
"reconstructed non-vertex tracks", nBinsNp, minNp, maxNp);
617 fhNpEffSec =
new TH1F(
"hNpEffSec",
"efficiency non-vertex tracks", nBinsNp, minNp, maxNp);
632 fhZAccSec =
new TH1F(
"hZAccSec",
"reconstructable non-vertex tracks", nBinsZ, minZ, maxZ);
633 fhZRecSec =
new TH1F(
"hZRecSecl",
"reconstructed non-vertex tracks", nBinsZ, minZ, maxZ);
634 fhZEffSec =
new TH1F(
"hZEffRec",
"efficiency non-vertex tracks", nBinsZ, minZ, maxZ);
640 fhNhClones =
new TH1F(
"hNhClones",
"number of hits for clones", nBinsNp, minNp, maxNp);
641 fhNhGhosts =
new TH1F(
"hNhGhosts",
"number of hits for ghosts", nBinsNp, minNp, maxNp);
646 while (TH1* histo = ((TH1*) next())) {
658 while (TH1* histo = ((TH1*) next()))
680 for (Int_t iHit = 0; iHit <
fMvdHits->GetEntriesFast(); iHit++) {
699 for (Int_t iHit = 0; iHit <
fStsHits->GetEntriesFast(); iHit++) {
724 LOG(debug) << GetName() <<
": Filled hit map from " <<
fStsHits->GetEntriesFast() <<
" STS hits";
747 for (Int_t iTrack = 0; iTrack < nTracks; iTrack++) {
756 assert(iTrack >= 0 && iTrack < fStsTrackMatches->GetEntriesFast());
762 Double_t quali = Double_t(nTrue) / Double_t(nHits);
800 LOG(debug) << GetName() <<
": Filled match map for " << nRec <<
" STS tracks. Ghosts " << nGhosts <<
" Clones "
810 if (!histo1 || !histo2 || !histo3) {
811 LOG(fatal) << GetName() <<
"::DivideHistos: "
812 <<
"NULL histogram pointer";
815 Int_t nBins = histo1->GetNbinsX();
816 if (histo2->GetNbinsX() != nBins || histo3->GetNbinsX() != nBins) {
817 LOG(error) << GetName() <<
"::DivideHistos: "
818 <<
"Different bin numbers in histos";
819 LOG(error) << histo1->GetName() <<
" " << histo1->GetNbinsX();
820 LOG(error) << histo2->GetName() <<
" " << histo2->GetNbinsX();
821 LOG(error) << histo3->GetName() <<
" " << histo3->GetNbinsX();
825 Double_t c1, c2, c3, ce;
826 for (Int_t iBin = 0; iBin < nBins; iBin++) {
827 c1 = histo1->GetBinContent(iBin);
828 c2 = histo2->GetBinContent(iBin);
831 Double_t c4 = (c3 * (1. - c3) / c2);
833 ce = TMath::Sqrt(c3 * (1. - c3) / c2);
843 histo3->SetBinContent(iBin, c3);
844 histo3->SetBinError(iBin, ce);
ClassImp(CbmConverterManager)
Data class for a reconstructed hit in the STS.
Data class for STS tracks.
int32_t GetAddress() const
void SetIndex(int32_t index)
TObject * Get(const CbmLink *lnk)
Int_t Size(Int_t fileNumber, Int_t eventNumber)
Task class creating and managing CbmMCDataArray objects.
CbmMCDataArray * InitBranch(const char *name)
void GetMomentum(TVector3 &momentum) const
void GetStartVertex(TVector3 &vertex) const
int32_t GetNofLinks() const
const CbmLink & GetMatchedLink() const
const std::vector< CbmLink > & GetLinks() const
static CbmMvdDetector * Instance()
CbmMvdStationPar * GetParameterFile()
virtual int32_t GetStationNr() const
Int_t GetStationCount() const
TClonesArray * fMvdHitMatch
std::map< CbmLink, McTrackInfo > fMcTrackInfoMap
CbmStsFindTracksQa(Int_t iVerbose=1)
CbmMCDataArray * fStsPoints
CbmMCDataArray * fMvdPoints
CbmMCDataManager * fMcManager
TClonesArray * fStsTracks
StsClusterMatch.
CbmStsSetup * fStsSetup
STS.
TVector3 fTargetPos
StsTrackMatch.
virtual InitStatus Init()
CbmTimeSlice * fTimeSlice
TClonesArray * fStsHits
StsPoints.
void FillMatchMap(Int_t &nRec, Int_t &nGhosts, Int_t &nClones)
CbmMCDataArray * fMCTracks
MC tracks.
TClonesArray * fStsClusterMatch
StsHitMatch.
virtual ~CbmStsFindTracksQa()
virtual void Exec(Option_t *opt)
TClonesArray * fMvdCluster
TH1F * fhMomAccAll
output folder with histos and canvases
McTrackInfo & getMcTrackInfo(const CbmLink &link)
TClonesArray * fStsHitMatch
StsHits.
FairRootManager * fManager
map track link -> track info
virtual void SetParContainers()
TClonesArray * fStsTrackMatches
StsTrack.
Bool_t fIsMvdActive
MCtrack.
void DivideHistos(TH1 *histo1, TH1 *histo2, TH1 *histo3)
virtual InitStatus ReInit()
data class for a reconstructed 3-d hit in the STS
int32_t GetFrontClusterId() const
int32_t GetBackClusterId() const
Bool_t Init(const char *geometryFile=nullptr)
Initialise the setup.
Int_t GetNofStations() const
static CbmStsSetup * Instance()
Int_t GetStationNumber(Int_t address)
Bool_t IsInit() const
Initialisation status for sensor parameters.
int32_t GetNofMvdHits() const
virtual int32_t GetTotalNofHits() const
int32_t GetNofStsHits() const
Bookkeeping of time-slice content.
const CbmMatch & GetMatch() const
int32_t GetNofWrongHits() const
int32_t GetNofTrueHits() const
Int_t fMatchedNHitsAll
percentage of matched hits
std::map< Int_t, Int_t > fHitMap
Int_t fStsTrackMatch
Mvd / Sts station -> number of attached hits.
Int_t fMatchedNHitsTrue
number of matched hits
Double_t fQuali
matched StsTrack index