Compatibility with the Root trunk
[u/mrichter/AliRoot.git] / PWGPP / TPC / AliAnalysisNoiseTPC.cxx
CommitLineData
36c8e4e6 1/**************************************************************************
2 * Copyright(c) 1998-1999, 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///////////////////////////////////////////////////////////////////////////
17// //
18// //
19// Class to test TPC warm-up LASER EVENTS rejection. //
20// //
21// Author: Alexander Kalweit (GSI) //
22// Modified: Jacek Otwinowski (GSI) //
23///////////////////////////////////////////////////////////////////////////
24
25#include "Riostream.h"
26#include "TChain.h"
27#include "TTree.h"
28#include "TH1F.h"
29#include "TH2F.h"
30#include "TH3F.h"
31#include "TList.h"
32#include "TMath.h"
33#include "TCanvas.h"
34#include "TObjArray.h"
35#include "TF1.h"
36#include "TFile.h"
37
38#include "AliAnalysisTaskSE.h"
39#include "AliAnalysisManager.h"
40
41#include "AliHeader.h"
42#include "AliGenPythiaEventHeader.h"
43#include "AliGenCocktailEventHeader.h"
44#include "AliPhysicsSelection.h"
45#include "AliTriggerAnalysis.h"
46
47#include "AliPID.h"
48#include "AliESDtrackCuts.h"
49#include "AliESDVertex.h"
50#include "AliESDEvent.h"
51#include "AliESDInputHandler.h"
52#include "AliESDtrack.h"
53#include "AliESDpid.h"
54
55#include "AliMCEventHandler.h"
56#include "AliMCEvent.h"
57#include "AliStack.h"
58#include "AliRecoParam.h"
59
60#include "AliLog.h"
61
62#include "AliAnalysisNoiseTPC.h"
63
64
c64cb1f6 65using std::cout;
66using std::endl;
67
36c8e4e6 68ClassImp(AliAnalysisNoiseTPC)
69
70//________________________________________________________________________
71AliAnalysisNoiseTPC::AliAnalysisNoiseTPC()
72: AliAnalysisTaskSE("TaskChargedHadron"), fESD(0), fListHist(0), fESDtrackCuts(0),
73 fHistNoiseTracks(0),fTimeBins(0),fTimeStart(0),fTimeEnd(0)
74{
75 // default Constructor
76}
77
78
79//________________________________________________________________________
80AliAnalysisNoiseTPC::AliAnalysisNoiseTPC(const char *name,UInt_t StartTime, UInt_t EndTime, Int_t deltaTime)
81 : AliAnalysisTaskSE(name), fESD(0), fListHist(0), fESDtrackCuts(0),
82 fHistNoiseTracks(0), fTimeBins(0), fTimeStart(StartTime), fTimeEnd(EndTime)
83{
84 //
85 // standard constructur which should be used
86 //
87 Printf("*** CONSTRUCTOR CALLED ****");
88 if(deltaTime)
89 {
90 fTimeBins = TMath::Nint((fTimeEnd-fTimeStart)/deltaTime);
91 printf("fTimeBins %d \n",fTimeBins);
92 } else {
93 printf("deltaTime is 0 \n");
94 }
95
96 // Output slot #0 writes into a TList container
97 DefineOutput(1, TList::Class());
98
99}
100
101
102
103
104//________________________________________________________________________
105void AliAnalysisNoiseTPC::UserCreateOutputObjects()
106{
107 // Create histograms
108 // Called once
109
110 fESDtrackCuts = new AliESDtrackCuts("AliESDtrackCuts","AliESDtrackCuts");
111 fESDtrackCuts->SetAcceptKinkDaughters(kFALSE);
112 fESDtrackCuts->SetMinNClustersTPC(80);
113 fESDtrackCuts->SetMaxChi2PerClusterTPC(2);
114 //
115 fESDtrackCuts->SetRequireTPCRefit(kTRUE);
116 fESDtrackCuts->SetRequireITSRefit(kFALSE);
117 fESDtrackCuts->SetEtaRange(-0.005,+0.005);
118 fESDtrackCuts->SetPtRange(10., 1e10);
119
120
121 fListHist = new TList();
122 fListHist->SetOwner(kTRUE);
123 //
124 /*
125 UInt_t StartTime = 1272672000; // 1st of May
126 UInt_t EndTime = 1288569600; // 1st of Nov
127 Double_t deltaTime = EndTime - StartTime;
128 Int_t timeBins = TMath::Nint(deltaTime/(15.*60)); // every 15min
129 */
130
131 // event number in file, # noise tracks, isSelectMB, isSelectWarm, has vtx., time
132 Int_t binsHistNoise[6] = { 20000, 100, 2, 2, 2, fTimeBins};
133 Double_t xminHistNoise[6] = { -0.5, -0.5, -0.5, -0.5,-0.5, fTimeStart};
134 Double_t xmaxHistNoise[6] = {19999.5, 99.5, 1.5, 1.5, 1.5, fTimeEnd};
135 fHistNoiseTracks = new THnSparseS("fHistNoiseTracks","noise tracks: ev in file, # noise tracks, isSelectMB, isSelectWarm, has vtx,time",6,binsHistNoise,xminHistNoise,xmaxHistNoise);
136 //
137 fListHist->Add(fHistNoiseTracks);
138 //
139
140 PostData(1, fListHist);
141}
142
143//________________________________________________________________________
144void AliAnalysisNoiseTPC::UserExec(Option_t *)
145{
146 //
147 // main event loop
148 //
149 AliLog::SetGlobalLogLevel(AliLog::kError);
150 //
151 // Check Monte Carlo information and other access first:
152 //
153 fESD = dynamic_cast<AliESDEvent*>( InputEvent() );
154 if (!fESD) {
155 //Printf("ERROR: fESD not available");
156 return;
157 }
158
159 if (!fESDtrackCuts) {
160 Printf("ERROR: fESDtrackCuts not available");
161 return;
162 }
163
164 //
165 // check if event is selected by physics selection class
166 //
167 AliPhysicsSelection *physicsSelection = NULL;
168 AliTriggerAnalysis* triggerAnalysis = NULL;
169
170 AliInputEventHandler* inputHandler = (AliInputEventHandler*) AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler();
171 if (!inputHandler)
172 {
173 Printf("ERROR: Could not receive input handler");
174 return;
175 }
176
177 Bool_t isSelectedMB = kFALSE;
178 // check MB
179 isSelectedMB = inputHandler->IsEventSelected() & AliVEvent::kMB;
180
181 // get physics selection
182 physicsSelection = static_cast<AliPhysicsSelection*> (inputHandler->GetEventSelection());
183 if(!physicsSelection) return;
184
185 // check Warm Up events
186 Bool_t isSelectedWarm = kFALSE;
187 triggerAnalysis = physicsSelection->GetTriggerAnalysis();
188 if(!triggerAnalysis) return;
189 isSelectedWarm = triggerAnalysis->IsOfflineTriggerFired(fESD, AliTriggerAnalysis::kTPCLaserWarmUp);
190
191 //
192 // monitor vertex position
193 //
194 const AliESDVertex *vertex = fESD->GetPrimaryVertexTracks();
195 if(vertex->GetNContributors()<1) {
196 // SPD vertex
197 vertex = fESD->GetPrimaryVertexSPD();
198 if(vertex->GetNContributors()<1) vertex = 0x0;
199 }
200
201 Int_t trackCounter = 0;
202 for (Int_t i=0; i<fESD->GetNumberOfTracks(); ++i)
203 {
204 AliESDtrack *track = fESD->GetTrack(i);
205 if (!track)
206 continue;
207
208 if (track->GetTPCNcls() < 30) continue;
209 //if (track->GetTPCchi2()/track->GetTPCNcls() > 0.3) continue;
210 if (TMath::Abs(track->Eta()) > 0.005) continue;
211 if (track->Pt() < 4) continue;
212 if (track->GetKinkIndex(0) > 0) continue;
213
214 UInt_t status = track->GetStatus();
cb474242 215 if ((status&AliESDtrack::kITSrefit)==AliESDtrack::kITSrefit) continue; // explicitly ask for tracks without ITS refit
216 if ((status&AliESDtrack::kTPCrefit)!=AliESDtrack::kTPCrefit) continue;
36c8e4e6 217
218 if (track->GetTPCsignal() > 10) continue; // explicitly ask for tracks without dE/dx
219
220 //if (TMath::Abs(track->GetZ()) < 50) continue;
221
222 trackCounter++;
223 }
224
225 /*
226 Float_t dca[2], cov[3];
227 // 1st track loop to determine multiplicities
228 for (Int_t i=0;i<fESD->GetNumberOfTracks();++i) {
229 AliESDtrack *track = fESD->GetTrack(i);
230 if (!track) continue;
231 if (fESDtrackCuts->AcceptTrack(track)) {
232 UInt_t status = track->GetStatus();
233 if ((status&AliESDtrack::kITSrefit)==1) continue; // explicitly ask for tracks without ITS refit
234 if (track->GetTPCsignal() > 30) continue; // explicitly ask for tracks without dE/dx
235 //if (track->GetTPCNcls() > 80) continue;
236 track->GetImpactParameters(dca, cov);
237 if (TMath::Abs(dca[0]) > 10) continue;
238 trackCounter++;
239 //
240 }
241 }
242 */
243
244 // run number, # noise tracks, isSelectedMB, isSelectedWarm, has vtx.
245 Bool_t hasVtx = vertex;
246 if (trackCounter > 98) trackCounter = 98;
247 //Double_t vecNoise[7] = {fESD->GetRunNumber(),fESD->GetEventNumberInFile(), trackCounter, isSelectedMB, isSelectedWarm, hasVtx, fESD->GetTimeStamp()};
248 Double_t vecNoise[6] = {fESD->GetEventNumberInFile(), trackCounter, isSelectedMB, isSelectedWarm, hasVtx, fESD->GetTimeStamp()};
249 fHistNoiseTracks->Fill(vecNoise);
250
251
252 if (trackCounter > 0) {
253 cout << "NOISE_EVENT_CATEGORY:"<<"\t"<<
254 AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()->GetTree()->GetCurrentFile()->GetName()<<"\t"<<
255 fESD->GetEventNumberInFile() << "\t" <<
256 fESD->GetTimeStamp() <<endl;
257 }
258
259 /*
260 if (trackCounter > -1) {
261 fHistNoiseTracks->Fill(vecNoise);
262 if (trackCounter > 25 && trackCounter < 90 && fESD->GetEventSpecie() != AliRecoParam::kCalib) { // dump all availbale info for these events
263 cout << "NOISE_EVENT_CATEGORY:"<<"\t"<<
264 AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()->GetTree()->GetCurrentFile()->GetName()<<"\t"<<
265 fESD->GetEventNumberInFile() << "\t" <<
266 fESD->GetTimeStamp() <<endl;
267 for (Int_t i=0;i<fESD->GetNumberOfTracks();++i) {
268 AliESDtrack *track = fESD->GetTrack(i);
269 if (fESDtrackCuts->AcceptTrack(track)) cout << "NOISE_TRACK:"<<"\t"<<
270 track->GetTPCNcls() <<"\t"<<
271 track->GetTPCsignal() <<"\t"<<
272 track->GetAlpha() <<"\t"<<
273 track->Pt() <<"\t"<<
274 track->GetZ() <<"\t"<<
275 track->Eta() << endl;
276 }
277 }
278 if (fESD->GetEventSpecie() == AliRecoParam::kCalib) {
279 cout << "LASER_EVENT_CATEGORY:"<<"\t"<<
280 AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()->GetTree()->GetCurrentFile()->GetName()<<"\t"<<
281 fESD->GetEventNumberInFile() << "\t" <<
282 fESD->GetTimeStamp() <<endl;
283 }
284
285 }
286 */
287
288 // Post output data
289 PostData(1, fListHist);
290
291}
292
293//________________________________________________________________________
294void AliAnalysisNoiseTPC::Terminate(Option_t *)
295{
296 // Draw result to the screen
297 // Called once at the end of the query
298 Printf("*** CONSTRUCTOR CALLED ****");
299
300}
301
302