Skip to content

Commit 616753e

Browse files
committed
use one flags to save hits
1 parent aa73d03 commit 616753e

File tree

1 file changed

+39
-45
lines changed

1 file changed

+39
-45
lines changed

RecoHGCal/TICL/plugins/TICLDumper.cc

Lines changed: 39 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -653,8 +653,7 @@ class TICLDumper : public edm::one::EDAnalyzer<edm::one::WatchRuns, edm::one::Sh
653653
bool saveTICLCandidate_;
654654
bool saveSimTICLCandidate_;
655655
bool saveTracks_;
656-
bool saveRecHits_;
657-
bool saveSimHits_;
656+
bool saveHits_;
658657

659658
// Output tree
660659
TTree* tree_;
@@ -769,6 +768,7 @@ class TICLDumper : public edm::one::EDAnalyzer<edm::one::WatchRuns, edm::one::Sh
769768
std::vector<float> rechit_y;
770769
std::vector<float> rechit_z;
771770
std::vector<float> rechit_time;
771+
std::vector<float> rechit_radius;
772772

773773
std::vector<uint32_t> simhit_ID;
774774
std::vector<float> simhit_energy;
@@ -897,6 +897,7 @@ void TICLDumper::clearVariables() {
897897
rechit_y.clear();
898898
rechit_z.clear();
899899
rechit_time.clear();
900+
rechit_radius.clear();
900901

901902
simhit_ID.clear();
902903
simhit_energy.clear();
@@ -965,8 +966,7 @@ TICLDumper::TICLDumper(const edm::ParameterSet& ps)
965966
saveTICLCandidate_(ps.getParameter<bool>("saveSimTICLCandidate")),
966967
saveSimTICLCandidate_(ps.getParameter<bool>("saveSimTICLCandidate")),
967968
saveTracks_(ps.getParameter<bool>("saveTracks")),
968-
saveRecHits_(ps.getParameter<bool>("saveRecHits")),
969-
saveSimHits_(ps.getParameter<bool>("saveSimHits")) {
969+
saveHits_(ps.getParameter<bool>("saveHits")) {
970970
if (saveSuperclustering_) {
971971
superclustering_linkedResultTracksters_token =
972972
consumes<std::vector<std::vector<unsigned int>>>(ps.getParameter<edm::InputTag>("superclustering"));
@@ -1020,16 +1020,16 @@ void TICLDumper::beginJob() {
10201020
tracksters_trees.push_back(tree);
10211021
tracksters_dumperHelpers_[i].initTree(tree, &eventId_);
10221022
}
1023-
if (saveRecHits_) {
1023+
if (saveHits_) {
10241024
rechits_tree_ = fs->make<TTree>("rechits", "HGCAL rechits");
10251025
rechits_tree_->Branch("ID", &rechit_ID);
10261026
rechits_tree_->Branch("energy", &rechit_energy);
10271027
rechits_tree_->Branch("position_x", &rechit_x);
10281028
rechits_tree_->Branch("position_y", &rechit_y);
10291029
rechits_tree_->Branch("position_z", &rechit_z);
10301030
rechits_tree_->Branch("time", &rechit_time);
1031-
}
1032-
if (saveSimHits_) {
1031+
rechits_tree_->Branch("radiusToSide", &rechit_radius);
1032+
10331033
simhits_tree_ = fs->make<TTree>("simhits", "HGCAL simhits");
10341034
simhits_tree_->Branch("ID", &simhit_ID);
10351035
simhits_tree_->Branch("energy", &simhit_energy);
@@ -1277,42 +1277,37 @@ void TICLDumper::analyze(const edm::Event& event, const edm::EventSetup& setup)
12771277

12781278
nclusters_ = clusters.size();
12791279

1280-
std::vector<std::vector<PCaloHit>> simhits_collections;
1281-
for (auto const& sh_token : simhits_tokens_) {
1282-
edm::Handle<std::vector<PCaloHit>> simhit_handle;
1283-
event.getByToken(sh_token, simhit_handle);
1284-
simhits_collections.push_back(*simhit_handle);
1285-
}
1286-
1287-
for (auto const& rh_token : rechits_tokens_) {
1288-
edm::Handle<HGCRecHitCollection> rechit_handle;
1289-
event.getByToken(rh_token, rechit_handle);
1290-
const auto& rhColl = *rechit_handle;
1291-
for (auto const& rh : rhColl) {
1292-
rechit_energy.push_back(rh.energy());
1293-
auto const rhPosition = detectorTools_->rhtools.getPosition(rh.detid());
1294-
rechit_x.push_back(rhPosition.x());
1295-
rechit_y.push_back(rhPosition.y());
1296-
rechit_z.push_back(rhPosition.z());
1297-
rechit_ID.push_back(rh.detid());
1298-
rechit_time.push_back(rh.time());
1280+
if (saveHits_) {
1281+
for (auto const& sh_token : simhits_tokens_) {
1282+
edm::Handle<std::vector<PCaloHit>> simhit_handle;
1283+
event.getByToken(sh_token, simhit_handle);
1284+
const auto& shColl = *simhit_handle;
1285+
for (auto const& sh : shColl) {
1286+
simhit_energy.push_back(sh.energy());
1287+
simhit_energyEM.push_back(sh.energyEM());
1288+
simhit_energyHad.push_back(sh.energyHad());
1289+
auto const shPosition = detectorTools_->rhtools.getPosition(sh.id());
1290+
simhit_x.push_back(shPosition.x());
1291+
simhit_y.push_back(shPosition.y());
1292+
simhit_z.push_back(shPosition.z());
1293+
simhit_ID.push_back(sh.id());
1294+
simhit_time.push_back(sh.time());
12991295
}
1300-
}
13011296

1302-
for (auto const& sh_token : simhits_tokens_) {
1303-
edm::Handle<std::vector<PCaloHit>> simhit_handle;
1304-
event.getByToken(sh_token, simhit_handle);
1305-
const auto& shColl = *simhit_handle;
1306-
for (auto const& sh : shColl) {
1307-
simhit_energy.push_back(sh.energy());
1308-
simhit_energyEM.push_back(sh.energyEM());
1309-
simhit_energyHad.push_back(sh.energyHad());
1310-
auto const shPosition = detectorTools_->rhtools.getPosition(sh.id());
1311-
simhit_x.push_back(shPosition.x());
1312-
simhit_y.push_back(shPosition.y());
1313-
simhit_z.push_back(shPosition.z());
1314-
simhit_ID.push_back(sh.id());
1315-
simhit_time.push_back(sh.time());
1297+
for (auto const& rh_token : rechits_tokens_) {
1298+
edm::Handle<HGCRecHitCollection> rechit_handle;
1299+
event.getByToken(rh_token, rechit_handle);
1300+
const auto& rhColl = *rechit_handle;
1301+
for (auto const& rh : rhColl) {
1302+
rechit_energy.push_back(rh.energy());
1303+
auto const rhPosition = detectorTools_->rhtools.getPosition(rh.detid());
1304+
rechit_x.push_back(rhPosition.x());
1305+
rechit_y.push_back(rhPosition.y());
1306+
rechit_z.push_back(rhPosition.z());
1307+
rechit_ID.push_back(rh.detid());
1308+
rechit_time.push_back(rh.time());
1309+
rechit_radius.push_back(detectorTools_->rhtools.getRadiusToSide(rh.detid()));
1310+
}
13161311
}
13171312
}
13181313

@@ -1526,10 +1521,10 @@ void TICLDumper::analyze(const edm::Event& event, const edm::EventSetup& setup)
15261521
tracks_tree_->Fill();
15271522
if (saveSimTICLCandidate_)
15281523
simTICLCandidate_tree->Fill();
1529-
if (saveRecHits_)
1524+
if (saveHits_) {
15301525
rechits_tree_->Fill();
1531-
if (saveSimHits_)
15321526
simhits_tree_->Fill();
1527+
}
15331528
}
15341529

15351530
void TICLDumper::endJob() {}
@@ -1610,8 +1605,7 @@ void TICLDumper::fillDescriptions(edm::ConfigurationDescriptions& descriptions)
16101605
desc.add<bool>("saveSuperclustering", true);
16111606
desc.add<bool>("saveRecoSuperclusters", true)
16121607
->setComment("Save superclustering Egamma collections (as reco::SuperCluster)");
1613-
desc.add<bool>("saveRecHits", false);
1614-
desc.add<bool>("saveSimHits", false);
1608+
desc.add<bool>("saveHits", false);
16151609
descriptions.add("ticlDumper", desc);
16161610
}
16171611

0 commit comments

Comments
 (0)