NCFS-Pack
A generic (astro)particle physics analysis framework
 
Loading...
Searching...
No Matches
NcObjMatrix Class Reference

Handling of a matrix structure of objects. More...

#include "NcObjMatrix.h"

Inheritance diagram for NcObjMatrix:

Detailed Description

Handling of a matrix structure of objects.


Copyright(c) 2003 NCFS/IIHE, All Rights Reserved. *
*
Authors: The Netherlands Center for Fundamental Studies (NCFS). *
The Inter-university Institute for High Energies (IIHE). *
Website : http://www.iihe.ac.be *
Contact : Nick van Eijndhoven (nickve.nl@gmail.com) *
*
Contributors are mentioned in the code where appropriate. *
*
No part of this software may be used, copied, modified or distributed *
by any means nor transmitted or translated into machine language for *
commercial purposes without written permission by the IIHE representative. *
Permission to use the software strictly for non-commercial purposes *
is hereby granted without fee, provided that the above copyright notice *
appears in all copies and that both the copyright notice and this *
permission notice appear in the supporting documentation. *
This software is provided "as is" without express or implied warranty. *
The authors make no claims that this software is free of error, or is *
consistent with any particular standard of merchantability, or that it *
will meet your requirements for any particular application, other than *
indicated in the corresponding documentation. *
This software should not be relied on for solving a problem whose *
incorrect solution could result in injury to a person or loss of property. *
If you do use this software in such a manner, it is at your own risk. *
The authors disclaim all liability for direct or consequential damage *
resulting from your use of this software. *

// Class NcObjMatrix
// Handling of a matrix structure of objects.
// All objects which are derived from TObject may be entered into the matrix
// structure. This means that also TObjArray objects can be entered,
// which implies an increase of the dimension of the resulting structure.
//
// Example :
// =========
//
// NcObjMatrix* matrix=new NcObjMatrix();
// matrix->SetOwner();
// matrix->SetSwapMode();
//
// Float_t pos[3];
//
// NcSignal* s=0;
//
// s=new NcSignal();
// s->SetSignal(135);
// pos[0]=-120.4
// pos[1]=78.25
// pos[3]=12.93
// s->SetPosition(pos,"car");
// matrix->EnterObject(6,21,s);
//
// s=new NcSignal();
// s->SetSignal(25.84);
// pos[0]=68.7
// pos[1]=-53.88
// pos[3]=22.69
// s->SetPosition(pos,"car");
// matrix->EnterObject(8,13,s);
//
// s=new NcSignal();
// s->SetSignal(87.25);
// pos[0]=154.8
// pos[1]=932.576
// pos[3]=-1382.754
// s->SetPosition(pos,"car");
// matrix->EnterObject(64,3,s);
//
// Int_t nrows=matrix->GetMaxRow();
// Int_t ncols=matrix->GetMaxColumn();
//
// cout << " Maxrow : " << nrows << " Maxcol : " << ncols
// << " Nobjects : " << matrix->GetNobjects() << endl;
//
// for (Int_t i=1; i<=nrows; i++)
// {
// for (Int_t j=1; j<=ncols; j++)
// {
// s=(NcSignal*)matrix->GetObject(i,j);
// if (s) cout << " At (" << i << "," << j << ") Signal : " << s->GetSignal() << endl;
// }
// }
//
//--- Author: Nick van Eijndhoven 23-jan-2003 Utrecht University
//- Modified: NvE $Date: 2010-03-19 11:10:02 +0100 (Fri, 19 Mar 2010) $ NCFS

Definition at line 12 of file NcObjMatrix.h.

Public Member Functions

 NcObjMatrix ()
 
 NcObjMatrix (const NcObjMatrix &m)
 
virtual ~NcObjMatrix ()
 
virtual TObject * Clone (const char *name="") const
 
virtual void EnterObject (Int_t row, Int_t col, TObject *obj)
 
Int_t GetIndices (TObject *obj, Int_t row, TArrayI &cols) const
 
Int_t GetIndices (TObject *obj, TArrayI &rows, Int_t col) const
 
Int_t GetIndices (TObject *obj, TArrayI &rows, TArrayI &cols) const
 
virtual Int_t GetMaxColumn () const
 
virtual Int_t GetMaxRow () const
 
virtual Int_t GetNobjects () const
 
Int_t GetNrefs (TObject *obj) const
 
virtual TObject * GetObject (Int_t j) const
 
virtual TObject * GetObject (Int_t row, Int_t col) const
 
virtual TObjArray * GetObjects ()
 
virtual Int_t GetOwner () const
 
virtual Int_t GetSwapMode () const
 
void RemoveObject (Int_t row, Int_t col)
 
void RemoveObjects (TObject *obj, Int_t row=0, Int_t col=0)
 
virtual void Reset ()
 
virtual void SetOwner (Int_t own=1)
 
virtual void SetSwapMode (Int_t swap=1)
 

Protected Attributes

Int_t fMaxcol
 
Int_t fMaxrow
 
TObjArray * fObjects
 
Int_t fOwn
 
TObjArray * fRows
 
Int_t fSwap
 

Constructor & Destructor Documentation

◆ NcObjMatrix() [1/2]

NcObjMatrix::NcObjMatrix ( )
// Default constructor.
// Note : The owner and swap mode flags will be initialised to 0.
// See the memberfunctions SetOwner() and SetSwapMode() for further
// details.

Definition at line 103 of file NcObjMatrix.cxx.

◆ ~NcObjMatrix()

NcObjMatrix::~NcObjMatrix ( )
virtual
// Default destructor.

Definition at line 122 of file NcObjMatrix.cxx.

◆ NcObjMatrix() [2/2]

NcObjMatrix::NcObjMatrix ( const NcObjMatrix & m)
// Copy constructor.

Definition at line 142 of file NcObjMatrix.cxx.

Member Function Documentation

◆ Clone()

TObject * NcObjMatrix::Clone ( const char * name = "") const
virtual
// Make a deep copy of the current object and provide the pointer to the copy.
// This memberfunction enables automatic creation of new objects of the
// correct type depending on the object type, a feature which may be very useful
// for containers when adding objects in case the container owns the objects.

Definition at line 880 of file NcObjMatrix.cxx.

◆ EnterObject()

void NcObjMatrix::EnterObject ( Int_t row,
Int_t col,
TObject * obj )
virtual
// Enter an object to the matrix structure at location (row,col).
// In case the location already contained an object, the existing object
// will first be removed before the new object is stored.
// According to the status of the owner flag (see the SetOwner() function)
// the existing object will also be deleted.
// Note : The first location in the matrix is indicated as (1,1).

Definition at line 288 of file NcObjMatrix.cxx.

◆ GetIndices() [1/3]

Int_t NcObjMatrix::GetIndices ( TObject * obj,
Int_t row,
TArrayI & cols ) const
// Provide the column indices of all the storage locations of the
// specified object in the specified row of the matrix.
// The column indices are returned in the TArrayI array.
// The integer return argument represents the number of storage locations which
// were encountered for the specified object in the specified matrix row.
//
// If obj=0 no object selection is performed and all column indices
// of the stored references for all objects in this specified matrix row
// are returned.
//
// If row=0 all rows will be scanned and all column indices matching the
// object selection are returned.
// Note that in this case multiple appearances of the same column index
// will only be recorded once in the returned TArrayI array.
//
// Notes :
// -------
// As usual the convention is that row and column numbering starts at 1.
//
// This memberfunction always resets the TArrayI array at the start.
//
// This memberfunction can only be used to obtain the column indices
// of the object as stored via the EnterObject() memberfunction.
// This means that in case the user has entered a TObjArray as object
// (to increase the dimension of the resulting structure), the column
// indices of that TObjArray are obtained and NOT the indices of the
// actual objects contained in that TObjArray structure.

Definition at line 670 of file NcObjMatrix.cxx.

◆ GetIndices() [2/3]

Int_t NcObjMatrix::GetIndices ( TObject * obj,
TArrayI & rows,
Int_t col ) const
// Provide the row indices of all the storage locations of the
// specified object in the specified column of the matrix.
// The row indices are returned in the TArrayI array.
// The integer return argument represents the number of storage locations which
// were encountered for the specified object in the specified matrix column.
//
// If obj=0 no object selection is performed and all row indices
// of the stored references for all objects in this specified matrix column
// are returned.
//
// If col=0 all columns will be scanned and all row indices matching the
// object selection are returned.
// Note that in this case multiple appearances of the same row index
// will only be recorded once in the returned TArrayI array.
//
// Notes :
// -------
// As usual the convention is that row and column numbering starts at 1.
//
// This memberfunction always resets the TArrayI array at the start.
//
// This memberfunction can only be used to obtain the row indices
// of the object as stored via the EnterObject() memberfunction.
// This means that in case the user has entered a TObjArray as object
// (to increase the dimension of the resulting structure), the row
// indices of that TObjArray are obtained and NOT the indices of the
// actual objects contained in that TObjArray structure.

Definition at line 775 of file NcObjMatrix.cxx.

◆ GetIndices() [3/3]

Int_t NcObjMatrix::GetIndices ( TObject * obj,
TArrayI & rows,
TArrayI & cols ) const
// Provide the (row,col) indices of all the storage locations of the
// specified object.
// The row and column indices are returned in the two separate TArrayI arrays
// from which the (row,col) pairs can be obtained from the corresponding
// array indices like (row,col)=(rows.At(j),cols.At(j)).
// The integer return argument represents the number of (row,col) pairs which
// were encountered for the specified object.
//
// If obj=0 no object selection is performed and all (row,col) indices
// of the stored references for all objects are returned.
//
// Notes :
// -------
// As usual the convention is that row and column numbering starts at 1.
//
// This memberfunction always resets the two TArrayI arrays at the start.
//
// This memberfunction can only be used to obtain the (row,col) indices
// of the object as stored via the EnterObject() memberfunction.
// This means that in case the user has entered a TObjArray as object
// (to increase the dimension of the resulting structure), the (row,col)
// indices of that TObjArray are obtained and NOT the indices of the
// actual objects contained in that TObjArray structure.

Definition at line 604 of file NcObjMatrix.cxx.

◆ GetMaxColumn()

Int_t NcObjMatrix::GetMaxColumn ( ) const
virtual
// Provide the maximum column number index.

Definition at line 557 of file NcObjMatrix.cxx.

◆ GetMaxRow()

Int_t NcObjMatrix::GetMaxRow ( ) const
virtual
// Provide the maximum row number index.

Definition at line 546 of file NcObjMatrix.cxx.

◆ GetNobjects()

Int_t NcObjMatrix::GetNobjects ( ) const
virtual
// Provide the number of stored objects.

Definition at line 568 of file NcObjMatrix.cxx.

◆ GetNrefs()

Int_t NcObjMatrix::GetNrefs ( TObject * obj) const
// Provide the number of stored references to the specified object.
// If obj=0 the total number of stored references for all objects is returned.

Definition at line 582 of file NcObjMatrix.cxx.

◆ GetObject() [1/2]

TObject * NcObjMatrix::GetObject ( Int_t j) const
virtual
// Provide a pointer to the j-th stored object.
// In case the index j is invalid, a value 0 will be returned.
// The first stored object is indicated as j=1.
//
// Note : Do NOT delete the object.
// To remove an object, the memberfunction RemoveObject() or
// RemoveObjects() should be used.

Definition at line 506 of file NcObjMatrix.cxx.

◆ GetObject() [2/2]

TObject * NcObjMatrix::GetObject ( Int_t row,
Int_t col ) const
virtual
// Provide a pointer to the object stored at the matrix location (row,col).
// In case no object was stored at the indicated location or the location
// would reside outside the matrix boundaries, a value 0 will be returned.
// Note : The first location in the matrix is indicated as (1,1).

Definition at line 475 of file NcObjMatrix.cxx.

◆ GetObjects()

TObjArray * NcObjMatrix::GetObjects ( )
virtual
// Provide references to all the stored objects.
// In case no objects are present, a value 0 will be returned.
//
// Note : Do NOT make any changes to the reference array apart from
// changing the order of the pointers of the various objects.
// For addition or removal of objects, the memberfunctions
// EnterObject(), RemoveObject() or RemoveObjects() should be used.

Definition at line 529 of file NcObjMatrix.cxx.

◆ GetOwner()

Int_t NcObjMatrix::GetOwner ( ) const
virtual
// Provide the owner flag for the stored objects.

Definition at line 238 of file NcObjMatrix.cxx.

◆ GetSwapMode()

Int_t NcObjMatrix::GetSwapMode ( ) const
virtual
// Provide the swap mode flag for this matrix.

Definition at line 277 of file NcObjMatrix.cxx.

◆ RemoveObject()

void NcObjMatrix::RemoveObject ( Int_t row,
Int_t col )
// Remove the object stored at the matrix location (row,col).
// In case the object was owned by the matrix, it will be deleted.
//
// Note : The first location in the matrix is indicated as (1,1).

Definition at line 354 of file NcObjMatrix.cxx.

◆ RemoveObjects()

void NcObjMatrix::RemoveObjects ( TObject * obj,
Int_t row = 0,
Int_t col = 0 )
// Remove object(s) from the matrix according to user specified selections.
// In case the object was owned by the matrix, it will be deleted.
//
// An object is only removed from the matrix if the stored reference matches
// the argument "obj".
// In case obj=0 no check on the matching of the stored reference is performed
// and the stored object is always removed in accordance with the other
// selection criteria.
//
// In case the argument "row" is specified, only the object references from
// that matrix row will be deleted.
// In case row=0 (default) no checking on the row index is performed.
//
// In case the argument "col" is specified, only the object references from
// that matrix column will be deleted.
// In case col=0 (default) no checking on the column index is performed.
//
// So, invokation of RemoveObjects(obj) will remove all references to the
// object "obj" from the total matrix, whereas RemoveObjects(obj,0,col)
// will remove all references to the object "obj" only from column "col".
//
// Notes :
// -------
// The first location in the matrix is indicated as (1,1).
//
// Invokation of RemoveObjects(0,row,col) is equivalent to invoking the
// memberfunction RemoveObject(row,col).
// Invoking the latter directly is slightly faster.
//
// Invokation of RemoveObjects(0) is equivalent to invoking Reset().
// Invoking the latter directly is slightly faster.

Definition at line 391 of file NcObjMatrix.cxx.

◆ Reset()

void NcObjMatrix::Reset ( )
virtual
// Reset the whole matrix structure.
// Note : The values of the owner and swap mode flags will not be modified.
// To modify the ownership, use the memberfunction SetOwner().
// To modify the swap mode, use the memberfunction SetSwapMode().

Definition at line 180 of file NcObjMatrix.cxx.

◆ SetOwner()

void NcObjMatrix::SetOwner ( Int_t own = 1)
virtual
// Set the owner flag (0/1) for the stored objects.
// When the owner flag is set to 1, all entered objects are owned by the
// matrix structure.
// At invokation of this memberfunction the default argument is own=1.

Definition at line 206 of file NcObjMatrix.cxx.

◆ SetSwapMode()

void NcObjMatrix::SetSwapMode ( Int_t swap = 1)
virtual
// Set the swap mode flag (0/1) for the internal matrix storage.
// In case the number of rows differs considerably from the number of columns,
// it might be more efficient (w.r.t. memory usage and/or output file size)
// to internally store the matrix with the rows and colums swapped.
// This swapping is only related with the internal storage and as such
// is completely hidden for the user.
// At invokation of this memberfunction the default argument is swap=1.
//
// Note : The swap mode can only be set as long as no objects have
// been stored in the matrix structure (i.e. a new instance
// of NcObjMatrix or after invokation of the Reset() function).

Definition at line 249 of file NcObjMatrix.cxx.

Member Data Documentation

◆ fMaxcol

Int_t NcObjMatrix::fMaxcol
protected

Definition at line 43 of file NcObjMatrix.h.

◆ fMaxrow

Int_t NcObjMatrix::fMaxrow
protected

Definition at line 42 of file NcObjMatrix.h.

◆ fObjects

TObjArray* NcObjMatrix::fObjects
protected

Definition at line 44 of file NcObjMatrix.h.

◆ fOwn

Int_t NcObjMatrix::fOwn
protected

Definition at line 40 of file NcObjMatrix.h.

◆ fRows

TObjArray* NcObjMatrix::fRows
protected

Definition at line 39 of file NcObjMatrix.h.

◆ fSwap

Int_t NcObjMatrix::fSwap
protected

Definition at line 41 of file NcObjMatrix.h.


The documentation for this class was generated from the following files: