+++ /dev/null
-#include "AliOADBPWG2Spectra.h"
-#include "AliOADBContainer.h"
-#include "TNamed.h"
-#include "TString.h"
-#include "TH1D.h"
-#include "TObject.h"
-#include "TList.h"
-#include "AliAnalysisManager.h"
-#include "TBrowser.h"
-#include "AliLog.h"
-
-ClassImp(AliOADBPWG2Spectra)
-
-const char * AliOADBPWG2Spectra::fgkDetectorNames[] = {"ITS", "ITSTPC", "TPC", "TOF", "TOFTPC", "Dummy", "Dummy"};
-const char * AliOADBPWG2Spectra::fgkPidTypeNames[] = {"GaussFit", "NSigma", "Bayes", "Kinks"};
-const char * AliOADBPWG2Spectra::fgkChargeTags[] = {"Pos", "Neg"};
-const char * AliOADBPWG2Spectra::fgkParticleNames[] = {"Pion", "Kaon", "Proton"};
-
-
-AliOADBPWG2Spectra::AliOADBPWG2Spectra():
-TNamed("Dummy", "OADB Object for PWG2 Spectra" ), fHistos(0)
-{
- // ctor
-
-
-
-}
-AliOADBPWG2Spectra::AliOADBPWG2Spectra(const char* name) :
-TNamed(name, "OADB Object for PWG2 Spectra" ), fHistos(0)
-
-{
- // ctor
- // name is appended to all histos (e.g. "Corrected")
-
- Init();
-
-}
-
-AliOADBPWG2Spectra::~AliOADBPWG2Spectra() {
- // dtor
- if(fHistos) delete fHistos;
-}
-
-void AliOADBPWG2Spectra::Init() {
- fHistos = new TList();
-}
-
-
-const char * AliOADBPWG2Spectra::GetOADBPWG2SpectraFileName() {
- // get file name to the OADB
- static TString filename;
- filename.Form("%s/PWG2/SPECTRA/spectraResults.root", AliOADBContainer::GetOADBPath());
- return filename.Data();
-
-}
-const char * AliOADBPWG2Spectra::GetHistoName(Int_t det, Int_t pidType, Int_t part,
- Int_t charge, const char * centrTag, Int_t centrBin) {
-
- // Returns histogram name
- // h[Name]_[Detector(s)]_[PIDType]_[Particle]_[Pos|Neg]_[MultiplicityOrCentralityIndex]
- // where "name" is the name of this container
-
-
- static TString histoName;
- if (centrTag) {
- if(!strcmp(centrTag,"MB")){
- // don't put a index for MB spectra
- histoName.Form("h%s_%s_%s_%s_%s_%s", GetName(), fgkDetectorNames[det], fgkPidTypeNames[pidType], fgkParticleNames[part], fgkChargeTags[charge], centrTag);
- }
- else {
- histoName.Form("h%s_%s_%s_%s_%s_%s_%d", GetName(), fgkDetectorNames[det], fgkPidTypeNames[pidType], fgkParticleNames[part], fgkChargeTags[charge], centrTag, centrBin);
- }
- }
- else
- histoName.Form("h%s_%s_%s_%s_%s", GetName(), fgkDetectorNames[det], fgkPidTypeNames[pidType], fgkParticleNames[part], fgkChargeTags[charge]);
-
- return histoName.Data();
-}
-
-TH1D * AliOADBPWG2Spectra::GetHisto(Int_t det, Int_t pidType, Int_t part,
- Int_t charge, const char * centrTag, Int_t centrBin){
-
- // Get an histogram from the list
- const char * name = GetHistoName(det,pidType,part,charge,centrTag,centrBin);
- TH1D * h = (TH1D*) fHistos->FindObject(name);
- return h;
-
-}
-
-void AliOADBPWG2Spectra::AddHisto(TH1D * h, Int_t det, Int_t pidType, Int_t part,
- Int_t charge, const char * centrTag, Int_t centrBin) {
- // Add a histogram to the list
- // Rename and rebinn it if necessary
-
- if(!h) {
- AliWarning("Empty pointer to histogram");
- return;
- }
-
- static TH1D * htest = BookHisto(kDetDummy, kGaussFit,kPion, kPos);
- const char * name = GetHistoName(det,pidType,part,charge,centrTag,centrBin);
- if(!CompareBinning(h,htest)){
- AliWarning("Histo have different binning! Rebinning to standard");
- {
- h = GetHistoStandardBinning(h,det,pidType,part,charge,centrTag,centrBin);
- }
- }
- if(!fHistos) {
- AliError("fHistos not allocated!!");
- return;
- }
-
- TH1D * hold = (TH1D*) fHistos->FindObject(name);
- if (hold) fHistos->Remove(hold);
- delete hold;
- if(strcmp(h->GetName(),name)){
- AliWarning(Form("Histogram names are not consinstent %s-%s, resetting", h->GetName(),name));
- h->SetName(name);
- }
- fHistos->Add(h);
-
-
-}
-
-TH1D * AliOADBPWG2Spectra::BookHisto(Int_t det, Int_t pidType, Int_t part,
- Int_t charge, const char * centrTag, Int_t centrBin) {
-
- // book a histogram according to the template. All the histograms
- // should have the same binning (if possible/reasonable) to
- // facilitate the compoarison and the combination
-
- const Float_t templBins[] = {0.05,0.1,0.12,0.14,0.16,0.18,0.20,0.25,0.30,0.35,0.4,0.45,0.5,0.55,0.6,0.65,0.7,0.75,0.8,0.85,0.9,0.95,1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.0,2.1,2.2,2.3,2.4,2.5,2.6,2.7,2.8,2.9,3.0,3.2,3.4,3.6,3.8,4.0,4.2,4.4,4.6,4.8,5.0};
- Int_t nbinsTempl=52;
- const char * name = GetHistoName(det,pidType,part,charge,centrTag,centrBin);
- TH1D * h = new TH1D(name, name, nbinsTempl, templBins);
- return h;
-
-}
-
-void AliOADBPWG2Spectra::Browse(TBrowser *b)
-{
- // Browse this object.
- // If b=0, there is no Browse call TObject::Browse(0) instead.
- // This means TObject::Inspect() will be invoked indirectly
-
-
- if (b) {
- b->Add(fHistos);
- }
- else
- TObject::Browse(b);
-}
-
-TH1D * AliOADBPWG2Spectra::GetHistoStandardBinning(const TH1D* h, Int_t det, Int_t pidType, Int_t part,
- Int_t charge, const char * centrTag, Int_t centrBin) {
- // Returns a histo with the standard binning and the same content of h
- // if the bins of h are not a subset of the standard binning, it crashes with a fatal error
- // under and overflows are ignored
-
- // 1. Create a histogram with the standard binning
- TH1D * hStd = BookHisto(det, pidType, part, charge, centrTag, centrBin);
- Int_t nBinsH1=hStd->GetNbinsX();
- Int_t nBinsH2=h->GetNbinsX();
- // Loop over standard bins,
- for(Int_t iBin=1; iBin<=nBinsH1; iBin++){
- Float_t lowPtH1 =hStd->GetBinLowEdge(iBin);
- Float_t binWidH1=hStd->GetBinWidth(iBin);
- // Loop over H2 bins and find overlapping bins to H1
- for(Int_t jBin=1; jBin<=nBinsH2; jBin++){
- Float_t lowPtH2=h->GetBinLowEdge(jBin);
- Float_t binWidH2=h->GetBinWidth(jBin);
- if(TMath::Abs(lowPtH1-lowPtH2)<0.001 && TMath::Abs(binWidH2-binWidH1)<0.001){
- hStd->SetBinContent(iBin, h->GetBinContent(jBin));
- hStd->SetBinError (iBin, h->GetBinError (jBin));
- break;
- }
- if(TMath::Abs(lowPtH1-lowPtH2)<0.001){
- AliError(Form("Found partially overlapping bins! [(%f,%f)(%f,%f)]",lowPtH1,binWidH1,lowPtH2,binWidH2));
- continue;
- }
- }
- }
- return hStd;
-}
-
-Bool_t AliOADBPWG2Spectra::CompareBinning(TH1 * h1, TH1 * h2) {
-
- // returns true if h1 and h2 have the same binning
- Int_t nbins1 = h1->GetNbinsX();
- Int_t nbins2 = h2->GetNbinsX();
-
- if(nbins1 != nbins2) return kFALSE;
-
- for(Int_t ibin = 1; ibin <= nbins1; ibin++){
- if(TMath::Abs(h1->GetBinLowEdge(ibin) - h2->GetBinLowEdge(ibin))>0.001) return kFALSE;
- if(TMath::Abs(h1->GetBinWidth(ibin) - h2->GetBinWidth(ibin))>0.001) return kFALSE;
- }
-
- return kTRUE;
-}
+++ /dev/null
-#ifndef AliOADBPWG2Spectra_H
-#define AliOADBPWG2Spectra_H
-
-//-------------------------------------------------------------------------
-// OADB interface for the PWG2 spectra
-// Author: Michele Floris, CERN
-//
-// -------------------------------------------------------------------------
-#include "TNamed.h"
-#include "TList.h"
-
-class TList;
-class TH1D;
-class TH1;
-class AliOADBPWG2Spectra : public TNamed {
-
- public :
-
- enum EPWG2SpectraDetector { kITSsa=0, kITSTPC, kTPC, kTOF, kTOFTPC, kNDetectors, kDetDummy };
- enum EPWG2SpectraPIDType { kGaussFit=0, kNSigma, kBayes, kKinks, kNPIDTypes };
- enum EPWG2SpectraCharge { kPos=0, kNeg, kNCharge };
- enum EPWG2SpectraParticle { kPion = 0, kKaon, kProton, kNParticle };
- AliOADBPWG2Spectra();
- AliOADBPWG2Spectra(const char* name);
- virtual ~AliOADBPWG2Spectra();
-
- void Init();
-
- static const char * GetOADBPWG2SpectraFileName();
- const char * GetHistoName(Int_t det, Int_t pidType, Int_t part,
- Int_t charge, const char * centrTag = 0, Int_t centrBin = -1) ;
- void AddHisto(TH1D * h, Int_t det, Int_t pidType, Int_t part,
- Int_t charge, const char * centrTag = 0, Int_t centrBin = -1) ;
- TH1D * GetHisto(Int_t det, Int_t pidType, Int_t part,
- Int_t charge, const char * centrTag = 0, Int_t centrBin = -1);
- TH1D * BookHisto(Int_t det, Int_t pidType, Int_t part,
- Int_t charge, const char * centrTag = 0, Int_t centrBin = -1) ;
-
- TH1D * GetHistoStandardBinning(const TH1D* h, Int_t det, Int_t pidType, Int_t part,
- Int_t charge, const char * centrTag, Int_t centrBin) ;
-
- static const char * GetDetectorName(Int_t i) {return fgkDetectorNames[i];}
- static const char * GetPIDName(Int_t i) {return fgkPidTypeNames[i];}
- static const char * GetChargeName(Int_t i) {return fgkChargeTags[i];}
- static const char * GetParticleName(Int_t i) {return fgkParticleNames[i];}
-
- Bool_t CompareBinning(TH1 * h1, TH1 * h2) ;
-
- virtual void Print (const Option_t * opt = "") const { fHistos->Print(opt); }
-
-// Browsable
- virtual Bool_t IsFolder() const { return kTRUE; }
- void Browse(TBrowser *b);
-
- static const char * fgkDetectorNames[] ; // Detector tags
- static const char * fgkPidTypeNames[] ; // Name of the PID technique
- static const char * fgkChargeTags[] ; // tags for charges
- static const char * fgkParticleNames[] ; // Particle tags
-
-
- private:
- AliOADBPWG2Spectra(const AliOADBPWG2Spectra& cont);
- AliOADBPWG2Spectra& operator=(const AliOADBPWG2Spectra& cont);
-
- private :
-
- TList * fHistos; // List containtig all the histograms
-
- ClassDef(AliOADBPWG2Spectra, 2);
-};
-
-#endif
#include <iostream>
#include "TH1D.h"
#include "TInterpreter.h"
+#include "AliBWFunc.h"
+#include "TDatabasePDG.h"
using namespace std;
+
class MyMainFrame : public TGMainFrame {
private:
AliOADBPWG2Spectra *fOADBSpectra; // spectra OADB
AliOADBContainer *fOADBContainer; // OADB container
+ Double_t fMass[3]; //masses
+ AliBWFunc * fFuncMan; // functions
static const char * fkContainers[];
static const Int_t fkNContainers ;
static const char * fkCentrTags[];
void DoExit();
void DoDraw();
void DoRatio();
+ void DoFit();
void DoLegend();
void DoLoad();
void DoClear();
const char * MyMainFrame::fkContainers[] = {"Corrected", "Raw"};
const Int_t MyMainFrame::fkNContainers = 2;
-const char * MyMainFrame::fkCentrTags[] = {"MB", "Ntracks", "SPD2"};
-const Int_t MyMainFrame::fkNCentrTags = 3;
+const char * MyMainFrame::fkCentrTags[] = {"V0M", "MB", "Ntracks", "SPD2"};
+const Int_t MyMainFrame::fkNCentrTags = 4;
void MyMainFrame::DoSelectedDetector(Int_t id) {
// Change the analysis type based on the detector
}
+void MyMainFrame::DoFit()
+{
+ // print to file
+ static TF1 * func = 0;
+ if(func) delete func;
+ func = fFuncMan->GetLevi(fMass[fComboParticle->GetSelected()], 0.12, 7, 1.5);
+ TCanvas *c1 = fEcan->GetCanvas();
+ TH1D * h = (TH1D*) c1->GetListOfPrimitives()->At(c1->GetListOfPrimitives()->GetEntries()-1);
+ h->Fit(func,"","same");
+ c1->Update();
+ c1->Modified();
+ c1->Update();
+
+}
+
void MyMainFrame::DoPrint()
{
// print to file
TString fileName = AliOADBPWG2Spectra::GetOADBPWG2SpectraFileName();
TFile * f = new TFile (fileName);
fOADBContainer = (AliOADBContainer*) f->Get(fkContainers[fComboContainer->GetSelected()]);
+ if(!fOADBContainer) return;
f->Close();
fOADBSpectra = (AliOADBPWG2Spectra*) fOADBContainer->GetObject(atoi(fRunNumber->GetText() ));
if(!fOADBSpectra) fOADBContainer->List();
fComboCentr->Select(0);
// Text fields
- fRunNumber; // run number
fTextCentrBin = new TGTextEntry (vframeButtons, "1");
fTextCentrBin->Resize(120,20);
vframeButtons->AddFrame(fTextCentrBin, new TGLayoutHints(kLHintsCenterX, 5, 5, 3, 4));
TGTextButton *print = new TGTextButton(vframeButtons, "&Print");
print->Connect("Clicked()", "MyMainFrame", this, "DoPrint()");
vframeButtons->AddFrame(print, new TGLayoutHints(kLHintsCenterX, 5, 5, 3, 4));
+ TGTextButton *fit = new TGTextButton(vframeButtons, "&Fit");
+ fit->Connect("Clicked()", "MyMainFrame", this, "DoFit()");
+ vframeButtons->AddFrame(fit, new TGLayoutHints(kLHintsCenterX, 5, 5, 3, 4));
TGTextButton *exit = new TGTextButton(vframeButtons, "&Exit ");
exit->Connect("Pressed()", "MyMainFrame", this, "DoExit()");
vframeButtons->AddFrame(exit, new TGLayoutHints(kLHintsCenterX, 5, 5, 3, 4));
// Map main frame
MapWindow();
+
+ // Misc init
+ fMass[AliOADBPWG2Spectra::kPion] = TDatabasePDG::Instance()->GetParticle("pi+")->Mass();
+ fMass[AliOADBPWG2Spectra::kKaon] = TDatabasePDG::Instance()->GetParticle("K+")->Mass();
+ fMass[AliOADBPWG2Spectra::kProton] = TDatabasePDG::Instance()->GetParticle("proton")->Mass();
+
+ fFuncMan = new AliBWFunc;
+ fFuncMan->SetVarType(AliBWFunc::kdNdpt);
+
}