]> git.uio.no Git - u/mrichter/AliRoot.git/blame - T0/readDigits.C
Code commit for Ramona, fix of warnings, add of AddTask macros and exchange of comments
[u/mrichter/AliRoot.git] / T0 / readDigits.C
CommitLineData
dc7ca31d 1void readDigits()
2{
3
4 // Dynamically link some shared libs
5 /* if (gClassTable->GetID("AliRun") < 0) {
6 gROOT->LoadMacro("loadlibs.C");
7 loadlibs();
8 }
9 */
10 Float_t c = 0.0299792; // cm/ps
11 Float_t channelWidth = 25;
12 Float_t timeDelay = 150;
13 char filename[100];
14 sprintf(filename,"galice.root");
15 AliRunLoader* rl = AliRunLoader::Open("galice.root",AliConfig::GetDefaultEventFolderName(),"read");
16 if (rl == 0x0)
17 {
18 cerr<<"Can not open session for file galice.root\n";
19 return;
20 }
21
22 rl->LoadgAlice();
23 gAlice = rl->GetAliRun();
24
25 AliT0* T0 = (AliT0 *)gAlice->GetDetector("T0");
26
27 rl->LoadHeader();
28 Int_t retval;
29 AliLoader* lstart = rl->GetLoader("T0Loader");
30
31 Int_t iNevents=rl->GetNumberOfEvents();
32 cout<<" nevents "<<iNevents<<endl;
33
34
35 TH1F *hTimediff = new TH1F("hTimediff","Time difference",100,5950,6050);
36 TH1F *hBestTimeright = new TH1F("hBestTimeright","First time right",
37 100,8450.,8650);
38 TH1F *hBestTimeleft = new TH1F("hBestTimeleft","First time left",
39 100,8450.,8650.);
40 TH1F *hRealVertex = new TH1F("hRealVertex","Real Vertex",100,-15,15);
41
42 TH1F *hVertex = new TH1F("hVertex","Z position of vertex", 100,-15,15);
43 // digits = new AliT0digit();
44 AliT0digit *fDigits ; // digits
45 fDigits = new AliT0digit();
46
47 // Event ------------------------- LOOP
48 for (Int_t j=0; j<iNevents; j++){
49 rl->GetEvent(j);
50
51 AliHeader *header = gAlice->GetHeader();
52 AliGenEventHeader* genHeader = header->GenEventHeader();
53 TArrayF *o = new TArrayF(3);
54 genHeader->PrimaryVertex(*o);
55 Float_t zRealVertex=o->At(2);
56 hRealVertex->Fill( zRealVertex);
57
58 lstart->LoadDigits("READ");
59 TTree *digitsTree = lstart->TreeD();
60 TBranch *brDigits=digitsTree->GetBranch("T0");
61 AliT0digit *fDigits = new AliT0digit();
62 if (brDigits) {
63 brDigits->SetAddress(&fDigits);
64 }else{
65 cerr<<"EXEC Branch T0 digits not found"<<endl;
66 return;
67 }
68 brDigits->GetEntry(0);
69 Int_t besttimeright = fDigits->BestTimeRight();
70 Int_t besttimeleft = fDigits->BestTimeLeft();
71 Int_t timeDiff = fDigits->TimeDiff();
72 Int_t sumMult= fDigits->SumMult();
73 hTimediff->Fill(timeDiff);
74 hBestTimeright->Fill(besttimeright);
75 hBestTimeleft->Fill(besttimeleft );
76 Float_t vertex= (timeDiff* channelWidth - timeDelay*1000.)*c;
77 cout<<j<<" "<<besttimeright<<" "<< besttimeleft<<" "<<timeDiff<<" "<<vertex<<endl;
78 hVertex->Fill(vertex);
79 }
80 Hfile = new TFile("Figdigits.root","RECREATE","Histograms for T0 digits");
81 printf("Writting histograms to root file \n");
82 Hfile->cd();
83 //Create a canvas, set the view range, show histograms
84 gStyle->SetOptStat(111111);
85 // TCanvas *c1 = new TCanvas("c1","Alice T0 Time ",400,10,600,600);
86 hTimediff->Write();
87 hBestTimeright->Write();
88 hBestTimeleft ->Write();
89 hVertex->Write();
90 hRealVertex->Write();
91
92
93} // end of macro
94
95
96
97