Belle II Software  release-05-01-25
ECLCalDigitVariables.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2019 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Torben Ferber *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 // analysis
12 #include <analysis/VariableManager/Manager.h>
13 
14 // framework
15 #include <framework/core/Module.h>
16 #include <framework/datastore/StoreObjPtr.h>
17 #include <framework/datastore/StoreArray.h>
18 
19 // dataobjects
20 #include <mdst/dataobjects/ECLCluster.h>
21 #include <mdst/dataobjects/Track.h>
22 #include <mdst/dataobjects/MCParticle.h>
23 
24 #include <analysis/dataobjects/Particle.h>
25 #include <ecl/dataobjects/ECLCalDigit.h>
26 #include <ecl/dataobjects/ECLShower.h>
27 #include <ecl/dataobjects/ECLCellIdMapping.h>
28 #include <tracking/dataobjects/ExtHit.h>
29 
30 #include <ecl/dataobjects/ECLDsp.h>
31 
32 using namespace std;
33 
34 namespace Belle2 {
40  namespace ECLCalDigitVariable {
41 
42  // enum with available data types
43  enum varType {
44  energy = 1,
45  time = 2,
46  timeResolution = 3,
47  twoComponentChi2 = 10,
48  twoComponentTotalEnergy = 11,
49  twoComponentHadronEnergy = 12,
50  twoComponentDiodeEnergy = 13,
51  twoComponentSavedChi2_PhotonHadron = 14,
52  twoComponentSavedChi2_PileUpPhoton = 15,
53  twoComponentSavedChi2_PhotonDiode = 16,
54  twoComponentFitType = 17,
55  weight = 18,
56  phi = 20,
57  theta = 21,
58  phiId = 22,
59  thetaId = 23,
60  cellId = 24,
61  mcenergy = 25,
62  usedforenergy = 26
63  };
64 
65  // enum with available center types
66  enum centerType {
67  maxCell = 0,
68  extCell = 1
69  };
70 
71 
73  int getCenterCell(const Particle* particle)
74  {
75  // get maximum cell id for this cluster (ignore weights)
76  const ECLCluster* cluster = particle->getECLCluster();
77  if (cluster) {
78  int maxCellId = -1;
79  double maxEnergy = -1.;
80 
81  auto clusterDigitRelations = cluster->getRelationsTo<ECLCalDigit>();
82  for (unsigned int ir = 0; ir < clusterDigitRelations.size(); ++ir) {
83  const auto calDigit = clusterDigitRelations.object(ir);
84 
85  if (calDigit->getEnergy() > maxEnergy) {
86  maxEnergy = calDigit->getEnergy();
87  maxCellId = calDigit->getCellId();
88  }
89  }
90 
91  return maxCellId;
92  }
93 
94  return -1;
95  }
96 
98  int getExtCell(const Particle* particle)
99  {
100  Const::EDetector myDetID = Const::EDetector::ECL;
101  Const::ChargedStable hypothesis = Const::pion;
102  int pdgCode = abs(hypothesis.getPDGCode());
103 
104  const Track* track = particle->getTrack();
105  if (track) {
106  for (const auto& extHit : track->getRelationsTo<ExtHit>()) {
107  if (abs(extHit.getPdgCode()) != pdgCode) continue;
108  if ((extHit.getDetectorID() != myDetID)) continue;
109  if (extHit.getStatus() != EXT_ENTER) continue;
110 
111  int copyid = extHit.getCopyID();
112 
113  if (copyid == -1) continue;
114  const int cellid = copyid + 1;
115  return cellid;
116  }
117  }
118 
119  return -1;
120  }
121 
123  double getCalDigitExpertByEnergyRank(const Particle* particle, const std::vector<double>& vars)
124  {
125 
126  if (vars.size() != 2) {
127  B2FATAL("Need exactly two parameters (energy rank, variable id).");
128  }
129 
130  if (int(std::lround(vars[0])) < 0) B2FATAL("Index cannot be negative.");
131 
132  const unsigned int indexIn = int(std::lround(vars[0]));
133 
134  const int varid = int(std::lround(vars[1]));
135 
136  //EnergyToSort vector is used for sorting digits by digit energy measured by FPGAs
137  std::vector<std::tuple<double, unsigned int>> energyToSort;
138 
139  const ECLCluster* cluster = particle->getECLCluster();
140 
141  if (cluster) {
142 
143  auto relatedDigits = cluster->getRelationsTo<ECLCalDigit>();
144 
145  if (indexIn < relatedDigits.size()) {
146 
147  for (unsigned int iRel = 0; iRel < relatedDigits.size(); iRel++) {
148 
149  const auto caldigit = relatedDigits.object(iRel);
150 
151  energyToSort.emplace_back(caldigit->getEnergy(), iRel);
152 
153  }
154 
155  } else {
156  return std::numeric_limits<double>::quiet_NaN();
157  }
158 
159  std::sort(energyToSort.begin(), energyToSort.end(), std::greater<>());
160 
161  const auto [digitEnergy, caldigitIndex] = energyToSort[indexIn];
162 
163  const auto caldigitSelected = relatedDigits.object(caldigitIndex);
164 
165  if (varid == varType::energy) {
166  return caldigitSelected->getEnergy();
167  } else if (varid == varType::time) {
168  return caldigitSelected->getTime();
169  } else if (varid == varType::twoComponentChi2) {
170  return caldigitSelected->getTwoComponentChi2();
171  } else if (varid == varType::twoComponentTotalEnergy) {
172  return caldigitSelected->getTwoComponentTotalEnergy();
173  } else if (varid == varType::twoComponentHadronEnergy) {
174  return caldigitSelected->getTwoComponentHadronEnergy();
175  } else if (varid == varType::twoComponentSavedChi2_PhotonHadron) {
176  return caldigitSelected->getTwoComponentSavedChi2(ECLDsp::photonHadron);
177  } else if (varid == varType::twoComponentSavedChi2_PileUpPhoton) {
178  return caldigitSelected->getTwoComponentSavedChi2(ECLDsp::photonHadronBackgroundPhoton);
179  } else if (varid == varType::twoComponentSavedChi2_PhotonDiode) {
180  return caldigitSelected->getTwoComponentSavedChi2(ECLDsp::photonDiodeCrossing);
181  } else if (varid == varType::twoComponentDiodeEnergy) {
182  return caldigitSelected->getTwoComponentDiodeEnergy();
183  } else if (varid == varType::twoComponentFitType) {
184  return int(caldigitSelected->getTwoComponentFitType());
185  } else if (varid == varType::cellId) {
186  return caldigitSelected->getCellId();
187  } else if (varid == varType::weight) {
188  const auto weight = relatedDigits.weight(caldigitIndex);
189  return weight;
190  } else {
191  B2FATAL("variable id not found.");
192  }
193 
194  }
195 
196  return std::numeric_limits<double>::quiet_NaN();
197 
198  }
199 
201  double getCalDigitExpert(const Particle* particle, const std::vector<double>& vars)
202  {
203  if (vars.size() != 4) {
204  B2FATAL("Need exactly four parameters (cellid, neighbour area size, variable id, and cluster center (0) or ext (1)).");
205  }
206 
207  StoreObjPtr<ECLCellIdMapping> mapping;
208  const unsigned int posid = int(std::lround(vars[0]));
209  const int nneighbours = int(std::lround(vars[1]));
210  const int varid = int(std::lround(vars[2]));
211  const int extid = int(std::lround(vars[3]));
212 
213  if (!mapping) {
214  B2ERROR("Mapping not found, did you forget to run the eclFillCellIdMapping module?");
215  return std::numeric_limits<double>::quiet_NaN();
216  }
217  if (nneighbours != 5 and nneighbours != 7) {
218  B2FATAL("Please request 5 or 7 neighbour area.");
219  return std::numeric_limits<double>::quiet_NaN();
220  }
221 
222  // get maximum cell id for this cluster (ignore weights)
223  // TODO: if eclshowers exist we could skip that step.
224  int maxCellId = -1;
225  if (extid == centerType::extCell) {
226  maxCellId = getExtCell(particle);
227  } else {
228  maxCellId = getCenterCell(particle);
229  }
230 
231 
232  if (maxCellId < 0) return std::numeric_limits<double>::quiet_NaN();
233 
234  // get the requested neighbourid
235  int neighbourid = -1;
236  std::vector<short int> neighbours;
237 
238  if (nneighbours == 5) {
239  neighbours = mapping->getCellIdToNeighbour5(maxCellId);
240  } else if (nneighbours == 7) {
241  neighbours = mapping->getCellIdToNeighbour7(maxCellId);
242  }
243 
244  if (posid < neighbours.size()) {
245  neighbourid = neighbours[posid];
246  } else {
247  B2WARNING("This position id is not contained in the requested neighbours.");
248  return std::numeric_limits<double>::quiet_NaN();
249  }
250 
251  // some variables can be returned even if no ECLCalDigit is present
252  if (varid == varType::phi) {
253  return mapping->getCellIdToPhi(neighbourid);
254  } else if (varid == varType::theta) {
255  return mapping->getCellIdToTheta(neighbourid);
256  } else if (varid == varType::phiId) {
257  return mapping->getCellIdToPhiId(neighbourid);
258  } else if (varid == varType::thetaId) {
259  return mapping->getCellIdToThetaId(neighbourid);
260  } else if (varid == varType::cellId) {
261  return neighbourid;
262  }
263  //... and some really need a ECLCalDigit being present
264  else {
265  const int storearraypos = mapping->getCellIdToStoreArray(neighbourid);
266  StoreArray<ECLCalDigit> eclCalDigits;
267 
268  if (storearraypos >= 0) {
269  if (varid == varType::energy) {
270  return eclCalDigits[storearraypos]->getEnergy();
271  } else if (varid == varType::time) {
272  return eclCalDigits[storearraypos]->getTime();
273  } else if (varid == varType::timeResolution) {
274  return eclCalDigits[storearraypos]->getTimeResolution();
275  } else if (varid == varType::twoComponentChi2) {
276  return eclCalDigits[storearraypos]->getTwoComponentChi2();
277  } else if (varid == varType::twoComponentTotalEnergy) {
278  return eclCalDigits[storearraypos]->getTwoComponentTotalEnergy();
279  } else if (varid == varType::twoComponentHadronEnergy) {
280  return eclCalDigits[storearraypos]->getTwoComponentHadronEnergy();
281  } else if (varid == varType::twoComponentSavedChi2_PhotonHadron) {
282  return eclCalDigits[storearraypos]->getTwoComponentSavedChi2(ECLDsp::photonHadron);
283  } else if (varid == varType::twoComponentSavedChi2_PileUpPhoton) {
284  return eclCalDigits[storearraypos]->getTwoComponentSavedChi2(ECLDsp::photonHadronBackgroundPhoton);
285  } else if (varid == varType::twoComponentSavedChi2_PhotonDiode) {
286  return eclCalDigits[storearraypos]->getTwoComponentSavedChi2(ECLDsp::photonDiodeCrossing);
287  } else if (varid == varType::twoComponentDiodeEnergy) {
288  return eclCalDigits[storearraypos]->getTwoComponentDiodeEnergy();
289  } else if (varid == varType::twoComponentFitType) {
290  return int(eclCalDigits[storearraypos]->getTwoComponentFitType());
291  } else if (varid == varType::mcenergy) {
292  // loop over all related MCParticles
293  auto digitMCRelations = eclCalDigits[storearraypos]->getRelationsTo<MCParticle>();
294  double edep = 0.0;
295  for (unsigned int i = 0; i < digitMCRelations.size(); ++i) {
296  edep += digitMCRelations.weight(i);
297  }
298  return edep;
299  } else if (varid == varType::usedforenergy) {
300  const ECLCluster* cluster = particle->getECLCluster();
301  if (cluster) {
302  unsigned int cellid = eclCalDigits[storearraypos]->getCellId();
303 
304  std::vector<unsigned int> listCellIds;
305  auto clusterShowerRelations = cluster->getRelationsWith<ECLShower>(); // should never happen to have more than one shower
306  for (unsigned int ir = 0; ir < clusterShowerRelations.size(); ++ir) {
307  const auto shower = clusterShowerRelations.object(ir);
308  listCellIds = shower->getListOfCrystalsForEnergy();
309  }
310 
311  if (std::find(listCellIds.begin(), listCellIds.end(), cellid) != listCellIds.end()) { //find is faster than count
312  return 1;
313  }
314 
315  return 0;
316  }
317  return std::numeric_limits<double>::quiet_NaN();
318 
319  }
320  } else {
321  return std::numeric_limits<double>::quiet_NaN();
322  }
323  }
324 
325  return std::numeric_limits<double>::quiet_NaN();
326  }
327 
328  }
329 
330  namespace Variable {
331 
333  double getECLCalDigitEnergyByEnergyRank(const Particle* particle, const std::vector<double>& vars)
334  {
335  if (vars.size() != 1) {
336  B2FATAL("Need exactly one parameters (energy index).");
337  }
338  std::vector<double> parameters {vars[0], ECLCalDigitVariable::varType::energy};
339  return ECLCalDigitVariable::getCalDigitExpertByEnergyRank(particle, parameters);
340  }
341 
343  double getECLCalDigitTimeByEnergyRank(const Particle* particle, const std::vector<double>& vars)
344  {
345  if (vars.size() != 1) {
346  B2FATAL("Need exactly one parameters (energy index).");
347  }
348  std::vector<double> parameters {vars[0], ECLCalDigitVariable::varType::time};
349  return ECLCalDigitVariable::getCalDigitExpertByEnergyRank(particle, parameters);
350  }
351 
353  double getCellIdByEnergyRank(const Particle* particle, const std::vector<double>& vars)
354  {
355  if (vars.size() != 1) {
356  B2FATAL("Need exactly one parameters (energy index).");
357  }
358  std::vector<double> parameters {vars[0], ECLCalDigitVariable::varType::cellId};
359  return ECLCalDigitVariable::getCalDigitExpertByEnergyRank(particle, parameters);
360  }
361 
363  double getTwoComponentFitTypeByEnergyRank(const Particle* particle, const std::vector<double>& vars)
364  {
365  if (vars.size() != 1) {
366  B2FATAL("Need exactly one parameters (energy index).");
367  }
368  std::vector<double> parameters {vars[0], ECLCalDigitVariable::varType::twoComponentFitType};
369  return ECLCalDigitVariable::getCalDigitExpertByEnergyRank(particle, parameters);
370  }
371 
373  double getTwoComponentChi2ByEnergyRank(const Particle* particle, const std::vector<double>& vars)
374  {
375  if (vars.size() != 1) {
376  B2FATAL("Need exactly one parameters (energy index).");
377  }
378  std::vector<double> parameters {vars[0], ECLCalDigitVariable::varType::twoComponentChi2};
379  return ECLCalDigitVariable::getCalDigitExpertByEnergyRank(particle, parameters);
380  }
381 
383  double getTwoComponentTotalEnergyByEnergyRank(const Particle* particle, const std::vector<double>& vars)
384  {
385  if (vars.size() != 1) {
386  B2FATAL("Need exactly one parameters (energy index).");
387  }
388  std::vector<double> parameters {vars[0], ECLCalDigitVariable::varType::twoComponentTotalEnergy};
389  return ECLCalDigitVariable::getCalDigitExpertByEnergyRank(particle, parameters);
390  }
391 
393  double getTwoComponentHadronEnergyByEnergyRank(const Particle* particle, const std::vector<double>& vars)
394  {
395  if (vars.size() != 1) {
396  B2FATAL("Need exactly one parameters (energy index).");
397  }
398  std::vector<double> parameters {vars[0], ECLCalDigitVariable::varType::twoComponentHadronEnergy};
399  return ECLCalDigitVariable::getCalDigitExpertByEnergyRank(particle, parameters);
400  }
401 
403  double getTwoComponentDiodeEnergyByEnergyRank(const Particle* particle, const std::vector<double>& vars)
404  {
405  if (vars.size() != 1) {
406  B2FATAL("Need exactly one parameters (energy index).");
407  }
408  std::vector<double> parameters {vars[0], ECLCalDigitVariable::varType::twoComponentDiodeEnergy};
409  return ECLCalDigitVariable::getCalDigitExpertByEnergyRank(particle, parameters);
410  }
411 
413  double getTwoComponentChi2SavedByEnergyRank_PhotonHadron(const Particle* particle, const std::vector<double>& vars)
414  {
415  if (vars.size() != 1) {
416  B2FATAL("Need exactly one parameters (energy index).");
417  }
418  std::vector<double> parameters {vars[0], ECLCalDigitVariable::varType::twoComponentSavedChi2_PhotonHadron};
419  return ECLCalDigitVariable::getCalDigitExpertByEnergyRank(particle, parameters);
420  }
421 
423  double getTwoComponentChi2SavedByEnergyRank_PileUpPhoton(const Particle* particle, const std::vector<double>& vars)
424  {
425  if (vars.size() != 1) {
426  B2FATAL("Need exactly one parameters (energy index).");
427  }
428  std::vector<double> parameters {vars[0], ECLCalDigitVariable::varType::twoComponentSavedChi2_PileUpPhoton};
429  return ECLCalDigitVariable::getCalDigitExpertByEnergyRank(particle, parameters);
430  }
431 
433  double getTwoComponentChi2SavedByEnergyRank_PhotonDiode(const Particle* particle, const std::vector<double>& vars)
434  {
435  if (vars.size() != 1) {
436  B2FATAL("Need exactly one parameters (energy index).");
437  }
438  std::vector<double> parameters {vars[0], ECLCalDigitVariable::varType::twoComponentSavedChi2_PhotonDiode};
439  return ECLCalDigitVariable::getCalDigitExpertByEnergyRank(particle, parameters);
440  }
441 
443  double getWeightByEnergyRank(const Particle* particle, const std::vector<double>& vars)
444  {
445  if (vars.size() != 1) {
446  B2FATAL("Need exactly one parameters (energy index).");
447  }
448  std::vector<double> parameters {vars[0], ECLCalDigitVariable::varType::weight};
449  return ECLCalDigitVariable::getCalDigitExpertByEnergyRank(particle, parameters);
450  }
451 
453  double getECLCalDigitEnergy(const Particle* particle, const std::vector<double>& vars)
454  {
455  if (vars.size() != 2) {
456  B2FATAL("Need exactly two parameters (cellid and neighbour area size).");
457  }
458 
459  std::vector<double> parameters {vars[0], vars[1], ECLCalDigitVariable::varType::energy, ECLCalDigitVariable::centerType::maxCell};
460  return ECLCalDigitVariable::getCalDigitExpert(particle, parameters);
461  }
462 
464  double getMCEnergy(const Particle* particle, const std::vector<double>& vars)
465  {
466  if (vars.size() != 2) {
467  B2FATAL("Need exactly two parameters (cellid and neighbour area size).");
468  }
469 
470  std::vector<double> parameters {vars[0], vars[1], ECLCalDigitVariable::varType::mcenergy, ECLCalDigitVariable::centerType::maxCell};
471  return ECLCalDigitVariable::getCalDigitExpert(particle, parameters);
472  }
473 
474 
476  double getExtECLCalDigitEnergy(const Particle* particle, const std::vector<double>& vars)
477  {
478  if (vars.size() != 2) {
479  B2FATAL("Need exactly two parameters (cellid and neighbour area size).");
480  }
481 
482  std::vector<double> parameters {vars[0], vars[1], ECLCalDigitVariable::varType::energy, ECLCalDigitVariable::centerType::extCell};
483  return ECLCalDigitVariable::getCalDigitExpert(particle, parameters);
484  }
485 
486 
488  double getECLCalDigitTime(const Particle* particle, const std::vector<double>& vars)
489  {
490  if (vars.size() != 2) {
491  B2FATAL("Need exactly two parameters (cellid and neighbour area size).");
492  }
493 
494  std::vector<double> parameters {vars[0], vars[1], ECLCalDigitVariable::varType::time, ECLCalDigitVariable::centerType::maxCell};
495  return ECLCalDigitVariable::getCalDigitExpert(particle, parameters);
496  }
497 
499  double getExtECLCalDigitTime(const Particle* particle, const std::vector<double>& vars)
500  {
501  if (vars.size() != 2) {
502  B2FATAL("Need exactly two parameters (cellid and neighbour area size).");
503  }
504 
505  std::vector<double> parameters {vars[0], vars[1], ECLCalDigitVariable::varType::time, ECLCalDigitVariable::centerType::extCell};
506  return ECLCalDigitVariable::getCalDigitExpert(particle, parameters);
507  }
508 
510  double getExtECLCalDigitTimeResolution(const Particle* particle, const std::vector<double>& vars)
511  {
512  if (vars.size() != 2) {
513  B2FATAL("Need exactly two parameters (cellid and neighbour area size).");
514  }
515 
516  std::vector<double> parameters {vars[0], vars[1], ECLCalDigitVariable::varType::timeResolution, ECLCalDigitVariable::centerType::extCell};
517  return ECLCalDigitVariable::getCalDigitExpert(particle, parameters);
518  }
519 
521  double getECLCalDigitTimeResolution(const Particle* particle, const std::vector<double>& vars)
522  {
523  if (vars.size() != 2) {
524  B2FATAL("Need exactly two parameters (cellid and neighbour area size).");
525  }
526 
527  std::vector<double> parameters {vars[0], vars[1], ECLCalDigitVariable::varType::timeResolution, ECLCalDigitVariable::centerType::maxCell};
528  return ECLCalDigitVariable::getCalDigitExpert(particle, parameters);
529  }
530 
532  double getTwoComponentChi2(const Particle* particle, const std::vector<double>& vars)
533  {
534  if (vars.size() != 2) {
535  B2FATAL("Need exactly two parameters (cellid and neighbour area size).");
536  }
537 
538  std::vector<double> parameters {vars[0], vars[1], ECLCalDigitVariable::varType::twoComponentChi2, ECLCalDigitVariable::centerType::maxCell};
539  return ECLCalDigitVariable::getCalDigitExpert(particle, parameters);
540  }
541 
543  double getExtECLCalDigitTwoComponentChi2(const Particle* particle, const std::vector<double>& vars)
544  {
545  if (vars.size() != 2) {
546  B2FATAL("Need exactly two parameters (cellid and neighbour area size).");
547  }
548 
549  std::vector<double> parameters {vars[0], vars[1], ECLCalDigitVariable::varType::twoComponentChi2, ECLCalDigitVariable::centerType::extCell};
550  return ECLCalDigitVariable::getCalDigitExpert(particle, parameters);
551  }
552 
554  double getTwoComponentTotalEnergy(const Particle* particle, const std::vector<double>& vars)
555  {
556  if (vars.size() != 2) {
557  B2FATAL("Need exactly two parameters (cellid and neighbour area size).");
558  }
559 
560  std::vector<double> parameters {vars[0], vars[1], ECLCalDigitVariable::varType::twoComponentTotalEnergy, ECLCalDigitVariable::centerType::maxCell};
561  return ECLCalDigitVariable::getCalDigitExpert(particle, parameters);
562  }
563 
565  double getExtECLCalDigitTwoComponentTotalEnergy(const Particle* particle, const std::vector<double>& vars)
566  {
567  if (vars.size() != 2) {
568  B2FATAL("Need exactly two parameters (cellid and neighbour area size).");
569  }
570 
571  std::vector<double> parameters {vars[0], vars[1], ECLCalDigitVariable::varType::twoComponentTotalEnergy, ECLCalDigitVariable::centerType::extCell};
572  return ECLCalDigitVariable::getCalDigitExpert(particle, parameters);
573  }
574 
576  double getTwoComponentHadronEnergy(const Particle* particle, const std::vector<double>& vars)
577  {
578  if (vars.size() != 2) {
579  B2FATAL("Need exactly two parameters (cellid and neighbour area size).");
580  }
581 
582  std::vector<double> parameters {vars[0], vars[1], ECLCalDigitVariable::varType::twoComponentHadronEnergy, ECLCalDigitVariable::centerType::maxCell};
583  return ECLCalDigitVariable::getCalDigitExpert(particle, parameters);
584  }
585 
587  double getUsedForClusterEnergy(const Particle* particle, const std::vector<double>& vars)
588  {
589  if (vars.size() != 2) {
590  B2FATAL("Need exactly two parameters (cellid and neighbour area size).");
591  }
592 
593  std::vector<double> parameters {vars[0], vars[1], ECLCalDigitVariable::varType::usedforenergy, ECLCalDigitVariable::centerType::maxCell};
594  return ECLCalDigitVariable::getCalDigitExpert(particle, parameters);
595  }
596 
598  double getExtECLCalDigitTwoComponentHadronEnergy(const Particle* particle, const std::vector<double>& vars)
599  {
600  if (vars.size() != 2) {
601  B2FATAL("Need exactly two parameters (cellid and neighbour area size).");
602  }
603 
604  std::vector<double> parameters {vars[0], vars[1], ECLCalDigitVariable::varType::twoComponentHadronEnergy, ECLCalDigitVariable::centerType::extCell};
605  return ECLCalDigitVariable::getCalDigitExpert(particle, parameters);
606  }
607 
609  double getECLCalDigitTwoComponentDiodeEnergy(const Particle* particle, const std::vector<double>& vars)
610  {
611  if (vars.size() != 2) {
612  B2FATAL("Need exactly two parameters (cellid and neighbour area size).");
613  }
614 
615  std::vector<double> parameters {vars[0], vars[1], ECLCalDigitVariable::varType::twoComponentDiodeEnergy, ECLCalDigitVariable::centerType::maxCell};
616  return ECLCalDigitVariable::getCalDigitExpert(particle, parameters);
617  }
618 
620  double getExtECLCalDigitTwoComponentDiodeEnergy(const Particle* particle, const std::vector<double>& vars)
621  {
622  if (vars.size() != 2) {
623  B2FATAL("Need exactly two parameters (cellid and neighbour area size).");
624  }
625 
626  std::vector<double> parameters {vars[0], vars[1], ECLCalDigitVariable::varType::twoComponentDiodeEnergy, ECLCalDigitVariable::centerType::extCell};
627  return ECLCalDigitVariable::getCalDigitExpert(particle, parameters);
628  }
629 
631  double getECLCalDigitTwoComponentFitType(const Particle* particle, const std::vector<double>& vars)
632  {
633  if (vars.size() != 2) {
634  B2FATAL("Need exactly two parameters (cellid and neighbour area size).");
635  }
636 
637  std::vector<double> parameters {vars[0], vars[1], ECLCalDigitVariable::varType::twoComponentFitType, ECLCalDigitVariable::centerType::maxCell};
638  return ECLCalDigitVariable::getCalDigitExpert(particle, parameters);
639  }
640 
642  double getExtECLCalDigitTwoComponentFitType(const Particle* particle, const std::vector<double>& vars)
643  {
644  if (vars.size() != 2) {
645  B2FATAL("Need exactly two parameters (cellid and neighbour area size).");
646  }
647 
648  std::vector<double> parameters {vars[0], vars[1], ECLCalDigitVariable::varType::twoComponentFitType, ECLCalDigitVariable::centerType::extCell};
649  return ECLCalDigitVariable::getCalDigitExpert(particle, parameters);
650  }
651 
653  double getECLCalDigitTwoComponentChi2Saved_PhotonHadron(const Particle* particle, const std::vector<double>& vars)
654  {
655  if (vars.size() != 2) {
656  B2FATAL("Need exactly two parameters (cellid and neighbour area size).");
657  }
658 
659  std::vector<double> parameters {vars[0], vars[1], ECLCalDigitVariable::varType::twoComponentSavedChi2_PhotonHadron, ECLCalDigitVariable::centerType::maxCell};
660  return ECLCalDigitVariable::getCalDigitExpert(particle, parameters);
661  }
662 
664  double getExtECLCalDigitTwoComponentChi2Saved_PhotonHadron(const Particle* particle, const std::vector<double>& vars)
665  {
666  if (vars.size() != 2) {
667  B2FATAL("Need exactly two parameters (cellid and neighbour area size).");
668  }
669 
670  std::vector<double> parameters {vars[0], vars[1], ECLCalDigitVariable::varType::twoComponentSavedChi2_PhotonHadron, ECLCalDigitVariable::centerType::extCell};
671  return ECLCalDigitVariable::getCalDigitExpert(particle, parameters);
672  }
673 
675  double getECLCalDigitTwoComponentChi2Saved_PileUpPhoton(const Particle* particle, const std::vector<double>& vars)
676  {
677  if (vars.size() != 2) {
678  B2FATAL("Need exactly two parameters (cellid and neighbour area size).");
679  }
680 
681  std::vector<double> parameters {vars[0], vars[1], ECLCalDigitVariable::varType::twoComponentSavedChi2_PileUpPhoton, ECLCalDigitVariable::centerType::maxCell};
682  return ECLCalDigitVariable::getCalDigitExpert(particle, parameters);
683  }
684 
686  double getExtECLCalDigitTwoComponentChi2Saved_PileUpPhoton(const Particle* particle, const std::vector<double>& vars)
687  {
688  if (vars.size() != 2) {
689  B2FATAL("Need exactly two parameters (cellid and neighbour area size).");
690  }
691 
692  std::vector<double> parameters {vars[0], vars[1], ECLCalDigitVariable::varType::twoComponentSavedChi2_PileUpPhoton, ECLCalDigitVariable::centerType::extCell};
693  return ECLCalDigitVariable::getCalDigitExpert(particle, parameters);
694  }
695 
697  double getECLCalDigitTwoComponentChi2Saved_PhotonDiode(const Particle* particle, const std::vector<double>& vars)
698  {
699  if (vars.size() != 2) {
700  B2FATAL("Need exactly two parameters (cellid and neighbour area size).");
701  }
702 
703  std::vector<double> parameters {vars[0], vars[1], ECLCalDigitVariable::varType::twoComponentSavedChi2_PhotonDiode, ECLCalDigitVariable::centerType::maxCell};
704  return ECLCalDigitVariable::getCalDigitExpert(particle, parameters);
705  }
706 
708  double getExtECLCalDigitTwoComponentChi2Saved_PhotonDiode(const Particle* particle, const std::vector<double>& vars)
709  {
710  if (vars.size() != 2) {
711  B2FATAL("Need exactly two parameters (cellid and neighbour area size).");
712  }
713 
714  std::vector<double> parameters {vars[0], vars[1], ECLCalDigitVariable::varType::twoComponentSavedChi2_PhotonDiode, ECLCalDigitVariable::centerType::extCell};
715  return ECLCalDigitVariable::getCalDigitExpert(particle, parameters);
716  }
717 
719  double getPhi(const Particle* particle, const std::vector<double>& vars)
720  {
721  if (vars.size() != 2) {
722  B2FATAL("Need exactly two parameters (cellid and neighbour area size).");
723  }
724 
725  std::vector<double> parameters {vars[0], vars[1], ECLCalDigitVariable::varType::phi, ECLCalDigitVariable::centerType::maxCell};
726  return ECLCalDigitVariable::getCalDigitExpert(particle, parameters);
727  }
728 
730  double getExtPhi(const Particle* particle, const std::vector<double>& vars)
731  {
732  if (vars.size() != 2) {
733  B2FATAL("Need exactly two parameters (cellid and neighbour area size).");
734  }
735 
736  std::vector<double> parameters {vars[0], vars[1], ECLCalDigitVariable::varType::phi, ECLCalDigitVariable::centerType::extCell};
737  return ECLCalDigitVariable::getCalDigitExpert(particle, parameters);
738  }
739 
741  double getTheta(const Particle* particle, const std::vector<double>& vars)
742  {
743  if (vars.size() != 2) {
744  B2FATAL("Need exactly two parameters (cellid and neighbour area size).");
745  }
746 
747  std::vector<double> parameters {vars[0], vars[1], ECLCalDigitVariable::varType::theta, ECLCalDigitVariable::centerType::maxCell};
748  return ECLCalDigitVariable::getCalDigitExpert(particle, parameters);
749  }
750 
752  double getExtTheta(const Particle* particle, const std::vector<double>& vars)
753  {
754  if (vars.size() != 2) {
755  B2FATAL("Need exactly two parameters (cellid and neighbour area size).");
756  }
757 
758  std::vector<double> parameters {vars[0], vars[1], ECLCalDigitVariable::varType::theta, ECLCalDigitVariable::centerType::extCell};
759  return ECLCalDigitVariable::getCalDigitExpert(particle, parameters);
760  }
761 
763  double getPhiId(const Particle* particle, const std::vector<double>& vars)
764  {
765  if (vars.size() != 2) {
766  B2FATAL("Need exactly two parameters (cellid and neighbour area size).");
767  }
768 
769  std::vector<double> parameters {vars[0], vars[1], ECLCalDigitVariable::varType::phiId, ECLCalDigitVariable::centerType::maxCell};
770  return ECLCalDigitVariable::getCalDigitExpert(particle, parameters);
771  }
772 
774  double getExtPhiId(const Particle* particle, const std::vector<double>& vars)
775  {
776  if (vars.size() != 2) {
777  B2FATAL("Need exactly two parameters (cellid and neighbour area size).");
778  }
779 
780  std::vector<double> parameters {vars[0], vars[1], ECLCalDigitVariable::varType::phiId, ECLCalDigitVariable::centerType::extCell};
781  return ECLCalDigitVariable::getCalDigitExpert(particle, parameters);
782  }
783 
785  double getThetaId(const Particle* particle, const std::vector<double>& vars)
786  {
787  if (vars.size() != 2) {
788  B2FATAL("Need exactly two parameters (cellid and neighbour area size).");
789  }
790 
791  std::vector<double> parameters {vars[0], vars[1], ECLCalDigitVariable::varType::thetaId, ECLCalDigitVariable::centerType::maxCell};
792  return ECLCalDigitVariable::getCalDigitExpert(particle, parameters);
793  }
794 
796  double getExtThetaId(const Particle* particle, const std::vector<double>& vars)
797  {
798  if (vars.size() != 2) {
799  B2FATAL("Need exactly two parameters (cellid and neighbour area size).");
800  }
801 
802  std::vector<double> parameters {vars[0], vars[1], ECLCalDigitVariable::varType::thetaId, ECLCalDigitVariable::centerType::extCell};
803  return ECLCalDigitVariable::getCalDigitExpert(particle, parameters);
804  }
805 
807  double getCellId(const Particle* particle, const std::vector<double>& vars)
808  {
809  if (vars.size() != 2) {
810  B2FATAL("Need exactly two parameters (cellid and neighbour area size).");
811  }
812 
813  std::vector<double> parameters {vars[0], vars[1], ECLCalDigitVariable::varType::cellId, ECLCalDigitVariable::centerType::maxCell};
814  return ECLCalDigitVariable::getCalDigitExpert(particle, parameters);
815  }
816 
818  double getCenterCellId(const Particle* particle)
819  {
820  const int centercellid = ECLCalDigitVariable::getCenterCell(particle);
821 
822  if (centercellid < 0) return std::numeric_limits<double>::quiet_NaN();
823  return centercellid;
824  }
825 
827  double getCenterCellCrystalTheta(const Particle* particle)
828  {
829  const int centercellid = ECLCalDigitVariable::getCenterCell(particle);
830  StoreObjPtr<ECLCellIdMapping> mapping;
831 
832  if (!mapping) {
833  B2ERROR("Mapping not found, did you forget to run the eclFillCellIdMapping module?");
834  return std::numeric_limits<double>::quiet_NaN();
835  }
836 
837  if (centercellid < 0) return std::numeric_limits<double>::quiet_NaN();
838  return mapping->getCellIdToTheta(centercellid);
839  }
840 
842  double getCenterCellCrystalPhi(const Particle* particle)
843  {
844  const int centercellid = ECLCalDigitVariable::getCenterCell(particle);
845  StoreObjPtr<ECLCellIdMapping> mapping;
846 
847  if (!mapping) {
848  B2ERROR("Mapping not found, did you forget to run the eclFillCellIdMapping module?");
849  return std::numeric_limits<double>::quiet_NaN();
850  }
851 
852  if (centercellid < 0) return std::numeric_limits<double>::quiet_NaN();
853  return mapping->getCellIdToPhi(centercellid);
854  }
855 
857  double getExtCellId(const Particle* particle)
858  {
859  const int extcellid = ECLCalDigitVariable::getExtCell(particle);
860 
861  if (extcellid < 0) return std::numeric_limits<double>::quiet_NaN();
862  return extcellid;
863  }
864 
866  double getCenterCellThetaId(const Particle* particle)
867  {
868  const int centercellid = ECLCalDigitVariable::getCenterCell(particle);
869  StoreObjPtr<ECLCellIdMapping> mapping;
870 
871  if (!mapping) {
872  B2ERROR("Mapping not found, did you forget to run the eclFillCellIdMapping module?");
873  return std::numeric_limits<double>::quiet_NaN();
874  }
875 
876  if (centercellid < 0) return std::numeric_limits<double>::quiet_NaN();
877  return mapping->getCellIdToThetaId(centercellid);
878  }
879 
881  double getCenterCellPhiId(const Particle* particle)
882  {
883  const int centercellid = ECLCalDigitVariable::getCenterCell(particle);
884  StoreObjPtr<ECLCellIdMapping> mapping;
885 
886  if (!mapping) {
887  B2ERROR("Mapping not found, did you forget to run the eclFillCellIdMapping module?");
888  return std::numeric_limits<double>::quiet_NaN();
889  }
890 
891  if (centercellid < 0) return std::numeric_limits<double>::quiet_NaN();
892  return mapping->getCellIdToPhiId(centercellid);
893  }
894 
896  double getExtCellThetaId(const Particle* particle)
897  {
898  const int extcellid = ECLCalDigitVariable::getExtCell(particle);
899  StoreObjPtr<ECLCellIdMapping> mapping;
900 
901  if (!mapping) {
902  B2ERROR("Mapping not found, did you forget to run the eclFillCellIdMapping module?");
903  return std::numeric_limits<double>::quiet_NaN();
904  }
905 
906  if (extcellid < 0) return std::numeric_limits<double>::quiet_NaN();
907  return mapping->getCellIdToThetaId(extcellid);
908  }
909 
911  double getExtCellPhiId(const Particle* particle)
912  {
913  const int extcellid = ECLCalDigitVariable::getExtCell(particle);
914  StoreObjPtr<ECLCellIdMapping> mapping;
915 
916  if (!mapping) {
917  B2ERROR("Mapping not found, did you forget to run the eclFillCellIdMapping module?");
918  return std::numeric_limits<double>::quiet_NaN();
919  }
920 
921  if (extcellid < 0) return std::numeric_limits<double>::quiet_NaN();
922  return mapping->getCellIdToPhiId(extcellid);
923  }
924 
926  double getExtCellCrystalTheta(const Particle* particle)
927  {
928  const int extcellid = ECLCalDigitVariable::getExtCell(particle);
929  StoreObjPtr<ECLCellIdMapping> mapping;
930 
931  if (!mapping) {
932  B2ERROR("Mapping not found, did you forget to run the eclFillCellIdMapping module?");
933  return std::numeric_limits<double>::quiet_NaN();
934  }
935 
936  if (extcellid < 0) return std::numeric_limits<double>::quiet_NaN();
937  return mapping->getCellIdToTheta(extcellid);
938  }
939 
941  double getExtCellCrystalPhi(const Particle* particle)
942  {
943  const int extcellid = ECLCalDigitVariable::getExtCell(particle);
944  StoreObjPtr<ECLCellIdMapping> mapping;
945 
946  if (!mapping) {
947  B2ERROR("Mapping not found, did you forget to run the eclFillCellIdMapping module?");
948  return std::numeric_limits<double>::quiet_NaN();
949  }
950 
951  if (extcellid < 0) return std::numeric_limits<double>::quiet_NaN();
952  return mapping->getCellIdToPhi(extcellid);
953  }
954 
956  double getCenterCellIndex(const Particle* particle, const std::vector<double>& vars)
957  {
958  if (vars.size() != 1) {
959  B2FATAL("Need exactly one parameters (neighbour area size).");
960  }
961 
962  StoreObjPtr<ECLCellIdMapping> mapping;
963  const int nneighbours = int(std::lround(vars[0]));
964 
965  if (!mapping) {
966  B2ERROR("Mapping not found, did you forget to run the eclFillCellIdMapping module?");
967  return std::numeric_limits<double>::quiet_NaN();
968  }
969  if (nneighbours != 5 and nneighbours != 7) {
970  B2FATAL("Please request 5 or 7 neighbour area.");
971  return std::numeric_limits<double>::quiet_NaN();
972  }
973 
974  const int centercellid = ECLCalDigitVariable::getCenterCell(particle);
975  if (centercellid < 0) return std::numeric_limits<double>::quiet_NaN();
976 
977  std::vector<short int> neighbours;
978 
979  if (nneighbours == 5) {
980  neighbours = mapping->getCellIdToNeighbour5(centercellid);
981  } else if (nneighbours == 7) {
982  neighbours = mapping->getCellIdToNeighbour7(centercellid);
983  }
984 
985  for (unsigned int idx = 0; idx < neighbours.size(); idx++) {
986  if (neighbours[idx] == centercellid) return idx;
987  }
988 
989  return std::numeric_limits<double>::quiet_NaN();
990  }
991 
992 
994  double getExtCenterCellIndex(const Particle* particle, const std::vector<double>& vars)
995  {
996  if (vars.size() != 1) {
997  B2FATAL("Need exactly one parameters (neighbour area size).");
998  }
999 
1000  StoreObjPtr<ECLCellIdMapping> mapping;
1001  const int nneighbours = int(std::lround(vars[0]));
1002 
1003  if (!mapping) {
1004  B2ERROR("Mapping not found, did you forget to run the eclFillCellIdMapping module?");
1005  return std::numeric_limits<double>::quiet_NaN();
1006  }
1007  if (nneighbours != 5 and nneighbours != 7) {
1008  B2FATAL("Please request 5 or 7 neighbour area.");
1009  return std::numeric_limits<double>::quiet_NaN();
1010  }
1011 
1012  const int centercellid = ECLCalDigitVariable::getExtCell(particle);
1013  if (centercellid < 0) return std::numeric_limits<double>::quiet_NaN();
1014 
1015  std::vector<short int> neighbours;
1016 
1017  if (nneighbours == 5) {
1018  neighbours = mapping->getCellIdToNeighbour5(centercellid);
1019  } else if (nneighbours == 7) {
1020  neighbours = mapping->getCellIdToNeighbour7(centercellid);
1021  }
1022 
1023  for (unsigned int idx = 0; idx < neighbours.size(); idx++) {
1024  if (neighbours[idx] == centercellid) return idx;
1025  }
1026 
1027  return std::numeric_limits<double>::quiet_NaN();
1028  }
1029 
1030  double getTotalECLCalDigitMCEnergy(const Particle* particle)
1031  {
1032  const MCParticle* mcparticle = particle->getRelatedTo<MCParticle>();
1033  if (mcparticle == nullptr)
1034  return std::numeric_limits<double>::quiet_NaN();
1035 
1036  double sum = 0.0;
1037  auto mcDigitRelations = mcparticle->getRelationsWith<ECLCalDigit>();
1038  for (unsigned int ir = 0; ir < mcDigitRelations.size(); ++ir) {
1039  sum += mcDigitRelations.weight(ir);
1040  }
1041 
1042  return sum;
1043 
1044  }
1045 
1046  double getClusterECLCalDigitMCEnergy(const Particle* particle)
1047  {
1048  // get MCParticle (return if there is none)
1049  const MCParticle* mcparticle = particle->getRelatedTo<MCParticle>();
1050  if (mcparticle == nullptr)
1051  return std::numeric_limits<double>::quiet_NaN();
1052 
1053  const ECLCluster* cluster = particle->getECLCluster();
1054  if (cluster) {
1055  std::vector<unsigned int> listCellIds;
1056  auto clusterShowerRelations = cluster->getRelationsWith<ECLShower>(); // should never happen to have more than one shower
1057  for (unsigned int ir = 0; ir < clusterShowerRelations.size(); ++ir) {
1058  const auto shower = clusterShowerRelations.object(ir);
1059  listCellIds = shower->getListOfCrystalsForEnergy();
1060  }
1061 
1062  double sum = 0.0;
1063  auto clusterDigitRelations = mcparticle->getRelationsWith<ECLCalDigit>();
1064  for (unsigned int ir = 0; ir < clusterDigitRelations.size(); ++ir) {
1065 
1066  // check if this digit is in the current cluster
1067  unsigned int cellid = clusterDigitRelations.object(ir)->getCellId();
1068  if (std::find(listCellIds.begin(), listCellIds.end(), cellid) != listCellIds.end()) { //find is faster than count
1069  sum += clusterDigitRelations.weight(ir);
1070  }
1071  }
1072 
1073  return sum;
1074  }
1075 
1076  return std::numeric_limits<float>::quiet_NaN();
1077 
1078  }
1079 
1080 
1081 
1082  double getClusterNHitsThreshold(const Particle* particle, const std::vector<double>& vars)
1083  {
1084  if (vars.size() != 1) {
1085  B2FATAL("Need exactly one parameter (energy threshold in GeV).");
1086  }
1087  const double threshold = vars[0];
1088 
1089  const ECLCluster* cluster = particle->getECLCluster();
1090  if (cluster) {
1091  double nhits = 0.;
1092 
1093  auto clusterDigitRelations = cluster->getRelationsTo<ECLCalDigit>();
1094  for (unsigned int ir = 0; ir < clusterDigitRelations.size(); ++ir) {
1095  const auto calDigit = clusterDigitRelations.object(ir);
1096  const auto weight = clusterDigitRelations.weight(ir);
1097 
1098  // take the unweighted eclcaldigit energy for this check (closer to real hardware threshold)
1099  if (calDigit->getEnergy() > threshold) {
1100  nhits += weight;
1101  }
1102  }
1103 
1104  return nhits;
1105  }
1106  return std::numeric_limits<float>::quiet_NaN();
1107  }
1108 
1109 
1110  VARIABLE_GROUP("ECL Calibration (cDST)");
1111  REGISTER_VARIABLE("eclcaldigitEnergy(i, j)", getECLCalDigitEnergy,
1112  "[calibration] Returns the energy of the i-th caldigit for 5x5 (j=5) or 7x7 (j=7) neighbours");
1113  REGISTER_VARIABLE("eclcaldigitTime(i, j)", getECLCalDigitTime,
1114  "[calibration] Returns the time of the i-th caldigit for 5x5 (j=5) or 7x7 (j=7) neighbours");
1115  REGISTER_VARIABLE("eclcaldigitTimeResolution(i, j)", getECLCalDigitTimeResolution,
1116  "[calibration] Returns the time resolution (dt99) of the i-th caldigit for 5x5 (j=5) or 7x7 (j=7) neighbours");
1117  REGISTER_VARIABLE("eclcaldigitTwoComponentChi2(i, j)", getTwoComponentChi2,
1118  "[calibration] Returns the two component fit chi2 of the i-th caldigit for 5x5 (j=5) or 7x7 (j=7) neighbours");
1119  REGISTER_VARIABLE("eclcaldigitTwoComponentTotalEnergy(i, j)", getTwoComponentTotalEnergy,
1120  "[calibration] Returns the two component total energy of the i-th caldigit for 5x5 (j=5) or 7x7 (j=7) neighbours");
1121  REGISTER_VARIABLE("eclcaldigitTwoComponentHadronEnergy(i, j)", getTwoComponentHadronEnergy,
1122  "[calibration] Returns the two component hadron energy of the i-th caldigit for 5x5 (j=5) or 7x7 (j=7) neighbours");
1123  REGISTER_VARIABLE("eclcaldigitPhi(i, j)", getPhi,
1124  "[calibration] Returns phi of the i-th caldigit for 5x5 (j=5) or 7x7 (j=7) neighbours");
1125  REGISTER_VARIABLE("eclcaldigitTheta(i, j)", getTheta,
1126  "[calibration] Returns theta of the i-th caldigit for 5x5 (j=5) or 7x7 (j=7) neighbours");
1127  REGISTER_VARIABLE("eclcaldigitPhiId(i, j)", getPhiId,
1128  "[calibration] Returns the phi Id of the i-th caldigit for 5x5 (j=5) or 7x7 (j=7) neighbours");
1129  REGISTER_VARIABLE("eclcaldigitThetaId(i, j)", getThetaId,
1130  "[calibration] Returns the theta Id of the i-th caldigit for 5x5 (j=5) or 7x7 (j=7) neighbours");
1131  REGISTER_VARIABLE("eclcaldigitCellId(i, j)", getCellId,
1132  "[calibration] Returns the cell id of the i-th caldigit for 5x5 (j=5) or 7x7 (j=7) neighbours (1-based)");
1133  REGISTER_VARIABLE("eclcaldigitUsedForClusterEnergy(i, j)", getUsedForClusterEnergy,
1134  " [calibration] Returns the 0 (not used) 1 (used) of the i-th caldigit for 5x5 (j=5) or 7x7 (j=7) neighbours (1-based)");
1135 
1136  REGISTER_VARIABLE("eclcaldigitCenterCellId", getCenterCellId, "[calibration] Returns the center cell id");
1137  REGISTER_VARIABLE("eclcaldigitCenterCellThetaId", getCenterCellThetaId, "[calibration] Returns the center cell theta id");
1138  REGISTER_VARIABLE("eclcaldigitCenterCellPhiId", getCenterCellPhiId, "[calibration] Returns the center cell phi id");
1139  REGISTER_VARIABLE("eclcaldigitCenterCellCrystalTheta", getCenterCellCrystalTheta,
1140  "[calibration] Returns the center cell crystal theta");
1141  REGISTER_VARIABLE("eclcaldigitCenterCellCrystalPhi", getCenterCellCrystalPhi,
1142  "[calibration] Returns the center cell crystal phi");
1143  REGISTER_VARIABLE("eclcaldigitCenterCellIndex(i)", getCenterCellIndex,
1144  "[calibration] Returns the center cell index (within its 5x5 (i=5) or 7x7 (i=7) neighbours)");
1145  REGISTER_VARIABLE("eclcaldigitMCEnergy(i, j)", getMCEnergy,
1146  "[calibration] Returns the true deposited energy of all particles of the i-th caldigit for 5x5 (j=5) or 7x7 (j=7) neighbours (1-based)");
1147  REGISTER_VARIABLE("clusterNHitsThreshold(i)", getClusterNHitsThreshold,
1148  "[calibration] Returns sum of crystal weights sum(w_i) with w_i<=1 associated to this cluster above threshold (in GeV)");
1149 
1150  VARIABLE_GROUP("ECL Calibration (based on extrapolated tracks) (cDST)");
1151  REGISTER_VARIABLE("eclcaldigitExtEnergy(i, j)", getExtECLCalDigitEnergy,
1152  "[calibration] Returns the energy of the i-th caldigit for 5x5 (j=5) or 7x7 (j=7) neighbours for an ext track");
1153  REGISTER_VARIABLE("eclcaldigitExtTime(i, j)", getExtECLCalDigitTime,
1154  "[calibration] Returns the time of the i-th caldigit for 5x5 (j=5) or 7x7 (j=7) neighbours for an ext track");
1155  REGISTER_VARIABLE("eclcaldigitExtTimeResolution(i, j)", getExtECLCalDigitTimeResolution,
1156  "[calibration] Returns the time resolution (dt99) of the i-th caldigit for 5x5 (j=5) or 7x7 (j=7) neighbours for an ext track");
1157  REGISTER_VARIABLE("eclcaldigitExtTwoComponentTotalEnergy(i, j)", getExtECLCalDigitTwoComponentTotalEnergy,
1158  "[calibration] Returns the TwoComponentTotalEnergy of the i-th caldigit for 5x5 (j=5) or 7x7 (j=7) neighbours for an ext track");
1159  REGISTER_VARIABLE("eclcaldigitExtTwoComponentHadronEnergy(i, j)", getExtECLCalDigitTwoComponentHadronEnergy,
1160  "[calibration] Returns the TwoComponentHadronEnergy of the i-th caldigit for 5x5 (j=5) or 7x7 (j=7) neighbours for an ext track");
1161  REGISTER_VARIABLE("eclcaldigitExtTwoComponentChi2(i, j)", getExtECLCalDigitTwoComponentChi2,
1162  "[calibration] Returns the TwoComponentchi2 of the i-th caldigit for 5x5 (j=5) or 7x7 (j=7) neighbours for an ext track");
1163  REGISTER_VARIABLE("eclcaldigitExtPhi(i, j)", getExtPhi,
1164  "[calibration] Returns phi of the i-th caldigit for 5x5 (j=5) or 7x7 (j=7) neighbours for an extrapolated track");
1165  REGISTER_VARIABLE("eclcaldigitExtTheta(i, j)", getExtTheta,
1166  "[calibration] Returns theta of the i-th caldigit for 5x5 (j=5) or 7x7 (j=7) neighbours for an extrapolated track");
1167  REGISTER_VARIABLE("eclcaldigitExtPhiId(i, j)", getExtPhiId,
1168  "[calibration] Returns the phi Id of the i-th caldigit for 5x5 (j=5) or 7x7 (j=7) neighbours for an extrapolated track");
1169  REGISTER_VARIABLE("eclcaldigitExtThetaId(i, j)", getExtThetaId,
1170  "[calibration] Returns the theta Id of the i-th caldigit for 5x5 (j=5) or 7x7 (j=7) neighbours for an extrapolated track");
1171  REGISTER_VARIABLE("eclcaldigitExtCellId", getExtCellId, "[calibration] Returns the extrapolated cell id");
1172  REGISTER_VARIABLE("eclcaldigitExtCellThetaId", getExtCellThetaId, "[calibration] Returns the ext cell theta id");
1173  REGISTER_VARIABLE("eclcaldigitExtCellPhiId", getExtCellPhiId, "[calibration] Returns the ext cell phi id");
1174  REGISTER_VARIABLE("eclcaldigitExtCellCrystalTheta", getExtCellCrystalTheta, "[calibration] Returns the ext cell crystal theta");
1175  REGISTER_VARIABLE("eclcaldigitExtCellCrystalPhi", getExtCellCrystalPhi, "[calibration] Returns the ext cell crystal phi");
1176  REGISTER_VARIABLE("eclcaldigitExtCenterCellIndex(i)", getExtCenterCellIndex,
1177  "[calibration] Returns the center cell index (within its 5x5 (i=5) or 7x7 (i=7) neighbours) for an ext track");
1178 
1179  REGISTER_VARIABLE("eclcaldigitExtTwoComponentFitType(i, j)", getExtECLCalDigitTwoComponentFitType,
1180  "[calibration] Returns the TwoComponentFitType of the i-th caldigit for 5x5 (j=5) or 7x7 (j=7) neighbours for an ext track");
1181  REGISTER_VARIABLE("eclcaldigitExtTwoComponentDiodeEnergy(i, j)", getExtECLCalDigitTwoComponentDiodeEnergy,
1182  "[calibration] Returns the TwoComponentDiodeEnergy of the i-th caldigit for 5x5 (j=5) or 7x7 (j=7) neighbours for an ext track");
1183  REGISTER_VARIABLE("eclcaldigitExtTwoComponentChi2Saved_PhotonHadron(i, j)", getExtECLCalDigitTwoComponentChi2Saved_PhotonHadron,
1184  "[calibration] Returns the TwoComponentChi2Saved_PhotonHadron of the i-th caldigit for 5x5 (j=5) or 7x7 (j=7) neighbours for an ext track");
1185  REGISTER_VARIABLE("eclcaldigitExtTwoComponentChi2Saved_PileUpPhoton(i, j)", getExtECLCalDigitTwoComponentChi2Saved_PileUpPhoton,
1186  "[calibration] Returns the TwoComponentChi2Saved_PileUpPhoton of the i-th caldigit for 5x5 (j=5) or 7x7 (j=7) neighbours for an ext track");
1187  REGISTER_VARIABLE("eclcaldigitExtTwoComponentChi2Saved_PhotonDiode(i, j)", getExtECLCalDigitTwoComponentChi2Saved_PhotonDiode,
1188  "[calibration] Returns the TwoComponentChi2Saved_PhotonDiode of the i-th caldigit for 5x5 (j=5) or 7x7 (j=7) neighbours for an ext track");
1189 
1190  REGISTER_VARIABLE("eclcaldigitTwoComponentFitType(i, j)", getECLCalDigitTwoComponentFitType,
1191  "[calibration] Returns the TwoComponentFitType of the i-th caldigit for 5x5 (j=5) or 7x7 (j=7) neighbours");
1192  REGISTER_VARIABLE("eclcaldigitTwoComponentDiodeEnergy(i, j)", getECLCalDigitTwoComponentDiodeEnergy,
1193  "[calibration] Returns the TwoComponentDiodeEnergy of the i-th caldigit for 5x5 (j=5) or 7x7 (j=7) neighbours");
1194  REGISTER_VARIABLE("eclcaldigitTwoComponentChi2Saved_PhotonHadron(i, j)", getECLCalDigitTwoComponentChi2Saved_PhotonHadron,
1195  "[calibration] Returns the TwoComponentChi2Saved_PhotonHadron of the i-th caldigit for 5x5 (j=5) or 7x7 (j=7) neighbours");
1196  REGISTER_VARIABLE("eclcaldigitTwoComponentChi2Saved_PileUpPhoton(i, j)", getECLCalDigitTwoComponentChi2Saved_PileUpPhoton,
1197  "[calibration] Returns the TwoComponentChi2Saved_PileUpPhoton of the i-th caldigit for 5x5 (j=5) or 7x7 (j=7) neighbours");
1198  REGISTER_VARIABLE("eclcaldigitTwoComponentChi2Saved_PhotonDiode(i, j)", getECLCalDigitTwoComponentChi2Saved_PhotonDiode,
1199  "[calibration] Returns the TwoComponentChi2Saved_PhotonDiode of the i-th caldigit for 5x5 (j=5) or 7x7 (j=7) neighbours");
1200 
1201  REGISTER_VARIABLE("eclcaldigitEnergyByEnergyRank(i)", getECLCalDigitEnergyByEnergyRank,
1202  "[calibration] Returns the caldigit energy of the i-th highest energy caldigit in the cluster (i>=0)");
1203 
1204  REGISTER_VARIABLE("eclcaldigitTimeByEnergyRank(i)", getECLCalDigitTimeByEnergyRank,
1205  "[calibration] Returns the caldigit time of the i-th highest energy caldigit in the cluster (i>=0)");
1206 
1207  REGISTER_VARIABLE("eclcaldigitTwoComponentFitTypeByEnergyRank(i)", getTwoComponentFitTypeByEnergyRank,
1208  "[calibration] Returns the offline fit type of the i-th highest energy caldigit in the cluster (i>=0)");
1209 
1210  REGISTER_VARIABLE("eclcaldigitTwoComponentChi2ByEnergyRank(i)", getTwoComponentChi2ByEnergyRank,
1211  "[calibration] Returns the two component chi2 of the i-th highest energy caldigit in the cluster (i>=0)");
1212 
1213  REGISTER_VARIABLE("eclcaldigitTwoComponentEnergyByEnergyRank(i)", getTwoComponentTotalEnergyByEnergyRank,
1214  "[calibration] Returns the two component total energy of the i-th highest energy caldigit in the cluster (i>=0)");
1215 
1216  REGISTER_VARIABLE("eclcaldigitTwoComponentHadronEnergyByEnergyRank(i)", getTwoComponentHadronEnergyByEnergyRank,
1217  "[calibration] Returns the two component fit Hadron Energy of the i-th highest energy caldigit in the cluster (i>=0)");
1218 
1219  REGISTER_VARIABLE("eclcaldigitTwoComponentDiodeEnergyByEnergyRank(i)", getTwoComponentDiodeEnergyByEnergyRank,
1220  "[calibration] Returns the two component fit Diode Energy of the i-th highest energy caldigit in the cluster (i>=0)");
1221 
1222  REGISTER_VARIABLE("eclcaldigitTwoComponentChi2SavedByEnergyRank_PhotonHadron(i)", getTwoComponentChi2SavedByEnergyRank_PhotonHadron,
1223  "[calibration] Returns the chi2 for the photo+hadron fit type of the i-th highest energy caldigit in the cluster (i>=0)");
1224 
1225  REGISTER_VARIABLE("eclcaldigitTwoComponentChi2SavedByEnergyRank_PileUpPhoton(i)", getTwoComponentChi2SavedByEnergyRank_PileUpPhoton,
1226  "[calibration] Returns the chi2 for the photo+hadron+pile-up photon fit type of the i-th highest energy caldigit in the cluster (i>=0)");
1227 
1228  REGISTER_VARIABLE("eclcaldigitTwoComponentChi2SavedByEnergyRank_PhotonDiode(i)", getTwoComponentChi2SavedByEnergyRank_PhotonDiode,
1229  "[calibration] Returns the chi2 for the photo+diode fit type of the i-th highest energy caldigit in the cluster (i>=0)");
1230 
1231  REGISTER_VARIABLE("eclcaldigitWeightByEnergyRank(i)", getWeightByEnergyRank,
1232  "[calibration] Returns the weight of the i-th highest energy caldigit in the cluster (i>=0)");
1233 
1234  REGISTER_VARIABLE("eclcaldigitCellIdByEnergyRank(i)", getCellIdByEnergyRank,
1235  "[calibration] Returns the cell id of the i-th highest energy caldigit in the cluster (i>=0)");
1236 
1237  REGISTER_VARIABLE("totalECLCalDigitMCEnergy", getTotalECLCalDigitMCEnergy,
1238  "[calibration] Returns total deposited MC energy in all ECLCalDigits for the MC particle");
1239 
1240  REGISTER_VARIABLE("clusterECLCalDigitMCEnergy", getClusterECLCalDigitMCEnergy,
1241  "[calibration] Returns total deposited MC energy in all ECLCalDigits for the MC particle that are used to calculate the cluster energy");
1242 
1243 
1244  }
1245 
1246  // Create an empty module which allows basf2 to easily find the library and load it from the steering file
1247  class EnableECLCalDigitVariablesModule: public Module {}; // Register this module to create a .map lookup file.
1248  REG_MODULE(EnableECLCalDigitVariables);
1250 }
REG_MODULE
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:652
Belle2::Module
Base class for Modules.
Definition: Module.h:74
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::EnableECLCalDigitVariablesModule
Definition: ECLCalDigitVariables.cc:1247