CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch13/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])/((double) denominator[j]);
00029       else if (type=="fakerate")
00030         value = 1-((double) numerator[j])/((double) denominator[j]);
00031       else return;
00032       err = sqrt( value*(1-value)/(double) denominator[j] );
00033       h->setBinContent(j+1, value);
00034       h->setBinError(j+1,err);
00035     }
00036     else {
00037       h->setBinContent(j+1, 0);
00038     }
00039   }
00040 }
00041 
00042 
00043 
00044 
00045 void MTVHistoProducerAlgo::BinLogX(TH1*h){  
00046   TAxis *axis = h->GetXaxis();
00047   int bins = axis->GetNbins();
00048   
00049   float from = axis->GetXmin();
00050   float to = axis->GetXmax();
00051   float width = (to - from) / bins;
00052   float *new_bins = new float[bins + 1];
00053   
00054   for (int i = 0; i <= bins; i++) {
00055     new_bins[i] = TMath::Power(10, from + i * width);
00056     
00057   }
00058   axis->Set(bins, new_bins);
00059   delete[] new_bins;
00060 }
00061 
00062 
00063 //void MTVHistoProducerAlgo::
00064 //void MTVHistoProducerAlgo::
00065