Changeset 9319 for trunk/MagicSoft


Ignore:
Timestamp:
02/11/09 17:51:43 (16 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r9318 r9319  
    154154     - added debug output
    155155
     156   * msimcamera/MSimCamera.[h,cc]:
     157     - outsourced the pedestal and gain numbers into ReInit
     158     - use an MPedestalCam for Electronic Noise and Gain
     159     - allow to switch ob whether the gain is applied to the
     160       electronic noise or not
     161     - SetPhotElfromShower
     162
     163   * msim/Makefile. msim/SimLinkDef.h:
     164     - added MSimMMCS
     165
     166   * msim/MSimMMCS.[h,cc]:
     167     - added
     168
     169   * msimcamera/Makefile:
     170     - added -I../mpedestal
    156171
    157172
  • trunk/MagicSoft/Mars/mjobs/MJSimulation.cc

    r9317 r9319  
    7878#include "MWriteRootFile.h"
    7979
     80#include "MSimMMCS.h"
    8081#include "MSimAbsorption.h"
    8182#include "MSimReflector.h"
  • trunk/MagicSoft/Mars/msim/Makefile

    r9243 r9319  
    2020#
    2121INCLUDES = -I. -I../mbase -I../mmc -I../mgeom -I../mgui -I../mcorsika \
    22            -I../mpointing -I../msimreflector -I../mhbase
     22           -I../mpointing -I../msimreflector -I../mhbase -I../mraw
    2323
    2424SRCFILES = MPhotonData.cc \
    2525           MPhotonEvent.cc \
    2626           MHPhotonEvent.cc \
     27           MSimMMCS.cc \
    2728           MSimAbsorption.cc \
    2829           MSimPointingPos.cc
  • trunk/MagicSoft/Mars/msim/SimLinkDef.h

    r9232 r9319  
    1515#pragma link C++ class MSimAbsorption+;
    1616
     17#pragma link C++ class MSimMMCS+;
     18
    1719#endif
  • trunk/MagicSoft/Mars/msimcamera/MSimCamera.cc

    r9290 r9319  
    5656#include "MPhotonData.h"
    5757
     58#include "MPedestalCam.h"
     59#include "MPedestalPix.h"
     60
    5861#include "MAnalogSignal.h"
    5962#include "MAnalogChannels.h"
    6063
     64#include "MMcEvt.hxx"            // To be replaced by a CheObs class
    6165#include "MRawRunHeader.h"
    6266
     
    7074//
    7175MSimCamera::MSimCamera(const char* name, const char *title)
    72 : fEvt(0), fStat(0), fRunHeader(0), fCamera(0), fSpline(0)//, fPulsePos(0)
     76    : fEvt(0), fStat(0), fRunHeader(0), fElectronicNoise(0), fGain(0),
     77    fCamera(0), fMcEvt(0), fSpline(0), fBaselineGain(kFALSE)
    7378{
    7479    fName  = name  ? name  : "MSimCamera";
     
    8388Int_t MSimCamera::PreProcess(MParList *pList)
    8489{
     90    fMcEvt = (MMcEvt*)pList->FindCreateObj("MMcEvt");
     91    if (!fMcEvt)
     92        return kFALSE;
     93
    8594    fCamera = (MAnalogChannels*)pList->FindCreateObj("MAnalogChannels");
    8695    if (!fCamera)
     
    115124    }
    116125 */
     126
     127    // Create it here to make sure that MGeomApply will set the correct size
     128    fElectronicNoise = (MPedestalCam*)pList->FindCreateObj("MPedestalCam", "ElectronicNoise");
     129    if (!fElectronicNoise)
     130        return kFALSE;
     131
     132    fGain = (MPedestalCam*)pList->FindCreateObj("MPedestalCam", "Gain");
     133    if (!fGain)
     134        return kFALSE;
     135
    117136    MPulseShape *pulse = (MPulseShape*)pList->FindObject("MPulseShape");
    118137    if (!pulse)
     
    122141    }
    123142
    124     *fLog << warn << "FIXME - SCALE WITH THE SAMPLING FREQUENCY." << endl;
     143    if (fRunHeader->GetFreqSampling()!=1000)
     144    {
     145        *fLog << err  << "ERROR - Sampling frequencies others than 1GHz are not yet supported." << endl;
     146        *fLog << warn << "FIXME - SCALE MPulsShape WITH THE SAMPLING FREQUENCY." << endl;
     147        return kFALSE;
     148    }
    125149
    126150    fSpline = pulse->GetSpline();
     
    131155    }
    132156
     157    // ---------------- Information output ----------------------
     158
     159    if (fBaselineGain)
     160        *fLog << inf << "Gain is also applied to the electronic noise." << endl;
     161
     162    return kTRUE;
     163}
     164
     165// --------------------------------------------------------------------------
     166//
     167// FIXME: For now this is a workaround to set a baseline and the
     168// electronic (guassian noise)
     169//
     170Bool_t MSimCamera::ReInit(MParList *plist)
     171{
     172    for (int i=0; i<fElectronicNoise->GetSize(); i++)
     173    {
     174        MPedestalPix &ped = (*fElectronicNoise)[i];
     175        ped.SetPedestal(15*256); // Baseline at 15 like in MAGIC
     176        ped.SetPedestalRms(1.5*256);//2.0); // 1.5 bit noise for a gain of 64
     177        ped.SetPedestalABoffset(0);
     178        ped.SetNumEvents(0);
     179
     180        // 256 scale from 8bit to 16bit
     181        // 8 signal height of one phe
     182        MPedestalPix &gain = (*fGain)[i];
     183        gain.SetPedestal(8*256);
     184        gain.SetPedestalRms(0);
     185        gain.SetPedestalABoffset(0);
     186        gain.SetNumEvents(0);
     187    }
    133188    return kTRUE;
    134189}
     
    144199    const Double_t freq = fRunHeader->GetFreqSampling()/1000.;
    145200
     201    // FIXME: Should we use a higher sampling here?
     202
    146203    const Double_t start = fStat->GetTimeFirst()*freq;
    147204    const Double_t end   = fStat->GetTimeLast() *freq;
    148205
    149206    const UInt_t   nlen  = TMath::CeilNint(end-start);
    150 
    151     // FIXME: Jitter the start point of digitization by one sample [0;1]
    152     // FIXME: TAKE PULSE WIDTH out of the calculation and start at TimeFirst
    153207
    154208    // Get number of pixels/channels
     
    165219    for (UInt_t i=0; i<npix; i++)
    166220    {
     221        const MPedestalPix &pix = (*fElectronicNoise)[i];
     222
     223        const Double_t val = pix.GetPedestal();
     224        const Double_t rms = pix.GetPedestalRms();
     225
     226        if (!fBaselineGain)
     227        {
     228            (*fCamera)[i].AddGaussianNoise(rms, val);
     229            continue;
     230        }
     231        // Sorry, the name "pedestal" is misleading here
     232        // FIXME: Simulate gain fluctuations
     233        const Double_t gain = (*fGain)[i].GetPedestal();
     234
    167235        // FIXME: We might add the base line here already.
    168         (*fCamera)[i].AddGaussianNoise(22.5/64);
     236        // FIXME: How stable is the offset?
     237        // FIXME: Should we write a container AppliedGain for MSImTrigger?
     238        (*fCamera)[i].AddGaussianNoise(rms*gain, val*gain);
    169239    }
    170240
     
    181251    //        Or maybe per channel and run?
    182252
     253    Double_t tot = 0;
     254
    183255    // Simulate pulses
    184256    for (Int_t i=0; i<num; i++)
     
    191263        // FIXME: Time jitter?
    192264        // FIXME: Add additional routing here?
     265        // FIMXE: How stable is the gain?
     266
     267        if (ph.GetPrimary()!=MMcEvt::kNightSky)
     268            tot += ph.GetWeight();
     269
     270        // Sorry, the name "pedestal" is misleading here
     271        // FIXME: Simulate gain fluctuations
     272        const Double_t gain = (*fGain)[idx].GetPedestal();
    193273
    194274        // === FIXME === FIXME === FIXME === Frequency!!!!
    195         (*fCamera)[idx].AddPulse(*fSpline, t, ph.GetWeight());
    196     }
     275        (*fCamera)[idx].AddPulse(*fSpline, t, ph.GetWeight()*gain);
     276    }
     277
     278    fMcEvt->SetPhotElfromShower(TMath::Nint(tot));
    197279
    198280    return kTRUE;
    199281}
    200 
    201 /*
    202 MSimCameraFiles::Process()
    203 {
    204     // fCorsikaHeader->GetEvtNumber()   -->   fMcEvt->SetEvtNumber()
    205     // fCorsikaHeader->GetTotalEnergy() -->   fMcEvt->SetEnergy()
    206     // fCorsikaHeader->GetParticleID()  -->   fMcEvt->SetParticleID()
    207     // fCorsikaHeader->GetImpact()      -->   fMcEvt->SetImpact()
    208     // fCorsikaHeader->GetTheta()       -->   fMcEvt->SetTheta()
    209     // fCorsikaHeader->GetPhi()         -->   fMcEvt->SetPhi()
    210     // fPointingPos->GetTheta()         -->   fMcEvt->SetTelescopeTheta()
    211     // fPointingPos->GetPhi()           -->   fMcEvt->SetTelescopePhi()
    212     // fStats->GetTimeFirst()           -->   fMcEvt->SetTimeFirst()
    213     // fStats->GetTimeLast()            -->   fMcEvt->SetTimeLast()
    214     //                                        fMcEvt->SetReuse()
    215     // MMcCorsikaRunHeader: fSlopeSpec, fELowLim, fEUppLim;
    216 
    217     fMcEvt->Fill(*fCorsikaHeader, *fPointingPos, *fStats);
    218 
    219     return kTRUE;
    220 }
    221 */
    222 
  • trunk/MagicSoft/Mars/msimcamera/MSimCamera.h

    r9274 r9319  
    66#endif
    77
     8class MMcEvt;
    89class MParList;
    910class MPhotonEvent;
     
    1112class MRawRunHeader;
    1213class MAnalogChannels;
     14class MPedestalCam;
    1315
    1416class MSpline3;
     
    1719{
    1820private:
    19     MPhotonEvent      *fEvt;        //! Event stroing the photons
    20     MPhotonStatistics *fStat;       //! Valid time range of the phootn event
    21     MRawRunHeader     *fRunHeader;  //! Sampling frequency
     21    MPhotonEvent      *fEvt;             //! Event stroing the photons
     22    MPhotonStatistics *fStat;            //! Valid time range of the phootn event
     23    MRawRunHeader     *fRunHeader;       //! Sampling frequency
     24    MPedestalCam      *fElectronicNoise; //! Electronic noise (baseline and rms)
     25    MPedestalCam      *fGain;            //! Electronic noise (baseline and rms)
    2226
    23     MAnalogChannels   *fCamera;     //! Output of the analog signals
     27    MAnalogChannels   *fCamera;          //! Output of the analog signals
     28    MMcEvt            *fMcEvt;           //! For information stored in MMcEvt
    2429
    25     MSpline3 *fSpline;
     30    MSpline3 *fSpline;     // Pusle Shape
     31
     32    Bool_t fBaselineGain;  // Should the gain be applied to baseline and electronic noise?
    2633
    2734    // MTask
    28     Int_t PreProcess(MParList *pList);
    29     Int_t Process();
     35    Int_t  PreProcess(MParList *pList);
     36    Bool_t ReInit(MParList *pList);
     37    Int_t  Process();
    3038
    3139public:
  • trunk/MagicSoft/Mars/msimcamera/Makefile

    r9308 r9319  
    2121INCLUDES = -I. -I../mbase -I../mgeom -I../msim -I../msignal -I../mcorsika \
    2222           -I../mmc -I../mgui -I../mcalib -I../mraw -I../mfileio -I../melectronics \
    23            -I../mtrigger
     23           -I../mtrigger -I../mpedestal
    2424
    2525SRCFILES = MSimPSF.cc \
Note: See TracChangeset for help on using the changeset viewer.