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