CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PFBlockProducer.cc
Go to the documentation of this file.
2 
5 
15 
18 
20 
24 
26 
28 
29 #include <set>
30 
31 using namespace std;
32 using namespace edm;
33 
35 
36 
37  // use configuration file to setup input/output collection names
38  inputTagRecTracks_
39  = iConfig.getParameter<InputTag>("RecTracks");
40 
41  inputTagGsfRecTracks_
42  = iConfig.getParameter<InputTag>("GsfRecTracks");
43 
44  inputTagConvBremGsfRecTracks_
45  = iConfig.getParameter<InputTag>("ConvBremGsfRecTracks");
46 
47  inputTagRecMuons_
48  = iConfig.getParameter<InputTag>("RecMuons");
49 
50  inputTagPFNuclear_
51  = iConfig.getParameter<InputTag>("PFNuclear");
52 
53  inputTagPFConversions_
54  = iConfig.getParameter<InputTag>("PFConversions");
55 
56  inputTagPFV0_
57  = iConfig.getParameter<InputTag>("PFV0");
58 
59  inputTagPFClustersECAL_
60  = iConfig.getParameter<InputTag>("PFClustersECAL");
61 
62  inputTagPFClustersHCAL_
63  = iConfig.getParameter<InputTag>("PFClustersHCAL");
64 
65  inputTagPFClustersHO_
66  = iConfig.getParameter<InputTag>("PFClustersHO");
67 
68  inputTagPFClustersHFEM_
69  = iConfig.getParameter<InputTag>("PFClustersHFEM");
70 
71  inputTagPFClustersHFHAD_
72  = iConfig.getParameter<InputTag>("PFClustersHFHAD");
73 
74  inputTagPFClustersPS_
75  = iConfig.getParameter<InputTag>("PFClustersPS");
76 
77  useEGPhotons_ = iConfig.getParameter<bool>("useEGPhotons");
78 
79  if(useEGPhotons_) {
80  inputTagEGPhotons_
81  = iConfig.getParameter<InputTag>("EGPhotons");
82  }
83 
84  useSuperClusters_ = iConfig.existsAs<bool>("useSuperClusters") ? iConfig.getParameter<bool>("useSuperClusters") : false;
85 
86  if (useSuperClusters_) {
87  inputTagSCBarrel_
88  = iConfig.getParameter<InputTag>("SCBarrel");
89  inputTagSCEndcap_
90  = iConfig.getParameter<InputTag>("SCEndcap");
91  }
92 
93  //default value = false (for compatibility with old HLT configs)
94  superClusterMatchByRef_ = iConfig.existsAs<bool>("SuperClusterMatchByRef") ? iConfig.getParameter<bool>("SuperClusterMatchByRef") : false;
95 
96  if (superClusterMatchByRef_) {
97  inputTagPFClusterAssociationEBEE_ = iConfig.getParameter<InputTag>("PFClusterAssociationEBEE");
98  }
99 
100  verbose_ =
101  iConfig.getUntrackedParameter<bool>("verbose",false);
102 
103  bool debug_ =
104  iConfig.getUntrackedParameter<bool>("debug",false);
105 
106  usePFatHLT_ = iConfig.getParameter<bool>("usePFatHLT");
107 
108  useNuclear_ = iConfig.getParameter<bool>("useNuclear");
109 
110  useConversions_ = iConfig.getParameter<bool>("useConversions");
111 
112  useConvBremGsfTracks_ = iConfig.getParameter<bool>("useConvBremGsfTracks");
113 
114  bool useConvBremPFRecTracks = iConfig.getParameter<bool>("useConvBremPFRecTracks");
115 
116  useV0_ = iConfig.getParameter<bool>("useV0");
117 
118  useHO_= iConfig.getParameter<bool>("useHO");
119 
120  produces<reco::PFBlockCollection>();
121 
122  // Glowinski & Gouzevitch
123  useKDTreeTrackEcalLinker_ = iConfig.getParameter<bool>("useKDTreeTrackEcalLinker");
124  // !Glowinski & Gouzevitch
125 
126  // particle flow parameters -----------------------------------
127 
128  std::vector<double> DPtovPtCut
129  = iConfig.getParameter<std::vector<double> >("pf_DPtoverPt_Cut");
130  if (DPtovPtCut.size()!=5)
131  {
132  edm::LogError("MisConfiguration")<<" vector pf_DPtoverPt_Cut has to be of size 5";
133  throw;
134  }
135 
136  std::vector<unsigned> NHitCut
137  = iConfig.getParameter<std::vector<unsigned> >("pf_NHit_Cut");
138  if (NHitCut.size()!=5)
139  {
140  edm::LogError("MisConfiguration")<<" vector pf_NHit_Cut has to be of size 5";
141  throw;
142  }
143 
144  bool useIterTracking
145  = iConfig.getParameter<bool>("useIterTracking");
146 
147  int nuclearInteractionsPurity
148  = iConfig.getParameter<unsigned>("nuclearInteractionsPurity");
149 
150  // if first parameter 0, deactivated
151  std::vector<double> EGPhotonSelectionCuts ;
152 
153  if (useEGPhotons_)
154  EGPhotonSelectionCuts = iConfig.getParameter<std::vector<double> >("PhotonSelectionCuts");
155 
156 
157  if (useNuclear_){
158  if (nuclearInteractionsPurity > 3 || nuclearInteractionsPurity < 1) {
159  nuclearInteractionsPurity = 1;
160  edm::LogInfo("PFBlockProducer") << "NI purity not properly implemented. Set it to the strongest level " << nuclearInteractionsPurity << endl;
161  }
162  vector<string> securityLevel;
163  securityLevel.push_back("isNucl"); securityLevel.push_back("isNucl && isNuclLoose"); securityLevel.push_back("isNucl && isNuclLoose && isNuclKink");
164  edm::LogInfo("PFBlockProducer") << "NI interactions are corrected in PFlow for " << securityLevel[nuclearInteractionsPurity-1].c_str() << endl;
165  }
166 
167 
168  pfBlockAlgo_.setParameters( DPtovPtCut,
169  NHitCut,
170  useConvBremPFRecTracks,
171  useIterTracking,
172  nuclearInteractionsPurity,
173  useEGPhotons_,
174  EGPhotonSelectionCuts,
175  useSuperClusters_,
176  superClusterMatchByRef_
177  );
178 
179  pfBlockAlgo_.setDebug(debug_);
180 
181  // Glowinski & Gouzevitch
182  pfBlockAlgo_.setUseOptimization(useKDTreeTrackEcalLinker_);
183  // !Glowinski & Gouzevitch
184 
185  // Use HO clusters for link
186  pfBlockAlgo_.setHOTag(useHO_);
187 
188 }
189 
190 
191 
193 
194 
195 
196 void
198  const EventSetup& iSetup) {
199 
200  LogDebug("PFBlockProducer")<<"START event: "<<iEvent.id().event()
201  <<" in run "<<iEvent.id().run()<<endl;
202 
203 
204  // get rectracks
205 
207 
208  // LogDebug("PFBlockProducer")<<"get reco tracks"<<endl;
209  bool found = iEvent.getByLabel(inputTagRecTracks_, recTracks);
210 
211  if(!found )
212  LogError("PFBlockProducer")<<" cannot get rectracks: "
213  <<inputTagRecTracks_<<endl;
214 
215 
216 
217  // get GsfTracks
219 
220  if(!usePFatHLT_) {
221  found = iEvent.getByLabel(inputTagGsfRecTracks_,GsfrecTracks);
222 
223  if(!found )
224  LogError("PFBlockProducer")<<" cannot get Gsfrectracks: "
225  << inputTagGsfRecTracks_ <<endl;
226  }
227 
228  // get ConvBremGsfTracks
229  Handle< reco::GsfPFRecTrackCollection > convBremGsfrecTracks;
230 
231  if(useConvBremGsfTracks_) {
232  found = iEvent.getByLabel(inputTagConvBremGsfRecTracks_,convBremGsfrecTracks);
233 
234  if(!found )
235  LogError("PFBlockProducer")<<" cannot get ConvBremGsfrectracks: "
236  << inputTagConvBremGsfRecTracks_ <<endl;
237  }
238 
239  // get recmuons
241 
242  // LogDebug("PFBlockProducer")<<"get reco muons"<<endl;
243  //if(!usePFatHLT_) {
244  found = iEvent.getByLabel(inputTagRecMuons_, recMuons);
245 
246  //if(!found )
247  // LogError("PFBlockProducer")<<" cannot get recmuons: "
248  // <<inputTagRecMuons_<<endl;
249 
250  // get PFNuclearInteractions
251  //}
252  //---------- Gouzevitch
253  // Handle< reco::PFNuclearInteractionCollection > pfNuclears;
255 
256  if( useNuclear_ ) {
257 
258  found = iEvent.getByLabel(inputTagPFNuclear_, pfNuclears);
259  if(!found )
260  LogError("PFBlockProducer")<<" cannot get PFNuclearInteractions : "
261  <<inputTagPFNuclear_<<endl;
262  }
263 
264  // get conversions
266  if( useConversions_ ) {
267  found = iEvent.getByLabel(inputTagPFConversions_, pfConversions);
268 
269  if(!found )
270  LogError("PFBlockProducer")<<" cannot get PFConversions : "
271  <<inputTagPFConversions_<<endl;
272  }
273 
274 
275  // get V0s
277  if( useV0_ ) {
278  found = iEvent.getByLabel(inputTagPFV0_, pfV0);
279 
280  if(!found )
281  LogError("PFBlockProducer")<<" cannot get PFV0 : "
282  <<inputTagPFV0_<<endl;
283  }
284 
285 
286 
287  // get ECAL, HCAL, HO and PS clusters
288 
289 
291  found = iEvent.getByLabel(inputTagPFClustersECAL_,
292  clustersECAL);
293  if(!found )
294  LogError("PFBlockProducer")<<" cannot get ECAL clusters: "
295  <<inputTagPFClustersECAL_<<endl;
296 
297 
299  found = iEvent.getByLabel(inputTagPFClustersHCAL_,
300  clustersHCAL);
301  if(!found )
302  LogError("PFBlockProducer")<<" cannot get HCAL clusters: "
303  <<inputTagPFClustersHCAL_<<endl;
304 
306  if (useHO_) {
307  found = iEvent.getByLabel(inputTagPFClustersHO_,
308  clustersHO);
309  if(!found )
310  LogError("PFBlockProducer")<<" cannot get HO clusters: "
311  <<inputTagPFClustersHO_<<endl;
312  }
313 
315  found = iEvent.getByLabel(inputTagPFClustersHFEM_,
316  clustersHFEM);
317  if(!found )
318  LogError("PFBlockProducer")<<" cannot get HFEM clusters: "
319  <<inputTagPFClustersHFEM_<<endl;
320 
322  found = iEvent.getByLabel(inputTagPFClustersHFHAD_,
323  clustersHFHAD);
324  if(!found )
325  LogError("PFBlockProducer")<<" cannot get HFHAD clusters: "
326  <<inputTagPFClustersHFHAD_<<endl;
327 
328 
330  found = iEvent.getByLabel(inputTagPFClustersPS_,
331  clustersPS);
332  if(!found )
333  LogError("PFBlockProducer")<<" cannot get PS clusters: "
334  <<inputTagPFClustersPS_<<endl;
335 
336  // dummy. Not used in the full framework
337  Handle< reco::PFRecTrackCollection > nuclearRecTracks;
338 
339 
341  found = iEvent.getByLabel(inputTagEGPhotons_,
342  egPhotons);
343 
344  if(!found && useEGPhotons_ )
345  LogError("PFBlockProducer")<<" cannot get photons"
346  << inputTagEGPhotons_ << endl;
347 
350 
351  if (useSuperClusters_) {
352  found = iEvent.getByLabel(inputTagSCBarrel_,
353  sceb);
354 
355  if(!found)
356  LogError("PFBlockProducer")<<" cannot get sceb"
357  << inputTagSCBarrel_ << endl;
358 
359 
360 
361  found = iEvent.getByLabel(inputTagSCEndcap_,
362  scee);
363 
364  if(!found)
365  LogError("PFBlockProducer")<<" cannot get scee"
366  << inputTagSCEndcap_ << endl;
367 
368  }
369 
371  if (superClusterMatchByRef_) {
372  found = iEvent.getByLabel(inputTagPFClusterAssociationEBEE_,
373  pfclusterassoc);
374 
375  if(!found)
376  LogError("PFBlockProducer")<<" cannot get PFCluster Association"
377  << inputTagPFClusterAssociationEBEE_ << endl;
378  }
379 
380  if( usePFatHLT_ ) {
381  pfBlockAlgo_.setInput( recTracks,
382  recMuons,
383  clustersECAL,
384  clustersHCAL,
385  clustersHO,
386  clustersHFEM,
387  clustersHFHAD,
388  clustersPS);
389  } else {
390  pfBlockAlgo_.setInput( recTracks,
391  GsfrecTracks,
392  convBremGsfrecTracks,
393  recMuons,
394  pfNuclears,
395  nuclearRecTracks,
396  pfConversions,
397  pfV0,
398  clustersECAL,
399  clustersHCAL,
400  clustersHO,
401  clustersHFEM,
402  clustersHFHAD,
403  clustersPS,
404  egPhotons,
405  sceb,
406  scee,
407  pfclusterassoc
408  );
409  }
410  pfBlockAlgo_.findBlocks();
411 
412  if(verbose_) {
413  ostringstream str;
414  str<<pfBlockAlgo_<<endl;
415  LogInfo("PFBlockProducer") << str.str()<<endl;
416  }
417 
418  auto_ptr< reco::PFBlockCollection >
419  pOutputBlockCollection( pfBlockAlgo_.transferBlocks() );
420 
421  iEvent.put(pOutputBlockCollection);
422 
423  LogDebug("PFBlockProducer")<<"STOP event: "<<iEvent.id().event()
424  <<" in run "<<iEvent.id().run()<<endl;
425 }
#define LogDebug(id)
RunNumber_t run() const
Definition: EventID.h:42
T getParameter(std::string const &) const
EventNumber_t event() const
Definition: EventID.h:44
T getUntrackedParameter(std::string const &, T const &) const
virtual void produce(edm::Event &, const edm::EventSetup &) override
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:184
tuple pfV0
Definition: pfV0_cfi.py:3
PFBlockProducer(const edm::ParameterSet &)
int iEvent
Definition: GenABIO.cc:243
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
edm::EventID id() const
Definition: EventBase.h:56