1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
17 Comments to be written here:
18 1. What do we calibrate.
20 Time dependence of gain and drift velocity in order to account for changes in: temperature, pressure, gas composition.
22 AliTPCcalibTime *calibTime = new AliTPCcalibTime("cosmicTime","cosmicTime",0, 1213.9e+06, 1213.96e+06, 0.04e+04, 0.04e+04);
25 2. How to interpret results
28 a.) determine the required time range:
30 AliXRDPROOFtoolkit tool;
31 TChain * chain = tool.MakeChain("pass2.txt","esdTree",0,6000);
32 chain->Draw("GetTimeStamp()")
34 b) analyse calibration object on Proof in calibration train
36 AliTPCcalibTime *calibTime = new AliTPCcalibTime("cosmicTime","cosmicTime", StartTimeStamp, EndTimeStamp, IntegrationTimeVdrift, IntegrationTimeDeDx);
40 TFile f("CalibObjects.root");
41 AliTPCcalibTime *cal = (AliTPCcalibTime *)f->Get("TPCCalib")->FindObject("cosmicTime");
42 cal->GetHistVdrift()->Projection(1,0)->Draw()
44 4. Analysis using debug streamers.
46 gSystem->AddIncludePath("-I$ALICE_ROOT/TPC/macros");
47 gROOT->LoadMacro("$ALICE_ROOT/TPC/macros/AliXRDPROOFtoolkit.cxx+")
48 AliXRDPROOFtoolkit tool;
49 TChain * chainTime = tool.MakeChain("time.txt","timeInfo",0,10200);
56 #include "Riostream.h"
62 #include "THnSparse.h"
70 #include "TGraphErrors.h"
73 #include "AliTPCclusterMI.h"
74 #include "AliTPCseed.h"
75 #include "AliESDVertex.h"
76 #include "AliESDEvent.h"
77 #include "AliESDfriend.h"
78 #include "AliESDInputHandler.h"
79 #include "AliAnalysisManager.h"
81 #include "AliTracker.h"
82 #include "AliMagFMaps.h"
83 #include "AliTPCCalROC.h"
87 #include "AliTPCcalibTime.h"
89 #include "TTreeStream.h"
90 #include "AliTPCTracklet.h"
91 #include "TTimeStamp.h"
92 #include "AliTPCcalibDB.h"
93 #include "AliTPCcalibLaser.h"
95 ClassImp(AliTPCcalibTime)
98 AliTPCcalibTime::AliTPCcalibTime()
104 fIntegrationTimeDeDx(0),
105 fIntegrationTimeVdrift(0),
106 fLaser(0), // pointer to laser calibration
107 fDz(0), // current delta z
108 fdEdx(0), // current dEdx
109 fdEdxRatio(0), // current dEdx ratio
110 fTl(0), // current tan(lambda)
111 fCutMaxD(5), // maximal distance in rfi ditection
112 fCutMaxDz(20), // maximal distance in rfi ditection
113 fCutTheta(0.03), // maximal distan theta
114 fCutMinDir(-0.99) // direction vector products
117 AliInfo("Default Constructor");
121 AliTPCcalibTime::AliTPCcalibTime(const Text_t *name, const Text_t *title, ULong64_t TriggerMask, UInt_t StartTime, UInt_t EndTime, Int_t deltaIntegrationTimeDeDx, Int_t deltaIntegrationTimeVdrift)
127 fIntegrationTimeDeDx(0),
128 fIntegrationTimeVdrift(0),
129 fLaser(0), // pointer to laser calibration
130 fDz(0), // current delta z
131 fdEdx(0), // current dEdx
132 fdEdxRatio(0), // current dEdx ratio
133 fTl(0), // current tan(lambda)
134 fCutMaxD(5), // maximal distance in rfi ditection
135 fCutMaxDz(20), // maximal distance in rfi ditection
136 fCutTheta(0.03), // maximal distan theta
137 fCutMinDir(-0.99) // direction vector products
143 AliInfo("Non Default Constructor");
145 fTriggerMask = TriggerMask;
147 fIntegrationTimeDeDx = deltaIntegrationTimeDeDx;
148 fIntegrationTimeVdrift = deltaIntegrationTimeVdrift;
150 Double_t deltaTime = EndTime - StartTime;
152 Int_t binsVdrift[2] = {TMath::Nint(deltaTime/deltaIntegrationTimeVdrift), 100};
153 Double_t xminVdrift[2] = {StartTime, -20};
154 Double_t xmaxVdrift[2] = {EndTime, 20};
155 fHistVdrift = new THnSparseF("HistVdrift","vDrift; time;#Delta z",2,binsVdrift,xminVdrift,xmaxVdrift);
157 Int_t binsDeDxTgl[3] = {TMath::Nint(deltaTime/deltaIntegrationTimeDeDx),30,100};
158 Double_t xminDeDxTgl[3] = {StartTime,-1,0.7};
159 Double_t xmaxDeDxTgl[3] = {EndTime,1,1.3};
160 fHistDeDxTgl = new THnSparseF("HistDeDxTgl","dEdx vs tgl;time;tgl;dEdxUp/dEdxLow",3,binsDeDxTgl,xminDeDxTgl,xmaxDeDxTgl);
162 Int_t binsDeDx[2] = {TMath::Nint(deltaTime/deltaIntegrationTimeDeDx),100};
163 Double_t xminDeDx[2] = {StartTime,1};
164 Double_t xmaxDeDx[2] = {EndTime,100};
165 fHistDeDx = new THnSparseF("HistDeDx","dEdx l;time;dEdx",2,binsDeDx,xminDeDx,xmaxDeDx);
171 AliTPCcalibTime::~AliTPCcalibTime(){
176 void AliTPCcalibTime::ResetCurrent(){
178 // reset current values
180 fDz=0; // current delta z
181 fdEdx=0; // current dEdx
182 fdEdxRatio=0; // current dEdx ratio
183 fTl=0; // current tan(lambda)
188 void AliTPCcalibTime::Process(AliESDEvent *event) {
192 Int_t ntracks=event->GetNumberOfTracks();
193 if (ntracks<2) return;
196 ProcessCosmic(event);
198 if (!fLaser) fLaser = new AliTPCcalibLaser("laserTPC","laserTPC",kFALSE);
199 fLaser->Process(event);
202 // fill debug streamer
203 if (fStreamLevel>0 && fDz!=0){
204 TTreeSRedirector *cstream = GetDebugStreamer();
206 TTimeStamp tstamp(fTime);
207 Float_t valuePressure0 = AliTPCcalibDB::GetPressure(tstamp,fRun,0);
208 Float_t valuePressure1 = AliTPCcalibDB::GetPressure(tstamp,fRun,1);
209 Double_t ptrelative0 = AliTPCcalibDB::GetPTRelative(tstamp,fRun,0);
210 Double_t ptrelative1 = AliTPCcalibDB::GetPTRelative(tstamp,fRun,1);
211 Double_t temp0 = AliTPCcalibDB::GetTemperature(tstamp,fRun,0);
212 Double_t temp1 = AliTPCcalibDB::GetTemperature(tstamp,fRun,1);
213 TVectorD vdriftA, vdriftC,vdriftAC;
214 if (fLaser && fTrigger==16) {
215 if (fLaser->fFitAside) vdriftA=*(fLaser->fFitAside);
216 if (fLaser->fFitCside) vdriftC=*(fLaser->fFitCside);
217 if (fLaser->fFitACside) vdriftAC=*(fLaser->fFitACside);
219 (*cstream)<<"timeInfo"<<
220 "run="<<fRun<< // run number
221 "event="<<fEvent<< // event number
222 "time="<<fTime<< // time stamp of event
223 "trigger="<<fTrigger<< // trigger
224 "mag="<<fMagF<< // magnetic field
225 // Environment values
226 "press0="<<valuePressure0<<
227 "press1="<<valuePressure1<<
228 "pt0="<<ptrelative0<<
229 "pt1="<<ptrelative1<<
233 // accumulated values
235 "fDz="<<fDz<< //! current delta z
236 "fdEdx="<<fdEdx<< //! current dEdx
237 "fdEdxRatio="<<fdEdxRatio<< //! current dEdx ratio
238 "fTl="<<fTl<< //! current tan(lambda)
242 "laserA.="<<&vdriftA<<
243 "laserC.="<<&vdriftC<<
244 "laserAC.="<<&vdriftAC<<
252 void AliTPCcalibTime::ProcessCosmic(AliESDEvent *event) {
255 Printf("ERROR: ESD not available");
258 if (event->GetTimeStamp() == 0 ) {
259 Printf("no time stamp!");
263 if (fTriggerMask != 0 && event->GetTriggerMask() != fTriggerMask) return;
265 UInt_t time = event->GetTimeStamp();
270 // Track0 is choosen in upper TPC part
271 // Track1 is choosen in lower TPC part
273 Int_t ntracks=event->GetNumberOfTracks();
274 if (ntracks==0) return;
275 if (ntracks > 10) return; // temporary debug to remove LASER events
278 if (GetDebugLevel()>1) printf("Hallo world: Im here\n");
279 AliESDfriend *ESDfriend=static_cast<AliESDfriend*>(event->FindListObject("AliESDfriend"));
281 TObjArray tpcSeeds(ntracks);
282 Double_t vtxx[3]={0,0,0};
283 Double_t svtxx[3]={0.000001,0.000001,100.};
284 AliESDVertex vtx(vtxx,svtxx);
288 for (Int_t i=0;i<ntracks;++i) {
289 AliESDtrack *track = event->GetTrack(i);
291 const AliExternalTrackParam * trackIn = track->GetInnerParam();
292 const AliExternalTrackParam * trackOut = track->GetOuterParam();
293 if (!trackIn) continue;
294 if (!trackOut) continue;
296 AliESDfriendTrack *friendTrack = ESDfriend->GetTrack(i);
297 TObject *calibObject;
298 AliTPCseed *seed = 0;
299 for (Int_t l=0;(calibObject=friendTrack->GetCalibObject(l));++l) {
300 if ((seed=dynamic_cast<AliTPCseed*>(calibObject))) break;
303 tpcSeeds.AddAt(seed,i);
304 if (track->GetTPCNcls() > 50) {
305 Double_t meanP = 0.5*(trackIn->GetP() + trackOut->GetP());
306 Double_t TPCsignal = seed->CookdEdxNorm(0.0,0.6,1,0,159,0x0,kTRUE,kTRUE);
307 Double_t vecDeDx[2] = {time, TPCsignal};
310 fHistDeDx->Fill(vecDeDx);
316 if (ntracks<2) return;
320 for (Int_t i=0;i<ntracks;++i) {
321 AliESDtrack *track0 = event->GetTrack(i);
322 // track0 - choosen upper part
323 if (!track0) continue;
324 if (!track0->GetOuterParam()) continue;
325 if (track0->GetOuterParam()->GetAlpha()<0) continue;
327 track0->GetDirection(d1);
328 for (Int_t j=0;j<ntracks;++j) {
330 AliESDtrack *track1 = event->GetTrack(j);
332 if (!track1) continue;
333 if (!track1->GetOuterParam()) continue;
334 if (track1->GetOuterParam()->GetAlpha()>0) continue;
337 track1->GetDirection(d2);
339 AliTPCseed * seed0 = (AliTPCseed*) tpcSeeds.At(i);
340 AliTPCseed * seed1 = (AliTPCseed*) tpcSeeds.At(j);
341 if (! seed0) continue;
342 if (! seed1) continue;
343 Float_t dir = (d1[0]*d2[0] + d1[1]*d2[1] + d1[2]*d2[2]);
344 Float_t dist0 = track0->GetLinearD(0,0);
345 Float_t dist1 = track1->GetLinearD(0,0);
347 // conservative cuts - convergence to be guarantied
348 // applying before track propagation
349 if (TMath::Abs(dist0+dist1)>fCutMaxD) continue; // distance to the 0,0
350 if (dir>fCutMinDir) continue; // direction vector product
351 Float_t bz = AliTracker::GetBz();
352 Float_t dvertex0[2]; //distance to 0,0
353 Float_t dvertex1[2]; //distance to 0,0
354 track0->GetDZ(0,0,0,bz,dvertex0);
355 track1->GetDZ(0,0,0,bz,dvertex1);
356 if (TMath::Abs(dvertex0[1])>250) continue;
357 if (TMath::Abs(dvertex1[1])>250) continue;
361 Float_t dmax = TMath::Max(TMath::Abs(dist0),TMath::Abs(dist1));
362 AliExternalTrackParam param0(*track0);
363 AliExternalTrackParam param1(*track1);
365 // Propagate using Magnetic field and correct fo material budget
367 AliTracker::PropagateTrackTo(¶m0,dmax+1,0.0005,3,kTRUE);
368 AliTracker::PropagateTrackTo(¶m1,dmax+1,0.0005,3,kTRUE);
370 // Propagate rest to the 0,0 DCA - z should be ignored
373 param0.PropagateToDCA(&vtx,bz,1000);
375 param1.PropagateToDCA(&vtx,bz,1000);
377 param0.GetDZ(0,0,0,bz,dvertex0);
378 param1.GetDZ(0,0,0,bz,dvertex1);
380 Double_t xyz0[3];//,pxyz0[3];
381 Double_t xyz1[3];//,pxyz1[3];
384 Bool_t isPair = IsPair(¶m0,¶m1);
386 Double_t z0 = track0->GetOuterParam()->GetZ();
387 Double_t z1 = track1->GetOuterParam()->GetZ();
389 Double_t z0inner = track0->GetInnerParam()->GetZ();
390 Double_t z1inner = track1->GetInnerParam()->GetZ();
392 if (isPair && z0>0 && z0inner>0 && z1<0 && z1inner<0) {
393 Double_t vecVdrift[2] = {time, param0.GetZ() - param1.GetZ()};
395 if (track0->GetTPCNcls() > 80) {
396 fHistVdrift->Fill(vecVdrift);
397 fDz = param0.GetZ() - param1.GetZ();
400 if (isPair && z0 > 0 && z1 > 0) {
401 if (track1->GetTPCNcls()> 110 && track0->GetTPCNcls()> 110 && seed1->CookdEdxNorm(0,0.6,1,0,159,0,kFALSE,kTRUE) > 0) {
402 Float_t dedxratio = seed0->CookdEdxNorm(0,0.6,1,0,159,0,kFALSE,kTRUE)/seed1->CookdEdxNorm(0,0.6,1,0,159,0,kFALSE,kTRUE);
403 Double_t vecDeDxTgl[3] = {time, track0->GetTgl(), seed0->CookdEdxNorm(0,0.6,1,0,159,0,kFALSE,kTRUE)/seed1->CookdEdxNorm(0,0.6,1,0,159,0,kFALSE,kTRUE)};
404 fHistDeDxTgl->Fill(vecDeDxTgl);
405 fdEdxRatio = dedxratio;
406 fTl = track0->GetTgl() ;
410 } // end 2nd order loop
411 } // end 1st order loop
416 void AliTPCcalibTime::Analyze() {
420 TH2D * hVdrift = GetHistVdrift()->Projection(1,0);
425 Long64_t AliTPCcalibTime::Merge(TCollection *li) {
427 TIterator* iter = li->MakeIterator();
428 AliTPCcalibTime* cal = 0;
430 while ((cal = (AliTPCcalibTime*)iter->Next())) {
431 if (!cal->InheritsFrom(AliTPCcalibTime::Class())) {
432 Error("Merge","Attempt to add object of class %s to a %s", cal->ClassName(), this->ClassName());
436 // add histograms here...
437 fHistDeDxTgl->Add(cal->GetHistDeDxVsTgl());
438 fHistVdrift->Add(cal->GetHistVdrift());
439 fHistDeDx->Add(cal->GetHistDeDx());
449 Bool_t AliTPCcalibTime::IsPair(AliExternalTrackParam *tr0, AliExternalTrackParam *tr1){
453 // 0. Same direction - OPOSITE - cutDir +cutT
454 TCut cutDir("cutDir","dir<-0.99")
456 TCut cutT("cutT","abs(Tr1.fP[3]+Tr0.fP[3])<0.03")
459 TCut cutD("cutD","abs(Tr0.fP[0]+Tr1.fP[0])<5")
463 TCut cutPt("cutPt","abs(Tr1.fP[4]+Tr0.fP[4])<1&&abs(Tr0.fP[4])+abs(Tr1.fP[4])<10");
466 const Double_t *p0 = tr0->GetParameter();
467 const Double_t *p1 = tr1->GetParameter();
468 if (TMath::Abs(p0[3]+p1[3])>fCutTheta) return kFALSE;
469 if (TMath::Abs(p0[0]+p1[0])>fCutMaxD) return kFALSE;
470 if (TMath::Abs(p0[1]-p1[1])>fCutMaxDz) return kFALSE;
471 Double_t d0[3], d1[3];
472 tr0->GetDirection(d0);
473 tr1->GetDirection(d1);
474 if (d0[0]*d1[0] + d0[1]*d1[1] + d0[2]*d1[2] >fCutMinDir) return kFALSE;