#include #include #include "TF1.h" #include "TH2F.h" #include #include #include #include #include "TFile.h" #include "TTree.h" #include "TH2.h" #include "TCanvas.h" #include "TProfile.h" #include "TF1.h" #include "TGraph.h" #include "TChain.h" #include "TStopwatch.h" #include "TLegend.h" #include "TMultiGraph.h" #include "TROOT.h" #include "SepPoHandler.h" #include "g_defines.h" SepPoHandler::SepPoHandler() { nHistograms=0; map::const_iterator cit, cit2; for(cit=PDGMap.begin(); cit!=PDGMap.end(); cit++) { for(cit2=cit; cit2!=PDGMap.end(); cit2++) { if(cit->first && cit2->first && cit->second!=cit2->second ) { //no summary and not the same Particle Name SeparationPower *pSepPo=new SeparationPower(cit->second, cit2->second); vSepPos.push_back(pSepPo); //dedxlog << "Created SeparationPower for: " << cit->second << "-" << cit2->second << endl; } } } } SepPoHandler::~SepPoHandler() { vector::iterator it; for(it=vSepPos.begin(); it!=vSepPos.end(); it++) { delete(*it); } } void SepPoHandler::FillSeparationPower(map > &FitMap) { vector::iterator it; for(it=vSepPos.begin(); it!=vSepPos.end(); it++) { (*it)->FillSeparationPower(FitMap); } } //Draw the SeparationPower for one Particlee with all the other Particles void SepPoHandler::Draw(string strName, TCanvas *pCanvas) { short int Colors[]={kRed, kGreen, kBlue, kMagenta, kYellow, kCyan, kRed, kGreen, kBlue, kMagenta, kYellow, kCyan}; assert( sizeof(Colors)/sizeof(short int) >= PDGMap.size() ); Int_t nColor=0; vector::const_iterator cit; ostringstream StackTitle; StackTitle << "SP_" << strName; TMultiGraph *mg=new TMultiGraph(StackTitle.str().c_str(), StackTitle.str().c_str()); assert(mg); TLegend *legend=new TLegend(0.39,0.6,0.9,0.8); assert(legend); legend->SetTextFont(72); legend->SetTextSize(0.04); for(cit=vSepPos.begin(); cit!=vSepPos.end(); cit++) { if ((*cit)->IsFor(strName)) { TGraph *pG=(*cit)->CreateGraph(); pG->SetMarkerStyle(20); pG->SetMarkerSize(0.6); pG->SetMarkerColor(Colors[nColor++]); mg->Add(pG); ostringstream legendText; legendText << strName << " - " << (*cit)->GetTheOtherParticle(strName); legend->AddEntry( pG, legendText.str().c_str() ); } } mg->Draw("AP"); assert(mg->GetHistogram()); assert(mg->GetHistogram()->GetXaxis()); mg->GetHistogram()->GetXaxis()->SetTitle("|P|"); legend->Draw(); } TH2F *SepPoHandler::CreateHistogram() { ostringstream HistogramName; HistogramName << "SP_" << nHistograms; nHistograms++; ostringstream HistoTitle; //the histograms are accesible over their names, i hope TH2F *pHisto = new TH2F(HistogramName.str().c_str(), HistogramName.str().c_str() , 300, 0, 3, 1400, 0, 14); //dedxlog << "Creating Histogram: " << HistogramName.str().c_str() << endl; assert(pHisto); pHisto->GetXaxis()->SetTitle("|P|"); pHisto->GetYaxis()->SetTitle("SeparationPower"); return(pHisto); } void SepPoHandler::Draw() { ostringstream CanvasName; CanvasName << "SepPo_Canvas_"; ostringstream CanvasTitle; TCanvas *pCanvas = new TCanvas(CanvasName.str().c_str(), CanvasName.str().c_str() , 30,30,500,350); assert(pCanvas); if( (PDGMap.size())%2 == 0 ) { pCanvas->Divide(2,(PDGMap.size())/2); } else { pCanvas->Divide(2,(PDGMap.size()+1)/2); } Int_t nCanvas=1; map::const_iterator cit; for(cit=PDGMap.begin(); cit!=PDGMap.end(); cit++) { if(cit->first) { pCanvas->cd(nCanvas++); Draw(cit->second, pCanvas); } } }