]> jspc29.x-matter.uni-frankfurt.de Git - mimosis_chain.git/commitdiff
Marvins work on sync
authorMaps <maps@ikf>
Thu, 12 Dec 2024 10:25:40 +0000 (11:25 +0100)
committerMaps <maps@ikf>
Thu, 12 Dec 2024 10:25:40 +0000 (11:25 +0100)
analysis/ledtest/a000-output.root [new file with mode: 0644]
analysis/ledtest/a001-output.root [new file with mode: 0644]
analysis/ledtest/analysis.C [new file with mode: 0644]
analysis/ledtest/first.C
analysis/ledtest/mimosis.h

diff --git a/analysis/ledtest/a000-output.root b/analysis/ledtest/a000-output.root
new file mode 100644 (file)
index 0000000..dadc993
Binary files /dev/null and b/analysis/ledtest/a000-output.root differ
diff --git a/analysis/ledtest/a001-output.root b/analysis/ledtest/a001-output.root
new file mode 100644 (file)
index 0000000..801da24
Binary files /dev/null and b/analysis/ledtest/a001-output.root differ
diff --git a/analysis/ledtest/analysis.C b/analysis/ledtest/analysis.C
new file mode 100644 (file)
index 0000000..fbd128f
--- /dev/null
@@ -0,0 +1,24 @@
+
+int hitcount = 3;
+int frameNumber = 2;
+
+fi = TFile::Open(s.c_str(), "RECREATE");
+tree = new TTree ("tree","hitcount-framenumber");
+b1 = tree -> Branch("x1",&hitcount);
+:
+b2 = tree -> Branch("y1",&frameNumber);
+b3 = tree -> Branch("x2",&hitcount);
+b4 = tree -> Branch("y2",&frameNumber);
+
+tree->Fill();
+   
+   
+   
+   
+   
+TFile *f = new TFile("a000-output.root");
+TTree *t1 = (TTree*)f->Get("hitcount-framenumber");
+Float_t px, py;
+t1->SetBranchAddress("b1", &px);
+t1->SetBranchAddress("b2", &py);
+t1->Draw("px:py");
index b3a497e46e49dea4dc33b879f0466d196fbe8410..3740b9c888abcac2cb839e28e94c1808a7efec54 100644 (file)
 #include "mimosis.h"
 
 
+class SecondProc : public base::EventProc {
+
+protected:
+    const base::H2handle test1Handle = MakeH1("test1", "", 4095,0,4095,"");
+    TH1* test1        = static_cast<TH1*>(test1Handle);
+    const base::H2handle test2Handle = MakeH1("test2", "", 4095,0,4095,"");
+    TH1* test2        = static_cast<TH1*>(test2Handle);
+    const base::H2handle sumHandle = MakeH1("Sum", "", 4095,0,4095,"");
+    TH1* sum        = static_cast<TH1*>(sumHandle);
+
+public:
+   SecondProc(const char* procname) : base::EventProc(procname) {}
+   bool Process(base::Event* ev) override;
+};
+
+
+bool SecondProc::Process(base::Event* ev)
+{
+  for(int i=0; i<arr_hitcount_0.size(); i++)
+  {
+    test1->SetBinContent(arr_framenum_0[i] % 4096, arr_hitcount_0[i]);
+
+    // if( arr_hitcount_0[i] > sum->GetBinContent(arr_framenum_0[i]%4096) )
+      sum->SetBinContent(arr_framenum_0[i] % 4096, arr_hitcount_0[i]); 
+
+    if(arr_framenum_0[i] == 0)
+    {
+      test1->Reset();
+      // sum->Reset();
+    }
+  }
+
+  
+  for(int i=0; i<arr_hitcount_1.size(); i++)
+  {
+    test2->SetBinContent(arr_framenum_1[i] % 4096, arr_hitcount_1[i]);
+
+    // if( arr_hitcount_1[i] > sum->GetBinContent(arr_framenum_1[i]%4096) )
+
+    if( arr_hitcount_1[i] > 100 )
+      sum->SetBinContent(arr_framenum_1[i] % 4096, arr_hitcount_1[i]); 
+
+    if(arr_framenum_1[i] == 0)
+    {
+      test2->Reset();
+      sum->Reset();
+    }
+  }
+
+
+  arr_hitcount_0.clear();
+  arr_hitcount_1.clear();
+  arr_framenum_0.clear();
+  arr_framenum_1.clear();
+  
+  return true;
+}
+
+
+
 void first()
 {
+  arr_hitcount_0.reserve(1000);
+  arr_hitcount_1.reserve(1000);
+  arr_framenum_0.reserve(1000);
+  arr_framenum_1.reserve(1000);
   //base::ProcMgr::instance()->SetRawAnalysis(true);
     base::ProcMgr::instance()->SetTriggeredAnalysis(true);
 
@@ -33,24 +97,23 @@ void first()
    //--------------------------------------------------------------------------------------
 
 
-   base::Buffer bufCopy;
-   // uint32_t* a;
+//base::Buffer bufCopy;
+   uint32_t* a = new uint32_t();
 
    // 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::MimosisProcessor *mimosis = new hadaq::MimosisProcessor(trb, 0xa000, &bufCopy);
-   hadaq::MimosisProcessor *mimosis1 = new hadaq::MimosisProcessor(trb1, 0xa001, &bufCopy);
+   hadaq::MimosisProcessor *mimosis = new hadaq::MimosisProcessor(trb, 0xa000, a);
+   hadaq::MimosisProcessor *mimosis1 = new hadaq::MimosisProcessor(trb1, 0xa001, a);
    // hadaq::MimosisProcessor *mimosis2 = new hadaq::MimosisProcessor(trb2, 0xa100);
 
    // hadaq::MimosisProcessor *mimosis = new hadaq::MimosisProcessor(trb, 0xa000, a);
    // hadaq::MimosisProcessor *mimosis1 = new hadaq::MimosisProcessor(trb1, 0xa001, a);
    // hadaq::MimosisProcessor *mimosis2 = new hadaq::MimosisProcessor(trb2, 0xa100);
 
-
-
+   new SecondProc("debug");
 }
 
 // extern "C" required by DABC to find function from compiled code
index 75ae2580c9872586c39874847369afad0f6aa002..34aa063b0d9458ddcbf18ded65f0120646b6ea7e 100644 (file)
@@ -4,6 +4,19 @@
 
 #include "hadaq/SubProcessor.h"
 
+#include <vector>
+
+#define NUM_SENSORS 2
+
+unsigned int g_hitcount[NUM_SENSORS];
+unsigned int g_framenumber[NUM_SENSORS];
+
+std::vector<unsigned int> arr_hitcount_0;
+std::vector<unsigned int> arr_hitcount_1;
+
+std::vector<unsigned int> arr_framenum_0;
+std::vector<unsigned int> arr_framenum_1;
+
 
 
 namespace hadaq
@@ -26,16 +39,24 @@ namespace hadaq
 
       // uint32_t* aP;
 
-      base::Buffer *bufCopy;
+      uint32_t testCnt = 0;
+      uint32_t * bufCopy;
+      // base::Buffer *bufCopy;
       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;
-
+      unsigned int hitcount = 0;
 
+      TrbProcessor * const trb;
+      TFile * fi;
+      TTree * tree;
+      TBranch *b1;
+      TBranch *b2;
+      TBranch *b3;
+      TBranch *b4;
 
       virtual bool DecodePixel(const unsigned int& word, unsigned int& column, unsigned int& row) const noexcept
       {
@@ -52,14 +73,23 @@ namespace hadaq
 
     public:
       // MimosisProcessor(TrbProcessor * const trb, const unsigned subid, uint32_t *a) noexcept
-      MimosisProcessor(TrbProcessor * const trb, const unsigned subid, base::Buffer *bC) noexcept
+      MimosisProcessor(TrbProcessor * const trb, const unsigned subid, uint32_t *a) noexcept
         : hadaq::SubProcessor(trb, "%04X", subid)
         , trb(trb)
         // , sensor(subid-0xa000)
         , sensor(subid)
-        , bufCopy(bC)
-      {}
-    
+        , bufCopy(a)
+      {
+       std::stringstream stream;
+       stream << std::hex << subid;
+       auto s (stream.str() + "-output.root");
+       fi = TFile::Open(s.c_str(), "RECREATE");
+       tree = new TTree ("tree","hitcount-framenumber");
+       b1 = tree -> Branch("x1",&hitcount);
+       b2 = tree -> Branch("y1",&frameNumber);
+        b3 = tree -> Branch("x2",&hitcount);
+        b4 = tree -> Branch("y2",&frameNumber);
+      }
 
 
 
@@ -86,25 +116,16 @@ bool hadaq::MimosisProcessor::FirstBufferScan(const base::Buffer& buf) noexcept
   unsigned int headers = 0, trailers = 0;
   unsigned int headersnow = 0;
   unsigned int lastlength = -1;
-  unsigned int hitcount = 0;
+  hitcount = 0;
   uint32_t data;
-
-
-  if(sensor == 0xa000) {
-    *bufCopy = buf;
-  }
-  uint32_t *arr2 = static_cast<uint32_t *>(bufCopy->ptr());
+  
 
   for (; n < len; n++) {
 
     data = arr[n];
     length++;
 
-    if(n%8 ==0)
-      printf("0x%x: 0x%x 0x%x\n", sensor, arr[n], arr2[n]);
-
-
-//Begin of frame - store frame header
+    //Begin of frame - store frame header
     if ((data & 0xFF000000) == 0xFE000000) {
 
       headers++;
@@ -122,8 +143,25 @@ bool hadaq::MimosisProcessor::FirstBufferScan(const base::Buffer& buf) noexcept
       }
     }
 
-//End of frame - process frame results and error flags
+
+    //End of frame - process frame results and error flags
     else if ((data & 0xFF000000) == 0xFF000000) {
+
+      if(sensor == 0xa000) {
+
+       arr_hitcount_0.push_back(hitcount);
+       arr_framenum_0.push_back(frameNumber);
+        b1 -> Fill();
+       b2 -> Fill();
+      } else if(sensor == 0xa001) {
+
+       arr_hitcount_1.push_back(hitcount);
+       arr_framenum_1.push_back(frameNumber);
+       b3 -> Fill();
+       b4 -> Fill();
+      }
+
+      Last4096->SetBinContent(frameNumber % 4096, hitcount);
       length--;
       trailers++;
       frameCounter++;
@@ -133,9 +171,10 @@ bool hadaq::MimosisProcessor::FirstBufferScan(const base::Buffer& buf) noexcept
     }
 
     else {
+
       headersnow = 0;
 
-//New region starts - save region number
+      //New region starts - save region number
       if ((data & 0xFF000000) == 0xFD000000) {
 
         lastRegion = region;
@@ -144,13 +183,13 @@ bool hadaq::MimosisProcessor::FirstBufferScan(const base::Buffer& buf) noexcept
           continue;
         region = tmp;
 
-//Hit data - decode pixel address and save      
+        //Hit data - decode pixel address and save      
       } else {
         DecodePixel(data >> 16, column, row);
         hitcount++;
       }
-      
-//Second Hit data - decode pixel address and save      
+
+      //Second Hit data - decode pixel address and save      
       if ((data & 0x0000FF00) != 0x0000FC00) {
         DecodePixel(data & 0xFFFF, column, row);
         hitcount++;
@@ -158,8 +197,7 @@ bool hadaq::MimosisProcessor::FirstBufferScan(const base::Buffer& buf) noexcept
     }
   }
 
-  // bC = std::move(buf);
-return true;
+  return true;
 }
 
 #endif