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