CMS 3D CMS Logo

HSCPTreeBuilder.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: HSCPTreeBuilder
4 // Class: HSCPTreeBuilder
5 //
13 //
14 // Original Author: Loic QUERTENMONT
15 // Created: Thu Mar 11 12:19:07 CEST 2010
16 //
17 
18 
19 #include <memory>
20 #include <cmath>
21 
30 
32 
35 
41 
48 
50 
53 
60 
63 
65 
68 
69 
73 
76 
78 
83 
86 
89 
91 
92 
93 #include "TFile.h"
94 #include "TObjString.h"
95 #include "TString.h"
96 #include "TH1F.h"
97 #include "TH2F.h"
98 #include "TProfile.h"
99 #include "TF1.h"
100 #include "TTree.h"
101 #include "TROOT.h"
102 
103 #include <ext/hash_map>
104 
105 
106 using namespace edm;
107 using namespace reco;
108 using namespace std;
109 using namespace __gnu_cxx;
110 
111 #define MAX_VERTICES 1000
112 #define MAX_HSCPS 10000
113 #define MAX_GENS 10000
114 #define MAX_ECALCRYS 10
115 
117  public:
118  explicit HSCPTreeBuilder(const edm::ParameterSet&);
119  ~HSCPTreeBuilder() override;
120 
121 
122  private:
123  void beginJob() override ;
124  bool filter(edm::Event&, const edm::EventSetup&) override;
125  void endJob() override ;
126  int ClosestMuonIndex(reco::TrackRef track, std::vector<reco::MuonRef>);
127 
130 
132 
140 
141  TTree* MyTree;
142  bool Event_triggerL1Bits[192];
143  bool Event_triggerHLTBits[128];
144  bool Event_technicalBits[64];
145  unsigned int Event_EventNumber;
146  unsigned int Event_RunNumber;
147  unsigned int Event_LumiSection;
148  unsigned int Event_BXCrossing;
149  unsigned int Event_Orbit;
150  unsigned int Event_Store;
151  unsigned int Event_Time;
154 
155  unsigned int NVertices;
156  float Vertex_x [MAX_VERTICES];
157  float Vertex_y [MAX_VERTICES];
158  float Vertex_z [MAX_VERTICES];
159  float Vertex_x_err [MAX_VERTICES];
160  float Vertex_y_err [MAX_VERTICES];
161  float Vertex_z_err [MAX_VERTICES];
162  int Vertex_TrackSize [MAX_VERTICES];
163  float Vertex_chi2 [MAX_VERTICES];
164  float Vertex_ndof [MAX_VERTICES];
165  bool Vertex_isFake [MAX_VERTICES];
166 
167  unsigned int NHSCPs;
168  bool Hscp_hasTrack [MAX_HSCPS];
169  bool Hscp_hasMuon [MAX_HSCPS];
170  bool Hscp_hasRpc [MAX_HSCPS];
171  bool Hscp_hasCalo [MAX_HSCPS];
172  int Hscp_type [MAX_HSCPS];
173  unsigned int Track_NOH [MAX_HSCPS];
174  float Track_p [MAX_HSCPS];
175  float Track_pt [MAX_HSCPS];
176  float Track_pt_err [MAX_HSCPS];
177  float Track_chi2 [MAX_HSCPS];
178  unsigned int Track_ndof [MAX_HSCPS];
179  float Track_eta [MAX_HSCPS];
180  float Track_eta_err [MAX_HSCPS];
181  float Track_phi [MAX_HSCPS];
182  float Track_phi_err [MAX_HSCPS];
183  float Track_dz [MAX_HSCPS];
184  float Track_d0 [MAX_HSCPS];
185  int Track_quality [MAX_HSCPS];
186  int Track_charge [MAX_HSCPS];
187  float Track_dEdxE1 [MAX_HSCPS];
188  float Track_dEdxE1_NOS [MAX_HSCPS];
189  unsigned int Track_dEdxE1_NOM [MAX_HSCPS];
190  float Track_dEdxE2 [MAX_HSCPS];
191  float Track_dEdxE2_NOS [MAX_HSCPS];
192  unsigned int Track_dEdxE2_NOM [MAX_HSCPS];
193  float Track_dEdxE3 [MAX_HSCPS];
194  float Track_dEdxE3_NOS [MAX_HSCPS];
195  unsigned int Track_dEdxE3_NOM [MAX_HSCPS];
196  float Track_dEdxD1 [MAX_HSCPS];
197  float Track_dEdxD1_NOS [MAX_HSCPS];
198  unsigned int Track_dEdxD1_NOM [MAX_HSCPS];
199  float Track_dEdxD2 [MAX_HSCPS];
200  float Track_dEdxD2_NOS [MAX_HSCPS];
201  unsigned int Track_dEdxD2_NOM [MAX_HSCPS];
202  float Track_dEdxD3 [MAX_HSCPS];
203  float Track_dEdxD3_NOS [MAX_HSCPS];
204  unsigned int Track_dEdxD3_NOM [MAX_HSCPS];
205  float Muon_p [MAX_HSCPS];
206  float Muon_pt [MAX_HSCPS];
207  float Muon_eta [MAX_HSCPS];
208  float Muon_phi [MAX_HSCPS];
209  int Muon_type [MAX_HSCPS];
210  bool Muon_qualityValid [MAX_HSCPS];
211  int Muon_charge [MAX_HSCPS];
212  float Muon_dt_IBeta [MAX_HSCPS];
213  float Muon_dt_IBeta_err [MAX_HSCPS];
214  float Muon_dt_fIBeta [MAX_HSCPS];
215  float Muon_dt_fIBeta_err [MAX_HSCPS];
216  int Muon_dt_ndof [MAX_HSCPS];
217  float Muon_csc_IBeta [MAX_HSCPS];
218  float Muon_csc_IBeta_err [MAX_HSCPS];
219  float Muon_csc_fIBeta [MAX_HSCPS];
220  float Muon_csc_fIBeta_err[MAX_HSCPS];
221  int Muon_csc_ndof [MAX_HSCPS];
222  float Muon_cb_IBeta [MAX_HSCPS];
223  float Muon_cb_IBeta_err [MAX_HSCPS];
224  float Muon_cb_fIBeta [MAX_HSCPS];
225  float Muon_cb_fIBeta_err [MAX_HSCPS];
226  int Muon_cb_ndof [MAX_HSCPS];
227  float Rpc_beta [MAX_HSCPS];
228 
229  float Calo_ecal_crossedE [MAX_HSCPS];
230  float Calo_ecal_beta [MAX_HSCPS];
231  float Calo_ecal_beta_err [MAX_HSCPS];
232  float Calo_ecal_invBeta_err [MAX_HSCPS];
233  float Calo_ecal_dEdx [MAX_HSCPS];
234  float Calo_ecal_time [MAX_HSCPS];
235  float Calo_ecal_time_err [MAX_HSCPS];
236  int Calo_ecal_numCrysCrossed [MAX_HSCPS];
237  float Calo_ecal_swissCrossKs [MAX_HSCPS][MAX_ECALCRYS];
238  float Calo_ecal_e1OverE9s [MAX_HSCPS][MAX_ECALCRYS];
239  float Calo_ecal_trackLengths [MAX_HSCPS][MAX_ECALCRYS];
240  float Calo_ecal_trackExitEtas [MAX_HSCPS][MAX_ECALCRYS];
241  float Calo_ecal_trackExitPhis [MAX_HSCPS][MAX_ECALCRYS];
242  float Calo_ecal_energies [MAX_HSCPS][MAX_ECALCRYS];
243  float Calo_ecal_outOfTimeEnergies[MAX_HSCPS][MAX_ECALCRYS];
244  float Calo_ecal_chi2s [MAX_HSCPS][MAX_ECALCRYS];
245  float Calo_ecal_outOfTimeChi2s [MAX_HSCPS][MAX_ECALCRYS];
246  float Calo_ecal_times [MAX_HSCPS][MAX_ECALCRYS];
247  float Calo_ecal_timeErrors [MAX_HSCPS][MAX_ECALCRYS];
248  unsigned int Calo_ecal_detIds [MAX_HSCPS][MAX_ECALCRYS];
249 
250  unsigned int NGens;
251  int Gen_pdgId [MAX_GENS];
252  float Gen_charge [MAX_GENS];
253  float Gen_p [MAX_GENS];
254  float Gen_px [MAX_GENS];
255  float Gen_py [MAX_GENS];
256  float Gen_pz [MAX_GENS];
257  float Gen_pt [MAX_GENS];
258  float Gen_eta [MAX_GENS];
259  float Gen_phi [MAX_GENS];
260  float Gen_beta [MAX_GENS];
261  float Gen_mass [MAX_GENS];
262 };
263 
265 {
266  m_gtReadoutRecordToken = consumes<L1GlobalTriggerReadoutRecord>(InputTag("gtDigis"));
267  m_trToken = consumes<edm::TriggerResults>(InputTag("TriggerResults"));
268  m_recoVertexToken = consumes<reco::VertexCollection>(InputTag("offlinePrimaryVertices"));
269  m_genParticlesToken = mayConsume<GenParticleCollection>(InputTag("genParticles"));
270  m_HSCPsToken = consumes<susybsm::HSCParticleCollection >(iConfig.getParameter<InputTag> ("HSCParticles"));
271 
272  reccordVertexInfo = iConfig.getUntrackedParameter<bool> ("reccordVertexInfo" , true );
273  reccordGenInfo = iConfig.getUntrackedParameter<bool> ("reccordGenInfo" , false );
274 
275  std::cout << "######################################################" << endl;
276  std::cout << " USE OF THE HSCPTreeBuilder is deprecated! " << endl;
277  std::cout << "better to use the HSCParticle Producer and then FWLite" << endl;
278  std::cout << "######################################################" << endl;
279 
280 }
281 
282 
284 {
285 }
286 
287 void
289 {
290  TTree::SetMaxTreeSize(1000*Long64_t(2000000000)); // authorize Trees up to 2 Terabytes
291  MyTree = tfs->make<TTree> ("HscpTree","HscpTree");
292 
293  MyTree->Branch("Event_EventNumber" ,&Event_EventNumber ,"Event_EventNumber/i");
294  MyTree->Branch("Event_RunNumber" ,&Event_RunNumber ,"Event_RunNumber/i");
295  MyTree->Branch("Event_LumiSection" ,&Event_LumiSection ,"Event_LumiSection/i");
296  MyTree->Branch("Event_BXCrossing" ,&Event_BXCrossing ,"Event_BXCrossing/i");
297  MyTree->Branch("Event_Orbit" ,&Event_Orbit ,"Event_Orbit/i");
298  MyTree->Branch("Event_Store" ,&Event_Store ,"Event_Store/i");
299  MyTree->Branch("Event_Time" ,&Event_Time ,"Event_Time/i");
300  MyTree->Branch("Event_PhysicsDeclared" ,&Event_PhysicsDeclared ,"Event_PhysicsDeclared/O");
301  MyTree->Branch("Event_technicalBits" ,Event_technicalBits ,"Event_technicalBits[64]/O");
302  MyTree->Branch("Event_triggerL1Bits" ,Event_triggerL1Bits ,"Event_triggerL1Bits[192]/O");
303  MyTree->Branch("Event_triggerHLTBits" ,Event_triggerHLTBits ,"Event_triggerHLTBits[128]/O");
304  MyTree->Branch("Event_BField" ,&Event_BField ,"Event_BField/F");
305 
306  if(reccordVertexInfo){
307  MyTree->Branch("NVertices" ,&NVertices ,"NVertices/I");
308  MyTree->Branch("Vertex_x" ,Vertex_x ,"Vertex_x[NVertices]/F");
309  MyTree->Branch("Vertex_y" ,Vertex_y ,"Vertex_y[NVertices]/F");
310  MyTree->Branch("Vertex_z" ,Vertex_z ,"Vertex_z[NVertices]/F");
311  MyTree->Branch("Vertex_x_err" ,Vertex_x_err ,"Vertex_x_err[NVertices]/F");
312  MyTree->Branch("Vertex_y_err" ,Vertex_y_err ,"Vertex_y_err[NVertices]/F");
313  MyTree->Branch("Vertex_z_err" ,Vertex_z_err ,"Vertex_z_err[NVertices]/F");
314  MyTree->Branch("Vertex_TrackSize",Vertex_TrackSize,"Vertex_TrackSize[NVertices]/I");
315  MyTree->Branch("Vertex_chi2" ,Vertex_chi2 ,"Vertex_chi2[NVertices]/F");
316  MyTree->Branch("Vertex_ndof" ,Vertex_ndof ,"Vertex_ndof[NVertices]/F");
317  MyTree->Branch("Vertex_isFake" ,Vertex_isFake ,"Vertex_isFake[NVertices]/O");
318  }
319 
320  MyTree->Branch("NHSCPs" ,&NHSCPs ,"NHSCPs/I");
321  MyTree->Branch("Hscp_hasTrack" ,Hscp_hasTrack ,"Hscp_hasTrack[NHSCPs]/O");
322  MyTree->Branch("Hscp_hasMuon" ,Hscp_hasMuon ,"Hscp_hasMuon[NHSCPs]/O");
323  MyTree->Branch("Hscp_hasRpc" ,Hscp_hasRpc ,"Hscp_hasRpc[NHSCPs]/O");
324  MyTree->Branch("Hscp_hasCalo" ,Hscp_hasCalo ,"Hscp_hasCalo[NHSCPs]/O");
325  MyTree->Branch("Hscp_type" ,Hscp_type ,"Hscp_type[NHSCPs]/I");
326  MyTree->Branch("Track_NOH" ,Track_NOH ,"Track_NOH[NHSCPs]/I");
327  MyTree->Branch("Track_p" ,Track_p ,"Track_p[NHSCPs]/F");
328  MyTree->Branch("Track_pt" ,Track_pt ,"Track_pt[NHSCPs]/F");
329  MyTree->Branch("Track_pt_err" ,Track_pt_err ,"Track_pt_err[NHSCPs]/F");
330  MyTree->Branch("Track_chi2" ,Track_chi2 ,"Track_chi2[NHSCPs]/F");
331  MyTree->Branch("Track_ndof" ,Track_ndof ,"Track_ndof[NHSCPs]/F");
332  MyTree->Branch("Track_eta" ,Track_eta ,"Track_eta[NHSCPs]/F");
333  MyTree->Branch("Track_eta_err" ,Track_eta_err ,"Track_eta_err[NHSCPs]/F");
334  MyTree->Branch("Track_phi" ,Track_phi ,"Track_phi[NHSCPs]/F");
335  MyTree->Branch("Track_phi_err" ,Track_phi_err ,"Track_phi_err[NHSCPs]/F");
336  MyTree->Branch("Track_d0" ,Track_d0 ,"Track_d0[NHSCPs]/F");
337  MyTree->Branch("Track_dz" ,Track_dz ,"Track_dz[NHSCPs]/F");
338  MyTree->Branch("Track_quality" ,Track_quality ,"Track_quality[NHSCPs]/I");
339  MyTree->Branch("Track_charge" ,Track_charge ,"Track_charge[NHSCPs]/I");
340  MyTree->Branch("Track_dEdxE1" ,Track_dEdxE1 ,"Track_dEdxE1[NHSCPs]/F");
341  MyTree->Branch("Track_dEdxE1_NOS" ,Track_dEdxE1_NOS ,"Track_dEdxE1_NOS[NHSCPs]/F");
342  MyTree->Branch("Track_dEdxE1_NOM" ,Track_dEdxE1_NOM ,"Track_dEdxE1_NOM[NHSCPs]/I");
343  MyTree->Branch("Track_dEdxE2" ,Track_dEdxE2 ,"Track_dEdxE2[NHSCPs]/F");
344  MyTree->Branch("Track_dEdxE2_NOS" ,Track_dEdxE2_NOS ,"Track_dEdxE2_NOS[NHSCPs]/F");
345  MyTree->Branch("Track_dEdxE2_NOM" ,Track_dEdxE2_NOM ,"Track_dEdxE2_NOM[NHSCPs]/I");
346  MyTree->Branch("Track_dEdxE3" ,Track_dEdxE3 ,"Track_dEdxE3[NHSCPs]/F");
347  MyTree->Branch("Track_dEdxE3_NOS" ,Track_dEdxE3_NOS ,"Track_dEdxE3_NOS[NHSCPs]/F");
348  MyTree->Branch("Track_dEdxE3_NOM" ,Track_dEdxE3_NOM ,"Track_dEdxE3_NOM[NHSCPs]/I");
349  MyTree->Branch("Track_dEdxD1" ,Track_dEdxD1 ,"Track_dEdxD1[NHSCPs]/F");
350  MyTree->Branch("Track_dEdxD1_NOS" ,Track_dEdxD1_NOS ,"Track_dEdxD1_NOS[NHSCPs]/F");
351  MyTree->Branch("Track_dEdxD1_NOM" ,Track_dEdxD1_NOM ,"Track_dEdxD1_NOM[NHSCPs]/I");
352  MyTree->Branch("Track_dEdxD2" ,Track_dEdxD2 ,"Track_dEdxD2[NHSCPs]/F");
353  MyTree->Branch("Track_dEdxD2_NOS" ,Track_dEdxD2_NOS ,"Track_dEdxD2_NOS[NHSCPs]/F");
354  MyTree->Branch("Track_dEdxD2_NOM" ,Track_dEdxD2_NOM ,"Track_dEdxD2_NOM[NHSCPs]/I");
355  MyTree->Branch("Track_dEdxD3" ,Track_dEdxD3 ,"Track_dEdxD3[NHSCPs]/F");
356  MyTree->Branch("Track_dEdxD3_NOS" ,Track_dEdxD3_NOS ,"Track_dEdxD3_NOS[NHSCPs]/F");
357  MyTree->Branch("Track_dEdxD3_NOM" ,Track_dEdxD3_NOM ,"Track_dEdxD3_NOM[NHSCPs]/I");
358  MyTree->Branch("Muon_p" ,Muon_p ,"Muon_p[NHSCPs]/F");
359  MyTree->Branch("Muon_pt" ,Muon_pt ,"Muon_pt[NHSCPs]/F");
360  MyTree->Branch("Muon_eta" ,Muon_eta ,"Muon_eta[NHSCPs]/F");
361  MyTree->Branch("Muon_phi" ,Muon_phi ,"Muon_phi[NHSCPs]/F");
362  MyTree->Branch("Muon_type" ,Muon_type ,"Muon_type[NHSCPs]/i");
363  MyTree->Branch("Muon_qualityValid" ,Muon_qualityValid ,"Muon_qualityValid[NHSCPs]/O");
364  MyTree->Branch("Muon_charge" ,Muon_charge ,"Muon_charge[NHSCPs]/i");
365  MyTree->Branch("Muon_dt_IBeta" ,Muon_dt_IBeta ,"Muon_dt_IBeta[NHSCPs]/F");
366  MyTree->Branch("Muon_dt_IBeta_err" ,Muon_dt_IBeta_err ,"Muon_dt_IBeta_err[NHSCPs]/F");
367  MyTree->Branch("Muon_dt_fIBeta" ,Muon_dt_fIBeta ,"Muon_dt_fIBeta[NHSCPs]/F");
368  MyTree->Branch("Muon_dt_fIBeta_err" ,Muon_dt_fIBeta_err ,"Muon_dt_fIBeta_err[NHSCPs]/F");
369  MyTree->Branch("Muon_dt_ndof" ,Muon_dt_ndof ,"Muon_dt_ndof[NHSCPs]/I");
370  MyTree->Branch("Muon_csc_IBeta" ,Muon_csc_IBeta ,"Muon_csc_IBeta[NHSCPs]/F");
371  MyTree->Branch("Muon_csc_IBeta_err" ,Muon_csc_IBeta_err ,"Muon_csc_IBeta_err[NHSCPs]/F");
372  MyTree->Branch("Muon_csc_fIBeta" ,Muon_csc_fIBeta ,"Muon_csc_fIBeta[NHSCPs]/F");
373  MyTree->Branch("Muon_csc_fIBeta_err",Muon_csc_fIBeta_err,"Muon_csc_fIBeta_err[NHSCPs]/F");
374  MyTree->Branch("Muon_csc_ndof" ,Muon_csc_ndof ,"Muon_csc_ndof[NHSCPs]/I");
375  MyTree->Branch("Muon_cb_IBeta" ,Muon_cb_IBeta ,"Muon_cb_IBeta[NHSCPs]/F");
376  MyTree->Branch("Muon_cb_IBeta_err" ,Muon_cb_IBeta_err ,"Muon_cb_IBeta_err[NHSCPs]/F");
377  MyTree->Branch("Muon_cb_fIBeta" ,Muon_cb_fIBeta ,"Muon_cb_fIBeta[NHSCPs]/F");
378  MyTree->Branch("Muon_cb_fIBeta_err" ,Muon_cb_fIBeta_err ,"Muon_cb_fIBeta_err[NHSCPs]/F");
379  MyTree->Branch("Muon_cb_ndof" ,Muon_cb_ndof ,"Muon_cb_ndof[NHSCPs]/I");
380 
381  MyTree->Branch("Rpc_beta" ,Rpc_beta ,"Rpc_beta[NHSCPs]/F");
382 
383  MyTree->Branch("Calo_ecal_crossedE" ,Calo_ecal_crossedE ,"Calo_ecal_crossedE[NHSCPs]/F");
384  MyTree->Branch("Calo_ecal_beta" ,Calo_ecal_beta ,"Calo_ecal_beta[NHSCPs]/F");
385  MyTree->Branch("Calo_ecal_beta_err" ,Calo_ecal_beta_err ,"Calo_ecal_beta_err[NHSCPs]/F");
386  MyTree->Branch("Calo_ecal_invBeta_err" ,Calo_ecal_invBeta_err ,"Calo_ecal_invBeta_err[NHSCPs]/F");
387  MyTree->Branch("Calo_ecal_dEdx" ,Calo_ecal_dEdx ,"Calo_ecal_dEdx[NHSCPs]/F");
388  MyTree->Branch("Calo_ecal_time" ,Calo_ecal_time ,"Calo_ecal_time[NHSCPs]/F");
389  MyTree->Branch("Calo_ecal_time_err" ,Calo_ecal_time_err ,"Calo_ecal_time_err[NHSCPs]/F");
390  MyTree->Branch("Calo_ecal_numCrysCrossed" ,Calo_ecal_numCrysCrossed,"Calo_ecal_numCrysCrossed[NHSCPs]/I");
391  MyTree->Branch("Calo_ecal_swissCrossKs" ,Calo_ecal_swissCrossKs ,"Calo_ecal_swissCrossKs[NHSCPs][10]/F");
392  MyTree->Branch("Calo_ecal_e1OverE9s" ,Calo_ecal_e1OverE9s ,"Calo_ecal_e1OverE9s[NHSCPs][10]/F");
393  MyTree->Branch("Calo_ecal_trackLengths" ,Calo_ecal_trackLengths ,"Calo_ecal_trackLengths[NHSCPs][10]/F");
394  MyTree->Branch("Calo_ecal_trackExitEtas" ,Calo_ecal_trackExitEtas ,"Calo_ecal_trackExitEtas[NHSCPs][10]/F");
395  MyTree->Branch("Calo_ecal_trackExitPhis" ,Calo_ecal_trackExitPhis ,"Calo_ecal_trackExitPhis[NHSCPs][10]/F");
396  MyTree->Branch("Calo_ecal_energies" ,Calo_ecal_energies ,"Calo_ecal_energies[NHSCPs][10]/F");
397  MyTree->Branch("Calo_ecal_outOfTimeEnergies",Calo_ecal_outOfTimeEnergies ,"Calo_ecal_outOfTimeEnergies[NHSCPs][10]/F");
398  MyTree->Branch("Calo_ecal_chi2s" ,Calo_ecal_chi2s ,"Calo_ecal_chi2s[NHSCPs][10]/F");
399  MyTree->Branch("Calo_ecal_outOfTimeChi2s" ,Calo_ecal_outOfTimeChi2s ,"Calo_ecal_outOfTimeChi2s[NHSCPs][10]/F");
400  MyTree->Branch("Calo_ecal_times" ,Calo_ecal_times ,"Calo_ecal_times[NHSCPs][10]/F");
401  MyTree->Branch("Calo_ecal_timeErrors" ,Calo_ecal_timeErrors ,"Calo_ecal_timeErrors[NHSCPs][10]/F");
402  MyTree->Branch("Calo_ecal_detIds" ,Calo_ecal_detIds ,"Calo_ecal_detIds[NHSCPs][10]/I");
403 
404  if(reccordGenInfo){
405  MyTree->Branch("NGens" ,&NGens ,"NGens/I");
406  MyTree->Branch("Gen_pdgId" ,Gen_pdgId ,"Gen_pdgId[NGens]/i");
407  MyTree->Branch("Gen_charge" ,Gen_charge ,"Gen_charge[NGens]/F");
408  MyTree->Branch("Gen_p" ,Gen_p ,"Gen_p[NGens]/F");
409  MyTree->Branch("Gen_px" ,Gen_px ,"Gen_px[NGens]/F");
410  MyTree->Branch("Gen_py" ,Gen_py ,"Gen_py[NGens]/F");
411  MyTree->Branch("Gen_pz" ,Gen_pz ,"Gen_pz[NGens]/F");
412  MyTree->Branch("Gen_pt" ,Gen_pt ,"Gen_pt[NGens]/F");
413  MyTree->Branch("Gen_eta" ,Gen_eta ,"Gen_eta[NGens]/F");
414  MyTree->Branch("Gen_phi" ,Gen_phi ,"Gen_phi[NGens]/F");
415  MyTree->Branch("Gen_beta" ,Gen_beta ,"Gen_beta[NGens]/F");
416  MyTree->Branch("Gen_mass" ,Gen_mass ,"Gen_mass[NGens]/F");
417  }
418 
419 }
420 
421 void
423 {
424 }
425 
426 
427 
428 bool
430 {
431  bool debug = false;
432  if (debug) cout << "I'm in HSCPTreeBuilder::analyze!" << endl;
433 
434 
435  Event_EventNumber = iEvent.id().event();
436  Event_RunNumber = iEvent.id().run();
437  Event_LumiSection = iEvent.eventAuxiliary().luminosityBlock();
438  Event_BXCrossing = iEvent.eventAuxiliary().bunchCrossing();
439  Event_Orbit = iEvent.eventAuxiliary().orbitNumber();
440  Event_Store = iEvent.eventAuxiliary().storeNumber();
441  Event_Time = iEvent.eventAuxiliary().time().value();
442 
443  // BField part:
445  iSetup.get<IdealMagneticFieldRecord>().get(MF);
446  const MagneticField* theMagneticField = MF.product();
447  Event_BField = fabs(theMagneticField->inTesla(GlobalPoint(0,0,0)).z());
448 
449  // L1 TRIGGER part:
451  iEvent.getByToken(m_gtReadoutRecordToken, h_gtReadoutRecord);
452  L1GtFdlWord fdlWord = h_gtReadoutRecord->gtFdlWord();
453  TechnicalTriggerWord L1technical = fdlWord.gtTechnicalTriggerWord();
454  Event_PhysicsDeclared = h_gtReadoutRecord->gtFdlWord().physicsDeclared();
455  for (unsigned int i = 0; i < 64; ++i){ Event_technicalBits [i] = L1technical[i]; }
456  DecisionWord L1decision = fdlWord.gtDecisionWord();
457  for (unsigned int i = 0; i < 128; ++i){ Event_triggerL1Bits [i] = L1decision[i]; }
458  DecisionWordExtended L1decisionE = fdlWord.gtDecisionWordExtended();
459  for (unsigned int i = 0; i < 64; ++i){ Event_triggerL1Bits [128+i] = L1decisionE[i]; }
460 
461  // HLT TRIGGER part:
463  iEvent.getByToken(m_trToken, trh);
464  for(unsigned int i=0;i<trh->size() && i<128;++i){Event_triggerHLTBits[i] = trh->at(i).accept();}
465 
466  edm::Handle<reco::VertexCollection> recoVertexHandle;
467  iEvent.getByToken(m_recoVertexToken, recoVertexHandle);
468  reco::VertexCollection recoVertex = *recoVertexHandle;
469 
470  if(reccordVertexInfo){
471  NVertices = 0;
472  for(unsigned int i=0;i<recoVertex.size();i++){
473  Vertex_x [NVertices] = recoVertex[i].x();
474  Vertex_y [NVertices] = recoVertex[i].y();
475  Vertex_z [NVertices] = recoVertex[i].z();
476  Vertex_x_err [NVertices] = recoVertex[i].xError();
477  Vertex_y_err [NVertices] = recoVertex[i].yError();
478  Vertex_z_err [NVertices] = recoVertex[i].zError();
479  Vertex_TrackSize[NVertices] = recoVertex[i].tracksSize();
480  Vertex_chi2 [NVertices] = recoVertex[i].chi2();
481  Vertex_ndof [NVertices] = recoVertex[i].ndof();
482  Vertex_isFake [NVertices] = recoVertex[i].isFake();
483  NVertices++;
484  }
485  }
486 
487  // Source Collection
489  iEvent.getByToken(m_HSCPsToken, HSCPCollectionHandle);
490  susybsm::HSCParticleCollection HSCPCollection = *HSCPCollectionHandle.product();
491 
492  NHSCPs=0;
493  for(unsigned int i=0; i<HSCPCollection.size();i++){
494  susybsm::HSCParticle hscp = HSCPCollection[i];
495  reco::MuonRef muon = hscp.muonRef();
496  reco::TrackRef track = hscp.trackRef();;
497 
498  Hscp_hasTrack [NHSCPs] = hscp.hasTrackRef();
499  Hscp_hasMuon [NHSCPs] = hscp.hasMuonRef();
500  Hscp_hasRpc [NHSCPs] = hscp.hasRpcInfo();
501  Hscp_hasCalo [NHSCPs] = hscp.hasCaloInfo();
502  Hscp_type [NHSCPs] = hscp.type();
503 
504  if(track.isNonnull() && Hscp_hasTrack[NHSCPs]){
505  Track_p [NHSCPs] = track->p();
506  Track_pt [NHSCPs] = track->pt();
507  Track_pt_err [NHSCPs] = track->ptError();
508  Track_eta [NHSCPs] = track->eta();
509  Track_eta_err [NHSCPs] = track->etaError();
510  Track_phi [NHSCPs] = track->phi();
511  Track_phi_err [NHSCPs] = track->phiError();
512  Track_NOH [NHSCPs] = track->found();
513  Track_chi2 [NHSCPs] = track->chi2();
514  Track_ndof [NHSCPs] = track->ndof();
515  Track_d0 [NHSCPs] = -1.0f * track->dxy(recoVertex[0].position());
516  Track_dz [NHSCPs] = -1.0f * track->dz (recoVertex[0].position());
517  Track_quality [NHSCPs] = track->qualityMask();
518  Track_charge [NHSCPs] = track->charge();
519 /* Track_dEdxE1 [NHSCPs] = hscp.dedxEstimator1().dEdx();
520  Track_dEdxE1_NOM [NHSCPs] = hscp.dedxEstimator1().numberOfMeasurements();
521  Track_dEdxE1_NOS [NHSCPs] = hscp.dedxEstimator1().numberOfSaturatedMeasurements();
522  Track_dEdxE2 [NHSCPs] = hscp.dedxEstimator2().dEdx();
523  Track_dEdxE2_NOM [NHSCPs] = hscp.dedxEstimator2().numberOfMeasurements();
524  Track_dEdxE2_NOS [NHSCPs] = hscp.dedxEstimator2().numberOfSaturatedMeasurements();
525  Track_dEdxE3 [NHSCPs] = hscp.dedxEstimator3().dEdx();
526  Track_dEdxE3_NOM [NHSCPs] = hscp.dedxEstimator3().numberOfMeasurements();
527  Track_dEdxE3_NOS [NHSCPs] = hscp.dedxEstimator3().numberOfSaturatedMeasurements();
528  Track_dEdxD1 [NHSCPs] = hscp.dedxDiscriminator1().dEdx();
529  Track_dEdxD1_NOM [NHSCPs] = hscp.dedxDiscriminator1().numberOfMeasurements();
530  Track_dEdxD1_NOS [NHSCPs] = hscp.dedxDiscriminator1().numberOfSaturatedMeasurements();
531  Track_dEdxD2 [NHSCPs] = hscp.dedxDiscriminator2().dEdx();
532  Track_dEdxD2_NOM [NHSCPs] = hscp.dedxDiscriminator2().numberOfMeasurements();
533  Track_dEdxD2_NOS [NHSCPs] = hscp.dedxDiscriminator2().numberOfSaturatedMeasurements();
534  Track_dEdxD3 [NHSCPs] = hscp.dedxDiscriminator3().dEdx();
535  Track_dEdxD3_NOM [NHSCPs] = hscp.dedxDiscriminator3().numberOfMeasurements();
536  Track_dEdxD3_NOS [NHSCPs] = hscp.dedxDiscriminator3().numberOfSaturatedMeasurements();
537 */
538  }
539 
540  if(muon.isNonnull() && Hscp_hasMuon[NHSCPs]){
541  Muon_p [NHSCPs] = muon->p();
542  Muon_pt [NHSCPs] = muon->pt();
543  Muon_eta [NHSCPs] = muon->eta();
544  Muon_phi [NHSCPs] = muon->phi();
545  Muon_type [NHSCPs] = muon->type();
546  Muon_qualityValid [NHSCPs] = muon->isQualityValid();
547  Muon_charge [NHSCPs] = muon->charge();
548 /* Muon_dt_IBeta [NHSCPs] = hscp.muonTimeDt().inverseBeta();
549  Muon_dt_IBeta_err [NHSCPs] = hscp.muonTimeDt().inverseBetaErr();
550  Muon_dt_fIBeta [NHSCPs] = hscp.muonTimeDt().freeInverseBeta();
551  Muon_dt_fIBeta_err [NHSCPs] = hscp.muonTimeDt().freeInverseBetaErr();
552  Muon_dt_ndof [NHSCPs] = hscp.muonTimeDt().nDof();
553  Muon_csc_IBeta [NHSCPs] = hscp.muonTimeCsc().inverseBeta();
554  Muon_csc_IBeta_err [NHSCPs] = hscp.muonTimeCsc().inverseBetaErr();
555  Muon_csc_fIBeta [NHSCPs] = hscp.muonTimeCsc().freeInverseBeta();
556  Muon_csc_fIBeta_err[NHSCPs] = hscp.muonTimeCsc().freeInverseBetaErr();
557  Muon_csc_ndof [NHSCPs] = hscp.muonTimeCsc().nDof();
558  Muon_cb_IBeta [NHSCPs] = hscp.muonTimeCombined().inverseBeta();
559  Muon_cb_IBeta_err [NHSCPs] = hscp.muonTimeCombined().inverseBetaErr();
560  Muon_cb_fIBeta [NHSCPs] = hscp.muonTimeCombined().freeInverseBeta();
561  Muon_cb_fIBeta_err [NHSCPs] = hscp.muonTimeCombined().freeInverseBetaErr();
562  Muon_cb_ndof [NHSCPs] = hscp.muonTimeCombined().nDof();
563 */
564  }
565 
566  if(hscp.hasCaloInfo()){
567 // Calo_ecal_crossedE [NHSCPs] = hscp.calo().ecalCrossedEnergy;
568 // Calo_ecal_beta [NHSCPs] = hscp.calo().ecalBeta;
569 // Calo_ecal_beta_err [NHSCPs] = hscp.calo().ecalBetaError;
570 // Calo_ecal_invBeta_err [NHSCPs] = hscp.calo().ecalInvBetaError;
571 // Calo_ecal_dEdx [NHSCPs] = hscp.calo().ecalDeDx;
572 // Calo_ecal_time [NHSCPs] = hscp.calo().ecalTime;
573 // Calo_ecal_time_err [NHSCPs] = hscp.calo().ecalTimeError;
574 // Calo_ecal_numCrysCrossed[NHSCPs] = hscp.calo().ecalCrysCrossed;
575 /* for(int i=0; i < Calo_ecal_numCrysCrossed[NHSCPs] && i < MAX_ECALCRYS; ++i)
576  {
577  Calo_ecal_swissCrossKs [NHSCPs][i] = hscp.calo().ecalSwissCrossKs[i];
578  Calo_ecal_e1OverE9s [NHSCPs][i] = hscp.calo().ecalE1OverE9s[i];
579  Calo_ecal_trackLengths [NHSCPs][i] = hscp.calo().ecalTrackLengths[i];
580  GlobalPoint exitPosition = hscp.calo().ecalTrackExitPositions[i];
581  Calo_ecal_trackExitEtas [NHSCPs][i] = exitPosition.eta();
582  Calo_ecal_trackExitPhis [NHSCPs][i] = exitPosition.phi();
583  Calo_ecal_energies [NHSCPs][i] = hscp.calo().ecalEnergies[i];
584  Calo_ecal_outOfTimeEnergies[NHSCPs][i] = hscp.calo().ecalOutOfTimeEnergies[i];
585  Calo_ecal_chi2s [NHSCPs][i] = hscp.calo().ecalChi2s[i];
586  Calo_ecal_outOfTimeChi2s [NHSCPs][i] = hscp.calo().ecalOutOfTimeChi2s[i];
587  Calo_ecal_times [NHSCPs][i] = hscp.calo().ecalTimes[i];
588  Calo_ecal_timeErrors [NHSCPs][i] = hscp.calo().ecalTimeErrors[i];
589  Calo_ecal_detIds [NHSCPs][i] = hscp.calo().ecalDetIds[i];
590  }
591 */
592  }
593 
594  if(Hscp_hasRpc[NHSCPs]){
595  Rpc_beta [NHSCPs] = hscp.rpc().beta;
596  }
597 
598  NHSCPs++;
599  }
600 
601 
602  if(reccordGenInfo){
604  iEvent.getByToken(m_genParticlesToken, genParticles);
605  NGens=0;
606  for(unsigned int i=0;i<genParticles->size();i++){
607  const GenParticle & part = (*genParticles)[i];
608  if(part.status()!=1)continue;
609  if(part.pt()<5)continue;
610 // if(fabs(part.pdgId())<1000000) continue;
611 
612  Gen_pdgId [NGens] = part.pdgId();
613  Gen_charge[NGens] = part.charge();
614  Gen_p [NGens] = part.p();
615  Gen_px [NGens] = part.px();
616  Gen_py [NGens] = part.py();
617  Gen_pz [NGens] = part.pz();
618  Gen_pt [NGens] = part.pt();
619  Gen_eta [NGens] = part.eta();
620  Gen_phi [NGens] = part.phi();
621  Gen_beta [NGens] = part.p()/part.energy();
622  Gen_mass [NGens] = part.mass();
623  NGens++;
624  }
625  }
626 
627 
628  MyTree->Fill();
629  return true;
630 }
631 
632 //define this as a plug-in
634 
635 
636 
637 
638 
639 
640 
641 
642 
643 
RunNumber_t run() const
Definition: EventID.h:39
unsigned int Event_LumiSection
T getParameter(std::string const &) const
EventNumber_t event() const
Definition: EventID.h:41
int pdgId() const final
PDG identifier.
T getUntrackedParameter(std::string const &, T const &) const
const TechnicalTriggerWord & gtTechnicalTriggerWord() const
get/set technical trigger bits
Definition: L1GtFdlWord.h:149
EventAuxiliary const & eventAuxiliary() const override
Definition: Event.h:92
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:251
double eta() const final
momentum pseudorapidity
unsigned int NGens
~HSCPTreeBuilder() override
const RPCBetaMeasurement & rpc() const
Definition: HSCParticle.h:77
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
double px() const final
x coordinate of momentum vector
Timestamp const & time() const
unsigned int Event_BXCrossing
double pt() const final
transverse momentum
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
int charge() const final
electric charge
Definition: LeafCandidate.h:91
unsigned int NVertices
void beginJob() override
bool hasTrackRef() const
Definition: HSCParticle.h:57
int bunchCrossing() const
HSCPTreeBuilder(const edm::ParameterSet &)
LuminosityBlockNumber_t luminosityBlock() const
void beginJob()
Definition: Breakpoints.cc:14
unsigned int Event_Orbit
#define MAX_GENS
bool filter(edm::Event &, const edm::EventSetup &) override
std::vector< bool > DecisionWordExtended
std::vector< HSCParticle > HSCParticleCollection
Definition: HSCParticle.h:94
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
int storeNumber() const
#define MAX_ECALCRYS
unsigned int Event_EventNumber
double pz() const final
z coordinate of momentum vector
int orbitNumber() const
unsigned int NHSCPs
std::vector< bool > DecisionWord
typedefs
unsigned int size() const
Get number of paths stored.
T z() const
Definition: PV3DBase.h:64
double energy() const final
energy
EDGetTokenT< L1GlobalTriggerReadoutRecord > m_gtReadoutRecordToken
std::vector< bool > TechnicalTriggerWord
technical trigger bits (64 bits)
#define MAX_VERTICES
const edm::EventSetup * iSetup_
const edm::Event * iEvent_
#define MAX_HSCPS
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
const HLTPathStatus & at(const unsigned int i) const
reco::MuonRef muonRef() const
Definition: HSCParticle.h:74
double p() const final
magnitude of momentum vector
EDGetTokenT< GenParticleCollection > m_genParticlesToken
#define debug
Definition: HDRShower.cc:19
EDGetTokenT< edm::TriggerResults > m_trToken
T const * product() const
Definition: Handle.h:74
part
Definition: HCALResponse.h:20
double py() const final
y coordinate of momentum vector
const DecisionWord & gtDecisionWord() const
get/set/print algorithms bits (decision word)
Definition: L1GtFdlWord.h:171
bool accept() const
has this path accepted the event?
Definition: HLTPathStatus.h:62
int type() const
Definition: HSCParticle.cc:5
reco::TrackRef trackRef() const
Definition: HSCParticle.h:72
edm::EventID id() const
Definition: EventBase.h:59
fixed size matrix
HLT enums.
bool hasRpcInfo() const
Definition: HSCParticle.h:59
static int position[264][3]
Definition: ReadPGInfo.cc:509
T get() const
Definition: EventSetup.h:71
int status() const final
status word
unsigned int Event_Store
unsigned int Event_Time
void endJob() override
bool hasMuonRef() const
Definition: HSCParticle.h:55
const DecisionWordExtended & gtDecisionWordExtended() const
get/set extended algorithms bits (extended decision word)
Definition: L1GtFdlWord.h:203
edm::Service< TFileService > tfs
bool hasCaloInfo() const
Definition: HSCParticle.h:60
EDGetTokenT< reco::VertexCollection > m_recoVertexToken
double phi() const final
momentum azimuthal angle
T const * product() const
Definition: ESHandle.h:86
TimeValue_t value() const
Definition: Timestamp.h:56
double mass() const final
mass
EDGetTokenT< susybsm::HSCParticleCollection > m_HSCPsToken
unsigned int Event_RunNumber