#include <TClass.h>
#include <TCollection.h>
#include <THashList.h>
+#include <THnSparse.h>
#include <TList.h>
#include <TObjArray.h>
#include <TObjString.h>
AliHFEcontainer::AliHFEcontainer():
TNamed("HFEcontainer", ""),
fContainers(NULL),
+ fCorrelationMatrices(NULL),
fVariables(NULL),
fNVars(0),
fNEvents(0)
// Default constructor
//
fContainers = new THashList();
+ fContainers->SetOwner();
}
//__________________________________________________________________
AliHFEcontainer::AliHFEcontainer(const Char_t *name):
TNamed(name, ""),
fContainers(NULL),
+ fCorrelationMatrices(NULL),
fVariables(NULL),
fNVars(0),
fNEvents(0)
// Default constructor
//
fContainers = new THashList();
+ fContainers->SetOwner();
}
//__________________________________________________________________
AliHFEcontainer::AliHFEcontainer(const Char_t *name, UInt_t nVar):
TNamed(name, ""),
fContainers(NULL),
+ fCorrelationMatrices(NULL),
fVariables(NULL),
fNVars(0),
fNEvents(0)
// Setting Number of Variables too
//
fContainers = new THashList();
+ fContainers->SetOwner();
SetNumberOfVariables(nVar);
}
AliHFEcontainer::AliHFEcontainer(const AliHFEcontainer &ref):
TNamed(ref),
fContainers(NULL),
+ fCorrelationMatrices(NULL),
fVariables(NULL),
fNVars(ref.fNVars),
fNEvents(ref.fNEvents)
{
//
// Copy constructor
- // creates a new object with new containers
+ // creates a new object with new (empty) containers
//
- fContainers = new THashList;
- for(Int_t ien = 0; ien < ref.fContainers->GetEntries(); ien++)
- fContainers->Add(new AliCFContainer(*dynamic_cast<AliCFContainer *>(ref.fContainers->At(ien))));
if(fNVars){
fVariables = new TObjArray(fNVars);
for(UInt_t ivar = 0; ivar < fNVars; ivar++)
fVariables->AddAt(new AliHFEvarInfo(*dynamic_cast<AliHFEvarInfo *>(ref.fVariables->UncheckedAt(ivar))), ivar);
}
+ fContainers = new THashList;
+ fContainers->SetOwner();
+ AliCFContainer *ctmp = NULL;
+ for(Int_t ien = 0; ien < ref.fContainers->GetEntries(); ien++){
+ ctmp = dynamic_cast<AliCFContainer *>(ref.fContainers->At(ien));
+ CreateContainer(ctmp->GetName(), ctmp->GetTitle(), ctmp->GetNStep());
+ }
+ // Copy also correlation matrices
+ if(ref.fCorrelationMatrices){
+ THnSparseF *htmp = NULL;
+ fCorrelationMatrices = new THashList;
+ fCorrelationMatrices->SetOwner();
+ for(Int_t ien = 0; ien < ref.fCorrelationMatrices->GetEntries(); ien++){
+ htmp = dynamic_cast<THnSparseF *>(ref.fCorrelationMatrices->At(ien));
+ CreateCorrelationMatrix(htmp->GetName(), htmp->GetTitle());
+ }
+ }
}
//__________________________________________________________________
} else {
fVariables = NULL;
}
-
+ // Copy also correlation matrices
+ if(ref.fCorrelationMatrices){
+ THnSparseF *htmp = NULL;
+ fCorrelationMatrices = new THashList;
+ fCorrelationMatrices->SetOwner();
+ for(Int_t ien = 0; ien < ref.fCorrelationMatrices->GetEntries(); ien++){
+ htmp = dynamic_cast<THnSparseF *>(ref.fCorrelationMatrices->At(ien));
+ CreateCorrelationMatrix(htmp->GetName(), htmp->GetTitle());
+ }
+ }
return *this;
}
//
// Destructor
//
- fContainers->Delete();
delete fContainers;
+ if(fCorrelationMatrices) delete fCorrelationMatrices;
if(fVariables){
fVariables->Delete();
delete fVariables;
containers.Add(cont->fContainers);
fContainers->Merge(&containers);
+ if(fCorrelationMatrices && cont->fCorrelationMatrices){
+ containers.Clear();
+ containers.Add(cont->fCorrelationMatrices);
+ fCorrelationMatrices->Merge(&containers);
+ }
+
fNEvents += cont->GetNumberOfEvents();
count++;
}
}
//__________________________________________________________________
-AliCFContainer *AliHFEcontainer::GetCFContainer(const Char_t *name){
+void AliHFEcontainer::CreateCorrelationMatrix(const Char_t *name, const Char_t *title){
+ //
+ // Create Correlation Matrix
+ //
+ if(!fCorrelationMatrices){
+ fCorrelationMatrices = new THashList;
+ fCorrelationMatrices->SetName("fCorrelationMatrices");
+ fCorrelationMatrices->SetOwner();
+ }
+
+ Int_t *nBins = new Int_t[2*fNVars];
+ AliHFEvarInfo *var = NULL;
+ for(UInt_t ivar = 0; ivar < fNVars; ivar++){
+ var = dynamic_cast<AliHFEvarInfo *>(fVariables->UncheckedAt(ivar));
+ nBins[ivar] = var->GetNumberOfBins();
+ nBins[ivar+fNVars] = var->GetNumberOfBins();
+ }
+
+ THnSparseF * hTmp = new THnSparseF(name, title, 2*fNVars, nBins);
+ for(UInt_t ivar = 0; ivar < fNVars; ivar++){
+ var = dynamic_cast<AliHFEvarInfo *>(fVariables->UncheckedAt(ivar));
+ hTmp->SetBinEdges(ivar,var->GetBinning());
+ //hTmp->GetAxis(ivar)->Set(var->GetNumberOfBins(), var->GetBinning());
+ hTmp->GetAxis(ivar)->SetTitle(var->GetVarName()->Data());
+ //hTmp->GetAxis(ivar + fNVars)->Set(var->GetNumberOfBins(), var->GetBinning());
+ hTmp->GetAxis(ivar + fNVars)->SetTitle(Form("%s_{MC}", var->GetVarName()->Data()));
+ hTmp->SetBinEdges(ivar+fNVars,var->GetBinning());
+ }
+ hTmp->Sumw2();
+ fCorrelationMatrices->AddLast(hTmp);
+}
+
+//__________________________________________________________________
+AliCFContainer *AliHFEcontainer::GetCFContainer(const Char_t *name) const{
//
// Find a given container
//
}
//__________________________________________________________________
-void AliHFEcontainer::FillCFContainer(const Char_t *name, UInt_t step, Double_t *content){
+THnSparseF *AliHFEcontainer::GetCorrelationMatrix(const Char_t *name) const{
+ //
+ // Find Correlation Matrix
+ //
+ return dynamic_cast<THnSparseF *>(fCorrelationMatrices->FindObject(name));
+}
+
+//__________________________________________________________________
+void AliHFEcontainer::FillCFContainer(const Char_t *name, UInt_t step, Double_t *content, Double_t weight) const {
+ //
+ // Fill container
+ //
+ AliCFContainer *cont = GetCFContainer(name);
+ if(!cont) return;
+ cont->Fill(content, step, weight);
+}
+
+//__________________________________________________________________
+void AliHFEcontainer::FillCFContainerStepname(const Char_t *name, const Char_t *steptitle, Double_t *content, Double_t weight)const{
//
// Fill container
//
AliCFContainer *cont = GetCFContainer(name);
if(!cont) return;
- cont->Fill(content, step);
+ // find the matching step title
+ Int_t mystep = -1;
+ for(Int_t istep = 0; istep < cont->GetNStep(); istep++){
+ TString tstept = cont->GetStepTitle(istep);
+ if(!tstept.CompareTo(steptitle)){
+ mystep = istep;
+ break;
+ }
+ }
+ if(mystep < 0){
+ // step not found
+ AliDebug(1, Form("Step %s not found in container %s", steptitle, name));
+ return;
+ }
+ AliDebug(1, Form("Filling step %s(%d) for container %s", steptitle, mystep, name));
+ cont->Fill(content, mystep, weight);
}
//__________________________________________________________________
for(UInt_t ibin = 0; ibin < fNVars; ibin++) dummyBinning[ibin] = 1;
AliCFContainer *cmerged = new AliCFContainer(name, title, nStepMerged, fNVars, dummyBinning);
delete dummyBinning;
- // cleanup old container content so that we can fill it with the new content
- AliInfo("Removing temporary grids");
- for(Int_t istep = 0; istep < cmerged->GetNStep(); istep++){
- AliCFGridSparse *grid = cmerged->GetGrid(istep);
- delete grid;
- }
// Fill container with content
AliInfo("Filling new container");
Int_t cstep = 0;
}
return cmerged;
}
+
+//__________________________________________________________________
+void AliHFEcontainer::SetStepTitle(const Char_t *contname, const Char_t *steptitle, UInt_t step){
+ //
+ // Set title for given analysis step in container with name contname
+ //
+ AliCFContainer *cont = GetCFContainer(contname);
+ if(!cont) return;
+ if(step >= static_cast<UInt_t>(cont->GetNStep())) return;
+ cont->SetStepTitle(step, steptitle);
+}
+
//__________________________________________________________________
void AliHFEcontainer::MakeLinearBinning(UInt_t var, UInt_t nBins, Double_t begin, Double_t end){
//