1 /**************************************************************************
2 * Copyright(c) 2004, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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
22 //////////////////////////////////////////////////////////////////////////////
24 // This class contains the procedures simulation ADC signal for the
25 // Forward Multiplicity detector : SDigits->Digits
32 // - ADC count in this channel
39 // - Total energy deposited in the strip
40 // - ADC count in this channel
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.
46 // +---------------------+
47 // | AliFMDBaseDigitizer |
48 // +---------------------+
51 // +----------+---------+
53 // +-----------------+ +------------------+
54 // | AliFMDDigitizer | | AliFMDSDigitizer |
55 // +-----------------+ +------------------+
57 // +-------------------+
58 // | AliFMDSSDigitizer |
59 // +-------------------+
61 // These classes has several paramters:
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).
71 // The dymamic MIP range of the VA1_ALICE pre-amplifier chip
74 // The largest number plus one that can be stored in one
75 // channel in one time step in the ALTRO ADC chip.
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
88 // The shaping function of the VA1_ALICE is generally given by
90 // f(x) = A(1 - exp(-Bx))
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.
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.
99 // That results in the following algorithm:
102 // FOR charge IN pre-amp. charge train DO
103 // IF last < charge THEN
104 // f(t) = (charge - last) * (1 - exp(-B * t)) + last
106 // f(t) = (last - charge) * exp(-B * t) + charge)
108 // FOR i IN # samples DO
109 // adc_i = f(i / (# samples))
116 // pre-amp. charge train
117 // is a series of 128 charges read from the VA1_ALICE chip
120 // is the number of times the ALTRO ADC samples each of the 128
121 // charges from the pre-amp.
123 // Where Q is the total charge collected by the VA1_ALICE
124 // pre-amplifier. Q is then given by
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).
135 // The energy deposited per MIP is given by
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.
142 // The final ADC count is given by
146 // where P is the (randomized) pedestal (see MakePedestal)
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
152 // typedef AliFMDMap<std::pair<Float_t, UShort_t> > AliFMDEdepMap;
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.
164 // Latest changes by Christian Holm Christensen
166 //////////////////////////////////////////////////////////////////////////////
169 // | A(-1 + B + exp(-B))
170 // | f(x) dx = ------------------- = 1
174 // and B is the a parameter defined by the shaping time (fShapingTime).
176 // Solving the above equation, for A gives
179 // A = ----------------
182 // So, if we define the function g: [0,1] -> [0:1] by
185 // | Bu + exp(-Bu) - Bv - exp(-Bv)
186 // g(u,v) = | f(x) dx = -A -----------------------------
190 // we can evaluate the ALTRO sample of the VA1_ALICE pre-amp between
191 // any two times (u, v), by
194 // B Bu + exp(-Bu) - Bv - exp(-Bv)
195 // C = Q g(u,v) = - Q ---------------- -----------------------------
196 // -1 + B + exp(-B) B
198 // Bu + exp(-Bu) - Bv - exp(-Bv)
199 // = - Q -----------------------------
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
215 //====================================================================
216 ClassImp(AliFMDSSDigitizer)
218 //____________________________________________________________________
220 AliFMDSSDigitizer::SumContributions(AliFMD* fmd)
222 AliFMDDebug(1, ("Runnin our version of SumContributions"));
224 // Sum energy deposited contributions from each hit in a cache
227 Fatal("SumContributions", "no run loader");
229 // Clear array of deposited energies
232 // Get the FMD loader
233 AliLoader* inFMD = fRunLoader->GetLoader("FMDLoader");
235 inFMD->LoadSDigits("READ");
237 // Get the tree of hits
238 TTree* sdigitsTree = inFMD->TreeS();
241 // inFMD->LoadSDigits("READ");
242 // sdigitsTree = inFMD->TreeH();
243 AliError("No sdigit tree from manager");
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");
251 // Get a list of hits from the FMD manager
252 TClonesArray *fmdSDigits = fmd->SDigits();
254 // Get number of entries in the tree
255 Int_t nevents = Int_t(sdigitsTree->GetEntries());
257 AliFMDParameters* param = AliFMDParameters::Instance();
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);
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));
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));
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));
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));
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
306 AliFMDDebug(3, ("Size of cache: %d bytes, read %d bytes",
307 sizeof(fEdep), read));
310 //____________________________________________________________________