Small patch for file copying for special outputs in proof mode (M.Vala)
[u/mrichter/AliRoot.git] / FMD / AliFMDSSDigitizer.cxx
CommitLineData
bf14171f 1/**************************************************************************
2 * Copyright(c) 2004, 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/* $Id: AliFMDDigitizer.cxx 22496 2007-11-26 13:50:44Z cholm $ */
16/** @file AliFMDDigitizer.cxx
17 @author Christian Holm Christensen <cholm@nbi.dk>
18 @date Mon Mar 27 12:38:26 2006
19 @brief FMD Digitizers implementation
20 @ingroup FMD_sim
21*/
22//////////////////////////////////////////////////////////////////////////////
23//
24// This class contains the procedures simulation ADC signal for the
25// Forward Multiplicity detector : SDigits->Digits
26//
27// Digits consists of
28// - Detector #
29// - Ring ID
30// - Sector #
31// - Strip #
32// - ADC count in this channel
33//
34// Digits consists of
35// - Detector #
36// - Ring ID
37// - Sector #
38// - Strip #
39// - Total energy deposited in the strip
40// - ADC count in this channel
41//
42// As the Digits and SDigits have so much in common, the classes
43// AliFMDDigitizer and AliFMDSDigitizer are implemented via a base
44// class AliFMDBaseDigitizer.
45//
46// +---------------------+
47// | AliFMDBaseDigitizer |
48// +---------------------+
49// ^
50// |
51// +----------+---------+
52// | |
53// +-----------------+ +------------------+
54// | AliFMDDigitizer | | AliFMDSDigitizer |
55// +-----------------+ +------------------+
56// |
57// +-------------------+
58// | AliFMDSSDigitizer |
59// +-------------------+
60//
61// These classes has several paramters:
62//
63// fPedestal
64// fPedestalWidth
65// (Only AliFMDDigitizer)
66// Mean and width of the pedestal. The pedestal is simulated
67// by a Guassian, but derived classes my override MakePedestal
68// to simulate it differently (or pick it up from a database).
69//
70// fVA1MipRange
71// The dymamic MIP range of the VA1_ALICE pre-amplifier chip
72//
73// fAltroChannelSize
74// The largest number plus one that can be stored in one
75// channel in one time step in the ALTRO ADC chip.
76//
77// fSampleRate
78// How many times the ALTRO ADC chip samples the VA1_ALICE
79// pre-amplifier signal. The VA1_ALICE chip is read-out at
80// 10MHz, while it's possible to drive the ALTRO chip at
81// 25MHz. That means, that the ALTRO chip can have time to
82// sample each VA1_ALICE signal up to 2 times. Although it's
83// not certain this feature will be used in the production,
84// we'd like have the option, and so it should be reflected in
85// the code.
86//
87//
88// The shaping function of the VA1_ALICE is generally given by
89//
90// f(x) = A(1 - exp(-Bx))
91//
92// where A is the total charge collected in the pre-amp., and B is a
93// paramter that depends on the shaping time of the VA1_ALICE circut.
94//
95// When simulating the shaping function of the VA1_ALICe
96// pre-amp. chip, we have to take into account, that the shaping
97// function depends on the previous value of read from the pre-amp.
98//
99// That results in the following algorithm:
100//
101// last = 0;
102// FOR charge IN pre-amp. charge train DO
103// IF last < charge THEN
104// f(t) = (charge - last) * (1 - exp(-B * t)) + last
105// ELSE
106// f(t) = (last - charge) * exp(-B * t) + charge)
107// ENDIF
108// FOR i IN # samples DO
109// adc_i = f(i / (# samples))
110// DONE
111// last = charge
112// DONE
113//
114// Here,
115//
116// pre-amp. charge train
117// is a series of 128 charges read from the VA1_ALICE chip
118//
119// # samples
120// is the number of times the ALTRO ADC samples each of the 128
121// charges from the pre-amp.
122//
123// Where Q is the total charge collected by the VA1_ALICE
124// pre-amplifier. Q is then given by
125//
126// E S
127// Q = - -
128// e R
129//
130// where E is the total energy deposited in a silicon strip, R is the
131// dynamic range of the VA1_ALICE pre-amp (fVA1MipRange), e is the
132// energy deposited by a single MIP, and S ALTRO channel size in each
133// time step (fAltroChannelSize).
134//
135// The energy deposited per MIP is given by
136//
137// e = M * rho * w
138//
139// where M is the universal number 1.664, rho is the density of
140// silicon, and w is the depth of the silicon sensor.
141//
142// The final ADC count is given by
143//
144// C' = C + P
145//
146// where P is the (randomized) pedestal (see MakePedestal)
147//
148// This class uses the class template AliFMDMap<Type> to make an
149// internal cache of the energy deposted of the hits. The class
150// template is instantasized as
151//
152// typedef AliFMDMap<std::pair<Float_t, UShort_t> > AliFMDEdepMap;
153//
154// The first member of the values is the summed energy deposition in a
155// given strip, while the second member of the values is the number of
156// hits in a given strip. Using the second member, it's possible to
157// do some checks on just how many times a strip got hit, and what
158// kind of error we get in our reconstructed hits. Note, that this
159// information is currently not written to the digits tree. I think a
160// QA (Quality Assurance) digit tree is better suited for that task.
161// However, the information is there to be used in the future.
162//
163//
164// Latest changes by Christian Holm Christensen
165//
166//////////////////////////////////////////////////////////////////////////////
167
168// /1
169// | A(-1 + B + exp(-B))
170// | f(x) dx = ------------------- = 1
171// | B
172// / 0
173//
174// and B is the a parameter defined by the shaping time (fShapingTime).
175//
176// Solving the above equation, for A gives
177//
178// B
179// A = ----------------
180// -1 + B + exp(-B)
181//
182// So, if we define the function g: [0,1] -> [0:1] by
183//
184// / v
185// | Bu + exp(-Bu) - Bv - exp(-Bv)
186// g(u,v) = | f(x) dx = -A -----------------------------
187// | B
188// / u
189//
190// we can evaluate the ALTRO sample of the VA1_ALICE pre-amp between
191// any two times (u, v), by
192//
193//
194// B Bu + exp(-Bu) - Bv - exp(-Bv)
195// C = Q g(u,v) = - Q ---------------- -----------------------------
196// -1 + B + exp(-B) B
197//
198// Bu + exp(-Bu) - Bv - exp(-Bv)
199// = - Q -----------------------------
200// -1 + B + exp(-B)
201//
202
203#include <TTree.h> // ROOT_TTree
204#include "AliFMDDebug.h" // Better debug macros
205#include "AliFMDSSDigitizer.h" // ALIFMDSSDIGITIZER_H
206#include "AliFMD.h" // ALIFMD_H
207#include "AliFMDSDigit.h" // ALIFMDDIGIT_H
208#include "AliFMDDigit.h" // ALIFMDDIGIT_H
209#include "AliFMDParameters.h" // ALIFMDPARAMETERS_H
210#include <AliRunDigitizer.h> // ALIRUNDIGITIZER_H
211#include <AliRun.h> // ALIRUN_H
212#include <AliLoader.h> // ALILOADER_H
213#include <AliRunLoader.h> // ALIRUNLOADER_H
214
215//====================================================================
216ClassImp(AliFMDSSDigitizer)
217
218//____________________________________________________________________
219void
220AliFMDSSDigitizer::SumContributions(AliFMD* fmd)
221{
222 AliFMDDebug(1, ("Runnin our version of SumContributions"));
223
224 // Sum energy deposited contributions from each hit in a cache
225 // (fEdep).
226 if (!fRunLoader)
227 Fatal("SumContributions", "no run loader");
228
229 // Clear array of deposited energies
230 fEdep.Reset();
231
232 // Get the FMD loader
233 AliLoader* inFMD = fRunLoader->GetLoader("FMDLoader");
234 // And load the hits
235 inFMD->LoadSDigits("READ");
236
237 // Get the tree of hits
238 TTree* sdigitsTree = inFMD->TreeS();
239 if (!sdigitsTree) {
240 // Try again
241 // inFMD->LoadSDigits("READ");
242 // sdigitsTree = inFMD->TreeH();
243 AliError("No sdigit tree from manager");
244 }
245
246 // Get the FMD branch
247 TBranch* sdigitsBranch = sdigitsTree->GetBranch("FMD");
248 if (sdigitsBranch) fmd->SetSDigitsAddressBranch(sdigitsBranch);
249 else AliFatal("Branch FMD hit not found");
250
251 // Get a list of hits from the FMD manager
252 TClonesArray *fmdSDigits = fmd->SDigits();
253
254 // Get number of entries in the tree
255 Int_t nevents = Int_t(sdigitsTree->GetEntries());
256
257 AliFMDParameters* param = AliFMDParameters::Instance();
258 Int_t read = 0;
259 // Loop over the events in the
260 for (Int_t event = 0; event < nevents; event++) {
261 // Read in entry number `event'
262 read += sdigitsBranch->GetEntry(event);
263
264 // Get the number of sdigits
265 Int_t nsdigits = fmdSDigits->GetEntries ();
266 AliFMDDebug(1, ("Got %5d SDigits", nsdigits));
267 for (Int_t sdigit = 0; sdigit < nsdigits; sdigit++) {
268 // Get the sdigit number `sdigit'
269 AliFMDSDigit* fmdSDigit =
270 static_cast<AliFMDSDigit*>(fmdSDigits->UncheckedAt(sdigit));
271
272 // Extract parameters
273 UShort_t detector = fmdSDigit->Detector();
274 Char_t ring = fmdSDigit->Ring();
275 UShort_t sector = fmdSDigit->Sector();
276 UShort_t strip = fmdSDigit->Strip();
277 Float_t edep = fmdSDigit->Edep();
278 // UShort_t minstrip = param->GetMinStrip(detector, ring, sector, strip);
279 // UShort_t maxstrip = param->GetMaxStrip(detector, ring, sector, strip);
280 // Check if strip is `dead'
281 AliFMDDebug(10, ("SDigit in FMD%d%c[%2d,%3d]=%f",
282 detector, ring, sector, strip, edep));
283 if (param->IsDead(detector, ring, sector, strip)) {
284 AliFMDDebug(5, ("FMD%d%c[%2d,%3d] is marked as dead",
285 detector, ring, sector, strip));
286 continue;
287 }
288 // Check if strip is out-side read-out range
289 // if (strip < minstrip || strip > maxstrip) {
290 // AliFMDDebug(5, ("FMD%d%c[%2d,%3d] is outside range [%3d,%3d]",
291 // detector,ring,sector,strip,minstrip,maxstrip));
292 // continue;
293 // }
294
295 // Give warning in case of double sdigit
296 if (fEdep(detector, ring, sector, strip).fEdep != 0)
297 AliFMDDebug(5, ("Double sdigit in %d%c(%d,%d)",
298 detector, ring, sector, strip));
299
300 // Sum energy deposition
301 fEdep(detector, ring, sector, strip).fEdep += edep;
302 fEdep(detector, ring, sector, strip).fN += 1;
303 // Add this to the energy deposited for this strip
304 } // sdigit loop
305 } // event loop
306 AliFMDDebug(3, ("Size of cache: %d bytes, read %d bytes",
307 sizeof(fEdep), read));
308}
309
310//____________________________________________________________________
311//
312// EOF
313//
314
315
316
317