CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_6/src/DataFormats/HeavyIonEvent/src/CentralityProvider.cc

Go to the documentation of this file.
00001 #include "DataFormats/HeavyIonEvent/interface/CentralityProvider.h"
00002 
00003 CentralityProvider::CentralityProvider(const edm::EventSetup& iSetup) :
00004    prevRun_(0),
00005    varType_(Missing)
00006 {
00007    const edm::ParameterSet &thepset = edm::getProcessParameterSet();
00008    if(thepset.exists("HeavyIonGlobalParameters")){
00009       edm::ParameterSet hiPset = thepset.getParameter<edm::ParameterSet>("HeavyIonGlobalParameters");
00010       tag_ = hiPset.getParameter<edm::InputTag>("centralitySrc");
00011       centralityVariable_ = hiPset.getParameter<std::string>("centralityVariable");
00012       if(centralityVariable_.compare("HFtowers") == 0) varType_ = HFtowers;
00013       if(centralityVariable_.compare("HFhits") == 0) varType_ = HFhits;
00014       if(centralityVariable_.compare("PixelHits") == 0) varType_ = PixelHits;
00015       if(centralityVariable_.compare("PixelTracks") == 0) varType_ = PixelTracks;
00016       if(centralityVariable_.compare("Tracks") == 0) varType_ = Tracks;
00017       if(centralityVariable_.compare("EB") == 0) varType_ = EB;
00018       if(centralityVariable_.compare("EE") == 0) varType_ = EE;
00019       if(varType_ == Missing){
00020          std::string errorMessage="Requested Centrality variable does not exist : "+centralityVariable_+"\n" +
00021             "Supported variables are: \n" + "HFtowers HFhits PixelHits PixelTracks Tracks EB EE" + "\n";
00022          throw cms::Exception("Configuration",errorMessage);
00023       }
00024       if(hiPset.exists("nonDefaultGlauberModel")){
00025          centralityMC_ = hiPset.getParameter<std::string>("nonDefaultGlauberModel");
00026       }
00027       centralityLabel_ = centralityVariable_+centralityMC_;
00028       SetName(centralityLabel_.data());
00029    }else{
00030    }
00031    newRun(iSetup);
00032 }
00033 
00034 void CentralityProvider::newEvent(const edm::Event& ev,const edm::EventSetup& iSetup){
00035    ev.getByLabel(tag_,chandle_);
00036    if(ev.id().run() == prevRun_) return;
00037    prevRun_ = ev.id().run();
00038    newRun(iSetup);
00039 }
00040 
00041 void CentralityProvider::newRun(const edm::EventSetup& iSetup){
00042    edm::ESHandle<CentralityTable> inputDB_;
00043    iSetup.get<HeavyIonRcd>().get(centralityLabel_,inputDB_);
00044    int nbinsMax = inputDB_->m_table.size();
00045    table_.clear();
00046    table_.reserve(nbinsMax);
00047    for(int j=0; j<nbinsMax; j++){
00048       const CentralityTable::CBin* thisBin;
00049       thisBin = &(inputDB_->m_table[j]);
00050       CBin newBin;
00051       newBin.bin_edge = thisBin->bin_edge;
00052       newBin.n_part_mean = thisBin->n_part.mean;
00053       newBin.n_part_var  = thisBin->n_part.var;
00054       newBin.n_coll_mean = thisBin->n_coll.mean;
00055       newBin.n_coll_var  = thisBin->n_coll.var;
00056       newBin.n_hard_mean = thisBin->n_hard.mean;
00057       newBin.n_hard_var  = thisBin->n_hard.var;
00058       newBin.b_mean = thisBin->b.mean;
00059       newBin.b_var = thisBin->b.var;
00060 
00061       newBin.eccRP_mean = thisBin->eccRP.mean;
00062       newBin.eccRP_var = thisBin->eccRP.var;
00063       newBin.ecc2_mean = thisBin->ecc2.mean;
00064       newBin.ecc2_var = thisBin->ecc2.var;
00065       newBin.ecc3_mean = thisBin->ecc3.mean;
00066       newBin.ecc3_var = thisBin->ecc3.var;
00067       newBin.s_mean = thisBin->S.mean;
00068       newBin.s_var = thisBin->S.var;
00069 
00070       table_.push_back(newBin);
00071    }
00072 }
00073 
00074 void CentralityProvider::print(){
00075    std::cout<<"Number of bins : "<<table_.size()<<std::endl;
00076    for(unsigned int j = 0; j < table_.size(); ++j){
00077       std::cout<<"Bin : "<<j<<std::endl;
00078       std::cout<<"Bin Low Edge : "<<table_[j].bin_edge <<std::endl;
00079       std::cout<<"Npart Mean : "<<table_[j].n_part_mean <<std::endl;
00080       std::cout<<"Npart RMS  : "<<table_[j].n_part_var <<std::endl;
00081       std::cout<<"Ncoll Mean : "<<table_[j].n_coll_mean <<std::endl;
00082       std::cout<<"Ncoll RMS  : "<<table_[j].n_coll_var <<std::endl;
00083       std::cout<<"Nhard Mean : "<<table_[j].n_hard_mean <<std::endl;
00084       std::cout<<"Nhard RMS  : "<<table_[j].n_hard_var <<std::endl;
00085       std::cout<<"b Mean     : "<<table_[j].b_mean <<std::endl;
00086       std::cout<<"b RMS      : "<<table_[j].b_var <<std::endl;
00087    }
00088 }
00089 
00090 double CentralityProvider::centralityValue() const {
00091    double var = -99;
00092    if(varType_ == HFhits) var = chandle_->EtHFhitSum();
00093    if(varType_ == HFtowers) var = chandle_->EtHFtowerSum();
00094    if(varType_ == PixelHits) var = chandle_->multiplicityPixel();
00095    if(varType_ == PixelTracks) var = chandle_->NpixelTracks();
00096    if(varType_ == Tracks) var = chandle_->Ntracks();
00097    if(varType_ == EB) var = chandle_->EtEBSum();
00098    if(varType_ == EE) var = chandle_->EtEESum();
00099 
00100    return var;
00101 }
00102 
00103 
00104 
00105 
00106