From 15be7f9bf1f36a8fb04953cae04e4feae08a8cb9 Mon Sep 17 00:00:00 2001 From: Maps Date: Mon, 4 Sep 2023 15:15:00 +0200 Subject: [PATCH] cleaned repo. use mimosis command now. --- analysis/crctest/CRCVerilogJan2.C | 187 +++++++++++ analysis/crctest/mimosis.h | 241 ++++++-------- analysis/other/first.C | 0 analysis/other/mimosis.h | 20 +- analysis/other/old_second.C | 0 analysis/rawreader/mimosis.h | 195 ++++++----- analysis/scurve/mimosis.h | 21 +- http/htdocs/pulse.htm | 1 - http/htdocs/setreg.pl | 14 +- scripts/Mimosis.pm | 364 +++++++++++++++++---- scripts/cli/mimosis | 204 +++++++++--- scripts/conf/CONF_dac_M47.pl | 15 + scripts/{ => legacy}/adc_i2c_cmd.pl | 0 scripts/{ => legacy}/basicsettings.pl | 0 scripts/legacy/instr.pl | 33 ++ scripts/{ => legacy}/mimosis_i2c_cmd.pl | 18 + scripts/{ => legacy}/start_probestation.sh | 10 +- scripts/pulse/curves.py | 2 +- scripts/pulse/fpn.py | 34 +- scripts/pulse/full_scan.pl | 70 ++-- scripts/start.sh | 10 +- 21 files changed, 1018 insertions(+), 421 deletions(-) create mode 100644 analysis/crctest/CRCVerilogJan2.C mode change 100644 => 100755 analysis/other/first.C mode change 100644 => 100755 analysis/other/mimosis.h mode change 100644 => 100755 analysis/other/old_second.C create mode 100644 scripts/conf/CONF_dac_M47.pl rename scripts/{ => legacy}/adc_i2c_cmd.pl (100%) rename scripts/{ => legacy}/basicsettings.pl (100%) create mode 100755 scripts/legacy/instr.pl rename scripts/{ => legacy}/mimosis_i2c_cmd.pl (86%) rename scripts/{ => legacy}/start_probestation.sh (75%) mode change 100644 => 100755 scripts/pulse/curves.py diff --git a/analysis/crctest/CRCVerilogJan2.C b/analysis/crctest/CRCVerilogJan2.C new file mode 100644 index 0000000..96475e5 --- /dev/null +++ b/analysis/crctest/CRCVerilogJan2.C @@ -0,0 +1,187 @@ +#include +#include +#include +#include + + + +std::bitset<16> calc_crc(std::vector>& data_in_array) +{ + std::bitset<16> lfsr_c (0xFFFF),lfsr_c_nomsb, lfsr_q; + std::bitset<128> data_in; + + // reset + lfsr_c.set(); // = 0xFFFF; + + for (size_t i=0; i crc; + + std::vector> messageLong; + + long sizeOfInput=lengthOfArray; + + + cout << sizeOfInput << endl; + + long stepSize=4; + + sizeOfInput=(sizeOfInput/stepSize)*stepSize; //truncate last words due to faulty handling in hardware + + cout << sizeOfInput << endl; + cout << sizeOfInput/4 << endl; + + for (long i=0; i<(sizeOfInput/stepSize); i++){ + + cout << i<< " "; + + uint32_t tempInt = (inputMessage[4*i+stepSize-1]&0xffff)<<16; + tempInt = tempInt|((inputMessage[4*i+stepSize-1]&0xffff0000)>>16); + std::bitset<128> messageTemp(tempInt); + + cout << std::hex << (uint32_t)inputMessage[4*i+stepSize-1] << " "; + + + for(long j=1; j>16); + std::bitset<128> lowerBits (tempInt); + cout << std::hex << (uint32_t)inputMessage[4*i+stepSize-1-j] << " "; + messageTemp=messageTemp|lowerBits; + //cout << std::hex << " messageTemp " << messageTemp << endl; + } + cout << endl; + messageLong.push_back(messageTemp); + } + +// for (long i=0; i<(sizeOfInput/stepSize); i++){ +// +// cout << i<< " "; +// +// std::bitset<128> messageTemp(inputMessage[4*i]); +// cout << std::hex << (uint32_t)inputMessage[4*i] << " "; +// +// +// for(long j=1; j lowerBits ((uint32_t)inputMessage[4*i+j]); +// cout << std::hex << (uint32_t)inputMessage[4*i+j] << " "; +// messageTemp=messageTemp|lowerBits; +// //cout << std::hex << " messageTemp " << messageTemp << endl; +// } +// cout << endl; +// messageLong.push_back(messageTemp); +// } + +// for(size_t i=0; i +#include +#include +#include + + +std::bitset<16> calc_crc(std::vector>& data_in_array) +{ + std::bitset<16> lfsr_c (0xFFFF),lfsr_c_nomsb, lfsr_q; + std::bitset<128> data_in; + + lfsr_c.set(); // = 0xFFFF; + + for (size_t i=0; i crc; + std::vector> messageLong; + long sizeOfInput=lengthOfArray; + long stepSize=4; + + sizeOfInput=(sizeOfInput/stepSize)*stepSize; //truncate last words due to faulty handling in hardware + + for (long i=0; i<(sizeOfInput/stepSize); i++) + { + uint32_t tempInt = (inputMessage[4*i+stepSize-1]&0xffff)<<16; + tempInt = tempInt|((inputMessage[4*i+stepSize-1]&0xffff0000)>>16); + + std::bitset<128> messageTemp(tempInt); + + for(long j=1; j>16); + std::bitset<128> lowerBits (tempInt); + messageTemp=messageTemp|lowerBits; + } + messageLong.push_back(messageTemp); + } + crc = calc_crc(messageLong); + return crc.to_ulong(); +} + namespace hadaq { + class TrbProcessor; /** This is specialized sub-processor for custom data. @@ -20,49 +94,10 @@ class MimosisProcessor : public SubProcessor { protected: - base::H1handle FrameLength; - base::H1handle NumHeaders; - base::H1handle NumTrailers; - base::H1handle NumHTDiff; - base::H1handle RegionHeaders; - base::H1handle Columns; - base::H1handle ErrorFlags; - base::H2handle Matrix; - base::H2handle MatrixCurrent; - base::H2handle MatrixLast; - base::H2handle FrameLengthDist; - base::H2handle LengthvsError; - base::H1handle PixelMultiplicity; - base::H1handle PixelMultiplicityTotal; - base::H1handle PixelMultiplicityA; - base::H1handle PixelMultiplicityB; - base::H1handle PixelMultiplicityC; - base::H1handle PixelMultiplicityD; - base::H1handle PixelMultiplicityATotal; - base::H1handle PixelMultiplicityBTotal; - base::H1handle PixelMultiplicityCTotal; - base::H1handle PixelMultiplicityDTotal; - - uint32_t length = 0; - uint32_t region = 0; - int frameCounter = 0; - int lastRegion = 0; - unsigned sensor=0; - - - virtual bool DecodePixel(uint16_t word, uint32_t* column, uint32_t* row) { - uint32_t pixelcode = (word >> 6) & 0x3ff; - uint32_t side = 0; - uint32_t 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; - } + const base::H1handle wrongcrchandle = MakeH1("wrong CRC", "32bit words", 2, 0, 2, "ch"); + TH1* wrongcrc = static_cast(wrongcrchandle); + + unsigned sensor=0; public: @@ -85,114 +120,38 @@ public: hadaq::MimosisProcessor::MimosisProcessor(TrbProcessor* trb, unsigned subid) : hadaq::SubProcessor(trb, "%04X", subid) { - FrameLength = MakeH1("FrameSize", "32bit words", 3000, 0, 3000, "ch"); - NumHeaders = MakeH1("NumHeaders", "", 2000, 0, 2000, "#"); - NumTrailers = MakeH1("NumTrailers", "Consecutive Frames", 500, 0, 500, "#"); - NumHTDiff = MakeH1("Difference Trailer Headers", "", 20, -10, 10, "#"); - RegionHeaders = MakeH1("RegionHeaders", "", 64, 0, 63, "#"); - Columns = MakeH1("Columns", "Hits per Column", 1024, 0, 1024, "#"); - ErrorFlags = MakeH1("ErrorFlags", "", 9, 0, 9, "Bit"); - Matrix = MakeH2("Matrix", "", 1024,0,1024,508,0,508); - MatrixCurrent = MakeH2("MatrixCurrent", "", 1024,0,1024,508,0,508); - MatrixLast = MakeH2("MatrixLast", "", 1024,0,1024,508,0,508); - FrameLengthDist = MakeH2("FrameLengthDist", "", 1024,0,1024,1024,0,1024,"this frame ; last frame"); - LengthvsError = MakeH2("LengthvsError", "", 1024,0,1024,2,0,2,"frame size; limit marker"); - PixelMultiplicity = MakeH1("PixelMultiplicity", "", 10000, 0, 1, "Hit probability"); - PixelMultiplicityTotal = MakeH1("PixelMultiplicityTotal", "", 10000, 0, 1, "Hit probability"); - PixelMultiplicityA = MakeH1("PixelMultiplicityA", "", 10000, 0, 1, "Hit probability"); - PixelMultiplicityB = MakeH1("PixelMultiplicityB", "", 10000, 0, 1, "Hit probability"); - PixelMultiplicityC = MakeH1("PixelMultiplicityC", "", 10000, 0, 1, "Hit probability"); - PixelMultiplicityD = MakeH1("PixelMultiplicityD", "", 10000, 0, 1, "Hit probability"); - PixelMultiplicityATotal = MakeH1("PixelMultiplicityATotal", "", 10000, 0, 1, "Hit probability"); - PixelMultiplicityBTotal = MakeH1("PixelMultiplicityBTotal", "", 10000, 0, 1, "Hit probability"); - PixelMultiplicityCTotal = MakeH1("PixelMultiplicityCTotal", "", 10000, 0, 1, "Hit probability"); - PixelMultiplicityDTotal = MakeH1("PixelMultiplicityDTotal", "", 10000, 0, 1, "Hit probability"); sensor = subid-0xa000; - } +} + bool hadaq::MimosisProcessor::FirstBufferScan(const base::Buffer &buf) { unsigned len = buf.datalen()/4; uint32_t* arr = (uint32_t*) buf.ptr(); - uint32_t column, row; - uint32_t lastcolumn =-1, lastrow=-1; - uint32_t headers = 0, trailers = 0; unsigned n=0; - unsigned headersnow = 0; - signed lastlength = -1; - - uCRC_t ucrc(16, 0x8005, 0xFFFF, false, false, 0); - - //0xfe69,0xfe5f,0xfeff,0xfe02,0xfe00,0xfe00,0xfe00,0xfe00,0xff00,0x62f7 //e2f7 - uint32_t b1[4] = {0xfe69fe5f,0xfefffe02,0xfe00fe00,0xfe00fe00}; - uint16_t b2[8] = {0xfe69,0xfe5f,0xfeff,0xfe02,0xfe00,0xfe00,0xfe00,0xfe00}; -// uint16_t b3[8] = {0xfe00,0xfe00,0xfe00,0xfe00,0xfe02,0xfeff,0xfe5f,0xfe69}; - uint16_t b3[8] = {0xfe5f,0xfe69,0xfe02,0xfeff,0xfe00,0xfe00,0xfe00,0xfe00}; - uint32_t b4[4] = {0xfe5ffe69,0xfe02feff,0xfe00fe00,0xfe00fe00}; - uint32_t b5[4] = {0xfe00fe00,0xfe00fe00,0xfefffe02,0xfe69fe5f}; - uint64_t b6[4] = {0xfe02fefffe5ffe69,0xfe00fe00fe00fe00}; - printf("%lx %lx %lx %lx %lx %lx\n",ucrc.get_crc(b1, 4),ucrc.get_crc(b2, 8),ucrc.get_crc(b3, 8),ucrc.get_crc(b4, 8),ucrc.get_crc(b5, 8),ucrc.get_crc(b6, 8)); - - exit; - int pulse_stats = 0; - for (;n> 16; - pulse_stats += (data & 0xFF) << 8; - } - else if(headersnow == 4) { - pulse_stats += data & 0xFF0000; - pulse_stats += (data & 0xFF) << 24; - // printf("%x\n", pulse_stats); - } - } - else if((data & 0xFF000000) == 0xFF000000) { - trailers++; - frameCounter++; - FillH2(MatrixCurrent,-1,-1); - } - else { - - headersnow = 0; - if((data & 0xFF000000) == 0xFD000000) { - lastRegion = region; - int tmp = (data>>16) & 0xff; - if(tmp > 63) continue; - region = tmp; - FillH1(RegionHeaders,region); - } - else { - DecodePixel(data>>16,&column,&row); - FillH1(Columns,column); - FillH2(Matrix,column,row); - FillH2(MatrixCurrent,column,row); - lastcolumn = column; lastrow = row; - } - if ((data & 0x0000FF00) != 0x0000FC00) { - DecodePixel(data&0xffff,&column,&row); - FillH1(Columns,column); - FillH2(Matrix,column,row); - FillH2(MatrixCurrent,column,row); + uint16_t crcsum = 0; + int headerpos = -5; - lastcolumn = column; lastrow = row; - } - } + for (;nFill(1); + else wrongcrc->Fill(0); } - - - FillH1(NumHeaders, headers); - FillH1(NumTrailers, trailers); - FillH1(NumHTDiff, ((int32_t)headers)/4-trailers); - - return true; } + return true; +} #endif diff --git a/analysis/other/first.C b/analysis/other/first.C old mode 100644 new mode 100755 diff --git a/analysis/other/mimosis.h b/analysis/other/mimosis.h old mode 100644 new mode 100755 index 45dd123..6b63e00 --- a/analysis/other/mimosis.h +++ b/analysis/other/mimosis.h @@ -70,7 +70,8 @@ namespace hadaq const base::H1handle PixelMultiplicityDTotal = MakeH1("PixelMultiplicityDTotal", "", 10000, 0, 1, "Hit probability"); const base::H1handle SCurve = MakeH1("S-Curve", "", 255, 0, 255, "S-Curve"); const base::H1handle Last1000 = MakeH1("Last 1000 Content", "", 1000, 0, 1000, "Last 1000 Content"); - const base::H1handle Last1024 = MakeH1("Last 1024 Content", "", 1024, 0, 1023, "Last 1024 Content"); + const base::H1handle Last4096 = MakeH1("Last 4096 Content", "", 4095, 0, 4095, "Last 4096 Content"); + const base::H1handle Last4096trig = MakeH1("Last 4096trig Content", "", 4095, 0, 4095, "Last 4096 Content, with trigger"); const base::H2handle SCurveAll = MakeH2("S-Curve all pixels", "",256,0,256,1024*504,0,1024*504,"SCurveAll"); const base::H1handle SCurveDebug = MakeH1("S-Curve Debug", "", 255, 0, 255, "S-Curve Debug"); const base::H1handle SCurveDebugProjectionY = MakeH1("S-Curve Debug ProjectionY", "", 255, 0, 255, "S-Curve Debug ProjectionY"); @@ -227,10 +228,12 @@ bool hadaq::MimosisProcessor::FirstBufferScan(const base::Buffer& buf) noexcept { auto f1 = new TF1("f1","([0]*(1+TMath::Erf((x-[1])/(TMath::Sqrt2()*[2]))))"); + double cont; TH1D * hist = new TH1D(); int counter = 0; + // for(int i = 1; i < 504*1024; i++) for(int i = 1; i < 2; i++) { @@ -391,12 +394,17 @@ bool hadaq::MimosisProcessor::FirstBufferScan(const base::Buffer& buf) noexcept if(start || startRegion) { static_cast(Last1000)->SetBinContent(1000 - binIndex,hitCountPlot); - static_cast(Last1024)->SetBinContent(mimosisFrameCounter%1024,length); + static_cast(Last4096)->SetBinContent(mimosisFrameCounter%4096,length); + if(length > 35) static_cast(Last4096trig)->SetBinContent(mimosisFrameCounter%4096,length); binIndex = binIndex == 1000 ? 0 : binIndex + 1; hitCountPlot = 0; } + static_cast(Last1000)->SetBinContent(1000 - binIndex,hitCountPlot); + static_cast(Last4096)->SetBinContent(mimosisFrameCounter%4096,length); + if(length > 35) static_cast(Last4096trig)->SetBinContent(mimosisFrameCounter%4096,length); + if(startRegion) { dacFifo.push(dacSetting); @@ -464,16 +472,8 @@ bool hadaq::MimosisProcessor::FirstBufferScan(const base::Buffer& buf) noexcept FillH1(Columns,column); FillH2(Matrix,column,row); FillH2(MatrixCurrent,column,row); - static_cast(Last1000)->SetBinContent(1000 - binIndex,hitCountPlot); - static_cast(Last1024)->SetBinContent(mimosisFrameCounter%1024,length); binIndex = binIndex == 1000 ? 0 : binIndex + 1; hitCountPlot = 0; - static_cast(Last1000)->SetBinContent(1000 - binIndex,hitCountPlot); - static_cast(Last1024)->SetBinContent(mimosisFrameCounter%1024,length); - binIndex = binIndex == 1000 ? 0 : binIndex + 1; - hitCountPlot = 0; - - // printf("check start decodePixel %d\n",15); diff --git a/analysis/other/old_second.C b/analysis/other/old_second.C old mode 100644 new mode 100755 diff --git a/analysis/rawreader/mimosis.h b/analysis/rawreader/mimosis.h index 60b520e..362c25b 100644 --- a/analysis/rawreader/mimosis.h +++ b/analysis/rawreader/mimosis.h @@ -19,33 +19,46 @@ namespace hadaq friend class TrbProcessor; protected: - const base::H1handle FrameLength = MakeH1("FrameSize", "32bit words", 3000, 0, 3000, "ch"); - const base::H1handle NumHeaders = MakeH1("NumHeaders", "", 2000, 0, 2000, "#"); - const base::H1handle NumTrailers = MakeH1("NumTrailers", "Consecutive Frames", 500, 0, 500, "#"); - const base::H1handle NumHTDiff = MakeH1("Difference Trailer Headers", "", 20, -10, 10, "#"); - const base::H1handle RegionHeaders = MakeH1("RegionHeaders", "", 64, 0, 63, "#"); - const base::H1handle Columns = MakeH1("Columns", "Hits per Column", 1024, 0, 1024, "#"); - const base::H1handle ErrorFlags = MakeH1("ErrorFlags", "", 9, 0, 9, "Bit"); - const base::H2handle Matrix = MakeH2("Matrix", "", 1024,0,1024,508,0,508); - const base::H2handle MatrixCurrent = MakeH2("MatrixCurrent", "", 1024,0,1024,508,0,508); - const base::H2handle MatrixLast = MakeH2("MatrixLast", "", 1024,0,1024,508,0,508); - const base::H2handle FrameLengthDist = MakeH2("FrameLengthDist", "", 1024,0,1024,1024,0,1024,"this frame ; last frame"); - const base::H2handle LengthvsError = MakeH2("LengthvsError", "", 1024,0,1024,2,0,2,"frame size; limit marker"); - - - const unsigned sensor; - unsigned long length = 0; - unsigned long region = 0; - int frameCounter = 0; - int lastRegion = 0; + const base::H1handle HandleFrameLength = MakeH1("FrameSize", "32bit words", 3000, 0, 3000, "ch"); + TH1* FrameLength = static_cast(HandleFrameLength); + const base::H1handle HandleNumHeaders = MakeH1("NumHeaders", "", 2000, 0, 2000, "#"); + TH1* NumHeaders = static_cast(HandleNumHeaders); + const base::H1handle HandleNumTrailers = MakeH1("NumTrailers", "Consecutive Frames", 500, 0, 500, "#"); + TH1* NumTrailers = static_cast(HandleNumTrailers); + const base::H1handle HandleRegionHeaders = MakeH1("RegionHeaders", "", 64, 0, 63, "#"); + TH1* RegionHeaders = static_cast(HandleRegionHeaders); + const base::H1handle HandleRegionCounts = MakeH1("RegionCounts", "", 64, 0, 63, "#"); + TH1* RegionCounts = static_cast(HandleRegionCounts); + const base::H1handle HandleColumns = MakeH1("Columns", "Hits per Column", 1024, 0, 1024, "#"); + TH1* Columns = static_cast(HandleColumns); + const base::H1handle HandleErrorFlags = MakeH1("ErrorFlags", "", 9, 0, 9, "Bit"); + TH1* ErrorFlags = static_cast(HandleErrorFlags); + const base::H2handle HandleFrameLengthDist = MakeH2("FrameLengthDist", "", 1024,0,1024,1024,0,1024,"this frame ; last frame"); + TH2* FrameLengthDist = static_cast(HandleFrameLengthDist); + const base::H2handle HandleMatrix = MakeH2("Matrix", "", 1024,0,1024,508,0,508); + TH2* Matrix = static_cast(HandleMatrix); + const base::H2handle HandleMatrixCurrent = MakeH2("MatrixCurrent", "", 1024,0,1024,508,0,508); + TH2* MatrixCurrent = static_cast(HandleMatrixCurrent); + const base::H2handle HandleMatrixLast = MakeH2("MatrixLast", "", 1024,0,1024,508,0,508); + TH2* MatrixLast = static_cast(HandleMatrixLast); + const base::H1handle HandleLast4096 = MakeH1("Last 4096 Content", "", 4095, 0, 4095, "Last 4096 Content"); + TH1* Last4096 = static_cast(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 long& column, unsigned long& row) const noexcept + virtual bool DecodePixel(const unsigned int& word, unsigned int& column, unsigned int& row) const noexcept { - const unsigned long pixelcode = (word >> 6) & 0x3ff; - unsigned long side = 0, topdown = 0; + 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; @@ -60,6 +73,7 @@ namespace hadaq : hadaq::SubProcessor(trb, "%04X", subid) , trb(trb) , sensor(subid-0xa000) + , sensoraddress(subid) {} @@ -81,106 +95,111 @@ namespace hadaq bool hadaq::MimosisProcessor::FirstBufferScan(const base::Buffer& buf) noexcept { const uint32_t len = buf.datalen()/4; - const uint32_t * arr = static_cast(buf.ptr()); - unsigned n = 0; - unsigned long column, row, lastcolumn = -1, lastrow = -1, headers = 0, trailers = 0; - unsigned headersnow = 0; - signed lastlength = -1; - + const uint32_t* arr = static_cast(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; - for (;n> 16; + frameNumber += (data & 0xFF) << 8; + } + + else if (headersnow == 2) { + frameNumber += data & 0xFF0000; + frameNumber += (data & 0xFF) << 24; + } } - else if((data & 0xFF000000) == 0xFF000000) - { +//End of frame - process frame results and error flags + else if ((data & 0xFF000000) == 0xFF000000) { length--; trailers++; frameCounter++; - FillH2(MatrixCurrent,-1,-1); - + MatrixCurrent->Fill(-1, -1); - if(frameCounter == 10000) - { - static_cast(MatrixCurrent)->Copy(*static_cast(MatrixLast)); - ClearH2(MatrixCurrent); + Last4096->SetBinContent(frameNumber % 4096, hitcount); + hitcount = 0; + if (frameCounter == 10000) { + MatrixCurrent->Copy(*MatrixLast); + MatrixLast->SetName("MatrixLast10000"); + MatrixCurrent->Reset(); + RegionCounts->Reset(); frameCounter = 0; } headersnow = 0; - FillH1(FrameLength,length); - if(lastlength != -1) - { - FillH2(FrameLengthDist, length, lastlength); + FrameLength->Fill(length); + + if (lastlength != -1) { + FrameLengthDist->Fill(length, lastlength); } lastlength = length; - FillH2(LengthvsError,length,(data & 0x00080000) ? 1 : 0); - - if(data & 0x00010000) FillH1(ErrorFlags,0); - if(data & 0x00020000) FillH1(ErrorFlags,1); - if(data & 0x00040000) FillH1(ErrorFlags,2); - if(data & 0x00080000) FillH1(ErrorFlags,3); - if(data & 0x00100000) FillH1(ErrorFlags,4); - if(data & 0x00200000) FillH1(ErrorFlags,5); - if(data & 0x00400000) FillH1(ErrorFlags,6); - if(data & 0x00800000) FillH1(ErrorFlags,7); - if(!(data & 0x00FF0000)) FillH1(ErrorFlags,8); + 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 - { + else { headersnow = 0; - if((data & 0xFF000000) == 0xFD000000) - { + +//New region starts - save region number + if ((data & 0xFF000000) == 0xFD000000) { lastRegion = region; - const int tmp = (data>>16) & 0xFF; - // if(tmp >63) - // { - // printf("%08x %08x %08x %i %i %i %i\n",arr[n-1],arr[n],arr[n+1],tmp, lastRegion, sensor, n%4); - // } - if(tmp > 63) continue; + int tmp = (data >> 16) & 0xFF; + if (tmp > 63) + continue; region = tmp; - FillH1(RegionHeaders,region); - - } - else - { - DecodePixel(data>>16,column,row); - FillH1(Columns,column); - FillH2(Matrix,column,row); - FillH2(MatrixCurrent,column,row); + 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); } - if((data & 0x0000FF00) != 0x0000FC00) - { - DecodePixel(data&0xFFFF,column,row); - FillH1(Columns,column); - FillH2(Matrix,column,row); - FillH2(MatrixCurrent,column,row); +//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); } } } - FillH1(NumHeaders, headers); - FillH1(NumTrailers, trailers); - FillH1(NumHTDiff, static_cast(headers)/4-trailers); +NumHeaders->Fill(headers); +NumTrailers->Fill(trailers); - return true; +return true; } #endif diff --git a/analysis/scurve/mimosis.h b/analysis/scurve/mimosis.h index b8864da..2edaadb 100644 --- a/analysis/scurve/mimosis.h +++ b/analysis/scurve/mimosis.h @@ -218,6 +218,9 @@ bool hadaq::MimosisProcessor::FirstBufferScan(const base::Buffer& buf) noexcept { auto exec = [=](){ + // std::ofstream fa; + // fa.open("alldata.csv"); + std::ofstream fs; fs.open("params.csv"); @@ -226,24 +229,24 @@ bool hadaq::MimosisProcessor::FirstBufferScan(const base::Buffer& buf) noexcept for(int j = pulseColRegionLow; jFixParameter(0,50000); + f1->SetParLimits(0,0,55000); f1->SetParLimits(1,0,255); - f1->SetParLimits(2,0,50); + f1->SetParLimits(2,0,60); + f1->SetParameters(50000,100,10); + f1->SetParError(1, 0.1); + f1->SetParError(2, 0.01); auto hist = static_cast(SCurveRegionA)->ProjectionX(" ",i*colsN+j,i*colsN+j); int status = static_cast(hist)->Fit("f1","NQS"); - if(status != 0) - { - fs << j << "\t" << i << "\t" << status << "\t0\t0\n"; - } - else if(status == 0) - { - fs << j << "\t" << i << "\t" << status << "\t" << f1->GetParameter(1) << "\t" << f1->GetParameter(2) << "\n"; - } + fs << j << "\t" << i << "\t" << status << "\t" << f1->GetParameter(1) << "\t" << f1->GetParameter(2) << "\n"; delete hist; delete f1; } } fs.close(); printf("fit done.\n"); + + static_cast(SCurveRegionA)->Print("alldata.csv"); }; std::thread t(exec); diff --git a/http/htdocs/pulse.htm b/http/htdocs/pulse.htm index b270a60..d137735 100644 --- a/http/htdocs/pulse.htm +++ b/http/htdocs/pulse.htm @@ -45,5 +45,4 @@ - diff --git a/http/htdocs/setreg.pl b/http/htdocs/setreg.pl index 923e4df..81a02d0 100755 --- a/http/htdocs/setreg.pl +++ b/http/htdocs/setreg.pl @@ -6,9 +6,15 @@ eval{ print "Content-type: text/html\r\n\r\n"; # print "Location: index.html\r\n\r\n"; }; - -my ($fpga,$reg,$value) = split('-',$ENV{'QUERY_STRING'}); + +my ($fpga,$register,$value) = split('-',$ENV{'QUERY_STRING'}); if(!defined $value) {exit 1;} -#print("cd ../scripts; ./mimosis_i2c_cmd.pl -f $fpga -r $reg -d $value"); -system("cd ../scripts; ./mimosis_i2c_cmd.pl -f $fpga -r $reg -d $value -s"); + +#print("cd ../scripts; ./mimosis_i2c_cmd.pl -f $fpga -r $register -d $value"); +#system("cd ../scripts; ./mimosis_i2c_cmd.pl -f $fpga -r $register -d $value -s"); +#exit 1; + +$register= sprintf("%x",$register); +$value = sprintf("%x",$value); +system("/u/maps/bin/mimosis -f 0xa000 -a reg $register $value"); exit 1; diff --git a/scripts/Mimosis.pm b/scripts/Mimosis.pm index 8bba9fa..4efd2c7 100755 --- a/scripts/Mimosis.pm +++ b/scripts/Mimosis.pm @@ -10,45 +10,45 @@ use Term::ANSIColor; #use FileHandle; #use Data::Dumper; -sub adc_i2c_command { - +sub adc_i2c_command +{ my ( $fpga, $addr, $cmd, $data, $readwrite, $skipcmd, $wordbyte ) = @_; $reg_data = ( $data << 16 ) + ( $cmd << 8 ) + 0x80 + $addr; $reg_flag = ( $readwrite << 8 ) + ( $skipcmd << 4 ) + $wordbyte; - if ( $readwrite == 0 ) { + if ( $readwrite == 0 ) + { trb_register_write_mem( $fpga, 0xd681, 0, [ $reg_flag, $reg_data ], 2 ); } - elsif ( $readwrite == 1 ) { + elsif ( $readwrite == 1 ) + { trb_register_write_mem( $fpga, 0xd681, 0, [ $reg_flag, $reg_data ], 2 ); usleep(1000); my $reg_return = trb_register_read( $fpga, 0xd684 ); return $reg_return->{$fpga} & 0xffff; - } } -sub mimosis_i2c_command { - +sub mimosis_i2c_command +{ my ( $fpga, $addr, $cmd, $data, $readwrite, $skipcmd, $wordbyte ) = @_; $reg_data = ( $data << 16 ) + ( $cmd << 8 ) + ( $addr << 1 ); $reg_flag = ( $readwrite << 8 ) + ( $skipcmd << 4 ) + $wordbyte; - if ( $readwrite == 0 ) { - + if ( $readwrite == 0 ) + { # printf( "%x %x %x %x\n", $fpga, $addr, $cmd, $data ); # printf( "%x %x\n", $reg_flag, $reg_data ); - trb_register_write_mem( $fpga, 0xde01, 0, [ $reg_flag, $reg_data, 0x1 ], 3 ); + trb_register_write_mem( $fpga, 0xde01, 0, [ $reg_flag, $reg_data, 0x1 ], 3 ); } elsif ( $readwrite == 1 ) { # printf( "%x %x %x %x\n", $fpga, $addr, $cmd, $data ); - trb_register_write_mem( $fpga, 0xde01, 0, - [ $reg_flag, $reg_data, 0x1 ], 3 ); + trb_register_write_mem( $fpga, 0xde01, 0, [ $reg_flag, $reg_data, 0x1 ], 3 ); usleep(1000); my $reg_return = trb_register_read( $fpga, 0xde04 ); return $reg_return->{$fpga} & 0xffff; @@ -57,7 +57,8 @@ sub mimosis_i2c_command { -sub mimosis_register_write { +sub mimosis_register_write +{ my ( $fpga, $mimosis_reg, $mimosis_data, $singleaccess ) = @_; my ( $addr, $cmd, $data ); @@ -66,23 +67,26 @@ sub mimosis_register_write { $data = ( ( $mimosis_reg & 0xff ) << 8 ) + $mimosis_data; # printf( "%x %x\n", $cmd, $data ); - if ($singleaccess) { - mimosis_i2c_command( $fpga, $addr, 0, $mimosis_reg>>8, 0, 1, 0); - usleep(1000); - mimosis_i2c_command( $fpga, $addr+1, 0, $mimosis_reg, 0, 1, 0); - usleep(1000); - mimosis_i2c_command( $fpga, $addr+2, 0, $mimosis_data, 0, 1, 0); - } - else { - mimosis_i2c_command( $fpga, $addr, $cmd, $data, 0, 0, 1); -#print "check Mimosis::mimosis_register_write()\n"; - } + if ($singleaccess) + { + mimosis_i2c_command( $fpga, $addr, 0, $mimosis_reg>>8, 0, 1, 0); + usleep(1000); + mimosis_i2c_command( $fpga, $addr+1, 0, $mimosis_reg, 0, 1, 0); + usleep(1000); + mimosis_i2c_command( $fpga, $addr+2, 0, $mimosis_data, 0, 1, 0); + } + else + { + mimosis_i2c_command( $fpga, $addr, $cmd, $data, 0, 0, 1); + # print "check Mimosis::mimosis_register_write()\n"; + } usleep(1000); } -sub mimosis_register_read { +sub mimosis_register_read +{ my ( $fpga, $mimosis_reg, $singleaccess) = @_; my ( $addr, $cmd, $data ); @@ -90,14 +94,16 @@ sub mimosis_register_read { $cmd = ( $mimosis_reg >> 8 ); $data = ( $mimosis_reg & 0xff ); - if ($singleaccess) { - mimosis_i2c_command( $fpga, $addr, 0, $mimosis_reg>>8, 0, 1, 0); - usleep(1000); - mimosis_i2c_command( $fpga, $addr+1, 0, $mimosis_reg, 0, 1, 0); - } - else { - mimosis_i2c_command( $fpga, $addr, $cmd, $data, 0, 0, 0); - } + if ($singleaccess) + { + mimosis_i2c_command( $fpga, $addr, 0, $mimosis_reg>>8, 0, 1, 0); + usleep(1000); + mimosis_i2c_command( $fpga, $addr+1, 0, $mimosis_reg, 0, 1, 0); + } + else + { + mimosis_i2c_command( $fpga, $addr, $cmd, $data, 0, 0, 0); + } # printf( "%x %x %x %x\n", $fpga, $addr, $cmd, $data ); usleep(1000); @@ -110,9 +116,10 @@ sub mimosis_register_read { -sub mimosis_instr_write { - my ( $fpga, $command ) = @_; - trb_register_write_mem( $fpga, 0xde01, 0, [ 0x0, ( $command << 8 ) + ( 0x11 << 1 ), 0x1 ], 3 ); +sub mimosis_instr_write +{ + my ( $fpga, $command ) = @_; + trb_register_write_mem( $fpga, 0xde01, 0, [ 0x0, ( $command << 8 ) + ( 0x11 << 1 ), 0x1 ], 3 ); } @@ -377,11 +384,12 @@ END_MESSAGE -sub mimosis_scan_region { - +sub mimosis_scan_region +{ my %params = @_; my $fpga = $params{'fpga'}; + my $pulseonly = $params{'pulseonly'}; my $region = $params{'region'}; my $firstrow = $params{'firstrow'}; my $lastrow = $params{'lastrow'}; @@ -393,7 +401,7 @@ sub mimosis_scan_region { my $lastset = $params{'lastset'}; my $setdiv = $params{'setdiv'}; my $settime = $params{'settime'}; - my $slow = $params{'s'}; + my $slow = $params{'slow'}; my $a = $params{'a'}; my $rowsatonce = $params{'rowsatonce'}; my $printset = $params{'printset'}; @@ -543,6 +551,236 @@ sub mimosis_scan_region { +sub mimosis_scan_pixel +{ + my %params = @_; + + my $fpga = $params{'fpga'}; + my $colpix = $params{'colpix'}; + my $rowpix = $params{'rowpix'}; + my $firstset = $params{'firstset'}; + my $lastset = $params{'lastset'}; + my $setdiv = $params{'setdiv'}; + my $settime = $params{'settime'}; + my $pulseonly = $params{'pulseonly'}; + my $slow = $params{'slow'}; + my $a = $params{'a'}; + my $printset = $params{'printset'}; + my $printall = $params{'printall'}; + my $analogAlimA = $params{'analogAlimA'}; + my $analogAlimB = $params{'analogAlimB'}; + my $analogDlimA = $params{'analogDlimA'}; + my $analogDlimB = $params{'analogDlimB'}; + my $modpulse = $params{'modpulse'}; + + defined $fpga or die "Mimosis::mimosis_scan_pixel: Must provide $fpga."; + defined $colpix or die "Mimosis::mimosis_scan_pixel: Must provide $colpix."; + defined $rowpix or die "Mimosis::mimosis_scan_pixel: Must provide $rowpix."; + + $firstset = defined $firstset ? $firstset : 0x0; + $lastset = defined $lastset ? $lastset : 0xff; + $setdiv = defined $setdiv ? $setdiv : 1; + $settime = defined $settime ? $settime : 1000; + $slow = defined $slow ? $slow : 10000; + $a = defined $a ? $a : 0; + $printset = defined $printset ? 1 : 0; + $printall = defined $printall ? 1 : 0; + $pixpulseA_A = defined $pixpulseA_A ? $pixpulseA_A : 25; + $pixpulseA_B = defined $pixpulseA_B ? $pixpulseA_B : 75; + $pixpulseD_A = defined $pixpulseD_A ? $pixpulseD_A : 0; + $pixpulseD_B = defined $pixpulseD_B ? $pixpulseD_B : 0; + $modpulse = defined $modpulse ? $modpulse : 3; + + if( !( $colpix < 1024 && $rowpix < 503 ) ) + { + print colored ( "Specified column/row values seem to be unlogic. Aborting.", 'red' ), "\n"; + exit 1; + } + + my $pixpulseA_A_msb = ( $pixpulseA_A & 0xff00 ) >> 8; + my $pixpulseA_A_lsb = $pixpulseA_A & 0x00ff; + my $pixpulseA_B_msb = ( $pixpulseA_B & 0xff00 ) >> 8; + my $pixpulseA_B_lsb = $pixpulseA_B & 0x00ff; + my $pixpulseD_A_msb = ( $pixpulseD_A & 0xff00 ) >> 8; + my $pixpulseD_A_lsb = $pixpulseD_A & 0x00ff; + my $pixpulseD_B_msb = ( $pixpulseD_B & 0xff00 ) >> 8; + my $pixpulseD_B_lsb = $pixpulseD_B & 0x00ff; + + Mimosis::mimosis_register_write( $fpga, 0x0020, 0x40, $a ); usleep($slow); #EN_PIXELMASK to 0 for pulse + Mimosis::mimosis_instr_write( $fpga, 0x3f ); usleep($slow); #INSTR select all pixels + Mimosis::mimosis_instr_write( $fpga, 0x04 ); usleep($slow); #INSTR reset mask + Mimosis::mimosis_instr_write( $fpga, 0x3e ); usleep($slow); #INSTR unselect all pixels + Mimosis::mimosis_register_write( $fpga, 0x0066, $pixpulseA_A_lsb, $a ); usleep($slow); #analog pulsing pulse A, limit A + Mimosis::mimosis_register_write( $fpga, 0x0166, $pixpulseA_A_msb, $a ); usleep($slow); + Mimosis::mimosis_register_write( $fpga, 0x0076, $pixpulseA_B_lsb, $a ); usleep($slow); # analog pulsing pulse A, limit B + Mimosis::mimosis_register_write( $fpga, 0x0176, $pixpulseA_B_msb, $a ); usleep($slow); + Mimosis::mimosis_register_write( $fpga, 0x0067, $pixpulseD_A_lsb, $a ); usleep($slow); # analog pulsing pulse D, limit A + Mimosis::mimosis_register_write( $fpga, 0x0167, $pixpulseD_A_msb, $a ); usleep($slow); + Mimosis::mimosis_register_write( $fpga, 0x0077, $pixpulseD_B_lsb, $a ); usleep($slow); # analog pulsing pulse D, limit B + Mimosis::mimosis_register_write( $fpga, 0x0177, $pixpulseD_B_msb, $a ); usleep($slow); + Mimosis::mimosis_register_write( $fpga, 0x007d, $modpulse, $a ); usleep($slow); #set modpulse. possible values: 1f/1, 1f/2, 1f/4, 1f/8, 1f/16, 1f/32, 1f/64, 1f/128 + + my $rAddrC = $colpix/16; #region address + my $bitC = ($colpix/2)%8; #double column in region + my $add_regC = $rAddrC << 8; + if (($colpix%2 == 1)) { $add_regC += 0x82; } + elsif (($colpix%2 == 0)) { $add_regC += 0x81; } + + my $rAddrR = $rowpix/8; + my $bitR = $rowpix%8; + my $add_regR = ( $rAddrR << 8 ) + 0x84; + + Mimosis::mimosis_register_write( $fpga, $add_regC, ( 0x1 << $bitC ), $a ); usleep($s); + Mimosis::mimosis_register_write( $fpga, $add_regR, ( 0x1 << $bitR ), $a ); usleep($s); + Mimosis::mimosis_instr_write( $fpga, 0x05 ); usleep($s); #INSTR set mask pulse + Mimosis::mimosis_register_write( $fpga, 0x4087, 0x0, $a ); usleep($s); #unselect all pixels (register wise) + + if( defined $pulseonly ){ exit 0; } + + my $setcounter = 0; + for my $set (reverse ($firstset .. $lastset) ) + { + $setcounter = $setcounter + 1; + if( ($setcounter-1)%$setdiv != 0) { next; } + + my $pulseNumber = ( $set << 24 ) + ( ( $colpix & 0x3ff ) << 12 ) + ( $rowpix & 0x1ff ); + trb_register_write_mem( $fpga, 0xa209, 0, [ $pulseNumber ], 1 ); usleep($slow); + Mimosis::mimosis_register_write( $fpga, 0x0046, $set, $a ); usleep($settime); + + if( $printset || $printall ) { printf("set: $set\n"); } + } + + Mimosis::mimosis_instr_write( $fpga, 0x3f ); usleep($slow); + Mimosis::mimosis_instr_write( $fpga, 0x04 ); usleep($slow); #INSTR set mask pulse + Mimosis::mimosis_instr_write( $fpga, 0x3e ); usleep($slow); #INSTR set mask pulse + + trb_register_write_mem( $fpga, 0xa209, 0, [ 0 ], 1 ); + exit 0; +} + + + +sub mimosis_scan_line +{ + my %params = @_; + + my $fpga = $params{'fpga'}; + my $pulseonly = $params{'pulseonly'}; + my $firstrow = $params{'firstrow'}; + my $lastrow = $params{'lastrow'}; + my $rowdiv = $params{'rowdiv'}; + my $firstcol = $params{'firstcol'}; + my $lastcol = $params{'lastcol'}; + my $coldiv = $params{'coldiv'}; + my $firstset = $params{'firstset'}; + my $lastset = $params{'lastset'}; + my $setdiv = $params{'setdiv'}; + my $settime = $params{'settime'}; + my $slow = $params{'slow'}; + my $a = $params{'a'}; + my $rowsatonce = $params{'rowsatonce'}; + my $printset = $params{'printset'}; + my $printrow = $params{'printrow'}; + my $printcol = $params{'printcol'}; + my $printall = $params{'printall'}; + my $analogAlimA = $params{'analogAlimA'}; + my $analogAlimB = $params{'analogAlimB'}; + my $analogDlimA = $params{'analogDlimA'}; + my $analogDlimB = $params{'analogDlimB'}; + my $modpulse = $params{'modpulse'}; + + defined $fpga or die "Mimosis::mimosis_scan_line: Must provide $fpga."; + + $firstrow = defined $firstrow ? $firstrow : 0; + $lastrow = defined $lastrow ? $lastrow : 504; + $rowdiv = defined $rowdiv ? $rowdiv : 1; + $firstcol = defined $firstcol ? $firstcol : 0; + $lastcol = defined $lastcol ? $lastcol : 1023; + $coldiv = defined $coldiv ? $coldiv : 1; + $firstset = defined $firstset ? $firstset : 0x0; + $lastset = defined $lastset ? $lastset : 0xff; + $setdiv = defined $setdiv ? $setdiv : 1; + $settime = defined $settime ? $settime : 1000; + $slow = defined $slow ? $slow : 10000; + $a = defined $a ? $a : 0; + $rowsatonce = defined $rowsatonce ? $rowsatonce : 1; + $printset = defined $printset ? 1 : 0; + $printrow = defined $printrow ? 1 : 0; + $printcol = defined $printcol ? 1 : 0; + $printall = defined $printall ? 1 : 0; + $pixpulseA_A = defined $pixpulseA_A ? $pixpulseA_A : 25; + $pixpulseA_B = defined $pixpulseA_B ? $pixpulseA_B : 75; + $pixpulseD_A = defined $pixpulseD_A ? $pixpulseD_A : 0; + $pixpulseD_B = defined $pixpulseD_B ? $pixpulseD_B : 0; + $modpulse = defined $modpulse ? $modpulse : 3; + + my $pixpulseA_A_msb = ( $pixpulseA_A & 0xff00 ) >> 8; + my $pixpulseA_A_lsb = $pixpulseA_A & 0x00ff; + my $pixpulseA_B_msb = ( $pixpulseA_B & 0xff00 ) >> 8; + my $pixpulseA_B_lsb = $pixpulseA_B & 0x00ff; + my $pixpulseD_A_msb = ( $pixpulseD_A & 0xff00 ) >> 8; + my $pixpulseD_A_lsb = $pixpulseD_A & 0x00ff; + my $pixpulseD_B_msb = ( $pixpulseD_B & 0xff00 ) >> 8; + my $pixpulseD_B_lsb = $pixpulseD_B & 0x00ff; + + + Mimosis::mimosis_register_write( $fpga, 0x0020, 0x40, $a ); usleep($slow); #EN_PIXELMASK to 0 for pulse + Mimosis::mimosis_instr_write( $fpga, 0x3f ); usleep($slow); #INSTR select all pixels + Mimosis::mimosis_instr_write( $fpga, 0x04 ); usleep($slow); #INSTR reset mask + Mimosis::mimosis_instr_write( $fpga, 0x3e ); usleep($slow); #INSTR unselect all pixels + Mimosis::mimosis_register_write( $fpga, 0x0066, $pixpulseA_A_lsb, $a ); usleep($slow); #analog pulsing pulse A, limit A + Mimosis::mimosis_register_write( $fpga, 0x0166, $pixpulseA_A_msb, $a ); usleep($slow); + Mimosis::mimosis_register_write( $fpga, 0x0076, $pixpulseA_B_lsb, $a ); usleep($slow); # analog pulsing pulse A, limit B + Mimosis::mimosis_register_write( $fpga, 0x0176, $pixpulseA_B_msb, $a ); usleep($slow); + Mimosis::mimosis_register_write( $fpga, 0x0067, $pixpulseD_A_lsb, $a ); usleep($slow); # analog pulsing pulse D, limit A + Mimosis::mimosis_register_write( $fpga, 0x0167, $pixpulseD_A_msb, $a ); usleep($slow); + Mimosis::mimosis_register_write( $fpga, 0x0077, $pixpulseD_B_lsb, $a ); usleep($slow); # analog pulsing pulse D, limit B + Mimosis::mimosis_register_write( $fpga, 0x0177, $pixpulseD_B_msb, $a ); usleep($slow); + Mimosis::mimosis_register_write( $fpga, 0x007d, $modpulse, $a ); usleep($slow); #set modpulse. possible values: 1f/1, 1f/2, 1f/4, 1f/8, 1f/16, 1f/32, 1f/64, 1f/128 + + for ( my $y = $firstrow; $y < $lastrow; $y+=$rowdiv ) + { + my $rAddrR = $y/8; + my $bitR = $y%8; + my $add_regR = ( $rAddrR << 8 ) + 0x84; + + if( $printrow || $printall ) { printf("row: $y\n"); } + + for( my $x = $firstcol; $x <= $lastcol; $x+=$coldiv ) + { + my $rAddrC = $x/16; #region address + my $bitC = ($x/2)%8; #double column in region + my $add_regC = ($rAddrC << 8); + if (($x%2 == 1)) { $add_regC += 0x82; } + elsif (($x%2 == 0)) { $add_regC += 0x81; } + + Mimosis::mimosis_register_write( $fpga, $add_regC, ( 0x1 << $bitC ), $a ); usleep($slow); + Mimosis::mimosis_register_write( $fpga, $add_regR, ( 0x1 << $bitR ), $a ); usleep($slow); + Mimosis::mimosis_instr_write( $fpga, 0x05 ); usleep($slow); #INSTR set mask pulse + Mimosis::mimosis_register_write( $fpga, 0x4087, 0x0, $a ); usleep($slow); #unselect all pixels (register wise) + + if( $printcol || $printall ) { printf("col: $x\n"); } + } + } + + + for ( my $set = $lastset; $set >= $firstset; $set -= $setdiv ) + { + + my $pulseNumber = ($set << 24) + 0x00c00000 + ($regBit << 20) + $yi; + trb_register_write_mem( $fpga, 0xa209, 0, [ $pulseNumber ], 1 ); usleep($slow); + Mimosis::mimosis_register_write( $fpga, 0x0046, $set, $a ); usleep($settime); + + if( $printset || $printall ) { printf("set: $set\n"); } + } + + Mimosis::mimosis_instr_write( $fpga, 0x3f ); usleep($slow); + Mimosis::mimosis_instr_write( $fpga, 0x04 ); usleep($slow); #INSTR set mask pulse + Mimosis::mimosis_instr_write( $fpga, 0x3e ); usleep($slow); #INSTR set mask pulse +} + + + sub mimosis_mask { my %params = @_; @@ -568,7 +806,8 @@ sub mimosis_mask trb_init_ports() or die trb_strerror(); - if ( defined $maskall ) { + if ( defined $maskall ) + { Mimosis::mimosis_register_write( $fpga, 0x0020, 0x42, $a ); usleep($slow); #EN_PIXELMASK Mimosis::mimosis_instr_write( $fpga, 0x3f ); usleep($slow); #INSTR select all pixels Mimosis::mimosis_instr_write( $fpga, 0x05 ); usleep($slow); #INSTR set mask pulse @@ -576,7 +815,8 @@ sub mimosis_mask exit; } - if ( defined $unmaskall ) { + if ( defined $unmaskall ) + { Mimosis::mimosis_register_write( $fpga, 0x0020, 0x42, $a ); usleep($slow); #EN_PIXELMASK Mimosis::mimosis_instr_write( $fpga, 0x3f ); usleep($slow); #INSTR select all pixels Mimosis::mimosis_instr_write( $fpga, 0x04 ); usleep($slow); #INSTR reset mask pulse @@ -584,7 +824,8 @@ sub mimosis_mask exit; } - if ( defined $hline ) { + if ( defined $hline ) + { Mimosis::mimosis_register_write( $fpga, 0x0020, 0x42, $a ); usleep($slow); #EN_PIXELMASK Mimosis::mimosis_instr_write( $fpga, 0x3e ); usleep($slow); #INSTR unselect all pixels Mimosis::mimosis_instr_write( $fpga, 0x27 ); usleep($slow); #select all columns @@ -595,7 +836,8 @@ sub mimosis_mask exit; } - if ( defined $vline ) { + if ( defined $vline ) + { Mimosis::mimosis_register_write( $fpga, 0x0020, 0x42, $a ); usleep($slow); #EN_PIXELMASK Mimosis::mimosis_instr_write( $fpga, 0x3e ); usleep($slow); #INSTR unselect all the pixels Mimosis::mimosis_register_write( $fpga, 0x0d83, 0xff, $a ); usleep($slow); #select some columns @@ -606,7 +848,8 @@ sub mimosis_mask exit; } - if ( defined $square ) { + if ( defined $square ) + { Mimosis::mimosis_register_write( $fpga, 0x0020, 0x42, $a ); usleep($slow); #EN_PIXELMASK Mimosis::mimosis_instr_write( $fpga, 0x3e ); usleep($slow); #INSTR unselect all pixels Mimosis::mimosis_register_write( $fpga, 0x0887, 0xff, $a ); usleep($slow); @@ -636,19 +879,23 @@ sub mimosis_mask my $cl; my $ch; - if ( defined $col && $col =~ /(\b[0-9]{1,4}),([0-9]{1,4}\b)/ && $1 < $2 && $1 < 1024 && $2 < 1024) { + if ( defined $col && $col =~ /(\b[0-9]{1,4}),([0-9]{1,4}\b)/ && $1 < $2 && $1 < 1024 && $2 < 1024) + { $cl = $1; $ch = $2; } - elsif ( defined $col && $col =~ /(^[0-9]{1,4}$)/ && $1 < 1024) { + elsif ( defined $col && $col =~ /(^[0-9]{1,4}$)/ && $1 < 1024) + { $cl = $1; $ch = $1; } - elsif ( defined $region ) { + elsif ( defined $region ) + { $cl = $col_limits->{$region}->[0]; $ch = $col_limits->{$region}->[1]; } - else { + else + { print colored ( "Either specified column values doesn't match INT,INT or values are unlogic. Using all columns now. You have 10 seconds to abort with Ctrl-C.", 'red' ), "\n"; sleep 10; $cl = 0; @@ -658,19 +905,23 @@ sub mimosis_mask my $rl; my $rh; - if ( defined $row && $row =~ /(\b[0-9]{1,3}),([0-9]{1,3}\b)/ && $1 < $2 && $1 < 504 && $2 < 504) { + if ( defined $row && $row =~ /(\b[0-9]{1,3}),([0-9]{1,3}\b)/ && $1 < $2 && $1 < 504 && $2 < 504) + { $rl = $1; $rh = $2; } - elsif ( defined $row && $row =~ /(^[0-9]{1,3})$/ && $1 < 504) { + elsif ( defined $row && $row =~ /(^[0-9]{1,3})$/ && $1 < 504) + { $rl = $1; $rh = $1; } - elsif ( defined $region ) { + elsif ( defined $region ) + { $rl = 0; $rh = 503; } - else { + else + { print colored ( "Either specified row values doesn't match INT,INT or values are unlogic. Using all rows now. You have 10 seconds to abort with Ctrl-C.", 'red' ), "\n"; sleep 10; $rl = 0; @@ -683,14 +934,16 @@ sub mimosis_mask # Select pixels to mask - for my $x ($cl .. $ch) { + for my $x ($cl .. $ch) + { my $rAddrC = $x/16; #region address my $bitC = ($x/2)%8; #double column in region my $add_regC = $rAddrC << 8; if (($x%2 == 1)) { $add_regC += 0x82; } elsif (($x%2 == 0)) { $add_regC += 0x81; } - for my $y ($rl .. $rh) { + for my $y ($rl .. $rh) + { my $rAddrR = $y/8; my $bitR = $y%8; my $add_regR = ( $rAddrR << 8 ) + 0x84; @@ -703,13 +956,10 @@ sub mimosis_mask if( $printall ){ printf "%d %x %x %d %d %x\n", $x, $add_regC, ( 1 << $bitC ), $y, $add_regR, ( 1 << $bitR ); } } } - } - - 1; __END__ diff --git a/scripts/cli/mimosis b/scripts/cli/mimosis index 82c279b..8aecbf7 100755 --- a/scripts/cli/mimosis +++ b/scripts/cli/mimosis @@ -13,13 +13,14 @@ use Data::Dump qw(dump); $SIG{INT} = sub { die "\nAbort.\n" }; +# print $ARGV[-1]; +# print dump @ARGV; my $fpga; my $a; my $slow; #load -my $file; my $printall_load; my $printwrong_load; @@ -30,6 +31,9 @@ my $cleanup_dacscan; my $printall_dacscan; #scurves +my $colpix_scurves; +my $rowpix_scurves; +my $pulseonly_scurves; my $region_scurves; my $firstrow_scurves; my $lastrow_scurves; @@ -63,8 +67,10 @@ my $vline_mask; my $square_mask; my $printall_mask; -#pulse +#instr +my $cmd_instr; +#reg my $res = GetOptions( @@ -90,7 +96,6 @@ my $res = GetOptions( { options => { - 'file|d=s' => \$file, 'printall|p' => \$printall_load, 'printwrong|w' => \$printwrong_load, }, @@ -109,6 +114,9 @@ my $res = GetOptions( { options => { + "colpix=s" => \$colpix_scurves, + "rowpix=s" => \$rowpix_scurves, + "pulseonly" => \$pulseonly_scurves, "region|r=s" => \$region_scurves, "firstrow=s" => \$firstrow_scurves, "lastrow=s" => \$lastrow_scurves, @@ -149,17 +157,20 @@ my $res = GetOptions( "printall|p" => \$printall_mask, }, }, - pulse => + instr => { options => { + "cmd|c=s" => \$cmd_instr, }, }, - i2c => + reg => { options => { }, + }, + }, completion => sub @@ -169,6 +180,8 @@ my $res = GetOptions( ); die "GetOptions failed!\n" unless $res->{success}; +# print $ARGV[-1]; +# print dump @ARGV; sub help_global { @@ -188,9 +201,8 @@ GLOBAL OPTIONS are: dacscan Make a DAC scan. scurves Make a S-Curve scan of mimosis or some parts of it. mask Mask some pixels. - pulse Pulse some pixels. (not yet implemented) - i2c Send a single i2c command. (not yet implemented) - adc Send a single i2c command to the adc. (not yet implemented) + instr Send an instruction to mimosis. + reg Write into a register. For every a short description is accessible with the -h option. END_MESSAGE @@ -200,7 +212,7 @@ END_MESSAGE elsif ( $_[2]->{_non_options_argv}[0] eq 'load' ) { my $message = <<'END_MESSAGE'; -usage: mimosis [GLOBAL OPTIONS] load [COMMAND OPTIONS] +usage: mimosis [GLOBAL OPTIONS] load [COMMAND OPTIONS] PATH GLOBAL OPTIONS are: -f, --fpga=HEX -> Hex address of the FPGA. Defaults to 0xa000. @@ -209,7 +221,6 @@ GLOBAL OPTIONS are: -h, --help -> Print this or specific help. COMMAND OPTIONS are: - -d, --file=PATH -> File with configurations by full or relativ PATH. Must be provided. -p, --printall -> Print all settings from file to stdout. -w, --printwrong -> Print all settings, that were not loaded to mimosis correctly stdout. -h, --help -> Print this help. @@ -249,6 +260,9 @@ GLOBAL OPTIONS are: -h, --help -> Print this or specific help. COMMAND OPTIONS are: + --colpix -> x value of a single pixel to pulse. + --rowpix -> y value of a single pixel to pulse. + --pulseonly -> if set, mark specified pixels only for pulsing and dont do a scan. --region A|B|C|D -> Region to pulse. If provided, ignores --collow, --colhig, --rowlow and --rowhig --x COL -> Column of a single pixel to pulse. --y COL -> Row of a single pixel to pulse. @@ -292,10 +306,10 @@ END_MESSAGE print $message; exit 0; } - elsif ( $_[2]->{_non_options_argv}[0] eq 'pulse' ) + elsif ( $_[2]->{_non_options_argv}[0] eq 'instr' ) { my $message = <<'END_MESSAGE'; -usage: mimosis [GLOBAL OPTIONS] pulse [COMMAND OPTIONS] +usage: mimosis [GLOBAL OPTIONS] instr [COMMAND OPTIONS] GLOBAL OPTIONS are: -f, --fpga=HEX -> Hex address of the FPGA. Defaults to 0xa000. @@ -304,6 +318,7 @@ GLOBAL OPTIONS are: -h, --help -> Print this or specific help. COMMAND OPTIONS are: + -c, --cmd -> Instruction to send. -h, --help -> Print this help. END_MESSAGE print $message; @@ -327,6 +342,16 @@ if( $res->{subcommand}[0] eq 'default' ) elsif( $res->{subcommand}[0] eq 'load' ) { + if( defined $ARGV[-1] && -e $ARGV[-1]) + { + $file = $ARGV[-1]; + } + else + { + print "No valid file provided.\n"; + exit 1; + } + Mimosis::mimosis_load_file( fpga => $fpga, file => $file, @@ -341,48 +366,110 @@ elsif( $res->{subcommand}[0] eq 'dacscan' ) { Mimosis::mimosis_dacscan( fpga => $fpga, + slow => $slow, + a => $a, name => $name, cleanup => $cleanup_dacscan, imagefileonly => $imagefileonly, - slow => $slow, - a => $a, printall => $printall_dacscan, ); } elsif( $res->{subcommand}[0] eq 'scurves' ) { - Mimosis::mimosis_scan_region( - fpga => $fpga, - slow => $slow, - a => $a, - region => $region_scurves, - firstrow => $firstrow_scurves, - lastrow => $lastrow_scurves, - rowdiv => $rowdiv_scurves, - firstcol => $firstcol_scurves, - lastcol => $lastcol_scurves, - coldiv => $coldiv_scurves, - firstset => $firstset_scurves, - lastset => $lastset_scurves, - setdiv => $setdiv_scurves, - settime => $settime_scurves, - rowsatonce => $rowsatonce_scurves, - printset => $printset_scurves, - printrow => $printrow_scurves, - printcol => $printcol_scurves, - printall => $printall_scurves, - analogAlimA => $analogAlimA_scurves, - analogAlimB => $analogAlimB_scurves, - analogDlimA => $analogDlimA_scurves, - analogDlimB => $analogDlimB_scurves, - modpulse => $modpulse_scurves, - ); + if( defined $region_scurves ) + { + Mimosis::mimosis_scan_region( + fpga => $fpga, + slow => $slow, + a => $a, + pulseonly => $pulseonly_scurves, + region => $region_scurves, + firstrow => $firstrow_scurves, + lastrow => $lastrow_scurves, + rowdiv => $rowdiv_scurves, + firstcol => $firstcol_scurves, + lastcol => $lastcol_scurves, + coldiv => $coldiv_scurves, + firstset => $firstset_scurves, + lastset => $lastset_scurves, + setdiv => $setdiv_scurves, + settime => $settime_scurves, + rowsatonce => $rowsatonce_scurves, + printset => $printset_scurves, + printrow => $printrow_scurves, + printcol => $printcol_scurves, + printall => $printall_scurves, + analogAlimA => $analogAlimA_scurves, + analogAlimB => $analogAlimB_scurves, + analogDlimA => $analogDlimA_scurves, + analogDlimB => $analogDlimB_scurves, + modpulse => $modpulse_scurves, + ); + exit 0; + } + + elsif( defined $colpix_scurves && defined $rowpix_scurves ) + { + Mimosis::mimosis_scan_pixel( + fpga => $fpga, + slow => $slow, + a => $a, + pulseonly => $pulseonly_scurves, + colpix => $colpix_scurves, + rowpix => $rowpix_scurves, + firstset => $firstset_scurves, + lastset => $lastset_scurves, + setdiv => $setdiv_scurves, + settime => $settime_scurves, + printset => $printset_scurves, + printall => $printall_scurves, + analogAlimA => $analogAlimA_scurves, + analogAlimB => $analogAlimB_scurves, + analogDlimA => $analogDlimA_scurves, + analogDlimB => $analogDlimB_scurves, + modpulse => $modpulse_scurves, + ); + exit 0; + } + + else + { + Mimosis::mimosis_scan_line( + fpga => $fpga, + slow => $slow, + a => $a, + pulseonly => $pulseonly_scurves, + firstrow => $firstrow_scurves, + lastrow => $lastrow_scurves, + rowdiv => $rowdiv_scurves, + firstcol => $firstcol_scurves, + lastcol => $lastcol_scurves, + coldiv => $coldiv_scurves, + firstset => $firstset_scurves, + lastset => $lastset_scurves, + setdiv => $setdiv_scurves, + settime => $settime_scurves, + rowsatonce => $rowsatonce_scurves, + printset => $printset_scurves, + printrow => $printrow_scurves, + printcol => $printcol_scurves, + printall => $printall_scurves, + analogAlimA => $analogAlimA_scurves, + analogAlimB => $analogAlimB_scurves, + analogDlimA => $analogDlimA_scurves, + analogDlimB => $analogDlimB_scurves, + modpulse => $modpulse_scurves, + ); + exit 0; + } } + elsif( $res->{subcommand}[0] eq 'mask' ) { Mimosis::mimosis_mask( + fpga => $fpga, region => $region_mask, row => $row_mask, col => $col_mask, @@ -395,9 +482,42 @@ elsif( $res->{subcommand}[0] eq 'mask' ) ); } -elsif( $res->{subcommand}[0] eq 'pulse' ) + +elsif( $res->{subcommand}[0] eq 'instr' ) { - printf("Not implemented yet.\n"); + if( defined $cmd_instr ) + {} + elsif( defined $ARGV[-1] ) + { + $cmd_instr = $ARGV[-1]; + } + else + { + print "No instruction provided.\n"; + exit 1; + } + + Mimosis::mimosis_instr_write( $fpga, hex($cmd_instr) ); } + +elsif( $res->{subcommand}[0] eq 'reg' ) +{ + my $reg_reg; + my $data_reg; + + if( defined $ARGV[-2] ) + { + $reg_reg = hex $ARGV[-2]; + $data_reg = hex $ARGV[-1]; + Mimosis::mimosis_register_write( $fpga, $reg_reg, $data_reg, $a ); + } + elsif( defined $ARGV[-1] && not defined $ARGV[-2] ) + { + $reg_reg = hex $ARGV[-1]; + printf( "%x\n", Mimosis::mimosis_register_read( $fpga, $reg_reg, $a ) ); + } +} + + exit 0; diff --git a/scripts/conf/CONF_dac_M47.pl b/scripts/conf/CONF_dac_M47.pl new file mode 100644 index 0000000..b384337 --- /dev/null +++ b/scripts/conf/CONF_dac_M47.pl @@ -0,0 +1,15 @@ +[0x0040, 64], #IBIAS 0 - 80 nA , 312 pA Pixel current +[0x0041, 52], #ITHR 0 - 2.5 nA , 9.8 pA Pixel current +[0x0042, 28], #IDB 0 - 40 nA , 157 pA Pixel current +[0x0043, 171], #VRESET 0.37 - 1.79 V , 6 mV Pixel input amplifier reset voltage +[0x0044, 70], #VPL 0.37 - 1.79 V , 6 mV Pixel voltage for charge injection (low value) +[0x0045, 188], #VPH 0.37 - 1.79 V , 6 mV Pixel voltage for charge injection (high +[0x0046, 254], #VPH_FINE 0 - 256 mV , 1 mV value) VPH+VPH_FINE +[0x0047, 144], #VCASP 0 - 1.54 V , 6 mV Pixel voltage +[0x0048, 131], #VCASNA 0 - 1.54 V , 6 mV Pixel threshold voltage for submatrix A +[0x0049, 0], #VCASNB 0 - 1.54 V , 6 mV Pixel threshold voltage for submatrix B +[0x004a, 0], #VCASNC 0 - 1.54 V , 6 mV Pixel threshold voltage for submatrix C +[0x004b, 0], #VCASND 0 - 1.54 V , 6 mV Pixel threshold voltage for submatrix D +[0x004c, 127], #VCASN2 0 - 1.54 V , 6 mV Pixel voltage +[0x004d, 55], #VCLIP 0 - 1.54 V , 6 mV Pixel clipping amplifier voltage +[0x004e, 125], #IBUFBIAS 0 - 10 μA , 312 pA Internal buffer bias (not in pixel) diff --git a/scripts/adc_i2c_cmd.pl b/scripts/legacy/adc_i2c_cmd.pl similarity index 100% rename from scripts/adc_i2c_cmd.pl rename to scripts/legacy/adc_i2c_cmd.pl diff --git a/scripts/basicsettings.pl b/scripts/legacy/basicsettings.pl similarity index 100% rename from scripts/basicsettings.pl rename to scripts/legacy/basicsettings.pl diff --git a/scripts/legacy/instr.pl b/scripts/legacy/instr.pl new file mode 100755 index 0000000..49bbbba --- /dev/null +++ b/scripts/legacy/instr.pl @@ -0,0 +1,33 @@ +#!/usr/bin/perl +use warnings; +no warnings "portable"; +use Getopt::Long; +use HADES::TrbNet; +use lib "/d/jspc37/mimosis/scripts/"; +use Mimosis; +use Time::HiRes qw(usleep sleep); +use Data::Dump qw(dump); + + +my $fpga; +my $cmd; + + +Getopt::Long::Configure(qw(gnu_getopt)); +GetOptions( + "fpga|f=s" => \$fpga, + "cmd=s" => \$cmd, +); + +if ( defined $fpga && defined $cmd) { + $fpga = hex $fpga if ( $fpga =~ /^0x/ ); + $cmd = hex $cmd if ( $cmd =~ /^0x/ ); +} +else {die print "Must provide FPGA address and register.\n";} + + +trb_init_ports() or die trb_strerror(); + +Mimosis::mimosis_instr_write( $fpga, $cmd ); + +print "sent.\n"; diff --git a/scripts/mimosis_i2c_cmd.pl b/scripts/legacy/mimosis_i2c_cmd.pl similarity index 86% rename from scripts/mimosis_i2c_cmd.pl rename to scripts/legacy/mimosis_i2c_cmd.pl index edebe16..75e0ecd 100755 --- a/scripts/mimosis_i2c_cmd.pl +++ b/scripts/legacy/mimosis_i2c_cmd.pl @@ -36,6 +36,24 @@ if ( defined $fpga_t && defined $reg_t) { } else {die print "Must provide FPGA address and register.\n";} +my $t = "10"; +print "$t\t"; +printf("%d\t", $t); +printf("%x\n", $t); + +$t = $t + 0; +print "$t\t"; +printf("%d\t", $t); +printf("%x\n", $t); + +$t = sprintf("%x",$t); +print "$t\t"; +printf("%d\t", $t); +printf("%x\n", $t); + +exit; + + trb_init_ports() or die trb_strerror(); diff --git a/scripts/start_probestation.sh b/scripts/legacy/start_probestation.sh similarity index 75% rename from scripts/start_probestation.sh rename to scripts/legacy/start_probestation.sh index 7ca6947..6afb5c4 100755 --- a/scripts/start_probestation.sh +++ b/scripts/legacy/start_probestation.sh @@ -13,9 +13,10 @@ sleep .1 cd - echo Load basic settings -./basicsettings.pl -s -d conf/CONF_allregisters.pl --fpga 0xfe82 -sleep .1 -./basicsettings.pl -s -d conf/CONF_testmode_enable.pl --fpga 0xfe82 +#./basicsettings.pl -s -d conf/CONF_allregisters.pl --fpga 0xfe82 +#./basicsettings.pl -s -d conf/CONF_testmode_enable.pl --fpga 0xfe82 +mimosis -f 0xfe82 -a load conf/CONF_allregisters.pl +mimosis -f 0xfe82 -a load conf/CONF_testmode_enable.pl sleep .1 echo Bit and word align @@ -32,7 +33,8 @@ sleep .1 cd - -./basicsettings.pl -s -d conf/CONF_testmode_disable.pl --fpga 0xfe82 +mimosis -f 0xfe82 -a load conf/CONF_testmode_disable.pl +#./basicsettings.pl -s -d conf/CONF_testmode_disable.pl --fpga 0xfe82 cd ../git/daqtools/xml-db #./get.pl Mimosis 0xfe82 CounterHeader rates #nicht implementiert... diff --git a/scripts/pulse/curves.py b/scripts/pulse/curves.py old mode 100644 new mode 100755 index ffa8dd9..4009fa2 --- a/scripts/pulse/curves.py +++ b/scripts/pulse/curves.py @@ -6,7 +6,7 @@ import matplotlib.pyplot as plt import numpy as np import pandas as pd -f = 'data/38_118.csv' +f = 'data/38_140.csv' dataset = pd.read_csv(f, delimiter='\t',header=None) values = list(dataset.columns.values) diff --git a/scripts/pulse/fpn.py b/scripts/pulse/fpn.py index c941b96..6c15cb1 100755 --- a/scripts/pulse/fpn.py +++ b/scripts/pulse/fpn.py @@ -17,32 +17,14 @@ for f in l: x = np.linspace(0, 255, num=255) hist = np.zeros(255) for i in range(len(meansig)): - if meansig[i,2] != 0.0 or meansig[i,3] < 0.0 or meansig[i,3] > 255 or meansig[i,4] < 1.0 or meansig[i,4] > 40.0: + # if meansig[i,0] != 0.0 or meansig[i,3] < 0.0 or meansig[i,3] > 255 or meansig[i,4] < 1.0 or meansig[i,4] > 40.0: + if meansig[i,0] != 0.0 or meansig[i,3] < 0.0 or meansig[i,3] > 255 or meansig[i,4] < 1.0 or meansig[i,4] > 40.0 or meansig[i,3] < 20: + # if meansig[i,2] != 0.0 or meansig[i,4] < 1.0: + # if meansig[i,4] < 1.0: continue - hist[int(meansig[i,3])] += 1 + hist[int(round(meansig[i,3]))] += 1 plt.bar(x,hist,width=1) plt.savefig("data/"+f+".png") - - -sys.exit() - - -dataset = pd.read_csv('regA_1.csv', delimiter='\t',header=None) -values = list(dataset.columns.values) -meansig = np.array(dataset[values[0:5]], dtype='float32') - -x = np.linspace(0, 255, num=255) - -hist = np.zeros(255) - -for i in range(len(meansig)): - # if i > 3500: - # break - if meansig[i,2] != 0.0 or meansig[i,3] < 0.0 or meansig[i,3] > 255 or meansig[i,4] < 1.0 or meansig[i,4] > 10.0: - continue - hist[int(meansig[i,3])] += 1 - # plt.plot(x, 50000*(1 + special.erf((x-meansig[i,3])/(np.sqrt(2)*meansig[i,4])))) - -plt.bar(x,hist,width=1) -# plt.hist(hist) -plt.show() + plt.clf() + plt.cla() + plt.close() diff --git a/scripts/pulse/full_scan.pl b/scripts/pulse/full_scan.pl index 8ad2529..ab3bd0f 100755 --- a/scripts/pulse/full_scan.pl +++ b/scripts/pulse/full_scan.pl @@ -11,36 +11,37 @@ use Term::ANSIColor; use File::Copy; -my $fpga, -my $vcasn, -my $vcasn_start, -my $vcasn_stop, -my $vcasn_step, -my $region_scurves, -my $firstrow_scurves, -my $lastrow_scurves, -my $rowdiv_scurves, -my $firstcol_scurves, -my $lastcol_scurves, -my $coldiv_scurves, -my $firstset_scurves, -my $lastset_scurves, -my $setdiv_scurves, -my $settime_scurves, -my $rowsatonce_scurves, -my $printset_scurves, -my $printrow_scurves, -my $printcol_scurves, -my $printall_scurves, -my $analogAlimA_scurves, -my $analogAlimB_scurves, -my $analogDlimA_scurves, -my $analogDlimB_scurves, -my $modpulse_scurves, -my $a, -my $slow, -my $scantime, -my $help, +my $fpga; +my $vcasn; +my $vcasn_start; +my $vcasn_stop; +my $vcasn_step; +my $region_scurves; +my $firstrow_scurves; +my $lastrow_scurves; +my $rowdiv_scurves; +my $firstcol_scurves; +my $lastcol_scurves; +my $coldiv_scurves; +my $firstset_scurves; +my $lastset_scurves; +my $setdiv_scurves; +my $settime_scurves; +my $rowsatonce_scurves; +my $printdac_scurves; +my $printrow_scurves; +my $printcol_scurves; +my $printset_scurves; +my $printall_scurves; +my $analogAlimA_scurves; +my $analogAlimB_scurves; +my $analogDlimA_scurves; +my $analogDlimB_scurves; +my $modpulse_scurves; +my $a; +my $slow; +my $scantime; +my $help; Getopt::Long::Configure(qw(gnu_getopt)); @@ -62,9 +63,10 @@ GetOptions( "setdiv=s" => \$setdiv_scurves, "settime=s" => \$settime_scurves, "nrows=s" => \$rowsatonce_scurves, - "printset" => \$printset_scurves, + "printdac" => \$printdac_scurves, "printrow" => \$printrow_scurves, "printcol" => \$printcol_scurves, + "printset" => \$printset_scurves, "printall" => \$printall_scurves, "analogAlimA=s" => \$analogAlimA_scurves, "analogAlimB=s" => \$analogAlimB_scurves, @@ -116,14 +118,14 @@ $vcasn_step = defined($vcasn_step) ? $vcasn_step : 1; $SIG{INT} = sub { die "\nAbort.\n" }; - trb_init_ports() or die trb_strerror(); - for( my $vcasnset = $vcasn_start; $vcasnset < $vcasn_stop; $vcasnset += $vcasn_step ) { Mimosis::mimosis_register_write( $fpga, $dacs{$vcasn}, $vcasnset, $a ); usleep($slow); + if( $printdac_scurves || $printall_scurves ) { printf("dac: $vcasnset\n"); } + Mimosis::mimosis_scan_region( fpga => $fpga, slow => $slow, @@ -151,5 +153,5 @@ for( my $vcasnset = $vcasn_start; $vcasnset < $vcasn_stop; $vcasnset += $vcasn_s modpulse => $modpulse_scurves, ); - copy( "/d/jspc37/mimosis/scurve/params.csv", $vcasn . ".csv" ) or die "Copy failed: $!"; + copy( "/d/jspc37/mimosis/analysis/scurve/params.csv", $vcasn . "_" . $vcasnset . ".csv" ) or die "Copy failed: $!"; } diff --git a/scripts/start.sh b/scripts/start.sh index 3c92caa..13ea0dc 100755 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -13,9 +13,10 @@ sleep .1 cd - echo Load basic settings -./basicsettings.pl -d conf/CONF_allregisters.pl --fpga 0xfe82 -#./basicsettings.pl -d conf/CONF_allregisters_1Link.pl --fpga 0xfe82 -./basicsettings.pl -d conf/CONF_testmode_enable.pl --fpga 0xfe82 +#./basicsettings.pl -d conf/CONF_allregisters.pl --fpga 0xfe82 +#./basicsettings.pl -d conf/CONF_testmode_enable.pl --fpga 0xfe82 +mimosis -f 0xfe82 -a load conf/CONF_allregisters.pl +mimosis -f 0xfe82 -a load conf/CONF_testmode_enable.pl sleep .1 echo Bit and word align @@ -32,7 +33,8 @@ sleep .1 cd - -./basicsettings.pl -d conf/CONF_testmode_disable.pl --fpga 0xfe82 +mimosis -f 0xfe82 -a load conf/CONF_testmode_disable.pl +#./basicsettings.pl -d conf/CONF_testmode_disable.pl --fpga 0xfe82 cd ../git/daqtools/xml-db #./get.pl Mimosis 0xfe82 CounterHeader rates #nicht implementiert... -- 2.43.0