KillerSD Class Reference

#include <KillerSD.hh>

Inheritance diagram for KillerSD:
MySD

List of all members.

Public Member Functions

 KillerSD (G4String, MyVGeometryParameter *)
virtual ~KillerSD ()
void Initialize (G4HCofThisEvent *)
G4bool ProcessHits (G4Step *, G4TouchableHistory *)
void EndOfEvent (G4HCofThisEvent *)
void SetBranch ()
void ReadOutputCard (G4String filename)
void SetVerbose (int val)
G4String get_VolName ()
int get_VerboseLevel ()
MyVGeometryParameterget_GeometryParameter ()
void set_VerboseLevel (int val)
void set_GeometryParameter (MyVGeometryParameter *val)

Private Member Functions

void ReSet ()
void ShowOutCard ()

Private Attributes

bool Switch
bool neutralCut
G4int maxn
G4double minp
G4double mine
G4double tres
G4double mint
G4double maxt
G4double minedep
std::vector< int > white_list
std::vector< int > black_list

Detailed Description

Definition at line 22 of file KillerSD.hh.


Constructor & Destructor Documentation

KillerSD::KillerSD ( G4String  name,
MyVGeometryParameter pointer 
)

Definition at line 40 of file KillerSD.cc.

00041 :MySD(name, pointer)
00042 {
00043 }

KillerSD::~KillerSD (  )  [virtual]

Definition at line 45 of file KillerSD.cc.

00045                    {
00046 }


Member Function Documentation

void KillerSD::EndOfEvent ( G4HCofThisEvent *   ) 

Definition at line 281 of file KillerSD.cc.

00281                                          {
00282         if (verboseLevel>0) {
00283                 //    hitsCollection->PrintAllHits();
00284                 /*
00285                    G4int NbHits = hitsCollection->entries();
00286                    G4cout << "\n-------->Hits Collection: in this event they are " << NbHits
00287                    << " hits in the MONITOR chambers: " << G4endl;
00288                    for (G4int i=0;i<NbHits;i++) (*hitsCollection)[i]->Print();
00289                  */
00290         }
00291 }

MyVGeometryParameter* MySD::get_GeometryParameter (  )  [inline, inherited]

Definition at line 28 of file MySD.hh.

References MySD::m_GeometryParameter.

00028 { return m_GeometryParameter; }

int MySD::get_VerboseLevel (  )  [inline, inherited]

Definition at line 27 of file MySD.hh.

References MySD::fVerboseLevel.

00027 { return fVerboseLevel; }

G4String MySD::get_VolName (  )  [inline, inherited]
void KillerSD::Initialize ( G4HCofThisEvent *  HCE  ) 

Definition at line 50 of file KillerSD.cc.

00051 {
00052 }

G4bool KillerSD::ProcessHits ( G4Step *  aStep,
G4TouchableHistory *  touchableHistory 
)

Definition at line 199 of file KillerSD.cc.

References black_list, maxt, mine, minedep, minp, mint, neutralCut, Switch, and white_list.

00200 {
00201 
00202         //*************************get useful variables***********************
00203 
00204         // get track info
00205         G4Track* aTrack = aStep->GetTrack() ;
00206         G4int trackID= aTrack->GetTrackID(); //G4 track ID of current track.
00207         G4int charge = aTrack->GetDefinition()->GetPDGCharge();
00208         G4int pid = aTrack->GetDefinition()->GetPDGEncoding();
00209 
00210         // get information at the beginning and at the end of step
00211         G4StepPoint* prePoint  = aStep->GetPreStepPoint() ;
00212         G4double total_e = prePoint->GetTotalEnergy();
00213         G4ThreeVector pointIn_mom = prePoint->GetMomentum();
00214         G4double pointIn_pa = pointIn_mom.mag();
00215         G4ThreeVector pointIn_pos = prePoint->GetPosition();
00216         G4double pointIn_time = prePoint->GetGlobalTime();//Time since the event in which the track belongs is created
00217         G4StepPoint* postPoint  = aStep->GetPostStepPoint() ;
00218         G4double pointOut_time = postPoint->GetGlobalTime();//Time since the event in which the track belongs is created
00219         G4ThreeVector pointOut_mom = postPoint->GetMomentum();
00220         G4double pointOut_pa = pointOut_mom.mag();
00221         G4ThreeVector pointOut_pos = postPoint->GetPosition();
00222 
00223         // get volume info
00224         const G4VTouchable *touchable = prePoint->GetTouchable();
00225         G4int ReplicaNo = touchable->GetVolume(0)->GetCopyNo();
00226         G4String VolName = touchable->GetVolume(0)->GetName();
00227 
00228         // get step info
00229         G4double edep = aStep->GetTotalEnergyDeposit();
00230         G4double stepL = aStep->GetStepLength();
00231 
00232         //*************************filter***********************
00233         //switch
00234         if (!Switch) return false;
00235 
00236         //neutralCut
00237         if ( charge == 0 && neutralCut ) return false;
00238 
00239         //maxn
00240 //      if ( maxn && nHits >= maxn ) return false;
00241 
00242         // white_list
00243         bool foundit = false;
00244         for (int i = 0; i<white_list.size(); i++){
00245                 if (pid == white_list[i]) foundit=true;
00246                 if (white_list[i]==0&&pid<1e7) foundit = true;
00247                 if (white_list[i]==-1&&trackID==1) foundit = true;
00248         }
00249         if (!foundit&&white_list.size()) return false;
00250         // black_list
00251         foundit = false;
00252         for (int i = 0; i<black_list.size(); i++){
00253                 if (pid == black_list[i]) foundit=true;
00254                 if (black_list[i]==0&&pid<1e7) foundit = true;
00255                 if (black_list[i]==-1&&trackID==1) foundit = true;
00256         }
00257         if (foundit) return false;
00258 
00259         //minp
00260         if ( minp && pointOut_pa < minp ) return false;
00261         //energy
00262         if (mine&&aTrack->GetTotalEnergy()<mine) return false;
00263 
00264         //time_window
00265         if(isnan(pointOut_time)){
00266                 G4cout<<"KillerSD:error, pointOut_time is nan "<<G4endl;
00267                 return false;
00268         }
00269         if ( pointOut_time < mint && mint ) return false;
00270         if ( pointOut_time > maxt && maxt ) return false;
00271 
00272         //minedep
00273         if( edep <= minedep ) return false;
00274 
00275         aTrack->SetTrackStatus(fStopAndKill);
00276         return true;
00277 }

void KillerSD::ReadOutputCard ( G4String  filename  )  [virtual]

Reimplemented from MySD.

Definition at line 61 of file KillerSD.cc.

References black_list, MyString2Anything::get_U(), MySD::get_VolName(), maxn, maxt, mine, minedep, minp, mint, neutralCut, ReSet(), ShowOutCard(), Switch, tres, and white_list.

00061                                               {
00062         ReSet();
00063         std::ifstream fin_card(filename);
00064         if(!fin_card){
00065                 std::cout<<"In KillerSD::ReadOutputCard, cannot open "<<filename<<"!!!"<<std::endl;
00066                 G4Exception("KillerSD::ReadOutputCard()",
00067                                 "InvalidSetup", FatalException,
00068                                 "cannot find output card");
00069         }
00070         std::stringstream buf_card;
00071         G4String s_card;
00072         G4String volName = get_VolName();
00073         int n_filter_section_symbol = 0;
00074         G4String FILTERSECTIONNAME = volName + "_FILTERSECTION";
00075         while(getline(fin_card,s_card)){
00076                 buf_card.str("");
00077                 buf_card.clear();
00078                 buf_card<<s_card;
00079 
00080                 //eleminate useless lines
00081                 const char* c_card = s_card.c_str();
00082                 int length = strlen(c_card);
00083                 int offset = 0;
00084                 for ( ; offset < length; offset++ ){
00085                         if ( c_card[offset] != ' ' ) break;
00086                 }
00087                 if ( c_card[offset] == '#' || (c_card[offset] == '/' && c_card[offset+1] == '/') || length - offset == 0 ){
00088                         continue;
00089                 }
00090 
00091                 G4String name, unit;
00092                 buf_card>>name;
00093 
00094                 if ( n_filter_section_symbol == 0 ){
00095                         if ( name == FILTERSECTIONNAME ){
00096                                 n_filter_section_symbol++;
00097                         }
00098                 }
00099                 else if ( n_filter_section_symbol == 1 ){
00100                         if ( name == FILTERSECTIONNAME ){
00101                                 n_filter_section_symbol++;
00102                         }
00103                         else if( name == "Switch" ) Switch = true;
00104                         else if( name == "neutralCut" ) neutralCut = true;
00105                         else if( name == "maxn" ) buf_card>>maxn;
00106                         else if( name == "WL" ){
00107                                 int pid = 0;
00108                                 buf_card>>pid;
00109                                 white_list.push_back(pid);
00110                         }
00111                         else if( name == "BL" ){
00112                                 int pid = 0;
00113                                 buf_card>>pid;
00114                                 black_list.push_back(pid);
00115                         }
00116                         else{
00117                                 G4double para;
00118                                 G4String unit;
00119                                 buf_card>>para>>unit;
00120                                 para *= MyString2Anything::get_U(unit);
00121                                 if( name == "minp" ) minp = para;
00122                                 else if( name == "mine" ) mine = para;
00123                                 else if ( name == "minedep" ) minedep = para;
00124                                 else if( name == "mint" ) mint = para;
00125                                 else if( name == "maxt" ) maxt = para;
00126                                 else if( name == "tres" ) tres = para;
00127                                 else{
00128                                         std::cout<<"In KillerSD::ReadOutputCard, unknown name: "<<name<<" in file "<<filename<<std::endl;
00129                                         std::cout<<"Will ignore this line!"<<std::endl;
00130                                 }
00131                         }
00132                 }
00133 
00134                 if ( n_filter_section_symbol > 1 ){
00135                         break;
00136                 }
00137         }
00138         buf_card.str("");
00139         buf_card.clear();
00140         if ( n_filter_section_symbol<= 1 ){
00141                 std::cout<<"*****************WARNING********************"<<std::endl;
00142                 std::cout<<"In KillerSD::ReadOutputCard, failed to find enough section seperators \""<<FILTERSECTIONNAME<<"\" for filter in file "<<filename<<std::endl;
00143                 std::cout<<"Will use default settings."<<std::endl;
00144                 std::cout<<"********************************************"<<std::endl;
00145         }
00146         fin_card.close();
00147         ShowOutCard();
00148 }

void KillerSD::ReSet (  )  [private]

Definition at line 152 of file KillerSD.cc.

References black_list, maxn, maxt, mine, minedep, minp, mint, neutralCut, Switch, tres, and white_list.

Referenced by ReadOutputCard().

00152                     {
00153         //for fileter
00154         Switch = true;
00155         neutralCut = false;
00156         minp = 0;
00157         mine = 0;
00158         maxn = 0;
00159         mint = 0;
00160         maxt = 0;
00161         tres = 0;
00162         minedep = -1*MeV;
00163         white_list.clear();
00164         black_list.clear();
00165 }

void MySD::set_GeometryParameter ( MyVGeometryParameter val  )  [inline, inherited]

Definition at line 32 of file MySD.hh.

References MySD::m_GeometryParameter.

Referenced by MyDetectorManager::GetSD().

00032 { m_GeometryParameter = val; }

void MySD::set_VerboseLevel ( int  val  )  [inline, inherited]

Definition at line 31 of file MySD.hh.

References MySD::fVerboseLevel.

00031 { fVerboseLevel = val; }

void KillerSD::SetBranch ( void   )  [virtual]

Reimplemented from MySD.

Definition at line 56 of file KillerSD.cc.

00056                         {
00057 }

void MySD::SetVerbose ( int  val  )  [inline, inherited]

Definition at line 21 of file MySD.hh.

References MySD::fVerboseLevel.

Referenced by MyDetectorManager::GetSD().

00021 {fVerboseLevel = val;}

void KillerSD::ShowOutCard (  )  [private]

Definition at line 169 of file KillerSD.cc.

References black_list, MySD::get_VolName(), maxn, maxt, mine, minedep, minp, mint, neutralCut, Switch, tres, and white_list.

Referenced by ReadOutputCard().

00169                           {
00170         std::cout<<"*************************Output settings for "<<get_VolName()<<"***************************"<<std::endl;
00171         //for fileter
00172         std::cout<<"Switch on?      "<<(Switch?"yes":"no")<<std::endl;
00173         std::cout<<"neutralCut on?  "<<(neutralCut?"yes":"no")<<std::endl;
00174         std::cout<<"minp =          "<<minp/MeV<<"MeV"<<std::endl;
00175         std::cout<<"mine =          "<<mine/MeV<<"MeV"<<std::endl;
00176         std::cout<<"maxn =          "<<maxn<<std::endl;
00177         std::cout<<"mint =          "<<mint/ns<<"ns"<<std::endl;
00178         std::cout<<"maxt =          "<<maxt/ns<<"ns"<<std::endl;
00179         std::cout<<"tres =          "<<tres/ns<<"ns"<<std::endl;
00180         std::cout<<"minedep =       "<<minedep/MeV<<"MeV"<<std::endl;
00181         std::cout<<"white list:     "<<std::endl;
00182         for ( int i = 0; i< white_list.size(); i++){
00183                 std::cout <<"  Only tracks with these following PDGCodes will be killed:"<<std::endl;
00184                 std::cout<<"            "<<i<<": "<<white_list[i]<<std::endl;
00185         }
00186         if ( white_list.size() == 0 ){
00187                 std::cout <<"  Empty! So all tracks will be killed!"<<std::endl;
00188         }
00189         std::cout<<"black list:     "<<std::endl;
00190         for ( int i = 0; i< black_list.size(); i++){
00191                 std::cout <<"  Tracks with these following PDGCodes will NOT be killed:"<<std::endl;
00192                 std::cout<<"            "<<i<<": "<<black_list[i]<<std::endl;
00193         }
00194         std::cout<<"******************************************************************************"<<std::endl;
00195 }


Member Data Documentation

std::vector<int> KillerSD::black_list [private]

Definition at line 55 of file KillerSD.hh.

Referenced by ProcessHits(), ReadOutputCard(), ReSet(), and ShowOutCard().

G4int KillerSD::maxn [private]

Definition at line 47 of file KillerSD.hh.

Referenced by ReadOutputCard(), ReSet(), and ShowOutCard().

G4double KillerSD::maxt [private]

Definition at line 52 of file KillerSD.hh.

Referenced by ProcessHits(), ReadOutputCard(), ReSet(), and ShowOutCard().

G4double KillerSD::mine [private]

Definition at line 49 of file KillerSD.hh.

Referenced by ProcessHits(), ReadOutputCard(), ReSet(), and ShowOutCard().

G4double KillerSD::minedep [private]

Definition at line 53 of file KillerSD.hh.

Referenced by ProcessHits(), ReadOutputCard(), ReSet(), and ShowOutCard().

G4double KillerSD::minp [private]

Definition at line 48 of file KillerSD.hh.

Referenced by ProcessHits(), ReadOutputCard(), ReSet(), and ShowOutCard().

G4double KillerSD::mint [private]

Definition at line 51 of file KillerSD.hh.

Referenced by ProcessHits(), ReadOutputCard(), ReSet(), and ShowOutCard().

bool KillerSD::neutralCut [private]

Definition at line 46 of file KillerSD.hh.

Referenced by ProcessHits(), ReadOutputCard(), ReSet(), and ShowOutCard().

bool KillerSD::Switch [private]

Definition at line 45 of file KillerSD.hh.

Referenced by ProcessHits(), ReadOutputCard(), ReSet(), and ShowOutCard().

G4double KillerSD::tres [private]

Definition at line 50 of file KillerSD.hh.

Referenced by ReadOutputCard(), ReSet(), and ShowOutCard().

std::vector<int> KillerSD::white_list [private]

Definition at line 54 of file KillerSD.hh.

Referenced by ProcessHits(), ReadOutputCard(), ReSet(), and ShowOutCard().


The documentation for this class was generated from the following files:

Generated on 15 Jun 2016 for g4sim by  doxygen 1.6.1