Changeset 9274 for trunk/MagicSoft/Mars


Ignore:
Timestamp:
01/27/09 10:40:55 (16 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
2 added
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r9267 r9274  
    1919                                                 -*-*- END OF LINE -*-*-
    2020
     21 2009/01/27 Thomas Bretz
     22
     23  * macros/rootlogon.C:
     24     - added new subdirectories
     25
     26   * melectronics/MAnalogSignal.[h,cc]:
     27     - added the posssibility to add a pulse from a TF1
     28     - removed the printout if out of range
     29     - returns whether the range had to be adapted
     30     - changed the Discriminate function to allow for giving a start
     31       and end time of the search
     32     - imporved the fining of the falling and rising edge
     33     - removed the printout in Discriminate
     34
     35   * msimcamera/MSimCamera.[h,cc]:
     36     - moved the pulse shape specific code into a new class MPulseShape
     37     - Fixed the range of the digitization
     38
     39   * melectronics/MPulseShape.[h,cc]:
     40     - added
     41
     42   * melectronics/Makefile, melectronics/ElectronicsLinkDef.h:
     43     - added MPulseShape
     44
     45   * msimcamera/MSimGeomCam.[h,cc]:
     46     - Fixed the time window for random photons (Maybe move to a later step
     47       in the analysis?)
     48
     49   * msimcamera/MSimReadout.cc:
     50     - call SetReadyToSave for the run-header
     51     - added some debug output in case of failure
     52
     53   * msimcamera/MSimSignalCam.[h,cc]:
     54     - subtract the trigger position of any
     55
     56   * msimcamera/MSimTrigger.cc:
     57     - some changes to the debug output
     58
     59
     60
    2161 2009/01/26 Thomas Bretz
    2262
     
    2565       msimelectronics
    2666     - added readcorsika
     67
     68   * mbase/Makefile, mbase/BaseLinkDef.h:
     69     - added MParEnv
     70
     71   * mbase/MParEnv.[h,cc]:
     72     - added
     73
     74   * mbase/MParameters.[h,cc]:
     75     - added ReadEnv to all classes
     76
     77   * mbase/MParList.cc:
     78     - return the container within MParEnv if MParEnv found
     79
     80   * mbase/MParContainer.cc:
     81     - fixed a typo
     82
     83   * manalysis/MEventRateCalc.cc:
     84     - added a comment
     85
     86   * melectronics/MAnalogChannels.[h,cc]:
     87     - made the GetNum* unsigned
     88     - added new member functions to just initialize one size
     89
     90   * mraw/MRawRunHeader.[h,cc]:
     91     - added a possibility to just init the number of pixels
     92
     93   * msimcamera/MSimReadout.[h,cc]:
     94     - get the number of output channels from the camera geometry
     95     - initialize the runheader in ReInit
     96     - initialize the data arrays from the run-header in reinit
     97
     98   * mimage/MHHillas.cc:
     99     - the default binning is not scales by 0.9 anymore
     100
     101   * mmc/MMcEvtBasic.h:
     102     - added new type "artificial"
     103
     104   * mraw/MRawRunHeader.cc:
     105     - set header size in constructor to 0
     106
     107   * msimcamera/MSimCalibrationSignal.[h,cc]:
     108     - we need fEvt and fTrigger always
     109     - renamed ReInit to CallReInit
     110     - set photon primary type
     111     - set number of photons from 50 to 5
     112
     113   * msimcamera/MSimRandomPhotons.cc:
     114     - explicitly set weight to 1
     115
     116   * mjobs/Makefile:
     117     - added msim, msimreflector, msimcamera and mcorsika
    27118
    28119
  • trunk/MagicSoft/Mars/NEWS

    r9262 r9274  
    4343     This is just a tiny change but it might change the appearance of
    4444     the radial profiles a little bit.
     45
     46   * The default binning of the center-of-gravity plot has slightly been
     47     increased
    4548
    4649 ;Database
  • trunk/MagicSoft/Mars/macros/rootlogon.C

    r8900 r9274  
    163163    gInterpreter->AddIncludePath(dir+"mtools");
    164164    gInterpreter->AddIncludePath(dir+"mtrigger");
     165    gInterpreter->AddIncludePath(dir+"melectronics");
     166    gInterpreter->AddIncludePath(dir+"msim");
     167    gInterpreter->AddIncludePath(dir+"msimreflector");
     168    gInterpreter->AddIncludePath(dir+"msimcamera");
     169    gInterpreter->AddIncludePath(dir+"mcorsika");
    165170
    166171    if (TString("linux")==gSystem->GetBuildArch())
  • trunk/MagicSoft/Mars/melectronics/ElectronicsLinkDef.h

    r9242 r9274  
    66
    77#pragma link C++ class APD+;
     8#pragma link C++ class MPulseShape+;
    89#pragma link C++ class MAnalogSignal+;
    910#pragma link C++ class MDigitalSignal+;
  • trunk/MagicSoft/Mars/melectronics/MAnalogSignal.cc

    r9252 r9274  
    3333#include "MAnalogSignal.h"
    3434
     35#include <TF1.h>
    3536#include <TRandom.h>
    3637#include <TObjArray.h>
     
    6970// and multiplied by f.
    7071//
    71 void MAnalogSignal::AddPulse(const MSpline3 &spline, Float_t t, Float_t f)
     72// Return kTRUE if the full range of the spline could be added to the
     73// analog signal, kFALSE otherwise.
     74//
     75Bool_t MAnalogSignal::AddPulse(const MSpline3 &spline, Float_t t, Float_t f)
    7276{
    7377    // FIXME: This could be improved using a MExtralgoSpline with
     
    7983    const Float_t end   = t+spline.GetXmax();
    8084
    81     /*const*/ Int_t  first = TMath::CeilNint(start);
    82     /*const*/ UInt_t last  = TMath::CeilNint(end); // Ceil:< Floor:<=
    83 
    84     if (first<0 || last>GetSize())
    85     {
    86         gLog << err << "ERROR - AddPulse: Out of bounds, ";
    87         gLog << "Win=[" << first << "," << last << "] N=" << GetSize() << " t=" << t;
    88         gLog << " Spline=[" << spline.GetXmin() << "," << spline.GetXmax() << "]" << endl;
    89 
    90         if (first<0)
    91             first=0;
    92         if (last>GetSize())
    93             last=GetSize();
    94     }
     85    Int_t  first = TMath::CeilNint(start);
     86    UInt_t last  = TMath::CeilNint(end); // Ceil:< Floor:<=
     87
     88    Bool_t rc = kTRUE;
     89    if (first<0)
     90    {
     91        first=0;
     92        rc = kFALSE;
     93    }
     94    if (last>GetSize())
     95    {
     96        last=GetSize();
     97        rc = kFALSE;
     98    }
     99
     100    // FIXME: As soon as we have access to TSpline3::fPoly we can
     101    //        gain a lot in execution speed here.
    95102
    96103    Float_t *arr = GetArray();
    97104    for (UInt_t i=first; i<last; i++)
    98105        arr[i] += spline.Eval(i-t)*f;
     106
     107    return rc;
     108}
     109
     110// ------------------------------------------------------------------------
     111//
     112// Evaluate the spline an add the result between t+xmin and t+xmax
     113// (xmin and xmax are the limits of the TF1) to the signal.
     114// The spline is evaluated at the bin-center of the analog signal
     115// and multiplied by f.
     116//
     117// Return kTRUE if the full range of the function could be added to the
     118// analog signal, kFALSE otherwise.
     119//
     120Bool_t MAnalogSignal::AddPulse(const TF1 &func, Float_t t, Float_t f)
     121{
     122    // Both in units of the sampling frequency
     123    const Float_t start = t+func.GetXmin();
     124    const Float_t end   = t+func.GetXmax();
     125
     126    Int_t  first = TMath::CeilNint(start);
     127    UInt_t last  = TMath::CeilNint(end); // Ceil:< Floor:<=
     128
     129    Bool_t rc = kTRUE;
     130    if (first<0)
     131    {
     132        first=0;
     133        rc = kFALSE;
     134    }
     135    if (last>GetSize())
     136    {
     137        last=GetSize();
     138        rc = kFALSE;
     139    }
     140
     141    // FIXME: As soon as we have access to TSpline3::fPoly we can
     142    //        gain a lot in execution speed here.
     143
     144    Float_t *arr = GetArray();
     145    for (UInt_t i=first; i<last; i++)
     146        arr[i] += func.Eval(i-t)*f;
     147
     148    return rc;
    99149}
    100150
     
    156206// The user is responsible of deleting the TObjArray.
    157207//
    158 TObjArray *MAnalogSignal::Discriminate(Float_t threshold, Float_t len) const
     208TObjArray *MAnalogSignal::Discriminate(Float_t threshold, Double_t start, Double_t end, Float_t len) const
    159209{
    160210    TObjArray *ttl = new TObjArray;
     
    175225
    176226    Double_t x1 = 0;
    177     Double_t x2 = 0;
     227    Double_t x2 = start;  // Start searching at x2
    178228
    179229    while (1)
    180230    {
    181         x1 = sp.SearchYup(x2+deadtime, threshold);
    182         if (x1<0)
    183             break;
    184 
    185         const Bool_t rising = sp.Deriv1(x1)>0;
    186         if (!rising)
     231        // Search for the next rising edge (starting at x2)
     232        while (1)
    187233        {
    188             // The last value might just have been a local max/min
    189             // or its period was short than 1e-4
     234            x1 = sp.SearchYup(x2+deadtime, threshold);
     235            if (x1<0 || x1>=end)
     236                return ttl;
     237
     238            const Bool_t rising = sp.Deriv1(x1)>0;
     239            if (rising)
     240                break;
     241
    190242            x2 = x1;
    191             //gLog << warn << "Rising edge expected at " << x1 << " (after " << x2 << ", N=" << fN << ")" << endl;
    192             continue;
    193243        }
    194244
    195         x2 = sp.SearchYup(x1+deadtime, threshold);
    196         if (x2<0)
    197             break;
    198 
    199         const Bool_t falling = sp.Deriv1(x2)<=0;
    200         if (!falling)
     245        // Search for the next falling edge (starting at x1)
     246        while (1)
    201247        {
    202             // The last value might just have been a local max/min
    203             // or its period was short than 1e-4
     248            x2 = sp.SearchYup(x1+deadtime, threshold);
     249            if (x2<0)
     250                x2 = end;
     251            if (x2>=end)
     252                break;
     253
     254            const Bool_t falling = sp.Deriv1(x2)<0;
     255            if (falling)
     256                break;
     257
    204258            x1 = x2;
    205             //gLog << warn << "Falling edge expected at " << x2 << " (after " << x1 << " N=" << fN << ")" << endl;
    206             continue;
    207259        }
    208260
     261        // We found a rising and a falling edge
    209262        MDigitalSignal *sig = new MDigitalSignal(x1, len>0?len:x2-x1);
    210263
     
    228281    }
    229282
    230     if (x1>=0)
    231         gLog << warn << "Falling edge expected before end at N=" << fN << "!" << endl;
    232 
    233283    return ttl;
    234284}
  • trunk/MagicSoft/Mars/melectronics/MAnalogSignal.h

    r9242 r9274  
    66#endif
    77
     8class TF1;
    89class MSpline3;
    910
     
    1718    MAnalogSignal(UInt_t n) { Set(n); }
    1819
    19     void Set(UInt_t n);
    20     void AddPulse(const MSpline3 &spline, Float_t t, Float_t f=1);
    21     void AddSignal(const MAnalogSignal &s);
     20    void   Set(UInt_t n);
     21    Bool_t AddPulse(const MSpline3 &spline, Float_t t, Float_t f=1);
     22    Bool_t AddPulse(const TF1 &f1, Float_t t, Float_t f=1);
     23    void   AddSignal(const MAnalogSignal &s);
    2224
    2325    // Deprecated. Use MSimRandomPhotons instead
     
    2628    void AddGaussianNoise(Float_t amplitude=1, Float_t offset=0);
    2729
    28     TObjArray *Discriminate(Float_t threshold, Float_t len=-1) const;
     30    TObjArray *Discriminate(Float_t threshold, Double_t start, Double_t end, Float_t len=-1) const;
     31    TObjArray *Discriminate(Float_t threshold, Float_t len=-1) const { return Discriminate(threshold, 0, fN-1, len); }
    2932
    3033    ClassDef(MAnalogSignal, 1) // Storage class for an analog signal
  • trunk/MagicSoft/Mars/melectronics/Makefile

    r9242 r9274  
    2424           MAnalogSignal.cc \
    2525           MAnalogChannels.cc \
    26            MDigitalSignal.cc
     26           MDigitalSignal.cc  \
     27           MPulseShape.cc
    2728
    2829############################################################
  • trunk/MagicSoft/Mars/msimcamera/MSimCamera.cc

    r9256 r9274  
    4747
    4848#include "MSpline3.h"
     49#include "MPulseShape.h"
    4950
    5051#include "MParList.h"
     52//#include "MParameters.h"
    5153
    5254#include "MPhotonEvent.h"
     
    6769//
    6870MSimCamera::MSimCamera(const char* name, const char *title)
    69 : fEvt(0), fStat(0), fRunHeader(0), fCamera(0), fSpline(0),
    70   fFunction("exp(-(x/2)^2/2)"), fNpx(25), fXmin(-25), fXmax(25)
     71: fEvt(0), fStat(0), fRunHeader(0), fCamera(0), fSpline(0)//, fPulsePos(0)
    7172{
    7273    fName  = name  ? name  : "MSimCamera";
     
    7677// --------------------------------------------------------------------------
    7778//
    78 //  Call Clear()
    79 //
    80 MSimCamera::~MSimCamera()
    81 {
    82     Clear();
    83 }
    84 
    85 // --------------------------------------------------------------------------
    86 //
    87 //  Delete fSpline if set and set it to 0
    88 //
    89 void MSimCamera::Clear(Option_t *)
    90 {
    91     if (fSpline)
    92         delete fSpline;
    93     fSpline=0;
    94 }
    95 
    96 // --------------------------------------------------------------------------
    97 //
    98 //  Read the intended pulse shape from a file and initialize the spline
    99 // accordingly
    100 //
    101 Bool_t MSimCamera::ReadFile(const char *fname)
    102 {
    103     if (!fRunHeader)
    104         return kFALSE;
    105 
    106     if (fname)
    107         fFileName = fname;
    108 
    109     *fLog << inf << "Reading pulse shape from " << fFileName << endl;
    110 
    111     const TGraph g(fFileName);
    112     if (g.GetN()==0)
    113     {
    114         *fLog << err << "ERROR - No data points from " << fFileName << "." << endl;
    115         return kFALSE;
    116     }
    117 
    118     // option: b1/e1 b2/e2   (first second derivative?)
    119     // option: valbeg/valend (first second derivative?)
    120 
    121     Clear();
    122     fSpline = new MSpline3(g, fRunHeader->GetFreqSampling()/1000.);
    123 
    124     return kTRUE;
    125 }
    126 
    127 void MSimCamera::SetFunction(const TF1 &f)
    128 {
    129     // FIXME: Use TF1 directly? (In most cases this seems to be slower)
    130     if (!fRunHeader)
    131         return;// kFALSE;
    132 
    133     // option: b1/e1 b2/e2   (first second derivative?)
    134     // option: valbeg/valend (first second derivative?)
    135 
    136     // if (f.GetNpar()==0)
    137     // No SUPPORT
    138 
    139     Clear();
    140     fSpline = new MSpline3(f, fRunHeader->GetFreqSampling()/1000.);
    141 
    142     fFunction = f.GetTitle();
    143 }
    144 
    145 Bool_t MSimCamera::SetFunction(const char *func, Int_t n, Double_t xmin, Double_t xmax)
    146 {
    147     // FIXME: Use TF1 directly? (In most cases this seems to be slower)
    148     TF1 f("f", func, xmin, xmax);
    149     f.SetNpx(n);
    150 
    151     SetFunction(f);
    152 
    153     return kTRUE;
    154 }
    155 
    156 // --------------------------------------------------------------------------
    157 //
    158 // SetReadyToSave for fRunHeader
    159 //
    160 Bool_t MSimCamera::ReInit(MParList *pList)
    161 {
    162     // make that the run-header gets written to the file
    163     fRunHeader->SetReadyToSave();
    164 
    165     return kTRUE;
    166 }
    167 
    168 // --------------------------------------------------------------------------
    169 //
    17079// Search for the necessayr parameter containers.
    17180// Setup spline for pulse shape.
     
    197106        return kFALSE;
    198107    }
    199 
    200 
    201     // FIMXE: Move to ReInit in case fRunHeader is read form file?
    202     if (!fFileName.IsNull())
    203         return ReadFile(fFileName);
    204 
    205     if (!fFunction.IsNull())
    206         return SetFunction(fFunction, fNpx, fXmin, fXmax);
    207 
     108/*
     109    fPulsePos = (MParameterD*)pList->FindObject("IntendedPulsePos", "MParameterD");
     110    if (!fPulsePos)
     111    {
     112        *fLog << err << "IntendedPulsePos [MParameterD] not found... aborting." << endl;
     113        return kFALSE;
     114    }
     115 */
     116    MPulseShape *pulse = (MPulseShape*)pList->FindObject("MPulseShape");
     117    if (!pulse)
     118    {
     119        *fLog << err << "MPulseShape not found... aborting." << endl;
     120        return kFALSE;
     121    }
     122
     123    *fLog << warn << "FIXME - SCALE WITH THE SAMPLING FREQUENCY." << endl;
     124
     125    fSpline = pulse->GetSpline();
    208126    if (!fSpline)
    209127    {
     
    225143    const Double_t freq = fRunHeader->GetFreqSampling()/1000.;
    226144
    227     const Double_t start = fStat->GetTimeFirst()*freq + fSpline->GetXmin();
    228     const Double_t end   = fStat->GetTimeLast() *freq + fSpline->GetXmax();
     145    const Double_t start = fStat->GetTimeFirst()*freq;
     146    const Double_t end   = fStat->GetTimeLast() *freq;
    229147
    230148    const UInt_t   nlen  = TMath::CeilNint(end-start);
     
    236154    const UInt_t npix = fStat->GetMaxIndex()+1;
    237155
     156    const Double_t pl = fSpline->GetXmin()*freq;
     157    const Double_t pr = fSpline->GetXmax()*freq;
     158
    238159    // Init the arrays and set the range which will contain valid data
    239160    fCamera->Init(npix, nlen);
    240     fCamera->SetValidRange(0   -TMath::FloorNint(fSpline->GetXmin()),
    241                            nlen-TMath::CeilNint( fSpline->GetXmax()));
     161    fCamera->SetValidRange(TMath::FloorNint(pr), TMath::CeilNint(nlen+pl));
    242162
    243163    // Add electronic noise to empty channels
     
    258178
    259179        const UInt_t   idx = ph.GetTag();
    260         const Double_t t   = (ph.GetTime()-fStat->GetTimeFirst())*freq - fSpline->GetXmin();
     180        const Double_t t   = (ph.GetTime()-fStat->GetTimeFirst())*freq;// - fSpline->GetXmin();
    261181
    262182        // FIXME: Time jitter?
    263183        // FIXME: Add additional routing here?
    264184
     185        // === FIXME === FIXME === FIXME === Frequency!!!!
    265186        (*fCamera)[idx].AddPulse(*fSpline, t, ph.GetWeight());
    266187    }
    267188
    268189    return kTRUE;
    269 }
    270 
    271 // --------------------------------------------------------------------------
    272 //
    273 // FileName: pulse-shape.txt
    274 // Function.Name: gaus
    275 // Function.Npx:    50
    276 // Function.Xmin:  -5
    277 // Function.Xmax:   5
    278 //
    279 Int_t MSimCamera::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
    280 {
    281     Bool_t rc = kFALSE;
    282     if (IsEnvDefined(env, prefix, "FileName", print))
    283     {
    284         rc = kTRUE;
    285         SetFileName(GetEnvValue(env, prefix, "FileName", fFileName));
    286     }
    287 
    288     if (IsEnvDefined(env, prefix, "Function.Name", print))
    289     {
    290         rc = kTRUE;
    291         SetFunction(GetEnvValue(env, prefix, "Function.Name", fFunction));
    292 
    293         if (IsEnvDefined(env, prefix, "Function.Npx", print))
    294             fNpx = GetEnvValue(env, prefix, "Function.Npx", fNpx);
    295         if (IsEnvDefined(env, prefix, "Function.Xmin", print))
    296             fXmin = GetEnvValue(env, prefix, "Function.Xmin", fXmin);
    297         if (IsEnvDefined(env, prefix, "Function.Xmax", print))
    298             fXmax = GetEnvValue(env, prefix, "Function.Xmax", fXmax);
    299     }
    300 
    301     return rc;
    302190}
    303191
  • trunk/MagicSoft/Mars/msimcamera/MSimCamera.h

    r9256 r9274  
    1212class MAnalogChannels;
    1313
    14 class TF1;
    1514class MSpline3;
    1615
     
    2423    MAnalogChannels   *fCamera;     //! Output of the analog signals
    2524
    26     MSpline3          *fSpline;     //! Spline to describe the pulse shape
    27 
    28     TString fFileName;              // File name of a file describing the pulse shape
    29 
    30     TString fFunction;              // Function describing the pulse shape
    31     Int_t   fNpx;                   // Number of
    32     Float_t fXmin;
    33     Float_t fXmax;
    34 
    35     // MParContainer
    36     Int_t ReadEnv(const TEnv &env, TString prefix, Bool_t print=kFALSE);
     25    MSpline3 *fSpline;
    3726
    3827    // MTask
    3928    Int_t PreProcess(MParList *pList);
    4029    Int_t Process();
    41     Bool_t ReInit(MParList *pList);
    42 
    43     Bool_t ReadFile(const char *fname);
    44     Bool_t SetFunction(const char *func, Int_t n, Double_t xmin, Double_t xmax);
    4530
    4631public:
    4732    MSimCamera(const char *name=NULL, const char *title=NULL);
    48     ~MSimCamera();
    49 
    50     void SetFunction(const TF1 &f);
    51     void SetFunction(const char *f)  { fFunction=f; fFileName=""; }
    52     void SetFileName(const char *n)  { fFileName=n; fFunction=""; }
    53 
    54     void Clear(Option_t *o="");
    5533
    5634    ClassDef(MSimCamera, 0) // Task to simulate the electronic noise and to convert photons into pulses
  • trunk/MagicSoft/Mars/msimcamera/MSimGeomCam.cc

    r9243 r9274  
    6161#include "MRawRunHeader.h"
    6262
     63#include "MPulseShape.h"
     64
    6365ClassImp(MSimGeomCam);
    6466
     
    7072//
    7173MSimGeomCam::MSimGeomCam(const char* name, const char *title)
    72     : fGeom(0), fEvt(0), fStat(0), fNameGeomCam("MGeomCam")
     74    : fGeom(0), fEvt(0), fStat(0), fPulsePos(0), fHeader(0), fPulse(0),
     75    fNameGeomCam("MGeomCam")
    7376{
    7477    fName  = name  ? name  : "MSimGeomCam";
     
    9699    {
    97100        *fLog << err << "MPhotonEvent not found... aborting." << endl;
     101        return kFALSE;
     102    }
     103
     104    fPulse = (MPulseShape*)pList->FindObject("MPulseShape");
     105    if (!fPulse)
     106    {
     107        *fLog << err << "MPulsShape not found... aborting." << endl;
    98108        return kFALSE;
    99109    }
     
    166176    const Float_t ns = fHeader->GetFreqSampling()/1000.*fHeader->GetNumSamplesHiGain();
    167177    const Float_t pp = fPulsePos->GetVal();
    168 
    169     // FIXME FIXME FIXME --- Make it depending on the trigger position?
    170 
    171     fStat->SetTime(first-pp, last+(ns-pp));
     178    const Float_t pw = fPulse->GetPulseWidth();
     179
     180    fStat->SetTime(first-pp-pw, last+(ns-pp)+pw);
    172181    fStat->SetMaxIndex(fGeom->GetNumPixels()-1);
    173182    fStat->SetReadyToSave();
  • trunk/MagicSoft/Mars/msimcamera/MSimGeomCam.h

    r9239 r9274  
    1313class MParameterD;
    1414class MRawRunHeader;
     15class MPulseShape;
    1516
    1617class MSimGeomCam : public MTask
     
    2223    MParameterD       *fPulsePos; //! Intended pulse position in digitization window [ns]
    2324    MRawRunHeader     *fHeader;   //! Length of digitization window
    24 
     25    MPulseShape       *fPulse;    //!
    2526
    2627    TString fNameGeomCam;
  • trunk/MagicSoft/Mars/msimcamera/MSimReadout.cc

    r9272 r9274  
    133133    fRunHeader->SetValidMagicNumber();
    134134    fRunHeader->SetSourceInfo("MonteCarlo");  // "Muon" from first event??
     135    fRunHeader->SetReadyToSave();
    135136
    136137    fData->InitRead(fRunHeader);
     
    197198    {
    198199        *fLog << err << "ERROR - Trigger position beyond valid analog signal range." << endl;
     200        *fLog << "        Trigger:    " << fTrigger->GetVal() << endl;
     201        *fLog << "        PulsePos:   " << pulpos << endl;
     202        *fLog << "        SamplesIn:  " << nsamp << endl;
     203        *fLog << "        SamplesOut: " << nslices << endl;
    199204        return kERROR;
    200205    }
     
    239244    fData->SetReadyToSave();
    240245
     246    // FIMXE: This will never be stored correctly :(
    241247    fRunHeader->SetNumEvents(fRunHeader->GetNumEvents()+1);
    242248
  • trunk/MagicSoft/Mars/msimcamera/MSimSignalCam.cc

    r9261 r9274  
    4646
    4747#include "MParList.h"
     48#include "MParameters.h"
    4849
    4950#include "MSignalCam.h"
     
    6263//
    6364MSimSignalCam::MSimSignalCam(const char* name, const char *title)
    64     : fEvt(0), fStat(0), fSignal(0)
     65    : fEvt(0), fStat(0), fSignal(0), fTrigger(0)
    6566{
    6667    fName  = name  ? name  : "MSimSignalCam";
     
    8586    {
    8687        *fLog << err << "MPhotonStatistics not found... aborting." << endl;
     88        return kFALSE;
     89    }
     90
     91    fTrigger = (MParameterD*)pList->FindObject("TriggerPos", "MParameterD");
     92    if (!fTrigger)
     93    {
     94        *fLog << err << "TriggerPos [MParameterD] not found... aborting." << endl;
    8795        return kFALSE;
    8896    }
     
    123131{
    124132    // FIXME: Check the maximum index in GetTag from the statistics container
    125 
    126133    fCont.Reset();
    127134    fTime.Reset();
     
    152159    // Get time of start point from the statistics container
    153160    //   FIXME: Should be the real time of the first photon
    154     const Float_t first = fStat->GetTimeFirst();
     161
     162    // ====> Distance to trigger position! (if TrigPos found!)
     163    // What about events with trigger<0?
     164    const Float_t trig  = fTrigger && fTrigger->GetVal()>=0 ? fTrigger->GetVal()  : 0;
     165    const Float_t first = fStat->GetTimeFirst()+trig /*+50+40*/;
    155166
    156167    // Loop over all pixels and set signal and arrival time.
     
    161172        MSignalPix &pix = (*fSignal)[idx];
    162173
    163         pix.SetNumPhotons(fCont[idx]); // gRandom->Uniform(last-first)
     174        pix.SetNumPhotons(fCont[idx]);
    164175        pix.SetArrivalTime(fCont[idx]<=0 ? -1 : fTime[idx]/fCont[idx]-first);
    165176        pix.SetRing(fCont[idx]>0); // Used==1, Unused==0
  • trunk/MagicSoft/Mars/msimcamera/MSimSignalCam.h

    r9239 r9274  
    1818class MPhotonStatistics;
    1919class MSignalCam;
     20class MParameterD;
    2021
    2122class MSimSignalCam : public MTask
    2223{
    2324private:
    24     MPhotonEvent      *fEvt;     //! Event containing the photons
    25     MPhotonStatistics *fStat;    //! Statistics about the event
    26     MSignalCam        *fSignal;  //! Output container
     25    MPhotonEvent      *fEvt;      //! Event containing the photons
     26    MPhotonStatistics *fStat;     //! Statistics about the event
     27    MSignalCam        *fSignal;   //! Output container
     28    MParameterD       *fTrigger;  //! Trigger position w.r.t. analog channels
    2729
    2830    MArrayD fCont;   //! Local buffer for contents
  • trunk/MagicSoft/Mars/msimcamera/MSimTrigger.cc

    r9265 r9274  
    231231    const Float_t  pulspos = fPulsePos->GetVal()/freq;
    232232
     233    // Valid range in units of bins
    233234    const Float_t min = fCamera->GetValidRangeMin()+pulspos;
    234     const Float_t max = fCamera->GetValidRangeMax()+pulspos-nsamp;
     235    const Float_t max = fCamera->GetValidRangeMax()-(nsamp-pulspos);
    235236
    236237    // Define gate time (minimum coincidence time)
     
    240241    TObjArray triggers;
    241242    triggers.SetOwner();
     243
     244    Int_t cnt  = 0;
     245    Int_t rmlo = 0;
     246    Int_t rmhi = 0;
    242247
    243248    for (int j=0; j<fCoincidenceMap.GetEntries(); j++)
     
    266271        MDigitalSignal *ttl = 0;
    267272        while ((ttl=static_cast<MDigitalSignal*>(Next())))
    268             if (ttl->GetStart()<min || ttl->GetStart()>max)
     273        {
     274            if (ttl->GetStart()<min)
     275            {
    269276                delete arr->Remove(ttl);
     277                rmlo++;
     278            }
     279            if (ttl->GetStart()>max)
     280            {
     281                delete arr->Remove(ttl);
     282                rmhi++;
     283            }
     284        }
    270285
    271286        // Remove the empty slots
    272287        arr->Compress();
     288
     289        cnt += arr->GetEntriesFast();
    273290
    274291        // If we have at least one trigger keep the earliest one.
     
    284301    // No trigger issued. Go on.
    285302    if (triggers.GetEntriesFast()==0)
     303    {
     304        *fLog << all << rmlo << "/" << rmhi << " trigger out of valid range. No trigger raised." << endl;
    286305        return kTRUE;
     306    }
    287307
    288308    // There are usually not enough entries that it is worth to search
     
    292312    triggers.Sort();
    293313
     314    // FIXME: Jitter! (Own class?)
     315    fTrigger->SetVal(static_cast<MDigitalSignal*>(triggers[0])->GetStart());
     316
    294317    // inf2?
    295318    *fLog << all;
    296     *fLog << triggers.GetEntriesFast() << " triggers in " << triggers.GetEntriesFast() << " patches.";
     319    *fLog << cnt << " triggers left in " << triggers.GetEntriesFast() << " patches (" << rmlo << "/" << rmhi << " trigger out of valid range), T=" << fTrigger->GetVal();
    297320    *fLog << endl;
    298 
    299     // FIXME: Jitter! (Own class?)
    300     fTrigger->SetVal(static_cast<MDigitalSignal*>(triggers[0])->GetStart());
    301 
    302321
    303322    return kTRUE;
Note: See TracChangeset for help on using the changeset viewer.