Changeset 17682 for trunk


Ignore:
Timestamp:
04/23/14 13:53:35 (11 years ago)
Author:
ftemme
Message:
Added the clipping of the trigger signal
Location:
trunk/Mars
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Mars/mbase/MArrayF.h

    r9211 r17682  
    170170
    171171    template<class T>
    172         void Add(T *src, Int_t n, Int_t p=0)
     172    void Add(T *src, Int_t n, Int_t p=0, Float_t m=1.)
     173    {
     174        // under these 3 conditions, we return immediately, because they either make no sense,
     175        // or result in an invariant array.
     176        if (p >= fN)
     177        {
     178            // maybe throw a warning, because p >= fN makes no sense at all
     179            return;
     180        }
     181        if ( n <= 0)
     182        {
     183            return;
     184        }
     185        if (m == 0.)
     186        {
     187            return;
     188        }
     189        if (src == NULL)
     190        {
     191            return;
     192        }
     193
     194        Float_t *dest = fArray + p;
     195        Float_t *end  = dest;
     196        if (n < fN-p)
     197        {
     198            end += n;
     199        }
     200        else
     201        {
     202            end += fN-p;
     203        }
     204
     205        // we treat the case m==1. special, in order to speed up the code a bit
     206        // since when m==1. the multiplication can be omitted and this should be a bit faster then.
     207        if (m == 1.)
     208        {
     209            while (dest<end)
     210                *dest++ += *src++;
     211        }
     212        else
     213        {
     214            while (dest<end)
     215                *dest++ += (*src++) * m;
     216        }
     217    }
     218
     219    template<class T>
     220        void AddClipped(Double_t th, T src, Int_t n, Int_t p=0)
    173221    {
    174222        Float_t *dest = fArray + p;
     
    176224
    177225        while (dest<end)
    178             *dest++ += *src++;
    179     }
    180 
    181     template<class T>
    182         void AddClipped(Double_t th, T src, Int_t n, Int_t p=0)
    183     {
    184         Float_t *dest = fArray + p;
    185         Float_t *end  = dest   + n;
    186 
    187         while (dest<end)
    188226            *dest++ += TMath::Min(*src++, th);
    189227    }
  • trunk/Mars/melectronics/MAnalogSignal.cc

    r9274 r17682  
    153153// Add a second analog signal. Just by addining it bin by bin.
    154154//
    155 void MAnalogSignal::AddSignal(const MAnalogSignal &s)
    156 {
    157     Add(s.GetArray(), s.fN);
    158 }
     155void MAnalogSignal::AddSignal(const MAnalogSignal &s, Int_t delay,
     156                              Float_t dampingFactor )
     157{
     158    Add(s.GetArray(), s.fN, delay, dampingFactor);
     159}
     160
    159161
    160162// Deprecated. Use MSimRandomPhotons instead
  • trunk/Mars/melectronics/MAnalogSignal.h

    r9274 r17682  
    2121    Bool_t AddPulse(const MSpline3 &spline, Float_t t, Float_t f=1);
    2222    Bool_t AddPulse(const TF1 &f1, Float_t t, Float_t f=1);
    23     void   AddSignal(const MAnalogSignal &s);
     23    void   AddSignal(const MAnalogSignal &s, Int_t delay=0,Float_t dampingFact=1.0);
    2424
    2525    // Deprecated. Use MSimRandomPhotons instead
  • trunk/Mars/msimcamera/MSimTrigger.cc

    r17209 r17682  
    9797//
    9898MSimTrigger::MSimTrigger(const char *name, const char *title)
    99     : fCamera(0), fPulsePos(0), fTrigger(0), fRunHeader(0),
    100     fEvtHeader(0), fElectronicNoise(0), fGain(0),
    101     fDiscriminatorThreshold(-1), fDigitalSignalLength(8), fCoincidenceTime(0.5),
    102     fShiftBaseline(kTRUE), fUngainSignal(kTRUE), fSimulateElectronics(kTRUE),
    103     fMinMultiplicity(-1)
     99    : fCamera(0),
     100      fPulsePos(0),
     101      fTrigger(0),
     102      fRunHeader(0),
     103      fEvtHeader(0),
     104      fElectronicNoise(0),
     105      fGain(0),
     106      fDiscriminatorThreshold(-1),
     107      fDigitalSignalLength(8),
     108      fCoincidenceTime(0.5),
     109      fShiftBaseline(kTRUE),
     110      fUngainSignal(kTRUE),
     111      fSimulateElectronics(kTRUE),
     112      fMinMultiplicity(-1),
     113      fCableDelay(21),
     114      fCableDamping(0.)     // default Damping Set to zero, so users, who do not set
     115                            // the CableDamoing in the ceres.rc do not see a difference.
     116
    104117{
    105118    fName  = name  ? name  : "MSimTrigger";
     
    385398    *fLog << "Using discriminator threshold of " << fDiscriminatorThreshold << endl;
    386399
     400    *fLog << "Using fCableDelay " << fCableDelay << endl;
     401    *fLog << "Using fCableDamping " << fCableDamping << endl;
     402
     403    ////////////////////////////////
     404    // open some output files for debugging
     405//    patch_file.open("/home/fact_opr/patch_file.csv", ios_base::out);
     406//    clipped_file.open("/home/fact_opr/clipped_file.csv", ios_base::out);
     407//    digital_file.open("/home/fact_opr/digital_file.csv", ios_base::out);
     408//    ratescan_file.open("/home/fact_opr/ratescan_file.csv", ios_base::out);
     409
     410
     411
    387412    return kTRUE;
    388413}
     
    497522    // summed overwrite with a newly allocated set of analog channels
    498523    MAnalogChannels *patches = fCamera;
     524    MAnalogChannels *raw_patches = fCamera;
    499525    if (!empty)
    500526    {
     
    502528
    503529        patches = new MAnalogChannels(npatch, fCamera->GetNumSamples());
    504         for (UInt_t i=0; i<npatch; i++)
    505         {
    506             const MArrayI &row = fRouteAC.GetRow(i);
    507             for (UInt_t j=0; j<row.GetSize(); j++)
     530        raw_patches = new MAnalogChannels(npatch, fCamera->GetNumSamples());
     531        for (UInt_t patch_id=0; patch_id<npatch; patch_id++)
     532        {
     533            const MArrayI &row = fRouteAC.GetRow(patch_id);
     534            for (UInt_t pxl_in_patch=0; pxl_in_patch<row.GetSize(); pxl_in_patch++)
    508535            {
    509                 const UInt_t idx = row[j];
     536                const UInt_t pixel_id = row[pxl_in_patch];
    510537
    511538                // FIXME: Shrinking the mapping table earlier (e.g.
    512539                //        ReInit) would avoid a lot of if's
    513                 if (idx<fCamera->GetNumChannels())
    514                     (*patches)[i].AddSignal((*fCamera)[idx]);
     540                if (pixel_id<fCamera->GetNumChannels())
     541                {
     542                    (*raw_patches)[patch_id].AddSignal((*fCamera)[pixel_id]);
     543                    (*patches)[patch_id].AddSignal((*fCamera)[pixel_id]);
     544                    (*patches)[patch_id].AddSignal((*fCamera)[pixel_id], fCableDelay, fCableDamping);
     545                }
    515546            }
    516547        }
    517548    }
     549
     550    // DN: 20140219 Ratescan:
     551    //
     552    //
     553//    for (UInt_t patch_id=0; patch_id<npatch; patch_id++)
     554//    {
     555//        MAnalogSignal current_patch = (*raw_patches)[patch_id];
     556//        float max = current_patch[0];
     557//        for (UInt_t i=1; i<current_patch.GetSize(); i++)
     558//        {
     559//            if (current_patch[i] > max)
     560//            {
     561//                max = current_patch[i];
     562//            }
     563//        }
     564//        ratescan_file << max << " ";
     565//    }
     566//    ratescan_file << endl;
     567
     568//    // DN 20131108: DEBUGGING:
     569//    for (UInt_t patch_id=0; patch_id<npatch; patch_id++)
     570//    {
     571//        for (UInt_t slice=0; slice<fCamera->GetNumSamples(); slice++)
     572//        {
     573//            patch_file << (*raw_patches)[patch_id][slice] << "\t";
     574//            clipped_file << (*patches)[patch_id][slice] << "\t";
     575//        }
     576//        patch_file << endl;
     577//        clipped_file << endl;
     578//    }
     579
     580
    518581
    519582    // FIXME: Write patches
     
    529592        const Double_t offset = fElectronicNoise ? (*fElectronicNoise)[i].GetPedestal() : 0;
    530593        const Double_t gain   = fGain            ? (*fGain)[i].GetPedestal()            : 1;
    531         ttls.AddAt((*patches)[i].Discriminate(fDiscriminatorThreshold*gain+offset, fDigitalSignalLength), i);
     594        ttls.AddAt(
     595                    (*patches)[i].Discriminate(
     596                        fDiscriminatorThreshold*gain+offset,                // treshold
     597                        Double_t(fCableDelay),                              // start
     598                        Double_t(fCamera->GetNumSamples() - fCableDelay),   // end
     599                        //fDigitalSignalLength                              // time-over-threshold, or fixed-length?
     600                        -1                                                  // -1 = time-over-threshold
     601                        ),
     602                    i
     603                    );
    532604    }
    533605
     
    537609    if (patches!=fCamera)
    538610        delete patches;
     611    if (raw_patches!=fCamera)
     612        delete raw_patches;
    539613
    540614    // =================== Simulate coincidences ======================
     
    557631    Int_t rmlo = 0;
    558632    Int_t rmhi = 0;
     633
     634//    cout << "MSimTrigger::fMinMultiplicity = " << fMinMultiplicity << endl;
     635//    cout << "MSimTrigger::fCoincidenceTime = " << fCoincidenceTime << endl;
     636//    cout << "fCoincidenceMap.GetEntries() = " << fCoincidenceMap.GetEntries() << endl;
     637//    cout << "MSimTrigger::fCableDelay = " << fCableDelay << endl;
     638//    cout << "MSimTrigger::fCableDamping = " << fCableDamping << endl;
     639//    cout << "min:" << min << endl;
     640//    cout << "max:" << max << endl;
    559641
    560642    for (int j=0; j<fCoincidenceMap.GetEntries(); j++)
     
    624706        arr->Compress();
    625707
     708//        cout << "ttls(j=" << j << "):";
     709//        TObjArray *arr2 = static_cast<TObjArray*>(ttls[j]);
     710//        TIter Nexty(arr);
     711//        MDigitalSignal *ttly = 0;
     712//        while ((ttly=static_cast<MDigitalSignal*>(Nexty())))
     713//        {
     714//            cout << "|"<< ttly->GetStart() << ", " << ttly->GetLength();
     715//        }
     716//        cout << endl;
     717
     718
    626719        // If we have at least one trigger keep the earliest one.
    627720        // FIXME: The triggers might be ordered in time automatically:
     
    674767}
    675768
     769Int_t MSimTrigger::PostProcess()
     770{
     771//    patch_file.close();
     772//    clipped_file.close();
     773//    digital_file.close();
     774//    ratescan_file.close();
     775    return kTRUE;
     776}
     777
     778
    676779// --------------------------------------------------------------------------
    677780//
     
    728831    }
    729832
     833    if (IsEnvDefined(env, prefix, "CableDelay", print))
     834    {
     835        rc = kTRUE;
     836        fCableDelay = GetEnvValue(env, prefix, "CableDelay", fCableDelay);
     837    }
     838
     839    if (IsEnvDefined(env, prefix, "CableDamping", print))
     840    {
     841        rc = kTRUE;
     842        fCableDamping = GetEnvValue(env, prefix, "CableDamping", fCableDamping);
     843    }
     844
     845
     846
    730847    return rc;
    731848}
  • trunk/Mars/msimcamera/MSimTrigger.h

    r9574 r17682  
    99#include "MLut.h"
    1010#endif
     11
     12#include <fstream>
    1113
    1214class MParList;
     
    3638    Float_t fDiscriminatorThreshold;    // Discriminator threshold
    3739    Float_t fDigitalSignalLength;       // Length of the output of the discriminator
    38     Float_t fCoincidenceTime;           // Minimum coincidence time (gate)
     40    Float_t fCoincidenceTime;           // Minimum coincidence time (gate) [slices]
    3941
    4042    Bool_t  fShiftBaseline;             // Shift the baseline back to 0 for the threshold (needs ElectronicNoise [MPedestalCam])
     
    4345
    4446    Int_t   fMinMultiplicity;           // N out of M
     47
     48    Int_t   fCableDelay;                // signal runtime on the clipping cable in slices, e.g. 105cm cable = 2*105cm
     49                                        // (20cm/ns) = 10.5ns = 21slices @ 2GHz [slices]
     50
     51    Float_t fCableDamping;              // the signal is damped a bit when reflecting at the end of the cable and is inverted as well.
     52                                        // Damping factor in [-1..0]. In short tests by Kai Schennetten it looked like -0.96.
     53
     54    // debugging
     55    std::ofstream patch_file;
     56    std::ofstream clipped_file;
     57    std::ofstream digital_file;
     58    std::ofstream ratescan_file;
     59
    4560
    4661    // MSimTrigger
     
    5368    Int_t PreProcess(MParList *pList);
    5469    Int_t Process();
     70    Int_t PostProcess();
    5571
    5672    // MParContainer
Note: See TracChangeset for help on using the changeset viewer.