]> jspc29.x-matter.uni-frankfurt.de Git - mimosis_chain.git/commitdiff
modifications in rawreader
authorMaps <maps@ikf>
Thu, 12 Dec 2024 10:52:18 +0000 (11:52 +0100)
committerMaps <maps@ikf>
Thu, 12 Dec 2024 10:52:18 +0000 (11:52 +0100)
analysis/rawreader/first.C
analysis/rawreader/mimosis.h
analysis/rawreader/mimosis_M1.h [new file with mode: 0644]
analysis/rawreader/start.sh

index 82d80758c566194ee8469440eedb6251bb75e4de..d54bfb5d04d9e70afeea88ef132f632b43c7d6a6 100644 (file)
@@ -1,5 +1,5 @@
 // this is example for
-
+    
 #include <cstdlib>
 
 #include "hadaq/TdcProcessor.h"
@@ -28,19 +28,20 @@ void first()
    // second parameter is function name, called after elements are created
    hadaq::HldProcessor* hld = new hadaq::HldProcessor(false, "after_create");
 
-
    //--------------------------------------------------------------------------------------
 
    // create TRB processor which holds custom data
    hadaq::TrbProcessor* trb = new hadaq::TrbProcessor(0xa000, hld);
    hadaq::TrbProcessor* trb1 = new hadaq::TrbProcessor(0xa001, hld);
    hadaq::TrbProcessor* trb2 = new hadaq::TrbProcessor(0xa100, hld);
-   // create custom processor
+   hadaq::TrbProcessor* trb3 = new hadaq::TrbProcessor(0xc200, hld);
+   hadaq::TrbProcessor* trb4 = new hadaq::TrbProcessor(0xf575, hld);  
+// create custom processor
    hadaq::MimosisProcessor *mimosis = new hadaq::MimosisProcessor(trb, 0xa000);
    hadaq::MimosisProcessor *mimosis1 = new hadaq::MimosisProcessor(trb1, 0xa001);
    hadaq::MimosisProcessor *mimosis2 = new hadaq::MimosisProcessor(trb2, 0xa100);
-
-
+   hadaq::MimosisProcessor *mimosis3 = new hadaq::MimosisProcessor(trb3, 0xc200);
+   hadaq::MimosisProcessor *mimosis4 = new hadaq::MimosisProcessor(trb4, 0xf575);
 
 }
 
index 362c25be90b1a72c6df8311a4365dd4e4b619d76..af223d69a1a5b590e28394fff34ebd32da035f76 100644 (file)
@@ -74,7 +74,8 @@ namespace hadaq
         , trb(trb)
         , sensor(subid-0xa000)
         , sensoraddress(subid)
-      {}
+      {
+      }
 
 
 
@@ -176,22 +177,47 @@ bool hadaq::MimosisProcessor::FirstBufferScan(const base::Buffer& buf) noexcept
 
 //Hit data - decode pixel address and save
       } else {
-        DecodePixel(data >> 16, column, row);
-        hitcount++;
-        Columns->Fill(column);
-        Matrix->Fill(column, row);
-        MatrixCurrent->Fill(column, row);
-        RegionCounts->Fill(column/16);
+        
+        unsigned int dataWord = data >> 16;
+        int code = dataWord & 0b111;
+        
+        while (code >= 0) {
+        
+          DecodePixel(dataWord, column, row);
+          hitcount++;
+          Columns->Fill(column);
+          Matrix->Fill(column, row);
+          MatrixCurrent->Fill(column, row);
+          RegionCounts->Fill(column/16);
+          
+          code >> 1;
+          if (code == 0) {code = -1;}
+          dataWord = dataWord += 8;
+        
+        }
+      
       }
 
 //Second Hit data - decode pixel address and save
       if ((data & 0x0000FF00) != 0x0000FC00) {
-        DecodePixel(data & 0xFFFF, column, row);
-        hitcount++;
-        Columns->Fill(column);
-        Matrix->Fill(column, row);
-        MatrixCurrent->Fill(column, row);
-        RegionCounts->Fill(column/16);
+        
+        unsigned int dataWord = data & 0xFFFF;
+        int code = dataWord & 0b111;
+        
+        while (code >= 0) {
+        
+          DecodePixel(dataWord, column, row);
+          hitcount++;
+          Columns->Fill(column);
+          Matrix->Fill(column, row);
+          MatrixCurrent->Fill(column, row);
+          RegionCounts->Fill(column/16);
+          
+          code >> 1;
+          if (code == 0) {code = -1;}
+          dataWord = dataWord += 8;
+        
+        }
       }
     }
   }
diff --git a/analysis/rawreader/mimosis_M1.h b/analysis/rawreader/mimosis_M1.h
new file mode 100644 (file)
index 0000000..58acfa3
--- /dev/null
@@ -0,0 +1,210 @@
+#ifndef MimosisProcessor_h
+#define MimosisProcessor_h
+
+
+#include "hadaq/SubProcessor.h"
+
+
+
+namespace hadaq
+{
+  class TrbProcessor;
+
+    /** This is specialized sub-processor for custom data.
+      * It should be used together with TrbProcessor,
+      * which the only can provide data
+      **/
+  class MimosisProcessor : public SubProcessor
+  {
+    friend class TrbProcessor;
+
+    protected:
+      const base::H1handle HandleFrameLength             = MakeH1("FrameSize", "32bit words", 3000, 0, 3000, "ch");
+      TH1* FrameLength       = static_cast<TH1*>(HandleFrameLength);
+      const base::H1handle HandleNumHeaders              = MakeH1("NumHeaders",  "", 2000, 0, 2000, "#");
+      TH1* NumHeaders        = static_cast<TH1*>(HandleNumHeaders);
+      const base::H1handle HandleNumTrailers             = MakeH1("NumTrailers", "Consecutive Frames", 500, 0, 500, "#");
+      TH1* NumTrailers       = static_cast<TH1*>(HandleNumTrailers);
+      const base::H1handle HandleRegionHeaders           = MakeH1("RegionHeaders", "", 64, 0, 63, "#");
+      TH1* RegionHeaders     = static_cast<TH1*>(HandleRegionHeaders);
+      const base::H1handle HandleRegionCounts           = MakeH1("RegionCounts", "", 64, 0, 63, "#");
+      TH1* RegionCounts      = static_cast<TH1*>(HandleRegionCounts);
+      const base::H1handle HandleColumns                 = MakeH1("Columns", "Hits per Column", 1024, 0, 1024, "#");
+      TH1* Columns           = static_cast<TH1*>(HandleColumns);
+      const base::H1handle HandleErrorFlags              = MakeH1("ErrorFlags", "", 9, 0, 9, "Bit");
+      TH1* ErrorFlags        = static_cast<TH1*>(HandleErrorFlags);
+      const base::H2handle HandleFrameLengthDist         = MakeH2("FrameLengthDist", "", 1024,0,1024,1024,0,1024,"this frame ; last frame");
+      TH2* FrameLengthDist   = static_cast<TH2*>(HandleFrameLengthDist);
+      const base::H2handle HandleMatrix                  = MakeH2("Matrix", "", 1024,0,1024,508,0,508);
+      TH2* Matrix            = static_cast<TH2*>(HandleMatrix);
+      const base::H2handle HandleMatrixCurrent           = MakeH2("MatrixCurrent", "", 1024,0,1024,508,0,508);
+      TH2* MatrixCurrent     = static_cast<TH2*>(HandleMatrixCurrent);
+      const base::H2handle HandleMatrixLast              = MakeH2("MatrixLast", "", 1024,0,1024,508,0,508);
+      TH2* MatrixLast        = static_cast<TH2*>(HandleMatrixLast);
+      const base::H1handle HandleLast4096                = MakeH1("Last 4096 Content", "", 4095, 0, 4095, "Last 4096 Content");
+      TH1* Last4096          = static_cast<TH1*>(HandleLast4096);
+
+      unsigned int sensoraddress;
+      unsigned int sensor;
+      unsigned int length = 0;
+      unsigned int region = 0;
+      unsigned int frameCounter = 0;
+      unsigned int frameNumber = 0;
+      unsigned int lastRegion = 0;
+      TrbProcessor * const trb;
+
+
+
+      virtual bool DecodePixel(const unsigned int& word, unsigned int& column, unsigned int& row) const noexcept
+      {
+        unsigned int pixelcode = (word >> 6) & 0x3ff;
+        unsigned int side = 0, topdown = 0;
+        if((pixelcode&3) == 0x1 || (pixelcode&3) == 0x2) side = 1;
+        if((pixelcode&3) == 0x3 || (pixelcode&3) == 0x2) topdown = 1;
+        row    = (pixelcode>>2)*2 + topdown;
+        column = (((word>>3)&0x7) + region*8)*2 + side;
+        return true;
+      }
+
+
+
+    public:
+      MimosisProcessor(TrbProcessor * const trb, const unsigned subid) noexcept
+        : hadaq::SubProcessor(trb, "%04X", subid)
+        , trb(trb)
+        , sensor(subid-0xa000)
+        , sensoraddress(subid)
+      {
+      }
+
+
+
+      virtual ~MimosisProcessor() noexcept override = default;
+
+
+      /** Scan all messages, find reference signals if returned false, buffer has error and must be discarded */
+      virtual bool FirstBufferScan(const base::Buffer&) noexcept override;
+
+
+      /** Scan buffer for selecting messages inside trigger window */
+      virtual bool SecondBufferScan(const base::Buffer&) const noexcept { return true; }
+  };
+}
+
+
+
+bool hadaq::MimosisProcessor::FirstBufferScan(const base::Buffer& buf) noexcept
+{
+  const uint32_t len = buf.datalen()/4;
+  const uint32_t* arr = static_cast<uint32_t *>(buf.ptr());
+  unsigned int n = 0;
+  unsigned int column, row, lastcolumn = -1, lastrow = -1;
+  unsigned int headers = 0, trailers = 0;
+  unsigned int headersnow = 0;
+  unsigned int lastlength = -1;
+  unsigned int hitcount = 0;
+  uint32_t data;
+
+  if(((arr[0]&0xFF000000) != 0xFE000000) ||
+     ((arr[0]&0xFF00) != 0xFE00) )
+    n = 1;
+
+  for (; n < len; n++) {
+    data = arr[n];
+    length++;
+
+//Begin of frame - store frame header
+    if ((data & 0xFF000000) == 0xFE000000) {
+      headers++;
+      headersnow++;
+      length = 0;
+
+      if (headersnow == 1) {
+        frameNumber = (data & 0xFF0000) >> 16;
+        frameNumber += (data & 0xFF) << 8;
+      }
+
+      else if (headersnow == 2) {
+        frameNumber += data & 0xFF0000;
+        frameNumber += (data & 0xFF) << 24;
+      }
+    }
+
+//End of frame - process frame results and error flags
+    else if ((data & 0xFF000000) == 0xFF000000) {
+      length--;
+      trailers++;
+      frameCounter++;
+      MatrixCurrent->Fill(-1, -1);
+
+      Last4096->SetBinContent(frameNumber % 4096, hitcount);
+      hitcount = 0;
+
+      if (frameCounter == 10000) {
+        MatrixCurrent->Copy(*MatrixLast);
+        MatrixLast->SetName("MatrixLast10000");
+        MatrixCurrent->Reset();
+        RegionCounts->Reset();
+        frameCounter = 0;
+      }
+
+      headersnow = 0;
+      FrameLength->Fill(length);
+
+      if (lastlength != -1) {
+        FrameLengthDist->Fill(length, lastlength);
+      }
+
+      lastlength = length;
+      if (data & 0x00010000)      ErrorFlags->Fill(0);
+      if (data & 0x00020000)      ErrorFlags->Fill(1);
+      if (data & 0x00040000)      ErrorFlags->Fill(2);
+      if (data & 0x00080000)      ErrorFlags->Fill(3);
+      if (data & 0x00100000)      ErrorFlags->Fill(4);
+      if (data & 0x00200000)      ErrorFlags->Fill(5);
+      if (data & 0x00400000)      ErrorFlags->Fill(6);
+      if (data & 0x00800000)      ErrorFlags->Fill(7);
+      if (!(data & 0x00FF0000))   ErrorFlags->Fill(8);
+    }
+
+    else {
+      headersnow = 0;
+
+//New region starts - save region number
+      if ((data & 0xFF000000) == 0xFD000000) {
+        lastRegion = region;
+        int tmp = (data >> 16) & 0xFF;
+        if (tmp > 63)
+          continue;
+        region = tmp;
+        RegionHeaders->Fill(region);
+
+//Hit data - decode pixel address and save
+      } else {
+        DecodePixel(data >> 16, column, row);
+        hitcount++;
+        Columns->Fill(column);
+        Matrix->Fill(column, row);
+        MatrixCurrent->Fill(column, row);
+        RegionCounts->Fill(column/16);
+      }
+
+//Second Hit data - decode pixel address and save
+      if ((data & 0x0000FF00) != 0x0000FC00) {
+        DecodePixel(data & 0xFFFF, column, row);
+        hitcount++;
+        Columns->Fill(column);
+        Matrix->Fill(column, row);
+        MatrixCurrent->Fill(column, row);
+        RegionCounts->Fill(column/16);
+      }
+    }
+  }
+
+NumHeaders->Fill(headers);
+NumTrailers->Fill(trailers);
+
+return true;
+}
+
+#endif
index 3a5e1b6b706f71d6e8fc14569b5b8558e037b5f5..af12af476d94b53b0db671fddf1358f3edf15291 100755 (executable)
@@ -10,7 +10,11 @@ elif [[ "$DAQOPSERVER" == "jspc29:150" ]]; then
     echo "start go4 for Lab317."
     source /d/jspc37/soft/trb3/trb3login
     go4analysis -http 9999 -stream localhost:36789 -disable-asf
-elif [[ "$DAQOPSERVER" == "jspc29:31" ]]; then
+elif [[ "$DAQOPSERVER" == "jspc29:7" ]]; then
+    echo "start go4 for Lab318."
+    source /d/jspc37/soft/trb3/trb3login
+    go4analysis -http 9992 -stream localhost:36790 -disable-asf
+elif [[ "$DAQOPSERVER" == "jspc29:109" ]]; then
     echo "start go4 for Probestation."
     source /d/jspc37/soft/trb3/trb3login
     go4analysis -http 8031 -stream localhost:6788 -disable-asf