Skip to content

Commit

Permalink
Merge pull request #42 from HGCDAQ/dev-shift-all
Browse files Browse the repository at this point in the history
Few bug fixes from shift computer
  • Loading branch information
andreypz authored Jul 19, 2017
2 parents 0fc1380 + a0e45ef commit f380048
Show file tree
Hide file tree
Showing 8 changed files with 135 additions and 64 deletions.
26 changes: 13 additions & 13 deletions producers/cmshgcal/STARTRUN
Original file line number Diff line number Diff line change
Expand Up @@ -109,19 +109,19 @@ sleep 2


#####################################################################
#if [ -f "HgcOnlineMon.exe" ]
#then
# printf '\033[22;33m\t HGC Online Monitor \033[0m \n'
# flog="../logs/Run${NEWRUNNUM}_HgcOnlineMon_$dt.log"
# config_file="../producers/cmshgcal/conf/OnlineMon.conf"
# ./HgcOnlineMon.exe -u 100 -rf -rs -sc 2 -c $config_file -tc 0 -r tcp://$HOSTIP:$RCPORT
# #nohup ./HgcOnlineMon.exe -u 100 -rf -rs -sc 2 -c $config_file -tc 0 -r tcp://$HOSTIP:$RCPORT > $flog 2>&1 &
# printf "The logs from the Online Monitor are in $flog file. \n"
#
#else
# printf '\033[22;31m\t Online monitor not found! \033[0m \n'
# echo 'Configure EUDAQ with the CMake option "-D BUILD_onlinemon=ON" and re-run "make install" to install.'
#fi
if [ -f "HgcOnlineMon.exe" ]
then
printf '\033[22;33m\t HGC Online Monitor \033[0m \n'
flog="../logs/Run${NEWRUNNUM}_HgcOnlineMon_$dt.log"
config_file="../producers/cmshgcal/conf/OnlineMon.conf"
#./HgcOnlineMon.exe -u 100 -rf -rs -sc 2 -c $config_file -tc 0 -r tcp://$HOSTIP:$RCPORT
nohup ./HgcOnlineMon.exe -u 100 -rf -rs -sc 0 -c $config_file -tc 0 -r tcp://$HOSTIP:$RCPORT > $flog 2>&1 &
printf "The logs from the Online Monitor are in $flog file. \n"

else
printf '\033[22;31m\t Online monitor not found! \033[0m \n'
echo 'Configure EUDAQ with the CMake option "-D BUILD_onlinemon=ON" and re-run "make install" to install.'
fi
#####################################################################


Expand Down
32 changes: 22 additions & 10 deletions producers/cmshgcal/STARTRUN_ALL
Original file line number Diff line number Diff line change
Expand Up @@ -104,27 +104,39 @@ sleep 2
######################################################################
# cmshgcal or RpiProducer
###############
printf '\033[22;33m\t cms hgcal *Rpi* Producer \033[0m \n'
#printf '\033[22;33m\t cms hgcal *Rpi* Producer \033[0m \n'

#xterm -sb -sl 1000 -geom 80x600-200-900 -fn fixed -T "RPI Producer RDB2" -e './RpiProducer.exe -n RPI-BRD2 -r tcp://$HOSTIP:$RCPORT' &
#xterm -sb -sl 1000 -geom 80x600-300-900 -fn fixed -T "RPI Producer RDB3" -e './RpiProducer.exe -n RPI-BRD3 -r tcp://$HOSTIP:$RCPORT' &

flog="../logs/Run${NEWRUNNUM}_RpiProducer_RDB2_$dt.log"
nohup ./RpiProducer.exe -n RPI-BRD2 -r tcp://$HOSTIP:$RCPORT > $flog 2>&1 &
printf "The logs from the RPiProducer are in $flog file. \n"
#flog="../logs/Run${NEWRUNNUM}_RpiProducer_RDB2_$dt.log"
#nohup ./RpiProducer.exe -n RPI-BRD2 -r tcp://$HOSTIP:$RCPORT > $flog 2>&1 &
#printf "The logs from the RPiProducer are in $flog file. \n"

#flog="../logs/Run${NEWRUNNUM}_RpiProducer_RDB3_$dt.log"
#nohup ./RpiProducer.exe -n RPI-BRD3 -r tcp://$HOSTIP:$RCPORT > $flog 2>&1 &
#printf "The logs from the RPiProducer are in $flog file. \n"
######################################################################

#sleep 2

flog="../logs/Run${NEWRUNNUM}_RpiProducer_RDB3_$dt.log"
nohup ./RpiProducer.exe -n RPI-BRD3 -r tcp://$HOSTIP:$RCPORT > $flog 2>&1 &
printf "The logs from the RPiProducer are in $flog file. \n"

# cmshgcal Producer
###############
printf '\033[22;33m\t cms hgcal Producer \033[0m \n'
xterm -sb -sl 1000 -geom 80x600-280-900 -fn fixed -T "CMS HGCal Producer" -e './HGCalProducer.exe -r tcp://$HOSTIP:$RCPORT' &
#flog="../logs/Run${NEWRUNNUM}_HGCalProducer_$dt.log"
#nohup ./HGCalProducer.exe -r tcp://$HOSTIP:$RCPORT > $flog 2>&1 &
#printf "The logs from the HGCalProducer are in $flog file. \n"

sleep 2

#######################################################################
# AHCAL producer
####################
printf '\033[22;33m\t caliceProducer-scintillator \033[0m \n'
#xterm -sb -sl 1000000 -geom 100x10-480-900 -fn fixed -T "CALICE AHCAL" -e "./AHCALProducer.exe -n CaliceSc -r tcp://$TLUIP:$RCPORT && read || read" &
#xterm -sb -sl 1000000 -geom 100x10-400-900 -fn fixed -T "CALICE AHCAL Two" -e "./AHCALProducer.exe -n CaliceSc-Two -r tcp://$TLUIP:$RCPORT && read || read" &
#xterm -sb -sl 1000000 -geom 100x10-480-900 -fn fixed -T "CALICE AHCAL" -e "./AHCALProducer.exe -n CaliceSc -r tcp://$TLUIP:$RCPORT && read || read" &
#xterm -sb -sl 1000000 -geom 100x10-400-900 -fn fixed -T "CALICE AHCAL Two" -e "./AHCALProducer.exe -n CaliceSc-Two -r tcp://$TLUIP:$RCPORT && read || read" &
flog="../logs/Run${NEWRUNNUM}_AHCALProducer_$dt.log"
nohup ./AHCALProducer.exe -n CaliceSc -r tcp://$TLUIP:$RCPORT > $flog 2>&1 &
printf "The logs from the AHCALProducer are in $flog file. \n"
Expand Down Expand Up @@ -155,7 +167,7 @@ then
#./HgcOnlineMon.exe -u 100 -rf -rs -sc 2 -c $config_file -tc 0 -r tcp://$HOSTIP:$RCPORT
nohup ./HgcOnlineMon.exe -u 100 -rf -rs -sc 0 -c $config_file -tc 0 -r tcp://$HOSTIP:$RCPORT > $flog 2>&1 &
printf "The logs from the Online Monitor are in $flog file. \n"

else
printf '\033[22;31m\t Online monitor not found! \033[0m \n'
echo 'Configure EUDAQ with the CMake option "-D BUILD_onlinemon=ON" and re-run "make install" to install.'
Expand Down
26 changes: 13 additions & 13 deletions producers/cmshgcal/STARTRUN_WITH_DWC
Original file line number Diff line number Diff line change
Expand Up @@ -124,19 +124,19 @@ echo "\n"
sleep 2

#####################################################################
#if [ -f "HgcOnlineMon.exe" ]
#then
# printf '\033[22;33m\t HGC Online Monitor \033[0m \n'
# flog="../logs/Run${NEWRUNNUM}_HgcOnlineMon_$dt.log"
# config_file="../producers/cmshgcal/conf/OnlineMon.conf"
# ./HgcOnlineMon.exe -u 100 -rf -rs -sc 2 -c $config_file -tc 0 -r tcp://$HOSTIP:$RCPORT
# #nohup ./HgcOnlineMon.exe -u 100 -rf -rs -sc 2 -c $config_file -tc 0 -r tcp://$HOSTIP:$RCPORT > $flog 2>&1 &
# printf "The logs from the Online Monitor are in $flog file. \n"
#
#else
# printf '\033[22;31m\t Online monitor not found! \033[0m \n'
# echo 'Configure EUDAQ with the CMake option "-D BUILD_onlinemon=ON" and re-run "make install" to install.'
#fi
if [ -f "HgcOnlineMon.exe" ]
then
printf '\033[22;33m\t HGC Online Monitor \033[0m \n'
flog="../logs/Run${NEWRUNNUM}_HgcOnlineMon_$dt.log"
config_file="../producers/cmshgcal/conf/OnlineMon.conf"
#./HgcOnlineMon.exe -u 100 -rf -rs -sc 2 -c $config_file -tc 0 -r tcp://$HOSTIP:$RCPORT
nohup ./HgcOnlineMon.exe -u 100 -rf -rs -sc 0 -c $config_file -tc 0 -r tcp://$HOSTIP:$RCPORT > $flog 2>&1 &
printf "The logs from the Online Monitor are in $flog file. \n"

else
printf '\033[22;31m\t Online monitor not found! \033[0m \n'
echo 'Configure EUDAQ with the CMake option "-D BUILD_onlinemon=ON" and re-run "make install" to install.'
fi
#####################################################################


Expand Down
9 changes: 9 additions & 0 deletions producers/cmshgcal/conf/AllInOneProducer.conf
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,15 @@ AHCALBXID0Offset = 2123
AHCALBXIDWidth = 160


[Producer.CMS-HGCAL]
UhalLogLevel = 5

DataBlockSize = 30787
AcquisitionMode = 1 #0 for DEBUG mode with print out and pause, 1 for beam test
NumberOfORMs = 3
RDOUT_ORM_PrefixName = "RDOUT_ORM"
ConnectionFile = "file://../producers/cmshgcal/etc/connection.xml"

[Producer.DWCs]
dataFilePrefix = "/home/cmsdaq/DAQ/eudaq/data/dwc_run_"
AcquisitionMode = 1
Expand Down
4 changes: 2 additions & 2 deletions producers/cmshgcal/conf/OnlineMon.conf
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[General]
DqmColorMap = 56
DqmColorMap = 109

# For HexagonHistos:

# Ofset of the signal peak in time slices (25 ns sampling):
mainFrameTS = 3
mainFrameTS = 2

# Zero suppression threshold for LG and HG ADC:
thresh_LG = 60
Expand Down
1 change: 1 addition & 0 deletions producers/cmshgcal/onlinemon/src/HexagonHistos.cc
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,7 @@ void HexagonHistos::Write() {
obj->Write();
}

ev_display_list->Clear();

//std::cout<<"Doing HexagonHistos::Write() before canvas drawing"<<std::endl;

Expand Down
83 changes: 64 additions & 19 deletions producers/cmshgcal/src/HGCalProducer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@

#include <iostream>
#include <ostream>
#include <sstream>
#include <vector>
#include <iomanip>
#include <unistd.h>
#include <sys/time.h>
#include <sys/types.h>
Expand Down Expand Up @@ -52,8 +54,10 @@ class HGCalProducer : public eudaq::Producer {
unsigned m_run, m_ev, m_uhalLogLevel, m_blockSize;
std::vector< ipbus::IpbusHwController* > m_rdout_orms;
TriggerController *m_triggerController;
// TFile *m_outrootfile;
//TH1D *m_htime;
// std::vector< std::fstream* > m_timingOutputs;
TFile *m_outrootfile;
TH1D *m_hreadouttime;
TH1D *m_hwritertime;
ACQ_MODE m_acqmode;
boost::thread m_triggerThread;
enum DAQState {
Expand Down Expand Up @@ -93,6 +97,10 @@ class HGCalProducer : public eudaq::Producer {
void MainLoop()
{
std::ostringstream os( std::ostringstream::ate );
// uint64_t prevTimeStamp[m_rdout_orms.size()];
// for( int i=0; i<(int)m_rdout_orms.size(); i++)
// prevTimeStamp[i]=0;

while (m_state != STATE_GOTOTERM){
if( m_state != STATE_RUNNING ) {
os.str("");
Expand All @@ -116,37 +124,62 @@ class HGCalProducer : public eudaq::Producer {
if (m_state == STATE_RUNNING) {
if( !m_triggerController->checkState( (STATES)RDOUT_RDY ) ) continue;
if( m_ev==m_triggerController->eventNumber() ) continue;
//boost::timer::cpu_timer timer;
//boost::timer::cpu_times times;
boost::timer::cpu_timer timerReadout;
boost::timer::cpu_times times;
eudaq::RawDataEvent ev(EVENT_TYPE,m_run,m_ev);
boost::thread threadVec[m_rdout_orms.size()];

for( int i=0; i<(int)m_rdout_orms.size(); i++)
threadVec[i]=boost::thread(readFIFOThread,m_rdout_orms[i],&m_blockSize);

for( int i=0; i<(int)m_rdout_orms.size(); i++){
threadVec[i].join();
threadVec[i].join();}

times=timerReadout.elapsed();
m_hreadouttime->Fill(times.wall/1e9);

int head[1];
boost::timer::cpu_timer timerWriter;
for( int i=0; i<(int)m_rdout_orms.size(); i++){
std::vector<uint32_t> the_data = m_rdout_orms[i]->getData() ;
// Send it to euDAQ converter plugins:

// Adding trailer
// checkCRC( "RDOUT.CRC",m_rdout_orms[i]);
uint32_t trailer=i;//8 bits for orm id
std::cout << "board id = " << trailer;
trailer|=m_triggerController->eventNumber()<<8;//24 bits for trigger number
std::cout << "\t event number id = " << m_triggerController->eventNumber();
std::cout << "\t trailer = " << trailer << std::endl;
m_rdout_orms[i]->addTrailerToData(trailer);
const std::vector<uint32_t> the_data = m_rdout_orms[i]->getData() ;
std::cout << "\t trailer = " << trailer << std::endl; //m_rdout_orms[i]->addTrailerToData(trailer);

the_data.push_back(trailer);

for (int b=0; b<20; b++)
std::cout<< boost::format("Thread: %d; Word number: %d, data Hex: 0x%08x ") % i % b % the_data[b]<<std::endl;
head[0] = i+1;
ev.AddBlock( 2*i, head, sizeof(head));
ev.AddBlock( 2*i+1, the_data);

std::cout<<i<<" head[0]="<<head[0]<<" Size of the data (bytes): "<<std::dec<<the_data.size()*4<<std::endl;

//for (int b=0; b<20; b++)
//std::cout<< boost::format("Thread: %d; Word number: %d, data Hex: 0x%08x ") % i % b % the_data[b]<<std::endl;

// Write it into raw file:
m_rawFile.write(reinterpret_cast<const char*>(&the_data[0]), the_data.size()*sizeof(uint32_t));

// Send it to euDAQ converter plugins:
ev.AddBlock( i, the_data);

// // Get and write timing informations:
// uint64_t timeStamp0 = m_rdout_orms[i]->ReadRegister("CLK_COUNT0");
// uint64_t timeStamp1 = m_rdout_orms[i]->ReadRegister("CLK_COUNT1");;
// uint64_t timeStamp = timeStamp0;
// timeStamp |= (timeStamp1<<0x20);
// (*m_timingOutputs[i]) << m_triggerController->eventNumber() << "\t" << m_triggerController->eventNumber() << "\t"
// << std::setw(12) << std::setfill('0') << std::hex << timeStamp << "\t"
// << std::dec << timeStamp-prevTimeStamp[i] << std::endl;
// prevTimeStamp[i]=timeStamp;

}
//times=timer.elapsed();
//m_htime->Fill(times.wall/1e9);
times=timerWriter.elapsed();
m_hwritertime->Fill(times.wall/1e9);

m_ev=m_triggerController->eventNumber();
SendEvent(ev);
for( std::vector<ipbus::IpbusHwController*>::iterator it=m_rdout_orms.begin(); it!=m_rdout_orms.end(); ++it ){
Expand Down Expand Up @@ -249,8 +282,9 @@ class HGCalProducer : public eudaq::Producer {
std::cout << "ca a du marcher" << std::endl;

//create root objects
//m_outrootfile = new TFile("../data/time.root","RECREATE");
//m_htime = new TH1D("rdoutTime","",10000,0,1);
m_outrootfile = new TFile("../data/time.root","RECREATE");
m_hreadouttime = new TH1D("rdoutTime","",10000,0,1);
m_hwritertime = new TH1D("writingTime","",10000,0,1);

// Let's open a file for raw data:
char rawFilename[256];
Expand All @@ -265,7 +299,14 @@ class HGCalProducer : public eudaq::Producer {


//m_triggerController.startrunning( m_run, m_acqmode );
std::ostringstream os( std::ostringstream::ate );
for( std::vector<ipbus::IpbusHwController*>::iterator it=m_rdout_orms.begin(); it!=m_rdout_orms.end(); ++it ){
// os.str("");
// os << std::setw(4) << std::setfill('0') << "/disk2_2TB/July2017_TB_data/HexaData_Run" << m_run << "_TIMING_" << (*it)->getInterface()->id() << ".txt";
// std::fstream* out=new std::fstream();
// out->open(os.str().c_str(),std::ios::out);
// (*out) << "TrigNumber TrigCount TimeStamp TimeDiff" << std::endl;
// m_timingOutputs.push_back(out);
(*it)->ResetTheData();
while(1){
if( (*it)->ReadRegister("DATE_STAMP") )
Expand All @@ -289,15 +330,19 @@ class HGCalProducer : public eudaq::Producer {
// m_triggerThread.join();
eudaq::mSleep(1000);
m_state = STATE_GOTOSTOP;
//m_outrootfile->Write();
//m_outrootfile->Close();
m_outrootfile->Write();
m_outrootfile->Close();
while (m_state == STATE_GOTOSTOP) {
eudaq::mSleep(1000); //waiting for EORE being send
}

uint32_t trailer=time(0);
m_rawFile.write(reinterpret_cast<const char*>(&trailer), sizeof(trailer));
m_rawFile.close();
// for( int iorm=0; iorm<(int)m_rdout_orms.size(); iorm++ ){
// m_timingOutputs[iorm]->close();
// delete m_timingOutputs[iorm];
// }

SetStatus(eudaq::Status::LVL_OK, "Stopped");

Expand Down
18 changes: 11 additions & 7 deletions producers/cmshgcal/src/HexaBoardConverterPlugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

const size_t RAW_EV_SIZE_32 = 123152;

const size_t nSkiPerBoard[3] = {0, 16,24};
const uint32_t skiMask[3] = {0x00000000, 0x0000FFFF, 0x00FFFFFF};
const size_t nSkiPerBoard[3] = {8, 16,16};
const uint32_t skiMask[3] = {0xF0F00000, 0xF0F0F0F0, 0xF0F0F0F0};
//const uint32_t skiMask = 0;

const int nSCA=13;
Expand Down Expand Up @@ -122,6 +122,9 @@ namespace eudaq {

else {
// This block contains the data

std::cout<<" We are in a data blaock. blo="<<blo<<std::endl;

std::vector<uint32_t> rawData32;
rawData32.resize(bl.size() / sizeof(uint32_t));
std::memcpy(&rawData32[0], &bl[0], bl.size());
Expand Down Expand Up @@ -161,7 +164,7 @@ namespace eudaq {
const unsigned skiID_2 = 3 - (skiID_1)%4;

if (skiID_2 > 3){
std::cout<<" EROOR in ski. It is "<<skiID_2<<std::endl;
std::cout<<" ERROR in ski. It is "<<skiID_2<<std::endl;
EUDAQ_WARN("There is another error with encoding. ski="+eudaq::to_string(skiID_2));
}
else {
Expand Down Expand Up @@ -218,11 +221,12 @@ namespace eudaq {
}
}

std::cout<<"St Ev NumPlanes: "<<sev.NumPlanes()<<std::endl;

// Indicate that data was successfully converted
return true;
}

std::cout<<"St Ev NumPlanes: "<<sev.NumPlanes()<<std::endl;

// Indicate that data was successfully converted
return true;
}

unsigned int gray_to_brady(unsigned int gray) const{
Expand Down

0 comments on commit f380048

Please sign in to comment.