9 #include <svd/modules/svdReconstruction/SVDRecoDigitCreatorModule.h>
11 #include <framework/core/Environment.h>
12 #include <framework/datastore/DataStore.h>
13 #include <framework/logging/LogConfig.h>
14 #include <framework/logging/Logger.h>
16 #include <svd/dataobjects/SVDEventInfo.h>
18 #include <svd/reconstruction/SVDReconstructionBase.h>
20 #include <svd/reconstruction/SVDRecoTimeFactory.h>
21 #include <svd/reconstruction/SVDRecoChargeFactory.h>
41 setDescription(
"This module reconstructs SVDShaperDigit in SVDRecoDigit, i.e. calibrated strip with reconstructed charge and time.");
42 setPropertyFlags(c_ParallelProcessingCertified);
45 addParam(
"ShaperDigits", m_storeShaperDigitsName,
46 "SVDShaperDigits collection name.",
string(
""));
47 addParam(
"RecoDigits", m_storeRecoDigitsName,
48 "SVDRecoDigits collection name.",
string(
""));
49 addParam(
"Clusters", m_storeClustersName,
50 "SVDCluster collection name.",
string(
""));
53 addParam(
"timeAlgorithm6Samples", m_timeRecoWith6SamplesAlgorithm,
54 "strip-time reconstruction algorithm for the 6-sample DAQ mode: CoG6 = 6-sample CoG (default), CoG3 = 3-sample CoG, ELS3 = 3-sample ELS",
55 std::string(
"inRecoDBObject"));
56 addParam(
"timeAlgorithm3Samples", m_timeRecoWith3SamplesAlgorithm,
57 "strip-time reconstruction algorithm for the 3-sample DAQ mode: CoG6 = 6-sample CoG, CoG3 = 3-sample CoG (default), ELS3 = 3-sample ELS",
58 std::string(
"inRecoDBObject"));
59 addParam(
"chargeAlgorithm6Samples", m_chargeRecoWith6SamplesAlgorithm,
60 " choose charge algorithm for 6-sample DAQ mode: MaxSample (default), SumSamples, ELS3 = 3-sample ELS",
61 std::string(
"inRecoDBObject"));
62 addParam(
"chargeAlgorithm3Samples", m_chargeRecoWith3SamplesAlgorithm,
63 " choose charge algorithm for 3-sample DAQ mode: MaxSample (default), SumSamples, ELS3 = 3-sample ELS",
64 std::string(
"inRecoDBObject"));
66 addParam(
"useDB", m_useDB,
67 "if false use clustering and reconstruction configuration module parameters", m_useDB);
71 void SVDRecoDigitCreatorModule::beginRun()
75 if (!m_recoConfig.isValid())
76 B2FATAL(
"no valid configuration found for SVD reconstruction");
78 B2INFO(
"SVDRecoConfiguration: from now on we are using " << m_recoConfig->get_uniqueID());
80 m_timeRecoWith6SamplesAlgorithm = m_recoConfig->getStripTimeRecoWith6Samples();
81 m_timeRecoWith3SamplesAlgorithm = m_recoConfig->getStripTimeRecoWith3Samples();
82 m_chargeRecoWith6SamplesAlgorithm = m_recoConfig->getStripChargeRecoWith6Samples();
83 m_chargeRecoWith3SamplesAlgorithm = m_recoConfig->getStripChargeRecoWith3Samples();
90 B2WARNING(
"strip time algorithm " << m_timeRecoWith6SamplesAlgorithm <<
" is NOT available, using CoG6");
91 m_timeRecoWith6SamplesAlgorithm =
"CoG6";
95 B2WARNING(
"strip time algorithm " << m_timeRecoWith3SamplesAlgorithm <<
" is NOT available, using CoG3");
96 m_timeRecoWith3SamplesAlgorithm =
"CoG3";
99 B2WARNING(
"strip charge algorithm " << m_chargeRecoWith6SamplesAlgorithm <<
" is NOT available, using MaxSample");
100 m_chargeRecoWith6SamplesAlgorithm =
"MaxSample";
103 B2WARNING(
"strip charge algorithm " << m_chargeRecoWith3SamplesAlgorithm <<
" is NOT available, using MaxSample");
104 m_chargeRecoWith3SamplesAlgorithm =
"MaxSample";
107 bool returnRawClusterTime =
false;
108 m_time6SampleClass = SVDRecoTimeFactory::NewTime(m_timeRecoWith6SamplesAlgorithm, returnRawClusterTime);
109 m_time3SampleClass = SVDRecoTimeFactory::NewTime(m_timeRecoWith3SamplesAlgorithm, returnRawClusterTime);
110 m_charge6SampleClass = SVDRecoChargeFactory::NewCharge(m_chargeRecoWith6SamplesAlgorithm);
111 m_charge3SampleClass = SVDRecoChargeFactory::NewCharge(m_chargeRecoWith3SamplesAlgorithm);
113 B2INFO(
"SVD 6-sample DAQ SVDRecoDigit, time algorithm: " << m_timeRecoWith6SamplesAlgorithm <<
", charge algorithm: " <<
114 m_chargeRecoWith6SamplesAlgorithm);
116 B2INFO(
"SVD 3-sample DAQ SVDRecoDigit, time algorithm: " << m_timeRecoWith3SamplesAlgorithm <<
", charge algorithm: " <<
117 m_chargeRecoWith3SamplesAlgorithm);
121 void SVDRecoDigitCreatorModule::initialize()
124 m_storeReco.registerInDataStore(m_storeRecoDigitsName, DataStore::c_ErrorIfAlreadyRegistered);
125 m_storeClusters.isOptional(m_storeClustersName);
126 m_storeShaper.isOptional(m_storeShaperDigitsName);
128 m_storeReco.registerRelationTo(m_storeShaper);
129 m_storeClusters.registerRelationTo(m_storeReco);
132 m_storeClustersName = m_storeClusters.getName();
133 m_storeShaperDigitsName = m_storeShaper.getName();
136 B2DEBUG(25,
"SVDRecoDigitCreator Parameters (in default system unit, *=cannot be set directly):");
138 B2DEBUG(25,
" 1. COLLECTIONS:");
139 B2DEBUG(25,
" --> SVDShaperDigits: " << DataStore::arrayName<SVDShaperDigit>(m_storeShaperDigitsName));
140 B2DEBUG(25,
" --> SVDRecoDigits: " << DataStore::arrayName<SVDRecoDigit>(m_storeRecoDigitsName));
141 B2DEBUG(25,
" --> SVDClusters: " << DataStore::arrayName<SVDCluster>(m_storeClustersName));
144 void SVDRecoDigitCreatorModule::event()
148 std::string m_svdEventInfoName =
"SVDEventInfo";
150 m_svdEventInfoName =
"SVDEventInfoSim";
153 if (Environment::Instance().getRealm() == LogConfig::c_Online) {
155 B2WARNING(
"No SVDEventInfo object in this event: SVD is excluded, so don't worry");
159 B2FATAL(
"No SVDEventInfo object in this event: something went wrong");
163 int numberOfAcquiredSamples = eventinfo->getNSamples();
165 int nShaperDigits = m_storeShaper.getEntries();
168 for (
int i = 0; i < nShaperDigits; ++i) {
170 VxdID sensorID = m_storeShaper[i]->getSensorID();
171 bool isU = m_storeShaper[i]->isUStrip();
172 int cellID = m_storeShaper[i]->getCellID();
179 strip.
maxSample = m_storeShaper[i]->getMaxADCCounts();
180 strip.
noise = m_NoiseCal.getNoise(sensorID, isU, cellID);
181 strip.
samples = m_storeShaper[i]->getSamples();;
182 strip.
charge = std::numeric_limits<double>::quiet_NaN();;
183 strip.
time = std::numeric_limits<double>::quiet_NaN();;
185 if (rawCluster.
add(sensorID, rawCluster.
isUSide(), strip)) {
187 double time = std::numeric_limits<float>::quiet_NaN();
188 double timeError = std::numeric_limits<float>::quiet_NaN();
189 double charge = std::numeric_limits<float>::quiet_NaN();
190 float chargeError = std::numeric_limits<float>::quiet_NaN();
191 int firstFrame = std::numeric_limits<int>::quiet_NaN();
192 std::vector<float> probabilities = {0.5};
193 double chi2 = std::numeric_limits<double>::quiet_NaN();
196 double SNR = std::numeric_limits<double>::quiet_NaN();
197 double seedCharge = std::numeric_limits<double>::quiet_NaN();
199 if (numberOfAcquiredSamples == 6) {
202 m_time6SampleClass->computeClusterTime(rawCluster, time, timeError, firstFrame);
204 m_charge6SampleClass->computeClusterCharge(rawCluster, charge, SNR, seedCharge);
205 }
else if (numberOfAcquiredSamples == 3) {
207 m_time3SampleClass->computeClusterTime(rawCluster, time, timeError, firstFrame);
210 m_charge3SampleClass->computeClusterCharge(rawCluster, charge, SNR, seedCharge);
213 B2ERROR(
"SVD Reconstruction not available for this strip: not supported number of acquired APV samples!!");
216 time = eventinfo->getTimeInFTSWReference(time, firstFrame);
219 SVDRecoDigit* recoDigit = m_storeReco.appendNew(sensorID, isU, cellID, charge, chargeError, time, timeError, probabilities, chi2);
225 cluster->addRelationTo(recoDigit, recoDigit->
getCharge());
231 void SVDRecoDigitCreatorModule::endRun()
234 delete m_time6SampleClass;
235 delete m_time3SampleClass;
236 delete m_charge6SampleClass;
237 delete m_charge3SampleClass;
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).
The SVD Cluster class This class stores all information about reconstructed SVD clusters.
float getCharge() const
Get amplitude estimate, alternate getter name.
Class representing a raw cluster candidate during clustering of the SVD.
bool add(VxdID vxdID, bool isUside, struct StripInRawCluster &aStrip)
Add a Strip to the current cluster.
The SVD RecoDigit Creator.
Class to check whether the reconstruction algorithms are available or not.
bool isChargeAlgorithmAvailable(TString chargeAlg)
bool isTimeAlgorithmAvailable(TString timeAlg)
Type-safe access to single objects in the data store.
bool isValid() const
Check whether the object was created.
Class to uniquely identify a any structure of the PXD and SVD.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Namespace to encapsulate code needed for simulation and reconstrucion of the SVD.
Abstract base class for different kinds of events.
structure containing the relevant informations of each strip of the raw cluster
double charge
strip charge
Belle2::SVDShaperDigit::APVFloatSamples samples
ADC of the acquired samples.
int shaperDigitIndex
index of the shaper digit
int maxSample
ADC max of the acquired samples.