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 
12 
28 
30 
31 #include <fstream>
32 #include <string>
33 #include "TMath.h"
34 #include "Math/VectorUtil.h"
35 
36 using namespace edm;
37 using namespace std;
38 using namespace reco;
39 
41  pfTransformer_(nullptr),
42  conf_(iConfig),
43  resMapEtaECAL_(nullptr),
44  resMapPhiECAL_(nullptr)
45 {
46  LogInfo("GoodSeedProducer")<<"Electron PreIdentification started ";
47 
48  //now do what ever initialization is needed
49  std::vector<edm::InputTag> tags = iConfig.getParameter< vector < InputTag > >("TkColList");
50  for(unsigned int i=0;i<tags.size();++i) {
51  trajContainers_.push_back(consumes<vector<Trajectory> >(tags[i]));
52  tracksContainers_.push_back(consumes<reco::TrackCollection>(tags[i]));
53  }
54 
55  minPt_=iConfig.getParameter<double>("MinPt");
56  maxPt_=iConfig.getParameter<double>("MaxPt");
57  maxEta_=iConfig.getParameter<double>("MaxEta");
58 
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  pfCLusTagECLabel_=consumes<reco::PFClusterCollection>(iConfig.getParameter<InputTag>("PFEcalClusterLabel"));
68 
69  pfCLusTagHCLabel_=consumes<reco::PFClusterCollection>(iConfig.getParameter<InputTag>("PFHcalClusterLabel"));
70 
71  pfCLusTagPSLabel_=consumes<reco::PFClusterCollection>(iConfig.getParameter<InputTag>("PFPSClusterLabel"));
72 
73  preidgsf_ = iConfig.getParameter<string>("PreGsfLabel");
74  preidckf_ = iConfig.getParameter<string>("PreCkfLabel");
75  preidname_= iConfig.getParameter<string>("PreIdLabel");
76 
77 
78  fitterName_ = iConfig.getParameter<string>("Fitter");
79  smootherName_ = iConfig.getParameter<string>("Smoother");
80 
81 
82  nHitsInSeed_=iConfig.getParameter<int>("NHitsInSeed");
83 
84  clusThreshold_=iConfig.getParameter<double>("ClusterThreshold");
85 
86  minEp_=iConfig.getParameter<double>("MinEOverP");
87  maxEp_=iConfig.getParameter<double>("MaxEOverP");
88 
89  //collection to produce
90  produceCkfseed_ = iConfig.getUntrackedParameter<bool>("ProduceCkfSeed",false);
91 
92  // to disable the electron part (for HI collisions for examples)
93  disablePreId_ = iConfig.getUntrackedParameter<bool>("DisablePreId",false);
94 
95  producePreId_ = iConfig.getUntrackedParameter<bool>("ProducePreId",true);
96  // if no electron, cannot produce the preid
97  if(disablePreId_)
98  producePreId_=false;
99  PtThresholdSavePredId_ = iConfig.getUntrackedParameter<double>("PtThresholdSavePreId",1.);
100 
101  LogDebug("GoodSeedProducer")<<"Seeds for GSF will be produced ";
102 
103  // no disablePreId_ switch here. The collection will be empty if it is true
104  produces<ElectronSeedCollection>(preidgsf_);
105 
106  if(produceCkfseed_){
107  LogDebug("GoodSeedProducer")<<"Seeds for CKF will be produced ";
108  produces<TrajectorySeedCollection>(preidckf_);
109  }
110 
111  if(producePreId_){
112  LogDebug("GoodSeedProducer")<<"PreId debugging information will be produced ";
113 
114  produces<PreIdCollection>(preidname_);
115  if(tracksContainers_.size()==1) // do not make a value map if more than one input track collection
117  }
118 
119  useQuality_ = iConfig.getParameter<bool>("UseQuality");
120  trackQuality_=TrackBase::qualityByName(iConfig.getParameter<std::string>("TrackQuality"));
121 
122  useTmva_= iConfig.getUntrackedParameter<bool>("UseTMVA",false);
123 
124  Min_dr_ = iConfig.getParameter<double>("Min_dr");
125 }
126 
127 
129 {
130 
131  // do anything here that needs to be done at desctruction time
132  // (e.g. close files, deallocate resources etc.)
133 
134  delete pfTransformer_;
135  delete resMapEtaECAL_;
136  delete resMapPhiECAL_;
137  if(useTmva_) {
138  for (UInt_t j = 0; j < 9; ++j){
139  delete reader[j];
140  }
141  }
142 }
143 
144 
145 //
146 // member functions
147 //
148 
149 // ------------ method called to produce the data ------------
150 void
152 {
153 
154  LogDebug("GoodSeedProducer")<<"START event: "<<iEvent.id().event()
155  <<" in run "<<iEvent.id().run();
156  //Create empty output collections
157  auto_ptr<ElectronSeedCollection> output_preid(new ElectronSeedCollection);
158  auto_ptr<TrajectorySeedCollection> output_nopre(new TrajectorySeedCollection);
159  auto_ptr<PreIdCollection> output_preidinfo(new PreIdCollection);
160  auto_ptr<edm::ValueMap<reco::PreIdRef> > preIdMap_p(new edm::ValueMap<reco::PreIdRef>);
161  edm::ValueMap<reco::PreIdRef>::Filler mapFiller(*preIdMap_p);
162 
163  //Tracking Tools
164  if(!disablePreId_)
165  {
168  iSetup.get<TrajectoryFitter::Record>().get(fitterName_, aFitter);
169  iSetup.get<TrajectoryFitter::Record>().get(smootherName_, aSmoother);
170  smoother_.reset(aSmoother->clone());
171  fitter_ = aFitter->clone();
173  edm::ESHandle<TransientTrackingRecHitBuilder> theTrackerRecHitBuilder;
174  try {
175  std::string theTrackerRecHitBuilderName("WithAngleAndTemplate"); // FIXME FIXME
176  iSetup.get<TransientRecHitRecord>().get(theTrackerRecHitBuilderName,theTrackerRecHitBuilder);
177  } catch(...) {
178  std::string theTrackerRecHitBuilderName("hltESPTTRHBWithTrackAngle"); // FIXME FIXME
179  iSetup.get<TransientRecHitRecord>().get(theTrackerRecHitBuilderName,theTrackerRecHitBuilder);
180  }
181  hitCloner = static_cast<TkTransientTrackingRecHitBuilder const *>(theTrackerRecHitBuilder.product())->cloner();
182  fitter_->setHitCloner(&hitCloner);
183  smoother_->setHitCloner(&hitCloner);
184  }
185 
186  // clear temporary maps
187  refMap_.clear();
188 
189  //Handle input collections
190  //ECAL clusters
191  Handle<PFClusterCollection> theECPfClustCollection;
192  iEvent.getByToken(pfCLusTagECLabel_,theECPfClustCollection);
193 
194 
195  vector<PFCluster const *> basClus;
196  for ( auto const & klus : *theECPfClustCollection.product() ) {
197  if(klus.correctedEnergy()>clusThreshold_) basClus.push_back(&klus);
198  }
199 
200  //HCAL clusters
201  Handle<PFClusterCollection> theHCPfClustCollection;
202  iEvent.getByToken(pfCLusTagHCLabel_,theHCPfClustCollection);
203 
204  //PS clusters
205  Handle<PFClusterCollection> thePSPfClustCollection;
206  iEvent.getByToken(pfCLusTagPSLabel_,thePSPfClustCollection);
207 
208  //Vector of track collections
209  for (unsigned int istr=0; istr<tracksContainers_.size();++istr){
210 
211  //Track collection
212  Handle<TrackCollection> tkRefCollection;
213  iEvent.getByToken(tracksContainers_[istr], tkRefCollection);
214  const TrackCollection& Tk=*(tkRefCollection.product());
215 
216  //Trajectory collection
217  Handle<vector<Trajectory> > tjCollection;
218  iEvent.getByToken(trajContainers_[istr], tjCollection);
219  auto const & Tj=*(tjCollection.product());
220 
221  LogDebug("GoodSeedProducer")<<"Number of tracks in collection "
222  <<tracksContainers_[istr] <<" to be analyzed "
223  <<Tj.size();
224 
225  //loop over the track collection
226  for(unsigned int i=0;i<Tk.size();++i){
227  if (useQuality_ &&
228  (!(Tk[i].quality(trackQuality_)))) continue;
229 
230  reco::PreId myPreId;
231  bool GoodPreId=false;
232 
233  TrackRef trackRef(tkRefCollection, i);
234  // TrajectorySeed Seed=Tj[i].seed();
235  math::XYZVectorF tkmom(Tk[i].momentum());
236  auto tketa= tkmom.eta();
237  auto tkpt = std::sqrt(tkmom.perp2());
238  auto const & Seed=(*trackRef->seedRef());
239  if(!disablePreId_)
240  {
241  int ipteta=getBin(Tk[i].eta(),Tk[i].pt());
242  int ibin=ipteta*9;
243 
244  float oPTOB=1.f/Tj[i].lastMeasurement().updatedState().globalMomentum().mag();
245  // float chikfred=Tk[i].normalizedChi2();
246  float nchi=Tk[i].normalizedChi2();
247 
248  int nhitpi=Tj[i].foundHits();
249  float EP=0;
250 
251  // set track info
252  myPreId.setTrack(trackRef);
253  //CLUSTERS - TRACK matching
254 
255  auto pfmass= 0.0005;
256  auto pfoutenergy=sqrt((pfmass*pfmass)+Tk[i].outerMomentum().Mag2());
257 
258  XYZTLorentzVector mom =XYZTLorentzVector(Tk[i].outerMomentum().x(),
259  Tk[i].outerMomentum().y(),
260  Tk[i].outerMomentum().z(),
261  pfoutenergy);
262  XYZTLorentzVector pos = XYZTLorentzVector(Tk[i].outerPosition().x(),
263  Tk[i].outerPosition().y(),
264  Tk[i].outerPosition().z(),
265  0.);
266 
267  BaseParticlePropagator theOutParticle( RawParticle(mom,pos),
268  0,0,B_.z());
269  theOutParticle.setCharge(Tk[i].charge());
270 
271  theOutParticle.propagateToEcalEntrance(false);
272 
273 
274 
275  float toteta=1000.f;
276  float totphi=1000.f;
277  float dr=1000.f;
278  float EE=0.f;
279  float feta=0.f;
280  GlobalPoint ElecTrkEcalPos(0,0,0);
281 
282  PFClusterRef clusterRef;
283  math::XYZPoint meanShowerSaved;
284  if(theOutParticle.getSuccess()!=0){
285  ElecTrkEcalPos=GlobalPoint(theOutParticle.vertex().x(),
286  theOutParticle.vertex().y(),
287  theOutParticle.vertex().z()
288  );
289 
290  constexpr float psLim = 2.50746495928f; // std::sinh(1.65f);
291  bool isBelowPS= (ElecTrkEcalPos.z()*ElecTrkEcalPos.z()) > (psLim*psLim)*ElecTrkEcalPos.perp2();
292  // bool isBelowPS=(std::abs(ElecTrkEcalPos.eta())>1.65f);
293 
294  unsigned clusCounter=0;
295  float max_ee = 0;
296  for(auto aClus : basClus) {
297 
298  float tmp_ep=float(aClus->correctedEnergy())*oPTOB;
299  if ((tmp_ep<minEp_)|(tmp_ep>maxEp_)) { ++clusCounter; continue;}
300 
301  double ecalShowerDepth
302  = PFCluster::getDepthCorrection(aClus->correctedEnergy(),
303  isBelowPS,
304  false);
305  auto mom = theOutParticle.momentum().Vect();
306  auto meanShower = ElecTrkEcalPos +
307  GlobalVector(mom.x(),mom.y(),mom.z()).unit()*ecalShowerDepth;
308 
309  float etarec=meanShower.eta();
310  float phirec=meanShower.phi();
311 
312 
313  float tmp_phi=std::abs(aClus->positionREP().phi()-phirec);
314  if (tmp_phi>float(TMath::Pi())) tmp_phi-= float(TMath::TwoPi());
315 
316  float tmp_dr=std::sqrt(std::pow(tmp_phi,2.f)+
317  std::pow(aClus->positionREP().eta()-etarec,2.f));
318 
319  if (tmp_dr<dr){
320  dr=tmp_dr;
321  if(dr < Min_dr_){ // find the most closest and energetic ECAL cluster
322  if(aClus->correctedEnergy() > max_ee){
323 
324  toteta=aClus->positionREP().eta()-etarec;
325  totphi=tmp_phi;
326  EP=tmp_ep;
327  EE=aClus->correctedEnergy();
328  feta= aClus->positionREP().eta();
329  clusterRef = PFClusterRef(theECPfClustCollection,clusCounter);
330  meanShowerSaved = meanShower;
331 
332  }
333  }
334  }
335  ++clusCounter;
336  }
337  }
338  float trk_ecalDeta_ = fabs(toteta);
339  float trk_ecalDphi_ = fabs(totphi);
340 
341  //Resolution maps
342  auto ecaletares
343  = resMapEtaECAL_->GetBinContent(resMapEtaECAL_->FindBin(feta,EE));
344  auto ecalphires
345  = resMapPhiECAL_->GetBinContent(resMapPhiECAL_->FindBin(feta,EE));
346 
347  //geomatrical compatibility
348  float chieta=(toteta!=1000.f)? toteta/ecaletares : toteta;
349  float chiphi=(totphi!=1000.f)? totphi/ecalphires : totphi;
350  float chichi= sqrt(chieta*chieta + chiphi*chiphi);
351 
352  //Matching criteria
353  float eta_cut = thr[ibin+0];
354  float phi_cut = thr[ibin+1];
355  float ep_cutmin=thr[ibin+2];
356  bool GoodMatching= ((trk_ecalDeta_<eta_cut) && (trk_ecalDphi_<phi_cut) && (EP>ep_cutmin) && (nhitpi>10));
357 
358  bool EcalMatching=GoodMatching;
359 
360  if (tkpt>maxPt_) GoodMatching=true;
361  if (tkpt<minPt_) GoodMatching=false;
362 
363 
364 
365  math::XYZPoint myPoint(ElecTrkEcalPos.x(),ElecTrkEcalPos.y(),ElecTrkEcalPos.z());
366  myPreId.setECALMatchingProperties(clusterRef,myPoint,meanShowerSaved,std::abs(toteta),std::abs(totphi),chieta,
367  chiphi,chichi,EP);
368  myPreId.setECALMatching(EcalMatching);
369 
370 
371  bool GoodRange= ((std::abs(tketa)<maxEta_) &
372  (tkpt>minPt_));
373  //KF FILTERING FOR UNMATCHED EVENTS
374  int hit1max=int(thr[ibin+3]);
375  float chiredmin=thr[ibin+4];
376  bool GoodKFFiltering =
377  ((nchi>chiredmin) | (nhitpi<hit1max));
378 
379 
380  myPreId.setTrackFiltering(GoodKFFiltering);
381 
382  bool GoodTkId= false;
383 
384  if((!GoodMatching) &&(GoodKFFiltering) &&(GoodRange)){
385  chired=1000;
386  chiRatio=1000;
387  dpt=0;
388  nhit=nhitpi;
389  chikfred = nchi;
390  trk_ecalDeta = trk_ecalDeta_;
391  trk_ecalDphi = trk_ecalDphi_;
392 
394  Trajectory::ConstRecHitContainer && hits=Tj[i].recHits();
395  for (int ih=hits.size()-1; ih>=0; ih--) tmp.push_back(hits[ih]);
396  Trajectory && FitTjs= fitter_->fitOne(Seed,tmp,Tj[i].lastMeasurement().updatedState());
397 
398  if(FitTjs.isValid()){
399  Trajectory && SmooTjs= smoother_->trajectory(FitTjs);
400  if(SmooTjs.isValid()){
401 
402  //Track refitted with electron hypothesis
403 
404  float pt_out=SmooTjs.firstMeasurement().
405  updatedState().globalMomentum().perp();
406  float pt_in=SmooTjs.lastMeasurement().
407  updatedState().globalMomentum().perp();
408  dpt=(pt_in>0) ? fabs(pt_out-pt_in)/pt_in : 0.;
409  // the following is simply the number of degrees of freedom
410  chiRatio=SmooTjs.chiSquared()/Tj[i].chiSquared();
412 
413  }
414  }
415 
416 
417  //TMVA Analysis
418  if(useTmva_){
419 
420  eta=tketa;
421  pt=tkpt;
422  eP=EP;
423 
424  float Ytmva=reader[ipteta]->EvaluateMVA( method_ );
425 
426  float BDTcut=thr[ibin+5];
427  if ( Ytmva>BDTcut) GoodTkId=true;
428  myPreId.setMVA(GoodTkId,Ytmva);
430  }else{
431 
432  float chiratiocut=thr[ibin+6];
433  float gschicut=thr[ibin+7];
434  float gsptmin=thr[ibin+8];
435 
436  GoodTkId=((dpt>gsptmin)&(chired<gschicut)&(chiRatio<chiratiocut));
437 
438  }
439  }
440 
441  GoodPreId= GoodTkId | GoodMatching;
442 
443  myPreId.setFinalDecision(GoodPreId);
444 
445  if(GoodPreId)
446  LogDebug("GoodSeedProducer")<<"Track (pt= "<<Tk[i].pt()<<
447  "GeV/c, eta= "<<Tk[i].eta() <<
448  ") preidentified for agreement between track and ECAL cluster";
449  if(GoodPreId &&(!GoodMatching))
450  LogDebug("GoodSeedProducer")<<"Track (pt= "<<Tk[i].pt()<<
451  "GeV/c, eta= "<<Tk[i].eta() <<
452  ") preidentified only for track properties";
453 
454  } // end of !disablePreId_
455 
456  if (GoodPreId){
457  //NEW SEED with n hits
458  ElectronSeed NewSeed(Seed);
459  NewSeed.setCtfTrack(trackRef);
460  output_preid->push_back(NewSeed);
461  }else{
462  if (produceCkfseed_){
463  output_nopre->push_back(Seed);
464  }
465  }
466  if(producePreId_ && myPreId.pt()>PtThresholdSavePredId_)
467  {
468  // save the index of the PreId object as to be able to create a Ref later
469  refMap_[trackRef] = output_preidinfo->size();
470  output_preidinfo->push_back(myPreId);
471  }
472  } //end loop on track collection
473  } //end loop on the vector of track collections
474 
475  // no disablePreId_ switch, it is simpler to have an empty collection rather than no collection
476  iEvent.put(output_preid,preidgsf_);
477  if (produceCkfseed_)
478  iEvent.put(output_nopre,preidckf_);
479  if(producePreId_)
480  {
481  const edm::OrphanHandle<reco::PreIdCollection> preIdRefProd = iEvent.put(output_preidinfo,preidname_);
482  // now make the Value Map, but only if one input collection
483  if(tracksContainers_.size()==1)
484  {
485  Handle<TrackCollection> tkRefCollection ;
486  iEvent.getByToken(tracksContainers_[0],tkRefCollection);
487  fillPreIdRefValueMap(tkRefCollection,preIdRefProd,mapFiller);
488  mapFiller.fill();
489  iEvent.put(preIdMap_p,preidname_);
490  }
491  }
492  // clear temporary maps
493  refMap_.clear();
494 }
495 // ------------ method called once each job just before starting event loop ------------
496 void
498  const EventSetup& es)
499 {
500  //Magnetic Field
501  ESHandle<MagneticField> magneticField;
502  es.get<IdealMagneticFieldRecord>().get(magneticField);
503  B_=magneticField->inTesla(GlobalPoint(0,0,0));
504 
507 
508  //Resolution maps
509  FileInPath ecalEtaMap(conf_.getParameter<string>("EtaMap"));
510  FileInPath ecalPhiMap(conf_.getParameter<string>("PhiMap"));
511  resMapEtaECAL_ = new PFResolutionMap("ECAL_eta",ecalEtaMap.fullPath().c_str());
512  resMapPhiECAL_ = new PFResolutionMap("ECAL_phi",ecalPhiMap.fullPath().c_str());
513 
514  if(useTmva_){
515  method_ = conf_.getParameter<string>("TMVAMethod");
516  FileInPath Weigths1(conf_.getParameter<string>("Weights1"));
517  FileInPath Weigths2(conf_.getParameter<string>("Weights2"));
518  FileInPath Weigths3(conf_.getParameter<string>("Weights3"));
519  FileInPath Weigths4(conf_.getParameter<string>("Weights4"));
520  FileInPath Weigths5(conf_.getParameter<string>("Weights5"));
521  FileInPath Weigths6(conf_.getParameter<string>("Weights6"));
522  FileInPath Weigths7(conf_.getParameter<string>("Weights7"));
523  FileInPath Weigths8(conf_.getParameter<string>("Weights8"));
524  FileInPath Weigths9(conf_.getParameter<string>("Weights9"));
525 
526  for(UInt_t j = 0; j < 9; ++j){
527  reader[j] = new TMVA::Reader("!Color:Silent");
528 
529  reader[j]->AddVariable("NHits", &nhit);
530  reader[j]->AddVariable("NormChi", &chikfred);
531  reader[j]->AddVariable("dPtGSF", &dpt);
532  reader[j]->AddVariable("EoP", &eP);
533  reader[j]->AddVariable("ChiRatio", &chiRatio);
534  reader[j]->AddVariable("RedChi", &chired);
535  reader[j]->AddVariable("EcalDEta", &trk_ecalDeta);
536  reader[j]->AddVariable("EcalDPhi", &trk_ecalDphi);
537  reader[j]->AddVariable("pt", &pt);
538  reader[j]->AddVariable("eta", &eta);
539 
540  if(j==0) reader[j]->BookMVA(method_, Weigths1.fullPath().c_str());
541  if(j==1) reader[j]->BookMVA(method_, Weigths2.fullPath().c_str());
542  if(j==2) reader[j]->BookMVA(method_, Weigths3.fullPath().c_str());
543  if(j==3) reader[j]->BookMVA(method_, Weigths4.fullPath().c_str());
544  if(j==4) reader[j]->BookMVA(method_, Weigths5.fullPath().c_str());
545  if(j==5) reader[j]->BookMVA(method_, Weigths6.fullPath().c_str());
546  if(j==6) reader[j]->BookMVA(method_, Weigths7.fullPath().c_str());
547  if(j==7) reader[j]->BookMVA(method_, Weigths8.fullPath().c_str());
548  if(j==8) reader[j]->BookMVA(method_, Weigths9.fullPath().c_str());
549  }
550  }
551  //read threshold
552  FileInPath parFile(conf_.getParameter<string>("ThresholdFile"));
553  ifstream ifs(parFile.fullPath().c_str());
554  for (int iy=0;iy<81;++iy) ifs >> thr[iy];
555 }
556 
557 void
559  delete pfTransformer_;
560  pfTransformer_ = nullptr;
561  delete resMapEtaECAL_;
562  resMapEtaECAL_ = nullptr;
563  delete resMapPhiECAL_;
564  resMapPhiECAL_ = nullptr;
565 }
566 
567 int
569  int ie=0;
570  int ip=0;
571  if (fabs(eta)<0.8) ie=0;
572  else{ if (fabs(eta)<1.479) ie=1;
573  else ie=2;
574  }
575  if (pt<6) ip=0;
576  else { if (pt<12) ip=1;
577  else ip=2;
578  }
579  int iep= ie*3+ip;
580  LogDebug("GoodSeedProducer")<<"Track pt ="<<pt<<" eta="<<eta<<" bin="<<iep;
581  return iep;
582 }
583 
585  const edm::OrphanHandle<reco::PreIdCollection>& preidhandle,
587 {
588  std::vector<reco::PreIdRef> values;
589 
590  unsigned ntracks=tracks->size();
591  for(unsigned itrack=0;itrack<ntracks;++itrack)
592  {
593  reco::TrackRef theTrackRef(tracks,itrack);
594  std::map<reco::TrackRef,unsigned>::const_iterator itcheck=refMap_.find(theTrackRef);
595  if(itcheck==refMap_.end())
596  {
597  // the track has been early discarded
598  values.push_back(reco::PreIdRef());
599  }
600  else
601  {
602  edm::Ref<reco::PreIdCollection> preIdRef(preidhandle,itcheck->second);
603  values.push_back(preIdRef);
604  // std::cout << " Checking Refs " << (theTrackRef==preIdRef->trackRef()) << std::endl;
605  }
606  }
607  filler.insert(tracks,values.begin(),values.end());
608 }
#define LogDebug(id)
int nHitsInSeed_
Number of hits in the seed;.
RunNumber_t run() const
Definition: EventID.h:42
const double TwoPi
const double Pi
void setCharge(float q)
set the MEASURED charge
Definition: RawParticle.cc:139
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
std::string preidckf_
Name of the Seed(Ckf) Collection.
edm::EDGetTokenT< reco::PFClusterCollection > pfCLusTagPSLabel_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
float eP
VARIABLES NEEDED FOR TMVA.
std::unique_ptr< TrajectorySmoother > smoother_
Smoother.
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
PFResolutionMap * resMapEtaECAL_
T y() const
Definition: PV3DBase.h:63
double EcalStripSumE_minClusEnergy_
float thr[150]
vector of thresholds for different bins of eta and pt
T perp2() const
Definition: PV3DBase.h:71
int FindBin(double eta, double e)
extrapolation requires overloading of this function
T eta() const
#define nullptr
double charge(const std::vector< uint8_t > &Ampls)
#define constexpr
float float float z
TkClonerImpl hitCloner
void setCtfTrack(const CtfTrackRef &)
Set additional info.
Definition: ElectronSeed.cc:64
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
void setTrack(reco::TrackRef trackref)
Definition: PreId.h:34
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
int getBin(float, float)
Find the bin in pt and eta.
int iEvent
Definition: GenABIO.cc:230
std::unique_ptr< TrajectoryFitter > fitter_
Fitter.
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
TMVA::Reader * reader[9]
READER FOR TMVA.
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:116
string unit
Definition: csvLumiCalc.py:46
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)
TrajectoryMeasurement const & lastMeasurement() const
Definition: Trajectory.h:181
T z() const
Definition: PV3DBase.h:64
TypeLabelItem const & produces()
declare what type of product will make and with which optional label
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int j
Definition: DBlmapReader.cc:9
bool useQuality_
TRACK QUALITY.
void fillPreIdRefValueMap(edm::Handle< reco::TrackCollection > tkhandle, const edm::OrphanHandle< reco::PreIdCollection > &, edm::ValueMap< reco::PreIdRef >::Filler &filler)
double f[11][100]
double minPt_
Minimum transverse momentum and maximum pseudorapidity.
PFResolutionMap * resMapPhiECAL_
std::string fitterName_
std::vector< ElectronSeed > ElectronSeedCollection
collection of ElectronSeed objects
bool disablePreId_
switch to disable the pre-id
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< float > > XYZVectorF
spatial vector with cartesian internal representation
Definition: Vector3D.h:17
virtual void beginRun(const edm::Run &run, const edm::EventSetup &) override
reco::TrackBase::TrackQuality trackQuality_
double clusThreshold_
Cut on the energy of the clusters.
TrackingRecHit::ConstRecHitContainer ConstRecHitContainer
Definition: Trajectory.h:47
tuple tags
Definition: o2o.py:248
PFTrackTransformer * pfTransformer_
PFTrackTransformer.
virtual void endRun(const edm::Run &run, const edm::EventSetup &) override
bool produceCkfseed_
Produce the Seed for Ckf tracks?
bool isValid() const
Definition: Trajectory.h:269
TrajectoryMeasurement const & firstMeasurement() const
Definition: Trajectory.h:194
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:12
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
T const * product() const
Definition: Handle.h:81
float chiSquared() const
Definition: Trajectory.h:252
std::vector< edm::EDGetTokenT< reco::TrackCollection > > 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
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::string smootherName_
edm::EDGetTokenT< reco::PFClusterCollection > pfCLusTagHCLabel_
std::string fullPath() const
Definition: FileInPath.cc:165
Definition: DDAxes.h:10
Resolution Map (resolution as a function of eta and E)
T x() const
Definition: PV3DBase.h:62
std::string preidgsf_
Name of the Seed(Gsf) Collection.
edm::EDGetTokenT< reco::PFClusterCollection > pfCLusTagECLabel_
double minEp_
Min and MAx allowed values forEoverP.
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
std::vector< edm::EDGetTokenT< std::vector< Trajectory > > > trajContainers_
Definition: Run.h:41
double PtThresholdSavePredId_
Threshold to save Pre Idinfo.
Global3DVector GlobalVector
Definition: GlobalVector.h:10
void setFinalDecision(bool accepted, unsigned n=0)
Definition: PreId.h:56
math::XYZTLorentzVector XYZTLorentzVector
Definition: RawParticle.h:15