Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

ProcessedNormal.cxx

Go to the documentation of this file.
00001 #include "FastShowerUtils/ProcessedNormal.h"
00002 #include "FastShowerUtils/IDistProcessor.h"
00003 #include "CLHEP/Random/RandGauss.h"
00004 #include <assert.h>
00005 #include <iostream>
00006 namespace FastShower{
00007   double ProcessedNormal::sample() const{
00008     return RandGauss::shoot();
00009   }
00010   double ProcessedNormal::sample(const IDistProcessor* dp) const{
00011     return dp->process(RandGauss::shoot());
00012   }
00013   double ProcessedNormal::sample(double lowLim, 
00014                                  double upLim, 
00015                                  const IDistProcessor* dp) const{
00016 
00017     //cout<<"*** "<<text()<<": low/upLim = "<<lowLim<<" / "<<upLim<<endl;
00018     assert(lowLim<upLim);
00019     
00020     double value = dp->process( RandGauss::shoot() );
00021 
00022     //keep going until within truncation limits;
00023     int ncalls = 0;
00024     while(value < lowLim || value > upLim){
00025       value = dp->process( RandGauss::shoot() );
00026       ++ncalls;
00027       if( ncalls%2 == 1000){
00028         cout<<"Processed Normal called "<< ncalls<<" times"<<endl;
00029         cout<<"Processed Normal lowLim "
00030             << lowLim<<" upLim"<<upLim<<" value"<<value<<endl;
00031       }
00032     }
00033     
00034     return value;
00035   }
00036   IProcessedDist* ProcessedNormal::clone() const {
00037     IProcessedDist* iptr = new ProcessedNormal(*this);
00038     return iptr;
00039   } 
00040 
00041 }
00042 

Generated on Tue Mar 18 11:50:03 2003 for FastShowerUtils by doxygen1.3-rc1