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

SimPixelTimeBucket.cxx

Go to the documentation of this file.
00001 //
00002 //
00003 // SimPixelTimeBucket
00004 //
00005 // Description: This class holds all the data relevant to a
00006 // single PMT pixel (all spots) at a given instant in time (a bucket).
00007 // 
00008 // Data members:
00009 // fNSpots       number of spots in the pixel (1 or 8 typically)
00010 // fDigiPE       a list of the digiPE that should have hit this pixel
00011 // fDigiPEXtalk  a list of the digiPE that DID hit this pixel, after crosstalk.
00012 // fTruth        a set of bits representing what happened.
00013 // fPE           the number of digiPE that should have hit this pixel
00014 // fPEXtalk      the number of digiPE that did hit this pixel, after crosstalk
00015 // fCharge       the charge on the anode in this bucket, in Munits
00016 // fTime         the earilest time of all the DigiPE in this bucket.
00017 
00018 #include "DetSim/SimPixelTimeBucket.h"
00019 #include "MessageService/MsgService.h"
00020 #include "Conventions/Munits.h"
00021 
00022 CVSID("$Id: SimPixelTimeBucket.cxx,v 1.11 2008/11/18 17:31:02 rhatcher Exp $");
00023 
00024 ClassImp(SimPixelTimeBucket)
00025 
00026 int SimPixelTimeBucket::fsTotalNumber = 0;
00027 
00028 SimPixelTimeBucket::SimPixelTimeBucket()
00029 {
00030   // Do not use!  Only for I/O.
00031   fsTotalNumber++;
00032 }
00033 
00034 
00035 SimPixelTimeBucket::SimPixelTimeBucket( Int_t nSpots ) :
00036   fNSpots(nSpots),
00037   fDigiPE(fNSpots+1),
00038   fDigiPEXtalk(fNSpots+1),
00039   fPE(fNSpots+1),
00040   fPEXtalk(fNSpots+1),
00041   fTruth(DigiSignal::kUnknown),
00042   fCharge(0),
00043   fTime(1e9)
00044 {
00045   fsTotalNumber++;
00046 
00047   // Fill with zeros.
00048   for(int i=0;i<=fNSpots;i++) {
00049     fPE[i]=0;
00050     fPEXtalk[i]=0;
00051   }
00052 }
00053 
00054 SimPixelTimeBucket::~SimPixelTimeBucket()
00055 {
00056   fsTotalNumber--;
00057 }
00058 
00059 void  SimPixelTimeBucket::SetCharge( Float_t charge )
00060 {
00061   fCharge = charge;
00062   //if(charge<-100*Munits::fC) {
00063   //  cout << "Charge got set to " << fCharge/Munits::fC << endl;
00064   // }
00065 }
00066 
00067 void  SimPixelTimeBucket::AddCharge( Float_t charge )
00068 {
00069   fCharge += charge;
00070   //if(fCharge<-100*Munits::fC) {
00071   //  cout << "Charge got added to " << fCharge/Munits::fC << " with increment " << charge/Munits::fC << endl;
00072   //}
00073 }
00074 
00075 
00076 
00077 Float_t SimPixelTimeBucket::GetTotalPE()
00078 {
00079   float tot = 0;
00080   for(int i=1;i<=fNSpots;i++) {
00081     tot += fPE[i];
00082   }
00083   return tot;
00084 }
00085 
00086 Float_t SimPixelTimeBucket::GetTotalPEXtalk()
00087 {
00088   float tot = 0;
00089   for(int i=1;i<=fNSpots;i++) {
00090     tot += fPEXtalk[i];
00091   }
00092   return tot;
00093 }
00094 
00095 
00096 
00097 void SimPixelTimeBucket::AddDigiPE(const DigiPE* digipe, Int_t spot)
00098 {
00099   //
00100   // Add DigiPE to the bucket.  Use the provided spot number instead of the 
00101   // PlexPixelSpotId in the digipe, because the PlexPixelSpotID is simply wrong,
00102   // if accurately wrong.
00103   //
00104   
00105   //Int_t spot = digipe->GetPixelSpotId().GetSpot();
00106   if( (spot > fNSpots) || (spot < 1) ) {
00107     // Problem!
00108     MSG("DetSim",Msg::kWarning) << "AddDigiPE() Invalid Pixel Spot number!" << endl;
00109     return;
00110   }
00111   if(digipe->GetTime() < fTime) fTime = digipe->GetTime();
00112   
00113   // This adds the hit info and the pe pointer.
00114   fPE[spot] += 1;                    // True number of PE.. don't touch this again.
00115   
00116   fDigiPE[spot].insert(std::pair<Double_t,const DigiPE*>(digipe->GetTime(), digipe));
00117   
00118   // This is a real hit.
00119   
00120   fTruth |= digipe->GetSource();
00121 }
00122 
00123 
00124 DigiSignal* SimPixelTimeBucket::CreateSignal() 
00125 {
00126   // Creates a new digiSignal with all the attendant data.
00127   // Caller becomes responsible for ownership.
00128   //
00129   DigiSignal* s = new DigiSignal();
00130   // Set up the charge
00131   s->SetCharge(fCharge);
00132   s->SetTruth(fTruth);
00133 
00134   // Add the PEs.
00135   for(UInt_t i = 0; i<fDigiPEXtalk.size(); i++) {
00136     PeList_t::iterator it = fDigiPEXtalk[i].begin();
00137     for( ; it!= fDigiPEXtalk[i].end() ; it++) {
00138       s->AddDigiPE(it->second);
00139     }
00140   }
00141 
00142   return s;
00143 }

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