Skip to content

Commit

Permalink
Merge pull request #55 from Mu2e/pasha.gr3
Browse files Browse the repository at this point in the history
Pasha.gr3
  • Loading branch information
pavel1murat authored Dec 1, 2024
2 parents b3b5e39 + 421030f commit 333c657
Show file tree
Hide file tree
Showing 20 changed files with 610 additions and 173 deletions.
2 changes: 1 addition & 1 deletion config/pasha/mu2edaq07_pcie0.C
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ int init_run_configuration(DtcGui* X) {

dtc[0].fDtcID = 7; // for one machine, make it the same as the PcieAddr
dtc[0].fPartitionID = 0;
dtc[0].fMode = 0;
dtc[0].fEventMode = 0;
dtc[0].fMacAddrByte = 0;

gSystem->Setenv("DTCLIB_DTC","0");
Expand Down
2 changes: 1 addition & 1 deletion config/pasha/mu2edaq07_pcie1.C
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ int init_run_configuration(DtcGui* X) {

dtc[0].fDtcID = 1; // for 1 node, make it the same as PcieAddr
dtc[0].fPartitionID = 0;
dtc[0].fMode = 0;
dtc[0].fEventMode = 0;
dtc[0].fMacAddrByte = 0;

gSystem->Setenv("DTCLIB_DTC","1");
Expand Down
2 changes: 1 addition & 1 deletion config/pasha/mu2edaq09_pcie0.C
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ int init_run_configuration(DtcGui* X) {

dtc[0].fDtcID = 0; // for one machine, make it the same as the PcieAddr
dtc[0].fPartitionID = 0;
dtc[0].fMode = 0;
dtc[0].fEventMode = 1;
dtc[0].fMacAddrByte = 0;

gSystem->Setenv("DTCLIB_DTC","0");
Expand Down
2 changes: 1 addition & 1 deletion config/pasha/mu2edaq09_pcie1.C
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ int init_run_configuration(DtcGui* X) {

dtc[0].fDtcID = 1; // for one machine, make it the same as the PcieAddr
dtc[0].fPartitionID = 0;
dtc[0].fMode = 0;
dtc[0].fEventMode = 0;
dtc[0].fMacAddrByte = 0;

gSystem->Setenv("DTCLIB_DTC","1");
Expand Down
11 changes: 6 additions & 5 deletions config/pasha/mu2edaq22_pcie0.C
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,17 @@ int init_run_configuration(DtcGui* X) {

dtc[0].fName = "DTC";
dtc[0].fPcieAddr = 0;
// dtc[0].fLinkMask = 0x000001; // ROC0
dtc[0].fLinkMask = 0x111111; // 6 ROCs
// dtc[0].fLinkMask = 0x111111; // 6 ROCs
dtc[0].fLinkMask = 0x000010; // TS1 : ROC1@DTC0
dtc[0].fReadoutMode = 0; // 0:patterns 1:digis
dtc[0].fJAMode = 0x01; // ROC tower@IERC: external clock (internal_clock << 4) + reset
dtc[0].fEmulateCfo = 1; //

dtc[0].fDtcID = 7; // for one machine, make it the same as the PcieAddr
dtc[0].fDtcID = 0; // for one machine, make it the same as the PcieAddr
dtc[0].fPartitionID = 0;
dtc[0].fMode = 0;
dtc[0].fMacAddrByte = 0;
dtc[0].fEventMode = 1;
dtc[0].fOnSpill = 1;
dtc[0].fMacAddrByte = -1;

gSystem->Setenv("DTCLIB_DTC","0");

Expand Down
6 changes: 4 additions & 2 deletions config/pasha/mu2edaq22_pcie1.C
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,17 @@ int init_run_configuration(DtcGui* X) {

dtc[0].fName = "DTC";
dtc[0].fPcieAddr = 1;
dtc[0].fLinkMask = 0x011; // TS2 (0x10) +TS1
dtc[0].fLinkMask = 0x010; // TS2 (0x10) +TS1
// dtc[0].fLinkMask = 0x01; // TS1
dtc[0].fJAMode = 0x01;
dtc[0].fReadoutMode = 1; // 0:patterns 1:digis

dtc[0].fDtcID = 1; // for 1 node, make it the same as PcieAddr
dtc[0].fPartitionID = 0;
dtc[0].fMode = 0;
dtc[0].fMacAddrByte = 0;

dtc[0].fOnSpill = 1;
dtc[0].fEventMode = 1;

gSystem->Setenv("DTCLIB_DTC","1");

Expand Down
121 changes: 101 additions & 20 deletions doc/control_roc.org
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,71 @@
*** set pulser frequency:
- 60 kHz: digi_rw -h 0 -a 85 -d 1 -w 1 # 31.29 MHz / (2**9+1) = 60.9941520468 kHz)
- 250 kHz: digi_rw -h 0 -a 85 -d 0 -w 1 # 31.29 MHz / (2**7+1) = 242.558139535 kHz)
*** details on over-the-fiber implementation (from Monica)
- DCS block register 263, or 0x107.
#+begin_src
On BLOCK_WRITE it takes 5 inputs:

[0] = rw (python -w option)
[1] = thisvcal (python -h option)
[2] = address (python -a option)
[3] = data_low (python -d option 16 LSB)
[4] = data_high (python -d option 16 MSB)

On BLOCK_READ it returns 7 outputs:

[0] = copy of input "rw"
[1] = copy of input "thishvcal"
[2] = used "digiaddr" (see below)
[3] = 16 LSB of "digidata" (see below)
[4] = 32 MSB of "digidata" (see below)
[5] = "adc_num" (see below)
[6] = "adc_mask" (see below)

This is how the inputs are used to generate the outputs

rw = (uint8_t) dtcbuffer[0]; // -w
thishvcal = (uint8_t) buffer[1]; // -h
digiaddr = dtcbuffer[2]; // -a
data_low = dtcbuffer[3]; // -d
data_high = dtcbuffer[4]; // -d


digidata = ((data_high<<16) & 0XFFFF0000) + (data_low & 0x0000FFFF);


// give TWI control to uProc before calling DIGI_READ/WRITE or ADC/READ_WRITE

*(registers_0_addr + REG_DIGIRW_SEL) = 1;

if (rw & 0x2) {
digiaddr |= 0x100;
rw &= 0x1;
}
if (thishvcal < 3) {
if (rw == 0) { //read
digidata = digi_read(digiaddr, thishvcal);
} else {
digi_write(digiaddr, digidata, thishvcal);
}
} else {
if (thishvcal == 3) {
if (rw == 0) { //read
digidata = *(registers_0_addr + digiaddr);
} else {
*(registers_0_addr + digiaddr) = digidata;
}
} else {
adc_num = thishvcal - 4;
if (rw == 0) {
digidata = adc_read(digiaddr, adc_num);
} else {
adc_mask = (0x1 << adc_num);
adc_write(digiaddr, digidata, adc_mask);
}
}
}
#+end_src
** find_alignment
** set_preamp_thresh
- set_preamp_thresh -c 91 -d 350 -hv 1
Expand All @@ -26,7 +91,7 @@
- measure_thresholds -c 91 : channel 91
** pulser_on -c 3 -d 10000 -y 200
-c 3 : (go by 8) : pulse channels 3,11,19,27,35,43,51,59,67,75,83 91
** [#B] readDeviceID
** [#B] readDeviceID
#+begin_src
readDeviceID
(13, 52)
Expand All @@ -37,11 +102,12 @@ readDeviceID

('DRAC ROC ID #', '5a71c')
#+end_src
** readSPI : no parameters
** readSPI : no parameters
conversion constants : https://github.com/bonventre/trackerScripts/blob/master/constants.py#L99
** set_digi_rw
set_digi_rw -s 1 : enable commands over the serial connection
set_digi_rw -s 0 : disable commands over the serial connection
** rates [-c channel] systemd-resolved
** rates [-c channel]
- if channel is not specified, all channels
- rates -c 91 : rate in the channel # 91
** read
Expand Down Expand Up @@ -265,23 +331,23 @@ readSPI
set_digi_rw -s 0
#+end_src

* TODO command implementation over the fiber


| command | status | comments |
|--------------------+--------+-----------------------------------------|
| digi_rw | | |
|--------------------+--------+-----------------------------------------|
| readSPI | OK | implemented |
| find_alignment | | implemented by Ed, minor wrinkle |
| set_preamp_thresh | | |
| measure_thresholds | | ok |
| pulser_on | | |
| readDeviceID | | |
| set_digi_rw | | shouldn't need, all goes over the fiber |
| rates | | |
| read | | |
|--------------------+--------+-----------------------------------------|
* TODO control_ROC command implementation over the fiber

|--------------------+--------+-----------------------------------------------------------|
| command | status | comments |
|--------------------+--------+-----------------------------------------------------------|
| digi_rw | | implemented |
|--------------------+--------+-----------------------------------------------------------|
| readSPI | OK | implemented |
| find_alignment | | implemented by Ed, minor wrinkle - parameter order, stars |
| set_preamp_thresh | | |
| measure_thresholds | | ok |
| pulser_on | | |
| readDeviceID | | |
| set_digi_rw | | shouldn't need, all goes over the fiber |
| rates | | |
| read | OK | implemented |
|--------------------+--------+-----------------------------------------------------------|
* ------------------------------------------------------------------------------
* setting the pulser frequency (Richie)
- 60 kHz: digi_rw -h 0 -a 85 -d 1 -w 1 # 31.29 MHz / (2**9+1) = 60.9941520468 kHz)
Expand Down Expand Up @@ -450,6 +516,21 @@ before next run, clear TDC counters with
#+end_src

* 5) hit format : https://github.com/bonventre/Digi_FW/blob/master/hdl/fer.vhd

-- some details: https://github.com/bonventre/Digi_FW/blob/master/hdl/fer.vhd#L682
from Richie:
32 bit words, MSB to LSB, assuming 1 adc packet (full hit is 2 packets)
cal_tdc(15 downto 0) & panel_id(8 downto 0) & straw_num(6 downto 0)
hv_tdc(15 downto 0) & ewmcount(3 downto 0) & cal_tot(3 downto 0) & cal_tdc(23 downto 16)
ewmcount(9 downto 0) & numadcpackets(5 downto 0) & "0" & ewm_overlap_error & missed_last_hit & fifo_was_fu
ll & hv_tot(3 downto 0) & hv_tdc(23 downto 0)
"00" & adc2(9 downto 0) & adc1(9 downto 0) & adc0(9 downto 0)
"00" & adc5(9 downto 0) & adc4(9 downto 0) & adc3(9 downto 0)
"00" & adc8(9 downto 0) & adc7(9 downto 0) & adc6(9 downto 0)
"00" & adc11(9 downto 0) & adc10(9 downto 0) & adc9(9 downto 0)
"00" & adc14(9 downto 0) & adc13(9 downto 0) & adc12(9 downto 0)


* 5.6) (Richie) there is an active FIXME: time = ((TDC & 0xFFFF00) + (0xFF - (TDC & 0xFF))) * 5/256. ns
* 6) VST data format

Expand Down
18 changes: 17 additions & 1 deletion doc/otsdaq_mu2e_tracker.org
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ root [2] .q
#+end_src
** after that can proceed
* ------------------------------------------------------------------------------
- bit 11 of reg 8 : set to 1
- reg 15 : n simulated hits per serdes .. 24 x4 = 94
payload :

* [[file:root_interface.org][ROOT interface]]
* [[file:tracker_roc_registers.org][tracker ROC registers]]
* tracker VST configurations
Expand Down Expand Up @@ -480,7 +484,7 @@ readDeviceID
('DRAC ROC ID #', '7a7fb')
** [[file:roc_id_1b561.org][ROC ID 1b561]] : <2024-05-09 Thu> installed at TS1
** [[file:roc_id_805d6.org][ROC ID 805d6]] : <2024-02-25 Sun> installed at TS2
* ROC Tower
* ROC Tower
- new PI ... mu2e@ ... (local)
** window 1: cd ~/LVHVBox/GServer/build
sudo ~/Server
Expand Down Expand Up @@ -561,6 +565,18 @@ powerOff
- to turn power OFF on channel 1 : powerOff 1
- to turn power OFF on all channels : powerOff

* hit-level error bits (Richie):
- missed_last_hit: This straw's input went above threshold but the
associated hit was not digitized either because the event was
already full or because the state machine was still busy digitizing
the waveform for the previous hit on this channel
- ewm_overlap_error: diagnostic error, goes high if an event window
marker arrives before the hit count for the previous event window
was recorded to the fifo. Shouldn't happen unless the state machine
crashes or event windows are sent within like 100 ns of each other
- fifo_was_full: the channel level fifo for this straw was full after
the last digitized hit so there is possibly missing hits between the
last hit and this one
* ------------------------------------------------------------------------------
* how to download firmware to DRAC from .job file (Monica)
<2023-12-13 Wed> Monica
Expand Down
6 changes: 4 additions & 2 deletions otsdaq-mu2e-tracker/Gui/DtcGui.hh
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,10 @@ public:
int fLinkMask; // active links, for DTC - ROCs, for CFO: nDTCs
int fReadoutMode;
int fJAMode;
int fOnSpill;

int fDtcID; // 4 pieces to be written to 0x9154
int fMode;
int fEventMode;
int fPartitionID;
int fMacAddrByte;

Expand All @@ -174,9 +175,10 @@ public:
fLinkMask = 0; // by default, not reading anything
fReadoutMode = 0; // 0:patterns 1:digis
fJAMode = 0;
fOnSpill = 0;
fDtcID = -1;
fPartitionID = -1;
fMode = -1;
fEventMode = 1;
fMacAddrByte = -1;


Expand Down
11 changes: 3 additions & 8 deletions otsdaq-mu2e-tracker/Gui/DtcGui_commands.cc
Original file line number Diff line number Diff line change
Expand Up @@ -460,27 +460,22 @@ void DtcGui::read_subevents() {
TDatime x1;
*fTextView << x1.AsSQLString() << " DtcGui::" << __func__ << std::endl;

// if (fDebugLevel > 1) printf("DtcGui::%s : Active DTC ID: %i\n",__func__,fActiveDtcID);

// int roc = dtel->fActiveRocID;
// RocTabElement_t* rtel = &dtel->fRocTel[roc];
// Restore old cout.
cout.rdbuf(old_cout_sb);
//-----------------------------------------------------------------------------
// CFO doesn't have ROC's
//-----------------------------------------------------------------------------
if (dtel->fData->fName == "DTC") {
// uint reg;
// sscanf(rtel->fRegR->GetText(),"0x%x",&reg);
try {
std::vector<std::unique_ptr<DTCLib::DTC_SubEvent>> list_of_subevents;
// int timeout_ms(150);
dtel->fDTC_i->ReadSubevents(list_of_subevents,0,1,0);
// *fTextView << Form("%s: roc: %i reg : 0x%04x val: 0x%04x",__func__,roc,reg,val) << std::endl;
}
catch (...) {
*fTextView << Form("ERROR in %s: coudn't read event BAIL OUT",__func__) << std::endl;
}
}

cout.rdbuf(str_cout.rdbuf());
TDatime x2;
*fTextView << x2.AsSQLString() << str_cout.str() << " DtcGui::" << __func__ << " : DONE " << std::endl;
fTextView->ShowBottom();
Expand Down
3 changes: 2 additions & 1 deletion otsdaq-mu2e-tracker/Gui/DtcGui_gui_DtcTab.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ void DtcGui::BuildDtcTabElement(TGTab*& Tab, DtcTabElement_t& DtcTel, DtcData_t*
DtcTel.fDTC_i = DtcInterface::Instance(DtcData->fPcieAddr,DtcData->fLinkMask);
DtcTel.fDTC_i->fDtcID = DtcData->fDtcID;
DtcTel.fDTC_i->fPartitionID = DtcData->fPartitionID;
DtcTel.fDTC_i->fMode = DtcData->fMode;
DtcTel.fDTC_i->fOnSpill = DtcData->fOnSpill;
DtcTel.fDTC_i->fEventMode = DtcData->fEventMode;
DtcTel.fDTC_i->fMacAddrByte = DtcData->fMacAddrByte;

DtcTel.fDTC_i->SetRocReadoutMode(DtcData->fReadoutMode);
Expand Down
Loading

0 comments on commit 333c657

Please sign in to comment.