CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FastElectronSeedProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: ElectronProducers
4 // Class: FastElectronSeedProducer
5 //
13 //
14 // Original Author: Patrick Janot
15 //
16 //
17 
18 // user include files
21 
25 
29 
33 
40 
42 
43 #include <iostream>
44 
46  : matcher_(0), caloGeomCacheId_(0), hcalIso_(0) /*, doubleConeSel_(0) */
47  {
48  edm::ParameterSet pset = iConfig.getParameter<edm::ParameterSet>("SeedConfiguration");
49  SCEtCut_=pset.getParameter<double>("SCEtCut");
50  maxHOverE_=pset.getParameter<double>("maxHOverE");
51  hOverEConeSize_=pset.getParameter<double>("hOverEConeSize");
52  hOverEHBMinE_=pset.getParameter<double>("hOverEHBMinE");
53  hOverEHFMinE_=pset.getParameter<double>("hOverEHFMinE");
54  fromTrackerSeeds_=pset.getParameter<bool>("fromTrackerSeeds");
55  initialSeeds_=pset.getParameter<edm::InputTag>("initialSeeds");
56 
58  iConfig.getParameter<double>("pTMin"),
59  iConfig.getParameter<edm::InputTag>("beamSpot"));
60 
61  // get labels from config'
62  clusters_[0]=iConfig.getParameter<edm::InputTag>("barrelSuperClusters");
63  clusters_[1]=iConfig.getParameter<edm::InputTag>("endcapSuperClusters");
64  simTracks_=iConfig.getParameter<edm::InputTag>("simTracks");
65  trackerHits_=iConfig.getParameter<edm::InputTag>("trackerHits");
66  hcalRecHits_= pset.getParameter<edm::InputTag>("hcalRecHits");
67 
68  //register your products
69  produces<reco::ElectronSeedCollection>();
70 
71 }
72 
73 
75  {
76  // do anything here that needs to be done at desctruction time
77  // (e.g. close files, deallocate resources etc.)
78  delete matcher_ ;
79  //delete doubleConeSel_ ;
80  delete hcalIso_ ;
81  }
82 
83 void
85  {
86  // get calo geometry
88  {
89  es.get<CaloGeometryRecord>().get(caloGeom_);
90  caloGeomCacheId_=es.get<CaloGeometryRecord>().cacheIdentifier();
91  }
92 
93 // // The H/E calculator
94 // calc_=HoECalculator(caloGeom_);
95 
96  matcher_->setupES(es) ;
97 
98  }
99 
100 void
102 {
103  LogDebug("FastElectronSeedProducer")<<"[FastElectronSeedProducer::produce] entering " ;
104 
105  // get initial TrajectorySeeds if necessary
106  if (fromTrackerSeeds_) {
107 
109  e.getByLabel(initialSeeds_, hSeeds);
110  initialSeedColl_ = const_cast<TrajectorySeedCollection *> (hSeeds.product());
111 
112  } else {
113 
114  initialSeedColl_=0;// not needed in this case
115 
116  }
117 
119 
120  // Get the Monte Carlo truth (SimTracks)
122  e.getByLabel(simTracks_,theSTC);
123  const edm::SimTrackContainer* theSimTracks = &(*theSTC);
124 
125  // Get the collection of Tracker RecHits
127  e.getByLabel(trackerHits_, theRHC);
128  const SiTrackerGSMatchedRecHit2DCollection* theGSRecHits = &(*theRHC);
129 
130  //Retrieve tracker topology from geometry
132  iSetup.get<IdealGeometryRecord>().get(tTopoHand);
133  const TrackerTopology *tTopo=tTopoHand.product();
134 
135 
136  // get Hcal Rechit collection
138  e.getByLabel(hcalRecHits_,hbhe);
139 
140  // define cone for H/E
141 // delete doubleConeSel_;
142 // doubleConeSel_ = new CaloDualConeSelector(0.,hOverEConeSize_,caloGeom_.product(),DetId::Hcal) ;
143 
144  // HCAL iso deposits
145  delete hcalIso_ ;
147 
148  // Get the two supercluster collections
149  for (unsigned int i=0; i<2; i++) {
150 
151  // invoke algorithm
153  e.getByLabel(clusters_[i],clusters);
154  reco::SuperClusterRefVector clusterRefs;
155  filterClusters(clusters,/*mhbhe_,*/clusterRefs) ;
156  matcher_->run(e,clusterRefs,theGSRecHits,theSimTracks,initialSeedColl_,tTopo,*seeds);
157 
158  }
159 
160  // Save event content
161  std::auto_ptr<reco::ElectronSeedCollection> pSeeds(seeds) ;
162  e.put(pSeeds);
163 
164 }
165 
166 
167 void
170  reco::SuperClusterRefVector & sclRefs )
171  {
172  // filter the superclusters
173  // - with EtCut
174  // - with HoE using calo cone
175  for (unsigned int i=0;i<superClusters->size();++i)
176  {
177  const reco::SuperCluster & scl=(*superClusters)[i] ;
178  if (scl.energy()/cosh(scl.eta())>SCEtCut_)
179  {
180 // //double HoE=calc_(&scl,mhbhe);
181 // double HoE = 0. ;
182 // double hcalE = 0. ;
183 // if (mhbhe_)
184 // {
185 // math::XYZPoint caloPos = scl.position() ;
186 // GlobalPoint pclu(caloPos.x(),caloPos.y(),caloPos.z()) ;
187 // std::auto_ptr<CaloRecHitMetaCollectionV> chosen
188 // = doubleConeSel_->select(pclu,*mhbhe_) ;
189 // CaloRecHitMetaCollectionV::const_iterator i ;
190 // for ( i = chosen->begin () ; i != chosen->end () ; ++i )
191 // {
192 // double hcalHit_E = i->energy() ;
193 // if ( i->detid().subdetId()==HcalBarrel && hcalHit_E > hOverEHBMinE_)
194 // { hcalE += hcalHit_E ; } //HB case
195 // //if ( i->detid().subdetId()==HcalBarrel)
196 // // { std::cout << "[ElectronSeedProducer] HcalBarrel: hcalHit_E, hOverEHBMinE_ " << hcalHit_E << " " << hOverEHBMinE_ << std::endl; }
197 // if ( i->detid().subdetId()==HcalEndcap && hcalHit_E > hOverEHFMinE_)
198 // { hcalE += hcalHit_E ; } //HF case
199 // //if ( i->detid().subdetId()==HcalEndcap)
200 // // { std::cout << "[ElectronSeedProducer] HcalEndcap: hcalHit_E, hOverEHFMinE_ " << hcalHit_E << " " << hOverEHFMinE_ << std::endl; }
201 // }
202 // }
203 // HoE = hcalE/scl.energy() ;
204  //double hcalE = hcalHelper_->hcalESum(scl), HoE = hcalE/scl.energy() ;
205  double newHcalE = hcalIso_->getHcalESum(&scl), newHoE = newHcalE/scl.energy() ;
206  //std::cout << "[ElectronSeedProducer] HoE, maxHOverE_ " << newHoE << " " << HoE << " " << maxHOverE_ << std::endl ;
207  if (newHoE<=maxHOverE_)
208  { sclRefs.push_back(edm::Ref<reco::SuperClusterCollection>(superClusters,i)) ; }
209  }
210  }
211 
212  LogDebug("ElectronSeedProducer")<<"Filtered out "
213  <<sclRefs.size()<<" superclusters from "<<superClusters->size() ;
214  }
#define LogDebug(id)
T getParameter(std::string const &) const
unsigned long long cacheIdentifier() const
int i
Definition: DBlmapReader.cc:9
void setupES(const edm::EventSetup &setup)
FastElectronSeedGenerator * matcher_
double eta() const
pseudorapidity of cluster centroid
Definition: CaloCluster.h:163
edm::ESHandle< CaloGeometry > caloGeom_
EgammaHcalIsolation * hcalIso_
std::vector< TrajectorySeed > TrajectorySeedCollection
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
virtual void beginRun(edm::Run const &run, const edm::EventSetup &es) override
double energy() const
cluster energy
Definition: CaloCluster.h:121
virtual void produce(edm::Event &e, const edm::EventSetup &c) override
std::vector< ElectronSeed > ElectronSeedCollection
collection of ElectronSeed objects
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:405
T const * product() const
Definition: Handle.h:81
void run(edm::Event &e, const reco::SuperClusterRefVector &sclRefs, const SiTrackerGSMatchedRecHit2DCollection *theGSRecHits, const edm::SimTrackContainer *theSimTracks, TrajectorySeedCollection *seeds, const TrackerTopology *tTopo, reco::ElectronSeedCollection &out)
const T & get() const
Definition: EventSetup.h:55
TrajectorySeedCollection * initialSeedColl_
T const * product() const
Definition: ESHandle.h:86
FastElectronSeedProducer(const edm::ParameterSet &conf)
void filterClusters(const edm::Handle< reco::SuperClusterCollection > &superClusters, reco::SuperClusterRefVector &sclRefs)
void push_back(value_type const &ref)
Add a Ref&lt;C, T&gt; to the RefVector.
Definition: RefVector.h:64
size_type size() const
Size of the RefVector.
Definition: RefVector.h:89
std::vector< SimTrack > SimTrackContainer
Definition: Run.h:41