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