Ignore:
Timestamp:
05/17/04 09:35:10 (21 years ago)
Author:
rico
Message:
*** empty log message ***
File:
1 edited

Legend:

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

    r4074 r4084  
    6060//
    6161MSrcPosFromFile::MSrcPosFromFile(TString cardpath, OnOffMode_t mode, const char *name, const char *title)
    62   : fRawRunHeader(NULL), fSourcePositionFilePath(cardpath)
     62  : MSrcPlace(TString(gsDefName+"Hist").Data()), fRawRunHeader(NULL), fSourcePositionFilePath(cardpath)
    6363{
    6464  fName  = name  ? name  : gsDefName.Data();
     
    6666  SetMode(mode);
    6767
     68  fRunList=0x0;
     69  fRunSrcPos=0x0;
     70  fRunMap=0x0;
     71
    6872  fLastRun = 0;
    69  
     73  fLastValidSrcPosCam=0x0;
     74}
     75// -------------------------------------------------------------------------
     76//
     77// Destructor
     78//
     79MSrcPosFromFile::~MSrcPosFromFile()
     80{
     81  if(fRunList)
     82    delete [] fRunList;
     83  if(fRunSrcPos)
     84    delete [] fRunSrcPos;
     85  if(fRunMap)
     86    delete fRunMap;
     87}
     88
     89// -------------------------------------------------------------------------
     90//
     91// Open and read the input file.
     92Int_t MSrcPosFromFile::PreProcess(MParList *pList)
     93{
    7094  // Count the number of runs in the card with the source poistions
    7195  ReadSourcePositionsFile(kCount);
    7296 
    73   fRunList = new Int_t[fNumRuns];
    74   fRunSrcPos = new MSrcPosCam[fNumRuns];
    75   fRunMap = new TExMap(fNumRuns);
     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);
    76103 
    77104  // Read card with the source poistions
    78105  ReadSourcePositionsFile(kRead);
    79 }
    80 
    81 MSrcPosFromFile::~MSrcPosFromFile()
    82 {
    83   delete [] fRunList;
    84   delete [] fRunSrcPos;
    85   delete fRunMap;
    86 }
    87 
    88 // -------------------------------------------------------------------------
    89 //
    90 Int_t MSrcPosFromFile::PreProcess(MParList *pList)
    91 {
     106
     107
    92108  if(!SearchForSrcPos(pList))
    93109    return kFALSE;
     
    119135      Float_t y;
    120136       
     137      *fLog << inf << "Source position for run " << run;
    121138      if (srcpos)
    122139        {
     140          fLastValidSrcPosCam = srcpos;
    123141          x = srcpos->GetX();
    124142          y = srcpos->GetY();
     143        }           
     144      else if(fLastValidSrcPosCam)
     145        {
     146          x = fLastValidSrcPosCam->GetX();
     147          y = fLastValidSrcPosCam->GetY();
    125148         
    126           GetSrcPosCam()->SetXY(x,y);
    127                
    128           *fLog << inf << "Source position for run " << run;
    129           *fLog << inf << "\tX\t" << setprecision(3) << x;
    130           *fLog << inf << "\tY\t" << setprecision(3) << y << endl;
    131         }           
     149          *fLog << inf << " not found in file. Taking previous position: ";
     150        }
    132151      else
    133152        {
    134           *fLog << inf << "Source position for run " << run << " not found in file. ";
    135           *fLog << inf << "Taking previous position: ";
    136           *fLog << inf << "\tX\t" << setprecision(3) << x;
    137           *fLog << inf << "\tY\t" << setprecision(3) << y << endl;       
     153          *fLog << err << "MSrcPosFromFile::ComputeNewSrcPosition error: no value for the first run. Don't know what values to take" << endl;
     154          return kFALSE;
    138155        }
     156
     157      GetSrcPosCam()->SetXY(x,y);
     158     
     159      *fLog << inf << "\tX\t" << setprecision(3) << x;
     160      *fLog << inf << "\tY\t" << setprecision(3) << y << endl;     
    139161    }
    140162 
Note: See TracChangeset for help on using the changeset viewer.