CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MoveFlatParamsToDB.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: MoveFlatParamsToDB
4 // Class: MoveFlatParamsToDB
5 //
13 //
14 // Original Author: Stephen Sanders
15 // Created: Fri Jun 11 12:56:15 EDT 2010
16 // $Id: MoveFlatParamsToDB.cc,v 1.2 2011/10/07 09:41:29 yilmaz Exp $
17 //
18 //
19 
20 
21 // system include files
22 #include <memory>
23 #include <iostream>
24 #include <fstream>
25 #include <vector>
26 #include <string>
27 // user include files
30 
36 
39 
45 
50 
52 #include "TFile.h"
53 #include "TH1.h"
54 #include "TH2D.h"
55 #include "TH2F.h"
56 #include "TTree.h"
57 #include "TH1I.h"
58 #include "TF1.h"
59 #include "TList.h"
60 #include "TString.h"
61 #include <time.h>
62 #include <cstdlib>
63 #include <iostream>
64 #include <vector>
65 using namespace std;
66 using namespace hi;
67 
68 //
69 // class declaration
70 //
71 
73 public:
74  explicit MoveFlatParamsToDB(const edm::ParameterSet&);
76 
77 
78 private:
79  virtual void beginJob() ;
80  virtual void analyze(const edm::Event&, const edm::EventSetup&);
81  virtual void endJob() ;
82 // edm::Service<TFileService> fs;
83  TFile * inFile;
84  //Hard coded limit of 100 different reaction planes
85  TH1D * x[NumEPNames];
86  TH1D * y[NumEPNames];
87  TH1D * xycnt[NumEPNames];
88  string rpname[NumEPNames];
89  int RPNameIndx[NumEPNames];
90  int RPSubEvnt[NumEPNames];
92  int nRP;
93 
94  // ----------member data ---------------------------
95 };
96 
97 //
98 // constants, enums and typedefs
99 //
100 
101 //
102 // static data member definitions
103 //
104 
105 //
106 // constructors and destructor
107 //
109 
110 {
111  cout<<"Enter MoveFlatParamsToDB"<<endl;
112  //now do what ever initialization is needed
113  inFile = new TFile("data/rpflat_combined.root");
114  if(inFile->IsZombie()) {
115  cout<<"file not found"<<endl;
116  }
117  TList * list = ((TDirectory *)inFile->Get("hiEvtPlaneFlatCalib"))->GetListOfKeys();
118  int indx =0;
119  int cnt = 0;
120  for(int i = 0; i<NumEPNames; i++) {
121  x[i]=0;
122  y[i]=0;
123  xycnt[i]=0;
124  }
125  while(indx >=0 && indx<NumEPNames) {
126  int EPNameIndx = -1;
127  TString name = list->At(indx)->GetName();
128  if(!name.Contains("cent")&&!name.Contains("vtx")&&!name.Contains("MidEtaTrackRescor")) {
129  for(int i = 0; i<NumEPNames; i++) {
130  if(name.CompareTo(EPNames[i])==0) {
131  EPNameIndx = i;
132  break;
133  }
134  }
135  if(EPNameIndx <0) cout<<"A bad reaction plane name has been encountered: "<<name.Data()<<endl;
136  RPNameIndx[cnt]=EPNameIndx;
137  TString sname = name;
138  x[cnt] = (TH1D *) inFile->Get(Form("hiEvtPlaneFlatCalib/%s/x_%s",name.Data(),name.Data()));
139  y[cnt] = (TH1D *) inFile->Get(Form("hiEvtPlaneFlatCalib/%s/y_%s",name.Data(),name.Data()));
140  xycnt[cnt] = (TH1D *) inFile->Get(Form("hiEvtPlaneFlatCalib/%s/cnt_%s",name.Data(),name.Data()));
141  rpname[cnt]=sname;
142  if(!x[cnt]) cout<<"bad x"<<endl;
143  if(!y[cnt]) cout<<"bad y"<<endl;
144  if(!xycnt[cnt]) cout<<"bad cnt"<<endl;
145  if(x[cnt] && xycnt[cnt] && y[cnt]) {
146  x[cnt]->Divide(xycnt[cnt]);
147  y[cnt]->Divide(xycnt[cnt]);
148  }
149  ++cnt;
150  if(cnt>NumEPNames||cnt>50) {
151  cout<<"Maximum number of reaction planes exceeded!"<<endl;
152  break;
153  }
154  }
155 
156  if(list->At(indx)==list->Last())
157  indx = -1;
158  else
159  ++indx;
160  }
161  nRP = cnt;
162  cout<<"nRP = "<<nRP<<endl;
163 }
164 
165 
167 {
168 
169  // do anything here that needs to be done at desctruction time
170  // (e.g. close files, deallocate resources etc.)
171 
172 }
173 
174 
175 //
176 // member functions
177 //
178 
179 // ------------ method called to for each event ------------
180 void
182 {
183  using namespace edm;
184  rpFlat = new RPFlatParams();
185  rpFlat->m_table.reserve(x[0]->GetNbinsX());
186  cout<<"Size of table: "<<x[0]->GetNbinsX()<<endl;
187  for(int j = 0; j<x[0]->GetNbinsX();j++) {
188  RPFlatParams::EP * thisBin = new RPFlatParams::EP();
189  for(int i = 0; i<nRP; i++) {
190  thisBin->x[i] = x[i]->GetBinContent(j+1);
191  thisBin->y[i] = y[i]->GetBinContent(j+1);
192  thisBin->RPNameIndx[i]=RPNameIndx[i];
193  }
194  rpFlat->m_table.push_back(*thisBin);
195  if(thisBin) delete thisBin;
196  }
197  cout<<"Number of RP: "<<nRP<<endl;
199  if(poolDbService.isAvailable())
200  poolDbService->writeOne( rpFlat,poolDbService->beginOfTime(),"HeavyIonRPRcd");
201  cout<<"DONE"<<endl;
202 }
203 
204 
205 // ------------ method called once each job just before starting event loop ------------
206 void
208 {
209 }
210 
211 // ------------ method called once each job just after ending the event loop ------------
212 void
214 }
215 
216 //define this as a plug-in
int i
Definition: DBlmapReader.cc:9
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
virtual void analyze(const edm::Event &, const edm::EventSetup &)
const std::string EPNames[]
MoveFlatParamsToDB(const edm::ParameterSet &)
void beginJob()
Definition: Breakpoints.cc:15
int iEvent
Definition: GenABIO.cc:243
int j
Definition: DBlmapReader.cc:9
void writeOne(T *payload, Time_t time, const std::string &recordName, bool withlogging=false)
int RPNameIndx[50]
Definition: RPFlatParams.h:14
tuple cout
Definition: gather_cfg.py:121
static const int NumEPNames
x
Definition: VDTMath.h:216
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run