**************************************************************************/
///////////////////////////////////////////////////////////////////////////
-// Dielectron Histogram framework helper //
+// Dielectron Histogram framework helper //
// //
/*
+A helper class to extract objects(histograms and/or profiles) from
+a AliDielctronHF array of objects.
+How to use it:
+ AliDielectronHFhelper *hf = new AliDielectronHFhelper("path/to/the/output/file.root", "ConfigName");
+ // print the structure
+ hf->Print();
+ //apply some cuts and print them
+ hf->SetRangeUser("cut1name",cutmin1,cutmax1);
+ hf->SetRangeUser(AliDielectronVarManager::kPt,ptmin,ptmax);
+ hf->PrintCuts();
+ // collect 1-,2- or 3-dim histograms or profiles with error option (default:"")
+ TObjArray *arrHists = hf->CollectHistos(AliDielectronVarManager::kM);
+ TObjArray *arrProfs = hf->CollectProfiles("",AliDielectronVarManager::kM,AliDielectronVarManager::kPt);
-
+ // then you are left with an array of histograms for all pair types or MC signals
*/
// //
#include "AliDielectronHFhelper.h"
#include "AliDielectronHF.h"
-//ClassImp(AliDielectronHFhelper)
+ClassImp(AliDielectronHFhelper)
//const char* AliDielectronHFhelper::fCutVars[AliDielectronHFhelper::kMaxCuts] = {"","","","","","","","","",""};
//________________________________________________________________
AliDielectronHFhelper::AliDielectronHFhelper(const char* filename, const char* container) :
TNamed(),
- fArrPairType(0x0),
+ fMainArr(0x0),
fCutVars(0x0),
fCutLowLimits(0),
fCutUpLimits(0)
//
// dtor
//
- if(fArrPairType) delete fArrPairType;
+ if(fMainArr) delete fMainArr;
if(fCutVars) delete fCutVars;
}
void AliDielectronHFhelper::SetHFArray(const char* filename, const char* container)
{
//
- // get HF containers from file
+ // get HF container from file
//
TFile *f = TFile::Open(filename);
TString objname(obj->GetName());
if( objname.Contains(Form("%s_HF",container)) && obj->IsA()==TObjArray::Class()) {
- fArrPairType = new TObjArray( *(dynamic_cast<TObjArray*>(obj)) );
- //fArrPairType->Print();
+ fMainArr = new TObjArray( *(dynamic_cast<TObjArray*>(obj)) );
+ //fMainArr->Print();
return;
}
}
//
// Set range from variable name
//
- // Int_t size=sizeof(fCutVars)/sizeof(const char*);
Int_t size=fCutLowLimits.GetNrows();
//
// unset range from variable name
//
+
Int_t size=fCutLowLimits.GetNrows();
- // PrintCuts();
TVectorD newlow;
TVectorD newup;
}
//________________________________________________________________
-TObjArray* AliDielectronHFhelper::CollectHistos()
+TObjArray* AliDielectronHFhelper::CollectProfiles(TString option,
+ AliDielectronVarManager::ValueTypes varx,
+ AliDielectronVarManager::ValueTypes vary,
+ AliDielectronVarManager::ValueTypes varz,
+ AliDielectronVarManager::ValueTypes vart)
{
//
- // collect histograms for all kind of pair types or sources
+ // collect 1-3 dimensional TProfiles for all kind of pair types or sources
//
- TObjArray *collection = new TObjArray(AliDielectron::kEv1PMRot+1);
-
- TObjArray *histArr = (TObjArray*) fArrPairType->Clone("tmpArr");
- if(!histArr) return 0x0;
- histArr->SetOwner(kTRUE);
-
- // loop over max. available pair types
- for(Int_t i=0; i<AliDielectron::kEv1PMRot+1; i++) {
-
- collection->AddAt(GetHistogram(AliDielectron::PairClassName(i),histArr), i);
+ // reconstruct the histogram/profile name resp. key
+ Int_t dim = 0;
+ if(varx < AliDielectronVarManager::kNMaxValues) dim++;
+ if(vary < AliDielectronVarManager::kNMaxValues) dim++;
+ if(varz < AliDielectronVarManager::kNMaxValues) dim++;
+ Bool_t bPairClass=0;
+ if( varx < AliDielectronVarManager::kPairMax ||
+ vary < AliDielectronVarManager::kPairMax ||
+ varz < AliDielectronVarManager::kPairMax ||
+ vart < AliDielectronVarManager::kPairMax ) bPairClass=kTRUE;
+ Bool_t bprf = !(option.Contains("hist",TString::kIgnoreCase));
+ Bool_t bStdOpt=kTRUE;
+ if(option.Contains("S",TString::kIgnoreCase) || option.Contains("rms",TString::kIgnoreCase)) bStdOpt=kFALSE;
+
+ TString key = "";
+ if(bprf) dim--;
+ switch(dim) {
+ case 3:
+ key+=Form("%s_",AliDielectronVarManager::GetValueName(varx));
+ key+=Form("%s_",AliDielectronVarManager::GetValueName(vary));
+ key+=Form("%s",AliDielectronVarManager::GetValueName(varz));
+ if(bprf) key+=Form("-%s%s",AliDielectronVarManager::GetValueName(vart),(bStdOpt ? "avg" : "rms"));
+ break;
+ case 2:
+ key+=Form("%s_",AliDielectronVarManager::GetValueName(varx));
+ key+=Form("%s",AliDielectronVarManager::GetValueName(vary));
+ if(bprf) key+=Form("-%s%s",AliDielectronVarManager::GetValueName(varz),(bStdOpt ? "avg" : "rms"));
+ break;
+ case 1:
+ key+=Form("%s",AliDielectronVarManager::GetValueName(varx));
+ if(bprf) key+=Form("-%s%s",AliDielectronVarManager::GetValueName(vary),(bStdOpt ? "avg" : "rms"));
+ break;
+ }
+ // to differentiate btw. leg and pair histos
+ if(bPairClass) key.Prepend("p");
+ // prepend HF
+ key.Prepend("HF_");
+
+ //TODO: printf("--------> KEY: %s \n",key.Data());
+ // get the requested object from the arrays
+ TObjArray *collection = new TObjArray(fMainArr->GetEntriesFast());
+
+ TObjArray *cloneArr = (TObjArray*) fMainArr->Clone("tmpArr");
+ if(!cloneArr) return 0x0;
+ cloneArr->SetOwner(kTRUE);
+
+ // loop over all pair types or sources
+ for(Int_t i=0; i<cloneArr->GetEntriesFast(); i++) {
+ if(!cloneArr->At(i)) continue;
+
+ // find histogram of interest from array of objects
+ TObjArray *arr = (TObjArray*) GetObject(cloneArr->At(i)->GetName(),cloneArr);
+ if(arr) {
+ collection->AddAt(arr->FindObject(key.Data()), i);
+ }
}
// clean up the clone
- if(histArr) {
- delete histArr;
- histArr=0;
+ if(cloneArr) {
+ delete cloneArr;
+ cloneArr=0;
}
return collection;
}
//________________________________________________________________
-TH1* AliDielectronHFhelper::GetHistogram(const char *step, TObjArray *histArr)
+TObject* AliDielectronHFhelper::GetObject(const char *step, TObjArray *histArr)
{
//
- // main function to recieve a single histogram
- // TODO: check memory
+ // main function to recieve a pair type or MC signal array
+ //
AliDebug(1,Form(" Step %s selected",step));
+ // TODO: check memory
- TObjArray *histos= 0x0;
- TH1 *hist = 0x0;
+ TObjArray *stepArr = 0x0; // this is the requested step
+ TObject *hist = 0x0;
if(!histArr) {
- histos = (TObjArray*) fArrPairType->FindObject(step)->Clone("tmpArr");
+ stepArr = (TObjArray*) fMainArr->FindObject(step)->Clone("tmpArr");
}
else {
- histos = (TObjArray*) histArr->FindObject(step);
+ stepArr = (TObjArray*) histArr->FindObject(step);
}
- if(histos) hist = FindHistograms(histos);
+ if(stepArr) hist = FindObjects(stepArr);
return hist;
}
//________________________________________________________________
-TH1* AliDielectronHFhelper::FindHistograms(TObjArray *histos)
+TObject* AliDielectronHFhelper::FindObjects(TObjArray *stepArr)
{
//
- // exclude histograms
+ // apply cuts and exclude objects from the array
//
// debug
- // TString title = histos->At(0)->GetTitle();
+ // TString title = stepArr->At(0)->GetTitle();
// TObjArray* vars = title.Tokenize(":");
// AliDebug(1,Form(" number of cuts/vars: %d/%d",fCutLowLimits.GetNrows(),vars->GetEntriesFast()));
// check for missing cuts
- CheckCuts(histos);
+ CheckCuts(stepArr);
// loop over all cuts
for(Int_t icut=0; icut<fCutLowLimits.GetNrows(); icut++) {
- Bool_t bFndBin = kFALSE; // exact bin found
- const char *cutvar = fCutVars->At(icut)->GetName();
- Double_t min = fCutLowLimits(icut);
- Double_t max = fCutUpLimits(icut);
+ Bool_t bFndBin = kFALSE; // bin with exact limits found
+ const char *cutvar = fCutVars->At(icut)->GetName(); // cut variable
+ Double_t min = fCutLowLimits(icut); // lower limit
+ Double_t max = fCutUpLimits(icut); // upper limit
AliDebug(5,Form(" Cut %d: %s [%.2f,%.2f]",icut,cutvar,min,max));
- // loop over all histograms
- for(Int_t i=0; i<histos->GetEntriesFast(); i++) {
+ // loop over the full grid of given step
+ for(Int_t i=0; i<stepArr->GetEntriesFast(); i++) {
// continue if already empty
- if(!histos->At(i)) continue;
+ if(!stepArr->At(i)) continue;
- // collect binning from histo title
- TString title = histos->At(i)->GetName();
+ // collect bins from the name
+ TString title = stepArr->At(i)->GetName();
if(title.IsNull()) continue;
- AliDebug(10,Form(" histo title: %s",title.Data()));
+ AliDebug(5,Form(" %03d object name: %s",i,title.Data()));
+ // loop over all variables
TObjArray *vars = title.Tokenize(":");
for(Int_t ivar=0; ivar<vars->GetEntriesFast(); ivar++) {
TString binvar = vars->At(ivar)->GetName();
- AliDebug(10,Form(" Check ivar %d binvar %s",ivar,binvar.Data()));
+ AliDebug(10,Form(" --> %d check bin var %s",ivar,binvar.Data()));
- // check for cuts and ranges by the user
+ // check cuts set by the user, and compare to the bin limits
if(binvar.Contains(cutvar)) {
+ // bin limits
TObjArray *limits = binvar.Tokenize("#");
-
- Double_t binmin = atof(limits->At(1)->GetName());
- Double_t binmax = atof(limits->At(2)->GetName());
+ Double_t binmin = atof(limits->At(1)->GetName()); // lower bin limit
+ Double_t binmax = atof(limits->At(2)->GetName()); // upper bin limit
AliDebug(10,Form(" bin %s var %s [%.2f,%.2f]",binvar.Data(),limits->At(0)->GetName(),binmin,binmax));
+ if(limits) delete limits;
- // remove histogram from array
+ // cut and remove objects from the array
if(binmin < min || binmax < min || binmin > max || binmax > max ) {
- AliDebug(10,Form(" removed, out of range min %.2f,%.2f max %.2f,%.2f",binmin,min,binmax,max));
- histos->AddAt(0x0,i);
+ AliDebug(10,Form(" removed, out of range! lower bin,cut: %.2f,%.2f or upper bin,cut: %.2f>%.2f",binmin,min,binmax,max));
+ stepArr->AddAt(0x0,i);
}
if(bFndBin && !(binmin == min && binmax == max)) {
- histos->AddAt(0x0,i);
- AliDebug(10,Form(" removed, within range min %.2f,%.2f max %.2f,%.2f",binmin,min,binmax,max));
+ stepArr->AddAt(0x0,i);
+ AliDebug(10,Form(" removed, within range! lower bin,cut: %.2f,%.2f or upper bin,cut: %.2f,%.2f",binmin,min,binmax,max));
}
- // clean up
- if(limits) delete limits;
- // do we have found an exact bin
+ // did we found a bin with exact the cut ranges
+ // this can happen only once per variable
if(binmin==min && binmax==max) bFndBin=kTRUE;
}
}
- // compress the array by removing all empty histos
- histos->Compress();
- AliDebug(1,Form(" Compression: %d histograms left",histos->GetEntriesFast()));
+ // compress the array by removing all empty entries
+ stepArr->Compress();
+ AliDebug(1,Form(" Compression: %d objects left",stepArr->GetEntriesFast()));
- // merge histograms
- TH1* hist = MergeHistos(histos);
- if(hist) AliDebug(1,Form(" Merging: %e histogram entries",hist->GetEntries()));
+ // merge left objects
+ TObject* hist = Merge(stepArr);
+ // if(hist) AliDebug(1,Form(" Merging: %e entries",hist->GetEntries()));
return hist;
}
//________________________________________________________________
-TH1* AliDielectronHFhelper::MergeHistos(TObjArray *arr)
+TObject* AliDielectronHFhelper::Merge(TObjArray *arr)
{
//
- // merge histos to one single histogram
+ // merge left objects to a single one
//
- if(arr->GetEntriesFast()<1) { AliError(" No more histosgrams left!"); return 0x0; }
+ if(arr->GetEntriesFast()<1) { AliError(" No more objects left!"); return 0x0; }
TObject *final=arr->At(0)->Clone();
if(!final) return 0x0;
// final->SetTitle(""); //TODO: change in future
for(Int_t i=1; i<arr->GetEntriesFast(); i++) {
listH.Add(arr->At(i));
+ // printf("%d: ent %.0f \n",i,((TH1*)((TObjArray*)arr->At(i))->At(0))->GetEntries());
// final->Add((TH1*)arr->At(i));
}
// arr->Clear();
final->Execute("Merge", listHargs.Data(), &error);
- return (TH1*)final;
+ return final;
}
//________________________________________________________________
void AliDielectronHFhelper::CheckCuts(TObjArray *arr)
{
//
- // Compare histo binning and cut variables. Add necessary cuts (largest limits)
+ // Compare binning and cut variables. Add necessary cuts (full range, no exclusion)
//
-
// build array with bin variable, minimum and maximum bin values
TString titleFIRST = arr->First()->GetName();
TString titleLAST = arr->Last()->GetName();
//
// Print out object contents
//
- AliInfo(Form(" Container: %s",fArrPairType->GetName()));
+ AliInfo(Form(" Container: %s",fMainArr->GetName()));
// pairtypes, steps and sources
- AliInfo(Form(" Number of filled steps: %d",fArrPairType->GetEntries()));
- for(Int_t istep=0; istep<fArrPairType->GetEntriesFast(); istep++) {
- if(fArrPairType->At(istep))
- AliInfo(Form(" step %d: %s",istep,fArrPairType->At(istep)->GetName()));
+ Int_t stepLast=0;
+ AliInfo(Form(" Number of filled steps: %d",fMainArr->GetEntries()));
+ for(Int_t istep=0; istep<fMainArr->GetEntriesFast(); istep++) {
+ if(fMainArr->At(istep)) {
+ AliInfo(Form(" step %d: %s",istep,fMainArr->At(istep)->GetName()));
+ stepLast=istep;
+ }
}
- AliInfo(Form(" Number of histograms: %d",((TObjArray*)fArrPairType->At(0))->GetEntriesFast()));
+ AliInfo(Form(" Number of objects: %d",
+ ((TObjArray*) ((TObjArray*)fMainArr->At(stepLast)) ->First())->GetEntriesFast()));
- TString title = ((TObjArray*)fArrPairType->At(0))->First()->GetTitle();
+ TString title = ((TObjArray*)fMainArr->At(stepLast))->First()->GetName();
TObjArray* binvars = title.Tokenize(":");
AliInfo(Form(" Number of variables: %d",binvars->GetEntriesFast()));
delete binvars;
{
//
- // Print out object contents
+ // Print cuts
//
// loop over all cuts
{"kRotPairz", "kRotPairz", "(rad.)"},
{"Cos2PhiCS", "cos(2#phi_{CS})", ""},
{"CosTilPhiCS", "cos(#phi_{CS})", ""},
+ {"CosPhiH2", "cos(2#phi)", ""},
+ {"SinPhiH2", "sin(2#phi)", ""},
{"DeltaPhiV0ArpH2", "#phi^{pair}-#Psi^{V0A}", ""},
{"DeltaPhiV0CrpH2", "#phi^{pair}-#Psi^{V0C}", ""},
{"DeltaPhiV0ACrpH2", "#phi^{pair}-#Psi^{V0AC}", ""},
{"v0CrpH2FlowV2", "cos(2(#phi^{pair}-#Psi^{V0C}))", ""},
{"v0ACrpH2FlowV2", "cos(2(#phi^{pair}-#Psi^{V0AC}))", ""},
{"TPCrpH2FlowV2", "cos(2(#phi^{pair}-#Psi^{TPC}))", ""},
+ {"TPCrpH2FlowV2Sin", "sin(2(#phi^{pair}-#Psi^{TPC}))", ""},
{"LegDistance", "d^{legs}", "(cm)"},
{"LegDistanceXY", "d^{legs}_{xy}", "(cm)"},
{"DeltaEta", "#Delta #eta", ""},
{"V0AV0CDiffH2", "cos(2(#Psi^{V0A}-#Psi^{V0C}))", ""},
{"TPCxH2", "Q_{x}^{TPC}", ""},
{"TPCyH2", "Q_{y}^{TPC}", ""},
- {"TPCmagH2", "|#vec{Q}^{TPC}|", ""},
+ {"TPCmagH2", "|#vec{Q}^{TPC}|", ""},
{"TPCrpH2", "#Psi^{TPC}", ""},
+ {"CosTPCrpH2", "cos(2#Psi^{TPC})", ""},
+ {"SinTPCrpH2", "sin(2#Psi^{TPC})", ""},
{"TPCsub1xH2", "Q_{x}^{TPCsub1}", ""},
{"TPCsub1yH2", "Q_{y}^{TPCsub1}", ""},
{"TPCsub1rpH2", "#Psi^{TPCsub1}", ""},
kRotPairz, //ee plane vector
kCos2PhiCS, // Cosine of 2*phi in mother's rest frame in the Collins-Soper picture
kCosTilPhiCS, // Shifted phi depending on kThetaCS
+ kCosPhiH2, // cosine of pair phi for 2nd harmonic
+ kSinPhiH2, // sinus of pair phi for 2nd harmonic
kDeltaPhiV0ArpH2, // Delta phi of the pair with respect to the 2nd order harmonic reaction plane from V0-A
kDeltaPhiV0CrpH2, // Delta phi of the pair with respect to the 2nd order harmonic reaction plane from V0-C
kDeltaPhiV0ACrpH2, // Delta phi of the pair with respect to the 2nd order harmonic reaction plane from V0-A + V0-C
kv0CrpH2FlowV2, // v2 coefficient with respect to the 2nd order reaction plane from V0-C
kv0ACrpH2FlowV2, // v2 coefficient with respect to the 2nd order reaction plane from V0-A + V0-C
kTPCrpH2FlowV2, // v2 coefficient with respect to the 2nd order reaction plane from TPC
+ kTPCrpH2FlowV2Sin, // sinus of v2 coefficient with respect to the 2nd order reaction plane from TPC
kLegDist, // distance of the legs
kLegDistXY, // distance of the legs in XY
kTPCyH2, // TPC y-component of the Q vector for 2nd harmonic (corrected)
kTPCmagH2, // TPC reaction plane the Q vectors magnitude for 2nd harmonic (corrected)
kTPCrpH2, // TPC reaction plane angle of the Q vector for 2nd harmonic (corrected)
+ kCosTPCrpH2, // cosine of TPC reaction plane angle of the Q vector for 2nd harmonic (corrected)
+ kSinTPCrpH2, // sinus of TPC reaction plane angle of the Q vector for 2nd harmonic (corrected)
kTPCsub1xH2, // TPC x-component of the Q vector for 2nd harmonic (corrected, sub event 1)
kTPCsub1yH2, // TPC y-component of the Q vector for 2nd harmonic (corrected, sub event 1)
kTPCsub1rpH2, // TPC reaction plane of the Q vector for 2nd harmonic (corrected, sub event 1)
*/
}
//common, regardless of calculation method
- // Flow quantities
+
+ // Flow quantities
+ values[AliDielectronVarManager::kCosPhiH2] = TMath::Cos(2*values[AliDielectronVarManager::kPhi]);
+ values[AliDielectronVarManager::kSinPhiH2] = TMath::Sin(2*values[AliDielectronVarManager::kPhi]);
Double_t delta=0.0;
// v2 with respect to VZERO-A event plane
delta = values[AliDielectronVarManager::kPhi] - fgData[AliDielectronVarManager::kV0ArpH2];
values[AliDielectronVarManager::kv0ArpH2FlowV2] = TMath::Cos( 2*(values[AliDielectronVarManager::kPhi] - values[AliDielectronVarManager::kv0ArpH2]) );
values[AliDielectronVarManager::kv0CrpH2FlowV2] = TMath::Cos( 2*(values[AliDielectronVarManager::kPhi] - values[AliDielectronVarManager::kv0CrpH2]) );
values[AliDielectronVarManager::kTPCrpH2FlowV2] = TMath::Cos( 2*(values[AliDielectronVarManager::kPhi] - values[AliDielectronVarManager::kTPCrpH2]) );
+ values[AliDielectronVarManager::kTPCrpH2FlowV2Sin] = TMath::Sin( 2*(values[AliDielectronVarManager::kPhi] - values[AliDielectronVarManager::kTPCrpH2]) );
+
// keep the interval [-pi,+pi]
if ( values[AliDielectronVarManager::kDeltaPhiv0ArpH2] > TMath::Pi() )
values[AliDielectronVarManager::kTPCyH2] = qcorr->Y();
values[AliDielectronVarManager::kTPCmagH2] = qcorr->Mod();
values[AliDielectronVarManager::kTPCrpH2] = ((TMath::Abs(qcorr->X())>1.0e-10) ? TMath::ATan2(qcorr->Y(),qcorr->X())/2.0 : 0.0);
+ // detector effects
+ values[AliDielectronVarManager::kCosTPCrpH2] = TMath::Cos( 2.* values[AliDielectronVarManager::kTPCrpH2] );
+ values[AliDielectronVarManager::kSinTPCrpH2] = TMath::Sin( 2.* values[AliDielectronVarManager::kTPCrpH2] );
+
// correlations for event plane resoultion
values[AliDielectronVarManager::kv0ATPCDiffH2] = TMath::Cos( 2.*(values[AliDielectronVarManager::kv0ArpH2] -
values[AliDielectronVarManager::kTPCrpH2]) );