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

PulserSummary.cxx

Go to the documentation of this file.
00001 
00002 // $Id: PulserSummary.cxx,v 1.8 2007/03/01 17:06:40 rhatcher Exp $
00003 //
00004 // PulserSummary.cxx
00005 //
00006 // List of averages of pulser summaries
00007 //
00008 // Author: Phil Adamson 4/2001
00009 //
00010 // $Log: PulserSummary.cxx,v $
00011 // Revision 1.8  2007/03/01 17:06:40  rhatcher
00012 // fix a bunch of CVSID lines.  The quoted string must be "$Id: $" (especially
00013 // common is to leave off the trailing $).
00014 //
00015 // Revision 1.7  2004/09/08 21:50:51  pa
00016 // Checkin of new PulserCalibration version. MIght even work
00017 //
00018 // Revision 1.6  2003/02/06 20:02:59  rjn
00019 // Modified PulserSummary.h and added classes to make PulserSummary objects from Raw Data.
00020 //
00021 // Revision 1.5  2002/10/11 10:38:12  phil.adamson
00022 // Add MakeLin, some minor fixups
00023 //
00024 // Revision 1.4  2002/10/07 10:07:43  phil.adamson
00025 // Try to fix the occasional nan...
00026 //
00027 // Revision 1.3  2002/09/25 08:54:08  phil.adamson
00028 // Add Ryan's bits to make PulserSummary objects from Raw Data
00029 //
00030 // Revision 1.2  2002/08/07 16:16:52  phil.adamson
00031 // Minor cosmetic details, plus provide ZeroCorr() methods in PulserSummary.
00032 // Phil.
00033 //
00034 //
00036 
00037 #include "MessageService/MsgService.h"
00038 #include "PulserCalibration/PulserSummary.h"
00039 #include "RawData/RawLIAdcSummary.h"
00040 #include <cmath>
00041 #include <cassert>
00042 
00043 CVSID("$Id: PulserSummary.cxx,v 1.8 2007/03/01 17:06:40 rhatcher Exp $");
00044 
00045 ClassImp(PulserSummary)
00046   
00047   // ............
00048 
00049 PulserSummary::PulserSummary()
00050 {
00051   MSG("Pulser",Msg::kVerbose) << "PulserSummary ctor\n";
00052   fMean=0;
00053   fMeanSquare=0;
00054   fRMS=0;
00055   fNumEntries=0;
00056   fChannel=0; // empty object has channel 0
00057 }
00058 
00059 PulserSummary::~PulserSummary()
00060 {
00061 
00062 }
00063 
00064 void PulserSummary::Add(RawLIAdcSummary &from, const PlexPinDiodeId &pinid)
00065 {
00066   fPinId = pinid;
00067   fReadoutType = ReadoutType::kPinDiode;
00068   MSG("Pulser",Msg::kVerbose) << "PIN "<<pinid<<" has "<<fMean<<" "<<fNumEntries<<" "<<fNumTriggers<<endl;
00069   Add(from);
00070 }
00071 
00072 void PulserSummary::AddDigit(RawDigit &from, 
00073                              const PlexPinDiodeId &pinid)
00074 {
00075    fPinId = pinid;
00076    fReadoutType = ReadoutType::kPinDiode;
00077    MSG("Pulser",Msg::kVerbose) << "PIN "<<pinid<<" has "<<fMean<<" "<<fNumEntries<<" "<<fNumTriggers<<endl;
00078    AddDigit(from);
00079 }
00080 
00081 void PulserSummary::Add(RawLIAdcSummary &from, const PlexStripEndId &seid)
00082 {
00083   fSEId = seid;
00084   fReadoutType = ReadoutType::kScintStrip;
00085   Add(from);
00086 }
00087 
00088 void PulserSummary::AddDigit(RawDigit &from, const PlexStripEndId &seid)
00089 {
00090   fSEId = seid;
00091   fReadoutType = ReadoutType::kScintStrip;
00092   AddDigit(from);
00093 }
00094 
00095 void PulserSummary::AddDigit(PulserNearDigit &from, const PlexStripEndId &seid)
00096 {
00097   fSEId = seid;
00098   fReadoutType = ReadoutType::kScintStrip;
00099   AddDigit(from);
00100 }
00101 
00102 void PulserSummary::Add(RawLIAdcSummary &from)
00103 {
00104    MSG("Pulser",Msg::kVerbose) << "fChannel " << RawChannelId(fChannel)
00105                                << " and Channel is: " << from.GetChannel()
00106                                << endl; 
00107    if (fChannel==0) {
00108       fChannel=from.GetChannel().GetEncoded();
00109    } 
00110    MSG("Pulser",Msg::kVerbose) << "fChannel " << RawChannelId(fChannel)
00111                                << " and Channel is: " << from.GetChannel()
00112                               << endl; 
00113   assert(from.GetChannel().GetEncoded()==fChannel);
00114   Int_t tempEnd=(int)fSEId.GetEnd();
00115   if(fSEId.GetPlane()==10 && fSEId.GetStrip()==4 && tempEnd==1) {
00116      MSG("Pulser",Msg::kVerbose) << "My Channel " 
00117                                  << "\tMean: " << from.GetMean()
00118                                  << "\tRMS: " <<  from.GetRms()
00119                                  << "\tEntries: " << from.GetEntries() << endl;
00120   }
00121 
00122  
00123     MSG("Pulser",Msg::kVerbose) << "PulserSummary::Add() Got channel "<<fChannel<<endl;
00124     fMean = 
00125       fNumEntries*(1.0/(fNumEntries + from.GetEntries())) * fMean 
00126       + from.GetEntries()*(1.0/(fNumEntries + from.GetEntries())) 
00127       * from.GetMean();
00128     fMeanSquare = 
00129       fNumEntries*(1.0/(fNumEntries + from.GetEntries())) *fMeanSquare
00130       + from.GetEntries()*(1.0/(fNumEntries + from.GetEntries())) 
00131       * (float(from.GetRms())*from.GetRms()+float(from.GetMean())*from.GetMean());
00132     fNumEntries +=from.GetEntries();
00133 }
00134 
00135 void PulserSummary::AddDigit(RawDigit &from)
00136 {
00137    MSG("Pulser",Msg::kVerbose) << "fChannel " << RawChannelId(fChannel)
00138                                << " and Channel is: " << from.GetChannel()
00139                                << endl; 
00140    if (fChannel==0) {
00141       fChannel=from.GetChannel().GetEncoded();
00142    } 
00143    MSG("Pulser",Msg::kVerbose) << "fChannel " << RawChannelId(fChannel)
00144                                << " and Channel is: " << from.GetChannel()
00145                                << endl; 
00146    assert(from.GetChannel().GetEncoded()==fChannel);
00147    //Int_t tempEnd=(int)fSEId.GetEnd();
00148    MSG("Pulser",Msg::kVerbose) 
00149       << "PulserSummary::Add() Got channel "<<fChannel<<endl;
00150    fMean = (float(fNumEntries)/(float(fNumEntries)+1.0))*fMean +
00151       (1.0/(float(fNumEntries)+1.0))*from.GetADC();
00152    fMeanSquare = (float(fNumEntries)/(float(fNumEntries)+1.0))*fMeanSquare +
00153       (1.0/(float(fNumEntries)+1.0))*(from.GetADC()*from.GetADC());
00154    fNumEntries ++;
00155 }
00156 
00157 void PulserSummary::AddDigit(PulserNearDigit &from)
00158 {
00159    MSG("Pulser",Msg::kVerbose) << "fChannel " << RawChannelId(fChannel)
00160                                << " and Channel is: " << from.GetChannel()
00161                                << endl; 
00162    if (fChannel==0) {
00163       fChannel=from.GetChannel().GetEncoded();
00164    } 
00165    MSG("Pulser",Msg::kVerbose) << "fChannel " << RawChannelId(fChannel)
00166                                << " and Channel is: " << from.GetChannel()
00167                                << endl; 
00168    assert(from.GetChannel().GetEncoded()==fChannel);
00169    //Int_t tempEnd=(int)fSEId.GetEnd();
00170    MSG("Pulser",Msg::kVerbose) 
00171       << "PulserSummary::Add() Got channel "<<fChannel<<endl;
00172    fMean = (float(fNumEntries)/(float(fNumEntries)+1.0))*fMean +
00173       (1.0/(float(fNumEntries)+1.0))*from.GetADC();
00174    fMeanSquare = (float(fNumEntries)/(float(fNumEntries)+1.0))*fMeanSquare +
00175       (1.0/(float(fNumEntries)+1.0))*(from.GetADC()*from.GetADC());
00176    fNumEntries ++;
00177 }
00178 
00179 void PulserSummary::Finish(int numTriggers)
00180 {
00181    
00182   if ((fMeanSquare - fMean*fMean)>1) {
00183     fRMS = std::sqrt(fMeanSquare - fMean*fMean);
00184   }
00185   else {
00186     fRMS = 1;
00187   }
00188    fNumTriggers = numTriggers;
00189    fMeanZC = fMean * float(fNumEntries)/float(numTriggers);
00190    float ms = fMeanSquare * float(fNumEntries)/float(numTriggers) -
00191      fMeanZC*fMeanZC;
00192    if (ms>1) {
00193      fRMSZC = std::sqrt(ms);
00194    }
00195    else {
00196      fRMSZC = 1;
00197    }
00198    MSG("Pulser",Msg::kVerbose) 
00199       << "PulserSummary::Finish() finished summary in channel: "
00200       << fChannel << " Mean:  " << fMean << " RMS: " 
00201       << fRMS << " NumEntries: " << fNumEntries << endl;
00202 }
00203 
00204 
00205 
00206 
00207 
00208 void PulserSummary::SetPinDiodeId(PlexPinDiodeId pin)
00209 {
00210   fPinId = pin;
00211 
00212 }

Generated on Mon Feb 15 11:07:27 2010 for loon by  doxygen 1.3.9.1