preparations for weights in generating function cumulants
authorsnelling <snelling@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 20 Feb 2009 13:33:47 +0000 (13:33 +0000)
committersnelling <snelling@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 20 Feb 2009 13:33:47 +0000 (13:33 +0000)
PWG2/FLOW/AliFlowCommon/AliFlowAnalysisWithCumulants.cxx
PWG2/FLOW/AliFlowCommon/AliFlowAnalysisWithCumulants.h
PWG2/FLOW/AliFlowTasks/AliAnalysisTaskCumulants.cxx
PWG2/FLOW/AliFlowTasks/AliAnalysisTaskCumulants.h
PWG2/FLOW/macros/runAliAnalysisTaskFlow.C
PWG2/FLOW/macros/runFlowAnalysis.C

index 1debaea..3a1207a 100644 (file)
@@ -61,6 +61,7 @@ ClassImp(AliFlowAnalysisWithCumulants)
 AliFlowAnalysisWithCumulants::AliFlowAnalysisWithCumulants():  
  fTrack(NULL),
  fHistList(NULL),
+ fWeightsList(NULL),
  fR0(0),
  fPtMax(0),
  fPtMin(0),
@@ -125,10 +126,15 @@ AliFlowAnalysisWithCumulants::AliFlowAnalysisWithCumulants():
  fDiffFlowGenFunIm7(NULL),
  */
  fCommonHists(NULL),
- fOtherEquations(kFALSE)
+ fOtherEquations(kFALSE),
+ fUsePhiWeights(kFALSE),
+ fUsePtWeights(kFALSE),
+ fUseEtaWeights(kFALSE)
 {
  //constructor 
  fHistList = new TList();
+ fWeightsList = new TList();
+ fWeightsList->SetName("Weights");
  fR0=AliFlowCumuConstants::fgR0;
  //Pt:
  fPtMax=AliFlowCommonConstants::GetPtMax(); 
@@ -154,11 +160,12 @@ AliFlowAnalysisWithCumulants::~AliFlowAnalysisWithCumulants()
 {
  //desctructor
  delete fHistList; 
+ delete fWeightsList;
 }
 
 //================================================================================================================
 
-void AliFlowAnalysisWithCumulants::CreateOutputObjects()
+void AliFlowAnalysisWithCumulants::Init()
 {
  //various output histograms
  
@@ -491,8 +498,10 @@ void AliFlowAnalysisWithCumulants::CreateOutputObjects()
  //common histograms for final results (8th order)
  fCommonHistsResults8th = new AliFlowCommonHistResults("AliFlowCommonHistResults8thOrderGFC");
  fHistList->Add(fCommonHistsResults8th);
-  
-}//end of CreateOutputObjects()
+ // add list fWeightsList with weights to the main list
+ fHistList->Add(fWeightsList); 
+}//end of Init()
 
 //================================================================================================================
 
@@ -502,6 +511,63 @@ void AliFlowAnalysisWithCumulants::Make(AliFlowEventSimple* anEvent)
  Int_t nPrim = anEvent->NumberOfTracks(); //total multiplicity
  
  Int_t nEventNSelTracksIntFlow = anEvent->GetEventNSelTracksIntFlow(); //selected multiplicity (particles used for int. flow)
+    
+ //---------------------------------------------------------------------------------------------------------
+ // weights:
+ Bool_t useWeights = fUsePhiWeights||fUsePtWeights||fUseEtaWeights;
+ cout<<endl;
+ cout<<fUsePhiWeights<<endl;
+ cout<<fUsePtWeights<<endl;
+ cout<<fUseEtaWeights<<endl;
+ cout<<endl;
+
+ TH1F *phiWeights = NULL; // histogram with phi weights
+ TH1D *ptWeights  = NULL; // histogram with pt weights
+ TH1D *etaWeights = NULL; // histogram with eta weights
+
+ //Double_t wPhi = 1.; // phi weight
+ //Double_t wPt  = 1.; // pt weight
+ //Double_t wEta = 1.; // eta weight
+   
+ if(useWeights)
+ {
+  if(!fWeightsList)
+  {
+   cout<<" WARNING: fWeightsList is NULL pointer. "<<endl;
+   exit(0);
+  }
+  if(fUsePhiWeights) 
+  {
+   phiWeights = dynamic_cast<TH1F *>(fWeightsList->FindObject("phi_weights"));
+   if(!phiWeights)
+   {
+    cout<<" WARNING: couldn't access the histogram with phi weights. "<<endl;
+    exit(0);
+   } 
+  } 
+  if(fUsePtWeights) 
+  { 
+   ptWeights = dynamic_cast<TH1D *>(fWeightsList->FindObject("pt_weights"));
+   if(!ptWeights) 
+   {
+    cout<<" WARNING: couldn't access the histogram with pt weights. "<<endl;
+    exit(0);
+   } 
+  } 
+  if(fUseEtaWeights) 
+  {
+   etaWeights = dynamic_cast<TH1D *>(fWeightsList->FindObject("eta_weights"));
+   if(!etaWeights) 
+   {
+    cout<<" WARNING: couldn't access the histogram with eta weights. "<<endl;
+    exit(0);
+   }
+  } 
+ } 
+ //---------------------------------------------------------------------------------------------------------
   
  if(nEventNSelTracksIntFlow>9) //generating function formalism applied here make sense only for selected multiplicity >= 10 
  { 
@@ -556,7 +622,7 @@ void AliFlowAnalysisWithCumulants::Make(AliFlowEventSimple* anEvent)
  AliFlowVector fQVector;
  fQVector.Set(0.,0.);
  fQVector.SetMult(0);
- fQVector=anEvent->GetQ();                               //get the Q vector for this event
+ fQVector=anEvent->GetQ(); //get the Q vector for this event
  fQVectorComponentsGFC->Fill(0.,fQVector.X(),1);         //in the 1st bin fill Q_x
  fQVectorComponentsGFC->Fill(1.,fQVector.Y(),1);         //in the 2nd bin fill Q_y
  fQVectorComponentsGFC->Fill(2.,pow(fQVector.X(),2.),1); //in the 3rd bin fill (Q_x)^2
index 46ab0ff..5319c3c 100644 (file)
@@ -39,16 +39,19 @@ class AliFlowAnalysisWithCumulants{
   AliFlowAnalysisWithCumulants();
   virtual ~AliFlowAnalysisWithCumulants(); 
   
-  virtual void CreateOutputObjects();
+  virtual void Init();
   virtual void Make(AliFlowEventSimple* anEvent);
   virtual void Finish();
   virtual void WriteHistograms(TString* outputFileName);
   virtual void WriteHistograms(TString outputFileName);
   
 //----------------------------------------------------------------------------------------------------------------
-//                                            setters and getters                                     fBinWidth            
+//                                            setters and getters                                                 
 //----------------------------------------------------------------------------------------------------------------
-  TList* GetHistList() const {return this->fHistList;}      //output histogram list
+  TList* GetHistList() const {return this->fHistList;}     
+  
+  void SetWeightsList(TList* wlist) {this->fWeightsList = wlist;}
+  TList* GetWeightsList() const {return this->fWeightsList;}
   
   void SetIntFlowResults(TH1D* const ifr)  {this->fIntFlowResultsGFC = ifr;};
   TH1D* GetIntFlowResults() const    {return this->fIntFlowResultsGFC;};
@@ -154,6 +157,15 @@ class AliFlowAnalysisWithCumulants{
   
   void SetCommonHists(AliFlowCommonHist* const ch)  {this->fCommonHists = ch;};
   AliFlowCommonHist* GetCommonHists() const   {return this->fCommonHists;};
+  
+  void SetUsePhiWeights(Bool_t const uPhiW) {this->fUsePhiWeights = uPhiW;};
+  Bool_t GetUsePhiWeights() const {return this->fUsePhiWeights;};
+  
+  void SetUsePtWeights(Bool_t const uPtW) {this->fUsePtWeights = uPtW;};
+  Bool_t GetUsePtWeights() const {return this->fUsePtWeights;};
+  
+  void SetUseEtaWeights(Bool_t const uEtaW) {this->fUseEtaWeights = uEtaW;};
+  Bool_t GetUseEtaWeights() const {return this->fUseEtaWeights;};
 //----------------------------------------------------------------------------------------------------------------
  
  private:
@@ -173,6 +185,7 @@ class AliFlowAnalysisWithCumulants{
   static const Int_t fgkFlow = AliFlowCumuConstants::kFlow;     //integrated flow coefficient to be calculated
   static const Int_t fgkMltpl = AliFlowCumuConstants::kMltpl;   //the multiple in p=m*n (diff. flow) 
   TList* fHistList;                                             //list to hold all output histograms
+  TList* fWeightsList;                                          //list to hold all histograms with weights
 
   Double_t fR0;         //needed for numerics
   Double_t fPtMax;      //maximum pt
@@ -244,6 +257,10 @@ class AliFlowAnalysisWithCumulants{
   AliFlowCommonHist* fCommonHists;      //common control histograms
   
   Bool_t fOtherEquations; //numerical equations for cumulants solved up to different highest order 
+  
+  Bool_t fUsePhiWeights;  //phi weights
+  Bool_t fUsePtWeights;   //v_2(pt) weights
+  Bool_t  fUseEtaWeights; //v_2(eta) weights
       
   ClassDef(AliFlowAnalysisWithCumulants, 0);
 };
index acd841f..05f9cb8 100644 (file)
@@ -63,7 +63,7 @@ ClassImp(AliAnalysisTaskCumulants)
 
 //================================================================================================================
 
-AliAnalysisTaskCumulants::AliAnalysisTaskCumulants(const char *name, Bool_t on): 
+AliAnalysisTaskCumulants::AliAnalysisTaskCumulants(const char *name, Bool_t on, Bool_t useWeights): 
  AliAnalysisTask(name,""), 
  fESD(NULL),
  fAOD(NULL),
@@ -75,7 +75,12 @@ AliAnalysisTaskCumulants::AliAnalysisTaskCumulants(const char *name, Bool_t on):
  fListHistos(NULL),
  fQAInt(NULL),
  fQADiff(NULL),
- fQA(on)
+ fQA(on),
+ fUseWeights(useWeights),
+ fUsePhiWeights(kFALSE),
+ fUsePtWeights(kFALSE),
+ fUseEtaWeights(kFALSE),
+ fListWeights(NULL)
 {
 //constructor
  cout<<"AliAnalysisTaskCumulants::AliAnalysisTaskCumulants(const char *name)"<<endl;
@@ -83,6 +88,12 @@ AliAnalysisTaskCumulants::AliAnalysisTaskCumulants(const char *name, Bool_t on):
  // Define input and output slots here
  // Input slot #0 works with a TChain
  DefineInput(0, TChain::Class());
+ // Input slot #1 is needed for the weights 
+ if(useWeights)
+ {
+  DefineInput(1, TList::Class());   
+ }
   
  // Output slot #0 writes into a TList container
  DefineOutput(0, TList::Class());  
@@ -104,7 +115,12 @@ AliAnalysisTaskCumulants::AliAnalysisTaskCumulants():
  fListHistos(NULL),  
  fQAInt(NULL),
  fQADiff(NULL),
- fQA(kFALSE)
+ fQA(kFALSE),
+ fUseWeights(kFALSE),
+ fUsePhiWeights(kFALSE),
+ fUsePtWeights(kFALSE),
+ fUseEtaWeights(kFALSE),
+ fListWeights(NULL)
 {
  //dummy constructor
  cout<<"AliAnalysisTaskCumulants::AliAnalysisTaskCumulants()"<<endl;
@@ -187,7 +203,23 @@ void AliAnalysisTaskCumulants::CreateOutputObjects()
   
  //analyser
  fGFC = new AliFlowAnalysisWithCumulants();
- fGFC->CreateOutputObjects();
+ fGFC->Init();
+ //weights:
+ if(fUseWeights)
+ {
+  //pass the flags to class:
+  if(fUsePhiWeights) fGFC->SetUsePhiWeights(fUsePhiWeights);
+  if(fUsePtWeights) fGFC->SetUsePtWeights(fUsePtWeights);
+  if(fUseEtaWeights) fGFC->SetUseEtaWeights(fUseEtaWeights);
+  //get data from input slot #1 which is used for weights:
+  if(GetNinputs()==2) 
+  {                   
+   fListWeights = (TList*)GetInputData(1); 
+  }
+  //pass the list with weights to class:
+  if(fListWeights) fGFC->SetWeightsList(fListWeights);
+ }
 
  if(fGFC->GetHistList()) 
  {
index b379d14..cdabc4d 100644 (file)
@@ -32,7 +32,7 @@ class TFile;
 class AliAnalysisTaskCumulants : public AliAnalysisTask{
  public:
   AliAnalysisTaskCumulants();
-  AliAnalysisTaskCumulants(const char *name, Bool_t QAon = kFALSE);
+  AliAnalysisTaskCumulants(const char *name, Bool_t QAon = kFALSE, Bool_t useWeights=kFALSE);
   virtual ~AliAnalysisTaskCumulants(){}; 
   
   virtual void   ConnectInputData(Option_t *);
@@ -53,6 +53,13 @@ class AliAnalysisTaskCumulants : public AliAnalysisTask{
   TList*        GetQAList2()              {return this->fQADiff; }
   void          SetQAOn(Bool_t kt)        {this->fQA = kt; }
   Bool_t        GetQAOn()                 {return this->fQA; }
+  
+  void SetUsePhiWeights(Bool_t const uPhiW) {this->fUsePhiWeights = uPhiW;};
+  Bool_t GetUsePhiWeights() const {return this->fUsePhiWeights;};
+  void SetUsePtWeights(Bool_t const uPtW) {this->fUsePtWeights = uPtW;};
+  Bool_t GetUsePtWeights() const {return this->fUsePtWeights;};
+  void SetUseEtaWeights(Bool_t const uEtaW) {this->fUseEtaWeights = uEtaW;};
+  Bool_t GetUseEtaWeights() const {return this->fUseEtaWeights;};
  
  private:
   AliAnalysisTaskCumulants(const AliAnalysisTaskCumulants& aatc);
@@ -71,6 +78,12 @@ class AliAnalysisTaskCumulants : public AliAnalysisTask{
   TList*        fQADiff;                  // QA histogram list
 
   Bool_t fQA;                             // flag to set the filling of the QA hostograms   
+  
+  Bool_t       fUseWeights;               // use any weights
+  Bool_t       fUsePhiWeights;            // phi weights
+  Bool_t       fUsePtWeights;             // v_2(pt) weights
+  Bool_t       fUseEtaWeights;            // v_2(eta) weights  
+  TList*       fListWeights;              // list with weights
            
   ClassDef(AliAnalysisTaskCumulants, 1); 
 };
index 5090414..c5324de 100644 (file)
@@ -42,7 +42,7 @@ Bool_t SP    = kTRUE;
 Bool_t LYZ1  = kTRUE;
 Bool_t LYZ2  = kFALSE;
 Bool_t LYZEP = kFALSE;
-Bool_t GFC   = kFALSE;
+Bool_t GFC   = kTRUE;
 Bool_t QC    = kFALSE;
 Bool_t FQD   = kFALSE;
 Bool_t MCEP  = kTRUE;
@@ -97,7 +97,7 @@ const Int_t maxnsigmatovertex2 = 3;
 //void runAliAnalysisTaskFlow(Int_t mode=mPROOF, const Char_t* data="/PWG2/akisiel/Therminator_midcentral_AOD", Int_t nRuns=44, Int_t offset=0)
 
 // Data at Nikhef
-void runAliAnalysisTaskFlow(Int_t mode=mLocal, Int_t nRuns = 55, const Char_t* dataDir="/data/alice2/kolk/Therminator_midcentral", Int_t offset = 0) 
+void runAliAnalysisTaskFlow(Int_t mode=mLocal, Int_t nRuns = 4, const Char_t* dataDir="/data/alice2/kolk/Therminator_midcentral", Int_t offset = 0) 
 //void runAliAnalysisTaskFlow(Int_t mode=mLocalPAR, Int_t nRuns = 55, const Char_t* dataDir="/data/alice2/kolk/Therminator_midcentral", Int_t offset = 0) 
 
 // Data on my mac
@@ -543,9 +543,12 @@ if (mode==mLocal || mode == mLocalPAR || mode == mGRID) {
    mgr->AddTask(taskLYZEP);
  }
  if (GFC){
-   if (QA) { AliAnalysisTaskCumulants *taskGFC = new AliAnalysisTaskCumulants("TaskCumulants",kTRUE);}
-   else { AliAnalysisTaskCumulants *taskGFC = new AliAnalysisTaskCumulants("TaskCumulants",kFALSE);}
+   if (QA) { AliAnalysisTaskCumulants *taskGFC = new AliAnalysisTaskCumulants("TaskCumulants",kTRUE,useWeights);}
+   else { AliAnalysisTaskCumulants *taskGFC = new AliAnalysisTaskCumulants("TaskCumulants",kFALSE,useWeights);}
    taskGFC->SetAnalysisType(type);
+   taskGFC->SetUsePhiWeights(usePhiWeights); 
+   taskGFC->SetUsePtWeights(usePtWeights);
+   taskGFC->SetUseEtaWeights(useEtaWeights); 
    taskGFC->SetCFManager1(cfmgr1);
    taskGFC->SetCFManager2(cfmgr2);
    if (QA) { 
@@ -804,6 +807,10 @@ if (mode==mLocal || mode == mLocalPAR || mode == mGRID) {
    mgr->ConnectOutput(taskGFC,0,coutputGFC);
    if (QA) { mgr->ConnectOutput(taskGFC,1,coutputQA1GFC);
    mgr->ConnectOutput(taskGFC,2,coutputQA2GFC); }
+   if (useWeights) {
+     mgr->ConnectInput(taskGFC,1,cinputWeights);
+     cinputWeights->SetData(weightsList);
+   } 
  }  
  if (QC)   { 
    mgr->ConnectInput(taskQC,0,cinput1); 
index bb304a6..708caa9 100644 (file)
@@ -12,7 +12,7 @@ Bool_t LYZ2  = kFALSE;
 Bool_t LYZEP = kFALSE; 
 Bool_t GFC   = kTRUE;
 Bool_t QC    = kTRUE;
-Bool_t FQD   = kTRUE;
+Bool_t FQD   = kFALSE;
 Bool_t MCEP  = kFALSE; //does not work yet 24/12/08
 //--------------------------------------------------------------------------------------
 
@@ -52,9 +52,9 @@ enum anaModes {mLocal,mLocalSource,mLocalPAR,};
 
 Int_t offset = 0;
                                           
-int runFlowAnalysis(Int_t mode=mLocal, Int_t aRuns = 100, const char* 
-                   //                    dir="/data/alice1/kolk/KineOnly3/")
-                   dir="/Users/snelling/alice_data/KineOnly3/")
+int runFlowAnalysis(Int_t mode=mLocal, Int_t aRuns = 44, const char* 
+                                         dir="/data/alice1/kolk/KineOnly3/")
+                   //dir="/Users/snelling/alice_data/KineOnly3/")
 {
   TStopwatch timer;
   timer.Start();
@@ -148,7 +148,11 @@ int runFlowAnalysis(Int_t mode=mLocal, Int_t aRuns = 100, const char*
   //GFC = Generating Function Cumulants 
   if(GFC) {
     AliFlowAnalysisWithCumulants* gfc = new AliFlowAnalysisWithCumulants();
-    gfc->CreateOutputObjects();
+    gfc->Init();
+    if(listWithWeights) gfc->SetWeightsList(listWithWeights);
+    if(usePhiWeights) gfc->SetUsePhiWeights(usePhiWeights);
+    if(usePtWeights) gfc->SetUsePtWeights(usePtWeights);
+    if(useEtaWeights) gfc->SetUseEtaWeights(useEtaWeights);
   }
   
   //FQD = Fitting q-distribution