Changeset 9306 for trunk/MagicSoft


Ignore:
Timestamp:
02/09/09 11:19:57 (16 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/msimcamera
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/msimcamera/MSimCalibrationSignal.cc

    r9272 r9306  
    6161
    6262#include "MGeomCam.h"
     63#include "MPulseShape.h"
     64#include "MTriggerPattern.h"
    6365
    6466#include "MRawRunHeader.h"
     
    7779//
    7880MSimCalibrationSignal::MSimCalibrationSignal(const char* name, const char *title)
    79     : fParList(0), fGeom(0), fPulsePos(0), fTrigger(0), fRunHeader(0), fEvtHeader(0),
    80     fEvt(0), fStat(0),  fNumEntries(1000)
     81    : fParList(0), fGeom(0), fPulse(0), fPulsePos(0), fTrigger(0),
     82    fRunHeader(0), fEvtHeader(0),  fEvt(0), fStat(0),
     83    fNumEvents(1000), fNumPhotons(5), fTimeJitter(1)
    8184{
    8285    fName  = name  ? name  : "MRead";//"MSimCalibrationSignal";
     
    130133    }
    131134
     135    fPulse = (MPulseShape*)pList->FindObject("MPulseShape");
     136    if (!fPulse)
     137    {
     138        *fLog << err << "MPulsShape not found... aborting." << endl;
     139        return kFALSE;
     140    }
     141
     142    *fLog << all << "Number of Events: " << fNumEvents << endl;
     143
    132144    //
    133145    // Search for MTaskList
     
    167179Int_t MSimCalibrationSignal::Process()
    168180{
    169     if (GetNumExecutions()>fNumEntries)
     181    if (GetNumExecutions()>fNumEvents)
    170182        return kFALSE;
    171183
     
    178190        for (UInt_t idx=0; idx<fGeom->GetNumPixels(); idx++)
    179191        {
    180             // FIXME: Where to get this number from?
    181             for (int i=0; i<5; i++)
     192            // FIXME: How does the distribution look like? Poissonian?
     193            for (UInt_t i=0; i<fNumPhotons; i++)
    182194            {
    183195                MPhotonData &ph = fEvt->Add(cnt++);
    184196
    185                 const Float_t tm = gRandom->Gaus(0, 1);
     197                // FIMXE: Is this the correct distribution
     198                const Float_t tm = gRandom->Gaus(0, fTimeJitter);
    186199
    187200                ph.SetPrimary(MMcEvtBasic::kArtificial);
     
    201214    const Double_t freq = fRunHeader->GetFreqSampling()/1000.;
    202215
     216    // We add an additional sample at the end to support a possible shift
     217    // of the start time of the first event by 0 to 1 sample.
     218    const Int_t   ns = fRunHeader->GetNumSamplesHiGain()+1;
     219
    203220    // Length (ns), Pulse position (Units ns)
    204     const Float_t ns = fRunHeader->GetNumSamplesHiGain()*freq;
    205221    const Float_t pp = fPulsePos->GetVal();
     222    const Float_t pw = fPulse->GetPulseWidth();
    206223
    207224    const Float_t first = cnt>0 ? fEvt->GetFirst()->GetTime() : 0;
    208     const Float_t last  = cnt>0 ? fEvt->GetLast()->GetTime()  : ns;
    209 
    210     fStat->SetTime(first-pp, last+(ns-pp));
     225    const Float_t last  = cnt>0 ? fEvt->GetLast()->GetTime()  : ns*freq;
     226
     227    fStat->SetTime(first-pp-pw, last-pp+pw + ns*freq);
    211228    fStat->SetMaxIndex(fGeom->GetNumPixels()-1);
    212229    fStat->SetReadyToSave();
     
    214231    // FIXME: Jitter! (Own class?)
    215232    fTrigger->SetVal(pp*freq);
    216 
    217     // FIXME: Set from somewhere else? (see also MSimTrigger)
    218     fEvtHeader->SetDAQEvtNumber(GetNumExecutions());
     233    fTrigger->SetReadyToSave();
     234
     235    // Set trigger pattern according to the trigger type
     236    const UInt_t p = fRunHeader->IsCalibrationRun() ? MTriggerPattern::kCalibration : MTriggerPattern::kPedestal;
     237    fEvtHeader->SetTriggerPattern(~(p | (p<<8)));
    219238    fEvtHeader->SetReadyToSave();
    220239
    221240    return kTRUE;
    222 
    223 }
     241}
     242
     243// --------------------------------------------------------------------------
     244//
     245// Read the parameters from the resource file.
     246//
     247//    NumEvents:   1000
     248//    NumPhotons:     5
     249//    TimeJitter:     1
     250//
     251Int_t MSimCalibrationSignal::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
     252{
     253    Bool_t rc = kFALSE;
     254    if (IsEnvDefined(env, prefix, "NumEvents", print))
     255    {
     256        rc = kTRUE;
     257        fNumEvents = GetEnvValue(env, prefix, "NumEvents", (Int_t)fNumEvents);
     258    }
     259
     260    if (IsEnvDefined(env, prefix, "NumPhotons", print))
     261    {
     262        rc = kTRUE;
     263        fNumPhotons = GetEnvValue(env, prefix, "NumPhotons", (Int_t)fNumPhotons);
     264    }
     265
     266    if (IsEnvDefined(env, prefix, "TimeJitter", print))
     267    {
     268        rc = kTRUE;
     269        fTimeJitter = GetEnvValue(env, prefix, "TimeJitter", fTimeJitter);
     270    }
     271
     272    return rc;
     273}
  • trunk/MagicSoft/Mars/msimcamera/MSimCalibrationSignal.h

    r9272 r9306  
    88class MGeomCam;
    99class MParList;
     10class MPulseShape;
    1011class MPhotonEvent;
    1112class MPhotonStatistics;
     
    1920    MParList          *fParList;    //! Store pointer to MParList for initializing ReInit
    2021    MGeomCam          *fGeom;       //! Camera geometry to know the number of expected pixels
     22    MPulseShape       *fPulse;      //! Pulse Shape to get pulse width from
    2123    MParameterD       *fPulsePos;   //! Expected position at which the pulse should be
    2224    MParameterD       *fTrigger;    //! Position in analog channels at which the triggersignal  is raised
    2325    MRawRunHeader     *fRunHeader;  //! Digitization window and frequency
    2426
    25     MRawEvtHeader     *fEvtHeader;  //! Event header which is filled
     27    MRawEvtHeader     *fEvtHeader;  //! Event header which is filled by the trigger pattern
    2628    MPhotonEvent      *fEvt;        //! Photon event into which the new photons are stored
    2729    MPhotonStatistics *fStat;       //! Photon statistic which is filled
     
    2931    TString fNameGeomCam;           // Name of the camera geometry
    3032
    31     UInt_t fNumEntries;             // Number of events to produce
     33    UInt_t  fNumEvents;             // Number of events to produce
     34    UInt_t  fNumPhotons;            // Average number of photons to produce
     35    Float_t fTimeJitter;            // Time jitter (sigma)
     36
     37    // MParContainer
     38    Int_t ReadEnv(const TEnv &env, TString prefix, Bool_t print=kFALSE);
    3239
    3340    // MTask
     
    4451    void SetNameGeomCam(const char *name="MGeomCam") { fNameGeomCam = name; }
    4552
    46     UInt_t  GetEntries() { return fNumEntries; }
     53    UInt_t  GetEntries() { return fNumEvents; }
    4754    TString GetFullFileName() const { return "cer000000"; }
    4855    //virtual Bool_t  Rewind();
Note: See TracChangeset for help on using the changeset viewer.