#include <MyTriggerSvc.hh>
Public Member Functions | |
MyTriggerSvc () | |
~MyTriggerSvc () | |
void | SetMyTrigger (G4String name) |
bool | TriggerIt (const G4Event *) |
Static Public Member Functions | |
static MyTriggerSvc * | GetMyTriggerSvc () |
Private Member Functions | |
void | ReSet () |
void | ShowOutCard () |
Private Attributes | |
int | minM_Hits |
int | minV_Hits |
double | minEleMom |
int | minAntipNum |
int | minTracks |
MyDetectorManager * | pMyDetectorManager |
MonitorSD * | myMonitorSD |
MonitorSD * | myMonitorSD2 |
McTruthSvc * | myMcTruthSvc |
KillerSD * | myKillerSD |
Static Private Attributes | |
static MyTriggerSvc * | fMyTriggerSvc = 0 |
Definition at line 19 of file MyTriggerSvc.hh.
MyTriggerSvc::MyTriggerSvc | ( | ) |
Definition at line 29 of file MyTriggerSvc.cc.
References fMyTriggerSvc.
00030 :pMyDetectorManager(0),myMonitorSD(0),myMonitorSD2(0),myMcTruthSvc(0),myKillerSD(0) 00031 { 00032 if (fMyTriggerSvc){ 00033 G4Exception("MyTriggerSvc::MyTriggerSvc()","Run0031", 00034 FatalException, "MyTriggerSvc constructed twice."); 00035 } 00036 fMyTriggerSvc = this; 00037 }
MyTriggerSvc::~MyTriggerSvc | ( | ) |
Definition at line 39 of file MyTriggerSvc.cc.
MyTriggerSvc * MyTriggerSvc::GetMyTriggerSvc | ( | ) | [static] |
Definition at line 44 of file MyTriggerSvc.cc.
References fMyTriggerSvc.
Referenced by MyAnalysisSvc::MyAnalysisSvc().
00044 { 00045 if ( !fMyTriggerSvc ){ 00046 fMyTriggerSvc = new MyTriggerSvc; 00047 } 00048 return fMyTriggerSvc; 00049 }
void MyTriggerSvc::ReSet | ( | ) | [private] |
Definition at line 205 of file MyTriggerSvc.cc.
References minAntipNum, minEleMom, minM_Hits, minTracks, and minV_Hits.
Referenced by SetMyTrigger().
00205 { 00206 minM_Hits = -1; 00207 minV_Hits = -1; 00208 minEleMom = -1*MeV; 00209 minAntipNum = -1; 00210 minTracks = -1; 00211 }
void MyTriggerSvc::SetMyTrigger | ( | G4String | name | ) |
Definition at line 51 of file MyTriggerSvc.cc.
References MyString2Anything::get_U(), McTruthSvc::GetMcTruthSvc(), MyDetectorManager::GetMyDetectorManager(), MyDetectorManager::GetSD(), minAntipNum, minEleMom, minM_Hits, minTracks, minV_Hits, myMcTruthSvc, myMonitorSD, pMyDetectorManager, ReSet(), and ShowOutCard().
Referenced by MyAnalysisSvc::set_out_card().
00051 { 00052 ReSet(); 00053 std::ifstream fin_card(filename); 00054 if(!fin_card){ 00055 std::cout<<"In MyTriggerSvc::ReadOutputCard, cannot open "<<filename<<"!!!"<<std::endl; 00056 G4Exception("MyTriggerSvc::ReadOutputCard()", 00057 "InvalidSetup", FatalException, 00058 "cannot find output card"); 00059 } 00060 std::stringstream buf_card; 00061 G4String s_card; 00062 int n_TRIGGER_section_symbol = 0; 00063 G4String TRIGGERSECTIONNAME = "TRIGGERSECTION"; 00064 while(getline(fin_card,s_card)){ 00065 buf_card.str(""); 00066 buf_card.clear(); 00067 buf_card<<s_card; 00068 00069 //eleminate useless lines 00070 const char* c_card = s_card.c_str(); 00071 int length = strlen(c_card); 00072 int offset = 0; 00073 for ( ; offset < length; offset++ ){ 00074 if ( c_card[offset] != ' ' ) break; 00075 } 00076 if ( c_card[offset] == '#' || (c_card[offset] == '/' && c_card[offset+1] == '/') || length - offset == 0 ){ 00077 continue; 00078 } 00079 00080 G4String name, unit; 00081 buf_card>>name; 00082 00083 if ( n_TRIGGER_section_symbol == 0 ){ 00084 if ( name == TRIGGERSECTIONNAME ){ 00085 n_TRIGGER_section_symbol++; 00086 } 00087 } 00088 else if ( n_TRIGGER_section_symbol == 1 ){ 00089 int para; 00090 buf_card>>para; 00091 if ( name == TRIGGERSECTIONNAME ){ 00092 n_TRIGGER_section_symbol++; 00093 } 00094 else if ( name == "minM_Hits" ){ 00095 minM_Hits = para; 00096 } 00097 else if ( name == "minV_Hits" ){ 00098 minV_Hits = para; 00099 } 00100 else if ( name == "minEleMom" ){ 00101 std::string unit; 00102 buf_card>>unit; 00103 minEleMom = para*MyString2Anything::get_U(unit); 00104 } 00105 else if ( name == "minAntipNum" ){ 00106 minAntipNum = para; 00107 } 00108 else if ( name == "minTracks" ){ 00109 minTracks = para; 00110 } 00111 else{ 00112 std::cout<<"In MyTriggerSvc::SetMyTrigger, unknown name: "<<name<<" in file "<<filename<<std::endl; 00113 std::cout<<"Will ignore this line!"<<std::endl; 00114 } 00115 } 00116 00117 if ( n_TRIGGER_section_symbol > 1 ){ 00118 break; 00119 } 00120 } 00121 buf_card.str(""); 00122 buf_card.clear(); 00123 if ( n_TRIGGER_section_symbol<= 1 ){ 00124 std::cout<<"*****************WARNING********************"<<std::endl; 00125 std::cout<<"In MyTriggerSvc::ReadOutputCard, failed to find enough section seperators \""<<TRIGGERSECTIONNAME<<"\" for TRIGGER in file "<<filename<<std::endl; 00126 std::cout<<"Will use default settings."<<std::endl; 00127 std::cout<<"********************************************"<<std::endl; 00128 } 00129 fin_card.close(); 00130 ShowOutCard(); 00131 pMyDetectorManager = MyDetectorManager::GetMyDetectorManager(); 00132 G4VSensitiveDetector* myVSD = 0; 00133 G4VSensitiveDetector* myVSD2 = 0; 00134 if ( minM_Hits != -1 ){ 00135 myVSD = pMyDetectorManager->GetSD("","M/MonitorSD"); 00136 if (myVSD){ 00137 myMonitorSD = dynamic_cast<MonitorSD*> (myVSD); 00138 std::cout<<"myVSD @ ["<<(void*) myVSD<<"]"<<std::endl; 00139 std::cout<<"myMonitorSD @ ["<<(void*) myMonitorSD<<"]"<<std::endl; 00140 } 00141 } 00142 if ( minV_Hits != -1 ){ 00143 myVSD = pMyDetectorManager->GetSD("","V/MonitorSD"); 00144 if (myVSD){ 00145 myMonitorSD = dynamic_cast<MonitorSD*> (myVSD); 00146 std::cout<<"myVSD @ ["<<(void*) myVSD<<"]"<<std::endl; 00147 std::cout<<"myMonitorSD @ ["<<(void*) myMonitorSD<<"]"<<std::endl; 00148 } 00149 } 00150 if ( minEleMom != -1*MeV ){ 00151 myMcTruthSvc = McTruthSvc::GetMcTruthSvc(); 00152 } 00153 if ( minAntipNum != -1 || minTracks != -1 ){ 00154 myMcTruthSvc = McTruthSvc::GetMcTruthSvc(); 00155 } 00156 }
void MyTriggerSvc::ShowOutCard | ( | ) | [private] |
Definition at line 213 of file MyTriggerSvc.cc.
References minAntipNum, minEleMom, minM_Hits, minTracks, and minV_Hits.
Referenced by SetMyTrigger().
00213 { 00214 std::cout<<"*************************Trigger settings"<<"***************************"<<std::endl; 00215 std::cout<<"minM_Hits = "<<minM_Hits<<std::endl; 00216 std::cout<<"minV_Hits = "<<minV_Hits<<std::endl; 00217 std::cout<<"minEleMom= "<<minEleMom/MeV<<", MeV"<<std::endl; 00218 std::cout<<"minAntipNum= "<<minAntipNum<<std::endl; 00219 std::cout<<"minTracks = "<<minTracks<<std::endl; 00220 std::cout<<"******************************************************************************"<<std::endl; 00221 }
bool MyTriggerSvc::TriggerIt | ( | const G4Event * | evt | ) |
Definition at line 158 of file MyTriggerSvc.cc.
References MonitorSD::Get_nHits(), McTruthSvc::get_nTracks(), McTruthSvc::get_pid(), McTruthSvc::get_px(), McTruthSvc::get_py(), McTruthSvc::get_pz(), minAntipNum, minEleMom, minM_Hits, minTracks, minV_Hits, myMcTruthSvc, and myMonitorSD.
Referenced by MyAnalysisSvc::EndOfEventAction().
00158 { 00159 00160 if ( minM_Hits != -1 ){ 00161 int nHits = 0; 00162 if (myMonitorSD){ 00163 nHits = myMonitorSD->Get_nHits(); 00164 } 00165 if ( nHits < minM_Hits ) return false; 00166 } 00167 if ( minV_Hits != -1 ){ 00168 int nHits = 0; 00169 if (myMonitorSD){ 00170 nHits = myMonitorSD->Get_nHits(); 00171 } 00172 if ( nHits < minV_Hits ) return false; 00173 } 00174 if ( minEleMom != -1*MeV ){ 00175 bool foundit = false; 00176 int nTracks = myMcTruthSvc->get_nTracks(); 00177 for ( int i = 0; i < nTracks; i++ ){ 00178 int pid = myMcTruthSvc->get_pid(i); 00179 double px = myMcTruthSvc->get_px(i)*GeV; 00180 double py = myMcTruthSvc->get_py(i)*GeV; 00181 double pz = myMcTruthSvc->get_pz(i)*GeV; 00182 double pa = sqrt(px*px+py*py+pz*pz); 00183 if ( pid == 11 && pa > minEleMom ) foundit = true; 00184 } 00185 if (!foundit) return false; 00186 } 00187 if ( minAntipNum != -1 ){ 00188 bool foundit = false; 00189 int nTracks = myMcTruthSvc->get_nTracks(); 00190 for ( int i = 0; i < nTracks; i++ ){ 00191 int pid = myMcTruthSvc->get_pid(i); 00192 if ( pid == -2212 ) foundit = true; 00193 } 00194 if (!foundit) return false; 00195 } 00196 if ( minTracks!= -1 ){ 00197 int nTracks = myMcTruthSvc->get_nTracks(); 00198 if (nTracks<minTracks) return false; 00199 } 00200 //std::cout<<"Passed Cut!"<<std::endl; 00201 00202 return true; 00203 }
MyTriggerSvc * MyTriggerSvc::fMyTriggerSvc = 0 [static, private] |
Definition at line 33 of file MyTriggerSvc.hh.
Referenced by GetMyTriggerSvc(), and MyTriggerSvc().
int MyTriggerSvc::minAntipNum [private] |
Definition at line 42 of file MyTriggerSvc.hh.
Referenced by ReSet(), SetMyTrigger(), ShowOutCard(), and TriggerIt().
double MyTriggerSvc::minEleMom [private] |
Definition at line 41 of file MyTriggerSvc.hh.
Referenced by ReSet(), SetMyTrigger(), ShowOutCard(), and TriggerIt().
int MyTriggerSvc::minM_Hits [private] |
Definition at line 39 of file MyTriggerSvc.hh.
Referenced by ReSet(), SetMyTrigger(), ShowOutCard(), and TriggerIt().
int MyTriggerSvc::minTracks [private] |
Definition at line 43 of file MyTriggerSvc.hh.
Referenced by ReSet(), SetMyTrigger(), ShowOutCard(), and TriggerIt().
int MyTriggerSvc::minV_Hits [private] |
Definition at line 40 of file MyTriggerSvc.hh.
Referenced by ReSet(), SetMyTrigger(), ShowOutCard(), and TriggerIt().
KillerSD* MyTriggerSvc::myKillerSD [private] |
Definition at line 49 of file MyTriggerSvc.hh.
McTruthSvc* MyTriggerSvc::myMcTruthSvc [private] |
Definition at line 48 of file MyTriggerSvc.hh.
Referenced by SetMyTrigger(), and TriggerIt().
MonitorSD* MyTriggerSvc::myMonitorSD [private] |
Definition at line 46 of file MyTriggerSvc.hh.
Referenced by SetMyTrigger(), and TriggerIt().
MonitorSD* MyTriggerSvc::myMonitorSD2 [private] |
Definition at line 47 of file MyTriggerSvc.hh.
Definition at line 45 of file MyTriggerSvc.hh.
Referenced by SetMyTrigger().