Line data Source code
1 : /**************************************************************************
2 : * Copyright(c) 1998-2000, 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 : * Produde digits from hits
19 : * digits is TObject and includes
20 : * We are writing array if C & A TDC
21 : * C & A ADC (will need for slow simulation)
22 : * TOF first particle C & A
23 : * mean time and time difference (vertex position)
24 : *
25 : * Alla.Maevskaya@cern.ch
26 : ****************************************************************/
27 :
28 :
29 : #include <TArrayI.h>
30 : #include <TFile.h>
31 : #include <TGraph.h>
32 : #include <TH1F.h>
33 : #include <TMath.h>
34 : #include <TRandom.h>
35 : #include <TTree.h>
36 :
37 : #include "AliLog.h"
38 : #include "AliFITDigitizer.h"
39 : #include "AliFIT.h"
40 : #include "AliFITHits.h"
41 : #include "AliFITDigit.h"
42 : #include "AliDigitizationInput.h"
43 : #include "AliRun.h"
44 : #include <AliLoader.h>
45 : #include <AliRunLoader.h>
46 : #include <stdlib.h>
47 :
48 4 : ClassImp(AliFITDigitizer)
49 :
50 : //___________________________________________
51 0 : AliFITDigitizer::AliFITDigitizer() :AliDigitizer(),
52 0 : fFIT(0),
53 0 : fHits(0),
54 0 : fDigits(0),
55 0 : fNdigits(0)
56 0 : {
57 : // Default ctor - don't use it
58 :
59 0 : }
60 :
61 : //___________________________________________
62 : AliFITDigitizer::AliFITDigitizer(AliDigitizationInput* digInput)
63 0 : :AliDigitizer(digInput),
64 0 : fFIT(0),
65 0 : fHits(0),
66 0 : fDigits(0),
67 0 : fNdigits(0)
68 0 : {
69 : // ctor which should be used
70 :
71 0 : }
72 :
73 :
74 : //------------------------------------------------------------------------
75 : AliFITDigitizer::~AliFITDigitizer()
76 0 : {
77 : // Destructor
78 :
79 0 : AliDebug(1,"FIT");
80 :
81 0 : }
82 :
83 : //------------------------------------------------------------------------
84 : Bool_t AliFITDigitizer::Init()
85 : {
86 : // Initialization
87 0 : AliDebug(1," Init");
88 0 : return kTRUE;
89 :
90 : }
91 :
92 : //---------------------------------------------------------------------
93 : void AliFITDigitizer::Digitize(Option_t* /*option*/)
94 : {
95 :
96 : /*
97 : Produde digits from hits
98 : digits is TObject and includes
99 : We are writing array if C & A for each channel CFD, LED, QT0 and QT1
100 : C & A ADC (will need for slow simulation)
101 : */
102 :
103 :
104 :
105 : //output loader
106 0 : AliDebug(1,"start...");
107 : //input loader
108 : //
109 : // From hits to digits
110 : //
111 :
112 0 : AliRunLoader *outRL = AliRunLoader::GetRunLoader(fDigInput->GetOutputFolderName());
113 0 : AliLoader * outFitLoader = outRL->GetLoader("FITLoader");
114 :
115 0 : fFIT = static_cast<AliFIT*>(gAlice->GetDetector("FIT"));
116 0 : if (!fFIT) {
117 0 : AliError("Can not get FIT from gAlice");
118 0 : return;
119 : }
120 0 : fFIT->ResetDigits();
121 :
122 0 : DigitizeHits();
123 :
124 : //load digits
125 0 : outFitLoader->LoadDigits("UPDATE");
126 0 : TTree *treeD = outFitLoader->TreeD();
127 0 : if (treeD == 0x0) {
128 0 : outFitLoader->MakeTree("D");
129 0 : treeD = outFitLoader->TreeD();
130 0 : }
131 0 : treeD->Reset();
132 0 : fFIT = (AliFIT*)outRL ->GetAliRun()->GetDetector("FIT");
133 : // Make a branch in the tree
134 0 : fFIT->MakeBranch("D");
135 0 : treeD->Fill();
136 :
137 0 : outFitLoader->WriteDigits("OVERWRITE");
138 0 : fFIT->ResetDigits();
139 0 : outFitLoader->UnloadDigits();
140 0 : }
141 : //____________________________________________________________________________
142 : void AliFITDigitizer::DigitizeHits()
143 : {
144 :
145 : Int_t hit, nhits;
146 0 : Float_t time[240], besttime[240];
147 0 : Int_t countE[240];
148 : Int_t timeCFD, timeLED, timeQT1, timeQT0;
149 :
150 : Int_t threshold = 0; //photoelectrons
151 : Float_t channelWidth = 24.4 ;
152 : Int_t pmt, mcp, volume, qt;
153 : //eqailized distance from IP
154 : Float_t zdetC = 84;
155 : Float_t zdetA = 335.;
156 : Float_t c = 0.0299792458; // cm/ps
157 0 : Float_t eqdistance = (zdetA - zdetC) /c;
158 : Float_t ph2Mip = 318;
159 :
160 : AliFITHits *startHit;
161 : TBranch *brHits=0;
162 :
163 0 : Int_t nFiles=fDigInput->GetNinputs();
164 0 : for (Int_t inputFile=0; inputFile<nFiles; inputFile++) {
165 0 : if (inputFile < nFiles-1) {
166 0 : AliWarning(Form("ignoring input stream %d", inputFile));
167 0 : continue;
168 : }
169 :
170 0 : for (Int_t i0=0; i0<240; i0++)
171 : {
172 0 : time[i0]=besttime[i0]=999999; countE[i0]=0;
173 : }
174 0 : AliRunLoader * inRL = AliRunLoader::GetRunLoader(fDigInput->GetInputFolderName(inputFile));
175 0 : AliLoader * fitLoader = inRL->GetLoader("FITLoader");
176 0 : if (!inRL->GetAliRun()) inRL->LoadgAlice();
177 : Int_t numpmt;
178 : //read Hits
179 0 : fitLoader->LoadHits("READ");//probably it is necessary to load them before
180 0 : fHits = fFIT->Hits ();
181 0 : TTree *th = fitLoader->TreeH();
182 0 : brHits = th->GetBranch("FIT");
183 0 : if (brHits) {
184 0 : fFIT->SetHitsAddressBranch(brHits);
185 : }else{
186 0 : AliWarning("Branch FIT hit not found for this event");
187 0 : continue;
188 : }
189 0 : Int_t ntracks = (Int_t) th->GetEntries();
190 0 : if (ntracks<=0) return;
191 : // Start loop on tracks in the hits containers
192 0 : for (Int_t track=0; track<ntracks;track++) {
193 0 : brHits->GetEntry(track);
194 0 : nhits = fHits->GetEntriesFast();
195 0 : for (hit=0;hit<nhits;hit++)
196 : {
197 0 : startHit = (AliFITHits*) fHits->UncheckedAt(hit);
198 0 : if (!startHit) {
199 0 : AliError("The unchecked hit doesn't exist");
200 0 : break;
201 : }
202 0 : Float_t ipart = startHit->Particle();
203 0 : if (ipart<49) continue;
204 0 : pmt = startHit->Pmt();
205 0 : mcp = startHit->MCP();
206 0 : volume = startHit->Volume();
207 0 : if(volume==2) continue;
208 0 : Float_t z = startHit->Z();
209 0 : numpmt= 4*mcp + pmt;
210 0 : besttime[numpmt] = startHit->Time();
211 0 : if(besttime[numpmt]<time[numpmt]) time[numpmt]=besttime[numpmt];
212 0 : countE[numpmt]++;
213 0 : } //hits loop
214 : } //track loop
215 :
216 0 : for (Int_t ipmt=0; ipmt<240; ipmt++)
217 : {
218 0 : if (countE[ipmt]>threshold && time[ipmt]<50000 && time[ipmt]>0 ) {
219 : //fill ADC
220 : // QTC procedure:
221 : // 1MIP ->318phe ;
222 0 : qt= 1000* countE[ipmt] /ph2Mip; // 318 ph/Mip
223 : // fill TDC
224 0 : if (ipmt>95) time[ipmt] = time[ipmt] + eqdistance;
225 0 : timeCFD = Int_t (gRandom->Gaus(time[ipmt], 50)/channelWidth );
226 0 : timeLED = Int_t (time[ipmt]/channelWidth );
227 : timeQT0 = 0;
228 : timeQT1 = qt ;
229 0 : AliDebug(1,Form("Digits::::: numpmt %i time CFD %i QTC %i :: counts %i \n ", ipmt, timeCFD, timeQT1, countE[ipmt]) );
230 0 : fFIT-> AddDigit(ipmt, timeCFD, timeLED, timeQT0, timeQT1, 0);
231 0 : } //hitted PMTs
232 : } //pmt loop
233 0 : fitLoader->UnloadHits();
234 :
235 0 : }
236 0 : }
237 :
238 : //____________________________________________________________________________
239 : void AliFITDigitizer::AddDigit(Int_t npmt,
240 : Int_t timeCFD, Int_t timeLED, Int_t timeQT0,
241 : Int_t timeQT1)
242 : {
243 :
244 : // Adds Digit
245 :
246 0 : TClonesArray &ldigits = *fDigits;
247 :
248 0 : new(ldigits[fNdigits++]) AliFITDigit(npmt,
249 : timeCFD, timeLED, timeQT0, timeQT1);
250 :
251 0 : }
252 : //____________________________________________________________________________
253 : void AliFITDigitizer::ResetDigits()
254 : {
255 :
256 : // Clears Digits
257 :
258 0 : fNdigits = 0;
259 0 : if (fDigits) fDigits->Clear();
260 0 : }
|