]>
Commit | Line | Data |
---|---|---|
9ed4b180 | 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$ */ |
9ed4b180 | 17 | |
18 | #include <stdlib.h> | |
4ae5bbc4 | 19 | #include <Riostream.h> |
9ed4b180 | 20 | #include <TObjArray.h> |
21 | #include <TTree.h> | |
22 | #include <TBranch.h> | |
23 | ||
24 | #include <AliRun.h> | |
25 | #include <AliRunDigitizer.h> | |
26 | ||
27 | #include "AliITSDigitizer.h" | |
28 | #include "AliITShit.h" | |
29 | #include "AliITSmodule.h" | |
30 | #include "AliITSsimulation.h" | |
31 | #include "AliITSDetType.h" | |
32 | #include "AliITSgeom.h" | |
33 | ||
34 | ClassImp(AliITSDigitizer) | |
35 | ||
36 | //______________________________________________________________________ | |
37 | AliITSDigitizer::AliITSDigitizer() : AliDigitizer(){ | |
38 | // Default constructor. Assign fITS since it is never written out from | |
39 | // here. | |
40 | // Inputs: | |
41 | // Option_t * opt Not used | |
42 | // Outputs: | |
43 | // none. | |
44 | // Return: | |
45 | // A blank AliITSDigitizer class. | |
46 | ||
47 | fITS = 0; | |
48 | } | |
49 | //______________________________________________________________________ | |
50 | AliITSDigitizer::AliITSDigitizer(AliRunDigitizer *mngr) : AliDigitizer(mngr){ | |
51 | // Standard constructor. Assign fITS since it is never written out from | |
52 | // here. | |
53 | // Inputs: | |
54 | // Option_t * opt Not used | |
55 | // Outputs: | |
56 | // none. | |
57 | // Return: | |
58 | // An AliItSDigitizer class. | |
59 | ||
60 | fITS = 0; | |
61 | } | |
62 | //______________________________________________________________________ | |
63 | AliITSDigitizer::~AliITSDigitizer(){ | |
64 | // Default destructor. | |
65 | // Inputs: | |
66 | // Option_t * opt Not used | |
67 | // Outputs: | |
68 | // none. | |
69 | // Return: | |
70 | // none. | |
71 | ||
72 | fITS = 0; // don't delete fITS. Done else where. | |
73 | } | |
74 | ||
75 | //______________________________________________________________________ | |
76 | Bool_t AliITSDigitizer::Init(){ | |
77 | // Iniliztion | |
78 | // Inputs: | |
79 | // none. | |
80 | // Outputs: | |
81 | // none. | |
82 | // Return: | |
83 | // none. | |
84 | ||
85 | // if(GetHits()) fITS->fHits = new TClonesArray("AliITSHit",1000); | |
86 | return kTRUE; | |
87 | } | |
88 | //______________________________________________________________________ | |
89 | void AliITSDigitizer::Exec(Option_t* opt){ | |
90 | // Main digitizing function. | |
91 | // Inputs: | |
92 | // Option_t * opt list of subdetector to digitize. =0 all. | |
93 | // Outputs: | |
94 | // none. | |
95 | // Return: | |
96 | // none. | |
97 | Int_t size=0,ifls=0,trk=0,ntracks=0,h=0,nhit=0; | |
98 | TTree *treeH=0; | |
99 | TBranch *brchHits=0; | |
100 | AliITShit *itsHit=0; | |
101 | char name[20] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; | |
102 | char *all; | |
103 | const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"), | |
104 | strstr(opt,"SSD")}; | |
105 | if(!det[0] && !det[1] && !det[2]) all = "All"; | |
106 | else all = 0; | |
107 | AliITSsimulation *sim = 0; | |
108 | AliITSDetType *iDetType = 0; | |
109 | AliITSmodule *mod = 0; | |
110 | Int_t id=0,module=0,nfls=0,mask=0; | |
111 | static Bool_t setDef=kTRUE; | |
112 | ||
113 | if(!fITS) fITS = (AliITS*)(gAlice->GetDetector("ITS")); | |
114 | if(!(fITS->GetITSgeom())){ | |
115 | Warning("Exec","Need ITS geometry to be properly defined first."); | |
116 | return; // need transformations to do digitization. | |
117 | } // end if !GetITSgeom() | |
118 | if (setDef) fITS->SetDefaultSimulation(); | |
119 | setDef=kFALSE; | |
120 | sprintf(name,"%s",fITS->GetName()); | |
121 | if(!GetModules()) { | |
122 | fITS->InitModules(0,size); | |
123 | } // end if | |
124 | ||
125 | nfls = GetManager()->GetNinputs(); | |
126 | for(ifls=0;ifls<nfls;ifls++){ | |
127 | treeH = GetManager()->GetInputTreeH(ifls); | |
128 | if(!(treeH && GetHits())) continue; | |
129 | brchHits = treeH->GetBranch(name); | |
130 | if(brchHits){ | |
131 | GetHits()->Clear(); | |
132 | fITS->SetHitsAddressBranch(brchHits); | |
133 | } else{ | |
134 | Error("Exec","branch ITS not found"); | |
135 | } // end if brchHits | |
136 | ||
137 | ntracks = (Int_t) treeH->GetEntries(); | |
138 | for(trk=0;trk<ntracks;trk++){ | |
139 | GetHits()->Clear(); | |
140 | brchHits->GetEntry(trk); | |
141 | nhit = GetHits()->GetEntries(); | |
142 | mask = GetManager()->GetMask(ifls); | |
143 | for(h=0;h<nhit;h++){ | |
144 | itsHit = GetHit(h); | |
145 | mod = GetModule(itsHit->GetModule()); | |
146 | id = fITS->GetITSgeom()->GetModuleType(module); | |
147 | if (!all && !det[id]) continue; | |
148 | mod->AddHit(itsHit,trk+mask,h); | |
149 | } // end for h | |
150 | } // end for trk | |
151 | } // end for ifls | |
152 | ||
153 | // Digitize | |
154 | fITS->MakeBranchInTreeD(GetManager()->GetTreeD()); | |
155 | for(module=0;module<size;module++){ | |
156 | id = fITS->GetITSgeom()->GetModuleType(module); | |
157 | if (!all && !det[id]) continue; | |
158 | iDetType = fITS->DetType(id); | |
159 | sim = (AliITSsimulation*)iDetType->GetSimulationModel(); | |
160 | if (!sim) { | |
161 | Error("Exec","The simulation class was not instanciated!"); | |
162 | exit(1); | |
163 | } // end if !sim | |
164 | mod = GetModule(module); | |
165 | sim->DigitiseModule(mod,module,0); | |
166 | // fills all branches - wasted disk space | |
167 | GetManager()->GetTreeD()->Fill(); | |
168 | fITS->ResetDigits(); | |
169 | } // end for module | |
170 | ||
171 | fITS->ClearModules(); | |
172 | ||
173 | GetManager()->GetTreeD()->GetEntries(); | |
174 | GetManager()->GetTreeD()->Write(0,TObject::kOverwrite); | |
175 | // reset tree | |
176 | GetManager()->GetTreeD()->Reset(); | |
177 | } |