AliPhysics  fde8a9f (fde8a9f)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AddTaskEMCALClusterize.C
Go to the documentation of this file.
1 
37  TString & arrayName,
38  const Bool_t bFillAOD = kFALSE,
39  const Int_t bMC = kFALSE,
40  const Bool_t exotic = kTRUE,
41  const TString name = "V1Unfold", // V1, V2, NxN, V1Unfold
42  const TString trigger = "",
43  const Bool_t tm = kTRUE,
44  const Int_t minEcell = 50,
45  const Int_t minEseed = 100,
46  const Int_t maxDeltaT = 250,
47  const Int_t timeWindow = 1000,
48  const Int_t minEUnf = 15,
49  const Int_t minFrac = 1,
50  const Bool_t bRecalE = kTRUE,
51  const Bool_t bBad = kTRUE,
52  const Bool_t bRecalT = kTRUE,
53  const Bool_t bNonLine = kFALSE,
54  const Int_t minCen = -1,
55  const Int_t maxCen = -1,
56  const Float_t clusterEnergyCutEvent = -1,
57  const Int_t nRowDiff = 1,
58  const Int_t nColDiff = 1,
59  const Bool_t skipOrReject = kFALSE
60  )
61 {
62  // Get the pointer to the existing analysis manager via the static access method.
63  //==============================================================================
64  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
65  if (!mgr)
66  {
67  ::Error("AddTaskEMCALClusterize", "No analysis manager to connect to.");
68  return NULL;
69  }
70 
71  // Check the analysis type using the event handlers connected to the analysis manager.
72  //==============================================================================
73  if (!mgr->GetInputEventHandler())
74  {
75  ::Error("AddTaskEMCALClusterize", "This clusterize requires an input event handler");
76  return NULL;
77  }
78 
79  printf("Passed Settings : mc %d, exo %d, name %s, trigger %s, tm %d\n",bMC,exotic,name.Data(),trigger.Data(),tm);
80  printf(" Ecell %d, Eseed %d, dT %d, wT %d, minUnf %d, minFrac %d \n",minEcell, minEseed,maxDeltaT,timeWindow,minEUnf,minFrac);
81  printf(" recalE %d, bad %d, recalT %d, nonlin %d, minCen %d, maxCen %d, rowDiff %d, colDiff %d \n",bRecalE,bBad,bRecalT,bNonLine,minCen,maxCen,nRowDiff,nColDiff);
82 
83  // Create name of task and AOD branch depending on different settings
84 
85  if(name.Contains("NxN")) arrayName = Form("%dx%d_Ecell%d_Eseed%d_DT%d_WT%d",2*nRowDiff+1,2*nColDiff+1,minEcell,minEseed,maxDeltaT,timeWindow);
86  else arrayName = Form( "%s_Ecell%d_Eseed%d_DT%d_WT%d", name.Data(),minEcell,minEseed,maxDeltaT,timeWindow);
87 
88  if(minCen != -1 && maxCen != -1)
89  arrayName+=Form("_Cen%d_%d",minCen,maxCen);
90 
91  printf("Created Branch Name: %s \n",arrayName.Data());
92 
93 
94  //-------------------------------------------------------
95  // Init the task and do settings
96  //-------------------------------------------------------
97 
98  AliAnalysisTaskEMCALClusterize* clusterize = new AliAnalysisTaskEMCALClusterize(Form("EMCALClusterize%s",arrayName.Data()));
99 
100  clusterize->SetAODBranchName(arrayName);
101 
102  //clusterize->SetOCDBPath("local://$ALICE_ROOT/OCDB");
103 
104  // Centrality range
105  clusterize->SetCentralityBin(minCen, maxCen);
106 
107  // Some general settings to create AOD file in case we want to keep it
108  clusterize->SwitchOffFillAODCaloCells();
109  clusterize->SwitchOffFillAODHeader();
110  clusterize->FillAODFile(bFillAOD); // fill aod.root with clusters?, not really needed for analysis.
111 
112  // Do track matching after clusterization
113  if(tm) clusterize->SwitchOnTrackMatching();
114  else clusterize->SwitchOffTrackMatching();
115 
116  //-------------------------------------------------------
117  // Set clusterization parameters via rec param
118  //-------------------------------------------------------
119 
120  AliEMCALRecParam * params = clusterize->GetRecParam();
121 
122  //
123  // Position and SS weight parameter
124  //
125  params->SetW0(4.5);
126 
127  //
128  // Time cuts
129  // Be careful using time cuts, best thing is to leave them open.
130  //
131  if(maxDeltaT > 1) params->SetTimeCut(maxDeltaT*1.e-9);
132  else { params->SetTimeCut(250*1.e-9); printf("default maxDeltaT = 250 ns\n"); }// Same as in reco
133 
134  if(timeWindow > 1)
135  {
136  params->SetTimeMin(-1*timeWindow*1.e-9);
137  params->SetTimeMax(timeWindow*1.e-9);
138  }
139  else
140  {
141  if(!bMC)
142  {
143  if(bRecalT)
144  {
145  params->SetTimeMin(-250*1.e-9);
146  params->SetTimeMax( 250*1.e-9);
147  printf("default time window for calibrated time -250 ns < T < 250 ns\n");
148  }
149  else
150  {
151  // same as in reco, USE IF NO TIME RECALIBRATION
152  params->SetTimeMin(425*1.e-9);
153  params->SetTimeMax(825*1.e-9);
154  printf("default time window 425 ns < T < 825 ns\n");
155  }
156  }
157  else
158  {
159  params->SetTimeMin(-100000000);
160  params->SetTimeMax( 100000000);
161  printf("open time cut\n");
162  }
163  }
164 
165  //
166  // Energy cuts
167  //
168  params->SetClusteringThreshold(minEseed/1.e3);
169  params->SetMinECut (minEcell/1.e3);
170 
171  //
172  // Clusterizer type
173  //
174  if(name.Contains("V2")) params->SetClusterizerFlag(AliEMCALRecParam::kClusterizerv2);
175  if(name.Contains("V1")) params->SetClusterizerFlag(AliEMCALRecParam::kClusterizerv1);
176  if(name.Contains("NxN"))
177  {
178  params->SetClusterizerFlag(AliEMCALRecParam::kClusterizerNxN);
179  printf("Set NxN cluster size to %dx%d (row diff %d, col diff %d)\n",2*nRowDiff+1,2*nColDiff+1,nRowDiff,nColDiff);
180  params->SetNxM(nRowDiff, nColDiff);
181  }
182 
183  //-------------------------------------------------------
184  // Unfolding, 2 options :
185  //-------------------------------------------------------
186 
187  // 1) Just unfold existing clusters
188  if(name.Contains("JustUnfold"))
189  clusterize->JustUnfold(kTRUE); // if TRUE, do just unfolding, do not recluster cells
190  else
191  clusterize->JustUnfold(kFALSE);
192 
193  // 2) Unfold clusters created in the clusterize (revise settings)
194  if (name.Contains("Unfold"))
195  {
196  clusterize->SwitchOnCellEnergySelection();
197  clusterize->SetCellCuts(minEUnf/1000.,minFrac/10000.);
198  clusterize->SetRejectBelowThreshold(skipOrReject);
199  printf("AliAnalysisTaskEMCALClusterize - Cuts: min E %f, frac %f\n",minEUnf/1000.,minFrac/10000.);
200  //clusterize->SwitchOffCellEnergySelection();
201 
202  if(!name.Contains("Just"))
203  params->SetUnfold(kTRUE);
204  else
205  params->SetUnfold(kFALSE);
206 
207  } // unfold
208 
209  //-------------------------------------------------------
210  // Configure AliEMCALRecoUtils
211  //-------------------------------------------------------
212 
213  AliEMCALRecoUtils * reco = clusterize->GetRecoUtils();
214 
215  gROOT->LoadMacro("$ALICE_PHYSICS/PWGPP/EMCAL/macros/ConfigureEMCALRecoUtils.C");
216 
217  ConfigureEMCALRecoUtils(reco,bMC,exotic,bNonLine,bRecalE,bBad,bRecalT);
218 
219  //-------------------------------------------------------
220  // Alignment matrices
221  //-------------------------------------------------------
222 
223  //clusterize->SetImportGeometryFromFile(kTRUE,"$ALICE_PHYSICS/OADB/EMCAL/geometry_2011.root"); // done automatically, set here to force
224 
225  clusterize->SwitchOnLoadOwnGeometryMatrices();
226 
227  //-------------------------------------------------------
228  // Clusterize events with some significant signal
229  //-------------------------------------------------------
230 
231  if(clusterEnergyCutEvent > 0)
232  {
233  clusterize->SwitchOnSelectEMCALEvent();
234  clusterize->SetEMCALEnergyCut(clusterEnergyCutEvent);
235  clusterize->SetEMCALNcellsCut(3);
236  }
237  else clusterize->SwitchOffSelectEMCALEvent();
238 
239  //-------------------------------------------------------
240  // Cluster MC labels recalculation
241  //-------------------------------------------------------
242 
243  if(bMC)
244  {
245  printf("Recalculate MC labels\n");
246  clusterize->SwitchOnUseClusterMCLabelForCell(0) ; // Take the cell MC label as basis (only possible in recent productions, from 2012?)
247  clusterize->SwitchOnRemapMCLabelForAODs() ; // Only in case 0, and for productions where the re-mapping of cell label in AODs was not done (productions before March 2013?)
248 
249  //clusterize->SwitchOnUseClusterMCLabelForCell(1) ; // Assign to each cell the same MC label as the original cluster to which it belonged
250  //clusterize->SwitchOnUseClusterMCLabelForCell(2) ; // Find the original clusters that have the same cells as the new cluster,
251  // assign the labels of the original clusters to the new cluster.
252  // only interesting if output is V1
253 
254  // clusterize->SwitchOnUseMCEdepFracLabelForCell(); // For Run2 MC, switch all the above off
255 
256  }
257 
258  //-------------------------------------------------------
259  // Trigger options
260  //-------------------------------------------------------
261 
262  if(trigger=="EMC7")
263  {
264  printf("Clusterizing task trigger EMC7\n");
265  clusterize->SelectCollisionCandidates(AliVEvent::kEMC7);
266  }
267  else if (trigger=="INT7")
268  {
269  printf("Clusterizing task trigger INT7\n");
270  clusterize->SelectCollisionCandidates(AliVEvent::kINT7);
271  }
272  else if(trigger=="EMC1")
273  {
274  printf("Clusterizing task trigger EMC1\n");
275  clusterize->SelectCollisionCandidates(AliVEvent::kEMC1);
276  }
277  else if(trigger=="MB")
278  {
279  printf("Clusterizing task trigger MB\n");
280  clusterize->SelectCollisionCandidates(AliVEvent::kMB);
281  }
282  else if(trigger=="PHOS")
283  {
284  printf("Clusterizing task trigger PHOS\n");
285  clusterize->SelectCollisionCandidates(AliVEvent::kPHI7);
286  }
287  else if(trigger=="PHOSPb")
288  {
289  printf("Clusterizing task trigger PHOSPb\n");
290  clusterize->SelectCollisionCandidates(AliVEvent::kPHOSPb);
291  }
292  else if(trigger=="AnyINT")
293  {
294  printf("Clusterizing task trigger AnyINT\n");
295  clusterize->SelectCollisionCandidates(AliVEvent::kAnyINT);
296  }
297  else if(trigger=="INT")
298  {
299  printf("Clusterizing task trigger AnyINT\n");
300  clusterize->SelectCollisionCandidates(AliVEvent::kAny);
301  }
302  else if(trigger=="EMCEGA")
303  {
304  printf("Clusterizing task trigger EMC Gamma\n");
305  clusterize->SelectCollisionCandidates(AliVEvent::kEMCEGA);
306  }
307  else if(trigger=="EMCEJE")
308  {
309  printf("Clusterizing task trigger EMC Jet\n");
310  clusterize->SelectCollisionCandidates(AliVEvent::kEMCEJE);
311  }
312  else if(trigger=="Central")
313  {
314  printf("Clusterizing task trigger Central\n");
315  clusterize->SelectCollisionCandidates(AliVEvent::kCentral);
316  }
317  else if(trigger=="SemiCentral")
318  {
319  printf("Clusterizing task trigger SemiCentral\n");
320  clusterize->SelectCollisionCandidates(AliVEvent::kSemiCentral);
321  }
322 
323  // Set clusters branch name, make sure the analysis after this one reads this name
324 
325  //-------------------------------------------------------
326  // Final settings, pass to manager and set the containers
327  //-------------------------------------------------------
328 
329  mgr->AddTask(clusterize);
330 
331  // Create containers for input/output
332  AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer() ;
333  mgr->ConnectInput (clusterize, 0, cinput1 );
334 
335  if(bFillAOD)
336  {
337  printf("AddTaskEMCALClusterize - Fill output AOD\n");
338  AliAnalysisDataContainer *coutput1 = mgr->GetCommonOutputContainer() ;
339  mgr->ConnectOutput (clusterize, 0, coutput1 );
340  }
341  return clusterize;
342 }
int Int_t
Definition: External.C:63
float Float_t
Definition: External.C:68
AliAnalysisTaskEMCALClusterize * AddTaskEMCALClusterize(TString &arrayName, const Bool_t bFillAOD=kFALSE, const Int_t bMC=kFALSE, const Bool_t exotic=kTRUE, const TString name="V1Unfold", const TString trigger="", const Bool_t tm=kTRUE, const Int_t minEcell=50, const Int_t minEseed=100, const Int_t maxDeltaT=250, const Int_t timeWindow=1000, const Int_t minEUnf=15, const Int_t minFrac=1, const Bool_t bRecalE=kTRUE, const Bool_t bBad=kTRUE, const Bool_t bRecalT=kTRUE, const Bool_t bNonLine=kFALSE, const Int_t minCen=-1, const Int_t maxCen=-1, const Float_t clusterEnergyCutEvent=-1, const Int_t nRowDiff=1, const Int_t nColDiff=1, const Bool_t skipOrReject=kFALSE)
bool Bool_t
Definition: External.C:53
Reclusterize EMCal clusters, put them in a new branch for other following analysis.
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)