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