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

Saving generator protons from pile-up for standard mixing and premixing #20172

Merged
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
5 changes: 3 additions & 2 deletions Configuration/StandardSequences/python/Digi_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@
# add updating the GEN information by default
from Configuration.StandardSequences.Generator_cff import *
from GeneratorInterface.Core.generatorSmeared_cfi import *
from SimGeneral.PileupInformation.genPUProtons_cfi import *

doAllDigi = cms.Sequence(generatorSmeared*calDigi+muonDigi)
pdigi = cms.Sequence(generatorSmeared*fixGenInfo*cms.SequencePlaceholder("randomEngineStateProducer")*cms.SequencePlaceholder("mix")*doAllDigi*addPileupInfo)
pdigi = cms.Sequence(generatorSmeared*fixGenInfo*cms.SequencePlaceholder("randomEngineStateProducer")*cms.SequencePlaceholder("mix")*doAllDigi*addPileupInfo*genPUProtons)
pdigi_valid = cms.Sequence(pdigi)
pdigi_nogen=cms.Sequence(generatorSmeared*cms.SequencePlaceholder("randomEngineStateProducer")*cms.SequencePlaceholder("mix")*doAllDigi*addPileupInfo)
pdigi_nogen=cms.Sequence(generatorSmeared*cms.SequencePlaceholder("randomEngineStateProducer")*cms.SequencePlaceholder("mix")*doAllDigi*addPileupInfo*genPUProtons)
pdigi_valid_nogen=cms.Sequence(pdigi_nogen)

from GeneratorInterface.HiGenCommon.HeavyIon_cff import *
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
'keep GenLumiInfoHeader_generator_*_*',
'keep GenLumiInfoProduct_*_*_*',
'keep GenEventInfoProduct_generator_*_*',
'keep recoGenParticles_genPUProtons_*_*',
'keep *_slimmedGenJetsFlavourInfos_*_*',
'keep *_slimmedGenJets__*',
'keep *_slimmedGenJetsAK8__*',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,20 @@
outputCommands = cms.untracked.vstring('keep CrossingFramePlaybackInfoNew_*_*_*',
'keep PileupSummaryInfos_*_*_*',
'keep int6stdbitsetstdpairs_*_AffectedAPVList_*',
'keep int_*_bunchSpacing_*')
'keep int_*_bunchSpacing_*',
'keep *_genPUProtons_*_*')
)
#RECO content
SimGeneralRECO = cms.PSet(
outputCommands = cms.untracked.vstring('keep PileupSummaryInfos_*_*_*',
'keep int_*_bunchSpacing_*')
'keep int_*_bunchSpacing_*',
'keep *_genPUProtons_*_*')
)
#AOD content
SimGeneralAOD = cms.PSet(
outputCommands = cms.untracked.vstring('keep PileupSummaryInfos_*_*_*',
'keep int_*_bunchSpacing_*')
'keep int_*_bunchSpacing_*',
'keep *_genPUProtons_*_*')
)

# mods for HGCAL
Expand Down
1 change: 1 addition & 0 deletions SimGeneral/DataMixingModule/plugins/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<use name="DataFormats/SiPixelDigi"/>
<use name="DataFormats/SiStripDigi"/>
<use name="DataFormats/TrackReco"/>
<use name="DataFormats/HepMCCandidate"/>
<use name="FWCore/Framework"/>
<use name="FWCore/MessageLogger"/>
<use name="FWCore/ParameterSet"/>
Expand Down
7 changes: 7 additions & 0 deletions SimGeneral/DataMixingModule/plugins/DataMixingModule.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
//
//
#include "SimDataFormats/CrossingFrame/interface/CrossingFramePlaybackInfoNew.h"
#include "DataFormats/HepMCCandidate/interface/GenParticle.h"
#include "DataMixingModule.h"
#include "SimGeneral/MixingModule/interface/PileUpEventPrincipal.h"

Expand Down Expand Up @@ -235,6 +236,12 @@ namespace edm
produces< int >("bunchSpacing");
produces<CrossingFramePlaybackInfoNew>();

std::vector<edm::InputTag> GenPUProtonsInputTags;
GenPUProtonsInputTags = ps.getParameter<std::vector<edm::InputTag> >("GenPUProtonsInputTags");
for(std::vector<edm::InputTag>::const_iterator it_InputTag = GenPUProtonsInputTags.begin();
it_InputTag != GenPUProtonsInputTags.end(); ++it_InputTag)
produces< std::vector<reco::GenParticle> >( it_InputTag->label() );

PUWorker_ = new DataMixingPileupCopy(ps, consumesCollector());
}

Expand Down
26 changes: 26 additions & 0 deletions SimGeneral/DataMixingModule/plugins/DataMixingPileupCopy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#include "DataFormats/Common/interface/Handle.h"
#include "DataFormats/Provenance/interface/Provenance.h"
#include "DataFormats/Provenance/interface/BranchDescription.h"

#include "DataFormats/HepMCCandidate/interface/GenParticle.h"
//
//
#include "DataMixingPileupCopy.h"
Expand All @@ -38,6 +40,7 @@ namespace edm
BunchSpacingInputTag_ = ps.getParameter<edm::InputTag>("BunchSpacingInputTag");
CFPlaybackInputTag_ = ps.getParameter<edm::InputTag>("CFPlaybackInputTag");

GenPUProtonsInputTags_ = ps.getParameter<std::vector<edm::InputTag> >("GenPUProtonsInputTags");

// apparently, we don't need consumes from Secondary input stream
//iC.consumes<std::vector<PileupSummaryInfo>>(PileupInfoInputTag_);
Expand Down Expand Up @@ -77,6 +80,17 @@ namespace edm
bsStorage_=10000;
}

// Gen. PU protons
std::shared_ptr<edm::Wrapper<std::vector<reco::GenParticle> > const> GenPUProtonsPTR;
for(std::vector<edm::InputTag>::const_iterator it_InputTag = GenPUProtonsInputTags_.begin();
it_InputTag != GenPUProtonsInputTags_.end(); ++it_InputTag){
GenPUProtonsPTR = getProductByTag<std::vector<reco::GenParticle> >( *ep, *it_InputTag , mcc);
if( GenPUProtonsPTR != nullptr ){
GenPUProtons_.push_back( *( GenPUProtonsPTR->product() ) );
GenPUProtons_labels_.push_back( it_InputTag->label() );
} else edm::LogWarning("DataMixingPileupCopy") << "Missing product with label: " << ( *it_InputTag ).label();
}

// Playback
std::shared_ptr<Wrapper<CrossingFramePlaybackInfoNew> const> PlaybackPTR =
getProductByTag<CrossingFramePlaybackInfoNew>(*ep,CFPlaybackInputTag_, mcc);
Expand Down Expand Up @@ -105,7 +119,19 @@ namespace edm
e.put(std::move(PSIVector));
e.put(std::move(bsInt),"bunchSpacing");

// Gen. PU protons
for(size_t idx = 0; idx < GenPUProtons_.size(); ++idx){
std::unique_ptr<std::vector<reco::GenParticle> > GenPUProtons_ptr( new std::vector<reco::GenParticle>() );
std::vector<reco::GenParticle>::const_iterator it_GenParticle = GenPUProtons_.at(idx).begin();
std::vector<reco::GenParticle>::const_iterator it_GenParticle_end = GenPUProtons_.at(idx).end();
for(; it_GenParticle != it_GenParticle_end; ++ it_GenParticle) GenPUProtons_ptr->push_back( *it_GenParticle );

e.put( std::move(GenPUProtons_ptr), GenPUProtons_labels_.at(idx) );
}

// clear local storage after this event
PileupSummaryStorage_.clear();
GenPUProtons_.clear();
GenPUProtons_labels_.clear();
}
} //edm
7 changes: 7 additions & 0 deletions SimGeneral/DataMixingModule/plugins/DataMixingPileupCopy.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
#include <vector>
#include <string>

namespace reco{
class GenParticle;
}

namespace edm
{
Expand Down Expand Up @@ -61,12 +64,16 @@ namespace edm
edm::InputTag BunchSpacingInputTag_ ; // InputTag for bunch spacing int
edm::InputTag CFPlaybackInputTag_ ; // InputTag for CrossingFrame Playback information

std::vector<edm::InputTag> GenPUProtonsInputTags_ ;

CrossingFramePlaybackInfoNew CrossingFramePlaybackStorage_;

std::vector<PileupSummaryInfo> PileupSummaryStorage_;
int bsStorage_;

std::vector<std::string> GenPUProtons_labels_;
std::vector<std::vector<reco::GenParticle> > GenPUProtons_;

// unsigned int eventId_; //=0 for signal, from 1-n for pileup events

std::string label_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
PileupInfoInputTag = cms.InputTag("addPileupInfo"),
BunchSpacingInputTag = cms.InputTag("addPileupInfo","bunchSpacing"),
CFPlaybackInputTag = cms.InputTag("mix"),
GenPUProtonsInputTags = cms.VInputTag("genPUProtons"),
#
SistripLabelSig = cms.InputTag("simSiStripDigis","ZeroSuppressed"),
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
PileupInfoInputTag = cms.InputTag("addPileupInfo"),
BunchSpacingInputTag = cms.InputTag("addPileupInfo","bunchSpacing"),
CFPlaybackInputTag = cms.InputTag("mix"),
GenPUProtonsInputTags = cms.VInputTag("genPUProtons"),
#
SistripLabelSig = cms.InputTag("simSiStripDigis","ZeroSuppressed"),
#
Expand Down
6 changes: 6 additions & 0 deletions SimGeneral/MixingModule/python/aliases_PreMix_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@
# )
#)

genPUProtons = cms.EDAlias(
mixData = cms.VPSet(
cms.PSet( type = cms.string('recoGenParticles') )
)
)

# no castor,pixel,strip digis in fastsim
from Configuration.Eras.Modifier_fastSim_cff import fastSim
fastSim.toModify(simCastorDigis, mix = None)
Expand Down
2 changes: 1 addition & 1 deletion SimGeneral/MixingModule/python/mixObjects_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
mixSimVertices.input = cms.VInputTag(cms.InputTag("famosSimHits"))

mixHepMCProducts = cms.PSet(
makeCrossingFrame = cms.untracked.bool(False),
makeCrossingFrame = cms.untracked.bool(True),
input = cms.VInputTag(cms.InputTag("generatorSmeared"),cms.InputTag("generator")),
type = cms.string('HepMCProduct')
)
Copy link
Contributor

Choose a reason for hiding this comment

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

One question: are we sure that the only thing that gets written to the CrossingFrame is the protons you want to save? Or, do a whole pile of HepMCProducts end up there?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this implementation the MixingModule is creating a CrossingFrame on the fly with all pileup HepMC events. We then select only the particles of interest (the protons) to save to disk. With the premixing workflow this will be run only once to generate the pileup sample. The proton collection will then be copied over from the random pileup event to the main event with the data mixing module.

Expand Down
1 change: 1 addition & 0 deletions SimGeneral/PileupInformation/plugins/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<use name="SimDataFormats/Vertex"/>
<use name="SimTracker/Common"/>
<use name="SimGeneral/MixingModule"/>
<use name="SimGeneral/HepPDTRecord"/>
<use name="clhep"/>
<library file="*.cc" name="SimGeneralPileupInformationPlugins">
<flags EDM_PLUGIN="1"/>
Expand Down
Loading