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

Legend:

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

    r9274 r9308  
    170170    }
    171171
     172    const Float_t freq = fHeader->GetFreqSampling()/1000.;
     173
     174    // We add an additional sample at the end to support a possible shift
     175    // of the start time of the first event by 0 to 1 sample.
     176    const Int_t   ns   = fHeader->GetNumSamplesHiGain()+1;
     177
    172178    const Float_t first = cnt>0 ? fEvt->GetFirst()->GetTime() :  0;
    173     const Float_t last  = cnt>0 ? fEvt->GetLast()->GetTime()  : -1;
     179    const Float_t last  = cnt>0 ? fEvt->GetLast()->GetTime()  : ns*freq;
    174180
    175181    // Length (ns), Pulse position (Units ns)
    176     const Float_t ns = fHeader->GetFreqSampling()/1000.*fHeader->GetNumSamplesHiGain();
    177     const Float_t pp = fPulsePos->GetVal();
    178     const Float_t pw = fPulse->GetPulseWidth();
    179 
    180     fStat->SetTime(first-pp-pw, last+(ns-pp)+pw);
     182    const Float_t pp   = fPulsePos->GetVal();
     183    const Float_t pw   = fPulse->GetPulseWidth();
     184
     185    fStat->SetTime(first-pp-pw, last-pp+pw + ns*freq);
    181186    fStat->SetMaxIndex(fGeom->GetNumPixels()-1);
    182187    fStat->SetReadyToSave();
  • trunk/MagicSoft/Mars/msimcamera/MSimReadout.cc

    r9274 r9308  
    7373//
    7474MSimReadout::MSimReadout(const char* name, const char *title)
    75 : fRunHeader(0), fCamera(0), fPulsePos(0), fTrigger(0), fData(0)
     75: fRunHeader(0), fEvtHeader(0), fCamera(0), fPulsePos(0), fTrigger(0), fData(0)
    7676{
    7777    fName  = name  ? name  : "MSimReadout";
     
    113113        return kFALSE;
    114114    }
     115
     116    fEvtHeader = (MRawEvtHeader*)pList->FindCreateObj("MRawEvtHeader");
     117    if (!fEvtHeader)
     118        return kFALSE;
    115119
    116120    fData = (MRawEvtData*)pList->FindCreateObj("MRawEvtData");
     
    244248    fData->SetReadyToSave();
    245249
     250    // Set the trigger/daq event number
     251    fEvtHeader->SetDAQEvtNumber(GetNumExecutions());
     252    fEvtHeader->SetReadyToSave();
     253
    246254    // FIMXE: This will never be stored correctly :(
    247255    fRunHeader->SetNumEvents(fRunHeader->GetNumEvents()+1);
  • trunk/MagicSoft/Mars/msimcamera/MSimReadout.h

    r9270 r9308  
    1010class MRawEvtData;
    1111class MRawRunHeader;
     12class MRawEvtHeader;
    1213class MAnalogChannels;
    1314
     
    1617private:
    1718    MRawRunHeader    *fRunHeader;  //! Digitization window and frequency
     19    MRawEvtHeader    *fEvtHeader;  //! Event header which is filled with the event number
    1820    MAnalogChannels  *fCamera;     //! Analog channes to be read out
    1921    MParameterD      *fPulsePos;   //! Intended pulse position
  • trunk/MagicSoft/Mars/msimcamera/MSimTrigger.cc

    r9278 r9308  
    3636// is calculated using a threshold and optional a fixed digital signal length.
    3737//
     38// The signal length of the digital signal emitted by the discriminator
     39// can either be bound to the time the signal is above the threshold
     40// defined by fDiscriminatorThreshold if fDigitalSignalLength<0 or set to a
     41// fixed length (fDigitalSignalLength>0).
     42//
    3843// With a second look-up table fCoincidenceMap the analog channels are
    39 // checked for coincidences. The earliest coincide is then stored as
     44// checked for coincidences. The coincidense must at least be of the length
     45// defined by fCoincidenceTime. The earliest coincide is then stored as
    4046// trigger position.
     47//
     48//
     49// For MAGIC1:
     50//  - fDigitalSignalLength between 6ns and 12ns
     51//  - fCoincidenceTime between 0.25ns to 1ns
    4152//
    4253//
     
    6980#include "MDigitalSignal.h"
    7081
     82#include "MTriggerPattern.h"
     83
    7184ClassImp(MSimTrigger);
    7285
     
    7992MSimTrigger::MSimTrigger(const char *name, const char *title)
    8093    : fCamera(0), fPulsePos(0), fTrigger(0), fRunHeader(0), fEvtHeader(0),
    81     fDiscriminatorThreshold(-1)
     94    fDiscriminatorThreshold(-1), fDigitalSignalLength(8), fCoincidenceTime(0.5)
    8295{
    8396    fName  = name  ? name  : "MSimTrigger";
     
    189202    fTrigger->SetVal(-1);
    190203
    191     // FIXME: Set from somewhere else? (see also MSimCalibrationSignal)
    192     fEvtHeader->SetDAQEvtNumber(GetNumExecutions());
    193     fEvtHeader->SetReadyToSave();
    194 
    195204    // ================== Simulate channel bundling ====================
    196205
     
    204213        for (UInt_t j=0; j<row.GetSize(); j++)
    205214        {
     215            // FIXME: Simulate clipping
    206216            const UInt_t idx = row[j];
    207217            patches[i].AddSignal((*fCamera)[idx]);
     
    216226    ttls.SetOwner();
    217227
    218         // MAGIC: Constant length of signals between 6ns and 12ns
    219     const Double_t siglen = 8; // Signal length (-1: As long as Signal-above-Threshold)
    220 
    221228    for (UInt_t i=0; i<npatch; i++)
    222         ttls.AddAt(patches[i].Discriminate(fDiscriminatorThreshold, siglen), i);
     229        ttls.AddAt(patches[i].Discriminate(fDiscriminatorThreshold, fDigitalSignalLength), i);
    223230
    224231    // FIXME: Write TTLs!
     
    235242    const Float_t max = fCamera->GetValidRangeMax()-(nsamp-pulspos);
    236243
    237     // Define gate time (minimum coincidence time)
    238     const Double_t gate = 1; // MAGIC: minimum coincidence time 0.25ns to 1ns,
    239 
    240244    // Create an array for the individual triggers
    241245    TObjArray triggers;
     
    258262        {
    259263            TObjArray *res = CalcCoincidence(*arr, *static_cast<TObjArray*>(ttls[idx[k]]),
    260                                              gate);
     264                                             fCoincidenceTime);
    261265
    262266            // Delete the original array and keep the new one
     
    303307    {
    304308        if (rmlo>0 || rmhi>0)
    305             *fLog << all << rmlo << "/" << rmhi << " trigger out of valid range. No trigger raised." << endl;
     309            *fLog << inf2 << rmlo << "/" << rmhi << " trigger out of valid range. No trigger raised." << endl;
    306310        return kTRUE;
    307311    }
     
    315319    // FIXME: Jitter! (Own class?)
    316320    fTrigger->SetVal(static_cast<MDigitalSignal*>(triggers[0])->GetStart());
     321    fTrigger->SetReadyToSave();
     322
     323    // Flag this event as triggered by the lvl1 trigger (FIXME?)
     324    fEvtHeader->SetTriggerPattern((UInt_t)~(MTriggerPattern::kTriggerLvl1 | (MTriggerPattern::kTriggerLvl1<<8)));
     325    fEvtHeader->SetReadyToSave();
    317326
    318327    // inf2?
    319     *fLog << all;
     328    *fLog << inf;
    320329    *fLog << cnt << " triggers left in " << triggers.GetEntriesFast() << " patches (" << rmlo << "/" << rmhi << " trigger out of valid range), T=" << fTrigger->GetVal();
    321330    *fLog << endl;
     
    329338// FileNameCoincidenceMap:  coincidence.txt
    330339// DiscriminatorTheshold:   3.5
     340// DigitalSignalLength:     8
     341// CoincidenceTime:         0.5
    331342//
    332343Int_t MSimTrigger::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
     
    351362    }
    352363
     364    if (IsEnvDefined(env, prefix, "DigitalSignalLength", print))
     365    {
     366        rc = kTRUE;
     367        fDigitalSignalLength = GetEnvValue(env, prefix, "DigitalSignalLength", fDigitalSignalLength);
     368    }
     369
     370    if (IsEnvDefined(env, prefix, "CoincidenceTime", print))
     371    {
     372        rc = kTRUE;
     373        fCoincidenceTime = GetEnvValue(env, prefix, "CoincidenceTime", fCoincidenceTime);
     374    }
     375
    353376    return rc;
    354377}
  • trunk/MagicSoft/Mars/msimcamera/MSimTrigger.h

    r9261 r9308  
    3232
    3333    Float_t fDiscriminatorThreshold;  // Discriminator threshold
     34    Float_t fDigitalSignalLength;     // Length of the output of the discriminator
     35    Float_t fCoincidenceTime;         // Minimum coincidence time (gate)
    3436
    3537    // MSimTrigger
     
    5052
    5153    void SetDiscriminatorThreshold(Float_t th) { fDiscriminatorThreshold=th; }
     54    void SetDigitalSignalLength(Float_t ln) { fDigitalSignalLength=ln; }
     55    void SetCoincidenceTime(Float_t tm) { fCoincidenceTime=tm; }
    5256
    5357    ClassDef(MSimTrigger, 0) // Task to simulate trigger electronics
  • trunk/MagicSoft/Mars/msimcamera/Makefile

    r9256 r9308  
    2020#
    2121INCLUDES = -I. -I../mbase -I../mgeom -I../msim -I../msignal -I../mcorsika \
    22            -I../mmc -I../mgui -I../mcalib -I../mraw -I../mfileio -I../melectronics
     22           -I../mmc -I../mgui -I../mcalib -I../mraw -I../mfileio -I../melectronics \
     23           -I../mtrigger
    2324
    2425SRCFILES = MSimPSF.cc \
Note: See TracChangeset for help on using the changeset viewer.