]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TPC/AliTPCcalibTrigger.cxx
- data member was shadowed (fTree)
[u/mrichter/AliRoot.git] / TPC / AliTPCcalibTrigger.cxx
CommitLineData
c43e2d89 1
2/**************************************************************************
3 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * *
5 * Author: The ALICE Off-line Project. *
6 * Contributors are mentioned in the code where appropriate. *
7 * *
8 * Permission to use, copy, modify and distribute this software and its *
9 * documentation strictly for non-commercial purposes is hereby granted *
10 * without fee, provided that the above copyright notice appears in all *
11 * copies and that both the copyright notice and this permission notice *
12 * appear in the supporting documentation. The authors make no claims *
13 * about the suitability of this software for any purpose. It is *
14 * provided "as is" without express or implied warranty. *
15 **************************************************************************/
16
17/*
18 // Load libraries
19 gSystem->Load("libANALYSIS");
84a3f7f3 20 gSystem->Load("libTPCcalib");
21
22
23 .x ~/NimStyle.C
c43e2d89 24 gSystem->Load("libANALYSIS");
25 gSystem->Load("libTPCcalib");
26
27 TFile f("CalibObjects.root");
28 AliTPCcalibTrigger *calibTrigger = (AliTPCcalibTrigger *)f->Get("TPCCalib")->FindObject("calibTrigger");
29
30
84a3f7f3 31 gSystem->AddIncludePath("-I$ALICE_ROOT/TPC/macros");
32 gROOT->LoadMacro("$ALICE_ROOT/TPC/macros/AliXRDPROOFtoolkit.cxx+")
33 AliXRDPROOFtoolkit tool;
34 TChain * chainTrack = tool.MakeChain("trigger.txt","Track",0,10200);
35 chainTrack->Lookup();
36 TChain * chainEvent = tool.MakeChain("trigger.txt","Event",0,10200);
37 chainEvent->Lookup();
38
39
c43e2d89 40*/
41
42#include "Riostream.h"
43#include "TChain.h"
44#include "TTree.h"
45#include "TH1F.h"
46#include "TH2F.h"
47#include "TH3F.h"
48#include "THnSparse.h"
49#include "TList.h"
50#include "TMath.h"
51#include "TCanvas.h"
52#include "TFile.h"
53#include "TF1.h"
54#include "TVectorD.h"
55#include "TProfile.h"
56#include "TGraphErrors.h"
57#include "TCanvas.h"
58
59#include "AliTPCclusterMI.h"
60#include "AliTPCseed.h"
61#include "AliESDVertex.h"
62#include "AliESDEvent.h"
63#include "AliESDfriend.h"
64#include "AliESDInputHandler.h"
65#include "AliAnalysisManager.h"
66
67#include "AliTracker.h"
68#include "AliMagF.h"
69#include "AliTPCCalROC.h"
70
71#include "AliLog.h"
72
73#include "AliTPCcalibTrigger.h"
74
75#include "TTreeStream.h"
76#include "AliTPCTracklet.h"
77#include "TTimeStamp.h"
78#include "AliTPCcalibDB.h"
79#include "AliTPCcalibLaser.h"
80#include "AliDCSSensorArray.h"
81#include "AliDCSSensor.h"
82
83ClassImp(AliTPCcalibTrigger)
84
85AliTPCcalibTrigger::AliTPCcalibTrigger():
86 AliTPCcalibBase("calibTrigger","calibTrigger"),
87 fHisMap(0)
88{
89
90}
91
92AliTPCcalibTrigger::AliTPCcalibTrigger(const char * name, const char * title):
93 AliTPCcalibBase(name,title),
94 fHisMap(0)
95{
96 //
97 //
98 //
99 fHisMap = new TMap;
100}
101
102Long64_t AliTPCcalibTrigger::Merge(TCollection *li) {
103 //
104 // Merge histograms
105 //
106 TIterator* iter = li->MakeIterator();
107 AliTPCcalibTrigger* cal = 0;
108
109 while ((cal = (AliTPCcalibTrigger*)iter->Next())) {
110 if (!cal->InheritsFrom(AliTPCcalibTrigger::Class())) {
111 Error("Merge","Attempt to add object of class %s to a %s", cal->ClassName(), this->ClassName());
112 return -1;
113 }
114 TMap * addMap=(cal->fHisMap);
115 if(!addMap) return 0;
116 TIterator* iterator = addMap->MakeIterator();
117 iterator->Reset();
84a3f7f3 118 // TPair* addPair=0;
119 TObject *object=0;
120 //
121 while((object=iterator->Next())){
122 THnSparse* his1 = dynamic_cast<THnSparseF*>(cal->fHisMap->GetValue(object->GetName()));
123 if (!his1) continue;
124 his1->Print();
125 THnSparse* his0 = dynamic_cast<THnSparseF*>(fHisMap->GetValue(object->GetName()));
126
127 if(!his0){
128 his0=MakeHisto(object->GetName());
129 fHisMap->Add(new TObjString(object->GetName()),his0);
c43e2d89 130 }
84a3f7f3 131 his0->Add(his1);
c43e2d89 132 }
133 }
134 return 0;
135}
136
137
138
139void AliTPCcalibTrigger::Process(AliESDEvent *event){
140 //
141 //
142 //
143 if (!event) return;
144 const TString &trigger = event->GetFiredTriggerClasses();
84a3f7f3 145 TTreeSRedirector * cstream = GetDebugStreamer();
146 //
147 TObjString str(event->GetFiredTriggerClasses());
148 Bool_t hasPIXEL=HasPIXEL(&str);
c018bcd4 149 Int_t hasTRD=HasTRD(&str);
84a3f7f3 150 Bool_t hasTOF=HasTOF(&str);
151 Bool_t hasACORDE=HasACORDE(&str);
c43e2d89 152 //
153 if (!GetHisto(trigger.Data())){
154 AddHisto(trigger.Data(),MakeHisto(trigger.Data()));
155 }
156 if (!GetHisto("all")){
157 AddHisto("all",MakeHisto("all"));
158 }
159
160 THnSparse *histoAll = GetHisto("all");
161 THnSparse *histo = GetHisto(trigger.Data());
84a3f7f3 162 Double_t xcont[9]={0,0,0,0,0,0,0,0,0};
c43e2d89 163
164 Int_t ntracks = event->GetNumberOfTracks();
165 xcont[0] = ntracks;
84a3f7f3 166 xcont[8] = 1;
c43e2d89 167 //
168 // GetLongest track
169 //
170 AliESDtrack * longest=0;
171 Int_t nclmax=0;
172 for (Int_t itrack=0; itrack<ntracks; itrack++){
173 AliESDtrack *track=event->GetTrack(itrack);
174 if (!track) continue;
175 if (track->GetTPCNcls()<=nclmax) continue;
176 nclmax = track->GetTPCNcls();
177 longest= track;
178 }
84a3f7f3 179 xcont[1] =nclmax;
180 histoAll->Fill(xcont);
181 histo->Fill(xcont);
182 if (cstream) {
183 (*cstream) << "Event" <<
184 "run="<<fRun<<
185 "time="<<fTime<<
c9673074 186 "tname.="<<&str<<
84a3f7f3 187 "pixel="<<hasPIXEL<<
188 "trd="<<hasTRD<<
189 "tof="<<hasTOF<<
190 "acorde="<<hasACORDE<<
191 "ntracks="<<ntracks<<
192 "\n";
193 }
c43e2d89 194 //
84a3f7f3 195 xcont[8] = -1.;
196 for (Int_t itrack=0; itrack<ntracks; itrack++){
197 AliESDtrack *track=event->GetTrack(itrack);
198 if (!track) continue;
c43e2d89 199 Float_t dca[2];
200 Double_t pxyz[3];
84a3f7f3 201 track->GetDZ(0.,0.,0.,event->GetMagneticField(),dca);
202 Bool_t status = track->GetPxPyPz(pxyz);
203 Double_t alpha = TMath::ATan2(pxyz[1],pxyz[0]);
204 xcont[1]=track->GetTPCNcls();
c43e2d89 205 xcont[2]=dca[0];
206 xcont[3]=dca[1];
84a3f7f3 207 xcont[4]=alpha;
208 xcont[5]=track->GetParameter()[3];
209 xcont[6]=track->Pt();
210 xcont[7]=track->GetTPCsignal();
211 histoAll->Fill(xcont);
212 histo->Fill(xcont);
213 //
214 //
215 if (cstream) {
216 Double_t mpt = track->GetParameter()[4];
c9673074 217 Int_t kokot[1000];
218 Int_t nclITS=track->GetITSclusters(kokot);
219 Int_t nclTPC=track->GetTPCNcls();
220 Int_t nclTRD=track->GetTRDclusters(kokot);
c018bcd4 221 Int_t ntlTRD=track->GetTRDntracklets();
c9673074 222 ULong_t tstatus = track->GetStatus();
84a3f7f3 223 (*cstream) << "Track" <<
224 "run="<<fRun<<
225 "time="<<fTime<<
c9673074 226 "tname.="<<&str<<
227 "status="<<status<<
c018bcd4 228 "tstatus="<<tstatus<<
c9673074 229 //
84a3f7f3 230 "ntracks="<<ntracks<<
c9673074 231 "tstatus="<<status<<
232 "nclITS="<<nclITS<<
233 "nclTPC="<<nclTPC<<
234 "nclTRD="<<nclTRD<<
c018bcd4 235 "ntlTRD="<<ntlTRD<<
c9673074 236 //
84a3f7f3 237 "pixel="<<hasPIXEL<<
238 "trd="<<hasTRD<<
239 "tof="<<hasTOF<<
240 "acorde="<<hasACORDE<<
241 "ncl="<<xcont[1]<<
242 "dcaR="<<xcont[2]<<
243 "dcaZ="<<xcont[3]<<
244 "alpha="<<xcont[4]<<
245 "theta="<<xcont[5]<<
246 "pt="<<xcont[6]<<
247 "dEdx="<<xcont[7]<<
248 "mpt="<<mpt<<
249 "\n";
250 }
c43e2d89 251 }
c43e2d89 252}
253
254THnSparse *AliTPCcalibTrigger::MakeHisto(const char* trigger){
255 //
256 // Make event/track histograms
257 // trigger histo
258 //
84a3f7f3 259 // ntracks nclMax dcaR dcaZ alpha theta pt dEdx ev
260 Int_t bins[9] = {50, 40, 20, 20, 18, 25, 25, 25, 2 };
261 //Int_t bins[9] = {50* 20* 25* 25* 18* 25* 25* 25 };
262 Double_t xmin[9] = {0., 0, 0, -250, -3.14, -1.5, 0, 0, -1.};
263 Double_t xmax[9] = {50, 160, 150, 250, 3.14, 1.5, 100, 100, 1.};
264 TString axisName[9]={
c43e2d89 265 "ntracks",
84a3f7f3 266 "ncl",
c43e2d89 267 "dcaR",
268 "dcaZ",
269 "alpha",
270 "theta",
271 "pt",
84a3f7f3 272 "dEdx",
273 "ev"
c43e2d89 274 };
84a3f7f3 275 TString axisTitle[9]={
c43e2d89 276 "Number of tracks",
277 "N_{cl}",
278 "dca_{R} (cm)",
279 "dca_{z} (cm)",
280 "alpha (mrad)",
281 "theta",
282 "p_{t} (GeV/c)",
84a3f7f3 283 "dEdx (a.u.)",
284 "ev"
c43e2d89 285 };
286
287
84a3f7f3 288 THnSparse *sparse = new THnSparseF(Form("his_%s",trigger), Form("his_%s",trigger), 9, bins, xmin, xmax);
289 for (Int_t iaxis=0; iaxis<9; iaxis++){
c43e2d89 290 sparse->GetAxis(iaxis)->SetName(axisName[iaxis]);
291 sparse->GetAxis(iaxis)->SetTitle(axisTitle[iaxis]);
292 }
293 return sparse;
294}
295
296THnSparse * AliTPCcalibTrigger::GetHisto(const char *trigger) {
297 //
298 // return histogram for given class
299 if (!fHisMap) fHisMap=new TMap;
300 return (THnSparse*) fHisMap->GetValue(trigger);
301}
302
303void AliTPCcalibTrigger::AddHisto(const char *trigger, THnSparse *his) {
304 if (!GetHisto(trigger)) {
305 TObjString *pstr = new TObjString(trigger);
306 fHisMap->Add(pstr,his);
307 }
308}
84a3f7f3 309
310TTree * AliTPCcalibTrigger::MakeTree(const char * fname){
311 //
312 //
313 //
314 TTreeSRedirector * sred = new TTreeSRedirector(fname);
315 TTreeStream &pcstream = (*sred)<<"Trigger";
316 //
317 //
318 TIterator* iterator = fHisMap->MakeIterator();
319 TObject * object=0;
320 //
321 while((object=iterator->Next())){
322 MakeTree(pcstream, object->GetName());
323 }
324 delete sred;
325 TFile *f = new TFile(fname);
326 TTree *tree = (TTree*)f->Get("Trigger");
327 return tree;
328}
329
330
331void AliTPCcalibTrigger::MakeTree(TTreeStream &pcstream, const char *tname){
332 //
333 // TTreeSRedirector * sred = new TTreeSRedirector("trigger.root");
334 // TTreeStream &pcstream = (*sred)<<"Trigger";
335 //
336 //AliTPCcalibTrigger *calibTrigger = this;
337 Double_t value;
338 THnSparse * his = GetHisto(tname);
339 if (!his) return;
340 //
341 Int_t *bins = new Int_t[100];
342 Int_t ndim = his->GetNdimensions();
343 Double_t position[10];
344 //
345 TObjString str(tname);
346 Bool_t isAll = str.String().Contains("all");
347 Bool_t hasPIXEL=HasPIXEL(&str);
c018bcd4 348 Int_t hasTRD=HasTRD(&str);
84a3f7f3 349 Bool_t hasTOF=HasTOF(&str);
350 Bool_t hasACORDE=HasACORDE(&str);
351 for (Long64_t i = 0; i < his->GetNbins(); ++i) {
352 value = his->GetBinContent(i, bins);
353 pcstream<<"val="<<value;
354 pcstream<<"tname.="<<&str;
355 //
356 pcstream<<"all="<<isAll;
357 pcstream<<"pixel="<<hasPIXEL;
358 pcstream<<"trd="<<hasTRD;
359 pcstream<<"tof="<<hasTOF;
360 pcstream<<"acorde="<<hasACORDE;
361 //
362 for (Int_t idim = 0; idim < ndim; idim++) {
363 position[idim] = his->GetAxis(idim)->GetBinCenter(bins[idim]);
364 pcstream<<Form("%s=",his->GetAxis(idim)->GetName())<<position[idim];
365 }
366 pcstream<<"\n";
367 }
368}
369
370
371Bool_t AliTPCcalibTrigger::HasTOF(TObjString *tname){
372 //
373 Bool_t result = kFALSE;
374 result|=(tname->String().Contains("0OB")>0);
375 result|=(tname->String().Contains("0OC")>0);
376 return result;
377}
378
379Bool_t AliTPCcalibTrigger::HasACORDE(TObjString *tname){
380 Bool_t result = kFALSE;
381 result|=(tname->String().Contains("0ASL")>0);
382 result|=(tname->String().Contains("0AMU")>0);
383 result|=(tname->String().Contains("0ASC")>0);
384 return result;
385}
386
387Bool_t AliTPCcalibTrigger::HasPIXEL(TObjString *tname){
388 return (tname->String().Contains("0SCO")>0);
389}
390
c018bcd4 391Int_t AliTPCcalibTrigger::HasTRD(TObjString *tname){
392 //
393 // Returns a mask containing TRD trigger information
394 // 0: No TRD trigger fired
395 // 1: TRD L1 fired
396 // 2: TRD L0 (krypton trigger) fired
397 //
398 Int_t result = 0;
399 if(tname->String().Contains("TRD")) result = 1; // Normal TRD L1 name
400 if(tname->String().Contains("0HPT1")) result = 1; // Old TRD L1 name
401 if(tname->String().Contains("0HWU") && !tname->String().Contains("TRD")) result = 2; // pretrigger always input for L1
c9673074 402 return result;
84a3f7f3 403}
404