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