10#include <background/modules/BeamBkgHitRateMonitor/CDCHitRateCounter.h>
13#include <framework/gearbox/Unit.h>
14#include <framework/gearbox/Const.h>
15#include <framework/logging/Logger.h>
17#include <tracking/trackFindingCDC/rootification/StoreWrappedObjPtr.h>
18#include <tracking/trackFindingCDC/eventdata/hits/CDCWireHit.h>
20#include <cdc/geometry/CDCGeometryPar.h>
21#include <cdc/dataobjects/WireID.h>
31 using TrackFindingCDC::StoreWrappedObjPtr;
32 using TrackFindingCDC::CDCWireHit;
34 namespace Background {
43 stringstream leafList;
47 <<
"layerHitRate[" <<
f_nLayer <<
"]/F:"
49 <<
"timeWindowForSmallCell/I:"
50 <<
"timeWindowForNormalCell/I:"
51 <<
"nActiveWireInTotal/I:"
53 <<
"nActiveWireInLayer[" <<
f_nLayer <<
"]/I:"
57 tree->Branch(
"cdc", &
m_rates, leafList.str().c_str());
83 std::map<const CDCHit*, bool> CDCHitToBackgroundFlag;
86 if (not storeVector) {
87 B2FATAL(
"CDCWireHitVector is unaccessible in DataStore."
88 "Need TFCDC_WireHitParameter module before.");
90 const std::vector<CDCWireHit>& cdcWireHitVector = *storeVector;
91 for (
const auto& cdcWireHit : cdcWireHitVector) {
92 const CDCHit* cdcHit = cdcWireHit.getHit();
93 CDCHitToBackgroundFlag[cdcHit] = cdcWireHit->hasBackgroundFlag();
107 const WireID wireID(hit.getID());
111 const unsigned short iSuperLayer = hit.getISuperLayer();
112 const unsigned short iLayer = hit.getICLayer();
113 const unsigned short iWireInLayer = hit.getIWire();
114 const unsigned short iPhiBin =
getIPhiBin(iSuperLayer, iWireInLayer);
115 const unsigned short adc = hit.getADCCount();
116 const short tdc = hit.getTDCCount();
119 if (CDCHitToBackgroundFlag[&hit]) {
121 unsigned short newStatus = (hit.getStatus() | 0x100);
122 hit.setStatus(newStatus);
127 if (iSuperLayer == 0 && adc < 15)
129 if (iSuperLayer != 0 && adc < 18)
137 rates.averageRate += 1;
138 rates.superLayerHitRate[iSuperLayer] += 1;
139 rates.layerHitRate[iLayer] += 1;
140 rates.layerPhiHitRate[iLayer][iPhiBin] += 1;
175 for (
int iLayer = 0 ; iLayer <
f_nLayer ; ++iLayer)
182 for (
int iLayer = 0 ; iLayer <
f_nLayer ; ++iLayer)
194 for (
int i = 0 ; i <
f_nLayer ; ++i)
196 for (
int i = 0 ; i <
f_nLayer ; ++i)
204 static const unsigned short nlayer_in_SL[
f_nSuperLayer] = { 8, 6, 6,
208 static const unsigned short nwire_in_layer[
f_nSuperLayer] = { 160, 160, 192,
217 for (
int i = 0 ; i < nlayer_in_SL[iSL] ; ++i) {
232 static const unsigned short nlayer_in_SL[
f_nSuperLayer] = { 8, 6, 6,
236 static const unsigned short nwire_in_layer[
f_nSuperLayer] = { 160, 160, 192,
248 for (
int iL = 0 ; iL < nlayer_in_SL[iSL] ; ++iL) {
253 for (
int i = 0 ; i < nwire_in_layer[iSL] ; ++i) {
254 WireID wireID(iSL, iL, i);
268 std::cout <<
"CDC, # of Active wires / # of total wires" << std::endl;
269 int contLayerID_2 = 0;
271 for (
int iL = 0 ; iL < nlayer_in_SL[iSL] ; ++iL) {
273 std::cout <<
"Layer " << contLayerID_2 <<
": "
276 << nwire_in_layer[iSL] << std::endl;
286 static const unsigned short nwire_in_layer[
f_nSuperLayer] = { 160, 160, 192,
static const int f_nLayer
the number of layers
std::map< unsigned, TreeStruct > m_buffer
average rates in time stamps
int m_nActiveWireInLayer[f_nLayer]
the number of wires used in this hit-rate calculation in each layer
TreeStruct m_rates
tree variables
void countActiveWires_countAll()
set m_nActiveWireInTotal, m_nActiveWireInLayer[] and m_nActiveWireInSuperLayer[].
const bool m_enableBackgroundHitFilter
flag to enable the CDC background hit (crosstakl, noise) filter.
bool isInTimeWindow(const int SL, const short tdc)
return true if the hit is in the given time window
virtual void initialize(TTree *tree) override
Class initializer: set branch addresses and other staf.
const int m_timeWindowLowerEdge_normalCell
lower edge of the time window for normal cells [tdc count = 0.982536 ns]
int m_nActiveWireInTotal
the number of wires used in this hit-rate calculation in the whole CDC
StoreArray< CDCHit > m_digits
collection of digits
virtual void accumulate(unsigned timeStamp) override
Accumulate hits.
unsigned short getIPhiBin(unsigned short iSL, unsigned short iWireInLayer)
get the bin ID of the division.
int m_nActiveWireInLayerPhi[f_nLayer][f_nPhiDivision]
the number of wires used in this hit-rate calculation in each phi bin in each layer
const int m_timeWindowUpperEdge_smallCell
upper edge of the time window for small cells [tdc count = 0.982536 ns]
const bool m_enableBadWireTreatment
flag to enable the bad wire treatment.
const int m_timeWindowUpperEdge_normalCell
upper edge of the time window for normal cells [tdc count = 0.982536 ns]
static const int f_nSuperLayer
the number of super layers
const bool m_enableMarkBackgroundHit
flag to enable to mark background flag on CDCHit (set 0x100 bit for CDCHit::m_status).
static const int f_nPhiDivision
the number of division in phi
void countActiveWires()
set m_nActiveWireInTotal, m_nActiveWireInLayer[] and m_nActiveWireInSuperLayer[].
const int m_timeWindowLowerEdge_smallCell
lower edge of the time window for small cells [tdc count = 0.982536 ns]
int m_nActiveWireInSuperLayer[f_nSuperLayer]
the number of wires used in this hit-rate calculation in each suler layer
virtual void normalize(unsigned timeStamp) override
Normalize accumulated hits (e.g.
virtual void clear() override
Clear time-stamp buffer to prepare for 'accumulate'.
Class containing the result of the unpacker in raw data and the result of the digitizer in simulation...
The Class for CDC Geometry Parameters.
bool isBadWire(const WireID &wid)
Inquire if the wire is totally-dead.
static CDCGeometryPar & Instance(const CDCGeometry *=nullptr)
Static method to get a reference to the CDCGeometryPar instance.
This class is for convenience access and registration of objects, that are stored inside the StoreWra...
Class to identify a wire inside the CDC.
Abstract base class for different kinds of events.
float superLayerHitRate[f_nSuperLayer]
SuperLayer average hit rate in kHz.
bool valid
status: true = rates valid
float layerPhiHitRate[f_nLayer][f_nPhiDivision]
Layer (in the phi bin) average hit rate in kHz.
int nActiveWireInLayerPhi[f_nLayer][f_nPhiDivision]
number of wires used in this analysis in each phi bin in each layer
float layerHitRate[f_nLayer]
Layer average hit rate in kHz.
int nActiveWireInTotal
number of wires used in this analysis in the whole CDC
int nActiveWireInSuperLayer[f_nSuperLayer]
number of wires used in this analysis in each super layer
int nActiveWireInLayer[f_nLayer]
number of wires used in this analysis in each layer
float averageRate
total detector average hit rate in KHz
void normalize()
normalize accumulated hits to hit rate in kHz
int timeWindowForSmallCell
time window for the small cells in 2*508.887 MHz clock ( 1 clock = 0.982536 ns)
int timeWindowForNormalCell
time window for the normal cells in 2*508.887 MHz clock ( 1 clock = 0.982536 ns)