CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EgammaHLTHybridClusterProducer.cc
Go to the documentation of this file.
1 // C/C++ headers
2 #include <iostream>
3 #include <vector>
4 #include <memory>
5 
6 // Framework
10 
13 
14 // Reconstruction Classes
25 
26 // Geometry
34 
35 // Level 1 Trigger
38 
39 // EgammaCoreTools
42 
43 // Class header file
45 
46 
48 
49  basicclusterCollection_ = ps.getParameter<std::string>("basicclusterCollection");
50  superclusterCollection_ = ps.getParameter<std::string>("superclusterCollection");
51  hitcollection_ = ps.getParameter<edm::InputTag>("ecalhitcollection");
52  hittoken_ = consumes<EcalRecHitCollection>(hitcollection_);
53 
54  // L1 matching parameters
55  l1TagIsolated_ = consumes<l1extra::L1EmParticleCollection>(ps.getParameter< edm::InputTag > ("l1TagIsolated"));
56  l1TagNonIsolated_ = consumes<l1extra::L1EmParticleCollection>(ps.getParameter< edm::InputTag > ("l1TagNonIsolated"));
57 
58  doIsolated_ = ps.getParameter<bool>("doIsolated");
59 
60  l1LowerThr_ = ps.getParameter<double> ("l1LowerThr");
61  l1UpperThr_ = ps.getParameter<double> ("l1UpperThr");
62  l1LowerThrIgnoreIsolation_ = ps.getParameter<double> ("l1LowerThrIgnoreIsolation");
63 
64  regionEtaMargin_ = ps.getParameter<double>("regionEtaMargin");
65  regionPhiMargin_ = ps.getParameter<double>("regionPhiMargin");
66 
67  // Parameters for the position calculation:
68  posCalculator_ = PositionCalc( ps.getParameter<edm::ParameterSet>("posCalcParameters") );
69 
70  const std::vector<std::string> flagnames =
71  ps.getParameter<std::vector<std::string> >("RecHitFlagToBeExcluded");
72 
73  const std::vector<int> flagsexcl=
74  StringToEnumValue<EcalRecHit::Flags>(flagnames);
75 
76  const std::vector<std::string> severitynames =
77  ps.getParameter<std::vector<std::string> >("RecHitSeverityToBeExcluded");
78 
79  const std::vector<int> severitiesexcl=
80  StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynames);
81 
82 
83  hybrid_p = new HybridClusterAlgo(ps.getParameter<double>("HybridBarrelSeedThr"),
84  ps.getParameter<int>("step"),
85  ps.getParameter<double>("ethresh"),
86  ps.getParameter<double>("eseed"),
87  ps.getParameter<double>("xi"),
88  ps.getParameter<bool>("useEtForXi"),
89  ps.getParameter<double>("ewing"),
90  flagsexcl,
91  posCalculator_,
92  ps.getParameter<bool>("dynamicEThresh"),
93  ps.getParameter<double>("eThreshA"),
94  ps.getParameter<double>("eThreshB"),
95  severitiesexcl,
96  ps.getParameter<bool>("excludeFlagged")
97  );
98 
99  bool dynamicPhiRoad = ps.getParameter<bool>("dynamicPhiRoad");
100  if (dynamicPhiRoad) {
101  edm::ParameterSet bremRecoveryPset = ps.getParameter<edm::ParameterSet>("bremRecoveryPset");
102  hybrid_p->setDynamicPhiRoad(bremRecoveryPset);
103  }
104 
105  produces< reco::BasicClusterCollection >(basicclusterCollection_);
106  produces< reco::SuperClusterCollection >(superclusterCollection_);
107  nEvt_ = 0;
108 }
109 
110 
112 {
113  delete hybrid_p;
114 }
115 
117 
119  desc.add<std::string>("debugLevel" , "INFO");
120  desc.add<std::string>("basicclusterCollection", "");
121  desc.add<std::string>("superclusterCollection", "");
122  desc.add<edm::InputTag>("ecalhitcollection", edm::InputTag("ecalRecHit","EcalRecHitsEB"));
123  desc.add<edm::InputTag>("l1TagIsolated", edm::InputTag("l1extraParticles","Isolated"));
124  desc.add<edm::InputTag>("l1TagNonIsolated", edm::InputTag("l1extraParticles","NonIsolated"));
125  desc.add<bool>("doIsolated", true);
126  desc.add<double>("l1LowerThr", 0);
127  desc.add<double>("l1UpperThr", 9999.0);
128  desc.add<double>("l1LowerThrIgnoreIsolation", 999.0);
129  desc.add<double>("regionEtaMargin", 0.14);
130  desc.add<double>("regionPhiMargin", 0.4);
131 
132  edm::ParameterSetDescription posCalcPSET;
133  posCalcPSET.add<double>("T0_barl", 7.4);
134  posCalcPSET.add<double>("T0_endc", 3.1);
135  posCalcPSET.add<double>("T0_endcPresh", 1.2);
136  posCalcPSET.add<double>("W0", 4.2);
137  posCalcPSET.add<double>("X0", 0.89);
138  posCalcPSET.add<bool>("LogWeighted", true);
139  desc.add<edm::ParameterSetDescription>("posCalcParameters", posCalcPSET);
140 
141  desc.add<std::vector<std::string>>("RecHitFlagToBeExcluded", std::vector<std::string>());
142  desc.add<std::vector<std::string> >("RecHitSeverityToBeExcluded", std::vector<std::string>());
143  desc.add<double>("severityRecHitThreshold", 4.0);
144  desc.add<double>("HybridBarrelSeedThr", 1.0);
145  desc.add<int>("step", 10);
146  desc.add<double>("ethresh", 0.1);
147  desc.add<double>("eseed", 0.35);
148  desc.add<double>("xi", 0);
149  desc.add<bool>("useEtForXi", true);
150  desc.add<double>("ewing", 1.0);
151  desc.add<bool>("dynamicEThresh", false);
152  desc.add<double>("eThreshA", 0.003);
153  desc.add<double>("eThreshB", 0.1);
154  desc.add<bool>("excludeFlagged", false);
155  desc.add<bool>("dynamicPhiRoad", false);
156  //desc.add<edm::ParameterSet>("bremRecoveryPset", edm::ParameterSet());
157 
158  descriptions.add("hltEgammaHLTHybridClusterProducer", desc);
159 }
160 
161 
163 {
164  // get the hit collection from the event:
166  evt.getByToken(hittoken_, rhcHandle);
167 
168  if (!(rhcHandle.isValid()))
169  {
170  edm::LogError("ProductNotFound")<< "could not get a handle on the EcalRecHitCollection!" << std::endl;
171  return;
172  }
173  const EcalRecHitCollection *hit_collection = rhcHandle.product();
174 
175  // get the collection geometry:
176  edm::ESHandle<CaloGeometry> geoHandle;
177  es.get<CaloGeometryRecord>().get(geoHandle);
178  const CaloGeometry& geometry = *geoHandle;
179  const CaloSubdetectorGeometry *geometry_p;
180  std::auto_ptr<const CaloSubdetectorTopology> topology;
181 
182  //edm::ESHandle<EcalChannelStatus> chStatus;
183  //es.get<EcalChannelStatusRcd>().get(chStatus);
184  //const EcalChannelStatus* theEcalChStatus = chStatus.product();
185 
187  es.get<EcalSeverityLevelAlgoRcd>().get(sevlv);
188  const EcalSeverityLevelAlgo* sevLevel = sevlv.product();
189 
190  if(hitcollection_.instance() == "EcalRecHitsEB") {
191  geometry_p = geometry.getSubdetectorGeometry(DetId::Ecal, EcalBarrel);
192  topology.reset(new EcalBarrelTopology(geoHandle));
193  } else if(hitcollection_.instance() == "EcalRecHitsEE") {
194  geometry_p = geometry.getSubdetectorGeometry(DetId::Ecal, EcalEndcap);
195  topology.reset(new EcalEndcapTopology(geoHandle));
196  } else if(hitcollection_.instance() == "EcalRecHitsPS") {
197  geometry_p = geometry.getSubdetectorGeometry(DetId::Ecal, EcalPreshower);
198  topology.reset(new EcalPreshowerTopology (geoHandle));
199  } else throw(std::runtime_error("\n\nHybrid Cluster Producer encountered invalied ecalhitcollection type.\n\n"));
200 
201  //Get the L1 EM Particle Collection
202  //Get the L1 EM Particle Collection
204  if(doIsolated_)
205  evt.getByToken(l1TagIsolated_, emIsolColl);
206 
207  //Get the L1 EM Particle Collection
209  evt.getByToken(l1TagNonIsolated_, emNonIsolColl);
210 
211  // Get the CaloGeometry
212  edm::ESHandle<L1CaloGeometry> l1CaloGeom ;
213  es.get<L1CaloGeometryRecord>().get(l1CaloGeom) ;
214 
215  std::vector<EcalEtaPhiRegion> regions;
216 
217  if(doIsolated_) {
218  for( l1extra::L1EmParticleCollection::const_iterator emItr = emIsolColl->begin(); emItr != emIsolColl->end() ;++emItr ){
219 
220  if (emItr->et() > l1LowerThr_ && emItr->et() < l1UpperThr_) {
221 
222  // Access the GCT hardware object corresponding to the L1Extra EM object.
223  int etaIndex = emItr->gctEmCand()->etaIndex() ;
224  int phiIndex = emItr->gctEmCand()->phiIndex() ;
225  // Use the L1CaloGeometry to find the eta, phi bin boundaries.
226  double etaLow = l1CaloGeom->etaBinLowEdge( etaIndex ) ;
227  double etaHigh = l1CaloGeom->etaBinHighEdge( etaIndex ) ;
228  double phiLow = l1CaloGeom->emJetPhiBinLowEdge( phiIndex ) ;
229  double phiHigh = l1CaloGeom->emJetPhiBinHighEdge( phiIndex ) ;
230 
231  int isbarl=0;
232  //Part of the region is in the barel if either the upper or lower
233  //edge of the region is within the barrel
234  if(((float)(etaLow)>-1.479 && (float)(etaLow)<1.479) ||
235  ((float)(etaHigh)>-1.479 && (float)(etaHigh)<1.479)) isbarl=1;
236 
237 
238  etaLow -= regionEtaMargin_;
239  etaHigh += regionEtaMargin_;
240  phiLow -= regionPhiMargin_;
241  phiHigh += regionPhiMargin_;
242 
243  if (etaHigh>1.479) etaHigh=1.479;
244  if (etaLow<-1.479) etaLow=-1.479;
245 
246  if(isbarl) regions.push_back(EcalEtaPhiRegion(etaLow,etaHigh,phiLow,phiHigh));
247 
248  }
249  }
250  }
251 
253  for( l1extra::L1EmParticleCollection::const_iterator emItr = emNonIsolColl->begin(); emItr != emNonIsolColl->end() ;++emItr ){
254 
255  if(doIsolated_&&emItr->et()<l1LowerThrIgnoreIsolation_) continue;
256 
257  if (emItr->et() > l1LowerThr_ && emItr->et() < l1UpperThr_) {
258 
259  // Access the GCT hardware object corresponding to the L1Extra EM object.
260  int etaIndex = emItr->gctEmCand()->etaIndex() ;
261  int phiIndex = emItr->gctEmCand()->phiIndex() ;
262  // Use the L1CaloGeometry to find the eta, phi bin boundaries.
263  double etaLow = l1CaloGeom->etaBinLowEdge( etaIndex ) ;
264  double etaHigh = l1CaloGeom->etaBinHighEdge( etaIndex ) ;
265  double phiLow = l1CaloGeom->emJetPhiBinLowEdge( phiIndex ) ;
266  double phiHigh = l1CaloGeom->emJetPhiBinHighEdge( phiIndex ) ;
267 
268  int isbarl=0;
269  //Part of the region is in the barel if either the upper or lower
270  //edge of the region is within the barrel
271  if(((float)(etaLow)>-1.479 && (float)(etaLow)<1.479) ||
272  ((float)(etaHigh)>-1.479 && (float)(etaHigh)<1.479)) isbarl=1;
273 
274 
275  etaLow -= regionEtaMargin_;
276  etaHigh += regionEtaMargin_;
277  phiLow -= regionPhiMargin_;
278  phiHigh += regionPhiMargin_;
279 
280  if (etaHigh>1.479) etaHigh=1.479;
281  if (etaLow<-1.479) etaLow=-1.479;
282 
283  if(isbarl) regions.push_back(EcalEtaPhiRegion(etaLow,etaHigh,phiLow,phiHigh));
284 
285  }
286  }
287  }
288 
289  // make the Basic clusters!
290  reco::BasicClusterCollection basicClusters;
291  hybrid_p->makeClusters(hit_collection, geometry_p, basicClusters, sevLevel, true, regions);
292 
293  // create an auto_ptr to a BasicClusterCollection, copy the clusters into it and put in the Event:
294  std::auto_ptr< reco::BasicClusterCollection > basicclusters_p(new reco::BasicClusterCollection);
295  basicclusters_p->assign(basicClusters.begin(), basicClusters.end());
296  edm::OrphanHandle<reco::BasicClusterCollection> bccHandle = evt.put(basicclusters_p,
298  if (!(bccHandle.isValid())) {
299  return;
300  }
301  reco::BasicClusterCollection clusterCollection = *bccHandle;
302 
303  reco::CaloClusterPtrVector clusterRefVector;
304  for (unsigned int i = 0; i < clusterCollection.size(); i++){
305  clusterRefVector.push_back(reco::CaloClusterPtr(bccHandle, i));
306  }
307 
308  reco::SuperClusterCollection superClusters = hybrid_p->makeSuperClusters(clusterRefVector);
309 
310  std::auto_ptr< reco::SuperClusterCollection > superclusters_p(new reco::SuperClusterCollection);
311  superclusters_p->assign(superClusters.begin(), superClusters.end());
312  evt.put(superclusters_p, superclusterCollection_);
313 
314 
315  nEvt_++;
316 }
317 
318 
T getParameter(std::string const &) const
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:43
int i
Definition: DBlmapReader.cc:9
edm::EDGetTokenT< l1extra::L1EmParticleCollection > l1TagIsolated_
CaloTopology const * topology(0)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:446
void push_back(Ptr< T > const &iPtr)
Definition: PtrVector.h:139
virtual void produce(edm::Event &, const edm::EventSetup &)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
reco::SuperClusterCollection makeSuperClusters(const reco::CaloClusterPtrVector &)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool isValid() const
Definition: HandleBase.h:76
T const * product() const
Definition: Handle.h:81
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:86
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::vector< BasicCluster > BasicClusterCollection
collection of BasicCluster objects
ESHandle< TrackerGeometry > geometry
edm::EDGetTokenT< l1extra::L1EmParticleCollection > l1TagNonIsolated_
std::string const & instance() const
Definition: InputTag.h:43
EgammaHLTHybridClusterProducer(const edm::ParameterSet &ps)
void makeClusters(const EcalRecHitCollection *, const CaloSubdetectorGeometry *geometry, reco::BasicClusterCollection &basicClusters, const EcalSeverityLevelAlgo *sevLv, bool regional=false, const std::vector< EcalEtaPhiRegion > &regions=std::vector< EcalEtaPhiRegion >())
edm::EDGetTokenT< EcalRecHitCollection > hittoken_