ATLAS Offline Software
Loading...
Searching...
No Matches
TileCellDetailsFillerTool.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/*
6 * File: TileCellDetailsFillerTool.cxx
7 * Author: Stephen Cole <scole@niu.edu>
8 *
9 * Created on January 28, 2011, 3:12 PM
10 */
11
16#include "TileEvent/TileCell.h"
17#include "GaudiKernel/ISvcLocator.h"
18#include "GaudiKernel/StatusCode.h"
19#include "GaudiKernel/MsgStream.h"
22
23
24namespace D3PD{
25
26
28 const std::string& name,
29 const IInterface* parent):
30 BlockFillerTool<CaloCell>(type,name,parent),
31 m_tileid (0),
32 m_tilehwid(0),
33 m_cabling(0),
34 m_tileBadChanTool("TileBadChanTool"),
35 m_run2plus(false),
37 {
38 declareProperty("SaveCellDetails", m_saveCellDetails = true);
39 declareProperty("SavePositionInfo", m_savePosition = true );
40 declareProperty("TileBadChanTool", m_tileBadChanTool);
41
42 TileCellDetailsFillerTool::book().ignore(); // Avoid coverity warnings
43 }
44
45
50 {
51 CHECK( detStore()->retrieve(m_tileid) );
52 CHECK( detStore()->retrieve(m_tilehwid) );
53 CHECK( m_tileBadChanTool.retrieve() );
55 m_run2plus = m_cabling->isRun2PlusCabling();
56
57 if (m_run2plus) {
58 for (int ros = 3; ros < 5; ++ros) {
59 for (int drawer = 0; drawer < 64; ++drawer) {
60 int drawer2 = m_cabling->E1_merged_with_run2plus(ros, drawer);
61 m_notRealE1run2[ros - 3][drawer2] = (drawer2 != 0);
62 }
63 }
64 }
65
66 return StatusCode::SUCCESS;
67 }
68
69
71 if (m_savePosition) {
77 }
78
81 CHECK(addVariable("Timediff",m_tdiffCells));
95 CHECK(addVariable("QBits1",m_qbits1));
96 CHECK(addVariable("QBits2",m_qbits2));
97 }
98
99
100 return StatusCode::SUCCESS;
101 }
102
104 MsgStream log( msgSvc(), name() );
105 log << MSG::DEBUG << " in TileCellDetailsFillerTool::fill()" << endmsg;
106 const CaloCell* cell=&p;
107 const TileCell* tilecell = dynamic_cast<const TileCell*> (cell);
108 if(tilecell){
109 Identifier id = tilecell->ID();
110 if ( log.level() < MSG::DEBUG ) log << MSG::VERBOSE << " cell_id " << m_tileid->to_string(id,-2) << endmsg;
111 int partition(0);
112 uint32_t bad1(0),bad2(0);
113 long chan1(-1),chan2(-1),pmt1(-1),pmt2(-1);
114 long gain1 = tilecell->gain1();
115 long gain2 = tilecell->gain2();
116 long qual1 = tilecell->qual1();
117 long qual2 = tilecell->qual2();
118 int module = m_tileid->module(id);
119
120 const CaloDetDescrElement * caloDDE = tilecell->caloDDE();
121 IdentifierHash hash1 = (gain1<0) ? TileHWID::NOT_VALID_HASH : caloDDE->onl1();
122 IdentifierHash hash2 = (gain2<0) ? TileHWID::NOT_VALID_HASH : caloDDE->onl2();
123 if (m_savePosition) {
124 *m_xCells=tilecell->x();
125 *m_yCells=tilecell->y();
126 *m_zCells=tilecell->z();
127 *m_pmt1Cells=pmt1;
128 *m_pmt2Cells=pmt2;
129 }
130 if (m_saveCellDetails) {
131 if (hash1 != TileHWID::NOT_VALID_HASH) {
132 HWIdentifier adc_id = m_tilehwid->adc_id(hash1,gain1);
133 if ( log.level() < MSG::DEBUG ) log << MSG::VERBOSE << " adc_id1 " << m_tilehwid->to_string(adc_id) << " hash " << hash1 << " " << gain1 << endmsg;
134 partition = m_tilehwid->ros(adc_id);
135 chan1 = m_tilehwid->channel(adc_id);
136 if (m_run2plus && partition > 2 && chan1 == E1_CHANNEL && m_notRealE1run2[partition - 3][module]) chan1 = -E1_CHANNEL;
137 pmt1 = m_cabling->channel2hole(partition,chan1);
138 bad1 = m_tileBadChanTool->encodeStatus(m_tileBadChanTool->getAdcStatus(adc_id));
139 }
140 if (hash2 != TileHWID::NOT_VALID_HASH) {
141 HWIdentifier adc_id = m_tilehwid->adc_id(hash2,gain2);
142 if ( log.level() < MSG::DEBUG ) log << MSG::VERBOSE << " adc_id2 " << m_tilehwid->to_string(adc_id) << " hash " << hash2 << " " << gain2 << endmsg;
143 if (hash1 == TileHWID::NOT_VALID_HASH) partition = m_tilehwid->ros(adc_id);
144 chan2 = m_tilehwid->channel(adc_id);
145 pmt2 = m_cabling->channel2hole(partition,chan2);
146 bad2 = m_tileBadChanTool->encodeStatus(m_tileBadChanTool->getAdcStatus(adc_id));
147 }
148
149
150
151 *m_moduleCells=module+1; // Note the +1 !!!
152 *m_partitionCells=partition;
153 *m_towerCells=m_tileid->tower(id);
154 *m_sampleCells=m_tileid->sample(id);
155 *m_qbits1=tilecell->qbit1();
156 *m_qbits2=tilecell->qbit2();
157 if(gain1>=0 && ((*m_qbits1) & TileCell::MASK_BADCH)!=0 &&
158 qual1!=qual2 && (qual1!=255 || qual2!=255))
159 gain1= !gain1;
160 if(gain2>=0 && ((*m_qbits2) & TileCell::MASK_BADCH)!=0 &&
161 qual1!=qual2 && (qual1!=255 || qual2!=255))
162 gain2= !gain2;
163 *m_gain1Cells=gain1;
164 *m_gain2Cells=gain2;
165 *m_chan1Cells=chan1;
166 *m_chan2Cells=chan2;
167 if(tilecell->badch1())
168 *m_status1Cells=bad1+10;
169 else *m_status1Cells=bad1;
170 if(tilecell->badch2())
171 *m_status2Cells=bad2+10;
172 else *m_status2Cells=bad2;
173 *m_qual1Cells=qual1;
174 *m_qual2Cells=qual2;
175 *m_timeCells=tilecell->time();
176 *m_ediffCells=tilecell->eneDiff();
177 *m_tdiffCells=tilecell->timeDiff();
178 }
179 if ( log.level() < MSG::DEBUG )DumpCellInfo(); // Dump cell info only if in VERBOSE mode
180 }
181 else log << MSG::WARNING << " Cell of id "<< cell->ID()
182 <<" : TileHelper is_tile, but TileCell pointer is 0 "
183 << endmsg;
184
185
186 return StatusCode::SUCCESS;
187 }
188
190 MsgStream log( msgSvc(), name() );
191 log << MSG::INFO << "Dumping Cell info:" << endmsg;
192 if (m_savePosition) {
193 log << MSG::INFO << " X :" <<*m_xCells << endmsg;
194 log << MSG::INFO << " Y :" <<*m_yCells << endmsg;
195 log << MSG::INFO << " Z :" <<*m_zCells << endmsg;
196 log << MSG::INFO << " PMT1 :" <<*m_pmt1Cells << endmsg;
197 log << MSG::INFO << " PMT2 :" <<*m_pmt2Cells << endmsg;
198 }
199 if (m_saveCellDetails) {
200 log << MSG::INFO << " Time :" <<*m_timeCells << endmsg;
201 log << MSG::INFO << " Ediff :" <<*m_ediffCells << endmsg;
202 log << MSG::INFO << " Tdiff :" <<*m_tdiffCells << endmsg;
203 log << MSG::INFO << " Module :" <<*m_moduleCells << endmsg;
204 log << MSG::INFO << " Partition :" <<*m_partitionCells << endmsg;
205 log << MSG::INFO << " Tower :" <<*m_towerCells << endmsg;
206 log << MSG::INFO << " Sample :" <<*m_sampleCells << endmsg;
207 log << MSG::INFO << " Gain1 :" <<*m_gain1Cells << endmsg;
208 log << MSG::INFO << " Gain2 :" <<*m_gain2Cells << endmsg;
209 log << MSG::INFO << " Chan1 :" <<*m_chan1Cells << endmsg;
210 log << MSG::INFO << " Chan2 :" <<*m_chan2Cells << endmsg;
211 log << MSG::INFO << " Status1 :" <<*m_status1Cells << endmsg;
212 log << MSG::INFO << " Status2 :" <<*m_status2Cells << endmsg;
213 log << MSG::INFO << " QF1 :" <<*m_qual1Cells << endmsg;
214 log << MSG::INFO << " QF2 :" <<*m_qual2Cells << endmsg;
215 }
216 }
217
218}
219
#define endmsg
Helpers for checking error return status codes and reporting errors.
#define CHECK(...)
Evaluate an expression and check for errors.
Data object for each calorimeter readout cell.
Definition CaloCell.h:57
float time() const
get time (data member)
Definition CaloCell.h:368
const CaloDetDescrElement * caloDDE() const
get pointer to CaloDetDescrElement (data member)
Definition CaloCell.h:321
float y() const
get y (through CaloDetDescrElement)
Definition CaloCell.h:436
float z() const
get z (through CaloDetDescrElement)
Definition CaloCell.h:443
float x() const
get x (through CaloDetDescrElement)
Definition CaloCell.h:429
Identifier ID() const
get ID (from cached data member) non-virtual and inline for fast access
Definition CaloCell.h:295
This class groups all DetDescr information related to a CaloCell.
IdentifierHash onl2() const
cell online identifier 2
IdentifierHash onl1() const
cell online identifier 1
virtual StatusCode addVariable(const std::string &name, const std::type_info &ti, void *&ptr, const std::string &docstring="", const void *defval=0)
Type-safe wrapper for block filler tools.
ToolHandle< ITileBadChanTool > m_tileBadChanTool
virtual StatusCode book()
Declare tuple variables.
virtual StatusCode fill(const CaloCell &p)
Fill one block — type-safe version.
virtual StatusCode initialize()
Standard Gaudi initialize method.
TileCellDetailsFillerTool(const std::string &type, const std::string &name, const IInterface *parent)
This is a "hash" representation of an Identifier.
static const TileCablingService * getInstance()
get pointer to service instance
uint8_t qual1(void) const
get quality of first PMT (data member)
Definition TileCell.h:197
float eneDiff(void) const
all get methods
Definition TileCell.h:182
int gain2(void) const
get gain of second PMT
Definition TileCell.cxx:175
bool badch1(void) const
check if first PMT is in bad channel list and masked
Definition TileCell.h:209
uint8_t qbit2(void) const
get quality bits of second PMT (data member)
Definition TileCell.h:206
int gain1(void) const
get gain of first PMT
Definition TileCell.cxx:168
uint8_t qual2(void) const
get quality of second PMT (data member)
Definition TileCell.h:200
bool badch2(void) const
check if second PMT is in bad channel list and masked
Definition TileCell.h:212
float timeDiff(void) const
get time diff for two PMTs (data member)
Definition TileCell.h:184
@ MASK_BADCH
Definition TileCell.h:63
uint8_t qbit1(void) const
get quality bits of first PMT (data member)
Definition TileCell.h:203
@ NOT_VALID_HASH
Definition TileHWID.h:314
Block filler tool for noisy FEB information.