10#include <background/modules/BeamBkgHitRateMonitor/SVDHitRateCounter.h>
13#include <framework/logging/Logger.h>
14#include <hlt/softwaretrigger/core/FinalTriggerDecisionCalculator.h>
15#include <framework/gearbox/Const.h>
16#include <framework/gearbox/Unit.h>
17#include <vxd/geometry/GeoCache.h>
21#define LOGRATIO(x,y) (x) << " / " << (y) << " = " << ((x) * 100 / (y)) << "%"
28 namespace Background {
38 B2DEBUG(10,
"SVDHitRateCounter: initialize()");
41 "layerAverageRates[4]/F:layerLadderAverageRates[4][16]/F:layerSensorAverageRates[4][5]:averageRate/F:l3LadderSensorAverageRates[7][2]/F:numEvents/I:valid/O");
43 "layerAverageRates[4]/F:layerLadderAverageRates[4][16]/F:layerSensorAverageRates[4][5]:averageRate/F:l3LadderSensorAverageRates[7][2]/F:numEvents/I:valid/O");
45 "layerAverageRates[4]/F:layerLadderAverageRates[4][16]/F:layerSensorAverageRates[4][5]:averageRate/F:l3LadderSensorAverageRates[7][2]/F:numEvents/I:valid/O");
47 "layerAverageRates[4]/F:layerLadderAverageRates[4][16]/F:layerSensorAverageRates[4][5]:averageRate/F:l3LadderSensorAverageRates[7][2]/F:numEvents/I:valid/O");
49 "layerAverageRates[4]/F:layerLadderAverageRates[4][16]/F:layerSensorAverageRates[4][5]:averageRate/F:l3LadderSensorAverageRates[7][2]/F:numEvents/I:valid/O");
51 "layerAverageRates[4]/F:layerLadderAverageRates[4][16]/F:layerSensorAverageRates[4][5]:averageRate/F:l3LadderSensorAverageRates[7][2]/F:numEvents/I:valid/O");
53 "layerAverageRates[4]/F:layerLadderAverageRates[4][16]/F:layerSensorAverageRates[4][5]:averageRate/F:l3LadderSensorAverageRates[7][2]/F:numEvents/I:valid/O");
55 "layerAverageRates[4]/F:layerLadderAverageRates[4][16]/F:layerSensorAverageRates[4][5]:averageRate/F:l3LadderSensorAverageRates[7][2]/F:numEvents/I:valid/O");
57 "layerAverageRates[4]/F:layerLadderAverageRates[4][16]/F:layerSensorAverageRates[4][5]:averageRate/F:l3LadderSensorAverageRates[7][2]/F:numEvents/I:valid/O");
60 for (
int layer = 0; layer <
m_nLayers; layer++) {
61 for (
int ladder = 0; ladder <
m_nLadders[layer]; ladder++) {
62 for (
int sensor = 0; sensor <
m_nSensors[layer]; sensor++) {
63 VxdID sensorID(layer + 3, ladder + 1, sensor + 1);
64 for (
bool isU : {
true,
false}) {
66 for (
int strip = 0; strip < nStrips; strip++) {
90 for (
int ladder = 0; ladder <
m_nLadders[layer]; ladder++) {
91 for (
int sensor = 0; sensor <
m_nSensors[layer]; sensor++) {
92 VxdID sensorID(layer + 3, ladder + 1, sensor + 1);
93 for (
bool isU : {
true,
false}) {
95 for (
int strip = 0; strip < nStrips; strip++) {
107 B2INFO(
"SVD active strips = " << LOGRATIO(
m_activeStrips, 223744));
108 for (layer = 0; layer <
m_nLayers; layer++)
109 B2INFO(
" Active strips L" << layer + 3 <<
".X.X = "
111 for (layer = 0; layer <
m_nLayers; layer++)
112 for (
int ladder = 0; ladder <
m_nLadders[layer]; ladder++)
113 B2INFO(
" Active strips L" << layer + 3 <<
"." << ladder + 1 <<
".X = "
115 for (layer = 0; layer <
m_nLayers; layer++)
116 for (
int sensor = 0; sensor <
m_nSensors[layer]; sensor++)
117 B2INFO(
" Active strips L" << layer + 3 <<
".X." << sensor + 1 <<
" = "
120 for (
int ladder = 0; ladder <
m_nLadders[layer]; ladder++)
121 for (
int sensor = 0; sensor <
m_nSensors[layer]; sensor++)
122 B2INFO(
" Active strips L3." << ladder + 1 <<
"." << sensor + 1 <<
" = "
126 for (layer = 0; layer <
m_nLayers; layer++) {
127 for (
int ladder = 0; ladder <
m_nLadders[layer]; ladder++) {
128 for (
int sensor = 0; sensor <
m_nSensors[layer]; sensor++) {
146 B2DEBUG(10,
"SVDHitRateCounter: accumulate()");
151 if (!eventAccepted)
return;
168 for (
const auto& digit :
m_digits) {
170 VxdID sensorID = digit.getSensorID();
174 rates.layerAverageRates[layer] ++;
175 rates.layerLadderAverageRates[layer][ladder] ++;
176 rates.layerSensorAverageRates[layer][sensor] ++;
177 rates.averageRate ++;
179 rates.l3LadderSensorAverageRates[ladder][sensor] ++;
181 if (digit.isUStrip()) {
182 ratesU.layerAverageRates[layer]++;
183 ratesU.layerLadderAverageRates[layer][ladder]++;
184 ratesU.layerSensorAverageRates[layer][sensor]++;
185 ratesU.averageRate++;
187 ratesU.l3LadderSensorAverageRates[ladder][sensor]++;
189 ratesV.layerAverageRates[layer]++;
190 ratesV.layerLadderAverageRates[layer][ladder]++;
191 ratesV.layerSensorAverageRates[layer][sensor]++;
192 ratesV.averageRate++;
194 ratesV.l3LadderSensorAverageRates[ladder][sensor]++;
216 rates_highE.numEvents++;
217 rates_lowE.numEvents++;
218 clustersU.numEvents++;
219 clustersV.numEvents++;
220 rates_energyU.numEvents++;
221 rates_energyV.numEvents++;
225 VxdID sensorID = cluster.getSensorID();
230 rates_highE.layerAverageRates[layer] ++;
231 rates_highE.layerLadderAverageRates[layer][ladder] ++;
232 rates_highE.layerSensorAverageRates[layer][sensor] ++;
233 rates_highE.averageRate ++;
235 rates_highE.l3LadderSensorAverageRates[ladder][sensor] ++;
237 rates_lowE.layerAverageRates[layer] ++;
238 rates_lowE.layerLadderAverageRates[layer][ladder] ++;
239 rates_lowE.layerSensorAverageRates[layer][sensor] ++;
240 rates_lowE.averageRate ++;
242 rates_lowE.l3LadderSensorAverageRates[ladder][sensor] ++;
252 B2WARNING(
"SVDEventInfo not available: assuming 6 samples were taken.");
255 if (nSamp < 2) nSamp = 2;
258 svdSamplingClock =
m_clockSettings->getClockFrequency(Const::SVD,
"sampling");
260 B2WARNING(
"HardwareClockSettings not available: using approximated SVD sampling clock frequency.");
261 double integrationTimeSeconds = (nSamp - 1) / svdSamplingClock /
Unit::s;
262 double chargePerUnitTime = cluster.getCharge() / integrationTimeSeconds;
263 if (cluster.isUCluster()) {
264 rates_energyU.layerAverageRates[layer] += chargePerUnitTime;
265 rates_energyU.layerLadderAverageRates[layer][ladder] += chargePerUnitTime;
266 rates_energyU.layerSensorAverageRates[layer][sensor] += chargePerUnitTime;
267 rates_energyU.averageRate += chargePerUnitTime;
269 rates_energyU.l3LadderSensorAverageRates[ladder][sensor] += chargePerUnitTime;
270 clustersU.layerAverageRates[layer]++;
271 clustersU.layerLadderAverageRates[layer][ladder]++;
272 clustersU.layerSensorAverageRates[layer][sensor]++;
273 clustersU.averageRate++;
275 clustersU.l3LadderSensorAverageRates[ladder][sensor]++;
277 rates_energyV.layerAverageRates[layer] += chargePerUnitTime;
278 rates_energyV.layerLadderAverageRates[layer][ladder] += chargePerUnitTime;
279 rates_energyV.layerSensorAverageRates[layer][sensor] += chargePerUnitTime;
280 rates_energyV.averageRate += chargePerUnitTime;
282 rates_energyV.l3LadderSensorAverageRates[ladder][sensor] += chargePerUnitTime;
283 clustersV.layerAverageRates[layer]++;
284 clustersV.layerLadderAverageRates[layer][ladder]++;
285 clustersV.layerSensorAverageRates[layer][sensor]++;
286 clustersV.averageRate++;
288 clustersV.l3LadderSensorAverageRates[ladder][sensor]++;
293 rates_highE.valid =
true;
294 rates_lowE.valid =
true;
295 clustersU.valid =
true;
296 clustersV.valid =
true;
297 rates_energyU.valid =
true;
298 rates_energyV.valid =
true;
305 B2DEBUG(10,
"SVDHitRateCounter: normalize()");
330 if (not rates.
valid)
return;
347 for (
int layer = 0; layer <
m_nLayers; layer++) {
349 for (
int ladder = 0; ladder <
m_nLadders[layer]; ladder++) {
352 for (
int sensor = 0; sensor <
m_nSensors[layer]; sensor++) {
357 for (
int ladder = 0; ladder <
m_nLadders[layer]; ladder++) {
358 for (
int sensor = 0; sensor <
m_nSensors[layer]; sensor++) {
368 static const double conv = ehEnergyJoules * 100e3;
370 if (!rates.
valid)
return;
375 for (
int layer = 0; layer <
m_nLayers; layer++) {
377 for (
int ladder = 0; ladder <
m_nLadders[layer]; ladder++)
379 for (
int sensor = 0; sensor <
m_nSensors[layer]; sensor++)
383 for (
int ladder = 0; ladder <
m_nLadders[layer]; ladder++)
384 for (
int sensor = 0; sensor <
m_nSensors[layer]; sensor++)
392 double length = sensorInfo.getLength();
393 double width = (sensorInfo.getForwardWidth() + sensorInfo.getBackwardWidth()) / 2.0;
394 double thickness = sensorInfo.getWSize();
395 return length * width * thickness * rho_Si / 1e3;
399 const unsigned short& strip)
int m_layerLadderActiveStripsV[4][16]
number of active V-strips in each layer, ladder
std::map< unsigned, TreeStruct > m_buffer
average strip occupancies in time stamps
void normalizeRates(TreeStruct &rates, bool isU=false, bool isV=false)
Normalize TreeStruct.
int m_activeStripsV
number of active V-strips
int m_activeStrips
number of active strips
double m_layerLadderMassKg[4][16]
Active mass of each ladder of each layer, in Kg.
double m_layerMassKg[4]
Active mass of each layer in Kg.
TreeStruct m_rates
tree variables for fired strips
std::map< unsigned, TreeStruct > m_buffer_energyV
Average deposited energy (V-side) per event in time stamps.
TreeStruct m_rates_highE
tree variables for high-energy clusters
std::string m_svdShaperDigitsName
name of the input SVDShaperDigits collection
int m_layerSensorActiveStripsV[4][5]
number of active V-strips in each layer, sensor position
int m_l3LadderSensorActiveStripsU[7][2]
number of active U-strips in each sensor in Layer 3
StoreObjPtr< SVDEventInfo > m_eventInfo
For number of APV samples taken (3 or 6).
TreeStruct m_rates_energyU
Tree variables for deposited charge per unit time, then converted to dose rate (U-side)
std::map< unsigned, TreeStruct > m_buffer_clustersV
average cluster occupancies (V-side) in time stamps
std::map< unsigned, TreeStruct > m_buffer_lowE
average cluster occupancies (low energy) in time stamps
TreeStruct m_ratesU
tree variables for fired U-strips
bool m_ignoreHotStripsPayload
count hot strips as active
int m_nLadders[4]
number of ladders on each layer
int m_l3LadderSensorActiveStrips[7][2]
number of active strips in each sensor in Layer 3
virtual void initialize(TTree *tree) override
Class initializer: set branch addresses and other staf.
int nStripsOnLayerSide(int layer, bool isU)
Return number of strips on a sensor.
int m_layerSensorActiveStrips[4][5]
number of active strips in each layer, sensor position
SVDFADCMaskedStrips m_FADCMaskedStrips
payload for strips masked on FADC level
bool m_ignoreMaskedStripsPayload
SVD: count FAD-masked strips as active.
static constexpr double c_SVDSamplingClockFrequency
SVD Sampling Clock frequency (approximated) in GHz (standard unit of frequency in basf2).
StoreArray< SVDCluster > m_clusters
collection of clusters
virtual void accumulate(unsigned timeStamp) override
Accumulate hits.
double m_layerSensorMassKg[4][5]
Active mass of each ladder/sensor position, in Kg.
std::map< unsigned, TreeStruct > m_buffer_highE
average cluster occupancies (high energy) in time stamps
double massOfSensor(int layer, int ladder, int sensor)
Returns the (active) mass of the given sensor in Kg.
double m_thrCharge
cut on cluster energy in electrons
SVDHotStripsCalibrations m_HotStripsCalib
payload for hot strips
int m_l3LadderSensorActiveStripsV[7][2]
number of active V-strips in each sensor in Layer 3
TreeStruct m_rates_energyV
Tree variables for deposited charge per unit time, then converted to dose rate (V-side)
OptionalDBObjPtr< HardwareClockSettings > m_clockSettings
hardware clock settings
double m_massKg
Active mass of the whole SVD in Kg.
int m_nSensors[4]
number of sensors on a ladder on each layer
int m_layerLadderActiveStrips[4][16]
number of active strips in each layer, ladder
StoreArray< SVDShaperDigit > m_digits
collection of digits
TreeStruct m_rates_lowE
tree variables for low-energy clusters
std::map< unsigned, TreeStruct > m_buffer_clustersU
average cluster occupancies (U-side) in time stamps
void normalizeEnergyRates(TreeStruct &rates)
Normalize a TreeStruct that stores charge/energy, not hits.
int m_activeStripsU
number of active U-strips
int m_layerSensorActiveStripsU[4][5]
number of active U-strips in each layer, sensor position
bool isStripActive(const VxdID &sensorID, const bool &isU, const unsigned short &strip)
Returns wether a strips is active (neither hot nor masked), taking into account the ignoreHotStrips a...
std::map< unsigned, TreeStruct > m_bufferU
average U-strip occupancies in time stamps
int m_layerActiveStripsV[4]
number of active V-strips in each layer
StoreObjPtr< SoftwareTriggerResult > m_resultStoreObjectPointer
trigger decision
int m_layerLadderActiveStripsU[4][16]
number of active U-strips in each layer, ladder
TreeStruct m_clustersV
tree variables for V-side clusters
int m_nLayers
number of layers
TreeStruct m_clustersU
tree variables for U-side clusters
std::map< unsigned, TreeStruct > m_buffer_energyU
Average deposited energy (U-side) per event in time stamps.
std::map< unsigned, TreeStruct > m_bufferV
average V-strip occupancies in time stamps
virtual void normalize(unsigned timeStamp) override
Normalize accumulated hits (e.g.
virtual void clear() override
Clear time-stamp buffer to prepare for 'accumulate'.
int m_layerActiveStrips[4]
number of active strips in each layer
int m_layerActiveStripsU[4]
number of active U-strips in each layer
TreeStruct m_ratesV
tree variables for fired V-strips
static const double ehEnergy
Energy needed to create an electron-hole pair in Si at std.
float isMasked(const VxdID &sensorID, const bool &isU, const unsigned short &strip) const
This is the method for getting the comprehensive list of masked strips at FADC level.
float isHot(const VxdID &sensorID, const bool &isU, const unsigned short &strip) const
This is the method for getting the offline list of bad strips to be masked.
static bool getFinalTriggerDecision(const SoftwareTriggerResult &result, bool forgetTotalResult=false)
Calculate the final cut decision using all "total_results" of all sub triggers in the software trigge...
bool isOptional(const std::string &name="")
Tell the DataStore about an optional input.
bool isValid() const
Check wether the array was registered.
static const double J
[joule]
static const double g_cm3
Practical units with the value set at 1.
static const double s
[second]
const SensorInfoBase & getSensorInfo(Belle2::VxdID id) const
Return a referecne to the SensorInfo of a given SensorID.
static GeoCache & getInstance()
Return a reference to the singleton instance.
Class to uniquely identify a any structure of the PXD and SVD.
baseType getSensorNumber() const
Get the sensor id.
baseType getLadderNumber() const
Get the ladder id.
baseType getLayerNumber() const
Get the layer id.
Abstract base class for different kinds of events.
bool valid
status: true = rates valid
float layerAverageRates[4]
layer average occupancy
float layerLadderAverageRates[4][16]
[#layer][#ladder]
float layerSensorAverageRates[4][5]
[#layer][#sensor]
float averageRate
total SVD average occupancy
void normalize()
normalize accumulated hits to single event
float l3LadderSensorAverageRates[7][2]
Layer 3 sensors [#ladder][#sensor].