Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

FluxAlg Class Reference

This is an Algorithm designed to get particle information from FluxSvc and put it onto the TDS for later retrieval. More...

#include <FluxAlg.h>

List of all members.

Public Methods

 FluxAlg (const std::string &name, ISvcLocator *pSvcLocator)
 ctor. More...

StatusCode initialize ()
 set parameters and attach to various perhaps useful services. More...

StatusCode execute ()
 process an event. More...

StatusCode finalize ()
 clean up, summarize. More...


Private Attributes

StringProperty m_source_name
IFluxSvcm_fluxSvc
IFluxm_flux
UnsignedIntegerProperty m_run
unsigned int m_sequence
IDataProviderSvc * m_eds
IParticlePropertySvc * m_partSvc


Detailed Description

This is an Algorithm designed to get particle information from FluxSvc and put it onto the TDS for later retrieval.

Author:
Toby Burnett
$Header $

Definition at line 26 of file FluxAlg.h.


Constructor & Destructor Documentation

FluxAlg::FluxAlg const std::string &    name,
ISvcLocator *    pSvcLocator
 

ctor.

Definition at line 39 of file FluxAlg.cxx.

00040 :Algorithm(name, pSvcLocator) , m_sequence(0)
00041 {
00042     // declare properties with setProperties calls
00043     declareProperty("source_name",  m_source_name="default");
00044     declareProperty("MCrun",        m_run=100);
00045     
00046 }


Member Function Documentation

StatusCode FluxAlg::execute  
 

process an event.

Definition at line 85 of file FluxAlg.cxx.

00086 {
00087     StatusCode  sc = StatusCode::SUCCESS;
00088     MsgStream   log( msgSvc(), name() );
00089     //
00090     // Purpose: have the flux service create parameters of an incoming particle 
00091     // if nothing has changed, then use the existing m_flux,
00092     // but if the "current" IFlux is not the same as the one we have now,
00093     // then change our m_flux pointer to be the new one.
00094     // Output:  a staturCode to ensure the function executed properly.
00095     
00096     if(m_fluxSvc->currentFlux() == m_flux){
00097         m_flux->generate();
00098     }else{
00099         m_flux = m_fluxSvc->currentFlux();
00100         m_flux->generate();
00101     }
00102     HepPoint3D p = m_flux->launchPoint();
00103     HepPoint3D d = m_flux->launchDir();
00104     double ke = m_flux->energy(); // kinetic energy in MeV
00105     std::string particleName = m_flux->particleName();
00106     //if it's a "timeTick, then ExposureAlg should take care of it, and no othe algorithms should care about it.
00107     if(particleName == "TimeTick"){
00108         log << MSG::DEBUG << particleName << " particle found, will exit particle creation/reconstruction loops" << endreq;
00109         particleName = "gamma"; 
00110         setFilterPassed( false );//no need to return - we want the time record on the TDS.  the ExposureAlg will handle the rest.
00111     }
00112     
00113     
00114     //here's where we get the particleID and mass for later.
00115     if( particleName=="p") particleName="proton";
00116     ParticleProperty* prop = m_partSvc->find(particleName);
00117     
00118     if( prop==0) {
00119         log << MSG::ERROR << "Particle name " << particleName << " not found by particle properties" << endreq;
00120         return StatusCode::FAILURE;
00121     }
00122     
00123     int partID = prop->jetsetID(); // same as stdhep id
00124     
00125     log << MSG::DEBUG << particleName
00126         << "(" << m_flux->energy()
00127         << " MeV), Launch: " 
00128         << "(" << p.x() <<", "<< p.y() <<", "<<p.z()<<")" 
00129         << " mm, Dir " 
00130         << "(" << d.x() <<", "<< d.y() <<", "<<d.z()<<")" 
00131         << endreq;
00132     
00133     
00134     // Here the TDS is prepared to receive hits vectors
00135     // Check for the MC branch - it will be created if it is not available
00136     Event::MCEvent* mch = 0;
00137 
00138     SmartDataPtr<Event::MCEvent> mcheader(eventSvc(), EventModel::MC::Event);
00139     if (mcheader == 0) {
00140         sc=eventSvc()->registerObject(EventModel::MC::Event , mch= new Event::MCEvent);
00141         if(sc.isFailure()) {
00142             log << MSG::WARNING << EventModel::MC::Event  <<" could not be registered on data store" << endreq;
00143             return sc;
00144         }
00145         
00146     }else mch = mcheader;
00147 
00148 
00149     mch->initialize(mch->getRunNumber(), m_flux->numSource(), mch->getSequence());
00150 
00151 
00152     
00153     Event::McParticleCol* pcol = new Event::McParticleCol;
00154     sc = eventSvc()->registerObject(EventModel::MC::McParticleCol, pcol);
00155     if( sc.isFailure()) {
00156         
00157         log << MSG::ERROR << "Could not Register "<< EventModel::MC::McParticleCol << endreq;
00158         
00159         return sc;
00160     }
00161     Event::McParticle * parent= new Event::McParticle;
00162     pcol->push_back(parent);
00163     
00164     double mass = prop->mass() , 
00165         energy = (ke+mass),
00166         momentum=sqrt(energy*energy - mass*mass); 
00167     HepLorentzVector pin(d*momentum,energy);
00168     
00169     // This parent particle decay at the start in the first particle, 
00170     // so initial momentum and final one are the same
00171     parent->initialize(parent, partID, 
00172         Event::McParticle::PRIMARY,
00173         pin,p);
00174     parent->finalize(pin, p);
00175     
00176     // get the event header to set the time
00177     Event::EventHeader* h = 0; 
00178 
00179     SmartDataPtr<Event::EventHeader> header(eventSvc(), EventModel::EventHeader);
00180     if(0==header) {
00181         // not already there: try to register instead
00182         sc = eventSvc()->registerObject(EventModel::EventHeader, h=new Event::EventHeader);
00183         if( sc.isFailure()) {
00184             log << MSG::WARNING << " could not find or register the event header" << endreq;
00185         }
00186     } else  h = header;
00187 
00188     h->setTime(m_flux->time());
00189     return StatusCode::SUCCESS;
00190 }

StatusCode FluxAlg::finalize  
 

clean up, summarize.

Definition at line 194 of file FluxAlg.cxx.

00194                             {
00195     StatusCode  sc = StatusCode::SUCCESS;
00196     MsgStream log(msgSvc(), name());
00197     
00198     return sc;
00199 }

StatusCode FluxAlg::initialize  
 

set parameters and attach to various perhaps useful services.

Definition at line 49 of file FluxAlg.cxx.

00049                               {
00050     StatusCode  sc = StatusCode::SUCCESS;
00051     MsgStream log(msgSvc(), name());
00052     log << MSG::INFO << "initialize" << endreq;
00053     
00054     // Use the Job options service to set the Algorithm's parameters
00055     setProperties();
00056     
00057     if ( service("FluxSvc", m_fluxSvc).isFailure() ){
00058         log << MSG::ERROR << "Couldn't find the FluxSvc!" << endreq;
00059         return StatusCode::FAILURE;
00060     }
00061     
00062     log << MSG::INFO << "loading source..." << endreq;
00063     
00064     sc =  m_fluxSvc->source(m_source_name, m_flux);
00065     if( sc.isFailure()) {
00066         log << MSG::ERROR << "Could not find flux " << m_source_name << endreq;
00067         return sc;
00068     }
00069     log << MSG::INFO << "Source: "<< m_flux->title() << endreq;
00070     
00071     log << MSG::INFO << "Source title: " << m_flux->title() << endreq;
00072     log << MSG::INFO << "        area: " << m_flux->targetArea() << endreq;
00073     log << MSG::INFO << "        rate: " << m_flux->rate() << endreq;
00074     
00075     if ( service("ParticlePropertySvc", m_partSvc).isFailure() ){
00076         log << MSG::ERROR << "Couldn't find the ParticlePropertySvc!" << endreq;
00077         return StatusCode::FAILURE;
00078     }
00079     return sc;
00080 }


Member Data Documentation

IDataProviderSvc* FluxAlg::m_eds [private]
 

Definition at line 47 of file FluxAlg.h.

IFlux* FluxAlg::m_flux [private]
 

Definition at line 40 of file FluxAlg.h.

IFluxSvc* FluxAlg::m_fluxSvc [private]
 

Definition at line 39 of file FluxAlg.h.

IParticlePropertySvc* FluxAlg::m_partSvc [private]
 

Definition at line 49 of file FluxAlg.h.

UnsignedIntegerProperty FluxAlg::m_run [private]
 

Definition at line 43 of file FluxAlg.h.

unsigned int FluxAlg::m_sequence [private]
 

Definition at line 44 of file FluxAlg.h.

StringProperty FluxAlg::m_source_name [private]
 

Definition at line 37 of file FluxAlg.h.


The documentation for this class was generated from the following files:
Generated on Wed Oct 16 14:01:33 2002 by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001