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.3 2010/04/30 12:48: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 
93 
94  input_->readPileUp(pileup_[0],vectorEventIDs_);
95 
96  std::cout << "-> The std::vector<EventPrincipalVector> of the secondary source 'input' has been filled with "
97  << pileup_[0].size() << " element corresponding to " << maxBunch_-minBunch_+1
98  << " bunch." << std::endl;
99 
100  // Run for one source (input) and the bunch 0
101  Loop(pileup_[0][0]);
102 }
103 
104 
106  //
107  // loop over events
108  //
109  std::cout <<"-> Loop over EventPrincipalVector wich size is "<< vec.size() << "." << std::endl;
110 
111  for (EventPrincipalVector::const_iterator it = vec.begin(); it != vec.end(); ++it) {
112  std::cout <<"-> Get the event: id " << (*it)->id() << std::endl;
113 
114  getBranches(&(**it));
115  }
116 }
117 
118 
120  {
121  std::cout << "-> dataStep2_ = " << dataStep2_ << std::endl;
122  tag_ = InputTag(label_);
123 
124  std::cout << "-> Will try to get the branch with the tag : " << tag_ << std::endl;
125  std::cout << " and the EventPrincipal ep with a size = " << ep->size() << std::endl;
126 
127  if (!dataStep2_){
128  // Get the SimTrack collection
129 
130  // default version changed to transmit vertexoffset
131  boost::shared_ptr<Wrapper<std::vector<SimTrack> > const> shPtr =
132  getProductByTag<std::vector<SimTrack> >(*ep, tag_);
133 
134  if (shPtr)
135  std::cout << "-> Could get SimTrack !" << std::endl;
136  else
137  std::cout << "-> Could not get SimTrack !" << std::endl;
138 
139  }
140  else{
141  // Get the PCrossingFrame collection given as signal
142 
143  // default version changed to transmit vertexoffset
144  tag_ = InputTag("CFwriter","g4SimHits");
145  boost::shared_ptr<Wrapper<PCrossingFrame<SimTrack> > const> shPtr =
146  getProductByTag<PCrossingFrame<SimTrack> >(*ep, tag_);
147 
148  if (shPtr)
149  std::cout << "-> Could get PCrossingFrame<SimTrack> !" << std::endl;
150  else
151  std::cout << "-> Could not get PCrossingFrame<SimTrack> !" << std::endl;
152 
153  }
154 
155  }
156 
157 
158 // ------------ method called once each job just before starting event loop ------------
159 void
161 {
162 }
163 
164 // ------------ method called once each job just after ending the event loop ------------
165 void
167  if (input_) input_->endJob();
168 }
169 
170 }//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_
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 &)