AliPhysics  29d4213 (29d4213)
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros
AliAnalysisTaskSEMonitNorm.cxx
Go to the documentation of this file.
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 
16 /* $Id$ */
17 
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"
43 
44 
48 
49 //________________________________________________________________________
51  AliAnalysisTaskSE(name),
52  fESD(0),
53  fOutput(0),
54  fCounterTrigg(0),
55  fCounterNotTrigg(0),
56  fCounterCandleTrig(0),
57  fCounterCandleNotTrig(0)
58 
59 {
60  // Constructor
61 
62  // Define input and output slots here
63  // Output slot #0 writes into a TList container
64  DefineOutput(1, TList::Class()); //My private output
65  DefineOutput(2, AliCounterCollection::Class());
66  DefineOutput(3, AliCounterCollection::Class());
67  DefineOutput(4, AliCounterCollection::Class());
68  DefineOutput(5, AliCounterCollection::Class());
69 
70 }
71 //________________________________________________________________________
73 {
74  // Destructor
75 
76  // histograms are in the output list and deleted when the output
77  // list is deleted by the TSelector dtor
78 
79  if (fOutput) {
80  delete fOutput;
81  fOutput = 0;
82  }
83 
84  if (fCounterTrigg) {
85  delete fCounterTrigg;
86  fCounterTrigg = 0;
87  }
88 
89  if (fCounterNotTrigg) {
90  delete fCounterNotTrigg;
91  fCounterNotTrigg = 0;
92  }
93 
94  if (fCounterCandleTrig) {
95  delete fCounterCandleTrig;
97  }
98 
100  delete fCounterCandleNotTrig;
102 
103  }
104 
105 
106 }
107 
108 
109 //________________________________________________________________________
111 {
112  // Create histograms
113  // Called once
114 
115  // Several histograms are more conveniently managed in a TList
116  fOutput = new TList;
117  fOutput->SetOwner();
118 
119 
120  //Counter for Normalization new line
121  fCounterTrigg = new AliCounterCollection("Triggered_Counter");//new line
122  fCounterTrigg->AddRubric("Event", "triggered/v0andONLINE/v0andOFFLINE/v0andOFF&ON/v0andON_notOFF/v0andOFF_notON/v0orOFF/V0orON");//new line
123  fCounterTrigg->AddRubric("Run", 10000000);//new line
124  fCounterTrigg->Init();//new line
125 
126  fCounterNotTrigg = new AliCounterCollection("NotTriggered_Counter");//new line
127  fCounterNotTrigg->AddRubric("Event", "!triggered/v0andONLINE/v0andOFFLINE/v0andOFF&ON/v0andON_notOFF/v0andOFF_notON/v0orOFF/v0orON");//new line
128  fCounterNotTrigg->AddRubric("Run", 10000000);//new line
129  fCounterNotTrigg->Init();//new line
130 
131  fCounterCandleTrig = new AliCounterCollection("Candle_Triggered_Counter");//new line
132  fCounterCandleTrig->AddRubric("Event", "triggered/candles02/2xcandles02/primVtx/TPConly");//new line
133  fCounterCandleTrig->AddRubric("Run", 10000000);//new line
134  fCounterCandleTrig->Init();//new line
135 
136 
137  fCounterCandleNotTrig = new AliCounterCollection("Candle_NotTriggered_Counter");//new line
138  fCounterCandleNotTrig->AddRubric("Event", "!triggered/candles02/2xcandles02/primVtx/TPConly");//new line
139  fCounterCandleNotTrig->AddRubric("Run", 10000000);//new line
140  fCounterCandleNotTrig->Init();//new line
141 
142 
143  PostData(1, fOutput);
144  PostData(2, fCounterTrigg);
145  PostData(3, fCounterNotTrigg);
146  PostData(4, fCounterCandleTrig);
147  PostData(5, fCounterCandleNotTrig);
148  return;
149 }
150 
151 //________________________________________________________________________
153 {
154  // Main loop
155  // Called for each event
156 
157  if (!InputEvent()) {
158  Printf("ERROR: fESD not available");
159  return;
160  }
161  AliESDEvent* esdE = (AliESDEvent*) InputEvent();
162  if (!esdE) {
163  Printf("ERROR: fESD not available");
164  return;
165  }
166 
167  // Select PHYSICS events (type=7, for data) and MC events (type=0)
168  // fCheckEventType is kFALSE if fReadMC is kTRUE, hence check is skipped
169  if(esdE->GetEventType()!=7 ) return;
170 
171  Int_t runNumber = (Int_t)esdE->GetRunNumber();
172 
173  //static AliTriggerAnalysis* triggerAnalysis = new AliTriggerAnalysis();
174  Bool_t eventTriggered = 0;
175 
176  Bool_t flag02 = kFALSE;
177  Bool_t flagPVT = kFALSE;
178  Bool_t flagTPCOnly70 = kFALSE;
179 
180  // use response of AliPhysicsSelection
181  eventTriggered = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected();
182 
183 
184  AliTriggerAnalysis *trigAnalys = new AliTriggerAnalysis();
185  Bool_t v0A;
186  Bool_t v0C;
187  Bool_t v0andOFF = kFALSE;
188  Bool_t v0orOFF = kFALSE;
189  if(esdE){
190  v0C = trigAnalys->IsOfflineTriggerFired(esdE , AliTriggerAnalysis::kV0C);
191  v0A = trigAnalys->IsOfflineTriggerFired(esdE , AliTriggerAnalysis::kV0A);
192  if(v0A&&v0C)v0andOFF=kTRUE;
193  if (v0A||v0C)v0orOFF=kTRUE;
194  }
195 
196  Int_t v0Con = trigAnalys->V0Trigger(esdE, AliTriggerAnalysis::kCSide, kTRUE, kFALSE);
197  Int_t v0Aon = trigAnalys->V0Trigger(esdE, AliTriggerAnalysis::kASide, kTRUE, kFALSE);
198 
199  Bool_t v0andON=kFALSE;
200  if((v0Aon==AliTriggerAnalysis::kV0BB)&&(v0Con==AliTriggerAnalysis::kV0BB))v0andON=kTRUE;
201 
202  Bool_t v0orON =((v0Aon==AliTriggerAnalysis::kV0BB)||(v0Con==AliTriggerAnalysis::kV0BB));
203 
204  Int_t trkEntries = (Int_t)esdE->GetNumberOfTracks();
205 
206  for(Int_t i=0;i<trkEntries;i++){
207  AliESDtrack *track=(AliESDtrack*)esdE->GetTrack(i);
208  UShort_t nClusTPC=track->GetTPCNcls();
209 
210  //TPConly
211  if((track->GetStatus()&AliESDtrack::kTPCin)&&TMath::Abs(track->Eta()<0.9)&&nClusTPC>=70){
212  if (!flagTPCOnly70){
213  flagTPCOnly70=kTRUE;
214  }
215  }
216 
217  //candles02
218  if((nClusTPC>=70)&&(track->GetStatus()&AliESDtrack::kITSrefit)&&(track->GetStatus()&AliESDtrack::kTPCrefit)){
219  if((track->Pt()>0.2)){
220  if(!flag02) flag02=kTRUE;
221  }
222  }
223  }
224 
225  //prim Vtx
226  if(esdE){
227  const AliESDVertex *vtrc1 = esdE->GetPrimaryVertex();
228  if(vtrc1 && vtrc1->GetNContributors()>0) flagPVT=kTRUE;
229  }
230 
231  if (eventTriggered){
232 
233  fCounterTrigg->Count(Form("Event:triggered/Run:%d", runNumber));
234  if (v0andON) fCounterTrigg->Count(Form("Event:v0andONLINE/Run:%d", runNumber));
235  if (v0andOFF) fCounterTrigg->Count(Form("Event:v0andOFFLINE/Run:%d", runNumber));
236  if (v0andON&&v0andOFF) fCounterTrigg->Count(Form("Event:v0andOFF&ON/Run:%d", runNumber));
237  if (v0andON&&!v0andOFF) fCounterTrigg->Count(Form("Event:v0andON_notOFF/Run:%d", runNumber));
238  if (!v0andON&&v0andOFF) fCounterTrigg->Count(Form("Event:v0andOFF_notON/Run:%d", runNumber));
239  if (v0orON) fCounterTrigg->Count(Form("Event:v0orON/Run:%d", runNumber));
240  if (v0orOFF) fCounterTrigg->Count(Form("Event:v0orOFF/Run:%d", runNumber));
241 
242  fCounterCandleTrig->Count(Form("Event:triggered/Run:%d", runNumber));
243  if (flagTPCOnly70) fCounterCandleTrig->Count(Form("Event:TPConly/Run:%d", runNumber));
244  if (flag02) fCounterCandleTrig->Count(Form("Event:candles02/Run:%d", runNumber));
245  if (flagPVT) fCounterCandleTrig->Count(Form("Event:primVtx/Run:%d", runNumber));
246 
247  }
248  else {
249  fCounterNotTrigg->Count(Form("Event:!triggered/Run:%d", runNumber));
250  if (v0andON) fCounterNotTrigg->Count(Form("Event:v0andONLINE/Run:%d", runNumber));
251  if (v0andOFF) fCounterNotTrigg->Count(Form("Event:v0andOFFLINE/Run:%d", runNumber));
252  if (v0andON&&v0andOFF) fCounterNotTrigg->Count(Form("Event:v0andOFF&ON/Run:%d", runNumber));
253  if (v0andON&&!v0andOFF) fCounterNotTrigg->Count(Form("Event:v0andON_notOFF/Run:%d", runNumber));
254  if (!v0andON&&v0andOFF) fCounterNotTrigg->Count(Form("Event:v0andOFF_notON/Run:%d", runNumber));
255  if (v0orON) fCounterNotTrigg->Count(Form("Event:v0orON/Run:%d", runNumber));
256  if (v0orOFF) fCounterNotTrigg->Count(Form("Event:v0orOFF/Run:%d", runNumber));
257 
258  fCounterCandleNotTrig->Count(Form("Event:!triggered/Run:%d", runNumber));
259  if (flagTPCOnly70) fCounterCandleNotTrig->Count(Form("Event:TPConly/Run:%d", runNumber));
260  if (flag02) fCounterCandleNotTrig->Count(Form("Event:candles02/Run:%d", runNumber));
261  if (flagPVT) fCounterCandleNotTrig->Count(Form("Event:primVtx/Run:%d", runNumber));
262 
263 
264  }
265 
266 
267  // Post the data already here
268  PostData(1, fOutput);
269  PostData(2, fCounterTrigg);
270  PostData(3, fCounterNotTrigg);
271  PostData(4, fCounterCandleTrig);
272  PostData(5, fCounterCandleNotTrig);
273 
274  return;
275 }
276 
277 //________________________________________________________________________
279 {
280  // Draw result to the screen
281  // Called once at the end of the query
282  fOutput = dynamic_cast<TList*> (GetOutputData(1));
283  if (!fOutput) {
284  Printf("ERROR: fOutput not available");
285  return;
286  }
287 
288  fCounterTrigg = dynamic_cast<AliCounterCollection*> (GetOutputData(2));
289  if (!fCounterTrigg) {
290  Printf("ERROR: fCounterTrigg not available");
291  return;
292  }
293 
294  fCounterNotTrigg = dynamic_cast<AliCounterCollection*> (GetOutputData(3));
295  if (!fCounterNotTrigg) {
296  Printf("ERROR: fCounterNotTrigg not available");
297  return;
298  }
299 
300  fCounterCandleTrig = dynamic_cast<AliCounterCollection*> (GetOutputData(4));
301  if (!fCounterCandleTrig) {
302  Printf("ERROR: fCounterCandleTrig not available");
303  return;
304  }
305 
306  fCounterCandleNotTrig = dynamic_cast<AliCounterCollection*> (GetOutputData(5));
307  if (!fCounterCandleNotTrig) {
308  Printf("ERROR: fCounterCandleNotTrig not available");
309  return;
310  }
311 
312  return;
313 }
314 
315 //_________________________________________________________________________
AliCounterCollection * fCounterNotTrigg
! counter for the differents not triggered events.
Class for monitoring of information used for open charm normalization (triggers, candles, ...)
ClassImp(AliAnalysisTaskTriggerRates) AliAnalysisTaskTriggerRates
AliCounterCollection * fCounterCandleNotTrig
! counter for candles in the triggered events (esd)
AliCounterCollection * fCounterTrigg
! counter for the differents triggered events.
virtual void UserExec(Option_t *option)
AliCounterCollection * fCounterCandleTrig
! counter for candles in the triggered events (esd)
AliAnalysisTaskSEMonitNorm(const char *name="AliAnalysisTaskSEMonitNorm")