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