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 //
18 //
19 
20 
21 // system include files
22 #include <memory>
23 
24 // user include files
27 
30 
32 #include "Math/Vector3D.h"
33 
37 
40 
57 
64 
66 #include "TList.h"
67 #include "TString.h"
68 #include <time.h>
69 #include <cstdlib>
70 
72 
73 using namespace std;
74 using namespace hi;
75 
76 #include <vector>
77 using std::vector;
78 
79 
80 //
81 // class declaration
82 //
83 
85  public:
88 
89  private:
90  virtual void beginJob() override ;
91  virtual void produce(edm::Event&, const edm::EventSetup&) override;
92  virtual void endJob() override ;
93 
94  // ----------member data ---------------------------
95 
99 
100  int vs_sell; // vertex collection size
101  float vzr_sell;
102  float vzErr_sell;
103 
104  Double_t epang[NumEPNames];
107  int nRP;
109 
110 };
111 
112 //
113 // constants, enums and typedefs
114 //
115 typedef std::vector<TrackingParticle> TrackingParticleCollection;
117 
118 
119 //
120 // static data member definitions
121 //
122 
123 //
124 // constructors and destructor
125 //
127 {
128 
129  vtxCollection_ = iConfig.getParameter<edm::InputTag>("vtxCollection_");
130  inputPlanes_ = iConfig.getParameter<edm::InputTag>("inputPlanes_");
131  centrality_ = iConfig.getParameter<edm::InputTag>("centrality_");
132  storeNames_ = 1;
133  //register your products
134  produces<reco::EvtPlaneCollection>();
135  //now do what ever other initialization is needed
136  Int_t FlatOrder = 21;
137  for(int i = 0; i<NumEPNames; i++) {
138  flat[i] = new HiEvtPlaneFlatten();
139  flat[i]->Init(FlatOrder,11,4,EPNames[i],EPOrder[i]);
140  }
141 
142 }
143 
144 
146 {
147 
148  // do anything here that needs to be done at desctruction time
149  // (e.g. close files, deallocate resources etc.)
150 
151 }
152 
153 
154 //
155 // member functions
156 //
157 
158 // ------------ method called to produce the data ------------
159 void
161 {
162  using namespace edm;
163  using namespace std;
164  using namespace reco;
165 
166  //
167  //Get Centrality
168  //
169 
170  edm::Handle<int> ch;
171  iEvent.getByLabel(centrality_,ch);
172  int bin = *(ch.product());
173 
174  // double centval = 2.5*bin+1.25;
175  //
176  //Get Vertex
177  //
178  edm::Handle<reco::VertexCollection> vertexCollection3;
179  iEvent.getByLabel(vtxCollection_,vertexCollection3);
180  const reco::VertexCollection * vertices3 = vertexCollection3.product();
181  vs_sell = vertices3->size();
182  if(vs_sell>0) {
183  vzr_sell = vertices3->begin()->z();
184  vzErr_sell = vertices3->begin()->zError();
185  } else
186  vzr_sell = -999.9;
187  //
188  //Get Flattening Parameters
189  //
190  edm::ESHandle<RPFlatParams> flatparmsDB_;
191  iSetup.get<HeavyIonRPRcd>().get(flatparmsDB_);
192  int flatTableSize = flatparmsDB_->m_table.size();
193  for(int i = 0; i<flatTableSize; i++) {
194  const RPFlatParams::EP* thisBin = &(flatparmsDB_->m_table[i]);
195  for(int j = 0; j<NumEPNames; j++) {
196  int indx = thisBin->RPNameIndx[j];
197  if(indx>=0) {
198  flat[indx]->SetXDB(i, thisBin->x[j]);
199  flat[indx]->SetYDB(i, thisBin->y[j]);
200  }
201  }
202  }
203 
204  //
205  //Get Event Planes
206  //
207 
209  iEvent.getByLabel(inputPlanes_,evtPlanes);
210 
211  if(!evtPlanes.isValid()){
212  // cout << "Error! Can't get hiEvtPlane product!" << endl;
213  return ;
214  }
215 
216  std::auto_ptr<EvtPlaneCollection> evtplaneOutput(new EvtPlaneCollection);
217  EvtPlane * ep[NumEPNames];
218  for(int i = 0; i<NumEPNames; i++) {
219  ep[i]=0;
220  }
221  for (EvtPlaneCollection::const_iterator rp = evtPlanes->begin();rp !=evtPlanes->end(); rp++) {
222  if(rp->angle() > -5) {
223  string baseName = rp->label();
224  for(int i = 0; i< NumEPNames; i++) {
225  if(EPNames[i].compare(baseName)==0) {
226  double psiFlat = flat[i]->GetFlatPsi(rp->angle(),vzr_sell,bin);
227  epang[i]=psiFlat;
228  if(EPNames[i].compare(rp->label())==0) {
229  if(storeNames_) ep[i]= new EvtPlane(psiFlat, rp->sumSin(), rp->sumCos(),rp->label().data());
230  else ep[i]= new EvtPlane(psiFlat, rp->sumSin(), rp->sumCos(),"");
231  }
232  }
233  }
234  }
235  }
236 
237  for(int i = 0; i< NumEPNames; i++) {
238  if(ep[i]!=0) evtplaneOutput->push_back(*ep[i]);
239  }
240  iEvent.put(evtplaneOutput);
241  storeNames_ = 0;
242 }
243 
244 // ------------ method called once each job just before starting event loop ------------
245 void
247 {
248 }
249 
250 // ------------ method called once each job just after ending the event loop ------------
251 void
253 }
254 
255 //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:19
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:230
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
virtual void produce(edm::Event &, const edm::EventSetup &) override
std::vector< EvtPlane > EvtPlaneCollection
Definition: EvtPlane.h:33
int j
Definition: DBlmapReader.cc:9
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:402
HiEvtPlaneFlatProducer(const edm::ParameterSet &)
const T & get() const
Definition: EventSetup.h:55
return(e1-e2)*(e1-e2)+dp *dp
virtual void endJob() override
int RPNameIndx[50]
Definition: RPFlatParams.h:16
static const int NumEPNames
virtual void beginJob() override