31#include "FairRootManager.h"
36#include "TParameter.h"
37#include "TPaveStats.h"
44#include <TClonesArray.h>
45#include <TGenericClassInfo.h>
50#include <boost/exception/exception.hpp>
51#include <boost/type_index/type_index_facade.hpp>
65 : FairTask(name, verbose)
70 ,
fOutFolder(
"MuchHitFinderQA",
"MuchHitFinderQA")
146 fManager = FairRootManager::Instance();
162 TFile* oldFile = gFile;
163 TDirectory* oldDir = gDirectory;
166 LOG_IF(fatal, !f) <<
"Could not open file " <<
fGeoFileName;
172 TObjArray* stations = f->Get<TObjArray>(
"stations");
173 LOG_IF(fatal, !stations) <<
"TObjArray stations not found in file " <<
fGeoFileName;
177 LOG(fatal) <<
"Can not find FairRootManager";
181 LOG(fatal) <<
"Can not find Much digi manager";
185 LOG(fatal) <<
"Can not find Much geo scheme";
189 LOG(error) <<
"No MC tracks found";
193 LOG(error) <<
"No MC points found";
197 LOG(error) <<
"No hits found";
201 LOG(error) <<
"No hits found";
222 LOG(debug) <<
"Init(): fNstations = " <<
fNstations;
231 new TH1I(Form(
"hMCPointsInCluster%i", i + 1), Form(
"MC Points in Cluster : Station %i ", i + 1), 10, 0, 10);
233 new TH1I(Form(
"hDigisInCluster%i", i + 1), Form(
"Digis in Cluster : Station %i ", i + 1), 10, 0, 10);
235 new TH1I(Form(
"hHitsPerCluster%i", i + 1), Form(
"Hits per Cluster : Station %i ", i + 1), 10, 0, 10);
240 gStyle->SetOptStat(1);
243 fhPullX =
new TH1D(
"hPullX",
"Pull distribution X;(x_{RC} - x_{MC}) / dx_{RC}", 500, -5, 5);
244 fhPullY =
new TH1D(
"hPullY",
"Pull distribution Y;(y_{RC} - y_{MC}) / dy_{RC}", 500, -5, 5);
245 fhPullT =
new TH1D(
"hPullT",
"Pull distribution T;(t_{RC} - t_{MC}) / dt_{RC}", 120, -5, 5);
248 fhResidualX =
new TH1D(
"hResidualX",
"Residual distribution X;(x_{RC} - x_{MC})(cm)", 500, -3, 3);
249 fhResidualY =
new TH1D(
"hResidualY",
"Residual distribution Y;(y_{RC} - y_{MC})(cm)", 500, -3, 3);
250 fhResidualT =
new TH1D(
"hResidualT",
"Residual distribution T;(t_{RC} - t_{MC})(ns)", 140, -17, 17);
301 LOG(debug) <<
"Event: " <<
fNevents.GetVal();
315 printf(
" CbmMuchHitFinderQa FinishTask\n");
318 gStyle->SetPaperSize(20, 20);
326 std::vector<TH1D*> vResHistos;
334 for (UInt_t i = 0; i < vResHistos.size(); i++) {
335 TH1D* histo = vResHistos[i];
337 if (histo->GetRMS() > 0.) {
338 histo->Fit(
"gaus",
"Q");
339 auto f = histo->GetFunction(
"gaus");
342 f->SetLineColor(kRed);
349 printf(
"===================================\n");
350 printf(
"StatisticsQa:\n");
351 printf(
"Total number of points: %i\n",
fPointsTotal.GetVal());
360 FairSink* sink = FairRootManager::Instance()->GetSink();
380 std::vector<TH1D*> vPullHistos;
381 vPullHistos.push_back(
fhPullX);
382 vPullHistos.push_back(
fhPullY);
383 vPullHistos.push_back(
fhPullT);
385 for (UInt_t i = 0; i < vPullHistos.size(); i++) {
386 TH1D* histo = vPullHistos[i];
390 TPaveStats* st = (TPaveStats*) histo->FindObject(
"stats");
396 st->SetOptStat(1110);
400 histo->DrawCopy(
"",
"");
409 std::vector<TH1D*> vResHistos;
414 for (UInt_t i = 0; i < vResHistos.size(); i++) {
415 TH1D* histo = vResHistos[i];
419 TPaveStats* st = (TPaveStats*) histo->FindObject(
"stats");
425 st->SetOptStat(1110);
429 histo->DrawCopy(
"",
"");
440 TArrayI hitsInCluster;
441 TArrayI pointsInCluster;
442 hitsInCluster.Set(nClusters);
443 pointsInCluster.Set(nClusters);
444 LOG(debug) <<
" start Stat QA ";
445 for (
Int_t i = 0; i < nClusters; i++)
446 hitsInCluster[i] = 0;
447 for (
Int_t i = 0; i < nClusters; i++)
448 pointsInCluster[i] = 0;
450 for (
Int_t i = 0; i <
fHits->GetEntriesFast(); i++) {
456 hitsInCluster[clusterId]++;
459 for (
Int_t i = 0; i < nClusters; i++) {
462 map<Int_t, Int_t> map_points;
472 for (
Int_t digiId = 0; digiId < nDigis; digiId++) {
477 LOG(fatal) <<
"CbmMuchHitFinderQa::StatisticsQa(): Match should be "
478 "present but is null.";
482 for (
Int_t iRefPoint = 0; iRefPoint < nPoints; iRefPoint++) {
484 map_points[pointId] = 1;
488 pointsInCluster[i] = map_points.size();
492 for (
Int_t i = 0; i < nClusters; i++) {
500 Int_t nPts = pointsInCluster[i];
501 Int_t nHits = hitsInCluster[i];
517 for (
Int_t i = 0; i <
fHits->GetEntriesFast(); i++) {
528 if (verbose) printf(
" Hit %i, station %i, layer %i ", i, iStation, iLayer);
532 for (
Int_t j = i + 1; j <
fHits->GetEntriesFast(); j++) {
535 if (hit1->
GetRefId() == clusterId) {
540 if (verbose) printf(
"hit_unique=%i", hit_unique);
542 if (verbose) printf(
"\n");
557 LOG(fatal) <<
"CbmMuchHitFinderQa::PullsQa(): Error, digi not found.";
561 LOG(fatal) <<
"CbmMuchHitFinderQa::PullsQa(): Error, index out of bounds.";
566 LOG(fatal) <<
"CbmMuchHitFinderQa::PullsQa(): Error, match not found.";
570 if (verbose) printf(
" n=%i", match->
GetNofLinks());
572 printf(
" noise hit");
584 LOG(fatal) <<
"CbmMuchHitFinderQa::PullsQa(): Error, module not found.";
592 if (!(currentLink == link)) {
598 if (verbose) printf(
" point_unique=%i", point_unique);
600 if (verbose) printf(
"\n");
611 Double_t tMC = point->GetTime();
613 Double_t xRC = hit->
GetX();
614 Double_t yRC = hit->
GetY();
615 Double_t dx = hit->
GetDx();
616 Double_t dy = hit->
GetDy();
623 LOG(error) <<
"Anomalously small dx";
627 LOG(error) <<
"Anomalously small dy";
630 fhPullX->Fill((xRC - xMC) / dx);
631 fhPullY->Fill((yRC - yMC) / dy);
632 fhPullT->Fill((tRC - tMC) / dt);
637 if (verbose) printf(
"\n");
652 for (
int iLink = 0; iLink < match.
GetNofLinks(); iLink++) {
654 int nMuchPoints =
fPoints->Size(link);
655 for (
Int_t iPoint = 0; iPoint < nMuchPoints; iPoint++) {
661 vPoints.push_back(link);
666 std::sort(vPoints.begin(), vPoints.end());
668 for (
Int_t iCluster = 0; iCluster < nClusters; ++iCluster) {
671 LOG(fatal) <<
"CbmMuchHitFinderQa::ClusterDeconvQa(): Error, cluster not found.";
675 for (
Int_t id = 0;
id < nDigis; ++id) {
679 LOG(fatal) <<
"CbmMuchHitFinderQa::ClusterDeconvQa(): Error, match not found.";
684 auto it = find(vPoints.begin(), vPoints.end(), pointLink);
685 assert(it != vPoints.end());
686 if (it->GetWeight() > 0.)
continue;
701 if (!point)
return kFALSE;
702 Int_t iTrack = point->GetTrackID();
704 if (!track)
return kFALSE;
706 if (iTrack != 0 && iTrack != 1)
return kFALSE;
710 if (TMath::Abs(pdgCode) == 13) {
ClassImp(CbmConverterManager)
@ kMuch
Muon detection system.
Data container for MUCH clusters.
Class for pixel hits in MUCH detector.
Definition of the CbmQaCanvas class.
int32_t GetAddress() const
int32_t GetDigi(int32_t index) const
Get digi at position index.
int32_t GetNofDigis() const
Number of digis in cluster.
static CbmDigiManager * Instance()
Static instance.
double GetTimeError() const
int32_t GetAddress() const
void SetIndex(int32_t index)
void SetWeight(float weight)
Task class creating and managing CbmMCDataArray objects.
int32_t GetMotherId() const
int32_t GetPdgCode() const
const CbmLink & GetLink(int32_t i) const
int32_t GetNofLinks() const
static int32_t GetLayerIndex(int32_t address)
static int32_t GetStationIndex(int32_t address)
Data container for MUCH clusters.
int32_t GetAddress() const
TParameter< int > fPointsTotal
CbmMuchGeoScheme * fGeoScheme
CbmMuchHitFinderQa(const char *name="MuchHitFinderQa", Int_t verbose=1)
TParameter< int > fNevents
FairRootManager * fManager
CbmMCDataArray * fMCTracks
std::vector< TH1I * > fhDigisInCluster
TParameter< int > fPointsUnderCounted
TParameter< int > fSignalPoints
number of processed events
TClonesArray * fClusters
subfolder for histograms
CbmTimeSlice * fTimeSlice
CbmDigiManager * fDigiManager
CbmQaCanvas * fCanvDigisInCluster
virtual void Exec(Option_t *option)
TFolder * histFolder
output folder with histos and canvases
TParameter< int > fSignalHits
virtual ~CbmMuchHitFinderQa()
CbmQaCanvas * fCanvResidual
virtual InitStatus Init()
Bool_t IsSignalPoint(CbmLink pointLink)
std::vector< TH1I * > fhHitsPerCluster
CbmQaCanvas * fCanvPointsInCluster
virtual void FinishTask()
virtual void SetParContainers()
CbmMCDataManager * fMcManager
CbmQaCanvas * fCanvHitsPerCluster
std::vector< TH1I * > fhPointsInCluster
TParameter< int > fPointsOverCounted
Bookkeeping of time-slice content.