CMS 3D CMS Logo

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