New TTask method for creating SDigits from Hits.
[u/mrichter/AliRoot.git] / ITS / AliITSsDigitize.cxx
CommitLineData
d8b00ff7 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/*
17$Log$
18*/
19
20#include <TROOT.h>
21#include <TFile.h>
22#include <TSeqCollection.h>
23#include <TString.h>
24#include <TClonesArray.h>
25
26#include "AliHeader.h"
27#include "AliRun.h"
28
29#include "AliITS.h"
30#include "AliITSsDigitize.h"
31#include "AliITSgeom.h"
32
33ClassImp(AliITSsDigitize)
34//______________________________________________________________________
35AliITSsDigitize::AliITSsDigitize(){
36 // Default constructor.
37 // Inputs:
38 // none.
39 // Outputs:
40 // none.
41 // Return:
42 // A zero-ed constructed AliITSsDigitize class.
43
44 fFilename = "";
45 fFile = 0;
46 fITS = 0;
47 fDet[0] = fDet[1] = fDet[2] = kTRUE;
48 fInit = kFALSE;
49}
50//______________________________________________________________________
51AliITSsDigitize::AliITSsDigitize(const char* filename){
52 // Standard constructor.
53 // Inputs:
54 // const char* filename filename containing the digits to be
55 // reconstructed. If filename = 0 (nil)
56 // then no file is opened but a file is
57 // assumed to already be opened. This
58 // already opened file will be used.
59 // Outputs:
60 // none.
61 // Return:
62 // A standardly constructed AliITSsDigitize class.
63
64 fFilename = filename;
65
66 if(filename){
67 fFile = (TFile*)gROOT->GetListOfFiles()->FindObject(fFilename.Data());
68 if(fFile) fFile->Close();
69 fFile = new TFile(fFilename.Data(),"UPDATE");
70 //
71 if(gAlice) {
72 delete gAlice;
73 gAlice = 0;
74 }
75 gAlice = (AliRun*)fFile->Get("gAlice");
76 if(!gAlice) {
77 cout << "gAlice not found on file. Aborting." << endl;
78 fInit = kFALSE;
79 return;
80 } // end if !gAlice
81 } // end if !filename.
82
83 Init();
84}
85//______________________________________________________________________
86AliITSsDigitize::~AliITSsDigitize(){
87 // Default constructor.
88 // Inputs:
89 // none.
90 // Outputs:
91 // none.
92 // Return:
93 // A destroyed AliITSsDigitize class.
94
95 if(fFile) fFile->Close();
96 fFile = 0;
97 fITS = 0;
98
99}
100//______________________________________________________________________
101Bool_t AliITSsDigitize::Init(){
102 // Class Initilizer.
103 // Inputs:
104 // none.
105 // Outputs:
106 // none.
107 // Return:
108 // kTRUE if no errors initilizing this class occurse else kFALSE
109 Int_t nparticles;
110
111 fITS = (AliITS*) gAlice->GetDetector("ITS");
112 if(!fITS){
113 cout << "ITS not found aborting. fITS=" << fITS << endl;
114 fInit = kFALSE;
115 return fInit;
116 } // end if !fITS
117 if(!(fITS->GetITSgeom())){
118 cout << "ITSgeom not found aborting."<< endl;
119 fInit = kFALSE;
120 return fInit;
121 } // end if !GetITSgeom()
122 // Now ready to init.
123
124 fDet[0] = fDet[1] = fDet[2] = kTRUE;
125 fEnt0 = 0;
126 fEnt = gAlice->GetEventsPerRun();
127
128 if(!gAlice->TreeS()){
129 cout << "Having to create the SDigits Tree." << endl;
130 gAlice->MakeTree("S");
131 } // end if !gAlice->TreeS()
132 //make branch
133 fITS->MakeBranch("S");
134 fITS->SetTreeAddress();
135 nparticles = gAlice->GetEvent(fEnt0);
136
137 // finished init.
138 fInit = InitSDig();
139 return fInit;
140}
141//______________________________________________________________________
142Bool_t AliITSsDigitize::InitSDig(){
143 // Sets up SDigitization part of AliITSDetType..
144 // Inputs:
145 // none.
146 // Outputs:
147 // none.
148 // Return:
149 // none.
150
151 return kTRUE;
152}
153
154//______________________________________________________________________
155void AliITSsDigitize::Exec(const Option_t *opt){
156 // Main SDigitization function.
157 // Inputs:
158 // Option_t * opt list of subdetector to digitize. =0 all.
159 // Outputs:
160 // none.
161 // Return:
162 // none.
163 Option_t *lopt;
164// Int_t nparticles,evnt;
165
166 if(strstr(opt,"All")||strstr(opt,"ALL")||strstr(opt,"ITS")||opt==0){
167 fDet[0] = fDet[1] = fDet[2] = kTRUE;
168 lopt = "All";
169 }else{
170 fDet[0] = fDet[1] = fDet[2] = kFALSE;
171 if(strstr(opt,"SPD")) fDet[kSPD] = kTRUE;
172 if(strstr(opt,"SDD")) fDet[kSDD] = kTRUE;
173 if(strstr(opt,"SSD")) fDet[kSSD] = kTRUE;
174 if(fDet[kSPD] && fDet[kSDD] && fDet[kSSD]) lopt = "All";
175 else lopt = opt;
176 } // end if strstr(opt,...)
177
178 if(!fInit){
179 cout << "Initilization Failed, Can't run Exec." << endl;
180 return;
181 } // end if !fInit
182
183 fITS->HitsToSDigits(gAlice->GetHeader()->GetEvent(),0,-1," ",lopt," ");
184}