AliPhysics  vAN-20151012 (2287573)
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros
AddTaskEMCALPi0Calibration.C
Go to the documentation of this file.
1 
20 AliAnalysisTaskEMCALPi0CalibSelection * AddTaskEMCALPi0Calibration(TString calibPath = "", // "alienpath/RecalibrationFactors.root"
21  TString trigger ="CEMC7",
22  Bool_t recalE = kFALSE,
23  Bool_t recalT = kFALSE,
24  Bool_t rmBad = kFALSE,
25  Bool_t nonlin = kTRUE,
26  Bool_t simu = kFALSE,
27  TString outputFile = "") // AnalysisResults.root
28 
29 {
30  // Get the pointer to the existing analysis manager via the static access method.
31  //==============================================================================
32  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
33  if (!mgr)
34  {
35  ::Error("AddTaskEMCALTriggerQA", "No analysis manager to connect to.");
36  return NULL;
37  }
38 
39  // Check the analysis type using the event handlers connected to the analysis manager.
40  //==============================================================================
41  if (!mgr->GetInputEventHandler())
42  {
43  ::Error("AddTaskEMCALPi0Calibration", "This task requires an input event handler");
44  return NULL;
45  }
46 
47 
48  // Create containers for input/output
49  AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer();
50 
52  //pi0calib->SetDebugLevel(10);
53  //pi0calib->UseFilteredEventAsInput();
54  pi0calib->SetClusterMinEnergy(0.3);
55  pi0calib->SetClusterMaxEnergy(10.);
56  pi0calib->SetClusterLambda0Cuts(0.1,0.5);
57 
58  pi0calib->SetAsymmetryCut(1.);
59  pi0calib->SetClusterMinNCells(1);
60  pi0calib->SetNCellsGroup(0);
61  pi0calib->SwitchOnSameSM();
62 
63  // Timing cuts
64  pi0calib->SetPairDTimeCut(100); // 20 ns in Run1
65  pi0calib->SetClusterMinTime(300); // 560 ns in Run1
66  pi0calib->SetClusterMaxTime(800); // 610 ns in Run1
67 
68  pi0calib->SetTriggerName(trigger);
69 
70  // Cluster recalculation, Reco Utils configuration
71 
72 
73  AliEMCALRecoUtils * reco = pi0calib->GetEMCALRecoUtils();
74 
75  gROOT->LoadMacro("$ALICE_PHYSICS/PWGPP/EMCAL/macros/ConfigureEMCALRecoUtils.C");
76 
78  simu,
79  kTRUE, // exotic
80  nonlin,
81  recalE,
82  rmBad,
83  recalT);
84 
85  reco->SetNumberOfCellsFromEMCALBorder(0); // Do not remove clusters in borders!
86 
87  // recalibrate energy and do corrections because of Temperature corrections
88  pi0calib->SwitchOnClusterCorrection();
89  reco->SwitchOnRecalibration();
90  reco->SwitchOnRunDepCorrection();
91 
92  //reco->Print("");
93 
94  //---------------------
95  // Geometry alignment
96  //---------------------
97 
98  pi0calib->SetGeometryName("EMCAL_COMPLETE12SMV1_DCAL_8SM");
99 
101 
102 
103  //---------------------
104  // Pass recalibration factors
105  // Do it here or inside the task
106  // If previous pass not available (first) avoid recalculate clusters
107  //---------------------
108 
109  pi0calib->SetCalibrationFilePath(calibPath);
110 
111  if(recalE && calibPath == "")
112  {
113  printf("Get the calibration file from AddTask!!!\n");
114 
115  TFile * calibFile = TFile::Open("RecalibrationFactors.root");
116  if(!calibFile)
117  {
118  printf("File %d not found!\n",calibPath.Data());
119  return;
120  }
121 
122  for(Int_t ism = 0; ism < 20; ism++)
123  {
124  TH2F * h = (TH2F*)calibFile->Get(Form("EMCALRecalFactors_SM%d",ism));
125 
126  if(h) reco->SetEMCALChannelRecalibrationFactors(ism,h);
127  else printf("Null histogram with calibration factors for SM%d, 1 will be used in the full SM\n",ism);
128  }
129  }
130  else
131  {
132  // First iteration, just fill histograms, switch off recalculation
133  reco->SwitchOffRecalibration();
134  reco->SwitchOffRunDepCorrection(); // Careful!!!, activate when T corrections are available.
136  pi0calib->SwitchOffRecalculatePosition();
137  printf("Pi0 Calibration: Do not recalculate the clusters! First iteration. \n");
138  }
139 
140  pi0calib->PrintInfo();
141 
142  mgr->AddTask(pi0calib);
143 
144  if(outputFile.Length()==0) outputFile = AliAnalysisManager::GetCommonFileName();
145 
146  AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer();
147  AliAnalysisDataContainer *coutput = mgr->CreateContainer(Form("Pi0Calibration_Trig%s",trigger.Data()),
148  TList::Class(), AliAnalysisManager::kOutputContainer,
149  outputFile.Data());
150 
151 // AliAnalysisDataContainer *cout_cuts = mgr->CreateContainer(Form("ParamsPi0Calibration_Trig%s",trigger.Data()),
152 // TList::Class(), AliAnalysisManager::kOutputContainer,
153 // "AnalysisParameters.root");
154 
155  mgr->AddTask(pi0calib);
156 
157  mgr->ConnectInput (pi0calib, 0, cinput1);
158  mgr->ConnectOutput (pi0calib, 1, coutput);
159 // mgr->ConnectOutput (pi0calib, 2, cout_cuts);
160 
161  return pi0calib;
162 }
This task provides the input for the EMCal energy calibration with pi0 invariant mass analysis per ch...
void ConfigureEMCALRecoUtils(AliEMCALRecoUtils *reco, Bool_t bMC=kFALSE, Bool_t bExotic=kTRUE, Bool_t bNonLin=kFALSE, Bool_t bRecalE=kTRUE, Bool_t bBad=kTRUE, Bool_t bRecalT=kTRUE)
AliAnalysisTaskEMCALPi0CalibSelection * AddTaskEMCALPi0Calibration(TString calibPath="", TString trigger="CEMC7", Bool_t recalE=kFALSE, Bool_t recalT=kFALSE, Bool_t rmBad=kFALSE, Bool_t nonlin=kTRUE, Bool_t simu=kFALSE, TString outputFile="")