]>
Commit | Line | Data |
---|---|---|
c1c44db3 | 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 | // // | |
18 | // FIT ( Fast Interaction Trigger ) Detector // | |
19 | // This class contains the base procedures for the FIT // | |
20 | // detector // | |
21 | // // | |
22 | //Begin_Html | |
23 | /* | |
24 | <img src="gif/AliFITClass.gif"> | |
25 | </pre> | |
26 | <br clear=left> | |
27 | <font size=+2 color=red> | |
28 | <p>The responsible person for this module is | |
29 | <a href="mailto:Alla.Maevskaia@cern.ch">Alla Maevskaia</a>. | |
30 | </font> | |
31 | <pre> | |
32 | */ | |
33 | //End_Html | |
34 | // // | |
35 | // // | |
36 | /////////////////////////////////////////////////////////////////////////////// | |
37 | ||
38 | #include "TClonesArray.h" | |
39 | #include "TString.h" | |
40 | ||
41 | #include "AliLoader.h" | |
42 | #include "AliLog.h" | |
43 | #include "AliLog.h" | |
44 | #include "AliMC.h" | |
45 | #include "AliRun.h" | |
46 | #include "AliFIT.h" | |
47 | #include "AliFITDigitizer.h" | |
48 | #include "AliFITDigit.h" | |
49 | #include "AliFITHits.h" | |
50 | #include "AliFITRawData.h" | |
51 | #include "AliFITRawReader.h" | |
52 | ||
53 | ClassImp(AliFIT) | |
54 | ||
55 | //static AliFITdigit *digits; | |
56 | ||
57 | //_____________________________________________________________________________ | |
58 | AliFIT::AliFIT() | |
59 | : AliDetector(), | |
60 | fIdSens(0) | |
61 | /* , fDigits(NULL)*/ | |
62 | { | |
63 | // | |
64 | // Default constructor for class AliFIT | |
65 | // | |
66 | fIshunt = 1; | |
67 | fHits = 0; | |
68 | fDigits = new TClonesArray("AliFITDigit",100); // from AliDetector | |
69 | fNdigits = 0; | |
70 | } | |
71 | ||
72 | //_____________________________________________________________________________ | |
73 | AliFIT::AliFIT(const char *name, const char *title) | |
74 | : AliDetector(name,title), | |
75 | fIdSens(0) | |
76 | /* , fDigits(new AliFITDigit())*/ | |
77 | { | |
78 | // | |
79 | // Standard constructor for T0 Detector | |
80 | // | |
81 | // | |
82 | // Initialise Hit array | |
83 | AliMC* mc = gAlice->GetMCApp(); | |
84 | if( mc && mc->GetHitLists() ) { | |
85 | fHits = new TClonesArray("AliFITHits",100); // from AliDetector | |
86 | mc->AddHitList(fHits); | |
87 | } | |
88 | ||
89 | fNdigits = 0; | |
90 | fDigits = new TClonesArray("AliFITDigit",100); // from AliDetector | |
91 | fIshunt = 1; | |
92 | // fIdSens = 0; | |
93 | //PH SetMarkerColor(kRed); | |
94 | } | |
95 | ||
96 | //_____________________________________________________________________________ | |
97 | AliFIT::~AliFIT() { | |
98 | ||
99 | //destructor | |
100 | if (fHits) { | |
101 | fHits->Delete(); | |
102 | delete fHits; | |
103 | } | |
104 | /* | |
105 | if (fDigits) { | |
106 | fDigits->Delete(); | |
107 | delete fDigits; | |
108 | cout<<" delete fDigits; "<<endl; | |
109 | } | |
110 | if (fRecPoints) { | |
111 | fRecPoints ->Delete(); | |
112 | delete fRecPoints; | |
113 | cout<<" delete fRecPoints; "<<endl; | |
114 | } | |
115 | */ | |
116 | } | |
117 | ||
118 | //_____________________________________________________________________________ | |
119 | void AliFIT::AddHit(Int_t track, Int_t *vol, Float_t *hits) | |
120 | { | |
121 | // | |
122 | // Add a FIT hit | |
123 | // | |
124 | TClonesArray &lhits = *fHits; | |
125 | new(lhits[fNhits++]) AliFITHits(fIshunt,track,vol,hits); | |
126 | } | |
127 | ||
128 | //____________________________________________________________________________ | |
129 | void AliFIT::AddDigit(Int_t npmt, | |
130 | Int_t timeCFD, Int_t timeLED, Int_t timeQT0, | |
131 | Int_t timeQT1, Int_t *labels) | |
132 | { | |
133 | ||
134 | // Adds Digit | |
135 | TClonesArray &ldigits = *fDigits; | |
136 | new(ldigits[fNdigits++]) AliFITDigit( npmt,timeCFD, timeLED, timeQT0, timeQT1, labels); | |
137 | } | |
138 | ||
139 | ||
140 | //------------------------------------------------------------------------- | |
141 | void AliFIT::Init() | |
142 | { | |
143 | // | |
144 | // Initialis the T0 after it has been built | |
145 | Int_t i; | |
146 | // | |
147 | // if(AliLog::GetGlobalDebugLevel()>0) { | |
148 | printf("\n%s: ",ClassName()); | |
149 | for(i=0;i<35;i++) printf("*"); | |
150 | printf(" FIT_INIT "); | |
151 | for(i=0;i<35;i++) printf("*"); | |
152 | printf("\n%s: ",ClassName()); | |
153 | // | |
154 | // Here the T0 initialisation code (if any!) | |
155 | for(i=0;i<80;i++) printf("*"); | |
156 | printf("\n"); | |
157 | // } | |
158 | } | |
159 | ||
160 | //--------------------------------------------------------------------------- | |
161 | void AliFIT::MakeBranch(Option_t* option) | |
162 | { | |
163 | // | |
164 | // Create Tree branches for the T0. | |
165 | ||
166 | // Options: | |
167 | // | |
168 | // H Make a branch of TClonesArray of AliT0Hit's | |
169 | // D Make a branch of TClonesArray of AliT0Digit's | |
170 | // | |
171 | // R Make a branch of AliT0RecPointUps | |
172 | // | |
173 | // char branchname[20]; | |
174 | // sprintf(branchname,"%s",GetName()); | |
175 | // strncpy(branchname, GetName(), 20); | |
176 | TString branchname = Form("%s", GetName()); | |
177 | ||
178 | const char *cH = strstr(option,"H"); | |
179 | const char *cD = strstr(option,"D"); | |
180 | const char *cS = strstr(option,"S"); | |
181 | ||
182 | if (cH && fLoader->TreeH()) | |
183 | { | |
184 | if (fHits == 0x0) fHits = new TClonesArray("AliFITHits", 405); | |
185 | AliDetector::MakeBranch(option); | |
186 | } | |
187 | if (cD && fLoader->TreeD()) | |
188 | { | |
189 | MakeBranchInTree(fLoader->TreeD(), GetName(), | |
190 | &fDigits, 100, 0)->SetAddress(&fDigits); | |
191 | // fLoader->TreeD()->Branch(branchname.Data(),"AliFITDigit",fDigits); | |
192 | } | |
193 | if (cS && fLoader->TreeS()) | |
194 | { | |
195 | MakeBranchInTree(fLoader->TreeD(), branchname, | |
196 | &fDigits, 405, 0); | |
197 | // fLoader->TreeS()->Branch(branchname,"AliFITDigit",&fDigits); | |
198 | } | |
199 | ||
200 | } | |
201 | ||
202 | //_____________________________________________________________________________ | |
203 | void AliFIT::ResetHits() | |
204 | { | |
205 | // | |
206 | //reset hits | |
207 | // | |
208 | AliDetector::ResetHits(); | |
209 | ||
210 | } | |
211 | //____________________________________________________________________ | |
212 | void AliFIT::ResetDigits() | |
213 | { | |
214 | // | |
215 | // Reset number of digits and the digits array for this detector | |
216 | // | |
217 | if (fDigits) fDigits->Clear(); | |
218 | fNdigits = 0; | |
219 | } | |
220 | ||
221 | //_____________________________________________________________________________ | |
222 | void AliFIT::SetTreeAddress() | |
223 | { | |
224 | ||
225 | TTree *treeH = fLoader->TreeH(); | |
226 | ||
227 | if (treeH) | |
228 | { | |
229 | if (fHits == 0x0) fHits = new TClonesArray("AliFITHits", 405); | |
230 | } | |
231 | ||
232 | AliDetector::SetTreeAddress(); | |
233 | TTree *treeD = fLoader->TreeD(); | |
234 | if (treeD) { | |
235 | if (fDigits == 0x0) fDigits = new TClonesArray("AliFITDigit",100); | |
236 | TBranch* branch = treeD->GetBranch ("FIT"); | |
237 | if (branch) branch->SetAddress(&fDigits); | |
238 | } | |
239 | ||
240 | // SDigitizer for Federico | |
241 | TTree *treeS = fLoader->TreeS(); | |
242 | if (treeS) { | |
243 | // if (fDigits == 0x0) fDigits = new AliFITDigit(); | |
244 | TBranch* branch = treeS->GetBranch ("FIT"); | |
245 | if (branch) branch->SetAddress(&fDigits); | |
246 | } | |
247 | ||
248 | } | |
249 | ||
250 | ||
251 | //_____________________________________________________________________________ | |
252 | AliDigitizer* AliFIT::CreateDigitizer(AliDigitizationInput* digInput) const | |
253 | { | |
254 | ||
255 | return new AliFITDigitizer(digInput); | |
256 | } | |
257 | ||
258 | //------------------------------------------------------------------- | |
259 | void AliFIT::Digits2Raw() | |
260 | { | |
261 | // | |
262 | // Starting from the FIT digits, writes the Raw Data objects | |
263 | // | |
264 | ||
265 | fLoader ->LoadDigits("read"); | |
266 | TTree* treeD = fLoader->TreeD(); | |
267 | if (!treeD) { | |
268 | AliError("no digits tree"); | |
269 | return; | |
270 | } | |
271 | TBranch *branch = treeD->GetBranch("FIT"); | |
272 | ||
273 | AliFITRawData rawWriter; | |
274 | rawWriter.SetVerbose(10); | |
275 | ||
276 | AliDebug(2,Form(" Formatting raw data for FIT ")); | |
277 | treeD->GetEntry(0); | |
278 | rawWriter.RawDataFIT(branch); | |
279 | ||
280 | ||
281 | fLoader->UnloadDigits(); | |
282 | ||
283 | } | |
284 | ||
285 | //____________________________________________________________________________ | |
286 | void AliFIT::Raw2Digits(AliRawReader *rawReader,TTree* digitsTree) | |
287 | { | |
288 | ||
289 | //FIT raw data-> digits conversion | |
290 | // reconstruct time information from raw data | |
291 | ||
292 | TClonesArray* digits = new TClonesArray ("AliFITDigit", 100); | |
293 | digitsTree->Branch("FIT", &digits); | |
294 | ||
295 | ||
296 | AliFITRawReader myrawreader(rawReader); | |
297 | if (!myrawreader.Next()) | |
298 | AliDebug(1,Form(" no raw data found!! %i", myrawreader.Next())); | |
299 | ||
300 | Int_t allData[500]; | |
301 | for (Int_t i=0; i<500; i++) allData[i]=0; | |
302 | for (Int_t i=0; i<500; i++) | |
303 | if(myrawreader.GetData(i)>0) allData[i]=myrawreader.GetData(i); | |
304 | ||
305 | Int_t timeCFD, timeLED, timeQT1, timeQT0; | |
306 | for (Int_t ipmt=0; ipmt<160; ipmt++) { | |
307 | if(allData[ipmt]>0) { | |
308 | timeCFD = allData[ipmt]; | |
309 | timeLED = allData[ipmt]; | |
310 | timeQT0= allData[ipmt+160]; | |
311 | timeQT1 = allData[ipmt+320]; | |
312 | AddDigit(ipmt, timeCFD, timeLED, timeQT0, timeQT1, 0); | |
313 | } | |
314 | } | |
315 | ||
316 | ||
317 | ||
318 | digitsTree->Fill(); | |
319 | GetLoader()->WriteDigits("OVERWRITE");//write out digits | |
320 | ResetDigits(); | |
321 | ||
322 | } |