User will overwrite this function. Histogram booking is no longer done in C++. This function is called in execute once the filters are all passed.
58 {
59
60
62
63
65
66
69
70
71
72
73
74 if(!(cscCluster.isValid())) {
76 return StatusCode::FAILURE;
77 }
78
79 ATH_MSG_DEBUG (
" Size of Cluster Collection : " << cscCluster->size() );
81
82 MonStruct monstruct;
83
85 {
87
88
89
90 int clusCount[33][9], sigclusCount[33][9];
91 unsigned int nEtaClusWidthCnt = 0, nPhiClusWidthCnt = 0;
92 for(
unsigned int kl = 0;
kl < 33;
kl++ ) {
93 for(
unsigned int km = 0;
km < 9;
km++ ) {
94 clusCount[
kl][
km] = 0;
95 sigclusCount[
kl][
km] = 0;
96 }
97 }
98
99 float stripsSum_EA = 0.;
100 float stripsSum_EAtest = -50.;
101 float stripsSum_EC = 0.;
102 float stripsSum_ECtest = -50.;
103
104 ATH_MSG_DEBUG (
" Begin loop over clusters ============================");
106 {
108 const std::vector<Identifier>& stripIds = iClus.
rdoList();
109 float clu_charge = iClus.
charge();
110 auto clu_time = Monitored::Scalar<float>(
"clu_time", (iClus.
time()));
111
112 ATH_MSG_DEBUG(
" cluster charge = " << clu_charge <<
"\t cluster time = " << clu_time );
113
114 unsigned int noStrips = stripIds.size();
115 auto noStrips_mon = Monitored::Scalar<int> ("noStrips_mon",noStrips);
116 Identifier clusId = iClus.
identify();
117
118
120 std::string stationString =
m_idHelperSvc->cscIdHelper().stationNameString(stationName);
121 int chamberType = stationString == "CSS" ? 0 : 1;
124 int wireLayer =
m_idHelperSvc->cscIdHelper().wireLayer(clusId);
125 int measuresPhi =
m_idHelperSvc->cscIdHelper().measuresPhi(clusId);
126
130 auto r = Monitored::Scalar<float> (
"r",std::hypot(
x,
y));
131
132 fill(
"CscClusMonitor",
z,
r);
133 fill(
"CscClusMonitor",
y,
x);
134
135
137 auto secLayer = Monitored::Scalar<float> ("secLayer", (sectorNo + 0.2 * (wireLayer - 1) + 0.1) );
138 int xfac = measuresPhi ? -1 : 1;
139
140
141 if(secLayer > 0.) {
142 stripsSum_EA = stripsSum_EA + noStrips;
143 }
144 if(stripsSum_EA > stripsSum_EAtest) {
145 stripsSum_EAtest = stripsSum_EA;
146 }
147
148 if(secLayer < 0. || secLayer == 0.) {
149 stripsSum_EC = stripsSum_EC + noStrips;
150 }
151 if(stripsSum_EC > stripsSum_ECtest) {
152 stripsSum_ECtest = stripsSum_EC;
153 }
154
155
156 int ns = sectorNo < 0 ? sectorNo*(-1) : sectorNo+16;
157 int nl = (measuresPhi ? wireLayer : wireLayer+4);
158
159
161
162
163
164 ATH_MSG_DEBUG(
" ns = " << ns <<
"\tm_nl = " << nl <<
"\tm_sec = " << sectorNo <<
"\t m_lay= " << wireLayer <<
"\tmPhi = " << measuresPhi);
165
166
167
168
169
171 bool cluster_status = ( (
stat ==
"unspoiled") ||
172 (
stat ==
"unspoiled with split") ||
174 ) ? true : false;
175
176
177 bool eta_cluster_status = cluster_status && ( noStrips > 2 ) && (measuresPhi == 0);
178
179
180 bool phi_cluster_status = cluster_status && ( noStrips > 0 ) && (measuresPhi == 1);
181
182 ATH_MSG_DEBUG (
" ClusterStatus eta = " << eta_cluster_status <<
" ,phi = " << phi_cluster_status);
184 << measuresPhi << ",wire:" << wireLayer << ") = " << secLayer << " status = "
185 << stat << " #of strips = " << noStrips );
186
187
188 if(eta_cluster_status || phi_cluster_status ) {
190 bool found_id = true;
191 std::vector <const CscStripPrepData*> stripVec;
192 std::vector <float> fStripIDs;
193
194 float maxStripCharge = 0., maxStipId = 0.;
195 int sIdx = 0, mxIdx = 0;
196
197 auto clus_phi_mon = Monitored::Scalar<int>("clus_phi_mon", (int)measuresPhi);
198 auto clus_eta_mon = Monitored::Scalar<int>("clus_eta_mon", (int)(!measuresPhi));
199 fill(
"CscClusMonitor",noStrips_mon, secLayer,clus_phi_mon, clus_eta_mon);
200
201
202 if(measuresPhi) {
203 nPhiClusWidthCnt++;
204 } else {
205 nEtaClusWidthCnt++;
206 }
207
208
209 for ( std::vector<Identifier>::const_iterator sId = stripIds.begin(); sId != stripIds.end(); ++sId, sIdx++ ) {
210 Identifier id = *sId;
212 auto stripid = Monitored::Scalar<int> ("stripid", thisStrip*xfac);
213 fStripIDs.push_back(stripid);
214
215 fill(
"CscClusMonitor",stripid, secLayer);
216
217 if(!pcol) {
219 if ( icol == nullptr ) {
220 found_id = false;
221 break;
222 } else {
224 }
225 }
226
227 bool found_strip = false;
228 float maxsampChVal = 0.;
229 if(found_id) {
231 found_strip = ( *istrip )->identify() ==
id ;
232 if(found_strip) {
233 stripVec.push_back(*istrip);
234 std::vector<float> samp_charges = ( *istrip )->sampleCharges();
235 for(
unsigned int i = 0;
i < samp_charges.size();
i++ ) {
236 if(samp_charges[i] > maxsampChVal) maxsampChVal = samp_charges[
i];
237 }
238 if(maxsampChVal > maxStripCharge ) {
239 maxStripCharge = maxsampChVal;
240 maxStipId = stripid;
241 mxIdx = sIdx;
242 }
243 break;
244 }
245 }
246 ATH_MSG_DEBUG (
" " << (found_strip?
"FoundStrip " :
"NoStripFound ") <<
" with max sampling = " << maxsampChVal);
247 }
248 }
249
251 ATH_MSG_DEBUG (
" Max Strip charge = " << maxStripCharge <<
" and strip Id = " << maxStipId <<
" and index = " << mxIdx);
252 float qmax = 0., qleft = 0., qright = 0., qsum = 0.;
253
254
255 bool size_ids_coll = (noStrips == stripVec.size() ? true : false) ;
256
257 if(found_id && size_ids_coll ) {
258
259 std::vector<ICscStripFitter::Result>
res;
261 bool range_check = (mxIdx > -1) && (mxIdx < int(noStrips));
262
263 ATH_MSG_DEBUG (
" Range check = (" << mxIdx <<
" > -1 ) && (" << mxIdx <<
" < " << noStrips <<
" ) = " << range_check
264 << "\t size of vec check " << noStrips << " == " << stripVec.size());
265
266 if( range_check ) {
267
268 if(mxIdx-1 >= 0 ) {
270 qleft =
res[0].charge;
271 qsum += qleft;
273 <<
res[0].time <<
" +- " <<
res[0].dtime <<
"\t w +- dw = " <<
res[0].
width <<
" +- "
274 <<
res[0].dwidth <<
"\t status= " <<
res[0].status <<
"\t chisq= " <<
res[0].chsq);
275 }
276
278 qmax =
res[1].charge;
279 qsum += qmax;
281 <<
res[1].time <<
" +- " <<
res[1].dtime <<
"\t w +- dw = " <<
res[1].
width <<
" +- "
282 <<
res[1].dwidth <<
"\t status= " <<
res[1].status <<
"\t chisq= " <<
res[1].chsq);
283
284 if(mxIdx+1 < int(noStrips)) {
286 qright =
res[2].charge;
287 qsum += qright;
289 <<
res[2].time <<
" +- " <<
res[2].dtime <<
"\t w +- dw = " <<
res[2].
width <<
" +- "
290 <<
res[2].dwidth <<
"\t status= " <<
res[2].status <<
"\t chisq= " <<
res[2].chsq);
291 }
292 }
293
294
295
296
297
298 float kiloele = 1.0e-3;
299
300
301
302
303
304 auto QmaxADC = Monitored::Scalar<float>("QmaxADC", (qmax * kiloele));
305 auto QsumADC = Monitored::Scalar<float>("QsumADC", (qsum * kiloele));
306
307
308
309
311
312
313 auto signal_mon = Monitored::Scalar<int>("signal_mon",(int)signal);
314 auto noise_mon = Monitored::Scalar<int>("noise_mon",(int)!(signal));
315 auto clus_phi = Monitored::Scalar<int>("clus_phi", (int)measuresPhi );
316 auto clus_eta = Monitored::Scalar<int>("clus_eta", (int)(!measuresPhi) );
317 auto clus_phiSig = Monitored::Scalar<int>("clus_phiSig", (int)measuresPhi && (signal));
318 auto clus_etaSig = Monitored::Scalar<int>("clus_etaSig", (int)(!measuresPhi) && (signal));
319 auto clus_phiNoise = Monitored::Scalar<int>("clus_phiNoise", (int)measuresPhi && !(signal));
320 auto clus_etaNoise = Monitored::Scalar<int>("clus_etaNoise", (int)(!measuresPhi) && !(signal));
321 auto sideA = Monitored::Scalar<int>(
"sideA",(
int)((
stationEta==1) && (signal)));
322 auto sideC = Monitored::Scalar<int>(
"sideC",(
int)((
stationEta==-1) && (signal)));
323 auto sideA_phiSig = Monitored::Scalar<int>(
"sideA_phiSig", (
int)(signal &&
stationEta==1 && !measuresPhi) );
324 auto sideC_phiSig = Monitored::Scalar<int>(
"sideC_phiSig", (
int)(signal &&
stationEta==-1 && !measuresPhi) );
325
326 if(signal) sigclusCount[
ns][nl]++;
327
328 auto clu_charge_kiloele = Monitored::Scalar<float>(
"clu_charge_kiloele", (iClus.
charge()*kiloele));
329
330 fill(
"CscClusMonitor",fStripIDs_col, QmaxADC, secLayer, noStrips_mon, QsumADC, clu_time, clu_charge_kiloele, clus_phi, clus_eta, clus_phiSig, clus_etaSig, clus_phiNoise, clus_etaNoise, signal_mon, noise_mon, sideA, sideC, sideA_phiSig, sideC_phiSig);
331
333
334 }
335 }
336
337 auto stripsSum_EA_mon = Monitored::Scalar<float> ("stripsSum_EA_mon",stripsSum_EA);
338 auto stripsSum_EC_mon = Monitored::Scalar<float> ("stripsSum_EC_mon",stripsSum_EC);
339 fill(
"CscClusMonitor",stripsSum_EA_mon, stripsSum_EC_mon);
340
341 }
342 ATH_MSG_DEBUG (
" End loop over clusters ============================");
343 auto nPhiClusWidthCnt_mon = Monitored::Scalar<int> ("nPhiClusWidthCnt_mon",nPhiClusWidthCnt);
344 auto nEtaClusWidthCnt_mon = Monitored::Scalar<int> ("nEtaClusWidthCnt_mon",nEtaClusWidthCnt);
345 fill(
"CscClusMonitor",nPhiClusWidthCnt_mon,nEtaClusWidthCnt_mon);
346
347
348 int numeta = 0, numphi = 0;
349 int numetasignal = 0, numphisignal = 0;
350
351
352 for(
int kl = 1;
kl < 33;
kl++ ) {
353
354
355 int eta_hits[4] = {0,0,0,0};
356 bool chamber_empty = true;
357 int sec =
kl < 17 ?
kl*(-1) :
kl;
358 for(
int km = 1;
km < 9;
km++ ) {
359 int lay = (
km > 4 &&
km < 9) ? km-4 :
km;
360 bool mphi = (
km > 0 &&
km < 5) ?
true : false;
361 std::string wlay = mphi ? "Phi-Layer " : "Eta-Layer: ";
364
366 ATH_MSG_DEBUG (
"sec[" << sec <<
"]\t" << wlay <<
"[" << lay <<
"] = " << monstruct.secLayer.back() <<
"= " <<
"\tNsig = " << scount <<
", Ntot = " <<
count);
367 if(mphi){
369 if(scount){
370 chamber_empty = false;
372 }
373 }
374 else{
376 if(scount){
377 eta_hits[lay-1]++;
378 chamber_empty = false;
380 }
381 }
382 ATH_MSG_DEBUG ( wlay <<
"Counts sec: [" << kl-16 <<
"]\tlayer: [" << km <<
"] = " << monstruct.secLayer.back() <<
"\t = " <<
count <<
"\t" << scount);
383 }
384
385 monstruct.count_mon.push_back(
count);
386 monstruct.scount_mon.push_back(scount);
387 monstruct.count_diff.push_back(
count-scount);
388 monstruct.mphi_true.push_back((
int)mphi &&
count);
389 monstruct.mphi_false.push_back((
int)!(mphi) &&
count);
390 monstruct.scount_phi_true.push_back((
int)mphi &&
count && scount);
391 monstruct.scount_phi_false.push_back((
int)mphi &&
count && !scount);
392 monstruct.scount_eta_true.push_back((
int)!(mphi) &&
count && scount);
393 monstruct.scount_eta_false.push_back((
int)!(mphi) &&
count && !scount);
394 monstruct.secLayer.push_back((sec + 0.2 * (lay - 1) + 0.1));
395
396 }
397
398 int segNum_new = -999.;
399 if(!chamber_empty){
400 std::ostringstream nseglist;
401 std::bitset<4> segNum;
402 for(
unsigned int mm = 0;
mm < 4;
mm++) {
403 bool set = (eta_hits[
mm] > 0 ? true :
false);
404 if(set) segNum.set(mm);
405 nseglist << (
set ?
"1" :
"0");
406 }
407 segNum_new = segNum.to_ulong();
408 ATH_MSG_DEBUG(
"segments= " << nseglist.str() <<
"\t = " << segNum.to_ulong());
409 }
410 auto segNum_mon = Monitored::Scalar<int>("segNum_mon", segNum_new);
411 auto sec_mon = Monitored::Scalar<float>("sec_mon",sec+0.3);
412 fill(
"CscClusMonitor", segNum_mon, sec_mon);
413 }
414
415 ATH_MSG_DEBUG(
" numphi = " << numphi <<
"\t numeta = " << numeta <<
"\tm_sphi = " << numphisignal <<
"\t m_seta = " << numetasignal);
416 auto numphi_mon = Monitored::Scalar<int>("numphi_mon", numphi);
417 auto numeta_mon = Monitored::Scalar<int>("numeta_mon", numeta);
418 auto numphi_sig_mon = Monitored::Scalar<int>("numphi_sig_mon", numphisignal);
419 auto numeta_sig_mon = Monitored::Scalar<int>("numeta_sig_mon", numetasignal);
420 auto numphi_numeta_mon = Monitored::Scalar<int>("numphi_numeta_mon", numphi+numeta);
421 auto numphi_numeta_sig_mon = Monitored::Scalar<int>("numphi_numeta_sig_mon", numphisignal+numetasignal);
422 auto num_num_noise_mon = Monitored::Scalar<int>("num_num_noise_mon", (numphi-numphisignal)+(numeta-numetasignal));
423 auto numphi_diff_mon = Monitored::Scalar<int>("numphi_diff_mon", numphi-numphisignal);
424 auto numeta_diff_mon = Monitored::Scalar<int>("numeta_diff_mon", numeta-numetasignal);
425
426 fill(
"CscClusMonitor",numphi_mon,numeta_mon,numphi_sig_mon,numeta_sig_mon,numphi_numeta_mon,numphi_numeta_sig_mon,num_num_noise_mon,numphi_diff_mon,numeta_diff_mon);
427
428 }
429
441 fill(
"CscClusMonitor", count_mon, scount_mon, count_diff, secLayer, mphi_true, mphi_false, scount_phi_true, scount_phi_false, scount_eta_true, scount_eta_false);
442
444
446
447}
double charge(const T &p)
std::pair< std::vector< unsigned int >, bool > res
bool evtSelTriggersPassed() const
SG::ReadHandleKey< Muon::CscPrepDataContainer > m_cscClusterKey
Gaudi::Property< double > m_qmaxADCCut
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
ToolHandle< ICscStripFitter > m_stripFitter
SG::ReadHandleKey< Muon::CscStripPrepDataContainer > m_cscPRDKey
DataModel_detail::const_iterator< DataVector > const_iterator
const_iterator end() const noexcept
const_iterator begin() const noexcept
virtual const Amg::Vector3D & globalPosition() const override final
Returns the global position.
double time() const
Returns the time.
int charge() const
Returns the charge.
CscClusterStatus status() const
Returns the Csc status (position measurement) flag.
virtual IdentifierHash identifyHash() const override final
Identifier identify() const
return the identifier
const std::vector< Identifier > & rdoList() const
return the List of rdo identifiers (pointers)
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 ®x)
count how many occurances of a regx are in a string
constexpr std::enable_if_t< is_bitmask_v< E >, E & > set(E &lhs, E rhs)
Convenience function to set bits in a class enum bitmask.
::StatusCode StatusCode
StatusCode definition for legacy code.
ValuesCollection< T > Collection(std::string name, const T &collection)
Declare a monitored (double-convertible) collection.
MuonPrepDataCollection< CscPrepData > CscPrepDataCollection
MuonPrepDataCollection< CscStripPrepData > CscStripPrepDataCollection
std::string toString(CscStripStatus cstat)
Return a string description of a CSC cluster status flag.
unsigned int constexpr sideC
unsigned int constexpr sideA
count_diff(count_in, count_ref, total_in, total_ref, thr_frac, thr_num)