CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GoodSeedProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: PFTracking
4 // Class: GoodSeedProducer
5 //
6 // Original Author: Michele Pioppi
7 // March 2010. F. Beaudette. Produce PreId information
8 
9 
13 
29 #include <fstream>
30 #include <string>
31 #include "TMath.h"
32 #include "Math/VectorUtil.h"
33 
34 using namespace edm;
35 using namespace std;
36 using namespace reco;
39 
41  pfTransformer_(0),
42  conf_(iConfig)
43 {
44  LogInfo("GoodSeedProducer")<<"Electron PreIdentification started ";
45 
46  //now do what ever initialization is needed
47 
49  iConfig.getParameter< vector < InputTag > >("TkColList");
50 
51  minPt_=iConfig.getParameter<double>("MinPt");
52  maxPt_=iConfig.getParameter<double>("MaxPt");
53  maxEta_=iConfig.getParameter<double>("MaxEta");
54 
55 
56  //ISOLATION REQUEST AS DONE IN THE TAU GROUP
57  applyIsolation_ =iConfig.getParameter<bool>("ApplyIsolation");
58  HcalIsolWindow_ =iConfig.getParameter<double>("HcalWindow");
59  EcalStripSumE_minClusEnergy_ = iConfig.getParameter<double>("EcalStripSumE_minClusEnergy");
60  EcalStripSumE_deltaEta_ = iConfig.getParameter<double>("EcalStripSumE_deltaEta");
61  EcalStripSumE_deltaPhiOverQ_minValue_ = iConfig.getParameter<double>("EcalStripSumE_deltaPhiOverQ_minValue");
62  EcalStripSumE_deltaPhiOverQ_maxValue_ = iConfig.getParameter<double>("EcalStripSumE_deltaPhiOverQ_maxValue");
63  minEoverP_= iConfig.getParameter<double>("EOverPLead_minValue");
64  maxHoverP_= iConfig.getParameter<double>("HOverPLead_maxValue");
65 
66  //
68  iConfig.getParameter<InputTag>("PFEcalClusterLabel");
69 
71  iConfig.getParameter<InputTag>("PFHcalClusterLabel");
72 
74  iConfig.getParameter<InputTag>("PFPSClusterLabel");
75 
76  preidgsf_ = iConfig.getParameter<string>("PreGsfLabel");
77  preidckf_ = iConfig.getParameter<string>("PreCkfLabel");
78  preidname_= iConfig.getParameter<string>("PreIdLabel");
79 
80 
81  fitterName_ = iConfig.getParameter<string>("Fitter");
82  smootherName_ = iConfig.getParameter<string>("Smoother");
83 
84 
85  nHitsInSeed_=iConfig.getParameter<int>("NHitsInSeed");
86 
87  clusThreshold_=iConfig.getParameter<double>("ClusterThreshold");
88 
89  minEp_=iConfig.getParameter<double>("MinEOverP");
90  maxEp_=iConfig.getParameter<double>("MaxEOverP");
91 
92  //collection to produce
93  produceCkfseed_ = iConfig.getUntrackedParameter<bool>("ProduceCkfSeed",false);
94 
95  // to disable the electron part (for HI collisions for examples)
96  disablePreId_ = iConfig.getUntrackedParameter<bool>("DisablePreId",false);
97 
98  producePreId_ = iConfig.getUntrackedParameter<bool>("ProducePreId",true);
99  // if no electron, cannot produce the preid
100  if(disablePreId_)
101  producePreId_=false;
102  PtThresholdSavePredId_ = iConfig.getUntrackedParameter<double>("PtThresholdSavePreId",1.);
103 
104  LogDebug("GoodSeedProducer")<<"Seeds for GSF will be produced ";
105 
106  // no disablePreId_ switch here. The collection will be empty if it is true
107  produces<ElectronSeedCollection>(preidgsf_);
108 
109  if(produceCkfseed_){
110  LogDebug("GoodSeedProducer")<<"Seeds for CKF will be produced ";
111  produces<TrajectorySeedCollection>(preidckf_);
112  }
113 
114 
115  if(producePreId_){
116  LogDebug("GoodSeedProducer")<<"PreId debugging information will be produced ";
117 
118  produces<PreIdCollection>(preidname_);
119  if(tracksContainers_.size()==1) // do not make a value map if more than one input track collection
121  }
122 
123  useQuality_ = iConfig.getParameter<bool>("UseQuality");
124  trackQuality_=TrackBase::qualityByName(iConfig.getParameter<std::string>("TrackQuality"));
125 
126  useTmva_= iConfig.getUntrackedParameter<bool>("UseTMVA",false);
127 
128  usePreshower_ = iConfig.getParameter<bool>("UsePreShower");
129 
130 }
131 
132 
134 {
135 
136  // do anything here that needs to be done at desctruction time
137  // (e.g. close files, deallocate resources etc.)
138 
139  delete pfTransformer_;
140 }
141 
142 
143 //
144 // member functions
145 //
146 
147 // ------------ method called to produce the data ------------
148 void
150 {
151 
152  LogDebug("GoodSeedProducer")<<"START event: "<<iEvent.id().event()
153  <<" in run "<<iEvent.id().run();
154  //Create empty output collections
155  auto_ptr<ElectronSeedCollection> output_preid(new ElectronSeedCollection);
156  auto_ptr<TrajectorySeedCollection> output_nopre(new TrajectorySeedCollection);
157  auto_ptr<PreIdCollection> output_preidinfo(new PreIdCollection);
158  auto_ptr<edm::ValueMap<reco::PreIdRef> > preIdMap_p(new edm::ValueMap<reco::PreIdRef>);
159  edm::ValueMap<reco::PreIdRef>::Filler mapFiller(*preIdMap_p);
160 
161  //Tracking Tools
162  if(!disablePreId_)
163  {
166  }
167 
168  // clear temporary maps
169  refMap_.clear();
170 
171  //Handle input collections
172  //ECAL clusters
173  Handle<PFClusterCollection> theECPfClustCollection;
174  iEvent.getByLabel(pfCLusTagECLabel_,theECPfClustCollection);
175 
176  vector<PFCluster> basClus;
177  vector<PFCluster>::const_iterator iklus;
178  for (iklus=theECPfClustCollection.product()->begin();
179  iklus!=theECPfClustCollection.product()->end();
180  iklus++){
181  if((*iklus).energy()>clusThreshold_) basClus.push_back(*iklus);
182  }
183 
184  //HCAL clusters
185  Handle<PFClusterCollection> theHCPfClustCollection;
186  iEvent.getByLabel(pfCLusTagHCLabel_,theHCPfClustCollection);
187 
188  //PS clusters
189  Handle<PFClusterCollection> thePSPfClustCollection;
190  iEvent.getByLabel(pfCLusTagPSLabel_,thePSPfClustCollection);
191 
192  ps1Clus.clear();
193  ps2Clus.clear();
194 
195  for (iklus=thePSPfClustCollection.product()->begin();
196  iklus!=thePSPfClustCollection.product()->end();
197  iklus++){
198  //layer==-11 first layer of PS
199  //layer==-12 secon layer of PS
200  if ((*iklus).layer()==-11) ps1Clus.push_back(*iklus);
201  if ((*iklus).layer()==-12) ps2Clus.push_back(*iklus);
202  }
203 
204  //Vector of track collections
205  for (unsigned int istr=0; istr<tracksContainers_.size();istr++){
206 
207  //Track collection
208  Handle<TrackCollection> tkRefCollection;
209  iEvent.getByLabel(tracksContainers_[istr], tkRefCollection);
210  const TrackCollection& Tk=*(tkRefCollection.product());
211 
212  //Trajectory collection
213  Handle<vector<Trajectory> > tjCollection;
214  iEvent.getByLabel(tracksContainers_[istr], tjCollection);
215  vector<Trajectory> Tj=*(tjCollection.product());
216 
217 
218  LogDebug("GoodSeedProducer")<<"Number of tracks in collection "
219  <<tracksContainers_[istr] <<" to be analyzed "
220  <<Tj.size();
221 
222 
223  //loop over the track collection
224  for(unsigned int i=0;i<Tk.size();i++){
225  if (useQuality_ &&
226  (!(Tk[i].quality(trackQuality_)))) continue;
227 
228  reco::PreId myPreId;
229  bool GoodPreId=false;
230 
231  TrackRef trackRef(tkRefCollection, i);
232  // TrajectorySeed Seed=Tj[i].seed();
233  TrajectorySeed Seed=(*trackRef->seedRef());
234  if(!disablePreId_)
235  {
236  int ipteta=getBin(Tk[i].eta(),Tk[i].pt());
237  int ibin=ipteta*8;
238 
239  float PTOB=Tj[i].lastMeasurement().updatedState().globalMomentum().mag();
240  float chikfred=Tk[i].normalizedChi2();
241  int nhitpi=Tj[i].foundHits();
242  float EP=0;
243 
244  // set track info
245  myPreId.setTrack(trackRef);
246  //CLUSTERS - TRACK matching
247 
248  float pfmass= 0.0005;
249  float pfoutenergy=sqrt((pfmass*pfmass)+Tk[i].outerMomentum().Mag2());
250  XYZTLorentzVector mom =XYZTLorentzVector(Tk[i].outerMomentum().x(),
251  Tk[i].outerMomentum().y(),
252  Tk[i].outerMomentum().z(),
253  pfoutenergy);
254  XYZTLorentzVector pos = XYZTLorentzVector(Tk[i].outerPosition().x(),
255  Tk[i].outerPosition().y(),
256  Tk[i].outerPosition().z(),
257  0.);
258 
259  BaseParticlePropagator theOutParticle =
261  0,0,B_.z());
262  theOutParticle.setCharge(Tk[i].charge());
263 
264  theOutParticle.propagateToEcalEntrance(false);
265 
266 
267  float toteta=1000;
268  float totphi=1000;
269  float dr=1000;
270  float EE=0;
271  float feta=0;
272  math::XYZPointF ElecTrkEcalPos(0,0,0);
273  PFClusterRef clusterRef;
274  math::XYZPoint meanShowerSaved;
275  if(theOutParticle.getSuccess()!=0){
276  ElecTrkEcalPos=math::XYZPointF(theOutParticle.vertex().x(),
277  theOutParticle.vertex().y(),
278  theOutParticle.vertex().z());
279  bool isBelowPS=(fabs(theOutParticle.vertex().eta())>1.65) ? true :false;
280 
281  unsigned clusCounter=0;
282 
283  for(vector<PFCluster>::const_iterator aClus = basClus.begin();
284  aClus != basClus.end(); aClus++,++clusCounter) {
285 
286  double ecalShowerDepth
287  = PFCluster::getDepthCorrection(aClus->energy(),
288  isBelowPS,
289  false);
290 
291  math::XYZPoint meanShower=math::XYZPoint(theOutParticle.vertex())+
292  math::XYZTLorentzVector(theOutParticle.momentum()).Vect().Unit()*ecalShowerDepth;
293 
294  float etarec=meanShower.eta();
295  float phirec=meanShower.phi();
296  float tmp_ep=aClus->energy()/PTOB;
297  float tmp_phi=fabs(aClus->position().phi()-phirec);
298  if (tmp_phi>TMath::TwoPi()) tmp_phi-= TMath::TwoPi();
299  float tmp_dr=sqrt(pow(tmp_phi,2)+
300  pow((aClus->position().eta()-etarec),2));
301 
302  if ((tmp_dr<dr)&&(tmp_ep>minEp_)&&(tmp_ep<maxEp_)){
303  dr=tmp_dr;
304  toteta=aClus->position().eta()-etarec;
305  totphi=tmp_phi;
306  EP=tmp_ep;
307  EE=aClus->energy();
308  feta= aClus->position().eta();
309  clusterRef = PFClusterRef(theECPfClustCollection,clusCounter);
310  meanShowerSaved = meanShower;
311  }
312  }
313  }
314 
315  //Resolution maps
316  double ecaletares
317  = resMapEtaECAL_->GetBinContent(resMapEtaECAL_->FindBin(feta,EE));
318  double ecalphires
319  = resMapPhiECAL_->GetBinContent(resMapPhiECAL_->FindBin(feta,EE));
320 
321  //geomatrical compatibility
322  float chieta=(toteta!=1000)? toteta/ecaletares : toteta;
323  float chiphi=(totphi!=1000)? totphi/ecalphires : totphi;
324  float chichi= sqrt(chieta*chieta + chiphi*chiphi);
325 
326 
327  //Matching criteria
328  float chi2cut=thr[ibin+0];
329  float ep_cutmin=thr[ibin+1];
330  bool GoodMatching= ((chichi<chi2cut) &&(EP>ep_cutmin) && (nhitpi>10));
331  bool EcalMatching=GoodMatching;
332 
333  if (Tk[i].pt()>maxPt_) GoodMatching=true;
334  if (Tk[i].pt()<minPt_) GoodMatching=false;
335 
336  //ENDCAP
337  //USE OF PRESHOWER
338  bool GoodPSMatching=false;
339  if ((fabs(Tk[i].eta())>1.68)&&(usePreshower_)){
340  int iptbin =4*getBin(Tk[i].pt());
341  ps2En=0;ps1En=0;
342  ps2chi=100.; ps1chi=100.;
343  PSforTMVA(mom,pos);
344  float p1e=thrPS[iptbin];
345  float p2e=thrPS[iptbin+1];
346  float p1c=thrPS[iptbin+2];
347  float p2c=thrPS[iptbin+3];
348  GoodPSMatching=
349  ((ps2En>p2e)
350  &&(ps1En>p1e)
351  &&(ps1chi<p1c)
352  &&(ps2chi<p2c));
353  GoodMatching = (GoodMatching && GoodPSMatching);
354  }
355 
356  math::XYZPoint myPoint(ElecTrkEcalPos.X(),ElecTrkEcalPos.Y(),ElecTrkEcalPos.Z());
357  myPreId.setECALMatchingProperties(clusterRef,myPoint,meanShowerSaved,toteta,totphi,chieta,
358  chiphi,chichi,EP);
359  myPreId.setECALMatching(EcalMatching);
360  myPreId.setESMatching(GoodPSMatching);
361 
362  if(applyIsolation_){
363  if(IsIsolated(float(Tk[i].charge()),Tk[i].p(),
364  ElecTrkEcalPos,*theECPfClustCollection,*theHCPfClustCollection))
365  GoodMatching=true;
366  }
367  bool GoodRange= ((fabs(Tk[i].eta())<maxEta_) &&
368  (Tk[i].pt()>minPt_));
369  //KF FILTERING FOR UNMATCHED EVENTS
370  int hit1max=int(thr[ibin+2]);
371  float chiredmin=thr[ibin+3];
372  bool GoodKFFiltering =
373  ((chikfred>chiredmin) || (nhitpi<hit1max));
374 
375  myPreId.setTrackFiltering(GoodKFFiltering);
376 
377  bool GoodTkId= false;
378 
379  if((!GoodMatching) &&(GoodKFFiltering) &&(GoodRange)){
380  chi=chichi;
381  chired=1000;
382  chiRatio=1000;
383  dpt=0;
384  nhit=nhitpi;
385 
387  Trajectory::ConstRecHitContainer hits=Tj[i].recHits();
388  for (int ih=hits.size()-1; ih>=0; ih--) tmp.push_back(hits[ih]);
389  vector<Trajectory> FitTjs=(fitter_.product())->fit(Seed,tmp,Tj[i].lastMeasurement().updatedState());
390 
391  if(FitTjs.size()>0){
392  if(FitTjs[0].isValid()){
393  vector<Trajectory> SmooTjs=(smoother_.product())->trajectories(FitTjs[0]);
394  if(SmooTjs.size()>0){
395  if(SmooTjs[0].isValid()){
396 
397  //Track refitted with electron hypothesis
398 
399  float pt_out=SmooTjs[0].firstMeasurement().
400  updatedState().globalMomentum().perp();
401  float pt_in=SmooTjs[0].lastMeasurement().
402  updatedState().globalMomentum().perp();
403  dpt=(pt_in>0) ? fabs(pt_out-pt_in)/pt_in : 0.;
404  // the following is simply the number of degrees of freedom
405  chiRatio=SmooTjs[0].chiSquared()/Tj[i].chiSquared();
406  chired=chiRatio*chikfred;
407  }
408  }
409  }
410  }
411 
412  //TMVA Analysis
413  if(useTmva_){
414 
415  eta=Tk[i].eta();
416  pt=Tk[i].pt();
417  eP=EP;
418 
419  float Ytmva=reader->EvaluateMVA( method_ );
420 
421  float BDTcut=thr[ibin+4];
422  if ( Ytmva>BDTcut) GoodTkId=true;
423  myPreId.setMVA(GoodTkId,Ytmva);
425  }else{
426 
427  //
428  float chiratiocut=thr[ibin+5];
429  float gschicut=thr[ibin+6];
430  float gsptmin=thr[ibin+7];
431 
432  GoodTkId=((dpt>gsptmin)&&(chired<gschicut)&&(chiRatio<chiratiocut));
433 
434  }
435  }
436 
437  GoodPreId= (GoodTkId || GoodMatching);
438 
439  myPreId.setFinalDecision(GoodPreId);
440 
441  if(GoodPreId)
442  LogDebug("GoodSeedProducer")<<"Track (pt= "<<Tk[i].pt()<<
443  "GeV/c, eta= "<<Tk[i].eta() <<
444  ") preidentified for agreement between track and ECAL cluster";
445  if(GoodPreId &&(!GoodMatching))
446  LogDebug("GoodSeedProducer")<<"Track (pt= "<<Tk[i].pt()<<
447  "GeV/c, eta= "<<Tk[i].eta() <<
448  ") preidentified only for track properties";
449 
450  } // end of !disablePreId_
451 
452  if (GoodPreId){
453 
454  //NEW SEED with n hits
455  ElectronSeed NewSeed(Seed);
456  NewSeed.setCtfTrack(trackRef);
457  output_preid->push_back(NewSeed);
458  }else{
459  if (produceCkfseed_){
460  output_nopre->push_back(Seed);
461  }
462  }
463  if(producePreId_ && myPreId.pt()>PtThresholdSavePredId_)
464  {
465  // save the index of the PreId object as to be able to create a Ref later
466  refMap_[trackRef] = output_preidinfo->size();
467  output_preidinfo->push_back(myPreId);
468  }
469  } //end loop on track collection
470  } //end loop on the vector of track collections
471 
472  // no disablePreId_ switch, it is simpler to have an empty collection rather than no collection
473  iEvent.put(output_preid,preidgsf_);
474  if (produceCkfseed_)
475  iEvent.put(output_nopre,preidckf_);
476  if(producePreId_)
477  {
478  const edm::OrphanHandle<reco::PreIdCollection> preIdRefProd = iEvent.put(output_preidinfo,preidname_);
479  // now make the Value Map, but only if one input collection
480  if(tracksContainers_.size()==1)
481  {
482  Handle<TrackCollection> tkRefCollection ;
483  iEvent.getByLabel(tracksContainers_[0],tkRefCollection);
484  fillPreIdRefValueMap(tkRefCollection,preIdRefProd,mapFiller);
485  mapFiller.fill();
486  iEvent.put(preIdMap_p,preidname_);
487  }
488  }
489 
490 }
491 // ------------ method called once each job just before starting event loop ------------
492 void
494  const EventSetup& es)
495 {
496  //Magnetic Field
497  ESHandle<MagneticField> magneticField;
498  es.get<IdealMagneticFieldRecord>().get(magneticField);
499  B_=magneticField->inTesla(GlobalPoint(0,0,0));
500 
503 
504 
505 
506  //Resolution maps
507  FileInPath ecalEtaMap(conf_.getParameter<string>("EtaMap"));
508  FileInPath ecalPhiMap(conf_.getParameter<string>("PhiMap"));
509  resMapEtaECAL_ = new PFResolutionMap("ECAL_eta",ecalEtaMap.fullPath().c_str());
510  resMapPhiECAL_ = new PFResolutionMap("ECAL_phi",ecalPhiMap.fullPath().c_str());
511 
512  if(useTmva_){
513  reader = new TMVA::Reader("!Color:Silent");
514  method_ = conf_.getParameter<string>("TMVAMethod");
515 
516  reader->AddVariable("eP",&eP);
517  reader->AddVariable("chi",&chi);
518  reader->AddVariable("chired",&chired);
519  reader->AddVariable("chiRatio",&chiRatio);
520  reader->AddVariable("dpt",&dpt);
521  reader->AddVariable("nhit",&nhit);
522  reader->AddVariable("eta",&eta);
523  reader->AddVariable("pt",&pt);
524  FileInPath Weigths(conf_.getParameter<string>("Weights"));
525  reader->BookMVA( method_, Weigths.fullPath().c_str() );
526  }
527 
528 
529  //read threshold
530  FileInPath parFile(conf_.getParameter<string>("ThresholdFile"));
531  ifstream ifs(parFile.fullPath().c_str());
532  for (int iy=0;iy<72;iy++) ifs >> thr[iy];
533 
534  //read PS threshold
535  FileInPath parPSFile(conf_.getParameter<string>("PSThresholdFile"));
536  ifstream ifsPS(parPSFile.fullPath().c_str());
537  for (int iy=0;iy<12;iy++) ifsPS >> thrPS[iy];
538 
539 }
540 
541 void
543  delete pfTransformer_;
544  delete resMapEtaECAL_;
545  delete resMapPhiECAL_;
546  if(useTmva_) delete reader;
547 }
548 
549 int
551 int ip=0;
552  if (pt<6) ip=0;
553  else { if (pt<12) ip=1;
554  else ip=2;
555  }
556 return ip;
557 }
558 
559 int
561  int ie=0;
562  int ip=0;
563  if (fabs(eta)<1.2) ie=0;
564  else{ if (fabs(eta)<1.68) ie=1;
565  else ie=2;
566  }
567  if (pt<6) ip=0;
568  else { if (pt<12) ip=1;
569  else ip=2;
570  }
571  int iep= ie*3+ip;
572  LogDebug("GoodSeedProducer")<<"Track pt ="<<pt<<" eta="<<eta<<" bin="<<iep;
573  return iep;
574 }
575 
576 void
578 
579  BaseParticlePropagator OutParticle(RawParticle(mom,pos)
580  ,0.,0.,B_.z()) ;
581 
582  OutParticle.propagateToPreshowerLayer1(false);
583  if (OutParticle.getSuccess()!=0){
584  // GlobalPoint v1=ps1TSOS.globalPosition();
585  math::XYZPoint v1=math::XYZPoint(OutParticle.vertex());
586  if ((v1.Rho() >=
588  (v1.Rho() <=
590  float enPScl1=0;
591  float chi1=100;
592  vector<PFCluster>::const_iterator ips;
593  for (ips=ps1Clus.begin(); ips!=ps1Clus.end();ips++){
594  float ax=((*ips).position().x()-v1.x())/0.114;
595  float ay=((*ips).position().y()-v1.y())/2.43;
596  float pschi= sqrt(ax*ax+ay*ay);
597  if (pschi<chi1){
598  chi1=pschi;
599  enPScl1=(*ips).energy();
600  }
601  }
602  ps1En=enPScl1;
603  ps1chi=chi1;
604 
605 
606  OutParticle.propagateToPreshowerLayer2(false);
607  if (OutParticle.getSuccess()!=0){
608  math::XYZPoint v2=math::XYZPoint(OutParticle.vertex());
609  if ((v2.Rho() >=
611  (v2.Rho() <=
613  float enPScl2=0;
614  float chi2=100;
615  for (ips=ps2Clus.begin(); ips!=ps2Clus.end();ips++){
616  float ax=((*ips).position().x()-v2.x())/1.88;
617  float ay=((*ips).position().y()-v2.y())/0.1449;
618  float pschi= sqrt(ax*ax+ay*ay);
619  if (pschi<chi2){
620  chi2=pschi;
621  enPScl2=(*ips).energy();
622  }
623  }
624 
625  ps2En=enPScl2;
626  ps2chi=chi2;
627 
628  }
629  }
630 
631  }
632 
633  }
634 }
635 
636 bool
638  math::XYZPointF myElecTrkEcalPos,
639  const PFClusterCollection &ecalColl,
640  const PFClusterCollection &hcalColl){
641 
642 
643  double myHCALenergy3x3=0.;
644  double myStripClusterE=0.;
645 
646 
647  // reco::TrackRef myElecTrk;
648 
649  if (fabs(myElecTrkEcalPos.z())<1. && myElecTrkEcalPos.x()<1. && myElecTrkEcalPos.y()<1. ) return false;
650 
651 
652 
653  PFClusterCollection::const_iterator hc=hcalColl.begin();
654  PFClusterCollection::const_iterator hcend=hcalColl.end();
655  for (;hc!=hcend;++hc){
656  math::XYZPoint clusPos = hc->position();
657  double en = hc->energy();
658  double deltaR = ROOT::Math::VectorUtil::DeltaR(myElecTrkEcalPos,clusPos);
659  if (deltaR<HcalIsolWindow_) {
660  myHCALenergy3x3 += en;
661 
662  }
663  }
664 
665 
666 
667  PFClusterCollection::const_iterator ec=ecalColl.begin();
668  PFClusterCollection::const_iterator ecend=ecalColl.end();
669  for (;ec!=ecend;++ec){
670  math::XYZPoint clusPos = ec->position();
671  double en = ec->energy();
672 
673 
674  double deltaPhi = ROOT::Math::VectorUtil::DeltaPhi(myElecTrkEcalPos,clusPos);
675  double deltaEta = abs(myElecTrkEcalPos.eta()-clusPos.eta());
676  double deltaPhiOverQ = deltaPhi/charge;
677  if (en >= EcalStripSumE_minClusEnergy_ && deltaEta<EcalStripSumE_deltaEta_ && deltaPhiOverQ > EcalStripSumE_deltaPhiOverQ_minValue_ && deltaPhiOverQ < EcalStripSumE_deltaPhiOverQ_maxValue_) {
678  myStripClusterE += en;
679  }
680  }
681 
682  double EoP=myStripClusterE/P;
683  double HoP=myHCALenergy3x3/P;
684 
685 
686  return ((EoP>minEoverP_)&&(EoP<2.5) && (HoP<maxHoverP_))?true:false;
687 }
688 
690  const edm::OrphanHandle<reco::PreIdCollection>& preidhandle,
692 {
693  std::vector<reco::PreIdRef> values;
694 
695  unsigned ntracks=tracks->size();
696  for(unsigned itrack=0;itrack<ntracks;++itrack)
697  {
698  reco::TrackRef theTrackRef(tracks,itrack);
699  std::map<reco::TrackRef,unsigned>::const_iterator itcheck=refMap_.find(theTrackRef);
700  if(itcheck==refMap_.end())
701  {
702  // the track has been early discarded
703  values.push_back(reco::PreIdRef());
704  }
705  else
706  {
707  edm::Ref<reco::PreIdCollection> preIdRef(preidhandle,itcheck->second);
708  values.push_back(preIdRef);
709  // std::cout << " Checking Refs " << (theTrackRef==preIdRef->trackRef()) << std::endl;
710  }
711  }
712  filler.insert(tracks,values.begin(),values.end());
713 }
#define LogDebug(id)
int nHitsInSeed_
Number of hits in the seed;.
RunNumber_t run() const
Definition: EventID.h:42
const double TwoPi
edm::ESHandle< TrajectoryFitter > fitter_
Fitter.
void setCharge(float q)
set the MEASURED charge
Definition: RawParticle.cc:138
T getParameter(std::string const &) const
EventNumber_t event() const
Definition: EventID.h:44
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
void setECALMatchingProperties(PFClusterRef clusterRef, const math::XYZPoint &ecalpos, const math::XYZPoint &meanShower, float deta, float dphi, float chieta, float chiphi, float chi2, float eop)
Definition: PreId.h:38
std::vector< reco::PreId > PreIdCollection
Definition: PreIdFwd.h:6
bool propagateToPreshowerLayer1(bool first=true)
std::string preidckf_
Name of the Seed(Ckf) Collection.
std::vector< reco::PFCluster > ps1Clus
Vector of clusters of the PreShower.
double deltaPhi(float phi1, float phi2)
Definition: VectorUtil.h:30
virtual void beginRun(edm::Run &run, const edm::EventSetup &)
float eP
VARIABLES NEEDED FOR TMVA.
edm::InputTag pfCLusTagPSLabel_
void insert(const H &h, I begin, I end)
Definition: ValueMap.h:52
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:10
static PFResolutionMap * resMapPhiECAL_
int getSuccess() const
Has propagation been performed and was barrel or endcap reached ?
#define abs(x)
Definition: mlp_lapack.h:159
#define P
edm::InputTag pfCLusTagHCLabel_
static PFResolutionMap * resMapEtaECAL_
double EcalStripSumE_minClusEnergy_
float thr[150]
vector of thresholds for different bins of eta and pt
int FindBin(double eta, double e)
extrapolation requires overloading of this function
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< float > > XYZPointF
point in space with cartesian internal representation
Definition: Point3D.h:11
bool IsIsolated(float charge, float P, math::XYZPointF, const reco::PFClusterCollection &ecalColl, const reco::PFClusterCollection &hcalColl)
bool applyIsolation_
ISOLATION REQUEST AS DONE IN THE TAU GROUP.
double charge(const std::vector< uint8_t > &Ampls)
T eta() const
void setCtfTrack(const CtfTrackRef &)
Set additional info.
Definition: ElectronSeed.cc:64
TransientTrackingRecHit::ConstRecHitContainer ConstRecHitContainer
Definition: Trajectory.h:43
void setTrack(reco::TrackRef trackref)
Definition: PreId.h:34
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:30
int getBin(float, float)
Find the bin in pt and eta.
int iEvent
Definition: GenABIO.cc:243
const XYZTLorentzVector & momentum() const
the momentum fourvector
Definition: RawParticle.h:285
edm::ParameterSet conf_
void setMVA(bool accepted, float mva, unsigned n=0)
Definition: PreId.h:72
std::string method_
TMVA method.
Definition: DDAxes.h:10
double EcalStripSumE_deltaEta_
double EcalStripSumE_deltaPhiOverQ_minValue_
std::vector< TrajectorySeed > TrajectorySeedCollection
double EcalStripSumE_deltaPhiOverQ_maxValue_
void setTrackFiltering(bool accepted, unsigned n=0)
Definition: PreId.h:68
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:84
T sqrt(T t)
Definition: SSEVec.h:28
edm::Ref< PFClusterCollection > PFClusterRef
persistent reference to PFCluster objects
Definition: PFClusterFwd.h:15
math::XYZVector B_
B field.
std::string preidname_
Name of the preid Collection (FB)
TypeLabelItem const & produces()
declare what type of product will make and with which optional label
bool useQuality_
TRACK QUALITY.
virtual void endRun()
void fillPreIdRefValueMap(edm::Handle< reco::TrackCollection > tkhandle, const edm::OrphanHandle< reco::PreIdCollection > &, edm::ValueMap< reco::PreIdRef >::Filler &filler)
double minPt_
Minimum transverse momentum and maximum pseudorapidity.
std::string fitterName_
std::vector< ElectronSeed > ElectronSeedCollection
collection of ElectronSeed objects
TMVA::Reader * reader
READER FOR TMVA.
bool disablePreId_
switch to disable the pre-id
virtual void produce(edm::Event &, const edm::EventSetup &)
reco::TrackBase::TrackQuality trackQuality_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:359
double clusThreshold_
Cut on the energy of the clusters.
bool propagateToEcalEntrance(bool first=true)
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
const XYZTLorentzVector & vertex() const
the vertex fourvector
Definition: RawParticle.h:284
PFTrackTransformer * pfTransformer_
PFTrackTransformer.
bool produceCkfseed_
Produce the Seed for Ckf tracks?
float pt() const
Definition: PreId.h:92
bool useTmva_
USE OF TMVA.
tuple tracks
Definition: testEve_cfg.py:39
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:13
static const float outerRadius(PFGeometry::Layers_t layer)
return outer radius of a given layer
Definition: PFGeometry.h:57
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
static const float innerRadius(PFGeometry::Layers_t layer)
return inner radius of a given layer
Definition: PFGeometry.h:53
std::vector< reco::PFCluster > ps2Clus
T const * product() const
Definition: Handle.h:74
std::vector< edm::InputTag > tracksContainers_
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
void setTrackProperties(float newchi2, float chi2ratio, float dpt)
Definition: PreId.h:50
edm::EventID id() const
Definition: EventBase.h:56
bool usePreshower_
Use of Preshower clusters.
void setECALMatching(bool accepted, unsigned n=0)
Definition: PreId.h:60
std::map< reco::TrackRef, unsigned > refMap_
Map used to create the TrackRef, PreIdRef value map.
bool producePreId_
Produce the pre-id debugging collection.
GoodSeedProducer(const edm::ParameterSet &)
std::vector< PFCluster > PFClusterCollection
collection of PFCluster objects
Definition: PFClusterFwd.h:9
std::string smootherName_
void setESMatching(bool accepted, unsigned n=0)
Definition: PreId.h:64
std::string fullPath() const
Definition: FileInPath.cc:170
edm::InputTag pfCLusTagECLabel_
Resolution Map (resolution as a function of eta and E)
void PSforTMVA(math::XYZTLorentzVector mom, math::XYZTLorentzVector pos)
std::string preidgsf_
Name of the Seed(Gsf) Collection.
double minEp_
Min and MAx allowed values forEoverP.
edm::ESHandle< TrajectorySmoother > smoother_
Smoother.
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
Definition: Run.h:31
double PtThresholdSavePredId_
Threshold to save Pre Idinfo.
void setFinalDecision(bool accepted, unsigned n=0)
Definition: PreId.h:56
math::XYZTLorentzVector XYZTLorentzVector
Definition: RawParticle.h:15