Ignore:
Timestamp:
05/18/04 10:16:45 (21 years ago)
Author:
rico
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mtemp/mifae/library
Files:
8 edited

Legend:

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

    r4087 r4094  
    6666//
    6767// Default constructor. The first argument is the name of the internal histo,
    68 // the second (third) argument is the name of a container
    69 // containing the source position in the camera plain, MScrPosCam (MDCA).
    70 // The default is "MSrcPosCam" ("MDCA").
    71 //
    72 MSrcPlace::MSrcPlace(const char* histname, const char* srcPos, const char* dca, const char *name, const char *title)
    73   : fSrcPos(NULL), fDCA(NULL)
     68// the second (third) argument is the name of the input (output) container
     69// containing the source position in the camera plain. Fourth argument is the
     70// name of the output MDCA container.
     71//
     72MSrcPlace::MSrcPlace(const char* srcPosIn, const char* srcPosOut, const char* dca, const char *name, const char *title)
     73  : fSrcPosIn(NULL), fSrcPosOut(NULL), fDCA(NULL), fHistoName("SrcPosHist"),
     74    fHistoBinPrec(1.), fHistPos(NULL)
    7475{
    7576    fName  = name  ? name  : gsDefName.Data();
    7677    fTitle = title ? title : gsDefTitle.Data();
    7778
    78     fSrcPosName  = srcPos;
    79     fDCAName     = dca;
    80 
    81     const Float_t cameraSize   = 600; //[mm]
    82     const Float_t binPrecision =   1; //[mm] ~ 0.0033 deg 
    83     const UInt_t nbins =  (UInt_t)(cameraSize*2/binPrecision);
    84    
    85     fHistPos = new TH2F(histname,"",nbins,-cameraSize,cameraSize,nbins,-cameraSize,cameraSize);
     79    fSrcPosInName   = srcPosIn;
     80    fSrcPosOutName  = srcPosOut;
     81    fDCAName        = dca;
    8682
    8783    fMode=kOn;
     84    fCreateHisto=kTRUE;
    8885}
    8986// -------------------------------------------------------------------------
     
    103100void MSrcPlace::SavePosIntoHisto()
    104101
    105   fHistPos->Fill(fSrcPos->GetX(),fSrcPos->GetY());
     102  if(fHistPos)
     103    fHistPos->Fill(fSrcPosOut->GetX(),fSrcPosOut->GetY());
    106104}
    107105// -------------------------------------------------------------------------
     
    111109void MSrcPlace::ReadPosFromHisto()
    112110
    113   Axis_t x;
    114   Axis_t y;
    115  
    116   fHistPos->GetRandom2(x,y);
    117   fSrcPos->SetXY(x,y);
    118   fDCA->SetRefPoint(x,y);
     111  if(fHistPos)
     112    {
     113      Axis_t x;
     114      Axis_t y;
     115     
     116      fHistPos->GetRandom2(x,y);
     117      fSrcPosOut->SetXY(x,y);
     118      fDCA->SetRefPoint(x,y);
     119    }
    119120}
    120121// -------------------------------------------------------------------------
     
    125126Int_t MSrcPlace::PreProcess(MParList* pList)
    126127{
    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)
     128  // create (if needed and requested) internal histogram
     129  if(fCreateHisto && !fHistPos)
     130    {
     131      const Float_t cameraSize   = 600; //[mm]
     132      const UInt_t nbins =  (UInt_t)(cameraSize*2/fHistoBinPrec);
     133      fHistPos = new TH2F(fHistoName,"",nbins,-cameraSize,cameraSize,nbins,-cameraSize,cameraSize);
     134      fHistPos->SetDirectory(0);
     135      *fLog << inf << "MSrcPlace::PreProcess Message: internal histogram " << fHistoName << " created with " << nbins << "x" << nbins << " bins" << endl;
     136    }
     137
     138  // look for/create input MSrcPosCam
     139  fSrcPosIn = (MSrcPosCam*)pList->FindObject(AddSerialNumber(fSrcPosInName), "MSrcPosCam");
     140  if (!fSrcPosIn)
     141    {
     142      *fLog << warn << AddSerialNumber(fSrcPosInName) << " [MSrcPosCam] not found... creating default container." << endl;
     143      fSrcPosIn = (MSrcPosCam*)pList->FindCreateObj("MSrcPosCam", AddSerialNumber(fSrcPosInName));
     144      if(!fSrcPosIn)
     145        return kFALSE;
     146    }
     147
     148  // look for/create output MSrcPosCam
     149  fSrcPosOut = (MSrcPosCam*)pList->FindObject(AddSerialNumber(fSrcPosOutName), "MSrcPosCam");
     150  if (!fSrcPosOut)
     151    {
     152      *fLog << warn << AddSerialNumber(fSrcPosOutName) << " [MSrcPosCam] not found... creating default container." << endl;
     153      fSrcPosOut = (MSrcPosCam*)pList->FindCreateObj("MSrcPosCam", AddSerialNumber(fSrcPosOutName));
     154      if(!fSrcPosOut)
    134155        return kFALSE;
    135156    }
     
    146167
    147168  // 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;
     169  if(fHistPos)
     170    {
     171      if(fMode==kOn)
     172        *fLog << inf << "MSrcPlace PreProcess Message: source postions will be stored in internal histo (" << fHistPos->GetName() << ")" << endl;
    154173      else
    155174        {
    156           *fLog << err << "MSrcPlace PreProcess Error: source postions attempted to be read from empty histo (" << fHistPos->GetName() << ")" << endl;
    157           return kFALSE;
     175          if(fHistPos->GetEntries())
     176            *fLog << inf << "MSrcPlace PreProcess Message: source postions will be read from internal histo (" << fHistPos->GetName() << ")" << endl;
     177          else
     178            {
     179              *fLog << err << "MSrcPlace PreProcess Error: source postions attempted to be read from empty histo (" << fHistPos->GetName() << ")" << endl;
     180              return kFALSE;
     181            }
    158182        }
    159183    }
     
    191215Int_t MSrcPlace::PostProcess()
    192216{
    193   if(fMode==kOn)
     217  if(fMode==kOn && fHistPos)
    194218    {
    195219      *fLog << inf << endl;
  • trunk/MagicSoft/Mars/mtemp/mifae/library/MSrcPlace.h

    r4087 r4094  
    1616 
    1717 private:
    18   MSrcPosCam*  fSrcPos;      //  Pointer to the source position
    19   MDCA*        fDCA;         //  Pointer to the MDCA object
     18  MSrcPosCam*  fSrcPosIn;       //  Pointer to the input source position container
     19  MSrcPosCam*  fSrcPosOut;      //  Pointer to the output source position container
     20  MDCA*        fDCA;            //  Pointer to the output MDCA container
    2021 
    21   TString      fSrcPosName;  //  Name of the MSrcPosCam object
    22   TString      fDCAName;     //  Name of the MDCA object
    23  
    24   TH2F*        fHistPos;  //  histogram of the used source positions
     22  TString      fSrcPosInName;   //  Name of the input MSrcPosCam object
     23  TString      fSrcPosOutName;  //  Name of the output MSrcPosCam object
     24  TString      fDCAName;        //  Name of the MDCA object
     25
     26  TString      fHistoName;      //  Name of internal histogram
     27  Float_t      fHistoBinPrec;   //  [mm] internal histo bin size
     28
     29  TH2F*        fHistPos;     //  histogram of the used source positions
    2530  OnOffMode_t  fMode;        //  On/Off data mode (write/read to/from the histogram)
     31  Bool_t       fCreateHisto; //  flag to decide whether internal histo is created or not
    2632
    2733  void  SavePosIntoHisto();
     
    3541
    3642 public:
    37   MSrcPlace(const char* histname="HistSrcPos",
    38             const char* src="MSrcPosCam", const char* dca="MDCA",
     43  MSrcPlace(const char* srcin="MSrcPosCam",const char* srcout="MSrcPosCam",
     44            const char* dcaout="MDCA",
    3945            const char* name=NULL, const char* title=NULL);
    4046
    4147  virtual ~MSrcPlace();
    4248
    43   void SetMode(OnOffMode_t mode)   {fMode=mode;}
    44   void SetSrcPosName(TString name) {fSrcPosName=name;}
    45   void SetDCAName(TString name)    {fDCAName=name;}
     49  void SetMode(OnOffMode_t mode)            {fMode=mode;}
     50  void SetInputSrcPosName(TString name)     {fSrcPosInName=name;}
     51  void SetOutputSrcPosName(TString name)    {fSrcPosOutName=name;}
     52  void SetDCAName(TString name)             {fDCAName=name;}
     53  void SetInternalHistoName(TString name)   {fHistoName=name;}
     54  void SetInternalHistoBinSize(Float_t size){fHistoBinPrec=size;}
     55  void SetCreateHisto(Bool_t inp=kTRUE)     {fCreateHisto=inp;}
    4656
    47   OnOffMode_t   GetMode()            {return fMode;}
    48   TH2F*         GetPositionHisto()   {return fHistPos;}
    49   MSrcPosCam*   GetSrcPosCam()       {return fSrcPos;}
    50   MDCA*         GetDCA()             {return fDCA;}
     57  OnOffMode_t   GetMode()              {return fMode;}
     58  TH2F*         GetPositionHisto()     {return fHistPos;}
     59  MSrcPosCam*   GetInputSrcPosCam()    {return fSrcPosIn;}
     60  MSrcPosCam*   GetOutputSrcPosCam()   {return fSrcPosOut;}
     61  MDCA*         GetDCA()               {return fDCA;}
     62  TString       GetInternalHistoName() {return fHistoName;}
    5163 
    5264  virtual Int_t ComputeNewSrcPosition() {return kTRUE;}
  • trunk/MagicSoft/Mars/mtemp/mifae/library/MSrcPosFromFile.cc

    r4087 r4094  
    4747#include "MLogManip.h"
    4848
     49
    4950ClassImp(MSrcPosFromFile);
    5051
     
    6162//
    6263MSrcPosFromFile::MSrcPosFromFile(TString cardpath, OnOffMode_t mode, const char *name, const char *title)
    63   : MSrcPlace(TString(gsDefName+"Hist").Data()), fRawRunHeader(NULL), fSourcePositionFilePath(cardpath)
     64  : fRawRunHeader(NULL), fSourcePositionFilePath(cardpath)
    6465{
    6566  fName  = name  ? name  : gsDefName.Data();
     
    7172  fRunMap=0x0;
    7273
    73   fLastRun = 0;
     74  fLastRun  = 0;
     75  fFirstRun = 0;
    7476  fLastValidSrcPosCam=0x0;
     77
     78  SetInternalHistoName(TString(fName)+"Hist");
    7579}
    7680// -------------------------------------------------------------------------
     
    139143      if(srcpos)
    140144        fLastValidSrcPosCam = srcpos;
     145      else if(fLastValidSrcPosCam)
     146        *fLog << inf << " not found in file. Taking previous position: ";
    141147      else
    142         *fLog << inf << " not found in file. Taking previous position: ";
    143 
    144       if(fLastValidSrcPosCam)
    145148        {
    146           *fLog << inf << "\tX\t" << setprecision(3) << fLastValidSrcPosCam->GetX();
    147           *fLog << inf << "\tY\t" << setprecision(3) << fLastValidSrcPosCam->GetY() << endl;     
     149          *fLog << warn << "MSrcPosFromFile::ComputeNewSrcPosition warning: no value for the first run. Taking first found run in file, run number " << fFirstRun << endl;
     150          fLastValidSrcPosCam = (MSrcPosCam*)fRunMap->GetValue(run);
    148151        }
    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     }
     152
     153      *fLog << inf << "\tX\t" << setprecision(3) << fLastValidSrcPosCam->GetX();
     154      *fLog << inf << "\tY\t" << setprecision(3) << fLastValidSrcPosCam->GetY() << endl;     
     155    }
     156
     157  GetOutputSrcPosCam()->SetXY(fLastValidSrcPosCam->GetX(),fLastValidSrcPosCam->GetY());
     158  GetDCA()->SetRefPoint(fLastValidSrcPosCam->GetX(),fLastValidSrcPosCam->GetY());
    161159
    162160  return kTRUE;
     
    186184    {
    187185      fin >> run >> x >> y;
     186      if(!fFirstRun) fFirstRun=run;
    188187      if(fin.eof())
    189188        break;
  • trunk/MagicSoft/Mars/mtemp/mifae/library/MSrcPosFromFile.h

    r4084 r4094  
    2020
    2121    Int_t  fNumRuns;
     22    UInt_t  fFirstRun;
    2223    UInt_t  fLastRun;
    2324
  • trunk/MagicSoft/Mars/mtemp/mifae/library/MSrcRotate.cc

    r4087 r4094  
    6262// -------------------------------------------------------------------------
    6363//
    64 // Default constructor. The first (second) argument is the name of a container
    65 // containing the source position in the camera plain, MScrPosCam (MDCA).
    66 // The default is "MSrcPosCam" ("MDCA").
    67 //
    68 MSrcRotate::MSrcRotate(const char* srcPos, const char* dca, const char *name, const char *title)
    69   : MSrcPlace(TString(gsDefName+"Hist").Data()), fRA(0), fDEC(0), fRefMJD(0), fRunNumber(0)
     64// Default constructor. The first (second) argument is the name of the
     65// input (output) MSrcPosCam object containing the source position in the
     66// camera plain
     67//
     68MSrcRotate::MSrcRotate(const char* srcPosIn, const char* srcPosOut, const char* dca, const char *name, const char *title)
     69  : fRA(0), fDEC(0), fRefMJD(0), fRunNumber(0)
    7070{
    7171    fName  = name  ? name  : gsDefName.Data();
    7272    fTitle = title ? title : gsDefTitle.Data();
    7373
    74     SetSrcPosName(srcPos);
     74    SetInputSrcPosName(srcPosIn);
     75    SetOutputSrcPosName(srcPosOut);
    7576    SetDCAName(dca);
     77
     78    SetInternalHistoName(TString(fName)+"Hist");
    7679}
    7780
     
    176179    Observation.RotationAngle(fRA,fDEC)-RefObservation.RotationAngle(fRA,fDEC) :
    177180    Observation.RotationAngle(fRA,fDEC) ;
    178   MSrcPosCam* srcpos = GetSrcPosCam();
     181  MSrcPosCam* srcposIn  = GetInputSrcPosCam();
     182  MSrcPosCam* srcposOut = GetOutputSrcPosCam();
    179183  MDCA* dca = GetDCA();
    180184 
     
    182186  Float_t s = TMath::Sin(rotationAngle);
    183187  // perform a rotation of -rotationAngle to move the source back to the "initial" position
    184   Float_t newX = c*srcpos->GetX()-s*srcpos->GetY();
    185   Float_t newY = s*srcpos->GetX()+c*srcpos->GetY();
     188  Float_t newX = c*srcposIn->GetX()-s*srcposIn->GetY();
     189  Float_t newY = s*srcposIn->GetX()+c*srcposIn->GetY();
    186190 
    187191#ifdef DEBUG
    188192  Double_t rotationAngleComp = fObservatory->RotationAngle(0.1256,2.63);
    189193  cout << "Event " << fEvtHeader->GetDAQEvtNumber() << endl;
    190   cout << "newMJD=" << newMJD <<", rotationAngle=" << rotationAngle <<", rotationAngleComp=" << rotationAngleComp << ", oldX="<<fIniSrcPos.GetX()<< ", oldY="<<fIniSrcPos.GetY()<< ", newX="<<newX<< ", newY="<<newY << endl;
     194  cout << "newMJD=" << newMJD <<", rotationAngle=" << rotationAngle <<", rotationAngleComp=" << rotationAngleComp << ", oldX="<<fIniSrcPosIn.GetX()<< ", oldY="<<fIniSrcPosIn.GetY()<< ", newX="<<newX<< ", newY="<<newY << endl;
    191195#endif
    192196 
    193   srcpos->SetX(newX);
    194   srcpos->SetY(newY);
     197  srcposOut->SetXY(newX,newY);
    195198  dca->SetRefPoint(newX,newY);
    196199
  • trunk/MagicSoft/Mars/mtemp/mifae/library/MSrcRotate.h

    r4072 r4094  
    3131 
    3232 public:
    33   MSrcRotate(const char* src="MSrcPosCam", const char* dca="MDCA",
     33  MSrcRotate(const char* srcIn="MSrcPosCam",const char* srcOut="MSrcPosCam",
     34             const char* dca="MDCA",
    3435             const char* name=NULL, const char* title=NULL);
    3536 
  • trunk/MagicSoft/Mars/mtemp/mifae/library/MSrcTranslate.cc

    r4087 r4094  
    3333//  Input Containers:
    3434//    MSrcPosCam
    35 //    [MDCA]
    3635//
    3736//  Output Containers:
     
    6261// -------------------------------------------------------------------------
    6362//
    64 // Default constructor. The first (second) argument is the name of a container
    65 // containing the source position in the camera plain, MScrPosCam (MDCA).
    66 // The default is "MSrcPosCam" ("MDCA").
     63// Default constructor. The first (second) argument is the name of the
     64// input (output) MSrcPosCam object containing the source position in the
     65// camera plain
    6766//
    68 MSrcTranslate::MSrcTranslate(const char* srcPos, const char* dca, const char *name, const char *title)
    69   : MSrcPlace(TString(gsDefName+"Hist").Data()), fShiftX(0.), fShiftY(0.), fTranslationIsRelative(kTRUE)
     67MSrcTranslate::MSrcTranslate(const char* srcPosIn, const char* srcPosOut, const char* dca, const char *name, const char *title)
     68  : fShiftX(0.), fShiftY(0.), fTranslationIsRelative(kTRUE)
    7069{
    7170    fName  = name  ? name  : gsDefName.Data();
    7271    fTitle = title ? title : gsDefTitle.Data();
    7372
    74     SetSrcPosName(srcPos);
     73    SetInputSrcPosName(srcPosIn);
     74    SetOutputSrcPosName(srcPosOut);
    7575    SetDCAName(dca);
     76
     77    SetInternalHistoName(TString(fName)+"Hist");
    7678}
    7779
     
    100102  Double_t newX,newY;
    101103
    102   MSrcPosCam* srcPos = GetSrcPosCam();
    103   MDCA*       dca    = GetDCA();
    104 
     104  MSrcPosCam* srcPosOut = GetOutputSrcPosCam();
     105  MDCA*       dca       = GetDCA();
     106 
    105107  if(fTranslationIsRelative)
    106108    {
    107       newX=srcPos->GetX()+fShiftX;
    108       newY=srcPos->GetY()+fShiftY;
     109      MSrcPosCam* srcPosIn  = GetInputSrcPosCam();
     110      newX=srcPosIn->GetX()+fShiftX;
     111      newY=srcPosIn->GetY()+fShiftY;
    109112    }
    110113  else
     
    114117    }
    115118
    116   srcPos->SetX(newX);
    117   srcPos->SetY(newY);
     119  srcPosOut->SetXY(newX,newY);
    118120  dca->SetRefPoint(newX,newY);
    119121
  • trunk/MagicSoft/Mars/mtemp/mifae/library/MSrcTranslate.h

    r4087 r4094  
    1717
    1818 public:
    19   MSrcTranslate(const char* src="MSrcPosCam", const char* dca="MDCA",
     19  MSrcTranslate(const char* srcIn="MSrcPosCam", const char* srcOut="MSrcPosCam",
     20                const char* dca="MDCA",
    2021                const char* name=NULL, const char* title=NULL);
    2122 
Note: See TracChangeset for help on using the changeset viewer.