| 1 | /* ======================================================================== *\
|
|---|
| 2 | !
|
|---|
| 3 | ! *
|
|---|
| 4 | ! * This file is part of MARS, the MAGIC Analysis and Reconstruction
|
|---|
| 5 | ! * Software. It is distributed to you in the hope that it can be a useful
|
|---|
| 6 | ! * and timesaving tool in analyzing Data of imaging Cerenkov telescopes.
|
|---|
| 7 | ! * It is distributed WITHOUT ANY WARRANTY.
|
|---|
| 8 | ! *
|
|---|
| 9 | ! * Permission to use, copy, modify and distribute this software and its
|
|---|
| 10 | ! * documentation for any purpose is hereby granted without fee,
|
|---|
| 11 | ! * provided that the above copyright notice appear in all copies and
|
|---|
| 12 | ! * that both that copyright notice and this permission notice appear
|
|---|
| 13 | ! * in supporting documentation. It is provided "as is" without express
|
|---|
| 14 | ! * or implied warranty.
|
|---|
| 15 | ! *
|
|---|
| 16 | !
|
|---|
| 17 | ! Author(s): Thomas Bretz, 02/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
|
|---|
| 18 | ! Author(s): Hendrik Bartko, 01/2004 <mailto:hbartko@mppmu.mpg.de>
|
|---|
| 19 | ! Author(s): Markus Gaug, 09/2004 <mailto:markus@ifae.es>
|
|---|
| 20 | !
|
|---|
| 21 | ! Copyright: MAGIC Software Development, 2002-2004
|
|---|
| 22 | !
|
|---|
| 23 | !
|
|---|
| 24 | \* ======================================================================== */
|
|---|
| 25 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 26 | //
|
|---|
| 27 | // MExtractSlidingWindow
|
|---|
| 28 | //
|
|---|
| 29 | // Extracts the signal from a sliding window of size fHiGainWindowSize and
|
|---|
| 30 | // fLoGainWindowSize, respectively. The signal is the one which maximizes
|
|---|
| 31 | // the clock-noise and pedestal-corrected integral contents.
|
|---|
| 32 | //
|
|---|
| 33 | // The amplitude-weighted arrival time is calculated from the window with
|
|---|
| 34 | // the highest integral using the following formula:
|
|---|
| 35 | //
|
|---|
| 36 | // t = sum(s(i) * i) / sum(i)
|
|---|
| 37 | //
|
|---|
| 38 | // where i denotes the FADC slice index and s(i) the clock-noise and
|
|---|
| 39 | /// pedestal-corrected FADC value at slice index i. The sum runs over the
|
|---|
| 40 | // extraction window size.
|
|---|
| 41 | //
|
|---|
| 42 | // Call: SetRange(higainfirst, higainlast, logainfirst, logainlast)
|
|---|
| 43 | // to modify the ranges in which the window is allowed to move.
|
|---|
| 44 | //
|
|---|
| 45 | // Defaults are:
|
|---|
| 46 | //
|
|---|
| 47 | // fHiGainFirst = fgHiGainFirst = 0
|
|---|
| 48 | // fHiGainLast = fgHiGainLast = 14
|
|---|
| 49 | // fLoGainFirst = fgLoGainFirst = 2
|
|---|
| 50 | // fLoGainLast = fgLoGainLast = 14
|
|---|
| 51 | //
|
|---|
| 52 | // Call: SetWindowSize(windowhigain, windowlogain)
|
|---|
| 53 | // to modify the sliding window widths. Windows have to be an even number.
|
|---|
| 54 | // Odd numbers are possible since the clock-noise is corrected for.
|
|---|
| 55 | //
|
|---|
| 56 | // Defaults are:
|
|---|
| 57 | //
|
|---|
| 58 | // fHiGainWindowSize = 6
|
|---|
| 59 | // fLoGainWindowSize = 6
|
|---|
| 60 | //
|
|---|
| 61 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 62 | #include "MExtractTimeAndChargeSlidingWindow.h"
|
|---|
| 63 |
|
|---|
| 64 | #include "MPedestalPix.h"
|
|---|
| 65 |
|
|---|
| 66 | #include "MLog.h"
|
|---|
| 67 | #include "MLogManip.h"
|
|---|
| 68 |
|
|---|
| 69 | ClassImp(MExtractTimeAndChargeSlidingWindow);
|
|---|
| 70 |
|
|---|
| 71 | using namespace std;
|
|---|
| 72 |
|
|---|
| 73 | const Byte_t MExtractTimeAndChargeSlidingWindow::fgHiGainFirst = 2;
|
|---|
| 74 | const Byte_t MExtractTimeAndChargeSlidingWindow::fgHiGainLast = 16;
|
|---|
| 75 | const Byte_t MExtractTimeAndChargeSlidingWindow::fgLoGainFirst = 2;
|
|---|
| 76 | const Byte_t MExtractTimeAndChargeSlidingWindow::fgLoGainLast = 14;
|
|---|
| 77 | const Byte_t MExtractTimeAndChargeSlidingWindow::fgHiGainWindowSize = 6;
|
|---|
| 78 | const Byte_t MExtractTimeAndChargeSlidingWindow::fgLoGainWindowSize = 6;
|
|---|
| 79 | // --------------------------------------------------------------------------
|
|---|
| 80 | //
|
|---|
| 81 | // Default constructor.
|
|---|
| 82 | //
|
|---|
| 83 | // Calls:
|
|---|
| 84 | // - SetRange(fgHiGainFirst, fgHiGainLast, fgLoGainFirst, fgLoGainLast)
|
|---|
| 85 | //
|
|---|
| 86 | // Initializes:
|
|---|
| 87 | // - fWindowSizeHiGain to fgHiGainWindowSize
|
|---|
| 88 | // - fWindowSizeLoGain to fgLoGainWindowSize
|
|---|
| 89 | //
|
|---|
| 90 | MExtractTimeAndChargeSlidingWindow::MExtractTimeAndChargeSlidingWindow(const char *name, const char *title)
|
|---|
| 91 | {
|
|---|
| 92 |
|
|---|
| 93 | fName = name ? name : "MExtractTimeAndChargeSlidingWindow";
|
|---|
| 94 | fTitle = title ? title : "Calculate arrival times and charges using a sliding window";
|
|---|
| 95 |
|
|---|
| 96 | fWindowSizeHiGain = fgHiGainWindowSize;
|
|---|
| 97 | fWindowSizeLoGain = fgLoGainWindowSize;
|
|---|
| 98 |
|
|---|
| 99 | SetRange(fgHiGainFirst, fgHiGainLast, fgLoGainFirst, fgLoGainLast);
|
|---|
| 100 | }
|
|---|
| 101 |
|
|---|
| 102 | //-------------------------------------------------------------------
|
|---|
| 103 | //
|
|---|
| 104 | // Set the ranges
|
|---|
| 105 | //
|
|---|
| 106 | // Calls:
|
|---|
| 107 | // - MExtractor::SetRange(hifirst,hilast,lofirst,lolast);
|
|---|
| 108 | // - SetWindowSize(fWindowSizeHiGain,fWindowSizeLoGain);
|
|---|
| 109 | //
|
|---|
| 110 | void MExtractTimeAndChargeSlidingWindow::SetRange(Byte_t hifirst, Byte_t hilast, Byte_t lofirst, Byte_t lolast)
|
|---|
| 111 | {
|
|---|
| 112 |
|
|---|
| 113 | MExtractor::SetRange(hifirst, hilast, lofirst, lolast);
|
|---|
| 114 |
|
|---|
| 115 | //
|
|---|
| 116 | // Redo the checks if the window is still inside the ranges
|
|---|
| 117 | //
|
|---|
| 118 | SetWindowSize(fWindowSizeHiGain,fWindowSizeLoGain);
|
|---|
| 119 |
|
|---|
| 120 | }
|
|---|
| 121 |
|
|---|
| 122 | // -----------------------------------------------------------------------------------------
|
|---|
| 123 | //
|
|---|
| 124 | // Checks:
|
|---|
| 125 | // - if a window is bigger than the one defined by the ranges, set it to the available range
|
|---|
| 126 | // - if a window is smaller than 2, set it to 2
|
|---|
| 127 | //
|
|---|
| 128 | // Sets:
|
|---|
| 129 | // - fNumHiGainSamples to: (Float_t)fWindowSizeHiGain
|
|---|
| 130 | // - fNumLoGainSamples to: (Float_t)fWindowSizeLoGain
|
|---|
| 131 | // - fSqrtHiGainSamples to: TMath::Sqrt(fNumHiGainSamples)
|
|---|
| 132 | // - fSqrtLoGainSamples to: TMath::Sqrt(fNumLoGainSamples)
|
|---|
| 133 | //
|
|---|
| 134 | void MExtractTimeAndChargeSlidingWindow::SetWindowSize(Int_t windowh, Int_t windowl)
|
|---|
| 135 | {
|
|---|
| 136 |
|
|---|
| 137 | fWindowSizeHiGain = windowh;
|
|---|
| 138 | fWindowSizeLoGain = windowl;
|
|---|
| 139 |
|
|---|
| 140 | const Int_t availhirange = (Int_t)(fHiGainLast-fHiGainFirst+1);
|
|---|
| 141 |
|
|---|
| 142 | if (fWindowSizeHiGain > availhirange)
|
|---|
| 143 | {
|
|---|
| 144 | *fLog << warn << GetDescriptor()
|
|---|
| 145 | << Form("%s%2i%s%2i%s%2i%s",": Hi Gain window size: ",(int)fWindowSizeHiGain,
|
|---|
| 146 | " is bigger than available range: [",(int)fHiGainFirst,",",(int)fHiGainLast,"]") << endl;
|
|---|
| 147 | *fLog << warn << GetDescriptor()
|
|---|
| 148 | << ": Will set window size to: " << (int)availhirange << endl;
|
|---|
| 149 | fWindowSizeHiGain = availhirange;
|
|---|
| 150 | }
|
|---|
| 151 |
|
|---|
| 152 | if (fWindowSizeHiGain<1)
|
|---|
| 153 | {
|
|---|
| 154 | fWindowSizeHiGain = 1;
|
|---|
| 155 | *fLog << warn << GetDescriptor() << ": High Gain window size too small, set to one sample" << endl;
|
|---|
| 156 | }
|
|---|
| 157 |
|
|---|
| 158 | if (fLoGainLast != 0 && fWindowSizeLoGain != 0)
|
|---|
| 159 | {
|
|---|
| 160 | const Int_t availlorange = (Int_t)(fLoGainLast-fLoGainFirst+1);
|
|---|
| 161 |
|
|---|
| 162 | if (fWindowSizeLoGain > availlorange)
|
|---|
| 163 | {
|
|---|
| 164 | *fLog << warn << GetDescriptor()
|
|---|
| 165 | << Form("%s%2i%s%2i%s%2i%s",": Lo Gain window size: ",(int)fWindowSizeLoGain,
|
|---|
| 166 | " is bigger than available range: [",(int)fLoGainFirst,",",(int)fLoGainLast,"]") << endl;
|
|---|
| 167 | *fLog << warn << GetDescriptor()
|
|---|
| 168 | << ": Will set window size to: " << (int)availlorange << endl;
|
|---|
| 169 | fWindowSizeLoGain = availlorange;
|
|---|
| 170 | }
|
|---|
| 171 | }
|
|---|
| 172 |
|
|---|
| 173 | fNumHiGainSamples = (Float_t)fWindowSizeHiGain;
|
|---|
| 174 | fNumLoGainSamples = fLoGainLast ? (Float_t)fWindowSizeLoGain : 0.;
|
|---|
| 175 |
|
|---|
| 176 | fSqrtHiGainSamples = TMath::Sqrt(fNumHiGainSamples);
|
|---|
| 177 | fSqrtLoGainSamples = TMath::Sqrt(fNumLoGainSamples);
|
|---|
| 178 |
|
|---|
| 179 | }
|
|---|
| 180 |
|
|---|
| 181 | // --------------------------------------------------------------------------
|
|---|
| 182 | //
|
|---|
| 183 | // InitArrays
|
|---|
| 184 | //
|
|---|
| 185 | // Gets called in the ReInit() and initialized the arrays
|
|---|
| 186 | //
|
|---|
| 187 | Bool_t MExtractTimeAndChargeSlidingWindow::InitArrays()
|
|---|
| 188 | {
|
|---|
| 189 | Int_t range = (Int_t)(fHiGainLast - fHiGainFirst + 1 + fHiLoLast);
|
|---|
| 190 | fHiGainSignal.Set(range);
|
|---|
| 191 | range = (Int_t)(fLoGainLast - fLoGainFirst + 1);
|
|---|
| 192 | fLoGainSignal.Set(range);
|
|---|
| 193 |
|
|---|
| 194 | return kTRUE;
|
|---|
| 195 |
|
|---|
| 196 | }
|
|---|
| 197 |
|
|---|
| 198 | // --------------------------------------------------------------------------
|
|---|
| 199 | //
|
|---|
| 200 | // Calculates the arrival time for each pixel
|
|---|
| 201 | //
|
|---|
| 202 | void MExtractTimeAndChargeSlidingWindow::FindTimeAndChargeHiGain(Byte_t *first, Byte_t *logain, Float_t &sum, Float_t &dsum,
|
|---|
| 203 | Float_t &time, Float_t &dtime,
|
|---|
| 204 | Byte_t &sat, const MPedestalPix &ped, const Bool_t abflag)
|
|---|
| 205 | {
|
|---|
| 206 |
|
|---|
| 207 | Int_t range = fHiGainLast - fHiGainFirst + 1;
|
|---|
| 208 | const Byte_t *end = first + range;
|
|---|
| 209 | Byte_t *p = first;
|
|---|
| 210 |
|
|---|
| 211 | Float_t max = 0; // highest integral content of all windows
|
|---|
| 212 | Int_t count = 0;
|
|---|
| 213 | sat = 0;
|
|---|
| 214 |
|
|---|
| 215 | const Float_t pedes = ped.GetPedestal();
|
|---|
| 216 | const Float_t ABoffs = ped.GetPedestalABoffset();
|
|---|
| 217 |
|
|---|
| 218 | Float_t PedMean[2] = { pedes + ABoffs, pedes - ABoffs };
|
|---|
| 219 |
|
|---|
| 220 | fMaxBinContent = 0;
|
|---|
| 221 | //
|
|---|
| 222 | // Check for saturation in all other slices
|
|---|
| 223 | //
|
|---|
| 224 | Int_t ids = fHiGainFirst;
|
|---|
| 225 |
|
|---|
| 226 | while (p<first+fWindowSizeHiGain)
|
|---|
| 227 | {
|
|---|
| 228 |
|
|---|
| 229 | const Float_t signal = (Float_t)*p - PedMean[(ids++ + abflag) & 0x1];
|
|---|
| 230 | sum += signal;
|
|---|
| 231 | fHiGainSignal[count] = signal;
|
|---|
| 232 |
|
|---|
| 233 | if (*p > fMaxBinContent)
|
|---|
| 234 | fMaxBinContent = *p;
|
|---|
| 235 |
|
|---|
| 236 | if (*p++ >= fSaturationLimit)
|
|---|
| 237 | if (!sat)
|
|---|
| 238 | sat = ids-2;
|
|---|
| 239 |
|
|---|
| 240 | count++;
|
|---|
| 241 | }
|
|---|
| 242 |
|
|---|
| 243 | //
|
|---|
| 244 | // Check for saturation in all other slices
|
|---|
| 245 | //
|
|---|
| 246 | while (p<end)
|
|---|
| 247 | if (*p++ >= fSaturationLimit)
|
|---|
| 248 | if (!sat)
|
|---|
| 249 | sat = ids-2;
|
|---|
| 250 |
|
|---|
| 251 | if (IsNoiseCalculation())
|
|---|
| 252 | return;
|
|---|
| 253 |
|
|---|
| 254 | //
|
|---|
| 255 | // Calculate the i-th sum as
|
|---|
| 256 | // sum_i+1 = sum_i + slice[i+8] - slice[i]
|
|---|
| 257 | // This is fast and accurate (because we are using int's)
|
|---|
| 258 | //
|
|---|
| 259 | count = 0;
|
|---|
| 260 | max = sum;
|
|---|
| 261 | Int_t idx = 0; // idx of the first slice of the maximum window
|
|---|
| 262 |
|
|---|
| 263 | for (p=first; p+fWindowSizeHiGain<end; p++)
|
|---|
| 264 | {
|
|---|
| 265 |
|
|---|
| 266 | const Float_t signal = (Float_t)*(p+fWindowSizeHiGain) - PedMean[(ids++ + abflag) & 0x1];
|
|---|
| 267 | sum += signal - fHiGainSignal[count];
|
|---|
| 268 | fHiGainSignal[count + fWindowSizeHiGain] = signal;
|
|---|
| 269 |
|
|---|
| 270 | if (sum>max)
|
|---|
| 271 | {
|
|---|
| 272 | max = sum;
|
|---|
| 273 | idx = count+1;
|
|---|
| 274 | }
|
|---|
| 275 | count++;
|
|---|
| 276 | }
|
|---|
| 277 |
|
|---|
| 278 | if (fHiLoLast != 0)
|
|---|
| 279 | {
|
|---|
| 280 |
|
|---|
| 281 | //
|
|---|
| 282 | // overlap bins
|
|---|
| 283 | //
|
|---|
| 284 | Byte_t *l = logain;
|
|---|
| 285 |
|
|---|
| 286 | while (p < end && l < logain+fHiLoLast)
|
|---|
| 287 | {
|
|---|
| 288 |
|
|---|
| 289 | const Float_t signal = (Float_t)*l - PedMean[(ids++ + abflag) & 0x1];
|
|---|
| 290 | sum += signal - fHiGainSignal[count];
|
|---|
| 291 | fHiGainSignal[count + fWindowSizeHiGain] = signal;
|
|---|
| 292 |
|
|---|
| 293 | if (*l > fMaxBinContent)
|
|---|
| 294 | fMaxBinContent = *logain;
|
|---|
| 295 |
|
|---|
| 296 | if (*l++ >= fSaturationLimit)
|
|---|
| 297 | if (!sat)
|
|---|
| 298 | sat = ids-2;
|
|---|
| 299 |
|
|---|
| 300 | if (sum>max)
|
|---|
| 301 | {
|
|---|
| 302 | max = sum;
|
|---|
| 303 | idx = count+1;
|
|---|
| 304 | }
|
|---|
| 305 | count++;
|
|---|
| 306 | p++;
|
|---|
| 307 | }
|
|---|
| 308 |
|
|---|
| 309 | if (fHiLoLast > (Byte_t)fWindowSizeHiGain)
|
|---|
| 310 | {
|
|---|
| 311 | while (l < logain + fHiLoLast)
|
|---|
| 312 | {
|
|---|
| 313 | const Float_t signal = (Float_t)*l - PedMean[(ids++ + abflag) & 0x1];
|
|---|
| 314 | sum += signal - fHiGainSignal[count];
|
|---|
| 315 | fHiGainSignal[count+fWindowSizeHiGain] = signal;
|
|---|
| 316 |
|
|---|
| 317 | if (*l++ >= fSaturationLimit)
|
|---|
| 318 | if (!sat)
|
|---|
| 319 | sat = ids-2;
|
|---|
| 320 |
|
|---|
| 321 | if (sum>max)
|
|---|
| 322 | {
|
|---|
| 323 | max = sum;
|
|---|
| 324 | idx = count+1;
|
|---|
| 325 | }
|
|---|
| 326 | count++;
|
|---|
| 327 | } /* while (l < logain + fHiLoLast) */
|
|---|
| 328 | } /* if (fHiLoLast > fWindowSizeHiGain) */
|
|---|
| 329 | } /* if (fHiLoLast != 0) */
|
|---|
| 330 |
|
|---|
| 331 | //
|
|---|
| 332 | // now calculate the time for the maximum window
|
|---|
| 333 | //
|
|---|
| 334 | Float_t timesignalsum = 0.;
|
|---|
| 335 | Int_t timesquaredsum = 0;
|
|---|
| 336 |
|
|---|
| 337 | for (Int_t i=idx; i<idx+fWindowSizeHiGain; i++)
|
|---|
| 338 | {
|
|---|
| 339 | timesignalsum += fHiGainSignal[i]*i;
|
|---|
| 340 | timesquaredsum += i*i;
|
|---|
| 341 | }
|
|---|
| 342 |
|
|---|
| 343 | sum = max;
|
|---|
| 344 |
|
|---|
| 345 | time = max > 0.1 ? timesignalsum / max + Float_t(fHiGainFirst) : 1.;
|
|---|
| 346 | dtime = max > 0.1 ? ped.GetPedestalRms() / max * sqrt(timesquaredsum - fWindowSizeHiGain*time) : 1.;
|
|---|
| 347 |
|
|---|
| 348 | }
|
|---|
| 349 |
|
|---|
| 350 |
|
|---|
| 351 | // --------------------------------------------------------------------------
|
|---|
| 352 | //
|
|---|
| 353 | // Calculates the arrival time for each pixel
|
|---|
| 354 | //
|
|---|
| 355 | void MExtractTimeAndChargeSlidingWindow::FindTimeAndChargeLoGain(Byte_t *first, Float_t &sum, Float_t &dsum,
|
|---|
| 356 | Float_t &time, Float_t &dtime,
|
|---|
| 357 | Byte_t &sat, const MPedestalPix &ped, const Bool_t abflag)
|
|---|
| 358 | {
|
|---|
| 359 |
|
|---|
| 360 | Int_t range = fLoGainLast - fLoGainFirst + 1;
|
|---|
| 361 | const Byte_t *end = first + range;
|
|---|
| 362 | Byte_t *p = first;
|
|---|
| 363 |
|
|---|
| 364 | Float_t max = 0; // highest integral content of all windows
|
|---|
| 365 | Int_t count = 0; // counter to recognize the AB-flag
|
|---|
| 366 |
|
|---|
| 367 | Float_t pedes = ped.GetPedestal();
|
|---|
| 368 | const Float_t ABoffs = ped.GetPedestalABoffset();
|
|---|
| 369 |
|
|---|
| 370 | Float_t PedMean[2] = { pedes + ABoffs, pedes - ABoffs };
|
|---|
| 371 | //
|
|---|
| 372 | // Check for saturation in all other slices
|
|---|
| 373 | //
|
|---|
| 374 | Int_t ids = fLoGainFirst;
|
|---|
| 375 |
|
|---|
| 376 | while (p<first+fWindowSizeLoGain)
|
|---|
| 377 | {
|
|---|
| 378 | const Float_t signal = (Float_t)*p - PedMean[(ids++ + abflag) & 0x1];
|
|---|
| 379 | sum += signal;
|
|---|
| 380 | fLoGainSignal[count] = signal;
|
|---|
| 381 |
|
|---|
| 382 | if (*p++ >= fSaturationLimit)
|
|---|
| 383 | sat++;
|
|---|
| 384 |
|
|---|
| 385 | count++;
|
|---|
| 386 | }
|
|---|
| 387 |
|
|---|
| 388 | //
|
|---|
| 389 | // Check for saturation in all other slices
|
|---|
| 390 | //
|
|---|
| 391 | while (p<end)
|
|---|
| 392 | if (*p++ >= fSaturationLimit)
|
|---|
| 393 | sat++;
|
|---|
| 394 |
|
|---|
| 395 | if (IsNoiseCalculation())
|
|---|
| 396 | return;
|
|---|
| 397 |
|
|---|
| 398 | //
|
|---|
| 399 | // Calculate the i-th sum as
|
|---|
| 400 | // sum_i+1 = sum_i + slice[i+8] - slice[i]
|
|---|
| 401 | // This is fast and accurate (because we are using int's)
|
|---|
| 402 | //
|
|---|
| 403 | count = 0;
|
|---|
| 404 | max = sum;
|
|---|
| 405 | Int_t idx = 0; // idx of the first slice of the maximum window
|
|---|
| 406 |
|
|---|
| 407 | for (p=first; p+fWindowSizeLoGain<end; p++)
|
|---|
| 408 | {
|
|---|
| 409 |
|
|---|
| 410 | const Float_t signal = (Float_t)*(p+fWindowSizeLoGain) - PedMean[(ids++ + abflag) & 0x1];
|
|---|
| 411 | sum += signal - fLoGainSignal[count];
|
|---|
| 412 | fLoGainSignal[count + fWindowSizeLoGain] = signal;
|
|---|
| 413 |
|
|---|
| 414 | if (sum>max)
|
|---|
| 415 | {
|
|---|
| 416 | max = sum;
|
|---|
| 417 | idx = count+1;
|
|---|
| 418 | }
|
|---|
| 419 | count++;
|
|---|
| 420 | }
|
|---|
| 421 |
|
|---|
| 422 | //
|
|---|
| 423 | // now calculate the time for the maximum window
|
|---|
| 424 | //
|
|---|
| 425 | Float_t timesignalsum = 0;
|
|---|
| 426 | Int_t timesquaredsum = 0;
|
|---|
| 427 |
|
|---|
| 428 | for (Int_t i=idx; i<idx+fWindowSizeLoGain; i++)
|
|---|
| 429 | {
|
|---|
| 430 | timesignalsum += fLoGainSignal[i]*i;
|
|---|
| 431 | timesquaredsum += i*i;
|
|---|
| 432 | }
|
|---|
| 433 |
|
|---|
| 434 | sum = max;
|
|---|
| 435 |
|
|---|
| 436 | time = max > 0.1 ? timesignalsum / max + Float_t(fLoGainFirst) : 1.;
|
|---|
| 437 | dtime = max > 0.1 ? ped.GetPedestalRms() / max * sqrt(timesquaredsum - fWindowSizeLoGain*time) : 1.;
|
|---|
| 438 | }
|
|---|
| 439 |
|
|---|
| 440 | // --------------------------------------------------------------------------
|
|---|
| 441 | //
|
|---|
| 442 | // In addition to the resources of the base-class MExtractor:
|
|---|
| 443 | // MJPedestal.MExtractor.WindowSizeHiGain: 6
|
|---|
| 444 | // MJPedestal.MExtractor.WindowSizeLoGain: 6
|
|---|
| 445 | //
|
|---|
| 446 | Int_t MExtractTimeAndChargeSlidingWindow::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
|
|---|
| 447 | {
|
|---|
| 448 |
|
|---|
| 449 | Byte_t hw = fWindowSizeHiGain;
|
|---|
| 450 | Byte_t lw = fWindowSizeLoGain;
|
|---|
| 451 |
|
|---|
| 452 | Bool_t rc = kFALSE;
|
|---|
| 453 |
|
|---|
| 454 | if (IsEnvDefined(env, prefix, "HiGainWindowSize", print))
|
|---|
| 455 | {
|
|---|
| 456 | hw = GetEnvValue(env, prefix, "HiGainWindowSize", hw);
|
|---|
| 457 | rc = kTRUE;
|
|---|
| 458 | }
|
|---|
| 459 | if (IsEnvDefined(env, prefix, "LoGainWindowSize", print))
|
|---|
| 460 | {
|
|---|
| 461 | lw = GetEnvValue(env, prefix, "LoGainWindowSize", lw);
|
|---|
| 462 | rc = kTRUE;
|
|---|
| 463 | }
|
|---|
| 464 |
|
|---|
| 465 | if (rc)
|
|---|
| 466 | SetWindowSize(hw, lw);
|
|---|
| 467 |
|
|---|
| 468 | return MExtractTime::ReadEnv(env, prefix, print) ? kTRUE : rc;
|
|---|
| 469 |
|
|---|
| 470 | }
|
|---|
| 471 |
|
|---|