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