24 #include "TApplication.h"
32 #include "TLinearFitter.h"
45 enum HarpoMonitorEventType {
65 if (plane != NULL )plane->
print();
74 Info(
"process",
"Event %ld",
nEvents);
88 Double_t qtot[2] = {-1,-1};
94 Double_t timestamp = -1;
103 Int_t triggerType = -1;
117 if(pmm2Hdr == NULL)
continue;
119 if(pmm2Stat == NULL)
continue;
120 unsigned int triggerinfo = pmm2Stat->
getTrigger(i);
129 Double_t trigCorr = 1.;
151 std::cout <<
"pmm2Event: " << anaEvt << std::endl;
164 for(
int ch = 0; ch<16; ch++) hit[ch] = 0;
165 for(imes=0;imes<esize;imes++) {
169 hPmm2->SetBinContent(ch+1,q);
173 std::cout << ch <<
" ";
176 std::cout << std::endl;
190 if(hit[3] && hit[4] && hit[5] && hit[6]){
192 Info(
"process",
"TT");
194 hInfo->SetBinContent(9,
hInfo->GetBinContent(9)+1);
207 for(
int ch = 0; ch<16; ch++){
208 int ch2 = ch%2 ? ch+1 : ch-1;
216 for(
int ch1 = 0; ch1<16; ch1++){
217 for(
int ch2 = 0; ch2<16; ch2++){
219 if(hit[ch1] && hit[ch2]){
225 for(Int_t ch = 0; ch<16; ch++)
hPmm2->SetBinContent(ch+1,-1);
231 Info(
"process",
"isTT = %d",isTT);
234 HarpoMonitorEventType eventType = E_OTHER;
235 for(Int_t ndet=0;ndet<2;ndet++) {
249 for(Int_t i=0;i<
NADC;i++){
257 h[ndet]->SetTitle(Form(
"X direction, evt: %li",
nEvents));
259 Double_t qTot = 0, qTotZs = 0, Tmin = -10, Xmin = -500, Tmax = -10;
260 for(Int_t i=0;i<
NADC;i++){
262 Double_t qTotT = 0, qTotTZs = 0, meanCh = 0;
264 for(Int_t j=0;j<
NALL;j++){
267 h[ndet]->SetBinContent(i+1,j+1,q);
272 hCh[ndet]->Fill(j+0.5,q);
273 hT[ndet]->Fill(i+0.5,q);
274 hTev[ndet]->Fill(i+0.5,q);
280 Info(
"process",
"TT %d %f",i,qTotT);
282 hQtotT[ndet]->Fill(qTotT);
287 Info(
"process",
"TT %d %f",i,qTotT);
288 std::cout << i <<
" " << qTotT << std::endl;
356 Double_t Qcl = 0, Xcl = 0;
357 for(Int_t j=0;j<
NCHAN;j++){
365 hCumul[ndet]->Fill(i+0.5,j+0.5,q);
366 hZs[ndet]->SetBinContent(i+1,j+1,q);
369 hChZs[ndet]->Fill(j+0.5,q);
370 hTZs[ndet]->Fill(i+0.5,q);
371 hTevZs[ndet]->Fill(i+0.5,q);
375 if(Qcl>250 && Tmin == -10 && i>5){
379 if(Qcl>250 && Tmin > 0) Tmax = i;
384 hTmin[ndet]->Fill(Tmin);
385 hTmax[ndet]->Fill(Tmax);
388 hQtot[ndet]->Fill(qTot);
391 if(Tmin>
fTmin) eventType = E_CREATED;
392 if(Tmax-Tmin>
fLTpc) eventType = E_TRAVERSING;
397 std::cout <<
"No Data Map for plane "<< ndet << std::endl;
402 if(qtot[0]>
fQmax || qtot[1]>
fQmax) eventType = E_SATURATED;
403 if(qtot[0]<
fQmin && qtot[1]<
fQmin) eventType = E_EMPTY;
405 hInfo->SetBinContent(8,triggerType);
437 qtot2X += qtot[0]*qtot[0];
438 qtot2Y += qtot[1]*qtot[1];
453 Info(
"process",
"trigCorr = %g",trigCorr);
518 Long64_t fAddress = 0x7fef1fc55000;
519 Long64_t address = 0;
521 Info(
"Init",
"Use default address %lld",fAddress);
524 TMapFile::SetMapAddress(fAddress);
529 mfile = TMapFile::Create(
"/tmp/harpo.map",
"RECREATE", 50000000,
530 "Memory mapped file with monitoring histograms");
539 Info(
"Init",
"Use default fIsZs %d",
fIsZs);
546 Info(
"Init",
"Use default fQmin %d",
fQmin);
553 Info(
"Init",
"Use default fQmax %d",
fQmax);
560 Info(
"InitCfg",
"Use default fTmin %g",
fTmin);
567 Info(
"InitCfg",
"Use default fLTpc %g",
fLTpc);
572 Double_t rateSample = 0;
574 Info(
"InitCfg",
"Use default fRateSample %g",
fRateSample);
579 Long64_t saveRate = 0;
581 Info(
"InitCfg",
"Use default fSaveRate %d",
fSaveRate);
588 hQvsT_TT[0] =
new TH1F(
"hQvsT_TT_X",
"Q vs T (traversing tracks);T [tb]; Q [ADC]",511,0,511);
589 hQvsT_TT[1] =
new TH1F(
"hQvsT_TT_Y",
"Q vs T (traversing tracks);T [tb]; Q [ADC]",511,0,511);
590 hQvsT_TT2D[0] =
new TH2F(
"hQvsT_TT2D_X",
"Q vs T (traversing tracks);T [tb]; Q [ADC]",511,0,511,500,0,50000);
591 hQvsT_TT2D[1] =
new TH2F(
"hQvsT_TT2D_Y",
"Q vs T (traversing tracks);T [tb]; Q [ADC]",511,0,511,500,0,50000);
592 hTdrift_TT[0] =
new TH1F(
"hTdrift_TT_X",
";T_{max}-T_{min} [tb]",511,0,511);
593 hTdrift_TT[1] =
new TH1F(
"hTdrift_TT_Y",
";T_{max}-T_{min} [tb]",511,0,511);
596 hTmin[0] =
new TH1F(
"hTmin_X",
"Tmin;T_{min} [tb]",511,0,511);
597 hTmin[1] =
new TH1F(
"hTmin_Y",
"Tmin;T_{min} [tb]",511,0,511);
599 hTmax[0] =
new TH1F(
"hTmax_X",
";T_{max} [tb]",511,0,511);
600 hTmax[1] =
new TH1F(
"hTmax_Y",
";T_{max} [tb]",511,0,511);
602 hT[0] =
new TH1F(
"hT_X",
";time [tb]",511,0,511);
603 hT[1] =
new TH1F(
"hT_Y",
";time [tb]",511,0,511);
605 hCh[0] =
new TH1F(
"hCh_X",
"Channels (cumulated);channel",304,0,304);
606 hCh[1] =
new TH1F(
"hCh_Y",
"Channels (cumulated);channel",304,0,304);
608 hQ[0] =
new TH1F(
"hQ_X",
"Pixel Charge;Q_{pixel} [ADC]",4096,0,4096);
609 hQ[1] =
new TH1F(
"hQ_Y",
"Pixel Charge;Q_{pixel} [ADC]",4096,0,4096);
611 hQev[0] =
new TH1F(
"hQev_X",
";Q_{pixel} [ADC]",4096,0,4096);
612 hQev[1] =
new TH1F(
"hQev_Y",
";Q_{pixel} [ADC]",4096,0,4096);
615 hTZs[0] =
new TH1F(
"hTZs_X",
";time [tb]",511,0,511);
616 hTZs[1] =
new TH1F(
"hTZs_Y",
";time [tb]",511,0,511);
618 hChZs[0] =
new TH1F(
"hChZs_X",
"Channels (cumulated);channel",304,0,304);
619 hChZs[1] =
new TH1F(
"hChZs_Y",
"Channels (cumulated);channel",304,0,304);
621 hQZs[0] =
new TH1F(
"hQZs_X",
";Q_{pixel} [ADC]",4096,0,4096);
622 hQZs[1] =
new TH1F(
"hQZs_Y",
";Q_{pixel} [ADC]",4096,0,4096);
624 hQevZs[0] =
new TH1F(
"hQevZs_X",
";Q_{pixel} [ADC]",4096,0,4096);
625 hQevZs[1] =
new TH1F(
"hQevZs_Y",
";Q_{pixel} [ADC]",4096,0,4096);
628 const Int_t nbins1 = 500;
629 const Int_t nbins2 = 500;
633 Double_t xmax2 = 1e8;
634 Double_t logxmin = TMath::Log(xmin);
635 Double_t logxmin2 = TMath::Log(xmin2);
636 Double_t logxmax = TMath::Log(xmax);
637 Double_t logxmax2 = TMath::Log(xmax2);
638 Double_t binwidth = (logxmax-logxmin)/nbins1;
639 Double_t binwidth2 = (logxmax2-logxmin2)/nbins2;
640 Double_t xbins1[nbins1+1];
641 Double_t xbins2[nbins2+1];
644 for (Int_t i=1;i<=nbins1;i++)
645 xbins1[i] = TMath::Exp(logxmin+i*binwidth);
646 for (Int_t i=1;i<=nbins2;i++)
647 xbins2[i] = TMath::Exp(logxmin2+i*binwidth2);
649 hQtotT[0] =
new TH1F(
"hQtotT_X",
"Cluster Charge;Q_{cluster} [ADC]",nbins1,xbins1);
650 hQtotT[1] =
new TH1F(
"hQtotT_Y",
"Cluster Charge;Q_{cluster} [ADC]",nbins1,xbins1);
652 hQtot[0] =
new TH1F(
"hQtot_X",
"Event Charge;Q_{event} [ADC]",nbins2,xbins2);
653 hQtot[1] =
new TH1F(
"hQtot_Y",
"Event Charge;Q_{event} [ADC]",nbins2,xbins2);
655 hQtotTZs[0] =
new TH1F(
"hQtotTZs_X",
";Q_{cluster} [ADC]",nbins1,xbins1);
656 hQtotTZs[1] =
new TH1F(
"hQtotTZs_Y",
";Q_{cluster} [ADC]",nbins1,xbins1);
658 hQtotZs[0] =
new TH1F(
"hQtotZs_X",
"Event Charge;Q_{event} [ADC]",nbins2,xbins2);
659 hQtotZs[1] =
new TH1F(
"hQtotZs_Y",
"Event Charge;Q_{event} [ADC]",nbins2,xbins2);
673 hInfo =
new TH1F(
"hInfo",
"",15,0.5,15.5);
674 hPmm2 =
new TH1F(
"hPmm2",
"",16,0,16);
676 hTmin[0]->SetLineColor(kBlue);
677 hTmax[0]->SetLineColor(kBlue+3);
678 hTmin[1]->SetLineColor(kRed);
679 hTmax[1]->SetLineColor(kRed+3);
682 hCh[0]->SetLineColor(kBlue);
683 hT[0]->SetLineColor(kBlue);
684 hQtotT[0]->SetLineColor(kBlue);
685 hQtot[0]->SetLineColor(kBlue);
686 hQ[0]->SetLineColor(kBlue);
687 hQev[0]->SetLineColor(kBlue);
688 hCh[1]->SetLineColor(kRed);
689 hT[1]->SetLineColor(kRed);
690 hQtotT[1]->SetLineColor(kRed);
691 hQtot[1]->SetLineColor(kRed);
692 hQ[1]->SetLineColor(kRed);
693 hQev[1]->SetLineColor(kRed);
700 hChZs[0]->SetLineColor(kBlue);
701 hTZs[0]->SetLineColor(kBlue);
703 hQtotZs[0]->SetLineColor(kBlue);
704 hQevZs[0]->SetLineColor(kBlue);
705 hQZs[0]->SetLineColor(kBlue);
706 hChZs[1]->SetLineColor(kRed);
707 hTZs[1]->SetLineColor(kRed);
709 hQtotZs[1]->SetLineColor(kRed);
710 hQevZs[1]->SetLineColor(kRed);
711 hQZs[1]->SetLineColor(kRed);
713 hChZs[0]->SetLineStyle(2);
714 hTZs[0]->SetLineStyle(2);
717 hQevZs[0]->SetLineStyle(2);
718 hQZs[0]->SetLineStyle(2);
719 hChZs[1]->SetLineStyle(2);
720 hTZs[1]->SetLineStyle(2);
723 hQevZs[1]->SetLineStyle(2);
724 hQZs[1]->SetLineStyle(2);
727 hTev[0] =
new TH1F(
"hTev_X",
"",511,0,511);
728 hTev[1] =
new TH1F(
"hTev_Y",
"",511,0,511);
729 hTevZs[0] =
new TH1F(
"hTevZs_X",
"",511,0,511);
730 hTevZs[1] =
new TH1F(
"hTevZs_Y",
"",511,0,511);
734 hQtotTev[0] =
new TH1F(
"hQtotTev_X",
"",nbins,0,Qmax);
735 hQtotTev[1] =
new TH1F(
"hQtotTev_Y",
"",nbins,0,Qmax);
736 hQtotTevZs[0] =
new TH1F(
"hQtotTevZs_X",
"",nbins,0,Qmax);
737 hQtotTevZs[1] =
new TH1F(
"hQtotTevZs_Y",
"",nbins,0,Qmax);
739 hTev[0]->SetLineColor(kBlue);
740 hTev[1]->SetLineColor(kRed);
743 hTevZs[0]->SetLineColor(kBlue);
744 hTevZs[1]->SetLineColor(kRed);
747 hTevZs[0]->SetLineStyle(2);
748 hTevZs[1]->SetLineStyle(2);
753 h[0] =
new TH2F(
"hX",
"X direction;time [t.b.];channel [1mm]",511,0,511,304,0,304);
754 hZs[0] =
new TH2F(
"hXZs",
"X direction;time [t.b.];channel [1mm]",511,0,511,304,0,304);
755 h[1] =
new TH2F(
"hY",
"Y direction;time [t.b.];channel [1mm]",511,0,511,304,0,304);
756 hZs[1] =
new TH2F(
"hYZs",
"Y direction;time [t.b.];channel [1mm]",511,0,511,304,0,304);
757 hCumul[0] =
new TH2F(
"hCumul_X",
"X direction;time [t.b.];channel [1mm]",511,0,511,304,0,304);
758 hCumul[1] =
new TH2F(
"hCumul_Y",
"Y direction;time [t.b.];channel [1mm]",511,0,511,304,0,304);
768 hPmm2Size =
new TH1F(
"hPmm2Size",
";#PM",12,1,13);
770 hPmm2Missed =
new TH1F(
"hPmm2Missed",
";#PM",12,1,13);
771 hPmm2Spectrum2D =
new TH2F(
"hPmm2Spectrum2D",
";Channel;Charge [ADC]",12,1,13,1024,0,1024);
772 hPmm2Coincidence =
new TH2F(
"hPmm2Coincidence",
";Channel;Channel",12,1,13,12,1,13);
796 hDeadTime[i] =
new TH1F(Form(
"hDeadTime_%d",i),
"; #deltaT [ms]; counts",500,0,500);
823 case H_MAP:
return h[ndet];
825 case H_Q:
return hQ[ndet];
827 case H_T:
return hT[ndet];
857 if ( hstFile == NULL ) {
858 const char* dir = gSystem->ExpandPathName(
"$HARPO_ANA_DIR/monitor");
860 if(gSystem->AccessPathName(dir))
863 hstFile =
new TString(Form(
"%s/onlinemonitor%lli.root",dir,
gHConfig->
GetRunNo()));
864 Info(
"Save",
"No Hist File name given, use default %s",hstFile->Data());
867 TFile *hf =
new TFile(hstFile->Data(),
"RECREATE");
948 Int_t size = vect->GetSize();
949 Double_t truncMean = 0;
950 Int_t* index =
new Int_t[size];
951 TMath::Sort(size,vect->GetArray(),index,kFALSE);
952 Int_t t = 0, tLow, tHigh;
955 while(vect->At(index[t])<10&&t<size-1) t++;
956 tLow = TMath::FloorNint(t + (size - t)*tl);
957 tHigh = TMath::FloorNint(t + (size - t)*th);
959 for(Int_t tind = tLow; tind<tHigh; tind++) truncMean += vect->At(index[tind]);
961 return truncMean/(tHigh-tLow);
Int_t fNsaturated[kNtriggerTypes+1]
Double_t TruncMean(TArrayD *vect, Double_t tl, Double_t th)
TH1 * GetHist(HarpoHistoIdentifiers i, Int_t ndet)
Redefine empty default.
Long64_t GetRunNo()
Set Run Number.
A class Pmm2Status is bits representation of pmm2 status register (0x400).
Int_t fTriggerDownscaling[kNtriggerTypes]
Int_t fNcreated[kNtriggerTypes+1]
Double_t GetData(Int_t i, Int_t j)
Set/Get Data Cell.
TH1F * hTriggerTraversing
Bool_t isExist(ULong_t det)
Detecror date exist //! Number of Real Detectors.
TGraphErrors * gRateSaturated[kNtriggerTypes+1]
unsigned int getTrigger(int trig) const
Int_t fTriggerTime[kNtriggerTypes]
TGraphErrors * gRateTraversing[kNtriggerTypes+1]
Int_t fNempty[kNtriggerTypes+1]
unpacked dcc data The class contains the data map for DCC or Feminos The data is stored as a 2D TMatr...
Monitoring RAW data for online GUI.
HarpoDetEvent * GetDetEvent(Long_t plane=XDCC)
Pmm2MesVect * GetMesurements()
Return pointer to decoded data.
TGraphErrors * gRateOther[kNtriggerTypes+1]
TH1F * hTriggerCorrection
Bool_t Lookup(const char *path, Bool_t &val)
Lookup function for scalar values.
A class store HARPO raw PMM2 event buffer and header. End provide access metods to the row data...
void Save(char *mode=NULL)
virtual const EventHeader_t * GetHeader() const
HarpoEventHeader * GetHeader()
Long64_t GetFromEvent()
Get First Event to process.
TGraphErrors * gRateEmpty[kNtriggerTypes+1]
HarpoRunHeader * fRunHeader
TString * GetHistFile()
Get Name of Histogram output file.
const ULong_t gkNDetectors
ULong_t GetTimeStamp(Long_t plane=XDCC)
HarpoDccMap * GetDccMap(Long_t plane=XDCC)
A list of all mesurements in one Event for Pmm2 v2 card The class is place holder for all unpacked me...
void print()
Ovreloaded medod whic do all job.
TGraphErrors * gRateTotal[kNtriggerTypes+1]
static const Int_t kNtriggerTypes
TH1F * hDeadTime[kNtriggerTypes+1]
R__EXTERN HarpoDetSet * gHDetSet
Int_t fNother[kNtriggerTypes+1]
TGraphErrors * gRateCreated[kNtriggerTypes+1]
Int_t fNtraversing[kNtriggerTypes+1]