ROOT logo
#include "AliFMDMCTrackInspectorTask.h"
#include "AliForwardCorrectionManager.h"
#include "AliAODForwardMult.h"
#include <TROOT.h>
#include <TTree.h>

//____________________________________________________________________
AliFMDMCTrackInspectorTask::AliFMDMCTrackInspectorTask(const char* name, 
						       Bool_t      useTree)
  : AliBaseESDTask(name, "", &(AliForwardCorrectionManager::Instance())),
    fEventInspector("event"), 
    fTrackInspector("fitter")
{
  fCloneList = true;
  fTrackInspector.GetTracker().SetUseTree(useTree);
  if (useTree) DefineOutput(3, TTree::Class());
}

//____________________________________________________________________
TAxis*
AliFMDMCTrackInspectorTask::DefaultEtaAxis() const
{
  static TAxis* a = new TAxis(0, 0, 0);
  return a;
}
//____________________________________________________________________
TAxis*
AliFMDMCTrackInspectorTask::DefaultVertexAxis() const
{
  static TAxis* a = new TAxis(10, -10, 10);
  return a;
}

//____________________________________________________________________
Bool_t 
AliFMDMCTrackInspectorTask::Setup()
{
  DGUARD(fDebug,1,"Setting up the MC hit energy loss task");
  fTrackInspector.Init(); 
  return true; 
}

//____________________________________________________________________
Bool_t 
AliFMDMCTrackInspectorTask::Book()
{
  DGUARD(fDebug,1,"Booking histograms for the MC hit energy loss task");
  fNeededCorrections = 0;
  fExtraCorrections  = 0;

  fTrackInspector.CreateOutputObjects(fList);  
  return true;
}

//____________________________________________________________________
Bool_t 
AliFMDMCTrackInspectorTask::PreData(const TAxis& /*ipz*/, const TAxis& eta)
{
  DGUARD(fDebug,2,"Final setup of the MC hit energy loss task");
  fTrackInspector.SetupForData(eta);
  if (fTrackInspector.GetTracker().GetTree()) 
    PostData(3, fTrackInspector.GetTracker().GetTree());
  return true;
}
//____________________________________________________________________
Bool_t 
AliFMDMCTrackInspectorTask::Event(AliESDEvent& esd)
{
  // --- Read in the data --------------------------------------------
  LoadBranches();

  Bool_t   lowFlux   = kFALSE;
  UInt_t   triggers  = 0;
  UShort_t ivz       = 0;
  TVector3 ip;
  Double_t cent      = 0;
  UShort_t nClusters = 0;
  UInt_t   found     = fEventInspector.Process(&esd, triggers, lowFlux, 
					       ivz, ip, cent, nClusters);
  if (found & AliFMDEventInspector::kNoEvent)    return false;
  if (found & AliFMDEventInspector::kNoTriggers) return false;
  if (found & AliFMDEventInspector::kNoSPD)      return false;
  if (found & AliFMDEventInspector::kNoFMD)      return false;
  if (found & AliFMDEventInspector::kNoVertex)   return false;
  if (found & AliFMDEventInspector::kBadVertex)  return false;

  // do not process pile-up, A, C, and E events 
  if (triggers & AliAODForwardMult::kPileUp)     return false;
  if (triggers & AliAODForwardMult::kA)          return false;
  if (triggers & AliAODForwardMult::kC)          return false;
  if (triggers & AliAODForwardMult::kE)          return false;
  
  // We want only the events found by off-line 
  if (!(triggers & AliAODForwardMult::kOffline)) return false;

  // Perhaps we should also insist on MB only 
  // if (fOnlyMB && (!(triggers & AliAODForwardMult::kInel))) return false;

  AliMCEvent* mc = MCEvent();
  if (!mc) return false;
  
  Bool_t ret = fTrackInspector.Event(esd, *mc, cent);

  if (fTrackInspector.GetTracker().GetTree()) 
    PostData(3, fTrackInspector.GetTracker().GetTree());

  return ret;
}
#define PFB(N,FLAG)				\
  do {									\
    AliForwardUtil::PrintName(N);					\
    std::cout << std::boolalpha << (FLAG) << std::noboolalpha << std::endl; \
  } while(false)

//____________________________________________________________________
void   
AliFMDMCTrackInspectorTask::Print(Option_t* option) const
{
  AliBaseESDTask::Print(option);
  gROOT->IncreaseDirLevel();
  fTrackInspector.Print(option);
  gROOT->DecreaseDirLevel();
}

//
// EOF
// 


 AliFMDMCTrackInspectorTask.cxx:1
 AliFMDMCTrackInspectorTask.cxx:2
 AliFMDMCTrackInspectorTask.cxx:3
 AliFMDMCTrackInspectorTask.cxx:4
 AliFMDMCTrackInspectorTask.cxx:5
 AliFMDMCTrackInspectorTask.cxx:6
 AliFMDMCTrackInspectorTask.cxx:7
 AliFMDMCTrackInspectorTask.cxx:8
 AliFMDMCTrackInspectorTask.cxx:9
 AliFMDMCTrackInspectorTask.cxx:10
 AliFMDMCTrackInspectorTask.cxx:11
 AliFMDMCTrackInspectorTask.cxx:12
 AliFMDMCTrackInspectorTask.cxx:13
 AliFMDMCTrackInspectorTask.cxx:14
 AliFMDMCTrackInspectorTask.cxx:15
 AliFMDMCTrackInspectorTask.cxx:16
 AliFMDMCTrackInspectorTask.cxx:17
 AliFMDMCTrackInspectorTask.cxx:18
 AliFMDMCTrackInspectorTask.cxx:19
 AliFMDMCTrackInspectorTask.cxx:20
 AliFMDMCTrackInspectorTask.cxx:21
 AliFMDMCTrackInspectorTask.cxx:22
 AliFMDMCTrackInspectorTask.cxx:23
 AliFMDMCTrackInspectorTask.cxx:24
 AliFMDMCTrackInspectorTask.cxx:25
 AliFMDMCTrackInspectorTask.cxx:26
 AliFMDMCTrackInspectorTask.cxx:27
 AliFMDMCTrackInspectorTask.cxx:28
 AliFMDMCTrackInspectorTask.cxx:29
 AliFMDMCTrackInspectorTask.cxx:30
 AliFMDMCTrackInspectorTask.cxx:31
 AliFMDMCTrackInspectorTask.cxx:32
 AliFMDMCTrackInspectorTask.cxx:33
 AliFMDMCTrackInspectorTask.cxx:34
 AliFMDMCTrackInspectorTask.cxx:35
 AliFMDMCTrackInspectorTask.cxx:36
 AliFMDMCTrackInspectorTask.cxx:37
 AliFMDMCTrackInspectorTask.cxx:38
 AliFMDMCTrackInspectorTask.cxx:39
 AliFMDMCTrackInspectorTask.cxx:40
 AliFMDMCTrackInspectorTask.cxx:41
 AliFMDMCTrackInspectorTask.cxx:42
 AliFMDMCTrackInspectorTask.cxx:43
 AliFMDMCTrackInspectorTask.cxx:44
 AliFMDMCTrackInspectorTask.cxx:45
 AliFMDMCTrackInspectorTask.cxx:46
 AliFMDMCTrackInspectorTask.cxx:47
 AliFMDMCTrackInspectorTask.cxx:48
 AliFMDMCTrackInspectorTask.cxx:49
 AliFMDMCTrackInspectorTask.cxx:50
 AliFMDMCTrackInspectorTask.cxx:51
 AliFMDMCTrackInspectorTask.cxx:52
 AliFMDMCTrackInspectorTask.cxx:53
 AliFMDMCTrackInspectorTask.cxx:54
 AliFMDMCTrackInspectorTask.cxx:55
 AliFMDMCTrackInspectorTask.cxx:56
 AliFMDMCTrackInspectorTask.cxx:57
 AliFMDMCTrackInspectorTask.cxx:58
 AliFMDMCTrackInspectorTask.cxx:59
 AliFMDMCTrackInspectorTask.cxx:60
 AliFMDMCTrackInspectorTask.cxx:61
 AliFMDMCTrackInspectorTask.cxx:62
 AliFMDMCTrackInspectorTask.cxx:63
 AliFMDMCTrackInspectorTask.cxx:64
 AliFMDMCTrackInspectorTask.cxx:65
 AliFMDMCTrackInspectorTask.cxx:66
 AliFMDMCTrackInspectorTask.cxx:67
 AliFMDMCTrackInspectorTask.cxx:68
 AliFMDMCTrackInspectorTask.cxx:69
 AliFMDMCTrackInspectorTask.cxx:70
 AliFMDMCTrackInspectorTask.cxx:71
 AliFMDMCTrackInspectorTask.cxx:72
 AliFMDMCTrackInspectorTask.cxx:73
 AliFMDMCTrackInspectorTask.cxx:74
 AliFMDMCTrackInspectorTask.cxx:75
 AliFMDMCTrackInspectorTask.cxx:76
 AliFMDMCTrackInspectorTask.cxx:77
 AliFMDMCTrackInspectorTask.cxx:78
 AliFMDMCTrackInspectorTask.cxx:79
 AliFMDMCTrackInspectorTask.cxx:80
 AliFMDMCTrackInspectorTask.cxx:81
 AliFMDMCTrackInspectorTask.cxx:82
 AliFMDMCTrackInspectorTask.cxx:83
 AliFMDMCTrackInspectorTask.cxx:84
 AliFMDMCTrackInspectorTask.cxx:85
 AliFMDMCTrackInspectorTask.cxx:86
 AliFMDMCTrackInspectorTask.cxx:87
 AliFMDMCTrackInspectorTask.cxx:88
 AliFMDMCTrackInspectorTask.cxx:89
 AliFMDMCTrackInspectorTask.cxx:90
 AliFMDMCTrackInspectorTask.cxx:91
 AliFMDMCTrackInspectorTask.cxx:92
 AliFMDMCTrackInspectorTask.cxx:93
 AliFMDMCTrackInspectorTask.cxx:94
 AliFMDMCTrackInspectorTask.cxx:95
 AliFMDMCTrackInspectorTask.cxx:96
 AliFMDMCTrackInspectorTask.cxx:97
 AliFMDMCTrackInspectorTask.cxx:98
 AliFMDMCTrackInspectorTask.cxx:99
 AliFMDMCTrackInspectorTask.cxx:100
 AliFMDMCTrackInspectorTask.cxx:101
 AliFMDMCTrackInspectorTask.cxx:102
 AliFMDMCTrackInspectorTask.cxx:103
 AliFMDMCTrackInspectorTask.cxx:104
 AliFMDMCTrackInspectorTask.cxx:105
 AliFMDMCTrackInspectorTask.cxx:106
 AliFMDMCTrackInspectorTask.cxx:107
 AliFMDMCTrackInspectorTask.cxx:108
 AliFMDMCTrackInspectorTask.cxx:109
 AliFMDMCTrackInspectorTask.cxx:110
 AliFMDMCTrackInspectorTask.cxx:111
 AliFMDMCTrackInspectorTask.cxx:112
 AliFMDMCTrackInspectorTask.cxx:113
 AliFMDMCTrackInspectorTask.cxx:114
 AliFMDMCTrackInspectorTask.cxx:115
 AliFMDMCTrackInspectorTask.cxx:116
 AliFMDMCTrackInspectorTask.cxx:117
 AliFMDMCTrackInspectorTask.cxx:118
 AliFMDMCTrackInspectorTask.cxx:119
 AliFMDMCTrackInspectorTask.cxx:120
 AliFMDMCTrackInspectorTask.cxx:121
 AliFMDMCTrackInspectorTask.cxx:122
 AliFMDMCTrackInspectorTask.cxx:123
 AliFMDMCTrackInspectorTask.cxx:124
 AliFMDMCTrackInspectorTask.cxx:125
 AliFMDMCTrackInspectorTask.cxx:126
 AliFMDMCTrackInspectorTask.cxx:127
 AliFMDMCTrackInspectorTask.cxx:128
 AliFMDMCTrackInspectorTask.cxx:129