CMS 3D CMS Logo

edm::TRandomAdaptor Class Reference

#include <IOMC/RandomEngine/src/TRandomAdaptor.h>

List of all members.

Public Member Functions

std::string beginTag ()
double flat ()
void flatArray (const int size, double *vect)
bool get (const std::vector< unsigned long > &v)
virtual std::istream & get (std::istream &is)
TRandom3 * getRootEngine ()
bool getState (const std::vector< unsigned long > &v)
virtual std::istream & getState (std::istream &is)
std::string name () const
 operator float ()
 operator unsigned int ()
TRandomAdaptoroperator= (const TRandomAdaptor &p)
std::vector< unsigned long > put () const
virtual std::ostream & put (std::ostream &os) const
void restoreStatus (const char filename[]="TRandom.conf")
void saveStatus (const char filename[]="TRandom.conf") const
void setSeed (long seed, int)
void setSeeds (const long *seeds, int)
void showStatus () const
 TRandomAdaptor (const TRandomAdaptor &p)
 TRandomAdaptor (std::istream &is)
 TRandomAdaptor (int rowIndex, int colIndex)
 TRandomAdaptor (long seed)
 TRandomAdaptor ()
virtual ~TRandomAdaptor ()

Static Public Member Functions

static std::string engineName ()

Private Member Functions

void Grumble (std::string errortext) const

Private Attributes

TRandom3 * trand_


Detailed Description

Definition at line 15 of file TRandomAdaptor.h.


Constructor & Destructor Documentation

edm::TRandomAdaptor::TRandomAdaptor (  )  [inline]

Definition at line 20 of file TRandomAdaptor.h.

00020 : trand_(new TRandom3()) {}

edm::TRandomAdaptor::TRandomAdaptor ( long  seed  )  [inline]

Definition at line 21 of file TRandomAdaptor.h.

00021 : trand_(new TRandom3(seed)) {}

edm::TRandomAdaptor::TRandomAdaptor ( int  rowIndex,
int  colIndex 
) [inline]

Definition at line 22 of file TRandomAdaptor.h.

00022 : trand_(new TRandom3(rowIndex*colIndex-1)) {}

edm::TRandomAdaptor::TRandomAdaptor ( std::istream &  is  ) 

Definition at line 24 of file TRandomAdaptor.cc.

References Grumble().

00026 {
00027   Grumble(std::string("Cannot instantiate a TRandom engine from an istream"));

virtual edm::TRandomAdaptor::~TRandomAdaptor (  )  [inline, virtual]

Definition at line 24 of file TRandomAdaptor.h.

References trand_.

00024 { delete trand_; }

edm::TRandomAdaptor::TRandomAdaptor ( const TRandomAdaptor p  )  [inline]

Definition at line 27 of file TRandomAdaptor.h.

References tmp, and trand_.

00027                                                { TRandom3* tmp = new TRandom3();
00028                                                                      *tmp = *(p.trand_);
00029                                                                      this->trand_ = tmp; }


Member Function Documentation

std::string edm::TRandomAdaptor::beginTag (  )  [inline]

Definition at line 66 of file TRandomAdaptor.h.

References trand_.

00066 { return std::string(trand_->GetName())+std::string("-begin"); }

static std::string edm::TRandomAdaptor::engineName (  )  [inline, static]

Definition at line 71 of file TRandomAdaptor.h.

00071 { return std::string("TRandomAdaptor"); }

double edm::TRandomAdaptor::flat (  )  [inline]

Definition at line 37 of file TRandomAdaptor.h.

References trand_.

00037 { return trand_->Rndm(); }

void edm::TRandomAdaptor::flatArray ( const int  size,
double *  vect 
) [inline]

Definition at line 40 of file TRandomAdaptor.h.

References trand_.

00040 { trand_->RndmArray(size,vect); }

bool edm::TRandomAdaptor::get ( const std::vector< unsigned long > &  v  ) 

Definition at line 59 of file TRandomAdaptor.cc.

References i, int, and trand_.

00060                                                             {
00061   if(v.empty())  return false;
00062   if(v[0] != CLHEP::engineIDulong<TRandomAdaptor>()) return false;
00063   int32_t numItems = v.size()-1;
00064   int32_t itemSize = sizeof(unsigned long);
00065   RootBuffer buffer(TBuffer::kRead,numItems*itemSize+1024);
00066   char* bufferPtr = buffer.Buffer();
00067   for(int i=0; i<(int)numItems; ++i) {
00068     *(unsigned long*)(bufferPtr+i*itemSize) = v[i+1];
00069   }
00070   trand_->Streamer(buffer);
00071   return true;

std::istream & edm::TRandomAdaptor::get ( std::istream &  is  )  [virtual]

Definition at line 49 of file TRandomAdaptor.cc.

References getState(), and Grumble().

00050                                                  {
00051   Grumble(std::string("get(std::istream) not available for TRandom engines"));
00052   return getState(is);

TRandom3* edm::TRandomAdaptor::getRootEngine (  )  [inline]

Definition at line 78 of file TRandomAdaptor.h.

References trand_.

00078 { return trand_; }

bool edm::TRandomAdaptor::getState ( const std::vector< unsigned long > &  v  )  [inline]

Definition at line 75 of file TRandomAdaptor.h.

00075 { return get(v); }

std::istream & edm::TRandomAdaptor::getState ( std::istream &  is  )  [virtual]

Definition at line 54 of file TRandomAdaptor.cc.

References Grumble().

Referenced by get().

00055                                                       {
00056   Grumble(std::string("getState(std::istream) not available for TRandom engines"));
00057   return is;

void edm::TRandomAdaptor::Grumble ( std::string  errortext  )  const [private]

Definition at line 73 of file TRandomAdaptor.cc.

References except, and edm::errors::UnimplementedFeature.

Referenced by get(), getState(), put(), and TRandomAdaptor().

00074                                                         {
00075 
00076 // Throw an edm::Exception for unimplemented functions
00077    std::ostringstream sstr;
00078    sstr << "Unimplemented Feature: " << errortext << '\n';
00079    edm::Exception except(edm::errors::UnimplementedFeature, sstr.str());
00080    throw except;

std::string edm::TRandomAdaptor::name ( void   )  const [inline]

Definition at line 70 of file TRandomAdaptor.h.

References trand_.

00070 { return std::string("T")+std::string(trand_->GetName()); }

edm::TRandomAdaptor::operator float (  )  [inline]

Definition at line 59 of file TRandomAdaptor.h.

References trand_.

00059 { return (float)(trand_->Rndm()); }

edm::TRandomAdaptor::operator unsigned int (  )  [inline]

Definition at line 62 of file TRandomAdaptor.h.

References trand_.

00062 { return (unsigned int)((trand_->Rndm())*exponent_bit_32); }

TRandomAdaptor& edm::TRandomAdaptor::operator= ( const TRandomAdaptor p  )  [inline]

Definition at line 31 of file TRandomAdaptor.h.

References tmp, and trand_.

00031                                                            { TRandom3* tmp = new TRandom3();
00032                                                                      *tmp = *(p.trand_);
00033                                                                      this->trand_ = tmp;
00034                                                                      return *this; }

std::vector< unsigned long > edm::TRandomAdaptor::put (  )  const

Definition at line 34 of file TRandomAdaptor.cc.

References i, int, trand_, and v.

00035                                                     {
00036   int32_t itemSize = sizeof(unsigned long);
00037   std::vector<unsigned long> v;
00038   v.push_back (CLHEP::engineIDulong<TRandomAdaptor>());
00039   RootBuffer buffer(TBuffer::kWrite,1024*itemSize);
00040   trand_->Streamer(buffer);
00041   buffer.SetReadMode();
00042   char* bufferPtr = buffer.Buffer();
00043   int32_t numItems = (buffer.Length()+itemSize-1)/itemSize;
00044   for( int i=0; i<(int)numItems; ++i)  {
00045     v.push_back(*(unsigned long*)(bufferPtr+i*itemSize));
00046   }
00047   return v;

std::ostream & edm::TRandomAdaptor::put ( std::ostream &  os  )  const [virtual]

Definition at line 29 of file TRandomAdaptor.cc.

References Grumble().

00030                                                       {
00031   Grumble(std::string("put(std::ostream) not available for TRandom engines"));
00032   return os;

void edm::TRandomAdaptor::restoreStatus ( const char  filename[] = "TRandom.conf"  )  [inline]

Definition at line 53 of file TRandomAdaptor.h.

References EgammaValidation_cff::filename, and trand_.

00053 { trand_->ReadRandom(filename); }

void edm::TRandomAdaptor::saveStatus ( const char  filename[] = "TRandom.conf"  )  const [inline]

Definition at line 50 of file TRandomAdaptor.h.

References EgammaValidation_cff::filename, and trand_.

00050 { trand_->WriteRandom(filename); }

void edm::TRandomAdaptor::setSeed ( long  seed,
int   
) [inline]

Definition at line 43 of file TRandomAdaptor.h.

References trand_.

00043 { trand_->SetSeed(seed); }

void edm::TRandomAdaptor::setSeeds ( const long *  seeds,
int   
) [inline]

Definition at line 47 of file TRandomAdaptor.h.

References trand_.

00047 { trand_->SetSeed(seeds[0]); }

void edm::TRandomAdaptor::showStatus (  )  const [inline]

Definition at line 56 of file TRandomAdaptor.h.

References trand_.

00056 { trand_->Dump(); }


Member Data Documentation

TRandom3* edm::TRandomAdaptor::trand_ [private]

Definition at line 84 of file TRandomAdaptor.h.

Referenced by beginTag(), flat(), flatArray(), get(), getRootEngine(), name(), operator float(), operator unsigned int(), operator=(), put(), restoreStatus(), saveStatus(), setSeed(), setSeeds(), showStatus(), TRandomAdaptor(), and ~TRandomAdaptor().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:44:25 2009 for CMSSW by  doxygen 1.5.4