]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWGLF/FORWARD/analysis2/AliBaseMCTrackDensity.cxx
Merge branch 'feature-movesplit'
[u/mrichter/AliRoot.git] / PWGLF / FORWARD / analysis2 / AliBaseMCTrackDensity.cxx
index 7a8ea55dbd4779dddcd76a9a5ace9a8ea4d8374d..8c8100d78cd8d0e5ce47cd04eb9ed661fc2d1087 100644 (file)
@@ -11,6 +11,7 @@
 #include <iostream>
 #include "AliCollisionGeometry.h"
 #include "AliGenEventHeader.h"
+#include "AliForwardUtil.h"
 #include <TF1.h>
 #include <TGraph.h>
 
@@ -23,16 +24,14 @@ AliBaseMCTrackDensity::AliBaseMCTrackDensity()
     fEtaBinFlow(0),
     fPhiBinFlow(0),
     fNRefs(0),
-    fV2Eta(0), 
-    fV22Pt(0), 
-    fV24Pt(0), 
-    fV2B(0),
+    fWeights(),
     fVz(0), 
     fB(0),
     fPhiR(0),
     fDebug(false)
 {
   // Default constructor 
+  DGUARD(fDebug, 3,"Default CTOR of AliBasMCTrackDensity");
 }
 
 //____________________________________________________________________
@@ -44,16 +43,14 @@ AliBaseMCTrackDensity::AliBaseMCTrackDensity(const char* name)
     fEtaBinFlow(0),
     fPhiBinFlow(0),
     fNRefs(0),
-    fV2Eta(0), 
-    fV22Pt(0), 
-    fV24Pt(0), 
-    fV2B(0), 
+    fWeights(),
     fVz(0), 
     fB(0),
     fPhiR(0),
     fDebug(false)
 {
   // Normal constructor constructor 
+  DGUARD(fDebug, 3,"Named CTOR of AliBasMCTrackDensity: %s", name);
 }
 
 //____________________________________________________________________
@@ -65,16 +62,14 @@ AliBaseMCTrackDensity::AliBaseMCTrackDensity(const AliBaseMCTrackDensity& o)
     fEtaBinFlow(o.fEtaBinFlow),
     fPhiBinFlow(o.fPhiBinFlow),
     fNRefs(o.fNRefs),
-    fV2Eta(o.fV2Eta), 
-    fV22Pt(o.fV22Pt), 
-    fV24Pt(o.fV24Pt), 
-    fV2B(o.fV2B), 
+    fWeights(o.fWeights),
     fVz(o.fVz), 
     fB(o.fB),
     fPhiR(o.fPhiR),
     fDebug(o.fDebug)
 {
   // Normal constructor constructor 
+  DGUARD(fDebug, 3,"Copy CTOR of AliBasMCTrackDensity");
 }
 
 //____________________________________________________________________
@@ -82,6 +77,7 @@ AliBaseMCTrackDensity&
 AliBaseMCTrackDensity::operator=(const AliBaseMCTrackDensity& o)
 {
   // Assignment operator 
+  DGUARD(fDebug,3,"MC track density assignmetn");
   if (&o == this) return *this; 
   TNamed::operator=(o);
   fUseOnlyPrimary       = o.fUseOnlyPrimary;
@@ -91,10 +87,7 @@ AliBaseMCTrackDensity::operator=(const AliBaseMCTrackDensity& o)
   fNRefs                = o.fNRefs;
   fDebug                = o.fDebug;
   fUseFlowWeights       = o.fUseFlowWeights;
-  fV2Eta                = o.fV2Eta;
-  fV22Pt                = o.fV22Pt;
-  fV24Pt                = o.fV24Pt;
-  fV2B                  = o.fV2B;
+  fWeights              = o.fWeights;
   fVz                   = o.fVz;
   fB                    = o.fB;
   fPhiR                 = o.fPhiR;
@@ -103,8 +96,9 @@ AliBaseMCTrackDensity::operator=(const AliBaseMCTrackDensity& o)
 
 //____________________________________________________________________
 void
-AliBaseMCTrackDensity::DefineOutput(TList* l)
+AliBaseMCTrackDensity::CreateOutputObjects(TList* l)
 {
+  DGUARD(fDebug,1,"MC track defines output");
   TList* ll = new TList;
   ll->SetName(GetTitle());
   ll->SetOwner();
@@ -140,66 +134,8 @@ AliBaseMCTrackDensity::DefineOutput(TList* l)
   fNRefs->SetFillStyle(3001);
   fNRefs->SetDirectory(0);
   ll->Add(fNRefs);
-
-  SetupWeights(ll);
-}
-
-//____________________________________________________________________
-void 
-AliBaseMCTrackDensity::SetupWeights(TList* l)
-{
-  fV2Eta = new TF1("v2eta", "gaus", -6, 6);
-  fV2Eta->SetParameters(20 * 0.1, 0, 9);
-  l->Add(fV2Eta);
-
-  Int_t          ptN     = 19;
-  const Double_t ptX[]   = {0.00,     0.25,     0.350,    0.45, 
-                           0.55,     0.650,    0.75,     0.85, 
-                           0.950,    1.10,     1.30,     1.500,
-                           1.70,     1.90,     2.250,    2.75, 
-                           3.25,     3.750,    4.50};
-  { 
-    // v2{2} dependence on pt
-    const Double_t y[] = {0.00000,  0.043400, 0.059911, 0.073516,
-                         0.089756, 0.105486, 0.117391, 0.128199,
-                         0.138013, 0.158271, 0.177726, 0.196383,
-                         0.208277, 0.216648, 0.242954, 0.249961,
-                         0.240131, 0.269006, 0.207796};
-    
-    fV22Pt = new TGraph(ptN, ptX, y);
-    fV22Pt->SetName("v2_2_vs_pt");
-    fV22Pt->SetMarkerStyle(20);
-    fV22Pt->SetMarkerColor(kRed+1);
-    l->Add(fV22Pt);
-  }
-
-  {
-    const Double_t y[] = {0.000000, 0.038646, 0.049824, 0.066662,
-                         0.075856, 0.081583, 0.099778, 0.104674,
-                         0.118545, 0.131874, 0.152959, 0.155348,
-                         0.169751, 0.179052, 0.178532, 0.198851,
-                         0.185737, 0.239901, 0.186098};
-
-    // v2{4} dependence on pt 
-    fV24Pt = new TGraph(ptN, ptX, y);
-    fV24Pt->SetName("v2_4_vs_pt");
-    fV24Pt->SetMarkerStyle(20);
-    fV24Pt->SetMarkerColor(kBlue+1);
-    l->Add(fV24Pt);
-  }
-  {
-    // V2 dependence on centrality
-    Int_t n            = 8;
-    const Double_t x[] = {1.75,     4.225,    5.965,    7.765,
-                         9.215,    10.46,    11.565,   12.575};
-    const Double_t y[] = {0.017855, 0.032440, 0.055818, 0.073137,
-                         0.083898, 0.086690, 0.082040, 0.077777};
-    fV2B = new TGraph(n, x, y);
-    fV2B->SetName("v2_vs_b");
-    fV2B->SetMarkerStyle(20);
-    fV2B->SetMarkerColor(kGreen+1);
-    l->Add(fV2B);
-  }
+  
+  fWeights.Init(ll);
 }
 
 
@@ -209,6 +145,7 @@ AliBaseMCTrackDensity::StoreParticle(AliMCParticle*       particle,
                                     const AliMCParticle* mother, 
                                     AliTrackReference*   ref) const
 {
+  DGUARD(fDebug,3,"MC track density store particle");
   // Store a particle. 
   if (!ref) return 0;
 
@@ -285,6 +222,7 @@ AliBaseMCTrackDensity::GetMother(Int_t     iTr,
 Bool_t
 AliBaseMCTrackDensity::GetCollisionParameters(const AliMCEvent& event)
 { 
+  DGUARD(fDebug,3,"MC track density get collision parameters");
   AliCollisionGeometry* hd = 
     dynamic_cast<AliCollisionGeometry*>(event.GenEventHeader());
   fPhiR = (hd ? hd->ReactionPlaneAngle() : 0.);
@@ -298,6 +236,7 @@ AliBaseMCTrackDensity::ProcessTrack(AliMCParticle* particle,
                                    const AliMCParticle* mother)
 {
   // Check the returned particle 
+  DGUARD(fDebug,3,"MC track density Process a track");
   if (!particle) return false;
     
   Int_t              nTrRef = particle->GetNumberOfTrackReferences();
@@ -355,6 +294,7 @@ AliBaseMCTrackDensity::ProcessTracks(const AliMCEvent& event,
   // Return:
   //    True on succes, false otherwise 
   //
+  DGUARD(fDebug,3,"MC track density Process a tracks");
   fVz = vz;
   GetCollisionParameters(event);
   
@@ -378,7 +318,7 @@ AliBaseMCTrackDensity::ProcessTracks(const AliMCEvent& event,
     // track back to the original primary?
     if (fUseOnlyPrimary && !isPrimary) continue;
 
-    const AliMCParticle* mother = GetMother(iTr, event);
+    const AliMCParticle* mother = isPrimary ? particle : GetMother(iTr, event);
     ProcessTrack(particle, mother);
 
   } // Loop over tracks
@@ -391,29 +331,30 @@ Double_t
 AliBaseMCTrackDensity::CalculateWeight(Double_t eta, Double_t pt, 
                                       Double_t phi, Int_t id) const
 {
-  Double_t w = (fV2Eta->Eval(eta) * 0.5 * (fV22Pt->Eval(pt) + fV24Pt->Eval(pt)) 
-               * fV2B->Eval(fB) / fV2B->Eval(10.46) 
-               * 2 * TMath::Cos(2* (phi - fPhiR)));
-  UInt_t aid = TMath::Abs(id);
-  switch (aid) { 
-  case 211:  w *= 1.3; break; // pions 
-  case 2212: w *= 1.0; break; // protons 
-  default:   w *= 0.7; break;
-  }
-  return w;
+  return fWeights.CalcWeight(eta, pt, phi, id, fPhiR, fB);
 }
+
+#define PF(N,V,...)                                    \
+  AliForwardUtil::PrintField(N,V, ## __VA_ARGS__)
+#define PFB(N,FLAG)                            \
+  do {                                                                 \
+    AliForwardUtil::PrintName(N);                                      \
+    std::cout << std::boolalpha << (FLAG) << std::noboolalpha << std::endl; \
+  } while(false)
+#define PFV(N,VALUE)                                   \
+  do {                                                 \
+    AliForwardUtil::PrintName(N);                      \
+    std::cout << (VALUE) << std::endl; } while(false)
+
 //____________________________________________________________________
 void
 AliBaseMCTrackDensity::Print(Option_t* /*option*/) const 
 {
-  char ind[gROOT->GetDirLevel()+1];
-  for (Int_t i = 0; i < gROOT->GetDirLevel(); i++) ind[i] = ' ';
-  ind[gROOT->GetDirLevel()] = '\0';
-  std::cout << ind << ClassName() << ": " << GetName() << '\n'
-           << std::boolalpha 
-           << ind << " Only primary tracks:    " << fUseOnlyPrimary << '\n'
-           << ind << " Use flow after burner:  " << fUseFlowWeights 
-           << std::noboolalpha << std::endl;
+  AliForwardUtil::PrintTask(*this);
+  gROOT->IncreaseDirLevel();  
+  PFB("Only primary tracks", fUseOnlyPrimary);
+  PFB("Use flow after burner", fUseFlowWeights);
+  gROOT->DecreaseDirLevel();
   
 }