Changeset 17148 for trunk/Mars


Ignore:
Timestamp:
09/09/13 12:39:18 (11 years ago)
Author:
ftemme
Message:
Merging changes from the MC branch in the trunk
Location:
trunk/Mars
Files:
14 edited
10 copied

Legend:

Unmodified
Added
Removed
  • trunk/Mars

  • trunk/Mars/mextralgo/MExtralgoSpline.cc

    r14854 r17148  
    207207// at x, until x==0. If y is not found or out of range -2 is returned.
    208208//
    209 Double_t MExtralgoSpline::SearchYdn(Float_t x, Float_t y) const
     209Double_t MExtralgoSpline::SearchYdn(Double_t x, Double_t y) const
    210210{
    211211    if (x>=fNum-1)
     
    228228// at x, until x==fNum-1. If y is not found or out of range -2 is returned.
    229229//
    230 Double_t MExtralgoSpline::SearchYup(Float_t x, Float_t y) const
     230Double_t MExtralgoSpline::SearchYup(Double_t x, Double_t y) const
    231231{
    232232    if (x<0)
  • trunk/Mars/mextralgo/MExtralgoSpline.h

    r14854 r17148  
    347347    Float_t Deriv1(const Float_t x) const;
    348348
    349     Double_t SearchYdn(Float_t maxpos, Float_t y) const;
    350     Double_t SearchYup(Float_t maxpos, Float_t y) const;
     349    Double_t SearchYdn(Double_t maxpos, Double_t y) const;
     350    Double_t SearchYup(Double_t maxpos, Double_t y) const;
    351351
    352352    Double_t SearchYdn(Float_t y) const { return SearchYdn(fNum, y); }
  • trunk/Mars/mfileio/MWriteFitsFile.cc

    r15277 r17148  
    1515#include "MWriteFitsFile.h"
    1616#include "MFitsArray.h"
     17
     18#include "MTime.h"
    1719
    1820//for find
     
    337339    return kTRUE;
    338340}
     341
     342void MWriteFitsFile::SetupHeaderKeys(MRawRunHeader &header)
     343{
     344    const MTime now(-1);
     345    SetHeaderKey("ISMC",true,"Bool if File is Montecarlo File");
     346    SetHeaderKey("TELESCOP", "FACT", "");
     347    SetHeaderKey("PACKAGE", "MARS Cheobs", "");
     348    SetHeaderKey("VERSION", "1.0", "");
     349    SetHeaderKey("CREATOR", "Ceres", "");
     350    SetHeaderKey("EXTREL", 1., "");
     351    SetHeaderKey("COMPILED", __DATE__" "__TIME__, "");
     352    //SetHeaderKey("REVISION", "0", "");
     353    SetHeaderKey("ORIGIN", "FACT", "");
     354    SetHeaderKey("DATE", now.GetStringFmt("%Y-%m-%dT%H:%M:%S").Data(), "");
     355    SetHeaderKey("NIGHT", now.GetNightAsInt(), "");
     356    SetHeaderKey("TIMESYS", "UTC", "");
     357    SetHeaderKey("TIMEUNIT", "d", "");
     358    SetHeaderKey("MJDREF", 40587, "");
     359    //SetHeaderKey("BLDVER", 1, "");
     360    SetHeaderKey("RUNID", header.GetRunNumber(), "");
     361    SetHeaderKey("NBOARD", 40, "");
     362    SetHeaderKey("NPIX", header.GetNumPixel(), "");
     363    SetHeaderKey("NROI", header.GetNumSamplesHiGain(), "");
     364    SetHeaderKey("NROITM", 0, "");
     365    SetHeaderKey("TMSHIFT", 0, "");
     366    SetHeaderKey("CAMERA", "MGeomCamFACT", "Montecarlo File");
     367    SetHeaderKey("DAQ", "DRS4", "Montecarlo File");
     368
     369    // FTemme: ADCRANGE and ADC have to be calculated, using the values for
     370    // the fadctype.
     371//    SetHeaderKey("ADCRANGE", 2000, "Dynamic range in mV");
     372//    SetHeaderKey("ADC", 12, "Resolution in bits");
     373
     374    switch(header.GetRunType())
     375    {
     376    case MRawRunHeader::kRTData|MRawRunHeader::kRTMonteCarlo:
     377        SetHeaderKey("RUNTYPE", "data", "");
     378        break;
     379    case MRawRunHeader::kRTPedestal|MRawRunHeader::kRTMonteCarlo:
     380        SetHeaderKey("RUNTYPE", "pedestal", "");
     381        break;
     382    case MRawRunHeader::kRTCalibration|MRawRunHeader::kRTMonteCarlo:
     383        SetHeaderKey("RUNTYPE", "calibration", "");
     384        break;
     385    }
     386//    SetHeaderKey("ID", 777, "Board  0: Board ID");
     387//    SetHeaderKey("FMVER", 532, "Board  0: Firmware Version");
     388//    SetHeaderKey("DNA", "0", "");
     389//    SetHeaderKey("BOARD", 0, "");
     390//    SetHeaderKey("PRESC", 40, "");
     391//    SetHeaderKey("PHASE", 0, "");
     392//    SetHeaderKey("DAC0", 26500, "");
     393//    SetHeaderKey("DAC1", 0, "");
     394//    SetHeaderKey("DAC2", 0, "");
     395//    SetHeaderKey("DAC3", 0, "");
     396//    SetHeaderKey("DAC4", 28800, "");
     397//    SetHeaderKey("DAC5", 28800, "");
     398//    SetHeaderKey("DAC6", 28800, "");
     399//    SetHeaderKey("DAC7", 28800, "");
     400    SetHeaderKey("REFCLK", header.GetFreqSampling(), "");
     401    SetHeaderKey("DRSCALIB", false, "");
     402//    SetHeaderKey("TSTARTI", 0, "");
     403//    SetHeaderKey("TSTARTF", 0., "");
     404//    SetHeaderKey("TSTOPI", 0, "");
     405//    SetHeaderKey("TSTOPF", 0., "");
     406//    SetHeaderKey("DATE-OBS", "1970-01-01T00:00:00", "");
     407//    SetHeaderKey("DATE-END", "1970-01-01T00:00:00", "");
     408//    SetHeaderKey("NTRG", 0, "");
     409//    SetHeaderKey("NTRGPED", 0, "");
     410//    SetHeaderKey("NTRGLPE", 0, "");
     411//    SetHeaderKey("NTRGTIM", 0, "");
     412//    SetHeaderKey("NTRGLPI", 0, "");
     413//    SetHeaderKey("NTRGEXT1", 0, "");
     414//    SetHeaderKey("NTRGEXT2", 0, "");
     415//    SetHeaderKey("NTRGMISC", 0, "");
     416}
     417
    339418template<>
    340419std::string MWriteFitsFile::GetFitsString(const double& value)
     
    11271206      return kFALSE;
    11281207
     1208
     1209   MRawRunHeader* header = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
     1210   SetupHeaderKeys(*header);
     1211
    11291212   if (GetContainer(pList) == kFALSE)
    11301213      return kFALSE;
  • trunk/Mars/mfileio/MWriteFitsFile.h

    r15277 r17148  
    1919#include "MFitsArray.h"
    2020#endif
     21
     22#ifndef MARS_MRawRunHeader
     23#include "MRawRunHeader.h"
     24#endif
     25
     26class MRawRunHeader;
    2127
    2228///////////////////////////////////////////////////////////////////////////////
     
    137143   Int_t       PreProcess(MParList *pList);
    138144   Int_t       PostProcess();
     145
     146   void        SetupHeaderKeys(MRawRunHeader &header);
    139147
    140148   //Header keys related stuff
  • trunk/Mars/mjobs/MJSimulation.cc

    r15277 r17148  
    260260    write.AddContainer("IncidentAngle",       "Events", kFALSE);
    261261}
     262
     263void MJSimulation::SetupHeaderKeys(MWriteFitsFile &write,MRawRunHeader &header) const
     264{
     265    const MTime now(-1);
     266    write.SetHeaderKey("ISMC",true,"Bool if File is Montecarlo File");
     267    write.SetHeaderKey("TELESCOP", "FACT", "");
     268    write.SetHeaderKey("PACKAGE", "MARS Cheobs", "");
     269    write.SetHeaderKey("VERSION", "1.0", "");
     270    write.SetHeaderKey("CREATOR", "Ceres", "");
     271    write.SetHeaderKey("EXTREL", 1., "");
     272    write.SetHeaderKey("COMPILED", __DATE__" "__TIME__, "");
     273    write.SetHeaderKey("REVISION", "0", "");
     274    write.SetHeaderKey("ORIGIN", "FACT", "");
     275    write.SetHeaderKey("DATE", now.GetStringFmt("%Y-%m-%dT%H:%M:%S").Data(), "");
     276    write.SetHeaderKey("NIGHT", now.GetNightAsInt(), "");
     277    write.SetHeaderKey("TIMESYS", "UTC", "");
     278    write.SetHeaderKey("TIMEUNIT", "d", "");
     279    write.SetHeaderKey("MJDREF", 40587, "");
     280    //write.SetHeaderKey("BLDVER", 1, "");
     281    write.SetHeaderKey("RUNID", header.GetRunNumber(), "");
     282    write.SetHeaderKey("NBOARD", 40, "");
     283    write.SetHeaderKey("NPIX", header.GetNumPixel(), "");
     284    write.SetHeaderKey("NROI", header.GetNumSamplesHiGain(), "");
     285    write.SetHeaderKey("NROITM", 0, "");
     286    write.SetHeaderKey("TMSHIFT", 0, "");
     287    write.SetHeaderKey("CAMERA", "MGeomCamFACT", "");
     288    write.SetHeaderKey("DAQ", "DRS4", "");
     289
     290    // FTemme: ADCRANGE and ADC have to be calculated, using the values for
     291    // the fadctype.
     292//    write.SetHeaderKey("ADCRANGE", 2000, "Dynamic range in mV");
     293//    write.SetHeaderKey("ADC", 12, "Resolution in bits");
     294
     295    switch(header.GetRunType())
     296    {
     297    case MRawRunHeader::kRTData|MRawRunHeader::kRTMonteCarlo:
     298        write.SetHeaderKey("RUNTYPE", "data", "");
     299        break;
     300    case MRawRunHeader::kRTPedestal|MRawRunHeader::kRTMonteCarlo:
     301        write.SetHeaderKey("RUNTYPE", "pedestal", "");
     302        break;
     303    case MRawRunHeader::kRTCalibration|MRawRunHeader::kRTMonteCarlo:
     304        write.SetHeaderKey("RUNTYPE", "calibration", "");
     305        break;
     306    }
     307//    write.SetHeaderKey("ID", 777, "Board  0: Board ID");
     308//    write.SetHeaderKey("FMVER", 532, "Board  0: Firmware Version");
     309//    write.SetHeaderKey("DNA", "0", "");
     310//    write.SetHeaderKey("BOARD", 0, "");
     311//    write.SetHeaderKey("PRESC", 40, "");
     312//    write.SetHeaderKey("PHASE", 0, "");
     313//    write.SetHeaderKey("DAC0", 26500, "");
     314//    write.SetHeaderKey("DAC1", 0, "");
     315//    write.SetHeaderKey("DAC2", 0, "");
     316//    write.SetHeaderKey("DAC3", 0, "");
     317//    write.SetHeaderKey("DAC4", 28800, "");
     318//    write.SetHeaderKey("DAC5", 28800, "");
     319//    write.SetHeaderKey("DAC6", 28800, "");
     320//    write.SetHeaderKey("DAC7", 28800, "");
     321    write.SetHeaderKey("REFCLK", header.GetFreqSampling(), "");
     322    write.SetHeaderKey("DRSCALIB", false, "");
     323//    write.SetHeaderKey("TSTARTI", 0, "");
     324//    write.SetHeaderKey("TSTARTF", 0., "");
     325//    write.SetHeaderKey("TSTOPI", 0, "");
     326//    write.SetHeaderKey("TSTOPF", 0., "");
     327//    write.SetHeaderKey("DATE-OBS", "1970-01-01T00:00:00", "");
     328//    write.SetHeaderKey("DATE-END", "1970-01-01T00:00:00", "");
     329//    write.SetHeaderKey("NTRG", 0, "");
     330//    write.SetHeaderKey("NTRGPED", 0, "");
     331//    write.SetHeaderKey("NTRGLPE", 0, "");
     332//    write.SetHeaderKey("NTRGTIM", 0, "");
     333//    write.SetHeaderKey("NTRGLPI", 0, "");
     334//    write.SetHeaderKey("NTRGEXT1", 0, "");
     335//    write.SetHeaderKey("NTRGEXT2", 0, "");
     336//    write.SetHeaderKey("NTRGMISC", 0, "");
     337}
     338
     339void MJSimulation::SetupVetoColumns(MWriteFitsFile &write) const
     340{
     341    write.VetoColumn("MParameterD.fVal");
     342    write.VetoColumn("MRawEvtData.fLoGainPixId");
     343    write.VetoColumn("MRawEvtData.fLoGainFadcSamples");
     344    write.VetoColumn("MRawEvtData.fABFlags");
     345    write.VetoColumn("MRawEvtHeader.fNumTrigLvl2");
     346    //write.VetoColumn("MRawEvtHeader.fTrigPattern");
     347    write.VetoColumn("MRawEvtHeader.fNumLoGainOn");
     348}
     349
    262350Bool_t MJSimulation::Process(const MArgs &args, const MSequence &seq)
    263351{
     
    558646    MTask &write3a = fWriteFitsFile ? static_cast<MTask&>(write3af) : static_cast<MTask&>(write3ar);
    559647
    560     write3af.SetHeaderKey("DUMMY0", 3, "First dummy");
    561     write3af.SetHeaderKey("DUMMY1", 3.14159265358979323846, "Second dummy");
    562     write3af.SetHeaderKey("DUMMY2", true, "Third dummy");
    563     write3af.SetHeaderKey("DUMMY3", "one value", "Fourth dummy");
    564 
    565     write3af.VetoColumn("MParameterD.fVal");
    566     write3af.VetoColumn("MCorsikaEvtHeader.fEvtNumber");
    567     write3af.VetoColumn("MCorsikaEvtHeader.fNumReuse");
    568     write3af.VetoColumn("MCorsikaEvtHeader.fTotalEnergy");
    569     write3af.VetoColumn("MCorsikaEvtHeader.fStartAltitude");
    570     write3af.VetoColumn("MCorsikaEvtHeader.fFirstTargetNum");
    571     write3af.VetoColumn("MCorsikaEvtHeader.fFirstInteractionHeight");
    572     write3af.VetoColumn("MCorsikaEvtHeader.fMomentumX");
    573     write3af.VetoColumn("MCorsikaEvtHeader.fMomentumY");
    574     write3af.VetoColumn("MCorsikaEvtHeader.fMomentumZ");
    575     write3af.VetoColumn("MCorsikaEvtHeader.fAz");
    576     write3af.VetoColumn("MCorsikaEvtHeader.fWeightedNumPhotons");
    577     write3af.VetoColumn("MCorsikaEvtHeader.fZd");
    578     write3af.VetoColumn("MCorsikaEvtHeader.fAd");
    579     write3af.VetoColumn("MCorsikaEvtHeader.fX");
    580     write3af.VetoColumn("MCorsikaEvtHeader.fY");
    581     write3af.VetoColumn("MCorsikaEvtHeader.fWeightNumPhotons");
    582     write3af.VetoColumn("MMcEvt.fEvtNumber");
    583     write3af.VetoColumn("MMcEvt.fThick0");
    584     write3af.VetoColumn("MMcEvt.fFirstTarget");
    585     write3af.VetoColumn("MMcEvt.fZFirstInteraction");
    586     write3af.VetoColumn("MMcEvt.fCoreD");
    587     write3af.VetoColumn("MMcEvt.fCoreX");
    588     write3af.VetoColumn("MMcEvt.fCoreY");
    589     write3af.VetoColumn("MMcEvt.fTimeFirst");
    590     write3af.VetoColumn("MMcEvt.fTimeLast");
    591     write3af.VetoColumn("MMcEvt.fLongiNmax");
    592     write3af.VetoColumn("MMcEvt.fLongit0");
    593     write3af.VetoColumn("MMcEvt.fLongitmax");
    594     write3af.VetoColumn("MMcEvt.fLongia");
    595     write3af.VetoColumn("MMcEvt.fLongib");
    596     write3af.VetoColumn("MMcEvt.fLongic");
    597     write3af.VetoColumn("MMcEvt.fLongichi2");
    598     write3af.VetoColumn("MMcEvt.fPhotIni");
    599     write3af.VetoColumn("MMcEvt.fPassPhotAtm");
    600     write3af.VetoColumn("MMcEvt.fPassPhotRef");
    601     write3af.VetoColumn("MMcEvt.fPassPhotCone");
    602     write3af.VetoColumn("MMcEvt.fPhotElfromShower");
    603     write3af.VetoColumn("MMcEvt.fPhotElinCamera");
    604     write3af.VetoColumn("MMcEvt.fElecCphFraction");
    605     write3af.VetoColumn("MMcEvt.fMuonCphFraction");
    606     write3af.VetoColumn("MMcEvt.fOtherCphFraction");
    607     write3af.VetoColumn("MMcEvt.fFadcTimeJitter");
    608     write3af.VetoColumn("MMcEvt.fEventReuse");
    609 
    610     write3af.VetoColumn("MRawEvtData.fHiGainPixId");
    611     write3af.VetoColumn("MRawEvtData.fLoGainPixId");
    612     write3af.VetoColumn("MRawEvtData.fLoGainFadcSamples");
    613     write3af.VetoColumn("MRawEvtData.fABFlags");
    614     write3af.VetoColumn("MRawEvtData.fStartCells");
    615     write3af.VetoColumn("MRawEvtData.fNumBytesPerSample");
    616     write3af.VetoColumn("MRawEvtData.fIsSigned");
    617     write3af.VetoColumn("MRawEvtHeader.fDAQEvtNumber"); //EventNum ?
    618     write3af.VetoColumn("MRawEvtHeader.fNumTrigLvl1");
    619     write3af.VetoColumn("MRawEvtHeader.fNumTrigLvl2");
    620     write3af.VetoColumn("MRawEvtHeader.fTrigPattern");
    621     write3af.VetoColumn("MRawEvtHeader.fNumLoGainOn");
     648    //SetupHeaderKeys(write3af,header);
     649    SetupVetoColumns(write3af);
    622650
    623651    write3af.SetBytesPerSample("Data", 2);
     
    649677    write3af.AddContainer("IntendedPulsePos", "RunHeaders");
    650678    write3af.AddContainer("MRawEvtData",      "Events");
     679    write3af.AddContainer("MMcEvtBasic",      "Events");
     680    write3af.AddContainer("MPhotonEvent","Events");
    651681
    652682    write3ar.AddContainer("ElectronicNoise",  "RunHeaders");
  • trunk/Mars/mjobs/MJSimulation.h

    r14864 r17148  
    1212class MWriteRootFile;
    1313class MWriteFitsFile;
     14class MRawRunHeader;
    1415
    1516class MJSimulation : public MJob
     
    3435    void SetupCommonFileStructure(MWriteRootFile &write) const;
    3536    void SetupCommonFileStructure(MWriteFitsFile& write) const;
     37    void SetupHeaderKeys(MWriteFitsFile& write, MRawRunHeader &header) const;
     38    void SetupVetoColumns(MWriteFitsFile& write) const;
    3639
    3740public:
  • trunk/Mars/mmc/MMcEvt.hxx

    r9937 r17148  
    1010{
    1111private:
    12     UInt_t  fEvtNumber;
     12    UInt_t  fEvtNumber;          // [fits: name=EventNum ; unit=uint32]
    1313    Float_t fThick0;             // [g/cm2]
    1414    Float_t fFirstTarget;        // []
  • trunk/Mars/mraw/MRawEvtData.cc

    r11870 r17148  
    114114//
    115115MRawEvtData::MRawEvtData(const char *name, const char *title)
    116     : fRunHeader(0), fNumBytesPerSample(1), fIsSigned(false)
     116    : fRunHeader(0), fNumBytesPerSample(1), fTriggerType(0), fIsSigned(false)
    117117{
    118118    fName  = name  ? name  : "MRawEvtData";
     
    359359
    360360    fNumBytesPerSample = fRunHeader ? fRunHeader->GetNumBytesPerSample() : 1;
     361
     362
     363    if (fRunHeader == 0)
     364    {
     365        fTriggerType = 0x0000;
     366    }
     367    else
     368    {
     369        switch(fRunHeader->GetRunType())
     370        {
     371        case MRawRunHeader::kRTMonteCarlo|MRawRunHeader::kRTData:
     372            fTriggerType = 0x0004; break;
     373        case MRawRunHeader::kRTMonteCarlo|MRawRunHeader::kRTPedestal:
     374            fTriggerType = 0x0400; break;
     375        case MRawRunHeader::kRTMonteCarlo|MRawRunHeader::kRTCalibration:
     376            fTriggerType = 0x0164; break;
     377        default:
     378            fTriggerType = 0x0000; break;
     379        }
     380    }
    361381
    362382    fHiGainPixId       = new MArrayS(numconnected);
  • trunk/Mars/mraw/MRawEvtData.h

    r14870 r17148  
    1212//class ifstream;
    1313#include <iosfwd>
     14#include <stdint.h>
    1415
    1516class MRawRunHeader;
     
    3637
    3738    MArrayB *fABFlags;            //-> A information about the exact trigger position
    38     MArrayS *fStartCells;         //
     39    MArrayS *fStartCells;         // {fits: unit=uint16 ; name=StartCellData }
     40
     41    UShort_t fTriggerType;       // {fits: unit=uint16 ; name=TriggerType }
    3942
    4043    UShort_t fNumBytesPerSample;
  • trunk/Mars/mraw/MRawEvtHeader.h

    r14792 r17148  
    5353    MTime   *fTime;            //! object to store the time in (ReadEvt)
    5454
    55     UInt_t   fDAQEvtNumber;    // Number of Event [fits: name=EventNum]
     55    UInt_t   fDAQEvtNumber;    // Number of Event {fits: name=EventNum ; unit=uint32}
    5656
    5757    UInt_t   fNumTrigLvl1;     // Number of 1st level tiggers between 2 events
  • trunk/Mars/msimcamera/MSimCamera.cc

    r10167 r17148  
    4343#include <TF1.h>
    4444#include <TRandom.h>
     45#include <TRandom3.h>
    4546
    4647#include "MLog.h"
     
    6364#include "MMcEvt.hxx"            // To be replaced by a CheObs class
    6465#include "MRawRunHeader.h"
     66
     67#include "math.h"
    6568
    6669ClassImp(MSimCamera);
     
    7578    : fEvt(0), fStat(0), fRunHeader(0), fElectronicNoise(0), fGain(0),
    7679    fCamera(0), fMcEvt(0), fSpline(0), fBaselineGain(kFALSE),
    77     fDefaultOffset(-1), fDefaultNoise(-1), fDefaultGain(-1)
     80      fDefaultOffset(-1), fDefaultNoise(-1), fDefaultGain(-1), fACFudgeFactor(0),
     81      fACTimeConstant(0)
    7882
    7983{
     
    135139        return kFALSE;
    136140
     141    fAccidentalPhotons = (MPedestalCam*)pList->FindObject("AccidentalPhotonRates","MPedestalCam");
     142    if(!fAccidentalPhotons)
     143    {
     144        *fLog << err << "AccidentalPhotonRates [MPedestalCam] not found... aborting." << endl;
     145        return kFALSE;
     146    }
     147
    137148    MParSpline *pulse = (MParSpline*)pList->FindObject("PulseShape", "MParSpline");
    138149    if (!pulse)
     
    142153    }
    143154
    144     if (fRunHeader->GetFreqSampling()!=1000)
    145     {
    146         *fLog << err  << "ERROR - Sampling frequencies others than 1GHz are not yet supported." << endl;
    147         *fLog << warn << "FIXME - SCALE MPulsShape WITH THE SAMPLING FREQUENCY." << endl;
    148         return kFALSE;
    149     }
     155//    if (fRunHeader->GetFreqSampling()!=1000)
     156//    {
     157//        *fLog << err  << "ERROR - Sampling frequencies others than 1GHz are not yet supported." << endl;
     158//        *fLog << warn << "FIXME - SCALE MPulsShape WITH THE SAMPLING FREQUENCY." << endl;
     159//        return kFALSE;
     160//    }
    150161
    151162    fSpline = pulse->GetSpline();
     
    238249        const Double_t rms = pix.GetPedestalRms();
    239250
     251        // FTemme: Implementation of AC-coupling:
     252        // to calculate the value of the accoupling per slice I use the
     253        // following equation:
     254        // accouplingPerSlice = accidentalPhotonRate * (1 + crossTalkProb)
     255        //       * areaOfOnePulse / samplingRate;
     256        // Therefore I need the following variables
     257        Double_t accidentalPhotonRate   = 0; // [MHz]
     258        Float_t crossTalkProb           = 0; // [1]
     259        Double_t areaOfOnePulse         = 0; // [ADC-Counts * s]
     260        Double_t samplingRate           = 0; // [slices * MHz]
     261
     262        // The accidental photon rate is stored in GHz, so we have to multiply
     263        // with 1E3 to get MHz:
     264        MPedestalPix &accPhoPix         = (*fAccidentalPhotons)[i];
     265        accidentalPhotonRate            = accPhoPix.GetPedestal() * 1E3;
     266        Double_t currentAccidentalPhotonRate = accidentalPhotonRate;
     267
     268        if(fACTimeConstant!=0)
     269        {
     270            Double_t accidentalPhotons      = fACTimeConstant * accidentalPhotonRate;
     271            Double_t sigmaAccidentalPhotons = sqrt(accidentalPhotons);
     272
     273            TRandom3 *random = new TRandom3(0);
     274            Double_t gaus = random->Gaus(accidentalPhotons,sigmaAccidentalPhotons);
     275            currentAccidentalPhotonRate = gaus / fACTimeConstant;
     276        }
     277
     278        // I don't know how to get the variable fCrosstalkProb from
     279        // the class APD (see MAvalanchePhotoDiode.h), because there is no
     280        // getter for the APD array(fAPDs) in MSimAPD.
     281        // So I set the crossTalkProb hardcoded to the value 0.15, which is
     282        // equal to the value of the apd of type 4
     283        crossTalkProb                   = 0.15;
     284
     285        // To get the area of one Pulse, I only need to calculate the Integral
     286        // of the Pulse Shape, which is stored in fSpline. Because the spline is
     287        // normalized to a maximal amplitude of 1.0, I had to multiply it with
     288        // the Default gain:
     289        areaOfOnePulse                  = fSpline->Integral() * fDefaultGain;
     290
     291        // 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;
     297
     298        // The accoupling is substracted from the timeline by decreasing the
     299        // mean of the gaussian noise which is added
     300
    240301        if (!fBaselineGain)
    241302        {
    242             (*fCamera)[i].AddGaussianNoise(rms, val);
     303            (*fCamera)[i].AddGaussianNoise(rms, val - accouplingPerSlice);
    243304            continue;
    244305        }
     
    250311        // FIXME: How stable is the offset?
    251312        // FIXME: Should we write a container AppliedGain for MSImTrigger?
    252         (*fCamera)[i].AddGaussianNoise(rms*gain, val*gain);
     313
     314        (*fCamera)[i].AddGaussianNoise(rms*gain, (val - accouplingPerSlice)*gain);
    253315    }
    254316
     
    323385        fDefaultGain = GetEnvValue(env, prefix, "DefaultGain", fDefaultGain);
    324386    }
     387    if (IsEnvDefined(env, prefix, "fACFudgeFactor", print))
     388    {
     389        rc = kTRUE;
     390        fACFudgeFactor = GetEnvValue(env, prefix, "fACFudgeFactor", fACFudgeFactor);
     391    }
     392    if (IsEnvDefined(env, prefix, "fACTimeConstant", print))
     393    {
     394        rc = kTRUE;
     395        fACTimeConstant = GetEnvValue(env, prefix, "fACTimeConstant", fACTimeConstant);
     396    }
    325397
    326398    return rc;
  • trunk/Mars/msimcamera/MSimCamera.h

    r9625 r17148  
    2424    MPedestalCam      *fElectronicNoise; //! Electronic noise (baseline and rms)
    2525    MPedestalCam      *fGain;            //! Electronic noise (baseline and rms)
     26    MPedestalCam      *fAccidentalPhotons;//! Accidental photon rates
    2627
    2728    MAnalogChannels   *fCamera;          //! Output of the analog signals
    2829    MMcEvt            *fMcEvt;           //! For information stored in MMcEvt
    2930
    30     const MSpline3    *fSpline;          // Pulse Shape
     31    const MSpline3    *fSpline;          // Pulse Shape   
    3132
    3233    Bool_t fBaselineGain;  // Should the gain be applied to baseline and electronic noise?
     
    3536    Double_t fDefaultNoise;   // Default noise (RMS) added to all samples
    3637    Double_t fDefaultGain;    // Default gain (multiplication factor to the given/used pulse shape)
     38
     39    Double_t fACFudgeFactor;
     40
     41    Double_t fACTimeConstant;
    3742
    3843    // MParContainer
  • trunk/Mars/msimcamera/MSimReadout.cc

    r9422 r17148  
    145145    fData->InitRead(fRunHeader);
    146146    fData->ResetPixels();
     147    fData->InitStartCells();
    147148    fData->SetIndices();
    148149
     
    202203
    203204    // Check if the whole requested signal can be digitized
    204     if (trig+nslices>=nsamp)
     205    if (trig+nslices>nsamp)
    205206    {
    206207        *fLog << err << "ERROR - Trigger position beyond valid analog signal range." << endl;
Note: See TracChangeset for help on using the changeset viewer.