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

HCAL: HF ShowerLibrary combining code/script update #34561

Merged
merged 5 commits into from
Jul 21, 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
64 changes: 32 additions & 32 deletions SimG4CMS/ShowerLibraryProducer/data/fileList.txt
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
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
hfShowerLibSimu_emm_eta4_phiall_e2_11000.root electron 2
hfShowerLibSimu_emm_eta4_phiall_e3_11000.root electron 3
hfShowerLibSimu_emm_eta4_phiall_e5_11000.root electron 5
hfShowerLibSimu_emm_eta4_phiall_e7_11000.root electron 7
hfShowerLibSimu_emm_eta4_phiall_e10_11000.root electron 10
hfShowerLibSimu_emm_eta4_phiall_e15_11000.root electron 15
hfShowerLibSimu_emm_eta4_phiall_e20_11000.root electron 20
hfShowerLibSimu_emm_eta4_phiall_e30_11000.root electron 30
hfShowerLibSimu_emm_eta4_phiall_e50_11000.root electron 50
hfShowerLibSimu_emm_eta4_phiall_e75_11000.root electron 75
hfShowerLibSimu_emm_eta4_phiall_e100_11000.root electron 100
hfShowerLibSimu_emm_eta4_phiall_e150_11000.root electron 150
hfShowerLibSimu_emm_eta4_phiall_e250_11000.root electron 250
hfShowerLibSimu_emm_eta4_phiall_e350_11000.root electron 350
hfShowerLibSimu_emm_eta4_phiall_e500_11000.root electron 500
hfShowerLibSimu_emm_eta4_phiall_e1000_11000.root electron 1000
hfShowerLibSimu_emm_eta4_phiall_pi2_11000.root Pion 2
hfShowerLibSimu_emm_eta4_phiall_pi3_11000.root Pion 3
hfShowerLibSimu_emm_eta4_phiall_pi5_11000.root Pion 5
hfShowerLibSimu_emm_eta4_phiall_pi7_11000.root Pion 7
hfShowerLibSimu_emm_eta4_phiall_pi10_11000.root Pion 10
hfShowerLibSimu_emm_eta4_phiall_pi15_11000.root Pion 15
hfShowerLibSimu_emm_eta4_phiall_pi20_11000.root Pion 20
hfShowerLibSimu_emm_eta4_phiall_pi30_11000.root Pion 30
hfShowerLibSimu_emm_eta4_phiall_pi50_11000.root Pion 50
hfShowerLibSimu_emm_eta4_phiall_pi75_11000.root Pion 75
hfShowerLibSimu_emm_eta4_phiall_pi100_11000.root Pion 100
hfShowerLibSimu_emm_eta4_phiall_pi150_11000.root Pion 150
hfShowerLibSimu_emm_eta4_phiall_pi250_11000.root Pion 250
hfShowerLibSimu_emm_eta4_phiall_pi350_11000.root Pion 350
hfShowerLibSimu_emm_eta4_phiall_pi500_11000.root Pion 500
hfShowerLibSimu_emm_eta4_phiall_pi1000_11000.root Pion 1000
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class HcalForwardLibWriter : public edm::one::EDAnalyzer<> {
int readUserData();
int nbins;
int nshowers;
int bsize;
int splitlevel;

TFile* theFile;
TTree* theTree;
Expand Down
49 changes: 31 additions & 18 deletions SimG4CMS/ShowerLibraryProducer/plugins/HcalForwardLibWriter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,22 @@ HcalForwardLibWriter::HcalForwardLibWriter(const edm::ParameterSet& iConfig) {
edm::FileInPath fp = theParms.getParameter<edm::FileInPath>("FileName");
nbins = theParms.getParameter<int>("Nbins");
nshowers = theParms.getParameter<int>("Nshowers");
bsize = theParms.getParameter<int>("BufSize");
splitlevel = theParms.getParameter<int>("SplitLevel");

std::string pName = fp.fullPath();
if (pName.find('.') == 0)
pName.erase(0, 2);
theDataFile = pName;
readUserData();

int bsize = 64000;
fs->file().cd();
LibTree = new TTree("HFSimHits", "HFSimHits");
LibTree->Branch("emParticles", "HFShowerPhotons-emParticles", &emColl, bsize);
LibTree->Branch("hadParticles", "HFShowerPhotons-hadParticles", &hadColl, bsize);

//https://root.cern/root/html534/TTree.html
// TBranch*Branch(const char* name, const char* classname, void** obj, Int_t bufsize = 32000, Int_t splitlevel = 99)
LibTree->Branch("emParticles", "HFShowerPhotons-emParticles", &emColl, bsize, splitlevel);
LibTree->Branch("hadParticles", "HFShowerPhotons-hadParticles", &hadColl, bsize, splitlevel);
}

HcalForwardLibWriter::~HcalForwardLibWriter() {}
Expand All @@ -38,37 +42,46 @@ void HcalForwardLibWriter::analyze(const edm::Event& iEvent, const edm::EventSet
for (int i = 0; i < n; ++i) {
std::string fn = theFileHandle[i].name;
std::string particle = theFileHandle[i].id;

// std::cout << "*** Input file " << i << " " << fn << std::endl;

TFile* theFile = new TFile(fn.c_str(), "READ");
TTree* theTree = (TTree*)gDirectory->Get("g4SimHits/CherenkovPhotons");
int nphot = 0;
float x[10000];
float y[10000];
float z[10000];
float t[10000];
float lambda[10000];
int fiberId[10000];
for (int kk = 0; kk < 10000; ++kk) {
x[kk] = 0.;
y[kk] = 0.;
z[kk] = 0.;
t[kk] = 0.;
lambda[kk] = 0.;
fiberId[kk] = 0;

const int size = 10000;
if (nshowers > size) {
edm::LogError("HcalForwardLibWriter") << "Too big Nshowers number";
return;
}

float x[size] = {0.};
float y[size] = {0.};
float z[size] = {0.};
float t[size] = {0.};
float lambda[size] = {0.};
int fiberId[size] = {0};
float primZ; // added

theTree->SetBranchAddress("nphot", &nphot);
theTree->SetBranchAddress("x", &x);
theTree->SetBranchAddress("y", &y);
theTree->SetBranchAddress("z", &z);
theTree->SetBranchAddress("t", &t);
theTree->SetBranchAddress("lambda", &lambda);
theTree->SetBranchAddress("fiberId", &fiberId);
theTree->SetBranchAddress("primZ", &primZ); // added
int nentries = int(theTree->GetEntries());
if (nentries > 5000)
nentries = 5000;
int ngood = 0;
int nbytes = 0;
// cycle over showers ====================================================
for (int iev = 0; iev < nentries; iev++) {
nbytes += theTree->GetEntry(iev);
if (primZ < 990.)
continue; // exclude showers with interactions in front of HF (1m of air)
ngood++;
if (ngood > nshowers)
continue;
if (particle == "electron") {
emColl.clear();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
HcalForwardLibWriterParameters = cms.PSet(
FileName = cms.FileInPath('SimG4CMS/ShowerLibraryProducer/data/fileList.txt'),
Nbins = cms.int32(16),
Nshowers = cms.int32(5000)
Nshowers = cms.int32(10000),
BufSize = cms.int32(1),
SplitLevel = cms.int32(2)
)
)

Expand Down
26 changes: 0 additions & 26 deletions SimG4CMS/ShowerLibraryProducer/test/python/writelibraryfile_cfg.py

This file was deleted.