#include "GausFitCenter.h" #include "GausFit.h" #include "TH1F.h" #include "TF1.h" #include "TGraphErrors.h" #include #include using namespace std; GausFitCenter::~GausFitCenter() { map >::iterator it1; for(it1=fGausFitMap.begin(); it1!=fGausFitMap.end(); ++it1) { map< string, GausFit*> ParticleMap; ParticleMap=it1->second; map< string, GausFit*>::iterator itParticleMap; map< string, GausFit*>::iterator endParticles=ParticleMap.end(); for(itParticleMap=ParticleMap.begin();itParticleMap!=endParticles; ++itParticleMap) { delete itParticleMap->second; itParticleMap->second=NULL; } } map::iterator it2; for(it2=fProjectionHistogram.begin(); it2!=fProjectionHistogram.end(); ++it2) { delete it2->second; it2->second=NULL; } map::iterator it3; for(it3=fBBGraphs.begin(); it3!=fBBGraphs.end(); ++it3) { delete it3->second; it3->second=NULL; } map::iterator it4; for(it4=fBBFit.begin(); it4!=fBBFit.end(); ++it4) { delete it4->second; it4->second=NULL; } } void GausFitCenter::AddGausHistogram(double P,const std::string &ParticleName, TH1F* projection) { map< string, GausFit*> ParticleMap; ParticleMap=fGausFitMap[P]; //get or create the particle map for momentum p if(ParticleMap.find(ParticleName)!=ParticleMap.end()) { cout << "Can' t add gaus histogram " << P << " - " << ParticleName; cout << " -> i found it in the GausFitMap already!" << endl; return; } GausFit *newGausFit=new GausFit(P,ParticleName,projection); newGausFit->Fit(); ParticleMap[ParticleName]=newGausFit; //add new Particle fGausFitMap[P]=ParticleMap; } void GausFitCenter::CreateBBGraphs() { map >::const_iterator itGausFitMap; map >::const_iterator end=fGausFitMap.end(); //map::iterator itGraphs=fBBGraphs.begin(); int iPoint=0; for(itGausFitMap=fGausFitMap.begin();itGausFitMap!=end;++itGausFitMap) { //i assume that GausFitMap is sorted in P map< string, GausFit*> ParticleMap; ParticleMap=itGausFitMap->second; map< string, GausFit*>::const_iterator itParticleMap; map< string, GausFit*>::const_iterator endParticles=ParticleMap.end(); for(itParticleMap=ParticleMap.begin();itParticleMap!=endParticles; ++itParticleMap) { GausFit* fit=itParticleMap->second; string Particle=itParticleMap->first; map::const_iterator pGraph=fBBGraphs.find(Particle); TGraphErrors *TheGraphToFill=NULL; if(pGraph==fBBGraphs.end() ) { TGraphErrors *p=new TGraphErrors(fGausFitMap.size()); fBBGraphs[Particle]=p; } TheGraphToFill=fBBGraphs[Particle]; assert(TheGraphToFill); TheGraphToFill->SetPoint(iPoint, fit->GetP(), fit->GetMean()); TheGraphToFill->SetPointError(iPoint, 0.01, fit->GetSigma()); cout << "GausFitCenter::CreateBBGraphs: fill Point Nr "; cout << iPoint << "(" << fit->GetP() << "," << fit->GetMean() << ")" << endl; } iPoint++; } } TGraphErrors *GausFitCenter::GetBBGraph(const std::string &ParticleName) const { map::const_iterator pGraph=fBBGraphs.find(ParticleName); if(pGraph!=fBBGraphs.end() ) { return pGraph->second; } return NULL; } void GausFitCenter::DrawResolution() const { } void GausFitCenter::DrawSeparationPower() const { } void GausFitCenter::Draw() const { } void GausFitCenter::GetSeparationPowerSummary(std::string &summary) const { } void GausFitCenter::PrintGausFitMap() const { map >::const_iterator itGausFitMap; map >::const_iterator end=fGausFitMap.end(); for(itGausFitMap=fGausFitMap.begin();itGausFitMap!=end; ++itGausFitMap) { map< string, GausFit*> ParticleMap; ParticleMap=itGausFitMap->second; double P=itGausFitMap->first; map< string, GausFit*>::const_iterator itParticleMap; map< string, GausFit*>::const_iterator endParticles=ParticleMap.end(); for(itParticleMap=ParticleMap.begin();itParticleMap!=endParticles; ++itParticleMap) { cout << "P: " << P << " " << itParticleMap->first << endl; } } }