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 
28 
33 
38 
46 
47 #include <string>
48 
49 using namespace reco ;
50 
52  : //conf_(iConfig),
53  applyHOverECut_(true), hcalHelper_(0),
54  caloGeom_(0), caloGeomCacheId_(0), caloTopo_(0), caloTopoCacheId_(0)
55  {
56  conf_ = iConfig.getParameter<edm::ParameterSet>("SeedConfiguration") ;
57 
58  initialSeeds_ = consumes<TrajectorySeedCollection>(conf_.getParameter<edm::InputTag>("initialSeeds")) ;
59  SCEtCut_ = conf_.getParameter<double>("SCEtCut") ;
60  fromTrackerSeeds_ = conf_.getParameter<bool>("fromTrackerSeeds") ;
61  prefilteredSeeds_ = conf_.getParameter<bool>("preFilteredSeeds") ;
62 
63  // new beamSpot tag
64  beamSpotTag_ = consumes<reco::BeamSpot>(conf_.getParameter<edm::InputTag>("beamSpot"));
65 
66  // for H/E
67  applyHOverECut_ = conf_.getParameter<bool>("applyHOverECut") ;
68  if (applyHOverECut_)
69  {
71  hcalCfg.hOverEConeSize = conf_.getParameter<double>("hOverEConeSize") ;
72  if (hcalCfg.hOverEConeSize>0)
73  {
74  hcalCfg.useTowers = true ;
75  hcalCfg.hcalTowers =
76  consumes<CaloTowerCollection>(conf_.getParameter<edm::InputTag>("hcalTowers")) ;
77  hcalCfg.hOverEPtMin = conf_.getParameter<double>("hOverEPtMin") ;
78  }
79  hcalHelper_ = new ElectronHcalHelper(hcalCfg) ;
80  maxHOverEBarrel_=conf_.getParameter<double>("maxHOverEBarrel") ;
81  maxHOverEEndcaps_=conf_.getParameter<double>("maxHOverEEndcaps") ;
82  maxHBarrel_=conf_.getParameter<double>("maxHBarrel") ;
83  maxHEndcaps_=conf_.getParameter<double>("maxHEndcaps") ;
84  }
85 
87  filterVtxTag_ = consumes<std::vector<reco::Vertex> >(rpset.getParameter<edm::InputTag> ("VertexProducer"));
88 
90  esg_tokens.token_bs = beamSpotTag_;
91  esg_tokens.token_vtx = mayConsume<reco::VertexCollection>(conf_.getParameter<edm::InputTag>("vertices"));
92  esg_tokens.token_measTrkEvt= consumes<MeasurementTrackerEvent>(conf_.getParameter<edm::InputTag>("measurementTrackerEvent"));
93 
94  matcher_ = new ElectronSeedGenerator(conf_,esg_tokens) ;
95 
96  // get collections from config'
97  superClusters_[0]=
98  consumes<reco::SuperClusterCollection>(iConfig.getParameter<edm::InputTag>("barrelSuperClusters")) ;
99  superClusters_[1]=
100  consumes<reco::SuperClusterCollection>(iConfig.getParameter<edm::InputTag>("endcapSuperClusters")) ;
101 
102  // Construction of SeedFilter was in beginRun() with the comment
103  // below, but it has to be done here because of ConsumesCollector
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.
108  if (prefilteredSeeds_) {
109  SeedFilter::Tokens sf_tokens;
110  sf_tokens.token_bs = beamSpotTag_;
111  sf_tokens.token_vtx = filterVtxTag_;
113  seedFilter_.reset(new SeedFilter(conf_, sf_tokens, iC));
114  }
115 
116  //register your products
117  produces<ElectronSeedCollection>() ;
118 }
119 
121 {}
122 
124 {}
125 
127  {
128  delete hcalHelper_ ;
129  delete matcher_ ;
130  }
131 
133  {
134  LogDebug("ElectronSeedProducer") <<"[ElectronSeedProducer::produce] entering " ;
135 
136  edm::Handle<reco::BeamSpot> theBeamSpot ;
137  e.getByToken(beamSpotTag_,theBeamSpot) ;
138 
139  if (hcalHelper_)
140  {
141  hcalHelper_->checkSetup(iSetup) ;
142  hcalHelper_->readEvent(e) ;
143  }
144 
145  // get calo geometry
147  iSetup.get<CaloGeometryRecord>().get(caloGeom_);
148  caloGeomCacheId_=iSetup.get<CaloGeometryRecord>().cacheIdentifier();
149  }
151  caloTopoCacheId_=iSetup.get<CaloTopologyRecord>().cacheIdentifier();
152  iSetup.get<CaloTopologyRecord>().get(caloTopo_);
153  }
154 
155  matcher_->setupES(iSetup);
156 
157  // get initial TrajectorySeeds if necessary
158  if (fromTrackerSeeds_)
159  {
160  if (!prefilteredSeeds_)
161  {
163  e.getByToken(initialSeeds_, hSeeds);
164  theInitialSeedColl = const_cast<TrajectorySeedCollection *> (hSeeds.product());
165  }
166  else
168  }
169  else
170  { theInitialSeedColl = 0 ; } // not needed in this case
171 
173 
174  // loop over barrel + endcap
175  for (unsigned int i=0; i<2; i++) {
177  e.getByToken(superClusters_[i],clusters);
178  SuperClusterRefVector clusterRefs ;
179  std::vector<float> hoe1s, hoe2s ;
180  filterClusters(*theBeamSpot,clusters,/*mhbhe_,*/clusterRefs,hoe1s,hoe2s);
182  { filterSeeds(e,iSetup,clusterRefs) ; }
183  matcher_->run(e,iSetup,clusterRefs,hoe1s,hoe2s,theInitialSeedColl,*seeds);
184  }
185 
186  // store the accumulated result
187  std::auto_ptr<ElectronSeedCollection> pSeeds(seeds) ;
188  ElectronSeedCollection::iterator is ;
189  for ( is=pSeeds->begin() ; is!=pSeeds->end() ; is++ ) {
190  edm::RefToBase<CaloCluster> caloCluster = is->caloCluster() ;
191  SuperClusterRef superCluster = caloCluster.castTo<SuperClusterRef>() ;
192  LogDebug("ElectronSeedProducer")
193  << "new seed with "
194  << (*is).nHits() << " hits"
195  << ", charge " << (*is).getCharge()
196  << " and cluster energy " << superCluster->energy()
197  << " PID "<<superCluster.id() ;
198  }
199  e.put(pSeeds) ;
201  }
202 
203 
204 //===============================
205 // Filter the superclusters
206 // - with EtCut
207 // - with HoE using calo cone
208 //===============================
209 
211  ( const reco::BeamSpot & bs,
212  const edm::Handle<reco::SuperClusterCollection> & superClusters,
213  SuperClusterRefVector & sclRefs,
214  std::vector<float> & hoe1s, std::vector<float> & hoe2s )
215  {
216  for (unsigned int i=0;i<superClusters->size();++i)
217  {
218  const SuperCluster & scl = (*superClusters)[i] ;
219  double sclEta = EleRelPoint(scl.position(),bs.position()).eta() ;
220  if (scl.energy()/cosh(sclEta)>SCEtCut_)
221  {
222 // if ((applyHOverECut_==true)&&((hcalHelper_->hcalESum(scl)/scl.energy()) > maxHOverE_))
223 // { continue ; }
224 // sclRefs.push_back(edm::Ref<reco::SuperClusterCollection>(superClusters,i)) ;
225  double had1, had2, had, scle ;
226  bool HoeVeto = false ;
227  if (applyHOverECut_==true)
228  {
229  had1 = hcalHelper_->hcalESumDepth1(scl);
230  had2 = hcalHelper_->hcalESumDepth2(scl);
231  had = had1+had2 ;
232  scle = scl.energy() ;
233  int detector = scl.seed()->hitsAndFractions()[0].first.subdetId() ;
234  if (detector==EcalBarrel && (had<maxHBarrel_ || had/scle<maxHOverEBarrel_)) HoeVeto=true;
235  else if (detector==EcalEndcap && (had<maxHEndcaps_ || had/scle<maxHOverEEndcaps_)) HoeVeto=true;
236  if (HoeVeto)
237  {
238  sclRefs.push_back(edm::Ref<reco::SuperClusterCollection>(superClusters,i)) ;
239  hoe1s.push_back(had1/scle) ;
240  hoe2s.push_back(had2/scle) ;
241  }
242  }
243  else
244  {
245  sclRefs.push_back(edm::Ref<reco::SuperClusterCollection>(superClusters,i)) ;
246  hoe1s.push_back(std::numeric_limits<float>::infinity()) ;
247  hoe2s.push_back(std::numeric_limits<float>::infinity()) ;
248  }
249  }
250  }
251  LogDebug("ElectronSeedProducer")<<"Filtered out "<<sclRefs.size()<<" superclusters from "<<superClusters->size() ;
252  }
253 
256  reco::SuperClusterRefVector & sclRefs )
257  {
258  for ( unsigned int i=0 ; i<sclRefs.size() ; ++i )
259  {
260  seedFilter_->seeds(event,setup,sclRefs[i],theInitialSeedColl) ;
261  LogDebug("ElectronSeedProducer")<<"Number of Seeds: "<<theInitialSeedColl->size() ;
262  }
263  }
264 
265 void
268  desc.add<edm::InputTag>("endcapSuperClusters",edm::InputTag("particleFlowSuperClusterECAL","particleFlowSuperClusterECALEndcapWithPreshower"));
269  {
270  edm::ParameterSetDescription psd0, psd1, psd2, psd3;
271  psd1.add<unsigned int>("maxElement", 0);
272  psd1.add<std::string>("ComponentName", std::string("StandardHitPairGenerator"));
273  psd1.addUntracked<int>("useOnDemandTracker", 0);
274  psd1.add<edm::InputTag>("SeedingLayers", edm::InputTag("hltMixedLayerPairs"));
275  psd0.add<edm::ParameterSetDescription>("OrderedHitsFactoryPSet", psd1);
276 
277  psd2.add<double>("deltaPhiRegion", 0.4);
278  psd2.add<double>("originHalfLength", 15.0);
279  psd2.add<bool>("useZInVertex", true);
280  psd2.add<double>("deltaEtaRegion", 0.1);
281  psd2.add<double>("ptMin", 1.5 );
282  psd2.add<double>("originRadius", 0.2);
283  psd2.add<edm::InputTag>("VertexProducer", edm::InputTag("dummyVertices"));
284  psd0.add<edm::ParameterSetDescription>("RegionPSet", psd2);
285 
286  psd0.add<double>("PhiMax2B",0.002);
287  psd0.add<double>("hOverEPtMin",0.0);
288  psd0.add<double>("PhiMax2F",0.003);
289  psd0.add<bool>("searchInTIDTEC",true);
290  psd0.add<double>("pPhiMax1",0.125);
291  psd0.add<double>("HighPtThreshold",35.0);
292  psd0.add<double>("r2MinF",-0.15);
293  psd0.add<double>("maxHBarrel",0.0);
294  psd0.add<double>("DeltaPhi1Low",0.23);
295  psd0.add<double>("DeltaPhi1High",0.08);
296  psd0.add<double>("ePhiMin1",-0.125);
297  psd0.add<edm::InputTag>("hcalTowers",edm::InputTag("towerMaker"));
298  psd0.add<double>("LowPtThreshold",5.0);
299  psd0.add<double>("maxHOverEBarrel",0.15);
300  psd0.add<bool>("dynamicPhiRoad",true);
301  psd0.add<double>("ePhiMax1",0.075);
302  psd0.add<std::string>("measurementTrackerName","");
303  psd0.add<double>("SizeWindowENeg",0.675);
304  psd0.add<double>("nSigmasDeltaZ1",5.0);
305  psd0.add<double>("rMaxI",0.2);
306  psd0.add<double>("maxHEndcaps",0.0);
307  psd0.add<bool>("preFilteredSeeds",false);
308  psd0.add<double>("r2MaxF",0.15);
309  psd0.add<double>("hOverEConeSize",0.15);
310  psd0.add<double>("pPhiMin1",-0.075);
311  psd0.add<edm::InputTag>("initialSeeds",edm::InputTag("newCombinedSeeds"));
312  psd0.add<double>("deltaZ1WithVertex",25.0);
313  psd0.add<double>("SCEtCut",0.0);
314  psd0.add<double>("z2MaxB",0.09);
315  psd0.add<bool>("fromTrackerSeeds",true);
316  psd0.add<edm::InputTag>("hcalRecHits",edm::InputTag("hbhereco"));
317  psd0.add<double>("z2MinB",-0.09);
318  psd0.add<double>("rMinI",-0.2);
319  psd0.add<double>("maxHOverEEndcaps",0.15);
320  psd0.add<double>("hOverEHBMinE",0.7);
321  psd0.add<bool>("useRecoVertex",false);
322  psd0.add<edm::InputTag>("beamSpot",edm::InputTag("offlineBeamSpot"));
323  psd0.add<edm::InputTag>("measurementTrackerEvent",edm::InputTag("MeasurementTrackerEvent"));
324  psd0.add<edm::InputTag>("vertices",edm::InputTag("offlinePrimaryVerticesWithBS"));
325  psd0.add<bool>("applyHOverECut",true);
326  psd0.add<double>("DeltaPhi2F",0.012);
327  psd0.add<double>("PhiMin2F",-0.003);
328  psd0.add<double>("hOverEHFMinE",0.8);
329  psd0.add<double>("DeltaPhi2B",0.008);
330  psd0.add<double>("PhiMin2B",-0.002);
331 
332  psd3.add<std::string>("ComponentName",std::string("SeedFromConsecutiveHitsCreator"));
333  psd3.add<std::string>("propagator",std::string("PropagatorWithMaterial"));
334  psd3.add<double>("SeedMomentumForBOFF",5.0);
335  psd3.add<double>("OriginTransverseErrorMultiplier",1.0);
336  psd3.add<double>("MinOneOverPtError",1.0);
337  psd3.add<std::string>("magneticField",std::string(""));
338  psd3.add<std::string>("TTRHBuilder",std::string("WithTrackAngle"));
339  psd3.add<bool>("forceKinematicWithRegionDirection",false);
340  psd0.add<edm::ParameterSetDescription>("SeedCreatorPSet",psd3);
341 
342  desc.add<edm::ParameterSetDescription>("SeedConfiguration",psd0);
343  }
344  desc.add<edm::InputTag>("barrelSuperClusters",edm::InputTag("particleFlowSuperClusterECAL","particleFlowSuperClusterECALBarrel"));
345  descriptions.add("ecalDrivenElectronSeeds",desc);
346 }
#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:126
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 &)
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
void setupES(const edm::EventSetup &setup)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:449
virtual void beginRun(edm::Run const &, edm::EventSetup const &) overridefinal
unsigned long long caloGeomCacheId_
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 &)
ProductID id() const
Accessor for product ID.
Definition: Ref.h:256
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:113
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:121
std::vector< ElectronSeed > ElectronSeedCollection
collection of ElectronSeed objects
ParameterDescriptionBase * add(U const &iLabel, T const &value)
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
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::unique_ptr< SeedFilter > seedFilter_
edm::ParameterSet conf_
edm::ESHandle< CaloGeometry > caloGeom_
T const * product() const
Definition: Handle.h:81
ElectronSeedGenerator * matcher_
TrajectorySeedCollection * theInitialSeedColl
REF castTo() const
cast to a concrete type
Definition: RefToBase.h:241
const T & get() const
Definition: EventSetup.h:55
void add(std::string const &label, ParameterSetDescription const &psetDescription)
edm::EDGetTokenT< reco::SuperClusterCollection > superClusters_[2]
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
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