CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ElectronSeedProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: ElectronProducers
4 // Class: ElectronSeedProducer
5 //
13 //
14 // Original Author: Ursula Berthon, Claude Charlot
15 // Created: Mon Mar 27 13:22:06 CEST 2006
16 //
17 //
18 
19 #include "ElectronSeedProducer.h"
20 
22 //#include "DataFormats/RecoCandidate/interface/RecoCandidate.h"
23 
29 
34 
39 
47 
48 #include <string>
49 
50 using namespace reco ;
51 
53  : //conf_(iConfig),
54  applyHOverECut_(true), hcalHelper_(0),
55  caloGeom_(0), caloGeomCacheId_(0), caloTopo_(0), caloTopoCacheId_(0)
56  {
57  conf_ = iConfig.getParameter<edm::ParameterSet>("SeedConfiguration") ;
58 
59  initialSeeds_ = consumes<TrajectorySeedCollection>(conf_.getParameter<edm::InputTag>("initialSeeds")) ;
60  SCEtCut_ = conf_.getParameter<double>("SCEtCut") ;
61  fromTrackerSeeds_ = conf_.getParameter<bool>("fromTrackerSeeds") ;
62  prefilteredSeeds_ = conf_.getParameter<bool>("preFilteredSeeds") ;
63 
64  // new beamSpot tag
65  if (conf_.exists("beamSpot")) {
66  beamSpotTag_ = consumes<reco::BeamSpot>(conf_.getParameter<edm::InputTag>("beamSpot"));
67  } else {
68  beamSpotTag_ = consumes<reco::BeamSpot>(edm::InputTag("offlineBeamSpot"));
69  }
70 
71  // for H/E
72 // if (conf_.exists("applyHOverECut"))
73 // { applyHOverECut_ = conf_.getParameter<bool>("applyHOverECut") ; }
74  applyHOverECut_ = conf_.getParameter<bool>("applyHOverECut") ;
75  if (applyHOverECut_)
76  {
78  hcalCfg.hOverEConeSize = conf_.getParameter<double>("hOverEConeSize") ;
79  if (hcalCfg.hOverEConeSize>0)
80  {
81  hcalCfg.useTowers = true ;
82  hcalCfg.hcalTowers =
83  consumes<CaloTowerCollection>(conf_.getParameter<edm::InputTag>("hcalTowers")) ;
84  hcalCfg.hOverEPtMin = conf_.getParameter<double>("hOverEPtMin") ;
85  }
86  hcalHelper_ = new ElectronHcalHelper(hcalCfg) ;
87  maxHOverEBarrel_=conf_.getParameter<double>("maxHOverEBarrel") ;
88  maxHOverEEndcaps_=conf_.getParameter<double>("maxHOverEEndcaps") ;
89  maxHBarrel_=conf_.getParameter<double>("maxHBarrel") ;
90  maxHEndcaps_=conf_.getParameter<double>("maxHEndcaps") ;
91 // hOverEConeSize_=conf_.getParameter<double>("hOverEConeSize") ;
92 // hOverEHBMinE_=conf_.getParameter<double>("hOverEHBMinE") ;
93 // hOverEHFMinE_=conf_.getParameter<double>("hOverEHFMinE") ;
94  }
95 
96  if( conf_.exists("RegionPSet") ) {
97  edm::ParameterSet rpset =
98  conf_.getParameter<edm::ParameterSet>("RegionPSet");
99  filterVtxTag_ =
100  consumes<std::vector<reco::Vertex> >(rpset.getParameter<edm::InputTag> ("VertexProducer"));
101  }
102 
104  esg_tokens.token_bs = beamSpotTag_;
105  if(conf_.exists("vertices")) {
106  esg_tokens.token_vtx =
107  mayConsume<reco::VertexCollection>(conf_.getParameter<edm::InputTag>("vertices"));
108  } else {
109  esg_tokens.token_vtx =
110  mayConsume<reco::VertexCollection>(edm::InputTag("offlinePrimaryVerticesWithBS"));
111  }
112  if(conf_.existsAs<edm::InputTag>("measurementTrackerEvent")) {
113  esg_tokens.token_measTrkEvt= consumes<MeasurementTrackerEvent>(conf_.getParameter<edm::InputTag>("measurementTrackerEvent"));
114  }
115 
116  matcher_ = new ElectronSeedGenerator(conf_,esg_tokens) ;
117 
118  // get collections from config'
119  superClusters_[0]=
120  consumes<reco::SuperClusterCollection>(iConfig.getParameter<edm::InputTag>("barrelSuperClusters")) ;
121  superClusters_[1]=
122  consumes<reco::SuperClusterCollection>(iConfig.getParameter<edm::InputTag>("endcapSuperClusters")) ;
123 
124  // Construction of SeedFilter was in beginRun() with the comment
125  // below, but it has to be done here because of ConsumesCollector
126  //
127  // FIXME: because of a bug presumably in tracker seeding,
128  // perhaps in CombinedHitPairGenerator, badly caching some EventSetup product,
129  // we must redo the SeedFilter for each run.
130  if (prefilteredSeeds_) {
131  SeedFilter::Tokens sf_tokens;
132  sf_tokens.token_bs = beamSpotTag_;
133  sf_tokens.token_vtx = filterVtxTag_;
135  seedFilter_.reset(new SeedFilter(conf_, sf_tokens, iC));
136  }
137 
138  //register your products
139  produces<ElectronSeedCollection>() ;
140 }
141 
142 
144 }
145 
147  {
148  }
149 
151  {
152  delete hcalHelper_ ;
153  delete matcher_ ;
154  }
155 
157  {
158  LogDebug("ElectronSeedProducer") <<"[ElectronSeedProducer::produce] entering " ;
159 
160  edm::Handle<reco::BeamSpot> theBeamSpot ;
161  e.getByToken(beamSpotTag_,theBeamSpot) ;
162 
163  if (hcalHelper_)
164  {
165  hcalHelper_->checkSetup(iSetup) ;
166  hcalHelper_->readEvent(e) ;
167  }
168 
169  // get calo geometry
171  iSetup.get<CaloGeometryRecord>().get(caloGeom_);
172  caloGeomCacheId_=iSetup.get<CaloGeometryRecord>().cacheIdentifier();
173  }
175  caloTopoCacheId_=iSetup.get<CaloTopologyRecord>().cacheIdentifier();
176  iSetup.get<CaloTopologyRecord>().get(caloTopo_);
177  }
178 
179  matcher_->setupES(iSetup);
180 
181  // get initial TrajectorySeeds if necessary
182  if (fromTrackerSeeds_)
183  {
184  if (!prefilteredSeeds_)
185  {
187  e.getByToken(initialSeeds_, hSeeds);
188  theInitialSeedColl = const_cast<TrajectorySeedCollection *> (hSeeds.product());
189  }
190  else
192  }
193  else
194  { theInitialSeedColl = 0 ; } // not needed in this case
195 
197 
198  // loop over barrel + endcap
199  for (unsigned int i=0; i<2; i++) {
201  e.getByToken(superClusters_[i],clusters);
202  SuperClusterRefVector clusterRefs ;
203  std::vector<float> hoe1s, hoe2s ;
204  filterClusters(*theBeamSpot,clusters,/*mhbhe_,*/clusterRefs,hoe1s,hoe2s);
206  { filterSeeds(e,iSetup,clusterRefs) ; }
207  matcher_->run(e,iSetup,clusterRefs,hoe1s,hoe2s,theInitialSeedColl,*seeds);
208  }
209 
210  // store the accumulated result
211  std::auto_ptr<ElectronSeedCollection> pSeeds(seeds) ;
212  ElectronSeedCollection::iterator is ;
213  for ( is=pSeeds->begin() ; is!=pSeeds->end() ; is++ ) {
214  edm::RefToBase<CaloCluster> caloCluster = is->caloCluster() ;
215  SuperClusterRef superCluster = caloCluster.castTo<SuperClusterRef>() ;
216  LogDebug("ElectronSeedProducer")
217  << "new seed with "
218  << (*is).nHits() << " hits"
219  << ", charge " << (*is).getCharge()
220  << " and cluster energy " << superCluster->energy()
221  << " PID "<<superCluster.id() ;
222  }
223  e.put(pSeeds) ;
225  }
226 
227 
228 //===============================
229 // Filter the superclusters
230 // - with EtCut
231 // - with HoE using calo cone
232 //===============================
233 
235  ( const reco::BeamSpot & bs,
236  const edm::Handle<reco::SuperClusterCollection> & superClusters,
237  SuperClusterRefVector & sclRefs,
238  std::vector<float> & hoe1s, std::vector<float> & hoe2s )
239  {
240  for (unsigned int i=0;i<superClusters->size();++i)
241  {
242  const SuperCluster & scl = (*superClusters)[i] ;
243  double sclEta = EleRelPoint(scl.position(),bs.position()).eta() ;
244  if (scl.energy()/cosh(sclEta)>SCEtCut_)
245  {
246 // if ((applyHOverECut_==true)&&((hcalHelper_->hcalESum(scl)/scl.energy()) > maxHOverE_))
247 // { continue ; }
248 // sclRefs.push_back(edm::Ref<reco::SuperClusterCollection>(superClusters,i)) ;
249  double had1, had2, had, scle ;
250  bool HoeVeto = false ;
251  if (applyHOverECut_==true)
252  {
253  had1 = hcalHelper_->hcalESumDepth1(scl);
254  had2 = hcalHelper_->hcalESumDepth2(scl);
255  had = had1+had2 ;
256  scle = scl.energy() ;
257  int detector = scl.seed()->hitsAndFractions()[0].first.subdetId() ;
258  if (detector==EcalBarrel && (had<maxHBarrel_ || had/scle<maxHOverEBarrel_)) HoeVeto=true;
259  else if (detector==EcalEndcap && (had<maxHEndcaps_ || had/scle<maxHOverEEndcaps_)) HoeVeto=true;
260  if (HoeVeto)
261  {
262  sclRefs.push_back(edm::Ref<reco::SuperClusterCollection>(superClusters,i)) ;
263  hoe1s.push_back(had1/scle) ;
264  hoe2s.push_back(had2/scle) ;
265  }
266  }
267  else
268  {
269  sclRefs.push_back(edm::Ref<reco::SuperClusterCollection>(superClusters,i)) ;
270  hoe1s.push_back(std::numeric_limits<float>::infinity()) ;
271  hoe2s.push_back(std::numeric_limits<float>::infinity()) ;
272  }
273  }
274  }
275  LogDebug("ElectronSeedProducer")<<"Filtered out "<<sclRefs.size()<<" superclusters from "<<superClusters->size() ;
276  }
277 
280  reco::SuperClusterRefVector & sclRefs )
281  {
282  for ( unsigned int i=0 ; i<sclRefs.size() ; ++i )
283  {
284  seedFilter_->seeds(event,setup,sclRefs[i],theInitialSeedColl) ;
285  LogDebug("ElectronSeedProducer")<<"Number of Seeds: "<<theInitialSeedColl->size() ;
286  }
287  }
#define LogDebug(id)
T getParameter(std::string const &) const
unsigned long long cacheIdentifier() const
const math::XYZPoint & position() const
cluster centroid position
Definition: CaloCluster.h:124
int i
Definition: DBlmapReader.cc:9
virtual void endRun(edm::Run const &, edm::EventSetup const &) overridefinal
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:184
edm::EDGetTokenT< reco::BeamSpot > token_bs
void readEvent(const edm::Event &)
void setupES(const edm::EventSetup &setup)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
virtual void beginRun(edm::Run const &, edm::EventSetup const &) overridefinal
unsigned long long caloGeomCacheId_
bool exists(std::string const &parameterName) const
checks if a parameter exists
edm::EDGetTokenT< std::vector< reco::Vertex > > filterVtxTag_
void checkSetup(const edm::EventSetup &)
edm::EDGetTokenT< TrajectorySeedCollection > initialSeeds_
T eta() const
void run(edm::Event &, const edm::EventSetup &setup, const reco::SuperClusterRefVector &, const std::vector< float > &hoe1s, const std::vector< float > &hoe2s, TrajectorySeedCollection *seeds, reco::ElectronSeedCollection &)
edm::EDGetTokenT< MeasurementTrackerEvent > token_measTrkEvt
edm::ESHandle< CaloTopology > caloTopo_
void filterClusters(const reco::BeamSpot &bs, const edm::Handle< reco::SuperClusterCollection > &superClusters, reco::SuperClusterRefVector &sclRefs, std::vector< float > &hoe1s, std::vector< float > &hoe2s)
std::vector< TrajectorySeed > TrajectorySeedCollection
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
const double infinity
ElectronSeedProducer(const edm::ParameterSet &)
double energy() const
cluster energy
Definition: CaloCluster.h:120
std::vector< ElectronSeed > ElectronSeedCollection
collection of ElectronSeed objects
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
std::unique_ptr< SeedFilter > seedFilter_
edm::ParameterSet conf_
edm::ESHandle< CaloGeometry > caloGeom_
ElectronSeedGenerator * matcher_
TrajectorySeedCollection * theInitialSeedColl
const T & get() const
Definition: EventSetup.h:55
REF castTo() const
cast to a concrete type
Definition: RefToBase.h:241
edm::EDGetTokenT< reco::SuperClusterCollection > superClusters_[2]
T const * product() const
Definition: Handle.h:81
unsigned long long caloTopoCacheId_
edm::EDGetTokenT< reco::BeamSpot > token_bs
Definition: SeedFilter.h:37
void filterSeeds(edm::Event &e, const edm::EventSetup &setup, 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
edm::EDGetTokenT< CaloTowerCollection > hcalTowers
const Point & position() const
position
Definition: BeamSpot.h:62
const CaloClusterPtr & seed() const
seed BasicCluster
Definition: SuperCluster.h:66
ProductID id() const
Accessor for product ID.
Definition: Ref.h:256
volatile std::atomic< bool > shutdown_flag false
edm::EDGetTokenT< reco::BeamSpot > beamSpotTag_
edm::EDGetTokenT< std::vector< reco::Vertex > > token_vtx
ElectronHcalHelper * hcalHelper_
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
edm::EDGetTokenT< std::vector< reco::Vertex > > token_vtx
Definition: SeedFilter.h:36
Definition: Run.h:41
virtual void produce(edm::Event &, const edm::EventSetup &) overridefinal