more secure string operations
[u/mrichter/AliRoot.git] / TPC / AliTPCcalibAlignment.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-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 //     Class to make and monitor alignment of the TPC                        //
20 // 
21 //         
22
23
24 #include "AliTracker.h"
25 #include "AliTPCcalibAlignment.h"
26 #include "AliTPCseed.h"
27 #include "AliTPCclusterMI.h"
28 #include "AliTPCClusterParam.h"
29 #include "AliESDtrack.h"
30 #include "TTreeStream.h"
31 #include "AliTPCTracklet.h"
32
33 #include <iostream>
34 using namespace std;
35
36 /* TEST
37
38   gSystem->Load("$ALICE_ROOT/TPC/TPCcalib/libTPCcalib.so");
39
40   .L AliXRDPROOFtoolkit.cxx+
41   AliXRDPROOFtoolkit tool;
42   TChain * chain = tool.MakeChain("listcosmic.txt","esdTree",0,100,0)
43 //TChain * chain = tool.MakeChain("listpp.txt","esdTree",0,100,0)
44
45   AliTPCcalibTracks::AddInfo(chain,"TPCClusterParam.root");
46   AliTPCcalibTracks::AddCuts(chain,"LOWFLUX");
47
48 //  AliMagFMaps* field = new AliMagFMaps("Maps","Maps", 2, 0., 10., 2); // NO FIELD
49   AliMagFMaps* field = new AliMagFMaps("Maps","Maps", 2, 1., 10., 2); // FIELD
50 //  field->SetL3ConstField(0); //Using const. field in the barrel
51   AliTracker::SetFieldMap(field,kFALSE);
52
53    chain->SetBranchStatus("*",1);
54   chain->Process("$ALICE_ROOT/TPC/TPCcalib/AliTPCSelectorTracks.cxx+"); 
55
56   TFile f("AliTPCcalibAlignmentDebug.root")  
57   TTree *t=f.Get("Alignment")
58
59   t->Draw("tracklet1.fInner.GetY()-trackletR1.fInner.GetY()")
60   t->Draw("tracklet1.fInner.GetSnp()-tracklet1.fOuter.GetSnp()")
61   t->Draw("common1.GetSnp()-common2.GetSnp()")
62   t->Draw("common1.GetY()-common2.GetY()")
63   t->Draw("common1.GetZ()-common2.GetZ()")
64
65   t->Draw("track1.GetY()-track2.GetY()","abs(track1.GetY()-track2.GetY())<0.2")
66   t->Draw("track1.GetZ()-track2.GetZ()","abs(track1.GetZ()-track2.GetZ())<0.2")
67   t->Draw("track1.GetY()-track2.GetY():track1.GetZ()-track2.GetZ()","abs(track1.GetY()-track2.GetY())<0.2&&abs(track1.GetZ()-track2.GetZ())<0.2")
68
69
70  */
71
72 ClassImp(AliTPCcalibAlignment)
73
74 AliTPCcalibAlignment::AliTPCcalibAlignment():
75   fDebugStream(0)
76 {
77   //
78   // Constructor
79   //
80    fDebugStream=new TTreeSRedirector("AliTPCcalibAlignmentDebug.root");
81 }
82
83 AliTPCcalibAlignment::~AliTPCcalibAlignment() {
84   //
85   // Destructor
86   //
87   delete fDebugStream;
88 }
89
90 void AliTPCcalibAlignment::Process(AliTPCseed *track) {
91   //
92   // Track processing
93   //
94   TObjArray tracklets=
95     AliTPCTracklet::CreateTracklets(track,AliTPCTracklet::kKalman,kFALSE,20,2);
96   TObjArray trackletsL=
97     AliTPCTracklet::CreateTracklets(track,AliTPCTracklet::kLinear,kFALSE,20,2);
98   TObjArray trackletsQ=
99     AliTPCTracklet::CreateTracklets(track,AliTPCTracklet::kQuadratic,kFALSE,20,2);
100   TObjArray trackletsR=
101     AliTPCTracklet::CreateTracklets(track,AliTPCTracklet::kRiemann,kFALSE,20,2);
102   tracklets.SetOwner();
103   if (tracklets.GetEntries()==2) {
104     AliTPCTracklet* t1=static_cast<AliTPCTracklet*>(tracklets[0]);
105     AliTPCTracklet* t2=static_cast<AliTPCTracklet*>(tracklets[1]);
106     AliExternalTrackParam *common1=0,*common2=0;
107     if (AliTPCTracklet::PropagateToMeanX(*t1,*t2,common1,common2))
108       (*fDebugStream)<<"Alignment"
109                      <<"common1.="<<common1
110                      <<"common2.="<<common2
111                      <<"tracklet1.="<<tracklets[0]
112                      <<"tracklet2.="<<tracklets[1]
113                      <<"trackletL1.="<<trackletsL[0]
114                      <<"trackletL2.="<<trackletsL[1]
115                      <<"trackletQ1.="<<trackletsQ[0]
116                      <<"trackletQ2.="<<trackletsQ[1]
117                      <<"trackletR1.="<<trackletsR[0]
118                      <<"trackletR2.="<<trackletsR[1]
119                      <<"\n";
120     delete common1;
121     delete common2;
122  }
123 }
124
125