CbmRoot
Loading...
Searching...
No Matches
CbmAnaConversionKF.cxx
Go to the documentation of this file.
1/* Copyright (C) 2014-2016 Fakultaet fuer Mathematik und Naturwissenschaften, Bergische Universitaet Wuppertal, Wuppertal
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Sascha Reinecke [committer], Florian Uhlig */
4
15#include "CbmAnaConversionKF.h"
16
17
18// included from CbmRoot
19#include "CbmKFParticleFinder.h"
21#include "CbmMCTrack.h"
22#include "CbmStsTrack.h"
23#include "CbmTrackMatchNew.h"
24
25#include "FairRootManager.h"
26
27#include "TDatabasePDG.h"
28
29#include "KFParticleTopoReconstructor.h"
30#include "KFTopoPerformance.h"
31
32
33#define M2E 2.6112004954086e-7
34
35using namespace std;
36
37
39 : fKFMcParticles(NULL)
40 , fMcTracks(NULL)
41 , fStsTracks(NULL)
42 , fStsTrackMatches(NULL)
43 , fKFparticle(NULL)
44 , fKFparticleFinderQA(NULL)
45 , fKFtopo(NULL)
46 , fKFtopoPerf(0)
47 , trackindexarray()
48 , particlecounter(0)
49 , particlecounter_2daughters(0)
50 , particlecounter_3daughters(0)
51 , particlecounter_4daughters(0)
52 , particlecounter_all(0)
53 , fhPi0_NDaughters(NULL)
54 , fNofGeneratedPi0_allEvents(0)
55 , fNofPi0_kfparticle_allEvents(0)
56 , fNofGeneratedPi0(0)
57 , fNofPi0_kfparticle(0)
58 , fhPi0Ratio(NULL)
59 , fhPi0_mass(NULL)
60 , fSignalIds()
61 , fGhostIds()
62 , fHistoList_kfparticle()
63 , particlevector()
64 , particleMatch()
65 , electronIDs()
66 , gammaIDs()
67 , fhInvMassPi0WithFullReco(NULL)
68 , fhInvMass2Gammas(NULL)
69 , fhInvMass2Gammas_cut(NULL)
70 , fhKF_particlevector(NULL)
71 , fhKF_trackvector(NULL)
72 , fhKF_NofPi0(NULL)
73 , fhKF_NofPi0_signal(NULL)
74 , fhKF_NofPi0_trackvector(NULL)
75 , fKF_photon_pairs()
76 , fhKF_invmass_fullReco(NULL)
77 , timer()
78 , fTime(0.)
79{
80}
81
83
84
86{
87 FairRootManager* ioman = FairRootManager::Instance();
88 if (NULL == ioman) { Fatal("CbmAnaConversionKF::Init", "RootManager not instantised!"); }
89
90 fKFMcParticles = (TClonesArray*) ioman->GetObject("KFMCParticles");
91 if (NULL == fKFMcParticles) { Fatal("CbmAnaConversionKF::Init", "No KFMCParticles array!"); }
92
93 fMcTracks = (TClonesArray*) ioman->GetObject("MCTrack");
94 if (NULL == fMcTracks) { Fatal("CbmAnaConversionKF::Init", "No MCTrack array!"); }
95
96 fStsTracks = (TClonesArray*) ioman->GetObject("StsTrack");
97 if (NULL == fStsTracks) { Fatal("CbmAnaConversionKF::Init", "No StsTrack array!"); }
98
99 fStsTrackMatches = (TClonesArray*) ioman->GetObject("StsTrackMatch");
100 if (NULL == fStsTrackMatches) { Fatal("CbmAnaConversionKF::Init", "No StsTrackMatch array!"); }
101
102
104 fKFtopoPerf = new KFTopoPerformance;
105 fKFtopoPerf->SetTopoReconstructor(fKFtopo);
106
107 InitHistos();
108}
109
110
112{
113 fHistoList_kfparticle.clear();
114
115 // #############################################
116 // Histograms related to KFParticle results
117 fhPi0_NDaughters = new TH1D("fhPi0_NDaughters", "fhPi0_NDaughters;number of daughers;#", 4, 0.5, 4.5);
118 fhPi0Ratio = new TH1D("fhPi0Ratio", "fhPi0Ratio; ratio;#", 1000, 0., 0.02);
119 fhPi0_mass = new TH1D("fhPi0_mass", "fhPi0_mass;mass;#", 500, 0., 0.5);
123
124 fhInvMassPi0WithFullReco = new TH1D("fhInvMassPi0WithFullReco", "fhInvMassPi0WithFullReco;invmass;#", 400, 0., 2.);
126
127 fhInvMass2Gammas = new TH1D("fhInvMass2Gammas", "fhInvMass2Gammas;invmass;#", 400, 0., 2.);
129 fhInvMass2Gammas_cut = new TH1D("fhInvMass2Gammas_cut", "fhInvMass2Gammas_cut;invmass;#", 400, 0., 2.);
131
132 fhKF_particlevector = new TH1D("fhKF_particlevector", "fhKF_particlevector;;#", 10, 0., 10.);
134 fhKF_particlevector->GetXaxis()->SetBinLabel(1, "electrons");
135 fhKF_particlevector->GetXaxis()->SetBinLabel(2, "gamma");
136 fhKF_particlevector->GetXaxis()->SetBinLabel(3, "pi0");
137 fhKF_trackvector = new TH1D("fhKF_trackvector", "fhKF_trackvector;;#", 10, 0., 10.);
139 fhKF_trackvector->GetXaxis()->SetBinLabel(1, "electrons");
140 fhKF_trackvector->GetXaxis()->SetBinLabel(2, "gamma");
141 fhKF_trackvector->GetXaxis()->SetBinLabel(3, "pi0");
142
143 fhKF_NofPi0 = new TH1D("fhKF_NofPi0", "fhKF_NofPi0;nof;#", 10, -0.5, 9.5);
145 fhKF_NofPi0_signal = new TH1D("fhKF_NofPi0_signal", "fhKF_NofPi0_signal;nof;#", 10, -0.5, 9.5);
147 fhKF_NofPi0_trackvector = new TH1D("fhKF_NofPi0_trackvector", "fhKF_NofPi0_trackvector;nof;#", 10, -0.5, 9.5);
149
150
151 fhKF_invmass_fullReco = new TH1D("fhKF_invmass_fullReco", "fhKF_invmass_fullReco;invmass;#", 400, 0., 2.);
153}
154
155
157{
158 //gDirectory->cd("analysis-conversion");
159 gDirectory->mkdir("KF");
160 gDirectory->cd("KF");
161 for (UInt_t i = 0; i < fHistoList_kfparticle.size(); i++) {
162 fHistoList_kfparticle[i]->Write();
163 }
164 gDirectory->cd("..");
165
166 cout << "CbmAnaConversionKF: Realtime - " << fTime << endl;
167}
168
169
171{
172 timer.Start();
173
174 electronIDs.clear();
175 gammaIDs.clear();
176 fKF_photon_pairs.clear();
177
178 //KFParticle_Analysis();
179 test2();
180
183
184 Reconstruct();
186
187 timer.Stop();
188 fTime += timer.RealTime();
189}
190
191
193{
194 fKFparticle = kfparticle;
195 fKFparticleFinderQA = kfparticleQA;
196 if (fKFparticle) { cout << "CbmAnaConversionKF: kf works" << endl; }
197 else {
198 cout << "CbmAnaConversionKF: kf works not" << endl;
199 }
200}
201
202
203void CbmAnaConversionKF::SetSignalIds(std::vector<int>* signalids)
204{
205 fSignalIds.clear();
206 fSignalIds = *signalids;
207}
208
209void CbmAnaConversionKF::SetGhostIds(std::vector<int>* ghostids)
210{
211 fGhostIds.clear();
212 fGhostIds = *ghostids;
213}
214
215
216/*
217void CbmAnaConversionKF::KFParticle_Analysis()
218{
219 timer.Start();
220
221 int testkf = fKFtopo->NPrimaryVertices();
222 cout << "KFParticle_Analysis - test kf NPrimaryVertices: " << testkf << endl;
223
224 const KFPTrackVector* kftrackvector;
225 kftrackvector = fKFtopo->GetTracks();
226 cout << "KFParticle_Analysis - trackvector: " << kftrackvector->Size() << endl;
227 KFParticle testparticle;
228 KFPTrack testtrack;
229 const int bla = 2;
230 kftrackvector->GetTrack(testtrack, bla);
231 cout << "KFParticle_Analysis - test p: " << testtrack.GetP() << endl;
232 kfvector_int pdgvector;
233 pdgvector = kftrackvector->PDG();
234 //cout << "pdg tests: " << pdgvector[1] << "\t" << pdgvector[2] << "\t" << pdgvector[3] << "\t" << pdgvector[4] << endl;
235
236
237 int nofpions = 0;
238 //nofpions = kftrackvector->NPions();
239 cout << "KFParticle_Analysis - number of pions: " << nofpions << endl;
240
241 int testpi = 0;
242 for(int i=0; i<kftrackvector->Size(); i++) {
243 if(TMath::Abs(pdgvector[i]) == 211) testpi++;
244 }
245 cout << "KFParticle_Analysis - testpi: " << testpi << endl;
246
247 //kftrackvector->PrintTracks();
248
249
250 vector<KFParticle> particlevector;
251 particlevector = fKFtopo->GetParticles();
252
253
254 cout << "KFParticle_Analysis - particlevector size: " << particlevector.size() << "\t";
255 for(int i=0; i<particlevector.size(); i++) {
256 if(particlevector[i].NDaughters() > 3) {
257 cout << particlevector[i].NDaughters() << "\t";
258 }
259 if(particlevector[i].GetPDG() == 111) {
260 cout << "blubb" << particlevector[i].NDaughters() << "\t";
261 if(particlevector[i].NDaughters() > 2) {
262 particlecounter++;
263 }
264
265 std::vector<int> daughterid;
266 daughterid = particlevector[i].DaughterIds();
267 cout << "daughterids: ";
268 for(int j=0; j<daughterid.size(); j++) {
269 cout << daughterid[j] << "/";
270 cout << "pdg-" << particlevector[daughterid[j]].GetPDG() << "-";
271 }
272 particlecounter_all++;
273 }
274 }
275 cout << endl;
276
277
278
279 cout << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" << endl;
280 cout << "KFParticle_Analysis - SignalIds size: " << fSignalIds.size() << "\t";
281 for(int i=0; i<fSignalIds.size(); i++) {
282 Int_t pdg = (fKFtopo->GetParticles()[fSignalIds[i]]).GetPDG();
283 Int_t daughters = (fKFtopo->GetParticles()[fSignalIds[i]]).NDaughters();
284 vector<int> daughterIds = (fKFtopo->GetParticles()[fSignalIds[i]]).DaughterIds();
285 float mass = 0;
286 float mass_sigma = 0;
287 (fKFtopo->GetParticles()[fSignalIds[i]]).GetMass(mass, mass_sigma);
288 if(pdg == 111) {
289 cout << "CbmAnaConversionKF: pi0 found, signal id: " << (fKFtopo->GetParticles()[fSignalIds[i]]).Id() << "\t daughters: " << daughters << "\t";
290 cout << "daughter ids: ";
291 Int_t electronids[4] = {0};
292 for(int j=0; j<daughterIds.size(); j++) {
293 vector<int> granddaughterIds = (fKFtopo->GetParticles()[daughterIds[j]]).DaughterIds();
294 cout << daughterIds[j] << " (" << granddaughterIds[0] << ",pdg" << (fKFtopo->GetParticles()[granddaughterIds[0]]).GetPDG() << "/" << granddaughterIds[1] << ",pdg" << (fKFtopo->GetParticles()[granddaughterIds[1]]).GetPDG() << ")" << " / ";
295 electronids[j*2] = granddaughterIds[0];
296 electronids[j*2+1] = granddaughterIds[1];
297 }
298 cout << endl;
299
300 cout << "the 4 electrons and their grandmotherids: ";
301 CbmMCTrack * electrontracks[4];
302 for(int k=0; k<4; k++) {
303 electrontracks[k] = (CbmMCTrack*) fMcTracks->At(electronids[k]);
304 CbmMCTrack* mother = (CbmMCTrack*) fMcTracks->At(electrontracks[k]->GetMotherId());
305 if(mother == NULL) continue;
306 CbmMCTrack* grandmother = (CbmMCTrack*) fMcTracks->At(mother->GetMotherId());
307 if(grandmother == NULL) continue;
308 cout << "gmid" << mother->GetMotherId() << "pdg" << grandmother->GetPdgCode() << " / ";
309
310 }
311 cout << endl;
312
313 particlecounter++;
314 if(daughters == 2) { particlecounter_2daughters++; }
315 if(daughters == 3) { particlecounter_3daughters++; }
316 if(daughters == 4) { particlecounter_4daughters++; }
317 fhPi0_NDaughters->Fill(daughters);
318 fhPi0_mass->Fill(mass);
319 fNofPi0_kfparticle++;
320 }
321 }
322
323 cout << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" << endl;
324 cout << "KFParticle_Analysis - GhostIds size: " << fGhostIds.size() << "\t";
325 for(int i=0; i<fGhostIds.size(); i++) {
326 Int_t pdg = (fKFtopo->GetParticles()[fGhostIds[i]]).GetPDG();
327 Int_t daughters = (fKFtopo->GetParticles()[fGhostIds[i]]).NDaughters();
328 if(pdg == 111) {
329 cout << "pi0 found!\t";
330 particlecounter++;
331 if(daughters == 2) { particlecounter_2daughters++; }
332 if(daughters == 3) { particlecounter_3daughters++; }
333 if(daughters == 4) { particlecounter_4daughters++; }
334 //fhPi0_NDaughters->Fill(daughters);
335 }
336 }
337
338 cout << endl;
339 cout << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" << endl;
340
341
342
343
344// trackindexarray.clear();
345// trackindexarray = fKFtopo->GetPVTrackIndexArray();
346// cout << "trackindexarray: " << trackindexarray.size() << endl;
347
348// KFVertex vertex;
349// vertex = fKFtopo->GetPrimKFVertex();
350// int testnof = 0;
351// testnof = vertex.GetNContributors();
352// cout << "nof contributors: " << testnof << endl;
353
354// KFParticle particle;
355// particle = fKFtopo->GetPrimVertex();
356
357
358// for(int i=0; i < kftrackvector->Size(); i++) {
359 //const kfvector_int& tempPDG;
360 //tempPDG = kftrackvector->PDG;
361 //fKFVertex->At(trackindexarray[i]);
362
363// }
364
365
366
367 test();
368
369 timer.Stop();
370 fTime += timer.RealTime();
371}
372*/
373
374
376{
377 int nofparticles = fKFMcParticles->GetEntriesFast();
378 cout << "CbmAnaConversionKF: test nof " << nofparticles << endl;
379 for (int i = 0; i < nofparticles; i++) {
380 CbmMCTrack* mcTrack1 = (CbmMCTrack*) fKFMcParticles->At(i);
381 int pdg = TMath::Abs(mcTrack1->GetPdgCode());
382 if (pdg == 111) { cout << "CbmAnaConversionKF: test successful!" << endl; }
383 }
384
385
386 vector<vector<int>> ids;
387 const vector<KFParticle>& particles = fKFparticle->GetTopoReconstructor()->GetParticles();
388 for (unsigned int iPart = 0; iPart < fSignalIds.size(); iPart++) {
389 if (particles[fSignalIds[iPart]].GetPDG() != 111) continue;
390 //some cuts on pi0 if needed
391
392 const KFParticle& pi0 = particles[fSignalIds[iPart]];
393 vector<int> electrons;
394 for (int iGamma = 0; iGamma < pi0.NDaughters(); iGamma++) {
395 const int GammaID = pi0.DaughterIds()[iGamma];
396 const KFParticle& Gamma = particles[GammaID];
397 for (int iElectron = 0; iElectron < Gamma.NDaughters(); iElectron++) {
398 int ElectronID = Gamma.DaughterIds()[iElectron];
399 const KFParticle& Electron = particles[ElectronID];
400 int STStrackID = Electron.DaughterIds()[0];
401 electrons.push_back(STStrackID);
402 }
403 }
404 ids.push_back(electrons);
405 }
406
407 if (ids.size() > 0) {
408 cout << "NEW TEST: (sts ids) ";
409 for (unsigned int i = 0; i < ids.size(); i++) {
410 for (int j = 0; j < 4; j++) {
411 cout << " " << ids[i][j];
412 }
413 cout << " | ";
414 }
415 cout << endl;
416
417
418 cout << "MC-pdgs: ";
420 for (unsigned int i = 0; i < ids.size(); i++) {
421 for (int j = 0; j < 4; j++) {
422 CbmStsTrack* stsTrack = (CbmStsTrack*) fStsTracks->At(ids[i][j]);
423 if (stsTrack == NULL) return;
424 CbmTrackMatchNew* stsMatch = (CbmTrackMatchNew*) fStsTrackMatches->At(ids[i][j]);
425 if (stsMatch == NULL) return;
426 int stsMcTrackId = stsMatch->GetMatchedLink().GetIndex();
427 if (stsMcTrackId < 0) return;
428 mcTracks[j] = (CbmMCTrack*) fMcTracks->At(stsMcTrackId);
429 if (mcTracks[j] == NULL) return;
430
431 CbmMCTrack* mother = (CbmMCTrack*) fMcTracks->At(mcTracks[j]->GetMotherId());
432 CbmMCTrack* grandmother = (CbmMCTrack*) fMcTracks->At(mother->GetMotherId());
433
434
435 cout << " " << stsMcTrackId << "/" << mcTracks[j]->GetPdgCode() << "(motherid" << mcTracks[j]->GetMotherId()
436 << ",motherpdg" << mother->GetPdgCode() << ",grandmotherpdg" << grandmother->GetPdgCode()
437 << ",grandmotherid" << mother->GetMotherId() << ")";
438 }
439 }
440 cout << endl;
441 Double_t mass = Invmass_4particles(mcTracks[0], mcTracks[1], mcTracks[2], mcTracks[3]);
442 cout << "mass: " << mass << endl;
443 }
444}
445
446
447Double_t CbmAnaConversionKF::Invmass_4particles(const CbmMCTrack* mctrack1, const CbmMCTrack* mctrack2,
448 const CbmMCTrack* mctrack3, const CbmMCTrack* mctrack4)
449// calculation of invariant mass from four electrons/positrons
450{
451 TLorentzVector lorVec1;
452 mctrack1->Get4Momentum(lorVec1);
453
454 TLorentzVector lorVec2;
455 mctrack2->Get4Momentum(lorVec2);
456
457 TLorentzVector lorVec3;
458 mctrack3->Get4Momentum(lorVec3);
459
460 TLorentzVector lorVec4;
461 mctrack4->Get4Momentum(lorVec4);
462
463
464 TLorentzVector sum;
465 sum = lorVec1 + lorVec2 + lorVec3 + lorVec4;
466 cout << "mc: \t" << sum.Px() << " / " << sum.Py() << " / " << sum.Pz() << " / " << sum.E()
467 << "\t => mag = " << sum.Mag() << endl;
468
469 return sum.Mag();
470}
471
472
474{
475 Int_t pi0counter_trackvector = 0;
476 const KFPTrackVector* kftrackvector;
477 kftrackvector = fKFtopo->GetTracks();
478 Int_t kftv_size = kftrackvector->Size();
479 cout << "CbmAnaConversionKF: size of kftrackvector: " << kftv_size << endl;
480
481 kfvector_int vector_pdgs = kftrackvector->PDG();
482
483 cout << "CbmAnaConversionKF: pdgs in trackvector: ";
484 for (int i = 0; i < kftv_size; i++) {
485 cout << vector_pdgs[i] << " / ";
486 if (TMath::Abs(vector_pdgs[i]) == 111) {
487 pi0counter_trackvector++;
488 fhKF_trackvector->Fill(2);
489 }
490 if (TMath::Abs(vector_pdgs[i]) == 11) { fhKF_trackvector->Fill(0); }
491 if (TMath::Abs(vector_pdgs[i]) == 22) { fhKF_trackvector->Fill(1); }
492 }
493 cout << endl;
494
495 fhKF_NofPi0_trackvector->Fill(pi0counter_trackvector);
496
497
498 // particlevector to get all pi0 detected by KFParticlePackage (including signal, ghost, background); trackvector DOES NOT WORK
499 particlevector.clear();
500 particleMatch.clear();
501 //vector<KFParticle> particlevector;
502
503
504 particlevector = fKFtopo->GetParticles();
505
506
507 particleMatch = fKFtopoPerf->ParticlesMatch();
508 Int_t pv_size = particlevector.size();
509 cout << "CbmAnaConversionKF: size of particlevector: " << pv_size << endl;
510 cout << "CbmAnaConversionKF: size of particleMatch: " << particleMatch.size() << endl;
511
512 Int_t electroncounter = 0;
513 Int_t pi0counter = 0;
514 Int_t pi0counter_signal = 0;
515 Int_t gammacounter = 0;
516 for (int i = 0; i < pv_size; i++) {
517 if (TMath::Abs(particlevector[i].GetPDG()) == 11) {
518 electroncounter++;
519 electronIDs.push_back(i);
520 fhKF_particlevector->Fill(0);
521 }
522 if (TMath::Abs(particlevector[i].GetPDG()) == 111) {
523 pi0counter++;
524 fhKF_particlevector->Fill(2);
525 //if(particleMatch[i].IsMatchedWithPdg()) {
526 // pi0counter_signal++;
527 //}
528 }
529 if (TMath::Abs(particlevector[i].GetPDG()) == 22) {
530 gammacounter++;
531 gammaIDs.push_back(i);
532 fhKF_particlevector->Fill(1);
533 }
534 }
535
536
537 fhKF_NofPi0->Fill(pi0counter);
538 fhKF_NofPi0_signal->Fill(pi0counter_signal);
539
540 cout << "CbmAnaConversionKF: nof electrons in particlevector: " << electroncounter << endl;
541 cout << "CbmAnaConversionKF: nof pi0 in particlevector: " << pi0counter << endl;
542 cout << "CbmAnaConversionKF: nof gamma in particlevector: " << gammacounter << endl;
543}
544
545
547{
548 Int_t nof = electronIDs.size();
549 if (nof >= 2) {
550 for (int a = 0; a < nof - 1; a++) {
551 for (int b = a + 1; b < nof; b++) {
552 KFParticle electron1 = particlevector[electronIDs[a]];
553 KFParticle electron2 = particlevector[electronIDs[b]];
554 Double_t openingAngle = electron1.GetAngle(electron2);
555
556 TLorentzVector lorentzE1;
557 lorentzE1.SetPxPyPzE(electron1.GetPx(), electron1.GetPy(), electron1.GetPz(), electron1.GetE());
558 TLorentzVector lorentzE2;
559 lorentzE2.SetPxPyPzE(electron2.GetPx(), electron2.GetPy(), electron2.GetPz(), electron2.GetE());
560 TLorentzVector sum = lorentzE1 + lorentzE2;
561 Double_t invmass = sum.Mag();
562
563 if (openingAngle < 1 && invmass < 0.03) {
564 vector<int> pair; // = {a, b};
565 pair.push_back(a);
566 pair.push_back(b);
567 fKF_photon_pairs.push_back(pair);
568 }
569 }
570 }
571 }
572}
573
574
576{
577 Int_t nof = fKF_photon_pairs.size();
578 if (nof >= 2) {
579 for (int a = 0; a < nof - 1; a++) {
580 for (int b = a + 1; b < nof; b++) {
581 Int_t electron11 = fKF_photon_pairs[a][0];
582 Int_t electron12 = fKF_photon_pairs[a][1];
583 Int_t electron21 = fKF_photon_pairs[b][0];
584 Int_t electron22 = fKF_photon_pairs[b][1];
585
586 Double_t invmass = Invmass_4particlesRECO(particlevector[electron11], particlevector[electron12],
587 particlevector[electron21], particlevector[electron22]);
588 fhKF_invmass_fullReco->Fill(invmass);
589 }
590 }
591 }
592}
593
594
596{
597 Int_t nof = electronIDs.size();
598 if (nof >= 4) {
599 for (int a = 0; a < nof - 3; a++) {
600 for (int b = a + 1; b < nof - 2; b++) {
601 for (int c = b + 1; c < nof - 1; c++) {
602 for (int d = c + 1; d < nof; d++) {
603 Int_t check1 = (particlevector[electronIDs[a]].GetPDG() > 0);
604 Int_t check2 = (particlevector[electronIDs[b]].GetPDG() > 0);
605 Int_t check3 = (particlevector[electronIDs[c]].GetPDG() > 0);
606 Int_t check4 = (particlevector[electronIDs[d]].GetPDG() > 0);
607 Int_t test1234 = check1 + check2 + check3 + check4;
608 if (test1234 != 2) continue; // need two electrons and two positrons
609
610
611 KFParticle particle1 = particlevector[electronIDs[a]];
612 KFParticle particle2 = particlevector[electronIDs[b]];
613 KFParticle particle3 = particlevector[electronIDs[c]];
614 KFParticle particle4 = particlevector[electronIDs[d]];
615 Double_t invmass = Invmass_4particlesRECO(particle1, particle2, particle3, particle4);
616
617
618 Bool_t fill = false;
619 Double_t invmass_cut = 0.02;
620
621 if (particle1.GetZ() == particle2.GetZ() && particle3.GetZ() == particle4.GetZ()) {
622 Double_t invmass_12 = Invmass_2electrons(particle1, particle2);
623 Double_t invmass_34 = Invmass_2electrons(particle3, particle4);
624 if (invmass_12 < invmass_cut && invmass_34 < invmass_cut) { fill = true; }
625 }
626 if (particle1.GetZ() == particle3.GetZ() && particle2.GetZ() == particle4.GetZ()) {
627 Double_t invmass_13 = Invmass_2electrons(particle1, particle3);
628 Double_t invmass_24 = Invmass_2electrons(particle2, particle4);
629 if (invmass_13 < invmass_cut && invmass_24 < invmass_cut) { fill = true; }
630 }
631 if (particle1.GetZ() == particle4.GetZ() && particle2.GetZ() == particle3.GetZ()) {
632 Double_t invmass_14 = Invmass_2electrons(particle1, particle4);
633 Double_t invmass_23 = Invmass_2electrons(particle2, particle3);
634 if (invmass_14 < invmass_cut && invmass_23 < invmass_cut) { fill = true; }
635 }
636
637
638 if (fill) fhInvMassPi0WithFullReco->Fill(invmass);
639
640 /*
641 CbmLmvmKinematicParams params1 = CalculateKinematicParamsReco(fElectrons_momenta[a], fElectrons_momenta[b]);
642 CbmLmvmKinematicParams params2 = CalculateKinematicParamsReco(fElectrons_momenta[a], fElectrons_momenta[c]);
643 CbmLmvmKinematicParams params3 = CalculateKinematicParamsReco(fElectrons_momenta[a], fElectrons_momenta[d]);
644 CbmLmvmKinematicParams params4 = CalculateKinematicParamsReco(fElectrons_momenta[b], fElectrons_momenta[c]);
645 CbmLmvmKinematicParams params5 = CalculateKinematicParamsReco(fElectrons_momenta[b], fElectrons_momenta[d]);
646 CbmLmvmKinematicParams params6 = CalculateKinematicParamsReco(fElectrons_momenta[c], fElectrons_momenta[d]);
647
648 Double_t openingAngleCut = 1;
649 Int_t IsPhoton_openingAngle1 = (params1.fAngle < openingAngleCut);
650 Int_t IsPhoton_openingAngle2 = (params2.fAngle < openingAngleCut);
651 Int_t IsPhoton_openingAngle3 = (params3.fAngle < openingAngleCut);
652 Int_t IsPhoton_openingAngle4 = (params4.fAngle < openingAngleCut);
653 Int_t IsPhoton_openingAngle5 = (params5.fAngle < openingAngleCut);
654 Int_t IsPhoton_openingAngle6 = (params6.fAngle < openingAngleCut);
655
656 Double_t invMassCut = 0.03;
657 Int_t IsPhoton_invMass1 = (params1.fMinv < invMassCut);
658 Int_t IsPhoton_invMass2 = (params2.fMinv < invMassCut);
659 Int_t IsPhoton_invMass3 = (params3.fMinv < invMassCut);
660 Int_t IsPhoton_invMass4 = (params4.fMinv < invMassCut);
661 Int_t IsPhoton_invMass5 = (params5.fMinv < invMassCut);
662 Int_t IsPhoton_invMass6 = (params6.fMinv < invMassCut);
663
664 if(IsPhoton_openingAngle1 && IsPhoton_openingAngle6 && IsPhoton_invMass1 && IsPhoton_invMass6 && (check1 + check2 == 1) && (check3 + check4 == 1)) {
665 fhElectrons_invmass_cut->Fill(invmass);
666 }
667 if(IsPhoton_openingAngle2 && IsPhoton_openingAngle5 && IsPhoton_invMass2 && IsPhoton_invMass5 && (check1 + check3 == 1) && (check2 + check4 == 1)) {
668 fhElectrons_invmass_cut->Fill(invmass);
669 }
670 if(IsPhoton_openingAngle3 && IsPhoton_openingAngle4 && IsPhoton_invMass3 && IsPhoton_invMass4 && (check1 + check4 == 1) && (check2 + check3 == 1)) {
671 fhElectrons_invmass_cut->Fill(invmass);
672 }
673 */
674 }
675 }
676 }
677 }
678 }
679}
680
681
683{
684 Int_t nof = gammaIDs.size();
685 if (nof >= 2) {
686 for (int a = 0; a < nof - 1; a++) {
687 for (int b = a + 1; b < nof; b++) {
688 KFParticle particle1 = particlevector[gammaIDs[a]];
689 KFParticle particle2 = particlevector[gammaIDs[b]];
690 Double_t invmass = Invmass_2gamma(particle1, particle2);
691 Double_t openingAngle = OpeningAngleBetweenPhotons(particle1, particle2);
692
693 fhInvMass2Gammas->Fill(invmass);
694
695 if ((TMath::Abs(particle1.GetZ() - particle2.GetZ()) < 0.005) && (openingAngle < 5)) {
696 fhInvMass2Gammas_cut->Fill(invmass);
697 }
698 }
699 }
700 }
701}
702
703
704Double_t CbmAnaConversionKF::Invmass_4particlesRECO(KFParticle part1, KFParticle part2, KFParticle part3,
705 KFParticle part4)
706// calculation of invariant mass from four electrons/positrons
707{
708 TVector3 momentum1(part1.GetPx(), part1.GetPy(), part1.GetPz());
709 Double_t energy1 = TMath::Sqrt(momentum1.Mag2() + M2E);
710 TLorentzVector lorVec1(momentum1, energy1);
711
712 TVector3 momentum2(part2.GetPx(), part2.GetPy(), part2.GetPz());
713 Double_t energy2 = TMath::Sqrt(momentum2.Mag2() + M2E);
714 TLorentzVector lorVec2(momentum2, energy2);
715
716 TVector3 momentum3(part3.GetPx(), part3.GetPy(), part3.GetPz());
717 Double_t energy3 = TMath::Sqrt(momentum3.Mag2() + M2E);
718 TLorentzVector lorVec3(momentum3, energy3);
719
720 TVector3 momentum4(part4.GetPx(), part4.GetPy(), part4.GetPz());
721 Double_t energy4 = TMath::Sqrt(momentum4.Mag2() + M2E);
722 TLorentzVector lorVec4(momentum4, energy4);
723
724
725 TLorentzVector sum;
726 sum = lorVec1 + lorVec2 + lorVec3 + lorVec4;
727
728 return sum.Mag();
729}
730
731
732Double_t CbmAnaConversionKF::Invmass_2gamma(KFParticle part1, KFParticle part2)
733{
734 TVector3 momentum1(part1.GetPx(), part1.GetPy(), part1.GetPz());
735 Double_t energy1 = TMath::Sqrt(momentum1.Mag2());
736 TLorentzVector lorVec1(momentum1, energy1);
737
738 TVector3 momentum2(part2.GetPx(), part2.GetPy(), part2.GetPz());
739 Double_t energy2 = TMath::Sqrt(momentum2.Mag2());
740 TLorentzVector lorVec2(momentum2, energy2);
741
742
743 TLorentzVector sum;
744 sum = lorVec1 + lorVec2;
745
746 return sum.Mag();
747}
748
749
750Double_t CbmAnaConversionKF::Invmass_2electrons(KFParticle part1, KFParticle part2)
751{
752 TVector3 momentum1(part1.GetPx(), part1.GetPy(), part1.GetPz());
753 Double_t energy1 = TMath::Sqrt(momentum1.Mag2() + M2E);
754 TLorentzVector lorVec1(momentum1, energy1);
755
756 TVector3 momentum2(part2.GetPx(), part2.GetPy(), part2.GetPz());
757 Double_t energy2 = TMath::Sqrt(momentum2.Mag2() + M2E);
758 TLorentzVector lorVec2(momentum2, energy2);
759
760
761 TLorentzVector sum;
762 sum = lorVec1 + lorVec2;
763
764 return sum.Mag();
765}
766
767
768Double_t CbmAnaConversionKF::OpeningAngleBetweenPhotons(KFParticle part1, KFParticle part2)
769{
770 TVector3 momentum1(part1.GetPx(), part1.GetPy(), part1.GetPz());
771 Double_t energy1 = TMath::Sqrt(momentum1.Mag2());
772 TLorentzVector lorVec1(momentum1, energy1);
773
774 TVector3 momentum2(part2.GetPx(), part2.GetPy(), part2.GetPz());
775 Double_t energy2 = TMath::Sqrt(momentum2.Mag2());
776 TLorentzVector lorVec2(momentum2, energy2);
777
778
779 Double_t angleBetweenPhotons = lorVec1.Angle(lorVec2.Vect());
780 Double_t theta = 180. * angleBetweenPhotons / TMath::Pi();
781
782 return theta;
783}
#define M2E
Data class for STS tracks.
static vector< vector< QAMCTrack > > mcTracks
TClonesArray * fStsTracks
std::vector< KFParticle > particlevector
Double_t Invmass_2gamma(KFParticle part1, KFParticle part2)
TClonesArray * fStsTrackMatches
const KFParticleTopoReconstructor * fKFtopo
TClonesArray * fKFMcParticles
Double_t Invmass_4particlesRECO(KFParticle part1, KFParticle part2, KFParticle part3, KFParticle part4)
void SetSignalIds(std::vector< int > *signalids)
std::vector< int > fSignalIds
std::vector< std::vector< int > > fKF_photon_pairs
CbmKFParticleFinder * fKFparticle
void SetKF(CbmKFParticleFinder *kfparticle, CbmKFParticleFinderQa *kfparticleQA)
std::vector< TH1 * > fHistoList_kfparticle
Double_t Invmass_2electrons(KFParticle part1, KFParticle part2)
std::vector< int > fGhostIds
CbmKFParticleFinderQa * fKFparticleFinderQA
TClonesArray * fMcTracks
std::vector< KFPartMatch > particleMatch
KFTopoPerformance * fKFtopoPerf
std::vector< int > electronIDs
Double_t Invmass_4particles(const CbmMCTrack *mctrack1, const CbmMCTrack *mctrack2, const CbmMCTrack *mctrack3, const CbmMCTrack *mctrack4)
void SetGhostIds(std::vector< int > *ghostids)
std::vector< int > gammaIDs
Double_t OpeningAngleBetweenPhotons(KFParticle part1, KFParticle part2)
const KFParticleTopoReconstructor * GetTopoReconstructor() const
int32_t GetMotherId() const
Definition CbmMCTrack.h:69
int32_t GetPdgCode() const
Definition CbmMCTrack.h:68
void Get4Momentum(TLorentzVector &momentum) const
Definition CbmMCTrack.h:173
const CbmLink & GetMatchedLink() const
Definition CbmMatch.h:41
Hash for CbmL1LinkKey.