AliPhysics  vAN-20150822 (d56cf94)
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros
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  // Position and SS weight parameter
123  params->SetW0(4.5);
124 
125  // Time cuts
126 
127  if(maxDeltaT > 1) params->SetTimeCut(maxDeltaT*1.e-9);
128  else { params->SetTimeCut(250*1.e-9); printf("default maxDeltaT = 250 ns\n"); }// Same as in reco
129 
130  if(timeWindow > 1)
131  {
132  params->SetTimeMin(-1*timeWindow*1.e-9);
133  params->SetTimeMax(timeWindow*1.e-9);
134  }
135  else
136  {
137  if(!bMC)
138  {
139  if(bRecalT)
140  {
141  params->SetTimeMin(-250*1.e-9);
142  params->SetTimeMax( 250*1.e-9);
143  printf("default time window for calibrated time -250 ns < T < 250 ns\n");
144  }
145  else
146  {
147  // same as in reco, USE IF NO TIME RECALIBRATION
148  params->SetTimeMin(425*1.e-9);
149  params->SetTimeMax(825*1.e-9);
150  printf("default time window 425 ns < T < 825 ns\n");
151  }
152  }
153  else
154  {
155  params->SetTimeMin(-100000000);
156  params->SetTimeMax( 100000000);
157  printf("open time cut\n");
158  }
159  }
160 
161  // Energy cuts
162  params->SetClusteringThreshold(minEseed/1.e3);
163  params->SetMinECut (minEcell/1.e3);
164 
165  // Clusterizer type
166  if(name.Contains("V2")) params->SetClusterizerFlag(AliEMCALRecParam::kClusterizerv2);
167  if(name.Contains("V1")) params->SetClusterizerFlag(AliEMCALRecParam::kClusterizerv1);
168  if(name.Contains("NxN"))
169  {
170  params->SetClusterizerFlag(AliEMCALRecParam::kClusterizerNxN);
171  printf("Set NxN cluster size to %dx%d (row diff %d, col diff %d)\n",2*nRowDiff+1,2*nColDiff+1,nRowDiff,nColDiff);
172  params->SetNxM(nRowDiff, nColDiff);
173  }
174 
175  //-------------------------------------------------------
176  // Unfolding, 2 options :
177  //-------------------------------------------------------
178 
179  // 1) Just unfold existing clusters
180  if(name.Contains("JustUnfold"))
181  clusterize->JustUnfold(kTRUE); // if TRUE, do just unfolding, do not recluster cells
182  else
183  clusterize->JustUnfold(kFALSE);
184 
185  // 2) Unfold clusters created in the clusterize (revise settings)
186  if (name.Contains("Unfold"))
187  {
188  clusterize->SwitchOnCellEnergySelection();
189  clusterize->SetCellCuts(minEUnf/1000.,minFrac/10000.);
190  clusterize->SetRejectBelowThreshold(skipOrReject);
191  printf("AliAnalysisTaskEMCALClusterize - Cuts: min E %f, frac %f\n",minEUnf/1000.,minFrac/10000.);
192  //clusterize->SwitchOffCellEnergySelection();
193 
194  if(!name.Contains("Just"))
195  params->SetUnfold(kTRUE);
196  else
197  params->SetUnfold(kFALSE);
198 
199  } // unfold
200 
201  //-------------------------------------------------------
202  // Configure AliEMCALRecoUtils
203  //-------------------------------------------------------
204 
205  AliEMCALRecoUtils * reco = clusterize->GetRecoUtils();
206 
207  gROOT->LoadMacro("$ALICE_PHYSICS/PWGPP/EMCAL/macros/ConfigureEMCALRecoUtils.C");
208 
209  ConfigureEMCALRecoUtils(reco,bMC,exotic,bNonLine,bRecalE,bBad,bRecalT);
210 
211  //-------------------------------------------------------
212  // Alignment matrices
213  //-------------------------------------------------------
214 
215  //clusterize->SetImportGeometryFromFile(kTRUE,"$ALICE_PHYSICS/OADB/EMCAL/geometry_2011.root"); // done automatically, set here to force
216 
217  clusterize->SwitchOnLoadOwnGeometryMatrices();
218 
219  //-------------------------------------------------------
220  // Clusterize events with some significant signal
221  //-------------------------------------------------------
222 
223  if(clusterEnergyCutEvent > 0)
224  {
225  clusterize->SwitchOnSelectEMCALEvent();
226  clusterize->SetEMCALEnergyCut(clusterEnergyCutEvent);
227  clusterize->SetEMCALNcellsCut(3);
228  }
229  else clusterize->SwitchOffSelectEMCALEvent();
230 
231  //-------------------------------------------------------
232  // Cluster MC labels recalculation
233  //-------------------------------------------------------
234 
235  if(bMC)
236  {
237  printf("Recalculate MC labels\n");
238  clusterize->SwitchOnUseClusterMCLabelForCell(0) ; // Take the cell MC label as basis (only possible in recent productions)
239  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?)
240 
241  //clusterize->SwitchOnUseClusterMCLabelForCell(1) ; // Assign to each cell the same MC label as the original cluster to which it belonged
242  //clusterize->SwitchOnUseClusterMCLabelForCell(2) ; // Find the original clusters that have the same cells as the new cluster,
243  // assign the labels of the original clusters to the new cluster.
244  // only interesting if output is V1
245 
246  }
247 
248  //-------------------------------------------------------
249  // Trigger options
250  //-------------------------------------------------------
251 
252  if(trigger=="EMC7")
253  {
254  printf("Clusterizing task trigger EMC7\n");
255  clusterize->SelectCollisionCandidates(AliVEvent::kEMC7);
256  }
257  else if (trigger=="INT7")
258  {
259  printf("Clusterizing task trigger INT7\n");
260  clusterize->SelectCollisionCandidates(AliVEvent::kINT7);
261  }
262  else if(trigger=="EMC1")
263  {
264  printf("Clusterizing task trigger EMC1\n");
265  clusterize->SelectCollisionCandidates(AliVEvent::kEMC1);
266  }
267  else if(trigger=="MB")
268  {
269  printf("Clusterizing task trigger MB\n");
270  clusterize->SelectCollisionCandidates(AliVEvent::kMB);
271  }
272  else if(trigger=="PHOS")
273  {
274  printf("Clusterizing task trigger PHOS\n");
275  clusterize->SelectCollisionCandidates(AliVEvent::kPHI7);
276  }
277  else if(trigger=="PHOSPb")
278  {
279  printf("Clusterizing task trigger PHOSPb\n");
280  clusterize->SelectCollisionCandidates(AliVEvent::kPHOSPb);
281  }
282  else if(trigger=="AnyINT")
283  {
284  printf("Clusterizing task trigger AnyINT\n");
285  clusterize->SelectCollisionCandidates(AliVEvent::kAnyINT);
286  }
287  else if(trigger=="INT")
288  {
289  printf("Clusterizing task trigger AnyINT\n");
290  clusterize->SelectCollisionCandidates(AliVEvent::kAny);
291  }
292  else if(trigger=="EMCEGA")
293  {
294  printf("Clusterizing task trigger EMC Gamma\n");
295  clusterize->SelectCollisionCandidates(AliVEvent::kEMCEGA);
296  }
297  else if(trigger=="EMCEJE")
298  {
299  printf("Clusterizing task trigger EMC Jet\n");
300  clusterize->SelectCollisionCandidates(AliVEvent::kEMCEJE);
301  }
302  else if(trigger=="Central")
303  {
304  printf("Clusterizing task trigger Central\n");
305  clusterize->SelectCollisionCandidates(AliVEvent::kCentral);
306  }
307  else if(trigger=="SemiCentral")
308  {
309  printf("Clusterizing task trigger SemiCentral\n");
310  clusterize->SelectCollisionCandidates(AliVEvent::kSemiCentral);
311  }
312 
313  // Set clusters branch name, make sure the analysis after this one reads this name
314 
315  //-------------------------------------------------------
316  // Final settings, pass to manager and set the containers
317  //-------------------------------------------------------
318 
319  mgr->AddTask(clusterize);
320 
321  // Create containers for input/output
322  AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer() ;
323  mgr->ConnectInput (clusterize, 0, cinput1 );
324 
325  if(bFillAOD)
326  {
327  printf("AddTaskEMCALClusterize - Fill output AOD\n");
328  AliAnalysisDataContainer *coutput1 = mgr->GetCommonOutputContainer() ;
329  mgr->ConnectOutput (clusterize, 0, coutput1 );
330  }
331  return clusterize;
332 }
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)
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)