]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWG2/FORWARD/analysis2/AliForwardMultiplicityBase.cxx
Preliminary work to get centrality in
[u/mrichter/AliRoot.git] / PWG2 / FORWARD / analysis2 / AliForwardMultiplicityBase.cxx
index 32d4162e02d207369e4e3ca7678f9496038540c1..12ec76b7aec6efaa4d32d383f7da99797bd4fc4c 100644 (file)
 #include "AliFMDEnergyFitter.h"
 #include "AliFMDSharingFilter.h"
 #include "AliFMDDensityCalculator.h"
-#include "AliFMDCorrections.h"
+#include "AliFMDCorrector.h"
 #include "AliFMDHistCollector.h"
+#include "AliESDEvent.h"
 #include <TROOT.h>
 #include <iostream>
 #include <iomanip>
 
 //====================================================================
+AliForwardMultiplicityBase::AliForwardMultiplicityBase(const char* name) 
+  : AliAnalysisTaskSE(name), 
+    fEnableLowFlux(true), 
+    fFirstEvent(true),
+    fCorrManager(0)
+{
+  // Set our persistent pointer 
+  fCorrManager = &AliForwardCorrectionManager::Instance();
+}
+
+//____________________________________________________________________
 Bool_t 
 AliForwardMultiplicityBase::CheckCorrections(UInt_t what) const
 {
@@ -58,7 +70,7 @@ AliForwardMultiplicityBase::CheckCorrections(UInt_t what) const
     return false;
   }
   // Check that we have the secondary maps, needed by 
-  //   AliFMDCorrections 
+  //   AliFMDCorrector 
   //   AliFMDHistCollector
   if (what & AliForwardCorrectionManager::kSecondaryMap && 
       !fcm.GetSecondaryMap()) {
@@ -66,22 +78,100 @@ AliForwardMultiplicityBase::CheckCorrections(UInt_t what) const
     return false;
   }
   // Check that we have the vertex bias correction, needed by 
-  //   AliFMDCorrections 
+  //   AliFMDCorrector 
   if (what & AliForwardCorrectionManager::kVertexBias && 
       !fcm.GetVertexBias()) { 
     AliFatal("No event vertex bias corrections");
     return false;
   }
   // Check that we have the merging efficiencies, optionally used by 
-  //   AliFMDCorrections 
+  //   AliFMDCorrector 
   if (what & AliForwardCorrectionManager::kMergingEfficiency && 
       !fcm.GetMergingEfficiency()) {
     AliFatal("No merging efficiencies");
     return false;
   }
+  // Check that we have the acceptance correction, needed by 
+  //   AliFMDCorrector 
+  if (what & AliForwardCorrectionManager::kAcceptance && 
+      !fcm.GetAcceptance()) { 
+    AliFatal("No acceptance corrections");
+    return false;
+  }
   return true;
 }
+//____________________________________________________________________
+Bool_t
+AliForwardMultiplicityBase::ReadCorrections(const TAxis*& pe, 
+                                           const TAxis*& pv, 
+                                           Bool_t        mc)
+{
+  UInt_t what = AliForwardCorrectionManager::kAll;
+  if (!fEnableLowFlux)
+    what ^= AliForwardCorrectionManager::kDoubleHit;
+  if (!GetCorrections().IsUseVertexBias())
+    what ^= AliForwardCorrectionManager::kVertexBias;
+  if (!GetCorrections().IsUseAcceptance())
+    what ^= AliForwardCorrectionManager::kAcceptance;
+  if (!GetCorrections().IsUseMergingEfficiency())
+    what ^= AliForwardCorrectionManager::kMergingEfficiency;
+
+  AliForwardCorrectionManager& fcm = AliForwardCorrectionManager::Instance();
+  if (!fcm.Init(GetEventInspector().GetCollisionSystem(),
+               GetEventInspector().GetEnergy(),
+               GetEventInspector().GetField(),
+               mc,
+               what)) return false;
+  if (!CheckCorrections(what)) return false;
 
+  // Sett our persistency pointer 
+  // fCorrManager = &fcm;
+
+  // Get the eta axis from the secondary maps - if read in
+  if (!pe) {
+    pe = fcm.GetEtaAxis();
+    if (!pe) AliFatal("No eta axis defined");
+  }
+  // Get the vertex axis from the secondary maps - if read in
+  if (!pv) {
+    pv = fcm.GetVertexAxis();
+    if (!pv) AliFatal("No vertex axis defined");
+  }
+
+  return true;
+}
+//____________________________________________________________________
+AliESDEvent*
+AliForwardMultiplicityBase::GetESDEvent()
+{
+  AliESDEvent* esd = dynamic_cast<AliESDEvent*>(InputEvent());
+  if (!esd) {
+    AliWarning("No ESD event found for input event");
+    return 0;
+  }
+
+  // On the first event, initialize the parameters
+  if (fFirstEvent && esd->GetESDRun()) {
+    GetEventInspector().ReadRunDetails(esd);
+
+    AliInfo(Form("Initializing with parameters from the ESD:\n"
+                 "         AliESDEvent::GetBeamEnergy()   ->%f\n"
+                 "         AliESDEvent::GetBeamType()     ->%s\n"
+                 "         AliESDEvent::GetCurrentL3()    ->%f\n"
+                 "         AliESDEvent::GetMagneticField()->%f\n"
+                 "         AliESDEvent::GetRunNumber()    ->%d\n",
+                 esd->GetBeamEnergy(),
+                 esd->GetBeamType(),
+                 esd->GetCurrentL3(),
+                 esd->GetMagneticField(),
+                 esd->GetRunNumber()));
+
+    fFirstEvent = false;
+
+    InitializeSubs();
+  }
+  return esd;
+}
 //____________________________________________________________________
 void
 AliForwardMultiplicityBase::MarkEventForStore() const
@@ -106,10 +196,18 @@ AliForwardMultiplicityBase::Print(Option_t* option) const
   // Parameters:
   //    option Not used
   //
+  
   std::cout << "AliForwardMultiplicityBase: " << GetName() << "\n" 
-           << "  Enable low flux code:   " << (fEnableLowFlux ? "yes" : "no")
-           << std::endl;
+           << "  Enable low flux code:   " << (fEnableLowFlux ? "yes" : "no") 
+           << "\n"
+           << "  Off-line trigger mask:  0x" 
+           << std::hex     << std::setfill('0') 
+           << std::setw (8) << fOfflineTriggerMask 
+           << std::dec     << std::setfill (' ') << std::endl;
   gROOT->IncreaseDirLevel();
+  if (fCorrManager) fCorrManager->Print();
+  else  
+    std::cout << "  Correction manager not set yet" << std::endl;
   GetEventInspector()   .Print(option);
   GetEnergyFitter()     .Print(option);    
   GetSharingFilter()    .Print(option);