|
ATLAS Offline Software
|
Go to the documentation of this file.
31 std::size_t getIndex(
const std::vector<float> &
bins,
float value)
37 if (itr ==
bins.begin() || itr ==
bins.end())
53 float start = integrals.begin()->first;
54 float end = integrals.rbegin()->first;
55 std::uniform_real_distribution<float> distr(
start,
end);
57 auto itr = integrals.lower_bound(
r);
58 if (itr == integrals.end() || itr == integrals.begin())
63 float lowBinEdge, lowBinValue, highBinEdge, highBinValue;
64 std::tie(highBinEdge, highBinValue) = *itr;
65 std::tie(lowBinEdge, lowBinValue) = *(--itr);
67 float pctDiff = (
r - lowBinEdge) / (highBinEdge - lowBinEdge);
68 return lowBinValue + pctDiff * (highBinValue - lowBinValue);
103 if (!timingFile || timingFile->IsZombie())
106 return StatusCode::FAILURE;
108 TDirectory *tdir = timingFile->GetDirectory(
"CellTiming");
112 return StatusCode::FAILURE;
116 std::regex pattern(
"Layer(\\d+)_([\\d.]+)eta([\\d.]+)_([\\d.-]+)ET([\\d.-]+)_midtrain");
117 std::map<CaloSampling::CaloSample, std::set<std::pair<float, float>>>
etaBins;
118 std::map<CaloSampling::CaloSample, std::set<std::pair<float, float>>> etBins;
119 std::map<CaloSampling::CaloSample, std::map<std::pair<std::pair<float, float>, std::pair<float, float>>,
TH1F *>> tmpHistMap;
120 std::set<CaloSampling::CaloSample> samples;
121 for (TObject *
obj : *tdir->GetListOfKeys())
123 TKey *
key =
dynamic_cast<TKey *
>(
obj);
127 return StatusCode::FAILURE;
134 if (std::strcmp(
key->GetClassName(),
"TH1F") != 0)
136 ATH_MSG_ERROR(
"Object " <<
key->GetName() <<
" not histogram as expected!");
137 return StatusCode::FAILURE;
142 auto etaBin = std::make_pair(std::stof(
match.str(2)), std::stof(
match.str(3)));
143 auto etBin = std::make_pair(std::stof(
match.str(4)), std::stof(
match.str(5)));
146 etBins[
sample].insert(etBin);
158 for (; itr !=
end; ++itr)
164 return StatusCode::FAILURE;
169 itr = etBins[
sample].begin();
175 for (; itr !=
end; ++itr)
181 return StatusCode::FAILURE;
187 for (
const auto &
p : tmpHistMap[
sample])
192 auto mapKey = std::make_tuple(
sample, etaIndex, etIndex);
194 float cumulativeSum = 0;
195 TAxis *
axis =
p.second->GetXaxis();
196 integrals[cumulativeSum] =
axis->GetBinLowEdge(1);
199 cumulativeSum +=
p.second->GetBinContent(
idx);
200 integrals[cumulativeSum] =
axis->GetBinUpEdge(
idx);
204 return StatusCode::SUCCESS;
210 auto superCells = std::make_unique<CaloCellContainer>();
213 if (!
cells.isValid())
216 return StatusCode::FAILURE;
224 if (!handle.isValid())
227 return StatusCode::FAILURE;
229 caloBCIDAvg = handle.cptr();
237 return StatusCode::FAILURE;
239 caloNoiseSigmaDiff = handle.
cptr();
246 if (!evtInfo.isValid())
249 return StatusCode::FAILURE;
253 generator.seed(evtInfo->eventNumber() * evtInfo->runNumber());
262 std::vector<float> energies(nSuperCells, 0.0);
263 std::vector<float> enTime(nSuperCells, 0.0);
264 std::vector<float> enForTime(nSuperCells, 0.0);
265 std::vector<char> timeDef(nSuperCells,
false);
266 std::vector<uint16_t> qualities(nSuperCells, 0);
267 std::vector<float> sigmaNoisePerSuperCell(nSuperCells, 0.0);
284 energies[scIDHash] +=
energy;
286 sigmaNoisePerSuperCell[scIDHash] += (*caloNoiseSigmaDiff)[cellIDHash];
290 bool isTile_BAD =
s >= 9 &&
s < 21;
291 if (
cell->provenance() & 0x2000)
293 if (
cell->energy() > 256)
296 timeDef[scIDHash] |=
true;
297 enForTime[scIDHash] +=
cell->energy();
298 enTime[scIDHash] +=
cell->energy() *
cell->time();
300 else if (!isTile_BAD)
307 if (
iEta == SIZE_MAX)
310 return StatusCode::FAILURE;
316 return StatusCode::FAILURE;
319 timeDef.at(scIDHash) |=
true;
320 enForTime.at(scIDHash) +=
cell->energy();
321 enTime.at(scIDHash) +=
cell->energy() * cellTime;
324 uint16_t &quality = qualities.at(scIDHash);
329 quality +=
cell->quality();
335 int side = tileCellID->
side(cellID);
337 int tower = tileCellID->
tower(cellID);
345 int tower2 = tower - 1;
353 else if (tower == 10)
368 for (std::size_t
idx = 0;
idx < energies.size(); ++
idx)
378 bool isTile_BAD =
s >= 9 &&
s < 21;
382 float sigmaNoise = sigmaNoisePerSuperCell.at(dde->
calo_hash());
383 if (!dde->
is_tile() && sigmaNoise > 0.0)
385 std::normal_distribution<double> distribution(0.0, sigmaNoise);
388 auto superCell = std::make_unique<CaloCell>();
389 superCell->setCaloDDE(dde);
390 superCell->setEnergy(
energy);
392 if (timeDef.at(
idx) && enForTime.at(
idx) != 0)
394 float time = enTime.at(
idx) / enForTime.at(
idx);
395 superCell->setTime(time);
396 float et = superCell->et();
398 if ((
et > 10
e3 && time > -8 && time < 18) || (
et <= 10
e3 && std::abs(time) < 8))
402 superCell->setTime(999.0);
403 superCell->setProvenance(prov);
405 superCells->push_back(superCell.release());
408 ATH_CHECK(superCellHandle.record(std::move(superCells)));
409 return StatusCode::SUCCESS;
def retrieve(aClass, aKey=None)
static std::string find_calib_file(const std::string &logical_file_name)
std::vector< float > CaloNoiseSigmaDiff
NAME : CaloNoiseSigmaDiff.h PACKAGE : Calorimeter/CaloConditions.
Extra patterns decribing particle interation process.
IdentifierHash calo_cell_hash(const Identifier cellId) const
create hash id from 'global' cell id
std::map< CaloSampling::CaloSample, std::vector< float > > m_etBins
Et binning read from timing file.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
ToolHandle< ICaloSuperCellIDTool > m_scidTool
Offline<->supercell mapping tool.
This class groups all DetDescr information related to a CaloCell. Provides a generic interface for al...
const CaloDetDescrElement * get_element(const Identifier &cellId) const
get element by its identifier
int side(const Identifier &id) const
std::map< std::tuple< CaloSampling::CaloSample, std::size_t, std::size_t >, std::map< float, float > > m_timingSamples
Timing distributions.
Helper class for Tile offline identifiers for supercells.
int tower(const Identifier &id) const
const Tile_SuperCell_ID * getTile_SuperCell_ID(void) const
const std::string & key() const
Return the StoreGate ID for the referenced object.
SG::ReadCondHandleKey< CaloNoiseSigmaDiff > m_caloNoiseSigmaDiffKey
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
std::size_t getEtIndex(CaloSampling::CaloSample sample, float et) const
bool is_valid() const
Check if id is in a valid state.
std::size_t getEtaIndex(CaloSampling::CaloSample sample, float eta) const
std::string m_cellTimingFile
The cell timing file.
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
An algorithm that can be simultaneously executed in multiple threads.
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Handle class for recording to StoreGate.
const TileID * getTileID(void) const
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setInterceptInner setEtaMap etaBin
virtual StatusCode initialize() override
IdentifierHash calo_hash() const
cell calo hash
int module(const Identifier &id) const
Helper class for offline supercell identifiers.
Helper class for TileCal offline identifiers.
::StatusCode StatusCode
StatusCode definition for legacy code.
bool m_useNoise
Use noise values.
Helper class for offline supercell identifiers.
int sampling(const Identifier &id) const
Helper class for offline cell identifiers.
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
def getRandom(smk, lhcRun)
bool is_tile() const
cell belongs to Tile
SG::WriteHandleKey< CaloCellContainer > m_outputSuperCellsKey
virtual ~SCEmulation() override
const CaloCell_ID * getCaloCell_ID(void) const
Access to IdHelper.
StatusCode initialize(bool used=true)
SG::ReadHandleKey< CaloBCIDAverage > m_caloBCIDAverageKey
std::map< CaloSampling::CaloSample, std::vector< float > > m_etaBins
eta binning read from timing file
SG::ReadHandleKey< CaloCellContainer > m_inputCellsKey
float average(const Identifier &id) const
SCEmulation(const std::string &name, ISvcLocator *pSvcLocator)
generator
Configure Herwig7 These are the commands corresponding to what would go into the regular Herwig infil...
virtual StatusCode execute(const EventContext &ctx) const override
Data object for each calorimeter readout cell.
CaloCell_ID::CaloSample getSampling() const
cell sampling
#define ATH_MSG_WARNING(x)
const CaloCell_SuperCell_ID * getCaloCell_SuperCell_ID(void) const
SG::ReadHandleKey< xAOD::EventInfo > m_evtInfoKey
def TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)
int section(const Identifier &id) const
Handle class for reading from StoreGate.
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
bool m_useBCID
Compensate for BCIDs.
Identifier cell_id(const Identifier &any_id) const
setScale setgFexType iEta
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space
const CaloIdManager * m_caloIdMgr
Calo ID helpers.
SG::ReadCondHandleKey< CaloSuperCellDetDescrManager > m_caloSuperCellMgrKey
Super cell manager key.
bool match(std::string s1, std::string s2)
match the individual directories of two strings
size_type calo_cell_hash_max(void) const
cell 'global' hash table max size
const_pointer_type cptr()