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