CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
20 // system include files
21 #include <memory>
22 #include <boost/bind.hpp>
23 
24 // user include files
27 
31 
35 
41 
43 
45 
46 #include "SecSourceAnalyzer.h"
47 
48 #include "TH1F.h"
49 
50 //
51 // constructors and destructor
52 //
53 namespace edm
54 {
56  :minBunch_(0),
57  maxBunch_(0),
58  tag_(InputTag())
59 {
60 // int minb = minBunch_;
61 // int maxb = maxBunch_;
62  int averageNumber = 1;
64  TH1F * histoName = new TH1F("h","",10,0,10);
65  bool playback = false;
66 
67  input_.reset(new edm::PileUp(iConfig.getParameter<edm::ParameterSet>("input"),
68  averageNumber,histoName,playback));
69 
70  dataStep2_ = iConfig.getParameter<bool>("dataStep2");
71 
72 
73  if (dataStep2_)
74  // The data file contain the PCrossingFrame<SimTrack>
75  label_ = iConfig.getParameter<edm::InputTag>("collPCF");
76  else
77  // The data file contain the SimTrack
78  label_ = iConfig.getParameter<edm::InputTag>("collSimTrack");
79 
80 }
81 
82 
84 {
85 }
86 
87 
88 //
89 // member functions
90 //
91 
92 // ------------ method called for each event ------------
93 void
95 {
97 
98  int nevt = 0 ;
99  for( int ibx = minBunch_ ; ibx <= maxBunch_ ; ++ibx )
100  {
101  if( ibx == 0 )
102  {
103  input_->readPileUp( iEvent.id(),
104  vectorEventIDs_[ ibx-minBunch_ ],
105  boost::bind(&SecSourceAnalyzer::getBranches,
106  this, _1, iEvent.moduleCallingContext()), ibx
107  );
108  }
109  else
110  {
111  input_->readPileUp( iEvent.id(),
112  vectorEventIDs_[ ibx-minBunch_ ],
113  boost::bind(&SecSourceAnalyzer::dummyFunction,
114  this, _1), ibx
115  );
116  }
117 
118  nevt += vectorEventIDs_[ ibx-minBunch_ ].size() ;
119  }
120 
121  std::cout << "-> The std::vector<EventPrincipalVector> of the secondary source 'input' has been filled with "
122  << nevt << " element corresponding to " << maxBunch_-minBunch_+1
123  << " bunch." << std::endl;
124 }
125 
127  ModuleCallingContext const* mcc)
128  {
129  InternalContext internalContext(ep.id(), mcc);
130  ParentContext parentContext(&internalContext);
131  ModuleCallingContext moduleCallingContext(&moduleDescription());
132  ModuleContextSentry moduleContextSentry(&moduleCallingContext, parentContext);
133 
134  std::cout <<"-> Get the event: id " << ep.id() << std::endl;
135  std::cout << "-> dataStep2_ = " << dataStep2_ << std::endl;
136  tag_ = InputTag(label_);
137 
138  std::cout << "-> Will try to get the branch with the tag : " << tag_ << std::endl;
139  std::cout << " and the EventPrincipal ep with a size = " << ep.size() << std::endl;
140 
141  if (!dataStep2_){
142  // Get the SimTrack collection
143 
144  // default version changed to transmit vertexoffset
145  boost::shared_ptr<Wrapper<std::vector<SimTrack> > const> shPtr =
146  getProductByTag<std::vector<SimTrack> >(ep, tag_, &moduleCallingContext);
147 
148  if (shPtr)
149  std::cout << "-> Could get SimTrack !" << std::endl;
150  else
151  std::cout << "-> Could not get SimTrack !" << std::endl;
152 
153  }
154  else{
155  // Get the PCrossingFrame collection given as signal
156 
157  // default version changed to transmit vertexoffset
158  tag_ = InputTag("CFwriter","g4SimHits");
159  boost::shared_ptr<Wrapper<PCrossingFrame<SimTrack> > const> shPtr =
160  getProductByTag<PCrossingFrame<SimTrack> >(ep, tag_, &moduleCallingContext);
161 
162  if (shPtr)
163  std::cout << "-> Could get PCrossingFrame<SimTrack> !" << std::endl;
164  else
165  std::cout << "-> Could not get PCrossingFrame<SimTrack> !" << std::endl;
166 
167  }
168 
169  }
170 
171 
172 // ------------ method called once each job just before starting event loop ------------
173 void
175 {
176 }
177 
178 // ------------ method called once each job just after ending the event loop ------------
179 void
181  if (input_) input_->endJob();
182 }
183 
184 }//edm
virtual void analyze(const edm::Event &, const edm::EventSetup &) override
T getParameter(std::string const &) const
size_t size() const
Definition: Principal.cc:238
std::vector< std::vector< edm::EventID > > vectorEventIDs_
virtual void dummyFunction(EventPrincipal const &ep)
tuple histoFileName
Definition: diJetCalib.py:108
EventID const & id() const
ModuleDescription const & moduleDescription() const
Definition: EDAnalyzer.h:38
int iEvent
Definition: GenABIO.cc:243
ModuleCallingContext const * moduleCallingContext() const
Definition: Event.h:212
tuple averageNumber
set the number of pileup
SecSourceAnalyzer(const edm::ParameterSet &)
boost::shared_ptr< PileUp > input_
edm::EventID id() const
Definition: EventBase.h:56
tuple playback
Definition: Playback_cff.py:20
virtual void getBranches(EventPrincipal const &ep, ModuleCallingContext const *)
tuple cout
Definition: gather_cfg.py:121