]>
Commit | Line | Data |
---|---|---|
e8189707 | 1 | ////////////////////////////////////////////////////////////////////////// |
2 | // Alice ITS first detector alignment program. // | |
3 | // // | |
4 | // version: 0.0.0 Draft. // | |
5 | // Date: April 18 1999 // | |
6 | // By: Bjorn S. Nilsen // | |
7 | // // | |
8 | ////////////////////////////////////////////////////////////////////////// | |
9 | ||
10 | // Data structure to hold averaged clusts. | |
11 | struct ClustAl_sl{ | |
12 | Int_t lay,lad,det; | |
13 | Float_t xg,yg,zg,xl,yl,zl; | |
14 | }; | |
15 | struct ClustAl_tl{ | |
16 | Int_t track,nclust; // track number and number of data points. | |
17 | ClustAl_sl *clust; // data points to fit. | |
18 | Float_t a,b,c,d,qual; // fit parameters and fit quality. | |
19 | Float_t px,py,pz,p,pt; | |
20 | // x=a+bz and y=c+dz; | |
21 | }; | |
22 | ||
23 | // | |
24 | void AlignITSmacro (const char *filename="galice_ITS_B0.root", | |
25 | const char *sfile="Align_ITS_B0", | |
26 | Float_t sigma1=0.0,Float_t sigma2=0.0,Float_t sigma3=0.0, | |
27 | Int_t evNumber=0) { | |
28 | ///////////////////////////////////////////////////////////////////////// | |
29 | // This macro is a small example of a ROOT macro | |
30 | // illustrating how to read the output of GALICE | |
31 | // and fill some histograms. | |
32 | // | |
33 | // Root > .L AlignITS.C //this loads the macro in memory | |
34 | // Root > AlignITS(); //by default process first event | |
35 | // Root > AlignITS("galice.root"); //process file galice.root | |
36 | // Root > AlignITS("galice.root",3); // process file galice.root | |
37 | // the first 4 eventst | |
38 | // or | |
39 | // Root > .x AlignITS.C; //by default process first event | |
40 | // Root > .x AlignITS.C("galice.root"); //process file galice.root | |
41 | // Root > .x AlignITS.C("galice.root",3); // process file galice.root | |
42 | // the first 4 eventst | |
43 | ///////////////////////////////////////////////////////////////////////// | |
44 | // Dynamically link some shared libs | |
45 | if (gClassTable->GetID("AliRun") < 0) { | |
46 | gROOT->LoadMacro("loadlibs.C"); | |
47 | loadlibs(); | |
48 | } // end if gClassTable... | |
49 | ||
50 | // Connect the Root Galice file containing Geometry, Kine and Clusts | |
51 | TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject(filename); | |
52 | if(!file) file = new TFile(filename); | |
53 | printf("reading from file %s\n",filename); | |
54 | ||
55 | // Get AliRun object from file or create it if not on file | |
56 | if(!gAlice) { | |
57 | gAlice = (AliRun*)file->Get("gAlice"); | |
58 | if( gAlice) printf("AliRun object found on file\n"); | |
59 | if(!gAlice) gAlice = new AliRun("gAlice","Alice test program"); | |
60 | } /* end if gAlice */ | |
61 | ||
62 | for(Int_t evnt=0;evnt<=evNumber;evnt++){ | |
63 | ||
64 | // define some variables for later use. | |
65 | Int_t nparticles = gAlice->GetEvent(evnt); | |
66 | printf("nparticles %d\n",nparticles); | |
67 | if (nparticles <= 0) continue; /* get next event */ | |
68 | ||
69 | // Get pointers to Alice detectors and Clusts containers | |
70 | AliITS *ITS = (AliITS*)gAlice->GetDetector("ITS"); | |
71 | if(!ITS) return; /* error no ITS data exit */ | |
72 | TTree *TH = gAlice->TreeH(); | |
73 | Int_t ntracks = TH->GetEntries(); | |
74 | ||
75 | // Array (stucture) of clusts for the first and second layer | |
76 | // this should be replaced with either clusters or digits | |
77 | // when they are proporly defined. | |
78 | ClustAl_tl *trk = new ClustAl_tl[ntracks]; | |
79 | Int_t ntrk; | |
80 | Float_t v0[3] = {0.0,0.0,0.0}; | |
81 | ||
82 | printf("ntracks=%d\n",ntracks); | |
83 | ||
84 | HitsTo(trk,ntrk,ntracks,TH,ITS,sigma1,sigma2,sigma3,0.0,0.0,0.0); | |
85 | ||
86 | printf("Filled data structures ntrk=%d fitting lines next\n",ntrk); | |
87 | // return; | |
88 | // setup to save all created histograms. | |
89 | char Hfilename[80]; | |
90 | sprintf(Hfilename,"%s.root",sfile); | |
91 | TFile *Hfile = (TFile*)gROOT->GetListOfFiles()->FindObject(Hfilename); | |
92 | if(Hfile) Hfile->Close(); | |
93 | Hfile = new TFile(Hfilename,"RECREATE","Histograms from AlignITS.C"); | |
94 | printf("Histograms saved to file %s\n",Hfilename); | |
95 | ||
96 | FitAllTracks(trk,ntrk,v0,sfile,Hfile); | |
97 | // fit all tracks and do a track quality hist. | |
98 | ||
99 | printf("Fitted tracks, finding vertex next\n"); | |
100 | ||
101 | FitVertexAll(trk,ntrk,sfile,Hfile); | |
102 | // Find all 2 track vertecies and hist. them. | |
103 | ||
104 | printf("Event %d done\n",evnt); | |
105 | ||
106 | for(Int_t i=0;i<ntrk;i++) delete trk[i].clust; | |
107 | delete[] trk; | |
108 | } /* end for evnt */ | |
109 | return; | |
110 | } |