25#include "TClonesArray.h"
26#include "TDatabasePDG.h"
28#include "TParticlePDG.h"
31#include <FairRootManager.h>
35#include <boost/assign/list_of.hpp>
41using boost::assign::list_of;
49 : fIsFixedBounds(true)
50 , fOutputDir(
"./test/")
57 , fStsTrackMatches(NULL)
60 , fTofHitsMatches(NULL)
65 , fTrackAcceptanceFunctions()
66 , fMCTrackIdForTofHits()
67 , fMCTrackIdForTofPoints()
87 static Int_t nofEvents = 0;
89 std::cout <<
"CbmLitTofQa::Exec: event=" << nofEvents << std::endl;
100 TDirectory* oldir = gDirectory;
101 TFile* outFile = FairRootManager::Instance()->GetOutFile();
102 if (outFile != NULL) {
106 gDirectory->cd(oldir->GetPath());
115 FairRootManager* ioman = FairRootManager::Instance();
116 assert(ioman != NULL);
120 fGlobalTracks = (TClonesArray*) ioman->GetObject(
"GlobalTrack");
121 fStsTracks = (TClonesArray*) ioman->GetObject(
"StsTrack");
123 fTofHits = (TClonesArray*) ioman->GetObject(
"TofHit");
126 fTofTracks = (TClonesArray*) ioman->GetObject(
"TofTrack");
143 vector<string> tmp = list_of(
"All")(
"Positive")(
"Negative")(
"Primary")(
"Secondary")(
"Electron")(
"Muon")(
"Proton")(
144 "AntiProton")(
"Pion")(
"PionPlus")(
"PionMinus")(
"Kaon")(
"KaonPlus")(
"KaonMinus");
167 for (Int_t iCat = 0; iCat < nofTrackCategories; iCat++) {
169 fHM->
Add(name,
new TH2F(name.c_str(),
string(name +
";P [GeV/c];M^{2} [(GeV/c)^{2}]").c_str(),
fPRangeBins,
172 fHM->
Add(name,
new TH2F(name.c_str(),
string(name +
";P [GeV/c];M^{2} [(GeV/c)^{2}]").c_str(),
fPRangeBins,
175 fHM->
Add(name,
new TH2F(name.c_str(),
string(name +
";P [GeV/c];M^{2} [(GeV/c)^{2}]").c_str(),
fPRangeBins,
178 fHM->
Add(name,
new TH2F(name.c_str(),
string(name +
";P [GeV/c];M^{2} [(GeV/c)^{2}]").c_str(),
fPRangeBins,
182 fHM->
Add(name,
new TH1F(name.c_str(),
string(name +
";Distance [cm]").c_str(), 200, 0., 50.));
184 fHM->
Add(name,
new TH1F(name.c_str(),
string(name +
";Normalized distance").c_str(), 200, 0., 50.));
186 fHM->
Add(name,
new TH1F(name.c_str(),
string(name +
";Length [cm]").c_str(), 1200, 0., 1200.));
188 fHM->
Add(name,
new TH1F(name.c_str(),
string(name +
";number of hits per global track").c_str(), 11, -0.5, 10.5));
190 string name =
"hmp_Tof_dTime";
191 fHM->
Add(name,
new TH1F(name.c_str(),
string(name +
";dt [ps];Counter").c_str(), 1000, -500., 500.));
192 name =
"hmp_Tof_TimeZero_a";
193 fHM->
Add(name,
new TH1F(name.c_str(),
string(name +
";Time [ns];Counter").c_str(), 2000, 0., 36.));
194 name =
"hmp_Tof_TimeZero_reco";
195 fHM->
Add(name,
new TH1F(name.c_str(),
string(name +
";Time [ns];Counter").c_str(), 2000, -5., 15.));
196 name =
"hmp_Tof_TimeZero_mc";
197 fHM->
Add(name,
new TH1F(name.c_str(),
string(name +
";Time [ns];Counter").c_str(), 2000, -5., 15.));
198 name =
"hmp_Tof_TimeZero_NofTracks";
199 fHM->
Add(name,
new TH1F(name.c_str(),
string(name +
";Number of tracks;Counter").c_str(), 100, 0., 100.));
200 name =
"hmp_Tof_Time_FirstTrack";
201 fHM->
Add(name,
new TH1F(name.c_str(),
string(name +
";Time [ns];Counter").c_str(), 2000, 0., 36.));
204 fHM->
Add(name,
new TH1F(name.c_str(),
string(name +
";Z [cm];Counter").c_str(), 200, 650, 900));
205 name =
"hmp_TofTrack_Z";
206 fHM->
Add(name,
new TH1F(name.c_str(),
string(name +
";Z [cm];Counter").c_str(), 200, 650, 900));
214 Int_t nofHits =
fTofHits->GetEntriesFast();
215 for (Int_t iHit = 0; iHit < nofHits; iHit++) {
218 if (tofHitMatch == NULL) {
228 for (Int_t iPoint = 0; iPoint < nofPoints; iPoint++) {
236 Double_t timeZeroReco = 0.0;
237 Double_t timeZeroMC = 0.0;
238 Double_t timeFirstTrack = 100.;
239 Double_t timeZeroA = 0.;
240 Int_t nofTracksForTimeZero = 0;
243 for (Int_t iTrack = 0; iTrack < nofGlobalTracks; iTrack++) {
247 if (stsId < 0 || tofId < 0)
continue;
255 if (tofHitMatch == NULL) {
261 Int_t tofMCTrackId = tofPoint->GetTrackID();
264 FairTrackParam vtxTrack;
265 float chiSqPrimary = 0.f;
268 Bool_t chiSqPrimaryOk = chiSqPrimary < 3.;
271 Double_t ctCorrection = 0.0;
272 Double_t ctReco = 0.299792458 * tofHit->
GetTime() + ctCorrection;
274 Double_t trackLengthReco = globalTrack->
GetLength() / 100.;
276 Double_t preco = (vtxTrack.GetQp() != 0) ? std::abs(1. / vtxTrack.GetQp()) : 0;
277 Double_t t = (trackLengthReco != 0) ? (ctReco / trackLengthReco) : 0;
278 Double_t m2reco = preco * preco * (t * t - 1);
281 if (chiSqPrimaryOk && radialPos < 50.) {
282 nofTracksForTimeZero++;
284 if (m2reco > 0.6) beta = preco /
sqrt(preco * preco + 0.93827231 * 0.93827231);
285 if (m2reco <= 0.6) beta = preco /
sqrt(preco * preco + 0.1395679 * 0.1395679);
286 timeZeroReco += tofHit->
GetTime() - trackLengthReco / (beta * 0.299792458);
287 timeZeroMC += tofPoint->GetTime() - trackLengthReco / (beta * 0.299792458);
288 timeZeroA += trackLengthReco / 0.299792458;
289 timeFirstTrack = std::min(timeFirstTrack, trackLengthReco / 0.299792458);
293 for (Int_t iCat = 0; iCat < nofTrackCategories; iCat++) {
296 Bool_t categoryOk = function(
fMCTracks, tofMCEventId, stsMCTrackId);
300 if (categoryOk && chiSqPrimaryOk) {
301 fHM->
H1(
"hmp_Tof_Reco_" + category +
"_m2p")->Fill(preco, m2reco);
302 if (accTofOk)
fHM->
H1(
"hmp_Tof_RecoAccTof_" + category +
"_m2p")->Fill(preco, m2reco);
304 if (stsMCTrackId == tofMCTrackId) {
305 fHM->
H1(
"hmp_Tof_RecoMCID_" + category +
"_m2p")->Fill(preco, m2reco);
306 if (accTofOk)
fHM->
H1(
"hmp_Tof_RecoMCIDAccTof_" + category +
"_m2p")->Fill(preco, m2reco);
311 if (nofTracksForTimeZero > 0) {
312 timeZeroReco /= nofTracksForTimeZero;
313 timeZeroMC /= nofTracksForTimeZero;
314 timeZeroA /= nofTracksForTimeZero;
316 fHM->
H1(
"hmp_Tof_TimeZero_reco")->Fill(timeZeroReco);
317 fHM->
H1(
"hmp_Tof_TimeZero_mc")->Fill(timeZeroMC);
318 fHM->
H1(
"hmp_Tof_TimeZero_a")->Fill(timeZeroA);
319 fHM->
H1(
"hmp_Tof_TimeZero_NofTracks")->Fill(nofTracksForTimeZero);
320 fHM->
H1(
"hmp_Tof_Time_FirstTrack")->Fill(timeFirstTrack);
325 Int_t nofTofHits =
fTofHits->GetEntriesFast();
326 for (Int_t iHit = 0; iHit < nofTofHits; iHit++) {
329 if (tofHitMatch == NULL) {
337 fHM->
H1(
"hmp_Tof_dTime")->Fill(1000 * (tofPoint->GetTime() - tofHit->
GetTime()));
338 fHM->
H1(
"hmp_Tof_Z")->Fill(tofHit->
GetZ());
344 map<Int_t, Int_t> nofTofHitsPerGlobalTrack;
345 Int_t nofTofTracks =
fTofTracks->GetEntriesFast();
346 for (Int_t iTrack = 0; iTrack < nofTofTracks; iTrack++) {
351 for (Int_t iTrack = 0; iTrack < nofTofTracks; iTrack++) {
355 if (tofHitMatch == NULL) {
360 const FairMCPoint* tofPoint =
static_cast<const FairMCPoint*
>(
fTofPoints->
Get(0, tofMCEventId, tofMCPointId));
361 Int_t tofMCTrackId = tofPoint->GetTrackID();
364 Double_t dx = par->GetX() - tofHit->
GetX();
365 Double_t dy = par->GetY() - tofHit->
GetY();
366 Double_t distance =
sqrt(dx * dx + dy * dy);
368 fHM->
H1(
"hmp_TofTrack_Z")->Fill(tofHit->
GetZ());
371 for (Int_t iCat = 0; iCat < nofTrackCategories; iCat++) {
374 Bool_t categoryOk = function(
fMCTracks, tofMCEventId, tofMCTrackId);
376 fHM->
H1(
"hmp_TofTrack_" + category +
"_Distance")->Fill(distance);
377 fHM->
H1(
"hmp_TofTrack_" + category +
"_NormDistance")->Fill(tofTrack->
GetDistance());
379 fHM->
H1(
"hmp_TofTrack_" + category +
"_NofHitsPerGlobalTrack")
388 fHM->
H2(
"hmp_Tof_RecoMCID_Pion_m2p")->FitSlicesY();
389 TH1* meanHist = gDirectory->Get<TH1>(
"hmp_Tof_RecoMCID_Pion_m2p_1");
390 TH1* sigmaHist = gDirectory->Get<TH1>(
"hmp_Tof_RecoMCID_Pion_m2p_2");
391 Int_t nofBins = meanHist->GetNbinsX();
392 for (Int_t iBin = 0; iBin <= nofBins; iBin++) {
393 Double_t mean = meanHist->GetBinContent(iBin);
394 Double_t sigma = sigmaHist->GetBinContent(iBin);
395 std::cout <<
"mean=" << mean <<
" sigma=" << sigma << std::endl;
ClassImp(CbmConverterManager)
TClonesArray * fTofTracks
Global function to define the track acceptance. Used in QA.
Create report for TOF QA.
Data class for STS tracks.
friend fvec sqrt(const fvec &a)
int32_t GetStsTrackIndex() const
int32_t GetTofHitIndex() const
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.
static void ExtrapolateTrackToPV(const CbmStsTrack *track, CbmVertex *pv, FairTrackParam *paramAtPV, float &chiPrim)
static Bool_t KaonTrackAcceptanceFunction(CbmMCDataArray *mcTracks, Int_t eventNo, Int_t index)
static Bool_t KaonMinusTrackAcceptanceFunction(CbmMCDataArray *mcTracks, Int_t eventNo, Int_t index)
static Bool_t PionMinusTrackAcceptanceFunction(CbmMCDataArray *mcTracks, Int_t eventNo, Int_t index)
static Bool_t AllTrackAcceptanceFunction(CbmMCDataArray *, Int_t, Int_t)
static Bool_t PionTrackAcceptanceFunction(CbmMCDataArray *mcTracks, Int_t eventNo, Int_t index)
static Bool_t NegativeTrackAcceptanceFunction(CbmMCDataArray *mcTracks, Int_t eventNo, Int_t index)
static Bool_t MuonTrackAcceptanceFunction(CbmMCDataArray *mcTracks, Int_t eventNo, Int_t index)
static Bool_t PionPlusTrackAcceptanceFunction(CbmMCDataArray *mcTracks, Int_t eventNo, Int_t index)
static Bool_t SecondaryTrackAcceptanceFunction(CbmMCDataArray *mcTracks, Int_t eventNo, Int_t index)
static Bool_t KaonPlusTrackAcceptanceFunction(CbmMCDataArray *mcTracks, Int_t eventNo, Int_t index)
static Bool_t ProtonTrackAcceptanceFunction(CbmMCDataArray *mcTracks, Int_t eventNo, Int_t index)
static Bool_t PositiveTrackAcceptanceFunction(CbmMCDataArray *mcTracks, Int_t eventNo, Int_t index)
static Bool_t AntiProtonTrackAcceptanceFunction(CbmMCDataArray *mcTracks, Int_t eventNo, Int_t index)
static Bool_t PrimaryTrackAcceptanceFunction(CbmMCDataArray *mcTracks, Int_t eventNo, Int_t index)
static Bool_t ElectronTrackAcceptanceFunction(CbmMCDataArray *mcTracks, Int_t eventNo, Int_t index)
Create report for TOF QA.
virtual ~CbmLitTofQa()
Destructor.
CbmMCDataArray * fTofPoints
TClonesArray * fStsTracks
virtual void Finish()
Inherited from FairTask.
void FillTrackCategoriesAndAcceptanceFunctions()
Assign default track categories and track acceptance functions.
void ProcessMC(Int_t iEvent)
set< pair< Int_t, Int_t > > fMCTrackIdForTofHits
TClonesArray * fTofTracks
set< pair< Int_t, Int_t > > fMCTrackIdForTofPoints
virtual void Exec(Option_t *opt)
Inherited from FairTask.
CbmMCDataArray * fMCTracks
CbmLitTofQa()
Constructor.
void ReadDataBranches()
Reads data branches.
void ProcessGlobalTracks()
TClonesArray * fStsTrackMatches
TClonesArray * fGlobalTracks
vector< string > fTrackCategories
void CreateHistograms()
Creates histograms.
TClonesArray * fTofHitsMatches
map< string, LitTrackAcceptanceFunction > fTrackAcceptanceFunctions
Bool_t(*) LitTrackAcceptanceFunction(CbmMCDataArray *mcTracks, Int_t eventNo, Int_t index)
virtual InitStatus Init()
Inherited from FairTask.
TObject * Get(const CbmLink *lnk)
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)
const CbmLink & GetMatchedLink() const
Base class for simulation reports.
void Create(CbmHistManager *histManager, const std::string &outputDir)
Main function which creates report data.
Geometric intersection of a MC track with a TOFb detector.
int32_t GetTofHitIndex() const
double GetTrackLength() const
double GetDistance() const
int32_t GetTrackIndex() const
const FairTrackParam * GetTrackParameter() const