CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC4_patch1/src/Validation/RecoTrack/src/MTVHistoProducerAlgo.cc

Go to the documentation of this file.
00001 #include "Validation/RecoTrack/interface/MTVHistoProducerAlgo.h"
00002 
00003 void MTVHistoProducerAlgo::doProfileX(TH2 * th2, MonitorElement* me){
00004   if (th2->GetNbinsX()==me->getNbinsX()){
00005     TProfile * p1 = (TProfile*) th2->ProfileX();
00006     p1->Copy(*me->getTProfile());
00007     delete p1;
00008   } else {
00009     throw cms::Exception("MultiTrackValidator") << "Different number of bins!";
00010   }
00011 }
00012 
00013 
00014 void MTVHistoProducerAlgo::fillPlotFromVector(MonitorElement* h, std::vector<int>& vec) {
00015   for (unsigned int j=0; j<vec.size(); j++){
00016     h->setBinContent(j+1, vec[j]);
00017   }
00018 }
00019 
00020 void MTVHistoProducerAlgo::fillPlotFromVectors(MonitorElement* h, 
00021                                                std::vector<int>& numerator, 
00022                                                std::vector<int>& denominator,
00023                                                std::string type){
00024   double value,err;
00025   for (unsigned int j=0; j<numerator.size(); j++){
00026     if (denominator[j]!=0){
00027       if (type=="effic"){
00028         value = ((double) numerator[j])*1./((double) denominator[j]);
00029         err = sqrt( value*(1-value)/(double) denominator[j] );
00030       } else if (type=="fakerate"){
00031         value = 1-((double) numerator[j])*1./((double) denominator[j]);
00032         err = sqrt( value*(1-value)/(double) denominator[j] );
00033       } else if (type=="pileup"){
00034         value = ((double) numerator[j])*1./((double) denominator[j]);
00035         err = sqrt( value*(1+value)/(double) denominator[j] );
00036       } else return;
00037       h->setBinContent(j+1, value);
00038       h->setBinError(j+1, err);
00039     }
00040     else {
00041       h->setBinContent(j+1, 0.);
00042       h->setBinError(j+1, 0.);
00043     }
00044   }
00045 }
00046 
00047 
00048 
00049 
00050 void MTVHistoProducerAlgo::BinLogX(TH1*h){  
00051   TAxis *axis = h->GetXaxis();
00052   int bins = axis->GetNbins();
00053   
00054   float from = axis->GetXmin();
00055   float to = axis->GetXmax();
00056   float width = (to - from) / bins;
00057   float *new_bins = new float[bins + 1];
00058   
00059   for (int i = 0; i <= bins; i++) {
00060     new_bins[i] = TMath::Power(10, from + i * width);
00061     
00062   }
00063   axis->Set(bins, new_bins);
00064   delete[] new_bins;
00065 }
00066 
00067 
00068 //void MTVHistoProducerAlgo::
00069 //void MTVHistoProducerAlgo::
00070