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 
28 
33 
38 
45 
46 #include <string>
47 
48 using namespace reco ;
49 
51  : //conf_(iConfig),
52  seedFilter_(0), applyHOverECut_(true), hcalHelper_(0),
53  caloGeom_(0), caloGeomCacheId_(0), caloTopo_(0), caloTopoCacheId_(0)
54  {
55  conf_ = iConfig.getParameter<edm::ParameterSet>("SeedConfiguration") ;
56 
57  initialSeeds_ = consumes<TrajectorySeedCollection>(conf_.getParameter<edm::InputTag>("initialSeeds")) ;
58  SCEtCut_ = conf_.getParameter<double>("SCEtCut") ;
59  fromTrackerSeeds_ = conf_.getParameter<bool>("fromTrackerSeeds") ;
60  prefilteredSeeds_ = conf_.getParameter<bool>("preFilteredSeeds") ;
61 
62  // new beamSpot tag
63  if (conf_.exists("beamSpot")) {
64  beamSpotTag_ = consumes<reco::BeamSpot>(conf_.getParameter<edm::InputTag>("beamSpot"));
65  } else {
66  beamSpotTag_ = consumes<reco::BeamSpot>(edm::InputTag("offlineBeamSpot"));
67  }
68 
69  // for H/E
70 // if (conf_.exists("applyHOverECut"))
71 // { applyHOverECut_ = conf_.getParameter<bool>("applyHOverECut") ; }
72  applyHOverECut_ = conf_.getParameter<bool>("applyHOverECut") ;
73  if (applyHOverECut_)
74  {
76  hcalCfg.hOverEConeSize = conf_.getParameter<double>("hOverEConeSize") ;
77  if (hcalCfg.hOverEConeSize>0)
78  {
79  hcalCfg.useTowers = true ;
80  hcalCfg.hcalTowers =
81  consumes<CaloTowerCollection>(conf_.getParameter<edm::InputTag>("hcalTowers")) ;
82  hcalCfg.hOverEPtMin = conf_.getParameter<double>("hOverEPtMin") ;
83  }
84  hcalHelper_ = new ElectronHcalHelper(hcalCfg) ;
85  maxHOverEBarrel_=conf_.getParameter<double>("maxHOverEBarrel") ;
86  maxHOverEEndcaps_=conf_.getParameter<double>("maxHOverEEndcaps") ;
87  maxHBarrel_=conf_.getParameter<double>("maxHBarrel") ;
88  maxHEndcaps_=conf_.getParameter<double>("maxHEndcaps") ;
89 // hOverEConeSize_=conf_.getParameter<double>("hOverEConeSize") ;
90 // hOverEHBMinE_=conf_.getParameter<double>("hOverEHBMinE") ;
91 // hOverEHFMinE_=conf_.getParameter<double>("hOverEHFMinE") ;
92  }
93 
94  if( conf_.exists("RegionPSet") ) {
95  edm::ParameterSet rpset =
96  conf_.getParameter<edm::ParameterSet>("RegionPSet");
97  filterVtxTag_ =
98  consumes<std::vector<reco::Vertex> >(rpset.getParameter<edm::InputTag> ("VertexProducer"));
99  }
100 
102  esg_tokens.token_bs = beamSpotTag_;
103  if(conf_.exists("vertices")) {
104  esg_tokens.token_vtx =
105  mayConsume<reco::VertexCollection>(conf_.getParameter<edm::InputTag>("vertices"));
106  } else {
107  esg_tokens.token_vtx =
108  mayConsume<reco::VertexCollection>(edm::InputTag("offlinePrimaryVerticesWithBS"));
109  }
110  matcher_ = new ElectronSeedGenerator(conf_,esg_tokens) ;
111 
112  // get collections from config'
113  superClusters_[0]=
114  consumes<reco::SuperClusterCollection>(iConfig.getParameter<edm::InputTag>("barrelSuperClusters")) ;
115  superClusters_[1]=
116  consumes<reco::SuperClusterCollection>(iConfig.getParameter<edm::InputTag>("endcapSuperClusters")) ;
117 
118  //register your products
119  produces<ElectronSeedCollection>() ;
120 }
121 
122 
124  // FIXME: because of a bug presumably in tracker seeding,
125  // perhaps in CombinedHitPairGenerator, badly caching some EventSetup product,
126  // we must redo the SeedFilter for each run.
127  if (prefilteredSeeds_) {
128  SeedFilter::Tokens sf_tokens;
129  sf_tokens.token_bs = beamSpotTag_;
130  sf_tokens.token_vtx = filterVtxTag_;
131  seedFilter_ = new SeedFilter(conf_,sf_tokens) ;
132  }
133 }
134 
136  {
137  delete seedFilter_ ;
138  seedFilter_ = 0 ;
139  }
140 
142  {
143  delete hcalHelper_ ;
144  delete matcher_ ;
145  }
146 
148  {
149  LogDebug("ElectronSeedProducer") <<"[ElectronSeedProducer::produce] entering " ;
150 
151  edm::Handle<reco::BeamSpot> theBeamSpot ;
152  e.getByToken(beamSpotTag_,theBeamSpot) ;
153 
154  if (hcalHelper_)
155  {
156  hcalHelper_->checkSetup(iSetup) ;
157  hcalHelper_->readEvent(e) ;
158  }
159 
160  // get calo geometry
162  iSetup.get<CaloGeometryRecord>().get(caloGeom_);
163  caloGeomCacheId_=iSetup.get<CaloGeometryRecord>().cacheIdentifier();
164  }
166  caloTopoCacheId_=iSetup.get<CaloTopologyRecord>().cacheIdentifier();
167  iSetup.get<CaloTopologyRecord>().get(caloTopo_);
168  }
169 
170  matcher_->setupES(iSetup);
171 
172  // get initial TrajectorySeeds if necessary
173  if (fromTrackerSeeds_)
174  {
175  if (!prefilteredSeeds_)
176  {
178  e.getByToken(initialSeeds_, hSeeds);
179  theInitialSeedColl = const_cast<TrajectorySeedCollection *> (hSeeds.product());
180  }
181  else
183  }
184  else
185  { theInitialSeedColl = 0 ; } // not needed in this case
186 
188 
189  // loop over barrel + endcap
190  for (unsigned int i=0; i<2; i++) {
192  e.getByToken(superClusters_[i],clusters);
193  SuperClusterRefVector clusterRefs ;
194  std::vector<float> hoe1s, hoe2s ;
195  filterClusters(*theBeamSpot,clusters,/*mhbhe_,*/clusterRefs,hoe1s,hoe2s);
197  { filterSeeds(e,iSetup,clusterRefs) ; }
198  matcher_->run(e,iSetup,clusterRefs,hoe1s,hoe2s,theInitialSeedColl,*seeds);
199  }
200 
201  // store the accumulated result
202  std::auto_ptr<ElectronSeedCollection> pSeeds(seeds) ;
203  ElectronSeedCollection::iterator is ;
204  for ( is=pSeeds->begin() ; is!=pSeeds->end() ; is++ ) {
205  edm::RefToBase<CaloCluster> caloCluster = is->caloCluster() ;
206  SuperClusterRef superCluster = caloCluster.castTo<SuperClusterRef>() ;
207  LogDebug("ElectronSeedProducer")
208  << "new seed with "
209  << (*is).nHits() << " hits"
210  << ", charge " << (*is).getCharge()
211  << " and cluster energy " << superCluster->energy()
212  << " PID "<<superCluster.id() ;
213  }
214  e.put(pSeeds) ;
216  }
217 
218 
219 //===============================
220 // Filter the superclusters
221 // - with EtCut
222 // - with HoE using calo cone
223 //===============================
224 
226  ( const reco::BeamSpot & bs,
227  const edm::Handle<reco::SuperClusterCollection> & superClusters,
228  /*HBHERecHitMetaCollection * mhbhe,*/ SuperClusterRefVector & sclRefs,
229  std::vector<float> & hoe1s, std::vector<float> & hoe2s )
230  {
231  for (unsigned int i=0;i<superClusters->size();++i)
232  {
233  const SuperCluster & scl = (*superClusters)[i] ;
234  double sclEta = EleRelPoint(scl.position(),bs.position()).eta() ;
235  if (scl.energy()/cosh(sclEta)>SCEtCut_)
236  {
237 // if ((applyHOverECut_==true)&&((hcalHelper_->hcalESum(scl)/scl.energy()) > maxHOverE_))
238 // { continue ; }
239 // sclRefs.push_back(edm::Ref<reco::SuperClusterCollection>(superClusters,i)) ;
240  double had1, had2, had, scle ;
241  bool HoeVeto = false ;
242  if (applyHOverECut_==true)
243  {
244  had1 = hcalHelper_->hcalESumDepth1(scl);
245  had2 = hcalHelper_->hcalESumDepth2(scl);
246  had = had1+had2 ;
247  scle = scl.energy() ;
248  int detector = scl.seed()->hitsAndFractions()[0].first.subdetId() ;
249  if (detector==EcalBarrel && (had<maxHBarrel_ || had/scle<maxHOverEBarrel_)) HoeVeto=true;
250  else if (detector==EcalEndcap && (had<maxHEndcaps_ || had/scle<maxHOverEEndcaps_)) HoeVeto=true;
251  if (HoeVeto)
252  {
253  sclRefs.push_back(edm::Ref<reco::SuperClusterCollection>(superClusters,i)) ;
254  hoe1s.push_back(had1/scle) ;
255  hoe2s.push_back(had2/scle) ;
256  }
257  }
258  else
259  {
260  sclRefs.push_back(edm::Ref<reco::SuperClusterCollection>(superClusters,i)) ;
261  hoe1s.push_back(std::numeric_limits<float>::infinity()) ;
262  hoe2s.push_back(std::numeric_limits<float>::infinity()) ;
263  }
264  }
265  }
266  LogDebug("ElectronSeedProducer")<<"Filtered out "<<sclRefs.size()<<" superclusters from "<<superClusters->size() ;
267  }
268 
271  reco::SuperClusterRefVector & sclRefs )
272  {
273  for ( unsigned int i=0 ; i<sclRefs.size() ; ++i )
274  {
275  seedFilter_->seeds(event,setup,sclRefs[i],theInitialSeedColl) ;
276  LogDebug("ElectronSeedProducer")<<"Number of Seeds: "<<theInitialSeedColl->size() ;
277  }
278  }
#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
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::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
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
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:33
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:32
Definition: Run.h:41
virtual void produce(edm::Event &, const edm::EventSetup &) overridefinal