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

Tau Embedding update and integration #43871

Merged
merged 58 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
df878d9
MCEmbeddingTools: update BuildFile
Feb 3, 2022
ff041ba
MCEmbeddingTools: update CollectionMerger
Feb 3, 2022
a2a267f
MCEmbeddingTools: introducing other GenFilters
Feb 3, 2022
bad12dd
MCEmbeddingTools: introducing EmbeddingBeamSpotOnlineProducer
Feb 3, 2022
5257e12
MCEmbeddingTools: introducing DoubleCollectionMerger
Feb 3, 2022
f15f9ac
MCEmbeddingTools: introducing EmbeddingHltPixelVerticesProducer
Feb 3, 2022
1756c37
MCEmbeddingTools: updating EmbeddingLHEProducer
Feb 3, 2022
948f821
MCEmbeddingTools: updating MuMuForEmbeddingSelector
Feb 3, 2022
cfca6a7
MCEmbeddingTools: updating TrackMergeremb
Feb 3, 2022
4731fe5
MCEmbeddingTools: adding configuration for all filters
Feb 3, 2022
384bccf
MCEmbeddingTools: adding configuration for additional producers
Feb 3, 2022
10eaeb2
MCEmbeddingTools: updating configuration for EmbeddingLHEProducer & M…
Feb 3, 2022
674e409
MCEmbeddingTools: update customisers
Feb 3, 2022
c1b408f
customisers.py: remove cleanUnscheduled since deprecated
Feb 3, 2022
2cba985
customisers.py: fix remaining code bugs
Feb 3, 2022
89846af
customisers.py: remove crashing modules for the time-being
Feb 3, 2022
2c5adca
DataFormats/EgammaCandidates/src/classes_def.xml: define maps require…
Feb 3, 2022
8d42003
MCEmbeddingTools: fixing customise_Merging to avoid schdule deadlocks
Feb 4, 2022
2a4cd33
TauAnalysis/MCEmbeddingTools: create skeleton for hcalDigis merger
Feb 10, 2022
3fb467b
TauAnalysis/MCEmbeddingTools: merging electron seeds also for low Pt …
Feb 10, 2022
a4bd3f2
customisers.py: merge lowPtGsfEleGsfTracks
Mar 4, 2022
5385960
merge also displaced Muons 1st Step collections
Apr 20, 2023
78bfe77
adapt displacedMuons configuration as for usual Muons
Apr 20, 2023
25e798e
Remove Low Pt Electron Seed Merger, since the producer creates not on…
Apr 20, 2023
ecb50b6
keeping all trajectory seeds now, since needed by lowPt electrons
Apr 21, 2023
e7b1817
Fix Geometry records for Tracking Rec. Hits
Apr 28, 2023
756aae2
Adding recoElectronSeeds to the collections to be kept for merging
May 12, 2023
0390729
Fix Ctf track reference for lowPtGsfElectrons
May 15, 2023
4069ab0
re-enable Filling of muons as done usually; merge track collection fo…
May 16, 2023
af160eb
Fixing production sequence for isolation deposits
May 17, 2023
26754e1
Fixing production sequence for id selection types
May 17, 2023
cb48e66
Removing MC info not required for muons in embedded samples
May 22, 2023
f73346c
adding merging and production sequences for displaced muons
May 22, 2023
cccdc99
Hotfix to cover displacedMuons after merging displacedTracks
May 26, 2023
41b8fb7
This doc not needed anymore, since derived from name, it seems
May 26, 2023
fea22b8
Fix rec. hits geometry records also for gsf tracks
May 30, 2023
13c344b
adapt nanoAOD config to create correct TriggerResults and gen particles
Jun 22, 2023
4b2dc52
Override MC matching removal for embedded samples
Jun 22, 2023
8ee77ad
fix trigger result creation
Jun 22, 2023
1eebd03
Improve calculation for generator particles
Jun 22, 2023
7351d14
Add 3rd HLT path to fix behaviour for 2016 samples
Jun 23, 2023
f059c81
add L1 results & bits for full nanoAOD content
Jun 26, 2023
311a3fc
add SIMembeddingpreHLT to be able to include L1simulation in nanoAOD
Jun 26, 2023
685d2a7
fix the case where a ctf track could be shared by several seeds or sa…
Jun 27, 2023
fc0d112
roll back the change, introduce explanationns into the cff file
Jun 27, 2023
5ddebdd
fix the ct pps sequences to use _LHC raw data
Jun 30, 2023
68428e4
add sequence to create L1 objects
Jun 30, 2023
286e560
add improved muon cleaning
Nov 23, 2023
9226bc1
make the changes compatible with cmssw changes
Nov 23, 2023
01c9307
format code with clang-format
Nov 27, 2023
e9283b6
rewrite header files to only contain declaration
Nov 28, 2023
efe13d9
load EventSetup information for each run separatly
Dec 6, 2023
c79fde4
debug correct handling of input comming from RESELECT collection
Dec 6, 2023
49d02ef
add a running test for embedding.
Dec 13, 2023
41944c0
add workflow unittests for each UL year
Jan 24, 2024
12e24e3
apply patches for code-checks and code-format as CI suggests
Feb 5, 2024
ffeab60
change root file dir in embedding tests
Feb 14, 2024
a8eae9f
PR to adress review comments (#3)
harrypuuter Apr 16, 2024
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
7 changes: 7 additions & 0 deletions DataFormats/EgammaCandidates/src/classes_def.xml
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,13 @@
<version ClassVersion="3" checksum="3868678681"/>
</class>

<!-- ValueMap<reco::GsfTrack> -->
<class name="edm::ValueMap<reco::GsfTrackRefVector>" />
<class name="edm::Wrapper<edm::ValueMap<reco::GsfTrackRefVector> >" />
<class name="std::vector<edm::RefVector<std::vector<reco::GsfTrack>,reco::GsfTrack,edm::refhelper::FindUsingAdvance<std::vector<reco::GsfTrack>,reco::GsfTrack> > >"/>
<class name="edm::Wrapper<edm::RefVector<std::vector<reco::GsfTrack>,reco::GsfTrack,edm::refhelper::FindUsingAdvance<std::vector<reco::GsfTrack>,reco::GsfTrack> > >"/>
<class name="std::vector<edm::Ref<std::vector<reco::GsfTrack>,reco::GsfTrack,edm::refhelper::FindUsingAdvance<std::vector<reco::GsfTrack>,reco::GsfTrack> > >"/>

Copy link
Contributor

@smuzaffar smuzaffar May 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@winterchristian , normally GsfTrackReco type dictionaries should go in to DataFormats/GsfTrackReco. Any specific reason to add these dict in DataFormats/EgammaCandidates package?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cms-sw/reconstruction-l2 any objections on moving these to DataFormats/GsfTrackReco ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No objection. Sorry we missed it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same from us (answering for @winterchristian since he is on holiday)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in #44884

<class name="reco::GsfElectron" ClassVersion="20">
<version ClassVersion="20" checksum="2375747450"/>
<version ClassVersion="19" checksum="1682285704"/>
Expand Down
10 changes: 6 additions & 4 deletions TauAnalysis/MCEmbeddingTools/plugins/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
<use name="FWCore/Framework"/>
<use name="FWCore/ParameterSet"/>
<use name="DataFormats/PatCandidates"/>
<use name="pythia8"/>
<use name="DataFormats/RPCRecHit"/>
<use name="DataFormats/EcalRecHit"/>
<use name="DataFormats/HcalRecHit"/>
<use name="TrackingTools/TrackAssociator"/>
<use name="DataFormats/TrackReco"/>
<use name="CondFormats/BeamSpotObjects"/>
<use name="SimDataFormats/GeneratorProducts"/>
<use name="CommonTools/UtilAlgos"/>
<use name="PhysicsTools/UtilAlgos"/>
<use name="CondFormats/JetMETObjects"/>
<use name="JetMETCorrections/Objects"/>
<use name="JetMETCorrections/JetCorrector"/>
<use name="RecoMET/METAlgorithms"/>
<flags EDM_PLUGIN="1"/>
86 changes: 74 additions & 12 deletions TauAnalysis/MCEmbeddingTools/plugins/CaloCleaner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,92 @@
#include "DataFormats/HcalRecHit/interface/HFRecHit.h"
#include "DataFormats/HcalRecHit/interface/HORecHit.h"
#include "DataFormats/HcalRecHit/interface/ZDCRecHit.h"
#include "DataFormats/HcalRecHit/interface/CastorRecHit.h"

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>
CaloCleaner<T>::CaloCleaner(const edm::ParameterSet &iConfig)
: mu_input_(consumes<edm::View<pat::Muon>>(iConfig.getParameter<edm::InputTag>("MuonCollection"))),
propagatorToken_(esConsumes(edm::ESInputTag("", "SteppingHelixPropagatorAny"))) {
std::vector<edm::InputTag> inCollections = iConfig.getParameter<std::vector<edm::InputTag>>("oldCollection");
for (const auto &inCollection : inCollections) {
inputs_[inCollection.instance()] = consumes<RecHitCollection>(inCollection);
produces<RecHitCollection>(inCollection.instance());
}

is_preshower_ = iConfig.getUntrackedParameter<bool>("is_preshower", false);
edm::ParameterSet parameters = iConfig.getParameter<edm::ParameterSet>("TrackAssociatorParameters");
edm::ConsumesCollector iC = consumesCollector();
parameters_.loadParameters(parameters, iC);
}

template <typename T>
CaloCleaner<T>::~CaloCleaner() {
// nothing to be done yet...
}

template <typename T>
void CaloCleaner<T>::produce(edm::Event &iEvent, const edm::EventSetup &iSetup) {
auto const &propagator = iSetup.getData(propagatorToken_);
trackAssociator_.setPropagator(&propagator);

edm::Handle<edm::View<pat::Muon>> muonHandle;
iEvent.getByToken(mu_input_, muonHandle);
edm::View<pat::Muon> muons = *muonHandle;

std::map<uint32_t, float> correction_map;

// Fill the correction map
for (edm::View<pat::Muon>::const_iterator iMuon = muons.begin(); iMuon != muons.end(); ++iMuon) {
const reco::Track *track = nullptr;
if (iMuon->track().isNonnull())
track = iMuon->track().get();
else if (iMuon->standAloneMuon().isNonnull())
track = iMuon->standAloneMuon().get();
else
throw cms::Exception("FatalError")
<< "Failed to fill muon id information for a muon with undefined references to tracks";
TrackDetMatchInfo info =
trackAssociator_.associate(iEvent, iSetup, *track, parameters_, TrackDetectorAssociator::Any);
fill_correction_map(&info, &correction_map);
}

// Copy the old collection and correct if necessary
for (auto input_ : inputs_) {
std::unique_ptr<RecHitCollection> recHitCollection_output(new RecHitCollection());
edm::Handle<RecHitCollection> recHitCollection;
iEvent.getByToken(input_.second, recHitCollection);
for (typename RecHitCollection::const_iterator recHit = recHitCollection->begin();
recHit != recHitCollection->end();
++recHit) {
if (correction_map[recHit->detid().rawId()] > 0) {
float new_energy = recHit->energy() - correction_map[recHit->detid().rawId()];
if (new_energy <= 0)
continue; // Do not save empty Hits
T newRecHit(*recHit);
newRecHit.setEnergy(new_energy);
recHitCollection_output->push_back(newRecHit);
} else {
recHitCollection_output->push_back(*recHit);
}
}
// Save the new collection
recHitCollection_output->sort();
iEvent.put(std::move(recHitCollection_output), input_.first);
}
}

//-------------------------------------------------------------------------------
// define 'buildRecHit' functions used for different types of recHits
//-------------------------------------------------------------------------------

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 @@ -36,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 @@ -65,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);
116 changes: 15 additions & 101 deletions TauAnalysis/MCEmbeddingTools/plugins/CaloCleaner.h
Original file line number Diff line number Diff line change
@@ -1,141 +1,55 @@
/** \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

#include "FWCore/Framework/interface/stream/EDProducer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "DataFormats/Common/interface/Handle.h"
#include "DataFormats/PatCandidates/interface/Muon.h"
#include "DataFormats/MuonReco/interface/MuonEnergy.h"
#include "DataFormats/PatCandidates/interface/Muon.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/Framework/interface/stream/EDProducer.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"

#include "TrackingTools/Records/interface/TrackingComponentsRecord.h"
#include "TrackingTools/TrackAssociator/interface/TrackAssociatorParameters.h"
#include "TrackingTools/TrackAssociator/interface/TrackDetectorAssociator.h"
#include "TrackingTools/Records/interface/TrackingComponentsRecord.h"

#include "DataFormats/Common/interface/SortedCollection.h"
#include "DataFormats/EcalRecHit/interface/EcalRecHit.h"

#include <string>
#include <iostream>
#include <map>
#include <string>

template <typename T>
class CaloCleaner : public edm::stream::EDProducer<> {
public:
explicit CaloCleaner(const edm::ParameterSet&);
explicit CaloCleaner(const edm::ParameterSet &);
~CaloCleaner() override;

private:
void produce(edm::Event&, const edm::EventSetup&) override;
void produce(edm::Event &, const edm::EventSetup &) override;

typedef edm::SortedCollection<T> RecHitCollection;

const edm::EDGetTokenT<edm::View<pat::Muon> > mu_input_;
const edm::EDGetTokenT<edm::View<pat::Muon>> mu_input_;

std::map<std::string, edm::EDGetTokenT<RecHitCollection> > inputs_;
std::map<std::string, edm::EDGetTokenT<RecHitCollection>> inputs_;
edm::ESGetToken<Propagator, TrackingComponentsRecord> propagatorToken_;

TrackDetectorAssociator trackAssociator_;
TrackAssociatorParameters parameters_;

bool is_preshower_;
void fill_correction_map(TrackDetMatchInfo*, std::map<uint32_t, float>*);
void fill_correction_map(TrackDetMatchInfo *, std::map<uint32_t, float> *);
};

template <typename T>
CaloCleaner<T>::CaloCleaner(const edm::ParameterSet& iConfig)
: mu_input_(consumes<edm::View<pat::Muon> >(iConfig.getParameter<edm::InputTag>("MuonCollection"))),
propagatorToken_(esConsumes(edm::ESInputTag("", "SteppingHelixPropagatorAny"))) {
std::vector<edm::InputTag> inCollections = iConfig.getParameter<std::vector<edm::InputTag> >("oldCollection");
for (const auto& inCollection : inCollections) {
inputs_[inCollection.instance()] = consumes<RecHitCollection>(inCollection);
produces<RecHitCollection>(inCollection.instance());
}

is_preshower_ = iConfig.getUntrackedParameter<bool>("is_preshower", false);
edm::ParameterSet parameters = iConfig.getParameter<edm::ParameterSet>("TrackAssociatorParameters");
edm::ConsumesCollector iC = consumesCollector();
parameters_.loadParameters(parameters, iC);
//trackAssociator_.useDefaultPropagator();
}

template <typename T>
CaloCleaner<T>::~CaloCleaner() {
// nothing to be done yet...
}

template <typename T>
void CaloCleaner<T>::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
auto const& propagator = iSetup.getData(propagatorToken_);
trackAssociator_.setPropagator(&propagator);

edm::Handle<edm::View<pat::Muon> > muonHandle;
iEvent.getByToken(mu_input_, muonHandle);
edm::View<pat::Muon> muons = *muonHandle;

std::map<uint32_t, float> correction_map;

// 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();
else if (iMuon->standAloneMuon().isNonnull())
track = iMuon->standAloneMuon().get();
else
throw cms::Exception("FatalError")
<< "Failed to fill muon id information for a muon with undefined references to tracks";
TrackDetMatchInfo info =
trackAssociator_.associate(iEvent, iSetup, *track, parameters_, TrackDetectorAssociator::Any);
fill_correction_map(&info, &correction_map);
}

// Copy the old collection and correct if necessary
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();
++recHit) {
if (correction_map[recHit->detid().rawId()] > 0) {
float new_energy = recHit->energy() - correction_map[recHit->detid().rawId()];
if (new_energy <= 0)
continue; // Do not save empty Hits
T newRecHit(*recHit);
newRecHit.setEnergy(new_energy);
recHitCollection_output->push_back(newRecHit);
} 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();
iEvent.put(std::move(recHitCollection_output), input_.first);
}
}
#endif
#endif
Loading