ATLAS Offline Software
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 
13 #include "CaloIdentifier/TileID.h"
16 #include "TileEvent/TileCell.h"
17 #include "GaudiKernel/ISvcLocator.h"
18 #include "GaudiKernel/StatusCode.h"
19 #include "GaudiKernel/MsgStream.h"
20 #include "StoreGate/StoreGateSvc.h"
22 
23 
24 namespace D3PD{
25 
26 
28  const std::string& name,
29  const IInterface* parent):
31  m_tileid (0),
32  m_tilehwid(0),
33  m_cabling(0),
34  m_tileBadChanTool("TileBadChanTool"),
35  m_run2plus(false),
36  m_notRealE1run2{{}}
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  {
53  CHECK( m_tileBadChanTool.retrieve() );
56 
57  if (m_run2plus) {
58  for (int ros = 3; ros < 5; ++ros) {
59  for (int drawer = 0; drawer < 64; ++drawer) {
61  m_notRealE1run2[ros - 3][drawer2] = (drawer2 != 0);
62  }
63  }
64  }
65 
66  return StatusCode::SUCCESS;
67  }
68 
69 
71  if (m_savePosition) {
75  CHECK(addVariable("PMT1",m_pmt1Cells));
76  CHECK(addVariable("PMT2",m_pmt2Cells));
77  }
78 
79  if (m_saveCellDetails){
80  CHECK(addVariable("Time",m_timeCells));
81  CHECK(addVariable("Timediff",m_tdiffCells));
82  CHECK(addVariable("Ediff",m_ediffCells));
83  CHECK(addVariable("Gain1",m_gain1Cells));
84  CHECK(addVariable("Gain2",m_gain2Cells));
85  CHECK(addVariable("Module",m_moduleCells));
86  CHECK(addVariable("Partition",m_partitionCells));
87  CHECK(addVariable("Tower",m_towerCells));
88  CHECK(addVariable("Sample",m_sampleCells));
89  CHECK(addVariable("Chan1",m_chan1Cells));
90  CHECK(addVariable("Chan2",m_chan2Cells));
91  CHECK(addVariable("Status1",m_status1Cells));
92  CHECK(addVariable("Status2",m_status2Cells));
93  CHECK(addVariable("Qual1",m_qual1Cells));
94  CHECK(addVariable("Qual2",m_qual2Cells));
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);
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 !!!
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;
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 
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
D3PD::TileCellDetailsFillerTool::E1_CHANNEL
@ E1_CHANNEL
Definition: TileCellDetailsFillerTool.h:121
TileCell
Definition: TileCell.h:57
D3PD::TileCellDetailsFillerTool::m_status1Cells
uint16_t * m_status1Cells
Definition: TileCellDetailsFillerTool.h:113
TileCellDetailsFillerTool.h
CaloDetDescrElement::onl2
IdentifierHash onl2() const
cell online identifier 2
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:408
D3PD::TileCellDetailsFillerTool::m_chan1Cells
short * m_chan1Cells
Definition: TileCellDetailsFillerTool.h:109
D3PD::TileCellDetailsFillerTool::m_pmt1Cells
short * m_pmt1Cells
Definition: TileCellDetailsFillerTool.h:111
ReadCellNoiseFromCool.cell
cell
Definition: ReadCellNoiseFromCool.py:53
TileCablingService::getInstance
static const TileCablingService * getInstance()
get pointer to service instance
Definition: TileCablingService.cxx:24
CaloCell::y
float y() const
get y (through CaloDetDescrElement)
Definition: CaloCell.h:420
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
D3PD::TileCellDetailsFillerTool::m_tileBadChanTool
ToolHandle< ITileBadChanTool > m_tileBadChanTool
Definition: TileCellDetailsFillerTool.h:63
D3PD::TileCellDetailsFillerTool::m_chan2Cells
short * m_chan2Cells
Definition: TileCellDetailsFillerTool.h:110
CaloDetDescrElement
This class groups all DetDescr information related to a CaloCell. Provides a generic interface for al...
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:66
TileCell::badch1
bool badch1(void) const
check if first PMT is in bad channel list and masked
Definition: TileCell.h:215
CaloTime_fillDB.gain2
gain2
Definition: CaloTime_fillDB.py:357
Tile_Base_ID::sample
int sample(const Identifier &id) const
Definition: Tile_Base_ID.cxx:171
D3PD::TileCellDetailsFillerTool::m_savePosition
bool m_savePosition
Definition: TileCellDetailsFillerTool.h:66
D3PD::TileCellDetailsFillerTool::m_sampleCells
uint16_t * m_sampleCells
Definition: TileCellDetailsFillerTool.h:106
D3PD::AddVariable::addVariable
virtual StatusCode addVariable(const std::string &name, const std::type_info &ti, void *&ptr, const std::string &docstring="", const void *defval=0)
Add a variable to the tuple.
Definition: AddVariable.cxx:85
D3PD::TileCellDetailsFillerTool::m_tileid
const TileID * m_tileid
Definition: TileCellDetailsFillerTool.h:59
Tile_Base_ID::tower
int tower(const Identifier &id) const
Definition: Tile_Base_ID.cxx:165
CaloCell::time
float time() const
get time (data member)
Definition: CaloCell.h:352
HWIdentifier
Definition: HWIdentifier.h:13
D3PD::TileCellDetailsFillerTool::m_qual2Cells
uint16_t * m_qual2Cells
Definition: TileCellDetailsFillerTool.h:116
TileCell::MASK_BADCH
@ MASK_BADCH
Definition: TileCell.h:63
Example_ReadSampleNoise.drawer
drawer
Definition: Example_ReadSampleNoise.py:39
TileHWID::channel
int channel(const HWIdentifier &id) const
extract channel field from HW identifier
Definition: TileHWID.h:189
TileID.h
D3PD::TileCellDetailsFillerTool::m_saveCellDetails
bool m_saveCellDetails
Definition: TileCellDetailsFillerTool.h:65
D3PD::TileCellDetailsFillerTool::m_pmt2Cells
short * m_pmt2Cells
Definition: TileCellDetailsFillerTool.h:112
TileHWID::ros
int ros(const HWIdentifier &id) const
extract ros field from HW identifier
Definition: TileHWID.h:167
D3PD::TileCellDetailsFillerTool::m_notRealE1run2
bool m_notRealE1run2[2][64]
Definition: TileCellDetailsFillerTool.h:120
CaloDetDescrElement::onl1
IdentifierHash onl1() const
cell online identifier 1
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:404
D3PD::TileCellDetailsFillerTool::m_qbits1
uint8_t * m_qbits1
Definition: TileCellDetailsFillerTool.h:117
D3PD::TileCellDetailsFillerTool::m_yCells
float * m_yCells
Definition: TileCellDetailsFillerTool.h:99
D3PD::TileCellDetailsFillerTool::TileCellDetailsFillerTool
TileCellDetailsFillerTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: TileCellDetailsFillerTool.cxx:27
python.PyAthena.module
module
Definition: PyAthena.py:131
TileCell::timeDiff
float timeDiff(void) const
get time diff for two PMTs (data member)
Definition: TileCell.h:190
TileCell::qual2
uint8_t qual2(void) const
get quality of second PMT (data member)
Definition: TileCell.h:206
D3PD::TileCellDetailsFillerTool::DumpCellInfo
void DumpCellInfo()
Definition: TileCellDetailsFillerTool.cxx:189
TileCablingService::isRun2PlusCabling
bool isRun2PlusCabling() const
Definition: TileCablingService.h:278
D3PD
Block filler tool for noisy FEB information.
Definition: CaloCellDetailsFillerTool.cxx:29
D3PD::TileCellDetailsFillerTool::m_timeCells
float * m_timeCells
Definition: TileCellDetailsFillerTool.h:97
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
D3PD::TileCellDetailsFillerTool::initialize
virtual StatusCode initialize()
Standard Gaudi initialize method.
Definition: TileCellDetailsFillerTool.cxx:49
D3PD::TileCellDetailsFillerTool::fill
virtual StatusCode fill(const CaloCell &p)
Fill one block — type-safe version.
Definition: TileCellDetailsFillerTool.cxx:103
TileHWID.h
Tile_Base_ID::module
int module(const Identifier &id) const
Definition: Tile_Base_ID.cxx:159
TileCablingService.h
StdJOSetup.msgSvc
msgSvc
Provide convenience handles for various services.
Definition: StdJOSetup.py:36
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
CaloCell::caloDDE
const CaloDetDescrElement * caloDDE() const
get pointer to CaloDetDescrElement (data member)
Definition: CaloCell.h:305
TileCell::badch2
bool badch2(void) const
check if second PMT is in bad channel list and masked
Definition: TileCell.h:218
D3PD::TileCellDetailsFillerTool::m_towerCells
uint16_t * m_towerCells
Definition: TileCellDetailsFillerTool.h:105
TileCell.h
test_pyathena.parent
parent
Definition: test_pyathena.py:15
D3PD::BlockFillerTool
Type-safe wrapper for block filler tools.
Definition: BlockFillerTool.h:65
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
python.LArCondContChannels.chan1
chan1
Definition: LArCondContChannels.py:666
TileCell::qbit1
uint8_t qbit1(void) const
get quality bits of first PMT (data member)
Definition: TileCell.h:209
maskDeadModules.ros
ros
Definition: maskDeadModules.py:35
TileCell::gain1
int gain1(void) const
get gain of first PMT
Definition: TileCell.cxx:182
TileCell::eneDiff
float eneDiff(void) const
all get methods
Definition: TileCell.h:188
D3PD::TileCellDetailsFillerTool::m_tdiffCells
float * m_tdiffCells
Definition: TileCellDetailsFillerTool.h:101
D3PD::TileCellDetailsFillerTool::m_status2Cells
uint16_t * m_status2Cells
Definition: TileCellDetailsFillerTool.h:114
TileHWID::NOT_VALID_HASH
@ NOT_VALID_HASH
Definition: TileHWID.h:314
D3PD::TileCellDetailsFillerTool::m_cabling
const TileCablingService * m_cabling
Definition: TileCellDetailsFillerTool.h:61
CaloTime_fillDB.gain1
gain1
Definition: CaloTime_fillDB.py:356
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
D3PD::TileCellDetailsFillerTool::m_qual1Cells
uint16_t * m_qual1Cells
Definition: TileCellDetailsFillerTool.h:115
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
D3PD::TileCellDetailsFillerTool::m_tilehwid
const TileHWID * m_tilehwid
Definition: TileCellDetailsFillerTool.h:60
errorcheck.h
Helpers for checking error return status codes and reporting errors.
CaloCell::ID
Identifier ID() const
get ID (from cached data member) non-virtual and inline for fast access
Definition: CaloCell.h:279
D3PD::TileCellDetailsFillerTool::m_zCells
float * m_zCells
Definition: TileCellDetailsFillerTool.h:100
D3PD::TileCellDetailsFillerTool::book
virtual StatusCode book()
Declare tuple variables.
Definition: TileCellDetailsFillerTool.cxx:70
D3PD::TileCellDetailsFillerTool::m_gain1Cells
short * m_gain1Cells
Definition: TileCellDetailsFillerTool.h:107
TileHWID::adc_id
HWIdentifier adc_id(int ros, int drawer, int channel, int adc) const
adc HWIdentifer
Definition: TileHWID.cxx:229
TileCell::qbit2
uint8_t qbit2(void) const
get quality bits of second PMT (data member)
Definition: TileCell.h:212
D3PD::TileCellDetailsFillerTool::m_partitionCells
uint16_t * m_partitionCells
Definition: TileCellDetailsFillerTool.h:104
TileCell::gain2
int gain2(void) const
get gain of second PMT
Definition: TileCell.cxx:189
CaloCell
Data object for each calorimeter readout cell.
Definition: CaloCell.h:57
Tile_Base_ID::to_string
std::string to_string(const Identifier &id, int level=0) const
Definition: Tile_Base_ID.cxx:52
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
TileCablingService::channel2hole
static int channel2hole(int ros, int channel)
Definition: TileCablingService.cxx:1946
DEBUG
#define DEBUG
Definition: page_access.h:11
CaloCell::z
float z() const
get z (through CaloDetDescrElement)
Definition: CaloCell.h:427
StateLessPT_NewConfig.partition
partition
Definition: StateLessPT_NewConfig.py:49
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
CaloCell::x
float x() const
get x (through CaloDetDescrElement)
Definition: CaloCell.h:413
TileCell::qual1
uint8_t qual1(void) const
get quality of first PMT (data member)
Definition: TileCell.h:203
D3PD::TileCellDetailsFillerTool::m_qbits2
uint8_t * m_qbits2
Definition: TileCellDetailsFillerTool.h:118
D3PD::TileCellDetailsFillerTool::m_moduleCells
uint16_t * m_moduleCells
Definition: TileCellDetailsFillerTool.h:103
python.Constants.VERBOSE
int VERBOSE
Definition: Control/AthenaCommon/python/Constants.py:14
D3PD::TileCellDetailsFillerTool::m_run2plus
bool m_run2plus
Definition: TileCellDetailsFillerTool.h:68
TileHWID::to_string
std::string to_string(const HWIdentifier &id, int level=0) const
extract all fields from HW identifier HWIdentifier get_all_fields ( const HWIdentifier & id,...
Definition: TileHWID.cxx:50
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
D3PD::TileCellDetailsFillerTool::m_ediffCells
float * m_ediffCells
Definition: TileCellDetailsFillerTool.h:102
StoreGateSvc.h
TileCablingService::E1_merged_with_run2plus
int E1_merged_with_run2plus(int ros, int module) const
Definition: TileCablingService.cxx:2457
D3PD::TileCellDetailsFillerTool::m_gain2Cells
short * m_gain2Cells
Definition: TileCellDetailsFillerTool.h:108
D3PD::TileCellDetailsFillerTool::m_xCells
float * m_xCells
Definition: TileCellDetailsFillerTool.h:98
Identifier
Definition: IdentifierFieldParser.cxx:14