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

PulserSummaryList.cxx

Go to the documentation of this file.
00001 
00002 // $Id: PulserSummaryList.cxx,v 1.7 2006/04/19 20:00:55 rhatcher Exp $
00003 //
00004 // PulserSummaryList.cxx
00005 //
00006 // List of averages of pulser summaries
00007 //
00008 // Author: Phil Adamson 4/2001
00009 //
00010 // $Log: PulserSummaryList.cxx,v $
00011 // Revision 1.7  2006/04/19 20:00:55  rhatcher
00012 // convert DetectorType:: to Detector:: everywhere.
00013 //
00014 // Revision 1.6  2004/11/30 07:56:25  rhatcher
00015 // react to modified RawChannelId ctor
00016 //
00017 // Revision 1.5  2004/09/08 21:50:51  pa
00018 // Checkin of new PulserCalibration version. MIght even work
00019 //
00020 // Revision 1.4  2004/09/03 17:31:12  phil.adamson
00021 //
00022 //
00023 // Fix breakage introduced by change to RawLIAdcSummaryBlock.h
00024 //
00025 // Revision 1.3  2002/10/11 10:38:12  phil.adamson
00026 // Add MakeLin, some minor fixups
00027 //
00028 // Revision 1.2  2002/08/07 16:16:52  phil.adamson
00029 // Minor cosmetic details, plus provide ZeroCorr() methods in PulserSummary.
00030 // Phil.
00031 //
00032 //
00034 
00035 
00036 #include "TNamed.h"
00037 #include "MessageService/MsgService.h"
00038 #include "Validity/VldContext.h"
00039 #include "PulserCalibration/PulserSummaryList.h"
00040 #include "PulserCalibration/PulserSummary.h"
00041 #include "RawData/RawLIAdcSummaryBlock.h"
00042 #include "RawData/RawLIAdcSummary.h"
00043 #include "Plex/PlexHandle.h"
00044 #include "Plex/PlexusABC.h"
00045 #include "RawData/RawChannelId.h"
00046 #include <map>
00047 #include <set>
00048 #include <algorithm>
00049 #include <cassert>
00050 
00051 ClassImp(PulserSummaryList)
00052   
00053   // ............
00054 
00055 CVSID("$Id: PulserSummaryList.cxx,v 1.7 2006/04/19 20:00:55 rhatcher Exp $");
00056 
00057 PulserSummaryList::PulserSummaryList() : 
00058   TNamed("PulserSummaryList","PulserSummaryList")
00059 {
00060   MSG("Pulser",Msg::kVerbose) <<" PulserSummaryList ctor \n";
00061   fLowPin = new PulserSummary();
00062   fHighPin = new PulserSummary();
00063   fTriggers=0;
00064   fUsePlex = false;
00065 }
00066 
00067 PulserSummaryList::~PulserSummaryList()
00068 {
00069   MSG("Pulser",Msg::kVerbose) <<" PulserSummaryList dtor \n";
00070   delete fLowPin;
00071   delete fHighPin;
00072 }
00073 
00074 
00075 PulserSummaryList::PulserSummaryList(const RawLIAdcSummaryBlock & rawsum) : 
00076   TNamed("PulserSummaryList","PulserSummaryList")
00077 {
00078   MSG("Pulser",Msg::kVerbose) <<
00079     " PulserSummaryList constructing from RawLIAdcSummary \n";
00080   fLowPin = new PulserSummary();
00081   fHighPin = new PulserSummary();
00082   fTriggers=0;
00083   fNumPulses = rawsum.GetPulses();
00084   fLed=rawsum.GetLed();
00085   fPulserBox=rawsum.GetPulserBox();
00086   fHeight=rawsum.GetPulseHeight();
00087   fWidth=rawsum.GetPulseWidth();
00088   fPointIndex=rawsum.GetCalibPoint();
00089   fExpectedPoints=rawsum.GetCalibType(); // Will be 1 for dougpoint, 
00090                                          // more than 1 for gaincurve
00091   fAggregateNo = PlexLedId(rawsum.GetVldContext().GetDetector(),
00092                            fPulserBox, fLed);
00093   fIdent = fLed + 100 * fExpectedPoints;
00094   fUsePlex = false;
00095   fValidity = rawsum.GetVldContext();
00096  this->Add(rawsum);
00097 }
00098 
00099 VldContext PulserSummaryList::GetVldContext() const
00100 {
00101   return fValidity;
00102 }
00103 
00104 
00105 
00106 void PulserSummaryList::Add(const RawLIAdcSummaryBlock &rawsum)
00107 {
00108   // If we get here, we should be adding the same kinds of pulse
00109   // but just in case...
00110   MSG("Pulser",Msg::kVerbose) <<"LED "<<fLed<<"  "<<rawsum.GetLed()<<endl;
00111   MSG("Pulser",Msg::kVerbose) <<"H   "<<fHeight<<"  "<<rawsum.GetPulseHeight()<<endl;
00112   MSG("Pulser",Msg::kVerbose) <<"W   "<<fWidth<<"  "<<rawsum.GetPulseWidth()<<endl;
00113 
00114   assert(fLed==rawsum.GetLed());
00115   assert(fPulserBox==rawsum.GetPulserBox());
00116   assert(fHeight==rawsum.GetPulseHeight());
00117   assert(fWidth==rawsum.GetPulseWidth());
00118   assert(fPointIndex==rawsum.GetCalibPoint());
00119   assert(fExpectedPoints==rawsum.GetCalibType());
00120 
00121   //Get validity context
00122   VldContext vldc(rawsum.GetVldContext());
00123   PlexHandle plex(vldc);
00124 
00125   int numTriggers=0;
00126   std::pair<PlexPinDiodeId,PlexPinDiodeId> myPins = 
00127      plex.GetPinDiodeIds(fAggregateNo); // hi, low
00128   fHighPin->SetPinDiodeId(myPins.first);
00129   fLowPin->SetPinDiodeId(myPins.second);
00130   //myGetPinDiodeIds(plex,fAggregateNo);
00131 
00132   MSG("Pulser",Msg::kVerbose)<<"We have "<<rawsum.GetNumberOfSummaries() <<" summaries"<<endl;
00133   TIter rawit = rawsum.GetDatumIter(); 
00134   while (RawLIAdcSummary *rawch = 
00135          dynamic_cast<RawLIAdcSummary *>(rawit.Next())) {
00136       RawChannelId rcid = rawch->GetChannel();
00137       ReadoutType::Readout_t rt = plex.GetReadoutType(rcid);
00138       if (rawsum.GetNumberOfSummaries()<10) 
00139         MSG("Pulser",Msg::kVerbose) << "Channel "<<rcid<<endl; 
00140       if (rt & ReadoutType::kScintStrip) {
00141         MSG("Pulser",Msg::kVerbose) << "Got LI in strip at "<<rawch->GetChannel()<<endl;
00142         // Find out which strip-end we are. At CalDet, this is
00143         // a bit pointless, but...
00144         PlexSEIdAltL altlist = plex.GetSEIdAltL(rcid);
00145         for (PlexSEIdAltL::iterator it = altlist.begin(); 
00146              it!=altlist.end(); it++) {
00147           PlexStripEndId seid = (*it).GetSEId();
00148           
00149           if (plex.GetLedId(seid) == fAggregateNo) {
00150              MSG("Pulser",Msg::kVerbose) << "Got LI in strip "
00151                                          << seid << endl;
00152              // near end
00153              // MSG("Pulser",Msg::kVerbose) << "Near "<<rcid<<endl;
00154              fNearMap[seid.BuildPlnStripEndKey()].Add(*rawch,seid);
00155           }
00156           else if (plex.GetLedId(seid.GetOppositeSEId())==fAggregateNo) {
00157              MSG("Pulser",Msg::kVerbose) << "Got LI in strip "
00158                                          << seid << endl;
00159              // far end
00160              // MSG("Pulser",Msg::kVerbose) << "Far "<<rcid<<endl; 
00161              fFarMap[seid.BuildPlnStripEndKey()].Add(*rawch,seid);
00162           }
00163           else {
00164              // Crosstalk or such
00165              // MSG("Pulser",Msg::kVerbose) << "Xtalk "<<rcid<<endl; 
00166           }
00167         }
00168       }
00169       else if (rt & ReadoutType::kPinDiode) {
00170          MSG("Pulser",Msg::kVerbose) << "Got LI in PIN at "<<rawch->GetChannel()<<endl;
00171          PlexPinDiodeId pinid = plex.GetPinDiodeId(rcid);
00172          //     MSG("Pulser",Msg::kDebug)<<"PIN "<<rcid<<" is "<<pinid<<endl;
00173          if (pinid==myPins.first) {
00174             //High gain PIN
00175             //MSG("Pulser",Msg::kDebug)<<"High Gain PIN "<<rcid<<" is "<<pinid<<endl;
00176             fHighPin->Add(*rawch,pinid);
00177          }
00178          else if (pinid==myPins.second) {
00179             //Low Gain PIN
00180             //MSG("Pulser",Msg::kDebug)<<"Low Gain PIN "<<rcid<<" is "<<pinid<<endl;
00181             fLowPin->Add(*rawch,pinid);
00182          }
00183          //MSG("Pulser",Msg::kDebug)<<"Other PIN "<<pinid<<" with "<<rawch->GetEntries()<<endl;
00184          // Else not this LED's PIN
00185       }
00186       else if (rt & ReadoutType::kFlashTrigPMT) {
00187          MSG("Pulser",Msg::kVerbose) << "Got LI in trigger at "<<rawch->GetChannel()<<endl;
00188          numTriggers = max(numTriggers,int(rawch->GetEntries()));
00189       }
00190   }
00191   
00192   
00193   fTriggers +=numTriggers;
00194   MSG("Pulser",Msg::kDebug) << "Trig PMT: "<<numTriggers<<" of "<<fTriggers<<" triggers\n";
00195   
00196 }
00197 
00198 void PulserSummaryList::Finish()
00199 {
00200   // Do zero correction here.
00201   for (std::map<Int_t,PulserSummary>::iterator it = fNearMap.begin();
00202        it!=fNearMap.end(); it++) (*it).second.Finish(fTriggers);
00203   for (std::map<Int_t,PulserSummary>::iterator it = fFarMap.begin();
00204        it!=fFarMap.end(); it++) (*it).second.Finish(fTriggers);
00205   fLowPin->Finish(fTriggers);
00206   fHighPin->Finish(fTriggers);
00207 }
00208 
00209 
00210 //  std::pair<PlexPinDiodeId,PlexPinDiodeId> PulserSummaryList::myGetPinDiodeIds(PlexHandle plex, PlexLedId led)
00211 //  {
00212 //     Int_t highpinchads[6]={4146,4274,4402,4786,4914,5042};
00213 //     Int_t lowpinchads[6]={4114,4242,4370,4626,4882,5010};
00214 //     PlexPinDiodeId high = 
00215 //       plex.GetPinDiodeId(RawChannelId(Detector::kCalDet,ElecType::kVA,
00216 //                                   0,highpinchads[led.GetLedInBox()-1]));
00217 //     PlexPinDiodeId low = 
00218 //       plex.GetPinDiodeId(RawChannelId(Detector::kCalDet,ElecType::kVA,
00219 //                                   0,lowpinchads[led.GetLedInBox()-1]));
00220 //      return std::make_pair(high,low);
00221 //  }
00222 
00223 //  PlexLedId PulserSummaryList::myGetLedId(PlexHandle plex, PlexStripEndId seid)
00224 //  {
00225 //    int led = getLed(plex.GetRawChannelId(seid).GetCrate(),seid.GetStrip(),seid.GetPlane());
00226 //    return PlexLedId(Detector::kCalDet, 0 , led);
00227 
00228 //  }
00229 
00230 //  int PulserSummaryList::getLed(int crate,int strip, int plane)
00231 //  {
00232 //    switch (crate)
00233 //      {
00234 //      case 0:
00235 //        if (strip<4) {
00236 //      if (plane==40) return 2;
00237 //      if ((plane%4)==0||(plane%4)==1) return 1;
00238 //      return 2;
00239 //        } else if (strip<14) {
00240 //      if (plane==50) return 3;
00241 //      if (plane==40) return 1;
00242 //      if ((plane%4)==0||(plane%4)==1) return 2;
00243 //      return 1;
00244 //        } else {
00245 //      if (plane==50) return 1;
00246 //      return 3;
00247 //        }
00248 //      case 1:
00249 //        if (strip<10) {
00250 //      if (plane==56||plane==58) return 4;
00251 //      return 6;
00252 //        } else if (strip<20) {
00253 //      if (plane==58) return 6;
00254 //      if ((plane%4)==0||(plane%4)==1) return 5;
00255 //      return 4;
00256 //        } else {
00257 //      if ((plane%4)==0||(plane%4)==1) return 4;
00258 //      return 5;
00259 //        }
00260 //      default:
00261 //        return 0;
00262 //      }
00263 
00264 //  }
00265 
00266 
00267 

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