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