Changeset 4094 for trunk/MagicSoft/Mars


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

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mtemp/mifae/Changelog

    r4087 r4094  
    1818
    1919                                                 -*-*- END OF LINE -*-*-
     20       
     21 2004/05/18  Javier Rico
     22   * library/MSrcPlace.[cc,h], library/MSrcRotate.[cc,h],
     23     library/MSrcTranslate.[cc,h], library/MSrcPosFromFile.[cc,h]
     24     - Add the possibility of having different input and output
     25       MSrcPosCam containers (CONSTRUCTORS HAVE CHANGED!)
     26     - Move the creation of internal histogram to PreProcess, so that
     27       it can be configured before creation. Now configurable: whether
     28       histo must be created or not (fCreateHisto), histo bin size
     29       (fHistoBinPrec), histogram name (fHistoName), with corresponding
     30       getters and setters
     31     - Update documentation
     32
     33   * library/MSrcPosFromFile.cc
     34     - If no position has been measured for the first analyzed run, use
     35       the one of the first run in file instead.
     36
     37   * programs/falseSource.cc
     38     - Change obsolete MSrcPosCam predefinitions for modern
     39       MSrcTranslate objects, which allow relative displacement of the
     40       source position from a previously assigned one.
     41     - Add flag for relative translation
     42     - Include control histograms (hOn[Off]SrcPos) for the source
     43       position
     44
     45   * programs/falsesource.datacard
     46     - Add datacard SRCABS for relative/absolute source translation
     47
     48   * programs/srcPos.cc
     49     - Avoid creation of internal histograms for the translation
    2050       
    2151 2004/05/17  Javier Rico
  • 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 
  • trunk/MagicSoft/Mars/mtemp/mifae/macros/alpha.C

    r4056 r4094  
    3636   
    3737    // ON data
    38     //    ton->Add("/disc01/HillasFiles/crabOnMisp3015_A.root");
    39     //    ton->Add("/disc01/HillasFiles/crabOnMisp3015_B.root");
    40     //    ton->Add("/disc01/HillasFiles/crabOnMisp3015_C.root");
    41     //    ton->Add("/disc01/HillasFiles/crabOnMisp3015_D.root");
    42     //    ton->Add("hillasCrab/crab20040215OnA.root");
    43     //    ton->Add("hillasCrab/crab20040215OnB.root");
    44     //    ton->Add("hillasCrab/crab20040215OnC.root");
    45     //    ton->Add("hillasCrab/crab20040215OnD.root");
    46     //    ton->Add("hillasCrab/crab20040215OnRotate2_-1.root");
    47     ton->Add("/disc01/HillasFiles/Mrk421/mrk421OnMisp3015_A.root");
    48     ton->Add("/disc01/HillasFiles/Mrk421/mrk421OnMisp3015_B.root");
    49     //ton->Add("/disc01/HillasFiles/Mrk421/mrk421OnMisp3015_C.root");
    50     //    ton->Add("~aliu/MagicData/CrabNebula/2004_03_19/crabOn3015_A_-1-2.root");
    51     //    ton->Add("~aliu/MagicData/CrabNebula/2004_03_19/crabOn3015_B_-1-1.root");
    52     //ton->Add("~aliu/MagicData/CrabNebula/2004_03_19/crabOn3015_C.root");
     38    ton->Add("/mnt/users/jrico/magic/mars/mars/mtemp/mifae/programs/srcPosPrueba.root");
    5339
    5440    TChain* toff= new TChain("Parameters");
    5541
    5642    // OFF data
    57     //toff->Add("/disc01/HillasFiles/crabOffMisp3015_A.root");
    58     //    toff->Add("/disc01/HillasFiles/crabOffMisp3015_B.root");
    59     //    toff->Add("/disc01/HillasFiles/crabOffMisp3015_C.root");
    60     //    toff->Add("/disc01/HillasFiles/crabOffMisp3015_D.root");
    61     //    toff->Add("/disc01/HillasFiles/crabOffMisp3015_E.root");
    62     //    toff->Add("/disc01/HillasFiles/crabOffMisp3015_F.root");
    63     //    toff->Add("/disc01/HillasFiles/crabOffMisp3015_G.root");
    64     //    toff->Add("/disc01/HillasFiles/crabOffMisp3015_H.root");
    65         //    toff->Add("hillasCrab/crab20040215OffA.root");
    66     //    toff->Add("hillasCrab/crab20040215OffB.root");
    67     //    toff->Add("hillasCrab/crab20040215OffC.root");
    68     //    toff->Add("hillasCrab/crab20040215OffD.root");
    69     //    toff->Add("hillasCrab/crab20040215OffE.root");
    70     //    toff->Add("hillasCrab/crab20040215OffF.root");
    71     //    toff->Add("hillasCrab/crab20040215OffG.root");
    72     //    toff->Add("hillasCrab/crab20040215OffH.root");
    73     //    toff->Add("hillasCrab/crab20040215OffRotate2_-1.root");
    74     toff->Add("/disc01/HillasFiles/OffMrk421/mrk421OffMisp3015_A.root");
    75     toff->Add("/disc01/HillasFiles/OffMrk421/mrk421OffMisp3015_B.root");
    76     toff->Add("/disc01/HillasFiles/OffMrk421/mrk421OffMisp3015_C.root");
    77     //    toff->Add("~aliu/MagicData/CrabNebula/2004_03_19/crabOff3015_-1-1.root");
    78     //    toff->Add("~aliu/MagicData/CrabNebula/2004_03_19/crabOff3015_A.root");
    79     //    toff->Add("~aliu/MagicData/CrabNebula/2004_03_19/crabOff3015_B.root");
    80     //    toff->Add("~aliu/MagicData/CrabNebula/2004_03_19/crabOff3015_C.root");
    81 
     43    toff->Add("/mnt/users/jrico/magic/mars/mars/mtemp/mifae/programs/srcPosOffPrueba.root");
    8244   
    8345    TCanvas *c1 = new TCanvas("c1","c1",800,500);
  • trunk/MagicSoft/Mars/mtemp/mifae/macros/signal.C

    r4049 r4094  
    1616  Float_t array[2];
    1717 
    18   Int_t nbin2d = 10;
     18  Int_t nbin2d = 5;
    1919  Int_t ntotal = 2*nbin2d+1;
    2020 
  • trunk/MagicSoft/Mars/mtemp/mifae/programs/falseSource.cc

    r4045 r4094  
    1616
    1717#include "TString.h"
    18 #include "TH1F.h"
     18#include "TH2F.h"
    1919#include "TFile.h"
    2020
    2121#include "MHillasSrcCalc.h"
    2222#include "MSrcPosCam.h"
     23#include "MSrcTranslate.h"
    2324#include "MHillasSrc.h"
    2425#include "MSrcRotate.h"
     
    4344TString offFile;
    4445TString outputFile;
    45 Bool_t kRotate=1;
     46Bool_t  kRotate=1;
     47Bool_t  kSrcPolicy=kFALSE;
    4648Double_t fRA= -1.;
    4749Double_t fDEC= -1.;
     
    7375const Float_t alphamax = 90.;      // maximum value in alpha (degrees)
    7476const Float_t conver   = 189./0.6; // conversion factor degrees to mm
     77const Float_t srclimit = field*conver;
     78const Float_t srcstep  = 3.;
     79const Int_t   nsrcbin  = (Int_t) (srclimit/srcstep);
    7580
    7681//-----------------------------------------------------------------------------
     
    131136 
    132137  // create the histograms (empty)
    133   TH1F *hOnAlpha[binning][binning];
    134   TH1F *hOffAlpha[binning][binning];
     138  TH1F* hOnAlpha[binning][binning];
     139  TH1F* hOffAlpha[binning][binning];
     140  TH2F* hOnSrcPos[binning];
     141  TH2F* hOffSrcPos[binning];
     142
    135143  for(Int_t i = -ival; i <= ival ; i++){ 
    136144    for(Int_t j = -ival; j <= ival ; j++){
     
    144152      hOffAlpha[i+ival][j+ival] = new TH1F(name, title, nbin, alphamin, alphamax);
    145153
     154      if(j==0)
     155        {
     156          sprintf(name,"hOnSrcPos[%d]", i);
     157          sprintf(title,"Source position (On data) (%d)", i);
     158          hOnSrcPos[i+ival] = new TH2F(name, title, nsrcbin, -srclimit, srclimit, nsrcbin, -srclimit, srclimit);
     159         
     160          sprintf(name,"hOffSrcPos[%d]", i);
     161          sprintf(title,"Source position (Off data) (%d)", i);
     162          hOffSrcPos[i+ival] = new TH2F(name, title, nsrcbin, -srclimit, srclimit, nsrcbin, -srclimit, srclimit);
     163        }
    146164    }
    147165  }
     
    154172 
    155173  // source dependent hillas containers/tasks
    156   MHillasSrcCalc* csrc1[binning][binning];
    157174  MSrcPosCam*     source[binning][binning];
    158175  MHillasSrc*     hillasSrc[binning][binning];
     176  MSrcTranslate*  srctranslate[binning][binning];
    159177  MSrcRotate*     srcrotate[binning][binning];
     178  MHillasSrcCalc* csrc1[binning][binning];
    160179
    161180  // normal containers/classes
     
    171190  tlist.AddToList(&read);
    172191   
    173   Int_t k,l; 
    174192  char sourceName[100]; 
    175193  char hillasSrcName[100];
     194  char translateName[100]; 
     195  char rotateName[100];
    176196
    177197  // create the tasks/containers for the different source positions
     
    186206          if (i<0 && j<0)
    187207            {
    188               k = -i;
    189               l = -j;
     208              Int_t k = -i;
     209              Int_t l = -j;
    190210              sprintf(sourceName,    "MSrcPosCam_Min%dMin%d", k, l);
    191211              sprintf(hillasSrcName, "MHillasSrc_Min%dMin%d", k, l);
     212              sprintf(translateName, "MSrcTranslate_Min%dMin%d", k, l);
     213              sprintf(rotateName,    "MSrcRotate_Min%dMin%d", k, l);
    192214            }
    193215         
    194216          if (i<0 && j>=0)
    195217            {
    196               k = -i;
     218              Int_t k = -i;
    197219              sprintf(sourceName,    "MSrcPosCam_Min%d%d", k, j);
    198220              sprintf(hillasSrcName, "MHillasSrc_Min%d%d", k, j);
     221              sprintf(translateName, "MSrcTranslate_Min%d%d", k, j);
     222              sprintf(rotateName,    "MSrcRotate_Min%d%d", k, j);
    199223            }
    200224         
    201225          if (i>=0 && j<0)
    202226            {
    203               l = -j;
     227              Int_t l = -j;
    204228              sprintf(sourceName,    "MSrcPosCam_%dMin%d", i, l);
    205229              sprintf(hillasSrcName, "MHillasSrc_%dMin%d", i, l);
     230              sprintf(translateName, "MSrcTranslate_%dMin%d", i, l);
     231              sprintf(rotateName,    "MSrcRotate_%dMin%d", i, l);
    206232            }
    207233         
     
    210236              sprintf(sourceName,    "MSrcPosCam_%d%d", i, j);
    211237              sprintf(hillasSrcName, "MHillasSrc_%d%d", i, j);
     238              sprintf(translateName, "MSrcTranslate_%d%d", i, j);
     239              sprintf(rotateName,    "MSrcRotate_%d%d", i, j);
    212240            }
    213241
    214242          // include containers in parameter list
    215243          source[i+ival][j+ival] = new MSrcPosCam(sourceName);
    216           source[i+ival][j+ival]->SetXY(xpos, ypos);     
    217244          plist.AddToList(source[i+ival][j+ival]);
    218           source[i+ival][j+ival]->Print();
    219245                 
    220246          hillasSrc[i+ival][j+ival] = new MHillasSrc(hillasSrcName);     
     
    222248         
    223249          // define the different tasks and include them in the task list
    224           if(kRotate)
     250          srctranslate[i+ival][j+ival] = new MSrcTranslate("MSrcPosCam",sourceName,"MDCA",translateName);         
     251          srctranslate[i+ival][j+ival]->SetTranslation(xpos,ypos);       
     252          srctranslate[i+ival][j+ival]->SetRelativeTranslation(kSrcPolicy);
     253          srctranslate[i+ival][j+ival]->SetInternalHistoBinSize(5.);
     254          srctranslate[i+ival][j+ival]->SetMode(MSrcPlace::kOn);
     255     
     256          tlist.AddToList(srctranslate[i+ival][j+ival]); 
     257
     258          if(kRotate && !kSrcPolicy)
    225259            {
    226               srcrotate[i+ival][j+ival] = new MSrcRotate(sourceName);
     260              srcrotate[i+ival][j+ival] = new MSrcRotate(sourceName,sourceName,"MDCA",rotateName);
    227261              srcrotate[i+ival][j+ival]->SetRAandDEC(fRA,fDEC);   
     262
     263              srctranslate[i+ival][j+ival]->SetCreateHisto(kFALSE);
     264              srcrotate[i+ival][j+ival]->SetMode(MSrcPlace::kOn);             
     265              srcrotate[i+ival][j+ival]->SetInternalHistoBinSize(5.);
     266
    228267              tlist.AddToList(srcrotate[i+ival][j+ival]); 
    229268            }
     269          else
     270            srcrotate[i+ival][j+ival] = NULL;
     271
    230272
    231273          TString HilName = "MHillas";   
     
    266308                hOnAlpha[i+ival][j+ival]->Fill(TMath::Abs(alpha));
    267309              }
     310
     311            // fill source position histo
     312            if(j==0)
     313              hOnSrcPos[i+ival]->Fill(source[i+ival][j+ival]->GetX(),source[i+ival][j+ival]->GetY());
    268314          }
    269315      if(++nread>nmaxevents) break;
     
    278324                        FILL OFF-DATA HISTOS
    279325  *******************************************************************/
     326 for(Int_t i=-ival;i<=ival;i++)
     327   for(Int_t j=-ival;j<=ival;j++)
     328     {
     329       if(srcrotate[i+ival][j+ival])
     330         srcrotate[i+ival][j+ival]->SetMode(MSrcPlace::kOff);
     331       srctranslate[i+ival][j+ival]->SetMode(MSrcPlace::kOff);
     332     }
     333
    280334 
    281335  MReadTree read2("Parameters", offFile);
     
    306360                hOffAlpha[i+ival][j+ival]->Fill(TMath::Abs(alpha));           
    307361              }         
     362
     363            // fill source position histo
     364            if(j==0)
     365              hOffSrcPos[i+ival]->Fill(source[i+ival][j+ival]->GetX(),source[i+ival][j+ival]->GetY());
    308366          }
    309367      if(++nread>nmaxevents) break;
     
    319377      hOnAlpha[i+ival][j+ival]->Write();
    320378      hOffAlpha[i+ival][j+ival]->Write();
     379      if(j==0)
     380        {
     381          hOnSrcPos[i+ival]->Write();
     382          hOffSrcPos[i+ival]->Write();
     383        }
    321384    }
    322385  }
     
    324387  f->Close();
    325388
     389 for(Int_t i=-ival;i<=ival;i++)
     390   for(Int_t j=-ival;j<=ival;j++)
     391     {
     392       if(srcrotate[i+ival][j+ival])
     393         delete srcrotate[i+ival][j+ival];
     394       delete srctranslate[i+ival][j+ival];
     395       delete source[i+ival][j+ival];
     396       delete hillasSrc[i+ival][j+ival];
     397       delete csrc1[i+ival][j+ival];
     398     }
    326399}
    327400//-----------------------------------------------------------------------
     
    379452        ifun >> kRotate;
    380453
     454      // source movement policy flag
     455      if(strcmp(word.Data(),"SRCABS")==0)
     456        ifun >> kSrcPolicy;       
     457
     458
    381459      // source celestial coordinates
    382460      if(strcmp(word.Data(),"SRCCOORDS")==0)
     
    394472        ifun >> binning;
    395473
    396 
    397474      // Number of bins in alpha plots
    398475      if(strcmp(word.Data(),"NBIN")==0)
    399476        ifun >> nbin;
    400 
    401      
    402 
    403477
    404478      // size cut
     
    461535  cout << "Off-data file name(s): " << offFile << endl;
    462536  cout << "Output file name: " << outputFile << endl;
    463   cout << "De-rotation flag " << kRotate << endl;
    464   cout << "Source celestial coordiantes (rad): RA = " << fRA << ", DEC = " << fDEC << endl;
     537  if(kSrcPolicy)
     538    cout << "Source position displaced with respect to the original existing one (no rotation applied)" << endl;
     539  else
     540    {
     541      cout << "De-rotation flag " << kRotate << endl;
     542      cout << "Source celestial coordiantes (rad): RA = " << fRA << ", DEC = " << fDEC << endl;
     543    }
    465544  cout << "Field width (degrees): " << field << endl;
    466545  cout << "Field binning: " << binning << endl;
  • trunk/MagicSoft/Mars/mtemp/mifae/programs/falsesource.datacard

    r3973 r4094  
    44
    55// On-data file name pattern
    6 ONFILES  /mnt/users/jrico/magic/mars/Mars_Standard01/hillasCrab/crab20040215On*.root
     6ONFILES  ./srcPosPrueba.root
    77
    88// Off-data file name pattern
    9 OFFFILES /mnt/users/jrico/magic/mars/Mars_Standard01/hillasCrab/crab20040215Off*.root
     9OFFFILES ./srcPosOffPrueba.root
    1010
    1111// output file name
    12 OUTFILE  ./rotateprueba.root
     12OUTFILE  ./rotateprueba2.root
    1313
    1414// rotation flag:
     
    1919// source coordinates (RA DEC in rads)
    2020SRCCOORDS 1.46 0.384
     21
     22// Flag to determine whether source position is absolute (0) or relative to previous position (1)
     23// In case SRCABS=1, no rotation is carried out
     24SRCABS 1
    2125
    2226// Width of examined field (degrees)
  • trunk/MagicSoft/Mars/mtemp/mifae/programs/srcPos.cc

    r4084 r4094  
    128128      srctranslate.SetTranslation(xpos,ypos);
    129129      srctranslate.SetRelativeTranslation(kSrcPolicy);
     130      srctranslate.SetCreateHisto(kFALSE);
    130131      srcrotate.SetRAandDECandRefMJD(fRA,fDEC,mjdpos);
    131132      srcrotate.SetMode(MSrcPlace::kOn);
     
    164165 
    165166  tlist.PrintStatistics();
    166 
    167167 
    168168  // do off-data if input file was specified
     
    196196
    197197  tlist.PrintStatistics();
    198 
    199198}
    200199//-----------------------------------------------------------------------
  • trunk/MagicSoft/Mars/mtemp/mifae/programs/srcpos.datacard

    r4087 r4094  
    11
    22// Maximun number of on and off events to be processed)
    3 NEVENTS 20000
     3NEVENTS 9999999
    44
    5 // Input file name pattern
     5// Input file name pattern (wildcards allowed)
    66INPUTFILES /mnt/users/jrico/magic/mars/Mars_Standard02/mtemp/mifae/hillas/mrk20040215OnNoCalB.root
    77
Note: See TracChangeset for help on using the changeset viewer.