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