Belle II Software development
SVD3SamplesEmulatorModule.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#include <svd/modules/svdSimulation/SVD3SamplesEmulatorModule.h>
10
11using namespace Belle2;
12
13//-----------------------------------------------------------------
14// Register the Module
15//-----------------------------------------------------------------
16REG_MODULE(SVD3SamplesEmulator);
17
18//-----------------------------------------------------------------
19// Implementation
20//-----------------------------------------------------------------
21
23{
24 B2DEBUG(1, "Constructor");
25 // Set module properties
26 setDescription("This module takes the SVDShaperDigit as input and select three consecutive samples starting from the one chosen by the user. The modules creates a new StoreArray of the class ShaperDigit with three samples only, selected from the original ShaperDigits. The three samples are stored in the first three positions of the APVSamples store array, and the last three are set to 0.");
27
28 // Parameter definitions
29 addParam("SVDShaperDigits", m_shaperDigitInputName, "StoreArray with the input shaperdigits", std::string("SVDShaperDigits"));
30 addParam("SVDEventInfo", m_svdEventInfoName, "input SVDEventInfo name", std::string(""));
31 addParam("StartingSample", m_startingSample, "Starting sample of the three samples (between 0 and 3, the default is 0)", int(0));
32 addParam("outputSVDShaperDigits", m_outputArrayName, "StoreArray with the output shaperdigits with 3 samples",
33 std::string("SVDShaperDigit3Samples"));
34 addParam("outputSVDEventInfo", m_svdEventInfoOutName, "output SVDEventInfo name", std::string("SVDEventInfo3Samples"));
35 addParam("chooseStartingSample", m_chooseStartingSample,
36 "If you want to choose the starting sample manually set this parameter to True. Default is False.", false);
37 addParam("chooseRelativeShift", m_chooseRelativeShift,
38 "If you want to choose the relative shift sample manually set this parameter to True. Default is False, so the relative shift is taken from the original SVDEventInfoSim. Set this True and choose the right relative shift, if you are using data.",
39 false);
40 addParam("relativeShift", m_relativeShift,
41 "Set the relative shift manually. Default is 0", int(-1));
42}
43
47
48
50{
51
52 B2DEBUG(10, "SVDShaperDigits: " << m_shaperDigitInputName);
53 B2DEBUG(10, "StartingSample: " << m_startingSample);
54 B2DEBUG(10, "outputSVDShaperDigits: " << m_outputArrayName);
55 B2DEBUG(10, "outputSVDEventInfo: " << m_svdEventInfoOutName);
56 B2DEBUG(10, "chooseStartingSample: " << m_chooseStartingSample);
57 B2DEBUG(10, "chooseRelativeShift: " << m_chooseRelativeShift);
58 B2DEBUG(10, "relativeShift: " << m_relativeShift);
59
61 if (m_startingSample > 3 || m_startingSample < 0) {
62 B2FATAL("The starting sample must be between 0 and 3, you set = " << m_startingSample);
63 return;
64 }
65 B2DEBUG(28, "The starting sample from which to start to select the three samples: " << m_startingSample);
66 B2DEBUG(28, "The three samples selected are: " << m_startingSample << " " << m_startingSample + 1 << " " << m_startingSample + 2);
67 } else if (m_chooseRelativeShift) {
69 B2FATAL("The relative shift must be between 0 and 12, you set = " << m_relativeShift);
70 return;
71 }
72 B2DEBUG(28, "The chosen relative shift is: " << m_relativeShift);
73 B2DEBUG(28,
74 "The starting sample has not been chosen. It will be chosen automatically from the information of the trigger bin in SVDEventInfo and relative shift set");
75 B2DEBUG(28,
76 "If you want to choose the starting sample manually, set 'chooseStartingSample' parameter True, and 'StartingSample' parameter to the value of the starting sample you desire (between 0 and 3)");
77 } else {
78 B2DEBUG(28,
79 "The relative shift and the starting sample have not been chosen. The starting sample will be obtained automatically from the information of the trigger bin and relative shift in SVDEventInfo");
80 B2DEBUG(28,
81 "If you want to choose the starting sample manually, set 'chooseStartingSample' parameter True, and 'StartingSample' parameter to the value of the starting sample you desire (between 0 and 3)");
82 B2DEBUG(28,
83 "If you want to choose the relative shift manually, set 'chooseRelativeShift' parameter True, and 'relativeShift' parameter to the value you desire (between 0 and 15)");
84 }
85
88 ShaperDigit3Samples.registerInDataStore();
89
90 if (!m_storeSVDEvtInfo.isOptional(m_svdEventInfoName)) m_svdEventInfoName = "SVDEventInfoSim";
92
93 //Register the new EventInfo with ModeByte for 3 samples in the data store
95}
96
97
98
100{
101 if (!m_storeSVDEvtInfo.isValid()) B2ERROR("No valid SVDEventInfo object is present!");
102
103 SVDModeByte modeByte = m_storeSVDEvtInfo->getModeByte();
105
106 int DAQMode = modeByte.getDAQMode();
107 if (DAQMode != 2) {
108 B2FATAL("The DAQMode is = " << DAQMode << " The number of samples of the input shaperdigits is NOT 6!");
109 return;
110 }
111
113 m_storeSVDEvtInfo3samples->setTriggerType(m_storeSVDEvtInfo->getTriggerType());
114 modeByte.setDAQMode(int(1));
115 m_storeSVDEvtInfo3samples->setModeByte(modeByte);
118 } else {
119 m_storeSVDEvtInfo3samples->setRelativeShift(m_storeSVDEvtInfo->getRelativeShift());
120 }
121 m_storeSVDEvtInfo3samples->setNSamples(3);
122
123 for (const SVDShaperDigit& shaper : m_ShaperDigit) {
124
125 Belle2::SVDShaperDigit::APVFloatSamples samples = shaper.getSamples();
126 VxdID sensorID = shaper.getSensorID();
127 bool side = shaper.isUStrip();
128 int cellID = shaper.getCellID();
129 int8_t fadcT = shaper.getFADCTime();
130
132
134 threeSamples[0] = samples[m_startingSample];
135 threeSamples[1] = samples[m_startingSample + 1];
136 threeSamples[2] = samples[m_startingSample + 2];
137 threeSamples[3] = 0.;
138 threeSamples[4] = 0.;
139 threeSamples[5] = 0.;
140 } else {
141 int startingSample = getFirstSample(modeByte);
142 threeSamples[0] = samples[startingSample];
143 threeSamples[1] = samples[startingSample + 1];
144 threeSamples[2] = samples[startingSample + 2];
145 threeSamples[3] = 0.;
146 threeSamples[4] = 0.;
147 threeSamples[5] = 0.;
148 }
149 ShaperDigit3Samples.appendNew(sensorID, side, cellID, threeSamples, fadcT);
150
151 }
152}
153
155{
156 int nTriggerClocks = 0;
158 nTriggerClocks = modeByte.getTriggerBin() + m_relativeShift;
159 } else {
160 nTriggerClocks = modeByte.getTriggerBin() + m_storeSVDEvtInfo->getRelativeShift();
161 }
162 return floor(nTriggerClocks / 4);
163}
164
165
@ c_ErrorIfAlreadyRegistered
If the object/array was already registered, produce an error (aborting initialisation).
Definition DataStore.h:72
void setDescription(const std::string &description)
Sets the description of the module.
Definition Module.cc:214
Module()
Constructor.
Definition Module.cc:30
std::string m_shaperDigitInputName
name of the input ShaperDigits StoreArray
virtual void initialize() override
init the module
virtual void event() override
processes the event
StoreObjPtr< SVDEventInfo > m_storeSVDEvtInfo3samples
storage for SVDEventInfo object produced for 3 samples
bool m_chooseRelativeShift
Set it True if you want to choose the relative shift manually.
std::string m_svdEventInfoName
Name of the input SVDEventInfo object.
std::string m_svdEventInfoOutName
Name of the output SVDEventInfo object.
int getFirstSample(const SVDModeByte modeByte)
return the starting sample
bool m_chooseStartingSample
Set it True if you want to choose the starting sample manually.
StoreArray< SVDShaperDigit > m_ShaperDigit
StoreArray with the 6-samples input shaperdigits with DAQMode = 2.
virtual ~SVD3SamplesEmulatorModule() override
if required
Int_t m_startingSample
Starting sample from which select the three samples of the initial six.
StoreObjPtr< SVDEventInfo > m_storeSVDEvtInfo
storage for SVDEventInfo object required for the module
SVD3SamplesEmulatorModule()
Constructor: Sets the description, the properties and the parameters of the module.
std::string m_outputArrayName
StoreArray with the 3-samples output shaperdigits, with DAQMode = 1.
Class to store SVD mode information.
Definition SVDModeByte.h:69
void setDAQMode(baseType daqMode)
Set the daqMode id.
baseType getTriggerBin() const
Get the triggerBin id.
baseType getDAQMode() const
Get the daqMode id.
The SVD ShaperDigit class.
std::array< APVFloatSampleType, c_nAPVSamples > APVFloatSamples
array of APVFloatSampleType objects
bool registerInDataStore(DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut)
Register the object/array in the DataStore.
Accessor to arrays stored in the data store.
Definition StoreArray.h:113
T * appendNew()
Construct a new T object at the end of the array.
Definition StoreArray.h:247
Class to uniquely identify a any structure of the PXD and SVD.
Definition VxdID.h:32
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:559
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition Module.h:649
Abstract base class for different kinds of events.