]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWGJE/AliFragmentationFunctionCorrections.cxx
Add parameter to change the reference multiplicity
[u/mrichter/AliRoot.git] / PWGJE / AliFragmentationFunctionCorrections.cxx
index 70141be85416f23a40be1433330a19b00d1e7602..1e61118c693ecfcf7de1b6ae315edfa8daa153aa 100644 (file)
@@ -303,19 +303,24 @@ AliFragmentationFunctionCorrections::AliFragFuncCorrHistos::AliFragFuncCorrHisto
 }
 
 //__________________________________________________________________________________________________________________
-AliFragmentationFunctionCorrections::AliFragFuncCorrHistos::AliFragFuncCorrHistos(const AliFragFuncCorrHistos& copy)
+AliFragmentationFunctionCorrections::AliFragFuncCorrHistos::AliFragFuncCorrHistos(const AliFragmentationFunctionCorrections::AliFragFuncCorrHistos& copy)
   : TObject()
   ,fArraySize(copy.fArraySize)
-  ,fh1CorrFFTrackPt(copy.fh1CorrFFTrackPt)
-  ,fh1CorrFFZ(copy.fh1CorrFFZ)
-  ,fh1CorrFFXi(copy.fh1CorrFFXi)
+  ,fh1CorrFFTrackPt(0)
+  ,fh1CorrFFZ(0)
+  ,fh1CorrFFXi(0)
   ,fCorrLabel(copy.fCorrLabel)
 {
   // copy constructor
+
+  fh1CorrFFTrackPt = new TH1F*[copy.fArraySize];
+  fh1CorrFFZ       = new TH1F*[copy.fArraySize];
+  fh1CorrFFXi      = new TH1F*[copy.fArraySize];
+
   for(Int_t i=0; i<copy.fArraySize; i++){
-    fh1CorrFFTrackPt[i] = copy.fh1CorrFFTrackPt[i];
-    fh1CorrFFZ[i]       = copy.fh1CorrFFZ[i];
-    fh1CorrFFXi[i]      = copy.fh1CorrFFXi[i];
+    fh1CorrFFTrackPt[i] = new TH1F(*(copy.fh1CorrFFTrackPt[i]));
+    fh1CorrFFZ[i]       = new TH1F(*(copy.fh1CorrFFZ[i]));
+    fh1CorrFFXi[i]      = new TH1F(*(copy.fh1CorrFFXi[i]));
   }
 }
 
@@ -326,16 +331,46 @@ AliFragmentationFunctionCorrections::AliFragFuncCorrHistos& AliFragmentationFunc
   
   if(this!=&o){
     TObject::operator=(o);
-    fArraySize       = o.fArraySize;
+    Int_t fArraySize_new = o.fArraySize;
     fCorrLabel       = o.fCorrLabel;
  
-    for(Int_t i=0; i<o.fArraySize; i++){
-      fh1CorrFFTrackPt[i] = o.fh1CorrFFTrackPt[i];
-      fh1CorrFFZ[i]       = o.fh1CorrFFZ[i];
-      fh1CorrFFXi[i]      = o.fh1CorrFFXi[i];
+    TH1F** fh1CorrFFTrackPt_new = new TH1F*[fArraySize_new];
+    TH1F** fh1CorrFFZ_new       = new TH1F*[fArraySize_new];
+    TH1F** fh1CorrFFXi_new      = new TH1F*[fArraySize_new];
+
+    for(Int_t i=0; i<fArraySize_new; i++){
+      fh1CorrFFTrackPt_new[i] = new TH1F(*(o.fh1CorrFFTrackPt[i]));
+      fh1CorrFFZ_new[i]       = new TH1F(*(o.fh1CorrFFZ[i]));
+      fh1CorrFFXi_new[i]      = new TH1F(*(o.fh1CorrFFXi[i]));
     }
-  }
     
+    // ---
+
+    if(fArraySize){
+      for(int i=0; i<fArraySize; i++) delete fh1CorrFFTrackPt[i];
+      for(int i=0; i<fArraySize; i++) delete fh1CorrFFZ[i];
+      for(int i=0; i<fArraySize; i++) delete fh1CorrFFXi[i];          
+    }
+
+    if(fh1CorrFFTrackPt) delete[] fh1CorrFFTrackPt;
+    if(fh1CorrFFZ)       delete[] fh1CorrFFZ;
+    if(fh1CorrFFXi)      delete[] fh1CorrFFXi;
+        
+    // ---
+
+    fArraySize = fArraySize_new;
+
+    fh1CorrFFTrackPt = fh1CorrFFTrackPt_new;
+    fh1CorrFFZ       = fh1CorrFFZ_new;
+    fh1CorrFFXi      = fh1CorrFFXi_new;
+    
+    for(Int_t i=0; i<fArraySize; i++){
+      fh1CorrFFTrackPt[i] = fh1CorrFFTrackPt_new[i];
+      fh1CorrFFZ[i]       = fh1CorrFFZ_new[i];
+      fh1CorrFFXi[i]      = fh1CorrFFXi_new[i];
+    }
+  }
+  
   return *this;
 }
 
@@ -898,7 +933,7 @@ void AliFragmentationFunctionCorrections::ReadRawFF(TString strfile, TString str
 { 
   // read raw FF - standard dir/list name
      
-  TString strdir  = "PWG4_FragmentationFunction_" + strID;
+  TString strdir  = "PWGJE_FragmentationFunction_" + strID;
   TString strlist = "fracfunc_" + strID;
     
   ReadRawFF(strfile,strdir,strlist,strFFID);
@@ -1010,7 +1045,7 @@ void AliFragmentationFunctionCorrections::ReadRawBgr(TString strfile, TString st
 { 
   // read raw FF - standard dir/list name
      
-  TString strdir  = "PWG4_FragmentationFunction_" + strID;
+  TString strdir  = "PWGJE_FragmentationFunction_" + strID;
   TString strlist = "fracfunc_" + strID;
     
   ReadRawBgr(strfile,strdir,strlist,strBgrID,strFFID);
@@ -1142,7 +1177,7 @@ void AliFragmentationFunctionCorrections::ReadRawBgrEmbedding(TString strfile, T
 { 
   // read raw FF - standard dir/list name
      
-  TString strdir  = "PWG4_FragmentationFunction_" + strID;
+  TString strdir  = "PWGJE_FragmentationFunction_" + strID;
   TString strlist = "fracfunc_" + strID;
     
   ReadRawBgrEmbedding(strfile,strdir,strlist,strFFID);
@@ -1415,21 +1450,32 @@ void AliFragmentationFunctionCorrections::UnfoldHistos(const Int_t nIter, const
     if(type == kFlagPt)      hist = fCorrFF[fNCorrectionLevels-2]->GetTrackPt(i); // level -2: before unfolding, level -1: unfolded
     else if(type == kFlagZ)  hist = fCorrFF[fNCorrectionLevels-2]->GetZ(i);       // level -2: before unfolding, level -1: unfolded
     else if(type == kFlagXi) hist = fCorrFF[fNCorrectionLevels-2]->GetXi(i);      // level -2: before unfolding, level -1: unfolded
+    else{ 
+      Printf("%s%d unknown type",(char*)__FILE__,__LINE__);
+      return;
+    }
+    
+    if(!hist){
+      Printf("%s%d no histo found ",(char*)__FILE__,__LINE__);
+      return;
+    }
+
 
     THnSparse* hnResponse = 0;
-    if(type == kFlagPt) hnResponse = fhnResponsePt[i];
+    if(type == kFlagPt)      hnResponse = fhnResponsePt[i];
     else if(type == kFlagZ)  hnResponse = fhnResponseZ[i];
     else if(type == kFlagXi) hnResponse = fhnResponseXi[i];
 
-
     TH1F* hPrior = 0;
     if(type == kFlagPt && fh1FFTrackPtPrior[i]  && ((TString(fh1FFTrackPtPrior[i]->GetName())).Length() > 0) ) hPrior = fh1FFTrackPtPrior[i];
     else if(type == kFlagZ  && fh1FFZPrior[i]   && ((TString(fh1FFZPrior[i]->GetName())).Length() > 0)       ) hPrior = fh1FFZPrior[i];
     else if(type == kFlagXi && fh1FFXiPrior[i]  && ((TString(fh1FFXiPrior[i]->GetName())).Length() > 0)      ) hPrior = fh1FFXiPrior[i];
 
 
-    TString histNameTHn = hist->GetName();
+    TString histNameTHn;
+    histNameTHn = hist->GetName();
     histNameTHn.ReplaceAll("TH1","THn");
+    
 
     TString priorNameTHn; 
     if(hPrior){
@@ -1437,14 +1483,18 @@ void AliFragmentationFunctionCorrections::UnfoldHistos(const Int_t nIter, const
       priorNameTHn.ReplaceAll("TH1","THn");
     }
 
-    TString histNameBackFolded = hist->GetName();
+    TString histNameBackFolded;
+    histNameBackFolded = hist->GetName();
     histNameBackFolded.Append("_backfold");
-
-    TString histNameRatioFolded = hist->GetName();
+    
+    TString histNameRatioFolded;
+    histNameRatioFolded = hist->GetName();
     histNameRatioFolded.ReplaceAll("fh1FF","hRatioFF");
+    
     histNameRatioFolded.Append("_unfold");
 
-    TString histNameRatioBackFolded = hist->GetName();
+    TString histNameRatioBackFolded;
+    histNameRatioBackFolded = hist->GetName();
     histNameRatioBackFolded.ReplaceAll("fh1FF","hRatioFF");
     histNameRatioBackFolded.Append("_backfold");
  
@@ -1452,22 +1502,20 @@ void AliFragmentationFunctionCorrections::UnfoldHistos(const Int_t nIter, const
     THnSparse* hnFlatEfficiency = TH1toSparse(hist,"fhnEfficiency","eff",kTRUE); // could optionally also use real eff 
     THnSparse* hnPrior          = 0;
     if(hPrior) hnPrior = TH1toSparse(hPrior,priorNameTHn,hPrior->GetTitle());
-
+    
     THnSparse* hnUnfolded 
       = Unfold(hnHist,hnResponse,hnFlatEfficiency,nIter,useCorrelatedErrors,hnPrior);  
      
-    TH1F* hUnfolded = (TH1F*) hnUnfolded->Projection(0);
-    if (hist)
-      hUnfolded->SetNameTitle(hist->GetName(),hist->GetTitle());
+    TH1F* hUnfolded = (TH1F*) hnUnfolded->Projection(0); 
+    hUnfolded->SetNameTitle(hist->GetName(),hist->GetTitle());
     
     if(type == kFlagPt) fCorrFF[fNCorrectionLevels-1]->AddCorrHistos(i,hUnfolded,0,0);
     if(type == kFlagZ)  fCorrFF[fNCorrectionLevels-1]->AddCorrHistos(i,0,hUnfolded,0);
     if(type == kFlagXi) fCorrFF[fNCorrectionLevels-1]->AddCorrHistos(i,0,0,hUnfolded);
 
     // backfolding: apply response matrix to unfolded spectrum
-    TH1F* hBackFolded = ApplyResponse(hUnfolded,hnResponse);
-    if (hist)
-      hBackFolded->SetNameTitle(histNameBackFolded,hist->GetTitle());
+    TH1F* hBackFolded = ApplyResponse(hUnfolded,hnResponse); 
+    hBackFolded->SetNameTitle(histNameBackFolded,hist->GetTitle());
 
     if(type == kFlagPt) fh1FFTrackPtBackFolded[i] = hBackFolded;
     if(type == kFlagZ)  fh1FFZBackFolded[i]       = hBackFolded;
@@ -1476,8 +1524,7 @@ void AliFragmentationFunctionCorrections::UnfoldHistos(const Int_t nIter, const
     // ratio unfolded to original histo 
     TH1F* hRatioUnfolded = (TH1F*) hUnfolded->Clone(histNameRatioFolded);
     hRatioUnfolded->Reset();
-    if (hist)
-      hRatioUnfolded->Divide(hUnfolded,hist,1,1,"B");
+    hRatioUnfolded->Divide(hUnfolded,hist,1,1,"B");
 
     if(type == kFlagPt) fh1FFRatioTrackPtFolded[i] = hRatioUnfolded;
     if(type == kFlagZ)  fh1FFRatioZFolded[i]       = hRatioUnfolded;
@@ -1999,7 +2046,7 @@ void AliFragmentationFunctionCorrections::WriteSingleTrackEff(TString strInfile,
 { 
   // read task ouput from MC and write single track eff - standard dir/list 
      
-  TString strdir  = "PWG4_FragmentationFunction_" + strID;
+  TString strdir  = "PWGJE_FragmentationFunction_" + strID;
   TString strlist = "fracfunc_" + strID;
     
   WriteSingleTrackEff(strInfile,strdir,strlist,strOutfile,updateOutfile,strOutDir,strPostfix);
@@ -2154,7 +2201,7 @@ void AliFragmentationFunctionCorrections::WriteSingleTrackSecCorr(TString strInf
 { 
   // read task ouput from MC and write single track eff - standard dir/list 
      
-  TString strdir  = "PWG4_FragmentationFunction_" + strID;
+  TString strdir  = "PWGJE_FragmentationFunction_" + strID;
   TString strlist = "fracfunc_" + strID;
     
   WriteSingleTrackSecCorr(strInfile,strdir,strlist,strOutfile,updateOutfile,strOutDir);
@@ -2293,7 +2340,7 @@ void AliFragmentationFunctionCorrections::WriteSingleResponse(TString strInfile,
 { 
   // read task ouput from MC and write single track eff - standard dir/list 
      
-  TString strdir  = "PWG4_FragmentationFunction_" + strID;
+  TString strdir  = "PWGJE_FragmentationFunction_" + strID;
   TString strlist = "fracfunc_" + strID;
     
   WriteSingleResponse(strInfile,strdir,strlist,strOutfile,updateOutfile,strOutDir);
@@ -2385,7 +2432,7 @@ void AliFragmentationFunctionCorrections::WriteJetTrackEff(TString strInfile, TS
 { 
   // read task ouput from MC and write single track eff - standard dir/list 
      
-  TString strdir  = "PWG4_FragmentationFunction_" + strID;
+  TString strdir  = "PWGJE_FragmentationFunction_" + strID;
   TString strlist = "fracfunc_" + strID;
     
   WriteJetTrackEff(strInfile,strdir,strlist,strOutfile,updateOutfile);
@@ -2604,7 +2651,7 @@ void AliFragmentationFunctionCorrections::WriteJetSecCorr(TString strInfile, TSt
 { 
   // read task ouput from MC and write secondary correction - standard dir/list 
      
-  TString strdir  = "PWG4_FragmentationFunction_" + strID;
+  TString strdir  = "PWGJE_FragmentationFunction_" + strID;
   TString strlist = "fracfunc_" + strID;
     
   WriteJetSecCorr(strInfile,strdir,strlist,strOutfile,updateOutfile);
@@ -2817,7 +2864,7 @@ void AliFragmentationFunctionCorrections::WriteJetResponse(TString strInfile, TS
 { 
   // read task ouput from MC and write single track eff - standard dir/list 
      
-  TString strdir  = "PWG4_FragmentationFunction_" + strID;
+  TString strdir  = "PWGJE_FragmentationFunction_" + strID;
   TString strlist = "fracfunc_" + strID;
     
   WriteJetResponse(strInfile,strdir,strlist,strOutfile,updateOutfile);
@@ -3646,14 +3693,14 @@ void AliFragmentationFunctionCorrections::WriteJetSpecResponse(TString strInfile
 
   TList* list = 0;
 
-  if(strlist && strlist.Length()){
-    
+  if(strlist && strlist.Length()){ 
     if(!(list = (TList*) gDirectory->Get(strlist))){ 
       Printf("%s:%d -- error retrieving list %s from directory %s", (char*)__FILE__,__LINE__,strlist.Data(),strdir.Data());
       return;
     }
   }  
-  
+  if(list == 0)return; // catch strlist.Lenght() == 0;
+   
   THnSparse* hn6ResponseJetPt  = (THnSparse*) list->FindObject("fhnCorrelation");
  
   Int_t axis6RecJetPt = 0;
@@ -3793,7 +3840,7 @@ void AliFragmentationFunctionCorrections::ReadRawPtSpec(TString strInfile, TStri
 { 
   // read track pt spec from task ouput - standard dir/list 
      
-  TString strdir  = "PWG4_FragmentationFunction_" + strID;
+  TString strdir  = "PWGJE_FragmentationFunction_" + strID;
   TString strlist = "fracfunc_" + strID;
     
   ReadRawPtSpec(strInfile,strdir,strlist);