]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGPP/TRD/AliTRDalignmentTask.cxx
Changing output file name for LEGO trains.
[u/mrichter/AliRoot.git] / PWGPP / TRD / AliTRDalignmentTask.cxx
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-commercialf 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 // TRD alignment task
18 //
19 // Some documentation
20 //
21 // Authors :
22 //
23 ////////////////////////////////////////////////
24
25 #include "TTreeStream.h"
26 #include "TROOT.h"
27 #include "TH1.h"
28 #include "TH2.h"
29
30 #include "AliTrackPointArray.h"
31 #include "AliLog.h"
32
33 #include "AliTRDgeometry.h"
34 #include "AliTRDcluster.h"
35 #include "AliTRDseedV1.h"
36 #include "AliTRDtrackV1.h"
37
38 #include "AliTRDalignmentTask.h"
39
40 ClassImp(AliTRDalignmentTask)
41
42 //________________________________________________________
43 AliTRDalignmentTask::AliTRDalignmentTask()
44   :AliTRDrecoTask()
45   ,fTree(0x0)
46   ,fArray(0x0)
47 {
48   InitFunctorList();
49 }
50
51 AliTRDalignmentTask::AliTRDalignmentTask(char* name)
52   :AliTRDrecoTask(name, "TRD alignment")
53   ,fTree(0x0)
54   ,fArray(0x0)
55 {
56   InitFunctorList();
57   DefineOutput(2, TTree::Class());
58 }
59
60 //________________________________________________________
61 AliTRDalignmentTask::~AliTRDalignmentTask()
62 {
63   if (fArray) delete fArray;
64 }
65
66
67 //________________________________________________________
68 void AliTRDalignmentTask::UserCreateOutputObjects()
69 {
70   // spatial resolution
71
72   if(!HasFunctorList()) InitFunctorList();
73   OpenFile(2, "RECREATE");
74
75   fTree = new TTree("spTree", "Tree with track space point arrays");
76   fTree->Branch("SP","AliTrackPointArray", &fArray);
77 }
78
79
80 //________________________________________________________
81 void AliTRDalignmentTask::UserExec(Option_t *opt)
82 {
83 // Documentation to come
84
85   AliTRDrecoTask::UserExec(opt);
86   PostData(2, fTree);
87 }
88
89
90 //________________________________________________________
91 TH1* AliTRDalignmentTask::PlotTrackPoints(const AliTRDtrackV1 *track)
92 {
93 // Documentation to come 
94
95   if(track) fkTrack = track;
96   if(!fkTrack){
97     AliWarning("No Track defined.");
98     return 0x0;
99   }
100
101   if (fArray) delete fArray;
102   fArray = new AliTrackPointArray(fkTrack->GetNumberOfTracklets());
103
104   // Filling the track points array
105   Float_t x, y, z;
106   AliTrackPoint p; Int_t ip = 0;
107   AliTRDseedV1 *tracklet = 0x0;
108   for(Int_t il=0; il<AliTRDgeometry::kNlayer; il++){
109     if(!(tracklet = fkTrack->GetTracklet(il))) continue;
110     if(!tracklet->IsOK()) continue;
111     tracklet->Fit(kTRUE);
112
113     x = tracklet->GetX0();
114     y = tracklet->GetYfit(0)-tracklet->GetYfit(1)*(tracklet->GetX0()-x);
115     z = tracklet->GetZfit(0);
116     p.SetXYZ(x,y,z);
117     fArray->AddPoint(ip++, &p);
118   }
119   fTree->Fill();
120
121 /*  if(fDebugLevel>=1){
122     Float_t yt = fRim.GetYat(x[il]);
123     (*fDebugStream) << "TrkltResiduals"
124       << "layer="  << il
125       << "x="      <<x[il]
126       << "y="      <<y[il]
127       << "yt="     <<yt
128       << "dydx="   << dydx[il]
129       << "dy="     << dy
130       << "\n";
131   }*/
132   return 0x0;
133 }
134
135
136
137 //________________________________________________________
138 Bool_t AliTRDalignmentTask::IsIdenticalWithOneOf(AliTrackPoint * const p, AliTrackPointArray *parray, int nmax) {
139
140   // Is the point p identical with one of the points on the list parray?
141   // This is a fix for aliroot 4-16-Rev-01 (and before) writing some 
142   // spurious unitialized points. 
143  
144   for (int i=0; i<parray->GetNPoints() && i<nmax; i++) {
145     AliTrackPoint pa;
146     parray->GetPoint(pa,i);
147     //printf("comparing %7.3f with %7.3f\n",p->GetY(),pa.GetY());
148     if (p->GetResidual(pa,0)<1e-8) return kTRUE;
149     //printf("different\n");
150   }
151   return kFALSE;
152 }