Skip to content

Commit

Permalink
PR to adress review comments (#3)
Browse files Browse the repository at this point in the history
* remove comments, set constants constant

* remove CASTOR cleaner and merger

* Remove single generator customize function. It is not used anymore since the generator step is splitted in 3 steps.

* remove unneeded filters

* optimize embedding correction calculation

* optimize selector loops

* format cpp code with scram build code-format

---------

Co-authored-by: cwinter <[email protected]>
  • Loading branch information
harrypuuter and cwinter authored Apr 16, 2024
1 parent ffeab60 commit a8eae9f
Show file tree
Hide file tree
Showing 25 changed files with 45 additions and 854 deletions.
26 changes: 2 additions & 24 deletions TauAnalysis/MCEmbeddingTools/plugins/CaloCleaner.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "TauAnalysis/MCEmbeddingTools/plugins/CaloCleaner.h"

#include "DataFormats/EcalRecHit/interface/EcalRecHit.h"
#include "DataFormats/HcalRecHit/interface/CastorRecHit.h"
#include "DataFormats/HcalRecHit/interface/HBHERecHit.h"
#include "DataFormats/HcalRecHit/interface/HFRecHit.h"
#include "DataFormats/HcalRecHit/interface/HORecHit.h"
Expand All @@ -11,7 +10,6 @@ typedef CaloCleaner<EcalRecHit> EcalRecHitColCleaner;
typedef CaloCleaner<HBHERecHit> HBHERecHitColCleaner;
typedef CaloCleaner<HFRecHit> HFRecHitColCleaner;
typedef CaloCleaner<HORecHit> HORecHitColCleaner;
typedef CaloCleaner<CastorRecHit> CastorRecHitColCleaner;
typedef CaloCleaner<ZDCRecHit> ZDCRecHitColCleaner;

template <typename T>
Expand All @@ -28,7 +26,6 @@ CaloCleaner<T>::CaloCleaner(const edm::ParameterSet &iConfig)
edm::ParameterSet parameters = iConfig.getParameter<edm::ParameterSet>("TrackAssociatorParameters");
edm::ConsumesCollector iC = consumesCollector();
parameters_.loadParameters(parameters, iC);
// trackAssociator_.useDefaultPropagator();
}

template <typename T>
Expand All @@ -49,8 +46,6 @@ void CaloCleaner<T>::produce(edm::Event &iEvent, const edm::EventSetup &iSetup)

// Fill the correction map
for (edm::View<pat::Muon>::const_iterator iMuon = muons.begin(); iMuon != muons.end(); ++iMuon) {
// get the basic informaiton like fill reco mouon does
// RecoMuon/MuonIdentification/plugins/MuonIdProducer.cc
const reco::Track *track = nullptr;
if (iMuon->track().isNonnull())
track = iMuon->track().get();
Expand All @@ -68,7 +63,6 @@ void CaloCleaner<T>::produce(edm::Event &iEvent, const edm::EventSetup &iSetup)
for (auto input_ : inputs_) {
std::unique_ptr<RecHitCollection> recHitCollection_output(new RecHitCollection());
edm::Handle<RecHitCollection> recHitCollection;
// iEvent.getByToken(input_.second[0], recHitCollection);
iEvent.getByToken(input_.second, recHitCollection);
for (typename RecHitCollection::const_iterator recHit = recHitCollection->begin();
recHit != recHitCollection->end();
Expand All @@ -83,14 +77,6 @@ void CaloCleaner<T>::produce(edm::Event &iEvent, const edm::EventSetup &iSetup)
} else {
recHitCollection_output->push_back(*recHit);
}
/* For the inveted collection
if (correction_map[recHit->detid().rawId()] > 0){
float new_energy = correction_map[recHit->detid().rawId()];
if (new_energy < 0) new_energy =0;
T newRecHit(*recHit);
newRecHit.setEnergy(new_energy);
recHitCollection_output->push_back(newRecHit);
}*/
}
// Save the new collection
recHitCollection_output->sort();
Expand All @@ -104,8 +90,7 @@ void CaloCleaner<T>::produce(edm::Event &iEvent, const edm::EventSetup &iSetup)

template <typename T>
void CaloCleaner<T>::fill_correction_map(TrackDetMatchInfo *, std::map<uint32_t, float> *) {
assert(0); // CV: make sure general function never gets called;
// always use template specializations
assert(0);
}

template <>
Expand All @@ -120,7 +105,6 @@ void CaloCleaner<EcalRecHit>::fill_correction_map(TrackDetMatchInfo *info, std::
for (std::vector<const EcalRecHit *>::const_iterator hit = info->crossedEcalRecHits.begin();
hit != info->crossedEcalRecHits.end();
hit++) {
// (*cor_map) [(*hit)->detid().rawId()] +=(*hit)->energy();
(*cor_map)[(*hit)->detid().rawId()] = (*hit)->energy();
}
}
Expand Down Expand Up @@ -149,20 +133,14 @@ void CaloCleaner<HFRecHit>::fill_correction_map(TrackDetMatchInfo *info, std::ma
return; // No corrections for HF
}

template <>
void CaloCleaner<CastorRecHit>::fill_correction_map(TrackDetMatchInfo *info, std::map<uint32_t, float> *cor_map) {
return; // No corrections for Castor
}

template <>
void CaloCleaner<ZDCRecHit>::fill_correction_map(TrackDetMatchInfo *info, std::map<uint32_t, float> *cor_map) {
return; // No corrections for Castor
return; // No corrections for ZDC
}

DEFINE_FWK_MODULE(EcalRecHitColCleaner);
DEFINE_FWK_MODULE(HBHERecHitColCleaner);
DEFINE_FWK_MODULE(HORecHitColCleaner);
// no need for cleaning outside of tracker, so just a copy of the old collection
DEFINE_FWK_MODULE(HFRecHitColCleaner);
DEFINE_FWK_MODULE(CastorRecHitColCleaner);
DEFINE_FWK_MODULE(ZDCRecHitColCleaner);
6 changes: 2 additions & 4 deletions TauAnalysis/MCEmbeddingTools/plugins/CaloCleaner.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
/** \class CaloCleaner
*
* Clean collections of calorimeter recHits
* (detectors supported at the moment: EB/EE, HB/HE and HO)
* (detectors supported: EB/EE, HB/HE and HO)
*
* \author Tomasz Maciej Frueboes;
* Christian Veelken, LLR
*
*
*
* Clean Up from STefan Wayand, KIT
* Clean Up from Christian Winter & Sebastian Brommer, KIT
*/
#ifndef TauAnalysis_MCEmbeddingTools_CaloCleaner_H
#define TauAnalysis_MCEmbeddingTools_CaloCleaner_H
Expand Down
20 changes: 2 additions & 18 deletions TauAnalysis/MCEmbeddingTools/plugins/CollectionMerger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ typedef CollectionMerger<edm::SortedCollection<EcalRecHit>, EcalRecHit> EcalRecH
typedef CollectionMerger<edm::SortedCollection<HBHERecHit>, HBHERecHit> HBHERecHitColMerger;
typedef CollectionMerger<edm::SortedCollection<HFRecHit>, HFRecHit> HFRecHitColMerger;
typedef CollectionMerger<edm::SortedCollection<HORecHit>, HORecHit> HORecHitColMerger;
typedef CollectionMerger<edm::SortedCollection<CastorRecHit>, CastorRecHit> CastorRecHitColMerger;
typedef CollectionMerger<edm::SortedCollection<ZDCRecHit>, ZDCRecHit> ZDCRecHitColMerger;

typedef CollectionMerger<edm::RangeMap<DTLayerId, edm::OwnVector<DTRecHit1DPair>>, DTRecHit1DPair> DTRecHitColMerger;
Expand All @@ -67,7 +66,6 @@ CollectionMerger<T1, T2>::CollectionMerger(const edm::ParameterSet &iConfig) {
willconsume(iConfig);
for (const auto &toproduce : inputs_) {
std::string alias(iConfig.getParameter<std::string>("@module_label"));
// std::cout<<toproduce.first<<"\t"<<toproduce.second.size()<<std::endl;
willproduce(toproduce.first, alias);
}
}
Expand Down Expand Up @@ -208,8 +206,7 @@ void CollectionMerger<T1, T2>::fill_output_obj_seed(edm::Event &iEvent,

edm::Handle<reco::TrackCollection> track_new_col;
iEvent.getByToken(inputs_fixtrackcol_, track_new_col);
std::map<reco::TrackRef, reco::TrackRef>
simple_track_to_track_map; // I didn't find a more elegant way, so just build a good old fassion std::map
std::map<reco::TrackRef, reco::TrackRef> simple_track_to_track_map;
for (unsigned abc = 0; abc < track_new_col->size(); ++abc) {
reco::TrackRef trackRef(track_new_col, abc);
simple_track_to_track_map[((*track_ref_map)[trackRef])[0]] = trackRef;
Expand Down Expand Up @@ -285,8 +282,7 @@ template <typename T1, typename T2>
void CollectionMerger<T1, T2>::fill_output_obj(edm::Event &iEvent,
std::unique_ptr<MergeCollection> &output,
std::vector<edm::Handle<MergeCollection>> &inputCollections) {
assert(0); // CV: make sure general function never gets called;
// always use template specializations
assert(0);
}

// Start with the Tracker collections
Expand All @@ -306,7 +302,6 @@ void CollectionMerger<edmNew::DetSetVector<SiStripCluster>, SiStripCluster>::fil
fill_output_obj_tracker(output, inputCollections);
}

// Next are the Calo entries
template <>
void CollectionMerger<edm::SortedCollection<EcalRecHit>, EcalRecHit>::fill_output_obj(
edm::Event &iEvent,
Expand Down Expand Up @@ -339,14 +334,6 @@ void CollectionMerger<edm::SortedCollection<HORecHit>, HORecHit>::fill_output_ob
fill_output_obj_calo(output, inputCollections);
}

template <>
void CollectionMerger<edm::SortedCollection<CastorRecHit>, CastorRecHit>::fill_output_obj(
edm::Event &iEvent,
std::unique_ptr<MergeCollection> &output,
std::vector<edm::Handle<MergeCollection>> &inputCollections) {
fill_output_obj_calo(output, inputCollections);
}

template <>
void CollectionMerger<edm::SortedCollection<ZDCRecHit>, ZDCRecHit>::fill_output_obj(
edm::Event &iEvent,
Expand All @@ -355,7 +342,6 @@ void CollectionMerger<edm::SortedCollection<ZDCRecHit>, ZDCRecHit>::fill_output_
fill_output_obj_calo(output, inputCollections);
}

// Here the Muon Chamber
template <>
void CollectionMerger<edm::RangeMap<DTLayerId, edm::OwnVector<DTRecHit1DPair>>, DTRecHit1DPair>::fill_output_obj(
edm::Event &iEvent,
Expand All @@ -380,7 +366,6 @@ void CollectionMerger<edm::RangeMap<RPCDetId, edm::OwnVector<RPCRecHit>>, RPCRec
fill_output_obj_muonchamber(output, inputCollections);
}

// Here Electron Seeds
template <>
void CollectionMerger<std::vector<reco::ElectronSeed>, reco::ElectronSeed>::fill_output_obj(
edm::Event &iEvent,
Expand All @@ -399,7 +384,6 @@ DEFINE_FWK_MODULE(EcalRecHitColMerger);
DEFINE_FWK_MODULE(HBHERecHitColMerger);
DEFINE_FWK_MODULE(HFRecHitColMerger);
DEFINE_FWK_MODULE(HORecHitColMerger);
DEFINE_FWK_MODULE(CastorRecHitColMerger);
DEFINE_FWK_MODULE(ZDCRecHitColMerger);

DEFINE_FWK_MODULE(DTRecHitColMerger);
Expand Down
2 changes: 1 addition & 1 deletion TauAnalysis/MCEmbeddingTools/plugins/CollectionMerger.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* \author Stefan Wayand;
* Christian Veelken, LLR
*
* Clean Up from Christian Winter & Sebastian Brommer, KIT
*/
#ifndef TauAnalysis_MCEmbeddingTools_CollectionMerger_H
#define TauAnalysis_MCEmbeddingTools_CollectionMerger_H
Expand Down Expand Up @@ -35,7 +36,6 @@
#include "DataFormats/TrackerRecHit2D/interface/BaseTrackerRecHit.h"
#include "DataFormats/TrackerRecHit2D/interface/OmniClusterRef.h"

// #include "TauAnalysis/MCEmbeddingTools/interface/embeddingAuxFunctions.h"
#include <iostream>
#include <map>
#include <string>
Expand Down
82 changes: 0 additions & 82 deletions TauAnalysis/MCEmbeddingTools/plugins/DYToElElGenFilter.cc

This file was deleted.

Loading

0 comments on commit a8eae9f

Please sign in to comment.