15 #include "CbmTofHit.h"
20 #include "TClonesArray.h"
21 #include "TDatabasePDG.h"
23 #include "TParticlePDG.h"
26 #include <boost/assign/list_of.hpp>
31 using boost::assign::list_of;
39 : fIsFixedBounds(true)
40 , fOutputDir(
"./test/")
47 , fStsTrackMatches(NULL)
50 , fTofHitsMatches(NULL)
56 , fTrackAcceptanceFunctions()
57 , fMCTrackIdForTofHits()
58 , fMCTrackIdForTofPoints() {
75 static Int_t nofEvents = 0;
77 std::cout <<
"CbmLitTofQa::Exec: event=" << nofEvents << std::endl;
87 TDirectory* oldir = gDirectory;
88 TFile* outFile = FairRootManager::Instance()->GetOutFile();
89 if (outFile != NULL) {
93 gDirectory->cd(oldir->GetPath());
101 FairRootManager* ioman = FairRootManager::Instance();
102 assert(ioman != NULL);
107 fGlobalTracks = (TClonesArray*) ioman->GetObject(
"GlobalTrack");
108 fStsTracks = (TClonesArray*) ioman->GetObject(
"StsTrack");
110 fTofHits = (TClonesArray*) ioman->GetObject(
"TofHit");
113 fTofTracks = (TClonesArray*) ioman->GetObject(
"TofTrack");
129 vector<string> tmp = list_of(
"All")(
"Positive")(
"Negative")(
"Primary")(
130 "Secondary")(
"Electron")(
"Muon")(
"Proton")(
"AntiProton")(
"Pion")(
131 "PionPlus")(
"PionMinus")(
"Kaon")(
"KaonPlus")(
"KaonMinus");
168 for (Int_t iCat = 0; iCat < nofTrackCategories; iCat++) {
171 new TH2F(name.c_str(),
172 string(name +
";P [GeV/c];M^{2} [(GeV/c)^{2}]").c_str(),
181 new TH2F(name.c_str(),
182 string(name +
";P [GeV/c];M^{2} [(GeV/c)^{2}]").c_str(),
191 new TH2F(name.c_str(),
192 string(name +
";P [GeV/c];M^{2} [(GeV/c)^{2}]").c_str(),
201 new TH2F(name.c_str(),
202 string(name +
";P [GeV/c];M^{2} [(GeV/c)^{2}]").c_str(),
214 name.c_str(),
string(name +
";Distance [cm]").c_str(), 200, 0., 50.));
217 new TH1F(name.c_str(),
218 string(name +
";Normalized distance").c_str(),
226 name.c_str(),
string(name +
";Length [cm]").c_str(), 1200, 0., 1200.));
229 new TH1F(name.c_str(),
230 string(name +
";number of hits per global track").c_str(),
235 string name =
"hmp_Tof_dTime";
237 new TH1F(name.c_str(),
238 string(name +
";dt [ps];Counter").c_str(),
242 name =
"hmp_Tof_TimeZero_a";
244 new TH1F(name.c_str(),
245 string(name +
";Time [ns];Counter").c_str(),
249 name =
"hmp_Tof_TimeZero_reco";
251 new TH1F(name.c_str(),
252 string(name +
";Time [ns];Counter").c_str(),
256 name =
"hmp_Tof_TimeZero_mc";
258 new TH1F(name.c_str(),
259 string(name +
";Time [ns];Counter").c_str(),
263 name =
"hmp_Tof_TimeZero_NofTracks";
265 new TH1F(name.c_str(),
266 string(name +
";Number of tracks;Counter").c_str(),
270 name =
"hmp_Tof_Time_FirstTrack";
272 new TH1F(name.c_str(),
273 string(name +
";Time [ns];Counter").c_str(),
283 Int_t nofHits =
fTofHits->GetEntriesFast();
284 for (Int_t iHit = 0; iHit < nofHits; iHit++) {
287 if (tofHitMatch == NULL) {
continue; }
293 make_pair(tofPointEventNo, tofPoint->GetTrackID()));
297 for (Int_t iPoint = 0; iPoint < nofPoints; iPoint++) {
301 pair<Int_t, Int_t>(iEvent, tofPoint->GetTrackID()));
306 Double_t timeZeroReco = 0.0;
307 Double_t timeZeroMC = 0.0;
308 Double_t timeFirstTrack = 100.;
309 Double_t timeZeroA = 0.;
310 Int_t nofTracksForTimeZero = 0;
313 for (Int_t iTrack = 0; iTrack < nofGlobalTracks; iTrack++) {
318 if (stsId < 0 || tofId < 0)
continue;
328 if (tofHitMatch == NULL) {
continue; }
333 Int_t tofMCTrackId = tofPoint->GetTrackID();
336 FairTrackParam vtxTrack;
339 float chiSqPrimary = 0.f;
343 Bool_t chiSqPrimaryOk = chiSqPrimary < 3.;
346 Double_t ctCorrection = 0.0;
347 Double_t ctReco = 0.299792458 * tofHit->
GetTime()
351 * tofPoint->GetTime();
352 Double_t trackLengthReco = globalTrack->
GetLength() / 100.;
355 (vtxTrack.GetQp() != 0) ? std::abs(1. / vtxTrack.GetQp()) : 0;
356 Double_t t = (trackLengthReco != 0) ? (ctReco / trackLengthReco) : 0;
357 Double_t m2reco = preco * preco * (t * t - 1);
361 if (chiSqPrimaryOk && radialPos < 50.) {
362 nofTracksForTimeZero++;
365 beta = preco /
sqrt(preco * preco + 0.93827231 * 0.93827231);
367 beta = preco /
sqrt(preco * preco + 0.1395679 * 0.1395679);
369 tofHit->
GetTime() - trackLengthReco / (beta * 0.299792458);
371 tofPoint->GetTime() - trackLengthReco / (beta * 0.299792458);
372 timeZeroA += trackLengthReco / 0.299792458;
373 timeFirstTrack =
std::min(timeFirstTrack, trackLengthReco / 0.299792458);
377 for (Int_t iCat = 0; iCat < nofTrackCategories; iCat++) {
381 Bool_t categoryOk =
function(
fMCTracks, tofMCEventId, stsMCTrackId);
387 if (categoryOk && chiSqPrimaryOk) {
388 fHM->
H1(
"hmp_Tof_Reco_" + category +
"_m2p")->Fill(preco, m2reco);
390 fHM->
H1(
"hmp_Tof_RecoAccTof_" + category +
"_m2p")
391 ->Fill(preco, m2reco);
393 if (stsMCTrackId == tofMCTrackId) {
394 fHM->
H1(
"hmp_Tof_RecoMCID_" + category +
"_m2p")->Fill(preco, m2reco);
396 fHM->
H1(
"hmp_Tof_RecoMCIDAccTof_" + category +
"_m2p")
397 ->Fill(preco, m2reco);
402 if (nofTracksForTimeZero > 0) {
403 timeZeroReco /= nofTracksForTimeZero;
404 timeZeroMC /= nofTracksForTimeZero;
405 timeZeroA /= nofTracksForTimeZero;
407 fHM->
H1(
"hmp_Tof_TimeZero_reco")->Fill(timeZeroReco);
408 fHM->
H1(
"hmp_Tof_TimeZero_mc")->Fill(timeZeroMC);
409 fHM->
H1(
"hmp_Tof_TimeZero_a")->Fill(timeZeroA);
410 fHM->
H1(
"hmp_Tof_TimeZero_NofTracks")->Fill(nofTracksForTimeZero);
411 fHM->
H1(
"hmp_Tof_Time_FirstTrack")->Fill(timeFirstTrack);
415 Int_t nofTofHits =
fTofHits->GetEntriesFast();
416 for (Int_t iHit = 0; iHit < nofTofHits; iHit++) {
419 if (tofHitMatch == NULL) {
continue; }
424 Int_t tofMCTrackId = tofPoint->GetTrackID();
426 fHM->
H1(
"hmp_Tof_dTime")
427 ->Fill(1000 * (tofPoint->GetTime() - tofHit->
GetTime()));
432 map<Int_t, Int_t> nofTofHitsPerGlobalTrack;
433 Int_t nofTofTracks =
fTofTracks->GetEntriesFast();
434 for (Int_t iTrack = 0; iTrack < nofTofTracks; iTrack++) {
440 for (Int_t iTrack = 0; iTrack < nofTofTracks; iTrack++) {
447 if (tofHitMatch == NULL) {
continue; }
450 const FairMCPoint* tofPoint =
static_cast<const FairMCPoint*
>(
452 Int_t tofMCTrackId = tofPoint->GetTrackID();
455 Double_t dx = par->GetX() - tofHit->
GetX();
456 Double_t dy = par->GetY() - tofHit->
GetY();
457 Double_t distance =
sqrt(dx * dx + dy * dy);
460 for (Int_t iCat = 0; iCat < nofTrackCategories; iCat++) {
464 Bool_t categoryOk =
function(
fMCTracks, tofMCEventId, tofMCTrackId);
466 fHM->
H1(
"hmp_TofTrack_" + category +
"_Distance")->Fill(distance);
467 fHM->
H1(
"hmp_TofTrack_" + category +
"_NormDistance")
469 fHM->
H1(
"hmp_TofTrack_" + category +
"_Length")
471 fHM->
H1(
"hmp_TofTrack_" + category +
"_NofHitsPerGlobalTrack")
479 fHM->
H2(
"hmp_Tof_RecoMCID_Pion_m2p")->FitSlicesY();
481 (TH1*) gDirectory->Get(
"hmp_Tof_RecoMCID_Pion_m2p_1");
483 (TH1*) gDirectory->Get(
"hmp_Tof_RecoMCID_Pion_m2p_2");
484 Int_t nofBins = meanHist->GetNbinsX();
485 for (Int_t iBin = 0; iBin <= nofBins; iBin++) {
486 Double_t mean = meanHist->GetBinContent(iBin);
487 Double_t sigma = sigmaHist->GetBinContent(iBin);
488 std::cout <<
"mean=" << mean <<
" sigma=" << sigma << std::endl;