CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes

PhiSymmetryCalibration Class Reference

#include <PhiSymmetryCalibration.h>

Inheritance diagram for PhiSymmetryCalibration:
edm::EDAnalyzer

List of all members.

Public Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
 Called at each event.
virtual void beginJob ()
 Called at beginning of job.
virtual void endJob ()
 Called at end of job.
void endLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &)
virtual void endRun (edm::Run &, const edm::EventSetup &)
 PhiSymmetryCalibration (const edm::ParameterSet &iConfig)
 Constructor.
void setUp (const edm::EventSetup &setup)
 ~PhiSymmetryCalibration ()
 Destructor.

Private Member Functions

void getKfactors ()

Private Attributes

double ap_
double b_
std::vector< DetIdbarrelCells
std::string barrelHits_
EcalGeomPhiSymHelper e_
std::vector< TH1F * > e_spectrum_b_histos
std::vector< TH1F * > e_spectrum_e_histos
std::string ecalHitsProducer_
double eCut_barl_
std::vector< DetIdendcapCells
std::string endcapHits_
float epsilon_M_barl [kBarlRings][kBarlWedges][kSides]
float epsilon_M_endc [kEndcWedgesX][kEndcWedgesY][kSides]
double esumMean_barl_ [kBarlRings]
double esumMean_endc_ [kEndcEtaRings]
std::vector< TH1F * > et_spectrum_b_histos
std::vector< TH1F * > et_spectrum_e_histos
double etsum_barl_ [kBarlRings][kBarlWedges][kSides]
double etsum_barl_miscal_ [kNMiscalBinsEB][kBarlRings]
double etsum_endc_ [kEndcWedgesX][kEndcWedgesX][kSides]
double etsum_endc_miscal_ [kNMiscalBinsEE][kEndcEtaRings]
double etsum_endc_uncorr [kEndcWedgesX][kEndcWedgesX][kSides]
double etsumMean_barl_ [kBarlRings]
double etsumMean_endc_ [kEndcEtaRings]
int eventSet_
int eventsinlb_
int eventsinrun_
bool isfirstpass_
double k_barl_ [kBarlRings]
double k_endc_ [kEndcEtaRings]
double miscalEB_ [kNMiscalBinsEB]
double miscalEE_ [kNMiscalBinsEE]
int nevents_
double newCalibs_barl [kBarlRings][kBarlWedges][kSides]
double newCalibs_endc [kEndcWedgesX][kEndcWedgesX][kSides]
unsigned int nhits_barl_ [kBarlRings][kBarlWedges][kSides]
unsigned int nhits_endc_ [kEndcWedgesX][kEndcWedgesX][kSides]
std::string oldcalibfile_
EcalIntercalibConstants oldCalibs_
 the old calibration constants (when reiterating, the last ones derived)
double oldCalibs_barl [kBarlRings][kBarlWedges][kSides]
double oldCalibs_endc [kEndcWedgesX][kEndcWedgesY][kSides]
float phi_endc [kMaxEndciPhi][kEndcEtaRings]
float rawconst_barl [kBarlRings][kBarlWedges][kSides]
float rawconst_endc [kEndcWedgesX][kEndcWedgesX][kSides]
bool reiteration_
bool spectra
int statusThreshold_
 threshold in channel status beyond which channel is marked bad

Static Private Attributes

static const int kMaxEndciPhi = 360
static const float kMiscalRangeEB = .05
static const float kMiscalRangeEE = .10
static const int kNMiscalBinsEB = 21
static const int kNMiscalBinsEE = 41

Detailed Description

Definition at line 35 of file PhiSymmetryCalibration.h.


Constructor & Destructor Documentation

PhiSymmetryCalibration::PhiSymmetryCalibration ( const edm::ParameterSet iConfig)

Constructor.

Definition at line 59 of file PhiSymmetryCalibration.cc.

References e_spectrum_b_histos, e_spectrum_e_histos, et_spectrum_b_histos, et_spectrum_e_histos, eventsinlb_, eventsinrun_, isfirstpass_, kBarlRings, kEndcEtaRings, nevents_, and spectra.

                                                                             :

  ecalHitsProducer_(iConfig.getParameter<std::string>("ecalRecHitsProducer")),
  barrelHits_( iConfig.getParameter< std::string > ("barrelHitCollection")),
  endcapHits_( iConfig.getParameter< std::string > ("endcapHitCollection")),
  eCut_barl_( iConfig.getParameter< double > ("eCut_barrel") ),
  ap_( iConfig.getParameter<double> ("ap") ),
  b_( iConfig.getParameter<double> ("b") ), 
  eventSet_( iConfig.getParameter< int > ("eventSet") ),
  statusThreshold_(iConfig.getUntrackedParameter<int>("statusThreshold",3)),
  reiteration_(iConfig.getUntrackedParameter< bool > ("reiteration",false)),
  oldcalibfile_(iConfig.getUntrackedParameter<std::string>("oldcalibfile",
                                            "EcalintercalibConstants.xml"))
{


  isfirstpass_=true;

  et_spectrum_b_histos.resize(kBarlRings);
  e_spectrum_b_histos.resize(kBarlRings);
  et_spectrum_e_histos.resize(kEndcEtaRings);
  e_spectrum_e_histos.resize(kEndcEtaRings); 
  
  spectra=true;

  nevents_=0;
  eventsinrun_=0;
  eventsinlb_=0;
}
PhiSymmetryCalibration::~PhiSymmetryCalibration ( )

Destructor.

Definition at line 93 of file PhiSymmetryCalibration.cc.

References e_spectrum_b_histos, e_spectrum_e_histos, et_spectrum_b_histos, et_spectrum_e_histos, i, kBarlRings, and kEndcEtaRings.

{


  for(Int_t i=0;i<kBarlRings;i++){
    delete et_spectrum_b_histos[i];
    delete e_spectrum_b_histos[i];
    
  }
  for(Int_t i=0;i<kEndcEtaRings;i++){
    delete et_spectrum_e_histos[i];
    delete e_spectrum_e_histos[i];    
  }

  
}

Member Function Documentation

void PhiSymmetryCalibration::analyze ( const edm::Event event,
const edm::EventSetup setup 
) [virtual]

Called at each event.

Implements edm::EDAnalyzer.

Definition at line 273 of file PhiSymmetryCalibration.cc.

References abs, ap_, b_, barrelHits_, EcalGeomPhiSymHelper::cellPos_, e_, e_spectrum_b_histos, e_spectrum_e_histos, DetId::Ecal, EcalBarrel, EcalEndcap, ecalHitsProducer_, eCut_barl_, endcapHits_, EcalGeomPhiSymHelper::endcapRing_, et_spectrum_b_histos, et_spectrum_e_histos, eta(), PV3DBase< T, PVType, FrameType >::eta(), EcalGeomPhiSymHelper::etaBoundary_, etsum_barl_, etsum_barl_miscal_, etsum_endc_, etsum_endc_miscal_, eventSet_, eventsinlb_, eventsinrun_, HcalObjRepresent::Fill(), edm::EventSetup::get(), EcalGeomPhiSymHelper::goodCell_barl, EcalGeomPhiSymHelper::goodCell_endc, EBDetId::ieta(), EBDetId::iphi(), isfirstpass_, EEDetId::ix(), EEDetId::iy(), kEndcEtaRings, kNMiscalBinsEB, kNMiscalBinsEE, miscalEB_, miscalEE_, nevents_, nhits_barl_, nhits_endc_, EcalGeomPhiSymHelper::nRing_, oldCalibs_, phi, EcalGeomPhiSymHelper::phi_endc_, reiteration_, relativeConstraints::ring, setUp(), spectra, and EEDetId::zside().

{
  using namespace edm;
  using namespace std;

  if (isfirstpass_) {
    setUp(setup);
    isfirstpass_=false;
  }

  
  Handle<EBRecHitCollection> barrelRecHitsHandle;
  Handle<EERecHitCollection> endcapRecHitsHandle;
  
  event.getByLabel(ecalHitsProducer_,barrelHits_,barrelRecHitsHandle);
  if (!barrelRecHitsHandle.isValid()) {
    LogError("") << "[PhiSymmetryCalibration] Error! Can't get product!" << std::endl;
  }
  
  event.getByLabel(ecalHitsProducer_,endcapHits_,endcapRecHitsHandle);
  if (!endcapRecHitsHandle.isValid()) {
    LogError("") << "[PhiSymmetryCalibration] Error! Can't get product!" << std::endl;
  }
  
 
  // get the ecal geometry
  edm::ESHandle<CaloGeometry> geoHandle;
  setup.get<CaloGeometryRecord>().get(geoHandle);
  const CaloSubdetectorGeometry *barrelGeometry = 
    geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalBarrel);
  const CaloSubdetectorGeometry *endcapGeometry = 
    geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalEndcap);
 
  bool pass=false;
  // select interesting EcalRecHits (barrel)
  EBRecHitCollection::const_iterator itb;
  for (itb=barrelRecHitsHandle->begin(); itb!=barrelRecHitsHandle->end(); itb++) {
    EBDetId hit = EBDetId(itb->id());
    float eta = barrelGeometry->getGeometry(hit)->getPosition().eta();
    float et = itb->energy()/cosh(eta);
    float e  = itb->energy();
    
    

    // if iterating, correct by the previous calib constants found,
    // which are supplied in the form of correction 
    if (reiteration_) {
      et= et  * oldCalibs_[hit];
      e = e  * oldCalibs_[hit];
    }

    float et_thr = eCut_barl_/cosh(eta) + 1.;

    int sign = hit.ieta()>0 ? 1 : 0;

    if (e >  eCut_barl_ && et < et_thr && e_.goodCell_barl[abs(hit.ieta())-1][hit.iphi()-1][sign]) {
      etsum_barl_[abs(hit.ieta())-1][hit.iphi()-1][sign] += et;
      nhits_barl_[abs(hit.ieta())-1][hit.iphi()-1][sign] ++;
      pass =true;
    }//if energy

    if (eventSet_==1) {
      // apply a miscalibration to all crystals and increment the 
      // ET sum, combined for all crystals
      for (int imiscal=0; imiscal<kNMiscalBinsEB; imiscal++) {
        if (miscalEB_[imiscal]*e >  eCut_barl_&& miscalEB_[imiscal]*et < et_thr && e_.goodCell_barl[abs(hit.ieta())-1][hit.iphi()-1][sign]) {
          etsum_barl_miscal_[imiscal][abs(hit.ieta())-1] += miscalEB_[imiscal]*et;
        }
      }

      // spectra stuff
      if(spectra && hit.ieta()>0) //POSITIVE!!!
        //      if(spectra && hit.ieta()<0) //NEGATIVE!!!
        {
          et_spectrum_b_histos[abs(hit.ieta())-1]->Fill(et*1000.);
          e_spectrum_b_histos[abs(hit.ieta())-1]->Fill(e*1000.);
        }//if spectra
      
    }//if eventSet_==1
  }//for barl


  // select interesting EcalRecHits (endcaps)
  EERecHitCollection::const_iterator ite;
  for (ite=endcapRecHitsHandle->begin(); ite!=endcapRecHitsHandle->end(); ite++) {
    EEDetId hit = EEDetId(ite->id());
    float eta = abs(endcapGeometry->getGeometry(hit)->getPosition().eta());
    float phi = endcapGeometry->getGeometry(hit)->getPosition().phi();

    float et = ite->energy()/cosh(eta);
    float e  = ite->energy();

    // if iterating, multiply by the previous correction factor
    if (reiteration_) {
      et= et * oldCalibs_[hit];
      e = e * oldCalibs_[hit];
    }

    int sign = hit.zside()>0 ? 1 : 0;


    // changes of eCut_endc_ -> variable linearthr 
    // e_cut = ap + eta_ring*b

    double eCut_endc=0;
    for (int ring=0; ring<kEndcEtaRings; ring++) {

      if(eta>e_.etaBoundary_[ring] && eta<e_.etaBoundary_[ring+1])
        {  
          float eta_ring= abs(e_.cellPos_[ring][50].eta())  ;
          eCut_endc = ap_ + eta_ring*b_;

        }
    }


    float et_thr = eCut_endc/cosh(eta) + 1.;
   
    if (e > eCut_endc && et < et_thr && e_.goodCell_endc[hit.ix()-1][hit.iy()-1][sign]){
      etsum_endc_[hit.ix()-1][hit.iy()-1][sign] += et;
      nhits_endc_[hit.ix()-1][hit.iy()-1][sign] ++;
      pass=true;
    }
 
   

    if (eventSet_==1) {
      // apply a miscalibration to all crystals and increment the 
      // ET sum, combined for all crystals
      for (int imiscal=0; imiscal<kNMiscalBinsEE; imiscal++) {
        if (miscalEE_[imiscal]*e> eCut_endc && et*miscalEE_[imiscal] < et_thr && e_.goodCell_endc[hit.ix()-1][hit.iy()-1][sign]){
          int ring = e_.endcapRing_[hit.ix()-1][hit.iy()-1];
          etsum_endc_miscal_[imiscal][ring] += miscalEE_[imiscal]*et;
        }
      }

      // spectra stuff
      if(spectra && hit.zside()>0) //POSITIVE!!!

        {
          int ring = e_.endcapRing_[hit.ix()-1][hit.iy()-1];

          et_spectrum_e_histos[ring]->Fill(et*1000.);
          e_spectrum_e_histos[ring]->Fill(e*1000.);

          if(ring==16)
            {
              int iphi_endc = 0;
              for (int ip=0; ip<e_.nRing_[ring]; ip++) {
                if (phi==e_.phi_endc_[ip][ring]) iphi_endc=ip;
              }

            }
        }//if spectra

    }//if eventSet_==1
  }//for endc

  if (pass) {
    nevents_++;
    eventsinrun_++;
    eventsinlb_++;
  }
}
void PhiSymmetryCalibration::beginJob ( void  ) [virtual]

Called at beginning of job.

Reimplemented from edm::EDAnalyzer.

Definition at line 114 of file PhiSymmetryCalibration.cc.

References e_spectrum_b_histos, e_spectrum_e_histos, et_spectrum_b_histos, et_spectrum_e_histos, etsum_barl_, etsum_barl_miscal_, etsum_endc_, etsum_endc_miscal_, eventSet_, i, kBarlRings, kBarlWedges, kEndcEtaRings, kEndcWedgesX, kEndcWedgesY, kMiscalRangeEB, kMiscalRangeEE, kNMiscalBinsEB, kNMiscalBinsEE, kSides, miscalEB_, miscalEE_, nhits_barl_, nhits_endc_, relativeConstraints::ring, spectra, and matplotRender::t.

{


  // initialize arrays
  for (int sign=0; sign<kSides; sign++) {
    for (int ieta=0; ieta<kBarlRings; ieta++) {
      for (int iphi=0; iphi<kBarlWedges; iphi++) {
        etsum_barl_[ieta][iphi][sign]=0.;
        nhits_barl_[ieta][iphi][sign]=0;

      }
    }
    for (int ix=0; ix<kEndcWedgesX; ix++) {
      for (int iy=0; iy<kEndcWedgesY; iy++) {
        etsum_endc_[ix][iy][sign]=0.;
        nhits_endc_[ix][iy][sign]=0;
      }
    }
  }



  for (int imiscal=0; imiscal<kNMiscalBinsEB; imiscal++) {
    miscalEB_[imiscal]= (1-kMiscalRangeEB) + float(imiscal)* (2*kMiscalRangeEB/(kNMiscalBinsEB-1));
    for (int ieta=0; ieta<kBarlRings; ieta++) etsum_barl_miscal_[imiscal][ieta]=0.;
  }

  for (int imiscal=0; imiscal<kNMiscalBinsEE; imiscal++) {
    miscalEE_[imiscal]= (1-kMiscalRangeEE) + float(imiscal)* (2*kMiscalRangeEE/(kNMiscalBinsEE-1));
    for (int ring=0; ring<kEndcEtaRings; ring++) etsum_endc_miscal_[imiscal][ring]=0.;
  }



  // start spectra stuff
  if (eventSet_!=1) spectra = false;
  
  if(spectra)
    {
      ostringstream t;
      for(Int_t i=0;i<kBarlRings;i++)
        {
          t << "et_spectrum_b_" << i+1;
          et_spectrum_b_histos[i]=new TH1F(t.str().c_str(),";E_{T} [MeV]",50,0.,500.);
          t.str("");
          
          t << "e_spectrum_b_" << i+1;
          e_spectrum_b_histos[i]=new TH1F(t.str().c_str(),";E [MeV]",50,0.,500.);
          t.str("");
        
        }
      for(Int_t i=0;i<kEndcEtaRings;i++)
        {
          t << "et_spectrum_e_" << i+1;
          et_spectrum_e_histos[i]=new TH1F(t.str().c_str(),";E_{T} [MeV]",75,0.,1500.);
          t.str("");
          
          t << "e_spectrum_e_" << i+1;
          e_spectrum_e_histos[i]=new TH1F(t.str().c_str(),";E [MeV]",75,0.,1500.);
          t.str("");
        
        }
    }
  // end spectra stuff
}
void PhiSymmetryCalibration::endJob ( void  ) [virtual]

Called at end of job.

Reimplemented from edm::EDAnalyzer.

Definition at line 185 of file PhiSymmetryCalibration.cc.

References gather_cfg::cout, e_, e_spectrum_b_histos, e_spectrum_e_histos, EcalGeomPhiSymHelper::endcapRing_, et_spectrum_b_histos, et_spectrum_e_histos, etsum_barl_, etsum_endc_, eventSet_, f, getKfactors(), i, k_barl_, k_endc_, kBarlRings, kBarlWedges, kEndcEtaRings, kEndcWedgesX, kEndcWedgesY, kSides, nevents_, nhits_barl_, nhits_endc_, dbtoconf::out, relativeConstraints::ring, and spectra.

{

  edm::LogInfo("Calibration") << "[PhiSymmetryCalibration] At end of job";

  // start spectra stuff
  if(spectra)
    {
      TFile f("Espectra_plus.root","recreate");

      for(int i=0;i<kBarlRings;i++){
        et_spectrum_b_histos[i]->Write();
        e_spectrum_b_histos[i]->Write();
      }

      for(int i=0;i<kEndcEtaRings;i++){
        et_spectrum_e_histos[i]->Write();
        e_spectrum_e_histos[i]->Write();
      }

      f.Close();
    }
  



  if (eventSet_==1) {
    // calculate factors to convert from fractional deviation of ET sum from 
    // the mean to the estimate of the miscalibration factor
    getKfactors();

    std::ofstream k_barl_out("k_barl.dat", ios::out);
    for (int ieta=0; ieta<kBarlRings; ieta++)
      k_barl_out << ieta << " " << k_barl_[ieta] << endl;
    k_barl_out.close();

    std::ofstream k_endc_out("k_endc.dat", ios::out);
    for (int ring=0; ring<kEndcEtaRings; ring++)
      k_endc_out << ring << " " << k_endc_[ring] << endl;
    k_endc_out.close();
  }


  if (eventSet_!=0) {
    // output ET sums

    stringstream etsum_file_barl;
    etsum_file_barl << "etsum_barl_"<<eventSet_<<".dat";

    std::ofstream etsum_barl_out(etsum_file_barl.str().c_str(),ios::out);

    for (int ieta=0; ieta<kBarlRings; ieta++) {
      for (int iphi=0; iphi<kBarlWedges; iphi++) {
        for (int sign=0; sign<kSides; sign++) {
          etsum_barl_out << eventSet_ << " " << ieta << " " << iphi << " " << sign 
                         << " " << etsum_barl_[ieta][iphi][sign] << " " 
                         <<  nhits_barl_[ieta][iphi][sign] << endl;
        }
      }
    }
    etsum_barl_out.close();

    stringstream etsum_file_endc;
    etsum_file_endc << "etsum_endc_"<<eventSet_<<".dat";

    std::ofstream etsum_endc_out(etsum_file_endc.str().c_str(),ios::out);
    for (int ix=0; ix<kEndcWedgesX; ix++) {
      for (int iy=0; iy<kEndcWedgesY; iy++) {
        int ring = e_.endcapRing_[ix][iy];
        if (ring!=-1) {
          for (int sign=0; sign<kSides; sign++) {
            etsum_endc_out << eventSet_ << " " << ix << " " << iy << " " << sign 
                           << " " << etsum_endc_[ix][iy][sign] << " " 
                           << nhits_endc_[ix][iy][sign]<<" " 
                           << e_.endcapRing_[ix][iy]<<endl;
          }
        }
      }
    }
    etsum_endc_out.close();
  } 
  cout<<"Events processed " << nevents_<< endl;
}
void PhiSymmetryCalibration::endLuminosityBlock ( edm::LuminosityBlock const &  lb,
edm::EventSetup const &   
) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 589 of file PhiSymmetryCalibration.cc.

References edm::LuminosityBlockBase::beginTime(), gather_cfg::cout, edm::LuminosityBlockBase::endTime(), eventsinlb_, edm::LuminosityBlockBase::id(), edm::LuminosityBlockBase::run(), and edm::Timestamp::value().

                                                                                                 {

  
  if ((lb.endTime().value()>>32)- (lb.beginTime().value()>>32) <60 ) 
    return;

  std::cout  << "PHILB : run "<< lb.run()
             << " id " << lb.id() 
             << " start " << (lb.beginTime().value()>>32)
             << " end "   << (lb.endTime().value()>>32) 
             << " dur "   << (lb.endTime().value()>>32)- (lb.beginTime().value()>>32)
    
             << " npass "      << eventsinlb_  << std::endl;
  
  eventsinlb_=0;

}
void PhiSymmetryCalibration::endRun ( edm::Run run,
const edm::EventSetup  
) [virtual]

Definition at line 438 of file PhiSymmetryCalibration.cc.

References edm::RunBase::beginTime(), gather_cfg::cout, edm::RunBase::endTime(), eventsinrun_, edm::RunBase::run(), and edm::Timestamp::value().

                                                                    {
 
  
  std::cout  << "PHIREPRT : run "<< run.run() 
             << " start " << (run.beginTime().value()>>32)
             << " end "   << (run.endTime().value()>>32) 
             << " dur "   << (run.endTime().value()>>32)- (run.beginTime().value()>>32)
          
             << " npass "      << eventsinrun_  << std::endl;
  eventsinrun_=0;        
 
  return ;

}
void PhiSymmetryCalibration::getKfactors ( ) [private]

Definition at line 455 of file PhiSymmetryCalibration.cc.

References gather_cfg::cout, etsum_barl_miscal_, etsum_endc_miscal_, f, k_barl_, k_endc_, kBarlRings, kEndcEtaRings, kMiscalRangeEB, kMiscalRangeEE, kNMiscalBinsEB, kNMiscalBinsEE, miscalEB_, miscalEE_, relativeConstraints::ring, and matplotRender::t.

Referenced by endJob().

{

  float epsilon_T_eb[kNMiscalBinsEB];
  float epsilon_M_eb[kNMiscalBinsEB];

  float epsilon_T_ee[kNMiscalBinsEE];
  float epsilon_M_ee[kNMiscalBinsEE];

  std::vector<TGraph*>  k_barl_graph(kBarlRings);
  std::vector<TCanvas*> k_barl_plot(kBarlRings);

  for (int ieta=0; ieta<kBarlRings; ieta++) {
    for (int imiscal=0; imiscal<kNMiscalBinsEB; imiscal++) {
      int middlebin =  int (kNMiscalBinsEB/2);
      epsilon_T_eb[imiscal] = etsum_barl_miscal_[imiscal][ieta]/etsum_barl_miscal_[middlebin][ieta] - 1.;
      epsilon_M_eb[imiscal] = miscalEB_[imiscal] - 1.;
    }
    k_barl_graph[ieta] = new TGraph (kNMiscalBinsEB,epsilon_M_eb,epsilon_T_eb);
    k_barl_graph[ieta]->Fit("pol1");


    ostringstream t;
    t<< "k_barl_" << ieta+1; 
    k_barl_plot[ieta] = new TCanvas(t.str().c_str(),"");
    k_barl_plot[ieta]->SetFillColor(10);
    k_barl_plot[ieta]->SetGrid();
    k_barl_graph[ieta]->SetMarkerSize(1.);
    k_barl_graph[ieta]->SetMarkerColor(4);
    k_barl_graph[ieta]->SetMarkerStyle(20);
    k_barl_graph[ieta]->GetXaxis()->SetLimits(-1.*kMiscalRangeEB,kMiscalRangeEB);
    k_barl_graph[ieta]->GetXaxis()->SetTitleSize(.05);
    k_barl_graph[ieta]->GetYaxis()->SetTitleSize(.05);
    k_barl_graph[ieta]->GetXaxis()->SetTitle("#epsilon_{M}");
    k_barl_graph[ieta]->GetYaxis()->SetTitle("#epsilon_{T}");
    k_barl_graph[ieta]->Draw("AP");

    k_barl_[ieta] = k_barl_graph[ieta]->GetFunction("pol1")->GetParameter(1);
    std::cout << "k_barl_[" << ieta << "]=" << k_barl_[ieta] << std::endl;
  }


  std::vector<TGraph*>  k_endc_graph(kEndcEtaRings);
  std::vector<TCanvas*> k_endc_plot(kEndcEtaRings);

  for (int ring=0; ring<kEndcEtaRings; ring++) {
    for (int imiscal=0; imiscal<kNMiscalBinsEE; imiscal++) {
      int middlebin =  int (kNMiscalBinsEE/2);
      epsilon_T_ee[imiscal] = etsum_endc_miscal_[imiscal][ring]/etsum_endc_miscal_[middlebin][ring] - 1.;
      epsilon_M_ee[imiscal] = miscalEE_[imiscal] - 1.;
    }
    k_endc_graph[ring] = new TGraph (kNMiscalBinsEE,epsilon_M_ee,epsilon_T_ee);
    k_endc_graph[ring]->Fit("pol1");

    ostringstream t;
    t<< "k_endc_"<< ring+1;
    k_endc_plot[ring] = new TCanvas(t.str().c_str(),"");
    k_endc_plot[ring]->SetFillColor(10);
    k_endc_plot[ring]->SetGrid();
    k_endc_graph[ring]->SetMarkerSize(1.);
    k_endc_graph[ring]->SetMarkerColor(4);
    k_endc_graph[ring]->SetMarkerStyle(20);
    k_endc_graph[ring]->GetXaxis()->SetLimits(-1*kMiscalRangeEE,kMiscalRangeEE);
    k_endc_graph[ring]->GetXaxis()->SetTitleSize(.05);
    k_endc_graph[ring]->GetYaxis()->SetTitleSize(.05);
    k_endc_graph[ring]->GetXaxis()->SetTitle("#epsilon_{M}");
    k_endc_graph[ring]->GetYaxis()->SetTitle("#epsilon_{T}");
    k_endc_graph[ring]->Draw("AP");

    k_endc_[ring] = k_endc_graph[ring]->GetFunction("pol1")->GetParameter(1);
    std::cout << "k_endc_[" << ring << "]=" << k_endc_[ring] << std::endl;
  }
 
  TFile f("PhiSymmetryCalibration_kFactors.root","recreate");
  for (int ieta=0; ieta<kBarlRings; ieta++) { 
    k_barl_plot[ieta]->Write();
    delete k_barl_plot[ieta]; 
    delete k_barl_graph[ieta];
  }
  for (int ring=0; ring<kEndcEtaRings; ring++) { 
    k_endc_plot[ring]->Write();
    delete k_endc_plot[ring];
    delete k_endc_graph[ring];
  }
  f.Close();

}
void PhiSymmetryCalibration::setUp ( const edm::EventSetup setup)

Definition at line 551 of file PhiSymmetryCalibration.cc.

References e_, edm::FileInPath::fullPath(), edm::EventSetup::get(), h, oldcalibfile_, oldCalibs_, insertMaterial::readXML(), reiteration_, runTheMatrix::ret, EcalGeomPhiSymHelper::setup(), and statusThreshold_.

Referenced by analyze().

                                                            {

  edm::ESHandle<EcalChannelStatus> chStatus;
  setup.get<EcalChannelStatusRcd>().get(chStatus);

  edm::ESHandle<CaloGeometry> geoHandle;
  setup.get<CaloGeometryRecord>().get(geoHandle);

  e_.setup(&(*geoHandle), &(*chStatus), statusThreshold_);
 
  
  if (reiteration_){   
    
    EcalCondHeader h;
    // namespace fs = boost::filesystem;
//     fs::path p(oldcalibfile_.c_str(),fs::native);
//     if (!fs::exists(p)) edm::LogError("PhiSym") << "File not found: " 
//                                              << oldcalibfile_ <<endl;
    
    edm::FileInPath fip("Calibration/EcalCalibAlgos/data/"+oldcalibfile_);
    

    
    int ret=
    EcalIntercalibConstantsXMLTranslator::readXML(fip.fullPath(),h,oldCalibs_);    
    if (ret) edm::LogError("PhiSym")<<"Error reading XML files"<<endl;;
    
  } else {
    // in fact if not reiterating, oldCalibs_ will never be used
    edm::ESHandle<EcalIntercalibConstants> pIcal;      
    setup.get<EcalIntercalibConstantsRcd>().get(pIcal);
    oldCalibs_=*pIcal;

  }
  
}

Member Data Documentation

double PhiSymmetryCalibration::ap_ [private]

Definition at line 133 of file PhiSymmetryCalibration.h.

Referenced by analyze().

double PhiSymmetryCalibration::b_ [private]

Definition at line 134 of file PhiSymmetryCalibration.h.

Referenced by analyze().

Definition at line 102 of file PhiSymmetryCalibration.h.

std::string PhiSymmetryCalibration::barrelHits_ [private]

Definition at line 125 of file PhiSymmetryCalibration.h.

Referenced by analyze().

Definition at line 76 of file PhiSymmetryCalibration.h.

Referenced by analyze(), endJob(), and setUp().

std::vector<TH1F*> PhiSymmetryCalibration::e_spectrum_b_histos [private]
std::vector<TH1F*> PhiSymmetryCalibration::e_spectrum_e_histos [private]

Definition at line 124 of file PhiSymmetryCalibration.h.

Referenced by analyze().

Definition at line 129 of file PhiSymmetryCalibration.h.

Referenced by analyze().

Definition at line 103 of file PhiSymmetryCalibration.h.

std::string PhiSymmetryCalibration::endcapHits_ [private]

Definition at line 126 of file PhiSymmetryCalibration.h.

Referenced by analyze().

Definition at line 114 of file PhiSymmetryCalibration.h.

Definition at line 115 of file PhiSymmetryCalibration.h.

Definition at line 92 of file PhiSymmetryCalibration.h.

Definition at line 93 of file PhiSymmetryCalibration.h.

std::vector<TH1F*> PhiSymmetryCalibration::et_spectrum_b_histos [private]
std::vector<TH1F*> PhiSymmetryCalibration::et_spectrum_e_histos [private]

Definition at line 79 of file PhiSymmetryCalibration.h.

Referenced by analyze(), beginJob(), and endJob().

Definition at line 88 of file PhiSymmetryCalibration.h.

Referenced by analyze(), beginJob(), and getKfactors().

Definition at line 80 of file PhiSymmetryCalibration.h.

Referenced by analyze(), beginJob(), and endJob().

Definition at line 89 of file PhiSymmetryCalibration.h.

Referenced by analyze(), beginJob(), and getKfactors().

Definition at line 81 of file PhiSymmetryCalibration.h.

Definition at line 82 of file PhiSymmetryCalibration.h.

Definition at line 83 of file PhiSymmetryCalibration.h.

Definition at line 136 of file PhiSymmetryCalibration.h.

Referenced by analyze(), beginJob(), and endJob().

Definition at line 163 of file PhiSymmetryCalibration.h.

Referenced by analyze(), endLuminosityBlock(), and PhiSymmetryCalibration().

Definition at line 162 of file PhiSymmetryCalibration.h.

Referenced by analyze(), endRun(), and PhiSymmetryCalibration().

Definition at line 151 of file PhiSymmetryCalibration.h.

Referenced by analyze(), and PhiSymmetryCalibration().

Definition at line 97 of file PhiSymmetryCalibration.h.

Referenced by endJob(), and getKfactors().

Definition at line 98 of file PhiSymmetryCalibration.h.

Referenced by endJob(), and getKfactors().

const int PhiSymmetryCalibration::kMaxEndciPhi = 360 [static, private]

Definition at line 140 of file PhiSymmetryCalibration.h.

const float PhiSymmetryCalibration::kMiscalRangeEB = .05 [static, private]

Definition at line 71 of file PhiSymmetryCalibration.h.

Referenced by beginJob(), and getKfactors().

const float PhiSymmetryCalibration::kMiscalRangeEE = .10 [static, private]

Definition at line 74 of file PhiSymmetryCalibration.h.

Referenced by beginJob(), and getKfactors().

const int PhiSymmetryCalibration::kNMiscalBinsEB = 21 [static, private]

Definition at line 70 of file PhiSymmetryCalibration.h.

Referenced by analyze(), beginJob(), and getKfactors().

const int PhiSymmetryCalibration::kNMiscalBinsEE = 41 [static, private]

Definition at line 73 of file PhiSymmetryCalibration.h.

Referenced by analyze(), beginJob(), and getKfactors().

Definition at line 99 of file PhiSymmetryCalibration.h.

Referenced by analyze(), beginJob(), and getKfactors().

Definition at line 100 of file PhiSymmetryCalibration.h.

Referenced by analyze(), beginJob(), and getKfactors().

Definition at line 161 of file PhiSymmetryCalibration.h.

Referenced by analyze(), endJob(), and PhiSymmetryCalibration().

Definition at line 110 of file PhiSymmetryCalibration.h.

Definition at line 111 of file PhiSymmetryCalibration.h.

Definition at line 85 of file PhiSymmetryCalibration.h.

Referenced by analyze(), beginJob(), and endJob().

Definition at line 86 of file PhiSymmetryCalibration.h.

Referenced by analyze(), beginJob(), and endJob().

Definition at line 146 of file PhiSymmetryCalibration.h.

Referenced by setUp().

the old calibration constants (when reiterating, the last ones derived)

Definition at line 149 of file PhiSymmetryCalibration.h.

Referenced by analyze(), and setUp().

Definition at line 106 of file PhiSymmetryCalibration.h.

Definition at line 107 of file PhiSymmetryCalibration.h.

Definition at line 142 of file PhiSymmetryCalibration.h.

Definition at line 118 of file PhiSymmetryCalibration.h.

Definition at line 119 of file PhiSymmetryCalibration.h.

Definition at line 145 of file PhiSymmetryCalibration.h.

Referenced by analyze(), and setUp().

Definition at line 160 of file PhiSymmetryCalibration.h.

Referenced by analyze(), beginJob(), endJob(), and PhiSymmetryCalibration().

threshold in channel status beyond which channel is marked bad

Definition at line 138 of file PhiSymmetryCalibration.h.

Referenced by setUp().