ATLAS Offline Software
Loading...
Searching...
No Matches
EventReaderAlg.cxx
Go to the documentation of this file.
1// Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
2
4
8
9#include "Identifier/Identifier.h"
11
12#include "CaloGeoHelpers/CaloSampling.h"
13
16
18
19#include <bitset>
20#include "CLHEP/Units/SystemOfUnits.h"
21#include "TTree.h"
22#include "xAODEgamma/EgammaxAODHelpers.h" //for getAssociatedTopoClusters
23
24
25using CLHEP::twopi;
26using CLHEP::GeV;
27using CLHEP::pi;
28
29EventReaderAlg::EventReaderAlg( const std::string& name, ISvcLocator* pSvcLocator ) :
30 EventReaderBaseAlg(name, pSvcLocator)
31 , m_ntsvc("THistSvc/THistSvc", name)
32 {}
33
35 ATH_MSG_INFO ("Initializing " << name() << "...");
36 ATH_MSG_INFO ("(EventReader) Initializing conditions...");
37
38 // Conditions
41 ATH_CHECK(m_noiseCDOKey.initialize()); //---- retrieve the noise CDO
42 ATH_CHECK(m_lumiDataKey.initialize() );
43 ATH_CHECK(m_pedestalKey.initialize());
44 ATH_CHECK(m_adc2MeVKey.initialize());
45 ATH_CHECK(m_ofcKey.initialize());
46 ATH_CHECK(m_shapeKey.initialize());
47 ATH_CHECK(m_minBiasAvgKey.initialize());
48 ATH_CHECK(m_fSamplKey.initialize());
50 ATH_MSG_DEBUG(" (EventReader) Condition Keys initialized!");
51
52 // Containers
53 ATH_CHECK(m_eventInfoSgKey.initialize());
54 ATH_CHECK(m_primVertSgKey.initialize());
55 ATH_CHECK(m_caloClusSgKey.initialize());
58 ATH_CHECK(m_electronCntSgKey.initialize());
59 ATH_CHECK(m_truthEventCntSgKey.initialize());
60 ATH_CHECK(m_larEMBHitCntSgKey.initialize());
61 ATH_CHECK(m_larDigitCntSgKey.initialize());
62 ATH_CHECK(m_larRawChCntSgKey.initialize());
63 ATH_CHECK(m_allCaloCellCntSgKey.initialize());
64 ATH_MSG_DEBUG(" (EventReader) Container Keys initialized!");
65
66 // -- Retrieve ID Helpers --
67 ATH_CHECK( detStore()->retrieve(m_onlineLArID, "LArOnlineID") ); // get online ID info from LAr (online)
68 ATH_CHECK( detStore()->retrieve (m_calocell_id, "CaloCell_ID") );
69 ATH_CHECK( m_larCablingKey.initialize());
70
71 StatusCode sc = detStore()->retrieve(m_caloIdMgr);
72 if (sc.isFailure()) {
73 ATH_MSG_ERROR(" Unable to retrieve CaloIdManager from DetectoreStore");
74 return StatusCode::FAILURE;
75 }
76 else{
77 m_larem_id = m_caloIdMgr->getEM_ID();
78 m_larhec_id = m_caloIdMgr->getHEC_ID();
79 m_larfcal_id = m_caloIdMgr->getFCAL_ID();
80 }
81 // -------------------------
82
83 // Book the variables to save in the *.root
84 m_Tree = new TTree("dumpedData", "dumpedData");
85 m_secondTree = new TTree("lumiblockData", "lumiblockData");
86
87 ATH_MSG_DEBUG("Booking branches...");
88 bookBranches(m_Tree); // book TTree with branches
90
91 if (!m_ntsvc->regTree("/rec/tree1", m_Tree).isSuccess()) {
92 ATH_MSG_ERROR("could not register tree [dumpedData]");
93 return StatusCode::FAILURE;
94 }
95 if (!m_ntsvc->regTree("/rec/tree2", m_secondTree).isSuccess()) {
96 ATH_MSG_ERROR("could not register tree [database]");
97 return StatusCode::FAILURE;
98 }
99
100 if (m_doTagAndProbe && m_doElecSelectByTrackOnly) ATH_MSG_INFO("Entering single_e mode...");
101 else if (m_doTagAndProbe && !m_doElecSelectByTrackOnly) ATH_MSG_INFO("Entering Zee T&P mode...");
102 else {
103 ATH_MSG_ERROR("No valid electron chain selected!");
104 return StatusCode::FAILURE;
105 }
106
107 return StatusCode::SUCCESS;
108}
109
110StatusCode EventReaderAlg::execute(const EventContext& ctx){
111 ATH_MSG_DEBUG ("Executing " << name() << "...");
112 ATH_MSG_DEBUG("Cleanning of event variables...");
113 clear(); // clear all variables selected to dump to the output NTuple.
114
115 // Conditions
116 if (!m_isMC){
117
118 if (!m_EneRescalerFldr.empty()){
120 const coral::Blob& blob = (**EneRescalerHdl)["CaloCondBlob16M"].data<coral::Blob>();
121 if (blob.size()<3) ATH_MSG_WARNING("Found empty blob, no correction needed");
122 m_EneRescaler = CaloCondBlobFlt::getInstance(blob); // offline egamma cell correction (due from 5 to 4 downsampling rate)
123 ATH_MSG_DEBUG("offlineEnergyRescaler is set!");
124 }
125
126 if (!m_run2DSPThresholdsKey.empty()) {
128 m_run2DSPThresh = std::unique_ptr<LArDSPThresholdsFlat>(new LArDSPThresholdsFlat(*dspThrshAttrHdl));
129 ATH_MSG_DEBUG("DSPThreshold has set!");
130 }
131
132 if (!m_lumiDataKey.empty()){
134 m_lumis =*lumiHdl;
135 ATH_MSG_DEBUG("LuminosityCondData is set!");
136 }
137
138 if (!m_offlineHVScaleCorrKey.empty()){
140 m_oflHVCorr =*oflHVCorrHdl;
141 ATH_MSG_DEBUG("OfflineHVCorrection is set!");
142 }
143 }
144 else{
145 if (!m_fSamplKey.empty()){ // MC
147 m_fSampl = *fSamplHdl;
148 ATH_MSG_DEBUG("SamplingFraction is set!");
149 }
150 }
151
159
160 m_larCabling = *larCablingHdl;
161 m_noiseCDO = *noiseHdl;
162 m_peds = *pedHdl;
163 m_adc2MeVs = *adc2mevHdl;
164 m_ofcs = *ofcHdl;
165 m_shapes = *shapeHdl;
166 m_minBiasAvgs = *minBiasAvgHdl;
167
169 if (!ei.isValid()) ATH_MSG_ERROR(" EventInfo container is not valid!");
170
171 if (ei->errorState(xAOD::EventInfo::LAr) == xAOD::EventInfo::Error) {
172 ATH_MSG_WARNING("Event not passing LAr! Skipping event.");
173 return StatusCode::SUCCESS;
174 }
175
177 if (!primVertexCnt.isValid()) ATH_MSG_ERROR(" Primary Vertex container is not valid!");
178
179 // *** Lumiblock data ***
180 // Verify if ei->lumiBlock() was dumped into lb_lumiblock. if not, add it.
181 // Each LB entry should be dumped just once, since their content doesnt change per event.
182 if (std::count(m_lb_lumiblock->begin(), m_lb_lumiblock->end(), ei->lumiBlock()) == 0){
183 if(!dumpLumiblockInfo(ei)) ATH_MSG_INFO("Lumiblock information cannot be collected!");
184 }
185
186 // EventInfo
187 if(!dumpEventInfo(ei)) ATH_MSG_INFO("Event information cannot be collected!");
188
189 // Clusters
190 if (m_doClusterDump){
191
193
194 if(!cls.isValid()){
195 ATH_MSG_ERROR("CaloCluster container is not valid!");
196 return StatusCode::FAILURE;
197 }
198
199 for (const xAOD::CaloCluster *cl : *cls){
200 ATH_MSG_DEBUG ("Cluster "<< m_c_clusterIndexCounter << ", Total size: " << cl->numberCells() << "/ "<< cl->clusterSize() << ", etaBE: " << cl->etaBE(2) << ", numberCellsInSampling: " << cl->numberCellsInSampling(CaloSampling::EMB2) <<", eta size: " << cl->etasize(CaloSampling::EMB2) << ", phi size: " << cl->phisize(CaloSampling::EMB2) );
201
202 if (! dumpClusterCells(cl, m_c_clusterIndexCounter , ctx) ) ATH_MSG_WARNING ("CaloCluster Cells cannot be dumped for Zee.");
203
205 }
206 }
207
208 // Apply the Zee cut
210
211 if(!dumpZeeCut(ei,primVertexCnt, ctx)) ATH_MSG_DEBUG("Zee cut algorithm cannot be executed!");
212
213 std::string eSelectionText = "";
214 SG::ReadHandle<xAOD::ElectronContainer> myElectronsSelection;
215
216 if (m_doElecSelectByTrackOnly) eSelectionText = "Number of myElectronsSelection single electrons: ";
217 else eSelectionText = "Number of myElectronsSelection tagAndProbe Zee candidates: ";
218
219 myElectronsSelection = SG::makeHandle(m_myElecSelectionSgKey,ctx);
220 // Optional: Skip empty events.
221 if (m_skipEmptyEvents && (myElectronsSelection->size() == 0)){
222 ATH_MSG_INFO("This event has no selected electrons! Cleanning event variables and skipping writing to NTuple...");
223 clear(); // clear all variables selected to dump to the output NTuple.
224 return StatusCode::SUCCESS;
225 }
226
227 if(!FillNTupleWithSelectedElectrons(ei, primVertexCnt, myElectronsSelection, eSelectionText, ctx)) ATH_MSG_DEBUG("FillNTupleWithElectrons cannot be executed!");
228
229 if (m_isMC){
230 // Particle Truth
233 if (!truthParticleCnt.isValid()) ATH_MSG_ERROR("TruthParticleContainer is not valid!");
234
235 if(!dumpTruthParticle(myElectronsSelection, truthParticleCnt)) ATH_MSG_DEBUG("Truth Particle information cannot be collected!");
236 }
237 }
238 } // end if-start TagAndProbe chain
239
240 m_Tree->Fill();
241
242 return StatusCode::SUCCESS;
243}
244
246
247 ATH_MSG_INFO(eSelectionText << elContainer->size() );
248
249 int electronIndex = 0;
250 for (const xAOD::Electron *elec : *elContainer){
251
252 const auto& clusLinks = elec->caloClusterLinks(); // get the cluster links for the electron
253
254 // loop over clusters and dump cells
255 for (const auto& clusLink : clusLinks){
256
257 // get associated topoclusters from superclusters
259 auto assocCls = xAOD::EgammaHelpers::getAssociatedTopoClusters( (*clusLink) );
260
261 for ( auto assocCl : assocCls){
262 ATH_MSG_DEBUG ("AssociatedTopoCluster " << m_c_clusterIndexCounter << ": e: "<< assocCl->e() << ", eta: " << assocCl->eta() << ", phi: " << assocCl->phi() <<". Total size: " << assocCl->numberCells() << "/ "<< assocCl->clusterSize() << ", etaBE: " << assocCl->etaBE(2) << ", numberCellsInSampling: " << assocCl->numberCellsInSampling(CaloSampling::EMB2) <<", eta size: " << assocCl->etasize(CaloSampling::EMB2) << ", phi size: " << assocCl->phisize(CaloSampling::EMB2) );
263 if (! dumpClusterCells(assocCl, m_c_clusterIndexCounter, ctx ) ) ATH_MSG_WARNING ("CaloCluster Cells cannot be dumped for Zee.");
264
266 }
267 }
268 else{ // dump only the superclusters
269 if (! dumpClusterCells((*clusLink), m_c_clusterIndexCounter, ctx ) ) ATH_MSG_WARNING ("CaloCluster Cells cannot be dumped for Zee.");
271 }
272 m_c_electronIndex_clusterLvl->push_back(electronIndex); // electron indexes for each cluster
273 } //end-for loop in clusLinks
274
275 // dump tag and probe electrons
276 if (!dumpElectrons(elec)) ATH_MSG_WARNING ("Cannot dump ordinary electrons...");
277 if (!dumpOfflineSS(elec)) ATH_MSG_WARNING ("Cannot dump offline shower shapes for electrons...");
278 if (!dumpPrimVertexAssocToElectron(elec, primVertexCnt, ei)) ATH_MSG_WARNING ("Cannot dump primary vertexes info associated to electrons...");
279 m_el_index->push_back(electronIndex);
280
281 electronIndex++;
282
283 } // end-for loop in m_electronsSelectedByTrack electrons
284
285 return StatusCode::SUCCESS;
286}
287
289 m_el_f1->push_back(electron->showerShapeValue(xAOD::EgammaParameters::f1));
290 m_el_f3->push_back(electron->showerShapeValue(xAOD::EgammaParameters::f3));
291 m_el_eratio->push_back(electron->showerShapeValue(xAOD::EgammaParameters::Eratio));
292 m_el_weta1->push_back(electron->showerShapeValue(xAOD::EgammaParameters::weta1));
293 m_el_weta2->push_back(electron->showerShapeValue(xAOD::EgammaParameters::weta2));
294 m_el_fracs1->push_back(electron->showerShapeValue(xAOD::EgammaParameters::fracs1));
295 m_el_wtots1->push_back(electron->showerShapeValue(xAOD::EgammaParameters::wtots1));
296 m_el_e277->push_back(electron->showerShapeValue(xAOD::EgammaParameters::e277));
297 m_el_reta->push_back(electron->showerShapeValue(xAOD::EgammaParameters::Reta));
298 m_el_rphi->push_back(electron->showerShapeValue(xAOD::EgammaParameters::Rphi));
299 m_el_deltae->push_back(electron->showerShapeValue(xAOD::EgammaParameters::DeltaE));
300 m_el_rhad->push_back(electron->showerShapeValue(xAOD::EgammaParameters::Rhad));
301 m_el_rhad1->push_back(electron->showerShapeValue(xAOD::EgammaParameters::Rhad1));
302
303 return StatusCode::SUCCESS;
304}
305
307 float electronEt = electron->e()/(cosh(electron->trackParticle()->eta()));
308 float track_p = (electron->trackParticle())->pt()*std::cosh((electron->trackParticle())->eta());
309 float eoverp = (electron->caloCluster())->e()/track_p;
310 m_el_eoverp->push_back(eoverp);
311 m_el_Pt->push_back(electron->pt());
312 m_el_et->push_back(electronEt);
313 m_el_Eta->push_back(electron->eta());
314 m_el_Phi->push_back(electron->phi());
315 m_el_m->push_back(electron->m());
316
317 return StatusCode::SUCCESS;
318}
319
321
322 const xAOD::TrackParticle *trackElectron = el->trackParticle();
323
324 // check for primary vertex in the event
325 // *************** Primary vertex check ***************
326 //loop over vertices and look for good primary vertex
327 float bestDeltaZ0Sin = 9999.0, bestZfromVertex = 9999.0, bestXFromVertex = 9999.0, bestYFromVertex = 9999.0, bestDeltaZ0 = 9999.0;
328 double bestD0Sig = 9999.0;
329 int vtxCounter = 0;//, bestVtxCounter = 0;
330 bool isAnyClosestVtx = false;
331 for (const xAOD::Vertex *vxIter : *primVertexCnt) {
332
333 // Select good primary vertex
334 float zFromVertex = vxIter->z();
335 float delta_z0 = fabs(trackElectron->z0() + trackElectron->vz() - zFromVertex); //where trk.vz() represents the point of reference for the z0 calculation (in this case, the beamspot position along the z axis).
336 float delta_z0_sin = delta_z0 * sin(trackElectron->theta()); //where sin(trk.theta()) parameterises the uncertainty of the z0 measurement.
337 double d0sig = xAOD::TrackingHelpers::d0significance( trackElectron, evtInfo->beamPosSigmaX(), evtInfo->beamPosSigmaY(), evtInfo->beamPosSigmaXY() );
338
339
340 if ((vxIter->vertexType() == xAOD::VxType::PriVtx) && ( fabs(delta_z0_sin) < m_z0Tag) && (fabs(d0sig) < m_d0TagSig) ){ //is this vertex passed into d0sig and dz0Sin conditions?
341 isAnyClosestVtx = true;
342
343 ATH_MSG_DEBUG ("(dumpPrimVertexAssocToElectron) Vertex "<< vtxCounter << ": This is a primary vertex. |delta_z0_sin| < 0.5 mm ("<< delta_z0_sin << "). |d0sig| < 5 (" << d0sig << ")");
344 if ( (fabs(delta_z0_sin) < fabs(bestDeltaZ0Sin) ) && (fabs(d0sig) < fabs(bestD0Sig)) ) // is this vertex the closest one to that electron track?
345 {
346 // assign all variables to dump:
347 ATH_MSG_DEBUG ("(dumpPrimVertexAssocToElectron) New best associated Vertex. Vertex "<< vtxCounter << ": |delta_z0_sin| < 0.5 mm ("<< delta_z0_sin << "). |d0sig| < 5 (" << d0sig << ")");
348
349 bestDeltaZ0Sin = delta_z0_sin;
350 bestD0Sig = d0sig;
351
352 bestXFromVertex = vxIter->x();
353 bestYFromVertex = vxIter->y();
354 bestZfromVertex = zFromVertex;
355 bestDeltaZ0 = delta_z0;
356 }
357 }
358 vtxCounter++;
359 }
360 // --------- Dump here: ---------
361 if (isAnyClosestVtx){
362 m_vtx_x->push_back(bestXFromVertex);
363 m_vtx_y->push_back(bestYFromVertex);
364 m_vtx_z->push_back(bestZfromVertex);
365 m_vtx_deltaZ0->push_back(bestDeltaZ0);
366 m_vtx_delta_z0_sin->push_back(bestDeltaZ0Sin);
367 m_vtx_d0sig->push_back(bestD0Sig);
368 }
369 else{
370 ATH_MSG_ERROR("A pre-selected electron track has no closest vertex to dump! (weird?)");
371 }
372 // -------------------------------
373
374
375 return StatusCode::SUCCESS;
376}
377
379
380 if (!m_isMC){
381 m_lb_bcidLuminosity->push_back(m_lumis->lbLuminosityPerBCIDVector());
382 ATH_MSG_INFO ("LB_data: lbLuminosityPerBCIDVector stored into ntuple." );
383 }
384 m_lb_lumiblock->push_back( ei->lumiBlock() );
385 ATH_MSG_INFO ("LB_data: Lumiblock "<< ei->lumiBlock() << " stored into ntuple." );
386
387 return StatusCode::SUCCESS;
388}
389
391 m_e_runNumber = ei->runNumber();
392 m_e_eventNumber = ei->eventNumber();
393 m_e_bcid = ei->bcid();
394 m_e_lumiBlock = ei->lumiBlock();
395 m_e_inTimePileup = ei->actualInteractionsPerCrossing();
396 m_e_outOfTimePileUp = ei->averageInteractionsPerCrossing();
397
398 ATH_MSG_INFO ("in execute, runNumber = " << m_e_runNumber << ", eventNumber = " << m_e_eventNumber << ", bcid: " << m_e_bcid );
399
400 return StatusCode::SUCCESS;
401}
402
404 ATH_MSG_INFO("Dumping Zee cut region...");
405
406 auto electronSelectionCnt = std::make_unique<ConstDataVector<xAOD::ElectronContainer>> (SG::VIEW_ELEMENTS);
407 auto TagAndProbeElectronSelectionCnt = std::make_unique<ConstDataVector<xAOD::ElectronContainer>> (SG::VIEW_ELEMENTS);
408
410
411 if (!electronsCnt.isValid()) {
412 ATH_MSG_ERROR("Electron container is not valid!");
413 return StatusCode::FAILURE;
414 }
415
416 // Pre-selection of electrons
417 for (auto el : *electronsCnt){
418 if (std::abs(el->eta()) > m_elecEtaCut){ // apply electron |eta| cut
419 continue;
420 }
421 if (trackSelectionElectrons(el, primVertexCnt, ei) == true){
422 if (eOverPElectron(el) == true){ // if 0.7 < E/p < 1.4
423 electronSelectionCnt->push_back( el );
424 }
425 }
426 else continue;
427 }
428
429 if (m_doElecSelectByTrackOnly){ // do not proceed to T&P
430 ATH_CHECK (evtStore()->record( electronSelectionCnt.release(), "MySelectedElectrons"));
431 return StatusCode::SUCCESS;
432 }
433
434 if (electronSelectionCnt->size() < 2){
435 ATH_MSG_DEBUG("(TagAndProbe) Not enough Electrons for T&P (nElectrons="<<electronSelectionCnt->size() << "). Storing "<<electronSelectionCnt->size()<<" electron on MyTagAndProbeElectrons container. This will not be dumped!");
436 ATH_CHECK (evtStore()->record( TagAndProbeElectronSelectionCnt.release(), "MyTagAndProbeElectrons"));
437 return StatusCode::SUCCESS;
438 }
439
440 // ## Loop over electron container in search of Zee pairs ##
441 for (const xAOD::Electron *elTag : *electronSelectionCnt){
442
443 if (! isTagElectron(elTag)) continue;
444 ATH_MSG_DEBUG("(TagAndProbe) Electron is a Tag!");
445
446 for (const xAOD::Electron *elProbe : *electronSelectionCnt){
447 if (elTag==elProbe) continue;
448
449 //check for charge (opposite charges for Zee)
450 if ( elTag->charge() == elProbe->charge() ) continue;
451 ATH_MSG_DEBUG ("(TagAndProbe) Electron Pair Charges are opposite! Good.");
452
453 //check for Zee mass
454 TLorentzVector el1;
455 TLorentzVector el2;
456 el1.SetPtEtaPhiE(elTag->pt(), elTag->trackParticle()->eta(), elTag->trackParticle()->phi(), elTag->e());
457 el2.SetPtEtaPhiE(elProbe->pt(), elProbe->trackParticle()->eta(), elProbe->trackParticle()->phi(), elProbe->e());
458
459 float tpPairMass = (el1 + el2).M(); // mass of the electron pair
460 ATH_MSG_DEBUG ("(TagAndProbe) Electron Pair mass: " << tpPairMass << ". Min: "<< m_minZeeMassTP*GeV << ". Max: " << m_maxZeeMassTP*GeV);
461 if (!((tpPairMass > m_minZeeMassTP*GeV) && (tpPairMass < m_maxZeeMassTP*GeV))){
462 ATH_MSG_DEBUG ("(TagAndProbe) Electron pair not in Z mass window.");
463 continue;
464 }
465 else{
466 ATH_MSG_INFO ("(TagAndProbe) Electron-positron pair are in Z mass window.");
467 // test for goodProbeElectron
468 if (!isGoodProbeElectron(elProbe)){
469 ATH_MSG_DEBUG (" Probe electron not passed in Goodnes of Probe test.");
470 continue;
471 }
472 ATH_MSG_INFO("(TagAndProbe) Electron is a good probe.");
473 ATH_MSG_INFO ("Tag and probe pair found.");
474
475 ATH_MSG_INFO ("TAG: pt="<< elTag->pt() << " e="<< elTag->e());
476 ATH_MSG_INFO ("PRO: pt="<< elProbe->pt() << " e="<< elProbe->e());
477 ATH_MSG_INFO ("Zee: M="<< tpPairMass << " E="<< (el1 + el2).E());
478 m_zee_M->push_back((el1 + el2).M());
479 m_zee_E->push_back((el1 + el2).E());
480 m_zee_pt->push_back((el1 + el2).Pt());
481 m_zee_px->push_back((el1 + el2).Px());
482 m_zee_py->push_back((el1 + el2).Py());
483 m_zee_pz->push_back((el1 + el2).Pz());
484 m_zee_T->push_back((el1 + el2).T());
485 m_zee_deltaR->push_back(el1.DeltaR(el2));
486
487 // ****************************************************************
488 // store electrons in a container to dump their clusters and cells.
489 TagAndProbeElectronSelectionCnt->push_back( (elTag) );
490 // ****************************************************************
491 }
492 } //end-loop probe electrons
493 } //end-loop tag electrons
494
495 ATH_CHECK (evtStore()->record( TagAndProbeElectronSelectionCnt.release(), "MyTagAndProbeElectrons"));
496 return StatusCode::SUCCESS;
497}
498
500 ATH_MSG_INFO("Dumping Truth Particle...");
501
502 auto elecCandidates = std::make_unique<ConstDataVector<xAOD::TruthParticleContainer>> (SG::VIEW_ELEMENTS);
503
504 if (truthParticleCnt->size() == 0) ATH_MSG_INFO("truthParticleCnt is empty!");
505 else{
506 for (const xAOD::Electron *recElectron : *electronSelectionCnt){
507
509 elecCandidates->push_back( truth );
510
511 ATH_MSG_INFO("(TruthParticle) Reco pt="<< recElectron->pt()<<" , Truth pt= "<< truth->pt());
512 }
513 }
514
515 if (elecCandidates->size() > 0) ATH_MSG_INFO("(TruthParticle) Size of elecCandidates is "<< elecCandidates->size()<<" !");
516
517 for (const xAOD::TruthParticle *elecSelected : *elecCandidates){
518 const xAOD::TruthVertex* vertex = elecSelected->prodVtx();
519
520 TLorentzVector elecCandidateLorentz;
521 elecCandidateLorentz.SetPtEtaPhiE(elecSelected->pt(),elecSelected->eta(),elecSelected->phi(),elecSelected->e());
522
523 m_mc_vert_x->push_back(vertex->x()); // vertex displacement
524 m_mc_vert_y->push_back(vertex->y()); // vertex displacement
525 m_mc_vert_z->push_back(vertex->z()); // vertex displacement in beam direction
526 m_mc_vert_time->push_back(vertex->t()); // vertex time
527 m_mc_vert_perp->push_back(vertex->perp()); // Vertex transverse distance from the beam line
528 m_mc_vert_eta->push_back(vertex->eta()); // Vertex pseudorapidity
529 m_mc_vert_phi->push_back(vertex->phi()); // Vertex azimuthal angle
530 m_mc_vert_uniqueID->push_back(HepMC::uniqueID(vertex));
531 m_mc_vert_status->push_back(HepMC::status(vertex));
532
533 m_mc_part_energy->push_back(elecSelected->e());
534 m_mc_part_pt->push_back(elecSelected->pt());
535 m_mc_part_pdgId->push_back(elecSelected->pdgId());
536 m_mc_part_m->push_back(elecSelected->m());
537 m_mc_part_phi->push_back(elecSelected->phi());
538 m_mc_part_eta->push_back(elecSelected->eta());
539 }
540 ATH_CHECK (evtStore()->record( elecCandidates.release(), "MyMatchedTruthElectrons"));
541 return StatusCode::SUCCESS;
542
543}
544
545StatusCode EventReaderAlg::dumpClusterCells(const xAOD::CaloCluster *cl, int clusIndex, const EventContext& ctx){
546
548 if(!LarDigCnt.isValid()) ATH_MSG_ERROR("LArDigitContainer is not a valid container!");
550 if(!LArRawCnt.isValid()) ATH_MSG_ERROR("LArRawChannelContainer is not a valid container!");
551
552 // calorimeter level
553 //Local variable larClusteredDigits uses 25000 bytes of stack space
554 //coverity[STACK_USE]
555 std::bitset<200000> larClusteredDigits;
556 std::vector<size_t> caloHashMap;
557 std::vector<HWIdentifier> channelHwidInClusterMap; //unique for any readout in the ATLAS
558 std::vector<int> cellIndexMap;
559 std::vector<float> channelIndexMap;
560 std::vector<int> cellLayerMap;
561 // cell level
562 std::vector<double> clusCellEtaMap;//unused
563 std::vector<double> clusCellPhiMap; //unused
564 // channel level
565 std::vector<double> channelEnergyInClusterMap;
566 std::vector<double> channelTimeInClusterMap;
567 std::vector<double> channelEtaInClusterMap;
568 std::vector<double> channelPhiInClusterMap;
569 std::vector<float> channelEffectiveSigmaClusterMap;
570 std::vector<float> channelNoiseClusterMap;
571
572 std::vector<int> channelCaloRegionMap;
573 std::vector<bool> badChannelMap;
574
575 // cluster
576 double clusEta = cl->eta();
577 double clusPhi = cl->phi();
578 double clusEt = cl->et();
579 double clusPt = cl->pt();
580 double clusTime = cl->time();
581
582 ATH_MSG_DEBUG (" (Cluster) Cluster: "<< clusIndex <<", numberCells: " << cl->numberCells() << ", e = " << cl->e() << ", time = "<< clusTime << ", pt = " << cl->pt() << " , eta = " << cl->eta() << " , phi = " << cl->phi());
583
584 // loop over cells in cluster
585 auto itrCellsBegin = cl->cell_begin();
586 auto itrCellsEnd = cl->cell_end();
587 int cellNum = 0; //cell number just for printing out
588
589 for (auto itCells=itrCellsBegin; itCells != itrCellsEnd; ++itCells){
590 const CaloCell* cell = (*itCells); //get the caloCells
591 if (cell){ // check for empty clusters
592 Identifier cellId = cell->ID();
593
594 int caloRegionIndex = getCaloRegionIndex(cell); // custom caloRegionIndex based on caloDDE
595
596 double eneCell = cell->energy();
597 double timeCell = cell->time();
598 double etaCell = cell->eta();
599 double phiCell = cell->phi();
600 int gainCell = cell->gain(); // CaloGain type
601 int layerCell = m_calocell_id->calo_sample(cell->ID());
602 bool badCell = cell->badcell(); // applied to LAR channels. For Tile, we use TileCell* tCell->badch1() or 2.
603 bool isTile = cell->caloDDE()->is_tile();
604 bool isLAr = cell->caloDDE()->is_lar_em();
605 bool isLArFwd = cell->caloDDE()->is_lar_fcal();
606 bool isLArHEC = cell->caloDDE()->is_lar_hec();
607 double detaCell = cell->caloDDE()->deta(); //delta eta - granularity
608 double dphiCell = cell->caloDDE()->dphi(); //delta phi - granularity
609 float effSigma = m_noiseCDO->getEffectiveSigma(cell->ID(), cell->gain(), cell->energy()); // effective sigma of cell related to its noise.
610 float cellNoise = m_noiseCDO->getNoise(cell->ID(), cell->gain()); // cell noise value
611
612 IdentifierHash chidHash;
613 HWIdentifier chhwid;
614 size_t index;
615
616 // ========= TileCal ==========
617 if (isTile) continue;
618
619 // ========= LAr ==========
620 else if ((isLAr) || (isLArFwd) || (isLArHEC)) { //LAr
621 chhwid = m_larCabling->createSignalChannelID(cellId);
622 chidHash = m_onlineLArID->channel_Hash(chhwid);
623 index = (size_t) (chidHash);
624
625 if (larClusteredDigits.test(index)) {
626 ATH_MSG_ERROR (" ##### (Cluster) Error LAr: Conflict index position in Channel map. Position was already filled in this event. Skipping the cell of index: " << index << " and hwid: " << chhwid << ". Cell_E/t="<<cell->energy() << "/"<< cell->time() << ". Eta/Phi: "<< cell->eta() << "/" << cell->phi());
627 continue;
628 }
629 if (badCell && m_noBadCells){
630 ATH_MSG_INFO (" (Cluster)(LAr) Cell "<< cellNum <<" in cluster is a bad LAr channel! Skipping the cell.");
631 continue;
632 }
633 larClusteredDigits.set(index);
634 caloHashMap.push_back(index);
635 cellIndexMap.push_back(m_c_cellIndexCounter);
636 clusCellEtaMap.push_back(etaCell);
637 clusCellPhiMap.push_back(phiCell);
638 cellLayerMap.push_back(layerCell);
639 channelIndexMap.push_back( m_c_cellIndexCounter );
640 channelHwidInClusterMap.push_back(chhwid);
641 channelTimeInClusterMap.push_back(timeCell);
642 channelEnergyInClusterMap.push_back(eneCell);
643 channelCaloRegionMap.push_back(caloRegionIndex);
644 channelEffectiveSigmaClusterMap.push_back(effSigma);
645 channelNoiseClusterMap.push_back(cellNoise);
646 if (!m_noBadCells) badChannelMap.push_back(badCell);
647
648 if (m_printCellsClus){ //optional to help debugging
649 ATH_MSG_INFO (" (Cluster) in IsLAr: Cell (layer) "<< cellNum << " (" << layerCell <<") ID: " << cellId << "). HwId (B_EC/P_N/FeedTr/slot/ch) " << chhwid << " (" << m_onlineLArID->barrel_ec(chhwid) << "/" << m_onlineLArID->pos_neg(chhwid) << "/"<< m_onlineLArID->feedthrough(chhwid) << "/" << m_onlineLArID->slot(chhwid) << "/" << m_onlineLArID->channel(chhwid) << ") . Index: " << index << ". ene " << eneCell << ". time " << timeCell << ". D_eta: " << detaCell << ". D_phi: " << dphiCell << " ):" << ". Eta/Phi: "<< cell->eta() << "/" << cell->phi());
650 }
651 } //end else LAr
652
653 else {
654 ATH_MSG_ERROR (" ####### (Cluster) ERROR ! No CaloCell region was found!");
655 continue;
656 }
657
658 // ##############################
659 // CELL INFO DUMP (CLUSTER)
660 // ##############################
661 const double clusterDphiRaw = clusPhi - phiCell;
662 double cluster_dphi = 0.;
663
664 if (clusterDphiRaw < -pi) {
665 cluster_dphi = twopi + clusterDphiRaw;
666 }
667 else if (clusterDphiRaw > pi) {
668 cluster_dphi = clusterDphiRaw - twopi;
669 }
670 else {
671 cluster_dphi = clusterDphiRaw;
672 }
673
674 m_c_clusterIndex_cellLvl->push_back(clusIndex);
676 m_c_cellGain->push_back(gainCell);
677 m_c_cellLayer->push_back(layerCell);
678 m_c_cellEnergy->push_back(eneCell);
679 m_c_cellTime->push_back(timeCell);
680 m_c_cellEta->push_back(etaCell);
681 m_c_cellPhi->push_back(phiCell);
682 m_c_cellDEta->push_back(detaCell);
683 m_c_cellDPhi->push_back(dphiCell);
684 m_c_cellToClusterDEta->push_back(clusEta - etaCell);
685 m_c_cellToClusterDPhi->push_back(cluster_dphi);
686 m_c_cellRegion->push_back(caloRegionIndex);
687
689 cellNum++;
690 } // end if-cell is empty verification
691 } // end loop at cells inside cluster
692
693 // ##############################
694 // CLUSTER INFO DUMP (CLUSTER)
695 // // ##############################
696 m_c_clusterIndex->push_back(clusIndex);
697 m_c_clusterEnergy->push_back(clusEt);
698 m_c_clusterTime->push_back(clusTime);
699 m_c_clusterEta->push_back(clusEta);
700 m_c_clusterPhi->push_back(clusPhi);
701 m_c_clusterPt->push_back(clusPt);
702
703 // ##############################
704 // DIGITS CHANNEL INFO DUMP (CLUSTER)
705 // ##############################
706 // Loop over ALL channels in LAr Digit Container.
707 // Dump only the channels inside the previous clusters
708
709 // ========= LAr ==========
710 if (larClusteredDigits.any()){
711 // -- LAr_Hits --
713 ATH_MSG_DEBUG (" (Cluster-HITS) Dumping LAr EMB Hits...");
714
715 m_ncell = m_calocell_id->calo_cell_hash_max();
716
718 if(!larHitCnt.isValid()) ATH_MSG_ERROR("LAr EMB Hit container is not valid!");
719
720 for (unsigned int k=0 ; k < channelHwidInClusterMap.size() ; k++){
721 double cell_total_ene = 0.0;
722 double cell_total_eneCalib = 0.0;
723 double cell_hit_tof = -999.0;
724 double hit_ene = 0.;
725 double hit_time = 0.;
726 float hit_fSampCalib = 1.;
727 int hit_sampling = 0;
728 size_t hit_index1 = 0;
729 bool thereIsOneHitToDump = false;
730 std::vector<double> hitEnergiesFromMap;
731 std::vector<double> hitTimesFromMap ;
732
733 for (const LArHit* hit : *larHitCnt){
734 Identifier hit_cellID = hit->cellID();
735 HWIdentifier hit_hwid = m_larCabling->createSignalChannelID(hit_cellID);
736 IdentifierHash hit_idHash = m_onlineLArID->channel_Hash(hit_hwid);
737 hit_index1 = (size_t) (hit_idHash);//(m_calocell_id->calo_cell_hash(hit_cellID));
738
739 if (larClusteredDigits.test(hit_index1)){
740 if (channelHwidInClusterMap[k]==hit_hwid){
741
742 hit_ene = hit->energy();
743 hit_time = hit->time();
744 hit_sampling = m_calocell_id->calo_sample(hit_cellID);
745
746 if (hit_index1 < m_ncell && fabs(hit_time) < 25.){ // time < 25 ns (current BC)
747 hitEnergiesFromMap.push_back(hit_ene);
748 hitTimesFromMap.push_back(hit_time);
749 hit_fSampCalib = m_fSampl->FSAMPL(hit_cellID);
750 thereIsOneHitToDump = true;
751
752 ATH_MSG_DEBUG ("(HITS) Match in "<< k <<"/"<< channelHwidInClusterMap.size() <<"! Sampling "<< hit_sampling << ", Cell (clus): "<< channelIndexMap[k] <<" ("<< clusIndex <<"), ID (mapHwid / hwid / hash ): "<< hit_cellID << " ("<< channelHwidInClusterMap[k] << " / "<< hit_hwid << " / "<< hit_index1 <<"), hitEne: "<< hit_ene <<", hitTime: "<< hit_time << ", m_fSampl: "<< hit_fSampCalib <<". eta="<< clusCellEtaMap[k]<< ", phi="<<clusCellPhiMap[k]<<".");
753
754 }// end-if caloHashMap matches
755 }// end-if cluster map has this hit_index
756 }// end-if current bc test
757 }// end-if current bc test
758
759 if (thereIsOneHitToDump){
760 for (auto hitE : hitEnergiesFromMap){
761 cell_total_ene += hitE;
762 cell_total_eneCalib += hitE / hit_fSampCalib; //calib energy from hits
763 }
764 cell_hit_tof = *std::min_element(hitTimesFromMap.begin(), hitTimesFromMap.end());
765
766 m_hits_energy->push_back(cell_total_ene);
767 m_hits_time->push_back(cell_hit_tof);
768 m_hits_sampling->push_back(hit_sampling);
769 m_hits_clusterIndex_chLvl->push_back(clusIndex);
770 m_hits_clusterChannelIndex->push_back(channelIndexMap[k]);
771 m_hits_hash->push_back(hit_index1);
772 m_hits_sampFrac->push_back(hit_fSampCalib);
773 m_hits_energyConv->push_back(cell_total_eneCalib);
774 m_hits_cellEta->push_back(clusCellEtaMap[k]);
775 m_hits_cellPhi->push_back(clusCellPhiMap[k]);
776 }
777 else{
778 ATH_MSG_DEBUG("(HITS) Hit from cell "<< k <<"/"<< channelHwidInClusterMap.size() <<" not found! Sampling "<< hit_sampling << ", Cell (clus): "<< channelIndexMap[k] <<" ("<< clusIndex <<"), mapHwid: "<< channelHwidInClusterMap[k]<<". eta="<< clusCellEtaMap[k]<< ", phi="<<clusCellPhiMap[k]<<".");
779 }
780 hitEnergiesFromMap.clear();
781 hitTimesFromMap.clear();
782
783 }// end for loop over caloHashMaps
784 }// end-if isMC and dumpHits
785
786
787 // -- LAr_Digits --
788 ATH_MSG_DEBUG (" (Cluster) Dumping LAr Digits...");
789
790 for (const LArDigit* dig : *LarDigCnt) {
791 HWIdentifier channelID = dig->channelID();
792 IdentifierHash idHash = m_onlineLArID->channel_Hash(channelID);
793 size_t index = (size_t) (idHash);
794
795 if (larClusteredDigits.test(index)) {
796 for (unsigned int k=0 ; k < channelHwidInClusterMap.size() ; k++){
797 if (channelHwidInClusterMap[k]==channelID){
798
799 // digits
800 std::vector<short> larDigitShort = dig->samples();
801 std::vector<float> larDigit( larDigitShort.begin(), larDigitShort.end() ); // get vector conversion from 'short int' to 'float'
802 m_c_channelDigits->push_back(larDigit);
803
804 const HWIdentifier digId = dig->hardwareID();
805 const int digGain = dig->gain();
806 auto ofc_a = m_ofcs->OFC_a(digId, digGain);
807 auto ofc_b = m_ofcs->OFC_b(digId, digGain);
808
809 std::vector<double> ofca, ofcb, shape, shapeDer;
810 const IdentifierHash& dig_cell_hashId = m_onlineLArID->channel_Hash(channelID);
811 for (size_t k=0; k < ofc_a.size(); k++) ofca.push_back((double) ofc_a[k]);
812 for (size_t k=0; k < ofc_b.size(); k++) ofcb.push_back((double) ofc_b[k]);
813
814 const auto& adc2mev = m_adc2MeVs->ADC2MEV(digId, digGain);
815 const float pedLAr = m_peds->pedestal(digId, digGain);
816 const auto& minBiasLAr = m_minBiasAvgs->minBiasAverage(digId);
817
818 // Remark: Looks like the EC does not have this rescale in DB (?)
819 if (!m_isMC){
820 auto sig_shape = m_shapes->Shape(digId, digGain);
821 auto sig_shapeDer = m_shapes->ShapeDer(digId, digGain);
822 for (size_t k=0; k < sig_shape.size(); k++) shape.push_back((double) sig_shape[k]);
823 for (size_t k=0; k < sig_shapeDer.size(); k++) shapeDer.push_back((double) sig_shapeDer[k]);
824
825 float offl_EneRescaler = 1.0; // if the channel is outside of hash_id limits from DB, set scale to 1.0 (energy remains unchanged).
826 const auto& offl_hv = m_oflHVCorr->HVScaleCorr(digId);
827 if (dig_cell_hashId < m_EneRescaler->getNChans()){ // if the channel is INSIDE the hash_id limit, get the data from DB.
828 offl_EneRescaler = m_EneRescaler->getData(dig_cell_hashId,0,0); // IMPORTANT REMARK: There was an update in Athena v23, compared to v22. There is a new <T> for getData() instance, which no longer needs the 2nd and 3rd accessor (adc, gain).
829 }
830 m_c_channelDSPThreshold->push_back(m_run2DSPThresh->tQThr(digId));
831 m_c_channelOfflEneRescaler->push_back(offl_EneRescaler);
832 m_c_channelOfflHVScale->push_back(offl_hv);
833 m_c_channelShape->push_back(std::move(shape));
834 m_c_channelShapeDer->push_back(std::move(shapeDer));
835 }
836 // Cell / readout data
837 m_c_channelEnergy->push_back(channelEnergyInClusterMap[k]);
838 m_c_channelTime->push_back(channelTimeInClusterMap[k]);
839 m_c_channelLayer->push_back(cellLayerMap[k]);
840 m_c_channelEffectiveSigma->push_back(channelEffectiveSigmaClusterMap[k]);
841 m_c_channelNoise->push_back(channelNoiseClusterMap[k]);
842 if (!m_noBadCells) m_c_channelBad->push_back(badChannelMap[k]);
843 // Calibration constants
844 m_c_channelOFCa->push_back(ofca);
845 m_c_channelOFCb->push_back(ofcb);
846 m_c_channelOFCTimeOffset->push_back(m_ofcs->timeOffset(digId,digGain));
847 m_c_channelADC2MEV0->push_back(adc2mev[0]);
848 m_c_channelADC2MEV1->push_back(adc2mev[1]);
849 m_c_channelPed->push_back(pedLAr);
850 m_c_channelMinBiasAvg->push_back(minBiasLAr);
851
852 // Channel info
853 int barrelEc = m_onlineLArID->barrel_ec(channelID);
854 int posNeg = m_onlineLArID->pos_neg(channelID);
855 int feedThr = m_onlineLArID->feedthrough(channelID); // feedthrough - cabling interface from cold and hot side. in barrel, there are 2 feedThr for each crate.
856 int slot = m_onlineLArID->slot(channelID);
857 int chn = m_onlineLArID->channel(channelID);
858 std::vector<int> chInfo {barrelEc, posNeg, feedThr, slot, chn } ; //unite info
859 m_c_channelChInfo->push_back(std::move(chInfo)); //add to the list of cell info (both calo)
860
861 // important indexes
862 m_c_clusterChannelIndex->push_back(channelIndexMap[k]);//each LAr cell is an individual read out.
863 m_c_clusterIndex_chLvl->push_back(clusIndex); // what roi this cell belongs at the actual event: 0, 1, 2 ...
864 m_c_channelHashMap->push_back(index); // online id hash for channel
865 m_c_channelChannelIdMap->push_back(channelID.get_identifier32().get_compact());
866
867
868 if (m_printCellsClus){
869
870 ATH_MSG_INFO ("(Cluster) In DumpLAr Digits: ReadOutIndex "<< channelIndexMap[k] << ". HwId " << channelID);
871 ATH_MSG_INFO ("(Cluster) In DumpLAr Digits: ReadOutIndex "<< channelIndexMap[k] << " HwId.get_compact() " << channelID.get_compact());
872 ATH_MSG_INFO ("(Cluster) In DumpLAr Digits: ReadOutIndex "<< channelIndexMap[k] << " HwId.get_identifier32().get_compact() " << channelID.get_identifier32().get_compact());
873
874 ATH_MSG_INFO("(Cluster) LAr OFC timeOffset: "<< m_ofcs->timeOffset(digId, digGain) <<", dig->hardwareID: " << digId << ", dig->channelID: "<< channelID);
875 ATH_MSG_INFO("\tOFCa ("<< ofca.size()<<"): ["<< ofca[0] <<", " << ofca[1] <<", " << ofca[2]<<", " << ofca[3] <<"]");
876 ATH_MSG_INFO("\tOFCb ("<< ofcb.size()<<"): ["<< ofcb[0] <<", " << ofcb[1] <<", " << ofcb[2]<<", " << ofcb[3] <<"]");
877
878 ATH_MSG_DEBUG ("(Cluster) In DumpLAr Digits: ReadOutIndex "<< channelIndexMap[k] << ". HwId (B_EC/P_N/FeedTr/slot/ch) " << channelID << " (" << barrelEc << "/" << posNeg << "/"<< feedThr << "/" << slot << "/" << chn << ". Dig (float): " << larDigit);
879
880 }
881 } //end-if caloHashMap matches
882 } //end for loop over caloHashMaps
883 } // end-if clustBits Test
884 } //end loop over LAr digits container
885 } //end-if larClustBits is not empty
886
887 // ##############################
888 // RAW CHANNEL INFO DUMP (CLUSTER)
889 // ##############################
890
891 // ========= LAr ==========
892 if (larClusteredDigits.any()) {
893 ATH_MSG_INFO ("(Cluster) Dumping LAr Raw Channel...");
894
895 for (const LArRawChannel& LArChannel : *LArRawCnt){
896
897 HWIdentifier channelID = LArChannel.channelID();
898 IdentifierHash chHwidHash = m_onlineLArID->channel_Hash(channelID);
899
900 size_t index = static_cast<size_t>(chHwidHash);
901
902 if (larClusteredDigits.test(index)){ //if this channel index is inside
903 for (unsigned int k=0 ; k < channelHwidInClusterMap.size() ; k++){ //loop over the vector of hashIndex, and verify if the cell index match.
904 if (channelHwidInClusterMap[k] == channelID){
905
906 //RawCh info
907 int rawEnergy = LArChannel.energy(); // energy in MeV (rounded to integer)
908 int rawTime = LArChannel.time(); // time in ps (rounded to integer)
909 uint16_t rawQuality = LArChannel.quality(); // quality from pulse reconstruction
910 int provenance = static_cast<int>(LArChannel.provenance()); // its uint16_t
911 float rawEnergyConv = static_cast<float>(rawEnergy);
912 float rawTimeConv = static_cast<float>(rawTime);
913 float rawQualityConv = static_cast<float>(rawQuality);
914
915 // Channel info
916 int barrelEc = m_onlineLArID->barrel_ec(channelID);
917 int posNeg = m_onlineLArID->pos_neg(channelID);
918 int feedThr = m_onlineLArID->feedthrough(channelID); // feedthrough - cabling interface from cold and hot side. in barrel, there are 2 feedThr for each crate.
919 int slot = m_onlineLArID->slot(channelID);
920 int chn = m_onlineLArID->channel(channelID);
921 std::vector<int> chInfo {barrelEc, posNeg, feedThr, slot, chn } ; //unite info
922 m_c_rawChannelChInfo->push_back(std::move(chInfo)); //add to the list of cell info (both calo)
923
924 if ( (rawEnergy != rawEnergyConv) || (rawTime != rawTimeConv) || (rawQuality != rawQualityConv) ){
925 ATH_MSG_ERROR (" ###### (Cluster) LAR RAW CHANNEL: Value conversion from int to float of amplitude, time or quality (uint16_t) had changed its actual value !!!");
926 }
927 m_c_rawChannelAmplitude->push_back(rawEnergyConv);
928 m_c_rawChannelTime->push_back(rawTimeConv);
929 m_c_rawChannelLayer->push_back(cellLayerMap[k]);
930 m_c_rawChannelQuality->push_back(rawQualityConv);
931 m_c_rawChannelProv->push_back(provenance);
932 m_c_rawChannelPed->push_back(-8888); // masked LAr
933 if (!m_isMC){
934 m_c_rawChannelDSPThreshold->push_back(m_run2DSPThresh->tQThr(channelID));
935 }
936
937 // important indexes
938 m_c_clusterRawChannelIndex->push_back(channelIndexMap[k]);
939 m_c_clusterIndex_rawChLvl->push_back(clusIndex); // what roi this ch belongs
940 m_c_rawChannelIdMap->push_back(channelID.get_identifier32().get_compact());
941
942 if (m_printCellsClus){ //optional to help debugging
943
944 HWIdentifier hardwareID = LArChannel.hardwareID();
945
946 if (!m_isMC){
947 ATH_MSG_INFO ("(Cluster) In DumpLAr Raw "<< channelIndexMap[k] <<": hardwareID (B_EC/P_N/feedThr/slot/chn): " << hardwareID << "(" << barrelEc << "/" << posNeg << "/" << feedThr << "/" << slot << "/" << chn << ")" << ". Energy: " << rawEnergyConv << ". Time: " << rawTimeConv << ". Provenance: " << provenance << ". Quality: " << rawQualityConv <<" ecut (DSPThr) = " << m_run2DSPThresh->tQThr(channelID));
948 }
949 else{
950 ATH_MSG_INFO ("(Cluster) In DumpLAr Raw "<< channelIndexMap[k] <<": hardwareID (B_EC/P_N/feedThr/slot/chn): " << hardwareID << "(" << barrelEc << "/" << posNeg << "/" << feedThr << "/" << slot << "/" << chn << ")" << ". Energy: " << rawEnergyConv << ". Time: " << rawTimeConv << ". Provenance: " << provenance << ". Quality: " << rawQualityConv);
951 }
952
953 } // end-if optional cell print
954 } // end-if hwid match rawChID
955 } // end loop over HWIDClusterMap
956 } // end-if clust.test
957 } //end loop LArRawChannelContainer
958 } // end-if clustBits have Cells
959
960 larClusteredDigits.reset();
961
962 caloHashMap.clear();
963
964 channelHwidInClusterMap.clear();
965 cellIndexMap.clear();
966 cellLayerMap.clear();
967 clusCellEtaMap.clear();
968 clusCellPhiMap.clear();
969 channelIndexMap.clear();
970 channelEnergyInClusterMap.clear();
971 channelTimeInClusterMap.clear();
972 channelEtaInClusterMap.clear();
973 channelPhiInClusterMap.clear();
974 channelEffectiveSigmaClusterMap.clear();
975 channelNoiseClusterMap.clear();
976 channelCaloRegionMap.clear();
977 if (!m_noBadCells) badChannelMap.clear();
978
979 ATH_MSG_INFO (" (Cluster) RawChannel: "<< m_c_rawChannelAmplitude->size() <<" channels dumped, from " << m_c_cellEta->size() <<" cluster cells. ");
980 ATH_MSG_INFO (" (Cluster) Digits: "<< m_c_channelDigits->size() <<" channels dumped, out of " << m_c_rawChannelAmplitude->size() <<" raw channel cluster channels. ");
981 if (m_c_channelDigits->size() == m_c_rawChannelAmplitude->size()){
982 ATH_MSG_INFO (" (Cluster) ALL Digits from the cluster were dumped successfully!");}
983 else{
984 ATH_MSG_INFO (" (Cluster) The digits from "<< (m_c_rawChannelAmplitude->size() - m_c_channelDigits->size()) <<" channels are missing!");}
985
986
987 return StatusCode::SUCCESS;
988}
989
990
992 ATH_MSG_DEBUG ("Finalizing " << name() << "...");
993 m_secondTree->Fill();
994
995 return StatusCode::SUCCESS;
996}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_INFO(x,...)
bool hit(const Container &ids, int pdgId)
static Double_t sc
#define pi
constexpr double twopi
ServiceHandle< StoreGateSvc > & evtStore()
const ServiceHandle< StoreGateSvc > & detStore() const
Data object for each calorimeter readout cell.
Definition CaloCell.h:57
static CaloCondBlobFlt * getInstance(coral::Blob &blob)
Returns a pointer to a non-const CaloCondBlobFlt.
const ILArMinBiasAverage * m_minBiasAvgs
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoSgKey
SG::ReadHandleKey< LArDigitContainer > m_larDigitCntSgKey
virtual StatusCode finalize() override
SG::ReadHandleKey< xAOD::VertexContainer > m_primVertSgKey
Gaudi::Property< bool > m_skipEmptyEvents
SG::ReadCondHandleKey< LArOnOffIdMapping > m_larCablingKey
const LArEM_ID * m_larem_id
Gaudi::Property< bool > m_getAssociatedTopoCluster
SG::ReadCondHandleKey< ILArMinBiasAverage > m_minBiasAvgKey
SG::ReadCondHandleKey< LArADC2MeV > m_adc2MeVKey
const LArADC2MeV * m_adc2MeVs
virtual StatusCode dumpOfflineSS(const xAOD::Electron *electron)
virtual StatusCode dumpTruthParticle(SG::ReadHandle< xAOD::ElectronContainer > &electronSelectionCnt, SG::ReadHandle< xAOD::TruthParticleContainer > &truthParticleCnt)
const CaloCondBlobFlt * m_EneRescaler
SG::ReadHandleKey< xAOD::ElectronContainer > m_myElecSelectionSgKey
SG::ReadCondHandleKey< LuminosityCondData > m_lumiDataKey
Gaudi::Property< bool > m_printCellsClus
Gaudi::Property< float > m_minZeeMassTP
virtual StatusCode FillNTupleWithSelectedElectrons(SG::ReadHandle< xAOD::EventInfo > &ei, SG::ReadHandle< xAOD::VertexContainer > &primVertexCnt, SG::ReadHandle< xAOD::ElectronContainer > &electronSelectionCnt, std::string &eSelectionText, const EventContext &ctx)
const ILArShape * m_shapes
const ILArOFC * m_ofcs
virtual StatusCode dumpLumiblockInfo(SG::ReadHandle< xAOD::EventInfo > &ei)
EventReaderAlg(const std::string &name, ISvcLocator *pSvcLocator)
const ILArPedestal * m_peds
virtual StatusCode dumpClusterCells(const xAOD::CaloCluster *cl, int clusIndex, const EventContext &ctx)
SG::ReadHandleKey< xAOD::TruthEventContainer > m_truthEventCntSgKey
const LArFCAL_ID * m_larfcal_id
const LArOnlineID * m_onlineLArID
const LArHEC_ID * m_larhec_id
const CaloIdManager * m_caloIdMgr
SG::ReadHandleKey< CaloCellContainer > m_allCaloCellCntSgKey
const ILArfSampl * m_fSampl
SG::ReadCondHandleKey< AthenaAttributeList > m_run2DSPThresholdsKey
virtual StatusCode initialize() override
SG::ReadHandleKey< LArRawChannelContainer > m_larRawChCntSgKey
const CaloNoise * m_noiseCDO
virtual StatusCode dumpEventInfo(SG::ReadHandle< xAOD::EventInfo > &ei)
virtual StatusCode dumpPrimVertexAssocToElectron(const xAOD::Electron *el, SG::ReadHandle< xAOD::VertexContainer > &primVertexCnt, SG::ReadHandle< xAOD::EventInfo > &evtInfo)
SG::ReadCondHandleKey< ILArfSampl > m_fSamplKey
virtual StatusCode dumpZeeCut(SG::ReadHandle< xAOD::EventInfo > &ei, SG::ReadHandle< xAOD::VertexContainer > &primVertexCnt, const EventContext &ctx)
SG::ReadHandleKey< LArHitContainer > m_larEMBHitCntSgKey
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_truthParticleCntSgKey
SG::ReadCondHandleKey< ILArShape > m_shapeKey
SG::ReadHandleKey< xAOD::ElectronContainer > m_electronCntSgKey
virtual StatusCode execute(const EventContext &ctx) override
Execute method.
SG::ReadCondHandleKey< ILArOFC > m_ofcKey
SG::ReadCondHandleKey< ILArPedestal > m_pedestalKey
Gaudi::Property< float > m_maxZeeMassTP
std::unique_ptr< LArDSPThresholdsFlat > m_run2DSPThresh
virtual StatusCode dumpElectrons(const xAOD::Electron *electron)
const LuminosityCondData * m_lumis
SG::ReadHandleKey< xAOD::CaloClusterContainer > m_caloClusSgKey
const LArOnOffIdMapping * m_larCabling
Gaudi::Property< bool > m_doClusterDump
SG::ReadCondHandleKey< CaloNoise > m_noiseCDOKey
const CaloCell_ID * m_calocell_id
const LArHVCorr * m_oflHVCorr
SG::ReadCondHandleKey< LArHVCorr > m_offlineHVScaleCorrKey
SG::ReadCondHandleKey< AthenaAttributeList > m_EneRescalerFldr
ServiceHandle< ITHistSvc > m_ntsvc
std::vector< float > * m_vtx_x
std::vector< std::vector< double > > * m_c_channelShape
std::vector< float > * m_el_deltae
std::vector< float > * m_c_channelPed
std::vector< int > * m_c_clusterIndex_rawChLvl
Gaudi::Property< float > m_d0TagSig
std::vector< double > * m_c_clusterEnergy
unsigned long long m_e_eventNumber
std::vector< float > * m_c_rawChannelQuality
std::vector< float > * m_el_fracs1
std::vector< int > * m_c_cellRegion
std::vector< unsigned int > * m_c_channelChannelIdMap
std::vector< double > * m_zee_py
std::vector< float > * m_el_wtots1
std::vector< double > * m_hits_cellPhi
std::vector< float > * m_el_Phi
std::vector< std::vector< double > > * m_c_channelShapeDer
Gaudi::Property< bool > m_doLArEMBHitsDump
std::vector< int > * m_c_clusterChannelIndex
Gaudi::Property< float > m_z0Tag
void bookDatabaseBranches(TTree *tree)
std::vector< double > * m_zee_px
std::vector< double > * m_zee_deltaR
std::vector< std::vector< float > > * m_lb_bcidLuminosity
std::vector< bool > * m_c_channelBad
std::vector< double > * m_hits_energyConv
std::vector< double > * m_c_cellTime
std::vector< float > * m_c_rawChannelProv
std::vector< float > * m_el_e277
std::vector< float > * m_el_rhad
std::vector< double > * m_vtx_d0sig
std::vector< int > * m_mc_vert_status
std::vector< std::vector< double > > * m_c_channelOFCb
std::vector< float > * m_mc_vert_phi
std::vector< std::vector< double > > * m_c_channelOFCa
std::vector< int > * m_mc_part_pdgId
std::vector< float > * m_c_rawChannelAmplitude
std::vector< float > * m_mc_vert_z
std::vector< double > * m_c_cellPhi
std::vector< float > * m_vtx_delta_z0_sin
std::vector< double > * m_c_cellEnergy
int getCaloRegionIndex(const CaloCell *cell)
std::vector< int > * m_c_clusterIndex_chLvl
std::vector< float > * m_mc_vert_y
std::vector< double > * m_zee_pt
std::vector< float > * m_hits_sampFrac
std::vector< int > * m_c_cellLayer
std::vector< double > * m_c_clusterPt
bool isGoodProbeElectron(const xAOD::Electron *el)
std::vector< float > * m_c_rawChannelPed
std::vector< float > * m_mc_part_pt
std::vector< int > * m_c_clusterIndex
std::vector< double > * m_c_cellToClusterDPhi
std::vector< float > * m_c_channelNoise
std::vector< int > * m_hits_clusterChannelIndex
std::vector< float > * m_el_f1
std::vector< float > * m_c_clusterRawChannelIndex
std::vector< float > * m_el_Pt
std::vector< int > * m_c_clusterCellIndex
bool isTagElectron(const xAOD::Electron *electron)
std::vector< float > * m_c_channelEffectiveSigma
std::vector< unsigned int > * m_c_channelHashMap
bool trackSelectionElectrons(const xAOD::Electron *electron, SG::ReadHandle< xAOD::VertexContainer > &primVertexCnt, SG::ReadHandle< xAOD::EventInfo > &ei)
std::vector< int > * m_c_rawChannelLayer
std::vector< std::vector< float > > * m_c_channelDigits
std::vector< double > * m_c_cellEta
std::vector< double > * m_c_cellDEta
std::vector< double > * m_hits_cellEta
Gaudi::Property< bool > m_doTruthPartDump
std::vector< float > * m_c_channelOfflEneRescaler
std::vector< double > * m_zee_M
std::vector< double > * m_zee_pz
std::vector< double > * m_c_cellDPhi
std::vector< float > * m_el_rhad1
std::vector< float > * m_el_weta1
EventReaderBaseAlg(const std::string &name, ISvcLocator *pSvcLocator)
std::vector< float > * m_el_et
std::vector< float > * m_vtx_z
std::vector< int > * m_lb_lumiblock
std::vector< int > * m_c_channelLayer
std::vector< double > * m_zee_T
std::vector< double > * m_c_clusterPhi
std::vector< int > * m_el_index
std::vector< std::vector< int > > * m_c_rawChannelChInfo
Gaudi::Property< bool > m_doTagAndProbe
Gaudi::Property< bool > m_isMC
std::vector< int > * m_mc_vert_uniqueID
std::vector< double > * m_hits_energy
std::vector< float > * m_c_channelADC2MEV1
std::vector< float > * m_mc_part_eta
std::vector< float > * m_mc_part_energy
std::vector< float > * m_el_Eta
std::vector< float > * m_c_channelOfflHVScale
std::vector< double > * m_c_channelTime
std::vector< int > * m_c_clusterIndex_cellLvl
std::vector< double > * m_c_clusterTime
void bookBranches(TTree *tree)
std::vector< float > * m_c_channelMinBiasAvg
std::vector< float > * m_mc_vert_time
std::vector< float > * m_c_channelDSPThreshold
std::vector< double > * m_c_clusterEta
std::vector< int > * m_c_cellGain
std::vector< float > * m_mc_part_phi
std::vector< float > * m_c_channelADC2MEV0
std::vector< int > * m_c_electronIndex_clusterLvl
std::vector< float > * m_mc_part_m
std::vector< double > * m_zee_E
std::vector< float > * m_mc_vert_x
Gaudi::Property< float > m_elecEtaCut
std::vector< float > * m_vtx_deltaZ0
std::vector< int > * m_hits_sampling
std::vector< std::vector< int > > * m_c_channelChInfo
std::vector< float > * m_c_rawChannelDSPThreshold
std::vector< float > * m_vtx_y
std::vector< double > * m_c_channelEnergy
std::vector< float > * m_el_rphi
Gaudi::Property< bool > m_doElecSelectByTrackOnly
std::vector< double > * m_c_channelOFCTimeOffset
std::vector< float > * m_el_eratio
std::vector< unsigned int > * m_hits_hash
std::vector< float > * m_c_rawChannelTime
Gaudi::Property< bool > m_noBadCells
std::vector< float > * m_mc_vert_eta
std::vector< float > * m_el_f3
std::vector< float > * m_el_reta
std::vector< int > * m_hits_clusterIndex_chLvl
std::vector< float > * m_mc_vert_perp
bool eOverPElectron(const xAOD::Electron *electron)
std::vector< float > * m_el_weta2
std::vector< float > * m_el_eoverp
std::vector< float > * m_el_m
std::vector< double > * m_c_cellToClusterDEta
std::vector< unsigned int > * m_c_rawChannelIdMap
std::vector< double > * m_hits_time
value_type get_compact() const
Get the compact id.
This is a "hash" representation of an Identifier.
value_type get_compact() const
Get the compact id.
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
Liquid Argon digit base class.
Definition LArDigit.h:25
Class to store hit energy and time in LAr cell from G4 simulation.
Definition LArHit.h:25
Liquid Argon ROD output object base class.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
@ LAr
The LAr calorimeter.
@ Error
The sub-detector issued an error.
float z0() const
Returns the parameter.
float theta() const
Returns the parameter, which has range 0 to .
float vz() const
The z origin for the parameters.
virtual double pt() const override final
The transverse momentum ( ) of the particle.
int uniqueID(const T &p)
int status(const T &p)
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition index.py:1
std::vector< const xAOD::CaloCluster * > getAssociatedTopoClusters(const xAOD::CaloCluster *cluster)
Return a vector of all the topo clusters associated with the egamma cluster.
@ wtots1
shower width is determined in a window detaxdphi = 0,0625 ×~0,2, corresponding typically to 20 strips...
@ e277
uncalibrated energy (sum of cells) of the middle sampling in a rectangle of size 7x7
Definition EgammaEnums.h:81
@ f3
fraction of energy reconstructed in 3rd sampling
Definition EgammaEnums.h:55
@ f1
E1/E = fraction of energy reconstructed in the first sampling, where E1 is energy in all strips belon...
Definition EgammaEnums.h:53
@ Eratio
(emaxs1-e2tsts1)/(emaxs1+e2tsts1)
@ DeltaE
e2tsts1-emins1
@ fracs1
shower shape in the shower core : [E(+/-3)-E(+/-1)]/E(+/-1), where E(+/-n) is the energy in ± n strip...
@ weta2
the lateral width is calculated with a window of 3x5 cells using the energy weighted sum over all cel...
@ weta1
shower width using +/-3 strips around the one with the maximal energy deposit: w3 strips = sqrt{sum(E...
Definition EgammaEnums.h:98
double d0significance(const xAOD::TrackParticle *tp, double d0_uncert_beam_spot_2)
const xAOD::TruthParticle * getTruthParticle(const xAOD::IParticle &p)
Return the truthParticle associated to the given IParticle (if any).
@ PriVtx
Primary vertex.
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
TruthVertex_v1 TruthVertex
Typedef to implementation.
Definition TruthVertex.h:15
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Vertex_v1 Vertex
Define the latest version of the vertex class.
TruthParticle_v1 TruthParticle
Typedef to implementation.
Electron_v1 Electron
Definition of the current "egamma version".
Definition Electron.h:17