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