Ignore:
Timestamp:
04/23/14 13:53:35 (11 years ago)
Author:
ftemme
Message:
Added the clipping of the trigger signal
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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}
Note: See TracChangeset for help on using the changeset viewer.