9#include <svd/modules/svdCrossTalkCalibrationsCollector/SVDCrossTalkCalibrationsCollectorModule.h>
11#include <svd/modules/svdCrossTalkFinder/SVDCrossTalkFinderHelperFunctions.h>
13#include <vxd/geometry/GeoCache.h>
28 setDescription(
"This module collects the list of channels exhibiting crossTalk readout.");
33 "SVDShaperDigit collection name",
string(
""));
36 "Multiple of the average occupancy for high occupancy strip classification", 2);
39 "Multiple of the average occupancy for high occupancy strip classification", 2);
42 "Number of APV chips with at least one high occupancy strips in event required for cross talk flag", 30);
67 std::string sensorName;
73 for (
auto& sensors : geo.
getSensors(ladders)) {
74 for (
int side = 0; side <= 1; side++) {
77 if (layers.getLayerNumber() == 3 or side == 1) {
78 sensorHist =
new TH1F(sensorName.c_str(),
"", 768, 0, 768);
80 sensorHist =
new TH1F(sensorName.c_str(),
"", 512, 0, 512);
96 vector<std::string> highOccChips_uSide ;
97 vector<std::string> highOccChips_vSide ;
98 vector<std::string> highOccChipsStripNum_uSide ;
99 vector<std::string> highOccChipsStripNum_vSide ;
100 vector<std::string> clusterStrips_uSide ;
101 vector<std::string> clusterStrips_vSide ;
102 vector<std::string> clusterChips_uSide ;
103 vector<int> strips_uSide;
104 vector<int> strips_vSide;
109 if (svdShaperDigit.getSensorID().getLayerNumber() == 3 or svdShaperDigit.getSensorID().getSensorNumber() == 1) {
113 int side = svdShaperDigit.isUStrip();
114 std::string sensorName;
117 double sensorAverage = 0.;
119 int stripID = svdShaperDigit.getCellID();
120 std::string sensorStripNum = sensorName +
"." + std::to_string(stripID);
125 int adjacentStrip = 0;
126 if (!strips_uSide.empty()) {
127 adjacentStrip = stripID - strips_uSide.back();
129 strips_uSide.push_back(stripID);
130 if (!highOccChips_uSide.empty() && sensorName == highOccChips_uSide.back() && adjacentStrip == 1) {
131 clusterChips_uSide.push_back(sensorName);
132 if (clusterStrips_uSide.empty() || clusterStrips_uSide.back() != sensorStripNum) {
133 clusterStrips_uSide.push_back(highOccChipsStripNum_uSide.back());
135 clusterStrips_uSide.push_back(sensorStripNum);
137 highOccChipsStripNum_uSide.push_back(sensorStripNum);
138 highOccChips_uSide.push_back(sensorName);
142 int adjacentStrip = 0;
143 if (!strips_vSide.empty()) {
144 adjacentStrip = stripID - strips_vSide.back();
146 strips_vSide.push_back(stripID);
147 if (!highOccChips_vSide.empty() && sensorName == highOccChips_vSide.back() && adjacentStrip == 1) {
148 if (clusterStrips_vSide.empty() || clusterStrips_vSide.back() != sensorStripNum) {
149 clusterStrips_vSide.push_back(highOccChipsStripNum_vSide.back());
151 clusterStrips_vSide.push_back(sensorStripNum);
153 highOccChipsStripNum_vSide.push_back(sensorStripNum);
154 highOccChips_vSide.push_back(sensorName);
159 std::sort(clusterChips_uSide.begin(), clusterChips_uSide.end());
160 clusterChips_uSide.erase(unique(clusterChips_uSide.begin(), clusterChips_uSide.end()), clusterChips_uSide.end());
161 int numberOfClusterChips = std::distance(clusterChips_uSide.begin(), std::unique(clusterChips_uSide.begin(),
162 clusterChips_uSide.end()));
167 std::string sensorID = svdShaperDigit.getSensorID();
168 std::string digitID = sensorID +
"." + std::to_string(svdShaperDigit.isUStrip());
169 std::string stripID = digitID +
"." + std::to_string(svdShaperDigit.getCellID());
170 if (std::find(clusterStrips_uSide.begin(), clusterStrips_uSide.end(), stripID) != clusterStrips_uSide.end()) {
171 std::string sensorName;
172 occupancyPDFName(svdShaperDigit.getSensorID(), svdShaperDigit.isUStrip(), sensorName);
174 xTalkStrip->Fill(svdShaperDigit.getCellID(), 1);
176 if (std::find(clusterStrips_vSide.begin(), clusterStrips_vSide.end(), stripID) != clusterStrips_vSide.end()) {
177 std::string sensorName;
178 occupancyPDFName(svdShaperDigit.getSensorID(), svdShaperDigit.isUStrip(), sensorName);
180 xTalkStrip->Fill(svdShaperDigit.getCellID(), 1);
194 std::string sensorName;
197 for (
auto& ladders : geo.
getLadders(layers)) {
198 for (
auto& sensors : geo.
getSensors(ladders)) {
199 for (
int side = 0; side <= 1; side++) {
204 m_layer = sensors.getLayerNumber();
205 m_ladder = sensors.getLadderNumber();
206 m_sensor = sensors.getSensorNumber();
209 getObjectPtr<TTree>(
"HTreeCrossTalkCalib")->Fill();
211 sensorOnMap->Delete();
223 if (side == 1) nBins = 768;
226 for (
int i = 0; i < nBins; i++) {
229 mean = count / nBins;
Calibration collector module base class.
void setDescription(const std::string &description)
Sets the description of the module.
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
void prepare() override final
Init the module.
TH1F * m_hist
Initialisation of crosstalk histogram.
std::string m_svdShaperDigitsName
SVDShaperDigit collection name.
int m_ladder
Number of ladders.
int m_uSideOccupancyFactor
Parameter to define high occupancy strips (some multiple above sensor average occupancy)
int m_side
Number of sides.
int m_sensor
Number of sensors.
int m_vSideOccupancyFactor
Parameter to define high occupancy strips (some multiple above sensor average occupancy)
StoreArray< SVDShaperDigit > m_svdShaperDigits
The storeArray for svdShaperDigits.
void closeRun() override final
End of run.
void collect() override final
Event processing.
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.
void finish() override
Termination.
SVDCrossTalkCalibrationsCollectorModule()
constructor
int m_layer
Number of layers to define size of TTree.
TTree * m_histogramTree
Initialisation of TTree object.
int m_nAPVFactor
Parameter to set number of sensors with possible cross-talk clusters required for event flagging.
void startRun() override final
New run.
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.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
#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.