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

HadMon.cxx

Go to the documentation of this file.
00001 #include "HadMon.h"
00002 
00003 #include <cmath>
00004 
00005 const int HadMon::NROWCOLS = 7;
00006 const double HadMon::ROWCOL_SPACING = 11.43; // cm
00007 
00008 int HadMon::Index(int channel)
00009 {
00010     // hard code channel map.
00011     // Channel numbers are 1-1 with buffer indices except:
00012     // - channels start with 1, indices start with 0
00013     // - buffer starts at index 104
00014     // - vert/horiz blocks are reversed.  Ie:
00015     //   channel = (01-48)(49-96)
00016     //   buffer  = (48-95)(00-47)
00017 
00018     if (channel < 1 || channel > 49) return -1;
00019     int offset = -1;
00020     if (channel == 49) offset = 104;
00021     else offset = channel + 151;
00022     return offset - 104;
00023 }
00024 
00025 int HadMon::Channel(int row, int col)
00026 {
00027     return col + (row-1)*NROWCOLS;
00028 }
00029 
00030 double HadMon::PixelPosition(int rowcol)
00031 {
00032     return (rowcol-4)*ROWCOL_SPACING;   // cm
00033 }
00034 
00035 double HadMon::GetStats(double& xmean, double &ymean,
00036                         double &xrms, double &yrms)
00037 {
00038     double qy=0,qx=0,q=0,q2y2=0,q2x2=0,max=0;
00039     for (int col=1; col<=7; ++col) {
00040         for (int row=1; row <= 7; ++row) {
00041             double X = this->PixelPosition(col);
00042             double Y = this->PixelPosition(row);
00043             int index = Index(Channel(row,col));
00044             double Q = this->GetVoltage(index);
00045 
00046             q += Q;
00047             qx += Q*X;
00048             qy += Q*Y;
00049             q2x2 += Q*X*Q*X;
00050             q2y2 += Q*Y*Q*Y;
00051             if (max<q) max = q;
00052         }
00053     }
00054     if (q == 0.0) return q;
00055 
00056     xmean = qx/q;
00057     ymean = qy/q;
00058     xrms = sqrt(q2x2)/fabs(q);
00059     yrms = sqrt(q2y2)/fabs(q);
00060     return q;
00061 }

Generated on Thu Nov 1 11:50:55 2007 for loon by  doxygen 1.3.9.1