]> git.uio.no Git - u/mrichter/AliRoot.git/blame - T0/AliT0.cxx
correcting printf format specifiers
[u/mrichter/AliRoot.git] / T0 / AliT0.cxx
CommitLineData
dc7ca31d 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///////////////////////////////////////////////////////////////////////////////
19// //
20// T0 (T-Zero) Detector //
21// This class contains the base procedures for the T0 //
22// detector //
23// //
24//Begin_Html
25/*
26<img src="gif/AliT0Class.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
3e2e3ece 40#include "TClonesArray.h"
dc7ca31d 41
3e2e3ece 42#include "AliLoader.h"
43#include "AliLog.h"
dc7ca31d 44#include "AliLog.h"
45#include "AliMC.h"
dc7ca31d 46#include "AliRun.h"
dc7ca31d 47#include "AliT0.h"
c2d9de6d 48#include "AliT0Digitizer.h"
dc7ca31d 49#include "AliT0RawData.h"
50#include "AliT0RecPoint.h"
3e2e3ece 51#include "AliT0digit.h"
52#include "AliT0hit.h"
dc7ca31d 53
54ClassImp(AliT0)
55
56 //static AliT0digit *digits;
57
58//_____________________________________________________________________________
59AliT0::AliT0()
60 : AliDetector(), fIdSens(0), fDigits(NULL), fRecPoints(NULL)
61{
62 //
63 // Default constructor for class AliT0
64 //
65 fIshunt = 1;
66 fHits = 0;
67 fDigits = 0;
68 fRecPoints = 0;
69}
70
71//_____________________________________________________________________________
72AliT0::AliT0(const char *name, const char *title)
73 : AliDetector(name,title), fIdSens(0), fDigits(new AliT0digit()), fRecPoints(new AliT0RecPoint())
74{
75 //
76 // Standard constructor for T0 Detector
77 //
78
79
80 //
81 // Initialise Hit array
82 fHits = new TClonesArray("AliT0hit", 405);
83 gAlice->GetMCApp()->AddHitList(fHits);
84 // fDigits = new AliT0digit();
85 // fRecPoints = new AliT0RecPoint();
86 fIshunt = 1;
87 // fIdSens = 0;
88 //PH SetMarkerColor(kRed);
89}
90
91//_____________________________________________________________________________
92AliT0::~AliT0() {
93
94249139 94 //destructor
dc7ca31d 95 if (fHits) {
96 fHits->Delete();
97 delete fHits;
98 }
99 /*
100 if (fDigits) {
101 fDigits->Delete();
102 delete fDigits;
103 cout<<" delete fDigits; "<<endl;
104 }
105 if (fRecPoints) {
106 fRecPoints ->Delete();
107 delete fRecPoints;
108 cout<<" delete fRecPoints; "<<endl;
109 }
110 */
111}
112
113//_____________________________________________________________________________
114void AliT0::AddHit(Int_t track, Int_t *vol, Float_t *hits)
115{
116 //
117 // Add a T0 hit
118 //
119 TClonesArray &lhits = *fHits;
120 new(lhits[fNhits++]) AliT0hit(fIshunt,track,vol,hits);
121}
122
123
124//_____________________________________________________________________________
125
126void AliT0::AddDigit(Int_t besttimeright, Int_t besttimeleft, Int_t meantime,
740f0839 127 Int_t timediff, Int_t sumMult, Int_t refpoint,
c41ceaac 128 TArrayI *timeCFD, TArrayI *qt0, TArrayI *timeLED, TArrayI *qt1)
dc7ca31d 129{
130
131 // Add a T0 digit to the list.
132 //
133
134 if (!fDigits) {
135 fDigits = new AliT0digit();
136 }
c41ceaac 137 fDigits-> SetTimeBestA(besttimeright);
138 fDigits->SetTimeBestC(besttimeleft);
dc7ca31d 139 fDigits-> SetMeanTime(meantime);
140 fDigits-> SetDiffTime(timediff);
141 fDigits-> SetSumMult(sumMult);
c41ceaac 142 fDigits->SetTimeCFD(*timeCFD);
143 fDigits->SetTimeLED(*timeLED);
144 fDigits->SetQT0(*qt0);
145 fDigits->SetQT1(*qt1);
740f0839 146 fDigits->SetRefPoint(refpoint);
dc7ca31d 147}
148
dc7ca31d 149//-------------------------------------------------------------------------
150void AliT0::Init()
151{
152 //
153 // Initialis the T0 after it has been built
154 Int_t i;
155 //
156 if(AliLog::GetGlobalDebugLevel()>0) {
157 printf("\n%s: ",ClassName());
158 for(i=0;i<35;i++) printf("*");
159 printf(" T0_INIT ");
160 for(i=0;i<35;i++) printf("*");
161 printf("\n%s: ",ClassName());
162 //
163 // Here the T0 initialisation code (if any!)
164 for(i=0;i<80;i++) printf("*");
165 printf("\n");
166 }
167}
168
169//---------------------------------------------------------------------------
170void AliT0::MakeBranch(Option_t* option)
171{
172 //
173// Create Tree branches for the T0.
174
175 // Options:
176 //
177 // H Make a branch of TClonesArray of AliT0Hit's
178 // D Make a branch of TClonesArray of AliT0Digit's
179 //
180 // R Make a branch of AliT0RecPoints
181 //
182 char branchname[20];
183 sprintf(branchname,"%s",GetName());
184
185 const char *cH = strstr(option,"H");
186 const char *cD = strstr(option,"D");
187 const char *cR = strstr(option,"R");
cb5f5d4d 188 const char *cS = strstr(option,"S");
dc7ca31d 189
190 if (cH && fLoader->TreeH())
191 {
192 if (fHits == 0x0) fHits = new TClonesArray("AliT0hit", 405);
193 AliDetector::MakeBranch(option);
194 }
195
196
197 if (cD && fLoader->TreeD())
198 {
199 if (fDigits == 0x0) fDigits = new AliT0digit();
200 // MakeBranchInTree(fLoader->TreeD(), branchname,
201 // &fDigits, 405, 0);
202 fLoader->TreeD()->Branch(branchname,"AliT0digit",&fDigits,405,1);
203 // fLoader->TreeD()->Print();
204 }
205 if (cR && fLoader->TreeR())
206 {
207 if (fRecPoints == 0x0) fRecPoints = new AliT0RecPoint();
208 MakeBranchInTree(fLoader->TreeR(), branchname,
209 &fRecPoints, 405, 0);
210 }
cb5f5d4d 211 if (cS && fLoader->TreeS())
212 {
213 if (fDigits == 0x0) fDigits = new AliT0digit();
214 // MakeBranchInTree(fLoader->TreeD(), branchname,
215 // &fDigits, 405, 0);
216 fLoader->TreeS()->Branch(branchname,"AliT0digit",&fDigits,405,1);
217 // fLoader->TreeD()->Print();
218 }
dc7ca31d 219
220}
221
222//_____________________________________________________________________________
223void AliT0::ResetHits()
224{
94249139 225 //
226 //reset hits
227 //
dc7ca31d 228 AliDetector::ResetHits();
229
230}
231//____________________________________________________________________
232void AliT0::ResetDigits()
233{
234 //
235 // Reset number of digits and the digits array for this detector
236 //
237 if (fDigits) fDigits->Clear();
238}
239
240//_____________________________________________________________________________
241void AliT0::SetTreeAddress()
242{
243
cb5b8b21 244 TTree *treeH = fLoader->TreeH();
dc7ca31d 245
246 if (treeH)
247 {
248 if (fHits == 0x0) fHits = new TClonesArray("AliT0hit", 405);
249 }
250
251 AliDetector::SetTreeAddress();
252 TTree *treeD = fLoader->TreeD();
253 if (treeD) {
254 if (fDigits == 0x0) fDigits = new AliT0digit();
255 TBranch* branch = treeD->GetBranch ("T0");
256 if (branch) branch->SetAddress(&fDigits);
257 }
258
259 TTree *treeR = fLoader->TreeR();
260 if (treeR) {
261 if (fRecPoints == 0x0) fRecPoints = new AliT0RecPoint() ;
262 TBranch* branch = treeR->GetBranch ("T0");
263 if (branch) branch->SetAddress(&fRecPoints);
264 }
cb5f5d4d 265 // SDigitizer for Federico
266 TTree *treeS = fLoader->TreeS();
267 if (treeS) {
268 if (fDigits == 0x0) fDigits = new AliT0digit();
269 TBranch* branch = treeS->GetBranch ("T0");
270 if (branch) branch->SetAddress(&fDigits);
271 }
dc7ca31d 272
273}
274
275
276//_____________________________________________________________________________
277void AliT0::MakeBranchInTreeD(TTree *treeD, const char *file)
278{
279 //
280 // Create TreeD branches for the FMD
281 //
282 const Int_t kBufferSize = 4000;
283 char branchname[20];
284 sprintf(branchname,"%s",GetName());
285 if(treeD)
286 {
287 MakeBranchInTree(treeD, branchname,&fDigits, kBufferSize, file);
288 }
289}
290
c2d9de6d 291//_____________________________________________________________________________
292AliDigitizer* AliT0::CreateDigitizer(AliRunDigitizer* manager) const
293{
294 return new AliT0Digitizer(manager);
295}
dc7ca31d 296//____________________________________________________________________________
297void AliT0::Digits2Raw()
298{
299//
300// Starting from the T0 digits, writes the Raw Data objects
301//
302// AliT0Loader* pStartLoader = (AliT0Loader*)fLoader;
303 fLoader ->LoadDigits("read");
304 TTree* treeD = fLoader->TreeD();
305 if (!treeD) {
306 AliError("no digits tree");
307 return;
308 }
309 if (fDigits == 0x0) fDigits = new AliT0digit();
310
311 TBranch *branch = treeD->GetBranch("T0");
312 if (branch) {
313 branch->SetAddress(&fDigits);
314 }else{
315 AliError("Branch T0 DIGIT not found");
316 exit(111);
317 }
318 AliT0RawData rawWriter;
319 rawWriter.SetVerbose(0);
320
321 AliDebug(2,Form(" Formatting raw data for T0 "));
322 branch->GetEntry(0);
323 // rawWriter.RawDataT0(treeD->GetBranch("T0"));
324 rawWriter.RawDataT0(fDigits);
325
326
327 fLoader->UnloadDigits();
328
329}
e0bba6cc 330
331//____________________________________________________________________________
332void AliT0::Raw2Digits(AliRawReader *rawReader,TTree* digitsTree)
333{
334
335 //T0 raw data-> digits conversion
336 // reconstruct time information from raw data
337 // cout<<" AliT0::Raw2Digits(AliRawReader *rawReader,TTree* digitsTree) "<<
338 // rawReader<<" "<<digitsTree<<endl;
339
340
341 // AliT0RawReader myrawreader(rawReader,digitsTree);
342 AliT0RawReader myrawreader(rawReader);
343 if (!myrawreader.Next())
344 AliDebug(1,Form(" no raw data found!! %i", myrawreader.Next()));
345 Int_t allData[110][5];
346 for (Int_t i=0; i<110; i++) {
347 allData[i][0]=myrawreader.GetData(i,0);
348 }
349
350
c2337900 351 fDigits = new AliT0digit();
e0bba6cc 352 digitsTree->Branch("T0","AliT0digit",&fDigits,405,1);
353
354
355 TArrayI *timeLED = new TArrayI(24);
356 TArrayI * timeCFD = new TArrayI(24);
357 TArrayI *chargeQT0 = new TArrayI(24);
358 TArrayI *chargeQT1 = new TArrayI(24);
359
360 for (Int_t in=0; in<24; in++)
361 {
362 timeLED->AddAt(allData[in+1][0],in);
363 timeCFD->AddAt(allData[in+25][0],in);
364 chargeQT0->AddAt(allData[in+55][0],in);
365 chargeQT1->AddAt(allData[in+79][0],in);
366 AliDebug(2, Form(" readed Raw %i %i %i %i %i", in, timeLED->At(in),timeCFD->At(in),chargeQT0->At(in),chargeQT1->At(in)));
367 }
368
c41ceaac 369 fDigits->SetTimeCFD(*timeCFD);
370 fDigits->SetQT0(*chargeQT1);
e0bba6cc 371
c41ceaac 372 fDigits->SetTimeLED(*timeLED);
373 fDigits->SetQT1(*chargeQT1);
e0bba6cc 374
375 fDigits->SetMeanTime(allData[49][0]);
376 fDigits->SetDiffTime(allData[50][0]);
c41ceaac 377 fDigits->SetTimeBestA(allData[51][0]);
378 fDigits->SetTimeBestC(allData[52][0]);
e0bba6cc 379 digitsTree->Fill();
380 fDigits->Write();
381
382 delete timeCFD ;
383 delete chargeQT0;
384 delete timeLED ;
385 delete chargeQT1;
386
387
388}