AliPhysics  8d00e07 (8d00e07)
AddTaskEMCALClusterize.C
Go to the documentation of this file.
1 
12 #if !defined(__CINT__) || defined(__MAKECINT__)
13 
14 #include <TROOT.h>
15 
16 #include "AliAnalysisManager.h"
17 
19 
20 //#include "ConfigureEMCALRecoUtils.C"
21 
22 #endif // CINT
23 
54  TString & arrayName,
55  const Bool_t bFillAOD = kFALSE,
56  const Int_t bMC = kFALSE,
57  const Bool_t exotic = kTRUE,
58  const TString name = "V1Unfold", // V1, V2, NxN, V1Unfold
59  const TString trigger = "",
60  const Int_t tm = 1,
61  const Int_t minEcell = 50,
62  const Int_t minEseed = 100,
63  const Int_t maxDeltaT = 250,
64  const Int_t timeWindow = 1000,
65  const Int_t minEUnf = 15,
66  const Int_t minFrac = 1,
67  const Bool_t bRecalE = kTRUE,
68  const Bool_t bBad = kTRUE,
69  const Bool_t bRecalT = kTRUE,
70  const Bool_t bNonLine = kFALSE,
71  const Int_t minCen = -1,
72  const Int_t maxCen = -1,
73  const Float_t clusterEnergyCutEvent = -1,
74  const Int_t nRowDiff = 1,
75  const Int_t nColDiff = 1,
76  const Bool_t skipOrReject = kFALSE,
77  const Int_t tCardMimic = 0,
78  const Bool_t cellUpd = kTRUE
79  )
80 {
81  // Get the pointer to the existing analysis manager via the static access method.
82  //==============================================================================
83  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
84  if (!mgr)
85  {
86  ::Error("AddTaskEMCALClusterize", "No analysis manager to connect to.");
87  return NULL;
88  }
89 
90  // Check the analysis type using the event handlers connected to the analysis manager.
91  //==============================================================================
92  if (!mgr->GetInputEventHandler())
93  {
94  ::Error("AddTaskEMCALClusterize", "This clusterize requires an input event handler");
95  return NULL;
96  }
97 
98  printf("AddTaskEMCALClusterize() - Passed Settings :\n");
99  printf("\t mc %d, exo %d, name %s, trigger %s, tm %d\n",
100  bMC,exotic,name.Data(),trigger.Data(),tm);
101  printf("\t Ecell %d, Eseed %d, dT %d, wT %d, minUnf %d, minFrac %d \n",
102  minEcell, minEseed,maxDeltaT,timeWindow,minEUnf,minFrac);
103  printf("\t recalE %d, bad %d, recalT %d, nonlin %d, minCen %d, maxCen %d, rowDiff %d, colDiff %d, t-card %d, cell update %d \n",
104  bRecalE,bBad,bRecalT,bNonLine,minCen,maxCen,nRowDiff,nColDiff,tCardMimic,cellUpd);
105 
106  // Create name of task and AOD branch depending on different settings
107 
108  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);
109  else arrayName = Form( "%s_Ecell%d_Eseed%d_DT%d_WT%d", name.Data(),minEcell,minEseed,maxDeltaT,timeWindow);
110 
111  if(minCen != -1 && maxCen != -1)
112  arrayName+=Form("_Cen%d_%d",minCen,maxCen);
113 
114  printf("AddTaskEMCALClusterize() - Created Branch Name: %s \n",arrayName.Data());
115 
116  //-------------------------------------------------------
117  // Init the task and do settings
118  //-------------------------------------------------------
119 
120  AliAnalysisTaskEMCALClusterize* clusterize = new AliAnalysisTaskEMCALClusterize(Form("EMCALClusterize%s",arrayName.Data()));
121 
122  clusterize->SetAODBranchName(arrayName);
123 
124  //clusterize->SetOCDBPath("local://$ALICE_ROOT/OCDB");
125 
126  // Centrality range
127  clusterize->SetCentralityBin(minCen, maxCen);
128 
129  // Some general settings to create AOD file in case we want to keep it
130  clusterize->SwitchOffFillAODCaloCells();
131  clusterize->SwitchOffFillAODHeader();
132  clusterize->FillAODFile(bFillAOD); // fill aod.root with clusters?, not really needed for analysis.
133 
134  // Update cells list after cuts
135  if ( cellUpd ) clusterize->SwitchOnUpdateCell();
136 
137  //-------------------------------------------------------
138  // Set clusterization parameters via rec param
139  //-------------------------------------------------------
140 
141  AliEMCALRecParam * params = clusterize->GetRecParam();
142 
143  //
144  // Position and SS weight parameter
145  //
146  params->SetW0(4.5);
147 
148  //
149  // Time cuts
150  // Be careful using time cuts, best thing is to leave them open.
151  //
152  if(maxDeltaT > 1) params->SetTimeCut(maxDeltaT*1.e-9);
153  else { params->SetTimeCut(250*1.e-9); printf("AddTaskEMCALClusterize() - default maxDeltaT = 250 ns\n"); }// Same as in reco
154 
155  if(timeWindow > 1)
156  {
157  params->SetTimeMin(-1*timeWindow*1.e-9);
158  params->SetTimeMax(timeWindow*1.e-9);
159  }
160  else
161  {
162  if(!bMC)
163  {
164  if(bRecalT)
165  {
166  params->SetTimeMin(-250*1.e-9);
167  params->SetTimeMax( 250*1.e-9);
168  printf("AddTaskEMCALClusterize() - default time window for calibrated time -250 ns < T < 250 ns\n");
169  }
170  else
171  {
172  // same as in reco, USE IF NO TIME RECALIBRATION
173  params->SetTimeMin(425*1.e-9);
174  params->SetTimeMax(825*1.e-9);
175  printf("AddTaskEMCALClusterize() - default time window 425 ns < T < 825 ns\n");
176  }
177  }
178  else
179  {
180  params->SetTimeMin(-100000000);
181  params->SetTimeMax( 100000000);
182  printf("AddTaskEMCALClusterize() - open time cut\n");
183  }
184  }
185 
186  //
187  // Energy cuts
188  //
189  params->SetClusteringThreshold(minEseed/1.e3);
190  params->SetMinECut (minEcell/1.e3);
191 
192  //
193  // Clusterizer type
194  //
195  if(name.Contains("V2")) params->SetClusterizerFlag(AliEMCALRecParam::kClusterizerv2);
196  if(name.Contains("V1")) params->SetClusterizerFlag(AliEMCALRecParam::kClusterizerv1);
197  if(name.Contains("NxN"))
198  {
199  params->SetClusterizerFlag(AliEMCALRecParam::kClusterizerNxN);
200  printf("AddTaskEMCALClusterize() - Set NxN cluster size to %dx%d (row diff %d, col diff %d)\n",
201  2*nRowDiff+1,2*nColDiff+1,nRowDiff,nColDiff);
202  params->SetNxM(nRowDiff, nColDiff);
203  }
204 
205  //-------------------------------------------------------
206  // Unfolding, 2 options :
207  //-------------------------------------------------------
208 
209  // 1) Just unfold existing clusters
210  if(name.Contains("JustUnfold"))
211  clusterize->JustUnfold(kTRUE); // if TRUE, do just unfolding, do not recluster cells
212  else
213  clusterize->JustUnfold(kFALSE);
214 
215  // 2) Unfold clusters created in the clusterize (revise settings)
216  if (name.Contains("Unfold"))
217  {
218  clusterize->SwitchOnCellEnergySelection();
219  clusterize->SetCellCuts(minEUnf/1000.,minFrac/10000.);
220  clusterize->SetRejectBelowThreshold(skipOrReject);
221  printf("AliAnalysisTaskEMCALClusterize() - Unfolding Cuts: min E %f, frac %f\n",
222  minEUnf/1000.,minFrac/10000.);
223  //clusterize->SwitchOffCellEnergySelection();
224 
225  if(!name.Contains("Just"))
226  params->SetUnfold(kTRUE);
227  else
228  params->SetUnfold(kFALSE);
229 
230  } // unfold
231 
232  //-------------------------------------------------------
233  // Configure AliEMCALRecoUtils
234  //-------------------------------------------------------
235 
236 // AliEMCALRecoUtils * reco = clusterize->GetRecoUtils();
237 //
238 // gROOT->LoadMacro("$ALICE_PHYSICS/PWGPP/EMCAL/macros/ConfigureEMCALRecoUtils.C");
239 //
240 // ConfigureEMCALRecoUtils(reco,bMC,exotic,bNonLine,bRecalE,bBad,bRecalT);
241 
242  clusterize->ConfigureEMCALRecoUtils(bMC,exotic,bNonLine,bRecalE,bBad,bRecalT);
243 
244  //-------------------------------------------------------
245  // Do track matching after clusterization
246  //-------------------------------------------------------
247  if ( tm > 0 )
248  {
249  clusterize->SwitchOnTrackMatching();
250  if ( tm == 2 ) clusterize->GetRecoUtils()->SwitchOnAODHybridTracksMatch();
251  else if ( tm == 1 ) clusterize->GetRecoUtils()->SwitchOnAODTPCOnlyTracksMatch();
252  else clusterize->GetRecoUtils()->SetAODTrackFilterMask(tm);
253  }
254  else clusterize->SwitchOffTrackMatching();
255 
256  //-------------------------------------------------------
257  // Alignment matrices
258  //-------------------------------------------------------
259 
260  //clusterize->SetImportGeometryFromFile(kTRUE,"$ALICE_PHYSICS/OADB/EMCAL/geometry_2011.root"); // done automatically, set here to force
261 
262  clusterize->SwitchOnLoadOwnGeometryMatrices();
263 
264  //-------------------------------------------------------
265  // Clusterize events with some significant signal
266  //-------------------------------------------------------
267 
268  if(clusterEnergyCutEvent > 0)
269  {
270  clusterize->SwitchOnSelectEMCALEvent();
271  clusterize->SetEMCALEnergyCut(clusterEnergyCutEvent);
272  clusterize->SetEMCALNcellsCut(3);
273  }
274  else clusterize->SwitchOffSelectEMCALEvent();
275 
276  //-------------------------------------------------------
277  // Cluster MC labels recalculation
278  //-------------------------------------------------------
279 
280  if(bMC)
281  {
282  //printf("Recalculate MC labels\n");
283  clusterize->SwitchOnUseClusterMCLabelForCell(0) ; // Take the cell MC label as basis (only possible in recent productions, from 2012?)
284  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?)
285 
286  //clusterize->SwitchOnUseClusterMCLabelForCell(1) ; // Assign to each cell the same MC label as the original cluster to which it belonged
287  //clusterize->SwitchOnUseClusterMCLabelForCell(2) ; // Find the original clusters that have the same cells as the new cluster,
288  // assign the labels of the original clusters to the new cluster.
289  // only interesting if output is V1
290 
291  // clusterize->SwitchOnUseMCEdepFracLabelForCell(); // For Run2 MC, switch all the above off
292 
293  }
294 
295  //-------------------------------------------------------
296  // T-Card cell correlation
297  //-------------------------------------------------------
298 
299  clusterize->SwitchOffTCardCorrelation();
300 
301  if(bMC && tCardMimic > 0)
302  {
303  if ( tCardMimic == 1 ) clusterize->SwitchOnTCardCorrelation(kFALSE);
304  else clusterize->SwitchOnTCardCorrelation(kTRUE);
305 
306  // Parameters setting
307  // See related EMCal meeting presentation, 14th december 2017, case E in slide 13 of:
308  // https://indico.cern.ch/event/650299/contributions/2645134/subcontributions/244024/attachments/1575981/2496596/ShowerShapes_pp7TeV_ClusterV1_MCvsData_TCardMimic_EMCalMeeting141217.pdf
309 
310  // Cell E dependent parametrization, pol1
311  // Set the same for all SM
312  Float_t mu1 = 2.20/100./1.10;
313  Float_t mu2 =-0.09/100.;
314  clusterize->SetInducedEnergyLossFraction (mu1, mu1, mu1, 0.); // constant
315  clusterize->SetInducedEnergyLossFractionP1(mu2, mu2, mu2, 0.); // slope
316 
317  // Absolute min E fraction
318  // Set the same for all SM
319  Float_t mu1Min = 0.80/100.;
320  for(Int_t ism = 0; ism < 20; ism++)
321  clusterize->SetInducedEnergyLossMinimumFractionPerSM(mu1Min,ism);
322 
323  // Absolute max E fraction
324  // Set the same for all SM
325  Float_t mu1Max = 2.50/100.;
326  for(Int_t ism = 0; ism < 20; ism++)
327  clusterize->SetInducedEnergyLossMaximumFractionPerSM(mu1Max,ism);
328 
329  clusterize->SetInducedTCardMinimumCellEnergy(0) ;
330  clusterize->SeInducedTCardMaximum(100) ;
331 
332  // No randomization of the previosly set parameters
333  clusterize->SwitchOffRandomizeTCardInducedEnergy() ;
334  clusterize->SetInducedEnergyLossFractionWidth(0., 0., 0., 0.);
335 
336  // Set the fraction of events where an SM shows different behavior from default
337  clusterize->SetInducedEnergyLossProbabilityPerSM(0.30, 0);
338  clusterize->SetInducedEnergyLossProbabilityPerSM(0.60, 1);
339  clusterize->SetInducedEnergyLossProbabilityPerSM(0.50, 2);
340  clusterize->SetInducedEnergyLossProbabilityPerSM(1.00, 3);
341  clusterize->SetInducedEnergyLossProbabilityPerSM(0.35, 4);
342  clusterize->SetInducedEnergyLossProbabilityPerSM(0.25, 5);
343  clusterize->SetInducedEnergyLossProbabilityPerSM(0.35, 6);
344  clusterize->SetInducedEnergyLossProbabilityPerSM(1.00, 7);
345  clusterize->SetInducedEnergyLossProbabilityPerSM(0.25, 8);
346  clusterize->SetInducedEnergyLossProbabilityPerSM(0.25, 9);
347 
348  for(Int_t ism = 10; ism < 20; ism++)
349  clusterize->SetInducedEnergyLossProbabilityPerSM(0., ism);
350  }
351 
352  //-------------------------------------------------------
353  // Trigger options
354  //-------------------------------------------------------
355 
356  if(trigger=="EMC7")
357  {
358  printf("AddTaskEMCALClusterize() - trigger EMC7\n");
359  clusterize->SelectCollisionCandidates(AliVEvent::kEMC7);
360  }
361  else if (trigger=="INT7")
362  {
363  printf("AddTaskEMCALClusterize() - trigger INT7\n");
364  clusterize->SelectCollisionCandidates(AliVEvent::kINT7);
365  }
366  else if(trigger=="EMC1")
367  {
368  printf("AddTaskEMCALClusterize() - trigger EMC1\n");
369  clusterize->SelectCollisionCandidates(AliVEvent::kEMC1);
370  }
371  else if(trigger=="MB")
372  {
373  printf("AddTaskEMCALClusterize() - trigger MB\n");
374  clusterize->SelectCollisionCandidates(AliVEvent::kMB);
375  }
376  else if(trigger=="PHOS")
377  {
378  printf("AddTaskEMCALClusterize() - trigger PHOS\n");
379  clusterize->SelectCollisionCandidates(AliVEvent::kPHI7);
380  }
381  else if(trigger=="PHOSPb")
382  {
383  printf("AddTaskEMCALClusterize() - trigger PHOSPb\n");
384  clusterize->SelectCollisionCandidates(AliVEvent::kPHOSPb);
385  }
386  else if(trigger=="AnyINT")
387  {
388  printf("AddTaskEMCALClusterize() - trigger AnyINT\n");
389  clusterize->SelectCollisionCandidates(AliVEvent::kAnyINT);
390  }
391  else if(trigger=="INT")
392  {
393  printf("AddTaskEMCALClusterize() - trigger AnyINT\n");
394  clusterize->SelectCollisionCandidates(AliVEvent::kAny);
395  }
396  else if(trigger=="EMCEGA")
397  {
398  printf("AddTaskEMCALClusterize() - EMC Gamma\n");
399  clusterize->SelectCollisionCandidates(AliVEvent::kEMCEGA);
400  }
401  else if(trigger=="EMCEJE")
402  {
403  printf("AddTaskEMCALClusterize() - trigger EMC Jet\n");
404  clusterize->SelectCollisionCandidates(AliVEvent::kEMCEJE);
405  }
406  else if(trigger=="Central")
407  {
408  printf("AddTaskEMCALClusterize() - trigger Central\n");
409  clusterize->SelectCollisionCandidates(AliVEvent::kCentral);
410  }
411  else if(trigger=="SemiCentral")
412  {
413  printf("AddTaskEMCALClusterize() - trigger SemiCentral\n");
414  clusterize->SelectCollisionCandidates(AliVEvent::kSemiCentral);
415  }
416 
417  // Set clusters branch name, make sure the analysis after this one reads this name
418 
419  //-------------------------------------------------------
420  // Final settings, pass to manager and set the containers
421  //-------------------------------------------------------
422 
423  mgr->AddTask(clusterize);
424 
425  // Create containers for input/output
426  AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer() ;
427  mgr->ConnectInput (clusterize, 0, cinput1 );
428 
429  if(bFillAOD)
430  {
431  printf("AddTaskEMCALClusterize() - Fill output AOD\n");
432  AliAnalysisDataContainer *coutput1 = mgr->GetCommonOutputContainer() ;
433  mgr->ConnectOutput (clusterize, 0, coutput1 );
434  }
435  return clusterize;
436 }
int Int_t
Definition: External.C:63
float Float_t
Definition: External.C:68
bool Bool_t
Definition: External.C:53
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 Int_t tm=1, 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, const Int_t tCardMimic=0, const Bool_t cellUpd=kTRUE)
Reclusterize EMCal clusters, put them in a new branch for other following analysis.