Ignore:
Timestamp:
11/25/13 21:40:11 (11 years ago)
Author:
tbretz
Message:
Some important conmetics: Define variables as const whenever you can, never declare veriables earlier as they are used; if you feel the need to list them, use comments; do never declare you own TRandom object - the root/Mars environment takes care of it (global seed, and which TRandom class to use\!)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Mars/msimcamera/MSimCamera.cc

    r17209 r17383  
    254254        //       * areaOfOnePulse / samplingRate;
    255255        // Therefore I need the following variables
    256         Double_t accidentalPhotonRate   = 0; // [MHz]
    257         Float_t crossTalkProb           = 0; // [1]
    258         Double_t areaOfOnePulse         = 0; // [ADC-Counts * s]
    259         Double_t samplingRate           = 0; // [slices * MHz]
     256        // Double_t accidentalPhotonRate; // [MHz]
     257        // Float_t crossTalkProb;        // [1]
     258        // Double_t areaOfOnePulse;      // [ADC-Counts * s]
     259        // Double_t samplingRate;        // [slices * MHz]
    260260
    261261        // The accidental photon rate is stored in GHz, so we have to multiply
    262262        // with 1E3 to get MHz:
    263         MPedestalPix &accPhoPix         = (*fAccidentalPhotons)[i];
    264         accidentalPhotonRate            = accPhoPix.GetPedestal() * 1E3;
     263        const MPedestalPix &accPhoPix = (*fAccidentalPhotons)[i];
     264
     265        const Double_t accidentalPhotonRate = accPhoPix.GetPedestal() * 1e3; //[MHz]
     266
    265267        Double_t currentAccidentalPhotonRate = accidentalPhotonRate;
    266 
    267         if(fACTimeConstant!=0)
     268        if (fACTimeConstant!=0)
    268269        {
    269             Double_t accidentalPhotons      = fACTimeConstant * accidentalPhotonRate;
    270             Double_t sigmaAccidentalPhotons = sqrt(accidentalPhotons);
    271 
    272             TRandom3 *random = new TRandom3(0);
    273             Double_t gaus = random->Gaus(accidentalPhotons,sigmaAccidentalPhotons);
     270            const Double_t accidentalPhotons      = fACTimeConstant * accidentalPhotonRate;
     271            const Double_t sigmaAccidentalPhotons = sqrt(accidentalPhotons);
     272
     273            const Double_t gaus = gRandom->Gaus(accidentalPhotons,sigmaAccidentalPhotons);
     274
    274275            currentAccidentalPhotonRate = gaus / fACTimeConstant;
    275             delete random;
    276276        }
    277277
    278         // I don't know how to get the variable fCrosstalkProb from
     278        // FIXME: I don't know how to get the variable fCrosstalkProb from
    279279        // the class APD (see MAvalanchePhotoDiode.h), because there is no
    280280        // getter for the APD array(fAPDs) in MSimAPD.
    281281        // So I set the crossTalkProb hardcoded to the value 0.15, which is
    282282        // equal to the value of the apd of type 4
    283         crossTalkProb                  = 0.15;
     283        const Double_t crossTalkProb = 0.15;
    284284
    285285        // To get the area of one Pulse, I only need to calculate the Integral
    286286        // of the Pulse Shape, which is stored in fSpline. Because the spline is
    287287        // normalized to a maximal amplitude of 1.0, I had to multiply it with
    288         // the Default gain:
    289         areaOfOnePulse                  = fSpline->Integral() * fDefaultGain;
     288        // the Default gain [ADC-Counts * s]
     289        const Double_t areaOfOnePulse = fSpline->Integral() * fDefaultGain;
    290290
    291291        // The sampling rate I get from the RunHeader:
    292         samplingRate                    = fRunHeader->GetFreqSampling();
    293 
    294         Double_t accouplingPerSlice = currentAccidentalPhotonRate
    295                 * (1 + crossTalkProb + fACFudgeFactor)
    296                 * areaOfOnePulse / samplingRate;
     292        const Double_t samplingRate = fRunHeader->GetFreqSampling(); // [slices * MHz]
     293
     294        const Double_t accouplingPerSlice = currentAccidentalPhotonRate
     295            * (1 + crossTalkProb + fACFudgeFactor)
     296            * areaOfOnePulse / samplingRate;
    297297
    298298        // The accoupling is substracted from the timeline by decreasing the
Note: See TracChangeset for help on using the changeset viewer.