Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

HistoAlgorithm Class Reference

#include <HistoAlgorithm.h>

List of all members.

Public Member Functions

StatusCode execute ()
StatusCode finalize ()
 HistoAlgorithm (const std::string &name, ISvcLocator *pSvcLocator)
StatusCode initialize ()

Private Attributes

IHistogram1D * m_h1D
IHistogram1D * m_h1DVar
IHistogram2D * m_h2D
IHistogram2D * m_h2DVar
IHistogram3D * m_h3D
IHistogram3D * m_h3DVar


Constructor & Destructor Documentation

HistoAlgorithm::HistoAlgorithm const std::string &  name,
ISvcLocator *  pSvcLocator
 

00013                                                          :
00014                                Algorithm(name, pSvcLocator)
00015 //------------------------------------------------------------------------------
00016 {
00017   m_h1D = m_h1DVar = 0;
00018   m_h2D = m_h2DVar = 0;
00019   m_h3D = m_h3DVar = 0;
00020 }


Member Function Documentation

StatusCode HistoAlgorithm::execute  ) 
 

00073 {
00074   MsgStream log( msgSvc(), name() );
00075 
00076   static int n = 0;
00077 
00078   double x = sin(double(n)) * 52. + 50.;
00079   double y = cos(double(2*n)) * 52. + 50.;
00080   double z = cos(double(5*n)) * 52. + 50.;
00081 
00082   m_h1D->fill(x);
00083   m_h1DVar->fill(x);
00084 
00085   m_h2D->fill(x, y);
00086   m_h2DVar->fill(x, y);
00087 
00088   m_h3D->fill(x, y, z);
00089   m_h3DVar->fill(x, y, z);
00090 
00091   n++;
00092   return StatusCode::SUCCESS;
00093 }

StatusCode HistoAlgorithm::finalize  ) 
 

00099 {
00100   MsgStream log(msgSvc(), name());
00101   log << MSG::INFO << "Finalizing..." << endreq;
00102 
00103   //1D HISTOGRAM STUFF
00104   log << MSG::INFO << "Info about Histogram 1D\n" << endreq;
00105   //General Info:
00106         log << MSG::INFO << "title: " << m_h1D->title() <<  endreq;
00107         //log << MSG::INFO << "label: " << m_h1D->label() <<  endreq;
00108         log << MSG::INFO << "dim:   " << m_h1D->dimension() << endreq;
00109         //log << MSG::INFO << "vers:  " << m_h1D->version()   << endreq;
00110   //Histo Info:
00111         log << MSG::INFO << "Entries (In): "  << m_h1D->entries()  << endreq;
00112         log << MSG::INFO << "Entries (Out): " << m_h1D->extraEntries()  << endreq;
00113         log << MSG::INFO << "Entries (All): " << m_h1D->allEntries()  << endreq;
00114         log << MSG::INFO << "Entries (Eq.): " << m_h1D->equivalentBinEntries()  << endreq;
00115 
00116         log << MSG::INFO << "Sum of Heights(In): "  << m_h1D->sumBinHeights()  << endreq;
00117         log << MSG::INFO << "Sum of Heights(Out): " << m_h1D->sumExtraBinHeights()  << endreq;
00118         log << MSG::INFO << "Sum of Heights(All): " << m_h1D->sumAllBinHeights() << endreq;
00119         log << MSG::INFO << "Min. Heights(In): "    << m_h1D->minBinHeight()  << endreq;
00120         log << MSG::INFO << "Max. Heights(In): "    << m_h1D->maxBinHeight()  << endreq;
00121   //Statistics:
00122         log << MSG::INFO << "mean: " << m_h1D->mean() << endreq;
00123         log << MSG::INFO << "rms: " <<  m_h1D->rms()  << endreq;
00124   //Print Histogram stream in ASCII on screen:  
00125         log << MSG::INFO << "Printing H1: " << endreq;
00126         histoSvc()->print( m_h1D );
00127 
00128   //1DVar HISTOGRAM STUFF
00129   log << MSG::INFO << "Info about Histogram 1DVar\n" << endreq;
00130   //General Info:
00131         log << MSG::INFO << "title: " << m_h1DVar->title() <<  endreq;
00132         //log << MSG::INFO << "label: " << m_h1DVar->label() <<  endreq;
00133         log << MSG::INFO << "dim:   " << m_h1DVar->dimension() << endreq;
00134         //log << MSG::INFO << "vers:  " << m_h1DVar->version()   << endreq;
00135   //Histo Info:
00136         log << MSG::INFO << "Entries (In): "  << m_h1DVar->entries()  << endreq;
00137         log << MSG::INFO << "Entries (Out): " << m_h1DVar->extraEntries()  << endreq;
00138         log << MSG::INFO << "Entries (All): " << m_h1DVar->allEntries()  << endreq;
00139         log << MSG::INFO << "Entries (Eq.): " << m_h1DVar->equivalentBinEntries()  << endreq;
00140         log << MSG::INFO << "Sum of Heights(In): "  << m_h1DVar->sumBinHeights()  << endreq;
00141         log << MSG::INFO << "Sum of Heights(Out): " << m_h1DVar->sumExtraBinHeights()  << endreq;
00142         log << MSG::INFO << "Sum of Heights(All): " << m_h1DVar->sumAllBinHeights() << endreq;
00143         log << MSG::INFO << "Min. Heights(In): "    << m_h1DVar->minBinHeight()  << endreq;
00144         log << MSG::INFO << "Max. Heights(In): "    << m_h1DVar->maxBinHeight()  << endreq;
00145   //Statistics:
00146         log << MSG::INFO << "mean: " << m_h1DVar->mean() << endreq;
00147         log << MSG::INFO << "rms: " <<  m_h1DVar->rms()  << endreq;
00148   //Print Histogram stream in ASCII on screen:  
00149         log << MSG::INFO << "Printing H1Var: " << endreq;
00150         histoSvc()->print( m_h1DVar );
00151 
00152   //2D HISTOGRAM STUFF
00153   log << MSG::INFO << "Info about Histogram 2D\n" << endreq;
00154   //General Info:
00155         log << MSG::INFO << "title: " << m_h2D->title() <<  endreq;
00156         //log << MSG::INFO << "label: " << m_h2D->label() <<  endreq;
00157         log << MSG::INFO << "dim:   " << m_h2D->dimension() << endreq;
00158         //log << MSG::INFO << "vers:  " << m_h2D->version()   << endreq;
00159   //Histo Info:
00160         log << MSG::INFO << "Entries (In): "  << m_h2D->entries()  << endreq;
00161         log << MSG::INFO << "Entries (Out): " << m_h2D->extraEntries()  << endreq;
00162         log << MSG::INFO << "Entries (All): " << m_h2D->allEntries()  << endreq;
00163         log << MSG::INFO << "Entries (Eq.): " << m_h2D->equivalentBinEntries()  << endreq;
00164         log << MSG::INFO << "Sum of Heights(In): "  << m_h2D->sumBinHeights()  << endreq;
00165         log << MSG::INFO << "Sum of Heights(Out): " << m_h2D->sumExtraBinHeights()  << endreq;
00166         log << MSG::INFO << "Sum of Heights(All): " << m_h2D->sumAllBinHeights() << endreq;
00167         log << MSG::INFO << "Min. Heights(In): "    << m_h2D->minBinHeight()  << endreq;
00168         log << MSG::INFO << "Max. Heights(In): "    << m_h2D->maxBinHeight()  << endreq;
00169   //Statistics:
00170         log << MSG::INFO << "meanX: " << m_h2D->meanX() << endreq;
00171         log << MSG::INFO << "meanY: " << m_h2D->meanY() << endreq;
00172         log << MSG::INFO << "rmsX: " <<  m_h2D->rmsX()  << endreq;
00173         log << MSG::INFO << "rmsY: " <<  m_h2D->rmsY()  << endreq;
00174   //Print Histogram stream in ASCII on screen:  
00175         log << MSG::INFO << "Printing H1Var: " << endreq;
00176         histoSvc()->print( m_h2D );
00177 
00178   //2DVar HISTOGRAM STUFF
00179   log << MSG::INFO << "Info about Histogram 2DVar\n" << endreq;
00180   //General Info:
00181         log << MSG::INFO << "title: " << m_h2DVar->title() <<  endreq;
00182         //log << MSG::INFO << "label: " << m_h2DVar->label() <<  endreq;
00183         log << MSG::INFO << "dim:   " << m_h2DVar->dimension() << endreq;
00184         //log << MSG::INFO << "vers:  " << m_h2DVar->version()   << endreq;
00185   //Histo Info:
00186         log << MSG::INFO << "Entries (In): "  << m_h2DVar->entries()  << endreq;
00187         log << MSG::INFO << "Entries (Out): " << m_h2DVar->extraEntries()  << endreq;
00188         log << MSG::INFO << "Entries (All): " << m_h2DVar->allEntries()  << endreq;
00189         log << MSG::INFO << "Entries (Eq.): " << m_h2DVar->equivalentBinEntries()  << endreq;
00190 
00191         log << MSG::INFO << "Sum of Heights(In): "  << m_h2DVar->sumBinHeights()  << endreq;
00192         log << MSG::INFO << "Sum of Heights(Out): " << m_h2DVar->sumExtraBinHeights()  << endreq;
00193         log << MSG::INFO << "Sum of Heights(All): " << m_h2DVar->sumAllBinHeights() << endreq;
00194         log << MSG::INFO << "Min. Heights(In): "    << m_h2DVar->minBinHeight()  << endreq;
00195         log << MSG::INFO << "Max. Heights(In): "    << m_h2DVar->maxBinHeight()  << endreq;
00196   //Statistics:
00197         log << MSG::INFO << "meanX: " << m_h2DVar->meanX() << endreq;
00198         log << MSG::INFO << "meanY: " << m_h2DVar->meanX() << endreq;
00199         log << MSG::INFO << "rmsX: " <<  m_h2DVar->rmsX()  << endreq;
00200         log << MSG::INFO << "rmsY: " <<  m_h2DVar->rmsY()  << endreq;
00201   //Print Histogram stream in ASCII on screen:  
00202 //      log << MSG::INFO << "Printing H2Var: " << endreq;
00203 //      histoSvc()->print( m_h2DVar );
00204 
00205   // Create X projection of the Pt versus P histogram m_hPtvsP
00206   IHistogram1D* xProj  = histoSvc()->histogramFactory()->projectionX( "Proj/101",  *m_h2D );
00207         IHistogram1D* yProj  = histoSvc()->histogramFactory()->projectionY( "Proj/102" , *m_h2D );
00208         IHistogram1D* xSlice = histoSvc()->histogramFactory()->sliceX( "Slice/101" , *m_h2D, 10);
00209         IHistogram1D* ySlice = histoSvc()->histogramFactory()->sliceY( "Slice/102" , *m_h2D, 20);
00210         log << MSG::INFO << "Projection X" << endreq;
00211   histoSvc()->print( xProj );
00212         log << MSG::INFO << "Projection Y" << endreq;
00213   histoSvc()->print( yProj );
00214         // Print the slices
00215         log << MSG::INFO << "Slice X:" << endreq;
00216   histoSvc()->print( xSlice );
00217         log << MSG::INFO << "Slice Y:" << endreq;
00218   histoSvc()->print( ySlice );
00219          
00220   return StatusCode::SUCCESS;
00221 }

StatusCode HistoAlgorithm::initialize  ) 
 

00026 {
00027   MsgStream log( msgSvc(), name() );
00028   int i;
00029   std::vector<double> edges;
00030   for( i = 0; i <= 10; i++) edges.push_back( double(i)*double(i) );
00031 
00032   /*
00033   // Getting existing histograms
00034   SmartDataPtr<IHistogram1D> h1(histoSvc(),"InFile/1");
00035   if( h1 ) {
00036     log << MSG::INFO << "Got histogram from file" << endreq;
00037     histoSvc()->print( h1);
00038   } else {
00039     log << MSG::ERROR << "Histogram h1 not found" << endreq;
00040   }
00041   */
00042 
00043   log << MSG::INFO << "Booking Histograms" << endreq;
00044 
00045   // Book 1D histogram with fixed and variable binning
00046   m_h1D    = histoSvc()->book( "1", "1D fix binning", 50, 0., 100. );
00047   m_h1DVar = histoSvc()->book( "Var/1", "1D variable binning", edges );
00048 
00049   m_h2D    = histoSvc()->book( "2", "2D fix binning", 50, 0., 100.,
00050                                                       50, 0., 100.  );
00051   m_h2DVar = histoSvc()->book( "Var/2", "2D variable binning", edges, edges );
00052 
00053   m_h3D    = histoSvc()->book( "3", "3D fix binning", 50, 0., 100.,
00054                                                       50, 0., 100.,
00055                                                       10, 0., 100.  );
00056   m_h3DVar = histoSvc()->book( "Var/3", "3D variable binning", edges,
00057                                                                edges,
00058                                                                edges );
00059   if( 0 == m_h1D ||0 == m_h2D || 0 == m_h3D ||
00060       0 == m_h1DVar ||0 == m_h2DVar ||0 == m_h3DVar   ) { 
00061     log << MSG::ERROR << "----- Cannot book or register histograms -----" << endreq;
00062     return StatusCode::FAILURE;  
00063   }
00064   log << MSG::INFO << "Finished booking Histograms" << endreq;
00065 
00066   return StatusCode::SUCCESS;
00067 }


Member Data Documentation

IHistogram1D* HistoAlgorithm::m_h1D [private]
 

IHistogram1D* HistoAlgorithm::m_h1DVar [private]
 

IHistogram2D* HistoAlgorithm::m_h2D [private]
 

IHistogram2D* HistoAlgorithm::m_h2DVar [private]
 

IHistogram3D* HistoAlgorithm::m_h3D [private]
 

IHistogram3D* HistoAlgorithm::m_h3DVar [private]
 


The documentation for this class was generated from the following files:
Generated on Wed Feb 2 16:17:04 2011 for BOSS6.5.5 by  doxygen 1.3.9.1