Skip to content
Snippets Groups Projects
Commit aff933f6 authored by Bertram Kopf's avatar Bertram Kopf
Browse files

added histos for pbarp test tools

parent 10431536
No related branches found
No related tags found
No related merge requests found
#include <getopt.h>
#include <fstream>
#include <algorithm>
#include <boost/algorithm/string.hpp>
#include "Examples/pbarp/pbarpHist.hh"
#include "Examples/pbarp/pbarpEnv.hh"
......@@ -33,9 +34,41 @@ pbarpHist::pbarpHist(boost::shared_ptr<AbsLhNew> theLh, fitParamsNew& theFitPara
std::vector<EvtDataNew*>::const_iterator it=dataList.begin();
while(it!=dataList.end())
{
fillMassHists((*it), 1.);
double weight = (*it)->evtWeight;
fillMassHists((*it), weight, _massDataHistMap);
++it;
}
const std::vector<EvtDataNew*> mcList=theEvtList->getMcVecs();
it=mcList.begin();
while(it!=mcList.end())
{
double evtWeight = (*it)->evtWeight;
fillMassHists((*it), evtWeight, _massMcHistMap);
double fitWeight= theLh->calcEvtIntensity( (*it), theFitParams );
fillMassHists((*it), evtWeight*fitWeight, _massFitHistMap);
++it;
}
double integralDataWoWeight=(double) theEvtList->getDataVecs().size();
Info <<"No of data events without weight " << integralDataWoWeight ; // << endmsg;
double integralDataWWeight=(double) theEvtList->NoOfWeightedDataEvts();
Info <<"No of data events with weight " << integralDataWWeight ; // << endmsg;
double integralMC=(double) theEvtList->NoOfWeightedMcEvts();
Info <<"No of MC events " << integralMC ; // << endmsg;
Info <<"scaling factor " << integralDataWWeight/integralMC ; // << endmsg;
double scaleFactor = integralDataWWeight/integralMC;
std::map<boost::shared_ptr<massHistData>, TH1F*, pawian::Collection::SharedPtrLess >::iterator itMassMap;
for(itMassMap= _massFitHistMap.begin(); itMassMap!= _massFitHistMap.end(); ++itMassMap){
itMassMap->second->Scale(scaleFactor);
}
}
pbarpHist::~pbarpHist(){
......@@ -51,17 +84,34 @@ void pbarpHist::initRootStuff(){
std::vector<std::vector<std::string> >::iterator itVecStr;
for(itVecStr=histMassNameVec.begin(); itVecStr!=histMassNameVec.end(); ++itVecStr){
boost::shared_ptr<massHistData> tmpMassHistData(new massHistData(*itVecStr));
std::string histName="data"+tmpMassHistData->_name;
TH1F* currentMassHist=new TH1F(histName.c_str(), histName.c_str(), 100., 0., 2.);
_massHistMap[tmpMassHistData]=currentMassHist;
std::string tmpBaseName=tmpMassHistData->_name;
boost::replace_all(tmpBaseName,"+","p");
boost::replace_all(tmpBaseName,"-","m");
std::string histName="data"+tmpBaseName;
std::string histDescription = "M("+tmpMassHistData->_name+") (data)";
TH1F* currentMassDataHist=new TH1F(histName.c_str(), histDescription.c_str(), 100., 0., 2.);
currentMassDataHist->Sumw2();
_massDataHistMap[tmpMassHistData]=currentMassDataHist;
histName="MC"+tmpBaseName;
histDescription = "M("+tmpMassHistData->_name+") (MC)";
TH1F* currentMassMcHist=new TH1F(histName.c_str(), histDescription.c_str(), 100., 0., 2.);
currentMassMcHist->Sumw2();
_massMcHistMap[tmpMassHistData]=currentMassMcHist;
histName="Fit"+tmpBaseName;
histDescription = "M("+tmpMassHistData->_name+") (fit)";
TH1F* currentMassFitHist=new TH1F(histName.c_str(), histDescription.c_str(), 100., 0., 2.);
currentMassFitHist->Sumw2();
_massFitHistMap[tmpMassHistData]=currentMassFitHist;
}
}
void pbarpHist::fillMassHists(EvtDataNew* theData, double weight){
void pbarpHist::fillMassHists(EvtDataNew* theData, double weight, std::map<boost::shared_ptr<massHistData>, TH1F*, pawian::Collection::SharedPtrLess >& toFill){
std::map<boost::shared_ptr<massHistData>, TH1F*, pawian::Collection::SharedPtrLess >::iterator it;
for(it= _massHistMap.begin(); it!= _massHistMap.end(); ++it){
for(it= toFill.begin(); it!= toFill.end(); ++it){
//get relevant 4 vecs
Vector4<double> combined4Vec(0.,0.,0.,0.);
......
......@@ -60,7 +60,6 @@ struct massHistData {
class TFile;
//class TH2F;
class TH1F;
// class TNtuple;
class pbarpHist {
......@@ -72,12 +71,13 @@ public:
protected:
private:
void fillMassHists(EvtDataNew* theData, double weight);
void fillMassHists(EvtDataNew* theData, double weight, std::map<boost::shared_ptr<massHistData>, TH1F*, pawian::Collection::SharedPtrLess >& toFill);
TFile* _theTFile;
std::map<boost::shared_ptr<massHistData>, TH1F*, pawian::Collection::SharedPtrLess > _massHistMap;
std::map<boost::shared_ptr<massHistData>, TH1F*, pawian::Collection::SharedPtrLess > _massDataHistMap;
std::map<boost::shared_ptr<massHistData>, TH1F*, pawian::Collection::SharedPtrLess > _massMcHistMap;
std::map<boost::shared_ptr<massHistData>, TH1F*, pawian::Collection::SharedPtrLess > _massFitHistMap;
void initRootStuff();
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment