CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HiEvtPlaneFlatCalib.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: HiEvtPlaneFlatCalib
4 // Class: HiEvtPlaneFlatCalib
5 //
14 //
15 // Original Author: Stephen Sanders
16 // Created: Sat Jun 26 16:04:04 EDT 2010
17 // $Id: HiEvtPlaneFlatCalib.cc,v 1.7 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 
34 #include "Math/Vector3D.h"
35 
39 
42 
48 
55 
57 #include "TFile.h"
58 #include "TH1.h"
59 #include "TH2D.h"
60 #include "TH2F.h"
61 #include "TTree.h"
62 #include "TH1I.h"
63 #include "TF1.h"
64 #include "TList.h"
65 #include "TString.h"
66 #include <time.h>
67 #include <cstdlib>
68 #include <vector>
69 
71 
72 using namespace std;
73 using namespace hi;
74 
75 //
76 // class declaration
77 //
78 
80  public:
81  explicit HiEvtPlaneFlatCalib(const edm::ParameterSet&);
83 
84  private:
85  virtual void beginJob() ;
86  virtual void analyze(const edm::Event&, const edm::EventSetup&);
87  virtual void endJob() ;
88 
89  // ----------member data ---------------------------
91  // const CentralityBins * cbins_;
93  int vs_sell; // vertex collection size
94  float vzr_sell;
95  float vzErr_sell;
96 
97  static const int NumCentBins=9;
98  double wcent[10];
99 
100  TH1D * hcent;
101  TH1D * hvtx;
102  TH1D * flatXhist[NumEPNames];
103  TH1D * flatYhist[NumEPNames];
104  TH1D * flatCnthist[NumEPNames];
105 
106  TH1D * flatXDBhist[NumEPNames];
107  TH1D * flatYDBhist[NumEPNames];
108  TH1D * hPsi[NumEPNames];
109  TH1D * hPsiFlat[NumEPNames];
110  TH1D * hPsiFlatCent[NumEPNames][NumCentBins];
111  TH1D * hPsiFlatSub1[NumEPNames];
112  TH1D * hPsiFlatSub2[NumEPNames];
113  Double_t epang[NumEPNames];
116  int nRP;
118 
119 };
120 
121 //
122 // constants, enums and typedefs
123 //
124 
125 //
126 // static data member definitions
127 //
128 
129 //
130 // constructors and destructor
131 //
133 {
134  genFlatPsi_ = iConfig.getUntrackedParameter<bool>("genFlatPsi_",true);
135 
136  // NumCentBins=9;
137  wcent[0] = 0;
138  wcent[1] = 5;
139  wcent[2] = 10;
140  wcent[3] = 20;
141  wcent[4] = 30;
142  wcent[5] = 40;
143  wcent[6] = 50;
144  wcent[7] = 60;
145  wcent[8] = 70;
146  wcent[9] = 100;
147 
148  //now do what ever other initialization is needed
149  // cbins_ = 0;
150  centrality_ = 0;
151  hcent = fs->make<TH1D>("cent","cent",41,0,40);
152  hvtx = fs->make<TH1D>("vtx","vtx",1000,-50,50);
153  //setting before 8:35 CDT on 11Jan2011
154  Int_t FlatOrder = 21;
155  for(int i = 0; i<NumEPNames; i++) {
156  TFileDirectory subdir = fs->mkdir(Form("%s",EPNames[i].data()));
157  flat[i] = new HiEvtPlaneFlatten();
158  flat[i]->Init(FlatOrder,11,4,EPNames[i],EPOrder[i]);
159  int nbins = flat[i]->GetHBins();
160  flatXhist[i] = subdir.make<TH1D>(Form("x_%s",EPNames[i].data()),Form("x_%s",EPNames[i].data()),nbins,-0.5,nbins-0.5);
161  flatYhist[i] = subdir.make<TH1D>(Form("y_%s",EPNames[i].data()),Form("y_%s",EPNames[i].data()),nbins,-0.5,nbins-0.5);
162  flatCnthist[i] = subdir.make<TH1D>(Form("cnt_%s",EPNames[i].data()),Form("cnt_%s",EPNames[i].data()),nbins,-0.5,nbins-0.5);
163  Double_t psirange = 4;
164  if(EPOrder[i]==2 ) psirange = 2;
165  if(EPOrder[i]==3 ) psirange = 1.5;
166  if(EPOrder[i]==4 ) psirange = 1;
167  if(EPOrder[i]==5) psirange = 0.8;
168  if(EPOrder[i]==6) psirange = 0.6;
169  hPsi[i] = subdir.make<TH1D>("psi","psi",800,-psirange,psirange);
170  hPsi[i]->SetXTitle("#Psi");
171  hPsi[i]->SetYTitle(Form("Counts (cent<80%c)",'%'));
172  hPsiFlat[i] = subdir.make<TH1D>("psiFlat","psiFlat",800,-psirange,psirange);
173  hPsiFlat[i]->SetXTitle("#Psi");
174  hPsiFlat[i]->SetYTitle(Form("Counts (cent<80%c)",'%'));
175  for(int j = 0; j<NumCentBins; j++) {
176  TString hname = Form("psiFlat_%d_%d",(int) wcent[j],(int) wcent[j+1]);
177  hPsiFlatCent[i][j] = subdir.make<TH1D>(hname.Data(),hname.Data(),800,-psirange,psirange);
178  hPsiFlatCent[i][j]->SetXTitle("#Psi");
179  hPsiFlatCent[i][j]->SetYTitle(Form("Counts (%d<cent#leq%d%c)",(int) wcent[j],(int) wcent[j+1],'%'));
180  }
181 
182  }
183 
184 }
185 
186 
188 {
189 
190  // do anything here that needs to be done at desctruction time
191  // (e.g. close files, deallocate resources etc.)
192 
193 }
194 
195 
196 //
197 // member functions
198 //
199 
200 // ------------ method called to produce the data ------------
201 void
203 {
204  using namespace edm;
205  using namespace reco;
206  //
207  //Get Centrality
208  //
209  if(!centrality_) centrality_ = new CentralityProvider(iSetup);
210 
211  centrality_->newEvent(iEvent,iSetup); // make sure you do this first in every event
212  int bin = centrality_->getBin();
213  double centval = 2.5*bin+1.25;
214  hcent->Fill(bin);
215  //
216  //Get Vertex
217  //
218  edm::Handle<reco::VertexCollection> vertexCollection3;
219  iEvent.getByLabel("hiSelectedVertex",vertexCollection3);
220  const reco::VertexCollection * vertices3 = vertexCollection3.product();
221  vs_sell = vertices3->size();
222  if(vs_sell>0) {
223  vzr_sell = vertices3->begin()->z();
224  vzErr_sell = vertices3->begin()->zError();
225  } else
226  vzr_sell = -999.9;
227  //
228  //Get Flattening Parameters
229  //
230  if(genFlatPsi_) {
231  edm::ESHandle<RPFlatParams> flatparmsDB_;
232  iSetup.get<HeavyIonRPRcd>().get(flatparmsDB_);
233  int flatTableSize = flatparmsDB_->m_table.size();
234  for(int i = 0; i<flatTableSize; i++) {
235  const RPFlatParams::EP* thisBin = &(flatparmsDB_->m_table[i]);
236  for(int j = 0; j<NumEPNames; j++) {
237  int indx = thisBin->RPNameIndx[j];
238  if(indx>=0) {
239  flat[indx]->SetXDB(i, thisBin->x[j]);
240  flat[indx]->SetYDB(i, thisBin->y[j]);
241  }
242  }
243  }
244  }
245 
246  //
247  //Get Event Planes
248  //
249 
251  iEvent.getByLabel("hiEvtPlane","recoLevel",evtPlanes);
252 
253  if(!evtPlanes.isValid()){
254  //cout << "Error! Can't get hiEvtPlane product!" << endl;
255  return ;
256  }
257 
258  for (EvtPlaneCollection::const_iterator rp = evtPlanes->begin();rp !=evtPlanes->end(); rp++) {
259  if(rp->angle() > -5) {
260  string baseName = rp->label();
261  for(int i = 0; i< NumEPNames; i++) {
262  if(EPNames[i].compare(baseName)==0) {
263  double psiFlat = flat[i]->GetFlatPsi(rp->angle(),vzr_sell,bin);
264  epang[i]=psiFlat;
265  if(EPNames[i].compare(rp->label())==0) {
266  flat[i]->Fill(rp->angle(),vzr_sell,bin);
267  if(i==0) hvtx->Fill(vzr_sell);
268 
269  if(centval<=80) hPsi[i]->Fill(rp->angle());
270  if(genFlatPsi_) {
271  if(centval<=80) hPsiFlat[i]->Fill(psiFlat);
272  for(int j = 0; j<NumCentBins; j++) {
273  if(centval>wcent[j]&&centval<=wcent[j+1]) hPsiFlatCent[i][j]->Fill(psiFlat);
274  }
275  }
276  }
277  }
278  }
279  }
280  }
281 
282 }
283 
284 // ------------ method called once each job just before starting event loop ------------
285 void
287 {
288 }
289 
290 // ------------ method called once each job just after ending the event loop ------------
291 void
293  for(int i = 0; i<NumEPNames; i++) {
294  for(int j = 0; j<flat[i]->GetHBins();j++) {
295  flatXhist[i]->SetBinContent(j+1,flat[i]->GetX(j));
296  flatYhist[i]->SetBinContent(j+1,flat[i]->GetY(j));
297  flatCnthist[i]->SetBinContent(j+1,flat[i]->GetCnt(j));
298  }
299  }
300 }
301 
302 //define this as a plug-in
T getUntrackedParameter(std::string const &, T const &) const
const int EPOrder[]
int i
Definition: DBlmapReader.cc:9
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
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
int j
Definition: DBlmapReader.cc:9
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
virtual void analyze(const edm::Event &, const edm::EventSetup &)
TFileDirectory mkdir(const std::string &dir, const std::string &descr="")
create a new subdirectory
const T & get() const
Definition: EventSetup.h:55
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
T * make() const
make new ROOT object
int RPNameIndx[50]
Definition: RPFlatParams.h:14
static const int NumEPNames
HiEvtPlaneFlatCalib(const edm::ParameterSet &)
CentralityProvider * centrality_
edm::Service< TFileService > fs