ATLAS Offline Software
Loading...
Searching...
No Matches
CscRdoValMonAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5// Athena include(s)
6#include "CscRdoValMonAlg.h"
9
10//
11// constructor ----------------------------------------------------------------
12//
13CscRdoValMonAlg::CscRdoValMonAlg(const std::string& name, ISvcLocator* pSvcLocator ) :
14 AthMonitorAlgorithm(name, pSvcLocator)
15 { }
16
17//
18// initialize ----------------------------------------------------------------
19//
21{
22 ATH_MSG_DEBUG ("CscRdoValMonAlg : in initialize()");
23 ATH_CHECK(m_idHelperSvc.retrieve());
25 ATH_CHECK(m_cscRdoKey.initialize());
27}
28
29//
30// fillHistograms ----------------------------------------------------------------
31//
32StatusCode CscRdoValMonAlg::fillHistograms(const EventContext& ctx) const
33{
34 ATH_MSG_DEBUG ( "CscRdoValMonAlg :: in fillHistograms()" );
35
36 if(m_cscRdoKey.key() == ""){ //it seems that protection is needed for this case
37 ATH_MSG_WARNING("CSC RDO key is blank, returning");
38 return StatusCode::SUCCESS;
39 }
40
42
43 // ==============================================================================
44 // Field Range Notes
45 // ==============================================================================
46 // StationName unsigned integer maps to "CSS", "CSL", etc.
47 // StationEta [-1,1] -1 for backward, 1 for forward endcap
48 // StationPhi [1,8] increases with Phi
49 // Technology [1] maps to "CSC"
50 // ChamberLayer [1,2] increases with |Z|
51 // WireLayer [1,4] increases with |Z|
52 // MeasuresPhi [0,1] 0 if measures R, 1 if measures Phi
53 // Strip [1,n] increases with R for MeasuresPhi=0
54 // increases with Phi for MeasuresPhi=1
55 // ==============================================================================
56
57 ATH_MSG_DEBUG ( " Size of RDO Container : " << CscRDO->size() );
58
59 // Begin Event ==================================================
60 ATH_MSG_DEBUG ( " BEGIN EVENT ========================================== " );
61
62 for (CscRawDataContainer::const_iterator it = CscRDO->begin(); it != CscRDO->end(); ++it)
63 {
64 const CscRawDataCollection * rdo = *it;
65 ATH_MSG_DEBUG ( " Number of Samples : " << rdo->numSamples() );
66 ATH_MSG_DEBUG ( " Size of Collection : " << rdo->size() );
67
68 size_t nEtaClusWidthCnt = 0, nPhiClusWidthCnt = 0; //cluster position in each phi-layer
69 Identifier stationId, channelId;
70
71 int clusCount[33][9], sigclusCount[33][9];
72 for(size_t kl = 0; kl < 33; kl++ )
73 {
74 for(size_t km = 0; km < 9; km++ )
75 {
76 clusCount[kl][km] = 0;
77 sigclusCount[kl][km] = 0;
78 }
79 }
80
81 // loop over ROD-clusters
82 for(CscRawDataCollection::const_iterator ic = (*it)->begin(); ic != (*it)->end(); ++ic)
83 {
84 const CscRawData *raw = (*ic);
85 if(raw)
86 {
87 // Identify side(A/C), sector(1-16)/layer(1-4)
88 stationId = m_cscRdoDecoderTool->stationIdentifier(raw,&m_idHelperSvc->cscIdHelper());
89 channelId = m_cscRdoDecoderTool->channelIdentifier(raw,&m_idHelperSvc->cscIdHelper(),0);
90 int stationName = m_idHelperSvc->cscIdHelper().stationName(channelId);
91 int chamberType = m_idHelperSvc->cscIdHelper().stationNameIndex("CSS") == stationName ? 0 : 1;
92 int stationEta = m_idHelperSvc->cscIdHelper().stationEta(channelId);
93 int stationPhi = m_idHelperSvc->cscIdHelper().stationPhi(channelId);
94 int wireLayer = m_idHelperSvc->cscIdHelper().wireLayer(channelId);
95 int measuresPhi = m_idHelperSvc->cscIdHelper().measuresPhi(channelId);
96 auto measuresPhi_mon = Monitored::Scalar<int>("measuresPhi_mon", measuresPhi);
97 auto measuresEta = Monitored::Scalar<int>("measuresEta", !measuresPhi );
98
99 // determine the sector number
100 int sectorNo = stationEta * (2 * stationPhi - chamberType);
101
102 // compute the indices to store cluster count
103 int ns = sectorNo < 0 ? sectorNo*(-1) : sectorNo+16; // [-16 -> -1] shifted to [1 -> 16] and [+1 -> +16] shifted to [+17 -> +32]
104 int nl = (measuresPhi ? wireLayer : wireLayer+4); // [ 1 -> 4] (phi-layers) and [5 -> 8] (eta-layers)
105 clusCount[ns][nl]++;
106
107 // indices for ns = [+1 -> +32]; 32 places (index '0' is not counted); allocated 33 places
108 // indices for nl = [+1 -> +8]; 8 places (index '0' is not counted); allocated 9 places
109 ATH_MSG_DEBUG(" ns = " << ns << "\tm_nl = " << nl << "\tm_sec = " << sectorNo << "\t m_lay= " << wireLayer << "\tmPhi = " << measuresPhi);
110
111 // y-axis fill value
112 // sector# +2 layer 1 maps to +2 + 0.2*(1-1) + 0.1 = +2.1
113 // sector# +2 layer 2 maps to +2 + 0.2*(2-1) + 0.1 = +2.3
114 // sector# +2 layer 3 maps to +2 + 0.2*(3-1) + 0.1 = +2.5
115 // sector# +2 layer 4 maps to +2 + 0.2*(4-1) + 0.1 = +2.7
116 auto secLayer = Monitored::Scalar<float>("secLayer",sectorNo + 0.2 * (wireLayer - 1) + 0.1);
117 int xfac = measuresPhi ? -1 : 1; // -48 / +192
118
119 // this way we get 4 time samples per strip
120 ATH_MSG_DEBUG (" Width of ROD cluster : " << raw->width() );
121 uint16_t diff_max = 0., diff = 0.;
122 std::vector<float> xVals;
123
124 // loop over strips in ROD cluster
125 auto raw_clus_width = Monitored::Scalar<size_t>("raw_clus_width",raw->width());
126
127 if (measuresPhi) nPhiClusWidthCnt++;
128 else nEtaClusWidthCnt++;
129 fill("CscRdoMonitor", raw_clus_width, secLayer, measuresPhi_mon, measuresEta);
130
131 // loop over strips
132 for (size_t n = 0; n < raw_clus_width; n++ )
133 {
134 // identify this strip
135 Identifier chID = m_cscRdoDecoderTool->channelIdentifier(raw, &m_idHelperSvc->cscIdHelper(), n);
136 int strip = m_idHelperSvc->cscIdHelper().strip(chID);
137 auto stripId = Monitored::Scalar<float>("stripId",strip * xfac); // x-axis fill value
138 fill("CscRdoMonitor", stripId, secLayer);
139
140 // for every strip that has a hit, store the X,Y values
141 xVals.push_back(stripId);
142
143 // extract the (four) time samples for this strip
144 std::vector<uint16_t> samples;
145 bool extractSamples = raw->samples(n, rdo->numSamples(), samples);
146 uint16_t n_max=0, n_min = 9999;
147
148 // if we have the time samples, identify the max/min sampling values i.e., ADC_max and ADC_min
149 if (extractSamples)
150 {
151 for (size_t np = 0; np < samples.size(); np++)
152 {
153 if(samples[np] < n_min) n_min = samples[np];
154 if(samples[np] > n_max) n_max = samples[np];
155 }
156 // the diff between max and min samplings Delta_ADC = (ADC_max - ADC_min)
157 diff = n_max - n_min;
158
159 // compute the max difference Max_Delta_ADC
160 if(diff > diff_max) diff_max = diff;
161
162 ATH_MSG_DEBUG ( n << " Max = " << n_max << " Min = " << n_min << " Diff = " << diff );
163 } // end if extractSamples
164 } // end for loop over strips in cluster
165
166 ATH_MSG_DEBUG ( " End loop over strips======================" );
167
168 ATH_MSG_DEBUG ( " Max difference : " << diff_max );
169
170 auto diff_max_mon = Monitored::Scalar<uint16_t>("diff_max_mon",diff_max);
171 fill("CscRdoMonitor", diff_max_mon);
172
173 // determine of the cluster is a noise/signal cluster Max_Delta_ADC > NoiseCut
174 bool signal = diff_max > m_cscNoiseCut ? true : false;
175 std::vector<int> tmp_xVals_signal;
176 std::vector<int> tmp_xVals_noise;
177 std::vector<float> tmp_secLayer_signal;
178 std::vector<float> tmp_secLayer_noise;
179
180 if (signal)
181 {
182 sigclusCount[ns][nl]++;
183 for(size_t nf = 0; nf < xVals.size(); nf++)
184 {
185 tmp_xVals_signal.push_back(xVals[nf]);
186 tmp_secLayer_signal.push_back(secLayer);
187 }
188 }
189 else
190 {
191 for(size_t nf = 0; nf < xVals.size(); nf++)
192 {
193 tmp_xVals_noise.push_back(xVals[nf]);
194 tmp_secLayer_noise.push_back(secLayer);
195 }
196 }
197 auto isSignal = Monitored::Scalar<int>("isSignal", (int) signal);
198 auto isNoise = Monitored::Scalar<int>("isNoise", (int) !signal);
199 auto tmp_xVals_signal_mon = Monitored::Collection("tmp_xVals_signal_mon", tmp_xVals_signal);
200 auto tmp_secLayer_sig_mon = Monitored::Collection("tmp_secLayer_sig_mon", tmp_secLayer_signal);
201 auto tmp_secLayer_noise_mon = Monitored::Collection("tmp_secLayer_noise_mon", tmp_secLayer_noise);
202 auto sideC_signal = Monitored::Scalar<int>("sideC_signal", (int) (signal && stationEta == -1));
203 auto sideA_signal = Monitored::Scalar<int>("sideA_signal", (int) (signal && stationEta == 1));
204 auto signal_measuresEta = Monitored::Scalar<int>("signal_measuresEta", (int)(signal && !measuresPhi));
205 auto signal_measuresEta_sideC = Monitored::Scalar<int>("signal_measuresEta_sideC", (int)(signal && !measuresPhi && stationEta == -1));
206 auto signal_measuresEta_sideA = Monitored::Scalar<int>("signal_measuresEta_sideA", (int)(signal && !measuresPhi && stationEta == 1));
207 auto signal_measuresPhi = Monitored::Scalar<int>("signal_measuresPhi", (int)(signal && measuresPhi));
208 auto signal_measuresPhi_sideC = Monitored::Scalar<int>("signal_measuresPhi_sideC", (int)(signal && measuresPhi && stationEta == -1));
209 auto signal_measuresPhi_sideA = Monitored::Scalar<int>("signal_measuresPhi_sideA", (int)(signal && measuresPhi && stationEta == 1));
210 auto tmp_xVals_noise_mon = Monitored::Collection("tmp_xVals_noise_mon", tmp_xVals_noise);
211 auto noise_measuresEta = Monitored::Scalar<int>("noise_measuresEta", (int)(!signal && !measuresPhi ));
212 auto noise_measuresPhi = Monitored::Scalar<int>("noise_measuresPhi", (int)(!signal && measuresPhi ));
213
214 fill("CscRdoMonitor", isSignal, isNoise, secLayer, tmp_secLayer_sig_mon, tmp_secLayer_noise_mon, tmp_xVals_signal_mon, tmp_xVals_noise_mon, raw_clus_width, sideC_signal, sideA_signal, signal_measuresEta, signal_measuresEta_sideC, signal_measuresEta_sideA, signal_measuresPhi, signal_measuresPhi_sideC, signal_measuresPhi_sideA, noise_measuresEta, noise_measuresPhi);
215
216 } // end if raw
217 } // end loop over ROD-clusters
218
219 ATH_MSG_DEBUG ( " End loop over clusters======================" );
220 auto nPhiClusWidthCnt_mon = Monitored::Scalar<size_t>("nPhiClusWidthCnt_mon", nPhiClusWidthCnt);
221 auto nEtaClusWidthCnt_mon = Monitored::Scalar<size_t>("nEtaClusWidthCnt_mon", nEtaClusWidthCnt);
222 fill("CscRdoMonitor", nPhiClusWidthCnt_mon, nEtaClusWidthCnt_mon);
223
224 int numeta = 0, numphi = 0, numetasignal = 0, numphisignal = 0;
225 for(int kl = 1; kl < 33; kl++ )
226 {
227 // int m_sec = kl < 17 ? kl*(-1) : kl; // [1->16](-side) [17-32] (+side)
228 for(int km = 1; km < 9; km++ )
229 {
230 int lay = (km > 4 && km < 9) ? km-4 : km; // 1,2,3,4 (phi-layers) 5-4, 6-4, 7-4, 8-4 (eta-layers)
231 bool mphi = (km > 0 && km < 5) ? true : false; // 1,2,3,4 (phi-layers) 5,6,7,8 (eta-layers)
232 std::string wlay = mphi ? "Phi-Layer " : "Eta-Layer: ";
233 int count = clusCount[kl][km];
234 int scount = sigclusCount[kl][km];
235 int tmp_counts_phi = 0, tmp_counts_eta = 0;
236
237 if(count > 0)
238 {
239 float secLayer = kl-16 + 0.2 * (lay - 1) + 0.1;
240 if(mphi)
241 {
242 numphi += count;
243 if(scount > 0)
244 {
245 numphisignal += scount;
246 tmp_counts_phi = count - scount;
247 }
248 else tmp_counts_phi = count;
249 }
250 else
251 {
252 numeta += count;
253 if(scount > 0)
254 {
255 numetasignal += scount;
256 tmp_counts_eta = count - scount;
257 }
258 else tmp_counts_eta = count;
259 }
260 ATH_MSG_DEBUG ( wlay << "Counts sec: [" << kl-16 << "]\tlayer: [" << km << "] = " << secLayer << "\t = " << count << "\t" << scount);
261
262 auto secLayer_count = Monitored::Scalar<float>("secLayer_count", secLayer);
263 auto mphi_mon = Monitored::Scalar<int>("mphi_mon",(int) ( (count>0) && mphi));
264 auto count_mon = Monitored::Scalar<int>("count_mon", count);
265 auto scount_mon = Monitored::Scalar<int>("scount_mon", scount);
266 auto mphi_scount = Monitored::Scalar<int>("mphi_scount",(int) ( (count>0) && mphi && (scount>0)));
267 auto mphi_inv = Monitored::Scalar<int>("mphi_inv", (int) ( (count>0) && !mphi));
268 auto mphi_inv_scount = Monitored::Scalar<int>("mphi_inv_scount", (int) ( (count>0) && !mphi && (scount>0)));
269 auto tmp_counts_phi_mon = Monitored::Scalar<int>("tmp_counts_phi_mon",tmp_counts_phi);
270 auto tmp_counts_eta_mon = Monitored::Scalar<int>("tmp_counts_eta_mon",tmp_counts_eta);
271
272 fill("CscRdoMonitor", count_mon, secLayer_count, mphi_mon, mphi_scount, scount_mon, tmp_counts_phi_mon, mphi_inv, mphi_inv_scount, tmp_counts_eta_mon);
273 } // end if count
274 }
275 }
276
277 auto numphi_mon = Monitored::Scalar<int>("numphi_mon",numphi);
278 auto numeta_mon = Monitored::Scalar<int>("numeta_mon",numeta);
279 auto numphisignal_mon = Monitored::Scalar<int>("numphisignal_mon",numphisignal);
280 auto numetasignal_mon = Monitored::Scalar<int>("numetasignal_mon",numetasignal);
281 auto diffnumphi = Monitored::Scalar<int>("diffnumphi", numphi-numphisignal);
282 auto diffnumeta = Monitored::Scalar<int>("diffnumeta",numeta-numetasignal);
283
284 fill("CscRdoMonitor", numphi_mon, numeta_mon, numphisignal_mon, numetasignal_mon, diffnumphi, diffnumeta);
285 }
286
287 ATH_MSG_DEBUG ( " END EVENT ============================================ " );
288 ATH_MSG_DEBUG ( "done collecting histograms" );
289 ATH_MSG_DEBUG ( "CSCRdoMon::fillHistograms reports success" );
290
291 return StatusCode::SUCCESS;
292}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
void diff(const Jet &rJet1, const Jet &rJet2, std::map< std::string, double > varDiff)
Difference between jets - Non-Class function required by trigger.
Definition Jet.cxx:631
virtual StatusCode initialize() override
initialize
AthMonitorAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Collection of CSC Raw Hits, arranged according to CSC Detector Elements Author: Ketevi A.
Class to hold the electronic output for a single CSC readout channel: n sampling ADC data + the addre...
Definition CscRawData.h:21
uint16_t width() const
Definition CscRawData.h:128
const std::vector< uint16_t > & samples() const
Definition CscRawData.h:130
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
CscRdoValMonAlg(const std::string &name, ISvcLocator *pSvcLocator)
ToolHandle< Muon::ICSC_RDO_Decoder > m_cscRdoDecoderTool
Gaudi::Property< size_t > m_cscNoiseCut
SG::ReadHandleKey< CscRawDataContainer > m_cscRdoKey
virtual StatusCode fillHistograms(const EventContext &ctx) const override
adds event to the monitoring histograms
virtual StatusCode initialize() override
initialize
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
size_type size() const noexcept
Returns the number of elements in the collection.
Declare a monitored scalar variable.
void fill(const ToolHandle< GenericMonitoringTool > &groupHandle, std::vector< std::reference_wrapper< Monitored::IMonitoredVariable > > &&variables) const
Fills a vector of variables to a group by reference.
int count(std::string s, const std::string &regx)
count how many occurances of a regx are in a string
Definition hcg.cxx:146
ValuesCollection< T > Collection(std::string name, const T &collection)
Declare a monitored (double-convertible) collection.