29#include "TClonesArray.h"
34#include <FairRootManager.h>
38#include <boost/assign/list_of.hpp>
46 : fIsFixedBounds(true)
51 , fOutputDir(
"./test/")
58 , fStsTrackMatches(NULL)
62 , fTrdTrackMatches(NULL)
65 , fMuchTrackMatches(NULL)
66 , fMuchPixelHits(NULL)
67 , fMuchStripHits(NULL)
73 , fMCTrackCreator(NULL)
96 static Int_t nofEvents = 0;
98 std::cout <<
"CbmLitFitQa::Exec: event=" << nofEvents << std::endl;
107 TDirectory* oldir = gDirectory;
108 TFile* outFile = FairRootManager::Instance()->GetOutFile();
109 if (outFile != NULL) {
113 gDirectory->cd(oldir->GetPath());
123 FairRootManager* ioman = FairRootManager::Instance();
124 assert(ioman != NULL);
126 fGlobalTracks = (TClonesArray*) ioman->GetObject(
"GlobalTrack");
127 fStsTracks = (TClonesArray*) ioman->GetObject(
"StsTrack");
129 fStsHits = (TClonesArray*) ioman->GetObject(
"StsHit");
130 fMvdHits = (TClonesArray*) ioman->GetObject(
"MvdHit");
131 fMuchTracks = (TClonesArray*) ioman->GetObject(
"MuchTrack");
133 fMuchPixelHits = (TClonesArray*) ioman->GetObject(
"MuchPixelHit");
134 fMuchStripHits = (TClonesArray*) ioman->GetObject(
"MuchStripHit");
135 fTrdTracks = (TClonesArray*) ioman->GetObject(
"TrdTrack");
137 fTrdHits = (TClonesArray*) ioman->GetObject(
"TrdHit");
141 if (0 == mcManager) LOG(fatal) <<
"CbmMatchRecoToMC::ReadAndCreateDataBranches() NULL MCDataManager.";
144 fEvents =
dynamic_cast<TClonesArray*
>(ioman->GetObject(
"CbmEvent"));
161 for (Int_t iTrack = 0; iTrack < nofGlobalTracks; iTrack++) {
177 if (mcId < 0)
return;
185 if (nofStsHits < 1)
return;
192 const FairTrackParam* lastParam = track->
GetParamLast();
198 if (nofMvdHits > 0) {
235 if (mcId < 0)
return;
242 if (nofHits < 1)
return;
248 const FairTrackParam* lastParam = track->
GetParamLast();
279 if (mcId < 0)
return;
286 if (nofHits < 1)
return;
292 const FairTrackParam* lastParam = track->
GetParamLast();
324 Double_t resX = 0., resY = 0., resTx = 0., resTy = 0., resQp = 0.;
326 resX = par->GetX() - mcPoint->
GetX();
327 resY = par->GetY() - mcPoint->
GetY();
328 resTx = par->GetTx() - mcPoint->
GetTx();
329 resTy = par->GetTy() - mcPoint->
GetTy();
330 resQp = par->GetQp() - mcPoint->
GetQp();
333 resX = par->GetX() - mcPoint->
GetX();
334 resY = par->GetY() - mcPoint->
GetY();
335 resTx = par->GetTx() - mcPoint->
GetTx();
336 resTy = par->GetTy() - mcPoint->
GetTy();
337 resQp = par->GetQp() - mcPoint->
GetQp();
340 resX = par->GetX() - mcPoint->
GetXOut();
341 resY = par->GetY() - mcPoint->
GetYOut();
342 resTx = par->GetTx() - mcPoint->
GetTxOut();
343 resTy = par->GetTy() - mcPoint->
GetTyOut();
344 resQp = par->GetQp() - mcPoint->
GetQpOut();
347 resX = par->GetX() - mcPoint->
GetX();
348 resY = par->GetY() - mcPoint->
GetY();
349 resTx = par->GetTx() - mcPoint->
GetTx();
350 resTy = par->GetTy() - mcPoint->
GetTy();
351 resQp = par->GetQp() - mcPoint->
GetQp();
353 Double_t mcP = mcPoint->
GetP();
355 fHM->
H2(histName +
"Res_X")->Fill(mcP, resX);
356 fHM->
H2(histName +
"Res_Y")->Fill(mcP, resY);
357 fHM->
H2(histName +
"Res_Tx")->Fill(mcP, resTx);
358 fHM->
H2(histName +
"Res_Ty")->Fill(mcP, resTy);
359 fHM->
H2(histName +
"Res_Qp")->Fill(mcP, resQp);
365 Double_t sigmaX = (C[0] > 0.) ? std::sqrt(C[0]) : -1.;
366 Double_t sigmaY = (C[5] > 0.) ? std::sqrt(C[5]) : -1.;
367 Double_t sigmaTx = (C[9] > 0.) ? std::sqrt(C[9]) : -1.;
368 Double_t sigmaTy = (C[12] > 0.) ? std::sqrt(C[12]) : -1.;
369 Double_t sigmaQp = (C[14] > 0.) ? std::sqrt(C[14]) : -1.;
371 fHM->
H2(histName +
"WrongCov_X")->Fill(mcP, wrongPar);
373 fHM->
H2(histName +
"Pull_X")->Fill(mcP, resX / sigmaX);
375 fHM->
H2(histName +
"WrongCov_Y")->Fill(mcP, wrongPar);
377 fHM->
H2(histName +
"Pull_Y")->Fill(mcP, resY / sigmaY);
379 fHM->
H2(histName +
"WrongCov_Tx")->Fill(mcP, wrongPar);
381 fHM->
H2(histName +
"Pull_Tx")->Fill(mcP, resTx / sigmaTx);
383 fHM->
H2(histName +
"WrongCov_Ty")->Fill(mcP, wrongPar);
385 fHM->
H2(histName +
"Pull_Ty")->Fill(mcP, resTy / sigmaTy);
387 fHM->
H2(histName +
"WrongCov_Qp")->Fill(mcP, wrongPar);
389 fHM->
H2(histName +
"Pull_Qp")->Fill(mcP, resQp / sigmaQp);
394 fHM->
H1(histName +
"_X")->Fill(par->GetX());
395 fHM->
H1(histName +
"_Y")->Fill(par->GetY());
396 fHM->
H1(histName +
"_Z")->Fill(par->GetZ());
397 fHM->
H1(histName +
"_Tx")->Fill(par->GetTx());
398 fHM->
H1(histName +
"_Ty")->Fill(par->GetTy());
399 fHM->
H1(histName +
"_Qp")->Fill(par->GetQp());
400 Double_t p = (par->GetQp() != 0) ? std::fabs(1. / par->GetQp()) : 0.;
401 fHM->
H1(histName +
"_p")->Fill(p);
404 Double_t pt = std::sqrt(mom.X() * mom.X() + mom.Y() * mom.Y());
405 fHM->
H1(histName +
"_pt")->Fill(pt);
411 Int_t nofEvents =
fEvents->GetEntriesFast();
413 for (
int i = 0; i < nofEvents; ++i)
424 for (Int_t i = 0; i < nofTracks; ++i) {
432 if (mcId < 0)
continue;
444 fHM->
H1(
"htf_ChiPrimary")->Fill(chiPrimary);
446 FairTrackParam vtxTrack;
449 TVector3 momMC, momRec;
451 vtxTrack.Momentum(momRec);
453 Double_t dpp = 100. * (momMC.Mag() - momRec.Mag()) / momMC.Mag();
454 fHM->
H1(
"htf_MomRes_Mom")->Fill(momMC.Mag(), dpp);
462 for (
int i = 0; i < nofTracks; ++i) {
473 if (mcId < 0)
continue;
486 fHM->
H1(
"htp_PrimaryVertexResidualPx")->Fill(vtxParam->
GetPx() - momMC.x());
487 fHM->
H1(
"htp_PrimaryVertexResidualPy")->Fill(vtxParam->
GetPy() - momMC.y());
488 fHM->
H1(
"htp_PrimaryVertexResidualPz")->Fill(vtxParam->
GetPz() - momMC.z());
490 fHM->
H1(
"htp_PrimaryVertexPullPx")->Fill((vtxParam->
GetPx() - momMC.x()) / vtxParam->
GetDpx());
491 fHM->
H1(
"htp_PrimaryVertexPullPy")->Fill((vtxParam->
GetPy() - momMC.y()) / vtxParam->
GetDpy());
492 fHM->
H1(
"htp_PrimaryVertexPullPz")->Fill((vtxParam->
GetPz() - momMC.z()) / vtxParam->
GetDpz());
494 fHM->
H1(
"htp_PrimaryVertexResidualTx")->Fill(vtxParam->GetTx() - mcTrack->
GetPx() / mcTrack->
GetPz());
495 fHM->
H1(
"htp_PrimaryVertexResidualTy")->Fill(vtxParam->GetTy() - mcTrack->
GetPy() / mcTrack->
GetPz());
496 fHM->
H1(
"htp_PrimaryVertexResidualQp")->Fill(vtxParam->GetQp() - 1 / mcTrack->
GetP());
499 vtxParam->CovMatrix(cov);
500 fHM->
H1(
"htp_PrimaryVertexPullTx")
501 ->Fill((vtxParam->GetTx() - mcTrack->
GetPx() / mcTrack->
GetPz()) / TMath::Sqrt(cov[9]));
502 fHM->
H1(
"htp_PrimaryVertexPullTy")
503 ->Fill((vtxParam->GetTy() - mcTrack->
GetPy() / mcTrack->
GetPz()) / TMath::Sqrt(cov[12]));
504 fHM->
H1(
"htp_PrimaryVertexPullQp")->Fill((vtxParam->GetQp() - 1 / mcTrack->
GetP()) / TMath::Sqrt(cov[14]));
522 fHM->
Add(
"htf_ChiPrimary",
new TH1F(
"htf_ChiPrimary",
"htf_ChiPrimary;#chi_{primary}", 100, 0, 10));
523 fHM->
Add(
"htp_PrimaryVertexResidualPx",
524 new TH1F(
"htp_PrimaryVertexResidualPx",
"htp_PrimaryVertexResidualPx;[cm]", 200, -1., 1.));
525 fHM->
Add(
"htp_PrimaryVertexResidualPy",
526 new TH1F(
"htp_PrimaryVertexResidualPy",
"htp_PrimaryVertexResidualPy;[cm]", 200, -1., 1.));
527 fHM->
Add(
"htp_PrimaryVertexResidualPz",
528 new TH1F(
"htp_PrimaryVertexResidualPz",
"htp_PrimaryVertexResidualPz;[cm]", 200, -1., 1.));
529 fHM->
Add(
"htp_PrimaryVertexPullPx",
530 new TH1F(
"htp_PrimaryVertexPullPx",
"htp_PrimaryVertexPullPx;[cm]", 200, -5., 5.));
531 fHM->
Add(
"htp_PrimaryVertexPullPy",
532 new TH1F(
"htp_PrimaryVertexPullPy",
"htp_PrimaryVertexPullPy;[cm]", 200, -5., 5.));
533 fHM->
Add(
"htp_PrimaryVertexPullPz",
534 new TH1F(
"htp_PrimaryVertexPullPz",
"htp_PrimaryVertexPullPz;[cm]", 200, -5., 5.));
536 fHM->
Add(
"htp_PrimaryVertexResidualTx",
537 new TH1F(
"htp_PrimaryVertexResidualTx",
"htp_PrimaryVertexResidualTx;[cm]", 200, -1., 1.));
538 fHM->
Add(
"htp_PrimaryVertexResidualTy",
539 new TH1F(
"htp_PrimaryVertexResidualTy",
"htp_PrimaryVertexResidualTy;[cm]", 200, -1., 1.));
540 fHM->
Add(
"htp_PrimaryVertexResidualQp",
541 new TH1F(
"htp_PrimaryVertexResidualQ[",
"htp_PrimaryVertexResidualQp;[cm]", 200, -1., 1.));
542 fHM->
Add(
"htp_PrimaryVertexPullTx",
543 new TH1F(
"htp_PrimaryVertexPullTx",
"htp_PrimaryVertexPullTx;[cm]", 200, -5., 5.));
544 fHM->
Add(
"htp_PrimaryVertexPullTy",
545 new TH1F(
"htp_PrimaryVertexPullTy",
"htp_PrimaryVertexPullTy;[cm]", 200, -5., 5.));
546 fHM->
Add(
"htp_PrimaryVertexPullQp",
547 new TH1F(
"htp_PrimaryVertexPullQp",
"htp_PrimaryVertexPullQp;[cm]", 200, -5., 5.));
555 string parameterNames[] = {
"X",
"Y",
"Tx",
"Ty",
"Qp"};
559 "Residual X [cm]",
"Residual Y [cm]",
"Residual Tx",
"Residual Ty",
"Residual q/p [(GeV/c)^{-1}]",
560 "Pull X",
"Pull Y",
"Pull Tx",
"Pull Ty",
"Pull q/p",
561 "Number of hits",
"Number of hits",
"Number of hits",
"Number of hits",
"Number of hits"};
564 string catNames[] = {
"Res",
"Pull",
"WrongCov"};
566 vector<Int_t> bins(15, 200);
567 vector<pair<Float_t, Float_t>> bounds;
569 vector<pair<Float_t, Float_t>> tmp = boost::assign::list_of(make_pair(-1., 1.))
571 (make_pair(-.01, .01))
572 (make_pair(-.01, .01))
579 (make_pair(0., 200.))
580 (make_pair(0., 200.))
581 (make_pair(0., 200.))
582 (make_pair(0., 200.))
583 (make_pair(0., 200.));
587 bounds.assign(15, make_pair(0., 0.));
590 Double_t momentumMin = 0.;
591 Double_t momentumMax = 10.;
592 Int_t nofMomentumBins = 20;
593 string momentumAxisTitle =
"P [GeV/c]";
596 for (Int_t i = 0; i < 2; i++) {
597 string trackParamName = (i == 0) ?
"FirstParam" :
"LastParam";
599 for (Int_t iCat = 0; iCat < 3; iCat++) {
600 for (Int_t iPar = 0; iPar < 5; iPar++) {
601 string histName =
"htf_" + detName +
"_" + trackParamName +
"_" + catNames[iCat] +
"_" + parameterNames[iPar];
602 Int_t histId = iCat * 5 + iPar;
604 new TH2F(histName.c_str(),
605 string(histName +
";" + momentumAxisTitle + +
";" + xTitles[histId] +
";Counter").c_str(),
606 nofMomentumBins, momentumMin, momentumMax, bins[histId], bounds[histId].first,
607 bounds[histId].second));
618 string parameterNames[] = {
"X",
"Y",
"Z",
"Tx",
"Ty",
"Qp",
"p",
"pt"};
621 string xTitles[] = {
"X [cm]",
"Y [cm]",
"Z [cm]",
"Tx",
"Ty",
"q/p [(GeV/c)^{-1}]",
622 "Momentum [GeV/c]",
"P_{t} [GeV/c]"};
624 vector<Int_t> bins(8, 200);
625 vector<pair<Float_t, Float_t>> bounds;
627 vector<pair<Float_t, Float_t>> tmp = boost::assign::list_of(make_pair(-500., 500.))
628 (make_pair(-500., 500.))
629 (make_pair(-500., 500.))
638 bounds.assign(8, make_pair(0., 0.));
642 for (Int_t i = 0; i < 2; i++) {
643 string trackParamName = (i == 0) ?
"FirstParam" :
"LastParam";
644 for (Int_t iPar = 0; iPar < 8; iPar++) {
645 string histName =
"htp_" + detName +
"_" + trackParamName +
"_" + parameterNames[iPar];
646 fHM->
Add(histName,
new TH1F(histName.c_str(),
string(histName +
";" + xTitles[iPar] +
";Counter").c_str(),
647 bins[iPar], bounds[iPar].first, bounds[iPar].second));
ClassImp(CbmConverterManager)
@ kMvd
Micro-Vertex Detector.
@ kTrd
Transition Radiation Detector.
@ kSts
Silicon Tracking System.
@ kMuch
Muon detection system.
Create report for fit QA.
Track fit QA for track reconstruction.
Creates CbmLitMCTrack objects.
Data class for a reconstructed hit in the STS.
Data class for STS tracks.
Helper class to convert unique channel ID back and forth.
Class characterising one event by a collection of links (indices) to data objects,...
int32_t GetStsTrackIndex() const
const CbmTrackParam * GetParamVertex() const
int32_t GetMuchTrackIndex() const
int32_t GetTrdTrackIndex() const
void ShrinkEmptyBinsH1ByPattern(const std::string &pattern)
Shrink empty bins in H1.
TH2 * H2(const std::string &name) const
Return pointer to TH2 histogram.
void WriteToFile()
Write all objects to current opened file.
void Add(const std::string &name, TNamed *object)
Add new named object to manager.
TH1 * H1(const std::string &name) const
Return pointer to TH1 histogram.
int32_t GetAddress() const
void DetermineSetup()
Determines detector presence using TGeoManager.
bool GetDet(ECbmModuleId detId) const
Return detector presence in setup.
Create report for fit QA.
Track fit QA for track reconstruction.
TClonesArray * fGlobalTracks
CbmMCDataArray * fMCTracks
TClonesArray * fStsTrackMatches
virtual ~CbmLitFitQa()
Destructor.
void ProcessTrackMomentumAtVertex()
TClonesArray * fTrdTrackMatches
CbmStsKFTrackFitter fKFFitter
TClonesArray * fMuchPixelHits
TClonesArray * fTrdTracks
void ProcessTrackParamsAtVertex()
void ProcessStsTrack(Int_t trackId)
void ReadDataBranches()
Reads data branches.
void FillTrackParamHistogramm(const string &histName, const FairTrackParam *par)
TClonesArray * fStsTracks
virtual InitStatus Init()
Inherited from FairTask.
void FillResidualsAndPulls(const FairTrackParam *par, const CbmLitMCPoint *mcPoint, const string &histName, Float_t wrongPar, ECbmModuleId detId)
virtual void Finish()
Inherited from FairTask.
void CreateTrackParamHistograms(ECbmModuleId detId, const string &detName)
TClonesArray * fMuchTrackMatches
CbmLitFitQa()
Constructor.
void ProcessGlobalTracks()
CbmLitMCTrackCreator * fMCTrackCreator
TClonesArray * fMuchTracks
void CreateResidualAndPullHistograms(ECbmModuleId detId, const string &detName)
virtual void Exec(Option_t *opt)
Inherited from FairTask.
void ProcessMuchTrack(Int_t trackId)
TClonesArray * fMuchStripHits
void ProcessTrdTrack(Int_t trackId)
Double_t GetTxOut() const
Double_t GetQpOut() const
Double_t GetTyOut() const
void Create(Int_t eventNum)
Creates array of CbmLitMCTracks for current event.
static CbmLitMCTrackCreator * Instance()
Singleton instance.
const CbmLitMCTrack & GetTrack(int mcEventId, int mcId) const
Return CbmLitMCTrack by its index.
UInt_t GetNofPointsAtStation(ECbmModuleId detId, Int_t stationId) const
Return number of MC points for specified detector ID and station ID.
const CbmLitMCPoint & GetPointAtStation(ECbmModuleId detId, Int_t stationId, Int_t index) const
Return MC point for specified detector id and point index.
TObject * Get(const CbmLink *lnk)
Task class creating and managing CbmMCDataArray objects.
CbmMCDataObject * GetObject(const char *name)
CbmMCDataArray * InitBranch(const char *name)
void GetMomentum(TVector3 &momentum) const
int32_t GetMotherId() const
int32_t GetNofLinks() const
const CbmLink & GetMatchedLink() const
static Int_t GetLayerSideIndex(Int_t address)
static Int_t GetStationIndex(Int_t address)
static Int_t GetLayerIndex(Int_t address)
virtual int32_t GetStationNr() const
Base class for simulation reports.
void Create(CbmHistManager *histManager, const std::string &outputDir)
Main function which creates report data.
data class for a reconstructed 3-d hit in the STS
Double_t FitToVertex(CbmStsTrack *track, CbmVertex *vtx, FairTrackParam *v_track)
Double_t GetChiToVertex(CbmStsTrack *track, CbmVertex *vtx=nullptr)
Int_t DoFit(CbmStsTrack *track, Int_t pidHypo=211)
static CbmStsSetup * Instance()
Int_t GetStationNumber(Int_t address)
int32_t GetNofMvdHits() const
int32_t GetMvdHitIndex(int32_t iHit) const
int32_t GetStsHitIndex(int32_t iHit) const
int32_t GetNofStsHits() const
double GetTrueOverAllHitsRatio() const
const FairTrackParam * GetParamLast() const
virtual int32_t GetNofHits() const
const FairTrackParam * GetParamFirst() const
int32_t GetHitIndex(int32_t iHit) const
static uint32_t GetLayerId(uint32_t address)
Return layer ID from address.