10#include <background/modules/BeamBkgHitRateMonitor/ECLHitRateCounter.h>
12#include <ecl/dbobjects/ECLCrystalCalib.h>
13#include <framework/database/DBObjPtr.h>
14#include <framework/geometry/B2Vector3.h>
26 namespace Background {
35 tree->Branch(
"ecl", &
m_rates,
"averageDspBkgRate[16]/F:numEvents/I:validDspRate/O");
39 ECLWaveformNoise(
"ECLWaveformRMS");
41 if (ECLElectronicsCalib)
for (
int i = 0; i < 8736; i++)
m_ADCtoEnergy[i] = ECLElectronicsCalib->getCalibVector()[i];
42 if (ECLECalib)
for (
int i = 0; i < 8736; i++)
m_ADCtoEnergy[i] *= ECLECalib->getCalibVector()[i];
44 if (ECLWaveformNoise)
for (
int i = 0; i < 8736; i++)
m_waveformNoise[i] = ECLWaveformNoise->getCalibVector()[i];
55 if (not
m_dsps.isValid())
return;
61 if (
m_dsps.getEntries() == 8736) {
69 for (
auto& aECLDsp :
m_dsps) {
71 int nadc = aECLDsp.getNADCPoints();
72 int cellID = aECLDsp.getCellId();
74 int crysID = cellID - 1;
75 std::vector<int> dspAv = aECLDsp.getDspA();
78 double dspMean = (std::accumulate(dspAv.begin(), dspAv.begin() + nadc, 0.0)) / nadc;
80 for (
int v = 0; v < nadc; v++) {
81 wpsum += pow(dspAv[v] - dspMean, 2);
83 double dspRMS =
sqrt(wpsum / nadc);
87 double dspBkgRate = ((pow(dspSigma, 2)) - (pow(
m_waveformNoise[crysID], 2))) / (2.53 * 1e-12);
93 rates.averageDspBkgRate[segmentNumber] += dspBkgRate;
98 rates.validDspRate =
true;
113 for (
int i = 0; i < 16; i++) {
122 for (
int cid = 1; cid < 8737; cid++) {
125 const double phi = position.
Phi();
126 const double z = position.
Z();
129 if (phi > 0.7853 && phi < 2.356) {
132 }
else if (phi >= 2.356 || phi <= -2.356) {
135 }
else if (phi > -2.356 && phi < -0.7853) {
142 }
else if (cid < 7777) {
144 if (phi > 0.7853 && phi < 2.356) {
147 }
else if (phi >= 2.356 || phi <= -2.356) {
150 }
else if (phi > -2.356 && phi < -0.7853) {
158 if (phi > 0.7853 && phi < 2.356) {
161 }
else if (phi >= 2.356 || phi <= -2.356) {
164 }
else if (phi > -2.356 && phi < -0.7853) {
173 if (phi > 0.7853 && phi < 2.356) {
176 }
else if (phi >= 2.356 || phi <= -2.356) {
179 }
else if (phi > -2.356 && phi < -0.7853) {
DataType Phi() const
The azimuth angle.
DataType Z() const
access variable Z (= .at(2) without boundary check)
std::map< int, int > m_segmentMap
map with keys containing ECL CellID and values containing segment number
int m_crystalsInSegment[16]
array containing the number of crystals in given segment
std::map< unsigned, TreeStruct > m_buffer
average rates in time stamps
TreeStruct m_rates
tree variables
StoreArray< ECLDsp > m_dsps
collection of ECL waveforms
virtual void initialize(TTree *tree) override
Class initializer: set branch addresses and other staf.
Belle2::ECL::ECLGeometryPar * m_geometry
pointer to ECLGeometryPar
std::vector< float > m_waveformNoise
vector used to store ECL electronic noise constants foe each crystal
virtual void accumulate(unsigned timeStamp) override
Accumulate hits.
int findECLSegment(int cellid)
Find the correcsponding ECL segment based on the cellID.
void segmentECL()
Performs ECL segmentation; Done once per run; Populates a map which connects each ECL crystal with a ...
virtual void normalize(unsigned timeStamp) override
Normalize accumulated hits (e.g.
virtual void clear() override
Clear time-stamp buffer to prepare for 'accumulate'.
std::vector< float > m_ADCtoEnergy
vector used to store ECL calibration constants for each crystal
Class for accessing objects in the database.
static ECLGeometryPar * Instance()
Static method to get a reference to the ECLGeometryPar instance.
ROOT::Math::XYZVector GetCrystalPos(int cid)
The Position of crystal.
void Mapping(int cid)
Mapping theta, phi Id.
double sqrt(double a)
sqrt for double
Abstract base class for different kinds of events.
bool validDspRate
status for rates calculated from waveforms, true if waveforms for all crystals are recorded
float averageDspBkgRate[16]
average background rate per crystal in given segment, calculated using ECL waveforms [hits/second]
void normalize()
normalize accumulated rates based on ECL waveforms