]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGGA/EMCALTasks/macros/AddTaskEMCALClusterize.C
add option to put new list of clusters in output or input event
[u/mrichter/AliRoot.git] / PWGGA / EMCALTasks / macros / AddTaskEMCALClusterize.C
1 // $Id$
2
3 AliAnalysisTaskEMCALClusterize* AddTaskEMCALClusterize(
4   TString & arrayName,
5   const Bool_t  bFillAOD   = kFALSE,                                                
6   const Int_t   bMC        = kFALSE,
7   const Bool_t  exotic     = kTRUE,
8   const TString name       = "V1Unfold", 
9   const TString trigger    = "", 
10   const Bool_t  tm         = kTRUE, 
11   const Int_t   minEcell   = 50,
12   const Int_t   minEseed   = 100,
13   const Int_t   maxDeltaT  = 250,
14   const Int_t   timeWindow = 1000,
15   const Int_t   minEUnf    = 15, 
16   const Int_t   minFrac    = 1,
17   const Bool_t  bRecalE    = kTRUE,
18   const Bool_t  bBad       = kTRUE,
19   const Bool_t  bRecalT    = kTRUE,
20   const Bool_t  bNonLine   = kFALSE,
21   const Int_t   nRowDiff   = 1,
22   const Int_t   nColDiff   = 1
23 )
24 {  
25   // Get the pointer to the existing analysis manager via the static access method.
26   //==============================================================================
27   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
28   if (!mgr)
29   {
30     ::Error("AddTaskEMCALClusterize", "No analysis manager to connect to.");
31     return NULL;
32   }  
33   
34   // Check the analysis type using the event handlers connected to the analysis manager.
35   //==============================================================================
36   if (!mgr->GetInputEventHandler())
37   {
38     ::Error("AddTaskEMCALClusterize", "This clusterize requires an input event handler");
39     return NULL;
40   }
41   
42   printf("Passed Settings : mc %d, exo %d, name %s, trigger %s, tm %d\n",bMC,exotic,name.Data(),trigger.Data(),tm);
43   printf("                  Ecell %d, Eseed %d, dT %d, wT %d, minUnf %d, minFrac %d \n",minEcell, minEseed,maxDeltaT,timeWindow,minEUnf,minFrac);
44   printf("                  recalE %d, bad %d, recalT %d, nonlin %d, rowDiff %d, colDiff %d \n",bRecalE,bBad,bRecalT,bNonLine,nRowDiff,nColDiff);
45
46   //-------------------------------------------------------
47   // Init the task and do settings
48   //-------------------------------------------------------
49
50   AliAnalysisTaskEMCALClusterize* clusterize = new AliAnalysisTaskEMCALClusterize(Form("EMCALClusterize%s_Ecell%d_Eseed%d_DT%d_WT%d",
51                                                                                        name.Data(),minEcell,minEseed,maxDeltaT,timeWindow));
52
53   //clusterize->SetOCDBPath("local://$ALICE_ROOT/OCDB");
54
55   // Some general settings to create AOD file in case we want to keep it
56   clusterize->SwitchOffFillAODCaloCells();
57   clusterize->SwitchOffFillAODHeader();
58   clusterize->FillAODFile(bFillAOD); // fill aod.root with clusters?, not really needed for analysis.
59
60   // Do track matching after clusterization
61   if(tm) clusterize->SwitchOnTrackMatching();
62   else   clusterize->SwitchOffTrackMatching();
63   
64   //-------------------------------------------------------
65   // Set clusterization parameters via rec param
66   //-------------------------------------------------------
67
68   AliEMCALRecParam * params = clusterize->GetRecParam();
69
70   // Position and SS weight parameter
71   params->SetW0(4.5);
72
73   // Time cuts, depend on data type (no cells time in AODs)
74   TString sHandler((mgr->GetInputEventHandler())->ClassName());
75   if(sHandler.Contains("AOD"))
76   {
77     printf("AliAnalysisTaskEMCALClusterize - Open time cuts for AODs\n");
78     params->SetTimeCut(1e6);//Open this cut for AODs
79     params->SetTimeMin(-1); //Open this cut for AODs
80     params->SetTimeMax(1e6);//Open this cut for AODs    
81   }
82   else
83   {
84     printf("AliAnalysisTaskEMCALClusterize - Set time cuts for ESDs\n");
85     if(maxDeltaT > 1) params->SetTimeCut(maxDeltaT*1.e-9);
86     else            { params->SetTimeCut(250*1.e-9); printf("default maxDeltaT = 250 ns\n"); }// Same as in reco
87     
88     if(timeWindow > 1)
89     {
90       params->SetTimeMin(-1*timeWindow*1.e-9);
91       params->SetTimeMax(timeWindow*1.e-9);
92     }
93     else
94     { 
95       if(bRecalT && !bMC)
96       {
97         params->SetTimeMin(-250*1.e-9);
98         params->SetTimeMax( 250*1.e-9);
99         printf("default time window for calibrated time -250 ns < T < 250 ns\n");
100       }
101       else 
102       {
103         // same as in reco, USE IF NO TIME RECALIBRATION
104         params->SetTimeMin(425*1.e-9);
105         params->SetTimeMax(825*1.e-9);
106         printf("default time window 425 ns < T < 825 ns\n");
107       }
108     }
109   }
110
111   // Energy cuts
112   params->SetClusteringThreshold(minEseed/1.e3);                                          
113   params->SetMinECut            (minEcell/1.e3); 
114
115   // Clusterizer type
116   if(name.Contains("V2")) params->SetClusterizerFlag(AliEMCALRecParam::kClusterizerv2);
117   if(name.Contains("V1")) params->SetClusterizerFlag(AliEMCALRecParam::kClusterizerv1);
118   if(name.Contains("NxN"))
119   {
120     params->SetClusterizerFlag(AliEMCALRecParam::kClusterizerNxN);
121     printf("Set NxN cluster size to %dx%d (row diff %d, col diff %d)\n",2*nRowDiff+1,2*nColDiff+1,nRowDiff,nColDiff);
122     params->SetNxM(nRowDiff, nColDiff);
123   }
124
125   //-------------------------------------------------------
126   // Unfolding, 2 options :
127   //-------------------------------------------------------
128
129   //    1) Just unfold existing clusters
130   if(name.Contains("JustUnfold"))
131     clusterize->JustUnfold(kTRUE); // if TRUE, do just unfolding, do not recluster cells
132   else  
133     clusterize->JustUnfold(kFALSE); 
134
135   //   2) Unfold clusters created in the clusterize (revise settings)
136   if (name.Contains("Unfold"))
137   {
138     clusterize->SwitchOnCellEnergySelection();
139     clusterize->SetCellCuts(minEUnf/1000.,minFrac/10000.);
140     printf("AliAnalysisTaskEMCALClusterize - Cuts: min E %f, frac %f\n",minEUnf/1000.,minFrac/10000.);
141     //clusterize->SwitchOffCellEnergySelection(); 
142     
143     if(!name.Contains("Just"))
144       params->SetUnfold(kTRUE);
145     else 
146       params->SetUnfold(kFALSE);
147     
148   } // unfold
149   
150   //-------------------------------------------------------
151   // Configure AliEMCALRecoUtils
152   //-------------------------------------------------------
153
154   AliEMCALRecoUtils * reco = clusterize->GetRecoUtils();
155   gROOT->LoadMacro("$ALICE_ROOT/PWGGA/EMCALTasks/macros/ConfigureEMCALRecoUtils.C"); // $ALICE_ROOT/PWGGA/EMCALTasks/macros
156   ConfigureEMCALRecoUtils(reco,bMC,exotic,bNonLine,bRecalE,bBad,bRecalT);
157   
158   //-------------------------------------------------------
159   //Alignment matrices
160   //-------------------------------------------------------
161
162   clusterize->SetImportGeometryFromFile(kTRUE); // import geometry.root file
163   
164   if(!bMC)
165   {    
166     clusterize->SwitchOnLoadOwnGeometryMatrices();
167   }
168   
169   //-------------------------------------------------------
170   // Trigger options
171   //-------------------------------------------------------
172
173   if(trigger=="EMC7")
174   {
175     printf("Clusterizing task trigger EMC7\n");
176     clusterize->SelectCollisionCandidates(AliVEvent::kEMC7);
177   }
178   else if (trigger=="INT7")
179   {
180     printf("Clusterizing task trigger INT7\n");
181     clusterize->SelectCollisionCandidates(AliVEvent::kINT7);
182   }
183   else if(trigger=="EMC1")
184   {
185     printf("Clusterizing task trigger EMC1\n");
186     clusterize->SelectCollisionCandidates(AliVEvent::kEMC1);
187   }
188   else if(trigger=="MB")
189   {
190     printf("Clusterizing task trigger MB\n");
191     clusterize->SelectCollisionCandidates(AliVEvent::kMB);
192   }  
193   else if(trigger=="PHOS")
194   {
195     printf("Clusterizing task trigger PHOS\n");
196     clusterize->SelectCollisionCandidates(AliVEvent::kPHI7);
197   }  
198   else if(trigger=="PHOSPb")
199   {
200     printf("Clusterizing task trigger PHOSPb\n");
201     clusterize->SelectCollisionCandidates(AliVEvent::kPHOSPb);
202   }
203   else if(trigger=="AnyINT")
204   {
205     printf("Clusterizing task trigger AnyINT\n");
206     clusterize->SelectCollisionCandidates(AliVEvent::kAnyINT);
207   }  
208   else if(trigger=="INT")
209   {
210     printf("Clusterizing task trigger AnyINT\n");
211     clusterize->SelectCollisionCandidates(AliVEvent::kAny);
212   }
213   else if(trigger=="EMCEGA")
214   {
215     printf("Clusterizing task trigger EMC Gamma\n");
216     clusterize->SelectCollisionCandidates(AliVEvent::kEMCEGA);
217   } 
218   else if(trigger=="EMCEJE")
219   {
220     printf("Clusterizing task trigger EMC Jet\n");
221     clusterize->SelectCollisionCandidates(AliVEvent::kEMCEJE);
222   }
223   else if(trigger=="Central")
224   {
225     printf("Clusterizing task trigger Central\n");
226     clusterize->SelectCollisionCandidates(AliVEvent::kCentral);
227   } 
228   else if(trigger=="SemiCentral")
229   {
230     printf("Clusterizing task trigger SemiCentral\n");
231     clusterize->SelectCollisionCandidates(AliVEvent::kSemiCentral);
232   }
233   
234   // Set clusters branch name, make sure the analysis after this one reads this name
235   
236   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);
237   else                     arrayName = Form(   "%s_Ecell%d_Eseed%d_DT%d_WT%d",              name.Data(),minEcell,minEseed,maxDeltaT,timeWindow);
238   
239   clusterize->SetAODBranchName(arrayName);
240   
241   printf("Created Branch Name: \n",arrayName.Data());
242   
243   //-------------------------------------------------------
244   // Final settings, pass to manager and set the containers
245   //-------------------------------------------------------
246
247   mgr->AddTask(clusterize);
248   
249   // Create containers for input/output
250   AliAnalysisDataContainer *cinput1  = mgr->GetCommonInputContainer()  ;
251   mgr->ConnectInput  (clusterize, 0,  cinput1 );
252   
253   if(bFillAOD)  
254   {
255     printf("AddTaskEMCALClusterize - Fill output AOD\n");
256     AliAnalysisDataContainer *coutput1 = mgr->GetCommonOutputContainer() ;
257     mgr->ConnectOutput (clusterize, 0, coutput1 );
258   }
259   return clusterize;
260 }