]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGJE/EMCALJetTasks/macros/AddTaskEmcalJet.C
update from Salvatore, Ruediger for some bug fixes
[u/mrichter/AliRoot.git] / PWGJE / EMCALJetTasks / macros / AddTaskEmcalJet.C
1 // $Id$ 
2
3 AliEmcalJetTask* AddTaskEmcalJet(
4   const UInt_t type          = AliEmcalJetTask::kAKT | AliEmcalJetTask::kFullJet | AliEmcalJetTask::kR040Jet,
5   const char *nTracks        = "Tracks",
6   const char *nClusters      = "CaloClusters",
7   const Double_t minTrPt     = 0.15,
8   const Double_t minClPt     = 0.30,
9   const Double_t ghostArea   = 0.01,
10   const Double_t radius      = 0.4,
11   const char *tag            = "Jet"
12 )
13 {  
14   // Get the pointer to the existing analysis manager via the static access method.
15   //==============================================================================
16   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
17   if (!mgr)
18   {
19     ::Error("AddTaskAliEmcalJet", "No analysis manager to connect to.");
20     return NULL;
21   }  
22   
23   // Check the analysis type using the event handlers connected to the analysis manager.
24   //==============================================================================
25   if (!mgr->GetInputEventHandler())
26   {
27     ::Error("AddTaskAliEmcalJet", "This task requires an input event handler");
28     return NULL;
29   }
30   
31   //-------------------------------------------------------
32   // Init the task and do settings
33   //-------------------------------------------------------
34
35   Double_t minJetPt = 0;
36
37   char *algoString;
38   if ((type & AliEmcalJetTask::kKT) != 0) {
39     algoString = "KT";
40     minJetPt = 0.1;
41   } else if ((type & AliEmcalJetTask::kAKT) != 0) {
42     algoString = "AKT";
43     minJetPt = 1.0;
44   }
45
46   char *typeString;
47   if ((type & AliEmcalJetTask::kFullJet) != 0)
48     typeString = "Full";
49   else if ((type & AliEmcalJetTask::kChargedJet) != 0)
50     typeString = "Charged";
51   else if ((type & AliEmcalJetTask::kNeutralJet) != 0)
52     typeString = "Neutral";
53
54   char radiusString[200];
55   if ((type & AliEmcalJetTask::kR020Jet) != 0)
56     sprintf(radiusString,"R020");
57   else if ((type & AliEmcalJetTask::kR030Jet) != 0)
58     sprintf(radiusString,"R030");
59   else if ((type & AliEmcalJetTask::kR040Jet) != 0)
60     sprintf(radiusString,"R040");
61   else
62     sprintf(radiusString,"R0%2.0f",radius*100.0);
63
64   char pTString[200];
65   if (minTrPt==0)
66     sprintf(pTString,"pT0000");
67   else if (minTrPt<1.0)
68     sprintf(pTString,"pT0%3.0f",minTrPt*1000.0);
69   else if (minTrPt>=1.0)
70     sprintf(pTString,"pT%4.0f",minTrPt*1000.0);
71
72   char ETString[200];
73   if (minClPt==0)
74     sprintf(ETString,"ET0000");
75   else if (minClPt<1.0)
76     sprintf(ETString,"ET0%3.0f",minClPt*1000.0);
77   else if (minClPt>=1.0)
78     sprintf(ETString,"ET%4.0f",minClPt*1000.0);  
79
80   TString name;
81   if (*nTracks && *nClusters)
82     name = TString(Form("%s_%s%s%s_%s_%s_%s_%s",
83                         tag,algoString,typeString,radiusString,nTracks,pTString,nClusters,ETString));
84   else if (!*nClusters)
85     name = TString(Form("%s_%s%s%s_%s_%s",
86                         tag,algoString,typeString,radiusString,nTracks,pTString));
87   else if (!*nTracks)
88     name = TString(Form("%s_%s%s%s_%s_%s",
89                         tag,algoString,typeString,radiusString,nClusters,ETString));
90  
91   AliEmcalJetTask* mgrTask = mgr->GetTask(name.Data());
92   if (mgrTask)
93     return mgrTask;  
94
95   AliEmcalJetTask* jetTask = new AliEmcalJetTask(name);
96   jetTask->SetTracksName(nTracks);
97   jetTask->SetClusName(nClusters);
98   jetTask->SetJetsName(name);
99   jetTask->SetJetType(type);
100   jetTask->SetMinJetTrackPt(minTrPt);
101   jetTask->SetMinJetClusPt(minClPt);
102   jetTask->SetMinJetPt(minJetPt);
103   if ((type & (AliEmcalJetTask::kRX1Jet|AliEmcalJetTask::kRX2Jet|AliEmcalJetTask::kRX3Jet)) != 0)
104     jetTask->SetRadius(radius);
105   jetTask->SetGhostArea(ghostArea);
106
107   //-------------------------------------------------------
108   // Final settings, pass to manager and set the containers
109   //-------------------------------------------------------
110
111   mgr->AddTask(jetTask);
112   
113   // Create containers for input/output
114   AliAnalysisDataContainer *cinput  = mgr->GetCommonInputContainer()  ;
115   mgr->ConnectInput  (jetTask, 0, cinput);
116
117   return jetTask;
118 }
119
120
121 AliEmcalJetTask* AddTaskEmcalJet(
122   const char *nTracks        = "Tracks",
123   const char *nClusters      = "CaloClusters",
124   const Int_t algo           = 1,
125   const Double_t radius      = 0.4,
126   const Int_t type           = 0,
127   const Double_t minTrPt     = 0.15,
128   const Double_t minClPt     = 0.30,
129   const Double_t ghostArea   = 0.01  ,
130   const char *tag            = "Jet"
131 )
132 {  
133   
134   UInt_t jetType = 0;
135
136   if (algo == 0) 
137     jetType |= AliEmcalJetTask::kKT; 
138   else 
139     jetType |= AliEmcalJetTask::kAKT;
140
141   if (type==0)
142     jetType |= AliEmcalJetTask::kFullJet; 
143   else if (type==1) 
144     jetType |= AliEmcalJetTask::kChargedJet; 
145   else if (type==2) 
146     jetType |= AliEmcalJetTask::kNeutralJet;
147
148   if (radius==0.2) 
149     jetType |= AliEmcalJetTask::kR020Jet; 
150   else if (radius==0.3) 
151     jetType |= AliEmcalJetTask::kR030Jet;
152   else if (radius==0.4) 
153     jetType |= AliEmcalJetTask::kR040Jet;
154   else
155     jetType |= AliEmcalJetTask::kRX1Jet;
156
157   return AddTaskEmcalJet(jetType, nTracks, nClusters, minTrPt, minClPt, ghostArea, radius, tag);
158 }