CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

MoveFlatParamsToDB Class Reference

#include <HiEvtPlaneFlatten/MoveFlatParamsToDB/src/MoveFlatParamsToDB.cc>

Inheritance diagram for MoveFlatParamsToDB:
edm::EDAnalyzer

List of all members.

Public Member Functions

 MoveFlatParamsToDB (const edm::ParameterSet &)
 ~MoveFlatParamsToDB ()

Private Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
virtual void beginJob ()
virtual void endJob ()

Private Attributes

TFile * inFile
int nRP
RPFlatParamsrpFlat
string rpname [NumEPNames]
int RPNameIndx [NumEPNames]
int RPSubEvnt [NumEPNames]
TH1D * x [NumEPNames]
TH1D * xycnt [NumEPNames]
TH1D * y [NumEPNames]

Detailed Description

Description: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 72 of file MoveFlatParamsToDB.cc.


Constructor & Destructor Documentation

MoveFlatParamsToDB::MoveFlatParamsToDB ( const edm::ParameterSet iConfig) [explicit]

Definition at line 108 of file MoveFlatParamsToDB.cc.

References gather_cfg::cout, hi::EPNames, i, list(), mergeVDriftHistosByStation::name, hi::NumEPNames, x, and detailsBasic3DVector::y.

{
  cout<<"Enter MoveFlatParamsToDB"<<endl;
  //now do what ever initialization is needed
  inFile = new TFile("data/rpflat_combined.root");
  if(inFile->IsZombie()) {
    cout<<"file not found"<<endl;
  }
  TList * list = ((TDirectory *)inFile->Get("hiEvtPlaneFlatCalib"))->GetListOfKeys();
  int indx =0;
  int cnt = 0;
  for(int i = 0; i<NumEPNames; i++) {
    x[i]=0;
    y[i]=0;
    xycnt[i]=0;
  }
  while(indx >=0 && indx<NumEPNames) {
    int EPNameIndx = -1;
    TString name = list->At(indx)->GetName();
    if(!name.Contains("cent")&&!name.Contains("vtx")&&!name.Contains("MidEtaTrackRescor")) {
      for(int i = 0; i<NumEPNames; i++) {
        if(name.CompareTo(EPNames[i])==0) {
          EPNameIndx = i;
          break;
        }
      }
      if(EPNameIndx <0) cout<<"A bad reaction plane name has been encountered: "<<name.Data()<<endl;
      RPNameIndx[cnt]=EPNameIndx;
      TString sname = name;
      x[cnt] = (TH1D *) inFile->Get(Form("hiEvtPlaneFlatCalib/%s/x_%s",name.Data(),name.Data()));
      y[cnt] = (TH1D *) inFile->Get(Form("hiEvtPlaneFlatCalib/%s/y_%s",name.Data(),name.Data()));
      xycnt[cnt] = (TH1D *) inFile->Get(Form("hiEvtPlaneFlatCalib/%s/cnt_%s",name.Data(),name.Data()));
      rpname[cnt]=sname;
      if(!x[cnt]) cout<<"bad x"<<endl;
      if(!y[cnt]) cout<<"bad y"<<endl;
      if(!xycnt[cnt]) cout<<"bad cnt"<<endl;
      if(x[cnt] && xycnt[cnt] && y[cnt]) {
        x[cnt]->Divide(xycnt[cnt]);
        y[cnt]->Divide(xycnt[cnt]);
      }
      ++cnt;
      if(cnt>NumEPNames||cnt>50) {
        cout<<"Maximum number of reaction planes exceeded!"<<endl;
        break;
      }
    }
    
    if(list->At(indx)==list->Last())
      indx = -1;
      else
        ++indx;
  }
  nRP = cnt;
  cout<<"nRP = "<<nRP<<endl;
}
MoveFlatParamsToDB::~MoveFlatParamsToDB ( )

Definition at line 166 of file MoveFlatParamsToDB.cc.

{
 
   // do anything here that needs to be done at desctruction time
   // (e.g. close files, deallocate resources etc.)

}

Member Function Documentation

void MoveFlatParamsToDB::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
) [private, virtual]

Implements edm::EDAnalyzer.

Definition at line 181 of file MoveFlatParamsToDB.cc.

References gather_cfg::cout, i, j, RPFlatParams::EP::RPNameIndx, RPFlatParams::EP::x, x, RPFlatParams::EP::y, and detailsBasic3DVector::y.

{
  using namespace edm;
  rpFlat = new RPFlatParams();
  rpFlat->m_table.reserve(x[0]->GetNbinsX());
  cout<<"Size of table: "<<x[0]->GetNbinsX()<<endl;
  for(int j = 0; j<x[0]->GetNbinsX();j++) {
    RPFlatParams::EP * thisBin = new RPFlatParams::EP();
    for(int i = 0; i<nRP; i++) {
      thisBin->x[i] = x[i]->GetBinContent(j+1);
      thisBin->y[i] = y[i]->GetBinContent(j+1);
      thisBin->RPNameIndx[i]=RPNameIndx[i];
    }
    rpFlat->m_table.push_back(*thisBin);
    if(thisBin) delete thisBin;
  }
  cout<<"Number of RP: "<<nRP<<endl;
  edm::Service<cond::service::PoolDBOutputService> poolDbService;
  if(poolDbService.isAvailable())
    poolDbService->writeOne( rpFlat,poolDbService->beginOfTime(),"HeavyIonRPRcd");
  cout<<"DONE"<<endl;
}
void MoveFlatParamsToDB::beginJob ( void  ) [private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 207 of file MoveFlatParamsToDB.cc.

{
}
void MoveFlatParamsToDB::endJob ( void  ) [private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 213 of file MoveFlatParamsToDB.cc.

                           {
}

Member Data Documentation

TFile* MoveFlatParamsToDB::inFile [private]

Definition at line 83 of file MoveFlatParamsToDB.cc.

int MoveFlatParamsToDB::nRP [private]

Definition at line 92 of file MoveFlatParamsToDB.cc.

Definition at line 91 of file MoveFlatParamsToDB.cc.

string MoveFlatParamsToDB::rpname[NumEPNames] [private]

Definition at line 88 of file MoveFlatParamsToDB.cc.

int MoveFlatParamsToDB::RPNameIndx[NumEPNames] [private]

Definition at line 89 of file MoveFlatParamsToDB.cc.

int MoveFlatParamsToDB::RPSubEvnt[NumEPNames] [private]

Definition at line 90 of file MoveFlatParamsToDB.cc.

TH1D* MoveFlatParamsToDB::x[NumEPNames] [private]

Definition at line 85 of file MoveFlatParamsToDB.cc.

TH1D* MoveFlatParamsToDB::xycnt[NumEPNames] [private]

Definition at line 87 of file MoveFlatParamsToDB.cc.

TH1D* MoveFlatParamsToDB::y[NumEPNames] [private]

Definition at line 86 of file MoveFlatParamsToDB.cc.