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