44#include "FairRootManager.h"
45#include "TClonesArray.h"
51#include "TProfile2D.h"
56#include <boost/assign/list_of.hpp>
64using boost::assign::list_of;
65using std::binary_search;
102 fHM->
H1(
"hen_EventNo_ClusteringQa")->Fill(0.5);
103 Int_t eventNum =
fHM->
H1(
"hen_EventNo_ClusteringQa")->GetEntries() - 1;
104 std::cout <<
"CbmLitClusteringQa::Exec: event=" << eventNum << std::endl;
135 TDirectory* oldir = gDirectory;
136 TFile* outFile = FairRootManager::Instance()->GetOutFile();
137 if (outFile != NULL) {
141 gDirectory->cd(oldir->GetPath());
152 TFile* oldFile = gFile;
153 TDirectory* oldDir = gDirectory;
155 TFile* file =
new TFile(digiFileName.c_str());
156 LOG_IF(fatal, !file) <<
"Could not open file " << digiFileName;
157 TObjArray* stations = file->Get<TObjArray>(
"stations");
158 LOG_IF(fatal, !stations) <<
"TObjArray stations could not be read from file " << digiFileName;
171 FairRootManager* ioman = FairRootManager::Instance();
172 assert(ioman != NULL);
176 if (0 == mcManager) LOG(fatal) <<
"CbmMatchRecoToMC::ReadAndCreateDataBranches() NULL MCDataManager.";
181 fMvdHits = (TClonesArray*) ioman->GetObject(
"MvdHit");
184 fStsClusters = (TClonesArray*) ioman->GetObject(
"StsCluster");
185 fStsHits = (TClonesArray*) ioman->GetObject(
"StsHit");
189 fRichHits = (TClonesArray*) ioman->GetObject(
"RichHit");
193 fMuchClusters = (TClonesArray*) ioman->GetObject(
"MuchCluster");
194 fMuchPixelHits = (TClonesArray*) ioman->GetObject(
"MuchPixelHit");
199 fTrdClusters = (TClonesArray*) ioman->GetObject(
"TrdCluster");
200 fTrdHits = (TClonesArray*) ioman->GetObject(
"TrdHit");
205 fTofHits = (TClonesArray*) ioman->GetObject(
"TofHit");
225 string histName =
"hno_NofObjects_" + detName +
"Points_Station";
227 Int_t evSize =
points->Size(0, iEvent);
229 for (Int_t iP = 0; iP < evSize; iP++) {
230 const FairMCPoint* point =
static_cast<const FairMCPoint*
>(
points->Get(0, iEvent, iP));
240 if (!
fHM->
Exists(
"hno_NofObjects_" + detName +
"Digis_Station"))
return;
244 Int_t stationId =
GetStationId(digi->GetAddress(), detId);
245 fHM->
H1(
"hno_NofObjects_" + detName +
"Digis_Station")->Fill(stationId);
246 fHM->
H1(
"hpa_" + detName +
"Digi_NofPointsInDigi_H1")->Fill(digiMatch->GetNofLinks());
247 fHM->
H1(
"hpa_" + detName +
"Digi_NofPointsInDigi_H2")->Fill(stationId, digiMatch->GetNofLinks());
254 if (NULL != clusters &&
fHM->
Exists(
"hno_NofObjects_" + detName +
"Clusters_Station")) {
255 for (Int_t i = 0; i < clusters->GetEntriesFast(); i++) {
257 const CbmMatch* clusterMatch =
static_cast<const CbmMatch*
>(clusterMatches->At(i));
259 fHM->
H1(
"hno_NofObjects_" + detName +
"Clusters_Station")->Fill(stationId);
260 fHM->
H1(
"hpa_" + detName +
"Cluster_NofDigisInCluster_H1")->Fill(cluster->
GetNofDigis());
261 fHM->
H1(
"hpa_" + detName +
"Cluster_NofDigisInCluster_H2")->Fill(stationId, cluster->
GetNofDigis());
262 fHM->
H1(
"hpa_" + detName +
"Cluster_NofPointsInCluster_H1")->Fill(clusterMatch->
GetNofLinks());
263 fHM->
H1(
"hpa_" + detName +
"Cluster_NofPointsInCluster_H2")->Fill(stationId, clusterMatch->
GetNofLinks());
271 if (NULL !=
hits &&
fHM->
Exists(
"hno_NofObjects_" + detName +
"Hits_Station")) {
272 for (Int_t i = 0; i <
hits->GetEntriesFast(); i++) {
276 fHM->
H1(
"hno_NofObjects_" + detName +
"Hits_Station")->Fill(stationId);
277 fHM->
H1(
"hpa_" + detName +
"Hit_SigmaX_H1")->Fill(hit->
GetDx());
278 fHM->
H1(
"hpa_" + detName +
"Hit_SigmaX_H2")->Fill(stationId, hit->
GetDx());
279 fHM->
H1(
"hpa_" + detName +
"Hit_SigmaY_H1")->Fill(hit->
GetDy());
280 fHM->
H1(
"hpa_" + detName +
"Hit_SigmaY_H2")->Fill(stationId, hit->
GetDy());
281 fHM->
H1(
"hpa_" + detName +
"Hit_NofPointsInHit_H1")->Fill(hitMatch->
GetNofLinks());
282 fHM->
H1(
"hpa_" + detName +
"Hit_NofPointsInHit_H2")->Fill(stationId, hitMatch->
GetNofLinks());
306 fHM->
H1(
"hno_NofObjects_MvdClusters_Event")->Fill(
fMvdClusters->GetEntriesFast());
308 fHM->
H1(
"hno_NofObjects_MvdHits_Event")->Fill(
fMvdHits->GetEntriesFast());
313 fHM->
H1(
"hno_NofObjects_StsClusters_Event")->Fill(
fStsClusters->GetEntriesFast());
315 fHM->
H1(
"hno_NofObjects_StsHits_Event")->Fill(
fStsHits->GetEntriesFast());
318 fHM->
H1(
"hno_NofObjects_RichHits_Event")->Fill(
fRichHits->GetEntriesFast());
323 fHM->
H1(
"hno_NofObjects_TrdClusters_Event")->Fill(
fTrdClusters->GetEntriesFast());
325 fHM->
H1(
"hno_NofObjects_TrdHits_Event")->Fill(
fTrdHits->GetEntriesFast());
335 fHM->
H1(
"hno_NofObjects_TofHits_Event")->Fill(
fTofHits->GetEntriesFast());
339 const TClonesArray* hitMatches,
const string& detName,
342 if (NULL ==
points || NULL ==
hits || NULL == hitMatches)
return;
343 string nameResidualX =
"hrp_" + detName +
"_ResidualX_H2";
344 string nameResidualY =
"hrp_" + detName +
"_ResidualY_H2";
345 string nameResidualT =
"hrp_" + detName +
"_ResidualT_H2";
346 string namePullX =
"hrp_" + detName +
"_PullX_H2";
347 string namePullY =
"hrp_" + detName +
"_PullY_H2";
348 string namePullT =
"hrp_" + detName +
"_PullT_H2";
353 Int_t nofHits =
hits->GetEntriesFast();
354 for (Int_t iHit = 0; iHit < nofHits; iHit++) {
357 if (std::isnan(
static_cast<Float_t
>(hit->
GetX())) || (std::isnan(
static_cast<Float_t
>(hit->
GetY()))))
continue;
358 const FairMCPoint* point =
static_cast<const FairMCPoint*
>(
360 if (point == NULL)
continue;
363 Float_t residualX = point->GetX() - hit->
GetX();
364 Float_t residualY = point->GetY() - hit->
GetY();
368 residualT = point->GetTime() - hit->
GetTime();
374 fHM->
H2(nameResidualX)->Fill(stationId, residualX);
375 fHM->
H2(nameResidualY)->Fill(stationId, residualY);
376 fHM->
H2(nameResidualT)->Fill(stationId, residualT);
377 fHM->
H2(namePullX)->Fill(stationId, residualX / hit->
GetDx());
378 fHM->
H2(namePullY)->Fill(stationId, residualY / hit->
GetDy());
384 const TClonesArray* hitMatches,
const string& detName,
387 if (NULL ==
points || NULL ==
hits || NULL == hitMatches)
return;
388 string accName =
"hhe_" + detName +
"_All_Acc_Station";
391 Int_t evSize =
points->Size(0, iEvent);
392 for (Int_t iP = 0; iP < evSize; iP++) {
393 const FairMCPoint* point =
static_cast<const FairMCPoint*
>(
points->Get(0, iEvent, iP));
397 string recName =
"hhe_" + detName +
"_All_Rec_Station";
398 string cloneName =
"hhe_" + detName +
"_All_Clone_Station";
399 set<pair<Int_t, Int_t>> mcPointSet;
400 Int_t nofHits =
hits->GetEntriesFast();
401 for (Int_t iHit = 0; iHit < nofHits; iHit++) {
405 == mcPointSet.end()) {
438 fHM->
Create1<TH1F>(
"hen_EventNo_ClusteringQa",
"hen_EventNo_ClusteringQa", 1, 0, 1.);
446 Int_t nofBins = 100000;
447 Double_t minX = -0.5;
448 Double_t maxX = 99999.5;
449 string name =
"hno_NofObjects_" + detName;
450 fHM->
Create1<TH1F>(name +
"Points_Event", name +
"Points_Event;Points per event;Counter", nofBins, minX, maxX);
451 fHM->
Create1<TH1F>(name +
"Digis_Event", name +
"Digis_Event;Digis per event;Counter", nofBins, minX, maxX);
452 fHM->
Create1<TH1F>(name +
"Clusters_Event", name +
"Clusters_Event;Clusters per event;Counter", nofBins, minX, maxX);
454 fHM->
Create1<TH1F>(name +
"PixelHits_Event", name +
"PixelHits_Event;Hits per event;Counter", nofBins, minX, maxX);
457 fHM->
Create1<TH1F>(name +
"Hits_Event", name +
"Hits_Event;Hits per event;Counter", nofBins, minX, maxX);
462 const string& xTitle)
468 Double_t minX = -0.5;
469 Double_t maxX = 99.5;
470 string name =
"hno_NofObjects_" + detName;
471 fHM->
Create1<TH1F>(name +
"Points_" + parameter, name +
"Points_" + parameter +
";" + xTitle +
";Points per event",
472 nofBins, minX, maxX);
473 fHM->
Create1<TH1F>(name +
"Digis_" + parameter, name +
"Digis_" + parameter +
";" + xTitle +
";Digis per event",
474 nofBins, minX, maxX);
475 fHM->
Create1<TH1F>(name +
"Clusters_" + parameter,
476 name +
"Clusters_" + parameter +
";" + xTitle +
";Clusters per event", nofBins, minX, maxX);
477 fHM->
Create1<TH1F>(name +
"Hits_" + parameter, name +
"Hits_" + parameter +
";" + xTitle +
";Hits per event", nofBins,
486 Int_t nofBinsStation = 100;
487 Double_t minStation = -0.5;
488 Double_t maxStation = 99.5;
492 Int_t nofBinsSigma = 100;
493 Double_t minSigma = -0.5;
494 Double_t maxSigma = 9.5;
495 Int_t nofBinsResidual = 200;
496 Double_t minResidual = -10.0;
497 Double_t maxResidual = 10.0;
498 Double_t minResidualT = -100.0;
499 Double_t maxResidualT = 100.0;
500 Int_t nofBinsPull = 100;
501 Double_t minPull = -5.0;
502 Double_t maxPull = 5.0;
504 string nameH1 =
"hpa_" + detName +
"Cluster_NofDigisInCluster_H1";
505 fHM->
Create1<TH1F>(nameH1, nameH1 +
";Number of digis;Yield", nofBins,
min,
max);
506 string nameH2 =
"hpa_" + detName +
"Cluster_NofDigisInCluster_H2";
507 fHM->
Create2<TH2F>(nameH2, nameH2 +
";Station;Number of digis;Yield", nofBinsStation, minStation,
max, nofBins,
min,
509 nameH1 =
"hpa_" + detName +
"Cluster_NofPointsInCluster_H1";
510 fHM->
Create1<TH1F>(nameH1, nameH1 +
";Number of points;Yield", nofBins,
min,
max);
511 nameH2 =
"hpa_" + detName +
"Cluster_NofPointsInCluster_H2";
512 fHM->
Create2<TH2F>(nameH2, nameH2 +
";Station;Number of points;Yield", nofBinsStation, minStation,
max, nofBins,
min,
514 nameH1 =
"hpa_" + detName +
"Digi_NofPointsInDigi_H1";
515 fHM->
Create1<TH1F>(nameH1, nameH1 +
";Number of points;Yield", nofBins,
min,
max);
516 nameH2 =
"hpa_" + detName +
"Digi_NofPointsInDigi_H2";
517 fHM->
Create2<TH2F>(nameH2, nameH2 +
";Station;Number of points;Yield", nofBinsStation, minStation, maxStation,
519 nameH1 =
"hpa_" + detName +
"Hit_NofPointsInHit_H1";
520 fHM->
Create1<TH1F>(nameH1, nameH1 +
";Number of points;Yield", nofBins,
min,
max);
521 nameH2 =
"hpa_" + detName +
"Hit_NofPointsInHit_H2";
522 fHM->
Create2<TH2F>(nameH2, nameH2 +
";Station;Number of points;Yield", nofBinsStation, minStation,
max, nofBins,
min,
524 nameH1 =
"hpa_" + detName +
"Hit_SigmaX_H1";
525 fHM->
Create1<TH1F>(nameH1, nameH1 +
";#sigma_{X} [cm];Yield", nofBinsSigma, minSigma, maxSigma);
526 nameH2 =
"hpa_" + detName +
"Hit_SigmaX_H2";
527 fHM->
Create2<TH2F>(nameH2, nameH2 +
";Station;#sigma_{X} [cm];Yield", nofBinsStation, minStation, maxStation,
528 nofBinsSigma, minSigma, maxSigma);
529 nameH1 =
"hpa_" + detName +
"Hit_SigmaY_H1";
530 fHM->
Create1<TH1F>(nameH1, nameH1 +
";#sigma_{Y} [cm];Yield", nofBinsSigma, minSigma, maxSigma);
531 nameH2 =
"hpa_" + detName +
"Hit_SigmaY_H2";
532 fHM->
Create2<TH2F>(nameH2, nameH2 +
";Station;#sigma_{Y} [cm];Yield", nofBinsStation, minStation, maxStation,
533 nofBinsSigma, minSigma, maxSigma);
536 nameH2 =
"hrp_" + detName +
"_ResidualX_H2";
537 fHM->
Create2<TH2F>(nameH2, nameH2 +
";Station;Residual X [cm];Yield", nofBinsStation, minStation, maxStation,
538 nofBinsResidual, minResidual, maxResidual);
539 nameH2 =
"hrp_" + detName +
"_ResidualY_H2";
540 fHM->
Create2<TH2F>(nameH2, nameH2 +
";Station;Residual Y [cm];Yield", nofBinsStation, minStation, maxStation,
541 nofBinsResidual, minResidual, maxResidual);
542 nameH2 =
"hrp_" + detName +
"_ResidualT_H2";
543 fHM->
Create2<TH2F>(nameH2, nameH2 +
";Station;Residual T [ns];Yield", nofBinsStation, minStation, maxStation,
544 nofBinsResidual, minResidualT, maxResidualT);
545 nameH2 =
"hrp_" + detName +
"_PullX_H2";
546 fHM->
Create2<TH2F>(nameH2, nameH2 +
";Station;Pull X;Yield", nofBinsStation, minStation, maxStation, nofBinsPull,
548 nameH2 =
"hrp_" + detName +
"_PullY_H2";
549 fHM->
Create2<TH2F>(nameH2, nameH2 +
";Station;Pull Y;Yield", nofBinsStation, minStation, maxStation, nofBinsPull,
551 nameH2 =
"hrp_" + detName +
"_PullT_H2";
552 fHM->
Create2<TH2F>(nameH2, nameH2 +
";Station;Pull T;Yield", nofBinsStation, minStation, maxStation, nofBinsPull,
557 const string& parameter,
const string& xTitle, Int_t nofBins,
558 Double_t minBin, Double_t maxBin)
561 vector<string> types = list_of(
"Acc")(
"Rec")(
"Eff")(
"Clone")(
"CloneProb");
562 vector<string> cat = list_of(
"All");
563 for (UInt_t iCat = 0; iCat < cat.size(); iCat++) {
564 for (UInt_t iType = 0; iType < types.size(); iType++) {
565 string yTitle = (types[iType] ==
"Eff") ?
"Efficiency [%]"
566 : (types[iType] ==
"CloneProb") ?
"Probability [%]"
568 string histName =
"hhe_" + detName +
"_" + cat[iCat] +
"_" + types[iType] +
"_" + parameter;
569 string histTitle = histName +
";" + xTitle +
";" + yTitle;
570 fHM->
Add(histName,
new TH1F(histName.c_str(), histTitle.c_str(), nofBins, minBin, maxBin));
Base class for cluster objects.
@ kMvd
Micro-Vertex Detector.
@ kTrd
Transition Radiation Detector.
@ kTof
Time-of-flight Detector.
@ kSts
Silicon Tracking System.
@ kMuch
Muon detection system.
@ kRich
Ring-Imaging Cherenkov Detector.
Simulation report for clustering QA.
ClassImp(CbmLitClusteringQa)
FairTask for clustering performance calculation.
Data container for MUCH clusters.
Class for pixel hits in MUCH detector.
static vector< vector< QAHit > > hits
Helper class to convert unique channel ID back and forth.
friend fscal max(fscal x, fscal y)
friend fscal min(fscal x, fscal y)
Base class for cluster objects.
int32_t GetAddress() const
int32_t GetNofDigis() const
Number of digis in cluster.
static Int_t GetNofDigis(ECbmModuleId systemId)
static Bool_t IsPresent(ECbmModuleId systemId)
Presence of a digi branch.
static Bool_t IsMatchPresent(ECbmModuleId systemId)
Presence of a digi match branch.
const Digi * Get(Int_t index) const
Get a digi object.
const CbmMatch * GetMatch(ECbmModuleId systemId, UInt_t index) const
Get a match object.
TH2 * H2(const std::string &name) const
Return pointer to TH2 histogram.
void Create2(const std::string &name, const std::string &title, Int_t nofBinsX, Double_t minBinX, Double_t maxBinX, Int_t nofBinsY, Double_t minBinY, Double_t maxBinY)
Helper function for creation of 2-dimensional histograms and profiles. Template argument is a real ob...
void WriteToFile()
Write all objects to current opened file.
Bool_t Exists(const std::string &name) const
Check existence of object in manager.
void Create1(const std::string &name, const std::string &title, Int_t nofBins, Double_t minBin, Double_t maxBin)
Helper function for creation of 1-dimensional histograms and profiles. Template argument is a real ob...
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.
double GetTimeError() const
int32_t GetAddress() const
Simulation report for clustering QA.
void ProcessClusters(const TClonesArray *clusters, const TClonesArray *clusterMatches, const string &detName, ECbmModuleId detId)
virtual void Exec(Option_t *opt)
Derived from FairTask.
TClonesArray * fTrdClusters
CbmTrdPoint.
TClonesArray * fStsHits
CbmStsCluster.
CbmMCDataArray * fTrdPoints
CbmMatch (hit)
virtual ~CbmLitClusteringQa()
Destructor.
TClonesArray * fStsClusterMatches
CbmStsHit array.
TClonesArray * fRichHits
CbmRichPoint.
CbmMCDataArray * fStsPoints
CbmMvdHit.
CbmTimeSlice * fTimeSlice
void FillEventCounterHistograms(Int_t iEvent)
CbmMCDataArray * fMvdPoints
CbmMCTrack.
Int_t GetStationId(Int_t address, ECbmModuleId detId)
void ReadDataBranches()
Read data branches.
CbmMCDataArray * fMCTracks
Interface to digi data.
void FillHitEfficiencyHistograms(Int_t iEvent, CbmMCDataArray *points, const TClonesArray *hits, const TClonesArray *hitMatches, const string &detName, ECbmModuleId detId)
void ProcessDigis(const string &detName)
void InitMuchGeoScheme(const string &digiFileName)
CbmLitClusteringQa()
Constructor.
TClonesArray * fMvdClusters
CbmMvdPoint.
CbmMCDataArray * fRichPoints
CbmMatch (hit)
CbmMCDataArray * fTofPoints
CbmMatch (hit)
virtual void Finish()
Derived from FairTask.
TClonesArray * fStsHitMatches
CbmMatch (cluster)
TClonesArray * fMuchClusters
CbmMuchPoint.
CbmDigiManager * fDigiMan
void CreateNofObjectsHistograms(ECbmModuleId detId, const string &detName)
virtual InitStatus Init()
Derived from FairTask.
CbmMCEventList * fEventList
void CreateClusterParametersHistograms(ECbmModuleId detId, const string &detName)
void FillResidualAndPullHistograms(CbmMCDataArray *points, const TClonesArray *hits, const TClonesArray *hitMatches, const string &detName, ECbmModuleId detId)
void ProcessPoints(Int_t iEvent, CbmMCDataArray *points, const string &detName, ECbmModuleId detId)
TClonesArray * fMuchPixelHitMatches
CbmMatch array.
TClonesArray * fTrdHits
CbmTrdCluster.
TClonesArray * fMvdHits
CbmMvdCluster.
TClonesArray * fMuchClusterMatches
CbmMuchPixelHit.
string fMuchDigiFileName
CbmTofHit.
CbmMCDataArray * fMuchPoints
CbmRichHit.
void ProcessHits(const TClonesArray *hits, const TClonesArray *hitMatches, const string &detName, ECbmModuleId detId)
TClonesArray * fTrdClusterMatches
CbmTrdHit.
TClonesArray * fTofHits
CbmTofPoint.
TClonesArray * fStsClusters
CbmStsPoint.
TClonesArray * fTrdHitMatches
CbmMatch (cluster)
TClonesArray * fMuchPixelHits
CbmMuchCluster.
void CreateHitEfficiencyHistograms(ECbmModuleId detId, const string &detName, const string ¶meter, const string &xTitle, Int_t nofBins, Double_t minBin, Double_t maxBin)
void DetermineSetup()
Determines detector presence using TGeoManager.
bool GetDet(ECbmModuleId detId) const
Return detector presence in setup.
Access to a MC data branch for time-based analysis.
Int_t Size(Int_t fileNumber, Int_t eventNumber)
Task class creating and managing CbmMCDataArray objects.
CbmMCDataObject * GetObject(const char *name)
CbmMCDataArray * InitBranch(const char *name)
Container class for MC events with number, file and start time.
double GetEventTime(uint32_t event, uint32_t file)
Event start time.
int32_t GetNofLinks() const
const CbmLink & GetMatchedLink() const
static CbmMuchGeoScheme * Instance()
void Init(TObjArray *stations, Int_t flag)
Base class for simulation reports.
void Create(CbmHistManager *histManager, const std::string &outputDir)
Main function which creates report data.
Class representing the top level of the STS setup.
Bool_t Init(const char *geometryFile=nullptr)
Initialise the setup.
static CbmStsSetup * Instance()
Int_t GetStationNumber(Int_t address)
Bool_t IsInit() const
Initialisation status for sensor parameters.
Bookkeeping of time-slice content.
static uint32_t GetLayerId(uint32_t address)
Return layer ID from address.