]>
Commit | Line | Data |
---|---|---|
5e319bd5 | 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: AliADDigitizer.cxx $ */ | |
17 | ||
18 | ///_________________________________________________________________________ | |
19 | /// | |
20 | /// This class constructs Digits out of Hits | |
21 | /// | |
22 | /// | |
23 | ||
24 | // --- Standard library --- | |
25 | ||
26 | // --- ROOT system --- | |
27 | #include <TMath.h> | |
28 | #include <TTree.h> | |
29 | #include <TMap.h> | |
30 | #include <TGeoManager.h> | |
31 | #include <TGeoPhysicalNode.h> | |
32 | #include <AliGeomManager.h> | |
33 | #include <TRandom.h> | |
34 | #include <TF1.h> | |
35 | #include <TH1F.h> | |
36 | ||
37 | // --- AliRoot header files --- | |
38 | #include "AliRun.h" | |
39 | #include "AliAD.h" | |
40 | #include "AliADhit.h" | |
41 | #include "AliRunLoader.h" | |
42 | #include "AliLoader.h" | |
43 | #include "AliGRPObject.h" | |
44 | #include "AliDigitizationInput.h" | |
45 | #include "AliCDBManager.h" | |
46 | #include "AliCDBStorage.h" | |
47 | #include "AliCDBEntry.h" | |
48 | //#include "AliADCalibData.h" | |
49 | #include "AliCTPTimeParams.h" | |
50 | #include "AliLHCClockPhase.h" | |
51 | #include "AliADdigit.h" | |
52 | #include "AliADDigitizer.h" | |
53 | //#include "AliADSDigit.h" | |
54 | ||
55 | ClassImp(AliADDigitizer) | |
56 | ||
57 | //____________________________________________________________________________ | |
58 | AliADDigitizer::AliADDigitizer() | |
59 | :AliDigitizer(), | |
60 | fNdigits(0), | |
61 | fDigits(0) | |
62 | { | |
63 | // default constructor | |
64 | } | |
65 | ||
66 | //____________________________________________________________________________ | |
67 | AliADDigitizer::AliADDigitizer(AliDigitizationInput* digInput) | |
68 | :AliDigitizer(digInput), | |
69 | fNdigits(0), | |
70 | fDigits(0) | |
71 | { | |
72 | // constructor | |
73 | } | |
74 | ||
75 | //____________________________________________________________________________ | |
76 | AliADDigitizer::~AliADDigitizer() | |
77 | { | |
78 | // destructor | |
79 | ||
80 | if (fDigits) { | |
81 | fDigits->Delete(); | |
82 | delete fDigits; | |
83 | fDigits=0; | |
84 | } | |
85 | ||
86 | } | |
87 | ||
88 | //____________________________________________________________________________ | |
89 | Bool_t AliADDigitizer::Init() | |
90 | { | |
91 | fDigits = new TClonesArray ("AliADdigit",1000); | |
92 | return kTRUE; | |
93 | } | |
94 | //____________________________________________________________________________ | |
95 | ||
96 | void AliADDigitizer::Digitize(Option_t* /*option*/) | |
97 | { | |
98 | // Creates digits from hits | |
99 | ||
100 | // tem. variables | |
101 | Int_t modules[16]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; | |
102 | Int_t moduls[16]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; | |
103 | Int_t mods; | |
104 | ||
105 | ||
106 | // loaders | |
107 | ||
108 | AliRunLoader* outRunLoader = AliRunLoader::GetRunLoader(fDigInput->GetOutputFolderName()); | |
109 | if (!outRunLoader) | |
110 | { | |
111 | Error("Exec","Can not get output Run Loader"); | |
112 | return; | |
113 | } | |
114 | AliLoader* outLoader = outRunLoader->GetLoader("ADLoader"); | |
115 | if (!outLoader) | |
116 | { | |
117 | Error("Exec","Can not get output AD Loader"); | |
118 | return; | |
119 | } | |
120 | ||
121 | outLoader->LoadDigits("update"); | |
122 | if (!outLoader->TreeD()) outLoader->MakeTree("D"); | |
123 | outLoader->MakeDigitsContainer(); | |
124 | TTree* treeD = outLoader->TreeD(); | |
125 | Int_t bufsize = 16000; | |
126 | treeD->Branch("ADdigit",&fDigits, bufsize); | |
127 | ||
128 | const Float_t eMin = 0;//1.52; //! MeVs, minimum energy | |
129 | // loop over inputs | |
130 | ||
131 | for (Int_t iInput=0; iInput < fDigInput->GetNinputs();iInput++) | |
132 | { | |
133 | AliRunLoader* runLoader = AliRunLoader::GetRunLoader(fDigInput->GetInputFolderName(iInput)); | |
134 | AliLoader* loader = runLoader->GetLoader("ADLoader"); | |
135 | if (!loader) | |
136 | { | |
137 | Error("Exec","Can not get AD Loader for input %d",iInput); | |
138 | continue; | |
139 | } | |
140 | if (!runLoader->GetAliRun()) runLoader->LoadgAlice(); | |
141 | AliAD* ad = (AliAD*) runLoader->GetAliRun()->GetDetector("AD"); | |
142 | if (!ad) | |
143 | { | |
144 | Error("Exec","No AD detector for input %d",iInput); | |
145 | continue; | |
146 | } | |
147 | loader->LoadHits(); | |
148 | TTree* treeH = loader->TreeH(); | |
149 | if (!treeH) | |
150 | { | |
151 | Error("Exec","Cannot get TreeH for input %d",iInput); | |
152 | continue; | |
153 | } | |
154 | TClonesArray* hits = ad->Hits(); | |
155 | ||
156 | // here I loop over tracks | |
157 | Int_t nTracks = (Int_t) treeH->GetEntries(); | |
158 | for (Int_t iTrack=0; iTrack < nTracks; iTrack++) | |
159 | { | |
160 | ad->ResetHits(); | |
161 | treeH->GetEvent(iTrack); | |
162 | Int_t nHits = hits->GetEntriesFast(); | |
163 | // here comes the loop over AD hits | |
164 | for (Int_t iHit=0; iHit < nHits; iHit++) | |
165 | { | |
166 | AliADhit* hit = (AliADhit *)hits->UncheckedAt(iHit); | |
167 | Float_t eloss_mev = hit->GetEloss()*1000.0; | |
168 | Int_t module = hit->GetModule(); | |
169 | //cout << "Module AD!!! " << module << endl; | |
170 | // at some point we shoukd have some calib objects to set real theresholds | |
171 | // simple checking on hit, minimum energy at scintillator pad should be > 1.52 MeV's | |
172 | if (eloss_mev > eMin) | |
173 | { | |
174 | modules[module] = 1;//cout << "energy: " << eloss_mev << endl; | |
175 | }else modules[module] = 0; | |
176 | }// end loop over hits | |
177 | } // endo loop over tracks | |
178 | for (Int_t i=0; i<16; i++) | |
179 | { | |
180 | moduls[i] = modules[i]; | |
181 | //cout << "iModule: " << i << " AD hits: " << moduls[i] << endl; | |
182 | } | |
183 | ||
184 | loader->UnloadHits(); | |
185 | ||
186 | } // end loop over inputs | |
187 | ||
188 | // here I add the hits to the TreeD | |
189 | ||
190 | Int_t tracks[3] = {-1,-1,-1}; | |
191 | for (Int_t i=0; i<16; i++) | |
192 | { | |
193 | if (moduls[i]==1) | |
194 | { | |
195 | mods = i; | |
196 | AddDigit(tracks,mods,mods); | |
197 | } | |
198 | } | |
199 | treeD->Fill(); | |
200 | outLoader->WriteDigits("OVERWRITE"); | |
201 | outLoader->UnloadDigits(); | |
202 | ResetDigit(); | |
203 | } | |
204 | ||
205 | //____________________________________________________________________________ | |
206 | void AliADDigitizer::AddDigit(Int_t* track, Int_t module, Float_t cell) | |
207 | { | |
208 | // Adds Digit | |
209 | TClonesArray &ldigits = *fDigits; | |
210 | new(ldigits[fNdigits++]) AliADdigit(track,module,cell); | |
211 | } | |
212 | //____________________________________________________________________________ | |
213 | void AliADDigitizer::AddDigit(Int_t* modul,Float_t cell) | |
214 | { | |
215 | // Adds Digit | |
216 | TClonesArray &ldigits = *fDigits; | |
217 | new(ldigits[fNdigits++]) AliADdigit(modul,cell); | |
218 | } | |
219 | ||
220 | //____________________________________________________________________________ | |
221 | void AliADDigitizer::ResetDigit() | |
222 | { | |
223 | // Clears Digits | |
224 | fNdigits = 0; | |
225 | if (fDigits) fDigits->Delete(); | |
226 | } | |
227 |