• Main Page
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

/Users/jmonk/Physics/ForIA/src/AnalysisTools/TrackDicer.cxx

Go to the documentation of this file.
00001 #include "ForIA/AnalysisTools/TrackDicer.hh"
00002 #include "ForIA/Units.hh"
00003 #include "ForIA/IDataLoader.hh"
00004 
00005 #include "TH2D.h"
00006 
00007 namespace ForIA{
00008   
00009   TrackDicer::TrackDicer(): m_doInitialise(true){
00010     
00011   }
00012   
00013   void TrackDicer::initialise(Efficiency effType){
00014     
00015     if(!m_doInitialise) return;
00016     
00017     DataLoaderPtr dl = IDataLoader::create();
00018     
00019     dl->open("Root/MinBias/Part7TeV_v20.root");
00020     
00021     string plotName = "EfficiencyChargedPrimaryStable";
00022     
00023     m_efficiencyPlot = dl->retrieve<TH2D>(plotName);
00024     
00025     if(m_efficiencyPlot == 0) throw std::runtime_error("TrackDicer::initialise(): Could not get plot " + plotName);
00026     
00027     m_efficiencyType = effType;
00028     
00029     string systPlotName = "Eff_Syst_Unc";
00030     
00031     if(effType != NOMINAL){
00032       m_efficiencySystematic = dl->retrieve<TH2D>(systPlotName);
00033     
00034       if(m_efficiencySystematic == 0) throw std::runtime_error
00035         ("TrackDicer::initialise(): Could not get plot " + systPlotName);
00036     }
00037     // see http://www.gnu.org/software/gsl/manual/html_node/Random-number-generator-algorithms.html
00038     m_randomGenerator = gsl_rng_alloc (gsl_rng_taus2);
00039     
00040     gsl_rng_set(m_randomGenerator, 14021980);
00041     
00042     m_doInitialise = false;
00043     
00044     return;
00045   }
00046 
00048   double TrackDicer::trackEfficiency(IFourMomentumConstPtr track)const{
00049     
00050     if(m_doInitialise) throw std::runtime_error
00051       ("TrackDicer::trackEfficiency: Has not been initialised");
00052     
00053     int xbin = m_efficiencyPlot->GetXaxis()->FindBin(track->PT()/GeV);
00054     int ybin = m_efficiencyPlot->GetYaxis()->FindBin(track->eta());
00055     
00056 //    std::cout<<track<<", xbin: "<<xbin<<", ybin: "<<ybin<<std::endl;
00057     
00058     int bin = m_efficiencyPlot->GetBin(xbin, ybin);
00059     
00060     if(m_efficiencyType == NOMINAL){
00061       return m_efficiencyPlot->GetBinContent(bin);
00062     }
00063     
00064     // for some reason the bin indexing on the systematics plots 
00065     // is different to that on the nominal values plot
00066     
00067     int systXBin = m_efficiencySystematic->GetXaxis()->FindBin(track->PT() / GeV);
00068     int systYBin = m_efficiencySystematic->GetYaxis()->FindBin(track->eta() / GeV);
00069     
00070     int systBin = m_efficiencySystematic->GetBin(systXBin, systYBin);
00071     
00072     double syst = m_efficiencySystematic->GetBinContent(systBin);
00073     
00074     if(m_efficiencyType == SYST_UP){
00075       return m_efficiencyPlot->GetBinContent(bin) + syst;
00076     }else if(m_efficiencyType == SYST_DOWN){
00077       return m_efficiencyPlot->GetBinContent(bin) - syst;
00078     }
00079     
00080     return 0.;
00081   }
00082 
00083 }

Generated on Mon Jul 30 2012 16:56:35 for ForIA by  doxygen 1.7.2