CbmRoot
CbmTrdTracksPidQa.cxx
Go to the documentation of this file.
1 // -----------------------------------------------------------------------
2 // ----- CbmTrdTracksPidQa -----
3 // ----- Created 24.02.07 by F. Uhlig -----
4 // -----------------------------------------------------------------------
5 
6 #include "CbmTrdTracksPidQa.h"
7 
8 #include "CbmTrdHit.h"
9 #include "CbmTrdPoint.h"
10 #include "CbmTrdTrack.h"
11 
12 #include "CbmMCTrack.h"
13 #include "FairRootManager.h"
14 
15 #include "TClonesArray.h"
16 #include "TH1F.h"
17 #include "TH2F.h"
18 #include "TMath.h"
19 #include "TVector3.h"
20 
21 #include <iostream>
22 using std::cout;
23 using std::endl;
24 
25 // ---- Default constructor -------------------------------------------------
26 
28  : CbmTrdTracksPidQa("TrdTracksPidQa", "") {}
29 // --------------------------------------------------------------------------
30 
31 
32 // ---- Standard constructor ------------------------------------------------
33 CbmTrdTracksPidQa::CbmTrdTracksPidQa(const char* name, const char*)
34  : FairTask(name)
35  , fTrdTrackCollection(NULL)
36  , fTrdHitCollection(NULL)
37  , fMCPointArray(NULL)
38  , fMCTrackArray(NULL)
39  , PartID(new TH1F("PartID", "Particle ID of the Track", 4600, -2300., 2300.))
40  , NrTRDHits(new TH1F("NrTRDHits", "Nr. of TRD Hits for track", 20, 0., 20.))
41  , ELossPI(new TH1F("ELossPI", "summed ELoss for pions", 2000, 0., 200.))
42  , ELossEL(new TH1F("ELossEL", "summed ELoss for electrons", 2000, 0., 200.))
43  , ELossALL(new TH1F("ELossALL",
44  "summed ELoss for all except electrons",
45  2000,
46  0.,
47  200.))
48  , MomPI(new TH1F("MomPI", "summed Momentum for pions", 110, 0., 11.))
49  , MomEL(new TH1F("MomEL", "summed Momentum for electrons", 110, 0., 11.))
50  , MomALL(new TH1F("MomALL",
51  "summed Momentum for all except electrons",
52  110,
53  0.,
54  11.))
55  , MOMvsELossEL(new TH2F("MomvsElossEL",
56  "Momentum vs Eloss PI",
57  2000,
58  0.,
59  200.,
60  110,
61  0.,
62  11.))
63  , MOMvsELossPI(new TH2F("MomvsElossPI",
64  "Momentum vs Eloss EL",
65  2000,
66  0.,
67  200.,
68  110,
69  0.,
70  11.))
71  , MOMvsELossALL(new TH2F("MomvsElossALL",
72  "Momentum vs Eloss EL",
73  2000,
74  0.,
75  200.,
76  110,
77  0.,
78  11.))
79  , WknPI(new TH1F("WknPI", "Wkn for pions ", 10000, 0., 2000.))
80  , WknEL(new TH1F("WknEL", "Wkn for electrons ", 10000, 0., 2000.))
81  , WknALL(new TH1F("WknALL",
82  "Wkn for all particles except electrons ",
83  10000,
84  0.,
85  2000.))
86  , WknLowPI(new TH1F("WknLowPI", "Wkn for pions ", 10000, 0., 2000.))
87  , WknLowEL(new TH1F("WknLowEL", "Wkn for electrons ", 10000, 0., 2000.))
88  , WknLowALL(new TH1F("WknLowALL",
89  "Wkn for all particles except electrons ",
90  10000,
91  0.,
92  2000.))
93  , WknHighPI(new TH1F("WknHighPI", "Wkn for pions ", 10000, 0., 2000.))
94  , WknHighEL(new TH1F("WknHighEL", "Wkn for electrons ", 10000, 0., 2000.))
95  , WknHighALL(new TH1F("WknHighALL",
96  "Wkn for all particles except electrons ",
97  10000,
98  0.,
99  2000.))
100  , AnnPI(new TH1F("AnnPI", "Ann for pions ", 400, -2., 2.))
101  , AnnEL(new TH1F("AnnEL", "Ann for electrons ", 400, -2., 2.))
102  , AnnALL(new TH1F("AnnALL", "Ann for all except electrons ", 400, -2., 2.))
103  , AnnLowPI(new TH1F("AnnLowPI", "Ann for pions ", 400, -2., 2.))
104  , AnnLowEL(new TH1F("AnnLowEL", "Ann for electrons ", 400, -2., 2.))
105  , AnnLowALL(
106  new TH1F("AnnLowALL", "Ann for all except electrons ", 400, -2., 2.))
107  , AnnHighPI(new TH1F("AnnHighPI", "Ann for pions ", 400, -2., 2.))
108  , AnnHighEL(new TH1F("AnnHighEL", "Ann for electrons ", 400, -2., 2.))
109  , AnnHighALL(
110  new TH1F("AnnHighALL", "Ann for all except electrons ", 400, -2., 2.))
111  , LikePI(new TH1F("LikePI", "Likelihood for pions ", 400, -2., 2.))
112  , LikeEL(new TH1F("LikeEL", "Likelihood for electrons ", 400, -2., 2.))
113  , LikeALL(
114  new TH1F("LikeALL", "Likelihood for all except electrons ", 400, -2., 2.))
115  , LikeHighPI(new TH1F("LikeHighPI", "Likelihood for pions ", 400, -2., 2.))
116  , LikeHighEL(
117  new TH1F("LikeHighEL", "Likelihood for electrons ", 400, -2., 2.))
118  , LikeHighALL(new TH1F("LikeHighALL",
119  "Likelihood for all except electrons ",
120  400,
121  -2.,
122  2.))
123  , LikeLowPI(new TH1F("LikeLowPI", "Likelihood for pions ", 400, -2., 2.))
124  , LikeLowEL(new TH1F("LikeLowEL", "Likelihood for electrons ", 400, -2., 2.))
125  , LikeLowALL(new TH1F("LikeLowALL",
126  "Likelihood for all except electrons ",
127  400,
128  -2.,
129  2.)) {}
130 // --------------------------------------------------------------------------
131 
132 
133 // ---- Destructor ----------------------------------------------------------
135 // --------------------------------------------------------------------------
136 
137 
138 // ---- Initialisation ------------------------------------------------------
140  // Get pointer to the ROOT I/O manager
141  FairRootManager* rootMgr = FairRootManager::Instance();
142  if (NULL == rootMgr) {
143  cout << "-E- CbmTrdTrackPidQa::Init : "
144  << "ROOT manager is not instantiated !" << endl;
145  return kFATAL;
146  }
147 
148 
149  // Get pointer to TRD point array
150  fMCPointArray = (TClonesArray*) rootMgr->GetObject("TrdPoint");
151  if (NULL == fMCPointArray) {
152  cout << "-W- CbmTrdTracksPidQa::Init : "
153  << "no MC point array !" << endl;
154  return kERROR;
155  }
156 
157  // Get pointer to TRD hit array
158  fTrdHitCollection = (TClonesArray*) rootMgr->GetObject("TrdHit");
159  if (NULL == fTrdHitCollection) {
160  cout << "-W- CbmTrdTracksPidQa::Init : "
161  << "no TRD hit array !" << endl;
162  return kERROR;
163  }
164 
165  // Get pointer to TRD track array
166  fTrdTrackCollection = (TClonesArray*) rootMgr->GetObject("TrdTrack");
167  if (NULL == fTrdTrackCollection) {
168  cout << "-W- CbmTrdTracksPidQa::Init : "
169  << "no TRD hit array !" << endl;
170  return kERROR;
171  }
172 
173  // Get MCTrack array
174  fMCTrackArray = (TClonesArray*) rootMgr->GetObject("MCTrack");
175  if (!fMCTrackArray) {
176  cout << "-E- CbmTrdTracksPidQa::Init : No MCTrack array!" << endl;
177  return kFATAL;
178  }
179 
180  return kSUCCESS;
181 }
182 
183 // --------------------------------------------------------------------------
184 
185 
186 // ---- Task execution ------------------------------------------------------
187 void CbmTrdTracksPidQa::Exec(Option_t*) {
188  // Declare variables
189  CbmTrdTrack* trdTrack = NULL;
190  CbmTrdPoint* mcPoint = NULL;
191  CbmTrdHit* trdHit = NULL;
192 
193  Int_t partID;
194  Int_t nrtrdpoints;
195  TVector3 mom;
196  Double_t momentum;
197 
198  // Event counters
199  Int_t nTrdTrack = fTrdTrackCollection->GetEntriesFast();
200 
201  // Loop over TRD tracks
202  for (Int_t iTrack = 0; iTrack < nTrdTrack; iTrack++) {
203  trdTrack = (CbmTrdTrack*) fTrdTrackCollection->At(iTrack);
204  if (NULL == trdTrack) continue;
205 
206  nrtrdpoints = trdTrack->GetNofHits();
207 
208  trdHit = (CbmTrdHit*) fTrdHitCollection->At(trdTrack->GetHitIndex(1));
209  if (NULL == trdHit) continue;
210 
211  mcPoint = (CbmTrdPoint*) fMCPointArray->At(trdHit->GetRefId());
212  if (NULL == mcPoint) continue;
213 
214 
215  NrTRDHits->Fill(nrtrdpoints);
216 
217  if (nrtrdpoints == 12) {
218 
219  partID = (((CbmMCTrack*) fMCTrackArray->At(mcPoint->GetTrackID()))
220  ->GetPdgCode());
221  (((CbmMCTrack*) fMCTrackArray->At(mcPoint->GetTrackID()))
222  ->GetMomentum(mom));
223  momentum = mom.Mag();
224 
225  PartID->Fill(partID);
226  if (TMath::Abs(partID) == 11) {
227  WknEL->Fill(trdTrack->GetPidWkn());
228  AnnEL->Fill(trdTrack->GetPidANN());
229  LikeEL->Fill(trdTrack->GetPidLikeEL());
230 
231  ELossEL->Fill(trdTrack->GetELoss() * 1000000.);
232  MomEL->Fill(momentum);
233  MOMvsELossEL->Fill(trdTrack->GetELoss() * 1000000., momentum);
234 
235  if (momentum < 2.) {
236  LikeLowEL->Fill(trdTrack->GetPidLikeEL());
237  WknLowEL->Fill(trdTrack->GetPidWkn());
238  AnnLowEL->Fill(trdTrack->GetPidANN());
239  } else {
240  LikeHighEL->Fill(trdTrack->GetPidLikeEL());
241  WknHighEL->Fill(trdTrack->GetPidWkn());
242  AnnHighEL->Fill(trdTrack->GetPidANN());
243  }
244  }
245  if (TMath::Abs(partID) == 211) {
246  WknPI->Fill(trdTrack->GetPidWkn());
247  AnnPI->Fill(trdTrack->GetPidANN());
248  LikePI->Fill(trdTrack->GetPidLikeEL());
249 
250  ELossPI->Fill(trdTrack->GetELoss() * 1000000.);
251  MomPI->Fill(momentum);
252  MOMvsELossPI->Fill(trdTrack->GetELoss() * 1000000., momentum);
253  if (momentum < 2.) {
254  LikeLowPI->Fill(trdTrack->GetPidLikeEL());
255  WknLowPI->Fill(trdTrack->GetPidWkn());
256  AnnLowPI->Fill(trdTrack->GetPidANN());
257  } else {
258  LikeHighPI->Fill(trdTrack->GetPidLikeEL());
259  WknHighPI->Fill(trdTrack->GetPidWkn());
260  AnnHighPI->Fill(trdTrack->GetPidANN());
261  }
262  }
263  if (!(TMath::Abs(partID) == 11)) {
264  WknALL->Fill(trdTrack->GetPidWkn());
265  AnnALL->Fill(trdTrack->GetPidANN());
266  LikeALL->Fill(trdTrack->GetPidLikeEL());
267 
268  ELossALL->Fill(trdTrack->GetELoss() * 1000000.);
269  MomALL->Fill(momentum);
270  MOMvsELossALL->Fill(trdTrack->GetELoss() * 1000000., momentum);
271 
272  if (momentum < 2.) {
273  LikeLowALL->Fill(trdTrack->GetPidLikeEL());
274  WknLowALL->Fill(trdTrack->GetPidWkn());
275  AnnLowALL->Fill(trdTrack->GetPidANN());
276  } else {
277  LikeHighALL->Fill(trdTrack->GetPidLikeEL());
278  WknHighALL->Fill(trdTrack->GetPidWkn());
279  AnnHighALL->Fill(trdTrack->GetPidANN());
280  }
281  }
282  }
283  }
284 }
285 
286 // --------------------------------------------------------------------------
287 
288 
289 // ---- Finish --------------------------------------------------------------
291 // --------------------------------------------------------------------------
292 
293 // ---- Write test histograms ------------------------------------------------
294 
296 
297  // Write histos to output
298  gDirectory->mkdir("TrdTracksPidQA");
299  gDirectory->cd("TrdTracksPidQA");
300 
301  if (WknPI) WknPI->Write();
302  if (WknEL) WknEL->Write();
303  if (WknALL) WknALL->Write();
304  if (WknLowPI) WknLowPI->Write();
305  if (WknLowEL) WknLowEL->Write();
306  if (WknLowALL) WknLowALL->Write();
307  if (WknHighPI) WknHighPI->Write();
308  if (WknHighEL) WknHighEL->Write();
309  if (WknHighALL) WknHighALL->Write();
310 
311  if (AnnPI) AnnPI->Write();
312  if (AnnEL) AnnEL->Write();
313  if (AnnALL) AnnALL->Write();
314  if (AnnLowPI) AnnLowPI->Write();
315  if (AnnLowEL) AnnLowEL->Write();
316  if (AnnLowALL) AnnLowALL->Write();
317  if (AnnHighPI) AnnHighPI->Write();
318  if (AnnHighEL) AnnHighEL->Write();
319  if (AnnHighALL) AnnHighALL->Write();
320 
321  if (LikePI) LikePI->Write();
322  if (LikeEL) LikeEL->Write();
323  if (LikeALL) LikeALL->Write();
324  if (LikeHighPI) LikeHighPI->Write();
325  if (LikeHighEL) LikeHighEL->Write();
326  if (LikeHighALL) LikeHighALL->Write();
327  if (LikeLowPI) LikeLowPI->Write();
328  if (LikeLowEL) LikeLowEL->Write();
329  if (LikeLowALL) LikeLowALL->Write();
330 
331  if (PartID) PartID->Write();
332  if (NrTRDHits) NrTRDHits->Write();
333  if (ELossPI) ELossPI->Write();
334  if (ELossEL) ELossEL->Write();
335  if (ELossALL) ELossALL->Write();
336  if (MomPI) MomPI->Write();
337  if (MomEL) MomEL->Write();
338  if (MomALL) MomALL->Write();
339  if (MOMvsELossPI) MOMvsELossPI->Write();
340  if (MOMvsELossEL) MOMvsELossEL->Write();
341  if (MOMvsELossALL) MOMvsELossALL->Write();
342 
343  gDirectory->cd("..");
344 }
345 
346 // --------------------------------------------------------------------------
347 
CbmTrdTracksPidQa::LikeEL
TH1F * LikeEL
Definition: CbmTrdTracksPidQa.h:92
CbmTrdTracksPidQa::~CbmTrdTracksPidQa
virtual ~CbmTrdTracksPidQa()
Definition: CbmTrdTracksPidQa.cxx:134
CbmTrdTracksPidQa::LikePI
TH1F * LikePI
Definition: CbmTrdTracksPidQa.h:91
CbmTrdTracksPidQa::fMCTrackArray
TClonesArray * fMCTrackArray
Definition: CbmTrdTracksPidQa.h:55
CbmTrack::GetNofHits
virtual Int_t GetNofHits() const
Definition: CbmTrack.h:53
CbmTrdTracksPidQa::AnnLowALL
TH1F * AnnLowALL
Definition: CbmTrdTracksPidQa.h:86
CbmTrdTracksPidQa.h
CbmTrdTracksPidQa
Definition: CbmTrdTracksPidQa.h:29
CbmTrdTracksPidQa::WknLowALL
TH1F * WknLowALL
Definition: CbmTrdTracksPidQa.h:76
CbmTrdTracksPidQa::fTrdHitCollection
TClonesArray * fTrdHitCollection
Definition: CbmTrdTracksPidQa.h:53
CbmTrdTrack::GetPidLikeEL
Double_t GetPidLikeEL() const
Definition: CbmTrdTrack.h:34
CbmTrdTracksPidQa::AnnLowPI
TH1F * AnnLowPI
Definition: CbmTrdTracksPidQa.h:84
CbmTrdTracksPidQa::MOMvsELossEL
TH2F * MOMvsELossEL
Definition: CbmTrdTracksPidQa.h:67
rootMgr
static FairRootManager * rootMgr
Definition: CbmDeviceHitBuilderTof.cxx:72
CbmTrdHit
data class for a reconstructed Energy-4D measurement in the TRD
Definition: CbmTrdHit.h:35
CbmTrdTracksPidQa::WknHighEL
TH1F * WknHighEL
Definition: CbmTrdTracksPidQa.h:78
CbmTrdTracksPidQa::WknHighALL
TH1F * WknHighALL
Definition: CbmTrdTracksPidQa.h:79
CbmTrdTracksPidQa::Finish
virtual void Finish()
Definition: CbmTrdTracksPidQa.cxx:290
CbmTrdTracksPidQa::LikeHighEL
TH1F * LikeHighEL
Definition: CbmTrdTracksPidQa.h:95
CbmTrdTracksPidQa::WknALL
TH1F * WknALL
Definition: CbmTrdTracksPidQa.h:73
CbmHit::GetRefId
Int_t GetRefId() const
Definition: CbmHit.h:72
CbmTrdTracksPidQa::Exec
virtual void Exec(Option_t *option)
Definition: CbmTrdTracksPidQa.cxx:187
CbmTrdTracksPidQa::MOMvsELossPI
TH2F * MOMvsELossPI
Definition: CbmTrdTracksPidQa.h:68
CbmTrdTracksPidQa::CbmTrdTracksPidQa
CbmTrdTracksPidQa()
Definition: CbmTrdTracksPidQa.cxx:27
CbmTrdTracksPidQa::LikeHighPI
TH1F * LikeHighPI
Definition: CbmTrdTracksPidQa.h:94
CbmTrdTracksPidQa::WknPI
TH1F * WknPI
Definition: CbmTrdTracksPidQa.h:71
CbmTrdTrack::GetELoss
Double_t GetELoss() const
Definition: CbmTrdTrack.h:33
CbmTrdTracksPidQa::fTrdTrackCollection
TClonesArray * fTrdTrackCollection
Definition: CbmTrdTracksPidQa.h:52
CbmTrdTrack::GetPidANN
Double_t GetPidANN() const
Definition: CbmTrdTrack.h:32
CbmTrdTracksPidQa::ELossPI
TH1F * ELossPI
Definition: CbmTrdTracksPidQa.h:61
CbmTrdTracksPidQa::AnnHighEL
TH1F * AnnHighEL
Definition: CbmTrdTracksPidQa.h:88
CbmTrdTracksPidQa::ELossALL
TH1F * ELossALL
Definition: CbmTrdTracksPidQa.h:63
CbmTrack::GetHitIndex
Int_t GetHitIndex(Int_t iHit) const
Definition: CbmTrack.h:54
CbmTrdTracksPidQa::WriteHistograms
void WriteHistograms()
Definition: CbmTrdTracksPidQa.cxx:295
CbmTrdTracksPidQa::MomALL
TH1F * MomALL
Definition: CbmTrdTracksPidQa.h:66
CbmTrdHit.h
Class for hits in TRD detector.
CbmTrdTracksPidQa::WknLowEL
TH1F * WknLowEL
Definition: CbmTrdTracksPidQa.h:75
CbmTrdTracksPidQa::AnnEL
TH1F * AnnEL
Definition: CbmTrdTracksPidQa.h:82
CbmTrdTracksPidQa::LikeHighALL
TH1F * LikeHighALL
Definition: CbmTrdTracksPidQa.h:96
CbmTrdTracksPidQa::NrTRDHits
TH1F * NrTRDHits
Definition: CbmTrdTracksPidQa.h:60
ClassImp
ClassImp(CbmTrdTracksPidQa)
CbmTrdPoint
Definition: CbmTrdPoint.h:23
CbmTrdTrack
Definition: CbmTrdTrack.h:22
CbmTrdTracksPidQa::AnnLowEL
TH1F * AnnLowEL
Definition: CbmTrdTracksPidQa.h:85
CbmTrdTracksPidQa::LikeALL
TH1F * LikeALL
Definition: CbmTrdTracksPidQa.h:93
CbmTrdTracksPidQa::WknHighPI
TH1F * WknHighPI
Definition: CbmTrdTracksPidQa.h:77
CbmMCTrack.h
CbmTrdTracksPidQa::LikeLowALL
TH1F * LikeLowALL
Definition: CbmTrdTracksPidQa.h:99
CbmMCTrack
Definition: CbmMCTrack.h:34
CbmTrdTrack::GetPidWkn
Double_t GetPidWkn() const
Definition: CbmTrdTrack.h:31
CbmTrdTracksPidQa::AnnPI
TH1F * AnnPI
Definition: CbmTrdTracksPidQa.h:81
CbmTrdTracksPidQa::WknLowPI
TH1F * WknLowPI
Definition: CbmTrdTracksPidQa.h:74
CbmTrdPoint.h
CbmTrdTracksPidQa::MomEL
TH1F * MomEL
Definition: CbmTrdTracksPidQa.h:65
CbmTrdTracksPidQa::MomPI
TH1F * MomPI
Definition: CbmTrdTracksPidQa.h:64
CbmTrdTracksPidQa::PartID
TH1F * PartID
Definition: CbmTrdTracksPidQa.h:59
CbmTrdTracksPidQa::MOMvsELossALL
TH2F * MOMvsELossALL
Definition: CbmTrdTracksPidQa.h:69
CbmTrdTracksPidQa::LikeLowPI
TH1F * LikeLowPI
Definition: CbmTrdTracksPidQa.h:97
CbmTrdTrack.h
CbmTrdTracksPidQa::Init
InitStatus Init()
Definition: CbmTrdTracksPidQa.cxx:139
CbmTrdTracksPidQa::LikeLowEL
TH1F * LikeLowEL
Definition: CbmTrdTracksPidQa.h:98
CbmTrdTracksPidQa::AnnHighPI
TH1F * AnnHighPI
Definition: CbmTrdTracksPidQa.h:87
CbmTrdTracksPidQa::ELossEL
TH1F * ELossEL
Definition: CbmTrdTracksPidQa.h:62
CbmTrdTracksPidQa::WknEL
TH1F * WknEL
Definition: CbmTrdTracksPidQa.h:72
CbmTrdTracksPidQa::AnnALL
TH1F * AnnALL
Definition: CbmTrdTracksPidQa.h:83
CbmTrdTracksPidQa::AnnHighALL
TH1F * AnnHighALL
Definition: CbmTrdTracksPidQa.h:89
CbmTrdTracksPidQa::fMCPointArray
TClonesArray * fMCPointArray
Definition: CbmTrdTracksPidQa.h:54