Added an initial template for a histogram fitting class.
#pragma link C++ class AliRsnMonitorTrack+;
#pragma link C++ class AliRsnAnalysisMonitorTask+;
-//#pragma link C++ class AliRsnFitResult+;
+#pragma link C++ class AliRsnFitResult+;
#endif
// retrieve number of bins for each axis
Int_t *nBins = new Int_t[nAxes];
TArrayD *binLimits = new TArrayD[nAxes];
- for (iaxis = 0; iaxis < nAxes; iaxis++) {
+ for (iaxis = 0; iaxis < nAxes; iaxis++)
+ {
AliRsnValue *fcnAxis = (AliRsnValue*)fAxisList.At(iaxis);
binLimits[iaxis] = fcnAxis->GetArray();
nBins[iaxis] = binLimits[iaxis].GetSize() - 1;
#include "AliRsnVAnalysisTaskSE.h"
#include "AliRsnEvent.h"
#include "AliRsnMother.h"
-#include "AliRsnPIDIndex.h"
class AliPID;
// settings
void SetEventCuts(AliRsnCutSet *const cuts) {fEventCuts = cuts;}
void AddPairDef(AliRsnPairDef *pairDef);
- void AddStepMC(AliRsnCutManager *mgr) {fStepListMC.AddLast(mgr);}
+ void AddStepMC(AliRsnCutManager *mgr) {fStepListMC.AddLast(mgr);}
void AddStepESD(AliRsnCutManager *mgr) {fStepListESD.AddLast(mgr);}
void AddAxis(AliRsnValue *axis) {fAxisList.AddLast(axis);}
if (fHistogram) delete fHistogram;
- fHistogram = (TH1F*)histogram->Clone();
+ fHistogram = (TH1D*)histogram->Clone();
fHistogram->SetName(Form("h_%s_%s", GetName(), histogram->GetName()));
fHistogram->SetTitle(histogram->GetTitle());
}
Double_t NormLinear(Double_t *x, Double_t *par);
Double_t NormBreitWigner(Double_t *x, Double_t *par);
Double_t NormGaus(Double_t *x, Double_t *par);
+
Double_t Signal(Double_t *x, Double_t *par);
Double_t Background(Double_t *x, Double_t *par);
Double_t Sum(Double_t *x, Double_t *par);
Double_t fPeakRange[2]; // peak fit range
Double_t fFitResult[kValues]; // array of fit results
- TH1F *fHistogram; // histogram to be fitted
+ TH1D *fHistogram; // histogram to be fitted
TF1 *fSignalFcn; // function for signal
TF1 *fBackgroundFcn; // function for background
TF1 *fSumFcn; // total function
//
#include <TString.h>
+#include <TAxis.h>
#include "AliLog.h"
return 0x0;
}
- Int_t *nbins = new Int_t [fSize];
- Double_t *min = new Double_t[fSize];
- Double_t *max = new Double_t[fSize];
-
// retrieve binnings for main and secondary axes
- AliRsnValue *fcnAxis = 0;
- for (Int_t i = 0; i < fSize; i++) {
+ AliRsnValue *fcnAxis;
+ TArrayD array[3];
+ for (Int_t i = 0; i < fSize; i++)
+ {
fcnAxis = (AliRsnValue*)fAxisList.At(i);
- if (!fcnAxis) {
- nbins[i] = 0;
- min[i] = 0.0;
- max[i] = 0.0;
+ if (!fcnAxis)
+ {
AliError("Empty axis");
+ array[i].Set(2);
+ array[i][0] = -1E5;
+ array[i][1] = -1E5;
continue;
}
- nbins[i] = fcnAxis->GetNBins();
- min[i] = fcnAxis->GetMin();
- max[i] = fcnAxis->GetMax();
+ else
+ {
+ array[i] = fcnAxis->GetArray();
+ }
}
// create histogram depending on the number of axes
switch (fSize)
{
case 1:
- fH1 = new TH1F(histoName, histoTitle, nbins[0], min[0], max[0]);
+ fH1 = new TH1F(histoName, histoTitle, array[0].GetSize() - 1, array[0].GetArray());
break;
case 2:
- fH1 = new TH2F(histoName, histoTitle, nbins[0], min[0], max[0], nbins[1], min[1], max[1]);
+ fH1 = new TH2F(histoName, histoTitle, array[0].GetSize() - 1, array[0].GetArray(), array[1].GetSize() - 1, array[1].GetArray());
break;
case 3:
- fH1 = new TH3F(histoName, histoTitle, nbins[0], min[0], max[0], nbins[1], min[1], max[1], nbins[2], min[2], max[2]);
+ fH1 = new TH3F(histoName, histoTitle, array[0].GetSize() - 1, array[0].GetArray(), array[1].GetSize() - 1, array[1].GetArray(), array[2].GetSize() - 1, array[2].GetArray());
break;
}
fH1->Sumw2();
AliError("No axes defined");
return 0x0;
}
+
+ // create dummy variables to initialize the histogram
+ Int_t dummyI;
+ Double_t dummyD;
- Int_t *nbins = new Int_t [fSize];
- Double_t *min = new Double_t[fSize];
- Double_t *max = new Double_t[fSize];
-
- // retrieve binnings for main and secondary axes
+ // create histogram
+ fHSparse = new THnSparseF(histoName, histoTitle, fSize, &dummyI, &dummyD, &dummyD);
+ fHSparse->Sumw2();
+
+ // update the various axes using the definitions given in the array of axes here
AliRsnValue *fcnAxis = 0;
- for (Int_t i = 0; i < fSize; i++) {
+ TAxis *axis = 0;
+ for (Int_t i = 0; i < fSize; i++)
+ {
fcnAxis = (AliRsnValue*)fAxisList.At(i);
+ axis = fHSparse->GetAxis(i);
if (!fcnAxis) {
- nbins[i] = 0;
- min[i] = 0.0;
- max[i] = 0.0;
- AliError("Empty axis");
+ axis->Set(1, -1E5, 1E5);
+ AliError("Empty axis: doing unique bin betweeen -100000 and 100000");
continue;
}
- nbins[i] = fcnAxis->GetNBins();
- min[i] = fcnAxis->GetMin();
- max[i] = fcnAxis->GetMax();
- }
-
- Int_t size = fAxisList.GetEntries();
- if (!size) {
- AliError("No axes defined");
- return 0x0;
+ axis->Set(fcnAxis->GetArray().GetSize() - 1, fcnAxis->GetArray().GetArray());
}
- // create histogram
- fHSparse = new THnSparseF(histoName, histoTitle, size, nbins, min, max);
- fHSparse->Sumw2();
-
- // clean heap
- delete [] nbins;
- delete [] min;
- delete [] max;
-
return fHSparse;
}
AliRsnValue::AliRsnValue() :
TNamed(),
fType(kValueTypes),
- fNBins(0),
- fMin(0.0),
- fMax(0.0),
- fValue(0.0)
+ fValue(0.0),
+ fArray(0)
{
//
// Main constructor (version 1)
(const char *name, EValueType type, Int_t nbins, Double_t min, Double_t max) :
TNamed(name, ""),
fType(type),
- fNBins(0),
- fMin(0.0),
- fMax(0.0),
- fValue(0.0)
+ fValue(0.0),
+ fArray(0)
{
//
// Main constructor (version 1)
(const char *name, EValueType type, Double_t min, Double_t max, Double_t step) :
TNamed(name, ""),
fType(type),
- fNBins(0),
- fMin(0.0),
- fMax(0.0),
- fValue(0.0)
+ fValue(0.0),
+ fArray(0)
{
//
// Main constructor (version 2)
SetBins(min, max, step);
}
-/*
//_____________________________________________________________________________
-const char* AliRsnValue::GetName() const
+AliRsnValue::AliRsnValue
+(const char *name, EValueType type, Int_t nbins, Double_t *array) :
+ TNamed(name, ""),
+ fType(type),
+ fValue(0.0),
+ fArray(0)
{
//
-// Return the name of this object defined by the type
+// Main constructor (version 2)
//
- switch (fType)
- {
- case kTrack1P: return "P1";
- case kTrack2P: return "P2";
- case kTrack1Pt: return "PT1";
- case kTrack2Pt: return "PT2";
- case kPairInvMass: return "IM";
- case kPairInvMassMC: return "IMMC";
- case kPairInvMassRes: return "IMRES";
- case kPairPt: return "PT";
- case kPairEta: return "ETA";
- case kPairMt: return "MT";
- case kPairY: return "Y";
- case kEventMult: return "MULT";
- default: return "UNDEF";
- }
+ SetBins(nbins, array);
}
-*/
//_____________________________________________________________________________
-TArrayD AliRsnValue::GetArray() const
+void AliRsnValue::SetBins(Int_t nbins, Double_t min, Double_t max)
{
//
-// Creates an array with all bin edges
+// Set binning for the axis in equally spaced bins
+// where the number of bins, minimum and maximum are given.
//
- TArrayD out(fNBins + 1);
-
- Int_t i;
- Double_t step = (fMax - fMin) / (Double_t)fNBins;
-
- for (i = 0; i <= fNBins; i++) out[i] = fMin + step * (Double_t)i;
-
- return out;
+ fArray.Set(nbins + 1);
+
+ Double_t mymax = TMath::Max(min, max);
+ Double_t mymin = TMath::Min(min, max);
+
+ Int_t k = 0;
+ Double_t binSize = (mymax - mymin) / ((Double_t)nbins);
+
+ fArray[0] = mymin;
+ for (k = 1; k <= nbins; k++) fArray[k] = fArray[k-1] + binSize;
+ for (k = 0; k < fArray.GetSize() - 1; k++) AliDebug(AliLog::kDebug + 3, Form("Bin #%d: %f - %f", k, fArray[k], fArray[k+1]));
}
//_____________________________________________________________________________
-void AliRsnValue::SetBins(Int_t n, Double_t min, Double_t max)
+void AliRsnValue::SetBins(Double_t min, Double_t max, Double_t step)
{
//
-// Set binning for histogram.
+// Set binning for the axis in equally spaced bins
+// where the bin size, minimum and maximum are given.
//
- fNBins = n;
-
- if (min < max)
- {
- fMin = min;
- fMax = max;
- }
- else
- {
- fMin = max;
- fMax = min;
- }
+ Double_t dblNbins = TMath::Abs(max - min) / step;
+ Int_t intNbins = ((Int_t)dblNbins) + 1;
+
+ SetBins(intNbins, min, max);
}
//_____________________________________________________________________________
-void AliRsnValue::SetBins(Double_t min, Double_t max, Double_t step)
+void AliRsnValue::SetBins(Int_t nbins, Double_t *array)
{
//
-// Binning for histogram.
+// Set binning for the axis in unequally spaced bins
+// using the same way it is done in TAxis
//
- if (min < max)
- {
- fMin = min;
- fMax = max;
- }
- else
- {
- fMin = max;
- fMax = min;
- }
-
- fNBins = (Int_t)((fMax - fMin) / (step)) + 1;
+ fArray.Adopt(nbins, array);
+ for (Int_t k = 0; k < fArray.GetSize() - 1; k++) AliDebug(AliLog::kDebug + 3, Form("Bin #%d: %f - %f", k, fArray[k], fArray[k+1]));
}
//_____________________________________________________________________________
};
AliRsnValue();
- AliRsnValue(const char *name, EValueType type, Int_t n, Double_t min, Double_t max);
+ AliRsnValue(const char *name, EValueType type, Int_t n = 0, Double_t min = 0.0, Double_t max = 0.0);
AliRsnValue(const char *name, EValueType type, Double_t min, Double_t max, Double_t step);
- AliRsnValue(const AliRsnValue& copy) : TNamed(copy),fType(copy.fType),fNBins(copy.fNBins),fMin(copy.fMin),fMax(copy.fMax),fValue(copy.fValue) {}
- AliRsnValue& operator=(const AliRsnValue& copy) {SetName(copy.GetName());fType=copy.fType;fNBins=copy.fNBins;fMin=copy.fMin;fMax=copy.fMax;fValue=copy.fValue;return (*this);}
+ AliRsnValue(const char *name, EValueType type, Int_t n, Double_t *array);
+ AliRsnValue(const AliRsnValue& copy) : TNamed(copy),fType(copy.fType),fValue(copy.fValue),fArray(copy.fArray) {}
+ AliRsnValue& operator=(const AliRsnValue& copy) {SetName(copy.GetName());fType=copy.fType;fValue=copy.fValue;fArray=copy.fArray;return (*this);}
virtual ~AliRsnValue() { }
- //const char* GetName() const;
- Int_t GetNBins() const {return fNBins;}
- Double_t GetMin() const {return fMin;}
- Double_t GetMax() const {return fMax;}
- TArrayD GetArray() const;
+ TArrayD GetArray() const {return fArray;}
Double_t GetValue() const {return fValue;}
EValueType GetValueType() {return fType;}
void SetValueType(EValueType type) {fType = type;}
void SetBins(Int_t n, Double_t min, Double_t max);
void SetBins(Double_t min, Double_t max, Double_t step);
+ void SetBins(Int_t n, Double_t *array);
Bool_t Eval(AliRsnMother * const mother, AliRsnPairDef * const pairDef, AliRsnEvent * const event);
private:
EValueType fType; // value type
- Int_t fNBins; // number of bins (when applicable)
- Double_t fMin; // lower edge
- Double_t fMax; // upper edge
Double_t fValue; // computed value
+ TArrayD fArray; // array of bins (when necessary)
// ROOT dictionary
ClassDef(AliRsnValue, 1)
// arguments must have to be the task and the 'dataLabel' argument.
//
Bool_t AddAnalysisTaskRsnTest
-(const char *dataLabel, const char *configMacro = "ConfigTaskRsnTest2010.C")
+(const char *dataLabel, const char *configMacro = "ConfigTaskRsnTest.C")
{
// retrieve analysis manager
AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
// load and execute configuration macro
gROOT->LoadMacro(configMacro);
+ if (!RsnConfigTask(task, dataLabel)) return kFALSE;
+ /*
// perf its expPID
if (!RsnConfigTask(task, dataLabel, kTRUE , kTRUE , kFALSE)) return kFALSE;
if (!RsnConfigTask(task, dataLabel, kTRUE , kFALSE, kFALSE)) return kFALSE;
if (!RsnConfigTask(task, dataLabel, kFALSE, kFALSE, kFALSE)) return kFALSE;
if (!RsnConfigTask(task, dataLabel, kFALSE, kTRUE , kTRUE )) return kFALSE;
if (!RsnConfigTask(task, dataLabel, kFALSE, kFALSE, kTRUE )) return kFALSE;
+ */
// add the task to manager
mgr->AddTask(task);
pairPMntp ->GetCutManager()->SetCommonDaughterCuts(cutSetDaughterCommon);
// function axes
- AliRsnValue *axisIM = new AliRsnValue("IM", AliRsnValue::kPairInvMass, 50, 0.9, 1.4);
- AliRsnValue *axisPt = new AliRsnValue("PT", AliRsnValue::kPairPt, 50, 0.0, 20.0);
+ Double_t ybins[] = {-0.8, -0.7, -0.6, -0.5, 0.5, 0.6, 0.7, 0.8};
+ AliRsnValue *axisIM = new AliRsnValue("IM", AliRsnValue::kPairInvMass, 50, 0.9, 1.4);
+ AliRsnValue *axisPt = new AliRsnValue("PT", AliRsnValue::kPairPt, 0.0, 20.0, 0.1);
+ AliRsnValue *axisY = new AliRsnValue("Y" , AliRsnValue::kPairY, sizeof(ybins)/sizeof(ybins[0]), ybins);
// functions for TH1-like output
AliRsnFunction *fcnPt = new AliRsnFunction;
// --> add axes
fcnPt ->AddAxis(axisIM);
fcnPt ->AddAxis(axisPt);
+ fcnPt ->AddAxis(axisY);
// add functions to TH1-like output
pairPMhist->AddFunction(fcnPt);
//
void runLocal
(
- Int_t nReadFiles = 1,
+ Int_t nReadFiles = 10,
Int_t nSkipFiles = 0,
const char *addTaskName = "AddAnalysisTaskRsnTest.C",
const char *inputSource = "/home/pulvir/analysis/resonances/LHC2010-7TeV-phi/rsn-package/sim.txt",
//AliLog::SetClassDebugLevel("AliRsnCutPID", AliLog::kDebug+2);
//AliLog::SetClassDebugLevel("AliRsnPair", AliLog::kDebug+2);
//AliLog::SetClassDebugLevel("AliRsnPairFunctions", AliLog::kDebug+2);
+ //AliLog::SetClassDebugLevel("AliRsnValue", AliLog::kDebug+4);
// check extension of input to distinguish between XML and TXT
TString sInput(inputSource);
RESONANCES/AliRsnAnalysisPhi7TeVNoPID.cxx \
RESONANCES/AliRsnMonitorTrack.cxx \
RESONANCES/AliRsnAnalysisMonitorTask.cxx \
-# RESONANCES/AliRsnFitResult.cxx \
-# RESONANCES/AliRsnAnalysisEffSE.cxx \
+ RESONANCES/AliRsnFitResult.cxx \
+# RESONANCES/AliRsnAnalysisEffSE.cxx \
HDRS= $(SRCS:.cxx=.h)