Ignore:
Timestamp:
05/17/04 11:36:24 (20 years ago)
Author:
rico
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mtemp/mifae/library
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mtemp/mifae/library/MSrcPlace.cc

    r4084 r4087  
    3030// It keeps a 2D histogram with the assigned positions, so that the same
    3131// distribution can be applied later to any data set (tipically the OFF data)
     32// Classes inheritating MSrcPlace should override the ComputeNewSrcPosition()
     33// method and probably include a call to MsrcPlace::PreProcess in their
     34// PreProcess method (see, e.g., MSrcPosFromFile or MSrcRotate classes)
    3235//
    3336//  Input Containers:
     
    9295  if(fHistPos)
    9396    delete fHistPos;
    94 }
    95 // -------------------------------------------------------------------------
    96 //
    97 // Look for/create the needed containers
    98 // Check whether RA and DEC have been initialized
    99 //
    100 Int_t MSrcPlace::SearchForSrcPos(MParList *pList)
    101 {
    102     // look for/create MSrcPosCam
    103   fSrcPos = (MSrcPosCam*)pList->FindObject(AddSerialNumber(fSrcPosName), "MSrcPosCam");
    104   if (!fSrcPos)
    105     {
    106       *fLog << warn << AddSerialNumber(fSrcPosName) << " [MSrcPosCam] not found... creating default container." << endl;
    107       fSrcPos = (MSrcPosCam*)pList->FindCreateObj("MSrcPosCam", AddSerialNumber(fSrcPosName));
    108       if(!fSrcPos)
    109         return kFALSE;
    110     }
    111 
    112   // look for/create MDCA
    113   fDCA = (MDCA*)pList->FindObject(AddSerialNumber(fDCAName), "MDCA");
    114   if (!fDCA)
    115     {
    116       *fLog << warn << AddSerialNumber(fDCAName) << " [MDCA] not found... creating default container." << endl;
    117       fDCA = (MDCA*)pList->FindCreateObj("MDCA", AddSerialNumber(fDCAName));
    118       if(!fDCA)
    119         return kFALSE;
    120     }
    121 
    122   return kTRUE;
    12397}
    12498
     
    146120// -------------------------------------------------------------------------
    147121//
    148 // Look for needed containers
    149 //
    150 Int_t MSrcPlace::PreProcess(MParList* plist)
     122// Look for needed containers.
     123// Check processing mode and if histogram is filled in case kOff mode
     124//
     125Int_t MSrcPlace::PreProcess(MParList* pList)
    151126{
    152   return SearchForSrcPos(plist);
     127    // look for/create MSrcPosCam
     128  fSrcPos = (MSrcPosCam*)pList->FindObject(AddSerialNumber(fSrcPosName), "MSrcPosCam");
     129  if (!fSrcPos)
     130    {
     131      *fLog << warn << AddSerialNumber(fSrcPosName) << " [MSrcPosCam] not found... creating default container." << endl;
     132      fSrcPos = (MSrcPosCam*)pList->FindCreateObj("MSrcPosCam", AddSerialNumber(fSrcPosName));
     133      if(!fSrcPos)
     134        return kFALSE;
     135    }
     136
     137  // look for/create MDCA
     138  fDCA = (MDCA*)pList->FindObject(AddSerialNumber(fDCAName), "MDCA");
     139  if (!fDCA)
     140    {
     141      *fLog << warn << AddSerialNumber(fDCAName) << " [MDCA] not found... creating default container." << endl;
     142      fDCA = (MDCA*)pList->FindCreateObj("MDCA", AddSerialNumber(fDCAName));
     143      if(!fDCA)
     144        return kFALSE;
     145    }
     146
     147  // check mode, look for a filled histogram in case kOff
     148  if(fMode==kOn)
     149    *fLog << inf << "MSrcPlace PreProcess Message: source postions will be stored in internal histo (" << fHistPos->GetName() << ")" << endl;
     150  else
     151    {
     152      if(fHistPos->GetEntries())
     153        *fLog << inf << "MSrcPlace PreProcess Message: source postions will be read from internal histo (" << fHistPos->GetName() << ")" << endl;
     154      else
     155        {
     156          *fLog << err << "MSrcPlace PreProcess Error: source postions attempted to be read from empty histo (" << fHistPos->GetName() << ")" << endl;
     157          return kFALSE;
     158        }
     159    }
     160  return kTRUE;
    153161}
    154162
     
    183191Int_t MSrcPlace::PostProcess()
    184192{
    185   *fLog << inf << endl;
    186   *fLog << inf << "MSrcPlace::PostProcess Message: Created internal histogram with: ";
    187   *fLog << inf << "Entries: " << fHistPos->GetEntries() << endl;
    188   *fLog << inf << "X projection mean: " << fHistPos->ProjectionX()->GetMean() << endl;
    189   *fLog << inf << "X projection rms:  " << fHistPos->ProjectionX()->GetRMS() << endl;
    190   *fLog << inf << "Y projection mean: " << fHistPos->ProjectionY()->GetMean() << endl;
    191   *fLog << inf << "Y projection rms:  " << fHistPos->ProjectionY()->GetRMS() << endl;
    192  
     193  if(fMode==kOn)
     194    {
     195      *fLog << inf << endl;
     196      *fLog << inf << "MSrcPlace::PostProcess Message: Created internal histogram with: " << endl;
     197      *fLog << inf << "Entries: " << fHistPos->GetEntries() << endl;
     198      *fLog << inf << "X projection mean: " << fHistPos->ProjectionX()->GetMean() << endl;
     199      *fLog << inf << "X projection rms:  " << fHistPos->ProjectionX()->GetRMS() << endl;
     200      *fLog << inf << "Y projection mean: " << fHistPos->ProjectionY()->GetMean() << endl;
     201      *fLog << inf << "Y projection rms:  " << fHistPos->ProjectionY()->GetRMS() << endl;
     202    }
    193203  return kTRUE;
    194204}
  • trunk/MagicSoft/Mars/mtemp/mifae/library/MSrcPlace.h

    r4084 r4087  
    2525  OnOffMode_t  fMode;        //  On/Off data mode (write/read to/from the histogram)
    2626
    27   virtual Int_t PreProcess(MParList *plist);
     27  void  SavePosIntoHisto();
     28  void  ReadPosFromHisto();
     29
    2830  virtual Int_t Process();
    2931  virtual Int_t PostProcess();
    3032
    31   void  SavePosIntoHisto();
    32   void  ReadPosFromHisto();
    33 
     33 protected:
     34  virtual Int_t PreProcess(MParList *plist);
    3435
    3536 public:
     
    4950  MDCA*         GetDCA()             {return fDCA;}
    5051 
    51   Int_t SearchForSrcPos(MParList *plist);
    5252  virtual Int_t ComputeNewSrcPosition() {return kTRUE;}
    5353
  • trunk/MagicSoft/Mars/mtemp/mifae/library/MSrcPosFromFile.cc

    r4084 r4087  
    4242#include "MRawRunHeader.h"
    4343#include "MSrcPosCam.h"
     44#include "MDCA.h"
    4445
    4546#include "MLog.h"
     
    9293Int_t MSrcPosFromFile::PreProcess(MParList *pList)
    9394{
    94   // Count the number of runs in the card with the source poistions
    95   ReadSourcePositionsFile(kCount);
    96  
    97   if(!fRunList)
    98     fRunList = new Int_t[fNumRuns];
    99   if(!fRunSrcPos)
    100     fRunSrcPos = new MSrcPosCam[fNumRuns];
    101   if(!fRunMap)
    102     fRunMap = new TExMap(fNumRuns);
    103  
    104   // Read card with the source poistions
    105   ReadSourcePositionsFile(kRead);
    106 
    107 
    108   if(!SearchForSrcPos(pList))
     95  if(GetMode()==MSrcPlace::kOn)
     96    {
     97      // Count the number of runs in the card with the source poistions
     98      ReadSourcePositionsFile(kCount);
     99     
     100      if(!fRunList)
     101        fRunList = new Int_t[fNumRuns];
     102      if(!fRunSrcPos)
     103        fRunSrcPos = new MSrcPosCam[fNumRuns];
     104      if(!fRunMap)
     105        fRunMap = new TExMap(fNumRuns);
     106     
     107      // Read card with the source poistions
     108      ReadSourcePositionsFile(kRead);
     109    }
     110
     111  if(!MSrcPlace::PreProcess(pList))
    109112    return kFALSE;
    110113 
     
    131134      fLastRun=run;
    132135      MSrcPosCam* srcpos = (MSrcPosCam*)fRunMap->GetValue(run);
    133      
    134       Float_t x;
    135       Float_t y;
    136        
     136
    137137      *fLog << inf << "Source position for run " << run;
    138       if (srcpos)
     138
     139      if(srcpos)
     140        fLastValidSrcPosCam = srcpos;
     141      else
     142        *fLog << inf << " not found in file. Taking previous position: ";
     143
     144      if(fLastValidSrcPosCam)
    139145        {
    140           fLastValidSrcPosCam = srcpos;
    141           x = srcpos->GetX();
    142           y = srcpos->GetY();
    143         }           
    144       else if(fLastValidSrcPosCam)
    145         {
    146           x = fLastValidSrcPosCam->GetX();
    147           y = fLastValidSrcPosCam->GetY();
    148          
    149           *fLog << inf << " not found in file. Taking previous position: ";
     146          *fLog << inf << "\tX\t" << setprecision(3) << fLastValidSrcPosCam->GetX();
     147          *fLog << inf << "\tY\t" << setprecision(3) << fLastValidSrcPosCam->GetY() << endl;     
    150148        }
    151       else
    152         {
    153           *fLog << err << "MSrcPosFromFile::ComputeNewSrcPosition error: no value for the first run. Don't know what values to take" << endl;
    154           return kFALSE;
    155         }
    156 
    157       GetSrcPosCam()->SetXY(x,y);
    158      
    159       *fLog << inf << "\tX\t" << setprecision(3) << x;
    160       *fLog << inf << "\tY\t" << setprecision(3) << y << endl;     
    161     }
    162  
     149    }
     150
     151  if(fLastValidSrcPosCam)
     152    {
     153      GetSrcPosCam()->SetXY(fLastValidSrcPosCam->GetX(),fLastValidSrcPosCam->GetY());
     154      GetDCA()->SetRefPoint(fLastValidSrcPosCam->GetX(),fLastValidSrcPosCam->GetY());
     155    }
     156  else
     157    {
     158      *fLog << err << "MSrcPosFromFile::ComputeNewSrcPosition error: no value for the first run. Don't know what values to take" << endl;
     159      return kFALSE;
     160    }
     161
    163162  return kTRUE;
    164163}
  • trunk/MagicSoft/Mars/mtemp/mifae/library/MSrcRotate.cc

    r4084 r4087  
    8383Int_t MSrcRotate::PreProcess(MParList *pList)
    8484{
    85   if(!SearchForSrcPos(pList))
     85  if(!MSrcPlace::PreProcess(pList))
    8686    return kFALSE;
    8787 
  • trunk/MagicSoft/Mars/mtemp/mifae/library/MSrcTranslate.cc

    r4084 r4087  
    2828// Task to translate the position of the source, starting from previous source
    2929// position (fTranslationIsRelative=kTRUE) or from camera center
    30 // (fTranslationIsRelative=kFALSE)
     30// (fTranslationIsRelative=kFALSE). This task allows you to modify the position
     31// of the source in an event-by-event basis
    3132//
    3233//  Input Containers:
     
    8283{
    8384  // look for/create MSrcPosCam and DCA
    84   if(!SearchForSrcPos(pList))
     85  if(!MSrcPlace::PreProcess(pList))
    8586    return kFALSE;
    8687
  • trunk/MagicSoft/Mars/mtemp/mifae/library/MSrcTranslate.h

    r4074 r4087  
    2424  virtual Int_t ComputeNewSrcPosition();
    2525
    26   ClassDef(MSrcTranslate, 0) // task to rotate the position of the source as a function of Azimuth and Zenith angles
     26  ClassDef(MSrcTranslate, 0) // task to set the position of the source within the camera in an event by event basis
    2727};
    2828
Note: See TracChangeset for help on using the changeset viewer.