9#include <svd/modules/svdCrossTalkFinder/SVDCrossTalkFinderModule.h>
10#include <svd/modules/svdCrossTalkFinder/SVDCrossTalkFinderHelperFunctions.h>
12#include <vxd/geometry/GeoCache.h>
19SVDCrossTalkFinderModule::SVDCrossTalkFinderModule() :
Module()
22 setDescription(
"Detect SVDRecoDigits created from cross-talk present in the origami sensors");
24 setPropertyFlags(c_ParallelProcessingCertified);
26 addParam(
"SVDRecoDigits", m_svdRecoDigitsName,
27 "SVDRecoDigit collection name",
string(
""));
29 addParam(
"createCalibrationPayload", m_createCalibrationPayload,
30 "Create cross-talk strip channel payload",
true);
32 addParam(
"outputFilename", m_outputFilename,
33 "Filename of root file for calibration payload", std::string(
"crossTalkStripsCalibration.root"));
35 addParam(
"uSideOccupancyFactor", m_uSideOccupancyFactor,
36 "Multiple of the average occupancy for high occupancy strip classification", 2);
38 addParam(
"vSideOccupancyFactor", m_vSideOccupancyFactor,
39 "Multiple of the average occupancy for high occupancy strip classification", 2);
41 addParam(
"nAPVFactor", m_nAPVFactor,
42 "Number of APV chips with at least one high occupancy strips in event required for cross talk flag", 30);
51 std::string sensorName;
57 for (
auto& sensors : geo.
getSensors(ladders)) {
58 for (
int side = 0; side <= 1; side++) {
61 if (layers.getLayerNumber() == 3 or side == 1) {
62 sensorHist =
new TH1F(sensorName.c_str(),
"", 768, 0, 768);
64 sensorHist =
new TH1F(sensorName.c_str(),
"", 512, 0, 512);
85 vector<std::string> highOccChips_uSide ;
86 vector<std::string> highOccChips_vSide ;
87 vector<std::string> highOccChipsStripNum_uSide ;
88 vector<std::string> highOccChipsStripNum_vSide ;
89 vector<std::string> clusterStrips_uSide ;
90 vector<std::string> clusterStrips_vSide ;
91 vector<std::string> clusterChips_uSide ;
92 vector<int> strips_uSide;
93 vector<int> strips_vSide;
97 if (svdRecoDigit.getSensorID().getLayerNumber() == 3 or svdRecoDigit.getSensorID().getSensorNumber() == 1) {
101 int side = svdRecoDigit.isUStrip();
102 std::string sensorName;
105 double sensorAverage = 0.;
107 int stripID = svdRecoDigit.getCellID();
108 std::string sensorStripNum = sensorName +
"." + std::to_string(stripID);
114 int adjacentStrip = 0;
115 if (!strips_uSide.empty()) {
116 adjacentStrip = stripID - strips_uSide.back();
118 strips_uSide.push_back(stripID);
119 if (!highOccChips_uSide.empty() && sensorName == highOccChips_uSide.back() && adjacentStrip == 1) {
120 clusterChips_uSide.push_back(sensorName);
121 if (clusterStrips_uSide.empty() || clusterStrips_uSide.back() != sensorStripNum) {
122 clusterStrips_uSide.push_back(highOccChipsStripNum_uSide.back());
124 clusterStrips_uSide.push_back(sensorStripNum);
126 highOccChipsStripNum_uSide.push_back(sensorStripNum);
127 highOccChips_uSide.push_back(sensorName);
131 int adjacentStrip = 0;
132 if (!strips_vSide.empty()) {
133 adjacentStrip = stripID - strips_vSide.back();
135 strips_vSide.push_back(stripID);
136 if (!highOccChips_vSide.empty() && sensorName == highOccChips_vSide.back() && adjacentStrip == 1) {
137 if (clusterStrips_vSide.empty() || clusterStrips_vSide.back() != sensorStripNum) {
138 clusterStrips_vSide.push_back(highOccChipsStripNum_vSide.back());
140 clusterStrips_vSide.push_back(sensorStripNum);
142 highOccChipsStripNum_vSide.push_back(sensorStripNum);
143 highOccChips_vSide.push_back(sensorName);
148 std::sort(clusterChips_uSide.begin(), clusterChips_uSide.end());
149 clusterChips_uSide.erase(unique(clusterChips_uSide.begin(), clusterChips_uSide.end()), clusterChips_uSide.end());
150 int numberOfClusterChips = std::distance(clusterChips_uSide.begin(), std::unique(clusterChips_uSide.begin(),
151 clusterChips_uSide.end()));
157 std::string sensorID = svdRecoDigit.getSensorID();
158 std::string digitID = sensorID +
"." + std::to_string(svdRecoDigit.isUStrip());
159 std::string stripID = digitID +
"." + std::to_string(svdRecoDigit.getCellID());
161 if (std::find(clusterStrips_uSide.begin(), clusterStrips_uSide.end(), stripID) != clusterStrips_uSide.end()) {
162 std::string sensorName;
163 occupancyPDFName(svdRecoDigit.getSensorID(), svdRecoDigit.isUStrip(), sensorName);
166 if (xTalkStrip->GetBinContent(svdRecoDigit.getCellID()) < 1.) xTalkStrip->Fill(svdRecoDigit.getCellID(),
true);
168 if (std::find(clusterStrips_vSide.begin(), clusterStrips_vSide.end(), stripID) != clusterStrips_vSide.end()) {
169 std::string sensorName;
170 occupancyPDFName(svdRecoDigit.getSensorID(), svdRecoDigit.isUStrip(), sensorName);
172 if (xTalkStrip->GetBinContent(svdRecoDigit.getCellID()) < 1.) xTalkStrip->Fill(svdRecoDigit.getCellID(),
true);
184 B2INFO(
"SVDCrossTalkFinderModule::terminate");
189 std::string sensorName;
192 for (
auto& ladders : geo.
getLadders(layers)) {
193 for (
auto& sensors : geo.
getSensors(ladders)) {
194 for (
int side = 0; side <= 1; side++) {
198 sensorOnMap->Write();
212 if (side == 1) nBins = 768;
215 for (
int i = 0; i < nBins; i++) {
218 mean = count / nBins;
StoreArray< SVDRecoDigit > m_svdRecoDigits
The storeArray for svdRecoDigits.
virtual void initialize() override
Init the module.
StoreObjPtr< SVDEventInfo > m_svdEventInfo
The storeObject for svdEventInfo.
virtual void event() override
Event.
int m_uSideOccupancyFactor
Parameter to define high occupancy strips (some multiple above sensor average occupancy)
bool m_createCalibrationPayload
If true module will produce and write-out payload for SVDCrossTalkStripsCalibrations.
virtual void terminate() override
Final output.
int m_vSideOccupancyFactor
Parameter to define high occupancy strips (some multiple above sensor average occupancy)
std::string m_outputFilename
Filename of root file containing cross-talk strip calibration payload.
std::string m_svdRecoDigitsName
SVDRecoDigit collection name.
std::map< std::string, TH1F * > m_sensorHistograms
map to store cross-talk strip histograms
void calculateAverage(const VxdID &sensorID, double &mean, int side)
Function to calculate sensor average occupancy.
SVDOccupancyCalibrations m_OccupancyCal
SVDOccupancy calibrations db object.
TFile * m_histogramFile
Pointer to root TFile containing histograms for calibration payload.
int m_nAPVFactor
Parameter to set number of sensors with possible cross-talk clusters required for event flagging.
float getOccupancy(const VxdID &sensorID, const bool &isU, const unsigned short &strip) const
This is the method for getting the occupancy, or the deviation from the average, still to be decided.
Class to faciliate easy access to sensor information of the VXD like coordinate transformations or pi...
const std::set< Belle2::VxdID > getLayers(SensorInfoBase::SensorType sensortype=SensorInfoBase::VXD)
Return a set of all known Layers.
const std::set< Belle2::VxdID > & getSensors(Belle2::VxdID ladder) const
Return a set of all sensor IDs belonging to a given ladder.
static GeoCache & getInstance()
Return a reference to the singleton instance.
const std::set< Belle2::VxdID > & getLadders(Belle2::VxdID layer) const
Return a set of all ladder IDs belonging to a given layer.
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.
void occupancyPDFName(const VxdID &sensor, int side, std::string &PDFName)
Function to maintain common naming convention between calibration occupancy file generation and occup...
Abstract base class for different kinds of events.