Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

MCPrintSIO Class Reference

#include <MCPrintSIO.h>

Inheritance diagram for MCPrintSIO:

Inheritance graph
[legend]
Collaboration diagram for MCPrintSIO:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 MCPrintSIO (const char *i_name)
 MCPrintSIO (const char *i_name, MCParticleSIO *particle)
void set (MCParticleSIO *particle)
unsigned int version ()
unsigned int xfer (SIO_stream *, SIO_operation, unsigned int)

Private Member Functions

unsigned int xfer_recurse (SIO_stream *stream, SIO_operation op, unsigned int version, const MCParticleSIO *particle)
int particleCnt (const MCParticleSIO *MCP) const

Private Attributes

MCParticleSIO_particle

Constructor & Destructor Documentation

MCPrintSIO::MCPrintSIO const char *  i_name  ) 
 

Definition at line 34 of file MCPrintSIO.cc.

References SIO_record::connect(), and SIO_recordManager::get().

00035   : SIO_block( i_name )
00036 {
00037 
00038   //
00039   // Local variables.
00040   //
00041   SIO_record* record;
00042 
00043   //
00044   // Join the event record.
00045   //
00046   record = SIO_recordManager::get( "LCD_LCDG4_Event" );
00047   if( record != NULL )
00048     record->connect( this );
00049 
00050 }

MCPrintSIO::MCPrintSIO const char *  i_name,
MCParticleSIO particle
 

Definition at line 52 of file MCPrintSIO.cc.

References SIO_record::connect(), and SIO_recordManager::get().

00053   : SIO_block( i_name ), _particle(particle)
00054 {
00055 
00056   //
00057   // Local variables.
00058   //
00059   SIO_record* record;
00060 
00061   //
00062   // Join the event record.
00063   //
00064   record = SIO_recordManager::get( "LCD_LCDG4_Event" );
00065   if( record != NULL )
00066     record->connect( this );
00067 
00068 }


Member Function Documentation

int MCPrintSIO::particleCnt const MCParticleSIO MCP  )  const [private]
 

Definition at line 79 of file MCPrintSIO.cc.

References MCParticleSIO::child(), and MCParticleSIO::numChildren().

00080 {
00081   //      printf("MCPid=%i MCPpx=%f\n",MCP->id(),MCP->px());
00082   int count = 0;
00083 
00084   for( int i=0; i < MCP->numChildren(); ++i )
00085     {
00086       //  printf("i=%i ",i);
00087       const MCParticleSIO* kid = MCP->child(i);
00088 
00089       // count each primary ...
00090       count++;
00091       //    printf(" count=%i\n",count);
00092 
00093       // and count recursively all daughters of each primary
00094 //    if ( kid->status() != MCParticleSIO::SHOWER) count += particleCnt(kid);
00095       count += particleCnt(kid);
00096       //        printf(" count=%\n",count);
00097     }
00098 
00099   //
00100   // That's all folks!
00101   //
00102   return count;
00103 }

void MCPrintSIO::set MCParticleSIO particle  ) 
 

Definition at line 70 of file MCPrintSIO.cc.

References _particle.

Referenced by LCDG4EventAction::EndOfEventAction().

00071 {
00072   _particle = particle;
00073 }

unsigned int MCPrintSIO::version  )  [virtual]
 

Implements SIO_block.

Definition at line 266 of file MCPrintSIO.cc.

References SIO_MCPRINT_MAJOR, SIO_MCPRINT_MINOR, and SIO_VERSION_ENCODE.

00267 { return( SIO_VERSION_ENCODE( SIO_MCPRINT_MAJOR,
00268                               SIO_MCPRINT_MINOR ) ); }

unsigned int MCPrintSIO::xfer SIO_stream ,
SIO_operation  ,
unsigned  int
[virtual]
 

Implements SIO_block.

Definition at line 109 of file MCPrintSIO.cc.

References cm, GeV, SIO_BLOCK_SUCCESS, SIO_DATA, SIO_operation, and SIO_PTAG.

00114 {
00115   double   d_vec[3];
00116   float    charge;
00117   int    temp;
00118 
00119   unsigned int    status;
00120 
00121   //
00122   // Count the number of children of the generator. All but the first SHOWER
00123   // particle are excluded. Note that the numkid counter starts at 1 to include
00124   // the PRIMARY particle.
00125   //
00126 
00127   // save total number of particles
00128   temp = particleCnt( _particle ) + 1;
00129   SIO_DATA( stream, &temp,     1 ); // # kids
00130 
00131   // save pointer as a tag
00132   SIO_PTAG( stream,  _particle         ); // Pntr tag
00133   // No parent
00134   temp     = 0;                   SIO_DATA( stream, &temp,     1 );
00135   // PDG id
00136   temp     = _particle->id();       SIO_DATA( stream, &temp,     1 );
00137   // status code (100*gen + geant4)
00138   temp     = _particle->status();       SIO_DATA( stream, &temp,     1 );
00139   // Charge
00140   charge   = _particle->charge();       SIO_DATA( stream, &charge,   1 );
00141   // ending position
00142   d_vec[0] = _particle->x()/cm;
00143   d_vec[1] = _particle->y()/cm;
00144   d_vec[2] = _particle->z()/cm;  SIO_DATA( stream, &d_vec[0], 3 );
00145   // momentum
00146   d_vec[0] = _particle->px()/GeV;
00147   d_vec[1] = _particle->py()/GeV;
00148   d_vec[2] = _particle->pz()/GeV; SIO_DATA( stream, &d_vec[0], 3 );
00149   // energy
00150   d_vec[0] = _particle->energy()/GeV; SIO_DATA( stream, &d_vec[0], 1 );
00151 
00152   // entrance point at calorimeter
00153   d_vec[0] = _particle->calX()/cm;
00154   d_vec[1] = _particle->calY()/cm;
00155   d_vec[2] = _particle->calZ()/cm;
00156   SIO_DATA( stream, d_vec, 3 );
00157 
00158   // another array for momentum at calorimeter entrance point
00159   d_vec[0] = _particle->calPX()/GeV;
00160   d_vec[1] = _particle->calPY()/GeV;
00161   d_vec[2] = _particle->calPZ()/GeV;
00162   SIO_DATA( stream, d_vec, 3 );
00163 
00164   //-----------------------------------------------------------------------
00165 
00166   //
00167   // Now output all the children
00168   //
00169   xfer_recurse( stream, op, version, (MCParticleSIO*)(_particle) );
00170 
00171   //
00172   // That's all folks!
00173   //
00174   return( SIO_BLOCK_SUCCESS );
00175 }

unsigned int MCPrintSIO::xfer_recurse SIO_stream stream,
SIO_operation  op,
unsigned int  version,
const MCParticleSIO particle
[private]
 

Definition at line 182 of file MCPrintSIO.cc.

References MCParticleSIO::calPX(), MCParticleSIO::calPY(), MCParticleSIO::calPZ(), MCParticleSIO::calX(), MCParticleSIO::calY(), MCParticleSIO::calZ(), MCParticleSIO::charge(), MCParticleSIO::child(), cm, MCParticleSIO::energy(), MCParticleSIO::getfsflag(), GeV, MCParticleSIO::id(), MCParticleSIO::parent(), MCParticleSIO::px(), MCParticleSIO::py(), MCParticleSIO::pz(), SIO_BLOCK_SUCCESS, SIO_DATA, SIO_operation, SIO_PNTR, SIO_PTAG, MCParticleSIO::status(), MCParticleSIO::x(), MCParticleSIO::y(), and MCParticleSIO::z().

00188 {
00189   //
00190   // Local variables
00191   //
00192   const MCParticleSIO *parent, *kid;
00193   double d_vec[3];
00194   float charge;
00195   int i, temp;
00196   unsigned int status;
00197 
00198   //  printf("got here G, numChi=%i\n",MCP->numChildren());
00199   for( i = 0; i < MCP->numChildren(); i++ ) {
00200     kid = MCP->child(i);
00201 //     double cal_pos[] = {0, 0, 0};
00202 //     double cal_drc[] = {0, 0, 0};
00203 
00204     //    MCentryMap::iterator mcit = m_EMCalSystem->entry()->find( kid );
00205     //    if ( mcit != m_EMCalSystem->entry()->end() ) {
00206     //        cal_pos = mcit->second.pos();
00207     //        cal_drc = mcit->second.drc();
00208     //    }
00209 
00210     // save pointer as a tag
00211     SIO_PTAG( stream,  kid );
00212     // point to parent
00213     parent   = kid->parent();     SIO_PNTR( stream, &parent    );
00214     // PDG id
00215     temp     = kid->id();         SIO_DATA( stream, &temp,   1 );
00216     // status code (100*gen + geant4)
00217     temp     = kid->status() + kid->getfsflag();
00218     SIO_DATA( stream, &temp,   1 );
00219     // charge
00220     charge   = kid->charge();   SIO_DATA( stream, &charge, 1 );
00221 
00222     // save ending point only.  starting point is ending point of parent
00223     // (doesn't work for EM secondaries produced before calorimeters,
00224     // because their starting point is not currently saved anywhere... )
00225     d_vec[0] = kid->x()/cm;
00226     d_vec[1] = kid->y()/cm;
00227     d_vec[2] = kid->z()/cm; SIO_DATA( stream, &d_vec[0], 3 );
00228     // momentum at production
00229     d_vec[0] = kid->px()/GeV;
00230     d_vec[1] = kid->py()/GeV;
00231     d_vec[2] = kid->pz()/GeV; SIO_DATA( stream, &d_vec[0], 3 ); // momentum
00232     // energy
00233     d_vec[0] = kid->energy()/GeV;   SIO_DATA( stream, &d_vec[0], 1 );
00234 
00235     // position entering calorimeter
00236     d_vec[0] = kid->calX()/cm;
00237     d_vec[1] = kid->calY()/cm;
00238     d_vec[2] = kid->calZ()/cm;  SIO_DATA( stream, &d_vec[0], 3 );
00239 
00240     // momentum entering calorimeter (I think)
00241     d_vec[0] = kid->calPX()/GeV;
00242     d_vec[1] = kid->calPY()/GeV;
00243     d_vec[2] = kid->calPZ()/GeV;  SIO_DATA( stream, &d_vec[0], 3 );
00244 
00245     //
00246     // Recurse to children of children...
00247     //
00248 //    if ( kid->status() != MCParticleSIO::SHOWER ) {
00249       xfer_recurse( stream, op, version, kid );
00250 //    }
00251   }
00252 
00253   //
00254   // That's all folks!
00255   //
00256   return( SIO_BLOCK_SUCCESS );
00257 }


Member Data Documentation

MCParticleSIO* MCPrintSIO::_particle [private]
 

Definition at line 42 of file MCPrintSIO.h.

Referenced by set().


The documentation for this class was generated from the following files:
Generated on Thu Oct 7 18:45:09 2004 for LCDG4 by doxygen 1.3.4