CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HiEvtPlaneFlatProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: HiEvtPlaneFlatProducer
4 // Class: HiEvtPlaneFlatProducer
5 //
14 //
15 // Original Author: Stephen Sanders
16 // Created: Sat Jun 26 16:04:04 EDT 2010
17 // $Id: HiEvtPlaneFlatProducer.cc,v 1.14 2012/02/15 11:04:09 eulisse Exp $
18 //
19 //
20 
21 
22 // system include files
23 #include <memory>
24 
25 // user include files
28 
31 
33 #include "Math/Vector3D.h"
34 
38 
41 
58 
65 
67 #include "TList.h"
68 #include "TString.h"
69 #include <time.h>
70 #include <cstdlib>
71 
73 
74 using namespace std;
75 using namespace hi;
76 
77 #include <vector>
78 using std::vector;
79 
80 
81 //
82 // class declaration
83 //
84 
86  public:
89 
90  private:
91  virtual void beginJob() ;
92  virtual void produce(edm::Event&, const edm::EventSetup&);
93  virtual void endJob() ;
94 
95  // ----------member data ---------------------------
96 
100 
101  int vs_sell; // vertex collection size
102  float vzr_sell;
103  float vzErr_sell;
104 
105  Double_t epang[NumEPNames];
108  int nRP;
110 
111 };
112 
113 //
114 // constants, enums and typedefs
115 //
116 typedef std::vector<TrackingParticle> TrackingParticleCollection;
118 
119 
120 //
121 // static data member definitions
122 //
123 
124 //
125 // constructors and destructor
126 //
128 {
129 
130  vtxCollection_ = iConfig.getParameter<edm::InputTag>("vtxCollection_");
131  inputPlanes_ = iConfig.getParameter<edm::InputTag>("inputPlanes_");
132  centrality_ = iConfig.getParameter<edm::InputTag>("centrality_");
133  storeNames_ = 1;
134  //register your products
135  produces<reco::EvtPlaneCollection>();
136  //now do what ever other initialization is needed
137  Int_t FlatOrder = 21;
138  for(int i = 0; i<NumEPNames; i++) {
139  flat[i] = new HiEvtPlaneFlatten();
140  flat[i]->Init(FlatOrder,11,4,EPNames[i],EPOrder[i]);
141  }
142 
143 }
144 
145 
147 {
148 
149  // do anything here that needs to be done at desctruction time
150  // (e.g. close files, deallocate resources etc.)
151 
152 }
153 
154 
155 //
156 // member functions
157 //
158 
159 // ------------ method called to produce the data ------------
160 void
162 {
163  using namespace edm;
164  using namespace std;
165  using namespace reco;
166 
167  //
168  //Get Centrality
169  //
170 
171  edm::Handle<int> ch;
172  iEvent.getByLabel(centrality_,ch);
173  int bin = *(ch.product());
174 
175  // double centval = 2.5*bin+1.25;
176  //
177  //Get Vertex
178  //
179  edm::Handle<reco::VertexCollection> vertexCollection3;
180  iEvent.getByLabel(vtxCollection_,vertexCollection3);
181  const reco::VertexCollection * vertices3 = vertexCollection3.product();
182  vs_sell = vertices3->size();
183  if(vs_sell>0) {
184  vzr_sell = vertices3->begin()->z();
185  vzErr_sell = vertices3->begin()->zError();
186  } else
187  vzr_sell = -999.9;
188  //
189  //Get Flattening Parameters
190  //
191  edm::ESHandle<RPFlatParams> flatparmsDB_;
192  iSetup.get<HeavyIonRPRcd>().get(flatparmsDB_);
193  int flatTableSize = flatparmsDB_->m_table.size();
194  for(int i = 0; i<flatTableSize; i++) {
195  const RPFlatParams::EP* thisBin = &(flatparmsDB_->m_table[i]);
196  for(int j = 0; j<NumEPNames; j++) {
197  int indx = thisBin->RPNameIndx[j];
198  if(indx>=0) {
199  flat[indx]->SetXDB(i, thisBin->x[j]);
200  flat[indx]->SetYDB(i, thisBin->y[j]);
201  }
202  }
203  }
204 
205  //
206  //Get Event Planes
207  //
208 
210  iEvent.getByLabel(inputPlanes_,evtPlanes);
211 
212  if(!evtPlanes.isValid()){
213  // cout << "Error! Can't get hiEvtPlane product!" << endl;
214  return ;
215  }
216 
217  std::auto_ptr<EvtPlaneCollection> evtplaneOutput(new EvtPlaneCollection);
218  EvtPlane * ep[NumEPNames];
219  for(int i = 0; i<NumEPNames; i++) {
220  ep[i]=0;
221  }
222  for (EvtPlaneCollection::const_iterator rp = evtPlanes->begin();rp !=evtPlanes->end(); rp++) {
223  if(rp->angle() > -5) {
224  string baseName = rp->label();
225  for(int i = 0; i< NumEPNames; i++) {
226  if(EPNames[i].compare(baseName)==0) {
227  double psiFlat = flat[i]->GetFlatPsi(rp->angle(),vzr_sell,bin);
228  epang[i]=psiFlat;
229  if(EPNames[i].compare(rp->label())==0) {
230  if(storeNames_) ep[i]= new EvtPlane(psiFlat, rp->sumSin(), rp->sumCos(),rp->label().data());
231  else ep[i]= new EvtPlane(psiFlat, rp->sumSin(), rp->sumCos(),"");
232  }
233  }
234  }
235  }
236  }
237 
238  for(int i = 0; i< NumEPNames; i++) {
239  if(ep[i]!=0) evtplaneOutput->push_back(*ep[i]);
240  }
241  iEvent.put(evtplaneOutput);
242  storeNames_ = 0;
243 }
244 
245 // ------------ method called once each job just before starting event loop ------------
246 void
248 {
249 }
250 
251 // ------------ method called once each job just after ending the event loop ------------
252 void
254 }
255 
256 //define this as a plug-in
T getParameter(std::string const &) const
const int EPOrder[]
int i
Definition: DBlmapReader.cc:9
std::vector< TrackingParticle > TrackingParticleCollection
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
TrackingParticleRefVector::iterator tp_iterator
std::string label() const
Definition: EvtPlane.h:20
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
const std::string EPNames[]
void beginJob()
Definition: Breakpoints.cc:15
int iEvent
Definition: GenABIO.cc:243
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:94
virtual void produce(edm::Event &, const edm::EventSetup &)
std::vector< EvtPlane > EvtPlaneCollection
Definition: EvtPlane.h:34
int j
Definition: DBlmapReader.cc:9
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
HiEvtPlaneFlatProducer(const edm::ParameterSet &)
const T & get() const
Definition: EventSetup.h:55
int RPNameIndx[50]
Definition: RPFlatParams.h:14
static const int NumEPNames