ATLAS Offline Software
TileCellDetailsFillerTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 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  {
52  CHECK( service("DetectorStore",detStore) );
53  CHECK( detStore->retrieve(m_tileid) );
54  CHECK( detStore->retrieve(m_tilehwid) );
55  CHECK( m_tileBadChanTool.retrieve() );
58 
59  if (m_run2plus) {
60  for (int ros = 3; ros < 5; ++ros) {
61  for (int drawer = 0; drawer < 64; ++drawer) {
63  m_notRealE1run2[ros - 3][drawer2] = (drawer2 != 0);
64  }
65  }
66  }
67 
68  return StatusCode::SUCCESS;
69  }
70 
71 
73  if (m_savePosition) {
77  CHECK(addVariable("PMT1",m_pmt1Cells));
78  CHECK(addVariable("PMT2",m_pmt2Cells));
79  }
80 
81  if (m_saveCellDetails){
82  CHECK(addVariable("Time",m_timeCells));
83  CHECK(addVariable("Timediff",m_tdiffCells));
84  CHECK(addVariable("Ediff",m_ediffCells));
85  CHECK(addVariable("Gain1",m_gain1Cells));
86  CHECK(addVariable("Gain2",m_gain2Cells));
87  CHECK(addVariable("Module",m_moduleCells));
88  CHECK(addVariable("Partition",m_partitionCells));
89  CHECK(addVariable("Tower",m_towerCells));
90  CHECK(addVariable("Sample",m_sampleCells));
91  CHECK(addVariable("Chan1",m_chan1Cells));
92  CHECK(addVariable("Chan2",m_chan2Cells));
93  CHECK(addVariable("Status1",m_status1Cells));
94  CHECK(addVariable("Status2",m_status2Cells));
95  CHECK(addVariable("Qual1",m_qual1Cells));
96  CHECK(addVariable("Qual2",m_qual2Cells));
97  CHECK(addVariable("QBits1",m_qbits1));
98  CHECK(addVariable("QBits2",m_qbits2));
99  }
100 
101 
102  return StatusCode::SUCCESS;
103  }
104 
106  MsgStream log( msgSvc(), name() );
107  log << MSG::DEBUG << " in TileCellDetailsFillerTool::fill()" << endmsg;
108  const CaloCell* cell=&p;
109  const TileCell* tilecell = dynamic_cast<const TileCell*> (cell);
110  if(tilecell){
111  Identifier id = tilecell->ID();
112  if ( log.level() < MSG::DEBUG ) log << MSG::VERBOSE << " cell_id " << m_tileid->to_string(id,-2) << endmsg;
113  int partition(0);
114  uint32_t bad1(0),bad2(0);
115  long chan1(-1),chan2(-1),pmt1(-1),pmt2(-1);
116  long gain1 = tilecell->gain1();
117  long gain2 = tilecell->gain2();
118  long qual1 = tilecell->qual1();
119  long qual2 = tilecell->qual2();
120  int module = m_tileid->module(id);
121 
122  const CaloDetDescrElement * caloDDE = tilecell->caloDDE();
123  IdentifierHash hash1 = (gain1<0) ? TileHWID::NOT_VALID_HASH : caloDDE->onl1();
124  IdentifierHash hash2 = (gain2<0) ? TileHWID::NOT_VALID_HASH : caloDDE->onl2();
125  if (m_savePosition) {
126  *m_xCells=tilecell->x();
127  *m_yCells=tilecell->y();
128  *m_zCells=tilecell->z();
129  *m_pmt1Cells=pmt1;
130  *m_pmt2Cells=pmt2;
131  }
132  if (m_saveCellDetails) {
133  if (hash1 != TileHWID::NOT_VALID_HASH) {
134  HWIdentifier adc_id = m_tilehwid->adc_id(hash1,gain1);
135  if ( log.level() < MSG::DEBUG ) log << MSG::VERBOSE << " adc_id1 " << m_tilehwid->to_string(adc_id) << " hash " << hash1 << " " << gain1 << endmsg;
136  partition = m_tilehwid->ros(adc_id);
137  chan1 = m_tilehwid->channel(adc_id);
140  bad1 = m_tileBadChanTool->encodeStatus(m_tileBadChanTool->getAdcStatus(adc_id));
141  }
142  if (hash2 != TileHWID::NOT_VALID_HASH) {
143  HWIdentifier adc_id = m_tilehwid->adc_id(hash2,gain2);
144  if ( log.level() < MSG::DEBUG ) log << MSG::VERBOSE << " adc_id2 " << m_tilehwid->to_string(adc_id) << " hash " << hash2 << " " << gain2 << endmsg;
145  if (hash1 == TileHWID::NOT_VALID_HASH) partition = m_tilehwid->ros(adc_id);
146  chan2 = m_tilehwid->channel(adc_id);
147  pmt2 = m_cabling->channel2hole(partition,chan2);
148  bad2 = m_tileBadChanTool->encodeStatus(m_tileBadChanTool->getAdcStatus(adc_id));
149  }
150 
151 
152 
153  *m_moduleCells=module+1; // Note the +1 !!!
157  *m_qbits1=tilecell->qbit1();
158  *m_qbits2=tilecell->qbit2();
159  if(gain1>=0 && ((*m_qbits1) & TileCell::MASK_BADCH)!=0 &&
160  qual1!=qual2 && (qual1!=255 || qual2!=255))
161  gain1= !gain1;
162  if(gain2>=0 && ((*m_qbits2) & TileCell::MASK_BADCH)!=0 &&
163  qual1!=qual2 && (qual1!=255 || qual2!=255))
164  gain2= !gain2;
168  *m_chan2Cells=chan2;
169  if(tilecell->badch1())
170  *m_status1Cells=bad1+10;
171  else *m_status1Cells=bad1;
172  if(tilecell->badch2())
173  *m_status2Cells=bad2+10;
174  else *m_status2Cells=bad2;
175  *m_qual1Cells=qual1;
176  *m_qual2Cells=qual2;
177  *m_timeCells=tilecell->time();
178  *m_ediffCells=tilecell->eneDiff();
179  *m_tdiffCells=tilecell->timeDiff();
180  }
181  if ( log.level() < MSG::DEBUG )DumpCellInfo(); // Dump cell info only if in VERBOSE mode
182  }
183  else log << MSG::WARNING << " Cell of id "<< cell->ID()
184  <<" : TileHelper is_tile, but TileCell pointer is 0 "
185  << endmsg;
186 
187 
188  return StatusCode::SUCCESS;
189  }
190 
192  MsgStream log( msgSvc(), name() );
193  log << MSG::INFO << "Dumping Cell info:" << endmsg;
194  if (m_savePosition) {
195  log << MSG::INFO << " X :" <<*m_xCells << endmsg;
196  log << MSG::INFO << " Y :" <<*m_yCells << endmsg;
197  log << MSG::INFO << " Z :" <<*m_zCells << endmsg;
198  log << MSG::INFO << " PMT1 :" <<*m_pmt1Cells << endmsg;
199  log << MSG::INFO << " PMT2 :" <<*m_pmt2Cells << endmsg;
200  }
201  if (m_saveCellDetails) {
202  log << MSG::INFO << " Time :" <<*m_timeCells << endmsg;
203  log << MSG::INFO << " Ediff :" <<*m_ediffCells << endmsg;
204  log << MSG::INFO << " Tdiff :" <<*m_tdiffCells << endmsg;
205  log << MSG::INFO << " Module :" <<*m_moduleCells << endmsg;
206  log << MSG::INFO << " Partition :" <<*m_partitionCells << endmsg;
207  log << MSG::INFO << " Tower :" <<*m_towerCells << endmsg;
208  log << MSG::INFO << " Sample :" <<*m_sampleCells << endmsg;
209  log << MSG::INFO << " Gain1 :" <<*m_gain1Cells << endmsg;
210  log << MSG::INFO << " Gain2 :" <<*m_gain2Cells << endmsg;
211  log << MSG::INFO << " Chan1 :" <<*m_chan1Cells << endmsg;
212  log << MSG::INFO << " Chan2 :" <<*m_chan2Cells << endmsg;
213  log << MSG::INFO << " Status1 :" <<*m_status1Cells << endmsg;
214  log << MSG::INFO << " Status2 :" <<*m_status2Cells << endmsg;
215  log << MSG::INFO << " QF1 :" <<*m_qual1Cells << endmsg;
216  log << MSG::INFO << " QF2 :" <<*m_qual2Cells << endmsg;
217  }
218  }
219 
220 }
221 
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
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
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:134
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:191
TileCablingService::isRun2PlusCabling
bool isRun2PlusCabling() const
Definition: TileCablingService.h:278
StoreGateSvc
The Athena Transient Store API.
Definition: StoreGateSvc.h:128
D3PD
Block filler tool for noisy FEB information.
Definition: InnerDetector/InDetMonitoring/InDetGlobalMonitoring/macros/EnhancedPrimaryVertexMonitoring/TrigD3PD/ChainGroup.h:21
D3PD::TileCellDetailsFillerTool::m_timeCells
float * m_timeCells
Definition: TileCellDetailsFillerTool.h:97
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:105
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
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
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:68
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
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:195
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:72
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:228
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
TileHWID::NOT_VALID_HASH
@ NOT_VALID_HASH
Definition: TileHWID.h:314
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
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
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:49
IdentifierHash
Definition: IdentifierHash.h:38
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