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 // $Id: ElectronSeedProducer.cc,v 1.23 2011/01/14 21:25:58 chamont Exp $
17 //
18 //
19 
20 #include "ElectronSeedProducer.h"
21 
23 //#include "DataFormats/RecoCandidate/interface/RecoCandidate.h"
24 
29 
34 
39 
46 
47 #include <string>
48 
49 using namespace reco ;
50 
52  : beamSpotTag_("offlineBeamSpot"),
53  //conf_(iConfig),
54  seedFilter_(0), applyHOverECut_(true), hcalHelper_(0),
55  caloGeom_(0), caloGeomCacheId_(0), caloTopo_(0), caloTopoCacheId_(0)
56  {
57  conf_ = iConfig.getParameter<edm::ParameterSet>("SeedConfiguration") ;
58 
59  initialSeeds_ = 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_ = conf_.getParameter<edm::InputTag>("beamSpot") ; }
67 
68  // for H/E
69 // if (conf_.exists("applyHOverECut"))
70 // { applyHOverECut_ = conf_.getParameter<bool>("applyHOverECut") ; }
71  applyHOverECut_ = conf_.getParameter<bool>("applyHOverECut") ;
72  if (applyHOverECut_)
73  {
75  hcalCfg.hOverEConeSize = conf_.getParameter<double>("hOverEConeSize") ;
76  if (hcalCfg.hOverEConeSize>0)
77  {
78  hcalCfg.useTowers = true ;
79  hcalCfg.hcalTowers = conf_.getParameter<edm::InputTag>("hcalTowers") ;
80  hcalCfg.hOverEPtMin = conf_.getParameter<double>("hOverEPtMin") ;
81  }
82  hcalHelper_ = new ElectronHcalHelper(hcalCfg) ;
83  maxHOverEBarrel_=conf_.getParameter<double>("maxHOverEBarrel") ;
84  maxHOverEEndcaps_=conf_.getParameter<double>("maxHOverEEndcaps") ;
85  maxHBarrel_=conf_.getParameter<double>("maxHBarrel") ;
86  maxHEndcaps_=conf_.getParameter<double>("maxHEndcaps") ;
87 // hOverEConeSize_=conf_.getParameter<double>("hOverEConeSize") ;
88 // hOverEHBMinE_=conf_.getParameter<double>("hOverEHBMinE") ;
89 // hOverEHFMinE_=conf_.getParameter<double>("hOverEHFMinE") ;
90  }
91 
93 
94  // get collections from config'
95  superClusters_[0]=iConfig.getParameter<edm::InputTag>("barrelSuperClusters") ;
96  superClusters_[1]=iConfig.getParameter<edm::InputTag>("endcapSuperClusters") ;
97 
98  //register your products
99  produces<ElectronSeedCollection>() ;
100 }
101 
102 
104  {
105  // FIXME: because of a bug presumably in tracker seeding,
106  // perhaps in CombinedHitPairGenerator, badly caching some EventSetup product,
107  // we must redo the SeedFilter for each run.
109  }
110 
112  {
113  delete seedFilter_ ;
114  seedFilter_ = 0 ;
115  }
116 
118  {
119  delete hcalHelper_ ;
120  delete matcher_ ;
121  }
122 
124  {
125  LogDebug("ElectronSeedProducer") <<"[ElectronSeedProducer::produce] entering " ;
126 
127  edm::Handle<reco::BeamSpot> theBeamSpot ;
128  e.getByLabel(beamSpotTag_,theBeamSpot) ;
129 
130  if (hcalHelper_)
131  {
132  hcalHelper_->checkSetup(iSetup) ;
133  hcalHelper_->readEvent(e) ;
134  }
135 
136  // get calo geometry
138  iSetup.get<CaloGeometryRecord>().get(caloGeom_);
139  caloGeomCacheId_=iSetup.get<CaloGeometryRecord>().cacheIdentifier();
140  }
142  caloTopoCacheId_=iSetup.get<CaloTopologyRecord>().cacheIdentifier();
143  iSetup.get<CaloTopologyRecord>().get(caloTopo_);
144  }
145 
146  matcher_->setupES(iSetup);
147 
148  // get initial TrajectorySeeds if necessary
149  if (fromTrackerSeeds_)
150  {
151  if (!prefilteredSeeds_)
152  {
154  e.getByLabel(initialSeeds_, hSeeds);
155  theInitialSeedColl = const_cast<TrajectorySeedCollection *> (hSeeds.product());
156  }
157  else
159  }
160  else
161  { theInitialSeedColl = 0 ; } // not needed in this case
162 
164 
165  // loop over barrel + endcap
166  for (unsigned int i=0; i<2; i++)
167  {
169  if (e.getByLabel(superClusters_[i],clusters))
170  {
171  SuperClusterRefVector clusterRefs ;
172  std::vector<float> hoe1s, hoe2s ;
173  filterClusters(*theBeamSpot,clusters,/*mhbhe_,*/clusterRefs,hoe1s,hoe2s) ;
175  { filterSeeds(e,iSetup,clusterRefs) ; }
176  matcher_->run(e,iSetup,clusterRefs,hoe1s,hoe2s,theInitialSeedColl,*seeds) ;
177  }
178  }
179 
180  // store the accumulated result
181  std::auto_ptr<ElectronSeedCollection> pSeeds(seeds) ;
182  ElectronSeedCollection::iterator is ;
183  for ( is=pSeeds->begin() ; is!=pSeeds->end() ; is++ )
184  {
185  edm::RefToBase<CaloCluster> caloCluster = is->caloCluster() ;
186  SuperClusterRef superCluster = caloCluster.castTo<SuperClusterRef>() ;
187  LogDebug("ElectronSeedProducer")<< "new seed with "
188  << (*is).nHits() << " hits"
189  << ", charge " << (*is).getCharge()
190  << " and cluster energy " << superCluster->energy()
191  << " PID "<<superCluster.id() ;
192  }
193  e.put(pSeeds) ;
195  }
196 
197 
198 //===============================
199 // Filter the superclusters
200 // - with EtCut
201 // - with HoE using calo cone
202 //===============================
203 
205  ( const reco::BeamSpot & bs,
206  const edm::Handle<reco::SuperClusterCollection> & superClusters,
207  /*HBHERecHitMetaCollection * mhbhe,*/ SuperClusterRefVector & sclRefs,
208  std::vector<float> & hoe1s, std::vector<float> & hoe2s )
209  {
210  for (unsigned int i=0;i<superClusters->size();++i)
211  {
212  const SuperCluster & scl = (*superClusters)[i] ;
213  double sclEta = EleRelPoint(scl.position(),bs.position()).eta() ;
214  if (scl.energy()/cosh(sclEta)>SCEtCut_)
215  {
216 // if ((applyHOverECut_==true)&&((hcalHelper_->hcalESum(scl)/scl.energy()) > maxHOverE_))
217 // { continue ; }
218 // sclRefs.push_back(edm::Ref<reco::SuperClusterCollection>(superClusters,i)) ;
219  double had1, had2, had, scle ;
220  bool HoeVeto = false ;
221  if (applyHOverECut_==true)
222  {
223  had1 = hcalHelper_->hcalESumDepth1(scl);
224  had2 = hcalHelper_->hcalESumDepth2(scl);
225  had = had1+had2 ;
226  scle = scl.energy() ;
227  int detector = scl.seed()->hitsAndFractions()[0].first.subdetId() ;
228  if (detector==EcalBarrel && (had<maxHBarrel_ || had/scle<maxHOverEBarrel_)) HoeVeto=true;
229  else if (detector==EcalEndcap && (had<maxHEndcaps_ || had/scle<maxHOverEEndcaps_)) HoeVeto=true;
230  if (HoeVeto)
231  {
232  sclRefs.push_back(edm::Ref<reco::SuperClusterCollection>(superClusters,i)) ;
233  hoe1s.push_back(had1/scle) ;
234  hoe2s.push_back(had2/scle) ;
235  }
236  }
237  else
238  {
239  sclRefs.push_back(edm::Ref<reco::SuperClusterCollection>(superClusters,i)) ;
240  hoe1s.push_back(std::numeric_limits<float>::infinity()) ;
241  hoe2s.push_back(std::numeric_limits<float>::infinity()) ;
242  }
243  }
244  }
245  LogDebug("ElectronSeedProducer")<<"Filtered out "<<sclRefs.size()<<" superclusters from "<<superClusters->size() ;
246  }
247 
250  reco::SuperClusterRefVector & sclRefs )
251  {
252  for ( unsigned int i=0 ; i<sclRefs.size() ; ++i )
253  {
254  seedFilter_->seeds(event,setup,sclRefs[i],theInitialSeedColl) ;
255  LogDebug("ElectronSeedProducer")<<"Number of Seeds: "<<theInitialSeedColl->size() ;
256  }
257  }
#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:123
int i
Definition: DBlmapReader.cc:9
virtual void beginRun(edm::Run &, edm::EventSetup const &)
void readEvent(const edm::Event &)
void setupES(const edm::EventSetup &setup)
unsigned long long caloGeomCacheId_
bool exists(std::string const &parameterName) const
checks if a parameter exists
void checkSetup(const edm::EventSetup &)
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:85
const double infinity
ElectronSeedProducer(const edm::ParameterSet &)
double energy() const
cluster energy
Definition: CaloCluster.h:120
std::vector< ElectronSeed > ElectronSeedCollection
collection of ElectronSeed objects
virtual void produce(edm::Event &, const edm::EventSetup &)
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
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
edm::InputTag superClusters_[2]
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
T const * product() const
Definition: Handle.h:74
unsigned long long caloTopoCacheId_
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
const Point & position() const
position
Definition: BeamSpot.h:63
const CaloClusterPtr & seed() const
seed BasicCluster
Definition: SuperCluster.h:62
ProductID id() const
Accessor for product ID.
Definition: Ref.h:256
ElectronHcalHelper * hcalHelper_
virtual void endRun(edm::Run &, edm::EventSetup const &)
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
Definition: Run.h:33