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