/data3/calcul/jacquem/working_dir/Micromegas/micromegasFrameWork/lcio/src/cpp/src/IMPL/SimCalorimeterHitImpl.cc

Go to the documentation of this file.
00001 #include "IMPL/SimCalorimeterHitImpl.h"
00002 #include "UTIL/LCWarning.h"
00003 #include <iostream>
00004 
00005 namespace IMPL{
00006   
00007   SimCalorimeterHitImpl::SimCalorimeterHitImpl() :
00008     _cellID0(0),
00009     _cellID1(0),
00010     _energy(0){
00011     _position[0] = 0. ;
00012     _position[1] = 0. ;
00013     _position[2] = 0. ; 
00014   }
00015 
00016 //   // copy of the SimCalorimeterHit hit
00017   SimCalorimeterHitImpl::SimCalorimeterHitImpl(const SimCalorimeterHit& hit) :
00018     
00019     _cellID0( hit.getCellID0() ),
00020     _cellID1( hit.getCellID1() ),
00021     _energy( hit.getEnergy() ) {
00022     
00023     const float* p = hit.getPosition() ;
00024     _position[0] = p[0] ;
00025     _position[1] = p[1] ;
00026     _position[2] = p[2] ;
00027     
00028     int nMC = hit.getNMCContributions() ;
00029     
00030     // now copy all the MCParticle contributions
00031     for(int i=0; i<nMC ;i++){
00032       
00033       MCParticleCont* con = new  MCParticleCont ;
00034       
00035       con->Particle = hit.getParticleCont(i) ;
00036       con->Energy = hit.getEnergyCont(i) ;
00037       con->Time = hit.getTimeCont(i) ;
00038       con->PDG = hit.getPDGCont(i) ;
00039       
00040       _vec.push_back( con ) ;
00041     }  
00042   }
00043   
00044 //   EVENT::LCObject* SimCalorimeterHitImpl::clone() const{
00045 //     // shallow copy ... more thought needed
00046 //     return new SimCalorimeterHitImpl( *this ) ;
00047 //   }
00048   
00049 
00050   SimCalorimeterHitImpl::~SimCalorimeterHitImpl(){
00051     // delete all MCParticle contributions
00052     MCParticleContVec::iterator iter = _vec.begin() ;
00053     
00054     while( iter != _vec.end() ){
00055       delete *iter++ ;
00056     }
00057     
00058   }
00059   
00060   int SimCalorimeterHitImpl::getCellID0() const {
00061     return _cellID0 ;
00062   }
00063   
00064   int SimCalorimeterHitImpl::getCellID1() const {
00065     return _cellID1 ;
00066   }
00067   
00068   float SimCalorimeterHitImpl::getEnergy() const {
00069     return _energy ;
00070   }
00071   
00072   const float* SimCalorimeterHitImpl::getPosition() const {
00073     return _position ;
00074   }
00075   
00076   int SimCalorimeterHitImpl::getNMCParticles() const {
00077     //static bool first = true ;
00078     //if( first ){
00079     //  std::cout << " WARNING >>>>>>>  SimCalorimeterHitImpl::getNMCParticles() is deprecated "
00080     //            << " - please use  SimCalorimeterHitImpl::getNMCContributions() ! " << std::endl ;
00081     //  first = false ;
00082     //}
00083 
00084     UTIL::LCWarning::getInstance().printWarning( "SIMCALORIMETERHIT_DEPRECATED_GETNMCPARTICLES" ) ;
00085 
00086     return getNMCContributions() ;
00087   }
00088 
00089   int SimCalorimeterHitImpl::getNMCContributions() const {
00090     return _vec.size() ;
00091   }
00092   
00093   EVENT::MCParticle * SimCalorimeterHitImpl::getParticleCont(int i) const {
00094     try{
00095       //return _vec.at(i)->Particle ;
00096       //FIXME gcc 2.95 doesn't know at(i) ??
00097       return _vec[i]->Particle ;      
00098     }
00099     catch( ... ){
00100       throw EVENT::Exception(std::string("SimCalorimeterHitImpl::getParticleCont: no particle at " + i ) ) ;
00101     }
00102   }
00103 
00104   
00105   float SimCalorimeterHitImpl::getEnergyCont(int i) const {
00106     return _vec[i]->Energy ;
00107   }
00108   
00109   float SimCalorimeterHitImpl::getTimeCont(int i) const {
00110     return _vec[i]->Time ;
00111   }
00112   
00113   int SimCalorimeterHitImpl::getPDGCont(int i) const{
00114     return _vec[i]->PDG ;
00115   }
00116   
00117   void SimCalorimeterHitImpl::setCellID0(int id0){
00118     checkAccess("SimCalorimeterHitImpl::setCellID0") ;
00119     _cellID0 = id0 ;
00120   }
00121   
00122   void SimCalorimeterHitImpl::setCellID1(int id1){
00123     checkAccess("SimCalorimeterHitImpl::setCellID1") ;
00124     _cellID1 = id1 ;
00125   }
00126   
00127   void SimCalorimeterHitImpl::setEnergy(float en){
00128     checkAccess("SimCalorimeterHitImpl::setEnergy") ;
00129     _energy = en ;
00130   }
00131   
00132   void SimCalorimeterHitImpl::setPosition(float pos[3]){
00133     checkAccess("SimCalorimeterHitImpl::setPosition") ;
00134     _position[0] = pos[0] ;
00135     _position[1] = pos[1] ;
00136     _position[2] = pos[2] ;
00137   }
00138   
00139   void SimCalorimeterHitImpl::addMCParticleContribution( EVENT::MCParticle *p,
00140                                                       float en,
00141                                                       float t,
00142                                                       int pdg ){
00143 
00144     checkAccess("SimCalorimeterHitImpl::addMCParticleContribution") ;
00145     if( p==0){
00146       // just add the energy - no MC contribution  !!
00147       _energy += en ;
00148       return ;
00149     }
00150     else if( pdg == 0 ) { // not in extended mode - only one contribution per primary particle
00151 
00152 
00153 
00154       for( std::vector<MCParticleCont*>::iterator iter=_vec.begin() ;
00155            iter != _vec.end() ; iter++ ){
00156 
00157         if( (*iter)->Particle == p ) {  //  && (*iter)->PDG == pdg ){
00158           
00159           (*iter)->Energy += en ;
00160 
00161           _energy += en ;
00162           return ;
00163         }
00164 
00165       }
00166     }
00167       
00168     _energy += en ;
00169     MCParticleCont* con = new  MCParticleCont ;
00170     
00171     con->Particle = p ;
00172     con->Energy = en ;
00173     con->Time = t ;
00174     con->PDG = pdg ;
00175     _vec.push_back( con ) ;
00176     
00177   }
00178 } // namespace IMPL

Generated on Mon Jan 7 13:15:21 2013 for MicromegasFramework by  doxygen 1.4.7