00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00024
00025 #include "PulserCalibration/PulserTimePlotter.h"
00026 #include "PulserCalibration/PulserRawDriftPin.h"
00027 #include "Plex/PlexPinDiodeId.h"
00028 #include "DatabaseInterface/DbiResultPtr.h"
00029 #include <vector>
00030
00031 using std::vector;
00032 using std::cout;
00033 using std::endl;
00034
00035 ClassImp(PulserTimePlotter)
00036
00037
00038
00039 PulserTimePlotter::PulserTimePlotter(VldContext vc)
00040 : fStartVC(vc), fVC(vc), fPlex(vc)
00041 {
00042
00043 }
00044
00045 PulserTimePlotter::~PulserTimePlotter()
00046 {
00047
00048 }
00049
00050 TGraphErrors * PulserTimePlotter::CreateGraph(PlexLedId &led, int gain)
00051 {
00052 vector<float> mean;
00053 vector<float> error;
00054 vector<float> secs;
00055 int sec;
00056
00057 std::pair<PlexPinDiodeId,PlexPinDiodeId> pinids =
00058 fPlex.GetPinDiodeIds(led);
00059 const PulserRawDriftPin *pin;
00060 DbiResultPtr<PulserRawDriftPin> pinRP(fStartVC);
00061 for (;;) {
00062 cout<<"In loop "<<*(pinRP.GetValidityRec())<<endl;
00063 if (pinRP.GetNumRows()>0) {
00064 switch (gain) {
00065 case 0:
00066 pin = pinRP.GetRowByIndex(pinids.second.GetEncoded());
00067 break;
00068 case 1:
00069 pin = pinRP.GetRowByIndex(pinids.first.GetEncoded());
00070 break;
00071 default:
00072 cout<<"You asked for non-existent gain "<<gain<<endl;
00073 return 0;
00074 }
00075 if (!pin) {
00076 cout<<"Couldn't get PIN data for gain "<<gain<<" of led "<<led<<endl;
00077 return 0;
00078 }
00079 cout<<pin->GetMean()<<" "<<pin->GetError()<<endl;
00080 mean.push_back(pin->GetMean());
00081 error.push_back(pin->GetError());
00082 sec = pinRP.GetValidityRec()->GetVldRange().GetTimeStart().GetSec();
00083 secs.push_back(sec);
00084 }
00085
00086 int ntime = pinRP.GetValidityRec()->GetVldRange().GetTimeEnd().GetSec() + 1;
00087 VldContext v(Detector::Detector_t(pinRP.GetValidityRec()->GetVldRange().GetDetectorMask()),
00088 SimFlag::SimFlag_t(pinRP.GetValidityRec()->GetVldRange().GetSimMask()),
00089 VldTimeStamp(ntime,0));
00090 cout<<v<<endl;
00091 if (pinRP.NewQuery(v,pinRP.GetValidityRec()->GetTask())==0) break;
00092 }
00093 TGraphErrors *g = new TGraphErrors(mean.size(),&(secs[0]),0,&(mean[0]),&(error[0]));
00094 return g;
00095 }