1 //////////////////////////////////////////////////////////////////////////
2 // Alice ITS first detector alignment program. //
4 // version: 0.0.0 Draft. //
5 // Date: April 18 1999 //
6 // By: Bjorn S. Nilsen //
8 //////////////////////////////////////////////////////////////////////////
10 // Data structure to hold averaged clusts.
13 Float_t xg,yg,zg,xl,yl,zl;
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;
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,
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.
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
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");
48 } // end if gClassTable...
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);
55 // Get AliRun object from file or create it if not on file
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");
62 for(Int_t evnt=0;evnt<=evNumber;evnt++){
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 */
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();
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];
80 Float_t v0[3] = {0.0,0.0,0.0};
82 printf("ntracks=%d\n",ntracks);
84 HitsTo(trk,ntrk,ntracks,TH,ITS,sigma1,sigma2,sigma3,0.0,0.0,0.0);
86 printf("Filled data structures ntrk=%d fitting lines next\n",ntrk);
88 // setup to save all created histograms.
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);
96 FitAllTracks(trk,ntrk,v0,sfile,Hfile);
97 // fit all tracks and do a track quality hist.
99 printf("Fitted tracks, finding vertex next\n");
101 FitVertexAll(trk,ntrk,sfile,Hfile);
102 // Find all 2 track vertecies and hist. them.
104 printf("Event %d done\n",evnt);
106 for(Int_t i=0;i<ntrk;i++) delete trk[i].clust;