00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
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();
00090
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
00109
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
00122 VldContext vldc(rawsum.GetVldContext());
00123 PlexHandle plex(vldc);
00124
00125 int numTriggers=0;
00126 std::pair<PlexPinDiodeId,PlexPinDiodeId> myPins =
00127 plex.GetPinDiodeIds(fAggregateNo);
00128 fHighPin->SetPinDiodeId(myPins.first);
00129 fLowPin->SetPinDiodeId(myPins.second);
00130
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
00143
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
00153
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
00160
00161 fFarMap[seid.BuildPlnStripEndKey()].Add(*rawch,seid);
00162 }
00163 else {
00164
00165
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
00173 if (pinid==myPins.first) {
00174
00175
00176 fHighPin->Add(*rawch,pinid);
00177 }
00178 else if (pinid==myPins.second) {
00179
00180
00181 fLowPin->Add(*rawch,pinid);
00182 }
00183
00184
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
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
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267