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