]>
Commit | Line | Data |
---|---|---|
4c039060 | 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 | ||
88cb7938 | 16 | /* $Id$ */ |
4c039060 | 17 | |
6ca40650 | 18 | /////////////////////////////////////////////////////////////////////////////// |
19 | // // | |
20 | // START (T-Zero) Detector // | |
21 | // This class contains the base procedures for the START // | |
22 | // detector // | |
23 | // // | |
24 | //Begin_Html | |
25 | /* | |
26 | <img src="gif/AliSTARTClass.gif"> | |
27 | </pre> | |
28 | <br clear=left> | |
29 | <font size=+2 color=red> | |
30 | <p>The responsible person for this module is | |
31 | <a href="mailto:Alla.Maevskaia@cern.ch">Alla Maevskaia</a>. | |
32 | </font> | |
33 | <pre> | |
34 | */ | |
35 | //End_Html | |
36 | // // | |
37 | // // | |
38 | /////////////////////////////////////////////////////////////////////////////// | |
39 | ||
ef0750c2 | 40 | #include <Riostream.h> |
971579f6 | 41 | |
88cb7938 | 42 | #include <TFile.h> |
43 | #include <TGeometry.h> | |
44 | #include <TMath.h> | |
45 | #include <TNode.h> | |
46 | #include <TParticle.h> | |
47 | #include <TRandom.h> | |
48 | #include <TTUBE.h> | |
49 | #include <TVirtualMC.h> | |
affef71b | 50 | #include <AliESD.h> |
2ab0c725 | 51 | |
e4da63c2 | 52 | #include "AliLog.h" |
53 | #include "AliMC.h" | |
88cb7938 | 54 | #include "AliLoader.h" |
971579f6 | 55 | #include "AliRun.h" |
db173afc | 56 | #include "TClonesArray.h" |
971579f6 | 57 | #include "AliSTART.h" |
6fc133d2 | 58 | #include "AliSTARTLoader.h" |
971579f6 | 59 | #include "AliSTARTdigit.h" |
971579f6 | 60 | #include "AliSTARThit.h" |
85a5290f | 61 | #include "AliSTARTDigitizer.h" |
e4da63c2 | 62 | #include "AliSTARTRawData.h" |
db173afc | 63 | #include "AliSTARTRecPoint.h" |
4951e003 | 64 | #include "AliLog.h" |
971579f6 | 65 | |
6ca40650 | 66 | ClassImp(AliSTART) |
ef51244a | 67 | |
e4da63c2 | 68 | //static AliSTARTdigit *digits; |
ef51244a | 69 | |
6ca40650 | 70 | //_____________________________________________________________________________ |
99560b47 | 71 | AliSTART::AliSTART() |
6ca40650 | 72 | { |
73 | // | |
74 | // Default constructor for class AliSTART | |
75 | // | |
f3ed336b | 76 | fIshunt = 1; |
971579f6 | 77 | fHits = 0; |
78 | fDigits = 0; | |
db173afc | 79 | fRecPoints = 0; |
6ca40650 | 80 | } |
81 | ||
82 | //_____________________________________________________________________________ | |
83 | AliSTART::AliSTART(const char *name, const char *title) | |
84 | : AliDetector(name,title) | |
85 | { | |
86 | // | |
87 | // Standard constructor for START Detector | |
88 | // | |
971579f6 | 89 | |
c345bb4f | 90 | |
6ca40650 | 91 | // |
92 | // Initialise Hit array | |
971579f6 | 93 | fHits = new TClonesArray("AliSTARThit", 405); |
f1538e33 | 94 | gAlice->GetMCApp()->AddHitList(fHits); |
db173afc | 95 | fDigits = new AliSTARTdigit(); |
96 | fRecPoints = new AliSTARTRecPoint(); | |
f3ed336b | 97 | fIshunt = 1; |
c345bb4f | 98 | fIdSens = 0; |
6ca40650 | 99 | SetMarkerColor(kRed); |
100 | } | |
bff160c8 | 101 | |
102 | //_____________________________________________________________________________ | |
103 | AliSTART::~AliSTART() { | |
db173afc | 104 | |
bff160c8 | 105 | if (fHits) { |
106 | fHits->Delete(); | |
107 | delete fHits; | |
db173afc | 108 | } |
109 | /* | |
110 | if (fDigits) { | |
111 | fDigits->Delete(); | |
112 | delete fDigits; | |
113 | cout<<" delete fDigits; "<<endl; | |
bff160c8 | 114 | } |
db173afc | 115 | if (fRecPoints) { |
116 | fRecPoints ->Delete(); | |
117 | delete fRecPoints; | |
118 | cout<<" delete fRecPoints; "<<endl; | |
119 | } | |
120 | */ | |
bff160c8 | 121 | } |
6ca40650 | 122 | |
123 | //_____________________________________________________________________________ | |
124 | void AliSTART::AddHit(Int_t track, Int_t *vol, Float_t *hits) | |
125 | { | |
126 | // | |
127 | // Add a START hit | |
128 | // | |
129 | TClonesArray &lhits = *fHits; | |
130 | new(lhits[fNhits++]) AliSTARThit(fIshunt,track,vol,hits); | |
131 | } | |
971579f6 | 132 | |
e73d68f2 | 133 | |
971579f6 | 134 | //_____________________________________________________________________________ |
c345bb4f | 135 | |
db173afc | 136 | void AliSTART::AddDigit(Int_t besttimeright, Int_t besttimeleft, Int_t meantime, |
137 | Int_t timediff, TArrayI *sumMult, | |
138 | TArrayI *time, TArrayI *adc, TArrayI *timeAmp, TArrayI *adcAmp) | |
971579f6 | 139 | { |
c345bb4f | 140 | |
db173afc | 141 | // Add a START digit to the list. |
142 | // | |
c345bb4f | 143 | |
db173afc | 144 | if (!fDigits) { |
145 | fDigits = new AliSTARTdigit(); | |
146 | } | |
147 | fDigits-> SetTimeBestRight(besttimeright); | |
148 | fDigits->SetTimeBestLeft(besttimeleft); | |
149 | fDigits-> SetMeanTime(meantime); | |
150 | fDigits-> SetDiffTime(timediff); | |
151 | fDigits-> SetSumMult(*sumMult); | |
152 | fDigits->SetTime(*time); | |
153 | fDigits->SetTimeAmp(*timeAmp); | |
154 | fDigits->SetADC(*adc); | |
155 | fDigits->SetADCAmp(*adcAmp); | |
971579f6 | 156 | } |
c345bb4f | 157 | |
db173afc | 158 | |
6ca40650 | 159 | //_____________________________________________________________________________ |
160 | void AliSTART::BuildGeometry() | |
161 | { | |
162 | // | |
163 | // Build simple ROOT TNode geometry for event display | |
164 | // | |
ef51244a | 165 | TNode *node, *top; |
6ca40650 | 166 | const int kColorSTART = 19; |
f3ed336b | 167 | |
ef51244a | 168 | top=gAlice->GetGeometry()->GetNode("alice"); |
6ca40650 | 169 | |
170 | // START define the different volumes | |
44b06417 | 171 | new TRotMatrix("rotx999","rot999", 90,0,90,90,180,0); |
6ca40650 | 172 | |
2ca99a7f | 173 | new TTUBE("S_0ST1","START volume 1","void",5.,10.7,5.3); |
ef51244a | 174 | top->cd(); |
1663993c | 175 | node = new TNode("0ST1","0ST01","S_0ST1",0,0,-69.7,""); |
ef51244a | 176 | node->SetLineColor(kColorSTART); |
177 | fNodes->Add(node); | |
6ca40650 | 178 | |
2ca99a7f | 179 | new TTUBE("S_0ST2","START volume 2","void",5.,10.7,5.3); |
ef51244a | 180 | top->cd(); |
1663993c | 181 | node = new TNode("0ST2","0ST2","S_0ST2",0,0,350,"rotx999"); |
ef51244a | 182 | node->SetLineColor(kColorSTART); |
183 | fNodes->Add(node); | |
6ca40650 | 184 | } |
185 | ||
186 | //_____________________________________________________________________________ | |
7fe81cad | 187 | Int_t AliSTART::DistanceToPrimitive(Int_t /*px*/, Int_t /*py*/) |
6ca40650 | 188 | { |
189 | // | |
190 | // Calculate the distance from the mouse to the START on the screen | |
191 | // Dummy routine | |
192 | // | |
193 | return 9999; | |
194 | } | |
195 | ||
6ca40650 | 196 | //------------------------------------------------------------------------- |
197 | void AliSTART::Init() | |
198 | { | |
199 | // | |
200 | // Initialis the START after it has been built | |
201 | Int_t i; | |
6ca40650 | 202 | // |
4951e003 | 203 | if(AliLog::GetGlobalDebugLevel()>0) { |
9e1a0ddb | 204 | printf("\n%s: ",ClassName()); |
205 | for(i=0;i<35;i++) printf("*"); | |
206 | printf(" START_INIT "); | |
207 | for(i=0;i<35;i++) printf("*"); | |
208 | printf("\n%s: ",ClassName()); | |
209 | // | |
210 | // Here the START initialisation code (if any!) | |
211 | for(i=0;i<80;i++) printf("*"); | |
212 | printf("\n"); | |
213 | } | |
6ca40650 | 214 | } |
215 | ||
216 | //--------------------------------------------------------------------------- | |
88cb7938 | 217 | void AliSTART::MakeBranch(Option_t* option) |
6ca40650 | 218 | { |
ef51244a | 219 | // |
db173afc | 220 | // Create Tree branches for the START. |
221 | ||
222 | // Options: | |
223 | // | |
224 | // H Make a branch of TClonesArray of AliSTARTHit's | |
225 | // D Make a branch of TClonesArray of AliSTARTDigit's | |
226 | // | |
227 | // R Make a branch of AliSTARTRecPoints | |
ef51244a | 228 | // |
e73d68f2 | 229 | char branchname[20]; |
6ca40650 | 230 | sprintf(branchname,"%s",GetName()); |
231 | ||
e73d68f2 | 232 | const char *cH = strstr(option,"H"); |
db173afc | 233 | const char *cD = strstr(option,"D"); |
234 | const char *cR = strstr(option,"R"); | |
235 | ||
236 | if (cH && fLoader->TreeH()) | |
e73d68f2 | 237 | { |
88cb7938 | 238 | if (fHits == 0x0) fHits = new TClonesArray("AliSTARThit", 405); |
db173afc | 239 | AliDetector::MakeBranch(option); |
e73d68f2 | 240 | } |
db173afc | 241 | |
242 | ||
243 | if (cD && fLoader->TreeD()) | |
244 | { | |
245 | if (fDigits == 0x0) fDigits = new AliSTARTdigit(); | |
246 | // MakeBranchInTree(fLoader->TreeD(), branchname, | |
247 | // &fDigits, 405, 0); | |
248 | fLoader->TreeD()->Branch(branchname,"AliSTARTdigit",&fDigits,405,1); | |
249 | } | |
250 | if (cR && fLoader->TreeR()) | |
251 | { | |
252 | if (fRecPoints == 0x0) fRecPoints = new AliSTARTRecPoint(); | |
253 | MakeBranchInTree(fLoader->TreeR(), branchname, | |
254 | &fRecPoints, 405, 0); | |
255 | } | |
2ab0c725 | 256 | |
6ca40650 | 257 | } |
971579f6 | 258 | |
e73d68f2 | 259 | //_____________________________________________________________________________ |
260 | void AliSTART::ResetHits() | |
261 | { | |
262 | AliDetector::ResetHits(); | |
263 | ||
e73d68f2 | 264 | } |
db173afc | 265 | //____________________________________________________________________ |
266 | void AliSTART::ResetDigits() | |
267 | { | |
268 | // | |
269 | // Reset number of digits and the digits array for this detector | |
270 | // | |
271 | if (fDigits) fDigits->Clear(); | |
272 | } | |
e73d68f2 | 273 | |
274 | //_____________________________________________________________________________ | |
275 | void AliSTART::SetTreeAddress() | |
276 | { | |
e4da63c2 | 277 | |
88cb7938 | 278 | TTree *treeH; |
88cb7938 | 279 | treeH = TreeH(); |
e73d68f2 | 280 | |
281 | if (treeH) | |
e73d68f2 | 282 | { |
88cb7938 | 283 | if (fHits == 0x0) fHits = new TClonesArray("AliSTARThit", 405); |
e73d68f2 | 284 | } |
88cb7938 | 285 | |
286 | AliDetector::SetTreeAddress(); | |
db173afc | 287 | TTree *treeD = fLoader->TreeD(); |
288 | if (treeD) { | |
289 | if (fDigits == 0x0) fDigits = new AliSTARTdigit(); | |
290 | TBranch* branch = treeD->GetBranch ("START"); | |
291 | if (branch) branch->SetAddress(&fDigits); | |
292 | } | |
293 | ||
294 | TTree *treeR = fLoader->TreeR(); | |
295 | if (treeR) { | |
296 | if (fRecPoints == 0x0) fRecPoints = new AliSTARTRecPoint() ; | |
297 | TBranch* branch = treeR->GetBranch ("START"); | |
298 | if (branch) branch->SetAddress(&fRecPoints); | |
299 | } | |
300 | ||
e73d68f2 | 301 | } |
302 | ||
e4da63c2 | 303 | |
db173afc | 304 | //_____________________________________________________________________________ |
305 | void AliSTART::MakeBranchInTreeD(TTree *treeD, const char *file) | |
306 | { | |
307 | // | |
308 | // Create TreeD branches for the FMD | |
309 | // | |
310 | const Int_t kBufferSize = 4000; | |
311 | char branchname[20]; | |
312 | sprintf(branchname,"%s",GetName()); | |
313 | if(treeD) | |
314 | { | |
315 | MakeBranchInTree(treeD, branchname,&fDigits, kBufferSize, file); | |
316 | } | |
6fc133d2 | 317 | } |
318 | ||
85a5290f | 319 | //_____________________________________________________________________________ |
c92eb8ad | 320 | AliDigitizer* AliSTART::CreateDigitizer(AliRunDigitizer* manager) const |
85a5290f | 321 | { |
322 | return new AliSTARTDigitizer(manager); | |
323 | } | |
e4da63c2 | 324 | //____________________________________________________________________________ |
325 | void AliSTART::Digits2Raw() | |
326 | { | |
327 | // | |
328 | // Starting from the START digits, writes the Raw Data objects | |
329 | // | |
db173afc | 330 | // AliSTARTLoader* pStartLoader = (AliSTARTLoader*)fLoader; |
331 | fLoader ->LoadDigits("read"); | |
332 | TTree* treeD = fLoader->TreeD(); | |
333 | if (!treeD) { | |
334 | AliError("no digits tree"); | |
335 | return; | |
336 | } | |
337 | if (fDigits == 0x0) fDigits = new AliSTARTdigit(); | |
338 | ||
339 | TBranch *branch = treeD->GetBranch("START"); | |
340 | if (branch) { | |
341 | branch->SetAddress(&fDigits); | |
342 | }else{ | |
343 | AliError("Branch START DIGIT not found"); | |
344 | exit(111); | |
345 | } | |
e4da63c2 | 346 | AliSTARTRawData rawWriter; |
347 | rawWriter.SetVerbose(0); | |
db173afc | 348 | |
e4da63c2 | 349 | AliDebug(2,Form(" Formatting raw data for START ")); |
db173afc | 350 | branch->GetEntry(0); |
351 | // rawWriter.RawDataSTART(treeD->GetBranch("START")); | |
352 | rawWriter.RawDataSTART(fDigits); | |
353 | ||
354 | ||
355 | fLoader->UnloadDigits(); | |
e4da63c2 | 356 | |
e4da63c2 | 357 | } |