Changeset 4002 for trunk/MagicSoft


Ignore:
Timestamp:
05/07/04 12:46:57 (20 years ago)
Author:
jlopez
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mastro/MAstroCamera.h

    r3957 r4002  
    3131    ~MAstroCamera();
    3232
     33    void SetStarList(TList*)
     34      {
     35      }
     36   
     37    void FillStarList()
     38      {
     39      }
     40   
    3341    void SetMirrors(TClonesArray &arr);
    3442    void SetMirrors(const char *fname);
  • trunk/MagicSoft/Mars/mtemp/MFindStars.cc

    r3808 r4002  
    5858{
    5959  fName  = name  ? name  : "MFindStars";
    60   fTitle = title ? title : "Tool to find stars from Base Currents";
     60  fTitle = title ? title : "Tool to find stars from DC Currents";
    6161
    6262  fMaxNumIntegratedEvents = 10;
    63   fRingInterest = 100; //[mm] ~ 0.3 deg
    64 
     63  fRingInterest = 100.; //[mm] ~ 0.3 deg
     64  fMinDCForStars = 3.; //[uA]
     65 
    6566  fPixelsUsed.Set(577);
    6667  fPixelsUsed.Reset((Char_t)kTRUE);
     
    9495    }
    9596
    96    fDrive = (MReportDrive*)pList->FindObject(AddSerialNumber("MReportDrive"));
     97    fDrive = (MReportDrive*)pList->FindObject(AddSerialNumber("MReportDrive"));
    9798
    9899    if (!fDrive)
     
    101102      return kFALSE;
    102103    }
     104    else
     105      {
     106        //Initialitation MAstroCamera
     107        // Name of a MC file having MGeomCam and MMcConfigRunHeader
     108        TString fname = "../data/Gamma_zbin9_90_7_1480to1489_w0.root";
     109
     110        // Time for which to get the picture
     111        //    MTime time;
     112        //    time.Set(2004, 2, 28, 01, 32, 15);
     113       
     114        // Current observatory
     115        MObservatory magic1;
     116       
     117        // Right Ascension [h] and declination [deg] of source
     118        // Currently 'perfect' pointing is assumed
     119        //    const Double_t ra  = MAstro::Hms2Rad(5, 34, 31.9);
     120        //    const Double_t dec = MAstro::Dms2Rad(22, 0, 52.0);
     121
     122        // --------------------------------------------------------------------------
     123        // Create camera display from geometry
     124        MMcConfigRunHeader *config=0;
     125        MGeomCam           *geom=0;
     126       
     127        TFile file(fname);
     128        TTree *tree = (TTree*)file.Get("RunHeaders");
     129        tree->SetBranchAddress("MMcConfigRunHeader", &config);
     130        if (tree->GetBranch("MGeomCam"))
     131          tree->SetBranchAddress("MGeomCam", &geom);
     132        tree->GetEntry(0);
     133       
     134        fAstro.SetMirrors(*config->GetMirrors());
     135        fAstro.SetGeom(*geom);
     136       
     137       
     138        fAstro.SetLimMag(6);
     139        fAstro.SetRadiusFOV(3);
     140        fAstro.ReadBSC("../data/bsc5.dat");
     141       
     142        fAstro.SetObservatory(magic1);
     143        // Time for which to get the picture
     144        //    MTime time;
     145        //    time.Set(2004, 2, 28, 01, 32, 15);
     146        //   fAstro.SetTime(time);
     147        fAstro.SetTime(*fTimeCurr);
     148        fAstro.SetGuiActive();
     149       
     150        fAstro.SetStarList(fStars->GetList());
     151       
     152      }
     153   
    103154
    104155    fStars = (MStarLocalCam*)pList->FindCreateObj(AddSerialNumber("MStarLocalCam"));
     
    109160    }
    110161
    111 //Initialitation MAstroCamera
    112     // Name of a MC file having MGeomCam and MMcConfigRunHeader
    113     TString fname = "../data/Gamma_zbin9_90_7_1480to1489_w0.root";
    114 
    115     // Time for which to get the picture
    116 //    MTime time;
    117 //    time.Set(2004, 2, 28, 01, 32, 15);
    118 
    119     // Current observatory
    120     MObservatory magic1;
    121 
    122     // Right Ascension [h] and declination [deg] of source
    123     // Currently 'perfect' pointing is assumed
    124 //    const Double_t ra  = MAstro::Hms2Rad(5, 34, 31.9);
    125 //    const Double_t dec = MAstro::Dms2Rad(22, 0, 52.0);
    126 
    127       // --------------------------------------------------------------------------
    128     // Create camera display from geometry
    129     MMcConfigRunHeader *config=0;
    130     MGeomCam           *geom=0;
    131 
    132     TFile file(fname);
    133     TTree *tree = (TTree*)file.Get("RunHeaders");
    134     tree->SetBranchAddress("MMcConfigRunHeader", &config);
    135     if (tree->GetBranch("MGeomCam"))
    136         tree->SetBranchAddress("MGeomCam", &geom);
    137     tree->GetEntry(0);
    138 
    139     fAstro.SetMirrors(*config->GetMirrors());
    140     fAstro.SetGeom(*geom);
    141 
    142 
    143     fAstro.SetLimMag(6);
    144     fAstro.SetRadiusFOV(3);
    145     fAstro.ReadBSC("../data/bsc5.dat");
    146 
    147     fAstro.SetObservatory(magic1);
    148     // Time for which to get the picture
    149 //    MTime time;
    150 //    time.Set(2004, 2, 28, 01, 32, 15);
    151 //   fAstro.SetTime(time);
    152     fAstro.SetTime(*fTimeCurr);
    153     fAstro.SetGuiActive();
    154 
    155     fAstro.SetStarList(fStars->GetList());
    156 
    157162    return kTRUE;
    158163}
     
    160165Int_t MFindStars::Process()
    161166{
    162 
    163     Float_t ra  = fDrive->GetRa();
    164     Float_t dec = fDrive->GetDec();
    165 
    166     fAstro.SetRaDec(ra, dec);
    167     fAstro.SetGuiActive();
    168    
    169     fAstro.FillStarList();
    170 
    171167    if (fNumIntegratedEvents < fMaxNumIntegratedEvents)
    172168    {
     
    176172    else
    177173    {
    178         //loop to extract position of stars on the camera
    179         TIter Next(fStars->GetList());
    180         MStarLocalPos* star;
    181         while ((star=(MStarLocalPos*)Next()))
    182             FindStar(star);
    183 
    184         //After finding stars reset all vairables
    185         fDisplay.Reset();
    186         fNumIntegratedEvents=0;
     174      if (fDrive)
     175        {
     176          Float_t ra  = fDrive->GetRa();
     177          Float_t dec = fDrive->GetDec();
     178         
     179          fAstro.SetRaDec(ra, dec);
     180          fAstro.SetGuiActive();
     181         
     182          fAstro.FillStarList();
     183        }
     184      else
     185        {
     186          Float_t maxPixelDC;
     187          MGeomPix maxPixel;
     188          while(1)
     189            {
     190              FindPixelWithMaxDC(maxPixelDC, maxPixel);
     191              if (maxPixelDC<fMinDCForStars)
     192                break;
     193             
     194              MStarLocalPos *starpos = new MStarLocalPos;
     195              starpos->SetExpValues(maxPixelDC,maxPixel.GetX(),maxPixel.GetY());
     196              fStars->GetList()->Add(starpos);
     197            }
     198        }
     199     
     200      //loop to extract position of stars on the camera
     201      TIter Next(fStars->GetList());
     202      MStarLocalPos* star;
     203      while ((star=(MStarLocalPos*)Next()))
     204        {
     205          FindStar(star);
     206          ShadowStar(star);
     207        }
     208     
     209     
     210      //After finding stars reset all vairables
     211      fDisplay.Reset();
     212      fNumIntegratedEvents=0;
    187213    }
    188214
     
    206232}
    207233
    208 Bool_t MFindStars::FindStar(MStarLocalPos* star)
    209 {   
    210 
    211     Float_t expX = star->GetXExp();
    212     Float_t expY = star->GetYExp();
    213 
     234Bool_t MFindStars::FindPixelWithMaxDC(Float_t &maxDC, MGeomPix &maxPix)
     235{
    214236    UInt_t numPixels = fGeomCam->GetNumPixels();
    215237
    216 // First define a area of interest around the expected position of the star
     238// Find the two close pixels with the maximun dc
     239    UInt_t maxPixIdx[2];
     240
    217241    for (UInt_t pix=1; pix<numPixels; pix++)
    218242    {
    219 
    220         Float_t pixXpos=(*fGeomCam)[pix].GetX();
    221         Float_t pixYpos=(*fGeomCam)[pix].GetY();
    222         Float_t dist = sqrt((pixXpos-expX)*(pixXpos-expX)+
    223                             (pixYpos-expY)*(pixYpos-expY));
    224 
    225       if (dist < fRingInterest)
    226           fPixelsUsed[pix]=(Char_t)kTRUE;
    227     }
    228 
    229     fDisplay.SetUsed(fPixelsUsed);
    230 
    231 // Find the two close pixels with the maximun dc
    232     for (UInt_t pix=1; pix<numPixels; pix++)
    233     {
    234         Float_t maxDC = 0;
     243        maxDC = 0;
    235244
    236245        if(fDisplay.IsUsed(pix))
    237246        {
    238247            Float_t dc[2];
    239             Float_t maxPix[2];
    240248            dc[0] = fDisplay.GetBinContent(pix+1);
    241249           
    242             MGeomPix g = (*fGeomCam)[pix];
     250            MGeomPix &g = (*fGeomCam)[pix];
    243251            Int_t numNextNeighbors = g.GetNumNeighbors();
    244252           
     
    256264                    if(dcsum > maxDC*2)
    257265                    {
    258                         maxPix[0] = pix;
    259                         maxPix[1] = swneighbor;
    260                         maxDC = dcsum/2;
     266                      if(dc[0]>=dc[1])
     267                        {
     268                        maxPixIdx[0] = pix;
     269                        maxPixIdx[1] = swneighbor;
     270                        }
     271                      else
     272                        {
     273                          maxPixIdx[1] = pix;
     274                          maxPixIdx[0] = swneighbor;
     275                        }
     276                      maxDC = dcsum/2;
    261277                    }   
    262278                }
     
    264280        }
    265281    }
     282
     283    maxPix = (*fGeomCam)[maxPixIdx[0]];
     284    return kTRUE;
     285}
     286
     287Bool_t MFindStars::FindStar(MStarLocalPos* star)
     288{   
     289
     290  MHCamera cam = fDisplay;
     291 
     292    Float_t expX = star->GetXExp();
     293    Float_t expY = star->GetYExp();
     294
     295    UInt_t numPixels = fGeomCam->GetNumPixels();
     296
     297// First define a area of interest around the expected position of the star
     298    for (UInt_t pix=1; pix<numPixels; pix++)
     299    {
     300
     301        Float_t pixXpos=(*fGeomCam)[pix].GetX();
     302        Float_t pixYpos=(*fGeomCam)[pix].GetY();
     303        Float_t dist = sqrt((pixXpos-expX)*(pixXpos-expX)+
     304                            (pixYpos-expY)*(pixYpos-expY));
     305
     306      if (dist < fRingInterest && cam.IsUsed(pix))
     307          fPixelsUsed[pix]=(Char_t)kTRUE;
     308    }
     309
     310    cam.SetUsed(fPixelsUsed);
     311
    266312
    267313    // determine mean x and mean y of the selected px
     
    274320    for(UInt_t pix=0; pix<numPixels; pix++)
    275321    {
    276         if(fDisplay.IsUsed(pix))
     322        if(cam.IsUsed(pix))
    277323        {
    278324            usedPx++;
    279325
    280             Float_t charge=fDisplay.GetBinContent(pix+1);
     326            Float_t charge=cam.GetBinContent(pix+1);
    281327            Float_t pixXpos=(*fGeomCam)[pix].GetX();
    282328            Float_t pixYpos=(*fGeomCam)[pix].GetY();
     
    287333            meanSqY+=charge*pixYpos*pixYpos;
    288334            sumCharge+=charge;
    289 //          fDisplay.ResetUsed(i); // this px must not be used again!
     335//          cam.ResetUsed(i); // this px must not be used again!
    290336        } //for... use 
    291337    }
    292338
    293339    star->SetCalcValues(sumCharge,meanX,meanY,meanSqX,meanSqY);
    294     fStars->GetList()->Add(star);
    295340   
    296341    return kTRUE;
    297342}
    298343
    299 
    300 
    301 
     344Bool_t MFindStars::ShadowStar(MStarLocalPos* star)
     345{
     346    UInt_t numPixels = fGeomCam->GetNumPixels();
     347
     348// Define an area around the star which will be set unused.
     349    for (UInt_t pix=1; pix<numPixels; pix++)
     350    {
     351
     352        Float_t pixXpos  = (*fGeomCam)[pix].GetX();
     353        Float_t pixYpos  = (*fGeomCam)[pix].GetY();
     354        Float_t starXpos = star->GetMeanXCalc();
     355        Float_t starYpos = star->GetMeanYCalc();
     356       
     357        Float_t starSize = 2*star->GetSigmaMajorAxisCalc();
     358       
     359        Float_t dist = sqrt((pixXpos-starXpos)*(pixXpos-starXpos)+
     360                            (pixYpos-starYpos)*(pixYpos-starYpos));
     361
     362        if (dist > starSize && fDisplay.IsUsed(pix))
     363          fPixelsUsed[pix]=(Char_t)kTRUE;
     364    }
     365
     366    fDisplay.SetUsed(fPixelsUsed);
     367
     368    return kTRUE;
     369}
     370
     371
     372
  • trunk/MagicSoft/Mars/mtemp/MFindStars.h

    r3808 r4002  
    2323
    2424class MGeomCam;
     25class MGeomPix;
    2526class MCameraDC;
    2627class MTime;
     
    4849
    4950    Float_t fRingInterest; //[mm]
     51    Float_t fMinDCForStars;
    5052
    51 public:
     53    Bool_t FindPixelWithMaxDC(Float_t &maxDC, MGeomPix &maxPix);
     54    Bool_t FindStar(MStarLocalPos* star);
     55    Bool_t ShadowStar(MStarLocalPos* star);
     56
     57  public:
    5258    MFindStars(const char *name=NULL, const char *title=NULL);
    5359   
     
    6066    void SetBlindPixels(TArrayS blindpixels);
    6167
    62     Bool_t FindStar(MStarLocalPos* star);
    6368
    64   ClassDef(MFindStars, 0) // Tool to find stars from Base Currents
     69  ClassDef(MFindStars, 0) // Tool to find stars from DC Currents
    6570};
    6671
  • trunk/MagicSoft/Mars/mtemp/Makefile

    r3927 r4002  
    1111#------------------------------------------------------------------------------
    1212
    13 INCLUDES = -I.
    14 
    1513CINT     = Temp
    1614
    17 SRCFILES =
     15#------------------------------------------------------------------------------
     16
     17INCLUDES = -I. \
     18           -I../mbase \
     19           -I../mjobs \
     20           -I../mpedestal \
     21           -I../mbadpixels \
     22           -I../mfileio \
     23           -I../mraw \
     24           -I../manalysis \
     25           -I../mgui \
     26           -I../mgeom \
     27           -I../msignal \
     28           -I../mcalib \
     29           -I../mfilter \
     30           -I../mhbase \
     31           -I../mimage \
     32           -I../mpointing \
     33           -I../mcamera \
     34           -I../mhist \
     35           -I../mmc \
     36           -I../mreport \
     37           -I../mastro
     38
     39SRCFILES = \
     40        MStarLocalPos.cc \
     41        MStarLocalCam.cc \
     42        MFindStars.cc
    1843
    1944############################################################
     
    2348include ../Makefile.rules
    2449
     50clean:  rmcint rmobjs rmcore rmlib
    2551mrproper:       clean rmbak
  • trunk/MagicSoft/Mars/mtemp/TempLinkDef.h

    r3927 r4002  
    55#pragma link off all functions;
    66
     7#pragma link C++ class MStarLocalPos+;
     8#pragma link C++ class MStarLocalCam+;
     9#pragma link C++ class MFindStars+;
     10
     11#endif
Note: See TracChangeset for help on using the changeset viewer.