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 choosen by the user. The modules creates a new StoreArray of the class ShaperDigit whit 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. Defauls is False.", false);
37 addParam("chooseRelativeShift", m_chooseRelativeShift,
38 "If you want to choose the relative shift sample manually set this parameter to True. Defauls 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
45{
46}
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) {
68 if (m_relativeShift < 0 || m_relativeShift > 12) {
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
99{
100}
101
102
104{
105 if (!m_storeSVDEvtInfo.isValid()) B2ERROR("No valid SVDEventInfo object is present!");
106
107 SVDModeByte modeByte = m_storeSVDEvtInfo->getModeByte();
109
110 int DAQMode = modeByte.getDAQMode();
111 if (DAQMode != 2) {
112 B2FATAL("The DAQMode is = " << DAQMode << " The number of samples of the input shaperdigits is NOT 6!");
113 return;
114 }
115
117 m_storeSVDEvtInfo3samples->setTriggerType(m_storeSVDEvtInfo->getTriggerType());
118 modeByte.setDAQMode(int(1));
119 m_storeSVDEvtInfo3samples->setModeByte(modeByte);
122 } else {
123 m_storeSVDEvtInfo3samples->setRelativeShift(m_storeSVDEvtInfo->getRelativeShift());
124 }
125 m_storeSVDEvtInfo3samples->setNSamples(3);
126
127 for (const SVDShaperDigit& shaper : m_ShaperDigit) {
128
129 Belle2::SVDShaperDigit::APVFloatSamples samples = shaper.getSamples();
130 VxdID sensorID = shaper.getSensorID();
131 bool side = shaper.isUStrip();
132 int cellID = shaper.getCellID();
133 int8_t fadcT = shaper.getFADCTime();
134
136
138 threeSamples[0] = samples[m_startingSample];
139 threeSamples[1] = samples[m_startingSample + 1];
140 threeSamples[2] = samples[m_startingSample + 2];
141 threeSamples[3] = 0.;
142 threeSamples[4] = 0.;
143 threeSamples[5] = 0.;
144 } else {
145 int startingSample = getFirstSample(modeByte);
146 threeSamples[0] = samples[startingSample];
147 threeSamples[1] = samples[startingSample + 1];
148 threeSamples[2] = samples[startingSample + 2];
149 threeSamples[3] = 0.;
150 threeSamples[4] = 0.;
151 threeSamples[5] = 0.;
152 }
153 ShaperDigit3Samples.appendNew(sensorID, side, cellID, threeSamples, fadcT);
154
155 }
156}
157
159{
160}
161
163{
164}
165
167{
168 int nTriggerClocks = 0;
170 nTriggerClocks = modeByte.getTriggerBin() + m_relativeShift;
171 } else {
172 nTriggerClocks = modeByte.getTriggerBin() + m_storeSVDEvtInfo->getRelativeShift();
173 }
174 return floor(nTriggerClocks / 4);
175}
176
177
@ c_ErrorIfAlreadyRegistered
If the object/array was already registered, produce an error (aborting initialisation).
Definition: DataStore.h:72
Base class for Modules.
Definition: Module.h:72
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
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
virtual void endRun() override
end the run
virtual void terminate() override
terminates the module
bool m_chooseRelativeShift
Set it True if you want to choose the relative shift manually.
virtual void beginRun() override
initializes the module
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.
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.
Definition: SVDModeByte.h:172
baseType getTriggerBin() const
Get the triggerBin id.
Definition: SVDModeByte.h:140
baseType getDAQMode() const
Get the daqMode id.
Definition: SVDModeByte.h:142
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:246
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:33
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition: Module.h:560
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
Abstract base class for different kinds of events.