Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run3-hcx302 Update the analyzer code to test the showerlibrary and the script which combines all momentum bins to make the library #34500

Merged
merged 2 commits into from
Jul 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 32 additions & 4 deletions SimG4CMS/ShowerLibraryProducer/data/fileList.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,32 @@
#####################################################################
# fileNameandLocation Type Momentum
#####################################################################
SimG4CMS/ShowerLibraryProducer/test/hfShowerLibSimu_100GeVElec.root electron 100
hfShowerLibSimu_emm_eta4_phiall_e2_10000.root electron 2
hfShowerLibSimu_emm_eta4_phiall_e3_10000.root electron 3
hfShowerLibSimu_emm_eta4_phiall_e5_10000.root electron 5
hfShowerLibSimu_emm_eta4_phiall_e7_10000.root electron 7
hfShowerLibSimu_emm_eta4_phiall_e10_10000.root electron 10
hfShowerLibSimu_emm_eta4_phiall_e15_10000.root electron 15
hfShowerLibSimu_emm_eta4_phiall_e20_10000.root electron 20
hfShowerLibSimu_emm_eta4_phiall_e30_10000.root electron 30
hfShowerLibSimu_emm_eta4_phiall_e50_10000.root electron 50
hfShowerLibSimu_emm_eta4_phiall_e75_10000.root electron 75
hfShowerLibSimu_emm_eta4_phiall_e100_10000.root electron 100
hfShowerLibSimu_emm_eta4_phiall_e150_10000.root electron 150
hfShowerLibSimu_emm_eta4_phiall_e250_10000.root electron 250
hfShowerLibSimu_emm_eta4_phiall_e350_10000.root electron 350
hfShowerLibSimu_emm_eta4_phiall_e500_10000.root electron 500
hfShowerLibSimu_emm_eta4_phiall_e1000_10000.root electron 1000
hfShowerLibSimu_emm_eta4_phiall_pi2_10000.root Pion 2
hfShowerLibSimu_emm_eta4_phiall_pi3_10000.root Pion 3
hfShowerLibSimu_emm_eta4_phiall_pi5_10000.root Pion 5
hfShowerLibSimu_emm_eta4_phiall_pi7_10000.root Pion 7
hfShowerLibSimu_emm_eta4_phiall_pi10_10000.root Pion 10
hfShowerLibSimu_emm_eta4_phiall_pi15_10000.root Pion 15
hfShowerLibSimu_emm_eta4_phiall_pi20_10000.root Pion 20
hfShowerLibSimu_emm_eta4_phiall_pi30_10000.root Pion 30
hfShowerLibSimu_emm_eta4_phiall_pi50_10000.root Pion 50
hfShowerLibSimu_emm_eta4_phiall_pi75_10000.root Pion 75
hfShowerLibSimu_emm_eta4_phiall_pi100_10000.root Pion 100
hfShowerLibSimu_emm_eta4_phiall_pi150_10000.root Pion 150
hfShowerLibSimu_emm_eta4_phiall_pi250_10000.root Pion 250
hfShowerLibSimu_emm_eta4_phiall_pi350_10000.root Pion 350
hfShowerLibSimu_emm_eta4_phiall_pi500_10000.root Pion 500
hfShowerLibSimu_emm_eta4_phiall_pi1000_10000.root Pion 1000
36 changes: 28 additions & 8 deletions SimG4CMS/ShowerLibraryProducer/test/HFShowerLibraryAnalyzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class HFShowerLibraryAnalyzer : public edm::one::EDAnalyzer<edm::one::WatchRuns,
std::vector<double> pmom_;
HFShowerPhotonCollection* photo_;
HFShowerPhotonCollection photon_;
std::vector<TH1F*> h_x_[2], h_y_[2], h_z_[2], h_t_[2], h_l_[2], h_n_[2];
std::vector<TH1F*> h_x_[2], h_y_[2], h_z_[2], h_t_[2], h_l_[2], h_nl_[2], h_ns_[2];
};

HFShowerLibraryAnalyzer::HFShowerLibraryAnalyzer(edm::ParameterSet const& ps)
Expand All @@ -65,6 +65,7 @@ HFShowerLibraryAnalyzer::HFShowerLibraryAnalyzer(edm::ParameterSet const& ps)
std::string branchPre = ps.getParameter<std::string>("BranchPre");
std::string branchPost = ps.getParameter<std::string>("BranchPost");
verbose_ = ps.getParameter<bool>("Verbosity");
evtPerBin_ = ps.getParameter<bool>("EventPerBin");

if (pTreeName.find('.') == 0)
pTreeName.erase(0, 2);
Expand Down Expand Up @@ -134,13 +135,14 @@ HFShowerLibraryAnalyzer::~HFShowerLibraryAnalyzer() {

void HFShowerLibraryAnalyzer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
desc.add<std::string>("FileName", "HFShowerLibrary_npmt_noatt_eta4_16en_v4.root");
desc.add<std::string>("FileName", "HFShowerLibrary_10000.root");
desc.add<std::string>("TreeEMID", "emParticles");
desc.add<std::string>("TreeHadID", "hadParticles");
desc.add<std::string>("BranchEvt", "");
desc.add<std::string>("BranchPre", "");
desc.add<std::string>("BranchPost", "");
desc.add<bool>("Verbosity", false);
desc.add<int>("EventPerBin", 10000);
descriptions.add("hfShowerLibaryAnalysis", desc);
}

Expand Down Expand Up @@ -195,13 +197,20 @@ void HFShowerLibraryAnalyzer::bookHistos() {
hist->GetYaxis()->SetTitleOffset(1.2);
h_l_[i].emplace_back(hist);
hist->Sumw2();
sprintf(name, "N%d%d", k, i);
sprintf(titlx, "Number of %s shower photons", type.c_str());
hist = tfile->make<TH1F>(name, title, 200, 0.0, 1000.0);
sprintf(name, "NL%d%d", k, i);
sprintf(titlx, "Number of %s shower photons in long fibers", type.c_str());
hist = tfile->make<TH1F>(name, title, 3000, 0.0, 3000.0);
hist->GetXaxis()->SetTitle(titlx);
hist->GetYaxis()->SetTitle("Shower");
hist->GetYaxis()->SetTitleOffset(1.2);
h_n_[i].emplace_back(hist);
h_nl_[i].emplace_back(hist);
sprintf(name, "NS%d%d", k, i);
sprintf(titlx, "Number of %s shower photons in short fibes", type.c_str());
hist = tfile->make<TH1F>(name, title, 3000, 0.0, 3000.0);
hist->GetXaxis()->SetTitle(titlx);
hist->GetYaxis()->SetTitle("Shower");
hist->GetYaxis()->SetTitleOffset(1.2);
h_ns_[i].emplace_back(hist);
}
}

Expand All @@ -212,22 +221,34 @@ void HFShowerLibraryAnalyzer::bookHistos() {
int irc = k * evtPerBin_ + j + 1;
getRecord(type, irc);
int nPhoton = (newForm_) ? photo_->size() : photon_.size();
h_n_[type][k]->Fill(nPhoton);
int nlong = 0, nshort = 0;
for (int i = 0; i < nPhoton; i++) {
if (newForm_) {
if (photo_->at(i).z() > 0) {
nlong++;
} else {
nshort++;
}
h_x_[type][k]->Fill((photo_->at(i)).x());
h_y_[type][k]->Fill((photo_->at(i)).y());
h_z_[type][k]->Fill((photo_->at(i)).z());
h_t_[type][k]->Fill((photo_->at(i)).t());
h_l_[type][k]->Fill((photo_->at(i)).lambda());
} else {
if (photon_[i].z() > 0) {
nlong++;
} else {
nshort++;
}
h_x_[type][k]->Fill(photon_[i].x());
h_y_[type][k]->Fill(photon_[i].y());
h_z_[type][k]->Fill(photon_[i].z());
h_t_[type][k]->Fill(photon_[i].t());
h_l_[type][k]->Fill(photon_[i].lambda());
}
}
h_nl_[type][k]->Fill(nlong);
h_ns_[type][k]->Fill(nshort);
}
}
}
Expand Down Expand Up @@ -308,7 +329,6 @@ void HFShowerLibraryAnalyzer::loadEventInfo(TBranch* branch) {
} else {
edm::LogVerbatim("HFShower") << "HFShowerLibrary::loadEventInfo loads EventInfo from hardwired numbers";
nMomBin_ = 16;
evtPerBin_ = 5000;
totEvents_ = nMomBin_ * evtPerBin_;
libVers_ = 1.1;
listVersion_ = 3.6;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
process.analysis_step)

#process.hfShowerLibaryAnalysis.Verbosity = True
#process.hfShowerLibaryAnalysis.EventPerBin = 5000
#process.hfShowerLibaryAnalysis.FileName = "HFShowerLibrary_npmt_noatt_eta4_16en_v4.root"

# filter all path with the production filter sequence
for path in process.paths:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
)

process.out = cms.OutputModule("PoolOutputModule",
fileName = cms.untracked.string('myOutputFile.root')
fileName = cms.untracked.string('/eos/cms/store/group/dpg_hcal/comm_hcal/lev/myOutputFile.root')
Nbins = cms.int32(16),
Nshowers = cms.int32(10000)
)

process.p = cms.Path(process.photon)
Expand Down