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;
147 const EventContext& ctx = getContext();
151 const unsigned evt=ctx.eventID().event_number();
152 ATH_MSG_DEBUG(
"Event " << evt <<
" contains " << cells->size() <<
" CaloCells" );
167 unsigned int runNumber = eventInfo->
runNumber();
168 std::string gainStrategy(
"");
174 bool consistent(
true);
175 for (; itr != itrE; ++itr) {
176 const unsigned int channel = itr->first;
177 if (channel != 1 && channel != 2)
continue;
178 const coral::AttributeList& attrList = itr->second;
182 <<
", name = " << strategy
183 <<
", status = " << status );
184 if (gainStrategy.empty()) gainStrategy = std::move(strategy);
185 else if (gainStrategy != strategy) consistent =
false;
187 std::string newStrategy(
"");
188 if (runNumber == 219978) newStrategy =
"GainOneOvEmecFcalLowEta";
189 if (runNumber == 219979) newStrategy =
"GainOneOvEmbFcalHighEta";
190 if (runNumber == 219980) newStrategy =
"CalibGainsEt";
191 if (runNumber == 220013) newStrategy =
"GainOneOvEmecFcalLowEta";
192 if (runNumber == 220014) newStrategy =
"GainOneOvEmbFcalHighEta";
193 if (runNumber == 220015) newStrategy =
"CalibGainsEt";
194 if (runNumber == 222871) newStrategy =
"GainOne";
195 if (runNumber == 222872) newStrategy =
"GainOne";
196 if (runNumber == 222873) newStrategy =
"GainOne";
197 if (runNumber == 223073) newStrategy =
"GainOne";
198 if (runNumber == 223074) newStrategy =
"GainOne";
199 if (runNumber == 223075) newStrategy =
"GainOne";
200 if (not newStrategy.empty()) {
201 ATH_MSG_INFO(
"Changing Gain Strategy to " << newStrategy);
202 gainStrategy = std::move(newStrategy);
204 if (!gainStrategy.empty() && consistent) {
205 m_isGain1 = (gainStrategy.find(
"GainOne") != std::string::npos);
206 m_isOvEmb = (gainStrategy.find(
"OvEmb") != std::string::npos);
207 m_isOvEmec = (gainStrategy.find(
"OvEmec") != std::string::npos);
208 m_isFcalLowEta = (gainStrategy.find(
"FcalLowEta") != std::string::npos);
209 m_isFcalHighEta = (gainStrategy.find(
"FcalHighEta") != std::string::npos);
210 }
else if (gainStrategy ==
"") {
233 <<
": old=" <<
m_nTTs <<
", new=" << tts->
size());
235 unsigned int nmiss = 0;
236 for(
auto* tt: *tts) {
256 for(
auto *tt : *tts) {
258 if(tt->isJepSaturated())
continue;
261 auto max = std::max_element(tt->adc().begin(), tt->adc().end());
265 if(
m_ttTool->disabledChannel(tt->coolId()))
continue;
278 if(specialChannelIt == specialChannelRangeEnd || level1Energy < specialChannelIt->second) {
279 ATH_MSG_DEBUG(
"Adding Energy for " << tt->coolId() <<
":" << caloEnergy <<
" vs. " << level1Energy);
283 specialChannelIt->second = -1000;
291 return StatusCode::SUCCESS;
298 for(
auto* tt: *tts) {
310 auto id =
m_ttTool->identifier(tt->eta(), tt->phi(), tt->sampling());
313 if(tt->sampling() == 0) {
318 std::vector<float> etRec =
m_jmTools->hadTTCellsEtByReceiver(&T);
319 if (etRec.size() == 2) {
322 else et = etRec[0] + etRec[1];
323 }
else if (etRec.size() == 1)
et = etRec[0];
329 std::vector<float> energyRec =
m_jmTools->emTTCellsEnergyByReceiver(&T);
330 if (energyRec.size() == 2) {
333 else energy = energyRec[1];
334 et = energy / std::cosh(tt->eta());
335 }
else et = energyRec[0] / std::cosh(tt->eta());
337 et = ttCellsEnergy(*tt) / std::cosh(tt->eta());
347 auto max = std::max_element(tt->adc().begin(), tt->adc().end());
349 if(!pprChanCalib->pprChanCalib(tt->coolId())) {
351 << std::hex << tt->coolId() << std::dec <<
"!");
355 double energy = (*
max - int( pprChanCalib->pprChanCalib(tt->coolId())->pedValue())) * 0.25;
356 ATH_MSG_DEBUG(
"PedValue " << tt->coolId() <<
":" <<
int( pprChanCalib->pprChanCalib(tt->coolId())->pedValue()) );
359 if (energy < 0.) energy = 0.;
365 auto id =
m_ttTool->identifier(tt->eta(), tt->phi(), tt->sampling());
367 energy /= std::cosh(tt->eta());
368 if(fabs(tt->eta()) > 2.5) {
370 }
else if(fabs(tt->eta()) > 1.9) {
376 energy /= std::cosh(tt->eta());
385 const std::vector<const CaloCell*>& cells(
m_xAODTTTools->getCaloCells(*tt));
386 double oneOverNCells = 1./double(cells.size());
387 for(
const auto *cell : cells) {
390 m_mapBadOFCIteration.insert(std::make_pair(tt->coolId(), std::make_pair(!(cell->provenance() & 0x100),
391 (cell->time()*oneOverNCells))));
394 if(!(cell->provenance() & 0x100)) {
395 it->second.first += 1;
397 it->second.second += (cell->time()*oneOverNCells);
410 std::ofstream bad_ofciter(
"bad-ofciter.txt");
412 for(;it != itE; ++it) {
413 bad_ofciter <<
"0x" << std::hex << it->first <<
" "
414 << std::dec << double(it->second.first) / double(
m_nEvent)
415 <<
" " << it->second.second / double(
m_nEvent) << std::endl;
420 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.
char data[hepevt_bytes_allocation_ATLAS]
float et(const xAOD::jFexSRJetRoI *j)
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
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)
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.
SG::ConstAccessor< T, ALLOC > ConstAccessor
Helper class to provide type-safe access to aux data.
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.