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