Changeset 9239


Ignore:
Timestamp:
01/22/09 19:07:37 (16 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
9 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r9238 r9239  
    3636   * msimreflector/MSimReflector.cc:
    3737     - force sorting of the array
     38
     39  * msimcamera/MSimPSF.[h,cc], msimcamera/MSimGeomCam.[h,cc],
     40    msimcamera/MSimExcessNoise.[h,cc], msimcamera/MSimSignalCam.[h,cc]:
     41    - added
    3842
    3943
  • trunk/MagicSoft/Mars/NEWS

    r9229 r9239  
    1111     So it is recommended although not necessary to reset your sequences
    1212     in the database before further processing.
     13
     14 ;NEW
     15
     16   * A first implementation of a Monte Carlo simulation program
     17     (ceres - Camera Electronics and REflector  Simulation) has been
     18     implemented. It can simulate a full telescope already including
     19     a complete reflector simulation and a flexible trigger and readout
     20     simulation. Currently, no perfect setup is implemented and
     21     especially the output of the program (data structure) should
     22     be considered alpha state. Also the user interface is not yet
     23     ready.
    1324
    1425 ;general
  • trunk/MagicSoft/Mars/mraw/MRawRunHeader.h

    r9219 r9239  
    159159    Bool_t IsValid() const { return fMagicNumber==0xc0c0 || fMagicNumber==0xc0c1; }
    160160    Bool_t IsMonteCarloRun() const { return fRunType>0x00ff; }
     161    Bool_t IsDataRun() const        { return (fRunType&0xff)==kRTData; }
     162    Bool_t IsPedestalRun() const    { return (fRunType&0xff)==kRTPedestal; }
     163    Bool_t IsCalibrationRun() const { return (fRunType&0xff)==kRTCalibration; }
    161164
    162165    void Print(Option_t *t=NULL) const;
  • trunk/MagicSoft/Mars/msim/MPhotonData.cc

    r9232 r9239  
    216216        gLog << "Weight:           " << fWeight << endl;
    217217}
    218 
    219 /*
    220 #include <TH2.h>
    221 #include <TH3.h>
    222 
    223 // --------------------------------------------------------------------------
    224 //
    225 // Fill radial photon distance scaled by scale into 1D histogram.
    226 //
    227 void MPhotonData::FillRad(TH1 &hist, Float_t scale) const
    228 {
    229     hist.Fill(TMath::Hypot(fPosX, fPosY)*scale);
    230 }
    231 
    232 // --------------------------------------------------------------------------
    233 //
    234 // Fill radial photon distance scaled by scale versus x into 2D histogram.
    235 //
    236 void MPhotonData::FillRad(TH2 &hist, Double_t x, Float_t scale) const
    237 {
    238     hist.Fill(x, TMath::Hypot(fPosX, fPosY)*scale);
    239 }
    240 
    241 // --------------------------------------------------------------------------
    242 //
    243 // Fill photon position (x,y) scaled by scale into 2D histogram.
    244 // (Note north in the camera plane is -y, and east -x)
    245 //
    246 void MPhotonData::Fill(TH2 &hist, Float_t scale) const
    247 {
    248     hist.Fill(fPosY*scale, fPosX*scale);
    249 }
    250 
    251 // --------------------------------------------------------------------------
    252 //
    253 // Fill photon position (x,y) scaled by scale versus z into 3D histogram.
    254 // (Note north in the camera plane is -y, and east -x)
    255 //
    256 void MPhotonData::Fill(TH3 &hist, Double_t z, Float_t scale) const
    257 {
    258     hist.Fill(fPosY*scale, fPosX*scale);
    259 }
    260 
    261 */
  • trunk/MagicSoft/Mars/msim/MPhotonEvent.cc

    r9232 r9239  
    5757// Here is an example (how to remove every second entry)
    5858//
     59//  ---------------------------------------------------------------------
     60//
    5961//    Int_t cnt = 0;
    6062//
     
    9193//     MPhotonEvent->Shrink(cnt);
    9294//
     95//  ---------------------------------------------------------------------
     96//
     97// The flag for a sorted array is for speed reasons not in all conditions
     98// maintained automatically. Especially Add() doesn't reset it.
     99//
     100// So be sure that if you want to sort your array it is really sorted.
     101//
    93102//
    94103//   Version 1:
     
    127136}
    128137
     138/*
    129139const char *MPhotonEvent::GetClassName() const
    130140{
    131141    return static_cast<TObject*>(fData.GetClass())->GetName();
    132142}
     143*/
    133144
    134145// --------------------------------------------------------------------------
     
    184195}
    185196
     197// --------------------------------------------------------------------------
     198//
     199// Return a pointer to the first photon if available.
     200//
     201MPhotonData *MPhotonEvent::GetFirst() const
     202{
     203    return static_cast<MPhotonData*>(fData.First());
     204}
     205
     206// --------------------------------------------------------------------------
     207//
     208// Return a pointer to the last photon if available.
     209//
     210MPhotonData *MPhotonEvent::GetLast() const
     211{
     212    return static_cast<MPhotonData*>(fData.Last());
     213}
     214
     215// --------------------------------------------------------------------------
     216//
     217// Read the Event section from the file
     218//
    186219Int_t MPhotonEvent::ReadCorsikaEvt(istream &fin)
    187220{
     
    234267
    235268    Shrink(n);
     269    fData.UnSort();
    236270
    237271    SetReadyToSave();
     
    241275}
    242276
     277// --------------------------------------------------------------------------
     278//
    243279Int_t MPhotonEvent::ReadRflEvt(std::istream &fin)
    244280{
     
    291327}
    292328
     329// --------------------------------------------------------------------------
     330//
     331// Print the array
     332//
    293333void MPhotonEvent::Print(Option_t *) const
    294334{
    295335    fData.Print();
    296336}
    297 
    298 /*
    299 // --------------------------------------------------------------------------
    300 //
    301 // Fills all photon distances scaled with scale (default=1) into a TH1
    302 //
    303 void MPhotonEvent::FillRad(TH1 &hist, Float_t scale) const
    304 {
    305     MPhotonData *ph=NULL;
    306 
    307     TIter Next(&fData);
    308     while ((ph=(MPhotonData*)Next()))
    309         ph->FillRad(hist, scale);
    310 }
    311 
    312 // --------------------------------------------------------------------------
    313 //
    314 // Fills all photon distances scaled with scale (default=1) versus x
    315 // into a TH2
    316 //
    317 void MPhotonEvent::FillRad(TH2 &hist, Double_t x, Float_t scale) const
    318 {
    319     MPhotonData *ph=NULL;
    320 
    321     TIter Next(&fData);
    322     while ((ph=(MPhotonData*)Next()))
    323         ph->FillRad(hist, x, scale);
    324 }
    325 
    326 // --------------------------------------------------------------------------
    327 //
    328 // Fills all photons (x,y) scaled with scale (default=1) into a TH2.
    329 //
    330 void MPhotonEvent::Fill(TH2 &hist, Float_t scale) const
    331 {
    332     MPhotonData *ph=NULL;
    333 
    334     TIter Next(&fData);
    335     while ((ph=(MPhotonData*)Next()))
    336         ph->Fill(hist, scale);
    337 }
    338 
    339 // --------------------------------------------------------------------------
    340 //
    341 // Fills all photons (x,y) scaled with scale (default=1) versus z into a TH3
    342 //
    343 void MPhotonEvent::Fill(TH3 &hist, Double_t z, Float_t scale) const
    344 {
    345     MPhotonData *ph=NULL;
    346 
    347     TIter Next(&fData);
    348     while ((ph=(MPhotonData*)Next()))
    349         ph->Fill(hist, z, scale);
    350 }
    351 
    352 void MPhotonEvent::DrawPixelContent(Int_t num) const
    353 {
    354 }
    355 
    356 #include "MHexagon.h"
    357 #include "MGeomCam.h"
    358 #include <TMarker.h>
    359 
    360 // ------------------------------------------------------------------------
    361 //
    362 // Fill a reflector event. Sums all pixels in each pixel as the
    363 // pixel contents.
    364 //
    365 // WARNING: Due to the estimation in DistanceToPrimitive and the
    366 //          calculation in pixels instead of x, y this is only a
    367 //          rough estimate.
    368 //
    369 Bool_t MPhotonEvent::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
    370 {
    371     //
    372     // sum the photons content in each pixel
    373     //
    374     val = 0;
    375 
    376     MHexagon hex(cam[idx]);
    377 
    378     MPhotonData *ph=NULL;
    379 
    380     TIter Next(&fData);
    381 
    382     switch (type)
    383     {
    384 
    385     case 1: // time
    386         while ((ph=(MPhotonData*)Next()))
    387             if (hex.DistanceToPrimitive(ph->GetPosY(), ph->GetPosX())<=0)
    388                 val += ph->GetTime();
    389         return val/fData.GetEntriesFast()>0;
    390 
    391     default: // signal
    392         while ((ph=(MPhotonData*)Next()))
    393             if (hex.DistanceToPrimitive(ph->GetPosY()*10, ph->GetPosX()*10)<=0)
    394                 val += cam.GetPixRatio(idx);
    395         return val>0;
    396     }
    397 
    398     return kFALSE;
    399 
    400 }
    401 */
    402337
    403338// ------------------------------------------------------------------------
  • trunk/MagicSoft/Mars/msim/MPhotonEvent.h

    r9232 r9239  
    55#include "MParContainer.h"
    66#endif
    7 /*
    8 #ifndef MARS_MCamEvent
    9 #include "MCamEvent.h"
    10 #endif
    11 */
     7
    128#ifndef ROOT_TClonesArray
    139#include <TClonesArray.h>
    1410#endif
    1511
    16 // gcc 3.2
    17 //class ifstream;
    1812#include <iosfwd>
    19 
    20 /*
    21 class TH1;
    22 class TH2;
    23 class TH3;
    24 */
    2513
    2614class MPhotonData;
     
    7159        Changed();
    7260    }
     61
     62    void SetSorted() { fSorted = kTRUE; }
    7363};
    7464
    75 class MPhotonEvent : public MParContainer//, public MCamEvent
     65class MPhotonEvent : public MParContainer
    7666{
    7767private:
     
    8171    MPhotonEvent(const char *name=NULL, const char *title=NULL);
    8272
    83     //void Clear(Option_t * = NULL);
    84     void Print(Option_t * = NULL) const;
     73    // TObjArray, FIXME: This could be improved if checking for IsSortable is omitted
     74    void Sort(Bool_t force=kFALSE) { if (force) fData.UnSort(); fData.Sort(); }
     75    Bool_t IsSorted() const { return fData.IsSorted(); }
    8576
    86     const char *GetClassName() const;
     77
     78    // Getter/Setter
     79    Int_t GetNumPhotons() const { return fData.GetEntriesFast(); }
    8780
    8881    TClonesArray &GetArray() { return fData; }
    8982    const TClonesArray &GetArray() const { return fData; }
    90     void Remove(TObject *o) { fData.Remove(o); }
    9183
    9284    MPhotonData &Add(Int_t n);
    9385    MPhotonData &Add();
     86
     87    MPhotonData *GetFirst() const;
     88    MPhotonData *GetLast() const;
    9489
    9590    MPhotonData &operator[](UInt_t idx);
     
    106101        //        for (int i=fData.GetSize()-1; i>=n; i--)
    107102        //          fData.RemoveAt(i);
    108         static_cast<MyClonesArray&>(fData).FastRemove(n, fData.GetSize()-1);
     103        const Bool_t sorted = fData.IsSorted();
     104
     105        MyClonesArray &loc = static_cast<MyClonesArray&>(fData);
     106
     107        loc.FastRemove(n, fData.GetSize()-1);
     108
     109        // If it was sorted before it is also sorted now.
     110        if (sorted)
     111            loc.SetSorted();
    109112
    110113        return fData.GetEntriesFast();
    111114    }
    112 /*
    113     void Expand(Int_t n)
    114     {
    115         for (int i=fData.GetSize(); i<n; i++)
    116             fData.New(i);
    117     }
    118  */
     115
     116    // I/O
    119117    Int_t ReadCorsikaEvt(istream &fin);
    120118    Int_t ReadRflEvt(istream &fin);
    121119
    122     Int_t GetNumPhotons() const { return fData.GetEntriesFast(); }
    123 /*
    124     void FillRad(TH1 &hist, Float_t scale=1) const;
    125     void FillRad(TH2 &hist, Double_t x, Float_t scale=1) const;
    126     void Fill(TH2 &hist, Float_t scale=1) const;
    127     void Fill(TH3 &hist, Double_t z, Float_t scale=1) const;
    128  */
     120    // TObject
    129121    void Paint(Option_t *o="");
    130 
    131 //    Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const;
    132 //    void   DrawPixelContent(Int_t num) const;
    133 
    134     void Sort() { fData.Sort(); }
     122    void Print(Option_t * = NULL) const;
     123    //void Clear(Option_t * = NULL);
    135124
    136125    ClassDef(MPhotonEvent, 1) //Container to store the raw Event Data
  • trunk/MagicSoft/Mars/msimreflector/MSimReflector.cc

    r9236 r9239  
    373373        // This is to avoid time consuming calculation if there is no
    374374        // chance of a coincidence.
     375        // FIXME: Inmprove search algorithm (2D Binary search?)
    375376        if (!mirror.CanHit(p))
    376377            continue;
     
    539540    // Doesn't seem to be too time consuming. But we could also sort later!
    540541    //  (after cones, inside the camera)
    541     fEvt->Sort();
    542 
    543     // FIXME FIXME FIXME: Set maxindex, first and last time.
     542    fEvt->Sort(kTRUE);
    544543
    545544    return kTRUE;
Note: See TracChangeset for help on using the changeset viewer.