diff --git a/Calibration/IsolatedParticles/interface/CaloPropagateTrack.h b/Calibration/IsolatedParticles/interface/CaloPropagateTrack.h index 033da06904501..32b813342b69f 100644 --- a/Calibration/IsolatedParticles/interface/CaloPropagateTrack.h +++ b/Calibration/IsolatedParticles/interface/CaloPropagateTrack.h @@ -100,6 +100,7 @@ namespace spr{ std::vector propagateCALO(const HepMC::GenEvent * genEvent, edm::ESHandle& pdt, const CaloGeometry* geo, const MagneticField* bField, double etaMax=3.0, bool debug=false); std::vector propagateCALO(edm::Handle& genParticles, edm::ESHandle& pdt, const CaloGeometry* geo, const MagneticField* bField, double etaMax=3.0, bool debug=false); spr::propagatedTrackDirection propagateCALO(unsigned int thisTrk, edm::Handle& SimTk, edm::Handle& SimVtx, const CaloGeometry* geo, const MagneticField* bField, bool debug=false); + spr::propagatedTrackDirection propagateHCALBack(unsigned int thisTrk, edm::Handle& SimTk, edm::Handle& SimVtx, const CaloGeometry* geo, const MagneticField* bField, bool debug=false); std::pair propagateHCALBack(const reco::Track*, const CaloGeometry* geo, const MagneticField* bField, bool debug=false); // Propagate tracks to the ECAL surface and optionally returns the diff --git a/Calibration/IsolatedParticles/macros/HBHEMuonOfflineAnalyzer.C b/Calibration/IsolatedParticles/macros/HBHEMuonOfflineAnalyzer.C deleted file mode 100644 index be1319ffc1fda..0000000000000 --- a/Calibration/IsolatedParticles/macros/HBHEMuonOfflineAnalyzer.C +++ /dev/null @@ -1,901 +0,0 @@ -////////////////////////////////////////////////////////// -// This class has been automatically generated on -// Sat Nov 17 12:34:52 2012 by ROOT version 5.30/04 -// from TTree TREE/TREE -// found on file: Validation.root -////////////////////////////////////////////////////////// - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -class HBHEMuonOfflineAnalyzer { - -public : - TTree *fChain; //!pointer to the analyzed TTree or TChain - Int_t fCurrent; //!current Tree number in a TChain - - // Declaration of leaf types - - UInt_t Event_No; - UInt_t Run_No; - UInt_t LumiNumber; - UInt_t BXNumber; - std::vector *pt_of_muon; - std::vector *eta_of_muon; - std::vector *phi_of_muon; - std::vector *energy_of_muon; - std::vector *p_of_muon; - std::vector *PF_Muon; - std::vector *Global_Muon; - std::vector *Tracker_muon; - std::vector *hcal_3into3; - std::vector *hcal_1x1; - std::vector *hcal_detID; - std::vector *hcal_edepth1; - std::vector *hcal_edepth2; - std::vector *hcal_edepth3; - std::vector *hcal_edepth4; - std::vector *hcal_edepthHot1; - std::vector *hcal_edepthHot2; - std::vector *hcal_edepthHot3; - std::vector *hcal_edepthHot4; - std::vector *TrackerLayer; - std::vector *matchedId; - std::vector *innerTrack; - std::vector *innerTrackpt; - std::vector *innerTracketa; - std::vector *innerTrackphi; - std::vector *MatchedStat; - std::vector *GlobalTrckPt; - std::vector *GlobalTrckEta; - std::vector *GlobalTrckPhi; - std::vector *NumPixelLayers; - std::vector *chiTracker; - std::vector *DxyTracker; - std::vector *DzTracker; - std::vector *OuterTrack; - std::vector *OuterTrackPt; - std::vector *OuterTrackEta; - std::vector *OuterTrackPhi; - std::vector *OuterTrackHits; - std::vector *OuterTrackRHits; - std::vector *OuterTrackChi; - std::vector *GlobalTrack; - std::vector *GlobTrack_Chi; - std::vector *Global_Muon_Hits; - std::vector *MatchedStations; - std::vector *Global_Track_Pt; - std::vector *Global_Track_Eta; - std::vector *Global_Track_Phi; - std::vector *Tight_LongitudinalImpactparameter; - std::vector *Tight_TransImpactparameter; - std::vector *InnerTrackPixelHits; - std::vector *IsolationR04; - std::vector *IsolationR03; - std::vector *hcal_cellHot; - std::vector *ecal_3into3; - std::vector *ecal_3x3; - std::vector *ecal_detID; - std::vector *ehcal_detID; - std::vector *tracker_3into3; - std::vector *activeLength; - std::vector *hltresults; - std::vector *all_triggers; - - - TBranch *b_Event_No; //! - TBranch *b_Run_No; //! - TBranch *b_LumiNumber; //! - TBranch *b_BXNumber; //! - TBranch *b_pt_of_muon; //! - TBranch *b_eta_of_muon; //! - TBranch *b_phi_of_muon; //! - TBranch *b_energy_of_muon; //! - TBranch *b_p_of_muon; //! - TBranch *b_PF_Muon; //! - TBranch *b_Global_Muon; //! - TBranch *b_Tracker_muon; //! - TBranch *b_hcal_3into3; //! - TBranch *b_hcal_1x1; //! - TBranch *b_hcal_detID; //! - TBranch *b_hcal_edepth1; //! - TBranch *b_hcal_edepth2; //! - TBranch *b_hcal_edepth3; //! - TBranch *b_hcal_edepth4; //! - TBranch *b_hcal_edepthHot1; //! - TBranch *b_hcal_edepthHot2; //! - TBranch *b_hcal_edepthHot3; //! - TBranch *b_hcal_edepthHot4; //! - TBranch *b_TrackerLayer; //! - TBranch *b_matchedId; //! - TBranch *b_innerTrack; //! - TBranch *b_innerTrackpt; //! - TBranch *b_innerTracketa; //! - TBranch *b_innerTrackphi; //! - TBranch *b_MatchedStat; //! - TBranch *b_GlobalTrckPt; //! - TBranch *b_GlobalTrckEta; //! - TBranch *b_GlobalTrckPhi; //! - TBranch *b_NumPixelLayers; //! - TBranch *b_chiTracker; //! - TBranch *b_DxyTracker; //! - TBranch *b_DzTracker; //! - TBranch *b_OuterTrack; //! - TBranch *b_OuterTrackPt; //! - TBranch *b_OuterTrackEta; //! - TBranch *b_OuterTrackPhi; //! - TBranch *b_OuterTrackHits; //! - TBranch *b_OuterTrackRHits; //! - TBranch *b_OuterTrackChi; //! - TBranch *b_GlobalTrack; //! - TBranch *b_GlobTrack_Chi; //! - TBranch *b_Global_Muon_Hits; //! - TBranch *b_MatchedStations; //! - TBranch *b_Global_Track_Pt; //! - TBranch *b_Global_Track_Eta; //! - TBranch *b_Global_Track_Phi; //! - TBranch *b_Tight_LongitudinalImpactparameter; //! - TBranch *b_Tight_TransImpactparameter; //! - TBranch *b_InnerTrackPixelHits; //! - TBranch *b_IsolationR04; //! - TBranch *b_IsolationR03; //! - TBranch *b_hcal_cellHot; //! - TBranch *b_ecal_3into3; //! - TBranch *b_ecal_3x3; //! - TBranch *b_ecal_detID; //! - TBranch *b_ehcal_detID; //! - TBranch *b_tracker_3into3; //! - TBranch *b_activeLength; //! - TBranch *b_hltresults; //! - TBranch *b_all_triggers; //! - - - HBHEMuonOfflineAnalyzer(TTree *tree=0, const char *outfile="dyll_PU20_25_output_10.root", const int mode=0, const int maxDHB=3, const int maxDHE=3); - // mode of LHC is kept 1 for 2017 scenario as no change in depth segmentation - // mode of LHC is 0 for 2019 - virtual ~HBHEMuonOfflineAnalyzer(); - virtual Int_t Cut(Long64_t entry); - virtual Int_t GetEntry(Long64_t entry); - virtual Long64_t LoadTree(Long64_t entry); - virtual void Init(TTree *tree); - virtual void Loop(); - virtual Bool_t Notify(); - virtual void Show(Long64_t entry = -1); - - std::vector firedTriggers; - void BookHistograms(const char* ); - bool LooseMuon(unsigned int ml); - bool tightMuon(unsigned int ml); - bool SoftMuon(unsigned int ml); - void etaPhiHcal(unsigned int detId, int &eta, int &phi, int &depth); - void etaPhiEcal(unsigned int detId, int& type, int& zside, - int& etaX, int& phiY, int& plane, int& strip); - void calculateP(double pt ,double eta , double& pM); - void close(); -private: - static const bool debug_=false; - static const int maxDep=3; - static const int maxEta=29; - static const int maxPhi=72; - //3x16x72x2 + 5x4x72x2 + 5x9x36x2 - static const int maxHist=13032; - int modeLHC, maxDepthHB_, maxDepthHE_, maxDepth_; - int nHist, nDepths[maxEta], nDepthsPhi[maxEta],indxEta[maxEta][maxDep][maxPhi]; - TFile *output_file; - - TH1D *h_Pt_Muon[3], *h_Eta_Muon[3], *h_Phi_Muon[3], *h_P_Muon[3]; - TH1D *h_PF_Muon[3], *h_GlobTrack_Chi[3], *h_Global_Muon_Hits[3]; - TH1D *h_MatchedStations[3], *h_Tight_TransImpactparameter[3]; - TH1D *h_Tight_LongitudinalImpactparameter[3], *h_InnerTrackPixelHits[3]; - TH1D *h_TrackerLayer[3], *h_IsolationR04[3] , *h_Global_Muon[3]; - TH1D *h_LongImpactParameter[3], *h_LongImpactParameterBin1[3], *h_LongImpactParameterBin2[3]; - - TH1D *h_TransImpactParameter[3], *h_TransImpactParameterBin1[3], *h_TransImpactParameterBin2[3]; - TH1D *h_Hot_MuonEnergy_hcal_ClosestCell[3][maxHist] , *h_Hot_MuonEnergy_hcal_HotCell[3][maxHist] , *h_Hot_MuonEnergy_hcal_HotCell_VsActiveLength[3][maxHist], *h_HotCell_MuonEnergy_phi[3][maxHist]; - TH2D *h_2D_Bin1[3], *h_2D_Bin2[3]; - TH1D *h_ecal_energy[3], *h_hcal_energy[3], *h_3x3_ecal[3], *h_1x1_hcal[3]; - TH1D *h_MuonHittingEcal[3], *h_HotCell[3], *h_MuonEnergy_hcal[3][maxHist]; - TH1D *h_Hot_MuonEnergy_hcal[3][maxHist]; - TH2D *hcal_ietaVsEnergy[3]; - TProfile *h_EtaX_hcal[3], *h_PhiY_hcal[3], *h_EtaX_ecal[3], *h_PhiY_ecal[3]; - TProfile *h_Eta_ecal[3], *h_Phi_ecal[3]; - TProfile *h_MuonEnergy_eta[3][maxDep], *h_MuonEnergy_phi[3][maxDep], *h_MuonEnergy_muon_eta[3][maxDep]; - TProfile *h_Hot_MuonEnergy_eta[3][maxDep], *h_Hot_MuonEnergy_phi[3][maxDep], *h_Hot_MuonEnergy_muon_eta[3][maxDep]; - TProfile *h_IsoHot_MuonEnergy_eta[3][maxDep], *h_IsoHot_MuonEnergy_phi[3][maxDep], *h_IsoHot_MuonEnergy_muon_eta[3][maxDep]; - TProfile *h_IsoWithoutHot_MuonEnergy_eta[3][maxDep], *h_IsoWithoutHot_MuonEnergy_phi[3][maxDep], *h_IsoWithoutHot_MuonEnergy_muon_eta[3][maxDep]; - TProfile *h_HotWithoutIso_MuonEnergy_eta[3][maxDep], *h_HotWithoutIso_MuonEnergy_phi[3][maxDep], *h_HotWithoutIso_MuonEnergy_muon_eta[3][maxDep]; -}; - -HBHEMuonOfflineAnalyzer::HBHEMuonOfflineAnalyzer(TTree *tree, const char* outFileName, - const int mode, const int maxDHB, - const int maxDHE) : modeLHC(mode), - maxDepthHB_(maxDHB), - maxDepthHE_(maxDHE) { - maxDepth_ = (maxDepthHB_ > maxDepthHE_) ? maxDepthHB_ : maxDepthHE_; - // if parameter tree is not specified (or zero), connect the file - // used to generate this class and read the Tree. - // std::cout<<"maxDepth_"<GetListOfFiles()->FindObject("file:/uscmst1b_scratch/lpc1/3DayLifetime/aman30/RunD.root"); - if (!f || !f->IsOpen()) { - f = new TFile("file:/uscmst1b_scratch/lpc1/3DayLifetime/aman30/RunD.root"); - } - TDirectory * dir = (TDirectory*)f->Get("/uscmst1b_scratch/lpc1/3DayLifetime/aman30/RunD.root:/HcalHBHEMuonAnalyzer"); - dir->GetObject("TREE",tree); - } - Init(tree); - - //Now book histograms - BookHistograms(outFileName); -} - -HBHEMuonOfflineAnalyzer::~HBHEMuonOfflineAnalyzer() { - if (!fChain) return; - delete fChain->GetCurrentFile(); -} - -Int_t HBHEMuonOfflineAnalyzer::Cut(Long64_t ) { - // This function may be called from Loop. - // returns 1 if entry is accepted. - // returns -1 otherwise. - return 1; -} - -Int_t HBHEMuonOfflineAnalyzer::GetEntry(Long64_t entry) { - // Read contents of entry. - if (!fChain) return 0; - return fChain->GetEntry(entry); -} - -Long64_t HBHEMuonOfflineAnalyzer::LoadTree(Long64_t entry) { - // Set the environment to read one entry - if (!fChain) return -5; - Long64_t centry = fChain->LoadTree(entry); - if (centry < 0) return centry; - if (fChain->GetTreeNumber() != fCurrent) { - fCurrent = fChain->GetTreeNumber(); - Notify(); - } - return centry; -} - -void HBHEMuonOfflineAnalyzer::Init(TTree *tree) { - // The Init() function is called when the selector needs to initialize - // a new tree or chain. Typically here the branch addresses and branch - // pointers of the tree will be set. - // It is normally not necessary to make changes to the generated - // code, but the routine can be extended by the user if needed. - // Init() will be called many times when running on PROOF - // (once per file to be processed). - - // Set object pointer - pt_of_muon = 0; - eta_of_muon = 0; - phi_of_muon = 0; - energy_of_muon = 0; - p_of_muon = 0; - PF_Muon = 0; - Global_Muon = 0; - Tracker_muon = 0; - hcal_3into3 = 0; - hcal_1x1 = 0; - hcal_detID = 0; - hcal_edepth1 = 0; - hcal_edepth2 = 0; - hcal_edepth3 = 0; - hcal_edepth4 = 0; - hcal_edepthHot1 = 0; - hcal_edepthHot2 = 0; - hcal_edepthHot3 = 0; - hcal_edepthHot4 = 0; - TrackerLayer = 0; - matchedId = 0; - innerTrack = 0; - innerTrackpt = 0; - innerTracketa = 0; - innerTrackphi = 0; - MatchedStat = 0; - GlobalTrckPt = 0; - GlobalTrckEta = 0; - GlobalTrckPhi = 0; - NumPixelLayers = 0; - chiTracker = 0; - DxyTracker = 0; - DzTracker = 0; - OuterTrack = 0; - OuterTrackPt = 0; - OuterTrackEta = 0; - OuterTrackPhi = 0; - OuterTrackHits = 0; - OuterTrackRHits = 0; - OuterTrackChi = 0; - GlobalTrack = 0; - GlobTrack_Chi = 0; - Global_Muon_Hits = 0; - MatchedStations = 0; - Global_Track_Pt = 0; - Global_Track_Eta = 0; - Global_Track_Phi = 0; - Tight_LongitudinalImpactparameter = 0; - Tight_TransImpactparameter = 0; - InnerTrackPixelHits = 0; - IsolationR04 = 0; - IsolationR03 = 0; - hcal_cellHot = 0; - ecal_3into3 = 0; - ecal_3x3 = 0; - ecal_detID = 0; - ehcal_detID = 0; - tracker_3into3 = 0; - activeLength = 0; - hltresults = 0; - all_triggers = 0; - - if (!tree) return; - fChain = tree; - fCurrent = -1; - fChain->SetMakeClass(1); - - fChain->SetBranchAddress("Event_No", &Event_No, &b_Event_No); - fChain->SetBranchAddress("Run_No", &Run_No, &b_Run_No); - fChain->SetBranchAddress("LumiNumber", &LumiNumber, &b_LumiNumber); - fChain->SetBranchAddress("BXNumber", &BXNumber, &b_BXNumber); - fChain->SetBranchAddress("pt_of_muon", &pt_of_muon, &b_pt_of_muon); - fChain->SetBranchAddress("eta_of_muon", &eta_of_muon, &b_eta_of_muon); - fChain->SetBranchAddress("phi_of_muon", &phi_of_muon, &b_phi_of_muon); - fChain->SetBranchAddress("energy_of_muon", &energy_of_muon, &b_energy_of_muon); - fChain->SetBranchAddress("p_of_muon", &p_of_muon, &b_p_of_muon); - fChain->SetBranchAddress("PF_Muon", &PF_Muon, &b_PF_Muon); - fChain->SetBranchAddress("Global_Muon", &Global_Muon, &b_Global_Muon); - fChain->SetBranchAddress("Tracker_muon", &Tracker_muon, &b_Tracker_muon); - fChain->SetBranchAddress("hcal_3into3", &hcal_3into3, &b_hcal_3into3); - fChain->SetBranchAddress("hcal_1x1", &hcal_1x1, &b_hcal_1x1); - fChain->SetBranchAddress("hcal_detID", &hcal_detID, &b_hcal_detID); - fChain->SetBranchAddress("hcal_edepth1", &hcal_edepth1, &b_hcal_edepth1); - fChain->SetBranchAddress("hcal_edepth2", &hcal_edepth2, &b_hcal_edepth2); - fChain->SetBranchAddress("hcal_edepth3", &hcal_edepth3, &b_hcal_edepth3); - fChain->SetBranchAddress("hcal_edepth4", &hcal_edepth4, &b_hcal_edepth4); - fChain->SetBranchAddress("hcal_edepthHot1", &hcal_edepthHot1, &b_hcal_edepthHot1); - fChain->SetBranchAddress("hcal_edepthHot2", &hcal_edepthHot2, &b_hcal_edepthHot2); - fChain->SetBranchAddress("hcal_edepthHot3", &hcal_edepthHot3, &b_hcal_edepthHot3); - fChain->SetBranchAddress("hcal_edepthHot4", &hcal_edepthHot4, &b_hcal_edepthHot4); - fChain->SetBranchAddress("TrackerLayer", &TrackerLayer, &b_TrackerLayer); - fChain->SetBranchAddress("matchedId", &matchedId, &b_matchedId); - fChain->SetBranchAddress("innerTrack", &innerTrack, &b_innerTrack); - fChain->SetBranchAddress("innerTrackpt", &innerTrackpt, &b_innerTrackpt); - fChain->SetBranchAddress("innerTracketa", &innerTracketa, &b_innerTracketa); - fChain->SetBranchAddress("innerTrackphi", &innerTrackphi, &b_innerTrackphi); - fChain->SetBranchAddress("MatchedStat", &MatchedStat, &b_MatchedStat); - fChain->SetBranchAddress("GlobalTrckPt", &GlobalTrckPt, &b_GlobalTrckPt); - fChain->SetBranchAddress("GlobalTrckEta", &GlobalTrckEta, &b_GlobalTrckEta); - fChain->SetBranchAddress("GlobalTrckPhi", &GlobalTrckPhi, &b_GlobalTrckPhi); - fChain->SetBranchAddress("NumPixelLayers", &NumPixelLayers, &b_NumPixelLayers); - fChain->SetBranchAddress("chiTracker", &chiTracker, &b_chiTracker); - fChain->SetBranchAddress("DxyTracker", &DxyTracker, &b_DxyTracker); - fChain->SetBranchAddress("DzTracker", &DzTracker, &b_DzTracker); - fChain->SetBranchAddress("OuterTrack", &OuterTrack, &b_OuterTrack); - fChain->SetBranchAddress("OuterTrackPt", &OuterTrackPt, &b_OuterTrackPt); - fChain->SetBranchAddress("OuterTrackEta", &OuterTrackEta, &b_OuterTrackEta); - fChain->SetBranchAddress("OuterTrackPhi", &OuterTrackPhi, &b_OuterTrackPhi); - fChain->SetBranchAddress("OuterTrackHits", &OuterTrackHits, &b_OuterTrackHits); - fChain->SetBranchAddress("OuterTrackRHits", &OuterTrackRHits, &b_OuterTrackRHits); - fChain->SetBranchAddress("OuterTrackChi", &OuterTrackChi, &b_OuterTrackChi); - fChain->SetBranchAddress("GlobalTrack", &GlobalTrack, &b_GlobalTrack); - fChain->SetBranchAddress("GlobTrack_Chi", &GlobTrack_Chi, &b_GlobTrack_Chi); - fChain->SetBranchAddress("Global_Muon_Hits", &Global_Muon_Hits, &b_Global_Muon_Hits); - fChain->SetBranchAddress("MatchedStations", &MatchedStations, &b_MatchedStations); - fChain->SetBranchAddress("Global_Track_Pt", &Global_Track_Pt, &b_Global_Track_Pt); - fChain->SetBranchAddress("Global_Track_Eta", &Global_Track_Eta, &b_Global_Track_Eta); - fChain->SetBranchAddress("Global_Track_Phi", &Global_Track_Phi, &b_Global_Track_Phi); - fChain->SetBranchAddress("Tight_LongitudinalImpactparameter", &Tight_LongitudinalImpactparameter, &b_Tight_LongitudinalImpactparameter); - fChain->SetBranchAddress("Tight_TransImpactparameter", &Tight_TransImpactparameter, &b_Tight_TransImpactparameter); - fChain->SetBranchAddress("InnerTrackPixelHits", &InnerTrackPixelHits, &b_InnerTrackPixelHits); - fChain->SetBranchAddress("IsolationR04", &IsolationR04, &b_IsolationR04); - fChain->SetBranchAddress("IsolationR03", &IsolationR03, &b_IsolationR03); - fChain->SetBranchAddress("hcal_cellHot", &hcal_cellHot, &b_hcal_cellHot); - fChain->SetBranchAddress("ecal_3into3", &ecal_3into3, &b_ecal_3into3); - fChain->SetBranchAddress("ecal_3x3", &ecal_3x3, &b_ecal_3x3); - fChain->SetBranchAddress("ecal_detID", &ecal_detID, &b_ecal_detID); - fChain->SetBranchAddress("ehcal_detID", &ehcal_detID, &b_ehcal_detID); - fChain->SetBranchAddress("tracker_3into3", &tracker_3into3, &b_tracker_3into3); - fChain->SetBranchAddress("activeLength", &activeLength, &b_activeLength); - fChain->SetBranchAddress("hltresults", &hltresults, &b_hltresults); - fChain->SetBranchAddress("all_triggers", &all_triggers, &b_all_triggers); - Notify(); -} - -void HBHEMuonOfflineAnalyzer::Loop() { - - //declarations - if (fChain == 0) return; - - Long64_t nentries = fChain->GetEntriesFast(); - - if(debug_) std::cout << "nevent = " << nentries << std::endl; - - Long64_t nbytes = 0, nb = 0; - - for (Long64_t jentry=0; jentryGetEntry(jentry); nbytes += nb; - - for (unsigned int ml = 0;ml< pt_of_muon->size();ml++) { - - if(debug_) std::cout << "ecal_det_id " << ecal_detID->at(ml) << std::endl; - - int typeEcal, etaXEcal, phiYEcal, zsideEcal, planeEcal, stripEcal; - etaPhiEcal(ecal_detID->at(ml),typeEcal,zsideEcal,etaXEcal,phiYEcal,planeEcal,stripEcal); - double etaEcal = (etaXEcal-0.5)*zsideEcal; - double phiEcal = phiYEcal-0.5; - - if(debug_) std::cout << "hcal_det_id " << std::hex << hcal_detID->at(ml) << std::dec; - - int etaHcal, phiHcal, depthHcal; - etaPhiHcal(hcal_detID->at(ml),etaHcal,phiHcal,depthHcal); - - int eta = (etaHcal > 0) ? etaHcal-1 : -(1+etaHcal); - - double etaXHcal = (etaHcal > 0) ? etaHcal-0.5 : etaHcal+0.5; - - if(debug_) std::cout<<"phiHcal"<Fill(p_of_muon->at(ml)); - h_Pt_Muon[cut]->Fill(pt_of_muon->at(ml)); - h_Eta_Muon[cut]->Fill(eta_of_muon->at(ml)); - h_Phi_Muon[cut]->Fill(phi_of_muon->at(ml)); - h_PF_Muon[cut]->Fill(PF_Muon->at(ml)); - h_GlobTrack_Chi[cut]->Fill(GlobTrack_Chi->at(ml)); - h_Global_Muon_Hits[cut]->Fill(Global_Muon_Hits->at(ml)); - h_MatchedStations[cut]->Fill(MatchedStations->at(ml)); - h_Tight_TransImpactparameter[cut]->Fill(Tight_TransImpactparameter->at(ml)); - h_Tight_LongitudinalImpactparameter[cut]->Fill(Tight_LongitudinalImpactparameter->at(ml)); - h_InnerTrackPixelHits[cut]->Fill(InnerTrackPixelHits->at(ml)); - h_TrackerLayer[cut]->Fill(TrackerLayer->at(ml)); - h_IsolationR04[cut]->Fill(IsolationR04->at(ml)); - h_Global_Muon[cut]->Fill(Global_Muon->at(ml)); - - h_TransImpactParameter[cut]->Fill(Tight_TransImpactparameter->at(ml)); - h_LongImpactParameter[cut]->Fill(Tight_LongitudinalImpactparameter->at(ml)); - - //in Phi Bins - if(((phi_of_muon->at(ml)) >= -1.5) || ((phi_of_muon->at(ml)) <= 0.5)) { - h_TransImpactParameterBin1[cut]->Fill(Tight_TransImpactparameter->at(ml)); - h_LongImpactParameterBin1[cut]->Fill(Tight_LongitudinalImpactparameter->at(ml)); - h_2D_Bin1[cut]->Fill(Tight_TransImpactparameter->at(ml),Tight_LongitudinalImpactparameter->at(ml)); - } - - if((phi_of_muon->at(ml) > 0.5) || (phi_of_muon->at(ml) < -1.5)) { - h_TransImpactParameterBin2[cut]->Fill(Tight_TransImpactparameter->at(ml)); - h_LongImpactParameterBin2[cut]->Fill(Tight_LongitudinalImpactparameter->at(ml)); - h_2D_Bin2[cut]->Fill(Tight_TransImpactparameter->at(ml),Tight_LongitudinalImpactparameter->at(ml)); - } - - - h_ecal_energy[cut]->Fill(ecal_3into3->at(ml)); - h_3x3_ecal[cut]->Fill(ecal_3x3->at(ml)); - h_Eta_ecal[cut]->Fill(eta_of_muon->at(ml),ecal_3x3->at(ml)); - h_Phi_ecal[cut]->Fill(phi_of_muon->at(ml),ecal_3x3->at(ml)); - h_MuonHittingEcal[cut]->Fill(typeEcal); - if (typeEcal == 1) { - h_EtaX_ecal[cut]->Fill(etaEcal,ecal_3x3->at(ml)); - h_PhiY_ecal[cut]->Fill(phiEcal,ecal_3x3->at(ml)); - } - - h_hcal_energy[cut]->Fill(hcal_3into3->at(ml)); - h_1x1_hcal[cut]->Fill(hcal_1x1->at(ml)); - h_EtaX_hcal[cut]->Fill(etaXHcal,hcal_1x1->at(ml)); - h_PhiY_hcal[cut]->Fill(phiYHcal,hcal_1x1->at(ml)); - h_HotCell[cut]->Fill(hcal_cellHot->at(ml)); - - for (int dep=0; depat(ml); - en2 = hcal_edepthHot1->at(ml); - } else if (dep == 1) { - en1 = hcal_edepth2->at(ml); - en2 = hcal_edepthHot2->at(ml); - if(debug_) std::cout<<"problem here.. lets see if it got printed"<at(ml); - en2 = hcal_edepthHot3->at(ml); - } else if (dep == 3) { - en1 = hcal_edepth4->at(ml); - en2 = hcal_edepthHot4->at(ml); - if(debug_) std::cout<<"Hello in 4"< -9999); - bool ok2 = (en2 > -9999); - - if(debug_) std::cout<<"Before Index"< 0) ? indxEta[eta][dep][PHI] : 1+indxEta[eta][dep][PHI]; - - if(debug_) std::cout<<"ieta"<at(ml))) continue; - if (ok1) { - if(debug_) std::cout<<"enter ok1"<at(ml)==1) { - if(en2 > 0) { - h_Hot_MuonEnergy_hcal_HotCell_VsActiveLength[cut][ind]->Fill(en2/activeLength->at(ml)); - } - if(debug_) std::cout<<"enter hot cell"<at(ml)!=1) { - } - } - - if(debug_) std::cout<<"ETA \t"<Show(entry); -} - -void HBHEMuonOfflineAnalyzer::BookHistograms(const char* fname) { - output_file = TFile::Open(fname,"RECREATE"); - std::string type[]={"tight","soft","loose"}; - char name[128], title[500]; - - std::cout<<"BookHistograms"< 15 && eta < 29) { - nDepths[eta] = maxDepthHE_; - } - - if(debug_) std::cout<<"Eta:"< 0.5 and #phi< -1.5 ", type[i].c_str()); - h_TransImpactParameterBin2[i] = new TH1D(name, title,100,0,0.5); - // - sprintf (name, "h_LongImpactParameter_%s", type[i].c_str()); - sprintf (title, "LongImpactParameter of %s muons (GeV)", type[i].c_str()); - h_LongImpactParameter[i] = new TH1D(name, title,100,0,30); - - sprintf (name, "h_LongImpactParameterBin1_%s", type[i].c_str()); - sprintf (title, "LongImpactParameter of %s muons (GeV) in -1.5 <= #phi <= 0.5", type[i].c_str()); - h_LongImpactParameterBin1[i] = new TH1D(name, title,100,0,30); - - sprintf (name, "h_LongImpactParameterBin2_%s", type[i].c_str()); - sprintf (title, "LongImpactParameter of %s muons (GeV) in #phi> 0.5 and #phi< -1.5 ", type[i].c_str()); - h_LongImpactParameterBin2[i] = new TH1D(name, title,100,0,30); - - sprintf (name, "h_2D_Bin1_%s", type[i].c_str()); - sprintf (title, "Trans/Long ImpactParameter of %s muons (GeV) in -1.5 <= #phi< 0.5 ", type[i].c_str()); - h_2D_Bin1[i] = new TH2D(name, title, 100,0,0.5,100,0,30); - - sprintf (name, "h_2D_Bin2_%s", type[i].c_str()); - sprintf (title, "Trans/Long ImpactParameter of %s muons (GeV) in #phi> 0.5 and #phi< -1.5 ", type[i].c_str()); - h_2D_Bin2[i] = new TH2D(name, title, 100,0,0.5,100,0,30); - - sprintf (name, "h_ecal_energy_%s", type[i].c_str()); - sprintf (title, "ECAL energy for %s muons", type[i].c_str()); - h_ecal_energy[i] = new TH1D(name, title,1000,-10.0,90.0); - - sprintf (name, "h_hcal_energy_%s", type[i].c_str()); - sprintf (title, "HCAL energy for %s muons", type[i].c_str()); - h_hcal_energy[i] = new TH1D(name, title,500,-10.0,90.0); - - sprintf (name, "h_3x3_ecal_%s", type[i].c_str()); - sprintf (title, "ECAL energy in 3x3 for %s muons", type[i].c_str()); - h_3x3_ecal[i] = new TH1D(name, title,1000,-10.0,90.0); - - sprintf (name, "h_1x1_hcal_%s", type[i].c_str()); - sprintf (title, "HCAL energy in 1x1 for %s muons", type[i].c_str()); - h_1x1_hcal[i] = new TH1D(name, title,500,-10.0,90.0); - - sprintf (name, "h_EtaX_hcal_%s", type[i].c_str()); - sprintf (title, "HCAL energy as a function of i#eta for %s muons", type[i].c_str()); - h_EtaX_hcal[i] = new TProfile(name, title,60,-30.0,30.0); - - sprintf (name, "h_PhiY_hcal_%s", type[i].c_str()); - sprintf (title, "HCAL energy as a function of i#phi for %s muons", type[i].c_str()); - h_PhiY_hcal[i] = new TProfile(name, title,72,0,72); - - sprintf (name, "h_EtaX_ecal_%s", type[i].c_str()); - sprintf (title, "EB energy as a function of i#eta for %s muons", type[i].c_str()); - h_EtaX_ecal[i] = new TProfile(name, title,170,-85.0,85.0); - - sprintf (name, "h_PhiY_ecal_%s", type[i].c_str()); - sprintf (title, "EB energy as a function of i#phi for %s muons", type[i].c_str()); - h_PhiY_ecal[i] = new TProfile(name, title,360,0,360); - - sprintf (name, "h_Eta_ecal_%s", type[i].c_str()); - sprintf (title, "ECAL energy as a function of #eta for %s muons", type[i].c_str()); - h_Eta_ecal[i] = new TProfile(name, title,100,-2.5,2.5); - - sprintf (name, "h_Phi_ecal_%s", type[i].c_str()); - sprintf (title, "ECAL energy as a function of #phi for %s muons", type[i].c_str()); - h_Phi_ecal[i] = new TProfile(name, title,100,-3.1415926,3.1415926); - - sprintf (name, "h_MuonHittingEcal_%s", type[i].c_str()); - sprintf (title, "%s muons hitting ECAL", type[i].c_str()); - h_MuonHittingEcal[i] = new TH1D(name, title,100,0,5.0); - - sprintf (name, "h_HotCell_%s", type[i].c_str()); - sprintf (title, "Hot cell for %s muons", type[i].c_str()); - h_HotCell[i] = new TH1D(name, title,100,0,2); - - for (int eta=0; eta<29; ++eta) { - for (int depth=0; depthat(ml)) { - if (Global_Muon->at(ml) && Tracker_muon->at(ml)) { - if (pt_of_muon->at(ml)>20.) { - if (IsolationR04->at(ml) < 0.12) { - return true; - } - } - } - } - return false; -} - -bool HBHEMuonOfflineAnalyzer::SoftMuon(unsigned int ml){ - if (innerTrack->at(ml)){ - if (pt_of_muon->at(ml) > 20.){ - if (TrackerLayer->at(ml)>5) { - if (innerTrack->at(ml) && NumPixelLayers->at(ml)> 1) { - if (chiTracker->at(ml) < 1.8 && DxyTracker->at(ml) <3 && DzTracker->at(ml) <30) { - if (IsolationR04->at(ml) < 0.12) { - return true; - } - } - } - } - } - } - return false; -} - -bool HBHEMuonOfflineAnalyzer::tightMuon(unsigned int ml) { - if (PF_Muon->at(ml) && (Global_Muon->at(ml))) { - // if(debug_) std::cout<<"global and PF Muon"<at(ml)) { - if (pt_of_muon->at(ml) > 20.) { - if (GlobTrack_Chi->at(ml) < 10 && Global_Muon_Hits->at(ml) >0 && MatchedStations->at(ml)>1){ - if (Tight_TransImpactparameter->at(ml) < 0.2 && Tight_LongitudinalImpactparameter->at(ml) < 0.5 ){ - if (InnerTrackPixelHits->at(ml) > 0 && TrackerLayer->at(ml) > 5){ - if (IsolationR04->at(ml) < 0.12) { - return true; - } - } - } - } - } - } - } - return false; -} - -void HBHEMuonOfflineAnalyzer::etaPhiHcal(unsigned int detId, int &eta, int &phi, int &depth) { - int zside, etaAbs; - if ((detId&0x1000000)==0) { - zside = (detId&0x2000)?(1):(-1); - etaAbs = (detId>>7)&0x3F; - phi = detId&0x7F; - depth = (detId>>14)&0x1F; - } else { - zside = (detId&0x80000)?(1):(-1); - etaAbs = (detId>>10)&0x1FF; - phi = detId&0x3FF; - depth = (detId>>20)&0xF; - } - eta = etaAbs*zside; -} - -void HBHEMuonOfflineAnalyzer::etaPhiEcal(unsigned int detId, int& type, int& zside, - int& etaX, int& phiY, int& plane, int& strip) { - - type = ((detId>>25)&0x7); - // std::cout<<"type"<>9)&0x7F; - phiY = detId&0x1FF; - } else if (type==2) { - zside = (detId&0x4000)?(1):(-1); - etaX = (detId>>7)&0x7F; - phiY = (detId&0x7F); - } else if (type==3) { - zside = (detId&0x80000)?(1):(-1); - etaX = (detId>>6)&0x3F; - /** get the sensor iy */ - phiY = (detId>>12)&0x3F; - /** get the strip */ - plane = ((detId>>18)&0x1)+1; - strip = detId&0x3F; - } else { - zside = etaX = phiY = 0; - } -} - - -void HBHEMuonOfflineAnalyzer::calculateP(double pt, double eta, double& pM) { - pM = (pt*cos(2*(1/atan(exp(eta))))); -} - -void HBHEMuonOfflineAnalyzer::close() { - output_file->cd(); - std::cout << "file yet to be Written" << std::endl; - output_file->Write(); - std::cout << "file Written" << std::endl; - output_file->Close(); - std::cout << "now doing return" << std::endl; -} diff --git a/Calibration/IsolatedParticles/macros/HBHEMuonOfflineSimAnalyzer.C b/Calibration/IsolatedParticles/macros/HBHEMuonOfflineSimAnalyzer.C new file mode 100644 index 0000000000000..e25bb87d03146 --- /dev/null +++ b/Calibration/IsolatedParticles/macros/HBHEMuonOfflineSimAnalyzer.C @@ -0,0 +1,885 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class HBHEMuonOfflineSimAnalyzer { + +public : + TTree *fChain; //!pointer to the analyzed TTree or TChain + Int_t fCurrent; + + UInt_t Run_No; + UInt_t Event_No; + UInt_t LumiNumber; + UInt_t BXNumber; + std::vector *pt_of_muon; + std::vector *eta_of_muon; + std::vector *phi_of_muon; + std::vector *p_of_muon; + std::vector *ecal_3x3; + std::vector *ecal_detID; + std::vector *hcal_1x1; + std::vector *matchedId; + std::vector *hcal_detID; + std::vector *hcal_cellHot; + std::vector *activeLength; + std::vector *hcal_edepth1; + std::vector *hcal_edepth2; + std::vector *hcal_edepth3; + std::vector *hcal_edepth4; + std::vector *hcal_activeL1; + std::vector *hcal_activeL2; + std::vector *hcal_activeL3; + std::vector *hcal_activeL4; + std::vector *activeLengthHot; + std::vector *hcal_edepthHot1; + std::vector *hcal_edepthHot2; + std::vector *hcal_edepthHot3; + std::vector *hcal_edepthHot4; + std::vector *hcal_activeHotL1; + std::vector *hcal_activeHotL2; + std::vector *hcal_activeHotL3; + std::vector *hcal_activeHotL4; + std::vector *hcal_edepth5; + std::vector *hcal_activeL5; + std::vector *hcal_edepthHot5; + std::vector *hcal_activeHotL5; + std::vector *hcal_edepth6; + std::vector *hcal_activeL6; + std::vector *hcal_edepthHot6; + std::vector *hcal_activeHotL6; + std::vector *hcal_edepth7; + std::vector *hcal_activeL7; + std::vector *hcal_edepthHot7; + std::vector *hcal_activeHotL7; + + TBranch *b_Run_No; //! + TBranch *b_Event_No; //! + TBranch *b_LumiNumber; //! + TBranch *b_BXNumber; //! + TBranch *b_pt_of_muon; //! + TBranch *b_eta_of_muon; //! + TBranch *b_phi_of_muon; //! + TBranch *b_p_of_muon; //! + TBranch *b_ecal_3x3; //! + TBranch *b_ecal_detID; //! + TBranch *b_hcal_1x1; //! + TBranch *b_hcal_detID; //! + TBranch *b_hcal_cellHot; //! + TBranch *b_activeLength; //! + TBranch *b_hcal_edepth1; //! + TBranch *b_hcal_edepth2; //! + TBranch *b_hcal_edepth3; //! + TBranch *b_hcal_edepth4; //! + TBranch *b_hcal_activeL1; //! + TBranch *b_hcal_activeL2; //! + TBranch *b_hcal_activeL3; //! + TBranch *b_hcal_activeL4; //! + TBranch *b_activeLengthHot; //! + TBranch *b_hcal_edepthHot1; //! + TBranch *b_hcal_edepthHot2; //! + TBranch *b_hcal_edepthHot3; //! + TBranch *b_hcal_edepthHot4; //! + TBranch *b_hcal_activeHotL1; //! + TBranch *b_hcal_activeHotL2; //! + TBranch *b_hcal_activeHotL3; //! + TBranch *b_hcal_activeHotL4; //! + TBranch *b_hcal_edepth5; //! + TBranch *b_hcal_activeL5; //! + TBranch *b_hcal_edepthHot5; //! + TBranch *b_hcal_activeHotL5; //! + TBranch *b_hcal_edepth6; //! + TBranch *b_hcal_activeL6; //! + TBranch *b_hcal_edepthHot6; //! + TBranch *b_hcal_activeHotL6; //! + TBranch *b_hcal_edepth7; //! + TBranch *b_hcal_activeL7; //! + TBranch *b_hcal_edepthHot7; //! + TBranch *b_hcal_activeHotL7; //! + TBranch *b_matchedId; //! + + HBHEMuonOfflineSimAnalyzer(const char *infile, const char *outfile="dyll_PU20_25_output_10.root", const int mode=0, const int maxDHB=4, const int maxDHE=7); + // mode of LHC is kept 1 for 2017 scenario as no change in depth segmentation + // mode of LHC is 0 for 2019 + virtual ~HBHEMuonOfflineSimAnalyzer(); + virtual Int_t Cut(Long64_t entry); + virtual Int_t GetEntry(Long64_t entry); + virtual Long64_t LoadTree(Long64_t entry); + virtual void Init(TTree *tree); + virtual void Loop(); + virtual Bool_t Notify(); + virtual void Show(Long64_t entry = -1); + + std::vector firedTriggers; + void BookHistograms(const char* ); + void WriteHistograms(); + bool LooseMuon(unsigned int ml); + bool tightMuon(unsigned int ml); + bool SoftMuon(unsigned int ml); + void etaPhiHcal(unsigned int detId, int &eta, int &phi, int &depth); + void etaPhiEcal(unsigned int detId, int& type, int& zside, + int& etaX, int& phiY, int& plane, int& strip); + void calculateP(double pt, double eta, double& pM); + void close(); + int NDepthBins(int ieta); + int NPhiBins(int ieta); + +private: + static const bool debug_=false; + static const int maxDep=7; + static const int maxEta=29; + static const int maxPhi=72; + //3x16x72x2 + 5x4x72x2 + 5x9x36x2 + static const int maxHist=20000;//13032; + int modeLHC, maxDepthHB_, maxDepthHE_, maxDepth_; + int nHist, nDepths[maxEta], nDepthsPhi[maxEta],indxEta[maxEta][maxDep][maxPhi]; + TFile *output_file; + + TH1D *h_Pt_Muon[3], *h_Eta_Muon[3], *h_Phi_Muon[3], *h_P_Muon[3]; + TH1D *h_PF_Muon[3], *h_GlobTrack_Chi[3], *h_Global_Muon_Hits[3]; + TH1D *h_MatchedStations[3], *h_Tight_TransImpactparameter[3]; + TH1D *h_Tight_LongitudinalImpactparameter[3], *h_InnerTrackPixelHits[3]; + TH1D *h_TrackerLayer[3], *h_IsolationR04[3] , *h_Global_Muon[3]; + TH1D *h_LongImpactParameter[3], *h_LongImpactParameterBin1[3], *h_LongImpactParameterBin2[3]; + + TH1D *h_TransImpactParameter[3], *h_TransImpactParameterBin1[3], *h_TransImpactParameterBin2[3]; + TH1D *h_Hot_MuonEnergy_hcal_ClosestCell[3][maxHist] , *h_Hot_MuonEnergy_hcal_HotCell[3][maxHist] , *h_Hot_MuonEnergy_hcal_HotCell_VsActiveLength[3][maxHist], *h_HotCell_MuonEnergy_phi[3][maxHist]; + TH2D *h_2D_Bin1[3], *h_2D_Bin2[3]; + TH1D *h_ecal_energy[3], *h_hcal_energy[3], *h_3x3_ecal[3], *h_1x1_hcal[3]; + TH1D *h_MuonHittingEcal[3], *h_HotCell[3], *h_MuonEnergy_hcal[3][maxHist]; + TH1D *h_Hot_MuonEnergy_hcal[3][maxHist]; + TH2D *hcal_ietaVsEnergy[3]; + TProfile *h_EtaX_hcal[3], *h_PhiY_hcal[3], *h_EtaX_ecal[3], *h_PhiY_ecal[3]; + TProfile *h_Eta_ecal[3], *h_Phi_ecal[3]; + TProfile *h_MuonEnergy_eta[3][maxDep], *h_MuonEnergy_phi[3][maxDep], *h_MuonEnergy_muon_eta[3][maxDep]; + TProfile *h_Hot_MuonEnergy_eta[3][maxDep], *h_Hot_MuonEnergy_phi[3][maxDep], *h_Hot_MuonEnergy_muon_eta[3][maxDep]; + TProfile *h_IsoHot_MuonEnergy_eta[3][maxDep], *h_IsoHot_MuonEnergy_phi[3][maxDep], *h_IsoHot_MuonEnergy_muon_eta[3][maxDep]; + TProfile *h_IsoWithoutHot_MuonEnergy_eta[3][maxDep], *h_IsoWithoutHot_MuonEnergy_phi[3][maxDep], *h_IsoWithoutHot_MuonEnergy_muon_eta[3][maxDep]; + TProfile *h_HotWithoutIso_MuonEnergy_eta[3][maxDep], *h_HotWithoutIso_MuonEnergy_phi[3][maxDep], *h_HotWithoutIso_MuonEnergy_muon_eta[3][maxDep]; + +}; + +HBHEMuonOfflineSimAnalyzer::HBHEMuonOfflineSimAnalyzer(const char* infile, + const char* outFileName, + const int mode, + const int maxDHB, + const int maxDHE) { + modeLHC = mode; + maxDepthHB_ = maxDHB; + maxDepthHE_ = maxDHE; + maxDepth_ = (maxDepthHB_ > maxDepthHE_) ? maxDepthHB_ : maxDepthHE_; + // if parameter tree is not specified (or zero), connect the file + // used to generate this class and read the Tree. + // std::cout<<"maxDepth_"<Get("HcalHBHEMuonAnalyzer"); + TTree *tree(0); + dir->GetObject("TREE",tree); + Init(tree); + + //Now book histograms + BookHistograms(outFileName); +} + +HBHEMuonOfflineSimAnalyzer::~HBHEMuonOfflineSimAnalyzer() { + if (!fChain) return; + delete fChain->GetCurrentFile(); +} + +Int_t HBHEMuonOfflineSimAnalyzer::Cut(Long64_t ) { + // This function may be called from Loop. + // returns 1 if entry is accepted. + // returns -1 otherwise. + return 1; +} + +Int_t HBHEMuonOfflineSimAnalyzer::GetEntry(Long64_t entry) { + // Read contents of entry. + if (!fChain) return 0; + return fChain->GetEntry(entry); +} + +Long64_t HBHEMuonOfflineSimAnalyzer::LoadTree(Long64_t entry) { + // Set the environment to read one entry + if (!fChain) return -5; + Long64_t centry = fChain->LoadTree(entry); + if (centry < 0) return centry; + if (fChain->GetTreeNumber() != fCurrent) { + fCurrent = fChain->GetTreeNumber(); + Notify(); + } + return centry; +} + +void HBHEMuonOfflineSimAnalyzer::Init(TTree *tree) { + // The Init() function is called when the selector needs to initialize + // a new tree or chain. Typically here the branch addresses and branch + // pointers of the tree will be set. + // It is normally not necessary to make changes to the generated + // code, but the routine can be extended by the user if needed. + // Init() will be called many times when running on PROOF + // (once per file to be processed). + + // Set object pointer + pt_of_muon = 0; + eta_of_muon = 0; + phi_of_muon = 0; + p_of_muon = 0; + ecal_3x3 = 0; + ecal_detID = 0; + hcal_1x1 = 0; + hcal_detID = 0; + hcal_cellHot = 0; + activeLength = 0; + hcal_edepth1 = 0; + hcal_edepth2 = 0; + hcal_edepth3 = 0; + hcal_edepth4 = 0; + hcal_activeL1 = 0; + hcal_activeL2 = 0; + hcal_activeL3 = 0; + hcal_activeL4 = 0; + activeLengthHot = 0; + hcal_edepthHot1 = 0; + hcal_edepthHot2 = 0; + hcal_edepthHot3 = 0; + hcal_edepthHot4 = 0; + hcal_activeHotL1 = 0; + hcal_activeHotL2 = 0; + hcal_activeHotL3 = 0; + hcal_activeHotL4 = 0; + hcal_edepth5 = 0; + hcal_activeL5 = 0; + hcal_edepthHot5 = 0; + hcal_activeHotL5 = 0; + hcal_edepth6 = 0; + hcal_activeL6 = 0; + hcal_edepthHot6 = 0; + hcal_activeHotL6 = 0; + hcal_edepth7 = 0; + hcal_activeL7 = 0; + hcal_edepthHot7 = 0; + hcal_activeHotL7 = 0; + matchedId = 0; + if (!tree) return; + fChain = tree; + fCurrent = -1; + fChain->SetMakeClass(1); + + fChain->SetBranchAddress("Run_No", &Run_No, &b_Run_No); + fChain->SetBranchAddress("Event_No", &Event_No, &b_Event_No); + fChain->SetBranchAddress("LumiNumber", &LumiNumber, &b_LumiNumber); + fChain->SetBranchAddress("BXNumber", &BXNumber, &b_BXNumber); + fChain->SetBranchAddress("pt_of_muon", &pt_of_muon, &b_pt_of_muon); + fChain->SetBranchAddress("eta_of_muon", &eta_of_muon, &b_eta_of_muon); + fChain->SetBranchAddress("phi_of_muon", &phi_of_muon, &b_phi_of_muon); + fChain->SetBranchAddress("p_of_muon", &p_of_muon, &b_p_of_muon); + fChain->SetBranchAddress("ecal_3x3", &ecal_3x3, &b_ecal_3x3); + fChain->SetBranchAddress("ecal_detID", &ecal_detID, &b_ecal_detID); + fChain->SetBranchAddress("hcal_1x1", &hcal_1x1, &b_hcal_1x1); + fChain->SetBranchAddress("matchedId", &matchedId, &b_matchedId); + fChain->SetBranchAddress("hcal_detID", &hcal_detID, &b_hcal_detID); + fChain->SetBranchAddress("hcal_cellHot", &hcal_cellHot, &b_hcal_cellHot); + fChain->SetBranchAddress("activeLength", &activeLength, &b_activeLength); + fChain->SetBranchAddress("hcal_edepth1", &hcal_edepth1, &b_hcal_edepth1); + fChain->SetBranchAddress("hcal_edepth2", &hcal_edepth2, &b_hcal_edepth2); + fChain->SetBranchAddress("hcal_edepth3", &hcal_edepth3, &b_hcal_edepth3); + fChain->SetBranchAddress("hcal_edepth4", &hcal_edepth4, &b_hcal_edepth4); + fChain->SetBranchAddress("hcal_edepth5", &hcal_edepth5, &b_hcal_edepth5); + fChain->SetBranchAddress("hcal_edepth6", &hcal_edepth6, &b_hcal_edepth6); + fChain->SetBranchAddress("hcal_edepth7", &hcal_edepth7, &b_hcal_edepth7); + fChain->SetBranchAddress("hcal_activeL1", &hcal_activeL1, &b_hcal_activeL1); + fChain->SetBranchAddress("hcal_activeL2", &hcal_activeL2, &b_hcal_activeL2); + fChain->SetBranchAddress("hcal_activeL3", &hcal_activeL3, &b_hcal_activeL3); + fChain->SetBranchAddress("hcal_activeL4", &hcal_activeL4, &b_hcal_activeL4); + fChain->SetBranchAddress("hcal_activeL5", &hcal_activeL5, &b_hcal_activeL5); + fChain->SetBranchAddress("hcal_activeL6", &hcal_activeL6, &b_hcal_activeL6); + fChain->SetBranchAddress("hcal_activeL7", &hcal_activeL7, &b_hcal_activeL7); + fChain->SetBranchAddress("activeLengthHot", &activeLengthHot, &b_activeLengthHot); + fChain->SetBranchAddress("hcal_edepthHot1", &hcal_edepthHot1, &b_hcal_edepthHot1); + fChain->SetBranchAddress("hcal_edepthHot2", &hcal_edepthHot2, &b_hcal_edepthHot2); + fChain->SetBranchAddress("hcal_edepthHot3", &hcal_edepthHot3, &b_hcal_edepthHot3); + fChain->SetBranchAddress("hcal_edepthHot4", &hcal_edepthHot4, &b_hcal_edepthHot4); + fChain->SetBranchAddress("hcal_edepthHot5", &hcal_edepthHot5, &b_hcal_edepthHot5); + fChain->SetBranchAddress("hcal_edepthHot6", &hcal_edepthHot6, &b_hcal_edepthHot6); + fChain->SetBranchAddress("hcal_edepthHot7", &hcal_edepthHot7, &b_hcal_edepthHot7); + fChain->SetBranchAddress("hcal_activeHotL1", &hcal_activeHotL1, &b_hcal_activeHotL1); + fChain->SetBranchAddress("hcal_activeHotL2", &hcal_activeHotL2, &b_hcal_activeHotL2); + fChain->SetBranchAddress("hcal_activeHotL3", &hcal_activeHotL3, &b_hcal_activeHotL3); + fChain->SetBranchAddress("hcal_activeHotL4", &hcal_activeHotL4, &b_hcal_activeHotL4); + fChain->SetBranchAddress("hcal_activeHotL5", &hcal_activeHotL5, &b_hcal_activeHotL5); + fChain->SetBranchAddress("hcal_activeHotL6", &hcal_activeHotL6, &b_hcal_activeHotL6); + fChain->SetBranchAddress("hcal_activeHotL7", &hcal_activeHotL7, &b_hcal_activeHotL7); + Notify(); +} + +void HBHEMuonOfflineSimAnalyzer::Loop() { + + //declarations + if (fChain == 0) return; + + Long64_t nentries = fChain->GetEntriesFast(); + + if (debug_) std::cout << "nevent = " << nentries << std::endl; + + Long64_t nbytes = 0, nb = 0; + + for (Long64_t jentry=0; jentryGetEntry(jentry); nbytes += nb; + + for (unsigned int ml = 0;ml< pt_of_muon->size();ml++) { + + if (debug_) std::cout << "ecal_det_id " << ecal_detID->at(ml) << std::endl; + + if (debug_) std::cout << "hcal_det_id " << std::hex << hcal_detID->at(ml) << std::dec; + + int etaHcal, phiHcal, depthHcal; + etaPhiHcal(hcal_detID->at(ml),etaHcal,phiHcal,depthHcal); + + int eta = (etaHcal > 0) ? etaHcal-1 : -(1+etaHcal); + int nDepth = NDepthBins(eta+1); + int nPhi = NPhiBins(eta+1); + + double phiYHcal = (phiHcal-0.5); + if (debug_) std::cout<<"phiHcal"<Fill(p_of_muon->at(ml)); + h_P_Muon[cut]->Fill(p_of_muon->at(ml)); + h_Pt_Muon[cut]->Fill(pt_of_muon->at(ml)); + h_Eta_Muon[cut]->Fill(eta_of_muon->at(ml)); + + double energyFill; + for (int dep=0; dep 36) ? (phiHcal-1) : (phiHcal-1)/2; + double en1(-9999), en2(-9999); + if (dep == 0) { + en1 = hcal_edepth1->at(ml); + en2 = hcal_edepthHot1->at(ml); + energyFill = (hcal_activeHotL1->at(ml) > 0) ? hcal_activeHotL1->at(ml) : 999; + + } else if (dep == 1) { + en1 = hcal_edepth2->at(ml); + en2 = hcal_edepthHot2->at(ml); + energyFill = (hcal_activeHotL2->at(ml) > 0) ? hcal_activeHotL2->at(ml) : 999; + if (debug_) std::cout<<"problem here.. lets see if it got printed"<at(ml); + en2 = hcal_edepthHot3->at(ml); + energyFill = (hcal_activeHotL3->at(ml) > 0) ? hcal_activeHotL3->at(ml) : 999; + } else if (dep == 3) { + en1 = hcal_edepth4->at(ml); + en2 = hcal_edepthHot4->at(ml); + if (debug_) std::cout<<"Hello in 4"<at(ml) > 0) ? hcal_activeHotL4->at(ml) : 999; + } else if (dep == 4) { + en1 = hcal_edepth5->at(ml); + en2 = hcal_edepthHot5->at(ml); + energyFill = (hcal_activeHotL5->at(ml) > 0) ? hcal_activeHotL5->at(ml) : 999; + } else if (dep == 5) { + if (debug_) std::cout << "Energy in depth 6 " << hcal_edepth6->size() << ":" << hcal_edepthHot6->size() << std::endl; + en1 = (hcal_edepth6->size() > ml) ? hcal_edepth6->at(ml) : 0; + en2 = (hcal_edepthHot6->size() >ml) ? hcal_edepthHot6->at(ml) : 0; + energyFill = (hcal_activeHotL6->at(ml) > 0) ? hcal_activeHotL6->at(ml) : 999; + } else if (dep == 6) { + if (debug_) std::cout << "Energy in depth 7 " << hcal_edepth7->size() << ":" << hcal_edepthHot7->size() << std::endl; + en1 = (hcal_edepth7->size() > ml) ? hcal_edepth7->at(ml) : 0; + en2 = (hcal_edepthHot7->size() >ml) ? hcal_edepthHot7->at(ml) : 0; + energyFill = (hcal_activeHotL7->at(ml) > 0) ? hcal_activeHotL7->at(ml) : 999; + } + + if (debug_) std::cout<<" Debug2"< -9999); + bool ok2 = (en2 > -9999); + + if (debug_) std::cout<<"Before Index"< 0) ? indxEta[eta][dep][PHI] : 1+indxEta[eta][dep][PHI]; + + if (debug_) { + std::cout<<"ieta"<at(ml))) continue; + if (ok1) { + if (debug_) std::cout<<"enter ok1"<at(ml)==1) { + if (en2 > 0) { + h_Hot_MuonEnergy_hcal_HotCell_VsActiveLength[cut][ind]->Fill(en2/energyFill); + } + if (debug_) std::cout<<"enter hot cell"<at(ml)!=1) { + } + } + + if (debug_) std::cout<<"ETA \t"<Show(entry); +} + +void HBHEMuonOfflineSimAnalyzer::BookHistograms(const char* fname) { + output_file = TFile::Open(fname,"RECREATE"); + //output_file->cd(); + std::string type[]={"tight","soft","loose"}; + char name[128], title[500]; + + std::cout<<"BookHistograms"<cd(); + for (int i=0; i<3; ++i) { + sprintf (name, "h_Pt_Muon_%s", type[i].c_str()); + sprintf (title, "p_{T} of %s muons (GeV)", type[i].c_str()); + h_Pt_Muon[i] = new TH1D(name, title,100,0,200); + + sprintf (name, "h_Eta_Muon_%s", type[i].c_str()); + sprintf (title, "#eta of %s muons", type[i].c_str()); + h_Eta_Muon[i] = new TH1D(name, title,50,-2.5,2.5); + + sprintf (name, "h_Phi_Muon_%s", type[i].c_str()); + sprintf (title, "#phi of %s muons", type[i].c_str()); + h_Phi_Muon[i] = new TH1D(name, title,100,-3.1415926,3.1415926); + + sprintf (name, "h_P_Muon_%s", type[i].c_str()); + sprintf (title, "p of %s muons (GeV)", type[i].c_str()); + h_P_Muon[i] = new TH1D(name, title,100,0,200); + + sprintf (name, "h_PF_Muon_%s", type[i].c_str()); + sprintf (title, "PF %s muons (GeV)", type[i].c_str()); + h_PF_Muon[i] = new TH1D(name, title,2,0,2); + + sprintf (name, "h_Global_Muon_Chi2_%s", type[i].c_str()); + sprintf (title, "Chi2 Global %s muons (GeV)", type[i].c_str()); + h_GlobTrack_Chi[i] = new TH1D(name, title,15,0,15); + + sprintf (name, "h_Global_Muon_Hits_%s", type[i].c_str()); + sprintf (title, "Global Hits %s muons (GeV)", type[i].c_str()); + h_Global_Muon_Hits[i] = new TH1D(name, title,10,0,10) ; + + sprintf (name, "h_Matched_Stations_%s", type[i].c_str()); + sprintf (title, "Matched Stations %s muons (GeV)", type[i].c_str()); + h_MatchedStations[i] = new TH1D(name, title,10,0,10); + + sprintf (name, "h_Transverse_ImpactParameter_%s", type[i].c_str()); + sprintf (title, "Transverse_ImpactParameter of %s muons (GeV)", type[i].c_str()); + h_Tight_TransImpactparameter[i] = new TH1D(name, title,50,0,10); + + sprintf (name, "h_Longitudinal_ImpactParameter_%s", type[i].c_str()); + sprintf (title, "Longitudinal_ImpactParameter of %s muons (GeV)", type[i].c_str()); + h_Tight_LongitudinalImpactparameter[i] = new TH1D(name, title,20,0,10); + + sprintf (name, "h_InnerTrack_PixelHits_%s", type[i].c_str()); + sprintf (title, "InnerTrack_PixelHits of %s muons (GeV)", type[i].c_str()); + h_InnerTrackPixelHits[i]= new TH1D(name, title,20,0,20); + + sprintf (name, "h_TrackLayers_%s", type[i].c_str()); + sprintf (title, "No. of Tracker Layers of %s muons (GeV)", type[i].c_str()); + h_TrackerLayer[i]= new TH1D(name, title,20,0,20);; + + sprintf (name, "h_IsolationR04_%s", type[i].c_str()); + sprintf (title, "IsolationR04 %s muons (GeV)", type[i].c_str()); + h_IsolationR04[i] = new TH1D(name, title,45,0,5);; + + sprintf (name, "h_Global_Muon_%s", type[i].c_str()); + sprintf (title, "Global %s muons (GeV)", type[i].c_str()); + h_Global_Muon[i]= new TH1D(name, title,2,0,2); + + sprintf (name, "h_TransImpactParameter_%s", type[i].c_str()); + sprintf (title, "TransImpactParameter of %s muons (GeV)", type[i].c_str()); + h_TransImpactParameter[i] = new TH1D(name, title,100,0,0.5); + + sprintf (name, "h_TransImpactParameterBin1_%s", type[i].c_str()); + sprintf (title, "TransImpactParameter of %s muons (GeV) in -1.5 <= #phi <= 0.5", type[i].c_str()); + h_TransImpactParameterBin1[i] = new TH1D(name, title,100,0,0.5); + + sprintf (name, "h_TransImpactParameterBin2_%s", type[i].c_str()); + sprintf (title, "TransImpactParameter of %s muons (GeV) in #phi> 0.5 and #phi< -1.5 ", type[i].c_str()); + h_TransImpactParameterBin2[i] = new TH1D(name, title,100,0,0.5); + // + sprintf (name, "h_LongImpactParameter_%s", type[i].c_str()); + sprintf (title, "LongImpactParameter of %s muons (GeV)", type[i].c_str()); + h_LongImpactParameter[i] = new TH1D(name, title,100,0,30); + + sprintf (name, "h_LongImpactParameterBin1_%s", type[i].c_str()); + sprintf (title, "LongImpactParameter of %s muons (GeV) in -1.5 <= #phi <= 0.5", type[i].c_str()); + h_LongImpactParameterBin1[i] = new TH1D(name, title,100,0,30); + + sprintf (name, "h_LongImpactParameterBin2_%s", type[i].c_str()); + sprintf (title, "LongImpactParameter of %s muons (GeV) in #phi> 0.5 and #phi< -1.5 ", type[i].c_str()); + h_LongImpactParameterBin2[i] = new TH1D(name, title,100,0,30); + + sprintf (name, "h_2D_Bin1_%s", type[i].c_str()); + sprintf (title, "Trans/Long ImpactParameter of %s muons (GeV) in -1.5 <= #phi< 0.5 ", type[i].c_str()); + h_2D_Bin1[i] = new TH2D(name, title, 100,0,0.5,100,0,30); + + sprintf (name, "h_2D_Bin2_%s", type[i].c_str()); + sprintf (title, "Trans/Long ImpactParameter of %s muons (GeV) in #phi> 0.5 and #phi< -1.5 ", type[i].c_str()); + h_2D_Bin2[i] = new TH2D(name, title, 100,0,0.5,100,0,30); + + sprintf (name, "h_ecal_energy_%s", type[i].c_str()); + sprintf (title, "ECAL energy for %s muons", type[i].c_str()); + h_ecal_energy[i] = new TH1D(name, title,1000,-10.0,90.0); + + sprintf (name, "h_hcal_energy_%s", type[i].c_str()); + sprintf (title, "HCAL energy for %s muons", type[i].c_str()); + h_hcal_energy[i] = new TH1D(name, title,500,-10.0,90.0); + + sprintf (name, "h_3x3_ecal_%s", type[i].c_str()); + sprintf (title, "ECAL energy in 3x3 for %s muons", type[i].c_str()); + h_3x3_ecal[i] = new TH1D(name, title,1000,-10.0,90.0); + + sprintf (name, "h_1x1_hcal_%s", type[i].c_str()); + sprintf (title, "HCAL energy in 1x1 for %s muons", type[i].c_str()); + h_1x1_hcal[i] = new TH1D(name, title,500,-10.0,90.0); + + sprintf (name, "h_EtaX_hcal_%s", type[i].c_str()); + sprintf (title, "HCAL energy as a function of i#eta for %s muons", type[i].c_str()); + h_EtaX_hcal[i] = new TProfile(name, title,60,-30.0,30.0); + + sprintf (name, "h_PhiY_hcal_%s", type[i].c_str()); + sprintf (title, "HCAL energy as a function of i#phi for %s muons", type[i].c_str()); + h_PhiY_hcal[i] = new TProfile(name, title,72,0,72); + + sprintf (name, "h_EtaX_ecal_%s", type[i].c_str()); + sprintf (title, "EB energy as a function of i#eta for %s muons", type[i].c_str()); + h_EtaX_ecal[i] = new TProfile(name, title,170,-85.0,85.0); + + sprintf (name, "h_PhiY_ecal_%s", type[i].c_str()); + sprintf (title, "EB energy as a function of i#phi for %s muons", type[i].c_str()); + h_PhiY_ecal[i] = new TProfile(name, title,360,0,360); + + sprintf (name, "h_Eta_ecal_%s", type[i].c_str()); + sprintf (title, "ECAL energy as a function of #eta for %s muons", type[i].c_str()); + h_Eta_ecal[i] = new TProfile(name, title,100,-2.5,2.5); + + sprintf (name, "h_Phi_ecal_%s", type[i].c_str()); + sprintf (title, "ECAL energy as a function of #phi for %s muons", type[i].c_str()); + h_Phi_ecal[i] = new TProfile(name, title,100,-3.1415926,3.1415926); + + sprintf (name, "h_MuonHittingEcal_%s", type[i].c_str()); + sprintf (title, "%s muons hitting ECAL", type[i].c_str()); + h_MuonHittingEcal[i] = new TH1D(name, title,100,0,5.0); + + sprintf (name, "h_HotCell_%s", type[i].c_str()); + sprintf (title, "Hot cell for %s muons", type[i].c_str()); + h_HotCell[i] = new TH1D(name, title,100,0,2); + + std::cout<<"problem here"<cd(); + for (int eta=0; eta<29; ++eta) { + int nDepth = NDepthBins(eta+1); + int nPhi = NPhiBins(eta+1); + //sprintf(name, "Dir_muon_type_%s_ieta%d",type[i].c_str(), eta); + //d_output_file[i][eta]= output_file->mkdir(name); + //output_file->cd(name); + //d_output_file[i][eta]->cd(); + for (int depth=0; depthSumw2(); + + ih++; + sprintf (name, "h_Hot_MuonEnergy_hc_%d_%d_%d_%s_HotCell_ByActiveLength", -(eta+1), (depth+1),PHI0, type[i].c_str()); + sprintf (title, "HCAL energy in hot tower (i#eta=%d, depth=%d, i#phi=%d) for extrapolated %s muons (Hot Cell) divided by Active Length", -(eta+1), (depth+1), PHI0, type[i].c_str()); + h_Hot_MuonEnergy_hcal_HotCell_VsActiveLength[i][ih] = new TH1D(name, title,4000,0.0,1.0); + h_Hot_MuonEnergy_hcal_HotCell_VsActiveLength[i][ih]->Sumw2(); + } + } + //output_file->cd(); + } + } + //output_file->cd(); +} + +bool HBHEMuonOfflineSimAnalyzer::LooseMuon(unsigned int ml){ + if (pt_of_muon->at(ml) > 20.){ + if (fabs(eta_of_muon->at(ml)) <= 5.0) { + + return true; + } + } + + return false; +} + +bool HBHEMuonOfflineSimAnalyzer::SoftMuon(unsigned int ml){ + if (pt_of_muon->at(ml) > 20.){ + if (fabs(eta_of_muon->at(ml)) <= 5.0) { + + return true; + } + } + + return false; +} + +bool HBHEMuonOfflineSimAnalyzer::tightMuon(unsigned int ml) { + if (pt_of_muon->at(ml) > 20.){ + if (fabs(eta_of_muon->at(ml)) <= 5.0) { + + return true; + } + } + + return false; +} + +void HBHEMuonOfflineSimAnalyzer::etaPhiHcal(unsigned int detId, int &eta, int &phi, int &depth) { + int zside, etaAbs; + if ((detId&0x1000000)==0) { + zside = (detId&0x2000)?(1):(-1); + etaAbs = (detId>>7)&0x3F; + phi = detId&0x7F; + depth = (detId>>14)&0x1F; + } else { + zside = (detId&0x80000)?(1):(-1); + etaAbs = (detId>>10)&0x1FF; + phi = detId&0x3FF; + depth = (detId>>20)&0xF; + } + eta = etaAbs*zside; +} + +void HBHEMuonOfflineSimAnalyzer::etaPhiEcal(unsigned int detId, int& type, + int& zside, int& etaX, int& phiY, + int& plane, int& strip) { + + type = ((detId>>25)&0x7); + // std::cout<<"type"<>9)&0x7F; + phiY = detId&0x1FF; + } else if (type==2) { + zside = (detId&0x4000)?(1):(-1); + etaX = (detId>>7)&0x7F; + phiY = (detId&0x7F); + } else if (type==3) { + zside = (detId&0x80000)?(1):(-1); + etaX = (detId>>6)&0x3F; + /** get the sensor iy */ + phiY = (detId>>12)&0x3F; + /** get the strip */ + plane = ((detId>>18)&0x1)+1; + strip = detId&0x3F; + } else { + zside = etaX = phiY = 0; + } +} + + +void HBHEMuonOfflineSimAnalyzer::calculateP(double pt, double eta, double& pM) { + pM = (pt*cos(2*(1/atan(exp(eta))))); +} + +void HBHEMuonOfflineSimAnalyzer::close() { + output_file->cd(); + std::cout << "file yet to be Written" << std::endl; + WriteHistograms(); + // output_file->Write(); + std::cout << "file Written" << std::endl; + output_file->Close(); + std::cout << "now doing return" << std::endl; +} + + +void HBHEMuonOfflineSimAnalyzer::WriteHistograms() { + + //output_file->cd(); + std::string type[]={"tight","soft","loose"}; + char name[128]; + + std::cout<<"BookHistograms"<cd(); + for (int i=0; i<3; ++i) { + + h_Pt_Muon[i]->Write(); + h_Eta_Muon[i]->Write(); + h_Phi_Muon[i]->Write(); + h_P_Muon[i]->Write(); + h_PF_Muon[i]->Write(); + + h_GlobTrack_Chi[i]->Write(); + h_Global_Muon_Hits[i]->Write(); + h_MatchedStations[i]->Write(); + + h_Tight_TransImpactparameter[i]->Write(); + h_Tight_LongitudinalImpactparameter[i]->Write(); + + h_InnerTrackPixelHits[i]->Write(); + h_TrackerLayer[i]->Write(); + h_IsolationR04[i]->Write(); + + h_Global_Muon[i]->Write(); + h_TransImpactParameter[i]->Write();; + h_TransImpactParameterBin1[i]->Write(); + h_TransImpactParameterBin2[i]->Write(); + // + h_LongImpactParameter[i]->Write(); + h_LongImpactParameterBin1[i]->Write(); + h_LongImpactParameterBin2[i]->Write(); + + h_ecal_energy[i]->Write(); + h_hcal_energy[i]->Write();; + h_3x3_ecal[i]->Write(); + h_1x1_hcal[i]->Write();; + + h_EtaX_hcal[i]->Write(); + h_PhiY_hcal[i]->Write();; + + h_EtaX_ecal[i]->Write();; + h_PhiY_ecal[i]->Write();; + h_Eta_ecal[i]->Write();; + h_Phi_ecal[i]->Write();; + h_MuonHittingEcal[i]->Write();; + h_HotCell[i]->Write();; + + output_file->cd(); + for (int eta=0; eta<29; ++eta) { + int nDepth = NDepthBins(eta+1); + int nPhi = NPhiBins(eta+1); + sprintf(name, "Dir_muon_type_%s_ieta%d",type[i].c_str(), eta+1); + d_output_file[i][eta]= output_file->mkdir(name); + //output_file->cd(name); + d_output_file[i][eta]->cd(); + for (int depth=0; depthWrite(); + + ih++; + h_Hot_MuonEnergy_hcal_HotCell_VsActiveLength[i][ih]->Write(); + } + } + output_file->cd(); + } + } + output_file->cd(); +} + +int HBHEMuonOfflineSimAnalyzer::NDepthBins(int eta) { + // int nDepth[29]={1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,3,1,2,2,2,2,2,2,2,2,2,3,3,2}; + // for 2019 scenario multi depth segmentation + // int nDepth[29]={3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,5,5,5,5,5,5,5,5,5,5,5,5,5}; + int nDepth[29]={4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,7,7,7,7,7,7,7,7,7,7,7,7,7}; + + int nbin = nDepth[eta-1]; + if (modeLHC == 0) { + if (eta<=15) { + nbin = maxDepthHB_; + } else if (eta == 16) { + nbin = 4; + } else { + nbin = maxDepthHE_; + } + } + return nbin; +} + +int HBHEMuonOfflineSimAnalyzer::NPhiBins(int eta) { + int nphi = (eta <= 20) ? 72 : 36; + return nphi; +} diff --git a/Calibration/IsolatedParticles/macros/plotTracks.C b/Calibration/IsolatedParticles/macros/plotTracks.C index 561d3584add89..360a0bea1cc27 100644 --- a/Calibration/IsolatedParticles/macros/plotTracks.C +++ b/Calibration/IsolatedParticles/macros/plotTracks.C @@ -218,10 +218,10 @@ int ibins[nbins+1] = { 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 186,191,196,201,206,211,221,231,241,251,261}; void plotEMean(std::string fname="MinBias_TuneZ2star_8TeV_pythia6.root", std::string hlt="MinBias PyThia6 Z2Star", int var=0, int eta=0, int pv=0, int dataMC=1, bool raio=false, bool approve=false, int savePlot=-1); -TCanvas* plotEMeanDraw(std::vector fnames, std::vector hlts, int var, int eta, int pv=0, bool approve=false, std::string dtype="Data"); -TCanvas* plotEMeanRatioDraw(std::vector fnames, std::vector hlts, int var, int eta, int pv=0, bool approve=false, std::string dtype="Data"); -TCanvas* plotEnergies(std::vector fnames, std::vector hlts, int var=0, int ien=0, int eta=0, int pv=0, bool varbin=false, int rebin=1, bool approve=false, std::string dtype="Data", bool logy=true, int pos=0); -TCanvas* plotEnergy(std::string fname="hlt.root", std::string HLT="All HLTs", int var=0, int ien=0, int eta=0, bool varbin=false, int rebin=1, bool approve=false, bool logy=true, int pos=0); +TCanvas* plotEMeanDraw(std::vector fnames, std::vector hlts, int var, int eta, int pv=0, bool approve=false, std::string dtype="Data", int coloff=0); +TCanvas* plotEMeanRatioDraw(std::vector fnames, std::vector hlts, int var, int eta, int pv=0, bool approve=false, std::string dtype="Data", int coloff=0); +TCanvas* plotEnergies(std::vector fnames, std::vector hlts, int var=0, int ien=0, int eta=0, int pv=0, bool varbin=false, int rebin=1, bool approve=false, std::string dtype="Data", bool logy=true, int pos=0, int coloff=0); +TCanvas* plotEnergy(std::string fname="hlt.root", std::string HLT="All HLTs", int var=0, int ien=0, int eta=0, bool varbin=false, int rebin=1, bool approve=false, bool logy=true, int pos=0, int coloff=0); void plotEMeanPVAll(std::string fname="StudyHLT_ZeroBias_1PV.root", std::string HLT="Zero Bias", int var=-1, int eta=-1, bool approve=true); TCanvas* plotEMeanDrawPV(std::string fname="StudyHLT_ZeroBias_1PV.root", std::string HLT="Zero Bias", int var=0, int eta=0, bool approve=true); TCanvas* plotEnergyPV(std::string fnamee="StudyHLT_HLTZeroBias.root", std::string HLT="Zero Bias", int var=0, int ien=0, int eta=0, bool varbin=false, int rebin=1, bool approve=false, bool logy=true, int pos=0); @@ -269,35 +269,34 @@ void plotEnergyAll(std::string fname="hlt.root", std::string hlt="All HLTs", std::string files[2]={"ZeroBiasStudyHLT.root","MinimumBiasStudyHLT.root"}; std::string types[2]={"Zero Bias Data","Minimum Bias Data"}; + std::string filem[5]={"pikp/QFBE0p2StudyHLT.root", "pikp/FBE2p2StudyHLT.root", "pikp/FBE0p2StudyHLT.root", "pikp/QFBE2p2StudyHLT.root", "pikp/FBAE2p2StudyHLT.root"}; + std::string typem[5]={"10.0.p02 QGSP_FTFP_BERT_EML","10.2.p02 FTFP_BERT_EMM","10.0.p02 FTFP_BERT_EML","10.2.p02 QGSP_FTFP_BERT_EMM","10.2.p02 FTFP_BERT_ATL_EMM"}; + std::string filex[6]={"AllDataStudyHLT.root","pikp/QFBE0p2StudyHLT.root", "pikp/FBE2p2StudyHLT.root", "pikp/FBE0p2StudyHLT.root", "pikp/QFBE2p2StudyHLT.root", "pikp/FBAE2p2StudyHLT.root"}; + std::string typex[6]={"Data (2016B)","10.0.p02 QGSP_FTFP_BERT_EML","10.2.p02 FTFP_BERT_EMM","10.0.p02 FTFP_BERT_EML","10.2.p02 QGSP_FTFP_BERT_EMM","10.2.p02 FTFP_BERT_ATL_EMM"}; /* std::string files[3]={"StudyHLT_ZeroBias_1PV.root","StudyHLT_PixelTrack_1PV.root","StudyHLT_1PV.root"}; std::string types[3]={"Zero Bias HLT","Pixel Track HLT","All HLTs"}; std::string files[5]={"StudyHLT_HLTZeroBias.root","StudyHLT_PixelTrack.root","StudyHLT_HLTJetE.root","StudyHLT_HLTPhysics.root","StudyHLT_All.root"}; std::string hltx[5]={"Zero Bias HLT","Pixel Track HLT","JetE HLT","Physics HLT","All HLTs"}; - */ - std::string filem[4]={"pikp/QFBE0p2StudyHLT.root", "pikp/FBE0p2StudyHLT.root", "pikp/QFBE2p2StudyHLT.root", "pikp/FBE2p2StudyHLT.root"}; - std::string typem[4]={"10.0.p02 QGSP_FTFP_BERT_EML","10.0.p02 FTFP_BERT_EML","10.2.p02 QGSP_FTFP_BERT_EMM","10.2.p02 FTFP_BERT_EMM"}; - /* std::string filem[3]={"StudyHLT_95p02_QGSP_FTFP_BERT.root", "StudyHLT_96p02_QGSP_FTFP_BERT.root", "StudyHLT_96p02_FTFP_BERT.root"}; std::string typem[3]={"Pythia8 (9.5.p02 QGSP_FTFP_BERT)","Pythia8 (9.6.p02 QGSP_FTFP_BERT)","Pythia8 (9.6.p02 FTFP_BERT)"}; - */ std::string filex[3]={"AllDataStudyHLT.root","pikp/QFBE0p2StudyHLT.root", "pikp/FBE2p2StudyHLT.root"}; std::string typex[3]={"Data (2016B)","10.0.p02 QGSP_FTFP_BERT_EML","10.2.p02 FTFP_BERT_EMM"}; + */ std::vector fnames, hlts; - std::string dtype("MC"); - if (data == 1) dtype = "Data"; - else if (data == 4) dtype = "MC"; + std::string dtype = (data == 1) ? "Data" : "MC"; + int coloff = (data == 4) ? 0 : 1; if (fname == "") { if (data == 1) { for (int i=0; i<2; ++i) { fnames.push_back(files[i]); hlts.push_back(types[i]); } } else if (data == 4) { - for (int i=0; i<3; ++i) { + for (int i=0; i<6; ++i) { fnames.push_back(filex[i]); hlts.push_back(typex[i]); } } else { - for (int i=0; i<4; ++i) { + for (int i=0; i<5; ++i) { fnames.push_back(filem[i]); hlts.push_back(typem[i]); } } @@ -311,7 +310,7 @@ void plotEnergyAll(std::string fname="hlt.root", std::string hlt="All HLTs", for (int ene=enemin; ene<=enemax; ++ene) { for (int eta=etamin; eta<=etamax; ++eta) { TCanvas *c = plotEnergies(fnames, hlts, var, ene, eta, pv, varbin, - rebin, approve, dtype, logy, pos); + rebin, approve, dtype, logy, pos, coloff); if (c != 0 && savePlot >= 0 && savePlot < 3) { std::string ext[3] = {"eps", "gif", "pdf"}; char name[200]; @@ -342,35 +341,38 @@ void plotEMean(std::string fname, std::string hlt, int var, int eta, int pv, std::string files[2]={"ZeroBiasStudyHLT.root","MinimumBiasStudyHLT.root"}; std::string types[2]={"Zero Bias Data","Minimum Bias Data"}; + std::string filem[5]={"pikp/QFBE0p2StudyHLT.root", "pikp/FBE2p2StudyHLT.root", "pikp/FBE0p2StudyHLT.root", "pikp/QFBE2p2StudyHLT.root", "pikp/FBAE2p2StudyHLT.root"}; + std::string typem[5]={"10.0.p02 QGSP_FTFP_BERT_EML","10.2.p02 FTFP_BERT_EMM","10.0.p02 FTFP_BERT_EML","10.2.p02 QGSP_FTFP_BERT_EMM","10.2.p02 FTFP_BERT_ATL_EMM"}; + std::string filex[6]={"AllDataStudyHLT.root","pikp/QFBE0p2StudyHLT.root", "pikp/FBE2p2StudyHLT.root", "pikp/FBE0p2StudyHLT.root", "pikp/QFBE2p2StudyHLT.root", "pikp/FBAE2p2StudyHLT.root"}; + std::string typex[6]={"Data (2016B)","10.0.p02 QGSP_FTFP_BERT_EML","10.2.p02 FTFP_BERT_EMM","10.0.p02 FTFP_BERT_EML","10.2.p02 QGSP_FTFP_BERT_EMM","10.2.p02 FTFP_BERT_ATL_EMM"}; /* std::string files[3]={"StudyHLT_ZeroBias_1PV.root","StudyHLT_PixelTrack_1PV.root","StudyHLT_1PV.root"}; std::string types[3]={"Zero Bias HLT","Pixel Track HLT","All HLTs"}; std::string files[5]={"StudyHLT_HLTZeroBias.root","StudyHLT_PixelTrack.root","StudyHLT_HLTJetE.root","StudyHLT_HLTPhysics.root","StudyHLT_All.root"}; std::string hltx[5]={"Zero Bias HLT","Pixel Track HLT","JetE HLT","Physics HLT","All HLTs"}; - */ - std::string filem[4]={"pikp/QFBE0p2StudyHLT.root", "pikp/FBE0p2StudyHLT.root", "pikp/QFBE2p2StudyHLT.root", "pikp/FBE2p2StudyHLT.root"}; - std::string typem[4]={"10.0.p02 QGSP_FTFP_BERT_EML","10.0.p02 FTFP_BERT_EML","10.2.p02 QGSP_FTFP_BERT_EMM","10.2.p02 FTFP_BERT_EMM"}; - /* std::string filem[3]={"StudyHLT_95p02_QGSP_FTFP_BERT.root", "StudyHLT_96p02_QGSP_FTFP_BERT.root", "StudyHLT_96p02_FTFP_BERT.root"}; std::string typem[3]={"Pythia8 (9.5.p02 QGSP_FTFP_BERT)","Pythia8 (9.6.p02 QGSP_FTFP_BERT)","Pythia8 (9.6.p02 FTFP_BERT)"}; - */ std::string filex[3]={"AllDataStudyHLT.root","pikp/QFBE0p2StudyHLT.root", "pikp/FBE2p2StudyHLT.root"}; std::string typex[3]={"Data (2016B)","10.0.p02 QGSP_FTFP_BERT_EML","10.2.p02 FTFP_BERT_EMM"}; + */ std::vector fnames, hlts; - std::string dtype("MC"); - if (data == 1) dtype = "Data"; - else if (data == 4) dtype = "MC"; + std::string dtype = (data == 1) ? "Data" : "MC"; + int coloff = (data == 4 || data == 3) ? 0 : 1; if (fname == "") { if (data == 1) { for (int i=0; i<2; ++i) { fnames.push_back(files[i]); hlts.push_back(types[i]); } } else if (data == 4) { + for (int i=0; i<6; ++i) { + fnames.push_back(filex[i]); hlts.push_back(typex[i]); + } + } else if (data == 3) { for (int i=0; i<3; ++i) { fnames.push_back(filex[i]); hlts.push_back(typex[i]); } } else { - for (int i=0; i<4; ++i) { + for (int i=0; i<5; ++i) { fnames.push_back(filem[i]); hlts.push_back(typem[i]); } } @@ -388,9 +390,9 @@ void plotEMean(std::string fname, std::string hlt, int var, int eta, int pv, for (int pv=pvmin; pv<=pvmax; ++pv) { TCanvas* c(0); if (ratio) { - c = plotEMeanRatioDraw(fnames, hlts, var, eta, pv, approve, dtype); + c = plotEMeanRatioDraw(fnames, hlts, var, eta, pv, approve, dtype, coloff); } else { - c = plotEMeanDraw(fnames, hlts, var, eta, pv, approve, dtype); + c = plotEMeanDraw(fnames, hlts, var, eta, pv, approve, dtype, coloff); } if (c != 0 && savePlot >= 0 && savePlot < 3) { std::string ext[3] = {"eps", "gif", "pdf"}; @@ -405,7 +407,7 @@ void plotEMean(std::string fname, std::string hlt, int var, int eta, int pv, TCanvas* plotEMeanDraw(std::vector fnames, std::vector hlts, int var, int eta, int pv, - bool approve, std::string dtype) { + bool approve, std::string dtype, int coloff) { bool debug(false); std::vector graphs; @@ -435,10 +437,11 @@ TCanvas* plotEMeanDraw(std::vector fnames, << std::endl; } TGraphAsymmErrors *graph = new TGraphAsymmErrors(NPT, mom, mean, dmom,dmom, dmean,dmean); - graph->SetMarkerStyle(styles[k]); - graph->SetMarkerColor(colors[k]); + graph->SetMarkerStyle(styles[coloff+k]); + graph->SetMarkerColor(colors[coloff+k]); graph->SetMarkerSize(1.6); - graph->SetLineColor(colors[k]); + graph->SetLineColor(colors[coloff+k]); + graph->SetLineWidth(2); graphs.push_back(graph); legend->AddEntry(graph, hlts[k].c_str(), "lp"); if (debug) std::cout << "Complete " << hlts[k] << std::endl; @@ -494,7 +497,8 @@ TCanvas* plotEMeanDraw(std::vector fnames, TCanvas* plotEMeanRatioDraw(std::vector fnames, std::vector hlts, int var, int eta, - int pv, bool approve, std::string dtype) { + int pv, bool approve, std::string dtype, + int coloff) { bool debug(false); std::vector graphs; @@ -558,10 +562,11 @@ TCanvas* plotEMeanRatioDraw(std::vector fnames, << std::endl; } TGraphAsymmErrors *graph = new TGraphAsymmErrors(NPT, mom, mean, dmom,dmom, dmean,dmean); - graph->SetMarkerStyle(styles[k]); - graph->SetMarkerColor(colors[k]); + graph->SetMarkerStyle(styles[coloff+k]); + graph->SetMarkerColor(colors[coloff+k]); graph->SetMarkerSize(1.6); - graph->SetLineColor(colors[k]); + graph->SetLineColor(colors[coloff+k]); + graph->SetLineWidth(2); graphs.push_back(graph); char text[100]; if (approve) { @@ -625,7 +630,7 @@ TCanvas* plotEMeanRatioDraw(std::vector fnames, TCanvas* plotEnergies(std::vector fnames, std::vector hlts, int var, int ien, int eta, int pv, bool varbin, int rebin, bool approve, - std::string dtype, bool logy, int pos) { + std::string dtype, bool logy, int pos, int coloff) { // bool debug(false); TLegend* legend = new TLegend(0.55, 0.70, 0.95, 0.85); @@ -649,7 +654,7 @@ TCanvas* plotEnergies(std::vector fnames, } histArr.AddLast(histo); labels.push_back(hlts[k]); - color.push_back(colors[k]); + color.push_back(colors[coloff+k]); int ibin = histo->GetMaximumBin(); if (histo->GetBinContent(ibin) > ymx0) ymx0 = histo->GetBinContent(ibin); } @@ -676,7 +681,7 @@ TCanvas* plotEnergies(std::vector fnames, TCanvas* plotEnergy(std::string fname, std::string HLT, int var, int ien, int eta, bool varbin, int rebin, bool approve, bool logy, - int pos) { + int pos, int coloff) { TFile *file = TFile::Open(fname.c_str()); char name[100]; @@ -691,7 +696,7 @@ TCanvas* plotEnergy(std::string fname, std::string HLT, int var, int ien, histArr.AddLast(histo); sprintf (name, "p=%s, #eta=%s %s", varPs[ien].c_str(), varEta[eta].c_str(), namefull[i+3].c_str()); labels.push_back(name); - color.push_back(colors[i]); + color.push_back(colors[coloff+i]); int ibin = histo->GetMaximumBin(); if (histo->GetBinContent(ibin) > ymx0) ymx0 = histo->GetBinContent(ibin); } @@ -756,6 +761,7 @@ TCanvas* plotEMeanDrawPV(std::string fname, std::string HLT, int var, int eta, graph->SetMarkerColor(colors[k]); graph->SetMarkerSize(1.6); graph->SetLineColor(colors[k]); + graph->SetLineWidth(2); graphs.push_back(graph); sprintf (name, "PV=%d:%d", pvBins[k], pvBins[k+1]-1); legend->AddEntry(graph, name, "lp"); diff --git a/Calibration/IsolatedParticles/plugins/HcalHBHEMuonSimAnalyzer.cc b/Calibration/IsolatedParticles/plugins/HcalHBHEMuonSimAnalyzer.cc index 8219e61323e1f..143783ad34685 100644 --- a/Calibration/IsolatedParticles/plugins/HcalHBHEMuonSimAnalyzer.cc +++ b/Calibration/IsolatedParticles/plugins/HcalHBHEMuonSimAnalyzer.cc @@ -38,7 +38,7 @@ #include "MagneticField/Engine/interface/MagneticField.h" #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h" -//#define EDM_ML_DEBUG +#define EDM_ML_DEBUG class HcalHBHEMuonSimAnalyzer : public edm::one::EDAnalyzer { @@ -47,7 +47,7 @@ class HcalHBHEMuonSimAnalyzer : public edm::one::EDAnalyzer actHB_, actHE_; - const int MaxDepth=7; - const int idMuon_=13; + double tMinE_, tMaxE_, tMinH_, tMaxH_; edm::Service fs_; edm::EDGetTokenT tok_SimTk_; @@ -73,26 +72,19 @@ class HcalHBHEMuonSimAnalyzer : public edm::one::EDAnalyzer tok_caloEB_, tok_caloEE_; edm::EDGetTokenT tok_caloHH_; + static const int depthMax_=7; + const int idMuon_=13; TTree *tree_; unsigned int runNumber_, eventNumber_, lumiNumber_, bxNumber_; std::vector ptGlob_, etaGlob_, phiGlob_, pMuon_; std::vector ecal3x3Energy_, hcal1x1Energy_; std::vector ecalDetId_, hcalDetId_, hcalHot_; - std::vector hcalDepth1Energy_, hcalDepth1ActiveLength_; - std::vector hcalDepth2Energy_, hcalDepth2ActiveLength_; - std::vector hcalDepth3Energy_, hcalDepth3ActiveLength_; - std::vector hcalDepth4Energy_, hcalDepth4ActiveLength_; - std::vector hcalDepth5Energy_, hcalDepth5ActiveLength_; - std::vector hcalDepth6Energy_, hcalDepth6ActiveLength_; - std::vector hcalDepth7Energy_, hcalDepth7ActiveLength_; - std::vector hcalDepth1EnergyHot_, hcalDepth1ActiveLengthHot_; - std::vector hcalDepth2EnergyHot_, hcalDepth2ActiveLengthHot_; - std::vector hcalDepth3EnergyHot_, hcalDepth3ActiveLengthHot_; - std::vector hcalDepth4EnergyHot_, hcalDepth4ActiveLengthHot_; - std::vector hcalDepth5EnergyHot_, hcalDepth5ActiveLengthHot_; - std::vector hcalDepth6EnergyHot_, hcalDepth6ActiveLengthHot_; - std::vector hcalDepth7EnergyHot_, hcalDepth7ActiveLengthHot_; - std::vector hcalActiveLength_, hcalActiveLengthHot_; + std::vector matchedId_; + std::vector hcalDepthEnergy_[depthMax_]; + std::vector hcalDepthActiveLength_[depthMax_]; + std::vector hcalDepthEnergyHot_[depthMax_]; + std::vector hcalDepthActiveLengthHot_[depthMax_]; + std::vector hcalActiveLength_, hcalActiveLengthHot_; }; HcalHBHEMuonSimAnalyzer::HcalHBHEMuonSimAnalyzer(const edm::ParameterSet& iConfig) { @@ -117,21 +109,22 @@ HcalHBHEMuonSimAnalyzer::HcalHBHEMuonSimAnalyzer(const edm::ParameterSet& iConfi tok_caloEB_ = consumes(edm::InputTag(g4Label_,ebLabel_)); tok_caloEE_ = consumes(edm::InputTag(g4Label_,eeLabel_)); tok_caloHH_ = consumes(edm::InputTag(g4Label_,hcLabel_)); - if (maxDepth_ > MaxDepth) maxDepth_ = MaxDepth; - else if (maxDepth_ < 1) maxDepth_ = 4; - + if (maxDepth_ > depthMax_) maxDepth_ = depthMax_; + else if (maxDepth_ < 1) maxDepth_ = 4; +#ifdef EDM_ML_DEBUG std::cout << "Labels: " << g4Label_ << ":" << ebLabel_ << ":" << eeLabel_ << ":" << hcLabel_ << "\nVerbosity " << verbosity_ << " MaxDepth " << maxDepth_ << " Maximum Eta " << etaMax_ << " tMin|tMax " << tMinE_ << ":" << tMaxE_ << ":" << tMinH_ << ":" << tMaxH_ << std::endl; +#endif } HcalHBHEMuonSimAnalyzer::~HcalHBHEMuonSimAnalyzer() { } void HcalHBHEMuonSimAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { - + clearVectors(); bool debug(false); #ifdef EDM_ML_DEBUG @@ -149,7 +142,7 @@ void HcalHBHEMuonSimAnalyzer::analyze(const edm::Event& iEvent, eventNumber_ = iEvent.id().event(); lumiNumber_ = iEvent.id().luminosityBlock(); bxNumber_ = iEvent.bunchCrossing(); - + //get Handles to SimTracks and SimHits edm::Handle SimTk; iEvent.getByToken(tok_SimTk_,SimTk); @@ -177,19 +170,22 @@ void HcalHBHEMuonSimAnalyzer::analyze(const edm::Event& iEvent, for (edm::PCaloHitContainer::const_iterator itr=pcalohh->begin(); itr != pcalohh->end(); ++itr) { PCaloHit hit(*itr); DetId newid = HcalHitRelabeller::relabel(hit.id(),hcons); - std::cout << "Old ID " << std::hex << hit.id() << std::dec << " New " << HcalDetId(newid) << std::endl; +#ifdef EDM_ML_DEBUG + std::cout << "Old ID " << std::hex << hit.id() << std::dec << " New " + << HcalDetId(newid) << std::endl; +#endif hit.setID(newid.rawId()); calohh.push_back(hit); } } else { calohh.insert(calohh.end(),pcalohh->begin(),pcalohh->end()); } - + // get handles to calogeometry and calotopology edm::ESHandle pG; iSetup.get().get(pG); const CaloGeometry* geo = pG.product(); - + edm::ESHandle bFieldH; iSetup.get().get(bFieldH); const MagneticField* bField = bFieldH.product(); @@ -197,7 +193,7 @@ void HcalHBHEMuonSimAnalyzer::analyze(const edm::Event& iEvent, edm::ESHandle theCaloTopology; iSetup.get().get(theCaloTopology); const CaloTopology *caloTopology = theCaloTopology.product(); - + edm::ESHandle htopo; iSetup.get().get(htopo); const HcalTopology* theHBHETopology = htopo.product(); @@ -211,10 +207,11 @@ void HcalHBHEMuonSimAnalyzer::analyze(const edm::Event& iEvent, spr::propagatedTrackDirection trkD = spr::propagateCALO(thisTrk, SimTk, SimVtx, geo, bField, debug); double eEcal(0), eHcal(0), activeLengthTot(0), activeLengthHotTot(0); - double eHcalDepth[MaxDepth], eHcalDepthHot[MaxDepth]; - double activeL[MaxDepth], activeHotL[MaxDepth]; + double eHcalDepth[depthMax_], eHcalDepthHot[depthMax_]; + double activeL[depthMax_], activeHotL[depthMax_]; unsigned int isHot(0); - for (int i=0; i 0) @@ -311,53 +320,31 @@ void HcalHBHEMuonSimAnalyzer::analyze(const edm::Event& iEvent, activeHotL[ehdepth[i].second-1] = actL; activeLengthHotTot += actL; #ifdef EDM_ML_DEBUG - if ((verbosity_%10) > 0) - std::cout << hcid0 << " E " << ehdepth[i].first << " L " - << actL << std::endl; + if ((verbosity_%10) > 0) + std::cout << hcid0 << " E " << ehdepth[i].first << " L " + << actL << std::endl; #endif } } #ifdef EDM_ML_DEBUG if ((verbosity_%10) > 0) { - for (int k=0; kBranch("eta_of_muon", &etaGlob_); tree_->Branch("phi_of_muon", &phiGlob_); tree_->Branch("p_of_muon", &pMuon_); + tree_->Branch("matchedId", &matchedId_); tree_->Branch("ecal_3x3", &ecal3x3Energy_); tree_->Branch("ecal_detID", &ecalDetId_); @@ -383,42 +371,18 @@ void HcalHBHEMuonSimAnalyzer::beginJob() { tree_->Branch("hcal_detID", &hcalDetId_); tree_->Branch("hcal_cellHot", &hcalHot_); tree_->Branch("activeLength", &hcalActiveLength_); - tree_->Branch("hcal_edepth1", &hcalDepth1Energy_); - tree_->Branch("hcal_edepth2", &hcalDepth2Energy_); - tree_->Branch("hcal_edepth3", &hcalDepth3Energy_); - tree_->Branch("hcal_edepth4", &hcalDepth4Energy_); - tree_->Branch("hcal_activeL1", &hcalDepth1ActiveLength_); - tree_->Branch("hcal_activeL2", &hcalDepth2ActiveLength_); - tree_->Branch("hcal_activeL3", &hcalDepth3ActiveLength_); - tree_->Branch("hcal_activeL4", &hcalDepth4ActiveLength_); tree_->Branch("activeLengthHot", &hcalActiveLengthHot_); - tree_->Branch("hcal_edepthHot1", &hcalDepth1EnergyHot_); - tree_->Branch("hcal_edepthHot2", &hcalDepth2EnergyHot_); - tree_->Branch("hcal_edepthHot3", &hcalDepth3EnergyHot_); - tree_->Branch("hcal_edepthHot4", &hcalDepth4EnergyHot_); - tree_->Branch("hcal_activeHotL1", &hcalDepth1ActiveLength_); - tree_->Branch("hcal_activeHotL2", &hcalDepth2ActiveLength_); - tree_->Branch("hcal_activeHotL3", &hcalDepth3ActiveLength_); - tree_->Branch("hcal_activeHotL4", &hcalDepth4ActiveLength_); - if (maxDepth_ > 4) { - tree_->Branch("hcal_edepth5", &hcalDepth5Energy_); - tree_->Branch("hcal_activeL5", &hcalDepth5ActiveLength_); - tree_->Branch("hcal_edepthHot5", &hcalDepth5EnergyHot_); - tree_->Branch("hcal_activeHotL5", &hcalDepth5ActiveLength_); - if (maxDepth_ > 5) { - tree_->Branch("hcal_edepth6", &hcalDepth6Energy_); - tree_->Branch("hcal_activeL6", &hcalDepth6ActiveLength_); - tree_->Branch("hcal_edepthHot6", &hcalDepth6EnergyHot_); - tree_->Branch("hcal_activeHotL6", &hcalDepth6ActiveLength_); - if (maxDepth_ > 6) { - tree_->Branch("hcal_edepth7", &hcalDepth7Energy_); - tree_->Branch("hcal_activeL7", &hcalDepth7ActiveLength_); - tree_->Branch("hcal_edepthHot7", &hcalDepth7EnergyHot_); - tree_->Branch("hcal_activeHotL7", &hcalDepth7ActiveLength_); - } - } + char name[100]; + for (int k=0; kBranch(name, &hcalDepthEnergy_[k]); + sprintf (name, "hcal_activeL%d", (k+1)); + tree_->Branch(name, &hcalDepthActiveLength_[k]); + sprintf (name, "hcal_edepthHot%d", (k+1)); + tree_->Branch(name, &hcalDepthEnergyHot_[k]); + sprintf (name, "hcal_activeHotL%d", (k+1)); + tree_->Branch(name, &hcalDepthActiveLength_[k]); } - } void HcalHBHEMuonSimAnalyzer::beginRun(edm::Run const& iRun, @@ -435,8 +399,7 @@ void HcalHBHEMuonSimAnalyzer::beginRun(edm::Run const& iRun, void HcalHBHEMuonSimAnalyzer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - //The following says we do not know what parameters are allowed so do no validation - // Please change this to state exactly what you do use, even if it is no parameters + edm::ParameterSetDescription desc; desc.add("ModuleLabel","g4SimHits"); desc.add("EBCollection","EcalHitsEB"); @@ -445,10 +408,10 @@ void HcalHBHEMuonSimAnalyzer::fillDescriptions(edm::ConfigurationDescriptions& d desc.addUntracked("Verbosity",0); desc.addUntracked("MaxDepth",4); desc.addUntracked("EtaMax",3.0); - desc.addUntracked("TimeMinCutECAL",-500.0); - desc.addUntracked("TimeMaxCutECAL",500.0); - desc.addUntracked("TimeMinCutHCAL",-500.0); - desc.addUntracked("TimeMaxCutHCAL",500.0); + desc.addUntracked("TimeMinCutECAL",-500.); + desc.addUntracked("TimeMaxCutECAL",500.); + desc.addUntracked("TimeMinCutHCAL",-500.); + desc.addUntracked("TimeMaxCutHCAL",500.); descriptions.add("hcalHBHEMuonSim",desc); } @@ -459,52 +422,30 @@ void HcalHBHEMuonSimAnalyzer::clearVectors() { eventNumber_ = -99999; lumiNumber_ = -99999; bxNumber_ = -99999; - + ptGlob_.clear(); etaGlob_.clear(); phiGlob_.clear(); pMuon_.clear(); - + matchedId_.clear(); ecal3x3Energy_.clear(); ecalDetId_.clear(); hcal1x1Energy_.clear(); hcalDetId_.clear(); hcalHot_.clear(); hcalActiveLength_.clear(); - hcalDepth1Energy_.clear(); - hcalDepth2Energy_.clear(); - hcalDepth3Energy_.clear(); - hcalDepth4Energy_.clear(); - hcalDepth5Energy_.clear(); - hcalDepth6Energy_.clear(); - hcalDepth7Energy_.clear(); - hcalDepth1ActiveLength_.clear(); - hcalDepth2ActiveLength_.clear(); - hcalDepth3ActiveLength_.clear(); - hcalDepth4ActiveLength_.clear(); - hcalDepth5ActiveLength_.clear(); - hcalDepth6ActiveLength_.clear(); - hcalDepth7ActiveLength_.clear(); hcalActiveLengthHot_.clear(); - hcalDepth1EnergyHot_.clear(); - hcalDepth2EnergyHot_.clear(); - hcalDepth3EnergyHot_.clear(); - hcalDepth4EnergyHot_.clear(); - hcalDepth5EnergyHot_.clear(); - hcalDepth6EnergyHot_.clear(); - hcalDepth7EnergyHot_.clear(); - hcalDepth1ActiveLengthHot_.clear(); - hcalDepth2ActiveLengthHot_.clear(); - hcalDepth3ActiveLengthHot_.clear(); - hcalDepth4ActiveLengthHot_.clear(); - hcalDepth5ActiveLengthHot_.clear(); - hcalDepth6ActiveLengthHot_.clear(); - hcalDepth7ActiveLengthHot_.clear(); + for (int k=0; kgetClosestCell(point); } trkDir.push_back(trkD); - } - + } #ifdef EDM_ML_DEBUG if (debug) { std::cout << "propagateCALO:: for " << trkDir.size() << " tracks" << std::endl; @@ -298,7 +296,6 @@ namespace spr{ vdet.phiHCAL = point.phi(); vdet.detIdHCAL = gHB->getClosestCell(point); } - #ifdef EDM_ML_DEBUG if (debug) { std::cout << "propagateCALO:: for 1 track" << std::endl; @@ -366,7 +363,6 @@ namespace spr{ } trkDir.push_back(trkD); } - #ifdef EDM_ML_DEBUG if (debug) { std::cout << "propagateCALO:: for " << trkDir.size() << " tracks" << std::endl; @@ -444,7 +440,6 @@ namespace spr{ } trkDir.push_back(trkD); } - #ifdef EDM_ML_DEBUG if (debug) { std::cout << "propagateCALO:: for " << trkDir.size() << " tracks" << std::endl; @@ -511,7 +506,6 @@ namespace spr{ trkD.detIdHCAL = gHB->getClosestCell(point); } } - #ifdef EDM_ML_DEBUG if (debug) { std::cout << "propagateCALO:: for track [" << thisTrk << "] Flag: " << trkD.ok << " ECAL (" << trkD.okECAL << ") HCAL (" << trkD.okHCAL << ")" << std::endl; @@ -535,6 +529,41 @@ namespace spr{ return trkD; } + spr::propagatedTrackDirection propagateHCALBack(unsigned int thisTrk, edm::Handle& SimTk, edm::Handle& SimVtx, const CaloGeometry* geo, const MagneticField* bField, bool debug) { + + const CaloSubdetectorGeometry* gHB = geo->getSubdetectorGeometry(DetId::Hcal,HcalBarrel); + spr::trackAtOrigin trk = spr::simTrackAtOrigin(thisTrk, SimTk, SimVtx, debug); + spr::propagatedTrackDirection trkD; + trkD.ok = trk.ok; + trkD.detIdECAL = DetId(0); + trkD.detIdHCAL = DetId(0); + trkD.detIdEHCAL= DetId(0); +#ifdef EDM_ML_DEBUG + if (debug) std::cout << "Propagate track " << thisTrk << " charge " << trk.charge << " position " << trk.position << " p " << trk.momentum << " Flag " << trkD.ok << std::endl; +#endif + if (trkD.ok) { + spr::propagatedTrack info = spr::propagateCalo (trk.position, trk.momentum, trk.charge, bField, spr::zBackHE, spr::rBackHB, spr::etaBEHcal, debug); + GlobalPoint point = GlobalPoint(info.point.x(),info.point.y(),info.point.z()); + trkD.okHCAL = info.ok; + trkD.pointHCAL = point; + trkD.directionHCAL = info.direction; + if (trkD.okHCAL) { + trkD.detIdHCAL = gHB->getClosestCell(point); + } + } +#ifdef EDM_ML_DEBUG + if (debug) { + std::cout << "propagateCALO:: for track [" << thisTrk << "] Flag: " << trkD.ok << " ECAL (" << trkD.okECAL << ") HCAL (" << trkD.okHCAL << ")" << std::endl; + if (trkD.okHCAL) { + std::cout << " HCAL point " << trkD.pointHCAL << " direction " + << trkD.directionHCAL << " " << (HcalDetId)(trkD.detIdHCAL); + } + } +#endif + return trkD; + } + + std::pair propagateHCALBack(const reco::Track* track, const CaloGeometry* geo, const MagneticField* bField, bool debug) { const CaloSubdetectorGeometry* gHB = geo->getSubdetectorGeometry(DetId::Hcal,HcalBarrel); GlobalPoint vertex (track->vx(), track->vy(), track->vz()); @@ -663,6 +692,7 @@ namespace spr{ std::cout << "propagateTracker:: Barrel " << tsosb.isValid() << " Endcap " << tsose.isValid() << " OverAll " << ok << " Point " << point << " RDist " << rdist << " dS " << dS << " dS/pt " << rdist*rat/momentum.perp() << " zdist " << dZ << " dz/pz " << dZ/momentum.z() << " Length " << length << std::endl; #endif } + return std::pair(point,length); } @@ -735,8 +765,8 @@ namespace spr{ } spr::trackAtOrigin simTrackAtOrigin(unsigned int thisTrk, - edm::Handle& - SimTk, edm::Handle& SimVtx, bool + edm::Handle& SimTk, + edm::Handle& SimVtx, bool #ifdef EDM_ML_DEBUG debug #endif