CMS 3D CMS Logo

TotemTestGem Class Reference

Description: Manages Root file creation for Totem Tests. More...

#include <SimG4CMS/Forward/interface/TotemTestGem.h>

Inheritance diagram for TotemTestGem:

SimProducer Observer< const BeginOfEvent * > Observer< const EndOfEvent * > SimWatcher

List of all members.

Public Member Functions

virtual void produce (edm::Event &, const edm::EventSetup &)
 TotemTestGem (const edm::ParameterSet &p)
virtual ~TotemTestGem ()

Private Member Functions

void clear ()
void fillEvent (TotemTestHistoClass &)
void update (const EndOfEvent *evt)
 This routine will be called when the appropriate signal arrives.
void update (const BeginOfEvent *evt)
 This routine will be called when the appropriate signal arrives.

Private Attributes

int evtnum
std::vector< TotemG4Hit * > hits
std::vector< std::string > names


Detailed Description

Description: Manages Root file creation for Totem Tests.

Usage: Used in testing Totem simulation

Definition at line 41 of file TotemTestGem.h.


Constructor & Destructor Documentation

TotemTestGem::TotemTestGem ( const edm::ParameterSet p  ) 

Definition at line 39 of file TotemTestGem.cc.

References edm::ParameterSet::getParameter(), and names.

00039                                                    {
00040   
00041   edm::ParameterSet m_Anal = p.getParameter<edm::ParameterSet>("TotemTestGem");
00042   names        = m_Anal.getParameter<std::vector<std::string> >("Names");
00043  
00044   edm::LogInfo("ForwardSim") << "TotemTestGem:: Initialised as observer of "
00045                              << "begin of job, begin/end events and of G4step";
00046 }

TotemTestGem::~TotemTestGem (  )  [virtual]

Definition at line 48 of file TotemTestGem.cc.

00048                             {
00049 }


Member Function Documentation

void TotemTestGem::clear ( void   )  [private]

Definition at line 124 of file TotemTestGem.cc.

References evtnum, and hits.

Referenced by update().

00124                          {
00125 
00126   evtnum = 0;
00127   hits.clear();
00128 }

void TotemTestGem::fillEvent ( TotemTestHistoClass product  )  [private]

Definition at line 102 of file TotemTestGem.cc.

References evtnum, TotemTestHistoClass::fillHit(), TotemG4Hit::getEnergyLoss(), TotemG4Hit::getEntry(), TotemG4Hit::getPabs(), TotemG4Hit::getParentId(), TotemG4Hit::getParticleType(), TotemG4Hit::getTrackID(), TotemG4Hit::getUnitID(), TotemG4Hit::getVx(), TotemG4Hit::getVy(), TotemG4Hit::getVz(), hits, cmsScimarkStop::PID, TotemTestHistoClass::setEVT(), GeomDetEnumerators::TID, x, y, and z.

Referenced by produce().

00102                                                          {
00103 
00104   product.setEVT(evtnum);
00105   
00106   for (unsigned ihit = 0; ihit < hits.size(); ihit++) {
00107     TotemG4Hit* aHit = hits[ihit];
00108     int UID     = aHit->getUnitID();
00109     int Ptype   = aHit->getParticleType();
00110     int TID     = aHit->getTrackID();
00111     int PID     = aHit->getParentId();
00112     float ELoss = aHit->getEnergyLoss();
00113     float PABS  = aHit->getPabs();
00114     float x     = aHit->getEntry().x();
00115     float y     = aHit->getEntry().y();
00116     float z     = aHit->getEntry().z();
00117     float vx    = aHit->getVx();
00118     float vy    = aHit->getVy();
00119     float vz    = aHit->getVz();
00120     product.fillHit(UID, Ptype, TID, PID, ELoss, PABS, vx, vy, vz, x, y,z);
00121   }
00122 } 

void TotemTestGem::produce ( edm::Event e,
const edm::EventSetup  
) [virtual]

Implements SimProducer.

Definition at line 55 of file TotemTestGem.cc.

References fillEvent(), and edm::Event::put().

00055                                                             {
00056 
00057   std::auto_ptr<TotemTestHistoClass> product(new TotemTestHistoClass);
00058   fillEvent(*product);
00059   e.put(product);
00060 }

void TotemTestGem::update ( const EndOfEvent  )  [private, virtual]

This routine will be called when the appropriate signal arrives.

Implements Observer< const EndOfEvent * >.

Definition at line 70 of file TotemTestGem.cc.

References evtnum, hits, in, LogDebug, and names.

00070                                                 {  
00071 
00072   evtnum = (*evt)()->GetEventID();
00073   LogDebug("ForwardSim") << "TotemTestGem:: Fill event " << evtnum;
00074 
00075   // access to the G4 hit collections 
00076   G4HCofThisEvent* allHC = (*evt)()->GetHCofThisEvent();
00077   
00078   int nhit = 0;
00079   for (unsigned int in=0; in<names.size(); in++) {
00080     int HCid = G4SDManager::GetSDMpointer()->GetCollectionID(names[in]);
00081     TotemG4HitCollection* theHC = (TotemG4HitCollection*) allHC->GetHC(HCid);
00082     LogDebug("ForwardSim") << "TotemTestGem :: Hit Collection for " <<names[in]
00083                            << " of ID " << HCid << " is obtained at " << theHC;
00084 
00085     if (HCid >= 0 && theHC > 0) {
00086       int nentries = theHC->entries();
00087       LogDebug("ForwardSim") << "TotemTestGem :: " << names[in] << " with "
00088                              << nentries << " entries";
00089       for (int ihit = 0; ihit <nentries; ihit++) {
00090         TotemG4Hit* aHit = (*theHC)[ihit];
00091         hits.push_back(aHit);
00092       }
00093       nhit += nentries;
00094     }
00095   }
00096  
00097   // Writing the data to the Tree
00098   LogDebug("ForwardSim") << "TotemTestGem:: --- after fillTree with " << nhit
00099                          << " Hits";
00100 }

void TotemTestGem::update ( const BeginOfEvent  )  [private, virtual]

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfEvent * >.

Definition at line 62 of file TotemTestGem.cc.

References clear(), and LogDebug.

00062                                                   {
00063 
00064   int iev = (*evt)()->GetEventID();
00065   LogDebug("ForwardSim") << "TotemTestGem: Begin of event = " << iev;
00066   clear();
00067 
00068 }


Member Data Documentation

int TotemTestGem::evtnum [private]

Definition at line 64 of file TotemTestGem.h.

Referenced by clear(), fillEvent(), and update().

std::vector<TotemG4Hit*> TotemTestGem::hits [private]

Definition at line 65 of file TotemTestGem.h.

Referenced by clear(), fillEvent(), and update().

std::vector<std::string> TotemTestGem::names [private]

Definition at line 63 of file TotemTestGem.h.

Referenced by TotemTestGem(), and update().


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