ATLAS Offline Software
Loading...
Searching...
No Matches
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
33
34
35#include "ZdcIdentifier/ZdcID.h"
38
39const 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
65void 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
140 int gain = ZdcCablingService::getInstance()->hwid2gain(module,ppmChannel);
141 int delay = ZdcCablingService::getInstance()->hwid2delay(module,ppmChannel);
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
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
#define endmsg
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
Helper class to provide type-safe access to aux data.
#define CHECK(...)
Evaluate an expression and check for errors.
double delay(std::size_t d)
const int slink2ppmChannel[64]
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
const ServiceHandle< StoreGateSvc > & detStore() const
value_type push_back(value_type pElem)
Add an element to the end of the collection.
std::unique_ptr< base_value_type > unique_type
Definition DataVector.h:829
value_type get_compact() const
Get the compact id.
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
Helper class to provide type-safe access to aux data.
int hwid2gain(int crate, int channel) const
static const ZdcCablingService * getInstance()
get pointer to service instance
int hwid2delay(int crate, int channel) const
Identifier h2s_channel_id(int crate, int channel) const
Definition ZdcID.h:25
virtual void handle(const Incident &) override
virtual StatusCode finalize() override
int convertTT2ZM(const xAOD::TriggerTowerContainer *ttCollection, xAOD::ZdcModuleContainer *zdcModules, xAOD::ZdcModuleContainer *zdcSums) const
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
ZdcRecChannelToolV2(const std::string &name)
AsgTool(const std::string &name)
Constructor specifying the tool instance's name.
Definition AsgTool.cxx:58
void setZdcId(uint32_t)
void setZdcSide(int)
void setZdcModule(int)
void setZdcChannel(int)
void setZdcType(int)
ZdcModuleContainer_v1 ZdcModuleContainer
ZdcModule_v1 ZdcModule
Definition ZdcModule.h:15
TriggerTowerContainer_v2 TriggerTowerContainer
Define the latest version of the TriggerTower container.
TriggerTower_v2 TriggerTower
Define the latest version of the TriggerTower class.
MsgStream & msg
Definition testRead.cxx:32