CMS 3D CMS Logo

RemovePileUpDominatedEventsGen.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: RemovePileUpDominatedEventsGen/RemovePileUpDominatedEventsGen
4 // Class: RemovePileUpDominatedEventsGen
5 //
18 //
19 // Original Author: Silvio DONATO
20 // Created: Fri, 12 Dec 2014 12:48:57 GMT
21 //
22 //
23 
24 #include <memory>
25 
30 #include <iostream>
33 
35 public:
38  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
39 
40 private:
41  bool filter(edm::Event&, const edm::EventSetup&) override;
42 
45  unsigned int bunchCrossing;
46 };
47 
49  : pileupSummaryInfos_(
50  consumes<std::vector<PileupSummaryInfo> >(iConfig.getParameter<edm::InputTag>("pileupSummaryInfos"))),
51  generatorInfo_(consumes<GenEventInfoProduct>(iConfig.getParameter<edm::InputTag>("generatorInfo"))) {
52  bunchCrossing = 0;
53  produces<float>();
54 }
55 
57 
59  using namespace edm;
60  using namespace std;
61 
63  iEvent.getByToken(generatorInfo_, generatorInfo);
64 
65  edm::Handle<std::vector<PileupSummaryInfo> > pileupSummaryInfos;
66  iEvent.getByToken(pileupSummaryInfos_, pileupSummaryInfos);
67 
68  //find in-time pile-up
69  if (bunchCrossing >= pileupSummaryInfos.product()->size() ||
70  pileupSummaryInfos.product()->at(bunchCrossing).getBunchCrossing() != 0) {
71  bool found = false;
72  for (bunchCrossing = 0; bunchCrossing < pileupSummaryInfos.product()->size() && !found; ++bunchCrossing) {
73  if (pileupSummaryInfos.product()->at(bunchCrossing).getBunchCrossing() == 0) {
74  found = true;
75  bunchCrossing--;
76  }
77  }
78  if (!found) {
79  edm::LogInfo("RemovePileUpDominatedEventsGen") << "In-time pile-up not found!" << endl;
80  return true;
81  }
82  }
83 
84  // cout << "Using "<<bunchCrossing<<endl;
85  // cout << "pileupSummaryInfos.product()->at(bunchCrossing).getBunchCrossing() "<<pileupSummaryInfos.product()->at(bunchCrossing).getBunchCrossing()<<endl;
86 
87  //get the PU pt-hat max
88  float signal_pT_hat = -1;
89  float pu_pT_hat_max = -1;
90 
91  PileupSummaryInfo puSummary_onTime = pileupSummaryInfos.product()->at(bunchCrossing);
92  for (const auto& pu_pT_hat : puSummary_onTime.getPU_pT_hats())
93  if (pu_pT_hat > pu_pT_hat_max)
94  pu_pT_hat_max = pu_pT_hat;
95 
96  //get the signal pt-hat
97  signal_pT_hat = generatorInfo->qScale();
98 
99  //save PU - signal pt-hat
100  std::unique_ptr<float> pOut(new float());
101  *pOut = signal_pT_hat - pu_pT_hat_max;
102  iEvent.put(std::move(pOut));
103 
104  //filter the event
105  if (signal_pT_hat > pu_pT_hat_max)
106  return true;
107  return false;
108 }
109 
112  desc.add<edm::InputTag>("pileupSummaryInfos", edm::InputTag("addPileupInfo"));
113  desc.add<edm::InputTag>("generatorInfo", edm::InputTag("generator"));
114  descriptions.addDefault(desc);
115 }
116 
RemovePileUpDominatedEventsGen::bunchCrossing
unsigned int bunchCrossing
Definition: RemovePileUpDominatedEventsGen.cc:45
GenEventInfoProduct
Definition: GenEventInfoProduct.h:17
PileupSummaryInfo.h
edm::Handle::product
T const * product() const
Definition: Handle.h:70
GenEventInfoProduct::qScale
double qScale() const
Definition: GenEventInfoProduct.h:41
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
RemovePileUpDominatedEventsGen::generatorInfo_
const edm::EDGetTokenT< GenEventInfoProduct > generatorInfo_
Definition: RemovePileUpDominatedEventsGen.cc:44
PileupSummaryInfo::getPU_pT_hats
const std::vector< float > & getPU_pT_hats() const
Definition: PileupSummaryInfo.h:72
L1TrackObjectNtupleMaker_cfg.pOut
pOut
Definition: L1TrackObjectNtupleMaker_cfg.py:172
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
newFWLiteAna.found
found
Definition: newFWLiteAna.py:118
edm::Handle
Definition: AssociativeIterator.h:50
RemovePileUpDominatedEventsGen::filter
bool filter(edm::Event &, const edm::EventSetup &) override
Definition: RemovePileUpDominatedEventsGen.cc:58
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
RemovePileUpDominatedEventsGen::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: RemovePileUpDominatedEventsGen.cc:110
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
edm::ParameterSet
Definition: ParameterSet.h:47
GenEventInfoProduct.h
Event.h
iEvent
int iEvent
Definition: GenABIO.cc:224
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
edm::EventSetup
Definition: EventSetup.h:58
RemovePileUpDominatedEventsGen::~RemovePileUpDominatedEventsGen
~RemovePileUpDominatedEventsGen() override
RemovePileUpDominatedEventsGen::pileupSummaryInfos_
const edm::EDGetTokenT< std::vector< PileupSummaryInfo > > pileupSummaryInfos_
Definition: RemovePileUpDominatedEventsGen.cc:43
RemovePileUpDominatedEventsGen::RemovePileUpDominatedEventsGen
RemovePileUpDominatedEventsGen(const edm::ParameterSet &)
Definition: RemovePileUpDominatedEventsGen.cc:48
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
Frameworkfwd.h
EDFilter.h
RemovePileUpDominatedEventsGen
Definition: RemovePileUpDominatedEventsGen.cc:34
edm::stream::EDFilter
Definition: EDFilter.h:36
edm::Event
Definition: Event.h:73
edm::ConfigurationDescriptions::addDefault
void addDefault(ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:99
edm::InputTag
Definition: InputTag.h:15
PileupSummaryInfo
Definition: PileupSummaryInfo.h:22