Merge branch 'master' into TPCdev
[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
88cb7938 16/* $Id$ */
94831058 17
4ae5bbc4 18#include <Riostream.h>
d8b00ff7 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"
7537d03c 32
33/////////////////////////////////////////////////////////
34// //
35// //
36// //
37/////////////////////////////////////////////////////////
fe7d86eb 38
39using std::endl;
40using std::cout;
d8b00ff7 41ClassImp(AliITSsDigitize)
42//______________________________________________________________________
7537d03c 43AliITSsDigitize::AliITSsDigitize():
44fInit(kFALSE),
45fEnt(0),
46fEnt0(0),
47fITS(0),
48fRunLoader(0x0){
d8b00ff7 49 // Default constructor.
50 // Inputs:
51 // none.
52 // Outputs:
53 // none.
54 // Return:
55 // A zero-ed constructed AliITSsDigitize class.
56
d8b00ff7 57 fDet[0] = fDet[1] = fDet[2] = kTRUE;
d8b00ff7 58}
59//______________________________________________________________________
7537d03c 60AliITSsDigitize::AliITSsDigitize(const char* filename):
61fInit(),
62fEnt(0),
63fEnt0(0),
64fITS(0),
65fRunLoader(0x0){
d8b00ff7 66 // Standard constructor.
67 // Inputs:
68 // const char* filename filename containing the digits to be
69 // reconstructed. If filename = 0 (nil)
70 // then no file is opened but a file is
71 // assumed to already be opened. This
72 // already opened file will be used.
73 // Outputs:
74 // none.
75 // Return:
76 // A standardly constructed AliITSsDigitize class.
77
88cb7938 78 if(gAlice)
79 {
80 delete gAlice;
81 gAlice = 0;
82 }
83 fRunLoader = AliRunLoader::Open(filename);
84 fRunLoader->LoadgAlice();
85 fRunLoader->LoadHeader();
86
d8b00ff7 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
88cb7938 100 if(fRunLoader) delete fRunLoader;
d8b00ff7 101 fITS = 0;
102
103}
104//______________________________________________________________________
105Bool_t AliITSsDigitize::Init(){
106 // Class Initilizer.
107 // Inputs:
108 // none.
109 // Outputs:
110 // none.
111 // Return:
112 // kTRUE if no errors initilizing this class occurse else kFALSE
88cb7938 113 //Int_t nparticles;
114
d8b00ff7 115 fITS = (AliITS*) gAlice->GetDetector("ITS");
116 if(!fITS){
117 cout << "ITS not found aborting. fITS=" << fITS << endl;
118 fInit = kFALSE;
119 return fInit;
120 } // end if !fITS
121 if(!(fITS->GetITSgeom())){
122 cout << "ITSgeom not found aborting."<< endl;
123 fInit = kFALSE;
124 return fInit;
125 } // end if !GetITSgeom()
126 // Now ready to init.
127
128 fDet[0] = fDet[1] = fDet[2] = kTRUE;
129 fEnt0 = 0;
33c3c91a 130 fEnt = AliRunLoader::Instance()->GetNumberOfEvents();
d8b00ff7 131
88cb7938 132 AliLoader* loader = fRunLoader->GetLoader("ITSLoader");
133
134 if(!loader->TreeS()){
d8b00ff7 135 cout << "Having to create the SDigits Tree." << endl;
88cb7938 136 loader->MakeTree("S");
d8b00ff7 137 } // end if !gAlice->TreeS()
138 //make branch
139 fITS->MakeBranch("S");
140 fITS->SetTreeAddress();
88cb7938 141
142 fRunLoader->GetEvent(fEnt0);
d8b00ff7 143 // finished init.
144 fInit = InitSDig();
145 return fInit;
146}
147//______________________________________________________________________
7537d03c 148Bool_t AliITSsDigitize::InitSDig() const {
d8b00ff7 149 // Sets up SDigitization part of AliITSDetType..
150 // Inputs:
151 // none.
152 // Outputs:
153 // none.
154 // Return:
155 // none.
156
157 return kTRUE;
158}
159
160//______________________________________________________________________
f21fc003 161void AliITSsDigitize::Digitize(const Option_t *opt){
d8b00ff7 162 // Main SDigitization function.
163 // Inputs:
164 // Option_t * opt list of subdetector to digitize. =0 all.
165 // Outputs:
166 // none.
167 // Return:
168 // none.
169 Option_t *lopt;
e8c2bf0d 170 Bool_t condition =kFALSE;
171 if(opt){
172 if(strstr(opt,"All")||strstr(opt,"ALL")||strstr(opt,"ITS"))condition =kTRUE;
173 }
174 else{
175 condition = kTRUE;
176 }
177 if(condition){
d8b00ff7 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){
f21fc003 190 cout << "Initilization Failed, Can't run Digitize." << endl;
d8b00ff7 191 return;
192 } // end if !fInit
193
88cb7938 194 fITS->HitsToSDigits(fRunLoader->GetHeader()->GetEvent(),0,-1," ",lopt," ");
d8b00ff7 195}