Belle II Software  release-06-01-15
DataWriterModule.cc
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 
9 
10 
11 #include <reconstruction/modules/KlId/DataWriter/DataWriterModule.h>
12 #include <mdst/dataobjects/KlId.h>
13 
14 #include <framework/datastore/StoreArray.h>
15 
16 #include <tracking/dataobjects/TrackClusterSeparation.h>
17 
18 #include <analysis/ClusterUtility/ClusterUtils.h>
19 
20 #include <TTree.h>
21 #include <TFile.h>
22 #include <utility>
23 
24 #include "reconstruction/modules/KlId/KLMExpert/KlId.h"
25 
26 using namespace std;
27 using namespace Belle2;
28 using namespace Belle2::KlongId;
29 
30 
31 // --------------------------------------Module----------------------------------------------
32 
33 
34 REG_MODULE(DataWriter);
35 
36 DataWriterModule::DataWriterModule(): Module()
37 {
38  setDescription("Used to write flat ntuple for KlId classifier trainings for both ECL and KLM KlID. Output is a root file.");
39 
40  addParam("outPath", m_outPath, "Output path - where you want your root files to be placed.", m_outPath);
41  addParam("useKLM", m_useKLM, "Write KLM data.", m_useKLM);
42  addParam("useECL", m_useECL, "Write ECL data.", m_useECL);
43 }
44 
45 
46 
48 {
49 }
50 
51 
53 {
54  // require existence of necessary datastore obj
55 
56  m_eclClusters.isRequired();
57  m_klmClusters.isRequired();
59 
60  m_klmClusters.requireRelationTo(m_mcParticles);
61  m_klmClusters.registerRelationTo(m_eclClusters);
62 
63  m_f = new TFile(m_outPath.c_str(), "recreate");
64 
65  m_treeECLhadron = new TTree("ECLdataHadron", "ECLdataHadron");
66  m_treeECLgamma = new TTree("ECLdataGamma", "ECLdataGamma");
67 
68  // KLM
69  if (m_useKLM) {
70  m_treeKLM = new TTree("KLMdata", "KLMdata");
71  m_treeKLM -> Branch("KLMMCMom", & m_KLMMCMom);
72  m_treeKLM -> Branch("KLMMCPhi", & m_KLMMCPhi);
73  m_treeKLM -> Branch("KLMMCTheta", & m_KLMMCTheta);
74  m_treeKLM -> Branch("KLMMom", & m_KLMMom);
75  m_treeKLM -> Branch("KLMPhi", & m_KLMPhi);
76  m_treeKLM -> Branch("KLMTheta", & m_KLMTheta);
77  m_treeKLM -> Branch("KLMMCLifetime", & m_KLMMCLifetime);
78  m_treeKLM -> Branch("KLMMCPDG", & m_KLMMCPDG);
79  m_treeKLM -> Branch("KLMMCPrimaryPDG", & m_KLMMCPrimaryPDG);
80  m_treeKLM -> Branch("KLMMCStatus", & m_KLMMCStatus);
81  m_treeKLM -> Branch("KLMnCluster", & m_KLMnCluster);
82  m_treeKLM -> Branch("KLMnLayer", & m_KLMnLayer);
83  m_treeKLM -> Branch("KLMnInnermostlayer", & m_KLMnInnermostLayer);
84  m_treeKLM -> Branch("KLMglobalZ", & m_KLMglobalZ);
85  m_treeKLM -> Branch("KLMtime", & m_KLMtime);
86  m_treeKLM -> Branch("KLMinvM", & m_KLMinvM);
87  m_treeKLM -> Branch("KLMTruth", & m_KLMTruth);
88  m_treeKLM -> Branch("KLMdistToNextCl", & m_KLMnextCluster);
89  m_treeKLM -> Branch("KLMenergy", & m_KLMenergy);
90  m_treeKLM -> Branch("KLMaverageInterClusterDist", & m_KLMavInterClusterDist);
91  m_treeKLM -> Branch("KLMhitDepth", & m_KLMhitDepth);
92 
93  m_treeKLM -> Branch("KLMECLHypo", & m_KLMECLHypo);
94  m_treeKLM -> Branch("KLMECLZMVA", & m_KLMECLZMVA);
95  m_treeKLM -> Branch("KLMECLZ40", & m_KLMECLZ40);
96  m_treeKLM -> Branch("KLMECLZ51", & m_KLMECLZ51);
97  m_treeKLM -> Branch("KLMECLUncertaintyPhi", & m_KLMECLUncertaintyPhi);
98  m_treeKLM -> Branch("KLMECLUncertaintyTheta", & m_KLMECLUncertaintyTheta);
99  m_treeKLM -> Branch("KLMdistToNextECL", & m_KLMECLDist);
100  m_treeKLM -> Branch("KLMtrackToECL", & m_KLMtrackToECL);
101  m_treeKLM -> Branch("KLMECLEerror", & m_KLMECLEerror);
102  m_treeKLM -> Branch("KLMECLenergy", & m_KLMECLE);
103  m_treeKLM -> Branch("KLMECLE9oE25", & m_KLMECLE9oE25);
104  m_treeKLM -> Branch("KLMECLtiming", & m_KLMECLTiming);
105  m_treeKLM -> Branch("KLMECLTerror", & m_KLMECLTerror);
106  m_treeKLM -> Branch("KLMECLdeltaL", & m_KLMECLdeltaL);
107  m_treeKLM -> Branch("KLMECLmintrackDist", & m_KLMECLminTrackDist);
108  m_treeKLM -> Branch("KLMTrackSepDist", & m_KLMTrackSepDist);
109  m_treeKLM -> Branch("KLMTrackSepAngle", & m_KLMTrackSepAngle);
110  m_treeKLM -> Branch("KLMInitialtrackSepAngle", & m_KLMInitialTrackSepAngle);
111  m_treeKLM -> Branch("KLMTrackRotationAngle", & m_KLMTrackRotationAngle);
112  m_treeKLM -> Branch("KLMTrackClusterSepAngle", & m_KLMTrackClusterSepAngle);
113  m_treeKLM -> Branch("isBeamBKG", & m_isBeamBKG);
114  m_treeKLM -> Branch("KLMKlId", & m_KLMKLid);
115  m_treeKLM -> Branch("KLMAngleToMC", & m_KLMAngleToMC);
116  m_treeKLM -> Branch("KLMMCWeight", & m_KLMMCWeight);
117  m_treeKLM -> Branch("KLMtrackFlag", & m_KLMtrackFlag);
118  m_treeKLM -> Branch("KLMeclFlag", & m_KLMeclFlag);
119  m_treeKLM -> Branch("isSignal", & m_isSignal);
120  }//useKLM
121 
122  //ECL
123  if (m_useECL) {
124  m_treeECLhadron = new TTree("ECLdataHadron", "ECLdataHadron");
125  m_treeECLgamma = new TTree("ECLdataGamma", "ECLdataGamma");
126 
127  m_treeECLhadron -> Branch("ECLMCMom", & m_ECLMCMom);
128  m_treeECLhadron -> Branch("ECLMCPhi", & m_ECLMCPhi);
129  m_treeECLhadron -> Branch("ECLMCLifetime", & m_ECLMCLifetime);
130  m_treeECLhadron -> Branch("ECLMCPDG", & m_ECLMCPDG);
131  m_treeECLhadron -> Branch("ECLMCTheta", & m_ECLMCTheta);
132  m_treeECLhadron -> Branch("ECLMCLifetime", & m_ECLMCLifetime);
133  m_treeECLhadron -> Branch("ECLMCPDG", & m_ECLMCPDG);
134  m_treeECLhadron -> Branch("ECLMCStatus", & m_ECLMCStatus);
135  m_treeECLhadron -> Branch("ECLMCPrimaryPDG", & m_ECLMCPrimaryPDG);
136  m_treeECLhadron -> Branch("ECLUncertaintyEnergy", & m_ECLUncertaintyEnergy);
137  m_treeECLhadron -> Branch("ECLUncertaintyTheta", & m_ECLUncertaintyTheta);
138  m_treeECLhadron -> Branch("ECLUncertaintyPhi", & m_ECLUncertaintyPhi);
139  m_treeECLhadron -> Branch("ECLMom", & m_ECLMom);
140  m_treeECLhadron -> Branch("ECLPhi", & m_ECLPhi);
141  m_treeECLhadron -> Branch("ECLTheta", & m_ECLTheta);
142  m_treeECLhadron -> Branch("ECLZ", & m_ECLZ);
143  m_treeECLhadron -> Branch("ECLenergy", & m_ECLE);
144  m_treeECLhadron -> Branch("ECLE9oE25", & m_ECLE9oE25);
145  m_treeECLhadron -> Branch("ECLtiming", & m_ECLTiming);
146  m_treeECLhadron -> Branch("ECLR", & m_ECLR);
147  m_treeECLhadron -> Branch("ECLTruth", & m_ECLTruth);
148  m_treeECLhadron -> Branch("ECLZ51", & m_ECLZ51);
149  m_treeECLhadron -> Branch("ECLZ40", & m_ECLZ40);
150  m_treeECLhadron -> Branch("ECLE1oE9", & m_ECLE1oE9);
151  m_treeECLhadron -> Branch("ECL2ndMom", & m_ECL2ndMom);
152  m_treeECLhadron -> Branch("ECLnumChrystals", & m_ECLnumChrystals);
153  m_treeECLhadron -> Branch("ECLLAT", & m_ECLLAT);
154  m_treeECLhadron -> Branch("ECLZMVA", & m_ECLZMVA);
155  m_treeECLhadron -> Branch("ECLKlId", & m_ECLKLid);
156  m_treeECLhadron -> Branch("ECLdeltaL", & m_ECLdeltaL);
157  m_treeECLhadron -> Branch("ECLmintrackDist", & m_ECLminTrkDistance);
158  m_treeECLhadron -> Branch("isBeamBKG", & m_isBeamBKG);
159  m_treeECLhadron -> Branch("ECLMCWeight", & m_ECLMCWeight);
160  m_treeECLhadron -> Branch("isSignal", & m_isSignal);
161 
162 
163  m_treeECLgamma -> Branch("ECLMCMom", & m_ECLMCMom);
164  m_treeECLgamma -> Branch("ECLMCPhi", & m_ECLMCPhi);
165  m_treeECLgamma -> Branch("ECLMCTheta", & m_ECLMCTheta);
166  m_treeECLgamma -> Branch("ECLMCLifetime", & m_ECLMCLifetime);
167  m_treeECLgamma -> Branch("ECLMCPDG", & m_ECLMCPDG);
168  m_treeECLgamma -> Branch("ECLMCStatus", & m_ECLMCStatus);
169  m_treeECLgamma -> Branch("ECLMCPrimaryPDG", & m_ECLMCPrimaryPDG);
170  m_treeECLgamma -> Branch("ECLUncertaintyEnergy", & m_ECLUncertaintyEnergy);
171  m_treeECLgamma -> Branch("ECLUncertaintyTheta", & m_ECLUncertaintyTheta);
172  m_treeECLgamma -> Branch("ECLUncertaintyPhi", & m_ECLUncertaintyPhi);
173  m_treeECLgamma -> Branch("ECLMom", & m_ECLMom);
174  m_treeECLgamma -> Branch("ECLPhi", & m_ECLPhi);
175  m_treeECLgamma -> Branch("ECLTheta", & m_ECLTheta);
176  m_treeECLgamma -> Branch("ECLZ", & m_ECLZ);
177  m_treeECLgamma -> Branch("ECLenergy", & m_ECLE);
178  m_treeECLgamma -> Branch("ECLE9oE25", & m_ECLE9oE25);
179  m_treeECLgamma -> Branch("ECLtiming", & m_ECLTiming);
180  m_treeECLgamma -> Branch("ECLR", & m_ECLR);
181  m_treeECLgamma -> Branch("ECLTruth", & m_ECLTruth);
182  m_treeECLgamma -> Branch("ECLZ51", & m_ECLZ51);
183  m_treeECLgamma -> Branch("ECLZ40", & m_ECLZ40);
184  m_treeECLgamma -> Branch("ECLE1oE9", & m_ECLE1oE9);
185  m_treeECLgamma -> Branch("ECL2ndMom", & m_ECL2ndMom);
186  m_treeECLgamma -> Branch("ECLnumChrystals", & m_ECLnumChrystals);
187  m_treeECLgamma -> Branch("ECLLAT", & m_ECLLAT);
188  m_treeECLgamma -> Branch("ECLZMVA", & m_ECLZMVA);
189  m_treeECLgamma -> Branch("ECLKlId", & m_ECLKLid);
190  m_treeECLgamma -> Branch("ECLdeltaL", & m_ECLdeltaL);
191  m_treeECLgamma -> Branch("ECLmintrackDist", & m_ECLminTrkDistance);
192  m_treeECLgamma -> Branch("isBeamBKG", & m_isBeamBKG);
193  m_treeECLgamma -> Branch("ECLMCWeight", & m_ECLMCWeight);
194  m_treeECLgamma -> Branch("isSignal", & m_isSignal);
195  }//useECL
196 }//init
197 
198 
200 {
201 }
202 
204 {
205 }
206 
208 {
209  // Use the neutralHadron hypothesis for the ECL
211 
212  for (const KLMCluster& cluster : m_klmClusters) {
213 
214  if (!m_useKLM) {continue;}
215 
216  const TVector3& clusterPos = cluster.getClusterPosition();
217 
218  m_KLMPhi = clusterPos.Phi();
219  m_KLMTheta = clusterPos.Theta();
220 
221  m_KLMglobalZ = clusterPos.Z();
222  m_KLMnCluster = m_klmClusters.getEntries();
223  m_KLMnLayer = cluster.getLayers();
224  m_KLMnInnermostLayer = cluster.getInnermostLayer();
225  m_KLMtime = cluster.getTime();
226  m_KLMinvM = cluster.getMomentum().M2();
227  m_KLMenergy = cluster.getEnergy();
228  m_KLMhitDepth = cluster.getClusterPosition().Mag();
229  m_KLMtrackFlag = cluster.getAssociatedTrackFlag();
230  m_KLMeclFlag = cluster.getAssociatedEclClusterFlag();
231 
232  m_KLMTrackSepDist = -999;
233  m_KLMTrackSepAngle = -999;
237  auto trackSeperations = cluster.getRelationsTo<TrackClusterSeparation>();
238  TrackClusterSeparation* trackSep;
239  float best_dist = 100000000;
240  for (auto trackSeperation : trackSeperations) {
241  float dist = trackSeperation.getDistance();
242  if (dist < best_dist) {
243  best_dist = dist;
244  trackSep = &trackSeperation;
245  m_KLMTrackSepDist = trackSep->getDistance();
246  m_KLMTrackSepAngle = trackSep->getTrackClusterAngle();
247  m_KLMInitialTrackSepAngle = trackSep->getTrackClusterInitialSeparationAngle();
248  m_KLMTrackRotationAngle = trackSep->getTrackRotationAngle();
249  m_KLMTrackClusterSepAngle = trackSep->getTrackClusterSeparationAngle();
250  }
251  }
252 
253 
254  if (isnan(m_KLMglobalZ)) { m_KLMglobalZ = -999;}
255  if (isnan(m_KLMnCluster)) { m_KLMnCluster = -999;}
256  if (isnan(m_KLMnLayer)) { m_KLMnLayer = -999;}
257  if (isnan(m_KLMnInnermostLayer)) { m_KLMnInnermostLayer = -999;}
258  if (isnan(m_KLMtime)) { m_KLMtime = -999;}
259  if (isnan(m_KLMinvM)) { m_KLMinvM = -999;}
260  if (isnan(m_KLMenergy)) { m_KLMenergy = -999;}
261  if (isnan(m_KLMhitDepth)) { m_KLMhitDepth = -999;}
262  if (isnan(m_KLMTrackSepDist)) { m_KLMTrackSepDist = -999;}
263  if (isnan(m_KLMTrackSepAngle)) { m_KLMTrackSepAngle = -999;}
265  if (isnan(m_KLMTrackRotationAngle)) { m_KLMTrackRotationAngle = -999;}
267 
268  // findClosestECLCluster with the c_neutralHadron hypothesis
269  pair<ECLCluster*, double> closestECLAndDist = findClosestECLCluster(clusterPos, eclHypothesis);
270  ECLCluster* closestECLCluster = get<0>(closestECLAndDist);
271  m_KLMECLDist = get<1>(closestECLAndDist);
272 
273  if (!(closestECLCluster == nullptr)) {
274  m_KLMECLE = closestECLCluster->getEnergy(eclHypothesis);
275  m_KLMECLE9oE25 = closestECLCluster->getE9oE21();
276  m_KLMECLEerror = closestECLCluster->getUncertaintyEnergy();
277  m_KLMECLTerror = closestECLCluster->getDeltaTime99();
278  m_KLMECLdeltaL = closestECLCluster->getDeltaL();;
279  m_KLMECLminTrackDist = closestECLCluster->getMinTrkDistance();
280  m_KLMECLTiming = closestECLCluster->getTime();
281  m_KLMECLZMVA = closestECLCluster->getZernikeMVA();
282  m_KLMECLZ40 = closestECLCluster->getAbsZernike40();
283  m_KLMECLZ51 = closestECLCluster->getAbsZernike51();
284  m_KLMECLUncertaintyPhi = closestECLCluster->getUncertaintyPhi();
285  m_KLMECLUncertaintyTheta = closestECLCluster->getUncertaintyTheta();
286  m_KLMECLHypo = closestECLCluster->getHypotheses();
287  } else {
288  m_KLMECLdeltaL = -999;
289  m_KLMECLminTrackDist = -999;
290  m_KLMECLE = -999;
291  m_KLMECLE9oE25 = -999;
292  m_KLMECLTiming = -999;
293  m_KLMECLTerror = -999;
294  m_KLMECLEerror = -999;
295 
296  m_KLMECLHypo = -999;
297  m_KLMECLZMVA = -999;
298  m_KLMECLZ40 = -999;
299  m_KLMECLZ51 = -999;
300  m_KLMECLUncertaintyPhi = -999;
302  }
303 
304  tuple<const KLMCluster*, double, double> closestKLMAndDist = findClosestKLMCluster(clusterPos);
305  m_KLMnextCluster = get<1>(closestKLMAndDist);
306  m_KLMavInterClusterDist = get<2>(closestKLMAndDist);
307 
308  const auto mcParticleWeightPair = cluster.getRelatedToWithWeight<MCParticle>();
309  MCParticle* part = mcParticleWeightPair.first;
310 
313 
314  if (part) {
315  m_KLMMCWeight = mcParticleWeightPair.second;
316  m_KLMAngleToMC = clusterPos.Angle(part->getMomentum());
317  m_KLMMCStatus = part->getStatus();
318  m_KLMMCLifetime = part->getLifetime();
319  m_KLMMCPDG = std::abs(part->getPDG());
321  m_KLMMCMom = part->getMomentum().Mag();
322  m_KLMMCPhi = part->getMomentum().Phi();
323  m_KLMMCTheta = part->getMomentum().Theta();
324  } else {
325  m_KLMMCWeight = -999;
326  m_KLMAngleToMC = -999;
327  m_KLMMCStatus = -999;
328  m_KLMMCLifetime = -999;
329  m_KLMMCPDG = -999;
330  m_KLMMCPrimaryPDG = -999;
331  m_KLMMCMom = -999;
332  m_KLMMCPhi = -999;
333  m_KLMMCTheta = -999;
334  }
335 
336  KlId* klid = cluster.getRelatedTo<KlId>();
337  if (klid) {
338  m_KLMKLid = klid->getKlId();
339  } else {
340  m_KLMKLid = -999;
341  }
342  m_isSignal = isKLMClusterSignal(cluster, 0);
343 
344 
345  m_treeKLM -> Fill();
346  }// for klmcluster in klmclusters
347 
348 // --------------- ECL CLUSTERS
349  for (const ECLCluster& cluster : m_eclClusters) {
350 
351  if (!m_useECL or !cluster.hasHypothesis(eclHypothesis)) {continue;}
352 
353  m_ECLminTrkDistance = cluster.getMinTrkDistance();
354  m_ECLdeltaL = cluster.getDeltaL();
355  m_ECLE = cluster.getEnergy(eclHypothesis);
356  m_ECLE9oE25 = cluster.getE9oE21();
357  m_ECLTiming = cluster.getTime();
358  m_ECLR = cluster.getR();
359  m_ECLEerror = cluster.getUncertaintyEnergy();
360  m_ECLZ51 = cluster.getAbsZernike51();
361  m_ECLZ40 = cluster.getAbsZernike40();
362  m_ECLE1oE9 = cluster.getE1oE9();
363  m_ECL2ndMom = cluster.getSecondMoment();
364  m_ECLnumChrystals = cluster.getNumberOfCrystals();
365  m_ECLLAT = cluster.getLAT();
366  m_ECLZMVA = cluster.getZernikeMVA();
367 
368  if (isnan(m_ECLminTrkDistance)) { m_ECLminTrkDistance = -999;}
369  if (isnan(m_ECLdeltaL)) { m_ECLdeltaL = -999;}
370  if (isnan(m_ECLE)) { m_ECLE = -999;}
371  if (isnan(m_ECLE9oE25)) { m_ECLE9oE25 = -999;}
372  if (isnan(m_ECLTiming)) { m_ECLTiming = -999;}
373  if (isnan(m_ECLR)) { m_ECLR = -999;}
374  if (isnan(m_ECLEerror)) { m_ECLEerror = -999;}
375  if (isnan(m_ECLZ40)) { m_ECLZ40 = -999;}
376  if (isnan(m_ECLZ51)) { m_ECLZ51 = -999;}
377  if (isnan(m_ECLE1oE9)) { m_ECLE1oE9 = -999;}
378  if (isnan(m_ECL2ndMom)) { m_ECL2ndMom = -999;}
379  if (isnan(m_ECLnumChrystals)) { m_ECLnumChrystals = -999;}
380  if (isnan(m_ECLLAT)) { m_ECLLAT = -999;}
381  if (isnan(m_ECLZMVA)) { m_ECLZMVA = -999;}
382 
383  KlId* klid = cluster.getRelatedTo<KlId>();
384  if (klid) {
385  m_ECLKLid = klid->getKlId();
386  } else {
387  m_ECLKLid = -999;
388  }
389 
390  const TVector3& clusterPos = cluster.getClusterPosition();
391 
392  m_ECLPhi = clusterPos.Phi();
393  m_ECLTheta = clusterPos.Theta();
394  m_ECLZ = clusterPos.Z();
395 
396  ClusterUtils C;
397  m_ECLMom = C.Get4MomentumFromCluster(&cluster, eclHypothesis).Vect().Mag2();
398  m_ECLDeltaTime = cluster.getDeltaTime99();
399 
400  m_ECLUncertaintyEnergy = cluster.getUncertaintyEnergy();
401  m_ECLUncertaintyTheta = cluster.getUncertaintyTheta();
402  m_ECLUncertaintyPhi = cluster.getUncertaintyPhi();
403 
404 // MCParticle* part = cluster.getRelatedTo<MCParticle>();
405  const auto mcParticleWeightPair = cluster.getRelatedToWithWeight<MCParticle>();
406  MCParticle* part = mcParticleWeightPair.first;
407 
410  if (part) {
411  m_ECLMCWeight = mcParticleWeightPair.second;
412  m_ECLMCStatus = part->getStatus();
413  m_ECLMCLifetime = part->getLifetime();
414  m_ECLMCPDG = std::abs(part->getPDG());
415 
417 
418  m_ECLMCMom = part->getMomentum().Mag2();
419  m_ECLMCPhi = part->getMomentum().Phi();
420  m_ECLMCTheta = part->getMomentum().Theta();
421  } else {
422  m_ECLMCWeight = -999;
423  m_ECLMCStatus = -999;
424  m_ECLMCLifetime = -999;
425  m_ECLMCPrimaryPDG = -999;
426  m_ECLMCPDG = -999;
427  m_ECLMCMom = -999;
428  m_ECLMCPhi = -999;
429  m_ECLMCTheta = -999;
430  }
431 
432  m_isSignal = isECLClusterSignal(cluster);
433 
434  if (cluster.hasHypothesis(ECLCluster::EHypothesisBit::c_neutralHadron)) { m_treeECLhadron -> Fill();}
435  if (cluster.hasHypothesis(ECLCluster::EHypothesisBit::c_nPhotons)) { m_treeECLgamma -> Fill();}
436  }// for ecl cluster in clusters
437 } // event
438 
439 
441 {
442  // close root files
443  m_f -> cd();
444  if (m_useKLM) { m_treeKLM -> Write();}
445  if (m_useECL) {
446  m_treeECLhadron -> Write();
447  m_treeECLgamma -> Write();
448  }
449  m_f -> Close();
450 }
451 
Class to provide momentum-related information from ECLClusters.
Definition: ClusterUtils.h:34
const TLorentzVector Get4MomentumFromCluster(const ECLCluster *cluster, ECLCluster::EHypothesisBit hypo)
Returns four momentum vector.
Definition: ClusterUtils.cc:24
Float_t m_KLMnLayer
number of layers hit in KLM cluster
bool m_useKLM
write out KLM data
Float_t m_ECLnumChrystals
number of crystals in the cluster
Float_t m_KLMInitialTrackSepAngle
angular distance from track to cluster at track starting point
Float_t m_KLMTrackSepDist
distance from track separation object
Float_t m_KLMnCluster
varibales to write out.
Float_t m_KLMMCPhi
phi of matched mc particle
Float_t m_ECLMCLifetime
MC particles lifetime.
Float_t m_ECLE1oE9
central crystal devided by 3x3 area with it in its center
Float_t m_KLMTheta
measured theta
Float_t m_KLMECLdeltaL
distance between track entry point and cluster center, might be removed
Float_t m_KLMTrackSepAngle
angular distance from track separation object
Float_t m_ECLMCPrimaryPDG
pdg code of higher order MC particle, a cluster related to a photon that originates from a pi0 decay ...
StoreArray< KLMCluster > m_klmClusters
Store array
Float_t m_KLMECLminTrackDist
track distance between associated ECL cluster and track extrapolated into ECL
Float_t m_ECLE9oE25
energy of 9/25 chrystall rings (E dispersion shape)
virtual void initialize() override
init
Float_t m_KLMMCLifetime
MC partilces life time.
std::string m_outPath
Output path variable.
Float_t m_ECLLAT
lateral shower shape
virtual void event() override
process event
Float_t m_KLMMom
measured momentum
Float_t m_KLMECLZ51
zernike moment 5,1 of closest ECL cluster
Float_t m_ECLdeltaL
distance between track entrace into cluster and cluster center
Float_t m_KLMMCPDG
pdg code of matched MCparticle
Float_t m_ECLminTrkDistance
more sophisticated distaqnce to track in ECL
Float_t m_ECLMCPDG
pdg code of the MCparticle directly related to the cluster
Float_t m_ECLMCWeight
mc weight
Float_t m_ECLKLid
classifier output
Float_t m_KLMTrackRotationAngle
angle between track at poca and trackbeginning
Float_t m_ECLEerror
uncertainty on E measurement in ECL
Float_t m_ECLR
distance of cluster to IP
Float_t m_ECLMom
measured momentum
Float_t m_ECLMCPhi
MC particle phi; -999 if not MCparticle
virtual void endRun() override
end run
Float_t m_KLMTruth
target variable for KLM classification
Float_t m_KLMAngleToMC
angle between KLMcluster and Mcparticle
Float_t m_KLMECLE9oE25
E in surrounding 9 crystals divided by surrounding 25 crydtalls.
Float_t m_ECLMCStatus
mc status, seen in detector etc.
Float_t m_ECLE
measured energy
Float_t m_KLMECLZMVA
zernike mva output for closest ECL cluster (based on around 10 z-moments)
virtual void terminate() override
terminate
TTree * m_treeECLhadron
tree containing ntuples for ECL cluster with N2 (hadron hypothesis)
Float_t m_KLMtrackToECL
primitive distance cluster <-> track for associated ECL cluster
Float_t m_ECLZ40
Zernike moment 4,0 see Belle2 note on that.
Float_t m_ECLZ
measured Z-coordinate
Float_t m_ECLUncertaintyPhi
measured uncertainty of phi
Float_t m_ECL2ndMom
second moment, shower shape
Float_t m_KLMECLUncertaintyTheta
theta uncertainty of closest ECL cluster
Float_t m_ECLZMVA
output of a BDT that was fitted on some Zernike Moments on a connected region
TTree * m_treeECLgamma
tree containing ntuples for ECL cluster with N1 (photon hypothesis)
bool m_useECL
write out KLM data
Float_t m_KLMMCStatus
MC particles status.
virtual void beginRun() override
beginn run
Float_t m_isBeamBKG
is beam bkg
Float_t m_KLMMCTheta
theta of matched mc particle
Float_t m_ECLTiming
timing of ECL
Float_t m_KLMMCWeight
mc weight
Float_t m_KLMECLTiming
timing of associated ECL cluster
Float_t m_KLMECLDist
distance associated ECL <-> KLM cluster
Float_t m_KLMglobalZ
global Z position in KLM
StoreArray< ECLCluster > m_eclClusters
Store array
Float_t m_isSignal
isSignal for the classifier
Float_t m_KLMnInnermostLayer
number of innermost layers hit
Float_t m_ECLTruth
ECL trarget variable.
Float_t m_KLMtime
timing of KLM Cluster
Float_t m_KLMECLTerror
uncertainty on time in associated ECL cluster
Float_t m_KLMinvM
invariant mass calculated from root vector
Float_t m_KLMnextCluster
distance to next KLM cluster
Float_t m_ECLUncertaintyEnergy
measured energy uncertainty
Float_t m_ECLTheta
measured theta
Float_t m_ECLUncertaintyTheta
measured uncertainty on theta
Float_t m_KLMECLHypo
hypotheis id of closest ecl cluster 5: gamma, 6:hadron
StoreArray< MCParticle > m_mcParticles
Store array
TTree * m_treeKLM
tree for klm data
Float_t m_ECLDeltaTime
KlId for that object.
Float_t m_ECLPhi
measured phi
Float_t m_KLMhitDepth
hit depth in KLM, distance to IP
Float_t m_ECLZ51
Zernike moment 5,1 see Belle2 note on that.
Float_t m_KLMTrackClusterSepAngle
angle between trach momentum and cluster (measured from ip)
Float_t m_KLMPhi
measured phi
virtual ~DataWriterModule()
Destructor.
Float_t m_ECLMCMom
MC particle momentum; -999 if not MCparticle.
Float_t m_KLMavInterClusterDist
average distance between all KLM clusters
Float_t m_KLMECLEerror
uncertainty on E in associated ECL cluster
Float_t m_KLMMCMom
momentum of matched mc particle
Float_t m_KLMKLid
KlId for that object.
Float_t m_KLMenergy
Energy deposit in KLM (0.2 GeV * nHitCells)
Float_t m_KLMMCPrimaryPDG
pdg code of MCparticles mother, for example pi0 for some gammas
Float_t m_KLMECLZ40
zernike moment 4,0 of closest ecl cluster
Float_t m_KLMeclFlag
ecl flag for belle comparision
Float_t m_KLMECLUncertaintyPhi
phi uncertainty oof closeest ecl cluster
Float_t m_KLMECLE
energy measured in associated ECL cluster
Float_t m_ECLMCTheta
MC particle momentum; -999 if not MCparticle.
Float_t m_KLMtrackFlag
track flag for belle comparision
ECL cluster data.
Definition: ECLCluster.h:27
double getDeltaL() const
Return deltaL.
Definition: ECLCluster.h:262
double getUncertaintyTheta() const
Return Uncertainty on Theta of Shower.
Definition: ECLCluster.h:322
double getE9oE21() const
Return E9/E21 (shower shape variable).
Definition: ECLCluster.h:277
double getEnergy(EHypothesisBit hypothesis) const
Return Energy (GeV).
Definition: ECLCluster.cc:19
double getUncertaintyEnergy() const
Return Uncertainty on Energy of Shower.
Definition: ECLCluster.h:319
double getMinTrkDistance() const
Get distance between cluster COG and track extrapolation to ECL.
Definition: ECLCluster.h:256
double getZernikeMVA() const
Return MVA based hadron/photon value based on Zernike moments (shower shape variable).
Definition: ECLCluster.h:271
double getUncertaintyPhi() const
Return Uncertainty on Phi of Shower.
Definition: ECLCluster.h:325
double getAbsZernike40() const
Return Zernike moment 40 (shower shape variable).
Definition: ECLCluster.h:265
unsigned short getHypotheses() const
Return hypothesis (expert only, this returns a bti pattern).
Definition: ECLCluster.h:244
double getDeltaTime99() const
Return cluster delta time 99.
Definition: ECLCluster.h:298
double getTime() const
Return cluster time.
Definition: ECLCluster.h:295
EHypothesisBit
The hypothesis bits for this ECLCluster (Connected region (CR) is split using this hypothesis.
Definition: ECLCluster.h:31
@ c_nPhotons
CR is split into n photons (N1)
@ c_neutralHadron
CR is reconstructed as a neutral hadron (N2)
double getAbsZernike51() const
Return Zernike moment 51 (shower shape variable).
Definition: ECLCluster.h:268
KLM cluster data.
Definition: KLMCluster.h:28
Klong identifcation (KlId) datastore object to store results from KlId calculations.
Definition: KlId.h:23
double getKlId() const
get the klong classifier output
Definition: KlId.cc:27
A Class to store the Monte Carlo particle information.
Definition: MCParticle.h:32
Base class for Modules.
Definition: Module.h:72
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
Store one Track-KLMCluster separation as a ROOT object.
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition: Module.h:560
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
Helper functions for all klid modules to improve readability of the code.
Definition: KlId.h:25
int mcParticleIsBeamBKG(Belle2::MCParticle *part)
return if MCparticle is beambkg
Definition: KlId.h:64
bool isKLMClusterSignal(const Belle2::KLMCluster &cluster, float mcWeigthCut=0.66)
checks if a cluster is signal under the mcWeightcondition (mcWeight = energy deposition)
Definition: KlId.h:96
bool isECLClusterSignal(const Belle2::ECLCluster &cluster, float mcWeigthCut=0.66)
checks if a cluster is signal under the mcWeightcondition (mcWeight = energy deposition)
Definition: KlId.h:110
int getPrimaryPDG(Belle2::MCParticle *part)
return if mc particles primary pdg.
Definition: KlId.h:147
std::tuple< const Belle2::KLMCluster *, double, double > findClosestKLMCluster(const TVector3 &klmClusterPosition)
find nearest KLMCluster, tis distance and the av intercluster distance
Definition: KlId.h:231
int mcParticleIsKlong(Belle2::MCParticle *part)
return the mc hirachy of the klong 0:not a klong 1:final particle, 2: klong is mother etc
Definition: KlId.h:74
std::pair< Belle2::ECLCluster *, double > findClosestECLCluster(const TVector3 &klmClusterPosition, const Belle2::ECLCluster::EHypothesisBit eclhypothesis=Belle2::ECLCluster::EHypothesisBit::c_neutralHadron)
Find the closest ECLCluster with a neutral hadron hypothesis, and return it with its distance.
Definition: KlId.h:199
Abstract base class for different kinds of events.