Belle II Software  release-05-02-19
SVDShaperDigitToDATCONSVDDigitConverterModule.cc
1 /******************************************************************************
2 * BASF2 (Belle Analysis Framework 2) *
3 * Copyright(C) 2010 - Belle II Collaboration *
4 * *
5 * Author: The Belle II Collaboration *
6 * Contributors: Christian Wessel *
7 * *
8 * This software is provided "as is" without any warranty. *
9 * Beware! Do not expose to open flames it can explode *
10 ******************************************************************************/
11 
12 #include <tracking/modules/DATCON/SVDShaperDigitToDATCONSVDDigitConverterModule.h>
13 
14 using namespace std;
15 using namespace Belle2;
16 
17 //-----------------------------------------------------------------
18 // Register the Module
19 //-----------------------------------------------------------------
20 REG_MODULE(SVDShaperDigitToDATCONSVDDigitConverter)
21 
22 //-----------------------------------------------------------------
23 // Implementation
24 //-----------------------------------------------------------------
25 
27 {
28  //Set module properties
29  setDescription("Converts SVDShaperDigits into DATCONSVDDigits and registers the relations needed.");
30  setPropertyFlags(c_ParallelProcessingCertified);
31 
32  addParam("svdShaperDigitListName", m_storeSVDShaperDigitsListName, "Name of the SVDShaperDigits list", string(""));
33  addParam("DATCONSVDDigitListName", m_storeDATCONSVDDigitsListName, "Name of the m_storeDATCONSVDDigits list",
34  string("DATCONSVDDigits"));
35  addParam("svdTrueHitsListName", m_storeTrueHitsListName, "Name of the SVDTrueHit list", string(""));
36  addParam("mcParticlesListName", m_storeMCParticlesListName, "Name of the MCParticles list", string(""));
37 }
38 
39 
40 void SVDShaperDigitToDATCONSVDDigitConverterModule::initialize()
41 {
42  storeDATCONSVDDigits.registerInDataStore(m_storeDATCONSVDDigitsListName, DataStore::c_DontWriteOut);
43  m_storeDATCONSVDDigitsListName = storeDATCONSVDDigits.getName();
44 
45  storeSVDShaperDigits.isRequired(m_storeSVDShaperDigitsListName);
46  m_storeSVDShaperDigitsListName = storeSVDShaperDigits.getName();
47 
48  storeDATCONSVDDigits.registerRelationTo(storeSVDShaperDigits);
49 
50  storeTrueHits.isOptional(m_storeTrueHitsListName);
51  if (storeTrueHits.isValid()) {
52  m_storeTrueHitsListName = storeTrueHits.getName();
53  storeDATCONSVDDigits.registerRelationTo(storeTrueHits, DataStore::c_Event, DataStore::c_DontWriteOut);
54  }
55 
56  storeMCParticles.isOptional(m_storeMCParticlesListName);
57  if (storeMCParticles.isValid()) {
58  m_storeMCParticlesListName = storeMCParticles.getName();
59  storeDATCONSVDDigits.registerRelationTo(storeMCParticles, DataStore::c_Event, DataStore::c_DontWriteOut);
60  }
61 }
62 
63 
64 void SVDShaperDigitToDATCONSVDDigitConverterModule::event()
65 {
66  for (auto& shaperdigit : storeSVDShaperDigits) {
67 
68  RelationVector<MCParticle> relatedMC = shaperdigit.getRelationsTo<MCParticle>();
69  RelationVector<SVDTrueHit> relatedSVDTrue = shaperdigit.getRelationsTo<SVDTrueHit>();
70  VxdID sensorid = shaperdigit.getSensorID();
71  bool isu = shaperdigit.isUStrip();
72  short cellid = shaperdigit.getCellID();
73  DATCONSVDDigit::APVFloatSamples rawsamples = shaperdigit.getSamples();
74 
75  DATCONSVDDigit newDATCONSVDDigit(sensorid, isu, cellid, rawsamples);
76  DATCONSVDDigit* datcondigit = storeDATCONSVDDigits.appendNew(newDATCONSVDDigit);
77 
78  // Register relation to the SVDShaperDigit the DATCONSVDDigit is derived from
79  datcondigit->addRelationTo(&shaperdigit);
80 
81  // Register relations to the according MCParticle and SVDTrueHit
82  if (relatedMC.size() > 0) {
83  for (unsigned int relmcindex = 0; relmcindex < relatedMC.size(); relmcindex++) {
84  datcondigit->addRelationTo(relatedMC[relmcindex], relatedMC.weight(relmcindex));
85  }
86  }
87  if (relatedSVDTrue.size() > 0) {
88  for (unsigned int reltruehitindex = 0; reltruehitindex < relatedSVDTrue.size(); reltruehitindex++) {
89  datcondigit->addRelationTo(relatedSVDTrue[reltruehitindex], relatedSVDTrue.weight(reltruehitindex));
90  }
91  }
92 
93  }
94 
95 } //end event function
96 
Belle2::RelationVector::size
size_t size() const
Get number of relations.
Definition: RelationVector.h:98
Belle2::VxdID
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:43
REG_MODULE
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:652
Belle2::DATCONSVDDigit::APVFloatSamples
std::array< APVFloatSampleType, c_nAPVSamples > APVFloatSamples
Types for array of samples for processing.
Definition: DATCONSVDDigit.h:59
Belle2::SVDTrueHit
Class SVDTrueHit - Records of tracks that either enter or leave the sensitive volume.
Definition: SVDTrueHit.h:35
Belle2::RelationsInterface::addRelationTo
void addRelationTo(const RelationsInterface< BASE > *object, float weight=1.0, const std::string &namedRelation="") const
Add a relation from this object to another object (with caching).
Definition: RelationsObject.h:144
Belle2::SVDShaperDigitToDATCONSVDDigitConverterModule
SVDShaperDigitToDATCONSVDDigitConverterModule:
Definition: SVDShaperDigitToDATCONSVDDigitConverterModule.h:46
Belle2::DATCONSVDDigit
The DATCONSVDDigit class.
Definition: DATCONSVDDigit.h:44
Belle2::Module
Base class for Modules.
Definition: Module.h:74
Belle2::RelationVector
Class for type safe access to objects that are referred to in relations.
Definition: DataStore.h:38
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::RelationVector::weight
float weight(int index) const
Get weight with index.
Definition: RelationVector.h:120
Belle2::MCParticle
A Class to store the Monte Carlo particle information.
Definition: MCParticle.h:43