CbmRoot
CbmRichTrainAnnElectrons.cxx
Go to the documentation of this file.
1 
9 
10 #include "CbmDrawHist.h"
11 #include "CbmGlobalTrack.h"
12 #include "CbmMCTrack.h"
13 #include "CbmRichRing.h"
14 #include "CbmTrackMatchNew.h"
15 #include "FairMCPoint.h"
16 #include "FairRootManager.h"
17 #include "FairTrackParam.h"
18 
19 #include "CbmRichUtil.h"
20 #include "TCanvas.h"
21 #include "TClonesArray.h"
22 #include "TH1D.h"
23 #include "TH2D.h"
24 #include "TMultiLayerPerceptron.h"
25 #include "TString.h"
26 #include "TSystem.h"
27 
28 #include "CbmUtils.h"
29 
30 #include <boost/assign/list_of.hpp>
31 
32 #include <cmath>
33 #include <iostream>
34 #include <string>
35 #include <vector>
36 
37 class CbmStsTrack;
38 
39 using boost::assign::list_of;
40 using std::cout;
41 using std::endl;
42 using std::fabs;
43 using std::string;
44 using std::vector;
45 
47  : fEventNum(0)
48  ,
49 
50  fRichHits(NULL)
51  , fRichRings(NULL)
52  , fRichPoints(NULL)
53  , fMCTracks(NULL)
54  , fRichRingMatches(NULL)
55  , fRichProj(NULL)
56  , fStsTrackMatches(NULL)
57  , fGlobalTracks(NULL)
58  , fStsTracks(NULL)
59  , fMinNofHitsInRichRing(7)
60  , fQuota(0.6)
61  , fMaxNofTrainSamples(5000)
62  , fNofPiLikeEl(0)
63  , fNofElLikePi(0)
64  , fAnnCut(-0.5)
65  , fhAnnOutput()
66  , fhCumProb()
67  , fRElIdParams()
68  , fCanvas()
69  , fOutputDir("results_images_ann/")
70  , fhAaxis()
71  , fhBaxis()
72  ,
73  // fhAaxisCor(),
74  // fhBaxisCor(),
75  fhDistTrueMatch()
76  , fhDistMisMatch()
77  , fhNofHits()
78  , fhChi2()
79  , fhRadPos()
80  , fhAaxisVsMom()
81  , fhBaxisVsMom()
82  , fhPhiVsRadAng()
83  , fHists() {
84  fhAaxis.resize(2);
85  fhBaxis.resize(2);
86  // fhAaxisCor.resize(2);
87  // fhBaxisCor.resize(2);
88  fhDistTrueMatch.resize(2);
89  fhDistMisMatch.resize(2);
90  fhNofHits.resize(2);
91  fhChi2.resize(2);
92  fhRadPos.resize(2);
93  fhAaxisVsMom.resize(2);
94  fhBaxisVsMom.resize(2);
95  fhPhiVsRadAng.resize(2);
96  fhAnnOutput.resize(2);
97  fhCumProb.resize(2);
98  fRElIdParams.resize(2);
99  string ss;
100  for (int i = 0; i < 2; i++) {
101  if (i == 0) ss = "Electron";
102  if (i == 1) ss = "Pion";
103  // difference between electrons and pions
104  fhAaxis[i] = new TH1D(string("fhAaxis" + ss).c_str(),
105  "fhAaxis;A axis [cm];Counter",
106  50,
107  0.,
108  8.);
109  fHists.push_back(fhAaxis[i]);
110  fhBaxis[i] = new TH1D(string("fhBAxis" + ss).c_str(),
111  "fhBAxis;B axis [cm];Counter",
112  50,
113  0.,
114  8.);
115  fHists.push_back(fhBaxis[i]);
116  // fhAaxisCor[i] = new TH1D(string("fhAaxisCor"+ss).c_str(), "fhAaxisCor;A axis [cm];Counter", 30,3,8);
117  // fHists.push_back(fhAaxisCor[i]);
118  // fhBaxisCor[i] = new TH1D(string("fhBAxisCor"+ss).c_str(), "fhBAxisCor;B axis [cm];Counter", 30,3,8);
119  // fHists.push_back(fhBaxisCor[i]);
120  fhDistTrueMatch[i] =
121  new TH1D(string("fhDistTrueMatch" + ss).c_str(),
122  "fhDistTrueMatch;Ring-track distance [cm];Counter",
123  50,
124  0.,
125  5.);
126  fHists.push_back(fhDistTrueMatch[i]);
127  fhDistMisMatch[i] =
128  new TH1D(string("fhDistMisMatch" + ss).c_str(),
129  "fhDistMisMatch;Ring-track distance [cm];Counter",
130  50,
131  0.,
132  5.);
133  fHists.push_back(fhDistMisMatch[i]);
134  fhNofHits[i] = new TH1D(string("fhNofHits" + ss).c_str(),
135  "fhNofHits;Number of hits;Counter",
136  50,
137  0,
138  50);
139  fHists.push_back(fhNofHits[i]);
140  fhChi2[i] = new TH1D(
141  string("fhChi2" + ss).c_str(), "fhChi2;#Chi^{2};Counter", 100, 0., 1.);
142  fHists.push_back(fhChi2[i]);
143  fhRadPos[i] = new TH1D(string("fhRadPos" + ss).c_str(),
144  "fhRadPos;Radial position [cm];Counter",
145  150,
146  0.,
147  150.);
148  fHists.push_back(fhRadPos[i]);
149  fhAaxisVsMom[i] = new TH2D(string("fhAaxisVsMom" + ss).c_str(),
150  "fhAaxisVsMom;P [GeV/c];A axis [cm]",
151  30,
152  0,
153  15,
154  50,
155  0,
156  10);
157  fHists.push_back(fhAaxisVsMom[i]);
158  fhBaxisVsMom[i] = new TH2D(string("fhBAxisVsMom" + ss).c_str(),
159  "fhBAxisVsMom;P [GeV/c];B axis [cm]",
160  30,
161  0,
162  15,
163  50,
164  0,
165  10);
166  fHists.push_back(fhBaxisVsMom[i]);
167  fhPhiVsRadAng[i] = new TH2D(string("fhPhiVsRadAng" + ss).c_str(),
168  "fhPhiVsRadAng;Phi [rad];Radial angle [rad]",
169  50,
170  -2.,
171  2.,
172  50,
173  0.,
174  6.3);
175  fHists.push_back(fhPhiVsRadAng[i]);
176  // ANN outputs
177  fhAnnOutput[i] = new TH1D(string("fhAnnOutput" + ss).c_str(),
178  "ANN output;ANN output;Counter",
179  100,
180  -1.2,
181  1.2);
182  fHists.push_back(fhAnnOutput[i]);
183  fhCumProb[i] = new TH1D(string("fhCumProb" + ss).c_str(),
184  "ANN output;ANN output;Cumulative probability",
185  100,
186  -1.2,
187  1.2);
188  fHists.push_back(fhCumProb[i]);
189  }
190 }
191 
193 
195  cout << "InitStatus CbmRichTrainAnnElectrons::Init()" << endl;
196 
197  FairRootManager* ioman = FairRootManager::Instance();
198  if (NULL == ioman) {
199  Fatal("CbmRichTrainAnnElectrons::Init", "RootManager not instantised!");
200  }
201 
202  //fRichHits = (TClonesArray*) ioman->GetObject("RichHit");
203  //if ( NULL == fRichHits) { Fatal("CbmRichTrainAnnElectrons::Init","No RichHit array!");}
204 
205  fRichRings = (TClonesArray*) ioman->GetObject("RichRing");
206  if (NULL == fRichRings) {
207  Fatal("CbmRichTrainAnnElectrons::Init", "No RichRing array!");
208  }
209 
210  //fRichPoints = (TClonesArray*) ioman->GetObject("RichPoint");
211  //if ( NULL == fRichPoints) { Fatal("CbmRichTrainAnnElectrons::Init","No RichPoint array!");}
212 
213  fMCTracks = (TClonesArray*) ioman->GetObject("MCTrack");
214  if (NULL == fMCTracks) {
215  Fatal("CbmRichTrainAnnElectrons::Init", "No MCTrack array!");
216  }
217 
218  fRichRingMatches = (TClonesArray*) ioman->GetObject("RichRingMatch");
219  if (NULL == fRichRingMatches) {
220  Fatal("CbmRichTrainAnnElectrons::Init", "No RichRingMatch array!");
221  }
222 
223  // fRichProj = (TClonesArray*) ioman->GetObject("RichProjection");
224  // if ( NULL == fRichProj) { Fatal("CbmRichTrainAnnElectrons::Init","No RichProjection array!");}
225 
226  fStsTrackMatches = (TClonesArray*) ioman->GetObject("StsTrackMatch");
227  if (NULL == fStsTrackMatches) {
228  Fatal("CbmRichTrainAnnElectrons::Init", "No track match array!");
229  }
230 
231  fGlobalTracks = (TClonesArray*) ioman->GetObject("GlobalTrack");
232  if (NULL == fGlobalTracks) {
233  Fatal("CbmRichTrainAnnElectrons::Init", "No global track array!");
234  }
235 
236  fStsTracks = (TClonesArray*) ioman->GetObject("StsTrack");
237  if (NULL == fStsTracks) {
238  Fatal("CbmRichTrainAnnElectrons::Init", "No STSTrack array!");
239  }
240 
241  return kSUCCESS;
242 }
243 
244 void CbmRichTrainAnnElectrons::Exec(Option_t* /*option*/) {
245  cout << endl << "-I- CbmRichTrainAnnElectrons, event " << fEventNum << endl;
246  DiffElandPi();
247  fEventNum++;
248  cout << "Nof Electrons = " << fRElIdParams[0].size() << endl;
249  cout << "Nof Pions = " << fRElIdParams[1].size() << endl;
250 }
251 
253  Int_t nGlTracks = fGlobalTracks->GetEntriesFast();
254 
255  for (Int_t iTrack = 0; iTrack < nGlTracks; iTrack++) {
256  CbmGlobalTrack* gTrack = (CbmGlobalTrack*) fGlobalTracks->At(iTrack);
257  if (NULL == gTrack) continue;
258  Int_t stsIndex = gTrack->GetStsTrackIndex();
259  if (stsIndex == -1) continue;
260  CbmStsTrack* stsTrack = (CbmStsTrack*) fStsTracks->At(stsIndex);
261  if (NULL == stsTrack) continue;
262  CbmTrackMatchNew* stsTrackMatch =
263  (CbmTrackMatchNew*) fStsTrackMatches->At(stsIndex);
264  if (NULL == stsTrackMatch) continue;
265  Int_t mcIdSts = stsTrackMatch->GetMatchedLink().GetIndex();
266 
267  Int_t richIndex = gTrack->GetRichRingIndex();
268  if (richIndex == -1) continue;
269  CbmRichRing* ring = (CbmRichRing*) fRichRings->At(richIndex);
270  if (NULL == ring) continue;
271  CbmTrackMatchNew* richRingMatch =
272  (CbmTrackMatchNew*) fRichRingMatches->At(richIndex);
273  if (NULL == richRingMatch) continue;
274  Int_t mcIdRich = richRingMatch->GetMatchedLink().GetIndex();
275 
276  CbmMCTrack* track = (CbmMCTrack*) fMCTracks->At(mcIdSts);
277  if (NULL == track) continue;
278  Int_t pdg = TMath::Abs(track->GetPdgCode());
279  Int_t motherId = track->GetMotherId();
280  Double_t momentum = track->GetP();
281 
282  // Double_t axisACor = ring->GetAaxisCor();
283  // Double_t axisBCor= ring->GetBaxisCor();
284 
285  Int_t lFoundHits =
286  richRingMatch->GetNofTrueHits() + richRingMatch->GetNofWrongHits();
287  Double_t lPercTrue = 0;
288  if (lFoundHits >= 3) {
289  lPercTrue =
290  (Double_t) richRingMatch->GetNofTrueHits() / (Double_t) lFoundHits;
291  }
292  Bool_t isTrueFound = (lPercTrue > fQuota);
293 
295  p.fAaxis = ring->GetAaxis();
296  p.fBaxis = ring->GetBaxis();
297  p.fPhi = ring->GetPhi();
298  p.fRadAngle = ring->GetRadialAngle();
299  p.fChi2 = ring->GetChi2() / ring->GetNDF();
300  p.fRadPos = ring->GetRadialPosition();
301  p.fNofHits = ring->GetNofHits();
303  p.fMomentum = momentum;
304 
305  if (p.fAaxis > 9. || p.fBaxis > 9.) continue;
306 
307  // electrons
308  if (pdg == 11 && motherId == -1 && isTrueFound && mcIdSts == mcIdRich
309  && mcIdRich != -1) {
310  fhAaxis[0]->Fill(p.fAaxis);
311  fhBaxis[0]->Fill(p.fBaxis);
312  // fhAaxisCor[0]->Fill(axisACor);
313  // fhBaxisCor[0]->Fill(axisBCor);
314  fhDistTrueMatch[0]->Fill(p.fDistance);
315  fhNofHits[0]->Fill(p.fNofHits);
316  fhChi2[0]->Fill(p.fChi2);
317  fhRadPos[0]->Fill(p.fRadPos);
318  fhAaxisVsMom[0]->Fill(momentum, p.fAaxis);
319  fhBaxisVsMom[0]->Fill(momentum, p.fBaxis);
320  fhPhiVsRadAng[0]->Fill(p.fPhi, p.fRadAngle);
321  fRElIdParams[0].push_back(p);
322  }
323 
324  if (pdg == 11 && motherId == -1 && isTrueFound && mcIdSts != mcIdRich
325  && mcIdRich != -1) {
326  fhDistMisMatch[0]->Fill(p.fDistance);
327  }
328 
329 
330  // pions
331  if (pdg == 211 && mcIdRich != -1) {
332  fhAaxis[1]->Fill(p.fAaxis);
333  fhBaxis[1]->Fill(p.fBaxis);
334  // fhAaxisCor[1]->Fill(axisACor);
335  // fhBaxisCor[1]->Fill(axisBCor);
336  if (mcIdRich == mcIdSts) {
337  fhDistTrueMatch[1]->Fill(p.fDistance);
338  fhAaxisVsMom[1]->Fill(momentum, p.fAaxis);
339  fhBaxisVsMom[1]->Fill(momentum, p.fBaxis);
340  } else {
341  fhDistMisMatch[1]->Fill(p.fDistance);
342  }
343  fhNofHits[1]->Fill(p.fNofHits);
344  fhChi2[1]->Fill(p.fChi2);
345  fhRadPos[1]->Fill(p.fRadPos);
346  fhPhiVsRadAng[1]->Fill(p.fPhi, p.fRadAngle);
347 
348  fRElIdParams[1].push_back(p);
349  }
350  } // global tracks
351 }
352 
354  TTree* simu = new TTree("MonteCarlo", "MontecarloData");
355  Double_t x[9];
356  Double_t xOut;
357 
358  simu->Branch("x0", &x[0], "x0/D");
359  simu->Branch("x1", &x[1], "x1/D");
360  simu->Branch("x2", &x[2], "x2/D");
361  simu->Branch("x3", &x[3], "x3/D");
362  simu->Branch("x4", &x[4], "x4/D");
363  simu->Branch("x5", &x[5], "x5/D");
364  simu->Branch("x6", &x[6], "x6/D");
365  simu->Branch("x7", &x[7], "x7/D");
366  simu->Branch("x8", &x[8], "x8/D");
367  simu->Branch("xOut", &xOut, "xOut/D");
368 
369  for (int j = 0; j < 2; j++) {
370  for (unsigned int i = 0; i < fRElIdParams[j].size(); i++) {
371  x[0] = fRElIdParams[j][i].fAaxis / 10.;
372  x[1] = fRElIdParams[j][i].fBaxis / 10.;
373  x[2] = (fRElIdParams[j][i].fPhi + 1.57) / 3.14;
374  x[3] = fRElIdParams[j][i].fRadAngle / 6.28;
375  x[4] = fRElIdParams[j][i].fChi2 / 1.2;
376  x[5] = fRElIdParams[j][i].fRadPos / 110.;
377  x[6] = fRElIdParams[j][i].fNofHits / 45.;
378  x[7] = fRElIdParams[j][i].fDistance / 5.;
379  x[8] = fRElIdParams[j][i].fMomentum / 15.;
380 
381  for (int k = 0; k < 9; k++) {
382  if (x[k] < 0.0) x[k] = 0.0;
383  if (x[k] > 1.0) x[k] = 1.0;
384  }
385 
386  if (j == 0) xOut = 1.;
387  if (j == 1) xOut = -1.;
388  simu->Fill();
389  if (i >= fMaxNofTrainSamples) break;
390  }
391  }
392 
393  TMultiLayerPerceptron network(
394  "x0,x1,x2,x3,x4,x5,x6,x7,x8:18:xOut", simu, "Entry$+1");
395  //network.LoadWeights("");
396  network.Train(300, "text,update=10");
397  network.DumpWeights("rich_v17a_elid_ann_weights.txt");
398  //network.Export();
399 
400  Double_t params[9];
401 
402  fNofPiLikeEl = 0;
403  fNofElLikePi = 0;
404 
405  for (int j = 0; j < 2; j++) {
406  for (unsigned int i = 0; i < fRElIdParams[j].size(); i++) {
407  params[0] = fRElIdParams[j][i].fAaxis / 10.;
408  params[1] = fRElIdParams[j][i].fBaxis / 10.;
409  params[2] = (fRElIdParams[j][i].fPhi + 1.57) / 3.14;
410  params[3] = fRElIdParams[j][i].fRadAngle / 6.28;
411  params[4] = fRElIdParams[j][i].fChi2 / 1.2;
412  params[5] = fRElIdParams[j][i].fRadPos / 110.;
413  params[6] = fRElIdParams[j][i].fNofHits / 45.;
414  params[7] = fRElIdParams[j][i].fDistance / 5.;
415  params[8] = fRElIdParams[j][i].fMomentum / 15.;
416 
417  for (int k = 0; k < 9; k++) {
418  if (params[k] < 0.0) params[k] = 0.0;
419  if (params[k] > 1.0) params[k] = 1.0;
420  }
421 
422  Double_t netEval = network.Evaluate(0, params);
423 
424  //if (netEval > maxEval) netEval = maxEval - 0.01;
425  // if (netEval < minEval) netEval = minEval + 0.01;
426 
427  fhAnnOutput[j]->Fill(netEval);
428  if (netEval >= fAnnCut && j == 1) fNofPiLikeEl++;
429  if (netEval < fAnnCut && j == 0) fNofElLikePi++;
430  }
431  }
432 }
433 
435  cout << "nof electrons = " << fRElIdParams[0].size() << endl;
436  cout << "nof pions = " << fRElIdParams[1].size() << endl;
437  cout << "Pions like electrons = " << fNofPiLikeEl
438  << ", pi supp = " << (Double_t) fRElIdParams[1].size() / fNofPiLikeEl
439  << endl;
440  cout << "Electrons like pions = " << fNofElLikePi << ", el lost eff = "
441  << 100. * (Double_t) fNofElLikePi / fRElIdParams[0].size() << endl;
442  cout << "ANN cut = " << fAnnCut << endl;
443 
444  Double_t cumProbFake = 0.;
445  Double_t cumProbTrue = 0.;
446  Int_t nofFake = (Int_t) fhAnnOutput[1]->GetEntries();
447  Int_t nofTrue = (Int_t) fhAnnOutput[0]->GetEntries();
448  for (Int_t i = 1; i <= fhAnnOutput[1]->GetNbinsX(); i++) {
449  cumProbFake += fhAnnOutput[1]->GetBinContent(i);
450  fhCumProb[1]->SetBinContent(i, (Double_t) cumProbFake / nofFake);
451 
452  cumProbTrue += fhAnnOutput[0]->GetBinContent(i);
453  fhCumProb[0]->SetBinContent(i, 1. - (Double_t) cumProbTrue / nofTrue);
454  }
455 
457  {
458  // TCanvas* c = CreateCanvas("ann_electrons_ann_output", "ann_electrons_ann_output", 500, 500);
459  CreateCanvas(
460  "ann_electrons_ann_output", "ann_electrons_ann_output", 500, 500);
461  DrawH1(list_of(fhAnnOutput[0])(fhAnnOutput[1]),
462  list_of("e^{#pm}")("#pi^{#pm}"),
463  kLinear,
464  kLog,
465  true,
466  0.8,
467  0.8,
468  0.99,
469  0.99);
470  }
471 
472  {
473  // TCanvas* c = CreateCanvas("ann_electrons_cum_prob", "ann_electrons_cum_prob", 500, 500);
474  CreateCanvas("ann_electrons_cum_prob", "ann_electrons_cum_prob", 500, 500);
475  DrawH1(list_of(fhCumProb[0])(fhCumProb[1]),
476  list_of("e^{#pm}")("#pi^{#pm}"),
477  kLinear,
478  kLinear,
479  true,
480  0.8,
481  0.8,
482  0.99,
483  0.99);
484  }
485 
486  {
487  int i = 1;
488  TCanvas* c = CreateCanvas(
489  "ann_electrons_params_ab", "ann_electrons_params_ab", 1200, 600);
490  c->Divide(2, 1);
491  c->cd(i++);
492  DrawH1(list_of(fhAaxis[0])(fhAaxis[1]),
493  list_of("e^{#pm}")("#pi^{#pm}"),
494  kLinear,
495  kLog,
496  true,
497  0.8,
498  0.8,
499  0.99,
500  0.99);
501  c->cd(i++);
502  DrawH1(list_of(fhBaxis[0])(fhBaxis[1]),
503  list_of("e^{#pm}")("#pi^{#pm}"),
504  kLinear,
505  kLog,
506  true,
507  0.8,
508  0.8,
509  0.99,
510  0.99);
511  // c3->cd(c++);
512  // DrawH1(list_of(fhAaxisCor[0])(fhAaxisCor[1]), list_of("e^{#pm}")("#pi^{#pm}"), kLinear, kLog, true, 0.8, 0.8, 0.99, 0.99);
513  // c3->cd(c++);
514  // DrawH1(list_of(fhBaxisCor[0])(fhBaxisCor[1]), list_of("e^{#pm}")("#pi^{#pm}"), kLinear, kLog, true, 0.8, 0.8, 0.99, 0.99);
515  }
516 
517  {
518  int i = 1;
519  TCanvas* c = CreateCanvas(
520  "ann_electrons_params_1", "ann_electrons_params_1", 1500, 600);
521  c->Divide(3, 1);
522  c->cd(i++);
523  //fhAaxisVsMom[0]->SetLineColor(kRed);
524  //fhAaxisVsMom[1]->SetLineColor(kBlue);
526  //DrawH2(fhAaxisVsMom[0], kLinear, kLinear, kLinear, "same");
527  c->cd(i++);
528  //fhBaxisVsMom[0]->SetLineColor(kRed);
529  //fhBaxisVsMom[1]->SetLineColor(kBlue);
530  //DrawH2(fhBaxisVsMom[1], kLinear, kLinear, kLinear);
532 
533  c->cd(i++);
535  fhDistMisMatch[1]),
536  list_of("e^{#pm} true match")("e^{#pm} mis match")(
537  "#pi^{#pm} true match")("#pi^{#pm} mis match"),
538  kLinear,
539  kLog,
540  true,
541  0.6,
542  0.7,
543  0.99,
544  0.99);
545  }
546 
547  {
548  int i = 1;
549  TCanvas* c = CreateCanvas(
550  "ann_electrons_params_2", "ann_electrons_params_2", 1500, 600);
551  c->Divide(3, 1);
552  c->cd(i++);
553  DrawH1(list_of(fhNofHits[0])(fhNofHits[1]),
554  list_of("e^{#pm}")("#pi^{#pm}"),
555  kLinear,
556  kLog,
557  true,
558  0.8,
559  0.8,
560  0.99,
561  0.99);
562  c->cd(i++);
563  DrawH1(list_of(fhChi2[0])(fhChi2[1]),
564  list_of("e^{#pm}")("#pi^{#pm}"),
565  kLinear,
566  kLog,
567  true,
568  0.8,
569  0.8,
570  0.99,
571  0.99);
572  c->cd(i++);
573  DrawH1(list_of(fhRadPos[0])(fhRadPos[1]),
574  list_of("e^{#pm}")("#pi^{#pm}"),
575  kLinear,
576  kLog,
577  true,
578  0.8,
579  0.8,
580  0.99,
581  0.99);
582  }
583 
584  {
585  int i = 1;
586  TCanvas* c = CreateCanvas(
587  "ann_electrons_params_2d", "ann_electrons_params_2d", 600, 900);
588  c->Divide(2, 3);
589  c->cd(i++);
590  DrawH2(fhAaxisVsMom[0]);
591  c->cd(i++);
592  DrawH2(fhAaxisVsMom[1]);
593  c->cd(i++);
594  DrawH2(fhBaxisVsMom[0]);
595  c->cd(i++);
596  DrawH2(fhBaxisVsMom[1]);
597  c->cd(i++);
598  DrawH2(fhPhiVsRadAng[0]);
599  c->cd(i++);
600  DrawH2(fhPhiVsRadAng[1]);
601  }
602 
603  // TCanvas* c5 = new TCanvas("ann_electrons_b_vs_mom", "ann_electrons_b_vs_mom", 600, 600);
604  // fhBaxisVsMom[0]->Add(fhBaxisVsMom[1]);
605  // DrawH2(fhBaxisVsMom[0]);
606  //
607  // TCanvas* c6 = new TCanvas("ann_electrons_a_vs_mom", "ann_electrons_a_vs_mom", 600, 600);
608  // fhAaxisVsMom[0]->Add(fhAaxisVsMom[1]);
609  // DrawH2(fhAaxisVsMom[0]);
610 }
611 
613  TrainAndTestAnn();
614  Draw();
615 
616  for (unsigned int i = 0; i < fHists.size(); i++) {
617  fHists[i]->Scale(1. / fHists[i]->Integral());
618  fHists[i]->Write();
619  }
620 
622 }
623 
624 TCanvas* CbmRichTrainAnnElectrons::CreateCanvas(const string& name,
625  const string& title,
626  int width,
627  int height) {
628  TCanvas* c = new TCanvas(name.c_str(), title.c_str(), width, height);
629  fCanvas.push_back(c);
630  return c;
631 }
632 
634  for (unsigned int i = 0; i < fCanvas.size(); i++) {
636  }
637 }
638 
CbmMCTrack::GetMotherId
Int_t GetMotherId() const
Definition: CbmMCTrack.h:71
CbmMatch::GetMatchedLink
const CbmLink & GetMatchedLink() const
Definition: CbmMatch.h:37
CbmRichTrainAnnElectrons::fNofPiLikeEl
Int_t fNofPiLikeEl
Definition: CbmRichTrainAnnElectrons.h:101
CbmRichTrainAnnElectrons::SaveCanvasToImage
void SaveCanvasToImage()
Definition: CbmRichTrainAnnElectrons.cxx:633
CbmRichTrainAnnElectrons::~CbmRichTrainAnnElectrons
virtual ~CbmRichTrainAnnElectrons()
Destructor.
Definition: CbmRichTrainAnnElectrons.cxx:192
RingElectronParam::fPhi
Double_t fPhi
Definition: CbmRichTrainAnnElectrons.h:39
CbmRichTrainAnnElectrons::fhAaxis
vector< TH1D * > fhAaxis
Definition: CbmRichTrainAnnElectrons.h:118
CbmTrackMatchNew::GetNofWrongHits
Int_t GetNofWrongHits() const
Definition: CbmTrackMatchNew.h:33
CbmRichTrainAnnElectrons::Exec
virtual void Exec(Option_t *option)
Inherited from FairTask.
Definition: CbmRichTrainAnnElectrons.cxx:244
CbmRichTrainAnnElectrons::fhCumProb
vector< TH1D * > fhCumProb
Definition: CbmRichTrainAnnElectrons.h:107
CbmRichTrainAnnElectrons::fhPhiVsRadAng
vector< TH2D * > fhPhiVsRadAng
Definition: CbmRichTrainAnnElectrons.h:132
RingElectronParam::fRadPos
Double_t fRadPos
Definition: CbmRichTrainAnnElectrons.h:42
RingElectronParam::fBaxis
Double_t fBaxis
Definition: CbmRichTrainAnnElectrons.h:38
CbmGlobalTrack::GetRichRingIndex
Int_t GetRichRingIndex() const
Definition: CbmGlobalTrack.h:41
CbmMCTrack::GetPdgCode
Int_t GetPdgCode() const
Definition: CbmMCTrack.h:70
i
int i
Definition: L1/vectors/P4_F32vec4.h:25
CbmRichRing::GetChi2
Double_t GetChi2() const
Definition: CbmRichRing.h:95
CbmGlobalTrack.h
CbmRichRing::GetNofHits
Int_t GetNofHits() const
Definition: CbmRichRing.h:40
CbmRichRing
Definition: CbmRichRing.h:17
CbmRichTrainAnnElectrons::fNofElLikePi
Int_t fNofElLikePi
Definition: CbmRichTrainAnnElectrons.h:102
CbmRichRing.h
CbmDrawHist.h
Helper functions for drawing 1D and 2D histograms and graphs.
CbmRichRing::GetRadialPosition
Float_t GetRadialPosition() const
Definition: CbmRichRing.cxx:181
CbmRichTrainAnnElectrons::fhDistMisMatch
vector< TH1D * > fhDistMisMatch
Definition: CbmRichTrainAnnElectrons.h:125
CbmRichTrainAnnElectrons::Init
virtual InitStatus Init()
Inherited from FairTask.
Definition: CbmRichTrainAnnElectrons.cxx:194
RingElectronParam::fChi2
Double_t fChi2
Definition: CbmRichTrainAnnElectrons.h:41
CbmRichTrainAnnElectrons::fMaxNofTrainSamples
UInt_t fMaxNofTrainSamples
Definition: CbmRichTrainAnnElectrons.h:99
CbmRichTrainAnnElectrons::CbmRichTrainAnnElectrons
CbmRichTrainAnnElectrons()
Default constructor.
Definition: CbmRichTrainAnnElectrons.cxx:46
CbmRichTrainAnnElectrons::fHists
vector< TH1 * > fHists
Definition: CbmRichTrainAnnElectrons.h:134
CbmRichUtil::GetRingTrackDistance
static Double_t GetRingTrackDistance(Int_t globalTrackId)
Definition: alignment/CbmRichUtil.h:20
CbmRichRing::GetRadialAngle
Double_t GetRadialAngle() const
Definition: CbmRichRing.cxx:189
CbmRichTrainAnnElectrons::fhDistTrueMatch
vector< TH1D * > fhDistTrueMatch
Definition: CbmRichTrainAnnElectrons.h:123
DrawH1
void DrawH1(TH1 *hist, HistScale logx, HistScale logy, const string &drawOpt, Int_t color, Int_t lineWidth, Int_t lineStyle, Int_t markerSize, Int_t markerStyle)
Definition: CbmDrawHist.cxx:49
RingElectronParam
Input Parameters for ANN for electron identification in RICH.
Definition: CbmRichTrainAnnElectrons.h:35
CbmGlobalTrack::GetStsTrackIndex
Int_t GetStsTrackIndex() const
Definition: CbmGlobalTrack.h:38
CbmRichTrainAnnElectrons::DiffElandPi
void DiffElandPi()
Fill input parameters for ANN in array and histograms.
Definition: CbmRichTrainAnnElectrons.cxx:252
RingElectronParam::fNofHits
Double_t fNofHits
Definition: CbmRichTrainAnnElectrons.h:43
RingElectronParam::fMomentum
Double_t fMomentum
Definition: CbmRichTrainAnnElectrons.h:45
kLinear
@ kLinear
Definition: CbmDrawHist.h:79
CbmRichTrainAnnElectrons::fhNofHits
vector< TH1D * > fhNofHits
Definition: CbmRichTrainAnnElectrons.h:126
CbmTrackMatchNew.h
CbmRichTrainAnnElectrons::fMCTracks
TClonesArray * fMCTracks
Definition: CbmRichTrainAnnElectrons.h:90
CbmRichTrainAnnElectrons::fRichRings
TClonesArray * fRichRings
Definition: CbmRichTrainAnnElectrons.h:88
ClassImp
ClassImp(CbmConverterManager) InitStatus CbmConverterManager
Definition: CbmConverterManager.cxx:12
CbmRichTrainAnnElectrons::fAnnCut
Double_t fAnnCut
Definition: CbmRichTrainAnnElectrons.h:103
CbmRichRing::GetAaxis
Double_t GetAaxis() const
Definition: CbmRichRing.h:83
CbmUtils.h
CbmRichTrainAnnElectrons::fOutputDir
string fOutputDir
Definition: CbmRichTrainAnnElectrons.h:114
CbmRichTrainAnnElectrons::CreateCanvas
TCanvas * CreateCanvas(const string &name, const string &title, int width, int height)
Definition: CbmRichTrainAnnElectrons.cxx:624
CbmRichTrainAnnElectrons::TrainAndTestAnn
void TrainAndTestAnn()
Train and test ANN.
Definition: CbmRichTrainAnnElectrons.cxx:353
RingElectronParam::fRadAngle
Double_t fRadAngle
Definition: CbmRichTrainAnnElectrons.h:40
CbmRichTrainAnnElectrons::Draw
void Draw(Option_t *="")
Draw results.
Definition: CbmRichTrainAnnElectrons.cxx:434
CbmRichRing::GetBaxis
Double_t GetBaxis() const
Definition: CbmRichRing.h:84
CbmGlobalTrack
Definition: CbmGlobalTrack.h:26
CbmRichTrainAnnElectrons::FinishTask
virtual void FinishTask()
Inherited from FairTask.
Definition: CbmRichTrainAnnElectrons.cxx:612
CbmRichTrainAnnElectrons::fhAaxisVsMom
vector< TH2D * > fhAaxisVsMom
Definition: CbmRichTrainAnnElectrons.h:130
CbmRichRing::GetPhi
Double_t GetPhi() const
Definition: CbmRichRing.h:87
CbmMCTrack.h
CbmTrackMatchNew::GetNofTrueHits
Int_t GetNofTrueHits() const
Definition: CbmTrackMatchNew.h:32
RingElectronParam::fDistance
Double_t fDistance
Definition: CbmRichTrainAnnElectrons.h:44
CbmRichTrainAnnElectrons::fQuota
Double_t fQuota
Definition: CbmRichTrainAnnElectrons.h:98
CbmMCTrack
Definition: CbmMCTrack.h:34
x
Double_t x
Definition: CbmMvdSensorDigiToHitTask.cxx:68
fabs
friend F32vec4 fabs(const F32vec4 &a)
Definition: L1/vectors/P4_F32vec4.h:60
CbmRichTrainAnnElectrons::fRichRingMatches
TClonesArray * fRichRingMatches
Definition: CbmRichTrainAnnElectrons.h:91
CbmRichTrainAnnElectrons.h
Train ANN for electron identification in RICH.
CbmRichRing::GetNDF
Double_t GetNDF() const
Definition: CbmRichRing.h:96
CbmRichTrainAnnElectrons::fRElIdParams
vector< vector< RingElectronParam > > fRElIdParams
Definition: CbmRichTrainAnnElectrons.h:111
CbmRichTrainAnnElectrons::fhAnnOutput
vector< TH1D * > fhAnnOutput
Definition: CbmRichTrainAnnElectrons.h:106
CbmTrackMatchNew
Definition: CbmTrackMatchNew.h:19
CbmRichTrainAnnElectrons::fhBaxis
vector< TH1D * > fhBaxis
Definition: CbmRichTrainAnnElectrons.h:119
DrawH2
void DrawH2(TH2 *hist, HistScale logx, HistScale logy, HistScale logz, const string &drawOpt)
Definition: CbmDrawHist.cxx:84
SetDefaultDrawStyle
void SetDefaultDrawStyle()
Definition: CbmDrawHist.cxx:33
Cbm::SaveCanvasAsImage
void SaveCanvasAsImage(TCanvas *c, const std::string &dir, const std::string &option)
Definition: CbmUtils.cxx:20
CbmRichTrainAnnElectrons::fhRadPos
vector< TH1D * > fhRadPos
Definition: CbmRichTrainAnnElectrons.h:129
CbmRichTrainAnnElectrons::fStsTracks
TClonesArray * fStsTracks
Definition: CbmRichTrainAnnElectrons.h:95
CbmRichTrainAnnElectrons
Train ANN for electron identification in RICH.
Definition: CbmRichTrainAnnElectrons.h:57
CbmStsTrack
Definition: CbmStsTrack.h:37
CbmRichTrainAnnElectrons::fEventNum
Int_t fEventNum
Definition: CbmRichTrainAnnElectrons.h:86
CbmMCTrack::GetP
Double_t GetP() const
Definition: CbmMCTrack.h:100
CbmRichTrainAnnElectrons::fGlobalTracks
TClonesArray * fGlobalTracks
Definition: CbmRichTrainAnnElectrons.h:94
kLog
@ kLog
Definition: CbmDrawHist.h:78
CbmRichTrainAnnElectrons::fCanvas
vector< TCanvas * > fCanvas
Definition: CbmRichTrainAnnElectrons.h:113
CbmRichTrainAnnElectrons::fStsTrackMatches
TClonesArray * fStsTrackMatches
Definition: CbmRichTrainAnnElectrons.h:93
CbmRichTrainAnnElectrons::fhChi2
vector< TH1D * > fhChi2
Definition: CbmRichTrainAnnElectrons.h:127
RingElectronParam::fAaxis
Double_t fAaxis
Definition: CbmRichTrainAnnElectrons.h:37
CbmRichTrainAnnElectrons::fhBaxisVsMom
vector< TH2D * > fhBaxisVsMom
Definition: CbmRichTrainAnnElectrons.h:131