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