CbmRoot
CbmTrdHitProducerQa.cxx
Go to the documentation of this file.
1 // -----------------------------------------------------------------------
2 // ----- CbmTrdHitProducerQa -----
3 // ----- Created 13/12/05 by M. Kalisky -----
4 // -----------------------------------------------------------------------
5 
6 #include "CbmTrdHitProducerQa.h"
7 
8 #include "CbmMatch.h"
9 #include "CbmTrdDigi.h"
10 #include "CbmTrdHit.h"
11 #include "CbmTrdPoint.h"
12 
13 #include "CbmMCTrack.h"
14 #include "FairBaseParSet.h"
15 #include "FairDetector.h"
16 #include "FairRootManager.h"
17 #include "FairRunAna.h"
18 #include "FairRuntimeDb.h"
19 
20 #include "TClonesArray.h"
21 #include "TH1F.h"
22 #include "TMath.h"
23 #include "TObjArray.h"
24 
25 #include <iostream>
26 using std::cout;
27 using std::endl;
28 
29 // ---- Default constructor -------------------------------------------------
30 
32  : CbmTrdHitProducerQa("TrdHitProducerQa", "") {}
33 // --------------------------------------------------------------------------
34 
35 
36 // ---- Standard constructor ------------------------------------------------
37 CbmTrdHitProducerQa::CbmTrdHitProducerQa(const char* name, const char*)
38  : FairTask(name)
39  , fTrdHitCollection(NULL)
40  , fTrdDigiCollection(NULL)
41  , fTrdDigiMatchCollection(NULL)
42  , fTrdPointCollection(NULL)
43  , fMCTrackArray(NULL)
44  , fNoTrdStations(-1)
45  , fNoTrdPerStation(-1)
46  , fHitPoolsX(new TH1F("fHitPoolsX", "", 500, -50, 50))
47  , fHitPoolsY(new TH1F("fHitPoolsY", "", 500, -50, 50))
48  , S1L1eTR15(new TH1F("S1L1eTR15", "TR of e- for first layer ", 600, 0., 60.))
49  , S1L1edEdx15(
50  new TH1F("S1L1edEdx15", "dEdx of e- for first layer ", 600, 0., 60.))
51  , S1L1edE15(
52  new TH1F("S1L1edE15", "dEdx+TR of e- for first layer ", 600, 0., 60.))
53  , S1L1edEall(
54  new TH1F("S1L1edEall", "dEdx+TR of e- for first layer ", 600, 0., 60.))
55  , S1L1pidE15(
56  new TH1F("S1L1pidE15", "dEdx+TR of pi- for first layer ", 600, 0., 60.))
57  , S1L1pidEall(
58  new TH1F("S1L1pidEall", "dEdx+TR of pi- for first layer ", 600, 0., 60.))
59  , S3L4eTR15(NULL)
60  , S3L4edEdx15(NULL)
61  , S3L4edE15(NULL)
62  , S3L4edEall(
63  new TH1F("S3L4edEall", "dEdx+TR of e- for layer 12", 600, 0., 60.))
64  , S3L4pidE15(NULL)
65  , S3L4pidEall(
66  new TH1F("S3L4pidEall", "dEdx+TR of pi- for layer 12", 600, 0., 60.)) {}
67 // --------------------------------------------------------------------------
68 
69 
70 // ---- Destructor ---------------------------------------------------------
72 // --------------------------------------------------------------------------
73 
74 
75 // ---- Initialisation ------------------------------------------------------
77  // Get pointer to the ROOT I/O manager
78  FairRootManager* rootMgr = FairRootManager::Instance();
79  if (NULL == rootMgr) {
80  cout << "-E- CbmTrdHitProducerQa::Init : "
81  << "ROOT manager is not instantiated !" << endl;
82  return kFATAL;
83  }
84 
85  // Get pointer to TRD point array
86  fTrdPointCollection = (TClonesArray*) rootMgr->GetObject("TrdPoint");
87  if (NULL == fTrdPointCollection) {
88  cout << "-W- CbmTrdHitProducerQa::Init : "
89  << "no TRD point array !" << endl;
90  return kERROR;
91  }
92 
93  // Get pointer to TRD digi array
94  fTrdDigiCollection = (TClonesArray*) rootMgr->GetObject("TrdDigi");
95  if (NULL == fTrdDigiCollection) {
96  cout << "-W- CbmTrdHitProducerQa::Init : "
97  << "no TRD digi array !" << endl;
98  return kERROR;
99  }
100 
101  // Get pointer to TRD digi array
102  fTrdDigiMatchCollection = (TClonesArray*) rootMgr->GetObject("TrdDigiMatch");
103  if (NULL == fTrdDigiMatchCollection) {
104  cout << "-W- CbmTrdHitProducerQa::Init : "
105  << "no TRD digi match array !" << endl;
106  return kERROR;
107  }
108 
109  // Get pointer to TRD hit array
110  fTrdHitCollection = (TClonesArray*) rootMgr->GetObject("TrdHit");
111  if (NULL == fTrdHitCollection) {
112  cout << "-W- CbmTrdHitProducerQa::Init : "
113  << "no TRD hit array !" << endl;
114  return kERROR;
115  }
116 
117  // Get MCTrack array
118  fMCTrackArray = (TClonesArray*) rootMgr->GetObject("MCTrack");
119  if (!fMCTrackArray) {
120  cout << "-E- CbmTrdHitProducerQa::Init : No MCTrack array!" << endl;
121  return kFATAL;
122  }
123 
124  return kSUCCESS;
125 }
126 
127 // --------------------------------------------------------------------------
128 
129 
130 // ---- Task execution ------------------------------------------------------
131 void CbmTrdHitProducerQa::Exec(Option_t*) {
132  // Declare variables
133  CbmTrdHit* trdHit = NULL;
134  // CbmTrdDigi* trdDigi = NULL;
135  CbmMatch* trdDigiMatch = NULL;
136  CbmTrdPoint* trdPoint = NULL;
137  // CbmMCTrack* mctrack = NULL;
138 
139 
140  Float_t hitPoolX = 0;
141  Float_t hitPoolY = 0;
142  Float_t hitPosX = 0;
143  Float_t hitPosY = 0;
144  // Float_t hitErrX = 0;
145  // Float_t hitErrY = 0;
146 
147  Float_t pointPosX = 0;
148  Float_t pointPosY = 0;
149 
150  Int_t plane = 0;
151  Int_t partID = 0;
152 
153  Float_t momentum;
154 
155 
156  // Event counters
157  Int_t nTrdHit = fTrdHitCollection->GetEntriesFast();
158 
159  // Loop over TRD hits
160  for (Int_t iHit = 0; iHit < nTrdHit; iHit++) {
161  trdHit = (CbmTrdHit*) fTrdHitCollection->At(iHit);
162  if (NULL == trdHit) continue;
163 
164  // This will have to change in the future, when the creation of the poin
165  // will not be necessarily connected to existence of tyhe point
166 
167  trdDigiMatch = (CbmMatch*) fTrdDigiMatchCollection->At(trdHit->GetRefId());
168  if (NULL == trdDigiMatch) continue;
169 
170  trdPoint = (CbmTrdPoint*) fTrdPointCollection->At(
171  trdDigiMatch->GetMatchedLink().GetIndex());
172  if (NULL == trdPoint) continue;
173 
174  plane = trdHit->GetPlaneId();
175 
176  if (plane == 1) {
177 
178  partID = (((CbmMCTrack*) fMCTrackArray->At(trdPoint->GetTrackID()))
179  ->GetPdgCode());
180 
181  momentum = TMath::Sqrt((trdPoint->GetPx() * trdPoint->GetPx())
182  + (trdPoint->GetPy() * trdPoint->GetPy())
183  + (trdPoint->GetPz() * trdPoint->GetPz()));
184 
185  if ((TMath::Abs(partID) == 11) && (momentum > 1.25)
186  && (momentum < 1.75)) {
187 
188  S1L1eTR15->Fill(0); //(trdHit->GetELossTR())*1000000);
189  S1L1edEdx15->Fill((trdHit->GetELoss()) * 1000000);
190  S1L1edE15->Fill((trdHit->GetELoss()) * 1000000);
191  }
192  if (TMath::Abs(partID) == 11) {
193  S1L1edEall->Fill((trdHit->GetELoss()) * 1000000);
194  }
195  if ((TMath::Abs(partID) == 211) && (momentum > 1.25)
196  && (momentum < 1.75)) {
197  S1L1pidE15->Fill((trdHit->GetELoss()) * 1000000);
198  }
199  if (TMath::Abs(partID) == 211) {
200  S1L1pidEall->Fill((trdHit->GetELoss()) * 1000000);
201  }
202  }
203 
204  if (plane == 12) {
205 
206  partID = (((CbmMCTrack*) fMCTrackArray->At(trdPoint->GetTrackID()))
207  ->GetPdgCode());
208 
209  momentum = TMath::Sqrt((trdPoint->GetPx() * trdPoint->GetPx())
210  + (trdPoint->GetPy() * trdPoint->GetPy())
211  + (trdPoint->GetPz() * trdPoint->GetPz()));
212 
213  if (TMath::Abs(partID) == 11) {
214  S3L4edEall->Fill((trdHit->GetELoss()) * 1000000);
215  }
216  if (TMath::Abs(partID) == 211) {
217  S3L4pidEall->Fill((trdHit->GetELoss()) * 1000000);
218  }
219  }
220 
221 
222  if (plane == 1) {
223  // compute the Hit pools for X and Y coordinate
224  hitPosX = trdHit->GetX();
225  // hitErrX = trdHit->GetDx();
226  // hitErrX /= 10000; // micrometers to centimeters
227  pointPosX = trdPoint->GetX();
228  hitPoolX = (hitPosX - pointPosX);
229 
230 
231  hitPosY = trdHit->GetY();
232  // hitErrY = trdHit->GetDy();
233  // hitErrY /= 10000; // micrometers to centimeters
234  pointPosY = trdPoint->GetY();
235  hitPoolY = (hitPosY - pointPosY);
236 
237 
238  // fill histograms
239  fHitPoolsX->Fill(hitPoolX);
240  fHitPoolsY->Fill(hitPoolY);
241  }
242  }
243 }
244 
245 // --------------------------------------------------------------------------
246 
247 
248 // ---- Finish --------------------------------------------------------------
250 // --------------------------------------------------------------------------
251 
252 
253 // ---- Prepare test histograms ---------------------------------------------
254 
255 /*
256 void CbmTrdHitProducerQa::PrepareHistograms()
257 {
258 
259  fHitPoolsX=NULL;
260  fHitPoolsY=NULL;
261 
262  S1L1eTR15=NULL;
263  S1L1edEdx15=NULL;
264  S1L1edE15=NULL;
265  S1L1edEall=NULL;
266  S1L1pidE15=NULL;
267  S1L1pidEall=NULL;
268 
269  S3L4eTR15=NULL;
270  S3L4edEdx15=NULL;
271  S3L4edE15=NULL;
272  S3L4edEall=NULL;
273  S3L4pidE15=NULL;
274  S3L4pidEall=NULL;
275 
276  fHitPoolsX = new TH1F("fHitPoolsX", "", 500, -50, 50);
277  fHitPoolsY = new TH1F("fHitPoolsY", "", 500, -50, 50);
278 
279  S1L1eTR15 = new TH1F("S1L1eTR15","TR of e- for first layer ",600,0.,60.);
280  S1L1edEdx15 = new TH1F("S1L1edEdx15","dEdx of e- for first layer ",600,0.,60.);
281  S1L1edE15 = new TH1F("S1L1edE15","dEdx+TR of e- for first layer ",600,0.,60.);
282  S1L1edEall = new TH1F("S1L1edEall","dEdx+TR of e- for first layer ",600,0.,60.);
283  S1L1pidE15 = new TH1F("S1L1pidE15","dEdx+TR of pi- for first layer ",600,0.,60.);
284  S1L1pidEall = new TH1F("S1L1pidEall","dEdx+TR of pi- for first layer ",600,0.,60.);
285  S3L4edEall = new TH1F("S3L4edEall","dEdx+TR of e- for layer 12",600,0.,60.);
286  S3L4pidEall = new TH1F("S3L4pidEall","dEdx+TR of pi- for layer 12",600,0.,60.);
287 
288 }
289 */
290 // --------------------------------------------------------------------------
291 
292 
293 // ---- Write test histograms ------------------------------------------------
294 
296  if (fHitPoolsX) fHitPoolsX->Write();
297  if (fHitPoolsY) fHitPoolsY->Write();
298 
299  if (S1L1eTR15) S1L1eTR15->Write();
300  if (S1L1edEdx15) S1L1edEdx15->Write();
301  if (S1L1edE15) S1L1edE15->Write();
302  if (S1L1edEall) S1L1edEall->Write();
303  if (S1L1pidE15) S1L1pidE15->Write();
304  if (S1L1pidEall) S1L1pidEall->Write();
305 
306  if (S3L4eTR15) S3L4eTR15->Write();
307  if (S3L4edEdx15) S3L4edEdx15->Write();
308  if (S3L4edE15) S3L4edE15->Write();
309  if (S3L4edEall) S3L4edEall->Write();
310  if (S3L4pidE15) S3L4pidE15->Write();
311  if (S3L4pidEall) S3L4pidEall->Write();
312 }
313 
314 // --------------------------------------------------------------------------
315 
CbmTrdHitProducerQa::fTrdDigiCollection
TClonesArray * fTrdDigiCollection
Definition: CbmTrdHitProducerQa.h:49
CbmMatch::GetMatchedLink
const CbmLink & GetMatchedLink() const
Definition: CbmMatch.h:37
CbmMatch
Definition: CbmMatch.h:22
CbmTrdHitProducerQa::Finish
virtual void Finish()
Definition: CbmTrdHitProducerQa.cxx:249
CbmTrdHitProducerQa::S1L1pidEall
TH1F * S1L1pidEall
Definition: CbmTrdHitProducerQa.h:70
CbmPixelHit::GetX
Double_t GetX() const
Definition: CbmPixelHit.h:83
CbmPixelHit::GetY
Double_t GetY() const
Definition: CbmPixelHit.h:84
CbmTrdHitProducerQa::S3L4edE15
TH1F * S3L4edE15
Definition: CbmTrdHitProducerQa.h:74
CbmTrdHit::GetELoss
Double_t GetELoss() const
Definition: CbmTrdHit.h:79
CbmTrdHitProducerQa::~CbmTrdHitProducerQa
virtual ~CbmTrdHitProducerQa()
Definition: CbmTrdHitProducerQa.cxx:71
CbmTrdHitProducerQa::S3L4edEall
TH1F * S3L4edEall
Definition: CbmTrdHitProducerQa.h:75
rootMgr
static FairRootManager * rootMgr
Definition: CbmDeviceHitBuilderTof.cxx:72
CbmTrdHit
data class for a reconstructed Energy-4D measurement in the TRD
Definition: CbmTrdHit.h:35
CbmTrdHitProducerQa::fTrdPointCollection
TClonesArray * fTrdPointCollection
Definition: CbmTrdHitProducerQa.h:51
CbmTrdHitProducerQa::S3L4eTR15
TH1F * S3L4eTR15
Definition: CbmTrdHitProducerQa.h:72
CbmTrdHitProducerQa::fMCTrackArray
TClonesArray * fMCTrackArray
Definition: CbmTrdHitProducerQa.h:52
CbmHit::GetRefId
Int_t GetRefId() const
Definition: CbmHit.h:72
CbmTrdHitProducerQa::S1L1eTR15
TH1F * S1L1eTR15
Definition: CbmTrdHitProducerQa.h:65
CbmMatch.h
CbmTrdHitProducerQa::S1L1edEdx15
TH1F * S1L1edEdx15
Definition: CbmTrdHitProducerQa.h:66
CbmTrdHitProducerQa::S3L4pidEall
TH1F * S3L4pidEall
Definition: CbmTrdHitProducerQa.h:77
CbmTrdDigi.h
CbmTrdHitProducerQa::S3L4pidE15
TH1F * S3L4pidE15
Definition: CbmTrdHitProducerQa.h:76
CbmTrdHitProducerQa::fTrdHitCollection
TClonesArray * fTrdHitCollection
Definition: CbmTrdHitProducerQa.h:48
ClassImp
ClassImp(CbmTrdHitProducerQa)
CbmTrdHitProducerQa::fHitPoolsX
TH1F * fHitPoolsX
Definition: CbmTrdHitProducerQa.h:62
CbmTrdHitProducerQa::S1L1edE15
TH1F * S1L1edE15
Definition: CbmTrdHitProducerQa.h:67
CbmTrdHit.h
Class for hits in TRD detector.
CbmTrdHitProducerQa
Definition: CbmTrdHitProducerQa.h:25
CbmTrdHitProducerQa.h
CbmTrdPoint
Definition: CbmTrdPoint.h:23
CbmMCTrack.h
CbmMCTrack
Definition: CbmMCTrack.h:34
CbmTrdPoint.h
CbmTrdHitProducerQa::S3L4edEdx15
TH1F * S3L4edEdx15
Definition: CbmTrdHitProducerQa.h:73
CbmTrdHitProducerQa::S1L1edEall
TH1F * S1L1edEall
Definition: CbmTrdHitProducerQa.h:68
CbmTrdHitProducerQa::fTrdDigiMatchCollection
TClonesArray * fTrdDigiMatchCollection
Definition: CbmTrdHitProducerQa.h:50
CbmTrdHitProducerQa::S1L1pidE15
TH1F * S1L1pidE15
Definition: CbmTrdHitProducerQa.h:69
CbmTrdHitProducerQa::CbmTrdHitProducerQa
CbmTrdHitProducerQa()
Definition: CbmTrdHitProducerQa.cxx:31
CbmTrdHitProducerQa::Init
InitStatus Init()
Definition: CbmTrdHitProducerQa.cxx:76
CbmTrdHitProducerQa::WriteHistograms
void WriteHistograms()
Definition: CbmTrdHitProducerQa.cxx:295
CbmTrdHitProducerQa::fHitPoolsY
TH1F * fHitPoolsY
Definition: CbmTrdHitProducerQa.h:63
CbmTrdHitProducerQa::Exec
virtual void Exec(Option_t *option)
Definition: CbmTrdHitProducerQa.cxx:131
CbmTrdHit::GetPlaneId
Int_t GetPlaneId() const
Inherited from CbmBaseHit.
Definition: CbmTrdHit.h:73