200 std::map<DetId, EcalRecHit> recHitsEB_map;
202 std::vector<EcalRecHit> seeds;
206 vector<EBDetId> usedXtals;
211 static const int MAXCLUS = 2000;
214 vector<float> etClus;
215 vector<float> etaClus;
216 vector<float> phiClus;
217 vector<EBDetId> max_hit;
218 vector< vector<EcalRecHit> > RecHitsCluster;
219 vector<float> s4s9Clus;
222 for(itb=rhEB->begin(); itb!=rhEB->end(); ++itb){
224 double energy = itb->energy();
226 std::pair<DetId, EcalRecHit> map_entry(itb->id(), *itb);
227 recHitsEB_map.insert(map_entry);
233 for (std::vector<EcalRecHit>::iterator itseed=seeds.begin(); itseed!=seeds.end(); itseed++) {
234 EBDetId seed_id = itseed->id();
235 std::vector<EBDetId>::const_iterator usedIds;
237 bool seedAlreadyUsed=
false;
238 for(usedIds=usedXtals.begin(); usedIds!=usedXtals.end(); usedIds++){
239 if(*usedIds==seed_id){
240 seedAlreadyUsed=
true;
245 if(seedAlreadyUsed)
continue;
249 std::vector<std::pair<DetId, float> > clus_used;
251 vector<EcalRecHit> RecHitsInWindow;
253 double simple_energy = 0;
255 for (std::vector<DetId>::iterator det=clus_v.begin(); det!=clus_v.end(); det++) {
258 bool HitAlreadyUsed=
false;
259 for(usedIds=usedXtals.begin(); usedIds!=usedXtals.end(); usedIds++){
265 if(HitAlreadyUsed)
continue;
266 if (recHitsEB_map.find(*det) != recHitsEB_map.end()){
268 std::map<DetId, EcalRecHit>::iterator aHit;
269 aHit = recHitsEB_map.find(*det);
270 usedXtals.push_back(*det);
271 RecHitsInWindow.push_back(aHit->second);
272 clus_used.push_back( std::pair<DetId, float>(*det, 1.) );
273 simple_energy = simple_energy + aHit->second.energy();
277 math::XYZPoint clus_pos = posCalculator_.Calculate_Location(clus_used,hitCollection_p,geometry_p,geometryES_p);
278 float theta_s = 2. * atan(
exp(-clus_pos.eta()));
279 float p0x_s = simple_energy *
sin(theta_s) *
cos(clus_pos.phi());
280 float p0y_s = simple_energy *
sin(theta_s) *
sin(clus_pos.phi());
282 float et_s =
sqrt( p0x_s*p0x_s + p0y_s*p0y_s);
286 eClus.push_back(simple_energy);
287 etClus.push_back(et_s);
288 etaClus.push_back(clus_pos.eta());
289 phiClus.push_back(clus_pos.phi());
290 max_hit.push_back(seed_id);
291 RecHitsCluster.push_back(RecHitsInWindow);
295 for(
int i=0;
i<4;
i++)s4s9_[
i]= itseed->energy();
296 for(
unsigned int j=0;
j<RecHitsInWindow.size();
j++){
298 if((((
EBDetId)RecHitsInWindow[
j].
id()).ieta() == seed_id.
ieta()-1 && seed_id.
ieta()!=1 ) || ( seed_id.
ieta()==1 && (((
EBDetId)RecHitsInWindow[
j].
id()).ieta() == seed_id.
ieta()-2))){
299 if(((
EBDetId)RecHitsInWindow[
j].id()).iphi() == seed_id.
iphi()-1 ||((
EBDetId)RecHitsInWindow[
j].
id()).iphi()-360 == seed_id.
iphi()-1 ){
300 s4s9_[0]+=RecHitsInWindow[
j].energy();
302 if(((
EBDetId)RecHitsInWindow[
j].
id()).iphi() == seed_id.
iphi()){
303 s4s9_[0]+=RecHitsInWindow[
j].energy();
304 s4s9_[1]+=RecHitsInWindow[
j].energy();
306 if(((
EBDetId)RecHitsInWindow[
j].
id()).iphi() == seed_id.
iphi()+1 ||((
EBDetId)RecHitsInWindow[
j].
id()).iphi()-360 == seed_id.
iphi()+1 ){
307 s4s9_[1]+=RecHitsInWindow[
j].energy();
312 if(((
EBDetId)RecHitsInWindow[
j].
id()).ieta() == seed_id.
ieta()){
313 if(((
EBDetId)RecHitsInWindow[
j].
id()).iphi() == seed_id.
iphi()-1 ||((
EBDetId)RecHitsInWindow[
j].
id()).iphi()-360 == seed_id.
iphi()-1 ){
314 s4s9_[0]+=RecHitsInWindow[
j].energy();
315 s4s9_[3]+=RecHitsInWindow[
j].energy();
317 if(((
EBDetId)RecHitsInWindow[
j].
id()).iphi() == seed_id.
iphi()+1 ||((
EBDetId)RecHitsInWindow[
j].
id()).iphi()-360 == seed_id.
iphi()+1 ){
318 s4s9_[1]+=RecHitsInWindow[
j].energy();
319 s4s9_[2]+=RecHitsInWindow[
j].energy();
323 if((((
EBDetId)RecHitsInWindow[
j].
id()).ieta() == seed_id.
ieta()+1 && seed_id.
ieta()!=-1 ) || ( seed_id.
ieta()==-1 && (((
EBDetId)RecHitsInWindow[
j].
id()).ieta() == seed_id.
ieta()+2))){
324 if(((
EBDetId)RecHitsInWindow[
j].id()).iphi() == seed_id.
iphi()-1 ||((
EBDetId)RecHitsInWindow[
j].
id()).iphi()-360 == seed_id.
iphi()-1 ){
325 s4s9_[3]+=RecHitsInWindow[
j].energy();
327 if(((
EBDetId)RecHitsInWindow[
j].
id()).iphi() == seed_id.
iphi()){
328 s4s9_[2]+=RecHitsInWindow[
j].energy();
329 s4s9_[3]+=RecHitsInWindow[
j].energy();
331 if(((
EBDetId)RecHitsInWindow[
j].
id()).iphi() == seed_id.
iphi()+1 ||((
EBDetId)RecHitsInWindow[
j].
id()).iphi()-360 == seed_id.
iphi()+1 ){
332 s4s9_[2]+=RecHitsInWindow[
j].energy();
337 cout<<
" (EBDetId)RecHitsInWindow[j].id()).ieta() "<<((
EBDetId)RecHitsInWindow[
j].
id()).ieta()<<
" seed_id.ieta() "<<seed_id.
ieta()<<endl;
338 cout<<
" Problem with S4 calculation "<<endl;
return;
343 s4s9Clus.push_back(*max_element( s4s9_,s4s9_+4)/simple_energy);
347 if (nClus == MAXCLUS)
return;
354 static const int MAXPI0S = 200;
357 vector<EBDetId> scXtals;
360 if (nClus <= 1)
return;
361 for(Int_t
i=0 ;
i<nClus ;
i++){
362 for(Int_t
j=
i+1 ;
j<nClus ;
j++){
365 float theta_0 = 2. * atan(
exp(-etaClus[
i]));
366 float theta_1 = 2. * atan(
exp(-etaClus[
j]));
368 float p0x = eClus[
i] *
sin(theta_0) *
cos(phiClus[
i]);
369 float p1x = eClus[
j] *
sin(theta_1) *
cos(phiClus[
j]);
370 float p0y = eClus[
i] *
sin(theta_0) *
sin(phiClus[
i]);
371 float p1y = eClus[
j] *
sin(theta_1) *
sin(phiClus[
j]);
372 float p0z = eClus[
i] *
cos(theta_0);
373 float p1z = eClus[
j] *
cos(theta_1);
375 float pt_pi0 =
sqrt( (p0x+p1x)*(p0x+p1x) + (p0y+p1y)*(p0y+p1y));
378 float m_inv =
sqrt ( (eClus[
i] + eClus[
j])*(eClus[
i] + eClus[j]) - (p0x+p1x)*(p0x+p1x) - (p0y+p1y)*(p0y+p1y) - (p0z+p1z)*(p0z+p1z) );
385 TVector3 pi0vect = TVector3((p0x+p1x), (p0y+p1y), (p0z+p1z));
386 for(Int_t
k=0 ;
k<nClus ;
k++){
387 if(
k==
i ||
k==j)
continue;
388 TVector3 Clusvect = TVector3(eClus[
k] *
sin(2. * atan(
exp(-etaClus[
k]))) *
cos(phiClus[k]), eClus[k] *
sin(2. * atan(
exp(-etaClus[k]))) *
sin(phiClus[k]) , eClus[k] *
cos(2. * atan(
exp(-etaClus[k]))));
389 float dretaclpi0 = fabs(etaClus[k] - pi0vect.Eta());
390 float drclpi0 = Clusvect.DeltaR(pi0vect);
394 Iso = Iso + etClus[
k];
395 IsoClus.push_back(k);
412 if(npi0_s == MAXPI0S)
return;
T getParameter(std::string const &) const
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
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
MonitorElement * hPt2Pi0EB_
MonitorElement * hPt1Pi0EB_
double seleXtalMinEnergy_
edm::ParameterSet parameters_