Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

MJWaveformUI.cc

Go to the documentation of this file.
00001 //---------------------------------------------------------------------------//
00002 //bb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nu//
00003 //                                                                           //
00004 //                         MAJORANA Simulation                               //
00005 //                                                                           //
00006 //      This code implementation is the intellectual property of the         //
00007 //      MAJORANA Collaboration. It is based on Geant4, an intellectual       //
00008 //      property of the RD44 GEANT4 collaboration.                           //
00009 //                                                                           //
00010 //                        *********************                              //
00011 //                                                                           //
00012 //    Neither the authors of this software system, nor their employing       //
00013 //    institutes, nor the agencies providing financial support for this      //
00014 //    work  make  any representation or  warranty, express or implied,       //
00015 //    regarding this software system or assume any liability for its use.    //
00016 //    By copying, distributing or modifying the Program (or any work based   //
00017 //    on on the Program) you indicate your acceptance of this statement,     //
00018 //    and all its terms.                                                     //
00019 //                                                                           //
00020 //bb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nu//
00021 //---------------------------------------------------------------------------//
00022 //                                                          
00023 // $Id: MJWaveformUI.cc,v 1.2 2004/11/09 13:42:39 xliu Exp $ 
00024 //      
00025 // CLASS IMPLEMENTATION:  MJWaveformUI.cc
00026 //
00027 //---------------------------------------------------------------------------//
00033 // 
00034 //---------------------------------------------------------------------------//
00045 //---------------------------------------------------------------------------//
00046 //
00047 
00048 //---------------------------------------------------------------------------//
00049 
00050 #include <iostream>
00051 #include <vector>
00052 
00053 #include <CLHEP/Units/SystemOfUnits.h>
00054 
00055 #include "waveform/MJWaveformUI.hh"
00056 
00057 //---------------------------------------------------------------------------//
00058 
00059 MJWaveformUI::MJWaveformUI(MJWaveformManager *manager):
00060   fManager(manager)
00061 {
00062   fPrompt = "wf: "; 
00063 }
00064 
00065 //---------------------------------------------------------------------------//
00066 
00067 MJWaveformUI::MJWaveformUI(const MJWaveformUI & other)
00068 {;}
00069 
00070 //---------------------------------------------------------------------------//
00071 
00072 MJWaveformUI::~MJWaveformUI()
00073 {;}
00074 
00075 //---------------------------------------------------------------------------//
00076 
00077 void MJWaveformUI::StartSession()
00078 {
00079   MJLog(trace) << "Starting Waveform Simulation Session...\n\n";
00080   do {
00081     cout << fPrompt;
00082     cin >> fLine;
00083     ParseLine();
00084     ExecuteCommand();
00085   } while (*fArgument.begin() != "EXIT");
00086   MJLog(trace) << "Waveform Simulation Session Complete.\n";
00087 }
00088 
00089 //---------------------------------------------------------------------------//
00090 
00091 void MJWaveformUI::ExecuteFromFile(char *fname)
00092 {;}
00093 
00094 //---------------------------------------------------------------------------//
00095 
00096 void MJWaveformUI::ExecuteCommand()
00097 {
00098   vector<string>::iterator    argumentIter = fArguments.begin();
00099   if(*argumentIter == "CLOSEROOTFILE") {
00100     if(fManager->GetOutputRoot() && fManager->GetDetector()) {
00101       fManager->GetDetector()->EndOfRunAction();
00102       fManager->GetOutputRoot()->CloseRootFile();
00103     } else {
00104       MJLog(error) << "No Root output format defined. You probably forgot to "
00105                    << "select a detector.\n";
00106     }
00107   } else if(*argumentIter == "DETECTOR") {
00108     argumentIter++;
00109     if(fArguments.size() != 3)
00110       MJLog(error) << "Incorrect number of arguments.\n";
00111     else if(fManager->GetDetector())
00112       MJLog(error) << "Detector already defined. Delete before redefining.\n";
00113     else {
00114       if(*argumentIter == "LANLCLOVER") {
00115         fManager->SetDetector(new MJWaveformLANLClover);
00116         fManager->SetRootOutput(new MJWaveformLANLCloverOutputRoot);
00117         MJLog(trace) << "LANL Clover selected.\n";
00118       } else if (*argumentIter == "SIMPLECOAXIAL") {
00119         fManager->SetDetector(new MJWaveformCoaxialDetector);
00120         fManager->SetRootOutput(new MJWaveformLANLCloverOutputRoot);
00121         MJLog(trace) << "Simple Coaxial Detector selected.\n";
00122       } else if (*argumentIter == "SIMPLEPLANAR") {
00123         fManager->SetDetector(new MJWaveformPlanarDetector);
00124         fManager->SetRootOutput(new MJWaveformPanarOutputRoot);
00125         MJLog(trace) << "Simple Planar Detector selected.\n";
00126       } else {
00127         MJLog(error) << "Unknown detector. Valid Options are : LANLClover " 
00128                      << "SimpleCoaxial SimplePlanar.\n";
00129       }
00130       if(fManager->GetDetector()) {
00131         fManager->GetDetector()->Construct();
00132         fManager->GetDetector()->BeginOfRunAction();
00133       }
00134     }
00135   } else if(*argumentIter == "CHARGEPOINT") {
00136     if(fArguments.size() != 6) 
00137       MJLog(error) << "Incorrect number of arguments.\n";
00138     else {
00139       if(fManager) {
00140         HepDouble x = atof((*(++argumentIter)).c_str()) * cm;
00141         HepDouble y = atof((*(++argumentIter)).c_str()) * cm;
00142         HepDouble z = atof((*(++argumentIter)).c_str()) * cm;
00143         HepDouble eLoss = atof((*(++argumentIter)).c_str()) * keV;
00144         fManager->GetDetector()->AddChargePoint(x, y, z, eLoss);
00145       } else
00146         MJLog(error) << "Define detector first!\n";
00147     }
00148   } else if(*argumentIter == "GO") {
00149     fManager->GetDetector()->BeginOfEventAction();
00150     fManager->GetDetector()->GenerateSignals();
00151     fManager->GetDetector()->EndOfEventAction();    
00152   } else if(*argumentIter == "ROOTFILENAME") {
00153     if(fOutputRoot) {
00154       fOutputRoot->SetRootFileName((*(++argumentIter)).c_str());
00155     } else {
00156       MJLog(error) << "No Root output format defined. You probably forgot to "
00157                    << "select a detector.\n";
00158     }
00159   } else {
00160     MJLog(warning) << "Unknown Command.\n";
00161   }
00162 }
00163 
00164 //---------------------------------------------------------------------------//
00165 
00166 void MJWaveformUI::ParseLine()
00167 {  
00168   bool      previousSpace = true;
00169   string::iterator    lineIter = fLine.begin();
00170   vector<string>::iterator  argumentIter = fArguments.begin();
00171   *argumentIter = "";
00172   while(lineIter != fLine.end()) {
00173     if(*lineIter != ' ') {
00174       previousSpace = false;
00175       *argumentIter += toupper(*lineIter.c_str());
00176     } else if(!previousSpace) {
00177       fArguments.push_back("");       
00178       argumentIter++;
00179       previousSpace = true;
00180     }
00181     lineIter++;
00182   }
00183 }
00184 
00185 //---------------------------------------------------------------------------//

Generated on Mon Nov 29 16:58:53 2004 for Majorana Simulation by  doxygen 1.3.9.1