Line data Source code
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 4 : ClassImp(AliFIT)
54 :
55 : //static AliFITdigit *digits;
56 :
57 : //_____________________________________________________________________________
58 : AliFIT::AliFIT()
59 0 : : AliDetector(),
60 0 : fIdSens(0)
61 : /* , fDigits(NULL)*/
62 0 : {
63 : //
64 : // Default constructor for class AliFIT
65 : //
66 0 : fIshunt = 1;
67 0 : fHits = 0;
68 0 : fDigits = new TClonesArray("AliFITDigit",100); // from AliDetector
69 0 : fNdigits = 0;
70 0 : }
71 :
72 : //_____________________________________________________________________________
73 : AliFIT::AliFIT(const char *name, const char *title)
74 0 : : AliDetector(name,title),
75 0 : fIdSens(0)
76 : /* , fDigits(new AliFITDigit())*/
77 0 : {
78 : //
79 : // Standard constructor for T0 Detector
80 : //
81 : //
82 : // Initialise Hit array
83 0 : AliMC* mc = gAlice->GetMCApp();
84 0 : if( mc && mc->GetHitLists() ) {
85 0 : fHits = new TClonesArray("AliFITHits",100); // from AliDetector
86 0 : mc->AddHitList(fHits);
87 : }
88 :
89 0 : fNdigits = 0;
90 0 : fDigits = new TClonesArray("AliFITDigit",100); // from AliDetector
91 0 : fIshunt = 1;
92 : // fIdSens = 0;
93 : //PH SetMarkerColor(kRed);
94 0 : }
95 :
96 : //_____________________________________________________________________________
97 0 : AliFIT::~AliFIT() {
98 :
99 : //destructor
100 0 : if (fHits) {
101 0 : fHits->Delete();
102 0 : 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 0 : }
117 :
118 : //_____________________________________________________________________________
119 : void AliFIT::AddHit(Int_t track, Int_t *vol, Float_t *hits)
120 : {
121 : //
122 : // Add a FIT hit
123 : //
124 0 : TClonesArray &lhits = *fHits;
125 0 : new(lhits[fNhits++]) AliFITHits(fIshunt,track,vol,hits);
126 0 : }
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 0 : TClonesArray &ldigits = *fDigits;
136 0 : new(ldigits[fNdigits++]) AliFITDigit( npmt,timeCFD, timeLED, timeQT0, timeQT1, labels);
137 0 : }
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 0 : printf("\n%s: ",ClassName());
149 0 : for(i=0;i<35;i++) printf("*");
150 0 : printf(" FIT_INIT ");
151 0 : for(i=0;i<35;i++) printf("*");
152 0 : printf("\n%s: ",ClassName());
153 : //
154 : // Here the T0 initialisation code (if any!)
155 0 : for(i=0;i<80;i++) printf("*");
156 0 : printf("\n");
157 : // }
158 0 : }
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 0 : TString branchname = Form("%s", GetName());
177 :
178 0 : const char *cH = strstr(option,"H");
179 0 : const char *cD = strstr(option,"D");
180 0 : const char *cS = strstr(option,"S");
181 :
182 0 : if (cH && fLoader->TreeH())
183 : {
184 0 : if (fHits == 0x0) fHits = new TClonesArray("AliFITHits", 405);
185 0 : AliDetector::MakeBranch(option);
186 : }
187 0 : if (cD && fLoader->TreeD())
188 : {
189 0 : MakeBranchInTree(fLoader->TreeD(), GetName(),
190 0 : &fDigits, 100, 0)->SetAddress(&fDigits);
191 : // fLoader->TreeD()->Branch(branchname.Data(),"AliFITDigit",fDigits);
192 : }
193 0 : if (cS && fLoader->TreeS())
194 : {
195 0 : MakeBranchInTree(fLoader->TreeD(), branchname,
196 0 : &fDigits, 405, 0);
197 : // fLoader->TreeS()->Branch(branchname,"AliFITDigit",&fDigits);
198 : }
199 :
200 0 : }
201 :
202 : //_____________________________________________________________________________
203 : void AliFIT::ResetHits()
204 : {
205 : //
206 : //reset hits
207 : //
208 0 : AliDetector::ResetHits();
209 :
210 0 : }
211 : //____________________________________________________________________
212 : void AliFIT::ResetDigits()
213 : {
214 : //
215 : // Reset number of digits and the digits array for this detector
216 : //
217 0 : if (fDigits) fDigits->Clear();
218 0 : fNdigits = 0;
219 0 : }
220 :
221 : //_____________________________________________________________________________
222 : void AliFIT::SetTreeAddress()
223 : {
224 :
225 0 : TTree *treeH = fLoader->TreeH();
226 :
227 0 : if (treeH)
228 : {
229 0 : if (fHits == 0x0) fHits = new TClonesArray("AliFITHits", 405);
230 : }
231 :
232 0 : AliDetector::SetTreeAddress();
233 0 : TTree *treeD = fLoader->TreeD();
234 0 : if (treeD) {
235 0 : if (fDigits == 0x0) fDigits = new TClonesArray("AliFITDigit",100);
236 0 : TBranch* branch = treeD->GetBranch ("FIT");
237 0 : if (branch) branch->SetAddress(&fDigits);
238 0 : }
239 :
240 : // SDigitizer for Federico
241 0 : TTree *treeS = fLoader->TreeS();
242 0 : if (treeS) {
243 : // if (fDigits == 0x0) fDigits = new AliFITDigit();
244 0 : TBranch* branch = treeS->GetBranch ("FIT");
245 0 : if (branch) branch->SetAddress(&fDigits);
246 0 : }
247 :
248 0 : }
249 :
250 :
251 : //_____________________________________________________________________________
252 : AliDigitizer* AliFIT::CreateDigitizer(AliDigitizationInput* digInput) const
253 : {
254 :
255 0 : return new AliFITDigitizer(digInput);
256 0 : }
257 :
258 : //-------------------------------------------------------------------
259 : void AliFIT::Digits2Raw()
260 : {
261 : //
262 : // Starting from the FIT digits, writes the Raw Data objects
263 : //
264 :
265 0 : fLoader ->LoadDigits("read");
266 0 : TTree* treeD = fLoader->TreeD();
267 0 : if (!treeD) {
268 0 : AliError("no digits tree");
269 0 : return;
270 : }
271 0 : TBranch *branch = treeD->GetBranch("FIT");
272 :
273 0 : AliFITRawData rawWriter;
274 0 : rawWriter.SetVerbose(10);
275 :
276 0 : AliDebug(2,Form(" Formatting raw data for FIT "));
277 0 : treeD->GetEntry(0);
278 0 : rawWriter.RawDataFIT(branch);
279 :
280 :
281 0 : fLoader->UnloadDigits();
282 :
283 0 : }
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 0 : TClonesArray* digits = new TClonesArray ("AliFITDigit", 100);
293 0 : digitsTree->Branch("FIT", &digits);
294 :
295 :
296 0 : AliFITRawReader myrawreader(rawReader);
297 0 : if (!myrawreader.Next())
298 0 : AliDebug(1,Form(" no raw data found!! %i", myrawreader.Next()));
299 :
300 0 : Int_t allData[500];
301 0 : for (Int_t i=0; i<500; i++) allData[i]=0;
302 0 : for (Int_t i=0; i<500; i++)
303 0 : if(myrawreader.GetData(i)>0) allData[i]=myrawreader.GetData(i);
304 :
305 : Int_t timeCFD, timeLED, timeQT1, timeQT0;
306 0 : for (Int_t ipmt=0; ipmt<160; ipmt++) {
307 0 : if(allData[ipmt]>0) {
308 : timeCFD = allData[ipmt];
309 : timeLED = allData[ipmt];
310 0 : timeQT0= allData[ipmt+160];
311 0 : timeQT1 = allData[ipmt+320];
312 0 : AddDigit(ipmt, timeCFD, timeLED, timeQT0, timeQT1, 0);
313 : }
314 : }
315 :
316 :
317 :
318 0 : digitsTree->Fill();
319 0 : GetLoader()->WriteDigits("OVERWRITE");//write out digits
320 0 : ResetDigits();
321 :
322 0 : }
|