--- /dev/null
+
+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");
#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);
//--------------------------------------------------------------------------------------
- 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
#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
// 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
{
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);
+ }
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++;
}
}
-//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++;
}
else {
+
headersnow = 0;
-//New region starts - save region number
+ //New region starts - save region number
if ((data & 0xFF000000) == 0xFD000000) {
lastRegion = region;
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++;
}
}
- // bC = std::move(buf);
-return true;
+ return true;
}
#endif