AliPhysics  2c6b7ad (2c6b7ad)
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",
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("V3")) params->SetClusterizerFlag(AliEMCALRecParam::kClusterizerv3); // faster V2
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  // See https://alice-notes.web.cern.ch/node/837
298  //-------------------------------------------------------
299 
300  clusterize->SwitchOffTCardCorrelation();
301 
302  if(bMC && tCardMimic > 0)
303  {
304  if ( tCardMimic == 1 ) clusterize->SwitchOnTCardCorrelation(kFALSE);
305  else clusterize->SwitchOnTCardCorrelation(kTRUE);
306 
307  // Parameters setting
308  // Optional emulation, all SM have cross talk all the time
309  for(Int_t ism = 0; ism < 22; ism++)
310  clusterize->SetInducedEnergyLossProbabilityPerSM(1.0, ism);
311 
312  clusterize->SetInducedTCardMinimumCellEnergy(0.01) ;
313  clusterize->SetInducedTCardMaximum(100) ;
314  clusterize->SetInducedTCardMaximumLowE(-1);
315  clusterize->SetInducedTCardMinimum(0.1);
316 
317  clusterize->SwitchOnRandomizeTCardInducedEnergy() ;
318 
319  clusterize->SetInducedEnergyLossMinimumFraction(0.35/100.);
320  clusterize->SetInducedEnergyLossMaximumFraction(1.6/100.);
321 
322  // SM0,4,5,6,8,9,12,13,14,15,16,17,18,19 (set it first for all SM equal)
323  Float_t mu1 = 0.80/100.;
324  Float_t mu2 =-0.11/100.;
325  Float_t wid = 0.50/100.;
326  clusterize->SetInducedEnergyLossFraction (mu1, mu1, mu1, 0.00000);
327  clusterize->SetInducedEnergyLossFractionP1(mu2, mu2, mu2, 0.00000);
328  clusterize->SetInducedEnergyLossFractionWidth(wid,wid,wid,0.00000);
329 
330  // SM3,7
331  mu1 = 1.20/100.;
332  mu2 =-0.11/100.;
333  clusterize->SetInducedEnergyLossFractionPerSM (3,mu1, mu1, mu1, 0.00000);
334  clusterize->SetInducedEnergyLossFractionP1PerSM(3,mu2, mu2, mu2, 0.00000);
335  clusterize->SetInducedEnergyLossMinimumFractionPerSM(0.6/100.,3);
336  clusterize->SetInducedEnergyLossMaximumFractionPerSM(1.8/100.,3);
337 
338  mu1 = 1.20/100.;
339  mu2 =-0.11/100.;
340  clusterize->SetInducedEnergyLossFractionPerSM (7,mu1, mu1, mu1, 0.00000);
341  clusterize->SetInducedEnergyLossFractionP1PerSM(7,mu2, mu2, mu2, 0.00000);
342  clusterize->SetInducedEnergyLossMinimumFractionPerSM(0.6/100.,7);
343  clusterize->SetInducedEnergyLossMaximumFractionPerSM(1.8/100.,7);
344 
345  // SM1,2,10,11
346  mu1 = 1.20/100.;
347  mu2 =-0.11/100.;
348  clusterize->SetInducedEnergyLossFractionPerSM (1,mu1, mu1, mu1, 0.00000);
349  clusterize->SetInducedEnergyLossFractionP1PerSM(1,mu2, mu2, mu2, 0.00000);
350  clusterize->SetInducedEnergyLossMinimumFractionPerSM(0.5/100.,1);
351 
352  clusterize->SetInducedEnergyLossFractionPerSM (10,mu1, mu1, mu1, 0.00000);
353  clusterize->SetInducedEnergyLossFractionP1PerSM(10,mu2, mu2, mu2, 0.00000);
354  clusterize->SetInducedEnergyLossMinimumFractionPerSM(0.5/100.,10);
355 
356  clusterize->SetInducedEnergyLossFractionPerSM (11,mu1, mu1, mu1, 0.00000);
357  clusterize->SetInducedEnergyLossFractionP1PerSM(11,mu2, mu2, mu2, 0.00000);
358  clusterize->SetInducedEnergyLossMinimumFractionPerSM(0.5/100.,11);
359 
360  mu1 = 1.15/100.;
361  mu2 =-0.11/100.;
362  clusterize->SetInducedEnergyLossFractionPerSM (2,mu1, mu1, mu1, 0.00000);
363  clusterize->SetInducedEnergyLossFractionP1PerSM(2,mu2, mu2, mu2, 0.00000);
364  clusterize->SetInducedEnergyLossMinimumFractionPerSM(0.45/100.,2);
365  }
366 
367  //-------------------------------------------------------
368  // Trigger options
369  //-------------------------------------------------------
370 
371  if(trigger=="EMC7")
372  {
373  printf("AddTaskEMCALClusterize() - trigger EMC7\n");
374  clusterize->SelectCollisionCandidates(AliVEvent::kEMC7);
375  }
376  else if (trigger=="INT7")
377  {
378  printf("AddTaskEMCALClusterize() - trigger INT7\n");
379  clusterize->SelectCollisionCandidates(AliVEvent::kINT7);
380  }
381  else if(trigger=="EMC1")
382  {
383  printf("AddTaskEMCALClusterize() - trigger EMC1\n");
384  clusterize->SelectCollisionCandidates(AliVEvent::kEMC1);
385  }
386  else if(trigger=="MB")
387  {
388  printf("AddTaskEMCALClusterize() - trigger MB\n");
389  clusterize->SelectCollisionCandidates(AliVEvent::kMB);
390  }
391  else if(trigger=="PHOS")
392  {
393  printf("AddTaskEMCALClusterize() - trigger PHOS\n");
394  clusterize->SelectCollisionCandidates(AliVEvent::kPHI7);
395  }
396  else if(trigger=="PHOSPb")
397  {
398  printf("AddTaskEMCALClusterize() - trigger PHOSPb\n");
399  clusterize->SelectCollisionCandidates(AliVEvent::kPHOSPb);
400  }
401  else if(trigger=="AnyINT")
402  {
403  printf("AddTaskEMCALClusterize() - trigger AnyINT\n");
404  clusterize->SelectCollisionCandidates(AliVEvent::kAnyINT);
405  }
406  else if(trigger=="INT")
407  {
408  printf("AddTaskEMCALClusterize() - trigger AnyINT\n");
409  clusterize->SelectCollisionCandidates(AliVEvent::kAny);
410  }
411  else if(trigger=="EMCEGA")
412  {
413  printf("AddTaskEMCALClusterize() - EMC Gamma\n");
414  clusterize->SelectCollisionCandidates(AliVEvent::kEMCEGA);
415  }
416  else if(trigger=="EMCEJE")
417  {
418  printf("AddTaskEMCALClusterize() - trigger EMC Jet\n");
419  clusterize->SelectCollisionCandidates(AliVEvent::kEMCEJE);
420  }
421  else if(trigger=="Central")
422  {
423  printf("AddTaskEMCALClusterize() - trigger Central\n");
424  clusterize->SelectCollisionCandidates(AliVEvent::kCentral);
425  }
426  else if(trigger=="SemiCentral")
427  {
428  printf("AddTaskEMCALClusterize() - trigger SemiCentral\n");
429  clusterize->SelectCollisionCandidates(AliVEvent::kSemiCentral);
430  }
431 
432  // Set clusters branch name, make sure the analysis after this one reads this name
433 
434  //-------------------------------------------------------
435  // Final settings, pass to manager and set the containers
436  //-------------------------------------------------------
437 
438  mgr->AddTask(clusterize);
439 
440  // Create containers for input/output
441  AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer() ;
442  mgr->ConnectInput (clusterize, 0, cinput1 );
443 
444  if(bFillAOD)
445  {
446  printf("AddTaskEMCALClusterize() - Fill output AOD\n");
447  AliAnalysisDataContainer *coutput1 = mgr->GetCommonOutputContainer() ;
448  mgr->ConnectOutput (clusterize, 0, coutput1 );
449  }
450  return clusterize;
451 }
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.