24#include "TClonesArray.h"
28#include "TGeoManager.h"
40#include <boost/assign/list_of.hpp>
49using boost::assign::list_of;
54 : FairTask(
"CbmPsdMCbmQaReal")
62 , fOutputDir(
"result")
68 cout <<
"CbmPsdMCbmQaReal::Init" << endl;
70 FairRootManager* ioman = FairRootManager::Instance();
71 if (
nullptr == ioman) { Fatal(
"CbmPsdMCbmQaReal::Init",
"RootManager not instantised!"); }
81 fPsdHits = (TClonesArray*) ioman->GetObject(
"PsdHit");
82 if (
nullptr ==
fPsdHits) { Fatal(
"CbmPsdMCbmQaReal::Init",
"No Psd Hits!"); }
84 fTofHits = (TClonesArray*) ioman->GetObject(
"TofHit");
85 if (
nullptr ==
fTofHits) { Fatal(
"CbmPsdMCbmQaReal::Init",
"No Tof Hits!"); }
87 fTofTracks = (TClonesArray*) ioman->GetObject(
"TofTracks");
88 if (
nullptr ==
fTofTracks) { Fatal(
"CbmPsdMCbmQaReal::Init",
"No Tof Tracks!"); }
93 fCbmEvent = (TClonesArray*) ioman->GetObject(
"CbmEvent");
94 if (
nullptr ==
fCbmEvent) { Fatal(
"CbmPsdMCbmQaReal::Init",
"No Event!"); }
105 fHM->
Create1<TH1D>(
"fhNofEntries",
"fhNofEntries; Counts", 1, 0.5, 1.5);
106 fHM->
Create1<TH1D>(
"fhNofCbmEvents",
"fhNofCbmEvents;Counts", 1, 0.5, 1.5);
108 fHM->
Create1<TH1D>(
"fhHitsInTimeslice",
"fhHitsInTimeslice;Timeslice;#Hits", 200, 1, 200);
111 fHM->
Create1<TH1D>(
"fhNofPsdDigisInTimeslice",
"fhNofPsdDigisInTimeslice;# PSD digis / timeslice;Counts", 100, 0,
113 fHM->
Create1<TH1D>(
"fhNofPsdHitsInTimeslice",
"fhNofPsdHitsInTimeslice;# PSD hits / timeslice;Counts", 100, 0, 2000);
116 fHM->
Create2<TH2D>(
"fhPsdHitPos",
"fhPsdHitPos;PSD module id [];PSD section id [];Counts", 20, 0, 20, 20, 0, 20);
117 fHM->
Create1<TH1D>(
"fhPsdHitsTimeLog",
"fhPsdHitsTimeLog;Time [ns];Counts", 400, 0., 0.);
121 fHM->
Create1<TH1D>(
"fhPsdDigisTimeLog",
"fhNofPsdDigisTimeLog;Time [ns];Counts", 400, 0., 0.);
122 fHM->
Create1<TH1D>(
"fhTofDigisTimeLog",
"fhTofDigisTimeLog;Time [ns];Counts", 400, 0., 0.);
123 fHM->
Create1<TH1D>(
"fhStsDigisTimeLog",
"fhStsDigisTimeLog;Time [ns];Counts", 400, 0., 0.);
124 fHM->
Create1<TH1D>(
"fhBmonDigisTimeLog",
"fhBmonDigisTimeLog;Time [ns];Counts", 400, 0., 0.);
127 fHM->
Create1<TH1D>(
"fhPsdDigisEdep",
"fhPsdDigisEdep;Edep [adc counts];Counts", 500, 0, 50000);
128 fHM->
Create1<TH1D>(
"fhPsdHitEdep",
"fhPsdHitEdep;Edep [adc counts];Counts", 500, 0, 50000);
129 fHM->
Create1<TH1D>(
"fhPsdEdepInEvent",
"fhPsdEdepInEvent; Edep [adc counts]; Counts", 500, 0, 300000);
132 fHM->
Create2<TH2D>(
"fhTofTrackMultPsdEdep",
"fhTofTrackMultPsdEdep;PSD Edep [adc counts];Tof track Mult [];Counts",
133 500, 0, 400000, 20, 0, 20);
134 fHM->
Create2<TH2D>(
"fhTofHitMultPsdEdep",
"fhTofHitMultPsdEdep;PSD Edep [adc counts];Tof hit Mult [];Counts", 500, 0,
138 fHM->
Create3<TH3D>(
"fhTofXYZ",
"fhTofXYZ;Tof Hit X [cm];TofHit Z [cm];Tof Hit Y [cm];Counts", 100, -20, 20, 141, 230.,
140 fHM->
Create1<TH1D>(
"fhTofHitsZ",
"fhTofHitsZ;Z [cm];Counts", 350, -0.5, 349.5);
141 fHM->
Create2<TH2D>(
"fhTofHitsXZ",
"fhTofHitsXZ;Z [cm];X [cm];Counts", 600, -150, 450, 500, -50, 450);
144 fHM->
Create1<TH1D>(
"fhTofTracksPerEvent",
"fhTofTracksPerEvent;NofTracks/Event;Counts", 20, -5, 25);
145 fHM->
Create2<TH2D>(
"fhTofTracksXY",
"fhTofTracksXY;X[cm];Y[cm];NofTracks/cm^2", 250, -100, 150, 300, -150, 150);
152 fHM->
H1(
"fhNofEntries")->Fill(1);
153 cout <<
"CbmPsdMCbmQaReal, entry No. " <<
fEntryNum << endl;
159 double minTime = std::numeric_limits<double>::max();
167 fHM->
H1(
"fhPsdHitsTimeLog")->GetXaxis()->SetLimits(minTime, minTime + dT);
168 fHM->
H1(
"fhPsdDigisTimeLog")->GetXaxis()->SetLimits(minTime, minTime + dT);
169 fHM->
H1(
"fhTofDigisTimeLog")->GetXaxis()->SetLimits(minTime, minTime + dT);
170 fHM->
H1(
"fhStsDigisTimeLog")->GetXaxis()->SetLimits(minTime, minTime + dT);
171 fHM->
H1(
"fhBmonDigisTimeLog")->GetXaxis()->SetLimits(minTime, minTime + dT);
181 fHM->
H1(
"fhNofPsdDigisInTimeslice")->Fill(nofPsdDigis);
182 for (
int i = 0; i < nofPsdDigis; i++) {
189 for (
int i = 0; i < nofTofDigis; i++) {
196 for (
int i = 0; i < nofStsDigis; i++) {
198 fHM->
H1(
"fhStsDigisTimeLog")->Fill(digi->GetTime());
211 int nofPsdHits =
fPsdHits->GetEntriesFast();
212 fHM->
H1(
"fhNofPsdHitsInTimeslice")->Fill(nofPsdHits);
214 for (
int iH = 0; iH < nofPsdHits; iH++) {
221 auto fNCbmEvent =
fCbmEvent->GetEntriesFast();
223 for (
int i = 0; i < fNCbmEvent; i++) {
224 fHM->
H1(
"fhNofCbmEvents")->Fill(1);
226 std::vector<int> evPsdHitIndx;
238 Double_t PsdEdepInEvent = 0.;
239 for (
int j = 0; j < nofPsdHitsInEvent; j++) {
241 evPsdHitIndx.push_back(iPsdHit);
243 PsdEdepInEvent += psdHit->
GetEdep();
245 fHM->
H1(
"fhPsdEdepInEvent")->Fill(PsdEdepInEvent);
246 fHM->
H2(
"fhTofTrackMultPsdEdep")->Fill(PsdEdepInEvent, nofTofTracksInEvent);
247 fHM->
H2(
"fhTofHitMultPsdEdep")->Fill(PsdEdepInEvent, nofTofHitsInEvent);
249 for (
int j = 0; j < nofTofHitsInEvent; j++) {
254 fHM->
H1(
"fhTofHitsZ")->Fill(tofHit->
GetZ());
255 fHM->
H1(
"fhTofHitsXZ")->Fill(tofHit->
GetZ(), tofHit->
GetX());
259 fHM->
H1(
"fhTofTracksPerEvent")->Fill(nofTofTracksInEvent);
260 for (
int j = 0; j < nofTofTracksInEvent; j++) {
277 double nofEvents =
fHM->
H1(
"fhNofCbmEvents")->GetEntries();
281 fHM->
CreateCanvas(
"psd_mcbm_fhNofEntries",
"psd_mcbm_fhNofEntries", 600, 600);
286 fHM->
CreateCanvas(
"psd_mcbm_fhNofCbmEvents",
"psd_mcbm_fhNofCbmEvents", 600, 600);
297 TCanvas* c =
fHM->
CreateCanvas(
"psd_mcbm_nofObjectsInTimeslice",
"psd_mcbm_nofObjectsInTimeslice", 1500, 500);
311 fHM->
CreateCanvas(
"psd_mcbm_DigisTimeLog",
"psd_mcbm_DigisTimeLog", 1200, 1200);
313 fHM->
H1(
"fhPsdDigisTimeLog")},
314 {
"STS",
"TOF",
"Bmon",
"PSD"},
kLinear,
kLog,
true, 0.87, 0.75, 0.99, 0.99);
315 gPad->SetLeftMargin(0.1);
316 gPad->SetRightMargin(0.10);
317 fHM->
H1(
"fhStsDigisTimeLog")->GetYaxis()->SetTitleOffset(0.7);
318 fHM->
H1(
"fhStsDigisTimeLog")->SetMinimum(0.9);
322 fHM->
CreateCanvas(
"psd_mcbm_fhPsdDigisEdep",
"psd_mcbm_fhPsdDigisEdep", 600, 600);
327 fHM->
CreateCanvas(
"psd_mcbm_fhPsdHitEdep",
"psd_mcbm_fhPsdHitEdep", 600, 600);
332 fHM->
CreateCanvas(
"psd_mcbm_fhPsdEdepInEvent",
"psd_mcbm_fhPsdEdepInEvent", 600, 600);
337 fHM->
CreateCanvas(
"psd_mcbm_fhTofTrackMultPsdEdep",
"psd_mcbm_fhTofTrackMultPsdEdep", 1200, 1200);
342 fHM->
CreateCanvas(
"psd_mcbm_fhTofHitMultPsdEdep",
"psd_mcbm_fhTofHitMultPsdEdep", 1200, 1200);
358 fHM->
H3(
"fhTofXYZ")->Draw();
362 TCanvas* c =
fHM->
CreateCanvas(
"TofTracksXY",
"TofTracksXY", 1200, 800);
375 std::cout <<
"Drawing Hists...";
377 std::cout <<
"DONE!" << std::endl;
381 std::cout <<
"Canvas saved to Images!" << std::endl;
386 TFile* oldFile = gFile;
387 TDirectory* oldDir = gDirectory;
389 std::string s =
fOutputDir +
"/RecoHists.root";
390 TFile* outFile =
new TFile(s.c_str(),
"RECREATE");
391 if (outFile->IsOpen()) {
393 std::cout <<
"Written to Root-file \"" << s <<
"\" ...";
395 std::cout <<
"Done!" << std::endl;
409 TFile* oldFile = gFile;
410 TDirectory* oldDir = gDirectory;
412 if (
fHM !=
nullptr)
delete fHM;
415 TFile* file =
new TFile(fileName.c_str());
ClassImp(CbmConverterManager)
@ kTof
Time-of-flight Detector.
@ kPsd
Projectile spectator detector.
@ kSts
Silicon Tracking System.
void DrawH1(TH1 *hist, HistScale logx, HistScale logy, const string &drawOpt, Int_t color, Int_t lineWidth, Int_t lineStyle, Int_t markerSize, Int_t markerStyle)
void DrawH2(TH2 *hist, HistScale logx, HistScale logy, HistScale logz, const string &drawOpt)
Helper functions for drawing 1D and 2D histograms and graphs.
TClonesArray * fTofTracks
FairTask for matching RECO data to MC.
static Int_t GetNofDigis(ECbmModuleId systemId)
static Bool_t IsPresent(ECbmModuleId systemId)
Presence of a digi branch.
InitStatus Init()
Initialisation.
const Digi * Get(Int_t index) const
Get a digi object.
static CbmDigiManager * Instance()
Static instance.
Class characterising one event by a collection of links (indices) to data objects,...
size_t GetNofData() const
uint32_t GetIndex(ECbmDataType type, uint32_t iData)
TCanvas * CreateCanvas(const std::string &name, const std::string &title, Int_t width, Int_t height)
Create and draw TCanvas and store pointer to it.
void SaveCanvasToImage(const std::string &outputDir, const std::string &options="png,eps")
Save all stored canvases to images.
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 ReadFromFile(TFile *file)
Read histograms from file.
void ScaleByPattern(const std::string &pattern, Double_t scale)
Scale histograms which name matches specified pattern.
void WriteToFile()
Write all objects to current opened file.
TH3 * H3(const std::string &name) const
Return pointer to TH3 histogram.
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 Create3(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, Int_t nofBinsZ, Double_t minBinZ, Double_t maxBinZ)
Helper function for creation of 3-dimensional histograms and profiles. Template argument is a real ob...
TH1 * H1(const std::string &name) const
Return pointer to TH1 histogram.
Data class for PSD digital information.
double GetEdep() const
Energy deposit.
double GetTime() const
Time.
data class for hit information in PSD
double GetSectionID() const
Index of PSD section @value section index [].
int32_t GetModuleID() const
Index of PSD module @value module index [].
double GetEdep() const
Energy deposited in PSD section @value Energy [a.u.].
CbmDigiManager * fDigiMan
bool fDigiHitsInitialized
void DrawHist()
Draw histograms.
void DrawFromFile(const string &fileName, const string &outputDir)
Draw histogram from file.
virtual void Exec(Option_t *option)
Inherited from FairTask.
virtual InitStatus Init()
Inherited from FairTask.
TClonesArray * fTofTracks
void InitHistograms()
Initialize histograms.
CbmPsdMCbmQaReal()
Standard constructor.
virtual void Finish()
Inherited from FairTask.
Data class for a single-channel message in the STS.
Data class for expanded digital TOF information.
double GetTime() const
Inherited from CbmDigi.
Provides information on attaching a TofHit to a TofTrack.