Ignore:
Timestamp:
02/16/04 11:18:25 (21 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mimage
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mimage/MHillas.cc

    r2624 r3183  
    188188Int_t MHillas::Calc(const MGeomCam &geom, const MCerPhotEvt &evt)
    189189{
    190     const UInt_t npixevt = evt.GetNumPixels();
    191 
    192     //
    193     // sanity check
    194     //
    195     if (npixevt < 3)
     190    //
     191    // sanity check 1
     192    //
     193    if (evt.GetNumPixels()<3)
    196194        return 1;
    197195
     
    209207    fSize  = 0;
    210208
    211     Int_t numused = 0;
    212 
    213     for (UInt_t i=0; i<npixevt; i++)
     209    MCerPhotPix *pix = 0;
     210
     211    TIter Next(evt);
     212    UInt_t numused = 0;
     213    while ((pix=(MCerPhotPix*)Next()))
    214214    {
    215         const MCerPhotPix &pix = evt[i];
    216 
    217         if (!pix.IsPixelUsed())
    218             continue;
    219 
    220         const MGeomPix &gpix = geom[pix.GetPixId()];
    221 
    222         const Float_t nphot = pix.GetNumPhotons();
     215        const MGeomPix &gpix = geom[pix->GetPixId()];
     216
     217        const Float_t nphot = pix->GetNumPhotons();
    223218
    224219        fSize  += nphot;                             // [counter]
     
    230225
    231226    //
    232     // sanity checks
     227    // sanity check 2
    233228    //
    234229    if (fSize==0)
     
    238233    fMeanY /= fSize;                                 // [mm]
    239234
     235    //
     236    // sanity check 3
     237    //
    240238    if (numused<3)
    241239        return 3;
     
    254252    Double_t corryy=0;                               // [m^2]
    255253
    256     for (UInt_t i=0; i<npixevt; i++)
     254    Next.Reset();
     255    while ((pix=(MCerPhotPix*)Next()))
    257256    {
    258         const MCerPhotPix &pix = evt[i];
    259 
    260         if (!pix.IsPixelUsed())
    261             continue;
    262 
    263         const MGeomPix &gpix = geom[pix.GetPixId()];
     257        const MGeomPix &gpix = geom[pix->GetPixId()];
    264258
    265259        const Float_t dx = gpix.GetX() - fMeanX;     // [mm]
    266260        const Float_t dy = gpix.GetY() - fMeanY;     // [mm]
    267261
    268         const Float_t nphot = pix.GetNumPhotons();   // [#phot]
     262        const Float_t nphot = pix->GetNumPhotons();  // [#phot]
    269263
    270264        corrxx += nphot * dx*dx;                     // [mm^2]
     
    297291    const Double_t d0    = corryy - corrxx;
    298292    const Double_t d1    = corrxy*2;
    299     const Double_t d2    = d0 + sqrt(d0*d0 + d1*d1);
     293    const Double_t d2    = d0 + TMath::Sqrt(d0*d0 + d1*d1);
    300294    const Double_t tand  = d2 / d1;
    301295    const Double_t tand2 = tand*tand;
    302296
    303     fDelta = atan(tand);
     297    fDelta = TMath::ATan(tand);
    304298
    305299    const Double_t s2 = tand2+1;
    306     const Double_t s  = sqrt(s2);
     300    const Double_t s  = TMath::Sqrt(s2);
    307301
    308302    fCosDelta =  1.0/s;   // need these in derived classes
    309303    fSinDelta = tand/s;   // like MHillasExt
    310304
    311     Double_t axis1 = (tand2*corryy + d2 + corrxx)/s2/fSize;
    312     Double_t axis2 = (tand2*corrxx - d2 + corryy)/s2/fSize;
     305    const Double_t axis1 = (tand2*corryy + d2 + corrxx)/s2/fSize;
     306    const Double_t axis2 = (tand2*corrxx - d2 + corryy)/s2/fSize;
    313307
    314308    //
     
    320314    // very small numbers can get negative by rounding
    321315    //
    322     fLength = axis1<0 ? 0 : sqrt(axis1);  // [mm]
    323     fWidth  = axis2<0 ? 0 : sqrt(axis2);  // [mm]
     316    fLength = axis1<0 ? 0 : TMath::Sqrt(axis1);  // [mm]
     317    fWidth  = axis2<0 ? 0 : TMath::Sqrt(axis2);  // [mm]
    324318
    325319    SetReadyToSave();
  • trunk/MagicSoft/Mars/mimage/MImgCleanStd.cc

    r2781 r3183  
    329329void MImgCleanStd::CleanStep1()
    330330{
    331     const Int_t entries = fEvt->GetNumPixels();
    332331    const TArrayD &data = fData->GetData();
    333332
     
    335334    // check the number of all pixels against the noise level and
    336335    // set them to 'unused' state if necessary
    337     // 
    338     for (Int_t i=0; i<entries; i++ )
    339     {
    340         MCerPhotPix &pix = (*fEvt)[i];
    341 
    342         if (data[pix.GetPixId()] <= fCleanLvl1)
    343             pix.SetPixelUnused();
    344     }
     336    //
     337    MCerPhotPix *pix;
     338
     339    // Loop over all pixels
     340    MCerPhotEvtIter Next(fEvt, kFALSE);
     341    while ((pix=static_cast<MCerPhotPix*>(Next())))
     342        if (data[pix->GetPixId()] <= fCleanLvl1)
     343            pix->SetPixelUnused();
    345344}
    346345
     
    351350//  neighbors).
    352351//
    353 //  Takes the maximum pixel id from CleanStep1 as an argument
    354 //
    355352void MImgCleanStd::CleanStep2()
    356353{
    357     const Int_t entries = fEvt->GetNumPixels();
    358 
    359     //
    360     // In the worst case we have to loop 6 times 577 times, to
    361     // catch the behaviour of all next neighbors. Here we can gain
    362     // much by using an array instead of checking through all pixels
    363     // (MCerPhotEvt::IsPixelUsed) all the time.
    364     //
    365     // We allocate the array ourself because the TArrays always do
    366     // range check which slows down the access to the array
    367     // by 25-50%
    368     //
    369     Byte_t *ispixused = new Byte_t[fCam->GetNumPixels()];
    370     memset(ispixused, 0, sizeof(Byte_t)*fCam->GetNumPixels());
    371 
    372     for (Int_t i=0; i<entries; i++)
    373     {
    374         const MCerPhotPix &pix = (*fEvt)[i];
    375         ispixused[pix.GetPixId()] = pix.IsPixelUsed() ? 1 : 0 ;
    376    }
    377 
    378     for (Int_t i=0; i<entries; i++)
    379     {
    380         // get entry i from list
    381         MCerPhotPix &pix = (*fEvt)[i];
    382 
    383         // get pixel id of this entry
    384         const Int_t idx = pix.GetPixId();
    385 
    386         // check if pixel is in use, if not goto next pixel in list
    387         if (ispixused[idx] == 0)
    388             continue;
     354    MCerPhotPix *pix;
     355
     356    // Loop over used pixels only
     357    TIter Next(*fEvt);
     358    while ((pix=static_cast<MCerPhotPix*>(Next())))
     359    {
     360        // get pixel id of this entry
     361        const Int_t idx = pix->GetPixId();
    389362 
    390363        // check for 'used' neighbors of this pixel
     
    400373
    401374            // when you find an used neighbor, break the loop
    402             if (ispixused[idx2] == 1)
     375            if (fEvt->IsPixelUsed(idx2))
    403376            {
    404377                hasNeighbor = kTRUE;
     
    408381
    409382        if (hasNeighbor == kFALSE)
    410             pix.SetPixelUnused();
    411     }
    412 
    413     delete ispixused;
     383            pix->SetPixelUnused();
     384    }
    414385
    415386    //
    416387    // now we declare all pixels that survive as CorePixels
    417388    //
    418     for (Int_t i=0; i<entries; i++)
    419     {
    420         MCerPhotPix &pix = (*fEvt)[i];
    421 
    422         if (pix.IsPixelUsed())
    423             pix.SetPixelCore();
    424     }
     389    Next.Reset();
     390    while ((pix=static_cast<MCerPhotPix*>(Next())))
     391        pix->SetPixelCore();
    425392}
    426393
     
    440407        const Int_t idx2 = gpix.GetNeighbor(j);
    441408
    442         if (!fEvt->GetPixById(idx2) || !fEvt->IsPixelCore(idx2))
     409        if (!fEvt->IsPixelCore(idx2))
    443410            continue;
    444411
     
    459426void MImgCleanStd::CleanStep4(UShort_t r, MCerPhotPix &pix)
    460427{
    461   // Skip events that have already a defined status;
    462         if( pix.GetRing()!= 0)
    463           return;
     428    //
     429    // Skip events that have already a defined status;
     430    //
     431    if (pix.GetRing() != 0)
     432        return;
     433
    464434    //
    465435    // check if the pixel's next neighbor is a used pixel.
     
    478448
    479449        MCerPhotPix *npix = fEvt->GetPixById(idx2);
    480 
    481450        if (!npix || !npix->IsPixelUsed() || npix->GetRing()>r-1 )
    482         continue;
     451            continue;
    483452
    484453        pix.SetRing(r);
     
    495464void MImgCleanStd::CleanStep3()
    496465{
    497     const Int_t entries = fEvt->GetNumPixels();
    498466    const TArrayD &data = fData->GetData();
    499467
    500468    for (UShort_t r=1; r<fCleanRings+1; r++)
    501469    {
    502         for (Int_t i=0; i<entries; i++)
     470        MCerPhotPix *pix;
     471
     472        // Loop over all pixels
     473        MCerPhotEvtIter NextAll(fEvt, kFALSE);
     474        while ((pix=static_cast<MCerPhotPix*>(NextAll())))
    503475        {
    504             //
    505             // get pixel as entry il from list
    506             //
    507             MCerPhotPix &pix = (*fEvt)[i];
    508 
    509476            //
    510477            // if pixel is a core pixel go to the next pixel
    511478            //
    512             if (pix.IsPixelCore())
     479            if (pix->IsPixelCore())
    513480                continue;
    514481
    515             if (data[pix.GetPixId()] <= fCleanLvl2)
     482            if (data[pix->GetPixId()] <= fCleanLvl2)
    516483                continue;
    517484
    518485            if (r==1)
    519                 CleanStep3b(pix);
     486                CleanStep3b(*pix);
    520487            else
    521                 CleanStep4(r, pix);
     488                CleanStep4(r, *pix);
    522489        }
    523490    }
  • trunk/MagicSoft/Mars/mimage/MNewImagePar.cc

    r2849 r3183  
    1818!   Author(s): Wolfgang Wittek 03/2003 <mailto:wittek@mppmu.mpg.de>
    1919!
    20 !   Copyright: MAGIC Software Development, 2000-2003
     20!   Copyright: MAGIC Software Development, 2000-2004
    2121!
    2222!
     
    3131// fLeakage1 ratio: (photons in most outer ring of pixels) over fSize
    3232// fLeakage2 ratio: (photons in the 2 outer rings of pixels) over fSize
     33// fNumSaturatedPixels: number of pixels in which at least one slice
     34//                      of the low gain FADC was saturated.
    3335//
    3436// Version 2:
    35 // Added fNumSaturatedPixels: number of pixels in which at least one slice
    36 // of the low gain FADC was saturated.
     37// ----------
     38//  - added fNumSaturatedPixels
    3739//
    3840/////////////////////////////////////////////////////////////////////////////
     
    106108        const MCerPhotPix &pix = evt[i];
    107109
     110        // count saturated pixels
    108111        if (pix.IsPixelSaturated())
    109           fNumSaturatedPixels++;
     112            fNumSaturatedPixels++;
    110113
     114        // skip unused pixels
    111115        if (!pix.IsPixelUsed())
    112116            continue;
     117
     118        // count used and core pixels
     119        if (pix.IsPixelCore())
     120            fNumCorePixels++;
     121
     122        // count used pixels
     123        fNumUsedPixels++;
    113124
    114125        const Int_t pixid = pix.GetPixId();
     
    125136        if (gpix.IsInOuterRing())
    126137           edgepix2 += nphot;
    127 
    128         //
    129         // count used and core pixels
    130         //
    131         if (pix.IsPixelCore())
    132             fNumCorePixels++;
    133 
    134         fNumUsedPixels++;
    135138
    136139        //
     
    172175    *fLog << " - Used Pixels    [#]   = " << fNumUsedPixels << " Pixels" << endl;
    173176    *fLog << " - Core Pixels    [#]   = " << fNumCorePixels << " Pixels" << endl;
     177    *fLog << " - Sat. Pixels    [#]   = " << fNumSaturatedPixels << " Pixels" << endl;
    174178}
  • trunk/MagicSoft/Mars/mimage/MNewImagePar.h

    r2849 r3183  
    1313{
    1414private:
    15     Float_t fLeakage1;      // (photons in most outer ring of pixels) over fSize
    16     Float_t fLeakage2;      // (photons in the 2 outer rings of pixels) over fSize
     15    Float_t fLeakage1;           // (photons in most outer ring of pixels) over fSize
     16    Float_t fLeakage2;           // (photons in the 2 outer rings of pixels) over fSize
    1717
    18     Float_t fConc;          // [ratio] concentration ratio: sum of the two highest pixels / fSize
    19     Float_t fConc1;         // [ratio] concentration ratio: sum of the highest pixel / fSize
     18    Float_t fConc;               // [ratio] concentration ratio: sum of the two highest pixels / fSize
     19    Float_t fConc1;              // [ratio] concentration ratio: sum of the highest pixel / fSize
    2020
    21     Short_t fNumUsedPixels; // Number of pixels which survived the image cleaning
    22     Short_t fNumCorePixels; // number of core pixels
    23 
    24     Short_t fNumSaturatedPixels; // number of saturated pixels
     21    Short_t fNumUsedPixels;      // Number of pixels which survived the image cleaning
     22    Short_t fNumCorePixels;      // number of core pixels
     23    Short_t fNumSaturatedPixels; // number of pixels with saturating lo-gains
    2524
    2625public:
     
    2928    void Reset();
    3029
    31     Float_t GetLeakage1() const    { return fLeakage1; }
    32     Float_t GetLeakage2() const    { return fLeakage2; }
     30    Float_t GetLeakage1() const { return fLeakage1; }
     31    Float_t GetLeakage2() const { return fLeakage2; }
    3332
    34     Float_t GetConc() const        { return fConc; }
    35     Float_t GetConc1() const       { return fConc1; }
     33    Float_t GetConc() const  { return fConc; }
     34    Float_t GetConc1() const { return fConc1; }
    3635
    37     Int_t GetNumUsedPixels() const { return fNumUsedPixels; }
    38     Int_t GetNumCorePixels() const { return fNumCorePixels; }
     36    Short_t GetNumUsedPixels() const { return fNumUsedPixels; }
     37    Short_t GetNumCorePixels() const { return fNumCorePixels; }
    3938
    4039    Short_t GetNumSaturatedPixels() const { return fNumSaturatedPixels; }
     
    4948
    5049#endif
    51 
    52 
    53 
    54 
    55 
    56 
    57 
    58 
    59 
    60 
    61 
    62 
    63 
    64 
    65 
    66 
    67 
    68 
    69 
    70 
    71 
    72 
    73 
    74 
    75 
    76 
    77 
Note: See TracChangeset for help on using the changeset viewer.