CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/SimG4Core/MagneticField/src/LocalFieldManager.cc

Go to the documentation of this file.
00001 
00002 #include "SimG4Core/MagneticField/interface/LocalFieldManager.h"
00003 
00004 #include "G4ChordFinder.hh"
00005 #include "G4Track.hh"
00006 
00007 #include <iostream>
00008 
00009 using namespace sim;
00010 
00011 LocalFieldManager::LocalFieldManager(G4Field* commonField,
00012                                      G4FieldManager* priFM,
00013                                      G4FieldManager* altFM)
00014    : G4FieldManager(commonField,0,false),
00015      fPrimaryFM(priFM), fAlternativeFM(altFM),
00016      fCurrentFM(0),
00017      fVerbosity(false)
00018 {
00019    this->CopyValuesAndChordFinder(priFM);
00020    fCurrentFM = priFM ;
00021 }
00022 
00023 void LocalFieldManager::ConfigureForTrack(const G4Track* trk)
00024 {
00025 
00026    int PID = trk->GetDynamicParticle()->GetDefinition()->GetPDGEncoding();
00027    
00028    if ( abs(PID)!=13 ) // maybe also high energy pions ?... what else ?
00029    {
00030       if ( fCurrentFM != fAlternativeFM )
00031       {
00032          this->CopyValuesAndChordFinder(fAlternativeFM);
00033          fCurrentFM = fAlternativeFM;
00034          if ( fVerbosity) print(trk);
00035       }
00036    }
00037    else
00038    {
00039       if ( fCurrentFM != fPrimaryFM )
00040       {
00041          this->CopyValuesAndChordFinder(fPrimaryFM);
00042          fCurrentFM = fPrimaryFM;
00043          if ( fVerbosity) print(trk);
00044       }
00045    }
00046    
00047    return ;
00048 
00049 }
00050 
00051 const G4FieldManager* LocalFieldManager::CopyValuesAndChordFinder(G4FieldManager * fm)
00052 {
00053 
00054     SetDeltaIntersection(fm->GetDeltaIntersection());
00055     SetDeltaOneStep(fm->GetDeltaOneStep());
00056     G4ChordFinder* cf = fm->GetChordFinder();
00057     cf->SetDeltaChord(cf->GetDeltaChord());
00058     SetChordFinder(cf);
00059     
00060     return fm;
00061 
00062 }
00063 
00064 void LocalFieldManager::print(const G4Track* trk)
00065 {
00066 
00067   if (fCurrentFM==fAlternativeFM) 
00068   {
00069      std::cout << " Alternative field manager with";
00070   }
00071   else 
00072   {
00073      std::cout << " Global field manager with";
00074   }
00075   std::cout << " DeltaIntersection " << G4FieldManager::GetDeltaIntersection()
00076             << ", DeltaOneStep " << G4FieldManager::GetDeltaOneStep()
00077             << " and DeltaChord " << G4FieldManager::GetChordFinder()->GetDeltaChord()
00078             << " for " << trk->GetDynamicParticle()->GetDefinition()->GetPDGEncoding()
00079             << " with " << trk->GetKineticEnergy()/MeV << " MeV in "
00080             << trk->GetVolume()->GetName() << std::endl;
00081 
00082    return ;
00083 
00084 }