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