Fix
[u/mrichter/AliRoot.git] / PWG3 / vertexingHF / AliAnalysisTaskSEMonitNorm.cxx
CommitLineData
013a4864 1/**************************************************************************
2 * Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
27de2dfb 16/* $Id$ */
17
013a4864 18//*************************************************************************
19//
20// Class for monitoring of information used for open charm normalization
21// (triggers, candles, ...)
22//
23// Origin: davide.caffarri@pd.infn.it
24//
25//*************************************************************************
26
27#include <TChain.h>
28#include <TTree.h>
29#include <TBranch.h>
30#include <TObjArray.h>
31#include <TH1F.h>
32#include <TH2F.h>
33#include <TCanvas.h>
34
35#include "AliAnalysisTask.h"
36#include "AliAnalysisManager.h"
37#include "AliESDEvent.h"
38#include "AliESDInputHandler.h"
39#include "AliTriggerAnalysis.h"
40#include "AliLog.h"
41#include "AliCounterCollection.h"
42#include "AliAnalysisTaskSEMonitNorm.h"
43
44ClassImp(AliAnalysisTaskSEMonitNorm)
45
46//________________________________________________________________________
47AliAnalysisTaskSEMonitNorm::AliAnalysisTaskSEMonitNorm(const char *name):
48 AliAnalysisTaskSE(name),
49 fESD(0),
50 fOutput(0),
51 fCounterTrigg(0),
52 fCounterNotTrigg(0),
53 fCounterCandleTrig(0),
54 fCounterCandleNotTrig(0)
55
56{
57 // Constructor
58
59 // Define input and output slots here
60 // Output slot #0 writes into a TList container
61 DefineOutput(1, TList::Class()); //My private output
62 DefineOutput(2, AliCounterCollection::Class());
63 DefineOutput(3, AliCounterCollection::Class());
64 DefineOutput(4, AliCounterCollection::Class());
65 DefineOutput(5, AliCounterCollection::Class());
66
67}
68//________________________________________________________________________
69AliAnalysisTaskSEMonitNorm::~AliAnalysisTaskSEMonitNorm()
70{
71 // Destructor
72
73 // histograms are in the output list and deleted when the output
74 // list is deleted by the TSelector dtor
75
76 if (fOutput) {
77 delete fOutput;
78 fOutput = 0;
79 }
80
81 if (fCounterTrigg) {
82 delete fCounterTrigg;
83 fCounterTrigg = 0;
84 }
85
86 if (fCounterNotTrigg) {
87 delete fCounterNotTrigg;
88 fCounterNotTrigg = 0;
89 }
90
91 if (fCounterCandleTrig) {
92 delete fCounterCandleTrig;
93 fCounterCandleTrig = 0;
94 }
95
96 if (fCounterCandleNotTrig) {
97 delete fCounterCandleNotTrig;
98 fCounterCandleNotTrig = 0;
99
100 }
101
102
103}
104
105
106//________________________________________________________________________
107void AliAnalysisTaskSEMonitNorm::UserCreateOutputObjects()
108{
109 // Create histograms
110 // Called once
111
112 // Several histograms are more conveniently managed in a TList
113 fOutput = new TList;
114 fOutput->SetOwner();
115
116
117 //Counter for Normalization new line
118 fCounterTrigg = new AliCounterCollection("Triggered_Counter");//new line
119 fCounterTrigg->AddRubric("Event", "triggered/v0andONLINE/v0andOFFLINE/v0andOFF&ON/v0andON_notOFF/v0andOFF_notON/v0orOFF/V0orON");//new line
120 fCounterTrigg->AddRubric("Run", 10000000);//new line
121 fCounterTrigg->Init();//new line
122
123 fCounterNotTrigg = new AliCounterCollection("NotTriggered_Counter");//new line
124 fCounterNotTrigg->AddRubric("Event", "!triggered/v0andONLINE/v0andOFFLINE/v0andOFF&ON/v0andON_notOFF/v0andOFF_notON/v0orOFF/v0orON");//new line
125 fCounterNotTrigg->AddRubric("Run", 10000000);//new line
126 fCounterNotTrigg->Init();//new line
127
128 fCounterCandleTrig = new AliCounterCollection("Candle_Triggered_Counter");//new line
129 fCounterCandleTrig->AddRubric("Event", "triggered/candles02/2xcandles02/primVtx/TPConly");//new line
130 fCounterCandleTrig->AddRubric("Run", 10000000);//new line
131 fCounterCandleTrig->Init();//new line
132
133
134 fCounterCandleNotTrig = new AliCounterCollection("Candle_NotTriggered_Counter");//new line
135 fCounterCandleNotTrig->AddRubric("Event", "!triggered/candles02/2xcandles02/primVtx/TPConly");//new line
136 fCounterCandleNotTrig->AddRubric("Run", 10000000);//new line
137 fCounterCandleNotTrig->Init();//new line
138
139
140 PostData(1, fOutput);
141 PostData(2, fCounterTrigg);
142 PostData(3, fCounterNotTrigg);
143 PostData(4, fCounterCandleTrig);
144 PostData(5, fCounterCandleNotTrig);
145 return;
146}
147
148//________________________________________________________________________
149void AliAnalysisTaskSEMonitNorm::UserExec(Option_t *)
150{
151 // Main loop
152 // Called for each event
153
154 if (!InputEvent()) {
155 Printf("ERROR: fESD not available");
156 return;
157 }
158 AliESDEvent* esdE = (AliESDEvent*) InputEvent();
dc222f77 159 if (!esdE) {
160 Printf("ERROR: fESD not available");
161 return;
162 }
163
013a4864 164 // Select PHYSICS events (type=7, for data) and MC events (type=0)
165 // fCheckEventType is kFALSE if fReadMC is kTRUE, hence check is skipped
166 if(esdE->GetEventType()!=7 ) return;
167
168 Int_t runNumber = (Int_t)esdE->GetRunNumber();
169
170 //static AliTriggerAnalysis* triggerAnalysis = new AliTriggerAnalysis();
171 Bool_t eventTriggered = 0;
172
173 Bool_t flag02 = kFALSE;
174 Bool_t flagPVT = kFALSE;
175 Bool_t flagTPCOnly70 = kFALSE;
176
177 // use response of AliPhysicsSelection
178 eventTriggered = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected();
179
180
181 AliTriggerAnalysis *trigAnalys = new AliTriggerAnalysis();
182 Bool_t v0A;
183 Bool_t v0C;
184 Bool_t v0andOFF = kFALSE;
185 Bool_t v0orOFF = kFALSE;
186 if(esdE){
187 v0C = trigAnalys->IsOfflineTriggerFired(esdE , AliTriggerAnalysis::kV0C);
188 v0A = trigAnalys->IsOfflineTriggerFired(esdE , AliTriggerAnalysis::kV0A);
189 if(v0A&&v0C)v0andOFF=kTRUE;
190 if (v0A||v0C)v0orOFF=kTRUE;
191 }
192
193 Int_t v0Con = trigAnalys->V0Trigger(esdE, AliTriggerAnalysis::kCSide, kTRUE, kFALSE);
194 Int_t v0Aon = trigAnalys->V0Trigger(esdE, AliTriggerAnalysis::kASide, kTRUE, kFALSE);
195
e11ae259 196 Bool_t v0andON=kFALSE;
013a4864 197 if((v0Aon==AliTriggerAnalysis::kV0BB)&&(v0Con==AliTriggerAnalysis::kV0BB))v0andON=kTRUE;
198
199 Bool_t v0orON =((v0Aon==AliTriggerAnalysis::kV0BB)||(v0Con==AliTriggerAnalysis::kV0BB));
200
201 Int_t trkEntries = (Int_t)esdE->GetNumberOfTracks();
202
203 for(Int_t i=0;i<trkEntries;i++){
204 AliESDtrack *track=(AliESDtrack*)esdE->GetTrack(i);
205 UShort_t nClusTPC=track->GetTPCNcls();
206
207 //TPConly
208 if((track->GetStatus()&AliESDtrack::kTPCin)&&TMath::Abs(track->Eta()<0.9)&&nClusTPC>=70){
209 if (!flagTPCOnly70){
210 flagTPCOnly70=kTRUE;
211 }
212 }
213
214 //candles02
215 if((nClusTPC>=70)&&(track->GetStatus()&AliESDtrack::kITSrefit)&&(track->GetStatus()&AliESDtrack::kTPCrefit)){
216 if((track->Pt()>0.2)){
217 if(!flag02) flag02=kTRUE;
218 }
219 }
220 }
221
222 //prim Vtx
223 if(esdE){
224 const AliESDVertex *vtrc1 = esdE->GetPrimaryVertex();
225 if(vtrc1 && vtrc1->GetNContributors()>0) flagPVT=kTRUE;
226 }
227
228 if (eventTriggered){
229
230 fCounterTrigg->Count(Form("Event:triggered/Run:%d", runNumber));
231 if (v0andON) fCounterTrigg->Count(Form("Event:v0andONLINE/Run:%d", runNumber));
232 if (v0andOFF) fCounterTrigg->Count(Form("Event:v0andOFFLINE/Run:%d", runNumber));
233 if (v0andON&&v0andOFF) fCounterTrigg->Count(Form("Event:v0andOFF&ON/Run:%d", runNumber));
234 if (v0andON&&!v0andOFF) fCounterTrigg->Count(Form("Event:v0andON_notOFF/Run:%d", runNumber));
235 if (!v0andON&&v0andOFF) fCounterTrigg->Count(Form("Event:v0andOFF_notON/Run:%d", runNumber));
236 if (v0orON) fCounterTrigg->Count(Form("Event:v0orON/Run:%d", runNumber));
237 if (v0orOFF) fCounterTrigg->Count(Form("Event:v0orOFF/Run:%d", runNumber));
238
239 fCounterCandleTrig->Count(Form("Event:triggered/Run:%d", runNumber));
240 if (flagTPCOnly70) fCounterCandleTrig->Count(Form("Event:TPConly/Run:%d", runNumber));
241 if (flag02) fCounterCandleTrig->Count(Form("Event:candles02/Run:%d", runNumber));
242 if (flagPVT) fCounterCandleTrig->Count(Form("Event:primVtx/Run:%d", runNumber));
243
244 }
245 else {
246 fCounterNotTrigg->Count(Form("Event:!triggered/Run:%d", runNumber));
247 if (v0andON) fCounterNotTrigg->Count(Form("Event:v0andONLINE/Run:%d", runNumber));
248 if (v0andOFF) fCounterNotTrigg->Count(Form("Event:v0andOFFLINE/Run:%d", runNumber));
249 if (v0andON&&v0andOFF) fCounterNotTrigg->Count(Form("Event:v0andOFF&ON/Run:%d", runNumber));
250 if (v0andON&&!v0andOFF) fCounterNotTrigg->Count(Form("Event:v0andON_notOFF/Run:%d", runNumber));
251 if (!v0andON&&v0andOFF) fCounterNotTrigg->Count(Form("Event:v0andOFF_notON/Run:%d", runNumber));
252 if (v0orON) fCounterNotTrigg->Count(Form("Event:v0orON/Run:%d", runNumber));
253 if (v0orOFF) fCounterNotTrigg->Count(Form("Event:v0orOFF/Run:%d", runNumber));
254
255 fCounterCandleNotTrig->Count(Form("Event:!triggered/Run:%d", runNumber));
256 if (flagTPCOnly70) fCounterCandleNotTrig->Count(Form("Event:TPConly/Run:%d", runNumber));
257 if (flag02) fCounterCandleNotTrig->Count(Form("Event:candles02/Run:%d", runNumber));
258 if (flagPVT) fCounterCandleNotTrig->Count(Form("Event:primVtx/Run:%d", runNumber));
259
260
261 }
262
263
264 // Post the data already here
265 PostData(1, fOutput);
266 PostData(2, fCounterTrigg);
267 PostData(3, fCounterNotTrigg);
268 PostData(4, fCounterCandleTrig);
269 PostData(5, fCounterCandleNotTrig);
270
271 return;
272}
273
274//________________________________________________________________________
275void AliAnalysisTaskSEMonitNorm::Terminate(Option_t *)
276{
277 // Draw result to the screen
278 // Called once at the end of the query
279 fOutput = dynamic_cast<TList*> (GetOutputData(1));
280 if (!fOutput) {
281 Printf("ERROR: fOutput not available");
282 return;
283 }
284
285 fCounterTrigg = dynamic_cast<AliCounterCollection*> (GetOutputData(2));
286 if (!fCounterTrigg) {
287 Printf("ERROR: fCounterTrigg not available");
288 return;
289 }
290
291 fCounterNotTrigg = dynamic_cast<AliCounterCollection*> (GetOutputData(3));
292 if (!fCounterNotTrigg) {
293 Printf("ERROR: fCounterNotTrigg not available");
294 return;
295 }
296
297 fCounterCandleTrig = dynamic_cast<AliCounterCollection*> (GetOutputData(4));
298 if (!fCounterCandleTrig) {
299 Printf("ERROR: fCounterCandleTrig not available");
300 return;
301 }
302
303 fCounterCandleNotTrig = dynamic_cast<AliCounterCollection*> (GetOutputData(5));
304 if (!fCounterCandleNotTrig) {
305 Printf("ERROR: fCounterCandleNotTrig not available");
306 return;
307 }
308
309 return;
310}
311
312//_________________________________________________________________________