Belle II Software  release-05-02-19
SVD3SamplesEmulatorModule.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2013 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Luigi Corona *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include <svd/modules/svdSimulation/SVD3SamplesEmulatorModule.h>
12 
13 using namespace Belle2;
14 
15 //-----------------------------------------------------------------
16 // Register the Module
17 //-----------------------------------------------------------------
18 REG_MODULE(SVD3SamplesEmulator)
19 
20 //-----------------------------------------------------------------
21 // Implementation
22 //-----------------------------------------------------------------
23 
25 {
26  B2DEBUG(1, "Constructor");
27  // Set module properties
28  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.");
29 
30  // Parameter definitions
31  addParam("SVDShaperDigits", m_shaperDigitInputName, "StoreArray with the input shaperdigits", std::string("SVDShaperDigits"));
32  addParam("StartingSample", m_startingSample, "Starting sample of the three samples (between 0 and 3, the default is 0)", int(0));
33  addParam("outputArrayName", m_outputArrayName, "StoreArray with the output shaperdigits with 3 samples",
34  std::string("SVDShaperDigit3Samples"));
35  addParam("SVDEventInfo", m_svdEventInfoName, "SVDEventInfo name", std::string(""));
36 }
37 
39 {
40  B2DEBUG(20, "Destructor");
41 }
42 
43 
45 {
46  if (m_startingSample > 3 || m_startingSample < 0) {
47  B2FATAL("The starting sample must be between 0 and 3, you set = " << m_startingSample);
48  return;
49  }
50 
51  B2DEBUG(10, "SVDShaperDigits: " << m_shaperDigitInputName);
52  B2DEBUG(10, "StartingSample: " << m_startingSample);
53  B2DEBUG(10, "outputArrayName: " << m_outputArrayName);
54 
55  B2INFO("The starting sample from which start to select the three samples: " << m_startingSample);
56  B2INFO("The three samples selected are: " << m_startingSample << " " << m_startingSample + 1 << " " << m_startingSample + 2);
57 
59  StoreArray<SVDShaperDigit> ShaperDigit3Samples(m_outputArrayName);
60  ShaperDigit3Samples.registerInDataStore();
61 
62  if (!m_storeSVDEvtInfo.isOptional(m_svdEventInfoName)) m_svdEventInfoName = "SVDEventInfoSim";
64 
65  //Register the new EventInfo with ModeByte for 3 samples in the data store
66  m_storeSVDEvtInfo3samples.registerInDataStore("SVDEventInfo3samples", DataStore::c_ErrorIfAlreadyRegistered);
67 }
68 
69 
71 {
72 }
73 
74 
76 {
77  if (!m_storeSVDEvtInfo.isValid()) B2ERROR("No valid SVDEventInfo object is present!");
78 
79  SVDModeByte modeByte = m_storeSVDEvtInfo->getModeByte();
80  StoreArray<SVDShaperDigit> ShaperDigit3Samples(m_outputArrayName);
81 
82  int DAQMode = modeByte.getDAQMode();
83  if (DAQMode != 2) {
84  B2FATAL("The DAQMode is = " << DAQMode << " The number of samples of the input shaperdigits is NOT 6!");
85  return;
86  }
87 
89  m_storeSVDEvtInfo3samples->setTriggerType(m_storeSVDEvtInfo->getTriggerType());
90  modeByte.setDAQMode(1);
91  m_storeSVDEvtInfo3samples->setModeByte(modeByte);
92 
93 
94  for (const SVDShaperDigit& shaper : m_ShaperDigit) {
95 
96  Belle2::SVDShaperDigit::APVFloatSamples samples = shaper.getSamples();
97  VxdID sensorID = shaper.getSensorID();
98  bool side = shaper.isUStrip();
99  int cellID = shaper.getCellID();
100  int8_t fadcT = shaper.getFADCTime();
101 
103 
104  threeSamples[0] = samples[m_startingSample];
105  threeSamples[1] = samples[m_startingSample + 1];
106  threeSamples[2] = samples[m_startingSample + 2];
107  threeSamples[3] = 0.;
108  threeSamples[4] = 0.;
109  threeSamples[5] = 0.;
110 
111  ShaperDigit3Samples.appendNew(sensorID, side, cellID, threeSamples, fadcT, modeByte);
112  // SVDShaperDigit* shaperThree = ShaperDigit3Samples.appendNew(sensorID, side, cellID, threeSamples, fadcT, modeByte);
113  // SVDModeByte threeModeByte = shaperThree->getModeByte();
114  // int daq = threeModeByte.getDAQMode();
115  //
116  // SVDModeByte modeByteAfterSettingNew = shaper.getModeByte();
117  // int DAQModeAfterSettingNew = modeByteAfterSettingNew.getDAQMode();
118  // B2INFO("ModeByte: " << modeByteAfterSettingNew);
119  // B2INFO("DAQMode After Setting New One: " << DAQModeAfterSettingNew);
120  // B2INFO("DAQMode Of the new ShaperDigit: " << daq);
121 
122  }
123 }
124 
126 {
127 }
128 
130 {
131 }
Belle2::StoreArray::appendNew
T * appendNew()
Construct a new T object at the end of the array.
Definition: StoreArray.h:256
Belle2::SVD3SamplesEmulatorModule
This module takes the SVDShaperDigit as input and select three consecutive samples starting from the ...
Definition: SVD3SamplesEmulatorModule.h:40
Belle2::VxdID
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:43
Belle2::SVD3SamplesEmulatorModule::m_storeSVDEvtInfo
StoreObjPtr< SVDEventInfo > m_storeSVDEvtInfo
storage for SVDEventInfo object required for the module
Definition: SVD3SamplesEmulatorModule.h:70
REG_MODULE
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:652
Belle2::SVD3SamplesEmulatorModule::m_storeSVDEvtInfo3samples
StoreObjPtr< SVDEventInfo > m_storeSVDEvtInfo3samples
storage for SVDEventInfo object produced for 3 samples
Definition: SVD3SamplesEmulatorModule.h:71
Belle2::SVD3SamplesEmulatorModule::beginRun
virtual void beginRun() override
initializes the module
Definition: SVD3SamplesEmulatorModule.cc:70
Belle2::SVDModeByte
Class to store SVD mode information.
Definition: SVDModeByte.h:79
Belle2::SVDModeByte::getDAQMode
baseType getDAQMode() const
Get the daqMode id.
Definition: SVDModeByte.h:152
Belle2::SVDShaperDigit
The SVD ShaperDigit class.
Definition: SVDShaperDigit.h:46
Belle2::Module
Base class for Modules.
Definition: Module.h:74
Belle2::SVDShaperDigit::APVFloatSamples
std::array< APVFloatSampleType, c_nAPVSamples > APVFloatSamples
array of APVFloatSampleType objects
Definition: SVDShaperDigit.h:63
Belle2::SVD3SamplesEmulatorModule::m_outputArrayName
std::string m_outputArrayName
StoreArray with the 3-samples output shaperdigits, with DAQMode = 1.
Definition: SVD3SamplesEmulatorModule.h:73
Belle2::SVDModeByte::setDAQMode
void setDAQMode(baseType daqMode)
Set the daqMode id.
Definition: SVDModeByte.h:182
Belle2::SVD3SamplesEmulatorModule::m_svdEventInfoName
std::string m_svdEventInfoName
Name of the SVDEventInfo object.
Definition: SVD3SamplesEmulatorModule.h:74
Belle2::SVD3SamplesEmulatorModule::event
virtual void event() override
processes the event
Definition: SVD3SamplesEmulatorModule.cc:75
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::SVD3SamplesEmulatorModule::terminate
virtual void terminate() override
terminates the module
Definition: SVD3SamplesEmulatorModule.cc:129
Belle2::SVD3SamplesEmulatorModule::m_shaperDigitInputName
std::string m_shaperDigitInputName
name of the input ShaperDigits StoreArray
Definition: SVD3SamplesEmulatorModule.h:69
Belle2::SVD3SamplesEmulatorModule::initialize
virtual void initialize() override
init the module
Definition: SVD3SamplesEmulatorModule.cc:44
Belle2::SVD3SamplesEmulatorModule::~SVD3SamplesEmulatorModule
virtual ~SVD3SamplesEmulatorModule()
if required
Definition: SVD3SamplesEmulatorModule.cc:38
Belle2::DataStore::c_ErrorIfAlreadyRegistered
@ c_ErrorIfAlreadyRegistered
If the object/array was already registered, produce an error (aborting initialisation).
Definition: DataStore.h:74
Belle2::StoreArray
Accessor to arrays stored in the data store.
Definition: ECLMatchingPerformanceExpertModule.h:33
Belle2::SVD3SamplesEmulatorModule::m_startingSample
Int_t m_startingSample
Starting sample from which select the three samples of the initial six.
Definition: SVD3SamplesEmulatorModule.h:72
Belle2::SVD3SamplesEmulatorModule::endRun
virtual void endRun() override
end the run
Definition: SVD3SamplesEmulatorModule.cc:125
Belle2::SVD3SamplesEmulatorModule::m_ShaperDigit
StoreArray< SVDShaperDigit > m_ShaperDigit
StoreArray with the 6-samples input shaperdigits with DAQMode = 2.
Definition: SVD3SamplesEmulatorModule.h:68