ATLAS Offline Software
Loading...
Searching...
No Matches
JiveXML::CaloMBTSRetriever Class Reference

Retrieves all Calo Cluster objects. More...

#include <CaloMBTSRetriever.h>

Inheritance diagram for JiveXML::CaloMBTSRetriever:
Collaboration diagram for JiveXML::CaloMBTSRetriever:

Public Member Functions

virtual StatusCode retrieve (ToolHandle< IFormatTool > &FormatTool) override
 Retrieve all the data.
const DataMap getMBTSData (const TileCellContainer *tileMBTSCellContainer)
 Retrieve MBTS cell location and details.
virtual std::string dataTypeName () const override
 Return the name of the data type.
virtual StatusCode initialize () override
 Default AthAlgTool methods.

Private Attributes

ToolHandle< TileCondToolTimingm_tileToolTiming
ToolHandle< TileCondToolEmscalem_tileToolEmscale
const TileTBIDm_tileTBID {}
SG::ReadHandleKey< TileCellContainerm_sgKeyMBTS {this, "StoreGateKey", "MBTSContainer", "Name of the TileCellContainer"}
SG::ReadHandleKey< TileDigitsContainerm_sgKeyTileDigits
SG::ReadHandleKey< TileRawChannelContainerm_sgKeyTileRawChannel
Gaudi::Property< double > m_mbtsThreshold {this, "MBTSThreshold", 0.05}
Gaudi::Property< bool > m_mbts {this, "RetrieveMBTS", true}
Gaudi::Property< bool > m_mbtsdigit {this, "DoMBTSDigits", false}
Gaudi::Property< bool > m_mbtsCellDetails {this, "DoMBTSCellDetails", false}

Detailed Description

Retrieves all Calo Cluster objects.

  • Properties
    • StoreGateKeyMBTS: default is 'MBTSContainer'. Don't change.
    • MBTSThreshold: default is 0.05 (geV)
    • RetrieveMBTS: activate retriever, default is true
    • DoMBTSDigits: write MBTS digits (ADC), default is false
  • Retrieved Data
    • location in phi and eta
    • numCells: number of cells in each cluster
    • cells: identifier and adc counts of each cell

Definition at line 47 of file CaloMBTSRetriever.h.

Member Function Documentation

◆ dataTypeName()

virtual std::string JiveXML::CaloMBTSRetriever::dataTypeName ( ) const
inlineoverridevirtual

Return the name of the data type.

Definition at line 57 of file CaloMBTSRetriever.h.

57{ return "MBTS"; };

◆ getMBTSData()

const DataMap JiveXML::CaloMBTSRetriever::getMBTSData ( const TileCellContainer * tileMBTSCellContainer)

Retrieve MBTS cell location and details.

Parameters
FormatToolthe tool that will create formated output from the DataMap

< Unit for TileRawChannels (ADC, pCb, etc.)

Definition at line 74 of file CaloMBTSRetriever.cxx.

74 {
75
76 ATH_MSG_DEBUG( "getMBTSData()" );
77
79
80 DataVect energy; energy.reserve(tileMBTSCellContainer->size());
81 DataVect label; label.reserve(tileMBTSCellContainer->size());
82 DataVect phi; phi.reserve(tileMBTSCellContainer->size());
83 DataVect eta; eta.reserve(tileMBTSCellContainer->size());
84 DataVect sampling; sampling.reserve(tileMBTSCellContainer->size());
85 DataVect timeVec; timeVec.reserve(tileMBTSCellContainer->size());
86 DataVect quality; quality.reserve(tileMBTSCellContainer->size());
87 DataVect type; type.reserve(tileMBTSCellContainer->size());
88 DataVect channel; channel.reserve(tileMBTSCellContainer->size());
89 DataVect module; module.reserve(tileMBTSCellContainer->size());
90 DataVect cellPedestal; cellPedestal.reserve(tileMBTSCellContainer->size());
91 DataVect cellRawAmplitude; cellRawAmplitude.reserve(tileMBTSCellContainer->size());
92 DataVect cellRawTime; cellRawTime.reserve(tileMBTSCellContainer->size());
93 DataVect adcCounts; adcCounts.reserve(tileMBTSCellContainer->size() * 10);
94
95 std::string adcCountsStr="adcCounts multiple=\"0\"";
96 const TileHWID* tileHWID = nullptr;
97 const TileInfo* tileInfo = nullptr;
98 const TileCablingService* cabling=nullptr;
101 bool offlineRch = false;
102
103 if ( detStore()->retrieve(m_tileTBID).isFailure() ) {
104 ATH_MSG_ERROR( "in getMBTSData(), Could not retrieve m_tileTBID" );
105 }
106
107 if ( detStore()->retrieve(tileHWID).isFailure() ) {
108 ATH_MSG_ERROR( "in getMBTSData(), Could not retrieve TileHWID" );
109 }
110
111 if ( detStore()->retrieve(tileInfo, "TileInfo").isFailure() ) {
112 ATH_MSG_ERROR( "in getMBTSData(), Could not retrieve TileInfo" );
113 }
114
115 SG::ReadHandle<TileRawChannelContainer> RawChannelCnt;
116 if (m_mbtsCellDetails) {
117 RawChannelCnt = SG::makeHandle(m_sgKeyTileRawChannel);
118 if (!RawChannelCnt.isValid()){
119 ATH_MSG_WARNING( "Could not retrieve TileRawChannel " );
120 }
121 else{
122 RChUnit = RawChannelCnt->get_unit();
123 offlineRch = (RChUnit<TileRawChannelUnit::OnlineADCcounts &&
124 RawChannelCnt->get_type() != TileFragHash::OptFilterDsp);
125 }
126 }
127
128 SG::ReadHandle<TileDigitsContainer> tileDigits;
129 if (m_mbtsdigit) {
130 tileDigits = SG::makeHandle(m_sgKeyTileDigits);
131 if (!tileDigits.isValid()){
132 ATH_MSG_WARNING( "Could not retrieve TileDigits " );
133 }
134 }
135
136 // from: TileCalorimeter/TileRec/src/TileCellToNtuple.cxx
137
138 std::string MBTS_ID;
139 int nchan =0;
140 int nTileSamples=0;
141 const int max_chan=5216;
142 double energyMeV = 0.;
143 double phiMBTS = 0.;
144 double amplitude = 0.;
145 unsigned long int cellid;
146 std::map<unsigned long int,double> theMbtspedestal;
147 std::map<unsigned long int,double> theMbtsrawamp;
148 std::map<unsigned long int,double> theMbtsrawtime;
149 std::map<unsigned long int,std::vector<float> > theMbtsdigit;
150 std::string myCellRawTimeStr = "0.";
151
152 //Loop over TileRawChannel to get Pedestal and raw amplitude and time
153
154 if (m_mbtsCellDetails && RawChannelCnt.isValid()) {
155 if (offlineRch) {
156
157 for (const auto rawChannel : *RawChannelCnt) {
158 for (const auto cell : *rawChannel) {
159 Identifier pmt_id = cell->pmt_ID();
160 if (!m_tileTBID->is_tiletb(pmt_id)) continue;
161 Identifier id = cell->cell_ID();
162 cellid = id.get_identifier32().get_compact();
163 HWIdentifier hwid=cell->adc_HWID();
164 int adc = tileHWID->adc(hwid);
165 int channel = tileHWID->channel(hwid);
166 int drawer = tileHWID->drawer(hwid);
167 int ros = tileHWID->ros(hwid);
168 int drawerIdx = TileCalibUtils::getDrawerIdx(ros,drawer);
169
170 amplitude = cell->amplitude();
171 //Change amplitude units to ADC counts
173 amplitude /= m_tileToolEmscale->channelCalib(drawerIdx, channel, adc, 1.0, TileRawChannelUnit::ADCcounts, RChUnit);
174 } else if (RChUnit > TileRawChannelUnit::OnlineADCcounts) {
175 amplitude = m_tileToolEmscale->undoOnlCalib(drawerIdx, channel, adc, amplitude, RChUnit);
176 }
177 theMbtspedestal.insert(std::make_pair( cellid, cell->pedestal() ) );
178 theMbtsrawamp.insert(std::make_pair( cellid, amplitude ));
179 theMbtsrawtime.insert(std::make_pair( cellid, cell->time(cell->uncorrTime()) ));
180 break;
181
182 }
183 }
184 }
185 }
186
187 //Loop over TileDigits to retrieve MBTS digits
188
189 if (m_mbtsdigit && tileDigits.isValid()) {
190
191 //----- get tile digits--------------------------
192
193 // tile digits loop
194 for (const auto digitChannel : *tileDigits) {
195
196 for (const auto cell : *digitChannel) {
197
198 Identifier pmt_id = cell->pmt_ID();
199 if (!m_tileTBID->is_tiletb(pmt_id)) continue;
200
201 Identifier id = cell->cell_ID();
202 cellid = id.get_identifier32().get_compact();
203
204 nTileSamples = cell->NtimeSamples();
205 std::vector<float> tileSamples = cell->samples();
206 theMbtsdigit.insert(std::make_pair( cellid, tileSamples));
207 break;
208
209 }
210 }//for TileDigitContainer loop
211 } //if (m_mbtsdigit)
212
213 //Loop Over TileCellContainer to retrieve MBTSCell information
214
215 for (const auto cell : *tileMBTSCellContainer) {
216
217 int qual = cell->quality();
218 if (cell->badcell()) qual = -qual;
219
220 timeVec.push_back(DataType( cell->time() ));
221 quality.push_back(DataType( qual ));
222
223 if ( cell->energy() >= m_mbtsThreshold ) {
224 energyMeV = cell->energy(); // roughly correct: energy unit is pC, which is 95% MeV
225 }else{
226 energyMeV = 0.;
227 }
228 energy.push_back(DataType( energyMeV )); // write in MeV
229
230 Identifier id=cell->ID();
231
232 //TileCell/type is "side" +/- 1
233 //TileCell/module is "phi" 0-7
234 //TileCell/channel is "eta" 0-1 zero is closer to beam pipe
235
236 type.push_back(DataType( m_tileTBID->type(id) ));
237 channel.push_back(DataType( m_tileTBID->channel(id) ));
238 module.push_back(DataType( m_tileTBID->module(id) ));
239
240 MBTS_ID = "type_" + DataType( m_tileTBID->type(id) ).toString() + "_ch_" +
241 DataType( m_tileTBID->channel(id) ).toString() + "_mod_" +
242 DataType( m_tileTBID->module(id) ).toString();
243
244 label.push_back(DataType( MBTS_ID ));
245
246 eta.push_back(DataType( 5.0*m_tileTBID->type(id) ));
247
248 phiMBTS = (M_PI/8)+(2*M_PI/8)*int(m_tileTBID->module(id));
249 phi.push_back(DataType( phiMBTS ));
250 sampling.push_back(DataType( m_tileTBID->channel(id) ));
251
252 if (m_mbtsCellDetails && RawChannelCnt.isValid()) {
253
254 cellPedestal.push_back(DataType( theMbtspedestal[id.get_identifier32().get_compact()] ));
255 cellRawAmplitude.push_back(DataType( theMbtsrawamp[id.get_identifier32().get_compact()] ));
256 myCellRawTimeStr = DataType(theMbtsrawtime[id.get_identifier32().get_compact()]).toString();
257
258 if ( myCellRawTimeStr.find('n') == 1 ) myCellRawTimeStr="0.";
259 cellRawTime.push_back( myCellRawTimeStr );
260
261 // this can rarely be '-nan', but checking this each time may make code slow ?
262 }
263 else { // don't have TileRawChannel container (for DPF input)
264
265 float maxTime = (tileInfo->NdigitSamples()/2) * 25;
266 int gain = cell->gain();
267
268 if (gain<0 || gain>1) { //invalid gain - channel missing
269 cellRawAmplitude.push_back(DataType(0));
270 cellRawTime.push_back(DataType(0));
271 cellPedestal.push_back(DataType(0)); //There is no pedestal in DPD .
272 }
273 else {
274
275 HWIdentifier hwid = tileHWID->adc_id(cabling->s2h_channel_id(id),gain);
276 int adc = tileHWID->adc(hwid);
277 int channel = tileHWID->channel(hwid);
278 int drawer = tileHWID->drawer(hwid);
279 int ros = tileHWID->ros(hwid);
280 int drawerIdx = TileCalibUtils::getDrawerIdx(ros,drawer);
281 float scale = m_tileToolEmscale->channelCalib(drawerIdx, channel, adc, 1.0,
283 float amp;
284
285 if ( cell->energy() >= m_mbtsThreshold ) amp = cell->energy()/scale;
286 else amp = 0.0;
287 float time = cell->time();
288
289 if ((qual != 0 || amp != 0.0) && (fabs(time) < maxTime && time != 0.0)) {
290 time += m_tileToolTiming->getSignalPhase(drawerIdx, channel, adc);
291 }
292
293 cellRawAmplitude.push_back(DataType(amp));
294 cellRawTime.push_back(DataType(time));
295 cellPedestal.push_back(DataType(0)); //There is no pedestal in DPD . This line is temporary.
296 }
297 }
298
299
300 if (m_mbtsdigit && tileDigits.isValid()) {
301
302 if ( !theMbtsdigit[id.get_identifier32().get_compact()].empty() ) {
303 for (int i=0; i<nTileSamples; i++) {
304 adcCountsStr="adcCounts multiple=\""+DataType(nTileSamples).toString()+"\"";
305 adcCounts.push_back(DataType( int(theMbtsdigit[id.get_identifier32().get_compact()][i]) ));
306 }
307 }
308 else {
309 for (int i=0; i<nTileSamples; i++) {
310 adcCountsStr="adcCounts multiple=\""+DataType(nTileSamples).toString()+"\"";
311 adcCounts.push_back(DataType(0));
312 }
313 }
314 }
315
316
317 ATH_MSG_DEBUG( "MBTS no: " << nchan << ", type_chan_mod: " << MBTS_ID
318 << ", energy MeV pC: " << energyMeV );
319
320 nchan++;
321
322 if (nchan >= max_chan) break;
323
324 }//TileCell Loop
325
326 if (!theMbtspedestal.empty()) theMbtspedestal.clear();
327 if (!theMbtsrawamp.empty() ) theMbtsrawamp.clear();
328 if (!theMbtsrawtime.empty()) theMbtsrawtime.clear();
329
330 // write values into DataMap
331 const auto nentries = phi.size();
332 DataMap["energy"] = std::move(energy);
333 DataMap["label"] = std::move(label);
334 DataMap["phi"] = std::move(phi);
335 DataMap["eta"] = std::move(eta);
336 DataMap["sampling"] = std::move(sampling);
337 DataMap["time"] = std::move(timeVec);
338 DataMap["quality"] = std::move(quality);
339 DataMap["type"] = std::move(type);
340 DataMap["channel"] = std::move(channel);
341 DataMap["module"] = std::move(module);
342 DataMap["cellPedestal"] = std::move(cellPedestal);
343 DataMap["cellRawAmplitude"] = std::move(cellRawAmplitude);
344 DataMap["cellRawTime"] = std::move(cellRawTime);
345 DataMap[adcCountsStr] = std::move(adcCounts);
346
347 //Be verbose
348 ATH_MSG_DEBUG( dataTypeName() << " retrieved with " << nentries << " entries" );
349
350 //All collections retrieved okay
351 return DataMap;
352
353 } // getMBTSData
#define M_PI
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
OFFLINE_FRAGMENTS_NAMESPACE::PointerType DataType
const int max_chan
static const Attributes_t empty
size_type size() const noexcept
virtual std::string dataTypeName() const override
Return the name of the data type.
Gaudi::Property< double > m_mbtsThreshold
SG::ReadHandleKey< TileRawChannelContainer > m_sgKeyTileRawChannel
Gaudi::Property< bool > m_mbtsCellDetails
Gaudi::Property< bool > m_mbtsdigit
ToolHandle< TileCondToolEmscale > m_tileToolEmscale
ToolHandle< TileCondToolTiming > m_tileToolTiming
virtual StatusCode retrieve(ToolHandle< IFormatTool > &FormatTool) override
Retrieve all the data.
SG::ReadHandleKey< TileDigitsContainer > m_sgKeyTileDigits
virtual bool isValid() override final
Can the handle be successfully dereferenced?
static const TileCablingService * getInstance()
get pointer to service instance
static unsigned int getDrawerIdx(unsigned int ros, unsigned int drawer)
Returns a drawer hash.
int channel(const HWIdentifier &id) const
extract channel field from HW identifier
Definition TileHWID.h:189
int adc(const HWIdentifier &id) const
extract adc field from HW identifier
Definition TileHWID.h:193
int drawer(const HWIdentifier &id) const
extract drawer field from HW identifier
Definition TileHWID.h:171
HWIdentifier adc_id(int ros, int drawer, int channel, int adc) const
adc HWIdentifer
Definition TileHWID.cxx:229
int ros(const HWIdentifier &id) const
extract ros field from HW identifier
Definition TileHWID.h:167
int NdigitSamples() const
Returns the number of sammples (digits) per event.
Definition TileInfo.h:75
std::string label(const std::string &format, int i)
Definition label.h:19
time(flags, cells_name, *args, **kw)
std::map< std::string, DataVect > DataMap
Definition DataType.h:59
std::vector< DataType > DataVect
Defines a map with a key and a vector of DataType objects e.g.
Definition DataType.h:58
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())

◆ initialize()

StatusCode JiveXML::CaloMBTSRetriever::initialize ( )
overridevirtual

Default AthAlgTool methods.

Initialise the Tool.

Definition at line 27 of file CaloMBTSRetriever.cxx.

27 {
28
29 ATH_MSG_DEBUG( "Initialising Tool" );
30
31 ATH_CHECK(m_sgKeyMBTS.initialize());
32
33 //=== get TileCondToolTiming
34 ATH_CHECK( m_tileToolTiming.retrieve() );
35
36 //=== get TileCondToolEmscale
37 ATH_CHECK( m_tileToolEmscale.retrieve() );
38
40
42
43 return StatusCode::SUCCESS;
44 }
#define ATH_CHECK
Evaluate an expression and check for errors.
SG::ReadHandleKey< TileCellContainer > m_sgKeyMBTS

◆ retrieve()

StatusCode JiveXML::CaloMBTSRetriever::retrieve ( ToolHandle< IFormatTool > & FormatTool)
overridevirtual

Retrieve all the data.

MBTS data retrieval from chosen collection.

Definition at line 49 of file CaloMBTSRetriever.cxx.

49 {
50
51 ATH_MSG_DEBUG( "in retrieve()" );
52
53 SG::ReadHandle<TileCellContainer> cellContainerMBTS(m_sgKeyMBTS);
54 if (!cellContainerMBTS.isValid()){
55 ATH_MSG_WARNING( "Could not retrieve MBTS Cells " );
56 }
57 else{
58 if (m_mbts) {
59 DataMap data = getMBTSData(&(*cellContainerMBTS));
60 ATH_CHECK( FormatTool->AddToEvent(dataTypeName(), m_sgKeyMBTS.key(), &data) );
61 ATH_MSG_DEBUG( "MBTS retrieved" );
62 }
63 }
64
65 //MBTS cells retrieved okay
66 return StatusCode::SUCCESS;
67 }
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
const DataMap getMBTSData(const TileCellContainer *tileMBTSCellContainer)
Retrieve MBTS cell location and details.
Gaudi::Property< bool > m_mbts

Member Data Documentation

◆ m_mbts

Gaudi::Property<bool> JiveXML::CaloMBTSRetriever::m_mbts {this, "RetrieveMBTS", true}
private

Definition at line 78 of file CaloMBTSRetriever.h.

78{this, "RetrieveMBTS", true};

◆ m_mbtsCellDetails

Gaudi::Property<bool> JiveXML::CaloMBTSRetriever::m_mbtsCellDetails {this, "DoMBTSCellDetails", false}
private

Definition at line 80 of file CaloMBTSRetriever.h.

80{this, "DoMBTSCellDetails", false};

◆ m_mbtsdigit

Gaudi::Property<bool> JiveXML::CaloMBTSRetriever::m_mbtsdigit {this, "DoMBTSDigits", false}
private

Definition at line 79 of file CaloMBTSRetriever.h.

79{this, "DoMBTSDigits", false};

◆ m_mbtsThreshold

Gaudi::Property<double> JiveXML::CaloMBTSRetriever::m_mbtsThreshold {this, "MBTSThreshold", 0.05}
private

Definition at line 77 of file CaloMBTSRetriever.h.

77{this, "MBTSThreshold", 0.05};

◆ m_sgKeyMBTS

SG::ReadHandleKey<TileCellContainer> JiveXML::CaloMBTSRetriever::m_sgKeyMBTS {this, "StoreGateKey", "MBTSContainer", "Name of the TileCellContainer"}
private

Definition at line 71 of file CaloMBTSRetriever.h.

71{this, "StoreGateKey", "MBTSContainer", "Name of the TileCellContainer"};

◆ m_sgKeyTileDigits

SG::ReadHandleKey<TileDigitsContainer> JiveXML::CaloMBTSRetriever::m_sgKeyTileDigits
private
Initial value:
{this, "TileDigitsContainer", ""
, "Input collection to retrieve Tile raw channels, used when DoMBTSCellDetails is True"}

Definition at line 72 of file CaloMBTSRetriever.h.

72 {this, "TileDigitsContainer", ""
73 , "Input collection to retrieve Tile raw channels, used when DoMBTSCellDetails is True"};

◆ m_sgKeyTileRawChannel

SG::ReadHandleKey<TileRawChannelContainer> JiveXML::CaloMBTSRetriever::m_sgKeyTileRawChannel
private
Initial value:
{this, "TileRawChannelContainer", ""
, "Input collection to retrieve Tile digits, used when doTileDigit is True"}

Definition at line 74 of file CaloMBTSRetriever.h.

74 {this, "TileRawChannelContainer", ""
75 , "Input collection to retrieve Tile digits, used when doTileDigit is True"};

◆ m_tileTBID

const TileTBID* JiveXML::CaloMBTSRetriever::m_tileTBID {}
private

Definition at line 69 of file CaloMBTSRetriever.h.

69{};

◆ m_tileToolEmscale

ToolHandle<TileCondToolEmscale> JiveXML::CaloMBTSRetriever::m_tileToolEmscale
private
Initial value:
{this,
"TileCondToolEmscale", "TileCondToolEmscale", "Tile EM scale calibration tool"}

Definition at line 66 of file CaloMBTSRetriever.h.

66 {this,
67 "TileCondToolEmscale", "TileCondToolEmscale", "Tile EM scale calibration tool"};

◆ m_tileToolTiming

ToolHandle<TileCondToolTiming> JiveXML::CaloMBTSRetriever::m_tileToolTiming
private
Initial value:
{this,
"TileCondToolTiming", "TileCondToolTiming", "Tile timing tool"}

Definition at line 63 of file CaloMBTSRetriever.h.

63 {this,
64 "TileCondToolTiming", "TileCondToolTiming", "Tile timing tool"};

The documentation for this class was generated from the following files: