]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Critical fixes to the SPD cluser code:
authorcholm <cholm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 16 Feb 2011 15:28:35 +0000 (15:28 +0000)
committercholm <cholm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 16 Feb 2011 15:28:35 +0000 (15:28 +0000)
- Removed DefineOutput from default CTOR - this CTOR is only used by ROOT I/O
  system, and _must_not_ set up things, as the data will be set via the
  streamer.
- Make all Getters of manager const.
- Moved implementation of manager class member functions to .cxx file.
- Removed direct setters/getters from task.
- Check pointer validity before de-referencing.
- Cache (in a static) return string from GetFileName - if not static,
  the data pointed to could disappear and lead to very strange errors.
- Fix includes and wrong cast in AliCentraldNdeta.cxx
- Also generate dictionary AliCentralMultiplicityTask::Manager - otherwise
  objects of that class is not persistent.

PWG2/FORWARD/analysis2/AliCentralMultiplicityTask.cxx
PWG2/FORWARD/analysis2/AliCentralMultiplicityTask.h
PWG2/FORWARD/analysis2/AliCentraldNdetaTask.cxx
PWG2/PWG2forward2LinkDef.h

index a45a784d13436e10dc50e97c8b821ee75e279f5a..5b843a707b66ffba2ca5c890bdfb9c954dff6b84 100644 (file)
@@ -24,6 +24,7 @@
 #include "AliMultiplicity.h"
 #include <TROOT.h>
 #include <TFile.h>
+#include <TError.h>
 #include <iostream>
 #include <iomanip>
 
@@ -39,7 +40,8 @@ AliCentralMultiplicityTask::AliCentralMultiplicityTask(const char* name)
   DefineOutput(1, TList::Class());
 }
 //____________________________________________________________________
-void AliCentralMultiplicityTask::UserCreateOutputObjects() {
+void AliCentralMultiplicityTask::UserCreateOutputObjects() 
+{
 
   AliAnalysisManager* am = AliAnalysisManager::GetAnalysisManager();
   AliAODHandler*      ah = 
@@ -55,7 +57,8 @@ void AliCentralMultiplicityTask::UserCreateOutputObjects() {
   
 }
 //____________________________________________________________________
-void AliCentralMultiplicityTask::UserExec(Option_t* /*option*/) {
+void AliCentralMultiplicityTask::UserExec(Option_t* /*option*/) 
+{
   
   AliESDInputHandler* eventHandler = 
     dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()
@@ -76,9 +79,10 @@ void AliCentralMultiplicityTask::UserExec(Option_t* /*option*/) {
   vertex->GetXYZ(vertexXYZ);
   if(TMath::Abs(vertexXYZ[2]) > 10) return;
   
-  Double_t delta = 2 ;
+  Double_t delta           = 2 ;
   Double_t vertexBinDouble = (vertexXYZ[2] + 10) / delta;
-  Int_t vtxbin = (Int_t)vertexBinDouble +1 ; //HHD: The vtxbins are 1-10, not 0-9
+  //HHD: The vtxbins are 1-10, not 0-9
+  Int_t    vtxbin          = Int_t(vertexBinDouble + 1) ; 
   
   // Make sure AOD is filled
   AliAnalysisManager* am = AliAnalysisManager::GetAnalysisManager();
@@ -95,17 +99,16 @@ void AliCentralMultiplicityTask::UserExec(Option_t* /*option*/) {
   
   const AliMultiplicity* spdmult = esd->GetMultiplicity();
   //Filling clusters in layer 1 used for tracklets...
-  for(Int_t j = 0; j< spdmult->GetNumberOfTracklets();j++) {
+  for(Int_t j = 0; j< spdmult->GetNumberOfTracklets();j++)
     aodHist->Fill(spdmult->GetEta(j),spdmult->GetPhi(j));
-  }
+
   //...and then the unused ones in layer 1 
-  for(Int_t j = 0; j< spdmult->GetNumberOfSingleClusters();j++) {
+  for(Int_t j = 0; j< spdmult->GetNumberOfSingleClusters();j++) 
     aodHist->Fill(-TMath::Log(TMath::Tan(spdmult->GetThetaSingle(j)/2.)),
-                  spdmult->GetPhiSingle(j));
-  }
+                 spdmult->GetPhiSingle(j));
   
-  // Corrections
   
+  // Corrections
   TH2D* hSecMap     = fManager.GetSecMapCorrection(vtxbin);
   TH1D* hAcceptance = fManager.GetAcceptanceCorrection(vtxbin);
   
@@ -123,32 +126,29 @@ void AliCentralMultiplicityTask::UserExec(Option_t* /*option*/) {
       
       Float_t aodnew   = aodvalue / acccor ;
       aodHist->SetBinContent(nx,ny, aodnew);
-      Float_t error = aodnew*TMath::Sqrt(TMath::Power(aodHist->GetBinError(nx,ny)/aodvalue,2) +
-                                        TMath::Power(hAcceptance->GetBinError(nx)/acccor,2) );
+      Float_t aodErr   = aodHist->GetBinError(nx,ny);
+      Float_t accErr   = hAcceptance->GetBinError(nx);
+      Float_t error    = aodnew *TMath::Sqrt(TMath::Power(aodErr/aodvalue,2) +
+                                            TMath::Power(accErr/acccor,2) );
       aodHist->SetBinError(nx,ny,error);
       
     }
     //Filling underflow bin if we eta bin is in range
     if(etabinSeen) aodHist->SetBinContent(nx,0, 1.);
-    
   }  
 
   PostData(1,fList);
-  
 }
 //____________________________________________________________________
-void AliCentralMultiplicityTask::Terminate(Option_t* /*option*/) {
-
-
-
+void AliCentralMultiplicityTask::Terminate(Option_t* /*option*/) 
+{
 }
 //____________________________________________________________________
 void
 AliCentralMultiplicityTask::Print(Option_t* /*option*/) const
 {
-   
 }
-//____________________________________________________________________
+//====================================================================
 AliCentralMultiplicityTask::Manager::Manager() :
   fAcceptancePath("$ALICE_ROOT/PWG2/FORWARD/corrections/CentralAcceptance"),
   fSecMapPath("$ALICE_ROOT/PWG2/FORWARD/corrections/CentralSecMap"),
@@ -161,22 +161,56 @@ AliCentralMultiplicityTask::Manager::Manager() :
 
 }
 //____________________________________________________________________
-const char* AliCentralMultiplicityTask::Manager::GetFileName(UShort_t  what ,
-                                                            UShort_t  sys, 
-                                                            UShort_t  sNN,
-                                                            Short_t   field) {
-  
-  TString fname = "";
+AliCentralMultiplicityTask::Manager::Manager(const Manager& o) 
+  :fAcceptancePath(o.fAcceptancePath),
+   fSecMapPath(o.fSecMapPath),
+   fAcceptance(o.fAcceptance),
+   fSecmap(o.fSecmap),
+   fAcceptanceName(o.fAcceptanceName),
+   fSecMapName(o.fSecMapName) 
+{}
+//____________________________________________________________________
+AliCentralMultiplicityTask::Manager&
+AliCentralMultiplicityTask::Manager::operator=(const Manager& o)
+{
+  fAcceptancePath = o.fAcceptancePath;
+  fSecMapPath     = o.fSecMapPath;
+  fAcceptance     = o.fAcceptance;
+  fSecmap         = o.fSecmap;
+  fAcceptanceName = o.fAcceptanceName;
+  fSecMapName     = o.fSecMapName;
+  return *this;
+}
+
+//____________________________________________________________________
+const char* 
+AliCentralMultiplicityTask::Manager::GetFullFileName(UShort_t what, 
+                                                    UShort_t sys, 
+                                                    UShort_t sNN,  
+                                                    Short_t  field) const
+{
+  return Form("%s/%s",
+             what == 0 ? GetSecMapPath() : GetAcceptancePath(), 
+             GetFileName(what, sys, sNN, field));
+}
+
+//____________________________________________________________________
+const char* 
+AliCentralMultiplicityTask::Manager::GetFileName(UShort_t  what ,
+                                                UShort_t  sys, 
+                                                UShort_t  sNN,
+                                                Short_t   field) const
+{
+  // Must be static - otherwise the data may disappear on return from
+  // this member function
+  static TString fname = "";
   
   switch(what) {
-  case 0:
-    fname.Append(fSecMapName.Data());
-    break;
-  case 1: 
-    fname.Append(fAcceptanceName.Data());
-    break;
+  case 0:  fname.Append(fSecMapName.Data());     break;
+  case 1:  fname.Append(fAcceptanceName.Data()); break;
   default:
-    printf("Invalid indentifier for central object, must be 0 or 1!");
+    ::Error("GetFileName", 
+           "Invalid indentifier %d for central object, must be 0 or 1!", what);
     break;
   }
   fname.Append(Form("_%s_%04dGeV_%c%1dkG.root", 
@@ -184,25 +218,50 @@ const char* AliCentralMultiplicityTask::Manager::GetFileName(UShort_t  what ,
                    sNN, (field < 0 ? 'm' : 'p'), TMath::Abs(field)));
   
   return fname.Data();
-  
 }
+
 //____________________________________________________________________
-void AliCentralMultiplicityTask::Manager::Init( UShort_t  sys, 
-                                               UShort_t  sNN,
-                                               Short_t   field) {
-  
+TH2D* 
+AliCentralMultiplicityTask::Manager::GetSecMapCorrection(UShort_t vtxbin) const
+{
+  if (!fSecmap) { 
+    ::Warning("GetSecMapCorrection","No secondary map defined");
+    return 0;
+  }
+  return fSecmap->GetCorrection(vtxbin);
+}
+//____________________________________________________________________
+TH1D* 
+AliCentralMultiplicityTask::Manager::GetAcceptanceCorrection(UShort_t vtxbin) 
+  const 
+{
+  if (!fAcceptance) { 
+    ::Warning("GetAcceptanceCorrection","No acceptance map defined");
+    return 0;
+  }
+  return fAcceptance->GetCorrection(vtxbin);
+}
+
+//____________________________________________________________________
+void 
+AliCentralMultiplicityTask::Manager::Init(UShort_t  sys, 
+                                         UShort_t  sNN,
+                                         Short_t   field) 
+{
   TFile fsec(GetFullFileName(0,sys,sNN,field));
-  fSecmap = dynamic_cast<AliCentralCorrSecondaryMap*>(fsec.Get(fSecMapName.Data()));  
+  fSecmap = 
+    dynamic_cast<AliCentralCorrSecondaryMap*>(fsec.Get(fSecMapName.Data()));  
   if(!fSecmap) {
-    printf("no central Secondary Map found!") ;
+    ::Error("Init", "no central Secondary Map found!") ;
     return;
   }
   TFile facc(GetFullFileName(1,sys,sNN,field));
-  fAcceptance = dynamic_cast<AliCentralCorrAcceptance*>(facc.Get(fAcceptanceName.Data()));
-if(!fAcceptance) {
-  printf("no central Acceptance found!") ;
-  return;
- }
+  fAcceptance = 
+    dynamic_cast<AliCentralCorrAcceptance*>(facc.Get(fAcceptanceName.Data()));
+  if(!fAcceptance) {
+    ::Error("Init", "no central Acceptance found!") ;
+    return;
+  }
 
 }
 //
index 77463f7c77d248ba0faf03ac3ac91a89313b8bcf..637b8589bd9243c665cb0ce70bc9368f1051bdb9 100644 (file)
@@ -74,7 +74,6 @@ public:
       fAODCentral(),
       fManager()
   {
-    
   }
   /** 
    * Copy constructor 
@@ -88,7 +87,7 @@ public:
       fAODCentral(o.fAODCentral),
       fManager(o.fManager)
   {
-    
+    DefineOutput(1, TList::Class());
   }
   /** 
    * Assignment operator 
@@ -104,6 +103,9 @@ public:
     fAODCentral = o.fAODCentral;
     fManager    = o.fManager;
     
+    
+    DefineOutput(1, TList::Class());
+    
     return *this;
   }
   /** 
@@ -143,102 +145,155 @@ public:
    * @param option Not used
    */
   virtual void Print(Option_t* option="") const;
-  /** 
-   * Set Path for acceptance 
-   * 
-   * @param path
-   */
-  void          SetAcceptancePath(const char* path) {fManager.SetAcceptancePath(path); }
-  /** 
-   * Set Path for Secondary Map 
+
+  //__________________________________________________________________
+  /**
+   * Manager of corrections 
+   *
+   * This is a small class to fetch corrections for secondaries and
+   * dead channels.
    * 
-   * @param path
    */
-  
-  void          SetSecMapPath(const char* path) {fManager.SetSecMapPath(path); }
-  
-  char*         GetFullFileName(UShort_t  what ,
-                               UShort_t  sys, 
-                               UShort_t  sNN,
-                               Short_t   field) {return fManager.GetFullFileName(what ,sys, sNN, field); }
-  
-  const char*   GetAcceptanceName() {return fManager.GetAcceptanceName(); }
-  const char*   GetSecMapName() {return fManager.GetSecMapName(); }
-  
-  
-  class Manager {
-    
-    // This is a small class to fetch corrections for secondaries and dead
-    // channels.
-    
+  class Manager 
+  {
   public:
+    /** 
+     * Constructor
+     * 
+     */
     Manager();
-    Manager(const Manager& o) :
-      fAcceptancePath(o.fAcceptancePath),
-      fSecMapPath(o.fSecMapPath),
-      fAcceptance(o.fAcceptance),
-      fSecmap(o.fSecmap),
-      fAcceptanceName(o.fAcceptanceName),
-      fSecMapName(o.fSecMapName) {}
-    
-  /** 
-   * Assignment operator 
-   * 
-   * @param o Object to assign from 
-   * 
-   * @return Reference to this object 
-   */
-  Manager& operator=(const Manager& o)
-  {
-    fAcceptancePath = o.fAcceptancePath;
-    fSecMapPath     = o.fSecMapPath;
-    fAcceptance     = o.fAcceptance;
-    fSecmap         = o.fSecmap;
-    fAcceptanceName = o.fAcceptanceName;
-    fSecMapName     = o.fSecMapName;
-    return *this;
-  }
-
-    void          Init(UShort_t  sys, 
-                      UShort_t  sNN,
-                      Short_t   field);
-    const char*   GetAcceptancePath() {return fAcceptancePath.Data(); }
-    const char*   GetSecMapPath() {return fSecMapPath.Data(); }
-    void          SetAcceptancePath(const char* path) {fAcceptancePath=path; }
-    void          SetSecMapPath(const char* path) {fSecMapPath=path; }
-    char*         GetFullFileName(UShort_t  what ,
-                                 UShort_t  sys, 
-                                 UShort_t  sNN,
-                                 Short_t   field) {return Form("%s/%s",
-what == 0 ? GetSecMapPath() : GetAcceptancePath(), GetFileName(what, sys, sNN, field));}
-    const char*   GetAcceptanceName() {return fAcceptanceName.Data(); }
-    const char*   GetSecMapName() {return fSecMapName.Data(); }
+    /** 
+     * Copy constructor 
+     * 
+     * @param o 
+     */
+    Manager(const Manager& o);
+    /** 
+     * Destructor
+     */
+    virtual ~Manager() {}
+    /** 
+     * Assignment operator 
+     * 
+     * @param o Object to assign from 
+     * 
+     * @return Reference to this object 
+     */
+    Manager& operator=(const Manager& o);
     
-    TH2D* GetSecMapCorrection(UShort_t vtxbin) {return fSecmap->GetCorrection(vtxbin);}
-    TH1D* GetAcceptanceCorrection(UShort_t vtxbin) {return fAcceptance->GetCorrection(vtxbin);}
+    /** 
+     * Initialize 
+     * 
+     * @param sys    Collision system (1: pp, 2: PbPb)
+     * @param sNN    Center of mass energy per nucleon pair [GeV]
+     * @param field  Magnetic field [kG]
+     */
+    void Init(UShort_t sys, UShort_t sNN, Short_t field);
+    /** 
+     * Get the acceptance path
+     * 
+     * @return 
+     */
+    const char* GetAcceptancePath() const {return fAcceptancePath.Data(); }
+    /** 
+     * Get the secondary path 
+     * 
+     * @return 
+     */
+    const char* GetSecMapPath() const {return fSecMapPath.Data(); }
+    /** 
+     * Set the path to the acceptance maps 
+     * 
+     * @param path PAth to object file 
+     */
+    void SetAcceptancePath(const char* path) {fAcceptancePath=path; }
+    /** 
+     * Set the path to the secondary maps 
+     * 
+     * @param path Path to object files 
+     */
+    void  SetSecMapPath(const char* path) {fSecMapPath=path; }
+    /** 
+     * Get full path name to object file 
+     * 
+     * @param what   What to get 
+     * @param sys    Collision system
+     * @param sNN    Center of mass energy 
+     * @param field  Magnetic field 
+     * 
+     * @return 
+     */
+    const char* GetFullFileName(UShort_t what, UShort_t sys, UShort_t sNN, 
+                               Short_t  field) const;
+    /** 
+     * Get the acceptance object name 
+     * 
+     * @return 
+     */
+    const char* GetAcceptanceName() const {return fAcceptanceName.Data(); }
+    /** 
+     * Get the secondary object name 
+     * 
+     * @return 
+     */
+    const char* GetSecMapName() const {return fSecMapName.Data(); }
     
+    /** 
+     * Get the secondary map
+     * 
+     * @param vtxbin 
+     * 
+     * @return 
+     */
+    TH2D* GetSecMapCorrection(UShort_t vtxbin) const;
+    /** 
+     * Get the acceptance correction 
+     * 
+     * @param vtxbin 
+     * 
+     * @return 
+     */
+    TH1D* GetAcceptanceCorrection(UShort_t vtxbin) const;
   private:
+    /** 
+     * Get the full path name 
+     * 
+     * @param what   What to get
+     * @param sys    Collision system
+     * @param sNN    Center of mass energy 
+     * @param field  Magnetic field 
+     * 
+     * @return 
+     */
+    const char* GetFileName(UShort_t what, UShort_t sys, UShort_t sNN,
+                           Short_t field) const;
     
     
-    const char*   GetFileName(UShort_t  what ,
-                             UShort_t  sys, 
-                             UShort_t  sNN,
-                             Short_t   field);
-    
-    
-    TString fAcceptancePath;
-    TString fSecMapPath;
-    AliCentralCorrAcceptance* fAcceptance;
-    AliCentralCorrSecondaryMap*     fSecmap;
-    TString fAcceptanceName;
-    TString fSecMapName;
+    TString                     fAcceptancePath; // Path to acceptance 
+    TString                     fSecMapPath;     // Path to secondary map
+    AliCentralCorrAcceptance*   fAcceptance;     // Acceptance 
+    AliCentralCorrSecondaryMap* fSecmap;         // Secindary map
+    TString                     fAcceptanceName; // Acceptance name
+    TString                     fSecMapName;     // Secindary name
 
+    ClassDef(Manager,1); // Manager of data 
   };
 
+  /** 
+   * Get a reference to the manager 
+   * 
+   * @return Reference to corrections manager 
+   */
+  Manager& GetManager() { return fManager; }
+  /** 
+   * Get a reference to the manager 
+   * 
+   * @return Reference to corrections manager 
+   */
+  const Manager& GetManager() const { return fManager; }
+
+
 protected: 
-private:
   
   TH2D*                  fData;          //sum histogram if needed
   TList*                 fList;          //Output List for diagnostics
index 025de16af0ac744a556397251815cb85ff886104..7a39c5f9321cdb914cd15a4569ccd4f5f3acf35e 100644 (file)
@@ -11,7 +11,7 @@
 #include <AliAODInputHandler.h>
 #include "AliForwardUtil.h"
 #include "AliAODForwardMult.h"
-#include <AliAODCentralMult.h>
+#include "AliAODCentralMult.h"
 
 //____________________________________________________________________
 AliCentraldNdetaTask::AliCentraldNdetaTask()
index 137d1546cd9f175bae02b57f382993001123b9a3..3bbc196563654ca073c638087ea19a6dc80c87e6 100644 (file)
@@ -64,6 +64,7 @@
 #pragma link C++ class AliForwarddNdetaTask+;
 
 #pragma link C++ class AliCentralMultiplicityTask+;
+#pragma link C++ class AliCentralMultiplicityTask::Manager+;
 #pragma link C++ class AliAODCentralMult+;
 #pragma link C++ class AliCentralCorrSecondaryMap+;
 #pragma link C++ class AliCentralCorrAcceptance+;