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  verbose_ =
94  iConfig.getUntrackedParameter<bool>("verbose",false);
95 
96  bool debug_ =
97  iConfig.getUntrackedParameter<bool>("debug",false);
98 
99  usePFatHLT_ = iConfig.getParameter<bool>("usePFatHLT");
100 
101  useNuclear_ = iConfig.getParameter<bool>("useNuclear");
102 
103  useConversions_ = iConfig.getParameter<bool>("useConversions");
104 
105  useConvBremGsfTracks_ = iConfig.getParameter<bool>("useConvBremGsfTracks");
106 
107  bool useConvBremPFRecTracks = iConfig.getParameter<bool>("useConvBremPFRecTracks");
108 
109  useV0_ = iConfig.getParameter<bool>("useV0");
110 
111  useHO_= iConfig.getParameter<bool>("useHO");
112 
113  produces<reco::PFBlockCollection>();
114 
115  // Glowinski & Gouzevitch
116  useKDTreeTrackEcalLinker_ = iConfig.getParameter<bool>("useKDTreeTrackEcalLinker");
117  // !Glowinski & Gouzevitch
118 
119  // particle flow parameters -----------------------------------
120 
121  std::vector<double> DPtovPtCut
122  = iConfig.getParameter<std::vector<double> >("pf_DPtoverPt_Cut");
123  if (DPtovPtCut.size()!=5)
124  {
125  edm::LogError("MisConfiguration")<<" vector pf_DPtoverPt_Cut has to be of size 5";
126  throw;
127  }
128 
129  std::vector<unsigned> NHitCut
130  = iConfig.getParameter<std::vector<unsigned> >("pf_NHit_Cut");
131  if (NHitCut.size()!=5)
132  {
133  edm::LogError("MisConfiguration")<<" vector pf_NHit_Cut has to be of size 5";
134  throw;
135  }
136 
137  bool useIterTracking
138  = iConfig.getParameter<bool>("useIterTracking");
139 
140  int nuclearInteractionsPurity
141  = iConfig.getParameter<unsigned>("nuclearInteractionsPurity");
142 
143  // if first parameter 0, deactivated
144  std::vector<double> EGPhotonSelectionCuts ;
145 
146  if (useEGPhotons_)
147  EGPhotonSelectionCuts = iConfig.getParameter<std::vector<double> >("PhotonSelectionCuts");
148 
149 
150  if (useNuclear_){
151  if (nuclearInteractionsPurity > 3 || nuclearInteractionsPurity < 1) {
152  nuclearInteractionsPurity = 1;
153  edm::LogInfo("PFBlockProducer") << "NI purity not properly implemented. Set it to the strongest level " << nuclearInteractionsPurity << endl;
154  }
155  vector<string> securityLevel;
156  securityLevel.push_back("isNucl"); securityLevel.push_back("isNucl && isNuclLoose"); securityLevel.push_back("isNucl && isNuclLoose && isNuclKink");
157  edm::LogInfo("PFBlockProducer") << "NI interactions are corrected in PFlow for " << securityLevel[nuclearInteractionsPurity-1].c_str() << endl;
158  }
159 
160 
161  pfBlockAlgo_.setParameters( DPtovPtCut,
162  NHitCut,
163  useConvBremPFRecTracks,
164  useIterTracking,
165  nuclearInteractionsPurity,
166  useEGPhotons_,
167  EGPhotonSelectionCuts,
168  useSuperClusters_
169  );
170 
171  pfBlockAlgo_.setDebug(debug_);
172 
173  // Glowinski & Gouzevitch
174  pfBlockAlgo_.setUseOptimization(useKDTreeTrackEcalLinker_);
175  // !Glowinski & Gouzevitch
176 
177  // Use HO clusters for link
178  pfBlockAlgo_.setHOTag(useHO_);
179 
180 }
181 
182 
183 
185 
186 
187 
188 void
190  const EventSetup& iSetup) {
191 
192  LogDebug("PFBlockProducer")<<"START event: "<<iEvent.id().event()
193  <<" in run "<<iEvent.id().run()<<endl;
194 
195 
196  // get rectracks
197 
199 
200  // LogDebug("PFBlockProducer")<<"get reco tracks"<<endl;
201  bool found = iEvent.getByLabel(inputTagRecTracks_, recTracks);
202 
203  if(!found )
204  LogError("PFBlockProducer")<<" cannot get rectracks: "
205  <<inputTagRecTracks_<<endl;
206 
207 
208 
209  // get GsfTracks
211 
212  if(!usePFatHLT_) {
213  found = iEvent.getByLabel(inputTagGsfRecTracks_,GsfrecTracks);
214 
215  if(!found )
216  LogError("PFBlockProducer")<<" cannot get Gsfrectracks: "
217  << inputTagGsfRecTracks_ <<endl;
218  }
219 
220  // get ConvBremGsfTracks
221  Handle< reco::GsfPFRecTrackCollection > convBremGsfrecTracks;
222 
223  if(useConvBremGsfTracks_) {
224  found = iEvent.getByLabel(inputTagConvBremGsfRecTracks_,convBremGsfrecTracks);
225 
226  if(!found )
227  LogError("PFBlockProducer")<<" cannot get ConvBremGsfrectracks: "
228  << inputTagConvBremGsfRecTracks_ <<endl;
229  }
230 
231  // get recmuons
233 
234  // LogDebug("PFBlockProducer")<<"get reco muons"<<endl;
235  //if(!usePFatHLT_) {
236  found = iEvent.getByLabel(inputTagRecMuons_, recMuons);
237 
238  //if(!found )
239  // LogError("PFBlockProducer")<<" cannot get recmuons: "
240  // <<inputTagRecMuons_<<endl;
241 
242  // get PFNuclearInteractions
243  //}
244  //---------- Gouzevitch
245  // Handle< reco::PFNuclearInteractionCollection > pfNuclears;
247 
248  if( useNuclear_ ) {
249 
250  found = iEvent.getByLabel(inputTagPFNuclear_, pfNuclears);
251  if(!found )
252  LogError("PFBlockProducer")<<" cannot get PFNuclearInteractions : "
253  <<inputTagPFNuclear_<<endl;
254  }
255 
256  // get conversions
258  if( useConversions_ ) {
259  found = iEvent.getByLabel(inputTagPFConversions_, pfConversions);
260 
261  if(!found )
262  LogError("PFBlockProducer")<<" cannot get PFConversions : "
263  <<inputTagPFConversions_<<endl;
264  }
265 
266 
267  // get V0s
269  if( useV0_ ) {
270  found = iEvent.getByLabel(inputTagPFV0_, pfV0);
271 
272  if(!found )
273  LogError("PFBlockProducer")<<" cannot get PFV0 : "
274  <<inputTagPFV0_<<endl;
275  }
276 
277 
278 
279  // get ECAL, HCAL, HO and PS clusters
280 
281 
283  found = iEvent.getByLabel(inputTagPFClustersECAL_,
284  clustersECAL);
285  if(!found )
286  LogError("PFBlockProducer")<<" cannot get ECAL clusters: "
287  <<inputTagPFClustersECAL_<<endl;
288 
289 
291  found = iEvent.getByLabel(inputTagPFClustersHCAL_,
292  clustersHCAL);
293  if(!found )
294  LogError("PFBlockProducer")<<" cannot get HCAL clusters: "
295  <<inputTagPFClustersHCAL_<<endl;
296 
298  if (useHO_) {
299  found = iEvent.getByLabel(inputTagPFClustersHO_,
300  clustersHO);
301  if(!found )
302  LogError("PFBlockProducer")<<" cannot get HO clusters: "
303  <<inputTagPFClustersHO_<<endl;
304  }
305 
307  found = iEvent.getByLabel(inputTagPFClustersHFEM_,
308  clustersHFEM);
309  if(!found )
310  LogError("PFBlockProducer")<<" cannot get HFEM clusters: "
311  <<inputTagPFClustersHFEM_<<endl;
312 
314  found = iEvent.getByLabel(inputTagPFClustersHFHAD_,
315  clustersHFHAD);
316  if(!found )
317  LogError("PFBlockProducer")<<" cannot get HFHAD clusters: "
318  <<inputTagPFClustersHFHAD_<<endl;
319 
320 
322  found = iEvent.getByLabel(inputTagPFClustersPS_,
323  clustersPS);
324  if(!found )
325  LogError("PFBlockProducer")<<" cannot get PS clusters: "
326  <<inputTagPFClustersPS_<<endl;
327 
328  // dummy. Not used in the full framework
329  Handle< reco::PFRecTrackCollection > nuclearRecTracks;
330 
331 
333  found = iEvent.getByLabel(inputTagEGPhotons_,
334  egPhotons);
335 
336  if(!found && useEGPhotons_ )
337  LogError("PFBlockProducer")<<" cannot get photons"
338  << inputTagEGPhotons_ << endl;
339 
342 
343  if (useSuperClusters_) {
344  found = iEvent.getByLabel(inputTagSCBarrel_,
345  sceb);
346 
347  if(!found)
348  LogError("PFBlockProducer")<<" cannot get sceb"
349  << inputTagSCBarrel_ << endl;
350 
351 
352 
353  found = iEvent.getByLabel(inputTagSCEndcap_,
354  scee);
355 
356  if(!found)
357  LogError("PFBlockProducer")<<" cannot get scee"
358  << inputTagSCEndcap_ << endl;
359 
360  }
361 
362  if( usePFatHLT_ ) {
363  pfBlockAlgo_.setInput( recTracks,
364  recMuons,
365  clustersECAL,
366  clustersHCAL,
367  clustersHO,
368  clustersHFEM,
369  clustersHFHAD,
370  clustersPS);
371  } else {
372  pfBlockAlgo_.setInput( recTracks,
373  GsfrecTracks,
374  convBremGsfrecTracks,
375  recMuons,
376  pfNuclears,
377  nuclearRecTracks,
378  pfConversions,
379  pfV0,
380  clustersECAL,
381  clustersHCAL,
382  clustersHO,
383  clustersHFEM,
384  clustersHFHAD,
385  clustersPS,
386  egPhotons,
387  sceb,
388  scee);
389  }
390  pfBlockAlgo_.findBlocks();
391 
392  if(verbose_) {
393  ostringstream str;
394  str<<pfBlockAlgo_<<endl;
395  LogInfo("PFBlockProducer") << str.str()<<endl;
396  }
397 
398  auto_ptr< reco::PFBlockCollection >
399  pOutputBlockCollection( pfBlockAlgo_.transferBlocks() );
400 
401  iEvent.put(pOutputBlockCollection);
402 
403  LogDebug("PFBlockProducer")<<"STOP event: "<<iEvent.id().event()
404  <<" in run "<<iEvent.id().run()<<endl;
405 }
#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:187
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:94
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
edm::EventID id() const
Definition: EventBase.h:56