114{
115 ATH_MSG_DEBUG(
"Initial clusterize size: "<<stepinfo->
size()<<
" - will merge steps in the same cell which are less than dR and dT to each other");
116 double total_energy1(0.);
117 for (const auto step: *stepinfo) {
118 total_energy1+=
step->energy();
119 }
120 ATH_MSG_DEBUG(
"Check: total energy before clusterize "<<total_energy1);
121
122 SG::ReadCondHandle<CaloDetDescrManager> caloMgrHandle{
m_caloMgrKey,Gaudi::Hive::currentContext()};
124 const CaloDetDescrManager* calo_dd_man = *caloMgrHandle;
125
126
127 std::map<Identifier, ISF_FCS_Parametrization::FCS_StepInfoCollection*> FCS_SIC_cells;
128 for (const auto step: *stepinfo) {
129 if (FCS_SIC_cells.find(
step->identify()) != FCS_SIC_cells.end()) {
130 auto&& stepCopy = std::make_unique<ISF_FCS_Parametrization::FCS_StepInfo>(*step);
131 FCS_SIC_cells[
step->identify()]->push_back( stepCopy.release() );
132 }
133 else {
134 auto && new_fcs_sic = std::make_unique<ISF_FCS_Parametrization::FCS_StepInfoCollection>();
135 auto&& stepCopy = std::make_unique<ISF_FCS_Parametrization::FCS_StepInfo>(*step);
136 new_fcs_sic->push_back( stepCopy.release() );
137 FCS_SIC_cells.insert(std::pair<Identifier, ISF_FCS_Parametrization::FCS_StepInfoCollection*>(
step->identify(),new_fcs_sic.release()));
138 }
139 }
140
141 ATH_MSG_DEBUG(
"Merging separately in each cell: Ncells: "<<FCS_SIC_cells.size());
142
143 for (std::map<Identifier, ISF_FCS_Parametrization::FCS_StepInfoCollection*>::iterator it = FCS_SIC_cells.begin(); it!= FCS_SIC_cells.end(); ++it) {
144 std::stable_sort(FCS_SIC_cells[
it->first]->begin(), FCS_SIC_cells[
it->first]->end(), SortByE());
146
148 continue;
149 }
150 else if ((
it->second)->size()==1) {
151 continue;
152 }
153
155 double dsame(0.);
156 double tsame(0.);
157 if (layer >= CaloCell_ID::PreSamplerB && layer <= CaloCell_ID::EME3) {
160 }
161 else if (layer >= CaloCell_ID::HEC0 && layer <= CaloCell_ID::HEC3) {
164 }
165 else if (layer >= CaloCell_ID::TileBar0 && layer <= CaloCell_ID::TileExt2) {
168 }
169 else if (layer >=CaloCell_ID::FCAL0 && layer <= CaloCell_ID::FCAL2) {
172 }
173 else {
176 }
178 while ( it1 != (
it->second)->end() ) {
180 while (it2 != (
it->second)->end()) {
181 if (((*it1)->diff2(**it2) < dsame) && std::fabs((*it1)->time() - (*it2)->time()) < tsame ) {
182 **it1 += **it2;
183 it2 = (
it->second)->
erase(it2);
184 continue;
185 }
186 ++it2;
187 }
188 ++it1;
189 }
190 }
191
193 stepinfo->clear();
194 for (std::map<Identifier, ISF_FCS_Parametrization::FCS_StepInfoCollection*>::iterator it = FCS_SIC_cells.begin(); it!= FCS_SIC_cells.end(); ++it) {
195 for (
const auto step: *(
it->second)) {
196 auto&& stepCopy = std::make_unique<ISF_FCS_Parametrization::FCS_StepInfo>(*step);
197 stepinfo->push_back( stepCopy.release() );
198 }
199
202 }
203 double total_energy2(0.);
204 for (const auto step: *stepinfo) {
205 total_energy2+=
step->energy();
206 }
209 unsigned int nInvalid(0);
210
212 while(stepIter != stepinfo->end()) {
213 if ((*stepIter)->valid()) {
214 ++stepIter;
215 continue;
216 }
217 ++nInvalid;
218 stepIter = stepinfo->erase(stepIter);
219 }
220 ATH_MSG_DEBUG(
"Removed "<<nInvalid<<
" StepInfo objects. New collection size: "<<stepinfo->size());
221 return StatusCode::SUCCESS;
222}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
CaloSampling::CaloSample CaloSample
CaloCell_ID::CaloSample getSampling() const
cell sampling
const CaloDetDescrElement * get_element(const Identifier &cellId) const
get element by its identifier
DataModel_detail::iterator< DataVector > iterator
size_type size() const noexcept
Returns the number of elements in the collection.
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
virtual void erase() override final
Free all allocated elements and release memory back to the system.
void stable_sort(DataModel_detail::iterator< DVL > beg, DataModel_detail::iterator< DVL > end)
Specialization of stable_sort for DataVector/List.