test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PileupSummaryInfoSlimmer.cc
Go to the documentation of this file.
5 
7 
8 #include <iostream>
9 
11 public:
13  src_(consumes<std::vector<PileupSummaryInfo> >(conf.getParameter<edm::InputTag>("src"))),
14  keepDetailedInfoFor_(conf.getParameter<std::vector<int32_t> >("keepDetailedInfoFor")) {
15  produces<std::vector<PileupSummaryInfo> >();
16  }
17 
18  void produce(edm::StreamID, edm::Event &, edm::EventSetup const &) const override final;
19 
20 private:
21  const edm::EDGetTokenT<std::vector<PileupSummaryInfo> > src_;
22  const std::vector<int> keepDetailedInfoFor_;
23 };
24 
25 void PileupSummaryInfoSlimmer::produce(edm::StreamID,
26  edm::Event& evt,
27  const edm::EventSetup& es ) const {
29  std::auto_ptr<std::vector<PileupSummaryInfo> > output( new std::vector<PileupSummaryInfo> );
30 
31  evt.getByToken(src_,input);
32 
33  for( const auto& psu : *input ) {
34  const int bunchCrossing = psu.getBunchCrossing();
35  const int bunchSpacing = psu.getBunchSpacing();
36  const int num_PU_vertices = psu.getPU_NumInteractions();
37  const float TrueNumInteractions = psu.getTrueNumInteractions();
38 
39  std::vector<float> zpositions;
40  std::vector<float> sumpT_lowpT;
41  std::vector<float> sumpT_highpT;
42  std::vector<int> ntrks_lowpT;
43  std::vector<int> ntrks_highpT;
44  std::vector<edm::EventID> eventInfo;
45  std::vector<float> pT_hats;
46 
47  const bool keep_details = std::find(keepDetailedInfoFor_.begin(),
48  keepDetailedInfoFor_.end(),
49  bunchCrossing) != keepDetailedInfoFor_.end();
50 
51  if( keep_details ) {
52  zpositions = psu.getPU_zpositions();
53  sumpT_lowpT = psu.getPU_sumpT_lowpT();
54  sumpT_highpT = psu.getPU_sumpT_highpT();
55  ntrks_lowpT = psu.getPU_ntrks_lowpT();
56  ntrks_highpT = psu.getPU_ntrks_highpT();
57  eventInfo = psu.getPU_EventID();
58  pT_hats = psu.getPU_pT_hats();
59  }
60  // insert the slimmed vertex info
61  output->emplace_back(num_PU_vertices,
62  zpositions,
63  sumpT_lowpT, sumpT_highpT,
64  ntrks_lowpT, ntrks_highpT,
65  eventInfo,
66  pT_hats,
67  bunchCrossing,
68  TrueNumInteractions,
69  bunchSpacing);
70  }
71 
72  evt.put(output);
73 }
74 
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
static std::string const input
Definition: EdmProvDump.cc:44
Definition: Event.h:16
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
void produce(edm::StreamID, edm::Event &, edm::EventSetup const &) const overridefinal
PileupSummaryInfoSlimmer(const edm::ParameterSet &conf)
const std::vector< int > keepDetailedInfoFor_
const edm::EDGetTokenT< std::vector< PileupSummaryInfo > > src_
string const
Definition: compareJSON.py:14