]>
Commit | Line | Data |
---|---|---|
0866e534 | 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 | // $Id$ | |
17 | ||
18 | // Macro to generate histograms from digits | |
19 | // By E. Sicking, CERN | |
20 | ||
21 | TDirectoryFile* GetDirectory(Int_t ievent, const TString& detName, Int_t nfiles) | |
22 | { | |
23 | for (Int_t file =0; file<nfiles; file++) { | |
24 | TString filename(detName); | |
25 | if ( file == 0 ) { | |
26 | filename += ".Digits.root"; | |
27 | } | |
28 | else { | |
29 | filename += TString(Form(".Digits%d.root",file)); | |
30 | } | |
31 | ||
32 | TFile* file0 = TFile::Open(filename.Data()); | |
33 | ||
34 | TDirectoryFile* dir = (TDirectoryFile*)file0->Get(Form("Event%d",ievent)); | |
35 | if (dir) return dir; | |
36 | } | |
37 | return 0; | |
38 | } | |
39 | ||
40 | void digitsSPD(Int_t nevents, Int_t nfiles) | |
41 | { | |
42 | ||
43 | TH1F * hadc = new TH1F ("hadc", "hadc",100, 0, 2); | |
44 | TH1F * hadclog = new TH1F ("hadclog", "hadclog",100, -1, 1); | |
45 | ||
46 | TDirectoryFile *tdf[100]; | |
47 | TDirectoryFile *tdfKine[100] ; | |
48 | ||
49 | TTree *ttree[100]; | |
50 | TTree *ttreeKine[100]; | |
51 | ||
52 | ||
53 | TClonesArray *arr= NULL; // | |
54 | ||
55 | //Run loader------------ | |
56 | TString name; | |
57 | name = "galice.root"; | |
58 | AliRunLoader* rlSig = AliRunLoader::Open(name.Data()); | |
59 | ||
60 | // gAlice | |
61 | rlSig->LoadgAlice(); | |
62 | gAlice = rlSig->GetAliRun(); | |
63 | ||
64 | // Now load kinematics and event header | |
65 | rlSig->LoadKinematics(); | |
66 | rlSig->LoadHeader(); | |
67 | cout << rlSig->GetNumberOfEvents()<< endl; | |
68 | //---------------------- | |
69 | ||
70 | ||
71 | //loop over events in the files | |
72 | for(Int_t event=0; event<nevents; event++){ | |
73 | //printf("###event= %d\n", event + file*100); | |
74 | printf("###event= %d\n", event); | |
75 | ||
76 | tdf[event] = GetDirectory(event, "ITS", nfiles); | |
77 | if ( ! tdf[event] ) { | |
78 | cerr << "Event directory not found in " << nfiles << " files" << endl; | |
79 | exit(1); | |
80 | } | |
81 | ||
82 | ttree[event] = (TTree*)tdf[event]->Get("TreeD"); | |
83 | ||
84 | arr = NULL; | |
85 | ttree[event]->SetBranchAddress("ITSDigitsSPD", &arr); | |
86 | ||
87 | ||
88 | // Runloader -> gives particle Stack | |
89 | rlSig->GetEvent(event); | |
90 | AliStack * stack = rlSig->Stack(); | |
91 | //stack->DumpPStack(); | |
92 | ||
93 | ||
94 | // loop over tracks | |
95 | Int_t NumberPrim=0; | |
96 | for(Int_t iev=0; iev<ttree[event]->GetEntries(); iev++){ | |
97 | ttree[event]->GetEntry(iev); | |
98 | ||
99 | ||
100 | for (Int_t j = 0; j < arr->GetEntries(); j++) { | |
101 | AliITSdigit* digit = dynamic_cast<AliITSdigit*> (arr->At(j)); | |
102 | if (digit){ | |
103 | hadc->Fill(digit->GetSignal()); | |
104 | hadclog->Fill(TMath::Log10(digit->GetSignal())); | |
105 | ||
106 | } | |
107 | } | |
108 | } | |
109 | ||
110 | } | |
111 | ||
112 | TFile fc("digits.ITS.SPD.root","RECREATE"); | |
113 | fc.cd(); | |
114 | ||
115 | hadc->Write(); | |
116 | hadclog->Write(); | |
117 | ||
118 | fc.Close(); | |
119 | ||
120 | } |