ATLAS Offline Software
ZdcRecChannelToolV2.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  * ZdcRecChannelTool.cxx
7  *
8  * Created on: Nov 24, 2009
9  * Author: steinber
10  */
11 
12 
13 #include <iostream>
14 #include <fstream>
15 
16 #include <cmath>
17 #include <map>
18 #include <vector>
19 
20 #include "TMath.h"
21 
22 #include "GaudiKernel/IInterface.h"
23 #include "GaudiKernel/MsgStream.h"
24 
31 #include "ZdcRec/ZdcSignalSinc.h"
33 
34 
35 #include "ZdcIdentifier/ZdcID.h"
37 #include "AthContainers/Accessor.h"
38 
39 const int slink2ppmChannel[64] =
40  {0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60,
41  3, 7, 11, 15, 19, 23, 27, 31, 35, 39, 43, 47, 51, 55, 59, 63,
42  1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61,
43  2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58, 62 };
44 
45 
46 //==================================================================================================
48  AsgTool(name)
49 {
50  //Declare properties here...
51 
52  declareInterface<ZdcRecChannelToolV2>(this);
53  declareProperty("ZeroSuppress", m_zeroSupress = 0,"Supress channels with only 0");
54  declareProperty("DeltaPeak", m_delta = 5,"Minimum difference between min and max to be considered a signal");
55  declareProperty("SaturationADC",m_saturation = 1000,"ADC value above which a HG channel is considered saturated");
56  declareProperty("NSamples",m_nsamples=5,"Number of samples in PPM raw data");
57  declareProperty("UseDelay",m_useDelay=0,"If true, then use delayed channels");
58  declareProperty("SampleTime",m_sample_time=12.5,"Sample time in ns (25. = 40 MHz, 12.5 = 80 MHz)");
59  declareProperty("GainFactor",m_gainFactor=10.,"High/lo gain factor");
60  declareProperty("PedestalValue",m_pedestalValue=100.,"Pedestal value");
61 }
62 //==================================================================================================
63 
64 
65 void ZdcRecChannelToolV2::handle( const Incident& inc )
66 {
67  if ( inc.type() == IncidentType::EndEvent) {
68 
69  }
70 }
71 
72 
73 //==================================================================================================
75 {
76  msg(MSG::INFO) << "Initializing " << name() << endmsg;
77 
78  //Get the pedestal information for the channels.
79  //For now, this is a file; later on it will be moved to a database
80 
81  // NONE
82 
83  const ZdcID* zdcId = nullptr;
84  if (detStore()->retrieve( zdcId ).isFailure() ) {
85  msg(MSG::ERROR) << "execute: Could not retrieve ZdcID object from the detector store" << endmsg;
86  return StatusCode::FAILURE;
87  }
88  else {
89  msg(MSG::DEBUG) << "execute: retrieved ZdcID" << endmsg;
90  }
91  m_zdcId = zdcId;
92 
93  msg(MSG::DEBUG) << "--> ZDC : END OF MODIFICATION 0" << endmsg ;
94  return StatusCode::SUCCESS;
95 
96  ServiceHandle<IIncidentSvc> incidentSvc("IncidentSvc", name());
97  CHECK(incidentSvc.retrieve());
98  incidentSvc->addListener(this, IncidentType::EndEvent);
99 }
100 //==================================================================================================
101 
102 //==================================================================================================
104 {
105  msg(MSG::INFO) << "Finalizing " << name() << endmsg;
106 
107  return StatusCode::SUCCESS;
108 }
109 //==================================================================================================
110 
112 {
113 
114  //typedef std::map<uint64_t,xAOD::ZdcModule*> hashmapType;
115  typedef std::map<uint32_t,xAOD::ZdcModule*> hashmapType;
116  hashmapType digits_map;
117  Identifier chan_id;
118 
119  //std::cout << "Zdc TT's have " << ttCollection->size() << " towers" << std::endl;
120 
121  for (const xAOD::TriggerTower* tt : *ttCollection)
122  {
123  //std::cout << "ZdcTT coolId = " << tt->coolId() << std::endl;
124  //std::cout << ZdcToString(*tt) << std::endl;
125 
126  uint32_t coolId = tt->coolId();
127  uint32_t pin = (coolId>>8) & 0xf;
128  uint32_t asic = coolId & 0xf;
129  uint32_t slinkChannel = asic*16 + pin;
130  uint32_t ppmChannel = slink2ppmChannel[slinkChannel];
131 
132  uint32_t module = (coolId>>16) & 0xf;
133 
134  ATH_MSG_DEBUG( "--> ZCS: " << ZdcCablingService::getInstance() << " mod=" << module << " slinkC=" << slinkChannel << " ppmC=" << ppmChannel );
135 
136  chan_id = ZdcCablingService::getInstance()->h2s_channel_id(module, ppmChannel);
137 
138  const uint32_t chan_hash = chan_id.get_identifier32().get_compact();
139 
142 
143  int side = m_zdcId->side(chan_id);
144  int mod = m_zdcId->module(chan_id);
145  int type = m_zdcId->type(chan_id);
146  int channel = m_zdcId->channel(chan_id);
147 
148  ATH_MSG_DEBUG( "Trying to set data of " << std::hex << chan_hash << std::dec << " side=" << side << " mod=" << mod << " type=" << type << " channel=" << channel << " gain=" << gain << " delay=" << delay);
149 
150  hashmapType::iterator iter = digits_map.find(chan_hash);
151  if (iter == digits_map.end())
152  {
153 
154  xAOD::ZdcModule* new_mod = new xAOD::ZdcModule();
155  ATH_MSG_DEBUG("new module for " << chan_hash << std::hex << " new_mod=" << new_mod);
156 
157  zdcModules->push_back(xAOD::ZdcModuleContainer::unique_type(new_mod));
158 
159  new_mod->setZdcId(chan_hash);
160  new_mod->setZdcSide(side);
161  new_mod->setZdcModule(mod);
162  new_mod->setZdcType(type);
163  new_mod->setZdcChannel(channel);
164 
165  digits_map.insert(std::pair<uint32_t,xAOD::ZdcModule*>(chan_hash,new_mod));
166  iter = digits_map.find(chan_hash);
167  }
168 
169  if (iter != digits_map.end())
170  {
171  ATH_MSG_DEBUG("adding data to " << std::hex << (*iter).first << " p=" << (*iter).second << " from tt=" << tt << " zdcModule=" << (*iter).second->zdcModule());
172  static const SG::Accessor<std::vector<uint16_t> > g0d1dataAcc ("g0d1data");
173  static const SG::Accessor<std::vector<uint16_t> > g1d1dataAcc ("g1d1data");
174  static const SG::Accessor<std::vector<uint16_t> > g0d0dataAcc ("g0d0data");
175  static const SG::Accessor<std::vector<uint16_t> > g1d0dataAcc ("g1d0data");
176  if (gain==0&&delay==0) g0d0dataAcc(*iter->second) = tt->adc() ;
177  if (gain==0&&delay==1) g0d1dataAcc(*iter->second) = tt->adc() ;
178  if (gain==1&&delay==0) g1d0dataAcc(*iter->second) = tt->adc() ;
179  if (gain==1&&delay==1) g1d1dataAcc(*iter->second) = tt->adc() ;
180  ATH_MSG_DEBUG("added data to " << std::hex << (*iter).first << " p=" << (*iter).second << " from tt=" << tt);
181  }
182  }
183 
184  ATH_MSG_INFO("adding side data");
185 
186  // create ZDC sides
187  for (int iside = 0;iside<2;iside++)
188  {
189  xAOD::ZdcModule* new_sum = new xAOD::ZdcModule();
191  new_sum->setZdcSide(iside ? 1 : -1);
192  }
193 
194  return 0;
195 
196 
197 }
198 
199 
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
ZdcCablingService::getInstance
static const ZdcCablingService * getInstance()
get pointer to service instance
Definition: ZdcCablingService.cxx:14
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:28
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SG::Accessor
Helper class to provide type-safe access to aux data.
Definition: Control/AthContainers/AthContainers/Accessor.h:66
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
ZdcSignalSinc.h
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
ZdcRecChannelToolV2::handle
virtual void handle(const Incident &) override
Definition: ZdcRecChannelToolV2.cxx:65
ZdcID::module
int module(const Identifier &id) const
Definition: ZdcID.h:163
CaloCondBlobAlgs_fillNoiseFromASCII.gain
gain
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:110
TriggerTowerContainer.h
xAOD::ZdcModule_v1
Class containing ZDC Module information.
Definition: ZdcModule_v1.h:25
ZdcRecChannelToolV2::m_gainFactor
float m_gainFactor
Definition: ZdcRecChannelToolV2.h:60
ZdcRecChannelToolV2::m_pedestalValue
float m_pedestalValue
Definition: ZdcRecChannelToolV2.h:65
ZdcRecChannelToolV2::ZdcRecChannelToolV2
ZdcRecChannelToolV2(const std::string &name)
Definition: ZdcRecChannelToolV2.cxx:47
ZdcCablingService::h2s_channel_id
Identifier h2s_channel_id(int crate, int channel) const
Definition: ZdcCablingService.cxx:326
xAOD::ZdcModule_v1::setZdcModule
void setZdcModule(int)
ZdcRecChannelToolV2::m_nsamples
unsigned int m_nsamples
Definition: ZdcRecChannelToolV2.h:58
AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
TRT::Hit::side
@ side
Definition: HitInfo.h:83
ZdcModuleAuxContainer.h
python.PyAthena.module
module
Definition: PyAthena.py:134
ZdcRecChannelToolV2::m_delta
int m_delta
Definition: ZdcRecChannelToolV2.h:62
ZdcCablingService.h
maskDeadModules.mod
mod
Definition: maskDeadModules.py:36
Identifier32::get_compact
value_type get_compact(void) const
Get the compact id.
Definition: Identifier32.h:171
ZdcRecChannelToolV2::initialize
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition: ZdcRecChannelToolV2.cxx:74
slink2ppmChannel
const int slink2ppmChannel[64]
Definition: ZdcRecChannelToolV2.cxx:39
xAOD::ZdcModule_v1::setZdcId
void setZdcId(uint32_t)
ZdcCablingService::hwid2delay
int hwid2delay(int crate, int channel) const
Definition: ZdcCablingService.cxx:417
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
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ZdcRecChannelToolV2::m_useDelay
bool m_useDelay
Definition: ZdcRecChannelToolV2.h:61
ZdcRecChannelToolV2::m_saturation
int m_saturation
Definition: ZdcRecChannelToolV2.h:64
xAOD::TriggerTower_v2
Description of TriggerTower_v2.
Definition: TriggerTower_v2.h:49
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
delay
double delay(std::size_t d)
Definition: JetTrigTimerTest.cxx:14
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
ZdcRecChannelToolV2::m_sample_time
float m_sample_time
Definition: ZdcRecChannelToolV2.h:59
ZdcToString.h
ZdcRecChannelToolV2::finalize
virtual StatusCode finalize() override
Definition: ZdcRecChannelToolV2.cxx:103
DataVector::unique_type
std::unique_ptr< base_value_type > unique_type
Type of a unique_ptr that can be used to insert elements into this container.
Definition: DataVector.h:828
xAOD::ZdcModule
ZdcModule_v1 ZdcModule
Definition: ZdcModule.h:15
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
ZdcRecChannelToolV2::m_zeroSupress
int m_zeroSupress
Definition: ZdcRecChannelToolV2.h:63
Accessor.h
Helper class to provide type-safe access to aux data.
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
ZdcRecChannelToolV2.h
ZdcCablingService::hwid2gain
int hwid2gain(int crate, int channel) const
Definition: ZdcCablingService.cxx:407
ZdcID.h
xAOD::ZdcModule_v1::setZdcSide
void setZdcSide(int)
xAOD::ZdcModule_v1::setZdcChannel
void setZdcChannel(int)
ZdcModuleToString.h
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
DEBUG
#define DEBUG
Definition: page_access.h:11
ZdcID::side
int side(const Identifier &id) const
Values of different levels (failure returns 0)
Definition: ZdcID.h:157
AthCommonMsg< AlgTool >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
ZdcID::type
int type(const Identifier &id) const
Definition: ZdcID.h:169
xAOD::ZdcModule_v1::setZdcType
void setZdcType(int)
Identifier::get_identifier32
Identifier32 get_identifier32(void) const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
TileDCSDataPlotter.tt
tt
Definition: TileDCSDataPlotter.py:874
ZdcID
Definition: ZdcID.h:25
ZdcModuleContainer.h
ZdcRecChannelToolV2::m_zdcId
const ZdcID * m_zdcId
Definition: ZdcRecChannelToolV2.h:67
ServiceHandle< IIncidentSvc >
ZdcID::channel
int channel(const Identifier &id) const
Definition: ZdcID.h:175
ZdcRecChannelToolV2::convertTT2ZM
int convertTT2ZM(const xAOD::TriggerTowerContainer *ttCollection, xAOD::ZdcModuleContainer *zdcModules, xAOD::ZdcModuleContainer *zdcSums) const
Definition: ZdcRecChannelToolV2.cxx:111
TriggerTowerAuxContainer.h