2 /**************************************************************************
3 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5 * Author: The ALICE Off-line Project. *
6 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
19 gSystem->Load("libANALYSIS");
20 gSystem->Load("libTPCcalib");
24 gSystem->Load("libANALYSIS");
25 gSystem->Load("libTPCcalib");
27 TFile f("CalibObjects.root");
28 AliTPCcalibTrigger *calibTrigger = (AliTPCcalibTrigger *)f->Get("TPCCalib")->FindObject("calibTrigger");
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);
36 TChain * chainEvent = tool.MakeChain("trigger.txt","Event",0,10200);
42 #include "Riostream.h"
48 #include "THnSparse.h"
56 #include "TGraphErrors.h"
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"
67 #include "AliTracker.h"
69 #include "AliTPCCalROC.h"
73 #include "AliTPCcalibTrigger.h"
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"
83 ClassImp(AliTPCcalibTrigger)
85 AliTPCcalibTrigger::AliTPCcalibTrigger():
86 AliTPCcalibBase("calibTrigger","calibTrigger"),
92 AliTPCcalibTrigger::AliTPCcalibTrigger(const char * name, const char * title):
93 AliTPCcalibBase(name,title),
102 AliTPCcalibTrigger::~AliTPCcalibTrigger(){
105 // class is owner of all histograms
107 if (!fHisMap) return;
108 fHisMap->SetOwner(kTRUE);
109 fHisMap->DeleteAll();
114 Long64_t AliTPCcalibTrigger::Merge(TCollection *li) {
118 TIterator* iter = li->MakeIterator();
119 AliTPCcalibTrigger* cal = 0;
121 while ((cal = (AliTPCcalibTrigger*)iter->Next())) {
122 if (!cal->InheritsFrom(AliTPCcalibTrigger::Class())) {
123 Error("Merge","Attempt to add object of class %s to a %s", cal->ClassName(), this->ClassName());
126 TMap * addMap=(cal->fHisMap);
127 if(!addMap) return 0;
128 TIterator* iterator = addMap->MakeIterator();
133 while((object=iterator->Next())){
134 THnSparse* his1 = dynamic_cast<THnSparseF*>(cal->fHisMap->GetValue(object->GetName()));
137 THnSparse* his0 = dynamic_cast<THnSparseF*>(fHisMap->GetValue(object->GetName()));
140 his0=MakeHisto(object->GetName());
141 fHisMap->Add(new TObjString(object->GetName()),his0);
151 void AliTPCcalibTrigger::Process(AliESDEvent *event){
156 const TString &trigger = event->GetFiredTriggerClasses();
157 TTreeSRedirector * cstream = GetDebugStreamer();
159 TObjString str(event->GetFiredTriggerClasses());
160 Bool_t hasPIXEL=HasPIXEL(&str);
161 Int_t hasTRD=HasTRD(&str);
162 Bool_t hasTOF=HasTOF(&str);
163 Bool_t hasACORDE=HasACORDE(&str);
165 if (!GetHisto(trigger.Data())){
166 AddHisto(trigger.Data(),MakeHisto(trigger.Data()));
168 if (!GetHisto("all")){
169 AddHisto("all",MakeHisto("all"));
172 THnSparse *histoAll = GetHisto("all");
173 THnSparse *histo = GetHisto(trigger.Data());
174 Double_t xcont[9]={0,0,0,0,0,0,0,0,0};
176 Int_t ntracks = event->GetNumberOfTracks();
182 AliESDtrack * longest=0;
184 for (Int_t itrack=0; itrack<ntracks; itrack++){
185 AliESDtrack *track=event->GetTrack(itrack);
186 if (!track) continue;
187 if (track->GetTPCNcls()<=nclmax) continue;
188 nclmax = track->GetTPCNcls();
192 histoAll->Fill(xcont);
195 (*cstream) << "Event" <<
202 "acorde="<<hasACORDE<<
203 "ntracks="<<ntracks<<
208 for (Int_t itrack=0; itrack<ntracks; itrack++){
209 AliESDtrack *track=event->GetTrack(itrack);
210 if (!track) continue;
213 track->GetDZ(0.,0.,0.,event->GetMagneticField(),dca);
214 Bool_t status = track->GetPxPyPz(pxyz);
215 Double_t alpha = TMath::ATan2(pxyz[1],pxyz[0]);
216 xcont[1]=track->GetTPCNcls();
220 xcont[5]=track->GetParameter()[3];
221 xcont[6]=track->Pt();
222 xcont[7]=track->GetTPCsignal();
223 histoAll->Fill(xcont);
228 Double_t mpt = track->GetParameter()[4];
230 Int_t nclITS=track->GetITSclusters(kokot);
231 Int_t nclTPC=track->GetTPCNcls();
232 Int_t nclTRD=track->GetTRDclusters(kokot);
233 Int_t ntlTRD=track->GetTRDntracklets();
234 ULong_t tstatus = track->GetStatus();
235 (*cstream) << "Track" <<
240 "tstatus="<<tstatus<<
242 "ntracks="<<ntracks<<
252 "acorde="<<hasACORDE<<
266 THnSparse *AliTPCcalibTrigger::MakeHisto(const char* trigger){
268 // Make event/track histograms
271 // ntracks nclMax dcaR dcaZ alpha theta pt dEdx ev
272 Int_t bins[9] = {50, 40, 20, 20, 18, 25, 25, 25, 2 };
273 //Int_t bins[9] = {50* 20* 25* 25* 18* 25* 25* 25 };
274 Double_t xmin[9] = {0., 0, 0, -250, -3.14, -1.5, 0, 0, -1.};
275 Double_t xmax[9] = {50, 160, 150, 250, 3.14, 1.5, 100, 100, 1.};
276 TString axisName[9]={
287 TString axisTitle[9]={
300 THnSparse *sparse = new THnSparseF(Form("his_%s",trigger), Form("his_%s",trigger), 9, bins, xmin, xmax);
301 for (Int_t iaxis=0; iaxis<9; iaxis++){
302 sparse->GetAxis(iaxis)->SetName(axisName[iaxis]);
303 sparse->GetAxis(iaxis)->SetTitle(axisTitle[iaxis]);
308 THnSparse * AliTPCcalibTrigger::GetHisto(const char *trigger) {
310 // return histogram for given class
311 if (!fHisMap) fHisMap=new TMap;
312 return (THnSparse*) fHisMap->GetValue(trigger);
315 void AliTPCcalibTrigger::AddHisto(const char *trigger, THnSparse *his) {
316 if (!GetHisto(trigger)) {
317 TObjString *pstr = new TObjString(trigger);
318 fHisMap->Add(pstr,his);
322 TTree * AliTPCcalibTrigger::MakeTree(const char * fname){
326 TTreeSRedirector * sred = new TTreeSRedirector(fname);
327 TTreeStream &pcstream = (*sred)<<"Trigger";
330 TIterator* iterator = fHisMap->MakeIterator();
333 while((object=iterator->Next())){
334 MakeTree(pcstream, object->GetName());
337 TFile *f = new TFile(fname);
338 TTree *tree = (TTree*)f->Get("Trigger");
343 void AliTPCcalibTrigger::MakeTree(TTreeStream &pcstream, const char *tname){
345 // TTreeSRedirector * sred = new TTreeSRedirector("trigger.root");
346 // TTreeStream &pcstream = (*sred)<<"Trigger";
348 //AliTPCcalibTrigger *calibTrigger = this;
350 THnSparse * his = GetHisto(tname);
353 Int_t *bins = new Int_t[100];
354 Int_t ndim = his->GetNdimensions();
355 Double_t position[10];
357 TObjString str(tname);
358 Bool_t isAll = str.String().Contains("all");
359 Bool_t hasPIXEL=HasPIXEL(&str);
360 Int_t hasTRD=HasTRD(&str);
361 Bool_t hasTOF=HasTOF(&str);
362 Bool_t hasACORDE=HasACORDE(&str);
363 for (Long64_t i = 0; i < his->GetNbins(); ++i) {
364 value = his->GetBinContent(i, bins);
365 pcstream<<"val="<<value;
366 pcstream<<"tname.="<<&str;
368 pcstream<<"all="<<isAll;
369 pcstream<<"pixel="<<hasPIXEL;
370 pcstream<<"trd="<<hasTRD;
371 pcstream<<"tof="<<hasTOF;
372 pcstream<<"acorde="<<hasACORDE;
374 for (Int_t idim = 0; idim < ndim; idim++) {
375 position[idim] = his->GetAxis(idim)->GetBinCenter(bins[idim]);
376 pcstream<<Form("%s=",his->GetAxis(idim)->GetName())<<position[idim];
383 Bool_t AliTPCcalibTrigger::HasTOF(TObjString *tname){
385 Bool_t result = kFALSE;
386 result|=(tname->String().Contains("0OB")>0);
387 result|=(tname->String().Contains("0OC")>0);
391 Bool_t AliTPCcalibTrigger::HasACORDE(TObjString *tname){
392 Bool_t result = kFALSE;
393 result|=(tname->String().Contains("0ASL")>0);
394 result|=(tname->String().Contains("0AMU")>0);
395 result|=(tname->String().Contains("0ASC")>0);
399 Bool_t AliTPCcalibTrigger::HasPIXEL(TObjString *tname){
400 return (tname->String().Contains("0SCO")>0);
403 Int_t AliTPCcalibTrigger::HasTRD(TObjString *tname){
405 // Returns a mask containing TRD trigger information
406 // 0: No TRD trigger fired
408 // 2: TRD L0 (krypton trigger) fired
411 if(tname->String().Contains("TRD")) result = 1; // Normal TRD L1 name
412 if(tname->String().Contains("0HPT1")) result = 1; // Old TRD L1 name
413 if(tname->String().Contains("0HWU") && !tname->String().Contains("TRD")) result = 2; // pretrigger always input for L1