Changeset 5052 for trunk/MagicSoft


Ignore:
Timestamp:
09/15/04 23:18:04 (20 years ago)
Author:
gaug
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mbadpixels/MBadPixelsIntensityCam.cc

    r5016 r5052  
    4343#include "MBadPixelsIntensityCam.h"
    4444
    45 #include <TClonesArray.h>
     45#include <TOrdCollection.h>
    4646
    4747#include "MGeomCam.h"
     
    6464  fTitle = title ? title : "Base container for the Intensity Calibration";
    6565 
    66   fCams = new TObjArray;
     66  fCams = new TOrdCollection;
    6767  fCams->SetOwner();
    6868
     
    139139// -------------------------------------------------------------------
    140140//
    141 // Calls TClonesArray::ExpandCreate() for fCams
    142 //
    143 void MBadPixelsIntensityCam::InitSize(const UInt_t n)
    144 {
    145 
    146   fCams->Expand(n);
    147 
    148   for (Int_t i=0; i<fCams->GetSize(); i++)
    149     (*fCams)[i] = new MBadPixelsCam;
    150 }
     141// Initialize the objects inside the TOrdCollection using the
     142// function Add().
     143//
     144// InitSize can only increase the size, but not shrink.
     145//
     146// It can be called more than one time. New Containers are
     147// added only from the current size to the argument i.
     148//
     149void MBadPixelsIntensityCam::InitSize(const UInt_t i)
     150{
     151
     152  const UInt_t save = GetSize();
     153
     154  if (i==save)
     155    return;
     156 
     157  if (i>save)
     158    Add(save,i);
     159}
     160
     161// -------------------------------------------------------------------
     162//
     163// Add MBadPixelsCams in the ranges from - to. In order to initialize
     164// from MBadPixelsCam derived containers, overwrite this function
     165//
     166void MBadPixelsIntensityCam::Add(const UInt_t from, const UInt_t to)
     167{
     168  for (UInt_t i=from; i<to; i++)
     169    fCams->AddAt(new MBadPixelsCam,i);
     170}
     171
    151172
    152173// -------------------------------------------------------------------
     
    166187// --------------------------------------------------------------------------
    167188//
    168 // Returns the current size of the TClonesArray fCams
     189// Returns the current size of the TOrdCollection fCams
    169190// independently if the MBadPixelsCam is filled with values or not.
    170191//
    171192Int_t MBadPixelsIntensityCam::GetSize() const
    172193{
    173   return fCams->GetEntries();
     194  return fCams->GetSize();
    174195}
    175196
     
    180201MBadPixelsPix &MBadPixelsIntensityCam::operator[](Int_t i)
    181202{
    182   return (*GetCam(GetSize()-1))[i];
     203  return (*GetCam())[i];
    183204}
    184205
     
    189210const MBadPixelsPix &MBadPixelsIntensityCam::operator[](Int_t i) const
    190211{
    191   return (*GetCam(GetSize()-1))[i];
     212  return (*GetCam())[i];
    192213}
    193214
     
    199220MBadPixelsCam *MBadPixelsIntensityCam::GetCam(Int_t i)
    200221{
    201   return static_cast<MBadPixelsCam*>(fCams->UncheckedAt(i==-1 ? GetSize()-1 : i));
     222  return static_cast<MBadPixelsCam*>(i==-1 ? fCams->Last() : fCams->At(i));
    202223}
    203224
     
    208229const MBadPixelsCam *MBadPixelsIntensityCam::GetCam(Int_t i) const
    209230{
    210   return static_cast<MBadPixelsCam*>(fCams->UncheckedAt(i==-1 ? GetSize()-1 : i));
     231  return static_cast<MBadPixelsCam*>(i==-1 ? fCams->Last() : fCams->At(i));
    211232}
    212233
  • trunk/MagicSoft/Mars/mbadpixels/MBadPixelsIntensityCam.h

    r5013 r5052  
    1212#endif
    1313
    14 class TObjArray;
     14class TOrdCollection;
    1515class MGeomCam;
    1616class MBadPixelsIntensityCam : public MParContainer, public MCamEvent
    1717{
    1818private:
     19
     20  TOrdCollection *fCams;        //-> Array of MBadPixelsCams, one per pulse colour and intensity
     21
     22  void Add(const UInt_t from, const UInt_t to);
    1923 
    20   void InitSize( const UInt_t n );
    21  
    22 protected: 
    23 
    24   TObjArray *fCams;        //-> Array of MBadPixelsCams, one per pulse colour and intensity
    25 
    2624public:
    2725
     
    7068 
    7169  // Inits
    72   void  Init   ( const MGeomCam &geom );
     70  void Init   ( const MGeomCam &geom );
     71  void InitSize( const UInt_t i );
    7372
    7473  Bool_t GetPixelContent ( Double_t &val, Int_t idx, const MGeomCam &cam,Int_t type=0) const;
  • trunk/MagicSoft/Mars/mcalib/MCalibrationIntensityCam.cc

    r5046 r5052  
    359359MCalibrationCam *MCalibrationIntensityCam::GetCam(Int_t i)
    360360{
    361   return static_cast<MCalibrationCam*>(fCams->Last());
     361  return static_cast<MCalibrationCam*>(i==-1 ? fCams->Last() : fCams->At(i));
    362362}
    363363
     
    368368const MCalibrationCam *MCalibrationIntensityCam::GetCam(Int_t i) const
    369369{
    370   return static_cast<MCalibrationCam*>(fCams->Last());
     370  return static_cast<MCalibrationCam*>(i==-1 ? fCams->Last() : fCams->At(i));
    371371}
    372372
Note: See TracChangeset for help on using the changeset viewer.