95 #include "TObjString.h"
104 #include <ext/hash_map>
108 using namespace reco;
110 using namespace __gnu_cxx;
112 #define MAX_VERTICES 1000
113 #define MAX_HSCPS 10000
114 #define MAX_GENS 10000
115 #define MAX_ECALCRYS 10
126 virtual void endJob()
override ;
127 int ClosestMuonIndex(
reco::TrackRef track, std::vector<reco::MuonRef>);
138 bool Event_triggerL1Bits[192];
139 bool Event_triggerHLTBits[128];
140 bool Event_technicalBits[64];
267 std::cout <<
"######################################################" << endl;
268 std::cout <<
" USE OF THE HSCPTreeBuilder is deprecated! " << endl;
269 std::cout <<
"better to use the HSCParticle Producer and then FWLite" << endl;
270 std::cout <<
"######################################################" << endl;
282 TTree::SetMaxTreeSize(1000*Long64_t(2000000000));
283 MyTree = tfs->make<TTree> (
"HscpTree",
"HscpTree");
285 MyTree->Branch(
"Event_EventNumber" ,&Event_EventNumber ,
"Event_EventNumber/i");
286 MyTree->Branch(
"Event_RunNumber" ,&Event_RunNumber ,
"Event_RunNumber/i");
287 MyTree->Branch(
"Event_LumiSection" ,&Event_LumiSection ,
"Event_LumiSection/i");
288 MyTree->Branch(
"Event_BXCrossing" ,&Event_BXCrossing ,
"Event_BXCrossing/i");
289 MyTree->Branch(
"Event_Orbit" ,&Event_Orbit ,
"Event_Orbit/i");
290 MyTree->Branch(
"Event_Store" ,&Event_Store ,
"Event_Store/i");
291 MyTree->Branch(
"Event_Time" ,&Event_Time ,
"Event_Time/i");
292 MyTree->Branch(
"Event_PhysicsDeclared" ,&Event_PhysicsDeclared ,
"Event_PhysicsDeclared/O");
293 MyTree->Branch(
"Event_technicalBits" ,Event_technicalBits ,
"Event_technicalBits[64]/O");
294 MyTree->Branch(
"Event_triggerL1Bits" ,Event_triggerL1Bits ,
"Event_triggerL1Bits[192]/O");
295 MyTree->Branch(
"Event_triggerHLTBits" ,Event_triggerHLTBits ,
"Event_triggerHLTBits[128]/O");
296 MyTree->Branch(
"Event_BField" ,&Event_BField ,
"Event_BField/F");
298 if(reccordVertexInfo){
299 MyTree->Branch(
"NVertices" ,&NVertices ,
"NVertices/I");
300 MyTree->Branch(
"Vertex_x" ,Vertex_x ,
"Vertex_x[NVertices]/F");
301 MyTree->Branch(
"Vertex_y" ,Vertex_y ,
"Vertex_y[NVertices]/F");
302 MyTree->Branch(
"Vertex_z" ,Vertex_z ,
"Vertex_z[NVertices]/F");
303 MyTree->Branch(
"Vertex_x_err" ,Vertex_x_err ,
"Vertex_x_err[NVertices]/F");
304 MyTree->Branch(
"Vertex_y_err" ,Vertex_y_err ,
"Vertex_y_err[NVertices]/F");
305 MyTree->Branch(
"Vertex_z_err" ,Vertex_z_err ,
"Vertex_z_err[NVertices]/F");
306 MyTree->Branch(
"Vertex_TrackSize",Vertex_TrackSize,
"Vertex_TrackSize[NVertices]/I");
307 MyTree->Branch(
"Vertex_chi2" ,Vertex_chi2 ,
"Vertex_chi2[NVertices]/F");
308 MyTree->Branch(
"Vertex_ndof" ,Vertex_ndof ,
"Vertex_ndof[NVertices]/F");
309 MyTree->Branch(
"Vertex_isFake" ,Vertex_isFake ,
"Vertex_isFake[NVertices]/O");
312 MyTree->Branch(
"NHSCPs" ,&NHSCPs ,
"NHSCPs/I");
313 MyTree->Branch(
"Hscp_hasTrack" ,Hscp_hasTrack ,
"Hscp_hasTrack[NHSCPs]/O");
314 MyTree->Branch(
"Hscp_hasMuon" ,Hscp_hasMuon ,
"Hscp_hasMuon[NHSCPs]/O");
315 MyTree->Branch(
"Hscp_hasRpc" ,Hscp_hasRpc ,
"Hscp_hasRpc[NHSCPs]/O");
316 MyTree->Branch(
"Hscp_hasCalo" ,Hscp_hasCalo ,
"Hscp_hasCalo[NHSCPs]/O");
317 MyTree->Branch(
"Hscp_type" ,Hscp_type ,
"Hscp_type[NHSCPs]/I");
318 MyTree->Branch(
"Track_NOH" ,Track_NOH ,
"Track_NOH[NHSCPs]/I");
319 MyTree->Branch(
"Track_p" ,Track_p ,
"Track_p[NHSCPs]/F");
320 MyTree->Branch(
"Track_pt" ,Track_pt ,
"Track_pt[NHSCPs]/F");
321 MyTree->Branch(
"Track_pt_err" ,Track_pt_err ,
"Track_pt_err[NHSCPs]/F");
322 MyTree->Branch(
"Track_chi2" ,Track_chi2 ,
"Track_chi2[NHSCPs]/F");
323 MyTree->Branch(
"Track_ndof" ,Track_ndof ,
"Track_ndof[NHSCPs]/F");
324 MyTree->Branch(
"Track_eta" ,Track_eta ,
"Track_eta[NHSCPs]/F");
325 MyTree->Branch(
"Track_eta_err" ,Track_eta_err ,
"Track_eta_err[NHSCPs]/F");
326 MyTree->Branch(
"Track_phi" ,Track_phi ,
"Track_phi[NHSCPs]/F");
327 MyTree->Branch(
"Track_phi_err" ,Track_phi_err ,
"Track_phi_err[NHSCPs]/F");
328 MyTree->Branch(
"Track_d0" ,Track_d0 ,
"Track_d0[NHSCPs]/F");
329 MyTree->Branch(
"Track_dz" ,Track_dz ,
"Track_dz[NHSCPs]/F");
330 MyTree->Branch(
"Track_quality" ,Track_quality ,
"Track_quality[NHSCPs]/I");
331 MyTree->Branch(
"Track_charge" ,Track_charge ,
"Track_charge[NHSCPs]/I");
332 MyTree->Branch(
"Track_dEdxE1" ,Track_dEdxE1 ,
"Track_dEdxE1[NHSCPs]/F");
333 MyTree->Branch(
"Track_dEdxE1_NOS" ,Track_dEdxE1_NOS ,
"Track_dEdxE1_NOS[NHSCPs]/F");
334 MyTree->Branch(
"Track_dEdxE1_NOM" ,Track_dEdxE1_NOM ,
"Track_dEdxE1_NOM[NHSCPs]/I");
335 MyTree->Branch(
"Track_dEdxE2" ,Track_dEdxE2 ,
"Track_dEdxE2[NHSCPs]/F");
336 MyTree->Branch(
"Track_dEdxE2_NOS" ,Track_dEdxE2_NOS ,
"Track_dEdxE2_NOS[NHSCPs]/F");
337 MyTree->Branch(
"Track_dEdxE2_NOM" ,Track_dEdxE2_NOM ,
"Track_dEdxE2_NOM[NHSCPs]/I");
338 MyTree->Branch(
"Track_dEdxE3" ,Track_dEdxE3 ,
"Track_dEdxE3[NHSCPs]/F");
339 MyTree->Branch(
"Track_dEdxE3_NOS" ,Track_dEdxE3_NOS ,
"Track_dEdxE3_NOS[NHSCPs]/F");
340 MyTree->Branch(
"Track_dEdxE3_NOM" ,Track_dEdxE3_NOM ,
"Track_dEdxE3_NOM[NHSCPs]/I");
341 MyTree->Branch(
"Track_dEdxD1" ,Track_dEdxD1 ,
"Track_dEdxD1[NHSCPs]/F");
342 MyTree->Branch(
"Track_dEdxD1_NOS" ,Track_dEdxD1_NOS ,
"Track_dEdxD1_NOS[NHSCPs]/F");
343 MyTree->Branch(
"Track_dEdxD1_NOM" ,Track_dEdxD1_NOM ,
"Track_dEdxD1_NOM[NHSCPs]/I");
344 MyTree->Branch(
"Track_dEdxD2" ,Track_dEdxD2 ,
"Track_dEdxD2[NHSCPs]/F");
345 MyTree->Branch(
"Track_dEdxD2_NOS" ,Track_dEdxD2_NOS ,
"Track_dEdxD2_NOS[NHSCPs]/F");
346 MyTree->Branch(
"Track_dEdxD2_NOM" ,Track_dEdxD2_NOM ,
"Track_dEdxD2_NOM[NHSCPs]/I");
347 MyTree->Branch(
"Track_dEdxD3" ,Track_dEdxD3 ,
"Track_dEdxD3[NHSCPs]/F");
348 MyTree->Branch(
"Track_dEdxD3_NOS" ,Track_dEdxD3_NOS ,
"Track_dEdxD3_NOS[NHSCPs]/F");
349 MyTree->Branch(
"Track_dEdxD3_NOM" ,Track_dEdxD3_NOM ,
"Track_dEdxD3_NOM[NHSCPs]/I");
350 MyTree->Branch(
"Muon_p" ,Muon_p ,
"Muon_p[NHSCPs]/F");
351 MyTree->Branch(
"Muon_pt" ,Muon_pt ,
"Muon_pt[NHSCPs]/F");
352 MyTree->Branch(
"Muon_eta" ,Muon_eta ,
"Muon_eta[NHSCPs]/F");
353 MyTree->Branch(
"Muon_phi" ,Muon_phi ,
"Muon_phi[NHSCPs]/F");
354 MyTree->Branch(
"Muon_type" ,Muon_type ,
"Muon_type[NHSCPs]/i");
355 MyTree->Branch(
"Muon_qualityValid" ,Muon_qualityValid ,
"Muon_qualityValid[NHSCPs]/O");
356 MyTree->Branch(
"Muon_charge" ,Muon_charge ,
"Muon_charge[NHSCPs]/i");
357 MyTree->Branch(
"Muon_dt_IBeta" ,Muon_dt_IBeta ,
"Muon_dt_IBeta[NHSCPs]/F");
358 MyTree->Branch(
"Muon_dt_IBeta_err" ,Muon_dt_IBeta_err ,
"Muon_dt_IBeta_err[NHSCPs]/F");
359 MyTree->Branch(
"Muon_dt_fIBeta" ,Muon_dt_fIBeta ,
"Muon_dt_fIBeta[NHSCPs]/F");
360 MyTree->Branch(
"Muon_dt_fIBeta_err" ,Muon_dt_fIBeta_err ,
"Muon_dt_fIBeta_err[NHSCPs]/F");
361 MyTree->Branch(
"Muon_dt_ndof" ,Muon_dt_ndof ,
"Muon_dt_ndof[NHSCPs]/I");
362 MyTree->Branch(
"Muon_csc_IBeta" ,Muon_csc_IBeta ,
"Muon_csc_IBeta[NHSCPs]/F");
363 MyTree->Branch(
"Muon_csc_IBeta_err" ,Muon_csc_IBeta_err ,
"Muon_csc_IBeta_err[NHSCPs]/F");
364 MyTree->Branch(
"Muon_csc_fIBeta" ,Muon_csc_fIBeta ,
"Muon_csc_fIBeta[NHSCPs]/F");
365 MyTree->Branch(
"Muon_csc_fIBeta_err",Muon_csc_fIBeta_err,
"Muon_csc_fIBeta_err[NHSCPs]/F");
366 MyTree->Branch(
"Muon_csc_ndof" ,Muon_csc_ndof ,
"Muon_csc_ndof[NHSCPs]/I");
367 MyTree->Branch(
"Muon_cb_IBeta" ,Muon_cb_IBeta ,
"Muon_cb_IBeta[NHSCPs]/F");
368 MyTree->Branch(
"Muon_cb_IBeta_err" ,Muon_cb_IBeta_err ,
"Muon_cb_IBeta_err[NHSCPs]/F");
369 MyTree->Branch(
"Muon_cb_fIBeta" ,Muon_cb_fIBeta ,
"Muon_cb_fIBeta[NHSCPs]/F");
370 MyTree->Branch(
"Muon_cb_fIBeta_err" ,Muon_cb_fIBeta_err ,
"Muon_cb_fIBeta_err[NHSCPs]/F");
371 MyTree->Branch(
"Muon_cb_ndof" ,Muon_cb_ndof ,
"Muon_cb_ndof[NHSCPs]/I");
373 MyTree->Branch(
"Rpc_beta" ,Rpc_beta ,
"Rpc_beta[NHSCPs]/F");
375 MyTree->Branch(
"Calo_ecal_crossedE" ,Calo_ecal_crossedE ,
"Calo_ecal_crossedE[NHSCPs]/F");
376 MyTree->Branch(
"Calo_ecal_beta" ,Calo_ecal_beta ,
"Calo_ecal_beta[NHSCPs]/F");
377 MyTree->Branch(
"Calo_ecal_beta_err" ,Calo_ecal_beta_err ,
"Calo_ecal_beta_err[NHSCPs]/F");
378 MyTree->Branch(
"Calo_ecal_invBeta_err" ,Calo_ecal_invBeta_err ,
"Calo_ecal_invBeta_err[NHSCPs]/F");
379 MyTree->Branch(
"Calo_ecal_dEdx" ,Calo_ecal_dEdx ,
"Calo_ecal_dEdx[NHSCPs]/F");
380 MyTree->Branch(
"Calo_ecal_time" ,Calo_ecal_time ,
"Calo_ecal_time[NHSCPs]/F");
381 MyTree->Branch(
"Calo_ecal_time_err" ,Calo_ecal_time_err ,
"Calo_ecal_time_err[NHSCPs]/F");
382 MyTree->Branch(
"Calo_ecal_numCrysCrossed" ,Calo_ecal_numCrysCrossed,
"Calo_ecal_numCrysCrossed[NHSCPs]/I");
383 MyTree->Branch(
"Calo_ecal_swissCrossKs" ,Calo_ecal_swissCrossKs ,
"Calo_ecal_swissCrossKs[NHSCPs][10]/F");
384 MyTree->Branch(
"Calo_ecal_e1OverE9s" ,Calo_ecal_e1OverE9s ,
"Calo_ecal_e1OverE9s[NHSCPs][10]/F");
385 MyTree->Branch(
"Calo_ecal_trackLengths" ,Calo_ecal_trackLengths ,
"Calo_ecal_trackLengths[NHSCPs][10]/F");
386 MyTree->Branch(
"Calo_ecal_trackExitEtas" ,Calo_ecal_trackExitEtas ,
"Calo_ecal_trackExitEtas[NHSCPs][10]/F");
387 MyTree->Branch(
"Calo_ecal_trackExitPhis" ,Calo_ecal_trackExitPhis ,
"Calo_ecal_trackExitPhis[NHSCPs][10]/F");
388 MyTree->Branch(
"Calo_ecal_energies" ,Calo_ecal_energies ,
"Calo_ecal_energies[NHSCPs][10]/F");
389 MyTree->Branch(
"Calo_ecal_outOfTimeEnergies",Calo_ecal_outOfTimeEnergies ,
"Calo_ecal_outOfTimeEnergies[NHSCPs][10]/F");
390 MyTree->Branch(
"Calo_ecal_chi2s" ,Calo_ecal_chi2s ,
"Calo_ecal_chi2s[NHSCPs][10]/F");
391 MyTree->Branch(
"Calo_ecal_outOfTimeChi2s" ,Calo_ecal_outOfTimeChi2s ,
"Calo_ecal_outOfTimeChi2s[NHSCPs][10]/F");
392 MyTree->Branch(
"Calo_ecal_times" ,Calo_ecal_times ,
"Calo_ecal_times[NHSCPs][10]/F");
393 MyTree->Branch(
"Calo_ecal_timeErrors" ,Calo_ecal_timeErrors ,
"Calo_ecal_timeErrors[NHSCPs][10]/F");
394 MyTree->Branch(
"Calo_ecal_detIds" ,Calo_ecal_detIds ,
"Calo_ecal_detIds[NHSCPs][10]/I");
397 MyTree->Branch(
"NGens" ,&NGens ,
"NGens/I");
398 MyTree->Branch(
"Gen_pdgId" ,Gen_pdgId ,
"Gen_pdgId[NGens]/i");
399 MyTree->Branch(
"Gen_charge" ,Gen_charge ,
"Gen_charge[NGens]/F");
400 MyTree->Branch(
"Gen_p" ,Gen_p ,
"Gen_p[NGens]/F");
401 MyTree->Branch(
"Gen_px" ,Gen_px ,
"Gen_px[NGens]/F");
402 MyTree->Branch(
"Gen_py" ,Gen_py ,
"Gen_py[NGens]/F");
403 MyTree->Branch(
"Gen_pz" ,Gen_pz ,
"Gen_pz[NGens]/F");
404 MyTree->Branch(
"Gen_pt" ,Gen_pt ,
"Gen_pt[NGens]/F");
405 MyTree->Branch(
"Gen_eta" ,Gen_eta ,
"Gen_eta[NGens]/F");
406 MyTree->Branch(
"Gen_phi" ,Gen_phi ,
"Gen_phi[NGens]/F");
407 MyTree->Branch(
"Gen_beta" ,Gen_beta ,
"Gen_beta[NGens]/F");
408 MyTree->Branch(
"Gen_mass" ,Gen_mass ,
"Gen_mass[NGens]/F");
424 if (debug)
cout <<
"I'm in HSCPTreeBuilder::analyze!" << endl;
427 Event_EventNumber = iEvent.
id().
event();
428 Event_RunNumber = iEvent.
id().
run();
443 iEvent.
getByLabel(
"gtDigis", h_gtReadoutRecord);
444 L1GtFdlWord fdlWord = h_gtReadoutRecord->gtFdlWord();
446 Event_PhysicsDeclared = h_gtReadoutRecord->gtFdlWord().physicsDeclared();
447 for (
unsigned int i = 0;
i < 64; ++
i){ Event_technicalBits [
i] = L1technical[
i]; }
449 for (
unsigned int i = 0;
i < 128; ++
i){ Event_triggerL1Bits [
i] = L1decision[
i]; }
451 for (
unsigned int i = 0;
i < 64; ++
i){ Event_triggerL1Bits [128+
i] = L1decisionE[
i]; }
456 for(
unsigned int i=0;
i<trh->size() &&
i<128;++
i){Event_triggerHLTBits[
i] = trh->at(
i).accept();}
459 iEvent.
getByLabel(
"offlinePrimaryVertices", recoVertexHandle);
462 if(reccordVertexInfo){
464 for(
unsigned int i=0;
i<recoVertex.size();
i++){
465 Vertex_x [NVertices] = recoVertex[
i].x();
466 Vertex_y [NVertices] = recoVertex[
i].y();
467 Vertex_z [NVertices] = recoVertex[
i].z();
468 Vertex_x_err [NVertices] = recoVertex[
i].xError();
469 Vertex_y_err [NVertices] = recoVertex[
i].yError();
470 Vertex_z_err [NVertices] = recoVertex[
i].zError();
471 Vertex_TrackSize[NVertices] = recoVertex[
i].tracksSize();
472 Vertex_chi2 [NVertices] = recoVertex[
i].chi2();
473 Vertex_ndof [NVertices] = recoVertex[
i].ndof();
474 Vertex_isFake [NVertices] = recoVertex[
i].isFake();
481 iEvent.
getByLabel(m_HSCPsTag, HSCPCollectionHandle);
485 for(
unsigned int i=0;
i<HSCPCollection.size();
i++){
494 Hscp_type [NHSCPs] = hscp.
type();
497 Track_p [NHSCPs] = track->p();
498 Track_pt [NHSCPs] = track->pt();
499 Track_pt_err [NHSCPs] = track->ptError();
500 Track_eta [NHSCPs] = track->eta();
501 Track_eta_err [NHSCPs] = track->etaError();
502 Track_phi [NHSCPs] = track->phi();
503 Track_phi_err [NHSCPs] = track->phiError();
504 Track_NOH [NHSCPs] = track->found();
505 Track_chi2 [NHSCPs] = track->chi2();
506 Track_ndof [NHSCPs] = track->ndof();
507 Track_d0 [NHSCPs] = -1.0f * track->dxy(recoVertex[0].
position());
508 Track_dz [NHSCPs] = -1.0f * track->dz (recoVertex[0].
position());
509 Track_quality [NHSCPs] = track->qualityMask();
510 Track_charge [NHSCPs] = track->charge();
533 Muon_p [NHSCPs] = muon->p();
534 Muon_pt [NHSCPs] = muon->pt();
535 Muon_eta [NHSCPs] = muon->eta();
536 Muon_phi [NHSCPs] = muon->phi();
537 Muon_type [NHSCPs] = muon->type();
538 Muon_qualityValid [NHSCPs] = muon->isQualityValid();
539 Muon_charge [NHSCPs] = muon->charge();
587 Rpc_beta [NHSCPs] = hscp.
rpc().
beta;
596 iEvent.
getByLabel(
"genParticles", genParticles);
598 for(
unsigned int i=0;
i<genParticles->size();
i++){
600 if(part.
status()!=1)
continue;
601 if(part.
pt()<5)
continue;
604 Gen_pdgId [NGens] = part.
pdgId();
605 Gen_charge[NGens] = part.
charge();
606 Gen_p [NGens] = part.
p();
607 Gen_px [NGens] = part.
px();
608 Gen_py [NGens] = part.
py();
609 Gen_pz [NGens] = part.
pz();
610 Gen_pt [NGens] = part.
pt();
611 Gen_eta [NGens] = part.
eta();
612 Gen_phi [NGens] = part.
phi();
613 Gen_beta [NGens] = part.
p()/part.
energy();
614 Gen_mass [NGens] = part.
mass();
unsigned int Event_LumiSection
virtual double energy() const GCC11_FINAL
energy
T getParameter(std::string const &) const
EventNumber_t event() const
T getUntrackedParameter(std::string const &, T const &) const
const TechnicalTriggerWord & gtTechnicalTriggerWord() const
get/set technical trigger bits
virtual double p() const GCC11_FINAL
magnitude of momentum vector
const RPCBetaMeasurement & rpc() const
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
virtual int pdgId() const GCC11_FINAL
PDG identifier.
Timestamp const & time() const
unsigned int Event_BXCrossing
std::vector< Vertex > VertexCollection
collection of Vertex objects
tuple HSCPTreeBuilder
HSCP TREE BUILDER.
DEFINE_FWK_MODULE(HiMixingModule)
virtual void beginJob() override
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]
bool Event_PhysicsDeclared
LuminosityBlockNumber_t luminosityBlock() const
bool isNonnull() const
Checks for non-null.
virtual bool filter(edm::Event &, const edm::EventSetup &) override
std::vector< bool > DecisionWordExtended
virtual float phi() const GCC11_FINAL
momentum azimuthal angle
std::vector< HSCParticle > HSCParticleCollection
virtual int status() const GCC11_FINAL
status word
unsigned int Event_EventNumber
std::vector< bool > DecisionWord
typedefs
virtual double px() const GCC11_FINAL
x coordinate of momentum vector
std::vector< bool > TechnicalTriggerWord
technical trigger bits (64 bits)
const edm::EventSetup * iSetup_
const edm::Event * iEvent_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
virtual float eta() const GCC11_FINAL
momentum pseudorapidity
EventAuxiliary const & eventAuxiliary() const
virtual float mass() const GCC11_FINAL
mass
reco::MuonRef muonRef() const
virtual int charge() const GCC11_FINAL
electric charge
T const * product() const
const DecisionWord & gtDecisionWord() const
get/set/print algorithms bits (decision word)
T const * product() const
reco::TrackRef trackRef() const
virtual void endJob() override
volatile std::atomic< bool > shutdown_flag false
const DecisionWordExtended & gtDecisionWordExtended() const
get/set extended algorithms bits (extended decision word)
edm::Service< TFileService > tfs
virtual float pt() const GCC11_FINAL
transverse momentum
TimeValue_t value() const
unsigned int Event_RunNumber