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

MJVWaveformDetector.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: MJVWaveformDetector.cc,v 1.2 2004/11/09 13:42:39 xliu Exp $ 
00024 //      
00025 // CLASS IMPLEMENTATION:  MJVWaveformDetector.cc
00026 //
00027 //---------------------------------------------------------------------------//
00033 // 
00034 //---------------------------------------------------------------------------//
00044 //---------------------------------------------------------------------------//
00045 
00046 #include "waveform/MJVWaveformDetector.hh"
00047 
00048 //---------------------------------------------------------------------------//
00049 
00050 #include "waveform/MJVWaveformCrystal.hh"
00051 #include "io/MJLogger.hh"
00052 
00053 //---------------------------------------------------------------------------//
00054 
00055 MJVWaveformDetector::MJVWaveformDetector():
00056   fNumberOfCrystals(0), fConstructed(false)
00057 {;}
00058 
00059 //---------------------------------------------------------------------------//
00060 
00061 MJVWaveformDetector::MJVWaveformDetector(const MJVWaveformDetector & other)
00062 {;}
00063 
00064 //---------------------------------------------------------------------------//
00065 
00066 MJVWaveformDetector::~MJVWaveformDetector()
00067 {
00068   DeleteCrystals();
00069 }
00070 
00071 //---------------------------------------------------------------------------//
00072 
00073 void MJVWaveformDetector::AddCrystal(MJVWaveformCrystal *crystal)
00074 {
00075   if(crystal != NULL) {
00076     if(fNumberOfCrystals++ == 0) {
00077       fFirstCrystal = crystal;
00078       fFirstCrystal->SetPreviousCrystal(NULL);
00079     } else {
00080       fLastCrystal->SetNextCrystal(crystal);
00081     }
00082     fLastCrystal = crystal;
00083     fLastCrystal->SetNextCrystal(NULL); 
00084   } else {
00085     MJLog(error) << "MJVWaveformDetector::AddCrystal: Tried to add crystal"
00086                  << " with NULL pointer.\n";
00087   }
00088 }
00089 
00090 //---------------------------------------------------------------------------//
00091 
00092 void MJVWaveformDetector::DeleteCrystals()
00093 {
00094   if(fNumberOfCrystals > 0 && fFirstCrystal){
00095     MJVWaveformCrystal *xtal = fFirstCrystal;
00096     MJVWaveformCrystal *xtal2;
00097     HepInt numberDeleted = 0;
00098     while(xtal) {
00099       xtal2 = xtal->GetNextCrystal();
00100       delete xtal;
00101       xtal = xtal2;
00102       numberDeleted++;
00103     }    
00104     if(numberDeleted != fNumberOfCrystals) {
00105       MJLog(error) << "MJVWaveformDetector::DeleteCrystals: fNumberOfCrystals"
00106                  << " != numberDeleted " << numberDeleted << fNumberOfCrystals
00107                  << '\n';
00108       MJLog(fatal);
00109     }
00110   } else {
00111     MJLog(warning) << "MJVWaveformDetector::DeleteCrystals: No crystals to "
00112                  << "delete. Possible serious allocation error.\n";
00113   }
00114   fNumberOfCrystals = 0;
00115   fFirstCrystal = fLastCrystal = 0;
00116 }
00117 
00118 //---------------------------------------------------------------------------//
00119 
00120 void MJVWaveformDetector::GenerateSignals()
00121 {
00122     MJVWaveformCrystal *xtal = fFirstCrystal;
00123     HepInt index = 0;
00124     while(xtal) {
00125       xtal->GenerateSignal();
00126       xtal = xtal->GetNextCrystal();
00127       index++;
00128     }
00129     MJLog(debugging) << "MJVWaveformDetector::GenerateSignals: " << index 
00130                      << " crystals processed.\n";
00131     if(index != fNumberOfCrystals) 
00132       MJLog(error) << "MJVWaveformDetector::GenerateSignals: " << index
00133                    << " crystals processed, but " << fNumberOfCrystals 
00134                    << " defined.\n";
00135 }
00136 
00137 //---------------------------------------------------------------------------//
00138 //---------------------------------------------------------------------------//

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