implement integrated flow in scalar product method and subevents in flowevent
[u/mrichter/AliRoot.git] / TPC / AliTPCcalibBase.cxx
CommitLineData
3ab35fc5 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// Base class for the calibration components using
20// as input TPCseeds and ESDs
21// Event loop outside of the component
22//
23//
ae28e92e 24// Base functionality to be implemeneted by component
25/*
26 //In some cases only one of this function to be implemented
27 virtual void Process(AliESDEvent *event)
28 virtual void Process(AliTPCseed *track)
29 //
30 virtual Long64_t Merge(TCollection *li);
31 virtual void Analyze()
32 void Terminate();
33*/
34// Functionality provided by base class for Algorith debuging:
35// TTreeSRedirector * cstream = GetDebugStreamer() - get debug streamer which can be use for numerical debugging
36//
37
38
39
40// marian.ivanov@cern.ch
3ab35fc5 41//
42#include "AliTPCcalibBase.h"
f7f33dec 43#include "TSystem.h"
44#include "TFile.h"
ae28e92e 45#include "TTreeStream.h"
f7f33dec 46#include "AliLog.h"
47328338 47#include "TTimeStamp.h"
108953e9 48#include "AliESDEvent.h"
f7f33dec 49
3ab35fc5 50
51ClassImp(AliTPCcalibBase)
52
ae28e92e 53AliTPCcalibBase::AliTPCcalibBase():
54 TNamed(),
55 fDebugStreamer(0),
108953e9 56 fStreamLevel(0),
57 fRun(0), //! current Run number
58 fEvent(0), //! current Event number
59 fTime(0), //! current Time
60 fTrigger(0), //! current trigger type
61 fMagF(0), //! current magnetic field
c51653e8 62 fTriggerMaskReject(-1), //trigger mask - reject trigger
63 fTriggerMaskAccept(-1), //trigger mask - accept trigger
2d22fa36 64 fHasLaser(kFALSE), //flag the laser is overlayed with given event
65 fRejectLaser(kTRUE), //flag- reject laser
ae28e92e 66 fDebugLevel(0)
3ab35fc5 67{
68 //
69 // Constructor
70 //
71}
72
8cf12c96 73AliTPCcalibBase::AliTPCcalibBase(const char * name, const char * title):
74 TNamed(name,title),
75 fDebugStreamer(0),
76 fStreamLevel(0),
77 fRun(0), //! current Run number
78 fEvent(0), //! current Event number
79 fTime(0), //! current Time
80 fTrigger(0), //! current trigger type
81 fMagF(0), //! current magnetic field
82 fTriggerMaskReject(-1), //trigger mask - reject trigger
83 fTriggerMaskAccept(-1), //trigger mask - accept trigger
84 fHasLaser(kFALSE), //flag the laser is overlayed with given event
85 fRejectLaser(kTRUE), //flag- reject laser
86 fDebugLevel(0)
87{
88 //
89 // Constructor
90 //
91}
92
ae28e92e 93AliTPCcalibBase::AliTPCcalibBase(const AliTPCcalibBase&calib):
94 TNamed(calib),
95 fDebugStreamer(0),
96 fStreamLevel(calib.fStreamLevel),
e5cbd73f 97 fRun(0), //! current Run number
98 fEvent(0), //! current Event number
99 fTime(0), //! current Time
100 fTrigger(0), //! current trigger type
101 fMagF(0), //! current magnetic field
c51653e8 102 fTriggerMaskReject(calib.fTriggerMaskReject), //trigger mask - reject trigger
103 fTriggerMaskAccept(calib.fTriggerMaskAccept), //trigger mask - accept trigger
2d22fa36 104 fHasLaser(calib.fHasLaser), //flag the laser is overlayed with given event
105 fRejectLaser(calib.fRejectLaser), //flag- reject laser
ae28e92e 106 fDebugLevel(calib.fDebugLevel)
107{
108 //
109 // copy constructor
110 //
111}
112
113AliTPCcalibBase &AliTPCcalibBase::operator=(const AliTPCcalibBase&calib){
114 //
115 //
116 //
117 ((TNamed *)this)->operator=(calib);
118 fDebugStreamer=0;
119 fStreamLevel=calib.fStreamLevel;
120 fDebugLevel=calib.fDebugLevel;
525062ee 121 return *this;
ae28e92e 122}
123
124
3ab35fc5 125AliTPCcalibBase::~AliTPCcalibBase() {
126 //
127 // destructor
128 //
f7f33dec 129 if (fDebugLevel>0) printf("AliTPCcalibBase::~AliTPCcalibBase\n");
ae28e92e 130 if (fDebugStreamer) delete fDebugStreamer;
131 fDebugStreamer=0;
132}
133
134void AliTPCcalibBase::Terminate(){
135 //
136 //
137 //
f7f33dec 138 if (fDebugLevel>0) printf("AliTPCcalibBase::Terminate\n");
ae28e92e 139 if (fDebugStreamer) delete fDebugStreamer;
140 fDebugStreamer = 0;
141 return;
142}
143
144TTreeSRedirector *AliTPCcalibBase::GetDebugStreamer(){
145 //
146 // Get Debug streamer
147 // In case debug streamer not yet initialized and StreamLevel>0 create new one
148 //
149 if (fStreamLevel==0) return 0;
150 if (fDebugStreamer) return fDebugStreamer;
151 TString dsName;
152 dsName=GetName();
153 dsName+="Debug.root";
154 dsName.ReplaceAll(" ","");
155 fDebugStreamer = new TTreeSRedirector(dsName.Data());
156 return fDebugStreamer;
3ab35fc5 157}
f7f33dec 158
159
108953e9 160void AliTPCcalibBase::UpdateEventInfo(AliESDEvent * event){
161 //
162 //
163 //
164 fRun = event->GetRunNumber();
165 fEvent = event->GetEventNumberInFile();
166 fTime = event->GetTimeStamp();
167 fTrigger = event->GetTriggerMask();
168 fMagF = event->GetMagneticField();
2d22fa36 169 fHasLaser = HasLaser(event);
108953e9 170}
171
2d22fa36 172
173Bool_t AliTPCcalibBase::HasLaser(AliESDEvent *event){
174 //
175 //
176 //
177 // Thresholds more than 8 tracks with small dip angle
178
179 const Int_t kMinLaserTracks = 8;
180 const Float_t kThrLaser = 0.3;
181 const Float_t kLaserTgl = 0.01;
182
183 Int_t ntracks = event->GetNumberOfTracks();
184 if (ntracks<kMinLaserTracks) return kFALSE;
185 Float_t nlaser=0;
186 Float_t nall=0;
187 for (Int_t i=0;i<ntracks;++i) {
188 AliESDtrack *track=event->GetTrack(i);
189 if (!track) continue;
190 if (track->GetTPCNcls()<=0) continue;
191 nall++;
192 if (TMath::Abs(track->GetTgl())<kLaserTgl) nlaser++;
193 }
194 if (nlaser>kMinLaserTracks) return kTRUE;
195 if (nall>0 && nlaser/nall>kThrLaser) return kTRUE;
196 return kFALSE;
197}
198
199
200
c51653e8 201Bool_t AliTPCcalibBase::AcceptTrigger(){
202 //
203 // Apply trigger mask - Don't do calibration for non proper triggers
204 //
2d22fa36 205 if (fTriggerMaskReject==(Int_t)fTrigger) return kFALSE;
206 if (fTriggerMaskAccept>0 && fTriggerMaskAccept!=(Int_t)fTrigger) return kFALSE;
207 if (fHasLaser && fRejectLaser) return kFALSE;
c51653e8 208 return kTRUE;
209}
210
211
f7f33dec 212void AliTPCcalibBase::RegisterDebugOutput(const char *path){
213 //
214 // store - copy debug output to the destination position
215 // currently ONLY for local copy
216 if (fDebugLevel>0) printf("AliTPCcalibBase::RegisterDebugOutput(%s)\n",path);
217 if (fStreamLevel==0) return;
218 TString dsName;
219 dsName=GetName();
220 dsName+="Debug.root";
221 dsName.ReplaceAll(" ","");
222 TString dsName2=path;
223 gSystem->MakeDirectory(dsName2.Data());
224 dsName2+=gSystem->HostName();
225 gSystem->MakeDirectory(dsName2.Data());
226 dsName2+="/";
47328338 227 TTimeStamp s;
228 dsName2+=Int_t(s.GetNanoSec());
229 dsName2+="/";
230 gSystem->MakeDirectory(dsName2.Data());
f7f33dec 231 dsName2+=dsName;
232 AliInfo(Form("copy %s\t%s\n",dsName.Data(),dsName2.Data()));
233 printf("copy %s\t%s\n",dsName.Data(),dsName2.Data());
234 TFile::Cp(dsName.Data(),dsName2.Data());
235}