38 const xAOD::TriggerTower::ConstAccessor<float> ttCellsEnergy(
"CaloCellEnergy");
39 const xAOD::TriggerTower::ConstAccessor<float> ttCellsET(
"CaloCellET");
59 m_ttTool(
"LVL1::L1TriggerTowerToolRun3/L1TriggerTowerToolRun3"),
60 m_xAODTTTools(
"LVL1::L1CaloxAODOfflineTriggerTowerTools/L1CaloxAODOfflineTriggerTowerTools", this),
61 m_jmTools(
"LVL1::L1CaloOfflineTriggerTowerTools/L1CaloOfflineTriggerTowerTools", this),
102 return StatusCode::FAILURE;
114 return StatusCode::SUCCESS;
124 <<
" events, skipping the rest" );
127 return StatusCode::SUCCESS;
135 return StatusCode::SUCCESS;
140 if(!
sc.isSuccess()) {
143 return StatusCode::RECOVERABLE;
150 const unsigned evt=ctx.eventID().event_number();
151 ATH_MSG_DEBUG(
"Event " << evt <<
" contains " << cells->size() <<
" CaloCells" );
166 unsigned int runNumber = eventInfo->
runNumber();
167 std::string gainStrategy(
"");
173 bool consistent(
true);
174 for (; itr != itrE; ++itr) {
175 const unsigned int channel = itr->first;
176 if (channel != 1 && channel != 2)
continue;
177 const coral::AttributeList& attrList = itr->second;
178 const std::string strategy(attrList[
"name"].data<std::string>());
179 const std::string status(attrList[
"status"].data<std::string>());
181 <<
", name = " << strategy
182 <<
", status = " << status );
183 if (gainStrategy.empty()) gainStrategy = std::move(strategy);
184 else if (gainStrategy != strategy) consistent =
false;
186 std::string newStrategy(
"");
187 if (runNumber == 219978) newStrategy =
"GainOneOvEmecFcalLowEta";
188 if (runNumber == 219979) newStrategy =
"GainOneOvEmbFcalHighEta";
189 if (runNumber == 219980) newStrategy =
"CalibGainsEt";
190 if (runNumber == 220013) newStrategy =
"GainOneOvEmecFcalLowEta";
191 if (runNumber == 220014) newStrategy =
"GainOneOvEmbFcalHighEta";
192 if (runNumber == 220015) newStrategy =
"CalibGainsEt";
193 if (runNumber == 222871) newStrategy =
"GainOne";
194 if (runNumber == 222872) newStrategy =
"GainOne";
195 if (runNumber == 222873) newStrategy =
"GainOne";
196 if (runNumber == 223073) newStrategy =
"GainOne";
197 if (runNumber == 223074) newStrategy =
"GainOne";
198 if (runNumber == 223075) newStrategy =
"GainOne";
199 if (not newStrategy.empty()) {
200 ATH_MSG_INFO(
"Changing Gain Strategy to " << newStrategy);
201 gainStrategy = std::move(newStrategy);
203 if (!gainStrategy.empty() && consistent) {
204 m_isGain1 = (gainStrategy.find(
"GainOne") != std::string::npos);
205 m_isOvEmb = (gainStrategy.find(
"OvEmb") != std::string::npos);
206 m_isOvEmec = (gainStrategy.find(
"OvEmec") != std::string::npos);
207 m_isFcalLowEta = (gainStrategy.find(
"FcalLowEta") != std::string::npos);
208 m_isFcalHighEta = (gainStrategy.find(
"FcalHighEta") != std::string::npos);
209 }
else if (gainStrategy ==
"") {
232 <<
": old=" <<
m_nTTs <<
", new=" << tts->
size());
234 unsigned int nmiss = 0;
235 for(
auto* tt: *tts) {
255 for(
auto *tt : *tts) {
257 if(tt->isJepSaturated())
continue;
260 auto max = std::max_element(tt->adc().begin(), tt->adc().end());
264 if(
m_ttTool->disabledChannel(ctx, tt->coolId()))
continue;
277 if(specialChannelIt == specialChannelRangeEnd || level1Energy < specialChannelIt->second) {
278 ATH_MSG_DEBUG(
"Adding Energy for " << tt->coolId() <<
":" << caloEnergy <<
" vs. " << level1Energy);
282 specialChannelIt->second = -1000;
290 return StatusCode::SUCCESS;
297 for(
auto* tt: *tts) {
309 auto id =
m_ttTool->identifier(tt->eta(), tt->phi(), tt->sampling());
312 if(tt->sampling() == 0) {
317 std::vector<float> etRec =
m_jmTools->hadTTCellsEtByReceiver(&T);
318 if (etRec.size() == 2) {
321 else et = etRec[0] + etRec[1];
322 }
else if (etRec.size() == 1)
et = etRec[0];
328 std::vector<float> energyRec =
m_jmTools->emTTCellsEnergyByReceiver(&T);
329 if (energyRec.size() == 2) {
332 else energy = energyRec[1];
333 et = energy / std::cosh(tt->eta());
334 }
else et = energyRec[0] / std::cosh(tt->eta());
336 et = ttCellsEnergy(*tt) / std::cosh(tt->eta());
346 auto max = std::max_element(tt->adc().begin(), tt->adc().end());
348 if(!pprChanCalib->pprChanCalib(tt->coolId())) {
350 << std::hex << tt->coolId() << std::dec <<
"!");
354 double energy = (*
max - int( pprChanCalib->pprChanCalib(tt->coolId())->pedValue())) * 0.25;
355 ATH_MSG_DEBUG(
"PedValue " << tt->coolId() <<
":" <<
int( pprChanCalib->pprChanCalib(tt->coolId())->pedValue()) );
358 if (energy < 0.) energy = 0.;
364 auto id =
m_ttTool->identifier(tt->eta(), tt->phi(), tt->sampling());
366 energy /= std::cosh(tt->eta());
367 if(fabs(tt->eta()) > 2.5) {
369 }
else if(fabs(tt->eta()) > 1.9) {
375 energy /= std::cosh(tt->eta());
384 const std::vector<const CaloCell*>& cells(
m_xAODTTTools->getCaloCells(*tt));
385 double oneOverNCells = 1./double(cells.size());
386 for(
const auto *cell : cells) {
389 m_mapBadOFCIteration.insert(std::make_pair(tt->coolId(), std::make_pair(!(cell->provenance() & 0x100),
390 (cell->time()*oneOverNCells))));
393 if(!(cell->provenance() & 0x100)) {
394 it->second.first += 1;
396 it->second.second += (cell->time()*oneOverNCells);
409 std::ofstream bad_ofciter(
"bad-ofciter.txt");
411 for(;it != itE; ++it) {
412 bad_ofciter <<
"0x" << std::hex << it->first <<
" "
413 << std::dec << double(it->second.first) / double(
m_nEvent)
414 <<
" " << it->second.second / double(
m_nEvent) << std::endl;
419 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
Helpers for checking error return status codes and reporting errors.
#define CHECK(...)
Evaluate an expression and check for errors.
float et(const xAOD::jFexSRJetRoI *j)
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
ServiceHandle< StoreGateSvc > & evtStore()
const ServiceHandle< StoreGateSvc > & detStore() const
Container class for CaloCell.
This class initializes the Calo (LAr and Tile) offline identifiers.
const CaloLVL1_ID * getLVL1_ID(void) const
This class is a collection of AttributeLists where each one is associated with a channel number.
const_iterator end() const
const_iterator begin() const
Access to Chan/AttributeList pairs via iterators.
ChanAttrListMap::const_iterator const_iterator
size_type size() const noexcept
Returns the number of elements in the collection.
Container of L1CaloRampData objects.
Transient class to store the RampData calculated from calibration runs.
ToolHandle< LVL1::IL1CaloxAODOfflineTriggerTowerTools > m_xAODTTTools
const CaloLVL1_ID * m_lvl1Helper
double getCaloEnergy(const xAOD::TriggerTower *tt)
std::string m_gainStrategyFolder
ToolHandle< LVL1::IL1CaloOfflineTriggerTowerTools > m_jmTools
std::string m_triggerTowerContainerName
std::map< unsigned int, std::pair< unsigned int, double > > m_mapBadOFCIteration
std::unique_ptr< L1CaloRampDataContainer > m_rampDataContainer
SG::ReadCondHandleKey< CondAttrListCollection > m_strategy
double m_tileSaturationCut
bool validTower(const bool &isTile)
SG::ReadHandleKey< CaloCellContainer > m_caloCellsKey
L1CaloRampMaker(const std::string &name, ISvcLocator *pSvcLocator)
unsigned int m_nEventsPerStep
std::string m_outputFolderName
void setupRampDataContainer(const xAOD::TriggerTowerContainer *triggerTowerContainer)
double getTriggerTowerEnergy(const xAOD::TriggerTower *tt, SG::ReadCondHandle< L1CaloPprChanCalibContainer > pprCond)
void checkProvenance(const xAOD::TriggerTower *tt)
StatusCode execute(const EventContext &ctx)
Execute method.
ToolHandle< LVL1::IL1TriggerTowerToolRun3 > m_ttTool
virtual ~L1CaloRampMaker()
SG::ReadCondHandleKey< L1CaloPprChanCalibContainer > m_pprChanCalibContainer
SG::ReadCondHandleKey< L1CaloPprDisabledChannelContainerRun2 > m_pprDisabledChannelContainer
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
std::map< int, int > m_specialChannelRange
The TriggerTowerKey object provides the key for each trigger tower depending on its eta-phi coords.
virtual unsigned int ttKey(const TriggerTower &tower)
returns the key of the passed tower
Trigger towers are the inputs to all other parts of the calorimeter trigger.
uint32_t runNumber() const
The current event's run number.
uint64_t eventNumber() const
The current event's event number.
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
EventInfo_v1 EventInfo
Definition of the latest event info version.
TriggerTowerContainer_v2 TriggerTowerContainer
Define the latest version of the TriggerTower container.
TriggerTower_v2 TriggerTower
Define the latest version of the TriggerTower class.
Extra patterns decribing particle interation process.