11 #include <tracking/modules/DATCON/DATCONSVDSimpleClusterizerModule.h>
13 #include <svd/geometry/SensorInfo.h>
31 setDescription(
"Clusterize DATCONSVDDigits");
32 setPropertyFlags(c_ParallelProcessingCertified);
35 addParam(
"DATCONSVDDigits", m_storeDATCONSVDDigitsListName,
36 "DATCONSVDDigits collection name",
string(
"DATCONSVDDigits"));
37 addParam(
"DATCONSVDCluster", m_storeDATCONSVDClustersName,
38 "DATCONSVDCluster collection name",
string(
"DATCONSVDCluster"));
39 addParam(
"SVDTrueHits", m_storeTrueHitsName,
40 "TrueHit collection name",
string(
""));
41 addParam(
"MCParticles", m_storeMCParticlesName,
42 "MCParticles collection name",
string(
""));
45 addParam(
"NoiseLevelADU", m_NoiseLevelInADU,
46 "Simple assumption of the noise level of the sensors in ADU's", (
unsigned short)(5));
47 addParam(
"NoiseCutADU", m_NoiseCutInADU,
48 "Simple assumption of the noise level of the sensors in ADU's", (
unsigned short)(5));
49 addParam(
"useSimpleClustering", m_useSimpleClustering,
50 "Use the simple clustering that is currently done on FPGA for phase 2",
bool(
true));
51 addParam(
"maxClusterSize", m_maxClusterSize,
52 "Maximum cluster size in count of strips.", (
unsigned short)(6));
57 void DATCONSVDSimpleClusterizerModule::initialize()
60 storeDATCONSVDCluster.registerInDataStore(m_storeDATCONSVDClustersName, DataStore::c_DontWriteOut);
61 m_storeDATCONSVDClustersName = storeDATCONSVDCluster.getName();
63 storeDATCONSVDDigits.isRequired(m_storeDATCONSVDDigitsListName);
64 m_storeDATCONSVDDigitsListName = storeDATCONSVDDigits.getName();
66 storeDATCONSVDCluster.registerRelationTo(storeDATCONSVDDigits, DataStore::c_Event, DataStore::c_DontWriteOut);
68 storeTrueHits.isOptional(m_storeTrueHitsName);
69 if (storeTrueHits.isValid()) {
70 m_storeTrueHitsName = storeTrueHits.getName();
71 storeDATCONSVDCluster.registerRelationTo(storeTrueHits, DataStore::c_Event, DataStore::c_DontWriteOut);
74 storeMCParticles.isOptional(m_storeMCParticlesName);
75 if (storeMCParticles.isValid()) {
76 m_storeMCParticlesName = storeMCParticles.getName();
77 storeDATCONSVDCluster.registerRelationTo(storeMCParticles, DataStore::c_Event, DataStore::c_DontWriteOut);
84 void DATCONSVDSimpleClusterizerModule::event()
86 int nDigits = storeDATCONSVDDigits.getEntries();
90 storeDATCONSVDCluster.clear();
91 clusterCandidates.clear();
97 unsigned short digitindex = 0;
100 for (
auto& datconsvddigit : storeDATCONSVDDigits) {
102 if (!noiseFilter(datconsvddigit)) {
109 VxdID thisSensorID = datconsvddigit.getSensorID();
110 bool thisSide = datconsvddigit.isUStrip();
111 unsigned short thisCellID = datconsvddigit.getCellID();
112 unsigned short thisCharge = datconsvddigit.getMaxSampleCharge();
115 if (! clusterCandidate.
add(thisSensorID, thisSide, digitindex, thisCharge, thisCellID)) {
117 if (clusterCandidate.
size() > 0) {
118 if (m_useSimpleClustering) {
121 B2WARNING(
"This one is not yet implemented, so no DATCONSVDCluster will be created! Skipping...");
124 clusterCandidates.push_back(clusterCandidate);
132 if (! clusterCandidate.
add(thisSensorID, thisSide, digitindex, thisCharge, thisCellID))
133 B2WARNING(
"this state is forbidden!!");
139 if (clusterCandidate.
size() > 0) {
140 if (m_useSimpleClustering) {
143 B2WARNING(
"This one is not yet implemented, so no DATCONSVDCluster will be created! Skipping...");
146 clusterCandidates.push_back(clusterCandidate);
151 B2DEBUG(1,
"Number of clusters: " << storeDATCONSVDCluster.getEntries());
155 void DATCONSVDSimpleClusterizerModule::saveClusters()
158 for (
auto clustercandit = clusterCandidates.begin(); clustercandit != clusterCandidates.end(); clustercandit++) {
163 bool isU = clustercand.
isUSide();
165 unsigned short clusterSeedCharge = clustercand.
getSeedCharge();
166 unsigned short clusterCharge = clustercand.
getCharge();
167 unsigned short clusterSize = clustercand.
size();
169 float clusterPositionError = 0;
179 if (clusterSize == 1) {
180 clusterPositionError = pitch / sqrt(12.);
181 }
else if (clusterSize == 2) {
182 clusterPositionError = pitch / 2.;
183 }
else if (clusterSize > 2) {
184 clusterPositionError = pitch;
188 storeDATCONSVDCluster.appendNew(
SVDCluster(sensorID, isU, clusterPosition, clusterPositionError,
189 0.0, 0.0, clusterCharge, clusterSeedCharge, clusterSize, 0.0, 0.0));
193 for (
auto digitindexit = indices.begin(); digitindexit != indices.end(); digitindexit++) {
195 DATCONSVDDigit* datconsvddigit = storeDATCONSVDDigits[*digitindexit];
203 if (relatedMC.
size() > 0) {
204 for (
unsigned int relmcindex = 0; relmcindex < relatedMC.
size(); relmcindex++) {
208 if (relatedSVDTrue.size() > 0) {
209 for (
unsigned int reltruehitindex = 0; reltruehitindex < relatedSVDTrue.size(); reltruehitindex++) {
210 datconSVDCluster->
addRelationTo(relatedSVDTrue[reltruehitindex], relatedSVDTrue.weight(reltruehitindex));
223 bool DATCONSVDSimpleClusterizerModule::noiseFilter(
DATCONSVDDigit datconsvddigit)
225 bool passNoiseFilter =
false;
229 unsigned short noiseCut = m_NoiseCutInADU;
231 if (sample[maxSampleIndex] <= m_NoiseLevelInADU ) {
238 if (maxSampleIndex > 0 && maxSampleIndex < (sample.size() - 1)) {
239 if (sample[maxSampleIndex - 1] >= noiseCut && sample[maxSampleIndex + 1] >= noiseCut) {
240 passNoiseFilter =
true;
244 return passNoiseFilter;