From e6636862fa5d3936263bc02830c5d464c2805f17 Mon Sep 17 00:00:00 2001
From: Nikolay Karpushkin <karpushkin@inr.ru>
Date: Wed, 23 Jun 2021 19:41:55 +0300
Subject: [PATCH] swap resolve

---
 core/data/raw/PsdGbtReader-v1.00.cxx          |  3 +-
 .../monitor/CbmMcbm2018MonitorAlgoPsd.cxx     | 31 +++++++++----------
 .../monitor/CbmMcbm2018MonitorAlgoPsd.h       |  2 +-
 macro/beamtime/mcbm2021/MonitorPsd.C          |  8 ++---
 4 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/core/data/raw/PsdGbtReader-v1.00.cxx b/core/data/raw/PsdGbtReader-v1.00.cxx
index 8d1af6217c..ec872249ed 100644
--- a/core/data/raw/PsdGbtReader-v1.00.cxx
+++ b/core/data/raw/PsdGbtReader-v1.00.cxx
@@ -112,7 +112,8 @@ namespace PsdDataV100
 
   int PsdGbtReader::ReadMs()
   {
-    std::stringstream().swap(save_buffer);
+    save_buffer.str("");
+    save_buffer.clear();
 
     //bool word_is_Ms_header = false;
     //ReadMsHeader();
diff --git a/fles/mcbm2018/monitor/CbmMcbm2018MonitorAlgoPsd.cxx b/fles/mcbm2018/monitor/CbmMcbm2018MonitorAlgoPsd.cxx
index f725506e2d..ef2530b703 100644
--- a/fles/mcbm2018/monitor/CbmMcbm2018MonitorAlgoPsd.cxx
+++ b/fles/mcbm2018/monitor/CbmMcbm2018MonitorAlgoPsd.cxx
@@ -396,7 +396,7 @@ Bool_t CbmMcbm2018MonitorAlgoPsd::ProcessMs(const fles::Timeslice& ts, size_t uM
               //double dHitTime = (double) fulCurrentMsIdx + PsdReader.VectPackHdr.at(hit_iter).uAdcTime * 12.5;  //in ns
               //double dHitTime = PsdReader.MsHdr.ulMicroSlice*1000. + PsdReader.VectPackHdr.at(hit_iter).uAdcTime*12.5; //in ns
               std::vector<uint16_t> uWfm = PsdReader.VectHitData.at(hit_iter).uWfm;
-              uSignalCharge /= kfAdc_to_mV;  // ->now in mV
+              uSignalCharge /= (int)kfAdc_to_mV;  // ->now in mV
 
               fhAdcTime->Fill(PsdReader.VectPackHdr.at(hit_iter).uAdcTime);
 
@@ -417,13 +417,13 @@ Bool_t CbmMcbm2018MonitorAlgoPsd::ProcessMs(const fles::Timeslice& ts, size_t uM
                 fvhHitFAChanEvo[uHitChannel]->Fill(fdMsTime - fdStartTime, uAccum);
 
                 //Hit data
-                int32_t iHitAmlpitude = 0;
-                int32_t iHitChargeWfm = 0;
+                double dHitAmlpitude = 0;
+                double dHitChargeWfm = 0;
                 if (fbMonitorWfmMode) fvhHitWfmChan[uHitChannel]->Reset();
                 if (fbMonitorFitMode) fvhHitFitWfmChan[uHitChannel]->Reset();
 
-                iHitChargeWfm = std::accumulate(uWfm.begin(), uWfm.end(), 0);
-                iHitChargeWfm -= uZeroLevel * uWfm.size();
+                dHitChargeWfm = std::accumulate(uWfm.begin(), uWfm.end(), 0);
+                dHitChargeWfm -= uZeroLevel * uWfm.size();
                 auto const max_iter = std::max_element(uWfm.begin(), uWfm.end());
                 assert(max_iter != uWfm.end());
                 if (max_iter == uWfm.end()) break;
@@ -582,7 +582,7 @@ Bool_t CbmMcbm2018MonitorAlgoPsd::ProcessMs(const fles::Timeslice& ts, size_t uM
               UInt_t uSignalCharge       = PsdReader.VectHitHdr.at(hit_iter).uSignalCharge;
               UInt_t uZeroLevel          = PsdReader.VectHitHdr.at(hit_iter).uZeroLevel;
               std::vector<uint16_t> uWfm = PsdReader.VectHitData.at(hit_iter).uWfm;
-              uSignalCharge /= kfAdc_to_mV;  // ->now in mV
+              uSignalCharge /= (int)kfAdc_to_mV;  // ->now in mV
 
               if (uHitChannel >= kuNbChanPsd)  //uHitChannel numerated from 0
               {
@@ -593,8 +593,7 @@ Bool_t CbmMcbm2018MonitorAlgoPsd::ProcessMs(const fles::Timeslice& ts, size_t uM
               //Hit header
               fhHitChargeMap->Fill(uHitChannel, uSignalCharge);
               fhHitMapEvo->Fill(uHitChannel, fdMsTime - fdStartTime);
-              fhChanHitMapEvo->Fill(uHitChannel,
-                                    fdMsTime - fdStartTime);  //should be placed map(channel)
+              fhChanHitMapEvo->Fill(uHitChannel, fdMsTime - fdStartTime);//should be placed map(ch)
 
               if (fbMonitorChanMode) {
 
@@ -602,13 +601,13 @@ Bool_t CbmMcbm2018MonitorAlgoPsd::ProcessMs(const fles::Timeslice& ts, size_t uM
                 fvhHitZeroLevelChan[uHitChannel]->Fill(uZeroLevel);
 
                 //Hit data
-                int32_t iHitAmlpitude = 0;
-                int32_t iHitChargeWfm = 0;
+                double dHitAmlpitude = 0;
+                double dHitChargeWfm = 0;
                 if (fbMonitorWfmMode) fvhHitWfmChan[uHitChannel]->Reset();
                 if (fbMonitorFitMode) fvhHitFitWfmChan[uHitChannel]->Reset();
 
-                iHitChargeWfm = std::accumulate(uWfm.begin(), uWfm.end(), 0);
-                iHitChargeWfm -= uZeroLevel * uWfm.size();
+                dHitChargeWfm = std::accumulate(uWfm.begin(), uWfm.end(), 0);
+                dHitChargeWfm -= uZeroLevel * uWfm.size();
                 auto const max_iter = std::max_element(uWfm.begin(), uWfm.end());
                 assert(max_iter != uWfm.end());
                 if (max_iter == uWfm.end()) break;
@@ -821,17 +820,17 @@ Bool_t CbmMcbm2018MonitorAlgoPsd::CreateHistograms()
 
       fvhHitZLChanEvo[uChan] =
         new TH2I(Form("hHitZLChanEvo%03u", uChan),
-                 Form("Hits ZeroLevel evolution for channel %03u; ZeroLevel [adc counts]", uChan), fuHistoryHistoSize,
+                 Form("Hits ZeroLevel evolution for channel %03u; Time in run [s]; ZeroLevel [adc counts]", uChan), fuHistoryHistoSize,
                  0, fuHistoryHistoSize, fviHistoZLArgs.at(0), fviHistoZLArgs.at(1), fviHistoZLArgs.at(2));
       fvhHitZLChanEvo[uChan]->SetMarkerColor(kRed);
       fvhHitLPChanEvo[uChan] =
         new TH2I(Form("hHitLPChanEvo%03u", uChan),
-                 Form("Hits LastPoint evolution for channel %03u; ZeroLevel [adc counts]", uChan), fuHistoryHistoSize,
+                 Form("Hits LastPoint evolution for channel %03u; Time in run [s]; ZeroLevel [adc counts]", uChan), fuHistoryHistoSize,
                  0, fuHistoryHistoSize, fviHistoZLArgs.at(0), fviHistoZLArgs.at(1), fviHistoZLArgs.at(2));
       fvhHitLPChanEvo[uChan]->SetMarkerColor(kBlue);
       fvhHitFAChanEvo[uChan] = new TH2I(
         Form("hHitFAChanEvo%03u", uChan),
-        Form("Hits FeeAccumulator evolution for channel %03u; ZeroLevel [adc counts]", uChan), fuHistoryHistoSize, 0,
+        Form("Hits FeeAccumulator evolution for channel %03u; Time in run [s]; ZeroLevel [adc counts]", uChan), fuHistoryHistoSize, 0,
         fuHistoryHistoSize, fviHistoZLArgs.at(0), fviHistoZLArgs.at(1), fviHistoZLArgs.at(2));
       fvhHitFAChanEvo[uChan]->SetMarkerColor(kOrange);
 
@@ -845,7 +844,7 @@ Bool_t CbmMcbm2018MonitorAlgoPsd::CreateHistograms()
                  Form("Hits zero level distribution for channel %03u; ZeroLevel [adc counts]", uChan),
                  fviHistoZLArgs.at(0), fviHistoZLArgs.at(1), fviHistoZLArgs.at(2));
 
-      fvhHitAmplChan[uChan] = new TH1I(Form("hHitAmplChan%03u", uChan),
+      fvhHitAmplChan[uChan] = new TH1F(Form("hHitAmplChan%03u", uChan),
                                        Form("Hits amplitude distribution for channel %03u; Amplitude [mV]", uChan),
                                        fviHistoAmplArgs.at(0), fviHistoAmplArgs.at(1), fviHistoAmplArgs.at(2));
 
diff --git a/fles/mcbm2018/monitor/CbmMcbm2018MonitorAlgoPsd.h b/fles/mcbm2018/monitor/CbmMcbm2018MonitorAlgoPsd.h
index 69acfdf50b..62f8c56f1b 100644
--- a/fles/mcbm2018/monitor/CbmMcbm2018MonitorAlgoPsd.h
+++ b/fles/mcbm2018/monitor/CbmMcbm2018MonitorAlgoPsd.h
@@ -104,7 +104,7 @@ private:
   static const Int_t kiMaxNbFlibLinks   = 32;
   static const UInt_t kuBytesPerMessage = 8;
   static const UInt_t kuNbChanPsd       = 12;
-  const float kfAdc_to_mV               = 1;
+  const float kfAdc_to_mV               = 16.5;
 
   static constexpr UInt_t GetNbChanPsd() { return kuNbChanPsd; }
   /// Running indices
diff --git a/macro/beamtime/mcbm2021/MonitorPsd.C b/macro/beamtime/mcbm2021/MonitorPsd.C
index 967c0d4594..dda9fb5cf2 100644
--- a/macro/beamtime/mcbm2021/MonitorPsd.C
+++ b/macro/beamtime/mcbm2021/MonitorPsd.C
@@ -60,16 +60,16 @@ void MonitorPsd(TString inFile = "", TString sHostname = "localhost", Int_t iSer
   monitor_psd->SetHistoryHistoSize(60);
   monitor_psd->SetHistoFilename(outFileNameHistos);
 
-  std::vector<Int_t> fviHistoChargeArgs {500, 0, 5000};
-  std::vector<Int_t> fviHistoAmplArgs {100, 0, 500};
-  std::vector<Int_t> fviHistoZLArgs {9000, 0, 9000};
+  std::vector<Int_t> fviHistoChargeArgs {100, 0, 100};
+  std::vector<Int_t> fviHistoAmplArgs {20, 0, 10};
+  std::vector<Int_t> fviHistoZLArgs {500, 0, 2000};
   monitor_psd->SetChargeHistoArgs(fviHistoChargeArgs);
   monitor_psd->SetAmplHistoArgs(fviHistoAmplArgs);
   monitor_psd->SetZLHistoArgs(fviHistoZLArgs);
 
   monitor_psd->SetMonitorChanMode(kTRUE);
   monitor_psd->SetMonitorWfmMode(kTRUE);
-  //monitor_psd->SetMonitorFitMode(kTRUE);
+  monitor_psd->SetMonitorFitMode(kTRUE);
 
   // --- Source task
   CbmMcbm2018Source* source = new CbmMcbm2018Source();
-- 
GitLab