CMS 3D CMS Logo

SecSourceAnalyzer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: SecSourceAnalyzer
4 // Class: SecSourceAnalyzer
5 //
13 //
14 // Original Author: Emilia Lubenova Becheva
15 // Created: Wed Apr 22 16:54:31 CEST 2009
16 //
17 //
18 
19 // system include files
20 #include <memory>
21 #include <functional>
22 
23 // user include files
26 
30 
34 
40 
42 
44 
45 #include "SecSourceAnalyzer.h"
46 
47 #include "TH1F.h"
48 
49 //
50 // constructors and destructor
51 //
52 namespace edm {
54  : minBunch_(0), maxBunch_(0), tag_(InputTag()) {
55  // int minb = minBunch_;
56  // int maxb = maxBunch_;
57  int averageNumber = 1;
59  std::unique_ptr<TH1F> histoName(new TH1F("h", "", 10, 0, 10));
60  bool playback = false;
61 
62  auto conf = std::make_shared<PileUpConfig>("input", averageNumber, histoName, playback);
63  input_.reset(new edm::PileUp(iConfig.getParameter<edm::ParameterSet>("input"), conf));
64 
65  dataStep2_ = iConfig.getParameter<bool>("dataStep2");
66 
67  if (dataStep2_)
68  // The data file contain the PCrossingFrame<SimTrack>
69  label_ = iConfig.getParameter<edm::InputTag>("collPCF");
70  else
71  // The data file contain the SimTrack
72  label_ = iConfig.getParameter<edm::InputTag>("collSimTrack");
73  }
74 
76 
77  //
78  // member functions
79  //
80 
81  // ------------ method called for each event ------------
83  using namespace std::placeholders;
84  vectorEventIDs_.resize(maxBunch_ - minBunch_ + 1);
85 
86  int nevt = 0;
87  for (int ibx = minBunch_; ibx <= maxBunch_; ++ibx) {
88  if (ibx == 0) {
89  input_->readPileUp(iEvent.id(),
91  std::bind(&SecSourceAnalyzer::getBranches, this, _1, iEvent.moduleCallingContext()),
92  ibx,
93  iEvent.streamID());
94  } else {
95  input_->readPileUp(iEvent.id(),
97  std::bind(&SecSourceAnalyzer::dummyFunction, this, _1),
98  ibx,
99  iEvent.streamID());
100  }
101 
102  nevt += vectorEventIDs_[ibx - minBunch_].size();
103  }
104 
105  std::cout << "-> The std::vector<EventPrincipalVector> of the secondary source 'input' has been filled with "
106  << nevt << " element corresponding to " << maxBunch_ - minBunch_ + 1 << " bunch." << std::endl;
107  }
108 
110  InternalContext internalContext(ep.id(), mcc);
111  ParentContext parentContext(&internalContext);
112  ModuleCallingContext moduleCallingContext(&moduleDescription());
113  ModuleContextSentry moduleContextSentry(&moduleCallingContext, parentContext);
114 
115  std::cout << "-> Get the event: id " << ep.id() << std::endl;
116  std::cout << "-> dataStep2_ = " << dataStep2_ << std::endl;
117  tag_ = InputTag(label_);
118 
119  std::cout << "-> Will try to get the branch with the tag : " << tag_ << std::endl;
120  std::cout << " and the EventPrincipal ep with a size = " << ep.size() << std::endl;
121 
122  if (!dataStep2_) {
123  // Get the SimTrack collection
124 
125  // default version changed to transmit vertexoffset
126  std::shared_ptr<Wrapper<std::vector<SimTrack> > const> shPtr =
127  getProductByTag<std::vector<SimTrack> >(ep, tag_, &moduleCallingContext);
128 
129  if (shPtr)
130  std::cout << "-> Could get SimTrack !" << std::endl;
131  else
132  std::cout << "-> Could not get SimTrack !" << std::endl;
133 
134  } else {
135  // Get the PCrossingFrame collection given as signal
136 
137  // default version changed to transmit vertexoffset
138  tag_ = InputTag("CFwriter", "g4SimHits");
139  std::shared_ptr<Wrapper<PCrossingFrame<SimTrack> > const> shPtr =
140  getProductByTag<PCrossingFrame<SimTrack> >(ep, tag_, &moduleCallingContext);
141 
142  if (shPtr)
143  std::cout << "-> Could get PCrossingFrame<SimTrack> !" << std::endl;
144  else
145  std::cout << "-> Could not get PCrossingFrame<SimTrack> !" << std::endl;
146  }
147 
148  return true;
149  }
150 
151  // ------------ method called once each job just before starting event loop ------------
153 
154  // ------------ method called once each job just after ending the event loop ------------
156  if (input_)
157  input_->endStream();
158  }
159 
160 } // namespace edm
boostrapWithFamos_cff.averageNumber
averageNumber
Definition: boostrapWithFamos_cff.py:15
ModuleCallingContext.h
edm::ModuleContextSentry
Definition: ModuleContextSentry.h:11
edm::one::EDAnalyzerBase::moduleDescription
ModuleDescription const & moduleDescription() const
Definition: EDAnalyzerBase.h:63
edm
HLT enums.
Definition: AlignableModifier.h:19
gather_cfg.cout
cout
Definition: gather_cfg.py:144
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
edm::SecSourceAnalyzer::minBunch_
int minBunch_
Definition: SecSourceAnalyzer.h:54
edm::SecSourceAnalyzer::dataStep2_
bool dataStep2_
Definition: SecSourceAnalyzer.h:57
EDAnalyzer.h
edm::PileUp
Definition: PileUp.h:40
edm::SecSourceAnalyzer::maxBunch_
int maxBunch_
Definition: SecSourceAnalyzer.h:55
edm::SecSourceAnalyzer::vectorEventIDs_
std::vector< std::vector< edm::SecondaryEventIDAndFileInfo > > vectorEventIDs_
Definition: SecSourceAnalyzer.h:60
MakerMacros.h
mix_2012_lumiLevel_15_20_50ns_PoissonOOTPU_cfi.histoFileName
histoFileName
Definition: mix_2012_lumiLevel_15_20_50ns_PoissonOOTPU_cfi.py:52
edm::EventPrincipal
Definition: EventPrincipal.h:48
personalPlayback.playback
playback
Definition: personalPlayback.py:503
edm::SecSourceAnalyzer::label_
edm::InputTag label_
Definition: SecSourceAnalyzer.h:58
edm::SecSourceAnalyzer::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: SecSourceAnalyzer.cc:82
edm::SecSourceAnalyzer::dummyFunction
bool dummyFunction(EventPrincipal const &ep)
Definition: SecSourceAnalyzer.h:46
edm::SecSourceAnalyzer::getBranches
bool getBranches(EventPrincipal const &ep, ModuleCallingContext const *)
Definition: SecSourceAnalyzer.cc:109
edm::InternalContext
Definition: InternalContext.h:23
InputSourceDescription.h
edm::ParentContext
Definition: ParentContext.h:27
VectorInputSourceFactory.h
edm::SecSourceAnalyzer::beginJob
void beginJob() override
Definition: SecSourceAnalyzer.cc:152
edm::SecSourceAnalyzer::input_
std::shared_ptr< PileUp > input_
Definition: SecSourceAnalyzer.h:62
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
edm::SecSourceAnalyzer::tag_
InputTag tag_
Definition: SecSourceAnalyzer.h:65
PCrossingFrame.h
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::SecSourceAnalyzer::endJob
void endJob() override
Definition: SecSourceAnalyzer.cc:155
InternalContext.h
edm::EventSetup
Definition: EventSetup.h:58
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
nevt
int nevt
Definition: ReggeGribovPartonMCHadronizer.h:66
ParentContext.h
Frameworkfwd.h
SecSourceAnalyzer.h
HltBtagPostValidation_cff.histoName
histoName
Definition: HltBtagPostValidation_cff.py:17
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::SecSourceAnalyzer::SecSourceAnalyzer
SecSourceAnalyzer(const edm::ParameterSet &)
Definition: SecSourceAnalyzer.cc:53
ParameterSet.h
PileUp.h
edm::Event
Definition: Event.h:73
VectorInputSource.h
ModuleContextSentry.h
SimTrackContainer.h
SiStripBadComponentsDQMServiceTemplate_cfg.ep
ep
Definition: SiStripBadComponentsDQMServiceTemplate_cfg.py:86
edm::SecSourceAnalyzer::~SecSourceAnalyzer
~SecSourceAnalyzer() override
Definition: SecSourceAnalyzer.cc:75
edm::InputTag
Definition: InputTag.h:15
edm::ModuleCallingContext
Definition: ModuleCallingContext.h:29