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

PulserFromRawSummaryList.cxx

Go to the documentation of this file.
00001 
00002 // $Id: PulserFromRawSummaryList.cxx,v 1.3 2003/09/03 09:31:16 rjn Exp $
00003 //
00004 // PulserFromRawSummaryList.cxx
00005 //
00006 // List of averages of pulser summaries
00007 //
00008 // Author: Ryan Nichol
00009 //
00010 //
00012 
00013 
00014 #include "TNamed.h"
00015 #include "MessageService/MsgService.h"
00016 #include "Validity/VldContext.h"
00017 #include "PulserCalibration/PulserFromRawSummaryList.h"
00018 #include "PulserCalibration/PulserSummary.h"
00019 #include "RawData/RawLIAdcSummaryBlock.h"
00020 #include "RawData/RawLIAdcSummary.h"
00021 #include "RawData/RawDigit.h"
00022 #include "Plex/PlexHandle.h"
00023 #include "Plex/PlexusABC.h"
00024 #include "RawData/RawChannelId.h"
00025 #include <map>
00026 #include <set>
00027 #include <algorithm>
00028 #include <cassert>
00029 
00030 ClassImp(PulserFromRawSummaryList)
00031   
00032   // ............
00033 
00034 CVSID("$Id: PulserFromRawSummaryList.cxx,v 1.3 2003/09/03 09:31:16 rjn Exp $");
00035 
00036 PulserFromRawSummaryList::PulserFromRawSummaryList() : 
00037   TNamed("PulserFromRawSummaryList","PulserFromRawSummaryList")
00038 {
00039   MSG("Pulser",Msg::kVerbose) <<" PulserFromRawSummaryList ctor \n";
00040   fLowPin = new PulserSummary();
00041   fHighPin = new PulserSummary();
00042   fTriggers=0;
00043   fUsePlex = false;
00044 }
00045 
00046 PulserFromRawSummaryList::~PulserFromRawSummaryList()
00047 {
00048   MSG("Pulser",Msg::kVerbose) <<" PulserFromRawSummaryList dtor \n";
00049   delete fLowPin;
00050   delete fHighPin;
00051 }
00052 
00053 
00054 PulserFromRawSummaryList::PulserFromRawSummaryList(const RawDigitDataBlock &rawddb, 
00055                                              const PulserFromRawLiBlock &rawsum) : 
00056   TNamed("PulserFromRawSummaryList","PulserFromRawSummaryList")
00057 {
00058   MSG("Pulser",Msg::kVerbose) <<
00059     " PulserFromRawSummaryList constructing from RawDigitDataBlock \n";
00060   fLowPin = new PulserSummary();
00061   fHighPin = new PulserSummary();
00062   fTriggers=0;
00063   fNumPulses = rawsum.GetPulses();
00064   fLed=rawsum.GetLed();
00065   fPulserBox=rawsum.GetPulserBox();
00066   fHeight=rawsum.GetPulseHeight();
00067   fWidth=rawsum.GetPulseWidth();
00068   fPointIndex=rawsum.GetCalibPoint();
00069   fExpectedPoints=rawsum.GetCalibType(); // Will be 1 for dougpoint, 
00070                                          // more than 1 for gaincurve
00071   fAggregateNo = PlexLedId(rawsum.GetVldContext().GetDetector(),
00072                            fPulserBox, fLed);
00073   fIdent = fLed + 100 * fExpectedPoints;
00074   fUsePlex = false;
00075   fValidity = rawsum.GetVldContext();
00076   this->Add(rawddb,rawsum);
00077 }
00078 
00079 VldContext PulserFromRawSummaryList::GetVldContext() const
00080 {
00081   return fValidity;
00082 }
00083 
00084 
00085 
00086 void PulserFromRawSummaryList::Add(const RawDigitDataBlock &rawddb, 
00087                                 const PulserFromRawLiBlock &rawsum)
00088 {
00089   // If we get here, we should be adding the same kinds of pulse
00090   // but just in case...
00091   MSG("Pulser",Msg::kVerbose) <<"LED "<<fLed<<"  "<<rawsum.GetLed()<<endl;
00092   MSG("Pulser",Msg::kVerbose) <<"H   "<<fHeight<<"  "<<rawsum.GetPulseHeight()<<endl;
00093   MSG("Pulser",Msg::kVerbose) <<"W   "<<fWidth<<"  "<<rawsum.GetPulseWidth()<<endl;
00094 
00095   assert(fLed==rawsum.GetLed());
00096   assert(fPulserBox==rawsum.GetPulserBox());
00097   assert(fHeight==rawsum.GetPulseHeight());
00098   assert(fWidth==rawsum.GetPulseWidth());
00099   assert(fPointIndex==rawsum.GetCalibPoint());
00100   assert(fExpectedPoints==rawsum.GetCalibType());
00101 
00102   //Get validity context
00103   VldContext vldc(rawsum.GetVldContext());
00104   PlexHandle plex(vldc);
00105 
00106   int numTriggers=0;
00107   std::pair<PlexPinDiodeId,PlexPinDiodeId> myPins = 
00108      plex.GetPinDiodeIds(fAggregateNo); // hi, low
00109   MSG("Pulser",Msg::kVerbose)<< "We have "
00110                          << rawddb.GetNumberOfDigits() 
00111                          << " digits"<<endl;
00112   TIter rawit = rawddb.GetDatumIter();
00113 
00114   uIntNearMap tempNearMap;
00115   uIntNearMap::iterator tempNearIter;
00116   while (RawDigit *rd = (RawDigit *) rawit()) {
00117      
00118      RawChannelId rcid = rd->GetChannel(); 
00119      ReadoutType::Readout_t rt = plex.GetReadoutType(rcid);
00120      switch (rcid.GetElecType()) {
00121          case (ElecType::kQIE):
00122              if(tempNearMap.find(rcid.GetEncoded())==
00123                 tempNearMap.end()) {
00124                  tempNearMap[rcid.GetEncoded()].New(*rd);
00125              }
00126              else {
00127                  tempNearIter=tempNearMap.find(rcid.GetEncoded());
00128                  tempNearIter->second.Add(*rd);
00129              }
00130              break;
00131          case (ElecType::kVA): 
00132              if (rt & ReadoutType::kScintStrip) {
00133                  MSG("Pulser",Msg::kVerbose) 
00134                      << "Got LI in strip at "<< rcid<<endl;
00135                  
00136                  // Find out which strip-end we are. At CalDet, this is
00137                  // a bit pointless, but...
00138                  PlexSEIdAltL altlist = plex.GetSEIdAltL(rcid);
00139                  for (PlexSEIdAltL::iterator it = altlist.begin(); 
00140                       it!=altlist.end(); it++) {
00141                      PlexStripEndId seid = (*it).GetSEId();
00142                      if (plex.GetLedId(seid) == fAggregateNo) {
00143                          MSG("Pulser",Msg::kVerbose) << "Got LI in strip "
00144                                                    << seid << endl;
00145             
00146                          fNearMap[seid.BuildPlnStripEndKey()].AddDigit(*rd,seid);
00147                      }
00148                      else if (plex.GetLedId(seid.GetOppositeSEId())==
00149                               fAggregateNo) {
00150                          MSG("Pulser",Msg::kVerbose) << "Got LI in strip "
00151                                                    << seid << endl;
00152                          
00153                          fFarMap[seid.BuildPlnStripEndKey()].AddDigit(*rd,seid);
00154                      }
00155                      else {
00156                          // Crosstalk or such
00157                          //     MSG("Pulser",Msg::kVerbose) << "Xtalk "<<rcid<<endl; 
00158                      }
00159                  }
00160              }
00161              else if (rt & ReadoutType::kPinDiode) {
00162                  MSG("Pulser",Msg::kVerbose) << "Got LI in PIN at "
00163                                            << rd->GetChannel()<< endl;
00164                  
00165                  PlexPinDiodeId pinid = plex.GetPinDiodeId(rcid);
00166                  if (pinid==myPins.first) {
00167                      //High gain PIN
00168                      fHighPin->AddDigit(*rd,pinid);
00169                  }
00170                  else if (pinid==myPins.second) {
00171                      //Low Gain PIN
00172                      fLowPin->AddDigit(*rd,pinid);
00173                  }
00174                  // Else not this LED's PIN
00175              }
00176              else if (rt & ReadoutType::kFlashTrigPMT) {
00177                  MSG("Pulser",Msg::kVerbose) 
00178                      << "Got LI in trigger at "<<rd->GetChannel()<<endl;
00179                  numTriggers++;
00180              }
00181              
00182              break;
00183          default:
00184              break;
00185      }
00186      
00187   }
00188   for(tempNearIter = tempNearMap.begin(); 
00189       tempNearIter != tempNearMap.end(); ++tempNearIter) {
00190 
00191       PulserNearDigit nd = tempNearIter->second;
00192       RawChannelId rcid = nd.GetChannel();
00193  
00194       ReadoutType::Readout_t rt2 = plex.GetReadoutType(rcid); 
00195       if (rt2 & ReadoutType::kScintStrip) {
00196           MSG("Pulser",Msg::kVerbose) 
00197               << "Got LI in strip at "<< rcid<<endl;
00198           
00199           // Find out which strip-end we are. At CalDet, this is
00200           // a bit pointless, but...
00201           PlexSEIdAltL altlist = plex.GetSEIdAltL(rcid);
00202           for (PlexSEIdAltL::iterator it = altlist.begin(); 
00203                it!=altlist.end(); it++) {
00204               PlexStripEndId seid = (*it).GetSEId();
00205               if (plex.GetLedId(seid) == fAggregateNo) {
00206                   MSG("Pulser",Msg::kVerbose) << "Got LI in strip "
00207                                             << seid << endl;
00208                   
00209                   fNearMap[seid.BuildPlnStripEndKey()].AddDigit(nd,seid);
00210               }
00211               else if (plex.GetLedId(seid.GetOppositeSEId())==
00212                        fAggregateNo) {
00213                   MSG("Pulser",Msg::kVerbose) << "Got LI in strip "
00214                                             << seid << endl;
00215                   
00216                   fFarMap[seid.BuildPlnStripEndKey()].AddDigit(nd,seid);
00217               }
00218               else {
00219                   // Crosstalk or such
00220                   //    MSG("Pulser",Msg::kVerbose) << "Xtalk "<<rcid<<endl; 
00221               }
00222           }
00223       }
00224      
00225   }
00226   
00227   fTriggers +=numTriggers;
00228   MSG("Pulser",Msg::kDebug) << "Trig PMT: "<<numTriggers<<" of "<<fTriggers<<" triggers\n";
00229   
00230 }
00231 
00232 void PulserFromRawSummaryList::Finish()
00233 {
00234   // Do zero correction here.
00235   for (std::map<Int_t,PulserSummary>::iterator it = fNearMap.begin();
00236        it!=fNearMap.end(); it++) (*it).second.Finish(fTriggers);
00237   for (std::map<Int_t,PulserSummary>::iterator it = fFarMap.begin();
00238        it!=fFarMap.end(); it++) (*it).second.Finish(fTriggers);
00239   fLowPin->Finish(fTriggers);
00240   fHighPin->Finish(fTriggers);
00241 }

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