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

Validation/Geometry: Fix TTree Option #30489

Merged
merged 2 commits into from
Jul 4, 2020
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
1 change: 1 addition & 0 deletions Validation/Geometry/interface/MaterialBudgetTree.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class MaterialBudgetTree : public MaterialBudgetFormat {
void book(); // user booking
std::unique_ptr<TFile> theFile;
std::unique_ptr<TTree> theTree;
std::string fname;

static const int MAXSTEPS = 10000;

Expand Down
29 changes: 19 additions & 10 deletions Validation/Geometry/src/MaterialBudgetTree.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@

#include "FWCore/MessageLogger/interface/MessageLogger.h"

MaterialBudgetTree::MaterialBudgetTree(std::shared_ptr<MaterialBudgetData> data, const std::string& filename)
MaterialBudgetTree::MaterialBudgetTree(std::shared_ptr<MaterialBudgetData> data, const std::string &filename)
: MaterialBudgetFormat(data) {
theFile = std::make_unique<TFile>(filename.c_str(), "RECREATE");
theFile->cd();
fname = filename;
book();
}

Expand Down Expand Up @@ -112,8 +111,6 @@ void MaterialBudgetTree::fillPerStep() {}
void MaterialBudgetTree::fillEndTrack() {
t_MB = theData->getTotalMB();
t_IL = theData->getTotalIL();
// t_Eta = theData->getEta();
// t_Phi = theData->getPhi();

t_ParticleID = theData->getID();
t_ParticlePt = theData->getPt();
Expand Down Expand Up @@ -204,16 +201,28 @@ void MaterialBudgetTree::fillEndTrack() {
}
}

theTree->Fill();
if (theData->getNumberOfSteps() != 0) {
Int_t ssize = theTree->Fill();
edm::LogInfo("MaterialBudget") << "MaterialBudgetTree: Filling Tree " << ssize << " bytes";
} else {
edm::LogWarning("MaterialBudget") << "MaterialBudgetTree: Event with 0 steps not recorded";
}
}

void MaterialBudgetTree::endOfRun() {
// Prefered method to include any instruction
// once all the tracks are done

edm::LogInfo("MaterialBudget") << "MaterialBudgetTree Writing TTree to ROOT file";
TFile *outFile = new TFile(fname.c_str(), "RECREATE");
outFile->mkdir("TEST");

if (theTree) {
TTree *t1 = theTree->CloneTree();
t1->Write();
edm::LogWarning("MaterialBudget") << "TTree Written " << t1;
} else {
edm::LogError("MaterialBudget") << "Material Budget Tree: Tree Pointer Null";
}

theFile->cd();
theTree->Write();
theFile->Close();
delete outFile;
}
12 changes: 6 additions & 6 deletions Validation/Geometry/test/runP_Tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
process.MessageLogger = cms.Service(
"MessageLogger",
destinations = cms.untracked.vstring('info'),
categories = cms.untracked.vstring('logMsg'),
categories = cms.untracked.vstring(['logMsg','MaterialBudget']),
info = cms.untracked.PSet(
threshold = cms.untracked.string('INFO'),
filename = cms.untracked.string('Log_%s_%s' % (options.label,options.geom)),
Expand Down Expand Up @@ -126,14 +126,14 @@ def _adaptToRun2(det):
MaterialBudgetAction = cms.PSet(
HistosFile = cms.string('matbdg_%s_%s.root' % (options.label,
options.geom)),
AllStepsToTree = cms.bool(True),
AllStepsToTree = cms.bool(False),
HistogramList = cms.string('Tracker'),
SelectedVolumes = cms.vstring(_components),
TreeFile = cms.string('None'), ## is NOT requested

TreeFile = cms.string('matbdg_tree_%s_%s.root' % (options.label,
options.geom)),
StopAfterProcess = cms.string('None'),
# TextFile = cms.string("matbdg_Tracker.txt")
TextFile = cms.string('None')
TextFile = cms.string('matbdg_%s_%s.txt' % (options.label,
options.geom))
)
))

Expand Down