129 std::map<DetId, EcalRecHit> recHitsEB_map;
131 std::vector<EcalRecHit> seeds;
135 vector<EBDetId> usedXtals;
140 static const int MAXCLUS = 2000;
143 vector<float> etClus;
144 vector<float> etaClus;
145 vector<float> phiClus;
146 vector<EBDetId> max_hit;
147 vector<vector<EcalRecHit> > RecHitsCluster;
148 vector<float> s4s9Clus;
151 for (itb = rhEB->begin(); itb != rhEB->end(); ++itb) {
153 double energy = itb->energy();
155 std::pair<DetId, EcalRecHit> map_entry(itb->id(), *itb);
156 recHitsEB_map.insert(map_entry);
159 seeds.push_back(*itb);
162 sort(seeds.begin(), seeds.end(), [](
auto&
x,
auto&
y) {
return (
x.energy() >
y.energy()); });
163 for (std::vector<EcalRecHit>::iterator itseed = seeds.begin(); itseed != seeds.end(); itseed++) {
164 EBDetId seed_id = itseed->id();
165 std::vector<EBDetId>::const_iterator usedIds;
167 bool seedAlreadyUsed =
false;
168 for (usedIds = usedXtals.begin(); usedIds != usedXtals.end(); usedIds++) {
169 if (*usedIds == seed_id) {
170 seedAlreadyUsed =
true;
180 std::vector<std::pair<DetId, float> > clus_used;
182 vector<EcalRecHit> RecHitsInWindow;
184 double simple_energy = 0;
186 for (std::vector<DetId>::iterator det = clus_v.begin(); det != clus_v.end(); det++) {
189 bool HitAlreadyUsed =
false;
190 for (usedIds = usedXtals.begin(); usedIds != usedXtals.end(); usedIds++) {
191 if (*usedIds == *det) {
192 HitAlreadyUsed =
true;
198 if (recHitsEB_map.find(*det) != recHitsEB_map.end()) {
200 std::map<DetId, EcalRecHit>::iterator aHit;
201 aHit = recHitsEB_map.find(*det);
202 usedXtals.push_back(*det);
203 RecHitsInWindow.push_back(aHit->second);
204 clus_used.push_back(std::pair<DetId, float>(*det, 1.));
205 simple_energy = simple_energy + aHit->second.energy();
210 float theta_s = 2. * atan(
exp(-clus_pos.eta()));
211 float p0x_s = simple_energy *
sin(theta_s) *
cos(clus_pos.phi());
212 float p0y_s = simple_energy *
sin(theta_s) *
sin(clus_pos.phi());
214 float et_s =
sqrt(p0x_s * p0x_s + p0y_s * p0y_s);
218 eClus.push_back(simple_energy);
219 etClus.push_back(et_s);
220 etaClus.push_back(clus_pos.eta());
221 phiClus.push_back(clus_pos.phi());
222 max_hit.push_back(seed_id);
223 RecHitsCluster.push_back(RecHitsInWindow);
227 for (
int i = 0;
i < 4;
i++)
228 s4s9_[
i] = itseed->energy();
229 for (
unsigned int j = 0;
j < RecHitsInWindow.size();
j++) {
235 s4s9_[0] += RecHitsInWindow[
j].energy();
238 s4s9_[0] += RecHitsInWindow[
j].energy();
239 s4s9_[1] += RecHitsInWindow[
j].energy();
243 s4s9_[1] += RecHitsInWindow[
j].energy();
249 if (((
EBDetId)RecHitsInWindow[
j].
id()).iphi() == seed_id.
iphi() - 1 ||
251 s4s9_[0] += RecHitsInWindow[
j].energy();
252 s4s9_[3] += RecHitsInWindow[
j].energy();
256 s4s9_[1] += RecHitsInWindow[
j].energy();
257 s4s9_[2] += RecHitsInWindow[
j].energy();
261 if ((((
EBDetId)RecHitsInWindow[
j].
id()).
ieta() == seed_id.
ieta() + 1 && seed_id.
ieta() != -1) ||
265 s4s9_[3] += RecHitsInWindow[
j].energy();
268 s4s9_[2] += RecHitsInWindow[
j].energy();
269 s4s9_[3] += RecHitsInWindow[
j].energy();
273 s4s9_[2] += RecHitsInWindow[
j].energy();
278 cout <<
" (EBDetId)RecHitsInWindow[j].id()).ieta() " << ((
EBDetId)RecHitsInWindow[
j].
id()).
ieta()
279 <<
" seed_id.ieta() " << seed_id.
ieta() << endl;
280 cout <<
" Problem with S4 calculation " << endl;
286 s4s9Clus.push_back(*max_element(s4s9_, s4s9_ + 4) / simple_energy);
290 if (nClus == MAXCLUS)
298 static const int MAXPI0S = 200;
301 vector<EBDetId> scXtals;
306 for (Int_t
i = 0;
i < nClus;
i++) {
307 for (Int_t
j =
i + 1;
j < nClus;
j++) {
311 float theta_0 = 2. * atan(
exp(-etaClus[
i]));
312 float theta_1 = 2. * atan(
exp(-etaClus[
j]));
314 float p0x = eClus[
i] *
sin(theta_0) *
cos(phiClus[
i]);
315 float p1x = eClus[
j] *
sin(theta_1) *
cos(phiClus[
j]);
316 float p0y = eClus[
i] *
sin(theta_0) *
sin(phiClus[
i]);
317 float p1y = eClus[
j] *
sin(theta_1) *
sin(phiClus[
j]);
318 float p0z = eClus[
i] *
cos(theta_0);
319 float p1z = eClus[
j] *
cos(theta_1);
321 float pt_pi0 =
sqrt((p0x + p1x) * (p0x + p1x) + (p0y + p1y) * (p0y + p1y));
325 float m_inv =
sqrt((eClus[
i] + eClus[
j]) * (eClus[
i] + eClus[j]) - (p0x + p1x) * (p0x + p1x) -
326 (p0y + p1y) * (p0y + p1y) - (p0z + p1z) * (p0z + p1z));
332 TVector3 pi0vect = TVector3((p0x + p1x), (p0y + p1y), (p0z + p1z));
333 for (Int_t
k = 0;
k < nClus;
k++) {
334 if (
k ==
i ||
k == j)
336 TVector3 Clusvect = TVector3(eClus[
k] *
sin(2. * atan(
exp(-etaClus[
k]))) *
cos(phiClus[k]),
337 eClus[k] *
sin(2. * atan(
exp(-etaClus[k]))) *
sin(phiClus[k]),
338 eClus[k] *
cos(2. * atan(
exp(-etaClus[k]))));
339 float dretaclpi0 = fabs(etaClus[k] - pi0vect.Eta());
340 float drclpi0 = Clusvect.DeltaR(pi0vect);
343 Iso = Iso + etClus[
k];
344 IsoClus.push_back(k);
358 if (npi0_s == MAXPI0S)
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
double clusSeedThr_
parameters needed for pizero finding
MonitorElement * hIsoPi0EB_
Sin< T >::type sin(const T &t)
MonitorElement * hPtPi0EB_
MonitorElement * hMinvPi0EB_
std::vector< EcalRecHit >::const_iterator const_iterator
edm::ParameterSet posCalcParameters_
int iphi() const
get the crystal iphi
Cos< T >::type cos(const T &t)
int ieta() const
get the crystal ieta
virtual std::vector< DetId > getWindow(const DetId &id, const int &northSouthSize, const int &eastWestSize) const
XYZPointD XYZPoint
point in space with cartesian internal representation
const CaloSubdetectorTopology * getSubdetectorTopology(const DetId &id) const
access the subdetector Topology for the given subdetector directly
math::XYZPoint Calculate_Location(const HitsAndFractions &iDetIds, const edm::SortedCollection< HitType > *iRecHits, const CaloSubdetectorGeometry *iSubGeom, const CaloSubdetectorGeometry *iESGeom=0)
MonitorElement * hPt2Pi0EB_
MonitorElement * hPt1Pi0EB_
double seleXtalMinEnergy_