diff --git a/CMakeLists.txt b/CMakeLists.txt index 85689dfd37fe3741cc760f78eab1cc0fe1a381a7..89fb4b625a7eb38502c580f1195245e1d10bbe82 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -346,7 +346,6 @@ If(FAIRMQ_FOUND) EndIf() add_subdirectory(tutorials) -add_subdirectory (beamtime) add_custom_target(cleanlib COMMAND ${CMAKE_COMMAND} -E remove libCbm* diff --git a/beamtime/CMakeLists.txt b/beamtime/CMakeLists.txt deleted file mode 100644 index 27d1cabf4587ff2c3fbfab9d1da43f4cd83986d2..0000000000000000000000000000000000000000 --- a/beamtime/CMakeLists.txt +++ /dev/null @@ -1,28 +0,0 @@ -# Create a library called "libCbmBeamtime" which includes the source files given in -# the array . -# The extension is already found. Any number of sources could be listed here. - -add_subdirectory(roclight) -add_subdirectory(trb) - -add_subdirectory(base) -add_subdirectory(data) -add_subdirectory(param) - -add_subdirectory(trd) -add_subdirectory(rich) -add_subdirectory(tof) - - -add_subdirectory(cosy2014) -add_subdirectory(cern2014) - -add_subdirectory(cern2016) - -add_subdirectory(cosy2017) -add_subdirectory(cern2017) -add_subdirectory(star2017) - -add_subdirectory(cosy2018) -add_subdirectory(star2018) - diff --git a/beamtime/base/CMakeLists.txt b/beamtime/base/CMakeLists.txt deleted file mode 100644 index 6b6b58c001d383ef4bebfe53bf84e968ccfbbaa3..0000000000000000000000000000000000000000 --- a/beamtime/base/CMakeLists.txt +++ /dev/null @@ -1,68 +0,0 @@ -# Create a library called "libCbmBeamtime" which includes the source files given in -# the array . -# The extension is already found. Any number of sources could be listed here. - -Set(INCLUDE_DIRECTORIES - ${CBMBASE_DIR} - ${CBMDATA_DIR} - ${CBMDATA_DIR}/mvd - ${CBMDATA_DIR}/sts - ${CBMDATA_DIR}/rich - ${CBMDATA_DIR}/much - ${CBMDATA_DIR}/trd - ${CBMDATA_DIR}/tof - ${CBMDATA_DIR}/psd - ${CMAKE_SOURCE_DIR}/beamtime/data/ - ${CBMROOT_SOURCE_DIR}/beamtime/base - ${CMAKE_SOURCE_DIR}/beamtime/data/fhodo - ${CMAKE_SOURCE_DIR}/beamtime/roclight -) - - -Set(SYSTEM_INCLUDE_DIRECTORIES - ${BASE_INCLUDE_DIRECTORIES} - ${Boost_INCLUDE_DIR} - ${IPC_INCLUDE_DIRECTORY} -) - -Include_Directories( - ${INCLUDE_DIRECTORIES} -) - -Include_Directories( - SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES} -) - -Set(LINK_DIRECTORIES - ${ROOT_LIBRARY_DIR} - ${Boost_LIBRARY_DIRS} - ${FAIRROOT_LIBRARY_DIR} -) - -Link_Directories( - ${LINK_DIRECTORIES} -) - -Set(SRCS - CbmROCUnpack.cxx - CbmTbDaqBuffer.cxx - CbmTbEventBuilder.cxx - CbmTbEventBuilderFixedTimeWindow.cxx - CbmTSUnpack.cxx -) - -If(_UINT8_T_EXIST) - Add_Definitions(-DHAVE_UINT8_T_HEADER_FILE) - Set(DEFINITIONS HAVE_UINT8_T_HEADER_FILE) -EndIf() - -Set(LINKDEF CbmBeamtimeBaseLinkDef.h) -Set(LIBRARY_NAME CbmBeamtimeBase) -Set(DEPENDENCIES - CbmBeamtimeData - CbmRocLight - CbmBase - Base -) - -GENERATE_LIBRARY() diff --git a/beamtime/base/CbmBeamtimeBaseLinkDef.h b/beamtime/base/CbmBeamtimeBaseLinkDef.h deleted file mode 100644 index 692bbc30ffd7892034599313fdc0d53b17070307..0000000000000000000000000000000000000000 --- a/beamtime/base/CbmBeamtimeBaseLinkDef.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifdef __CINT__ - -#pragma link off all globals; -#pragma link off all classes; -#pragma link off all functions; - -#pragma link C++ class CbmROCUnpack; -#pragma link C++ class CbmTSUnpack; -#pragma link C++ class CbmTbEventBuilder; -#pragma link C++ class CbmTbEventBuilderFixedTimeWindow; -#pragma link C++ class CbmTbDaqBuffer; - -#endif diff --git a/beamtime/base/CbmROCUnpack.cxx b/beamtime/base/CbmROCUnpack.cxx deleted file mode 100644 index 016bcd3db988c48ae18fea180c786d222969896b..0000000000000000000000000000000000000000 --- a/beamtime/base/CbmROCUnpack.cxx +++ /dev/null @@ -1,20 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmROCUnpack ----- -// ----- Created 07.11.2014 by F. Uhlig ----- -// ----- ----- -// ----------------------------------------------------------------------------- -#include "CbmROCUnpack.h" -#include <TObject.h> // for TObject - -CbmROCUnpack::CbmROCUnpack() - : TObject(), - fPersistence(kTRUE) -{ -} - -CbmROCUnpack::~CbmROCUnpack() -{ -} - -ClassImp(CbmROCUnpack) diff --git a/beamtime/base/CbmROCUnpack.h b/beamtime/base/CbmROCUnpack.h deleted file mode 100644 index adbd8fe31561e624fc1be3e11d8c8d774bbdf67b..0000000000000000000000000000000000000000 --- a/beamtime/base/CbmROCUnpack.h +++ /dev/null @@ -1,66 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmROCUnpack ----- -// ----- Created 10.11.2014 by F. Uhlig ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CBMROCUNPACK_H -#define CBMROCUNPACK_H - -#include <Rtypes.h> // for ClassDef -#include <RtypesCore.h> // for Bool_t, ULong_t, kTRUE -#include <TObject.h> // for TObject -#include <boost/any.hpp> -#include <string> -#include <vector> -#include <FairRootManager.h> - -namespace roc { class Message; } - -class CbmROCUnpack : public TObject -{ - public: - - CbmROCUnpack(); - virtual ~CbmROCUnpack(); - - virtual Bool_t Init() = 0; - virtual Bool_t DoUnpack(roc::Message* Message, ULong_t hitTime) = 0; - virtual void FillOutput(boost::any digi) = 0; - virtual void Reset() = 0; - virtual void Finish() = 0; - - void SetPersistence(Bool_t persistence = kTRUE) - { fPersistence = persistence; } - - /** @brief Register the output arrays - ** - ** An array for the digis will be created and - ** registered as output to the ROOT tree. The current implementation - ** uses std::vector as container. - ** The pointer to the registered array is passed as return value - **/ - template <class Digi> - std::vector<Digi>* RegisterOutput(std::string branchName) - { - // --- Get FairRootManager instance - FairRootManager* ioman = FairRootManager::Instance(); - assert ( ioman ); - - // --- Branch for digis - std::vector<Digi>* fDigis = new std::vector<Digi>(); - ioman->RegisterAny(branchName.c_str(), fDigis, - fPersistence); - return fDigis; - } - - - protected: - - Bool_t fPersistence; - - ClassDef(CbmROCUnpack, 0) -}; - -#endif diff --git a/beamtime/base/CbmTSUnpack.cxx b/beamtime/base/CbmTSUnpack.cxx deleted file mode 100644 index 61e105f497cbb06b00898bfad416a97e8c83b286..0000000000000000000000000000000000000000 --- a/beamtime/base/CbmTSUnpack.cxx +++ /dev/null @@ -1,20 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmTSUnpack ----- -// ----- Created 07.11.2014 by F. Uhlig ----- -// ----- ----- -// ----------------------------------------------------------------------------- -#include "CbmTSUnpack.h" -#include <TObject.h> // for TObject - - -CbmTSUnpack::CbmTSUnpack() - : TObject() -{ -} - -CbmTSUnpack::~CbmTSUnpack() -{ -} - -ClassImp(CbmTSUnpack) diff --git a/beamtime/base/CbmTSUnpack.h b/beamtime/base/CbmTSUnpack.h deleted file mode 100644 index 9fd96edbb670a566a9d69e822e94f8cf7fd2130f..0000000000000000000000000000000000000000 --- a/beamtime/base/CbmTSUnpack.h +++ /dev/null @@ -1,72 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmTSUnpack ----- -// ----- Created 07.11.2014 by F. Uhlig ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CBMTSUNPACK_H -#define CBMTSUNPACK_H - -#include <Rtypes.h> // for ClassDef -#include <RtypesCore.h> // for Bool_t, kTRUE -#include <stddef.h> // for size_t -#include <TObject.h> // for TObject -#include <boost/any.hpp> -#include <FairRootManager.h> // FairRootManager - -namespace fles { class Timeslice; } - -class CbmTSUnpack : public TObject -{ - public: - - CbmTSUnpack(); - virtual ~CbmTSUnpack(); - - virtual Bool_t Init() = 0; - - virtual Bool_t DoUnpack(const fles::Timeslice& ts, size_t component) = 0; - - virtual void Reset() = 0; - - virtual void Finish() = 0; - - virtual void SetParContainers() = 0; - - virtual Bool_t InitContainers() {return kTRUE;} - - virtual Bool_t ReInitContainers() {return kTRUE;} - - virtual void FillOutput(boost::any) = 0; - - /** @brief Register the output arrays - ** - ** An array for the digis will be created and - ** registered as output to the ROOT tree. The current implementation - ** uses std::vector as container. - ** The pointer to the registered array is passed as return value - **/ - template <class Digi> - std::vector<Digi>* RegisterOutput(std::string branchName) - { - - // --- Get FairRootManager instance - FairRootManager* ioman = FairRootManager::Instance(); - assert ( ioman ); - - // --- Branch for digis - std::vector<Digi>* fDigis = new std::vector<Digi>(); - ioman->RegisterAny(branchName.c_str(), fDigis, - kTRUE); - return fDigis; -// Isoutputbranchpersistent(branchName)); - - } - // -------------------------------------------------------------------------- - - - ClassDef(CbmTSUnpack, 0) -}; - -#endif diff --git a/beamtime/base/CbmTbDaqBuffer.cxx b/beamtime/base/CbmTbDaqBuffer.cxx deleted file mode 100644 index 56327c7f9bd384e5816f3037835a6fb034f363fd..0000000000000000000000000000000000000000 --- a/beamtime/base/CbmTbDaqBuffer.cxx +++ /dev/null @@ -1,87 +0,0 @@ -/** @file CbmTbDaqBuffer.cxx - ** @author Volker Friese <v.friese@gsi.de> - ** @date 13 December 2013 - **/ - -#include "CbmTbDaqBuffer.h" - -#include <FairLogger.h> // for Logger, LOG -#include <stddef.h> // for NULL -#include <iomanip> // for setprecision, __iom_t5 -#include <sstream> // for basic_stringstream<>::string_type -#include <boost/any.hpp> - -// ----- Initialisation of static variables ------------------------------ -CbmTbDaqBuffer* CbmTbDaqBuffer::fgInstance = nullptr; -// --------------------------------------------------------------------------- - - - -// ----- Constructor ----------------------------------------------------- -CbmTbDaqBuffer::CbmTbDaqBuffer() : fData() { -} -// --------------------------------------------------------------------------- - - -// ----- Destructor ------------------------------------------------------ -CbmTbDaqBuffer::~CbmTbDaqBuffer() { -} -// --------------------------------------------------------------------------- - -Double_t CbmTbDaqBuffer::GetTimeFirst() const -{ - if ( ! GetSize() ) return -1.; - // Return the key from the first element in the map - // The key of the map is the time of digi - return fData.begin()->first; -} - -Double_t CbmTbDaqBuffer::GetTimeLast() const -{ - if ( ! GetSize() ) return -1.; - // Return the key from the last element in the map - // The key of the map is the time of digi - return (--fData.end())->first; -} - -// ----- Access to next data --------------------------------------------- -CbmTbDaqBuffer::Data CbmTbDaqBuffer::GetNextData(Double_t time) { - - // --- Check for empty buffer - if ( ! fData.size() ) return std::make_pair(boost::any(), ECbmModuleId::kNotExist); - - // --- Get data from buffer - std::multimap<Double_t, std::pair<boost::any, ECbmModuleId>>::iterator it = fData.begin(); - Double_t digi_time = it->first; - - if ( digi_time < time ) { - boost::any digi = it->second.first; - ECbmModuleId sysID = it->second.second; - fData.erase(it); - return std::make_pair(digi, sysID); - } - return std::make_pair(boost::any(), ECbmModuleId::kNotExist); -} -// --------------------------------------------------------------------------- - -// ----- Instance -------------------------------------------------------- -CbmTbDaqBuffer* CbmTbDaqBuffer::Instance() { - if ( ! fgInstance ) fgInstance = new CbmTbDaqBuffer(); - return fgInstance; -} -// --------------------------------------------------------------------------- - -// ----- Print status ---------------------------------------------------- -void CbmTbDaqBuffer::PrintStatus() const { - Int_t size = GetSize(); - std::stringstream ss; - ss << "CbmTbDaqBuffer: Status "; - if ( ! size ) { - LOG(info) << ss.str() << "empty"; - return; - } - LOG(info) << ss.str() << GetSize() << " digis from " - << std::fixed << std::setprecision(9) << GetTimeFirst() * 1.e-9 << " s to " - << GetTimeLast() *1.e-9 << " s"; -} -// --------------------------------------------------------------------------- diff --git a/beamtime/base/CbmTbDaqBuffer.h b/beamtime/base/CbmTbDaqBuffer.h deleted file mode 100644 index a66952b285df441e8dae1229d8ae2c4340f72bf8..0000000000000000000000000000000000000000 --- a/beamtime/base/CbmTbDaqBuffer.h +++ /dev/null @@ -1,118 +0,0 @@ -/** @file CbmDaqBuffer.h - ** @author Volker Friese <v.friese@gsi.de> - ** @date 17 July 2012 - **/ - -#ifndef CBMTBDAQBUFFER_H -#define CBMTBDAQBUFFER_H 1 - -#include <RtypesCore.h> // for Double_t, Int_t -#include <map> // for multimap, __map_const_iterator, multimap<>::... -#include <utility> // for pair -#include <boost/any.hpp> -#include "CbmDefs.h" - -/** @class CbmTbDaqBuffer - ** @author Volker Friese <v.friese@gsi.de> - ** @date 13 December 2012 - ** @brief Singleton buffer class for CBM raw data - ** - ** The CbmTbDaqBuffer stores and sorts (w.r.t. time) CBM raw data - ** (currently: boost::any) transiently. - ** Data can be send to the buffer by the method InsertData. - ** They can be retrieved by GetNextData, which delivers a - ** time-ordered sequence of raw data objects. - ** - ** There is only one buffer stream, irrespective of the detector system. - ** - ** The buffer handles objects only by pointer, i.e. the data have - ** to be instantiated by the sending task (digitiser) and - ** deleted by the receiving class (CbmDaq). - **/ -class CbmTbDaqBuffer -{ - public: - - typedef std::pair<boost::any, ECbmModuleId> Data; - - /** Destructor **/ - ~CbmTbDaqBuffer(); - - /** Pointer to next raw data object - ** up to given time - ** @param time maximal time [ns] - ** @return pointer to raw data object - ** - ** A NULL pointer will be returned if no further data can be released. - ** This does not mean that the buffer is empty. - **/ - // boost::any GetNextData(Double_t time); - Data GetNextData(Double_t time); - - - /** Current buffer size - ** @return number of objects in buffer - */ - Int_t GetSize() const { return fData.size(); } - - - /** Get first digi time **/ - Double_t GetTimeFirst() const; - - /** Get last digi time **/ - Double_t GetTimeLast() const; - - /** Access to singleton instance - ** @return pointer to instance - **/ - static CbmTbDaqBuffer* Instance(); - - /** Print buffer status **/ - void PrintStatus() const; - - /** Insert digi of any type into the buffer */ - template <class Digi> - void InsertData(Digi* digi) - { - Double_t digi_time = digi->GetTime(); - ECbmModuleId systemID = Digi::GetSystem(); - InsertData(digi, digi_time, systemID); - } - - private: - - - /** Buffer management **/ - std::multimap<Double_t, Data> fData; - - - /** Pointer to singleton instance **/ - static CbmTbDaqBuffer* fgInstance; - - - /** Default constructor - ** Declared private to prevent instantiation. - **/ - CbmTbDaqBuffer(); - - - /** Copy constructor. Defined private to prevent usage. **/ - CbmTbDaqBuffer(const CbmTbDaqBuffer&); - - - /** Assignment operator. Defined private to prevent usage. **/ - CbmTbDaqBuffer& operator=(const CbmTbDaqBuffer&); - - /** Insert data into the buffer - ** @param digi pointer to data object to be inserted - **/ - // void InsertData(boost::any digi); - void InsertData(boost::any digi, Double_t time, ECbmModuleId systemID) - { - fData.insert(std::make_pair(time, std::make_pair(std::move(digi), systemID))); - } - -}; - - -#endif /* CBMTBDAQBUFFER_H */ diff --git a/beamtime/base/CbmTbEventBuilder.cxx b/beamtime/base/CbmTbEventBuilder.cxx deleted file mode 100644 index 1454b96df7c515c4087d923e961ea4b964c4c400..0000000000000000000000000000000000000000 --- a/beamtime/base/CbmTbEventBuilder.cxx +++ /dev/null @@ -1,21 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmTbEventBuilder ----- -// ----- Created 14.12.2014 by F. Uhlig ----- -// ----- ----- -// ----------------------------------------------------------------------------- -#include "CbmTbEventBuilder.h" -#include <TObject.h> // for TObject -#include <stddef.h> // for NULL - -CbmTbEventBuilder::CbmTbEventBuilder() - : TObject(), - fCurrentEvent(NULL) -{ -} - -CbmTbEventBuilder::~CbmTbEventBuilder() -{ -} - -ClassImp(CbmTbEventBuilder) diff --git a/beamtime/base/CbmTbEventBuilder.h b/beamtime/base/CbmTbEventBuilder.h deleted file mode 100644 index 85c7adab45401d17aa645f5b0574561d0f0db19d..0000000000000000000000000000000000000000 --- a/beamtime/base/CbmTbEventBuilder.h +++ /dev/null @@ -1,42 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmTbEventBuilder ----- -// ----- Created 14.12.2014 by F. Uhlig ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CBMTBEVENTBUILDER_H -#define CBMTBEVENTBUILDER_H - -#include <Rtypes.h> // for ClassDef -#include <RtypesCore.h> // for Bool_t -#include <TObject.h> // for TObject -#include <boost/any.hpp> -class CbmTbEvent; - -class CbmTbEventBuilder : public TObject -{ - public: - - CbmTbEventBuilder(); - virtual ~CbmTbEventBuilder(); - - virtual Bool_t Init() = 0; - virtual Bool_t IsInEvent(boost::any digi) = 0; - virtual void Reset() = 0; - virtual void PrintCurrentEvent() = 0; - - virtual void BuildNextEvent() = 0; - - protected: - // --- Event status - CbmTbEvent* fCurrentEvent; ///< Pointer to current event - - private: - CbmTbEventBuilder(const CbmTbEventBuilder&); - CbmTbEventBuilder& operator=(const CbmTbEventBuilder&); - - ClassDef(CbmTbEventBuilder, 0) -}; - -#endif diff --git a/beamtime/base/CbmTbEventBuilderFixedTimeWindow.cxx b/beamtime/base/CbmTbEventBuilderFixedTimeWindow.cxx deleted file mode 100644 index 6ddad0e6ebb81b2d93f7d88862462576468495d3..0000000000000000000000000000000000000000 --- a/beamtime/base/CbmTbEventBuilderFixedTimeWindow.cxx +++ /dev/null @@ -1,69 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmTbEventBuilderFixedTimeWindow ----- -// ----- Created 14.12.2014 by F. Uhlig ----- -// ----- ----- -// ----------------------------------------------------------------------------- -#include "CbmTbEventBuilderFixedTimeWindow.h" - -#include <FairEventHeader.h> // for FairEventHeader -#include <TMathBase.h> // for Abs -#include <FairLogger.h> // for LOG, Logger -#include "CbmTbEvent.h" // for CbmTbEvent -#include <FairRootManager.h> // for FairRootManager -#include <FairRunOnline.h> // for FairRunOnline - -CbmTbEventBuilderFixedTimeWindow::CbmTbEventBuilderFixedTimeWindow() - : CbmTbEventBuilder(), - fEventTimeWindow(500.) -{ -} - -CbmTbEventBuilderFixedTimeWindow::~CbmTbEventBuilderFixedTimeWindow() -{ -} - -Bool_t CbmTbEventBuilderFixedTimeWindow::Init() -{ - // --- Get event header from Run - fCurrentEvent = - dynamic_cast<CbmTbEvent*> (FairRunOnline::Instance()->GetEventHeader()); - if ( ! fCurrentEvent ) { - LOG(fatal) << "No event header in run!"; - } - - LOG(info) << "Init : event header at " << fCurrentEvent; - FairRootManager* ioman = FairRootManager::Instance(); - ioman->Register("EventHeader.", "Event", fCurrentEvent, kTRUE); - - return kTRUE; -} - -Bool_t CbmTbEventBuilderFixedTimeWindow::IsInEvent(boost::any /*digi*/) -{ -/* - if ( ! fCurrentEvent ) { - LOG(fatal) << "No pointer to event header! " << fCurrentEvent; - } - - // If event is empty or time of digi matches to event, - // add digi to event. - Double_t tDif = TMath::Abs(digi->GetTime() - fCurrentEvent->GetTime() ); - - if ( fCurrentEvent->IsEmpty() || tDif < fEventTimeWindow ) { - - // --- Update event object - fCurrentEvent->AddDigi(digi); - return kTRUE; - } - -*/ - return kFALSE; -} - -void CbmTbEventBuilderFixedTimeWindow::Reset() -{ - // --- Clear event header - fCurrentEvent->Clear(); -} -ClassImp(CbmTbEventBuilderFixedTimeWindow) diff --git a/beamtime/base/CbmTbEventBuilderFixedTimeWindow.h b/beamtime/base/CbmTbEventBuilderFixedTimeWindow.h deleted file mode 100644 index 1da9f45b2d3af6b1b34f1f48d2165a46167bba50..0000000000000000000000000000000000000000 --- a/beamtime/base/CbmTbEventBuilderFixedTimeWindow.h +++ /dev/null @@ -1,41 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmTbEventBuilderFixedTimeWindow ----- -// ----- Created 14.12.2014 by F. Uhlig ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CBMTBEVENTBUILDERFIXEDTIMEWINDOW_H -#define CBMTBEVENTBUILDERFIXEDTIMEWINDOW_H - -#include <Rtypes.h> // for ClassDef -#include <RtypesCore.h> // for Bool_t, Double_t -#include "CbmTbEvent.h" // for CbmTbEvent -#include "CbmTbEventBuilder.h" // for CbmTbEventBuilder -#include <boost/any.hpp> - -class CbmTbEventBuilderFixedTimeWindow : public CbmTbEventBuilder -{ - public: - - CbmTbEventBuilderFixedTimeWindow(); - virtual ~CbmTbEventBuilderFixedTimeWindow(); - - virtual Bool_t Init(); - virtual Bool_t IsInEvent(boost::any); - virtual void Reset(); - virtual void PrintCurrentEvent() - { fCurrentEvent->Print(); } - - virtual void BuildNextEvent(){;} - - void SetEventTimeWindow(Double_t window) { fEventTimeWindow = window; } - - private: - - Double_t fEventTimeWindow; - - ClassDef(CbmTbEventBuilderFixedTimeWindow, 1) -}; - -#endif diff --git a/beamtime/cern2014/CMakeLists.txt b/beamtime/cern2014/CMakeLists.txt deleted file mode 100644 index 837e7b4b061db8966f9358c0017095988f3a80c5..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/CMakeLists.txt +++ /dev/null @@ -1,113 +0,0 @@ -# Create a library called "libCbmFlibReader" which includes the source files given in -# the array . -# The extension is already found. Any number of sources could be listed here. - -Set(INCLUDE_DIRECTORIES - ${CBMDATA_DIR} - ${CBMDATA_DIR}/trd - - ${CBMBASE_DIR} - - ${CBMROOT_SOURCE_DIR}/beamtime/base - ${CBMROOT_SOURCE_DIR}/beamtime/rich - ${CBMROOT_SOURCE_DIR}/beamtime/data/fhodo - ${CBMROOT_SOURCE_DIR}/beamtime/data/raw - ${CBMROOT_SOURCE_DIR}/beamtime/tof - ${CBMROOT_SOURCE_DIR}/beamtime/tof/tdc - ${CBMROOT_SOURCE_DIR}/beamtime/tof/tdc/get4 - - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/unpacker - ${CMAKE_CURRENT_SOURCE_DIR}/tasks - ${CMAKE_CURRENT_SOURCE_DIR}/get4 - - ${CBMROOT_SOURCE_DIR}/beamtime/trb/trbnet_lib -) - -Set(SYSTEM_INCLUDE_DIRECTORIES - ${BASE_INCLUDE_DIRECTORIES} - ${Boost_INCLUDE_DIR} - ${ROOT_INCLUDE_DIR} - ${CBMROOT_SOURCE_DIR}/external/ipc_legacy/ipc/src - ${CBMROOT_SOURCE_DIR}/external/flib_dpb/flib_dpb - ${CBMROOT_SOURCE_DIR}/external/flib_dpb_20/flib_dpb_20 - ${CBMROOT_SOURCE_DIR}/external/spadic/spadic - - - # needed by rootcling - ${CBMROOT_SOURCE_DIR}/external/spadic/spadic/lib/message/wrap/cpp - ${CBMROOT_SOURCE_DIR}/external/spadic/spadic/lib/message - ${CMAKE_SOURCE_DIR}/external/cppzmq -) - -Include_Directories(${INCLUDE_DIRECTORIES}) -Include_Directories(SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES}) - - -Set(LINK_DIRECTORIES - ${ROOT_LIBRARY_DIR} - ${FAIRROOT_LIBRARY_DIR} - ${Boost_LIBRARY_DIRS} - ${Vc_LIB_DIR} - ${KFParticle_LIB_DIR} -) - -Link_Directories( - ${LINK_DIRECTORIES} -) - -Set(SRCS - CbmFlibFileSource.cxx -# CbmNxFlibFileSource.cxx - CbmFlibFileSourceNew.cxx - CbmFiberHodoMapping.cxx - - unpacker/CbmTSUnpackSpadic.cxx - unpacker/CbmTSUnpackSpadic20.cxx - unpacker/CbmTSUnpackSpadic11OnlineMonitor.cxx - unpacker/CbmTSUnpackSpadic20OnlineMonitor.cxx - unpacker/CbmTSUnpackSpadic20DesyOnlineMonitor.cxx - unpacker/CbmTSUnpackSpadicLegacy.cxx - unpacker/CbmTSUnpackNxyter.cxx - unpacker/CbmTSUnpackStsxyter.cxx - unpacker/CbmTSUnpackTestMiniRich.cxx - unpacker/CbmTSUnpackFiberHodo.cxx - unpacker/CbmTSUnpackDummy.cxx - unpacker/CbmTSUnpackTrb.cxx - unpacker/CbmGet4v1xHackDef.cxx - unpacker/CbmTSUnpackGet4v1x.cxx - unpacker/CbmTSUnpackSpadicOnlineFex.cxx - - get4/CbmGet4FastMonitor.cxx - get4/CbmGet4EpochBuffer.cxx - get4/CbmGet4EventBuilder.cxx - get4/CbmGet4EventBuffer.cxx - - tasks/CbmTrdRawBeamProfile.cxx - tasks/CbmTrdRawBuchData.cxx - tasks/CbmTrdRawPulseMonitor.cxx - tasks/CbmTrdOnlineDisplay.cxx - tasks/CbmTrdEveOnlineDisplay.cxx - tasks/CbmTrdDaqBuffer.cxx - - tasks/CbmTestMiniRichPairBuilder.cxx -) - -Set(NO_DICT_SRCS - unpacker/TimesliceReader.cpp - unpacker/TimesliceReader20.cpp -) - -If(_UINT8_T_EXIST) - Add_Definitions(-DHAVE_UINT8_T_HEADER_FILE) - Set(DEFINITIONS HAVE_UINT8_T_HEADER_FILE) -EndIf() - -Set(LINKDEF CbmBeamtimeCern2014LinkDef.h ) -Set(LIBRARY_NAME CbmBeamtimeCern2014) -Set(DEPENDENCIES - CbmBase CbmBeamtimeBase CbmBeamtimeData fles_ipc_legacy flib_dpb flib_dpb_20 - spadicMessage trbnet Eve Base -) - -GENERATE_LIBRARY() diff --git a/beamtime/cern2014/CbmBeamDefaults.h b/beamtime/cern2014/CbmBeamDefaults.h deleted file mode 100644 index f0605c859cb1b58e25890d6a3812f2cdbc1d6c30..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/CbmBeamDefaults.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Deprecation Warning: this class is not used any longer in the new cbmtrdtools which are the base parameter classes for any new analysis. - * It is just needed for older tasks, so it cannot be removed yet. - */ - -#ifndef CBMBEAMDEFAULTS_H -#define CBMBEAMDEFAULTS_H 1 - -#include <map> - - -/** DetectorID enumerator **/ -enum Exp_Group {kFlesRich=0xE000, - kFlesMuenster=0xE001, - kFlesFrankfurt=0xE002, - kFlesBucarest=0xE003, - kFlesHodo1=0xE004, - kFlesHodo2=0xE005}; -/** Maximum number of Syscores which could be in the system **/ -const Int_t NrOfSyscores = 1; - -/* Number of Active Syscores in the System */ -const Int_t NrOfActiveSyscores=1; -/** Number of AFCKs which could be in the system **/ -const Int_t NrOfAfcks = 4; // was 4 -/** Maximum number of Spadics which could attached to one Syscore **/ -const Int_t NrOfSpadics =3; // was 3 -const Int_t NrOfHalfSpadics = NrOfSpadics*2; - -/* Number of Active Spadics on each Syscore the System */ -const Int_t NrOfActiveSpadics=1; -const Int_t NrOfActiveHalfSpadics = NrOfActiveSpadics*2; - -/** Base address which will be added to each half spadic number - the first halfspadic which is connected to the Syscore - get SpadicBaseAddress+0, the second SpadicBaseAddress +1 ... */ -const Int_t SpadicBaseAddress = 0; -const Int_t BaseEquipmentID = kFlesRich; - -/* -static const std::map<Int_t, Int_t> groupToExpMap - = { std::make_pair(kMuenster,0), - std::make_pair(kFrankfurt,1), - std::make_pair(Bucarest,2) -}; -*/ -static const std::map<Int_t, Int_t> groupToExpMap = { - {kFlesRich,0}, - {kFlesMuenster,1}, - {kFlesFrankfurt,2}, - {kFlesBucarest,3} -}; - -#endif diff --git a/beamtime/cern2014/CbmBeamtimeCern2014LinkDef.h b/beamtime/cern2014/CbmBeamtimeCern2014LinkDef.h deleted file mode 100644 index 51a49f4b8b63de8802dcc55d6cc12c5502c02047..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/CbmBeamtimeCern2014LinkDef.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifdef __CINT__ - -#pragma link off all globals; -#pragma link off all classes; -#pragma link off all functions; - -#pragma link C++ class CbmFlibFileSource; -//#pragma link C++ class CbmNxFlibFileSource; -#pragma link C++ class CbmFlibFileSourceNew; - -//#pragma link C++ class CbmTSUnpack; -#pragma link C++ class CbmTSUnpackSpadic; -#pragma link C++ class CbmTSUnpackSpadic20; -#pragma link C++ class CbmTSUnpackSpadic11OnlineMonitor; -#pragma link C++ class CbmTSUnpackSpadic20OnlineMonitor; -#pragma link C++ class CbmTSUnpackSpadic20DesyOnlineMonitor; -#pragma link C++ class CbmTSUnpackSpadicLegacy; -#pragma link C++ class CbmTSUnpackNxyter; -#pragma link C++ class CbmTSUnpackStsxyter; - -#pragma link C++ class CbmTSUnpackTestMiniRich; -#pragma link C++ class CbmTestMiniRichPairBuilder; - -#pragma link C++ class CbmTSUnpackFiberHodo; -#pragma link C++ class CbmTSUnpackDummy; -#pragma link C++ class CbmTSUnpackTrb; -#pragma link C++ class get4v1x::Message; -#pragma link C++ class get4v1x::FullMessage; -#pragma link C++ class CbmTSUnpackGet4v1x+; -#pragma link C++ class CbmTSUnpackSpadicOnlineFex; - -#pragma link C++ class CbmGet4FastMonitor; -#pragma link C++ class CbmGet4EpochBuffer; -#pragma link C++ class CbmGet4EventBuilder+; -#pragma link C++ class CbmGet4EventBuffer; - -#ifdef BUILD_TOF_BEAMTIME - #pragma link C++ class CbmGet4EventDumper; - // #pragma link C++ class CbmGet4EventMonitor; -#endif // NOT BUILD_BEAMTIME_LIB - -#pragma link C++ class CbmFiberHodoMapping; -#pragma link C++ class CbmTrdRawBeamProfile; -#pragma link C++ class CbmTrdRawBuchData; -#pragma link C++ class CbmTrdRawPulseMonitor; -#pragma link C++ class CbmTrdOnlineDisplay; -#pragma link C++ class CbmTrdEveOnlineDisplay; -//#pragma link C++ class CbmTrdDaqBuffer; - -#endif diff --git a/beamtime/cern2014/CbmFiberHodoMapping.cxx b/beamtime/cern2014/CbmFiberHodoMapping.cxx deleted file mode 100644 index 468f1341691890b5dbc71c93b382530a194d8d7a..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/CbmFiberHodoMapping.cxx +++ /dev/null @@ -1,125 +0,0 @@ -#include "CbmFiberHodoMapping.h" - -#include "CbmBeamDefaults.h" - -#include "FairLogger.h" - -CbmFiberHodoMapping::CbmFiberHodoMapping() - :TObject(), - fFiberHodoFiber(), - fFiberHodoPlane(), - fFiberHodoPixel() -{ - InitializeFiberHodoMapping(); -} - -CbmFiberHodoMapping::~CbmFiberHodoMapping() -{ -} - -// ----- Get Fiber Hodoscope station number ------------------------------ -Int_t CbmFiberHodoMapping::GetFiberHodoStation(Int_t rocId) { - - return rocId; - - if ( rocId < 5 || rocId > 6 ) { - LOG(error) << GetName() << ": Illegal Fiber Hodoscope ROC Id " << rocId; - return -1; - } - return ( rocId - 5 ); -} -// --------------------------------------------------------------------------- - -Int_t CbmFiberHodoMapping::GetFiberHodoChannel(Int_t /*rocId*/, Int_t /*nxId*/, Int_t /*nxChannel*/) { - Int_t channel = -1; - return channel; -} - - -// ----- Mapping --------------------------------------------------------- -Bool_t CbmFiberHodoMapping::Map(Int_t eqId, Int_t /*febId*/, Int_t channel, - Int_t& iStation, Int_t& iSector, - Int_t& iSide, Int_t& iChannel) { - - iStation = eqId - kFlesHodo1; - iSector = 0; - iSide = fFiberHodoPlane[channel]; - iChannel = fFiberHodoFiber[channel]; - return kTRUE; - -} -// --------------------------------------------------------------------------- - -void CbmFiberHodoMapping::InitializeFiberHodoMapping() -{ - // This code was copied from the Go4 analysis used for previous beamtimes - for (Int_t i=0; i<128; i++) { - fFiberHodoFiber[i] = -1; - fFiberHodoPlane[i] = -1; - fFiberHodoPixel[i] = -1; - } - - for (Int_t ifiber=1; ifiber<=64; ifiber++) { - // Calculate fiber number [1..64] from feb channel - // lcn: linearconnectornumber, is the wire number on one of the - // flat cables. [1..16] - // each 16 fibers go to one connector. - // fibersubnr[0..15] linear fiber counter in groups of 16 - - Int_t fibersubnr=(ifiber-1)%16; - - Int_t lcn=15-fibersubnr*2; - if (fibersubnr>=8) lcn=(fibersubnr-7)*2; - - Int_t channel=-1; - Int_t cable=(ifiber-1)/16+1; - Int_t pixel= ((lcn-1)/2)*8 +((lcn-1)%2); - if (cable==1) { - channel=(lcn-1)*4+0; - pixel=pixel+1; - } - if (cable==2) { - channel=(lcn-1)*4+2; - pixel=pixel+3; - } - if (cable==3) { - channel=(lcn-1)*4+1; - pixel=pixel+5; - } - if (cable==4) { - channel=(lcn-1)*4+3; - pixel=pixel+7; - } - - // new code to resolve cabling problem during cern-oct12 - int ifiber_bis = ifiber; - if (ifiber <= 8 ) ifiber_bis = ifiber + 56; else - if (ifiber <= 16 ) ifiber_bis = ifiber + 40; else - if (ifiber <= 24 ) ifiber_bis = ifiber + 24; else - if (ifiber <= 32 ) ifiber_bis = ifiber + 8; else - if (ifiber <= 40 ) ifiber_bis = ifiber - 8; else - if (ifiber <= 48 ) ifiber_bis = ifiber - 24; else - if (ifiber <= 56 ) ifiber_bis = ifiber - 40; else - if (ifiber <= 64 ) ifiber_bis = ifiber - 56; - - // and swap at the end - ifiber_bis = 65 - ifiber_bis; - - fFiberHodoFiber[channel] = ifiber_bis - 1; - fFiberHodoPlane[channel] = 0; - fFiberHodoPixel[channel] = pixel; - - fFiberHodoFiber[channel+64] = ifiber_bis - 1; - fFiberHodoPlane[channel+64] = 1; - fFiberHodoPixel[channel+64] = pixel; - - } - - for (Int_t i=0; i<128; i++) { - LOG(debug) << "Channel[" << i << "]: " << fFiberHodoFiber[i] << ", " - << fFiberHodoPlane[i] << ", " << fFiberHodoPixel[i] ; - } - -} - -ClassImp(CbmFiberHodoMapping) diff --git a/beamtime/cern2014/CbmFiberHodoMapping.h b/beamtime/cern2014/CbmFiberHodoMapping.h deleted file mode 100644 index c025d8052ad8befa4ef41363f9ee966ee6b1a236..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/CbmFiberHodoMapping.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef CBMFIBERHODOMAPPING_H -#define CBMFIBERHODOMAPPING_H 1 - - -#include "TObject.h" -#include "TString.h" - - -class CbmFiberHodoMapping : public TObject -{ - - - public: - - /** Default constructor **/ - CbmFiberHodoMapping(); - - - /** Destructor **/ - virtual ~CbmFiberHodoMapping(); - - /** Fiber Hodoscope station from ROC Id **/ - Int_t GetFiberHodoStation(Int_t rocId); - - /** Fiber Hodoscope channel from ROC, NXYTER and NXYTER channel **/ - Int_t GetFiberHodoChannel(Int_t rocId, Int_t nxId, Int_t nxChannel); - - - /** Mapping - **@param iRoc ROC number (from hit message) - **@param iNx NXYter number (from hit message) - **@param iId Channel ID (from hit message) - **@param iStation Station number (return) - **@param iSector Sector number ( return) - **@param iSide Front side (0) / Back side (1) ( return) - **@param iChannel Channel number (return) - **/ - Bool_t Map(Int_t iRoc, Int_t iNx, Int_t iId, - Int_t& iStation, Int_t& iSector, Int_t& iSide, Int_t& iChannel); - - private: - - void InitializeFiberHodoMapping(); - - Int_t fFiberHodoFiber[128]; //! /** Mapping from fiber hodoscope feb channel to fiber number **/ - Int_t fFiberHodoPlane[128]; //! /** Mapping from fiber hodoscope feb channel to plane number 1=X, 2=Y **/ - Int_t fFiberHodoPixel[128]; //! /** Mapping from fiber hodoscope feb channel to pixel number **/ - - ClassDef(CbmFiberHodoMapping,1); - -}; - -#endif - - - - diff --git a/beamtime/cern2014/CbmFlibFileSource.cxx b/beamtime/cern2014/CbmFlibFileSource.cxx deleted file mode 100644 index ab8217ce25fa2ad2fcfffd1977bdc919035faafe..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/CbmFlibFileSource.cxx +++ /dev/null @@ -1,232 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmFlibFileSource ----- -// ----- Created 01.11.2013 by F. Uhlig ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#include "CbmFlibFileSource.h" -#include "CbmSpadicRawMessage.h" - -#include "TimesliceInputArchive.hpp" -#include "Timeslice.hpp" -#include "TimesliceSubscriber.hpp" -#include "MicrosliceContents.hpp" - -// note M. Krieger, 2014-08-15: these includes should not be needed, please test -//#if 0 -//#include "Message.hpp" -//#include "message_reader.h" -//#endif - -#include "TimesliceReader.hpp" - -#include "FairLogger.h" -#include "FairRootManager.h" - -#include "TClonesArray.h" - -#include <iostream> -#include <fstream> - -CbmFlibFileSource::CbmFlibFileSource() - : FairSource(), - fFileName(""), - fHost("localhost"), - fPort(5556), - fSpadicRaw(new TClonesArray("CbmSpadicRawMessage", 10)), - fTSCounter(0), - fSource(NULL) -{ -} - - - -/* -CbmFlibFileSource::CbmFlibFileSource(const CbmFlibFileSource& source) - : FairSource(source), - fFileName(""), - fHost("localhost"), - fPort(5556), - fSpadicRaw(NULL), - fSource(NULL) -{ -} -*/ - -CbmFlibFileSource::~CbmFlibFileSource() -{ -} - -Bool_t CbmFlibFileSource::Init() -{ - if ( 0 == fFileName.Length() ) { - TString connector = Form("tcp://%s:%i", fHost.Data(), fPort); - LOG(info) << "Open TSPublisher at " << connector; - fSource = new fles::TimesliceSubscriber(connector.Data()); - if ( !fSource) { - LOG(fatal) << "Could not connect to publisher."; - } - } else { - LOG(info) << "Open the Flib input file " << fFileName; - // Check if the input file exist - FILE* inputFile = fopen(fFileName.Data(), "r"); - if ( ! inputFile ) { - LOG(fatal) << "Input file " << fFileName << " doesn't exist."; - } - fclose(inputFile); - // Open the input file - fSource = new fles::TimesliceInputArchive(fFileName.Data()); - //fSource.reset(new fles::TimesliceInputArchive(fFileName.Data())); - if ( !fSource) { - LOG(fatal) << "Could not open input file."; - } - } - - FairRootManager* ioman = FairRootManager::Instance(); - ioman->Register("SpadicRawMessage", "spadic raw data", fSpadicRaw, kTRUE); - - return kTRUE; - -} - -Int_t CbmFlibFileSource::ReadEvent(UInt_t) -{ - fSpadicRaw->Clear(); - while (auto timeslice = fSource->get()) { - fTSCounter++; - if ( 0 == fTSCounter%100 ) { - LOG(info) << "Analyse Event " << fTSCounter; - } - const fles::Timeslice& ts = *timeslice; - for (size_t c {0}; c < ts.num_components(); c++) { - auto systemID = ts.descriptor(c, 0).sys_id; - - if(gLogger->IsLogNeeded( fair::Severity::debug )) { - PrintMicroSliceDescriptor(ts.descriptor(c, 0)); - } - switch (systemID) { - case 0xFA: - LOG(info) << "It is flesnet pattern generator data"; - break; - case 0xF0: - LOG(info) << "It is flib pattern generator data"; - break; - case 0xBC: - LOG(info) << "It is spadic data with wrong system ID"; - UnpackSpadicCbmNetMessage(ts, c); - break; - case 0x40: - LOG(debug) << "It is spadic data with correct system ID"; - UnpackSpadicCbmNetMessage(ts, c); - break; - default: - LOG(info) << "Not known now"; - } - } - return 0; - } - - return 1; // no more data; trigger end of run -} - -void CbmFlibFileSource::PrintMicroSliceDescriptor(const fles::MicrosliceDescriptor& mdsc) -{ - LOG(debug) << "Header ID: Ox" << std::hex << static_cast<int>(mdsc.hdr_id) - << std::dec; - LOG(debug) << "Header version: Ox" << std::hex << static_cast<int>(mdsc.hdr_ver) - << std::dec; - LOG(debug) << "Equipement ID: " << mdsc.eq_id; - LOG(debug) << "Flags: " << mdsc.flags; - LOG(debug) << "Sys ID: Ox" << std::hex << static_cast<int>(mdsc.sys_id) - << std::dec; - LOG(debug) << "Sys version: Ox" << std::hex << static_cast<int>(mdsc.sys_ver) - << std::dec; - LOG(debug) << "Microslice Idx: " << mdsc.idx; - LOG(debug) << "Checksum: " << mdsc.crc; - LOG(debug) << "Size: " << mdsc.size; - LOG(debug) << "Offset: " << mdsc.offset; -} - - -void CbmFlibFileSource::UnpackSpadicCbmNetMessage(const fles::Timeslice& ts, size_t component) -{ - spadic::TimesliceReader r; - Int_t counter=0; - - r.add_component(ts, component); - - for (auto addr : r.sources()) { -// std::cout << "---- reader " << addr << " ----" << std::endl; - while (auto mp = r.get_message(addr)) { - if (gLogger->IsLogNeeded( fair::Severity::debug )) { - print_message(*mp); - } - Int_t link = ts.descriptor(component, 0).eq_id; - Int_t address = addr; - Int_t channel = mp->channel_id(); - Int_t epoch = -1; - Int_t time = mp->timestamp(); - Int_t samples = mp->samples().size(); - Int_t* sample_values = new Int_t[samples]; - Int_t counter1=0; - for (auto x : mp->samples()) { - sample_values[counter1] = x; - ++counter1; - } - new( (*fSpadicRaw)[counter] ) - CbmSpadicRawMessage(link, address, channel, epoch, time, -1, -1, -1, -1, -1, -1, samples, sample_values); - ++counter; - delete[] sample_values; - } - } - -} - -void CbmFlibFileSource::print_message(const spadic::Message& m) -{ - std::cout << "v: " << (m.is_valid() ? "o" : "x"); - std::cout << " / gid: " << static_cast<int>(m.group_id()); - std::cout << " / chid: " << static_cast<int>(m.channel_id()); - if ( m.is_hit() ) { - std::cout << " / ts: " << m.timestamp(); - std::cout << " / samples (" << m.samples().size() << "):"; - for (auto x : m.samples()) { - std::cout << " " << x; - } - std::cout << std::endl; - } else { - if ( m.is_epoch_marker() ) { - std::cout << " This is an Epoch Marker" << std::endl; - } else if ( m.is_epoch_out_of_sync() ) { - std::cout << " This is an out of sync Epoch Marker" << std::endl; - } else { - std::cout << " This is not known" << std::endl; - } - } -} - - - - -Bool_t CbmFlibFileSource::CheckTimeslice(const fles::Timeslice& ts) -{ - if ( 0 == ts.num_components() ) { - LOG(error) << "No Component in TS " << ts.index(); - return 1; - } - LOG(info) << "Found " << ts.num_components() - << " different components in tiemeslice"; - return kTRUE; -} - -void CbmFlibFileSource::Close() -{ -} - -void CbmFlibFileSource::Reset() -{ -} - - -ClassImp(CbmFlibFileSource) diff --git a/beamtime/cern2014/CbmFlibFileSource.h b/beamtime/cern2014/CbmFlibFileSource.h deleted file mode 100644 index 80fd2dafd0ae75d772263ab5c3226498ccda5183..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/CbmFlibFileSource.h +++ /dev/null @@ -1,72 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmFlibFileSource ----- -// ----- Created 08.08.2014 by F. Uhlig ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CBMFLIBFILESOURCE_H -#define CBMFLIBFILESOURCE_H - -#include "TimesliceSource.hpp" -#include "Timeslice.hpp" -#include "MicrosliceDescriptor.hpp" -#include "Message.hpp" - -#include "FairSource.h" - -#include "TString.h" -#include "TClonesArray.h" - -#include <memory> - - -class CbmFlibFileSource : public FairSource -{ - public: - CbmFlibFileSource(); - virtual ~CbmFlibFileSource(); - - Bool_t Init(); - Int_t ReadEvent(UInt_t); - - Source_Type GetSourceType() {return kONLINE;} - - virtual void SetParUnpackers() {;} - - virtual Bool_t InitUnpackers() {return kTRUE;} - - virtual Bool_t ReInitUnpackers() {return kTRUE;} - - void Close(); - void Reset(); - - void SetFileName(TString name) { fFileName = name; } - void SetHostName(TString name) { fHost = name; } - void SetPortNumber(Int_t port) { fPort = port; } - - private: - - TString fFileName; - TString fHost; - Int_t fPort; - - // --- Output arrays - TClonesArray* fSpadicRaw; ///< Output array of CbmSpadicRawMessage - - Int_t fTSCounter; - - fles::TimesliceSource* fSource; //! - Bool_t CheckTimeslice(const fles::Timeslice& ts); - void UnpackSpadicCbmNetMessage(const fles::Timeslice& ts, size_t component); - void print_message(const spadic::Message& m); - void PrintMicroSliceDescriptor(const fles::MicrosliceDescriptor& mdsc); - - CbmFlibFileSource operator=(const CbmFlibFileSource&); - CbmFlibFileSource(const CbmFlibFileSource& source); - - ClassDef(CbmFlibFileSource, 1) -}; - - -#endif diff --git a/beamtime/cern2014/CbmFlibFileSourceNew.cxx b/beamtime/cern2014/CbmFlibFileSourceNew.cxx deleted file mode 100644 index 8df8aeca16aedb831fbb433d6e3cfb9829599854..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/CbmFlibFileSourceNew.cxx +++ /dev/null @@ -1,207 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmFlibFileSourceNew ----- -// ----- Created 01.11.2013 by F. Uhlig ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#include "CbmFlibFileSourceNew.h" - - -#include "TimesliceInputArchive.hpp" -#include "Timeslice.hpp" -#include "TimesliceSubscriber.hpp" -#include "MicrosliceContents.hpp" - -#include "FairLogger.h" - -#include <iostream> -#include <fstream> - -CbmFlibFileSourceNew::CbmFlibFileSourceNew() - : FairSource(), - fFileName(""), - fInputFileList(new TObjString()), - fFileCounter(0), - fHost("localhost"), - fPort(5556), - fUnpackers(), - fTSNumber(0), - fTSCounter(0), - fTimer(), - fSource(NULL) -{ -} - -CbmFlibFileSourceNew::CbmFlibFileSourceNew(const CbmFlibFileSourceNew& source) - : FairSource(source), - fFileName(""), - fInputFileList(), - fFileCounter(0), - fHost("localhost"), - fPort(5556), - fUnpackers(), - fTSNumber(0), - fTSCounter(0), - fTimer(), - fSource(NULL) -{ -} - -CbmFlibFileSourceNew::~CbmFlibFileSourceNew() -{ -} - -Bool_t CbmFlibFileSourceNew::Init() -{ - if ( 0 == fFileName.Length() ) { - TString connector = Form("tcp://%s:%i", fHost.Data(), fPort); - LOG(info) << "Open TSPublisher at " << connector; - fInputFileList.Add(new TObjString(connector)); - fSource = new fles::TimesliceSubscriber(connector.Data()); - if ( !fSource) { - LOG(fatal) << "Could not connect to publisher."; - } - } else { - // --- Open input file - TObjString* tmp = - dynamic_cast<TObjString*>(fInputFileList.At(fFileCounter)); - fFileName = tmp->GetString(); - - LOG(info) << "Open the Flib input file " << fFileName; - // Check if the input file exist - FILE* inputFile = fopen(fFileName.Data(), "r"); - if ( ! inputFile ) { - LOG(fatal) << "Input file " << fFileName << " doesn't exist."; - } - fclose(inputFile); - fSource = new fles::TimesliceInputArchive(fFileName.Data()); - if ( !fSource) { - LOG(fatal) << "Could not open input file."; - } - } - - for (auto it=fUnpackers.begin(); it!=fUnpackers.end(); ++it) { - LOG(info) << "Initialize " << it->second->GetName() << - " for systemID 0x" << std::hex << it->first << std::dec; - it->second->Init(); - // it->second->Register(); - } - - return kTRUE; -} - -Int_t CbmFlibFileSourceNew::ReadEvent(UInt_t) -{ - - // fTimer.Start(); - //while( fFileCounter < fInputFileList.GetSize() ) { - while (auto timeslice = fSource->get()) { - fTSCounter++; - if ( 0 == fTSCounter%10000 ) { - /* - fTimer.Stop(); - Double_t rtime = fTimer.RealTime(); - Double_t ctime = fTimer.CpuTime(); - */ - LOG(info) << "Analyse Event " << fTSCounter; - /* - LOG(info) << "Real time/100 timeslices: " << rtime << " s"; - LOG(info) << "CPU time/100 timeslices: " << ctime << " s"; - fTimer<.Start(); - */ - } - const fles::Timeslice& ts = *timeslice; - auto tsIndex = ts.index(); - if( (tsIndex != (fTSNumber+1)) &&( fTSNumber != 0) ) { - LOG(warning) << "Missed Timeslices. Old TS Number was " << fTSNumber - << " New TS Number is " << tsIndex; - } - fTSNumber=tsIndex; - for (size_t c {0}; c < ts.num_components(); c++) { - auto systemID = ts.descriptor(c, 0).sys_id; - - if(gLogger->IsLogNeeded( fair::Severity::debug )) { - PrintMicroSliceDescriptor(ts.descriptor(c, 0)); - } - - auto it=fUnpackers.find(systemID); - if (it == fUnpackers.end()) { - //LOG(fatal) << "Could not find unpacker for system id 0x" << - //std::hex << systemID << std::dec; - } else { - it->second->DoUnpack(ts, c); - } - } - return 0; - } - /* - // Check if there is another file in the list - fFileCounter += 1; - - if ( fInputFileList.GetSize() > fFileCounter ) { - delete fSource; - TObjString* tmp = - dynamic_cast<TObjString*>(fInputFileList.At(fFileCounter)); - fFileName = tmp->GetString(); - LOG(info) << "Open the Flib input file " << fFileName; - // Check if the input file exist - FILE* inputFile = fopen(fFileName.Data(), "r"); - if ( ! inputFile ) { - LOG(fatal) << "Input file " << fFileName << " doesn't exist."; - } - fclose(inputFile); - fSource = new fles::TimesliceInputArchive(fFileName.Data()); - } - */ - // } - for (auto it=fUnpackers.begin(); it!=fUnpackers.end(); ++it) { - LOG(info) << "Finish " << it->second->GetName() << - " for systemID 0x" << std::hex << it->first << std::dec; - it->second->Finish(); - // it->second->Register(); - } - return 1; // no more data; trigger end of run -} - -void CbmFlibFileSourceNew::PrintMicroSliceDescriptor(const fles::MicrosliceDescriptor& mdsc) -{ - LOG(info) << "Header ID: Ox" << std::hex << static_cast<int>(mdsc.hdr_id) - << std::dec; - LOG(info) << "Header version: Ox" << std::hex << static_cast<int>(mdsc.hdr_ver) - << std::dec; - LOG(info) << "Equipement ID: " << mdsc.eq_id; - LOG(info) << "Flags: " << mdsc.flags; - LOG(info) << "Sys ID: Ox" << std::hex << static_cast<int>(mdsc.sys_id) - << std::dec; - LOG(info) << "Sys version: Ox" << std::hex << static_cast<int>(mdsc.sys_ver) - << std::dec; - LOG(info) << "Microslice Idx: " << mdsc.idx; - LOG(info) << "Checksum: " << mdsc.crc; - LOG(info) << "Size: " << mdsc.size; - LOG(info) << "Offset: " << mdsc.offset; -} - -Bool_t CbmFlibFileSourceNew::CheckTimeslice(const fles::Timeslice& ts) -{ - if ( 0 == ts.num_components() ) { - LOG(error) << "No Component in TS " << ts.index(); - return 1; - } - LOG(info) << "Found " << ts.num_components() - << " different components in tiemeslice"; - return kTRUE; -} - -void CbmFlibFileSourceNew::Close() -{ -} - -void CbmFlibFileSourceNew::Reset() -{ - for (auto it=fUnpackers.begin(); it!=fUnpackers.end(); ++it) { - it->second->Reset(); - } -} - -ClassImp(CbmFlibFileSourceNew) diff --git a/beamtime/cern2014/CbmFlibFileSourceNew.h b/beamtime/cern2014/CbmFlibFileSourceNew.h deleted file mode 100644 index e75d927f67535a12ac270fb64fae095f89da800a..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/CbmFlibFileSourceNew.h +++ /dev/null @@ -1,86 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmFlibFileSourceNew ----- -// ----- Created 07.11.2014 by F. Uhlig ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CBMFLIBFILESOURCENEW_H -#define CBMFLIBFILESOURCENEW_H - -#include "TimesliceSource.hpp" -#include "Timeslice.hpp" -#include "MicrosliceDescriptor.hpp" -#include "Message.hpp" - -#include "FairSource.h" -#include "CbmTSUnpack.h" - -#include "TString.h" -#include "TClonesArray.h" -#include "TList.h" -#include "TObjString.h" -#include "TStopwatch.h" - -#include <memory> -#include <map> - -//class CbmDaqBuffer; - -class CbmFlibFileSourceNew : public FairSource -{ - public: - CbmFlibFileSourceNew(); - CbmFlibFileSourceNew(const CbmFlibFileSourceNew& source); - virtual ~CbmFlibFileSourceNew(); - - Bool_t Init(); - Int_t ReadEvent(UInt_t); - - Source_Type GetSourceType() {return kONLINE;} - - virtual void SetParUnpackers() {;} - - virtual Bool_t InitUnpackers() {return kTRUE;} - - virtual Bool_t ReInitUnpackers() {return kTRUE;} - - void Close(); - void Reset(); - - void SetFileName(TString name) { fFileName = name; fInputFileList.Add(new TObjString(name));} - void SetHostName(TString name) { fHost = name; } - void SetPortNumber(Int_t port) { fPort = port; } - - void AddUnpacker(CbmTSUnpack* unpacker, Int_t id) - { fUnpackers.insert ( std::pair<Int_t,CbmTSUnpack*>(id,unpacker) ); } - - void AddFile(const char * name) { - fInputFileList.Add(new TObjString(name)); - } - - private: - - TString fFileName; - TList fInputFileList; ///< List of input files - Int_t fFileCounter; - TString fHost; - Int_t fPort; - - std::map<Int_t, CbmTSUnpack*> fUnpackers; - - UInt_t fTSNumber; - UInt_t fTSCounter; - TStopwatch fTimer; - - fles::TimesliceSource* fSource; //! - Bool_t CheckTimeslice(const fles::Timeslice& ts); - void PrintMicroSliceDescriptor(const fles::MicrosliceDescriptor& mdsc); - - CbmFlibFileSourceNew operator=(const CbmFlibFileSourceNew&); - - ClassDef(CbmFlibFileSourceNew, 1) -}; - - -#endif diff --git a/beamtime/cern2014/CbmNxFlibFileSource.cxx b/beamtime/cern2014/CbmNxFlibFileSource.cxx deleted file mode 100644 index 1363bb78fab97ce3ece36a60811f6b33162137fc..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/CbmNxFlibFileSource.cxx +++ /dev/null @@ -1,273 +0,0 @@ -#include "CbmNxFlibFileSource.h" -#include "CbmNxyterRawMessage.h" - -#include "TimesliceInputArchive.hpp" -#include "Timeslice.hpp" -#include "MicrosliceContents.hpp" - -#include "TimesliceReader.hpp" - -#include "FairLogger.h" -#include "FairRootManager.h" - -#include "TClonesArray.h" - -#include <iostream> -#include <fstream> - -#define VERBOSE - -struct DTM_header -{ - uint8_t packet_length; - uint8_t packet_counter; - uint16_t ROC_ID; -}; - -struct hit_data -{ - uint8_t MessageType; // message type: typ. hit (01) or epoch (02) - uint8_t NxNumber; // nxyter number - uint8_t NxLtxMsb; // ROC TS MSBs - uint16_t NxTs; // timestamp value from nxyter - uint8_t NxChNum; // channel number - uint16_t NxAdcValue; // ADC value - bool NxPileUp; // pileup flag - bool NxOverflow; // overflow flag - bool NxLastEpoch; // last epoch flag - - void Dump() { - printf("MessageType=%02X, NxNumber=%02X, NxLtxMsb=%02X, NxTs=%04X, NxChNum=%02X, NxAdcValue=%04X, NxPileUp=%d, NxOverflow=%d, NxLastEpoch=%d\n", - MessageType, NxNumber, NxLtxMsb, NxTs, NxChNum, - NxAdcValue, NxPileUp, NxOverflow, NxLastEpoch); - } -}; - -CbmNxFlibFileSource::CbmNxFlibFileSource() - : FairSource(), - fFileName(""), - fCurrEpoch(0), - fNxyterRaw(new TClonesArray("CbmNxyterRawMessage", 10)), - fSource(NULL) -{ -} - -CbmNxFlibFileSource::CbmNxFlibFileSource(const CbmNxFlibFileSource& source) - : FairSource(source), - fFileName(""), - fCurrEpoch(0), - fNxyterRaw(NULL), - fSource(NULL) -{ -} - - -CbmNxFlibFileSource::~CbmNxFlibFileSource() -{ -} - - -Bool_t CbmNxFlibFileSource::Init() -{ - LOG(info) << "Open the Flib input file"; - if ( 0 == fFileName.Length() ) { - LOG(fatal) << "No input file defined."; - } else { - // Check if the input file exist - FILE* inputFile = fopen(fFileName.Data(), "r"); - if ( ! inputFile ) { - LOG(fatal) << "Input file " << fFileName << " doesn't exist."; - } - fclose(inputFile); - // Open the input file - fSource = new fles::TimesliceInputArchive(fFileName.Data()); - //fSource.reset(new fles::TimesliceInputArchive(fFileName.Data())); - - } - if ( !fSource) { - LOG(fatal) << "Could not open input file."; - } - - FairRootManager* ioman = FairRootManager::Instance(); - ioman->Register("NxyterRawMessage", "nXYTER raw data", fNxyterRaw, kTRUE); - - return kTRUE; - -} - -Int_t CbmNxFlibFileSource::ReadEvent() -{ - fNxyterRaw->Clear(); - - while (auto timeslice = fSource->get()) { - const fles::Timeslice& ts = *timeslice; - for (size_t c {0}; c < ts.num_components(); c++) { - auto systemID = ts.descriptor(c, 0).sys_id; - - PrintMicroSliceDescriptor(ts.descriptor(c, 0)); - - switch (systemID) { - case 0x10: - LOG(info) << "It seems to be nXYTER data."; - UnpackNxyterCbmNetMessage(ts, c); - break; - } - - } - return 0; - } - - return 1; // no more data; trigger end of run -} - -void CbmNxFlibFileSource::PrintMicroSliceDescriptor(const fles::MicrosliceDescriptor& mdsc) -{ - LOG(info) << "Header ID: Ox" << std::hex << static_cast<int>(mdsc.hdr_id); - LOG(info) << "Header version: Ox" << std::hex << static_cast<int>(mdsc.hdr_ver) - << std::dec; - LOG(info) << "Equipement ID: " << mdsc.eq_id; - LOG(info) << "Flags: " << mdsc.flags; - LOG(info) << "Sys ID: Ox" << std::hex << static_cast<int>(mdsc.sys_id); - LOG(info) << "Sys version: Ox" << std::hex << static_cast<int>(mdsc.sys_ver) - << std::dec; - LOG(info) << "Microslice Idx: " << mdsc.idx; - LOG(info) << "Checksum: " << mdsc.crc; - LOG(info) << "Size: " << mdsc.size; - LOG(info) << "Offset: " << mdsc.offset; -} - - - -void CbmNxFlibFileSource::UnpackNxyterCbmNetMessage(const fles::Timeslice& ts, size_t component) -{ - Int_t counter=0; //TODO was ist das??? - - DTM_header cur_DTM_header; - hit_data cur_hit_data; - - for (size_t m = 0; m < ts.num_microslices(component); ++m) { - // iterate over microslice - auto msDescriptor = ts.descriptor(component, m); - const uint8_t* msContent = reinterpret_cast<const uint8_t*>(ts.content(component, m)); - - uint32_t offset = 16; - uint32_t local_offset = 0; - const uint8_t* msContent_shifted; - int padding; - - // Loop throught the data of one microslice - while (offset < msDescriptor.size) { - msContent_shifted = &msContent[offset]; - - // Extract DTM header info - cur_DTM_header.packet_length = msContent_shifted[0]; - cur_DTM_header.packet_counter = msContent_shifted[1]; - const uint16_t* ROC_ID_pointer = reinterpret_cast<const uint16_t*>(&msContent_shifted[2]); - cur_DTM_header.ROC_ID = *ROC_ID_pointer; - - #ifdef VERBOSE - printf ("pack_len=0x%02X, pack_cnt=0x%02X, ROC=0x%04X\n", - cur_DTM_header.packet_length, cur_DTM_header.packet_counter, cur_DTM_header.ROC_ID); - #endif - - local_offset = 4; - while (local_offset < static_cast<uint32_t>(cur_DTM_header.packet_length*2+4)) { - - cur_hit_data.MessageType = (msContent_shifted[local_offset+5] >> 0) & 0x0F; // 1 byte - - if (cur_hit_data.MessageType == 1) // hit - { - cur_hit_data.NxNumber = (msContent_shifted[local_offset+5] >> 6) & 0x03; // 1 byte - cur_hit_data.NxLtxMsb = (msContent_shifted[local_offset+4] >> 0) & 0x07; // 1 byte - - uint16_t topTimestampVal =((msContent_shifted[local_offset+2] >> 0) & 0x0001) * 0x2000; // 2 bytes - uint16_t midTimestampVal =((msContent_shifted[local_offset+3] >> 0) ) * 0x0020; // 2 bytes - uint16_t lowTimestampVal = (msContent_shifted[local_offset+4] >> 3) & 0x001F; // 2 bytes - cur_hit_data.NxTs = topTimestampVal + midTimestampVal + lowTimestampVal; // 2 bytes - - cur_hit_data.NxChNum = (msContent_shifted[local_offset+2] >> 1) & 0x7F; // 1 byte - - uint16_t highADCval =((msContent_shifted[local_offset+0] >> 0) & 0x001F) * 0x0080; // 2 bytes - uint16_t lowADCval = (msContent_shifted[local_offset+1] >> 1) & 0x007F; // 2 bytes - cur_hit_data.NxAdcValue = highADCval + lowADCval; // 2 bytes - - cur_hit_data.NxPileUp = (msContent_shifted[local_offset+0] >> 5) & 0x01; // 1 bit - cur_hit_data.NxOverflow = (msContent_shifted[local_offset+0] >> 6) & 0x01; // 1 bit - cur_hit_data.NxLastEpoch = (msContent_shifted[local_offset+0] >> 7) & 0x01; // 1 bit - - #ifdef VERBOSE - printf("%02X%02X%02X%02X%02X%02X\t", msContent_shifted[local_offset], msContent_shifted[local_offset+1], - msContent_shifted[local_offset+2], msContent_shifted[local_offset+3], - msContent_shifted[local_offset+4], msContent_shifted[local_offset+5]); - cur_hit_data.Dump(); - #endif - - new( (*fNxyterRaw)[counter] ) - CbmNxyterRawMessage(msDescriptor.eq_id, - cur_DTM_header.ROC_ID*4 + cur_hit_data.NxNumber, //TODO check - cur_hit_data.NxChNum, - fCurrEpoch - cur_hit_data.NxLastEpoch, // note the trick - cur_hit_data.NxTs, - cur_hit_data.NxAdcValue, - cur_hit_data.NxLastEpoch); - ++counter; - } else if (cur_hit_data.MessageType == 2) { // epoch counter - - uint32_t topEpochByte = msContent_shifted[local_offset+1] * 0x01000000; - uint32_t higEpochByte = msContent_shifted[local_offset+2] * 0x00010000; - uint32_t midEpochByte = msContent_shifted[local_offset+3] * 0x00000100; - uint32_t lowEpochByte = msContent_shifted[local_offset+4]; - - fCurrEpoch = topEpochByte + higEpochByte + midEpochByte + lowEpochByte; - #ifdef VERBOSE - printf("epoch: %02X%02X%02X%02X%02X%02X:\t\t%d\n", msContent_shifted[local_offset], msContent_shifted[local_offset+1], - msContent_shifted[local_offset+2], msContent_shifted[local_offset+3], - msContent_shifted[local_offset+4], msContent_shifted[local_offset+5], - fCurrEpoch); - #endif - - } - - local_offset += 6; // next hit or epoch marker - } - - #ifdef VERBOSE - printf ("\n"); - #endif - - // add 4 - DTM header size - offset += static_cast<uint32_t>(cur_DTM_header.packet_length * 2+4); - // shift some more bytes to fit the CbmNet package size - if ((padding = offset % 8) > 0) offset += (8-padding); - - } - - #ifdef VERBOSE - printf ("\n"); - #endif - - } - -} - -Bool_t CbmNxFlibFileSource::CheckTimeslice(const fles::Timeslice& ts) -{ - if ( 0 == ts.num_components() ) { - LOG(error) << "No Component in TS " << ts.index(); - return 1; - } - LOG(info) << "Found " << ts.num_components() - << " different components in tiemeslice"; - return kTRUE; -} - -void CbmNxFlibFileSource::Close() -{ -} - -void CbmNxFlibFileSource::Reset() -{ -} - - -ClassImp(CbmNxFlibFileSource) diff --git a/beamtime/cern2014/CbmNxFlibFileSource.h b/beamtime/cern2014/CbmNxFlibFileSource.h deleted file mode 100644 index a543df2a0987bf19bf2ec992a75bb46bdbb984eb..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/CbmNxFlibFileSource.h +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef CBMNXFLIBFILESOURCE_H -#define CBMNXFLIBFILESOURCE_H - -#include "TimesliceSource.hpp" -#include "Timeslice.hpp" -#include "MicrosliceDescriptor.hpp" -#include "Message.hpp" - -#include "FairSource.h" - -#include "TString.h" -#include "TClonesArray.h" - -#include <memory> - - -class CbmNxFlibFileSource : public FairSource -{ - public: - CbmNxFlibFileSource(); - CbmNxFlibFileSource(const CbmNxFlibFileSource& source); - virtual ~CbmNxFlibFileSource(); - - Bool_t Init(); - Int_t ReadEvent(); - void Close(); - void Reset(); - - void SetFileName(TString name) { fFileName = name; } - - private: - - TString fFileName; - - Int_t fCurrEpoch; // Current epoch (first epoch in the stream initialises the variable sith sensible value) - - // --- Output arrays - TClonesArray* fNxyterRaw; ///< Output array of CbmNxyterRawMessage - - fles::TimesliceSource* fSource; //! - Bool_t CheckTimeslice(const fles::Timeslice& ts); - void UnpackNxyterCbmNetMessage(const fles::Timeslice& ts, size_t component); - void PrintMicroSliceDescriptor(const fles::MicrosliceDescriptor& mdsc); - - CbmNxFlibFileSource operator=(const CbmNxFlibFileSource&); - - ClassDef(CbmNxFlibFileSource, 1) -}; - - -#endif // CBMNXFLIBFILESOURCE_H diff --git a/beamtime/cern2014/get4/CbmGet4EpochBuffer.cxx b/beamtime/cern2014/get4/CbmGet4EpochBuffer.cxx deleted file mode 100644 index 3b4d772c8ecbdea77df8e91530899f76e3c3cd3e..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/get4/CbmGet4EpochBuffer.cxx +++ /dev/null @@ -1,157 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmGet4EpochBuffer ----- -// ----- Created 24.02.2015 by ----- -// ----- P.-A. Loizeau ----- -// ----- ----- -// ----------------------------------------------------------------------------- - - -#include <iostream> -#include <iomanip> - -#include "TString.h" - -#include "FairLogger.h" - -#include "CbmGet4EpochBuffer.h" - -/* - * TODO: - * 1) Find proper default values for fuBufferMaxSize, fuBufferMaxEpochSpread - * and fuBufferHighWater - */ - -// ----- Initialization of static variables ------------------------------ -CbmGet4EpochBuffer* CbmGet4EpochBuffer::fgInstance = NULL; -// --------------------------------------------------------------------------- - -// ----- Constructor ----------------------------------------------------- -CbmGet4EpochBuffer::CbmGet4EpochBuffer() : - fData(), - fuBufferMaxSize(200), - fuBufferMaxEpochSpread(100), - fuBufferHighWater(160) -{ - LOG(info) << "CbmGet4EpochBuffer::CbmGet4EpochBuffer = Starting epoch buffer with: "; - LOG(info) << fuBufferHighWater << " stored epochs for buffer high water "; - LOG(info) << fuBufferMaxSize << " stored epochs for maximum buffer storage "; - LOG(info) << fuBufferMaxEpochSpread << " for epoch spread rejection when maximum reached "; - PrintStatus(); -} -// --------------------------------------------------------------------------- - -// ----- Destructor ------------------------------------------------------ -CbmGet4EpochBuffer::~CbmGet4EpochBuffer() -{ -} -// --------------------------------------------------------------------------- - -// ----- Access to next epoch --------------------------------------------- -std::multiset< get4v1x::FullMessage >* CbmGet4EpochBuffer::GetNextEpoch() -{ - // --- Check for empty buffer - if( !fData.size() ) - return NULL; - - // --- Get data from buffer - std::multiset< get4v1x::FullMessage >* multiset = fData.front(); - fData.pop_front(); - return multiset; - -} -// --------------------------------------------------------------------------- - -// ----- Insert Epoch into buffer ----------------------------------------- -Int_t CbmGet4EpochBuffer::InsertEpoch( std::multiset< get4v1x::FullMessage >* epochCont ) -{ - - if( !epochCont ) - LOG(fatal)<<"CbmGet4EpochBuffer:InsertEpoch = Invalid epoch multiset pointer"; -/* - if( 100000 < epochCont->size() ) - LOG(info) << "CbmGet4EpochBuffer::InsertEpoch = Inserting epoch multiset, epoch idx " - << ( epochCont->begin() )->getExtendedEpoch() - << " New buffer size: " << fData.size() - << " First epoch: "<< GetEpochFirst() - << " Last epoch: "<< GetEpochLast(); -*/ - if( 0 < epochCont->size() ) - { - fData.push_back(epochCont); - LOG(debug2) << "CbmGet4EpochBuffer::InsertEpoch = Inserting epoch multiset, epoch idx " -// LOG(info) << "CbmGet4EpochBuffer::InsertEpoch = Inserting epoch multiset, epoch idx " - << ( epochCont->begin() )->getExtendedEpoch() - << " New buffer size: " << fData.size() - << " First epoch: "<< GetEpochFirst() - << " Last epoch: "<< GetEpochLast(); - - if( fuBufferHighWater == fData.size() ) - { - LOG(info) << "CbmGet4EpochBuffer::InsertEpoch = High water mark reached, " - << fuBufferHighWater << "/" << fuBufferMaxSize - << " epoch stored in buffer."; - LOG(info) << " If MAX reached, epoch older than " - << fuBufferMaxEpochSpread << " epoch from the new one will be dropped!"; - } // if( fuBufferHighWater == fData.size() ) - if( fuBufferMaxSize <= fData.size() ) - { - LOG(warning) << "CbmGet4EpochBuffer::InsertEpoch = Max buffer size reached. " - << "Now dropping all epochs more than " << fuBufferMaxEpochSpread - << " epochs older than the newly inserted one!!!"; - - // now drop all epochs too old - // WARNING: in case of epoch index cycle (should never happen but well...) the - // "older" epoch is also thrown out - // Loop stop at least when reaching the newly inserted epoch - while( ( ((fData.front())->begin() )->getExtendedEpoch() + fuBufferMaxEpochSpread - < ( epochCont->begin() )->getExtendedEpoch() ) || - ( ( ( epochCont->begin() )->getExtendedEpoch() ) - < ((fData.front())->begin() )->getExtendedEpoch() ) - ) - { - // Throw out the epoch: clear multiset, delete multiset, pop multiset pointer - (fData.front())->clear(); - delete (fData.front()); - fData.pop_front(); - } // while first epoch has to be thrown out - } // if( fuBufferMaxSize <= fData.size() ) - } // if( 0 < epochCont->size() ) - else - { - LOG(debug2) << "CbmGet4EpochBuffer: Trying to insert an empty epoch multiset => do nothing "; -// LOG(info) << "CbmGet4EpochBuffer: Trying to insert an empty epoch multiset => do nothing "; - epochCont->clear(); - delete epochCont; - } // else of if( 0 < epochCont->size() ) - - return fData.size(); -} -// --------------------------------------------------------------------------- - - - -// ----- Instance -------------------------------------------------------- -CbmGet4EpochBuffer* CbmGet4EpochBuffer::Instance() { - if ( ! fgInstance ) fgInstance = new CbmGet4EpochBuffer(); - return fgInstance; -} -// --------------------------------------------------------------------------- - - - -// ----- Print status ---------------------------------------------------- -void CbmGet4EpochBuffer::PrintStatus() const { - Int_t size = GetSize(); - LOG(info) << "CbmGet4EpochBuffer: Status "; - if( !size ) - { - LOG(info) << "empty"; - return; - } // if( !size ) - LOG(info) << GetSize() << " epoch multisets from epoch " - << Form("%9llu to epoch ", GetEpochFirst() ) - << Form("%9llu ", GetEpochLast() ); -} -// --------------------------------------------------------------------------- - diff --git a/beamtime/cern2014/get4/CbmGet4EpochBuffer.h b/beamtime/cern2014/get4/CbmGet4EpochBuffer.h deleted file mode 100644 index 79286f99064ac2bed9ab186cf2b6128a32cb23ea..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/get4/CbmGet4EpochBuffer.h +++ /dev/null @@ -1,147 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmGet4EpochBuffer ----- -// ----- Created 24.02.2015 by ----- -// ----- P.-A. Loizeau ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CBMGET4EPOCHBUFFER_H -#define CBMGET4EPOCHBUFFER_H 1 - -#include <deque> -#include <set> - -#include "CbmGet4v1xHackDef.h" - -/** @class CbmGet4EpochBuffer - ** @author P.-A. Loizeau - ** @date 24 February 2015 - ** @brief Singleton buffer class for CBM TOF GET4 raw data organized in epochs - ** - ** The CbmGet4EpochBuffer stores GET4 raw data already ordered - ** in epochs (multisets) transiently. - ** Full time sorted epoch multisets can be sent to the buffer by - ** the method InsertEpoch. - ** They can be retrieved by GetNextEpoch, which delivers a - ** pointer to the multiset of time sorted data. - ** The standard deque is used to approximate a FIFO behavior. - ** - ** There is only one buffer stream. - ** - ** The buffer handles objects only by pointer, i.e. the multisets have - ** to be instantiated by the sending task (unpacker) and - ** deleted by the receiving class (Event Builder). - **/ -class CbmGet4EpochBuffer -{ - public: - - /** Destructor **/ - ~CbmGet4EpochBuffer(); - - /** Set the maximal number of epochs that the buffer is allowed to store - ** @param uBuffMaxSz buffer maximal size in epochs - **/ - void SetBufferMaxSize( UInt_t uBuffMaxSz = 200 ) { fuBufferMaxSize = uBuffMaxSz;}; - - /** Set the maximal spread in epoch number above which epochs are dropped in case - ** the maximal number of stored epochs is reached - ** @param ulBuffMaxEpSprd epoch number spread limit for event dropping - **/ - void SetBufferDropEpochSpread( ULong64_t ulBuffMaxEpSprd = 100 ) - { fuBufferMaxEpochSpread = ulBuffMaxEpSprd;}; - - /** High water mark: when this number of stored epochs is reached at insertion, - ** a message is printed to warn the user that the maximal limit of stored events - ** is close. - ** @param uBuffHW buffer high water level in epochs - **/ - void SetBufferHighWater( UInt_t uBuffHW = 180 ) { fuBufferHighWater = uBuffHW;}; - - /** Pointer to next epoch container - ** @return pointer to multiset containing time ordered data of this single epoch - ** - ** A NULL pointer will be returned if the buffer is empty. - **/ - std::multiset< get4v1x::FullMessage >* GetNextEpoch(); - - - /** Current buffer size - ** @return number of objects in buffer - **/ - Int_t GetSize() const { return fData.size(); } - - /** Get first Epoch index **/ - ULong64_t GetEpochFirst() const { - if( !GetSize() ) return 0; - return ( ( fData.front() )->begin() )->getExtendedEpoch(); - } - - - /** Get last Epoch index **/ - ULong64_t GetEpochLast() const { - if ( ! GetSize() ) return 0; - return ( ( fData.back() )->begin() )->getExtendedEpoch(); - } - - /** Insert data into the buffer - ** @param epochCont pointer to multiset containing the epoch to be inserted - ** @return number of objects in buffer - **/ - Int_t InsertEpoch( std::multiset< get4v1x::FullMessage >* epochCont); - - - /** Access to singleton instance - ** @return pointer to instance - **/ - static CbmGet4EpochBuffer* Instance(); - - - /** Print buffer status **/ - void PrintStatus() const; - - - private: - - /** Buffer management - ** Store pointer of time ordered data multiset for get4 epoch. - **/ - std::deque< std::multiset< get4v1x::FullMessage >* > fData; - - - /** Pointer to singleton instance **/ - static CbmGet4EpochBuffer* fgInstance; - - /** Limit in number of stored epochs **/ - UInt_t fuBufferMaxSize; - - /** Border for throwing out older epochs (FIFO) - ** If the buffer limit is reached, all epoch older - ** than this limit relative to the new epoch to be - ** inserted are thrown out. - ** Warning are printed out! - **/ - ULong64_t fuBufferMaxEpochSpread; - - /** High water mark for buffer full. - ** Info message is printed out when reached. - **/ - UInt_t fuBufferHighWater; - - /** Default constructor - ** Declared private to prevent instantiation. - **/ - CbmGet4EpochBuffer(); - - - /** Copy constructor. Defined private to prevent usage. **/ - CbmGet4EpochBuffer(const CbmGet4EpochBuffer&); - - - /** Assignment operator. Defined private to prevent usage. **/ - CbmGet4EpochBuffer& operator=(const CbmGet4EpochBuffer&); - -}; - -#endif /* CBMGET4EPOCHBUFFER_H */ diff --git a/beamtime/cern2014/get4/CbmGet4EventBuffer.cxx b/beamtime/cern2014/get4/CbmGet4EventBuffer.cxx deleted file mode 100644 index ff68faa00ff7dd2f88476f22bfc66b41590c5d7b..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/get4/CbmGet4EventBuffer.cxx +++ /dev/null @@ -1,272 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmGet4EventBuffer ----- -// ----- Created 24.02.2015 by ----- -// ----- P.-A. Loizeau ----- -// ----- ----- -// ----------------------------------------------------------------------------- - - -#include <iostream> -#include <iomanip> - -#include "TString.h" - -#include "FairLogger.h" - -#include "CbmGet4EventBuffer.h" - -/* - * TODO: - * 1) Find proper default values for fuBufferMaxSize, fuBufferMaxEventSpread - * and fuBufferHighWater - */ - -// ----- Initialization of static variables ------------------------------ -CbmGet4EventBuffer* CbmGet4EventBuffer::fgInstance = NULL; -// --------------------------------------------------------------------------- - -// ----- Constructor ----------------------------------------------------- -CbmGet4EventBuffer::CbmGet4EventBuffer() : - fData(), - fuBufferMaxSize(500), - fuBufferMaxEventSpread(100), - fuBufferHighWater(400) -{ - fData.clear(); - LOG(info) << "CbmGet4EpochBuffer::CbmGet4EpochBuffer = Starting event buffer with: "; - LOG(info) << fuBufferHighWater << " stored events for buffer high water "; - LOG(info) << fuBufferMaxSize << " stored events for maximum buffer storage "; - LOG(info) << fuBufferMaxEventSpread << " for events spread rejection when maximum reached "; - PrintStatus(); -} -// --------------------------------------------------------------------------- - -// ----- Destructor ------------------------------------------------------ -CbmGet4EventBuffer::~CbmGet4EventBuffer() -{ -} -// --------------------------------------------------------------------------- - -// ----- Access to next Event --------------------------------------------- -std::pair< CbmGet4EventHeader, std::vector< get4v1x::FullMessage >* > - CbmGet4EventBuffer::GetNextEvent() -{ - // --- Check for empty buffer - if( !fData.size() ) -// return std::make_pair( 0, NULL); - return std::make_pair< CbmGet4EventHeader, std::vector< get4v1x::FullMessage >* >(0, NULL); - - // --- Get data from buffer - std::pair< CbmGet4EventHeader, std::vector< get4v1x::FullMessage >* > event = - fData.front(); - fData.pop_front(); - return event; - -} -// --------------------------------------------------------------------------- - -// ----- Insert Event into buffer ----------------------------------------- -Int_t CbmGet4EventBuffer::InsertEvent( ULong64_t uEventIdx, - std::vector< get4v1x::FullMessage >* eventCont ) -{ - - if( !eventCont ) - LOG(fatal)<<"CbmGet4EventBuffer::InsertEvent = invalid event vector pointer"; - - if( 0 < eventCont->size() ) - { - LOG(debug) << "CbmGet4EventBuffer::InsertEvent = Inserting event vector, event idx " - << uEventIdx; - CbmGet4EventHeader header(0); - header.fuEventIndex = uEventIdx; - std::pair< CbmGet4EventHeader, std::vector< get4v1x::FullMessage >* > event(header, eventCont); - fData.push_back(event); - - if( fuBufferHighWater == fData.size() ) - { - LOG(info) << "CbmGet4EventBuffer::InsertEvent = High water mark reached, " - << fuBufferHighWater << "/" << fuBufferMaxSize - << " event stored in buffer."; - LOG(info) << " If MAX reached, event older than " - << fuBufferMaxEventSpread << " events from the new one will be dropped!"; - } // if( fuBufferHighWater == fData.size() ) - if( fuBufferMaxSize <= fData.size() ) - { - LOG(warning) << "CbmGet4EventBuffer::InsertEvent = Max buffer size reached. " - << "Now dropping all events more than " << fuBufferMaxEventSpread - << " events older than the newly inserted one!!!"; - - // now drop all events too old - // WARNING: in case of event index cycle (should never happen but well...) the - // "older" epoch is also thrown out - // Loop stop at least when reaching the newly inserted event - while( ( ((fData.front()).first).fuEventIndex + fuBufferMaxEventSpread - < uEventIdx ) || - ( uEventIdx < ((fData.front()).first).fuEventIndex ) - ) - { - // Throw out the event: clear event vector, delete event vector, pop the pair - ((fData.front()).second)->clear(); - delete ((fData.front()).second); - fData.pop_front(); - } // while first event has to be thrown out - } // if( fuBufferMaxSize <= fData.size() ) - } // if( 0 < eventCont->size() ) - else - { - LOG(debug2) << "CbmGet4EventBuffer: Trying to insert an empty event vector => do nothing "; - } // else of if( 0 < eventCont->size() ) - - return fData.size(); -} - -Int_t CbmGet4EventBuffer::InsertEvent( ULong64_t uEventIdx, - Int_t iTrigType, ULong64_t uTrigExtEp, UInt_t uTrigTs, - std::vector< get4v1x::FullMessage >* eventCont) -{ - - if( !eventCont ) - LOG(fatal)<<"CbmGet4EventBuffer::InsertEvent = invalid event vector pointer"; - - if( 0 < eventCont->size() ) - { - LOG(debug) << "CbmGet4EventBuffer::InsertEvent = Inserting event vector, event idx " - << uEventIdx; - CbmGet4EventHeader header( uEventIdx, iTrigType, uTrigExtEp, uTrigTs); - std::pair< CbmGet4EventHeader, std::vector< get4v1x::FullMessage >* > event(header, eventCont); - fData.push_back(event); - - if( fuBufferHighWater == fData.size() ) - { - LOG(info) << "CbmGet4EventBuffer::InsertEvent = High water mark reached, " - << fuBufferHighWater << "/" << fuBufferMaxSize - << " event stored in buffer."; - LOG(info) << " If MAX reached, event older than " - << fuBufferMaxEventSpread << " events from the new one will be dropped!"; - } // if( fuBufferHighWater == fData.size() ) - if( fuBufferMaxSize <= fData.size() ) - { - LOG(warning) << "CbmGet4EventBuffer::InsertEvent = Max buffer size reached. " - << "Now dropping all events more than " << fuBufferMaxEventSpread - << " events older than the newly inserted one!!!"; - - // now drop all events too old - // WARNING: in case of event index cycle (should never happen but well...) the - // "older" epoch is also thrown out - // Loop stop at least when reaching the newly inserted event - while( ( ((fData.front()).first).fuEventIndex + fuBufferMaxEventSpread - < uEventIdx ) || - ( uEventIdx < ((fData.front()).first).fuEventIndex ) - ) - { - // Throw out the event: clear event vector, delete event vector, pop the pair - ((fData.front()).second)->clear(); - delete ((fData.front()).second); - fData.pop_front(); - } // while first event has to be thrown out - } // if( fuBufferMaxSize <= fData.size() ) - } // if( 0 < eventCont->size() ) - else - { - LOG(debug2) << "CbmGet4EventBuffer: Trying to insert an empty event vector => do nothing "; - } // else of if( 0 < eventCont->size() ) - - return fData.size(); -} - -Int_t CbmGet4EventBuffer::InsertEvent( CbmGet4EventHeader eventHdr, - std::vector< get4v1x::FullMessage >* eventCont) -{ - - if( !eventCont ) - LOG(fatal)<<"CbmGet4EventBuffer::InsertEvent = invalid event vector pointer"; - - if( 0 < eventCont->size() ) - { - LOG(debug) << "CbmGet4EventBuffer::InsertEvent = Inserting event vector, event idx " - << eventHdr.fuEventIndex; - - std::pair< CbmGet4EventHeader, std::vector< get4v1x::FullMessage >* > event(eventHdr, eventCont); - fData.push_back(event); - - if( fuBufferHighWater == fData.size() ) - { - LOG(info) << "CbmGet4EventBuffer::InsertEvent = High water mark reached, " - << fuBufferHighWater << "/" << fuBufferMaxSize - << " event stored in buffer."; - LOG(info) << " If MAX reached, event older than " - << fuBufferMaxEventSpread << " events from the new one will be dropped!"; - } // if( fuBufferHighWater == fData.size() ) - if( fuBufferMaxSize <= fData.size() ) - { - LOG(warning) << "CbmGet4EventBuffer::InsertEvent = Max buffer size reached. " - << "Now dropping all events more than " << fuBufferMaxEventSpread - << " events older than the newly inserted one!!!"; - - // now drop all events too old - // WARNING: in case of event index cycle (should never happen but well...) the - // "older" epoch is also thrown out - // Loop stop at least when reaching the newly inserted event - while( ( ((fData.front()).first).fuEventIndex + fuBufferMaxEventSpread - < eventHdr.fuEventIndex ) || - ( eventHdr.fuEventIndex < ((fData.front()).first).fuEventIndex ) - ) - { - // Throw out the event: clear event vector, delete event vector, pop the pair - ((fData.front()).second)->clear(); - delete ((fData.front()).second); - fData.pop_front(); - } // while first event has to be thrown out - } // if( fuBufferMaxSize <= fData.size() ) - } // if( 0 < eventCont->size() ) - else - { - LOG(debug2) << "CbmGet4EventBuffer: Trying to insert an empty event vector => do nothing "; - } // else of if( 0 < eventCont->size() ) - - return fData.size(); -} -// --------------------------------------------------------------------------- - -// --------------------------------------------------------------------------- -void CbmGet4EventBuffer::Clear() -{ - LOG(debug)<< "CbmGet4EventBuffer::Clear "; - while( 0 < GetSize() ) - { - // Get next Event - std::pair< CbmGet4EventHeader, std::vector< get4v1x::FullMessage >* > pEvtCont = GetNextEvent(); - if( 0 < (pEvtCont.second)->size() ) - (pEvtCont.second)->clear(); - delete (pEvtCont.second); - } // while( 0 < fOutputBuffer->GetSize() ) -} -// --------------------------------------------------------------------------- - - - -// ----- Instance -------------------------------------------------------- -CbmGet4EventBuffer* CbmGet4EventBuffer::Instance() { - if ( ! fgInstance ) fgInstance = new CbmGet4EventBuffer(); - return fgInstance; -} -// --------------------------------------------------------------------------- - - - -// ----- Print status ---------------------------------------------------- -void CbmGet4EventBuffer::PrintStatus() const { - UInt_t size = GetSize(); - LOG(info) << "CbmGet4EventBuffer: Status "; - if( !size ) - { - LOG(info) << "empty"; - return; - } // if( !size ) - LOG(info) << GetSize() << " event vectors from event " - << Form("%9llu to event ", GetEventFirst() ) - << Form("%9llu ", GetEventLast() ); -} -// --------------------------------------------------------------------------- - diff --git a/beamtime/cern2014/get4/CbmGet4EventBuffer.h b/beamtime/cern2014/get4/CbmGet4EventBuffer.h deleted file mode 100644 index 4259797f8f97012a5b7f238bd585f77192f6eecb..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/get4/CbmGet4EventBuffer.h +++ /dev/null @@ -1,194 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmGet4EventBuffer ----- -// ----- Created 24.02.2015 by ----- -// ----- P.-A. Loizeau ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CBMGET4EVENTBUFFER_H -#define CBMGET4EVENTBUFFER_H 1 - -#include <deque> -#include <vector> -//#include <utility> // for std::pair, maybe not needed - -#include "CbmGet4v1xHackDef.h" - -class CbmGet4EventHeader -{ - public: - ULong64_t fuEventIndex; - Int_t fiTriggerType; - ULong64_t fuTriggerExtEp; - UInt_t fuTriggerTs; - CbmGet4EventHeader(UInt_t uInitVal = 0): - fuEventIndex(uInitVal), - fiTriggerType(uInitVal), - fuTriggerExtEp(uInitVal), - fuTriggerTs(uInitVal) - {}; - CbmGet4EventHeader( UInt_t uEvtIdxIn, Int_t iTrigTypIn, - UInt_t uTrigExtEpIn, UInt_t uTrigTsIn): - fuEventIndex( uEvtIdxIn), - fiTriggerType( iTrigTypIn), - fuTriggerExtEp( uTrigExtEpIn), - fuTriggerTs( uTrigTsIn) - {}; -}; -/** @class CbmGet4EventBuffer - ** @author P.-A. Loizeau - ** @date 24 February 2015 - ** @brief Singleton buffer class for CBM TOF GET4 raw data organized in events - ** - ** The CbmGet4EventBuffer stores GET4 raw data already ordered - ** in event (vectors) transiently. - ** Full time sorted event vectors can be sent to the buffer by - ** the method InsertEvent. - ** They can be retrieved by GetNextEvent, which delivers a - ** pointer to the vector of time sorted data. - ** The standard deque is used to approximate a FIFO behavior. - ** - ** There is only one buffer stream. - ** - ** The buffer handles buffer objects only by pointer, i.e. the vectors have - ** to be instantiated by the sending task (unpacker) and - ** deleted by the receiving class (Event Builder). - **/ -class CbmGet4EventBuffer -{ - public: - - /** Destructor **/ - ~CbmGet4EventBuffer(); - - /** Set the maximal number of events that the buffer is allowed to store - ** @param uBuffMaxSz buffer maximal size in events - **/ - void SetBufferMaxSize( UInt_t uBuffMaxSz = 500 ) { fuBufferMaxSize = uBuffMaxSz;}; - - /** Set the maximal spread in event number above which events are dropped in case - ** the maximal number of stored events is reached - ** @param ulBuffMaxEvtSprd event number spread limit for event dropping - **/ - void SetBufferDropEventSpread( ULong64_t ulBuffMaxEvtSprd = 100 ) - { fuBufferMaxEventSpread = ulBuffMaxEvtSprd;}; - - /** High water mark: when this number of stored events is reached at insertion, - ** a message is printed to warn the user that the maximal limit of stored events - ** is close. - ** @param uBuffHW buffer high water level in events - **/ - void SetBufferHighWater( UInt_t uBuffHW = 400 ) { fuBufferHighWater = uBuffHW;}; - - /** Pointer to next epoch container - ** @return a pair of event header and pointer to vector containing time - ** ordered data of this event - ** - ** A pair (0, NULL pointer) will be returned if the buffer is empty. - **/ - std::pair< CbmGet4EventHeader, std::vector< get4v1x::FullMessage >* > GetNextEvent(); - - - /** Current buffer size - ** @return number of objects in buffer - **/ - UInt_t GetSize() const { return fData.size(); } - - /** Get first Event index **/ - ULong64_t GetEventFirst() const { - if( !GetSize() ) return 0; - return (( fData.front() ).first).fuEventIndex; - } - - - /** Get last Event index **/ - ULong64_t GetEventLast() const { - if ( ! GetSize() ) return 0; - return (( fData.back() ).first).fuEventIndex; - } - - /** Insert data into the buffer - ** @param uEventIdx event index of the event to be inserted - ** @param eventCont pointer to vector containing the event to be inserted - ** @return number of objects in buffer - **/ - Int_t InsertEvent( ULong64_t uEventIdx, std::vector< get4v1x::FullMessage >* eventCont); - - /** Insert data into the buffer - ** @param uEventIdx event index of the event to be inserted - ** @param iTrigType Trigger type of the event to be inserted - ** @param uTrigExtEp Trigger extended epoch of the event to be inserted - ** @param uTrigTs Trigger timestamp of the event to be inserted - ** @param eventCont pointer to vector containing the event to be inserted - ** @return number of objects in buffer - **/ - Int_t InsertEvent( ULong64_t uEventIdx, Int_t iTrigType, ULong64_t uTrigExtEp, UInt_t uTrigTs, - std::vector< get4v1x::FullMessage >* eventCont); - - /** Insert data into the buffer - ** @param eventHdr event header containing the index of the event and its trigger info - ** @param eventCont pointer to vector containing the event to be inserted - ** @return number of objects in buffer - **/ - Int_t InsertEvent( CbmGet4EventHeader eventHdr, std::vector< get4v1x::FullMessage >* eventCont); - - - /** Clear buffer and delete corresponding events - **/ - void Clear(); - - /** Access to singleton instance - ** @return pointer to instance - **/ - static CbmGet4EventBuffer* Instance(); - - - /** Print buffer status **/ - void PrintStatus() const; - - - private: - - /** Buffer management - ** Store pairs of event header and pointer of time ordered data vector for get4 event. - **/ - std::deque< std::pair< CbmGet4EventHeader, std::vector< get4v1x::FullMessage >* > > fData; - - - /** Pointer to singleton instance **/ - static CbmGet4EventBuffer* fgInstance; - - /** Limit in number of stored events **/ - UInt_t fuBufferMaxSize; - - /** Border for throwing out older events (FIFO) - ** If the buffer limit is reached, all events older - ** than this limit relative to the new event to be - ** inserted are thrown out. - ** Warning message are be printed out! - **/ - ULong64_t fuBufferMaxEventSpread; - - /** High water mark for buffer full. - ** Info message is printed out when reached. - **/ - UInt_t fuBufferHighWater; - - - /** Default constructor - ** Declared private to prevent instantiation. - **/ - CbmGet4EventBuffer(); - - - /** Copy constructor. Defined private to prevent usage. **/ - CbmGet4EventBuffer(const CbmGet4EventBuffer&); - - - /** Assignment operator. Defined private to prevent usage. **/ - CbmGet4EventBuffer& operator=(const CbmGet4EventBuffer&); - -}; - -#endif /* CBMGET4EVENTBUFFER_H */ diff --git a/beamtime/cern2014/get4/CbmGet4EventBuilder.cxx b/beamtime/cern2014/get4/CbmGet4EventBuilder.cxx deleted file mode 100644 index 3c21a382669b8d27f2065ac59fea3b5bca7bc3f8..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/get4/CbmGet4EventBuilder.cxx +++ /dev/null @@ -1,855 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmGet4EventBuilder ----- -// ----- Created 23.02.2015 by ----- -// ----- P.-A. Loizeau ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#include "CbmGet4EventBuilder.h" - -// TOF Classes and includes -#include "CbmGet4EpochBuffer.h" -#include "CbmGet4EventBuffer.h" -#include "CbmGet4v1xDef.h" - -// CBMroot classes and includes - -// FAIR classes and includes -#include "FairLogger.h" - -// ROOT Classes and includes -#include "TH1.h" -#include "TROOT.h" -#include <TFile.h> -#ifdef MUL_TRIGG_DEBUG - #include "TH2.h" -#endif // MUL_TRIGG_DEBUG - -// C++ std Classes and includes -#ifdef MUL_TRIGG_DEBUG - #include <iostream> - #include <limits> -#endif // MUL_TRIGG_DEBUG - -/***************** Hit multiplicity trigger ******************/ -const Int_t kiBinSizeClkCycle = 10; // Bin size for Multi histo, in clocks -/*************************************************************/ - -/*************** Channel coincidence trigger *****************/ -// Constants for channels coincidence trigger -//const Int_t kiMaxNbTriggers = 16; -//const Int_t kiMaxNbChPerTrig = 4; -/*************************************************************/ - -//___________________________________________________________________ -// - -// ------------------------------------------------------------------ -CbmGet4EventBuilder::CbmGet4EventBuilder() - : FairTask("CbmGet4EventBuilder"), - fuInputEvents(0), - fuOutputEvents(0), - fuInputEpochs(0), - fInputBuffer(NULL), - fOutputBuffer(NULL), - fpEpoch{NULL, NULL, NULL}, - fiCurrentEpoch(-1), - fdMaxTimePerLoopS(0.0), - fStart(), - fStop(), - fsHistoFilename("./get4EventBuilder.hst.root"), - fbTriggerMode(kFALSE), - fiNbTriggers(0), - fvdTrigWinNeg(), - fvdTrigWinPos(), - fvdTrigDeadtime(), - fviTrigType(), - fiEpochStartHitScan(-1), - fiIndexStartHitScan(-1), - fhHitMultiplicity(NULL), - fiMultiHistBinSz(kiBinSizeClkCycle), - fiNbBinsMultiHist(0), - fiMultiThreshold(-1), - fhMaxMulPerEpochDist(NULL), - fhEventSizeDist(NULL), -#ifdef MUL_TRIGG_DEBUG - canvasDeb(NULL), - fhMaxMulEpoch(NULL), - fhBinThrEpoch(NULL), - fhMaxEvtSizeEpoch(NULL), - fhEvtSizeEvo(NULL), -#endif // MUL_TRIGG_DEBUG - fvvuTriggerComp(), - fvdCoincWin(), - fuLastTriggerId(0), - fvvbTrigCompFound(), - fvvulTrigCompEp(), - fvvuTrigCompTs() -{ - LOG(info)<<" CbmGet4EventBuilder: Task started"; -} -CbmGet4EventBuilder::CbmGet4EventBuilder(const char* name, Int_t verbose) - : FairTask(name, verbose), - fuInputEvents(0), - fuOutputEvents(0), - fuInputEpochs(0), - fInputBuffer(NULL), - fOutputBuffer(NULL), - fpEpoch{NULL, NULL, NULL}, - fiCurrentEpoch(-1), - fdMaxTimePerLoopS(0.0), - fStart(), - fStop(), - fsHistoFilename("./get4EventBuilder.hst.root"), - fbTriggerMode(kFALSE), - fiNbTriggers(0), - fvdTrigWinNeg(), - fvdTrigWinPos(), - fvdTrigDeadtime(), - fviTrigType(), - fiEpochStartHitScan(-1), - fiIndexStartHitScan(-1), - fhHitMultiplicity(NULL), - fiMultiHistBinSz(kiBinSizeClkCycle), - fiNbBinsMultiHist(0), - fiMultiThreshold(-1), - fhMaxMulPerEpochDist(NULL), - fhEventSizeDist(NULL), -#ifdef MUL_TRIGG_DEBUG - canvasDeb(NULL), - fhMaxMulEpoch(NULL), - fhBinThrEpoch(NULL), - fhMaxEvtSizeEpoch(NULL), - fhEvtSizeEvo(NULL), -#endif // MUL_TRIGG_DEBUG - fvvuTriggerComp(), - fvdCoincWin(), - fuLastTriggerId(0), - fvvbTrigCompFound(), - fvvulTrigCompEp(), - fvvuTrigCompTs() -{ - LOG(info)<<" CbmGet4EventBuilder: Task started"; -} -// ------------------------------------------------------------------ - -// ------------------------------------------------------------------ -CbmGet4EventBuilder::~CbmGet4EventBuilder() -{ - // Destructor -#ifdef MUL_TRIGG_DEBUG - delete canvasDeb; -#endif // MUL_TRIGG_DEBUG -} -// ------------------------------------------------------------------ -/************************************************************************************/ -void CbmGet4EventBuilder::SetTriggerMode( Bool_t bTrigModeIn ) -{ - fbTriggerMode = bTrigModeIn; - - if( kFALSE == fbTriggerMode ) - { - fiNbTriggers = 1; - ResizeTriggerVectors(); - } // if( kFALSE == fbTriggerMode ) - return; -} -void CbmGet4EventBuilder::SetTriggerWinNeg( Double_t dWinNeg, Int_t iTrigger ) -{ - if( 0 <= iTrigger && iTrigger < fiNbTriggers ) - fvdTrigWinNeg[iTrigger] = dWinNeg; - else LOG(error)<<" CbmGet4EventBuilder::SetTriggerWinNeg => Trying to set the Neg trigger Win " - <<"for a non existing trigger, therefore ignored\n" - <<" Nb Triggers: "<<fiNbTriggers - <<" Attempted trigger: "<<iTrigger; -} -void CbmGet4EventBuilder::SetTriggerWinPos( Double_t dWinPos, Int_t iTrigger ) -{ - if( 0 <= iTrigger && iTrigger < fiNbTriggers ) - fvdTrigWinPos[iTrigger] = dWinPos; - else LOG(error)<<" CbmGet4EventBuilder::SetTriggerWinPos => Trying to set the Pos trigger Win " - <<"for a non existing trigger, therefore ignored\n" - <<" Nb Triggers: "<<fiNbTriggers - <<" Attempted trigger: "<<iTrigger; -} -void CbmGet4EventBuilder::SetTriggerDeadT( Double_t dDeadT, Int_t iTrigger ) -{ - if( 0 <= iTrigger && iTrigger < fiNbTriggers ) - fvdTrigDeadtime[iTrigger] = dDeadT; - else LOG(error)<<" CbmGet4EventBuilder::SetTriggerDeadT => Trying to set the trigger deadtime " - <<"for a non existing trigger, therefore ignored\n" - <<" Nb Triggers: "<<fiNbTriggers - <<" Attempted trigger: "<<iTrigger; -} -void CbmGet4EventBuilder::SetTriggerType( Int_t iType, Int_t iTrigger ) -{ - if( 0 <= iTrigger && iTrigger < fiNbTriggers ) - fviTrigType[iTrigger] = iType; - else LOG(error)<<" CbmGet4EventBuilder::SetTriggerType => Trying to set the trigger type " - <<"for a non existing trigger, therefore ignored\n" - <<" Nb Triggers: "<<fiNbTriggers - <<" Attempted trigger: "<<iTrigger; -} -void CbmGet4EventBuilder::SetNbTriggers( Int_t iNbTriggers ) -{ - - if( kFALSE == fbTriggerMode ) - { - LOG(error)<<" CbmGet4EventBuilder::SetNbTriggers => Trying to set triggers number " - <<"in multiplicity trigger mode, therefore ignored"; - return; - }// if( kFALSE == fbTriggerMode ) - - fiNbTriggers = iNbTriggers; - ResizeTriggerVectors(); -} -void CbmGet4EventBuilder::SetHistoFilename( TString sNameIn ) -{ - fsHistoFilename = sNameIn; - - LOG(info)<<" CbmGet4EventBuilder::SetHistoFilename => Histograms output file is now\n" - <<fsHistoFilename; -} -void CbmGet4EventBuilder::ResizeTriggerVectors() -{ - fvdTrigWinNeg.resize(fiNbTriggers); - fvdTrigWinPos.resize(fiNbTriggers); - fvdTrigDeadtime.resize(fiNbTriggers); - fviTrigType.resize(fiNbTriggers); - - if( kTRUE == fbTriggerMode ) - { - fvvuTriggerComp.resize(fiNbTriggers); - fvdCoincWin.resize(fiNbTriggers); - fvvbTrigCompFound.resize(fiNbTriggers); - fvvulTrigCompEp.resize(fiNbTriggers); - fvvuTrigCompTs.resize(fiNbTriggers); - } // if( kTRUE == fbTriggerMode ) - - return; -} -Int_t CbmGet4EventBuilder::PrevEpId() -{ - if( 0 < fiCurrentEpoch) - return (fiCurrentEpoch - 1); - else return (kiMaxEpochInUse - 1); -} -Int_t CbmGet4EventBuilder::CurrEpId() -{ - return fiCurrentEpoch; -} -Int_t CbmGet4EventBuilder::NextEpId() -{ - /* - if( fiCurrentEpoch + 1 < kiMaxEpochInUse) - return fiCurrentEpoch + 1; - else return fiCurrentEpoch + 1 - kiMaxEpochInUse; - */ - return (fiCurrentEpoch + 1)%kiMaxEpochInUse; -} -/************************************************************************************/ -// FairTasks inherited functions -InitStatus CbmGet4EventBuilder::Init() -{ - if( kFALSE == RegisterInputs() ) - return kFATAL; - - if( kFALSE == RegisterOutputs() ) - return kFATAL; - - if( kFALSE == CreateHistos() ) - return kFATAL; - - // Common variables initial values, mostly in case some are missed in ctor - fuInputEvents = 0; - fiCurrentEpoch = 0; - for( Int_t iEp = 0; iEp < kiMaxEpochInUse; iEp++) - fpEpoch[iEp] = NULL; - fiEpochStartHitScan = -1; - fiIndexStartHitScan = 0; - - if( kFALSE == fbTriggerMode ) - { - fiNbBinsMultiHist = get4v1x::kuCoarseCounterSize/fiMultiHistBinSz; - fhHitMultiplicity = new TH1I( "hHitMultiplicity", - "Hit multiplicity evolution within current epoch; Clock cycles [6.4 ns]; counts", - fiNbBinsMultiHist, 0, get4v1x::kuCoarseCounterSize); - fhMaxMulPerEpochDist = new TH1I( "hMaxMulPerEpochDist", - "Max multiplicity per epoch; Max Mul [hits]", - 250, 0, 250); - fhEventSizeDist = new TH1I( "hEventSizeDist", - "nb Hits per event; event size [hits]", - 250, 0, 250); -#ifdef MUL_TRIGG_DEBUG - canvasDeb = new TCanvas("canvasDeb", "Multiplicity trigger debug", 1200, 600); - canvasDeb->Divide(2); - fhMaxMulEpoch = new TH2I( "hMaxMulEpoch", - "Max multiplicity per epoch; Epoch Index mod. 1000; Epoch Index/1000; Max Mul [hits]", - 1000, 0, 1000, - 2000, 0, 2000); - fhBinThrEpoch = new TH2I( "hBinThrEpoch", - "Max multiplicity per epoch; Epoch Index mod. 1000; Epoch Index/1000; Bin gt thr", - 1000, 0, 1000, - 2000, 0, 2000); - fhMaxEvtSizeEpoch = new TH2I( "hMaxEvtSizeEpoch", - "Max event size per epoch; Epoch Index mod. 1000; Epoch Index/1000; Max event size [bin]", - 1000, 0, 1000, - 2000, 0, 2000); - fhEvtSizeEvo = new TH2I( "hEvtSizeEvo", - "Event size distribution VS epoch index; Event size [hits]; Epoch Index/1000; Counts []", - 500, 0, 500, - 2000, 0, 2000); -#endif // MUL_TRIGG_DEBUG - } // if( kFALSE == fbTriggerMode ) - else - { - - } // else of if( kFALSE == fbTriggerMode ) - - return kSUCCESS; -} - -void CbmGet4EventBuilder::Exec(Option_t* /*option*/) -{ - // Task execution - - LOG(debug)<<" CbmGet4EventBuilder => New loop"; - - // Initialize the looping time start point - fStart.Set(); - - // Prepare temp triggers variables - std::vector< Int_t > vTriggerTimes; - - // Build events from as many available closed epochs as possible - // TODO: Last epoch may not be processed, to be checked - while( 0 < fInputBuffer->GetSize() ) - { - LOG(debug2)<<" CbmGet4EventBuilder => out buffer size: "<<fOutputBuffer->GetSize(); - LOG(debug2)<<" CbmGet4EventBuilder => PrevEpId: "<<PrevEpId() - <<" Pointer "<< fpEpoch[ PrevEpId() ] ; - LOG(debug2)<<" CbmGet4EventBuilder => CurrEpId: "<<CurrEpId() - <<" Pointer "<< fpEpoch[ CurrEpId() ] ; - LOG(debug2)<<" CbmGet4EventBuilder => NextEpId: "<<NextEpId() - <<" Pointer "<< fpEpoch[ NextEpId() ] ; - - // Get next Closed Epoch - std::multiset< get4v1x::FullMessage >* pvEpCont = fInputBuffer->GetNextEpoch(); - if( NULL == pvEpCont ) - { - LOG(error)<<" CbmGet4EventBuilder => Tried to get one epoch too much!!!"; - break; - } // if( NULL == pvEpCont ) - - if( 0 == fuInputEpochs ) - { - // first epoch, store it and wait for next epoch - fpEpoch[ CurrEpId() ] = pvEpCont; - fuInputEpochs++; - continue; - } // if( 0 == fuInputEpochs ) - else if( 1 == fuInputEpochs ) - { - // second epoch, store it and process the first epoch - fpEpoch[ NextEpId() ] = pvEpCont; - } // if( 1 == fuInputEpochs ) - else - { - // Update Epoch index - fiCurrentEpoch = NextEpId(); - // remove data of old epoch buffer to be overwritten - if( NULL != fpEpoch[ NextEpId() ]) - { - if( 0 < fpEpoch[ NextEpId() ]->size() ) - fpEpoch[ NextEpId() ]->clear(); - delete fpEpoch[ NextEpId() ]; - } // if( NULL != fpEpoch[ NextEpId() ]) - // Store pointer on epoch vector for next epoch - fpEpoch[ NextEpId() ] = pvEpCont; - } // if more than 2 epochs already received - LOG(debug2)<<" CbmGet4EventBuilder => PrevEpId: "<<PrevEpId() - <<" Pointer "<< fpEpoch[ PrevEpId() ] ; - LOG(debug2)<<" CbmGet4EventBuilder => CurrEpId: "<<CurrEpId() - <<" Pointer "<< fpEpoch[ CurrEpId() ] ; - LOG(debug2)<<" CbmGet4EventBuilder => NextEpId: "<<NextEpId() - <<" Pointer "<< fpEpoch[ NextEpId() ] ; - fuInputEpochs++; - - LOG(debug)<<" CbmGet4EventBuilder => Find where to start event building"; - // Update index of epoch in which one should start scanning, counting deadtime - if( -1 < fiEpochStartHitScan ) - fiEpochStartHitScan --; - else - { - // Case where many epochs without events => not up to date - fiEpochStartHitScan = -1; - fiIndexStartHitScan = 0; - } // else of if( -1 < fiEpochStartHitScan ) - - // Just jump empty epochs: should not happen but still safer - if( fpEpoch[ CurrEpId() ]->size() < 1 ) - continue; - - // Check if Prev epoch is there - Bool_t bPrevEpThere = kTRUE; - if( NULL == fpEpoch[ PrevEpId() ] ) - bPrevEpThere = kFALSE; - else if( fpEpoch[ PrevEpId() ]->size() < 1 ) - // Just jump empty epochs: should not happen but still safer - bPrevEpThere = kFALSE; - else if( (fpEpoch[ CurrEpId() ]->begin() )->getExtendedEpoch() - 1 != - (fpEpoch[ PrevEpId() ]->begin() )->getExtendedEpoch() ) - bPrevEpThere = kFALSE; - - // Check if next epoch is there - LOG(debug2)<<" CbmGet4EventBuilder pointer => " - <<fpEpoch[ CurrEpId() ] <<"\n" - <<fpEpoch[ NextEpId() ] ; - LOG(debug2)<<" CbmGet4EventBuilder size => " - <<(fpEpoch[ CurrEpId() ]->size() ) <<"\n" - <<(fpEpoch[ NextEpId() ]->size() ) ; - LOG(debug2)<<" CbmGet4EventBuilder epoch => " - <<(fpEpoch[ CurrEpId() ]->begin() )->getExtendedEpoch() <<"\n" - <<(fpEpoch[ NextEpId() ]->begin() )->getExtendedEpoch() ; - Bool_t bNextEpThere = kTRUE; - if( NULL == fpEpoch[ NextEpId() ] ) - bNextEpThere = kFALSE; - else if( fpEpoch[ NextEpId() ]->size() < 1 ) - // Just jump empty epochs: should not happen but still safer - bNextEpThere = kFALSE; - else if( (fpEpoch[ CurrEpId() ]->begin() )->getExtendedEpoch() + 1 != - (fpEpoch[ NextEpId() ]->begin() )->getExtendedEpoch() ) - bNextEpThere = kFALSE; - - if( -1 == fiEpochStartHitScan && kFALSE == bPrevEpThere ) - { - fiEpochStartHitScan = 0; - fiIndexStartHitScan = 0; - } // if( -1 == fiEpochStartHitScan && kFALSE == bPrevEpThere ) - - // Look for trigger - if( kFALSE == fbTriggerMode ) - { - LOG(debug)<<" CbmGet4EventBuilder => Start event finding"; - // First scan Hits to fill the multiplicity histogram - for( auto itHit = fpEpoch[ CurrEpId() ]->begin(); - itHit != fpEpoch[ CurrEpId() ]->end(); ++itHit) - { -// get4v1x::FullMessage mess = *itData; // Maybe not smart to copy data => ref/pointer? - const get4v1x::FullMessage& mess = *itHit; // Attempt with reference - if( mess.isGet4Msg() ) - fhHitMultiplicity->Fill( mess.getGet4CoarseTs() ); - else if( mess.isGet4Hack32Msg() ) - // Assume only hit messages are filled in epoch buffer in 32b mode - // If crazy values, maybe add here a test on 32b message type - fhHitMultiplicity->Fill( mess.getGet4V10R32HitTs() ); - else - LOG(error)<<" CbmGet4EventBuilder => Non GET4 hit message found in epoch buffer!!! Type: " - << mess.getMessageType() - ; - } // for( auto itHit = fpEpoch[ CurrEpId() ]->begin(); itHit != fpEpoch[ CurrEpId() ]->end(); ++itHit) - - // Find bins above multiplicity threshold - for( Int_t iBin = 0; iBin < fiNbBinsMultiHist; iBin++) - if( fiMultiThreshold <= fhHitMultiplicity->GetBinContent( iBin + 1) ) - { - // => New trigger candidate - // First check if already some triggers in current epoch and if "yes", - // check if we are outside of deadtime - if( 0 < vTriggerTimes.size() ) - if( iBin*fiMultiHistBinSz - vTriggerTimes.back() < fvdTrigDeadtime[0] ) - // If within deadtime, ignore this candidate and go on with scanning - continue; - - // If out of deadtime => new trigger! => Save approx. middle of bin as trigger time! - vTriggerTimes.push_back( iBin*fiMultiHistBinSz + fiMultiHistBinSz/2 ); - } // if( fiMultiThreshold <= fhHitMultiplicity->GetBinContent( iBin + 1) ) - - ULong64_t ulEpochIdx = (fpEpoch[ CurrEpId() ]->begin() )->getExtendedEpoch(); - - // Now rescan the hits to see which ones correspond to events - UInt_t uMaxEventSzEp = 0; - // For each possible trigger, check from last possible hit to hits - // in next epoch - LOG(debug)<<" CbmGet4EventBuilder => Start event building for " - << vTriggerTimes.size() <<" event triggers"; - for( UInt_t uTrigg = 0; uTrigg < vTriggerTimes.size(); uTrigg ++) - { - LOG(debug)<<"~~~~~~~~~~~~~ CbmGet4EventBuilder => Scan hits for trigger nb " - <<uTrigg<<" over "<<vTriggerTimes.size(); - // create a new vector for this event - std::vector< get4v1x::FullMessage >* vEvent = new std::vector< get4v1x::FullMessage >; - - // Event borders - Int_t iTriggLoBorder = vTriggerTimes[uTrigg] + fvdTrigWinNeg[0]; - Int_t iTriggHiBorder = vTriggerTimes[uTrigg] + fvdTrigWinPos[0]; - Int_t iFirstHitBorder = vTriggerTimes[uTrigg] + fvdTrigDeadtime[0] + fvdTrigWinNeg[0]; - Bool_t bEventOver = kFALSE; - - LOG(debug)<<"~~~~~~~~~~~~~ Start epoch "<<fiEpochStartHitScan - <<" Start index "<<fiIndexStartHitScan; - LOG(debug)<<"~~~~~~~~~~~~~ iTriggLoBorder "<<iTriggLoBorder<<" iTriggHiBorder "<<iTriggHiBorder - <<" vTriggerTimes "<<vTriggerTimes[uTrigg] - ; - - if( -1 == fiEpochStartHitScan && kTRUE == bPrevEpThere ) - { - LOG(debug)<<" CbmGet4EventBuilder => Scan hits in previous epoch"; - Int_t iHitIndex = 0; -// for( auto itHit = fpEpoch[ PrevEpId() ]->begin() + fiIndexStartHitScan; // NOT WORKING - for( auto itHit = fpEpoch[ PrevEpId() ]->begin(); // NOT OPTIMAL - itHit != fpEpoch[ PrevEpId() ]->end(); ++itHit) - { - // NOT OPTIMAL (PAL): best would be to use an iterator for the start index - // itself, but not sure how to do this safely - if( iHitIndex < fiIndexStartHitScan) - { - iHitIndex++; - continue; - } // if( iHitIndex < fiIndexStartHitScan) - - const get4v1x::FullMessage& mess = *itHit; - - // Offset for previous epoch: -1 full epoch - Int_t iHitCoarseTime = -get4v1x::kuCoarseCounterSize; - if( mess.isGet4Msg() ) - iHitCoarseTime += mess.getGet4CoarseTs(); - else if( mess.isGet4Hack32Msg() ) - // Assume only hit messages are filled in epoch buffer in 32b mode - // If crazy values, maybe add here a test on 32b message type - iHitCoarseTime += mess.getGet4V10R32HitTs(); - else - { - LOG(error)<<" CbmGet4EventBuilder => Non GET4 hit message found in epoch buffer!!! Type: " - << mess.getMessageType() - ; - // Update Hit index - iHitIndex++; - continue; - } // Bad message type => Jump - - // Find the first possible hit for next event (or as close as possible) - if( iHitCoarseTime <= iFirstHitBorder ) - { - if( iHitIndex + 1 == static_cast<Int_t>(fpEpoch[ PrevEpId() ]->size()) ) - { - // End of epoch => first possible is first hit in current Ep - fiEpochStartHitScan = 0; - fiIndexStartHitScan = 0; - } // if( itHit + 1 == fpEpoch[ PrevEpId() ]->end() ) - else fiIndexStartHitScan = iHitIndex + 1; - } // if( iHitCoarseTime <= iFirstHitBorder ) - - if( iTriggHiBorder < iHitCoarseTime ) - { - // Passed the end of event => Stop scanning and go to next event - bEventOver = kTRUE; - break; - } // if( iTriggHiBorder < iHitCoarseTime ) - - if( iTriggLoBorder < iHitCoarseTime ) - // Hit within event borders - vEvent->push_back(*itHit); - - // Update Hit index - iHitIndex++; - } // for hits is previous epoch - LOG(debug)<<" CbmGet4EventBuilder => Done scanning hits in prvious epoch"; - } // if( -1 == fiEpochStartHitScan && kTRUE == bPrevEpThere ) - if( 0 == fiEpochStartHitScan && kFALSE == bEventOver ) - { - LOG(debug)<<" CbmGet4EventBuilder => Scan hits in current epoch"; - Int_t iHitIndex = 0; -// for( auto itHit = fpEpoch[ CurrEpId() ]->begin() + fiIndexStartHitScan; // NOT WORKING - for( auto itHit = fpEpoch[ CurrEpId() ]->begin(); // NOT OPTIMAL - itHit != fpEpoch[ CurrEpId() ]->end(); ++itHit) - { - // NOT OPTIMAL (PAL): best would be to use an iterator for the start index - // itself, but not sure how to do this safely - if( iHitIndex < fiIndexStartHitScan) - { - iHitIndex++; - continue; - } // if( iHitIndex < fiIndexStartHitScan) - - const get4v1x::FullMessage& mess = *itHit; - - // Offset for current epoch: 0 - Int_t iHitCoarseTime = 0; - if( mess.isGet4Msg() ) - iHitCoarseTime += mess.getGet4CoarseTs(); - else if( mess.isGet4Hack32Msg() ) - // Assume only hit messages are filled in epoch buffer in 32b mode - // If crazy values, maybe add here a test on 32b message type - iHitCoarseTime += mess.getGet4V10R32HitTs(); - else - { - LOG(error)<<" CbmGet4EventBuilder => Non GET4 hit message found in epoch buffer!!! Type: " - << mess.getMessageType() - ; - // Update Hit index - iHitIndex++; - continue; - } // Bad message type => Jump - - // Find the first possible hit for next event (or as close as possible) - if( iHitCoarseTime <= iFirstHitBorder ) - { - if( iHitIndex + 1 == static_cast<Int_t>(fpEpoch[ CurrEpId() ]->size()) ) - { - // End of epoch => first possible is first hit in next Ep - fiEpochStartHitScan = 1; - fiIndexStartHitScan = 0; - } // if( itHit + 1 == fpEpoch[ CurrEpId() ]->end() ) - else fiIndexStartHitScan = iHitIndex + 1; - } // if( iHitCoarseTime <= iFirstHitBorder ) - - if( iTriggHiBorder < iHitCoarseTime ) - { - // Passed the end of event => Stop scanning and go to next event - bEventOver = kTRUE; - break; - } // if( iTriggHiBorder < iHitCoarseTime ) - - if( iTriggLoBorder < iHitCoarseTime ) - // Hit within event borders - vEvent->push_back(*itHit); - - // Update Hit index - iHitIndex++; - } // for hits is current epoch - LOG(debug)<<" CbmGet4EventBuilder => Done scanning hits in current epoch"; - } // if( 0 == fiEpochStartHitScan ) - if( 1 == fiEpochStartHitScan && kTRUE == bNextEpThere && kFALSE == bEventOver ) - { - LOG(debug)<<" CbmGet4EventBuilder => Scan hits in next epoch"; - Int_t iHitIndex = 0; -// for( auto itHit = fpEpoch[ NextEpId() ]->begin() + fiIndexStartHitScan; // NOT WORKING - for( auto itHit = fpEpoch[ NextEpId() ]->begin(); // NOT OPTIMAL - itHit != fpEpoch[ NextEpId() ]->end(); ++itHit) - { - // NOT OPTIMAL (PAL): best would be to use an iterator for the start index - // itself, but not sure how to do this safely - if( iHitIndex < fiIndexStartHitScan) - { - iHitIndex++; - continue; - } // if( iHitIndex < fiIndexStartHitScan) - - const get4v1x::FullMessage& mess = *itHit; - - // Offset for next epoch: +1 full epoch - Int_t iHitCoarseTime = get4v1x::kuCoarseCounterSize; - if( mess.isGet4Msg() ) - iHitCoarseTime += mess.getGet4CoarseTs(); - else if( mess.isGet4Hack32Msg() ) - // Assume only hit messages are filled in epoch buffer in 32b mode - // If crazy values, maybe add here a test on 32b message type - iHitCoarseTime += mess.getGet4V10R32HitTs(); - else - { - LOG(error)<<" CbmGet4EventBuilder => Non GET4 hit message found in epoch buffer!!! Type: " - << mess.getMessageType() - ; - // Update Hit index - iHitIndex++; - continue; - } // Bad message type => Jump - - // Find the first possible hit for next event (or as close as possible) - if( iHitCoarseTime <= iFirstHitBorder ) - { - if( iHitIndex + 1 == static_cast<Int_t>(fpEpoch[ NextEpId() ]->size()) ) - { - // End of epoch => first possible is first hit in over next Ep - // Case should be impossible but as crazy user can try to set - // a deadtime bigger than an epoch, check in case - fiEpochStartHitScan = 2; - fiIndexStartHitScan = 0; - } // if( itHit + 1 == fpEpoch[ NextEpId() ]->end() ) - else fiIndexStartHitScan = iHitIndex + 1; - } // if( iHitCoarseTime <= iFirstHitBorder ) - - if( iTriggHiBorder < iHitCoarseTime ) - // Passed the end of event => Stop scanning and go to next event - break; - - if( iTriggLoBorder < iHitCoarseTime ) - // Hit within event borders - vEvent->push_back(*itHit); - - // Update Hit index - iHitIndex++; - } // for hits is next epoch - LOG(debug)<<" CbmGet4EventBuilder => Done scanning hits in next epoch"; - } // if( 1 == fiEpochStartHitScan ) - - fhEventSizeDist->Fill( vEvent->size() ); - if( uMaxEventSzEp < vEvent->size() ) - uMaxEventSzEp = vEvent->size(); -#ifdef MUL_TRIGG_DEBUG - fhEvtSizeEvo->Fill( vEvent->size(), ulEpochIdx/1000 ); -#endif // MUL_TRIGG_DEBUG - - if( 0 < vEvent->size() ) - { - // Not empty => push to buffer - // Trigger index for this simple multiplicity trigger: -1 or -Threshold? - fOutputBuffer->InsertEvent( fuOutputEvents, -1, ulEpochIdx, vTriggerTimes[uTrigg], vEvent ); - fuOutputEvents++; - - if( 0 == ( fuOutputEvents%100000 ) && 0 < fuOutputEvents ) - { - LOG(info)<< "CbmGet4EventBuilder::Exec : " - << fuOutputEvents << " events found and processed."; - } // if( 0 == ( fuOutputEvents%100 ) && 0 < fuOutputEvents ) - } // if( 0 < vEvent->size() ) - else - { - vEvent->clear(); - delete vEvent; - } // else of if( 0 < vEvent->size() ) - } // for( UInt_t uTrigg = 0; uTrigg < vTriggerTimes.size(); uTrigg ++) - - // All event triggers scanned, now clear them - vTriggerTimes.clear(); - - fhMaxMulPerEpochDist->Fill( fhHitMultiplicity->GetMaximum() ); -#ifdef MUL_TRIGG_DEBUG - fhMaxMulEpoch->Fill( ulEpochIdx%1000, ulEpochIdx/1000,fhHitMultiplicity->GetMaximum() ); - for( Int_t iBin = 0; iBin < fiNbBinsMultiHist; iBin++) - if( fiMultiThreshold <= fhHitMultiplicity->GetBinContent( iBin + 1) ) - fhBinThrEpoch->Fill( ulEpochIdx%1000, ulEpochIdx/1000); - - if( 0 < uMaxEventSzEp ) - fhMaxEvtSizeEpoch->Fill(ulEpochIdx%1000, ulEpochIdx/1000, uMaxEventSzEp ); -// delete canvasDeb; -#endif // MUL_TRIGG_DEBUG - - fhHitMultiplicity->Reset(); - } // if( kFALSE == fbTriggerMode ) - else - { - } // else of if( kFALSE == fbTriggerMode ) - - // Fill histos if needed - FillHistos(); - - // if total looping time larger than limit: stop looping for now - // We can start on the backlog later - fStop.Set(); - Double_t dLooptTime = fStop.GetSec() - fStart.GetSec() - + (fStop.GetNanoSec() - fStart.GetNanoSec())/1e9; - if( fdMaxTimePerLoopS < dLooptTime ) - break; - } // while( 0 < fInputBuffer->GetSize() ) -#ifdef MUL_TRIGG_DEBUG - fuInputEvents += 1; - if( 0 == ( fuInputEvents%10000 ) && 0 < fuInputEvents ) - { - canvasDeb->cd(1); -// fhMaxMulEpoch->Draw("colz"); -// fhBinThrEpoch->Draw("colz"); - fhMaxEvtSizeEpoch->Draw("colz"); - gPad->Modified(); - gPad->Update(); - canvasDeb->cd(2); -// fhMaxMulPerEpochDist->Draw(""); - fhEventSizeDist->Draw(""); - gPad->Modified(); - gPad->Update(); - } - - LOG(debug)<< "CbmGet4EventBuilder::Exec : " - << fuInputEvents << " events processed and " - << fuOutputEvents << " events built => buffer size " - << fOutputBuffer->GetSize(); - // Clear output buffer as no event consumer in this mode - // Commented out as should be DONE in CbmGet4EventDumper - // fOutputBuffer->Clear(); -#endif // MUL_TRIGG_DEBUG -} - -void CbmGet4EventBuilder::Finish() -{ - LOG(info)<<"CbmGet4EventBuilder::Finish up with " - << fuInputEvents << " events processed and " - << fuOutputEvents << " events built" ; - - WriteHistos(); - - DeleteHistos(); -} - -/************************************************************************************/ -Bool_t CbmGet4EventBuilder::RegisterInputs() -{ - fInputBuffer = CbmGet4EpochBuffer::Instance(); - - if(NULL == fInputBuffer) - return kFALSE; - - return kTRUE; -} -Bool_t CbmGet4EventBuilder::RegisterOutputs() -{ - fOutputBuffer = CbmGet4EventBuffer::Instance(); - - if(NULL == fOutputBuffer) - return kFALSE; - - fOutputBuffer->PrintStatus(); - - return kTRUE; -} -/************************************************************************************/ -// ------------------------------------------------------------------ -Bool_t CbmGet4EventBuilder::CreateHistos() -{ - // Create histogramms - - TDirectory * oldir = gDirectory; // <= To prevent histos from being sucked in by the param file of the TRootManager! - gROOT->cd(); // <= To prevent histos from being sucked in by the param file of the TRootManager ! - - gDirectory->cd( oldir->GetPath() ); // <= To prevent histos from being sucked in by the param file of the TRootManager! - - return kTRUE; -} - -// ------------------------------------------------------------------ -Bool_t CbmGet4EventBuilder::FillHistos() -{ - return kTRUE; -} -// ------------------------------------------------------------------ - -Bool_t CbmGet4EventBuilder::WriteHistos() -{ - // TODO: add sub-folders - - // Write histogramms to the file - TDirectory * oldir = gDirectory; - TFile *fHist = new TFile(fsHistoFilename,"RECREATE"); - fHist->cd(); - - fhMaxMulPerEpochDist->Write(); - fhEventSizeDist->Write(); -#ifdef MUL_TRIGG_DEBUG - fhMaxMulEpoch->Write(); - fhBinThrEpoch->Write(); - fhMaxEvtSizeEpoch->Write(); - fhEvtSizeEvo->Write(); -#endif // MUL_TRIGG_DEBUG - gDirectory->cd( oldir->GetPath() ); - - fHist->Close(); - - return kTRUE; -} -Bool_t CbmGet4EventBuilder::DeleteHistos() -{ - return kTRUE; -} - -ClassImp(CbmGet4EventBuilder) diff --git a/beamtime/cern2014/get4/CbmGet4EventBuilder.h b/beamtime/cern2014/get4/CbmGet4EventBuilder.h deleted file mode 100644 index d36b77d8f301cdefffb4a8250e97e43c375d8dcf..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/get4/CbmGet4EventBuilder.h +++ /dev/null @@ -1,185 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmGet4EventBuilder ----- -// ----- Created 23.02.2015 by ----- -// ----- P.-A. Loizeau ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CBMGET4EVENTBUILDER_H -#define CBMGET4EVENTBUILDER_H - -// Specific headers -#include "CbmGet4v1xHackDef.h" - -// FAIR/CBMROOT headers -#include "FairTask.h" - -// ROOT headers -#include "TTimeStamp.h" - -// C++ std headers -#include <vector> -#include <set> - -// Enable debug online histos for multiplicity trigger -#define MUL_TRIGG_DEBUG - -// 3 epochs max in use: Prev. Ep., Curr. Ep., Next Ep. -const Int_t kiMaxEpochInUse = 3; - -class CbmGet4EpochBuffer; -class CbmGet4EventBuffer; -class TH1; - -#ifdef MUL_TRIGG_DEBUG -#include "TCanvas.h" -class TH2; -#endif // MUL_TRIGG_DEBUG - -class CbmGet4EventBuilder : public FairTask -{ - public: - CbmGet4EventBuilder(); - CbmGet4EventBuilder(const char* name, Int_t verbose = 1); - virtual ~CbmGet4EventBuilder(); - - virtual InitStatus Init(); - virtual void Exec(Option_t* option); - virtual void Finish(); - - // Setters - // Common - void SetMaxTimePerLoop( Double_t dTimeLimitIn ) { fdMaxTimePerLoopS = dTimeLimitIn; } - void SetTriggerMode( Bool_t bTrigModeIn ); - void SetTriggerWinNeg( Double_t dWinNeg, Int_t iTrigger = 0 ); - void SetTriggerWinPos( Double_t dWinPos, Int_t iTrigger = 0 ); - void SetTriggerDeadT( Double_t dDeadT, Int_t iTrigger = 0 ); - void SetTriggerType( Int_t iType, Int_t iTrigger = 0 ); - // Multiplicity trigger - void SetMultiThreshold( Double_t dMulThrIn) { fiMultiThreshold = dMulThrIn; } - void SetMultiHistBinSzClk( Int_t iMulHistBin){ fiMultiHistBinSz = iMulHistBin; } - // Channel Coincidence trigger - void SetNbTriggers( Int_t iNbTriggers ); - void SetTrigNbComponents( Int_t iTrigIndex, Int_t iNbComp ); - void SetTrigCompChan( Int_t iTrigIndex, Int_t iCompIndex, Int_t iChIndex); - void SetCoincWin( Int_t iTrigIndex, Double_t dCoincWin); - - void SetHistoFilename( TString sNameIn ); - - // Getters - Double_t GetMaxTimePerLoop() const { return fdMaxTimePerLoopS; } - Bool_t GetTriggerMode() const { return fbTriggerMode; } - Double_t GetTriggerWinNeg( Int_t iTrigger = 0 ); - Double_t GetTriggerWinPos( Int_t iTrigger = 0 ); - Double_t GetTriggerDeadT( Int_t iTrigger = 0 ); - Int_t GetTriggerType( Int_t iTrigger = 0 ); - // Multiplicity trigger - Double_t GetMultiThreshold() const { return fiMultiThreshold; } - Int_t GetMultiHistBin() const { return fiMultiHistBinSz; } - // Channel Coincidence trigger - Int_t GetNbTriggers(); - Int_t GetTrigNbComponents( Int_t iTrigIndex ); - Int_t GetTrigCompChan( Int_t iTrigIndex, Int_t iCompIndex ); - Double_t GetCoincWin( Int_t iTrigIndex ); - - protected: - - private: - void ResizeTriggerVectors(); - Int_t PrevEpId(); - Int_t CurrEpId(); - Int_t NextEpId(); - - Bool_t RegisterInputs(); - Bool_t RegisterOutputs(); - - Bool_t CreateHistos(); - Bool_t FillHistos(); - Bool_t WriteHistos(); - Bool_t DeleteHistos(); - - CbmGet4EventBuilder(const CbmGet4EventBuilder&); - CbmGet4EventBuilder operator=(const CbmGet4EventBuilder&); - - // Class Members: Input and output - UInt_t fuInputEvents; // Number of processed input "events" - UInt_t fuOutputEvents; // Number of processed output "events" - UInt_t fuInputEpochs; // Number of received input epochs - CbmGet4EpochBuffer* fInputBuffer; // Epoch buffer - CbmGet4EventBuffer* fOutputBuffer; // Event buffer - std::multiset< get4v1x::FullMessage >* fpEpoch[kiMaxEpochInUse]; //! Pointers on epochs in use - Int_t fiCurrentEpoch;// Which of the 3 epoch is in use - - // Control - Double_t fdMaxTimePerLoopS; - TTimeStamp fStart; - TTimeStamp fStop; - TString fsHistoFilename; - - Bool_t fbTriggerMode; // kFALSE => Hit Multi, kTRUE => Channels Coinc. - /************* Common event definition params ****************/ - // Number of defined triggers (1 if multiplicity, 1 to N if coinc) - Int_t fiNbTriggers; - // Trigger window past [-]: save all hits (h) with [-] < t(h) - t(T) - std::vector< Double_t > fvdTrigWinNeg; - // Trigger window future [+]: save all hits (h) with [+] > t(h) - t(T) - std::vector< Double_t > fvdTrigWinPos; - // Deadtime [d]: individual deadtime for each trigger, prevent new events closer than [d] - // could be later used with trigger type to define priorities - std::vector< Double_t > fvdTrigDeadtime; - // Trigger type: would possibly allow priority or trigger merging in later stage - std::vector< Int_t > fviTrigType; - // Epoch in which the first possible hit in a new event can be found - // 3 possible values: -1 = previous epoch, 0 = current epoch, 1 = next epoch - // This hit is defined as the first hit for which in latest trigger we have: - // t(1) + [d] - [-] < t(h) - // OBSOLETE if trigger priority is implemented - Int_t fiEpochStartHitScan; - // Index within epoch vector of the first possible hit in new event - // This hit is defined as the first hit for which in latest trigger we have: - // t(1) + [d] - [-] < t(h) - // OBSOLETE if trigger priority is implemented - Int_t fiIndexStartHitScan; - /*************************************************************/ - - /***************** Hit multiplicity trigger ******************/ - TH1* fhHitMultiplicity; // Hit multiplicity evolution within current epoch - Int_t fiMultiHistBinSz; // Bin size for the Multi histo in clock cycles - Int_t fiNbBinsMultiHist; // Number of bins in multiplicity histogram - Int_t fiMultiThreshold; // Threshold above which an event is "found" - TH1* fhMaxMulPerEpochDist; // max Hit multiplicity/bin in each epoch - TH1* fhEventSizeDist; // nb Hits per event -#ifdef MUL_TRIGG_DEBUG - TCanvas* canvasDeb; - TH2* fhMaxMulEpoch; // max Hit multiplicity/bin in each epoch - TH2* fhBinThrEpoch; // bin over threshold in each epoch - TH2* fhMaxEvtSizeEpoch; // max event size in each epoch - TH2* fhEvtSizeEvo; // Evolution of event size distribution VS epoch/1000 -#endif // MUL_TRIGG_DEBUG - /*************************************************************/ - - /*************** Channel coincidence trigger *****************/ - // Event definition parameters - // Trigger components = - // - 1 "Main" channel(1) giving Trigger time (T) - // - n "other" channels (2) - std::vector< std::vector < UInt_t > > fvvuTriggerComp; - // Coincidence window => max dt = |t(1) - t(2)|, in ps - std::vector< Double_t > fvdCoincWin; - - // Event definition variables - // Index of last trigger found - UInt_t fuLastTriggerId; - // Flag indicating if a trigger component was found since last occurrence of its trigger - std::vector< std::vector < Bool_t > > fvvbTrigCompFound; - // Epoch of the last hit for each trigger component, 0 if not found yet - std::vector< std::vector < ULong64_t > > fvvulTrigCompEp; - // Coarse counter of the last hit for each trigger component, 0 if not found yet - std::vector< std::vector < UInt_t > > fvvuTrigCompTs; - /*************************************************************/ - - ClassDef(CbmGet4EventBuilder, 1) -}; - -#endif // CBMGET4EVENTBUILDER_H diff --git a/beamtime/cern2014/get4/CbmGet4EventDumper.cxx b/beamtime/cern2014/get4/CbmGet4EventDumper.cxx deleted file mode 100644 index 1adc3a327a8ec6c5bb76a8c8c3dc37950d380cb9..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/get4/CbmGet4EventDumper.cxx +++ /dev/null @@ -1,372 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmGet4EventDumper ----- -// ----- Created 16.04.2015 by ----- -// ----- P.-A. Loizeau ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#include "CbmGet4EventDumper.h" - -// TOF Classes and includes -#include "CbmGet4EventBuffer.h" -#include "CbmGet4v1xDef.h" -#include "CbmGet4v1xHackDef.h" -#include "TTofGet4Board.h" -#include "TTofGet4Data.h" - -// CBMroot classes and includes - -// FAIR classes and includes -//#include "FairRunOnline.h" -//#include "FairEventHeader.h" -#include "FairLogger.h" - -// ROOT Classes and includes -#include "TH1.h" -#include "TROOT.h" -#include "TClonesArray.h" - -// C++ std headers - -//___________________________________________________________________ -// - -// ------------------------------------------------------------------ -CbmGet4EventDumper::CbmGet4EventDumper() - : FairTask("CbmGet4EventDumper"), - fuInputEvents(0), - fuOutputEvents(0), - fInputBuffer(NULL), - fEvtHeader(NULL), - fIOMan(NULL), - fGet4BoardCollection(NULL), - fuNbGet4(0), - fvbActiveChips(), - fuNbEvtBuffEmptyCall(0), - fbWriteDataInCbmOut(kFALSE), - fdMaxTimePerLoopS(0.0), - fStart(), - fStop() -{ - LOG(info)<<" CbmGet4EventDumper: Task started"; -} -CbmGet4EventDumper::CbmGet4EventDumper(const char* name, Int_t verbose) - : FairTask(name, verbose), - fuInputEvents(0), - fuOutputEvents(0), - fInputBuffer(NULL), - fEvtHeader(NULL), - fIOMan(NULL), - fGet4BoardCollection(NULL), - fuNbGet4(0), - fvbActiveChips(), - fuNbEvtBuffEmptyCall(0), - fbWriteDataInCbmOut(kFALSE), - fdMaxTimePerLoopS(0.0), - fStart(), - fStop() -{ - LOG(info)<<" CbmGet4EventDumper: Task started"; -} -// ------------------------------------------------------------------ - -// ------------------------------------------------------------------ -CbmGet4EventDumper::~CbmGet4EventDumper() -{ -} -// ------------------------------------------------------------------ -/************************************************************************************/ -void CbmGet4EventDumper::SetActiveGet4( UInt_t uChipsIndex, Bool_t bActiveFlag) -{ - if( 0 == fvbActiveChips.size() && 0 < fuNbGet4 ) - { - fvbActiveChips.resize(fuNbGet4); - for( UInt_t uChip = 0; uChip < fuNbGet4; uChip++) - fvbActiveChips[uChip] = kTRUE; - } // if( 0 == fvbActiveChips.size() - - if( uChipsIndex < fuNbGet4 ) - fvbActiveChips[uChipsIndex] = bActiveFlag; - else LOG(error)<<" CbmGet4EventDumper::SetActiveGet4 => Invalid chip index " - << uChipsIndex ; -} -/************************************************************************************/ -// FairTasks inherited functions -InitStatus CbmGet4EventDumper::Init() -{ - if( kFALSE == RegisterInputs() ) - return kFATAL; - - if( kFALSE == RegisterOutputs() ) - return kFATAL; - - if( kFALSE == CreateHistos() ) - return kFATAL; - - // Common variables initial values, mostly in case some are missed in ctor - fuInputEvents = 0; - fuOutputEvents = 0; - - return kSUCCESS; -} - -void CbmGet4EventDumper::Exec(Option_t* /*option*/) -{ - // Task execution - LOG(debug)<<" CbmGet4EventDumper => New loop"; - - // Initialize the looping time start point - fStart.Set(); - - Int_t iNbHitsDumped = 0; - - // We try to always dump at least 1 event per execution loop - // as the FairRunOnline is always inserting a new "event" per loop - // to the output tree (see l278 to 281) - if( 0 < fInputBuffer->GetSize() ) - { - // From FairRunOnline EventLoop method - fIOMan->StoreWriteoutBufferData(fIOMan->GetEventTime()); - - iNbHitsDumped = this->ReadEvent(); - fuOutputEvents ++; - - // Fill histos if needed - FillHistos(); - - // From FairRunOnline EventLoop method - fIOMan->Fill(); - fIOMan->DeleteOldWriteoutBufferData(); - } // if( 0 < fInputBuffer->GetSize() ) - /* - else if( kTRUE == fbWriteDataInCbmOut) - LOG(info)<<" CbmGet4EventDumper => No event to dump in this execution loop\n" - <<" => Empty event in output tree!" - ; - */ - - // Now we dump events from as many available events as possible - // while keeping enough events in buffer to account for some - // execution loops without events - while( fuNbEvtBuffEmptyCall < fInputBuffer->GetSize() ) - { - iNbHitsDumped += this->ReadEventMore(); - fuOutputEvents ++; - - // Fill histos if needed - FillHistos(); - - if( 0 == ( fuOutputEvents%100000 ) && 0 < fuOutputEvents ) - { - LOG(info)<< "CbmGet4EventDumper::Exec : " - << fuOutputEvents << " events dumped."; - } // if( 0 == ( fuOutputEvents%100 ) && 0 < fuOutputEvents ) - - // if total looping time larger than limit: stop looping for now - // We can start on the backlog later - fStop.Set(); - Double_t dLooptTime = fStop.GetSec() - fStart.GetSec() - + (fStop.GetNanoSec() - fStart.GetNanoSec())/1e9; - if( fdMaxTimePerLoopS < dLooptTime ) - break; - } // while( fuNbEvtBuffEmptyCall < fInputBuffer->GetSize() ) - - // Update execution loop counter - fuInputEvents++; -} - -void CbmGet4EventDumper::Finish() -{ - LOG(info)<<"CbmGet4EventDumper::Finish up with " - << fuInputEvents << " loops done and " - << fuOutputEvents << " events dumped" ; - - WriteHistos(); - - DeleteHistos(); -} - -/************************************************************************************/ -Bool_t CbmGet4EventDumper::RegisterInputs() -{ - fInputBuffer = CbmGet4EventBuffer::Instance(); - - if(NULL == fInputBuffer) - return kFALSE; - - return kTRUE; -} -Bool_t CbmGet4EventDumper::RegisterOutputs() -{ - // Recover the pointer on the FairRoot IO manager - fIOMan = FairRootManager::Instance(); - - // Now recover the pointer on the event header - fEvtHeader = dynamic_cast<FairEventHeader*> (fIOMan->GetObject("EventHeader.")); - if( NULL == fEvtHeader ) - { - LOG(warning)<<"CbmGet4EventDumper::RegisterOutputs: No event Header was found!!!"; - return kFALSE; - } - - - if( 0 < fuNbGet4 ) - { - fGet4BoardCollection = new TClonesArray( "TTofGet4Board", fuNbGet4); - fIOMan->Register( "TofGet4Tdc","TofUnpack",fGet4BoardCollection, fbWriteDataInCbmOut); - } // if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::get4 ) ) - - if(NULL == fGet4BoardCollection) - { - LOG(error)<<"CbmGet4EventDumper::RegisterOutputs: no TOF GET4 TDC array created! "; - fuNbGet4 = 0; - return kFALSE; - } // if(NULL == fGet4BoardCollection) - - return kTRUE; -} - -Bool_t CbmGet4EventDumper::ClearOutput() -{ - LOG(debug)<<"Clear GET4"; - if( 0 < fuNbGet4 && NULL != fGet4BoardCollection ) - fGet4BoardCollection->Clear("C"); - return kTRUE; -} -/************************************************************************************/ -Int_t CbmGet4EventDumper::ReadEvent() -{ - Int_t iNbHitsDumped = 0; - - // Clear storage - ClearOutput(); - - // First obtain a pointer on an input event - std::pair< CbmGet4EventHeader, std::vector< get4v1x::FullMessage >* > pvEvent = fInputBuffer->GetNextEvent(); -/* - * Missing: - * 1) Trigger time in Event buffer => Done - * 2) Trigger type and trigger epoch in output event => needed? - * - */ - // Initialize all board objects - std::vector<TTofGet4Board *> vGet4Board; - vGet4Board.resize( fuNbGet4, NULL ); - for( UInt_t uGet4 = 0; uGet4 < fuNbGet4; uGet4++ ) - { - vGet4Board[uGet4] = dynamic_cast<TTofGet4Board*> ( fGet4BoardCollection->ConstructedAt(uGet4) ); - vGet4Board[uGet4]->SetTriggerFullTime( - ( ( (pvEvent.first).fuTriggerExtEp ) & 0xFFFFFFFF ) *get4v1x::kdEpochInPs + - (pvEvent.first).fuTriggerTs *get4v1x::kdClockCycleSize ); // in ps - vGet4Board[uGet4]->SetTriggerTime( (pvEvent.first).fuTriggerTs ); // in clock cycles - // This class uses unsigned integer => remapped trigger index - // < -256: unknown trigger => 512 - // -256 to -1: multiplicity triggers => 256 to 511 - // 0 < : usual coincidence trigger => 0 to 255, hope nobody implement more than that - vGet4Board[uGet4]->SetTriggIndx( 0 <= (pvEvent.first).fiTriggerType? - static_cast<UInt_t>( (pvEvent.first).fiTriggerType ) : - -256 < (pvEvent.first).fiTriggerType? - static_cast<UInt_t>( 512 + (pvEvent.first).fiTriggerType ) : 512 ); - } // for( UInt_t uGet4 = 0; uGet4 < fuNbGet4; uGet4++ ) - - - // Do stuff with our hits - for( UInt_t uHit = 0; uHit < (pvEvent.second)->size(); uHit++ ) - { - get4v1x::FullMessage mess = (pvEvent.second)->at(uHit); - - uint8_t cRocId = mess.getRocNumber(); - uint8_t cChipId = mess.getGet4V10R32ChipId(); - uint32_t uChipFullId = cChipId + get4v1x::kuMaxGet4PerRoc*cRocId; - - TTofGet4Data data( - mess.getGet4V10R32HitChan(), - mess.getGet4V10R32HitFt(), - mess.getGet4V10R32HitTs(), - mess.getMsgFullTime( mess.getExtendedEpoch() & 0xFFFFFFFF ), - mess.getMsgFullTimeD( mess.getExtendedEpoch() & 0xFFFFFFFF ), - ( mess.getExtendedEpoch() & 0xFFFFFFFF ), - ( ( mess.getExtendedEpoch() >> 32 ) & 0xFFFFFFFF ), - mess.getGet4V10R32HitTot(), - kTRUE ); - vGet4Board[ uChipFullId ]->AddData( data ); - } // for( Int_t iHit = 0; iHit < (pvEvent.second)->size(); iHit++ ) - vGet4Board.clear(); -/* - TTofGet4Board * Get4Board = (TTofGet4Board*) fGet4BoardCollection->ConstructedAt(uGet4); - // Get4Board->SetTriggerFullTime (not needed?) - // Get4Board->SetTriggerTime - // Get4Board->SetTriggIndx - // Get4Board->SetValid - // Get4Board->AddData - - // TTofGet4Data( UInt_t uChan, UInt_t uFt, - // UInt_t uCoarseT, - // ULong64_t uFulltime = 0, Double_t dFullTime = 0.0, - // UInt_t uGet4Epoch = 0, UInt_t uGet4EpCycle = 0, - // UInt_t uTot = 0, Bool_t bIs32Bit = kFALSE ); -*/ - // Now clear the input event object and delete it - if( 0 < (pvEvent.second)->size() ) - (pvEvent.second)->clear(); - delete (pvEvent.second); - - return iNbHitsDumped; -} -// ------------------------------------------------------------------ -Int_t CbmGet4EventDumper::ReadEventMore() -{ - Int_t iNbHitsDumped = 0; - - // From FairRunOnline EventLoop method - fIOMan->StoreWriteoutBufferData(fIOMan->GetEventTime()); - - iNbHitsDumped = this->ReadEvent(); - - // From FairRunOnline EventLoop method - fIOMan->Fill(); - fIOMan->DeleteOldWriteoutBufferData(); - - return iNbHitsDumped; -} -/************************************************************************************/ -// ------------------------------------------------------------------ -Bool_t CbmGet4EventDumper::CreateHistos() -{ - // Create histogramms - - TDirectory * oldir = gDirectory; // <= To prevent histos from being sucked in by the param file of the TRootManager! - gROOT->cd(); // <= To prevent histos from being sucked in by the param file of the TRootManager ! - - gDirectory->cd( oldir->GetPath() ); // <= To prevent histos from being sucked in by the param file of the TRootManager! - - return kTRUE; -} - -// ------------------------------------------------------------------ -Bool_t CbmGet4EventDumper::FillHistos() -{ - return kTRUE; -} -// ------------------------------------------------------------------ - -Bool_t CbmGet4EventDumper::WriteHistos() -{ -/* - // Write histogramms to the file - TDirectory * oldir = gDirectory; - TFile *fHist = new TFile("./get4EventDumper.hst.root","RECREATE"); - fHist->cd(); - - fhMaxMulPerEpochDist->Write(); - fHist->Close(); -*/ - return kTRUE; -} -Bool_t CbmGet4EventDumper::DeleteHistos() -{ - return kTRUE; -} - -ClassImp(CbmGet4EventDumper) diff --git a/beamtime/cern2014/get4/CbmGet4EventDumper.h b/beamtime/cern2014/get4/CbmGet4EventDumper.h deleted file mode 100644 index 7f392aac3627ea9c851c5d11bed9b06e5aff4e56..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/get4/CbmGet4EventDumper.h +++ /dev/null @@ -1,98 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmGet4EventDumper ----- -// ----- Created 16.04.2015 by ----- -// ----- P.-A. Loizeau ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CBMGET4EVENTDUMPER_H -#define CBMGET4EVENTDUMPER_H - -// Specific headers - -// FAIR/CBMROOT headers -#include "FairTask.h" -#include "FairEventHeader.h"// compilation error of dictionary if not explicitly included, not sure why - -// ROOT headers -#include "TTimeStamp.h" - -// C++ std headers -#include <vector> - -class CbmGet4EventBuffer; -//class FairRootManager; -//class FairEventHeader; -class TClonesArray; - -class CbmGet4EventDumper : public FairTask -{ - public: - CbmGet4EventDumper(); - CbmGet4EventDumper(const char* name, Int_t verbose = 1); - virtual ~CbmGet4EventDumper(); - - virtual InitStatus Init(); - virtual void Exec(Option_t* option); - virtual void Finish(); - - // Setters - void SetMaxTimePerLoop( Double_t dTimeLimitIn ) { fdMaxTimePerLoopS = dTimeLimitIn; } - inline void SetGet4Nb( UInt_t uNbChipsIn) { fuNbGet4 = uNbChipsIn; } - void SetActiveGet4( UInt_t uChipsIndex, Bool_t bActiveFlag = kTRUE); - inline void SetNbEvtBuffEmptyCall( UInt_t uNbEvt = 0 ){ fuNbEvtBuffEmptyCall = uNbEvt; }; - inline void SetDataWriting( Bool_t bWriteOn = kTRUE ){ fbWriteDataInCbmOut = bWriteOn; }; - - // Getters - Double_t GetMaxTimePerLoop() const { return fdMaxTimePerLoopS; } - - protected: - - private: - // To get rid of warning due to pointer member - // Implement properly if needed - CbmGet4EventDumper(const CbmGet4EventDumper&); - CbmGet4EventDumper& operator=(const CbmGet4EventDumper&); - - Bool_t RegisterInputs(); - Bool_t RegisterOutputs(); - Bool_t ClearOutput(); - - Int_t ReadEvent(); - Int_t ReadEventMore(); - - Bool_t CreateHistos(); - Bool_t FillHistos(); - Bool_t WriteHistos(); - Bool_t DeleteHistos(); - -// CbmGet4EventDumper(const CbmGet4EventDumper&); -// CbmGet4EventDumper operator=(const CbmGet4EventDumper&); - - // Counters - UInt_t fuInputEvents; // Number of processed input "events" - UInt_t fuOutputEvents; // Number of processed output "events" - - // Class Members: Input and output - CbmGet4EventBuffer* fInputBuffer; // Event buffer - FairEventHeader * fEvtHeader; // Event header to keep another track of event info - FairRootManager * fIOMan; // FairRoot IO manager, to control output array and event header - TClonesArray * fGet4BoardCollection; // Collection of GET4 board objects, updated on each event - - // Settings - UInt_t fuNbGet4; - std::vector< Bool_t > fvbActiveChips; // Active flag to avoid mapping need (one per GET4 chip, def. kTRUE) - UInt_t fuNbEvtBuffEmptyCall; // nb of events to keep if possible to deal w/ execution call w/o events - Bool_t fbWriteDataInCbmOut; // enable data writing in output tree file, otherwise jump emptying input buffer - - // Control - Double_t fdMaxTimePerLoopS; - TTimeStamp fStart; - TTimeStamp fStop; - /*************************************************************/ - - ClassDef(CbmGet4EventDumper, 1) -}; - -#endif // CBMGET4EVENTDUMPER_H diff --git a/beamtime/cern2014/get4/CbmGet4FastMonitor.cxx b/beamtime/cern2014/get4/CbmGet4FastMonitor.cxx deleted file mode 100644 index 672da574ae540729aba711b510ca627bc56dccf6..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/get4/CbmGet4FastMonitor.cxx +++ /dev/null @@ -1,3953 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmGet4FastMonitor ----- -// ----- Created 15.12.2014 by ----- -// ----- P.-A. Loizeau ----- -// ----- Based on CbmGet4FastMonitor ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#include "CbmGet4FastMonitor.h" - -// Specific headers -#include "CbmGet4v1xDef.h" - -// FAIRROOT headers -#include "FairLogger.h" -#include "FairRootManager.h" - -// ROOT headers -#include "TF1.h" -#include "TProfile.h" -#include "TH2.h" -#include "TClonesArray.h" -#include "TFile.h" -#include "TMath.h" -#include "TTimeStamp.h" -#include "TROOT.h" - -// C++ std headers -#include <iostream> -#include <stdint.h> - -/********* - * DONE - * 2) Counts as function of time (s bin, per ch/chip/ROC/Det) => / OK / OK / OK - * 3) Split class => OK - *********/ - -// Default values -const Double_t kdEvoBinSizeS = 1.5; -const Double_t kdEvoLengthSec = 1800.0; -//const Double_t kdMsSizeSec = 1e-3; // up to 01/03 15:00 -const Double_t kdMsSizeSec = 16384*8*(1e-9); // From to 01/03 15:00 - -const Int_t kiNbDet = 4; -const TString ksDetName[kiNbDet] = {"HDP2", "TSU", "HDP5", "USTC"}; -const UInt_t kuNbTdcMappedDet = 88; -const Int_t kiTdcDetMap[kuNbTdcMappedDet] = - { - 0, 0, 0, 0, 0, 0, 0, 0, // ROC 0 FEE 0 - 0, 0, 0, 0, 0, 0, 0, 0, // ROC 0 FEE 1 - 1, 1, 1, 1, 1, 1, 1, 1, // ROC 0 FEE 2 - 4, 4, 4, 4, 4, 4, 4, 4, // ROC 0 FEE 3 - 4, 4, 4, 4, 4, 4, 4, 4, // ROC 0 FEE 4 - 4, 4, 4, 4, 4, 4, 4, 4, // ROC 0 FEE 5 - 4, 4, 4, 4, 4, 4, 4, 4, // ROC 0 FEE 6 - 4, 4, 4, 4, 4, 4, 4, 4, // ROC 0 FEE 7 - 1, 1, 1, 1, 1, 1, 1, 1, // ROC 1 FEE 0 - 2, 2, 2, 2, 2, 2, 2, 2, // ROC 1 FEE 1 - 3, 3, 3, 3, 3, 3, 3, 3, // ROC 1 FEE 2 - }; - -// Defautl value for nb bins in Pulser time difference histos -const UInt_t kuNbBinsDt = 5000; -Double_t dMinDt = -1.*(kuNbBinsDt*get4v1x::kdBinSize/2.) -get4v1x::kdBinSize/2.; -Double_t dMaxDt = 1.*(kuNbBinsDt*get4v1x::kdBinSize/2.) +get4v1x::kdBinSize/2.; - -struct DTM_header -{ - uint8_t packet_length; - uint8_t packet_counter; - uint16_t ROC_ID; - - void Dump() { - printf ("HEADER ======================= pack_len=0x%02X, pack_cnt=0x%02X, ROC=0x%04X\n", - packet_length, packet_counter, ROC_ID); - } -}; - -CbmGet4FastMonitor::CbmGet4FastMonitor() -: CbmTSUnpack(), - fbVerbose(kFALSE), - fbDebug(kFALSE), - fiDebugTsStart(-1), - fiDebugTsStop(-1), - fiMode(0), - fsHistoFilename("./get4Monitor.hst.root"), - fuNbRocs(0), - fuNbGet4(0), - fuNbFee(0), - fuMsOverlapTs(0), - fvbActiveChips(), - fulTsNb(0), - fulMsNb(0), - fsMaxMsNb(0), - fuOffset(0), - fuMaxOffset(0), - fuLocalOffset(0), - fuMaxLocalOffset(0), - fvbRocFeetFirstSyncDlm(kFALSE), - fvbRocFeetSyncStart(kFALSE), - fvbGet4WaitFirstSync(kTRUE), - fvuCurrEpoch(), - fvuCurrEpochCycle(), - fvuCurrEpoch2(), - fvuCurrEpoch2Cycle(), - fhMessageTypePerRoc(NULL), - fhRocSyncTypePerRoc(NULL), - fhRocAuxTypePerRoc(NULL), - fhSysMessTypePerRoc(NULL), - fhMessTypePerGet4(NULL), - fhGet4EpochFlags(NULL), - fhGet4EpochSyncDist(NULL), - fhGet4EpochJumps(NULL), - fhGet4BadEpochRatio(NULL), - fhGet4BadEpRatioChip(NULL), - fhGet4ChanDataCount(NULL), - fhGet4ChanDllStatus(NULL), - fhGet4ChanTotMap(NULL), - fhGet4ChanErrors(NULL), - fhGet4ChanTotOwErrorsProp(NULL), - fhGet4ChanTotOrErrorsProp(NULL), - fhGet4ChanTotEdErrorsProp(NULL), - fhGet4ChanSlowContM(NULL), - fhGet4ChanEdgesCounts(NULL), - fhGet4ChanDeadtime(NULL), - fhGet4SeuCounter(NULL), - fdEvoBinSizeS(kdEvoBinSizeS), - fdEvoLengthSec(kdEvoLengthSec), - fdMsLengthSec(kdMsSizeSec), - fhMsSizeEvo(NULL), - fvhRocDataCntEvo(), - fvhRocEpochCntEvo(), - fvhRocErrorCntEvo(), - fvhRocTotErrorCntEvo(), - fvhRocEpochMissmCntEvo(), - fvhRocDataLossCntEvo(), - fvhRocEpochLossCntEvo(), - fvhGet4DataCntEvo(), - fvhGet4ErrorCntEvo(), - fvhGet4EpochMissmCntEvo(), - fvhGet4DataLossCntEvo(), - fvhGet4EpochLossCntEvo(), - fvhGet4ChDataCntEvo(), - fvhGet4ChErrorCntEvo(), - fvhDetDataCntEvo(), - fvhDetErrorCntEvo(), - fvhDetEpochMissmCntEvo(), - fvhDetDataLossCntEvo(), - fvhDetEpochLossCntEvo(), - fhClosedEpSizeEvo(NULL), - fbPulserMode(kFALSE), - fuPulserFee(0), - fuPulserChan(), - fvuLastHitEp(), - fvmLastHit(), - fhTimeResFee(), - fhTimeRmsAllFee(NULL), - fhTimeResAllFee(NULL), - fbPulserFeeB(kFALSE), - fuPulserFeeB(kFALSE), - fhTimeResFeeB(), - fhTimeRmsAllFeeB(NULL), - fhTimeResAllFeeB(NULL), - fhTimeResFeeAB(), - fhTimeRmsAllFeeAB(NULL), - fhTimeResAllFeeAB(NULL), - fhTimeRmsAllPairs(NULL), - fhTimeResAllPairs(NULL), - fhTimeRmsAllCombi(NULL), - fhTimeResAllCombi(NULL), - fhTimeResPairs(), - fhTimeResCombi(), - fhTimeRmsAllCombiEncA(NULL), - fhTimeResAllCombiEncA(NULL), - fhTimeRmsAllCombiEncB(NULL), - fhTimeResAllCombiEncB(NULL), - fhPulserHitDistNs(NULL), - fhPulserHitDistUs(NULL), - fhPulserHitDistMs(NULL), - fhPulserFeeDnl(NULL), - fhPulserFeeInl(NULL), - fhPulserFeeDistCT(), - fvuPrevHitEp(), - fvmPrevHit(), - fhFtSmallDtFeeA(NULL), - fhFtSmallDtFeeB(NULL), - fhFtBigDtFeeA(NULL), - fhFtBigDtFeeB(NULL), - fhFtPrevSmallDtFeeA(NULL), - fhFtPrevSmallDtFeeB(NULL), - fhFtPrevBigDtFeeA(NULL), - fhFtPrevBigDtFeeB(NULL), - fhFullCtEpJumpFeeA(), - fhFullCtEpJumpFeeACh(), - fhFullCtEpJumpFeeAChSort(), - fhFullCtEpJumpFeeAChOrder(NULL), - fvChanOrder(), - fhFullCtChOrderCh(), - fhFullCtEpQualityCh(), - fhFullCtEpQualityChZoom(), - fhEpQualityFirstChFeeA(), - fbOldReadoutOk(kFALSE), - fhGet4ChanTotCount(NULL), - fvuLastOldTotEp(), - fvmLastOldTot(), - fhPulserFeeTotDnl(NULL), - fhPulserFeeTotInl(NULL), - fhPulserFeeRisCtWideBins(NULL), - fhPulserFeeFalCtWideBins(NULL), - fbEnableMissingEdgeCheck(kFALSE), - fvuLastTotInFtBins(), - fhPulserFeeFtRecoMissRis(NULL), - fhPulserFeeFtRecoMissFal(NULL), - fvuNbRisEdgeEpoch(), - fvuNbFalEdgeEpoch(), - fhPulserFeeExtraRisEp(NULL), - fhPulserFeeExtraFalEp(NULL), - fhPulserFeeExtraEdgesEp(NULL), - fvuFeePrevRisEp(), - fvmFeePrevRis(), - fvuFeePrevFalEp(), - fvmFeePrevFal(), - fhPulserFeeFtExtraEdgeRisA(NULL), - fhPulserFeeFtExtraEdgeFalA(NULL), - fhPulserFeeFtExtraEdgeRisB(NULL), - fhPulserFeeFtExtraEdgeFalB(NULL), - fhPulserFeeGoodTot(NULL), - fhPulserFeeExtraRecoTot(NULL), - fhPulserFeeTotDistCT(), - fvuPrevOldTotEp(), - fvmPrevOldTot(), - fhFtTotSmallDtFeeA(NULL), - fhFtTotSmallDtFeeB(NULL), - fhFtTotBigDtFeeA(NULL), - fhFtTotBigDtFeeB(NULL), - fhFtPrevTotSmallDtFeeA(NULL), - fhFtPrevTotSmallDtFeeB(NULL), - fhFtPrevTotBigDtFeeA(NULL), - fhFtPrevTotBigDtFeeB(NULL), - fvvhChannelsCoinc(), - fdMaxCoincDist(100.0), - fvhGet4MultipleHits(), - fvhGet4DistDoubleHits(), - fvhGet4DistTripleHits(), - fvhGet4DistMultipleHits(), - fvhGet4MultipleHitsVsTot(), - fdMaxDtMultiHit(20.0), - fvbChanSecondHit(), - fvbChanThirdHit(), - fvdChanFirstHitTot(), - fbHistoWriteDone(kFALSE), - fbEnaCalibOutput(kFALSE), - fsCalibOutFoldername(""), - fsCalibFilename(""), - fvhFineTime() -{ -} - -CbmGet4FastMonitor::~CbmGet4FastMonitor() -{ -} - -Bool_t CbmGet4FastMonitor::Init() -{ - LOG(info) << "Initializing"; - - FairRootManager* ioman = FairRootManager::Instance(); - if (ioman == NULL) { - LOG(fatal) << "No FairRootManager instance"; - } -// ioman->Register("Get4RawMessage", "GET4 raw data", fGet4Raw, kTRUE); -// ioman->Register("NxyterRawSyncMessage", "GET4 raw sync data", fGet4RawSync, kTRUE); - - if( 0 >= fuNbRocs || 0 >= fuNbGet4 ) - { - LOG(error) << "CbmGet4FastMonitor::Init => Nb of ROCs or GET4s not defined!!! "; - LOG(error) << "Nb of ROCs:"<< fuNbRocs << " Nb of GET4s : " << fuNbGet4; - LOG(fatal) << "Please use the functions SetRocNb and/or SetGet4Nb before running!!"; - } - - // Initialize TS counter - fulTsNb = 0; - - // At start all ROCs and GET4 are considered "unsynchronized" - // Stay so until the DLM 10 is issued: ~/flesnet/build/sync_frontend - // The GET4 are synchronized after reception of 1st epoch2 with SYNC - fvbRocFeetFirstSyncDlm.resize( fuNbRocs); - fvbRocFeetSyncStart.resize( fuNbRocs); - for( UInt_t uRoc = 0; uRoc < fuNbRocs; uRoc++) - { - fvbRocFeetFirstSyncDlm[uRoc] = kFALSE; - fvbRocFeetSyncStart[uRoc] = kFALSE; - } // for( UInt_t uRoc = 0; uRoc < fuNbRocs; uRoc++) - fvbGet4WaitFirstSync.resize(fuNbGet4); - for( UInt_t uChip = 0; uChip < fuNbGet4; uChip++) - fvbGet4WaitFirstSync[uChip] = kTRUE; - - // Prepare the active chips flags - if( 0 == fvbActiveChips.size() && 0 < fuNbGet4 ) - { - fvbActiveChips.resize(fuNbGet4); - for( UInt_t uChip = 0; uChip < fuNbGet4; uChip++) - fvbActiveChips[uChip] = kTRUE; - } // if( 0 == fvbActiveChips.size() - // Prepare the epoch storing vectors - fvuCurrEpoch.resize( fuNbRocs); - fvuCurrEpochCycle.resize( fuNbRocs); - for( UInt_t uRoc = 0; uRoc < fuNbRocs; uRoc++) - { - fvuCurrEpoch[uRoc] = 0; - fvuCurrEpochCycle[uRoc] = 0; - } // for( UInt_t uRoc = 0; uRoc < fuNbRocs; uRoc++) - fvuCurrEpoch2.resize(fuNbGet4); - fvuCurrEpoch2Cycle.resize(fuNbGet4); - for( UInt_t uChip = 0; uChip < fuNbGet4; uChip++) - { - fvuCurrEpoch2[uChip] = 0; - fvuCurrEpoch2Cycle[uChip] = 0; - } // for( UInt_t uChip = 0; uChip < fuNbGet4; uChip++) - - LOG(info) << "Initializing Histos"; - InitMonitorHistograms(); - LOG(info) << "Initialization done"; - - PrintOptions(); - - return kTRUE; -} - -void CbmGet4FastMonitor::PrintOptions() -{ - LOG(info) << "Nb of ROCs: "<< fuNbRocs << " Nb of GET4s : " << fuNbGet4; - LOG(info) << "TS overlap: "<< fuMsOverlapTs << " MS "; - - LOG(info) << "Monitor mode: "<< fiMode; - - LOG(info) << "Active chips: "; - for( UInt_t iChip = 0; iChip < fuNbGet4; iChip++) - LOG(info) << Form(" %3u", iChip); - LOG(info); - for( UInt_t iChip = 0; iChip < fuNbGet4; iChip++) - LOG(info) << Form(" %3d", static_cast<Int_t> (fvbActiveChips[iChip]) ); - LOG(info) << ""; - - LOG(info) << "Pulser mode: "<< fbPulserMode; - LOG(info) << "Pulser FEE board: "<< fuPulserFee; - if( kTRUE == fbPulserFeeB ) - { - LOG(info) << "Second FEE B board: ON"; - LOG(info) << "Pulser FEE B board: "<< fuPulserFeeB; - } // if( kTRUE == fbPulserFeeB ) - LOG(info) << "Pulser channels: "; - for( UInt_t iChan = 0; iChan < kuNbChanTest; iChan++) - LOG(info) << Form(" %3d", fuPulserChan[iChan] ); - LOG(info) << ""; - - LOG(info) << "Binning evolution plots: "<< fdEvoBinSizeS << " s"; - LOG(info) << "Length evolution plots: "<< fdEvoLengthSec << " s"; - LOG(info) << "MS length: "<< fdMsLengthSec << " s"; - LOG(info) << "24b mode allowed: "<< fbOldReadoutOk; - - LOG(info) << "Max time dist for coincidences: "<< fdMaxCoincDist << " ps"; - LOG(info) << "Max time dist for multiple hits: "<< fdMaxDtMultiHit << " ps"; - - LOG(info) << "Calibration saving enabled: "<< fbEnaCalibOutput; - LOG(info) << "Calibration out folder: "<< fsCalibOutFoldername; - LOG(info) << "Calibration out file: "<< fsCalibFilename; - -} - -void CbmGet4FastMonitor::SetActiveGet4( UInt_t uChipsIndex, Bool_t bActiveFlag) -{ - if( 0 == fvbActiveChips.size() && 0 < fuNbGet4 ) - { - fvbActiveChips.resize(fuNbGet4); - for( UInt_t uChip = 0; uChip < fuNbGet4; uChip++) - fvbActiveChips[uChip] = kTRUE; - } // if( 0 == fvbActiveChips.size() - - if( uChipsIndex < fuNbGet4 ) - fvbActiveChips[uChipsIndex] = bActiveFlag; - else LOG(error)<<" CbmGet4FastMonitor::SetActiveGet4 => Invalid chip index " - << uChipsIndex ; -} - -void CbmGet4FastMonitor::SetPulserChans( - UInt_t inPulserChanA, UInt_t inPulserChanB, UInt_t inPulserChanC, UInt_t inPulserChanD, - UInt_t inPulserChanE, UInt_t inPulserChanF, UInt_t inPulserChanG, UInt_t inPulserChanH, - UInt_t inPulserChanI, UInt_t inPulserChanJ, UInt_t inPulserChanK, UInt_t inPulserChanL, - UInt_t inPulserChanM, UInt_t inPulserChanN, UInt_t inPulserChanO, UInt_t inPulserChanP ) -{ - fuPulserChan[ 0] = inPulserChanA; - fuPulserChan[ 1] = inPulserChanB; - fuPulserChan[ 2] = inPulserChanC; - fuPulserChan[ 3] = inPulserChanD; - fuPulserChan[ 4] = inPulserChanE; - fuPulserChan[ 5] = inPulserChanF; - fuPulserChan[ 6] = inPulserChanG; - fuPulserChan[ 7] = inPulserChanH; - fuPulserChan[ 8] = inPulserChanI; - fuPulserChan[ 9] = inPulserChanJ; - fuPulserChan[10] = inPulserChanK; - fuPulserChan[11] = inPulserChanL; - fuPulserChan[12] = inPulserChanM; - fuPulserChan[13] = inPulserChanN; - fuPulserChan[14] = inPulserChanO; - fuPulserChan[15] = inPulserChanP; -} - -void CbmGet4FastMonitor::SetHistoFilename( TString sNameIn ) -{ - fsHistoFilename = sNameIn; - - LOG(info)<<" CbmGet4FastMonitor::SetHistoFilename => Histograms output file is now \n" - <<fsHistoFilename; -} -Bool_t CbmGet4FastMonitor::DoUnpack(const fles::Timeslice& ts, size_t component) -{ - fulTsNb++; - if( 0 == fiMode || kTRUE == fbVerbose || - (kTRUE == fbDebug && fiDebugTsStart <= fiDebugTsStop && - static_cast<UInt_t> (fiDebugTsStart) <= fulTsNb && - fulTsNb <= static_cast<UInt_t> (fiDebugTsStop) ) ) - LOG(info)<<" ++++++++++++ Ts # "<<fulTsNb; - - if( 2 == fiMode ) - LOG(debug)<<" ++++++++++++ Ts # "<<fulTsNb<<" Start!"; - - // Loop over microslices - fsMaxMsNb = ts.num_microslices(component) - fuMsOverlapTs; - for (size_t m = 0; m < fsMaxMsNb; ++m) - { - fulMsNb = m; - auto msDescriptor = ts.descriptor(component, m); - const uint8_t* msContent = reinterpret_cast<const uint8_t*>(ts.content(component, m)); - - uint32_t offset = 16; - uint32_t local_offset = 0; - const uint8_t* msContent_shifted; - int padding; - - if( 0 == fiMode || kTRUE == fbVerbose ) - LOG(info)<<" ************ Ms # "<<m; - - fuMaxOffset = msDescriptor.size; - - // AdHoc conversion factor for TS number to time - // Work only for 2 links and 1 MS per TS - fhMsSizeEvo->Fill( (fulTsNb/2)*fdMsLengthSec, fuMaxOffset); - - // Loop over the data of one microslice - while (offset < msDescriptor.size) - { - msContent_shifted = &msContent[offset]; - fuOffset = offset; - - // Extract DTM header info - DTM_header cur_DTM_header; - - cur_DTM_header.packet_length = msContent_shifted[0]; - cur_DTM_header.packet_counter = msContent_shifted[1]; - const uint16_t* ROC_ID_pointer = reinterpret_cast<const uint16_t*>(&msContent_shifted[2]); -// cur_DTM_header.ROC_ID = *ROC_ID_pointer; - // TODO: Check if planned behavior - // -> ROC ID increased by 256 per link, 16 bits => only links 1 and 2 easy to use - cur_DTM_header.ROC_ID = (*ROC_ID_pointer) / 256; // ROC ID increased by 256 per link - - uint32_t packageSize = static_cast<uint32_t>(cur_DTM_header.packet_length*2+4); - fuMaxLocalOffset = packageSize; - - // Loop over messages - local_offset = 4; - if( 0 == fiMode || kTRUE == fbVerbose ) - { - // Debug printout - cur_DTM_header.Dump(); - LOG(info)<<" Package Size: "<<packageSize<<" ROC ID: "<<cur_DTM_header.ROC_ID; - while (local_offset < packageSize) - { - fuLocalOffset = local_offset; - get4v1x::Message mess; - uint64_t dataContent = - ( static_cast<uint64_t>( cur_DTM_header.ROC_ID & 0xFFFF) << 48) - + ( static_cast<uint64_t>( (msContent_shifted[local_offset + 0] ) & 0xFF) << 40) - + ( static_cast<uint64_t>( (msContent_shifted[local_offset + 1] ) & 0xFF) << 32) - + ( static_cast<uint64_t>( (msContent_shifted[local_offset + 2] ) & 0xFF) << 24) - + ( static_cast<uint64_t>( (msContent_shifted[local_offset + 3] ) & 0xFF) << 16) - + ( static_cast<uint64_t>( (msContent_shifted[local_offset + 4] ) & 0xFF) << 8) - + ( static_cast<uint64_t>( (msContent_shifted[local_offset + 5] ) & 0xFF)); - mess.setData( dataContent ); - mess.printDataLog(); - - local_offset += 6; // next message - } // while (local_offset < packageSize) - } // if( 0 == fiMode || kTRUE == fbVerbose ) - switch(fiMode) - { - case 0: - { - // debug mode, nothing to do here (printout already done) - break; - } // case 0 - case 1: - { - // Monitor mode, fill histograms - while (local_offset < packageSize) - { - fuLocalOffset = local_offset; - get4v1x::Message mess; - uint64_t dataContent = - ( static_cast<uint64_t>( cur_DTM_header.ROC_ID & 0xFFFF) << 48) - + ( static_cast<uint64_t>( (msContent_shifted[local_offset + 0] ) & 0xFF) << 40) - + ( static_cast<uint64_t>( (msContent_shifted[local_offset + 1] ) & 0xFF) << 32) - + ( static_cast<uint64_t>( (msContent_shifted[local_offset + 2] ) & 0xFF) << 24) - + ( static_cast<uint64_t>( (msContent_shifted[local_offset + 3] ) & 0xFF) << 16) - + ( static_cast<uint64_t>( (msContent_shifted[local_offset + 4] ) & 0xFF) << 8) - + ( static_cast<uint64_t>( (msContent_shifted[local_offset + 5] ) & 0xFF)); - mess.setData( dataContent ); - - if( kTRUE == fbDebug && fiDebugTsStart <= fiDebugTsStop && - static_cast<UInt_t> (fiDebugTsStart) <= fulTsNb && - fulTsNb <= static_cast<UInt_t> (fiDebugTsStop) ) - mess.printDataLog(); - - fhMessageTypePerRoc->Fill( cur_DTM_header.ROC_ID, mess.getMessageType() ); - - switch( mess.getMessageType() ) - { - case get4v1x::MSG_HIT: - { - // This is NXYTER in a GET4 unpacker => ignore - break; - } // case get4v1x::MSG_HIT: - case get4v1x::MSG_EPOCH: - { - // Ignore all messages before RocFeet system SYNC - if (kFALSE == fvbRocFeetSyncStart[cur_DTM_header.ROC_ID] ) - break; - this->MonitorMessage_epoch(mess, msDescriptor.eq_id); - break; - } // case get4v1x::MSG_EPOCH: - case get4v1x::MSG_SYNC: - { - // Ignore all messages before RocFeet system SYNC - if (kFALSE == fvbRocFeetSyncStart[cur_DTM_header.ROC_ID] ) - break; - this->MonitorMessage_sync(mess, msDescriptor.eq_id); - break; - } // case get4v1x::MSG_SYNC: - case get4v1x::MSG_AUX: - { - // Ignore all messages before RocFeet system SYNC - if (kFALSE == fvbRocFeetSyncStart[cur_DTM_header.ROC_ID] ) - break; - this->MonitorMessage_aux(mess, msDescriptor.eq_id); - break; - } // case get4v1x::MSG_AUX: - case get4v1x::MSG_EPOCH2: - { - // Ignore all messages before RocFeet system SYNC - if (kFALSE == fvbRocFeetSyncStart[cur_DTM_header.ROC_ID] ) - break; - this->MonitorMessage_epoch2(mess, msDescriptor.eq_id); - break; - } // case get4v1x::MSG_EPOCH2: - case get4v1x::MSG_GET4: - { - // Ignore all messages before RocFeet system SYNC - if (kFALSE == fvbRocFeetSyncStart[cur_DTM_header.ROC_ID] ) - break; - this->MonitorMessage_get4(mess, msDescriptor.eq_id); - break; - } // case get4v1x::MSG_GET4: - case get4v1x::MSG_SYS: - this->MonitorMessage_sys(mess, msDescriptor.eq_id); - break; - default: - break; - } // switch( mess.getMessageType() ) - local_offset += 6; // next message - } // while (local_offset < packageSize) - break; - } // case 1 - default: - break; - } // switch(fiMode) - - offset += packageSize; - - // shift some more bytes to fit the CbmNet package size - if ((padding = offset % 8) > 0) - { - offset += (8-padding); - } // if ((padding = offset % 8) > 0) - - } // while (offset < msDescriptor.size) - - } // for (size_t m = 0; m < ts.num_microslices(component); ++m) - - FinishUnpack(); - - return kTRUE; -} - -void CbmGet4FastMonitor::FinishUnpack() -{ -} - -void CbmGet4FastMonitor::Reset() -{ -// fGet4Raw->Clear(); -// fGet4RawSync->Clear(); -} - -void CbmGet4FastMonitor::Finish() -{ - if( kFALSE == fbHistoWriteDone ) - { - WriteMonitorHistograms(); - fbHistoWriteDone = kTRUE; - } // if( kFALSE == fbHistoWriteDone ) - else LOG(error)<<"CbmGet4FastMonitor::Finish => WriteMonitorHistograms already called once in this run, therefore ignore it"; - if( kTRUE == fbEnaCalibOutput ) - WriteCalibrationFile(); - DeleteMonitorHistograms(); -} - -//************** Monitor functions *************/ - - -void CbmGet4FastMonitor::InitMonitorHistograms() -{ - // FIXME: maybe changed current folder to TRoot and back - // as for now all histos are placed in the analysis output file - // which leads to problems at Finish - - fhMessageTypePerRoc = new TH2I("hMessageTypePerRoc", - "Nb of message for each type per ROC; ROC #; Type", - fuNbRocs, -0.5, fuNbRocs -0.5, - 16, -0.5, 15.5); - fhMessageTypePerRoc->GetYaxis()->SetBinLabel(1 + get4v1x::MSG_NOP, "NOP"); - fhMessageTypePerRoc->GetYaxis()->SetBinLabel(1 + get4v1x::MSG_HIT, "HIT"); - fhMessageTypePerRoc->GetYaxis()->SetBinLabel(1 + get4v1x::MSG_EPOCH, "EPOCH"); - fhMessageTypePerRoc->GetYaxis()->SetBinLabel(1 + get4v1x::MSG_SYNC, "SYNC"); - fhMessageTypePerRoc->GetYaxis()->SetBinLabel(1 + get4v1x::MSG_AUX, "AUX"); - fhMessageTypePerRoc->GetYaxis()->SetBinLabel(1 + get4v1x::MSG_EPOCH2, "EPOCH2"); - fhMessageTypePerRoc->GetYaxis()->SetBinLabel(1 + get4v1x::MSG_GET4, "GET4"); - fhMessageTypePerRoc->GetYaxis()->SetBinLabel(1 + get4v1x::MSG_SYS, "SYS"); - fhMessageTypePerRoc->GetYaxis()->SetBinLabel(1 + get4v1x::MSG_GET4_SLC, "MSG_GET4_SLC"); - fhMessageTypePerRoc->GetYaxis()->SetBinLabel(1 + get4v1x::MSG_GET4_32B, "MSG_GET4_32B"); - fhMessageTypePerRoc->GetYaxis()->SetBinLabel(1 + 15, "GET4 Hack 32B"); - - fhRocSyncTypePerRoc = new TH2I("hRocSyncTypePerRoc", - "Nb of message for each SYNC type per ROC; ROC # ; SYNC Type", - fuNbRocs, -0.5, fuNbRocs -0.5, - get4v1x::kuMaxSync, -0.5, get4v1x::kuMaxSync - 0.5); - - fhRocAuxTypePerRoc = new TH2I("hRocAuxTypePerRoc", - "Nb of message for each AUX type per ROC; ROC # ; AUX Type", - fuNbRocs, -0.5, fuNbRocs -0.5, - get4v1x::kuMaxAux, -0.5, get4v1x::kuMaxAux - 0.5); - - fhSysMessTypePerRoc = new TH2I("hSysMessTypePerRoc", - "Nb of system message for each type per ROC; ROC # ; System Type", - fuNbRocs, -0.5, fuNbRocs -0.5, - 16, -0.5, 15.5); - fhSysMessTypePerRoc->GetYaxis()->SetBinLabel(1 + get4v1x::SYSMSG_DAQ_START, "DAQ START"); - fhSysMessTypePerRoc->GetYaxis()->SetBinLabel(1 + get4v1x::SYSMSG_DAQ_FINISH, "DAQ FINISH"); - fhSysMessTypePerRoc->GetYaxis()->SetBinLabel(1 + get4v1x::SYSMSG_NX_PARITY, "NX PARITY"); - fhSysMessTypePerRoc->GetYaxis()->SetBinLabel(1 + get4v1x::SYSMSG_SYNC_PARITY, "SYNC PARITY"); - fhSysMessTypePerRoc->GetYaxis()->SetBinLabel(1 + get4v1x::SYSMSG_DAQ_RESUME, "DAQ RESUME"); - fhSysMessTypePerRoc->GetYaxis()->SetBinLabel(1 + get4v1x::SYSMSG_FIFO_RESET, "FIFO RESET"); - fhSysMessTypePerRoc->GetYaxis()->SetBinLabel(1 + get4v1x::SYSMSG_USER, "USER"); - fhSysMessTypePerRoc->GetYaxis()->SetBinLabel(1 + get4v1x::SYSMSG_PCTIME, "PCTIME"); - fhSysMessTypePerRoc->GetYaxis()->SetBinLabel(1 + get4v1x::SYSMSG_ADC, "ADC"); - fhSysMessTypePerRoc->GetYaxis()->SetBinLabel(1 + get4v1x::SYSMSG_PACKETLOST, "PACKET LOST"); - fhSysMessTypePerRoc->GetYaxis()->SetBinLabel(1 + get4v1x::SYSMSG_GET4_EVENT, "GET4 ERROR"); - fhSysMessTypePerRoc->GetYaxis()->SetBinLabel(1 + get4v1x::SYSMSG_CLOSYSYNC_ERROR, "CLOSYSYNC ERROR"); - fhSysMessTypePerRoc->GetYaxis()->SetBinLabel(1 + get4v1x::SYSMSG_TS156_SYNC, "TS156 SYNC"); - fhSysMessTypePerRoc->GetYaxis()->SetBinLabel(1 + 15, "GET4 Hack 32B"); - - fhMessTypePerGet4 = new TH2I("hMessTypePerGet4", - "Nb of message for each type per GET4; GET4 chip # ; Type", - fuNbGet4, -0.5, fuNbGet4 -0.5, - 4, -0.5, 3.5); - fhMessTypePerGet4->GetYaxis()->SetBinLabel(1 + get4v1x::GET4_32B_EPOCH, "EPOCH"); - fhMessTypePerGet4->GetYaxis()->SetBinLabel(1 + get4v1x::GET4_32B_SLCM, "S.C. M"); - fhMessTypePerGet4->GetYaxis()->SetBinLabel(1 + get4v1x::GET4_32B_ERROR, "ERROR"); - fhMessTypePerGet4->GetYaxis()->SetBinLabel(1 + get4v1x::GET4_32B_DATA, "DATA"); - - fhGet4EpochFlags = new TH2I("hGet4EpochFlags", - "Number of epochs with corresponding flag set per GET4; GET4 # ;", - fuNbGet4, -0.5, fuNbGet4 -0.5, - 4, -0.5, 3.5); - fhGet4EpochFlags->GetYaxis()->SetBinLabel(1, "SYNC"); - fhGet4EpochFlags->GetYaxis()->SetBinLabel(2, "Ep. Missmatch"); - fhGet4EpochFlags->GetYaxis()->SetBinLabel(3, "Ep. Loss"); - fhGet4EpochFlags->GetYaxis()->SetBinLabel(4, "Data Loss"); - - fhGet4EpochSyncDist = new TH2I("hGet4EpochSyncDist", - "Distance between epochs with SYNC flag for each GET4; SYNC distance [epochs]; Epochs", - fuNbGet4, -0.5, fuNbGet4 -0.5, - 2*get4v1x::kuSyncCycleSzGet4, -0.5, 2*get4v1x::kuSyncCycleSzGet4 -0.5); - - fhGet4EpochJumps = new TH2I("hGet4EpochJumps", - "Distance between epochs when jump happens for each GET4; GET4 Chip # ; Epoch Jump of [Epoch]", - fuNbGet4, -0.5, fuNbGet4 -0.5, - 401, -200.5, 200.5); - fhGet4BadEpochRatio = new TH1I("hGet4BadEpochRatio", - "Counts of bad (missing, repeated, ...) epoch messages and good ones, mean represents G/T ratio; Epoch Quality; Counts []", - 2, -0.5, 1.5); - fhGet4BadEpRatioChip= new TH2I("hGet4BadEpRatioChip", - "Counts of bad (missing, repeated, ...) epoch messages and good ones, per chip; GET4 Chip # ; Epoch Quality; Counts []", - fuNbGet4, -0.5, fuNbGet4 -0.5, - 2, -0.5, 1.5); - - fhGet4ChanDataCount = new TH1I("hGet4ChanDataCount", - "Data Messages per GET4 channel; GET4 channel # ; Data Count", - fuNbGet4*get4v1x::kuChanPerGet4, -0.5, fuNbGet4*get4v1x::kuChanPerGet4 -0.5); - - fhGet4ChanDllStatus = new TH2I("hGet4ChanDllStatus", - "DLL flag status per GET4 channel; GET4 channel # ; DLL Flag value Count", - fuNbGet4*get4v1x::kuChanPerGet4 , -0.5, fuNbGet4*get4v1x::kuChanPerGet4 -0.5, - 2, -0.5, 1.5); - - fhGet4ChanTotMap = new TH2I("hGet4ChanTotMap", - "TOT values per GET4 channel; GET4 channel # ; TOT value [ns]", - fuNbGet4*get4v1x::kuChanPerGet4, -0.5, fuNbGet4*get4v1x::kuChanPerGet4 -0.5, - 50, 0.0, 50.0); - - fhGet4ChanErrors = new TH2I("hGet4ChanErrors", - "Error messages per GET4 channel; GET4 channel # ; Error", - fuNbGet4*get4v1x::kuChanPerGet4*2, -0.5, fuNbGet4*get4v1x::kuChanPerGet4 -0.5, - 32, -0.5, 31.5); - fhGet4ChanErrors->GetYaxis()->SetBinLabel(1, "0x00: Readout Init "); - fhGet4ChanErrors->GetYaxis()->SetBinLabel(2, "0x01: Sync "); - fhGet4ChanErrors->GetYaxis()->SetBinLabel(3, "0x02: Epoch count sync"); - fhGet4ChanErrors->GetYaxis()->SetBinLabel(4, "0x03: Epoch "); - fhGet4ChanErrors->GetYaxis()->SetBinLabel(5, "0x04: FIFO Write "); - fhGet4ChanErrors->GetYaxis()->SetBinLabel(6, "0x05: Lost event "); - fhGet4ChanErrors->GetYaxis()->SetBinLabel(7, "0x06: Channel state "); - fhGet4ChanErrors->GetYaxis()->SetBinLabel(8, "0x07: Token Ring state"); - fhGet4ChanErrors->GetYaxis()->SetBinLabel(9, "0x08: Token "); - fhGet4ChanErrors->GetYaxis()->SetBinLabel(10, "0x09: Error Readout "); - fhGet4ChanErrors->GetYaxis()->SetBinLabel(11, "0x0a: SPI "); - fhGet4ChanErrors->GetYaxis()->SetBinLabel(12, "0x0b: DLL Lock error "); // <- From GET4 v1.2 - fhGet4ChanErrors->GetYaxis()->SetBinLabel(13, "0x0c: DLL Reset invoc."); // <- From GET4 v1.2 - fhGet4ChanErrors->GetYaxis()->SetBinLabel(14, "0x11: Overwrite "); - fhGet4ChanErrors->GetYaxis()->SetBinLabel(15, "0x12: ToT out of range"); - fhGet4ChanErrors->GetYaxis()->SetBinLabel(16, "0x13: Event Discarded "); - fhGet4ChanErrors->GetYaxis()->SetBinLabel(17, "0x7f: Unknown "); - fhGet4ChanErrors->GetYaxis()->SetBinLabel(18, "Corrupt error or unsupported yet"); - - fhGet4ChanTotOwErrorsProp = new TProfile("hGet4ChanTotOwErrorsProp", - "Percentage of Overwrite Error messages per GET4 channel; GET4 channel # ; Overwrite prop. [\%]", - fuNbGet4*get4v1x::kuChanPerGet4*2, -0.5, fuNbGet4*get4v1x::kuChanPerGet4 -0.5); - fhGet4ChanTotOrErrorsProp = new TProfile("hGet4ChanTotOrErrorsProp", - "Percentage of ToT out of range Error messages per GET4 channel; GET4 channel # ; Overwrite prop. [\%]", - fuNbGet4*get4v1x::kuChanPerGet4*2, -0.5, fuNbGet4*get4v1x::kuChanPerGet4 -0.5); - fhGet4ChanTotEdErrorsProp = new TProfile("hGet4ChanTotEdErrorsProp", - "Percentage of Event Discarded Error messages per GET4 channel; GET4 channel # ; Overwrite prop. [\%]", - fuNbGet4*get4v1x::kuChanPerGet4*2, -0.5, fuNbGet4*get4v1x::kuChanPerGet4 -0.5); - - fhGet4ChanSlowContM = new TH2I("hGet4ChanSlowContM", - "Slow control messages per GET4 channel; GET4 channel # ; Type", - fuNbGet4*get4v1x::kuChanPerGet4*2, -0.5, fuNbGet4*get4v1x::kuChanPerGet4 -0.5, - 4, -0.5, 3.5); - fhGet4ChanSlowContM->GetYaxis()->SetBinLabel(1, "0: Scaler event "); - fhGet4ChanSlowContM->GetYaxis()->SetBinLabel(2, "1: Dead time counter event "); - fhGet4ChanSlowContM->GetYaxis()->SetBinLabel(3, "2: SPI receiver data "); - fhGet4ChanSlowContM->GetYaxis()->SetBinLabel(4, "3: Start message/Hamming Er."); - fhGet4ChanEdgesCounts = new TH2I("hGet4ChanEdgesCounts", - "Detected edges scaler per GET4 channel; GET4 channel # ; Scaler Value [det. edges]", - fuNbGet4*get4v1x::kuChanPerGet4*2, -0.5, fuNbGet4*get4v1x::kuChanPerGet4 -0.5, - 128, -0.5, 127.5); - fhGet4ChanDeadtime = new TH2I("hGet4ChanDeadtime", - "Deadtime per GET4 channel; GET4 channel # ; Deadtime [Clock cycles]", - fuNbGet4*get4v1x::kuChanPerGet4*2, -0.5, fuNbGet4*get4v1x::kuChanPerGet4 -0.5, - 100, -0.5, 999.5); - fhGet4SeuCounter = new TH2I("hGet4SeuCounter", - "SEU count per GET4 ; GET4 channel # ; SEU [events]", - fuNbGet4, -0.5, fuNbGet4 -0.5, - 128, -0.5, 127.5); - - // Time evolution histos - Int_t iNbBinsEvo = fdEvoLengthSec / fdEvoBinSizeS; - // FLIB - fhMsSizeEvo = new TProfile( "hMsSizeEvo", - "Evolution of the size of Microslices; Time [s] ; Mean size [Bytes]", - iNbBinsEvo, -0.5, fdEvoLengthSec - 0.5 ); - // ROC - fvhRocDataCntEvo.resize(fuNbRocs); - fvhRocEpochCntEvo.resize(fuNbRocs); - fvhRocErrorCntEvo.resize(fuNbRocs); - fvhRocTotErrorCntEvo.resize(fuNbRocs); - fvhRocTotErrorCntEvo.resize(fuNbRocs); - fvhRocEpochMissmCntEvo.resize(fuNbRocs); - fvhRocDataLossCntEvo.resize(fuNbRocs); - fvhRocEpochLossCntEvo.resize(fuNbRocs); - for( UInt_t uRoc = 0; uRoc < fuNbRocs; uRoc++) - { - fvhRocDataCntEvo[uRoc] = new TH1I( - Form("hRocDataCntEvo_%03u", uRoc), - Form("Evolution of data rate for ROC #%03d; Time [s] ; Data rate [1/s]", uRoc), - iNbBinsEvo, -0.5, fdEvoLengthSec - 0.5 ); - fvhRocEpochCntEvo[uRoc] = new TH1I( - Form("hRocEpochCntEvo_%03u", uRoc), - Form("Evolution of epoch rate for ROC #%03d; Time [s] ; Epoch rate [1/s]", uRoc), - iNbBinsEvo, -0.5, fdEvoLengthSec - 0.5 ); - fvhRocErrorCntEvo[uRoc] = new TH1I( - Form("hRocErrorCntEvo_%03u", uRoc), - Form("Evolution of error rate for ROC #%03d; Time [s] ; Error rate [1/s]", uRoc), - iNbBinsEvo, -0.5, fdEvoLengthSec - 0.5 ); - fvhRocTotErrorCntEvo[uRoc] = new TH1I( - Form("hRocTotErrorCntEvo_%03u", uRoc), - Form("Evolution of TOT error rate for ROC #%03d; Time [s] ; TOT Error rate [1/s]", uRoc), - iNbBinsEvo, -0.5, fdEvoLengthSec - 0.5 ); - fvhRocEpochMissmCntEvo[uRoc] = new TH1I( - Form("hRocEpochMissmCntEvo_%03u", uRoc), - Form("Evolution of epoch missmatch rate for ROC #%03d; Time [s] ; Epoch missmatch rate [1/s]", uRoc), - iNbBinsEvo, -0.5, fdEvoLengthSec - 0.5 ); - fvhRocDataLossCntEvo[uRoc] = new TH1I( - Form("hRocDataLossCntEvo_%03u", uRoc), - Form("Evolution of data loss rate for ROC #%03d; Time [s] ; Data loss rate [1/s]", uRoc), - iNbBinsEvo, -0.5, fdEvoLengthSec - 0.5 ); - fvhRocEpochLossCntEvo[uRoc] = new TH1I( - Form("hRocEpochLossCntEvo_%03u", uRoc), - Form("Evolution of epoch loss rate for ROC #%03d; Time [s] ; Epoch loss rate [1/s]", uRoc), - iNbBinsEvo, -0.5, fdEvoLengthSec - 0.5 ); - } // for( Int_t uRoc = 0; uRoc < fuNbRocs; uRoc++) - // GET4 - fvhGet4DataCntEvo.resize(fuNbGet4); - fvhGet4ErrorCntEvo.resize(fuNbGet4); - fvhGet4EpochMissmCntEvo.resize(fuNbGet4); - fvhGet4DataLossCntEvo.resize(fuNbGet4); - fvhGet4EpochLossCntEvo.resize(fuNbGet4); - fvhGet4ChDataCntEvo.resize(fuNbGet4); - fvhGet4ChErrorCntEvo.resize(fuNbGet4); - fvhFineTime.resize(fuNbGet4); - for( UInt_t uGet4 = 0; uGet4 < fuNbGet4; uGet4++) - { - if( kTRUE == fvbActiveChips[uGet4] ) - { - fvhGet4DataCntEvo[uGet4] = new TH1I( - Form("hGet4DataCntEvo_%03u", uGet4), - Form("Evolution of data rate for GET4 #%03d; Time [s] ; Data rate [1/s]", uGet4), - iNbBinsEvo, -0.5, fdEvoLengthSec - 0.5 ); - fvhGet4ErrorCntEvo[uGet4] = new TH1I( - Form("hGet4ErrorCntEvo_%03u", uGet4), - Form("Evolution of error rate for GET4 #%03d; Time [s] ; Error rate [1/s]", uGet4), - iNbBinsEvo, -0.5, fdEvoLengthSec - 0.5 ); - fvhGet4EpochMissmCntEvo[uGet4] = new TH1I( - Form("hGet4EpochMissmCntEvo_%03u", uGet4), - Form("Evolution of epoch missmatch rate for GET4 #%03d; Time [s] ; Error missmatch rate [1/s]", uGet4), - iNbBinsEvo, -0.5, fdEvoLengthSec - 0.5 ); - fvhGet4DataLossCntEvo[uGet4] = new TH1I( - Form("hGet4DataLossCntEvo_%03u", uGet4), - Form("Evolution of data loss rate for GET4 #%03d; Time [s] ; Data loss rate [1/s]", uGet4), - iNbBinsEvo, -0.5, fdEvoLengthSec - 0.5 ); - fvhGet4EpochLossCntEvo[uGet4] = new TH1I( - Form("hGet4EpochLossCntEvo_%03u", uGet4), - Form("Evolution of epoch loss rate for GET4 #%03d; Time [s] ; Error loss rate [1/s]", uGet4), - iNbBinsEvo, -0.5, fdEvoLengthSec - 0.5 ); - fvhGet4ChDataCntEvo[uGet4] = new TH2I( - Form("hGet4ChDataCntEvo_%03u", uGet4), - Form("Evolution of data rate for GET4 #%03d; Channel ; Time [s] ; Data rate [1/s]", uGet4), - get4v1x::kuChanPerGet4, -0.5, get4v1x::kuChanPerGet4 -0.5, - iNbBinsEvo, -0.5, fdEvoLengthSec - 0.5 ); - fvhGet4ChErrorCntEvo[uGet4] = new TH2I( - Form("hGet4ChErrorCntEvo_%03u", uGet4), - Form("Evolution of error rate for GET4 #%03d; Channel ; Time [s] ; Error rate [1/s]", uGet4), - get4v1x::kuChanPerGet4, -0.5, get4v1x::kuChanPerGet4 -0.5, - iNbBinsEvo, -0.5, fdEvoLengthSec - 0.5 ); - } // if( kTRUE == fvbActiveChips[uGet4] ) - - // Calibration TDC indexing not compatible with making only for active TDC - if( kTRUE == fbEnaCalibOutput ) - { - fvhFineTime[ uGet4 ].resize(get4v1x::kuChanPerGet4); - for( UInt_t uChan = 0; uChan < get4v1x::kuChanPerGet4; uChan++ ) - { - TString sCalibHistoOutputName = Form("tof_get4_ft_b%03u_ch%03u", - uGet4, uChan ); - fvhFineTime[ uGet4 ][ uChan ] = new TH1I( - sCalibHistoOutputName, - Form("Fine Time distribution for channel %03d in GET4 #%03d; FineTime [bin] ; Counts [1]", - uChan, uGet4), - get4v1x::kuFineCounterSize, -0.5, get4v1x::kuFineCounterSize - 0.5 ); - } // for( UInt_t uChan = 0; uChan < get4v1x::kuChanPerGet4; uChan++ ) - } // if( kTRUE == fbEnaCalibOutput ) - } // for( Int_t uGet4 = 0; uGet4 < fuNbGet4; uGet4++) - // DETECTORS - fvhDetDataCntEvo.resize(kiNbDet); - fvhDetErrorCntEvo.resize(kiNbDet); - fvhDetEpochMissmCntEvo.resize(kiNbDet); - fvhDetDataLossCntEvo.resize(kiNbDet); - fvhDetEpochLossCntEvo.resize(kiNbDet); - for( Int_t iDet = 0; iDet < kiNbDet; iDet++) - { - fvhDetDataCntEvo[iDet] = new TH1I( - Form("hDetDataCntEvo_%s", ksDetName[iDet].Data()), - Form("Evolution of data rate for %s; Time [s] ; Data rate [1/s]", - ksDetName[iDet].Data()), - iNbBinsEvo, -0.5, fdEvoLengthSec - 0.5 ); - fvhDetErrorCntEvo[iDet] = new TH1I( - Form("hDetErrorCntEvo_%s", ksDetName[iDet].Data()), - Form("Evolution of error rate for %s; Time [s] ; Error rate [1/s]", - ksDetName[iDet].Data()), - iNbBinsEvo, -0.5, fdEvoLengthSec - 0.5 ); - fvhDetEpochMissmCntEvo[iDet] = new TH1I( - Form("hDetEpochMissmCntEvo_%s", ksDetName[iDet].Data()), - Form("Evolution of epoch missmatch rate for %s; Time [s] ; Error missmatch rate [1/s]", - ksDetName[iDet].Data()), - iNbBinsEvo, -0.5, fdEvoLengthSec - 0.5 ); - fvhDetDataLossCntEvo[iDet] = new TH1I( - Form("hDetDataLossCntEvo_%s", ksDetName[iDet].Data()), - Form("Evolution of data loss rate for %s; Time [s] ; Data loss rate [1/s]", - ksDetName[iDet].Data()), - iNbBinsEvo, -0.5, fdEvoLengthSec - 0.5 ); - fvhDetEpochLossCntEvo[iDet] = new TH1I( - Form("hDetEpochLossCntEvo_%s", ksDetName[iDet].Data()), - Form("Evolution of epoch loss rate for %s; Time [s] ; Error loss rate [1/s]", - ksDetName[iDet].Data()), - iNbBinsEvo, -0.5, fdEvoLengthSec - 0.5 ); - } // for( Int_t iDet = 0; iDet < kiNbDet; iDet++) - - fhClosedEpSizeEvo = new TProfile( "hClosedEpSizeEvo", - "Evolution of the size of closed epochs; Time [s] ; Mean size rate [Messages]", - iNbBinsEvo, -0.5, fdEvoLengthSec - 0.5 ); - - if( kTRUE == fbPulserMode ) - { - // Full Fee test - UInt_t uHistoFeeIdx = 0; - UInt_t uNbBinsDt = kuNbBinsDt + 1; // To account for extra bin due to shift by 1/2 bin of both ranges - for( UInt_t uChanFeeA = 0; uChanFeeA < kuNbChanFee; uChanFeeA++) - { - for( UInt_t uChanFeeB = uChanFeeA + 1; uChanFeeB < kuNbChanFee; uChanFeeB++) - { - fhTimeResFee[uHistoFeeIdx] = new TH1I( - Form("hTimeResFee_%03u_%03u", uChanFeeA, uChanFeeB), - Form("Time difference for channels %03u and %03u in chosen Fee; DeltaT [ps]; Counts", - uChanFeeA, uChanFeeB), - uNbBinsDt, dMinDt, dMaxDt); - if( kTRUE == fbPulserFeeB ) - { - fhTimeResFeeB[uHistoFeeIdx] = new TH1I( - Form("hTimeResFeeB_%03u_%03u", uChanFeeA, uChanFeeB), - Form("Time difference for channels %03u and %03u in 2nd chosen Fee; DeltaT [ps]; Counts", - uChanFeeA, uChanFeeB), - uNbBinsDt, dMinDt, dMaxDt); - } // if( kTRUE == fbPulserFeeB ) - uHistoFeeIdx++; - } // for any unique pair of channel in chosen Fee - - if( kTRUE == fbPulserFeeB ) - { - for( UInt_t uChanFeeB = 0; uChanFeeB < kuNbChanFee; uChanFeeB++) - fhTimeResFeeAB[uChanFeeA*kuNbChanFee + uChanFeeB] = new TH1I( - Form("hTimeResFeeAB_%03u_%03u", uChanFeeA, uChanFeeB), - Form("Time difference for channels %03u in 1st chosen Fee and %03u in 2nd chosen Fee; DeltaT [ps]; Counts", - uChanFeeA, uChanFeeB), - uNbBinsDt, dMinDt, dMaxDt); - } // if( kTRUE == fbPulserFeeB ) - } // for( UInt_t uChanFeeA = 0; uChanFeeA < kuNbChanFee; uChanFeeA++) - fhTimeRmsAllFee = new TH2D( "hTimeRmsAllFee", - "Time difference RMS for any channels pair in chosen Fee; Ch A; Ch B; [ps]", - kuNbChanFee - 1, -0.5, kuNbChanFee - 1.5, - kuNbChanFee - 1, 0.5, kuNbChanFee - 0.5); - fhTimeResAllFee = new TH2D( "hTimeResAllFee", - "Time resolution for any channels pair in chosen Fee (for single channel); Ch A; Ch B; [ps]", - kuNbChanFee - 1, -0.5, kuNbChanFee - 1.5, - kuNbChanFee - 1, 0.5, kuNbChanFee - 0.5); - - if( kTRUE == fbPulserFeeB ) - { - fhTimeRmsAllFeeB = new TH2D( "hTimeRmsAllFeeB", - "Time difference RMS for any channels pair in 2nd chosen Fee; Ch A; Ch B; [ps]", - kuNbChanFee - 1, -0.5, kuNbChanFee - 1.5, - kuNbChanFee - 1, 0.5, kuNbChanFee - 0.5); - fhTimeResAllFeeB = new TH2D( "hTimeResAllFeeB", - "Time resolution for any channels pair in 2nd chosen Fee (for single channel); Ch A; Ch B; [ps]", - kuNbChanFee - 1, -0.5, kuNbChanFee - 1.5, - kuNbChanFee - 1, 0.5, kuNbChanFee - 0.5); - fhTimeRmsAllFeeAB = new TH2D( "hTimeRmsAllFeeAB", - "Time difference RMS for any channels pair in 1st and 2nd chosen Fee; Ch A FEE A; Ch B FEE B; [ps]", - kuNbChanFee, -0.5, kuNbChanFee - 0.5, - kuNbChanFee, -0.5, kuNbChanFee - 0.5); - fhTimeResAllFeeAB = new TH2D( "hTimeResAllFeeAB", - "Time resolution for any channels pair in 1st and 2nd chosen Fee (for single channel); Ch A FEE A; Ch B FEE B; [ps]", - kuNbChanFee, -0.5, kuNbChanFee - 0.5, - kuNbChanFee, -0.5, kuNbChanFee - 0.5); - } // if( kTRUE == fbPulserFeeB ) - - // Chosen channels test - fhTimeRmsAllPairs = new TH1D( "hTimeRmsAllPairs", - "Time difference RMS for chosen channels pairs; Pair # ; [ps]", - kuNbChanTest - 1, -0.5, kuNbChanTest - 1.5); - fhTimeResAllPairs = new TH1D( "hTimeResAllPairs", - "Time resolution for chosen channels pairs (for single channel); Pair # ; [ps]", - kuNbChanTest - 1, -0.5, kuNbChanTest - 1.5); - fhTimeRmsAllCombi = new TH2D( "hTimeRmsAllCombi", - "Time difference RMS for chosen channels pairs; Ch A; Ch B; [ps]", - kuNbChanComb - 1, -0.5, kuNbChanComb - 1.5, - kuNbChanComb - 1, 0.5, kuNbChanComb - 0.5); - fhTimeResAllCombi = new TH2D( "hTimeResAllCombi", - "Time resolution for chosen channels combinations (for single channel); Ch A; Ch B; [ps]", - kuNbChanComb - 1, -0.5, kuNbChanComb - 1.5, - kuNbChanComb - 1, 0.5, kuNbChanComb - 0.5); - UInt_t uHistoCombiIdx = 0; - for( UInt_t uChanA = 0; uChanA < kuNbChanTest-1; uChanA++) - { - fhTimeResPairs[uChanA] = new TH1I( - Form("hTimeResPairs_%03u_%03u", fuPulserChan[uChanA], fuPulserChan[uChanA+1]), - Form("Time difference for selected channels %03u and %03u; DeltaT [ps]; Counts", - fuPulserChan[uChanA], fuPulserChan[uChanA+1]), - uNbBinsDt, dMinDt, dMaxDt); - fhTimeResPairsTot[2*uChanA] = new TH2I( - Form("hTimeResPairsTot_%03u_%03u_A", fuPulserChan[uChanA], fuPulserChan[uChanA+1]), - Form("Time difference for selected channels %03u and %03u; DeltaT [ps]; TOT %03u [bin]; Counts", - fuPulserChan[uChanA], fuPulserChan[uChanA+1], fuPulserChan[uChanA] ), - uNbBinsDt, dMinDt, dMaxDt, - get4v1x::kuTotCounterSize, 0, get4v1x::kuTotCounterSize ); - fhTimeResPairsTot[2*uChanA+1] = new TH2I( - Form("hTimeResPairsTot_%03u_%03u_B", fuPulserChan[uChanA], fuPulserChan[uChanA+1]), - Form("Time difference for selected channels %03u and %03u; DeltaT [ps]; TOT %03u [bin]; Counts", - fuPulserChan[uChanA], fuPulserChan[uChanA+1], fuPulserChan[uChanA+1] ), - uNbBinsDt, dMinDt, dMaxDt, - get4v1x::kuTotCounterSize, 0, get4v1x::kuTotCounterSize ); - for( UInt_t uChanB = uChanA+1; uChanB < kuNbChanComb; uChanB++) - { - fhTimeResCombi[uHistoCombiIdx] = new TH1I( - Form("hTimeResCombi_%03u_%03u", fuPulserChan[uChanA], fuPulserChan[uChanB]), - Form("Time difference for selected channels %03u and %03u; DeltaT [ps]; Counts", - fuPulserChan[uChanA], fuPulserChan[uChanB]), - uNbBinsDt, dMinDt, dMaxDt); - fhTimeResCombiTot[2*uHistoCombiIdx] = new TH2I( - Form("hTimeResCombiTot_%03u_%03u_A", fuPulserChan[uChanA], fuPulserChan[uChanB]), - Form("Time difference for selected channels %03u and %03u; DeltaT [ps]; TOT %03u [bin]; Counts", - fuPulserChan[uChanA], fuPulserChan[uChanB], fuPulserChan[uChanA]), - uNbBinsDt, dMinDt, dMaxDt, - get4v1x::kuTotCounterSize, 0, get4v1x::kuTotCounterSize ); - fhTimeResCombiTot[2*uHistoCombiIdx+1] = new TH2I( - Form("hTimeResCombiTot_%03u_%03u_B", fuPulserChan[uChanA], fuPulserChan[uChanB]), - Form("Time difference for selected channels %03u and %03u; DeltaT [ps]; TOT %03u [bin]; Counts", - fuPulserChan[uChanA], fuPulserChan[uChanB], fuPulserChan[uChanB]), - uNbBinsDt, dMinDt, dMaxDt, - get4v1x::kuTotCounterSize, 0, get4v1x::kuTotCounterSize ); - - fhTimeResCombiEncA[uHistoCombiIdx] = new TH1I( - Form("hTimeResCombiEncA_%03u_%03u", fuPulserChan[uChanA], fuPulserChan[uChanB]), - Form("Time difference for selected channels %03u and %03u; DeltaT [ps]; Counts", - fuPulserChan[uChanA], fuPulserChan[uChanB]), - uNbBinsDt, dMinDt, dMaxDt); - fhTimeResCombiEncB[uHistoCombiIdx] = new TH1I( - Form("hTimeResCombiEncB_%03u_%03u", fuPulserChan[uChanA], fuPulserChan[uChanB]), - Form("Time difference for selected channels %03u and %03u; DeltaT [ps]; Counts", - fuPulserChan[uChanA], fuPulserChan[uChanB]), - uNbBinsDt, dMinDt, dMaxDt); - - uHistoCombiIdx++; - } // for( UInt_t uChanB = uChanA+1; uChanB < kuNbChanComb; uChanB++) - } // for( UInt_t uChanA = 0; uChanA < kuNbChanTest; uChanA++) - - fhTimeRmsAllCombiEncA = new TH2D( "hTimeRmsAllCombiEncA", - "Time difference RMS for chosen channels pairs, if FT of both in Encoder A; Ch A; Ch B; [ps]", - kuNbChanComb - 1, -0.5, kuNbChanComb - 1.5, - kuNbChanComb - 1, 0.5, kuNbChanComb - 0.5); - fhTimeResAllCombiEncA = new TH2D( "hTimeResAllCombiEncA", - "Time resolution for chosen channels combinations (for single channel), if FT of both in Encoder A; Ch A; Ch B; [ps]", - kuNbChanComb - 1, -0.5, kuNbChanComb - 1.5, - kuNbChanComb - 1, 0.5, kuNbChanComb - 0.5); - fhTimeRmsAllCombiEncB = new TH2D( "hTimeRmsAllCombiEncB", - "Time difference RMS for chosen channels pairs, if FT of both in Encoder B; Ch A; Ch B; [ps]", - kuNbChanComb - 1, -0.5, kuNbChanComb - 1.5, - kuNbChanComb - 1, 0.5, kuNbChanComb - 0.5); - fhTimeResAllCombiEncB= new TH2D( "hTimeResAllCombiEncB", - "Time resolution for chosen channels combinations (for single channel), if FT of both in Encoder B; Ch A; Ch B; [ps]", - kuNbChanComb - 1, -0.5, kuNbChanComb - 1.5, - kuNbChanComb - 1, 0.5, kuNbChanComb - 0.5); - - fhPulserHitDistNs = new TH2D( "hPulserHitDistNs", - "Time Interval between hits for all channels in chosen Fee; Chan # ; Hits interval [ns]", - kuNbChanFee, -0.5, kuNbChanFee - 0.5, - 1000 , 0., 1000.0); - fhPulserHitDistUs = new TH2D( "hPulserHitDistUs", - "Time Interval between hits for all channels in chosen Fee; Chan # ; Hits interval [us]", - kuNbChanFee, -0.5, kuNbChanFee - 0.5, - 1000 , 0., 1000.0); - fhPulserHitDistMs = new TH2D( "hPulserHitDistMs", - "Time Interval between hits for all channels in chosen Fee; Chan # ; Hits interval [ms]", - kuNbChanFee, -0.5, kuNbChanFee - 0.5, - 1000 , 0., 1000.0); - - fhPulserFeeDnl = new TH2D( "hPulserFeeDnl", - "DNL for all channels in chosen FEE board; Chan # ; FT Bin; DNL [bin]", - kuNbChanFee, -0.5, kuNbChanFee - 0.5, - get4v1x::kuFineTime+1 , -0.5, get4v1x::kuFineTime + 0.5); - - fhPulserFeeInl = new TH2D( "hPulserFeeInl", - "INL for all channels in chosen FEE board; Chan # ; FT Bin; INL [bin]", - kuNbChanFee, -0.5, kuNbChanFee - 0.5, - get4v1x::kuFineTime+1 , -0.5, get4v1x::kuFineTime + 0.5); - - fhPulserFeeDistCT.resize( kuNbChipFee ); - for( UInt_t uChip = 0; uChip < kuNbChipFee; uChip ++) - fhPulserFeeDistCT[uChip] = new TH2D( Form("fhPulserFeeDistCT_chip%03u", uChip), - Form("Coarse counter distribution for all channels in chip %03u in chosen FEE board; CT Bin; Chan # ; Counts []", uChip), - get4v1x::kuCoarseCounterSize, -0.5, get4v1x::kuCoarseCounterSize - 0.5, - get4v1x::kuChanPerGet4, -0.5, get4v1x::kuChanPerGet4 - 0.5 ); - - fhFtSmallDtFeeA = new TH2D( "hFtSmallDtFeeA", - "FT of both channels when normal time difference in FEE A; FT Bin Chan 1 ; FT Bin Chan 2; Counts []", - get4v1x::kuFineTime+1 , -0.5, get4v1x::kuFineTime + 0.5, - get4v1x::kuFineTime+1 , -0.5, get4v1x::kuFineTime + 0.5); - fhFtSmallDtFeeB = new TH2D( "hFtSmallDtFeeB", - "FT of both channels when normal time difference in FEE B; FT Bin Chan 1 ; FT Bin Chan 2; Counts []", - get4v1x::kuFineTime+1 , -0.5, get4v1x::kuFineTime + 0.5, - get4v1x::kuFineTime+1 , -0.5, get4v1x::kuFineTime + 0.5); - - fhFtBigDtFeeA = new TH2D( "hFtBigDtFeeA", - "FT of both channels when big time difference in FEE A; FT Bin Chan 1 ; FT Bin Chan 2; Counts []", - get4v1x::kuFineTime+1 , -0.5, get4v1x::kuFineTime + 0.5, - get4v1x::kuFineTime+1 , -0.5, get4v1x::kuFineTime + 0.5); - fhFtBigDtFeeB = new TH2D( "hFtBigDtFeeB", - "FT of both channels when big time difference in FEE B; FT Bin Chan 1 ; FT Bin Chan 2; Counts []", - get4v1x::kuFineTime+1 , -0.5, get4v1x::kuFineTime + 0.5, - get4v1x::kuFineTime+1 , -0.5, get4v1x::kuFineTime + 0.5); - - fhFtPrevSmallDtFeeA = new TH2D( "hFtPrevSmallDtFeeA", - "FT of Previous time for both channels when normal time difference in FEE A; FT Bin Chan 1 ; FT Bin Chan 2; Counts []", - get4v1x::kuFineTime+1 , -0.5, get4v1x::kuFineTime + 0.5, - get4v1x::kuFineTime+1 , -0.5, get4v1x::kuFineTime + 0.5); - fhFtPrevSmallDtFeeB = new TH2D( "hFtPrevSmallDtFeeB", - "FT of Previous time for both channels when normal time difference in FEE B; FT Bin Chan 1 ; FT Bin Chan 2; Counts []", - get4v1x::kuFineTime+1 , -0.5, get4v1x::kuFineTime + 0.5, - get4v1x::kuFineTime+1 , -0.5, get4v1x::kuFineTime + 0.5); - - fhFtPrevBigDtFeeA = new TH2D( "hFtPrevBigDtFeeA", - "FT of Previous time for both channels when big time difference in FEE A; FT Bin Chan 1 ; FT Bin Chan 2; Counts []", - get4v1x::kuFineTime+1 , -0.5, get4v1x::kuFineTime + 0.5, - get4v1x::kuFineTime+1 , -0.5, get4v1x::kuFineTime + 0.5); - fhFtPrevBigDtFeeB = new TH2D( "hFtPrevBigDtFeeB", - "FT of Previous time for both channels when big time difference in FEE B; FT Bin Chan 1 ; FT Bin Chan 2; Counts []", - get4v1x::kuFineTime+1 , -0.5, get4v1x::kuFineTime + 0.5, - get4v1x::kuFineTime+1 , -0.5, get4v1x::kuFineTime + 0.5); - - fhFullCtEpJumpFeeA.resize(kuNbChipFee); - fhEpQualityFirstChFeeA.resize(kuNbChipFee); - for( UInt_t uChipFeeA = 0; uChipFeeA < kuNbChipFee; uChipFeeA++) - { - fhFullCtEpJumpFeeA[uChipFeeA] = new TH2D( Form("hFullCtEpJumpFeeA_%03u", uChipFeeA), - Form("Coarse time for time and tot of last hits when epoch jump, Range is %04u; Coarse Bin Time ; Full Coarse bin TOT; Counts []", - get4v1x::kuCoarseCounterSize), - 400 + 1 , get4v1x::kuCoarseCounterSize - 200 -0.5, get4v1x::kuCoarseCounterSize + 200 + 0.5, - 400 + 1 , get4v1x::kuCoarseCounterSize - 200 -0.5, get4v1x::kuCoarseCounterSize + 200 + 0.5 ); - fhEpQualityFirstChFeeA[uChipFeeA] = new TH2D( Form("hEpQualityFirstChFeeA_%03u", uChipFeeA), - Form("Epoch quality as function of first channel in last pulse, chip %03u; First channel in last pulse ; Epoch quality; Counts []", - uChipFeeA), - get4v1x::kuChanPerGet4, -0.5, get4v1x::kuChanPerGet4 - 0.5, - 2 , -0.5, 1.5 ); - } // for( UInt_t uChipFeeA = 0; uChipFeeA < kuNbChipFee; uChipFeeA++) - fhFullCtEpJumpFeeACh.resize(get4v1x::kuChanPerGet4); - fhFullCtEpJumpFeeAChSort.resize(get4v1x::kuChanPerGet4); - fhFullCtChOrderCh.resize(get4v1x::kuChanPerGet4); - fhFullCtEpQualityCh.resize(get4v1x::kuChanPerGet4); - fhFullCtEpQualityChZoom.resize(get4v1x::kuChanPerGet4); - for( UInt_t uChan = 0; uChan < get4v1x::kuChanPerGet4; uChan++) - { - fhFullCtEpJumpFeeACh[uChan] = new TH2D( Form("hFullCtEpJumpFeeACh_%03u", uChan), - Form("Coarse time for time and tot of last hits when epoch jump, Range is %04u; Coarse Bin Time ; Full Coarse bin TOT; Counts []", - get4v1x::kuCoarseCounterSize), - 400 + 1 , get4v1x::kuCoarseCounterSize - 200 -0.5, get4v1x::kuCoarseCounterSize + 200 + 0.5, - 400 + 1 , get4v1x::kuCoarseCounterSize - 200 -0.5, get4v1x::kuCoarseCounterSize + 200 + 0.5 ); - fhFullCtEpJumpFeeAChSort[uChan] = new TH2D( Form("hFullCtEpJumpFeeAChSort_%03u", uChan), - Form("Coarse time for time and tot of last hits when epoch jump, Range is %04u; Coarse Bin Time ; Full Coarse bin TOT; Counts []", - get4v1x::kuCoarseCounterSize), - 400 + 1 , get4v1x::kuCoarseCounterSize - 200 -0.5, get4v1x::kuCoarseCounterSize + 200 + 0.5, - 400 + 1 , get4v1x::kuCoarseCounterSize - 200 -0.5, get4v1x::kuCoarseCounterSize + 200 + 0.5 ); - - fhFullCtChOrderCh[uChan] = new TH2D( Form("hFullCtChOrderCh_%03u", uChan), - Form("Channel position VS Coarse time for time of last hits when epoch jump, normal Range is %04u, chan %03u; Coarse Bin Time ; Channel order; Counts []", - get4v1x::kuCoarseCounterSize, uChan), - 400 + 1 , get4v1x::kuCoarseCounterSize - 200 -0.5, get4v1x::kuCoarseCounterSize + 200 + 0.5, - get4v1x::kuChanPerGet4 , -0.5, get4v1x::kuChanPerGet4 - 0.5 ); - fhFullCtEpQualityCh[uChan] = new TH2D( Form("hFullCtEpQualityCh_%03u", uChan), - Form("Epoch quality VS Coarse time for time of last hits, normal Range is %04u, chan %03u; Coarse Bin Time ; Epoch Quality; Counts []", - get4v1x::kuCoarseCounterSize, uChan), - (get4v1x::kuCoarseCounterSize + 24)/100 , -0.5, get4v1x::kuCoarseCounterSize + 24 - 0.5, - 2, -0.5, 1.5 ); - fhFullCtEpQualityChZoom[uChan] = new TH2D( Form("hFullCtEpQualityChZoom_%03u", uChan), - Form("Epoch quality VS Coarse time for time of last hits, normal Range is %04u, chan %03u; Coarse Bin Time ; Epoch Quality; Counts []", - get4v1x::kuCoarseCounterSize, uChan), -// 200, get4v1x::kuCoarseCounterSize - 200 -0.5, get4v1x::kuCoarseCounterSize - 0.5, - get4v1x::kuCoarseCounterSize, -0.5, get4v1x::kuCoarseCounterSize - 0.5, - 2, -0.5, 1.5 ); - } - fvChanOrder.resize(kuNbChipFee); - fhFullCtEpJumpFeeAChOrder = new TH2D( "hFullCtEpJumpFeeAChOrder", - "Get4 channels time order when epoch jump found; Channel Order ; Get4 channel; Counts []", - get4v1x::kuChanPerGet4 , -0.5, get4v1x::kuChanPerGet4 - 0.5, - get4v1x::kuChanPerGet4 , -0.5, get4v1x::kuChanPerGet4 - 0.5); - } // if( kTRUE == fbPulserMode ) - - if( kTRUE == fbOldReadoutOk ) - { - fhGet4ChanTotCount = new TH1I("hGet4ChanTotCount", - "Data Messages per GET4 TOT channel; GET4 channel # ; Data Count", - fuNbGet4*get4v1x::kuChanPerGet4, -0.5, fuNbGet4*get4v1x::kuChanPerGet4 -0.5); - - fhPulserFeeTotDnl = new TH2D( "hPulserFeeTotDnl", - "DNL for all TOT channels in chosen FEE board; Chan # ; FT Bin; DNL [bin]", - kuNbChanFee, -0.5, kuNbChanFee - 0.5, - get4v1x::kuFineTime+1 , -0.5, get4v1x::kuFineTime + 0.5); - - fhPulserFeeTotInl = new TH2D( "hPulserFeeTotInl", - "INL for all TOT channels in chosen FEE board; Chan # ; FT Bin; INL [bin]", - kuNbChanFee, -0.5, kuNbChanFee - 0.5, - get4v1x::kuFineTime+1 , -0.5, get4v1x::kuFineTime + 0.5); - - fhPulserFeeRisCtWideBins = new TH2D( "hPulserFeeRisCtWideBins", - "CT for all Rising edge channels in chosen FEE board; Chan # ; CT Bin; counts []", - kuNbChanFee, -0.5, kuNbChanFee - 0.5, - get4v1x::kuCoarseCounterSize/10 + 1, -5, get4v1x::kuCoarseCounterSize + 5); - fhPulserFeeFalCtWideBins = new TH2D( "hPulserFeeFalCtWideBins", - "CT for all Falling edge channels in chosen FEE board; Chan # ; CT Bin; counts []", - kuNbChanFee, -0.5, kuNbChanFee - 0.5, - get4v1x::kuCoarseCounterSize/10 + 1, -5, get4v1x::kuCoarseCounterSize + 5); - - if( kTRUE == fbEnableMissingEdgeCheck) - { - fvuLastTotInFtBins.resize( kuNbChanFee ); - fvuNbRisEdgeEpoch.resize( kuNbChanFee ); - fvuNbFalEdgeEpoch.resize( kuNbChanFee ); - fvuFeePrevRisEp.resize( kuNbChanFee ); - fvmFeePrevRis.resize( kuNbChanFee ); - fvuFeePrevFalEp.resize( kuNbChanFee ); - fvmFeePrevFal.resize( kuNbChanFee ); - for( UInt_t uChan = 0; uChan < kuNbChanFee; uChan ++) - { - fvuLastTotInFtBins[uChan] = 0; - fvuNbRisEdgeEpoch[uChan] = 0; - fvuNbFalEdgeEpoch[uChan] = 0; - fvuFeePrevRisEp[uChan] = 0; - fvuFeePrevFalEp[uChan] = 0; - } - fhPulserFeeFtRecoMissRis = new TH2D( "hPulserFeeFtRecoMissRis", - "Reconstructed FT of missing rising edges in chosen FEE board; Chan # ; FT Bin; Counts []", - kuNbChanFee, -0.5, kuNbChanFee - 0.5, - get4v1x::kuFineTime+1 , -0.5, get4v1x::kuFineTime + 0.5); - fhPulserFeeFtRecoMissFal = new TH2D( "hPulserFeeFtRecoMissFal", - "Reconstructed FT of missing rising edges in chosen FEE board; Chan # ; FT Bin; Counts []", - kuNbChanFee, -0.5, kuNbChanFee - 0.5, - get4v1x::kuFineTime+1 , -0.5, get4v1x::kuFineTime + 0.5); - - fhPulserFeeExtraRisEp = new TH2D( "hPulserFeeExtraRisEp", - "Number of extra rising edges per epoch in chosen FEE board; Chan # ; Nb Rising edge; Counts []", - kuNbChanFee, -0.5, kuNbChanFee - 0.5, - 10 , 1.5, 11.5); - fhPulserFeeExtraFalEp = new TH2D( "hPulserFeeExtraFalEp", - "Number of extra falling edges per epoch in chosen FEE board; Chan # ; Nb Falling edge; Counts []", - kuNbChanFee, -0.5, kuNbChanFee - 0.5, - 10 , 1.5, 11.5); - fhPulserFeeExtraEdgesEp = new TH2D( "hPulserFeeExtraEdgesEp", - "Number of extra edges per epoch in chosen FEE board; Chan (R, F)# ; Nb edges; Counts []", - 2*kuNbChanFee, -0.5, kuNbChanFee - 0.5, - 10 , 1.5, 11.5); - - fhPulserFeeFtExtraEdgeRisA = new TH2D( "hPulserFeeFtExtraEdgeRisA", - "When extra edge message, FT of first rising edge message in chosen FEE board; Chan # ; FT Bin; Counts []", - kuNbChanFee, -0.5, kuNbChanFee - 0.5, - get4v1x::kuFineTime+1 , -0.5, get4v1x::kuFineTime + 0.5); - fhPulserFeeFtExtraEdgeFalA = new TH2D( "hPulserFeeFtExtraEdgeFalA", - "When extra edge message, FT of first falling edge message in chosen FEE board; Chan # ; FT Bin; Counts []", - kuNbChanFee, -0.5, kuNbChanFee - 0.5, - get4v1x::kuFineTime+1 , -0.5, get4v1x::kuFineTime + 0.5); - fhPulserFeeFtExtraEdgeRisB = new TH2D( "hPulserFeeFtExtraEdgeRisB", - "When extra edge message, FT of second rising edge message in chosen FEE board; Chan # ; FT Bin; Counts []", - kuNbChanFee, -0.5, kuNbChanFee - 0.5, - get4v1x::kuFineTime+1 , -0.5, get4v1x::kuFineTime + 0.5); - fhPulserFeeFtExtraEdgeFalB = new TH2D( "hPulserFeeFtExtraEdgeFalB", - "When extra edge message, FT of second falling edge message in chosen FEE board; Chan # ; FT Bin; Counts []", - kuNbChanFee, -0.5, kuNbChanFee - 0.5, - get4v1x::kuFineTime+1 , -0.5, get4v1x::kuFineTime + 0.5); - - fhPulserFeeGoodTot = new TH2D( "hPulserFeeGoodTot", - "TOT distrib for good pulses in chosen FEE board; Chan # ; Tot [FT Bin]; Counts []", - kuNbChanFee, -0.5, kuNbChanFee - 0.5, - get4v1x::kuFineTime+1 , -0.5, get4v1x::kuFineTime + 0.5); - fhPulserFeeExtraRecoTot = new TH2D( "hPulserFeeExtraRecoTot", - "When extra edge message, reconstructed TOT, for channels in chosen FEE board; Chan # ; TOT reco [Bin]; Counts []", - kuNbChanFee, -0.5, kuNbChanFee - 0.5, - get4v1x::kuFineTime+1 , -0.5, get4v1x::kuFineTime + 0.5); - - } // if( kTRUE == fbEnableMissingEdgeCheck) - - fhPulserFeeTotDistCT.resize( kuNbChipFee ); - for( UInt_t uChip = 0; uChip < kuNbChipFee; uChip ++) - fhPulserFeeTotDistCT[uChip] = new TH2D( Form("fhPulserFeeTotDistCT_chip%03u", uChip), - Form("Coarse counter distribution for all channels in chip %03u in chosen FEE board; CT Bin; Chan # ; Counts []", uChip), - get4v1x::kuCoarseCounterSize, -0.5, get4v1x::kuCoarseCounterSize - 0.5, - get4v1x::kuChanPerGet4, -0.5, get4v1x::kuChanPerGet4 - 0.5 ); - - fhFtTotSmallDtFeeA = new TH2D( "hFtTotSmallDtFeeA", - "FT of Tot for both channels when normal time difference in FEE A; FT Bin Chan 1 ; FT Bin Chan 2; Counts []", - get4v1x::kuFineTime+1 , -0.5, get4v1x::kuFineTime + 0.5, - get4v1x::kuFineTime+1 , -0.5, get4v1x::kuFineTime + 0.5); - fhFtTotSmallDtFeeB = new TH2D( "hFtTotSmallDtFeeB", - "FT of Tot for both channels when normal time difference in FEE B; FT Bin Chan 1 ; FT Bin Chan 2; Counts []", - get4v1x::kuFineTime+1 , -0.5, get4v1x::kuFineTime + 0.5, - get4v1x::kuFineTime+1 , -0.5, get4v1x::kuFineTime + 0.5); - - fhFtTotBigDtFeeA = new TH2D( "hFtTotBigDtFeeA", - "FT of Tot for both channels when big time difference in FEE A; FT Bin Chan 1 ; FT Bin Chan 2; Counts []", - get4v1x::kuFineTime+1 , -0.5, get4v1x::kuFineTime + 0.5, - get4v1x::kuFineTime+1 , -0.5, get4v1x::kuFineTime + 0.5); - fhFtTotBigDtFeeB = new TH2D( "hFtTotBigDtFeeB", - "FT of Tot for both channels when big time difference in FEE B; FT Bin Chan 1 ; FT Bin Chan 2; Counts []", - get4v1x::kuFineTime+1 , -0.5, get4v1x::kuFineTime + 0.5, - get4v1x::kuFineTime+1 , -0.5, get4v1x::kuFineTime + 0.5); - - fhFtPrevTotSmallDtFeeA = new TH2D( "hFtPrevTotSmallDtFeeA", - "FT of Previous Tot for both channels when normal time difference in FEE A; FT Bin Chan 1 ; FT Bin Chan 2; Counts []", - get4v1x::kuFineTime+1 , -0.5, get4v1x::kuFineTime + 0.5, - get4v1x::kuFineTime+1 , -0.5, get4v1x::kuFineTime + 0.5); - fhFtPrevTotSmallDtFeeB = new TH2D( "hFtPrevTotSmallDtFeeB", - "FT of Previous Tot for both channels when normal time difference in FEE B; FT Bin Chan 1 ; FT Bin Chan 2; Counts []", - get4v1x::kuFineTime+1 , -0.5, get4v1x::kuFineTime + 0.5, - get4v1x::kuFineTime+1 , -0.5, get4v1x::kuFineTime + 0.5); - - fhFtPrevTotBigDtFeeA = new TH2D( "hFtPrevTotBigDtFeeA", - "FT of Previous Tot for both channels when big time difference in FEE A; FT Bin Chan 1 ; FT Bin Chan 2; Counts []", - get4v1x::kuFineTime+1 , -0.5, get4v1x::kuFineTime + 0.5, - get4v1x::kuFineTime+1 , -0.5, get4v1x::kuFineTime + 0.5); - fhFtPrevTotBigDtFeeB = new TH2D( "hFtPrevTotBigDtFeeB", - "FT of Previous Tot for both channels when big time difference in FEE B; FT Bin Chan 1 ; FT Bin Chan 2; Counts []", - get4v1x::kuFineTime+1 , -0.5, get4v1x::kuFineTime + 0.5, - get4v1x::kuFineTime+1 , -0.5, get4v1x::kuFineTime + 0.5); - } // if( kTRUE == fbOldReadoutOk ) - - // Prepare the vector storing the hit data for time diff calculation - fvuLastHitEp.resize( fuNbGet4 * get4v1x::kuChanPerGet4); - fvmLastHit.resize( fuNbGet4 * get4v1x::kuChanPerGet4); - fvuPrevHitEp.resize( fuNbGet4 * get4v1x::kuChanPerGet4); - fvmPrevHit.resize( fuNbGet4 * get4v1x::kuChanPerGet4); - if( kTRUE == fbOldReadoutOk ) - { - fvuLastOldTotEp.resize( fuNbGet4 * get4v1x::kuChanPerGet4); - fvmLastOldTot.resize( fuNbGet4 * get4v1x::kuChanPerGet4); - fvuPrevOldTotEp.resize( fuNbGet4 * get4v1x::kuChanPerGet4); - fvmPrevOldTot.resize( fuNbGet4 * get4v1x::kuChanPerGet4); - } // if( kTRUE == fbOldReadoutOk ) - - // Now clear the hits - for( UInt_t uChan = 0; uChan < fuNbGet4 * get4v1x::kuChanPerGet4; uChan++) - { - fvuLastHitEp[uChan] = 0; - fvmLastHit[uChan].reset(); - fvuPrevHitEp[uChan] = 0; - fvmPrevHit[uChan].reset(); - if( kTRUE == fbOldReadoutOk ) - { - fvuLastOldTotEp[uChan] = 0; - fvmLastOldTot[uChan].reset(); - fvuPrevOldTotEp[uChan] = 0; - fvmPrevOldTot[uChan].reset(); - } // if( kTRUE == fbOldReadoutOk ) - } // for( UInt_t uChan = 0; uChan < fuNbGet4 * get4v1x::kuChanPerGet4; uChan++) - - fuNbFee = fuNbGet4 / get4v1x::kuGet4PerFee; - LOG(info) << "Nb FEE boards: " <<fuNbFee; - fvvhChannelsCoinc.resize(fuNbFee); - for( UInt_t uFeeA = 0; uFeeA < fuNbFee; uFeeA++) - { - LOG(info) << uFeeA << " / " <<fvvhChannelsCoinc.size(); -// fvvhChannelsCoinc[uFeeA].resize( fuNbFee - uFeeA); // Pb: index start at 0 of course! - fvvhChannelsCoinc[uFeeA].resize( fuNbFee ); // TODO: stupid but faster to code, find better way - for( UInt_t uFeeB = uFeeA; uFeeB < fuNbFee; uFeeB++) - { - LOG(info) << uFeeA << " / " <<fvvhChannelsCoinc.size() << " " - << uFeeB << " / " <<fvvhChannelsCoinc[uFeeA].size(); - fvvhChannelsCoinc[uFeeA][uFeeB] = - new TH2D( Form("hChannelsCoinc_%03u_%03u", uFeeA, uFeeB), - Form("Coincidence between FEE %3u and %3u; Ch FEE %3u ; Ch FEE %3u;", - uFeeA, uFeeB, uFeeA, uFeeB), - get4v1x::kuChanPerFee, -0.5, get4v1x::kuChanPerFee - 0.5, - get4v1x::kuChanPerFee, -0.5, get4v1x::kuChanPerFee - 0.5); - } - } // for( UInt_t uFee = 0; uFee < fuNbFee; uFee++) - - // Multiple hits (reflections, ...) detection - if( 1 == fiMode ) - { - fvhGet4MultipleHits.resize(fuNbGet4); - fvhGet4DistDoubleHits.resize(fuNbGet4); - fvhGet4DistTripleHits.resize(fuNbGet4); - fvhGet4DistMultipleHits.resize(fuNbGet4); - fvhGet4MultipleHitsVsTot.resize(fuNbGet4); - fvbChanSecondHit.resize(fuNbGet4); - fvbChanThirdHit.resize(fuNbGet4); - fvdChanFirstHitTot.resize(fuNbGet4); - for( UInt_t uGet4 = 0; uGet4 < fuNbGet4; uGet4++) - { - if( kTRUE == fvbActiveChips[uGet4] ) - { - fvhGet4MultipleHits[uGet4] = new TH2I( - Form("hGet4MultipleHits_%03u", uGet4), - Form("Multiple hits for GET4 #%03d; Channel ; Close hit # [1]; Counts[1]", uGet4), - get4v1x::kuChanPerGet4, -0.5, get4v1x::kuChanPerGet4 -0.5, - 4, 0.5, 4.5 ); - fvhGet4DistDoubleHits[uGet4] = new TH2I( - Form("hGet4DistDoubleHits_%03u", uGet4), - Form("Time dist between 1st and 2nd hit for GET4 #%03d; Channel ; Time dist [ps]; Counts[1]", uGet4), - get4v1x::kuChanPerGet4, -0.5, get4v1x::kuChanPerGet4 -0.5, - static_cast<Int_t>(fdMaxDtMultiHit/100.0), 0.0, fdMaxDtMultiHit ); - fvhGet4DistTripleHits[uGet4] = new TH2I( - Form("hGet4DistTripleHits_%03u", uGet4), - Form("Time dist between 2nd and 3rd hit for GET4 #%03d; Channel ; Time dist [ps]; Counts[1]", uGet4), - get4v1x::kuChanPerGet4, -0.5, get4v1x::kuChanPerGet4 -0.5, - static_cast<Int_t>(fdMaxDtMultiHit/100.0), 0.0, fdMaxDtMultiHit ); - fvhGet4DistMultipleHits[uGet4] = new TH2I( - Form("hGet4DistMultipleHits_%03u", uGet4), - Form("Time dist between hits after 3rd one for GET4 #%03d; Channel ; Time dist [ps]; Counts[1]", uGet4), - get4v1x::kuChanPerGet4, -0.5, get4v1x::kuChanPerGet4 -0.5, - static_cast<Int_t>(fdMaxDtMultiHit/100.0), 0.0, fdMaxDtMultiHit ); - fvbChanSecondHit[uGet4].resize(get4v1x::kuChanPerGet4, kFALSE); - fvbChanThirdHit[uGet4].resize(get4v1x::kuChanPerGet4, kFALSE); - - fvhGet4MultipleHitsVsTot[uGet4] = new TH2I( - Form("hGet4MultipleHitsVsTot_%03u", uGet4), - Form("Multiple hits for GET4 #%03d; TOT [ns] ; Close hit # [1]; Counts[1]", uGet4), - 26, 0.0, 26.0, - 4, 0.5, 4.5 ); - fvdChanFirstHitTot[uGet4].resize(get4v1x::kuChanPerGet4, 0.0); - } // if( kTRUE == fvbActiveChips[uGet4] ) - } // for( UInt_t uGet4 = 0; uGet4 < fuNbGet4; uGet4++) - } // if( 1 == fiMode ) -} -void CbmGet4FastMonitor::FillMonitorHistograms() -{ -} -void CbmGet4FastMonitor::WriteMonitorHistograms() -{ - TDirectory * oldir = gDirectory; - TFile *fHist; - fHist = new TFile( fsHistoFilename,"RECREATE"); - - LOG(info)<<" Saving monitor histograms to : "<<fsHistoFilename; - - fHist->cd(); - - fhMessageTypePerRoc->Write(); - fhRocSyncTypePerRoc->Write(); - fhRocAuxTypePerRoc ->Write(); - fhSysMessTypePerRoc->Write(); - fhMessTypePerGet4 ->Write(); - fhGet4EpochFlags ->Write(); - fhGet4EpochSyncDist->Write(); - fhGet4EpochJumps ->Write(); - fhGet4BadEpRatioChip->Write(); - fhGet4BadEpochRatio->Write(); - fhGet4ChanDataCount->Write(); - fhGet4ChanDllStatus->Write(); - fhGet4ChanTotMap ->Write(); - fhGet4ChanErrors ->Write(); - fhGet4ChanTotOwErrorsProp->Write(); - fhGet4ChanTotOrErrorsProp->Write(); - fhGet4ChanTotEdErrorsProp->Write(); - fhGet4ChanSlowContM->Write(); - fhGet4ChanEdgesCounts->Write(); - fhGet4ChanDeadtime->Write(); - fhGet4SeuCounter->Write(); - - fhMsSizeEvo->Write(); - for( UInt_t uRoc = 0; uRoc < fuNbRocs; uRoc++) - { - // FIXME: problem with scale function: on at least 1 computer it acts as if the - // "width" option was given!!!!!!!! - fvhRocDataCntEvo[uRoc] ->Scale( 1/fdEvoBinSizeS ); // Weight factor to account for bin size in s - fvhRocEpochCntEvo[uRoc] ->Scale( 1/fdEvoBinSizeS ); // Weight factor to account for bin size in s - fvhRocErrorCntEvo[uRoc] ->Scale( 1/fdEvoBinSizeS ); // Weight factor to account for bin size in s - fvhRocTotErrorCntEvo[uRoc] ->Scale( 1/fdEvoBinSizeS ); // Weight factor to account for bin size in s - fvhRocEpochMissmCntEvo[uRoc]->Scale( 1/fdEvoBinSizeS ); // Weight factor to account for bin size in s - fvhRocDataLossCntEvo[uRoc] ->Scale( 1/fdEvoBinSizeS ); // Weight factor to account for bin size in s - fvhRocEpochLossCntEvo[uRoc]->Scale( 1/fdEvoBinSizeS ); // Weight factor to account for bin size in s - fvhRocDataCntEvo[uRoc] ->Write(); - fvhRocEpochCntEvo[uRoc] ->Write(); - fvhRocErrorCntEvo[uRoc] ->Write(); - fvhRocTotErrorCntEvo[uRoc] ->Write(); - fvhRocEpochMissmCntEvo[uRoc]->Write(); - fvhRocDataLossCntEvo[uRoc] ->Write(); - fvhRocEpochLossCntEvo[uRoc]->Write(); - } // for( Int_t uRoc = 0; uRoc < fuNbRocs; uRoc++) - // GET4 - for( UInt_t uGet4 = 0; uGet4 < fuNbGet4; uGet4++) - if( kTRUE == fvbActiveChips[uGet4] ) - { - fvhGet4DataCntEvo[uGet4] ->Scale( 1/fdEvoBinSizeS ); // Weight factor to account for bin size in s - fvhGet4ErrorCntEvo[uGet4] ->Scale( 1/fdEvoBinSizeS ); // Weight factor to account for bin size in s - fvhGet4EpochMissmCntEvo[uGet4]->Scale( 1/fdEvoBinSizeS ); // Weight factor to account for bin size in s - fvhGet4DataLossCntEvo[uGet4] ->Scale( 1/fdEvoBinSizeS ); // Weight factor to account for bin size in s - fvhGet4EpochLossCntEvo[uGet4]->Scale( 1/fdEvoBinSizeS ); // Weight factor to account for bin size in s - fvhGet4ChDataCntEvo[uGet4] ->Scale( 1/fdEvoBinSizeS ); // Weight factor to account for bin size in s - fvhGet4ChErrorCntEvo[uGet4] ->Scale( 1/fdEvoBinSizeS ); // Weight factor to account for bin size in s - fvhGet4DataCntEvo[uGet4] ->Write(); - fvhGet4ErrorCntEvo[uGet4] ->Write(); - fvhGet4EpochMissmCntEvo[uGet4]->Write(); - fvhGet4DataLossCntEvo[uGet4] ->Write(); - fvhGet4EpochLossCntEvo[uGet4]->Write(); - fvhGet4ChDataCntEvo[uGet4] ->Write(); - fvhGet4ChErrorCntEvo[uGet4] ->Write(); - } // for( Int_t uGet4 = 0; uGet4 < fuNbGet4; uGet4++) - // DETECTORS - for( Int_t iDet = 0; iDet < kiNbDet; iDet++) - { - fvhDetDataCntEvo[iDet] ->Scale( 1/fdEvoBinSizeS ); // Weight factor to account for bin size in s - fvhDetErrorCntEvo[iDet] ->Scale( 1/fdEvoBinSizeS ); // Weight factor to account for bin size in s - fvhDetEpochMissmCntEvo[iDet]->Scale( 1/fdEvoBinSizeS ); // Weight factor to account for bin size in s - fvhDetDataLossCntEvo[iDet] ->Scale( 1/fdEvoBinSizeS ); // Weight factor to account for bin size in s - fvhDetEpochLossCntEvo[iDet]->Scale( 1/fdEvoBinSizeS ); // Weight factor to account for bin size in s - fvhDetDataCntEvo[iDet] ->Write(); - fvhDetErrorCntEvo[iDet] ->Write(); - fvhDetEpochMissmCntEvo[iDet]->Write(); - fvhDetDataLossCntEvo[iDet] ->Write(); - fvhDetEpochLossCntEvo[iDet]->Write(); - } // for( Int_t iDet = 0; iDet < kiNbDet; iDet++) - fhClosedEpSizeEvo->Write(); - - if( kTRUE == fbPulserMode ) - { - // Reset summary histograms for safety - fhTimeRmsAllFee->Reset(); - fhTimeResAllFee->Reset(); - if( kTRUE == fbPulserFeeB ) - { - fhTimeRmsAllFeeB->Reset(); - fhTimeResAllFeeB->Reset(); - fhTimeRmsAllFeeAB->Reset(); - fhTimeResAllFeeAB->Reset(); - } // if( kTRUE == fbPulserFeeB ) - - // First make a gauss fit to obtain the time resolution data - // for all Fee channels pairs - UInt_t uHistoFeeIdx = 0; - UInt_t uHistoFeeIdxB = 0; - TF1 *fitFunc[kuNbChanFee*(kuNbChanFee-1)/2]; - TF1 *fitFuncB[kuNbChanFee*(kuNbChanFee-1)/2]; - TF1 *fitFuncAB[kuNbChanFee*kuNbChanFee]; - for( UInt_t uChanFeeA = 0; uChanFeeA < kuNbChanFee; uChanFeeA++) - { - TString sFitRes = ""; - for( UInt_t uChanFeeB = uChanFeeA + 1; uChanFeeB < kuNbChanFee; uChanFeeB++) - { - Double_t dRes = 0.0; - - // No need to fit if not data in histo - if( 0 == fhTimeResFee[uHistoFeeIdx]->Integral() ) - { - LOG(debug)<<" FEE histo empty: "<<uHistoFeeIdx<<" " - <<uChanFeeA<<" "<<uChanFeeB; - uHistoFeeIdx++; - continue; - } // if( 0 == fhTimeResFee[uHistoFeeIdx]->Integral() ) - - Double_t dFitLimit = fhTimeResFee[uHistoFeeIdx]->GetRMS(); - if( dFitLimit < get4v1x::kdBinSize ) - dFitLimit = get4v1x::kdBinSize; - - fitFunc[uHistoFeeIdx] = new TF1( Form("f_%03d_%03d",uChanFeeA,uChanFeeB), "gaus", - fhTimeResFee[uHistoFeeIdx]->GetMean() - 5*dFitLimit , - fhTimeResFee[uHistoFeeIdx]->GetMean() + 5*dFitLimit); - // Fix the Mean fit value around the Histogram Mean - fitFunc[uHistoFeeIdx]->SetParameter( 0, fhTimeResFee[uHistoFeeIdx]->Integral()); - fitFunc[uHistoFeeIdx]->FixParameter( 1, fhTimeResFee[uHistoFeeIdx]->GetMean() ); - fitFunc[uHistoFeeIdx]->SetParameter( 2, 2*dFitLimit ); -// fitFunc[uHistoFeeIdx]->SetParLimits(1, -// fhTimeResFee[uHistoFeeIdx]->GetMean() - 3, -// fhTimeResFee[uHistoFeeIdx]->GetMean() + 3 ); - - // Using integral instead of bin center seems to lead to unrealistic values => no "I" -// fhTimeResFee[uHistoFeeIdx]->Fit( Form("f_%03d_%03d",uChanFeeA,uChanFeeB), "IQRM0"); - fhTimeResFee[uHistoFeeIdx]->Fit( Form("f_%03d_%03d",uChanFeeA,uChanFeeB), "QRM0"); - - dRes = fitFunc[uHistoFeeIdx]->GetParameter(2); - - // If needed uncomment for debugging - //(WARNING: this adds 1024 histos to the file!) -// fhTimeResFee[uHistoFeeIdx]->Write(); - - delete fitFunc[uHistoFeeIdx]; - - fhTimeRmsAllFee->Fill(uChanFeeA, uChanFeeB, fhTimeResFee[uHistoFeeIdx]->GetRMS() ); - fhTimeResAllFee->Fill(uChanFeeA, uChanFeeB, dRes/TMath::Sqrt2() ); -// fhTimeResAllFee->Fill(uChanFeeA, uChanFeeB, dRes/TMath::Sqrt2() ); - sFitRes += Form("%4.0f (%4.0f) ", dRes, dRes/TMath::Sqrt2() ); - - uHistoFeeIdx++; - } // for( UInt_t uChanFeeB = uChanFeeA + 1; uChanFeeB < kuNbChanFee; uChanFeeB++) - LOG(info)<<" FEE Fit ch "<<uChanFeeA<<" Results: "<<sFitRes; - - if( kTRUE == fbPulserFeeB ) - { - for( UInt_t uChanFeeB = uChanFeeA + 1; uChanFeeB < kuNbChanFee; uChanFeeB++) - { - Double_t dResB = 0.0; - - // No need to fit if not data in histo - if( 0 == fhTimeResFeeB[uHistoFeeIdxB]->Integral() ) - { - LOG(debug)<<" FEE B histo empty: "<<uHistoFeeIdxB<<" " - <<uChanFeeA<<" "<<uChanFeeB; - uHistoFeeIdxB++; - continue; - } // if( 0 == fhTimeResFeeB[uHistoFeeIdx]->Integral() ) - - Double_t dFitLimit = fhTimeResFeeB[uHistoFeeIdxB]->GetRMS(); - if( dFitLimit < get4v1x::kdBinSize ) - dFitLimit = get4v1x::kdBinSize; - - fitFuncB[uHistoFeeIdxB] = new TF1( Form("fB_%03d_%03d",uChanFeeA,uChanFeeB), "gaus", - fhTimeResFeeB[uHistoFeeIdxB]->GetMean() - 5*dFitLimit , - fhTimeResFeeB[uHistoFeeIdxB]->GetMean() + 5*dFitLimit); - // Fix the Mean fit value around the Histogram Mean - fitFuncB[uHistoFeeIdxB]->SetParameter( 0, fhTimeResFeeB[uHistoFeeIdxB]->Integral() ); - fitFuncB[uHistoFeeIdxB]->FixParameter( 1, fhTimeResFeeB[uHistoFeeIdxB]->GetMean() ); - fitFuncB[uHistoFeeIdxB]->SetParameter( 2, 2*dFitLimit ); -// fitFuncB[uHistoFeeIdxB]->SetParLimits(1, -// fhTimeResFeeB[uHistoFeeIdxB]->GetMean() - 3, -// fhTimeResFeeB[uHistoFeeIdxB]->GetMean() + 3 ); - - - // Using integral instead of bin center seems to lead to unrealistic values => no "I" - // fhTimeResFee[uHistoFeeIdx]->Fit( Form("f_%03d_%03d",uChanFeeA,uChanFeeB), "IQRM0"); - fhTimeResFeeB[uHistoFeeIdxB]->Fit( Form("fB_%03d_%03d",uChanFeeA,uChanFeeB), "QRM0B"); - - dResB = fitFuncB[uHistoFeeIdxB]->GetParameter(2); - - // If needed uncomment for debugging - //(WARNING: this adds 1024 histos to the file!) -// fhTimeResFeeB[uHistoFeeIdxB]->Write(); - - delete fitFuncB[uHistoFeeIdxB]; - - fhTimeRmsAllFeeB->Fill(uChanFeeA, uChanFeeB, fhTimeResFeeB[uHistoFeeIdxB]->GetRMS() ); - fhTimeResAllFeeB->Fill(uChanFeeA, uChanFeeB, dResB/TMath::Sqrt2() ); - - uHistoFeeIdxB++; - } // for( UInt_t uChanFeeB = uChanFeeA + 1; uChanFeeB < kuNbChanFee; uChanFeeB++) - - for( UInt_t uChanFeeB = 0; uChanFeeB < kuNbChanFee; uChanFeeB++) - { - Double_t dResAB = 0.0; - - // No need to fit if not data in histo - if( 0 == fhTimeResFeeAB[uChanFeeA*kuNbChanFee + uChanFeeB]->Integral() ) - { - LOG(debug)<<" FEE AB histo empty: " - <<uChanFeeA<<" "<<uChanFeeB; - continue; - } // if( 0 == fhTimeResFeeAB[uHistoFeeIdx]->Integral() ) - - Double_t dFitLimit = fhTimeResFeeAB[uChanFeeA*kuNbChanFee + uChanFeeB]->GetRMS(); - if( dFitLimit < get4v1x::kdBinSize ) - dFitLimit = get4v1x::kdBinSize; - - fitFuncAB[uChanFeeA*kuNbChanFee + uChanFeeB] = new TF1( Form("fAB_%03d_%03d",uChanFeeA,uChanFeeB), "gaus", - fhTimeResFeeAB[uChanFeeA*kuNbChanFee + uChanFeeB]->GetMean() - 5*dFitLimit , - fhTimeResFeeAB[uChanFeeA*kuNbChanFee + uChanFeeB]->GetMean() + 5*dFitLimit ); - // Fix the Mean fit value around the Histogram Mean - fitFuncAB[uChanFeeA*kuNbChanFee + uChanFeeB]->SetParameter( 0, fhTimeResFeeAB[uChanFeeA*kuNbChanFee + uChanFeeB]->Integral() ); - fitFuncAB[uChanFeeA*kuNbChanFee + uChanFeeB]->FixParameter( 1, fhTimeResFeeAB[uChanFeeA*kuNbChanFee + uChanFeeB]->GetMean() ); - fitFuncAB[uChanFeeA*kuNbChanFee + uChanFeeB]->SetParameter( 2, 2*dFitLimit ); -// fitFuncAB[uChanFeeA*kuNbChanFee + uChanFeeB]->SetParLimits(1, -// fhTimeResFeeAB[uChanFeeA*kuNbChanFee + uChanFeeB]->GetMean() - 3, -// fhTimeResFeeAB[uChanFeeA*kuNbChanFee + uChanFeeB]->GetMean() + 3 ); - - // Using integral instead of bin center seems to lead to unrealistic values => no "I" - // fhTimeResFee[uHistoFeeIdx]->Fit( Form("f_%03d_%03d",uChanFeeA,uChanFeeB), "IQRM0"); - fhTimeResFeeAB[uChanFeeA*kuNbChanFee + uChanFeeB]->Fit( Form("fAB_%03d_%03d",uChanFeeA,uChanFeeB), "QRM0B"); - - dResAB = fitFuncAB[uChanFeeA*kuNbChanFee + uChanFeeB]->GetParameter(2); - - // If needed uncomment for debugging - //(WARNING: this adds 1024 histos to the file!) -// fhTimeResFeeAB[uChanFeeA*kuNbChanFee + uChanFeeB]->Write(); - - delete fitFuncAB[uChanFeeA*kuNbChanFee + uChanFeeB]; - - fhTimeRmsAllFeeAB->Fill(uChanFeeA, uChanFeeB, fhTimeResFeeAB[uChanFeeA*kuNbChanFee + uChanFeeB]->GetRMS() ); - fhTimeResAllFeeAB->Fill(uChanFeeA, uChanFeeB, dResAB/TMath::Sqrt2() ); - } // for( UInt_t uChanFeeB = 0; uChanFeeB < kuNbChanFee; uChanFeeB++) - } // if( kTRUE == fbPulserFeeB ) - } // for( UInt_t uChanFeeA = 0; uChanFeeA < kuNbChanFee; uChanFeeA++) - - // Then write the Fee summary histo - fhTimeRmsAllFee->Write(); - fhTimeResAllFee->Write(); - if( kTRUE == fbPulserFeeB ) - { - fhTimeRmsAllFeeB->Write(); - fhTimeResAllFeeB->Write(); - fhTimeRmsAllFeeAB->Write(); - fhTimeResAllFeeAB->Write(); - } // if( kTRUE == fbPulserFeeB ) - - // Reset summary histograms for safety - fhTimeRmsAllPairs->Reset(); - fhTimeResAllPairs->Reset(); - fhTimeRmsAllCombi->Reset(); - fhTimeResAllCombi->Reset(); - fhTimeRmsAllCombiEncA->Reset(); - fhTimeResAllCombiEncA->Reset(); - fhTimeRmsAllCombiEncB->Reset(); - fhTimeResAllCombiEncB->Reset(); - - // Write the histos for the test on chosen channel pairs - UInt_t uHistoCombiIdx = 0; - UInt_t uHistoCombiIdxEncA = 0; - UInt_t uHistoCombiIdxEncB = 0; - TF1 *fitFuncPairs[kuNbChanTest - 1]; - TF1 *fitFuncCombi[kuNbChanComb*(kuNbChanComb-1)/2]; - TF1 *fitFuncCombiEncA[kuNbChanComb*(kuNbChanComb-1)/2]; - TF1 *fitFuncCombiEncB[kuNbChanComb*(kuNbChanComb-1)/2]; - TString sFitCombRes = "\n"; - for( UInt_t uChanA = 0; uChanA < kuNbChanTest-1; uChanA++) - { - Double_t dSigPair = 0.0; - Double_t dResPair = 0.0; - Double_t dFitLimit = 0.0; - // No need to fit if not data in histo - if( 0 == fhTimeResPairs[uChanA]->Integral() ) - { - - LOG(debug)<<" Pair histo empty: "<<uHistoFeeIdx<<" " - <<uChanA<<" "<<uChanA+1; - } // if( 0 == fhTimeResFee[uHistoFeeIdx]->Integral() ) - else - { - dFitLimit = fhTimeResPairs[uChanA]->GetRMS(); - if( dFitLimit < get4v1x::kdBinSize ) - dFitLimit = get4v1x::kdBinSize; - - fitFuncPairs[uChanA] = new TF1( Form("fPair_%03d_%03d",uChanA, uChanA+1), "gaus", - fhTimeResPairs[uChanA]->GetMean() - 5*dFitLimit , - fhTimeResPairs[uChanA]->GetMean() + 5*dFitLimit); - // Fix the Mean fit value around the Histogram Mean - fitFuncPairs[uChanA]->SetParameter( 0, fhTimeResPairs[uChanA]->Integral()); - fitFuncPairs[uChanA]->FixParameter( 1, fhTimeResPairs[uChanA]->GetMean() ); - fitFuncPairs[uChanA]->SetParameter( 2, 2*dFitLimit ); - // fitFuncPairs[uChanA]->SetParLimits(1, - // fhTimeResPairs[uChanA]->GetMean() - 3, - // fhTimeResPairs[uChanA]->GetMean() + 3 ); - - // Using integral instead of bin center seems to lead to unrealistic values => no "I" - // fhTimeResPairs[uChanA]->Fit( Form("fPair_%03d_%03d",uChanA,uChanA+1), "IQRM0"); - fhTimeResPairs[uChanA]->Fit( Form("fPair_%03d_%03d",uChanA,uChanA+1), "QRM0B"); - dSigPair = fitFuncPairs[uChanA]->GetParameter(2); - dResPair = dSigPair/TMath::Sqrt2(); - - fhTimeResPairs[uChanA]->Write(); - fhTimeResPairsTot[(2*uChanA)]->Write(); - fhTimeResPairsTot[(2*uChanA)+1]->Write(); - - delete fitFuncPairs[uChanA]; - - fhTimeRmsAllPairs->Fill(uChanA, fhTimeResPairs[uChanA]->GetRMS() ); - fhTimeResAllPairs->Fill(uChanA, dResPair ); - LOG(info)<<" Pair Fit ch "<<uChanA<<" ch "<<uChanA+1<<" Results: " - <<Form("%4.0f (%4.0f) ", dSigPair, dResPair ); - } // els of if( 0 == fhTimeResPairs[uChanA]->Integral() ) - - for( UInt_t uChanB = uChanA+1; uChanB < kuNbChanComb; uChanB++) - { - Double_t dSigCombi = 0.0; - Double_t dResCombi = 0.0; - // No need to fit if not data in histo - if( 0 == fhTimeResCombi[uHistoCombiIdx]->Integral() ) - { - - LOG(debug)<<" Combi histo empty: "<<uHistoCombiIdx<<" " - <<uChanA<<" "<<uChanA+1; - uHistoCombiIdx++; - continue; - } // if( 0 == fhTimeResFee[uHistoFeeIdx]->Integral() ) - - dFitLimit = fhTimeResCombi[uHistoCombiIdx]->GetRMS(); - if( dFitLimit < get4v1x::kdBinSize ) - dFitLimit = get4v1x::kdBinSize; - - fitFuncCombi[uHistoCombiIdx] = new TF1( Form("fCombi_%03d_%03d",uChanA, uChanB), "gaus", - fhTimeResCombi[uHistoCombiIdx]->GetMean() - 5*dFitLimit , - fhTimeResCombi[uHistoCombiIdx]->GetMean() + 5*dFitLimit); - // Fix the Mean fit value around the Histogram Mean - fitFuncCombi[uHistoCombiIdx]->SetParameter( 0, fhTimeResCombi[uHistoCombiIdx]->Integral()); - fitFuncCombi[uHistoCombiIdx]->FixParameter( 1, fhTimeResCombi[uHistoCombiIdx]->GetMean() ); - fitFuncCombi[uHistoCombiIdx]->SetParameter( 2, 2*dFitLimit ); -// fitFuncCombi[uHistoCombiIdx]->SetParLimits(1, -// fhTimeResCombi[uHistoCombiIdx]->GetMean() - 3, -// fhTimeResCombi[uHistoCombiIdx]->GetMean() + 3 ); - - // Using integral instead of bin center seems to lead to unrealistic values => no "I" -// fhTimeResCombi[uHistoCombiIdx]->Fit( Form("fCombi_%03d_%03d",uChanA,uChanB), "IQRM0"); - fhTimeResCombi[uHistoCombiIdx]->Fit( Form("fCombi_%03d_%03d",uChanA,uChanB), "QRM0B"); - dSigCombi = fitFuncCombi[uHistoCombiIdx]->GetParameter(2); - dResCombi = dSigCombi/TMath::Sqrt2(); - - fhTimeResCombi[uHistoCombiIdx]->Write(); - fhTimeResCombiTot[2*uHistoCombiIdx]->Write(); - fhTimeResCombiTot[2*uHistoCombiIdx+1]->Write(); - - delete fitFuncCombi[uHistoCombiIdx]; - - fhTimeRmsAllCombi->Fill(uChanA, uChanB, fhTimeResCombi[uHistoCombiIdx]->GetRMS() ); - fhTimeResAllCombi->Fill(uChanA, uChanB, dResCombi ); - - sFitCombRes += Form("Pair Fit ch %d ch %d Results: %4.0f (%4.0f)\n", - uChanA, uChanB, dSigCombi, dResCombi ); - - uHistoCombiIdx++; - } // for( UInt_t uChanB = uChanA+1; uChanB < kuNbChanComb; uChanB++) - - for( UInt_t uChanB = uChanA+1; uChanB < kuNbChanComb; uChanB++) - { - Double_t dSigCombi = 0.0; - Double_t dResCombi = 0.0; - // Same for signals in FT encoder A - dSigCombi = 0.0; - dResCombi = 0.0; - // No need to fit if not data in histo - if( 0 < fhTimeResCombiEncA[uHistoCombiIdxEncA]->Integral() ) - { - dFitLimit = fhTimeResCombiEncA[uHistoCombiIdxEncA]->GetRMS(); - if( dFitLimit < get4v1x::kdBinSize ) - dFitLimit = get4v1x::kdBinSize; - - fitFuncCombiEncA[uHistoCombiIdxEncA] = new TF1( Form("fCombiEncA_%03d_%03d",uChanA, uChanB), "gaus", - fhTimeResCombiEncA[uHistoCombiIdxEncA]->GetMean() - 5*dFitLimit , - fhTimeResCombiEncA[uHistoCombiIdxEncA]->GetMean() + 5*dFitLimit); - // Fix the Mean fit value around the Histogram Mean - fitFuncCombiEncA[uHistoCombiIdxEncA]->SetParameter( 0, fhTimeResCombiEncA[uHistoCombiIdxEncA]->Integral()); - fitFuncCombiEncA[uHistoCombiIdxEncA]->FixParameter( 1, fhTimeResCombiEncA[uHistoCombiIdxEncA]->GetMean() ); - fitFuncCombiEncA[uHistoCombiIdxEncA]->SetParameter( 2, 2*dFitLimit ); - - fhTimeResCombiEncA[uHistoCombiIdxEncA]->Fit( Form("fCombiEncA_%03d_%03d",uChanA,uChanB), "QRM0B"); - dSigCombi = fitFuncCombiEncA[uHistoCombiIdxEncA]->GetParameter(2); - dResCombi = dSigCombi/TMath::Sqrt2(); - - fhTimeResCombiEncA[uHistoCombiIdxEncA]->Write(); - - delete fitFuncCombiEncA[uHistoCombiIdxEncA]; - - fhTimeRmsAllCombiEncA->Fill(uChanA, uChanB, fhTimeResCombiEncA[uHistoCombiIdxEncA]->GetRMS() ); - fhTimeResAllCombiEncA->Fill(uChanA, uChanB, dResCombi ); - } // if( 0 != fhTimeResFee[uHistoFeeIdx]->Integral() ) - uHistoCombiIdxEncA++; - - // Same for signals in FT encoder B - dSigCombi = 0.0; - dResCombi = 0.0; - // No need to fit if not data in histo - if( 0 < fhTimeResCombiEncB[uHistoCombiIdxEncB]->Integral() ) - { - dFitLimit = fhTimeResCombiEncB[uHistoCombiIdxEncB]->GetRMS(); - if( dFitLimit < get4v1x::kdBinSize ) - dFitLimit = get4v1x::kdBinSize; - - fitFuncCombiEncB[uHistoCombiIdxEncB] = new TF1( Form("fCombiEncB_%03d_%03d",uChanA, uChanB), "gaus", - fhTimeResCombiEncB[uHistoCombiIdxEncB]->GetMean() - 5*dFitLimit , - fhTimeResCombiEncB[uHistoCombiIdxEncB]->GetMean() + 5*dFitLimit); - // Fix the Mean fit value around the Histogram Mean - fitFuncCombiEncB[uHistoCombiIdxEncB]->SetParameter( 0, fhTimeResCombiEncB[uHistoCombiIdxEncB]->Integral()); - fitFuncCombiEncB[uHistoCombiIdxEncB]->FixParameter( 1, fhTimeResCombiEncB[uHistoCombiIdxEncB]->GetMean() ); - fitFuncCombiEncB[uHistoCombiIdxEncB]->SetParameter( 2, 2*dFitLimit ); - - fhTimeResCombiEncB[uHistoCombiIdxEncB]->Fit( Form("fCombiEncB_%03d_%03d",uChanA,uChanB), "QRM0B"); - dSigCombi = fitFuncCombiEncB[uHistoCombiIdxEncB]->GetParameter(2); - dResCombi = dSigCombi/TMath::Sqrt2(); - - fhTimeResCombiEncB[uHistoCombiIdxEncB]->Write(); - - delete fitFuncCombiEncB[uHistoCombiIdxEncB]; - - fhTimeRmsAllCombiEncB->Fill(uChanA, uChanB, fhTimeResCombiEncB[uHistoCombiIdxEncB]->GetRMS() ); - fhTimeResAllCombiEncB->Fill(uChanA, uChanB, dResCombi ); - } // if( 0 != fhTimeResFee[uHistoFeeIdx]->Integral() ) - - uHistoCombiIdxEncB++; - } // for( UInt_t uChanB = uChanA+1; uChanB < kuNbChanComb; uChanB++) - } // for( UInt_t uChanA = 0; uChanA < kuNbChanTest; uChanA++) - LOG(info)<<sFitCombRes; - fhTimeRmsAllPairs->Write(); - fhTimeResAllPairs->Write(); - fhTimeRmsAllCombi->Write(); - fhTimeResAllCombi->Write(); - fhTimeRmsAllCombiEncA->Write(); - fhTimeResAllCombiEncA->Write(); - fhTimeRmsAllCombiEncB->Write(); - fhTimeResAllCombiEncB->Write(); - - // Write the hists interval histos - fhPulserHitDistNs->Write(); - fhPulserHitDistUs->Write(); - fhPulserHitDistMs->Write(); - - // Write the raw count per FT bin histograms to file - TH2 * hFtDistribFeeRis = (TH2*)(fhPulserFeeDnl->Clone("hFtDistribFeeRis")); - hFtDistribFeeRis->Write(); - delete hFtDistribFeeRis; - - // Compute the DNL from the bins occupancy - for( UInt_t uChanFeeA = 0; uChanFeeA < kuNbChanFee; uChanFeeA++) - { - Double_t dNbCountsTotal = fhPulserFeeDnl->Integral( uChanFeeA+1, uChanFeeA+1, 1, get4v1x::kuFineTime+1); - Double_t dNbCountsBinMean = dNbCountsTotal/(get4v1x::kuFineTime+1); - for( UInt_t uBin = 1; uBin <= get4v1x::kuFineTime+1; uBin ++) - fhPulserFeeDnl->SetBinContent( uChanFeeA+1, uBin, - fhPulserFeeDnl->GetBinContent(uChanFeeA+1, uBin)/dNbCountsBinMean ); - } // for( UInt_t uChanFeeA = 0; uChanFeeA < kuNbChanFee; uChanFeeA++) - fhPulserFeeDnl->Write(); - // COmpute the INL from the DNL - for( UInt_t uChanFeeA = 0; uChanFeeA < kuNbChanFee; uChanFeeA++) - { - Double_t dInl = 0.0; - for( UInt_t uBin = 1; uBin <= get4v1x::kuFineTime+1; uBin ++) - { - dInl += 0.5 * fhPulserFeeDnl->GetBinContent(uChanFeeA+1, uBin); - fhPulserFeeInl->SetBinContent( uChanFeeA+1, uBin, dInl - (uBin-0.5) ); - dInl += 0.5 * fhPulserFeeDnl->GetBinContent(uChanFeeA+1, uBin); - } // for( UInt_t uBin = 1; uBin <= get4v1x::kuFineTime+1; uBin ++) - } // for( UInt_t uChanFeeA = 0; uChanFeeA < kuNbChanFee; uChanFeeA++) - fhPulserFeeInl->Write(); - for( UInt_t uChip = 0; uChip < kuNbChipFee; uChip ++) - fhPulserFeeDistCT[uChip]->Write(); - - fhFtSmallDtFeeA->Write(); - fhFtSmallDtFeeB->Write(); - - fhFtBigDtFeeA->Write(); - fhFtBigDtFeeB->Write(); - - fhFtPrevSmallDtFeeA->Write(); - fhFtPrevSmallDtFeeB->Write(); - - fhFtPrevBigDtFeeA->Write(); - fhFtPrevBigDtFeeB->Write(); - - for( UInt_t uChipFeeA = 0; uChipFeeA < kuNbChipFee; uChipFeeA++) - { - fhFullCtEpJumpFeeA[uChipFeeA]->Write(); - fhEpQualityFirstChFeeA[uChipFeeA]->Write(); - } - for( UInt_t uChan = 0; uChan < get4v1x::kuChanPerGet4; uChan++) - { - fhFullCtEpJumpFeeACh[uChan]->Write(); - fhFullCtEpJumpFeeAChSort[uChan]->Write(); - fhFullCtChOrderCh[uChan]->Write(); - fhFullCtEpQualityCh[uChan]->Write(); - fhFullCtEpQualityChZoom[uChan]->Write(); - } - fhFullCtEpJumpFeeAChOrder->Write(); - - if( kTRUE == fbOldReadoutOk ) - { - fhGet4ChanTotCount->Write(); - - // Write the raw count per FT bin histograms to file - TH2 * hFtDistribFeeFal = (TH2*)(fhPulserFeeTotDnl->Clone("hFtDistribFeeFal")); - hFtDistribFeeFal->Write(); - delete hFtDistribFeeFal; - - // Write the raw count per CT bin histograms to file - fhPulserFeeRisCtWideBins->Write(); - fhPulserFeeFalCtWideBins->Write(); - - // Write the missing message counts per FT bin histograms to file - if( kTRUE == fbEnableMissingEdgeCheck) - { - fhPulserFeeFtRecoMissRis->Write(); - fhPulserFeeFtRecoMissFal->Write(); - fhPulserFeeExtraRisEp->Write(); - fhPulserFeeExtraFalEp->Write(); - fhPulserFeeExtraEdgesEp->Write(); - - fhPulserFeeFtExtraEdgeRisA->Write(); - fhPulserFeeFtExtraEdgeFalA->Write(); - fhPulserFeeFtExtraEdgeRisB->Write(); - fhPulserFeeFtExtraEdgeFalB->Write(); - - fhPulserFeeGoodTot->Write(); - fhPulserFeeExtraRecoTot->Write(); - } // if( kTRUE == fbEnableMissingEdgeCheck) - - // Compute the DNL from the bins occupancy - for( UInt_t uChanFeeA = 0; uChanFeeA < kuNbChanFee; uChanFeeA++) - { - Double_t dNbCountsTotal = fhPulserFeeTotDnl->Integral( uChanFeeA+1, uChanFeeA+1, 1, get4v1x::kuFineTime+1); - Double_t dNbCountsBinMean = dNbCountsTotal/(get4v1x::kuFineTime+1); - for( UInt_t uBin = 1; uBin <= get4v1x::kuFineTime+1; uBin ++) - fhPulserFeeTotDnl->SetBinContent( uChanFeeA+1, uBin, - fhPulserFeeTotDnl->GetBinContent(uChanFeeA+1, uBin)/dNbCountsBinMean ); - } // for( UInt_t uChanFeeA = 0; uChanFeeA < kuNbChanFee; uChanFeeA++) - fhPulserFeeTotDnl->Write(); - // COmpute the INL from the DNL - for( UInt_t uChanFeeA = 0; uChanFeeA < kuNbChanFee; uChanFeeA++) - { - Double_t dInl = 0.0; - for( UInt_t uBin = 1; uBin <= get4v1x::kuFineTime+1; uBin ++) - { - dInl += 0.5 * fhPulserFeeTotDnl->GetBinContent(uChanFeeA+1, uBin); - fhPulserFeeTotInl->SetBinContent( uChanFeeA+1, uBin, dInl - (uBin-0.5) ); - dInl += 0.5 * fhPulserFeeTotDnl->GetBinContent(uChanFeeA+1, uBin); - } // for( UInt_t uBin = 1; uBin <= get4v1x::kuFineTime+1; uBin ++) - } // for( UInt_t uChanFeeA = 0; uChanFeeA < kuNbChanFee; uChanFeeA++) - fhPulserFeeTotInl->Write(); - for( UInt_t uChip = 0; uChip < kuNbChipFee; uChip ++) - fhPulserFeeTotDistCT[uChip]->Write(); - - fhFtTotSmallDtFeeA->Write(); - fhFtTotSmallDtFeeB->Write(); - - fhFtTotBigDtFeeA->Write(); - fhFtTotBigDtFeeB->Write(); - - fhFtPrevTotSmallDtFeeA->Write(); - fhFtPrevTotSmallDtFeeB->Write(); - - fhFtPrevTotBigDtFeeA->Write(); - fhFtPrevTotBigDtFeeB->Write(); - } // if( kTRUE == fbOldReadoutOk ) - } // if( kTRUE == fbPulserMode ) - - for( UInt_t uFeeA = 0; uFeeA < fuNbFee; uFeeA++) - for( UInt_t uFeeB = uFeeA; uFeeB < fuNbFee; uFeeB++) - fvvhChannelsCoinc[uFeeA][uFeeB]->Write(); - - // Multiple hits (reflections, ...) detection - if( 1 == fiMode ) - { - for( UInt_t uGet4 = 0; uGet4 < fuNbGet4; uGet4++) - { - if( kTRUE == fvbActiveChips[uGet4] ) - { - fvhGet4MultipleHits[uGet4] ->Write(); - fvhGet4DistDoubleHits[uGet4] ->Write(); - fvhGet4DistTripleHits[uGet4] ->Write(); - fvhGet4DistMultipleHits[uGet4]->Write(); - fvhGet4MultipleHitsVsTot[uGet4]->Write(); - } // if( kTRUE == fvbActiveChips[uGet4] ) - } // for( UInt_t uGet4 = 0; uGet4 < fuNbGet4; uGet4++) - } // if( 1 == fiMode ) - - gDirectory->cd( oldir->GetPath() ); - fHist->Close(); -} -void CbmGet4FastMonitor::DeleteMonitorHistograms() -{ - -} -void CbmGet4FastMonitor::MonitorMessage_epoch( get4v1x::Message mess, uint16_t EqID) -{ - // ROC epoch message: 250 MHz clock for now - // TODO: check compatibility when ROC clock changed to 200 MHz - uint8_t cRocId = mess.getRocNumber(); - LOG(debug3)<<"CbmGet4FastMonitor::MonitorMessage_epoch => ROC Epoch: EqId " - <<EqID<<" roc " - <<cRocId; - - // Epoch counter overflow book keeping - if( (get4v1x::kulMainEpochCycleSz - 2) < fvuCurrEpoch[cRocId] && - mess.getEpochNumber() < 2 ) - fvuCurrEpochCycle[cRocId]++; - - fvuCurrEpoch[cRocId] = mess.getEpochNumber(); -} -void CbmGet4FastMonitor::MonitorMessage_sync( get4v1x::Message mess, uint16_t EqID) -{ - // ROC sync message: TS in 250 MHz clock for now - // TODO: check compatibility when ROC clock changed to 200 MHz - uint8_t cRocId = mess.getRocNumber(); - fhRocSyncTypePerRoc->Fill( cRocId, mess.getSyncChNum() ); - LOG(debug3)<<"CbmGet4FastMonitor::MonitorMessage_sync => ROC Sync: EqId " - <<EqID<<" roc " - <<cRocId; -} -void CbmGet4FastMonitor::MonitorMessage_aux( get4v1x::Message mess, uint16_t EqID) -{ - // ROC aux message: TS in 250 MHz clock for now - // TODO: check compatibility when ROC clock changed to 200 MHz - uint8_t cRocId = mess.getRocNumber(); - fhRocAuxTypePerRoc->Fill( cRocId, mess.getAuxChNum() ); - LOG(debug3)<<"CbmGet4FastMonitor::MonitorMessage_aux => ROC Aux: EqId " - <<EqID<<" roc " - <<cRocId; -} -void CbmGet4FastMonitor::MonitorMessage_epoch2( get4v1x::Message mess, uint16_t EqID) -{ - // GET4 v1.x epoch message (24b only for now) - // TODO: check compatibility when 32b format without hack ready - uint8_t cRocId = mess.getRocNumber(); - uint8_t cChipId = mess.getEpoch2ChipNumber(); - uint32_t uChipFullId = cChipId + get4v1x::kuMaxGet4PerRoc*cRocId; - - LOG(debug3)<<"CbmGet4FastMonitor::MonitorMessage_epoch2 => GET4 Epoch2: EqId " - <<EqID<<" roc " - <<cRocId<<" chip " - <<cChipId; - - // Reject data of chips above defined limit to avoid overflow/seg fault - if( fuNbGet4 <= uChipFullId ) - { - if( kTRUE == fbVerbose ) - LOG(info)<<"CbmGet4FastMonitor::MonitorMessage_epoch2 => Ignored message with ChipId above limit!" - <<" ChipId: "<<cChipId - <<" RocId: " <<cRocId - <<" Limit: " <<fuNbGet4; - return; - } // if( fuNbGet4 <= cChipId + kuMaxGet4PerRoc*mess.getRocNumber() ) - - // Reject data of Inactive chips - if( kFALSE == fvbActiveChips[uChipFullId]) - { - if( kTRUE == fbVerbose ) - LOG(info)<<"CbmGet4FastMonitor::MonitorMessage_epoch2 => Ignored message with Inactive Chip!" - <<" ChipId: "<<cChipId - <<" RocId: " <<cRocId ; - return; - } // if( kFALSE == fvbActiveChips[uChipFullId]) - - // As long as the 1st epoch with sync flag after SYNC DLM is found, - // consider data as not good - if( kTRUE == fvbGet4WaitFirstSync[uChipFullId] ) - { - if( 1 == mess.getEpoch2Sync() ) - { - fvbGet4WaitFirstSync[uChipFullId] = kFALSE; - - LOG(info) << "First SYNC Epoch after DLM in chip " - <<Form("%3u: ", uChipFullId) - <<Form(" EP #%6u", mess.getEpoch2Number() ) - <<Form(" TS #%12llu", fulTsNb) - <<Form(" MS #%5llu/%5lu", fulMsNb, static_cast<ULong_t>(fsMaxMsNb) ) - <<Form(" OF #%5u/%5u", fuOffset, fuMaxOffset) - <<Form(" LO #%5u/%5u", fuLocalOffset, fuMaxLocalOffset); - } // if( 1 == mess.getEpoch2Sync() ) - else return; - } // if( kTRUE == fvbGet4WaitFirstSync[uChipFullId] ) - - // Count epoch messages per chip - fhMessTypePerGet4->Fill( uChipFullId, get4v1x::GET4_32B_EPOCH); - - if( fvuCurrEpoch2[uChipFullId] +1 != mess.getEpoch2Number() && - 0 != fvuCurrEpoch2[uChipFullId] ) - { - Int_t iEpJump = mess.getEpoch2Number(); - iEpJump -= fvuCurrEpoch2[uChipFullId]; - - // If debug mode, print the message - if( kTRUE == fbDebug ) - LOG(info) << "Epoch nb jump in chip " - <<Form("%3u: ", uChipFullId) - << Form(" %3d (%6u -> %6u)", iEpJump, fvuCurrEpoch2[uChipFullId], - mess.getEpoch2Number() ) - <<Form(" TS #%12llu", fulTsNb) - <<Form(" MS #%5llu/%5lu", fulMsNb, static_cast<ULong_t>(fsMaxMsNb) ) - <<Form(" OF #%5u/%5u", fuOffset, fuMaxOffset) - <<Form(" LO #%5u/%5u", fuLocalOffset, fuMaxLocalOffset); - else LOG(debug) << "Epoch nb jump in chip " - <<Form("%3u: ", uChipFullId) - << Form(" %3d (%6u -> %6u)", iEpJump, fvuCurrEpoch2[uChipFullId], - mess.getEpoch2Number() ) - <<Form(" TS #%12llu", fulTsNb) - <<Form(" MS #%5llu/%5lu", fulMsNb, static_cast<ULong_t>(fsMaxMsNb) ) - <<Form(" OF #%5u/%5u", fuOffset, fuMaxOffset) - <<Form(" LO #%5u/%5u", fuLocalOffset, fuMaxLocalOffset); - - fhGet4EpochJumps->Fill(uChipFullId, iEpJump); - fhGet4BadEpochRatio->Fill(0); - fhGet4BadEpRatioChip->Fill( uChipFullId, 0); - - if( kTRUE == fbPulserMode && kTRUE == fbOldReadoutOk && fuPulserFee == (uChipFullId/kuNbChipFee) ) - { - UInt_t uChipFeeA = uChipFullId%kuNbChipFee; - for( UInt_t uChan = 0; uChan < get4v1x::kuChanPerGet4; uChan++ ) - if( 0ull != fvmLastHit[ fuPulserFee * kuNbChanFee+ uChipFeeA*get4v1x::kuChanPerGet4+ uChan].getData() ) - { - fhFullCtEpJumpFeeA[uChipFeeA]->Fill( - fvmLastHit[ fuPulserFee * kuNbChanFee+ uChipFeeA*get4v1x::kuChanPerGet4+ uChan].getGet4CoarseTs(), - fvmLastOldTot[ fuPulserFee * kuNbChanFee+ uChipFeeA*get4v1x::kuChanPerGet4+ uChan].getGet4CoarseTs() ); - fhFullCtEpJumpFeeACh[uChan]->Fill( - fvmLastHit[ fuPulserFee * kuNbChanFee+ uChipFeeA*get4v1x::kuChanPerGet4+ uChan].getGet4CoarseTs(), - fvmLastOldTot[ fuPulserFee * kuNbChanFee+ uChipFeeA*get4v1x::kuChanPerGet4+ uChan].getGet4CoarseTs() ); - - fhFullCtEpQualityCh[uChan]->Fill( - fvmLastHit[ fuPulserFee * kuNbChanFee+ uChipFeeA*get4v1x::kuChanPerGet4+ uChan].getGet4CoarseTs(), 0); - fhFullCtEpQualityChZoom[uChan]->Fill( - fvmLastHit[ fuPulserFee * kuNbChanFee+ uChipFeeA*get4v1x::kuChanPerGet4+ uChan].getGet4CoarseTs(), 0); - - if( get4v1x::kuChanPerGet4 == fvChanOrder[uChipFeeA].size() ) - { - UInt_t uChOrder; - for( uChOrder = 0; uChOrder < get4v1x::kuChanPerGet4; uChOrder++ ) - if( uChan == fvChanOrder[uChipFeeA][uChOrder] ) - break; - fhFullCtChOrderCh[uChan]->Fill( - fvmLastHit[ fuPulserFee * kuNbChanFee+ uChipFeeA*get4v1x::kuChanPerGet4+ uChan].getGet4CoarseTs(), uChOrder); - } // if( get4v1x::kuChanPerGet4 == fvChanOrder[uChipFeeA].size() ) - } // for( UInt_t uChan = 0; uChan < get4v1x::kuChanPerGet4; uChan++ ) - - if( get4v1x::kuChanPerGet4 == fvChanOrder[uChipFeeA].size() ) - for( UInt_t uChOrder = 0; uChOrder < fvChanOrder[uChipFeeA].size(); uChOrder++ ) - { - UInt_t uChanOrdered = fuPulserFee * kuNbChanFee+ uChipFeeA*get4v1x::kuChanPerGet4+ fvChanOrder[uChipFeeA][uChOrder]; - fhFullCtEpJumpFeeAChSort[uChOrder]->Fill( - fvmLastHit[ uChanOrdered ].getGet4CoarseTs(), - fvmLastOldTot[ uChanOrdered ].getGet4CoarseTs() ); - fhFullCtEpJumpFeeAChOrder->Fill( uChOrder, fvChanOrder[uChipFeeA][uChOrder]); - } // for( UInt_t uChOrder = 0; uChOrder < fvChanOrder[uChipFeeA].size(); uChOrder++ ) - - if( 0 < fvChanOrder[uChipFeeA].size() ) - fhEpQualityFirstChFeeA[uChipFeeA]->Fill( fvChanOrder[uChipFeeA][0], 0 ); - } // if( kTRUE == fbPulserMode && kTRUE == fbOldReadoutOk && fuPulserFee == (uChipFullId/kuNbChipFee) ) - } // if( fvuCurrEpoch2[uChipFullId] +1 != mess.getGet4V10R32EpochNumber()) - else - { - fhGet4BadEpochRatio->Fill( 1 ); - fhGet4BadEpRatioChip->Fill( uChipFullId, 1); - if( kTRUE == fbPulserMode && kTRUE == fbOldReadoutOk && fuPulserFee == (uChipFullId/kuNbChipFee) ) - { - UInt_t uChipFeeA = uChipFullId%kuNbChipFee; - - for( UInt_t uChan = 0; uChan < get4v1x::kuChanPerGet4; uChan++ ) - if( 0ull != fvmLastHit[ fuPulserFee * kuNbChanFee+ uChipFeeA*get4v1x::kuChanPerGet4+ uChan].getData() ) - { - fhFullCtEpQualityCh[uChan]->Fill( - fvmLastHit[ fuPulserFee * kuNbChanFee+ uChipFeeA*get4v1x::kuChanPerGet4+ uChan].getGet4CoarseTs(), 1); - fhFullCtEpQualityChZoom[uChan]->Fill( - fvmLastHit[ fuPulserFee * kuNbChanFee+ uChipFeeA*get4v1x::kuChanPerGet4+ uChan].getGet4CoarseTs(), 1); - } // for( UInt_t uChan = 0; uChan < get4v1x::kuChanPerGet4; uChan++ ) - - if( 0 < fvChanOrder[uChipFeeA].size() ) - fhEpQualityFirstChFeeA[uChipFeeA]->Fill( fvChanOrder[uChipFeeA][0], 1 ); - } // if( kTRUE == fbPulserMode && kTRUE == fbOldReadoutOk && fuPulserFee == (uChipFullId/kuNbChipFee) ) - } // else of if( fvuCurrEpoch2[uChipFullId] +1 != mess.getGet4V10R32EpochNumber()) - - // Epoch counter overflow book keeping - if( (get4v1x::kul24bGet4EpochCycleSz - 2) < fvuCurrEpoch2[uChipFullId] && - mess.getEpoch2Number() < 2 ) - fvuCurrEpoch2Cycle[uChipFullId]++; - - fvuCurrEpoch2[uChipFullId] = mess.getEpoch2Number(); - - // Monitoring of data Time evolution - fvhRocEpochCntEvo[cRocId]->Fill( - ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs*(1e-12) ); // Time since start in s -/* - fvhGet4EpochCntEvo[uChipFullId]->Fill( - ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs*(1e-12) ); // Time since start in s - if( uChipFullId < kuNbTdcMappedDet ) - if( kiTdcDetMap[uChipFullId] < kiNbDet ) - fvhDetEpochCntEvo[ kiTdcDetMap[uChipFullId] ]->Fill( - ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs*(1e-12) ); // Time since start in s -*/ - - if( 1 == mess.getEpoch2Sync() ) - { - fhGet4EpochFlags->Fill(uChipFullId, 0); - fhGet4EpochSyncDist->Fill( uChipFullId, fvuCurrEpoch2[uChipFullId] % get4v1x::kuSyncCycleSzGet4 ); - } // if( 1 == mess.getEpoch2Sync() ) - - if( 1 == mess.getEpoch2EpochMissmatch() ) - { - fhGet4EpochFlags->Fill(uChipFullId, 1); - // If debug mode, print the message - if( kTRUE == fbDebug ) - LOG(debug) << "Epoch missmatch in chip " - <<Form("%3u: ", uChipFullId) - <<Form(" EP #%6u", mess.getEpoch2Number() ) - <<Form(" TS #%12llu", fulTsNb) - <<Form(" MS #%5llu/%5lu", fulMsNb, static_cast<ULong_t>(fsMaxMsNb) ) - <<Form(" OF #%5u/%5u", fuOffset, fuMaxOffset) - <<Form(" LO #%5u/%5u", fuLocalOffset, fuMaxLocalOffset); - else LOG(debug) << "Epoch missmatch in chip " - <<Form("%3u: ", uChipFullId) - <<Form(" EP #%6u", mess.getEpoch2Number() ) - <<Form(" TS #%12llu", fulTsNb) - <<Form(" MS #%5llu/%5lu", fulMsNb, static_cast<ULong_t>(fsMaxMsNb) ) - <<Form(" OF #%5u/%5u", fuOffset, fuMaxOffset) - <<Form(" LO #%5u/%5u", fuLocalOffset, fuMaxLocalOffset); - - fvhRocEpochMissmCntEvo[cRocId]->Fill( - ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs*(1e-12) ); // Time since start in s - fvhGet4EpochMissmCntEvo[uChipFullId]->Fill( - ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs*(1e-12) ); // Time since start in s - if( uChipFullId < kuNbTdcMappedDet ) - if( kiTdcDetMap[uChipFullId] < kiNbDet ) - fvhDetEpochMissmCntEvo[ kiTdcDetMap[uChipFullId] ]->Fill( - ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs*(1e-12) ); // Time since start in s - } // if( 1 == mess.getEpoch2EpochMissmatch() ) - if( 1 == mess.getEpoch2EpochLost() ) - { - fhGet4EpochFlags->Fill(uChipFullId, 2); - // If debug mode, print the message - if( kTRUE == fbDebug ) - LOG(info) << "Epoch loss in chip " - <<Form("%3u: ", uChipFullId) - <<Form(" EP #%6u", mess.getEpoch2Number() ) - <<Form(" TS #%12llu", fulTsNb) - <<Form(" MS #%5llu/%5lu", fulMsNb, static_cast<ULong_t>(fsMaxMsNb) ) - <<Form(" OF #%5u/%5u", fuOffset, fuMaxOffset) - <<Form(" LO #%5u/%5u", fuLocalOffset, fuMaxLocalOffset); - else LOG(debug) << "Epoch loss in chip " - <<Form("%3u: ", uChipFullId) - <<Form(" EP #%6u", mess.getEpoch2Number() ) - <<Form(" TS #%12llu", fulTsNb) - <<Form(" MS #%5llu/%5lu", fulMsNb, static_cast<ULong_t>(fsMaxMsNb) ) - <<Form(" OF #%5u/%5u", fuOffset, fuMaxOffset) - <<Form(" LO #%5u/%5u", fuLocalOffset, fuMaxLocalOffset); - - fvhRocEpochLossCntEvo[cRocId]->Fill( - ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs*(1e-12) ); // Time since start in s - fvhGet4EpochLossCntEvo[uChipFullId]->Fill( - ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs*(1e-12) ); // Time since start in s - if( uChipFullId < kuNbTdcMappedDet ) - if( kiTdcDetMap[uChipFullId] < kiNbDet ) - fvhDetEpochLossCntEvo[ kiTdcDetMap[uChipFullId] ]->Fill( - ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs*(1e-12) ); // Time since start in s - } // if( 1 == mess.getEpoch2EpochLost() ) - if( 1 == mess.getEpoch2DataLost() ) - { - fhGet4EpochFlags->Fill(uChipFullId, 3); - // If debug mode, print the message - if( kTRUE == fbDebug ) - LOG(info) << "Data Loss in chip " - <<Form("%3u: ", uChipFullId) - <<Form(" EP #%6u", mess.getEpoch2Number() ) - <<Form(" TS #%12llu", fulTsNb) - <<Form(" MS #%5llu/%5lu", fulMsNb, static_cast<ULong_t>(fsMaxMsNb) ) - <<Form(" OF #%5u/%5u", fuOffset, fuMaxOffset) - <<Form(" LO #%5u/%5u", fuLocalOffset, fuMaxLocalOffset); - else LOG(debug) << "Data Loss in chip " - <<Form("%3u: ", uChipFullId) - <<Form(" EP #%6u", mess.getEpoch2Number() ) - <<Form(" TS #%12llu", fulTsNb) - <<Form(" MS #%5llu/%5lu", fulMsNb, static_cast<ULong_t>(fsMaxMsNb) ) - <<Form(" OF #%5u/%5u", fuOffset, fuMaxOffset) - <<Form(" LO #%5u/%5u", fuLocalOffset, fuMaxLocalOffset); - - fvhRocDataLossCntEvo[cRocId]->Fill( - ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs*(1e-12) ); // Time since start in s - fvhGet4DataLossCntEvo[uChipFullId]->Fill( - ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs*(1e-12) ); // Time since start in s - if( uChipFullId < kuNbTdcMappedDet ) - if( kiTdcDetMap[uChipFullId] < kiNbDet ) - fvhDetDataLossCntEvo[ kiTdcDetMap[uChipFullId] ]->Fill( - ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs*(1e-12) ); // Time since start in s - } // if( 1 == mess.getEpoch2DataLost() ) - - // Fill Pulser test histos if needed - // Accepted pairs are when both messages are defined and they are at most - // 1 epoch apart => possibility of double use is the pulse happens on top of - // an epoch and more than once every 3 epochs. For example: - // HHHHEHHHH.......E......HHHHEHHHH leads to - // (HHHHHHHH) (HHHHHHHH) and - // (HHHH HHHH) - if( kTRUE == fbPulserMode && kTRUE == fbOldReadoutOk - && 0 == (uChipFullId%kuNbChipFee) - && fuPulserFee == (uChipFullId/kuNbChipFee)) - { - // Fill the time difference for all channels pairs in - // the chosen Fee - UInt_t uHistoFeeIdx = 0; - for( UInt_t uChanFeeA = 0; uChanFeeA < kuNbChanFee; uChanFeeA++) - { - for( UInt_t uChanFeeB = uChanFeeA + 1; uChanFeeB < kuNbChanFee; uChanFeeB++) - { - if( - ( get4v1x::MSG_GET4 == fvmLastHit[ fuPulserFee * kuNbChanFee+ uChanFeeA].getMessageType() ) && - ( get4v1x::MSG_GET4 == fvmLastHit[ fuPulserFee * kuNbChanFee+ uChanFeeB].getMessageType() ) && - ( fvuLastHitEp[ fuPulserFee * kuNbChanFee+ uChanFeeA ] - < fvuLastHitEp[ fuPulserFee * kuNbChanFee+ uChanFeeB ] + 2 ) && - ( fvuLastHitEp[ fuPulserFee * kuNbChanFee+ uChanFeeA ] + 2 - > fvuLastHitEp[ fuPulserFee * kuNbChanFee+ uChanFeeB ] ) ) - { - Double_t dTimeDiff = 0.0; - dTimeDiff = fvmLastHit[ fuPulserFee * kuNbChanFee+ uChanFeeA].CalcGet4V10R24HitTimeDiff( - fvuLastHitEp[ fuPulserFee * kuNbChanFee+ uChanFeeA], - fvuLastHitEp[ fuPulserFee * kuNbChanFee+ uChanFeeB], - fvmLastHit[ fuPulserFee * kuNbChanFee+ uChanFeeB] ); - - fhTimeResFee[uHistoFeeIdx]->Fill( dTimeDiff ); - - if( TMath::Abs(dTimeDiff) <= 5000 ) - { - fhFtSmallDtFeeA->Fill( - (fvmLastHit[ fuPulserFee * kuNbChanFee+ uChanFeeA ].getGet4Ts()) & get4v1x::kuFineTime, - (fvmLastHit[ fuPulserFee * kuNbChanFee+ uChanFeeB ].getGet4Ts()) & get4v1x::kuFineTime ); - fhFtTotSmallDtFeeA->Fill( - (fvmLastOldTot[ fuPulserFee * kuNbChanFee+ uChanFeeA ].getGet4Ts()) & get4v1x::kuFineTime, - (fvmLastOldTot[ fuPulserFee * kuNbChanFee+ uChanFeeB ].getGet4Ts()) & get4v1x::kuFineTime ); - fhFtPrevSmallDtFeeA->Fill( - (fvmPrevHit[ fuPulserFee * kuNbChanFee+ uChanFeeA ].getGet4Ts()) & get4v1x::kuFineTime, - (fvmPrevHit[ fuPulserFee * kuNbChanFee+ uChanFeeB ].getGet4Ts()) & get4v1x::kuFineTime ); - fhFtPrevTotSmallDtFeeA->Fill( - (fvmPrevOldTot[ fuPulserFee * kuNbChanFee+ uChanFeeA ].getGet4Ts()) & get4v1x::kuFineTime, - (fvmPrevOldTot[ fuPulserFee * kuNbChanFee+ uChanFeeB ].getGet4Ts()) & get4v1x::kuFineTime ); - } // if( TMath::Abs(dTimeDiff) < 5000 ) - else if( TMath::Abs(dTimeDiff) < 15000) - { - fhFtBigDtFeeA->Fill( - (fvmLastHit[ fuPulserFee * kuNbChanFee+ uChanFeeA ].getGet4Ts()) & get4v1x::kuFineTime, - (fvmLastHit[ fuPulserFee * kuNbChanFee+ uChanFeeB ].getGet4Ts()) & get4v1x::kuFineTime ); - fhFtTotBigDtFeeA->Fill( - (fvmLastOldTot[ fuPulserFee * kuNbChanFee+ uChanFeeA ].getGet4Ts()) & get4v1x::kuFineTime, - (fvmLastOldTot[ fuPulserFee * kuNbChanFee+ uChanFeeB ].getGet4Ts()) & get4v1x::kuFineTime ); - fhFtPrevBigDtFeeA->Fill( - (fvmPrevHit[ fuPulserFee * kuNbChanFee+ uChanFeeA ].getGet4Ts()) & get4v1x::kuFineTime, - (fvmPrevHit[ fuPulserFee * kuNbChanFee+ uChanFeeB ].getGet4Ts()) & get4v1x::kuFineTime ); - fhFtPrevTotBigDtFeeA->Fill( - (fvmPrevOldTot[ fuPulserFee * kuNbChanFee+ uChanFeeA ].getGet4Ts()) & get4v1x::kuFineTime, - (fvmPrevOldTot[ fuPulserFee * kuNbChanFee+ uChanFeeB ].getGet4Ts()) & get4v1x::kuFineTime ); - - if( kTRUE == fbDebug ) - { - LOG(info) << "Big time difference for FEE A channels " - <<Form("%3u %3u: ", uChanFeeA, uChanFeeB) - <<Form(" TS #%12llu", fulTsNb); - fvmLastHit[ fuPulserFee * kuNbChanFee+ uChanFeeA ].printDataLog(); - fvmLastHit[ fuPulserFee * kuNbChanFee+ uChanFeeB ].printDataLog(); - } // if( kTRUE == fbDebug ) - } // if( TMath::Abs(dTimeDiff) > 5000 && TMath::Abs(dTimeDiff) < 15000) - } // if both channels have matching data - - if( kTRUE == fbPulserFeeB ) - if( - ( get4v1x::MSG_GET4 == fvmLastHit[ fuPulserFeeB * kuNbChanFee+ uChanFeeA].getMessageType() ) && - ( get4v1x::MSG_GET4 == fvmLastHit[ fuPulserFeeB * kuNbChanFee+ uChanFeeB].getMessageType() ) && - ( fvuLastHitEp[ fuPulserFeeB * kuNbChanFee+ uChanFeeA ] - < fvuLastHitEp[ fuPulserFeeB * kuNbChanFee+ uChanFeeB ] + 2 ) && - ( fvuLastHitEp[ fuPulserFeeB * kuNbChanFee+ uChanFeeA ] + 2 - > fvuLastHitEp[ fuPulserFeeB * kuNbChanFee+ uChanFeeB ] ) ) - { - Double_t dTimeDiffB = 0.0; - dTimeDiffB = fvmLastHit[ fuPulserFeeB * kuNbChanFee+ uChanFeeA].CalcGet4V10R24HitTimeDiff( - fvuLastHitEp[ fuPulserFeeB * kuNbChanFee+ uChanFeeA], - fvuLastHitEp[ fuPulserFeeB * kuNbChanFee+ uChanFeeB], - fvmLastHit[ fuPulserFeeB * kuNbChanFee+ uChanFeeB] ); - - fhTimeResFeeB[uHistoFeeIdx]->Fill( dTimeDiffB ); - - if( TMath::Abs(dTimeDiffB) <= 5000 ) - { - fhFtSmallDtFeeB->Fill( - (fvmLastHit[ fuPulserFeeB * kuNbChanFee+ uChanFeeA ].getGet4Ts()) & get4v1x::kuFineTime, - (fvmLastHit[ fuPulserFeeB * kuNbChanFee+ uChanFeeB ].getGet4Ts()) & get4v1x::kuFineTime ); - fhFtTotSmallDtFeeB->Fill( - (fvmLastOldTot[ fuPulserFeeB * kuNbChanFee+ uChanFeeA ].getGet4Ts()) & get4v1x::kuFineTime, - (fvmLastOldTot[ fuPulserFeeB * kuNbChanFee+ uChanFeeB ].getGet4Ts()) & get4v1x::kuFineTime ); - fhFtPrevSmallDtFeeB->Fill( - (fvmPrevHit[ fuPulserFeeB * kuNbChanFee+ uChanFeeA ].getGet4Ts()) & get4v1x::kuFineTime, - (fvmPrevHit[ fuPulserFeeB * kuNbChanFee+ uChanFeeB ].getGet4Ts()) & get4v1x::kuFineTime ); - fhFtPrevTotSmallDtFeeB->Fill( - (fvmPrevOldTot[ fuPulserFeeB * kuNbChanFee+ uChanFeeA ].getGet4Ts()) & get4v1x::kuFineTime, - (fvmPrevOldTot[ fuPulserFeeB * kuNbChanFee+ uChanFeeB ].getGet4Ts()) & get4v1x::kuFineTime ); - } // if( TMath::Abs(dTimeDiff) < 5000 ) - else if( TMath::Abs(dTimeDiffB) < 15000) - { - fhFtBigDtFeeB->Fill( - (fvmLastHit[ fuPulserFeeB * kuNbChanFee+ uChanFeeA ].getGet4Ts()) & get4v1x::kuFineTime, - (fvmLastHit[ fuPulserFeeB * kuNbChanFee+ uChanFeeB ].getGet4Ts()) & get4v1x::kuFineTime ); - fhFtTotBigDtFeeB->Fill( - (fvmLastOldTot[ fuPulserFeeB * kuNbChanFee+ uChanFeeA ].getGet4Ts()) & get4v1x::kuFineTime, - (fvmLastOldTot[ fuPulserFeeB * kuNbChanFee+ uChanFeeB ].getGet4Ts()) & get4v1x::kuFineTime ); - fhFtPrevBigDtFeeB->Fill( - (fvmPrevHit[ fuPulserFeeB * kuNbChanFee+ uChanFeeA ].getGet4Ts()) & get4v1x::kuFineTime, - (fvmPrevHit[ fuPulserFeeB * kuNbChanFee+ uChanFeeB ].getGet4Ts()) & get4v1x::kuFineTime ); - fhFtPrevTotBigDtFeeB->Fill( - (fvmPrevOldTot[ fuPulserFeeB * kuNbChanFee+ uChanFeeA ].getGet4Ts()) & get4v1x::kuFineTime, - (fvmPrevOldTot[ fuPulserFeeB * kuNbChanFee+ uChanFeeB ].getGet4Ts()) & get4v1x::kuFineTime ); - } // if( TMath::Abs(dTimeDiff) > 5000 && TMath::Abs(dTimeDiff) < 15000) - } // if both channels in FEE B have matching data - uHistoFeeIdx++; - } // for any unique pair of channel in chosen Fee - - if( kTRUE == fbPulserFeeB ) - for( UInt_t uChanFeeB = 0; uChanFeeB < kuNbChanFee; uChanFeeB++) - { - if( - ( get4v1x::MSG_GET4 == fvmLastHit[ fuPulserFee * kuNbChanFee+ uChanFeeA].getMessageType() ) && - ( get4v1x::MSG_GET4 == fvmLastHit[ fuPulserFeeB * kuNbChanFee+ uChanFeeB].getMessageType() ) && - ( fvuLastHitEp[ fuPulserFee * kuNbChanFee+ uChanFeeA ] - < fvuLastHitEp[ fuPulserFeeB * kuNbChanFee+ uChanFeeB ] + 2 ) && - ( fvuLastHitEp[ fuPulserFee * kuNbChanFee+ uChanFeeA ] + 2 - > fvuLastHitEp[ fuPulserFeeB * kuNbChanFee+ uChanFeeB ] ) ) - { - Double_t dTimeDiffAB = 0.0; - dTimeDiffAB = fvmLastHit[ fuPulserFee * kuNbChanFee+ uChanFeeA].CalcGet4V10R24HitTimeDiff( - fvuLastHitEp[ fuPulserFee * kuNbChanFee+ uChanFeeA], - fvuLastHitEp[ fuPulserFeeB * kuNbChanFee+ uChanFeeB], - fvmLastHit[ fuPulserFeeB * kuNbChanFee+ uChanFeeB] ); - - fhTimeResFeeAB[uChanFeeA*kuNbChanFee + uChanFeeB]->Fill( dTimeDiffAB ); - } // if both channels in FEE A and B have matching data - } // if( kTRUE == fbPulserFeeB ) && for( UInt_t uChanFeeB = uChanFeeA + 1; uChanFeeB < kuNbChanFee; uChanFeeB++) - } // for( UInt_t uChanFeeA = 0; uChanFeeA < kuNbChanFee; uChanFeeA++) - - // Fill the time difference for the chosen channel pairs - UInt_t uHistoCombiIdx = 0; - for( UInt_t uChanA = 0; uChanA < kuNbChanTest-1; uChanA++) - { - if( ( get4v1x::MSG_GET4 == fvmLastHit[ fuPulserChan[uChanA] ].getMessageType() ) && - ( get4v1x::MSG_GET4 == fvmLastHit[ fuPulserChan[uChanA+1] ].getMessageType() ) && - ( fvuLastHitEp[ fuPulserChan[uChanA] ] - < fvuLastHitEp[ fuPulserChan[uChanA+1] ] + 2 ) && - ( fvuLastHitEp[ fuPulserChan[uChanA] ] + 2 - > fvuLastHitEp[ fuPulserChan[uChanA+1] ] ) ) - { - Double_t dTimeDiff = - fvmLastHit[ fuPulserChan[uChanA] ].CalcGet4V10R24HitTimeDiff( - fvuLastHitEp[ fuPulserChan[uChanA] ], - fvuLastHitEp[ fuPulserChan[uChanA+1] ], - fvmLastHit[ fuPulserChan[uChanA+1] ] ); - fhTimeResPairs[uChanA]->Fill( dTimeDiff ); - - if( TMath::Abs(dTimeDiff) > 5000 && TMath::Abs(dTimeDiff) < 15000) - { - if( kTRUE == fbDebug ) - { - LOG(info) << "Big time difference for channel pair " - <<Form("%3u: ", uChanA) - <<Form(" TS #%12llu", fulTsNb); - fvmLastHit[ fuPulserChan[uChanA] ].printDataLog(); - fvmLastHit[ fuPulserChan[uChanA+1] ].printDataLog(); - } // if( kTRUE == fbDebug ) - } // if( TMath::Abs(dTimeDiff) > 5000 && TMath::Abs(dTimeDiff) < 15000) - } // // if both channels have data - - for( UInt_t uChanB = uChanA+1; uChanB < kuNbChanComb; uChanB++) - { - if( ( get4v1x::MSG_GET4 == fvmLastHit[ fuPulserChan[uChanA] ].getMessageType() ) && - ( get4v1x::MSG_GET4 == fvmLastHit[ fuPulserChan[uChanB] ].getMessageType() ) && - ( fvuLastHitEp[ fuPulserChan[uChanA] ] - < fvuLastHitEp[ fuPulserChan[uChanB] ] + 2 ) && - ( fvuLastHitEp[ fuPulserChan[uChanA] ] + 2 - > fvuLastHitEp[ fuPulserChan[uChanB] ] ) ) - { - Double_t dTimeDiff = - fvmLastHit[ fuPulserChan[uChanA] ].CalcGet4V10R24HitTimeDiff( - fvuLastHitEp[ fuPulserChan[uChanA] ], - fvuLastHitEp[ fuPulserChan[uChanB] ], - fvmLastHit[ fuPulserChan[uChanB] ] ); - fhTimeResCombi[uHistoCombiIdx]->Fill( dTimeDiff ); - - if( ( fvmLastHit[ fuPulserChan[uChanA] ].getGet4FineTs() < (get4v1x::kuFineCounterSize/2) ) && - ( fvmLastHit[ fuPulserChan[uChanB] ].getGet4FineTs() < (get4v1x::kuFineCounterSize/2) ) ) - fhTimeResCombiEncA[uHistoCombiIdx]->Fill( dTimeDiff ); - else if( ( (get4v1x::kuFineCounterSize/2) <= fvmLastHit[ fuPulserChan[uChanA] ].getGet4FineTs() ) && - ( (get4v1x::kuFineCounterSize/2) <= fvmLastHit[ fuPulserChan[uChanB] ].getGet4FineTs() ) ) - fhTimeResCombiEncB[uHistoCombiIdx]->Fill( dTimeDiff ); - - if( TMath::Abs(dTimeDiff) > 5000 && TMath::Abs(dTimeDiff) < 15000) - { - if( kTRUE == fbDebug ) - { - LOG(info) << "Big time difference for channel combination " - <<Form("%3u: ", uHistoCombiIdx) - <<Form(" TS #%12llu", fulTsNb); - fvmLastHit[ fuPulserChan[uChanA] ].printDataLog(); - fvmLastHit[ fuPulserChan[uChanB] ].printDataLog(); - } // if( kTRUE == fbDebug ) - } // if( TMath::Abs(dTimeDiff) > 5000 && TMath::Abs(dTimeDiff) < 15000) - - } // if both channels have data - uHistoCombiIdx++; - } // for( UInt_t uChanB = uChanA+1; uChanB < kuNbChanComb; uChanB++) - } // for( UInt_t uChanA = 0; uChanA < kuNbChanTest; uChanA++) - - } // if( kTRUE == fbPulserMode && 0 == uChipFullId && kTRUE == fbOldReadoutOk ) - - // Check for missing edges in 24b mode with pulser - if( kTRUE == fbPulserMode && kTRUE == fbOldReadoutOk - && fuPulserFee == (uChipFullId/kuNbChipFee) && - kTRUE == fbEnableMissingEdgeCheck ) - { - UInt_t uChipInFee = uChipFullId%kuNbChipFee; - UInt_t uChInFee = get4v1x::kuChanPerGet4 * uChipInFee; - UInt_t uFullChId = get4v1x::kuChanPerGet4*( uChipFullId ); - - for( uChInFee = get4v1x::kuChanPerGet4 * uChipInFee; - uChInFee < get4v1x::kuChanPerGet4 * (uChipInFee+1); - uChInFee ++, uFullChId++ ) - { - UInt_t uLastTotValFt = fvuLastTotInFtBins[uChInFee]; - // Try to find missing edges - if( ( ( 20 < fvmLastHit[uFullChId ].getGet4CoarseTs() ) && - ( fvmLastHit[uFullChId ].getGet4CoarseTs() < (get4v1x::kuCoarseCounterSize - 20) ) ) && - ( ( 20 < fvmLastOldTot[uFullChId ].getGet4CoarseTs() ) && - ( fvmLastOldTot[uFullChId ].getGet4CoarseTs() < (get4v1x::kuCoarseCounterSize - 20) ) ) ) - { - if( fvuLastOldTotEp[uFullChId] == fvuLastHitEp[uFullChId] ) - { - // Should be a good pulse away from the epoch edges and with matching edge messages - // (same epoch, middle range of CT, ok as long as no more than 1 pulse/epoch) - Double_t dTot = fvmLastOldTot[ uFullChId ].CalcGet4V10R24HitTimeDiff( - fvuLastOldTotEp[uFullChId], - fvuLastHitEp[ uFullChId], - fvmLastHit[ uFullChId ] )/1000.0; - if( 0.0 < dTot && dTot < 100.0 ) - { - // Good TOT => save its FT - if( fvmLastHit[ uFullChId ].getGet4FineTs() < fvmLastOldTot[ uFullChId ].getGet4FineTs() ) - fvuLastTotInFtBins[uChInFee] = fvmLastOldTot[ uFullChId ].getGet4FineTs() - - fvmLastHit[ uFullChId ].getGet4FineTs(); - else fvuLastTotInFtBins[uChInFee] = get4v1x::kuFineCounterSize - + fvmLastOldTot[ uFullChId ].getGet4FineTs() - - fvmLastHit[ uFullChId ].getGet4FineTs(); - } // if( 0.0 < dTot && dTot < 100.0 ) - else - LOG(info)<<"Bad TOT " - <<uChInFee<<", FT(R) " - <<fvmLastHit[ uFullChId ].getGet4FineTs()<<", FT(F) " - <<fvmLastOldTot[ uFullChId ].getGet4FineTs()<<", CT(R) " - <<fvmLastHit[uFullChId ].getGet4CoarseTs()<<", CT(F) " - <<fvmLastOldTot[uFullChId ].getGet4CoarseTs()<<", Ep(R) " - <<fvuLastHitEp[uFullChId]<<", Ep(F) " - <<fvuLastOldTotEp[uFullChId]<<", TOT " - <<dTot; - } // Same epoch => both edges there - else // one edge is missing, assume its the one with old epoch index - { - UInt_t uRecoFt = 0; - if( fvuLastOldTotEp[uFullChId] < fvuLastHitEp[uFullChId]) - { - // Falling edge is missing - uRecoFt = fvmLastHit[ uFullChId ].getGet4FineTs() - + fvuLastTotInFtBins[uChInFee]; - if( get4v1x::kuFineTime < uRecoFt ) - uRecoFt -= get4v1x::kuFineTime + 1; - fhPulserFeeFtRecoMissFal->Fill( uChInFee, uRecoFt); - - LOG(info)<<"Missing edge: F, ch " - <<uChInFee<<", FT(R) " - <<fvmLastHit[ uFullChId ].getGet4FineTs()<<", FT(F) " - <<uRecoFt<<", CT(R) " - <<fvmLastHit[uFullChId ].getGet4CoarseTs()<<", CT(F) " - <<fvmLastOldTot[uFullChId ].getGet4CoarseTs()<<", Ep(R) " - <<fvuLastHitEp[uFullChId]<<", Ep(F) " - <<fvuLastOldTotEp[uFullChId]; - } // if( fvuLastOldTotEp[uChipInFee] < fvuLastHitEp[uChipInFee]) - else - { - // Rising edge is missing - if( fvmLastOldTot[ uFullChId ].getGet4FineTs() < fvuLastTotInFtBins[uChInFee]) - uRecoFt = get4v1x::kuFineTime + 1 - + fvmLastOldTot[ uFullChId ].getGet4FineTs() - - fvuLastTotInFtBins[uChInFee]; - else uRecoFt = fvmLastOldTot[ uFullChId ].getGet4FineTs() - - fvuLastTotInFtBins[uChInFee]; - fhPulserFeeFtRecoMissRis->Fill( uChInFee, uRecoFt); - - LOG(info)<<"Missing edge: R, ch " - <<uChInFee<<", FT(R) " - <<uRecoFt<<", FT(F) " - <<fvmLastOldTot[ uFullChId ].getGet4FineTs()<<", CT(R) " - <<fvmLastHit[uFullChId ].getGet4CoarseTs()<<", CT(F) " - <<fvmLastOldTot[uFullChId ].getGet4CoarseTs()<<", Ep(R) " - <<fvuLastHitEp[uFullChId]<<", Ep(F) " - <<fvuLastOldTotEp[uFullChId]; - } // else of if( fvuLastOldTotEp[uChipInFee] < fvuLastHitEp[uChipInFee]) - } // else of if( fvuLastOldTotEp[uChipInFee] == fvuLastHitEp[uChipInFee] ) - } // if both edges in safe CT range to avoid epoch edges crossing - - // Check if extra edges - if( (1 < fvuNbRisEdgeEpoch[uChInFee] || 1 < fvuNbFalEdgeEpoch[uChInFee]) && - ( fvuNbRisEdgeEpoch[uChInFee] != fvuNbFalEdgeEpoch[uChInFee] )) - { - if( (2 == fvuNbRisEdgeEpoch[uChInFee] && 2 >= fvuNbFalEdgeEpoch[uChInFee]) || - (2 >= fvuNbRisEdgeEpoch[uChInFee] && 2 == fvuNbFalEdgeEpoch[uChInFee]) ) - { - LOG(info)<< "Extra edges and edges nb missmatch: ch " << Form("%2u", uChInFee) - << " Nb Ris " <<fvuNbRisEdgeEpoch[uChInFee] - << " Nb Fal " <<fvuNbFalEdgeEpoch[uChInFee] - << Form(" TS #%12llu", fulTsNb) - << Form(" Last TOT %3u %3u", uLastTotValFt, fvuLastTotInFtBins[uChInFee]); - if(2 == fvuNbRisEdgeEpoch[uChInFee] && 1 == fvuNbFalEdgeEpoch[uChInFee]) - { - UInt_t uTotReco = 0; - if( fvmFeePrevRis[ uChInFee ].getGet4FineTs() < fvmLastOldTot[ uFullChId ].getGet4FineTs() ) - uTotReco = fvmLastOldTot[ uFullChId ].getGet4FineTs() - - fvmFeePrevRis[ uChInFee ].getGet4FineTs(); - else uTotReco = get4v1x::kuFineCounterSize - + fvmLastOldTot[ uFullChId ].getGet4FineTs() - - fvmFeePrevRis[ uChInFee ].getGet4FineTs(); - LOG(info)<< Form(" TOT reco %3u", uTotReco); - fhPulserFeeExtraRecoTot->Fill( uChInFee, uTotReco); - } // if(2 == fvuNbRisEdgeEpoch[uChInFee] && 1 == fvuNbFalEdgeEpoch[uChInFee]) - if(1 == fvuNbRisEdgeEpoch[uChInFee] && 2 == fvuNbFalEdgeEpoch[uChInFee]) - { - UInt_t uTotReco = 0; - if( fvmLastHit[ uFullChId ].getGet4FineTs() < fvmLastOldTot[ uFullChId ].getGet4FineTs() ) - uTotReco = fvmLastOldTot[ uFullChId ].getGet4FineTs() - - fvmLastHit[ uFullChId ].getGet4FineTs(); - else uTotReco = get4v1x::kuFineCounterSize - + fvmLastOldTot[ uFullChId ].getGet4FineTs() - - fvmLastHit[ uFullChId ].getGet4FineTs(); - LOG(info)<< Form(" TOT reco %3u", uTotReco); - fhPulserFeeExtraRecoTot->Fill( uChInFee, uTotReco); - } // if(1 == fvuNbRisEdgeEpoch[uChInFee] && 2 == fvuNbFalEdgeEpoch[uChInFee]) - LOG(info)<< ""; - LOG(info)<<" Previous messages " - << ( fvuFeePrevRisEp[uChInFee] == fvuLastHitEp[uFullChId] ? - Form(" FT(R) %3u, CT(R) %4u, Ep(R) %6u", - fvmFeePrevRis[ uChInFee ].getGet4FineTs(), - fvmFeePrevRis[ uChInFee ].getGet4CoarseTs(), - fvuFeePrevRisEp[uChInFee] ) : - " ") - << ( fvuFeePrevFalEp[uChInFee] == fvuLastOldTotEp[uFullChId] ? - Form(" FT(F) %3u, CT(F) %4u, Ep(F) %6u", - fvmFeePrevFal[ uChInFee ].getGet4FineTs(), - fvmFeePrevFal[ uChInFee ].getGet4CoarseTs(), - fvuFeePrevFalEp[uChInFee] ) : - " "); - LOG(info)<< ""; - LOG(info)<<" Last messages " - <<Form(" FT(R) %3u, CT(R) %4u, Ep(R) %6u", - fvmLastHit[ uFullChId ].getGet4FineTs(), - fvmLastHit[ uFullChId ].getGet4CoarseTs(), - fvuLastHitEp[uFullChId] ) - <<Form(" FT(F) %3u, CT(F) %4u, Ep(F) %6u", - fvmLastOldTot[ uFullChId ].getGet4FineTs(), - fvmLastOldTot[ uFullChId ].getGet4CoarseTs(), - fvuLastOldTotEp[uFullChId] ); - - if( 2 == fvuNbRisEdgeEpoch[uChInFee] ) - fhPulserFeeFtExtraEdgeRisA->Fill( uChInFee, fvmFeePrevRis[ uChInFee ].getGet4FineTs()); - if( 2 == fvuNbFalEdgeEpoch[uChInFee] ) - fhPulserFeeFtExtraEdgeFalA->Fill( uChInFee, fvmFeePrevFal[ uChInFee ].getGet4FineTs()); - fhPulserFeeFtExtraEdgeRisB->Fill( uChInFee, fvmLastHit[ uFullChId ].getGet4FineTs()); - fhPulserFeeFtExtraEdgeFalB->Fill( uChInFee, fvmLastOldTot[ uFullChId ].getGet4FineTs()); - } // if only one extra message or less per edge - else - { - LOG(info)<<"Extra edges and edges nb missmatch: ch " << uChInFee - << " Nb Ris " <<fvuNbRisEdgeEpoch[uChInFee] - << " Nb Fal " <<fvuNbFalEdgeEpoch[uChInFee] - << Form(" TS #%12llu", fulTsNb); - LOG(info)<< ""; - LOG(info)<<" " - <<Form(" FT(R) %3u, CT(R) %4u, Ep(R) %6u", - fvmLastHit[ uFullChId ].getGet4FineTs(), - fvmLastHit[ uFullChId ].getGet4CoarseTs(), - fvuLastHitEp[uFullChId] ) - <<Form(" FT(F) %3u, CT(F) %4u, Ep(F) %6u", - fvmLastOldTot[ uFullChId ].getGet4FineTs(), - fvmLastOldTot[ uFullChId ].getGet4CoarseTs(), - fvuLastOldTotEp[uFullChId] ); - } - } - else fhPulserFeeGoodTot->Fill( uChInFee, fvuLastTotInFtBins[uChInFee]); - if( 1 < fvuNbRisEdgeEpoch[uChInFee] ) - { - fhPulserFeeExtraRisEp->Fill( uChInFee, fvuNbRisEdgeEpoch[uChInFee]); - fhPulserFeeExtraEdgesEp->Fill( uChInFee - 0.25, fvuNbRisEdgeEpoch[uChInFee]); - } - fvuNbRisEdgeEpoch[uChInFee] = 0; - if( 1 < fvuNbFalEdgeEpoch[uChInFee] ) - { - fhPulserFeeExtraFalEp->Fill( uChInFee, fvuNbFalEdgeEpoch[uChInFee]); - fhPulserFeeExtraEdgesEp->Fill( uChInFee + 0.25, fvuNbFalEdgeEpoch[uChInFee]); - } - fvuNbFalEdgeEpoch[uChInFee] = 0; - } // Loop over channels in this GET4 chip - } // if( kTRUE == fbPulserMode && kTRUE == fbOldReadoutOk && fuPulserFee == (uChipFullId/kuNbChipFee)) - - // for channel readout order in case of epoch jumps - if( kTRUE == fbPulserMode && kTRUE == fbOldReadoutOk - && fuPulserFee == (uChipFullId/kuNbChipFee)) - fvChanOrder[uChipFullId%kuNbChipFee].clear(); - -} -void CbmGet4FastMonitor::MonitorMessage_get4( get4v1x::Message mess, uint16_t EqID) -{ - // GET4 v1.x data message (24b only for now) - // TODO: check compatibility when 32b format without hack ready - uint8_t cRocId = mess.getRocNumber(); - LOG(debug3)<<"CbmGet4FastMonitor::MonitorMessage_get4 => GET4 Data: EqId " - <<EqID<<" roc " - <<cRocId; - - uint8_t cChipId = mess.getGet4Number(); - UInt_t uChipFullId = cChipId + get4v1x::kuMaxGet4PerRoc*cRocId; - UInt_t uFullChId = - get4v1x::kuChanPerGet4*( uChipFullId ) - + mess.getGet4ChNum(); - UInt_t uTimeStamp = mess.getGet4Ts(); - - // Reject data of chips above defined limit to avoid overflow/seg fault - if( fuNbGet4 <= uChipFullId ) - { - if( kTRUE == fbVerbose ) - LOG(info)<<"CbmGet4FastMonitor::MonitorMessage_get4 => Ignored message with ChipId above limit!" - <<" ChipId: "<<cChipId - <<" RocId: " <<cRocId - <<" Limit: " <<fuNbGet4; - return; - } // if( fuNbGet4 <= cChipId + kuMaxGet4PerRoc*mess.getRocNumber() ) - - // Reject data of Inactive chips - if( kFALSE == fvbActiveChips[uChipFullId]) - { - if( kTRUE == fbVerbose ) - LOG(info)<<"CbmGet4FastMonitor::MonitorMessage_get4 => Ignored message with Inactive Chip!" - <<" ChipId: "<<cChipId - <<" RocId: " <<cRocId ; - return; - } // if( kFALSE == fvbActiveChips[uChipFullId]) - - // As long as the 1st epoch with sync flag after SYNC DLM is found, - // consider data as not good - if( kTRUE == fvbGet4WaitFirstSync[uChipFullId] ) - return; - - fvhRocDataCntEvo[cRocId]->Fill( - ( ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs - + uTimeStamp*get4v1x::kdBinSize ) - *(1e-12) ); // Time since start in s - fvhGet4DataCntEvo[uChipFullId]->Fill( - ( ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs - + uTimeStamp*get4v1x::kdBinSize ) - *(1e-12) ); // Time since start in s - fvhGet4ChDataCntEvo[uChipFullId]->Fill( mess.getGet4ChNum(), - ( ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs - + uTimeStamp*get4v1x::kdBinSize ) - *(1e-12) ); // Time since start in s - if( uChipFullId < kuNbTdcMappedDet ) - if( kiTdcDetMap[uChipFullId] < kiNbDet ) - fvhDetDataCntEvo[ kiTdcDetMap[uChipFullId] ]->Fill( - ( ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs - + uTimeStamp*get4v1x::kdBinSize ) - *(1e-12) ); // Time since start in s - - // Count data messages per chip - fhMessTypePerGet4->Fill( uChipFullId, get4v1x::GET4_32B_DATA); - - if( kTRUE == fbEnaCalibOutput ) - fvhFineTime[ uChipFullId ][ mess.getGet4ChNum() ]->Fill( mess.getGet4FineTs() ); - - if( kTRUE == fbPulserMode && kTRUE == fbOldReadoutOk ) - { - if( 1 == mess.getGet4Edge() ) - { - Double_t dTot = mess.CalcGet4V10R24HitTimeDiff( - fvuCurrEpoch2[uChipFullId], - fvuLastHitEp[ uFullChId], - fvmLastHit[ uFullChId ] )/1000.0; - if( 0.0 < dTot && dTot < 100.0 ) - fhGet4ChanTotMap->Fill( uFullChId, dTot); - - // Save the hit info in order to fill later the pulser histos - // First fill time interval histos - if( fuPulserFee == (uFullChId/kuNbChanFee) ) - { - // Fill the DNL histos - fhPulserFeeTotDnl->Fill( uFullChId%kuNbChanFee, uTimeStamp & get4v1x::kuFineTime ); - - // Fill the CT histo - fhPulserFeeFalCtWideBins->Fill( uFullChId%kuNbChanFee, mess.getGet4CoarseTs() ); - fhPulserFeeTotDistCT[ uChipFullId%kuNbChipFee ]->Fill( mess.getGet4CoarseTs(), mess.getGet4ChNum()); - - if( kTRUE == fbEnableMissingEdgeCheck ) - { - fvuFeePrevFalEp[uFullChId%kuNbChanFee] = fvuLastOldTotEp[ uFullChId ]; - fvmFeePrevFal[ uFullChId%kuNbChanFee] = fvmLastOldTot[ uFullChId ]; - // count edges per epoch - fvuNbFalEdgeEpoch[uFullChId%kuNbChanFee] ++; - } // if( kTRUE == fbEnableMissingEdgeCheck ) - } // if( fuPulserFee == (uFullChId/kuNbChanFee) ) - } // if( 1 == mess.getGet4Edge() ) - else - { - Double_t dTot = fvmLastOldTot[ uFullChId ].CalcGet4V10R24HitTimeDiff( - fvuLastOldTotEp[ uFullChId ], - fvuCurrEpoch2[uChipFullId], - mess )/1000.0; - if( 0.0 < dTot && dTot < 100.0 ) - fhGet4ChanTotMap->Fill( uFullChId, dTot); - - // Save the hit info in order to fill later the pulser histos - // First fill time interval histos - if( fuPulserFee == (uFullChId/kuNbChanFee) ) - { - Double_t dHitsDt = mess.CalcGet4V10R24HitTimeDiff( - fvuCurrEpoch2[uChipFullId], - fvuLastHitEp[ uFullChId ], - fvmLastHit[ uFullChId ] ); - if( 0 == fvuLastHitEp[uFullChId]) - {} - else if( dHitsDt < 1e6 ) - fhPulserHitDistNs->Fill( uFullChId%kuNbChanFee, dHitsDt / 1e3 ); - else if( dHitsDt < 1e9) - fhPulserHitDistUs->Fill( uFullChId%kuNbChanFee, dHitsDt / 1e6 ); - else - fhPulserHitDistMs->Fill( uFullChId%kuNbChanFee, dHitsDt / 1e9 ); - - if( 0 < fvuLastHitEp[uFullChId] && dHitsDt < 5e3 ) - LOG(debug) <<uFullChId<<" "<<dHitsDt<<" " - <<fvuLastHitEp[ uFullChId ]<<" "<<fvuCurrEpoch2[uChipFullId]<<" " - <<fvmLastOldTot[ uFullChId ].CalcGet4V10R24HitTimeDiff( - fvuLastOldTotEp[ uFullChId ], - fvuLastHitEp[ uFullChId], - fvmLastHit[ uFullChId ] )/1000.0<<" " - <<fvmLastOldTot[ uFullChId ].CalcGet4V10R24HitTimeDiff( - fvuLastOldTotEp[ uFullChId ], - fvuCurrEpoch2[uChipFullId], - mess )/1000.0;; - - // Fill the DNL histos - fhPulserFeeDnl->Fill( uFullChId%kuNbChanFee, uTimeStamp & get4v1x::kuFineTime ); - - // Fill the CT histo - fhPulserFeeRisCtWideBins->Fill( uFullChId%kuNbChanFee, mess.getGet4CoarseTs() ); - fhPulserFeeDistCT[ uChipFullId%kuNbChipFee ]->Fill( mess.getGet4CoarseTs(), mess.getGet4ChNum()); - - if( kTRUE == fbEnableMissingEdgeCheck ) - { - fvuFeePrevRisEp[uFullChId%kuNbChanFee] = fvuLastHitEp[ uFullChId ]; - fvmFeePrevRis[ uFullChId%kuNbChanFee] = fvmLastHit[ uFullChId ]; - // count edges per epoch - fvuNbRisEdgeEpoch[uFullChId%kuNbChanFee] ++; - } // if( kTRUE == fbEnableMissingEdgeCheck ) - } // if( fuPulserFee == (uFullChId/kuNbChanFee) ) - } // else of if( 1 == mess.getGet4Edge() ) - } // if( kTRUE == fbPulserMode && kTRUE == fbOldReadoutOk ) - - if( kTRUE == fbOldReadoutOk ) - { - if( 1 == mess.getGet4Edge() ) - { - fhGet4ChanTotCount->Fill( uFullChId ); - - // Keep Epoch of Previous hit message (one per GET4 chip & channel) - fvuPrevOldTotEp[ uFullChId ] = fvuLastOldTotEp[ uFullChId ]; - // Keep Previous hit message (one per GET4 chip & channel) - fvmPrevOldTot[ uFullChId ] = fvmLastOldTot[ uFullChId ]; - - // Epoch of Last hit message (one per GET4 chip & channel) - fvuLastOldTotEp[ uFullChId ] = fvuCurrEpoch2[uChipFullId]; - // Last hit message (one per GET4 chip & channel) - fvmLastOldTot[ uFullChId ] = mess; - - fvdChanFirstHitTot[uChipFullId][mess.getGet4ChNum()] = - mess.CalcGet4V10R24HitTimeDiff( - fvuCurrEpoch2[uChipFullId], fvuLastHitEp[ uFullChId ], fvmLastHit[ uFullChId ] ); - } // if( 1 == mess.getGet4Edge() ) - else - { - fhGet4ChanDataCount->Fill( uFullChId ); - // Fill time coincidence map - for( UInt_t uFeeA = 0; uFeeA < fuNbFee; uFeeA++) - for( UInt_t uFeeChan = 0; uFeeChan < get4v1x::kuChanPerFee; uFeeChan++ ) - if( ( get4v1x::MSG_GET4 == - fvmLastHit[ uFeeA*get4v1x::kuChanPerFee + uFeeChan ].getMessageType() ) && - ( fvuLastHitEp[ uFeeA*get4v1x::kuChanPerFee + uFeeChan/get4v1x::kuChanPerGet4 ] - < fvuCurrEpoch2[uChipFullId] + 2 ) && - ( fvuLastHitEp[ uFeeA*get4v1x::kuChanPerFee + uFeeChan/get4v1x::kuChanPerGet4 ] + 2 - > fvuCurrEpoch2[uChipFullId] ) ) - { - // compare to last hit in other channel - Double_t dHitsDt = mess.CalcGet4V10R24HitTimeDiff( - fvuCurrEpoch2[uChipFullId], - fvuLastHitEp[ uFeeA*get4v1x::kuChanPerFee + uFeeChan/get4v1x::kuChanPerGet4 ], - fvmLastHit[ uFeeA*get4v1x::kuChanPerFee + uFeeChan ] ); - if( TMath::Abs(dHitsDt) < fdMaxCoincDist ) - { - if( uFeeA*get4v1x::kuChanPerFee + uFeeChan < uFullChId ) - fvvhChannelsCoinc[uFeeA][uFullChId/get4v1x::kuChanPerFee]->Fill( - uFeeChan, uFullChId%get4v1x::kuChanPerFee); - else fvvhChannelsCoinc[uFullChId/get4v1x::kuChanPerFee][uFeeA]->Fill( - uFullChId%get4v1x::kuChanPerFee, uFeeChan); - } // if( TMath::Abs(dHitsDt) < fdMaxCoincDist ) - } // for each pair, if both hits valid - - // Multiple hits (reflections, ...) detection - if( 1 == fiMode) - { - Double_t dHitsDt = mess.CalcGet4V10R24HitTimeDiff( - fvuCurrEpoch2[uChipFullId], - fvuLastHitEp[ uFullChId ], - fvmLastHit[ uFullChId ] ); - if( dHitsDt < fdMaxDtMultiHit ) - { - if( kFALSE == fvbChanSecondHit[uChipFullId][mess.getGet4ChNum()] ) - { - fvhGet4MultipleHits[uChipFullId]->Fill( mess.getGet4ChNum(), 2); - fvhGet4DistDoubleHits[uChipFullId]->Fill( mess.getGet4ChNum(), dHitsDt); - fvbChanSecondHit[uChipFullId][mess.getGet4ChNum()] = kTRUE; - - fvhGet4MultipleHitsVsTot[uChipFullId]->Fill( - fvdChanFirstHitTot[uChipFullId][mess.getGet4ChNum()], 2); - } - else if ( kFALSE == fvbChanThirdHit[uChipFullId][mess.getGet4ChNum()] ) - { - fvhGet4MultipleHits[uChipFullId]->Fill( mess.getGet4ChNum(), 3); - fvhGet4DistTripleHits[uChipFullId]->Fill( mess.getGet4ChNum(), dHitsDt); - fvbChanThirdHit[uChipFullId][mess.getGet4ChNum()] = kTRUE; - - fvhGet4MultipleHitsVsTot[uChipFullId]->Fill( - fvdChanFirstHitTot[uChipFullId][mess.getGet4ChNum()], 3); - } - else - { - fvhGet4MultipleHits[uChipFullId]->Fill( mess.getGet4ChNum(), 4); - fvhGet4DistMultipleHits[uChipFullId]->Fill( mess.getGet4ChNum(), dHitsDt); - - fvhGet4MultipleHitsVsTot[uChipFullId]->Fill( - fvdChanFirstHitTot[uChipFullId][mess.getGet4ChNum()], 4); - } - } // if( dHitsDt < fdMaxDtMultiHit ) - else - { - fvhGet4MultipleHits[uChipFullId]->Fill( mess.getGet4ChNum(), 1); - fvbChanSecondHit[uChipFullId][mess.getGet4ChNum()] = kFALSE; - fvbChanThirdHit[uChipFullId][mess.getGet4ChNum()] = kFALSE; - - fvhGet4MultipleHitsVsTot[uChipFullId]->Fill( - fvdChanFirstHitTot[uChipFullId][mess.getGet4ChNum()], 1); - } // else of if( dHitsDt < fdMaxDtMultiHit ) - } // if( 1 == fiMode) - - // Keep Epoch of Previous hit message (one per GET4 chip & channel) - fvuPrevHitEp[ uFullChId ] = fvuLastHitEp[ uFullChId ]; - // Keep Previous hit message (one per GET4 chip & channel) - fvmPrevHit[ uFullChId ] = fvmLastHit[ uFullChId ]; - - // Epoch of Last hit message (one per GET4 chip & channel) - fvuLastHitEp[ uFullChId ] = fvuCurrEpoch2[uChipFullId]; - // Last hit message (one per GET4 chip & channel) - fvmLastHit[ uFullChId ] = mess; - - // for the channel readout order in case of epoch jump - if( kTRUE == fbPulserMode && kTRUE == fbOldReadoutOk - && fuPulserFee == (uChipFullId/kuNbChipFee)) - fvChanOrder[uChipFullId%kuNbChipFee].push_back( mess.getGet4ChNum() ); - } // else of if( 1 == mess.getGet4Edge() ) - } // if( kTRUE == fbOldReadoutOk ) -} -void CbmGet4FastMonitor::MonitorMessage_sys( get4v1x::Message mess, uint16_t EqID) -{ - uint8_t cRocId = mess.getRocNumber(); - LOG(debug3)<<"CbmGet4FastMonitor::MonitorMessage_sys => System message: EqId " - <<EqID<<" roc " - <<cRocId; - - if( mess.getSysMesType() < get4v1x::SYSMSG_GET4V1_32BIT_0 ) - fhSysMessTypePerRoc->Fill( cRocId, mess.getSysMesType() ); - - switch( mess.getSysMesType() ) - { - case get4v1x::SYSMSG_DAQ_START: - { - break; - } // case get4v1x::SYSMSG_DAQ_START - case get4v1x::SYSMSG_DAQ_FINISH: - { - break; - } // case get4v1x::SYSMSG_DAQ_FINISH - case get4v1x::SYSMSG_NX_PARITY: - case get4v1x::SYSMSG_ADC: - case get4v1x::SYSMSG_PCTIME: - { - // NXYTER related => don't care in this unpacker - break; - } // case get4v1x::SYSMSG_NX_PARITY - case get4v1x::SYSMSG_SYNC_PARITY: - { - break; - } // case get4v1x::SYSMSG_SYNC_PARITY - case get4v1x::SYSMSG_DAQ_RESUME: - { - break; - } // case get4v1x::SYSMSG_DAQ_RESUME - case get4v1x::SYSMSG_FIFO_RESET: - { - break; - } // case get4v1x::SYSMSG_FIFO_RESET - case get4v1x::SYSMSG_USER: - { - if( get4v1x::SYSMSG_USER_ROCFEET_SYNC == mess.getSysMesData() ) - { - LOG(info)<<"CbmGet4FastMonitor::MonitorMessage_sys => SYNC DLM!" - <<" RocId: " << Form("%02u", cRocId) - <<Form(" TS #%12llu", fulTsNb) - <<Form(" MS #%5llu/%5lu", fulMsNb, static_cast<ULong_t>(fsMaxMsNb) ) - <<Form(" OF #%5u/%5u", fuOffset, fuMaxOffset) - <<Form(" LO #%5u/%5u", fuLocalOffset, fuMaxLocalOffset); - if( kTRUE == fvbRocFeetFirstSyncDlm[cRocId] && - kFALSE == fvbRocFeetSyncStart[cRocId]) - fvbRocFeetSyncStart[cRocId] = kTRUE; - else if( kFALSE == fvbRocFeetFirstSyncDlm[cRocId] ) - fvbRocFeetFirstSyncDlm[cRocId] = kTRUE; - } // if( get4v1x::SYSMSG_USER_ROCFEET_SYNC == mess.getSysMesData() ) - break; - } // case get4v1x::SYSMSG_USER - case get4v1x::SYSMSG_PACKETLOST: - { - break; - } // case get4v1x::SYSMSG_PACKETLOST - case get4v1x::SYSMSG_GET4_EVENT: - { - // GET4 v1.x error message (24b only for now) - // TODO: check compatibility when 32b format without hack ready - uint8_t cChipId = mess.getGet4V10R24ErrorChip(); - uint32_t uChipFullId = cChipId + get4v1x::kuMaxGet4PerRoc*cRocId; - uint8_t uErrorType= mess.getGet4V10R24ErrorData(); - - // As long as the 1st epoch with sync flag after SYNC DLM is found, - // consider data as not good - if( kTRUE == fvbGet4WaitFirstSync[uChipFullId] ) - return; - - // Count error messages per ROC - fvhRocErrorCntEvo[cRocId]->Fill( - ( ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs ) - *(1e-12) ); // Time since start in s - // Count error messages per chip - fhMessTypePerGet4->Fill( uChipFullId, get4v1x::GET4_32B_ERROR); - fvhGet4ErrorCntEvo[uChipFullId]->Fill( - ( ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs ) - *(1e-12) ); // Time since start in s - - if( ( get4v1x::GET4_V1X_ERR_EP < uErrorType && - uErrorType < get4v1x::GET4_V1X_ERR_TOK_RING_ST ) ) - fvhGet4ChErrorCntEvo[uChipFullId]->Fill( mess.getGet4V10R24ErrorChan(), - ( ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs ) - *(1e-12) ); // Time since start in s - - if( uChipFullId < kuNbTdcMappedDet ) - if( kiTdcDetMap[uChipFullId] < kiNbDet ) - fvhDetErrorCntEvo[ kiTdcDetMap[uChipFullId] ]->Fill( - ( ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs) - *(1e-12) ); // Time since start in s - break; - } // case get4v1x::SYSMSG_GET4_EVENT - case get4v1x::SYSMSG_CLOSYSYNC_ERROR: - { - break; - } // case get4v1x::SYSMSG_CLOSYSYNC_ERROR - case get4v1x::SYSMSG_TS156_SYNC: - { - break; - } // case get4v1x::SYSMSG_TS156_SYNC - case get4v1x::SYSMSG_GET4V1_32BIT_0: - case get4v1x::SYSMSG_GET4V1_32BIT_1: - case get4v1x::SYSMSG_GET4V1_32BIT_2: - case get4v1x::SYSMSG_GET4V1_32BIT_3: - case get4v1x::SYSMSG_GET4V1_32BIT_4: - case get4v1x::SYSMSG_GET4V1_32BIT_5: - case get4v1x::SYSMSG_GET4V1_32BIT_6: - case get4v1x::SYSMSG_GET4V1_32BIT_7: - case get4v1x::SYSMSG_GET4V1_32BIT_8: - case get4v1x::SYSMSG_GET4V1_32BIT_9: - case get4v1x::SYSMSG_GET4V1_32BIT_10: - case get4v1x::SYSMSG_GET4V1_32BIT_11: - case get4v1x::SYSMSG_GET4V1_32BIT_12: - case get4v1x::SYSMSG_GET4V1_32BIT_13: - case get4v1x::SYSMSG_GET4V1_32BIT_14: - case get4v1x::SYSMSG_GET4V1_32BIT_15: - { - // Ignore all messages before RocFeet system SYNC - if (kFALSE == fvbRocFeetSyncStart[cRocId] ) - break; - - // GET4 v1.x 32b raw message using hack - fhMessageTypePerRoc->Fill( cRocId, 15 ); - fhSysMessTypePerRoc->Fill( cRocId, 15 ); - - MonitorMessage_Get4v1( mess, EqID); - break; - } // case get4v1x::SYSMSG_TS156_SYNC - default: - { - if( kTRUE == fbVerbose ) - LOG(warning)<<"CbmGet4FastMonitor::MonitorMessage_sys => Unknown sysMess type ignored: " - <<mess.getSysMesType(); - break; - } // default: - } // switch( mess.getSysMesType() ) -} -void CbmGet4FastMonitor::MonitorMessage_Get4v1( get4v1x::Message mess, uint16_t EqID) -{ - // GET4 v1.x 32b raw message using hack - uint8_t cRocId = mess.getRocNumber(); - uint8_t cChipId = mess.getGet4V10R32ChipId(); - uint32_t uChipFullId = cChipId + get4v1x::kuMaxGet4PerRoc*cRocId; - uint8_t cMessType = mess.getGet4V10R32MessageType(); - - LOG(debug3)<<"CbmGet4FastMonitor::MonitorMessage_Get4v1 => 32b GET4 message: EqId " - <<EqID<<" roc " - <<cRocId; - - // Reject data of chips above defined limit to avoid overflow/seg fault - if( fuNbGet4 <= uChipFullId ) - { - if( kTRUE == fbVerbose ) - LOG(info)<<"CbmGet4FastMonitor::MonitorMessage_Get4v1 => Ignored message with ChipId above limit!" - <<" ChipId: "<<cChipId - <<" RocId: " <<cRocId - <<" Limit: " <<fuNbGet4; - return; - } // if( fuNbGet4 <= cChipId + kuMaxGet4PerRoc*mess.getRocNumber() ) - - // Reject data of Inactive chips - if( kFALSE == fvbActiveChips[uChipFullId]) - { - if( kTRUE == fbVerbose ) - LOG(info)<<"CbmGet4FastMonitor::MonitorMessage_Get4v1 => Ignored message with Inactive Chip!" - <<" ChipId: "<<cChipId - <<" RocId: " <<cRocId ; - return; - } // if( kFALSE == fvbActiveChips[uChipFullId]) - - // Count messages type per chip - fhMessTypePerGet4->Fill( uChipFullId, cMessType); - - switch( cMessType ) - { - case get4v1x::GET4_32B_EPOCH: // => Epoch message - { - // As long as the 1st epoch with sync flag after SYNC DLM is found, - // consider data as not good - if( kTRUE == fvbGet4WaitFirstSync[uChipFullId] ) - { - if( 1 == mess.getGet4V10R32SyncFlag() ) - { - fvbGet4WaitFirstSync[uChipFullId] = kFALSE; - - LOG(info) << "First SYNC Epoch after DLM in chip " - <<Form("%3u: ", uChipFullId) - <<Form(" EP #%6u", mess.getGet4V10R32EpochNumber() ) - <<Form(" TS #%12llu", fulTsNb) - <<Form(" MS #%5llu/%5lu", fulMsNb, static_cast<ULong_t>(fsMaxMsNb) ) - <<Form(" OF #%5u/%5u", fuOffset, fuMaxOffset) - <<Form(" LO #%5u/%5u", fuLocalOffset, fuMaxLocalOffset); - } // if( 1 == mess.getGet4V10R32SyncFlag() ) - else return; - } // if( kTRUE == fvbGet4WaitFirstSync[uChipFullId] ) - - if( fvuCurrEpoch2[uChipFullId] +1 != mess.getGet4V10R32EpochNumber() && - 0 != fvuCurrEpoch2[uChipFullId] ) - { - Int_t iEpJump = mess.getGet4V10R32EpochNumber(); - iEpJump -= fvuCurrEpoch2[uChipFullId]; - if( TMath::Abs(iEpJump) < 200 ) - { - if( kTRUE == fbDebug ) - LOG(info) << "Epoch nb jump in chip " - <<Form("%3u: ", uChipFullId) - << Form(" %3d (%6u -> %6u)", iEpJump, fvuCurrEpoch2[uChipFullId], - mess.getGet4V10R32EpochNumber() ) - <<Form(" TS #%12llu", fulTsNb) - <<Form(" MS #%5llu/%5lu", fulMsNb, static_cast<ULong_t>(fsMaxMsNb) ) - <<Form(" OF #%5u/%5u", fuOffset, fuMaxOffset) - <<Form(" LO #%5u/%5u", fuLocalOffset, fuMaxLocalOffset); - } // if( TMath::Abs(iEpJump) < 200 ) - else LOG(info) << "Epoch nb jump in chip " - <<Form("%3u: ", uChipFullId) - << Form(" %3d (%6u -> %6u)", iEpJump, fvuCurrEpoch2[uChipFullId], - mess.getGet4V10R32EpochNumber() ) - <<Form(" TS #%12llu", fulTsNb) - <<Form(" MS #%5llu/%5lu", fulMsNb, static_cast<ULong_t>(fsMaxMsNb) ) - <<Form(" OF #%5u/%5u", fuOffset, fuMaxOffset) - <<Form(" LO #%5u/%5u", fuLocalOffset, fuMaxLocalOffset); - - fhGet4EpochJumps->Fill(uChipFullId, iEpJump); - fhGet4BadEpochRatio->Fill(0); - fhGet4BadEpRatioChip->Fill( uChipFullId, 0); - - if( kTRUE == fbPulserMode && fuPulserFee == (uChipFullId/kuNbChipFee) ) - { - UInt_t uChipFeeA = uChipFullId%kuNbChipFee; - for( UInt_t uChan = 0; uChan < get4v1x::kuChanPerGet4; uChan++ ) - if( 0ull != fvmLastHit[ fuPulserFee * kuNbChanFee+ uChipFeeA*get4v1x::kuChanPerGet4+ uChan].getData() ) - { - fhFullCtEpJumpFeeA[uChipFeeA]->Fill( - fvmLastHit[ fuPulserFee * kuNbChanFee+ uChipFeeA*get4v1x::kuChanPerGet4+ uChan].getGet4V10R32HitTs(), - fvmLastHit[ fuPulserFee * kuNbChanFee+ uChipFeeA*get4v1x::kuChanPerGet4+ uChan].getGet4V10R32HitTs() + - fvmLastHit[ fuPulserFee * kuNbChanFee+ uChipFeeA*get4v1x::kuChanPerGet4+ uChan].getGet4V10R32HitTot()/ - static_cast<Int_t>(get4v1x::kdClockCycleSize/get4v1x::kdTotBinSize) ); - fhFullCtEpJumpFeeACh[uChan]->Fill( - fvmLastHit[ fuPulserFee * kuNbChanFee+ uChipFeeA*get4v1x::kuChanPerGet4+ uChan].getGet4V10R32HitTs(), - fvmLastHit[ fuPulserFee * kuNbChanFee+ uChipFeeA*get4v1x::kuChanPerGet4+ uChan].getGet4V10R32HitTs() + - fvmLastHit[ fuPulserFee * kuNbChanFee+ uChipFeeA*get4v1x::kuChanPerGet4+ uChan].getGet4V10R32HitTot()/ - static_cast<Int_t>(get4v1x::kdClockCycleSize/get4v1x::kdTotBinSize) ); - - fhFullCtEpQualityCh[uChan]->Fill( - fvmLastHit[ fuPulserFee * kuNbChanFee+ uChipFeeA*get4v1x::kuChanPerGet4+ uChan].getGet4V10R32HitTs(), 0); - fhFullCtEpQualityChZoom[uChan]->Fill( - fvmLastHit[ fuPulserFee * kuNbChanFee+ uChipFeeA*get4v1x::kuChanPerGet4+ uChan].getGet4V10R32HitTs(), 0); - - if( get4v1x::kuChanPerGet4 == fvChanOrder[uChipFeeA].size() ) - { - UInt_t uChOrder; - for( uChOrder = 0; uChOrder < get4v1x::kuChanPerGet4; uChOrder++ ) - if( uChan == fvChanOrder[uChipFeeA][uChOrder] ) - break; - fhFullCtChOrderCh[uChan]->Fill( - fvmLastHit[ fuPulserFee * kuNbChanFee+ uChipFeeA*get4v1x::kuChanPerGet4+ uChan].getGet4V10R32HitTs(), uChOrder); - } // if( get4v1x::kuChanPerGet4 == fvChanOrder[uChipFeeA].size() ) - } // for( UInt_t uChan = 0; uChan < get4v1x::kuChanPerGet4; uChan++ ) - - if( get4v1x::kuChanPerGet4 == fvChanOrder[uChipFeeA].size() ) - for( UInt_t uChOrder = 0; uChOrder < fvChanOrder[uChipFeeA].size(); uChOrder++ ) - { - UInt_t uChanOrdered = fuPulserFee * kuNbChanFee+ uChipFeeA*get4v1x::kuChanPerGet4+ fvChanOrder[uChipFeeA][uChOrder]; - fhFullCtEpJumpFeeAChSort[uChOrder]->Fill( - fvmLastHit[ uChanOrdered ].getGet4V10R32HitTs(), - fvmLastHit[ uChanOrdered].getGet4V10R32HitTs() + - fvmLastHit[ uChanOrdered ].getGet4V10R32HitTot() / static_cast<Int_t>(get4v1x::kdClockCycleSize/get4v1x::kdTotBinSize) ); - fhFullCtEpJumpFeeAChOrder->Fill( uChOrder, fvChanOrder[uChipFeeA][uChOrder]); - } // for( UInt_t uChOrder = 0; uChOrder < fvChanOrder[uChipFeeA].size(); uChOrder++ ) - - if( 0 < fvChanOrder[uChipFeeA].size() ) - fhEpQualityFirstChFeeA[uChipFeeA]->Fill( fvChanOrder[uChipFeeA][0], 0 ); - } // if( kTRUE == fbPulserMode && fuPulserFee == (uChipFullId/kuNbChipFee) ) - } // if( fvuCurrEpoch2[uChipFullId] +1 != mess.getGet4V10R32EpochNumber()) - else - { - fhGet4BadEpochRatio->Fill(1); - fhGet4BadEpRatioChip->Fill( uChipFullId, 1); - if( kTRUE == fbPulserMode && fuPulserFee == (uChipFullId/kuNbChipFee) ) - { - UInt_t uChipFeeA = uChipFullId%kuNbChipFee; - - for( UInt_t uChan = 0; uChan < get4v1x::kuChanPerGet4; uChan++ ) - if( 0ull != fvmLastHit[ fuPulserFee * kuNbChanFee+ uChipFeeA*get4v1x::kuChanPerGet4+ uChan].getData() ) - { - fhFullCtEpQualityCh[uChan]->Fill( - fvmLastHit[ fuPulserFee * kuNbChanFee+ uChipFeeA*get4v1x::kuChanPerGet4+ uChan].getGet4V10R32HitTs(), 1); - fhFullCtEpQualityChZoom[uChan]->Fill( - fvmLastHit[ fuPulserFee * kuNbChanFee+ uChipFeeA*get4v1x::kuChanPerGet4+ uChan].getGet4V10R32HitTs(), 1); - } // for( UInt_t uChan = 0; uChan < get4v1x::kuChanPerGet4; uChan++ ) - - if( 0 < fvChanOrder[uChipFeeA].size() ) - fhEpQualityFirstChFeeA[uChipFeeA]->Fill( fvChanOrder[uChipFeeA][0], 1 ); - } // if( kTRUE == fbPulserMode && fuPulserFee == (uChipFullId/kuNbChipFee) ) - } // else of if( fvuCurrEpoch2[uChipFullId] +1 != mess.getGet4V10R32EpochNumber()) - - // Epoch counter overflow book keeping - if( (get4v1x::kulGet4EpochCycleSz - 2) < fvuCurrEpoch2[uChipFullId] && - mess.getEpoch2Number() < 2 ) - fvuCurrEpoch2Cycle[uChipFullId]++; - - fvuCurrEpoch2[uChipFullId] = mess.getGet4V10R32EpochNumber(); - - fvhRocEpochCntEvo[cRocId]->Fill( - ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs*(1e-12) ); // Time since start in s - - if( 1 == mess.getGet4V10R32SyncFlag() ) - { - fhGet4EpochFlags->Fill(uChipFullId , 0); - fhGet4EpochSyncDist->Fill( uChipFullId, fvuCurrEpoch2[uChipFullId] % get4v1x::kuSyncCycleSzGet4 ); - } // if( 1 == mess.getGet4V10R32SyncFlag() ) - - // Fill Pulser test histos if needed - // Accepted pairs are when both messages are defined and they are at most - // 1 epoch apart => possibility of double use is the pulse happens on top of - // an epoch and more than once every 3 epochs. For example: - // HHHHEHHHH.......E......HHHHEHHHH leads to - // (HHHHHHHH) (HHHHHHHH) and - // (HHHH HHHH) - if( kTRUE == fbPulserMode && 0 == (uChipFullId%kuNbChipFee) - && fuPulserFee == (uChipFullId/kuNbChipFee) ) - { - // Fill the time difference for all channels pairs in - // the chosen Fee - UInt_t uHistoFeeIdx = 0; - for( UInt_t uChanFeeA = 0; uChanFeeA < kuNbChanFee; uChanFeeA++) - { - for( UInt_t uChanFeeB = uChanFeeA + 1; uChanFeeB < kuNbChanFee; uChanFeeB++) - { - if( ( 0xF0 <= fvmLastHit[ fuPulserFee * kuNbChanFee+ uChanFeeA].getSysMesType() ) && - ( 0xF0 <= fvmLastHit[ fuPulserFee * kuNbChanFee+ uChanFeeB].getSysMesType() ) && - ( fvuLastHitEp[ fuPulserFee * kuNbChanFee+ uChanFeeA ] - < fvuLastHitEp[ fuPulserFee * kuNbChanFee+ uChanFeeB ] + 2 ) && - ( fvuLastHitEp[ fuPulserFee * kuNbChanFee+ uChanFeeA ] + 2 - > fvuLastHitEp[ fuPulserFee * kuNbChanFee+ uChanFeeB ] ) ) - { - Double_t dTimeDiff = 0.0; - dTimeDiff = fvmLastHit[ fuPulserFee * kuNbChanFee+ uChanFeeA].CalcGet4V10R32HitTimeDiff( - fvuLastHitEp[ fuPulserFee * kuNbChanFee+ uChanFeeA], - fvuLastHitEp[ fuPulserFee * kuNbChanFee+ uChanFeeB], - fvmLastHit[ fuPulserFee * kuNbChanFee+ uChanFeeB] ); - - fhTimeResFee[uHistoFeeIdx]->Fill( dTimeDiff ); - } // if both channels have matching data - - if( kTRUE == fbPulserFeeB ) - if( - ( 0xF0 <= fvmLastHit[ fuPulserFeeB * kuNbChanFee+ uChanFeeA].getSysMesType() ) && - ( 0xF0 <= fvmLastHit[ fuPulserFeeB * kuNbChanFee+ uChanFeeB].getSysMesType() ) && - ( fvuLastHitEp[ fuPulserFeeB * kuNbChanFee+ uChanFeeA ] - < fvuLastHitEp[ fuPulserFeeB * kuNbChanFee+ uChanFeeB ] + 2 ) && - ( fvuLastHitEp[ fuPulserFeeB * kuNbChanFee+ uChanFeeA ] + 2 - > fvuLastHitEp[ fuPulserFeeB * kuNbChanFee+ uChanFeeB ] ) ) - { - Double_t dTimeDiffB = 0.0; - dTimeDiffB = fvmLastHit[ fuPulserFeeB * kuNbChanFee+ uChanFeeA].CalcGet4V10R32HitTimeDiff( - fvuLastHitEp[ fuPulserFeeB * kuNbChanFee+ uChanFeeA], - fvuLastHitEp[ fuPulserFeeB * kuNbChanFee+ uChanFeeB], - fvmLastHit[ fuPulserFeeB * kuNbChanFee+ uChanFeeB] ); - - fhTimeResFeeB[uHistoFeeIdx]->Fill( dTimeDiffB ); - } // if both channels in FEE B have matching data - uHistoFeeIdx++; - } // for any unique pair of channel in chosen Fee - - if( kTRUE == fbPulserFeeB ) - for( UInt_t uChanFeeB = 0; uChanFeeB < kuNbChanFee; uChanFeeB++) - { - if( - ( 0xF0 <= fvmLastHit[ fuPulserFee * kuNbChanFee+ uChanFeeA].getSysMesType() ) && - ( 0xF0 <= fvmLastHit[ fuPulserFeeB * kuNbChanFee+ uChanFeeB].getSysMesType() ) && - ( fvuLastHitEp[ fuPulserFee * kuNbChanFee+ uChanFeeA ] - < fvuLastHitEp[ fuPulserFeeB * kuNbChanFee+ uChanFeeB ] + 2 ) && - ( fvuLastHitEp[ fuPulserFee * kuNbChanFee+ uChanFeeA ] + 2 - > fvuLastHitEp[ fuPulserFeeB * kuNbChanFee+ uChanFeeB ] ) ) - { - Double_t dTimeDiffAB = 0.0; - dTimeDiffAB = fvmLastHit[ fuPulserFee * kuNbChanFee+ uChanFeeA].CalcGet4V10R32HitTimeDiff( - fvuLastHitEp[ fuPulserFee * kuNbChanFee+ uChanFeeA], - fvuLastHitEp[ fuPulserFeeB * kuNbChanFee+ uChanFeeB], - fvmLastHit[ fuPulserFeeB * kuNbChanFee+ uChanFeeB] ); - - fhTimeResFeeAB[uChanFeeA * kuNbChanFee + uChanFeeB]->Fill( dTimeDiffAB ); - } // if both channels in FEE A and B have matching data - } // if( kTRUE == fbPulserFeeB ) && for( UInt_t uChanFeeB = uChanFeeA + 1; uChanFeeB < kuNbChanFee; uChanFeeB++) - } // for( UInt_t uChanFeeA = 0; uChanFeeA < kuNbChanFee; uChanFeeA++) - - // Fill the time difference for the chosen channel pairs - UInt_t uHistoCombiIdx = 0; - for( UInt_t uChanA = 0; uChanA < kuNbChanTest-1; uChanA++) - { - if( ( 0xF0 <= fvmLastHit[ fuPulserChan[uChanA] ].getSysMesType() ) && - ( 0xF0 <= fvmLastHit[ fuPulserChan[uChanA+1] ].getSysMesType() ) && - ( fvuLastHitEp[ fuPulserChan[uChanA] ] - < fvuLastHitEp[ fuPulserChan[uChanA+1] ] + 2 ) && - ( fvuLastHitEp[ fuPulserChan[uChanA] ] + 2 - > fvuLastHitEp[ fuPulserChan[uChanA+1] ] ) ) - { - Double_t dTimeDiff = - fvmLastHit[ fuPulserChan[uChanA] ].CalcGet4V10R32HitTimeDiff( - fvuLastHitEp[ fuPulserChan[uChanA] ], - fvuLastHitEp[ fuPulserChan[uChanA+1] ], - fvmLastHit[ fuPulserChan[uChanA+1] ] ); - fhTimeResPairs[uChanA]->Fill( dTimeDiff ); - Double_t dTotA = fvmLastHit[ fuPulserChan[uChanA] ].getGet4V10R32HitTot(); - Double_t dTotB = fvmLastHit[ fuPulserChan[uChanA+1] ].getGet4V10R32HitTot(); - fhTimeResPairsTot[2*uChanA]->Fill( dTimeDiff, dTotA ); - fhTimeResPairsTot[2*uChanA+1]->Fill( dTimeDiff, dTotB ); - } // // if both channels have data - - for( UInt_t uChanB = uChanA+1; uChanB < kuNbChanComb; uChanB++) - { - if( ( 0xF0 <= fvmLastHit[ fuPulserChan[uChanA] ].getSysMesType() ) && - ( 0xF0 <= fvmLastHit[ fuPulserChan[uChanB] ].getSysMesType() ) && - ( fvuLastHitEp[ fuPulserChan[uChanA] ] - < fvuLastHitEp[ fuPulserChan[uChanB] ] + 2 ) && - ( fvuLastHitEp[ fuPulserChan[uChanA] ] + 2 - > fvuLastHitEp[ fuPulserChan[uChanB] ] ) ) - { - Double_t dTimeDiff = - fvmLastHit[ fuPulserChan[uChanA] ].CalcGet4V10R32HitTimeDiff( - fvuLastHitEp[ fuPulserChan[uChanA] ], - fvuLastHitEp[ fuPulserChan[uChanB] ], - fvmLastHit[ fuPulserChan[uChanB] ] ); - fhTimeResCombi[uHistoCombiIdx]->Fill( dTimeDiff ); - - if( ( fvmLastHit[ fuPulserChan[uChanA] ].getGet4V10R32HitFt() < (get4v1x::kuFineCounterSize/2) ) && - ( fvmLastHit[ fuPulserChan[uChanB] ].getGet4V10R32HitFt() < (get4v1x::kuFineCounterSize/2) ) ) - fhTimeResCombiEncA[uHistoCombiIdx]->Fill( dTimeDiff ); - else if( ( (get4v1x::kuFineCounterSize/2) <= fvmLastHit[ fuPulserChan[uChanA] ].getGet4V10R32HitFt() ) && - ( (get4v1x::kuFineCounterSize/2) <= fvmLastHit[ fuPulserChan[uChanB] ].getGet4V10R32HitFt() ) ) - fhTimeResCombiEncB[uHistoCombiIdx]->Fill( dTimeDiff ); - - Double_t dTotA = fvmLastHit[ fuPulserChan[uChanA] ].getGet4V10R32HitTot(); - Double_t dTotB = fvmLastHit[ fuPulserChan[uChanB] ].getGet4V10R32HitTot(); - fhTimeResCombiTot[2*uHistoCombiIdx]->Fill( dTimeDiff, dTotA ); - fhTimeResCombiTot[2*uHistoCombiIdx+1]->Fill( dTimeDiff, dTotB ); - } // if both channels have data - uHistoCombiIdx++; - } // for( UInt_t uChanB = uChanA+1; uChanB < kuNbChanComb; uChanB++) - } // for( UInt_t uChanA = 0; uChanA < kuNbChanTest; uChanA++) - - } // if( kTRUE == fbPulserMode ) - - // for channel readout order in case of epoch jumps - if( kTRUE == fbPulserMode && fuPulserFee == (uChipFullId/kuNbChipFee) ) - fvChanOrder[uChipFullId%kuNbChipFee].clear(); - break; - } // case get4v1x::GET4_32B_EPOCH - case get4v1x::GET4_32B_SLCM: // => Slow control - { - Double_t dFullChId = - get4v1x::kuChanPerGet4*( uChipFullId ) - + mess.getGet4V10R32SlChan() - + 0.5*mess.getGet4V10R32SlEdge(); - - // As long as the 1st epoch with sync flag after SYNC DLM is found, - // consider data as not good - if( kTRUE == fvbGet4WaitFirstSync[uChipFullId] ) - return; - - fhGet4ChanSlowContM->Fill( dFullChId, mess.getGet4V10R32SlType() ); - - switch( mess.getGet4V10R32SlType() ) - { - case get4v1x::GET4_32B_SLC_SCALER: - { - fhGet4ChanEdgesCounts->Fill( dFullChId, mess.getGet4V10R32SlData() ); - break; - } - case get4v1x::GET4_32B_SLC_DEADT: - { - fhGet4ChanDeadtime->Fill( dFullChId, mess.getGet4V10R32SlData() ); - break; - } - case get4v1x::GET4_32B_SLC_SPIREAD: - { - break; - } - case get4v1x::GET4_32B_SLC_START_SEU: - { - // If Ch = 0 and Edge = 1 => SEU counter - // Otherwise => Start message! - if( 0 == mess.getGet4V10R32SlChan() && - 1 == mess.getGet4V10R32SlEdge() ) - fhGet4SeuCounter->Fill( uChipFullId, mess.getGet4V10R32SlData() ); - break; - } - default: - { - break; - } - } // switch( mess.getGet4V10R32SlType() ) - break; - } // case get4v1x::GET4_32B_SLCM - case get4v1x::GET4_32B_ERROR: // => Error message - { - Double_t dFullChId = - get4v1x::kuChanPerGet4*( uChipFullId ) - + mess.getGet4V10R32ErrorChan() - + 0.5*mess.getGet4V10R32ErrorEdge(); - - UInt_t uErrorType = mess.getGet4V10R32ErrorData(); - - // As long as the 1st epoch with sync flag after SYNC DLM is found, - // consider data as not good - if( kTRUE == fvbGet4WaitFirstSync[uChipFullId] ) - return; - - // If debug mode, print the message - if( kTRUE == fbDebug ) - { - LOG(info) <<Form(" TS #%12llu ", fulTsNb); - mess.printDataLog(); - } // if( kTRUE == fbDebug ) - - // Count error messages per ROC - fvhRocErrorCntEvo[cRocId]->Fill( - ( ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs ) - *(1e-12) ); // Time since start in s - if( 0x11 <= uErrorType && uErrorType <= 0x13 ) - fvhRocTotErrorCntEvo[cRocId]->Fill( - ( ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs ) - *(1e-12) ); // Time since start in s - - fvhGet4ErrorCntEvo[uChipFullId]->Fill( - ( ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs) - *(1e-12) ); // Time since start in s - - if( ( get4v1x::GET4_V1X_ERR_EP < uErrorType && - uErrorType < get4v1x::GET4_V1X_ERR_TOK_RING_ST ) || - get4v1x::GET4_V1X_ERR_TOT_OVERWRT == uErrorType || - get4v1x::GET4_V1X_ERR_TOT_RANGE == uErrorType ) - fvhGet4ChErrorCntEvo[uChipFullId]->Fill( mess.getGet4V10R32ErrorChan(), - ( ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs) - *(1e-12) ); // Time since start in s - - if( uChipFullId < kuNbTdcMappedDet ) - if( kiTdcDetMap[uChipFullId] < kiNbDet ) - fvhDetErrorCntEvo[ kiTdcDetMap[uChipFullId] ]->Fill( - ( ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs) - *(1e-12) ); // Time since start in s - - switch( uErrorType ) - { - case get4v1x::GET4_V1X_ERR_READ_INIT: - fhGet4ChanErrors->Fill( dFullChId, 0); - LOG(info)<<"CbmGet4FastMonitor::MonitorMessage_Get4v1 => Readout Init!" - <<" ChipId: "<<Form("%02u", cChipId) - <<" RocId: " <<Form("%02u", cRocId) - <<" TS: " <<fulTsNb; - break; - case get4v1x::GET4_V1X_ERR_SYNC: - fhGet4ChanErrors->Fill( dFullChId, 1); - break; - case get4v1x::GET4_V1X_ERR_EP_CNT_SYNC: - fhGet4ChanErrors->Fill( dFullChId, 2); - break; - case get4v1x::GET4_V1X_ERR_EP: - fhGet4ChanErrors->Fill( dFullChId, 3); - break; - case get4v1x::GET4_V1X_ERR_FIFO_WRITE: - fhGet4ChanErrors->Fill( dFullChId, 4); - break; - case get4v1x::GET4_V1X_ERR_LOST_EVT: - fhGet4ChanErrors->Fill( dFullChId, 5); - break; - case get4v1x::GET4_V1X_ERR_CHAN_STATE: - fhGet4ChanErrors->Fill( dFullChId, 6); - break; - case get4v1x::GET4_V1X_ERR_TOK_RING_ST: - fhGet4ChanErrors->Fill( dFullChId, 7); - break; - case get4v1x::GET4_V1X_ERR_TOKEN: - fhGet4ChanErrors->Fill( dFullChId, 8); - break; - case get4v1x::GET4_V1X_ERR_READOUT_ERR: - fhGet4ChanErrors->Fill( dFullChId, 9); - break; - case get4v1x::GET4_V1X_ERR_SPI: - fhGet4ChanErrors->Fill( dFullChId, 10); - break; - case get4v1x::GET4_V1X_ERR_DLL_LOCK: - fhGet4ChanErrors->Fill( dFullChId, 11); - break; - case get4v1x::GET4_V1X_ERR_DLL_RESET: - fhGet4ChanErrors->Fill( dFullChId, 12); - break; - case get4v1x::GET4_V1X_ERR_TOT_OVERWRT: - fhGet4ChanErrors->Fill( dFullChId, 13); - fhGet4ChanTotOwErrorsProp->Fill( dFullChId, 100.0); - break; - case get4v1x::GET4_V1X_ERR_TOT_RANGE: - fhGet4ChanErrors->Fill( dFullChId, 14); - fhGet4ChanTotOrErrorsProp->Fill( dFullChId, 100.0); - break; - case get4v1x::GET4_V1X_ERR_EVT_DISCARD: - fhGet4ChanErrors->Fill( dFullChId, 15); - fhGet4ChanTotEdErrorsProp->Fill( dFullChId, 100.0); - break; - case get4v1x::GET4_V1X_ERR_UNKNOWN: - fhGet4ChanErrors->Fill( dFullChId, 16); - break; - default: // Corrupt error or not yet supported error - fhGet4ChanErrors->Fill( dFullChId, 17); - break; - } // switch( mess.getGet4V10R32ErrorData() ) - break; - } // case get4v1x::GET4_32B_ERROR - case get4v1x::GET4_32B_DATA: // => Hit Data - { - UInt_t uFullChId = - get4v1x::kuChanPerGet4*( uChipFullId ) - + mess.getGet4V10R32HitChan(); - - // As long as the 1st epoch with sync flag after SYNC DLM is found, - // consider data as not good - if( kTRUE == fvbGet4WaitFirstSync[uChipFullId] ) - return; - - fvhRocDataCntEvo[cRocId]->Fill( - ( ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs - + mess.getGet4V10R32HitTimeBin() *get4v1x::kdBinSize ) - *(1e-12) ); // Time since start in s - fvhGet4DataCntEvo[uChipFullId]->Fill( - ( ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs - + mess.getGet4V10R32HitTimeBin() *get4v1x::kdBinSize ) - *(1e-12) ); // Time since start in s - fvhGet4ChDataCntEvo[uChipFullId]->Fill( mess.getGet4V10R32HitChan(), - ( ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs - + mess.getGet4V10R32HitTimeBin() *get4v1x::kdBinSize ) - *(1e-12) ); // Time since start in s - if( uChipFullId < kuNbTdcMappedDet ) - if( kiTdcDetMap[uChipFullId] < kiNbDet ) - fvhDetDataCntEvo[ kiTdcDetMap[uChipFullId] ]->Fill( - ( ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs - + mess.getGet4V10R32HitTimeBin() *get4v1x::kdBinSize ) - *(1e-12) ); // Time since start in s - - fhGet4ChanDataCount->Fill( uFullChId ); - fhGet4ChanDllStatus->Fill( uFullChId, mess.getGet4V10R32HitDllFlag() ); - fhGet4ChanTotMap->Fill( uFullChId, mess.getGet4V10R32HitTot() - *get4v1x::kdTotBinSize/1000.0 ); - - if( kTRUE == fbEnaCalibOutput ) - fvhFineTime[ uChipFullId ][ mess.getGet4V10R32HitChan() ]->Fill( mess.getGet4V10R32HitFt() ); - - if( kTRUE == fbPulserMode ) - { - // First fill time interval histos - if( fuPulserFee == (uFullChId/kuNbChanFee) ) - { - Double_t dHitsDt = mess.CalcGet4V10R32HitTimeDiff( - fvuCurrEpoch2[uChipFullId], - fvuLastHitEp[ uFullChId ], - fvmLastHit[ uFullChId ] ); - if( 0 == fvuLastHitEp[uFullChId]) - {} - else if( dHitsDt < 1e6 ) - fhPulserHitDistNs->Fill( uFullChId%kuNbChanFee, dHitsDt / 1e3 ); - else if( dHitsDt < 1e9) - fhPulserHitDistUs->Fill( uFullChId%kuNbChanFee, dHitsDt / 1e6 ); - else - fhPulserHitDistMs->Fill( uFullChId%kuNbChanFee, dHitsDt / 1e9 ); - - if( 0 < fvuLastHitEp[uFullChId] && dHitsDt < 5e3 ) - LOG(debug) <<uFullChId<<" "<<dHitsDt<<" " - <<fvuLastHitEp[ uFullChId ]<<" "<<fvuCurrEpoch2[uChipFullId]<<" " - <<fvmLastHit[ uFullChId ].getGet4V10R32HitTot()*get4v1x::kdTotBinSize/1000.0<<" " - <<mess.getGet4V10R32HitTot()*get4v1x::kdTotBinSize/1000.0;; - - // Fill the DNL histos - fhPulserFeeDnl->Fill( uFullChId%kuNbChanFee, mess.getGet4V10R32HitFt() ); - - // Fill the CT histo - fhPulserFeeDistCT[ uChipFullId%kuNbChipFee ]->Fill( mess.getGet4V10R32HitTs(), mess.getGet4V10R32HitChan()); - } // if( fuPulserFee == (uFullChId/kuNbChanFee) ) - } // if( kTRUE == fbPulserMode ) - - // Fill time coincidence map - for( UInt_t uFeeA = 0; uFeeA < fuNbFee; uFeeA++) - for( UInt_t uFeeChan = 0; uFeeChan < get4v1x::kuChanPerFee; uFeeChan++ ) - if( ( 0xF0 <= fvmLastHit[ uFeeA*get4v1x::kuChanPerFee + uFeeChan ].getSysMesType() ) && - ( fvuLastHitEp[ uFeeA*get4v1x::kuChanPerFee + uFeeChan/get4v1x::kuChanPerGet4 ] - < fvuCurrEpoch2[uChipFullId] + 2 ) && - ( fvuLastHitEp[ uFeeA*get4v1x::kuChanPerFee + uFeeChan/get4v1x::kuChanPerGet4 ] + 2 - > fvuCurrEpoch2[uChipFullId] ) ) - { - // compare to last hit in other channekl - Double_t dHitsDt = mess.CalcGet4V10R32HitTimeDiff( - fvuCurrEpoch2[uChipFullId], - fvuLastHitEp[ uFeeA*get4v1x::kuChanPerFee + uFeeChan/get4v1x::kuChanPerGet4 ], - fvmLastHit[ uFeeA*get4v1x::kuChanPerFee + uFeeChan ] ); - if( TMath::Abs(dHitsDt) < fdMaxCoincDist ) - { - if( uFeeA*get4v1x::kuChanPerFee + uFeeChan < uFullChId ) - fvvhChannelsCoinc[uFeeA][uFullChId/get4v1x::kuChanPerFee]->Fill( - uFeeChan, uFullChId%get4v1x::kuChanPerFee); - else fvvhChannelsCoinc[uFullChId/get4v1x::kuChanPerFee][uFeeA]->Fill( - uFullChId%get4v1x::kuChanPerFee, uFeeChan); - } // if( TMath::Abs(dHitsDt) < fdMaxCoincDist ) - } // for each pair, if both hits valid - - // Multiple hits (reflections, ...) detection - if( 1 == fiMode) - { - Double_t dHitsDt = mess.CalcGet4V10R32HitTimeDiff( - fvuCurrEpoch2[uChipFullId], - fvuLastHitEp[ uFullChId ], - fvmLastHit[ uFullChId ] ); - if( dHitsDt < fdMaxDtMultiHit ) - { - if( kFALSE == fvbChanSecondHit[uChipFullId][mess.getGet4V10R32HitChan()] ) - { - fvhGet4MultipleHits[uChipFullId]->Fill( mess.getGet4V10R32HitChan(), 2); - fvhGet4DistDoubleHits[uChipFullId]->Fill( mess.getGet4V10R32HitChan(), dHitsDt); - fvbChanSecondHit[uChipFullId][mess.getGet4V10R32HitChan()] = kTRUE; - - fvhGet4MultipleHitsVsTot[uChipFullId]->Fill( - fvdChanFirstHitTot[uChipFullId][mess.getGet4ChNum()], 2); - } - else if ( kFALSE == fvbChanThirdHit[uChipFullId][mess.getGet4V10R32HitChan()] ) - { - fvhGet4MultipleHits[uChipFullId]->Fill( mess.getGet4V10R32HitChan(), 3); - fvhGet4DistTripleHits[uChipFullId]->Fill( mess.getGet4V10R32HitChan(), dHitsDt); - fvbChanThirdHit[uChipFullId][mess.getGet4V10R32HitChan()] = kTRUE; - - fvhGet4MultipleHitsVsTot[uChipFullId]->Fill( - fvdChanFirstHitTot[uChipFullId][mess.getGet4ChNum()], 3); - } - else - { - fvhGet4MultipleHits[uChipFullId]->Fill( mess.getGet4V10R32HitChan(), 4); - fvhGet4DistMultipleHits[uChipFullId]->Fill( mess.getGet4V10R32HitChan(), dHitsDt); - - fvhGet4MultipleHitsVsTot[uChipFullId]->Fill( - fvdChanFirstHitTot[uChipFullId][mess.getGet4ChNum()], 4); - } - } // if( dHitsDt < fdMaxDtMultiHit ) - else - { - fvhGet4MultipleHits[uChipFullId]->Fill( mess.getGet4V10R32HitChan(), 1); - fvbChanSecondHit[uChipFullId][mess.getGet4V10R32HitChan()] = kFALSE; - fvbChanThirdHit[uChipFullId][mess.getGet4V10R32HitChan()] = kFALSE; - - fvdChanFirstHitTot[uChipFullId][mess.getGet4ChNum()] = - mess.getGet4V10R32HitTot() * get4v1x::kdTotBinSize/1000.0; - fvhGet4MultipleHitsVsTot[uChipFullId]->Fill( - fvdChanFirstHitTot[uChipFullId][mess.getGet4ChNum()], 1); - } // else of if( dHitsDt < fdMaxDtMultiHit ) - } // if( 1 == fiMode) - - // Save the hit info in order to fill later the histos - // Epoch of Last hit message (one per GET4 chip & channel) - fvuLastHitEp[ uFullChId ] = fvuCurrEpoch2[uChipFullId]; - // Last hit message (one per GET4 chip & channel) - fvmLastHit[ uFullChId ] = mess; - - // for the channel readout order in case of epoch jump - if( kTRUE == fbPulserMode && fuPulserFee == (uChipFullId/kuNbChipFee)) - fvChanOrder[uChipFullId%kuNbChipFee].push_back( mess.getGet4V10R32HitChan() ); - - fhGet4ChanTotOwErrorsProp->Fill( uFullChId, 0.0); - fhGet4ChanTotOrErrorsProp->Fill( uFullChId, 0.0); - fhGet4ChanTotEdErrorsProp->Fill( uFullChId, 0.0); - - break; - } // case get4v1x::GET4_32B_DATA - } // switch( cMessType ) - -} -//**********************************************/ - -Bool_t CbmGet4FastMonitor::WriteCalibrationFile() -{ - TTimeStamp timeCurrent; - TDirectory* oldDir = gDirectory; - TString sCalibOutFilename; - if( "" == fsCalibFilename ) - sCalibOutFilename = Form("%sTofTdcCalibHistos_%u_%u.root", fsCalibOutFoldername.Data(), timeCurrent.GetDate( kFALSE), timeCurrent.GetTime( kFALSE) ); - else sCalibOutFilename = Form("%sTofTdcCalibHistos_%s.root", fsCalibOutFoldername.Data(), fsCalibFilename.Data() ); - TFile* fileCalibrationOut = new TFile( sCalibOutFilename, "RECREATE", - Form("Calibration Data for ToF TDCs, saved from analysis on %s", timeCurrent.AsString("lc") ), - 9); - if( kTRUE == fileCalibrationOut->IsOpen() ) - { - sCalibOutFilename += ":/"; - gDirectory->Cd(sCalibOutFilename); - - UInt_t uNbChan = get4v1x::kuChanPerGet4; - - if( 0 == uNbChan ) - { - LOG(info)<<"CbmGet4FastMonitor::WriteCalibrationFile Undefined tdc parameters for type "; - LOG(info)<<"get4"; - LOG(info)<<" => No calib histo saving!"; - return kFALSE; - } - - TString sInfoSaving = "Saved initial calibration histograms for following get4 channels:"; - LOG(info)<<sInfoSaving; - - sInfoSaving = " "; - for( UInt_t uChanInd = 0; uChanInd< uNbChan; uChanInd++) - sInfoSaving += Form("%3u ", uChanInd); - LOG(info)<<sInfoSaving; - - for( UInt_t uGet4 = 0; uGet4 < fuNbGet4; uGet4 ++) -// if( kTRUE == fvbActiveChips[uGet4] ) // Calibration TDC indexing not compatible - { - sInfoSaving = Form("tdc #%3u: ",uGet4 ); - for( UInt_t uChanInd = 0; uChanInd< uNbChan; uChanInd++) - { - TString sCalibHistoOutputName = Form("tof_get4_ft_b%03u_ch%03u", - uGet4, uChanInd ); - - // New Calibration histo using only new data -// if( 0 < (fvhFineTime[ uGet4 ][ uChanInd ]->GetEntries() ) ) // Calibration TDC requires all channels there - { - fvhFineTime[ uGet4 ][ uChanInd ]->Write( sCalibHistoOutputName, TObject::kOverwrite); - sInfoSaving += " 1 "; - } // if( 0 < (fvhFineTime[ uGet4 ][ uChanInd ]->GetEntries() ) ) -// else sInfoSaving += " 0 "; - } // for( Int_t uChanInd = 0; uChanInd< uNbChan; uChanInd++) - LOG(info)<<sInfoSaving; - } // for( Int_t uGet4 = 0; uGet4 < fuNbGet4; uGet4 ++) - - //fileCalibrationOut->Write("",TObject::kOverwrite); - fileCalibrationOut->Close(); - LOG(info)<<"Calibration data saved in "<<sCalibOutFilename; - LOG(info)<<"Parameter line: InitialCalibFilename: Text_t " - << (static_cast<TString>( sCalibOutFilename(0, sCalibOutFilename.Length() -2 ) )); - } // if( kTRUE == fileCalibrationOut->IsOpen() ) - else LOG(warning)<<"CbmGet4FastMonitor::WriteCalibrationFile => Unable to open root file " - <<sCalibOutFilename - <<" to save calibration data, please check settings"; - gDirectory->Cd(oldDir->GetPath()); - - return kTRUE; -} - -ClassImp(CbmGet4FastMonitor) diff --git a/beamtime/cern2014/get4/CbmGet4FastMonitor.h b/beamtime/cern2014/get4/CbmGet4FastMonitor.h deleted file mode 100644 index cc594e2879c7f60ece157b7d616b9e1b04ebbceb..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/get4/CbmGet4FastMonitor.h +++ /dev/null @@ -1,328 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmGet4FastMonitor ----- -// ----- Created 15.12.2014 by ----- -// ----- P.-A. Loizeau ----- -// ----- Based on CbmTSUnpackNxyter ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CBMFASTGET4MONITOR_H -#define CBMFASTGET4MONITOR_H - -#include "Timeslice.hpp" - -// Specific headers -#include "CbmGet4v1xHackDef.h" -#include "CbmTSUnpack.h" - -// ROOT headers -#include "TClonesArray.h" - -// C++ std headers -#include <vector> -//#include <map> -//#include <set> - -class TH1; -class TH2; -class TProfile; - -const UInt_t kuNbChanFee = 32; -const UInt_t kuNbChipFee = 8; -const UInt_t kuNbChanTest = 16; -const UInt_t kuNbChanComb = 4; - -class CbmGet4FastMonitor : public CbmTSUnpack -{ -public: - - CbmGet4FastMonitor(); - virtual ~CbmGet4FastMonitor(); - - virtual Bool_t Init(); - - virtual Bool_t DoUnpack(const fles::Timeslice& ts, size_t component); - - virtual void Reset(); - - virtual void Finish(); - - void SetParContainers() {;} - - virtual void FillOutput(boost::any){;} - - inline void SetRocNb( UInt_t uNbRocsIn ) { fuNbRocs = uNbRocsIn; } - inline void SetGet4Nb( UInt_t uNbChipsIn) { fuNbGet4 = uNbChipsIn; } - inline void SetMsOverlapTs( UInt_t uMsOverIn) { fuMsOverlapTs = uMsOverIn; } - void SetActiveGet4( UInt_t uChipsIndex, Bool_t bActiveFlag = kTRUE); - - inline void SetVerbose( Bool_t inVerb = kTRUE ) { fbVerbose = inVerb; } - inline void SetDebug( Bool_t inDeb = kTRUE ) { fbDebug = inDeb; } - inline void SetDebugStartTs( Int_t inDebStart = -1 ) { fiDebugTsStart = inDebStart; } - inline void SetDebugStopTs( Int_t inDebStop = -1 ) { fiDebugTsStop = inDebStop; } - - inline void SetMode( Int_t inMode = 2 ) { fiMode = inMode; } - - inline void SetBinSizeEvoHistos( Double_t dBinSzIn ) { fdEvoBinSizeS = ( 0.0 < dBinSzIn ? dBinSzIn : 1.0);}; - inline void SetLengthEvoHistos( Double_t dLengthIn ) { fdEvoLengthSec = dLengthIn;}; - inline void SetMicroSliceLength( Double_t dMsIn ) { fdMsLengthSec = dMsIn;}; - inline void SetPulserMode( Bool_t inPulserMode = kTRUE ) { fbPulserMode = inPulserMode; } - inline void SetPulserFee( UInt_t inPulserFee = 0 ) { fuPulserFee = inPulserFee; } - inline void SetPulserFeeB( UInt_t inPulserFeeB = 0 ) { fuPulserFeeB = inPulserFeeB; fbPulserFeeB = kTRUE;} - void SetPulserChans( UInt_t inPulserChanA = 0, UInt_t inPulserChanB = 1, UInt_t inPulserChanC = 2, - UInt_t inPulserChanD = 3, UInt_t inPulserChanE = 4, UInt_t inPulserChanF = 5, - UInt_t inPulserChanG = 6, UInt_t inPulserChanH = 7, UInt_t inPulserChanI = 8, - UInt_t inPulserChanJ = 9, UInt_t inPulserChanK = 10, UInt_t inPulserChanL = 11, - UInt_t inPulserChanM = 12, UInt_t inPulserChanN = 13, UInt_t inPulserChanO = 14, - UInt_t inPulserChanP = 15 ); - inline void SetOldReadoutSupp( Bool_t inReadoutAllowed = kTRUE ) { fbOldReadoutOk = inReadoutAllowed; } - inline void SetMissEdgeCheck( Bool_t inMissCheckAllowed = kTRUE ) - { fbOldReadoutOk = inMissCheckAllowed; fbEnableMissingEdgeCheck = inMissCheckAllowed; } - - inline void SetMaxCoincDist( Double_t dMaxDistIn) { fdMaxCoincDist = dMaxDistIn;} - - inline void SetMaxDtMultiHit( Double_t dMaxDt ) { fdMaxDtMultiHit = dMaxDt; }; - - void SetHistoFilename( TString sNameIn ); - - void SetCalibOutOn( Bool_t bCalibOn = kTRUE) { fbEnaCalibOutput = bCalibOn;}; - void SetCalibOutFolder( TString sCalibOUtFolder = "./") { fsCalibOutFoldername = sCalibOUtFolder;}; - void SetCalibFilename( TString sCalibFileName = "") { fsCalibFilename = sCalibFileName;}; - -protected: - // virtual void Register(); - void FinishUnpack(); - -private: - // Behavior control variables - Bool_t fbVerbose; - Bool_t fbDebug; - Int_t fiDebugTsStart; - Int_t fiDebugTsStop; - Int_t fiMode; - TString fsHistoFilename; - - // Hardware related variables => MUST be set on startup by user! - UInt_t fuNbRocs; - UInt_t fuNbGet4; - UInt_t fuNbFee; - UInt_t fuMsOverlapTs; - std::vector< Bool_t > fvbActiveChips; // Active flag to avoid mapping need (one per GET4 chip, def. kTRUE) - - // TS counter - ULong64_t fulTsNb; - ULong64_t fulMsNb; - size_t fsMaxMsNb; - UInt_t fuOffset; - UInt_t fuMaxOffset; - UInt_t fuLocalOffset; - UInt_t fuMaxLocalOffset; - - // SYNC handling - std::vector< Bool_t > fvbRocFeetFirstSyncDlm; // Keep track whether the 1st SYNC DLM was processed (one per ROC) - std::vector< Bool_t > fvbRocFeetSyncStart; // Keep track whether the SYNC DLM was processed (one per ROC) - std::vector< Bool_t > fvbGet4WaitFirstSync; // True until the 1st SYNC Ep2 after DLM is found (one per GET4) - - // Epochs book-keeping variables - std::vector< UInt_t > fvuCurrEpoch; // Current epoch (one per ROC) - std::vector< UInt_t > fvuCurrEpochCycle; // Current cycle of the epoch counter (one per ROC) - std::vector< UInt_t > fvuCurrEpoch2; // Current epoch2 (one per GET4 chip) - std::vector< UInt_t > fvuCurrEpoch2Cycle; // Current cycle of the epoch2 counter (one per GET4 chip) - - // Monitoring related variables - // Base, always on - TH2 * fhMessageTypePerRoc; - TH2 * fhRocSyncTypePerRoc; - TH2 * fhRocAuxTypePerRoc; - TH2 * fhSysMessTypePerRoc; - TH2 * fhMessTypePerGet4; - TH2 * fhGet4EpochFlags; - TH2 * fhGet4EpochSyncDist; - TH2 * fhGet4EpochJumps; - TH1 * fhGet4BadEpochRatio; - TH2 * fhGet4BadEpRatioChip; - TH1 * fhGet4ChanDataCount; - TH2 * fhGet4ChanDllStatus; - TH2 * fhGet4ChanTotMap; - TH2 * fhGet4ChanErrors; - TProfile * fhGet4ChanTotOwErrorsProp; - TProfile * fhGet4ChanTotOrErrorsProp; - TProfile * fhGet4ChanTotEdErrorsProp; - TH2 * fhGet4ChanSlowContM; - TH2 * fhGet4ChanEdgesCounts; - TH2 * fhGet4ChanDeadtime; - TH2 * fhGet4SeuCounter; - // Time evolution of data - Double_t fdEvoBinSizeS; - Double_t fdEvoLengthSec; - Double_t fdMsLengthSec; - TProfile * fhMsSizeEvo; - std::vector< TH1 * > fvhRocDataCntEvo; - std::vector< TH1 * > fvhRocEpochCntEvo; - std::vector< TH1 * > fvhRocErrorCntEvo; - std::vector< TH1 * > fvhRocTotErrorCntEvo; - std::vector< TH1 * > fvhRocEpochMissmCntEvo; - std::vector< TH1 * > fvhRocDataLossCntEvo; - std::vector< TH1 * > fvhRocEpochLossCntEvo; - std::vector< TH1 * > fvhGet4DataCntEvo; - std::vector< TH1 * > fvhGet4ErrorCntEvo; - std::vector< TH1 * > fvhGet4EpochMissmCntEvo; - std::vector< TH1 * > fvhGet4DataLossCntEvo; - std::vector< TH1 * > fvhGet4EpochLossCntEvo; - std::vector< TH2 * > fvhGet4ChDataCntEvo; - std::vector< TH2 * > fvhGet4ChErrorCntEvo; - std::vector< TH1 * > fvhDetDataCntEvo; - std::vector< TH1 * > fvhDetErrorCntEvo; - std::vector< TH1 * > fvhDetEpochMissmCntEvo; - std::vector< TH1 * > fvhDetDataLossCntEvo; - std::vector< TH1 * > fvhDetEpochLossCntEvo; - TProfile * fhClosedEpSizeEvo; - // TDC pulser test, works up to 1 hits per 2 epoch - Bool_t fbPulserMode; - UInt_t fuPulserFee; - UInt_t fuPulserChan[kuNbChanTest]; //! - std::vector< UInt_t > fvuLastHitEp; // Epoch of Last hit message (one per GET4 chip & channel) - std::vector< get4v1x::Message > fvmLastHit; // Last hit message (one per GET4 chip & channel) - TH1 * fhTimeResFee[kuNbChanFee*(kuNbChanFee-1)/2]; //! - TH2 * fhTimeRmsAllFee; - TH2 * fhTimeResAllFee; - //--------------------------------------------------------------// - Bool_t fbPulserFeeB; - UInt_t fuPulserFeeB; - TH1 * fhTimeResFeeB[kuNbChanFee*(kuNbChanFee-1)/2]; //! - TH2 * fhTimeRmsAllFeeB; - TH2 * fhTimeResAllFeeB; - TH1 * fhTimeResFeeAB[kuNbChanFee*kuNbChanFee]; //! - TH2 * fhTimeRmsAllFeeAB; - TH2 * fhTimeResAllFeeAB; - //--------------------------------------------------------------// - TH1 * fhTimeRmsAllPairs; - TH1 * fhTimeResAllPairs; - TH2 * fhTimeRmsAllCombi; - TH2 * fhTimeResAllCombi; - TH1 * fhTimeResPairs[kuNbChanTest - 1]; //! - TH1 * fhTimeResCombi[kuNbChanComb*(kuNbChanComb-1)/2]; //! - TH2 * fhTimeResPairsTot[(kuNbChanTest - 1)*2]; //! - TH2 * fhTimeResCombiTot[(kuNbChanComb*(kuNbChanComb-1)/2)*2]; //! - TH1 * fhTimeResCombiEncA[kuNbChanComb*(kuNbChanComb-1)/2]; //! - TH1 * fhTimeResCombiEncB[kuNbChanComb*(kuNbChanComb-1)/2]; //! - TH2 * fhTimeRmsAllCombiEncA; - TH2 * fhTimeResAllCombiEncA; - TH2 * fhTimeRmsAllCombiEncB; - TH2 * fhTimeResAllCombiEncB; - TH2 * fhPulserHitDistNs; - TH2 * fhPulserHitDistUs; - TH2 * fhPulserHitDistMs; - TH2 * fhPulserFeeDnl; - TH2 * fhPulserFeeInl; - std::vector<TH2 *> fhPulserFeeDistCT; - //--------------------------------------------------------------// - std::vector< UInt_t > fvuPrevHitEp; //! Epoch of previous hit message (one per GET4 chip & channel) - std::vector< get4v1x::Message > fvmPrevHit; //! Previous hit message (one per GET4 chip & channel) - // Finetime monitoring for hits with normal pulser time difference and too big difference - TH2 * fhFtSmallDtFeeA; - TH2 * fhFtSmallDtFeeB; - TH2 * fhFtBigDtFeeA; - TH2 * fhFtBigDtFeeB; - TH2 * fhFtPrevSmallDtFeeA; - TH2 * fhFtPrevSmallDtFeeB; - TH2 * fhFtPrevBigDtFeeA; - TH2 * fhFtPrevBigDtFeeB; - // Coarse time and Tot full coarse time of last hits in 32b mode when epoch jumps found - std::vector<TH2 *> fhFullCtEpJumpFeeA; - std::vector<TH2 *> fhFullCtEpJumpFeeACh; - std::vector<TH2 *> fhFullCtEpJumpFeeAChSort; - TH2 * fhFullCtEpJumpFeeAChOrder; - std::vector<std::vector<UInt_t>> fvChanOrder; - std::vector<TH2 *> fhFullCtChOrderCh; - std::vector<TH2 *> fhFullCtEpQualityCh; - std::vector<TH2 *> fhFullCtEpQualityChZoom; - std::vector<TH2 *> fhEpQualityFirstChFeeA; - // Monitoring of 24b mode for debugging purpose - Bool_t fbOldReadoutOk; - TH1 * fhGet4ChanTotCount; - std::vector< UInt_t > fvuLastOldTotEp; //! Epoch of Last TOT message (one per GET4 chip & channel) - std::vector< get4v1x::Message > fvmLastOldTot; //! Last TOT message (one per GET4 chip & channel) - // - TH2 * fhPulserFeeTotDnl; - TH2 * fhPulserFeeTotInl; - TH2 * fhPulserFeeRisCtWideBins; - TH2 * fhPulserFeeFalCtWideBins; - Bool_t fbEnableMissingEdgeCheck; - std::vector< UInt_t > fvuLastTotInFtBins; - TH2 * fhPulserFeeFtRecoMissRis; - TH2 * fhPulserFeeFtRecoMissFal; - std::vector< UInt_t > fvuNbRisEdgeEpoch; - std::vector< UInt_t > fvuNbFalEdgeEpoch; - TH2 * fhPulserFeeExtraRisEp; - TH2 * fhPulserFeeExtraFalEp; - TH2 * fhPulserFeeExtraEdgesEp; - std::vector< UInt_t > fvuFeePrevRisEp; //! Epoch of previous to last Rising edge message (one per GET4 channel in Fee) - std::vector< get4v1x::Message > fvmFeePrevRis; //! Previous to last Rising edge message (one per GET4 channel in fee) - std::vector< UInt_t > fvuFeePrevFalEp; //! Epoch of previous to last Falling edge message (one per GET4 channel in Fee) - std::vector< get4v1x::Message > fvmFeePrevFal; //! Previous to last Falling edge message (one per GET4 channel in fee) - TH2 * fhPulserFeeFtExtraEdgeRisA; - TH2 * fhPulserFeeFtExtraEdgeFalA; - TH2 * fhPulserFeeFtExtraEdgeRisB; - TH2 * fhPulserFeeFtExtraEdgeFalB; - TH2 * fhPulserFeeGoodTot; - TH2 * fhPulserFeeExtraRecoTot; - std::vector<TH2 *> fhPulserFeeTotDistCT; - //--------------------------------------------------------------// - std::vector< UInt_t > fvuPrevOldTotEp; //! Epoch of previous TOT message (one per GET4 chip & channel) - std::vector< get4v1x::Message > fvmPrevOldTot; //! Previous TOT message (one per GET4 chip & channel) - // TOT Finetime monitoring for hits with normal pulser time difference and too big difference - TH2 * fhFtTotSmallDtFeeA; - TH2 * fhFtTotSmallDtFeeB; - TH2 * fhFtTotBigDtFeeA; - TH2 * fhFtTotBigDtFeeB; - TH2 * fhFtPrevTotSmallDtFeeA; - TH2 * fhFtPrevTotSmallDtFeeB; - TH2 * fhFtPrevTotBigDtFeeA; - TH2 * fhFtPrevTotBigDtFeeB; - // Channel coincidences - std::vector< std::vector< TH2 * > > fvvhChannelsCoinc; //! - Double_t fdMaxCoincDist; - - // Multiple hits (reflections, ...) detection - std::vector< TH2 * > fvhGet4MultipleHits; //! - std::vector< TH2 * > fvhGet4DistDoubleHits; //! - std::vector< TH2 * > fvhGet4DistTripleHits; //! - std::vector< TH2 * > fvhGet4DistMultipleHits; //! - std::vector< TH2 * > fvhGet4MultipleHitsVsTot; //! - Double_t fdMaxDtMultiHit; - std::vector< std::vector< Bool_t > > fvbChanSecondHit; //! - std::vector< std::vector< Bool_t > > fvbChanThirdHit; //! - std::vector< std::vector< Double_t > > fvdChanFirstHitTot; //! - - // Monitoring functions - void InitMonitorHistograms(); - void MonitorMessage_epoch( get4v1x::Message mess, uint16_t EqID); - void MonitorMessage_sync( get4v1x::Message mess, uint16_t EqID); - void MonitorMessage_aux( get4v1x::Message mess, uint16_t EqID); - void MonitorMessage_sys( get4v1x::Message mess, uint16_t EqID); - void MonitorMessage_epoch2( get4v1x::Message mess, uint16_t EqID); - void MonitorMessage_get4( get4v1x::Message mess, uint16_t EqID); - void MonitorMessage_Get4v1( get4v1x::Message mess, uint16_t EqID); - void FillMonitorHistograms(); - void WriteMonitorHistograms(); - void DeleteMonitorHistograms(); - Bool_t fbHistoWriteDone; - - // Finetime calibration members and method - Bool_t fbEnaCalibOutput; - TString fsCalibOutFoldername; - TString fsCalibFilename; - std::vector< std::vector< TH1 * > > fvhFineTime; //! - Bool_t WriteCalibrationFile(); - - CbmGet4FastMonitor(const CbmGet4FastMonitor&); - CbmGet4FastMonitor operator=(const CbmGet4FastMonitor&); - - void PrintOptions(); - - ClassDef(CbmGet4FastMonitor, 1) -}; - -#endif // CBMFASTGET4MONITOR_H diff --git a/beamtime/cern2014/tasks/CbmTestMiniRichPairBuilder.cxx b/beamtime/cern2014/tasks/CbmTestMiniRichPairBuilder.cxx deleted file mode 100644 index 245bca746e689b696dfd047315022b0949d21519..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/tasks/CbmTestMiniRichPairBuilder.cxx +++ /dev/null @@ -1,122 +0,0 @@ -#include "CbmTestMiniRichPairBuilder.h" - -// ROOT -#include "TClonesArray.h" -#include "TH2D.h" - -// FairRoot -#include "FairLogger.h" - -CbmTestMiniRichPairBuilder::CbmTestMiniRichPairBuilder() : - FairTask() -{ -} - -CbmTestMiniRichPairBuilder::~CbmTestMiniRichPairBuilder() -{ -} - -InitStatus CbmTestMiniRichPairBuilder::Init() -{ - FairRootManager* ioman = FairRootManager::Instance(); - - fInputTrbRawMessages = static_cast<TClonesArray*> (ioman->GetObject("fTrbRawMessages")); - if (!fInputTrbRawMessages) { - LOG(fatal); - return kERROR; - } - - fhToT = new TH2D("fhToT", "ToT;ch;ToT, ns", 33, 0., 33., 2500, 0., 50.); - - return kSUCCESS; -} - -void CbmTestMiniRichPairBuilder::Exec(Option_t*) -{ - LOG(debug3) << "CbmTestMiniRichPairBuilder::Exec"; - - fLeadingEdges.clear(); - fTrailingEdges.clear(); - - LOG(debug3) << "########################################################"; - - Int_t nRawMess = fInputTrbRawMessages->GetEntriesFast(); - for (Int_t iRawMess=0; iRawMess<nRawMess; iRawMess++) { - CbmTrbRawMessage* curRawMess = static_cast<CbmTrbRawMessage*>(fInputTrbRawMessages->At(iRawMess)); - //curRawMess->Print(); - - // Push all leading edges into a list - if (curRawMess->GetEdge() == 1) { - // LEADING EDGE - fLeadingEdges.push_back(curRawMess); - } - - // Find reference timestamp - if (curRawMess->GetSourceAddress() == 0xc001) { - } - } - - LOG(debug3) << "########################################################"; - - nRawMess = fInputTrbRawMessages->GetEntries(); - for (Int_t iRawMess=0; iRawMess<nRawMess; iRawMess++) { - CbmTrbRawMessage* curRawMess = static_cast<CbmTrbRawMessage*>(fInputTrbRawMessages->At(iRawMess)); - //curRawMess->Print(); - if (curRawMess->GetEdge() == 0) { - // TRAILING EDGE - - Bool_t v_LEfound = kFALSE; - std::list<CbmTrbRawMessage*>::iterator iter = fLeadingEdges.begin(); - for ( ; iter != fLeadingEdges.end(); ++iter) { - if ((curRawMess->GetSourceAddress() == (*iter)->GetSourceAddress()) && - (curRawMess->GetChannelID() == (*iter)->GetChannelID())) { - Double_t tot = curRawMess->GetFullTime2() - (*iter)->GetFullTime2(); - if ((tot > -20.) && (tot < 200.)) { - // Both leading and trailing edges are accounted - //LOG(debug4) << "pair found. ToT=" << tot; - fhToT->Fill(curRawMess->GetChannelID(), tot); - fLeadingEdges.erase(iter); - v_LEfound = kTRUE; - break; - } /*else { - // Wrong ToT for the current pair - }*/ - } /*else { - // Leading edge is of a different channel - }*/ - } - if (!v_LEfound) { - fTrailingEdges.push_back(curRawMess); - } - } - } - - if (fTrailingEdges.size() != 0) { - LOG(warning) << fTrailingEdges.size() << " trailing edges are left without a leading edge."; - } - -/* - LOG(debug3) << "########################################################"; - - std::list<CbmTrbRawMessage*>::iterator iterL = fLeadingEdges.begin(); - - LOG(debug4) << "Remaining leading edges:"; - for (; iterL != fLeadingEdges.end(); ++iterL) { - (*iterL)->Print(); - } - - std::list<CbmTrbRawMessage*>::iterator iterT = fTrailingEdges.begin(); - LOG(debug4) << "Remaining trailing edges:"; - for (; iterT != fTrailingEdges.end(); ++iterT) { - (*iterT)->Print(); - } -*/ - LOG(debug3) << "########################################################"; -} - -void CbmTestMiniRichPairBuilder::Finish() -{ - fhToT->Write(); -} - -ClassImp(CbmTestMiniRichPairBuilder) diff --git a/beamtime/cern2014/tasks/CbmTestMiniRichPairBuilder.h b/beamtime/cern2014/tasks/CbmTestMiniRichPairBuilder.h deleted file mode 100644 index a8bae456eff3706a99983ac384580516dc9a06c4..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/tasks/CbmTestMiniRichPairBuilder.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef CBMTESTMINIRICHPAIRBUILDER_H -#define CBMTESTMINIRICHPAIRBUILDER_H - -#include "FairTask.h" // mother class - -// STD -#include <list> - -// CbmRoot -#include "CbmTrbRawMessage.h" - -class TClonesArray; -class TH2D; - -class CbmTestMiniRichPairBuilder : public FairTask -{ -public: - CbmTestMiniRichPairBuilder(); - virtual ~CbmTestMiniRichPairBuilder(); - - virtual InitStatus Init(); - - virtual void Exec(Option_t* opt); - - virtual void Finish(); - -private: - - TClonesArray* fInputTrbRawMessages; - - TH2D* fhToT; - - std::list<CbmTrbRawMessage*> fLeadingEdges; - std::list<CbmTrbRawMessage*> fTrailingEdges; - - ClassDef(CbmTestMiniRichPairBuilder, 1); -}; - -#endif // CBMTESTMINIRICHPAIRBUILDER_H diff --git a/beamtime/cern2014/tasks/CbmTrdDaqBuffer.cxx b/beamtime/cern2014/tasks/CbmTrdDaqBuffer.cxx deleted file mode 100644 index 08166686e44bbbdd20fa6ddba3059ee0485f4d76..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/tasks/CbmTrdDaqBuffer.cxx +++ /dev/null @@ -1,106 +0,0 @@ -/** @file CbmDaqBuffer.cxx - ** @author Volker Friese <v.friese@gsi.de> - ** @date 13 December 2013 - **/ - - -#include <iostream> -#include <iomanip> - -#include "TString.h" - -#include "FairLogger.h" - -#include "CbmTrdDaqBuffer.h" - -using std::pair; -using std::multimap; -using std::fixed; -using std::setprecision; - -// ----- Initialisation of static variables ------------------------------ -CbmTrdDaqBuffer* CbmTrdDaqBuffer::fgInstance = NULL; -// --------------------------------------------------------------------------- - - - -// ----- Constructor ----------------------------------------------------- -CbmTrdDaqBuffer::CbmTrdDaqBuffer() : fData() { -} -// --------------------------------------------------------------------------- - - -// ----- Destructor ------------------------------------------------------ -CbmTrdDaqBuffer::~CbmTrdDaqBuffer() { -} -// --------------------------------------------------------------------------- - - - - -// ----- Access to next data --------------------------------------------- -CbmSpadicRawMessage* CbmTrdDaqBuffer::GetNextData(Double_t time) { - - - // --- Check for empty buffer - if ( ! fData.size() ) return NULL; - - // --- Get data from buffer - CbmSpadicRawMessage* rawMessage = NULL; - multimap<Double_t, CbmSpadicRawMessage*>::iterator it = fData.begin(); - CbmSpadicRawMessage* test = it->second; - if ( test->GetTime() < time ) { - rawMessage = test; - fData.erase(it); - } - return rawMessage; - -} -// --------------------------------------------------------------------------- - - - - -// ----- Insert data into buffer ----------------------------------------- -void CbmTrdDaqBuffer::InsertData(CbmSpadicRawMessage* rawMessage) { - - if ( ! rawMessage ) LOG(fatal) << "DaqBuffer: invalid rawMessage pointer"; - - pair<Double_t, CbmSpadicRawMessage*> value (rawMessage->GetFullTime(), rawMessage); - fData.insert(value); - - LOG(debug2) << "TrdDaqBuffer: Inserting rawMessage, EquipmentID " - << rawMessage->GetEquipmentID() - << ", SourceAddress " << rawMessage->GetSourceAddress() - << ", ChannelID " << rawMessage->GetChannelID() - << ", time " << rawMessage->GetFullTime(); - -} -// --------------------------------------------------------------------------- - - - -// ----- Instance -------------------------------------------------------- -CbmTrdDaqBuffer* CbmTrdDaqBuffer::Instance() { - if ( ! fgInstance ) fgInstance = new CbmTrdDaqBuffer(); - return fgInstance; -} -// --------------------------------------------------------------------------- - - - -// ----- Print status ---------------------------------------------------- -void CbmTrdDaqBuffer::PrintStatus() const { - TString sysName; - Int_t size = GetSize(); - LOG(info) << "DaqBuffer: Status "; - if ( ! size ) { - LOG(info) << "empty"; - return; - } - LOG(info) << GetSize() << " rawMessages from " - << fixed << setprecision(9) << GetTimeFirst() * 1.e-9 << " s to " - << GetTimeLast() *1.e-9 << " s"; -} -// --------------------------------------------------------------------------- - diff --git a/beamtime/cern2014/tasks/CbmTrdDaqBuffer.h b/beamtime/cern2014/tasks/CbmTrdDaqBuffer.h deleted file mode 100644 index c15ac5f5a5274e4fa31f458363621c48c3c5d581..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/tasks/CbmTrdDaqBuffer.h +++ /dev/null @@ -1,115 +0,0 @@ -/** @file CbmDaqBuffer.h - ** @author Volker Friese <v.friese@gsi.de> - ** @date 17 July 2012 - **/ - -#ifndef CBMDAQBUFFER_H -#define CBMDAQBUFFER_H 1 - -#include <map> - -#include "CbmSpadicRawMessage.h" - - -/** @Class CbmTrdDaqBuffer - ** @author Volker Friese <v.friese@gsi.de> - ** @date 13 December 2012 - ** @brief Singleton buffer class for CBM raw data - ** - ** The CbmTrdDaqBuffer stores and sorts (w.r.t. time) CBM raw data - ** (currently: CbmSpadicRawMessage) transiently. - ** Data can be send to the buffer by the method InsertData. - ** They can be retrieved by GetNextData, which delivers a - ** time-ordered sequence of raw data objects. - ** - ** There is only one buffer stream, irrespective of the detector system. - ** - ** The buffer handles objects only by pointer, i.e. the data have - ** to be instantiated by the sending task (rawMessagetiser) and - ** deleted by the receiving class (CbmTrdDaq). - **/ -class CbmTrdDaqBuffer -{ - public: - - /** Destructor **/ - ~CbmTrdDaqBuffer(); - - - - /** Pointer to next raw data object - ** up to given time - ** @param time maximal time [ns] - ** @return pointer to raw data object - ** - ** A NULL pointer will be returned if no further data can be released. - ** This does not mean that the buffer is empty. - **/ - CbmSpadicRawMessage* GetNextData(Double_t time); - - - /** Current buffer size - ** @return number of objects in buffer - */ - Int_t GetSize() const { return fData.size(); } - - - /** Get first rawMessage time **/ - Double_t GetTimeFirst() const { - if ( ! GetSize() ) return -1.; - return (fData.begin())->second->GetFullTime(); - } - - - /** Get last rawMessage time **/ - Double_t GetTimeLast() const { - if ( ! GetSize() ) return -1.; - return (--fData.end())->second->GetFullTime(); - } - - - /** Insert data into the buffer - ** @param rawMessage pointer to data object to be inserted - **/ - void InsertData(CbmSpadicRawMessage* rawMessage); - - - /** Access to singleton instance - ** @return pointer to instance - **/ - static CbmTrdDaqBuffer* Instance(); - - - /** Print buffer status **/ - void PrintStatus() const; - - - private: - - - /** Buffer management **/ - std::multimap<Double_t, CbmSpadicRawMessage*> fData; - - - /** Pointer to singleton instance **/ - static CbmTrdDaqBuffer* fgInstance; - - - /** Default constructor - ** Declared private to prevent instantiation. - **/ - CbmTrdDaqBuffer(); - - - /** Copy constructor. Defined private to prevent usage. **/ - CbmTrdDaqBuffer(const CbmTrdDaqBuffer&); - - - /** Assignment operator. Defined private to prevent usage. **/ - CbmTrdDaqBuffer& operator=(const CbmTrdDaqBuffer&); - - - -}; - -#endif /* CBMDAQBUFFER_H */ diff --git a/beamtime/cern2014/tasks/CbmTrdEveOnlineDisplay.cxx b/beamtime/cern2014/tasks/CbmTrdEveOnlineDisplay.cxx deleted file mode 100644 index 0c3e9090573dfaae40d3a62ad575d56b1e6dc12c..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/tasks/CbmTrdEveOnlineDisplay.cxx +++ /dev/null @@ -1,261 +0,0 @@ -#include "CbmTrdEveOnlineDisplay.h" - -#include "CbmHistManager.h" -#include "CbmTrdRawBeamProfile.h" - -#include "FairLogger.h" - -#include "TCanvas.h" -#include "TPad.h" -#include "TStyle.h" -#include "TH1.h" -#include "TH2.h" -#include "TString.h" -#include "TROOT.h" -#include "TSeqCollection.h" -#include "TTask.h" -#include "TClass.h" -#include "TDataMember.h" -#include "TMethodCall.h" -#include "TEveManager.h" -#include "TEveBrowser.h" -#include "TGFileBrowser.h" -#include "TMacro.h" -#include "TFolder.h" - -TCanvas* g_Canvas = NULL; -TCanvas* g_Spadic1 = NULL; -TGFileBrowser* g_Browser =NULL; - -// ---- Default constructor ------------------------------------------- -CbmTrdEveOnlineDisplay::CbmTrdEveOnlineDisplay() - :FairTask("CbmTrdEveOnlineDisplay"), - // fCanvas(NULL), - fSpadic1(NULL), - fSpadic1a(NULL), - // fBrowser(NULL), - fUpdateInterval(10), - fEventCounter(0) -{ -} - -// ---- Destructor ---------------------------------------------------- -CbmTrdEveOnlineDisplay::~CbmTrdEveOnlineDisplay() -{ - // delete fCanvas; - delete fSpadic1; - delete fSpadic1a; - // delete fBrowser; -} - -// ---- Initialisation ---------------------------------------------- -void CbmTrdEveOnlineDisplay::SetParContainers() -{ -} - -// ---- Init ---------------------------------------------------------- -InitStatus CbmTrdEveOnlineDisplay::Init() -{ - - TEveManager::Create(); - - // --- Create special browser - - gEve->GetBrowser()->StartEmbedding(0); - g_Browser = gEve->GetBrowser()->MakeFileBrowser(); - gEve->GetBrowser()->StopEmbedding("TRD Canvas"); - - TMacro* m; - - m = new TMacro; - m->AddLine("{ g_Browser->Clear();" - " g_Browser->cd();" - " g_Browser->Update(); }"); - m->SetName("Clear Canvas"); - g_Browser->Add(m); - - TH1* h1 = NULL; - TH1* h2 = NULL; - gROOT->cd(); - Float_t lsize=0.07; - gStyle->SetPalette(1); - gStyle->SetLabelSize(lsize); - - - // --- Create an embedded canvas - - gEve->GetBrowser()->StartEmbedding(1); - g_Canvas = new TCanvas; - gEve->GetBrowser()->StopEmbedding("TRD Canvas"); - - gEve->GetBrowser()->StartEmbedding(1); - g_Spadic1 = new TCanvas;//("fSpadic1", "Spadic1", 0, 0, 1010, 810); - gEve->GetBrowser()->StopEmbedding("TRD Canvas"); - g_Spadic1->Divide(3,2); - - // Should be set for each pad of the Canvas - gPad->SetFillColor(0); - - g_Spadic1->cd(1); - h1=static_cast<TH1*>(gROOT->FindObjectAny("CountRate_SysCore1_Spadic1")); - if (h1!=NULL) { - h1->Draw(""); - } - g_Browser->Add(h1); - - g_Spadic1->cd(2); - h2=static_cast<TH2*>(gROOT->FindObjectAny("BaseLine_SysCore1_Spadic1")); - if (h2!=NULL) { - h2->Draw("COLZ"); - } - g_Browser->Add(h2); - - g_Spadic1->cd(3); - h2=static_cast<TH2*>(gROOT->FindObjectAny("Integrated_ADC_Spectrum_SysCore1_Spadic1")); - if (h2!=NULL) { - h2->Draw("COLZ"); - } - g_Browser->Add(h2); - - g_Spadic1->cd(4); - h2=static_cast<TH2*>(gROOT->FindObjectAny("Trigger_Heatmap_SysCore1_Spadic1")); - if (h2!=NULL) { - h2->Draw("COLZ"); - } - g_Browser->Add(h2); - - //TFolder* Syscore1_Spadic1 = new TFolder("Syscore1_Spadic1","Syscore1_Spadic1"); - // Syscore1_Spadic1->Add(fSpadic1); - //g_Browser->Add(Syscore1_Spadic1); - - - /* - - TCanvas* fSpadic1a = new TCanvas("fSpadic1a", "Spadic1_Signal_Shape", 50, 50, 1510, 810); - fSpadic1a->Divide(8,4); - gPad->SetFillColor(0); - - for (Int_t i=0; i<32; i++) { - fSpadic1a->cd(i+1); - - TString temphistname = TString::Format("Signal_Shape_SysCore1_Spadic1_Ch%02d", i); - h2=static_cast<TH2*>(gROOT->FindObjectAny(temphistname.Data())); - */ - /* - if(i<10) { - temphistname = temphistname + std::to_string(0) + std::to_string(i); - h2=static_cast<TH2*>(gROOT->FindObjectAny(temphistname.Data())); - if (h2!=NULL) { - h2->Draw(""); - } - } else { - temphistname = temphistname + std::to_string(i); - h2=static_cast<TH2*>(gROOT->FindObjectAny(temphistname.Data())); - if (h2!=NULL) { - h2->Draw(""); - - } - } - } - */ - - /* - - // --- Fill and register some lists/folders/histos - - gDirectory = 0; - */ - /* - TList* l = new TList; - l->SetName("Spadic 1"); - l->Add(fSpadic1); - */ - //fBrowser->Add(fSpadic1); - - /* - TFolder* f = new TFolder("Booboayes", "Statisticos"); - h = new TH1F("Fooes", "Baros", 51, 0, 1); - for (Int_t i=0; i<2000; ++i) { - h->Fill(gRandom->Gaus(.7, .1)); - h->Fill(gRandom->Gaus(.3, .1)); - } - f->Add(h); - g_hlt_browser->Add(f); - - h = new TH1F("Fooesoto", "Barosana", 51, 0, 1); - for (Int_t i=0; i<4000; ++i) { - h->Fill(gRandom->Gaus(.25, .02), 0.04); - h->Fill(gRandom->Gaus(.5, .1)); - h->Fill(gRandom->Gaus(.75, .02), 0.04); - } - g_hlt_browser->Add(h); - */ - - // --- Add some macros. - - /* - */ - -/* - CbmTrdRawBeamProfile* c = static_cast<CbmTrdRawBeamProfile*>(gROOT->FindObjectAny("CbmTrdRawBeamProfile")).Data()); - LOG(info)<<"Found class "<< c->GetName(); - - - CbmTrdRawBeamProfile* c = static_cast<CbmTrdRawBeamProfile*>(gROOT->FindObjectAny("CbmTrdRawBeamProfile")).Data()); - LOG(info)<<"Found class "<< c->GetName(); - - TClass *cl = c->IsA(); - TDataMember *dm = cl->GetDataMember("fHM"); - TMethodCall *getter = dm->GetterMethod(c); - - - CbmHistManager* HM_RawProfile; - getter->Execute(c,"",HM_RawProfile); - - if (HM_RawProfile) - LOG(info) << "Hier bin ich" << HM_RawProfile->GetName(); - - TList* list = gROOT->GetListOfBrowsables(); - TIter nextT(list); - TObject *t = NULL; - while ((t = (TObject *) nextT())) { - LOG(info) << "Found obj " << t->GetName(); - } - */ - - return kSUCCESS; - -} - -// ---- ReInit ------------------------------------------------------- -InitStatus CbmTrdEveOnlineDisplay::ReInit() -{ - return kSUCCESS; -} - -// ---- Exec ---------------------------------------------------------- -void CbmTrdEveOnlineDisplay::Exec(Option_t*) -{ - - fEventCounter++; - - if ( 0 == fEventCounter%fUpdateInterval ) { - LOG(debug)<<"Update Canvas for Event "<< fEventCounter; - for(Int_t iCh=0; iCh<5; iCh++){ - fSpadic1->cd(iCh+1); - gPad->Modified(); - gPad->Update(); - } - fSpadic1->Modified(); - fSpadic1->Update(); - } - -} - -// ---- Finish -------------------------------------------------------- -void CbmTrdEveOnlineDisplay::Finish() -{ - fSpadic1->Update(); -} - -ClassImp(CbmTrdEveOnlineDisplay) diff --git a/beamtime/cern2014/tasks/CbmTrdEveOnlineDisplay.h b/beamtime/cern2014/tasks/CbmTrdEveOnlineDisplay.h deleted file mode 100644 index cdce39ca3c8a34bb5b6f150ab0d7d7bac39247b8..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/tasks/CbmTrdEveOnlineDisplay.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef CBMTRDEVEONLINEDISPLAY_H -#define CBMTRDEVEONLINEDISPLAY_H - -#include "FairTask.h" - -//#include "TGFileBrowser.h" - - -class TClonesArray; -class TCanvas; -class TH2; - -class CbmTrdEveOnlineDisplay : public FairTask -{ - public: - - /** Default constructor **/ - CbmTrdEveOnlineDisplay(); - - /** Destructor **/ - ~CbmTrdEveOnlineDisplay(); - - - /** Initiliazation of task at the beginning of a run **/ - virtual InitStatus Init(); - - /** ReInitiliazation of task when the runID changes **/ - virtual InitStatus ReInit(); - - - /** Executed for each event. **/ - virtual void Exec(Option_t* opt); - - /** Load the parameter container from the runtime database **/ - virtual void SetParContainers(); - - /** Finish task called at the end of the run **/ - virtual void Finish(); - - void SetUpdateInterval(Int_t val) { fUpdateInterval = val; } - - private: - - TCanvas* fSpadic1; //! - TCanvas* fSpadic1a; //! - - Int_t fUpdateInterval; - Int_t fEventCounter; - - CbmTrdEveOnlineDisplay(const CbmTrdEveOnlineDisplay&); - CbmTrdEveOnlineDisplay operator=(const CbmTrdEveOnlineDisplay&); - - ClassDef(CbmTrdEveOnlineDisplay,1); -}; - -#endif diff --git a/beamtime/cern2014/tasks/CbmTrdOnlineDisplay.cxx b/beamtime/cern2014/tasks/CbmTrdOnlineDisplay.cxx deleted file mode 100644 index 75244bac48442896e4d08886a6d1c401eca576ba..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/tasks/CbmTrdOnlineDisplay.cxx +++ /dev/null @@ -1,298 +0,0 @@ -#include "CbmTrdOnlineDisplay.h" - -#include "CbmHistManager.h" -#include "CbmTrdRawBeamProfile.h" - -#include "FairLogger.h" - -#include "TCanvas.h" -#include "TPad.h" -#include "TStyle.h" -#include "TH1.h" -#include "TH2.h" -#include "TString.h" -#include "TROOT.h" -#include "TSeqCollection.h" -#include "TTask.h" -#include "TClass.h" -#include "TDataMember.h" -#include "TMethodCall.h" - -// ---- Default constructor ------------------------------------------- -CbmTrdOnlineDisplay::CbmTrdOnlineDisplay(TString inFile) - :FairTask("CbmTrdOnlineDisplay"), - fSpadic1(), - fSpadic1a(), - fSpadicTime(), - finFile(inFile), - fUpdateInterval(10), - fEventCounter(0) -{ -} - -// ---- Destructor ---------------------------------------------------- -CbmTrdOnlineDisplay::~CbmTrdOnlineDisplay() -{ -// delete[] fSpadic1; -// delete[] fSpadic1a; -} - -// ---- Initialisation ---------------------------------------------- -void CbmTrdOnlineDisplay::SetParContainers() -{ -} - -// ---- Init ---------------------------------------------------------- -InitStatus CbmTrdOnlineDisplay::Init() -{ - - TH1* h1 = NULL; - TH1* h2 = NULL; - // TGraph* g1 = NULL; - gROOT->cd(); - Float_t lsize=0.07; - gStyle->SetPalette(1); - gStyle->SetLabelSize(lsize); - - fSpadicTime = new TCanvas("fSpadicTime","fSpadicTime",0,0,1600,1200); - fSpadicTime->Divide(4,3); - fSpadicTime->cd(1)->SetLogy(1); - fSpadicTime->cd(1)->SetLogx(1); - h1=static_cast<TH1*>(gROOT->FindObjectAny(TString("DeltaClusterTime2015CernSPS"))); - if (h1!=NULL) { - h1->Draw(""); - } - fSpadicTime->cd(2); - h2=static_cast<TH2*>(gROOT->FindObjectAny(TString("DeltaClusterTimeCorrelation2015CernSPS"))); - if (h2!=NULL) { - h2->Draw("colz"); - } - fSpadicTime->cd(3); - h2=static_cast<TH2*>(gROOT->FindObjectAny(TString("DeltaClusterTimeCorrelationFullCluster2015CernSPS"))); - if (h2!=NULL) { - h2->Draw("colz"); - } - fSpadicTime->cd(4); - h2=static_cast<TH2*>(gROOT->FindObjectAny(TString("DeltaClusterTimeCorrelationAllEvents2015CernSPS"))); - if (h2!=NULL) { - h2->Draw("colz"); - } - h1=static_cast<TH1*>(gROOT->FindObjectAny(TString("DeltaTime_Cluster_SysCore0_Spadic0"))); - fSpadicTime->cd(5)->SetLogy(1); - if (h1!=NULL) { - h1->Draw(""); - } - h1=static_cast<TH1*>(gROOT->FindObjectAny(TString("DeltaTime_Cluster_SysCore0_Spadic1"))); - h1->SetLineColor(2); - if (h1!=NULL) { - h1->Draw("same"); - } - h1=static_cast<TH1*>(gROOT->FindObjectAny(TString("DeltaTime_Cluster_SysCore1_Spadic1"))); - h1->SetLineColor(3); - if (h1!=NULL) { - h1->Draw("same"); - } - h1=static_cast<TH1*>(gROOT->FindObjectAny(TString("DeltaTime_Cluster_SysCore1_Spadic1"))); - h1->SetLineColor(4); - if (h1!=NULL) { - h1->Draw("same"); - } - for (Int_t sys = 0; sys < 2; sys++){ - for (Int_t spa = 0; spa < 2; spa++){ - fSpadic1[spa][sys] = new TCanvas(TString("fSysCore" + std::to_string(sys) + "Spadic" + std::to_string(spa)), TString("fSysCore" + std::to_string(sys) + "Spadic" + std::to_string(spa)), 0, 0, 2000, 1200); - fSpadic1[spa][sys]->Divide(5,3); - - // Should be set for each pad of the Canvas - gPad->SetFillColor(0); - - fSpadic1[spa][sys]->cd(1); - h1=static_cast<TH1*>(gROOT->FindObjectAny(TString("CountRate_SysCore" + std::to_string(sys) + "_Spadic" + std::to_string(spa)))); - if (h1!=NULL) { - h1->Draw(""); - } - - fSpadic1[spa][sys]->cd(2)->SetLogz(1); - h2=static_cast<TH2*>(gROOT->FindObjectAny(TString("BaseLine_SysCore" + std::to_string(sys) + "_Spadic" + std::to_string(spa)))); - if (h2!=NULL) { - h2->Draw("COLZ"); - } - - fSpadic1[spa][sys]->cd(3)->SetLogy(1); - h1=static_cast<TH1*>(gROOT->FindObjectAny(TString("GroupId_SysCore" + std::to_string(sys) + "_Spadic" + std::to_string(spa)))); - if (h1!=NULL) { - h1->Draw(""); - } - - fSpadic1[spa][sys]->cd(4)->SetLogz(1); - h2=static_cast<TH2*>(gROOT->FindObjectAny(TString("Trigger_Heatmap_SysCore" + std::to_string(sys) + "_Spadic" + std::to_string(spa)))); - if (h2!=NULL) { - h2->Draw("COLZ"); - } - fSpadic1[spa][sys]->cd(5)->SetLogy(1); - /* - g1=static_cast<TGraph*>(gROOT->FindObjectAny(TString("TriggerCounterGraph_SysCore" + std::to_string(sys) + "_Spadic" + std::to_string(spa)))); - if (g1!=NULL) { - g1->Draw("AL"); - } - */ - h1=static_cast<TH1*>(gROOT->FindObjectAny(TString("TriggerCounter_SysCore" + std::to_string(sys) + "_Spadic" + std::to_string(spa)))); - if (h1!=NULL) { - h1->Draw(""); - } - h1=static_cast<TH1*>(gROOT->FindObjectAny(TString("OverFlowCounter_SysCore" + std::to_string(sys) + "_Spadic" + std::to_string(spa)))); - h1->SetLineColor(2); - if (h1!=NULL) { - h1->Draw("same"); - } - h1=static_cast<TH1*>(gROOT->FindObjectAny(TString("ErrorCounter_SysCore" + std::to_string(sys) + "_Spadic" + std::to_string(spa)))); - h1->SetLineColor(3); - if (h1!=NULL) { - h1->Draw("same"); - } - - fSpadic1[spa][sys]->cd(6)->SetLogy(1); - h1=static_cast<TH1*>(gROOT->FindObjectAny(TString("TriggerSum"))); - if (h1!=NULL) { - h1->Draw(""); - } - - fSpadic1[spa][sys]->cd(7)->SetLogy(0); - h1=static_cast<TH2*>(gROOT->FindObjectAny(TString("StopTypes_SysCore" + std::to_string(sys) + "_Spadic" + std::to_string(spa)))); - if (h1!=NULL) { - h1->Draw("colz"); - } - fSpadic1[spa][sys]->cd(8)->SetLogy(0); - h1=static_cast<TH2*>(gROOT->FindObjectAny(TString("InfoTypes_SysCore" + std::to_string(sys) + "_Spadic" + std::to_string(spa)))); - if (h1!=NULL) { - h1->Draw("colz"); - } - fSpadic1[spa][sys]->cd(9)->SetLogy(0); - h1=static_cast<TH2*>(gROOT->FindObjectAny(TString("TriggerTypes_SysCore" + std::to_string(sys) + "_Spadic" + std::to_string(spa)))); - if (h1!=NULL) { - h1->Draw("colz"); - } - fSpadic1[spa][sys]->cd(10)->SetLogy(1); - h1=static_cast<TH1*>(gROOT->FindObjectAny(TString("ClusterSize_SysCore" + std::to_string(sys) + "_Spadic" + std::to_string(spa)))); - if (h1!=NULL) { - h1->Draw(""); - } - fSpadic1[spa][sys]->cd(11)->SetLogy(0); - h1=static_cast<TH2*>(gROOT->FindObjectAny(TString("Message_Length_SysCore" + std::to_string(sys) + "_Spadic" + std::to_string(spa)))); - if (h1!=NULL) { - h1->Draw("colz"); - } - fSpadic1[spa][sys]->cd(12)->SetLogy(0); - h1=static_cast<TH2*>(gROOT->FindObjectAny(TString("TriggerType_ClusterSize_SysCore" + std::to_string(sys) + "_Spadic" + std::to_string(spa)))); - if (h1!=NULL) { - h1->Draw("colz"); - } - } - } - - for (Int_t sys = 0; sys < 2; sys++){ - for (Int_t spa = 0; spa < 2; spa++) { - fSpadic1a[spa][sys] = new TCanvas(TString("fSysCore" + std::to_string(sys) + "Spadic" + std::to_string(spa) +"_Signal_Shape"), TString("fSysCore" + std::to_string(sys) + "Spadic" + std::to_string(spa) +"_Signal_Shape"), 50, 50, 1200, 700); - fSpadic1a[spa][sys]->Divide(8,4); - gPad->SetFillColor(0); - - for (Int_t i=0; i<32; i++) { - fSpadic1a[spa][sys]->cd(i+1)->SetLogz(1); - - if (true){ - TString temphistname = "Signal_Shape_SysCore"+std::to_string(sys)+"_Spadic"+std::to_string(spa)+"_Ch"; - if(i<10) { - temphistname = temphistname + std::to_string(0) + std::to_string(i); - h2=static_cast<TH2*>(gROOT->FindObjectAny(temphistname.Data())); - if (h2!=NULL) { - h2->Draw("COLZ"); - } - } else { - temphistname = temphistname + std::to_string(i); - h2=static_cast<TH2*>(gROOT->FindObjectAny(temphistname.Data())); - if (h2!=NULL) { - h2->Draw("COLZ"); - } - } - } else { - TString temphistname = "Signal_Shape_SysCore"+std::to_string(sys)+"_Spadic"+std::to_string(spa)+"_Ch" + std::to_string(0) + std::to_string(i); - h1=static_cast<TH1*>(gROOT->FindObjectAny(temphistname.Data())); - if (h1!=NULL) { - h1->SetLineColor(sys); - h1->SetLineStyle(spa); - if (sys == 0 && spa == 0) - h1->Draw("C"); - else - h1->Draw("C,same"); - } - } - } - } - } - return kSUCCESS; - -} - -// ---- ReInit ------------------------------------------------------- -InitStatus CbmTrdOnlineDisplay::ReInit() -{ - return kSUCCESS; -} - -// ---- Exec ---------------------------------------------------------- -void CbmTrdOnlineDisplay::Exec(Option_t*) -{ - Int_t maxTrigger = 0; - fEventCounter++; - TH1* h1=NULL; - - if ( 0 == fEventCounter%(fUpdateInterval/10)) { - LOG(info)<<"Update Canvas for Event "<< fEventCounter; - for (Int_t sys = 0; sys < 2; sys++){ - for (Int_t spa = 0; spa < 2; spa++){ - h1=static_cast<TH1*>(gROOT->FindObjectAny(TString("TriggerCounter_SysCore" + std::to_string(sys) + "_Spadic" + std::to_string(spa)))); - if (h1->GetBinContent(h1->GetMaximumBin()) > maxTrigger) - maxTrigger = h1->GetBinContent(h1->GetMaximumBin()); - } - } - for (Int_t sys = 0; sys < 2; sys++){ - for (Int_t spa = 0; spa < 2; spa++){ - h1=static_cast<TH1*>(gROOT->FindObjectAny(TString("TriggerCounter_SysCore" + std::to_string(sys) + "_Spadic" + std::to_string(spa)))); - //h1->GetYaxis()->SetRangeUser(-10,10+1.125*maxTrigger); - for(Int_t iCh=0; iCh<9; iCh++){ - fSpadic1[spa][sys]->cd(iCh+1); - gPad->Modified(); - //gPad->Update(); - } - fSpadic1[spa][sys]->Update(); - } - } - } -} - - // ---- Finish -------------------------------------------------------- -void CbmTrdOnlineDisplay::Finish() -{ -fSpadicTime->Update(); - finFile.ReplaceAll("data/",""); -finFile.ReplaceAll(".tsa","_"); - fSpadicTime->SaveAs(TString("pics/" + finFile + "fSpadicTime.png")); -fSpadicTime->Write("",TObject::kOverwrite); - for (Int_t sys = 0; sys < 2; sys++){ - for (Int_t spa = 0; spa < 2; spa++){ - fSpadic1[spa][sys]->Update(); - fSpadic1[spa][sys]->SaveAs(TString("pics/") + finFile + TString(fSpadic1[spa][sys]->GetTitle())+TString(".png")); - fSpadic1[spa][sys]->Write("",TObject::kOverwrite); - for(Int_t iCh=0; iCh<32; iCh++){ - fSpadic1a[spa][sys]->cd(iCh+1); - gPad->Modified(); - //gPad->Update(); - } - fSpadic1a[spa][sys]->ResizeOpaque(0); - //fSpadic1a[spa][sys]->Resize(); - fSpadic1a[spa][sys]->Update(); - fSpadic1a[spa][sys]->SaveAs(TString("pics/") + finFile + TString(fSpadic1a[spa][sys]->GetTitle())+TString(".png")); - fSpadic1a[spa][sys]->Write("",TObject::kOverwrite); - } - } -} - ClassImp(CbmTrdOnlineDisplay) diff --git a/beamtime/cern2014/tasks/CbmTrdOnlineDisplay.h b/beamtime/cern2014/tasks/CbmTrdOnlineDisplay.h deleted file mode 100644 index 700db22304f204fba67125aba0a6de23293d0475..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/tasks/CbmTrdOnlineDisplay.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef CBMTRDONLINEDISPLAY_H -#define CBMTRDONLINEDISPLAY_H - -#include "FairTask.h" - -class TClonesArray; -class TCanvas; -class TH2; - -class CbmTrdOnlineDisplay : public FairTask -{ - public: - - /** Default constructor **/ - CbmTrdOnlineDisplay(TString inFile=""); - - /** Destructor **/ - ~CbmTrdOnlineDisplay(); - - - /** Initiliazation of task at the beginning of a run **/ - virtual InitStatus Init(); - - /** ReInitiliazation of task when the runID changes **/ - virtual InitStatus ReInit(); - - - /** Executed for each event. **/ - virtual void Exec(Option_t* opt); - - /** Load the parameter container from the runtime database **/ - virtual void SetParContainers(); - - /** Finish task called at the end of the run **/ - virtual void Finish(); - - void SetUpdateInterval(Int_t val) { fUpdateInterval = val; } - - private: - - TCanvas* fSpadic1[3][3]; //! - TCanvas* fSpadic1a[3][3]; //! - TCanvas* fSpadicTime; - TString finFile; - - Int_t fUpdateInterval; - Int_t fEventCounter; - - CbmTrdOnlineDisplay(const CbmTrdOnlineDisplay&); - CbmTrdOnlineDisplay operator=(const CbmTrdOnlineDisplay&); - - ClassDef(CbmTrdOnlineDisplay,1); -}; - -#endif diff --git a/beamtime/cern2014/tasks/CbmTrdRawBeamProfile.cxx b/beamtime/cern2014/tasks/CbmTrdRawBeamProfile.cxx deleted file mode 100644 index 6da7f13c526b8eccf687e5bc683ed9b92b0a22c1..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/tasks/CbmTrdRawBeamProfile.cxx +++ /dev/null @@ -1,1728 +0,0 @@ -#include "CbmTrdRawBeamProfile.h" - -#include "CbmSpadicRawMessage.h" -#include "CbmNxyterRawMessage.h" -#include "CbmTrbRawMessage.h" -#include "CbmTrdDigi.h" -#include "CbmTrdCluster.h" -#include "CbmHistManager.h" -#include "CbmBeamDefaults.h" -#include "CbmTrdAddress.h" -#include "CbmTrdDaqBuffer.h" - -#include "FairLogger.h" - -#include "TH1.h" -#include "TH2.h" -#include "TGraph.h" -#include "TCanvas.h" -#include "TString.h" -#include "TStyle.h" - -#include <cmath> -#include <map> -//#include <multimap> -#include <vector> -#include <iostream> - -using std::cout; -using std::endl; - -// ---- Default constructor ------------------------------------------- -CbmTrdRawBeamProfile::CbmTrdRawBeamProfile() - : FairTask("CbmTrdRawBeamProfile"), - fRawSpadic(NULL), - fNxyterRaw(NULL), - fTrbRaw(NULL), - fDigis(NULL), - fClusters(NULL), - fiDigi(0), - fiCluster(0), - fHM(new CbmHistManager()), - fmaxTimeGlobal(0), - fmaxTimeGroup(), - fmaxFullTimeGlobal(0), - fmaxFullTimeGroup(), - flastDlmTriggerTime(), - fEpoch(-1), - flastEpoch(-1), - fSuperEpoch(-1), - flastSuperEpoch(-1), - fSpadicMessageCounter(0), - fNxyterMessageCounter(0), - fTrbMessageCounter(0), - fContainerCounter(0), - fInfoCounter(0), - fHitCounter(0), - fMultiHitCounter(0), - fErrorCounter(0), - fLostHitCounter(0), - fDoubleCounter(0), - fFragmentedCounter(0), - fSys0Spa0Buffer(), - fSys0Spa1Buffer(), - fTimeBuffer(), - fFullTimeBuffer(), - fFullTimeBufferAll(), - fTrbBuffer() -{ - LOG(debug) << "Default Constructor of CbmTrdRawBeamProfile"; -} - -// ---- Destructor ---------------------------------------------------- -CbmTrdRawBeamProfile::~CbmTrdRawBeamProfile() -{ - fDigis->Delete(); - delete fDigis; - fClusters->Delete(); - delete fClusters; - - for (std::map<TString, std::map<Int_t, std::map<Int_t, CbmSpadicRawMessage*> > >::iterator SpaSysIt = fTimeBuffer.begin(); SpaSysIt != fTimeBuffer.end(); SpaSysIt++){ - for (std::map<Int_t, std::map<Int_t, CbmSpadicRawMessage*> >::iterator TimeIt = SpaSysIt->second.begin(); TimeIt != SpaSysIt->second.end(); TimeIt++){ - for (std::map<Int_t, CbmSpadicRawMessage*> ::iterator CombiIt = TimeIt->second.begin(); CombiIt != TimeIt->second.end(); CombiIt++){ - if(CombiIt->second != NULL) - delete CombiIt->second; - } - TimeIt->second.clear(); - } - SpaSysIt->second.clear(); - } - fTimeBuffer.clear(); - - for (std::map<TString, std::map<ULong_t, std::map<Int_t, CbmSpadicRawMessage*> > >::iterator SpaSysIt = fFullTimeBuffer.begin() ; SpaSysIt != fFullTimeBuffer.end(); SpaSysIt++){ - for (std::map<ULong_t, std::map<Int_t, CbmSpadicRawMessage*> > ::iterator timeIt = SpaSysIt->second.begin() ; timeIt != SpaSysIt->second.end(); timeIt++){ - for (std::map<Int_t, CbmSpadicRawMessage*> ::iterator combiIt = timeIt->second.begin(); combiIt != timeIt->second.end(); combiIt++){ - if(combiIt->second != NULL) - delete combiIt->second; - } - timeIt->second.clear(); - } - SpaSysIt->second.clear(); - } - fFullTimeBuffer.clear(); - for (std::map<TString, std::map<ULong_t, std::multimap<Int_t, CbmSpadicRawMessage*> > >::iterator SpaSysIt = fFullTimeBufferAll.begin() ; SpaSysIt != fFullTimeBufferAll.end(); SpaSysIt++){ - for (std::map<ULong_t, std::multimap<Int_t, CbmSpadicRawMessage*> > ::iterator timeIt = SpaSysIt->second.begin() ; timeIt != SpaSysIt->second.end(); timeIt++){ - for (std::multimap<Int_t, CbmSpadicRawMessage*> ::iterator combiIt = timeIt->second.begin(); combiIt != timeIt->second.end(); combiIt++){ - if(combiIt->second != NULL) - delete combiIt->second; - } - timeIt->second.clear(); - } - SpaSysIt->second.clear(); - } - fFullTimeBufferAll.clear(); - for (std::map<Int_t, std::map<Int_t, std::map<Int_t, std::map<Int_t, CbmTrbRawMessage*> > > >::iterator SourceAIt = fTrbBuffer.begin() ; SourceAIt != fTrbBuffer.end(); SourceAIt++){ - for (std::map<Int_t, std::map<Int_t, std::map<Int_t, CbmTrbRawMessage*> > >::iterator epochIt = SourceAIt->second.begin() ; epochIt != SourceAIt->second.end(); epochIt++){ - for (std::map<Int_t, std::map<Int_t, CbmTrbRawMessage*> > ::iterator chIdIt = epochIt->second.begin() ; chIdIt != epochIt->second.end(); chIdIt++){ - for (std::map<Int_t, CbmTrbRawMessage*> ::iterator timeIt = chIdIt->second.begin(); timeIt != chIdIt->second.end(); timeIt++){ - if(timeIt->second != NULL) - delete timeIt->second; - } - chIdIt->second.clear(); - } - epochIt->second.clear(); - } - SourceAIt->second.clear(); - } - fTrbBuffer.clear(); - //fTrbBuffer has to be cleaned here!!!!! - LOG(debug) << "Destructor of CbmTrdRawBeamProfile"; -} - - // ---- Initialisation ---------------------------------------------- - void CbmTrdRawBeamProfile::SetParContainers() - { - LOG(debug) << "SetParContainers of CbmTrdRawBeamProfile"; - // Load all necessary parameter containers from the runtime data base - /* - FairRunAna* ana = FairRunAna::Instance(); - FairRuntimeDb* rtdb=ana->GetRuntimeDb(); - - <CbmTrdRawBeamProfileDataMember> = (<ClassPointer>*) - (rtdb->getContainer("<ContainerName>")); - */ - } - - // ---- Init ---------------------------------------------------------- - InitStatus CbmTrdRawBeamProfile::Init() - { - LOG(debug) << "Initilization of CbmTrdRawBeamProfile"; - - // Get a handle from the IO manager - FairRootManager* ioman = FairRootManager::Instance(); - - // Get a pointer to the previous already existing data level - fRawSpadic = static_cast<TClonesArray*>(ioman->GetObject("SpadicRawMessage")); - if ( ! fRawSpadic ) { - LOG(fatal) << "No InputDataLevelName SpadicRawMessage array!\n CbmTrdRawBeamProfile will be inactive"; - return kERROR; - } - fNxyterRaw = static_cast<TClonesArray*>(ioman->GetObject("NxyterRawMessage")); - if ( ! fNxyterRaw ) { - LOG(error) << "No InputDataLevelName CbmNxyterRawMessage array!\n Nxyter data within CbmTrdRawBeamProfile will be inactive"; - //return kERROR; - } - fTrbRaw = static_cast<TClonesArray*>(ioman->GetObject("TrbRawMessage")); - if ( ! fTrbRaw ) { - LOG(error) << "No InputDataLevelName CbmTrbRawMessage array!\n TRB data within CbmTrdRawBeamProfile will be inactive"; - //return kERROR; - } - - - fDigis = new TClonesArray("CbmTrdDigi", 100); - ioman->Register("TrdDigi", "TRD Digis", fDigis, IsOutputBranchPersistent("TrdDigi")); - - fClusters = new TClonesArray("CbmTrdCluster",100); - ioman->Register("TrdCluster", "TRD Clusters", fClusters, IsOutputBranchPersistent("TrdCluster")); - - // Do whatever else is needed at the initilization stage - // Create histograms to be filled - // initialize variables - CbmTrdRawBeamProfile::CreateHistograms(); - - return kSUCCESS; - - } - - // ---- ReInit ------------------------------------------------------- - InitStatus CbmTrdRawBeamProfile::ReInit() - { - LOG(debug) << "Initilization of CbmTrdRawBeamProfile"; - return kSUCCESS; - } - - // ---- Exec ---------------------------------------------------------- -void CbmTrdRawBeamProfile::Exec(Option_t*) -{ - TString errorMessage, infoMessage, debugMessage; - const Int_t maxNrColumns = 16; - /* - This function is reinitialized for each new TimeSliceContainer - */ - fContainerCounter++; - /* - Int_t channelMapping[32] = {31,15,30,14,29,13,28,12,27,11,26,10,25, 9,24, 8, - 23, 7,22, 6,21, 5,20, 4,19, 3,18, 2,17, 1,16, 0}; - */ - TString timebinName[32] = { "00", "01", "02", "03", "04", "05", "06", "07", "08", "09", - "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", - "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", - "30", "31"}; - - //std::map<TString, std::map<ULong_t, std::map<Int_t, CbmSpadicRawMessage*> > > timeBuffer;// <ASIC ID "Syscore%d_Spadic%d"<Time, <CombiId, SpadicMessage> > - - - Int_t entriesInTrbMessage = fTrbRaw->GetEntriesFast(); - Int_t lastGlobalEpoch(0); - Int_t lastEpoch[4][16] = {{0}}; - Int_t lastTdcCoarse[4][16] = {{0}}; - for (Int_t i=0; i < entriesInTrbMessage; ++i) { - fTrbMessageCounter++; - CbmTrbRawMessage* raw = /*static_cast<*/(CbmTrbRawMessage*)/*>*/(fTrbRaw->At(i)); - Int_t eqID = raw->GetEquipmentID(); - Int_t sourceA = raw->GetSourceAddress(); - if (sourceA == 272) continue; //RICH - //printf("EI%i SA%i ->",eqID,sourceA); - Int_t chID = raw->GetChannelID(); - if (chID == 0) continue;// seems to be not connected - Int_t epoch = raw->GetEpochMarker(); - Int_t tdcFine = raw->GetTDCfine(); - Int_t tdcCoarse = raw->GetTDCcoarse(); - Int_t edge = raw->GetEdge(); - // ULong_t fullTime = raw->GetFullTime(); - - //LOG(info) << "TrbMessage: " << fTrbMessageCounter << " EqId:" << eqID << " sourceA:" << sourceA << " ChID:" << chID << " Epoch:" << epoch << " tdcFine:" << tdcFine << " tdcCoarse:" << tdcCoarse << " edge:" << edge; - - std::map<Int_t, CbmTrbRawMessage*>::iterator timeBufferIt = fTrbBuffer[sourceA][epoch][chID].find(tdcCoarse); - if (timeBufferIt == fTrbBuffer[sourceA][epoch][chID].end()){ - fTrbBuffer[sourceA][epoch][chID][tdcCoarse] = new CbmTrbRawMessage(eqID, sourceA, chID, epoch, tdcCoarse, tdcFine, (Bool_t)edge); - } else { - LOG(error) << "Message already in buffer <<<<<<< TrbMessage: EqId:" << eqID << " sourceA:" << sourceA << " ChID:" << chID << " tdcFine:" << tdcFine << " tdcCoarse:" << tdcCoarse << " edge:" << edge; - } - if (i > 0){ - if (epoch - lastGlobalEpoch < 0) - LOG(error) << "-------------------->GlobalEpoch:" << epoch << " LastGlobalEpoch:"<< lastGlobalEpoch; - if (epoch - lastEpoch[sourceA-272][chID] < 0){ - // ERROR - LOG(error) << ":::::::::::::::::::::::::::Epoch:" << epoch << " LastEpoch:"<< lastEpoch[sourceA-272][chID]; - } else if (epoch - lastEpoch[sourceA-272][chID] == 0) { - - if (tdcCoarse - lastTdcCoarse[sourceA-272][chID] < 0) { - // ERROR - LOG(error) << "======================Coarse:" << tdcCoarse << " LastCoarse:"<< lastTdcCoarse[sourceA-272][chID]; - } else { - } - } else { - //next epoch - } - } - lastGlobalEpoch = epoch; - lastEpoch[sourceA-272][chID] = epoch; - lastTdcCoarse[sourceA-272][chID] = tdcCoarse; - } - - - Int_t entriesInNxyterMessage = fNxyterRaw->GetEntriesFast(); - for (Int_t i=0; i < entriesInNxyterMessage; ++i) { - fNxyterMessageCounter++; - CbmNxyterRawMessage* raw = /*static_cast<*/(CbmNxyterRawMessage*)/*>*/(fNxyterRaw->At(i)); - Int_t eqID = raw->GetEquipmentID(); - Int_t sourceA = raw->GetSourceAddress(); - //printf("EI%i SA%i ->",eqID,sourceA); - Int_t chID = raw->GetChannelID(); - // Int_t AdcValue = raw->GetADCvalue(); - // ULong_t fullTime = raw->GetFullTime(); - LOG(info) << "NxyterMessage: EqId:" << eqID << " sourceA:" << sourceA << " ChID:" << chID; - } - - Int_t entriesInMessage = fRawSpadic->GetEntriesFast(); - Int_t entries = fDigis->GetEntriesFast(); - Int_t sumTrigger[3][6] = {{0}}; - Int_t sumError[3][6] = {{0}}; - Int_t sumOverflow[3][6] = {{0}}; - - LOG(debug) << "Container: " << fContainerCounter; - LOG(debug) << "SPADIC Entries in Message: " << entriesInMessage; - LOG(debug) << "Nxyter Entries in Message: " << entriesInNxyterMessage; - LOG(debug) << "Entries in total: " << fSpadicMessageCounter; - LOG(debug) << "Digis in TClonesArray: " << fDigis->GetEntriesFast(); - LOG(debug) << "Clusters in TClonesArray: " << fClusters->GetEntriesFast(); - // Find info about hitType, stopType and infoType in cbmroot/fles/spadic/message/constants/.. - /* - TString triggerTypes[5] = {"infoMessage", - "Global trigger", - "Self triggered", - "Neighbor triggered", - "Self and neighbor triggered"}; - TString stopTypes[6] = {"Normal end of message", - "Channel buffer full", - "Ordering FIFO full", - "Multi hit", - "Multi hit and channel buffer full", - "Multi hit and ordering FIFO full"}; - - TString infoTypes[8] = {"Channel disabled during message building", - "Next grant timeout", - "Next request timeout", - "New grant but channel empty", - "Corruption in message builder", - "Empty word", - "Epoch out of sync", - "infoType out of array"}; - */ - - //if (entriesInMessage > 1) entriesInMessage = 1; // for fast data visualization - ULong_t lastSpadicTime[3][6] = {{0}}; //[sys][spa] - ULong_t lastSpadicTimeCh[3][6][32] = {{{0}}}; //[sys][spa][ch] - Int_t lastTriggerType[32] = {-1}; - Int_t clusterSize[3][6] = {{1}}; - Int_t rowId(0), columnId(0), combiId(0); - Int_t wrongTimeOrder[3][6] = {{0}}; - Bool_t isHit(false), isInfo(false); - for (Int_t i=0; i < entriesInMessage; ++i) { - fSpadicMessageCounter++; - CbmSpadicRawMessage* raw = (CbmSpadicRawMessage*)(fRawSpadic->At(i)); - /* - if ((raw->GetSuperEpoch() != fSuperEpoch)){// || (raw->GetEpochMarker() != fEpoch)){ - Clusterizer(); - TimeClustering2015CernSPS(); - } - */ - fEpoch = raw->GetEpochMarker(); - fSuperEpoch = raw->GetSuperEpoch(); - if (fEpoch == 0 || fSuperEpoch == 0) continue; - Int_t eqID = raw->GetEquipmentID(); - Int_t sourceA = raw->GetSourceAddress(); - //printf("EI%i SA%i ->",eqID,sourceA); - Int_t chID = raw->GetChannelID(); - Int_t SysId(-1), SpaId(-1); - Int_t nrSamples=raw->GetNrSamples(); - Int_t triggerType=raw->GetTriggerType(); - Int_t stopType=raw->GetStopType(); - Int_t infoType=raw->GetInfoType(); - Int_t bufferOverflowCount = raw->GetBufferOverflowCount(); - fLostHitCounter += bufferOverflowCount; - if (triggerType == -1 && stopType == -1){ - isHit = false; - isInfo = true; - fInfoCounter++; - } else { - isHit = true; - isInfo = false; - if (stopType == 3) - fMultiHitCounter++; - else if (stopType == 0) - fHitCounter++; - else - fErrorCounter++; - } - - if (stopType != 0 && stopType != 3) - if (infoType > 6) { - errorMessage.Form("SuperEpoch %5i Epoche %5i Container:%5i Message:%5i eqID:%i sourceA:%i chID:%02i StopType: %i TriggerType: %i InfoType%i out of range",fSuperEpoch,fEpoch,fContainerCounter,fSpadicMessageCounter,eqID,sourceA,chID,stopType,triggerType,infoType); - LOG(error) << errorMessage; - infoType = 7; - } - Int_t groupId=raw->GetGroupId(); - ULong_t fullTime = raw->GetFullTime(); - Int_t time = raw->GetTime(); - TString syscore=""; - switch (eqID) { - case kFlesMuenster: // Muenster - syscore="SysCore0_"; - SysId = 0; - break; - case kFlesFrankfurt: // Frankfurt - syscore="SysCore1_"; - SysId = 1; - break; - case kFlesBucarest: // Bucarest - syscore="SysCore2_"; - SysId = 2; - break; - default: - LOG(error) << "Container " << fContainerCounter << " Message " << fSpadicMessageCounter << " EquipmentID " << eqID << "not known."; - break; - } - - TString spadic=""; - switch (sourceA) { - case (SpadicBaseAddress+0): // first spadic - spadic="Spadic0"; - SpaId = 0; - break; - case (SpadicBaseAddress+1): // first spadic - spadic="Spadic0"; - SpaId = 1; - chID += 16; - break; - case (SpadicBaseAddress+2): // second spadic - spadic="Spadic1"; - SpaId = 2; - break; - case (SpadicBaseAddress+3): // second spadic - spadic="Spadic1"; - SpaId = 3; - chID += 16; - break; - case (SpadicBaseAddress+4): // third spadic - spadic="Spadic2"; - SpaId = 4; - break; - case (SpadicBaseAddress+5): // third spadic - spadic="Spadic2"; - SpaId = 5; - chID += 16; - break; - default: - LOG(error) << "Container " << fContainerCounter << " Message " << fSpadicMessageCounter << " Source Address " << sourceA << "not known."; - break; - } - /* - if(chID % 2 == 0) - rowId = 0; - else - rowId = 1; - //printf("EI%i SA%i ->|\n",eqID,sourceA); - */ - chID = GetChannelOnPadPlane(chID);//channelMapping[chID];// Remapping from ASIC to pad-plane - /* - // Compare to channel mapping from pad-plane to ASIC - columnId = chID; - if (columnId > 16) - columnId -= 16; - */ - columnId = GetColumnID(raw); - rowId = GetRowID(raw); - combiId = rowId * (maxNrColumns + 1) + columnId; - if (isHit){ - infoMessage.Form("SuperEpoch %5i Epoche %5i FullTime %12lu eqID:%i sourceA:%i chID:%02i StopType: %i TriggerType: %i InfoType: %i", - fSuperEpoch,fEpoch,fullTime,eqID,sourceA,chID,stopType,triggerType,infoType); - LOG(debug) << infoMessage; - if (flastEpoch == fEpoch && flastSuperEpoch == fSuperEpoch){ - infoMessage.Form("SuperEpoch %5i Epoche %5i FullTime %12lu eqID:%i sourceA:%i chID:%02i StopType: %i TriggerType: %i InfoType: %i still in same (Super)Epoch", - fSuperEpoch,fEpoch,fullTime,eqID,sourceA,chID,stopType,triggerType,infoType); - LOG(debug) << infoMessage; - if (fullTime > fmaxFullTimeGlobal){ - infoMessage.Form("SuperEpoch %5i Epoche %5i FullTime %12lu eqID:%i sourceA:%i chID:%02i StopType: %i TriggerType: %i InfoType: %i maxFullTimeGlobal: %12lu", - fSuperEpoch,fEpoch,fullTime,eqID,sourceA,chID,stopType,triggerType,infoType,fmaxFullTimeGlobal); - LOG(debug) << infoMessage; - fmaxFullTimeGlobal = fullTime; - } - if (fullTime < fmaxFullTimeGlobal) { - infoMessage.Form("SuperEpoch %5i Epoche %5i FullTime %12lu eqID:%i sourceA:%i chID:%02i StopType: %i TriggerType: %i InfoType: %i maxFullTimeGlobal: %12lu time jump #Delta t: %9i", - fSuperEpoch,fEpoch,fullTime,eqID,sourceA,chID,stopType,triggerType,infoType,fmaxFullTimeGlobal,Int_t(fullTime-fmaxFullTimeGlobal)); - LOG(debug) << infoMessage; - //wrongTimeOrder[SysId][SpaId]++; - //continue; - } - if (fullTime > fmaxFullTimeGroup[SysId][SpaId]){ - infoMessage.Form("SuperEpoch %5i Epoche %5i Time %9i FullTime %12lu eqID:%i sourceA:%i chID:%02i StopType: %i TriggerType: %i InfoType: %i maxFullTimeGroup: %12lu", - fSuperEpoch,fEpoch,raw->GetTime(),fullTime,eqID,sourceA,chID,stopType,triggerType,infoType,fmaxFullTimeGroup[SysId][SpaId]); - LOG(debug) << infoMessage; - fmaxFullTimeGroup[SysId][SpaId] = fullTime; - } - if (fullTime < fmaxFullTimeGroup[SysId][SpaId]) { - infoMessage.Form("SuperEpoch %5i Epoche %5i Time %9i FullTime %12lu eqID:%i sourceA:%i chID:%02i StopType: %i TriggerType: %i InfoType: %i maxFullTimeGroup: %12lu time jump #Delta t: %9i", - fSuperEpoch,fEpoch,raw->GetTime(),fullTime,eqID,sourceA,chID,stopType,triggerType,infoType,fmaxFullTimeGroup[SysId][SpaId],Int_t(fullTime-fmaxFullTimeGroup[SysId][SpaId])); - //LOG(error) << infoMessage; - //wrongTimeOrder[SysId][SpaId]++; - //continue; - } - if (time > fmaxTimeGlobal){ - infoMessage.Form("SuperEpoch %5i Epoche %5i Time %9i eqID:%i sourceA:%i chID:%02i StopType: %i TriggerType: %i InfoType: %i maxTimeGlobal: %9i", - fSuperEpoch,fEpoch,time,eqID,sourceA,chID,stopType,triggerType,infoType,fmaxTimeGlobal); - LOG(debug) << infoMessage; - fmaxTimeGlobal = time; - } - } else { - infoMessage.Form("SuperEpoch %5i Epoche %5i FullTime %12lu eqID:%i sourceA:%i chID:%02i StopType: %i TriggerType: %i InfoType: %i new (Super)Epoch", - fSuperEpoch,fEpoch,fullTime,eqID,sourceA,chID,stopType,triggerType,infoType); - LOG(debug) << infoMessage; - //fmaxFullTimeGlobal = fullTime; - if (fEpoch != flastEpoch || fSuperEpoch > flastSuperEpoch) { - fmaxTimeGlobal = time; - for (Int_t iSys = 0; iSys < 3; iSys++) - for (Int_t iSpa = 0; iSpa < 6; iSpa++) - fmaxTimeGroup[iSys][iSpa] = 0; - fmaxTimeGroup[SysId][SpaId] = time; - } - if (time < fmaxTimeGlobal) { - infoMessage.Form("SuperEpoch %5i Epoche %5i Time %9i eqID:%i sourceA:%i chID:%02i StopType: %i TriggerType: %i InfoType: %i maxTimeGlobal: %9i time jump #Delta t: %9i", - fSuperEpoch,fEpoch,time,eqID,sourceA,chID,stopType,triggerType,infoType,fmaxTimeGlobal,Int_t(time-fmaxTimeGlobal)); - LOG(info) << infoMessage; - //wrongTimeOrder[SysId][SpaId]++; - //continue; - } - if (time > fmaxTimeGroup[SysId][SpaId]){ - infoMessage.Form("SuperEpoch %5i Epoche %5i Time %9i eqID:%i sourceA:%i chID:%02i StopType: %i TriggerType: %i InfoType: %i maxTimeGroup: %9i", - fSuperEpoch,fEpoch,time,eqID,sourceA,chID,stopType,triggerType,infoType,fmaxTimeGroup[SysId][SpaId]); - LOG(debug) << infoMessage; - fmaxTimeGroup[SysId][SpaId] = time; - } - if (time < fmaxTimeGroup[SysId][SpaId]) { - infoMessage.Form("SuperEpoch %5i Epoche %5i Time %9i eqID:%i sourceA:%i chID:%02i StopType: %i TriggerType: %i InfoType: %i maxTimeGroup: %9i time jump #Delta t: %9i", - fSuperEpoch,fEpoch,time,eqID,sourceA,chID,stopType,triggerType,infoType,fmaxTimeGroup[SysId][SpaId],Int_t(time-fmaxTimeGroup[SysId][SpaId])); - LOG(error) << infoMessage; - wrongTimeOrder[SysId][SpaId]++; - continue; - } - } - - - } - if (triggerType == 0){ - flastDlmTriggerTime[SysId][SpaId][raw->GetChannelID()] = fullTime; - infoMessage.Form("SuperEpoch %5i Epoche %5i FullTime %12lu eqID:%i sourceA:%i StopType: %i TriggerType: %i InfoType: %i new (Super)Epoch", - fSuperEpoch,fEpoch,fullTime,eqID,sourceA,stopType,triggerType,infoType); - LOG(info) << infoMessage; - for (Int_t iSys = 0; iSys < 1; iSys++){ - for (Int_t iSpa = 0; iSpa < 2; iSpa++){ - infoMessage.Form("SysID%02i SpaID%02i",iSys,iSpa); - LOG(info) << infoMessage; - //for (Int_t iCh = 0; iCh < 15; iCh++){ - infoMessage.Form("%12lu | %12lu | %12lu | %12lu | %12lu | %12lu | %12lu | %12lu | %12lu | %12lu | %12lu | %12lu | %12lu | %12lu | %12lu ", - flastDlmTriggerTime[iSys][iSpa][ 0],flastDlmTriggerTime[iSys][iSpa][ 1],flastDlmTriggerTime[iSys][iSpa][ 2],flastDlmTriggerTime[iSys][iSpa][ 3], - flastDlmTriggerTime[iSys][iSpa][ 4],flastDlmTriggerTime[iSys][iSpa][ 5],flastDlmTriggerTime[iSys][iSpa][ 6],flastDlmTriggerTime[iSys][iSpa][ 7], - flastDlmTriggerTime[iSys][iSpa][ 8],flastDlmTriggerTime[iSys][iSpa][ 9],flastDlmTriggerTime[iSys][iSpa][10],flastDlmTriggerTime[iSys][iSpa][11], - flastDlmTriggerTime[iSys][iSpa][12],flastDlmTriggerTime[iSys][iSpa][13],flastDlmTriggerTime[iSys][iSpa][14] - ); - LOG(info) << infoMessage; - // } - } - } - cout << "----------------------------------------------------------------------------------------------------------------------------------------------------------------" << endl; - } - - //if (stopType == 0 && triggerType > 0){ - if (fullTime > lastSpadicTime[SysId][SpaId]){ - // ok, next hit - - clusterSize[SysId][SpaId] = 1; - } else if (fullTime == lastSpadicTime[SysId][SpaId]) { // Clusterizer - // possible FNR trigger - if (stopType == 0){ // normal ending - //clusterSize = 1; - if (triggerType == 0) { // gobal dlm trigger - - } else if (triggerType == 1) { //Self triggered - // central pad candidate - clusterSize[SysId][SpaId]+=1; - } else if (triggerType == 2) { //Neighbor triggered - // outer pad candidate - clusterSize[SysId][SpaId]+=1; - } else { //Self and neighbor triggered - // central pad candidate - clusterSize[SysId][SpaId]+=1; - } - } else {// multihit or currupted - } - } else { - if (isHit){ - //TimeClustering2015CernSPS(); - wrongTimeOrder[SysId][SpaId]++; - continue; - errorMessage.Form("SuperEpoch %5i Epoch %5i Container:%5i Message:%5i FullTime:%15lu eqID:%i sourceA:%i (Sys%iSpa%i) ChId:%2i CombiID:%2i StopType: %i TriggerType: %i InfoType:%i message time %15lu < last message time %15lu",fSuperEpoch,fEpoch,fContainerCounter,fSpadicMessageCounter,fullTime,eqID,sourceA,SysId,SpaId,chID,combiId,stopType,triggerType,infoType,fullTime, lastSpadicTime[SysId][SpaId]); - LOG(error) << errorMessage; - } - } - if (isHit){ - if (flastEpoch > fEpoch && flastSuperEpoch > fSuperEpoch){ - errorMessage.Form("SuperEpoch %5i Epoch %5i | lastSuperEpoch %5i lastEpoch %5i",fSuperEpoch,fEpoch,flastSuperEpoch,flastEpoch); - LOG(error) << errorMessage; - } - - if (flastSuperEpoch == fSuperEpoch && flastEpoch == fEpoch){ - - std::map<Int_t, CbmSpadicRawMessage*>::iterator timeBufferIt = fTimeBuffer[TString(syscore+spadic)][time].find(combiId); - if (timeBufferIt == fTimeBuffer[TString(syscore+spadic)][time].end()){ - fTimeBuffer[TString(syscore+spadic)][time][combiId]= new CbmSpadicRawMessage((Int_t)raw->GetEquipmentID(), (Int_t)raw->GetSourceAddress(), raw->GetChannelID(), - raw->GetEpochMarker(), raw->GetTime(), raw->GetSuperEpoch(), raw->GetTriggerType(), - raw->GetInfoType(), raw->GetStopType(), raw->GetGroupId(), raw->GetBufferOverflowCount(), - raw->GetNrSamples(), raw->GetSamples()); - } else { - debugMessage.Form("SuperEpoch %5i Epoch %5i Container:%5i Message:%5i FullTime:%15lu eqID:%i sourceA:%i (Sys%iSpa%i) ChId:%2i CombiID:%2i StopType: %i TriggerType: %i allready in buffer", - fSuperEpoch,fEpoch,fContainerCounter,fSpadicMessageCounter,fullTime,eqID,sourceA,SysId,SpaId,chID,combiId,stopType,triggerType); - LOG(debug) << debugMessage; - } - } else { - TimeClustering2015CernSPS(); - } - - std::map<Int_t, CbmSpadicRawMessage*>::iterator fullTimeBufferIt = fFullTimeBuffer[TString(syscore+spadic)][fullTime].find(combiId); - if (fullTimeBufferIt == fFullTimeBuffer[TString(syscore+spadic)][fullTime].end()){ - - //if (raw->GetStopType() == 0 )//|| raw->GetStopType() == 3 ) - fFullTimeBuffer[TString(syscore+spadic)][fullTime][combiId]= new CbmSpadicRawMessage((Int_t)raw->GetEquipmentID(), (Int_t)raw->GetSourceAddress(), raw->GetChannelID(), - raw->GetEpochMarker(), raw->GetTime(), raw->GetSuperEpoch(), raw->GetTriggerType(), - raw->GetInfoType(), raw->GetStopType(), raw->GetGroupId(), raw->GetBufferOverflowCount(), raw->GetNrSamples(), raw->GetSamples()); - } else { - //fFullTimeBuffer[TString(syscore+spadic)][fullTime][-1]=raw; - debugMessage.Form("SuperEpoch %5i Epoch %5i Container:%5i Message:%5i FullTime:%15lu eqID:%i sourceA:%i (Sys%iSpa%i) ChId:%2i CombiID:%2i StopType: %i TriggerType: %i allready in fullTime buffer",fSuperEpoch,fEpoch,fContainerCounter,fSpadicMessageCounter,fullTime,eqID,sourceA,SysId,SpaId,chID,combiId,stopType,triggerType); - LOG(debug) << debugMessage; - - fDoubleCounter++; - } - //} - } else { - if (raw->GetBufferOverflowCount() > 0){ - infoMessage.Form("SuperEpoch %5i Epoch %5i Container:%5i Message:%5i FullTime:%15lu eqID:%i sourceA:%i (Sys%iSpa%i) ChId:%2i CombiID:%2i InfoType: %i Lost %3i messages",fSuperEpoch,fEpoch,fContainerCounter,fSpadicMessageCounter,fullTime,eqID,sourceA,SysId,SpaId,chID,combiId,infoType,raw->GetBufferOverflowCount()); - LOG(info) << infoMessage; - } else { - infoMessage.Form("SuperEpoch %5i Epoch %5i Container:%5i Message:%5i FullTime:%15lu eqID:%i sourceA:%i (Sys%iSpa%i) ChId:%2i CombiID:%2i InfoType: %i",fSuperEpoch,fEpoch,fContainerCounter,fSpadicMessageCounter,fullTime,eqID,sourceA,SysId,SpaId,chID,combiId,infoType); - //LOG(info) << infoMessage; - } - } - /* - if (fullTime > lastSpadicTime[SysId][SpaId]){ - // ok, next hit - - clusterSize[SysId][SpaId] = 1; - } else if (fullTime == lastSpadicTime[SysId][SpaId]) { // Clusterizer - // possible FNR trigger - if (stopType == 0){ // normal ending - //clusterSize = 1; - if (triggerType == 0) { // gobal dlm trigger - - } else if (triggerType == 1) { //Self triggered - // central pad candidate - clusterSize[SysId][SpaId]+=1; - } else if (triggerType == 2) { //Neighbor triggered - // outer pad candidate - clusterSize[SysId][SpaId]+=1; - } else { //Self and neighbor triggered - // central pad candidate - clusterSize[SysId][SpaId]+=1; - } - } else {// multihit or currupted - } - } else { - if (isHit){ - //TimeClustering2015CernSPS(); - wrongTimeOrder[SysId][SpaId]++; - //break; - errorMessage.Form("SuperEpoch %5i Epoch %5i Container:%5i Message:%5i FullTime:%15lu eqID:%i sourceA:%i (Sys%iSpa%i) ChId:%2i CombiID:%2i StopType: %i TriggerType: %i InfoType:%i message time %15lu < last message time %15lu",fSuperEpoch,fEpoch,fContainerCounter,fSpadicMessageCounter,fullTime,eqID,sourceA,SysId,SpaId,chID,combiId,stopType,triggerType,infoType,fullTime, lastSpadicTime[SysId][SpaId]); - LOG(error) << errorMessage; - } - } - */ - TString channelId; - channelId.Form("_Ch%02d", chID); - - fHM->H1(TString("Message_Length_" + syscore + spadic).Data())->Fill(nrSamples,chID); - fHM->H1(TString("StopType_Message_Length_" + syscore + spadic).Data())->Fill(nrSamples,stopType); - fHM->H1(TString("InfoType_Message_Length_" + syscore + spadic).Data())->Fill(nrSamples,infoType); - fHM->H1(TString("TriggerType_Message_Length_" + syscore + spadic).Data())->Fill(nrSamples,triggerType); - if (triggerType == -1){ - fHM->H2(TString("TriggerTypes_" + syscore + spadic).Data())->Fill(triggerType,chID,bufferOverflowCount); - } else { - fHM->H2(TString("TriggerTypes_" + syscore + spadic).Data())->Fill(triggerType,chID); - } - fHM->H2(TString("StopTypes_" + syscore + spadic).Data())->Fill(stopType,chID); - fHM->H2(TString("Trigger_Stop_Types_" + syscore + spadic).Data())->Fill(triggerType,stopType); - fHM->H2(TString("Trigger_Info_Types_" + syscore + spadic).Data())->Fill(triggerType,infoType); - fHM->H2(TString("Stop_Info_Types_" + syscore + spadic).Data())->Fill(stopType,infoType); - fHM->H2(TString("InfoTypes_" + syscore + spadic).Data())->Fill(infoType,chID); - - fHM->H1(TString("GroupId_" + syscore + spadic).Data())->Fill(groupId); - - if (stopType > 0){ //corrupt or multi message - //TString histName = "ErrorCounter_" + syscore + spadic; - //fHM->H1(histName.Data())->Fill(chID); - sumError[SysId][SpaId]++; - } else { //only normal message end - if (isHit) - sumTrigger[SysId][SpaId]++; - if (isInfo) - sumOverflow[SysId][SpaId] += bufferOverflowCount; - - if (isHit){ - TString histName = "CountRate_" + syscore + spadic; - fHM->H1(histName.Data())->Fill(chID); - - histName = "Noise1_" + syscore + spadic + channelId; - Float_t Baseline = 0; - for (Int_t bin = 1; bin < 4; bin++){ - Baseline += raw->GetSamples()[nrSamples-bin]; - fHM->H1(histName.Data())->Fill(raw->GetSamples()[nrSamples-bin]); - } - Baseline /= 3.; - - histName = "BaseLine_" + syscore + spadic; - fHM->H2(histName.Data())->Fill(chID, Baseline); - - Float_t AdcIntegral = 0; - Int_t maxADC(-300); - Int_t maxTimeBin(-1); - - for (Int_t bin = 0; bin < nrSamples; bin++) { - if (raw->GetSamples()[bin] > maxADC){ - maxADC = raw->GetSamples()[bin]; - maxTimeBin = bin; - } - AdcIntegral += raw->GetSamples()[bin] - Baseline; - - histName = "Signal_Shape_" + syscore + spadic + channelId; - - fHM->H2(histName.Data())->Fill(bin,raw->GetSamples()[bin] - Baseline); - histName = "Pulse_" + syscore + spadic + channelId; - - fHM->H2(histName.Data())->Fill(bin,raw->GetSamples()[bin]); - if (stopType == 0) - if (triggerType == 1 || triggerType == 3){ - if (kFlesMuenster == eqID){ - if (maxADC > -200 && maxADC <= -190 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger-200")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > -190 && maxADC <= -180 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger-190")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > -180 && maxADC <= -170 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger-180")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > -170 && maxADC <= -160 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger-170")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > -160 && maxADC <= -150 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger-160")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > -150 && maxADC <= -140 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger-150")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > -140 && maxADC <= -130 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger-140")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > -130 && maxADC <= -120 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger-130")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > -120 && maxADC <= -110 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger-120")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > -110 && maxADC <= -100 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger-110")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > -100 && maxADC <= -90 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger-100")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > -90 && maxADC <= -80 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger-090")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > -80 && maxADC <= -70 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger-080")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > -70 && maxADC <= -60 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger-070")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > -60 && maxADC <= -50 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger-060")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > -50 && maxADC <= -40 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger-050")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > -40 && maxADC <= -30 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger-040")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > -30 && maxADC <= -20 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger-030")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > -20 && maxADC <= -10 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger-020")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > -10 && maxADC <= 0 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger-010")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > 0 && maxADC <= 10 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger0000")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > 200 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger0200")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > 190 && maxADC <= 200 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger0190")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > 180 && maxADC <= 190 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger0180")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > 170 && maxADC <= 180 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger0170")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > 160 && maxADC <= 170 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger0160")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > 150 && maxADC <= 160 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger0150")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > 140 && maxADC <= 150 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger0140")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > 130 && maxADC <= 140 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger0130")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > 120 && maxADC <= 130 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger0120")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > 110 && maxADC <= 120 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger0110")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > 100 && maxADC <= 110 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger0100")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > 90 && maxADC <= 100 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger0090")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > 80 && maxADC <= 90 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger0080")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > 70 && maxADC <= 80 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger0070")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > 60 && maxADC <= 70 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger0060")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > 50 && maxADC <= 60 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger0050")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > 40 && maxADC <= 50 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger0040")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > 30 && maxADC <= 40 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger0030")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > 20 && maxADC <= 30 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger0020")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > 10 && maxADC <= 20 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger0010")->Fill(bin,raw->GetSamples()[bin]); - } - if (FragmentedPulseTest(raw) && maxADC < 0){//maxADC > 0 /*&& maxADC > -200 */&& maxTimeBin < 5){ - fHM->H2("MeanPulseShape_Fragmented")->Fill(bin,raw->GetSamples()[bin]); - fHM->H1("MeanPulseProfile_Fragmented")->Fill(bin,raw->GetSamples()[bin]); - } else if (!FragmentedPulseTest(raw) && maxADC > 0) {// {//if (maxADC < 0 /*&& maxADC > -200 */&& maxTimeBin < 5) { - fHM->H2("MeanPulseShape_Unfragmented")->Fill(bin,raw->GetSamples()[bin]); - fHM->H1("MeanPulseProfile_Unfragmented")->Fill(bin,raw->GetSamples()[bin]); - } - } - } - } - if (FragmentedPulseTest(raw)) - fFragmentedCounter++; - if (stopType == 0) - if (triggerType == 1/* || triggerType == 3*/) { - if (FragmentedPulseTest(raw)){ - - fHM->H2("FragmentedVsUnfragmentedPulses")->Fill(0.0,raw->GetSamples()[maxTimeBin]); - } else { - fHM->H2("FragmentedVsUnfragmentedPulses")->Fill(1,raw->GetSamples()[maxTimeBin]); - } - } - for (Int_t bin = 0; bin < nrSamples; bin++) { - histName = "maxADC_TimeBinCorr_" + syscore + spadic + "_TB" + timebinName[bin]; - fHM->H2(histName.Data())->Fill(raw->GetSamples()[maxTimeBin],raw->GetSamples()[bin]); - } - - histName = "maxTimeBin_" + syscore + spadic + channelId; - fHM->H1(histName.Data())->Fill(maxTimeBin); - - histName = "maxADC_" + syscore + spadic + channelId; - fHM->H1(histName.Data())->Fill(maxADC); - - histName = "maxADC_maxTimeBin_" + syscore + spadic + channelId; - fHM->H2(histName.Data())->Fill(maxTimeBin,maxADC); - - histName = "Integrated_ADC_Spectrum_" + syscore + spadic; - if (maxADC > -200) // minimum amplitude threshold to reduce noise - fHM->H2(histName.Data())->Fill(chID, AdcIntegral); - - histName = "Trigger_Heatmap_" + syscore + spadic; - if (maxADC > -200){ // minimum amplitude threshold to reduce noise - fHM->H2(histName.Data())->Fill(columnId ,rowId); - } - - histName = "DeltaTime_" + syscore + spadic; - fHM->H1(histName.Data())->Fill(fullTime-lastSpadicTime[SysId][SpaId]); - - histName = "TriggerRate_" + syscore + spadic; - if (fullTime-lastSpadicTimeCh[SysId][SpaId][chID] > 0.0) - if (triggerType == 1 || triggerType == 3) - fHM->H1(histName.Data())->Fill(chID, 1.0/((fullTime-lastSpadicTimeCh[SysId][SpaId][chID])*1.0E-09));//ns -> s -> Hz - - histName = "DeltaTime_Left_Right_" + syscore + spadic; - if (chID < 31) - fHM->H1(histName.Data())->Fill(fullTime-lastSpadicTimeCh[SysId][SpaId][chID+1]); - if (chID > 0) - fHM->H1(histName.Data())->Fill(fullTime-lastSpadicTimeCh[SysId][SpaId][chID-1]); - - histName = "DeltaTime_Left_Right_Trigger_" + syscore + spadic; - if (triggerType == 1 || triggerType == 3){ - if (chID < 31) - if (lastTriggerType[chID+1] == 2 || lastTriggerType[chID+1] == 3) - fHM->H1(histName.Data())->Fill(fullTime-lastSpadicTimeCh[SysId][SpaId][chID+1]); - if (chID > 0) - if (lastTriggerType[chID-1] == 2 || lastTriggerType[chID-1] == 3) - fHM->H1(histName.Data())->Fill(fullTime-lastSpadicTimeCh[SysId][SpaId][chID-1]); - } - } - } - - lastSpadicTime[SysId][SpaId] = fullTime; - lastSpadicTimeCh[SysId][SpaId][chID] = fullTime; - lastTriggerType[chID] = triggerType; - flastEpoch = fEpoch; - flastSuperEpoch = fSuperEpoch; - entries++; - } //entriesInMessage - - for (Int_t sy = 0; sy < 2; sy++){ - for (Int_t sp = 0; sp < 2; sp++){ - TString histName = "_SysCore" + std::to_string(sy) + "_Spadic" + std::to_string(sp); - for (Int_t timeSlice = 1; timeSlice <= fHM->H1((TString("TriggerCounter") + histName).Data())->GetNbinsX(); timeSlice++){ - fHM->H1((TString("TriggerCounter") + histName).Data())->SetBinContent(timeSlice,fHM->H1((TString("TriggerCounter") + histName).Data())->GetBinContent(timeSlice+1)); // shift all bin one to the left - fHM->H1((TString("OverFlowCounter") + histName).Data())->SetBinContent(timeSlice,fHM->H1((TString("OverFlowCounter") + histName).Data())->GetBinContent(timeSlice+1)); - fHM->H1((TString("ErrorCounter") + histName).Data())->SetBinContent(timeSlice,fHM->H1((TString("ErrorCounter") + histName).Data())->GetBinContent(timeSlice+1)); - } - fHM->H1((TString("TriggerCounter") + histName).Data())->SetBinContent(fHM->H1((TString("TriggerCounter") + histName).Data())->GetNbinsX(),sumTrigger[sy][2*sp] + sumTrigger[sy][2*sp+1]);// set only the spa sys combi to new value - fHM->G1((TString("TriggerCounterGraph") + histName).Data())->SetPoint(fHM->G1((TString("TriggerCounterGraph") + histName).Data())->GetN(),fHM->G1((TString("TriggerCounterGraph") + histName).Data())->GetN(),sumTrigger[sy][2*sp] + sumTrigger[sy][2*sp+1]); - - fHM->H1((TString("OverFlowCounter") + histName).Data())->SetBinContent(fHM->H1((TString("OverFlowCounter") + histName).Data())->GetNbinsX(),sumOverflow[sy][2*sp] + sumOverflow[sy][2*sp+1]); - fHM->G1((TString("OverFlowCounterGraph") + histName).Data())->SetPoint(fHM->G1((TString("OverFlowCounterGraph") + histName).Data())->GetN(),fHM->G1((TString("OverFlowCounterGraph") + histName).Data())->GetN(),sumOverflow[sy][2*sp] + sumOverflow[sy][2*sp+1]); - fHM->H1((TString("ErrorCounter") + histName).Data())->SetBinContent(fHM->H1((TString("ErrorCounter") + histName).Data())->GetNbinsX(),sumError[sy][2*sp] + sumError[sy][2*sp+1]); - fHM->G1((TString("ErrorCounterGraph") + histName).Data())->SetPoint(fHM->G1((TString("ErrorCounterGraph") + histName).Data())->GetN(),fHM->G1((TString("ErrorCounterGraph") + histName).Data())->GetN(),sumError[sy][2*sp] + sumError[sy][2*sp+1]); - fHM->H1("TriggerSum")->Fill(TString("SysCore" + std::to_string(sy) + "_Spadic" + std::to_string(sp)),sumTrigger[sy][2*sp] + sumTrigger[sy][2*sp+1]); - } - } - for(Int_t syscore = 0; syscore < 3; ++syscore) { - for(Int_t spadic = 0; spadic < 3; ++spadic) { - if(wrongTimeOrder[syscore][spadic] > 0) - LOG(error) << "SPADIC " << syscore << spadic << " Wrong time stamp order in " << Float_t(wrongTimeOrder[syscore][spadic]*100./entriesInMessage) <<"% of all events " << wrongTimeOrder[syscore][spadic]; - } - } - -} - Bool_t CbmTrdRawBeamProfile::FragmentedPulseTest(CbmSpadicRawMessage* raw) - { - Int_t maxAdcValue(-300),maxTimeBin(-1), sample(-300); - Int_t nrSamples=raw->GetNrSamples(); - for (Int_t bin = 0; bin < nrSamples; bin++) { - sample = raw->GetSamples()[bin]; - if (sample > maxAdcValue){ - maxAdcValue = sample; - maxTimeBin = bin; - } - } - if (maxTimeBin == 0) - return true; - else if (raw->GetSamples()[maxTimeBin] - raw->GetSamples()[/*maxTimeBin-1*/0] <= 0) - return true; - else - return false; - } - Int_t CbmTrdRawBeamProfile::GetMaximumAdc(CbmSpadicRawMessage* raw) - { - if (raw==NULL) return -1; - Int_t maxAdcValue(-300), sample(-300); - Int_t nrSamples=raw->GetNrSamples(); - for (Int_t bin = 0; bin < nrSamples; bin++) { - sample = raw->GetSamples()[bin]; - if (sample > maxAdcValue){ - maxAdcValue = sample; - } - } - return maxAdcValue; - } - -void CbmTrdRawBeamProfile::CleanUpBuffers() -{ - - for (std::map<TString, std::map<Int_t, std::map<Int_t, CbmSpadicRawMessage*> > >::iterator SpaSysIt = fTimeBuffer.begin(); SpaSysIt != fTimeBuffer.end(); SpaSysIt++){ - for (std::map<Int_t, std::map<Int_t, CbmSpadicRawMessage*> >::iterator TimeIt = SpaSysIt->second.begin(); TimeIt != SpaSysIt->second.end(); TimeIt++){ - for (std::map<Int_t, CbmSpadicRawMessage*> ::iterator CombiIt = TimeIt->second.begin(); CombiIt != TimeIt->second.end(); CombiIt++){ - if(CombiIt->second != NULL) - delete CombiIt->second; - } - TimeIt->second.clear(); - } - SpaSysIt->second.clear(); - } - fTimeBuffer.clear(); - /* - for (std::map<TString, std::map<ULong_t, std::map<Int_t, CbmSpadicRawMessage*> > >::iterator SpaSysIt = fFullTimeBuffer.begin() ; SpaSysIt != fFullTimeBuffer.end(); SpaSysIt++){ - for (std::map<ULong_t, std::map<Int_t, CbmSpadicRawMessage*> > ::iterator timeIt = SpaSysIt->second.begin() ; timeIt != SpaSysIt->second.end(); timeIt++){ - for (std::map<Int_t, CbmSpadicRawMessage*> ::iterator combiIt = timeIt->second.begin(); combiIt != timeIt->second.end(); combiIt++){ - if(combiIt->second != NULL) - delete combiIt->second; - } - timeIt->second.clear(); - } - SpaSysIt->second.clear(); - } - fFullTimeBuffer.clear(); - for (std::map<TString, std::map<ULong_t, std::multimap<Int_t, CbmSpadicRawMessage*> > >::iterator SpaSysIt = fFullTimeBufferAll.begin() ; SpaSysIt != fFullTimeBufferAll.end(); SpaSysIt++){ - for (std::map<ULong_t, std::multimap<Int_t, CbmSpadicRawMessage*> > ::iterator timeIt = SpaSysIt->second.begin() ; timeIt != SpaSysIt->second.end(); timeIt++){ - for (std::multimap<Int_t, CbmSpadicRawMessage*> ::iterator combiIt = timeIt->second.begin(); combiIt != timeIt->second.end(); combiIt++){ - if(combiIt->second != NULL) - delete combiIt->second; - } - timeIt->second.clear(); - } - SpaSysIt->second.clear(); - } - fFullTimeBufferAll.clear(); - for (std::map<Int_t, std::map<Int_t, std::map<Int_t, std::map<Int_t, CbmTrbRawMessage*> > > >::iterator SourceAIt = fTrbBuffer.begin() ; SourceAIt != fTrbBuffer.end(); SourceAIt++){ - for (std::map<Int_t, std::map<Int_t, std::map<Int_t, CbmTrbRawMessage*> > >::iterator epochIt = SourceAIt->second.begin() ; epochIt != SourceAIt->second.end(); epochIt++){ - for (std::map<Int_t, std::map<Int_t, CbmTrbRawMessage*> > ::iterator chIdIt = epochIt->second.begin() ; chIdIt != epochIt->second.end(); chIdIt++){ - for (std::map<Int_t, CbmTrbRawMessage*> ::iterator timeIt = chIdIt->second.begin(); timeIt != chIdIt->second.end(); timeIt++){ - if(timeIt->second != NULL) - delete timeIt->second; - } - chIdIt->second.clear(); - } - epochIt->second.clear(); - } - SourceAIt->second.clear(); - } - fTrbBuffer.clear(); - */ -} - -void CbmTrdRawBeamProfile::TimeClustering2015CernSPS() -{ - TString errorMessage, infoMessage, debugMessage; - debugMessage.Form("CbmTrdRawBeamProfile::TimeClustering2015CernSPS: SuperEpoch: %9i Epoch: %9i",fSuperEpoch, fEpoch); - LOG(debug) << debugMessage; - const Int_t deltaTimeThreshold = 100000; - //printf("Start TimeClustering for 2015 CERN SPS Data\n FFM Chamber on link0\n MS Chamber on link1 \n!!!!HARD CODED!!!!\n"); - //CbmSpadicRawMessage* raw = NULL; - //Int_t layerId(0), moduleId(0), sectorId(0), rowId(0), columnId(0), clusterSize(0); - Int_t maxCombiIdFFM(-1), maxCombiIdMS(-1); - Int_t lastFFMTime(0), thisFFMTime(0); - Int_t /*lastMSTime(0),*/ thisMSTime(0); - // Bool_t inside_Cluster(false); - if (fTimeBuffer.begin() != fTimeBuffer.end()){ - //cout << (fTimeBuffer.begin())->first<< endl; - } else { - errorMessage.Form("No TimeBuffer map found"); - LOG(error) << errorMessage; - return; - } - std::map<TString, std::map<Int_t, std::map<Int_t, CbmSpadicRawMessage*> > >::iterator FFMIt = fTimeBuffer.find(TString("SysCore0_Spadic0")); - if (FFMIt == fTimeBuffer.end()){ - infoMessage.Form("No map found for SysCore0_Spadic0 at SuperEpoch %9i Epoch %9i",fSuperEpoch,fEpoch); - LOG(info) << infoMessage; - CleanUpBuffers(); - return; - } - std::map<TString, std::map<Int_t, std::map<Int_t, CbmSpadicRawMessage*> > >::iterator MSIt = fTimeBuffer.find(TString("SysCore0_Spadic1")); - if (MSIt == fTimeBuffer.end()){ - infoMessage.Form("No map found for SysCore0_Spadic1 at SuperEpoch %9i Epoch %9i",fSuperEpoch,fEpoch); - LOG(info) << infoMessage; - CleanUpBuffers(); - return; - } -// std::map<Int_t, std::map<Int_t, CbmSpadicRawMessage*> >::iterator secondTimeIt = (MSIt->second).begin(); - for (std::map<Int_t, std::map<Int_t, CbmSpadicRawMessage*> >::iterator firstTimeIt = (FFMIt->second).begin() ; firstTimeIt != (FFMIt->second).end(); firstTimeIt++){ - Int_t maxChargeFFM(-300), lastChargeFFM(-301), maxChargeMS(-300), lastChargeMS(-301); - //secondEpochIt = (MSIt->second).find(firstEpochIt->first); - //if (secondEpochIt == (MSIt->second).end()) continue; - //std::map<Int_t, std::map<Int_t, CbmSpadicRawMessage*> >::iterator secondTimeIt = (secondEpochIt->second).begin(); - //for (std::map<Int_t, std::map<Int_t, CbmSpadicRawMessage*> >::iterator firstTimeIt = (firstEpochIt->second).begin(); firstTimeIt != (firstEpochIt->second).end(); firstTimeIt++){ - thisFFMTime = (Int_t)firstTimeIt->first; - debugMessage.Form("SysCore0_Spadic0 at SuperEpoch %9i Epoch %9i Time %12i",fSuperEpoch,fEpoch,thisFFMTime); - LOG(info) << debugMessage; - for (std::map<Int_t, CbmSpadicRawMessage*> ::iterator combiFFMIt = (firstTimeIt->second).begin(); combiFFMIt != (firstTimeIt->second).end(); combiFFMIt++){ - //raw = combiIt->second; - maxChargeFFM = GetMaximumAdc(combiFFMIt->second); - if (maxChargeFFM > lastChargeFFM){ - lastChargeFFM = maxChargeFFM; - maxCombiIdFFM = combiFFMIt->first; - } - } - //for ( std::map<Int_t, std::map<Int_t, CbmSpadicRawMessage*> >::iterator secondTimeIt = (secondEpochIt->second).begin(); secondTimeIt != (secondEpochIt->second).end(); secondTimeIt++){ - - //cout << "thisFFMTime: " << thisFFMTime << endl; - - if (thisFFMTime > lastFFMTime){ - //cout << " nextFFMTime found" << endl; -// for (secondTimeIt ; secondTimeIt != (MSIt->second).end(); secondTimeIt++){ - for (std::map<Int_t, std::map<Int_t, CbmSpadicRawMessage*> >::iterator secondTimeIt = (MSIt->second).begin(); secondTimeIt != (MSIt->second).end(); secondTimeIt++){ - thisMSTime = (Int_t)secondTimeIt->first; - - //cout << " thisMSTime: " << thisMSTime; - Int_t deltaTime = Int_t(thisMSTime - thisFFMTime); - - if (thisMSTime < thisFFMTime){ - // before message seen in first detector - debugMessage.Form("SysCore0_Spadic0 at SuperEpoch %9i Epoch %9i Time %12i #DeltaTime %12i past",fSuperEpoch,fEpoch,thisFFMTime,deltaTime); - LOG(info) << debugMessage; - for (std::map<Int_t, CbmSpadicRawMessage*> ::iterator combiMSIt = (secondTimeIt->second).begin(); combiMSIt != (secondTimeIt->second).end(); combiMSIt++){ - for (std::map<Int_t, CbmSpadicRawMessage*> ::iterator combiFFMIt = (firstTimeIt->second).begin(); combiFFMIt != (firstTimeIt->second).end(); combiFFMIt++){ - //Int_t equalFFMMessages = (firstTimeIt->second).count(combiFFMIt->first); - //Int_t equalMSMessages = (secondTimeIt->second).count(combiMSIt->first); - if (deltaTime < deltaTimeThreshold) - //for (Int_t iEqualFFM = 0; iEqualFFM < equalFFMMessages; iEqualFFM++) - // for (Int_t iEqualMS = 0; iEqualMS < equalMSMessages; iEqualMS++) - fHM->H2("DeltaClusterTimeCorrelationAllEvents2015CernSPS")->Fill(combiFFMIt->first,combiMSIt->first); - } - } - - } - else if (thisMSTime == thisFFMTime) { - //same time in both detectors - debugMessage.Form("SysCore0_Spadic0 at SuperEpoch %9i Epoch %9i Time %12i #DeltaTime %12i now",fSuperEpoch,fEpoch,thisFFMTime,deltaTime); - LOG(info) << debugMessage; - //cout << " now " << Int_t(thisMSTime - thisFFMTime) <<endl; - fHM->H1("DeltaClusterTime2015CernSPS")->Fill(deltaTime); - for (std::map<Int_t, CbmSpadicRawMessage*> ::iterator combiMSIt = (secondTimeIt->second).begin(); combiMSIt != (secondTimeIt->second).end(); combiMSIt++){ - //raw = combiIt->second; - if (deltaTime < deltaTimeThreshold) - for (std::map<Int_t, CbmSpadicRawMessage*> ::iterator combiFFMIt = (firstTimeIt->second).begin(); combiFFMIt != (firstTimeIt->second).end(); combiFFMIt++){ - fHM->H2("DeltaClusterTimeCorrelationFullCluster2015CernSPS")->Fill(combiFFMIt->first,combiMSIt->first); - fHM->H2("DeltaClusterTimeCorrelationAllEvents2015CernSPS")->Fill(combiFFMIt->first,combiMSIt->first); - } - maxChargeMS = GetMaximumAdc(combiMSIt->second); - if (maxChargeMS > lastChargeMS){ - lastChargeMS = maxChargeMS; - maxCombiIdMS = combiMSIt->first; - } - } - fHM->H2("DeltaClusterTimeCorrelation2015CernSPS")->Fill(maxCombiIdFFM,maxCombiIdMS); - // lastMSTime = thisMSTime; (VF) not used - break; - } else { - //we are looking for first message after FFM message time - //cout << " past " << Int_t(thisMSTime - thisFFMTime) <<endl; - - debugMessage.Form("SysCore0_Spadic0 at SuperEpoch %9i Epoch %9i Time %12i #DeltaTime %12i future",fSuperEpoch,fEpoch,thisFFMTime,deltaTime); - LOG(info) << debugMessage; - fHM->H1("DeltaClusterTime2015CernSPS")->Fill(Int_t(thisMSTime - thisFFMTime));//Fill only for the first message of a new cluster - //cout << "---find max channel---" << endl; - if (deltaTime < deltaTimeThreshold) - for (std::map<Int_t, CbmSpadicRawMessage*> ::iterator combiMSIt = (secondTimeIt->second).begin(); combiMSIt != (secondTimeIt->second).end(); combiMSIt++){ - //raw = combiIt->second; - for (std::map<Int_t, CbmSpadicRawMessage*> ::iterator combiFFMIt = (firstTimeIt->second).begin(); combiFFMIt != (firstTimeIt->second).end(); combiFFMIt++){ - fHM->H2("DeltaClusterTimeCorrelationFullCluster2015CernSPS")->Fill(combiFFMIt->first,combiMSIt->first); - fHM->H2("DeltaClusterTimeCorrelationAllEvents2015CernSPS")->Fill(combiFFMIt->first,combiMSIt->first); - } - maxChargeMS = GetMaximumAdc(combiMSIt->second); - if (maxChargeMS > lastChargeMS){ - lastChargeMS = maxChargeMS; - maxCombiIdMS = combiMSIt->first; - } - } - // cout << "---done---" << endl; - if (deltaTime < deltaTimeThreshold) - fHM->H2("DeltaClusterTimeCorrelation2015CernSPS")->Fill(maxCombiIdFFM,maxCombiIdMS); - - break; // break for new cluster - - - } - // lastMSTime = thisMSTime; (VF) not used - } - } - lastFFMTime = thisFFMTime; - } - - CleanUpBuffers(); - -} - - void CbmTrdRawBeamProfile::Clusterizer() - { - LOG(info) << "CbmTrdRawBeamProfile::Clusterizer : SuperEpoch: " << fSuperEpoch << " Epoch: " << fEpoch; - /* - TCanvas* b = new TCanvas("rawpulseshape","rawpulseshape",800,600); - TH1F* rawpulse = new TH1F("rawpulse","rawpulse",32,-0.5,31.5); - rawpulse->GetYaxis()->SetRangeUser(-255,256); - */ - Int_t mapDigiCounter = 0; - CbmSpadicRawMessage* raw = NULL; - Int_t layerId(0), moduleId(0), sectorId(0), rowId(0), columnId(0), clusterSize(0); - ULong_t lastClusterTime = 0; - ULong_t fullTime = 0; - TString SysSpaID = ""; - std::vector<Int_t> digiIndices; - for (std::map<TString, std::map<ULong_t, std::map<Int_t, CbmSpadicRawMessage*> > >::iterator SpaSysIt = fFullTimeBuffer.begin() ; SpaSysIt != fFullTimeBuffer.end(); SpaSysIt++){ - SysSpaID = SpaSysIt->first; - //printf("%s\n",SysSpaID.Data()); - for (std::map<ULong_t, std::map<Int_t, CbmSpadicRawMessage*> > ::iterator timeIt = (SpaSysIt->second).begin() ; timeIt != (SpaSysIt->second).end(); timeIt++){ - LOG(debug) << "ClusterSize:" << Int_t((timeIt->second).size()); - clusterSize = Int_t((timeIt->second).size()); - fullTime = timeIt->first; - //printf(" %lu\n",fullTime); - fHM->H1(TString("ClusterSize_" + SysSpaID).Data())->Fill(clusterSize); - - //Delta time between time clusters - fHM->H1(TString("DeltaTime_Cluster_" + SysSpaID).Data())->Fill(fullTime - lastClusterTime); - lastClusterTime = fullTime; - - Int_t lastCombiID = -1; - //digiIndices.clear(); - //printf("\nTime: %lu\n",fullTime); - for (std::map<Int_t, CbmSpadicRawMessage*> ::iterator combiIt = (timeIt->second).begin(); combiIt != (timeIt->second).end(); combiIt++){ - mapDigiCounter++; - //rawpulse->SetLineColor(Int_t(digiIndices.size())+1); - raw = combiIt->second; - fHM->H2(TString("StopType_ClusterSize_" + SysSpaID).Data())->Fill(clusterSize,Int_t(raw->GetStopType())); - - if (Int_t(raw->GetStopType()) != 0 && Int_t(raw->GetStopType() != 3)) - fHM->H2(TString("InfoType_ClusterSize_" + SysSpaID).Data())->Fill(clusterSize,Int_t(raw->GetInfoType())); - fHM->H2(TString("TriggerType_ClusterSize_" + SysSpaID).Data())->Fill(clusterSize,Int_t(raw->GetTriggerType())); - - fHM->H2(TString("ClusterSize_Message_Length_" + SysSpaID).Data())->Fill(clusterSize,Int_t(raw->GetNrSamples())); - layerId = GetLayerID(raw); - moduleId = GetModuleID(raw); - //printf("%p fullTime %12lu %12lu %s CI%2i layer %i EI%i SA%i TT%i\n",std::addressof(raw),fullTime,raw->GetFullTime(),(SysSpaID).Data(),combiIt->first,layerId,Int_t(raw->GetEquipmentID()),Int_t(raw->GetSourceAddress()),raw->GetTriggerType()); - fHM->H2(TString("LayerId").Data())->Fill(layerId,SysSpaID,1); - fHM->H2(TString("ModuleId").Data())->Fill(moduleId,SysSpaID,1); - - sectorId = GetSectorID(raw); - rowId = GetRowID(raw); - columnId = GetColumnID(raw); - - // BaseLineCorrection== - Float_t Baseline = 0.; - if (raw->GetStopType() == 0){ - for (Int_t bin = 1; bin < 4; bin++){ - Baseline += raw->GetSamples()[raw->GetNrSamples()-bin]; - } - Baseline /= 3.; - } else { - // Use average baseline estimated for full message length - } - const Int_t nSamples = 32;//raw->GetNrSamples(); - Float_t Samples[nSamples] = {0.}; - for (Int_t iBin = 0; iBin < raw->GetNrSamples(); iBin++){ - //rawpulse->SetBinContent(iBin+1,raw->GetSamples()[iBin]); - Samples[iBin] = raw->GetSamples()[iBin] - Baseline; - } - /* - b->cd(); - if(Int_t(digiIndices.size())==0) - rawpulse->DrawCopy(); - else - rawpulse->DrawCopy("same"); - rawpulse->Reset(); - */ - //===================== - //printf("la%i mo%i se%i ro%i co%i\n",layerId,moduleId,sectorId,rowId,columnId); - new ((*fDigis)[fiDigi]) CbmTrdDigi(CbmTrdAddress::GetAddress(layerId,moduleId,sectorId,rowId,columnId), - raw->GetFullTime()*57.14,//57,14 ns per timestamp - raw->GetTriggerType(), raw->GetInfoType(), raw->GetStopType(), - raw->GetNrSamples(), Samples/*&Samples[32]*/); - //digiIndices.push_back(fiDigi); - - if (combiIt != timeIt->second.begin()){ - fHM->H1(TString("DeltaCh_Cluster_" + SpaSysIt->first).Data())->Fill(combiIt->first - lastCombiID); - } - - if (combiIt->first - lastCombiID != 1 && digiIndices.size() > 0){ - //printf("\n"); - //printf("|>------------------Cluster %i finished (%02i)\n", fiCluster,Int_t(digiIndices.size())); - CbmTrdCluster* cluster = new ((*fClusters)[fiCluster]) CbmTrdCluster(); - cluster->SetAddress(CbmTrdAddress::GetAddress(layerId,moduleId,sectorId,rowId,columnId)); - cluster->SetDigis(digiIndices); - digiIndices.clear(); - TString pulseId; - pulseId.Form("pics/%08iRawCluster.png",fiCluster); - //b->Update(); - if (fiCluster % 100 == 0){ - //b->SaveAs(pulseId); - } - //b->Clear(); - fiCluster++; - } - digiIndices.push_back(fiDigi); - //printf(" %02i row%i col%02i %i\n",combiIt->first,rowId,columnId,Int_t(digiIndices.size())); - //printf("%i ",combiIt->first); - //delete combiIt->second; - lastCombiID = combiIt->first; - fiDigi++; - } - if (digiIndices.size() > 0){ - //printf("digiIndices %i > 0\n",(Int_t)digiIndices.size()); - //printf("|>------------------Cluster %i finished (%02i)\n", fiCluster,Int_t(digiIndices.size())); - CbmTrdCluster* cluster = new ((*fClusters)[fiCluster]) CbmTrdCluster(); - cluster->SetAddress(CbmTrdAddress::GetAddress(layerId,moduleId,sectorId,rowId,columnId)); - cluster->SetDigis(digiIndices); - digiIndices.clear(); - TString pulseId; - pulseId.Form("pics/%08iRawCluster.png",fiCluster); - //b->Update(); - if (fiCluster % 100 == 0){ - //b->SaveAs(pulseId); - } - //b->Clear(); - fiCluster++; - } - //timeIt->second.clear(); - } - //SpaSysIt->second.clear(); - } - - printf("[INFO ] CbmTrdRawBeamProfile::Clusterizer Digis: %i\n",mapDigiCounter); - } - - Int_t CbmTrdRawBeamProfile::GetSysCoreID(CbmSpadicRawMessage* raw) - { - Int_t eqID = raw->GetEquipmentID(); - if (eqID == (Int_t)kFlesMuenster) { - return 0; - } else if (eqID == (Int_t)kFlesFrankfurt){ - return 1; - } else if (eqID == (Int_t)kFlesBucarest){ - return 2; - } else - LOG(error) << "Container " << fContainerCounter << " Message " << fSpadicMessageCounter << " EquipmentID " << eqID << "not known."; - return -1; - } - Int_t CbmTrdRawBeamProfile::GetSpadicID(CbmSpadicRawMessage* raw) - { - Int_t sourceA = raw->GetSourceAddress() - SpadicBaseAddress; - if (sourceA == 0 || sourceA == 1) - return 0; - else if (sourceA == 2 || sourceA == 3) - return 1; - else if (sourceA == 4 || sourceA == 5) - return 2; - else - LOG(error) << "Container " << fContainerCounter << " Message " << fSpadicMessageCounter << " Source Address " << sourceA << "not known."; - return -1; - } - Int_t CbmTrdRawBeamProfile::GetModuleID(CbmSpadicRawMessage* raw) - { - if (raw == NULL){ - LOG(error) << "CbmTrdRawBeamProfile::GetModuleID: CbmSpadicRawMessage == NULL"; - return -1; - } else { - Int_t sys = GetSysCoreID(raw); - Int_t spa = GetSpadicID(raw); - - return sys * 3 + spa; - } - } - Int_t CbmTrdRawBeamProfile::GetLayerID(CbmSpadicRawMessage* raw) - { - if (raw == NULL){ - LOG(error) << "CbmTrdRawBeamProfile::GetModuleID: CbmSpadicRawMessage == NULL"; - return -1; - } else { - Int_t sys = GetSysCoreID(raw); - Int_t spa = GetSpadicID(raw); - - return sys * 3 + spa; - } - } - Int_t CbmTrdRawBeamProfile::GetSectorID(CbmSpadicRawMessage* raw) - { - if (raw == NULL) - LOG(error) << "CbmTrdRawBeamProfile::GetSectorID: CbmSpadicRawMessage == NULL"; - return 0; - } - Int_t CbmTrdRawBeamProfile::GetRowID(CbmSpadicRawMessage* raw) - { - if (raw == NULL) - LOG(error) << "CbmTrdRawBeamProfile::GetRowID: CbmSpadicRawMessage == NULL"; - Int_t chID = raw->GetChannelID(); - Int_t sourceA = raw->GetSourceAddress(); - switch (sourceA) { - case (SpadicBaseAddress+0): // first spadic - break; - case (SpadicBaseAddress+1): // first spadic - chID += 16; - break; - case (SpadicBaseAddress+2): // second spadic - break; - case (SpadicBaseAddress+3): // second spadic - chID += 16; - break; - case (SpadicBaseAddress+4): // third spadic - break; - case (SpadicBaseAddress+5): // third spadic - chID += 16; - break; - default: - LOG(error) << "Container " << fContainerCounter << " Message " << fSpadicMessageCounter << " Source Address " << sourceA << "not known."; - break; - } - Int_t columnId = GetChannelOnPadPlane(chID); - if (columnId > 16) - return 1; - else - return 0; - } - Int_t CbmTrdRawBeamProfile::GetColumnID(CbmSpadicRawMessage* raw) - { - if (raw == NULL) - LOG(error) << "CbmTrdRawBeamProfile::GetColumnID: CbmSpadicRawMessage == NULL"; - Int_t chID = raw->GetChannelID(); - Int_t sourceA = raw->GetSourceAddress(); - switch (sourceA) { - case (SpadicBaseAddress+0): // first spadic - break; - case (SpadicBaseAddress+1): // first spadic - chID += 16; - break; - case (SpadicBaseAddress+2): // second spadic - break; - case (SpadicBaseAddress+3): // second spadic - chID += 16; - break; - case (SpadicBaseAddress+4): // third spadic - break; - case (SpadicBaseAddress+5): // third spadic - chID += 16; - break; - default: - LOG(error) << "Container " << fContainerCounter << " Message " << fSpadicMessageCounter << " Source Address " << sourceA << "not known."; - break; - } - Int_t columnId = GetChannelOnPadPlane(chID); - if (columnId >= 16) - columnId -= 16; - return columnId; - } - Int_t CbmTrdRawBeamProfile::GetChannelOnPadPlane(Int_t SpadicChannel) - { - Int_t channelMapping[32] = {31,15,30,14,29,13,28,12,27,11,26,10,25, 9,24, 8, - 23, 7,22, 6,21, 5,20, 4,19, 3,18, 2,17, 1,16, 0}; - if (SpadicChannel < 0 || SpadicChannel > 31){ - LOG(error) << "CbmTrdRawBeamProfile::GetChannelOnPadPlane ChId " << SpadicChannel; - return -1; - } else { - return channelMapping[SpadicChannel]; - } - } -Int_t CbmTrdRawBeamProfile::GetCombiID(CbmSpadicRawMessage* raw) -{ - const Int_t maxNrColumns = 16; - return (GetRowID(raw) * (maxNrColumns + 1) + GetColumnID(raw)); -} - // ---- Finish -------------------------------------------------------- - void CbmTrdRawBeamProfile::Finish() - { - Clusterizer(); - TimeClustering2015CernSPS(); - LOG(debug) << "Finish of CbmTrdRawBeamProfile"; - // Write to file - fHM->WriteToFile(); - // Update Histos and Canvases - - LOG(info) << "CbmTrdRawBeamProfile::Finish Container: " << fContainerCounter; - LOG(info) << "CbmTrdRawBeamProfile::Finish Spadic Messages: " << fSpadicMessageCounter; - LOG(info) << "CbmTrdRawBeamProfile::Finish Nxyter Messages: " << fNxyterMessageCounter; - LOG(info) << "CbmTrdRawBeamProfile::Finish Trb Messages: " << fTrbMessageCounter; - LOG(info) << "CbmTrdRawBeamProfile::Finish Infos: " << fInfoCounter; - LOG(info) << "CbmTrdRawBeamProfile::Finish Hits: " << fHitCounter; - LOG(info) << "CbmTrdRawBeamProfile::Finish Multihits: " << fMultiHitCounter; - LOG(info) << "CbmTrdRawBeamProfile::Finish Errors: " << fErrorCounter << " (stoptype != 0 && != 3)"; - LOG(info) << "CbmTrdRawBeamProfile::Finish LostHits: " << fLostHitCounter << " (buffer full)"; - LOG(info) << "CbmTrdRawBeamProfile::Finish Identical Messages: " << fDoubleCounter; - LOG(info) << "CbmTrdRawBeamProfile::Finish Fragemented Signals: " << fFragmentedCounter; - LOG(info) << "CbmTrdRawBeamProfile::Finish Digis: " << fDigis->GetEntriesFast(); - LOG(info) << "CbmTrdRawBeamProfile::Finish Clusters: " << fClusters->GetEntriesFast(); - } - - void CbmTrdRawBeamProfile::CreateHistograms() - { - gStyle->SetNumberContours(99); - gStyle->SetPadTickX(1); - gStyle->SetPadTickY(1); - // Create histograms for 3 Syscores with maximum 3 Spadics - TString histName = ""; - TString syscoreName[3] = { "SysCore0", "SysCore1", "SysCore2" }; - TString spadicName[3] = { "Spadic0", "Spadic1", "Spadic2" }; - TString channelName[32] = { "00", "01", "02", "03", "04", "05", "06", "07", "08", "09", - "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", - "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", - "30", "31"}; - TString timebinName[32] = { "00", "01", "02", "03", "04", "05", "06", "07", "08", "09", - "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", - "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", - "30", "31"}; - TString triggerTypes[5] = { "infoMessage", - "Global trigger", - "Self triggered", - "Neighbor triggered", - "Self and neighbor triggered"}; - TString stopTypes[6] = {"Normal end of message", - "Channel buffer full", - "Ordering FIFO full", - "Multi hit", - "Multi hit and channel buffer full", - "Multi hit and ordering FIFO full"}; - TString infoTypes[8] = {"Channel disabled during message building", - "Next grant timeout", - "Next request timeout", - "New grant but channel empty", - "Corruption in message builder", - "Empty word", - "Epoch out of sync", - "infoType out of array"}; //not official type, just to monitor overflows - - fHM->Add("DeltaClusterTime2015CernSPS", new TH1I("DeltaClusterTime2015CernSPS","DeltaClusterTime2015CernSPS",1E6,-100,200E6)); - fHM->H1("DeltaClusterTime2015CernSPS")->GetXaxis()->SetTitle("#Deltat_{SPADIC1-SPADIC0} (ns)"); - - fHM->Add("DeltaClusterTimeCorrelation2015CernSPS", new TH2I("DeltaClusterTimeCorrelation2015CernSPS","DeltaClusterTimeCorrelation2015CernSPS",34,-0.5,33.5,34,-0.5,33.5)); - fHM->H2("DeltaClusterTimeCorrelation2015CernSPS")->GetXaxis()->SetTitle("max CombiID Spadic0"); - fHM->H2("DeltaClusterTimeCorrelation2015CernSPS")->GetYaxis()->SetTitle("max CombiID Spadic1"); - - fHM->Add("DeltaClusterTimeCorrelationFullCluster2015CernSPS", new TH2I("DeltaClusterTimeCorrelationFullCluster2015CernSPS","DeltaClusterTimeCorrelationFullCluster2015CernSPS",34,-0.5,33.5,34,-0.5,33.5)); - fHM->H2("DeltaClusterTimeCorrelationFullCluster2015CernSPS")->GetXaxis()->SetTitle("all CombiID Spadic0"); - fHM->H2("DeltaClusterTimeCorrelationFullCluster2015CernSPS")->GetYaxis()->SetTitle("all CombiID Spadic1"); - - - fHM->Add("DeltaClusterTimeCorrelationAllEvents2015CernSPS", new TH2I("DeltaClusterTimeCorrelationAllEvents2015CernSPS","DeltaClusterTimeCorrelationAllEvents2015CernSPS",34,-0.5,33.5,34,-0.5,33.5)); - fHM->H2("DeltaClusterTimeCorrelationAllEvents2015CernSPS")->GetXaxis()->SetTitle("all CombiID Spadic0"); - fHM->H2("DeltaClusterTimeCorrelationAllEvents2015CernSPS")->GetYaxis()->SetTitle("all CombiID Spadic1"); - - fHM->Add("TriggerSum", new TH1I("TriggerSum", "TriggerSum", 9,0,9)); - fHM->Add("LayerId", new TH2I("LayerId", "LayerId", 9, -0.5, 8.5, 9, -0.5, 8.5)); - for(Int_t syscore = 0; syscore < 3; ++syscore) { - for(Int_t spadic = 0; spadic < 3; ++spadic) { - fHM->H1("LayerId")->GetYaxis()->SetBinLabel(syscore*3+spadic+1,syscoreName[syscore]+"_"+spadicName[spadic]); - } - } - fHM->Add("ModuleId", new TH2I("ModuleId", "ModuleId", 9, -0.5, 8.5, 9, -0.5, 8.5)); - for(Int_t syscore = 0; syscore < 3; ++syscore) { - for(Int_t spadic = 0; spadic < 3; ++spadic) { - fHM->H1("ModuleId")->GetYaxis()->SetBinLabel(syscore*3+spadic+1,syscoreName[syscore]+"_"+spadicName[spadic]); - } - } - for (Int_t maxAdcThreshold = -200; maxAdcThreshold <= 200; maxAdcThreshold+=10){ - histName.Form("maxAdcLarger%04i",maxAdcThreshold); - fHM->Add(TString("MeanPulseShape_"+histName).Data(), new TH2I(TString("MeanPulseShape_"+histName).Data(),TString("MeanPulseShape_"+histName).Data(),32,-0.5,31.5,2*256,-256.5,255.5)); - //cout << "MeanPulseShape_" << histName << endl; - //fHM->Add(TString("MeanPulseProfile_")+histName.Data(), new TProfile(TString("MeanPulseProfile_")+histName.Data(),TString("MeanPulseProfile_")+histName.Data(),32,-0.5,31.5,-256.5,255.5)); - } - - fHM->Add("FragmentedVsUnfragmentedPulses", new TH2I("FragmentedVsUnfragmentedPulses","FragmentedVsUnfragmentedPulses",2,-0.5,1.5,2*256,-256.5,255.5)); - fHM->H2("FragmentedVsUnfragmentedPulses")->GetXaxis()->SetBinLabel(1,"fragmented"); - fHM->H2("FragmentedVsUnfragmentedPulses")->GetXaxis()->SetBinLabel(2,"normal"); - - fHM->Add("MeanPulseShape_Fragmented", new TH2I("MeanPulseShape_Fragmented","MeanPulseShape_Fragmented",32,-0.5,31.5,2*256,-256.5,255.5)); - fHM->Add("MeanPulseProfile_Fragmented", new TProfile("MeanPulseProfile_Fragmented","MeanPulseProfile_Fragmented",32,-0.5,31.5,-256.5,255.5)); - - fHM->Add("MeanPulseShape_Unfragmented", new TH2I("MeanPulseShape_UnfragmentedPulses","MeanPulseShape_Unfragmented",32,-0.5,31.5,2*256,-256.5,255.5)); - fHM->Add("MeanPulseProfile_Unfragmented", new TProfile("MeanPulseProfile_UnfragmentedPulses","MeanPulseProfile_Unfragmented",32,-0.5,31.5,-256.5,255.5)); - - - for(Int_t syscore = 0; syscore < 3; ++syscore) { - for(Int_t spadic = 0; spadic < 3; ++spadic) { - fHM->H1("TriggerSum")->GetXaxis()->SetBinLabel(3*syscore+spadic+1,TString(syscoreName[syscore]+"_"+spadicName[spadic])); - - histName = "CountRate_" + syscoreName[syscore] + "_" + spadicName[spadic]; - TString title = histName + ";Channel;Counts"; - fHM->Add(histName.Data(), new TH1I(histName, title, 32, -0.5, 31.5)); - - histName = "TriggerRate_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";ChannelID;trigger rate [Hz]"; - fHM->Add(histName.Data(), new TProfile(histName, title, 32, -0.5, 31.5)); - - histName = "DeltaTime_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";Delta t ;Counts"; - fHM->Add(histName.Data(), new TH1I(histName, title, 5101, -100.5, 5000.5)); - - histName = "DeltaTime_Left_Right_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";Delta t ;Counts"; - fHM->Add(histName.Data(), new TH1I(histName, title, 5101, -100.5, 5000.5)); - - histName = "DeltaTime_Left_Right_Trigger_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";Delta t ;Counts"; - fHM->Add(histName.Data(), new TH1I(histName, title, 5101, -100.5, 5000.5)); - - histName = "DeltaTime_Cluster_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";Delta t ;Counts"; - fHM->Add(histName.Data(), new TH1I(histName, title, 5101, -100.5, 5000.5)); - - histName = "DeltaCh_Cluster_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";Delta t ;Counts"; - fHM->Add(histName.Data(), new TH1I(histName, title, 65, -32.5, 32.5)); - - histName = "StopType_Message_Length_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";Message Length (Time-Bins) ;"; - fHM->Add(histName.Data(), new TH2I(histName, title, 33, -0.5, 32.5,6,-0.5,5.5)); - for (Int_t sType=0; sType < 6; sType++) - fHM->H1(histName.Data())->GetYaxis()->SetBinLabel(sType+1,stopTypes[sType]); - - histName = "InfoType_Message_Length_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";Message Length (Time-Bins) ;"; - fHM->Add(histName.Data(), new TH2I(histName, title, 33, -0.5, 32.5, 8, -0.5, 7.5)); - for (Int_t iType=0; iType < 8; iType++) - fHM->H1(histName.Data())->GetYaxis()->SetBinLabel(iType+1,infoTypes[iType]); - - histName = "TriggerType_Message_Length_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";Message Length (Time-Bins) ;"; - fHM->Add(histName.Data(), new TH2I(histName, title, 33, -0.5, 32.5,5,-1.5,3.5)); - for (Int_t tType=0; tType < 4; tType++) - fHM->H1(histName.Data())->GetYaxis()->SetBinLabel(tType+1,triggerTypes[tType]); - - histName = "Message_Length_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";Message Length (Time-Bins) ;Channel"; - fHM->Add(histName.Data(), new TH2I(histName, title, 33, -0.5, 32.5, 32, -0.5, 31.5)); - - histName = "TriggerTypes_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + "; ;Channel"; - fHM->Add(histName.Data(), new TH2I(histName, title, 5, -1.5, 3.5,32,-0.5,31.5)); - for (Int_t tType=0; tType < 4; tType++) - fHM->H1(histName.Data())->GetXaxis()->SetBinLabel(tType+1,triggerTypes[tType]); - - histName = "StopTypes_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + "; ;Channel"; - fHM->Add(histName.Data(), new TH2I(histName, title, 6, -0.5, 5.5,32,-0.5,31.5)); - for (Int_t sType=0; sType < 6; sType++) - fHM->H1(histName.Data())->GetXaxis()->SetBinLabel(sType+1,stopTypes[sType]); - - histName = "InfoTypes_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + "; ;Channel"; - fHM->Add(histName.Data(), new TH2I(histName, title, 8, -0.5, 7.5,32,-0.5,31.5)); - for (Int_t iType=0; iType < 8; iType++) - fHM->H1(histName.Data())->GetXaxis()->SetBinLabel(iType+1,infoTypes[iType]); - - histName = "Trigger_Stop_Types_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + "; ;"; - fHM->Add(histName.Data(), new TH2I(histName, title, 5, -1.5, 3.5, 6, -0.5, 5.5)); - for (Int_t tType=0; tType < 4; tType++) - fHM->H1(histName.Data())->GetXaxis()->SetBinLabel(tType+1,triggerTypes[tType]); - for (Int_t sType=0; sType < 6; sType++) - fHM->H1(histName.Data())->GetYaxis()->SetBinLabel(sType+1,stopTypes[sType]); - - histName = "Trigger_Info_Types_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + "; ;"; - fHM->Add(histName.Data(), new TH2I(histName, title, 5, -1.5, 3.5, 8, -0.5, 7.5)); - for (Int_t tType=0; tType < 4; tType++) - fHM->H1(histName.Data())->GetXaxis()->SetBinLabel(tType+1,triggerTypes[tType]); - for (Int_t iType=0; iType < 8; iType++) - fHM->H1(histName.Data())->GetYaxis()->SetBinLabel(iType+1,infoTypes[iType]); - - - histName = "Stop_Info_Types_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + "; ;"; - fHM->Add(histName.Data(), new TH2I(histName, title, 6, -0.5, 5.5, 8, -0.5, 7.5)); - for (Int_t sType=0; sType < 6; sType++) - fHM->H1(histName.Data())->GetXaxis()->SetBinLabel(sType+1,stopTypes[sType]); - for (Int_t iType=0; iType < 8; iType++) - fHM->H1(histName.Data())->GetYaxis()->SetBinLabel(iType+1,infoTypes[iType]); - - - histName = "GroupId_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + "; ;Counts"; - fHM->Add(histName.Data(), new TH1I(histName, title, 2, -0.5, 1.5)); - - - histName = "ClusterSize_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";Cluster Size [Channel] ;Counts"; - fHM->Add(histName.Data(), new TH1I(histName, title, 10, -0.5, 9.5)); - - histName = "ClusterSize_Message_Length_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";Cluster Size [Channel] ;Message Length (Time-Bins)"; - fHM->Add(histName.Data(), new TH2I(histName, title, 10, -0.5, 9.5, 33, -0.5, 32.5)); - - - histName = "StopType_ClusterSize_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";Cluster Size [Channel] ; "; - fHM->Add(histName.Data(), new TH2I(histName, title, 10, -0.5, 9.5, 6, -0.5, 5.5)); - for (Int_t sType=0; sType < 6; sType++) - fHM->H1(histName.Data())->GetYaxis()->SetBinLabel(sType+1,stopTypes[sType]); - - histName = "TriggerType_ClusterSize_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";Cluster Size [Channel] ; "; - fHM->Add(histName.Data(), new TH2I(histName, title, 10, -0.5, 9.5, 5, -1.5, 3.5)); - for (Int_t tType=0; tType < 4; tType++) - fHM->H1(histName.Data())->GetYaxis()->SetBinLabel(tType+1,triggerTypes[tType]); - - histName = "InfoType_ClusterSize_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";Cluster Size [Channel] ; "; - fHM->Add(histName.Data(), new TH2I(histName, title, 10, -0.5, 9.5, 8, -0.5, 7.5)); - for (Int_t iType=0; iType < 8; iType++) - fHM->H1(histName.Data())->GetYaxis()->SetBinLabel(iType+1,infoTypes[iType]); - - histName = "TriggerCounterGraph_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";TimeSlice;Trigger / TimeSlice"; - fHM->Add(histName.Data(), new TGraph()); - fHM->G1(histName.Data())->SetTitle(histName.Data()); - - histName = "TriggerCounter_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";TimeSlice;Trigger / TimeSlice"; - fHM->Add(histName.Data(), new TH1I(histName, title, 1000, 0, 1000)); - - histName = "OverFlowCounterGraph_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";TimeSlice;Trigger / TimeSlice"; - fHM->Add(histName.Data(), new TGraph()); - fHM->G1(histName.Data())->SetTitle(histName.Data()); - - histName = "OverFlowCounter_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";TimeSlice;OverFlow / TimeSlice"; - fHM->Add(histName.Data(), new TH1I(histName, title, 1000, 0, 1000)); - - histName = "ErrorCounterGraph_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";TimeSlice;Trigger / TimeSlice"; - fHM->Add(histName.Data(), new TGraph()); - fHM->G1(histName.Data())->SetTitle(histName.Data()); - - histName = "ErrorCounter_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";TimeSlice;Error / TimeSlice"; - fHM->Add(histName.Data(), new TH1I(histName, title, 1000, 0, 1000)); - //title = histName + ";Channel;ADC value in Bin 0"; - //fHM->Add(histName.Data(), new TH1I(histName, title, 32, -0.5, 31.5)); - - histName = "BaseLine_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";Channel;ADC value"; - fHM->Add(histName.Data(), new TH2F(histName, title, 32, -0.5, 31.5, 511, -256, 255)); - - histName = "Integrated_ADC_Spectrum_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";Channel;Integr. ADC values in Bin [0,31]"; - fHM->Add(histName.Data(), new TH2F(histName, title, 32, -0.5, 31.5, 2*33*256, -33*256, 33*256)); - - histName = "Trigger_Heatmap_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";Column;Row"; - fHM->Add(histName.Data(), new TH2I(histName, title, 16, -0.5, 15.5, 2, -0.5, 1.5)); - /* - histName = "maxADC_TimeBinCorr_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + "max ADC value; value in time bin"; - fHM->Add(histName.Data(), new TH2I(histName, title, 511, -256, 255, 511, -256, 255)); - */ - - for(Int_t channel = 0; channel < 32; channel++) { - histName = "Noise1_" + syscoreName[syscore] + "_" + spadicName[spadic] + "_Ch" + channelName[channel]; - title = histName + ";ADC value;Count"; - fHM->Add(histName.Data(), new TH1F(histName, title, 511, -256, 255)); - } - - for(Int_t channel = 0; channel < 32; channel++) { - histName = "Signal_Shape_" + syscoreName[syscore] + "_" + spadicName[spadic] + "_Ch" + channelName[channel]; - title = histName + ";Time Bin;ADC value"; - fHM->Add(histName.Data(), new TH2I(histName, title, 32, -0.5, 31.5, 767, -256, 511)); - } - for(Int_t channel = 0; channel < 32; channel++) { - histName = "Pulse_" + syscoreName[syscore] + "_" + spadicName[spadic] + "_Ch" + channelName[channel]; - title = histName + ";Time Bin;ADC value"; - fHM->Add(histName.Data(), new TH2I(histName, title, 32, -0.5, 31.5, 767, -256, 511)); - } - for(Int_t channel = 0; channel < 32; channel++) { - histName = "maxTimeBin_" + syscoreName[syscore] + "_" + spadicName[spadic] + "_Ch" + channelName[channel]; - title = histName + ";max Time Bin;count"; - fHM->Add(histName.Data(), new TH1I(histName, title, 32, -0.5, 31.5)); - } - for(Int_t channel = 0; channel < 32; channel++) { - histName = "maxADC_" + syscoreName[syscore] + "_" + spadicName[spadic] + "_Ch" + channelName[channel]; - title = histName + ";max ADC value;count"; - fHM->Add(histName.Data(), new TH1I(histName, title, 511, -256, 255)); - } - for(Int_t channel = 0; channel < 32; channel++) { - histName = "maxADC_maxTimeBin_" + syscoreName[syscore] + "_" + spadicName[spadic] + "_Ch" + channelName[channel]; - title = histName + ";max Time Bin;max ADC value"; - fHM->Add(histName.Data(), new TH2I(histName, title, 32, -0.5, 31.5, 511, -256, 255)); - } - - //for(Int_t channel = 0; channel < 32; channel++) { - for(Int_t bin = 0; bin < 32; bin++) { - histName = "maxADC_TimeBinCorr_" + syscoreName[syscore] + "_" + spadicName[spadic] + "_TB" + timebinName[bin]; - title = histName + "max ADC value; value in time bin"; - fHM->Add(histName.Data(), new TH2I(histName, title, 511, -256, 255, 511, -256, 255)); - } - // } - - } - } - } - ClassImp(CbmTrdRawBeamProfile) diff --git a/beamtime/cern2014/tasks/CbmTrdRawBeamProfile.h b/beamtime/cern2014/tasks/CbmTrdRawBeamProfile.h deleted file mode 100644 index 7699b3abca3662147148f3d0ba2b131db00059db..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/tasks/CbmTrdRawBeamProfile.h +++ /dev/null @@ -1,109 +0,0 @@ -#ifndef CBMTRDRAWBEAMPROFILE_H -#define CBMTRDRAWBEAMPROFILE_H - -#include "FairTask.h" -#include "CbmHistManager.h" -#include "CbmSpadicRawMessage.h" -#include "CbmTrbRawMessage.h" -#include "TClonesArray.h" - -class CbmTrdRawBeamProfile : public FairTask -{ - public: - - /** Default constructor **/ - CbmTrdRawBeamProfile(); - - /** Constructor with parameters (Optional) **/ - // CbmTrdRawBeamProfile(Int_t verbose); - - - /** Destructor **/ - ~CbmTrdRawBeamProfile(); - - - /** Initiliazation of task at the beginning of a run **/ - virtual InitStatus Init(); - - /** ReInitiliazation of task when the runID changes **/ - virtual InitStatus ReInit(); - - - /** Executed for each event. **/ - virtual void Exec(Option_t* opt); - - /** Load the parameter container from the runtime database **/ - virtual void SetParContainers(); - - /** Finish task called at the end of the run **/ - virtual void Finish(); - virtual Int_t GetSysCoreID(CbmSpadicRawMessage* raw); - virtual Int_t GetSpadicID(CbmSpadicRawMessage* raw); - virtual Int_t GetModuleID(CbmSpadicRawMessage* raw); - virtual Int_t GetLayerID(CbmSpadicRawMessage* raw); - virtual Int_t GetSectorID(CbmSpadicRawMessage* raw); - virtual Int_t GetRowID(CbmSpadicRawMessage* raw); - virtual Int_t GetColumnID(CbmSpadicRawMessage* raw); - virtual Int_t GetCombiID(CbmSpadicRawMessage* raw); - virtual Int_t GetChannelOnPadPlane(Int_t SpadicChannel); - virtual Bool_t FragmentedPulseTest(CbmSpadicRawMessage* raw); - virtual Int_t GetMaximumAdc(CbmSpadicRawMessage* raw); - - private: - - /** Input array from previous already existing data level **/ - TClonesArray* fRawSpadic; - TClonesArray* fNxyterRaw; - TClonesArray* fTrbRaw; - /** Output array **/ - TClonesArray* fDigis; //! TRD digis - TClonesArray* fClusters; - Int_t fiDigi; - Int_t fiCluster; - CbmHistManager* fHM; - Int_t fmaxTimeGlobal; - Int_t fmaxTimeGroup[3][6]; - ULong_t fmaxFullTimeGlobal; - ULong_t fmaxFullTimeGroup[3][6]; - ULong_t flastDlmTriggerTime[3][6][15]; - Int_t fEpoch; - Int_t flastEpoch; - Int_t fSuperEpoch; - Int_t flastSuperEpoch; - Int_t fSpadicMessageCounter; - Int_t fNxyterMessageCounter; - Int_t fTrbMessageCounter; - Int_t fContainerCounter; - Int_t fInfoCounter; - Int_t fHitCounter; - Int_t fMultiHitCounter; - Int_t fErrorCounter; - Int_t fLostHitCounter; - Int_t fDoubleCounter; - Int_t fFragmentedCounter; - std::map<Int_t, std::map<Int_t, std::map<Int_t, CbmSpadicRawMessage*> > > fSys0Spa0Buffer;//<SuperEpoch <Epoch <Time, SpadicMessage> > > > - std::map<Int_t, std::map<Int_t, std::map<Int_t, CbmSpadicRawMessage*> > > fSys0Spa1Buffer;//<SuperEpoch <Epoch <Time, SpadicMessage> > > > - std::map<TString, std::map<Int_t, std::map<Int_t, CbmSpadicRawMessage*> > > fTimeBuffer;//<ASIC ID "Syscore%d_Spadic%d" <Time, <CombiId, SpadicMessage> > > > - std::map<TString, std::map<ULong_t, std::map<Int_t, CbmSpadicRawMessage*> > > fFullTimeBuffer;// <ASIC ID "Syscore%d_Spadic%d"<Time, <CombiId, SpadicMessage> > > - std::map<TString, std::map<ULong_t, std::multimap<Int_t, CbmSpadicRawMessage*> > > fFullTimeBufferAll;// <ASIC ID "Syscore%d_Spadic%d"<Time, <CombiId, SpadicMessage> > > - //std::map<Int_t, - std::map<Int_t, std::map<Int_t, std::map<Int_t, std::map<Int_t, CbmTrbRawMessage*> > > > fTrbBuffer;// sourceA < epoch < chId < Coarse, TrbMessage > > > > > - //std::map<Int_t, CbmTrbRawMessage*> fTrbBuffer; - /** Output array to new data level**/ - // TClonesArray* <OutputDataLevel>; - - void CleanUpBuffers(); - - void CreateHistograms(); - - void Clusterizer(); - - void TimeClustering2015CernSPS(); - - CbmTrdRawBeamProfile(const CbmTrdRawBeamProfile&); - CbmTrdRawBeamProfile operator=(const CbmTrdRawBeamProfile&); - - ClassDef(CbmTrdRawBeamProfile,2); -}; - -#endif diff --git a/beamtime/cern2014/tasks/CbmTrdRawBuchData.cxx b/beamtime/cern2014/tasks/CbmTrdRawBuchData.cxx deleted file mode 100644 index 810b84f142f5bda7897c95555e63019966308e53..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/tasks/CbmTrdRawBuchData.cxx +++ /dev/null @@ -1,1727 +0,0 @@ -// specialized for Bucharest Data martin.kohn@cern.ch -#include "CbmTrdRawBuchData.h" - -#include "CbmSpadicRawMessage.h" -#include "CbmNxyterRawMessage.h" -#include "CbmTrbRawMessage.h" -#include "CbmTrdDigi.h" -#include "CbmTrdCluster.h" -#include "CbmHistManager.h" -#include "CbmBeamDefaults.h" -#include "CbmTrdAddress.h" -#include "CbmTrdDaqBuffer.h" - -#include "FairLogger.h" - -#include "TH1.h" -#include "TH2.h" -#include "TGraph.h" -#include "TCanvas.h" -#include "TString.h" -#include "TStyle.h" - -#include <cmath> -#include <map> -//#include <multimap> -#include <vector> -#include <iostream> - -using std::cout; -using std::endl; - -// ---- Default constructor ------------------------------------------- -CbmTrdRawBuchData::CbmTrdRawBuchData() - : FairTask("CbmTrdRawBuchData"), - fRawSpadic(NULL), - fNxyterRaw(NULL), - fTrbRaw(NULL), - fDigis(NULL), - fClusters(NULL), - fiDigi(0), - fiCluster(0), - fHM(new CbmHistManager()), - fmaxTimeGlobal(0), - fmaxTimeGroup(), - fmaxFullTimeGlobal(0), - fmaxFullTimeGroup(), - flastDlmTriggerTime(), - fEpoch(-1), - flastEpoch(-1), - fSuperEpoch(-1), - flastSuperEpoch(-1), - fSpadicMessageCounter(0), - fNxyterMessageCounter(0), - fTrbMessageCounter(0), - fContainerCounter(0), - fInfoCounter(0), - fHitCounter(0), - fMultiHitCounter(0), - fErrorCounter(0), - fLostHitCounter(0), - fDoubleCounter(0), - fFragmentedCounter(0), - fSys0Spa0Buffer(), - fSys0Spa1Buffer(), - fTimeBuffer(), - fFullTimeBuffer(), - fFullTimeBufferAll(), - fTrbBuffer() -{ - LOG(debug) << "Default Constructor of CbmTrdRawBuchData"; -} - -// ---- Destructor ---------------------------------------------------- -CbmTrdRawBuchData::~CbmTrdRawBuchData() -{ - fDigis->Delete(); - delete fDigis; - fClusters->Delete(); - delete fClusters; - - for (std::map<TString, std::map<Int_t, std::map<Int_t, CbmSpadicRawMessage*> > >::iterator SpaSysIt = fTimeBuffer.begin(); SpaSysIt != fTimeBuffer.end(); SpaSysIt++){ - for (std::map<Int_t, std::map<Int_t, CbmSpadicRawMessage*> >::iterator TimeIt = SpaSysIt->second.begin(); TimeIt != SpaSysIt->second.end(); TimeIt++){ - for (std::map<Int_t, CbmSpadicRawMessage*> ::iterator CombiIt = TimeIt->second.begin(); CombiIt != TimeIt->second.end(); CombiIt++){ - if(CombiIt->second != NULL) - delete CombiIt->second; - } - TimeIt->second.clear(); - } - SpaSysIt->second.clear(); - } - fTimeBuffer.clear(); - - for (std::map<TString, std::map<ULong_t, std::map<Int_t, CbmSpadicRawMessage*> > >::iterator SpaSysIt = fFullTimeBuffer.begin() ; SpaSysIt != fFullTimeBuffer.end(); SpaSysIt++){ - for (std::map<ULong_t, std::map<Int_t, CbmSpadicRawMessage*> > ::iterator timeIt = SpaSysIt->second.begin() ; timeIt != SpaSysIt->second.end(); timeIt++){ - for (std::map<Int_t, CbmSpadicRawMessage*> ::iterator combiIt = timeIt->second.begin(); combiIt != timeIt->second.end(); combiIt++){ - if(combiIt->second != NULL) - delete combiIt->second; - } - timeIt->second.clear(); - } - SpaSysIt->second.clear(); - } - fFullTimeBuffer.clear(); - for (std::map<TString, std::map<ULong_t, std::multimap<Int_t, CbmSpadicRawMessage*> > >::iterator SpaSysIt = fFullTimeBufferAll.begin() ; SpaSysIt != fFullTimeBufferAll.end(); SpaSysIt++){ - for (std::map<ULong_t, std::multimap<Int_t, CbmSpadicRawMessage*> > ::iterator timeIt = SpaSysIt->second.begin() ; timeIt != SpaSysIt->second.end(); timeIt++){ - for (std::multimap<Int_t, CbmSpadicRawMessage*> ::iterator combiIt = timeIt->second.begin(); combiIt != timeIt->second.end(); combiIt++){ - if(combiIt->second != NULL) - delete combiIt->second; - } - timeIt->second.clear(); - } - SpaSysIt->second.clear(); - } - fFullTimeBufferAll.clear(); - for (std::map<Int_t, std::map<Int_t, std::map<Int_t, std::map<Int_t, CbmTrbRawMessage*> > > >::iterator SourceAIt = fTrbBuffer.begin() ; SourceAIt != fTrbBuffer.end(); SourceAIt++){ - for (std::map<Int_t, std::map<Int_t, std::map<Int_t, CbmTrbRawMessage*> > >::iterator epochIt = SourceAIt->second.begin() ; epochIt != SourceAIt->second.end(); epochIt++){ - for (std::map<Int_t, std::map<Int_t, CbmTrbRawMessage*> > ::iterator chIdIt = epochIt->second.begin() ; chIdIt != epochIt->second.end(); chIdIt++){ - for (std::map<Int_t, CbmTrbRawMessage*> ::iterator timeIt = chIdIt->second.begin(); timeIt != chIdIt->second.end(); timeIt++){ - if(timeIt->second != NULL) - delete timeIt->second; - } - chIdIt->second.clear(); - } - epochIt->second.clear(); - } - SourceAIt->second.clear(); - } - fTrbBuffer.clear(); - //fTrbBuffer has to be cleaned here!!!!! - LOG(debug) << "Destructor of CbmTrdRawBuchData"; -} - - // ---- Initialisation ---------------------------------------------- - void CbmTrdRawBuchData::SetParContainers() - { - LOG(debug) << "SetParContainers of CbmTrdRawBuchData"; - // Load all necessary parameter containers from the runtime data base - /* - FairRunAna* ana = FairRunAna::Instance(); - FairRuntimeDb* rtdb=ana->GetRuntimeDb(); - - <CbmTrdRawBuchDataDataMember> = (<ClassPointer>*) - (rtdb->getContainer("<ContainerName>")); - */ - } - - // ---- Init ---------------------------------------------------------- - InitStatus CbmTrdRawBuchData::Init() - { - LOG(debug) << "Initilization of CbmTrdRawBuchData"; - - // Get a handle from the IO manager - FairRootManager* ioman = FairRootManager::Instance(); - - // Get a pointer to the previous already existing data level - fRawSpadic = static_cast<TClonesArray*>(ioman->GetObject("SpadicRawMessage")); - if ( ! fRawSpadic ) { - LOG(fatal) << "No InputDataLevelName SpadicRawMessage array!\n CbmTrdRawBuchData will be inactive"; - return kERROR; - } - fNxyterRaw = static_cast<TClonesArray*>(ioman->GetObject("NxyterRawMessage")); - if ( ! fNxyterRaw ) { - LOG(error) << "No InputDataLevelName CbmNxyterRawMessage array!\n Nxyter data within CbmTrdRawBuchData will be inactive"; - //return kERROR; - } - fTrbRaw = static_cast<TClonesArray*>(ioman->GetObject("TrbRawMessage")); - if ( ! fTrbRaw ) { - LOG(error) << "No InputDataLevelName CbmTrbRawMessage array!\n TRB data within CbmTrdRawBuchData will be inactive"; - //return kERROR; - } - - - fDigis = new TClonesArray("CbmTrdDigi", 100); - ioman->Register("TrdDigi", "TRD Digis", fDigis, IsOutputBranchPersistent("TrdDigi")); - - fClusters = new TClonesArray("CbmTrdCluster",100); - ioman->Register("TrdCluster", "TRD Clusters", fClusters, IsOutputBranchPersistent("TrdCluster")); - - // Do whatever else is needed at the initilization stage - // Create histograms to be filled - // initialize variables - CbmTrdRawBuchData::CreateHistograms(); - - return kSUCCESS; - - } - - // ---- ReInit ------------------------------------------------------- - InitStatus CbmTrdRawBuchData::ReInit() - { - LOG(debug) << "Initilization of CbmTrdRawBuchData"; - return kSUCCESS; - } - - // ---- Exec ---------------------------------------------------------- -void CbmTrdRawBuchData::Exec(Option_t*) -{ - TString errorMessage, infoMessage, debugMessage; - const Int_t maxNrColumns = 16; - /* - This function is reinitialized for each new TimeSliceContainer - */ - fContainerCounter++; - /* - Int_t channelMapping[32] = {31,15,30,14,29,13,28,12,27,11,26,10,25, 9,24, 8, - 23, 7,22, 6,21, 5,20, 4,19, 3,18, 2,17, 1,16, 0}; - */ - TString timebinName[32] = { "00", "01", "02", "03", "04", "05", "06", "07", "08", "09", - "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", - "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", - "30", "31"}; - - //std::map<TString, std::map<ULong_t, std::map<Int_t, CbmSpadicRawMessage*> > > timeBuffer;// <ASIC ID "Syscore%d_Spadic%d"<Time, <CombiId, SpadicMessage> > - - - Int_t entriesInTrbMessage = fTrbRaw->GetEntriesFast(); - Int_t lastGlobalEpoch(0); - Int_t lastEpoch[4][16] = {{0}}; - Int_t lastTdcCoarse[4][16] = {{0}}; - for (Int_t i=0; i < entriesInTrbMessage; ++i) { - fTrbMessageCounter++; - CbmTrbRawMessage* raw = /*static_cast<*/(CbmTrbRawMessage*)/*>*/(fTrbRaw->At(i)); - Int_t eqID = raw->GetEquipmentID(); - Int_t sourceA = raw->GetSourceAddress(); - if (sourceA == 272) continue; //RICH - //printf("EI%i SA%i ->",eqID,sourceA); - Int_t chID = raw->GetChannelID(); - if (chID == 0) continue;// seems to be not connected - Int_t epoch = raw->GetEpochMarker(); - Int_t tdcFine = raw->GetTDCfine(); - Int_t tdcCoarse = raw->GetTDCcoarse(); - Int_t edge = raw->GetEdge(); - // ULong_t fullTime = raw->GetFullTime(); - - //LOG(info) << "TrbMessage: " << fTrbMessageCounter << " EqId:" << eqID << " sourceA:" << sourceA << " ChID:" << chID << " Epoch:" << epoch << " tdcFine:" << tdcFine << " tdcCoarse:" << tdcCoarse << " edge:" << edge; - - std::map<Int_t, CbmTrbRawMessage*>::iterator timeBufferIt = fTrbBuffer[sourceA][epoch][chID].find(tdcCoarse); - if (timeBufferIt == fTrbBuffer[sourceA][epoch][chID].end()){ - fTrbBuffer[sourceA][epoch][chID][tdcCoarse] = new CbmTrbRawMessage(eqID, sourceA, chID, epoch, tdcCoarse, tdcFine, (Bool_t)edge); - } else { - LOG(error) << "Message already in buffer <<<<<<< TrbMessage: EqId:" << eqID << " sourceA:" << sourceA << " ChID:" << chID << " tdcFine:" << tdcFine << " tdcCoarse:" << tdcCoarse << " edge:" << edge; - } - if (i > 0){ - if (epoch - lastGlobalEpoch < 0) - LOG(error) << "-------------------->GlobalEpoch:" << epoch << " LastGlobalEpoch:"<< lastGlobalEpoch; - if (epoch - lastEpoch[sourceA-272][chID] < 0){ - // ERROR - LOG(error) << ":::::::::::::::::::::::::::Epoch:" << epoch << " LastEpoch:"<< lastEpoch[sourceA-272][chID]; - } else if (epoch - lastEpoch[sourceA-272][chID] == 0) { - - if (tdcCoarse - lastTdcCoarse[sourceA-272][chID] < 0) { - // ERROR - LOG(error) << "======================Coarse:" << tdcCoarse << " LastCoarse:"<< lastTdcCoarse[sourceA-272][chID]; - } else { - } - } else { - //next epoch - } - } - lastGlobalEpoch = epoch; - lastEpoch[sourceA-272][chID] = epoch; - lastTdcCoarse[sourceA-272][chID] = tdcCoarse; - } - - - Int_t entriesInNxyterMessage = fNxyterRaw->GetEntriesFast(); - for (Int_t i=0; i < entriesInNxyterMessage; ++i) { - fNxyterMessageCounter++; - CbmNxyterRawMessage* raw = /*static_cast<*/(CbmNxyterRawMessage*)/*>*/(fNxyterRaw->At(i)); - Int_t eqID = raw->GetEquipmentID(); - Int_t sourceA = raw->GetSourceAddress(); - //printf("EI%i SA%i ->",eqID,sourceA); - Int_t chID = raw->GetChannelID(); - // Int_t AdcValue = raw->GetADCvalue(); - // ULong_t fullTime = raw->GetFullTime(); - LOG(info) << "NxyterMessage: EqId:" << eqID << " sourceA:" << sourceA << " ChID:" << chID; - } - - Int_t entriesInMessage = fRawSpadic->GetEntriesFast(); - Int_t entries = fDigis->GetEntriesFast(); - Int_t sumTrigger[3][6] = {{0}}; - Int_t sumError[3][6] = {{0}}; - Int_t sumOverflow[3][6] = {{0}}; - - LOG(debug) << "Container: " << fContainerCounter; - LOG(debug) << "SPADIC Entries in Message: " << entriesInMessage; - LOG(debug) << "Nxyter Entries in Message: " << entriesInNxyterMessage; - LOG(debug) << "Entries in total: " << fSpadicMessageCounter; - LOG(debug) << "Digis in TClonesArray: " << fDigis->GetEntriesFast(); - LOG(debug) << "Clusters in TClonesArray: " << fClusters->GetEntriesFast(); - // Find info about hitType, stopType and infoType in cbmroot/fles/spadic/message/constants/.. - /* - TString triggerTypes[5] = {"infoMessage", - "Global trigger", - "Self triggered", - "Neighbor triggered", - "Self and neighbor triggered"}; - TString stopTypes[6] = {"Normal end of message", - "Channel buffer full", - "Ordering FIFO full", - "Multi hit", - "Multi hit and channel buffer full", - "Multi hit and ordering FIFO full"}; - TString infoTypes[8] = {"Channel disabled during message building", - "Next grant timeout", - "Next request timeout", - "New grant but channel empty", - "Corruption in message builder", - "Empty word", - "Epoch out of sync", - "infoType out of array"}; - */ - //if (entriesInMessage > 1) entriesInMessage = 1; // for fast data visualization - ULong_t lastSpadicTime[3][6] = {{0}}; //[sys][spa] - ULong_t lastSpadicTimeCh[3][6][32] = {{{0}}}; //[sys][spa][ch] - Int_t lastTriggerType[32] = {-1}; - Int_t clusterSize[3][6] = {{1}}; - Int_t rowId(0), columnId(0), combiId(0); - Int_t wrongTimeOrder[3][6] = {{0}}; - Bool_t isHit(false), isInfo(false); - for (Int_t i=0; i < entriesInMessage; ++i) { - fSpadicMessageCounter++; - CbmSpadicRawMessage* raw = (CbmSpadicRawMessage*)(fRawSpadic->At(i)); - /* - if ((raw->GetSuperEpoch() != fSuperEpoch)){// || (raw->GetEpochMarker() != fEpoch)){ - Clusterizer(); - TimeClustering2015CernSPS(); - } - */ - fEpoch = raw->GetEpochMarker(); - fSuperEpoch = raw->GetSuperEpoch(); - if (fEpoch == 0 || fSuperEpoch == 0) continue; - Int_t eqID = raw->GetEquipmentID(); - Int_t sourceA = raw->GetSourceAddress(); - //printf("EI%i SA%i ->",eqID,sourceA); - Int_t chID = raw->GetChannelID(); - Int_t SysId(-1), SpaId(-1); - Int_t nrSamples=raw->GetNrSamples(); - Int_t triggerType=raw->GetTriggerType(); - Int_t stopType=raw->GetStopType(); - Int_t infoType=raw->GetInfoType(); - Int_t bufferOverflowCount = raw->GetBufferOverflowCount(); - fLostHitCounter += bufferOverflowCount; - if (triggerType == -1 && stopType == -1){ - isHit = false; - isInfo = true; - fInfoCounter++; - } else { - isHit = true; - isInfo = false; - if (stopType == 3) - fMultiHitCounter++; - else if (stopType == 0) - fHitCounter++; - else - fErrorCounter++; - } - - if (stopType != 0 && stopType != 3) - if (infoType > 6) { - errorMessage.Form("SuperEpoch %5i Epoche %5i Container:%5i Message:%5i eqID:%i sourceA:%i chID:%02i StopType: %i TriggerType: %i InfoType%i out of range",fSuperEpoch,fEpoch,fContainerCounter,fSpadicMessageCounter,eqID,sourceA,chID,stopType,triggerType,infoType); - LOG(error) << errorMessage; - infoType = 7; - } - Int_t groupId=raw->GetGroupId(); - ULong_t fullTime = raw->GetFullTime(); - Int_t time = raw->GetTime(); - TString syscore=""; - switch (eqID) { - case kFlesMuenster: // Muenster - syscore="SysCore0_"; - SysId = 0; - break; - case kFlesFrankfurt: // Frankfurt - syscore="SysCore1_"; - SysId = 1; - break; - case kFlesBucarest: // Bucarest - syscore="SysCore2_"; - SysId = 2; - break; - default: - LOG(error) << "Container " << fContainerCounter << " Message " << fSpadicMessageCounter << " EquipmentID " << eqID << "not known."; - break; - } - - TString spadic=""; - switch (sourceA) { - case (SpadicBaseAddress+0): // first spadic - spadic="Spadic0"; - SpaId = 0; - break; - case (SpadicBaseAddress+1): // first spadic - spadic="Spadic0"; - SpaId = 1; - chID += 16; - break; - case (SpadicBaseAddress+2): // second spadic - spadic="Spadic1"; - SpaId = 2; - break; - case (SpadicBaseAddress+3): // second spadic - spadic="Spadic1"; - SpaId = 3; - chID += 16; - break; - case (SpadicBaseAddress+4): // third spadic - spadic="Spadic2"; - SpaId = 4; - break; - case (SpadicBaseAddress+5): // third spadic - spadic="Spadic2"; - SpaId = 5; - chID += 16; - break; - default: - LOG(error) << "Container " << fContainerCounter << " Message " << fSpadicMessageCounter << " Source Address " << sourceA << "not known."; - break; - } - /* - if(chID % 2 == 0) - rowId = 0; - else - rowId = 1; - //printf("EI%i SA%i ->|\n",eqID,sourceA); - */ - chID = GetChannelOnPadPlane(chID);//channelMapping[chID];// Remapping from ASIC to pad-plane - /* - // Compare to channel mapping from pad-plane to ASIC - columnId = chID; - if (columnId > 16) - columnId -= 16; - */ - columnId = GetColumnID(raw); - rowId = GetRowID(raw); - combiId = rowId * (maxNrColumns + 1) + columnId; - if (isHit){ - infoMessage.Form("SuperEpoch %5i Epoche %5i FullTime %12lu eqID:%i sourceA:%i chID:%02i StopType: %i TriggerType: %i InfoType: %i", - fSuperEpoch,fEpoch,fullTime,eqID,sourceA,chID,stopType,triggerType,infoType); - LOG(debug) << infoMessage; - if (flastEpoch == fEpoch && flastSuperEpoch == fSuperEpoch){ - infoMessage.Form("SuperEpoch %5i Epoche %5i FullTime %12lu eqID:%i sourceA:%i chID:%02i StopType: %i TriggerType: %i InfoType: %i still in same (Super)Epoch", - fSuperEpoch,fEpoch,fullTime,eqID,sourceA,chID,stopType,triggerType,infoType); - LOG(debug) << infoMessage; - if (fullTime > fmaxFullTimeGlobal){ - infoMessage.Form("SuperEpoch %5i Epoche %5i FullTime %12lu eqID:%i sourceA:%i chID:%02i StopType: %i TriggerType: %i InfoType: %i maxFullTimeGlobal: %12lu", - fSuperEpoch,fEpoch,fullTime,eqID,sourceA,chID,stopType,triggerType,infoType,fmaxFullTimeGlobal); - LOG(debug) << infoMessage; - fmaxFullTimeGlobal = fullTime; - } - if (fullTime < fmaxFullTimeGlobal) { - infoMessage.Form("SuperEpoch %5i Epoche %5i FullTime %12lu eqID:%i sourceA:%i chID:%02i StopType: %i TriggerType: %i InfoType: %i maxFullTimeGlobal: %12lu time jump #Delta t: %9i", - fSuperEpoch,fEpoch,fullTime,eqID,sourceA,chID,stopType,triggerType,infoType,fmaxFullTimeGlobal,Int_t(fullTime-fmaxFullTimeGlobal)); - LOG(debug) << infoMessage; - //wrongTimeOrder[SysId][SpaId]++; - //continue; - } - if (fullTime > fmaxFullTimeGroup[SysId][SpaId]){ - infoMessage.Form("SuperEpoch %5i Epoche %5i Time %9i FullTime %12lu eqID:%i sourceA:%i chID:%02i StopType: %i TriggerType: %i InfoType: %i maxFullTimeGroup: %12lu", - fSuperEpoch,fEpoch,raw->GetTime(),fullTime,eqID,sourceA,chID,stopType,triggerType,infoType,fmaxFullTimeGroup[SysId][SpaId]); - LOG(debug) << infoMessage; - fmaxFullTimeGroup[SysId][SpaId] = fullTime; - } - if (fullTime < fmaxFullTimeGroup[SysId][SpaId]) { - infoMessage.Form("SuperEpoch %5i Epoche %5i Time %9i FullTime %12lu eqID:%i sourceA:%i chID:%02i StopType: %i TriggerType: %i InfoType: %i maxFullTimeGroup: %12lu time jump #Delta t: %9i", - fSuperEpoch,fEpoch,raw->GetTime(),fullTime,eqID,sourceA,chID,stopType,triggerType,infoType,fmaxFullTimeGroup[SysId][SpaId],Int_t(fullTime-fmaxFullTimeGroup[SysId][SpaId])); - //LOG(error) << infoMessage; - //wrongTimeOrder[SysId][SpaId]++; - //continue; - } - if (time > fmaxTimeGlobal){ - infoMessage.Form("SuperEpoch %5i Epoche %5i Time %9i eqID:%i sourceA:%i chID:%02i StopType: %i TriggerType: %i InfoType: %i maxTimeGlobal: %9i", - fSuperEpoch,fEpoch,time,eqID,sourceA,chID,stopType,triggerType,infoType,fmaxTimeGlobal); - LOG(debug) << infoMessage; - fmaxTimeGlobal = time; - } - } else { - infoMessage.Form("SuperEpoch %5i Epoche %5i FullTime %12lu eqID:%i sourceA:%i chID:%02i StopType: %i TriggerType: %i InfoType: %i new (Super)Epoch", - fSuperEpoch,fEpoch,fullTime,eqID,sourceA,chID,stopType,triggerType,infoType); - LOG(debug) << infoMessage; - //fmaxFullTimeGlobal = fullTime; - if (fEpoch != flastEpoch || fSuperEpoch > flastSuperEpoch) { - fmaxTimeGlobal = time; - for (Int_t iSys = 0; iSys < 3; iSys++) - for (Int_t iSpa = 0; iSpa < 6; iSpa++) - fmaxTimeGroup[iSys][iSpa] = 0; - fmaxTimeGroup[SysId][SpaId] = time; - } - if (time < fmaxTimeGlobal) { - infoMessage.Form("SuperEpoch %5i Epoche %5i Time %9i eqID:%i sourceA:%i chID:%02i StopType: %i TriggerType: %i InfoType: %i maxTimeGlobal: %9i time jump #Delta t: %9i", - fSuperEpoch,fEpoch,time,eqID,sourceA,chID,stopType,triggerType,infoType,fmaxTimeGlobal,Int_t(time-fmaxTimeGlobal)); - LOG(info) << infoMessage; - //wrongTimeOrder[SysId][SpaId]++; - //continue; - } - if (time > fmaxTimeGroup[SysId][SpaId]){ - infoMessage.Form("SuperEpoch %5i Epoche %5i Time %9i eqID:%i sourceA:%i chID:%02i StopType: %i TriggerType: %i InfoType: %i maxTimeGroup: %9i", - fSuperEpoch,fEpoch,time,eqID,sourceA,chID,stopType,triggerType,infoType,fmaxTimeGroup[SysId][SpaId]); - LOG(debug) << infoMessage; - fmaxTimeGroup[SysId][SpaId] = time; - } - if (time < fmaxTimeGroup[SysId][SpaId]) { - infoMessage.Form("SuperEpoch %5i Epoche %5i Time %9i eqID:%i sourceA:%i chID:%02i StopType: %i TriggerType: %i InfoType: %i maxTimeGroup: %9i time jump #Delta t: %9i", - fSuperEpoch,fEpoch,time,eqID,sourceA,chID,stopType,triggerType,infoType,fmaxTimeGroup[SysId][SpaId],Int_t(time-fmaxTimeGroup[SysId][SpaId])); - LOG(error) << infoMessage; - wrongTimeOrder[SysId][SpaId]++; - continue; - } - } - - - } - if (triggerType == 0){ - flastDlmTriggerTime[SysId][SpaId][raw->GetChannelID()] = fullTime; - infoMessage.Form("SuperEpoch %5i Epoche %5i FullTime %12lu eqID:%i sourceA:%i StopType: %i TriggerType: %i InfoType: %i new (Super)Epoch", - fSuperEpoch,fEpoch,fullTime,eqID,sourceA,stopType,triggerType,infoType); - LOG(info) << infoMessage; - for (Int_t iSys = 0; iSys < 1; iSys++){ - for (Int_t iSpa = 0; iSpa < 2; iSpa++){ - infoMessage.Form("SysID%02i SpaID%02i",iSys,iSpa); - LOG(info) << infoMessage; - //for (Int_t iCh = 0; iCh < 15; iCh++){ - infoMessage.Form("%12lu | %12lu | %12lu | %12lu | %12lu | %12lu | %12lu | %12lu | %12lu | %12lu | %12lu | %12lu | %12lu | %12lu | %12lu ", - flastDlmTriggerTime[iSys][iSpa][ 0],flastDlmTriggerTime[iSys][iSpa][ 1],flastDlmTriggerTime[iSys][iSpa][ 2],flastDlmTriggerTime[iSys][iSpa][ 3], - flastDlmTriggerTime[iSys][iSpa][ 4],flastDlmTriggerTime[iSys][iSpa][ 5],flastDlmTriggerTime[iSys][iSpa][ 6],flastDlmTriggerTime[iSys][iSpa][ 7], - flastDlmTriggerTime[iSys][iSpa][ 8],flastDlmTriggerTime[iSys][iSpa][ 9],flastDlmTriggerTime[iSys][iSpa][10],flastDlmTriggerTime[iSys][iSpa][11], - flastDlmTriggerTime[iSys][iSpa][12],flastDlmTriggerTime[iSys][iSpa][13],flastDlmTriggerTime[iSys][iSpa][14] - ); - LOG(info) << infoMessage; - // } - } - } - cout << "----------------------------------------------------------------------------------------------------------------------------------------------------------------" << endl; - } - - //if (stopType == 0 && triggerType > 0){ - if (fullTime > lastSpadicTime[SysId][SpaId]){ - // ok, next hit - - clusterSize[SysId][SpaId] = 1; - } else if (fullTime == lastSpadicTime[SysId][SpaId]) { // Clusterizer - // possible FNR trigger - if (stopType == 0){ // normal ending - //clusterSize = 1; - if (triggerType == 0) { // gobal dlm trigger - - } else if (triggerType == 1) { //Self triggered - // central pad candidate - clusterSize[SysId][SpaId]+=1; - } else if (triggerType == 2) { //Neighbor triggered - // outer pad candidate - clusterSize[SysId][SpaId]+=1; - } else { //Self and neighbor triggered - // central pad candidate - clusterSize[SysId][SpaId]+=1; - } - } else {// multihit or currupted - } - } else { - if (isHit){ - //TimeClustering2015CernSPS(); - wrongTimeOrder[SysId][SpaId]++; - continue; - errorMessage.Form("SuperEpoch %5i Epoch %5i Container:%5i Message:%5i FullTime:%15lu eqID:%i sourceA:%i (Sys%iSpa%i) ChId:%2i CombiID:%2i StopType: %i TriggerType: %i InfoType:%i message time %15lu < last message time %15lu",fSuperEpoch,fEpoch,fContainerCounter,fSpadicMessageCounter,fullTime,eqID,sourceA,SysId,SpaId,chID,combiId,stopType,triggerType,infoType,fullTime, lastSpadicTime[SysId][SpaId]); - LOG(error) << errorMessage; - } - } - if (isHit){ - if (flastEpoch > fEpoch && flastSuperEpoch > fSuperEpoch){ - errorMessage.Form("SuperEpoch %5i Epoch %5i | lastSuperEpoch %5i lastEpoch %5i",fSuperEpoch,fEpoch,flastSuperEpoch,flastEpoch); - LOG(error) << errorMessage; - } - - if (flastSuperEpoch == fSuperEpoch && flastEpoch == fEpoch){ - - std::map<Int_t, CbmSpadicRawMessage*>::iterator timeBufferIt = fTimeBuffer[TString(syscore+spadic)][time].find(combiId); - if (timeBufferIt == fTimeBuffer[TString(syscore+spadic)][time].end()){ - fTimeBuffer[TString(syscore+spadic)][time][combiId]= new CbmSpadicRawMessage((Int_t)raw->GetEquipmentID(), (Int_t)raw->GetSourceAddress(), raw->GetChannelID(), - raw->GetEpochMarker(), raw->GetTime(), raw->GetSuperEpoch(), raw->GetTriggerType(), - raw->GetInfoType(), raw->GetStopType(), raw->GetGroupId(), raw->GetBufferOverflowCount(), - raw->GetNrSamples(), raw->GetSamples()); - } else { - debugMessage.Form("SuperEpoch %5i Epoch %5i Container:%5i Message:%5i FullTime:%15lu eqID:%i sourceA:%i (Sys%iSpa%i) ChId:%2i CombiID:%2i StopType: %i TriggerType: %i allready in buffer", - fSuperEpoch,fEpoch,fContainerCounter,fSpadicMessageCounter,fullTime,eqID,sourceA,SysId,SpaId,chID,combiId,stopType,triggerType); - LOG(debug) << debugMessage; - } - } else { - TimeClustering2015CernSPS(); - } - - std::map<Int_t, CbmSpadicRawMessage*>::iterator fullTimeBufferIt = fFullTimeBuffer[TString(syscore+spadic)][fullTime].find(combiId); - if (fullTimeBufferIt == fFullTimeBuffer[TString(syscore+spadic)][fullTime].end()){ - - //if (raw->GetStopType() == 0 )//|| raw->GetStopType() == 3 ) - fFullTimeBuffer[TString(syscore+spadic)][fullTime][combiId]= new CbmSpadicRawMessage((Int_t)raw->GetEquipmentID(), (Int_t)raw->GetSourceAddress(), raw->GetChannelID(), - raw->GetEpochMarker(), raw->GetTime(), raw->GetSuperEpoch(), raw->GetTriggerType(), - raw->GetInfoType(), raw->GetStopType(), raw->GetGroupId(), raw->GetBufferOverflowCount(), raw->GetNrSamples(), raw->GetSamples()); - } else { - //fFullTimeBuffer[TString(syscore+spadic)][fullTime][-1]=raw; - debugMessage.Form("SuperEpoch %5i Epoch %5i Container:%5i Message:%5i FullTime:%15lu eqID:%i sourceA:%i (Sys%iSpa%i) ChId:%2i CombiID:%2i StopType: %i TriggerType: %i allready in fullTime buffer",fSuperEpoch,fEpoch,fContainerCounter,fSpadicMessageCounter,fullTime,eqID,sourceA,SysId,SpaId,chID,combiId,stopType,triggerType); - LOG(debug) << debugMessage; - - fDoubleCounter++; - } - //} - } else { - if (raw->GetBufferOverflowCount() > 0){ - infoMessage.Form("SuperEpoch %5i Epoch %5i Container:%5i Message:%5i FullTime:%15lu eqID:%i sourceA:%i (Sys%iSpa%i) ChId:%2i CombiID:%2i InfoType: %i Lost %3i messages",fSuperEpoch,fEpoch,fContainerCounter,fSpadicMessageCounter,fullTime,eqID,sourceA,SysId,SpaId,chID,combiId,infoType,raw->GetBufferOverflowCount()); - LOG(info) << infoMessage; - } else { - infoMessage.Form("SuperEpoch %5i Epoch %5i Container:%5i Message:%5i FullTime:%15lu eqID:%i sourceA:%i (Sys%iSpa%i) ChId:%2i CombiID:%2i InfoType: %i",fSuperEpoch,fEpoch,fContainerCounter,fSpadicMessageCounter,fullTime,eqID,sourceA,SysId,SpaId,chID,combiId,infoType); - //LOG(info) << infoMessage; - } - } - /* - if (fullTime > lastSpadicTime[SysId][SpaId]){ - // ok, next hit - - clusterSize[SysId][SpaId] = 1; - } else if (fullTime == lastSpadicTime[SysId][SpaId]) { // Clusterizer - // possible FNR trigger - if (stopType == 0){ // normal ending - //clusterSize = 1; - if (triggerType == 0) { // gobal dlm trigger - - } else if (triggerType == 1) { //Self triggered - // central pad candidate - clusterSize[SysId][SpaId]+=1; - } else if (triggerType == 2) { //Neighbor triggered - // outer pad candidate - clusterSize[SysId][SpaId]+=1; - } else { //Self and neighbor triggered - // central pad candidate - clusterSize[SysId][SpaId]+=1; - } - } else {// multihit or currupted - } - } else { - if (isHit){ - //TimeClustering2015CernSPS(); - wrongTimeOrder[SysId][SpaId]++; - //break; - errorMessage.Form("SuperEpoch %5i Epoch %5i Container:%5i Message:%5i FullTime:%15lu eqID:%i sourceA:%i (Sys%iSpa%i) ChId:%2i CombiID:%2i StopType: %i TriggerType: %i InfoType:%i message time %15lu < last message time %15lu",fSuperEpoch,fEpoch,fContainerCounter,fSpadicMessageCounter,fullTime,eqID,sourceA,SysId,SpaId,chID,combiId,stopType,triggerType,infoType,fullTime, lastSpadicTime[SysId][SpaId]); - LOG(error) << errorMessage; - } - } - */ - TString channelId; - channelId.Form("_Ch%02d", chID); - - fHM->H1(TString("Message_Length_" + syscore + spadic).Data())->Fill(nrSamples,chID); - fHM->H1(TString("StopType_Message_Length_" + syscore + spadic).Data())->Fill(nrSamples,stopType); - fHM->H1(TString("InfoType_Message_Length_" + syscore + spadic).Data())->Fill(nrSamples,infoType); - fHM->H1(TString("TriggerType_Message_Length_" + syscore + spadic).Data())->Fill(nrSamples,triggerType); - if (triggerType == -1){ - fHM->H2(TString("TriggerTypes_" + syscore + spadic).Data())->Fill(triggerType,chID,bufferOverflowCount); - } else { - fHM->H2(TString("TriggerTypes_" + syscore + spadic).Data())->Fill(triggerType,chID); - } - fHM->H2(TString("StopTypes_" + syscore + spadic).Data())->Fill(stopType,chID); - fHM->H2(TString("Trigger_Stop_Types_" + syscore + spadic).Data())->Fill(triggerType,stopType); - fHM->H2(TString("Trigger_Info_Types_" + syscore + spadic).Data())->Fill(triggerType,infoType); - fHM->H2(TString("Stop_Info_Types_" + syscore + spadic).Data())->Fill(stopType,infoType); - fHM->H2(TString("InfoTypes_" + syscore + spadic).Data())->Fill(infoType,chID); - - fHM->H1(TString("GroupId_" + syscore + spadic).Data())->Fill(groupId); - - if (stopType > 0){ //corrupt or multi message - //TString histName = "ErrorCounter_" + syscore + spadic; - //fHM->H1(histName.Data())->Fill(chID); - sumError[SysId][SpaId]++; - } else { //only normal message end - if (isHit) - sumTrigger[SysId][SpaId]++; - if (isInfo) - sumOverflow[SysId][SpaId] += bufferOverflowCount; - - if (isHit){ - TString histName = "CountRate_" + syscore + spadic; - fHM->H1(histName.Data())->Fill(chID); - - histName = "Noise1_" + syscore + spadic + channelId; - Float_t Baseline = 0; - for (Int_t bin = 1; bin < 4; bin++){ - Baseline += raw->GetSamples()[nrSamples-bin]; - fHM->H1(histName.Data())->Fill(raw->GetSamples()[nrSamples-bin]); - } - Baseline /= 3.; - - histName = "BaseLine_" + syscore + spadic; - fHM->H2(histName.Data())->Fill(chID, Baseline); - - Float_t AdcIntegral = 0; - Int_t maxADC(-300); - Int_t maxTimeBin(-1); - - for (Int_t bin = 0; bin < nrSamples; bin++) { - if (raw->GetSamples()[bin] > maxADC){ - maxADC = raw->GetSamples()[bin]; - maxTimeBin = bin; - } - AdcIntegral += raw->GetSamples()[bin] - Baseline; - - histName = "Signal_Shape_" + syscore + spadic + channelId; - - fHM->H2(histName.Data())->Fill(bin,raw->GetSamples()[bin] - Baseline); - histName = "Pulse_" + syscore + spadic + channelId; - - fHM->H2(histName.Data())->Fill(bin,raw->GetSamples()[bin]); - if (stopType == 0) - if (triggerType == 1 || triggerType == 3){ - if (kFlesMuenster == eqID){ - if (maxADC > -200 && maxADC <= -190 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger-200")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > -190 && maxADC <= -180 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger-190")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > -180 && maxADC <= -170 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger-180")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > -170 && maxADC <= -160 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger-170")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > -160 && maxADC <= -150 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger-160")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > -150 && maxADC <= -140 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger-150")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > -140 && maxADC <= -130 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger-140")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > -130 && maxADC <= -120 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger-130")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > -120 && maxADC <= -110 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger-120")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > -110 && maxADC <= -100 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger-110")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > -100 && maxADC <= -90 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger-100")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > -90 && maxADC <= -80 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger-090")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > -80 && maxADC <= -70 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger-080")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > -70 && maxADC <= -60 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger-070")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > -60 && maxADC <= -50 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger-060")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > -50 && maxADC <= -40 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger-050")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > -40 && maxADC <= -30 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger-040")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > -30 && maxADC <= -20 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger-030")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > -20 && maxADC <= -10 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger-020")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > -10 && maxADC <= 0 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger-010")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > 0 && maxADC <= 10 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger0000")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > 200 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger0200")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > 190 && maxADC <= 200 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger0190")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > 180 && maxADC <= 190 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger0180")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > 170 && maxADC <= 180 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger0170")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > 160 && maxADC <= 170 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger0160")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > 150 && maxADC <= 160 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger0150")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > 140 && maxADC <= 150 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger0140")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > 130 && maxADC <= 140 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger0130")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > 120 && maxADC <= 130 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger0120")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > 110 && maxADC <= 120 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger0110")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > 100 && maxADC <= 110 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger0100")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > 90 && maxADC <= 100 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger0090")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > 80 && maxADC <= 90 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger0080")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > 70 && maxADC <= 80 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger0070")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > 60 && maxADC <= 70 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger0060")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > 50 && maxADC <= 60 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger0050")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > 40 && maxADC <= 50 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger0040")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > 30 && maxADC <= 40 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger0030")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > 20 && maxADC <= 30 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger0020")->Fill(bin,raw->GetSamples()[bin]); - } else if (maxADC > 10 && maxADC <= 20 && maxTimeBin < 5) { - fHM->H2("MeanPulseShape_maxAdcLarger0010")->Fill(bin,raw->GetSamples()[bin]); - } - if (FragmentedPulseTest(raw) && maxADC < 0){//maxADC > 0 /*&& maxADC > -200 */&& maxTimeBin < 5){ - fHM->H2("MeanPulseShape_Fragmented")->Fill(bin,raw->GetSamples()[bin]); - fHM->H1("MeanPulseProfile_Fragmented")->Fill(bin,raw->GetSamples()[bin]); - } else if (!FragmentedPulseTest(raw) && maxADC > 0) {// {//if (maxADC < 0 /*&& maxADC > -200 */&& maxTimeBin < 5) { - fHM->H2("MeanPulseShape_Unfragmented")->Fill(bin,raw->GetSamples()[bin]); - fHM->H1("MeanPulseProfile_Unfragmented")->Fill(bin,raw->GetSamples()[bin]); - } - } - } - } - if (FragmentedPulseTest(raw)) - fFragmentedCounter++; - if (stopType == 0) - if (triggerType == 1/* || triggerType == 3*/) { - if (FragmentedPulseTest(raw)){ - - fHM->H2("FragmentedVsUnfragmentedPulses")->Fill(0.0,raw->GetSamples()[maxTimeBin]); - } else { - fHM->H2("FragmentedVsUnfragmentedPulses")->Fill(1,raw->GetSamples()[maxTimeBin]); - } - } - for (Int_t bin = 0; bin < nrSamples; bin++) { - histName = "maxADC_TimeBinCorr_" + syscore + spadic + "_TB" + timebinName[bin]; - fHM->H2(histName.Data())->Fill(raw->GetSamples()[maxTimeBin],raw->GetSamples()[bin]); - } - - histName = "maxTimeBin_" + syscore + spadic + channelId; - fHM->H1(histName.Data())->Fill(maxTimeBin); - - histName = "maxADC_" + syscore + spadic + channelId; - fHM->H1(histName.Data())->Fill(maxADC); - - histName = "maxADC_maxTimeBin_" + syscore + spadic + channelId; - fHM->H2(histName.Data())->Fill(maxTimeBin,maxADC); - - histName = "Integrated_ADC_Spectrum_" + syscore + spadic; - if (maxADC > -200) // minimum amplitude threshold to reduce noise - fHM->H2(histName.Data())->Fill(chID, AdcIntegral); - - histName = "Trigger_Heatmap_" + syscore + spadic; - if (maxADC > -200){ // minimum amplitude threshold to reduce noise - fHM->H2(histName.Data())->Fill(columnId ,rowId); - } - - histName = "DeltaTime_" + syscore + spadic; - fHM->H1(histName.Data())->Fill(fullTime-lastSpadicTime[SysId][SpaId]); - - histName = "TriggerRate_" + syscore + spadic; - if (fullTime-lastSpadicTimeCh[SysId][SpaId][chID] > 0.0) - if (triggerType == 1 || triggerType == 3) - fHM->H1(histName.Data())->Fill(chID, 1.0/((fullTime-lastSpadicTimeCh[SysId][SpaId][chID])*1.0E-09));//ns -> s -> Hz - - histName = "DeltaTime_Left_Right_" + syscore + spadic; - if (chID < 31) - fHM->H1(histName.Data())->Fill(fullTime-lastSpadicTimeCh[SysId][SpaId][chID+1]); - if (chID > 0) - fHM->H1(histName.Data())->Fill(fullTime-lastSpadicTimeCh[SysId][SpaId][chID-1]); - - histName = "DeltaTime_Left_Right_Trigger_" + syscore + spadic; - if (triggerType == 1 || triggerType == 3){ - if (chID < 31) - if (lastTriggerType[chID+1] == 2 || lastTriggerType[chID+1] == 3) - fHM->H1(histName.Data())->Fill(fullTime-lastSpadicTimeCh[SysId][SpaId][chID+1]); - if (chID > 0) - if (lastTriggerType[chID-1] == 2 || lastTriggerType[chID-1] == 3) - fHM->H1(histName.Data())->Fill(fullTime-lastSpadicTimeCh[SysId][SpaId][chID-1]); - } - } - } - - lastSpadicTime[SysId][SpaId] = fullTime; - lastSpadicTimeCh[SysId][SpaId][chID] = fullTime; - lastTriggerType[chID] = triggerType; - flastEpoch = fEpoch; - flastSuperEpoch = fSuperEpoch; - entries++; - } //entriesInMessage - - for (Int_t sy = 0; sy < 2; sy++){ - for (Int_t sp = 0; sp < 2; sp++){ - TString histName = "_SysCore" + std::to_string(sy) + "_Spadic" + std::to_string(sp); - for (Int_t timeSlice = 1; timeSlice <= fHM->H1((TString("TriggerCounter") + histName).Data())->GetNbinsX(); timeSlice++){ - fHM->H1((TString("TriggerCounter") + histName).Data())->SetBinContent(timeSlice,fHM->H1((TString("TriggerCounter") + histName).Data())->GetBinContent(timeSlice+1)); // shift all bin one to the left - fHM->H1((TString("OverFlowCounter") + histName).Data())->SetBinContent(timeSlice,fHM->H1((TString("OverFlowCounter") + histName).Data())->GetBinContent(timeSlice+1)); - fHM->H1((TString("ErrorCounter") + histName).Data())->SetBinContent(timeSlice,fHM->H1((TString("ErrorCounter") + histName).Data())->GetBinContent(timeSlice+1)); - } - fHM->H1((TString("TriggerCounter") + histName).Data())->SetBinContent(fHM->H1((TString("TriggerCounter") + histName).Data())->GetNbinsX(),sumTrigger[sy][2*sp] + sumTrigger[sy][2*sp+1]);// set only the spa sys combi to new value - fHM->G1((TString("TriggerCounterGraph") + histName).Data())->SetPoint(fHM->G1((TString("TriggerCounterGraph") + histName).Data())->GetN(),fHM->G1((TString("TriggerCounterGraph") + histName).Data())->GetN(),sumTrigger[sy][2*sp] + sumTrigger[sy][2*sp+1]); - - fHM->H1((TString("OverFlowCounter") + histName).Data())->SetBinContent(fHM->H1((TString("OverFlowCounter") + histName).Data())->GetNbinsX(),sumOverflow[sy][2*sp] + sumOverflow[sy][2*sp+1]); - fHM->G1((TString("OverFlowCounterGraph") + histName).Data())->SetPoint(fHM->G1((TString("OverFlowCounterGraph") + histName).Data())->GetN(),fHM->G1((TString("OverFlowCounterGraph") + histName).Data())->GetN(),sumOverflow[sy][2*sp] + sumOverflow[sy][2*sp+1]); - fHM->H1((TString("ErrorCounter") + histName).Data())->SetBinContent(fHM->H1((TString("ErrorCounter") + histName).Data())->GetNbinsX(),sumError[sy][2*sp] + sumError[sy][2*sp+1]); - fHM->G1((TString("ErrorCounterGraph") + histName).Data())->SetPoint(fHM->G1((TString("ErrorCounterGraph") + histName).Data())->GetN(),fHM->G1((TString("ErrorCounterGraph") + histName).Data())->GetN(),sumError[sy][2*sp] + sumError[sy][2*sp+1]); - fHM->H1("TriggerSum")->Fill(TString("SysCore" + std::to_string(sy) + "_Spadic" + std::to_string(sp)),sumTrigger[sy][2*sp] + sumTrigger[sy][2*sp+1]); - } - } - for(Int_t syscore = 0; syscore < 3; ++syscore) { - for(Int_t spadic = 0; spadic < 3; ++spadic) { - if(wrongTimeOrder[syscore][spadic] > 0) - LOG(error) << "SPADIC " << syscore << spadic << " Wrong time stamp order in " << Float_t(wrongTimeOrder[syscore][spadic]*100./entriesInMessage) <<"% of all events " << wrongTimeOrder[syscore][spadic]; - } - } - -} - Bool_t CbmTrdRawBuchData::FragmentedPulseTest(CbmSpadicRawMessage* raw) - { - Int_t maxAdcValue(-300),maxTimeBin(-1), sample(-300); - Int_t nrSamples=raw->GetNrSamples(); - for (Int_t bin = 0; bin < nrSamples; bin++) { - sample = raw->GetSamples()[bin]; - if (sample > maxAdcValue){ - maxAdcValue = sample; - maxTimeBin = bin; - } - } - if (maxTimeBin == 0) - return true; - else if (raw->GetSamples()[maxTimeBin] - raw->GetSamples()[/*maxTimeBin-1*/0] <= 0) - return true; - else - return false; - } - Int_t CbmTrdRawBuchData::GetMaximumAdc(CbmSpadicRawMessage* raw) - { - if (raw==NULL) return -1; - Int_t maxAdcValue(-300), sample(-300); - Int_t nrSamples=raw->GetNrSamples(); - for (Int_t bin = 0; bin < nrSamples; bin++) { - sample = raw->GetSamples()[bin]; - if (sample > maxAdcValue){ - maxAdcValue = sample; - } - } - return maxAdcValue; - } - -void CbmTrdRawBuchData::CleanUpBuffers() -{ - - for (std::map<TString, std::map<Int_t, std::map<Int_t, CbmSpadicRawMessage*> > >::iterator SpaSysIt = fTimeBuffer.begin(); SpaSysIt != fTimeBuffer.end(); SpaSysIt++){ - for (std::map<Int_t, std::map<Int_t, CbmSpadicRawMessage*> >::iterator TimeIt = SpaSysIt->second.begin(); TimeIt != SpaSysIt->second.end(); TimeIt++){ - for (std::map<Int_t, CbmSpadicRawMessage*> ::iterator CombiIt = TimeIt->second.begin(); CombiIt != TimeIt->second.end(); CombiIt++){ - if(CombiIt->second != NULL) - delete CombiIt->second; - } - TimeIt->second.clear(); - } - SpaSysIt->second.clear(); - } - fTimeBuffer.clear(); - /* - for (std::map<TString, std::map<ULong_t, std::map<Int_t, CbmSpadicRawMessage*> > >::iterator SpaSysIt = fFullTimeBuffer.begin() ; SpaSysIt != fFullTimeBuffer.end(); SpaSysIt++){ - for (std::map<ULong_t, std::map<Int_t, CbmSpadicRawMessage*> > ::iterator timeIt = SpaSysIt->second.begin() ; timeIt != SpaSysIt->second.end(); timeIt++){ - for (std::map<Int_t, CbmSpadicRawMessage*> ::iterator combiIt = timeIt->second.begin(); combiIt != timeIt->second.end(); combiIt++){ - if(combiIt->second != NULL) - delete combiIt->second; - } - timeIt->second.clear(); - } - SpaSysIt->second.clear(); - } - fFullTimeBuffer.clear(); - for (std::map<TString, std::map<ULong_t, std::multimap<Int_t, CbmSpadicRawMessage*> > >::iterator SpaSysIt = fFullTimeBufferAll.begin() ; SpaSysIt != fFullTimeBufferAll.end(); SpaSysIt++){ - for (std::map<ULong_t, std::multimap<Int_t, CbmSpadicRawMessage*> > ::iterator timeIt = SpaSysIt->second.begin() ; timeIt != SpaSysIt->second.end(); timeIt++){ - for (std::multimap<Int_t, CbmSpadicRawMessage*> ::iterator combiIt = timeIt->second.begin(); combiIt != timeIt->second.end(); combiIt++){ - if(combiIt->second != NULL) - delete combiIt->second; - } - timeIt->second.clear(); - } - SpaSysIt->second.clear(); - } - fFullTimeBufferAll.clear(); - for (std::map<Int_t, std::map<Int_t, std::map<Int_t, std::map<Int_t, CbmTrbRawMessage*> > > >::iterator SourceAIt = fTrbBuffer.begin() ; SourceAIt != fTrbBuffer.end(); SourceAIt++){ - for (std::map<Int_t, std::map<Int_t, std::map<Int_t, CbmTrbRawMessage*> > >::iterator epochIt = SourceAIt->second.begin() ; epochIt != SourceAIt->second.end(); epochIt++){ - for (std::map<Int_t, std::map<Int_t, CbmTrbRawMessage*> > ::iterator chIdIt = epochIt->second.begin() ; chIdIt != epochIt->second.end(); chIdIt++){ - for (std::map<Int_t, CbmTrbRawMessage*> ::iterator timeIt = chIdIt->second.begin(); timeIt != chIdIt->second.end(); timeIt++){ - if(timeIt->second != NULL) - delete timeIt->second; - } - chIdIt->second.clear(); - } - epochIt->second.clear(); - } - SourceAIt->second.clear(); - } - fTrbBuffer.clear(); - */ -} - -void CbmTrdRawBuchData::TimeClustering2015CernSPS() -{ - TString errorMessage, infoMessage, debugMessage; - debugMessage.Form("CbmTrdRawBuchData::TimeClustering2015CernSPS: SuperEpoch: %9i Epoch: %9i",fSuperEpoch, fEpoch); - LOG(debug) << debugMessage; - const Int_t deltaTimeThreshold = 100000; - //printf("Start TimeClustering for 2015 CERN SPS Data\n FFM Chamber on link0\n MS Chamber on link1 \n!!!!HARD CODED!!!!\n"); - //CbmSpadicRawMessage* raw = NULL; - //Int_t layerId(0), moduleId(0), sectorId(0), rowId(0), columnId(0), clusterSize(0); - Int_t maxCombiIdFFM(-1), maxCombiIdMS(-1); - Int_t lastFFMTime(0), thisFFMTime(0); - Int_t /*lastMSTime(0),*/ thisMSTime(0); - // Bool_t inside_Cluster(false); - if (fTimeBuffer.begin() != fTimeBuffer.end()){ - //cout << (fTimeBuffer.begin())->first<< endl; - } else { - errorMessage.Form("No TimeBuffer map found"); - LOG(error) << errorMessage; - return; - } - std::map<TString, std::map<Int_t, std::map<Int_t, CbmSpadicRawMessage*> > >::iterator FFMIt = fTimeBuffer.find(TString("SysCore0_Spadic0")); - if (FFMIt == fTimeBuffer.end()){ - infoMessage.Form("No map found for SysCore0_Spadic0 at SuperEpoch %9i Epoch %9i",fSuperEpoch,fEpoch); - LOG(info) << infoMessage; - CleanUpBuffers(); - return; - } - std::map<TString, std::map<Int_t, std::map<Int_t, CbmSpadicRawMessage*> > >::iterator MSIt = fTimeBuffer.find(TString("SysCore0_Spadic1")); - if (MSIt == fTimeBuffer.end()){ - infoMessage.Form("No map found for SysCore0_Spadic1 at SuperEpoch %9i Epoch %9i",fSuperEpoch,fEpoch); - LOG(info) << infoMessage; - CleanUpBuffers(); - return; - } -// std::map<Int_t, std::map<Int_t, CbmSpadicRawMessage*> >::iterator secondTimeIt = (MSIt->second).begin(); - for (std::map<Int_t, std::map<Int_t, CbmSpadicRawMessage*> >::iterator firstTimeIt = (FFMIt->second).begin() ; firstTimeIt != (FFMIt->second).end(); firstTimeIt++){ - Int_t maxChargeFFM(-300), lastChargeFFM(-301), maxChargeMS(-300), lastChargeMS(-301); - //secondEpochIt = (MSIt->second).find(firstEpochIt->first); - //if (secondEpochIt == (MSIt->second).end()) continue; - //std::map<Int_t, std::map<Int_t, CbmSpadicRawMessage*> >::iterator secondTimeIt = (secondEpochIt->second).begin(); - //for (std::map<Int_t, std::map<Int_t, CbmSpadicRawMessage*> >::iterator firstTimeIt = (firstEpochIt->second).begin(); firstTimeIt != (firstEpochIt->second).end(); firstTimeIt++){ - thisFFMTime = (Int_t)firstTimeIt->first; - debugMessage.Form("SysCore0_Spadic0 at SuperEpoch %9i Epoch %9i Time %12i",fSuperEpoch,fEpoch,thisFFMTime); - LOG(info) << debugMessage; - for (std::map<Int_t, CbmSpadicRawMessage*> ::iterator combiFFMIt = (firstTimeIt->second).begin(); combiFFMIt != (firstTimeIt->second).end(); combiFFMIt++){ - //raw = combiIt->second; - maxChargeFFM = GetMaximumAdc(combiFFMIt->second); - if (maxChargeFFM > lastChargeFFM){ - lastChargeFFM = maxChargeFFM; - maxCombiIdFFM = combiFFMIt->first; - } - } - //for ( std::map<Int_t, std::map<Int_t, CbmSpadicRawMessage*> >::iterator secondTimeIt = (secondEpochIt->second).begin(); secondTimeIt != (secondEpochIt->second).end(); secondTimeIt++){ - - //cout << "thisFFMTime: " << thisFFMTime << endl; - - if (thisFFMTime > lastFFMTime){ - //cout << " nextFFMTime found" << endl; -// for (secondTimeIt ; secondTimeIt != (MSIt->second).end(); secondTimeIt++){ - for (std::map<Int_t, std::map<Int_t, CbmSpadicRawMessage*> >::iterator secondTimeIt = (MSIt->second).begin(); secondTimeIt != (MSIt->second).end(); secondTimeIt++){ - thisMSTime = (Int_t)secondTimeIt->first; - - //cout << " thisMSTime: " << thisMSTime; - Int_t deltaTime = Int_t(thisMSTime - thisFFMTime); - - if (thisMSTime < thisFFMTime){ - // before message seen in first detector - debugMessage.Form("SysCore0_Spadic0 at SuperEpoch %9i Epoch %9i Time %12i #DeltaTime %12i past",fSuperEpoch,fEpoch,thisFFMTime,deltaTime); - LOG(info) << debugMessage; - for (std::map<Int_t, CbmSpadicRawMessage*> ::iterator combiMSIt = (secondTimeIt->second).begin(); combiMSIt != (secondTimeIt->second).end(); combiMSIt++){ - for (std::map<Int_t, CbmSpadicRawMessage*> ::iterator combiFFMIt = (firstTimeIt->second).begin(); combiFFMIt != (firstTimeIt->second).end(); combiFFMIt++){ - //Int_t equalFFMMessages = (firstTimeIt->second).count(combiFFMIt->first); - //Int_t equalMSMessages = (secondTimeIt->second).count(combiMSIt->first); - if (deltaTime < deltaTimeThreshold) - //for (Int_t iEqualFFM = 0; iEqualFFM < equalFFMMessages; iEqualFFM++) - // for (Int_t iEqualMS = 0; iEqualMS < equalMSMessages; iEqualMS++) - fHM->H2("DeltaClusterTimeCorrelationAllEvents2015CernSPS")->Fill(combiFFMIt->first,combiMSIt->first); - } - } - - } - else if (thisMSTime == thisFFMTime) { - //same time in both detectors - debugMessage.Form("SysCore0_Spadic0 at SuperEpoch %9i Epoch %9i Time %12i #DeltaTime %12i now",fSuperEpoch,fEpoch,thisFFMTime,deltaTime); - LOG(info) << debugMessage; - //cout << " now " << Int_t(thisMSTime - thisFFMTime) <<endl; - fHM->H1("DeltaClusterTime2015CernSPS")->Fill(deltaTime); - for (std::map<Int_t, CbmSpadicRawMessage*> ::iterator combiMSIt = (secondTimeIt->second).begin(); combiMSIt != (secondTimeIt->second).end(); combiMSIt++){ - //raw = combiIt->second; - if (deltaTime < deltaTimeThreshold) - for (std::map<Int_t, CbmSpadicRawMessage*> ::iterator combiFFMIt = (firstTimeIt->second).begin(); combiFFMIt != (firstTimeIt->second).end(); combiFFMIt++){ - fHM->H2("DeltaClusterTimeCorrelationFullCluster2015CernSPS")->Fill(combiFFMIt->first,combiMSIt->first); - fHM->H2("DeltaClusterTimeCorrelationAllEvents2015CernSPS")->Fill(combiFFMIt->first,combiMSIt->first); - } - maxChargeMS = GetMaximumAdc(combiMSIt->second); - if (maxChargeMS > lastChargeMS){ - lastChargeMS = maxChargeMS; - maxCombiIdMS = combiMSIt->first; - } - } - fHM->H2("DeltaClusterTimeCorrelation2015CernSPS")->Fill(maxCombiIdFFM,maxCombiIdMS); - // lastMSTime = thisMSTime; (VF) not used - break; - } else { - //we are looking for first message after FFM message time - //cout << " past " << Int_t(thisMSTime - thisFFMTime) <<endl; - - debugMessage.Form("SysCore0_Spadic0 at SuperEpoch %9i Epoch %9i Time %12i #DeltaTime %12i future",fSuperEpoch,fEpoch,thisFFMTime,deltaTime); - LOG(info) << debugMessage; - fHM->H1("DeltaClusterTime2015CernSPS")->Fill(Int_t(thisMSTime - thisFFMTime));//Fill only for the first message of a new cluster - //cout << "---find max channel---" << endl; - if (deltaTime < deltaTimeThreshold) - for (std::map<Int_t, CbmSpadicRawMessage*> ::iterator combiMSIt = (secondTimeIt->second).begin(); combiMSIt != (secondTimeIt->second).end(); combiMSIt++){ - //raw = combiIt->second; - for (std::map<Int_t, CbmSpadicRawMessage*> ::iterator combiFFMIt = (firstTimeIt->second).begin(); combiFFMIt != (firstTimeIt->second).end(); combiFFMIt++){ - fHM->H2("DeltaClusterTimeCorrelationFullCluster2015CernSPS")->Fill(combiFFMIt->first,combiMSIt->first); - fHM->H2("DeltaClusterTimeCorrelationAllEvents2015CernSPS")->Fill(combiFFMIt->first,combiMSIt->first); - } - maxChargeMS = GetMaximumAdc(combiMSIt->second); - if (maxChargeMS > lastChargeMS){ - lastChargeMS = maxChargeMS; - maxCombiIdMS = combiMSIt->first; - } - } - // cout << "---done---" << endl; - if (deltaTime < deltaTimeThreshold) - fHM->H2("DeltaClusterTimeCorrelation2015CernSPS")->Fill(maxCombiIdFFM,maxCombiIdMS); - - break; // break for new cluster - - - } - // lastMSTime = thisMSTime; (VF) not used - } - } - lastFFMTime = thisFFMTime; - } - - CleanUpBuffers(); - -} - - void CbmTrdRawBuchData::Clusterizer() - { - LOG(info) << "CbmTrdRawBuchData::Clusterizer : SuperEpoch: " << fSuperEpoch << " Epoch: " << fEpoch; - /* - TCanvas* b = new TCanvas("rawpulseshape","rawpulseshape",800,600); - TH1F* rawpulse = new TH1F("rawpulse","rawpulse",32,-0.5,31.5); - rawpulse->GetYaxis()->SetRangeUser(-255,256); - */ - Int_t mapDigiCounter = 0; - CbmSpadicRawMessage* raw = NULL; - Int_t layerId(0), moduleId(0), sectorId(0), rowId(0), columnId(0), clusterSize(0); - ULong_t lastClusterTime = 0; - ULong_t fullTime = 0; - TString SysSpaID = ""; - std::vector<Int_t> digiIndices; - for (std::map<TString, std::map<ULong_t, std::map<Int_t, CbmSpadicRawMessage*> > >::iterator SpaSysIt = fFullTimeBuffer.begin() ; SpaSysIt != fFullTimeBuffer.end(); SpaSysIt++){ - SysSpaID = SpaSysIt->first; - //printf("%s\n",SysSpaID.Data()); - for (std::map<ULong_t, std::map<Int_t, CbmSpadicRawMessage*> > ::iterator timeIt = (SpaSysIt->second).begin() ; timeIt != (SpaSysIt->second).end(); timeIt++){ - LOG(debug) << "ClusterSize:" << Int_t((timeIt->second).size()); - clusterSize = Int_t((timeIt->second).size()); - fullTime = timeIt->first; - //printf(" %lu\n",fullTime); - fHM->H1(TString("ClusterSize_" + SysSpaID).Data())->Fill(clusterSize); - - //Delta time between time clusters - fHM->H1(TString("DeltaTime_Cluster_" + SysSpaID).Data())->Fill(fullTime - lastClusterTime); - lastClusterTime = fullTime; - - Int_t lastCombiID = -1; - //digiIndices.clear(); - //printf("\nTime: %lu\n",fullTime); - for (std::map<Int_t, CbmSpadicRawMessage*> ::iterator combiIt = (timeIt->second).begin(); combiIt != (timeIt->second).end(); combiIt++){ - mapDigiCounter++; - //rawpulse->SetLineColor(Int_t(digiIndices.size())+1); - raw = combiIt->second; - fHM->H2(TString("StopType_ClusterSize_" + SysSpaID).Data())->Fill(clusterSize,Int_t(raw->GetStopType())); - - if (Int_t(raw->GetStopType()) != 0 && Int_t(raw->GetStopType() != 3)) - fHM->H2(TString("InfoType_ClusterSize_" + SysSpaID).Data())->Fill(clusterSize,Int_t(raw->GetInfoType())); - fHM->H2(TString("TriggerType_ClusterSize_" + SysSpaID).Data())->Fill(clusterSize,Int_t(raw->GetTriggerType())); - - fHM->H2(TString("ClusterSize_Message_Length_" + SysSpaID).Data())->Fill(clusterSize,Int_t(raw->GetNrSamples())); - layerId = GetLayerID(raw); - moduleId = GetModuleID(raw); - //printf("%p fullTime %12lu %12lu %s CI%2i layer %i EI%i SA%i TT%i\n",std::addressof(raw),fullTime,raw->GetFullTime(),(SysSpaID).Data(),combiIt->first,layerId,Int_t(raw->GetEquipmentID()),Int_t(raw->GetSourceAddress()),raw->GetTriggerType()); - fHM->H2(TString("LayerId").Data())->Fill(layerId,SysSpaID,1); - fHM->H2(TString("ModuleId").Data())->Fill(moduleId,SysSpaID,1); - - sectorId = GetSectorID(raw); - rowId = GetRowID(raw); - columnId = GetColumnID(raw); - - // BaseLineCorrection== - Float_t Baseline = 0.; - if (raw->GetStopType() == 0){ - for (Int_t bin = 1; bin < 4; bin++){ - Baseline += raw->GetSamples()[raw->GetNrSamples()-bin]; - } - Baseline /= 3.; - } else { - // Use average baseline estimated for full message length - } - const Int_t nSamples = 32;//raw->GetNrSamples(); - Float_t Samples[nSamples] = {0.}; - for (Int_t iBin = 0; iBin < raw->GetNrSamples(); iBin++){ - //rawpulse->SetBinContent(iBin+1,raw->GetSamples()[iBin]); - Samples[iBin] = raw->GetSamples()[iBin] - Baseline; - } - /* - b->cd(); - if(Int_t(digiIndices.size())==0) - rawpulse->DrawCopy(); - else - rawpulse->DrawCopy("same"); - rawpulse->Reset(); - */ - //===================== - //printf("la%i mo%i se%i ro%i co%i\n",layerId,moduleId,sectorId,rowId,columnId); - new ((*fDigis)[fiDigi]) CbmTrdDigi(CbmTrdAddress::GetAddress(layerId,moduleId,sectorId,rowId,columnId), - raw->GetFullTime()*57.14,//57,14 ns per timestamp - raw->GetTriggerType(), raw->GetInfoType(), raw->GetStopType(), - raw->GetNrSamples(), Samples/*&Samples[32]*/); - //digiIndices.push_back(fiDigi); - - if (combiIt != timeIt->second.begin()){ - fHM->H1(TString("DeltaCh_Cluster_" + SpaSysIt->first).Data())->Fill(combiIt->first - lastCombiID); - } - - if (combiIt->first - lastCombiID != 1 && digiIndices.size() > 0){ - //printf("\n"); - //printf("|>------------------Cluster %i finished (%02i)\n", fiCluster,Int_t(digiIndices.size())); - CbmTrdCluster* cluster = new ((*fClusters)[fiCluster]) CbmTrdCluster(); - cluster->SetAddress(CbmTrdAddress::GetAddress(layerId,moduleId,sectorId,rowId,columnId)); - cluster->SetDigis(digiIndices); - digiIndices.clear(); - TString pulseId; - pulseId.Form("pics/%08iRawCluster.png",fiCluster); - //b->Update(); - if (fiCluster % 100 == 0){ - //b->SaveAs(pulseId); - } - //b->Clear(); - fiCluster++; - } - digiIndices.push_back(fiDigi); - //printf(" %02i row%i col%02i %i\n",combiIt->first,rowId,columnId,Int_t(digiIndices.size())); - //printf("%i ",combiIt->first); - //delete combiIt->second; - lastCombiID = combiIt->first; - fiDigi++; - } - if (digiIndices.size() > 0){ - //printf("digiIndices %i > 0\n",(Int_t)digiIndices.size()); - //printf("|>------------------Cluster %i finished (%02i)\n", fiCluster,Int_t(digiIndices.size())); - CbmTrdCluster* cluster = new ((*fClusters)[fiCluster]) CbmTrdCluster(); - cluster->SetAddress(CbmTrdAddress::GetAddress(layerId,moduleId,sectorId,rowId,columnId)); - cluster->SetDigis(digiIndices); - digiIndices.clear(); - TString pulseId; - pulseId.Form("pics/%08iRawCluster.png",fiCluster); - //b->Update(); - if (fiCluster % 100 == 0){ - //b->SaveAs(pulseId); - } - //b->Clear(); - fiCluster++; - } - //timeIt->second.clear(); - } - //SpaSysIt->second.clear(); - } - - printf("[INFO ] CbmTrdRawBuchData::Clusterizer Digis: %i\n",mapDigiCounter); - } - - Int_t CbmTrdRawBuchData::GetSysCoreID(CbmSpadicRawMessage* raw) - { - Int_t eqID = raw->GetEquipmentID(); - if (eqID == (Int_t)kFlesMuenster) { - return 0; - } else if (eqID == (Int_t)kFlesFrankfurt){ - return 1; - } else if (eqID == (Int_t)kFlesBucarest){ - return 2; - } else - LOG(error) << "Container " << fContainerCounter << " Message " << fSpadicMessageCounter << " EquipmentID " << eqID << "not known."; - return -1; - } - Int_t CbmTrdRawBuchData::GetSpadicID(CbmSpadicRawMessage* raw) - { - Int_t sourceA = raw->GetSourceAddress() - SpadicBaseAddress; - if (sourceA == 0 || sourceA == 1) - return 0; - else if (sourceA == 2 || sourceA == 3) - return 1; - else if (sourceA == 4 || sourceA == 5) - return 2; - else - LOG(error) << "Container " << fContainerCounter << " Message " << fSpadicMessageCounter << " Source Address " << sourceA << "not known."; - return -1; - } - Int_t CbmTrdRawBuchData::GetModuleID(CbmSpadicRawMessage* raw) - { - if (raw == NULL){ - LOG(error) << "CbmTrdRawBuchData::GetModuleID: CbmSpadicRawMessage == NULL"; - return -1; - } else { - Int_t sys = GetSysCoreID(raw); - Int_t spa = GetSpadicID(raw); - - return sys * 3 + spa; - } - } - Int_t CbmTrdRawBuchData::GetLayerID(CbmSpadicRawMessage* raw) - { - if (raw == NULL){ - LOG(error) << "CbmTrdRawBuchData::GetModuleID: CbmSpadicRawMessage == NULL"; - return -1; - } else { - Int_t sys = GetSysCoreID(raw); - Int_t spa = GetSpadicID(raw); - - return sys * 3 + spa; - } - } - Int_t CbmTrdRawBuchData::GetSectorID(CbmSpadicRawMessage* raw) - { - if (raw == NULL) - LOG(error) << "CbmTrdRawBuchData::GetSectorID: CbmSpadicRawMessage == NULL"; - return 0; - } - Int_t CbmTrdRawBuchData::GetRowID(CbmSpadicRawMessage* raw) - { - if (raw == NULL) - LOG(error) << "CbmTrdRawBuchData::GetRowID: CbmSpadicRawMessage == NULL"; - Int_t chID = raw->GetChannelID(); - Int_t sourceA = raw->GetSourceAddress(); - switch (sourceA) { - case (SpadicBaseAddress+0): // first spadic - break; - case (SpadicBaseAddress+1): // first spadic - chID += 16; - break; - case (SpadicBaseAddress+2): // second spadic - break; - case (SpadicBaseAddress+3): // second spadic - chID += 16; - break; - case (SpadicBaseAddress+4): // third spadic - break; - case (SpadicBaseAddress+5): // third spadic - chID += 16; - break; - default: - LOG(error) << "Container " << fContainerCounter << " Message " << fSpadicMessageCounter << " Source Address " << sourceA << "not known."; - break; - } - Int_t columnId = GetChannelOnPadPlane(chID); - if (columnId > 16) - return 1; - else - return 0; - } - Int_t CbmTrdRawBuchData::GetColumnID(CbmSpadicRawMessage* raw) - { - if (raw == NULL) - LOG(error) << "CbmTrdRawBuchData::GetColumnID: CbmSpadicRawMessage == NULL"; - Int_t chID = raw->GetChannelID(); - Int_t sourceA = raw->GetSourceAddress(); - switch (sourceA) { - case (SpadicBaseAddress+0): // first spadic - break; - case (SpadicBaseAddress+1): // first spadic - chID += 16; - break; - case (SpadicBaseAddress+2): // second spadic - break; - case (SpadicBaseAddress+3): // second spadic - chID += 16; - break; - case (SpadicBaseAddress+4): // third spadic - break; - case (SpadicBaseAddress+5): // third spadic - chID += 16; - break; - default: - LOG(error) << "Container " << fContainerCounter << " Message " << fSpadicMessageCounter << " Source Address " << sourceA << "not known."; - break; - } - Int_t columnId = GetChannelOnPadPlane(chID); - if (columnId >= 16) - columnId -= 16; - return columnId; - } - Int_t CbmTrdRawBuchData::GetChannelOnPadPlane(Int_t SpadicChannel) - { - Int_t channelMapping[32] = {31,15,30,14,29,13,28,12,27,11,26,10,25, 9,24, 8, - 23, 7,22, 6,21, 5,20, 4,19, 3,18, 2,17, 1,16, 0}; - if (SpadicChannel < 0 || SpadicChannel > 31){ - LOG(error) << "CbmTrdRawBuchData::GetChannelOnPadPlane ChId " << SpadicChannel; - return -1; - } else { - return channelMapping[SpadicChannel]; - } - } -Int_t CbmTrdRawBuchData::GetCombiID(CbmSpadicRawMessage* raw) -{ - const Int_t maxNrColumns = 16; - return (GetRowID(raw) * (maxNrColumns + 1) + GetColumnID(raw)); -} - // ---- Finish -------------------------------------------------------- - void CbmTrdRawBuchData::Finish() - { - Clusterizer(); - TimeClustering2015CernSPS(); - LOG(debug) << "Finish of CbmTrdRawBuchData"; - // Write to file - fHM->WriteToFile(); - // Update Histos and Canvases - - LOG(info) << "CbmTrdRawBuchData::Finish Container: " << fContainerCounter; - LOG(info) << "CbmTrdRawBuchData::Finish Spadic Messages: " << fSpadicMessageCounter; - LOG(info) << "CbmTrdRawBuchData::Finish Nxyter Messages: " << fNxyterMessageCounter; - LOG(info) << "CbmTrdRawBuchData::Finish Trb Messages: " << fTrbMessageCounter; - LOG(info) << "CbmTrdRawBuchData::Finish Infos: " << fInfoCounter; - LOG(info) << "CbmTrdRawBuchData::Finish Hits: " << fHitCounter; - LOG(info) << "CbmTrdRawBuchData::Finish Multihits: " << fMultiHitCounter; - LOG(info) << "CbmTrdRawBuchData::Finish Errors: " << fErrorCounter << " (stoptype != 0 && != 3)"; - LOG(info) << "CbmTrdRawBuchData::Finish LostHits: " << fLostHitCounter << " (buffer full)"; - LOG(info) << "CbmTrdRawBuchData::Finish Identical Messages: " << fDoubleCounter; - LOG(info) << "CbmTrdRawBuchData::Finish Fragemented Signals: " << fFragmentedCounter; - LOG(info) << "CbmTrdRawBuchData::Finish Digis: " << fDigis->GetEntriesFast(); - LOG(info) << "CbmTrdRawBuchData::Finish Clusters: " << fClusters->GetEntriesFast(); - } - - void CbmTrdRawBuchData::CreateHistograms() - { - gStyle->SetNumberContours(99); - gStyle->SetPadTickX(1); - gStyle->SetPadTickY(1); - // Create histograms for 3 Syscores with maximum 3 Spadics - TString histName = ""; - TString syscoreName[3] = { "SysCore0", "SysCore1", "SysCore2" }; - TString spadicName[3] = { "Spadic0", "Spadic1", "Spadic2" }; - TString channelName[32] = { "00", "01", "02", "03", "04", "05", "06", "07", "08", "09", - "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", - "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", - "30", "31"}; - TString timebinName[32] = { "00", "01", "02", "03", "04", "05", "06", "07", "08", "09", - "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", - "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", - "30", "31"}; - TString triggerTypes[5] = { "infoMessage", - "Global trigger", - "Self triggered", - "Neighbor triggered", - "Self and neighbor triggered"}; - TString stopTypes[6] = {"Normal end of message", - "Channel buffer full", - "Ordering FIFO full", - "Multi hit", - "Multi hit and channel buffer full", - "Multi hit and ordering FIFO full"}; - TString infoTypes[8] = {"Channel disabled during message building", - "Next grant timeout", - "Next request timeout", - "New grant but channel empty", - "Corruption in message builder", - "Empty word", - "Epoch out of sync", - "infoType out of array"}; //not official type, just to monitor overflows - - fHM->Add("DeltaClusterTime2015CernSPS", new TH1I("DeltaClusterTime2015CernSPS","DeltaClusterTime2015CernSPS",1E6,-100,200E6)); - fHM->H1("DeltaClusterTime2015CernSPS")->GetXaxis()->SetTitle("#Deltat_{SPADIC1-SPADIC0} (ns)"); - - fHM->Add("DeltaClusterTimeCorrelation2015CernSPS", new TH2I("DeltaClusterTimeCorrelation2015CernSPS","DeltaClusterTimeCorrelation2015CernSPS",34,-0.5,33.5,34,-0.5,33.5)); - fHM->H2("DeltaClusterTimeCorrelation2015CernSPS")->GetXaxis()->SetTitle("max CombiID Spadic0"); - fHM->H2("DeltaClusterTimeCorrelation2015CernSPS")->GetYaxis()->SetTitle("max CombiID Spadic1"); - - fHM->Add("DeltaClusterTimeCorrelationFullCluster2015CernSPS", new TH2I("DeltaClusterTimeCorrelationFullCluster2015CernSPS","DeltaClusterTimeCorrelationFullCluster2015CernSPS",34,-0.5,33.5,34,-0.5,33.5)); - fHM->H2("DeltaClusterTimeCorrelationFullCluster2015CernSPS")->GetXaxis()->SetTitle("all CombiID Spadic0"); - fHM->H2("DeltaClusterTimeCorrelationFullCluster2015CernSPS")->GetYaxis()->SetTitle("all CombiID Spadic1"); - - - fHM->Add("DeltaClusterTimeCorrelationAllEvents2015CernSPS", new TH2I("DeltaClusterTimeCorrelationAllEvents2015CernSPS","DeltaClusterTimeCorrelationAllEvents2015CernSPS",34,-0.5,33.5,34,-0.5,33.5)); - fHM->H2("DeltaClusterTimeCorrelationAllEvents2015CernSPS")->GetXaxis()->SetTitle("all CombiID Spadic0"); - fHM->H2("DeltaClusterTimeCorrelationAllEvents2015CernSPS")->GetYaxis()->SetTitle("all CombiID Spadic1"); - - fHM->Add("TriggerSum", new TH1I("TriggerSum", "TriggerSum", 9,0,9)); - fHM->Add("LayerId", new TH2I("LayerId", "LayerId", 9, -0.5, 8.5, 9, -0.5, 8.5)); - for(Int_t syscore = 0; syscore < 3; ++syscore) { - for(Int_t spadic = 0; spadic < 3; ++spadic) { - fHM->H1("LayerId")->GetYaxis()->SetBinLabel(syscore*3+spadic+1,syscoreName[syscore]+"_"+spadicName[spadic]); - } - } - fHM->Add("ModuleId", new TH2I("ModuleId", "ModuleId", 9, -0.5, 8.5, 9, -0.5, 8.5)); - for(Int_t syscore = 0; syscore < 3; ++syscore) { - for(Int_t spadic = 0; spadic < 3; ++spadic) { - fHM->H1("ModuleId")->GetYaxis()->SetBinLabel(syscore*3+spadic+1,syscoreName[syscore]+"_"+spadicName[spadic]); - } - } - for (Int_t maxAdcThreshold = -200; maxAdcThreshold <= 200; maxAdcThreshold+=10){ - histName.Form("maxAdcLarger%04i",maxAdcThreshold); - fHM->Add(TString("MeanPulseShape_"+histName).Data(), new TH2I(TString("MeanPulseShape_"+histName).Data(),TString("MeanPulseShape_"+histName).Data(),32,-0.5,31.5,2*256,-256.5,255.5)); - //cout << "MeanPulseShape_" << histName << endl; - //fHM->Add(TString("MeanPulseProfile_")+histName.Data(), new TProfile(TString("MeanPulseProfile_")+histName.Data(),TString("MeanPulseProfile_")+histName.Data(),32,-0.5,31.5,-256.5,255.5)); - } - - fHM->Add("FragmentedVsUnfragmentedPulses", new TH2I("FragmentedVsUnfragmentedPulses","FragmentedVsUnfragmentedPulses",2,-0.5,1.5,2*256,-256.5,255.5)); - fHM->H2("FragmentedVsUnfragmentedPulses")->GetXaxis()->SetBinLabel(1,"fragmented"); - fHM->H2("FragmentedVsUnfragmentedPulses")->GetXaxis()->SetBinLabel(2,"normal"); - - fHM->Add("MeanPulseShape_Fragmented", new TH2I("MeanPulseShape_Fragmented","MeanPulseShape_Fragmented",32,-0.5,31.5,2*256,-256.5,255.5)); - fHM->Add("MeanPulseProfile_Fragmented", new TProfile("MeanPulseProfile_Fragmented","MeanPulseProfile_Fragmented",32,-0.5,31.5,-256.5,255.5)); - - fHM->Add("MeanPulseShape_Unfragmented", new TH2I("MeanPulseShape_UnfragmentedPulses","MeanPulseShape_Unfragmented",32,-0.5,31.5,2*256,-256.5,255.5)); - fHM->Add("MeanPulseProfile_Unfragmented", new TProfile("MeanPulseProfile_UnfragmentedPulses","MeanPulseProfile_Unfragmented",32,-0.5,31.5,-256.5,255.5)); - - - for(Int_t syscore = 0; syscore < 3; ++syscore) { - for(Int_t spadic = 0; spadic < 3; ++spadic) { - fHM->H1("TriggerSum")->GetXaxis()->SetBinLabel(3*syscore+spadic+1,TString(syscoreName[syscore]+"_"+spadicName[spadic])); - - histName = "CountRate_" + syscoreName[syscore] + "_" + spadicName[spadic]; - TString title = histName + ";Channel;Counts"; - fHM->Add(histName.Data(), new TH1I(histName, title, 32, -0.5, 31.5)); - - histName = "TriggerRate_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";ChannelID;trigger rate [Hz]"; - fHM->Add(histName.Data(), new TProfile(histName, title, 32, -0.5, 31.5)); - - histName = "DeltaTime_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";Delta t ;Counts"; - fHM->Add(histName.Data(), new TH1I(histName, title, 5101, -100.5, 5000.5)); - - histName = "DeltaTime_Left_Right_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";Delta t ;Counts"; - fHM->Add(histName.Data(), new TH1I(histName, title, 5101, -100.5, 5000.5)); - - histName = "DeltaTime_Left_Right_Trigger_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";Delta t ;Counts"; - fHM->Add(histName.Data(), new TH1I(histName, title, 5101, -100.5, 5000.5)); - - histName = "DeltaTime_Cluster_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";Delta t ;Counts"; - fHM->Add(histName.Data(), new TH1I(histName, title, 5101, -100.5, 5000.5)); - - histName = "DeltaCh_Cluster_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";Delta t ;Counts"; - fHM->Add(histName.Data(), new TH1I(histName, title, 65, -32.5, 32.5)); - - histName = "StopType_Message_Length_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";Message Length (Time-Bins) ;"; - fHM->Add(histName.Data(), new TH2I(histName, title, 33, -0.5, 32.5,6,-0.5,5.5)); - for (Int_t sType=0; sType < 6; sType++) - fHM->H1(histName.Data())->GetYaxis()->SetBinLabel(sType+1,stopTypes[sType]); - - histName = "InfoType_Message_Length_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";Message Length (Time-Bins) ;"; - fHM->Add(histName.Data(), new TH2I(histName, title, 33, -0.5, 32.5, 8, -0.5, 7.5)); - for (Int_t iType=0; iType < 8; iType++) - fHM->H1(histName.Data())->GetYaxis()->SetBinLabel(iType+1,infoTypes[iType]); - - histName = "TriggerType_Message_Length_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";Message Length (Time-Bins) ;"; - fHM->Add(histName.Data(), new TH2I(histName, title, 33, -0.5, 32.5,5,-1.5,3.5)); - for (Int_t tType=0; tType < 4; tType++) - fHM->H1(histName.Data())->GetYaxis()->SetBinLabel(tType+1,triggerTypes[tType]); - - histName = "Message_Length_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";Message Length (Time-Bins) ;Channel"; - fHM->Add(histName.Data(), new TH2I(histName, title, 33, -0.5, 32.5, 32, -0.5, 31.5)); - - histName = "TriggerTypes_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + "; ;Channel"; - fHM->Add(histName.Data(), new TH2I(histName, title, 5, -1.5, 3.5,32,-0.5,31.5)); - for (Int_t tType=0; tType < 4; tType++) - fHM->H1(histName.Data())->GetXaxis()->SetBinLabel(tType+1,triggerTypes[tType]); - - histName = "StopTypes_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + "; ;Channel"; - fHM->Add(histName.Data(), new TH2I(histName, title, 6, -0.5, 5.5,32,-0.5,31.5)); - for (Int_t sType=0; sType < 6; sType++) - fHM->H1(histName.Data())->GetXaxis()->SetBinLabel(sType+1,stopTypes[sType]); - - histName = "InfoTypes_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + "; ;Channel"; - fHM->Add(histName.Data(), new TH2I(histName, title, 8, -0.5, 7.5,32,-0.5,31.5)); - for (Int_t iType=0; iType < 8; iType++) - fHM->H1(histName.Data())->GetXaxis()->SetBinLabel(iType+1,infoTypes[iType]); - - histName = "Trigger_Stop_Types_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + "; ;"; - fHM->Add(histName.Data(), new TH2I(histName, title, 5, -1.5, 3.5, 6, -0.5, 5.5)); - for (Int_t tType=0; tType < 4; tType++) - fHM->H1(histName.Data())->GetXaxis()->SetBinLabel(tType+1,triggerTypes[tType]); - for (Int_t sType=0; sType < 6; sType++) - fHM->H1(histName.Data())->GetYaxis()->SetBinLabel(sType+1,stopTypes[sType]); - - histName = "Trigger_Info_Types_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + "; ;"; - fHM->Add(histName.Data(), new TH2I(histName, title, 5, -1.5, 3.5, 8, -0.5, 7.5)); - for (Int_t tType=0; tType < 4; tType++) - fHM->H1(histName.Data())->GetXaxis()->SetBinLabel(tType+1,triggerTypes[tType]); - for (Int_t iType=0; iType < 8; iType++) - fHM->H1(histName.Data())->GetYaxis()->SetBinLabel(iType+1,infoTypes[iType]); - - - histName = "Stop_Info_Types_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + "; ;"; - fHM->Add(histName.Data(), new TH2I(histName, title, 6, -0.5, 5.5, 8, -0.5, 7.5)); - for (Int_t sType=0; sType < 6; sType++) - fHM->H1(histName.Data())->GetXaxis()->SetBinLabel(sType+1,stopTypes[sType]); - for (Int_t iType=0; iType < 8; iType++) - fHM->H1(histName.Data())->GetYaxis()->SetBinLabel(iType+1,infoTypes[iType]); - - - histName = "GroupId_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + "; ;Counts"; - fHM->Add(histName.Data(), new TH1I(histName, title, 2, -0.5, 1.5)); - - - histName = "ClusterSize_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";Cluster Size [Channel] ;Counts"; - fHM->Add(histName.Data(), new TH1I(histName, title, 10, -0.5, 9.5)); - - histName = "ClusterSize_Message_Length_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";Cluster Size [Channel] ;Message Length (Time-Bins)"; - fHM->Add(histName.Data(), new TH2I(histName, title, 10, -0.5, 9.5, 33, -0.5, 32.5)); - - - histName = "StopType_ClusterSize_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";Cluster Size [Channel] ; "; - fHM->Add(histName.Data(), new TH2I(histName, title, 10, -0.5, 9.5, 6, -0.5, 5.5)); - for (Int_t sType=0; sType < 6; sType++) - fHM->H1(histName.Data())->GetYaxis()->SetBinLabel(sType+1,stopTypes[sType]); - - histName = "TriggerType_ClusterSize_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";Cluster Size [Channel] ; "; - fHM->Add(histName.Data(), new TH2I(histName, title, 10, -0.5, 9.5, 5, -1.5, 3.5)); - for (Int_t tType=0; tType < 4; tType++) - fHM->H1(histName.Data())->GetYaxis()->SetBinLabel(tType+1,triggerTypes[tType]); - - histName = "InfoType_ClusterSize_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";Cluster Size [Channel] ; "; - fHM->Add(histName.Data(), new TH2I(histName, title, 10, -0.5, 9.5, 8, -0.5, 7.5)); - for (Int_t iType=0; iType < 8; iType++) - fHM->H1(histName.Data())->GetYaxis()->SetBinLabel(iType+1,infoTypes[iType]); - - histName = "TriggerCounterGraph_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";TimeSlice;Trigger / TimeSlice"; - fHM->Add(histName.Data(), new TGraph()); - fHM->G1(histName.Data())->SetTitle(histName.Data()); - - histName = "TriggerCounter_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";TimeSlice;Trigger / TimeSlice"; - fHM->Add(histName.Data(), new TH1I(histName, title, 1000, 0, 1000)); - - histName = "OverFlowCounterGraph_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";TimeSlice;Trigger / TimeSlice"; - fHM->Add(histName.Data(), new TGraph()); - fHM->G1(histName.Data())->SetTitle(histName.Data()); - - histName = "OverFlowCounter_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";TimeSlice;OverFlow / TimeSlice"; - fHM->Add(histName.Data(), new TH1I(histName, title, 1000, 0, 1000)); - - histName = "ErrorCounterGraph_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";TimeSlice;Trigger / TimeSlice"; - fHM->Add(histName.Data(), new TGraph()); - fHM->G1(histName.Data())->SetTitle(histName.Data()); - - histName = "ErrorCounter_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";TimeSlice;Error / TimeSlice"; - fHM->Add(histName.Data(), new TH1I(histName, title, 1000, 0, 1000)); - //title = histName + ";Channel;ADC value in Bin 0"; - //fHM->Add(histName.Data(), new TH1I(histName, title, 32, -0.5, 31.5)); - - histName = "BaseLine_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";Channel;ADC value"; - fHM->Add(histName.Data(), new TH2F(histName, title, 32, -0.5, 31.5, 511, -256, 255)); - - histName = "Integrated_ADC_Spectrum_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";Channel;Integr. ADC values in Bin [0,31]"; - fHM->Add(histName.Data(), new TH2F(histName, title, 32, -0.5, 31.5, 2*33*256, -33*256, 33*256)); - - histName = "Trigger_Heatmap_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";Column;Row"; - fHM->Add(histName.Data(), new TH2I(histName, title, 16, -0.5, 15.5, 2, -0.5, 1.5)); - /* - histName = "maxADC_TimeBinCorr_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + "max ADC value; value in time bin"; - fHM->Add(histName.Data(), new TH2I(histName, title, 511, -256, 255, 511, -256, 255)); - */ - - for(Int_t channel = 0; channel < 32; channel++) { - histName = "Noise1_" + syscoreName[syscore] + "_" + spadicName[spadic] + "_Ch" + channelName[channel]; - title = histName + ";ADC value;Count"; - fHM->Add(histName.Data(), new TH1F(histName, title, 511, -256, 255)); - } - - for(Int_t channel = 0; channel < 32; channel++) { - histName = "Signal_Shape_" + syscoreName[syscore] + "_" + spadicName[spadic] + "_Ch" + channelName[channel]; - title = histName + ";Time Bin;ADC value"; - fHM->Add(histName.Data(), new TH2I(histName, title, 32, -0.5, 31.5, 767, -256, 511)); - } - for(Int_t channel = 0; channel < 32; channel++) { - histName = "Pulse_" + syscoreName[syscore] + "_" + spadicName[spadic] + "_Ch" + channelName[channel]; - title = histName + ";Time Bin;ADC value"; - fHM->Add(histName.Data(), new TH2I(histName, title, 32, -0.5, 31.5, 767, -256, 511)); - } - for(Int_t channel = 0; channel < 32; channel++) { - histName = "maxTimeBin_" + syscoreName[syscore] + "_" + spadicName[spadic] + "_Ch" + channelName[channel]; - title = histName + ";max Time Bin;count"; - fHM->Add(histName.Data(), new TH1I(histName, title, 32, -0.5, 31.5)); - } - for(Int_t channel = 0; channel < 32; channel++) { - histName = "maxADC_" + syscoreName[syscore] + "_" + spadicName[spadic] + "_Ch" + channelName[channel]; - title = histName + ";max ADC value;count"; - fHM->Add(histName.Data(), new TH1I(histName, title, 511, -256, 255)); - } - for(Int_t channel = 0; channel < 32; channel++) { - histName = "maxADC_maxTimeBin_" + syscoreName[syscore] + "_" + spadicName[spadic] + "_Ch" + channelName[channel]; - title = histName + ";max Time Bin;max ADC value"; - fHM->Add(histName.Data(), new TH2I(histName, title, 32, -0.5, 31.5, 511, -256, 255)); - } - - //for(Int_t channel = 0; channel < 32; channel++) { - for(Int_t bin = 0; bin < 32; bin++) { - histName = "maxADC_TimeBinCorr_" + syscoreName[syscore] + "_" + spadicName[spadic] + "_TB" + timebinName[bin]; - title = histName + "max ADC value; value in time bin"; - fHM->Add(histName.Data(), new TH2I(histName, title, 511, -256, 255, 511, -256, 255)); - } - // } - - } - } - } - ClassImp(CbmTrdRawBuchData) diff --git a/beamtime/cern2014/tasks/CbmTrdRawBuchData.h b/beamtime/cern2014/tasks/CbmTrdRawBuchData.h deleted file mode 100644 index 9f945b662e3f912724160a0cf80a3117eab23638..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/tasks/CbmTrdRawBuchData.h +++ /dev/null @@ -1,108 +0,0 @@ -#ifndef CBMTRDRAWBUCHDATA_H -#define CBMTRDRAWBUCHDATA_H - -#include "FairTask.h" -#include "CbmHistManager.h" -#include "CbmSpadicRawMessage.h" -#include "CbmTrbRawMessage.h" -#include "TClonesArray.h" - -class CbmTrdRawBuchData : public FairTask -{ - public: - - /** Default constructor **/ - CbmTrdRawBuchData(); - - /** Constructor with parameters (Optional) **/ - // CbmTrdRawBuchData(Int_t verbose); - - - /** Destructor **/ - ~CbmTrdRawBuchData(); - - - /** Initiliazation of task at the beginning of a run **/ - virtual InitStatus Init(); - - /** ReInitiliazation of task when the runID changes **/ - virtual InitStatus ReInit(); - - /** Executed for each event. **/ - virtual void Exec(Option_t* opt); - - /** Load the parameter container from the runtime database **/ - virtual void SetParContainers(); - - /** Finish task called at the end of the run **/ - virtual void Finish(); - virtual Int_t GetSysCoreID(CbmSpadicRawMessage* raw); - virtual Int_t GetSpadicID(CbmSpadicRawMessage* raw); - virtual Int_t GetModuleID(CbmSpadicRawMessage* raw); - virtual Int_t GetLayerID(CbmSpadicRawMessage* raw); - virtual Int_t GetSectorID(CbmSpadicRawMessage* raw); - virtual Int_t GetRowID(CbmSpadicRawMessage* raw); - virtual Int_t GetColumnID(CbmSpadicRawMessage* raw); - virtual Int_t GetCombiID(CbmSpadicRawMessage* raw); - virtual Int_t GetChannelOnPadPlane(Int_t SpadicChannel); - virtual Bool_t FragmentedPulseTest(CbmSpadicRawMessage* raw); - virtual Int_t GetMaximumAdc(CbmSpadicRawMessage* raw); - - private: - - /** Input array from previous already existing data level **/ - TClonesArray* fRawSpadic; - TClonesArray* fNxyterRaw; - TClonesArray* fTrbRaw; - /** Output array **/ - TClonesArray* fDigis; //! TRD digis - TClonesArray* fClusters; - Int_t fiDigi; - Int_t fiCluster; - CbmHistManager* fHM; - Int_t fmaxTimeGlobal; - Int_t fmaxTimeGroup[3][6]; - ULong_t fmaxFullTimeGlobal; - ULong_t fmaxFullTimeGroup[3][6]; - ULong_t flastDlmTriggerTime[3][6][15]; - Int_t fEpoch; - Int_t flastEpoch; - Int_t fSuperEpoch; - Int_t flastSuperEpoch; - Int_t fSpadicMessageCounter; - Int_t fNxyterMessageCounter; - Int_t fTrbMessageCounter; - Int_t fContainerCounter; - Int_t fInfoCounter; - Int_t fHitCounter; - Int_t fMultiHitCounter; - Int_t fErrorCounter; - Int_t fLostHitCounter; - Int_t fDoubleCounter; - Int_t fFragmentedCounter; - std::map<Int_t, std::map<Int_t, std::map<Int_t, CbmSpadicRawMessage*> > > fSys0Spa0Buffer;//<SuperEpoch <Epoch <Time, SpadicMessage> > > > - std::map<Int_t, std::map<Int_t, std::map<Int_t, CbmSpadicRawMessage*> > > fSys0Spa1Buffer;//<SuperEpoch <Epoch <Time, SpadicMessage> > > > - std::map<TString, std::map<Int_t, std::map<Int_t, CbmSpadicRawMessage*> > > fTimeBuffer;//<ASIC ID "Syscore%d_Spadic%d" <Time, <CombiId, SpadicMessage> > > > - std::map<TString, std::map<ULong_t, std::map<Int_t, CbmSpadicRawMessage*> > > fFullTimeBuffer;// <ASIC ID "Syscore%d_Spadic%d"<Time, <CombiId, SpadicMessage> > > - std::map<TString, std::map<ULong_t, std::multimap<Int_t, CbmSpadicRawMessage*> > > fFullTimeBufferAll;// <ASIC ID "Syscore%d_Spadic%d"<Time, <CombiId, SpadicMessage> > > - //std::map<Int_t, - std::map<Int_t, std::map<Int_t, std::map<Int_t, std::map<Int_t, CbmTrbRawMessage*> > > > fTrbBuffer;// sourceA < epoch < chId < Coarse, TrbMessage > > > > > - //std::map<Int_t, CbmTrbRawMessage*> fTrbBuffer; - /** Output array to new data level**/ - // TClonesArray* <OutputDataLevel>; - - void CleanUpBuffers(); - - void CreateHistograms(); - - void Clusterizer(); - - void TimeClustering2015CernSPS(); - - CbmTrdRawBuchData(const CbmTrdRawBuchData&); - CbmTrdRawBuchData operator=(const CbmTrdRawBuchData&); - - ClassDef(CbmTrdRawBuchData,2); -}; - -#endif diff --git a/beamtime/cern2014/tasks/CbmTrdRawPulseMonitor.cxx b/beamtime/cern2014/tasks/CbmTrdRawPulseMonitor.cxx deleted file mode 100644 index 180fda0329669977ba73449d395913fba73c403e..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/tasks/CbmTrdRawPulseMonitor.cxx +++ /dev/null @@ -1,293 +0,0 @@ -#include "CbmTrdRawPulseMonitor.h" -#include "CbmTrdRawBeamProfile.h" - -#include "CbmSpadicRawMessage.h" -#include "CbmTrdDigi.h" -#include "CbmTrdCluster.h" -#include "CbmHistManager.h" -#include "CbmBeamDefaults.h" -#include "CbmTrdAddress.h" -#include "CbmTrdDaqBuffer.h" - -#include "FairLogger.h" - -#include "TH1.h" -#include "TH2.h" -#include "TCanvas.h" - -#include "TString.h" -#include "TStyle.h" - -#include <cmath> -#include <map> -#include <vector> -// ---- Default constructor ------------------------------------------- -CbmTrdRawPulseMonitor::CbmTrdRawPulseMonitor() - : FairTask("CbmTrdRawPulseMonitor"), - fRawSpadic(NULL), - fMonitor(NULL), - fRatio(NULL), - fRawpulse(NULL), - fS_N(NULL), - fSignalMap(NULL), - fHM(NULL), - fMessageCounter(0), - fContainerCounter(0) -{ - LOG(debug) << "Default Constructor of CbmTrdRawPulseMonitor"; -} - -// ---- Destructor ---------------------------------------------------- -CbmTrdRawPulseMonitor::~CbmTrdRawPulseMonitor() -{ - LOG(debug) << "Destructor of CbmTrdRawPulseMonitor"; -} - -// ---- Initialisation ---------------------------------------------- -void CbmTrdRawPulseMonitor::SetParContainers() -{ - LOG(debug) << "SetParContainers of CbmTrdRawPulseMonitor"; - // Load all necessary parameter containers from the runtime data base - /* - FairRunAna* ana = FairRunAna::Instance(); - FairRuntimeDb* rtdb=ana->GetRuntimeDb(); - - <CbmTrdRawPulseMonitorDataMember> = (<ClassPointer>*) - (rtdb->getContainer("<ContainerName>")); - */ -} - -// ---- Init ---------------------------------------------------------- -InitStatus CbmTrdRawPulseMonitor::Init() -{ - gStyle->SetNumberContours(99); - gStyle->SetPadTickX(1); - gStyle->SetPadTickY(1); - LOG(debug) << "Initilization of CbmTrdRawPulseMonitor"; - - // Get a handle from the IO manager - FairRootManager* ioman = FairRootManager::Instance(); - - // Get a pointer to the previous already existing data level - fRawSpadic = static_cast<TClonesArray*>(ioman->GetObject("SpadicRawMessage")); - if ( ! fRawSpadic ) { - LOG(fatal) << "No InputDataLevelName array!\n CbmTrdRawPulseMonitor will be inactive"; - return kERROR; - } - fMonitor = new TCanvas("PulseMonitor","PulseMonitor", 0, 0, 1700, 1000); - fMonitor->Divide(8,4); - fRawpulse = new TH1I("rawPulse","rawPulse",32,-0.5,31.5); - fRawpulse->GetYaxis()->SetRangeUser(-255,256); - fRatio = new TCanvas("Ratio","Ratio", 0, 0, 1600, 600); - fRatio->Divide(2,1); - fS_N = new TH1I("S/N","S/N",2,-0.5,1.5); - fS_N->GetXaxis()->SetBinLabel(1,"Noise"); - fS_N->GetXaxis()->SetBinLabel(2,"Signal"); - fSignalMap = new TH2I("SignalMap","SignalMap",16,-0.5,15.5,2,-0.5,1.5); - return kSUCCESS; -} - -// ---- ReInit ------------------------------------------------------- -InitStatus CbmTrdRawPulseMonitor::ReInit() -{ - LOG(debug) << "Initilization of CbmTrdRawPulseMonitor"; - return kSUCCESS; -} - -// ---- Exec ---------------------------------------------------------- -void CbmTrdRawPulseMonitor::Exec(Option_t*) -{ - CbmTrdRawBeamProfile* dummy = new CbmTrdRawBeamProfile(); - // const Int_t maxNrColumns = 16; (VF) not used - //TH1I* rawpulse = new TH1I("rawPulse","rawPulse",32,-0.5,31.5); - - /* - This function is reinitialized for each new TimeSliceContainer - */ - fContainerCounter++; - /* - Int_t channelMapping[32] = {31,15,30,14,29,13,28,12,27,11,26,10,25, 9,24, 8, - 23, 7,22, 6,21, 5,20, 4,19, 3,18, 2,17, 1,16, 0}; - */ - /* - TString timebinName[32] = { "00", "01", "02", "03", "04", "05", "06", "07", "08", "09", - "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", - "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", - "30", "31"}; - */ - //std::map<TString, std::map<ULong_t, std::map<Int_t, CbmSpadicRawMessage*> > > timeBuffer;// <ASIC ID "Syscore%d_Spadic%d"<Time, <CombiId, SpadicMessage> > - - Int_t entriesInMessage = fRawSpadic->GetEntriesFast(); - - - LOG(debug) << "Container: " << fContainerCounter; - LOG(debug) << "Entries in Message: " << entriesInMessage; - LOG(debug) << "Entries in total: " << fMessageCounter; - // Find info about hitType, stopType and infoType in cbmroot/fles/spadic/message/constants/.. - /* - TString triggerTypes[4] = {"Global trigger", - "Self triggered", - "Neighbor triggered", - "Self and neighbor triggered"}; - TString stopTypes[6] = {"Normal end of message", - "Channel buffer full", - "Ordering FIFO full", - "Multi hit", - "Multi hit and channel buffer full", - "Multi hit and ordering FIFO full"}; - TString infoTypes[8] = {"Channel disabled during message building", - "Next grant timeout", - "Next request timeout", - "New grant but channel empty", - "Corruption in message builder", - "Empty word", - "Epoch out of sync", - "infoType out of array"}; - */ - //if (entriesInMessage > 1) entriesInMessage = 1; // for fast data visualization - - Int_t rowId(0), columnId(0)/*, combiId(0)*/; - Int_t eventCounter = 0; - Int_t maxAdcTimeBin(-1), maxAdc(-300); - for (Int_t i=0; i < entriesInMessage; ++i) { - fMessageCounter++; - CbmSpadicRawMessage* raw = /*static_cast<*/(CbmSpadicRawMessage*)/*>*/(fRawSpadic->At(i)); - Int_t eqID = raw->GetEquipmentID(); - Int_t sourceA = raw->GetSourceAddress(); - //printf("EI%i SA%i ->",eqID,sourceA); - Int_t chID = raw->GetChannelID(); - Int_t SysId(-1), SpaId(-1); - // Int_t nrSamples=raw->GetNrSamples(); - Int_t triggerType=raw->GetTriggerType(); - Int_t stopType=raw->GetStopType(); - Int_t infoType=raw->GetInfoType(); - if (stopType != 0 && stopType != 3) - if (infoType > 6) { - LOG(error) << "Container " << fContainerCounter << " Message " << fMessageCounter << " eqId " << eqID << " sourceA " << sourceA << " InfoType " << infoType << " out of range. Set to 7. StopType:" << stopType << " TriggerType:" << triggerType; - infoType = 7; - } - // Int_t groupId=raw->GetGroupId(); - // ULong_t time = raw->GetFullTime(); - - - TString syscore=""; - switch (eqID) { - case kFlesMuenster: // Muenster - syscore="SysCore0_"; - SysId = 0; - break; - case kFlesFrankfurt: // Frankfurt - syscore="SysCore1_"; - SysId = 1; - break; - case kFlesBucarest: // Bucarest - syscore="SysCore2_"; - SysId = 2; - break; - default: - LOG(error) << "Container " << fContainerCounter << " Message " << fMessageCounter << " EquipmentID " << eqID << "not known."; - break; - } - - TString spadic=""; - switch (sourceA) { - case (SpadicBaseAddress+0): // first spadic - spadic="Spadic0"; - SpaId = 0; - break; - case (SpadicBaseAddress+1): // first spadic - spadic="Spadic0"; - SpaId = 1; - chID += 16; - break; - case (SpadicBaseAddress+2): // second spadic - spadic="Spadic1"; - SpaId = 2; - break; - case (SpadicBaseAddress+3): // second spadic - spadic="Spadic1"; - SpaId = 3; - chID += 16; - break; - case (SpadicBaseAddress+4): // third spadic - spadic="Spadic2"; - SpaId = 4; - break; - case (SpadicBaseAddress+5): // third spadic - spadic="Spadic2"; - SpaId = 5; - chID += 16; - break; - default: - LOG(error) << "Container " << fContainerCounter << " Message " << fMessageCounter << " Source Address " << sourceA << "not known."; - break; - } - - if (SysId > 0 || SpaId > 1) continue; - eventCounter++; - maxAdcTimeBin= -1; - maxAdc = -300; - - chID = dummy->GetChannelOnPadPlane(chID);//channelMapping[chID];// Remapping from ASIC to pad-plane - - columnId = dummy->GetColumnID(raw); - rowId = dummy->GetRowID(raw); - - // combiId = rowId * (maxNrColumns + 1) + columnId; (VF) not used - - fRawpulse->Reset(); - /* - if (eventCounter % 10 == 0){ - for (Int_t pad = 1; pad <=32; pad++) { - fMonitor->cd(pad); - fRawpulse->DrawCopy(); - } - } - */ - for (Int_t iBin = 0; iBin < raw->GetNrSamples(); iBin++){ - fRawpulse->SetBinContent(iBin+1,raw->GetSamples()[iBin]); - if (maxAdc <= raw->GetSamples()[iBin]){ - maxAdcTimeBin = iBin; - maxAdc = raw->GetSamples()[iBin]; - } - } - if (maxAdcTimeBin < 15 && maxAdc > -175 && raw->GetSamples()[raw->GetNrSamples()-1] < -175){ - fS_N->Fill(1);//Signal - fRawpulse->SetLineColor(2); - fSignalMap->Fill(columnId,rowId); - } else { - fS_N->Fill(0);//Noise - fRawpulse->SetLineColor(15); - } - fMonitor->cd(chID+1); - fRawpulse->DrawCopy("same"); - if (eventCounter % 10 == 0) - fMonitor->Update(); - } //entriesInMessage - fMonitor->Update(); - fRawpulse->Reset(); - for (Int_t iBin = 0; iBin < 32; iBin++){ - fRawpulse->SetBinContent(iBin+1,-256); - } - for (Int_t pad = 1; pad <=32; pad++) { - fMonitor->cd(pad); - fRawpulse->DrawCopy(); - } - fRatio->cd(1)->SetLogy(1); - fS_N->DrawCopy(); - fRatio->cd(2); - fSignalMap->DrawCopy("colz"); - fRatio->Update(); -} - - // ---- Finish -------------------------------------------------------- - void CbmTrdRawPulseMonitor::Finish() - { - LOG(debug) << "Finish of CbmTrdRawPulseMonitor"; - // Update Histos and Canvases - - LOG(info) << "CbmTrdRawPulseMonitor::Finish Container: " << fContainerCounter; - LOG(info) << "CbmTrdRawPulseMonitor::Finish Messages: " << fMessageCounter; - } - - ClassImp(CbmTrdRawPulseMonitor) diff --git a/beamtime/cern2014/tasks/CbmTrdRawPulseMonitor.h b/beamtime/cern2014/tasks/CbmTrdRawPulseMonitor.h deleted file mode 100644 index 29868bbc87e918fc8036fe1985c837fb64c0c65a..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/tasks/CbmTrdRawPulseMonitor.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef CBMTRDRAWPULSEMONITOR_H -#define CBMTRDRAWPULSEMONITOR_H - -#include "FairTask.h" -#include "CbmHistManager.h" -#include "CbmSpadicRawMessage.h" -#include "TClonesArray.h" -#include "TCanvas.h" - -class CbmTrdRawPulseMonitor : public FairTask -{ - public: - - /** Default constructor **/ - CbmTrdRawPulseMonitor(); - - /** Constructor with parameters (Optional) **/ - // CbmTrdRawPulseMonitor(Int_t verbose); - - - /** Destructor **/ - ~CbmTrdRawPulseMonitor(); - - - /** Initiliazation of task at the beginning of a run **/ - virtual InitStatus Init(); - - /** ReInitiliazation of task when the runID changes **/ - virtual InitStatus ReInit(); - - - /** Executed for each event. **/ - virtual void Exec(Option_t* opt); - - /** Load the parameter container from the runtime database **/ - virtual void SetParContainers(); - - /** Finish task called at the end of the run **/ - virtual void Finish(); - - private: - - /** Input array from previous already existing data level **/ - TClonesArray* fRawSpadic; - /** Output array **/ - TCanvas *fMonitor; - TCanvas *fRatio; - TH1I* fRawpulse; - TH1I* fS_N; - TH2I* fSignalMap; - - CbmHistManager* fHM; - - Int_t fMessageCounter; - Int_t fContainerCounter; - - CbmTrdRawPulseMonitor(const CbmTrdRawPulseMonitor&); - CbmTrdRawPulseMonitor operator=(const CbmTrdRawPulseMonitor&); - - ClassDef(CbmTrdRawPulseMonitor,2); -}; - -#endif diff --git a/beamtime/cern2014/unpacker/CbmGet4v1xDef.h b/beamtime/cern2014/unpacker/CbmGet4v1xDef.h deleted file mode 100644 index efe7b9eac37a7e2d919c3cdc69c589a65f14243a..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/unpacker/CbmGet4v1xDef.h +++ /dev/null @@ -1,85 +0,0 @@ -#ifndef GET4_V1_X_DEF_H -#define GET4_V1_X_DEF_H - -// ROOT headers -//#include "Rtypes.h" - -namespace get4v1x { - - enum Get4Message32bTypes { - GET4_32B_EPOCH = 0, - GET4_32B_SLCM = 1, - GET4_32B_ERROR = 2, - GET4_32B_DATA = 3 - }; - - enum Get4Message32bSlC { - GET4_32B_SLC_SCALER = 0, - GET4_32B_SLC_DEADT = 1, - GET4_32B_SLC_SPIREAD = 2, - GET4_32B_SLC_START_SEU = 3 - }; - - enum Get4Message32bErrors { - GET4_V1X_ERR_READ_INIT = 0x00, - GET4_V1X_ERR_SYNC = 0x01, - GET4_V1X_ERR_EP_CNT_SYNC = 0x02, - GET4_V1X_ERR_EP = 0x03, - GET4_V1X_ERR_FIFO_WRITE = 0x04, - GET4_V1X_ERR_LOST_EVT = 0x05, - GET4_V1X_ERR_CHAN_STATE = 0x06, - GET4_V1X_ERR_TOK_RING_ST = 0x07, - GET4_V1X_ERR_TOKEN = 0x08, - GET4_V1X_ERR_READOUT_ERR = 0x09, - GET4_V1X_ERR_SPI = 0x0A, - GET4_V1X_ERR_DLL_LOCK = 0x0B, - GET4_V1X_ERR_DLL_RESET = 0x0C, - GET4_V1X_ERR_TOT_OVERWRT = 0x11, - GET4_V1X_ERR_TOT_RANGE = 0x12, - GET4_V1X_ERR_EVT_DISCARD = 0x13, - GET4_V1X_ERR_UNKNOWN = 0x7F - }; - // Hardware max Number - const uint32_t kuMaxRoc = 15; - const uint32_t kuMaxGet4 = 128; // For ROC v3 - const uint32_t kuMaxGet4PerRoc = 64; // For ROC v3 - const uint32_t kuChanPerGet4 = 4; - const uint32_t kuGet4PerFee = 8; - const uint32_t kuChanPerFee = kuChanPerGet4 * kuGet4PerFee; - - - // Size of one clock cycle (=1 coarse bin) - const double kdClockCycleSize = 6400.0; //[ps] - // TODO:For now make 100ps default, maybe need later an option for it - const double kdTotBinSize = 100.0; //ps - - const uint32_t kuFineTime = 0x0000007F; // Fine Counter value - const uint32_t kuFtShift = 0; // Fine Counter offset - const uint32_t kuCoarseTime = 0x0007FF80; // Coarse Counter value - const uint32_t kuCtShift = 7; // Coarse Counter offset - - const uint32_t kuFineCounterSize = ( (kuFineTime>>kuFtShift)+1 ); - const uint32_t kuCoarseCounterSize = ( (kuCoarseTime>>kuCtShift)+1 ); - const uint32_t kuCoarseOverflowTest = kuCoarseCounterSize / 2 ; // Limit for overflow check - const uint32_t kuTotCounterSize = 256; - - // Nominal bin size of NL are neglected - const double kdBinSize = kdClockCycleSize / static_cast<double>(kuFineTime + 1); - // Epoch Size in bins - const uint32_t kuEpochInBins = kuFineTime + kuCoarseTime + 1; - // Epoch Size in ps - // alternatively: (kiCoarseTime>>kiCtShift + 1)*kdClockCycleSize - const double kdEpochInPs = kuEpochInBins*kdBinSize; - - // Size of the epoch counters in ROC messages - const uint64_t kulMainEpochCycleSz = 0xFFFFFFFFuLL; // for ROC 250.00 MHz clock - const uint64_t kulGet4EpochCycleSz = 0x00FFFFFFuLL; // for GET4 156.25 MHz clock in 32b mode (Hack) - const uint64_t kul24bGet4EpochCycleSz = 0xFFFFFFFFuLL; // for GET4 156.25 MHz clock in 24b mode (ROC check) - - // Size of the nominal SYNC cycles - // (aka nb of epoch between 2 epochs with SYNC flag when no problem) - const uint32_t kuSyncCycleSzMain = 40; - const uint32_t kuSyncCycleSzGet4 = 25; -} - -#endif // GET4_V1_X_DEF_H diff --git a/beamtime/cern2014/unpacker/CbmGet4v1xHackDef.cxx b/beamtime/cern2014/unpacker/CbmGet4v1xHackDef.cxx deleted file mode 100644 index 2b0475c05e725ccc340cffd89eeed13cda165bb1..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/unpacker/CbmGet4v1xHackDef.cxx +++ /dev/null @@ -1,861 +0,0 @@ -#include "CbmGet4v1xHackDef.h" - -// Specific headers -#include "CbmGet4v1xDef.h" - -// FAIRROOT headers -#include "FairLogger.h" - -// ROOT headers -#include "TString.h" - -// std C++ lib headers -#include <stdio.h> -#include <string.h> - -#include <iostream> -//#include <stdint.h> - - -bool get4v1x::Message::convertFromOld(void* src) -{ - data = 0; - - uint8_t* arr = static_cast<uint8_t*> (src); - - setMessageType((arr[0] >> 5) & 0x7); - setRocNumber((arr[0] >> 2) & 0x7); - - switch (getMessageType()) { - case MSG_HIT: - setNxNumber(arr[0] & 0x3); - setNxLtsMsb((arr[1] >> 5) & 0x7); - setNxTs(((arr[1] & 0x1f) << 9) | (arr[2] << 1) | (arr[3] >> 7)); - setNxChNum(arr[3] & 0x7f); - setNxAdcValue(((arr[4] & 0x7f) << 5) | ((arr[5] & 0xf8) >> 3)); - setNxPileup((arr[5] >> 2) & 0x1); - setNxOverflow((arr[5] >> 1) & 0x1); - setNxLastEpoch(arr[5] & 0x1); - break; - - case MSG_EPOCH: - setEpochNumber((arr[1] << 24) | (arr[2] << 16) | (arr[3] << 8) | arr[4]); - setEpochMissed(arr[5]); - break; - - case MSG_SYNC: - setSyncChNum(arr[0] & 0x3); - setSyncEpochLSB(arr[1] >> 7); - setSyncTs(((arr[1] & 0x7f) << 7) | ((arr[2] & 0xfc) >> 1)); - setSyncData(((arr[2] & 0x3) << 22) | (arr[3] << 14) | (arr[4] << 6) | (arr[5] >> 2)); - setSyncStFlag(arr[5] & 0x3); - break; - - case MSG_AUX: - setAuxChNum(((arr[0] & 0x3) << 5) | ((arr[1] & 0xf8) >> 3)); - setAuxEpochLSB((arr[1] & 0x4) >> 2); - setAuxTs(((arr[1] & 0x3) << 12) | (arr[2] << 4) | ((arr[3] & 0xe0) >> 4)); - setAuxFalling((arr[3] >> 4) & 1); - setAuxOverflow((arr[3] >> 3) & 1); - break; - - case MSG_SYS: - setSysMesType(arr[1]); - setSysMesData((arr[2] << 24) | (arr[3] << 16) | (arr[4] << 8) | arr[5]); - break; - - default: - return false; - } - - return true; -} - - -bool get4v1x::Message::convertToOld(void* tgt) -{ - uint8_t* data_in = static_cast<uint8_t*> (tgt); - for (int n=0;n<6;n++) data_in[n] = 0; - - data_in[0] = ((getMessageType() & 0x7) << 5) | ((getRocNumber() & 0x7) << 2); - - switch (getMessageType()) { - case MSG_HIT: - data_in[0] = data_in[0] | (getNxNumber() & 0x3); - data_in[1] = ((getNxTs() >> 9) & 0x1f) | ((getNxLtsMsb() << 5) & 0xe0); - data_in[2] = (getNxTs() >> 1); - data_in[3] = ((getNxTs() << 7) & 0x80) | (getNxChNum() & 0x7f); - data_in[4] = (getNxAdcValue() >> 5) & 0x7f; - data_in[5] = ((getNxAdcValue() << 3) & 0xf8) | - (getNxLastEpoch() & 0x1) | - ((getNxOverflow() & 0x1) << 1) | - ((getNxPileup() & 0x1) << 2); - break; - - case MSG_EPOCH: - data_in[1] = (getEpochNumber() >> 24) & 0xff; - data_in[2] = (getEpochNumber() >> 16) & 0xff; - data_in[3] = (getEpochNumber() >> 8) & 0xff; - data_in[4] = getEpochNumber() & 0xff; - data_in[5] = getEpochMissed(); - break; - - case MSG_SYNC: - data_in[0] = data_in[0] | (getSyncChNum() & 0x3); - data_in[1] = (getSyncEpochLSB() << 7) | ((getSyncTs() >> 7) & 0x7f); - data_in[2] = ((getSyncTs() << 1) & 0xfc) | ((getSyncData() >> 22) & 0x3); - data_in[3] = (getSyncData() >> 14) & 0xff; - data_in[4] = (getSyncData() >> 6) & 0xff; - data_in[5] = ((getSyncData() << 2) & 0xfc) | (getSyncStFlag() & 0x3); - break; - - case MSG_AUX: - data_in[0] = data_in[0] | ((getAuxChNum() >> 5) & 0x3); - data_in[1] = ((getAuxChNum() << 3) & 0xf8) | - ((getAuxEpochLSB() << 2) & 0x4) | - ((getAuxTs() >> 12) & 0x3); - data_in[2] = (getAuxTs() >> 4) & 0xff; - data_in[3] = ((getAuxTs() << 4) & 0xe0) | - (getAuxFalling() << 4) | - (getAuxOverflow() << 3); - break; - - case MSG_SYS: - data_in[1] = getSysMesType(); - data_in[2] = (getSysMesData() >> 24) & 0xff; - data_in[3] = (getSysMesData() >> 16) & 0xff; - data_in[4] = (getSysMesData() >> 8) & 0xff; - data_in[5] = getSysMesData() & 0xff; - break; - - default: - return false; - } - - return true; -} - - -//---------------------------------------------------------------------------- -//! Returns expanded and adjusted time of message (in ns) -//! epoch should correspond to the message type - epoch2 for Get4, epoch for all others -//! When converting from GET4 (156Mhz) to SYNC (250 Mhz) clock, one should take into account -//! that initial value of 250 MHz timestamp counter is 0x80 or 512 ns. Therefore such offset -//! should be applied during conversion - -uint64_t get4v1x::Message::getMsgFullTime(uint32_t epoch) const -{ - switch (getMessageType()) { - case MSG_HIT: - return FullTimeStamp(getNxLastEpoch() ? epoch - 1 : epoch, getNxTs()); - case MSG_EPOCH: - return FullTimeStamp(getEpochNumber(), 0); - case MSG_SYNC: - return FullTimeStamp((getSyncEpochLSB() == (epoch & 0x1)) ? epoch : epoch - 1, getSyncTs()); - case MSG_AUX: - return FullTimeStamp((getAuxEpochLSB() == (epoch & 0x1)) ? epoch : epoch - 1, getAuxTs()); - case MSG_EPOCH2: - return FullTimeStamp2(getEpoch2Number(), 0) / 20 + 512; - case MSG_GET4: - return FullTimeStamp2(epoch, getGet4Ts()) / 20 + 512; - case MSG_SYS: - return FullTimeStamp(epoch, 0); - - } - return 0; -} - -//---------------------------------------------------------------------------- -//! strict weak ordering operator, assumes same epoch for both messages -bool get4v1x::Message::operator<(const Message& other) const -{ - uint64_t uThisTs = 0; - uint64_t uOtherTs = 0; - - // if both GET4 32b messages, use the full timestamp info - if( MSG_SYS == this->getMessageType() && - SYSMSG_GET4V1_32BIT_0 <= this->getSysMesType() && - MSG_SYS == other.getMessageType() && - SYSMSG_GET4V1_32BIT_0 <= other.getSysMesType() ) - { - uThisTs = this->getGet4V10R32HitTimeBin(); - uOtherTs = other.getGet4V10R32HitTimeBin(); - return uThisTs < uOtherTs; - } // both GET4 32b - - // First find the timestamp of the current message - if( MSG_SYS == this->getMessageType() && - SYSMSG_GET4V1_32BIT_0 <= this->getSysMesType() ) - { - if( GET4_32B_DATA == this->getGet4V10R32MessageType() ) - uThisTs = ( this->getGet4V10R32HitTimeBin() ) / 20 + 512; - else uThisTs = 0; - } // if 32b GET4 message - else uThisTs = this->getMsgFullTime( 0 ); - - // Then find the timestamp of the current message - if( MSG_SYS == other.getMessageType() && - SYSMSG_GET4V1_32BIT_0 <= other.getSysMesType() ) - { - if( GET4_32B_DATA == other.getGet4V10R32MessageType() ) - uOtherTs = ( other.getGet4V10R32HitTimeBin() ) / 20 + 512; - else uOtherTs = 0; - } // if 32b GET4 message - else uOtherTs = other.getMsgFullTime( 0 ); - - return uThisTs < uOtherTs; -} -//---------------------------------------------------------------------------- -//! Returns expanded and adjusted time of message in double (in ns) -//! epoch should correspond to the message type - epoch2 for Get4, epoch for all others - -double get4v1x::Message::getMsgFullTimeD(uint32_t epoch) const -{ - switch (getMessageType()) { - case MSG_EPOCH2: - return FullTimeStamp2(getEpoch2Number(), 0) / 20. + 512.; - case MSG_GET4: - return FullTimeStamp2(epoch, getGet4Ts()) / 20. + 512.; - } - return getMsgFullTime(epoch); -} - - -//---------------------------------------------------------------------------- -//! Returns the time difference between two expanded time stamps - -uint64_t get4v1x::Message::CalcDistance(uint64_t start, uint64_t stop) -{ - if (start>stop) { - stop += 0x3FFFFFFFFFFFLLU; - if (start>stop) { - printf("Epochs overflow error in CalcDistance\n"); - return 0; - } - } - - return stop - start; -} - - -//---------------------------------------------------------------------------- -//! Returns the time difference between two expanded time stamps - -double get4v1x::Message::CalcDistanceD(double start, double stop) -{ - if (start>stop) { - stop += 0x3FFFFFFFFFFFLLU; - if (start>stop) { - printf("Epochs overflow error in CalcDistanceD\n"); - return 0.; - } - } - - return stop - start; -} - - - -//---------------------------------------------------------------------------- -//! Print message in human readable format to \a cout. -/*! - * Prints a one line representation of the message in to \a cout. - * See printData(std::ostream&, unsigned, uint32_t) const for full - * documentation. - */ - -void get4v1x::Message::printDataCout(unsigned kind, uint32_t epoch) const -{ - printData(msg_print_Cout, kind, epoch); -} - -//---------------------------------------------------------------------------- -//! Print message in human readable format to the Fairroot logger. -/*! - * Prints a one line representation of the message in to the Fairroot logger. - * TODO: Add coloring of possible - * See printData(std::ostream&, unsigned, uint32_t) const for full - * documentation. - */ - -void get4v1x::Message::printDataLog(unsigned kind, uint32_t epoch) const -{ - printData(msg_print_FairLog, kind, epoch); -} - -//---------------------------------------------------------------------------- -//! Print message in binary or human readable format to a stream. -/*! - * Prints a one line representation of the message in to a stream, selected by \a outType. - * The stream is \a cout if \a outType is kFALSE and \a FairLogger if \a outType is kTRUE. - * The parameter \a kind is mask with 4 bits - * \li get4v1x::msg_print_Prefix (1) - ROC number and message type - * \li get4v1x::msg_print_Data (2) - print all message specific data fields - * \li get4v1x::msg_print_Hex (4) - print data as hex dump - * \li get4v1x::msg_print_Human (8) - print in human readable format - * - * If bit msg_print_Human in \a kind is not set, raw format - * output is generated. All data fields are shown in hexadecimal. - * This is the format of choice when chasing hardware problems at the bit level. - * - * If bit msg_print_Human is set, a more human readable output is generated. - * The timestamp is shown as fully extended and adjusted time as - * returned by the getMsgFullTime(uint32_t) const method. - * All data fields are represented in decimal. - * - * \param os output stream - * \param kind mask determing output format - * \param epoch current epoch number (from last epoch message) - * - * Typical message output in human format looks like -\verbatim -Msg:7 Roc:1 SysType: 1 Nx:0 Data: 0 : DAQ started -Msg:7 Roc:1 SysType: 6 Nx:0 Data: 0 : FIFO reset -Msg:2 Roc:1 EPO @ 0.536870912 Epo: 32768 0x00008000 Miss: 0 -Msg:0 Roc:0 NOP (raw 80:40:82:0F:00:00) -Msg:2 Roc:1 EPO @ 0.646627328 Epo: 39467 0x00009a2b Miss: 0 -Msg:1 Roc:1 HIT @ 0.646614333 Nx:2 Chn: 12 Ts: 3389-e( 8) Adc:2726 Pu:0 Of:0 -Msg:1 Roc:1 HIT @ 0.646630717 Nx:2 Chn: 13 Ts: 3389 ( 0) Adc:2745 Pu:0 Of:0 -Msg:2 Roc:1 EPO @ 0.805306368 Epo: 49152 0x0000c000 Miss: 0 -Msg:3 Roc:1 SYN @ 0.805306408 Chn:2 Ts: 40 Data: 49152 0x00c000 Flag:0 -Msg:7 Roc:1 SysType: 2 Nx:0 Data: 0 : DAQ finished -\endverbatim - * - * Typical message output in binary format looks like -\verbatim -Msg:7 Roc:1 SysType: 1 Nx:0 Data: 0 : DAQ started -Msg:7 Roc:1 SysType: 6 Nx:0 Data: 0 : FIFO reset -Msg:2 Roc:1 Epoch:00008000 Missed:00 -Msg:1 Roc:1 Nx:2 Chn:0d Ts:3ec9 Last:1 Msb:7 Adc:a22 Pup:0 Oflw:0 -Msg:1 Roc:1 Nx:2 Chn:0e Ts:3ec9 Last:0 Msb:7 Adc:a18 Pup:0 Oflw:0 -Msg:0 Roc:0 NOP (raw 80:40:82:0F:00:00) -Msg:2 Roc:1 Epoch:00010000 Missed:00 -Msg:3 Roc:1 SyncChn:2 EpochLSB:0 Ts:0028 Data:010000 Flag:0 -Msg:7 Roc:1 SysType: 2 Nx:0 Data: 0 : DAQ finished -\endverbatim - */ - -//void get4v1x::Message::printData(std::ostream& os, unsigned kind, uint32_t epoch) const -void get4v1x::Message::printData(unsigned outType, unsigned kind, uint32_t epoch) const -{ - char buf[256]; - // Use a TString in case of FairLogger as the log level is decided only later - TString sLogBuff = ""; - - if (kind & msg_print_Hex) { -// uint8_t* arr = static_cast<uint8_t*> ( &data ); - uint8_t* arr = (uint8_t*) ( &data ); - snprintf(buf, sizeof(buf), "%02X:%02X:%02X:%02X:%02X:%02X ", - arr[0], arr[1], arr[2], arr[3], arr[4], arr[5]); -// os << buf; - if( msg_print_Cout == outType) - std::cout << buf; - else sLogBuff = TString::Format("%s", buf ); - } - - if (kind & msg_print_Human) { - double timeInSec = getMsgFullTimeD(epoch)/1.e9; - int fifoFill = 0; - - switch (getMessageType()) { - case MSG_HIT: - fifoFill = getNxLtsMsb() - ((getNxTs()>>11)&0x7); - if (getNxLastEpoch()) fifoFill += 8; - snprintf(buf, sizeof(buf), - "Msg:%u Roc:%u ", getMessageType(), getRocNumber()); -// os << buf; - if( msg_print_Cout == outType) - std::cout << buf; - else sLogBuff = TString::Format("%s", buf ); - - snprintf(buf, sizeof(buf), - "HIT @%15.9f Nx:%d Chn:%3d Ts:%5d%s(%2d) Adc:%4d Pu:%d Of:%d", - timeInSec, getNxNumber(), getNxChNum(), getNxTs(), - (getNxLastEpoch() ? "-e" : " "), - fifoFill, getNxAdcValue(), getNxPileup(), getNxOverflow()); -// os << buf << std::endl; - if( msg_print_Cout == outType) - std::cout << buf << std::endl; - else LOG(info) << sLogBuff << buf; - break; - case MSG_EPOCH: - snprintf(buf, sizeof(buf), - "Msg:%u Roc:%u ", getMessageType(), getRocNumber()); -// os << buf; - if( msg_print_Cout == outType) - std::cout << buf; - else sLogBuff = TString::Format("%s", buf ); - - snprintf(buf, sizeof(buf), - "EPO @%15.9f Epo:%10u 0x%08x Miss: %3d%c", - timeInSec, getEpochNumber(), getEpochNumber(), - getEpochMissed(), (getEpochMissed()==0xff) ? '+' : ' '); -// os << buf << std::endl; - if( msg_print_Cout == outType) - std::cout << buf << std::endl; - else LOG(info) << sLogBuff << buf; - break; - case MSG_SYNC: - snprintf(buf, sizeof(buf), - "Msg:%u Roc:%u ", getMessageType(), getRocNumber()); -// os << buf; - if( msg_print_Cout == outType) - std::cout << buf; - else sLogBuff = TString::Format("%s", buf ); - - snprintf(buf, sizeof(buf), - "SYN @%15.9f Chn:%d Ts:%5d%s Data:%8d 0x%06x Flag:%d", - timeInSec, getSyncChNum(), getSyncTs(), - ((getSyncEpochLSB() != (epoch&0x1)) ? "-e" : " "), - getSyncData(), getSyncData(), getSyncStFlag()); -// os << buf << std::endl; - if( msg_print_Cout == outType) - std::cout << buf << std::endl; - else LOG(info) << sLogBuff << buf; - break; - case MSG_AUX: - snprintf(buf, sizeof(buf), - "Msg:%u Roc:%u ", getMessageType(), getRocNumber()); -// os << buf; - if( msg_print_Cout == outType) - std::cout << buf; - else sLogBuff = TString::Format("%s", buf ); - - snprintf(buf, sizeof(buf), - "AUX @%15.9f Chn:%d Ts:%5d%s Falling:%d Overflow:%d", - timeInSec, getAuxChNum(), getAuxTs(), - ((getAuxEpochLSB() != (epoch&0x1)) ? "-e" : " "), - getAuxFalling(), getAuxOverflow()); -// os << buf << std::endl; - if( msg_print_Cout == outType) - std::cout << buf << std::endl; - else LOG(info) << sLogBuff << buf; - break; - case MSG_EPOCH2: - snprintf(buf, sizeof(buf), - "Msg:%u Roc:%u ", getMessageType(), getRocNumber()); -// os << buf; - if( msg_print_Cout == outType) - std::cout << buf; - else sLogBuff = TString::Format("%s", buf ); - - snprintf(buf, sizeof(buf), - "EPO2 @%17.11f Get4:%2d Epoche2:%10u 0x%08x StampTime:%2d Sync:%x Dataloss:%x Epochloss:%x Epochmissmatch:%x", - timeInSec, getEpoch2ChipNumber(), getEpoch2Number(), getEpoch2Number(), - getEpoch2StampTime(), getEpoch2Sync(), getEpoch2DataLost(), getEpoch2EpochLost(), getEpoch2EpochMissmatch()); -// os << buf << std::endl; - if( msg_print_Cout == outType) - std::cout << buf << std::endl; - else LOG(info) << sLogBuff << buf; - break; - case MSG_GET4: - snprintf(buf, sizeof(buf), - "Msg:%u Roc:%u ", getMessageType(), getRocNumber()); -// os << buf; - if( msg_print_Cout == outType) - std::cout << buf; - else sLogBuff = TString::Format("%s", buf ); - - snprintf(buf, sizeof(buf), - "Get4 @%17.11f Get4:%2d Chn:%3d Edge:%1d Ts:%7d CRC8:%3d", - timeInSec, getGet4Number(), getGet4ChNum(), getGet4Edge(), getGet4Ts(), getGet4CRC() ); -// os << buf << std::endl; - if( msg_print_Cout == outType) - std::cout << buf << std::endl; - else LOG(info) << sLogBuff << buf; - break; - default: - kind = kind & ~msg_print_Human; - if (kind==0) kind = msg_print_Prefix | msg_print_Data; - } - - // return, if message was correctly printed in human-readable form - if (kind & msg_print_Human) return; - } - - if (kind & msg_print_Prefix) { - snprintf(buf, sizeof(buf), "Msg:%u Roc:%u ", getMessageType(), getRocNumber()); -// os << buf; - if( msg_print_Cout == outType) - std::cout << buf; - else sLogBuff = TString::Format("%s", buf ); - } - - if (kind & msg_print_Data) { -// uint8_t* arr = static_cast<uint8_t*> ( &data ); - uint8_t* arr = (uint8_t*) ( &data ); - switch (getMessageType()) { - case MSG_NOP: - snprintf(buf, sizeof(buf), "NOP (raw %02X:%02X:%02X:%02X:%02X:%02X)", - arr[0], arr[1], arr[2], arr[3], arr[4], arr[5]); - break; - case MSG_HIT: - snprintf(buf, sizeof(buf), "Nx:%1x Chn:%02x Ts:%04x Last:%1x Msb:%1x Adc:%03x Pup:%1x Oflw:%1x", - getNxNumber(), getNxChNum(), getNxTs(), getNxLastEpoch(), - getNxLtsMsb(), getNxAdcValue(), getNxPileup(), - getNxOverflow()); - break; - case MSG_EPOCH: - snprintf(buf, sizeof(buf), "Epoch:%08x Missed:%02x", - getEpochNumber(), getEpochMissed()); - break; - case MSG_SYNC: - snprintf(buf, sizeof(buf), "SyncChn:%1x EpochLSB:%1x Ts:%04x Data:%06x Flag:%1x", - getSyncChNum(), getSyncEpochLSB(), getSyncTs(), - getSyncData(), getSyncStFlag()); - break; - case MSG_AUX: - snprintf(buf, sizeof(buf), "AuxChn:%02x EpochLSB:%1x Ts:%04x Falling:%1x Overflow:%1x", - getAuxChNum(), getAuxEpochLSB(), getAuxTs(), - getAuxFalling(), getAuxOverflow()); - break; - case MSG_EPOCH2: - snprintf(buf, sizeof(buf), "Get4:0x%02x Epoche2:0x%08x StampTime:0x%x Sync:%x Dataloss:%x Epochloss:%x Epochmissmatch:%x", - getEpoch2ChipNumber(), getEpoch2Number(), getEpoch2StampTime(), getEpoch2Sync(), - getEpoch2DataLost(), getEpoch2EpochLost(), getEpoch2EpochMissmatch()); - break; - case MSG_GET4: - snprintf(buf, sizeof(buf), "Get4:0x%02x Chn:%1x Edge:%1x Ts:0x%05x CRC8:0x%02x (CT:%5u FT:%3u)", - getGet4Number(), getGet4ChNum(), getGet4Edge(), getGet4Ts(), getGet4CRC(), getGet4CoarseTs(), getGet4FineTs() ); - break; - case MSG_SYS: { - char sysbuf[256]; - - switch (getSysMesType()) { - case SYSMSG_DAQ_START: - snprintf(sysbuf, sizeof(sysbuf), "DAQ started"); - break; - case SYSMSG_DAQ_FINISH: - snprintf(sysbuf, sizeof(sysbuf), "DAQ finished"); - break; - case SYSMSG_NX_PARITY: { - uint32_t nxb3_data = getSysMesData(); - uint32_t nxb3_flg = (nxb3_data>>31) & 0x01; - uint32_t nxb3_val = (nxb3_data>>24) & 0x7f; - uint32_t nxb2_flg = (nxb3_data>>23) & 0x01; - uint32_t nxb2_val = (nxb3_data>>16) & 0x7f; - uint32_t nxb1_flg = (nxb3_data>>15) & 0x01; - uint32_t nxb1_val = (nxb3_data>>8 ) & 0x7f; - uint32_t nxb0_flg = (nxb3_data>>7 ) & 0x01; - uint32_t nxb0_val = (nxb3_data ) & 0x7f; - snprintf(sysbuf, sizeof(sysbuf),"Nx:%1x %1d%1d%1d%1d:%02x:%02x:%02x:%02x nX parity error", getNxNumber(), - nxb3_flg, nxb2_flg, nxb1_flg, nxb0_flg, - nxb3_val, nxb2_val, nxb1_val, nxb0_val); - } - break; - case SYSMSG_SYNC_PARITY: - snprintf(sysbuf, sizeof(sysbuf), "SYNC parity error "); - break; - case SYSMSG_DAQ_RESUME: - snprintf(sysbuf, sizeof(sysbuf), "DAQ resume after high/low water"); - break; - case SYSMSG_FIFO_RESET: - snprintf(sysbuf, sizeof(sysbuf), "FIFO reset"); - break; - case SYSMSG_USER: { - const char* subtyp = ""; - if (getSysMesData()==SYSMSG_USER_CALIBR_ON) subtyp = "Calibration ON"; else - if (getSysMesData()==SYSMSG_USER_CALIBR_OFF) subtyp = "Calibration OFF"; else - if (getSysMesData()==SYSMSG_USER_RECONFIGURE) subtyp = "Reconfigure"; - snprintf(sysbuf, sizeof(sysbuf), "User message 0x%08x %s", getSysMesData(), subtyp); - break; - } - case SYSMSG_PACKETLOST: - snprintf(sysbuf, sizeof(sysbuf), "Packet lost"); - break; - case SYSMSG_GET4_EVENT: - { - // 24b GET4 Error event - uint32_t get4_24b_er_chan = getGet4V10R24ErrorChan(); - uint32_t get4_24b_er_edge = getGet4V10R24ErrorEdge(); - uint32_t get4_24b_er_unus = getGet4V10R24ErrorUnused(); - uint32_t get4_24b_er_chip = getGet4V10R24ErrorChip(); - uint32_t get4_24b_er_code = getGet4V10R24ErrorData(); - - snprintf(sysbuf, sizeof(sysbuf), - "Get4:0x%02x Ch:0x%01x Edge:%01x Unused:%04x ErrCode:0x%02x - GET4 V1 Error Event", - get4_24b_er_chip, get4_24b_er_chan, get4_24b_er_edge, get4_24b_er_unus, get4_24b_er_code); - - /* - // For csv files output - snprintf(sysbuf, sizeof(sysbuf), - "Get4 V1 24 bits, chip %02d, type:0x10 => ;Error ;;;;;;;;;;;;;;%02x ;Channel; %1d ;Edge; %1d;Unused; %4x;", - get4_24b_er_chip, get4_24b_er_code, get4_24b_er_chan, get4_24b_er_edge, get4_24b_er_unus ); - */ - break; - } // - case SYSMSG_CLOSYSYNC_ERROR: - snprintf(sysbuf, sizeof(sysbuf), "Closy synchronization error"); - break; - case SYSMSG_TS156_SYNC: - snprintf(sysbuf, sizeof(sysbuf), "156.25MHz timestamp reset"); - break; - case SYSMSG_GET4V1_32BIT_0: - case SYSMSG_GET4V1_32BIT_1: - case SYSMSG_GET4V1_32BIT_2: - case SYSMSG_GET4V1_32BIT_3: - case SYSMSG_GET4V1_32BIT_4: - case SYSMSG_GET4V1_32BIT_5: - case SYSMSG_GET4V1_32BIT_6: - case SYSMSG_GET4V1_32BIT_7: - case SYSMSG_GET4V1_32BIT_8: - case SYSMSG_GET4V1_32BIT_9: - case SYSMSG_GET4V1_32BIT_10: - case SYSMSG_GET4V1_32BIT_11: - case SYSMSG_GET4V1_32BIT_12: - case SYSMSG_GET4V1_32BIT_13: - case SYSMSG_GET4V1_32BIT_14: - case SYSMSG_GET4V1_32BIT_15: - { - // 32 bits readout mode message - uint32_t get4_32b_chip = getGet4V10R32ChipId(); - uint32_t get4_32b_type = getGet4V10R32MessageType(); - - switch(get4_32b_type) - { - case GET4_32B_EPOCH: // epoch message - { - uint32_t get4_32b_ep_epoch = getGet4V10R32EpochNumber(); - uint32_t get4_32b_ep_sync = getGet4V10R32SyncFlag(); - - snprintf(sysbuf, sizeof(sysbuf), - "Get4 V1 32 bits, chip %02d, type:0x%02x => Epoch 0x%06x Sync: %1d", - get4_32b_chip, get4_32b_type, get4_32b_ep_epoch, get4_32b_ep_sync ); - - /* - snprintf(sysbuf, sizeof(sysbuf), - "Get4 V1 32 bits, type:0x%02x => ;chip;%02d;Epoch; %08d; Sync:; %1d;", - get4_32b_type, get4_32b_chip, get4_32b_ep_epoch, get4_32b_ep_sync ); - */ - break; - } - case GET4_32B_SLCM: // slow control message - { - uint32_t get4_32b_sl_data = getGet4V10R32SlData(); - uint32_t get4_32b_sl_type = getGet4V10R32SlType(); - uint32_t get4_32b_sl_edge = getGet4V10R32SlEdge(); - uint32_t get4_32b_sl_chan = getGet4V10R32SlChan(); - - snprintf(sysbuf, sizeof(sysbuf), - "Get4 V1 32 bits, chip %02d, type:0x%02x => Slow control Chan:%01d Edge:%01d Type:%01x Data:0x%06x", - get4_32b_chip, get4_32b_type, get4_32b_sl_chan, get4_32b_sl_edge, - get4_32b_sl_type, get4_32b_sl_data ); - - /* - // For csv files output - snprintf(sysbuf, sizeof(sysbuf), - "Get4 V1 32 bits, type:0x%02x => ;chip;%02d;Slow control ;;;;;;;;;;;;;;Chan:;%01d ;Edge:;%01d ;Type:;%01x ;Data:;0x%06x;", - get4_32b_type, get4_32b_chip, get4_32b_sl_chan, get4_32b_sl_edge, - get4_32b_sl_type, get4_32b_sl_data ); - */ - break; - } - case GET4_32B_ERROR: // error event - { - uint32_t get4_32b_er_code = getGet4V10R32ErrorData(); - uint32_t get4_32b_er_unus = getGet4V10R32ErrorUnused(); - uint32_t get4_32b_er_chan = getGet4V10R32ErrorChan(); - uint32_t get4_32b_er_edge = getGet4V10R32ErrorEdge(); - - snprintf(sysbuf, sizeof(sysbuf), - "Get4 V1 32 bits, chip %02d, type:0x%02x => Error 0x%02x Channel %1d Edge %1d Unused:%04x", - get4_32b_chip, get4_32b_type, get4_32b_er_code, get4_32b_er_chan, - get4_32b_er_edge, get4_32b_er_unus ); - - /* - // For csv files output - snprintf(sysbuf, sizeof(sysbuf), - "Get4 V1 32 bits, type:0x%02x => ;chip;%02d;Error ;;;;;;;;;;;;;;%02x ;Channel; %1d ;Edge; %1d;Unused; %4x;", - get4_32b_type, get4_32b_chip, get4_32b_er_code, get4_32b_er_chan, - get4_32b_er_edge, get4_32b_er_unus ); - */ - break; - } - case GET4_32B_DATA: // data event - { - uint32_t get4_32b_dat_tot = getGet4V10R32HitTot(); - uint32_t get4_32b_dat_ft = getGet4V10R32HitFt(); - uint32_t get4_32b_dat_ts = getGet4V10R32HitTs(); - uint32_t get4_32b_dat_chan = getGet4V10R32HitChan(); - uint32_t get4_32b_dat_dll = getGet4V10R32HitDllFlag(); - - snprintf(sysbuf, sizeof(sysbuf), - "Get4 V1 32 bits, chip %02d, type:0x%02x => Data Dll %1d Channel %1d Ts:0x%03x Ft:0x%02x Tot:0x%02x", - get4_32b_chip, get4_32b_type, get4_32b_dat_dll, get4_32b_dat_chan, - get4_32b_dat_ts, get4_32b_dat_ft, get4_32b_dat_tot); - - /* - // For csv files output - snprintf(sysbuf, sizeof(sysbuf), - "Get4 V1 32 bits, type:0x%02x => ;chip;%02d;Data ;;;;Dll; %1d ;Channel; %1d ;Ts:;%04d ;Ft:;%03d ;Tot:;%03d;", - get4_32b_type, get4_32b_chip, get4_32b_dat_dll, get4_32b_dat_chan, - get4_32b_dat_ts, get4_32b_dat_ft, get4_32b_dat_tot); - */ - break; - } - default: - snprintf(sysbuf, sizeof(sysbuf), - "Get4 V1 32 bits, unknown type:0x%02x ", get4_32b_type ); - break; - } // switch(get4_32b_type) - //snprintf(sysbuf, sizeof(sysbuf), - // "Get4 V1 32 bits, full data:0x%08x %08x ", getFieldBE(32, 32), getFieldBE(0, 32) ); - - break; - } // case SYSMSG_GET4V1_32BIT + channel! - default: - snprintf(sysbuf, sizeof(sysbuf), "unknown system message type "); - } // switch (getSysMesType()) - - snprintf(buf, sizeof(buf), "SysType:%2x Data:%8x : %s", getSysMesType(), getSysMesData(), sysbuf); - - break; - } // case MSG_SYS: - case MSG_GET4_SLC: - { - // 32b GET4 slow control message, new "true" ROC support - - snprintf(buf, sizeof(buf), - "Get4 V1 32 bits Slow control in \"new true\" readout mode " - "=> not supported, check CbmGet4v1xToolsDef files" ); - break; - } - case MSG_GET4_32B: - { - // 32b GET4 data event, new "true" ROC support - - snprintf(buf, sizeof(buf), - "Get4 V1 32 bits Data in \"new true\" readout mode " - "=> not supported, check CbmGet4v1xToolsDef files" ); - - break; - } // case MSG_GET4_32B: - default: - snprintf(buf, sizeof(buf), "Error - unexpected MessageType: %1x", getMessageType()); - } - } - -// os << buf << std::endl; - if( msg_print_Cout == outType) - std::cout << buf << std::endl; - else LOG(info) << sLogBuff << buf; -} - -uint32_t get4v1x::Message::RawSize(int fmt) -{ - switch (fmt) { - case formatEth1: return 6; - case formatOptic1: return 8; - case formatEth2: return 6; - case formatOptic2: return 8; - case formatNormal: return 8; - } - return 8; -} - -bool get4v1x::Message::assign(void* src, int fmt) -{ - switch (fmt) { - case formatEth1: - convertFromOld(src); - return true; - case formatOptic1: - convertFromOld(static_cast<uint8_t*> ( src ) + 2); - setRocNumber( (*( static_cast<uint8_t*> ( src ) ) << 8) - | *( static_cast<uint8_t*> ( src ) + 1) ); - return true; - case formatEth2: - memcpy(&data, src, 6); - return true; - case formatOptic2: - memcpy(&data, static_cast<uint8_t*> ( src ) + 2, 6); - setRocNumber(*( static_cast<uint16_t*> ( src ) )); - return true; - case formatNormal: - memcpy(&data, src, 8); - return true; - } - - return false; -} - -bool get4v1x::Message::copyto(void* tgt, int fmt) -{ - switch (fmt) { - case formatEth1: - convertToOld(tgt); - return true; - case formatOptic1: - convertToOld( static_cast<uint8_t*> ( tgt ) + 2); - *( static_cast<uint16_t*> ( tgt ) ) = getRocNumber(); - return true; - case formatEth2: - memcpy(tgt, &data, 6); - return true; - case formatOptic2: - memcpy( static_cast<uint8_t*> ( tgt ) + 2, &data, 6); - *( static_cast<uint16_t*> ( tgt ) ) = getRocNumber(); - return true; - case formatNormal: - memcpy(tgt, &data, 8); - return true; - } - - return false; - -} - -double get4v1x::Message::CalcGet4V10R24HitTimeDiff( - uint32_t epochA, uint32_t epochB, Message& messB) -{ - Double_t dTimeDiff = 0.0; - // if conditions needed to deal with unsigned int at full resolution - if( epochA < epochB) - dTimeDiff -= - ( epochB - epochA )*get4v1x::kdEpochInPs; - else dTimeDiff += - ( epochA - epochB )*get4v1x::kdEpochInPs; - // if conditions needed to deal with unsigned int at full resolution - if( this->getGet4Ts() < messB.getGet4Ts() ) - dTimeDiff -= - ( messB.getGet4Ts() - this->getGet4Ts() - )*get4v1x::kdBinSize; - else dTimeDiff += - ( this->getGet4Ts() - messB.getGet4Ts() - )*get4v1x::kdBinSize; - - return dTimeDiff; -} - -double get4v1x::Message::CalcGet4V10R32HitTimeDiff( - uint32_t epochA, uint32_t epochB, Message& messB) -{ - Double_t dTimeDiff = 0.0; - // if conditions needed to deal with unsigned int at full resolution - if( epochA < epochB) - dTimeDiff -= - ( epochB - epochA )*get4v1x::kdEpochInPs; - else dTimeDiff += - ( epochA - epochB )*get4v1x::kdEpochInPs; - // if conditions needed to deal with unsigned int at full resolution - if( this->getGet4V10R32HitTimeBin() < messB.getGet4V10R32HitTimeBin() ) - dTimeDiff -= - ( messB.getGet4V10R32HitTimeBin() - this->getGet4V10R32HitTimeBin() - )*get4v1x::kdBinSize; - else dTimeDiff += - ( this->getGet4V10R32HitTimeBin() - messB.getGet4V10R32HitTimeBin() - )*get4v1x::kdBinSize; - - return dTimeDiff; -} - -//---------------------------------------------------------------------------- -//! strict weak ordering operator, including epoch for both messages -bool get4v1x::FullMessage::operator<(const FullMessage& other) const -{ - if( other.fuExtendedEpoch == this->fuExtendedEpoch ) - // Same epoch => use Message (base) class ordering operator - return this->Message::operator<( other ); - else return this->fuExtendedEpoch < other.fuExtendedEpoch; - -} diff --git a/beamtime/cern2014/unpacker/CbmGet4v1xHackDef.h b/beamtime/cern2014/unpacker/CbmGet4v1xHackDef.h deleted file mode 100644 index f3f0117a4ac565fe0c37eda279b5b981162157d2..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/unpacker/CbmGet4v1xHackDef.h +++ /dev/null @@ -1,594 +0,0 @@ -#ifndef GET4_V1_X_TOOLS_DEF_H -#define GET4_V1_X_TOOLS_DEF_H - - -#ifdef HAVE_UINT8_T_HEADER_FILE -#include <_types/_uint8_t.h> -#include <_types/_uint16_t.h> -#include <_types/_uint32_t.h> -#include <_types/_uint64_t.h> -#else -#include <stdint.h> -#endif - -namespace get4v1x { - - - enum MessageFormat { - formatEth1 = 0, // original message format with big-endian coding, 6-byte - formatOptic1 = 1, // original message format with big-endian coding, add 2 byte send/recv info, 8-byte - formatEth2 = 2, // new message format with little-endian coding, 6-byte - formatOptic2 = 3, // new message format with little-endian coding, add 2 byte send/recv info, 8-byte - formatNormal = 4 // new message format with little-endian coding, 16-bit roc number (default) - }; - - enum MessageTypes { - MSG_NOP = 0, - MSG_HIT = 1, - MSG_EPOCH = 2, - MSG_SYNC = 3, - MSG_AUX = 4, - MSG_EPOCH2 = 5, - MSG_GET4 = 6, - MSG_SYS = 7, - MSG_GET4_SLC = 8, - MSG_GET4_32B = 9 - }; - - enum SysMessageTypes { - SYSMSG_DAQ_START = 1, // indicates start daq in data stream - SYSMSG_DAQ_FINISH = 2, // stop daq - SYSMSG_NX_PARITY = 3, // nx_parity error - SYSMSG_SYNC_PARITY = 4, // sync parity error - SYSMSG_DAQ_RESUME = 5, // daq resume due to low/high water marker, only in udp case - SYSMSG_FIFO_RESET = 6, // FPGA fifo reset - SYSMSG_USER = 7, // user define message, generated by writing into ROC_ADDSYSMSG register - SYSMSG_PCTIME = 8, // contains value of time() function, indicates when message was created on PC - SYSMSG_ADC = 9, // contains feb1d (1 bit), channel id (7 bit) and adc value (24 bit), measured on PC - SYSMSG_PACKETLOST = 10, // inserted by udp transport when packet was lost at this place - SYSMSG_GET4_EVENT = 11, // GET4 event - SYSMSG_CLOSYSYNC_ERROR = 12, // added to data stream when the closy-sync-strobe does not match the rocs 156MHz timestamp counter - SYSMSG_TS156_SYNC = 13, // added when 156MHz timestamp counter is reset by a DLM - SYSMSG_GET4V1_32BIT_0 = 240, // Get4 V1.0, 32bit mode, Raw messages - SYSMSG_GET4V1_32BIT_1 = 241, // Get4 V1.0, 32bit mode, Raw messages - SYSMSG_GET4V1_32BIT_2 = 242, // Get4 V1.0, 32bit mode, Raw messages - SYSMSG_GET4V1_32BIT_3 = 243, // Get4 V1.0, 32bit mode, Raw messages - SYSMSG_GET4V1_32BIT_4 = 244, // Get4 V1.0, 32bit mode, Raw messages - SYSMSG_GET4V1_32BIT_5 = 245, // Get4 V1.0, 32bit mode, Raw messages - SYSMSG_GET4V1_32BIT_6 = 246, // Get4 V1.0, 32bit mode, Raw messages - SYSMSG_GET4V1_32BIT_7 = 247, // Get4 V1.0, 32bit mode, Raw messages - SYSMSG_GET4V1_32BIT_8 = 248, // Get4 V1.0, 32bit mode, Raw messages - SYSMSG_GET4V1_32BIT_9 = 249, // Get4 V1.0, 32bit mode, Raw messages - SYSMSG_GET4V1_32BIT_10 = 250, // Get4 V1.0, 32bit mode, Raw messages - SYSMSG_GET4V1_32BIT_11 = 251, // Get4 V1.0, 32bit mode, Raw messages - SYSMSG_GET4V1_32BIT_12 = 252, // Get4 V1.0, 32bit mode, Raw messages - SYSMSG_GET4V1_32BIT_13 = 253, // Get4 V1.0, 32bit mode, Raw messages - SYSMSG_GET4V1_32BIT_14 = 254, // Get4 V1.0, 32bit mode, Raw messages - SYSMSG_GET4V1_32BIT_15 = 255, // Get4 V1.0, 32bit mode, Raw messages - }; - - enum SysMessageUserTypes { - SYSMSG_USER_CALIBR_ON = 7, - SYSMSG_USER_CALIBR_OFF = 8, - SYSMSG_USER_RECONFIGURE = 9, - SYSMSG_USER_ROCFEET_SYNC = 16 - }; - - enum MessagePrintMask { - msg_print_Prefix = 1, - msg_print_Data = 2, - msg_print_Hex = 4, - msg_print_Human = 8 - }; - - enum MessagePrintType { - msg_print_Cout = 1, - msg_print_FairLog = 2, - }; - - - // Max nb of each external trigger signal type - const uint32_t kuMaxSync = 2; // <- MAX_SYNC - const uint32_t kuMaxAux = 4; // <- MAX_AUX - - class Message { - - protected: - uint64_t data; // main and only storage field for the message - - public: - Message() : data(0) {} - - Message(const Message& src) : data(src.data) {} - - virtual ~Message() {}; - - void assign(const Message& src) { data = src.data; } - - Message& operator=(const Message& src) { assign(src); return *this; } - - inline void reset() { data = 0; } - - inline uint64_t getData() const { return data; } - inline void setData( uint64_t value) { data = value; } - - inline uint32_t getField(uint32_t shift, uint32_t len) const - { return (data >> shift) & (((static_cast<uint32_t>(1)) << len) - 1); } - - inline void setField(uint32_t shift, uint32_t len, uint32_t value) - { data = (data & ~((((static_cast<uint64_t>(1)) << len) - 1) << shift)) | ((static_cast<uint64_t>(value)) << shift); } - - inline uint8_t getBit(uint32_t shift) const - { return (data >> shift) & 1; } - - inline void setBit(uint32_t shift, uint8_t value) - { data = value ? (data | ((static_cast<uint64_t>(1)) << shift)) : (data & ~((static_cast<uint64_t>(1)) << shift)) ; } - - - inline uint32_t getFieldBE(uint32_t shift, uint32_t len) const - { return (dataBE() >> shift) & (((static_cast<uint32_t>(1)) << len) - 1); } - inline uint8_t getBitBE(uint32_t shift) const - { return (dataBE() >> shift) & 1; } - inline uint64_t dataBE() const - { return ((data&0x00000000000000FF)<<56)+ - ((data&0x000000000000FF00)<<40)+ - ((data&0x0000000000FF0000)<<24)+ - ((data&0x00000000FF000000)<< 8)+ - ((data>> 8)&0x00000000FF000000)+ - ((data>>24)&0x0000000000FF0000)+ - ((data>>40)&0x000000000000FF00)+ - ((data>>56)&0x00000000000000FF); - } - - // --------------------------- common fields --------------------------------- - - //! Returns the message type. Valid for all message types. 4 bit - inline uint8_t getMessageType() const { return getField(0, 4); } - - //! Returns the number of the sending ROC. Valid for all message types. - /*! - * The field has full 16 bits and allows to aggregate data of up to 64K ROC's - * in one message stream. - */ - inline uint16_t getRocNumber() const { return getField(48, 16); } - - //! Sets the message type field in the current message - inline void setMessageType(uint8_t v) { setField(0, 4, v); } - - //! Sets the ROC number field in the current message - inline void setRocNumber(uint16_t v) { setField(48, 16, v); } - - - // ---------- nXYTER Hit data access methods ---------------- - - //! For Hit data: Returns nXYTER number (2 bit field) - /*! - * A ROC can support up to 2 FEBs with a total of 4 nXYTER chips. - * This field identifies FEB as well as chip. Each supported - * configuration (either 2 x FEB1nx/FEB2nx or a single FEB4nx) - * as a unique nXYTER chip numbering. - */ - inline uint8_t getNxNumber() const { return getField(6, 2); } - - //! For Hit data: Returns 3 most significant bits of ROC LTS (3 bit field) - /*! - * The 3 MSBs of the ROC local time stamp counter at the time of data - * capture are stored in this field. A comparison of this number, - * which reflects the time of readout, and the 3 MSBs of the timestamp - * (returned by getNxLtsMsb() const), which reflects the time of the - * hit, allows to estimate the time the hit stayed in the nXYTER internal - * FIFOs. This in turn gives an indication of the data load in the - * nXYTER. - */ - inline uint8_t getNxLtsMsb() const { return getField(8, 3); } - - //! For Hit data: Returns nXYTER time stamp (14 bit field) - /*! - * Raw timestamp as delivered by the nXYTER. The last-epoch flag - * (returned by getNxLastEpoch() const) determines whether the - * hit belongs to the current or the last epoch. Use the - * getMsgFullTime(uint32_t) const method to determine the - * expanded and adjusted timestamp.inline uint32_t getSysMesData() const { return getField(16, 32); } - */ - inline uint16_t getNxTs() const { return getField(11, 14); } - - //! For Hit data: Returns nXYTER channel number (7 bit field) - inline uint8_t getNxChNum() const { return getField(25, 7); } - - // 1 bit unused - - //! For Hit data: Returns ADC value (12 bit field) - inline uint16_t getNxAdcValue() const { return getField(33, 12); } - - //! For Hit data: Returns nXYTER pileup flag (1 bit field) - /*! - * This flag is set when the nXYTER trigger circuit detected two hits - * during the peak sense time interval of the slow amplitude channel. - * This flag indicates that separation between two hits was smaller than - * what can be handled by the amplitude channel. \sa getNxOverflow() const - */ - inline uint8_t getNxPileup() const { return getBit(45); } - - //! For Hit data: Returns nXYTER overflow flag (1 bit field) - /*! - * This flag is set when a nXYTER channels detects a hit but this hit - * can't be stored because the 4 stage channel FIFO is full. This flag - * indicates that the hit data rate was higher than the chip can handle - * over a longer time. \sa getNxPileup() const - */ - inline uint8_t getNxOverflow() const { return getBit(46); } - - //! For Hit data: Returns nXYTER last-epoch flag (1 bit field) - /*! - * This flag is set when the hit actually belong to the previous epoch. - * Use the getMsgFullTime(uint32_t) const method to determine the - * expanded and adjusted timestamp. - */ - inline uint8_t getNxLastEpoch() const { return getBit(47); } - - - //! For Hit data: Sets nXYTER number (2 bit field) - inline void setNxNumber(uint8_t v) { setField(6, 2, v); } - - //! For Hit data: Sets 3 most significant bits of ROC LTS (3 bit field) - inline void setNxLtsMsb(uint8_t v) { setField(8, 3, v); } - - //! For Hit data: Sets nXYTER time stamp (14 bit field) - inline void setNxTs(uint16_t v) { setField(11, 14, v); } - - //! For Hit data: Sets nXYTER channel number (7 bit field) - inline void setNxChNum(uint8_t v) { setField(25, 7, v); } - - // 1 bit unused - - //! For Hit data: Sets ADC value (12 bit field) - inline void setNxAdcValue(uint16_t v) { setField(33, 12, v); } - - //! For Hit data: Sets nXYTER pileup flag (1 bit field) - inline void setNxPileup(uint8_t v) { setBit(45, v); } - - //! For Hit data: Sets nXYTER overflow flag (1 bit field) - inline void setNxOverflow(uint8_t v) { setBit(46,v ); } - - //! For Hit data: Sets nXYTER last-epoch flag (1 bit field) - inline void setNxLastEpoch(uint8_t v) { setBit(47, v); } - - // ---------- Epoch marker access methods ------------ - - // 2 bit unused - - //! For Epoch data: Returns current epoch number (32 bit field) - // inline uint32_t getEpochNumber() const { return getField(8, 32); } - // on some machines 32-bit field is not working - inline uint32_t getEpochNumber() const { return data >> 8; } - - - //! For Epoch data: Returns number of missed hits (8 bit field) - inline uint8_t getEpochMissed() const { return getField(40, 8); } - - //! For Epoch data: Sets epoch number (32 bit field) - inline void setEpochNumber(uint32_t v) { setField(8, 32, v); } - - //! For Epoch data: Sets missed hits count (8 bit field) - inline void setEpochMissed(uint8_t v) { setField(40, 8, v); } - - - // ---------- Sync marker access methods ------------- - - //! For Sync data: Returns sync channel number (2 bit field) - inline uint8_t getSyncChNum() const { return getField(6, 2); } - - //! For Sync data: Returns sync time stamp (13 bit field, 2 ns bins) - inline uint16_t getSyncTs() const { return getField(8, 13) << 1; } - - //! For Sync data: Returns LSB of true epoch (1 bit field) - inline uint8_t getSyncEpochLSB() const { return getBit(21); } - - //! For Sync data: Returns sync message data (24 bit field) - inline uint32_t getSyncData() const { return getField(22, 24); } - - //! For Sync data: Returns sync status flags (2 bit field) - inline uint8_t getSyncStFlag() const { return getField(46, 2); } - - - //! For Sync data: Set sync channel number (2 bit field) - inline void setSyncChNum(uint8_t v) { setField(6, 2, v); } - - //! For Sync data: Set sync time stamp (13 bit field, 2 ns bins ) - inline void setSyncTs(uint16_t v) { setField(8, 13, v >> 1); } - - //! For Sync data: Set LSB of true epoch (1 bit field) - inline void setSyncEpochLSB(uint8_t v) { setBit(21, v); } - - //! For Sync data: Set sync message data (24 bit field) - inline void setSyncData(uint32_t v) { setField(22, 24, v); } - - //! For Sync data: Set sync status flags (2 bit field) - inline void setSyncStFlag(uint8_t v) { setField(46, 2, v); } - - - // ---------- AUX marker access methods -------------- - - //! For Aux data: Returns aux channel number (7 bit field) - inline uint8_t getAuxChNum() const { return getField(6, 7); } - - //! For Aux data: Returns aux time stamp (13 bit field, 2 ns bins) - inline uint16_t getAuxTs() const { return getField(13, 13) << 1; } - - //! For Aux data: Returns LSB of true epoch (1 bit field) - inline uint8_t getAuxEpochLSB() const { return getBit(26); } - - //! For Aux data: Returns falling edge flag (1 bit flag) - inline uint8_t getAuxFalling() const { return getBit(27); } - - //! For Aux data: Returns overflow flag (1 bit field) - inline uint8_t getAuxOverflow() const { return getBit(28); } - - - //! For Aux data: Set aux channel number (7 bit field) - inline void setAuxChNum(uint8_t v) { setField(6, 7, v); } - - //! For Aux data: Set aux time stamp (13 bit field) - inline void setAuxTs(uint16_t v) { setField(13, 13, v >> 1); } - - //! For Aux data: Set LSB of true epoch (1 bit field) - inline void setAuxEpochLSB(uint8_t v) { setBit(26, v); } - - //! For Aux data: Set falling edge flag (1 bit flag) - inline void setAuxFalling(uint8_t v) { setBit(27, v); } - - //! For Aux data: Set overflow flag (1 bit field) - inline void setAuxOverflow(uint8_t v) { setBit(28, v); } - - // ---------- Epoch2 marker access methods ------------ - - //! For Epoch2 data: Returns epoch missmatch flag (set in ROC when - //! ROC timestamp and timestamp send by GET4 did not match) (1 bit field) - inline uint32_t getEpoch2EpochMissmatch() const { return getBit(4); } - - //! For Epoch2 data: Returns epoch-lost flag (1 bit field) - inline uint32_t getEpoch2EpochLost() const { return getBit(5); } - - //! For Epoch2 data: Returns data-lost flag (1 bit field) - inline uint32_t getEpoch2DataLost() const { return getBit(6); } - - //! For Epoch2 data: Returns sync flag (1 bit field) - inline uint32_t getEpoch2Sync() const { return getBit(7); } - - //! For Epoch2 data: Returns the LTS156 bits 11 to 8. This - //! gives information at what time in the Epoche the epoche number - //! was set (2 bit field) - inline uint32_t getEpoch2StampTime() const { return getField(8, 2); } - - //! For Epoch2 data: Returns the epoch number (32 bit field) - // on some machines 32-bit field is not working - inline uint32_t getEpoch2Number() const { return (data >> 10) & 0xFFFFFFFF; } - - //! For Epoch2 data: Returns the number of the GET4 chip that send - //! the epoche message (6 bit field) - inline uint32_t getEpoch2ChipNumber() const { return getField(42, 6); } - - //! For Epoch2 data: Set epoch missmatch flag (1 bit field) - inline void setEpoch2EpochMissmatch(uint32_t v) { setBit(4, v); } - - //! For Epoch2 data: Set epoch-lost flag (1 bit field) - inline void setEpoch2EpochLost(uint32_t v) { setBit(5, v); } - - //! For Epoch2 data: Set data-lost flag (1 bit field) - inline void setEpoch2DataLost(uint32_t v) { setBit(6, v); } - - //! For Epoch2 data: Set sync flag (1 bit field) - inline void setEpoch2Sync(uint32_t v) { setBit(7, v); } - - //! For Epoch2 data: Set the LTS156 bits 11 to 8. This - //! gives information at what time in the Epoche the epoche number - //! was set (2 bit field) - inline void setEpoch2StampTime(uint32_t v) { setField(8, 2, v); } - - //! For Epoch2 data: Set the epoch number (32 bit field) - inline void setEpoch2Number(uint32_t v) { setField(10, 32, v); } - - //! For Epoch2 data: Set the number of the GET4 chip that send - //! the epoche message (6 bit field) - inline void setEpoch2ChipNumber(uint32_t v) { setField(42, 6, v); } - - // ---------- Get4 Hit data access methods ---------------- - - //! For Get4 data: Returns Get4 chip number (6 bit field) - inline uint8_t getGet4Number() const { return getField(6, 6); } - - //! For Get4 data: Returns Get4 channel number (2 bit field) - inline uint8_t getGet4ChNum() const { return getField(12, 2); } - - //! For Get4 data: Returns Get4 time stamp, 50 ps binning (19 bit field) - inline uint32_t getGet4Ts() const { return getField(14, 19); } - - //! For Get4 data: Returns Get4 fine time stamp, 50 ps binning (7 bit field) - inline uint32_t getGet4FineTs() const { return getField(14, 7); } - - //! For Get4 data: Returns Get4 coarse time stamp, 6.4 ns binning (12 bit field) - inline uint32_t getGet4CoarseTs() const { return getField(21, 12); } - - //! For Get4 data: Returns Get4 rising or falling edge (1 bit field) - inline uint32_t getGet4Edge() const { return getBit(33); } - - //! For Get4 data: Returns the CRC-8 of the rest of the message. - //! For details check the ROC documentation. (8 bit field) - inline uint32_t getGet4CRC() const { return getField(40, 8); } - - - //! For Get4 data: Sets Get4 chip number (6 bit field) - inline void setGet4Number(uint8_t v) { setField(6, 6, v); } - - //! For Get4 data: Sets Get4 channel number (2 bit field) - inline void setGet4ChNum(uint8_t v) { setField(12, 2, v); } - - //! For Get4 data: Sets Get4 time stamp, 50 ps binning (19 bit field) - inline void setGet4Ts(uint32_t v) { setField(14, 19, v); } - - //! For Get4 data: Sets Get4 rising or falling edge (1 bit field) - inline void setGet4Edge(uint32_t v) { setBit(33, v); } - - //! For Get4 data: Set the CRC-8 of the rest of the message - //! For details check the ROC documentation. (8 bit field) - inline void setGet4CRC(uint32_t v) { setField(40, 8, v); } - - // ---------- System message access methods ---------- - - // 2 bit unused - - //! For SysMes data: Returns system message subtype (8 bit field) - inline uint8_t getSysMesType() const { return getField(8, 8); } - - //! For SysMes data: Returns system message data (32 bit field) - // inline uint32_t getSysMesData() const { return getField(16, 32); } - // on some machine 32-bit field not working - inline uint32_t getSysMesData() const { return data >> 16; } - - //! For SysMes data: Set system message type (8 bit field) - inline void setSysMesType(uint8_t v) { setField(8, 8, v); } - - //! For SysMes data: Set system message data (32 bit field) - inline void setSysMesData(uint32_t v) { setField(16, 32, v); } - - // ---------- Get4 v1.x 24b data access methods ---------------- - // type 2 => Error message: encapsulated in SysMes subtype SYSMSG_GET4_EVENT - // 24 bits mode - inline uint8_t getGet4V10R24ErrorChan() const { return getField( 26, 2); } - inline bool getGet4V10R24ErrorEdge() const { return getBit( 28); } - inline uint8_t getGet4V10R24ErrorUnused() const { return getField( 29, 6); } -// inline uint8_t getGet4V10R24ErrorChip() const { return getField( 35, 6); } // or getField(40, 8) -// inline uint8_t getGet4V10R24ErrorData() const { return getField( 41, 7); } // or getField(16,10) - inline uint8_t getGet4V10R24ErrorChip() const { return getField( 40, 8); } - inline uint8_t getGet4V10R24ErrorData() const { return getField( 16, 10); } - - // ---------- Get4 v1.x 24b tool methods ----------------------- - double CalcGet4V10R24HitTimeDiff(uint32_t epochA, uint32_t epochB, Message& messB); - - // ---------- Get4 v1.x 32b data access methods ---------------- - inline uint8_t getGet4V10R32ChipId() const { return getField( 6, 6); } - inline uint8_t getGet4V10R32MessageType() const { return getFieldBE( 46, 2); } - // type 0 => Epoch message - inline uint32_t getGet4V10R32EpochNumber() const { return getFieldBE( 17,24); } - inline bool getGet4V10R32SyncFlag() const { return getBitBE( 16); } - // type 1 => Slow control - inline uint32_t getGet4V10R32SlData() const { return getFieldBE( 16,24); } - inline uint8_t getGet4V10R32SlType() const { return getFieldBE( 40, 2); } - inline bool getGet4V10R32SlEdge() const { return getBitBE( 42); } - inline uint8_t getGet4V10R32SlChan() const { return getFieldBE( 43, 2); } - // type 2 => Error message - inline uint8_t getGet4V10R32ErrorData() const { return getFieldBE( 16, 7); } - inline uint16_t getGet4V10R32ErrorUnused() const { return getFieldBE( 23,19); } - inline uint8_t getGet4V10R32ErrorChan() const { return getFieldBE( 42, 2); } - inline bool getGet4V10R32ErrorEdge() const { return getBitBE( 44); } - // type 3 => Hit Data - inline uint8_t getGet4V10R32HitTot() const { return getFieldBE( 16, 8); } - inline uint8_t getGet4V10R32HitFt() const { return getFieldBE( 24, 7); } - inline uint16_t getGet4V10R32HitTs() const { return getFieldBE( 31,12); } - inline uint32_t getGet4V10R32HitTimeBin() const { return getFieldBE( 24,19); } - inline uint8_t getGet4V10R32HitChan() const { return getFieldBE( 43, 2); } - inline bool getGet4V10R32HitDllFlag() const { return getBitBE( 45); } - - // ---------- Get4 v1.x 32b tool methods ----------------------- - double CalcGet4V10R32HitTimeDiff(uint32_t epochA, uint32_t epochB, Message& messB); - - // ---------- Common functions ----------------------- - - //! Returns \a true is message type is #MSG_NOP (filler message) - inline bool isNopMsg() const { return getMessageType() == MSG_NOP; } - //! Returns \a true is message type is #MSG_HIT (nXYTER hit data) - inline bool isHitMsg() const { return getMessageType() == MSG_HIT; } - //! Returns \a true is message type is #MSG_EPOCH (epoch marker) - inline bool isEpochMsg() const { return getMessageType() == MSG_EPOCH;} - //! Returns \a true is message type is #MSG_SYNC - inline bool isSyncMsg() const { return getMessageType() == MSG_SYNC; } - //! Returns \a true is message type is #MSG_AUX - inline bool isAuxMsg() const { return getMessageType() == MSG_AUX; } - //! Returns \a true is message type is #MSG_EPOCH2 (epoch2 marker) - inline bool isEpoch2Msg() const { return getMessageType() == MSG_EPOCH2;} - //! Returns \a true is message type is #MSG_GET4 (Get4 hit data) - inline bool isGet4Msg() const { return getMessageType() == MSG_GET4; } - //! Returns \a true is message type is #MSG_SYS (system message) - inline bool isSysMsg() const { return getMessageType() == MSG_SYS; } - //! Returns \a true is message type is #MSG_GET4_SLC (system message) - inline bool isGet4SlCtrMsg() const { return getMessageType() == MSG_GET4_SLC; } - //! Returns \a true is message type is #MSG_GET4_32B (system message) - inline bool isGet4Hit32Msg() const { return getMessageType() == MSG_GET4_32B; } - //! Returns \a true is message type is #MSG_SYS (system message) and subtype is 32bHack - inline bool isGet4Hack32Msg() const { return - ( (getMessageType() == MSG_SYS) && - (SYSMSG_GET4V1_32BIT_0 <= getSysMesType()) ); } - - //! Returns \a true if system message and subtype #ROC_SYSMSG_DAQ_START - inline bool isStartDaqMsg() const - { return isSysMsg() && (getSysMesType() == SYSMSG_DAQ_START); } - //! Returns \a true if system message and subtype #ROC_SYSMSG_DAQ_FINISH - inline bool isStopDaqMsg() const - { return isSysMsg() && (getSysMesType() == SYSMSG_DAQ_FINISH); } - - - void printDataCout(unsigned kind = msg_print_Prefix | msg_print_Data, uint32_t epoch = 0) const; - void printDataLog(unsigned kind = msg_print_Prefix | msg_print_Data, uint32_t epoch = 0) const; - -// void printData(std::ostream& os, unsigned kind = msg_print_Human, uint32_t epoch = 0) const; - void printData(unsigned outType = msg_print_Cout, unsigned kind = msg_print_Human, - uint32_t epoch = 0) const; - - uint64_t getMsgFullTime(uint32_t epoch) const; - - double getMsgFullTimeD(uint32_t epoch) const; - - //! Expanded timestamp for 250 MHz * 14 bit epochs - inline static uint64_t FullTimeStamp(uint32_t epoch, uint16_t stamp) - { return (static_cast<uint64_t>(epoch) << 14) | (stamp & 0x3fff); } - - //! Expanded timestamp for 250/8*5 MHz * 19 bit epochs - inline static uint64_t FullTimeStamp2(uint32_t epoch, uint32_t stamp) - { return (static_cast<uint64_t>(epoch) << 19) | (stamp & 0x7ffff); } - - - static uint64_t CalcDistance(uint64_t start, uint64_t stop); - - static double CalcDistanceD(double start, double stop); - - bool operator<(const Message& other) const; - - // -------------------- methods for working with different formats - - static uint32_t RawSize(int fmt); - - bool convertFromOld(void* src); - - bool convertToOld(void* tgt); - - bool assign(void* src, int fmt = formatNormal); - - bool copyto(void* tgt, int fmt = formatNormal); - }; - - class FullMessage : public Message { - protected: - uint64_t fuExtendedEpoch; // Epoch of the message, extended with 32b epoch cycle counter - - public: - FullMessage() : Message(), fuExtendedEpoch(0) {} - - FullMessage(const Message& src, uint64_t uEpIn) : Message(src), fuExtendedEpoch(uEpIn) {} - - FullMessage(const FullMessage& src) : Message(src), fuExtendedEpoch(src.fuExtendedEpoch) {} - - void assign(const FullMessage& src) { Message::assign(src); fuExtendedEpoch = src.fuExtendedEpoch; } - - FullMessage& operator=(const FullMessage& src) { assign(src); return *this; } - - bool operator<(const FullMessage& other) const; - - inline void reset() { Message::reset(); fuExtendedEpoch = 0; } - - inline uint64_t getExtendedEpoch() const {return fuExtendedEpoch; } - }; - -} - - -#endif // GET4_V1_X_TOOLS_DEF_H diff --git a/beamtime/cern2014/unpacker/CbmGet4v1xToolsDef.cxx b/beamtime/cern2014/unpacker/CbmGet4v1xToolsDef.cxx deleted file mode 100644 index b9e64873c10cdeed76d3473b039428a586236c76..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/unpacker/CbmGet4v1xToolsDef.cxx +++ /dev/null @@ -1,704 +0,0 @@ -#include "CbmGet4v1xToolsDef.h" - -// FAIRROOT headers -#include "FairLogger.h" - -// ROOT headers -#include "TString.h" - -// std C++ lib headers -#include <stdio.h> -#include <string.h> - -#include <iostream> -//#include <stdint.h> - - -bool get4v1x::Message::convertFromOld(void* src) -{ - data = 0; - - uint8_t* arr = (uint8_t*) src; - - setMessageType((arr[0] >> 5) & 0x7); - setRocNumber((arr[0] >> 2) & 0x7); - - switch (getMessageType()) { - case MSG_HIT: - setNxNumber(arr[0] & 0x3); - setNxLtsMsb((arr[1] >> 5) & 0x7); - setNxTs(((arr[1] & 0x1f) << 9) | (arr[2] << 1) | (arr[3] >> 7)); - setNxChNum(arr[3] & 0x7f); - setNxAdcValue(((arr[4] & 0x7f) << 5) | ((arr[5] & 0xf8) >> 3)); - setNxPileup((arr[5] >> 2) & 0x1); - setNxOverflow((arr[5] >> 1) & 0x1); - setNxLastEpoch(arr[5] & 0x1); - break; - - case MSG_EPOCH: - setEpochNumber((arr[1] << 24) | (arr[2] << 16) | (arr[3] << 8) | arr[4]); - setEpochMissed(arr[5]); - break; - - case MSG_SYNC: - setSyncChNum(arr[0] & 0x3); - setSyncEpochLSB(arr[1] >> 7); - setSyncTs(((arr[1] & 0x7f) << 7) | ((arr[2] & 0xfc) >> 1)); - setSyncData(((arr[2] & 0x3) << 22) | (arr[3] << 14) | (arr[4] << 6) | (arr[5] >> 2)); - setSyncStFlag(arr[5] & 0x3); - break; - - case MSG_AUX: - setAuxChNum(((arr[0] & 0x3) << 5) | ((arr[1] & 0xf8) >> 3)); - setAuxEpochLSB((arr[1] & 0x4) >> 2); - setAuxTs(((arr[1] & 0x3) << 12) | (arr[2] << 4) | ((arr[3] & 0xe0) >> 4)); - setAuxFalling((arr[3] >> 4) & 1); - setAuxOverflow((arr[3] >> 3) & 1); - break; - - case MSG_SYS: - setSysMesType(arr[1]); - setSysMesData((arr[2] << 24) | (arr[3] << 16) | (arr[4] << 8) | arr[5]); - break; - - default: - return false; - } - - return true; -} - - -bool get4v1x::Message::convertToOld(void* tgt) -{ - uint8_t* data = (uint8_t*) tgt; - for (int n=0;n<6;n++) data[n] = 0; - - data[0] = ((getMessageType() & 0x7) << 5) | ((getRocNumber() & 0x7) << 2); - - switch (getMessageType()) { - case MSG_HIT: - data[0] = data[0] | (getNxNumber() & 0x3); - data[1] = ((getNxTs() >> 9) & 0x1f) | ((getNxLtsMsb() << 5) & 0xe0); - data[2] = (getNxTs() >> 1); - data[3] = ((getNxTs() << 7) & 0x80) | (getNxChNum() & 0x7f); - data[4] = (getNxAdcValue() >> 5) & 0x7f; - data[5] = ((getNxAdcValue() << 3) & 0xf8) | - (getNxLastEpoch() & 0x1) | - ((getNxOverflow() & 0x1) << 1) | - ((getNxPileup() & 0x1) << 2); - break; - - case MSG_EPOCH: - data[1] = (getEpochNumber() >> 24) & 0xff; - data[2] = (getEpochNumber() >> 16) & 0xff; - data[3] = (getEpochNumber() >> 8) & 0xff; - data[4] = getEpochNumber() & 0xff; - data[5] = getEpochMissed(); - break; - - case MSG_SYNC: - data[0] = data[0] | (getSyncChNum() & 0x3); - data[1] = (getSyncEpochLSB() << 7) | ((getSyncTs() >> 7) & 0x7f); - data[2] = ((getSyncTs() << 1) & 0xfc) | ((getSyncData() >> 22) & 0x3); - data[3] = (getSyncData() >> 14) & 0xff; - data[4] = (getSyncData() >> 6) & 0xff; - data[5] = ((getSyncData() << 2) & 0xfc) | (getSyncStFlag() & 0x3); - break; - - case MSG_AUX: - data[0] = data[0] | ((getAuxChNum() >> 5) & 0x3); - data[1] = ((getAuxChNum() << 3) & 0xf8) | - ((getAuxEpochLSB() << 2) & 0x4) | - ((getAuxTs() >> 12) & 0x3); - data[2] = (getAuxTs() >> 4) & 0xff; - data[3] = ((getAuxTs() << 4) & 0xe0) | - (getAuxFalling() << 4) | - (getAuxOverflow() << 3); - break; - - case MSG_SYS: - data[1] = getSysMesType(); - data[2] = (getSysMesData() >> 24) & 0xff; - data[3] = (getSysMesData() >> 16) & 0xff; - data[4] = (getSysMesData() >> 8) & 0xff; - data[5] = getSysMesData() & 0xff; - break; - - default: - return false; - } - - return true; -} - - -//---------------------------------------------------------------------------- -//! Returns expanded and adjusted time of message (in ns) -//! epoch should correspond to the message type - epoch2 for Get4, epoch for all others -//! When converting from GET4 (156Mhz) to SYNC (250 Mhz) clock, one should take into account -//! that initial value of 250 MHz timestamp counter is 0x80 or 512 ns. Therefore such offset -//! should be applied during conversion - -uint64_t get4v1x::Message::getMsgFullTime(uint32_t epoch) const -{ - switch (getMessageType()) { - case MSG_HIT: - return FullTimeStamp(getNxLastEpoch() ? epoch - 1 : epoch, getNxTs()); - case MSG_EPOCH: - return FullTimeStamp(getEpochNumber(), 0); - case MSG_SYNC: - return FullTimeStamp((getSyncEpochLSB() == (epoch & 0x1)) ? epoch : epoch - 1, getSyncTs()); - case MSG_AUX: - return FullTimeStamp((getAuxEpochLSB() == (epoch & 0x1)) ? epoch : epoch - 1, getAuxTs()); - case MSG_EPOCH2: - return FullTimeStamp2(getEpoch2Number(), 0) / 20 + 512; - case MSG_GET4: - return FullTimeStamp2(epoch, getGet4Ts()) / 20 + 512; - case MSG_SYS: - return FullTimeStamp(epoch, 0); - - } - return 0; -} - -//---------------------------------------------------------------------------- -//! Returns expanded and adjusted time of message in double (in ns) -//! epoch should correspond to the message type - epoch2 for Get4, epoch for all others - -double get4v1x::Message::getMsgFullTimeD(uint32_t epoch) const -{ - switch (getMessageType()) { - case MSG_EPOCH2: - return FullTimeStamp2(getEpoch2Number(), 0) / 20. + 512.; - case MSG_GET4: - return FullTimeStamp2(epoch, getGet4Ts()) / 20. + 512.; - } - return getMsgFullTime(epoch); -} - - -//---------------------------------------------------------------------------- -//! Returns the time difference between two expanded time stamps - -uint64_t get4v1x::Message::CalcDistance(uint64_t start, uint64_t stop) -{ - if (start>stop) { - stop += 0x3FFFFFFFFFFFLLU; - if (start>stop) { - printf("Epochs overflow error in CalcDistance\n"); - return 0; - } - } - - return stop - start; -} - - -//---------------------------------------------------------------------------- -//! Returns the time difference between two expanded time stamps - -double get4v1x::Message::CalcDistanceD(double start, double stop) -{ - if (start>stop) { - stop += 0x3FFFFFFFFFFFLLU; - if (start>stop) { - printf("Epochs overflow error in CalcDistanceD\n"); - return 0.; - } - } - - return stop - start; -} - - - -//---------------------------------------------------------------------------- -//! Print message in human readable format to \a cout. -/*! - * Prints a one line representation of the message in to \a cout. - * See printData(std::ostream&, unsigned, uint32_t) const for full - * documentation. - */ - -void get4v1x::Message::printDataCout(unsigned kind, uint32_t epoch) const -{ - printData(msg_print_Cout, kind, epoch); -} - -//---------------------------------------------------------------------------- -//! Print message in human readable format to the Fairroot logger. -/*! - * Prints a one line representation of the message in to the Fairroot logger. - * TODO: Add coloring of possible - * See printData(std::ostream&, unsigned, uint32_t) const for full - * documentation. - */ - -void get4v1x::Message::printDataLog(unsigned kind, uint32_t epoch) const -{ - printData(msg_print_FairLog, kind, epoch); -} - -//---------------------------------------------------------------------------- -//! Print message in binary or human readable format to a stream. -/*! - * Prints a one line representation of the message in to a stream, selected by \a outType. - * The stream is \a cout if \a outType is kFALSE and \a FairLogger if \a outType is kTRUE. - * The parameter \a kind is mask with 4 bits - * \li get4v1x::msg_print_Prefix (1) - ROC number and message type - * \li get4v1x::msg_print_Data (2) - print all message specific data fields - * \li get4v1x::msg_print_Hex (4) - print data as hex dump - * \li get4v1x::msg_print_Human (8) - print in human readable format - * - * If bit msg_print_Human in \a kind is not set, raw format - * output is generated. All data fields are shown in hexadecimal. - * This is the format of choice when chasing hardware problems at the bit level. - * - * If bit msg_print_Human is set, a more human readable output is generated. - * The timestamp is shown as fully extended and adjusted time as - * returned by the getMsgFullTime(uint32_t) const method. - * All data fields are represented in decimal. - * - * \param os output stream - * \param kind mask determing output format - * \param epoch current epoch number (from last epoch message) - * - * Typical message output in human format looks like -\verbatim -Msg:7 Roc:1 SysType: 1 Nx:0 Data: 0 : DAQ started -Msg:7 Roc:1 SysType: 6 Nx:0 Data: 0 : FIFO reset -Msg:2 Roc:1 EPO @ 0.536870912 Epo: 32768 0x00008000 Miss: 0 -Msg:0 Roc:0 NOP (raw 80:40:82:0F:00:00) -Msg:2 Roc:1 EPO @ 0.646627328 Epo: 39467 0x00009a2b Miss: 0 -Msg:1 Roc:1 HIT @ 0.646614333 Nx:2 Chn: 12 Ts: 3389-e( 8) Adc:2726 Pu:0 Of:0 -Msg:1 Roc:1 HIT @ 0.646630717 Nx:2 Chn: 13 Ts: 3389 ( 0) Adc:2745 Pu:0 Of:0 -Msg:2 Roc:1 EPO @ 0.805306368 Epo: 49152 0x0000c000 Miss: 0 -Msg:3 Roc:1 SYN @ 0.805306408 Chn:2 Ts: 40 Data: 49152 0x00c000 Flag:0 -Msg:7 Roc:1 SysType: 2 Nx:0 Data: 0 : DAQ finished -\endverbatim - * - * Typical message output in binary format looks like -\verbatim -Msg:7 Roc:1 SysType: 1 Nx:0 Data: 0 : DAQ started -Msg:7 Roc:1 SysType: 6 Nx:0 Data: 0 : FIFO reset -Msg:2 Roc:1 Epoch:00008000 Missed:00 -Msg:1 Roc:1 Nx:2 Chn:0d Ts:3ec9 Last:1 Msb:7 Adc:a22 Pup:0 Oflw:0 -Msg:1 Roc:1 Nx:2 Chn:0e Ts:3ec9 Last:0 Msb:7 Adc:a18 Pup:0 Oflw:0 -Msg:0 Roc:0 NOP (raw 80:40:82:0F:00:00) -Msg:2 Roc:1 Epoch:00010000 Missed:00 -Msg:3 Roc:1 SyncChn:2 EpochLSB:0 Ts:0028 Data:010000 Flag:0 -Msg:7 Roc:1 SysType: 2 Nx:0 Data: 0 : DAQ finished -\endverbatim - */ - -//void get4v1x::Message::printData(std::ostream& os, unsigned kind, uint32_t epoch) const -void get4v1x::Message::printData(unsigned outType, unsigned kind, uint32_t epoch) const -{ - char buf[256]; - // Use a TString in case of FairLogger as the log level is decided only later - TString sLogBuff = ""; - - if (kind & msg_print_Hex) { - uint8_t* arr = (uint8_t*) &data; - snprintf(buf, sizeof(buf), "%02X:%02X:%02X:%02X:%02X:%02X ", - arr[0], arr[1], arr[2], arr[3], arr[4], arr[5]); -// os << buf; - if( msg_print_Cout == outType) - std::cout << buf; - else sLogBuff = TString::Format("%s", buf ); - } - - if (kind & msg_print_Human) { - double timeInSec = getMsgFullTimeD(epoch)/1.e9; - int fifoFill = 0; - - switch (getMessageType()) { - case MSG_HIT: - fifoFill = getNxLtsMsb() - ((getNxTs()>>11)&0x7); - if (getNxLastEpoch()) fifoFill += 8; - snprintf(buf, sizeof(buf), - "Msg:%u Roc:%u ", getMessageType(), getRocNumber()); -// os << buf; - if( msg_print_Cout == outType) - std::cout << buf; - else sLogBuff = TString::Format("%s", buf ); - - snprintf(buf, sizeof(buf), - "HIT @%15.9f Nx:%d Chn:%3d Ts:%5d%s(%2d) Adc:%4d Pu:%d Of:%d", - timeInSec, getNxNumber(), getNxChNum(), getNxTs(), - (getNxLastEpoch() ? "-e" : " "), - fifoFill, getNxAdcValue(), getNxPileup(), getNxOverflow()); -// os << buf << std::endl; - if( msg_print_Cout == outType) - std::cout << buf << std::endl; - else LOG(info) << sLogBuff << buf; - break; - case MSG_EPOCH: - snprintf(buf, sizeof(buf), - "Msg:%u Roc:%u ", getMessageType(), getRocNumber()); -// os << buf; - if( msg_print_Cout == outType) - std::cout << buf; - else sLogBuff = TString::Format("%s", buf ); - - snprintf(buf, sizeof(buf), - "EPO @%15.9f Epo:%10u 0x%08x Miss: %3d%c", - timeInSec, getEpochNumber(), getEpochNumber(), - getEpochMissed(), (getEpochMissed()==0xff) ? '+' : ' '); -// os << buf << std::endl; - if( msg_print_Cout == outType) - std::cout << buf << std::endl; - else LOG(info) << sLogBuff << buf; - break; - case MSG_SYNC: - snprintf(buf, sizeof(buf), - "Msg:%u Roc:%u ", getMessageType(), getRocNumber()); -// os << buf; - if( msg_print_Cout == outType) - std::cout << buf; - else sLogBuff = TString::Format("%s", buf ); - - snprintf(buf, sizeof(buf), - "SYN @%15.9f Chn:%d Ts:%5d%s Data:%8d 0x%06x Flag:%d", - timeInSec, getSyncChNum(), getSyncTs(), - ((getSyncEpochLSB() != (epoch&0x1)) ? "-e" : " "), - getSyncData(), getSyncData(), getSyncStFlag()); -// os << buf << std::endl; - if( msg_print_Cout == outType) - std::cout << buf << std::endl; - else LOG(info) << sLogBuff << buf; - break; - case MSG_AUX: - snprintf(buf, sizeof(buf), - "Msg:%u Roc:%u ", getMessageType(), getRocNumber()); -// os << buf; - if( msg_print_Cout == outType) - std::cout << buf; - else sLogBuff = TString::Format("%s", buf ); - - snprintf(buf, sizeof(buf), - "AUX @%15.9f Chn:%d Ts:%5d%s Falling:%d Overflow:%d", - timeInSec, getAuxChNum(), getAuxTs(), - ((getAuxEpochLSB() != (epoch&0x1)) ? "-e" : " "), - getAuxFalling(), getAuxOverflow()); -// os << buf << std::endl; - if( msg_print_Cout == outType) - std::cout << buf << std::endl; - else LOG(info) << sLogBuff << buf; - break; - case MSG_EPOCH2: - snprintf(buf, sizeof(buf), - "Msg:%u Roc:%u ", getMessageType(), getRocNumber()); -// os << buf; - if( msg_print_Cout == outType) - std::cout << buf; - else sLogBuff = TString::Format("%s", buf ); - - snprintf(buf, sizeof(buf), - "EPO2 @%17.11f Get4:%2d Epoche2:%10u 0x%08x StampTime:%2d Sync:%x Dataloss:%x Epochloss:%x Epochmissmatch:%x", - timeInSec, getEpoch2ChipNumber(), getEpoch2Number(), getEpoch2Number(), - getEpoch2StampTime(), getEpoch2Sync(), getEpoch2DataLost(), getEpoch2EpochLost(), getEpoch2EpochMissmatch()); -// os << buf << std::endl; - if( msg_print_Cout == outType) - std::cout << buf << std::endl; - else LOG(info) << sLogBuff << buf; - break; - case MSG_GET4: - snprintf(buf, sizeof(buf), - "Msg:%u Roc:%u ", getMessageType(), getRocNumber()); -// os << buf; - if( msg_print_Cout == outType) - std::cout << buf; - else sLogBuff = TString::Format("%s", buf ); - - snprintf(buf, sizeof(buf), - "Get4 @%17.11f Get4:%2d Chn:%3d Edge:%1d Ts:%7d CRC8:%3d", - timeInSec, getGet4Number(), getGet4ChNum(), getGet4Edge(), getGet4Ts(), getGet4CRC() ); -// os << buf << std::endl; - if( msg_print_Cout == outType) - std::cout << buf << std::endl; - else LOG(info) << sLogBuff << buf; - break; - default: - kind = kind & ~msg_print_Human; - if (kind==0) kind = msg_print_Prefix | msg_print_Data; - } - - // return, if message was correctly printed in human-readable form - if (kind & msg_print_Human) return; - } - - if (kind & msg_print_Prefix) { - snprintf(buf, sizeof(buf), "Msg:%u Roc:%u ", getMessageType(), getRocNumber()); -// os << buf; - if( msg_print_Cout == outType) - std::cout << buf; - else sLogBuff = TString::Format("%s", buf ); - } - - if (kind & msg_print_Data) { - uint8_t* arr = (uint8_t*) &data; - switch (getMessageType()) { - case MSG_NOP: - snprintf(buf, sizeof(buf), "NOP (raw %02X:%02X:%02X:%02X:%02X:%02X)", - arr[0], arr[1], arr[2], arr[3], arr[4], arr[5]); - break; - case MSG_HIT: - snprintf(buf, sizeof(buf), "Nx:%1x Chn:%02x Ts:%04x Last:%1x Msb:%1x Adc:%03x Pup:%1x Oflw:%1x", - getNxNumber(), getNxChNum(), getNxTs(), getNxLastEpoch(), - getNxLtsMsb(), getNxAdcValue(), getNxPileup(), - getNxOverflow()); - break; - case MSG_EPOCH: - snprintf(buf, sizeof(buf), "Epoch:%08x Missed:%02x", - getEpochNumber(), getEpochMissed()); - break; - case MSG_SYNC: - snprintf(buf, sizeof(buf), "SyncChn:%1x EpochLSB:%1x Ts:%04x Data:%06x Flag:%1x", - getSyncChNum(), getSyncEpochLSB(), getSyncTs(), - getSyncData(), getSyncStFlag()); - break; - case MSG_AUX: - snprintf(buf, sizeof(buf), "AuxChn:%02x EpochLSB:%1x Ts:%04x Falling:%1x Overflow:%1x", - getAuxChNum(), getAuxEpochLSB(), getAuxTs(), - getAuxFalling(), getAuxOverflow()); - break; - case MSG_EPOCH2: - snprintf(buf, sizeof(buf), "Get4:0x%02x Epoche2:0x%08x StampTime:0x%x Sync:%x Dataloss:%x Epochloss:%x Epochmissmatch:%x", - getEpoch2ChipNumber(), getEpoch2Number(), getEpoch2StampTime(), getEpoch2Sync(), - getEpoch2DataLost(), getEpoch2EpochLost(), getEpoch2EpochMissmatch()); - /* - // For csv files output - snprintf(buf, sizeof(buf), - "Get4 V1 32 bits, type:0x00 => ;chip;%02d;Epoch; %08d; Sync:; %1d;", - getEpoch2ChipNumber(), getEpoch2Number(), getEpoch2Sync() ); - */ - break; - case MSG_GET4: - snprintf(buf, sizeof(buf), "Get4:0x%02x Chn:%1x Edge:%1x Ts:0x%05x CRC8:0x%02x", - getGet4Number(), getGet4ChNum(), getGet4Edge(), getGet4Ts(), getGet4CRC() ); - break; - case MSG_SYS: { - char sysbuf[256]; - - switch (getSysMesType()) { - case SYSMSG_DAQ_START: - snprintf(sysbuf, sizeof(sysbuf), "DAQ started"); - break; - case SYSMSG_DAQ_FINISH: - snprintf(sysbuf, sizeof(sysbuf), "DAQ finished"); - break; - case SYSMSG_NX_PARITY: { - uint32_t data = getSysMesData(); - uint32_t nxb3_flg = (data>>31) & 0x01; - uint32_t nxb3_val = (data>>24) & 0x7f; - uint32_t nxb2_flg = (data>>23) & 0x01; - uint32_t nxb2_val = (data>>16) & 0x7f; - uint32_t nxb1_flg = (data>>15) & 0x01; - uint32_t nxb1_val = (data>>8 ) & 0x7f; - uint32_t nxb0_flg = (data>>7 ) & 0x01; - uint32_t nxb0_val = (data ) & 0x7f; - snprintf(sysbuf, sizeof(sysbuf),"Nx:%1x %1d%1d%1d%1d:%02x:%02x:%02x:%02x nX parity error", getNxNumber(), - nxb3_flg, nxb2_flg, nxb1_flg, nxb0_flg, - nxb3_val, nxb2_val, nxb1_val, nxb0_val); - } - break; - case SYSMSG_SYNC_PARITY: - snprintf(sysbuf, sizeof(sysbuf), "SYNC parity error "); - break; - case SYSMSG_DAQ_RESUME: - snprintf(sysbuf, sizeof(sysbuf), "DAQ resume after high/low water"); - break; - case SYSMSG_FIFO_RESET: - snprintf(sysbuf, sizeof(sysbuf), "FIFO reset"); - break; - case SYSMSG_USER: { - const char* subtyp = ""; - if (getSysMesData()==SYSMSG_USER_CALIBR_ON) subtyp = "Calibration ON"; else - if (getSysMesData()==SYSMSG_USER_CALIBR_OFF) subtyp = "Calibration OFF"; else - if (getSysMesData()==SYSMSG_USER_RECONFIGURE) subtyp = "Reconfigure"; - snprintf(sysbuf, sizeof(sysbuf), "User message 0x%08x %s", getSysMesData(), subtyp); - break; - } - case SYSMSG_PACKETLOST: - snprintf(sysbuf, sizeof(sysbuf), "Packet lost"); - break; - case SYSMSG_GET4_EVENT: - { - if( 1 == isGet4Err24bit() && 0 == isGet4Err32bit() ) - { - // 24b GET4 Error event - uint32_t get4_24b_er_chan = getGet4V10R24ErrorChan(); - uint32_t get4_24b_er_edge = getGet4V10R24ErrorEdge(); - uint32_t get4_24b_er_unus = getGet4V10R24ErrorUnused(); - uint32_t get4_24b_er_chip = getGet4V10R24ErrorChip(); - uint32_t get4_24b_er_code = getGet4V10R24ErrorData(); - - snprintf(sysbuf, sizeof(sysbuf), - "Get4:0x%02x Ch:0x%01x Edge:%01x Unused:%04x ErrCode:0x%02x - GET4 V1 Error Event", - get4_24b_er_chip, get4_24b_er_chan, get4_24b_er_edge, get4_24b_er_unus, get4_24b_er_code); - - /* - // For csv files output - snprintf(sysbuf, sizeof(sysbuf), - "Get4 V1 24 bits, chip %02d, type:0x10 => ;Error ;;;;;;;;;;;;;;%02x ;Channel; %1d ;Edge; %1d;Unused; %4x;", - get4_24b_er_chip, get4_24b_er_code, get4_24b_er_chan, get4_24b_er_edge, get4_24b_er_unus ); - */ - } - else - { - // 32b GET4 error event - uint32_t get4_32b_er_code = getGet4V10R32ErrorData(); - uint32_t get4_32b_er_chan = getGet4V10R32ErrorChan(); - uint32_t get4_32b_er_unus = getGet4V10R32ErrorUnused(); - uint32_t get4_32b_er_chip = getGet4V10R32ErrorChip(); - uint32_t get4_32b_er_edge = getGet4V10R32ErrorEdge(); - - snprintf(sysbuf, sizeof(sysbuf), - "Get4 V1 32 bits, chip %02d, type:0x10 => Error 0x%02x Channel %1d Edge %1d Unused:%04x", - get4_32b_er_chip, get4_32b_er_code, get4_32b_er_chan, get4_32b_er_edge, get4_32b_er_unus ); - - /* - // For csv files output - snprintf(sysbuf, sizeof(sysbuf), - "Get4 V1 32 bits, type:0x10 => ;chip;%02d;Error ;;;;;;;;;;;;;;%02x ;Channel; %1d ;Edge; %1d;Unused; %4x;", - get4_32b_er_chip, get4_32b_er_code, get4_32b_er_chan, get4_32b_er_edge, get4_32b_er_unus ); - */ - break; - } - break; - } // - case SYSMSG_CLOSYSYNC_ERROR: - snprintf(sysbuf, sizeof(sysbuf), "Closy synchronization error"); - break; - case SYSMSG_TS156_SYNC: - snprintf(sysbuf, sizeof(sysbuf), "156.25MHz timestamp reset"); - break; - - default: - snprintf(sysbuf, sizeof(sysbuf), "unknown system message type "); - } // switch (getSysMesType()) - - snprintf(buf, sizeof(buf), "SysType:%2x Data:%8x : %s", getSysMesType(), getSysMesData(), sysbuf); - - break; - } // case MSG_SYS: - case MSG_GET4_SLC: - { - // 32b GET4 slow control message - uint32_t get4_32b_sl_chip = getGet4V10R32ChipId(); - uint32_t get4_32b_sl_data = getGet4V10R32SlData(); - uint32_t get4_32b_sl_type = getGet4V10R32SlType(); - uint32_t get4_32b_sl_edge = getGet4V10R32SlEdge(); - uint32_t get4_32b_sl_chan = getGet4V10R32SlChan(); - - snprintf(buf, sizeof(buf), - "Get4 V1 32 bits, chip %02d, type:0x01 => Slow control Chan:%01d Edge:%01d Type:%01x Data:0x%06x", - get4_32b_sl_chip, get4_32b_sl_chan, get4_32b_sl_edge, get4_32b_sl_type, get4_32b_sl_data ); - - /* - // For csv files output - snprintf(buf, sizeof(buf), - "Get4 V1 32 bits, type:0x01 => ;chip;%02d;Slow control ;;;;;;;;;;;;;;Chan:;%01d ;Edge:;%01d ;Type:;%01x ;Data:;0x%06x;", - get4_32b_sl_chip, get4_32b_sl_chan, get4_32b_sl_edge, get4_32b_sl_type, get4_32b_sl_data ); - */ - break; - } - case MSG_GET4_32B: - { - // 32b GET4 data event - uint32_t get4_32b_dat_chip = getGet4V10R32ChipId(); - uint32_t get4_32b_dat_tot = getGet4V10R32HitTot(); - uint32_t get4_32b_dat_ft = getGet4V10R32HitFt(); - uint32_t get4_32b_dat_ts = getGet4V10R32HitTs(); - uint32_t get4_32b_dat_chan = getGet4V10R32HitChan(); - uint32_t get4_32b_dat_dll = getGet4V10R32HitDllFlag(); - - snprintf(buf, sizeof(buf), - "Get4 V1 32 bits, chip %02d, type:0x11 => Data Dll %1d Channel %1d Ts:0x%03x Ft:0x%02x Tot:0x%02x", - get4_32b_dat_chip, get4_32b_dat_dll, get4_32b_dat_chan, get4_32b_dat_ts, - get4_32b_dat_ft, get4_32b_dat_tot); - - /* - // For csv files output - snprintf(buf, sizeof(buf), - "Get4 V1 32 bits, type:0x11 => ;chip;%02d;Data ;;;;Dll; %1d ;Channel; %1d ;Ts:;%04d ;Ft:;%03d ;Tot:;%03d;", - get4_32b_dat_chip, get4_32b_dat_dll, get4_32b_dat_chan, get4_32b_dat_ts, - get4_32b_dat_ft, get4_32b_dat_tot); - */ - break; - } // case MSG_GET4_32B: - default: - snprintf(buf, sizeof(buf), "Error - unexpected MessageType: %1x", getMessageType()); - } - } - -// os << buf << std::endl; - if( msg_print_Cout == outType) - std::cout << buf << std::endl; - else LOG(info) << sLogBuff << buf; -} - -uint32_t get4v1x::Message::RawSize(int fmt) -{ - switch (fmt) { - case formatEth1: return 6; - case formatOptic1: return 8; - case formatEth2: return 6; - case formatOptic2: return 8; - case formatNormal: return 8; - } - return 8; -} - -bool get4v1x::Message::assign(void* src, int fmt) -{ - switch (fmt) { - case formatEth1: - convertFromOld(src); - return true; - case formatOptic1: - convertFromOld((uint8_t*) src + 2); - setRocNumber((*((uint8_t*) src) << 8) | *((uint8_t*) src + 1) ); - return true; - case formatEth2: - memcpy(&data, src, 6); - return true; - case formatOptic2: - memcpy(&data, (uint8_t*) src + 2, 6); - setRocNumber(*((uint16_t*) src)); - return true; - case formatNormal: - memcpy(&data, src, 8); - return true; - } - - return false; -} - -bool get4v1x::Message::copyto(void* tgt, int fmt) -{ - switch (fmt) { - case formatEth1: - convertToOld(tgt); - return true; - case formatOptic1: - convertToOld((uint8_t*) tgt + 2); - *((uint16_t*) tgt) = getRocNumber(); - return true; - case formatEth2: - memcpy(tgt, &data, 6); - return true; - case formatOptic2: - memcpy((uint8_t*) tgt + 2, &data, 6); - *((uint16_t*) tgt) = getRocNumber(); - return true; - case formatNormal: - memcpy(tgt, &data, 8); - return true; - } - - return false; - -} diff --git a/beamtime/cern2014/unpacker/CbmGet4v1xToolsDef.h b/beamtime/cern2014/unpacker/CbmGet4v1xToolsDef.h deleted file mode 100644 index 5b522fa2876823f3173276258d129406ca4fe316..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/unpacker/CbmGet4v1xToolsDef.h +++ /dev/null @@ -1,526 +0,0 @@ -#ifndef GET4_V1_X_TOOLS_DEF_H -#define GET4_V1_X_TOOLS_DEF_H - -#ifdef HAVE_UINT8_T_HEADER_FILE -#include <_types/_uint8_t.h> -//#include <_types/_uint16_t.h> -#include <_types/_uint32_t.h> -#include <_types/_uint64_t.h> -#else -#include <stdint.h> -#endif - -namespace get4v1x { - - - enum MessageFormat { - formatEth1 = 0, // original message format with big-endian coding, 6-byte - formatOptic1 = 1, // original message format with big-endian coding, add 2 byte send/recv info, 8-byte - formatEth2 = 2, // new message format with little-endian coding, 6-byte - formatOptic2 = 3, // new message format with little-endian coding, add 2 byte send/recv info, 8-byte - formatNormal = 4 // new message format with little-endian coding, 16-bit roc number (default) - }; - - enum MessageTypes { - MSG_NOP = 0, - MSG_HIT = 1, - MSG_EPOCH = 2, - MSG_SYNC = 3, - MSG_AUX = 4, - MSG_EPOCH2 = 5, - MSG_GET4 = 6, - MSG_SYS = 7, - MSG_GET4_SLC = 8, - MSG_GET4_32B = 9 - }; - - enum SysMessageTypes { - SYSMSG_DAQ_START = 1, // indicates start daq in data stream - SYSMSG_DAQ_FINISH = 2, // stop daq - SYSMSG_NX_PARITY = 3, // nx_parity error - SYSMSG_SYNC_PARITY = 4, // sync parity error - SYSMSG_DAQ_RESUME = 5, // daq resume due to low/high water marker, only in udp case - SYSMSG_FIFO_RESET = 6, // FPGA fifo reset - SYSMSG_USER = 7, // user define message, generated by writing into ROC_ADDSYSMSG register - SYSMSG_PCTIME = 8, // contains value of time() function, indicates when message was created on PC - SYSMSG_ADC = 9, // contains feb1d (1 bit), channel id (7 bit) and adc value (24 bit), measured on PC - SYSMSG_PACKETLOST = 10, // inserted by udp transport when packet was lost at this place - SYSMSG_GET4_EVENT = 11, // GET4 event - SYSMSG_CLOSYSYNC_ERROR = 12, // added to data stream when the closy-sync-strobe does not match the rocs 156MHz timestamp counter - SYSMSG_TS156_SYNC = 13 // added when 156MHz timestamp counter is reset by a DLM - }; - - enum SysMessageUserTypes { - SYSMSG_USER_CALIBR_ON = 7, - SYSMSG_USER_CALIBR_OFF = 8, - SYSMSG_USER_RECONFIGURE = 9 - }; - - enum MessagePrintMask { - msg_print_Prefix = 1, - msg_print_Data = 2, - msg_print_Hex = 4, - msg_print_Human = 8 - }; - - enum MessagePrintType { - msg_print_Cout = 1, - msg_print_FairLog = 2, - }; - - class Message { - - protected: - uint64_t data; // main and only storage field for the message - - public: - Message() : data(0) {} - - Message(const Message& src) : data(src.data) {} - - void assign(const Message& src) { data = src.data; } - - Message& operator=(const Message& src) { assign(src); return *this; } - - inline void reset() { data = 0; } - - inline uint64_t getData() const { return data; } - inline void setData( uint64_t value) { data = value; } - - inline uint32_t getField(uint32_t shift, uint32_t len) const - { return (data >> shift) & ((((uint32_t)1) << len) - 1); } - - inline void setField(uint32_t shift, uint32_t len, uint32_t value) - { data = (data & ~(((((uint64_t) 1) << len) - 1) << shift)) | (((uint64_t) value) << shift); } - - inline uint8_t getBit(uint32_t shift) const - { return (data >> shift) & 1; } - - inline void setBit(uint32_t shift, uint8_t value) - { data = value ? (data | (((uint64_t) 1) << shift)) : (data & ~(((uint64_t) 1) << shift)) ; } - - - inline uint32_t getFieldBE(uint32_t shift, uint32_t len) const - { return (dataBE() >> shift) & ((((uint32_t)1) << len) - 1); } - inline uint8_t getBitBE(uint32_t shift) const - { return (dataBE() >> shift) & 1; } - inline uint64_t dataBE() const - { return ((data&0x00000000000000FF)<<56)+ - ((data&0x000000000000FF00)<<40)+ - ((data&0x0000000000FF0000)<<24)+ - ((data&0x00000000FF000000)<< 8)+ - ((data>> 8)&0x00000000FF000000)+ - ((data>>24)&0x0000000000FF0000)+ - ((data>>40)&0x000000000000FF00)+ - ((data>>56)&0x00000000000000FF); - } - - // --------------------------- common fields --------------------------------- - - //! Returns the message type. Valid for all message types. 4 bit - inline uint8_t getMessageType() const { return getField(0, 4); } - - //! Returns the number of the sending ROC. Valid for all message types. - /*! - * The field has full 16 bits and allows to aggregate data of up to 64K ROC's - * in one message stream. - */ - inline uint16_t getRocNumber() const { return getField(48, 16); } - - //! Sets the message type field in the current message - inline void setMessageType(uint8_t v) { setField(0, 4, v); } - - //! Sets the ROC number field in the current message - inline void setRocNumber(uint16_t v) { setField(48, 16, v); } - - - // ---------- nXYTER Hit data access methods ---------------- - - //! For Hit data: Returns nXYTER number (2 bit field) - /*! - * A ROC can support up to 2 FEBs with a total of 4 nXYTER chips. - * This field identifies FEB as well as chip. Each supported - * configuration (either 2 x FEB1nx/FEB2nx or a single FEB4nx) - * as a unique nXYTER chip numbering. - */ - inline uint8_t getNxNumber() const { return getField(6, 2); } - - //! For Hit data: Returns 3 most significant bits of ROC LTS (3 bit field) - /*! - * The 3 MSBs of the ROC local time stamp counter at the time of data - * capture are stored in this field. A comparison of this number, - * which reflects the time of readout, and the 3 MSBs of the timestamp - * (returned by getNxLtsMsb() const), which reflects the time of the - * hit, allows to estimate the time the hit stayed in the nXYTER internal - * FIFOs. This in turn gives an indication of the data load in the - * nXYTER. - */ - inline uint8_t getNxLtsMsb() const { return getField(8, 3); } - - //! For Hit data: Returns nXYTER time stamp (14 bit field) - /*! - * Raw timestamp as delivered by the nXYTER. The last-epoch flag - * (returned by getNxLastEpoch() const) determines whether the - * hit belongs to the current or the last epoch. Use the - * getMsgFullTime(uint32_t) const method to determine the - * expanded and adjusted timestamp.inline uint32_t getSysMesData() const { return getField(16, 32); } - */ - inline uint16_t getNxTs() const { return getField(11, 14); } - - //! For Hit data: Returns nXYTER channel number (7 bit field) - inline uint8_t getNxChNum() const { return getField(25, 7); } - - // 1 bit unused - - //! For Hit data: Returns ADC value (12 bit field) - inline uint16_t getNxAdcValue() const { return getField(33, 12); } - - //! For Hit data: Returns nXYTER pileup flag (1 bit field) - /*! - * This flag is set when the nXYTER trigger circuit detected two hits - * during the peak sense time interval of the slow amplitude channel. - * This flag indicates that separation between two hits was smaller than - * what can be handled by the amplitude channel. \sa getNxOverflow() const - */ - inline uint8_t getNxPileup() const { return getBit(45); } - - //! For Hit data: Returns nXYTER overflow flag (1 bit field) - /*! - * This flag is set when a nXYTER channels detects a hit but this hit - * can't be stored because the 4 stage channel FIFO is full. This flag - * indicates that the hit data rate was higher than the chip can handle - * over a longer time. \sa getNxPileup() const - */ - inline uint8_t getNxOverflow() const { return getBit(46); } - - //! For Hit data: Returns nXYTER last-epoch flag (1 bit field) - /*! - * This flag is set when the hit actually belong to the previous epoch. - * Use the getMsgFullTime(uint32_t) const method to determine the - * expanded and adjusted timestamp. - */ - inline uint8_t getNxLastEpoch() const { return getBit(47); } - - - //! For Hit data: Sets nXYTER number (2 bit field) - inline void setNxNumber(uint8_t v) { setField(6, 2, v); } - - //! For Hit data: Sets 3 most significant bits of ROC LTS (3 bit field) - inline void setNxLtsMsb(uint8_t v) { setField(8, 3, v); } - - //! For Hit data: Sets nXYTER time stamp (14 bit field) - inline void setNxTs(uint16_t v) { setField(11, 14, v); } - - //! For Hit data: Sets nXYTER channel number (7 bit field) - inline void setNxChNum(uint8_t v) { setField(25, 7, v); } - - // 1 bit unused - - //! For Hit data: Sets ADC value (12 bit field) - inline void setNxAdcValue(uint16_t v) { setField(33, 12, v); } - - //! For Hit data: Sets nXYTER pileup flag (1 bit field) - inline void setNxPileup(uint8_t v) { setBit(45, v); } - - //! For Hit data: Sets nXYTER overflow flag (1 bit field) - inline void setNxOverflow(uint8_t v) { setBit(46,v ); } - - //! For Hit data: Sets nXYTER last-epoch flag (1 bit field) - inline void setNxLastEpoch(uint8_t v) { setBit(47, v); } - - // ---------- Epoch marker access methods ------------ - - // 2 bit unused - - //! For Epoch data: Returns current epoch number (32 bit field) - // inline uint32_t getEpochNumber() const { return getField(8, 32); } - // on some machines 32-bit field is not working - inline uint32_t getEpochNumber() const { return data >> 8; } - - - //! For Epoch data: Returns number of missed hits (8 bit field) - inline uint8_t getEpochMissed() const { return getField(40, 8); } - - //! For Epoch data: Sets epoch number (32 bit field) - inline void setEpochNumber(uint32_t v) { setField(8, 32, v); } - - //! For Epoch data: Sets missed hits count (8 bit field) - inline void setEpochMissed(uint8_t v) { setField(40, 8, v); } - - - // ---------- Sync marker access methods ------------- - - //! For Sync data: Returns sync channel number (2 bit field) - inline uint8_t getSyncChNum() const { return getField(6, 2); } - - //! For Sync data: Returns sync time stamp (13 bit field, 2 ns bins) - inline uint16_t getSyncTs() const { return getField(8, 13) << 1; } - - //! For Sync data: Returns LSB of true epoch (1 bit field) - inline uint8_t getSyncEpochLSB() const { return getBit(21); } - - //! For Sync data: Returns sync message data (24 bit field) - inline uint32_t getSyncData() const { return getField(22, 24); } - - //! For Sync data: Returns sync status flags (2 bit field) - inline uint8_t getSyncStFlag() const { return getField(46, 2); } - - - //! For Sync data: Set sync channel number (2 bit field) - inline void setSyncChNum(uint8_t v) { setField(6, 2, v); } - - //! For Sync data: Set sync time stamp (13 bit field, 2 ns bins ) - inline void setSyncTs(uint16_t v) { setField(8, 13, v >> 1); } - - //! For Sync data: Set LSB of true epoch (1 bit field) - inline void setSyncEpochLSB(uint8_t v) { setBit(21, v); } - - //! For Sync data: Set sync message data (24 bit field) - inline void setSyncData(uint32_t v) { setField(22, 24, v); } - - //! For Sync data: Set sync status flags (2 bit field) - inline void setSyncStFlag(uint8_t v) { setField(46, 2, v); } - - - // ---------- AUX marker access methods -------------- - - //! For Aux data: Returns aux channel number (7 bit field) - inline uint8_t getAuxChNum() const { return getField(6, 7); } - - //! For Aux data: Returns aux time stamp (13 bit field, 2 ns bins) - inline uint16_t getAuxTs() const { return getField(13, 13) << 1; } - - //! For Aux data: Returns LSB of true epoch (1 bit field) - inline uint8_t getAuxEpochLSB() const { return getBit(26); } - - //! For Aux data: Returns falling edge flag (1 bit flag) - inline uint8_t getAuxFalling() const { return getBit(27); } - - //! For Aux data: Returns overflow flag (1 bit field) - inline uint8_t getAuxOverflow() const { return getBit(28); } - - - //! For Aux data: Set aux channel number (7 bit field) - inline void setAuxChNum(uint8_t v) { setField(6, 7, v); } - - //! For Aux data: Set aux time stamp (13 bit field) - inline void setAuxTs(uint16_t v) { setField(13, 13, v >> 1); } - - //! For Aux data: Set LSB of true epoch (1 bit field) - inline void setAuxEpochLSB(uint8_t v) { setBit(26, v); } - - //! For Aux data: Set falling edge flag (1 bit flag) - inline void setAuxFalling(uint8_t v) { setBit(27, v); } - - //! For Aux data: Set overflow flag (1 bit field) - inline void setAuxOverflow(uint8_t v) { setBit(28, v); } - - // ---------- Epoch2 marker access methods ------------ - - //! For Epoch2 data: Returns epoch missmatch flag (set in ROC when - //! ROC timestamp and timestamp send by GET4 did not match) (1 bit field) - inline uint32_t getEpoch2EpochMissmatch() const { return getBit(4); } - - //! For Epoch2 data: Returns epoch-lost flag (1 bit field) - inline uint32_t getEpoch2EpochLost() const { return getBit(5); } - - //! For Epoch2 data: Returns data-lost flag (1 bit field) - inline uint32_t getEpoch2DataLost() const { return getBit(6); } - - //! For Epoch2 data: Returns sync flag (1 bit field) - inline uint32_t getEpoch2Sync() const { return getBit(7); } - - //! For Epoch2 data: Returns the LTS156 bits 11 to 8. This - //! gives information at what time in the Epoche the epoche number - //! was set (2 bit field) - inline uint32_t getEpoch2StampTime() const { return getField(8, 2); } - - //! For Epoch2 data: Returns the epoch number (32 bit field) - // on some machines 32-bit field is not working - inline uint32_t getEpoch2Number() const { return (data >> 10) & 0xFFFFFFFF; } - - //! For Epoch2 data: Returns the number of the GET4 chip that send - //! the epoche message (6 bit field) - inline uint32_t getEpoch2ChipNumber() const { return getField(42, 6); } - - //! For Epoch2 data: Set epoch missmatch flag (1 bit field) - inline void setEpoch2EpochMissmatch(uint32_t v) { setBit(4, v); } - - //! For Epoch2 data: Set epoch-lost flag (1 bit field) - inline void setEpoch2EpochLost(uint32_t v) { setBit(5, v); } - - //! For Epoch2 data: Set data-lost flag (1 bit field) - inline void setEpoch2DataLost(uint32_t v) { setBit(6, v); } - - //! For Epoch2 data: Set sync flag (1 bit field) - inline void setEpoch2Sync(uint32_t v) { setBit(7, v); } - - //! For Epoch2 data: Set the LTS156 bits 11 to 8. This - //! gives information at what time in the Epoche the epoche number - //! was set (2 bit field) - inline void setEpoch2StampTime(uint32_t v) { setField(8, 2, v); } - - //! For Epoch2 data: Set the epoch number (32 bit field) - inline void setEpoch2Number(uint32_t v) { setField(10, 32, v); } - - //! For Epoch2 data: Set the number of the GET4 chip that send - //! the epoche message (6 bit field) - inline void setEpoch2ChipNumber(uint32_t v) { setField(42, 6, v); } - - // ---------- Get4 Hit data access methods ---------------- - - //! For Get4 data: Returns Get4 chip number (6 bit field) - inline uint8_t getGet4Number() const { return getField(6, 6); } - - //! For Get4 data: Returns Get4 channel number (2 bit field) - inline uint8_t getGet4ChNum() const { return getField(12, 2); } - - //! For Get4 data: Returns Get4 time stamp, 50 ps binning (19 bit field) - inline uint32_t getGet4Ts() const { return getField(14, 19); } - - //! For Get4 data: Returns Get4 rising or falling edge (1 bit field) - inline uint32_t getGet4Edge() const { return getBit(33); } - - //! For Get4 data: Returns the CRC-8 of the rest of the message. - //! For details check the ROC documentation. (8 bit field) - inline uint32_t getGet4CRC() const { return getField(40, 8); } - - - //! For Get4 data: Sets Get4 chip number (6 bit field) - inline void setGet4Number(uint8_t v) { setField(6, 6, v); } - - //! For Get4 data: Sets Get4 channel number (2 bit field) - inline void setGet4ChNum(uint8_t v) { setField(12, 2, v); } - - //! For Get4 data: Sets Get4 time stamp, 50 ps binning (19 bit field) - inline void setGet4Ts(uint32_t v) { setField(14, 19, v); } - - //! For Get4 data: Sets Get4 rising or falling edge (1 bit field) - inline void setGet4Edge(uint32_t v) { setBit(33, v); } - - //! For Get4 data: Set the CRC-8 of the rest of the message - //! For details check the ROC documentation. (8 bit field) - inline void setGet4CRC(uint32_t v) { setField(40, 8, v); } - - // ---------- System message access methods ---------- - - // 2 bit unused - - //! For SysMes data: Returns system message subtype (8 bit field) - inline uint8_t getSysMesType() const { return getField(8, 8); } - - //! For SysMes data: Returns system message data (32 bit field) - // inline uint32_t getSysMesData() const { return getField(16, 32); } - // on some machine 32-bit field not working - inline uint32_t getSysMesData() const { return data >> 16; } - - //! For SysMes data: Set system message type (8 bit field) - inline void setSysMesType(uint8_t v) { setField(8, 8, v); } - - //! For SysMes data: Set system message data (32 bit field) - inline void setSysMesData(uint32_t v) { setField(16, 32, v); } - - // ---------- Get4 v1.x 32b data access methods ---------------- - inline uint8_t getGet4V10R32ChipId() const { return getField( 4, 6); } - // type 1 => Slow control - inline uint8_t getGet4V10R32SlChan() const { return getField( 10, 2); } - inline bool getGet4V10R32SlEdge() const { return getBit( 12); } - inline uint8_t getGet4V10R32SlType() const { return getField( 13, 2); } - inline uint32_t getGet4V10R32SlData() const { return getField( 16,24); } - // type 2 => Error message: encapsulated in SysMes subtype SYSMSG_GET4_EVENT - inline uint8_t isGet4Err24bit() const { return 0x10 == getField( 24, 2); } - inline uint8_t isGet4Err32bit() const { return 0x100 == getField( 16, 3); } - // 24 bits mode - inline uint8_t getGet4V10R24ErrorChan() const { return getField( 26, 2); } - inline bool getGet4V10R24ErrorEdge() const { return getBit( 28); } - inline uint8_t getGet4V10R24ErrorUnused() const { return getField( 29, 6); } - inline uint8_t getGet4V10R24ErrorChip() const { return getField( 35, 6); } // or getField(40, 8) - inline uint8_t getGet4V10R24ErrorData() const { return getField( 41, 7); } - // 32 bits mode - inline bool getGet4V10R32ErrorEdge() const { return getBit( 19); } - inline uint8_t getGet4V10R32ErrorChan() const { return getField( 20, 2); } - inline uint16_t getGet4V10R32ErrorUnused() const { return getField( 22,13); } - inline uint8_t getGet4V10R32ErrorChip() const { return getField( 35, 6); } - inline uint8_t getGet4V10R32ErrorData() const { return getField( 41, 7); } - // type 3 => Hit Data - inline uint8_t getGet4V10R32HitChan() const { return getField( 10, 2); } - inline bool getGet4V10R32HitDllFlag() const { return getBit( 12); } - inline uint32_t getGet4V10R32HitTs() const { return getField( 13,12); } - inline uint8_t getGet4V10R32HitFt() const { return getField( 24, 7); } - inline uint32_t getGet4V10R32HitTimeBin() const { return getField( 13,19); } - inline uint8_t getGet4V10R32HitTot() const { return getField( 32, 8); } - inline uint32_t getGet4V10R32HitCRC() const { return getField( 40, 8); } - - - // ---------- Common functions ----------------------- - - //! Returns \a true is message type is #MSG_NOP (filler message) - inline bool isNopMsg() const { return getMessageType() == MSG_NOP; } - //! Returns \a true is message type is #MSG_HIT (nXYTER hit data) - inline bool isHitMsg() const { return getMessageType() == MSG_HIT; } - //! Returns \a true is message type is #MSG_EPOCH (epoch marker) - inline bool isEpochMsg() const { return getMessageType() == MSG_EPOCH;} - //! Returns \a true is message type is #MSG_SYNC - inline bool isSyncMsg() const { return getMessageType() == MSG_SYNC; } - //! Returns \a true is message type is #MSG_AUX - inline bool isAuxMsg() const { return getMessageType() == MSG_AUX; } - //! Returns \a true is message type is #MSG_EPOCH2 (epoch2 marker) - inline bool isEpoch2Msg() const { return getMessageType() == MSG_EPOCH2;} - //! Returns \a true is message type is #MSG_GET4 (Get4 hit data) - inline bool isGet4Msg() const { return getMessageType() == MSG_GET4; } - //! Returns \a true is message type is #MSG_SYS (system message) - inline bool isSysMsg() const { return getMessageType() == MSG_SYS; } - //! Returns \a true is message type is #MSG_GET4_SLC (system message) - inline bool isGet4SlCtrMsg() const { return getMessageType() == MSG_GET4_SLC; } - //! Returns \a true is message type is #MSG_GET4_32B (system message) - inline bool isGet4Hit32Msg() const { return getMessageType() == MSG_GET4_32B; } - - //! Returns \a true if system message and subtype #ROC_SYSMSG_DAQ_START - inline bool isStartDaqMsg() const - { return isSysMsg() && (getSysMesType() == SYSMSG_DAQ_START); } - //! Returns \a true if system message and subtype #ROC_SYSMSG_DAQ_FINISH - inline bool isStopDaqMsg() const - { return isSysMsg() && (getSysMesType() == SYSMSG_DAQ_FINISH); } - - - void printDataCout(unsigned kind = msg_print_Prefix | msg_print_Data, uint32_t epoch = 0) const; - void printDataLog(unsigned kind = msg_print_Prefix | msg_print_Data, uint32_t epoch = 0) const; - -// void printData(std::ostream& os, unsigned kind = msg_print_Human, uint32_t epoch = 0) const; - void printData(unsigned outType = msg_print_Cout, unsigned kind = msg_print_Human, - uint32_t epoch = 0) const; - - uint64_t getMsgFullTime(uint32_t epoch) const; - - double getMsgFullTimeD(uint32_t epoch) const; - - //! Expanded timestamp for 250 MHz * 14 bit epochs - inline static uint64_t FullTimeStamp(uint32_t epoch, uint16_t stamp) - { return ((uint64_t) epoch << 14) | (stamp & 0x3fff); } - - //! Expanded timestamp for 250/8*5 MHz * 19 bit epochs - inline static uint64_t FullTimeStamp2(uint32_t epoch, uint32_t stamp) - { return ((uint64_t) epoch << 19) | (stamp & 0x7ffff); } - - - static uint64_t CalcDistance(uint64_t start, uint64_t stop); - - static double CalcDistanceD(double start, double stop); - - // -------------------- methods for working with different formats - - static uint32_t RawSize(int fmt); - - bool convertFromOld(void* src); - - bool convertToOld(void* tgt); - - bool assign(void* src, int fmt = formatNormal); - - bool copyto(void* tgt, int fmt = formatNormal); - }; - -} - - -#endif // GET4_V1_X_TOOLS_DEF_H diff --git a/beamtime/cern2014/unpacker/CbmTSUnpackDummy.cxx b/beamtime/cern2014/unpacker/CbmTSUnpackDummy.cxx deleted file mode 100644 index b7710eafb8e1207f7d13d01883e5e66e14c97d1b..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/unpacker/CbmTSUnpackDummy.cxx +++ /dev/null @@ -1,18 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmTSUnpackDummy ----- -// ----- Created 21.11.2014 by F. Uhlig ----- -// ----- ----- -// ----------------------------------------------------------------------------- -#include "CbmTSUnpackDummy.h" - -CbmTSUnpackDummy::CbmTSUnpackDummy() - : CbmTSUnpack() -{ -} - -CbmTSUnpackDummy::~CbmTSUnpackDummy() -{ -} - -ClassImp(CbmTSUnpackDummy) diff --git a/beamtime/cern2014/unpacker/CbmTSUnpackDummy.h b/beamtime/cern2014/unpacker/CbmTSUnpackDummy.h deleted file mode 100644 index 5daf8cecfb9b0e341f069c6741ccdf5c33e2dcc6..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/unpacker/CbmTSUnpackDummy.h +++ /dev/null @@ -1,39 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmTSUnpackDummy ----- -// ----- Created 21.11.2014 by F. Uhlig ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CBMTSUNPACKDUMMY_H -#define CBMTSUNPACKDUMMY_H - -#include "Timeslice.hpp" - - -#include "CbmTSUnpack.h" - -class CbmTSUnpackDummy : public CbmTSUnpack -{ - public: - - CbmTSUnpackDummy(); - virtual ~CbmTSUnpackDummy(); - - virtual Bool_t Init() { return kTRUE; } - - virtual Bool_t DoUnpack(const fles::Timeslice& /*ts*/, size_t /*component*/) - { return kTRUE; } - - virtual void Reset() { return; } - - virtual void Finish() { return; } - - void SetParContainers() {;} - - virtual void FillOutput(boost::any){;} - - ClassDef(CbmTSUnpackDummy, 1) -}; - -#endif diff --git a/beamtime/cern2014/unpacker/CbmTSUnpackFiberHodo.cxx b/beamtime/cern2014/unpacker/CbmTSUnpackFiberHodo.cxx deleted file mode 100644 index b444d2818e9e3926f3575ad99d16c77d63c2f8be..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/unpacker/CbmTSUnpackFiberHodo.cxx +++ /dev/null @@ -1,247 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmTSUnpackFiberHodo ----- -// ----- Created 07.11.2014 by ----- -// ----- E. Ovcharenko, F. Uhlig ----- -// ----- ----- -// ----------------------------------------------------------------------------- -#include "CbmTSUnpackFiberHodo.h" - -#include "CbmNxyterRawMessage.h" -#include "CbmFiberHodoDigi.h" -#include "CbmFiberHodoAddress.h" -#include "CbmNxyterRawMessage.h" -#include "CbmFiberHodoMapping.h" - -#include "FairLogger.h" -#include "FairRootManager.h" - -#include "TClonesArray.h" - -#include <iostream> -#include <stdint.h> - -//#define VERBOSE - -struct DTM_header -{ - uint8_t packet_length; - uint8_t packet_counter; - uint16_t ROC_ID; -}; - -struct hit_data -{ - uint8_t MessageType; // message type: typ. hit (01) or epoch (02) - uint8_t NxNumber; // nxyter number - uint8_t NxLtxMsb; // ROC TS MSBs - uint16_t NxTs; // timestamp value from nxyter - uint8_t NxChNum; // channel number - uint16_t NxAdcValue; // ADC value - bool NxPileUp; // pileup flag - bool NxOverflow; // overflow flag - bool NxLastEpoch; // last epoch flag - - void Dump() { - /* - printf("MessageType=%02X, NxNumber=%02X, NxLtxMsb=%02X, NxTs=%04X, NxChNum=%02X, NxAdcValue=%04X, NxPileUp=%d, NxOverflow=%d, NxLastEpoch=%d\n", - MessageType, NxNumber, NxLtxMsb, NxTs, NxChNum, - NxAdcValue, NxPileUp, NxOverflow, NxLastEpoch); - */ - } -}; - - - -CbmTSUnpackFiberHodo::CbmTSUnpackFiberHodo() - : CbmTSUnpack(), - fCurrEpoch(0), - fFiberHodoRaw(new TClonesArray("CbmNxyterRawMessage", 10)), - fFiberHodoDigi(new TClonesArray("CbmFiberHodoDigi", 10)), - fRawMessage(NULL), - fDigi(NULL), - fHodoMap(new CbmFiberHodoMapping()), - fBuffer(CbmTbDaqBuffer::Instance()) -{ -} - -CbmTSUnpackFiberHodo::~CbmTSUnpackFiberHodo() -{ - if ( fBuffer ) delete fBuffer; -} - -Bool_t CbmTSUnpackFiberHodo::Init() -{ - LOG(info) << "Initializing"; - - FairRootManager* ioman = FairRootManager::Instance(); - if (ioman == NULL) { - LOG(fatal) << "No FairRootManager instance"; - } - ioman->Register("FiberHodoRawMessage", "fiberhodo raw data", fFiberHodoRaw, kTRUE); - ioman->Register("FiberHodoDigi", "fiber hodo digi", fFiberHodoDigi, kTRUE); - - return kTRUE; -} - -Bool_t CbmTSUnpackFiberHodo::DoUnpack(const fles::Timeslice& ts, size_t component) -{ - LOG(debug) << "Unpacking FiberHodo Data"; - - Int_t counter=0; //TODO was ist das??? - - DTM_header cur_DTM_header; - hit_data cur_hit_data; - - for (size_t m = 0; m < ts.num_microslices(component); ++m) { - // iterate over microslice - auto msDescriptor = ts.descriptor(component, m); - const uint8_t* msContent = reinterpret_cast<const uint8_t*>(ts.content(component, m)); - - uint32_t offset = 16; - uint32_t local_offset = 0; - const uint8_t* msContent_shifted; - int padding; - - // Loop throught the data of one microslice - while (offset < msDescriptor.size) { - msContent_shifted = &msContent[offset]; - - // Extract DTM header info - cur_DTM_header.packet_length = msContent_shifted[0]; - cur_DTM_header.packet_counter = msContent_shifted[1]; - const uint16_t* ROC_ID_pointer = reinterpret_cast<const uint16_t*>(&msContent_shifted[2]); - cur_DTM_header.ROC_ID = *ROC_ID_pointer; - -#ifdef VERBOSE - printf ("pack_len=0x%02X, pack_cnt=0x%02X, ROC=0x%04X\n", - cur_DTM_header.packet_length, cur_DTM_header.packet_counter, cur_DTM_header.ROC_ID); -#endif - - local_offset = 4; - while (local_offset < static_cast<uint32_t>(cur_DTM_header.packet_length*2+4)) { - - cur_hit_data.MessageType = (msContent_shifted[local_offset+5] >> 0) & 0x0F; // 1 byte - - if (cur_hit_data.MessageType == 1) // hit - { - cur_hit_data.NxNumber = (msContent_shifted[local_offset+5] >> 6) & 0x03; // 1 byte - cur_hit_data.NxLtxMsb = (msContent_shifted[local_offset+4] >> 0) & 0x07; // 1 byte - - uint16_t topTimestampVal =((msContent_shifted[local_offset+2] >> 0) & 0x0001) * 0x2000; // 2 bytes - uint16_t midTimestampVal =((msContent_shifted[local_offset+3] >> 0) ) * 0x0020; // 2 bytes - uint16_t lowTimestampVal = (msContent_shifted[local_offset+4] >> 3) & 0x001F; // 2 bytes - cur_hit_data.NxTs = topTimestampVal + midTimestampVal + lowTimestampVal; // 2 bytes - - cur_hit_data.NxChNum = (msContent_shifted[local_offset+2] >> 1) & 0x7F; // 1 byte - - uint16_t highADCval =((msContent_shifted[local_offset+0] >> 0) & 0x001F) * 0x0080; // 2 bytes - uint16_t lowADCval = (msContent_shifted[local_offset+1] >> 1) & 0x007F; // 2 bytes - cur_hit_data.NxAdcValue = highADCval + lowADCval; // 2 bytes - - cur_hit_data.NxPileUp = (msContent_shifted[local_offset+0] >> 5) & 0x01; // 1 bit - cur_hit_data.NxOverflow = (msContent_shifted[local_offset+0] >> 6) & 0x01; // 1 bit - cur_hit_data.NxLastEpoch = (msContent_shifted[local_offset+0] >> 7) & 0x01; // 1 bit - -#ifdef VERBOSE - printf("%02X%02X%02X%02X%02X%02X\t", msContent_shifted[local_offset], msContent_shifted[local_offset+1], - msContent_shifted[local_offset+2], msContent_shifted[local_offset+3], - msContent_shifted[local_offset+4], msContent_shifted[local_offset+5]); - cur_hit_data.Dump(); -#endif - - fRawMessage = new( (*fFiberHodoRaw)[counter] ) - CbmNxyterRawMessage(msDescriptor.eq_id, - cur_DTM_header.ROC_ID*4 + cur_hit_data.NxNumber, //TODO check - cur_hit_data.NxChNum, - fCurrEpoch - cur_hit_data.NxLastEpoch, // note the trick - cur_hit_data.NxTs, - cur_hit_data.NxAdcValue, - cur_hit_data.NxLastEpoch, - cur_hit_data.NxPileUp, - cur_hit_data.NxOverflow); - ++counter; - - FillHodoDigiToBuffer(); - - } else if (cur_hit_data.MessageType == 2) { // epoch counter - - uint32_t topEpochByte = msContent_shifted[local_offset+1] * 0x01000000; - uint32_t higEpochByte = msContent_shifted[local_offset+2] * 0x00010000; - uint32_t midEpochByte = msContent_shifted[local_offset+3] * 0x00000100; - uint32_t lowEpochByte = msContent_shifted[local_offset+4]; - - fCurrEpoch = topEpochByte + higEpochByte + midEpochByte + lowEpochByte; -#ifdef VERBOSE - printf("epoch: %02X%02X%02X%02X%02X%02X:\t\t%d\n", msContent_shifted[local_offset], msContent_shifted[local_offset+1], - msContent_shifted[local_offset+2], msContent_shifted[local_offset+3], - msContent_shifted[local_offset+4], msContent_shifted[local_offset+5], - fCurrEpoch); -#endif - - } - - local_offset += 6; // next hit or epoch marker - } - -#ifdef VERBOSE - printf ("\n"); -#endif - - // add 4 - DTM header size - offset += static_cast<uint32_t>(cur_DTM_header.packet_length * 2+4); - // shift some more bytes to fit the CbmNet package size - if ((padding = offset % 8) > 0) offset += (8-padding); - - } - -#ifdef VERBOSE - printf ("\n"); -#endif - - } - - return kTRUE; -} - -void CbmTSUnpackFiberHodo::FillHodoDigiToBuffer() { - - // --- Get absolute time, NXYTER and channel number - Int_t eqId = fRawMessage->GetEquipmentID(); - ULong_t hitTime = fRawMessage->GetFullTime(); - Int_t febId = fRawMessage->GetSourceAddress(); - Int_t channelId = fRawMessage->GetChannelID(); - Int_t charge = fRawMessage->GetADCvalue(); - - Int_t iStation; - Int_t iSector; - Int_t iPlane; - Int_t iFiber; - - fHodoMap->Map(eqId, febId, channelId, iStation, iSector, iPlane, iFiber); - Int_t address = CbmFiberHodoAddress::GetAddress(iStation, iPlane, iFiber); - - - fDigi = new( (*fFiberHodoDigi)[fFiberHodoDigi->GetEntriesFast()] ) - CbmFiberHodoDigi(address, charge, hitTime); - - // --- Create a HODO digi and send it to the buffer - // CbmFiberHodoDigi* digi = new CbmFiberHodoDigi(address, charge, hitTime); - - fBuffer->InsertData<CbmFiberHodoDigi>(fDigi); - -} - -void CbmTSUnpackFiberHodo::Reset() -{ - fFiberHodoRaw->Clear(); -} - -/* -void CbmTSUnpackFiberHodo::Register() -{ -} -*/ - - -ClassImp(CbmTSUnpackFiberHodo) diff --git a/beamtime/cern2014/unpacker/CbmTSUnpackFiberHodo.h b/beamtime/cern2014/unpacker/CbmTSUnpackFiberHodo.h deleted file mode 100644 index a86e0fa30e10fc7360427f84aa1896f48266b630..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/unpacker/CbmTSUnpackFiberHodo.h +++ /dev/null @@ -1,62 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmTSUnpackFiberHodo ----- -// ----- Created 07.11.2014 by ----- -// ----- E. Ovcharenko, F. Uhlig ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CBMTSUNPACKFIBERHODO_H -#define CBMTSUNPACKFIBERHODO_H - -#include "Timeslice.hpp" - -#include "CbmTSUnpack.h" - -#include "CbmNxyterRawMessage.h" -#include "CbmFiberHodoDigi.h" -#include "CbmTbDaqBuffer.h" -#include "TClonesArray.h" - -class CbmFiberHodoMapping; - -class CbmTSUnpackFiberHodo : public CbmTSUnpack -{ - public: - - CbmTSUnpackFiberHodo(); - virtual ~CbmTSUnpackFiberHodo(); - - virtual Bool_t Init(); - - virtual Bool_t DoUnpack(const fles::Timeslice& ts, size_t component); - - virtual void Reset(); - - virtual void Finish() {;} - - void SetParContainers() {;} - // protected: - // virtual void Register(); - - virtual void FillOutput(boost::any){;} - - private: - Int_t fCurrEpoch; // Current epoch (first epoch in the stream initialises the - - TClonesArray* fFiberHodoRaw; - TClonesArray* fFiberHodoDigi; - CbmNxyterRawMessage* fRawMessage; - CbmFiberHodoDigi* fDigi; - CbmFiberHodoMapping* fHodoMap; - CbmTbDaqBuffer* fBuffer; - - void FillHodoDigiToBuffer(); - - CbmTSUnpackFiberHodo(const CbmTSUnpackFiberHodo&); - CbmTSUnpackFiberHodo operator=(const CbmTSUnpackFiberHodo&); - - ClassDef(CbmTSUnpackFiberHodo, 1) -}; - -#endif diff --git a/beamtime/cern2014/unpacker/CbmTSUnpackGet4v1x.cxx b/beamtime/cern2014/unpacker/CbmTSUnpackGet4v1x.cxx deleted file mode 100644 index 8b1be718fc0da9a9957d2e0263efcf1b49863299..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/unpacker/CbmTSUnpackGet4v1x.cxx +++ /dev/null @@ -1,3399 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmTSUnpackGet4v1x ----- -// ----- Created 15.12.2014 by ----- -// ----- P.-A. Loizeau ----- -// ----- Based on CbmTSUnpackGet4v1x ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#include "CbmTSUnpackGet4v1x.h" - -// Specific headers -#include "CbmGet4v1xDef.h" -#include "CbmGet4EpochBuffer.h" - -// FAIRROOT headers -#include "FairLogger.h" -#include "FairRootManager.h" - -// ROOT headers -#include "TF1.h" -#include "TProfile.h" -#include "TH2.h" -#include "TClonesArray.h" -#include "TFile.h" -#include "TMath.h" -#include "TTimeStamp.h" -#include "TROOT.h" - -// C++ std headers -#include <iostream> -#include <stdint.h> - -/********* - * TODO - * 1) Use the time sorted data => ~OK - * 2) Counts as function of time (s bin, per ch/chip/ROC/Det) => / OK / OK / OK - * 3) Split class - * 4) Time sorted data output => ~OK - * 5) Monitor size of closed epochs => OK - *********/ - -// Default values -const Double_t kdEvoBinSizeS = 1.5; -const Double_t kdEvoLengthSec = 1800.0; -//const Double_t kdMsSizeSec = 1e-3; // up to 01/03 15:00 -const Double_t kdMsSizeSec = 16384*8*(1e-9); // From to 01/03 15:00 - -const Int_t kiNbDet = 4; -const TString ksDetName[kiNbDet] = {"HDP2", "TSU", "HDP5", "USTC"}; -const UInt_t kuNbTdcMappedDet = 88; -const Int_t kiTdcDetMap[kuNbTdcMappedDet] = - { - 0, 0, 0, 0, 0, 0, 0, 0, // ROC 0 FEE 0 - 0, 0, 0, 0, 0, 0, 0, 0, // ROC 0 FEE 1 - 1, 1, 1, 1, 1, 1, 1, 1, // ROC 0 FEE 2 - 4, 4, 4, 4, 4, 4, 4, 4, // ROC 0 FEE 3 - 4, 4, 4, 4, 4, 4, 4, 4, // ROC 0 FEE 4 - 4, 4, 4, 4, 4, 4, 4, 4, // ROC 0 FEE 5 - 4, 4, 4, 4, 4, 4, 4, 4, // ROC 0 FEE 6 - 4, 4, 4, 4, 4, 4, 4, 4, // ROC 0 FEE 7 - 1, 1, 1, 1, 1, 1, 1, 1, // ROC 1 FEE 0 - 2, 2, 2, 2, 2, 2, 2, 2, // ROC 1 FEE 1 - 3, 3, 3, 3, 3, 3, 3, 3, // ROC 1 FEE 2 - }; - -struct DTM_header -{ - uint8_t packet_length; - uint8_t packet_counter; - uint16_t ROC_ID; - - void Dump() { - printf ("HEADER ======================= pack_len=0x%02X, pack_cnt=0x%02X, ROC=0x%04X\n", - packet_length, packet_counter, ROC_ID); - } -}; - -CbmTSUnpackGet4v1x::CbmTSUnpackGet4v1x() -: CbmTSUnpack(), - fbVerbose(kFALSE), - fiMode(0), - fsHistoFilename("./get4Monitor.hst.root"), - fuNbRocs(0), - fuNbGet4(0), - fuNbFee(0), - fuMsOverlapTs(0), - fvbActiveChips(), - fulTsNb(0), - fulMsNb(0), - fsMaxMsNb(0), - fuOffset(0), - fuMaxOffset(0), - fuLocalOffset(0), - fuMaxLocalOffset(0), - fvbRocFeetSyncStart(kFALSE), - fvbGet4WaitFirstSync(kTRUE), - fvuCurrEpoch(), - fvuCurrEpochCycle(), - fvuCurrEpoch2(), - fvuCurrEpoch2Cycle(), - fhMessageTypePerRoc(NULL), - fhRocSyncTypePerRoc(NULL), - fhRocAuxTypePerRoc(NULL), - fhSysMessTypePerRoc(NULL), - fhMessTypePerGet4(NULL), - fhGet4EpochFlags(NULL), - fhGet4EpochSyncDist(NULL), - fhGet4EpochJumps(NULL), - fhGet4ChanDataCount(NULL), - fhGet4ChanDllStatus(NULL), - fhGet4ChanTotMap(NULL), - fhGet4ChanErrors(NULL), - fhGet4ChanSlowContM(NULL), - fdEvoBinSizeS(kdEvoBinSizeS), - fdEvoLengthSec(kdEvoLengthSec), - fdMsLengthSec(kdMsSizeSec), - fhMsSizeEvo(NULL), - fvhRocDataCntEvo(), - fvhRocEpochCntEvo(), - fvhRocErrorCntEvo(), - fvhRocDataLossCntEvo(), - fvhRocEpochLossCntEvo(), - fvhGet4DataCntEvo(), - fvhGet4ErrorCntEvo(), - fvhGet4DataLossCntEvo(), - fvhGet4EpochLossCntEvo(), - fvhGet4ChDataCntEvo(), - fvhGet4ChErrorCntEvo(), - fvhDetDataCntEvo(), - fvhDetErrorCntEvo(), - fvhDetDataLossCntEvo(), - fvhDetEpochLossCntEvo(), - fhClosedEpSizeEvo(NULL), -/* - fbPulserMode(kFALSE), - fuPulserFee(0), - fuPulserChan(), - fhTimeResFee(), - fhTimeRmsAllFee(NULL), - fhTimeResAllFee(NULL), - fhTimeResPairs(), - fhTimeResCombi(), - fhPulserHitDistNs(NULL), - fhPulserHitDistUs(NULL), - fhPulserHitDistMs(NULL), - fhPulserFeeDnl(NULL), - fhPulserFeeInl(NULL), - fbOldReadoutOk(kFALSE), - fhGet4ChanTotCount(NULL), - fhPulserFeeTotDnl(NULL), - fhPulserFeeTotInl(NULL), -*/ - fvvhChannelsCoinc(), - fdMaxCoincDist(100.0), - fvuLastHitEp(), - fvmLastHit(), - fvuLastOldTotEp(), - fvmLastOldTot(), - fmsOrderedEpochsData(), - fmsOrderedEpochsBuffStat(), - fvuCurrEpochBuffer(), - fvuCurrEpochBufferIt(), - fuLastEpBufferReady(0), - fuCurrEpReadBuffer(0), - fEpochBuffer(NULL), - fbEnaCalibOutput(kFALSE), - fsCalibOutFoldername(""), - fsCalibFilename(""), - fvhFineTime() -{ -} - -CbmTSUnpackGet4v1x::~CbmTSUnpackGet4v1x() -{ -} - -Bool_t CbmTSUnpackGet4v1x::Init() -{ - LOG(info) << "Initializing"; - - FairRootManager* ioman = FairRootManager::Instance(); - if (ioman == NULL) { - LOG(fatal) << "No FairRootManager instance"; - } -// ioman->Register("Get4RawMessage", "GET4 raw data", fGet4Raw, kTRUE); -// ioman->Register("NxyterRawSyncMessage", "GET4 raw sync data", fGet4RawSync, kTRUE); - - if( 0 >= fuNbRocs || 0 >= fuNbGet4 ) - { - LOG(error) << "CbmTSUnpackGet4v1x::Init => Nb of ROCs or GET4s not defined!!! "; - LOG(error) << "Nb of ROCs:"<< fuNbRocs << " Nb of GET4s : " << fuNbGet4; - LOG(fatal) << "Please use the functions SetRocNb and/or SetGet4Nb before running!!"; - } - - // Initialize TS counter - fulTsNb = 0; - - // At start all ROCs and GET4 are considered "unsynchronized" - // Stay so until the DLM 10 is issued: ~/flesnet/build/sync_frontend - // The GET4 are synchronized after reception of 1st epoch2 with SYNC - fvbRocFeetSyncStart.resize( fuNbRocs); - for( UInt_t uRoc = 0; uRoc < fuNbRocs; uRoc++) - fvbRocFeetSyncStart[uRoc] = kFALSE; - fvbGet4WaitFirstSync.resize(fuNbGet4); - for( UInt_t uChip = 0; uChip < fuNbGet4; uChip++) - fvbGet4WaitFirstSync[uChip] = kTRUE; - - // Prepare the active chips flags - if( 0 == fvbActiveChips.size() && 0 < fuNbGet4 ) - { - fvbActiveChips.resize(fuNbGet4); - for( UInt_t uChip = 0; uChip < fuNbGet4; uChip++) - fvbActiveChips[uChip] = kTRUE; - } // if( 0 == fvbActiveChips.size() - // Prepare the epoch storing vectors - fvuCurrEpoch.resize( fuNbRocs); - fvuCurrEpochCycle.resize( fuNbRocs); - for( UInt_t uRoc = 0; uRoc < fuNbRocs; uRoc++) - { - fvuCurrEpoch[uRoc] = 0; - fvuCurrEpochCycle[uRoc] = 0; - } // for( UInt_t uRoc = 0; uRoc < fuNbRocs; uRoc++) - fvuCurrEpoch2.resize(fuNbGet4); - fvuCurrEpoch2Cycle.resize(fuNbGet4); - fvuCurrEpochBuffer.resize(fuNbGet4); - fvuCurrEpochBufferIt.resize(fuNbGet4); - for( UInt_t uChip = 0; uChip < fuNbGet4; uChip++) - { - fvuCurrEpoch2[uChip] = 0; - fvuCurrEpoch2Cycle[uChip] = 0; - fvuCurrEpochBuffer[uChip] = 0; - fvuCurrEpochBufferIt[uChip] = fmsOrderedEpochsData.end(); - } // for( UInt_t uChip = 0; uChip < fuNbGet4; uChip++) - - LOG(info) << "Initializing Histos"; - InitMonitorHistograms(); - LOG(info) << "Initialization done"; - - if( 2 == fiMode ) - { - LOG(info) << "Initializing Epoch buffer"; - fEpochBuffer = CbmGet4EpochBuffer::Instance(); - if( NULL == fEpochBuffer ) - LOG(fatal) << "Failed to Obtain the epoch buffer instance!"; - else LOG(info) << "Initialization done"; - } // if( 2 == fiMode ) - - return kTRUE; -} - -void CbmTSUnpackGet4v1x::SetActiveGet4( UInt_t uChipsIndex, Bool_t bActiveFlag) -{ - if( 0 == fvbActiveChips.size() && 0 < fuNbGet4 ) - { - fvbActiveChips.resize(fuNbGet4); - for( UInt_t uChip = 0; uChip < fuNbGet4; uChip++) - fvbActiveChips[uChip] = kTRUE; - } // if( 0 == fvbActiveChips.size() - - if( uChipsIndex < fuNbGet4 ) - fvbActiveChips[uChipsIndex] = bActiveFlag; - else LOG(error)<<" CbmTSUnpackGet4v1x::SetActiveGet4 => Invalid chip index " - << uChipsIndex; -} -/* -void CbmTSUnpackGet4v1x::SetPulserChans( - UInt_t inPulserChanA, UInt_t inPulserChanB, UInt_t inPulserChanC, UInt_t inPulserChanD, - UInt_t inPulserChanE, UInt_t inPulserChanF, UInt_t inPulserChanG, UInt_t inPulserChanH, - UInt_t inPulserChanI, UInt_t inPulserChanJ, UInt_t inPulserChanK, UInt_t inPulserChanL, - UInt_t inPulserChanM, UInt_t inPulserChanN, UInt_t inPulserChanO, UInt_t inPulserChanP ) -{ - fuPulserChan[ 0] = inPulserChanA; - fuPulserChan[ 1] = inPulserChanB; - fuPulserChan[ 2] = inPulserChanC; - fuPulserChan[ 3] = inPulserChanD; - fuPulserChan[ 4] = inPulserChanE; - fuPulserChan[ 5] = inPulserChanF; - fuPulserChan[ 6] = inPulserChanG; - fuPulserChan[ 7] = inPulserChanH; - fuPulserChan[ 8] = inPulserChanI; - fuPulserChan[ 9] = inPulserChanJ; - fuPulserChan[10] = inPulserChanK; - fuPulserChan[11] = inPulserChanL; - fuPulserChan[12] = inPulserChanM; - fuPulserChan[13] = inPulserChanN; - fuPulserChan[14] = inPulserChanO; - fuPulserChan[15] = inPulserChanP; -} -*/ -void CbmTSUnpackGet4v1x::SetHistoFilename( TString sNameIn ) -{ - fsHistoFilename = sNameIn; - - LOG(info)<<" CbmTSUnpackGet4v1x::SetHistoFilename => Histograms output file is now \n" - <<fsHistoFilename; -} -Bool_t CbmTSUnpackGet4v1x::DoUnpack(const fles::Timeslice& ts, size_t component) -{ - fulTsNb++; - if( 0 == fiMode || kTRUE == fbVerbose ) - LOG(info)<<" ++++++++++++ Ts # "<<fulTsNb; - - if( 2 == fiMode ) - LOG(debug)<<" ++++++++++++ Ts # "<<fulTsNb<<" Start!"; - - // Loop over microslices - fsMaxMsNb = ts.num_microslices(component) - fuMsOverlapTs; - for (size_t m = 0; m < fsMaxMsNb; ++m) - { - fulMsNb = m; - auto msDescriptor = ts.descriptor(component, m); - const uint8_t* msContent = reinterpret_cast<const uint8_t*>(ts.content(component, m)); - - uint32_t offset = 16; - uint32_t local_offset = 0; - const uint8_t* msContent_shifted; - int padding; - - if( 0 == fiMode || kTRUE == fbVerbose ) - LOG(info)<<" ************ Ms # "<<m; - - fuMaxOffset = msDescriptor.size; - - // AdHoc conversion factor for TS number to time - // Work only for 2 links and 1 MS per TS - fhMsSizeEvo->Fill( (fulTsNb/2)*fdMsLengthSec, fuMaxOffset); - - // Loop over the data of one microslice - while (offset < msDescriptor.size) - { - msContent_shifted = &msContent[offset]; - fuOffset = offset; - - // Extract DTM header info - DTM_header cur_DTM_header; - - cur_DTM_header.packet_length = msContent_shifted[0]; - cur_DTM_header.packet_counter = msContent_shifted[1]; - const uint16_t* ROC_ID_pointer = reinterpret_cast<const uint16_t*>(&msContent_shifted[2]); -// cur_DTM_header.ROC_ID = *ROC_ID_pointer; - // TODO: Check if planned behavior - // -> ROC ID increased by 256 per link, 16 bits => only links 1 and 2 easy to use - cur_DTM_header.ROC_ID = (*ROC_ID_pointer) / 256; // ROC ID increased by 256 per link - - uint32_t packageSize = static_cast<uint32_t>(cur_DTM_header.packet_length*2+4); - fuMaxLocalOffset = packageSize; - - // Loop over messages - local_offset = 4; - if( 0 == fiMode || kTRUE == fbVerbose ) - { - // Debug printout - cur_DTM_header.Dump(); - LOG(info)<<" Package Size: "<<packageSize<<" ROC ID: "<<cur_DTM_header.ROC_ID; - while (local_offset < packageSize) - { - fuLocalOffset = local_offset; - get4v1x::Message mess; - uint64_t dataContent = - ( static_cast<uint64_t>( cur_DTM_header.ROC_ID & 0xFFFF) << 48) - + ( static_cast<uint64_t>( (msContent_shifted[local_offset + 0] ) & 0xFF) << 40) - + ( static_cast<uint64_t>( (msContent_shifted[local_offset + 1] ) & 0xFF) << 32) - + ( static_cast<uint64_t>( (msContent_shifted[local_offset + 2] ) & 0xFF) << 24) - + ( static_cast<uint64_t>( (msContent_shifted[local_offset + 3] ) & 0xFF) << 16) - + ( static_cast<uint64_t>( (msContent_shifted[local_offset + 4] ) & 0xFF) << 8) - + ( static_cast<uint64_t>( (msContent_shifted[local_offset + 5] ) & 0xFF)); - mess.setData( dataContent ); - mess.printDataLog(); - - local_offset += 6; // next message - } // while (local_offset < packageSize) - } // if( 0 == fiMode || kTRUE == fbVerbose ) - switch(fiMode) - { - case 0: - { - // debug mode, nothing to do here (printout already done) - break; - } // case 0 -/* - case 1: - { - // Monitor mode, fill histograms - while (local_offset < packageSize) - { - fuLocalOffset = local_offset; - get4v1x::Message mess; - uint64_t dataContent = - ( static_cast<uint64_t>( cur_DTM_header.ROC_ID & 0xFFFF) << 48) - + ( static_cast<uint64_t>( (msContent_shifted[local_offset + 0] ) & 0xFF) << 40) - + ( static_cast<uint64_t>( (msContent_shifted[local_offset + 1] ) & 0xFF) << 32) - + ( static_cast<uint64_t>( (msContent_shifted[local_offset + 2] ) & 0xFF) << 24) - + ( static_cast<uint64_t>( (msContent_shifted[local_offset + 3] ) & 0xFF) << 16) - + ( static_cast<uint64_t>( (msContent_shifted[local_offset + 4] ) & 0xFF) << 8) - + ( static_cast<uint64_t>( (msContent_shifted[local_offset + 5] ) & 0xFF)); - mess.setData( dataContent ); - - fhMessageTypePerRoc->Fill( cur_DTM_header.ROC_ID, mess.getMessageType() ); - - switch( mess.getMessageType() ) - { - case get4v1x::MSG_HIT: - { - // This is NXYTER in a GET4 unpacker => ignore - break; - } // case get4v1x::MSG_HIT: - case get4v1x::MSG_EPOCH: - { - // Ignore all messages before RocFeet system SYNC - if (kFALSE == fvbRocFeetSyncStart[cur_DTM_header.ROC_ID] ) - break; - this->MonitorMessage_epoch(mess, msDescriptor.eq_id); - break; - } // case get4v1x::MSG_EPOCH: - case get4v1x::MSG_SYNC: - { - // Ignore all messages before RocFeet system SYNC - if (kFALSE == fvbRocFeetSyncStart[cur_DTM_header.ROC_ID] ) - break; - this->MonitorMessage_sync(mess, msDescriptor.eq_id); - break; - } // case get4v1x::MSG_SYNC: - case get4v1x::MSG_AUX: - { - // Ignore all messages before RocFeet system SYNC - if (kFALSE == fvbRocFeetSyncStart[cur_DTM_header.ROC_ID] ) - break; - this->MonitorMessage_aux(mess, msDescriptor.eq_id); - break; - } // case get4v1x::MSG_AUX: - case get4v1x::MSG_EPOCH2: - { - // Ignore all messages before RocFeet system SYNC - if (kFALSE == fvbRocFeetSyncStart[cur_DTM_header.ROC_ID] ) - break; - this->MonitorMessage_epoch2(mess, msDescriptor.eq_id); - break; - } // case get4v1x::MSG_EPOCH2: - case get4v1x::MSG_GET4: - { - // Ignore all messages before RocFeet system SYNC - if (kFALSE == fvbRocFeetSyncStart[cur_DTM_header.ROC_ID] ) - break; - this->MonitorMessage_get4(mess, msDescriptor.eq_id); - break; - } // case get4v1x::MSG_GET4: - case get4v1x::MSG_SYS: - this->MonitorMessage_sys(mess, msDescriptor.eq_id); - break; - default: - break; - } // switch( mess.getMessageType() ) - local_offset += 6; // next message - } // while (local_offset < packageSize) - break; - } // case 1 -*/ - case 2: - { - // Normal mode, unpack data and fill TClonesArray of CbmRawMessage - while (local_offset < packageSize) - { - fuLocalOffset = local_offset; - get4v1x::Message mess; - uint64_t dataContent = - ( static_cast<uint64_t>( cur_DTM_header.ROC_ID & 0xFFFF) << 48) - + ( static_cast<uint64_t>( (msContent_shifted[local_offset + 0] ) & 0xFF) << 40) - + ( static_cast<uint64_t>( (msContent_shifted[local_offset + 1] ) & 0xFF) << 32) - + ( static_cast<uint64_t>( (msContent_shifted[local_offset + 2] ) & 0xFF) << 24) - + ( static_cast<uint64_t>( (msContent_shifted[local_offset + 3] ) & 0xFF) << 16) - + ( static_cast<uint64_t>( (msContent_shifted[local_offset + 4] ) & 0xFF) << 8) - + ( static_cast<uint64_t>( (msContent_shifted[local_offset + 5] ) & 0xFF)); - mess.setData( dataContent ); - - fhMessageTypePerRoc->Fill( cur_DTM_header.ROC_ID, mess.getMessageType() ); - switch( mess.getMessageType() ) - { - case get4v1x::MSG_HIT: - { - // This is NXYTER in a GET4 unpacker => ignore - break; - } // case get4v1x::MSG_HIT: - case get4v1x::MSG_EPOCH: - { - // Ignore all messages before RocFeet system SYNC - if (kFALSE == fvbRocFeetSyncStart[cur_DTM_header.ROC_ID] ) - break; - - this->ProcessMessage_epoch(mess, msDescriptor.eq_id); - break; - } // case get4v1x::MSG_EPOCH: - case get4v1x::MSG_SYNC: - { - // Ignore all messages before RocFeet system SYNC - if (kFALSE == fvbRocFeetSyncStart[cur_DTM_header.ROC_ID] ) - break; - - this->ProcessMessage_sync(mess, msDescriptor.eq_id); - break; - } // case get4v1x::MSG_SYNC: - case get4v1x::MSG_AUX: - { - // Ignore all messages before RocFeet system SYNC - if (kFALSE == fvbRocFeetSyncStart[cur_DTM_header.ROC_ID] ) - break; - - this->ProcessMessage_aux(mess, msDescriptor.eq_id); - break; - } // case get4v1x::MSG_AUX: - case get4v1x::MSG_EPOCH2: - { - // Ignore all messages before RocFeet system SYNC - if (kFALSE == fvbRocFeetSyncStart[cur_DTM_header.ROC_ID] ) - break; - - this->ProcessMessage_epoch2(mess, msDescriptor.eq_id); - break; - } // case get4v1x::MSG_EPOCH2: - case get4v1x::MSG_GET4: - { - // Ignore all messages before RocFeet system SYNC - if (kFALSE == fvbRocFeetSyncStart[cur_DTM_header.ROC_ID] ) - break; - - this->ProcessMessage_get4(mess, msDescriptor.eq_id); - break; - } // case get4v1x::MSG_GET4: - case get4v1x::MSG_SYS: - this->ProcessMessage_sys(mess, msDescriptor.eq_id); - break; - default: - break; - } // switch( mess.getMessageType() ) - - local_offset += 6; // next message - } // while (local_offset < packageSize) - break; - } // case 2 - default: - break; - } // switch(fiMode) - - offset += packageSize; - - // shift some more bytes to fit the CbmNet package size - if ((padding = offset % 8) > 0) - { - offset += (8-padding); - } // if ((padding = offset % 8) > 0) - - } // while (offset < msDescriptor.size) - - } // for (size_t m = 0; m < ts.num_microslices(component); ++m) - - FinishUnpack(); - - return kTRUE; -} - -void CbmTSUnpackGet4v1x::FinishUnpack() -{ - // Something to do only in Processing mode - // TODO: Use the stored data for something usefull !!! - if( 2 == fiMode ) - { - if( kFALSE == fvbGet4WaitFirstSync[0] ) - { - LOG(debug)<<" CbmTSUnpackGet4v1x::FinishUnpack => Stored epochs: " - <<fmsOrderedEpochsData.size()<<" " - <<fmsOrderedEpochsBuffStat.size(); - UInt_t uNbClosedEpochs = 0; -// Bool_t bOneEpochPrinted = kFALSE; - auto itBuffer = fmsOrderedEpochsData.begin(); - for( auto itFlag = fmsOrderedEpochsBuffStat.begin(); itFlag!=fmsOrderedEpochsBuffStat.end(); ++itFlag ) - { - if( kTRUE == itFlag->second ) - { - uNbClosedEpochs++; - LOG(debug)<<" CbmTSUnpackGet4v1x::FinishUnpack => Epochs: "<<uNbClosedEpochs -// <<" Size: "<< (itBuffer->second).size(); // OLD - <<" Size: "<< (itBuffer->second)->size(); - - fhClosedEpSizeEvo->Fill( - (itBuffer->first)*get4v1x::kdEpochInPs*(1e-12), -// (itBuffer->second).size() ); // OLD - (itBuffer->second)->size() ); - - // Fill the closed epochs to the epoch buffer - // We transmit only epoch with data - // TODO: move this to the place where Epochs are "closed" - if( 0 < (itBuffer->second)->size() ) - fEpochBuffer->InsertEpoch( itBuffer->second ); - - // Use data for monitoring -/* - if( kTRUE == fbPulserMode ) - { - // Loop on data -// for( auto itData = (itBuffer->second).begin(); itData != (itBuffer->second).end(); ++itData) // OLD - for( auto itData = (itBuffer->second)->begin(); itData != (itBuffer->second)->end(); ++itData) - { - get4v1x::FullMessage mess = *itData; - uint8_t cRocId = mess.getRocNumber(); - uint8_t cChipId = mess.getGet4V10R32ChipId(); - uint32_t uChipFullId = cChipId + get4v1x::kuMaxGet4PerRoc*cRocId; -// uint8_t cMessType = mess.getGet4V10R32MessageType(); - UInt_t uFullChId = - get4v1x::kuChanPerGet4*( uChipFullId ) - + mess.getGet4V10R32HitChan(); - - // As long as the 1st epoch with sync flag after SYNC DLM is found, - // consider data as not good - if( kTRUE == fvbGet4WaitFirstSync[uChipFullId] ) - return; - - fhGet4ChanDataCount->Fill( uFullChId ); - fhGet4ChanDllStatus->Fill( uFullChId, mess.getGet4V10R32HitDllFlag() ); - fhGet4ChanTotMap->Fill( uFullChId, mess.getGet4V10R32HitTot() - *get4v1x::kdTotBinSize/1000.0 ); - - // Save the hit info in order to fill later the pulser histos - - // First fill time interval histos - if( fuPulserFee == (uFullChId/kuNbChanFee) ) - { - Double_t dHitsDt = mess.CalcGet4V10R32HitTimeDiff( - fvuCurrEpoch2[uChipFullId], - fvuLastHitEp[ uFullChId ], - fvmLastHit[ uFullChId ] ); - if( 0 == fvuLastHitEp[uFullChId]) - {} - else if( dHitsDt < 1e6 ) - fhPulserHitDistNs->Fill( uFullChId%kuNbChanFee, dHitsDt / 1e3 ); - else if( dHitsDt < 1e9) - fhPulserHitDistUs->Fill( uFullChId%kuNbChanFee, dHitsDt / 1e6 ); - else - fhPulserHitDistMs->Fill( uFullChId%kuNbChanFee, dHitsDt / 1e9 ); - - if( 0 < fvuLastHitEp[uFullChId] && dHitsDt < 5e3 ) - LOG(debug) <<uFullChId<<" "<<dHitsDt<<" " - <<fvuLastHitEp[ uFullChId ]<<" "<<fvuCurrEpoch2[uChipFullId]<<" " - <<fvmLastHit[ uFullChId ].getGet4V10R32HitTot()*get4v1x::kdTotBinSize/1000.0<<" " - <<mess.getGet4V10R32HitTot()*get4v1x::kdTotBinSize/1000.0;; - - - // Fill the DNL histos - fhPulserFeeDnl->Fill( uFullChId%kuNbChanFee, mess.getGet4V10R32HitFt() ); - } // if( fuPulserFee == (uFullChId/kuNbChanFee) ) - - // Epoch of Last hit message (one per GET4 chip & channel) - fvuLastHitEp[ uFullChId ] = itData->getExtendedEpoch(); - // Last hit message (one per GET4 chip & channel) - fvmLastHit[ uFullChId ] = mess; - } // for( auto itData = (itBuffer->second).begin(); itData != (itBuffer->second).begin(); ++itData) - - // Fill the time difference for all channels pairs in - // the chosen Fee - UInt_t uHistoFeeIdx = 0; - for( UInt_t uChanFeeA = 0; uChanFeeA < kuNbChanFee; uChanFeeA++) - for( UInt_t uChanFeeB = uChanFeeA + 1; uChanFeeB < kuNbChanFee; uChanFeeB++) - { - if( ( 0xF0 <= fvmLastHit[ fuPulserFee * kuNbChanFee+ uChanFeeA].getSysMesType() ) && - ( 0xF0 <= fvmLastHit[ fuPulserFee * kuNbChanFee+ uChanFeeB].getSysMesType() ) && - ( fvuLastHitEp[ fuPulserFee * kuNbChanFee+ uChanFeeA ] - < fvuLastHitEp[ fuPulserFee * kuNbChanFee+ uChanFeeB ] + 2 ) && - ( fvuLastHitEp[ fuPulserFee * kuNbChanFee+ uChanFeeA ] + 2 - > fvuLastHitEp[ fuPulserFee * kuNbChanFee+ uChanFeeB ] ) ) - { - Double_t dTimeDiff = 0.0; - dTimeDiff = fvmLastHit[ fuPulserFee * kuNbChanFee+ uChanFeeA].CalcGet4V10R32HitTimeDiff( - fvuLastHitEp[ fuPulserFee * kuNbChanFee+ uChanFeeA], - fvuLastHitEp[ fuPulserFee * kuNbChanFee+ uChanFeeB], - fvmLastHit[ fuPulserFee * kuNbChanFee+ uChanFeeB] ); - - fhTimeResFee[uHistoFeeIdx]->Fill( dTimeDiff ); - } // if both channels have matching data - uHistoFeeIdx++; - } // for any unique pair of channel in chosen Fee - - // Fill the time difference for the chosen channel pairs - UInt_t uHistoCombiIdx = 0; - for( UInt_t uChanA = 0; uChanA < kuNbChanTest-1; uChanA++) - { - if( ( 0xF0 <= fvmLastHit[ fuPulserChan[uChanA] ].getSysMesType() ) && - ( 0xF0 <= fvmLastHit[ fuPulserChan[uChanA+1] ].getSysMesType() ) && - ( fvuLastHitEp[ fuPulserChan[uChanA] ] - < fvuLastHitEp[ fuPulserChan[uChanA+1] ] + 2 ) && - ( fvuLastHitEp[ fuPulserChan[uChanA] ] + 2 - > fvuLastHitEp[ fuPulserChan[uChanA+1] ] ) ) - { - Double_t dTimeDiff = - fvmLastHit[ fuPulserChan[uChanA] ].CalcGet4V10R32HitTimeDiff( - fvuLastHitEp[ fuPulserChan[uChanA] ], - fvuLastHitEp[ fuPulserChan[uChanA+1] ], - fvmLastHit[ fuPulserChan[uChanA+1] ] ); - fhTimeResPairs[uChanA]->Fill( dTimeDiff ); - } // // if both channels have data - - for( UInt_t uChanB = uChanA+1; uChanB < kuNbChanComb; uChanB++) - { - if( ( 0xF0 <= fvmLastHit[ fuPulserChan[uChanA] ].getSysMesType() ) && - ( 0xF0 <= fvmLastHit[ fuPulserChan[uChanB] ].getSysMesType() ) && - ( fvuLastHitEp[ fuPulserChan[uChanA] ] - < fvuLastHitEp[ fuPulserChan[uChanB] ] + 2 ) && - ( fvuLastHitEp[ fuPulserChan[uChanA] ] + 2 - > fvuLastHitEp[ fuPulserChan[uChanB] ] ) ) - { - Double_t dTimeDiff = - fvmLastHit[ fuPulserChan[uChanA] ].CalcGet4V10R32HitTimeDiff( - fvuLastHitEp[ fuPulserChan[uChanA] ], - fvuLastHitEp[ fuPulserChan[uChanB] ], - fvmLastHit[ fuPulserChan[uChanB] ] ); - fhTimeResCombi[uHistoCombiIdx]->Fill( dTimeDiff ); - } // if both channels have data - uHistoCombiIdx++; - } // for( UInt_t uChanB = uChanA+1; uChanB < kuNbChanComb; uChanB++) - } // for( UInt_t uChanA = 0; uChanA < kuNbChanTest; uChanA++) - } // if( kTRUE == fbPulserMode ) -*/ - } - /* - if( kFALSE == bOneEpochPrinted && 0 < (itBuffer->second).size() ) - { - for( auto itData = (itBuffer->second).begin(); itData != (itBuffer->second).end(); ++itData) - { - LOG(debug)<<" Epoch: "<< itData->getExtendedEpoch() <<" "; - itData->printDataLog(); - } // for( auto itData = (itBuffer->second).begin(); itData != (itBuffer->second).begin(); ++itData) - bOneEpochPrinted = kTRUE; - } // if( kFALSE == bOneEpochPrinted && 0 < (itBuffer->second).size() ) - */ - ++itBuffer; - } // for( auto itFlag = fmsOrderedEpochsBuffStat.begin(); itFlag!=fmsOrderedEpochsBuffStat.end(); ++itFlag ) - LOG(debug)<<" CbmTSUnpackGet4v1x::FinishUnpack => Closed epochs: "<<uNbClosedEpochs; - } // if( kFALSE == fvbGet4WaitFirstSync[0] ) - - - auto itBuffer = fmsOrderedEpochsData.begin(); - for( auto itFlag = fmsOrderedEpochsBuffStat.begin(); itFlag!=fmsOrderedEpochsBuffStat.end(); ++itFlag ) - { - if( kTRUE == itFlag->second ) - { -// (itBuffer->second).clear(); // OLD, now done in Epoch buffer or Epoch consumer!! - fmsOrderedEpochsData.erase( itBuffer ); - fmsOrderedEpochsBuffStat.erase( itFlag ); - } // if( kTRUE == itFlag->second ) - ++itBuffer; - } // for( auto itFlag = fmsOrderedEpochsBuffStat.begin(); itFlag!=fmsOrderedEpochsBuffStat.end(); ++itFlag ) - if( 0 < fmsOrderedEpochsBuffStat.size() ) - fuLastEpBufferReady = (fmsOrderedEpochsBuffStat.begin())->first ; - else fuLastEpBufferReady = 0; - - - LOG(debug)<<" ++++++++++++ Ts # "<<fulTsNb<<" Done!"; - } // if( 2 == fiMode ) -} - -void CbmTSUnpackGet4v1x::Reset() -{ -// fGet4Raw->Clear(); -// fGet4RawSync->Clear(); -} - -void CbmTSUnpackGet4v1x::Finish() -{ - WriteMonitorHistograms(); - if( kTRUE == fbEnaCalibOutput ) - WriteCalibrationFile(); - DeleteMonitorHistograms(); -} - -/* -void CbmTSUnpackGet4v1x::Register() -{ -} -*/ -/* -void CbmTSUnpackGet4v1x::Print6bytesMessage(const uint8_t* msContent_shifted) -{ - if( kTRUE == fbVerbose ) - printf("0x%02X%02X%02X%02X%02X%02X :\t", - msContent_shifted[0], msContent_shifted[1], - msContent_shifted[2], msContent_shifted[3], - msContent_shifted[4], msContent_shifted[5]); -} -*/ - -//************** Monitor functions *************/ - - -void CbmTSUnpackGet4v1x::InitMonitorHistograms() -{ - // FIXME: maybe changed current folder to TRoot and back - // as for now all histos are placed in the analysis output file - // which leads to problems at Finish - - fhMessageTypePerRoc = new TH2I("hMessageTypePerRoc", - "Nb of message for each type per ROC; ROC #; Type", - fuNbRocs, -0.5, fuNbRocs -0.5, - 16, -0.5, 15.5); - fhMessageTypePerRoc->GetYaxis()->SetBinLabel(1 + get4v1x::MSG_NOP, "NOP"); - fhMessageTypePerRoc->GetYaxis()->SetBinLabel(1 + get4v1x::MSG_HIT, "HIT"); - fhMessageTypePerRoc->GetYaxis()->SetBinLabel(1 + get4v1x::MSG_EPOCH, "EPOCH"); - fhMessageTypePerRoc->GetYaxis()->SetBinLabel(1 + get4v1x::MSG_SYNC, "SYNC"); - fhMessageTypePerRoc->GetYaxis()->SetBinLabel(1 + get4v1x::MSG_AUX, "AUX"); - fhMessageTypePerRoc->GetYaxis()->SetBinLabel(1 + get4v1x::MSG_EPOCH2, "EPOCH2"); - fhMessageTypePerRoc->GetYaxis()->SetBinLabel(1 + get4v1x::MSG_GET4, "GET4"); - fhMessageTypePerRoc->GetYaxis()->SetBinLabel(1 + get4v1x::MSG_SYS, "SYS"); - fhMessageTypePerRoc->GetYaxis()->SetBinLabel(1 + get4v1x::MSG_GET4_SLC, "MSG_GET4_SLC"); - fhMessageTypePerRoc->GetYaxis()->SetBinLabel(1 + get4v1x::MSG_GET4_32B, "MSG_GET4_32B"); - fhMessageTypePerRoc->GetYaxis()->SetBinLabel(1 + 15, "GET4 Hack 32B"); - - fhRocSyncTypePerRoc = new TH2I("hRocSyncTypePerRoc", - "Nb of message for each SYNC type per ROC; ROC # ; SYNC Type", - fuNbRocs, -0.5, fuNbRocs -0.5, - get4v1x::kuMaxSync, -0.5, get4v1x::kuMaxSync - 0.5); - - fhRocAuxTypePerRoc = new TH2I("hRocAuxTypePerRoc", - "Nb of message for each AUX type per ROC; ROC # ; AUX Type", - fuNbRocs, -0.5, fuNbRocs -0.5, - get4v1x::kuMaxAux, -0.5, get4v1x::kuMaxAux - 0.5); - - fhSysMessTypePerRoc = new TH2I("hSysMessTypePerRoc", - "Nb of system message for each type per ROC; ROC # ; System Type", - fuNbRocs, -0.5, fuNbRocs -0.5, - 16, -0.5, 15.5); - fhSysMessTypePerRoc->GetYaxis()->SetBinLabel(1 + get4v1x::SYSMSG_DAQ_START, "DAQ START"); - fhSysMessTypePerRoc->GetYaxis()->SetBinLabel(1 + get4v1x::SYSMSG_DAQ_FINISH, "DAQ FINISH"); - fhSysMessTypePerRoc->GetYaxis()->SetBinLabel(1 + get4v1x::SYSMSG_NX_PARITY, "NX PARITY"); - fhSysMessTypePerRoc->GetYaxis()->SetBinLabel(1 + get4v1x::SYSMSG_SYNC_PARITY, "SYNC PARITY"); - fhSysMessTypePerRoc->GetYaxis()->SetBinLabel(1 + get4v1x::SYSMSG_DAQ_RESUME, "DAQ RESUME"); - fhSysMessTypePerRoc->GetYaxis()->SetBinLabel(1 + get4v1x::SYSMSG_FIFO_RESET, "FIFO RESET"); - fhSysMessTypePerRoc->GetYaxis()->SetBinLabel(1 + get4v1x::SYSMSG_USER, "USER"); - fhSysMessTypePerRoc->GetYaxis()->SetBinLabel(1 + get4v1x::SYSMSG_PCTIME, "PCTIME"); - fhSysMessTypePerRoc->GetYaxis()->SetBinLabel(1 + get4v1x::SYSMSG_ADC, "ADC"); - fhSysMessTypePerRoc->GetYaxis()->SetBinLabel(1 + get4v1x::SYSMSG_PACKETLOST, "PACKET LOST"); - fhSysMessTypePerRoc->GetYaxis()->SetBinLabel(1 + get4v1x::SYSMSG_GET4_EVENT, "GET4 ERROR"); - fhSysMessTypePerRoc->GetYaxis()->SetBinLabel(1 + get4v1x::SYSMSG_CLOSYSYNC_ERROR, "CLOSYSYNC ERROR"); - fhSysMessTypePerRoc->GetYaxis()->SetBinLabel(1 + get4v1x::SYSMSG_TS156_SYNC, "TS156 SYNC"); - fhSysMessTypePerRoc->GetYaxis()->SetBinLabel(1 + 15, "GET4 Hack 32B"); - - fhMessTypePerGet4 = new TH2I("hMessTypePerGet4", - "Nb of message for each type per GET4; GET4 chip # ; Type", - fuNbGet4, -0.5, fuNbGet4 -0.5, - 4, -0.5, 3.5); - fhMessTypePerGet4->GetYaxis()->SetBinLabel(1 + get4v1x::GET4_32B_EPOCH, "EPOCH"); - fhMessTypePerGet4->GetYaxis()->SetBinLabel(1 + get4v1x::GET4_32B_SLCM, "S.C. M"); - fhMessTypePerGet4->GetYaxis()->SetBinLabel(1 + get4v1x::GET4_32B_ERROR, "ERROR"); - fhMessTypePerGet4->GetYaxis()->SetBinLabel(1 + get4v1x::GET4_32B_DATA, "DATA"); - - fhGet4EpochFlags = new TH2I("hGet4EpochFlags", - "Number of epochs with corresponding flag set per GET4; GET4 # ;", - fuNbGet4, -0.5, fuNbGet4 -0.5, - 4, -0.5, 3.5); - fhGet4EpochFlags->GetYaxis()->SetBinLabel(1, "SYNC"); - fhGet4EpochFlags->GetYaxis()->SetBinLabel(2, "Ep. Missmatch"); - fhGet4EpochFlags->GetYaxis()->SetBinLabel(3, "Ep. Loss"); - fhGet4EpochFlags->GetYaxis()->SetBinLabel(4, "Data Loss"); - - fhGet4EpochSyncDist = new TH2I("hGet4EpochSyncDist", - "Distance between epochs with SYNC flag for each GET4; SYNC distance [epochs]; Epochs", - fuNbGet4, -0.5, fuNbGet4 -0.5, - 2*get4v1x::kuSyncCycleSzGet4, -0.5, 2*get4v1x::kuSyncCycleSzGet4 -0.5); - - fhGet4EpochJumps = new TH2I("hGet4EpochJumps", - "Distance between epochs when jump happens for each GET4; GET4 Chip # ; Epoch Jump of [Epoch]", - fuNbGet4, -0.5, fuNbGet4 -0.5, - 401, -200.5, 200.5); - - fhGet4ChanDataCount = new TH1I("hGet4ChanDataCount", - "Data Messages per GET4 channel; GET4 channel # ; Data Count", - fuNbGet4*get4v1x::kuChanPerGet4, -0.5, fuNbGet4*get4v1x::kuChanPerGet4 -0.5); - - fhGet4ChanDllStatus = new TH2I("hGet4ChanDllStatus", - "DLL flag status per GET4 channel; GET4 channel # ; DLL Flag value Count", - fuNbGet4*get4v1x::kuChanPerGet4 , -0.5, fuNbGet4*get4v1x::kuChanPerGet4 -0.5, - 2, -0.5, 1.5); - - fhGet4ChanTotMap = new TH2I("hGet4ChanTotMap", - "TOT values per GET4 channel; GET4 channel # ; TOT value [ns]", - fuNbGet4*get4v1x::kuChanPerGet4, -0.5, fuNbGet4*get4v1x::kuChanPerGet4 -0.5, - 50, 0.0, 50.0); - - fhGet4ChanErrors = new TH2I("hGet4ChanErrors", - "Error messages per GET4 channel; GET4 channel # ; Error", - fuNbGet4*get4v1x::kuChanPerGet4*2, -0.5, fuNbGet4*get4v1x::kuChanPerGet4 -0.5, - 32, -0.5, 31.5); - fhGet4ChanErrors->GetYaxis()->SetBinLabel(1, "0x00: Readout Init "); - fhGet4ChanErrors->GetYaxis()->SetBinLabel(2, "0x01: Sync "); - fhGet4ChanErrors->GetYaxis()->SetBinLabel(3, "0x02: Epoch count sync"); - fhGet4ChanErrors->GetYaxis()->SetBinLabel(4, "0x03: Epoch "); - fhGet4ChanErrors->GetYaxis()->SetBinLabel(5, "0x04: FIFO Write "); - fhGet4ChanErrors->GetYaxis()->SetBinLabel(6, "0x05: Lost event "); - fhGet4ChanErrors->GetYaxis()->SetBinLabel(7, "0x06: Channel state "); - fhGet4ChanErrors->GetYaxis()->SetBinLabel(8, "0x07: Token Ring state"); - fhGet4ChanErrors->GetYaxis()->SetBinLabel(9, "0x08: Token "); - fhGet4ChanErrors->GetYaxis()->SetBinLabel(10, "0x09: Error Readout "); - fhGet4ChanErrors->GetYaxis()->SetBinLabel(11, "0x0a: SPI "); - fhGet4ChanErrors->GetYaxis()->SetBinLabel(12, "0x0b: DLL Lock error "); // <- From GET4 v1.2 - fhGet4ChanErrors->GetYaxis()->SetBinLabel(13, "0x0c: DLL Reset invoc."); // <- From GET4 v1.2 - fhGet4ChanErrors->GetYaxis()->SetBinLabel(14, "0x11: Overwrite "); - fhGet4ChanErrors->GetYaxis()->SetBinLabel(15, "0x12: ToT out of range"); - fhGet4ChanErrors->GetYaxis()->SetBinLabel(16, "0x13: Event Discarded "); - fhGet4ChanErrors->GetYaxis()->SetBinLabel(17, "0x7f: Unknown "); - fhGet4ChanErrors->GetYaxis()->SetBinLabel(18, "Corrupt error or unsupported yet"); - - fhGet4ChanSlowContM = new TH2I("hGet4ChanSlowContM", - "Slow control messages per GET4 channel; GET4 channel # ; Type", - fuNbGet4*get4v1x::kuChanPerGet4*2, -0.5, fuNbGet4*get4v1x::kuChanPerGet4 -0.5, - 4, -0.5, 3.5); - fhGet4ChanSlowContM->GetYaxis()->SetBinLabel(1, "0: Scaler event "); - fhGet4ChanSlowContM->GetYaxis()->SetBinLabel(2, "1: Dead time counter event "); - fhGet4ChanSlowContM->GetYaxis()->SetBinLabel(3, "2: SPI receiver data "); - fhGet4ChanSlowContM->GetYaxis()->SetBinLabel(4, "3: Start message/Hamming Er."); - - // Time evolution histos - Int_t iNbBinsEvo = fdEvoLengthSec / fdEvoBinSizeS; - // FLIB - fhMsSizeEvo = new TProfile( "hMsSizeEvo", - "Evolution of the size of Microslices; Time [s] ; Mean size [Bytes]", - iNbBinsEvo, -0.5, fdEvoLengthSec - 0.5 ); - // ROC - fvhRocDataCntEvo.resize(fuNbRocs); - fvhRocEpochCntEvo.resize(fuNbRocs); - fvhRocErrorCntEvo.resize(fuNbRocs); - fvhRocDataLossCntEvo.resize(fuNbRocs); - fvhRocEpochLossCntEvo.resize(fuNbRocs); - for( UInt_t uRoc = 0; uRoc < fuNbRocs; uRoc++) - { - fvhRocDataCntEvo[uRoc] = new TH1I( - Form("hRocDataCntEvo_%03u", uRoc), - Form("Evolution of data rate for ROC #%03d; Time [s] ; Data rate [1/s]", uRoc), - iNbBinsEvo, -0.5, fdEvoLengthSec - 0.5 ); - fvhRocEpochCntEvo[uRoc] = new TH1I( - Form("hRocEpochCntEvo_%03u", uRoc), - Form("Evolution of epoch rate for ROC #%03d; Time [s] ; Epoch rate [1/s]", uRoc), - iNbBinsEvo, -0.5, fdEvoLengthSec - 0.5 ); - fvhRocErrorCntEvo[uRoc] = new TH1I( - Form("hRocErrorCntEvo_%03u", uRoc), - Form("Evolution of error rate for ROC #%03d; Time [s] ; Error rate [1/s]", uRoc), - iNbBinsEvo, -0.5, fdEvoLengthSec - 0.5 ); - fvhRocDataLossCntEvo[uRoc] = new TH1I( - Form("hRocDataLossCntEvo_%03u", uRoc), - Form("Evolution of data loss rate for ROC #%03d; Time [s] ; Data loss rate [1/s]", uRoc), - iNbBinsEvo, -0.5, fdEvoLengthSec - 0.5 ); - fvhRocEpochLossCntEvo[uRoc] = new TH1I( - Form("hRocEpochLossCntEvo_%03u", uRoc), - Form("Evolution of epoch loss rate for ROC #%03d; Time [s] ; Epoch loss rate [1/s]", uRoc), - iNbBinsEvo, -0.5, fdEvoLengthSec - 0.5 ); - } // for( Int_t uRoc = 0; uRoc < fuNbRocs; uRoc++) - // GET4 - fvhGet4DataCntEvo.resize(fuNbGet4); - fvhGet4ErrorCntEvo.resize(fuNbGet4); - fvhGet4DataLossCntEvo.resize(fuNbGet4); - fvhGet4EpochLossCntEvo.resize(fuNbGet4); - fvhGet4ChDataCntEvo.resize(fuNbGet4); - fvhGet4ChErrorCntEvo.resize(fuNbGet4); - fvhFineTime.resize(fuNbGet4); - for( UInt_t uGet4 = 0; uGet4 < fuNbGet4; uGet4++) - { - if( kTRUE == fvbActiveChips[uGet4] ) - { - fvhGet4DataCntEvo[uGet4] = new TH1I( - Form("hGet4DataCntEvo_%03u", uGet4), - Form("Evolution of data rate for GET4 #%03d; Time [s] ; Data rate [1/s]", uGet4), - iNbBinsEvo, -0.5, fdEvoLengthSec - 0.5 ); - fvhGet4ErrorCntEvo[uGet4] = new TH1I( - Form("hGet4ErrorCntEvo_%03u", uGet4), - Form("Evolution of error rate for GET4 #%03d; Time [s] ; Error rate [1/s]", uGet4), - iNbBinsEvo, -0.5, fdEvoLengthSec - 0.5 ); - fvhGet4DataLossCntEvo[uGet4] = new TH1I( - Form("hGet4DataLossCntEvo_%03u", uGet4), - Form("Evolution of data loss rate for GET4 #%03d; Time [s] ; Data loss rate [1/s]", uGet4), - iNbBinsEvo, -0.5, fdEvoLengthSec - 0.5 ); - fvhGet4EpochLossCntEvo[uGet4] = new TH1I( - Form("hGet4EpochLossCntEvo_%03u", uGet4), - Form("Evolution of epoch loss rate for GET4 #%03d; Time [s] ; Error loss rate [1/s]", uGet4), - iNbBinsEvo, -0.5, fdEvoLengthSec - 0.5 ); - fvhGet4ChDataCntEvo[uGet4] = new TH2I( - Form("hGet4ChDataCntEvo_%03u", uGet4), - Form("Evolution of data rate for GET4 #%03d; Channel ; Time [s] ; Data rate [1/s]", uGet4), - get4v1x::kuChanPerGet4, -0.5, get4v1x::kuChanPerGet4 -0.5, - iNbBinsEvo, -0.5, fdEvoLengthSec - 0.5 ); - fvhGet4ChErrorCntEvo[uGet4] = new TH2I( - Form("hGet4ChErrorCntEvo_%03u", uGet4), - Form("Evolution of error rate for GET4 #%03d; Channel ; Time [s] ; Error rate [1/s]", uGet4), - get4v1x::kuChanPerGet4, -0.5, get4v1x::kuChanPerGet4 -0.5, - iNbBinsEvo, -0.5, fdEvoLengthSec - 0.5 ); - } // if( kTRUE == fvbActiveChips[uGet4] ) - - // Calibration TDC indexing not compatible with making only for active TDC - if( kTRUE == fbEnaCalibOutput ) - { - fvhFineTime[ uGet4 ].resize(get4v1x::kuChanPerGet4); - for( UInt_t uChan = 0; uChan < get4v1x::kuChanPerGet4; uChan++ ) - { - TString sCalibHistoOutputName = Form("tof_get4_ft_b%03u_ch%03u", - uGet4, uChan ); - fvhFineTime[ uGet4 ][ uChan ] = new TH1I( - sCalibHistoOutputName, - Form("Fine Time distribution for channel %03d in GET4 #%03d; FineTime [bin] ; Counts [1]", - uChan, uGet4), - get4v1x::kuFineCounterSize, -0.5, get4v1x::kuFineCounterSize - 0.5 ); - } // for( UInt_t uChan = 0; uChan < get4v1x::kuChanPerGet4; uChan++ ) - } // if( kTRUE == fbEnaCalibOutput ) - } // for( Int_t uGet4 = 0; uGet4 < fuNbGet4; uGet4++) - // DETECTORS - fvhDetDataCntEvo.resize(kiNbDet); - fvhDetErrorCntEvo.resize(kiNbDet); - fvhDetDataLossCntEvo.resize(kiNbDet); - fvhDetEpochLossCntEvo.resize(kiNbDet); - for( Int_t iDet = 0; iDet < kiNbDet; iDet++) - { - fvhDetDataCntEvo[iDet] = new TH1I( - Form("hDetDataCntEvo_%s", ksDetName[iDet].Data()), - Form("Evolution of data rate for %s; Time [s] ; Data rate [1/s]", - ksDetName[iDet].Data()), - iNbBinsEvo, -0.5, fdEvoLengthSec - 0.5 ); - fvhDetErrorCntEvo[iDet] = new TH1I( - Form("hDetErrorCntEvo_%s", ksDetName[iDet].Data()), - Form("Evolution of error rate for %s; Time [s] ; Error rate [1/s]", - ksDetName[iDet].Data()), - iNbBinsEvo, -0.5, fdEvoLengthSec - 0.5 ); - fvhDetDataLossCntEvo[iDet] = new TH1I( - Form("hDetDataLossCntEvo_%s", ksDetName[iDet].Data()), - Form("Evolution of data loss rate for %s; Time [s] ; Data loss rate [1/s]", - ksDetName[iDet].Data()), - iNbBinsEvo, -0.5, fdEvoLengthSec - 0.5 ); - fvhDetEpochLossCntEvo[iDet] = new TH1I( - Form("hDetEpochLossCntEvo_%s", ksDetName[iDet].Data()), - Form("Evolution of epoch loss rate for %s; Time [s] ; Error loss rate [1/s]", - ksDetName[iDet].Data()), - iNbBinsEvo, -0.5, fdEvoLengthSec - 0.5 ); - } // for( Int_t iDet = 0; iDet < kiNbDet; iDet++) - - fhClosedEpSizeEvo = new TProfile( "hClosedEpSizeEvo", - "Evolution of the size of closed epochs; Time [s] ; Mean size rate [Messages]", - iNbBinsEvo, -0.5, fdEvoLengthSec - 0.5 ); - -/* - if( kTRUE == fbPulserMode ) - { - // Full Fee test - UInt_t uHistoFeeIdx = 0; - UInt_t uNbBinsDt = 500; - Double_t dMinDt = -1.*(uNbBinsDt*get4v1x::kdBinSize/2.) -get4v1x::kdBinSize/2.; - Double_t dMaxDt = 1.*(uNbBinsDt*get4v1x::kdBinSize/2.) +get4v1x::kdBinSize/2.; - uNbBinsDt ++; // To account for extra bin due to shift by 1/2 bin of both ranges - for( UInt_t uChanFeeA = 0; uChanFeeA < kuNbChanFee; uChanFeeA++) - for( UInt_t uChanFeeB = uChanFeeA + 1; uChanFeeB < kuNbChanFee; uChanFeeB++) - { - fhTimeResFee[uHistoFeeIdx] = new TH1I( - Form("hTimeResFee_%03u_%03u", uChanFeeA, uChanFeeB), - Form("Time difference for channels %03u an %03u in chosen Fee; DeltaT [ps]; Counts", - uChanFeeA, uChanFeeB), - uNbBinsDt, dMinDt, dMaxDt); - uHistoFeeIdx++; - } // for any unique pair of channel in chosen Fee - fhTimeRmsAllFee = new TH2D( "hTimeRmsAllFee", - "Time difference RMS for any channels pair in chosen Fee; Ch A; Ch B", - kuNbChanFee - 1, -0.5, kuNbChanFee - 1.5, - kuNbChanFee - 1, 0.5, kuNbChanFee - 0.5); - fhTimeResAllFee = new TH2D( "hTimeResAllFee", - "Time resolution for any channels pair in chosen Fee; Ch A; Ch B", - kuNbChanFee - 1, -0.5, kuNbChanFee - 1.5, - kuNbChanFee - 1, 0.5, kuNbChanFee - 0.5); - - // Chosen channels test - UInt_t uHistoCombiIdx = 0; - for( UInt_t uChanA = 0; uChanA < kuNbChanTest-1; uChanA++) - { - fhTimeResPairs[uChanA] = new TH1I( - Form("hTimeResPairs_%03u_%03u", fuPulserChan[uChanA], fuPulserChan[uChanA+1]), - Form("Time difference for selected channels %03u an %03u; DeltaT [ps]; Counts", - fuPulserChan[uChanA], fuPulserChan[uChanA+1]), - uNbBinsDt, dMinDt, dMaxDt); - for( UInt_t uChanB = uChanA+1; uChanB < kuNbChanComb; uChanB++) - { - fhTimeResCombi[uHistoCombiIdx] = new TH1I( - Form("hTimeResCombi_%03u_%03u", fuPulserChan[uChanA], fuPulserChan[uChanB]), - Form("Time difference for selected channels %03u an %03u; DeltaT [ps]; Counts", - fuPulserChan[uChanA], fuPulserChan[uChanB]), - uNbBinsDt, dMinDt, dMaxDt); - uHistoCombiIdx++; - } // for( UInt_t uChanB = uChanA+1; uChanB < kuNbChanComb; uChanB++) - } // for( UInt_t uChanA = 0; uChanA < kuNbChanTest; uChanA++) - - fhPulserHitDistNs = new TH2D( "hPulserHitDistNs", - "Time Interval between hits for all channels in chosen Fee; Chan # ; Hits interval [ns]", - kuNbChanFee, -0.5, kuNbChanFee - 0.5, - 1000 , 0., 1000.0); - fhPulserHitDistUs = new TH2D( "hPulserHitDistUs", - "Time Interval between hits for all channels in chosen Fee; Chan # ; Hits interval [us]", - kuNbChanFee, -0.5, kuNbChanFee - 0.5, - 1000 , 0., 1000.0); - fhPulserHitDistMs = new TH2D( "hPulserHitDistMs", - "Time Interval between hits for all channels in chosen Fee; Chan # ; Hits interval [ms]", - kuNbChanFee, -0.5, kuNbChanFee - 0.5, - 1000 , 0., 1000.0); - - fhPulserFeeDnl = new TH2D( "hPulserFeeDnl", - "DNL for all channels in chosen FEE board; Chan # ; FT Bin; DNL [bin]", - kuNbChanFee, -0.5, kuNbChanFee - 0.5, - get4v1x::kuFineTime+1 , -0.5, get4v1x::kuFineTime + 0.5); - - fhPulserFeeInl = new TH2D( "hPulserFeeInl", - "INL for all channels in chosen FEE board; Chan # ; FT Bin; INL [bin]", - kuNbChanFee, -0.5, kuNbChanFee - 0.5, - get4v1x::kuFineTime+1 , -0.5, get4v1x::kuFineTime + 0.5); - } // if( kTRUE == fbPulserMode ) - - if( kTRUE == fbOldReadoutOk ) - { - fhGet4ChanTotCount = new TH1I("hGet4ChanTotCount", - "Data Messages per GET4 TOT channel; GET4 channel # ; Data Count", - fuNbGet4*get4v1x::kuChanPerGet4, -0.5, fuNbGet4*get4v1x::kuChanPerGet4 -0.5); - - fhPulserFeeTotDnl = new TH2D( "fhPulserFeeTotDnl", - "DNL for all TOT channels in chosen FEE board; Chan # ; FT Bin; DNL [bin]", - kuNbChanFee, -0.5, kuNbChanFee - 0.5, - get4v1x::kuFineTime+1 , -0.5, get4v1x::kuFineTime + 0.5); - - fhPulserFeeTotInl = new TH2D( "hPulserFeeTotInl", - "INL for all TOT channels in chosen FEE board; Chan # ; FT Bin; INL [bin]", - kuNbChanFee, -0.5, kuNbChanFee - 0.5, - get4v1x::kuFineTime+1 , -0.5, get4v1x::kuFineTime + 0.5); - } // if( kTRUE == fbOldReadoutOk ) -*/ - // Prepare the vector storing the hit data for time diff calculation - fvuLastHitEp.resize( fuNbGet4 * get4v1x::kuChanPerGet4); - fvmLastHit.resize( fuNbGet4 * get4v1x::kuChanPerGet4); -// if( kTRUE == fbOldReadoutOk ) - { - fvuLastOldTotEp.resize( fuNbGet4 * get4v1x::kuChanPerGet4); - fvmLastOldTot.resize( fuNbGet4 * get4v1x::kuChanPerGet4); - } // if( kTRUE == fbOldReadoutOk ) - - // Now clear the hits - for( UInt_t uChan = 0; uChan < fuNbGet4 * get4v1x::kuChanPerGet4; uChan++) - { - fvuLastHitEp[uChan] = 0; - fvmLastHit[uChan].reset(); -// if( kTRUE == fbOldReadoutOk ) - { - fvuLastOldTotEp[uChan] = 0; - fvmLastOldTot[uChan].reset(); - } // if( kTRUE == fbOldReadoutOk ) - } // for( UInt_t uChan = 0; uChan < fuNbGet4 * get4v1x::kuChanPerGet4; uChan++) - - fuNbFee = fuNbGet4 / get4v1x::kuGet4PerFee; - LOG(info) << "Nb FEE boards: " <<fuNbFee; - fvvhChannelsCoinc.resize(fuNbFee); - for( UInt_t uFeeA = 0; uFeeA < fuNbFee; uFeeA++) - { - LOG(info) << uFeeA << " / " <<fvvhChannelsCoinc.size(); -// fvvhChannelsCoinc[uFeeA].resize( fuNbFee - uFeeA); // Pb: index start at 0 of course! - fvvhChannelsCoinc[uFeeA].resize( fuNbFee ); // TODO: stupid but faster to code, find better way - for( UInt_t uFeeB = uFeeA; uFeeB < fuNbFee; uFeeB++) - { - LOG(info) << uFeeA << " / " <<fvvhChannelsCoinc.size() << " " - << uFeeB << " / " <<fvvhChannelsCoinc[uFeeA].size(); - fvvhChannelsCoinc[uFeeA][uFeeB] = - new TH2D( Form("hChannelsCoinc_%03u_%03u", uFeeA, uFeeB), - Form("Coincidence between FEE %3u and %3u; Ch FEE %3u ; Ch FEE %3u;", - uFeeA, uFeeB, uFeeA, uFeeB), - get4v1x::kuChanPerFee, -0.5, get4v1x::kuChanPerFee - 0.5, - get4v1x::kuChanPerFee, -0.5, get4v1x::kuChanPerFee - 0.5); - } - } // for( UInt_t uFee = 0; uFee < fuNbFee; uFee++) -/* - // Multiple hits (reflections, ...) detection - if( 1 == fiMode ) - { - fvhGet4MultipleHits.resize(fuNbGet4); - fvhGet4DistDoubleHits.resize(fuNbGet4); - fvhGet4DistTripleHits.resize(fuNbGet4); - fvhGet4DistMultipleHits.resize(fuNbGet4); - fvhGet4MultipleHitsVsTot.resize(fuNbGet4); - fvbChanSecondHit.resize(fuNbGet4); - fvbChanThirdHit.resize(fuNbGet4); - fvdChanFirstHitTot.resize(fuNbGet4); - for( UInt_t uGet4 = 0; uGet4 < fuNbGet4; uGet4++) - { - if( kTRUE == fvbActiveChips[uGet4] ) - { - fvhGet4MultipleHits[uGet4] = new TH2I( - Form("hGet4MultipleHits_%03u", uGet4), - Form("Multiple hits for GET4 #%03d; Channel ; Close hit # [1]; Counts[1]", uGet4), - get4v1x::kuChanPerGet4, -0.5, get4v1x::kuChanPerGet4 -0.5, - 4, 0.5, 4.5 ); - fvhGet4DistDoubleHits[uGet4] = new TH2I( - Form("hGet4DistDoubleHits_%03u", uGet4), - Form("Time dist between 1st and 2nd hit for GET4 #%03d; Channel ; Time dist [ps]; Counts[1]", uGet4), - get4v1x::kuChanPerGet4, -0.5, get4v1x::kuChanPerGet4 -0.5, - static_cast<Int_t>(fdMaxDtMultiHit/100.0), 0.0, fdMaxDtMultiHit ); - fvhGet4DistTripleHits[uGet4] = new TH2I( - Form("hGet4DistTripleHits_%03u", uGet4), - Form("Time dist between 2nd and 3rd hit for GET4 #%03d; Channel ; Time dist [ps]; Counts[1]", uGet4), - get4v1x::kuChanPerGet4, -0.5, get4v1x::kuChanPerGet4 -0.5, - static_cast<Int_t>(fdMaxDtMultiHit/100.0), 0.0, fdMaxDtMultiHit ); - fvhGet4DistMultipleHits[uGet4] = new TH2I( - Form("hGet4DistMultipleHits_%03u", uGet4), - Form("Time dist between hits after 3rd one for GET4 #%03d; Channel ; Time dist [ps]; Counts[1]", uGet4), - get4v1x::kuChanPerGet4, -0.5, get4v1x::kuChanPerGet4 -0.5, - static_cast<Int_t>(fdMaxDtMultiHit/100.0), 0.0, fdMaxDtMultiHit ); - fvbChanSecondHit[uGet4].resize(get4v1x::kuChanPerGet4, kFALSE); - fvbChanThirdHit[uGet4].resize(get4v1x::kuChanPerGet4, kFALSE); - - fvhGet4MultipleHitsVsTot[uGet4] = new TH2I( - Form("hGet4MultipleHitsVsTot_%03u", uGet4), - Form("Multiple hits for GET4 #%03d; TOT [ns] ; Close hit # [1]; Counts[1]", uGet4), - 10, 0.0, 10.0, - 4, 0.5, 4.5 ); - fvdChanFirstHitTot[uGet4].resize(get4v1x::kuChanPerGet4, 0.0); - } // if( kTRUE == fvbActiveChips[uGet4] ) - } // for( UInt_t uGet4 = 0; uGet4 < fuNbGet4; uGet4++) - } // if( 1 == fiMode ) -*/ -} -void CbmTSUnpackGet4v1x::FillMonitorHistograms() -{ -} -void CbmTSUnpackGet4v1x::WriteMonitorHistograms() -{ - TDirectory * oldir = gDirectory; - TFile *fHist; - fHist = new TFile( fsHistoFilename,"RECREATE"); - - fHist->cd(); - - fhMessageTypePerRoc->Write(); - fhRocSyncTypePerRoc->Write(); - fhRocAuxTypePerRoc ->Write(); - fhSysMessTypePerRoc->Write(); - fhMessTypePerGet4 ->Write(); - fhGet4EpochFlags ->Write(); - fhGet4EpochSyncDist->Write(); - fhGet4EpochJumps ->Write(); - fhGet4ChanDataCount->Write(); - fhGet4ChanDllStatus->Write(); - fhGet4ChanTotMap ->Write(); - fhGet4ChanErrors ->Write(); - fhGet4ChanSlowContM->Write(); - - fhMsSizeEvo->Write(); - for( UInt_t uRoc = 0; uRoc < fuNbRocs; uRoc++) - { - // FIXME: problem with scale function: on at least 1 computer it acts as if the - // "width" option was given!!!!!!!! - fvhRocDataCntEvo[uRoc] ->Scale( 1/fdEvoBinSizeS ); // Weight factor to account for bin size in s - fvhRocEpochCntEvo[uRoc] ->Scale( 1/fdEvoBinSizeS ); // Weight factor to account for bin size in s - fvhRocErrorCntEvo[uRoc] ->Scale( 1/fdEvoBinSizeS ); // Weight factor to account for bin size in s - fvhRocDataLossCntEvo[uRoc] ->Scale( 1/fdEvoBinSizeS ); // Weight factor to account for bin size in s - fvhRocEpochLossCntEvo[uRoc]->Scale( 1/fdEvoBinSizeS ); // Weight factor to account for bin size in s - fvhRocDataCntEvo[uRoc] ->Write(); - fvhRocEpochCntEvo[uRoc] ->Write(); - fvhRocErrorCntEvo[uRoc] ->Write(); - fvhRocDataLossCntEvo[uRoc] ->Write(); - fvhRocEpochLossCntEvo[uRoc]->Write(); - } // for( Int_t uRoc = 0; uRoc < fuNbRocs; uRoc++) - // GET4 - for( UInt_t uGet4 = 0; uGet4 < fuNbGet4; uGet4++) - if( kTRUE == fvbActiveChips[uGet4] ) - { - fvhGet4DataCntEvo[uGet4] ->Scale( 1/fdEvoBinSizeS ); // Weight factor to account for bin size in s - fvhGet4ErrorCntEvo[uGet4] ->Scale( 1/fdEvoBinSizeS ); // Weight factor to account for bin size in s - fvhGet4DataLossCntEvo[uGet4] ->Scale( 1/fdEvoBinSizeS ); // Weight factor to account for bin size in s - fvhGet4EpochLossCntEvo[uGet4]->Scale( 1/fdEvoBinSizeS ); // Weight factor to account for bin size in s - fvhGet4ChDataCntEvo[uGet4] ->Scale( 1/fdEvoBinSizeS ); // Weight factor to account for bin size in s - fvhGet4ChErrorCntEvo[uGet4] ->Scale( 1/fdEvoBinSizeS ); // Weight factor to account for bin size in s - fvhGet4DataCntEvo[uGet4] ->Write(); - fvhGet4ErrorCntEvo[uGet4] ->Write(); - fvhGet4DataLossCntEvo[uGet4] ->Write(); - fvhGet4EpochLossCntEvo[uGet4]->Write(); - fvhGet4ChDataCntEvo[uGet4] ->Write(); - fvhGet4ChErrorCntEvo[uGet4] ->Write(); - } // for( Int_t uGet4 = 0; uGet4 < fuNbGet4; uGet4++) - // DETECTORS - for( Int_t iDet = 0; iDet < kiNbDet; iDet++) - { - fvhDetDataCntEvo[iDet] ->Scale( 1/fdEvoBinSizeS ); // Weight factor to account for bin size in s - fvhDetErrorCntEvo[iDet] ->Scale( 1/fdEvoBinSizeS ); // Weight factor to account for bin size in s - fvhDetDataLossCntEvo[iDet] ->Scale( 1/fdEvoBinSizeS ); // Weight factor to account for bin size in s - fvhDetEpochLossCntEvo[iDet]->Scale( 1/fdEvoBinSizeS ); // Weight factor to account for bin size in s - fvhDetDataCntEvo[iDet] ->Write(); - fvhDetErrorCntEvo[iDet] ->Write(); - fvhDetDataLossCntEvo[iDet] ->Write(); - fvhDetEpochLossCntEvo[iDet]->Write(); - } // for( Int_t iDet = 0; iDet < kiNbDet; iDet++) - fhClosedEpSizeEvo->Write(); -/* - if( kTRUE == fbPulserMode ) - { - // First make a gauss fit to obtain the time resolution data - // for all Fee channels pairs - UInt_t uHistoFeeIdx = 0; - TF1 *fitFunc[kuNbChanFee*(kuNbChanFee-1)/2]; - for( UInt_t uChanFeeA = 0; uChanFeeA < kuNbChanFee; uChanFeeA++) - for( UInt_t uChanFeeB = uChanFeeA + 1; uChanFeeB < kuNbChanFee; uChanFeeB++) - { - Double_t dRes = 0.0; - - // No need to fit if not data in histo - if( 0 == fhTimeResFee[uHistoFeeIdx]->Integral() ) - { - - LOG(info)<<" FMC histo empty: "<<uHistoFeeIdx<<" " - <<uChanFeeA<<" "<<uChanFeeB; - uHistoFeeIdx++; - continue; - } // if( 0 == fhTimeResFee[uHistoFeeIdx]->Integral() ) - - fitFunc[uHistoFeeIdx] = new TF1( Form("f_%03d_%03d",uChanFeeA,uChanFeeB), "gaus", - fhTimeResFee[uHistoFeeIdx]->GetMean() - 5*fhTimeResFee[uHistoFeeIdx]->GetRMS() , - fhTimeResFee[uHistoFeeIdx]->GetMean() + 5*fhTimeResFee[uHistoFeeIdx]->GetRMS()); - - fhTimeResFee[uHistoFeeIdx]->Fit( Form("f_%03d_%03d",uChanFeeA,uChanFeeB), "IQRM0"); - - dRes = fitFunc[uHistoFeeIdx]->GetParameter(2); - - // If needed uncomment for debugging - //(WARNING: this adds 1024 histos to the file!) - fhTimeResFee[uHistoFeeIdx]->Write(); - - delete fitFunc[uHistoFeeIdx]; - - fhTimeRmsAllFee->Fill(uChanFeeA, uChanFeeB, fhTimeResFee[uHistoFeeIdx]->GetRMS() ); - fhTimeResAllFee->Fill(uChanFeeA, uChanFeeB, dRes/TMath::Sqrt2() ); -// fhTimeResAllFee->Fill(uChanFeeA, uChanFeeB, dRes/TMath::Sqrt2() ); - - uHistoFeeIdx++; - } // for any unique pair of channel in chosen Fee - - // Then write the Fee summary histo - fhTimeRmsAllFee->Write(); - fhTimeResAllFee->Write(); - - // Write the histos for the test on chosen channel pairs - UInt_t uHistoCombiIdx = 0; - for( UInt_t uChanA = 0; uChanA < kuNbChanTest-1; uChanA++) - { - fhTimeResPairs[uChanA]->Write(); - for( UInt_t uChanB = uChanA+1; uChanB < kuNbChanComb; uChanB++) - { - fhTimeResCombi[uHistoCombiIdx]->Write(); - uHistoCombiIdx++; - } // for( UInt_t uChanB = uChanA+1; uChanB < kuNbChanComb; uChanB++) - } // for( UInt_t uChanA = 0; uChanA < kuNbChanTest; uChanA++) - - // Write the hists interval histos - fhPulserHitDistNs->Write(); - fhPulserHitDistUs->Write(); - fhPulserHitDistMs->Write(); - - // Compute the DNL from the bins occupancy - for( UInt_t uChanFeeA = 0; uChanFeeA < kuNbChanFee; uChanFeeA++) - { - Double_t dNbCountsTotal = fhPulserFeeDnl->Integral( uChanFeeA+1, uChanFeeA+1, 1, get4v1x::kuFineTime+1); - Double_t dNbCountsBinMean = dNbCountsTotal/(get4v1x::kuFineTime+1); - for( UInt_t uBin = 1; uBin <= get4v1x::kuFineTime+1; uBin ++) - fhPulserFeeDnl->SetBinContent( uChanFeeA+1, uBin, - fhPulserFeeDnl->GetBinContent(uChanFeeA+1, uBin)/dNbCountsBinMean ); - } // for( UInt_t uChanFeeA = 0; uChanFeeA < kuNbChanFee; uChanFeeA++) - fhPulserFeeDnl->Write(); - // COmpute the INL from the DNL - for( UInt_t uChanFeeA = 0; uChanFeeA < kuNbChanFee; uChanFeeA++) - { - Double_t dInl = 0.0; - for( UInt_t uBin = 1; uBin <= get4v1x::kuFineTime+1; uBin ++) - { - dInl += 0.5 * fhPulserFeeDnl->GetBinContent(uChanFeeA+1, uBin); - fhPulserFeeInl->SetBinContent( uChanFeeA+1, uBin, dInl - (uBin-0.5) ); - dInl += 0.5 * fhPulserFeeDnl->GetBinContent(uChanFeeA+1, uBin); - } // for( UInt_t uBin = 1; uBin <= get4v1x::kuFineTime+1; uBin ++) - } // for( UInt_t uChanFeeA = 0; uChanFeeA < kuNbChanFee; uChanFeeA++) - fhPulserFeeInl->Write(); - - - if( kTRUE == fbOldReadoutOk ) - { - fhGet4ChanTotCount->Write(); - - // Compute the DNL from the bins occupancy - for( UInt_t uChanFeeA = 0; uChanFeeA < kuNbChanFee; uChanFeeA++) - { - Double_t dNbCountsTotal = fhPulserFeeTotDnl->Integral( uChanFeeA+1, uChanFeeA+1, 1, get4v1x::kuFineTime+1); - Double_t dNbCountsBinMean = dNbCountsTotal/(get4v1x::kuFineTime+1); - for( UInt_t uBin = 1; uBin <= get4v1x::kuFineTime+1; uBin ++) - fhPulserFeeTotDnl->SetBinContent( uChanFeeA+1, uBin, - fhPulserFeeTotDnl->GetBinContent(uChanFeeA+1, uBin)/dNbCountsBinMean ); - } // for( UInt_t uChanFeeA = 0; uChanFeeA < kuNbChanFee; uChanFeeA++) - fhPulserFeeTotDnl->Write(); - // COmpute the INL from the DNL - for( UInt_t uChanFeeA = 0; uChanFeeA < kuNbChanFee; uChanFeeA++) - { - Double_t dInl = 0.0; - for( UInt_t uBin = 1; uBin <= get4v1x::kuFineTime+1; uBin ++) - { - dInl += 0.5 * fhPulserFeeTotDnl->GetBinContent(uChanFeeA+1, uBin); - fhPulserFeeTotInl->SetBinContent( uChanFeeA+1, uBin, dInl - (uBin-0.5) ); - dInl += 0.5 * fhPulserFeeTotDnl->GetBinContent(uChanFeeA+1, uBin); - } // for( UInt_t uBin = 1; uBin <= get4v1x::kuFineTime+1; uBin ++) - } // for( UInt_t uChanFeeA = 0; uChanFeeA < kuNbChanFee; uChanFeeA++) - fhPulserFeeTotInl->Write(); - } // if( kTRUE == fbOldReadoutOk ) - } // if( kTRUE == fbPulserMode ) -*/ - for( UInt_t uFeeA = 0; uFeeA < fuNbFee; uFeeA++) - for( UInt_t uFeeB = uFeeA; uFeeB < fuNbFee; uFeeB++) - fvvhChannelsCoinc[uFeeA][uFeeB]->Write(); -/* - // Multiple hits (reflections, ...) detection - if( 1 == fiMode ) - { - for( UInt_t uGet4 = 0; uGet4 < fuNbGet4; uGet4++) - { - if( kTRUE == fvbActiveChips[uGet4] ) - { - fvhGet4MultipleHits[uGet4] ->Write(); - fvhGet4DistDoubleHits[uGet4] ->Write(); - fvhGet4DistTripleHits[uGet4] ->Write(); - fvhGet4DistMultipleHits[uGet4]->Write(); - fvhGet4MultipleHitsVsTot[uGet4]->Write(); - } // if( kTRUE == fvbActiveChips[uGet4] ) - } // for( UInt_t uGet4 = 0; uGet4 < fuNbGet4; uGet4++) - } // if( 1 == fiMode ) -*/ - gDirectory->cd( oldir->GetPath() ); - fHist->Close(); -} -void CbmTSUnpackGet4v1x::DeleteMonitorHistograms() -{ - -} -/* -void CbmTSUnpackGet4v1x::MonitorMessage_epoch( get4v1x::Message mess, uint16_t EqID) -{ - // ROC epoch message: 250 MHz clock for now - // TODO: check compatibility when ROC clock changed to 200 MHz - uint8_t cRocId = mess.getRocNumber(); - LOG(debug3)<<"CbmTSUnpackGet4v1x::MonitorMessage_epoch => ROC Epoch: EqId " - <<EqID<<" roc " - <<cRocId; - - // Epoch counter overflow book keeping - if( (get4v1x::kulMainEpochCycleSz - 2) < fvuCurrEpoch[cRocId] && - mess.getEpochNumber() < 2 ) - fvuCurrEpochCycle[cRocId]++; - - fvuCurrEpoch[cRocId] = mess.getEpochNumber(); -} -void CbmTSUnpackGet4v1x::MonitorMessage_sync( get4v1x::Message mess, uint16_t EqID) -{ - // ROC sync message: TS in 250 MHz clock for now - // TODO: check compatibility when ROC clock changed to 200 MHz - uint8_t cRocId = mess.getRocNumber(); - fhRocSyncTypePerRoc->Fill( cRocId, mess.getSyncChNum() ); - LOG(debug3)<<"CbmTSUnpackGet4v1x::MonitorMessage_sync => ROC Sync: EqId " - <<EqID<<" roc " - <<cRocId; -} -void CbmTSUnpackGet4v1x::MonitorMessage_aux( get4v1x::Message mess, uint16_t EqID) -{ - // ROC aux message: TS in 250 MHz clock for now - // TODO: check compatibility when ROC clock changed to 200 MHz - uint8_t cRocId = mess.getRocNumber(); - fhRocAuxTypePerRoc->Fill( cRocId, mess.getAuxChNum() ); - LOG(debug3)<<"CbmTSUnpackGet4v1x::MonitorMessage_aux => ROC Aux: EqId " - <<EqID<<" roc " - <<cRocId; -} -void CbmTSUnpackGet4v1x::MonitorMessage_epoch2( get4v1x::Message mess, uint16_t EqID) -{ - // GET4 v1.x epoch message (24b only for now) - // TODO: check compatibility when 32b format without hack ready - uint8_t cRocId = mess.getRocNumber(); - uint8_t cChipId = mess.getEpoch2ChipNumber(); - uint32_t uChipFullId = cChipId + get4v1x::kuMaxGet4PerRoc*cRocId; - - LOG(debug3)<<"CbmTSUnpackGet4v1x::MonitorMessage_epoch2 => GET4 Epoch2: EqId " - <<EqID<<" roc " - <<cRocId<<" chip " - <<cChipId; - - // Reject data of chips above defined limit to avoid overflow/seg fault - if( fuNbGet4 <= uChipFullId ) - { - if( kTRUE == fbVerbose ) - LOG(info)<<"CbmTSUnpackGet4v1x::MonitorMessage_epoch2 => Ignored message with ChipId above limit!" - <<" ChipId: "<<cChipId - <<" RocId: " <<cRocId - <<" Limit: " <<fuNbGet4; - return; - } // if( fuNbGet4 <= cChipId + kuMaxGet4PerRoc*mess.getRocNumber() ) - - // Reject data of Inactive chips - if( kFALSE == fvbActiveChips[uChipFullId]) - { - if( kTRUE == fbVerbose ) - LOG(info)<<"CbmTSUnpackGet4v1x::MonitorMessage_epoch2 => Ignored message with Inactive Chip!" - <<" ChipId: "<<cChipId - <<" RocId: " <<cRocId; - return; - } // if( kFALSE == fvbActiveChips[uChipFullId]) - - // As long as the 1st epoch with sync flag after SYNC DLM is found, - // consider data as not good - if( kTRUE == fvbGet4WaitFirstSync[uChipFullId] ) - { - if( 1 == mess.getEpoch2Sync() ) - { - fvbGet4WaitFirstSync[uChipFullId] = kFALSE; - - LOG(info) << "First SYNC Epoch after DLM in chip " - <<Form("%3u: ", uChipFullId) - <<Form(" EP #%6u", mess.getEpoch2Number() ) - <<Form(" TS #%12llu", fulTsNb) - <<Form(" MS #%5llu/%5lu", fulMsNb, static_cast<ULong_t>(fsMaxMsNb)) - <<Form(" OF #%5u/%5u", fuOffset, fuMaxOffset) - <<Form(" LO #%5u/%5u", fuLocalOffset, fuMaxLocalOffset); - } // if( 1 == mess.getEpoch2Sync() ) - else return; - } // if( kTRUE == fvbGet4WaitFirstSync[uChipFullId] ) - - // Count epoch messages per chip - fhMessTypePerGet4->Fill( uChipFullId, get4v1x::GET4_32B_EPOCH); - - if( fvuCurrEpoch2[uChipFullId] +1 != mess.getEpoch2Number() && - 0 != fvuCurrEpoch2[uChipFullId] ) - { - Int_t iEpJump = mess.getEpoch2Number(); - iEpJump -= fvuCurrEpoch2[uChipFullId]; - LOG(debug) << "Epoch nb jump in chip " - <<Form("%3u: ", uChipFullId) - << Form(" %3d (%6u -> %6u)", iEpJump, fvuCurrEpoch2[uChipFullId], - mess.getEpoch2Number() ) - <<Form(" TS #%12llu", fulTsNb) - <<Form(" MS #%5llu/%5lu", fulMsNb, static_cast<ULong_t>(fsMaxMsNb)) - <<Form(" OF #%5u/%5u", fuOffset, fuMaxOffset) - <<Form(" LO #%5u/%5u", fuLocalOffset, fuMaxLocalOffset); - - fhGet4EpochJumps->Fill(uChipFullId, iEpJump); - } // if( fvuCurrEpoch2[uChipFullId] +1 != mess.getGet4V10R32EpochNumber()) - - // Epoch counter overflow book keeping - if( (get4v1x::kul24bGet4EpochCycleSz - 2) < fvuCurrEpoch2[uChipFullId] && - mess.getEpoch2Number() < 2 ) - fvuCurrEpoch2Cycle[uChipFullId]++; - - fvuCurrEpoch2[uChipFullId] = mess.getEpoch2Number(); - - // Monitoring of data Time evolution - fvhRocEpochCntEvo[cRocId]->Fill( - ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs*(1e-12) ); // Time since start in s -/ * - fvhGet4EpochCntEvo[uChipFullId]->Fill( - ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs*(1e-12) ); // Time since start in s - if( uChipFullId < kuNbTdcMappedDet ) - if( kiTdcDetMap[uChipFullId] < kiNbDet ) - fvhDetEpochCntEvo[ kiTdcDetMap[uChipFullId] ]->Fill( - ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs*(1e-12) ); // Time since start in s -* / - - if( 1 == mess.getEpoch2Sync() ) - { - fhGet4EpochFlags->Fill(uChipFullId, 0); - fhGet4EpochSyncDist->Fill( uChipFullId, fvuCurrEpoch2[uChipFullId] % get4v1x::kuSyncCycleSzGet4 ); - } // if( 1 == mess.getEpoch2Sync() ) - - if( 1 == mess.getEpoch2EpochMissmatch() ) - { - fhGet4EpochFlags->Fill(uChipFullId, 1); - LOG(debug) << "Epoch missmatch in chip " - <<Form("%3u: ", uChipFullId) - <<Form(" EP #%6u", mess.getEpoch2Number() ) - <<Form(" TS #%12llu", fulTsNb) - <<Form(" MS #%5llu/%5lu", fulMsNb, static_cast<ULong_t>(fsMaxMsNb)) - <<Form(" OF #%5u/%5u", fuOffset, fuMaxOffset) - <<Form(" LO #%5u/%5u", fuLocalOffset, fuMaxLocalOffset); - // TODO: evlution plot - } // if( 1 == mess.getEpoch2EpochMissmatch() ) - if( 1 == mess.getEpoch2EpochLost() ) - { - fhGet4EpochFlags->Fill(uChipFullId, 2); - LOG(debug) << "Epoch loss in chip " - <<Form("%3u: ", uChipFullId) - <<Form(" EP #%6u", mess.getEpoch2Number() ) - <<Form(" TS #%12llu", fulTsNb) - <<Form(" MS #%5llu/%5lu", fulMsNb, static_cast<ULong_t>(fsMaxMsNb)) - <<Form(" OF #%5u/%5u", fuOffset, fuMaxOffset) - <<Form(" LO #%5u/%5u", fuLocalOffset, fuMaxLocalOffset); - - fvhRocEpochLossCntEvo[cRocId]->Fill( - ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs*(1e-12) ); // Time since start in s - fvhGet4EpochLossCntEvo[uChipFullId]->Fill( - ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs*(1e-12) ); // Time since start in s - if( uChipFullId < kuNbTdcMappedDet ) - if( kiTdcDetMap[uChipFullId] < kiNbDet ) - fvhDetEpochLossCntEvo[ kiTdcDetMap[uChipFullId] ]->Fill( - ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs*(1e-12) ); // Time since start in s - } // if( 1 == mess.getEpoch2EpochLost() ) - if( 1 == mess.getEpoch2DataLost() ) - { - fhGet4EpochFlags->Fill(uChipFullId, 3); - LOG(debug) << "Data Loss in chip " - <<Form("%3u: ", uChipFullId) - <<Form(" EP #%6u", mess.getEpoch2Number() ) - <<Form(" TS #%12llu", fulTsNb) - <<Form(" MS #%5llu/%5lu", fulMsNb, static_cast<ULong_t>(fsMaxMsNb)) - <<Form(" OF #%5u/%5u", fuOffset, fuMaxOffset) - <<Form(" LO #%5u/%5u", fuLocalOffset, fuMaxLocalOffset); - - fvhRocDataLossCntEvo[cRocId]->Fill( - ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs*(1e-12) ); // Time since start in s - fvhGet4DataLossCntEvo[uChipFullId]->Fill( - ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs*(1e-12) ); // Time since start in s - if( uChipFullId < kuNbTdcMappedDet ) - if( kiTdcDetMap[uChipFullId] < kiNbDet ) - fvhDetDataLossCntEvo[ kiTdcDetMap[uChipFullId] ]->Fill( - ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs*(1e-12) ); // Time since start in s - } // if( 1 == mess.getEpoch2DataLost() ) - - // Fill Pulser test histos if needed - // Accepted pairs are when both messages are defined and they are at most - // 1 epoch apart => possibility of double use is the pulse happens on top of - // an epoch and more than once every 3 epochs. For example: - // HHHHEHHHH.......E......HHHHEHHHH leads to - // (HHHHHHHH) (HHHHHHHH) and - // (HHHH HHHH) - if( kTRUE == fbPulserMode && 0 == uChipFullId && kTRUE == fbOldReadoutOk ) - { - // Fill the time difference for all channels pairs in - // the chosen Fee - UInt_t uHistoFeeIdx = 0; - for( UInt_t uChanFeeA = 0; uChanFeeA < kuNbChanFee; uChanFeeA++) - for( UInt_t uChanFeeB = uChanFeeA + 1; uChanFeeB < kuNbChanFee; uChanFeeB++) - { - if( - ( get4v1x::MSG_GET4 == fvmLastHit[ fuPulserFee * kuNbChanFee+ uChanFeeA].getMessageType() ) && - ( get4v1x::MSG_GET4 == fvmLastHit[ fuPulserFee * kuNbChanFee+ uChanFeeB].getMessageType() ) && - ( fvuLastHitEp[ fuPulserFee * kuNbChanFee+ uChanFeeA ] - < fvuLastHitEp[ fuPulserFee * kuNbChanFee+ uChanFeeB ] + 2 ) && - ( fvuLastHitEp[ fuPulserFee * kuNbChanFee+ uChanFeeA ] + 2 - > fvuLastHitEp[ fuPulserFee * kuNbChanFee+ uChanFeeB ] ) ) - { - Double_t dTimeDiff = 0.0; - dTimeDiff = fvmLastHit[ fuPulserFee * kuNbChanFee+ uChanFeeA].CalcGet4V10R24HitTimeDiff( - fvuLastHitEp[ fuPulserFee * kuNbChanFee+ uChanFeeA], - fvuLastHitEp[ fuPulserFee * kuNbChanFee+ uChanFeeB], - fvmLastHit[ fuPulserFee * kuNbChanFee+ uChanFeeB] ); - - fhTimeResFee[uHistoFeeIdx]->Fill( dTimeDiff ); - } // if both channels have matching data - uHistoFeeIdx++; - } // for any unique pair of channel in chosen Fee - - // Fill the time difference for the chosen channel pairs - UInt_t uHistoCombiIdx = 0; - for( UInt_t uChanA = 0; uChanA < kuNbChanTest-1; uChanA++) - { - if( ( get4v1x::MSG_GET4 == fvmLastHit[ fuPulserChan[uChanA] ].getMessageType() ) && - ( get4v1x::MSG_GET4 == fvmLastHit[ fuPulserChan[uChanA+1] ].getMessageType() ) && - ( fvuLastHitEp[ fuPulserChan[uChanA] ] - < fvuLastHitEp[ fuPulserChan[uChanA+1] ] + 2 ) && - ( fvuLastHitEp[ fuPulserChan[uChanA] ] + 2 - > fvuLastHitEp[ fuPulserChan[uChanA+1] ] ) ) - { - Double_t dTimeDiff = - fvmLastHit[ fuPulserChan[uChanA] ].CalcGet4V10R24HitTimeDiff( - fvuLastHitEp[ fuPulserChan[uChanA] ], - fvuLastHitEp[ fuPulserChan[uChanA+1] ], - fvmLastHit[ fuPulserChan[uChanA+1] ] ); - fhTimeResPairs[uChanA]->Fill( dTimeDiff ); - } // // if both channels have data - - for( UInt_t uChanB = uChanA+1; uChanB < kuNbChanComb; uChanB++) - { - if( ( get4v1x::MSG_GET4 == fvmLastHit[ fuPulserChan[uChanA] ].getMessageType() ) && - ( get4v1x::MSG_GET4 == fvmLastHit[ fuPulserChan[uChanB] ].getMessageType() ) && - ( fvuLastHitEp[ fuPulserChan[uChanA] ] - < fvuLastHitEp[ fuPulserChan[uChanB] ] + 2 ) && - ( fvuLastHitEp[ fuPulserChan[uChanA] ] + 2 - > fvuLastHitEp[ fuPulserChan[uChanB] ] ) ) - { - Double_t dTimeDiff = - fvmLastHit[ fuPulserChan[uChanA] ].CalcGet4V10R24HitTimeDiff( - fvuLastHitEp[ fuPulserChan[uChanA] ], - fvuLastHitEp[ fuPulserChan[uChanB] ], - fvmLastHit[ fuPulserChan[uChanB] ] ); - fhTimeResCombi[uHistoCombiIdx]->Fill( dTimeDiff ); - } // if both channels have data - uHistoCombiIdx++; - } // for( UInt_t uChanB = uChanA+1; uChanB < kuNbChanComb; uChanB++) - } // for( UInt_t uChanA = 0; uChanA < kuNbChanTest; uChanA++) - - } // if( kTRUE == fbPulserMode && 0 == uChipFullId && kTRUE == fbOldReadoutOk ) - -} -void CbmTSUnpackGet4v1x::MonitorMessage_get4( get4v1x::Message mess, uint16_t EqID) -{ - // GET4 v1.x data message (24b only for now) - // TODO: check compatibility when 32b format without hack ready - uint8_t cRocId = mess.getRocNumber(); - LOG(debug3)<<"CbmTSUnpackGet4v1x::MonitorMessage_get4 => GET4 Data: EqId " - <<EqID<<" roc " - <<cRocId; - - uint8_t cChipId = mess.getGet4Number(); - UInt_t uChipFullId = cChipId + get4v1x::kuMaxGet4PerRoc*cRocId; - UInt_t uFullChId = - get4v1x::kuChanPerGet4*( uChipFullId ) - + mess.getGet4ChNum(); - UInt_t uTimeStamp = mess.getGet4Ts(); - - // Reject data of chips above defined limit to avoid overflow/seg fault - if( fuNbGet4 <= uChipFullId ) - { - if( kTRUE == fbVerbose ) - LOG(info)<<"CbmTSUnpackGet4v1x::MonitorMessage_get4 => Ignored message with ChipId above limit!" - <<" ChipId: "<<cChipId - <<" RocId: " <<cRocId - <<" Limit: " <<fuNbGet4; - return; - } // if( fuNbGet4 <= cChipId + kuMaxGet4PerRoc*mess.getRocNumber() ) - - // Reject data of Inactive chips - if( kFALSE == fvbActiveChips[uChipFullId]) - { - if( kTRUE == fbVerbose ) - LOG(info)<<"CbmTSUnpackGet4v1x::MonitorMessage_get4 => Ignored message with Inactive Chip!" - <<" ChipId: "<<cChipId - <<" RocId: " <<cRocId; - return; - } // if( kFALSE == fvbActiveChips[uChipFullId]) - - // As long as the 1st epoch with sync flag after SYNC DLM is found, - // consider data as not good - if( kTRUE == fvbGet4WaitFirstSync[uChipFullId] ) - return; - - fvhRocDataCntEvo[cRocId]->Fill( - ( ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs - + uTimeStamp*get4v1x::kdBinSize ) - *(1e-12) ); // Time since start in s - fvhGet4DataCntEvo[uChipFullId]->Fill( - ( ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs - + uTimeStamp*get4v1x::kdBinSize ) - *(1e-12) ); // Time since start in s - fvhGet4ChDataCntEvo[uChipFullId]->Fill( mess.getGet4ChNum(), - ( ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs - + uTimeStamp*get4v1x::kdBinSize ) - *(1e-12) ); // Time since start in s - if( uChipFullId < kuNbTdcMappedDet ) - if( kiTdcDetMap[uChipFullId] < kiNbDet ) - fvhDetDataCntEvo[ kiTdcDetMap[uChipFullId] ]->Fill( - ( ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs - + uTimeStamp*get4v1x::kdBinSize ) - *(1e-12) ); // Time since start in s - - // Count data messages per chip - fhMessTypePerGet4->Fill( uChipFullId, get4v1x::GET4_32B_DATA); - - if( kTRUE == fbEnaCalibOutput ) - fvhFineTime[ uChipFullId ][ mess.getGet4ChNum() ]->Fill( mess.getGet4FineTs() ); - - if( kTRUE == fbPulserMode && kTRUE == fbOldReadoutOk ) - { - if( 1 == mess.getGet4Edge() ) - { - Double_t dTot = mess.CalcGet4V10R24HitTimeDiff( - fvuCurrEpoch2[uChipFullId], - fvuLastHitEp[ uFullChId], - fvmLastHit[ uFullChId ] )/1000.0; - if( 0.0 < dTot && dTot < 100.0 ) - fhGet4ChanTotMap->Fill( uFullChId, dTot); - - // Save the hit info in order to fill later the pulser histos - // First fill time interval histos - if( fuPulserFee == (uFullChId/kuNbChanFee) ) - // Fill the DNL histos - fhPulserFeeTotDnl->Fill( uFullChId%kuNbChanFee, uTimeStamp & get4v1x::kuFineTime ); - } // if( 1 == mess.getGet4Edge() ) - else - { - Double_t dTot = fvmLastOldTot[ uFullChId ].CalcGet4V10R24HitTimeDiff( - fvuLastOldTotEp[ uFullChId ], - fvuCurrEpoch2[uChipFullId], - mess )/1000.0; - if( 0.0 < dTot && dTot < 100.0 ) - fhGet4ChanTotMap->Fill( uFullChId, dTot); - - // Save the hit info in order to fill later the pulser histos - // First fill time interval histos - if( fuPulserFee == (uFullChId/kuNbChanFee) ) - { - Double_t dHitsDt = mess.CalcGet4V10R24HitTimeDiff( - fvuCurrEpoch2[uChipFullId], - fvuLastHitEp[ uFullChId ], - fvmLastHit[ uFullChId ] ); - if( 0 == fvuLastHitEp[uFullChId]) - {} - else if( dHitsDt < 1e6 ) - fhPulserHitDistNs->Fill( uFullChId%kuNbChanFee, dHitsDt / 1e3 ); - else if( dHitsDt < 1e9) - fhPulserHitDistUs->Fill( uFullChId%kuNbChanFee, dHitsDt / 1e6 ); - else - fhPulserHitDistMs->Fill( uFullChId%kuNbChanFee, dHitsDt / 1e9 ); - - if( 0 < fvuLastHitEp[uFullChId] && dHitsDt < 5e3 ) - LOG(debug) <<uFullChId<<" "<<dHitsDt<<" " - <<fvuLastHitEp[ uFullChId ]<<" "<<fvuCurrEpoch2[uChipFullId]<<" " - <<fvmLastOldTot[ uFullChId ].CalcGet4V10R24HitTimeDiff( - fvuLastOldTotEp[ uFullChId ], - fvuLastHitEp[ uFullChId], - fvmLastHit[ uFullChId ] )/1000.0<<" " - <<fvmLastOldTot[ uFullChId ].CalcGet4V10R24HitTimeDiff( - fvuLastOldTotEp[ uFullChId ], - fvuCurrEpoch2[uChipFullId], - mess )/1000.0;; - - // Fill the DNL histos - fhPulserFeeDnl->Fill( uFullChId%kuNbChanFee, uTimeStamp & get4v1x::kuFineTime ); - } // if( fuPulserFee == (uFullChId/kuNbChanFee) ) - } // else of if( 1 == mess.getGet4Edge() ) - } // if( kTRUE == fbPulserMode && kTRUE == fbOldReadoutOk ) - - if( kTRUE == fbOldReadoutOk ) - { - if( 1 == mess.getGet4Edge() ) - { - fhGet4ChanTotCount->Fill( uFullChId ); - // Epoch of Last hit message (one per GET4 chip & channel) - fvuLastOldTotEp[ uFullChId ] = fvuCurrEpoch2[uChipFullId]; - // Last hit message (one per GET4 chip & channel) - fvmLastOldTot[ uFullChId ] = mess; - - fvdChanFirstHitTot[uChipFullId][mess.getGet4ChNum()] = - mess.CalcGet4V10R24HitTimeDiff( - fvuCurrEpoch2[uChipFullId], fvuLastHitEp[ uFullChId ], fvmLastHit[ uFullChId ] ); - } // if( 1 == mess.getGet4Edge() ) - else - { - fhGet4ChanDataCount->Fill( uFullChId ); - // Fill time coincidence map - for( UInt_t uFeeA = 0; uFeeA < fuNbFee; uFeeA++) - for( UInt_t uFeeChan = 0; uFeeChan < get4v1x::kuChanPerFee; uFeeChan++ ) - if( ( get4v1x::MSG_GET4 == - fvmLastHit[ uFeeA*get4v1x::kuChanPerFee + uFeeChan ].getMessageType() ) && - ( fvuLastHitEp[ uFeeA*get4v1x::kuChanPerFee + uFeeChan/get4v1x::kuChanPerGet4 ] - < fvuCurrEpoch2[uChipFullId] + 2 ) && - ( fvuLastHitEp[ uFeeA*get4v1x::kuChanPerFee + uFeeChan/get4v1x::kuChanPerGet4 ] + 2 - > fvuCurrEpoch2[uChipFullId] ) ) - { - // compare to last hit in other channel - Double_t dHitsDt = mess.CalcGet4V10R24HitTimeDiff( - fvuCurrEpoch2[uChipFullId], - fvuLastHitEp[ uFeeA*get4v1x::kuChanPerFee + uFeeChan/get4v1x::kuChanPerGet4 ], - fvmLastHit[ uFeeA*get4v1x::kuChanPerFee + uFeeChan ] ); - if( TMath::Abs(dHitsDt) < fdMaxCoincDist ) - { - if( uFeeA*get4v1x::kuChanPerFee + uFeeChan < uFullChId ) - fvvhChannelsCoinc[uFeeA][uFullChId/get4v1x::kuChanPerFee]->Fill( - uFeeChan, uFullChId%get4v1x::kuChanPerFee); - else fvvhChannelsCoinc[uFullChId/get4v1x::kuChanPerFee][uFeeA]->Fill( - uFullChId%get4v1x::kuChanPerFee, uFeeChan); - } // if( TMath::Abs(dHitsDt) < fdMaxCoincDist ) - } // for each pair, if both hits valid - - // Multiple hits (reflections, ...) detection - if( 1 == fiMode) - { - Double_t dHitsDt = mess.CalcGet4V10R24HitTimeDiff( - fvuCurrEpoch2[uChipFullId], - fvuLastHitEp[ uFullChId ], - fvmLastHit[ uFullChId ] ); - if( dHitsDt < fdMaxDtMultiHit ) - { - if( kFALSE == fvbChanSecondHit[uChipFullId][mess.getGet4ChNum()] ) - { - fvhGet4MultipleHits[uChipFullId]->Fill( mess.getGet4ChNum(), 2); - fvhGet4DistDoubleHits[uChipFullId]->Fill( mess.getGet4ChNum(), dHitsDt); - fvbChanSecondHit[uChipFullId][mess.getGet4ChNum()] = kTRUE; - - fvhGet4MultipleHitsVsTot[uChipFullId]->Fill( - fvdChanFirstHitTot[uChipFullId][mess.getGet4ChNum()], 2); - } - else if ( kFALSE == fvbChanThirdHit[uChipFullId][mess.getGet4ChNum()] ) - { - fvhGet4MultipleHits[uChipFullId]->Fill( mess.getGet4ChNum(), 3); - fvhGet4DistTripleHits[uChipFullId]->Fill( mess.getGet4ChNum(), dHitsDt); - fvbChanThirdHit[uChipFullId][mess.getGet4ChNum()] = kTRUE; - - fvhGet4MultipleHitsVsTot[uChipFullId]->Fill( - fvdChanFirstHitTot[uChipFullId][mess.getGet4ChNum()], 3); - } - else - { - fvhGet4MultipleHits[uChipFullId]->Fill( mess.getGet4ChNum(), 4); - fvhGet4DistMultipleHits[uChipFullId]->Fill( mess.getGet4ChNum(), dHitsDt); - - fvhGet4MultipleHitsVsTot[uChipFullId]->Fill( - fvdChanFirstHitTot[uChipFullId][mess.getGet4ChNum()], 4); - } - } // if( dHitsDt < fdMaxDtMultiHit ) - else - { - fvhGet4MultipleHits[uChipFullId]->Fill( mess.getGet4ChNum(), 1); - fvbChanSecondHit[uChipFullId][mess.getGet4ChNum()] = kFALSE; - fvbChanThirdHit[uChipFullId][mess.getGet4ChNum()] = kFALSE; - - fvhGet4MultipleHitsVsTot[uChipFullId]->Fill( - fvdChanFirstHitTot[uChipFullId][mess.getGet4ChNum()], 1); - } // else of if( dHitsDt < fdMaxDtMultiHit ) - } // if( 1 == fiMode) - - // Epoch of Last hit message (one per GET4 chip & channel) - fvuLastHitEp[ uFullChId ] = fvuCurrEpoch2[uChipFullId]; - // Last hit message (one per GET4 chip & channel) - fvmLastHit[ uFullChId ] = mess; - } // else of if( 1 == mess.getGet4Edge() ) - } // if( kTRUE == fbOldReadoutOk ) -} -void CbmTSUnpackGet4v1x::MonitorMessage_sys( get4v1x::Message mess, uint16_t EqID) -{ - uint8_t cRocId = mess.getRocNumber(); - LOG(debug3)<<"CbmTSUnpackGet4v1x::MonitorMessage_sys => System message: EqId " - <<EqID<<" roc " - <<cRocId; - - if( mess.getSysMesType() < get4v1x::SYSMSG_GET4V1_32BIT_0 ) - fhSysMessTypePerRoc->Fill( cRocId, mess.getSysMesType() ); - - switch( mess.getSysMesType() ) - { - case get4v1x::SYSMSG_DAQ_START: - { - break; - } // case get4v1x::SYSMSG_DAQ_START - case get4v1x::SYSMSG_DAQ_FINISH: - { - break; - } // case get4v1x::SYSMSG_DAQ_FINISH - case get4v1x::SYSMSG_NX_PARITY: - case get4v1x::SYSMSG_ADC: - case get4v1x::SYSMSG_PCTIME: - { - // NXYTER related => don't care in this unpacker - break; - } // case get4v1x::SYSMSG_NX_PARITY - case get4v1x::SYSMSG_SYNC_PARITY: - { - break; - } // case get4v1x::SYSMSG_SYNC_PARITY - case get4v1x::SYSMSG_DAQ_RESUME: - { - break; - } // case get4v1x::SYSMSG_DAQ_RESUME - case get4v1x::SYSMSG_FIFO_RESET: - { - break; - } // case get4v1x::SYSMSG_FIFO_RESET - case get4v1x::SYSMSG_USER: - { - if( get4v1x::SYSMSG_USER_ROCFEET_SYNC == mess.getSysMesData() ) - { - LOG(info)<<"CbmTSUnpackGet4v1x::MonitorMessage_sys => SYNC DLM!" - <<" RocId: " << Form("%02u", cRocId) - <<Form(" TS #%12llu", fulTsNb) - <<Form(" MS #%5llu/%5lu", fulMsNb, static_cast<ULong_t>(fsMaxMsNb)) - <<Form(" OF #%5u/%5u", fuOffset, fuMaxOffset) - <<Form(" LO #%5u/%5u", fuLocalOffset, fuMaxLocalOffset); - fvbRocFeetSyncStart[cRocId] = kTRUE; - } // if( get4v1x::SYSMSG_USER_ROCFEET_SYNC == mess.getSysMesData() ) - break; - } // case get4v1x::SYSMSG_USER - case get4v1x::SYSMSG_PACKETLOST: - { - break; - } // case get4v1x::SYSMSG_PACKETLOST - case get4v1x::SYSMSG_GET4_EVENT: - { - // GET4 v1.x error message (24b only for now) - // TODO: check compatibility when 32b format without hack ready - uint8_t cChipId = mess.getGet4V10R24ErrorChip(); - uint32_t uChipFullId = cChipId + get4v1x::kuMaxGet4PerRoc*cRocId; - uint8_t uErrorType= mess.getGet4V10R24ErrorData(); - // Count error messages per ROC - fvhRocErrorCntEvo[cRocId]->Fill( - ( ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs ) - *(1e-12) ); // Time since start in s - // Count error messages per chip - fhMessTypePerGet4->Fill( uChipFullId, get4v1x::GET4_32B_ERROR); - fvhGet4ErrorCntEvo[uChipFullId]->Fill( - ( ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs ) - *(1e-12) ); // Time since start in s - - if( ( get4v1x::GET4_V1X_ERR_EP < uErrorType && - uErrorType < get4v1x::GET4_V1X_ERR_TOK_RING_ST ) ) - fvhGet4ChErrorCntEvo[uChipFullId]->Fill( mess.getGet4V10R24ErrorChan(), - ( ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs ) - *(1e-12) ); // Time since start in s - - if( uChipFullId < kuNbTdcMappedDet ) - if( kiTdcDetMap[uChipFullId] < kiNbDet ) - fvhDetErrorCntEvo[ kiTdcDetMap[uChipFullId] ]->Fill( - ( ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs) - *(1e-12) ); // Time since start in s - break; - } // case get4v1x::SYSMSG_GET4_EVENT - case get4v1x::SYSMSG_CLOSYSYNC_ERROR: - { - break; - } // case get4v1x::SYSMSG_CLOSYSYNC_ERROR - case get4v1x::SYSMSG_TS156_SYNC: - { - break; - } // case get4v1x::SYSMSG_TS156_SYNC - case get4v1x::SYSMSG_GET4V1_32BIT_0: - case get4v1x::SYSMSG_GET4V1_32BIT_1: - case get4v1x::SYSMSG_GET4V1_32BIT_2: - case get4v1x::SYSMSG_GET4V1_32BIT_3: - case get4v1x::SYSMSG_GET4V1_32BIT_4: - case get4v1x::SYSMSG_GET4V1_32BIT_5: - case get4v1x::SYSMSG_GET4V1_32BIT_6: - case get4v1x::SYSMSG_GET4V1_32BIT_7: - case get4v1x::SYSMSG_GET4V1_32BIT_8: - case get4v1x::SYSMSG_GET4V1_32BIT_9: - case get4v1x::SYSMSG_GET4V1_32BIT_10: - case get4v1x::SYSMSG_GET4V1_32BIT_11: - case get4v1x::SYSMSG_GET4V1_32BIT_12: - case get4v1x::SYSMSG_GET4V1_32BIT_13: - case get4v1x::SYSMSG_GET4V1_32BIT_14: - case get4v1x::SYSMSG_GET4V1_32BIT_15: - { - // Ignore all messages before RocFeet system SYNC - if (kFALSE == fvbRocFeetSyncStart[cRocId] ) - break; - - // GET4 v1.x 32b raw message using hack - fhMessageTypePerRoc->Fill( cRocId, 15 ); - fhSysMessTypePerRoc->Fill( cRocId, 15 ); - - MonitorMessage_Get4v1( mess, EqID); - break; - } // case get4v1x::SYSMSG_TS156_SYNC - default: - { - if( kTRUE == fbVerbose ) - LOG(warning)<<"CbmTSUnpackGet4v1x::MonitorMessage_sys => Unknown sysMess type ignored: " - <<mess.getSysMesType(); - break; - } // default: - } // switch( mess.getSysMesType() ) -} -void CbmTSUnpackGet4v1x::MonitorMessage_Get4v1( get4v1x::Message mess, uint16_t EqID) -{ - // GET4 v1.x 32b raw message using hack - uint8_t cRocId = mess.getRocNumber(); - uint8_t cChipId = mess.getGet4V10R32ChipId(); - uint32_t uChipFullId = cChipId + get4v1x::kuMaxGet4PerRoc*cRocId; - uint8_t cMessType = mess.getGet4V10R32MessageType(); - - LOG(debug3)<<"CbmTSUnpackGet4v1x::MonitorMessage_Get4v1 => 32b GET4 message: EqId " - <<EqID<<" roc " - <<cRocId; - - // Reject data of chips above defined limit to avoid overflow/seg fault - if( fuNbGet4 <= uChipFullId ) - { - if( kTRUE == fbVerbose ) - LOG(info)<<"CbmTSUnpackGet4v1x::MonitorMessage_Get4v1 => Ignored message with ChipId above limit!" - <<" ChipId: "<<cChipId - <<" RocId: " <<cRocId - <<" Limit: " <<fuNbGet4; - return; - } // if( fuNbGet4 <= cChipId + kuMaxGet4PerRoc*mess.getRocNumber() ) - - // Reject data of Inactive chips - if( kFALSE == fvbActiveChips[uChipFullId]) - { - if( kTRUE == fbVerbose ) - LOG(info)<<"CbmTSUnpackGet4v1x::MonitorMessage_Get4v1 => Ignored message with Inactive Chip!" - <<" ChipId: "<<cChipId - <<" RocId: " <<cRocId; - return; - } // if( kFALSE == fvbActiveChips[uChipFullId]) - - // Count messages type per chip - fhMessTypePerGet4->Fill( uChipFullId, cMessType); - - switch( cMessType ) - { - case get4v1x::GET4_32B_EPOCH: // => Epoch message - { - // As long as the 1st epoch with sync flag after SYNC DLM is found, - // consider data as not good - if( kTRUE == fvbGet4WaitFirstSync[uChipFullId] ) - { - if( 1 == mess.getGet4V10R32SyncFlag() ) - { - fvbGet4WaitFirstSync[uChipFullId] = kFALSE; - - LOG(info) << "First SYNC Epoch after DLM in chip " - <<Form("%3u: ", uChipFullId) - <<Form(" EP #%6u", mess.getGet4V10R32EpochNumber() ) - <<Form(" TS #%12llu", fulTsNb) - <<Form(" MS #%5llu/%5lu", fulMsNb, static_cast<ULong_t>(fsMaxMsNb)) - <<Form(" OF #%5u/%5u", fuOffset, fuMaxOffset) - <<Form(" LO #%5u/%5u", fuLocalOffset, fuMaxLocalOffset); - } // if( 1 == mess.getGet4V10R32SyncFlag() ) - else return; - } // if( kTRUE == fvbGet4WaitFirstSync[uChipFullId] ) - - if( fvuCurrEpoch2[uChipFullId] +1 != mess.getGet4V10R32EpochNumber() && - 0 != fvuCurrEpoch2[uChipFullId] ) - { - Int_t iEpJump = mess.getGet4V10R32EpochNumber(); - iEpJump -= fvuCurrEpoch2[uChipFullId]; - if( TMath::Abs(iEpJump) < 200 ) - LOG(debug) << "Epoch nb jump in chip " - <<Form("%3u: ", uChipFullId) - << Form(" %3d (%6u -> %6u)", iEpJump, fvuCurrEpoch2[uChipFullId], - mess.getGet4V10R32EpochNumber() ) - <<Form(" TS #%12llu", fulTsNb) - <<Form(" MS #%5llu/%5lu", fulMsNb, static_cast<ULong_t>(fsMaxMsNb)) - <<Form(" OF #%5u/%5u", fuOffset, fuMaxOffset) - <<Form(" LO #%5u/%5u", fuLocalOffset, fuMaxLocalOffset); - else LOG(info) << "Epoch nb jump in chip " - <<Form("%3u: ", uChipFullId) - << Form(" %3d (%6u -> %6u)", iEpJump, fvuCurrEpoch2[uChipFullId], - mess.getGet4V10R32EpochNumber() ) - <<Form(" TS #%12llu", fulTsNb) - <<Form(" MS #%5llu/%5lu", fulMsNb, fsMaxMsNb) - <<Form(" OF #%5u/%5u", fuOffset, fuMaxOffset) - <<Form(" LO #%5u/%5u", fuLocalOffset, fuMaxLocalOffset); - - fhGet4EpochJumps->Fill(uChipFullId, iEpJump); - } // if( fvuCurrEpoch2[uChipFullId] +1 != mess.getGet4V10R32EpochNumber()) - - // Epoch counter overflow book keeping - if( (get4v1x::kulGet4EpochCycleSz - 2) < fvuCurrEpoch2[uChipFullId] && - mess.getEpoch2Number() < 2 ) - fvuCurrEpoch2Cycle[uChipFullId]++; - - fvuCurrEpoch2[uChipFullId] = mess.getGet4V10R32EpochNumber(); - - fvhRocEpochCntEvo[cRocId]->Fill( - ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs*(1e-12) ); // Time since start in s - - if( 1 == mess.getGet4V10R32SyncFlag() ) - { - fhGet4EpochFlags->Fill(uChipFullId , 0); - fhGet4EpochSyncDist->Fill( uChipFullId, fvuCurrEpoch2[uChipFullId] % get4v1x::kuSyncCycleSzGet4 ); - } // if( 1 == mess.getGet4V10R32SyncFlag() ) - - // Fill Pulser test histos if needed - // Accepted pairs are when both messages are defined and they are at most - // 1 epoch apart => possibility of double use is the pulse happens on top of - // an epoch and more than once every 3 epochs. For example: - // HHHHEHHHH.......E......HHHHEHHHH leads to - // (HHHHHHHH) (HHHHHHHH) and - // (HHHH HHHH) - if( kTRUE == fbPulserMode && 0 == uChipFullId ) - { - // Fill the time difference for all channels pairs in - // the chosen Fee - UInt_t uHistoFeeIdx = 0; - for( UInt_t uChanFeeA = 0; uChanFeeA < kuNbChanFee; uChanFeeA++) - for( UInt_t uChanFeeB = uChanFeeA + 1; uChanFeeB < kuNbChanFee; uChanFeeB++) - { - if( ( 0xF0 <= fvmLastHit[ fuPulserFee * kuNbChanFee+ uChanFeeA].getSysMesType() ) && - ( 0xF0 <= fvmLastHit[ fuPulserFee * kuNbChanFee+ uChanFeeB].getSysMesType() ) && - ( fvuLastHitEp[ fuPulserFee * kuNbChanFee+ uChanFeeA ] - < fvuLastHitEp[ fuPulserFee * kuNbChanFee+ uChanFeeB ] + 2 ) && - ( fvuLastHitEp[ fuPulserFee * kuNbChanFee+ uChanFeeA ] + 2 - > fvuLastHitEp[ fuPulserFee * kuNbChanFee+ uChanFeeB ] ) ) - { - Double_t dTimeDiff = 0.0; - dTimeDiff = fvmLastHit[ fuPulserFee * kuNbChanFee+ uChanFeeA].CalcGet4V10R32HitTimeDiff( - fvuLastHitEp[ fuPulserFee * kuNbChanFee+ uChanFeeA], - fvuLastHitEp[ fuPulserFee * kuNbChanFee+ uChanFeeB], - fvmLastHit[ fuPulserFee * kuNbChanFee+ uChanFeeB] ); - - fhTimeResFee[uHistoFeeIdx]->Fill( dTimeDiff ); - } // if both channels have matching data - uHistoFeeIdx++; - } // for any unique pair of channel in chosen Fee - - // Fill the time difference for the chosen channel pairs - UInt_t uHistoCombiIdx = 0; - for( UInt_t uChanA = 0; uChanA < kuNbChanTest-1; uChanA++) - { - if( ( 0xF0 <= fvmLastHit[ fuPulserChan[uChanA] ].getSysMesType() ) && - ( 0xF0 <= fvmLastHit[ fuPulserChan[uChanA+1] ].getSysMesType() ) && - ( fvuLastHitEp[ fuPulserChan[uChanA] ] - < fvuLastHitEp[ fuPulserChan[uChanA+1] ] + 2 ) && - ( fvuLastHitEp[ fuPulserChan[uChanA] ] + 2 - > fvuLastHitEp[ fuPulserChan[uChanA+1] ] ) ) - { - Double_t dTimeDiff = - fvmLastHit[ fuPulserChan[uChanA] ].CalcGet4V10R32HitTimeDiff( - fvuLastHitEp[ fuPulserChan[uChanA] ], - fvuLastHitEp[ fuPulserChan[uChanA+1] ], - fvmLastHit[ fuPulserChan[uChanA+1] ] ); - fhTimeResPairs[uChanA]->Fill( dTimeDiff ); - } // // if both channels have data - - for( UInt_t uChanB = uChanA+1; uChanB < kuNbChanComb; uChanB++) - { - if( ( 0xF0 <= fvmLastHit[ fuPulserChan[uChanA] ].getSysMesType() ) && - ( 0xF0 <= fvmLastHit[ fuPulserChan[uChanB] ].getSysMesType() ) && - ( fvuLastHitEp[ fuPulserChan[uChanA] ] - < fvuLastHitEp[ fuPulserChan[uChanB] ] + 2 ) && - ( fvuLastHitEp[ fuPulserChan[uChanA] ] + 2 - > fvuLastHitEp[ fuPulserChan[uChanB] ] ) ) - { - Double_t dTimeDiff = - fvmLastHit[ fuPulserChan[uChanA] ].CalcGet4V10R32HitTimeDiff( - fvuLastHitEp[ fuPulserChan[uChanA] ], - fvuLastHitEp[ fuPulserChan[uChanB] ], - fvmLastHit[ fuPulserChan[uChanB] ] ); - fhTimeResCombi[uHistoCombiIdx]->Fill( dTimeDiff ); - } // if both channels have data - uHistoCombiIdx++; - } // for( UInt_t uChanB = uChanA+1; uChanB < kuNbChanComb; uChanB++) - } // for( UInt_t uChanA = 0; uChanA < kuNbChanTest; uChanA++) - - } // if( kTRUE == fbPulserMode ) - break; - } // case get4v1x::GET4_32B_EPOCH - case get4v1x::GET4_32B_SLCM: // => Slow control - { - Double_t dFullChId = - get4v1x::kuChanPerGet4*( uChipFullId ) - + mess.getGet4V10R32SlChan() - + 0.5*mess.getGet4V10R32SlEdge(); - - // As long as the 1st epoch with sync flag after SYNC DLM is found, - // consider data as not good - if( kTRUE == fvbGet4WaitFirstSync[uChipFullId] ) - return; - - fhGet4ChanSlowContM->Fill( dFullChId, mess.getGet4V10R32SlType() ); - break; - } // case get4v1x::GET4_32B_SLCM - case get4v1x::GET4_32B_ERROR: // => Error message - { - Double_t dFullChId = - get4v1x::kuChanPerGet4*( uChipFullId ) - + mess.getGet4V10R32ErrorChan() - + 0.5*mess.getGet4V10R32ErrorEdge(); - - UInt_t uErrorType = mess.getGet4V10R32ErrorData(); - - // As long as the 1st epoch with sync flag after SYNC DLM is found, - // consider data as not good - if( kTRUE == fvbGet4WaitFirstSync[uChipFullId] ) - return; - - // Count error messages per ROC - fvhRocErrorCntEvo[cRocId]->Fill( - ( ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs ) - *(1e-12) ); // Time since start in s - - fvhGet4ErrorCntEvo[uChipFullId]->Fill( - ( ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs) - *(1e-12) ); // Time since start in s - - if( ( get4v1x::GET4_V1X_ERR_EP < uErrorType && - uErrorType < get4v1x::GET4_V1X_ERR_TOK_RING_ST ) || - get4v1x::GET4_V1X_ERR_TOT_OVERWRT == uErrorType || - get4v1x::GET4_V1X_ERR_TOT_RANGE == uErrorType ) - fvhGet4ChErrorCntEvo[uChipFullId]->Fill( mess.getGet4V10R32ErrorChan(), - ( ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs) - *(1e-12) ); // Time since start in s - - if( uChipFullId < kuNbTdcMappedDet ) - if( kiTdcDetMap[uChipFullId] < kiNbDet ) - fvhDetErrorCntEvo[ kiTdcDetMap[uChipFullId] ]->Fill( - ( ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs) - *(1e-12) ); // Time since start in s - - switch( uErrorType ) - { - case get4v1x::GET4_V1X_ERR_READ_INIT: - fhGet4ChanErrors->Fill( dFullChId, 0); - LOG(info)<<"CbmTSUnpackGet4v1x::MonitorMessage_Get4v1 => Readout Init!" - <<" ChipId: "<<Form("%02u", cChipId) - <<" RocId: " <<Form("%02u", cRocId) - <<" TS: " <<fulTsNb; - break; - case get4v1x::GET4_V1X_ERR_SYNC: - fhGet4ChanErrors->Fill( dFullChId, 1); - break; - case get4v1x::GET4_V1X_ERR_EP_CNT_SYNC: - fhGet4ChanErrors->Fill( dFullChId, 2); - break; - case get4v1x::GET4_V1X_ERR_EP: - fhGet4ChanErrors->Fill( dFullChId, 3); - break; - case get4v1x::GET4_V1X_ERR_FIFO_WRITE: - fhGet4ChanErrors->Fill( dFullChId, 4); - break; - case get4v1x::GET4_V1X_ERR_LOST_EVT: - fhGet4ChanErrors->Fill( dFullChId, 5); - break; - case get4v1x::GET4_V1X_ERR_CHAN_STATE: - fhGet4ChanErrors->Fill( dFullChId, 6); - break; - case get4v1x::GET4_V1X_ERR_TOK_RING_ST: - fhGet4ChanErrors->Fill( dFullChId, 7); - break; - case get4v1x::GET4_V1X_ERR_TOKEN: - fhGet4ChanErrors->Fill( dFullChId, 8); - break; - case get4v1x::GET4_V1X_ERR_READOUT_ERR: - fhGet4ChanErrors->Fill( dFullChId, 9); - break; - case get4v1x::GET4_V1X_ERR_SPI: - fhGet4ChanErrors->Fill( dFullChId, 10); - break; - case get4v1x::GET4_V1X_ERR_DLL_LOCK: - fhGet4ChanErrors->Fill( dFullChId, 11); - break; - case get4v1x::GET4_V1X_ERR_DLL_RESET: - fhGet4ChanErrors->Fill( dFullChId, 12); - break; - case get4v1x::GET4_V1X_ERR_TOT_OVERWRT: - fhGet4ChanErrors->Fill( dFullChId, 13); - break; - case get4v1x::GET4_V1X_ERR_TOT_RANGE: - fhGet4ChanErrors->Fill( dFullChId, 14); - break; - case get4v1x::GET4_V1X_ERR_EVT_DISCARD: - fhGet4ChanErrors->Fill( dFullChId, 15); - break; - case get4v1x::GET4_V1X_ERR_UNKNOWN: - fhGet4ChanErrors->Fill( dFullChId, 16); - break; - default: // Corrupt error or not yet supported error - fhGet4ChanErrors->Fill( dFullChId, 17); - break; - } // switch( mess.getGet4V10R32ErrorData() ) - break; - } // case get4v1x::GET4_32B_ERROR - case get4v1x::GET4_32B_DATA: // => Hit Data - { - UInt_t uFullChId = - get4v1x::kuChanPerGet4*( uChipFullId ) - + mess.getGet4V10R32HitChan(); - - // As long as the 1st epoch with sync flag after SYNC DLM is found, - // consider data as not good - if( kTRUE == fvbGet4WaitFirstSync[uChipFullId] ) - return; - - fvhRocDataCntEvo[cRocId]->Fill( - ( ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs - + mess.getGet4V10R32HitTimeBin() *get4v1x::kdBinSize ) - *(1e-12) ); // Time since start in s - fvhGet4DataCntEvo[uChipFullId]->Fill( - ( ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs - + mess.getGet4V10R32HitTimeBin() *get4v1x::kdBinSize ) - *(1e-12) ); // Time since start in s - fvhGet4ChDataCntEvo[uChipFullId]->Fill( mess.getGet4V10R32HitChan(), - ( ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs - + mess.getGet4V10R32HitTimeBin() *get4v1x::kdBinSize ) - *(1e-12) ); // Time since start in s - if( uChipFullId < kuNbTdcMappedDet ) - if( kiTdcDetMap[uChipFullId] < kiNbDet ) - fvhDetDataCntEvo[ kiTdcDetMap[uChipFullId] ]->Fill( - ( ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs - + mess.getGet4V10R32HitTimeBin() *get4v1x::kdBinSize ) - *(1e-12) ); // Time since start in s - - fhGet4ChanDataCount->Fill( uFullChId ); - fhGet4ChanDllStatus->Fill( uFullChId, mess.getGet4V10R32HitDllFlag() ); - fhGet4ChanTotMap->Fill( uFullChId, mess.getGet4V10R32HitTot() - *get4v1x::kdTotBinSize/1000.0 ); - - if( kTRUE == fbEnaCalibOutput ) - fvhFineTime[ uChipFullId ][ mess.getGet4V10R32HitChan() ]->Fill( mess.getGet4V10R32HitFt() ); - - if( kTRUE == fbPulserMode ) - { - // First fill time interval histos - if( fuPulserFee == (uFullChId/kuNbChanFee) ) - { - Double_t dHitsDt = mess.CalcGet4V10R32HitTimeDiff( - fvuCurrEpoch2[uChipFullId], - fvuLastHitEp[ uFullChId ], - fvmLastHit[ uFullChId ] ); - if( 0 == fvuLastHitEp[uFullChId]) - {} - else if( dHitsDt < 1e6 ) - fhPulserHitDistNs->Fill( uFullChId%kuNbChanFee, dHitsDt / 1e3 ); - else if( dHitsDt < 1e9) - fhPulserHitDistUs->Fill( uFullChId%kuNbChanFee, dHitsDt / 1e6 ); - else - fhPulserHitDistMs->Fill( uFullChId%kuNbChanFee, dHitsDt / 1e9 ); - - if( 0 < fvuLastHitEp[uFullChId] && dHitsDt < 5e3 ) - LOG(debug) <<uFullChId<<" "<<dHitsDt<<" " - <<fvuLastHitEp[ uFullChId ]<<" "<<fvuCurrEpoch2[uChipFullId]<<" " - <<fvmLastHit[ uFullChId ].getGet4V10R32HitTot()*get4v1x::kdTotBinSize/1000.0<<" " - <<mess.getGet4V10R32HitTot()*get4v1x::kdTotBinSize/1000.0;; - - // Fill the DNL histos - fhPulserFeeDnl->Fill( uFullChId%kuNbChanFee, mess.getGet4V10R32HitFt() ); - } // if( fuPulserFee == (uFullChId/kuNbChanFee) ) - } // if( kTRUE == fbPulserMode ) - - // Fill time coincidence map - for( UInt_t uFeeA = 0; uFeeA < fuNbFee; uFeeA++) - for( UInt_t uFeeChan = 0; uFeeChan < get4v1x::kuChanPerFee; uFeeChan++ ) - if( ( 0xF0 <= fvmLastHit[ uFeeA*get4v1x::kuChanPerFee + uFeeChan ].getSysMesType() ) && - ( fvuLastHitEp[ uFeeA*get4v1x::kuChanPerFee + uFeeChan/get4v1x::kuChanPerGet4 ] - < fvuCurrEpoch2[uChipFullId] + 2 ) && - ( fvuLastHitEp[ uFeeA*get4v1x::kuChanPerFee + uFeeChan/get4v1x::kuChanPerGet4 ] + 2 - > fvuCurrEpoch2[uChipFullId] ) ) - { - // compare to last hit in other channekl - Double_t dHitsDt = mess.CalcGet4V10R32HitTimeDiff( - fvuCurrEpoch2[uChipFullId], - fvuLastHitEp[ uFeeA*get4v1x::kuChanPerFee + uFeeChan/get4v1x::kuChanPerGet4 ], - fvmLastHit[ uFeeA*get4v1x::kuChanPerFee + uFeeChan ] ); - if( TMath::Abs(dHitsDt) < fdMaxCoincDist ) - { - if( uFeeA*get4v1x::kuChanPerFee + uFeeChan < uFullChId ) - fvvhChannelsCoinc[uFeeA][uFullChId/get4v1x::kuChanPerFee]->Fill( - uFeeChan, uFullChId%get4v1x::kuChanPerFee); - else fvvhChannelsCoinc[uFullChId/get4v1x::kuChanPerFee][uFeeA]->Fill( - uFullChId%get4v1x::kuChanPerFee, uFeeChan); - } // if( TMath::Abs(dHitsDt) < fdMaxCoincDist ) - } // for each pair, if both hits valid - - // Multiple hits (reflections, ...) detection - if( 1 == fiMode) - { - Double_t dHitsDt = mess.CalcGet4V10R32HitTimeDiff( - fvuCurrEpoch2[uChipFullId], - fvuLastHitEp[ uFullChId ], - fvmLastHit[ uFullChId ] ); - if( dHitsDt < fdMaxDtMultiHit ) - { - if( kFALSE == fvbChanSecondHit[uChipFullId][mess.getGet4V10R32HitChan()] ) - { - fvhGet4MultipleHits[uChipFullId]->Fill( mess.getGet4V10R32HitChan(), 2); - fvhGet4DistDoubleHits[uChipFullId]->Fill( mess.getGet4V10R32HitChan(), dHitsDt); - fvbChanSecondHit[uChipFullId][mess.getGet4V10R32HitChan()] = kTRUE; - - fvhGet4MultipleHitsVsTot[uChipFullId]->Fill( - fvdChanFirstHitTot[uChipFullId][mess.getGet4ChNum()], 2); - } - else if ( kFALSE == fvbChanThirdHit[uChipFullId][mess.getGet4V10R32HitChan()] ) - { - fvhGet4MultipleHits[uChipFullId]->Fill( mess.getGet4V10R32HitChan(), 3); - fvhGet4DistTripleHits[uChipFullId]->Fill( mess.getGet4V10R32HitChan(), dHitsDt); - fvbChanThirdHit[uChipFullId][mess.getGet4V10R32HitChan()] = kTRUE; - - fvhGet4MultipleHitsVsTot[uChipFullId]->Fill( - fvdChanFirstHitTot[uChipFullId][mess.getGet4ChNum()], 3); - } - else - { - fvhGet4MultipleHits[uChipFullId]->Fill( mess.getGet4V10R32HitChan(), 4); - fvhGet4DistMultipleHits[uChipFullId]->Fill( mess.getGet4V10R32HitChan(), dHitsDt); - - fvhGet4MultipleHitsVsTot[uChipFullId]->Fill( - fvdChanFirstHitTot[uChipFullId][mess.getGet4ChNum()], 4); - } - } // if( dHitsDt < fdMaxDtMultiHit ) - else - { - fvhGet4MultipleHits[uChipFullId]->Fill( mess.getGet4V10R32HitChan(), 1); - fvbChanSecondHit[uChipFullId][mess.getGet4V10R32HitChan()] = kFALSE; - fvbChanThirdHit[uChipFullId][mess.getGet4V10R32HitChan()] = kFALSE; - - fvdChanFirstHitTot[uChipFullId][mess.getGet4ChNum()] = - mess.getGet4V10R32HitTot() * get4v1x::kdTotBinSize/1000.0; - fvhGet4MultipleHitsVsTot[uChipFullId]->Fill( - fvdChanFirstHitTot[uChipFullId][mess.getGet4ChNum()], 1); - } // else of if( dHitsDt < fdMaxDtMultiHit ) - } // if( 1 == fiMode) - - // Save the hit info in order to fill later the histos - // Epoch of Last hit message (one per GET4 chip & channel) - fvuLastHitEp[ uFullChId ] = fvuCurrEpoch2[uChipFullId]; - // Last hit message (one per GET4 chip & channel) - fvmLastHit[ uFullChId ] = mess; - - break; - } // case get4v1x::GET4_32B_DATA - } // switch( cMessType ) - -} -*/ -//**********************************************/ - -//************ Processing functions ************/ -void CbmTSUnpackGet4v1x::ProcessMessage_epoch( get4v1x::Message mess, uint16_t EqID) -{ - // ROC epoch message: 250 MHz clock for now - // TODO: check compatibility when ROC clock changed to 200 MHz - uint8_t cRocId = mess.getRocNumber(); - LOG(debug3)<<"CbmTSUnpackGet4v1x::MonitorMessage_epoch => ROC Epoch: EqId " - <<EqID<<" roc " - <<cRocId; - - // Epoch counter overflow book keeping - if( (get4v1x::kulMainEpochCycleSz - 2) < fvuCurrEpoch[cRocId] && - mess.getEpochNumber() < 2 ) - fvuCurrEpochCycle[cRocId]++; - - fvuCurrEpoch[cRocId] = mess.getEpochNumber(); -} -void CbmTSUnpackGet4v1x::ProcessMessage_sync( get4v1x::Message mess, uint16_t EqID) -{ - // ROC sync message: TS in 250 MHz clock for now - // TODO: check compatibility when ROC clock changed to 200 MHz - uint8_t cRocId = mess.getRocNumber(); - fhRocSyncTypePerRoc->Fill( cRocId, mess.getSyncChNum() ); - - LOG(debug3)<<"CbmTSUnpackGet4v1x::MonitorMessage_sync => ROC Sync: EqId " - <<EqID<<" roc " - <<cRocId; -} -void CbmTSUnpackGet4v1x::ProcessMessage_aux( get4v1x::Message mess, uint16_t EqID) -{ - // ROC aux message: TS in 250 MHz clock for now - // TODO: check compatibility when ROC clock changed to 200 MHz - uint8_t cRocId = mess.getRocNumber(); - fhRocSyncTypePerRoc->Fill( cRocId, mess.getSyncChNum() ); - - LOG(debug3)<<"CbmTSUnpackGet4v1x::MonitorMessage_aux => ROC Aux: EqId " - <<EqID<<" roc " - <<cRocId; -} -void CbmTSUnpackGet4v1x::ProcessMessage_epoch2( get4v1x::Message mess, uint16_t EqID) -{ - // GET4 v1.x epoch message (24b only for now) - // TODO: check compatibility when 32b format without hack ready - uint8_t cRocId = mess.getRocNumber(); - uint8_t cChipId = mess.getEpoch2ChipNumber(); - uint32_t uChipFullId = cChipId + get4v1x::kuMaxGet4PerRoc*cRocId; - - if( kTRUE == fbVerbose ) - LOG(info)<<"CbmTSUnpackGet4v1x::ProcessMessage_epoch2 => Found a GET4 24b message: ignore it"; - - LOG(debug3)<<"CbmTSUnpackGet4v1x::MonitorMessage_epoch2 => GET4 Epoch2: EqId " - <<EqID<<" roc " - <<cRocId; - - // Reject data of chips above defined limit to avoid overflow/seg fault - if( fuNbGet4 <= uChipFullId ) - { - if( kTRUE == fbVerbose ) - LOG(info)<<"CbmTSUnpackGet4v1x::MonitorMessage_epoch2 => Ignored message with ChipId above limit!" - <<" ChipId: "<<cChipId - <<" RocId: " <<cRocId - <<" Limit: " <<fuNbGet4; - return; - } // if( fuNbGet4 <= cChipId + kuMaxGet4PerRoc*mess.getRocNumber() ) - - // Reject data of Inactive chips - if( kFALSE == fvbActiveChips[uChipFullId]) - { - if( kTRUE == fbVerbose ) - LOG(info)<<"CbmTSUnpackGet4v1x::MonitorMessage_epoch2 => Ignored message with Inactive Chip!" - <<" ChipId: "<<cChipId - <<" RocId: " <<cRocId; - return; - } // if( kFALSE == fvbActiveChips[uChipFullId]) - - // As long as the 1st epoch with sync flag after SYNC DLM is found, - // consider data as not good - if( kTRUE == fvbGet4WaitFirstSync[uChipFullId] ) - { - if( 1 == mess.getEpoch2Sync() ) - { - fvbGet4WaitFirstSync[uChipFullId] = kFALSE; - - LOG(info) << "First SYNC Epoch after DLM in chip " - <<Form("%3u: ", uChipFullId) - <<Form(" EP #%6u", mess.getEpoch2Number() ) - <<Form(" TS #%12llu", fulTsNb) - <<Form(" MS #%5llu/%5lu", fulMsNb, static_cast<ULong_t>(fsMaxMsNb) ) - <<Form(" OF #%5u/%5u", fuOffset, fuMaxOffset) - <<Form(" LO #%5u/%5u", fuLocalOffset, fuMaxLocalOffset); - } // if( 1 == mess.getEpoch2Sync() ) - else return; - } // if( kTRUE == fvbGet4WaitFirstSync[uChipFullId] ) - - // Count epoch messages per chip - fhMessTypePerGet4->Fill( uChipFullId, get4v1x::GET4_32B_EPOCH); - - if( fvuCurrEpoch2[uChipFullId] +1 != mess.getEpoch2Number() && - 0 != fvuCurrEpoch2[uChipFullId] ) - { - Int_t iEpJump = mess.getEpoch2Number(); - iEpJump -= fvuCurrEpoch2[uChipFullId]; - LOG(info) << "Epoch nb jump in chip " - <<Form("%3u: ", uChipFullId) - << Form(" %3d (%6u -> %6u)", iEpJump, fvuCurrEpoch2[uChipFullId], - mess.getEpoch2Number() ) - <<Form(" TS #%12llu", fulTsNb) - <<Form(" MS #%5llu/%5lu", fulMsNb, static_cast<ULong_t>(fsMaxMsNb) ) - <<Form(" OF #%5u/%5u", fuOffset, fuMaxOffset) - <<Form(" LO #%5u/%5u", fuLocalOffset, fuMaxLocalOffset); - - fhGet4EpochJumps->Fill(uChipFullId, iEpJump); - } // if( fvuCurrEpoch2[uChipFullId] +1 != mess.getGet4V10R32EpochNumber()) - - // Epoch counter overflow book keeping - if( (get4v1x::kul24bGet4EpochCycleSz - 2) < fvuCurrEpoch2[uChipFullId] && - mess.getEpoch2Number() < 2 ) - fvuCurrEpoch2Cycle[uChipFullId]++; - - fvuCurrEpoch2[uChipFullId] = mess.getEpoch2Number(); - - // Monitoring of data Time evolution - fvhRocEpochCntEvo[cRocId]->Fill( - ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs*(1e-12) ); // Time since start in s -/* - fvhGet4EpochCntEvo[uChipFullId]->Fill( - ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs*(1e-12) ); // Time since start in s - if( uChipFullId < kuNbTdcMappedDet ) - if( kiTdcDetMap[uChipFullId] < kiNbDet ) - fvhDetEpochCntEvo[ kiTdcDetMap[uChipFullId] ]->Fill( - ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs*(1e-12) ); // Time since start in s -*/ - if( 1 == mess.getEpoch2Sync() ) - { - fhGet4EpochFlags->Fill(uChipFullId, 0); - fhGet4EpochSyncDist->Fill( uChipFullId, fvuCurrEpoch2[uChipFullId] % get4v1x::kuSyncCycleSzGet4 ); - } // if( 1 == mess.getEpoch2Sync() ) - - if( 1 == mess.getEpoch2EpochMissmatch() ) - { - fhGet4EpochFlags->Fill(uChipFullId, 1); - LOG(info) << "Epoch missmatch in chip " - <<Form("%3u: ", uChipFullId) - <<Form(" EP #%6u", mess.getEpoch2Number() ) - <<Form(" TS #%12llu", fulTsNb) - <<Form(" MS #%5llu/%5lu", fulMsNb, static_cast<ULong_t>(fsMaxMsNb) ) - <<Form(" OF #%5u/%5u", fuOffset, fuMaxOffset) - <<Form(" LO #%5u/%5u", fuLocalOffset, fuMaxLocalOffset); - } // if( 1 == mess.getEpoch2EpochMissmatch() ) - if( 1 == mess.getEpoch2EpochLost() ) - { - fhGet4EpochFlags->Fill(uChipFullId, 2); - LOG(info) << "Epoch loss in chip " - <<Form("%3u: ", uChipFullId) - <<Form(" EP #%6u", mess.getEpoch2Number() ) - <<Form(" TS #%12llu", fulTsNb) - <<Form(" MS #%5llu/%5lu", fulMsNb, static_cast<ULong_t>(fsMaxMsNb) ) - <<Form(" OF #%5u/%5u", fuOffset, fuMaxOffset) - <<Form(" LO #%5u/%5u", fuLocalOffset, fuMaxLocalOffset); - - fvhRocEpochLossCntEvo[cRocId]->Fill( - ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs*(1e-12) ); // Time since start in s - fvhGet4EpochLossCntEvo[uChipFullId]->Fill( - ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs*(1e-12) ); // Time since start in s - if( uChipFullId < kuNbTdcMappedDet ) - if( kiTdcDetMap[uChipFullId] < kiNbDet ) - fvhDetEpochLossCntEvo[ kiTdcDetMap[uChipFullId] ]->Fill( - ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs*(1e-12) ); // Time since start in s - } // if( 1 == mess.getEpoch2EpochLost() ) - if( 1 == mess.getEpoch2DataLost() ) - { - fhGet4EpochFlags->Fill(uChipFullId, 3); - LOG(info) << "Data Loss in chip " - <<Form("%3u: ", uChipFullId) - <<Form(" EP #%6u", mess.getEpoch2Number() ) - <<Form(" TS #%12llu", fulTsNb) - <<Form(" MS #%5llu/%5lu", fulMsNb, static_cast<ULong_t>(fsMaxMsNb) ) - <<Form(" OF #%5u/%5u", fuOffset, fuMaxOffset) - <<Form(" LO #%5u/%5u", fuLocalOffset, fuMaxLocalOffset); - - fvhRocDataLossCntEvo[cRocId]->Fill( - ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs*(1e-12) ); // Time since start in s - fvhGet4DataLossCntEvo[uChipFullId]->Fill( - ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs*(1e-12) ); // Time since start in s - if( uChipFullId < kuNbTdcMappedDet ) - if( kiTdcDetMap[uChipFullId] < kiNbDet ) - fvhDetDataLossCntEvo[ kiTdcDetMap[uChipFullId] ]->Fill( - ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs*(1e-12) ); // Time since start in s - } // if( 1 == mess.getEpoch2DataLost() ) - - // TODO: real processing ? - // For now do nothing to go faster -} -void CbmTSUnpackGet4v1x::ProcessMessage_get4( get4v1x::Message mess, uint16_t EqID) -{ - // GET4 v1.x data message (24b only for now) - // TODO: check compatibility when 32b format without hack ready - uint8_t cRocId = mess.getRocNumber(); - if( kTRUE == fbVerbose ) - LOG(debug)<<"CbmTSUnpackGet4v1x::ProcessMessage_get4 => Found a GET4 24b message: ignore it"; - - LOG(debug3)<<"CbmTSUnpackGet4v1x::MonitorMessage_get4 => GET4 Data: EqId " - <<EqID<<" roc " - <<cRocId; - - uint8_t cChipId = mess.getGet4Number(); - UInt_t uChipFullId = cChipId + get4v1x::kuMaxGet4PerRoc*cRocId; -/* UInt_t uFullChId = - get4v1x::kuChanPerGet4*( uChipFullId ) - + mess.getGet4ChNum();*/ - UInt_t uTimeStamp = mess.getGet4Ts(); - - // Reject data of chips above defined limit to avoid overflow/seg fault - if( fuNbGet4 <= uChipFullId ) - { - if( kTRUE == fbVerbose ) - LOG(info)<<"CbmTSUnpackGet4v1x::MonitorMessage_get4 => Ignored message with ChipId above limit!" - <<" ChipId: "<<cChipId - <<" RocId: " <<cRocId - <<" Limit: " <<fuNbGet4; - return; - } // if( fuNbGet4 <= cChipId + kuMaxGet4PerRoc*mess.getRocNumber() ) - - // Reject data of Inactive chips - if( kFALSE == fvbActiveChips[uChipFullId]) - { - if( kTRUE == fbVerbose ) - LOG(info)<<"CbmTSUnpackGet4v1x::MonitorMessage_get4 => Ignored message with Inactive Chip!" - <<" ChipId: "<<cChipId - <<" RocId: " <<cRocId; - return; - } // if( kFALSE == fvbActiveChips[uChipFullId]) - - // As long as the 1st epoch with sync flag after SYNC DLM is found, - // consider data as not good - if( kTRUE == fvbGet4WaitFirstSync[uChipFullId] ) - return; - - fvhRocDataCntEvo[cRocId]->Fill( - ( ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs - + uTimeStamp*get4v1x::kdBinSize ) - *(1e-12) ); // Time since start in s - fvhGet4DataCntEvo[uChipFullId]->Fill( - ( ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs - + uTimeStamp*get4v1x::kdBinSize ) - *(1e-12) ); // Time since start in s - fvhGet4ChDataCntEvo[uChipFullId]->Fill( mess.getGet4ChNum(), - ( ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs - + uTimeStamp*get4v1x::kdBinSize ) - *(1e-12) ); // Time since start in s - if( uChipFullId < kuNbTdcMappedDet ) - if( kiTdcDetMap[uChipFullId] < kiNbDet ) - fvhDetDataCntEvo[ kiTdcDetMap[uChipFullId] ]->Fill( - ( ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs - + uTimeStamp*get4v1x::kdBinSize ) - *(1e-12) ); // Time since start in s - - // Count data messages per chip - fhMessTypePerGet4->Fill( uChipFullId, get4v1x::GET4_32B_DATA); - - if( kTRUE == fbEnaCalibOutput ) - fvhFineTime[ uChipFullId ][ mess.getGet4ChNum() ]->Fill( mess.getGet4FineTs() ); - - // TODO: real processing ? - // For now do nothing to go faster -} -void CbmTSUnpackGet4v1x::ProcessMessage_sys( get4v1x::Message mess, uint16_t EqID) -{ - uint8_t cRocId = mess.getRocNumber(); - LOG(debug3)<<"CbmTSUnpackGet4v1x::MonitorMessage_sys => System message: EqId " - <<EqID<<" roc " - <<cRocId; - - if( mess.getSysMesType() < get4v1x::SYSMSG_GET4V1_32BIT_0 ) - fhSysMessTypePerRoc->Fill( cRocId, mess.getSysMesType() ); - - switch( mess.getSysMesType() ) - { - case get4v1x::SYSMSG_DAQ_START: - { - break; - } // case get4v1x::SYSMSG_DAQ_START - case get4v1x::SYSMSG_DAQ_FINISH: - { - break; - } // case get4v1x::SYSMSG_DAQ_FINISH - case get4v1x::SYSMSG_NX_PARITY: - case get4v1x::SYSMSG_ADC: - case get4v1x::SYSMSG_PCTIME: - { - // NXYTER related => don't care in this unpacker - break; - } // case get4v1x::SYSMSG_NX_PARITY - case get4v1x::SYSMSG_SYNC_PARITY: - { - break; - } // case get4v1x::SYSMSG_SYNC_PARITY - case get4v1x::SYSMSG_DAQ_RESUME: - { - break; - } // case get4v1x::SYSMSG_DAQ_RESUME - case get4v1x::SYSMSG_FIFO_RESET: - { - break; - } // case get4v1x::SYSMSG_FIFO_RESET - case get4v1x::SYSMSG_USER: - { - if( get4v1x::SYSMSG_USER_ROCFEET_SYNC == mess.getSysMesData() ) - { - LOG(info)<<"CbmTSUnpackGet4v1x::MonitorMessage_sys => SYNC DLM!" - <<" RocId: " << Form("%02u", cRocId) - <<Form(" TS #%12llu", fulTsNb) - <<Form(" MS #%5llu/%5lu", fulMsNb, static_cast<ULong_t>(fsMaxMsNb)) - <<Form(" OF #%5u/%5u", fuOffset, fuMaxOffset) - <<Form(" LO #%5u/%5u", fuLocalOffset, fuMaxLocalOffset); - fvbRocFeetSyncStart[cRocId] = kTRUE; - } // if( get4v1x::SYSMSG_USER_ROCFEET_SYNC == mess.getSysMesData() ) - break; - } // case get4v1x::SYSMSG_USER - case get4v1x::SYSMSG_PACKETLOST: - { - break; - } // case get4v1x::SYSMSG_PACKETLOST - case get4v1x::SYSMSG_GET4_EVENT: - { - // GET4 v1.x error message (24b only for now) - // TODO: check compatibility when 32b format without hack ready - uint8_t cChipId = mess.getGet4V10R24ErrorChip(); - uint32_t uChipFullId = cChipId + get4v1x::kuMaxGet4PerRoc*cRocId; - uint8_t uErrorType= mess.getGet4V10R24ErrorData(); - - // Count error messages per ROC - fvhRocErrorCntEvo[cRocId]->Fill( - ( ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs ) - *(1e-12) ); // Time since start in s - - // Count error messages per chip - fhMessTypePerGet4->Fill( uChipFullId, get4v1x::GET4_32B_ERROR); - fvhGet4ErrorCntEvo[uChipFullId]->Fill( - ( ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs) - *(1e-12) ); // Time since start in s - - if( ( get4v1x::GET4_V1X_ERR_EP < uErrorType && - uErrorType < get4v1x::GET4_V1X_ERR_TOK_RING_ST ) ) - fvhGet4ChErrorCntEvo[uChipFullId]->Fill( mess.getGet4V10R24ErrorChan(), - ( ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs) - *(1e-12) ); // Time since start in s - - if( uChipFullId < kuNbTdcMappedDet ) - if( kiTdcDetMap[uChipFullId] < kiNbDet ) - fvhDetErrorCntEvo[ kiTdcDetMap[uChipFullId] ]->Fill( - ( ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs) - *(1e-12) ); // Time since start in s - break; - } // case get4v1x::SYSMSG_GET4_EVENT - case get4v1x::SYSMSG_CLOSYSYNC_ERROR: - { - // GET4 v1.x error message (24b only for now) - // TODO: check compatibility when 32b format without hack ready - break; - } // case get4v1x::SYSMSG_CLOSYSYNC_ERROR - case get4v1x::SYSMSG_TS156_SYNC: - { - break; - } // case get4v1x::SYSMSG_TS156_SYNC - case get4v1x::SYSMSG_GET4V1_32BIT_0: - case get4v1x::SYSMSG_GET4V1_32BIT_1: - case get4v1x::SYSMSG_GET4V1_32BIT_2: - case get4v1x::SYSMSG_GET4V1_32BIT_3: - case get4v1x::SYSMSG_GET4V1_32BIT_4: - case get4v1x::SYSMSG_GET4V1_32BIT_5: - case get4v1x::SYSMSG_GET4V1_32BIT_6: - case get4v1x::SYSMSG_GET4V1_32BIT_7: - case get4v1x::SYSMSG_GET4V1_32BIT_8: - case get4v1x::SYSMSG_GET4V1_32BIT_9: - case get4v1x::SYSMSG_GET4V1_32BIT_10: - case get4v1x::SYSMSG_GET4V1_32BIT_11: - case get4v1x::SYSMSG_GET4V1_32BIT_12: - case get4v1x::SYSMSG_GET4V1_32BIT_13: - case get4v1x::SYSMSG_GET4V1_32BIT_14: - case get4v1x::SYSMSG_GET4V1_32BIT_15: - { - // Ignore all messages before RocFeet system SYNC - if (kFALSE == fvbRocFeetSyncStart[cRocId] ) - break; - - // GET4 v1.x 32b raw message using hack - fhMessageTypePerRoc->Fill( cRocId, 15 ); - fhSysMessTypePerRoc->Fill( cRocId, 15 ); - - ProcessMessage_Get4v1( mess, EqID); - break; - } // case get4v1x::SYSMSG_TS156_SYNC - default: - { - if( kTRUE == fbVerbose ) - LOG(warning)<<"CbmTSUnpackGet4v1x::ProcessMessage_sys => Unknown sysMess type ignored: " - <<mess.getSysMesType(); - break; - } // default: - } // switch( mess.getSysMesType() ) -} -void CbmTSUnpackGet4v1x::ProcessMessage_Get4v1( get4v1x::Message mess, uint16_t EqID) -{ - // GET4 v1.x 32b raw message using hack - uint8_t cRocId = mess.getRocNumber(); - uint8_t cChipId = mess.getGet4V10R32ChipId(); - uint32_t uChipFullId = cChipId + get4v1x::kuMaxGet4PerRoc*cRocId; - uint8_t cMessType = mess.getGet4V10R32MessageType(); - - LOG(debug3)<<"CbmTSUnpackGet4v1x::ProcessMessage_Get4v1 => 32b GET4 message: EqId " - <<EqID<<" roc " - <<cRocId; - - // Reject data of chips above defined limit to avoid overflow/seg fault - if( fuNbGet4 <= uChipFullId ) - { - if( kTRUE == fbVerbose ) - LOG(info)<<"CbmTSUnpackGet4v1x::ProcessMessage_Get4v1 => Ignored message with ChipId above limit!" - <<" ChipId: "<<cChipId - <<" RocId: " <<cRocId - <<" Limit: " <<fuNbGet4; - return; - } // if( fuNbGet4 <= cChipId + kuMaxGet4PerRoc*mess.getRocNumber() ) - - // Reject data of Inactive chips - if( kFALSE == fvbActiveChips[uChipFullId]) - { - if( kTRUE == fbVerbose ) - LOG(info)<<"CbmTSUnpackGet4v1x::ProcessMessage_Get4v1 => Ignored message with Inactive Chip!" - <<" ChipId: "<<cChipId - <<" RocId: " <<cRocId; - return; - } // if( kFALSE == fvbActiveChips[uChipFullId]) - - // Count epoch messages per chip - fhMessTypePerGet4->Fill( uChipFullId, cMessType); - - switch( cMessType ) - { - case get4v1x::GET4_32B_EPOCH: // => Epoch message - { - - // As long as the 1st epoch with sync flag after SYNC DLM is found, - // consider data as not good - if( kTRUE == fvbGet4WaitFirstSync[uChipFullId] ) - { - if( 1 == mess.getGet4V10R32SyncFlag() ) - { - fvbGet4WaitFirstSync[uChipFullId] = kFALSE; - - LOG(info) << "First SYNC Epoch after DLM in chip " - <<Form("%3u: ", uChipFullId) - <<Form(" EP #%6u", mess.getGet4V10R32EpochNumber() ) - <<Form(" TS #%12llu", fulTsNb) - <<Form(" MS #%5llu/%5lu", fulMsNb, static_cast<ULong_t>(fsMaxMsNb)) - <<Form(" OF #%5u/%5u", fuOffset, fuMaxOffset) - <<Form(" LO #%5u/%5u", fuLocalOffset, fuMaxLocalOffset); - } // if( 1 == mess.getGet4V10R32SyncFlag() ) - else return; - } // if( kTRUE == fvbGet4WaitFirstSync[uChipFullId] ) - - if( fvuCurrEpoch2[uChipFullId] +1 != mess.getGet4V10R32EpochNumber() && - 0 != fvuCurrEpoch2[uChipFullId] ) - { - Int_t iEpJump = mess.getGet4V10R32EpochNumber(); - iEpJump -= fvuCurrEpoch2[uChipFullId]; - LOG(debug) << "Epoch nb jump in chip " - <<Form("%3u: ", uChipFullId) - << Form(" %3d (%6u -> %6u)", iEpJump, fvuCurrEpoch2[uChipFullId], - mess.getGet4V10R32EpochNumber() ) - <<Form(" TS #%12llu", fulTsNb) - <<Form(" MS #%5llu/%5lu", fulMsNb, static_cast<ULong_t>(fsMaxMsNb)) - <<Form(" OF #%5u/%5u", fuOffset, fuMaxOffset) - <<Form(" LO #%5u/%5u", fuLocalOffset, fuMaxLocalOffset); - - fhGet4EpochJumps->Fill(uChipFullId, iEpJump); - } // if( fvuCurrEpoch2[uChipFullId] +1 != mess.getGet4V10R32EpochNumber()) - - // Epoch counter overflow book keeping - if( (get4v1x::kulGet4EpochCycleSz - 2) < fvuCurrEpoch2[uChipFullId] && - mess.getEpoch2Number() < 2 ) - fvuCurrEpoch2Cycle[uChipFullId]++; - - fvuCurrEpoch2[uChipFullId] = mess.getGet4V10R32EpochNumber(); - - fvhRocEpochCntEvo[cRocId]->Fill( - ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs*(1e-12) ); // Time since start in s - - if( 1 == mess.getGet4V10R32SyncFlag() ) - { - fhGet4EpochFlags->Fill(uChipFullId , 0); - fhGet4EpochSyncDist->Fill( uChipFullId, fvuCurrEpoch2[uChipFullId] % get4v1x::kuSyncCycleSzGet4 ); - } // if( 1 == mess.getGet4V10R32SyncFlag() ) - - // Check other active chips current epoch and close all epochs which all chips passed - fvuCurrEpochBuffer[uChipFullId] = static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24); - ULong64_t uLowerCurrentReadyEp = fvuCurrEpochBuffer[uChipFullId]; -// LOG(debug2)<<"CbmTSUnpackGet4v1x::MonitorMessage_Get4v1 => Check close " -// << uLowerCurrentReadyEp << " => "; - for( UInt_t uChipScan = 0; uChipScan < fuNbGet4; uChipScan++) - { -// LOG(debug2)<<"( "<<fvbActiveChips[uChipScan]<<", "<<fvuCurrEpochBuffer[uChipScan]<<") "; - if( kTRUE == fvbActiveChips[uChipScan] && - fvuCurrEpochBuffer[uChipScan] < uLowerCurrentReadyEp ) - uLowerCurrentReadyEp = fvuCurrEpochBuffer[uChipScan]; - } // for( UInt_t uChipScan = 0; uChipScan < fuNbGet4; uChipScan++) - - // - -// LOG(info)<<" => ( "<<fuLastEpBufferReady<<", "<<uLowerCurrentReadyEp<<") "; - - // The map is ordered so we can just loop over - if( fuLastEpBufferReady < uLowerCurrentReadyEp ) - { -// for( std::map<ULong64_t, Bool_t>::iterator it= fmsOrderedEpochsBuffStat.find(fuLastEpBufferReady); - // Check to avoid starting at an entry already removed in previous loops - auto it_Start = fmsOrderedEpochsBuffStat.find(fuLastEpBufferReady); - if( fmsOrderedEpochsBuffStat.end() == it_Start ) - it_Start = fmsOrderedEpochsBuffStat.begin(); - - for( auto it= it_Start; - it!=fmsOrderedEpochsBuffStat.find(uLowerCurrentReadyEp); - ++it) - it->second = kTRUE; - auto it = fmsOrderedEpochsBuffStat.find(uLowerCurrentReadyEp); - --it; // Go back to previous element - fuLastEpBufferReady = it->first; - } - - // Start new buffer for this epoch if it does not already exist - if( fmsOrderedEpochsData.end() == fmsOrderedEpochsData.find(fvuCurrEpochBuffer[uChipFullId]) ) - { - // new entry in map with empty multiset -/* - fmsOrderedEpochsData.insert( fmsOrderedEpochsData.end(), - std::pair< ULong64_t, std::multiset< get4v1x::FullMessage > >( - fvuCurrEpochBuffer[uChipFullId], - std::multiset< get4v1x::FullMessage >() ) ); -*/ - std::multiset< get4v1x::FullMessage > * newEpochBuff = new std::multiset< get4v1x::FullMessage >(); - fmsOrderedEpochsData.insert( fmsOrderedEpochsData.end(), - std::pair< ULong64_t, std::multiset< get4v1x::FullMessage >* >( - fvuCurrEpochBuffer[uChipFullId], newEpochBuff) ); - - // new entry in map with kFALSE flag - fmsOrderedEpochsBuffStat.insert( fmsOrderedEpochsBuffStat.end(), - std::pair<ULong64_t, Bool_t>(fvuCurrEpochBuffer[uChipFullId], kFALSE) ); - } // if( fmsOrderedEpochsData.end() == fmsOrderedEpochsData.find(fvuCurrEpochBuffer[uChipFullId]) ) - - fvuCurrEpochBufferIt[uChipFullId] = fmsOrderedEpochsData.find(fvuCurrEpochBuffer[uChipFullId]); - - break; - } // case get4v1x::GET4_32B_EPOCH - case get4v1x::GET4_32B_SLCM: // => Slow control - { - Double_t dFullChId = - get4v1x::kuChanPerGet4*2*( uChipFullId ) - + mess.getGet4V10R32SlChan() - + 0.5*mess.getGet4V10R32SlEdge(); - - // As long as the 1st epoch with sync flag after SYNC DLM is found, - // consider data as not good - if( kTRUE == fvbGet4WaitFirstSync[uChipFullId] ) - return; - - fhGet4ChanSlowContM->Fill( dFullChId, mess.getGet4V10R32SlType() ); - break; - } // case get4v1x::GET4_32B_SLCM - case get4v1x::GET4_32B_ERROR: // => Error message - { - Double_t dFullChId = - get4v1x::kuChanPerGet4*2*( uChipFullId ) - + mess.getGet4V10R32ErrorChan() - + 0.5*mess.getGet4V10R32ErrorEdge(); - UInt_t uErrorType = mess.getGet4V10R32ErrorData(); - - // As long as the 1st epoch with sync flag after SYNC DLM is found, - // consider data as not good - if( kTRUE == fvbGet4WaitFirstSync[uChipFullId] ) - return; - - // Count error messages per ROC - fvhRocErrorCntEvo[cRocId]->Fill( - ( ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs ) - *(1e-12) ); // Time since start in s - - fvhGet4ErrorCntEvo[uChipFullId]->Fill( - ( ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs) - *(1e-12) ); // Time since start in s - - if( ( get4v1x::GET4_V1X_ERR_EP < uErrorType && - uErrorType < get4v1x::GET4_V1X_ERR_TOK_RING_ST ) || - get4v1x::GET4_V1X_ERR_TOT_OVERWRT == uErrorType || - get4v1x::GET4_V1X_ERR_TOT_RANGE == uErrorType ) - fvhGet4ChErrorCntEvo[uChipFullId]->Fill( mess.getGet4V10R32ErrorChan(), - ( ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs) - *(1e-12) ); // Time since start in s - - if( uChipFullId < kuNbTdcMappedDet ) - if( kiTdcDetMap[uChipFullId] < kiNbDet ) - fvhDetErrorCntEvo[ kiTdcDetMap[uChipFullId] ]->Fill( - ( ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs) - *(1e-12) ); // Time since start in s - - switch( uErrorType ) - { - case get4v1x::GET4_V1X_ERR_READ_INIT: - fhGet4ChanErrors->Fill( dFullChId, 0); - LOG(debug)<<"CbmTSUnpackGet4v1x::MonitorMessage_Get4v1 => Readout Init!" - <<" ChipId: "<<Form("%02u", cChipId) - <<" RocId: " <<Form("%02u", cRocId) - <<" TS: " <<fulTsNb; - break; - case get4v1x::GET4_V1X_ERR_SYNC: - fhGet4ChanErrors->Fill( dFullChId, 1); - break; - case get4v1x::GET4_V1X_ERR_EP_CNT_SYNC: - fhGet4ChanErrors->Fill( dFullChId, 2); - break; - case get4v1x::GET4_V1X_ERR_EP: - fhGet4ChanErrors->Fill( dFullChId, 3); - break; - case get4v1x::GET4_V1X_ERR_FIFO_WRITE: - fhGet4ChanErrors->Fill( dFullChId, 4); - break; - case get4v1x::GET4_V1X_ERR_LOST_EVT: - fhGet4ChanErrors->Fill( dFullChId, 5); - break; - case get4v1x::GET4_V1X_ERR_CHAN_STATE: - fhGet4ChanErrors->Fill( dFullChId, 6); - break; - case get4v1x::GET4_V1X_ERR_TOK_RING_ST: - fhGet4ChanErrors->Fill( dFullChId, 7); - break; - case get4v1x::GET4_V1X_ERR_TOKEN: - fhGet4ChanErrors->Fill( dFullChId, 8); - break; - case get4v1x::GET4_V1X_ERR_READOUT_ERR: - fhGet4ChanErrors->Fill( dFullChId, 9); - break; - case get4v1x::GET4_V1X_ERR_SPI: - fhGet4ChanErrors->Fill( dFullChId, 10); - break; - case get4v1x::GET4_V1X_ERR_DLL_LOCK: - fhGet4ChanErrors->Fill( dFullChId, 11); - break; - case get4v1x::GET4_V1X_ERR_DLL_RESET: - fhGet4ChanErrors->Fill( dFullChId, 12); - break; - case get4v1x::GET4_V1X_ERR_TOT_OVERWRT: - fhGet4ChanErrors->Fill( dFullChId, 13); - break; - case get4v1x::GET4_V1X_ERR_TOT_RANGE: - fhGet4ChanErrors->Fill( dFullChId, 14); - break; - case get4v1x::GET4_V1X_ERR_EVT_DISCARD: - fhGet4ChanErrors->Fill( dFullChId, 15); - break; - case get4v1x::GET4_V1X_ERR_UNKNOWN: - fhGet4ChanErrors->Fill( dFullChId, 16); - break; - default: // Corrupt error or not yet supported error - fhGet4ChanErrors->Fill( dFullChId, 17); - break; - } // switch( mess.getGet4V10R32ErrorData() ) - break; - } // case get4v1x::GET4_32B_ERROR - case get4v1x::GET4_32B_DATA: // => Hit Data - { - UInt_t uFullChId = - get4v1x::kuChanPerGet4*( uChipFullId ) - + mess.getGet4V10R32HitChan(); - - // As long as the 1st epoch with sync flag after SYNC DLM is found, - // consider data as not good - if( kTRUE == fvbGet4WaitFirstSync[uChipFullId] ) - return; - - fvhRocDataCntEvo[cRocId]->Fill( - ( ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs - + mess.getGet4V10R32HitTimeBin() *get4v1x::kdBinSize ) - *(1e-12) ); // Time since start in s - fvhGet4DataCntEvo[uChipFullId]->Fill( - ( ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs - + mess.getGet4V10R32HitTimeBin() *get4v1x::kdBinSize ) - *(1e-12) ); // Time since start in s - fvhGet4ChDataCntEvo[uChipFullId]->Fill( mess.getGet4V10R32HitChan(), - ( ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs - + mess.getGet4V10R32HitTimeBin() *get4v1x::kdBinSize ) - *(1e-12) ); // Time since start in s - if( uChipFullId < kuNbTdcMappedDet ) - if( kiTdcDetMap[uChipFullId] < kiNbDet ) - fvhDetDataCntEvo[ kiTdcDetMap[uChipFullId] ]->Fill( - ( ( static_cast<ULong64_t>(fvuCurrEpoch2[uChipFullId]) + - ( static_cast<ULong64_t>(fvuCurrEpoch2Cycle[uChipFullId]) << 24) ) - *get4v1x::kdEpochInPs - + mess.getGet4V10R32HitTimeBin() *get4v1x::kdBinSize ) - *(1e-12) ); // Time since start in s - - fhGet4ChanDataCount->Fill( uFullChId ); - fhGet4ChanDllStatus->Fill( uFullChId, mess.getGet4V10R32HitDllFlag() ); - fhGet4ChanTotMap->Fill( uFullChId, mess.getGet4V10R32HitTot() - *get4v1x::kdTotBinSize/1000.0 ); - - LOG(debug)<<"CbmTSUnpackGet4v1x::MonitorMessage_Get4v1 => Data!" - <<" ChipId: "<<Form("%02u", cChipId) - <<" RocId: " <<Form("%02u", cRocId) - <<" TS: " <<fulTsNb; - - if( kTRUE == fbEnaCalibOutput ) - fvhFineTime[ uChipFullId ][ mess.getGet4V10R32HitChan() ]->Fill( mess.getGet4V10R32HitFt() ); - - // Save the message in the corresponding epoch vector - get4v1x::FullMessage fullMess( mess, fvuCurrEpochBuffer[uChipFullId] ); -// std::map< ULong64_t, std::multiset< get4v1x::FullMessage > >::iterator it; -// auto it = fmsOrderedEpochsData.find( fvuCurrEpochBuffer[uChipFullId] ); - auto it = fvuCurrEpochBufferIt[uChipFullId]; -// (it->second).insert( (it->second).end(), fullMess ); // OLD - (it->second)->insert( (it->second)->end(), fullMess ); - - break; - } // case get4v1x::GET4_32B_DATA - } // switch( cMessType ) -} -//**********************************************/ - -Bool_t CbmTSUnpackGet4v1x::WriteCalibrationFile() -{ - TTimeStamp timeCurrent; - TDirectory* oldDir = gDirectory; - TString sCalibOutFilename; - if( "" == fsCalibFilename ) - sCalibOutFilename = Form("%sTofTdcCalibHistos_%u_%u.root", fsCalibOutFoldername.Data(), timeCurrent.GetDate( kFALSE), timeCurrent.GetTime( kFALSE) ); - else sCalibOutFilename = Form("%sTofTdcCalibHistos_%s.root", fsCalibOutFoldername.Data(), fsCalibFilename.Data() ); - TFile* fileCalibrationOut = new TFile( sCalibOutFilename, "RECREATE", - Form("Calibration Data for ToF TDCs, saved from analysis on %s", timeCurrent.AsString("lc") ), - 9); - if( kTRUE == fileCalibrationOut->IsOpen() ) - { - sCalibOutFilename += ":/"; - gDirectory->Cd(sCalibOutFilename); - - UInt_t uNbChan = get4v1x::kuChanPerGet4; - - if( 0 == uNbChan ) - { - LOG(info)<<"CbmTSUnpackGet4v1x::WriteCalibrationFile Undefined tdc parameters for type "; - LOG(info)<<"get4"; - LOG(info)<<" => No calib histo saving!"; - return kFALSE; - } - - TString sInfoSaving = "Saved initial calibration histograms for following get4 channels:"; - LOG(info)<<sInfoSaving; - - sInfoSaving = " "; - for( UInt_t uChanInd = 0; uChanInd< uNbChan; uChanInd++) - sInfoSaving += Form("%3u ", uChanInd); - LOG(info)<<sInfoSaving; - - for( UInt_t uGet4 = 0; uGet4 < fuNbGet4; uGet4 ++) -// if( kTRUE == fvbActiveChips[uGet4] ) // Calibration TDC indexing not compatible - { - sInfoSaving = Form("tdc #%3u: ",uGet4 ); - for( UInt_t uChanInd = 0; uChanInd< uNbChan; uChanInd++) - { - TString sCalibHistoOutputName = Form("tof_get4_ft_b%03u_ch%03u", - uGet4, uChanInd ); - - // New Calibration histo using only new data -// if( 0 < (fvhFineTime[ uGet4 ][ uChanInd ]->GetEntries() ) ) // Calibration TDC requires all channels there - { - fvhFineTime[ uGet4 ][ uChanInd ]->Write( sCalibHistoOutputName, TObject::kOverwrite); - sInfoSaving += " 1 "; - } // if( 0 < (fvhFineTime[ uGet4 ][ uChanInd ]->GetEntries() ) ) -// else sInfoSaving += " 0 "; - } // for( Int_t uChanInd = 0; uChanInd< uNbChan; uChanInd++) - LOG(info)<<sInfoSaving; - } // for( Int_t uGet4 = 0; uGet4 < fuNbGet4; uGet4 ++) - - //fileCalibrationOut->Write("",TObject::kOverwrite); - fileCalibrationOut->Close(); - LOG(info)<<"Calibration data saved in "<<sCalibOutFilename; - LOG(info)<<"Parameter line: InitialCalibFilename: Text_t " - << (static_cast<TString>( sCalibOutFilename(0, sCalibOutFilename.Length() -2 ) )); - } // if( kTRUE == fileCalibrationOut->IsOpen() ) - else LOG(warning)<<"CbmTSUnpackGet4v1x::WriteCalibrationFile => Unable to open root file " - <<sCalibOutFilename - <<" to save calibration data, please check settings"; - gDirectory->Cd(oldDir->GetPath()); - - return kTRUE; -} - -ClassImp(CbmTSUnpackGet4v1x) diff --git a/beamtime/cern2014/unpacker/CbmTSUnpackGet4v1x.h b/beamtime/cern2014/unpacker/CbmTSUnpackGet4v1x.h deleted file mode 100644 index db9ffa6a34329d06f6da3b5d8a7bcc8edafe1ad9..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/unpacker/CbmTSUnpackGet4v1x.h +++ /dev/null @@ -1,261 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmTSUnpackGet4v1x ----- -// ----- Created 15.12.2014 by ----- -// ----- P.-A. Loizeau ----- -// ----- Based on CbmTSUnpackNxyter ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CBMTSUNPACKGET4V1X_H -#define CBMTSUNPACKGET4V1X_H - -#include "Timeslice.hpp" - -// Specific headers -#include "CbmGet4v1xHackDef.h" -#include "CbmTSUnpack.h" - -// ROOT headers -#include "TClonesArray.h" - -// C++ std headers -#include <vector> -#include <map> -#include <set> - -class TH1; -class TH2; -class TProfile; - -class CbmGet4EpochBuffer; -/* -const UInt_t kuNbChanFee = 32; -const UInt_t kuNbChanTest = 16; -const UInt_t kuNbChanComb = 4; -*/ -class CbmTSUnpackGet4v1x : public CbmTSUnpack -{ -public: - - CbmTSUnpackGet4v1x(); - virtual ~CbmTSUnpackGet4v1x(); - - virtual Bool_t Init(); - - virtual Bool_t DoUnpack(const fles::Timeslice& ts, size_t component); - - virtual void Reset(); - - virtual void Finish(); - - void SetParContainers() {;} - - virtual void FillOutput(boost::any){;} - - inline void SetRocNb( UInt_t uNbRocsIn ) { fuNbRocs = uNbRocsIn; } - inline void SetGet4Nb( UInt_t uNbChipsIn) { fuNbGet4 = uNbChipsIn; } - inline void SetMsOverlapTs( UInt_t uMsOverIn) { fuMsOverlapTs = uMsOverIn; } - void SetActiveGet4( UInt_t uChipsIndex, Bool_t bActiveFlag = kTRUE); - - inline void SetVerbose( Bool_t inVerb = kTRUE ) { fbVerbose = inVerb; } - - inline void SetMode( Int_t inMode = 2 ) { fiMode = inMode; } - - inline void SetBinSizeEvoHistos( Double_t dBinSzIn ) { fdEvoBinSizeS = ( 0.0 < dBinSzIn ? dBinSzIn : 1.0);}; - inline void SetLengthEvoHistos( Double_t dLengthIn ) { fdEvoLengthSec = dLengthIn;}; - inline void SetMicroSliceLength( Double_t dMsIn ) { fdMsLengthSec = dMsIn;}; -/* - inline void SetPulserMode( Bool_t inPulserMode = kTRUE ) { fbPulserMode = inPulserMode; } - inline void SetPulserFee( UInt_t inPulserFee = 0 ) { fuPulserFee = inPulserFee; } - void SetPulserChans( UInt_t inPulserChanA = 0, UInt_t inPulserChanB = 1, UInt_t inPulserChanC = 2, - UInt_t inPulserChanD = 3, UInt_t inPulserChanE = 4, UInt_t inPulserChanF = 5, - UInt_t inPulserChanG = 6, UInt_t inPulserChanH = 7, UInt_t inPulserChanI = 8, - UInt_t inPulserChanJ = 9, UInt_t inPulserChanK = 10, UInt_t inPulserChanL = 11, - UInt_t inPulserChanM = 12, UInt_t inPulserChanN = 13, UInt_t inPulserChanO = 14, - UInt_t inPulserChanP = 15 ); - inline void SetOldReadoutSupp( Bool_t inReadoutAllowed = kTRUE ) { fbOldReadoutOk = inReadoutAllowed; } -*/ - - inline void SetMaxCoincDist( Double_t dMaxDistIn) { fdMaxCoincDist = dMaxDistIn;} - -// inline void SetMaxDtMultiHit( Double_t dMaxDt ) { fdMaxDtMultiHit = dMaxDt; }; - - void SetHistoFilename( TString sNameIn ); - - void SetCalibOutOn( Bool_t bCalibOn = kTRUE) { fbEnaCalibOutput = bCalibOn;}; - void SetCalibOutFolder( TString sCalibOUtFolder = "./") { fsCalibOutFoldername = sCalibOUtFolder;}; - void SetCalibFilename( TString sCalibFileName = "") { fsCalibFilename = sCalibFileName;}; - -protected: - // virtual void Register(); - void FinishUnpack(); - -private: - // Behavior control variables - Bool_t fbVerbose; - Int_t fiMode; - TString fsHistoFilename; - - // Hardware related variables => MUST be set on startup by user! - UInt_t fuNbRocs; - UInt_t fuNbGet4; - UInt_t fuNbFee; - UInt_t fuMsOverlapTs; - std::vector< Bool_t > fvbActiveChips; // Active flag to avoid mapping need (one per GET4 chip, def. kTRUE) - - // TS counter - ULong64_t fulTsNb; - ULong64_t fulMsNb; - size_t fsMaxMsNb; - UInt_t fuOffset; - UInt_t fuMaxOffset; - UInt_t fuLocalOffset; - UInt_t fuMaxLocalOffset; - - // SYNC handling - std::vector< Bool_t > fvbRocFeetSyncStart; // Keep track whether the SYNC DLM was processed (one per ROC) - std::vector< Bool_t > fvbGet4WaitFirstSync; // True until the 1st SYNC Ep2 after DLM is found (one per GET4) - - // Epochs book-keeping variables - std::vector< UInt_t > fvuCurrEpoch; // Current epoch (one per ROC) - std::vector< UInt_t > fvuCurrEpochCycle; // Current cycle of the epoch counter (one per ROC) - std::vector< UInt_t > fvuCurrEpoch2; // Current epoch2 (one per GET4 chip) - std::vector< UInt_t > fvuCurrEpoch2Cycle; // Current cycle of the epoch2 counter (one per GET4 chip) - - // Monitoring related variables - // Base, always on - TH2 * fhMessageTypePerRoc; - TH2 * fhRocSyncTypePerRoc; - TH2 * fhRocAuxTypePerRoc; - TH2 * fhSysMessTypePerRoc; - TH2 * fhMessTypePerGet4; - TH2 * fhGet4EpochFlags; - TH2 * fhGet4EpochSyncDist; - TH2 * fhGet4EpochJumps; // TODO - TH1 * fhGet4ChanDataCount; - TH2 * fhGet4ChanDllStatus; - TH2 * fhGet4ChanTotMap; - TH2 * fhGet4ChanErrors; - TH2 * fhGet4ChanSlowContM; - // Time evolution of data - Double_t fdEvoBinSizeS; - Double_t fdEvoLengthSec; - Double_t fdMsLengthSec; - TProfile * fhMsSizeEvo; - std::vector< TH1 * > fvhRocDataCntEvo; - std::vector< TH1 * > fvhRocEpochCntEvo; - std::vector< TH1 * > fvhRocErrorCntEvo; - std::vector< TH1 * > fvhRocDataLossCntEvo; - std::vector< TH1 * > fvhRocEpochLossCntEvo; - std::vector< TH1 * > fvhGet4DataCntEvo; - std::vector< TH1 * > fvhGet4ErrorCntEvo; - std::vector< TH1 * > fvhGet4DataLossCntEvo; - std::vector< TH1 * > fvhGet4EpochLossCntEvo; - std::vector< TH2 * > fvhGet4ChDataCntEvo; - std::vector< TH2 * > fvhGet4ChErrorCntEvo; - std::vector< TH1 * > fvhDetDataCntEvo; - std::vector< TH1 * > fvhDetErrorCntEvo; - std::vector< TH1 * > fvhDetDataLossCntEvo; - std::vector< TH1 * > fvhDetEpochLossCntEvo; - TProfile * fhClosedEpSizeEvo; - -/* - // TDC pulser test, works up to 1 hits per 2 epoch - Bool_t fbPulserMode; - UInt_t fuPulserFee; - UInt_t fuPulserChan[kuNbChanTest]; - TH1 * fhTimeResFee[kuNbChanFee*(kuNbChanFee-1)/2]; - TH2 * fhTimeRmsAllFee; - TH2 * fhTimeResAllFee; - TH1 * fhTimeResPairs[kuNbChanTest - 1]; - TH1 * fhTimeResCombi[kuNbChanComb*(kuNbChanComb-1)/2]; - TH2 * fhPulserHitDistNs; - TH2 * fhPulserHitDistUs; - TH2 * fhPulserHitDistMs; - TH2 * fhPulserFeeDnl; - TH2 * fhPulserFeeInl; - // Monitoring of 24b mode for debugging purpose - Bool_t fbOldReadoutOk; - TH1 * fhGet4ChanTotCount; - // - TH2 * fhPulserFeeTotDnl; - TH2 * fhPulserFeeTotInl; - - // Multiple hits (reflections, ...) detection - std::vector< TH2 * > fvhGet4MultipleHits; - std::vector< TH2 * > fvhGet4DistDoubleHits; - std::vector< TH2 * > fvhGet4DistTripleHits; - std::vector< TH2 * > fvhGet4DistMultipleHits; - std::vector< TH2 * > fvhGet4MultipleHitsVsTot; - Double_t fdMaxDtMultiHit; - std::vector< std::vector< Bool_t > > fvbChanSecondHit; - std::vector< std::vector< Bool_t > > fvbChanThirdHit; - std::vector< std::vector< Double_t > > fvdChanFirstHitTot; - - // Monitoring functions - void MonitorMessage_epoch( get4v1x::Message mess, uint16_t EqID); - void MonitorMessage_sync( get4v1x::Message mess, uint16_t EqID); - void MonitorMessage_aux( get4v1x::Message mess, uint16_t EqID); - void MonitorMessage_sys( get4v1x::Message mess, uint16_t EqID); - void MonitorMessage_epoch2( get4v1x::Message mess, uint16_t EqID); - void MonitorMessage_get4( get4v1x::Message mess, uint16_t EqID); - void MonitorMessage_Get4v1( get4v1x::Message mess, uint16_t EqID); -*/ - // Channel coincidences - std::vector< std::vector< TH2 * > > fvvhChannelsCoinc; - Double_t fdMaxCoincDist; - std::vector< UInt_t > fvuLastHitEp; // Epoch of Last hit message (one per GET4 chip & channel) - std::vector< get4v1x::Message > fvmLastHit; // Last hit message (one per GET4 chip & channel) - std::vector< UInt_t > fvuLastOldTotEp; // Epoch of Last TOT message (one per GET4 chip & channel) - std::vector< get4v1x::Message > fvmLastOldTot; // Last TOT message (one per GET4 chip & channel) - void InitMonitorHistograms(); - void FillMonitorHistograms(); - void WriteMonitorHistograms(); - void DeleteMonitorHistograms(); - - // Unpacking related variables - // Map of following pairs: full epoch + Multiset containers for ordered data (1/epoch) -// std::map< ULong64_t, std::multiset< get4v1x::FullMessage > > fmsOrderedEpochsData; // OLD - std::map< ULong64_t, std::multiset< get4v1x::FullMessage >* > fmsOrderedEpochsData; - // Map of following pairs: full epoch + Closed buffer flag (1/epoch) - std::map< ULong64_t, Bool_t > fmsOrderedEpochsBuffStat; - // FULL epoch2 key of the Current buffer (one per GET4 chip) - std::vector< ULong64_t > fvuCurrEpochBuffer; - // iterator of the Current buffer (one per GET4 chip) - std::vector< - std::map< ULong64_t, std::multiset< -// get4v1x::FullMessage > // OLD - get4v1x::FullMessage > * - >::iterator > fvuCurrEpochBufferIt; - // Last epoch buffer for which all chips were done - ULong64_t fuLastEpBufferReady; - // Current buffer for read (first unread close epoch, to be erased after read?) - ULong64_t fuCurrEpReadBuffer; - - CbmGet4EpochBuffer * fEpochBuffer; - - // Unpacking functions - // EqID = Equipment identifier from ums - void ProcessMessage_epoch( get4v1x::Message mess, uint16_t EqID); - void ProcessMessage_sync( get4v1x::Message mess, uint16_t EqID); - void ProcessMessage_aux( get4v1x::Message mess, uint16_t EqID); - void ProcessMessage_sys( get4v1x::Message mess, uint16_t EqID); - void ProcessMessage_epoch2( get4v1x::Message mess, uint16_t EqID); - void ProcessMessage_get4( get4v1x::Message mess, uint16_t EqID); - void ProcessMessage_Get4v1( get4v1x::Message mess, uint16_t EqID); - - // Finetime calibration members and method - Bool_t fbEnaCalibOutput; - TString fsCalibOutFoldername; - TString fsCalibFilename; - std::vector< std::vector< TH1 * > > fvhFineTime; - Bool_t WriteCalibrationFile(); - - CbmTSUnpackGet4v1x(const CbmTSUnpackGet4v1x&); - CbmTSUnpackGet4v1x operator=(const CbmTSUnpackGet4v1x&); - - ClassDef(CbmTSUnpackGet4v1x, 1) -}; - -#endif // CBMTSUNPACKGET4V1X_H diff --git a/beamtime/cern2014/unpacker/CbmTSUnpackNxyter.cxx b/beamtime/cern2014/unpacker/CbmTSUnpackNxyter.cxx deleted file mode 100644 index 45bcb25115c8555aace3dc96841676397d2e46ee..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/unpacker/CbmTSUnpackNxyter.cxx +++ /dev/null @@ -1,301 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmTSUnpackNxyter ----- -// ----- Created 07.11.2014 by ----- -// ----- E. Ovcharenko, F. Uhlig ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#include "CbmTSUnpackNxyter.h" - -#include "CbmNxyterRawMessage.h" -#include "CbmNxyterRawSyncMessage.h" - -#include "FairLogger.h" -#include "FairRootManager.h" - -#include "TClonesArray.h" - -#include <iostream> -#include <stdint.h> - -#define VERBOSE - -struct DTM_header -{ - uint8_t packet_length; - uint8_t packet_counter; - uint16_t ROC_ID; - - void Dump() { - #ifdef VERBOSE - printf ("HEADER ======================= pack_len=0x%02X, pack_cnt=0x%02X, ROC=0x%04X\n", - packet_length, packet_counter, ROC_ID); - #endif - } -}; - -CbmTSUnpackNxyter::CbmTSUnpackNxyter() - : CbmTSUnpack(), - fNxyterRaw(new TClonesArray("CbmNxyterRawMessage", 10)), - fNxyterRawSync(new TClonesArray("CbmNxyterRawSyncMessage", 10)) -{ - for( size_t iRoc = 0; iRoc < fgkNRocsMax; ++iRoc ) { - fCurrEpoch[ iRoc ] = 0; - } -} - -CbmTSUnpackNxyter::~CbmTSUnpackNxyter() -{ -} - -Bool_t CbmTSUnpackNxyter::Init() -{ - LOG(info) << "Initializing nxyter unpacker"; - - FairRootManager* ioman = FairRootManager::Instance(); - if (ioman == NULL) { - LOG(fatal) << "No FairRootManager instance"; - } - ioman->Register("NxyterRawMessage", "nXYTER raw data", fNxyterRaw, kTRUE); - ioman->Register("NxyterRawSyncMessage", "nXYTER raw sync data", fNxyterRawSync, kTRUE); - - return kTRUE; -} - -Bool_t CbmTSUnpackNxyter::DoUnpack(const fles::Timeslice& ts, size_t component) -{ - // Loop over microslices - for (size_t m = 0; m < ts.num_microslices(component); ++m) - { - auto msDescriptor = ts.descriptor(component, m); - const uint8_t* msContent = reinterpret_cast<const uint8_t*>(ts.content(component, m)); - - uint32_t offset = 16; - uint32_t local_offset = 0; - const uint8_t* msContent_shifted; - int padding; - - // Loop over the data of one microslice - while (offset < msDescriptor.size) - { - msContent_shifted = &msContent[offset]; - - // Extract DTM header info - DTM_header cur_DTM_header; - - cur_DTM_header.packet_length = msContent_shifted[0]; - cur_DTM_header.packet_counter = msContent_shifted[1]; - const uint16_t* ROC_ID_pointer = reinterpret_cast<const uint16_t*>(&msContent_shifted[2]); - cur_DTM_header.ROC_ID = *ROC_ID_pointer; - - // Debug printout - cur_DTM_header.Dump(); - - uint32_t packageSize = static_cast<uint32_t>(cur_DTM_header.packet_length*2+4); - - // Loop over messages - local_offset = 4; - while (local_offset < packageSize) - { - // Extract the message type to define which procedure to apply to the 6-bytes message - uint8_t messageType = (msContent_shifted[local_offset+5] >> 0) & 0x07; // 3 bits - - this->Print6bytesMessage(&msContent_shifted[local_offset]); - - switch(messageType) { - case MSG_HIT: - this->ProcessMessage_hit(&msContent_shifted[local_offset], msDescriptor.eq_id, cur_DTM_header.ROC_ID); - break; - case MSG_EPOCH: - this->ProcessMessage_epoch(&msContent_shifted[local_offset], cur_DTM_header.ROC_ID); - break; - case MSG_SYNC: - this->ProcessMessage_sync(&msContent_shifted[local_offset], msDescriptor.eq_id, cur_DTM_header.ROC_ID); - break; - case MSG_AUX: - this->ProcessMessage_aux(&msContent_shifted[local_offset], msDescriptor.eq_id, cur_DTM_header.ROC_ID); - break; - case MSG_SYS: - this->ProcessMessage_sys(&msContent_shifted[local_offset], msDescriptor.eq_id, cur_DTM_header.ROC_ID); - break; - } - - local_offset += 6; // next message - } - - offset += packageSize; - - // shift some more bytes to fit the CbmNet package size - if ((padding = offset % 8) > 0) { - offset += (8-padding); - } - - } - - } - - return kTRUE; -} - -void CbmTSUnpackNxyter::Reset() -{ - fNxyterRaw->Clear(); - fNxyterRawSync->Clear(); -} - -/* -void CbmTSUnpackNxyter::Register() -{ -} -*/ - -void CbmTSUnpackNxyter::Print6bytesMessage(const uint8_t* msContent_shifted) -{ - #ifdef VERBOSE - printf("0x%02X%02X%02X%02X%02X%02X :\t", - msContent_shifted[0], msContent_shifted[1], - msContent_shifted[2], msContent_shifted[3], - msContent_shifted[4], msContent_shifted[5]); - #endif -} - - -// Last epoch flag, overflow flag, pileup flag, ADC value, channel, timestamp, LTS, NX id, ROC id, messageType=1 -// [LOPAAAAA][AAAAAAA-][CCCCCCCT][TTTTTTTT][TTTTTLLL][NNRRR001] -void CbmTSUnpackNxyter::ProcessMessage_hit(const uint8_t* msContent_shifted, uint16_t EqID, uint16_t RocID) -{ - - Int_t messageType, rocID, nxID, lts, timestamp, channel, ADCvalue; - Bool_t pileUp, overflow, lastEpoch; - - messageType = (msContent_shifted[5] >> 0) & 0x07; // 3 bits - rocID = (msContent_shifted[5] >> 3) & 0x07; // 3 bits - nxID = (msContent_shifted[5] >> 6) & 0x03; // 2 bits - lts = (msContent_shifted[4] >> 0) & 0x07; // 3 bits - timestamp = ((msContent_shifted[4] >> 3) & 0x1F) // 5 bits - + (((msContent_shifted[3] >> 0) & 0xFF) << 5) // 8 bits - + (((msContent_shifted[2] >> 0) & 0x01) << 13); // 1 bit - channel = (msContent_shifted[2] >> 1) & 0x7F; // 7 bits - ADCvalue = ((msContent_shifted[1] >> 1) & 0x7F) // 7 bits - + (((msContent_shifted[0] >> 0) & 0x1F) << 7); // 5 bits - pileUp = (msContent_shifted[0] >> 5) & 0x01; // 1 bit - overflow = (msContent_shifted[0] >> 6) & 0x01; // 1 bit - lastEpoch = (msContent_shifted[0] >> 7) & 0x01; // 1 bit - - #ifdef VERBOSE - printf("messType=%d\tROC=0x%01X\tNX=0x%01X\tLTS=0x%01X\tTs=0x%04X\tCh=0x%02X\tADC=0x%04X\tpileUp=%d\toverfl=%d\tlastE=%d\n", - messageType, rocID, nxID, lts, timestamp, channel, ADCvalue, pileUp, overflow, lastEpoch); - #endif - - new( (*fNxyterRaw)[fNxyterRaw->GetEntriesFast()] ) - CbmNxyterRawMessage( - EqID, - RocID*4 + nxID, - channel, - fCurrEpoch[RocID], // - cur_hit_data.NxLastEpoch, //TODO subtract here or in GetFullTime() method ?! - timestamp, - ADCvalue, - lastEpoch, - pileUp, - overflow); -} - -// Missed event (currently skipped), epoch counter value, ROC id, messageType=2 -// [MMMMMMMM][EEEEEEEE][EEEEEEEE][EEEEEEEE][EEEEEEEE][--RRR010] -void CbmTSUnpackNxyter::ProcessMessage_epoch(const uint8_t* msContent_shifted, uint16_t RocID) -{ - Int_t messageType = (msContent_shifted[5] >> 0) & 0x07; // 3 bits - - fCurrEpoch[ RocID ] = ((msContent_shifted[4] >> 0) & 0xFF) // 8 bits - + (((msContent_shifted[3] >> 0) & 0xFF) << 8) // 8 bits - + (((msContent_shifted[2] >> 0) & 0xFF) << 16) // 8 bits - + (((msContent_shifted[1] >> 0) & 0xFF) << 24); // 8 bits - - // Debug printout - #ifdef VERBOSE - printf("messType=%d\tepoch=0x%08X\troc=%04d\n", messageType, fCurrEpoch[RocID], RocID); - #endif -} - - -// Status, Data, Timestamp, syncChannel, ROC id, messageType=3 -// [SSDDDDDD][DDDDDDDD][DDDDDDDD][DDTTTTTT][TTTTTTTT][CCRRR011] -void CbmTSUnpackNxyter::ProcessMessage_sync(const uint8_t* msContent_shifted, uint16_t EqID, uint16_t RocID) -{ - Int_t messageType, rocID, syncCh, timestamp, data, status; - - messageType = (msContent_shifted[5] >> 0) & 0x07; // 3 bits - rocID = (msContent_shifted[5] >> 3) & 0x07; // 3 bits - syncCh = (msContent_shifted[5] >> 6) & 0x03; // 2 bits - timestamp = ((msContent_shifted[4] >> 0) & 0xFF) // 8 bits - + (((msContent_shifted[3] >> 0) & 0x3F) << 8); // 6 bits - data = ((msContent_shifted[3] >> 6) & 0x03) // 2 bits - + (((msContent_shifted[2] >> 0) & 0xFF) << 2) // 8 bits - + (((msContent_shifted[1] >> 0) & 0xFF) << 10) // 8 bits - + (((msContent_shifted[0] >> 0) & 0x3F) << 18); // 6 bits - status = (msContent_shifted[0] >> 6) & 0x03; // 2 bits - - new( (*fNxyterRawSync)[fNxyterRawSync->GetEntriesFast()] ) - CbmNxyterRawSyncMessage( - EqID, - RocID*4 + syncCh, //TODO check - syncCh, - fCurrEpoch[RocID], // - cur_hit_data.NxLastEpoch, //TODO subtract here or in GetFullTime() method ?! - timestamp, - status, - data); - - #ifdef VERBOSE - printf("messType=%d\tROC=0x%01X\tsyncCh=0x%01X\tTs=0x%04X\tdata=0x%08X\tstat=0x%01X\n", - messageType, rocID, syncCh, timestamp, data, status); - #endif -} - -// Pileup flag, edge type, timestamp, channel, ROC id, messageType=4 -// [--------][--------][---PETTT][TTTTTTTT][TTTCCCCC][CCRRR100] -void CbmTSUnpackNxyter::ProcessMessage_aux(const uint8_t* msContent_shifted, uint16_t /*EqID*/, uint16_t /*RocID*/) -{ - Int_t messageType, rocID, channel, timestamp; - Bool_t edgeType, pileUp; - - messageType = (msContent_shifted[5] >> 0) & 0x07; // 3 bits - rocID = (msContent_shifted[5] >> 3) & 0x07; // 3 bits - channel = ((msContent_shifted[5] >> 6) & 0x03) // 2 bits - + (((msContent_shifted[4] >> 0) & 0x1F) << 2); // 5 bits - - timestamp = ((msContent_shifted[4] >> 5) & 0x07) // 3 bits - + (((msContent_shifted[3] >> 0) & 0xFF) << 3) // 8 bits - + (((msContent_shifted[2] >> 0) & 0x07) << 11); // 3 bit - - edgeType = (msContent_shifted[2] >> 3) & 0x01; // 1 bit - pileUp = (msContent_shifted[2] >> 4) & 0x01; // 1 bit - - //TODO put the unpacked data into some output array - - #ifdef VERBOSE - printf("messType=%d\tROC=0x%01X\tCh=0x%02X\tTs=0x%04X\tedgeType=%d\tpileUp=%d\n", - messageType, rocID, channel, timestamp, edgeType, pileUp); - #endif -} - -// First four bytes are yet not unpacked, system message type, NX id, ROC id, messageType=7 -// [--------][--------][--------][--------][TTTTTTTT][NNRRR111] -void CbmTSUnpackNxyter::ProcessMessage_sys(const uint8_t* msContent_shifted, uint16_t /*EqID*/, uint16_t /*RocID*/) -{ - Int_t messageType, rocID, nxID, sysMessType; - - messageType = (msContent_shifted[5] >> 0) & 0x07; // 3 bits - rocID = (msContent_shifted[5] >> 3) & 0x07; // 3 bits - nxID = (msContent_shifted[5] >> 6) & 0x03; // 2 bits - sysMessType = (msContent_shifted[4] >> 0) & 0xFF; // 8 bits - - //TODO put the unpacked data into some output array - - #ifdef VERBOSE - printf("messType=%d\tROC=0x%01X\tNX=0x%02X\tsysMessType=%02X\n", - messageType, rocID, nxID, sysMessType); - #endif -} - -ClassImp(CbmTSUnpackNxyter) diff --git a/beamtime/cern2014/unpacker/CbmTSUnpackNxyter.h b/beamtime/cern2014/unpacker/CbmTSUnpackNxyter.h deleted file mode 100644 index 3179c7fb2f342ebfd3b85509bb46813309bfd124..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/unpacker/CbmTSUnpackNxyter.h +++ /dev/null @@ -1,75 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmTSUnpackNxyter ----- -// ----- Created 07.11.2014 by ----- -// ----- E. Ovcharenko, F. Uhlig ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CBMTSUNPACKNXYTER_H -#define CBMTSUNPACKNXYTER_H - -#include "Timeslice.hpp" - -#include "CbmTSUnpack.h" - -#include "TClonesArray.h" - -enum MessageTypes { - MSG_NOP = 0, - MSG_HIT = 1, - MSG_EPOCH = 2, - MSG_SYNC = 3, - MSG_AUX = 4, - MSG_SYS = 7 -}; - -class CbmTSUnpackNxyter : public CbmTSUnpack -{ -public: - - CbmTSUnpackNxyter(); - virtual ~CbmTSUnpackNxyter(); - - virtual Bool_t Init(); - - virtual Bool_t DoUnpack(const fles::Timeslice& ts, size_t component); - - virtual void Reset(); - - virtual void Finish() {;} - - void SetParContainers() {;} - - // protected: - // virtual void Register(); - - virtual void FillOutput(boost::any){;} - - static const size_t fgkNRocsMax = 64; - -private: - - Int_t fCurrEpoch[fgkNRocsMax]; // Current epoch of each of the ROCs - - void Print6bytesMessage(const uint8_t* msContent_shifted); - - void ProcessMessage_hit(const uint8_t* msContent_shifted, uint16_t EqID, uint16_t RocID); - void ProcessMessage_epoch(const uint8_t* msContent_shifted, uint16_t RocID); - void ProcessMessage_sync(const uint8_t* msContent_shifted, uint16_t EqID, uint16_t RocID); - void ProcessMessage_aux(const uint8_t* msContent_shifted, uint16_t EqID, uint16_t RocID); - void ProcessMessage_sys(const uint8_t* msContent_shifted, uint16_t EqID, uint16_t RocID); - - // Output array of raw hit messages - TClonesArray* fNxyterRaw; - - // Output array of raw sync messages - TClonesArray* fNxyterRawSync; - - CbmTSUnpackNxyter(const CbmTSUnpackNxyter&); - CbmTSUnpackNxyter operator=(const CbmTSUnpackNxyter&); - - ClassDef(CbmTSUnpackNxyter, 1) -}; - -#endif diff --git a/beamtime/cern2014/unpacker/CbmTSUnpackSpadic.cxx b/beamtime/cern2014/unpacker/CbmTSUnpackSpadic.cxx deleted file mode 100644 index cfb7bd9e8c3d5a969047aff0bde2610960c74f07..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/unpacker/CbmTSUnpackSpadic.cxx +++ /dev/null @@ -1,384 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmTSUnpackSpadic ----- -// ----- Created 07.11.2014 by F. Uhlig ----- -// ----- ----- -// ----------------------------------------------------------------------------- -#include "CbmTSUnpackSpadic.h" - -#include "CbmSpadicRawMessage.h" - -#include "TimesliceReader.hpp" - -#include "FairLogger.h" -#include "FairRootManager.h" - -#include "TClonesArray.h" - -#include <iostream> - -CbmTSUnpackSpadic::CbmTSUnpackSpadic() - : CbmTSUnpack(), - fSpadicRaw(new TClonesArray("CbmSpadicRawMessage", 10)), - fEpochMarkerArray(), - fPreviousEpochMarkerArray(), - fSuperEpochArray(), - fEpochMarker(0), - fSuperEpoch(0), - fNrExtraneousSamples{0} -{ - for (Int_t i=0; i < NrOfSyscores; ++i) { - for (Int_t j=0; j < NrOfHalfSpadics; ++j) { - fEpochMarkerArray[i][j] = 0; - fPreviousEpochMarkerArray[i][j] =0; - fSuperEpochArray[i][j] = 0; - } - } -} - -CbmTSUnpackSpadic::~CbmTSUnpackSpadic() -{ - LOG(info) << "Number of extraneous Samples "<< fNrExtraneousSamples; -} - -Bool_t CbmTSUnpackSpadic::Init() -{ - LOG(info) << "Initializing"; - - FairRootManager* ioman = FairRootManager::Instance(); - if (ioman == NULL) { - LOG(fatal) << "No FairRootManager instance"; - } - ioman->Register("SpadicRawMessage", "spadic raw data", fSpadicRaw, kFALSE); - - return kTRUE; -} - -Bool_t CbmTSUnpackSpadic::DoUnpack(const fles::Timeslice& ts, size_t component) -{ - // compare to: https://github.com/spadic/spadic10-software/blob/master/lib/message/message.h - // or fles/spadic/message/wrap/cpp/message.cpp - LOG(debug) << "Unpacking Spadic Data"; - - spadic::TimesliceReader r; - Int_t counter=0; - - r.add_component(ts, component); - - for (auto addr : r.sources()) { - LOG(debug) << "---- reader " << addr << " ----"; - while (auto mp = r.get_message(addr)) { - if(gLogger->IsLogNeeded( fair::Severity::debug )) { - print_message(*mp); - } - counter++; - Int_t link = ts.descriptor(component, 0).eq_id; - Int_t address = addr; - /* - if ( mp->is_valid() ){ - LOG(debug) << counter << " This message is valid"; - } else { - LOG(error) << counter << " This message is not valid"; - continue; - } - */ - Bool_t isInfo(false), isHit(false), isEpoch(false), isEpochOutOfSynch(false), isOverflow(false), isHitAborted(false), isStrange(false); - if ( mp->is_epoch_out_of_sync() ){ - isEpochOutOfSynch = true; - FillEpochInfo(link, addr, mp->epoch_count()); - GetEpochInfo(link, addr); - Int_t triggerType = -1; - Int_t infoType = -1; - Int_t stopType = -1; - Int_t groupId = mp->group_id(); - Int_t channel = mp->channel_id(); - Int_t time = -1; - Int_t bufferOverflowCounter = 0; - Int_t samples = 1; - Int_t* sample_values = new Int_t[samples]; - sample_values[0] = -256; - LOG(debug) << counter << " This is an out of sync Epoch Marker"; - LOG(debug) << " TimeStamp: " << mp->timestamp(); - LOG(debug) << " Channel: " << mp->channel_id(); - LOG(debug) << " Group: " << mp->group_id(); - new( (*fSpadicRaw)[fSpadicRaw->GetEntriesFast()] ) - CbmSpadicRawMessage(link, address, channel, fEpochMarker, time, - fSuperEpoch, triggerType, infoType, stopType, groupId, - bufferOverflowCounter, samples, sample_values, - isHit, isInfo, isEpoch, isEpochOutOfSynch, isHitAborted, isOverflow, isStrange); - delete[] sample_values; - } - else if ( mp->is_epoch_marker() ) { - LOG(debug) << counter << " This is an Epoch Marker"; - isEpoch = true; - FillEpochInfo(link, addr, mp->epoch_count()); - GetEpochInfo(link, addr); - Int_t triggerType = -1; - Int_t infoType = -1; - Int_t stopType = -1; - Int_t groupId = mp->group_id(); - Int_t channel = mp->channel_id(); - Int_t time = -1; - Int_t bufferOverflowCounter = 0; - Int_t samples = 1; - Int_t* sample_values = new Int_t[samples]; - sample_values[0] = -256; - new( (*fSpadicRaw)[fSpadicRaw->GetEntriesFast()] ) - CbmSpadicRawMessage(link, address, channel, fEpochMarker, time, - fSuperEpoch, triggerType, infoType, stopType, groupId, - bufferOverflowCounter, samples, sample_values, - isHit, isInfo, isEpoch, isEpochOutOfSynch, isHitAborted, isOverflow, isStrange); - delete[] sample_values; - } - else if ( mp->is_buffer_overflow() ){ - LOG(debug) << counter << " This is a buffer overflow message"; - isOverflow = true; - GetEpochInfo(link, addr); - Int_t triggerType = -1; - Int_t infoType = -1; - Int_t stopType = -1; - Int_t groupId = mp->group_id(); - Int_t channel = mp->channel_id(); - Int_t time = mp->timestamp(); - Int_t bufferOverflowCounter = static_cast<Int_t>(mp->buffer_overflow_count()); - Int_t samples = 1; - Int_t* sample_values = new Int_t[samples]; - sample_values[0] = -256; - new( (*fSpadicRaw)[fSpadicRaw->GetEntriesFast()] ) - CbmSpadicRawMessage(link, address, channel, fEpochMarker, time, - fSuperEpoch, triggerType, infoType, stopType, groupId, - bufferOverflowCounter, samples, sample_values, - isHit, isInfo, isEpoch, isEpochOutOfSynch, isHitAborted, isOverflow, isStrange); - delete[] sample_values; - } - else if ( mp->is_info() ){ - LOG(debug) << counter << " This is a info message"; - isInfo = true; - GetEpochInfo(link, addr); - - Int_t triggerType = -1; - Int_t infoType = static_cast<Int_t>(mp->info_type()); - Int_t stopType = -1; - Int_t groupId = mp->group_id(); - Int_t channel = mp->channel_id(); - Int_t time = mp->timestamp(); - Int_t bufferOverflowCounter = 0;//mp->buffer_overflow_count();// should be now obsolete - Int_t samples = 1; - Int_t* sample_values = new Int_t[samples]; - sample_values[0] = -256; - new( (*fSpadicRaw)[fSpadicRaw->GetEntriesFast()] ) - CbmSpadicRawMessage(link, address, channel, fEpochMarker, time, - fSuperEpoch, triggerType, infoType, stopType, groupId, - bufferOverflowCounter, samples, sample_values, - isHit, isInfo, isEpoch, isEpochOutOfSynch, isHitAborted, isOverflow, isStrange); - delete[] sample_values; - } - else if ( mp->is_hit() ) { - LOG(debug) << counter << " This is a hit message"; - isHit = true; - GetEpochInfo(link, addr); - Int_t triggerType = static_cast<Int_t>(mp->hit_type()); - Int_t stopType = static_cast<Int_t>(mp->stop_type()); - Int_t time = mp->timestamp(); - Int_t infoType = -1; - Int_t groupId = mp->group_id(); - Int_t bufferOverflowCounter = 0; - Int_t samples = mp->samples().size(); - if(samples>32) { - fNrExtraneousSamples++; - samples=32; //Suppress extraneous Samples, which cannot (!) occur in Raw Data Stream. - } - Int_t* sample_values = new Int_t[samples]; - Int_t channel = mp->channel_id(); - Int_t counter1=0; - for (auto x : mp->samples()) { - sample_values[counter1] = x; - ++counter1; - } - //} - new( (*fSpadicRaw)[fSpadicRaw->GetEntriesFast()] ) - CbmSpadicRawMessage(link, address, channel, fEpochMarker, time, - fSuperEpoch, triggerType, infoType, stopType, groupId, - bufferOverflowCounter, samples, sample_values, - isHit, isInfo, isEpoch, isEpochOutOfSynch, isHitAborted, isOverflow, isStrange); - //++counter; - delete[] sample_values; - } - else if ( mp->is_hit_aborted()) { - LOG(debug) << counter << " This is a hit message was aborted"; - isHitAborted = true; - GetEpochInfo(link, addr); - Int_t triggerType = -1; - Int_t stopType = -1; - Int_t time = mp->timestamp(); - Int_t infoType = -1; - Int_t groupId = -1;//mp->group_id();//??? - Int_t bufferOverflowCounter = 0; - Int_t samples = 1; - Int_t* sample_values = NULL; - Int_t channel = mp->channel_id(); - infoType = static_cast<Int_t>(mp->info_type());// should here be stoptype instead??? - sample_values = new Int_t[samples]; - sample_values[0] = -256; - new( (*fSpadicRaw)[fSpadicRaw->GetEntriesFast()] ) - CbmSpadicRawMessage(link, address, channel, fEpochMarker, time, - fSuperEpoch, triggerType, infoType, stopType, groupId, - bufferOverflowCounter, samples, sample_values, - isHit, isInfo, isEpoch, isEpochOutOfSynch, isHitAborted, isOverflow, isStrange); - //++counter; - delete[] sample_values; - - } - else { - isStrange = true; - //GetEpochInfo(link, addr); - Int_t triggerType = -1; - Int_t stopType = -1; - Int_t time = -1;//mp->timestamp(); - Int_t infoType = -1; - Int_t groupId = -1;//mp->group_id(); - Int_t bufferOverflowCounter = 0; - Int_t samples = 1; - Int_t* sample_values = NULL; - Int_t channel = -1;//mp->channel_id(); - sample_values = new Int_t[samples]; - sample_values[0] = -256; - new( (*fSpadicRaw)[fSpadicRaw->GetEntriesFast()] ) - CbmSpadicRawMessage(link, address, channel, fEpochMarker, time, - fSuperEpoch, triggerType, infoType, stopType, groupId, - bufferOverflowCounter, samples, sample_values, - isHit, isInfo, isEpoch, isEpochOutOfSynch, isHitAborted, isOverflow, isStrange); - //++counter; - delete[] sample_values; - - LOG(debug) << counter << " This message type is not hit, info, epoch or overflow and will not be stored in the TClonesArray"; - LOG(debug) << " valide:" << mp->is_valid() << " epoch marker:" << fEpochMarker << " super epoch marker:" << fSuperEpoch << " time:" << time << " link:" << link << " address:" << address; - LOG(debug) << "Channel ID:" << mp->channel_id(); - //if ( mp->is_hit_aborted() ) - //LOG(info) << "hit is aborted"; - //if ( mp->is_hit() ) - LOG(debug) << "GroupID:" << mp->group_id() << "hit: triggerType:" << static_cast<Int_t>(mp->hit_type()) << " stopType:" << static_cast<Int_t>(mp->stop_type()) << " Nr.of samples:" << mp->samples().size(); - - //if () - for (auto x : mp->samples()) { - LOG(debug) << " " << x; - } - LOG(debug); - //if (mp->is_info()) - LOG(debug) << "InfoType:" << static_cast<Int_t>(mp->info_type()); - //if () - LOG(debug) << "Nr. of overflows:" << static_cast<Int_t>(mp->buffer_overflow_count()); - //print_message(mp); - } - } - } - return kTRUE; -} - - void CbmTSUnpackSpadic::print_message(const spadic::Message& m) - { - LOG(info) << "v: " << (m.is_valid() ? "o" : "x"); - LOG(debug) << " / gid: " << static_cast<int>(m.group_id()); - LOG(debug) << " / chid: " << static_cast<int>(m.channel_id()); - if ( m.is_hit() ) { - LOG(debug) << " / ts: " << m.timestamp(); - LOG(debug) << " / samples (" << m.samples().size() << "):"; - for (auto x : m.samples()) { - LOG(debug) << " " << x; - } - LOG(debug); - } else { - if ( m.is_epoch_marker() ) { - LOG(debug) << " This is an Epoch Marker"; - } else if ( m.is_epoch_out_of_sync() ) { - LOG(info) << " This is an out of sync Epoch Marker"; - } else { - LOG(info) << " This is not known"; - } - } - } - -void CbmTSUnpackSpadic::FillEpochInfo(Int_t link, Int_t addr, Int_t epoch_count) -{ - auto it=groupToExpMap.find(link); - if (it == groupToExpMap.end()) { - LOG(fatal) << "Could not find an entry for equipment ID" << - std::hex << link << std::dec; - } else { - /* Check for repeated Epoch Messages, as the repeated Microslices - are not captured by the CbmTsUnpacker. This is to ensure the - linearity of the GetFullTime() method. - */ - // dirty workaround in the following line: only sufficiently big backsteps of Epoch will trigger an upcount of SuperEpoch. this avoids a high sensitivity of the SuperEpoch counting method to overlaps of some epochs, before the overlaps are understood better - if ( epoch_count < (fEpochMarkerArray[it->second][addr] - 3000) ) - { - if(SuppressMultipliedEpochMessages) - if ( epoch_count != fPreviousEpochMarkerArray[it->second][addr] ){ - fSuperEpochArray[it->second][addr]++; - } else { - LOG(error)<< "Multiply repeated Epoch Messages at Super Epoch " - << fSuperEpoch << " Epoch " - << epoch_count << " for Syscore" - << it->second << "_Spadic" - << addr; - } - else fSuperEpochArray[it->second][addr]++; - - LOG(debug) << "Overflow of EpochCounter for Syscore" - << it->second << "_Spadic" - << addr; - } else if ((epoch_count - fEpochMarkerArray[it->second][addr]) !=1 ) { - LOG(info) << "Missed epoch counter for Syscore" - << it->second << "_Spadic" - << addr; - } else if (epoch_count == fEpochMarkerArray[it->second][addr]){ - LOG(error) << "Identical Epoch Counters for Syscore" - << it->second << "_Spadic" - << addr; - } - fPreviousEpochMarkerArray[it->second][addr] = fEpochMarkerArray[it->second][addr]; - fEpochMarkerArray[it->second][addr] = epoch_count; - } - -} - - void CbmTSUnpackSpadic::GetEpochInfo(Int_t link, Int_t addr) - { - auto it=groupToExpMap.find(link); - if (it == groupToExpMap.end()) { - LOG(fatal) << "Could not find an entry for equipment ID" << - std::hex << link << std::dec; - } else { - fEpochMarker = fEpochMarkerArray[it->second][addr]; - fSuperEpoch = fSuperEpochArray[it->second][addr]; - } - - } - - void CbmTSUnpackSpadic::Reset() - { - fSpadicRaw->Clear(); - } - - void CbmTSUnpackSpadic::Finish() - { - for (Int_t i=0; i < NrOfSyscores; ++i) { - for (Int_t j=0; j < NrOfHalfSpadics; ++j) { - LOG(debug) << "There have been " << fSuperEpochArray[i][j] - << " SuperEpochs for Syscore" << i << "_Spadic" - << j << " in this file"; - } - } - - } - - - /* - void CbmTSUnpackSpadic::Register() - { - } - */ - - - ClassImp(CbmTSUnpackSpadic) - diff --git a/beamtime/cern2014/unpacker/CbmTSUnpackSpadic.h b/beamtime/cern2014/unpacker/CbmTSUnpackSpadic.h deleted file mode 100644 index 99929183249420596f062c63d0aa811b5553179d..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/unpacker/CbmTSUnpackSpadic.h +++ /dev/null @@ -1,66 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmTSUnpackSpadic ----- -// ----- Created 07.11.2014 by F. Uhlig ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CBMTSUNPACKSPADIC_H -#define CBMTSUNPACKSPADIC_H - -#include "Timeslice.hpp" -#include "Message.hpp" - - -#include "CbmTSUnpack.h" -#include "CbmBeamDefaults.h" - -#include "TClonesArray.h" - -class CbmTSUnpackSpadic : public CbmTSUnpack -{ - public: - - CbmTSUnpackSpadic(); - virtual ~CbmTSUnpackSpadic(); - - virtual Bool_t Init(); - - virtual Bool_t DoUnpack(const fles::Timeslice& ts, size_t component); - void print_message(const spadic::Message& m); - - virtual void Reset(); - - virtual void Finish(); - - void SetParContainers() {;} - - // protected: - // virtual void Register(); - - virtual void FillOutput(boost::any){;} - private: - - TClonesArray* fSpadicRaw; - - Int_t fEpochMarkerArray[NrOfSyscores][NrOfHalfSpadics]; -//Array to store the previous Epoch counter - Int_t fPreviousEpochMarkerArray[NrOfSyscores][NrOfHalfSpadics]; -//Suppress multiple Epoch Messages in duplicated Microslices. NOTE:Currently Buggy - const Bool_t SuppressMultipliedEpochMessages = false; - Int_t fSuperEpochArray[NrOfSyscores][NrOfHalfSpadics]; - - Int_t fEpochMarker; - Int_t fSuperEpoch; - Int_t fNrExtraneousSamples; - void GetEpochInfo(Int_t link, Int_t addr); - void FillEpochInfo(Int_t link, Int_t addr, Int_t epoch_count); - - CbmTSUnpackSpadic(const CbmTSUnpackSpadic&); - CbmTSUnpackSpadic operator=(const CbmTSUnpackSpadic&); - - ClassDef(CbmTSUnpackSpadic, 2) -}; - -#endif - diff --git a/beamtime/cern2014/unpacker/CbmTSUnpackSpadic11OnlineMonitor.cxx b/beamtime/cern2014/unpacker/CbmTSUnpackSpadic11OnlineMonitor.cxx deleted file mode 100644 index 63b7ad4587b4c559503f68d3cface772d43c4cf6..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/unpacker/CbmTSUnpackSpadic11OnlineMonitor.cxx +++ /dev/null @@ -1,858 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmTSUnpackSpadic11OnlineMonitor ----- -// ----- Created 10.12.2016 by C. Bergmann ----- -// ----- ----- -// ----------------------------------------------------------------------------- -#include "CbmTSUnpackSpadic11OnlineMonitor.h" - -#include "CbmSpadicRawMessage.h" - -#include "TimesliceReader.hpp" - -#include "FairLogger.h" -#include "FairRootManager.h" - -#include "TClonesArray.h" - -#include "CbmHistManager.h" -#include "TCanvas.h" -#include "TH1.h" -#include "TH2.h" -#include "TH3.h" -#include "TMultiGraph.h" -#include "TMath.h" -#include "FairRun.h" -#include "FairRunOnline.h" -#include "THttpServer.h" - -#include <iostream> -#include <map> -#include <vector> - -CbmTSUnpackSpadic11OnlineMonitor::CbmTSUnpackSpadic11OnlineMonitor(Bool_t highPerformance) - : CbmTSUnpack(), - fSpadicRaw(new TClonesArray("CbmSpadicRawMessage", 10)), - fHighPerformance(highPerformance), - fEpochMarkerArray(), - fPreviousEpochMarkerArray(), - fSuperEpochArray(), - fEpochMarker(0), - fSuperEpoch(0), - fNrExtraneousSamples{0}, - fHM(new CbmHistManager()), - fcB(NULL), - fcM(NULL), - fcH(NULL), - fcL(NULL), - fcE(NULL), - fcO(NULL), - fcS(NULL), - fcI(NULL), - fcTS(NULL), - fcF(NULL), - fcSp(NULL), - fcPS{NULL}, - fcMS{NULL}, - fBaseline{NULL}, - fmaxADCmaxTimeBin{NULL}, - fHit{NULL}, - fLost{NULL}, - fEpoch{NULL}, - fOutOfSync{NULL}, - fStrange{NULL}, - fInfo{NULL}, - fHitTimeA{NULL}, - fHitTimeB{NULL}, - fHitFrequency{NULL}, - fSpectrum{NULL}, - fPulseShape{NULL}, - fMessageStatistic{NULL}, - fTSGraph{NULL}, - fLastSuperEpochA{0}, - fLastSuperEpochB{0}, - fLastFullTime{{{0}}}, - fMessageTypes{"Epoch", - "Epoch out of synch", - "Hit", - "Hit aborted", - "Info", - "Overflow", - "Strange"}, - fTriggerTypes{ "Global trigger", - "Self triggered", - "Neighbor triggered", - "Self and neighbor triggered"}, - fStopTypes{"Normal end of message", - "Channel buffer full", - "Ordering FIFO full", - "Multi hit", - "Multi hit and channel buffer full", - "Multi hit and ordering FIFO full"}, - fInfoTypes{"Channel disabled during message building", - "Next grant timeout", - "Next request timeout", - "New grant but channel empty", - "Corruption in message builder", - "Empty word", - "Epoch out of sync"} -{ - for (Int_t i=0; i < NrOfSyscores; ++i) { - for (Int_t j=0; j < NrOfHalfSpadics; ++j) { - fEpochMarkerArray[i][j] = 0; - fPreviousEpochMarkerArray[i][j] =0; - fSuperEpochArray[i][j] = 0; - } - } - InitHistos(); - InitCanvas(); -} - - CbmTSUnpackSpadic11OnlineMonitor::~CbmTSUnpackSpadic11OnlineMonitor() - { - LOG(info) << "Number of extraneous Samples "<< fNrExtraneousSamples; - } - - Bool_t CbmTSUnpackSpadic11OnlineMonitor::Init() - { - LOG(info) << "Initializing"; - - FairRootManager* ioman = FairRootManager::Instance(); - if (ioman == NULL) { - LOG(fatal) << "No FairRootManager instance"; - } - ioman->Register("SpadicRawMessage", "spadic raw data", fSpadicRaw, kTRUE); - - return kTRUE; - } - -Bool_t CbmTSUnpackSpadic11OnlineMonitor::DoUnpack(const fles::Timeslice& ts, size_t component) -{ - // compare to: https://github.com/spadic/spadic10-software/blob/master/lib/message/message.h - // or fles/spadic/message/wrap/cpp/message.cpp - LOG(debug) << "Unpacking Spadic Data"; - //TH2I* h = NULL; (VF) unused - TString cName; - spadic::TimesliceReader r; - Int_t counter=0; - - r.add_component(ts, component); - - for (auto addr : r.sources()) { - LOG(debug) << "---- reader " << addr << " ----"; - while (auto mp = r.get_message(addr)) { - if(gLogger->IsLogNeeded( fair::Severity::debug )) { - print_message(*mp); - } - counter++; - Int_t link = ts.descriptor(component, 0).eq_id; - Int_t address = addr; - /* - if ( mp->is_valid() ){ - LOG(debug) << counter << " This message is valid"; - } else { - LOG(error) << counter << " This message is not valid"; - continue; - } - */ - Bool_t isInfo(false), isHit(false), isEpoch(false), isEpochOutOfSync(false), isOverflow(false), isHitAborted(false), isStrange(false); - if ( mp->is_epoch_out_of_sync() ){ - isEpochOutOfSync = true; - FillEpochInfo(link, addr, mp->epoch_count()); - GetEpochInfo(link, addr); - Int_t triggerType = -1; - Int_t infoType = -1; - Int_t stopType = -1; - Int_t groupId = mp->group_id(); - Int_t channel = mp->channel_id(); - Int_t time = -1; - Int_t bufferOverflowCounter = 0; - Int_t samples = 1; - Int_t* sample_values = new Int_t[samples]; - sample_values[0] = -256; - LOG(debug) << counter << " This is an out of sync Epoch Marker"; - LOG(debug) << " TimeStamp: " << mp->timestamp(); - LOG(debug) << " Channel: " << mp->channel_id(); - LOG(debug) << " Group: " << mp->group_id(); - new( (*fSpadicRaw)[fSpadicRaw->GetEntriesFast()] ) - CbmSpadicRawMessage(link, address, channel, fEpochMarker, time, - fSuperEpoch, triggerType, infoType, stopType, groupId, - bufferOverflowCounter, samples, sample_values, - isHit, isInfo, isEpoch, isEpochOutOfSync, isHitAborted, isOverflow, isStrange); - delete[] sample_values; - fMessageStatistic[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->Fill(fMessageTypes[1].Data(),1); - if (!fHighPerformance)fOutOfSync[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->Fill(channel,groupId,1); - } - else if ( mp->is_epoch_marker() ) { - LOG(debug) << counter << " This is an Epoch Marker"; - isEpoch = true; - FillEpochInfo(link, addr, mp->epoch_count()); - GetEpochInfo(link, addr); - Int_t triggerType = -1; - Int_t infoType = -1; - Int_t stopType = -1; - Int_t groupId = mp->group_id(); - Int_t channel = mp->channel_id(); - Int_t time = -1; - Int_t bufferOverflowCounter = 0; - Int_t samples = 1; - Int_t* sample_values = new Int_t[samples]; - sample_values[0] = -256; - new( (*fSpadicRaw)[fSpadicRaw->GetEntriesFast()] ) - CbmSpadicRawMessage(link, address, channel, fEpochMarker, time, - fSuperEpoch, triggerType, infoType, stopType, groupId, - bufferOverflowCounter, samples, sample_values, - isHit, isInfo, isEpoch, isEpochOutOfSync, isHitAborted, isOverflow, isStrange); - delete[] sample_values; - fMessageStatistic[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->Fill(fMessageTypes[0].Data(),1); - if (!fHighPerformance)fEpoch[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->Fill(channel,groupId,1); - } - else if ( mp->is_buffer_overflow() ){ - LOG(debug) << counter << " This is a buffer overflow message"; - isOverflow = true; - GetEpochInfo(link, addr); - Int_t triggerType = -1; - Int_t infoType = -1; - Int_t stopType = -1; - Int_t groupId = mp->group_id(); - Int_t channel = mp->channel_id(); - Int_t time = mp->timestamp(); - Int_t bufferOverflowCounter = static_cast<Int_t>(mp->buffer_overflow_count()); - Int_t samples = 1; - Int_t* sample_values = new Int_t[samples]; - sample_values[0] = -256; - new( (*fSpadicRaw)[fSpadicRaw->GetEntriesFast()] ) - CbmSpadicRawMessage(link, address, channel, fEpochMarker, time, - fSuperEpoch, triggerType, infoType, stopType, groupId, - bufferOverflowCounter, samples, sample_values, - isHit, isInfo, isEpoch, isEpochOutOfSync, isHitAborted, isOverflow, isStrange); - delete[] sample_values; - fMessageStatistic[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->Fill(fMessageTypes[5].Data(),bufferOverflowCounter); - channel = GetChannelOnPadPlane(channel,groupId); - if (channel > 15){ - channel-= 16; - groupId = 1; - } else { - groupId = 0; - } - fLost[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->Fill(channel,groupId,bufferOverflowCounter); - } - else if ( mp->is_info() ){ - LOG(debug) << counter << " This is a info message"; - isInfo = true; - GetEpochInfo(link, addr); - - Int_t triggerType = -1; - Int_t infoType = static_cast<Int_t>(mp->info_type()); - Int_t stopType = -1; - Int_t groupId = mp->group_id(); - Int_t channel = mp->channel_id(); - Int_t time = mp->timestamp(); - Int_t bufferOverflowCounter = 0;//mp->buffer_overflow_count();// should be now obsolete - Int_t samples = 1; - Int_t* sample_values = new Int_t[samples]; - sample_values[0] = -256; - new( (*fSpadicRaw)[fSpadicRaw->GetEntriesFast()] ) - CbmSpadicRawMessage(link, address, channel, fEpochMarker, time, - fSuperEpoch, triggerType, infoType, stopType, groupId, - bufferOverflowCounter, samples, sample_values, - isHit, isInfo, isEpoch, isEpochOutOfSync, isHitAborted, isOverflow, isStrange); - delete[] sample_values; - fMessageStatistic[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->Fill(fInfoTypes[infoType].Data(),1); - channel = GetChannelOnPadPlane(channel,groupId); - if (channel > 15){ - channel-= 16; - groupId = 1; - } else { - groupId = 0; - } - if (!fHighPerformance)fInfo[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->Fill(channel,groupId,1); - } - else if ( mp->is_hit() ) { - LOG(debug) << counter << " This is a hit message"; - isHit = true; - GetEpochInfo(link, addr); - Int_t triggerType = static_cast<Int_t>(mp->hit_type()); - Int_t stopType = static_cast<Int_t>(mp->stop_type()); - Int_t time = mp->timestamp(); - Int_t infoType = -1; - Int_t groupId = mp->group_id(); - Int_t bufferOverflowCounter = 0; - Int_t samples = mp->samples().size(); - if(samples>32) { - fNrExtraneousSamples++; - samples=32; //Suppress extraneous Samples, which cannot (!) occur in Raw Data Stream. - } - Int_t* sample_values = new Int_t[samples]; - Int_t channel = mp->channel_id(); - Int_t padRow(-1); - Int_t padChannel = GetChannelOnPadPlane(channel,groupId); - - Int_t counter1=0; - Int_t maxADC(-256), maxTB(-1); - for (auto x : mp->samples()) { - sample_values[counter1] = x; - if (triggerType == 1 && stopType == 0 && sample_values[2]>-150) { - if (!fHighPerformance)fPulseShape[(GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address))*32+channel+16*(groupId%2)]->Fill(counter1,x); - } - if (x >= maxADC){ - maxADC = x; - maxTB = counter1; - } - ++counter1; - } - if (GetSpadicID(address) > 2 || GetSyscoreID(link) > 3){ - printf("link:%i SysCoreID:%i address:%i SpadicID:%i array:%i\n",link,GetSyscoreID(link),address,GetSpadicID(address),GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)); - } else { - if (triggerType == 1 && stopType == 0){ - cName.Form("SysCore_%i_Spadic_%i",GetSyscoreID(link),GetSpadicID(address)); - //h = (TH2I*)fHM->H2(TString("Baseline_"+cName).Data()); - //h->Fill(sample_values[0],groupId*16+channel); - fBaseline[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->Fill(sample_values[0],groupId*16+channel); - fmaxADCmaxTimeBin[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->Fill(maxTB,maxADC); - - if (maxTB > 0 && maxTB < 5){ - if (!fHighPerformance)fSpectrum[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->Fill(maxADC/*-sample_values[0]*/); - } - } - } - //} - new( (*fSpadicRaw)[fSpadicRaw->GetEntriesFast()] ) - CbmSpadicRawMessage(link, address, channel, fEpochMarker, time, - fSuperEpoch, triggerType, infoType, stopType, groupId, - bufferOverflowCounter, samples, sample_values, - isHit, isInfo, isEpoch, isEpochOutOfSync, isHitAborted, isOverflow, isStrange); - //++counter; - delete[] sample_values; - fMessageStatistic[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->Fill(fStopTypes[stopType].Data(),1); - fMessageStatistic[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->Fill(fTriggerTypes[triggerType].Data(),1); - - if (groupId == 0){ - fHitTimeA[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->Fill(0); - if(fLastSuperEpochA[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)] < fSuperEpoch){ - fLastSuperEpochA[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)] = fSuperEpoch; - for (Int_t i = 1; i < fHitTimeA[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->GetXaxis()->GetNbins(); i++){ - fHitTimeA[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->SetBinContent(i, fHitTimeA[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->GetBinContent(i+1)); - } - fHitTimeA[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->SetBinContent(fHitTimeA[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->GetXaxis()->GetNbins(),0); - } - }else{ - fHitTimeB[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->Fill(0); - if(fLastSuperEpochB[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)] < fSuperEpoch){ - fLastSuperEpochB[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)] = fSuperEpoch; - for (Int_t i = 1; i < fHitTimeB[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->GetXaxis()->GetNbins(); i++){ - fHitTimeB[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->SetBinContent(i, fHitTimeB[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->GetBinContent(i+1)); - } - fHitTimeB[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->SetBinContent(fHitTimeB[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->GetXaxis()->GetNbins(),0); - } - } - if (padChannel > 15){ - padChannel -= 16; - padRow = 1; - } else { - padRow = 0; - } - fHit[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->Fill(padChannel,padRow,1); - /* - fTSGraph[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->SetPoint(fTSGraph[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->GetN(),fTSGraph[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->GetN(),//fSpadicRaw[fSpadicRaw->GetEntriesFast()]->GetFullTime()/1.5E7 - ( static_cast<ULong_t>(fSuperEpoch) << 24) | - ( static_cast<ULong_t>(fEpochMarker) << 12) | - ( time & 0xfff ) - ); - */ - ULong_t fullTime = ( static_cast<ULong_t>(fSuperEpoch) << 24) | - ( static_cast<ULong_t>(fEpochMarker) << 12) | - ( time & 0xfff ); - //if (fLastFullTime[GetSyscoreID(link)][GetSpadicID(address)][channel] < fullTime) - //{ - ULong_t deltaTime = fullTime - fLastFullTime[GetSyscoreID(link)][GetSpadicID(address)][channel]; - if (!fHighPerformance)fHitFrequency[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->Fill(1./(deltaTime/1.5E7)/*,channel*/); - fLastFullTime[GetSyscoreID(link)][GetSpadicID(address)][channel] = fullTime; - //} - } - else if ( mp->is_hit_aborted()) { - LOG(debug) << counter << " This is a hit message was aborted"; - isHitAborted = true; - GetEpochInfo(link, addr); - Int_t triggerType = -1; - Int_t stopType = -1; - Int_t time = mp->timestamp(); - Int_t infoType = -1; - Int_t groupId = -1;//mp->group_id();//??? - Int_t bufferOverflowCounter = 0; - Int_t samples = 1; - Int_t* sample_values = NULL; - Int_t channel = mp->channel_id(); - infoType = static_cast<Int_t>(mp->info_type());// should here be stoptype instead??? - sample_values = new Int_t[samples]; - sample_values[0] = -256; - new( (*fSpadicRaw)[fSpadicRaw->GetEntriesFast()] ) - CbmSpadicRawMessage(link, address, channel, fEpochMarker, time, - fSuperEpoch, triggerType, infoType, stopType, groupId, - bufferOverflowCounter, samples, sample_values, - isHit, isInfo, isEpoch, isEpochOutOfSync, isHitAborted, isOverflow, isStrange); - //++counter; - delete[] sample_values; - fMessageStatistic[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->Fill(fMessageTypes[3].Data(),1); - } - else { - isStrange = true; - //GetEpochInfo(link, addr); - Int_t triggerType = -1; - Int_t stopType = -1; - Int_t time = -1;//mp->timestamp(); - Int_t infoType = -1; - Int_t groupId = -1;//mp->group_id(); - Int_t bufferOverflowCounter = 0; - Int_t samples = 1; - Int_t* sample_values = NULL; - Int_t channel = -1;//mp->channel_id(); - sample_values = new Int_t[samples]; - sample_values[0] = -256; - new( (*fSpadicRaw)[fSpadicRaw->GetEntriesFast()] ) - CbmSpadicRawMessage(link, address, channel, fEpochMarker, time, - fSuperEpoch, triggerType, infoType, stopType, groupId, - bufferOverflowCounter, samples, sample_values, - isHit, isInfo, isEpoch, isEpochOutOfSync, isHitAborted, isOverflow, isStrange); - //++counter; - delete[] sample_values; - fMessageStatistic[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->Fill(fMessageTypes[6].Data(),1); - //fStrange[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->Fill(channel,groupId); - LOG(debug) << counter << " This message type is not hit, info, epoch or overflow and will not be stored in the TClonesArray"; - LOG(debug) << " valide:" << mp->is_valid() << " epoch marker:" << fEpochMarker << " super epoch marker:" << fSuperEpoch << " time:" << time << " link:" << link << " address:" << address; - LOG(debug) << "Channel ID:" << mp->channel_id(); - //if ( mp->is_hit_aborted() ) - //LOG(info) << "hit is aborted"; - //if ( mp->is_hit() ) - LOG(debug) << "GroupID:" << mp->group_id() << "hit: triggerType:" << static_cast<Int_t>(mp->hit_type()) << " stopType:" << static_cast<Int_t>(mp->stop_type()) << " Nr.of samples:" << mp->samples().size(); - - //if () - std::stringstream ss; - for (auto x : mp->samples()) { - ss << " " << x; - } - LOG(debug) << ss.str(); - //if (mp->is_info()) - LOG(debug) << "InfoType:" << static_cast<Int_t>(mp->info_type()); - //if () - LOG(debug) << "Nr. of overflows:" << static_cast<Int_t>(mp->buffer_overflow_count()); - //print_message(mp); - } - } - } - if (fSuperEpoch%1000 == 0) - UpdateCanvas(); - return kTRUE; -} - - void CbmTSUnpackSpadic11OnlineMonitor::print_message(const spadic::Message& m) - { - LOG(info) << "v: " << (m.is_valid() ? "o" : "x"); - LOG(debug) << " / gid: " << static_cast<int>(m.group_id()); - LOG(debug) << " / chid: " << static_cast<int>(m.channel_id()); - if ( m.is_hit() ) { - LOG(debug) << " / ts: " << m.timestamp(); - LOG(debug) << " / samples (" << m.samples().size() << "):"; - std::stringstream ss; - for (auto x : m.samples()) { - ss << " " << x; - } - LOG(debug) << ss.str(); - } else { - if ( m.is_epoch_marker() ) { - LOG(debug) << " This is an Epoch Marker"; - } else if ( m.is_epoch_out_of_sync() ) { - LOG(info) << " This is an out of sync Epoch Marker"; - } else { - LOG(info) << " This is not known"; - } - } - } - - void CbmTSUnpackSpadic11OnlineMonitor::FillEpochInfo(Int_t link, Int_t addr, Int_t epoch_count) - { - auto it=groupToExpMap.find(link); - if (it == groupToExpMap.end()) { - LOG(fatal) << "Could not find an entry for equipment ID" << - std::hex << link << std::dec; - } else { - /* Check for repeated Epoch Messages, as the repeated Microslices - are not captured by the CbmTsUnpacker. This is to ensure the - linearity of the GetFullTime() method. - */ - // dirty workaround in the following line: only sufficiently big backsteps of Epoch will trigger an upcount of SuperEpoch. this avoids a high sensitivity of the SuperEpoch counting method to overlaps of some epochs, before the overlaps are understood better - if ( epoch_count < (fEpochMarkerArray[it->second][addr] - 3000) ) - { - if(SuppressMultipliedEpochMessages) - if ( epoch_count != fPreviousEpochMarkerArray[it->second][addr] ){ - fSuperEpochArray[it->second][addr]++; - } else { - LOG(error)<< "Multiply repeated Epoch Messages at Super Epoch " - << fSuperEpoch << " Epoch " - << epoch_count << " for Syscore" - << it->second << "_Spadic" - << addr; - } - else fSuperEpochArray[it->second][addr]++; - - LOG(debug) << "Overflow of EpochCounter for Syscore" - << it->second << "_Spadic" - << addr; - } else if ((epoch_count - fEpochMarkerArray[it->second][addr]) !=1 ) { - LOG(info) << "Missed epoch counter for Syscore" - << it->second << "_Spadic" - << addr; - } else if (epoch_count == fEpochMarkerArray[it->second][addr]){ - LOG(error) << "Identical Epoch Counters for Syscore" - << it->second << "_Spadic" - << addr; - } - fPreviousEpochMarkerArray[it->second][addr] = fEpochMarkerArray[it->second][addr]; - fEpochMarkerArray[it->second][addr] = epoch_count; - } - - } - - void CbmTSUnpackSpadic11OnlineMonitor::GetEpochInfo(Int_t link, Int_t addr) - { - auto it=groupToExpMap.find(link); - if (it == groupToExpMap.end()) { - LOG(fatal) << "Could not find an entry for equipment ID" << - std::hex << link << std::dec; - } else { - fEpochMarker = fEpochMarkerArray[it->second][addr]; - fSuperEpoch = fSuperEpochArray[it->second][addr]; - } - - } - Int_t CbmTSUnpackSpadic11OnlineMonitor::GetChannelOnPadPlane(Int_t SpadicChannel, Int_t groupId) - { - if(SpadicChannel > 31 || groupId > 1) LOG(debug) << "CbmTSUnpackSpadic11OnlineMonitor:: ChId " << SpadicChannel << " GroupId: " << groupId; - SpadicChannel = groupId * 16 + SpadicChannel; - Int_t channelMapping[32] = {31,15,30,14,29,13,28,12,27,11,26,10,25, 9,24, 8, - 23, 7,22, 6,21, 5,20, 4,19, 3,18, 2,17, 1,16, 0}; - if (SpadicChannel < 0 || SpadicChannel > 31){ - if (SpadicChannel !=-1) LOG(debug) << "CbmTSUnpackSpadic11OnlineMonitor::GetChannelOnPadPlane ChId " << SpadicChannel << " GroupId: " << groupId; - return -1; - } else { - return channelMapping[SpadicChannel]; - } - } - - Int_t CbmTSUnpackSpadic11OnlineMonitor::GetSpadicID(Int_t address) - { - //TString spadic=""; - Int_t SpaId = -1; - switch (address) { - case (SpadicBaseAddress+0): // first spadic - //spadic="Spadic0"; - SpaId = 0; - break; - case (SpadicBaseAddress+1): // first spadic - //spadic="Spadic0"; - SpaId = 0; - break; - case (SpadicBaseAddress+2): // second spadic - //spadic="Spadic1"; - SpaId = 1; - break; - case (SpadicBaseAddress+3): // second spadic - //spadic="Spadic1"; - SpaId = 1; - break; - case (SpadicBaseAddress+4): // third spadic - //spadic="Spadic2"; - SpaId = 2; - break; - case (SpadicBaseAddress+5): // third spadic - //spadic="Spadic2"; - SpaId = 2; - break; - default: - LOG(error) << "Source Address " << address << " not known."; - break; - } - return SpaId; - } - Int_t CbmTSUnpackSpadic11OnlineMonitor::GetSyscoreID(Int_t link) - { - Int_t SyscoreID=link-BaseEquipmentID; - if((SyscoreID<0||SyscoreID>3)){ - LOG(debug) << "EqID " << link << " not known."; - SyscoreID=-1; - } - return SyscoreID; - } - // ---- ------------------------------------------------------- - - inline TString CbmTSUnpackSpadic11OnlineMonitor::GetSpadicName(Int_t link,Int_t address){ - - TString spadicName=""; - Int_t SpadicID=0; - spadicName="SysCore_"+std::to_string(GetSyscoreID(link))+"_"; - SpadicID=GetSpadicID(address); - - //SpadicID/=2; - - spadicName += "Spadic_"; - - spadicName+=std::to_string(SpadicID); - - return spadicName; - } -void CbmTSUnpackSpadic11OnlineMonitor::InitHistos() -{ -#ifdef USE_HTTP_SERVER - THttpServer* server = FairRunOnline::Instance()->GetHttpServer(); -#endif - //cout << "InitHistos" << endl; - TString histName; - for (Int_t iLink = 0; iLink < NrOfSyscores; iLink++){ - for (Int_t iAddress = 0; iAddress < NrOfSpadics; iAddress++){ - histName.Form("SysCore_%i_Spadic_%i",iLink,iAddress); - fHM->Add(TString("Baseline_"+histName).Data(),new TH2I (TString("Baseline_"+histName).Data(),TString("Baseline_"+histName).Data(), 128,-256.5,255.5,32,-0.5,31.5)); - fBaseline[(iLink)*(NrOfSpadics)+iAddress]=(TH2I*)fHM->H2(TString("Baseline_"+histName).Data()); - fBaseline[(iLink)*(NrOfSpadics)+iAddress]->GetXaxis()->SetTitle("ADC"); - fBaseline[(iLink)*(NrOfSpadics)+iAddress]->GetYaxis()->SetTitle("Channel ID"); - fHM->Add(TString("maxADC_vs_maxTimeBin_"+histName).Data(),new TH2I (TString("maxADC_vs_maxTimeBin_"+histName).Data(),TString("maxADC_vs_maxTimeBin_"+histName).Data(),32,-0.5,31.5, 128,-256.5,255.5)); - fmaxADCmaxTimeBin[(iLink)*(NrOfSpadics)+iAddress]=(TH2I*)fHM->H2(TString("maxADC_vs_maxTimeBin_"+histName).Data()); - fmaxADCmaxTimeBin[(iLink)*(NrOfSpadics)+iAddress]->GetXaxis()->SetTitle("max. Time Bin"); - fmaxADCmaxTimeBin[(iLink)*(NrOfSpadics)+iAddress]->GetYaxis()->SetTitle("max ADC"); - fHM->Add(TString("Hit_"+histName).Data(),new TH2I (TString("Hit_"+histName).Data(),TString("Hit_"+histName).Data(),16,-0.5,15.5,2,-0.5,1.5)); - fHit[(iLink)*(NrOfSpadics)+iAddress]=(TH2I*)fHM->H2(TString("Hit_"+histName).Data()); - fHM->Add(TString("Lost_"+histName).Data(),new TH2I (TString("Lost_"+histName).Data(),TString("Lost_"+histName).Data(),16,-0.5,15.5,2,-0.5,1.5)); - fLost[(iLink)*(NrOfSpadics)+iAddress]=(TH2I*)fHM->H2(TString("Lost_"+histName).Data()); - fHM->Add(TString("Epoch_"+histName).Data(),new TH2I (TString("Epoch_"+histName).Data(),TString("Epoch_"+histName).Data(),16,-0.5,15.5,2,-0.5,1.5)); - fEpoch[(iLink)*(NrOfSpadics)+iAddress]=(TH2I*)fHM->H2(TString("Epoch_"+histName).Data()); - fHM->Add(TString("OutOfSync_"+histName).Data(),new TH2I (TString("OutOfSync_"+histName).Data(),TString("OutOfSync_"+histName).Data(),16,-0.5,15.5,2,-0.5,1.5)); - fOutOfSync[(iLink)*(NrOfSpadics)+iAddress]=(TH2I*)fHM->H2(TString("OutOfSync_"+histName).Data()); - fHM->Add(TString("Strange_"+histName).Data(),new TH2I (TString("Strange_"+histName).Data(),TString("Strange_"+histName).Data(),16,-0.5,15.5,2,-0.5,1.5)); - fStrange[(iLink)*(NrOfSpadics)+iAddress]=(TH2I*)fHM->H2(TString("Strange_"+histName).Data()); - fHM->Add(TString("Info_"+histName).Data(),new TH2I (TString("Info_"+histName).Data(),TString("Info_"+histName).Data(),16,-0.5,15.5,2,-0.5,1.5)); - fInfo[(iLink)*(NrOfSpadics)+iAddress]=(TH2I*)fHM->H2(TString("Info_"+histName).Data()); - fTSGraph[(iLink)*(NrOfSpadics)+iAddress] = new TGraph(); - //fHM->Add(TString("HitTime_"+histName).Data(),fTSGraph[(iLink)*(NrOfSpadics)+iAddress]); - //fTSGraph[(iLink)*(NrOfSpadics)+iAddress]->SetNameTitle(TString("HitTime_"+histName).Data(),TString("HitTime_"+histName).Data()); - //fTSGraph[(iLink)*(NrOfSpadics)+iAddress]->GetXaxis()->SetTitle("Timeslice"); - fHM->Add(TString("HitTimeA_"+histName).Data(),new TH1I (TString("HitTimeA_"+histName).Data(),TString("HitTimeA_"+histName).Data(),300,-299.5,0.5)); - fHitTimeA[(iLink)*(NrOfSpadics)+iAddress]=(TH1I*)fHM->H1(TString("HitTimeA_"+histName).Data()); - fHitTimeA[(iLink)*(NrOfSpadics)+iAddress]->GetXaxis()->SetTitle("SuperEpoch count"); - fHM->Add(TString("HitTimeB_"+histName).Data(),new TH1I (TString("HitTimeB_"+histName).Data(),TString("HitTimeB_"+histName).Data(),300,-299.5,0.5)); - fHitTimeB[(iLink)*(NrOfSpadics)+iAddress]=(TH1I*)fHM->H1(TString("HitTimeB_"+histName).Data()); - fHitTimeB[(iLink)*(NrOfSpadics)+iAddress]->GetXaxis()->SetTitle("SuperEpoch count"); - fHitTimeB[(iLink)*(NrOfSpadics)+iAddress]->SetLineColor(2); - fHM->Add(TString("MessageStatistic_"+histName).Data(),new TH1I (TString("MessageStatistic_"+histName).Data(),TString("MessageStatistic_"+histName).Data(),24,-0.5,23.5)); - fMessageStatistic[(iLink)*(NrOfSpadics)+iAddress]=(TH1I*)fHM->H1(TString("MessageStatistic_"+histName).Data()); - for (Int_t iM = 0; iM < 7; iM++){ - fMessageStatistic[(iLink)*(NrOfSpadics)+iAddress]->GetXaxis()->SetBinLabel(iM+1,fMessageTypes[iM]); - } - for (Int_t iT = 0; iT < 4; iT++){ - fMessageStatistic[(iLink)*(NrOfSpadics)+iAddress]->GetXaxis()->SetBinLabel(7+1+iT,fTriggerTypes[iT]); - } - for (Int_t iS = 0; iS < 6; iS++){ - fMessageStatistic[(iLink)*(NrOfSpadics)+iAddress]->GetXaxis()->SetBinLabel(7+4+1+iS,fStopTypes[iS]); - } - for (Int_t iI = 0; iI < 7; iI++){ - fMessageStatistic[(iLink)*(NrOfSpadics)+iAddress]->GetXaxis()->SetBinLabel(7+4+6+1+iI,fInfoTypes[iI]); - } - - - //const Int_t nBins=70; - //auto BinBoarders = [&nBins] (Int_t reBinHigh=32){ - ////auto BinBoarders = [&nBins] (Int_t reBinLow=32){ - //const Double_t Threshold = 100.; - //const Double_t MaxFreq = (17500000.0); - //const Double_t slope=MaxFreq/nBins; - //const Int_t iThreshhold=std::ceil((MaxFreq/Threshold-0.5)/static_cast<Double_t>(reBinHigh)); - //LOG(fatal) << "iThresshold = " << iThreshhold; - //Double_t* Result=new Double_t[nBins+1]; - // - //for(Int_t i=0;i<nBins;i++){ - // size_t j=nBins-i; - // //Result[j]=TMath::Power(TMath::E(),i*slope+TMath::Log(2)); - // //printf("%d\n",Result[j]); - // Double_t LowEdge = MaxFreq/(reBinHigh*(i*i)+0.5); - // Result[j]=LowEdge; - //}/* - // for(Int_t i=0;i<nBins-iThreshhold;i++) { - // size_t j=nBins-iThreshhold-i; - // Double_t LowEdge = MaxFreq/(reBinHigh*(iThreshhold)+0.5+RebinLow*(i)); - // Result[j]=LowEdge; - // }*/ - //Result[0]=0.0; - //std::sort(Result,&Result[nBins]); - //return Result; - //}; - //Double_t* freqbins = (BinBoarders()); - const Int_t nBins = 234; - //const Double_t maxFreq = (175000000.0); (VF) unused - auto BinBoarders = [/*&nBins*/] (Int_t /*reBinHigh*/=32) - { - const Double_t MaxFreq = (175000000.0); - //const Double_t slope=10;//MaxFreq/nBins; (VF) unused - Double_t* Result=new Double_t[nBins+1]; - for(Int_t i=0;i<nBins;i++) - { - size_t j=nBins-i; - Double_t LowEdge = MaxFreq/(TMath::Power(TMath::E(),(0.1*Int_t(i)))); - //printf("LowEdge: %e\n",LowEdge); - Result[j]=LowEdge; - //Result[j]=TMath::Power(TMath::E(),i*slope+TMath::Log(2)); - } - Result[0]=0.1; - std::sort(Result,&Result[nBins]); - return Result; - }; - Double_t* freqbins = (BinBoarders()); - fHM->Add(TString("HitFrequency_"+histName).Data(),new TH1I (TString("HitFrequency_"+histName).Data(),TString("HitFrequency_"+histName).Data(),nBins,freqbins/*100000,1,10000000*/)); - fHitFrequency[(iLink)*(NrOfSpadics)+iAddress]=(TH1I*)fHM->H1(TString("HitFrequency_"+histName).Data()); - fHitFrequency[(iLink)*(NrOfSpadics)+iAddress]->GetXaxis()->SetTitle("Trigger frequency (Hz)"); - fHitFrequency[(iLink)*(NrOfSpadics)+iAddress]->GetYaxis()->SetTitle("Channel ID"); - fHM->Add(TString("Spectrum_"+histName).Data(),new TH1I (TString("Spectrum_"+histName).Data(),TString("Spectrum_"+histName).Data(),513,-256.5,256.5)); - fSpectrum[(iLink)*(NrOfSpadics)+iAddress]=(TH1I*)fHM->H1(TString("Spectrum_"+histName).Data()); - fSpectrum[(iLink)*(NrOfSpadics)+iAddress]->GetXaxis()->SetTitle("max. ADC (ADC)"); - for (Int_t iCh = 0; iCh < 32; iCh++){ - TString chName; - chName.Form("Ch%02i_",iCh); - fHM->Add(TString("PulseShape_"+chName+histName).Data(),new TH2I (TString("PulseShape_"+chName+histName).Data(),TString("PulseShape_"+chName+histName).Data(),32,-0.5,31.5, 128,-256.5,255.5)); - fPulseShape[((iLink)*(NrOfSpadics)+iAddress)*32+iCh]=(TH2I*)fHM->H2(TString("PulseShape_"+chName+histName).Data()); - fPulseShape[((iLink)*(NrOfSpadics)+iAddress)*32+iCh]->GetXaxis()->SetTitle("Time Bin"); - fPulseShape[((iLink)*(NrOfSpadics)+iAddress)*32+iCh]->GetYaxis()->SetTitle("ADC"); - fPulseShape[((iLink)*(NrOfSpadics)+iAddress)*32+iCh]->GetZaxis()->SetTitle("counts"); - } - } - } -} -void CbmTSUnpackSpadic11OnlineMonitor::InitCanvas() -{ - //cout << "InitCanvas" << endl; - //TCanvas* c[2]; - //TH2I* h = NULL; - TString cName; - if (!fHighPerformance){ - fcE= new TCanvas(TString("EpochMap").Data(),TString("EpochMap").Data(),1600,1200); - fcE->Divide(3,4); - fcO= new TCanvas(TString("OutOfSyncMap").Data(),TString("OutOfSyncMap").Data(),1600,1200); - fcO->Divide(3,4); - fcS= new TCanvas(TString("StrangeMap").Data(),TString("StrangeMap").Data(),1600,1200); - fcS->Divide(3,4); - fcI= new TCanvas(TString("InfoMap").Data(),TString("InfoMap").Data(),1600,1200); - fcI->Divide(3,4); - fcF= new TCanvas(TString("HitFrequency").Data(),TString("HitFrequency").Data(),1600,1200); - fcF->Divide(3,4); - fcSp= new TCanvas(TString("HitSelfTriggersSpectrum").Data(),TString("HitSelfTriggersSpectrum").Data(),1600,1200); - fcSp->Divide(3,4); - } - fcB = new TCanvas(TString("Baseline").Data(),TString("Baseline").Data(),1600,1200); - fcB->Divide(3,4); - fcM/*[(iLink)*(NrOfSpadics)+iAddress]*/ = new TCanvas(TString("maxADC_vs_maxTimeBin").Data(),TString("maxADC_vs_maxTimeBin").Data(),1600,1200); - fcM->Divide(3,4); - fcH= new TCanvas(TString("HitMap").Data(),TString("HitMap").Data(),1600,1200); - fcH->Divide(3,4); - fcL= new TCanvas(TString("LostMap").Data(),TString("LostMap").Data(),1600,1200); - fcL->Divide(3,4); - fcTS= new TCanvas(TString("TSGraph").Data(),TString("TSGraph").Data(),1600,1200); - fcTS->Divide(3,4); - fcMS= new TCanvas(TString("MessageStatistic").Data(),TString("MessageStatistic").Data(),1600,1200); - fcMS->Divide(3,4); - - for (Int_t iLink = 0; iLink < NrOfSyscores; iLink++){ - for (Int_t iAddress = 0; iAddress < NrOfSpadics; iAddress++){ - cName.Form("SysCore_%i_Spadic_%i",iLink,iAddress); - if (!fHighPerformance){ - fcPS[(iLink)*(NrOfSpadics)+iAddress] = new TCanvas(TString("PulseShapes_"+cName).Data(),TString("PulseShapes_"+cName).Data(),1600,1200); - fcPS[(iLink)*(NrOfSpadics)+iAddress]->Divide(4,8); - for(Int_t iCh = 0; iCh < 32; iCh++){ - fcPS[(iLink)*(NrOfSpadics)+iAddress]->cd(iCh+1); - fPulseShape[((iLink)*(NrOfSpadics)+iAddress)*32+iCh]->Draw("colz"); - } - fcE->cd((iLink)*(NrOfSpadics)+iAddress+1)->SetLogz(0); - fEpoch[(iLink)*(NrOfSpadics)+iAddress]->Draw("colz"); - fcO->cd((iLink)*(NrOfSpadics)+iAddress+1)->SetLogz(0); - fOutOfSync[(iLink)*(NrOfSpadics)+iAddress]->Draw("colz"); - fcS->cd((iLink)*(NrOfSpadics)+iAddress+1)->SetLogz(0); - fStrange[(iLink)*(NrOfSpadics)+iAddress]->Draw("colz"); - fcI->cd((iLink)*(NrOfSpadics)+iAddress+1)->SetLogx(0); - fInfo[(iLink)*(NrOfSpadics)+iAddress]->Draw("colz"); - fcF->cd((iLink)*(NrOfSpadics)+iAddress+1)->SetLogx(1); - fcF->cd((iLink)*(NrOfSpadics)+iAddress+1)->SetLogy(1); - fcF->cd((iLink)*(NrOfSpadics)+iAddress+1)->SetLogz(0); - fHitFrequency[(iLink)*(NrOfSpadics)+iAddress]->Draw(/*"colz"*/); - fcSp->cd((iLink)*(NrOfSpadics)+iAddress+1)->SetLogy(1); - fSpectrum[(iLink)*(NrOfSpadics)+iAddress]->Draw(); - } - fcB->cd((iLink)*(NrOfSpadics)+iAddress+1)->SetLogz(); - fBaseline[(iLink)*(NrOfSpadics)+iAddress]->Draw("colz"); - cName.Form("SysCore_%i_Spadic_%i",iLink,iAddress); - fcM->cd((iLink)*(NrOfSpadics)+iAddress+1)->SetLogz(); - fmaxADCmaxTimeBin[(iLink)*(NrOfSpadics)+iAddress]->Draw("colz"); - fcH->cd((iLink)*(NrOfSpadics)+iAddress+1)->SetLogz(0); - fHit[(iLink)*(NrOfSpadics)+iAddress]->Draw("colz"); - fcL->cd((iLink)*(NrOfSpadics)+iAddress+1)->SetLogz(0); - fLost[(iLink)*(NrOfSpadics)+iAddress]->Draw("colz"); - fcMS->cd((iLink)*(NrOfSpadics)+iAddress+1)->SetLogy(1); - fMessageStatistic[(iLink)*(NrOfSpadics)+iAddress]->Draw(""); - fcTS->cd((iLink)*(NrOfSpadics)+iAddress+1); - fHitTimeA[(iLink)*(NrOfSpadics)+iAddress]->GetYaxis()->SetRangeUser(0,1000); - fHitTimeA[(iLink)*(NrOfSpadics)+iAddress]->Draw(""); - fHitTimeB[(iLink)*(NrOfSpadics)+iAddress]->Draw("same"); - //fTSGraph[(iLink)*(NrOfSpadics)+iAddress]->Draw("ALP"); - - - } - } -} - void CbmTSUnpackSpadic11OnlineMonitor::UpdateCanvas() - { - /* - //cout << "UpdateCanvas" << endl; - TH2I* h = NULL; - TString cName; - for (Int_t iLink = 0; iLink < NrOfSyscores; iLink++){ - for (Int_t iAddress = 0; iAddress < NrOfSpadics; iAddress++){ - cName.Form("SysCore_%i_Spadic_%i",iLink,iAddress); - fcB->cd((iLink)*(NrOfSpadics)+iAddress+1); - fBaseline[(iLink)*(NrOfSpadics)+iAddress]->Draw("colz"); - //h = (TH2I*)fHM->H2(TString("Baseline_"+cName).Data()); - //h->Draw("colz"); - //fcB->cd((iLink)*(NrOfSpadics)+iAddress+1)->Update(); - cName.Form("SysCore_%i_Spadic_%i",iLink,iAddress); - fcM->cd((iLink)*(NrOfSpadics)+iAddress+1); - fmaxADCmaxTimeBin[(iLink)*(NrOfSpadics)+iAddress]->Draw("colz"); - //h = (TH2I*)fHM->H2(TString("maxADC_vs_maxTimeBin_"+cName).Data()); - //h->Draw("colz"); - //fcM->cd((iLink)*(NrOfSpadics)+iAddress+1)->Update(); - } - } - */ - } - void CbmTSUnpackSpadic11OnlineMonitor::Reset() - { - fSpadicRaw->Clear(); - } - void CbmTSUnpackSpadic11OnlineMonitor::FinishEvent() - { - //UpdateCanvas(); - } - void CbmTSUnpackSpadic11OnlineMonitor::Finish() - { - for (Int_t i=0; i < NrOfSyscores; ++i) { - for (Int_t j=0; j < NrOfHalfSpadics; ++j) { - LOG(debug) << "There have been " << fSuperEpochArray[i][j] - << " SuperEpochs for Syscore" << i << "_Spadic" - << j << " in this file"; - } - } - UpdateCanvas(); - } - - - /* - void CbmTSUnpackSpadic11OnlineMonitor::Register() - { - } - */ - - - ClassImp(CbmTSUnpackSpadic11OnlineMonitor) - diff --git a/beamtime/cern2014/unpacker/CbmTSUnpackSpadic11OnlineMonitor.h b/beamtime/cern2014/unpacker/CbmTSUnpackSpadic11OnlineMonitor.h deleted file mode 100644 index a4d053ff72c509df20975c7bb1cdbc17b24e9e80..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/unpacker/CbmTSUnpackSpadic11OnlineMonitor.h +++ /dev/null @@ -1,111 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmTSUnpackSpadic11OnlineMonitor ----- -// ----- Created 10.12.2016 by C. Bergmann ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CBMTSUNPACKSPADIC11ONLINEMONITOR_H -#define CBMTSUNPACKSPADIC11ONLINEMONITOR_H - -#include "Timeslice.hpp" -#include "Message.hpp" - -#include "CbmTSUnpack.h" -#include "CbmBeamDefaults.h" - -#include "CbmHistManager.h" -#include "TClonesArray.h" - -class CbmTSUnpackSpadic11OnlineMonitor : public CbmTSUnpack -{ - public: - - CbmTSUnpackSpadic11OnlineMonitor(Bool_t highPerformancen = true ); - virtual ~CbmTSUnpackSpadic11OnlineMonitor(); - - virtual Bool_t Init(); - - virtual Bool_t DoUnpack(const fles::Timeslice& ts, size_t component); - void print_message(const spadic::Message& m); - - virtual void Reset(); - - virtual void Finish(); - virtual void FinishEvent(); - void SetParContainers() {;} - - // protected: - // virtual void Register(); - - virtual void FillOutput(boost::any){;} - private: - - TClonesArray* fSpadicRaw; - - Bool_t fHighPerformance; - - Int_t fEpochMarkerArray[NrOfSyscores][NrOfHalfSpadics]; - //Array to store the previous Epoch counter - Int_t fPreviousEpochMarkerArray[NrOfSyscores][NrOfHalfSpadics]; - //Suppress multiple Epoch Messages in duplicated Microslices. NOTE:Currently Buggy - const Bool_t SuppressMultipliedEpochMessages = false; - Int_t fSuperEpochArray[NrOfSyscores][NrOfHalfSpadics]; - - static Int_t GetSpadicID(Int_t address); - static Int_t GetSyscoreID(Int_t link); - inline TString GetSpadicName(Int_t link,Int_t address); - Int_t GetChannelOnPadPlane(Int_t SpadicChannel, Int_t groupId); - Int_t fEpochMarker; - Int_t fSuperEpoch; - Int_t fNrExtraneousSamples; - void GetEpochInfo(Int_t link, Int_t addr); - void FillEpochInfo(Int_t link, Int_t addr, Int_t epoch_count); - CbmHistManager* fHM; - TCanvas* fcB; - TCanvas* fcM;//[(iLink)*(NrOfHalfSpadics/2)]; - TCanvas* fcH; - TCanvas* fcL; - TCanvas* fcE; - TCanvas* fcO; - TCanvas* fcS; - TCanvas* fcI; - TCanvas* fcTS; - TCanvas* fcF; - TCanvas* fcSp; - TCanvas* fcPS[(NrOfSyscores)*(NrOfSpadics)]; - TCanvas* fcMS; - void InitHistos(); - void InitCanvas(); - void UpdateCanvas(); - TH2I* fBaseline[(NrOfSyscores)*(NrOfSpadics)]; - TH2I* fmaxADCmaxTimeBin[(NrOfSyscores)*(NrOfSpadics)]; - TH2I* fHit[(NrOfSyscores)*(NrOfSpadics)]; - TH2I* fLost[(NrOfSyscores)*(NrOfSpadics)]; - TH2I* fEpoch[(NrOfSyscores)*(NrOfSpadics)]; - TH2I* fOutOfSync[(NrOfSyscores)*(NrOfSpadics)]; - TH2I* fStrange[(NrOfSyscores)*(NrOfSpadics)]; - TH2I* fInfo[(NrOfSyscores)*(NrOfSpadics)]; - TH1I* fHitTimeA[(NrOfSyscores)*(NrOfSpadics)]; - TH1I* fHitTimeB[(NrOfSyscores)*(NrOfSpadics)]; - TH1I* fHitFrequency[(NrOfSyscores)*(NrOfSpadics)]; - TH1I* fSpectrum[(NrOfSyscores)*(NrOfSpadics)]; - TH2I* fPulseShape[(NrOfSyscores)*(NrOfSpadics)*32]; - TH1I* fMessageStatistic[(NrOfSyscores)*(NrOfSpadics)]; - TGraph* fTSGraph[(NrOfSyscores)*(NrOfSpadics)]; - Int_t fLastSuperEpochA[(NrOfSyscores)*(NrOfSpadics)]; - Int_t fLastSuperEpochB[(NrOfSyscores)*(NrOfSpadics)]; - ULong_t fLastFullTime[NrOfSyscores][NrOfSpadics][32]; - TString fMessageTypes[7]; - TString fTriggerTypes[4]; - TString fStopTypes[6]; - TString fInfoTypes[7]; - //Int_t fSumHitMessages[(NrOfSyscores)*(NrOfSpadics)]; - CbmTSUnpackSpadic11OnlineMonitor(const CbmTSUnpackSpadic11OnlineMonitor&); - CbmTSUnpackSpadic11OnlineMonitor operator=(const CbmTSUnpackSpadic11OnlineMonitor&); - - ClassDef(CbmTSUnpackSpadic11OnlineMonitor, 2) - }; - -#endif - diff --git a/beamtime/cern2014/unpacker/CbmTSUnpackSpadic20.cxx b/beamtime/cern2014/unpacker/CbmTSUnpackSpadic20.cxx deleted file mode 100644 index e854b56edad8d322e2df666e95b74b683f3cbe91..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/unpacker/CbmTSUnpackSpadic20.cxx +++ /dev/null @@ -1,439 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmTSUnpackSpadic20 ----- -// ----- Created 07.11.2014 by P. Munkes ----- -// ----- ----- -// ----------------------------------------------------------------------------- -#include "CbmTSUnpackSpadic20.h" - -#include "CbmSpadicRawMessage.h" - -#include "TimesliceReader20.hpp" - -#include "FairLogger.h" -#include "FairRootManager.h" - -#include "TClonesArray.h" -#include <TFile.h> - -#include "CbmHistManager.h" - -#include <iostream> -#include <array> -#include <algorithm> - -CbmTSUnpackSpadic20::CbmTSUnpackSpadic20 () : - CbmTSUnpack (), - fHm (new CbmHistManager), - fSpadicRaw (new TClonesArray ("CbmSpadicRawMessage", 10)), - fEpochMarkerArray (), - fPreviousEpochMarkerArray (), - fSuperEpochArray (), - fEpochMarker (0), - fSuperEpoch (0), - fNrExtraneousSamples { 0 }, - multihit_buffer() -{} - -CbmTSUnpackSpadic20::~CbmTSUnpackSpadic20 () -{ - LOG(info) << "Number of extraneous Samples " << fNrExtraneousSamples; -} - -Bool_t -CbmTSUnpackSpadic20::Init () -{ - LOG(info) << "Initializing"; - - FairRootManager* ioman = FairRootManager::Instance (); - if (ioman == NULL) - { - LOG(fatal) << "No FairRootManager instance"; - } - ioman->Register ("SpadicRawMessage", "spadic raw data", fSpadicRaw, kFALSE); - - CbmTSUnpackSpadic20::CreateHistograms(); - return kTRUE; -} - -void -CbmTSUnpackSpadic20::CreateHistograms() -{ - -} - -Bool_t -CbmTSUnpackSpadic20::DoUnpack (const fles::Timeslice& ts, size_t component) -{ - // compare to: https://github.com/spadic/spadic10-software/blob/master/lib/message/message.h - // or fles/spadic/message/wrap/cpp/message.cpp - LOG(debug) << "Unpacking Spadic Data"; - - spadic::TimesliceReader20 r; - Int_t counter = 0; - - r.add_component (ts, component); - - std::array<Int_t,32> sample_values; - sample_values.fill(-256); - for (uint16_t addr : r.sources ()) - { - // auto spadicLink=(addr); - int address=2*(r.get_link(addr)/0x100)/8+(r.get_link(addr)/0x100)%8; - //LOG(info) <<std::hex << "---- reader " << addr << " ----" << r.get_link(addr) << "--------------" << ts.descriptor(component,0).eq_id<<std::dec; - - //LOG(info) << "---- reader " << std::hex << addr; - - while (std::unique_ptr<spadic::Message> mp = r.get_message (addr)) - { - if (gLogger->IsLogNeeded (fair::Severity::debug)) - { - print_message (*mp); - } - counter++; - Int_t link = ts.descriptor(component, 0).eq_id-0xaa00; - //std::cout << std::hex << address << std::dec <<std::endl; - - Bool_t isInfo (false), isHit (false), isEpoch (false), - isEpochOutOfSynch (false), isOverflow (false), - isHitAborted (false), isStrange (false); - Int_t triggerType = -1; - Int_t infoType = -1; - Int_t stopType = -1; - Int_t groupId = mp->group_id (); - Int_t channel = mp->channel_id (); - Int_t time = -1; - Int_t bufferOverflowCounter = 0; - Int_t samples = 0; - if (mp->is_epoch_marker ()) - { - LOG(debug) << counter << " This is an Epoch Marker"; - isEpoch = true; - FillEpochInfo (link, address, mp->epoch_count ()); - GetEpochInfo (link, address); - time=0; - } - else if (mp->is_buffer_overflow ()) - { - LOG(debug) << counter << " This is a buffer overflow message"; - isOverflow = true; - GetEpochInfo (link, address); - time = mp->timestamp (); - bufferOverflowCounter = - static_cast<Int_t> (mp->buffer_overflow_count ()); - } - else if (mp->is_info ()) - { - LOG(debug) << counter << " This is a info message"; - isInfo = true; - GetEpochInfo (link, address); - infoType = static_cast<Int_t> (mp->info_type ()); - time = mp->timestamp (); - bufferOverflowCounter = 0; //mp->buffer_overflow_count();// should be now obsolete - } - else if (mp->is_hit ()) - { - TString HistName = ""; - n_hit++; - LOG(debug) << counter << " This is a hit message"; - isHit = true; - GetEpochInfo (link, address); - triggerType = static_cast<Int_t> (mp->hit_type ()); - stopType = static_cast<Int_t> (mp->stop_type ()); - time = mp->timestamp (); - samples = mp->samples ().size (); - if (samples > 32) - { - fNrExtraneousSamples++; - samples = 32; //Suppress extraneous Samples, which cannot (!) occur in Raw Data Stream. - } - auto temp_sample_array = mp->samples(); - std::copy(temp_sample_array.begin(),temp_sample_array.begin()+samples,sample_values.begin()); - - //Changes by J.Beckhoff - ULong_t fullTime = ( ( static_cast<ULong_t>(fSuperEpoch) << 24) | - ( static_cast<ULong_t>(fEpochMarker) << 12) | - ( time & 0xfff ) - ); - hit_object currHit{ - triggerType, - stopType, - samples, - true, //b_complete - false, //b_multiFlag - time, - fullTime, - {0} - }; - currHit.samples.fill(-256); - if(samples == 0) //hit messages with 0 samples are discarded here - { - currHit.b_complete = false; - n_zeroSample++; - continue; - } - std::copy(temp_sample_array.begin(),temp_sample_array.begin()+samples,currHit.samples.begin()); - - if(currHit.fullTime - multihit_buffer[std::make_pair(link, addr)][channel].fullTime < 32)//successor - { - n_succ++; - currHit = correct_successor(link, addr, channel, currHit); - } - if(currHit.stopType >= 3) //predecessor - { - n_pre++; - currHit = correct_predecessor(link, addr, channel, currHit); - } - if(currHit.b_complete == true) //hit is complete and ready for digi creation - { - if(currHit.b_multiFlag == true) // flag corrected multimessages with StopType = 10 - { - stopType = 10; - n_finalMultiMessage++; - } - triggerType = currHit.triggerType; - time = currHit.time; - samples = currHit.nrSamples; - std::copy(currHit.samples.begin(),currHit.samples.begin() + currHit.nrSamples,sample_values.begin()); - n_final_hit++; - } - else - { - continue; - } - //end changes J.Beckhoff - } - else if (mp->is_hit_aborted ()) - { - LOG(debug) << counter << " This is a hit message was aborted"; - isHitAborted = true; - GetEpochInfo (link, address); - samples = 0; - infoType = static_cast<Int_t> (mp->info_type ()); // should here be stoptype instead??? - } - else - { - isStrange = true; - GetEpochInfo(link, address); - LOG(debug) << counter - << " This message type is not hit, info, epoch or overflow and will not be stored in the TClonesArray"; - LOG(debug) << " valide:" << mp->is_valid () << " epoch marker:" - << fEpochMarker << " super epoch marker:" - << fSuperEpoch << " time:" << time << " link:" - << link << " address:" << address; - LOG(debug) << "Channel ID:" << mp->channel_id (); - LOG(debug) << "GroupID:" << mp->group_id () << "hit: triggerType:" - << static_cast<Int_t> (mp->hit_type ()) - << " stopType:" - << static_cast<Int_t> (mp->stop_type ()) - << " Nr.of samples:" << mp->samples ().size (); - std::stringstream ss; - for (auto x : mp->samples ()) - { - ss << " " << x; - } - LOG(debug) << ss.str(); - //if (mp->is_info()) - LOG(debug) << "InfoType:" << static_cast<Int_t> (mp->info_type ()); - //if () - LOG(debug) << "Nr. of overflows:" - << static_cast<Int_t> (mp->buffer_overflow_count ()); - } - Int_t* sample_ptr=sample_values.data(); - new( (*fSpadicRaw)[fSpadicRaw->GetEntriesFast()] ) - CbmSpadicRawMessage(link, address, channel, fEpochMarker, time, - fSuperEpoch, triggerType, infoType, stopType, groupId, - bufferOverflowCounter, samples, sample_ptr, - isHit, isInfo, isEpoch, isEpochOutOfSynch, isHitAborted, - isOverflow, isStrange); - sample_values.fill(-256); - } - } - return kTRUE; -} - -//changes by J.Beckhoff -CbmTSUnpackSpadic20::hit_object CbmTSUnpackSpadic20::correct_successor(Int_t link, Int_t addr, Int_t channel, hit_object currHit) -{ - auto oldHit=multihit_buffer[std::make_pair(link, addr)][channel]; - Int_t samples_pre = oldHit.nrSamples; - Int_t samples_succ = currHit.nrSamples; - if(samples_pre < 6)//multimessage, if predecessor with less than 6 samples - { - int sum_Samples = std::min((samples_pre + samples_succ), 32); - for(int i = sum_Samples-1; i >= 0; i--) //combine pre + succ samples - { - if(i >= samples_pre)//predecessor samples - { - currHit.samples[i] = currHit.samples[i-samples_pre]; - } - else //successor samples - { - currHit.samples[i] = oldHit.samples[i]; - } - } - //set hit variables - currHit.nrSamples = sum_Samples; - currHit.triggerType = oldHit.triggerType; //time and triggerType of predecessor - currHit.time = oldHit.time; //time and triggerType of predecessor - currHit.fullTime = oldHit.fullTime; //time and triggerType of predecessor - currHit.b_complete = true; - currHit.b_multiFlag = true; - n_multimessage_succ++; - } - else // multihit, handled to the digitizer - { - currHit.b_complete = true; - currHit.b_multiFlag = false; - n_multihit_succ++; - } - multihit_buffer[std::make_pair(link,addr)].erase(channel); //delete buffer entry - return currHit; -} - -CbmTSUnpackSpadic20::hit_object CbmTSUnpackSpadic20::correct_predecessor(Int_t link, Int_t addr, Int_t channel, hit_object currHit) -{ - if(currHit.nrSamples < 6) //multimessage, if less than 6 samples - { - currHit.b_complete = false; - n_multimessage_pre++; - } - else //multihit, handled to the digitizer - { - currHit.b_complete = true; - n_multihit_pre++; - } - currHit.b_multiFlag = false; - //make buffer entry - multihit_buffer[std::make_pair(link,addr)].erase(channel); - multihit_buffer[std::make_pair(link,addr)].insert(std::make_pair(channel, currHit)); - return currHit; -} -//end changes by J.Beckhoff - -void -CbmTSUnpackSpadic20::print_message (const spadic::Message& m) -{ - LOG(info) << "v: " << (m.is_valid () ? "o" : "x"); - LOG(debug) << " / gid: " << static_cast<int> (m.group_id ()); - LOG(debug) << " / chid: " << static_cast<int> (m.channel_id ()); - if (m.is_hit ()) - { - LOG(debug) << " / ts: " << m.timestamp (); - LOG(debug) << " / samples (" << m.samples ().size () << "):"; - std::stringstream ss; - for (auto x : m.samples ()) - { - ss << " " << x; - } - LOG(debug) << ss.str(); - } - else - { - if (m.is_epoch_marker ()) - { - LOG(debug) << " This is an Epoch Marker"; - } - else if (m.is_epoch_out_of_sync ()) - { - LOG(info) << " This is an out of sync Epoch Marker"; - } - else - { - LOG(info) << " This is not known"; - } - } -} - -void -CbmTSUnpackSpadic20::FillEpochInfo (Int_t link, Int_t addr, Int_t epoch_count) -{ - - - /* Check for repeated Epoch Messages, as the repeated Microslices - are not captured by the CbmTsUnpacker. This is to ensure the - linearity of the GetFullTime() method. - */ - // dirty workaround in the following line: only sufficiently big backsteps of Epoch will trigger an upcount of SuperEpoch. this avoids a high sensitivity of the SuperEpoch counting method to overlaps of some epochs, before the overlaps are understood better - if (epoch_count < (fEpochMarkerArray[std::pair<int,int>(link,addr)] - 3000)) - { - if (SuppressMultipliedEpochMessages) - if (epoch_count != fPreviousEpochMarkerArray[std::pair<int,int>(link,addr)]) - { - fSuperEpochArray[std::pair<int,int>(link,addr)]++; - } - else - { - LOG(error) << "Multiply repeated Epoch Messages at Super Epoch " - << fSuperEpoch << " Epoch " << epoch_count - << " for AFCK" << link << "_Spadic" << addr; - } - else - fSuperEpochArray[std::pair<int,int>(link,addr)]++; - - LOG(debug) << "Overflow of EpochCounter for Afck" << link - << "_Spadic" << addr; - } - else if ((epoch_count - fEpochMarkerArray[std::pair<int,int>(link,addr)]) != 1) - { - LOG(info) <<std::hex<< "Missed epoch counter for Afck" << link - << "_Spadic" << addr <<std::dec; - } - else if (epoch_count == fEpochMarkerArray[std::pair<int,int>(link,addr)]) - { - LOG(error) << "Identical Epoch Counters for Afck" << link - << "_Spadic" << addr; - } - fPreviousEpochMarkerArray[std::pair<int,int>(link,addr)] = - fEpochMarkerArray[std::pair<int,int>(link,addr)]; - fEpochMarkerArray[std::pair<int,int>(link,addr)] = epoch_count; - - -} - -void -CbmTSUnpackSpadic20::GetEpochInfo (Int_t link, Int_t addr) -{ - fEpochMarker = fEpochMarkerArray[std::pair<int,int>(link,addr)]; - fSuperEpoch = fSuperEpochArray[std::pair<int,int>(link,addr)]; -} - -void -CbmTSUnpackSpadic20::Reset () -{ - fSpadicRaw->Clear (); -} - -void -CbmTSUnpackSpadic20::Finish () -{ - LOG(debug) << n_hit << " initial hits" << "\n" - << n_pre << " Predecessor, " << n_succ << " Successor" << "\n" - << "Multihits: " << n_multihit_pre << " Predecessor, " << n_multihit_succ << " Successor" << "\n" - << "Multimessages: " << n_multimessage_pre << " Predecessor, " << n_multimessage_succ << " Successor" << "\n" - << "Zero Sample Hits: " << n_zeroSample << "\n" - << "Final Multimessages: " << n_finalMultiMessage << "\n" - << n_final_hit << " final hits"; - for (auto it = fSuperEpochArray.begin (); it != fSuperEpochArray.end (); it++) - { - LOG(debug) << "There have been " << it->second << " SuperEpochs for Afck" - << it->first.first << "_Spadic" << it->first.second - << " in this file"; - - } - - gDirectory->mkdir (this->GetName ()); - gDirectory->Cd (this->GetName ()); - fHm->WriteToFile (); - FairRootManager::Instance ()->GetOutFile ()->cd (); - -} - -/* - void CbmTSUnpackSpadic20::Register() - { - } -*/ - -ClassImp(CbmTSUnpackSpadic20) - diff --git a/beamtime/cern2014/unpacker/CbmTSUnpackSpadic20.h b/beamtime/cern2014/unpacker/CbmTSUnpackSpadic20.h deleted file mode 100644 index 9e33c1eb7d6f0ce865f012fe5e7ed9140dad0c21..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/unpacker/CbmTSUnpackSpadic20.h +++ /dev/null @@ -1,135 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmTSUnpackSpadic ----- -// ----- Created 07.11.2014 by F. Uhlig ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CBMTSUNPACKSPADIC20_H -#define CBMTSUNPACKSPADIC20_H - -#include "Timeslice.hpp" -#include "Message.hpp" - - -#include "CbmTSUnpack.h" -#include "CbmBeamDefaults.h" -#include <map> - -#include "TClonesArray.h" - -#include "CbmHistManager.h" - - -#include <vector> -#include <array> - -class CbmTSUnpackSpadic20 : public CbmTSUnpack -{ - protected: - CbmHistManager* fHm; - - public: - - CbmTSUnpackSpadic20(); - virtual ~CbmTSUnpackSpadic20(); - - virtual Bool_t Init(); - - void CreateHistograms(); - virtual Bool_t DoUnpack(const fles::Timeslice& ts, size_t component); - void print_message(const spadic::Message& m); - - virtual void Reset(); - - virtual void Finish(); - - void SetParContainers() {;} - - // protected: - // virtual void Register(); - - /** - * A structure to store a hit message with some of its information. - * Used for reconstruction of multihits. - * Multimessage hits (b_multiFlag = true) are flagged with StopType 10. - */ - struct hit_object{ - //attributes - Int_t triggerType; /**< TriggerType of the hit.*/ - Int_t stopType; /**< StopType of the hit.*/ - Int_t nrSamples; /**< Number of samples of the hit.*/ - Bool_t b_complete; /**< = true, if the hit was corrected and is complete for Digi creation.*/ - Bool_t b_multiFlag; /**< = true, if the hit is a corrected multimessage. (For QA)*/ - Int_t time; /**< Timestamp of the hit.*/ - ULong_t fullTime; /**< Fulltime of the hit.*/ - std::array<Short_t,32> samples; /**< Samples of the hit.*/ - - }; - - /** - * Handling of a hit identified as a successor of a multihit. - * @param link Link of the successor hit. (E-Link of SPADIC) - * @param addr Address of the successor hit. (Address of AFCK) - * @param channel Channel of the successor hit. (Channel on SPADIC) - * @param currHit Hit object of the successor hit containing its data. - * @return Edited successor hit object. - * */ - hit_object correct_successor(Int_t link, Int_t addr, Int_t channel, hit_object currHit); - - /** - * Handling of a hit identified as a predecessor of a multihit. - * @param link Link of the predecessor hit. (E-Link of SPADIC) - * @param addr Address of the predecessor hit. (Address of AFCK) - * @param channel Channel of the predecessor hit. (Channel on SPADIC) - * @param currHit Hit object of the predecessor hit containing its data. - * @return Edited predecessor hit object. - * */ - hit_object correct_predecessor(Int_t link, Int_t addr, Int_t channel, hit_object currHit); - - - virtual void FillOutput(boost::any){;} - private: - - TClonesArray* fSpadicRaw; - - std::map<std::pair<int,int>,int> fEpochMarkerArray; -//Array to store the previous Epoch counter - std::map<std::pair<int,int>,int> fPreviousEpochMarkerArray; -//Suppress multiple Epoch Messages in duplicated Microslices. NOTE:Currently Buggy - const Bool_t SuppressMultipliedEpochMessages = false; - std::map<std::pair<int,int>,int> fSuperEpochArray; - - Int_t fEpochMarker; - Int_t fSuperEpoch; - Int_t fNrExtraneousSamples; - - ULong_t n_hit = 0; - ULong_t n_multihit_pre = 0; - ULong_t n_multihit_succ = 0; - ULong_t n_multimessage_pre = 0; - ULong_t n_multimessage_succ = 0; - ULong_t n_final_multimessage = 0; - ULong_t n_final_hit = 0; - ULong_t n_zeroSample = 0; - ULong_t n_pre = 0; - ULong_t n_succ = 0; - ULong_t n_finalMultiMessage = 0; - - void GetEpochInfo(Int_t link, Int_t addr); - void FillEpochInfo(Int_t link, Int_t addr, Int_t epoch_count); - - CbmTSUnpackSpadic20(const CbmTSUnpackSpadic20&); - CbmTSUnpackSpadic20 operator=(const CbmTSUnpackSpadic20&); - - - //Buffer of hit_objects, which are identified as predecessors of multihits. - std::map<std::pair<int,int>,std::map<uint16_t, hit_object> > multihit_buffer; - - ClassDef(CbmTSUnpackSpadic20, 2) - - -}; - -#endif - diff --git a/beamtime/cern2014/unpacker/CbmTSUnpackSpadic20DesyOnlineMonitor.cxx b/beamtime/cern2014/unpacker/CbmTSUnpackSpadic20DesyOnlineMonitor.cxx deleted file mode 100644 index 95f171d4a54d4c8a97f6528cdb80dd7534e75d77..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/unpacker/CbmTSUnpackSpadic20DesyOnlineMonitor.cxx +++ /dev/null @@ -1,1362 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmTSUnpackSpadic20OnlineMonitor ----- -// ----- Created 07.11.2014 by F. Uhlig ----- -// ----- ----- -// ----------------------------------------------------------------------------- -#include "CbmTSUnpackSpadic20DesyOnlineMonitor.h" - -#include "CbmSpadicRawMessage.h" - -#include "TimesliceReader20.hpp" -#include "Timeslice.hpp" - -#include "Message.hpp" - -#include "FairLogger.h" -#include "FairRootManager.h" - -#include "TClonesArray.h" - -#include "CbmHistManager.h" -#include "TCanvas.h" -#include "TH1.h" -#include "TH2.h" -#include "TH3.h" -#include "TMultiGraph.h" -#include "TMath.h" -#include "FairRun.h" -#include "FairRunOnline.h" -#include "THttpServer.h" - -#include <iostream> -#include <map> -#include <vector> - - - -CbmTSUnpackSpadic20DesyOnlineMonitor::CbmTSUnpackSpadic20DesyOnlineMonitor(Bool_t highPerformance) - : CbmTSUnpack(), - fSpadicRaw(new TClonesArray("CbmSpadicRawMessage", 10)), - fHighPerformance(highPerformance), - fEpochMarkerArray(), - fPreviousEpochMarkerArray(), - fSuperEpochArray(), - fEpochMarker(0), - fSuperEpoch(0), - fNrExtraneousSamples{0}, - fHM(new CbmHistManager()), - fcB(NULL), - fcM(NULL), - fcH(NULL), - fcL(NULL), - fcE(NULL), - fcO(NULL), - fcS(NULL), - fcI(NULL), - fcTS(NULL), - fcF(NULL), - fcSp(NULL), - fcPS{NULL}, - fcMS{NULL}, - fcSy{NULL}, - fcNS{nullptr}, - fcTH{nullptr}, - fcAS(NULL), - fcA{NULL}, - fcES{nullptr}, - fcHC{nullptr}, - fBaseline{NULL}, - fmaxADCmaxTimeBin{NULL}, - fHit{NULL}, - fHitChannel{NULL}, - fLost{NULL}, - fEpoch{NULL}, - fOutOfSync{NULL}, - fStrange{NULL}, - fInfo{NULL}, - fHitTimeA{NULL}, - fHitTimeB{NULL}, - fHitFrequency{NULL}, - fSpectrum{NULL}, - fPulseShape{NULL}, - fMessageStatistic{NULL}, - fHitSync{NULL}, - fNrSamples{NULL}, - fTimeBetweenHits{NULL}, - fADCmaxSum{NULL}, - fTSGraph{NULL}, - fLastSuperEpochA{0}, - fLastSuperEpochB{0}, - fLastFullTime{{{0}}}, - fHitsTrd0{{}}, - fHitsTrd1{{}}, - fHitsTrd1n{{}}, - fHitsTrd2{{}}, - fLastTimeGlobal{0}, - fThisTime{0}, - fAlignmentCounter0{0}, - fAlignmentCounter1{0}, - fAlignmentCompareCounter{0}, - fAlignmentCompareCounter1{0}, - fLastTimes{}, - fMessageTypes{"Epoch", - "Epoch out of synch", - "Hit", - "Hit aborted", - "Info", - "Overflow", - "Strange"}, - fTriggerTypes{ "Global trigger", - "Self triggered", - "Neighbor triggered", - "Self and neighbor triggered"}, - fClusterSwitch{}, - fMaxSum{}, - fLastTrigger{}, - fLastChannel{}, - fStopTypes{"Normal end of message", - "Channel buffer full", - "Ordering FIFO full", - "Multi hit", - "Multi hit and channel buffer full", - "Multi hit and ordering FIFO full"}, - fInfoTypes{"Channel disabled during message building", - "Next grant timeout", - "Next request timeout", - "New grant but channel empty", - "Corruption in message builder", - "Empty word", - "Epoch out of sync"}, - fAlignments{"0_1", - "1_2", - "2_3"}, - fChambers{"0", - "1", - "2", - "3"}, - // fAFCKs{24465,0x1889,43522,43523}, // Insert AFCK Adresses!!!!!!!!! 6281 22465 - fAFCKs{43520,43521,43522,43523}, // Insert AFCK Adresses!!!!!!!!! 6281 22465 - fSource{-1}, - fLastSource{-1}, - fFillCounter{0}, - fSyncChambers{NULL}, - fEventSelection{NULL}, - fAlignment{NULL}, - fMaxADC{NULL} -{ -// for (Int_t i=0; i < NrOfAfcks; ++i) { -// for (Int_t j=0; j < NrOfHalfSpadics; ++j) { -// fEpochMarkerArray[i][j] = 0; -// fPreviousEpochMarkerArray[i][j] =0; -// fSuperEpochArray[i][j] = 0; -// } -// } -// } - fLastTimeGlobal=0; - fThisTime=0; - fSource=-1; - fLastSource=-1; - fAlignmentCounter0=0; - fAlignmentCounter1=0; - fAlignmentCompareCounter=0; - fFillCounter=0; - InitHistos(); - InitCanvas(); -} - -CbmTSUnpackSpadic20DesyOnlineMonitor::~CbmTSUnpackSpadic20DesyOnlineMonitor() -{ - LOG(info) << "Number of extraneous Samples "<< fNrExtraneousSamples; -} - -Bool_t CbmTSUnpackSpadic20DesyOnlineMonitor::Init() -{ - LOG(info) << "Initializing"; - - FairRootManager* ioman = FairRootManager::Instance(); - if (ioman == NULL) { - LOG(fatal) << "No FairRootManager instance"; - } - ioman->Register("SpadicRawMessage", "spadic raw data", fSpadicRaw, kTRUE); - return kTRUE; -} - - - -Bool_t CbmTSUnpackSpadic20DesyOnlineMonitor::DoUnpack(const fles::Timeslice& ts, size_t component) -{ - // compare to: https://github.com/spadic/spadic10-software/blob/master/lib/message/message.h - // or fles/spadic/message/wrap/cpp/message.cpp - LOG(debug) << "Unpacking Spadic Data"; - Int_t link = 0; - // TH2I* h = NULL; (VF) not used - TString cName; - - LOG(debug) << "Timeslice contains " << ts.num_microslices(component) - << "microslices."; - - // std::cout << "Timeslice contains " << ts.num_microslices(component) << std::endl; //only turned off for debugging!! - - //printf("Component: %i Num MS: %i \n", component, ts.num_microslices(component)); - - // Timeslice reader for spadic 2.0 - //spadic::TimesliceReader20 tsReader; - //tsReader.add_component(ts, component); - /* - for (auto addr : tsReader.sources()) { - std::cout << "---- reader " << addr << " ----" << std::endl; - while (auto mp = tsReader.get_message(addr)) { - //print_message(*mp); - auto& s = mp->samples(); - if ( mp->is_info() ) - std::cout << " This is a info message" << std::endl; - printf("Group: %i Ch: %i Ts: %i Samples: %i Trace: ", mp->group_id(), mp->channel_id(), mp->timestamp(), s.size()); - for(int i = 0; i < s.size(); i++) - printf(" %02i,", s[i]); - printf("\n"); - // Process the Spadic 2.0 message ;) - } - } - */ - - //Int_t link = ts.descriptor(component, 0).eq_id; - //printf("Link: %x\n", link); - //Int_t address = addr; - - Int_t address = 0; // Fake the addr for now - //Int_t addr = 0; // Fake! - Int_t counter=0; - /* - // Loop over microslices - //for (size_t m = 0; m < ts.num_microslices(component); ++m){ - for (size_t m {0}; m < ts.num_microslices(component); m++){ - - //spadic::MessageReader r; - - //std::vector<uint16_t> buf0; - //std::vector<uint16_t> buf1; - // std::vector<uint16_t> buf2; - // std::vector<uint16_t> buf3; - //buf0.reserve(20000); - //buf1.reserve(20000); - - // Get the microslice - //auto mc = ts.get_microslice(component, m); - //auto mv = reinterpret_cast<const fles::MicrosliceView&>(mc); - //auto mv_p = reinterpret_cast<const uint16_t *>(mv.content()); // Pointer to the data - //auto mv_s = mv.desc().size * sizeof(*mv.content()) / sizeof(*mv_p); // Size - - //printf("Component: %x\n", component); - - for(auto p=0; p<mv_s; p++){ - printf("%04x ", mv_p[p]); - } - printf("\n"); - - //continue; - - //const uint64_t* pInBuff = reinterpret_cast<const uint64_t*>( mv_p ); - - // ---------------- - // Get the microslice - - auto msDescriptor = ts.descriptor(component, m); // mc - Int_t fEquipmentId = msDescriptor.eq_id; - //auto msContent = reinterpret_cast<const uint16_t*>(ts.content(component, m)); - const uint8_t* msContent = ts.content(component, m); - auto s = msDescriptor.size * sizeof(*msContent) / sizeof(*msContent); - const uint64_t* pInBuff = reinterpret_cast<const uint64_t*>( msContent ); - - for (auto uIdx = 0; uIdx < s; uIdx ++){ - //for (auto uIdx = 0; uIdx < mv_s; uIdx ++){ - uint64_t ulData = static_cast<uint64_t>( pInBuff[uIdx] ); - //uint64_t ulData = static_cast<uint64_t>( mv_p[uIdx] ); - //auto ulData = mv_p[uIdx]; - //printf("%016x ", ulData); - uint16_t afck_id = (ulData & 0xffff000000000000) >> 48; - // Last 2bytes of mac addr of the afck, hard coded now for sps2016 - //if(afck_id != 0x5b9d) //IRI AFCK - //if(afck_id != 0x187f) // IKF 217 - //if(afck_id != 0x5f91 && afck_id != 1889){ // if not from AFCK 0 or AFCK 1 - - - if(afck_id != 0x5f91){ // if not from AFCK 0 - //continue; - } - - //uint64_t ulData = static_cast<uint64_t>( pInBuff[uIdx] ); - uint8_t downlink_header = (ulData & 0xf00000) >> 20; - uint8_t downlink_nr = (ulData & 0xf0000) >> 16; - uint16_t payload = ulData & 0xffff; - //if(downlink_header != 0xa) - // std::cout << "Corruption in downlink header found" << std::endl; - - //printf("%04x : %04X\n", afck_id, payload); - - // Put the data in a buffer - //if(downlink_nr == 0) - // buf0.push_back(payload); - //else if(downlink_nr == 1) - // buf1.push_back(payload); - } - } -*/ - // This is not nice... quick n' dirty - //std::move(buf1.begin(), buf1.end(), std::back_inserter(buf0)); - //r.add_buffer(buf0.data() , buf0.size()); - //r.add_buffer(buf1.data() , buf1.size()); - // r.add_buffer(buf2.data() , buf2.size()); - // r.add_buffer(buf3.data() , buf3.size()); - - - spadic::TimesliceReader20 tsReader; - tsReader.add_component(ts, component); - for (auto addr : tsReader.sources()) { - // std::cout << "---- reader " << std::hex << addr << " ----comp " << std::hex << component<< std::endl; - - while (auto m = tsReader.get_message(addr)) { - // Int_t SpadicAddress = tsReader.get_link(addr)/(256*8); - // if((int)tsReader.get_link(addr)== 1024){ - // printf("Double Hit noticed! tsReader.get_link(addr): %i \n", tsReader.get_link(addr)); - // continue; - // } - Int_t groupId = (((int)tsReader.get_link(addr))%2048)/256; - Int_t SpadicAddress = tsReader.get_link(addr)/2048; - Int_t HalfSpadicAddress = 2*SpadicAddress + groupId; - Int_t AfckAddress = ts.descriptor(component,0).eq_id; - - - //groupId = 0; - /* if ( (SpadicAddress) == 0x0c00 ){ - std::cout << "False addr" <<std::endl; - continue; - }*/ - // Int_t AfckAddress = addr - tsReader.get_link(addr)/256; - // Int_t AfckAddress = 9000; - //std::cout << addr << " " <<tsReader.get_link(addr) << " " <<std::endl; - /* if ((AfckAddress == 6289) or (AfckAddress == 6290)){ - AfckAddress = 6281; - }else{ AfckAddress = 0; - } - */ - Int_t AfckID = -1; - for(int i = 0; i < 4; i++){ - if (AfckAddress == fAFCKs[i]){ - AfckID = i; - break; - } - } - - // AfckID = 0; - - link = ts.descriptor(component, 0).eq_id; - // printf("Addr: %x, AfckID: %i, Spadic Address: %i, Group ID: %i, tsReader.get_link(addr): %x, Eq Id: %x", addr, AfckID, SpadicAddress, groupId, tsReader.get_link(addr),ts.descriptor(component, 0).eq_id); - // printf("\n"); - - // @FIXME - - // std::cout << std::hex << link << std::endl; - //} // End microslice - - Bool_t isInfo(false), isHit(false), isEpoch(false), isEpochOutOfSync(false), isOverflow(false), isHitAborted(false), isStrange(false); - - //while(auto m = r.get_message()) { - - - if(m->is_hit()){ - // auto& s = m->samples(); (VF) not used - GetEpochInfo(HalfSpadicAddress, AfckID); - - // Fill some nice histos - fSource = AfckID * NrOfSpadics + (Int_t)(SpadicAddress); - Int_t triggerType = static_cast<Int_t>(m->hit_type()); - Int_t stopType = static_cast<Int_t>(m->stop_type()); - Int_t time = m->timestamp(); - fThisTime= ((fEpochMarker << 12) + time); - // printf("Timestamp: %i, Epoch: %i, fThisTime: %i \n", time, fEpochMarker, fThisTime); - Int_t infoType = -1; - Int_t channel = m->channel_id(); - // Int_t groupId = m->group_id(); - //std::cout << "GROUP ID "<< groupId <<std::endl; - Int_t bufferOverflowCounter = 0; - Int_t samples = m->samples().size(); - Int_t padRow(-1); - Int_t padChannel = GetChannelOnPadPlane(channel,groupId); - Int_t counter1=0; - Int_t maxADC(-256), maxTB(-1); - // Int_t maxADCsum(-256); (VF) not used - // Int_t adc(-256); (VF) not used - // Int_t base(-256); (VF) not used - // ULong_t timediff= fThisTime-fLastTimes[fSource]; (VF) not used - // Bool_t fillCluster=kFALSE; (VF) not used - Int_t* sample_values = new Int_t[samples]; - // Int_t baseline=-1; (VF) not used - // printf("Afck Address: %i Source : %i \n", AfckAddress, fSource); - // if(samples == 0){ - // continue;} - if((triggerType == 1) or (triggerType == 0)){ - for (auto x : m->samples()) { - sample_values[counter1] = static_cast<int>(x); - //if (!fHighPerformance) - fPulseShape[(fSource)*32+channel+16*(groupId%2) ]->Fill(counter1,x); - if(counter1==0) fBaseline[fSource]->Fill(x,groupId*16+channel); - //fPulseShape[channel+16*(groupId%2)]->Fill(counter1,x); - //} - if (x > maxADC){ - maxADC = x; - maxTB = counter1; - } - ++counter1; - } - // fMaxADC[(fSource)*32+channel+16*(groupId%2)]->Fill(maxADC); - } - new( (*fSpadicRaw)[fSpadicRaw->GetEntriesFast()] ) - CbmSpadicRawMessage(link, address, channel, fEpochMarker, time, - fSuperEpoch, triggerType, infoType, stopType, groupId, - bufferOverflowCounter, samples, sample_values, - isHit, isInfo, isEpoch, isEpochOutOfSync, isHitAborted, isOverflow, isStrange); - static ULong_t firstTimeStamp=0; - if(firstTimeStamp==0){ - // firstTimeStamp=raw->GetFullTime(); - } - - - // printf("Source: %i, AFCK Address: %i, AFCK Id: %i, SPADIC Address: %i Ch: %i Ts: %i hit type: %i Stop type: %i Samples: %i Trace: ADCmax: %i Trigger: %i Base: %i \n", fSource, AfckAddress, AfckID, SpadicAddress, m->channel_id(), m->timestamp(), m->hit_type(), m->stop_type(), s.size(), maxADCsum, triggerType, base); - // printf("Channel: %i, Group ID: %i \n", channel, groupId); - - - // Nasty look on messages from all available channels here. - // Only filled within one epoch. Therefore: regress of time will declare the histo as finished. - if(time < maxTime){ - syncHistFinished = true; - } - - // Here it is: its only processed and filled as long as not declared as finished. - if(!syncHistFinished){ - maxTime = time; // lets bookkeep the highest time value we've seen so far - if(first){ // just in case we are using ULong_t FullTime for the time info, - // its worth to store what was the time of the very first message in this histo. - startTime = time; - } - fHitSync[fSource]->Fill(time, groupId*16+channel); // when startTime should be used, its x=time-startTime here - } - - - - //MaxADC vs Max TimeBin Histo - fmaxADCmaxTimeBin[fSource]->Fill(maxTB,maxADC); - - - //Nr of Samples vs Stop Type Histo - fNrSamples[fSource]->Fill(samples,stopType); - - // Sync of Chambers Histo - fSyncChambers[0]->Fill(fThisTime-fLastTimeGlobal,fSource); // not sure if this gives us the right Number of the Chamber - fLastTimeGlobal=fThisTime; - - //Time between Hits Histo - fTimeBetweenHits[fSource]->Fill(fThisTime-fLastTimes[fSource]); - - - //Information for the next message - fLastTimes[fSource]=fThisTime; - fLastTrigger[fSource]=triggerType; - fLastChannel[fSource]=channel; - - - //Hitmap Histo - if (padChannel > 15){ - padChannel -= 16; - padRow = 1; - } else { - padRow = 0; - } - fHit[fSource]->Fill(padChannel,padRow); - fHitChannel[fSource]->Fill(channel,groupId); - // printf("fSource: %i, Group ID: %i \n", fSource, groupId); - //Max ADC Spectrum - fMaxADC[channel+16*(groupId%2)]->Fill(maxADC); - cName.Form("SysCore_%i_Spadic_%i",0,0); - //h = (TH2I*)fHM->H2(TString("Baseline_"+cName).Data()); - //h->Fill(sample_values[0],groupId*16+channel); - /* - if(sample_values[0] !=0) - fBaseline[fSource]->Fill( m->samples()[0],groupId*16+channel); - */ - - // Alignment Histo 0_1 marker1 - if((triggerType == 1) or (triggerType == 3)){ - if((fSource == 0) or (fSource == 3)){ - if (fLastSource == fSource){ - if (fSource == 0){ // Source 0 should correspond to TRD0 - fHitsTrd0[fAlignmentCounter0][0] = fThisTime; - // printf("This Time: %i \n", fThisTime); - fHitsTrd0[fAlignmentCounter0][1] = padChannel + 16 * padRow; // channel+16*(groupId%2); - // printf("Hit bei fSource = 0, Time: %i, AlignmentCounter: %i, Pad: %i, Channel: %i \n", fHitsTrd0[fAlignmentCounter0][0] ,fAlignmentCounter0, padChannel, channel+16*(groupId%2)); - fAlignmentCounter0++; - } else if (fSource == 3){ // Source 3 should correspond to TRD1 - fHitsTrd1[fAlignmentCounter0][0] = fThisTime; - // printf("This Time: %i \n", fThisTime); - fHitsTrd1[fAlignmentCounter0][1] =padChannel + 16 * padRow; // channel+16*(groupId%2); - // printf("Hit bei fSource = 3, Time: %i, AlignmentCounter: %i, Pad: %i Channel: %i \n", fHitsTrd1[fAlignmentCounter0][0],fAlignmentCounter0, padChannel, channel+16*(groupId%2)); - fAlignmentCounter0++; - } - } else { - // Now both Alignment Arrays have to be compared - fAlignmentCompareCounter=0; - if(fLastSource == 0){ - // printf("Last Source was 0, starting comparison! \n"); - // printf("Alignment Counter: %i fSource: %i fLastSource: %i, AlignmentCompareCounter: %i \n", fAlignmentCounter0, fSource, fLastSource, fAlignmentCompareCounter); - // for(int i=0; i < fAlignmentCounter0; i++){ - // printf("fHitsTrd0: %i, Channel: %i, fHitsTrd1: %i, Channel: %i \n", fHitsTrd0[i][0], fHitsTrd0[i][1], fHitsTrd1[i][0], fHitsTrd1[i][1]); - // } - for(ULong_t i=0; i < fAlignmentCounter0; i++){ - // printf(" fHitsTrd0: %i, fHitsTrd1: %i, AlignmentCompareCounter: %i, i: %i \n",fHitsTrd0[i][0],fHitsTrd1[fAlignmentCompareCounter][0], fAlignmentCompareCounter, i); - while(fHitsTrd0[i][0] > fHitsTrd1[fAlignmentCompareCounter][0]){ - fAlignmentCompareCounter++; - if(fAlignmentCompareCounter <10){ - // printf("INCREASING AlignmentCompareCounter"); - } - } - if (fHitsTrd0[i][0] == fHitsTrd1[fAlignmentCompareCounter][0]){ - fAlignment[0]->Fill(fHitsTrd0[i][1],fHitsTrd1[fAlignmentCompareCounter][1]); - // printf("Coincidence at Channels: %i and %i! \n",fHitsTrd0[i][1],fHitsTrd1[fAlignmentCompareCounter][1]); - // printf("At Time: %i = %i \n", fHitsTrd0[i][0], fHitsTrd1[fAlignmentCompareCounter][0]); - } - } - for(ULong_t i = 0; i <= fAlignmentCounter0; i++){ - fHitsTrd1[i][0]=0; - } - fHitsTrd0[0][0] = fThisTime; - fHitsTrd0[0][1] =padChannel + 16 * padRow; // channel+16*(groupId%2); - //fAlignmentCounter0++; - } - if(fLastSource == 3){ - // printf("Last Source was 3, starting comparison! \n"); - // printf("Alignment Counter: %i fSource: %i fLastSource: %i, AlignmentCompareCounter: %i \n", fAlignmentCounter0, fSource, fLastSource, fAlignmentCompareCounter); - // for(int i=0; i < fAlignmentCounter0; i++){ - // printf("fHitsTrd0: %i, Channel: %i, fHitsTrd1: %i, Channel: %i \n", fHitsTrd0[i][0], fHitsTrd0[i][1], fHitsTrd1[i][0], fHitsTrd1[i][1]); - // } - for(ULong_t i=0; i < fAlignmentCounter0; i++){ - // printf(" fHitsTrd0: %i, fHitsTrd1: %i, AlignmentCompareCounter: %i, i: %i \n",fHitsTrd0[fAlignmentCompareCounter][0],fHitsTrd1[i][0], fAlignmentCompareCounter, i); - while(fHitsTrd1[i][0] > fHitsTrd0[fAlignmentCompareCounter][0]){ - fAlignmentCompareCounter++; - if(fAlignmentCompareCounter <10){ - // printf("INCREASING AlignmentCompareCounter"); - } - } - if (fHitsTrd1[i][0] == fHitsTrd0[fAlignmentCompareCounter][0]){ - fAlignment[0]->Fill(fHitsTrd0[fAlignmentCompareCounter][1],fHitsTrd1[i][1]); - // printf(" fHitsTrd0: %i, fHitsTrd1: %i \n",fHitsTrd0[fAlignmentCompareCounter][0],fHitsTrd1[i][0]); - // printf("Coincidence at Channels: %i and %i! \n",fHitsTrd0[fAlignmentCompareCounter][1],fHitsTrd1[i][1]); - // printf("At Time: %i = %i \n", fHitsTrd0[fAlignmentCompareCounter][0], fHitsTrd1[i][0]); - } - } - for(ULong_t i = 0; i <= fAlignmentCounter0; i++){ - fHitsTrd0[i][0]=0; - } - fHitsTrd1[0][0] = fThisTime; - fHitsTrd1[0][1] = padChannel + 16 * padRow; // channel+16*(groupId%2); - // fAlignmentCounter0++; - } - fLastSource = fSource; - fAlignmentCounter0 = 1; - } - } - } - - - - - - //Alignment Histo 1_2 - - // if((triggerType == 1) or (triggerType == 3)){ - // if((fSource == 3) or (fSource == 6)){ - // if (fLastSource == fSource){ - // if (fSource == 3){ // Source 3 should correspond to TRD1 - // fHitsTrd1n[fAlignmentCounter1][0] = fThisTime; - // fHitsTrd1n[fAlignmentCounter1][1] = padChannel + 16 * padRow; // channel+16*(groupId%2); - // // printf("Hit bei fSource = 0, Time: %i, AlignmentCounter: %i, Pad: %i, Channel: %i \n", fHitsTrd0[fAlignmentCounter1][0] ,fAlignmentCounter1, padChannel, channel+16*(groupId%2)); - // fAlignmentCounter1++; - // } else if (fSource == 6){ // Source 3 should correspond to TRD1 - // fHitsTrd2[fAlignmentCounter1][0] = fThisTime; - // fHitsTrd2[fAlignmentCounter1][1] =padChannel + 16 * padRow; // channel+16*(groupId%2); - // // printf("Hit bei fSource = 3, Time: %i, AlignmentCounter: %i, Pad: %i Channel: %i \n", fHitsTrd1[fAlignmentCounter1][0],fAlignmentCounter1, padChannel, channel+16*(groupId%2)); - // fAlignmentCounter1++; - // } - // } else { - // // Now both Alignment Arrays have to be compared - // fAlignmentCompareCounter=0; - // if(fLastSource == 3){ - // // printf("Last Source was 0, starting comparison! \n"); - // // printf("Alignment Counter: %i fSource: %i fLastSource: %i, AlignmentCompareCounter: %i \n", fAlignmentCounter1, fSource, fLastSource, fAlignmentCompareCounter); - // // for(int i=0; i < fAlignmentCounter1; i++){ - // // printf("fHitsTrd0: %i, Channel: %i, fHitsTrd1: %i, Channel: %i \n", fHitsTrd0[i][0], fHitsTrd0[i][1], fHitsTrd1[i][0], fHitsTrd1[i][1]); - // // } - // for(int i=0; i < fAlignmentCounter1; i++){ - // // printf(" fHitsTrd0: %i, fHitsTrd1: %i, AlignmentCompareCounter: %i, i: %i \n",fHitsTrd0[i][0],fHitsTrd1[fAlignmentCompareCounter][0], fAlignmentCompareCounter, i); - // while(fHitsTrd1n[i][0] > fHitsTrd2[fAlignmentCompareCounter][0]){ - // fAlignmentCompareCounter++; - // if(fAlignmentCompareCounter <10){ - // // printf("INCREASING AlignmentCompareCounter"); - // } - // } - // if (fHitsTrd1n[i][0] == fHitsTrd2[fAlignmentCompareCounter][0]){ - // fAlignment[1]->Fill(fHitsTrd1n[i][1],fHitsTrd2[fAlignmentCompareCounter][1]); - // // printf("Coincidence at Channels: %i and %i! \n",fHitsTrd0[i][1],fHitsTrd1[fAlignmentCompareCounter][1]); - // // printf("At Time: %i = %i \n", fHitsTrd0[i][0], fHitsTrd1[fAlignmentCompareCounter][0]); - // } - // } - // for(int i = 0; i <= fAlignmentCounter1; i++){ - // fHitsTrd2[i][0]=0; - // } - // fHitsTrd1n[0][0] = fThisTime; - // fHitsTrd1n[0][1] =padChannel + 16 * padRow; // channel+16*(groupId%2); - // //fAlignmentCounter1++; - // } - // if(fLastSource == 6){ - // // printf("Last Source was 3, starting comparison! \n"); - // // printf("Alignment Counter: %i fSource: %i fLastSource: %i, AlignmentCompareCounter: %i \n", fAlignmentCounter1, fSource, fLastSource, fAlignmentCompareCounter); - // // for(int i=0; i < fAlignmentCounter1; i++){ - // // printf("fHitsTrd0: %i, Channel: %i, fHitsTrd1: %i, Channel: %i \n", fHitsTrd0[i][0], fHitsTrd0[i][1], fHitsTrd1[i][0], fHitsTrd1[i][1]); - // // } - // for(int i=0; i < fAlignmentCounter1; i++){ - // // printf(" fHitsTrd0: %i, fHitsTrd1: %i, AlignmentCompareCounter: %i, i: %i \n",fHitsTrd0[fAlignmentCompareCounter][0],fHitsTrd1[i][0], fAlignmentCompareCounter, i); - // while(fHitsTrd2[i][0] > fHitsTrd1n[fAlignmentCompareCounter][0]){ - // fAlignmentCompareCounter++; - // if(fAlignmentCompareCounter <10){ - // // printf("INCREASING AlignmentCompareCounter"); - // } - // } - // if (fHitsTrd2[i][0] == fHitsTrd1n[fAlignmentCompareCounter][0]){ - // fAlignment[1]->Fill(fHitsTrd1n[fAlignmentCompareCounter][1],fHitsTrd2[i][1]); - // // printf(" fHitsTrd0: %i, fHitsTrd1: %i \n",fHitsTrd0[fAlignmentCompareCounter][0],fHitsTrd1[i][0]); - // // printf("Coincidence at Channels: %i and %i! \n",fHitsTrd0[fAlignmentCompareCounter][1],fHitsTrd1[i][1]); - // // printf("At Time: %i = %i \n", fHitsTrd0[fAlignmentCompareCounter][0], fHitsTrd1[i][0]); - // } - // } - // for(int i = 0; i <= fAlignmentCounter1; i++){ - // fHitsTrd1n[i][0]=0; - // } - // fHitsTrd2[0][0] = fThisTime; - // fHitsTrd2[0][1] = padChannel + 16 * padRow; // channel+16*(groupId%2); - // // fAlignmentCounter1++; - // } - // fLastSource = fSource; - // fAlignmentCounter1 = 1; - // } - // } - // } - - - } - else if ( m->is_buffer_overflow() ){ - LOG(debug) << counter << " This is a buffer overflow message"; - isOverflow = true; - //GetEpochInfo(link, addr); - Int_t triggerType = -1; - Int_t infoType = -1; - Int_t stopType = -1; - // Int_t groupId = m->group_id(); - Int_t channel = m->channel_id(); - Int_t time = m->timestamp(); - Int_t bufferOverflowCounter = static_cast<Int_t>(m->buffer_overflow_count()); - Int_t samples = 1; - Int_t* sample_values = new Int_t[samples]; - sample_values[0] = -256; - - new( (*fSpadicRaw)[fSpadicRaw->GetEntriesFast()] ) - CbmSpadicRawMessage(link, address, channel, fEpochMarker, time, - fSuperEpoch, triggerType, infoType, stopType, groupId, - bufferOverflowCounter, samples, sample_values, - isHit, isInfo, isEpoch, isEpochOutOfSync, isHitAborted, isOverflow, isStrange); - - delete[] sample_values; - fMessageStatistic[fSource]->Fill(fMessageTypes[5].Data(),bufferOverflowCounter); - channel = GetChannelOnPadPlane(channel,groupId); - if (channel > 15){ - channel-= 16; - groupId = 1; - } else { - groupId = 0; - } - fLost[fSource]->Fill(channel,groupId,bufferOverflowCounter); - new( (*fSpadicRaw)[fSpadicRaw->GetEntriesFast()] ) - CbmSpadicRawMessage(link, address, channel, fEpochMarker, time, - fSuperEpoch, triggerType, infoType, stopType, groupId, - bufferOverflowCounter, samples, sample_values, - isHit, isInfo, isEpoch, isEpochOutOfSync, isHitAborted, isOverflow, isStrange); - - } - - else if ( m->is_info() ){ - LOG(debug) << counter << " This is a info message"; - isInfo = true; - //GetEpochInfo(link, addr); - - Int_t triggerType = -1; - Int_t infoType = static_cast<Int_t>(m->info_type()); - Int_t stopType = -1; - // Int_t groupId = m->group_id(); - Int_t channel = m->channel_id(); - Int_t time = m->timestamp(); - Int_t bufferOverflowCounter = 0;//mp->buffer_overflow_count();// should be now obsolete - Int_t samples = 1; - Int_t* sample_values = new Int_t[samples]; - sample_values[0] = -256; - new( (*fSpadicRaw)[fSpadicRaw->GetEntriesFast()] ) - CbmSpadicRawMessage(link, address, channel, fEpochMarker, time, - fSuperEpoch, triggerType, infoType, stopType, groupId, - bufferOverflowCounter, samples, sample_values, - isHit, isInfo, isEpoch, isEpochOutOfSync, isHitAborted, isOverflow, isStrange); - delete[] sample_values; - fMessageStatistic[fSource]->Fill(fInfoTypes[infoType].Data(),1); - channel = GetChannelOnPadPlane(channel,groupId); - if (channel > 15){ - channel-= 16; - groupId = 1; - } else { - groupId = 0; - } - fInfo[fSource]->Fill(channel,groupId,1); - } - - - else if ( m->is_hit_aborted()) { - LOG(debug) << counter << " This is a hit message was aborted"; - isHitAborted = true; - // GetEpochInfo(link, addr); - Int_t triggerType = -1; - Int_t stopType = -1; - Int_t time = m->timestamp(); - Int_t infoType = -1; - // Int_t groupId = -1;//mp->group_id();//??? - Int_t bufferOverflowCounter = 0; - Int_t samples = 1; - Int_t* sample_values = NULL; - Int_t channel = m->channel_id(); - infoType = static_cast<Int_t>(m->info_type());// should here be stoptype instead??? - sample_values = new Int_t[samples]; - sample_values[0] = -256; - new( (*fSpadicRaw)[fSpadicRaw->GetEntriesFast()] ) - CbmSpadicRawMessage(link, address, channel, fEpochMarker, time, - fSuperEpoch, triggerType, infoType, stopType, groupId, - bufferOverflowCounter, samples, sample_values, - isHit, isInfo, isEpoch, isEpochOutOfSync, isHitAborted, isOverflow, isStrange); - //++counter; - delete[] sample_values; - fMessageStatistic[fSource]->Fill(fMessageTypes[3].Data(),1); - } - - else if ( m->is_epoch_marker() ) { - LOG(debug) << counter << " This is an Epoch Marker"; - isEpoch = true; - FillEpochInfo(HalfSpadicAddress, AfckID, m->epoch_count()); - GetEpochInfo(HalfSpadicAddress, AfckID); - Int_t triggerType = -1; - Int_t infoType = -1; - Int_t stopType = -1; - //Int_t groupId = mp->group_id(); - Int_t channel = m->channel_id(); - Int_t time = -1; - Int_t bufferOverflowCounter = 0; - Int_t samples = 1; - Int_t* sample_values = new Int_t[samples]; - sample_values[0] = -256; - new( (*fSpadicRaw)[fSpadicRaw->GetEntriesFast()] ) - CbmSpadicRawMessage(link, address, channel, fEpochMarker, time, - fSuperEpoch, triggerType, infoType, stopType, groupId, - bufferOverflowCounter, samples, sample_values, - isHit, isInfo, isEpoch, isEpochOutOfSync, isHitAborted, isOverflow, isStrange); - delete[] sample_values; - fMessageStatistic[AfckID * NrOfSpadics + SpadicAddress]->Fill(fMessageTypes[0].Data(),1); - if (!fHighPerformance)fEpoch[AfckID * NrOfSpadics + SpadicAddress]->Fill(channel,groupId,1); - } - - else { - isStrange = true; - //GetEpochInfo(link, addr); - Int_t triggerType = -1; - Int_t stopType = -1; - Int_t time = -1;//mp->timestamp(); - Int_t infoType = -1; - // Int_t groupId = -1;//mp->group_id(); - Int_t bufferOverflowCounter = 0; - Int_t samples = 1; - Int_t* sample_values = NULL; - Int_t channel = -1;//mp->channel_id(); - sample_values = new Int_t[samples]; - sample_values[0] = -256; - new( (*fSpadicRaw)[fSpadicRaw->GetEntriesFast()] ) - CbmSpadicRawMessage(link, address, channel, fEpochMarker, time, - fSuperEpoch, triggerType, infoType, stopType, groupId, - bufferOverflowCounter, samples, sample_values, - isHit, isInfo, isEpoch, isEpochOutOfSync, isHitAborted, isOverflow, isStrange); - //++counter; - delete[] sample_values; - // fMessageStatistic[fSource]->Fill(fMessageTypes[6].Data(),1); - //fStrange[fSource]->Fill(channel,groupId); - LOG(debug) << counter << " This message type is not hit, info, epoch or overflow and will not be stored in the TClonesArray"; - LOG(debug) << " valide:" << m->is_valid() << " epoch marker:" << fEpochMarker << " super epoch marker:" << fSuperEpoch << " time:" << time << " link:" << link << " address:" << address; - LOG(debug) << "Channel ID:" << m->channel_id(); - //if ( mp->is_hit_aborted() ) - //LOG(info) << "hit is aborted"; - //if ( mp->is_hit() ) - LOG(debug) << "GroupID:" << m->group_id() << "hit: triggerType:" << static_cast<Int_t>(m->hit_type()) << " stopType:" << static_cast<Int_t>(m->stop_type()) << " Nr.of samples:" << m->samples().size(); - - //if () - std::stringstream ss; - for (auto x : m->samples()) { - ss << " " << x; - } - LOG(debug) << ss.str(); - //if (mp->is_info()) - LOG(debug) << "InfoType:" << static_cast<Int_t>(m->info_type()); - //if () - LOG(debug) << "Nr. of overflows:" << static_cast<Int_t>(m->buffer_overflow_count()); - //print_message(mp); - } - } // while() - - } // tsReader - - return kTRUE; -} - -void CbmTSUnpackSpadic20DesyOnlineMonitor::print_message(const spadic::Message& m) -{ - printf("PrintMsg\n"); - LOG(info) << "v: " << (m.is_valid() ? "o" : "x"); - LOG(debug) << " / gid: " << static_cast<int>(m.group_id()); - LOG(debug) << " / chid: " << static_cast<int>(m.channel_id()); - if ( m.is_hit() ) { - LOG(debug) << " / ts: " << m.timestamp(); - LOG(debug) << " / samples (" << m.samples().size() << "):"; - std::stringstream ss; - for (auto x : m.samples()) { - ss << " " << x; - } - LOG(debug) << ss.str(); - } else { - if ( m.is_epoch_marker() ) { - LOG(debug) << " This is an Epoch Marker"; - } else if ( m.is_epoch_out_of_sync() ) { - LOG(info) << " This is an out of sync Epoch Marker"; - } else { - LOG(info) << " This is not known"; - } - } -} - - -void CbmTSUnpackSpadic20DesyOnlineMonitor::FillEpochInfo(Int_t HalfSpadicAddress, Int_t AfckID, Int_t epoch_count) -{ - - - if ( epoch_count < (fEpochMarkerArray[std::make_pair(HalfSpadicAddress,AfckID)] - 3000) ) - { - if(SuppressMultipliedEpochMessages) - if ( epoch_count != fPreviousEpochMarkerArray[std::make_pair(HalfSpadicAddress,AfckID)] ){ - fSuperEpochArray[std::make_pair(HalfSpadicAddress,AfckID)]++; - } else { - LOG(error)<< "Multiply repeated Epoch Messages at Super Epoch " - << fSuperEpoch << " Epoch " - << epoch_count << " for AFCK" - << AfckID << "_Half_Spadic" - << HalfSpadicAddress; - } - else fSuperEpochArray[std::make_pair(HalfSpadicAddress,AfckID)]++; - - LOG(debug) << "Overflow of EpochCounter for Syscore" - << AfckID << "Half_Spadic" - << HalfSpadicAddress; - } else if ((epoch_count - fEpochMarkerArray[std::make_pair(HalfSpadicAddress,AfckID)]) !=1 ) { - // LOG(info) << "Missed epoch counter for Syscore" - // << AfckID << "_Spadic" - // << HalfSpadicAddress; - } else if (epoch_count == fEpochMarkerArray[std::make_pair(HalfSpadicAddress,AfckID)]){ - LOG(error) << "Identical Epoch Counters for Syscore" - << AfckID << "_Spadic" - << HalfSpadicAddress; - } - fPreviousEpochMarkerArray[std::make_pair(HalfSpadicAddress,AfckID)] = fEpochMarkerArray[std::make_pair(HalfSpadicAddress,AfckID)]; - fEpochMarkerArray[std::make_pair(HalfSpadicAddress,AfckID)] = epoch_count; - - -} - -void CbmTSUnpackSpadic20DesyOnlineMonitor::GetEpochInfo(Int_t HalfSpadicAddress, Int_t AfckID) -{ - // printf("Get epoch info\n"); - - fEpochMarker = fEpochMarkerArray[std::make_pair(HalfSpadicAddress,AfckID)]; - fSuperEpoch = fSuperEpochArray[std::make_pair(HalfSpadicAddress,AfckID)]; - - - -} - -Int_t CbmTSUnpackSpadic20DesyOnlineMonitor::GetChannelOnPadPlane(Int_t SpadicChannel, Int_t groupId) -{ - if(SpadicChannel > 15 || groupId > 1) LOG(debug) << "CbmTSUnpackSpadic20DesyOnlineMonitor:: ChId " << SpadicChannel << " GroupId: " << groupId; - SpadicChannel = groupId * 16 + SpadicChannel; - Int_t channelMapping[32] = {31,15,30,14,29,13,28,12,27,11,26,10,25, 9,24, 8, - 23, 7,22, 6,21, 5,20, 4,19, 3,18, 2,17, 1,16, 0}; - if (SpadicChannel < 0 || SpadicChannel > 31){ - if (SpadicChannel !=-1) LOG(debug) << "CbmTSUnpackSpadic20DesyOnlineMonitor::GetChannelOnPadPlane ChId " << SpadicChannel << " GroupId: " << groupId; - return -1; - } else { - return channelMapping[SpadicChannel]; - } -} - -Int_t CbmTSUnpackSpadic20DesyOnlineMonitor::GetSpadicID(Int_t address) -{ - //TString spadic=""; - Int_t SpaId = -1; - switch (address) { - case (SpadicBaseAddress+0): // first spadic - //spadic="Spadic0"; - SpaId = 0; - break; - case (SpadicBaseAddress+1): // first spadic - //spadic="Spadic0"; - SpaId = 0; - break; - case (SpadicBaseAddress+2): // second spadic - //spadic="Spadic1"; - SpaId = 1; - break; - case (SpadicBaseAddress+3): // second spadic - //spadic="Spadic1"; - SpaId = 1; - break; - case (SpadicBaseAddress+4): // third spadic - //spadic="Spadic2"; - SpaId = 2; - break; - case (SpadicBaseAddress+5): // third spadic - //spadic="Spadic2"; - SpaId = 2; - break; - default: - LOG(error) << "Source Address " << address << " not known."; - break; - } - return SpaId; -} - -//Int_t CbmTSUnpackSpadic20DesyOnlineMonitor::GetAfckID(Int_t AfckAddress) // Fix me!! -//{ -// -// /* Int_t AfckID = -1; -// for(int i = 0; i < 4; i++) -// if (AfckAddress == fAFCKs[i]){ -// AfckID = i; -// } -// return AfckID; -// Int_t SyscoreID=link-BaseEquipmentID; -// if((SyscoreID<0||SyscoreID>3)){ -// LOG(debug) << "EqID " << link << " not known."; -// SyscoreID=-1; -// } -// return SyscoreID; -// */ -//} -// ---- ------------------------------------------------------- - - -inline TString CbmTSUnpackSpadic20DesyOnlineMonitor::GetSpadicName(Int_t /*link*/, - Int_t /*address*/){ - - TString spadicName=""; - Int_t SpadicID=0; - Int_t SpadicAddress = 0; - Int_t AfckID = 0; - spadicName="Afck_"+std::to_string(AfckID)+"_"; - SpadicID=SpadicAddress; - - //SpadicID/=2; - - spadicName += "Spadic_"; - - spadicName+=std::to_string(SpadicID); - - return spadicName; -} - -void CbmTSUnpackSpadic20DesyOnlineMonitor::InitHistos() -{ - - #ifdef USE_HTTP_SERVER - THttpServer* server = FairRunOnline::Instance()->GetHttpServer(); - #endif - - //cout << "InitHistos" << endl; - TString histName; - - // fHM->Add("DeltaT",new TH1I ("DeltaT","DeltaT",4001,-2000.5,2000.5)); - // fDeltaT[0]=(TH1I*)fHM->H1("DeltaT"); - - for (Int_t iLink = 0; iLink < NrOfAfcks; iLink++){ - for (Int_t iAddress = 0; iAddress < NrOfSpadics; iAddress++){ - - histName.Form("AFCK_%i_Spadic_%i",iLink,iAddress); - //histName.Form("AFCK_0_Spadic_0"); - - fHM->Add(TString("Time_between_Hits"+histName).Data(),new TH1D (TString("Time_between_Hits"+histName).Data(),TString("Time_between_Hits"+histName).Data(),8092,-0.5,8091.5)); - fTimeBetweenHits[(iLink)*(NrOfSpadics)+iAddress]=(TH1D*)fHM->H1(TString("Time_between_Hits"+histName).Data()); - fTimeBetweenHits[(iLink)*(NrOfSpadics)+iAddress]->GetXaxis()->SetTitle("Delta_Time"); - - fHM->Add(TString("Cluster_ADCmax_sum"+histName).Data(),new TH1I (TString("Cluster_ADCmax_sum"+histName).Data(),TString("Cluster_ADCmax_sum"+histName).Data(),1000,0.,1000.)); - fADCmaxSum[(iLink)*(NrOfSpadics)+iAddress]=(TH1I*)fHM->H1(TString("Cluster_ADCmax_sum"+histName).Data()); - fADCmaxSum[(iLink)*(NrOfSpadics)+iAddress]->GetXaxis()->SetTitle("ADCmax_Sum"); - - - fHM->Add(TString("Nr_Samples_vs_Stoptype"+histName).Data(),new TH2I (TString("Nr_Samples_vs_Stoptype"+histName).Data(),TString("Nr_Samples_vs_Stoptype"+histName).Data(),33,-0.5,32.5,6,-0.5,5.5)); - fNrSamples[(iLink)*(NrOfSpadics)+iAddress]=(TH2I*)fHM->H2(TString("Nr_Samples_vs_Stoptype"+histName).Data()); - fNrSamples[(iLink)*(NrOfSpadics)+iAddress]->GetXaxis()->SetTitle("Nr_Of_Samples"); - fNrSamples[(iLink)*(NrOfSpadics)+iAddress]->GetYaxis()->SetTitle("Stop_Type"); - - fHM->Add(TString("Baseline_"+histName).Data(),new TH2I (TString("Baseline_"+histName).Data(),TString("Baseline_"+histName).Data(), 128,-256.5,255.5,32,-0.5,31.5)); - fBaseline[(iLink)*(NrOfSpadics)+iAddress]=(TH2I*)fHM->H2(TString("Baseline_"+histName).Data()); - fBaseline[(iLink)*(NrOfSpadics)+iAddress]->GetXaxis()->SetTitle("ADC"); - fBaseline[(iLink)*(NrOfSpadics)+iAddress]->GetYaxis()->SetTitle("Channel ID"); - fHM->Add(TString("maxADC_vs_maxTimeBin_"+histName).Data(),new TH2I (TString("maxADC_vs_maxTimeBin_"+histName).Data(),TString("maxADC_vs_maxTimeBin_"+histName).Data(),32,-0.5,31.5, 128,-256.5,255.5)); - - fmaxADCmaxTimeBin[(iLink)*(NrOfSpadics)+iAddress]=(TH2I*)fHM->H2(TString("maxADC_vs_maxTimeBin_"+histName).Data()); - fmaxADCmaxTimeBin[(iLink)*(NrOfSpadics)+iAddress]->GetXaxis()->SetTitle("max. Time Bin"); - fmaxADCmaxTimeBin[(iLink)*(NrOfSpadics)+iAddress]->GetYaxis()->SetTitle("max ADC"); - fHM->Add(TString("Hit_"+histName).Data(),new TH2I (TString("Hit_"+histName).Data(),TString("Hit_"+histName).Data(),16,-0.5,15.5,2,-0.5,1.5)); - fHit[(iLink)*(NrOfSpadics)+iAddress]=(TH2I*)fHM->H2(TString("Hit_"+histName).Data()); - fHM->Add(TString("Hit_Channel"+histName).Data(),new TH2I (TString("Hit_Channel"+histName).Data(),TString("Hit_Channel"+histName).Data(),16,-0.5,15.5,2,-0.5,1.5)); - fHitChannel[(iLink)*(NrOfSpadics)+iAddress]=(TH2I*)fHM->H2(TString("Hit_Channel"+histName).Data()); - fHitChannel[(iLink)*(NrOfSpadics)+iAddress]->GetXaxis()->SetTitle("Channel ID"); - fHitChannel[(iLink)*(NrOfSpadics)+iAddress]->GetYaxis()->SetTitle("Group ID"); - fHM->Add(TString("Lost_"+histName).Data(),new TH2I (TString("Lost_"+histName).Data(),TString("Lost_"+histName).Data(),16,-0.5,15.5,2,-0.5,1.5)); - - fLost[(iLink)*(NrOfSpadics)+iAddress]=(TH2I*)fHM->H2(TString("Lost_"+histName).Data()); - fHM->Add(TString("Epoch_"+histName).Data(),new TH2I (TString("Epoch_"+histName).Data(),TString("Epoch_"+histName).Data(),16,-0.5,15.5,2,-0.5,1.5)); - fEpoch[(iLink)*(NrOfSpadics)+iAddress]=(TH2I*)fHM->H2(TString("Epoch_"+histName).Data()); - fHM->Add(TString("OutOfSync_"+histName).Data(),new TH2I (TString("OutOfSync_"+histName).Data(),TString("OutOfSync_"+histName).Data(),16,-0.5,15.5,2,-0.5,1.5)); - fOutOfSync[(iLink)*(NrOfSpadics)+iAddress]=(TH2I*)fHM->H2(TString("OutOfSync_"+histName).Data()); - fHM->Add(TString("Strange_"+histName).Data(),new TH2I (TString("Strange_"+histName).Data(),TString("Strange_"+histName).Data(),16,-0.5,15.5,2,-0.5,1.5)); - fStrange[(iLink)*(NrOfSpadics)+iAddress]=(TH2I*)fHM->H2(TString("Strange_"+histName).Data()); - fHM->Add(TString("Info_"+histName).Data(),new TH2I (TString("Info_"+histName).Data(),TString("Info_"+histName).Data(),16,-0.5,15.5,2,-0.5,1.5)); - fInfo[(iLink)*(NrOfSpadics)+iAddress]=(TH2I*)fHM->H2(TString("Info_"+histName).Data()); - fTSGraph[(iLink)*(NrOfSpadics)+iAddress] = new TGraph(); - - fHM->Add(TString("Sync_"+histName).Data(),new TH2I (TString("Sync_"+histName).Data(),TString("Sync_"+histName).Data(), 4096,-0.5,4095.5,32,-0.5,31.5)); - fHitSync[(iLink)*(NrOfSpadics)+iAddress]=(TH2I*)fHM->H2(TString("Sync_"+histName).Data()); - - fHM->Add(TString("HitTimeA_"+histName).Data(),new TH1I (TString("HitTimeA_"+histName).Data(),TString("HitTimeA_"+histName).Data(),300,-299.5,0.5)); - fHitTimeA[(iLink)*(NrOfSpadics)+iAddress]=(TH1I*)fHM->H1(TString("HitTimeA_"+histName).Data()); - fHitTimeA[(iLink)*(NrOfSpadics)+iAddress]->GetXaxis()->SetTitle("SuperEpoch count"); - fHM->Add(TString("HitTimeB_"+histName).Data(),new TH1I (TString("HitTimeB_"+histName).Data(),TString("HitTimeB_"+histName).Data(),300,-299.5,0.5)); - fHitTimeB[(iLink)*(NrOfSpadics)+iAddress]=(TH1I*)fHM->H1(TString("HitTimeB_"+histName).Data()); - fHitTimeB[(iLink)*(NrOfSpadics)+iAddress]->GetXaxis()->SetTitle("SuperEpoch count"); - fHitTimeB[(iLink)*(NrOfSpadics)+iAddress]->SetLineColor(2); - fHM->Add(TString("MessageStatistic_"+histName).Data(),new TH1I (TString("MessageStatistic_"+histName).Data(),TString("MessageStatistic_"+histName).Data(),24,-0.5,23.5)); - fMessageStatistic[(iLink)*(NrOfSpadics)+iAddress]=(TH1I*)fHM->H1(TString("MessageStatistic_"+histName).Data()); - for (Int_t iM = 0; iM < 7; iM++){ - fMessageStatistic[(iLink)*(NrOfSpadics)+iAddress]->GetXaxis()->SetBinLabel(iM+1,fMessageTypes[iM]); - } - for (Int_t iT = 0; iT < 4; iT++){ - fMessageStatistic[(iLink)*(NrOfSpadics)+iAddress]->GetXaxis()->SetBinLabel(7+1+iT,fTriggerTypes[iT]); - } - for (Int_t iS = 0; iS < 6; iS++){ - fMessageStatistic[(iLink)*(NrOfSpadics)+iAddress]->GetXaxis()->SetBinLabel(7+4+1+iS,fStopTypes[iS]); - } - for (Int_t iI = 0; iI < 7; iI++){ - fMessageStatistic[(iLink)*(NrOfSpadics)+iAddress]->GetXaxis()->SetBinLabel(7+4+6+1+iI,fInfoTypes[iI]); - } - - // const Int_t nBins=70; - // auto BinBoarders = [&nBins] (Int_t reBinHigh=32){ - // //auto BinBoarders = [&nBins] (Int_t reBinLow=32){ - // const Double_t Threshold = 100.; - // const Double_t MaxFreq = (17500000.0); - // const Double_t slope=MaxFreq/nBins; - // const Int_t iThreshhold=std::ceil((MaxFreq/Threshold-0.5)/static_cast<Double_t>(reBinHigh)); - // LOG(fatal) << "iThresshold = " << iThreshhold; - // Double_t* Result=new Double_t[nBins+1]; - // - // for(Int_t i=0;i<nBins;i++){ - // size_t j=nBins-i; - // //Result[j]=TMath::Power(TMath::E(),i*slope+TMath::Log(2)); - // //printf("%d\n",Result[j]); - // Double_t LowEdge = MaxFreq/(reBinHigh*(i*i)+0.5); - // Result[j]=LowEdge; - // }/* - // for(Int_t i=0;i<nBins-iThreshhold;i++) { - // size_t j=nBins-iThreshhold-i; - // Double_t LowEdge = MaxFreq/(reBinHigh*(iThreshhold)+0.5+RebinLow*(i)); - // Result[j]=LowEdge; - // }*/ - // Result[0]=0.0; - // std::sort(Result,&Result[nBins]); - // return Result; - // }; - // Double_t* freqbins = (BinBoarders()); - - const Int_t nBins = 234; - // const Double_t maxFreq = (175000000.0); (VF) not used - auto BinBoarders = [/*&nBins*/] (Int_t /*reBinHigh*/=32) - { - const Double_t MaxFreq = (175000000.0); -// const Double_t slope=10;//MaxFreq/nBins; (VF) not used - Double_t* Result=new Double_t[nBins+1]; - for(Int_t i=0;i<nBins;i++) - { - size_t j=nBins-i; - Double_t LowEdge = MaxFreq/(TMath::Power(TMath::E(),(0.1*Int_t(i)))); - //printf("LowEdge: %e\n",LowEdge); - Result[j]=LowEdge; - //Result[j]=TMath::Power(TMath::E(),i*slope+TMath::Log(2)); - } - Result[0]=0.1; - std::sort(Result,&Result[nBins]); - return Result; - }; - Double_t* freqbins = (BinBoarders()); - fHM->Add(TString("HitFrequency_"+histName).Data(),new TH1I (TString("HitFrequency_"+histName).Data(),TString("HitFrequency_"+histName).Data(),nBins,freqbins/*100000,1,10000000*/)); - fHitFrequency[(iLink)*(NrOfSpadics)+iAddress]=(TH1I*)fHM->H1(TString("HitFrequency_"+histName).Data()); - fHitFrequency[(iLink)*(NrOfSpadics)+iAddress]->GetXaxis()->SetTitle("Trigger frequency (Hz)"); - fHitFrequency[(iLink)*(NrOfSpadics)+iAddress]->GetYaxis()->SetTitle("Channel ID"); - fHM->Add(TString("Spectrum_"+histName).Data(),new TH1I (TString("Spectrum_"+histName).Data(),TString("Spectrum_"+histName).Data(),513,-256.5,256.5)); - fSpectrum[(iLink)*(NrOfSpadics)+iAddress]=(TH1I*)fHM->H1(TString("Spectrum_"+histName).Data()); - fSpectrum[(iLink)*(NrOfSpadics)+iAddress]->GetXaxis()->SetTitle("max. ADC (ADC)"); - - - - for (Int_t iCh = 0; iCh < 32; iCh++){ - TString chName; - chName.Form("Ch%02i_",iCh); - // FIXME!!! - fHM->Add(TString("PulseShape_"+chName+histName).Data(),new TH2I (TString("PulseShape_"+chName+histName).Data(),TString("PulseShape_"+chName+histName).Data(),32,-0.5,31.5, 128,-256.5,255.5)); - fPulseShape[((iLink)*(NrOfSpadics)+iAddress)*32+iCh]=(TH2I*)fHM->H2(TString("PulseShape_"+chName+histName).Data()); - fPulseShape[((iLink)*(NrOfSpadics)+iAddress)*32+iCh]->GetXaxis()->SetTitle("Time Bin"); - fPulseShape[((iLink)*(NrOfSpadics)+iAddress)*32+iCh]->GetYaxis()->SetTitle("ADC"); - fPulseShape[((iLink)*(NrOfSpadics)+iAddress)*32+iCh]->GetZaxis()->SetTitle("counts"); - } - - for (Int_t iCh = 0; iCh < 32; iCh++){ - TString chName; - chName.Form("Ch%02i_",iCh); - // FIXME!!! - fHM->Add(TString("MaxADC_"+chName+histName).Data(),new TH1D (TString("MaxADC_"+chName+histName).Data(),TString("MaxADC_"+chName+histName).Data(),256,-256.5,255.5)); - fMaxADC[((iLink)*(NrOfSpadics)+iAddress)*32+iCh]=(TH1D*)fHM->H1(TString("MaxADC_"+chName+histName).Data()); - fMaxADC[((iLink)*(NrOfSpadics)+iAddress)*32+iCh]->GetXaxis()->SetTitle("ADC"); - fMaxADC[((iLink)*(NrOfSpadics)+iAddress)*32+iCh]->GetYaxis()->SetTitle("counts"); - } - - //Alignment Histos - for (Int_t iHist =0; iHist <3; iHist++){ - TString align; - align.Form("%s", fAlignments[iHist].Data()); - fHM->Add(TString("Alignment_"+align).Data(),new TH2I (TString("Alignment_"+align).Data(),TString("Alignment_"+align).Data(),32,-0.5,31.5,32,-0.5,31.5)); - fAlignment[iHist]=(TH2I*)fHM->H2(TString("Alignment_"+align).Data()); - fAlignment[iHist]->GetXaxis()->SetTitle(TString("Channels_Chamber_"+fChambers[iHist]).Data()); - fAlignment[iHist]->GetYaxis()->SetTitle(TString("Channels_Chamber_"+fChambers[iHist+1]).Data()); - - } - - - //Global Histo: Sync - fHM->Add("SyncChambers",new TH2I ("SyncChambers","SyncChambers",4096,-0.5,4095.5,4,-0.5,3.5)); - fSyncChambers[0]=(TH2I*)fHM->H2("SyncChambers"); - fSyncChambers[0]->GetXaxis()->SetTitle("Time_between_Hits"); - fSyncChambers[0]->GetYaxis()->SetTitle("Chamber"); - - //Global Histo: Event Selection - fHM->Add("Event_Selection",new TH1I ("Event_Selection","Event_Selection",5,-0.5,4.5)); - fEventSelection[0]=(TH1I*)fHM->H1("Event_Selection"); - fEventSelection[0]->GetXaxis()->SetTitle("Chambers_Hit"); - - - } - } - fHM->Create2<TH2I>("TimeCorrel","TimeCorrel",4,-0.5,3.5,5000,-0.5,20000); - fHM->H2("TimeCorrel")->GetXaxis()->SetTitle("SpadicId"); - fHM->H2("TimeCorrel")->GetXaxis()->SetTitle("#Delta t"); - -} - - - - -void CbmTSUnpackSpadic20DesyOnlineMonitor::InitCanvas() -{ - TString cName; - if (!fHighPerformance){ - fcE= new TCanvas(TString("EpochMap").Data(),TString("EpochMap").Data(),1600,1200); - fcE->Divide(3,4); - fcO= new TCanvas(TString("OutOfSyncMap").Data(),TString("OutOfSyncMap").Data(),1600,1200); - fcO->Divide(3,4); - fcS= new TCanvas(TString("StrangeMap").Data(),TString("StrangeMap").Data(),1600,1200); - fcS->Divide(3,4); - fcI= new TCanvas(TString("InfoMap").Data(),TString("InfoMap").Data(),1600,1200); - fcI->Divide(3,4); - fcF= new TCanvas(TString("HitFrequency").Data(),TString("HitFrequency").Data(),1600,1200); - fcF->Divide(3,4); - fcSp= new TCanvas(TString("HitSelfTriggersSpectrum").Data(),TString("HitSelfTriggersSpectrum").Data(),1600,1200); - fcSp->Divide(3,4); - } - fcB = new TCanvas(TString("Baseline").Data(),TString("Baseline").Data(),1600,1200); - fcB->Divide(3,4); - fcM/*[(iLink)*(NrOfSpadics)+iAddress]*/ = new TCanvas(TString("maxADC_vs_maxTimeBin").Data(),TString("maxADC_vs_maxTimeBin").Data(),1600,1200); - fcM->Divide(3,4); - fcH= new TCanvas(TString("HitMap").Data(),TString("HitMap").Data(),1600,1200); - fcH->Divide(3,4); - fcHC= new TCanvas(TString("HitMapChannel").Data(),TString("HitMapChannel").Data(),1600,1200); - fcHC->Divide(3,4); - fcL= new TCanvas(TString("LostMap").Data(),TString("LostMap").Data(),1600,1200); - fcL->Divide(3,4); - fcTS= new TCanvas(TString("TSGraph").Data(),TString("TSGraph").Data(),1600,1200); - fcTS->Divide(3,4); - fcMS= new TCanvas(TString("MessageStatistic").Data(),TString("MessageStatistic").Data(),1600,1200); - fcMS->Divide(3,4); - fcSy= new TCanvas(TString("SyncChambers").Data(),TString("SyncChambers").Data(),1600,1200); - fcSy->Divide(1,1); - fcNS= new TCanvas(TString("Nr_Samples_vs_Stoptype").Data(),TString("Nr_Samples_vs_Stoptype").Data(),1600,1200); - fcNS->Divide(3,4); - fcTH= new TCanvas(TString("Time_between_Hits").Data(),TString("Time_between_Hits").Data(),1600,1200); - fcTH->Divide(3,4); - fcAS= new TCanvas(TString("Cluster_ADCmax_sum").Data(),TString("Cluster_ADCmax_sum").Data(),1600,1200); - fcAS->Divide(3,4); - fcA= new TCanvas(TString("Alignment").Data(),TString("Alignment").Data(),1600,1200); - fcA->Divide(2,2); - fcES= new TCanvas(TString("Event_Selection").Data(),TString("Event_Selection").Data(),1600,1200); - fcES->Divide(1,1); - - - for (Int_t iLink = 0; iLink < NrOfAfcks; iLink++){ - for (Int_t iAddress = 0; iAddress < NrOfSpadics; iAddress++){ - cName.Form("AFCK_%i_Spadic_%i",iLink,iAddress); - if (!fHighPerformance){ - fcPS[(iLink)*(NrOfSpadics)+iAddress] = new TCanvas(TString("PulseShapes_"+cName).Data(),TString("PulseShapes_"+cName).Data(),1600,1200); - fcPS[(iLink)*(NrOfSpadics)+iAddress]->Divide(4,8); - for(Int_t iCh = 0; iCh < 32; iCh++){ - fcPS[(iLink)*(NrOfSpadics)+iAddress]->cd(iCh+1); - //fPulseShape[((iLink)*(NrOfSpadics)+iAddress)*32+iCh]->Draw("colz"); - fPulseShape[((iLink)*(NrOfSpadics)+iAddress)*32+iCh]->Draw("col"); - } - for(Int_t iCh = 0; iCh < 32; iCh++){ - fcPS[(iLink)*(NrOfSpadics)+iAddress]->cd(iCh+1); - fMaxADC[((iLink)*(NrOfSpadics)+iAddress)*32+iCh]->Draw(""); - } - fcE->cd((iLink)*(NrOfSpadics)+iAddress+1)->SetLogz(0); - fEpoch[(iLink)*(NrOfSpadics)+iAddress]->Draw("colz"); - fcO->cd((iLink)*(NrOfSpadics)+iAddress+1)->SetLogz(0); - fOutOfSync[(iLink)*(NrOfSpadics)+iAddress]->Draw("colz"); - fcS->cd((iLink)*(NrOfSpadics)+iAddress+1)->SetLogz(0); - fStrange[(iLink)*(NrOfSpadics)+iAddress]->Draw("colz"); - fcI->cd((iLink)*(NrOfSpadics)+iAddress+1)->SetLogx(0); - fInfo[(iLink)*(NrOfSpadics)+iAddress]->Draw("colz"); - fcF->cd((iLink)*(NrOfSpadics)+iAddress+1)->SetLogx(1); - fcF->cd((iLink)*(NrOfSpadics)+iAddress+1)->SetLogy(1); - fcF->cd((iLink)*(NrOfSpadics)+iAddress+1)->SetLogz(0); - fHitFrequency[(iLink)*(NrOfSpadics)+iAddress]->Draw(/*"colz"*/); - fcSp->cd((iLink)*(NrOfSpadics)+iAddress+1)->SetLogy(1); - fSpectrum[(iLink)*(NrOfSpadics)+iAddress]->Draw(); - fHitSync[(iLink)*(NrOfSpadics)+iAddress]->Draw("colz"); - // fDeltaT[0]->Draw(""); - } - fcB->cd((iLink)*(NrOfSpadics)+iAddress+1)->SetLogz(); - fBaseline[(iLink)*(NrOfSpadics)+iAddress]->Draw("colz"); - // cName.Form("AFCK_%i_Spadic_%i",iLink,iAddress); - fcM->cd((iLink)*(NrOfSpadics)+iAddress+1)->SetLogz(); - fmaxADCmaxTimeBin[(iLink)*(NrOfSpadics)+iAddress]->Draw("colz"); - fcH->cd((iLink)*(NrOfSpadics)+iAddress+1)->SetLogz(1); - fHit[(iLink)*(NrOfSpadics)+iAddress]->Draw("colz"); - fcHC->cd((iLink)*(NrOfSpadics)+iAddress+1)->SetLogz(1); - fHitChannel[(iLink)*(NrOfSpadics)+iAddress]->Draw("colz"); - fcL->cd((iLink)*(NrOfSpadics)+iAddress+1)->SetLogz(0); - fLost[(iLink)*(NrOfSpadics)+iAddress]->Draw("colz"); - fcAS->cd((iLink)*(NrOfSpadics)+iAddress+1); - fADCmaxSum[(iLink)*(NrOfSpadics)+iAddress]->Draw("hist"); - fcMS->cd((iLink)*(NrOfSpadics)+iAddress+1)->SetLogy(1); - fMessageStatistic[(iLink)*(NrOfSpadics)+iAddress]->Draw(""); - fcTS->cd((iLink)*(NrOfSpadics)+iAddress+1); - fHitTimeA[(iLink)*(NrOfSpadics)+iAddress]->GetYaxis()->SetRangeUser(0,1000); - fHitTimeA[(iLink)*(NrOfSpadics)+iAddress]->Draw(""); - fHitTimeB[(iLink)*(NrOfSpadics)+iAddress]->Draw("same"); - //fTSGraph[(iLink)*(NrOfSpadics)+iAddress]->Draw("ALP"); - fHitSync[(iLink)*(NrOfSpadics)+iAddress]->Draw("colz"); - // fDeltaT[0]->Draw(""); - fcNS->cd((iLink)*(NrOfSpadics)+iAddress+1)->SetLogz(); - fNrSamples[(iLink)*(NrOfSpadics)+iAddress]->Draw("colz"); - fcTH->cd((iLink)*(NrOfSpadics)+iAddress+1)->SetLogy(); - fTimeBetweenHits[(iLink)*(NrOfSpadics)+iAddress]->Draw(""); - for (Int_t iHist =0; iHist <3; iHist++){ - fcA->cd(iHist+1)->SetLogz(1); - fAlignment[iHist]->Draw("colz"); - } - fcES->cd(1)->SetLogy(0); - fEventSelection[0]->Draw(""); - fcSy->cd(1)->SetLogz(1); - fSyncChambers[0]->Draw(""); - } - } -} - - - -void CbmTSUnpackSpadic20DesyOnlineMonitor::UpdateCanvas() -{ - /* - //cout << "UpdateCanvas" << endl; - TH2I* h = NULL; - TString cName; - for (Int_t iLink = 0; iLink < NrOfAfcks; iLink++){ - for (Int_t iAddress = 0; iAddress < NrOfSpadics; iAddress++){ - cName.Form("AFCK_%i_Spadic_%i",iLink,iAddress); - fcB->cd((iLink)*(NrOfSpadics)+iAddress+1); - fBaseline[(iLink)*(NrOfSpadics)+iAddress]->Draw("colz"); - h = (TH2I*)fHM->H2(TString("Baseline_"+cName).Data()); - h->Draw("colz"); - fcB->cd((iLink)*(NrOfSpadics)+iAddress+1)->Update(); - cName.Form("AFCK_%i_Spadic_%i",iLink,iAddress); - fcM->cd((iLink)*(NrOfSpadics)+iAddress+1); - fmaxADCmaxTimeBin[(iLink)*(NrOfSpadics)+iAddress]->Draw("colz"); - h = (TH2I*)fHM->H2(TString("maxADC_vs_maxTimeBin_"+cName).Data()); - h->Draw("colz"); - fcM->cd((iLink)*(NrOfSpadics)+iAddress+1)->Update(); - } - } - */ -} - -void CbmTSUnpackSpadic20DesyOnlineMonitor::Reset() -{ - fSpadicRaw->Clear(); -} -void CbmTSUnpackSpadic20DesyOnlineMonitor::FinishEvent() -{ - //UpdateCanvas(); -} - -void CbmTSUnpackSpadic20DesyOnlineMonitor::Finish() -{ - for(auto p : fSuperEpochArray){ - int supEpCnt= p.second; - int halfSpadicAddress=p.first.first; - int afckId=p.first.second; - LOG(debug) << "There have been " << supEpCnt - << " SuperEpochs for AFCK" << afckId << "_Spadic" - << halfSpadicAddress << " in this file"; - } - UpdateCanvas(); -} - - - /* - void CbmTSUnpackSpadic20DesyOnlineMonitor::Register() - { - } - */ - - - ClassImp(CbmTSUnpackSpadic20DesyOnlineMonitor) diff --git a/beamtime/cern2014/unpacker/CbmTSUnpackSpadic20DesyOnlineMonitor.h b/beamtime/cern2014/unpacker/CbmTSUnpackSpadic20DesyOnlineMonitor.h deleted file mode 100644 index c4d65390a7105e683f923bfba71560945405c943..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/unpacker/CbmTSUnpackSpadic20DesyOnlineMonitor.h +++ /dev/null @@ -1,158 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmTSUnpackSpadic20OnlineMonitor ----- -// ----- Created 20.12.2016 by C. Bergmann ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CBMTSUNPACKSPADIC20DESYONLINEMONITOR_H -#define CBMTSUNPACKSPADIC20DESYONLINEMONITOR_H - -#include "Timeslice.hpp" -#include "Message.hpp" - -#include <map> -#include "CbmTSUnpack.h" -#include "CbmBeamDefaults.h" - -#include "CbmHistManager.h" -#include "TClonesArray.h" - -class CbmTSUnpackSpadic20DesyOnlineMonitor : public CbmTSUnpack -{ - public: - - CbmTSUnpackSpadic20DesyOnlineMonitor(Bool_t highPerformancen = true ); - virtual ~CbmTSUnpackSpadic20DesyOnlineMonitor(); - - virtual Bool_t Init(); - - virtual Bool_t DoUnpack(const fles::Timeslice& ts, size_t component); - void print_message(const spadic::Message& m); - - virtual void Reset(); - - virtual void Finish(); - virtual void FinishEvent(); - void SetParContainers() {;} - - // protected: - // virtual void Register(); - - virtual void FillOutput(boost::any){;} - - private: - - TClonesArray* fSpadicRaw; - - Bool_t fHighPerformance; - - - std::map<std::pair<int,int>,int>fEpochMarkerArray; - //Array to store the previous Epoch counter - std::map<std::pair<int,int>,int>fPreviousEpochMarkerArray; - //Suppress multiple Epoch Messages in duplicated Microslices. NOTE:Currently Buggy - const Bool_t SuppressMultipliedEpochMessages = false; - std::map<std::pair<int,int>,int>fSuperEpochArray; - - static Int_t GetSpadicID(Int_t address); -// static Int_t GetAfckID(Int_t AfckAddress); - inline TString GetSpadicName(Int_t link,Int_t address); - Int_t GetChannelOnPadPlane(Int_t SpadicChannel, Int_t groupId); - Int_t fEpochMarker; - Int_t fSuperEpoch; - Int_t fNrExtraneousSamples; - Int_t startTime = 0; // should be ULong_t as soon as used with a GetFullTime lateron - Bool_t first = true; // for the "Sync" histo : is it the very first entry into this histo? - Bool_t syncHistFinished = false; // declare explicitly, if the "Sync" histo is finished. - Int_t maxTime = 0; // should be ULong_t as soon as used with a GetFullTime lateron - Int_t lastTsCh7 = 0; - void GetEpochInfo(Int_t link, Int_t addr); - void FillEpochInfo(Int_t link, Int_t addr, Int_t epoch_count); - CbmHistManager* fHM; - TCanvas* fcB; - TCanvas* fcM;//[(iLink)*(NrOfHalfSpadics/2)]; - TCanvas* fcH; - TCanvas* fcL; - TCanvas* fcE; - TCanvas* fcO; - TCanvas* fcS; - TCanvas* fcI; - TCanvas* fcTS; - TCanvas* fcF; - TCanvas* fcSp; - TCanvas* fcPS[(NrOfAfcks)*(NrOfSpadics)]; - TCanvas* fcMS; - TCanvas* fcSy; - TCanvas* fcNS; - TCanvas* fcTH; - TCanvas* fcAS; - TCanvas* fcA; - TCanvas* fcES; - TCanvas* fcHC; - void InitHistos(); - void InitCanvas(); - void UpdateCanvas(); - TH2I* fBaseline[(NrOfAfcks)*(NrOfSpadics)]; - TH2I* fmaxADCmaxTimeBin[(NrOfAfcks)*(NrOfSpadics)]; - TH2I* fHit[(NrOfAfcks)*(NrOfSpadics)]; - TH2I* fHitChannel[(NrOfAfcks)*(NrOfSpadics)]; - TH2I* fLost[(NrOfAfcks)*(NrOfSpadics)]; - TH2I* fEpoch[(NrOfAfcks)*(NrOfSpadics)]; - TH2I* fOutOfSync[(NrOfAfcks)*(NrOfSpadics)]; - TH2I* fStrange[(NrOfAfcks)*(NrOfSpadics)]; - TH2I* fInfo[(NrOfAfcks)*(NrOfSpadics)]; - TH1I* fHitTimeA[(NrOfAfcks)*(NrOfSpadics)]; - TH1I* fHitTimeB[(NrOfAfcks)*(NrOfSpadics)]; - TH1I* fHitFrequency[(NrOfAfcks)*(NrOfSpadics)]; - TH1I* fSpectrum[(NrOfAfcks)*(NrOfSpadics)]; - TH2I* fPulseShape[(NrOfAfcks)*(NrOfSpadics)*32]; - TH1I* fMessageStatistic[(NrOfAfcks)*(NrOfSpadics)]; - TH2I* fHitSync[(NrOfAfcks)*(NrOfSpadics)]; - TH2I* fNrSamples[(NrOfAfcks)*(NrOfSpadics)]; - TH1D* fTimeBetweenHits[(NrOfAfcks)*(NrOfSpadics)]; - TH1I* fADCmaxSum[(NrOfAfcks)*(NrOfSpadics)]; - // TH1I* fDeltaT[1]; - TGraph* fTSGraph[(NrOfAfcks)*(NrOfSpadics)]; - Int_t fLastSuperEpochA[(NrOfAfcks)*(NrOfSpadics)]; - Int_t fLastSuperEpochB[(NrOfAfcks)*(NrOfSpadics)]; - ULong_t fLastFullTime[NrOfAfcks][NrOfSpadics][32]; - ULong_t fHitsTrd0[16777216][2]; - ULong_t fHitsTrd1[16777216][2]; - ULong_t fHitsTrd1n[16777216][2]; - ULong_t fHitsTrd2[16777216][2]; - ULong_t fLastTimeGlobal; - ULong_t fThisTime; - ULong_t fAlignmentCounter0; - ULong_t fAlignmentCounter1; - ULong_t fAlignmentCompareCounter; - ULong_t fAlignmentCompareCounter1; - ULong_t fLastTimes[(NrOfAfcks)*(NrOfSpadics)]; - TString fMessageTypes[7]; - TString fTriggerTypes[4]; - Int_t fClusterSwitch[(NrOfAfcks)*(NrOfSpadics)]; - Int_t fMaxSum[(NrOfAfcks)*(NrOfSpadics)]; - Int_t fLastTrigger[(NrOfAfcks)*(NrOfSpadics)]; - Int_t fLastChannel[(NrOfAfcks)*(NrOfSpadics)]; - TString fStopTypes[6]; - TString fInfoTypes[7]; - TString fAlignments[3]; - TString fChambers[4]; - Int_t fAFCKs[4]; - Int_t fSource; - Int_t fLastSource; - ULong_t fFillCounter; - //Int_t fSumHitMessages[(NrOfAfcks)*(NrOfSpadics)]; - CbmTSUnpackSpadic20DesyOnlineMonitor(const CbmTSUnpackSpadic20DesyOnlineMonitor&); - CbmTSUnpackSpadic20DesyOnlineMonitor operator=(const CbmTSUnpackSpadic20DesyOnlineMonitor&); - - TH2I* fSyncChambers[1]; - TH1I* fEventSelection[1]; - TH2I* fAlignment[3]; - TH1D* fMaxADC[32*(NrOfAfcks)*(NrOfSpadics)]; - - ClassDef(CbmTSUnpackSpadic20DesyOnlineMonitor, 2) - - }; - -#endif diff --git a/beamtime/cern2014/unpacker/CbmTSUnpackSpadic20OnlineMonitor.cxx b/beamtime/cern2014/unpacker/CbmTSUnpackSpadic20OnlineMonitor.cxx deleted file mode 100644 index 465f1d1d168d41e5b223018ce043503193b11631..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/unpacker/CbmTSUnpackSpadic20OnlineMonitor.cxx +++ /dev/null @@ -1,902 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmTSUnpackSpadic20OnlineMonitor ----- -// ----- Created 07.11.2014 by F. Uhlig ----- -// ----- ----- -// ----------------------------------------------------------------------------- -#include "CbmTSUnpackSpadic20OnlineMonitor.h" - -#include "CbmSpadicRawMessage.h" - -#include "TimesliceReader.hpp" -#include "Timeslice.hpp" - -#include "Message.hpp" - -#include "FairLogger.h" -#include "FairRootManager.h" - -#include "TClonesArray.h" - -#include "CbmHistManager.h" -#include "TCanvas.h" -#include "TH1.h" -#include "TH2.h" -#include "TH3.h" -#include "TMultiGraph.h" -#include "TMath.h" -#include "FairRun.h" -#include "FairRunOnline.h" -#include "THttpServer.h" - -#include <iostream> -#include <map> -#include <vector> - - - -CbmTSUnpackSpadic20OnlineMonitor::CbmTSUnpackSpadic20OnlineMonitor(Bool_t highPerformance) - : CbmTSUnpack(), - fSpadicRaw(new TClonesArray("CbmSpadicRawMessage", 10)), - fHighPerformance(highPerformance), - fEpochMarkerArray(), - fPreviousEpochMarkerArray(), - fSuperEpochArray(), - fEpochMarker(0), - fSuperEpoch(0), - fNrExtraneousSamples{0}, - fHM(new CbmHistManager()), - fcB(NULL), - fcM(NULL), - fcH(NULL), - fcL(NULL), - fcE(NULL), - fcO(NULL), - fcS(NULL), - fcI(NULL), - fcTS(NULL), - fcF(NULL), - fcSp(NULL), - fcPS{NULL}, - fcMS{NULL}, - fBaseline{NULL}, - fmaxADCmaxTimeBin{NULL}, - fHit{NULL}, - fLost{NULL}, - fEpoch{NULL}, - fOutOfSync{NULL}, - fStrange{NULL}, - fInfo{NULL}, - fHitTimeA{NULL}, - fHitTimeB{NULL}, - fHitFrequency{NULL}, - fSpectrum{NULL}, - fPulseShape{NULL}, - fMessageStatistic{NULL}, - fHitSync{NULL}, - fTSGraph{NULL}, - fLastSuperEpochA{0}, - fLastSuperEpochB{0}, - fLastFullTime{{{0}}}, - fMessageTypes{"Epoch", - "Epoch out of synch", - "Hit", - "Hit aborted", - "Info", - "Overflow", - "Strange"}, - fTriggerTypes{ "Global trigger", - "Self triggered", - "Neighbor triggered", - "Self and neighbor triggered"}, - fStopTypes{"Normal end of message", - "Channel buffer full", - "Ordering FIFO full", - "Multi hit", - "Multi hit and channel buffer full", - "Multi hit and ordering FIFO full"}, - fInfoTypes{"Channel disabled during message building", - "Next grant timeout", - "Next request timeout", - "New grant but channel empty", - "Corruption in message builder", - "Empty word", - "Epoch out of sync"}, - fMaxADC{NULL} -{ - for (Int_t i=0; i < NrOfSyscores; ++i) { - for (Int_t j=0; j < NrOfHalfSpadics; ++j) { - fEpochMarkerArray[i][j] = 0; - fPreviousEpochMarkerArray[i][j] =0; - fSuperEpochArray[i][j] = 0; - } - } - - InitHistos(); - InitCanvas(); -} - -CbmTSUnpackSpadic20OnlineMonitor::~CbmTSUnpackSpadic20OnlineMonitor() -{ - LOG(info) << "Number of extraneous Samples "<< fNrExtraneousSamples; -} - -Bool_t CbmTSUnpackSpadic20OnlineMonitor::Init() -{ - LOG(info) << "Initializing"; - - FairRootManager* ioman = FairRootManager::Instance(); - if (ioman == NULL) { - LOG(fatal) << "No FairRootManager instance"; - } - ioman->Register("SpadicRawMessage", "spadic raw data", fSpadicRaw, kTRUE); - return kTRUE; -} - - -Int_t startTime = 0; // should be ULong_t as soon as used with a GetFullTime lateron -Bool_t first = true; // for the "Sync" histo : is it the very first entry into this histo? -Bool_t syncHistFinished = false; // declare explicitly, if the "Sync" histo is finished. -Int_t maxTime = 0; // should be ULong_t as soon as used with a GetFullTime lateron - -Bool_t CbmTSUnpackSpadic20OnlineMonitor::DoUnpack(const fles::Timeslice& ts, size_t component) -{ - // compare to: https://github.com/spadic/spadic10-software/blob/master/lib/message/message.h - // or fles/spadic/message/wrap/cpp/message.cpp - LOG(debug) << "Unpacking Spadic Data"; - Int_t link = 0; - //TH2I* h = NULL; - TString cName; - - LOG(debug) << "Timeslice contains " << ts.num_microslices(component) - << "microslices."; - - std::cout << "Timeslice contains " << ts.num_microslices(component) << std::endl; - - - //printf("Component: %i Num MS: %i \n", component, ts.num_microslices(component)); - - // Loop over microslices - //for (size_t m = 0; m < ts.num_microslices(component); ++m){ - for (size_t m {0}; m < ts.num_microslices(component); m++){ - - spadic::MessageReader r; - Int_t address = 0; // Fake the addr for now - Int_t addr = 0; // Fake! - Int_t counter=0; - std::vector<uint16_t> buf0; - std::vector<uint16_t> buf1; - //buf0.reserve(20000); - //buf1.reserve(20000); - - // Get the microslice - auto mc = ts.get_microslice(component, m); - auto mv = reinterpret_cast<const fles::MicrosliceView&>(mc); - //auto mv_p = reinterpret_cast<const uint16_t *>(mv.content()); // Pointer to the data // (VF) not used - //auto mv_s = mv.desc().size * sizeof(*mv.content()) / sizeof(*mv_p); // Size (VF) unused - - //for(auto p=0; p<mv_s; p++){ - // printf("D: %x", mv_p[p]); - //} - //continue; - - //const uint64_t* pInBuff = reinterpret_cast<const uint64_t*>( mv_p ); - - // ---------------- - // Get the microslice - auto msDescriptor = ts.descriptor(component, m); // mc - //Int_t fEquipmentId = msDescriptor.eq_id; (VF) unused - //auto msContent = reinterpret_cast<const uint16_t*>(ts.content(component, m)); - const uint8_t* msContent = ts.content(component, m); - auto s = msDescriptor.size * sizeof(*msContent) / sizeof(*msContent); - const uint64_t* pInBuff = reinterpret_cast<const uint64_t*>( msContent ); - - for (size_t uIdx = 0; uIdx < s; uIdx ++){ - //for (auto uIdx = 0; uIdx < mv_s; uIdx ++){ - - uint64_t ulData = static_cast<uint64_t>( pInBuff[uIdx] ); - //uint64_t ulData = static_cast<uint64_t>( mv_p[uIdx] ); - - //auto ulData = mv_p[uIdx]; - //printf("%04x ", ulData); - - uint16_t afck_id = (ulData & 0xffff000000000000) >> 48; - // Last 2bytes of mac addr of the afck, hard coded now for sps2016 - //if(afck_id != 0x5b9d) //IRI AFCK - //if(afck_id != 0x187f) // IKF 217 - if(afck_id != 0x5f91) // LEMO - continue; - - //uint64_t ulData = static_cast<uint64_t>( pInBuff[uIdx] ); - uint8_t downlink_header = (ulData & 0xf00000) >> 20; - uint8_t downlink_nr = (ulData & 0xf0000) >> 16; - uint16_t payload = ulData & 0xffff; - - if(downlink_header != 0xa) - std::cout << "Corruption in downlink header found" << std::endl; - - //printf("Payload: 0x%04X\n", payload); - - // Put the data in a buffer - if(downlink_nr == 0) - buf0.push_back(payload); - else if(downlink_nr == 1) - buf1.push_back(payload); - } - - // This is not nice... quick n' dirty - //std::move(buf1.begin(), buf1.end(), std::back_inserter(buf0)); - - r.add_buffer(buf0.data() , buf0.size()); - r.add_buffer(buf1.data() , buf1.size()); - link = ts.descriptor(component, 0).eq_id; - - //} // End microslice - - Bool_t isInfo(false), isHit(false), isEpoch(false), isEpochOutOfSync(false), isOverflow(false), isHitAborted(false), isStrange(false); - - while(auto message = r.get_message()) { - - if(message->is_hit()){ - auto& sample = message->samples(); - - printf("Group: %i Ch: %i Ts: %i Samples: %lu\n", message->group_id(), message->channel_id(), message->timestamp(), sample.size()); - //printf("Ch: %i Ts: %i hit type: %i Stop type: %i Samples: %i Trace: \n", message->channel_id(), message->timestamp(), message->hit_type(), message->stop_type(), sample.size()); - //for(int i = 0; i < sample.size(); i++) - // printf(" %02i,", sample[i]); - //printf("\n"); - - - // Fill some nice histos - //Int_t triggerType = static_cast<Int_t>(message->hit_type()); - //Int_t stopType = static_cast<Int_t>(message->stop_type()); - Int_t time = message->timestamp(); - //Int_t infoType = -1; - Int_t channel = message->channel_id(); - Int_t groupId = message->group_id(); - //Int_t bufferOverflowCounter = 0; - Int_t samples = message->samples().size(); - //Int_t padRow(-1); - //Int_t padChannel = GetChannelOnPadPlane(channel,groupId); - Int_t counter1=0; - Int_t maxADC(-256)/*, maxTB(-1) (VF) unused*/; - Int_t* sample_values = new Int_t[samples]; - for (auto x : message->samples()) { - sample_values[counter1] = x; - //if (sample_values[2]>-150) { - //if (!fHighPerformance) - //fPulseShape[ ( GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address))*32+channel+16*(groupId%2) ]->Fill(counter1,x); - fPulseShape[channel+16*(groupId%2)]->Fill(counter1,x); - // fMaxADC[channel]->Fill(counter1,x); - //} - if (x > maxADC){ - maxADC = x; - // maxTB = counter1; (VF) not used - } - ++counter1; - } - - // Nasty look on messages from all available channels here. - // Only filled within one epoch. Therefore: regress of time will declare the histo as finished. - if(time < maxTime){ - syncHistFinished = true; - } - - // Here it is: its only processed and filled as long as not declared as finished. - if(!syncHistFinished){ - maxTime = time; // lets bookkeep the highest time value we've seen so far - if(first){ // just in case we are using ULong_t FullTime for the time info, - // its worth to store what was the time of the very first message in this histo. - startTime = time; - } - fHitSync[0]->Fill(time, groupId*16+channel); // when startTime should be used, its x=time-startTime here - } - - fMaxADC[channel]->Fill(maxADC); - cName.Form("SysCore_%i_Spadic_%i",0,0); - //h = (TH2I*)fHM->H2(TString("Baseline_"+cName).Data()); - //h->Fill(sample_values[0],groupId*16+channel); - fBaseline[0]->Fill(sample_values[0],groupId*16+channel); - - - // ---- - } - - else if ( message->is_buffer_overflow() ){ - LOG(debug) << counter << " This is a buffer overflow message"; - isOverflow = true; - //GetEpochInfo(link, addr); - //Int_t triggerType = -1; - //Int_t infoType = -1; - //Int_t stopType = -1; - Int_t groupId = message->group_id(); - Int_t channel = message->channel_id(); - //Int_t time = message->timestamp(); - Int_t bufferOverflowCounter = static_cast<Int_t>(message->buffer_overflow_count()); - Int_t samples = 1; - Int_t* sample_values = new Int_t[samples]; - sample_values[0] = -256; - /* - new( (*fSpadicRaw)[fSpadicRaw->GetEntriesFast()] ) - CbmSpadicRawMessage(link, address, channel, fEpochMarker, time, - fSuperEpoch, triggerType, infoType, stopType, groupId, - bufferOverflowCounter, samples, sample_values, - isHit, isInfo, isEpoch, isEpochOutOfSync, isHitAborted, isOverflow, isStrange); - */ - delete[] sample_values; - fMessageStatistic[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->Fill(fMessageTypes[5].Data(),bufferOverflowCounter); - channel = GetChannelOnPadPlane(channel,groupId); - if (channel > 15){ - channel-= 16; - groupId = 1; - } else { - groupId = 0; - } - fLost[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->Fill(channel,groupId,bufferOverflowCounter); - } - - else if ( message->is_info() ){ - LOG(debug) << counter << " This is a info message"; - isInfo = true; - //GetEpochInfo(link, addr); - - Int_t triggerType = -1; - Int_t infoType = static_cast<Int_t>(message->info_type()); - Int_t stopType = -1; - Int_t groupId = message->group_id(); - Int_t channel = message->channel_id(); - Int_t time = message->timestamp(); - Int_t bufferOverflowCounter = 0;//mp->buffer_overflow_count();// should be now obsolete - Int_t samples = 1; - Int_t* sample_values = new Int_t[samples]; - sample_values[0] = -256; - new( (*fSpadicRaw)[fSpadicRaw->GetEntriesFast()] ) - CbmSpadicRawMessage(link, address, channel, fEpochMarker, time, - fSuperEpoch, triggerType, infoType, stopType, groupId, - bufferOverflowCounter, samples, sample_values, - isHit, isInfo, isEpoch, isEpochOutOfSync, isHitAborted, isOverflow, isStrange); - delete[] sample_values; - fMessageStatistic[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->Fill(fInfoTypes[infoType].Data(),1); - channel = GetChannelOnPadPlane(channel,groupId); - if (channel > 15){ - channel-= 16; - groupId = 1; - } else { - groupId = 0; - } - if (!fHighPerformance)fInfo[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->Fill(channel,groupId,1); - } - - - else if ( message->is_hit_aborted()) { - LOG(debug) << counter << " This is a hit message was aborted"; - isHitAborted = true; - GetEpochInfo(link, addr); - Int_t triggerType = -1; - Int_t stopType = -1; - Int_t time = message->timestamp(); - Int_t infoType = -1; - Int_t groupId = -1;//mp->group_id();//??? - Int_t bufferOverflowCounter = 0; - Int_t samples = 1; - Int_t* sample_values = NULL; - Int_t channel = message->channel_id(); - infoType = static_cast<Int_t>(message->info_type());// should here be stoptype instead??? - sample_values = new Int_t[samples]; - sample_values[0] = -256; - new( (*fSpadicRaw)[fSpadicRaw->GetEntriesFast()] ) - CbmSpadicRawMessage(link, address, channel, fEpochMarker, time, - fSuperEpoch, triggerType, infoType, stopType, groupId, - bufferOverflowCounter, samples, sample_values, - isHit, isInfo, isEpoch, isEpochOutOfSync, isHitAborted, isOverflow, isStrange); - //++counter; - delete[] sample_values; - fMessageStatistic[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->Fill(fMessageTypes[3].Data(),1); - } - - else { - isStrange = true; - //GetEpochInfo(link, addr); - Int_t triggerType = -1; - Int_t stopType = -1; - Int_t time = -1;//mp->timestamp(); - Int_t infoType = -1; - Int_t groupId = -1;//mp->group_id(); - Int_t bufferOverflowCounter = 0; - Int_t samples = 1; - Int_t* sample_values = NULL; - Int_t channel = -1;//mp->channel_id(); - sample_values = new Int_t[samples]; - sample_values[0] = -256; - new( (*fSpadicRaw)[fSpadicRaw->GetEntriesFast()] ) - CbmSpadicRawMessage(link, address, channel, fEpochMarker, time, - fSuperEpoch, triggerType, infoType, stopType, groupId, - bufferOverflowCounter, samples, sample_values, - isHit, isInfo, isEpoch, isEpochOutOfSync, isHitAborted, isOverflow, isStrange); - //++counter; - delete[] sample_values; - fMessageStatistic[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->Fill(fMessageTypes[6].Data(),1); - //fStrange[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->Fill(channel,groupId); - LOG(debug) << counter << " This message type is not hit, info, epoch or overflow and will not be stored in the TClonesArray"; - LOG(debug) << " valide:" << message->is_valid() << " epoch marker:" << fEpochMarker << " super epoch marker:" << fSuperEpoch << " time:" << time << " link:" << link << " address:" << address; - LOG(debug) << "Channel ID:" << message->channel_id(); - //if ( mp->is_hit_aborted() ) - //LOG(info) << "hit is aborted"; - //if ( mp->is_hit() ) - LOG(debug) << "GroupID:" << message->group_id() << "hit: triggerType:" << static_cast<Int_t>(message->hit_type()) << " stopType:" << static_cast<Int_t>(message->stop_type()) << " Nr.of samples:" << message->samples().size(); - - //if () - std::stringstream ss; - for (auto x : message->samples()) { - ss << " " << x; - } - LOG(debug) << ss.str(); - //if (mp->is_info()) - LOG(debug) << "InfoType:" << static_cast<Int_t>(message->info_type()); - //if () - LOG(debug) << "Nr. of overflows:" << static_cast<Int_t>(message->buffer_overflow_count()); - //print_message(mp); - } - } - - } // End microslice - - return kTRUE; -} - -void CbmTSUnpackSpadic20OnlineMonitor::print_message(const spadic::Message& m) -{ - printf("PrintMsg\n"); - LOG(info) << "v: " << (m.is_valid() ? "o" : "x"); - LOG(debug) << " / gid: " << static_cast<int>(m.group_id()); - LOG(debug) << " / chid: " << static_cast<int>(m.channel_id()); - if ( m.is_hit() ) { - LOG(debug) << " / ts: " << m.timestamp(); - LOG(debug) << " / samples (" << m.samples().size() << "):"; - for (auto x : m.samples()) { - LOG(debug) << " " << x; - } - LOG(debug); - } else { - if ( m.is_epoch_marker() ) { - LOG(debug) << " This is an Epoch Marker"; - } else if ( m.is_epoch_out_of_sync() ) { - LOG(info) << " This is an out of sync Epoch Marker"; - } else { - LOG(info) << " This is not known"; - } - } -} - - -void CbmTSUnpackSpadic20OnlineMonitor::FillEpochInfo(Int_t link, Int_t addr, Int_t epoch_count) -{ - - auto it=groupToExpMap.find(link); - if (it == groupToExpMap.end()) { - LOG(fatal) << "Could not find an entry for equipment ID" << - std::hex << link << std::dec; - } else { - /* Check for repeated Epoch Messages, as the repeated Microslices - are not captured by the CbmTsUnpacker. This is to ensure the - linearity of the GetFullTime() method. - */ - // dirty workaround in the following line: only sufficiently big backsteps of Epoch will trigger an upcount of SuperEpoch. this avoids a high sensitivity of the SuperEpoch counting method to overlaps of some epochs, before the overlaps are understood better - if ( epoch_count < (fEpochMarkerArray[it->second][addr] - 3000) ) - { - if(SuppressMultipliedEpochMessages) - if ( epoch_count != fPreviousEpochMarkerArray[it->second][addr] ){ - fSuperEpochArray[it->second][addr]++; - } else { - LOG(error)<< "Multiply repeated Epoch Messages at Super Epoch " - << fSuperEpoch << " Epoch " - << epoch_count << " for Syscore" - << it->second << "_Spadic" - << addr; - } - else fSuperEpochArray[it->second][addr]++; - - LOG(debug) << "Overflow of EpochCounter for Syscore" - << it->second << "_Spadic" - << addr; - } else if ((epoch_count - fEpochMarkerArray[it->second][addr]) !=1 ) { - LOG(info) << "Missed epoch counter for Syscore" - << it->second << "_Spadic" - << addr; - } else if (epoch_count == fEpochMarkerArray[it->second][addr]){ - LOG(error) << "Identical Epoch Counters for Syscore" - << it->second << "_Spadic" - << addr; - } - fPreviousEpochMarkerArray[it->second][addr] = fEpochMarkerArray[it->second][addr]; - fEpochMarkerArray[it->second][addr] = epoch_count; - } - -} - -void CbmTSUnpackSpadic20OnlineMonitor::GetEpochInfo(Int_t link, Int_t addr) -{ - printf("Get epoch info\n"); - auto it=groupToExpMap.find(link); - if (it == groupToExpMap.end()) { - LOG(fatal) << "Could not find an entry for equipment ID" << - std::hex << link << std::dec; - } else { - fEpochMarker = fEpochMarkerArray[it->second][addr]; - fSuperEpoch = fSuperEpochArray[it->second][addr]; - } - -} - -Int_t CbmTSUnpackSpadic20OnlineMonitor::GetChannelOnPadPlane(Int_t SpadicChannel, Int_t groupId) -{ - if(SpadicChannel > 31 || groupId > 1) LOG(debug) << "CbmTSUnpackSpadic20OnlineMonitor:: ChId " << SpadicChannel << " GroupId: " << groupId; - SpadicChannel = groupId * 16 + SpadicChannel; - Int_t channelMapping[32] = {31,15,30,14,29,13,28,12,27,11,26,10,25, 9,24, 8, - 23, 7,22, 6,21, 5,20, 4,19, 3,18, 2,17, 1,16, 0}; - if (SpadicChannel < 0 || SpadicChannel > 31){ - if (SpadicChannel !=-1) LOG(debug) << "CbmTSUnpackSpadic20OnlineMonitor::GetChannelOnPadPlane ChId " << SpadicChannel << " GroupId: " << groupId; - return -1; - } else { - return channelMapping[SpadicChannel]; - } -} - -Int_t CbmTSUnpackSpadic20OnlineMonitor::GetSpadicID(Int_t address) -{ - //TString spadic=""; - Int_t SpaId = -1; - switch (address) { - case (SpadicBaseAddress+0): // first spadic - //spadic="Spadic0"; - SpaId = 0; - break; - case (SpadicBaseAddress+1): // first spadic - //spadic="Spadic0"; - SpaId = 0; - break; - case (SpadicBaseAddress+2): // second spadic - //spadic="Spadic1"; - SpaId = 1; - break; - case (SpadicBaseAddress+3): // second spadic - //spadic="Spadic1"; - SpaId = 1; - break; - case (SpadicBaseAddress+4): // third spadic - //spadic="Spadic2"; - SpaId = 2; - break; - case (SpadicBaseAddress+5): // third spadic - //spadic="Spadic2"; - SpaId = 2; - break; - default: - LOG(error) << "Source Address " << address << " not known."; - break; - } - return SpaId; -} - -Int_t CbmTSUnpackSpadic20OnlineMonitor::GetSyscoreID(Int_t /*link*/) -{ - /* - Int_t SyscoreID=link-BaseEquipmentID; - if((SyscoreID<0||SyscoreID>3)){ - LOG(debug) << "EqID " << link << " not known."; - SyscoreID=-1; - } - return SyscoreID; - */ - return 0; // FIXME!!!!!! Defaults to AFCK 0!! -} -// ---- ------------------------------------------------------- - - -inline TString CbmTSUnpackSpadic20OnlineMonitor::GetSpadicName(Int_t link,Int_t address){ - - TString spadicName=""; - Int_t SpadicID=0; - spadicName="SysCore_"+std::to_string(GetSyscoreID(link))+"_"; - SpadicID=GetSpadicID(address); - - //SpadicID/=2; - - spadicName += "Spadic_"; - - spadicName+=std::to_string(SpadicID); - - return spadicName; -} - -void CbmTSUnpackSpadic20OnlineMonitor::InitHistos() -{ - - #ifdef USE_HTTP_SERVER - THttpServer* server = FairRunOnline::Instance()->GetHttpServer(); - #endif - - //cout << "InitHistos" << endl; - TString histName; - - - for (Int_t iLink = 0; iLink < NrOfSyscores; iLink++){ - for (Int_t iAddress = 0; iAddress < NrOfSpadics; iAddress++){ - - //histName.Form("SysCore_%i_Spadic_%i",iLink,iAddress); - histName.Form("AFCK_0_Spadic_0"); - - fHM->Add(TString("Baseline_"+histName).Data(),new TH2I (TString("Baseline_"+histName).Data(),TString("Baseline_"+histName).Data(), 128,-256.5,255.5,32,-0.5,31.5)); - fBaseline[(iLink)*(NrOfSpadics)+iAddress]=(TH2I*)fHM->H2(TString("Baseline_"+histName).Data()); - fBaseline[(iLink)*(NrOfSpadics)+iAddress]->GetXaxis()->SetTitle("ADC"); - fBaseline[(iLink)*(NrOfSpadics)+iAddress]->GetYaxis()->SetTitle("Channel ID"); - fHM->Add(TString("maxADC_vs_maxTimeBin_"+histName).Data(),new TH2I (TString("maxADC_vs_maxTimeBin_"+histName).Data(),TString("maxADC_vs_maxTimeBin_"+histName).Data(),32,-0.5,31.5, 128,-256.5,255.5)); - - fmaxADCmaxTimeBin[(iLink)*(NrOfSpadics)+iAddress]=(TH2I*)fHM->H2(TString("maxADC_vs_maxTimeBin_"+histName).Data()); - fmaxADCmaxTimeBin[(iLink)*(NrOfSpadics)+iAddress]->GetXaxis()->SetTitle("max. Time Bin"); - fmaxADCmaxTimeBin[(iLink)*(NrOfSpadics)+iAddress]->GetYaxis()->SetTitle("max ADC"); - fHM->Add(TString("Hit_"+histName).Data(),new TH2I (TString("Hit_"+histName).Data(),TString("Hit_"+histName).Data(),16,-0.5,15.5,2,-0.5,1.5)); - fHit[(iLink)*(NrOfSpadics)+iAddress]=(TH2I*)fHM->H2(TString("Hit_"+histName).Data()); - fHM->Add(TString("Lost_"+histName).Data(),new TH2I (TString("Lost_"+histName).Data(),TString("Lost_"+histName).Data(),16,-0.5,15.5,2,-0.5,1.5)); - fLost[(iLink)*(NrOfSpadics)+iAddress]=(TH2I*)fHM->H2(TString("Lost_"+histName).Data()); - fHM->Add(TString("Epoch_"+histName).Data(),new TH2I (TString("Epoch_"+histName).Data(),TString("Epoch_"+histName).Data(),16,-0.5,15.5,2,-0.5,1.5)); - fEpoch[(iLink)*(NrOfSpadics)+iAddress]=(TH2I*)fHM->H2(TString("Epoch_"+histName).Data()); - fHM->Add(TString("OutOfSync_"+histName).Data(),new TH2I (TString("OutOfSync_"+histName).Data(),TString("OutOfSync_"+histName).Data(),16,-0.5,15.5,2,-0.5,1.5)); - fOutOfSync[(iLink)*(NrOfSpadics)+iAddress]=(TH2I*)fHM->H2(TString("OutOfSync_"+histName).Data()); - fHM->Add(TString("Strange_"+histName).Data(),new TH2I (TString("Strange_"+histName).Data(),TString("Strange_"+histName).Data(),16,-0.5,15.5,2,-0.5,1.5)); - fStrange[(iLink)*(NrOfSpadics)+iAddress]=(TH2I*)fHM->H2(TString("Strange_"+histName).Data()); - fHM->Add(TString("Info_"+histName).Data(),new TH2I (TString("Info_"+histName).Data(),TString("Info_"+histName).Data(),16,-0.5,15.5,2,-0.5,1.5)); - fInfo[(iLink)*(NrOfSpadics)+iAddress]=(TH2I*)fHM->H2(TString("Info_"+histName).Data()); - fTSGraph[(iLink)*(NrOfSpadics)+iAddress] = new TGraph(); - - fHM->Add(TString("Sync_"+histName).Data(),new TH2I (TString("Sync_"+histName).Data(),TString("Sync_"+histName).Data(), 4096,-0.5,4095.5,32,-0.5,31.5)); - fHitSync[(iLink)*(NrOfSpadics)+iAddress]=(TH2I*)fHM->H2(TString("Sync_"+histName).Data()); - - fHM->Add(TString("HitTimeA_"+histName).Data(),new TH1I (TString("HitTimeA_"+histName).Data(),TString("HitTimeA_"+histName).Data(),300,-299.5,0.5)); - fHitTimeA[(iLink)*(NrOfSpadics)+iAddress]=(TH1I*)fHM->H1(TString("HitTimeA_"+histName).Data()); - fHitTimeA[(iLink)*(NrOfSpadics)+iAddress]->GetXaxis()->SetTitle("SuperEpoch count"); - fHM->Add(TString("HitTimeB_"+histName).Data(),new TH1I (TString("HitTimeB_"+histName).Data(),TString("HitTimeB_"+histName).Data(),300,-299.5,0.5)); - fHitTimeB[(iLink)*(NrOfSpadics)+iAddress]=(TH1I*)fHM->H1(TString("HitTimeB_"+histName).Data()); - fHitTimeB[(iLink)*(NrOfSpadics)+iAddress]->GetXaxis()->SetTitle("SuperEpoch count"); - fHitTimeB[(iLink)*(NrOfSpadics)+iAddress]->SetLineColor(2); - fHM->Add(TString("MessageStatistic_"+histName).Data(),new TH1I (TString("MessageStatistic_"+histName).Data(),TString("MessageStatistic_"+histName).Data(),24,-0.5,23.5)); - fMessageStatistic[(iLink)*(NrOfSpadics)+iAddress]=(TH1I*)fHM->H1(TString("MessageStatistic_"+histName).Data()); - for (Int_t iM = 0; iM < 7; iM++){ - fMessageStatistic[(iLink)*(NrOfSpadics)+iAddress]->GetXaxis()->SetBinLabel(iM+1,fMessageTypes[iM]); - } - for (Int_t iT = 0; iT < 4; iT++){ - fMessageStatistic[(iLink)*(NrOfSpadics)+iAddress]->GetXaxis()->SetBinLabel(7+1+iT,fTriggerTypes[iT]); - } - for (Int_t iS = 0; iS < 6; iS++){ - fMessageStatistic[(iLink)*(NrOfSpadics)+iAddress]->GetXaxis()->SetBinLabel(7+4+1+iS,fStopTypes[iS]); - } - for (Int_t iI = 0; iI < 7; iI++){ - fMessageStatistic[(iLink)*(NrOfSpadics)+iAddress]->GetXaxis()->SetBinLabel(7+4+6+1+iI,fInfoTypes[iI]); - } - - // const Int_t nBins=70; - // auto BinBoarders = [&nBins] (Int_t reBinHigh=32){ - // //auto BinBoarders = [&nBins] (Int_t reBinLow=32){ - // const Double_t Threshold = 100.; - // const Double_t MaxFreq = (17500000.0); - // const Double_t slope=MaxFreq/nBins; - // const Int_t iThreshhold=std::ceil((MaxFreq/Threshold-0.5)/static_cast<Double_t>(reBinHigh)); - // LOG(fatal) << "iThresshold = " << iThreshhold; - // Double_t* Result=new Double_t[nBins+1]; - // - // for(Int_t i=0;i<nBins;i++){ - // size_t j=nBins-i; - // //Result[j]=TMath::Power(TMath::E(),i*slope+TMath::Log(2)); - // //printf("%d\n",Result[j]); - // Double_t LowEdge = MaxFreq/(reBinHigh*(i*i)+0.5); - // Result[j]=LowEdge; - // }/* - // for(Int_t i=0;i<nBins-iThreshhold;i++) { - // size_t j=nBins-iThreshhold-i; - // Double_t LowEdge = MaxFreq/(reBinHigh*(iThreshhold)+0.5+RebinLow*(i)); - // Result[j]=LowEdge; - // }*/ - // Result[0]=0.0; - // std::sort(Result,&Result[nBins]); - // return Result; - // }; - // Double_t* freqbins = (BinBoarders()); - - const Int_t nBins = 234; - // const Double_t maxFreq = (175000000.0); (VF) unused - auto BinBoarders = [/*&nBins*/] (Int_t /*reBinHigh*/=32) - { - const Double_t MaxFreq = (175000000.0); - // const Double_t slope=10;//MaxFreq/nBins; (VF) unused - Double_t* Result=new Double_t[nBins+1]; - for(Int_t i=0;i<nBins;i++) - { - size_t j=nBins-i; - Double_t LowEdge = MaxFreq/(TMath::Power(TMath::E(),(0.1*Int_t(i)))); - //printf("LowEdge: %e\n",LowEdge); - Result[j]=LowEdge; - //Result[j]=TMath::Power(TMath::E(),i*slope+TMath::Log(2)); - } - Result[0]=0.1; - std::sort(Result,&Result[nBins]); - return Result; - }; - Double_t* freqbins = (BinBoarders()); - fHM->Add(TString("HitFrequency_"+histName).Data(),new TH1I (TString("HitFrequency_"+histName).Data(),TString("HitFrequency_"+histName).Data(),nBins,freqbins/*100000,1,10000000*/)); - fHitFrequency[(iLink)*(NrOfSpadics)+iAddress]=(TH1I*)fHM->H1(TString("HitFrequency_"+histName).Data()); - fHitFrequency[(iLink)*(NrOfSpadics)+iAddress]->GetXaxis()->SetTitle("Trigger frequency (Hz)"); - fHitFrequency[(iLink)*(NrOfSpadics)+iAddress]->GetYaxis()->SetTitle("Channel ID"); - fHM->Add(TString("Spectrum_"+histName).Data(),new TH1I (TString("Spectrum_"+histName).Data(),TString("Spectrum_"+histName).Data(),513,-256.5,256.5)); - fSpectrum[(iLink)*(NrOfSpadics)+iAddress]=(TH1I*)fHM->H1(TString("Spectrum_"+histName).Data()); - fSpectrum[(iLink)*(NrOfSpadics)+iAddress]->GetXaxis()->SetTitle("max. ADC (ADC)"); - - - - for (Int_t iCh = 0; iCh < 32; iCh++){ - TString chName; - chName.Form("Ch%02i_",iCh); - // FIXME!!! - fHM->Add(TString("PulseShape_"+chName+histName).Data(),new TH2I (TString("PulseShape_"+chName+histName).Data(),TString("PulseShape_"+chName+histName).Data(),32,-0.5,31.5, 128,-256.5,255.5)); - fPulseShape[((iLink)*(NrOfSpadics)+iAddress)*32+iCh]=(TH2I*)fHM->H2(TString("PulseShape_"+chName+histName).Data()); - fPulseShape[((iLink)*(NrOfSpadics)+iAddress)*32+iCh]->GetXaxis()->SetTitle("Time Bin"); - fPulseShape[((iLink)*(NrOfSpadics)+iAddress)*32+iCh]->GetYaxis()->SetTitle("ADC"); - fPulseShape[((iLink)*(NrOfSpadics)+iAddress)*32+iCh]->GetZaxis()->SetTitle("counts"); - } - - for (Int_t iCh = 0; iCh < 32; iCh++){ - TString chName; - chName.Form("Ch%02i_",iCh); - // FIXME!!! - fHM->Add(TString("MaxADC_"+chName+histName).Data(),new TH1D (TString("MaxADC_"+chName+histName).Data(),TString("MaxADC_"+chName+histName).Data(),256,-256.5,255.5)); - fMaxADC[iCh]=(TH1D*)fHM->H1(TString("MaxADC_"+chName+histName).Data()); - fMaxADC[iCh]->GetXaxis()->SetTitle("ADC"); - fMaxADC[iCh]->GetYaxis()->SetTitle("counts"); - } - - } - } -} - - - - -void CbmTSUnpackSpadic20OnlineMonitor::InitCanvas() -{ - TString cName; - if (!fHighPerformance){ - fcE= new TCanvas(TString("EpochMap").Data(),TString("EpochMap").Data(),1600,1200); - fcE->Divide(3,4); - fcO= new TCanvas(TString("OutOfSyncMap").Data(),TString("OutOfSyncMap").Data(),1600,1200); - fcO->Divide(3,4); - fcS= new TCanvas(TString("StrangeMap").Data(),TString("StrangeMap").Data(),1600,1200); - fcS->Divide(3,4); - fcI= new TCanvas(TString("InfoMap").Data(),TString("InfoMap").Data(),1600,1200); - fcI->Divide(3,4); - fcF= new TCanvas(TString("HitFrequency").Data(),TString("HitFrequency").Data(),1600,1200); - fcF->Divide(3,4); - fcSp= new TCanvas(TString("HitSelfTriggersSpectrum").Data(),TString("HitSelfTriggersSpectrum").Data(),1600,1200); - fcSp->Divide(3,4); - } - fcB = new TCanvas(TString("Baseline").Data(),TString("Baseline").Data(),1600,1200); - fcB->Divide(3,4); - fcM/*[(iLink)*(NrOfSpadics)+iAddress]*/ = new TCanvas(TString("maxADC_vs_maxTimeBin").Data(),TString("maxADC_vs_maxTimeBin").Data(),1600,1200); - fcM->Divide(3,4); - fcH= new TCanvas(TString("HitMap").Data(),TString("HitMap").Data(),1600,1200); - fcH->Divide(3,4); - fcL= new TCanvas(TString("LostMap").Data(),TString("LostMap").Data(),1600,1200); - fcL->Divide(3,4); - fcTS= new TCanvas(TString("TSGraph").Data(),TString("TSGraph").Data(),1600,1200); - fcTS->Divide(3,4); - fcMS= new TCanvas(TString("MessageStatistic").Data(),TString("MessageStatistic").Data(),1600,1200); - fcMS->Divide(3,4); - - for (Int_t iLink = 0; iLink < NrOfSyscores; iLink++){ - for (Int_t iAddress = 0; iAddress < NrOfSpadics; iAddress++){ - cName.Form("SysCore_%i_Spadic_%i",iLink,iAddress); - if (!fHighPerformance){ - fcPS[(iLink)*(NrOfSpadics)+iAddress] = new TCanvas(TString("PulseShapes_"+cName).Data(),TString("PulseShapes_"+cName).Data(),1600,1200); - fcPS[(iLink)*(NrOfSpadics)+iAddress]->Divide(4,8); - for(Int_t iCh = 0; iCh < 32; iCh++){ - fcPS[(iLink)*(NrOfSpadics)+iAddress]->cd(iCh+1); - //fPulseShape[((iLink)*(NrOfSpadics)+iAddress)*32+iCh]->Draw("colz"); - fPulseShape[((iLink)*(NrOfSpadics)+iAddress)*32+iCh]->Draw("col"); - } - for(Int_t iCh = 0; iCh < 32; iCh++){ - fcPS[(iLink)*(NrOfSpadics)+iAddress]->cd(iCh+1); - fMaxADC[((iLink)*(NrOfSpadics)+iAddress)*32+iCh]->Draw(""); - } - fcE->cd((iLink)*(NrOfSpadics)+iAddress+1)->SetLogz(0); - fEpoch[(iLink)*(NrOfSpadics)+iAddress]->Draw("colz"); - fcO->cd((iLink)*(NrOfSpadics)+iAddress+1)->SetLogz(0); - fOutOfSync[(iLink)*(NrOfSpadics)+iAddress]->Draw("colz"); - fcS->cd((iLink)*(NrOfSpadics)+iAddress+1)->SetLogz(0); - fStrange[(iLink)*(NrOfSpadics)+iAddress]->Draw("colz"); - fcI->cd((iLink)*(NrOfSpadics)+iAddress+1)->SetLogx(0); - fInfo[(iLink)*(NrOfSpadics)+iAddress]->Draw("colz"); - fcF->cd((iLink)*(NrOfSpadics)+iAddress+1)->SetLogx(1); - fcF->cd((iLink)*(NrOfSpadics)+iAddress+1)->SetLogy(1); - fcF->cd((iLink)*(NrOfSpadics)+iAddress+1)->SetLogz(0); - fHitFrequency[(iLink)*(NrOfSpadics)+iAddress]->Draw(/*"colz"*/); - fcSp->cd((iLink)*(NrOfSpadics)+iAddress+1)->SetLogy(1); - fSpectrum[(iLink)*(NrOfSpadics)+iAddress]->Draw(); - fHitSync[(iLink)*(NrOfSpadics)+iAddress]->Draw("colz"); - } - fcB->cd((iLink)*(NrOfSpadics)+iAddress+1)->SetLogz(); - fBaseline[(iLink)*(NrOfSpadics)+iAddress]->Draw("col"); - cName.Form("AFCK_%i_Spadic_%i",iLink,iAddress); - fcM->cd((iLink)*(NrOfSpadics)+iAddress+1)->SetLogz(); - fmaxADCmaxTimeBin[(iLink)*(NrOfSpadics)+iAddress]->Draw("colz"); - fcH->cd((iLink)*(NrOfSpadics)+iAddress+1)->SetLogz(0); - fHit[(iLink)*(NrOfSpadics)+iAddress]->Draw("colz"); - fcL->cd((iLink)*(NrOfSpadics)+iAddress+1)->SetLogz(0); - fLost[(iLink)*(NrOfSpadics)+iAddress]->Draw("colz"); - fcMS->cd((iLink)*(NrOfSpadics)+iAddress+1)->SetLogy(1); - fMessageStatistic[(iLink)*(NrOfSpadics)+iAddress]->Draw(""); - fcTS->cd((iLink)*(NrOfSpadics)+iAddress+1); - fHitTimeA[(iLink)*(NrOfSpadics)+iAddress]->GetYaxis()->SetRangeUser(0,1000); - fHitTimeA[(iLink)*(NrOfSpadics)+iAddress]->Draw(""); - fHitTimeB[(iLink)*(NrOfSpadics)+iAddress]->Draw("same"); - //fTSGraph[(iLink)*(NrOfSpadics)+iAddress]->Draw("ALP"); - fHitSync[(iLink)*(NrOfSpadics)+iAddress]->Draw("colz"); - } - } - -} - - - -void CbmTSUnpackSpadic20OnlineMonitor::UpdateCanvas() -{ - /* - //cout << "UpdateCanvas" << endl; - TH2I* h = NULL; - TString cName; - for (Int_t iLink = 0; iLink < NrOfSyscores; iLink++){ - for (Int_t iAddress = 0; iAddress < NrOfSpadics; iAddress++){ - cName.Form("AFCK_%i_Spadic_%i",iLink,iAddress); - fcB->cd((iLink)*(NrOfSpadics)+iAddress+1); - fBaseline[(iLink)*(NrOfSpadics)+iAddress]->Draw("colz"); - h = (TH2I*)fHM->H2(TString("Baseline_"+cName).Data()); - h->Draw("colz"); - fcB->cd((iLink)*(NrOfSpadics)+iAddress+1)->Update(); - cName.Form("AFCK_%i_Spadic_%i",iLink,iAddress); - fcM->cd((iLink)*(NrOfSpadics)+iAddress+1); - fmaxADCmaxTimeBin[(iLink)*(NrOfSpadics)+iAddress]->Draw("colz"); - h = (TH2I*)fHM->H2(TString("maxADC_vs_maxTimeBin_"+cName).Data()); - h->Draw("colz"); - fcM->cd((iLink)*(NrOfSpadics)+iAddress+1)->Update(); - } - } - */ -} - -void CbmTSUnpackSpadic20OnlineMonitor::Reset() -{ - fSpadicRaw->Clear(); -} -void CbmTSUnpackSpadic20OnlineMonitor::FinishEvent() -{ - //UpdateCanvas(); -} - -void CbmTSUnpackSpadic20OnlineMonitor::Finish() -{ - for (Int_t i=0; i < NrOfSyscores; ++i) { - for (Int_t j=0; j < NrOfHalfSpadics; ++j) { - LOG(debug) << "There have been " << fSuperEpochArray[i][j] - << " SuperEpochs for Syscore" << i << "_Spadic" - << j << " in this file"; - } - } - UpdateCanvas(); -} - - - /* - void CbmTSUnpackSpadic20OnlineMonitor::Register() - { - } - */ - - - ClassImp(CbmTSUnpackSpadic20OnlineMonitor) diff --git a/beamtime/cern2014/unpacker/CbmTSUnpackSpadic20OnlineMonitor.h b/beamtime/cern2014/unpacker/CbmTSUnpackSpadic20OnlineMonitor.h deleted file mode 100644 index 0025e1c412f56b9c209ec5fc304e332ca36e8881..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/unpacker/CbmTSUnpackSpadic20OnlineMonitor.h +++ /dev/null @@ -1,115 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmTSUnpackSpadic20OnlineMonitor ----- -// ----- Created 20.12.2016 by C. Bergmann ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CBMTSUNPACKSPADIC20ONLINEMONITOR_H -#define CBMTSUNPACKSPADIC20ONLINEMONITOR_H - -#include "Timeslice.hpp" -#include "Message.hpp" - -#include "CbmTSUnpack.h" -#include "CbmBeamDefaults.h" - -#include "CbmHistManager.h" -#include "TClonesArray.h" - -class CbmTSUnpackSpadic20OnlineMonitor : public CbmTSUnpack -{ - public: - - CbmTSUnpackSpadic20OnlineMonitor(Bool_t highPerformancen = true ); - virtual ~CbmTSUnpackSpadic20OnlineMonitor(); - - virtual Bool_t Init(); - - virtual Bool_t DoUnpack(const fles::Timeslice& ts, size_t component); - void print_message(const spadic::Message& m); - - virtual void Reset(); - - virtual void Finish(); - virtual void FinishEvent(); - void SetParContainers() {;} - - // protected: - // virtual void Register(); - - virtual void FillOutput(boost::any){;} - - private: - - TClonesArray* fSpadicRaw; - - Bool_t fHighPerformance; - - Int_t fEpochMarkerArray[NrOfSyscores][NrOfHalfSpadics]; - //Array to store the previous Epoch counter - Int_t fPreviousEpochMarkerArray[NrOfSyscores][NrOfHalfSpadics]; - //Suppress multiple Epoch Messages in duplicated Microslices. NOTE:Currently Buggy - const Bool_t SuppressMultipliedEpochMessages = false; - Int_t fSuperEpochArray[NrOfSyscores][NrOfHalfSpadics]; - - static Int_t GetSpadicID(Int_t address); - static Int_t GetSyscoreID(Int_t link); - inline TString GetSpadicName(Int_t link,Int_t address); - Int_t GetChannelOnPadPlane(Int_t SpadicChannel, Int_t groupId); - Int_t fEpochMarker; - Int_t fSuperEpoch; - Int_t fNrExtraneousSamples; - void GetEpochInfo(Int_t link, Int_t addr); - void FillEpochInfo(Int_t link, Int_t addr, Int_t epoch_count); - CbmHistManager* fHM; - TCanvas* fcB; - TCanvas* fcM;//[(iLink)*(NrOfHalfSpadics/2)]; - TCanvas* fcH; - TCanvas* fcL; - TCanvas* fcE; - TCanvas* fcO; - TCanvas* fcS; - TCanvas* fcI; - TCanvas* fcTS; - TCanvas* fcF; - TCanvas* fcSp; - TCanvas* fcPS[(NrOfSyscores)*(NrOfSpadics)]; - TCanvas* fcMS; - void InitHistos(); - void InitCanvas(); - void UpdateCanvas(); - TH2I* fBaseline[(NrOfSyscores)*(NrOfSpadics)]; - TH2I* fmaxADCmaxTimeBin[(NrOfSyscores)*(NrOfSpadics)]; - TH2I* fHit[(NrOfSyscores)*(NrOfSpadics)]; - TH2I* fLost[(NrOfSyscores)*(NrOfSpadics)]; - TH2I* fEpoch[(NrOfSyscores)*(NrOfSpadics)]; - TH2I* fOutOfSync[(NrOfSyscores)*(NrOfSpadics)]; - TH2I* fStrange[(NrOfSyscores)*(NrOfSpadics)]; - TH2I* fInfo[(NrOfSyscores)*(NrOfSpadics)]; - TH1I* fHitTimeA[(NrOfSyscores)*(NrOfSpadics)]; - TH1I* fHitTimeB[(NrOfSyscores)*(NrOfSpadics)]; - TH1I* fHitFrequency[(NrOfSyscores)*(NrOfSpadics)]; - TH1I* fSpectrum[(NrOfSyscores)*(NrOfSpadics)]; - TH2I* fPulseShape[(NrOfSyscores)*(NrOfSpadics)*32]; - TH1I* fMessageStatistic[(NrOfSyscores)*(NrOfSpadics)]; - TH2I* fHitSync[(NrOfSyscores)*(NrOfSpadics)]; - TGraph* fTSGraph[(NrOfSyscores)*(NrOfSpadics)]; - Int_t fLastSuperEpochA[(NrOfSyscores)*(NrOfSpadics)]; - Int_t fLastSuperEpochB[(NrOfSyscores)*(NrOfSpadics)]; - ULong_t fLastFullTime[NrOfSyscores][NrOfSpadics][32]; - TString fMessageTypes[7]; - TString fTriggerTypes[4]; - TString fStopTypes[6]; - TString fInfoTypes[7]; - //Int_t fSumHitMessages[(NrOfSyscores)*(NrOfSpadics)]; - CbmTSUnpackSpadic20OnlineMonitor(const CbmTSUnpackSpadic20OnlineMonitor&); - CbmTSUnpackSpadic20OnlineMonitor operator=(const CbmTSUnpackSpadic20OnlineMonitor&); - - TH1D* fMaxADC[32]; - - ClassDef(CbmTSUnpackSpadic20OnlineMonitor, 2) - - }; - -#endif diff --git a/beamtime/cern2014/unpacker/CbmTSUnpackSpadicLegacy.cxx b/beamtime/cern2014/unpacker/CbmTSUnpackSpadicLegacy.cxx deleted file mode 100644 index b7f6faec6d7dbbc6ae34d20e99a557cded6a73c4..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/unpacker/CbmTSUnpackSpadicLegacy.cxx +++ /dev/null @@ -1,224 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- Cbmtsunpackspadic ----- -// ----- Created 07.11.2014 by F. Uhlig ----- -// ----- ----- -// ----------------------------------------------------------------------------- -#include "CbmTSUnpackSpadicLegacy.h" - -#include "CbmSpadicRawMessage.h" - -#include "TimesliceReader.hpp" - -#include "FairLogger.h" -#include "FairRootManager.h" - -#include "TClonesArray.h" - -#include <iostream> - -CbmTSUnpackSpadicLegacy::CbmTSUnpackSpadicLegacy() - : CbmTSUnpack(), - fSpadicRaw(new TClonesArray("CbmSpadicRawMessage", 10)), - fEpochMarkerArray(), - fSuperEpochArray(), - fEpochMarker(0), - fSuperEpoch(0) -{ - for (Int_t i=0; i < NrOfSyscores; ++i) { - for (Int_t j=0; j < NrOfHalfSpadics; ++j) { - fEpochMarkerArray[i][j] = 0; - fSuperEpochArray[i][j] = 0; - } - } -} - -CbmTSUnpackSpadicLegacy::~CbmTSUnpackSpadicLegacy() -{ -} - -Bool_t CbmTSUnpackSpadicLegacy::Init() -{ - LOG(info) << "Initializing"; - - FairRootManager* ioman = FairRootManager::Instance(); - if (ioman == NULL) { - LOG(fatal) << "No FairRootManager instance"; - } - ioman->Register("SpadicRawMessage", "spadic raw data", fSpadicRaw, kTRUE); - - return kTRUE; -} - -Bool_t CbmTSUnpackSpadicLegacy::DoUnpack(const fles::Timeslice& ts, size_t component) -{ - // compare to: https://github.com/spadic/spadic10-software/blob/master/lib/message/message.h - LOG(debug) << "Unpacking Spadic Data"; - - spadic::TimesliceReader r; - Int_t counter=0; - - r.add_component(ts, component); - - for (auto addr : r.sources()) { - LOG(debug) << "---- reader " << addr << " ----"; - while (auto mp = r.get_message(addr)) { - if(gLogger->IsLogNeeded( fair::Severity::debug )) { - print_message(*mp); - } - - Int_t link = ts.descriptor(component, 0).eq_id; - Int_t address = addr; - - if ( mp->is_epoch_marker() ) { - FillEpochInfo(link, addr, mp->epoch_count()); - } - if ( mp->is_info() ){ - //std::cout << "InfoMessage found" << std::endl; - - GetEpochInfo(link, addr); - - Int_t triggerType = -1; - Int_t infoType = static_cast<Int_t>(mp->info_type()); - Int_t stopType = -1; - Int_t groupId = mp->group_id(); - Int_t channel = mp->channel_id(); - Int_t time = mp->timestamp(); - Int_t bufferOverflowCounter = mp->buffer_overflow_count(); - Int_t samples = 1; - Int_t* sample_values = new Int_t[samples]; - sample_values[0] = -256; - new( (*fSpadicRaw)[fSpadicRaw->GetEntriesFast()] ) - CbmSpadicRawMessage(link, address, channel, fEpochMarker, time, - fSuperEpoch, triggerType, infoType, stopType, groupId, - bufferOverflowCounter, samples, sample_values); - delete[] sample_values; - } - - if ( mp->is_hit() ) { - - GetEpochInfo(link, addr); - Int_t triggerType = -1; - Int_t stopType = -1; - Int_t time = -1; - Int_t infoType = -1; - Int_t groupId = -1; - Int_t bufferOverflowCounter = 0; - Int_t samples = 1; - Int_t* sample_values = NULL; - Int_t channel = mp->channel_id(); - if ( mp->is_hit_aborted()){ - infoType = static_cast<Int_t>(mp->info_type()); - sample_values = new Int_t[samples]; - sample_values[0] = -256; - } else { - groupId = mp->group_id(); - - triggerType = static_cast<Int_t>(mp->hit_type()); - stopType = static_cast<Int_t>(mp->stop_type()); - time = mp->timestamp(); - samples = mp->samples().size(); - sample_values = new Int_t[samples]; - Int_t counter1=0; - for (auto x : mp->samples()) { - sample_values[counter1] = x; - ++counter1; - } - } - new( (*fSpadicRaw)[fSpadicRaw->GetEntriesFast()] ) - CbmSpadicRawMessage(link, address, channel, fEpochMarker, time, - fSuperEpoch, triggerType, infoType, stopType, groupId, - bufferOverflowCounter, samples, sample_values); - ++counter; - delete[] sample_values; - } - } - } - return kTRUE; -} - -void CbmTSUnpackSpadicLegacy::print_message(const spadic::Message& m) -{ - LOG(debug) << "v: " << (m.is_valid() ? "o" : "x"); - LOG(debug) << " / gid: " << static_cast<int>(m.group_id()); - LOG(debug) << " / chid: " << static_cast<int>(m.channel_id()); - if ( m.is_hit() ) { - LOG(debug) << " / ts: " << m.timestamp(); - LOG(debug) << " / samples (" << m.samples().size() << "):"; - std::stringstream ss; - for (auto x : m.samples()) { - ss << " " << x; - } - LOG(debug) << ss.str(); - } else { - if ( m.is_epoch_marker() ) { - LOG(debug) << " This is an Epoch Marker"; - } else if ( m.is_epoch_out_of_sync() ) { - LOG(info) << " This is an out of sync Epoch Marker"; - } else { - LOG(debug) << " This is not known"; - } - } -} - -void CbmTSUnpackSpadicLegacy::FillEpochInfo(Int_t link, Int_t addr, Int_t epoch_count) -{ - auto it=groupToExpMap.find(link); - if (it == groupToExpMap.end()) { - LOG(fatal) << "Could not find an entry for equipment ID" << - std::hex << link << std::dec; - } else { - if ( epoch_count < fEpochMarkerArray[it->second][addr] ) { - fSuperEpochArray[it->second][addr]++; - LOG(debug) << "Overflow of EpochCounter for Syscore" - << it->second << "_Spadic" - << addr; - } else if ((epoch_count - fEpochMarkerArray[it->second][addr]) !=1 ) { - LOG(info) << "Missed epoch counter for Syscore" - << it->second << "_Spadic" - << addr; - } - fEpochMarkerArray[it->second][addr] = epoch_count; - } - -} - -void CbmTSUnpackSpadicLegacy::GetEpochInfo(Int_t link, Int_t addr) -{ - auto it=groupToExpMap.find(link); - if (it == groupToExpMap.end()) { - LOG(fatal) << "Could not find an entry for equipment ID" << - std::hex << link << std::dec; - } else { - fEpochMarker = fEpochMarkerArray[it->second][addr]; - fSuperEpoch = fSuperEpochArray[it->second][addr]; - } - -} - -void CbmTSUnpackSpadicLegacy::Reset() -{ - fSpadicRaw->Clear(); -} - -void CbmTSUnpackSpadicLegacy::Finish() -{ - for (Int_t i=0; i < NrOfSyscores; ++i) { - for (Int_t j=0; j < NrOfHalfSpadics; ++j) { - LOG(debug) << "There have been " << fSuperEpochArray[i][j] - << " SuperEpochs for Syscore" << i << "_Spadic" - << j << " in this file"; - } - } - -} - - -/* -void CbmTSUnpackSpadicLegacy::Register() -{ -} -*/ - - -ClassImp(CbmTSUnpackSpadicLegacy) diff --git a/beamtime/cern2014/unpacker/CbmTSUnpackSpadicLegacy.h b/beamtime/cern2014/unpacker/CbmTSUnpackSpadicLegacy.h deleted file mode 100644 index 811d346c872e63eb0a88cd53b7f30ec5443fd87a..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/unpacker/CbmTSUnpackSpadicLegacy.h +++ /dev/null @@ -1,69 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmTSUnpackSpadic ----- -// ----- Created 07.11.2014 by F. Uhlig ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CBMTSUNPACKSPADICLEGACY_H -#define CBMTSUNPACKSPADICLEGACY_H - -#include "CbmTSUnpack.h" -#include "CbmBeamDefaults.h" - -#include "TClonesArray.h" - -#include "Timeslice.hpp" -#include "Message.hpp" - -class CbmTSUnpackSpadicLegacy : public CbmTSUnpack -{ - public: - - CbmTSUnpackSpadicLegacy(); - virtual ~CbmTSUnpackSpadicLegacy(); - - virtual Bool_t Init(); - - virtual Bool_t DoUnpack(const fles::Timeslice& ts, size_t component); - void print_message(const spadic::Message& m); - - virtual void Reset(); - - virtual void Finish(); - - void SetParContainers() {;} - - // protected: - // virtual void Register(); - - virtual void FillOutput(boost::any){;} - - static const Int_t NrOfSyscores2 = 3; - static const Int_t NrOfSpadics2 = 3; - static const Int_t NrOfHalfSpadics2 = NrOfSpadics2*2; - - - private: - - TClonesArray* fSpadicRaw; - - Int_t fEpochMarkerArray[NrOfSyscores2][NrOfHalfSpadics2]; -//Array to store the previous Epoch counter - Int_t fPreviousEpochMarkerArray[NrOfSyscores2][NrOfHalfSpadics2]; - Int_t fSuperEpochArray[NrOfSyscores2][NrOfHalfSpadics2]; - - Int_t fEpochMarker; - Int_t fSuperEpoch; - - void GetEpochInfo(Int_t link, Int_t addr); - void FillEpochInfo(Int_t link, Int_t addr, Int_t epoch_count); - - CbmTSUnpackSpadicLegacy(const CbmTSUnpackSpadicLegacy&); - CbmTSUnpackSpadicLegacy operator=(const CbmTSUnpackSpadicLegacy&); - - ClassDef(CbmTSUnpackSpadicLegacy, 2) -}; - -#endif - diff --git a/beamtime/cern2014/unpacker/CbmTSUnpackSpadicOnlineFex.cxx b/beamtime/cern2014/unpacker/CbmTSUnpackSpadicOnlineFex.cxx deleted file mode 100644 index 2eaef965115e10200e044d9ce1883c49f5d61b52..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/unpacker/CbmTSUnpackSpadicOnlineFex.cxx +++ /dev/null @@ -1,858 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmTSUnpackSpadicOnlineFex ----- -// ----- Created 10.12.2016 by C. Bergmann ----- -// ----- ----- -// ----------------------------------------------------------------------------- -#include "CbmTSUnpackSpadicOnlineFex.h" - -#include "CbmSpadicRawMessage.h" - -#include "TimesliceReader.hpp" - -#include "FairLogger.h" -#include "FairRootManager.h" - -#include "TClonesArray.h" - -#include "CbmHistManager.h" -#include "TCanvas.h" -#include "TH1.h" -#include "TH2.h" -#include "TH3.h" -#include "TMultiGraph.h" -#include "TMath.h" -#include "FairRun.h" -#include "FairRunOnline.h" -#include "THttpServer.h" - -#include <iostream> -#include <map> -#include <vector> - -CbmTSUnpackSpadicOnlineFex::CbmTSUnpackSpadicOnlineFex(Bool_t highPerformance) - : CbmTSUnpack(), - fSpadicRaw(new TClonesArray("CbmSpadicRawMessage", 10)), - fHighPerformance(highPerformance), - fEpochMarkerArray(), - fPreviousEpochMarkerArray(), - fSuperEpochArray(), - fEpochMarker(0), - fSuperEpoch(0), - fNrExtraneousSamples{0}, - fHM(new CbmHistManager()), - fcB(NULL), - fcM(NULL), - fcH(NULL), - fcL(NULL), - fcE(NULL), - fcO(NULL), - fcS(NULL), - fcI(NULL), - fcTS(NULL), - fcF(NULL), - fcSp(NULL), - fcPS{NULL}, - fcMS{NULL}, - fBaseline{NULL}, - fmaxADCmaxTimeBin{NULL}, - fHit{NULL}, - fLost{NULL}, - fEpoch{NULL}, - fOutOfSync{NULL}, - fStrange{NULL}, - fInfo{NULL}, - fHitTimeA{NULL}, - fHitTimeB{NULL}, - fHitFrequency{NULL}, - fSpectrum{NULL}, - fPulseShape{NULL}, - fMessageStatistic{NULL}, - fTSGraph{NULL}, - fLastSuperEpochA{0}, - fLastSuperEpochB{0}, - fLastFullTime{{{0}}}, - fMessageTypes{"Epoch", - "Epoch out of synch", - "Hit", - "Hit aborted", - "Info", - "Overflow", - "Strange"}, - fTriggerTypes{ "Global trigger", - "Self triggered", - "Neighbor triggered", - "Self and neighbor triggered"}, - fStopTypes{"Normal end of message", - "Channel buffer full", - "Ordering FIFO full", - "Multi hit", - "Multi hit and channel buffer full", - "Multi hit and ordering FIFO full"}, - fInfoTypes{"Channel disabled during message building", - "Next grant timeout", - "Next request timeout", - "New grant but channel empty", - "Corruption in message builder", - "Empty word", - "Epoch out of sync"} -{ - for (Int_t i=0; i < NrOfSyscores; ++i) { - for (Int_t j=0; j < NrOfHalfSpadics; ++j) { - fEpochMarkerArray[i][j] = 0; - fPreviousEpochMarkerArray[i][j] =0; - fSuperEpochArray[i][j] = 0; - } - } - InitHistos(); - InitCanvas(); -} - - CbmTSUnpackSpadicOnlineFex::~CbmTSUnpackSpadicOnlineFex() - { - LOG(info) << "Number of extraneous Samples "<< fNrExtraneousSamples; - } - - Bool_t CbmTSUnpackSpadicOnlineFex::Init() - { - LOG(info) << "Initializing"; - - FairRootManager* ioman = FairRootManager::Instance(); - if (ioman == NULL) { - LOG(fatal) << "No FairRootManager instance"; - } - ioman->Register("SpadicRawMessage", "spadic raw data", fSpadicRaw, kTRUE); - - return kTRUE; - } - -Bool_t CbmTSUnpackSpadicOnlineFex::DoUnpack(const fles::Timeslice& ts, size_t component) -{ - // compare to: https://github.com/spadic/spadic10-software/blob/master/lib/message/message.h - // or fles/spadic/message/wrap/cpp/message.cpp - LOG(debug) << "Unpacking Spadic Data"; - // TH2I* h = NULL; (VF) not used - TString cName; - spadic::TimesliceReader r; - Int_t counter=0; - - r.add_component(ts, component); - - for (auto addr : r.sources()) { - LOG(debug) << "---- reader " << addr << " ----"; - while (auto mp = r.get_message(addr)) { - if(gLogger->IsLogNeeded( fair::Severity::debug )) { - print_message(*mp); - } - counter++; - Int_t link = ts.descriptor(component, 0).eq_id; - Int_t address = addr; - /* - if ( mp->is_valid() ){ - LOG(debug) << counter << " This message is valid"; - } else { - LOG(error) << counter << " This message is not valid"; - continue; - } - */ - Bool_t isInfo(false), isHit(false), isEpoch(false), isEpochOutOfSync(false), isOverflow(false), isHitAborted(false), isStrange(false); - if ( mp->is_epoch_out_of_sync() ){ - isEpochOutOfSync = true; - FillEpochInfo(link, addr, mp->epoch_count()); - GetEpochInfo(link, addr); - Int_t triggerType = -1; - Int_t infoType = -1; - Int_t stopType = -1; - Int_t groupId = mp->group_id(); - Int_t channel = mp->channel_id(); - Int_t time = -1; - Int_t bufferOverflowCounter = 0; - Int_t samples = 1; - Int_t* sample_values = new Int_t[samples]; - sample_values[0] = -256; - LOG(debug) << counter << " This is an out of sync Epoch Marker"; - LOG(debug) << " TimeStamp: " << mp->timestamp(); - LOG(debug) << " Channel: " << mp->channel_id(); - LOG(debug) << " Group: " << mp->group_id(); - new( (*fSpadicRaw)[fSpadicRaw->GetEntriesFast()] ) - CbmSpadicRawMessage(link, address, channel, fEpochMarker, time, - fSuperEpoch, triggerType, infoType, stopType, groupId, - bufferOverflowCounter, samples, sample_values, - isHit, isInfo, isEpoch, isEpochOutOfSync, isHitAborted, isOverflow, isStrange); - delete[] sample_values; - fMessageStatistic[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->Fill(fMessageTypes[1].Data(),1); - if (!fHighPerformance)fOutOfSync[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->Fill(channel,groupId,1); - } - else if ( mp->is_epoch_marker() ) { - LOG(debug) << counter << " This is an Epoch Marker"; - isEpoch = true; - FillEpochInfo(link, addr, mp->epoch_count()); - GetEpochInfo(link, addr); - Int_t triggerType = -1; - Int_t infoType = -1; - Int_t stopType = -1; - Int_t groupId = mp->group_id(); - Int_t channel = mp->channel_id(); - Int_t time = -1; - Int_t bufferOverflowCounter = 0; - Int_t samples = 1; - Int_t* sample_values = new Int_t[samples]; - sample_values[0] = -256; - new( (*fSpadicRaw)[fSpadicRaw->GetEntriesFast()] ) - CbmSpadicRawMessage(link, address, channel, fEpochMarker, time, - fSuperEpoch, triggerType, infoType, stopType, groupId, - bufferOverflowCounter, samples, sample_values, - isHit, isInfo, isEpoch, isEpochOutOfSync, isHitAborted, isOverflow, isStrange); - delete[] sample_values; - fMessageStatistic[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->Fill(fMessageTypes[0].Data(),1); - if (!fHighPerformance)fEpoch[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->Fill(channel,groupId,1); - } - else if ( mp->is_buffer_overflow() ){ - LOG(debug) << counter << " This is a buffer overflow message"; - isOverflow = true; - GetEpochInfo(link, addr); - Int_t triggerType = -1; - Int_t infoType = -1; - Int_t stopType = -1; - Int_t groupId = mp->group_id(); - Int_t channel = mp->channel_id(); - Int_t time = mp->timestamp(); - Int_t bufferOverflowCounter = static_cast<Int_t>(mp->buffer_overflow_count()); - Int_t samples = 1; - Int_t* sample_values = new Int_t[samples]; - sample_values[0] = -256; - new( (*fSpadicRaw)[fSpadicRaw->GetEntriesFast()] ) - CbmSpadicRawMessage(link, address, channel, fEpochMarker, time, - fSuperEpoch, triggerType, infoType, stopType, groupId, - bufferOverflowCounter, samples, sample_values, - isHit, isInfo, isEpoch, isEpochOutOfSync, isHitAborted, isOverflow, isStrange); - delete[] sample_values; - fMessageStatistic[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->Fill(fMessageTypes[5].Data(),bufferOverflowCounter); - channel = GetChannelOnPadPlane(channel,groupId); - if (channel > 15){ - channel-= 16; - groupId = 1; - } else { - groupId = 0; - } - fLost[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->Fill(channel,groupId,bufferOverflowCounter); - } - else if ( mp->is_info() ){ - LOG(debug) << counter << " This is a info message"; - isInfo = true; - GetEpochInfo(link, addr); - - Int_t triggerType = -1; - Int_t infoType = static_cast<Int_t>(mp->info_type()); - Int_t stopType = -1; - Int_t groupId = mp->group_id(); - Int_t channel = mp->channel_id(); - Int_t time = mp->timestamp(); - Int_t bufferOverflowCounter = 0;//mp->buffer_overflow_count();// should be now obsolete - Int_t samples = 1; - Int_t* sample_values = new Int_t[samples]; - sample_values[0] = -256; - new( (*fSpadicRaw)[fSpadicRaw->GetEntriesFast()] ) - CbmSpadicRawMessage(link, address, channel, fEpochMarker, time, - fSuperEpoch, triggerType, infoType, stopType, groupId, - bufferOverflowCounter, samples, sample_values, - isHit, isInfo, isEpoch, isEpochOutOfSync, isHitAborted, isOverflow, isStrange); - delete[] sample_values; - fMessageStatistic[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->Fill(fInfoTypes[infoType].Data(),1); - channel = GetChannelOnPadPlane(channel,groupId); - if (channel > 15){ - channel-= 16; - groupId = 1; - } else { - groupId = 0; - } - if (!fHighPerformance)fInfo[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->Fill(channel,groupId,1); - } - else if ( mp->is_hit() ) { - LOG(debug) << counter << " This is a hit message"; - isHit = true; - GetEpochInfo(link, addr); - Int_t triggerType = static_cast<Int_t>(mp->hit_type()); - Int_t stopType = static_cast<Int_t>(mp->stop_type()); - Int_t time = mp->timestamp(); - Int_t infoType = -1; - Int_t groupId = mp->group_id(); - Int_t bufferOverflowCounter = 0; - Int_t samples = mp->samples().size(); - if(samples>32) { - fNrExtraneousSamples++; - samples=32; //Suppress extraneous Samples, which cannot (!) occur in Raw Data Stream. - } - Int_t* sample_values = new Int_t[samples]; - Int_t channel = mp->channel_id(); - Int_t padRow(-1); - Int_t padChannel = GetChannelOnPadPlane(channel,groupId); - - Int_t counter1=0; - Int_t maxADC(-256), maxTB(-1); - for (auto x : mp->samples()) { - sample_values[counter1] = x; - if (triggerType == 1 && stopType == 0 && sample_values[2]>-150) { - if (!fHighPerformance)fPulseShape[(GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address))*32+channel+16*(groupId%2)]->Fill(counter1,x); - } - if (x >= maxADC){ - maxADC = x; - maxTB = counter1; - } - ++counter1; - } - if (GetSpadicID(address) > 2 || GetSyscoreID(link) > 3){ - printf("link:%i SysCoreID:%i address:%i SpadicID:%i array:%i\n",link,GetSyscoreID(link),address,GetSpadicID(address),GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)); - } else { - if (triggerType == 1 && stopType == 0){ - cName.Form("SysCore_%i_Spadic_%i",GetSyscoreID(link),GetSpadicID(address)); - //h = (TH2I*)fHM->H2(TString("Baseline_"+cName).Data()); - //h->Fill(sample_values[0],groupId*16+channel); - fBaseline[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->Fill(sample_values[0],groupId*16+channel); - fmaxADCmaxTimeBin[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->Fill(maxTB,maxADC); - - if (maxTB > 0 && maxTB < 5){ - if (!fHighPerformance)fSpectrum[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->Fill(maxADC/*-sample_values[0]*/); - } - } - } - //} - new( (*fSpadicRaw)[fSpadicRaw->GetEntriesFast()] ) - CbmSpadicRawMessage(link, address, channel, fEpochMarker, time, - fSuperEpoch, triggerType, infoType, stopType, groupId, - bufferOverflowCounter, samples, sample_values, - isHit, isInfo, isEpoch, isEpochOutOfSync, isHitAborted, isOverflow, isStrange); - //++counter; - delete[] sample_values; - fMessageStatistic[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->Fill(fStopTypes[stopType].Data(),1); - fMessageStatistic[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->Fill(fTriggerTypes[triggerType].Data(),1); - - if (groupId == 0){ - fHitTimeA[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->Fill(0); - if(fLastSuperEpochA[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)] < fSuperEpoch){ - fLastSuperEpochA[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)] = fSuperEpoch; - for (Int_t i = 1; i < fHitTimeA[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->GetXaxis()->GetNbins(); i++){ - fHitTimeA[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->SetBinContent(i, fHitTimeA[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->GetBinContent(i+1)); - } - fHitTimeA[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->SetBinContent(fHitTimeA[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->GetXaxis()->GetNbins(),0); - } - }else{ - fHitTimeB[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->Fill(0); - if(fLastSuperEpochB[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)] < fSuperEpoch){ - fLastSuperEpochB[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)] = fSuperEpoch; - for (Int_t i = 1; i < fHitTimeB[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->GetXaxis()->GetNbins(); i++){ - fHitTimeB[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->SetBinContent(i, fHitTimeB[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->GetBinContent(i+1)); - } - fHitTimeB[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->SetBinContent(fHitTimeB[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->GetXaxis()->GetNbins(),0); - } - } - if (padChannel > 15){ - padChannel -= 16; - padRow = 1; - } else { - padRow = 0; - } - fHit[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->Fill(padChannel,padRow,1); - /* - fTSGraph[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->SetPoint(fTSGraph[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->GetN(),fTSGraph[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->GetN(),//fSpadicRaw[fSpadicRaw->GetEntriesFast()]->GetFullTime()/1.5E7 - ( static_cast<ULong_t>(fSuperEpoch) << 24) | - ( static_cast<ULong_t>(fEpochMarker) << 12) | - ( time & 0xfff ) - ); - */ - ULong_t fullTime = ( static_cast<ULong_t>(fSuperEpoch) << 24) | - ( static_cast<ULong_t>(fEpochMarker) << 12) | - ( time & 0xfff ); - //if (fLastFullTime[GetSyscoreID(link)][GetSpadicID(address)][channel] < fullTime) - //{ - ULong_t deltaTime = fullTime - fLastFullTime[GetSyscoreID(link)][GetSpadicID(address)][channel]; - if (!fHighPerformance)fHitFrequency[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->Fill(1./(deltaTime/1.5E7)/*,channel*/); - fLastFullTime[GetSyscoreID(link)][GetSpadicID(address)][channel] = fullTime; - //} - } - else if ( mp->is_hit_aborted()) { - LOG(debug) << counter << " This is a hit message was aborted"; - isHitAborted = true; - GetEpochInfo(link, addr); - Int_t triggerType = -1; - Int_t stopType = -1; - Int_t time = mp->timestamp(); - Int_t infoType = -1; - Int_t groupId = -1;//mp->group_id();//??? - Int_t bufferOverflowCounter = 0; - Int_t samples = 1; - Int_t* sample_values = NULL; - Int_t channel = mp->channel_id(); - infoType = static_cast<Int_t>(mp->info_type());// should here be stoptype instead??? - sample_values = new Int_t[samples]; - sample_values[0] = -256; - new( (*fSpadicRaw)[fSpadicRaw->GetEntriesFast()] ) - CbmSpadicRawMessage(link, address, channel, fEpochMarker, time, - fSuperEpoch, triggerType, infoType, stopType, groupId, - bufferOverflowCounter, samples, sample_values, - isHit, isInfo, isEpoch, isEpochOutOfSync, isHitAborted, isOverflow, isStrange); - //++counter; - delete[] sample_values; - fMessageStatistic[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->Fill(fMessageTypes[3].Data(),1); - } - else { - isStrange = true; - //GetEpochInfo(link, addr); - Int_t triggerType = -1; - Int_t stopType = -1; - Int_t time = -1;//mp->timestamp(); - Int_t infoType = -1; - Int_t groupId = -1;//mp->group_id(); - Int_t bufferOverflowCounter = 0; - Int_t samples = 1; - Int_t* sample_values = NULL; - Int_t channel = -1;//mp->channel_id(); - sample_values = new Int_t[samples]; - sample_values[0] = -256; - new( (*fSpadicRaw)[fSpadicRaw->GetEntriesFast()] ) - CbmSpadicRawMessage(link, address, channel, fEpochMarker, time, - fSuperEpoch, triggerType, infoType, stopType, groupId, - bufferOverflowCounter, samples, sample_values, - isHit, isInfo, isEpoch, isEpochOutOfSync, isHitAborted, isOverflow, isStrange); - //++counter; - delete[] sample_values; - fMessageStatistic[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->Fill(fMessageTypes[6].Data(),1); - //fStrange[GetSyscoreID(link) * NrOfSpadics + GetSpadicID(address)]->Fill(channel,groupId); - LOG(debug) << counter << " This message type is not hit, info, epoch or overflow and will not be stored in the TClonesArray"; - LOG(debug) << " valide:" << mp->is_valid() << " epoch marker:" << fEpochMarker << " super epoch marker:" << fSuperEpoch << " time:" << time << " link:" << link << " address:" << address; - LOG(debug) << "Channel ID:" << mp->channel_id(); - //if ( mp->is_hit_aborted() ) - //LOG(info) << "hit is aborted"; - //if ( mp->is_hit() ) - LOG(debug) << "GroupID:" << mp->group_id() << "hit: triggerType:" << static_cast<Int_t>(mp->hit_type()) << " stopType:" << static_cast<Int_t>(mp->stop_type()) << " Nr.of samples:" << mp->samples().size(); - - //if () - std::stringstream ss; - for (auto x : mp->samples()) { - ss << " " << x; - } - LOG(debug) << ss.str(); - //if (mp->is_info()) - LOG(debug) << "InfoType:" << static_cast<Int_t>(mp->info_type()); - //if () - LOG(debug) << "Nr. of overflows:" << static_cast<Int_t>(mp->buffer_overflow_count()); - //print_message(mp); - } - } - } - if (fSuperEpoch%1000 == 0) - UpdateCanvas(); - return kTRUE; -} - - void CbmTSUnpackSpadicOnlineFex::print_message(const spadic::Message& m) - { - LOG(info) << "v: " << (m.is_valid() ? "o" : "x"); - LOG(debug) << " / gid: " << static_cast<int>(m.group_id()); - LOG(debug) << " / chid: " << static_cast<int>(m.channel_id()); - if ( m.is_hit() ) { - LOG(debug) << " / ts: " << m.timestamp(); - LOG(debug) << " / samples (" << m.samples().size() << "):"; - std::stringstream ss; - for (auto x : m.samples()) { - ss << " " << x; - } - LOG(debug) << ss.str(); - } else { - if ( m.is_epoch_marker() ) { - LOG(debug) << " This is an Epoch Marker"; - } else if ( m.is_epoch_out_of_sync() ) { - LOG(info) << " This is an out of sync Epoch Marker"; - } else { - LOG(info) << " This is not known"; - } - } - } - - void CbmTSUnpackSpadicOnlineFex::FillEpochInfo(Int_t link, Int_t addr, Int_t epoch_count) - { - auto it=groupToExpMap.find(link); - if (it == groupToExpMap.end()) { - LOG(fatal) << "Could not find an entry for equipment ID" << - std::hex << link << std::dec; - } else { - /* Check for repeated Epoch Messages, as the repeated Microslices - are not captured by the CbmTsUnpacker. This is to ensure the - linearity of the GetFullTime() method. - */ - // dirty workaround in the following line: only sufficiently big backsteps of Epoch will trigger an upcount of SuperEpoch. this avoids a high sensitivity of the SuperEpoch counting method to overlaps of some epochs, before the overlaps are understood better - if ( epoch_count < (fEpochMarkerArray[it->second][addr] - 3000) ) - { - if(SuppressMultipliedEpochMessages) - if ( epoch_count != fPreviousEpochMarkerArray[it->second][addr] ){ - fSuperEpochArray[it->second][addr]++; - } else { - LOG(error)<< "Multiply repeated Epoch Messages at Super Epoch " - << fSuperEpoch << " Epoch " - << epoch_count << " for Syscore" - << it->second << "_Spadic" - << addr; - } - else fSuperEpochArray[it->second][addr]++; - - LOG(debug) << "Overflow of EpochCounter for Syscore" - << it->second << "_Spadic" - << addr; - } else if ((epoch_count - fEpochMarkerArray[it->second][addr]) !=1 ) { - LOG(info) << "Missed epoch counter for Syscore" - << it->second << "_Spadic" - << addr; - } else if (epoch_count == fEpochMarkerArray[it->second][addr]){ - LOG(error) << "Identical Epoch Counters for Syscore" - << it->second << "_Spadic" - << addr; - } - fPreviousEpochMarkerArray[it->second][addr] = fEpochMarkerArray[it->second][addr]; - fEpochMarkerArray[it->second][addr] = epoch_count; - } - - } - - void CbmTSUnpackSpadicOnlineFex::GetEpochInfo(Int_t link, Int_t addr) - { - auto it=groupToExpMap.find(link); - if (it == groupToExpMap.end()) { - LOG(fatal) << "Could not find an entry for equipment ID" << - std::hex << link << std::dec; - } else { - fEpochMarker = fEpochMarkerArray[it->second][addr]; - fSuperEpoch = fSuperEpochArray[it->second][addr]; - } - - } - Int_t CbmTSUnpackSpadicOnlineFex::GetChannelOnPadPlane(Int_t SpadicChannel, Int_t groupId) - { - if(SpadicChannel > 31 || groupId > 1) LOG(debug) << "CbmTSUnpackSpadicOnlineFex:: ChId " << SpadicChannel << " GroupId: " << groupId; - SpadicChannel = groupId * 16 + SpadicChannel; - Int_t channelMapping[32] = {31,15,30,14,29,13,28,12,27,11,26,10,25, 9,24, 8, - 23, 7,22, 6,21, 5,20, 4,19, 3,18, 2,17, 1,16, 0}; - if (SpadicChannel < 0 || SpadicChannel > 31){ - if (SpadicChannel !=-1) LOG(debug) << "CbmTSUnpackSpadicOnlineFex::GetChannelOnPadPlane ChId " << SpadicChannel << " GroupId: " << groupId; - return -1; - } else { - return channelMapping[SpadicChannel]; - } - } - - Int_t CbmTSUnpackSpadicOnlineFex::GetSpadicID(Int_t address) - { - //TString spadic=""; - Int_t SpaId = -1; - switch (address) { - case (SpadicBaseAddress+0): // first spadic - //spadic="Spadic0"; - SpaId = 0; - break; - case (SpadicBaseAddress+1): // first spadic - //spadic="Spadic0"; - SpaId = 0; - break; - case (SpadicBaseAddress+2): // second spadic - //spadic="Spadic1"; - SpaId = 1; - break; - case (SpadicBaseAddress+3): // second spadic - //spadic="Spadic1"; - SpaId = 1; - break; - case (SpadicBaseAddress+4): // third spadic - //spadic="Spadic2"; - SpaId = 2; - break; - case (SpadicBaseAddress+5): // third spadic - //spadic="Spadic2"; - SpaId = 2; - break; - default: - LOG(error) << "Source Address " << address << " not known."; - break; - } - return SpaId; - } - Int_t CbmTSUnpackSpadicOnlineFex::GetSyscoreID(Int_t link) - { - Int_t SyscoreID=link-BaseEquipmentID; - if((SyscoreID<0||SyscoreID>3)){ - LOG(debug) << "EqID " << link << " not known."; - SyscoreID=-1; - } - return SyscoreID; - } - // ---- ------------------------------------------------------- - - inline TString CbmTSUnpackSpadicOnlineFex::GetSpadicName(Int_t link,Int_t address){ - - TString spadicName=""; - Int_t SpadicID=0; - spadicName="SysCore_"+std::to_string(GetSyscoreID(link))+"_"; - SpadicID=GetSpadicID(address); - - //SpadicID/=2; - - spadicName += "Spadic_"; - - spadicName+=std::to_string(SpadicID); - - return spadicName; - } -void CbmTSUnpackSpadicOnlineFex::InitHistos() -{ -#ifdef USE_HTTP_SERVER - THttpServer* server = FairRunOnline::Instance()->GetHttpServer(); -#endif - //cout << "InitHistos" << endl; - TString histName; - for (Int_t iLink = 0; iLink < NrOfSyscores; iLink++){ - for (Int_t iAddress = 0; iAddress < NrOfSpadics; iAddress++){ - histName.Form("SysCore_%i_Spadic_%i",iLink,iAddress); - fHM->Add(TString("Baseline_"+histName).Data(),new TH2I (TString("Baseline_"+histName).Data(),TString("Baseline_"+histName).Data(), 128,-256.5,255.5,32,-0.5,31.5)); - fBaseline[(iLink)*(NrOfSpadics)+iAddress]=(TH2I*)fHM->H2(TString("Baseline_"+histName).Data()); - fBaseline[(iLink)*(NrOfSpadics)+iAddress]->GetXaxis()->SetTitle("ADC"); - fBaseline[(iLink)*(NrOfSpadics)+iAddress]->GetYaxis()->SetTitle("Channel ID"); - fHM->Add(TString("maxADC_vs_maxTimeBin_"+histName).Data(),new TH2I (TString("maxADC_vs_maxTimeBin_"+histName).Data(),TString("maxADC_vs_maxTimeBin_"+histName).Data(),32,-0.5,31.5, 128,-256.5,255.5)); - fmaxADCmaxTimeBin[(iLink)*(NrOfSpadics)+iAddress]=(TH2I*)fHM->H2(TString("maxADC_vs_maxTimeBin_"+histName).Data()); - fmaxADCmaxTimeBin[(iLink)*(NrOfSpadics)+iAddress]->GetXaxis()->SetTitle("max. Time Bin"); - fmaxADCmaxTimeBin[(iLink)*(NrOfSpadics)+iAddress]->GetYaxis()->SetTitle("max ADC"); - fHM->Add(TString("Hit_"+histName).Data(),new TH2I (TString("Hit_"+histName).Data(),TString("Hit_"+histName).Data(),16,-0.5,15.5,2,-0.5,1.5)); - fHit[(iLink)*(NrOfSpadics)+iAddress]=(TH2I*)fHM->H2(TString("Hit_"+histName).Data()); - fHM->Add(TString("Lost_"+histName).Data(),new TH2I (TString("Lost_"+histName).Data(),TString("Lost_"+histName).Data(),16,-0.5,15.5,2,-0.5,1.5)); - fLost[(iLink)*(NrOfSpadics)+iAddress]=(TH2I*)fHM->H2(TString("Lost_"+histName).Data()); - fHM->Add(TString("Epoch_"+histName).Data(),new TH2I (TString("Epoch_"+histName).Data(),TString("Epoch_"+histName).Data(),16,-0.5,15.5,2,-0.5,1.5)); - fEpoch[(iLink)*(NrOfSpadics)+iAddress]=(TH2I*)fHM->H2(TString("Epoch_"+histName).Data()); - fHM->Add(TString("OutOfSync_"+histName).Data(),new TH2I (TString("OutOfSync_"+histName).Data(),TString("OutOfSync_"+histName).Data(),16,-0.5,15.5,2,-0.5,1.5)); - fOutOfSync[(iLink)*(NrOfSpadics)+iAddress]=(TH2I*)fHM->H2(TString("OutOfSync_"+histName).Data()); - fHM->Add(TString("Strange_"+histName).Data(),new TH2I (TString("Strange_"+histName).Data(),TString("Strange_"+histName).Data(),16,-0.5,15.5,2,-0.5,1.5)); - fStrange[(iLink)*(NrOfSpadics)+iAddress]=(TH2I*)fHM->H2(TString("Strange_"+histName).Data()); - fHM->Add(TString("Info_"+histName).Data(),new TH2I (TString("Info_"+histName).Data(),TString("Info_"+histName).Data(),16,-0.5,15.5,2,-0.5,1.5)); - fInfo[(iLink)*(NrOfSpadics)+iAddress]=(TH2I*)fHM->H2(TString("Info_"+histName).Data()); - fTSGraph[(iLink)*(NrOfSpadics)+iAddress] = new TGraph(); - //fHM->Add(TString("HitTime_"+histName).Data(),fTSGraph[(iLink)*(NrOfSpadics)+iAddress]); - //fTSGraph[(iLink)*(NrOfSpadics)+iAddress]->SetNameTitle(TString("HitTime_"+histName).Data(),TString("HitTime_"+histName).Data()); - //fTSGraph[(iLink)*(NrOfSpadics)+iAddress]->GetXaxis()->SetTitle("Timeslice"); - fHM->Add(TString("HitTimeA_"+histName).Data(),new TH1I (TString("HitTimeA_"+histName).Data(),TString("HitTimeA_"+histName).Data(),300,-299.5,0.5)); - fHitTimeA[(iLink)*(NrOfSpadics)+iAddress]=(TH1I*)fHM->H1(TString("HitTimeA_"+histName).Data()); - fHitTimeA[(iLink)*(NrOfSpadics)+iAddress]->GetXaxis()->SetTitle("SuperEpoch count"); - fHM->Add(TString("HitTimeB_"+histName).Data(),new TH1I (TString("HitTimeB_"+histName).Data(),TString("HitTimeB_"+histName).Data(),300,-299.5,0.5)); - fHitTimeB[(iLink)*(NrOfSpadics)+iAddress]=(TH1I*)fHM->H1(TString("HitTimeB_"+histName).Data()); - fHitTimeB[(iLink)*(NrOfSpadics)+iAddress]->GetXaxis()->SetTitle("SuperEpoch count"); - fHitTimeB[(iLink)*(NrOfSpadics)+iAddress]->SetLineColor(2); - fHM->Add(TString("MessageStatistic_"+histName).Data(),new TH1I (TString("MessageStatistic_"+histName).Data(),TString("MessageStatistic_"+histName).Data(),24,-0.5,23.5)); - fMessageStatistic[(iLink)*(NrOfSpadics)+iAddress]=(TH1I*)fHM->H1(TString("MessageStatistic_"+histName).Data()); - for (Int_t iM = 0; iM < 7; iM++){ - fMessageStatistic[(iLink)*(NrOfSpadics)+iAddress]->GetXaxis()->SetBinLabel(iM+1,fMessageTypes[iM]); - } - for (Int_t iT = 0; iT < 4; iT++){ - fMessageStatistic[(iLink)*(NrOfSpadics)+iAddress]->GetXaxis()->SetBinLabel(7+1+iT,fTriggerTypes[iT]); - } - for (Int_t iS = 0; iS < 6; iS++){ - fMessageStatistic[(iLink)*(NrOfSpadics)+iAddress]->GetXaxis()->SetBinLabel(7+4+1+iS,fStopTypes[iS]); - } - for (Int_t iI = 0; iI < 7; iI++){ - fMessageStatistic[(iLink)*(NrOfSpadics)+iAddress]->GetXaxis()->SetBinLabel(7+4+6+1+iI,fInfoTypes[iI]); - } - - - //const Int_t nBins=70; - //auto BinBoarders = [&nBins] (Int_t reBinHigh=32){ - ////auto BinBoarders = [&nBins] (Int_t reBinLow=32){ - //const Double_t Threshold = 100.; - //const Double_t MaxFreq = (17500000.0); - //const Double_t slope=MaxFreq/nBins; - //const Int_t iThreshhold=std::ceil((MaxFreq/Threshold-0.5)/static_cast<Double_t>(reBinHigh)); - //LOG(fatal) << "iThresshold = " << iThreshhold; - //Double_t* Result=new Double_t[nBins+1]; - // - //for(Int_t i=0;i<nBins;i++){ - // size_t j=nBins-i; - // //Result[j]=TMath::Power(TMath::E(),i*slope+TMath::Log(2)); - // //printf("%d\n",Result[j]); - // Double_t LowEdge = MaxFreq/(reBinHigh*(i*i)+0.5); - // Result[j]=LowEdge; - //}/* - // for(Int_t i=0;i<nBins-iThreshhold;i++) { - // size_t j=nBins-iThreshhold-i; - // Double_t LowEdge = MaxFreq/(reBinHigh*(iThreshhold)+0.5+RebinLow*(i)); - // Result[j]=LowEdge; - // }*/ - //Result[0]=0.0; - //std::sort(Result,&Result[nBins]); - //return Result; - //}; - //Double_t* freqbins = (BinBoarders()); - const Int_t nBins = 234; - // const Double_t maxFreq = (175000000.0); (VF) not used - auto BinBoarders = [/*&nBins*/] (Int_t /*reBinHigh*/=32) - { - const Double_t MaxFreq = (175000000.0); - // const Double_t slope=10;//MaxFreq/nBins; (VF) not used - Double_t* Result=new Double_t[nBins+1]; - for(Int_t i=0;i<nBins;i++) - { - size_t j=nBins-i; - Double_t LowEdge = MaxFreq/(TMath::Power(TMath::E(),(0.1*Int_t(i)))); - //printf("LowEdge: %e\n",LowEdge); - Result[j]=LowEdge; - //Result[j]=TMath::Power(TMath::E(),i*slope+TMath::Log(2)); - } - Result[0]=0.1; - std::sort(Result,&Result[nBins]); - return Result; - }; - Double_t* freqbins = (BinBoarders()); - fHM->Add(TString("HitFrequency_"+histName).Data(),new TH1I (TString("HitFrequency_"+histName).Data(),TString("HitFrequency_"+histName).Data(),nBins,freqbins/*100000,1,10000000*/)); - fHitFrequency[(iLink)*(NrOfSpadics)+iAddress]=(TH1I*)fHM->H1(TString("HitFrequency_"+histName).Data()); - fHitFrequency[(iLink)*(NrOfSpadics)+iAddress]->GetXaxis()->SetTitle("Trigger frequency (Hz)"); - fHitFrequency[(iLink)*(NrOfSpadics)+iAddress]->GetYaxis()->SetTitle("Channel ID"); - fHM->Add(TString("Spectrum_"+histName).Data(),new TH1I (TString("Spectrum_"+histName).Data(),TString("Spectrum_"+histName).Data(),513,-256.5,256.5)); - fSpectrum[(iLink)*(NrOfSpadics)+iAddress]=(TH1I*)fHM->H1(TString("Spectrum_"+histName).Data()); - fSpectrum[(iLink)*(NrOfSpadics)+iAddress]->GetXaxis()->SetTitle("max. ADC (ADC)"); - for (Int_t iCh = 0; iCh < 32; iCh++){ - TString chName; - chName.Form("Ch%02i_",iCh); - fHM->Add(TString("PulseShape_"+chName+histName).Data(),new TH2I (TString("PulseShape_"+chName+histName).Data(),TString("PulseShape_"+chName+histName).Data(),32,-0.5,31.5, 128,-256.5,255.5)); - fPulseShape[((iLink)*(NrOfSpadics)+iAddress)*32+iCh]=(TH2I*)fHM->H2(TString("PulseShape_"+chName+histName).Data()); - fPulseShape[((iLink)*(NrOfSpadics)+iAddress)*32+iCh]->GetXaxis()->SetTitle("Time Bin"); - fPulseShape[((iLink)*(NrOfSpadics)+iAddress)*32+iCh]->GetYaxis()->SetTitle("ADC"); - fPulseShape[((iLink)*(NrOfSpadics)+iAddress)*32+iCh]->GetZaxis()->SetTitle("counts"); - } - } - } -} -void CbmTSUnpackSpadicOnlineFex::InitCanvas() -{ - //cout << "InitCanvas" << endl; - //TCanvas* c[2]; - //TH2I* h = NULL; - TString cName; - if (!fHighPerformance){ - fcE= new TCanvas(TString("EpochMap").Data(),TString("EpochMap").Data(),1600,1200); - fcE->Divide(3,4); - fcO= new TCanvas(TString("OutOfSyncMap").Data(),TString("OutOfSyncMap").Data(),1600,1200); - fcO->Divide(3,4); - fcS= new TCanvas(TString("StrangeMap").Data(),TString("StrangeMap").Data(),1600,1200); - fcS->Divide(3,4); - fcI= new TCanvas(TString("InfoMap").Data(),TString("InfoMap").Data(),1600,1200); - fcI->Divide(3,4); - fcF= new TCanvas(TString("HitFrequency").Data(),TString("HitFrequency").Data(),1600,1200); - fcF->Divide(3,4); - fcSp= new TCanvas(TString("HitSelfTriggersSpectrum").Data(),TString("HitSelfTriggersSpectrum").Data(),1600,1200); - fcSp->Divide(3,4); - } - fcB = new TCanvas(TString("Baseline").Data(),TString("Baseline").Data(),1600,1200); - fcB->Divide(3,4); - fcM/*[(iLink)*(NrOfSpadics)+iAddress]*/ = new TCanvas(TString("maxADC_vs_maxTimeBin").Data(),TString("maxADC_vs_maxTimeBin").Data(),1600,1200); - fcM->Divide(3,4); - fcH= new TCanvas(TString("HitMap").Data(),TString("HitMap").Data(),1600,1200); - fcH->Divide(3,4); - fcL= new TCanvas(TString("LostMap").Data(),TString("LostMap").Data(),1600,1200); - fcL->Divide(3,4); - fcTS= new TCanvas(TString("TSGraph").Data(),TString("TSGraph").Data(),1600,1200); - fcTS->Divide(3,4); - fcMS= new TCanvas(TString("MessageStatistic").Data(),TString("MessageStatistic").Data(),1600,1200); - fcMS->Divide(3,4); - - for (Int_t iLink = 0; iLink < NrOfSyscores; iLink++){ - for (Int_t iAddress = 0; iAddress < NrOfSpadics; iAddress++){ - cName.Form("SysCore_%i_Spadic_%i",iLink,iAddress); - if (!fHighPerformance){ - fcPS[(iLink)*(NrOfSpadics)+iAddress] = new TCanvas(TString("PulseShapes_"+cName).Data(),TString("PulseShapes_"+cName).Data(),1600,1200); - fcPS[(iLink)*(NrOfSpadics)+iAddress]->Divide(4,8); - for(Int_t iCh = 0; iCh < 32; iCh++){ - fcPS[(iLink)*(NrOfSpadics)+iAddress]->cd(iCh+1); - fPulseShape[((iLink)*(NrOfSpadics)+iAddress)*32+iCh]->Draw("colz"); - } - fcE->cd((iLink)*(NrOfSpadics)+iAddress+1)->SetLogz(0); - fEpoch[(iLink)*(NrOfSpadics)+iAddress]->Draw("colz"); - fcO->cd((iLink)*(NrOfSpadics)+iAddress+1)->SetLogz(0); - fOutOfSync[(iLink)*(NrOfSpadics)+iAddress]->Draw("colz"); - fcS->cd((iLink)*(NrOfSpadics)+iAddress+1)->SetLogz(0); - fStrange[(iLink)*(NrOfSpadics)+iAddress]->Draw("colz"); - fcI->cd((iLink)*(NrOfSpadics)+iAddress+1)->SetLogx(0); - fInfo[(iLink)*(NrOfSpadics)+iAddress]->Draw("colz"); - fcF->cd((iLink)*(NrOfSpadics)+iAddress+1)->SetLogx(1); - fcF->cd((iLink)*(NrOfSpadics)+iAddress+1)->SetLogy(1); - fcF->cd((iLink)*(NrOfSpadics)+iAddress+1)->SetLogz(0); - fHitFrequency[(iLink)*(NrOfSpadics)+iAddress]->Draw(/*"colz"*/); - fcSp->cd((iLink)*(NrOfSpadics)+iAddress+1)->SetLogy(1); - fSpectrum[(iLink)*(NrOfSpadics)+iAddress]->Draw(); - } - fcB->cd((iLink)*(NrOfSpadics)+iAddress+1)->SetLogz(); - fBaseline[(iLink)*(NrOfSpadics)+iAddress]->Draw("colz"); - cName.Form("SysCore_%i_Spadic_%i",iLink,iAddress); - fcM->cd((iLink)*(NrOfSpadics)+iAddress+1)->SetLogz(); - fmaxADCmaxTimeBin[(iLink)*(NrOfSpadics)+iAddress]->Draw("colz"); - fcH->cd((iLink)*(NrOfSpadics)+iAddress+1)->SetLogz(0); - fHit[(iLink)*(NrOfSpadics)+iAddress]->Draw("colz"); - fcL->cd((iLink)*(NrOfSpadics)+iAddress+1)->SetLogz(0); - fLost[(iLink)*(NrOfSpadics)+iAddress]->Draw("colz"); - fcMS->cd((iLink)*(NrOfSpadics)+iAddress+1)->SetLogy(1); - fMessageStatistic[(iLink)*(NrOfSpadics)+iAddress]->Draw(""); - fcTS->cd((iLink)*(NrOfSpadics)+iAddress+1); - fHitTimeA[(iLink)*(NrOfSpadics)+iAddress]->GetYaxis()->SetRangeUser(0,1000); - fHitTimeA[(iLink)*(NrOfSpadics)+iAddress]->Draw(""); - fHitTimeB[(iLink)*(NrOfSpadics)+iAddress]->Draw("same"); - //fTSGraph[(iLink)*(NrOfSpadics)+iAddress]->Draw("ALP"); - - - } - } -} - void CbmTSUnpackSpadicOnlineFex::UpdateCanvas() - { - /* - //cout << "UpdateCanvas" << endl; - TH2I* h = NULL; - TString cName; - for (Int_t iLink = 0; iLink < NrOfSyscores; iLink++){ - for (Int_t iAddress = 0; iAddress < NrOfSpadics; iAddress++){ - cName.Form("SysCore_%i_Spadic_%i",iLink,iAddress); - fcB->cd((iLink)*(NrOfSpadics)+iAddress+1); - fBaseline[(iLink)*(NrOfSpadics)+iAddress]->Draw("colz"); - //h = (TH2I*)fHM->H2(TString("Baseline_"+cName).Data()); - //h->Draw("colz"); - //fcB->cd((iLink)*(NrOfSpadics)+iAddress+1)->Update(); - cName.Form("SysCore_%i_Spadic_%i",iLink,iAddress); - fcM->cd((iLink)*(NrOfSpadics)+iAddress+1); - fmaxADCmaxTimeBin[(iLink)*(NrOfSpadics)+iAddress]->Draw("colz"); - //h = (TH2I*)fHM->H2(TString("maxADC_vs_maxTimeBin_"+cName).Data()); - //h->Draw("colz"); - //fcM->cd((iLink)*(NrOfSpadics)+iAddress+1)->Update(); - } - } - */ - } - void CbmTSUnpackSpadicOnlineFex::Reset() - { - fSpadicRaw->Clear(); - } - void CbmTSUnpackSpadicOnlineFex::FinishEvent() - { - //UpdateCanvas(); - } - void CbmTSUnpackSpadicOnlineFex::Finish() - { - for (Int_t i=0; i < NrOfSyscores; ++i) { - for (Int_t j=0; j < NrOfHalfSpadics; ++j) { - LOG(debug) << "There have been " << fSuperEpochArray[i][j] - << " SuperEpochs for Syscore" << i << "_Spadic" - << j << " in this file"; - } - } - UpdateCanvas(); - } - - - /* - void CbmTSUnpackSpadicOnlineFex::Register() - { - } - */ - - - ClassImp(CbmTSUnpackSpadicOnlineFex) - diff --git a/beamtime/cern2014/unpacker/CbmTSUnpackSpadicOnlineFex.h b/beamtime/cern2014/unpacker/CbmTSUnpackSpadicOnlineFex.h deleted file mode 100644 index b4ce1fe9d6b7998066ebdcc1da19e5bab66cbb4a..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/unpacker/CbmTSUnpackSpadicOnlineFex.h +++ /dev/null @@ -1,112 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmTSUnpackSpadicOnlineFex ----- -// ----- Created 10.12.2016 by C. Bergmann ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CBMTSUNPACKSPADICONLINEFEX_H -#define CBMTSUNPACKSPADICONLINEFEX_H - -#include "Timeslice.hpp" -#include "Message.hpp" - - -#include "CbmTSUnpack.h" -#include "CbmBeamDefaults.h" - -#include "CbmHistManager.h" -#include "TClonesArray.h" - -class CbmTSUnpackSpadicOnlineFex : public CbmTSUnpack -{ - public: - - CbmTSUnpackSpadicOnlineFex(Bool_t highPerformancen = true ); - virtual ~CbmTSUnpackSpadicOnlineFex(); - - virtual Bool_t Init(); - - virtual Bool_t DoUnpack(const fles::Timeslice& ts, size_t component); - void print_message(const spadic::Message& m); - - virtual void Reset(); - - virtual void Finish(); - virtual void FinishEvent(); - void SetParContainers() {;} - - // protected: - // virtual void Register(); - - virtual void FillOutput(boost::any){;} - private: - - TClonesArray* fSpadicRaw; - - Bool_t fHighPerformance; - - Int_t fEpochMarkerArray[NrOfSyscores][NrOfHalfSpadics]; - //Array to store the previous Epoch counter - Int_t fPreviousEpochMarkerArray[NrOfSyscores][NrOfHalfSpadics]; - //Suppress multiple Epoch Messages in duplicated Microslices. NOTE:Currently Buggy - const Bool_t SuppressMultipliedEpochMessages = false; - Int_t fSuperEpochArray[NrOfSyscores][NrOfHalfSpadics]; - - static Int_t GetSpadicID(Int_t address); - static Int_t GetSyscoreID(Int_t link); - inline TString GetSpadicName(Int_t link,Int_t address); - Int_t GetChannelOnPadPlane(Int_t SpadicChannel, Int_t groupId); - Int_t fEpochMarker; - Int_t fSuperEpoch; - Int_t fNrExtraneousSamples; - void GetEpochInfo(Int_t link, Int_t addr); - void FillEpochInfo(Int_t link, Int_t addr, Int_t epoch_count); - CbmHistManager* fHM; - TCanvas* fcB; - TCanvas* fcM;//[(iLink)*(NrOfHalfSpadics/2)]; - TCanvas* fcH; - TCanvas* fcL; - TCanvas* fcE; - TCanvas* fcO; - TCanvas* fcS; - TCanvas* fcI; - TCanvas* fcTS; - TCanvas* fcF; - TCanvas* fcSp; - TCanvas* fcPS[(NrOfSyscores)*(NrOfSpadics)]; - TCanvas* fcMS; - void InitHistos(); - void InitCanvas(); - void UpdateCanvas(); - TH2I* fBaseline[(NrOfSyscores)*(NrOfSpadics)]; - TH2I* fmaxADCmaxTimeBin[(NrOfSyscores)*(NrOfSpadics)]; - TH2I* fHit[(NrOfSyscores)*(NrOfSpadics)]; - TH2I* fLost[(NrOfSyscores)*(NrOfSpadics)]; - TH2I* fEpoch[(NrOfSyscores)*(NrOfSpadics)]; - TH2I* fOutOfSync[(NrOfSyscores)*(NrOfSpadics)]; - TH2I* fStrange[(NrOfSyscores)*(NrOfSpadics)]; - TH2I* fInfo[(NrOfSyscores)*(NrOfSpadics)]; - TH1I* fHitTimeA[(NrOfSyscores)*(NrOfSpadics)]; - TH1I* fHitTimeB[(NrOfSyscores)*(NrOfSpadics)]; - TH1I* fHitFrequency[(NrOfSyscores)*(NrOfSpadics)]; - TH1I* fSpectrum[(NrOfSyscores)*(NrOfSpadics)]; - TH2I* fPulseShape[(NrOfSyscores)*(NrOfSpadics)*32]; - TH1I* fMessageStatistic[(NrOfSyscores)*(NrOfSpadics)]; - TGraph* fTSGraph[(NrOfSyscores)*(NrOfSpadics)]; - Int_t fLastSuperEpochA[(NrOfSyscores)*(NrOfSpadics)]; - Int_t fLastSuperEpochB[(NrOfSyscores)*(NrOfSpadics)]; - ULong_t fLastFullTime[NrOfSyscores][NrOfSpadics][32]; - TString fMessageTypes[7]; - TString fTriggerTypes[4]; - TString fStopTypes[6]; - TString fInfoTypes[7]; - //Int_t fSumHitMessages[(NrOfSyscores)*(NrOfSpadics)]; - CbmTSUnpackSpadicOnlineFex(const CbmTSUnpackSpadicOnlineFex&); - CbmTSUnpackSpadicOnlineFex operator=(const CbmTSUnpackSpadicOnlineFex&); - - ClassDef(CbmTSUnpackSpadicOnlineFex, 2) - }; - -#endif - diff --git a/beamtime/cern2014/unpacker/CbmTSUnpackStsxyter.cxx b/beamtime/cern2014/unpacker/CbmTSUnpackStsxyter.cxx deleted file mode 100644 index 809a7cc6711b168996238bf6e84edd83b8a8dd3d..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/unpacker/CbmTSUnpackStsxyter.cxx +++ /dev/null @@ -1,636 +0,0 @@ -#include "CbmTSUnpackStsxyter.h" -#include "CbmStsxyterRawHitMessage.h" -#include "FairLogger.h" -#include "FairRootManager.h" -#include "TClonesArray.h" -#include <iostream> -#include "MicrosliceContents.hpp" - - -#define VERBOSE - - - -CbmTSUnpackStsxyter::CbmTSUnpackStsxyter() -: CbmTSUnpack(), - fDtmNum( 0 ), - fDtmNumInitialized( kFALSE ), - fCurrEpoch(), - fStsxyterRawHitMessage(new TClonesArray("CbmStsxyterRawHitMessage", 10)) -{ - fCurrEpoch.resize( fkgNumStsxytersDefault ); - for( size_t iChip = 0; iChip < fCurrEpoch.size(); ++iChip ) { - fCurrEpoch.at( iChip).resize( fkgNumStsxyterLinks ); - } -} - -Bool_t CbmTSUnpackStsxyter::fgParityTableinitialized = kFALSE; -std::vector< Bool_t > CbmTSUnpackStsxyter::fgParityTable; - -CbmTSUnpackStsxyter::~CbmTSUnpackStsxyter() -{ -} - - - -Bool_t CbmTSUnpackStsxyter::Init() -{ - LOG(info) << "Initializing"; - - if( ! fgParityTableinitialized ) { - InitializeParityTable(); - } - - FairRootManager* ioman = FairRootManager::Instance(); - if (ioman == NULL) { - LOG(fatal) << "No FairRootManager instance"; - } - ioman->Register("StsxyterRawHit", "STS-XYTER raw hit data", fStsxyterRawHitMessage, kTRUE); - fDtmNum = 0; - fDtmNumInitialized = kFALSE; - - return kTRUE; -} - - - -Bool_t CbmTSUnpackStsxyter::DoUnpack(const fles::Timeslice& timeslice, size_t component) -{ - for( size_t iMicroslice = 0; iMicroslice < timeslice.num_microslices(component); ++iMicroslice ) - { - // LOG(info) << "New microslice"; - - // size_t microsliceSize = timeslice.descriptor( component, iMicroslice ).size; - // const uint16_t * microsliceContentPtr = ( const uint16_t * ) timeslice.content( component, iMicroslice ); - // flib_dpb::MicrosliceContents microslice( microsliceContentPtr, microsliceSize ); - // auto dtms = microslice.dtms(); - // for( size_t iDtm = 0; iDtm < dtms.size(); ++iDtm ) { - // flib_dpb::DTM currDtm = dtms.at( iDtm ); - // UnpackDtm( (const uint8_t * ) currDtm.data, currDtm.size ); - // } - - auto microsliceDescriptor = timeslice.descriptor( component, iMicroslice ); - // const uint8_t* microsliceContent = timeslice.content( component, iMicroslice ); - const uint8_t * const microsliceBegin = timeslice.content( component, iMicroslice ); - const uint8_t * const microsliceEnd = microsliceBegin + microsliceDescriptor.size; - - // printf("Microslice byte dump: \n"); - // ByteDumpSwap( microsliceBegin, microsliceDescriptor.size ); - - const uint8_t * currDtm = GetFirstDtm( microsliceBegin ); - while( currDtm < microsliceEnd ) { - Bool_t dtmSeqNumError = CheckDtmNumSequence( currDtm, (iMicroslice == 0) ); - if( dtmSeqNumError ) { - printf("Microslice number %lu byte dump:\n", static_cast<unsigned long int>(iMicroslice) ); - ByteDumpSwap( microsliceBegin, microsliceDescriptor.size ); - printf("Error at dtm at %#04x\n", static_cast<unsigned int>(currDtm - microsliceBegin) ); - } - UnpackDtmContent( GetDtmContent( currDtm ), GetDtmContentSize( currDtm ), microsliceDescriptor.eq_id ); - currDtm += GetDtmFullSize( currDtm ); - } - } - return kTRUE; -} - - - -const uint8_t * CbmTSUnpackStsxyter::GetFirstDtm( const uint8_t * const & microsliceBegin ) const -{ - const size_t kMicrosliceCopyOfHalfOfDescriptorSize = 16; - const uint8_t * dtmBegin = microsliceBegin + kMicrosliceCopyOfHalfOfDescriptorSize; - return dtmBegin; -} - - - -Bool_t CbmTSUnpackStsxyter::CheckDtmNumSequence( const uint8_t * const & dtm, const Bool_t & newTimeslice ) -{ - if( newTimeslice ) { - fDtmNumInitialized = kFALSE; - } - - uint8_t dtmNumCurr = dtm[ fkgDtmNumOffset ]; - uint8_t dtmNumExpected = fDtmNum < 255 ? fDtmNum + 1 : 0; - if( fDtmNumInitialized ) { - if( dtmNumCurr - dtmNumExpected != 0 ) { - LOG(error) << "Wrong DTM number! Previous DTM had number " << static_cast< size_t >( fDtmNum ) << ". Current DTM had number " << static_cast< size_t >( dtmNumCurr ) << " expected " << static_cast< int >( dtmNumExpected ); - fDtmNum = dtmNumCurr; - return kTRUE; - } - } - fDtmNum = dtmNumCurr; - fDtmNumInitialized = kTRUE; - return kFALSE; -} - - - -const uint8_t * CbmTSUnpackStsxyter::GetDtmContent( const uint8_t * const & dtm ) const -{ - return dtm + fkgDtmDataOffset; -} - - - -size_t CbmTSUnpackStsxyter::GetDtmContentSize( const uint8_t * const & dtm ) const -{ - const size_t dtmSizeWordsMinusOne = dtm[ fkgDtmSizeOffset ]; - const size_t kDtmWordSizeBytes = 2; - const size_t dtmSizeBytes = ( dtmSizeWordsMinusOne + 1 ) * kDtmWordSizeBytes; - return dtmSizeBytes; -} - - - -size_t CbmTSUnpackStsxyter::GetDtmFullSize( const uint8_t * const & dtm ) const -{ - const size_t dtmSizeFieldSize = 1; - const size_t dtmNumFieldSize = 1; - const size_t dtmSizeWithoutPadding = dtmSizeFieldSize + dtmNumFieldSize + GetDtmContentSize( dtm ); - const size_t kDtmSizeMultipleOfBytes = 8; - const size_t unpaddedRemainderSize = dtmSizeWithoutPadding % kDtmSizeMultipleOfBytes; - const size_t paddingSize = unpaddedRemainderSize > 0 ? kDtmSizeMultipleOfBytes - unpaddedRemainderSize : 0; - const size_t dtmSizeWithPadding = dtmSizeWithoutPadding + paddingSize; - return dtmSizeWithPadding; -} - - - -Bool_t CbmTSUnpackStsxyter::IsStsxyterDtm( const uint8_t * const & dtmContent, const size_t & size ) const -{ - // printf("Dtm contents:\n"); - // ByteDump( dtmContent, size ); - - if( size % 2 ) { - LOG(error) << "Size of the DTM payload is not even number of bytes"; - return kFALSE; - } - - const uint16_t * const wordData = reinterpret_cast< const uint16_t * const >( dtmContent ); - const size_t wordSize = size / 2; - - const size_t kActualStsyxterSourceAddressOffsetWords = 1; - const size_t kStsxyterSourceAddress = 0x0000; - const size_t kTrailingJunkWordReverseOffsetWords = 1; - const size_t kTrailingJunkWordMastercopyReverseOffsetWords = 2; - - // printf("SrcAddr: %04x\n", wordData[ kActualStsyxterSourceAddressOffsetWords ] ); - // printf("LastWrd: %04x\n", wordData[ wordSize - kTrailingJunkWordReverseOffsetWords ] ); - // printf("BLstWrd: %04x\n", wordData[ wordSize - kTrailingJunkWordMastercopyReverseOffsetWords ]); - - if( wordData[ kActualStsyxterSourceAddressOffsetWords ] == kStsxyterSourceAddress - && wordData[ wordSize - kTrailingJunkWordReverseOffsetWords ] == wordData[ wordSize - kTrailingJunkWordMastercopyReverseOffsetWords ] ) { - return kTRUE; - } - return kFALSE; -} - - - -Bool_t CbmTSUnpackStsxyter::IsStsxyterDtmUnstrict( const uint8_t * const & dtmContent, const size_t & size ) const -{ - - if( size % 2 ) { - LOG(error) << "Size of the DTM payload is not even number of bytes"; - return kFALSE; - } - - const uint16_t * const wordData = reinterpret_cast< const uint16_t * const >( dtmContent ); - - const size_t kActualStsyxterSourceAddressOffsetWords = 1; - const size_t kStsxyterSourceAddress = 0x0000; - - if( wordData[ kActualStsyxterSourceAddressOffsetWords ] == kStsxyterSourceAddress ) { - return kTRUE; - } - return kFALSE; -} - - - -void CbmTSUnpackStsxyter::ByteDump( const uint8_t * const & data, size_t sizeBytes, size_t lineLenBytes ) const -{ - for( size_t iByte = 0; iByte < sizeBytes; iByte += 1 ) { - printf( "%02x ", data[ iByte ] ); - if( lineLenBytes > 0 ) { - if( iByte % lineLenBytes == lineLenBytes - 1 ) printf("\n"); - } - } - if( lineLenBytes > 0 ) { - if( sizeBytes % lineLenBytes != 0 ) printf("\n"); - } -} - - - -void CbmTSUnpackStsxyter::ByteDumpSwap( const uint8_t * const & data, size_t sizeBytes, size_t lineLenBytes ) const -{ - for( size_t iByte = 0; iByte < sizeBytes; iByte += 1 ) { - size_t printByte = iByte % 2 ? iByte - 1 : iByte + 1; - printf( "%02x ", data[ printByte ] ); - if( lineLenBytes > 0 ) { - if( iByte % lineLenBytes == lineLenBytes - 1 ) printf("\n"); - } - } - if( lineLenBytes > 0 ) { - if( sizeBytes % lineLenBytes != 0 ) printf("\n"); - } -} - - - -void CbmTSUnpackStsxyter::UnpackDtmContent( const uint8_t * const & dtmContent, const size_t & size, const uint16_t & equipmentId ) -{ - // printf("Processing DTM:\n"); - // ByteDumpSwap( dtmContent, size ); - // if( IsStsxyterDtm( dtmContent, size ) ) { - if( IsStsxyterDtmUnstrict( dtmContent, size ) ) { - UnpackStsxyterDtmContent( dtmContent, size, equipmentId ); - return; - } - LOG(error) << "In CbmTSUnpackStsxyter::UnpackDtmContent: Unidentified Dtm\n"; -} - - - -void CbmTSUnpackStsxyter::UnpackStsxyterDtmContent( const uint8_t * const & dtmContent, const size_t & size, const uint16_t & equipmentId ) -{ - const size_t kFirstMsgOffset = 4; - const size_t kLeadingJunkWordSize = 2; - const size_t kAddressSize = 2; - const size_t kTrailingJunkWordSize = 2; - const size_t kOverheadSize = kLeadingJunkWordSize + kAddressSize + kTrailingJunkWordSize; - const size_t payloadSize = size - kOverheadSize; - const size_t kMsgSize = 4; - if( payloadSize % kMsgSize > 0 ) { - LOG(error) << "Looks like the payload size in STS-XYTER DTM is not a multiple of STS-XYTER messages (" << kMsgSize << " bytes). Either the data is corrupted, or DTM source is not properly identified."; - } - const size_t nMsgs = payloadSize / kMsgSize; - - const uint8_t * currMsg = dtmContent + kFirstMsgOffset; - for( size_t iMsg = 0; iMsg < nMsgs; iMsg += 1 ) { - const size_t kSourceAddressInStsxyterDtmContentsAcutalOffsetWords = 1; - UnpackStsxyterMessage( GetUint32( currMsg ), reinterpret_cast< const uint16_t * >( dtmContent)[kSourceAddressInStsxyterDtmContentsAcutalOffsetWords], equipmentId ); - currMsg += kMsgSize; - } - - -/* - if( GetField( msg, kEpochSignatureFirstBit, kEpochSignatureNBits ) == kEpochSignatureValue ) { - fMsgType = MsgEpo; - UnpackXEpo(); - return; - } - if( GetField( msg, kHitSignatureFirstBit, kHitSignatureNBits ) == kHitSignatureValue ) { - fMsgType = MsgHit; - UnpackXHit(); - return; - } - printf("Error: neither hit, nor epoch message from stsxyter!\n"); - - // printf("getField( Epoch ) = %d\n", getField( msg, kEpochSignatureFirstBit, kEpochSignatureNBits ) ); - // printf("getField( Hit ) = %d\n", getField( msg, kHitSignatureFirstBit, kHitSignatureNBits ) ); - // printf("kEpochSignatureFirstBit = %d\n", kEpochSignatureFirstBit ); - // printf("kHitSignatureFirstBit = %d\n", kHitSignatureFirstBit ); - // printf("fStsxMsgRaw = %p\n", fMsgRaw ); - // printf("fPktRaw = %p\n", fPktRaw ); - // for( uint8_t iByte = 0; iByte < 4; ++iByte ) { - // for( int iBit = 7; iBit >=0 ; --iBit ) { - // printf("%d", getField( msg, iBit + 8 * iByte, 1 ) ); - // } - // printf(" "); - // } - - printf("Nearest fragment of current usb packet:\n"); - PrintUsbpktRaw( 50 ); - PrintUsbpktPos(); - printf("Current cbmnet packet in hex:\n"); - PrintCbmnetPktRawHex(); - printf("Current cbmnet packet in bin:\n"); - PrintCbmnetPktRawBin(); -*/ - - -} - - - -void CbmTSUnpackStsxyter::UnpackStsxyterMessage( const uint32_t & msg, const Int_t & sourceAddress, const uint16_t & equipmentId ) -{ - // printf("Stsxyter message:\n"); - // printf("%04x\n", msg); - // ByteDump( (const uint8_t * const) & msg, 4 ); - if( IsEpochMessage( msg ) ) { - UnpackEpochMessage( msg, sourceAddress, equipmentId ); - return; - } - if( IsHitMessage( msg ) ) { - UnpackHitMessage( msg, sourceAddress, equipmentId ); - return; - } - LOG(error) << "STS-XYTER message is neither hit nor epoch!"; -} - - - -void CbmTSUnpackStsxyter::UnpackEpochMessage( const uint32_t & msg, const Int_t & sourceAddress, const uint16_t & /*equipmentId*/ ) -{ - uint32_t link = GetField( msg, kEpochLinkFirstBit, kEpochLinkNBits ); - uint32_t nchem = GetField( msg, kEpochNChMarkersFirstBit, kEpochNChMarkersNBits ); - uint32_t ovf = GetBit( msg, kEpochFifoOvfBit ); - uint32_t epochA = GetField( msg, kEpochABits0To1FirstBit, kEpochABits0To1NBits ) - | GetField( msg, kEpochABits2To6FirstBit, kEpochABits2To6NBits ) << kEpochABits0To1NBits; - uint32_t epochB = GetField( msg, kEpochBFirstBit, kEpochBNBits ); - uint32_t epochC = GetField( msg, kEpochCFirstBit, kEpochCNBits ); - - if( nchem != 0 ) { - LOG(error) << "CbmTSUnpackStsxyter::UnpackEpochMessage: Number of channel epoch markers is %d\n" << nchem; - // PrintCbmnetPktRawHex(); - } - - if( epochA != epochB || epochB != epochC ) { - LOG(error) << "CbmTSUnpackStsxyter::UnpackEpochMessage: Epoch numbers don't match: " << "XEpo: link=" << link << " epochA=" << epochA << " epochB=" << epochB << " epochC=" << epochC << " epochOvf=" << ovf; - } - - if( link >= fkgNumStsxyterLinks ) { - LOG(error) << "CbmTSUnpackStsxyter::UnpackEpochMessage: Invalid link number " << link; - } - - if( sourceAddress >= static_cast<Int_t>(fCurrEpoch.size()) ) { - fCurrEpoch.resize( sourceAddress + 1, std::vector< Int_t>( fkgNumStsxyterLinks, 0 ) ); - } - - fCurrEpoch.at( sourceAddress ).at(link) = epochA; - - // LOG(info) << "XEpo: link=" << link << " epochA=" << epochA << " epochB=" << epochB << " epochC=" << epochC << " epochOvf=" << ovf; -} - - - -void CbmTSUnpackStsxyter::UnpackHitMessage( const uint32_t & msg, const Int_t & sourceAddress, const uint16_t & equipmentId ) -{ - uint32_t link = GetField( msg, kHitLinkFirstBit, kHitLinkNBits ); - - uint32_t kNLinks = 4; - if( link >= kNLinks ) { - LOG(error) << "In UnpackHitMessage: Invalid link number " << link; - } - uint32_t channelWithinLink = GetField( msg, kHitChannelFirstBit, kHitChannelNBits ); - const uint32_t kNChannelsPerLink = 32; - uint32_t channel = channelWithinLink + link * kNChannelsPerLink; - uint32_t zeroBit0 = GetBit( msg, kHitUnusedBit0 ); - uint32_t amplitude = GetField( msg, kHitAmpFirstBit, kHitAmpNBits ); - uint32_t zeroBit1 = GetBit( msg, kHitUnusedBit1 ); -// uint32_t parity = GetBit( msg, kHitParityBit ); -// uint32_t hitMissed = GetBit( msg, kHitEvMissedBit ); - uint32_t zeroBits23 = GetField( msg, kHitUnusedBits23FirstBit, kHitUnusedBits23NBits ); - uint32_t time = GetField( msg, kHitTimestampFirstBit, kHitTimestampNBits ); - - if( zeroBit0 || zeroBit1 || zeroBits23 ) { - LOG(error) << "In UnpackHitMessage: In a HIT message one of the bits, that must be zero, is not"; - } - - uint32_t epoch = fCurrEpoch.at(sourceAddress).at( link ); - if( ( time & ( 1 << ( kHitTimestampNBits - 1 ) ) ) == ( epoch & 1 ) ) { - --epoch; - } - - // fXFullTsNs = ( static_cast<uint64_t>(epoch) * 2048 + fXTs ) * 2; - - // TODO: Fix the next line properly - // Don't know yet how to fix the next line properly. Since the data class CbmStsxyterRawHitMessage is not used at all - // in CbmRoot the hot fix for the time being is to set the value to false in any case. - // Probably the best way would be to remove the unpacker and the data class completly. -// Bool_t parityError = ( (GetEvenParity( time ) ^ GetEvenParity( amplitude ) ^ GetEvenParity( hitMissed) ^ 1) == parity ); - Bool_t parityError = false; - - // LOG(info) << "XHit: ch=" << channel << " amp=" << amplitude << " time=" << time << " missed=" << hitMissed << " par_err=" << parityError; - - Int_t hitNumber=fStsxyterRawHitMessage->GetEntriesFast(); - new( (*fStsxyterRawHitMessage)[hitNumber] ) - CbmStsxyterRawHitMessage( - equipmentId, - sourceAddress, - channel, - fCurrEpoch.at(sourceAddress).at(link), - time, - amplitude, - parityError); -} - - - -Bool_t CbmTSUnpackStsxyter::IsEpochMessage( const uint32_t & msg ) -{ - if( GetField( msg, kEpochSignatureFirstBit, kEpochSignatureNBits ) == kEpochSignatureValue ) { - return kTRUE; - } - return kFALSE; -} - - - -Bool_t CbmTSUnpackStsxyter::IsHitMessage( const uint32_t & msg ) -{ - if( GetField( msg, kHitSignatureFirstBit, kHitSignatureNBits ) == kHitSignatureValue ) { - return kTRUE; - } - return kFALSE; -} - - -void CbmTSUnpackStsxyter::InitializeParityTable() -{ - size_t parityTableSize = 2 << kHitAmpNBits; - parityTableSize = TMath::Max( parityTableSize, static_cast< size_t >(2 << kHitTimestampNBits) ); - const uint8_t evMissedBitNBits = 1; - parityTableSize = TMath::Max( parityTableSize, static_cast< size_t >(2 << evMissedBitNBits ) ); - fgParityTable.resize( parityTableSize ); - for( size_t number = 0; number < parityTableSize; ++number ) { - fgParityTable.at( number ) = CalculateEvenParity( number ); - // printf("Parity of %08lu is %d\n", number, CalculateEvenParity( number ) ); - } - fgParityTableinitialized = kTRUE; -} - - - -Bool_t CbmTSUnpackStsxyter::CalculateEvenParity( size_t number ) -{ - bool parity = 0; - while( number ) { - parity = !parity; - number = number & (number - 1); - } - return parity; -} - - - -void CbmTSUnpackStsxyter::Reset() -{ - fStsxyterRawHitMessage->Clear(); -} - - -/* -void CbmTSUnpackStsxyter::Register() -{ -} - */ - - -/* - -void CbmTSUnpackStsxyter::Print6bytesMessage(const uint8_t* msContent_shifted) -{ - #ifdef VERBOSE - printf("0x%02X%02X%02X%02X%02X%02X :\t", - msContent_shifted[0], msContent_shifted[1], - msContent_shifted[2], msContent_shifted[3], - msContent_shifted[4], msContent_shifted[5]); - #endif -} - - -// Last epoch flag, overflow flag, pileup flag, ADC value, channel, timestamp, LTS, NX id, ROC id, messageType=1 -// [LOPAAAAA][AAAAAAA-][CCCCCCCT][TTTTTTTT][TTTTTLLL][NNRRR001] -void CbmTSUnpackStsxyter::ProcessMessage_hit(const uint8_t* msContent_shifted, uint16_t EqID, uint16_t RocID) -{ - - Int_t messageType, rocID, nxID, lts, timestamp, channel, ADCvalue; - Bool_t pileUp, overflow, lastEpoch; - - messageType = (msContent_shifted[5] >> 0) & 0x07; // 3 bits - rocID = (msContent_shifted[5] >> 3) & 0x07; // 3 bits - nxID = (msContent_shifted[5] >> 6) & 0x03; // 2 bits - lts = (msContent_shifted[4] >> 0) & 0x07; // 3 bits - timestamp = ((msContent_shifted[4] >> 3) & 0x1F) // 5 bits - + (((msContent_shifted[3] >> 0) & 0xFF) << 5) // 8 bits - + (((msContent_shifted[2] >> 0) & 0x01) << 13); // 1 bit - channel = (msContent_shifted[2] >> 1) & 0x7F; // 7 bits - ADCvalue = ((msContent_shifted[1] >> 1) & 0x7F) // 7 bits - + (((msContent_shifted[0] >> 0) & 0x1F) << 7); // 5 bits - pileUp = (msContent_shifted[0] >> 5) & 0x01; // 1 bit - overflow = (msContent_shifted[0] >> 6) & 0x01; // 1 bit - lastEpoch = (msContent_shifted[0] >> 7) & 0x01; // 1 bit - - #ifdef VERBOSE - printf("messType=%d\tROC=0x%01X\tNX=0x%01X\tLTS=0x%01X\tTs=0x%04X\tCh=0x%02X\tADC=0x%04X\tpileUp=%d\toverfl=%d\tlastE=%d\n", - messageType, rocID, nxID, lts, timestamp, channel, ADCvalue, pileUp, overflow, lastEpoch); - #endif - - new( (*fNxyterRaw)[fNxyterRaw->GetEntriesFast()] ) - CbmNxyterRawMessage( - EqID, - RocID*4 + nxID, - channel, - fCurrEpoch, // - cur_hit_data.NxLastEpoch, //TODO subtract here or in GetFullTime() method ?! - timestamp, - ADCvalue, - lastEpoch, - pileUp, - overflow); -} - -// Missed event (currently skipped), epoch counter value, ROC id, messageType=2 -// [MMMMMMMM][EEEEEEEE][EEEEEEEE][EEEEEEEE][EEEEEEEE][--RRR010] -void CbmTSUnpackStsxyter::ProcessMessage_epoch(const uint8_t* msContent_shifted) -{ - Int_t messageType = (msContent_shifted[5] >> 0) & 0x07; // 3 bits - - fCurrEpoch = ((msContent_shifted[4] >> 0) & 0xFF) // 8 bits - + (((msContent_shifted[3] >> 0) & 0xFF) << 8) // 8 bits - + (((msContent_shifted[2] >> 0) & 0xFF) << 16) // 8 bits - + (((msContent_shifted[1] >> 0) & 0xFF) << 24); // 8 bits - - // Debug printout - #ifdef VERBOSE - printf("messType=%d\tepoch=0x%08X\n", messageType, fCurrEpoch); - #endif -} - - -// Status, Data, Timestamp, syncChannel, ROC id, messageType=3 -// [SSDDDDDD][DDDDDDDD][DDDDDDDD][DDTTTTTT][TTTTTTTT][CCRRR011] -void CbmTSUnpackStsxyter::ProcessMessage_sync(const uint8_t* msContent_shifted, uint16_t EqID, uint16_t RocID) -{ - Int_t messageType, rocID, syncCh, timestamp, data, status; - - messageType = (msContent_shifted[5] >> 0) & 0x07; // 3 bits - rocID = (msContent_shifted[5] >> 3) & 0x07; // 3 bits - syncCh = (msContent_shifted[5] >> 6) & 0x03; // 2 bits - timestamp = ((msContent_shifted[4] >> 0) & 0xFF) // 8 bits - + (((msContent_shifted[3] >> 0) & 0x3F) << 8); // 6 bits - data = ((msContent_shifted[3] >> 6) & 0x03) // 2 bits - + (((msContent_shifted[2] >> 0) & 0xFF) << 2) // 8 bits - + (((msContent_shifted[1] >> 0) & 0xFF) << 10) // 8 bits - + (((msContent_shifted[0] >> 0) & 0x3F) << 18); // 6 bits - status = (msContent_shifted[0] >> 6) & 0x03; // 2 bits - - new( (*fNxyterRawSync)[fNxyterRawSync->GetEntriesFast()] ) - CbmNxyterRawSyncMessage( - EqID, - RocID*4 + syncCh, //TODO check - syncCh, - fCurrEpoch, // - cur_hit_data.NxLastEpoch, //TODO subtract here or in GetFullTime() method ?! - timestamp, - status, - data); - - #ifdef VERBOSE - printf("messType=%d\tROC=0x%01X\tsyncCh=0x%01X\tTs=0x%04X\tdata=0x%08X\tstat=0x%01X\n", - messageType, rocID, syncCh, timestamp, data, status); - #endif - -} - -// Pileup flag, edge type, timestamp, channel, ROC id, messageType=4 -// [--------][--------][---PETTT][TTTTTTTT][TTTCCCCC][CCRRR100] -void CbmTSUnpackStsxyter::ProcessMessage_aux(const uint8_t* msContent_shifted, uint16_t EqID, uint16_t RocID) -{ - Int_t messageType, rocID, channel, timestamp; - Bool_t edgeType, pileUp; - - messageType = (msContent_shifted[5] >> 0) & 0x07; // 3 bits - rocID = (msContent_shifted[5] >> 3) & 0x07; // 3 bits - channel = ((msContent_shifted[5] >> 6) & 0x03) // 2 bits - + (((msContent_shifted[4] >> 0) & 0x1F) << 2); // 5 bits - - timestamp = ((msContent_shifted[4] >> 5) & 0x07) // 3 bits - + (((msContent_shifted[3] >> 0) & 0xFF) << 3) // 8 bits - + (((msContent_shifted[2] >> 0) & 0x07) << 11); // 3 bit - - edgeType = (msContent_shifted[2] >> 3) & 0x01; // 1 bit - pileUp = (msContent_shifted[2] >> 4) & 0x01; // 1 bit - - //TODO put the unpacked data into some output array - - #ifdef VERBOSE - printf("messType=%d\tROC=0x%01X\tCh=0x%02X\tTs=0x%04X\tedgeType=%d\tpileUp=%d\n", - messageType, rocID, channel, timestamp, edgeType, pileUp); - #endif -} - -// First four bytes are yet not unpacked, system message type, NX id, ROC id, messageType=7 -// [--------][--------][--------][--------][TTTTTTTT][NNRRR111] -void CbmTSUnpackStsxyter::ProcessMessage_sys(const uint8_t* msContent_shifted, uint16_t EqID, uint16_t RocID) -{ - Int_t messageType, rocID, nxID, sysMessType; - - messageType = (msContent_shifted[5] >> 0) & 0x07; // 3 bits - rocID = (msContent_shifted[5] >> 3) & 0x07; // 3 bits - nxID = (msContent_shifted[5] >> 6) & 0x03; // 2 bits - sysMessType = (msContent_shifted[4] >> 0) & 0xFF; // 8 bits - - //TODO put the unpacked data into some output array - - #ifdef VERBOSE - printf("messType=%d\tROC=0x%01X\tNX=0x%02X\tsysMessType=%02X\n", - messageType, rocID, nxID, sysMessType); - #endif -} - - */ - -ClassImp(CbmTSUnpackStsxyter) diff --git a/beamtime/cern2014/unpacker/CbmTSUnpackStsxyter.h b/beamtime/cern2014/unpacker/CbmTSUnpackStsxyter.h deleted file mode 100644 index fe211d90a3007fea336eb31c6ccdc2a069de1f99..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/unpacker/CbmTSUnpackStsxyter.h +++ /dev/null @@ -1,141 +0,0 @@ -#ifndef CBMTSUNPACKSTSXYTER_H -#define CBMTSUNPACKSTSXYTER_H - -#include "Timeslice.hpp" - -#include "CbmTSUnpack.h" -#include "TClonesArray.h" -#ifdef HAVE_UINT8_T_HEADER_FILE -#include <_types/_uint8_t.h> -#include <_types/_uint16_t.h> -#include <_types/_uint32_t.h> -#include <_types/_uint64_t.h> -#else -#include <stdint.h> -#endif - -class CbmTSUnpackStsxyter : public CbmTSUnpack -{ -public: - - CbmTSUnpackStsxyter(); - virtual ~CbmTSUnpackStsxyter(); - - virtual Bool_t Init(); - - virtual Bool_t DoUnpack(const fles::Timeslice& ts, size_t component); - - virtual void Reset(); - - virtual void Finish() {;} - -private: - static const size_t fkgDtmSizeOffset = 0; - static const size_t fkgDtmNumOffset = 1; - static const size_t fkgDtmDataOffset = 2; - static const size_t fkgNumStsxytersDefault = 8; - static const size_t fkgNumStsxyterLinks = 4; - - Int_t fDtmNum; - Bool_t fDtmNumInitialized; - std::vector< std::vector< Int_t > > fCurrEpoch; - - Bool_t CheckDtmNumSequence( const uint8_t * const & dtm, const Bool_t & newTimeslice ); - const uint8_t * GetFirstDtm( const uint8_t * const & microsliceBegin ) const; - const uint8_t * GetDtmContent( const uint8_t * const & dtm ) const; - size_t GetDtmContentSize( const uint8_t * const & dtm ) const; - size_t GetDtmFullSize( const uint8_t * const & dtm ) const; - Bool_t IsStsxyterDtm( const uint8_t * const & dtmContent, const size_t & size ) const; - Bool_t IsStsxyterDtmUnstrict( const uint8_t * const & dtmContent, const size_t & size ) const; - void ByteDump( const uint8_t * const & data, size_t sizeBytes, size_t lineLenBytes = 32 ) const; - void ByteDumpSwap( const uint8_t * const & data, size_t sizeBytes, size_t lineLenBytes = 32 ) const; - void UnpackDtmContent( const uint8_t * const & dtmContent, const size_t & size, const uint16_t & equipmentId ); - void UnpackStsxyterDtmContent( const uint8_t * const & dtmContent, const size_t & size, const uint16_t & equipmentId ); - void UnpackStsxyterMessage( const uint32_t & msg, const Int_t & sourceAddress, const uint16_t & equipmentId ); - void UnpackEpochMessage( const uint32_t & msg, const Int_t & sourceAddress, const uint16_t & equipmentId ); - void UnpackHitMessage( const uint32_t & msg, const Int_t & sourceAddress, const uint16_t & equipmentId ); - static Bool_t IsEpochMessage( const uint32_t & msg ); - static Bool_t IsHitMessage( const uint32_t & msg ); - - static uint32_t GetUint32( const uint8_t * const & val ) { return * ( reinterpret_cast< const uint32_t * const >( val ) ); } - static uint32_t GetField(const uint32_t dword, const uint8_t shift, const uint8_t len) { return (dword >> shift) & (((static_cast<uint32_t>(1)) << len) - 1); } - static uint32_t GetBit(const uint32_t dword, const uint8_t shift) { return ( dword >> shift ) & 1; } - - static void InitializeParityTable(); - static std::vector< Bool_t > fgParityTable; - static Bool_t fgParityTableinitialized; - static Bool_t CalculateEvenParity( size_t number ); - static Bool_t GetEvenParity( uint32_t number ) { return fgParityTable.at( number ); } - - TClonesArray* fStsxyterRawHitMessage; // Output array of raw hit messages - -#ifdef __SWAPWORDS -#error "__SWAPWORDS" identifier is defined -#endif - -#define __SWAPWORDS( firstBit ) ( (firstBit) >= 16 ? (firstBit) - 16 : (firstBit) + 16 ) - - static const uint8_t kHitSignatureFirstBit = __SWAPWORDS( 30 ); - static const uint8_t kHitSignatureNBits = 31 - 30 + 1 ; - static const uint8_t kHitSignatureValue = 2; // 0b10 ; - - static const uint8_t kHitLinkFirstBit = __SWAPWORDS( 28 ); - static const uint8_t kHitLinkNBits = 29 - 28 + 1 ; - - static const uint8_t kHitChannelFirstBit = __SWAPWORDS( 23 ); - static const uint8_t kHitChannelNBits = 27 - 23 + 1; - - static const uint8_t kHitUnusedBit0 = __SWAPWORDS( 22 ); - static const uint32_t kHitUnusedBit0Value = 0; - - static const uint8_t kHitAmpFirstBit = __SWAPWORDS( 17 ); - static const uint8_t kHitAmpNBits = 21 - 17 + 1; - - static const uint8_t kHitUnusedBit1 = __SWAPWORDS( 16 ); - static const uint32_t kHitUnusedBit1Value = 0; - - static const uint8_t kHitParityBit = __SWAPWORDS( 15 ); - - static const uint8_t kHitEvMissedBit = __SWAPWORDS( 14 ); - - static const uint8_t kHitUnusedBits23FirstBit = __SWAPWORDS( 12 ); - static const uint8_t kHitUnusedBits23NBits = 13 - 12 + 1; - static const uint32_t kHitUnusedBits23Value = 0; // 0b00; - - static const uint8_t kHitTimestampFirstBit = __SWAPWORDS( 0 ); - static const uint8_t kHitTimestampNBits = 11 - 0 + 1; - // static const uint8_t kHitTimestampNBits = 10 - 0 + 1; - - static const uint8_t kEpochSignatureFirstBit = __SWAPWORDS( 29 ); - static const uint8_t kEpochSignatureNBits = 3; - static const uint8_t kEpochSignatureValue = 1; // 0b001; - - static const uint8_t kEpochLinkFirstBit = __SWAPWORDS( 27 ); - static const uint8_t kEpochLinkNBits = 28 - 27 + 1; - - static const uint8_t kEpochNChMarkersFirstBit = __SWAPWORDS( 22 ); - static const uint8_t kEpochNChMarkersNBits = 26 - 22 + 1 ; - - static const uint8_t kEpochFifoOvfBit = __SWAPWORDS( 22 ); - - static const uint8_t kEpochABits0To1FirstBit = __SWAPWORDS( 14 ); - static const uint8_t kEpochABits0To1NBits = 15 - 14 + 1 ; - - static const uint8_t kEpochABits2To6FirstBit = __SWAPWORDS( 16 ); - static const uint8_t kEpochABits2To6NBits = 20 - 16 + 1 ; - - static const uint8_t kEpochBFirstBit = __SWAPWORDS( 7 ); - static const uint8_t kEpochBNBits = 13 - 7 + 1 ; - - static const uint8_t kEpochCFirstBit = __SWAPWORDS( 0 ); - static const uint8_t kEpochCNBits = 6 - 0 + 1 ; - -#undef __SWAPWORDS - - CbmTSUnpackStsxyter(const CbmTSUnpackStsxyter&); - CbmTSUnpackStsxyter& operator=(const CbmTSUnpackStsxyter&); - - ClassDef(CbmTSUnpackStsxyter, 1); -}; - -#endif diff --git a/beamtime/cern2014/unpacker/CbmTSUnpackTestMiniRich.cxx b/beamtime/cern2014/unpacker/CbmTSUnpackTestMiniRich.cxx deleted file mode 100644 index 0877dadf631e95ee64a8b46064e0b6ee0d45ec72..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/unpacker/CbmTSUnpackTestMiniRich.cxx +++ /dev/null @@ -1,718 +0,0 @@ -#include "CbmTSUnpackTestMiniRich.h" - -// ROOT -#include "TClonesArray.h" -#include "TH1D.h" -#include "TH2D.h" - -// FairRoot -#include "FairLogger.h" -#include "FairRootManager.h" - -// Temporary -#include "Support.hpp" -#include "Timeslice.hpp" - -// Project -#include "CbmTrbRawMessage.h" -#include "CbmTimeSlice.h" - -#define RISINGEDGEID 1 -#define FALLINGEDGEID 0 - -CbmTSUnpackTestMiniRich::CbmTSUnpackTestMiniRich() : - CbmTSUnpack(), - fCTSch1Fine(0.), - fEventsCounter(0), - fCurMSid(0), - fInSubSubEvent(kFALSE), - fCurEpochCounter(0) -{ -} - -CbmTSUnpackTestMiniRich::~CbmTSUnpackTestMiniRich() -{ -} - -Bool_t CbmTSUnpackTestMiniRich::Init() -{ - LOG(info) << "Initializing test mRICH unpacker"; - - FairRootManager* ioman = FairRootManager::Instance(); - if (ioman == NULL) { - LOG(fatal) << "No FairRootManager instance"; - } - - fTrbRawMessages = new TClonesArray("CbmTrbRawMessage"); - ioman->Register("fTrbRawMessages", "Raw TRB messages", fTrbRawMessages, kTRUE); - - // Hardcode TRB addresses - this->InitTRBaddresses(); - - // Init histograms - this->InitHistograms(); - - return kTRUE; -} - -void CbmTSUnpackTestMiniRich::InitTRBaddresses(void) -{ - fNtdcs = 7; - fAddresses.insert(std::pair<Int_t, Int_t>(0xc000, 0)); - fAddresses.insert(std::pair<Int_t, Int_t>(0x7000, 1)); - fAddresses.insert(std::pair<Int_t, Int_t>(0x7001, 2)); - fAddresses.insert(std::pair<Int_t, Int_t>(0x7100, 3)); - fAddresses.insert(std::pair<Int_t, Int_t>(0x7101, 4)); - fAddresses.insert(std::pair<Int_t, Int_t>(0x7110, 5)); - fAddresses.insert(std::pair<Int_t, Int_t>(0x7111, 6)); - - fLastFirstChTime_CTS = 0.; - for (Int_t i=0; i<fNtdcs; i++) { - fCh0time.push_back(0.); - fPrevCh0time.push_back(0.); - } -} - -void CbmTSUnpackTestMiniRich::InitHistograms(void) -{ - Double_t refValue = 102400.; - fhZeroChDeltaT = new TH2D("fhZeroChDeltaT", "fhZeroChDeltaT;TDC;ns", fNtdcs, 0., fNtdcs, 4000, refValue-20., refValue+20.); - fhFirstChDeltaT_CTS = new TH1D("fhFirstChDeltaT_CTS", "fhFirstChDeltaT_CTS;ns", 4000, 102400-20., 102400+20.); - - Double_t refValue3 = 0.; - Double_t refWidth3 = 1000.; - fhCTSCh1E0DeltaT = new TH1D("fhCTSCh1E0DeltaT", "fhCTSCh1E0DeltaT", 4000, refValue3-refWidth3/2., refValue3+refWidth3/2.); - fhCTSCh1E1DeltaT = new TH1D("fhCTSCh1E1DeltaT", "fhCTSCh1E1DeltaT", 4000, refValue3-refWidth3/2., refValue3+refWidth3/2.); - fhCTSCh2E0DeltaT = new TH1D("fhCTSCh2E0DeltaT", "fhCTSCh2E0DeltaT", 4000, refValue3-refWidth3/2., refValue3+refWidth3/2.); - fhCTSCh2E1DeltaT = new TH1D("fhCTSCh2E1DeltaT", "fhCTSCh2E1DeltaT", 4000, refValue3-refWidth3/2., refValue3+refWidth3/2.); - - Double_t nbins = 5000; - Double_t refValue2 = 0.; - Double_t histoWidth = 1000.; - for (Int_t i=0; i<fNtdcs; i++) { - TString histoName; - TString histoTitle; - - histoName.Form("fhDeltaT_LE_%d", i); - histoTitle.Form("fhDeltaT_LE_%d;ch;ns", i); - fhDeltaT_LE.push_back(new TH2D(histoName, histoTitle, 33, 0., 33., nbins, refValue2-histoWidth/2., refValue2+histoWidth/2.)); - histoName.Form("fhDeltaT_FE_%d", i); - histoTitle.Form("fhDeltaT_FE_%d;ch;ns", i); - fhDeltaT_FE.push_back(new TH2D(histoName, histoTitle, 33, 0., 33., nbins, refValue2-histoWidth/2., refValue2+histoWidth/2.)); - histoName.Form("fhDeltaT_LE_corr_%d", i); - histoTitle.Form("fhDeltaT_LE_corr_%d;ch;ns", i); - fhDeltaT_LE_corr.push_back(new TH2D(histoName, histoTitle, 33, 0., 33., 4000, 0., 400.)); - histoName.Form("fhDeltaT_FE_corr_%d", i); - histoTitle.Form("fhDeltaT_FE_corr_%d;ch;ns", i); - fhDeltaT_FE_corr.push_back(new TH2D(histoName, histoTitle, 33, 0., 33., 4000, 0., 400.)); - - histoName.Form("fhFine_LE_%d", i); - histoTitle.Form("fhFine_LE_%d;ch;fine time counter value", i); - fhFine_LE.push_back(new TH2D(histoName, histoTitle, 33, 0., 33., 1025, 0., 1025.)); - histoName.Form("fhFine_FE_%d", i); - histoTitle.Form("fhFine_FE_%d;ch;fine time counter value", i); - fhFine_FE.push_back(new TH2D(histoName, histoTitle, 33, 0., 33., 1025, 0., 1025.)); - - histoName.Form("fhToT_%d", i); - histoTitle.Form("fhToT_%d;ch;ns", i); - fhToT.push_back(new TH2D(histoName, histoTitle, 33, 0., 33., 2000, -10., 10.)); - } - -} - -void CbmTSUnpackTestMiniRich::WriteHistograms(void) -{ - fhZeroChDeltaT->Write(); - fhFirstChDeltaT_CTS->Write(); - - fhCTSCh1E0DeltaT->Write(); - fhCTSCh1E1DeltaT->Write(); - fhCTSCh2E0DeltaT->Write(); - fhCTSCh2E1DeltaT->Write(); - - for (Int_t i=0; i<fNtdcs; i++) { - fhDeltaT_LE[i]->Write(); - fhDeltaT_FE[i]->Write(); - fhDeltaT_LE_corr[i]->Write(); - fhDeltaT_FE_corr[i]->Write(); - } - - for (Int_t i=0; i<fNtdcs; i++) { - fhFine_LE[i]->Write(); - } - - for (Int_t i=0; i<fNtdcs; i++) { - fhFine_FE[i]->Write(); - } - - for (Int_t i=0; i<fNtdcs; i++) { - fhToT[i]->Write(); - } -} - -Bool_t CbmTSUnpackTestMiniRich::DoUnpack(const fles::Timeslice& ts, size_t component) -{ - /*if (fEventsCounter%100 == 0)*/ - { - LOG(info) << "Processing timeslice " << fEventsCounter; - } - fEventsCounter++; - - LOG(debug) << "Components: " << ts.num_components(); - LOG(debug) << "Microslices: " << ts.num_microslices(component); - - /*const uint64_t compSize = ts.size_component(component); - LOG(debug) << "Component " << component << " has size " << compSize;*/ - - for (size_t iMS = 0; iMS < ts.num_microslices(component); ++iMS) - { - fCurMSid = iMS; - LOG(debug) << "======================================================="; - const fles::MicrosliceView mv = ts.get_microslice(component, iMS); - const fles::MicrosliceDescriptor& msDesc = mv.desc(); - const uint8_t* msContent = mv.content(); - LOG(debug) << "msDesc.size=" << msDesc.size; - LOG(debug) << "msDesc.idx=" << msDesc.idx; - //PrintRaw(msDesc.size, msContent); - //LOG(debug) << "======================================================="; - ProcessMicroslice(msDesc.size, msContent); - //LOG(debug) << "======================================================="; - } - return kTRUE; -} - -void CbmTSUnpackTestMiniRich::Reset() -{ - fTrbRawMessages->Clear(); -} - -void CbmTSUnpackTestMiniRich::Finish() -{ - this->WriteHistograms(); -} - -void CbmTSUnpackTestMiniRich::ProcessMicroslice(size_t const size, uint8_t const * const ptr) -{ - if (size == 0) return; - - fGwordCnt = 0; //TODO testing - - Int_t offset; // offset in bytes - Int_t* dataPtr; - - offset = 0; SwapBytes(4, ptr+offset); - LOG(debug4) << "[" << fGwordCnt++ << "]\t" << GetWordHexRepr(ptr+offset) << "\t" << "ok" << "\t" - << "Reserved 0000 0000"; - - offset = 4; SwapBytes(4, ptr+offset); dataPtr = (Int_t*)(ptr+offset); - Int_t mbsNumber = (Int_t)(dataPtr[0] & 0xffffff); - LOG(debug4) << "[" << fGwordCnt++ << "]\t" << GetWordHexRepr(ptr+offset) << "\t" << "ok" << "\t" - << "mbsNumber = " << mbsNumber; - - - // We suppose that the first word is - // "HadesTransportUnitQueue - Length" - offset = 0+8; SwapBytes(4, ptr+offset); dataPtr = (Int_t*)(ptr+offset); - fTRBeventSize1 = (Int_t)(dataPtr[0]); - LOG(debug4) << "[" << fGwordCnt++ << "]\t" << GetWordHexRepr(ptr+offset) << "\t" << "ok" << "\t" - << "HadesTransportUnitQueue - Length = " << fTRBeventSize1; - - if (*dataPtr >= 0 && uint(*dataPtr) == 0x80030000) { - LOG(info) << "dataPtr == 0x80030000"; - exit(EXIT_FAILURE); - } - - - // We suppose that the second word is - // "HadesTransportUnitQueue - Decoder (Seems to be allways the same)" - offset = 4+8; SwapBytes(4, ptr+offset); dataPtr = (Int_t*)(ptr+offset); - Int_t dcdr = (Int_t)(dataPtr[0]); - if (dcdr == 0x00030062) { - LOG(debug4) << "[" << fGwordCnt++ << "]\t" << GetWordHexRepr(ptr+offset) << "\t" << "ok" << "\t" - << "HadesTransportUnitQueue - Decoder = " << dcdr; - } else { - LOG(warning) << "[" << fGwordCnt++ << "]\t" << GetWordHexRepr(ptr+offset) << "\t" << "er" << "\t" - << "HadesTransportUnitQueue - Decoder = " << dcdr - << " is not 0x00030062 (196706)"; - } - - // We suppose that the third word is - // TRB event length (in bytes) - // It should be 8 less than the size specified two words ago - offset = 8+8; SwapBytes(4, ptr+offset); dataPtr = (Int_t*)(ptr+offset); - fTRBeventSize2 = (Int_t)(dataPtr[0]); - if (fTRBeventSize2 == fTRBeventSize1-8) { - LOG(debug4) << "[" << fGwordCnt++ << "]\t" << GetWordHexRepr(ptr+offset) << "\t" << "ok" << "\t" - << "TRB event - Length = " << fTRBeventSize2 - << " == " << fTRBeventSize1 << "-8"; - } else { - LOG(debug) << "[" << fGwordCnt++ << "]\t" << GetWordHexRepr(ptr+offset) << "\t" << "er" << "\t" - << "TRB event - Length = " << fTRBeventSize2 - << " != " << fTRBeventSize1 << "-8=" << fTRBeventSize1-8; - } - - ProcessTRBevent(fTRBeventSize2, ptr+offset); -} - -Int_t CbmTSUnpackTestMiniRich::ProcessTRBevent(size_t const size, uint8_t const * const ptr) -{ - Int_t offset; // offset in bytes - Int_t* dataPtr; - - // Skip first word (already processed outside) - - // We suppose that the second word consists of - // 0002 - number of following word till the Event Data Starts (should be the same) - // 00<TriggerType>1 - value in [7:4] defines TriggerType - offset = 4; SwapBytes(4, ptr+offset); dataPtr = (Int_t*)(ptr+offset); - Int_t checkSize = (Int_t)((dataPtr[0] >> 16) & 0xffff); - fTriggerType = (Int_t)((dataPtr[0] >> 4) & 0xf); - if (checkSize == 2) { - LOG(debug4) << "[" << fGwordCnt++ << "]\t" << GetWordHexRepr(ptr+offset) << "\t" << "ok" << "\t" - << "checkSize == 2" << "\t" - << "trigger type = " << fTriggerType; - } else { - LOG(warning) << "[" << fGwordCnt++ << "]\t" << GetWordHexRepr(ptr+offset) << "\t" << "er" << "\t" - << "checkSize != 2" << "\t" - << "trigger type = " << fTriggerType; - } - - /*for (size_t iWord=2; iWord<size; iWord++) { - offset = iWord*4; - LOG(debug4) << "\t" << GetWordHexRepr(ptr+offset); - }*/ - - // We suppose that the third word consists of - // 0000 <SubEventId> - offset = 8; SwapBytes(4, ptr+offset); dataPtr = (Int_t*)(ptr+offset); - Int_t checkBytes = (Int_t)((dataPtr[0] >> 16) & 0xffff); - fSubEvId = (Int_t)((dataPtr[0]) & 0xffff); - if (checkBytes == 0) { - LOG(debug4) << "[" << fGwordCnt++ << "]\t" << GetWordHexRepr(ptr+offset) << "\t" << "ok" << "\t" - << "checkBytes == 0" << "\t" - << "subevent ID = 0x" << GetHexRepresentation(2, ptr+offset); - } else { - LOG(warning) << "[" << fGwordCnt++ << "]\t" << GetWordHexRepr(ptr+offset) << "\t" << "er" << "\t" - << "checkBytes != 0" << "\t" - << "subevent ID = 0x" << GetHexRepresentation(2, ptr+offset); - } - - // We suppose that the fourth word is the trigger number - offset = 12; SwapBytes(4, ptr+offset); dataPtr = (Int_t*)(ptr+offset); - fTriggerNum = (Int_t)(dataPtr[0]); - LOG(debug4) << "[" << fGwordCnt++ << "]\t" << GetWordHexRepr(ptr+offset) << "\t" << "ok" << "\t" - << "trigger num = " << fTriggerNum; - - offset = 16; - - // Int_t iIter = 0; (VF) unused - - while (static_cast<size_t>(offset) < size) { - - //std::cout << "SE iteration " << iIter++ << "\toffset=" << offset << "\tsize=" << size << std::endl; - - // We suppose that the fifth word is the header of the subevent - // <Length> <HubId> - SwapBytes(4, ptr+offset); dataPtr = (Int_t*)(ptr+offset); - fSubEvSize = (Int_t)((dataPtr[0] >> 16) & 0xffff); - fHubId = (Int_t)((dataPtr[0]) & 0xffff); - LOG(debug4) << "[" << fGwordCnt++ << "]\t" << GetWordHexRepr(ptr+offset) << "\t" << "ok" << "\t" - << "hub ID = 0x" << GetHexRepresentation(2, ptr+offset) << "\t" - << "subevent size = " << fSubEvSize; - - //FIXME change from 0xc001 to 0xc000 at some point - if ((fHubId == 0xc001) || (fHubId == 0xc000)) { - fSubSubEvId = fHubId; - offset += (4 + ProcessCTSsubevent(fSubEvSize*4, ptr+offset)); - // In principle, should be reset here for safety - fSubSubEvId = 0; - } else if (fHubId == 0x5555) { - //TODO one could implement additional checks here about the - // words coming after the "event end" but we skip everything by now. - offset += (4 + ProcessSKIPsubevent(fSubEvSize*4, ptr+offset)); - } else { - offset += (4 + ProcessTRBsubevent(fSubEvSize*4, ptr+offset)); - } - } - - //TODO implement checks - //std::cout << "Done processing TRB event. offset=" << offset << "\tsize=" << size << std::endl; - - return size; //TODO check -} - -Int_t CbmTSUnpackTestMiniRich::ProcessTRBsubevent(size_t const size, uint8_t const * const ptr) -{ - //std::cout << "ProcessTRBsubevent size=" << size << " bytes" << std::endl; - - Int_t offset; // offset in bytes - Int_t* dataPtr; - - // Skip first word (already processed outside) - - // Int_t iIter = 0; (VF) unused - offset = 4; - - while (static_cast<size_t>(offset) < size) { - - //std::cout << "SSE iteration " << iIter++ << "\toffset=" << offset << "\tsize=" << size << std::endl; - - // We suppose that the second word is the header of the subsubevent - // <Length> <SubSubEv.Id> - SwapBytes(4, ptr+offset); dataPtr = (Int_t*)(ptr+offset); - fSubSubEvSize = (Int_t)((dataPtr[0] >> 16) & 0xffff); - fSubSubEvId = (Int_t)((dataPtr[0]) & 0xffff); - LOG(debug4) << "[" << fGwordCnt++ << "]\t" << GetWordHexRepr(ptr+offset) << "\t" << "ok" << "\t" - << "subsubevent ID (FPGA ID) = 0x" << GetHexRepresentation(2, ptr+offset) << "\t" - << "subsubevent size = " << fSubSubEvSize; - - // Add 4 bytes which correspond to the header word - offset += (4 + ProcessTRBsubsubevent(fSubSubEvSize*4, ptr+offset+4)); // MAIN CALL HERE - - // In principle, should be reset here for safety - fSubSubEvId = 0; - - } - - - //TODO implement checks - //std::cout << "Done processing TRB subevent. offset=" << offset << "\tsize=" << size << std::endl; - - return size; //TODO check -} - -Int_t CbmTSUnpackTestMiniRich::ProcessCTSsubevent(size_t const size, uint8_t const * const ptr) -{ - //std::cout << "ProcessCTSsubevent size=" << size << " bytes" << std::endl; - - Int_t offset; // offset in bytes - Int_t* dataPtr; - - // Skip first word (already processed outside) - - // We suppose that the second word is the header of the subsubevent - offset = 4; SwapBytes(4, ptr+offset); dataPtr = (Int_t*)(ptr+offset); - LOG(debug4) << "[" << fGwordCnt++ << "]\t" << GetWordHexRepr(ptr+offset) << "\t" << "ok" << "\t" - << "CTS header"; - -/* (FU) not used - Short_t trigState[16]; - for (Int_t i=0; i<16; i++) { - trigState[i] = ((*dataPtr >> i) & 0x1); // 16 x 1 bit - } -*/ - - Short_t nInp = ((*dataPtr >> 16) & 0xf); // 4 bits - Short_t nTrigCh = ((*dataPtr >> 20) & 0x1f); // 5 bits - Short_t inclLastIdle = ((*dataPtr >> 25) & 0x1); // 1 bit - Short_t inclTrigInfo = ((*dataPtr >> 26) & 0x1); // 1 bit - Short_t inclTS = ((*dataPtr >> 27) & 0x1); // 1 bit - Short_t ETM = ((*dataPtr >> 28) & 0x3); // 2 bits - - // in words (not bytes) - Short_t CTSinfo_size = nInp*2 + nTrigCh*2 + inclLastIdle*2 + inclTrigInfo*3 + inclTS; - switch (ETM) { - case 0: - break; - case 1: - CTSinfo_size += 1; - break; - case 2: - CTSinfo_size += 4; - break; - case 3: - LOG(debug) << "ETM == 3"; - //TODO implement - break; - } - - LOG(debug) << "CTS information size (extracted from the CTS header): " << CTSinfo_size; - - offset = 8; - - while (offset-8 < CTSinfo_size*4) { - - SwapBytes(4, ptr+offset); dataPtr = (Int_t*)(ptr+offset); - ULong_t MSidx = 102400UL * ((ULong_t)(*dataPtr) - 1); - LOG(debug4) << "[" << fGwordCnt++ << "]\t" << GetWordHexRepr(ptr+offset) << "\t" << MSidx << "\t" << "ok" << "\t" - << "CTS information"; - - offset += 4; - } - - // size - full size including CTS header word, CTS informations words (CTSinfo_size) and TCD data - // Thus TDC data size = full size - 1 word (header) - CTSinfo_size words (CTS informations) - offset += (ProcessTRBsubsubevent((size-(1+CTSinfo_size)*4), ptr+offset)); // MAIN CALL HERE - - //TODO implement checks - //std::cout << "Done processing CTS subevent. offset=" << offset << "\tsize=" << size << std::endl; - - return size; //TODO check -} - -Int_t CbmTSUnpackTestMiniRich::ProcessSKIPsubevent(size_t const size, uint8_t const * const ptr) -{ - //std::cout << "ProcessSKIPsubevent size=" << size << " bytes" << std::endl; - - Int_t offset; // offset in bytes -// Int_t* dataPtr; (FU) not used - - // Skip first word (already processed outside) - - // Int_t iIter = 0; (VF) unused - offset = 4; - - while (static_cast<size_t>(offset) < size+4) { - - SwapBytes(4, ptr+offset); -// dataPtr = (Int_t*)(ptr+offset); (FU) not used - LOG(debug4) << "[" << fGwordCnt++ << "]\t" << GetWordHexRepr(ptr+offset); - - offset += 4; - } - - //TODO implement checks - //std::cout << "Done processing SKIP subevent. offset=" << offset << "\tsize=" << size << std::endl; - - return size; //TODO check -} - -Int_t CbmTSUnpackTestMiniRich::ProcessTRBsubsubevent(size_t const size, uint8_t const * const ptr) -{ - //std::cout << "ProcessTRBsubsubevent size=" << size << " bytes" << std::endl; - - fCurEpochCounter = 0; //TODO check - fInSubSubEvent = kFALSE; //TODO check - - Int_t foundCh0times = this->GetCh0Time(size, ptr); - - if (foundCh0times == 0) { - LOG(error) << "No (ch==0 && edge==1) messages found."; - } else if (foundCh0times > 1) { - LOG(error) << "More than one (ch==0 && edge==1) message found."; - } /*else { - LOG(debug3) << "Exactly one (ch==0 && edge==1) message found."; - }*/ - - // To be on the safe side - reset again - fCurEpochCounter = 0; //TODO check - - for (size_t iWord=0; iWord<size/4; iWord++) { - ////SwapBytes(4, ptr+iWord*4); //now implemented in GetCh0Time() which is called right before - ProcessTDCword(ptr+iWord*4); // MAIN CALL HERE - } - - //TODO Implement checks that the first word was the header and the last word was the trailer - - return size; //TODO check -} - -Int_t CbmTSUnpackTestMiniRich::GetCh0Time(size_t const size, uint8_t const * const ptrStart) -{ - Int_t nFound = 0; // Counter of (ch==0 && edge==1) messages found in this subsubevent - - Int_t tdcIndex = fAddresses[fSubSubEvId]; - - for (size_t iWord=0; iWord<size/4; iWord++) - { - uint8_t const * ptr = ptrStart+iWord*4; - - SwapBytes(4, ptr); //!!!!!!! - - Int_t* tdcDataPtr = (Int_t*)ptr; - Int_t tdcData = tdcDataPtr[0]; - Int_t tdcTimeDataMarker = (tdcData >> 31) & 0x1; // 1 bit - - if (tdcTimeDataMarker == 0x1) { // Process only TIME messages, by now ignore anything else (HEADER, TRAILER...) - - Int_t channel = (tdcData >> 22) & 0x7f; // 7 bits - Int_t fine = (tdcData >> 12) & 0x3ff; // 10 bits - Int_t edge = (tdcData >> 11) & 0x1; // 1 bit - Int_t coarse = (tdcData) & 0x7ff; // 11 bits - Int_t epoch = fCurEpochCounter; - - Double_t fullTime = (Double_t)epoch*2048.*5. + (Double_t)(coarse)*5. - (Double_t)(fine)*0.005; - - LOG(debug4) << "[pre] " << GetWordHexRepr(ptr) << "\t" << "ok" << "\t" << "TIMESTAMP" << "\t" - << "ch=" << channel << "\t" - << "edge=" << edge << "\t" - << "epoch=" << epoch << "\t" - << "coarse=" << coarse << "\t" - << "fine=" << fine << "\t" - << "full=" << fullTime; - - if (fSubSubEvId == 0xc000 && channel == 1 && edge == RISINGEDGEID) { - fCTSch1Fine = (Double_t)(fine)*0.005; - } - - if (channel == 0 && edge == RISINGEDGEID) { - nFound++; - - fhZeroChDeltaT->Fill(tdcIndex, (fullTime - fPrevCh0time[tdcIndex])); - - fPrevCh0time[tdcIndex] = fCh0time[tdcIndex]; - fCh0time[tdcIndex] = fullTime; // only last found time is saved if multiple messages are found in the subsubsevent - - LOG(debug4) << "[pre] hit! fCh0time=" << fCh0time[tdcIndex] << "\tfPrevCh0time=" << fPrevCh0time[tdcIndex]; - } - - /*if (channel == 2 && edge == FALLINGEDGEID) { - fasd = fullTime - fPrevCh0time[tdcIndex]; - LOG(debug4) << "fasd=" << fasd; - }*/ - - if (fSubSubEvId == 0xc000) { - if (channel == 1) { - if (edge == 0) { - fCTSCh1E0dT_prev = fCTSCh1E0dT; - fCTSCh1E0dT = fullTime - fCh0time[0]; - fhCTSCh1E0DeltaT->Fill(fCTSCh1E0dT); - } else { - fCTSCh1E1dT_prev = fCTSCh1E1dT; - fCTSCh1E1dT = fullTime - fCh0time[0]; - fhCTSCh1E1DeltaT->Fill(fCTSCh1E1dT); - } - } else if (channel == 2) { - if (edge == 0) { - fCTSCh2E0dT_prev = fCTSCh2E0dT; - fCTSCh2E0dT = fullTime - fCh0time[0]; - fhCTSCh2E0DeltaT->Fill(fCTSCh2E0dT); - } else { - fCTSCh2E1dT_prev = fCTSCh2E1dT; - fCTSCh2E1dT = fullTime - fCh0time[0]; - fhCTSCh2E1DeltaT->Fill(fCTSCh2E1dT); - } - } - } - - } else { // Process only EPOCH messages, by now ignore anything else (HEADER, TRAILER...) - - UInt_t tdcMarker = (tdcData >> 29) & 0x7; // 3 bits - - if (tdcMarker == 0x3) { // EPOCH counter - fCurEpochCounter = (tdcData) & 0xfffffff; // 28 bits - } - } - } - - return nFound; -} - -void CbmTSUnpackTestMiniRich::ProcessTDCword(uint8_t const * const ptr) -{ - Int_t* tdcDataPtr = (Int_t*)ptr; - Int_t tdcData = tdcDataPtr[0]; - Int_t tdcTimeDataMarker = (tdcData >> 31) & 0x1; // 1 bit - - if (tdcTimeDataMarker == 0x1) { - - Int_t channel = (tdcData >> 22) & 0x7f; // 7 bits - Int_t fine = (tdcData >> 12) & 0x3ff; // 10 bits - Int_t edge = (tdcData >> 11) & 0x1; // 1 bit - Int_t coarse = (tdcData) & 0x7ff; // 11 bits - Int_t epoch = fCurEpochCounter; - - Double_t fullTime = (Double_t)epoch*2048.*5. + (Double_t)(coarse)*5. - (Double_t)(fine)*0.005; - - LOG(debug4) << "[" << fGwordCnt << "]\t" << GetWordHexRepr(ptr) << "\t" << "ok" << "\t" << "TIMESTAMP" << "\t" - << "ch=" << channel << "\t" - << "edge=" << edge << "\t" - << "epoch=" << epoch << "\t" - << "coarse=" << coarse << "\t" - << "fine=" << fine << "\t" - << "full=" << fullTime; - - fGwordCnt++; - - // Fine time couter value distribution - LOG(debug4) << std::hex << fSubSubEvId << std::dec; - Int_t tdcIndex = fAddresses[fSubSubEvId]; - LOG(debug4) << "TDC 0x" << std::hex << fSubSubEvId << std::dec << " index=" << tdcIndex; - - // -------------------------------------------------------------------- - if (edge == FALLINGEDGEID) { - fhFine_FE[tdcIndex]->Fill(channel, fine); - } else { - fhFine_LE[tdcIndex]->Fill(channel, fine); - } - // -------------------------------------------------------------------- - - // -------------------------------------------------------------------- - Double_t curDiff2 = fullTime - fLastFirstChTime_CTS; - if (fSubSubEvId == 0xc000 && channel == 1 && edge == RISINGEDGEID) { - fhFirstChDeltaT_CTS->Fill(curDiff2); - LOG(debug4) << "CTS ch " << channel << " deltaT=" << curDiff2; - fLastFirstChTime_CTS = fullTime; - } - // -------------------------------------------------------------------- - - // -------------------------------------------------------------------- - Double_t curDiff = fullTime - fPrevCh0time[tdcIndex]; - if (channel != 0) { - LOG(debug4) << "TDC 0x" << std::hex << fSubSubEvId << std::dec << " (" << tdcIndex << ")" << "\t" - << "ch=" << channel << "\t" - << "edge=" << edge << "\t" - << "time=" << fullTime << "\t" - << "diff=" << curDiff; - if (edge == FALLINGEDGEID) { - fhDeltaT_FE[tdcIndex]->Fill(channel, curDiff); - fhDeltaT_FE_corr[tdcIndex]->Fill(channel, curDiff - fCTSCh2E1dT); // fCTSch1Fine - } else { // LEADING - fhDeltaT_LE[tdcIndex]->Fill(channel, curDiff); - fhDeltaT_LE_corr[tdcIndex]->Fill(channel, curDiff - fCTSCh2E1dT); // fCTSch1Fine - } - } - // -------------------------------------------------------------------- - - WriteEdge(fSubSubEvId, channel, edge, epoch, coarse, fine); - - } else { - - UInt_t tdcMarker = (tdcData >> 29) & 0x7; // 3 bits - - if (tdcMarker == 0x0) { // TDC trailer - if (fInSubSubEvent) { - LOG(debug4) << "[" << fGwordCnt++ << "]\t" << GetWordHexRepr(ptr) << "\t" << "ok" << "\t" << "TDC TRAILER"; - fInSubSubEvent = kFALSE; - } else { - LOG(debug4) << "[" << fGwordCnt++ << "]\t" << GetWordHexRepr(ptr) << "\t" << "er" << "\t" << "UNKNOWN (TDC TRAILER not after header)"; - exit(EXIT_FAILURE); - } - } else if (tdcMarker == 0x1) { // TDC header - // UInt_t randomCode = (tdcData >> 16) & 0xff; // 8 bits - // UInt_t errorBits = (tdcData) & 0xffff; //16 bits - if (!fInSubSubEvent) { - LOG(debug4) << "[" << fGwordCnt++ << "]\t" << GetWordHexRepr(ptr) << "\t" << "ok" << "\t" << "TDC HEADER"; - fInSubSubEvent = kTRUE; - } else { - LOG(debug4) << "[" << fGwordCnt++ << "]\t" << GetWordHexRepr(ptr) << "\t" << "er" << "\t" << "UNKNOWN (TDC HEADER not after trailer)"; - } - } else if (tdcMarker == 0x2) { // DEBUG - // UInt_t debugMode = (tdcData >> 24) & 0x1f; // 5 bits - // UInt_t debugBits = (tdcData) & 0xffffff; // 24 bits - LOG(debug4) << "[" << fGwordCnt++ << "]\t" << GetWordHexRepr(ptr) << "\t" << "ok" << "\t" << "DEBUG"; - } else if (tdcMarker == 0x3) { // EPOCH counter - fCurEpochCounter = (tdcData) & 0xfffffff; // 28 bits - LOG(debug4) << "[" << fGwordCnt << "]\t" << GetWordHexRepr(ptr) << "\t" << "ok" << "\t" << "EPOCH\t" << fCurEpochCounter; - fGwordCnt++; - } else { - if (tdcTimeDataMarker != 0x1) { - LOG(debug4) << "[" << fGwordCnt++ << "]\t" << GetWordHexRepr(ptr) << "\t" << "er" << "\t" << "UNKNOWN"; - } - } - } -} - -void CbmTSUnpackTestMiniRich::WriteEdge(CbmTrbRawMessage* p_obj) -{ - Int_t nEdges = fTrbRawMessages->GetEntriesFast(); - new ((*fTrbRawMessages)[nEdges]) CbmTrbRawMessage(*p_obj); -} - -void CbmTSUnpackTestMiniRich::WriteEdge(Int_t febID, Int_t ch, Int_t edge, Int_t epoch, Int_t coarse, Int_t fine) -{ - Int_t nEdges = fTrbRawMessages->GetEntriesFast(); - new ((*fTrbRawMessages)[nEdges]) CbmTrbRawMessage(0x30, febID, ch, epoch, coarse, fine, edge, 0., fCurMSid); -} - -ClassImp(CbmTSUnpackTestMiniRich) diff --git a/beamtime/cern2014/unpacker/CbmTSUnpackTestMiniRich.h b/beamtime/cern2014/unpacker/CbmTSUnpackTestMiniRich.h deleted file mode 100644 index 22e269b35b5feaaad69a04d5253a96ffbed67cf7..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/unpacker/CbmTSUnpackTestMiniRich.h +++ /dev/null @@ -1,147 +0,0 @@ -#ifndef CBMTSUNPACKTESTMINIRICH_H -#define CBMTSUNPACKTESTMINIRICH_H - -#include "CbmTSUnpack.h" // mother class - -// STD -#include <map> -#include <vector> - -// ROOT -#include <TH2D.h> - -class TClonesArray; -class CbmTrbRawMessage; - -class CbmTSUnpackTestMiniRich : public CbmTSUnpack -{ -public: - CbmTSUnpackTestMiniRich(); - virtual ~CbmTSUnpackTestMiniRich(); - - virtual Bool_t Init(); - - void InitTRBaddresses(void); - - void InitHistograms(void); - - void WriteHistograms(void); - - virtual Bool_t DoUnpack(const fles::Timeslice& ts, size_t component); - - virtual void Reset(); - - virtual void Finish(); - - virtual void SetParContainers() {;} - - virtual void FillOutput(boost::any) {;} - -private: // histograms - - TH2D* fhZeroChDeltaT; - TH1D* fhFirstChDeltaT_CTS; - - TH1D* fhCTSCh1E0DeltaT; - TH1D* fhCTSCh1E1DeltaT; - TH1D* fhCTSCh2E0DeltaT; - TH1D* fhCTSCh2E1DeltaT; - - std::vector<TH2D*> fhDeltaT_LE; - std::vector<TH2D*> fhDeltaT_FE; - std::vector<TH2D*> fhDeltaT_LE_corr; - std::vector<TH2D*> fhDeltaT_FE_corr; - std::vector<TH2D*> fhFine_LE; - std::vector<TH2D*> fhFine_FE; - std::vector<TH2D*> fhToT; - -private: - - Int_t fNtdcs; - - std::map<Int_t, Int_t> fAddresses; - - Double_t fLastFirstChTime_CTS; - - std::vector<Double_t> fCh0time; - - std::vector<Double_t> fPrevCh0time; - - Double_t fCTSch1Fine; - - Double_t fCTSCh1E0dT; - Double_t fCTSCh1E1dT; - Double_t fCTSCh2E0dT; - Double_t fCTSCh2E1dT; - - Double_t fCTSCh1E0dT_prev; - Double_t fCTSCh1E1dT_prev; - Double_t fCTSCh2E0dT_prev; - Double_t fCTSCh2E1dT_prev; - -private: - - void ProcessMicroslice(size_t const size, uint8_t const * const ptr); - - /** - * Including header - */ - Int_t ProcessTRBevent(size_t const size, uint8_t const * const ptr); - - /** - * Including header - * Return number of processed bytes - */ - Int_t ProcessTRBsubevent(size_t const size, uint8_t const * const ptr); - - /** - * Including TDC header, but not including TRB subsubevent header - * Return number of processed bytes - */ - Int_t ProcessTRBsubsubevent(size_t const size, uint8_t const * const ptr); - - Int_t ProcessCTSsubevent(size_t const size, uint8_t const * const ptr); - - Int_t ProcessSKIPsubevent(size_t const size, uint8_t const * const ptr); - - Int_t GetCh0Time(size_t const size, uint8_t const * const ptrStart); - - void ProcessTDCword(uint8_t const * const ptr); - - /** - * Write unpacked edge into the output collection - */ - void WriteEdge(CbmTrbRawMessage* p_obj); - - /** - * Write unpacked edge into the output collection - */ - void WriteEdge(Int_t febID, Int_t ch, Int_t edge, Int_t epoch, Int_t coarse, Int_t fine); - -private: - - Int_t fEventsCounter; - - Int_t fCurMSid; - Int_t fGwordCnt; // global word counter within current microslice - - Bool_t fInSubSubEvent; - - UInt_t fCurEpochCounter; - Int_t fTRBeventSize1; - Int_t fTRBeventSize2; - Int_t fTriggerType; - Int_t fSubEvId; - Int_t fTriggerNum; - Int_t fSubEvSize; - Int_t fHubId; - Int_t fSubSubEvSize; - Int_t fSubSubEvId; - - // Output collection - TClonesArray* fTrbRawMessages; - - ClassDef(CbmTSUnpackTestMiniRich, 1); -}; - -#endif // CBMTSUNPACKTESTMINIRICH_H diff --git a/beamtime/cern2014/unpacker/CbmTSUnpackTrb.cxx b/beamtime/cern2014/unpacker/CbmTSUnpackTrb.cxx deleted file mode 100644 index 3c3d132f1c2dec8032cdccc78fcdde9fd806ab77..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/unpacker/CbmTSUnpackTrb.cxx +++ /dev/null @@ -1,398 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmTSUnpackTrb ----- -// ----- Created 07.11.2014 by F. Uhlig ----- -// ----- ----- -// ----------------------------------------------------------------------------- -#include "CbmTSUnpackTrb.h" - -#include "CbmTrbIterator.h" -#include "CbmRawEvent.h" -#include "CbmRawSubEvent.h" -#include "CbmRichTrbParam.h" -#include "CbmTrbCalibrator.h" -#include "CbmTrbRawMessage.h" - -#include "TimesliceReader.hpp" - -#include "FairLogger.h" -#include "FairRootManager.h" - -#include "TClonesArray.h" - -#include <iostream> -#include <bitset> - -CbmTSUnpackTrb::CbmTSUnpackTrb() - : CbmTSUnpack(), - fTrbRaw(new TClonesArray("CbmTrbRawMessage", 10)), - fTrbBridge(new TrbBridge()), - fTrbEventList(), - fData(), - fDataSize(0), - fSynchRefTime(0.), - fSynchOffsetTimeMap(), - fTrbIter(NULL), - fRawEvent(NULL), - fRawSubEvent(NULL), - fLink(0), - fEpochMarker(), - fTimeBuffer() -{ -} - -CbmTSUnpackTrb::~CbmTSUnpackTrb() -{ -} - -Bool_t CbmTSUnpackTrb::Init() -{ - LOG(info) << "Initializing"; - - FairRootManager* ioman = FairRootManager::Instance(); - if (ioman == NULL) { - LOG(fatal) << "No FairRootManager instance"; - } - ioman->Register("TrbRawMessage", "trb raw data", fTrbRaw, kTRUE); - - return kTRUE; -} - -Bool_t CbmTSUnpackTrb::DoUnpack(const fles::Timeslice& ts, size_t component) -{ - LOG(debug) << "Unpacking Trb Data"; - - fLink = ts.descriptor(component, 0).eq_id; - - Int_t skipMS = 1; //TODO: should be set from macro according to the flib settings - fTrbEventList = fTrbBridge->extractEventsFromTimeslice(ts, skipMS); - - LOG(debug) << "Found " << fTrbEventList.size() << " TRB events in time slice"; - - // Loop over all TRB events which are in the timeslice - while ( !fTrbEventList.empty() ) { - fData = fTrbEventList.front(); - fDataSize = fData.size(); - UnpackTrbEvents(); - fTrbEventList.pop_front(); - } - - return kTRUE; -} - - -void CbmTSUnpackTrb::Reset() -{ - fTrbEventList.clear(); - fTrbRaw->Clear(); -} - -void CbmTSUnpackTrb::Finish() -{ -} - -void CbmTSUnpackTrb::UnpackTrbEvents() -{ - - - fTrbIter = new CbmTrbIterator(static_cast<void*>(fData.data()), fDataSize); - - // Loop over TRB events - while (true) { - - // Try to extract next event from the Iterator. If no events left - go out of the loop - fRawEvent = fTrbIter->NextEvent(); - if (fRawEvent == NULL) break; - if(gLogger->IsLogNeeded( fair::Severity::debug )) { - fRawEvent->Print(); - } - fSynchRefTime = -1.; - - // Loop over TRB subevents - while (true){ - fRawSubEvent = fTrbIter->NextSubEvent(); - if (fRawSubEvent == NULL) break; - if(gLogger->IsLogNeeded( fair::Severity::debug )) { - fRawSubEvent->Print(); - } - ProcessTdc(fRawSubEvent); - } - - } - -} - -void CbmTSUnpackTrb::ProcessTdc(CbmRawSubEvent* rawSubEvent) -{ - UInt_t tdcDataIndex = 0; - UInt_t tdcData = 0x0; -// UInt_t trbId = rawSubEvent->SubId(); - - while (true) { - tdcData = rawSubEvent->SubDataValue(tdcDataIndex); - UInt_t tdcNofWords = (tdcData >> 16) & 0xffff; - UInt_t tdcId = tdcData & 0xffff; - LOG(debug) << "TDC DATA tdcNofWords = " << tdcNofWords << " , ID= " - << std::hex << tdcId << std::dec; - - if (tdcId == 0x5555) break; // Fixed word for end of SubSubEvent - - // if these ids show up one has to jump to the next word and interpret that one - // this magic knowledge comes from Jan and Manuel - if (tdcId == 0x7000 || tdcId == 0x7001 || tdcId == 0x7002 || tdcId == 0x7003){ - tdcDataIndex++; - continue; - } - - //read TDC words to array - UInt_t* dataArray = new UInt_t[tdcNofWords]; - for (UInt_t i = 0; i < tdcNofWords; i++) { - tdcDataIndex++; - tdcData = rawSubEvent->SubDataValue(tdcDataIndex); - dataArray[i] = tdcData; - } - DecodeTdcDataNew(dataArray, tdcNofWords, tdcId); - tdcDataIndex++; - delete [] dataArray; - } -} - -void CbmTSUnpackTrb::DecodeTdcDataNew(UInt_t* data, UInt_t length, UInt_t tdcId) -{ - - // ignore MBS-Triggern+ Billboard and CTS for the time beeing - if ( 0x7005 == tdcId || 0x112 == tdcId ) return; - - for (UInt_t i = 0; i < length; i++){ - LOG(debug) << "Data word: " << std::hex << data[i] << std::dec; - std::bitset<32> value(data[i]); - LOG(debug) << "Data word: " << value; - - UInt_t tdcData = data[i]; - - UInt_t tdcTimeDataMarker = (data[i] >> 31) & 0x1; //1 bit - if (tdcTimeDataMarker == 0x1) { //TIME DATA - LOG(debug) << "Found tdc time data for tdc " << tdcId; - UInt_t chNum = (tdcData >> 22) & 0x7f; // 7bits - UInt_t fineTime = (tdcData >> 12) & 0x3ff; // 10 bits //0x3ff - UInt_t edge = (tdcData >> 11) & 0x1; // 1bit - UInt_t coarseTime = (tdcData) & 0x7ff; // 1bits - - Int_t epochMarker = 0; - auto it=fEpochMarker.find(tdcId); - if (it != fEpochMarker.end()) { - epochMarker = it->second; - } - - LOG(debug) << "Found " << fineTime << ", " << edge << ", " << coarseTime - << " fine, edge and coarse " - << " for TDC " << tdcId << ", channel " << chNum; - - Double_t fullTime = GetFullCoarseTime(epochMarker, coarseTime); - LOG(info) << "FullTime: " << fullTime; - - new( (*fTrbRaw)[fTrbRaw->GetEntriesFast()] ) - CbmTrbRawMessage(fLink, tdcId, chNum, epochMarker, coarseTime, fineTime, edge, 0.); //FIXME 0 correction temporary - - - if( 110 == tdcId ) { - pair<Double_t, CbmTrbRawMessage*> - value_pair (fullTime, static_cast<CbmTrbRawMessage*>(fTrbRaw->At(fTrbRaw->GetEntriesFast()))); - fTimeBuffer.insert(value_pair); - - - - } - } else { - LOG(debug) << "No tdc time data for tdc " << tdcId; - UInt_t tdcMarker = (tdcData >> 29) & 0x7; //3 bits - if (tdcMarker == 0x1) {// TDC header - UInt_t randomCode = (tdcData >> 16) & 0xff; // 8bits - UInt_t errorBits = (tdcData) & 0xffff; //16 bits - LOG(debug) << Form("TDC HEADER randomCode:0x%02x, errorBits:0x%04x\n", - randomCode, errorBits); - } else if (tdcMarker == 0x2) {// DEBUG - UInt_t debugMode = (tdcData >> 24) & 0x1f; //5 - UInt_t debugBits = (tdcData) & 0xffffff;//24 bits - LOG(debug) << Form("DEBUG debugMode:%i, debugBits:0x%06x\n", - debugMode, debugBits); - } else if (tdcMarker == 0x3){ // EPOCH counter - UInt_t curEpochCounter = (tdcData) & 0xfffffff; //28 bits - - auto it=fEpochMarker.find(tdcId); - if (it == fEpochMarker.end()) { - fEpochMarker.insert( std::pair<Int_t,Int_t>(tdcId,curEpochCounter) ); - } else { - it->second = curEpochCounter; - } - - LOG(debug) << Form("EPOCH COUNTER epochCounter:0x%07x\n", - curEpochCounter); - } - } - - } -} - -void CbmTSUnpackTrb::DecodeTdcData(UInt_t* data, UInt_t size, UInt_t trbId, UInt_t tdcId) -{ - Bool_t isPmtTdc = CbmRichTrbParam::Instance()->IsPmtTdc(tdcId); - UInt_t curEpochCounter = 0; - UInt_t prevChNum[5] = {0, 0, 0, 0, 0}; - -/* (FU) not used - UInt_t prevEpochCounter[5] = {0, 0, 0, 0, 0}; - UInt_t prevCoarseTime[5] = {0, 0, 0, 0, 0}; - UInt_t prevFineTime[5] = {0, 0, 0, 0, 0}; -*/ - - UInt_t prevCounter = 0; -// UInt_t prevNof = 0; - for (UInt_t i = 0; i < size; i++){ - UInt_t tdcData = data[i]; - - UInt_t tdcTimeDataMarker = (tdcData >> 31) & 0x1; //1 bit - if (tdcTimeDataMarker == 0x1) { //TIME DATA - - UInt_t chNum = (tdcData >> 22) & 0x7f; // 7bits - UInt_t fineTime = (tdcData >> 12) & 0x3ff; // 10 bits //0x3ff - UInt_t edge = (tdcData >> 11) & 0x1; // 1bit - UInt_t coarseTime = (tdcData) & 0x7ff; // 1bits - - // Give the calibrator the read fine time so that it was taken into account - if ((trbId != 0x7005)) CbmTrbCalibrator::Instance()->AddFineTime(tdcId, chNum, fineTime); - - if (chNum == 0 ) { - Double_t time = GetFullTime(tdcId, chNum, curEpochCounter, coarseTime, fineTime); - //cout << "CHANNEL0: " << fixed << fSynchRefTime << " " << time << " "<<fSynchRefTime - time << " " <<hex << " TRB " << trbId << " TDC " << tdcId << dec << endl; - if (fSynchRefTime == -1. ) {//&& (isPmtTrb || tdcId == 0x0110) - fSynchRefTime = time; - } - if (fSynchRefTime != -1){ - fSynchOffsetTimeMap[tdcId] = fSynchRefTime - time; - } else{ - fSynchOffsetTimeMap[tdcId] = 0.; - } - } else { - if (tdcId == 0x7005) { //CTS - - } else if (tdcId == 0x0110) { // reference time TDC for event building - //cout << fSynchOffsetTimeMap[0x0110] << endl; - if (chNum == 5) { // || // hodoscope (beam trigger) - // (fAnaType == kCbmRichLaserPulserEvent && chNum == 7) || // UV LED - // (fAnaType == kCbmRichLedPulserEvent && chNum == 15) ){ // Laser - - - /* - new( (*fTrbRaw)[fTrbRaw->GetEntriesFast()] ) - CbmTrbRawMessage(trbId, tdcId, chNum, curEpochCounter, coarseTime, fineTime, 0, 0, 0, 0); - */ - // fRawEventTimeHits.push_back(rawHitRef); - } - } else if ( isPmtTdc ) { - if (chNum == prevChNum[prevCounter]) { - LOG(debug) << " DOUBLE HIT DETECTED TIMEDATA chNum:" << chNum << ", fineTime:" << fineTime << ", edge:" << edge << ", coarseTime:" << coarseTime - << ", fullTime:" << fixed << GetFullTime(tdcId, chNum, curEpochCounter, coarseTime, fineTime); - //fNofDoubleHits++; - continue; - } - if (chNum%2 == 1) { // leading edge - if (chNum == prevChNum[prevCounter]) { - prevCounter++; - } - prevChNum[prevCounter] = chNum; -/* (FU) not used - prevEpochCounter[prevCounter] = curEpochCounter; - prevCoarseTime[prevCounter] = coarseTime; - prevFineTime[prevCounter] = fineTime; -*/ - } else { // trailing edge - //prevNof = prevCounter; - prevCounter = 0; - if (chNum == prevChNum[prevCounter]) { - prevCounter++; - } - if (chNum - prevChNum[prevCounter] == 1) { - /* - new( (*fTrbRaw)[fTrbRaw->GetEntriesFast()] ) - CbmTrbRawHit(trbId, tdcId, prevChNum[prevCounter], - prevEpochCounter[prevCounter], prevCoarseTime[prevCounter], - prevFineTime[prevCounter], chNum, curEpochCounter, - coarseTime, fineTime); - */ - prevChNum[prevCounter] = chNum; -/* (FU) not used - prevEpochCounter[prevCounter] = 0; - prevCoarseTime[prevCounter] = 0; - prevFineTime[prevCounter] = 0; -*/ - } else { - LOG(debug) << "Leading edge channel number - trailing edge channel number != 1. tdcId=" << hex << tdcId << dec << - ", chNum=" << chNum << ", prevChNum=" << prevChNum[prevCounter]; - } - } - } //isPmtTrb - }// if chNum!=0 - LOG(debug) << "TIMEDATA chNum:" << chNum << ", fineTime:" << fineTime << ", edge:" << edge << ", coarseTime:" << coarseTime - << ", fullTime:" << fixed << GetFullTime(tdcId, chNum, curEpochCounter, coarseTime, fineTime); - if (fineTime == 0x3ff) LOG(debug) << "-ERROR- Dummy fine time registered: " << fineTime; - }//if TIME DATA - - UInt_t tdcMarker = (tdcData >> 29) & 0x7; //3 bits - if (tdcMarker == 0x1) {// TDC header -/* - UInt_t randomCode = (tdcData >> 16) & 0xff; // 8bits - UInt_t errorBits = (tdcData) & 0xffff; //16 bits - printf("TDC HEADER randomCode:0x%02x, errorBits:0x%04x\n", randomCode, errorBits); -*/ - } else if (tdcMarker == 0x2) {// DEBUG -/* - UInt_t debugMode = (tdcData >> 24) & 0x1f; //5 - UInt_t debugBits = (tdcData) & 0xffffff;//24 bits - printf("DEBUG debugMode:%i, debugBits:0x%06x\n", debugMode, debugBits); -*/ - } else if (tdcMarker == 0x3){ // EPOCH counter -/* - curEpochCounter = (tdcData) & 0xfffffff; //28 bits - printf("EPOCH COUNTER epochCounter:0x%07x\n", curEpochCounter); -*/ - } - }// for loop -} - -Double_t CbmTSUnpackTrb::GetFullCoarseTime(UInt_t epoch, UShort_t coarseTime) -{ - Double_t coarseUnit = 5.; // 5 ns - Double_t epochUnit = coarseUnit * 0x800; // ~10.3 mus - - Double_t time = epoch * epochUnit + coarseTime * coarseUnit; - - return time; -} - - -Double_t CbmTSUnpackTrb::GetFullTime(UShort_t TDCid, UShort_t CH, UInt_t epoch, UShort_t coarseTime, UShort_t fineTime) -{ - Double_t coarseUnit = 5.; - Double_t epochUnit = coarseUnit * 0x800; - - Double_t time = epoch * epochUnit + coarseTime * coarseUnit - - CbmTrbCalibrator::Instance()->GetFineTimeCalibrated(TDCid, CH, fineTime); - if (CH != 0){ - if (fSynchOffsetTimeMap[TDCid] > 150) { - LOG(error) << "CbmRichTrbUnpack::GetFullTime Synch Offset > 150 ns for TDC" << TDCid; - } else { - time = time + fSynchOffsetTimeMap[TDCid]; - } - } - return time; -} - -/* -void CbmTSUnpackTrb::Register() -{ -} -*/ - - -ClassImp(CbmTSUnpackTrb) diff --git a/beamtime/cern2014/unpacker/CbmTSUnpackTrb.h b/beamtime/cern2014/unpacker/CbmTSUnpackTrb.h deleted file mode 100644 index f889f55e9962ea5b2d2d2cccb303dd2c13c5be12..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/unpacker/CbmTSUnpackTrb.h +++ /dev/null @@ -1,83 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmTSUnpackTrb ----- -// ----- Created 22.11.2014 by F. Uhlig ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CBMTSUNPACKTRB_H -#define CBMTSUNPACKTRB_H - -#include "Timeslice.hpp" -#include "Message.hpp" -#include "TrbBridge.hpp" - -#include "CbmTSUnpack.h" -#include "CbmBeamDefaults.h" -#include "CbmTrbRawMessage.h" - -#include "TClonesArray.h" - -#include <map> -#include <list> -#include <vector> - -class CbmRawSubEvent; -class CbmRawEvent; -class CbmRawSubEvent; -class CbmTrbIterator; - -class CbmTSUnpackTrb : public CbmTSUnpack -{ - public: - - CbmTSUnpackTrb(); - virtual ~CbmTSUnpackTrb(); - - virtual Bool_t Init(); - - virtual Bool_t DoUnpack(const fles::Timeslice& ts, size_t component); - - virtual void Reset(); - - virtual void Finish(); - - void SetParContainers() {;} - - virtual void FillOutput(boost::any){;} - - private: - - TClonesArray* fTrbRaw; - TrbBridge* fTrbBridge; - std::list<std::vector<uint32_t>> fTrbEventList; - std::vector<uint32_t> fData; - size_t fDataSize; - - Double_t fSynchRefTime; // Reference time for synchronization - std::map<UInt_t, Double_t> fSynchOffsetTimeMap; // first - TDCId, second - time offeset in ns - CbmTrbIterator* fTrbIter; //! - CbmRawEvent* fRawEvent; //! - CbmRawSubEvent* fRawSubEvent; //! - Int_t fLink; - std::map<Int_t, Int_t> fEpochMarker; - - /** Buffer management **/ - std::multimap<Double_t, CbmTrbRawMessage*> fTimeBuffer; - - - void LoopOverTrbEvents(); - void UnpackTrbEvents(); - void ProcessTdc(CbmRawSubEvent* rawSubEvent); - void DecodeTdcData(UInt_t* data, UInt_t size, UInt_t trbId, UInt_t tdcId); - void DecodeTdcDataNew(UInt_t* data, UInt_t length, UInt_t tdcId); - Double_t GetFullCoarseTime(UInt_t epoch, UShort_t coarseTime); - Double_t GetFullTime(UShort_t TDC, UShort_t CH, UInt_t epoch, UShort_t coarseTime, UShort_t fineTime); - - CbmTSUnpackTrb(const CbmTSUnpackTrb&); - CbmTSUnpackTrb operator=(const CbmTSUnpackTrb&); - - ClassDef(CbmTSUnpackTrb, 1) -}; - -#endif diff --git a/beamtime/cern2014/unpacker/CbmTSUnpackTrb2.cxx b/beamtime/cern2014/unpacker/CbmTSUnpackTrb2.cxx deleted file mode 100644 index 9b5d8e1a0500113fe0c621d2b8f901118d870508..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/unpacker/CbmTSUnpackTrb2.cxx +++ /dev/null @@ -1,306 +0,0 @@ -/* - * CbmTSUnpackTrb2.cxx - * - * Created on: Mar 24, 2015 - * Author: evovch - */ - -#include "CbmTSUnpackTrb2.h" - -#include <TClonesArray.h> - -#include "FairLogger.h" -#include "FairRootManager.h" - -#include "CbmTrbIterator.h" -#include "CbmTrbCalibrator.h" -#include "CbmRichTrbParam.h" - -#include "CbmRawEvent.h" -#include "CbmRawSubEvent.h" -#include "CbmTrbRawMessage.h" - -// Uncoment if you want to have excessive printout (do not execute on many events, may produce Gb's of output) -//#define DEBUGPRINT - -CbmTSUnpackTrb2::CbmTSUnpackTrb2() : - CbmTSUnpack(), - fLink(0), - fTrbBridge(new TrbBridge()), - fTrbEventList(), - fData(), - fDataSize(0), - fTrbIter(NULL), - fRawEvent(NULL), - fRawSubEvent(NULL), - fTimestampsUnpacked(0), - fTrbRawHits(new TClonesArray("CbmTrbRawMessage", 10)), - - fLastSyncTime(0.), - fMainSyncTime(0.), - fCorr(0.), - fMainSyncDefined(kFALSE), - - startTime(0.), - startTimeKnown(kFALSE), - hitDistrInTime(new TH1D("hitDistrInTime", "hitDistrInTime", 1200, 0., 120.)), - hitDistrInTimeOneSpill(new TH1D("hitDistrInTimeOneSpill", "hitDistrInTimeOneSpill", 5000, 3., 5.)) - -{ - -} - -CbmTSUnpackTrb2::~CbmTSUnpackTrb2() -{ - -} - -Bool_t CbmTSUnpackTrb2::Init() -{ - LOG(debug) << "Initializing"; - - FairRootManager* ioman = FairRootManager::Instance(); - if (ioman == NULL) { - LOG(fatal) << "No FairRootManager instance"; - } - ioman->Register("CbmTrbRawMessage", "TRB raw messages", fTrbRawHits, kTRUE); - - return kTRUE; -} - -Bool_t CbmTSUnpackTrb2::DoUnpack(const fles::Timeslice& ts, size_t component) -{ - //LOG(info) << "Unpacking Trb Data"; - //LOG(info) << "--- Number of microslices: " << ts.num_microslices(component); - - fLink = ts.descriptor(component, 0).eq_id; - - Int_t skipMS = 1; //TODO: should be set from macro according to the flib settings - fTrbEventList = fTrbBridge->extractEventsFromTimeslice(ts, skipMS); - - LOG(debug) << "Found " << fTrbEventList.size() << " TRB events in time slice"; - - // Loop over all TRB events which are in the timeslice - while ( !fTrbEventList.empty() ) { - fData = fTrbEventList.front(); - fDataSize = fData.size(); - UnpackTrbEvents(); - fTrbEventList.pop_front(); - } - - return kTRUE; -} - -void CbmTSUnpackTrb2::UnpackTrbEvents() -{ - fTrbIter = new CbmTrbIterator(static_cast<void*>(fData.data()), fDataSize); - - // Loop over TRB events - while (true) { - - // Try to extract next event from the Iterator. If no events left - go out of the loop - fRawEvent = fTrbIter->NextEvent(); - if (fRawEvent == NULL) break; -#ifdef DEBUGPRINT - //if(gLogger->IsLogNeeded( fair::Severity::debug )) - { - fRawEvent->Print(); - } -#endif - -// fSynchRefTime = -1.; - - // Loop over TRB subevents - while (true){ - fRawSubEvent = fTrbIter->NextSubEvent(); - if (fRawSubEvent == NULL) break; -#ifdef DEBUGPRINT - if(gLogger->IsLogNeeded( fair::Severity::debug )) { - fRawSubEvent->Print(); - } -#endif - ProcessSubEvent(fRawSubEvent); - } - - } -} - -void CbmTSUnpackTrb2::Reset() -{ - fTrbRawHits->Clear(); -} - -void CbmTSUnpackTrb2::Finish() -{ - LOG(info) << "CbmTSUnpackTrb2::Finish"; -} - -void CbmTSUnpackTrb2::ProcessSubEvent(CbmRawSubEvent* subEvent) { - UInt_t tdcDataIndex = 0; - UInt_t tdcData = 0x0; - UInt_t subEventId = subEvent->SubId(); - - fLastSyncTime = 0.; - fMainSyncTime = 0.; - fCorr = 0.; - fMainSyncDefined = kFALSE; - - // Loop over subsubevents - while (true) { - tdcData = subEvent->SubDataValue(tdcDataIndex); - UInt_t tdcNofWords = (tdcData >> 16) & 0xffff; - UInt_t subSubEventId = tdcData & 0xffff; -#ifdef DEBUGPRINT - printf("%08x - SUBSUBEVENT HEADER tdcNofWords = %i, ID = 0x%04x\n", tdcData, tdcNofWords, subSubEventId); -#endif - - if (subSubEventId == 0x7000 || subSubEventId == 0x7001 || subSubEventId == 0x7002 || subSubEventId == 0x7003) { - tdcDataIndex++; - continue; - } - - // read TDC words to array - UInt_t dataArray[tdcNofWords]; - for (UInt_t i = 0; i < tdcNofWords; i++) { - tdcDataIndex++; - tdcData = subEvent->SubDataValue(tdcDataIndex); - dataArray[i] = tdcData; - } - - if (subSubEventId == 0x5555) { - ProcessSkip(dataArray, tdcNofWords, subSubEventId); - break; - } - - if (subSubEventId != 0x7005 && subSubEventId != 0x0112) { - ProcessSubSubEvent(dataArray, tdcNofWords, subSubEventId); - } else { - ProcessSkip(dataArray, tdcNofWords, subSubEventId); - } - - tdcDataIndex++; - } - -} - -void CbmTSUnpackTrb2::ProcessSkip(UInt_t* data, UInt_t size, UInt_t subEventId) -{ -#ifdef DEBUGPRINT - for (UInt_t i=0; i<size; i++) { - //printf ("%08x - skip\n", data[i]); - } -#endif -} - -void CbmTSUnpackTrb2::ProcessSubSubEvent(UInt_t* data, UInt_t size, UInt_t subEventId) { - CbmRichTrbParam* param = CbmRichTrbParam::Instance(); - - UInt_t tdcId = subEventId; - - UInt_t curEpochCounter = 0; - - for (UInt_t i = 0; i < size; i++) { - UInt_t tdcData = data[i]; - UInt_t tdcTimeDataMarker = (tdcData >> 31) & 0x1; - - if (tdcTimeDataMarker == 0x1) // TIME DATA - { -#ifdef DEBUGPRINT - printf("%08x - TIMESTAMP", tdcData); -#endif - fTimestampsUnpacked++; - - UInt_t channel = (tdcData >> 22) & 0x7f; - UInt_t fine = (tdcData >> 12) & 0x3ff; - UInt_t edge = (tdcData >> 11) & 0x1; - UInt_t coarse = (tdcData) & 0x7ff; - UInt_t epoch = curEpochCounter; - - if (param->IsSyncChannel(channel)) { // SYNC MESSAGE PROCESSING - //CbmTrbCalibrator::Instance()->AddFineTime(tdcId, channel, fine); //TODO check - needed or not? - - // Between-TDC synchronization - fLastSyncTime = GetFullTime(tdcId, channel, epoch, coarse, fine); - if (!fMainSyncDefined) { - fMainSyncDefined = kTRUE; - fMainSyncTime = GetFullTime(tdcId, channel, epoch, coarse, fine); - } - fCorr = fMainSyncTime-fLastSyncTime; - -#ifdef DEBUGPRINT - printf(" --- SYNC - tdc 0x%04x ch %d edge %d epoch %08x coarse %08x fine %08x = %f\tcorrection=%f\n", - tdcId, channel, edge, epoch, coarse, fine, GetFullTime(tdcId, channel, epoch, coarse, fine)+fCorr, fCorr); -#endif - } else if (param->IsLeadingEdgeChannel(channel)) { // LEADING EDGE PROCESSING - CbmTrbCalibrator::Instance()->AddFineTime(tdcId, channel, fine); -#ifdef DEBUGPRINT - printf(" --- LEAD - tdc 0x%04x ch %d edge %d epoch %08x coarse %08x fine %08x = %f\tcorrection=%f\n", - tdcId, channel, edge, epoch, coarse, fine, GetFullTime(tdcId, channel, epoch, coarse, fine)+fCorr, fCorr); -#endif - Double_t ftime = GetFullTime(tdcId, channel, epoch, coarse, fine)+fCorr; - - if (!startTimeKnown) { startTime = ftime; startTimeKnown = kTRUE; } - - hitDistrInTime->Fill((ftime - startTime) / 1000000000); - if ((ftime - startTime)/1000000000 > 3. && (ftime - startTime)/1000000000 < 5.) { - hitDistrInTimeOneSpill->Fill((ftime - startTime)/1000000000); - } - - //if (tdcId == 0x0110 && channel == 7) printf (" LED pulse\n"); - - } else { // TRAILING EDGE PROCESSING - CbmTrbCalibrator::Instance()->AddFineTime(tdcId, channel, fine); -#ifdef DEBUGPRINT - printf(" --- TRAIL - tdc 0x%04x ch %d edge %d epoch %08x coarse %08x fine %08x = %f\tcorrection=%f\n", - tdcId, channel, edge, epoch, coarse, fine, GetFullTime(tdcId, channel, epoch, coarse, fine)+fCorr, fCorr); -#endif - - Double_t ftime = GetFullTime(tdcId, channel, epoch, coarse, fine)+fCorr; - - hitDistrInTime->Fill((ftime - startTime) / 1000000000); - if ((ftime - startTime)/1000000000 > 3. && (ftime - startTime)/1000000000 < 5.) { - hitDistrInTimeOneSpill->Fill((ftime - startTime)/1000000000); - } - - } - - // Important to keep it here - after fCorr computation - new ((*fTrbRawHits)[fTrbRawHits->GetEntriesFast()]) CbmTrbRawMessage( - 0, tdcId, channel, epoch, coarse, fine, edge, fCorr); - - } // if TIME DATA - - UInt_t tdcMarker = (tdcData >> 29) & 0x7; //3 bits - if (tdcMarker == 0x1) { // TDC header - UInt_t randomCode = (tdcData >> 16) & 0xff; // 8bits - UInt_t errorBits = (tdcData) & 0xffff; //16 bits -#ifdef DEBUGPRINT - printf("%08x - TDC HEADER randomCode:0x%02x, errorBits:0x%04x\n", tdcData, randomCode, errorBits); -#endif - } else if (tdcMarker == 0x2) { // DEBUG - UInt_t debugMode = (tdcData >> 24) & 0x1f; //5 bits - UInt_t debugBits = (tdcData) & 0xffffff; //24 bits -#ifdef DEBUGPRINT - printf("%08x - DEBUG debugMode:%i, debugBits:0x%06x\n", tdcData, debugMode, debugBits); -#endif - } else if (tdcMarker == 0x3) { // EPOCH counter - curEpochCounter = (tdcData) & 0xfffffff; //28 bits -#ifdef DEBUGPRINT -// printf("%08x - EPOCH COUNTER epochCounter:0x%07x\n", tdcData, curEpochCounter); -#endif - } else { -#ifdef DEBUGPRINT - if (tdcTimeDataMarker != 0x1) printf("%08x\n", tdcData); -#endif - } - - } // for loop - -} - -Double_t CbmTSUnpackTrb2::GetFullTime(UInt_t tdcId, UInt_t channel, UInt_t epoch, UInt_t coarse, UInt_t fine) -{ - return CbmTrbCalibrator::Instance()->GetFullTime(tdcId, channel, epoch, coarse, fine); -} - -ClassImp(CbmTSUnpackTrb2) diff --git a/beamtime/cern2014/unpacker/CbmTSUnpackTrb2.h b/beamtime/cern2014/unpacker/CbmTSUnpackTrb2.h deleted file mode 100644 index be99198671ecc48d98d1b7c3cb9be26018d0fd8c..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/unpacker/CbmTSUnpackTrb2.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * CbmTSUnpackTrb2.h - * - * Created on: Mar 24, 2015 - * Author: evovch - */ - -#ifndef FLES_READER_UNPACKER_CBMTSUNPACKTRB2_H_ -#define FLES_READER_UNPACKER_CBMTSUNPACKTRB2_H_ - -#include "CbmTSUnpack.h" - -#include "TH1.h" - -#include "Timeslice.hpp" -#include "Message.hpp" -#include "TrbBridge.hpp" - -class CbmTrbIterator; -class CbmRawEvent; -class CbmRawSubEvent; - -class CbmTSUnpackTrb2: public CbmTSUnpack { -public: - CbmTSUnpackTrb2(); - virtual ~CbmTSUnpackTrb2(); - - virtual Bool_t Init(); - - virtual Bool_t DoUnpack(const fles::Timeslice& ts, size_t component); - - void UnpackTrbEvents(); - - virtual void Reset(); - - virtual void Finish(); - -private: - - Int_t fLink; - - TrbBridge* fTrbBridge; - std::list<std::vector<uint32_t>> fTrbEventList; - std::vector<uint32_t> fData; - size_t fDataSize; - - CbmTrbIterator* fTrbIter; //! - CbmRawEvent* fRawEvent; //! - CbmRawSubEvent* fRawSubEvent; //! - - //Between-TDC synchronization - Double_t fLastSyncTime; - Double_t fMainSyncTime; - Double_t fCorr; - Bool_t fMainSyncDefined; - - // Histo for many-seconds hit distribution in time - TH1D* hitDistrInTime; - TH1D* hitDistrInTimeOneSpill; - Double_t startTime; - Bool_t startTimeKnown; - - // Output raw hits - TClonesArray* fTrbRawHits; - - // Counter of timestamps being unpacked - UInt_t fTimestampsUnpacked; - - void ProcessSubEvent(CbmRawSubEvent* subEvent); - void ProcessSubSubEvent(UInt_t* data, UInt_t size, UInt_t subEventId); - void ProcessSkip(UInt_t* data, UInt_t size, UInt_t subEventId); - - Double_t GetFullTime(UInt_t tdcId, UInt_t channel, UInt_t epoch, UInt_t coarse, UInt_t fine); - - ClassDef(CbmTSUnpackTrb2, 1) -}; - -#endif /* FLES_READER_UNPACKER_CBMTSUNPACKTRB2_H_ */ diff --git a/beamtime/cern2014/unpacker/Support.hpp b/beamtime/cern2014/unpacker/Support.hpp deleted file mode 100644 index 61fbd19c11d59b18e7557b49c47265bd970aea27..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/unpacker/Support.hpp +++ /dev/null @@ -1,126 +0,0 @@ -#ifndef SUPPORT_HPP -#define SUPPORT_HPP - -#include <string> -//#include <cstdio> -#include <iostream> - -std::string GetBinaryRepresentation(size_t const size, uint8_t const * const ptr) -{ - std::string outString; - - unsigned char *b = (unsigned char*) ptr; - unsigned char byte; - - char cStr[2]; - cStr[1] = '\0'; - - for (int i=size-1; i>=0; i--) { - for (int j=7; j>=0; j--) { - byte = (b[i] >> j) & 1; - sprintf(cStr, "%u", byte); - outString.append(cStr); - } - } - - return outString; -} - -/** - * size in bytes - */ -std::string GetHexRepresentation(size_t const size, uint8_t const * const ptr) -{ - std::string outString; - - unsigned char *b = (unsigned char*) ptr; - unsigned char byte; - - char cStr[3]; - cStr[2] = '\0'; - - for (int i=size-1; i>=0; i--) { - byte = b[i] & 0xff; - sprintf(cStr, "%02x", byte); - outString.append(cStr); - } - - return outString; -} - -std::string GetWordHexRepr(uint8_t const * const ptr) -{ - std::string outString; - - unsigned char *b = (unsigned char*) ptr; - unsigned char byte[4]; - byte[0] = b[3] & 0xff; - byte[1] = b[2] & 0xff; - byte[2] = b[1] & 0xff; - byte[3] = b[0] & 0xff; - - char cStr[10]; - cStr[9] = '\0'; - - sprintf(cStr, "%02x%02x %02x%02x", byte[0], byte[1], byte[2], byte[3]); - - outString.append(cStr); - - return outString; -} - -std::string GetWordHexReprInv(uint8_t const * const ptr) -{ - std::string outString; - - unsigned char *b = (unsigned char*) ptr; - unsigned char byte[4]; - byte[0] = b[0] & 0xff; - byte[1] = b[1] & 0xff; - byte[2] = b[2] & 0xff; - byte[3] = b[3] & 0xff; - - char cStr[10]; - cStr[9] = '\0'; - - sprintf(cStr, "%02x%02x %02x%02x", byte[0], byte[1], byte[2], byte[3]); - - outString.append(cStr); - - return outString; -} - -void SwapBytes(size_t const /*size*/, uint8_t const * ptr) -{ - unsigned char *b = (unsigned char*) ptr; - unsigned char byte[4]; - byte[0] = b[3] & 0xff; - byte[1] = b[2] & 0xff; - byte[2] = b[1] & 0xff; - byte[3] = b[0] & 0xff; - - b[0] = byte[0]; - b[1] = byte[1]; - b[2] = byte[2]; - b[3] = byte[3]; -} - -void PrintRaw(size_t const size, uint8_t const * const ptr) -{ - size_t nWords = size/4; - // size_t nRestBytes = size%4; (VF) not used - - for (size_t iWord=0; iWord<nWords; iWord++) { - //std::cout << GetHexRepresentation(4, ptr+iWord*4) << " "; - - std::cout << GetWordHexReprInv(ptr+iWord*4) << " "; - } - /*if (nRestBytes > 0) { - std::cout << GetHexRepresentation(nRestBytes, ptr+nWords*4) << " " << std::endl; - } else { - std::cout << std::endl; - }*/ - std::cout << std::endl; -} - -#endif // SUPPORT_HPP diff --git a/beamtime/cern2014/unpacker/TimesliceReader.cpp b/beamtime/cern2014/unpacker/TimesliceReader.cpp deleted file mode 100644 index 4aedb253ecf6392035b40213c7cb4dd8d2a62ae3..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/unpacker/TimesliceReader.cpp +++ /dev/null @@ -1,64 +0,0 @@ -//! \author Michael Krieger - -#include "TimesliceReader.hpp" -#include <unordered_map> - -namespace spadic { - -struct TimesliceReader::TimesliceReader_ { - std::unordered_map<uint16_t, spadic::MessageReader> _readers; - //< one MessageReader per CBMnet source address - - TimesliceReader_() : _readers{} {} - - void add_mc(const flib_dpb::MicrosliceContents& mc) - { - for (auto& dtm : mc.dtms()) { - // TODO distinguish same source address from different components - auto& reader = _readers[dtm.addr]; - reader.add_buffer(dtm.data, dtm.size); - } - } -}; - -TimesliceReader::TimesliceReader() : _t {new TimesliceReader_} {} -TimesliceReader::~TimesliceReader() {} - -void TimesliceReader::add_timeslice(const fles::Timeslice& ts) -{ - for (size_t c {0}; c < ts.num_components(); c++) { - add_component(ts, c); - } -} - -void TimesliceReader::add_component(const fles::Timeslice& ts, size_t component) -{ - for (size_t m {0}; m < ts.num_core_microslices(); m++) { // num_microslices includes the overlapping slices, while num_core_microslices -- num_microslices needs "component" - auto& desc = ts.descriptor(component, m); - auto *content = ts.content(component, m); - - // interpret raw bytes as 16-bit unsigned integers, assuming the - // native byte order is correct - auto p = reinterpret_cast<const uint16_t *>(content); - auto s = desc.size * sizeof(*content) / sizeof(*p); - _t->add_mc({p, s}); - } -} - -std::unordered_set<uint16_t> TimesliceReader::sources() const -{ - std::unordered_set<uint16_t> result; - for (auto& item : _t->_readers) { - auto addr = item.first; - result.insert(addr); - } - return result; -} - -std::unique_ptr<spadic::Message> -TimesliceReader::get_message(uint16_t source_addr) const -{ - return _t->_readers[source_addr].get_message(); -} - -} // namespace diff --git a/beamtime/cern2014/unpacker/TimesliceReader.hpp b/beamtime/cern2014/unpacker/TimesliceReader.hpp deleted file mode 100644 index c53af7273333a4b88fbdce1d172ebac9710487d6..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/unpacker/TimesliceReader.hpp +++ /dev/null @@ -1,35 +0,0 @@ -//! \author Michael Krieger - -/** - * Read SPADIC Messages out of Timeslices containing Microslices using the - * "packed DTM" format. - */ - -#ifndef SPADIC_TIMESLICE_READER -#define SPADIC_TIMESLICE_READER - -#include "Message.hpp" -#include "Timeslice.hpp" -#include "MicrosliceContents.hpp" -#include <unordered_set> - -namespace spadic { - -struct TimesliceReader -{ - TimesliceReader(); - ~TimesliceReader(); - - void add_timeslice(const fles::Timeslice& ts); - void add_component(const fles::Timeslice& ts, size_t component); - std::unordered_set<uint16_t> sources() const; - std::unique_ptr<spadic::Message> get_message(uint16_t source_addr) const; - -private: - struct TimesliceReader_; - std::unique_ptr<TimesliceReader_> _t; -}; - -} // namespace - -#endif diff --git a/beamtime/cern2014/unpacker/TimesliceReader20.cpp b/beamtime/cern2014/unpacker/TimesliceReader20.cpp deleted file mode 100644 index 60e647c9b05a796bcbceb6350d7c27c7f212d8f4..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/unpacker/TimesliceReader20.cpp +++ /dev/null @@ -1,96 +0,0 @@ -// Author Cruz Garcia -// Based on TimesliceReader.* from Michael Krieger -// ------------------------------------------------------- -// Use this implementation at your discretion. This is -// a temporal implementation of a the DPB ID until it is -// included in the microslice header. -// Developed for the DESY 2017 testbeam -// ------------------------------------------------------- - -#include "TimesliceReader20.hpp" -#include <unordered_map> - -namespace spadic { - -struct TimesliceReader20::TimesliceReader20_ { - - std::unordered_map<uint16_t, spadic::MessageReader> _readers; - std::unordered_map<uint16_t, uint16_t> _eLinkSources; // <source addr, link> - - TimesliceReader20_() : _readers{},_eLinkSources{} {} - - // Microslice contents are different, thereofre use another implementation - void add_mc(const flib_dpb_20::MicrosliceContents20& mc) - { - for (auto& dtm : mc.dtms()) { - - // printf("DTM Addr: %04x Link: %04x Size: %04x Payload: %04x\n", dtm.addr, dtm.link, dtm.size, *dtm.data); - // TODO distinguish same source address from different components - //auto& reader = _readers[dtm.addr]; - //auto& reader = _readers[dtm.link]; // Add by the eLink?? - - // Not the most elegant way of givin a reader addr, but - // ok for now - - // Formwer way - //auto id = dtm.addr; - //auto id = dtm.addr + dtm.link; - // Proposed for DESY - auto id = ((dtm.addr & 0xff) << 8) + ((dtm.link & 0xff00) >> 8); - - auto& reader = _readers[id]; - reader.add_buffer(dtm.data, dtm.size); - _eLinkSources[id] = dtm.link; - } - } -}; - -TimesliceReader20::TimesliceReader20() : _t {new TimesliceReader20_} {} -TimesliceReader20::~TimesliceReader20() {} - -void TimesliceReader20::add_timeslice(const fles::Timeslice& ts) -{ - for (size_t c {0}; c < ts.num_components(); c++) { - add_component(ts, c); - } -} - -void TimesliceReader20::add_component(const fles::Timeslice& ts, size_t component) -{ - //printf("***Component: %x Link: %x\n", component, ts.descriptor(component, 0).eq_id); - - for (size_t m {0}; m < ts.num_core_microslices(); m++) { // num_microslices includes the overlapping slices, while num_core_microslices -- num_microslices needs "component" - - auto& desc = ts.descriptor(component, m); - auto *content = ts.content(component, m); - - // interpret raw bytes as 16-bit unsigned integers, assuming the - // native byte order is correct - auto p = reinterpret_cast<const uint16_t *>(content); - auto s = desc.size * sizeof(*content) / sizeof(*p); - - _t->add_mc({p, s}); - } -} - -std::unordered_set<uint16_t> TimesliceReader20::sources() const -{ - std::unordered_set<uint16_t> result; - for (auto& item : _t->_readers) { - auto addr = item.first; - result.insert(addr); - } - return result; -} - -std::unique_ptr<spadic::Message> TimesliceReader20::get_message(uint16_t source_addr) const -{ - return _t->_readers[source_addr].get_message(); -} - -uint16_t TimesliceReader20::get_link(uint16_t source_addr) const -{ - return _t->_eLinkSources[source_addr]; -} - -} // namespace diff --git a/beamtime/cern2014/unpacker/TimesliceReader20.hpp b/beamtime/cern2014/unpacker/TimesliceReader20.hpp deleted file mode 100644 index 19505c2018fb18f4080bbfee805d9defa0cc5ff7..0000000000000000000000000000000000000000 --- a/beamtime/cern2014/unpacker/TimesliceReader20.hpp +++ /dev/null @@ -1,36 +0,0 @@ -//! \author Michael Krieger - -/** - * Read SPADIC Messages out of Timeslices containing Microslices using the - * "packed DTM" format. - */ - -#ifndef SPADIC_TIMESLICE_READER -#define SPADIC_TIMESLICE_READER - -#include "Message.hpp" -#include "Timeslice.hpp" -#include "MicrosliceContents20.hpp" -#include <unordered_set> - -namespace spadic { - -struct TimesliceReader20 -{ - TimesliceReader20(); - ~TimesliceReader20(); - - void add_timeslice(const fles::Timeslice& ts); - void add_component(const fles::Timeslice& ts, size_t component); - std::unordered_set<uint16_t> sources() const; - std::unique_ptr<spadic::Message> get_message(uint16_t source_addr) const; - uint16_t get_link(uint16_t source_addr) const; - -private: - struct TimesliceReader20_; - std::unique_ptr<TimesliceReader20_> _t; -}; - -} // namespace - -#endif diff --git a/beamtime/cern2016/CMakeLists.txt b/beamtime/cern2016/CMakeLists.txt deleted file mode 100644 index 7bf0c0f6a681edaac02876c0f549d452fd476491..0000000000000000000000000000000000000000 --- a/beamtime/cern2016/CMakeLists.txt +++ /dev/null @@ -1,72 +0,0 @@ -# Create a library called "libCbmFlibReader" which includes the source files given in -# the array . -# The extension is already found. Any number of sources could be listed here. - -Set(INCLUDE_DIRECTORIES - ${CBMBASE_DIR} - - ${CBMDATA_DIR} - ${CBMDATA_DIR}/tof - ${CBMDATA_DIR}/much - - ${CBMROOT_SOURCE_DIR}/beamtime/base - ${CBMROOT_SOURCE_DIR}/beamtime/param - ${CBMROOT_SOURCE_DIR}/beamtime/data/fhodo - ${CBMROOT_SOURCE_DIR}/beamtime/data/raw - ${CBMROOT_SOURCE_DIR}/beamtime/data - - ${CBMROOT_SOURCE_DIR}/fles/flestools - - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/unpacker - ${CMAKE_CURRENT_SOURCE_DIR}/param -) - -Set(SYSTEM_INCLUDE_DIRECTORIES - ${BASE_INCLUDE_DIRECTORIES} - ${Boost_INCLUDE_DIR} - ${ROOT_INCLUDE_DIR} - ${IPC_INCLUDE_DIRECTORY} - ${CBMROOT_SOURCE_DIR}/external/flib_dpb/flib_dpb - ${CMAKE_SOURCE_DIR}/external/cppzmq -) - -Include_Directories(${INCLUDE_DIRECTORIES}) -Include_Directories(SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES}) - - -Set(LINK_DIRECTORIES - ${ROOT_LIBRARY_DIR} - ${FAIRROOT_LIBRARY_DIR} - ${Boost_LIBRARY_DIRS} -) - -Link_Directories( - ${LINK_DIRECTORIES} -) - -Set(SRCS -# CbmFlibTestSource.cxx - CbmFlibCern2016Source.cxx - - unpacker/CbmTSUnpackFHodo.cxx - unpacker/CbmTSUnpackMuch.cxx - unpacker/CbmTSUnpackTof.cxx - - unpacker/CbmTSMonitorTofLegacy.cxx - unpacker/CbmTSMonitorTof.cxx - unpacker/CbmTSMonitorMuch.cxx -) - -If(_UINT8_T_EXIST) - Add_Definitions(-DHAVE_UINT8_T_HEADER_FILE) - Set(DEFINITIONS HAVE_UINT8_T_HEADER_FILE) -EndIf() - -Set(LINKDEF CbmBeamtimeCern2016LinkDef.h ) -Set(LIBRARY_NAME CbmBeamtimeCern2016) -Set(DEPENDENCIES - CbmFlibFlesTools CbmBase CbmBeamtimeBase CbmBeamtimeData CbmBeamtimeParam fles_ipc Eve Base -) - -GENERATE_LIBRARY() diff --git a/beamtime/cern2016/CbmBeamtimeCern2016LinkDef.h b/beamtime/cern2016/CbmBeamtimeCern2016LinkDef.h deleted file mode 100644 index 56334dd7a9e05c121ce577485cdd8510d1043142..0000000000000000000000000000000000000000 --- a/beamtime/cern2016/CbmBeamtimeCern2016LinkDef.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifdef __CINT__ - -#pragma link off all globals; -#pragma link off all classes; -#pragma link off all functions; - -#pragma link C++ class CbmFlibCern2016Source; -#pragma link C++ class CbmTSUnpackFHodo; -#pragma link C++ class CbmTSUnpackTof; -#pragma link C++ class CbmTSUnpackMuch; -#pragma link C++ class CbmTSMonitorTofLegacy; -#pragma link C++ class CbmTSMonitorTof; -#pragma link C++ class CbmTSMonitorMuch; - -#endif diff --git a/beamtime/cern2016/CbmFlibCern2016Source.cxx b/beamtime/cern2016/CbmFlibCern2016Source.cxx deleted file mode 100644 index 7eb3a15ffe7edcbd29b7c98f15fa12c7df7046cc..0000000000000000000000000000000000000000 --- a/beamtime/cern2016/CbmFlibCern2016Source.cxx +++ /dev/null @@ -1,361 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmFlibCern2016Source ----- -// ----- Created 20.06.2016 by F. Uhlig ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#include "CbmFlibCern2016Source.h" - -#include "CbmTbDaqBuffer.h" - -#include "TimesliceInputArchive.hpp" -#include "Timeslice.hpp" -#include "TimesliceSubscriber.hpp" -#include "MicrosliceContents.hpp" - -#include "FairLogger.h" -#include "FairRunOnline.h" - -#include "TH1.h" -#include "THttpServer.h" - -#include <iostream> -#include <fstream> -#include <iomanip> - -CbmFlibCern2016Source::CbmFlibCern2016Source() - : FairSource(), - fFileName(""), - fInputFileList(new TObjString()), - fFileCounter(0), - fHost("localhost"), - fPort(5556), - fUnpackers(), - fDetectorSystemMap(), - fBuffer(CbmTbDaqBuffer::Instance()), - fTSNumber(0), - fTSCounter(0), - fTimer(), - fBufferFillNeeded(kTRUE), - fHistoMissedTS(NULL), - fNofTSSinceLastTS(0), - fuTsReduction(1), - fSource(NULL) -{ -} - -CbmFlibCern2016Source::CbmFlibCern2016Source(const CbmFlibCern2016Source& source) - : FairSource(source), - fFileName(""), - fInputFileList(), - fFileCounter(0), - fHost("localhost"), - fPort(5556), - fUnpackers(), - fDetectorSystemMap(), - fBuffer(CbmTbDaqBuffer::Instance()), - fTSNumber(0), - fTSCounter(0), - fTimer(), - fBufferFillNeeded(kTRUE), - fHistoMissedTS(NULL), - fNofTSSinceLastTS(0), - fuTsReduction(1), - fSource(NULL) -{ -} - -CbmFlibCern2016Source::~CbmFlibCern2016Source() -{ -} - -Bool_t CbmFlibCern2016Source::Init() -{ - if ( 0 == fFileName.Length() && 0 == fInputFileList.GetSize()) { - TString connector = Form("tcp://%s:%i", fHost.Data(), fPort); - LOG(info) << "Open TSPublisher at " << connector; - fInputFileList.Add(new TObjString(connector)); - fSource = new fles::TimesliceSubscriber(connector.Data()); - if ( !fSource) { - LOG(fatal) << "Could not connect to publisher."; - } - } else { -/* - // --- Open input file - TObjString* tmp = - dynamic_cast<TObjString*>(fInputFileList.At(fFileCounter)); - fFileName = tmp->GetString(); - - LOG(info) << "Open the Flib input file " << fFileName; - // Check if the input file exist - FILE* inputFile = fopen(fFileName.Data(), "r"); - if ( ! inputFile ) { - LOG(fatal) << "Input file " << fFileName << " doesn't exist."; - } - fclose(inputFile); - fSource = new fles::TimesliceInputArchive(fFileName.Data()); - if ( !fSource) { - LOG(fatal) << "Could not open input file."; - } -*/ - if( kFALSE == OpenNextFile() ) - { - LOG(error) << "Could not open the first file in the list, Doing nothing!"; - return kFALSE; - } // if( kFALSE == OpenNextFile() ) - } - - for (auto it=fUnpackers.begin(); it!=fUnpackers.end(); ++it) { - LOG(info) << "Initialize " << it->second->GetName() << - " for systemID 0x" << std::hex << it->first << std::dec; - it->second->Init(); - // it->second->Register(); - } - - THttpServer* server = FairRunOnline::Instance()->GetHttpServer(); -// server->SetJSROOT("https://root.cern.ch/js/latest"); - - fHistoMissedTS = new TH1I("Missed_TS", "Missed TS", 2, 0., 2.); - - if (server) - server->Register("/TofRaw", fHistoMissedTS); - - - return kTRUE; -} - -void CbmFlibCern2016Source::SetParUnpackers() -{ - for (auto it=fUnpackers.begin(); it!=fUnpackers.end(); ++it) { - LOG(info) << "Set parameter container " << it->second->GetName() << - " for systemID 0x" << std::hex << it->first << std::dec; - it->second->SetParContainers(); - } - -} - -Bool_t CbmFlibCern2016Source::InitUnpackers() -{ - Bool_t result = kTRUE; - for (auto it=fUnpackers.begin(); it!=fUnpackers.end(); ++it) { - LOG(info) << "Initialize parameter container " << it->second->GetName() << - " for systemID 0x" << std::hex << it->first << std::dec; - result = result && it->second->InitContainers(); - } - return result; -} - -Bool_t CbmFlibCern2016Source::ReInitUnpackers() -{ - Bool_t result = kTRUE; - for (auto it=fUnpackers.begin(); it!=fUnpackers.end(); ++it) { - LOG(info) << "Initialize parameter container " << it->second->GetName() << - " for systemID 0x" << std::hex << it->first << std::dec; - result = result && it->second->ReInitContainers(); - } - return result; -} - -Int_t CbmFlibCern2016Source::ReadEvent(UInt_t) -{ -// LOG(info); -// LOG(info) << "Before FillBuffer"; - Int_t retVal = -1; - if (fBufferFillNeeded) { - FillBuffer(); - } -// LOG(info) << "After FillBuffer"; - - retVal = GetNextEvent(); - LOG(debug) << "After GetNextEvent: " << retVal; - - Int_t bla = 0; - // If no more data and file mode, try to read next file in List - if( fSource->eos() && 0 < fFileName.Length() ) - { - fFileCounter ++; // Increment file counter to go to next item in List - bla = ( kFALSE == OpenNextFile() ? 1 : 0 ); - } // if( fSource->eos() && 0 < fFileName.Length() ) - -// Int_t bla = fSource->eos(); // no more data; trigger end of run -// LOG(info) << "After fSource->eos: " << bla; - return bla; // no more data; trigger end of run -} - -void CbmFlibCern2016Source::PrintMicroSliceDescriptor(const fles::MicrosliceDescriptor& mdsc) -{ - LOG(info) << "Header ID: Ox" << std::hex << static_cast<int>(mdsc.hdr_id) - << std::dec; - LOG(info) << "Header version: Ox" << std::hex << static_cast<int>(mdsc.hdr_ver) - << std::dec; - LOG(info) << "Equipement ID: " << mdsc.eq_id; - LOG(info) << "Flags: " << mdsc.flags; - LOG(info) << "Sys ID: Ox" << std::hex << static_cast<int>(mdsc.sys_id) - << std::dec; - LOG(info) << "Sys version: Ox" << std::hex << static_cast<int>(mdsc.sys_ver) - << std::dec; - LOG(info) << "Microslice Idx: " << mdsc.idx; - LOG(info) << "Checksum: " << mdsc.crc; - LOG(info) << "Size: " << mdsc.size; - LOG(info) << "Offset: " << mdsc.offset; -} - -Bool_t CbmFlibCern2016Source::CheckTimeslice(const fles::Timeslice& ts) -{ - if ( 0 == ts.num_components() ) { - LOG(error) << "No Component in TS " << ts.index(); - return 1; - } - LOG(info) << "Found " << ts.num_components() - << " different components in timeslice"; - return kTRUE; -} - -void CbmFlibCern2016Source::Close() -{ - for (auto it=fUnpackers.begin(); it!=fUnpackers.end(); ++it) { - LOG(info) << "Finish " << it->second->GetName() << " for systemID 0x" - << std::hex << it->first << std::dec; - it->second->Finish(); - } - fHistoMissedTS->Write(); -} - -void CbmFlibCern2016Source::Reset() -{ - for (auto it=fUnpackers.begin(); it!=fUnpackers.end(); ++it) { - it->second->Reset(); - } -} - -Int_t CbmFlibCern2016Source::FillBuffer() -{ - - while (auto timeslice = fSource->get()) { - fTSCounter++; - if ( 0 == fTSCounter%10000 ) { - LOG(info) << "Analyse Event " << fTSCounter; - } - - const fles::Timeslice& ts = *timeslice; - auto tsIndex = ts.index(); - if( (tsIndex != (fTSNumber+1)) &&( fTSNumber != 0) ) { - LOG(debug) << "Missed Timeslices. Old TS Number was " << fTSNumber - << " New TS Number is " << tsIndex; - fHistoMissedTS->Fill(1, tsIndex-fTSNumber); - fNofTSSinceLastTS=tsIndex-fTSNumber; - } else { - fHistoMissedTS->Fill(0); - fNofTSSinceLastTS=1; - } - fTSNumber=tsIndex; - - if ( 0 ==fTSNumber%1000 ) { - LOG(info) << "Reading Timeslice " << fTSNumber; - } - - for (size_t c {0}; c < ts.num_components(); c++) { - auto systemID = static_cast<int>(ts.descriptor(c, 0).sys_id); - - LOG(debug) << "Found systemID: " << std::hex - << systemID << std::dec; - - if(gLogger->IsLogNeeded( fair::Severity::debug1 )) { - PrintMicroSliceDescriptor(ts.descriptor(c, 0)); - } - - auto it=fUnpackers.find(systemID); - if (it == fUnpackers.end()) { - LOG(debug) << "Could not find unpacker for system id 0x" - << std::hex << systemID << std::dec; - } else { - if( 0 == tsIndex%fuTsReduction || systemID != 0x10 ) - it->second->DoUnpack(ts, c); - } - } - return 0; - } - - return 1; -} - -Int_t CbmFlibCern2016Source::GetNextEvent() -{ - - Double_t fTimeBufferOut = fBuffer->GetTimeLast(); - LOG(debug) << "Timeslice contains data from " - << std::setprecision(9) << std::fixed - << static_cast<Double_t>(fBuffer->GetTimeFirst()) * 1.e-9 << " to " - << std::setprecision(9) << std::fixed - << static_cast<Double_t>(fBuffer->GetTimeLast()) * 1.e-9 << " s"; - - LOG(debug) << "Buffer has " << fBuffer->GetSize() << " entries."; - - - CbmTbDaqBuffer::Data digi = fBuffer->GetNextData(fTimeBufferOut); -// CbmDigi* digi = fBuffer->GetNextData(fTimeBufferOut); - -// LOG(info) << "Before if"; - if ( digi.first.empty() ) return 1; -// LOG(info) << "After if"; - - while(! digi.first.empty() ) { - ECbmModuleId detId = digi.second; -// Int_t detId = digi->GetSystemId(); - Int_t flibId = fDetectorSystemMap[detId]; - LOG(debug) << "Digi has system ID " << detId - << " which maps to FlibId "<< flibId; - std::map<Int_t, CbmTSUnpack*>::iterator it=fUnpackers.find(flibId); - if (it == fUnpackers.end()) { - LOG(error) << "Skipping digi with unknown id " - << detId; - continue; - } else { - it->second->FillOutput(digi.first); - } - digi = fBuffer->GetNextData(fTimeBufferOut); - }; - - return 0; -} - -Bool_t CbmFlibCern2016Source::OpenNextFile() -{ - // First Close and delete existing source - if( NULL != fSource ) - delete fSource; - - if( fFileCounter < fInputFileList.GetSize() ) - { - // --- Open current input file - TObjString* tmp = - dynamic_cast<TObjString*>(fInputFileList.At(fFileCounter)); - fFileName = tmp->GetString(); - - LOG(info) << "Open the Flib input file " << fFileName; - // Check if the input file exist - FILE* inputFile = fopen(fFileName.Data(), "r"); - if ( ! inputFile ) { - LOG(error) << "Input file " << fFileName << " doesn't exist."; - return kFALSE; - } - fclose(inputFile); - fSource = new fles::TimesliceInputArchive(fFileName.Data()); - if ( !fSource) { - LOG(error) << "Could not open input file."; - return kFALSE; - } - } // if( fFileCounter < fInputFileList.GetSize() ) - else - { - LOG(info) << "End of files list reached: file counter is " << fFileCounter - << " for " << fInputFileList.GetSize() << " entries in the file list."; - return kFALSE; - } // else of if( fFileCounter < fInputFileList.GetSize() ) - - return kTRUE; -} - - -ClassImp(CbmFlibCern2016Source) diff --git a/beamtime/cern2016/CbmFlibCern2016Source.h b/beamtime/cern2016/CbmFlibCern2016Source.h deleted file mode 100644 index d9aa5d65221c13de0325dafb7485bc02e2b22379..0000000000000000000000000000000000000000 --- a/beamtime/cern2016/CbmFlibCern2016Source.h +++ /dev/null @@ -1,109 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmFlibCern2016Source ----- -// ----- Created 20.06.2016 by F. Uhlig ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CBMFLIBCERN2016SOURCE_H -#define CBMFLIBCERN2016SOURCE_H - -#include "TimesliceSource.hpp" -#include "Timeslice.hpp" -#include "MicrosliceDescriptor.hpp" - -#include "FairSource.h" -#include "CbmTSUnpack.h" -#include "CbmTbDaqBuffer.h" -#include "CbmDefs.h" - -#include "TString.h" -#include "TClonesArray.h" -#include "TList.h" -#include "TObjString.h" -#include "TStopwatch.h" - -#include <memory> -#include <map> - -class TH1I; - -class CbmFlibCern2016Source : public FairSource -{ - public: - CbmFlibCern2016Source(); - CbmFlibCern2016Source(const CbmFlibCern2016Source& source); - virtual ~CbmFlibCern2016Source(); - - Bool_t Init(); - Int_t ReadEvent(UInt_t); - - Source_Type GetSourceType() {return kONLINE;} - - virtual void SetParUnpackers(); - - virtual Bool_t InitUnpackers(); - - virtual Bool_t ReInitUnpackers(); - - void Close(); - void Reset(); - - void SetFileName(TString name) { fFileName = name; fInputFileList.Add(new TObjString(name));} - void SetHostName(TString name) { fHost = name; } - void SetPortNumber(Int_t port) { fPort = port; } - - void AddUnpacker(CbmTSUnpack* unpacker, Int_t flibId, ECbmModuleId detId) - { - fUnpackers.insert ( std::pair<Int_t,CbmTSUnpack*>(flibId,unpacker) ); - fDetectorSystemMap.insert ( std::pair<ECbmModuleId,Int_t>(detId,flibId) ); - } - - void AddFile(const char * name) { - fInputFileList.Add(new TObjString(name)); - } - - UInt_t GetTsCount() { return fTSCounter; } - UInt_t GetNofTSSinceLastTS() { return fNofTSSinceLastTS; } - - void SetDataReductionMuch( UInt_t uTsReduction = 15 ) { fuTsReduction = uTsReduction; } - - private: - - TString fFileName; - TList fInputFileList; ///< List of input files - Int_t fFileCounter; - TString fHost; - Int_t fPort; - - std::map<Int_t, CbmTSUnpack*> fUnpackers; - std::map<ECbmModuleId, Int_t> fDetectorSystemMap; //! Map detector system id to flib system id - - CbmTbDaqBuffer* fBuffer; - - UInt_t fTSNumber; - UInt_t fTSCounter; - TStopwatch fTimer; - - Bool_t fBufferFillNeeded; /** True if the input buffer has to be filled again **/ - - TH1I* fHistoMissedTS; - Int_t fNofTSSinceLastTS; - - UInt_t fuTsReduction; - - fles::TimesliceSource* fSource; //! - Bool_t CheckTimeslice(const fles::Timeslice& ts); - void PrintMicroSliceDescriptor(const fles::MicrosliceDescriptor& mdsc); - - Int_t FillBuffer(); - Int_t GetNextEvent(); - Bool_t OpenNextFile(); - - CbmFlibCern2016Source operator=(const CbmFlibCern2016Source&); - - ClassDef(CbmFlibCern2016Source, 2) -}; - - -#endif diff --git a/beamtime/cern2016/CbmFlibTestSource.cxx b/beamtime/cern2016/CbmFlibTestSource.cxx deleted file mode 100644 index dcdd6ef6c970b943cf02cadc77187ae491b864aa..0000000000000000000000000000000000000000 --- a/beamtime/cern2016/CbmFlibTestSource.cxx +++ /dev/null @@ -1,440 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmFlibTestSource ----- -// ----- Created 20.06.2016 by F. Uhlig ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#include "CbmFlibTestSource.h" - -#include "CbmTbDaqBuffer.h" - -#include "TimesliceInputArchive.hpp" -#include "Timeslice.hpp" -#include "TimesliceSubscriber.hpp" -#include "MicrosliceContents.hpp" - -#include "FairLogger.h" - -#include "TSystem.h" -#include "TList.h" -#include "TObjString.h" -#include "TRegexp.h" -#include "TSystemDirectory.h" - -#include <iostream> -#include <fstream> -#include <iomanip> - -#include "CbmTofDigi.h" - -std::vector<CbmDigi*> vdigi; - -CbmFlibTestSource::CbmFlibTestSource() - : FairSource(), - fFileName(""), - fInputFileList(new TObjString()), - fFileCounter(0), - fHost("localhost"), - fPort(5556), - fUnpackers(), - fDetectorSystemMap(), - fBuffer(CbmTbDaqBuffer::Instance()), - fTSNumber(0), - fTSCounter(0), - fiReqDigiAddr(), - fiReqMode(0), - fdMaxDeltaT(500.), - fTimer(), - fBufferFillNeeded(kTRUE), - fSource(NULL) -{ -} - -CbmFlibTestSource::CbmFlibTestSource(const CbmFlibTestSource& source) - : FairSource(source), - fFileName(""), - fInputFileList(), - fFileCounter(0), - fHost("localhost"), - fPort(5556), - fUnpackers(), - fDetectorSystemMap(), - fBuffer(CbmTbDaqBuffer::Instance()), - fTSNumber(0), - fTSCounter(0), - fiReqDigiAddr(), - fiReqMode(0), - fdMaxDeltaT(100.), - fTimer(), - fBufferFillNeeded(kTRUE), - fSource(NULL) -{ -} - -CbmFlibTestSource::~CbmFlibTestSource() -{ -} - -Bool_t CbmFlibTestSource::Init() -{ - Int_t fNFiles = fInputFileList.GetEntries(); - if ( fiReqDigiAddr.size()>0 ) - for(UInt_t i=0; i<fiReqDigiAddr.size(); i++) - LOG(info) << Form("Look for 0x%08x digis in %d input files",fiReqDigiAddr[i],fNFiles); - if ( 0 == fNFiles ) { //fFileName.Length() ) { - TString connector = Form("tcp://%s:%i", fHost.Data(), fPort); - LOG(info) << "Open TSPublisher at " << connector; - fInputFileList.Add(new TObjString(connector)); - fSource = new fles::TimesliceSubscriber(connector.Data()); - if ( !fSource) { - LOG(fatal) << "Could not connect to publisher."; - } - } else { - // --- Open input file - TObjString* tmp = - dynamic_cast<TObjString*>(fInputFileList.At(fFileCounter)); - fFileName = tmp->GetString(); - - LOG(info) << "Open the Flib input file " << fFileName; - // Check if the input file exist - FILE* inputFile = fopen(fFileName.Data(), "r"); - if ( ! inputFile ) { - LOG(fatal) << "Input file " << fFileName << " doesn't exist."; - } - fclose(inputFile); - fSource = new fles::TimesliceInputArchive(fFileName.Data()); - if ( !fSource) { - LOG(fatal) << "Could not open input file."; - } - } - - for (auto it=fUnpackers.begin(); it!=fUnpackers.end(); ++it) { - LOG(info) << "Initialize " << it->second->GetName() << - " for systemID 0x" << std::hex << it->first << std::dec; - it->second->Init(); - // it->second->Register(); - } - - return kTRUE; -} - -void CbmFlibTestSource::AddPath(const TString& tFileDirectory, - const TString& tFileNameWildCard) -{ - - FileStat_t tFileStat; - if(1 == gSystem->GetPathInfo(tFileDirectory.Data(), tFileStat)) - { - LOG(fatal) << - TString::Format("\nInput data file directory %s does not " - "exist.", - tFileDirectory.Data() - ).Data() - ; - } - - TRegexp* tRegexp = new TRegexp(tFileNameWildCard.Data(), kTRUE); - - TSystemDirectory* tSystemDirectory = - new TSystemDirectory("dir", tFileDirectory.Data()); - - TString tDirectoryName(tFileDirectory); - - if(!tDirectoryName.EndsWith("/")) - { - tDirectoryName += "/"; - } - TList* tList = tSystemDirectory->GetListOfFiles(); - - for (Int_t iRun=0; iRun< 999; iRun++) { - - Char_t* cRun = Form("_%04d.t",iRun); - TIterator* tIter = tList->MakeIterator(); - TSystemFile* tSystemFile; - TString tFileName; - - - while(NULL != (tSystemFile = (TSystemFile*)tIter->Next())) - { - tFileName = tSystemFile->GetName(); - - //LOG(info)<<" Check file "<<tFileName.Data()<<" for "<<cRun; - - if( tFileName.Contains(*tRegexp) && tFileName.Contains(cRun) ) - { - tFileName = tDirectoryName + tFileName; - - LOG(info)<<" Add file to input "<<tFileName.Data(); - - AddFile(tFileName); - break; - } - } - } - tList->Delete(); - if(0==fInputFileList.GetEntries()) - LOG(fatal)<<" did not find any valid input file at "<<tFileDirectory.Data(); -} - -void CbmFlibTestSource::SetParUnpackers() -{ - for (auto it=fUnpackers.begin(); it!=fUnpackers.end(); ++it) { - LOG(info) << "Set parameter container " << it->second->GetName() << - " for systemID 0x" << std::hex << it->first << std::dec; - it->second->SetParContainers(); - } - -} - -Bool_t CbmFlibTestSource::InitUnpackers() -{ - Bool_t result = kTRUE; - for (auto it=fUnpackers.begin(); it!=fUnpackers.end(); ++it) { - LOG(info) << "Initialize parameter container " << it->second->GetName() << - " for systemID 0x" << std::hex << it->first << std::dec; - result = result && it->second->InitContainers(); - } - return result; -} - -Bool_t CbmFlibTestSource::ReInitUnpackers() -{ - Bool_t result = kTRUE; - for (auto it=fUnpackers.begin(); it!=fUnpackers.end(); ++it) { - LOG(info) << "Initialize parameter container " << it->second->GetName() << - " for systemID 0x" << std::hex << it->first << std::dec; - result = result && it->second->ReInitContainers(); - } - return result; -} - -Int_t CbmFlibTestSource::ReadEvent(UInt_t iEv) -{ - - LOG(debug) << "Request received for "<<iEv<<". event "; - - - while ( 1 == GetNextEvent()){ - if (fBufferFillNeeded) { - Int_t iRet = FillBuffer(); - if (iRet>0) break; // no more data - } - } - - if ( fSource->eos() && fFileCounter < fInputFileList.GetEntries()){ - fFileCounter++; - TObjString* tmp = - dynamic_cast<TObjString*>(fInputFileList.At(fFileCounter)); - if(NULL != tmp) { - fFileName = tmp->GetString(); - LOG(info) << "Open the "<<fFileCounter<<". ("<<fInputFileList.GetEntries() - <<") Flib input file " << fFileName; - delete(fSource); - fSource = new fles::TimesliceInputArchive(fFileName.Data()); - if ( !fSource) { - LOG(fatal) << "Could not open input file."; - } - } - } - return fSource->eos(); // no more data; trigger end of run -} - -void CbmFlibTestSource::PrintMicroSliceDescriptor(const fles::MicrosliceDescriptor& mdsc) -{ - LOG(info) << "Header ID: Ox" << std::hex << static_cast<int>(mdsc.hdr_id) - << std::dec; - LOG(info) << "Header version: Ox" << std::hex << static_cast<int>(mdsc.hdr_ver) - << std::dec; - LOG(info) << "Equipement ID: " << mdsc.eq_id; - LOG(info) << "Flags: " << mdsc.flags; - LOG(info) << "Sys ID: Ox" << std::hex << static_cast<int>(mdsc.sys_id) - << std::dec; - LOG(info) << "Sys version: Ox" << std::hex << static_cast<int>(mdsc.sys_ver) - << std::dec; - LOG(info) << "Microslice Idx: " << mdsc.idx; - LOG(info) << "Checksum: " << mdsc.crc; - LOG(info) << "Size: " << mdsc.size; - LOG(info) << "Offset: " << mdsc.offset; -} - -Bool_t CbmFlibTestSource::CheckTimeslice(const fles::Timeslice& ts) -{ - if ( 0 == ts.num_components() ) { - LOG(error) << "No Component in TS " << ts.index(); - return 1; - } - LOG(info) << "Found " << ts.num_components() - << " different components in timeslice"; - return kTRUE; -} - -void CbmFlibTestSource::Close() -{ - for (auto it=fUnpackers.begin(); it!=fUnpackers.end(); ++it) { - LOG(info) << "Finish " << it->second->GetName() << " for systemID 0x" - << std::hex << it->first << std::dec; - it->second->Finish(); - } - -} - -void CbmFlibTestSource::Reset() -{ - for (auto it=fUnpackers.begin(); it!=fUnpackers.end(); ++it) { - it->second->Reset(); - } -} - -Int_t CbmFlibTestSource::FillBuffer() -{ - - while (auto timeslice = fSource->get()) { - fTSCounter++; - if ( 0 == fTSCounter%10000 ) { - LOG(info) << "Processing TimeSlice " << fTSCounter; - } - - const fles::Timeslice& ts = *timeslice; - auto tsIndex = ts.index(); - if( (tsIndex != (fTSNumber+1)) &&( fTSNumber != 0) ) { - LOG(warning) << "Missed Timeslices. Old TS Number was " << fTSNumber - << " New TS Number is " << tsIndex; - } - fTSNumber=tsIndex; - - if ( 0 ==fTSNumber%10000 ) { - LOG(info) << "Reading Timeslice " << fTSNumber; - } - - for (size_t c {0}; c < ts.num_components(); c++) { - auto systemID = static_cast<int>(ts.descriptor(c, 0).sys_id); - - LOG(debug) << "Found systemID: " << std::hex - << systemID << std::dec; - - if(gLogger->IsLogNeeded( fair::Severity::debug1 )) { - PrintMicroSliceDescriptor(ts.descriptor(c, 0)); - } - - auto it=fUnpackers.find(systemID); - if (it == fUnpackers.end()) { - LOG(debug) << "Could not find unpacker for system id 0x" - << std::hex << systemID << std::dec; - } else { - it->second->DoUnpack(ts, c); - } - } - return 0; - } - - return 1; -} - -Int_t CbmFlibTestSource::GetNextEvent() -{ - const Int_t AddrMask=0x0001FFFF; - UInt_t nDigi=0; - Bool_t bOut=kFALSE; - Double_t fTimeBufferOut=0.; - //Double_t dTLast=0.; - while (!bOut) - { - fTimeBufferOut = fBuffer->GetTimeLast(); - LOG(debug) << "Buffer has " << fBuffer->GetSize() << " entries and contains data from " - << std::setprecision(9) << std::fixed - << static_cast<Double_t>(fBuffer->GetTimeFirst()) * 1.e-9 << " to " - << std::setprecision(9) << std::fixed - << static_cast<Double_t>(fBuffer->GetTimeLast()) * 1.e-9 << " s"; - - if(fTimeBufferOut - fBuffer->GetTimeFirst()<1.E6) {fBufferFillNeeded=kTRUE; return 1;} // store 1 msec of data in memory - - CbmDigi* digi = fBuffer->GetNextData(fTimeBufferOut); - if (NULL == digi) {fBufferFillNeeded=kTRUE; return 1;} - - LOG(debug) << "Buffer has " << fBuffer->GetSize() << " entries left for digitime = " <<digi->GetTime(); - - Double_t dTEnd = digi->GetTime() + fdMaxDeltaT; - - if(dTEnd > fTimeBufferOut) { - LOG(warning) <<Form("Remaining buffer < %f with %d entries is not sufficient for digi ending at %f -> skipped ", - fTimeBufferOut, fBuffer->GetSize(), dTEnd ); - fBufferFillNeeded=kTRUE; return 1; - } - - Bool_t bDet[fiReqDigiAddr.size()][2]; - for(UInt_t i=0; i<fiReqDigiAddr.size(); i++) for(Int_t j=0; j<2; j++) bDet[i][j]=kFALSE; //initialize - - nDigi=0; - while(digi) { // build digi array - if (nDigi == vdigi.size()) vdigi.resize(nDigi+100); - vdigi[nDigi++]=digi; - for(UInt_t i=0; i<fiReqDigiAddr.size(); i++) - if( (digi->GetAddress() & AddrMask) == fiReqDigiAddr[i]) { - Int_t j = ((CbmTofDigi *)digi)->GetSide(); - bDet[i][j]=kTRUE; - if (fiReqDigiAddr[i] == 0x00005006) bDet[i][1]=kTRUE; // diamond with pad readout - } - //if(bOut) LOG(info)<<Form("Found 0x%08x, Req 0x%08x ", digi->GetAddress(), fiReqDigiAddr); - digi = fBuffer->GetNextData(dTEnd); - } - - LOG(debug) << nDigi << " digis associated to dTEnd = " <<dTEnd<<":"; - for(UInt_t iDigi=0; iDigi<nDigi; iDigi++) LOG(debug)<<Form(" 0x%08x",vdigi[iDigi]->GetAddress()); - LOG(debug)<< ""; - if( fiReqDigiAddr.size() > 1) - LOG(debug) << "Found Req coinc in event with " <<nDigi << " digis, dTEnd = " <<dTEnd; - - //dTLast = vdigi[nDigi-1]->GetTime(); - - if(fiReqDigiAddr.size()==0) bOut=kTRUE; // output everything - else { - if( fiReqMode == 0 ) { // check for presence of requested detectors - for(UInt_t i=0; i<fiReqDigiAddr.size(); i++) - if(bDet[i][0]==kFALSE || bDet[i][1]==kFALSE ) break; - else if( i == fiReqDigiAddr.size()-1 ) bOut=kTRUE; - } else { // check for presence of any known detector - Int_t iDetMul=0; - for(UInt_t i=0; i<fiReqDigiAddr.size(); i++) - if(bDet[i][0]==kTRUE && bDet[i][1]==kTRUE ) { - iDetMul++; - if(iDetMul == fiReqMode) {bOut=kTRUE; break;} - } - } - - } - for(UInt_t iDigi=0; iDigi<nDigi; iDigi++){ - digi=vdigi[iDigi]; - Int_t detId = digi->GetSystemId(); - Int_t flibId = fDetectorSystemMap[detId]; - LOG(debug1) << "Digi has system ID " << detId - << " which maps to FlibId "<< flibId; - std::map<Int_t, CbmTSUnpack*>::iterator it=fUnpackers.find(flibId); - if (it == fUnpackers.end()) { - LOG(error) << "Skipping digi with unknown id " - << detId; - continue; - } else { - //nDigi++; - //LOG(debug) << "Found unpacker " << it->second; - if(bOut) it->second->FillOutput(digi); - else digi->Delete(); - } - // digi = fBuffer->GetNextData(dTEnd); - }; - vdigi.clear(); - } // end of bOut condition - LOG(debug) << "Buffer has " << fBuffer->GetSize() << " entries left, " - << nDigi <<" digis in current event. "; - //( fBuffer->GetSize() <= 100000 ) ? fBufferFillNeeded=kTRUE : fBufferFillNeeded=kFALSE; - //((dTLast + 1.E10) > fTimeBufferOut) ? fBufferFillNeeded=kTRUE : fBufferFillNeeded=kFALSE; // store 10 sec in memory - return 0; -} - -void CbmFlibTestSource::AddReqDigiAddr(Int_t iAddr) -{ - Int_t iNReq=fiReqDigiAddr.size(); - fiReqDigiAddr.resize(iNReq+1); // hopefully the old entries are preserved ... - fiReqDigiAddr[iNReq]=iAddr; -} -ClassImp(CbmFlibTestSource) diff --git a/beamtime/cern2016/CbmFlibTestSource.h b/beamtime/cern2016/CbmFlibTestSource.h deleted file mode 100644 index 23abc1066a34391b6699ee407c4c92c48b1dd803..0000000000000000000000000000000000000000 --- a/beamtime/cern2016/CbmFlibTestSource.h +++ /dev/null @@ -1,109 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmFlibTestSource ----- -// ----- Created 20.06.2016 by F. Uhlig ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CBMFLIBTESTSOURCE_H -#define CBMFLIBTESTSOURCE_H - -#include "TimesliceSource.hpp" -#include "Timeslice.hpp" -#include "MicrosliceDescriptor.hpp" - -#include "FairSource.h" -#include "CbmTSUnpack.h" -#include "CbmTbDaqBuffer.h" - -#include "TString.h" -#include "TClonesArray.h" -#include "TList.h" -#include "TObjString.h" -#include "TStopwatch.h" -#include "Rtypes.h" - -#include <memory> -#include <map> - - -class CbmFlibTestSource : public FairSource -{ - public: - CbmFlibTestSource(); - CbmFlibTestSource(const CbmFlibTestSource& source); - virtual ~CbmFlibTestSource(); - - Bool_t Init(); - Int_t ReadEvent(UInt_t); - - Source_Type GetSourceType() {return kONLINE;} - - virtual void SetParUnpackers(); - - virtual Bool_t InitUnpackers(); - - virtual Bool_t ReInitUnpackers(); - - void Close(); - void Reset(); - - void SetFileName(TString name) { fFileName = name; fInputFileList.Add(new TObjString(name));} - void SetHostName(TString name) { fHost = name; } - void SetPortNumber(Int_t port) { fPort = port; } - void SetReqDigiAddr(Int_t ival) {fiReqDigiAddr.resize(1); fiReqDigiAddr[0] = ival;}; - void AddReqDigiAddr(Int_t ival); - void SetReqMode(Int_t ival) { fiReqMode = ival; } - void SetMaxDeltaT(Double_t dval) { fdMaxDeltaT = dval;} - - void AddUnpacker(CbmTSUnpack* unpacker, Int_t flibId, Int_t detId) - { - fUnpackers.insert ( std::pair<Int_t,CbmTSUnpack*>(flibId,unpacker) ); - fDetectorSystemMap.insert ( std::pair<Int_t,Int_t>(detId,flibId) ); - } - - void AddFile(const char * name) { - fInputFileList.Add(new TObjString(name)); - } - - void AddPath(const TString& tFileDirectory, - const TString& tFileNameWildCard); - - UInt_t GetTsCount() { return fTSCounter; } - - private: - - TString fFileName; - TList fInputFileList; ///< List of input files - Int_t fFileCounter; - TString fHost; - Int_t fPort; - - std::map<Int_t, CbmTSUnpack*> fUnpackers; - std::map<Int_t, Int_t> fDetectorSystemMap; //! Map detector system id to flib system id - - CbmTbDaqBuffer* fBuffer; - - UInt_t fTSNumber; - UInt_t fTSCounter; - std::vector< Int_t > fiReqDigiAddr; - Int_t fiReqMode; - Double_t fdMaxDeltaT; - TStopwatch fTimer; - - Bool_t fBufferFillNeeded; /** True if the input buffer has to be filled again **/ - - fles::TimesliceSource* fSource; //! - Bool_t CheckTimeslice(const fles::Timeslice& ts); - void PrintMicroSliceDescriptor(const fles::MicrosliceDescriptor& mdsc); - - Int_t FillBuffer(); - Int_t GetNextEvent(); - - CbmFlibTestSource operator=(const CbmFlibTestSource&); - - ClassDef(CbmFlibTestSource, 1) -}; - - -#endif diff --git a/beamtime/cern2016/param/.gitignore b/beamtime/cern2016/param/.gitignore deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/beamtime/cern2016/unpacker/CbmTSMonitorMuch.cxx b/beamtime/cern2016/unpacker/CbmTSMonitorMuch.cxx deleted file mode 100644 index 010036a019302fc7676a32efaa20ad9160ecea69..0000000000000000000000000000000000000000 --- a/beamtime/cern2016/unpacker/CbmTSMonitorMuch.cxx +++ /dev/null @@ -1,857 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmTSMonitorMuch ----- -// ----- Created 11.11.2016 by V. Singhal and A. Kumar ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#include "CbmTSMonitorMuch.h" -#include "CbmMuchUnpackPar.h" - -#include "CbmMuchAddress.h" -#include "CbmHistManager.h" - -#include "FairLogger.h" -#include "FairRootManager.h" -#include "FairRun.h" -#include "FairRuntimeDb.h" -#include "FairRunOnline.h" - -#include "TClonesArray.h" -#include "TString.h" -#include "TRandom.h" -#include "THttpServer.h" -#include "TROOT.h" - -#include <iostream> -#include <stdint.h> -#include <iomanip> - -class CbmMuchAddress; -using std::hex; -using std::dec; -using namespace std; - -Bool_t bResetMuchHistos = kFALSE; - -CbmTSMonitorMuch::CbmTSMonitorMuch() - : CbmTSUnpack(), - fuOverlapMsNb(0), - fNrOfNdpbs(0), - fNrOfNdpbsA(0), - fNrOfNdpbsB(0), - fNrOfFebsPerNdpb(0), - fMsgCounter(11,0), // length of enum MessageTypes initialized with 0 - fNdpbIdIndexMap(), - fMuchStationMapX(), - fMuchStationMapY(), - fHM(new CbmHistManager()), - fCurrentEpoch(), - fNofEpochs(0), - fCurrentEpochTime(0.), - fdStartTime( -1 ), - fdStartTimeMsSz(-1.), - fcMsSizeAll(NULL), - fEquipmentId(0), - fUnpackPar(NULL), - fFebRateDate_nDPB(), - fHitDtDate_nDPB(), - fdLastHitTime_nDPB(), - fiRunStartDateTimeSec( -1 ), - fiBinSizeDatePlots( -1 ), - fHistMessType(NULL), - fHistSysMessType(NULL), - fChan_Counts_Much(), - fRaw_ADC_Much(), - fFebRate(), - fHitMissEvo(), - fHistPadDistr(NULL) -{ -} - -CbmTSMonitorMuch::~CbmTSMonitorMuch() -{ -} - -Bool_t CbmTSMonitorMuch::Init() -{ - LOG(info) << "Initializing flib nxyter unpacker for MUCH"; - - FairRootManager* ioman = FairRootManager::Instance(); - if (ioman == NULL) { - LOG(fatal) << "No FairRootManager instance"; - } - - return kTRUE; -} - -void CbmTSMonitorMuch::SetParContainers() -{ - LOG(info) << "Setting parameter containers for " << GetName(); - fUnpackPar = (CbmMuchUnpackPar*)(FairRun::Instance()->GetRuntimeDb()->getContainer("CbmMuchUnpackPar")); -} - - -Bool_t CbmTSMonitorMuch::InitContainers() -{ - LOG(info) << "Init parameter containers for " << GetName(); - - Bool_t bReInit = ReInitContainers(); - CreateHistograms(); - - return bReInit; -} - -Bool_t CbmTSMonitorMuch::ReInitContainers() -{ - LOG(info) << "ReInit parameter containers for " << GetName(); - - fNrOfNdpbsA = fUnpackPar->GetNrOfnDpbsModA(); - fNrOfNdpbsB = fUnpackPar->GetNrOfnDpbsModB(); - fNrOfNdpbs = fNrOfNdpbsA + fNrOfNdpbsB; - fNrOfFebsPerNdpb = fUnpackPar->GetNrOfFebsPerNdpb(); - - LOG(info) << "Nr. of nDPBs Mod. A: " << fNrOfNdpbsA; - - LOG(info) << "Nr. of nDPBs Mod. B: " << fNrOfNdpbsB; - - fNdpbIdIndexMap.clear(); - for (Int_t i = 0; i< fNrOfNdpbsA; ++i) - { - fNdpbIdIndexMap[fUnpackPar->GetNdpbIdA(i)] = i; - LOG(info) << "nDPB Id of MUCH A " << i - << " : 0x" << std::hex << fUnpackPar->GetNdpbIdA(i) - << std::dec; - } // for (Int_t i = 0; i< NrOfnDpbsModA; ++i) - for (Int_t i = 0; i< fNrOfNdpbsB; ++i) - { - fNdpbIdIndexMap[fUnpackPar->GetNdpbIdB(i)] = i + fNrOfNdpbsA; - LOG(info) << "nDPB Id of MUCH B " << i - << " : 0x" << std::hex << fUnpackPar->GetNdpbIdB(i) - << std::dec; - } // for (Int_t i = 0; i< NrOfnDpbsModB; ++i) - - Int_t NrOfFebs = fUnpackPar->GetNrOfFebs(); - - LOG(info) << "Nr. of FEBs : " << NrOfFebs; - - - Int_t NrOfChannels = fUnpackPar->GetNrOfChannels(); - LOG(info) << "Nr. of Channels : " << NrOfChannels; - - // Need to clear the 2 Arrays fMuchStationMapX and MapY - - // log all the DPBs number - - // Filling all the Mapping values in the 2 X and Y arrays - // Int_t nrOfChannels = fUnpackPar->GetNumberOfChannels(); - - for (Int_t febId = 0 ; febId<NrOfFebs; febId++){// looping on all the FEB IDs - for (Int_t channelId=0; channelId<NrOfChannels; channelId++){ - - //Have to check GetPadX and GetPadY values. -// LOG(info) << "Value of GetPadX " << fUnpackPar->GetPadX(febId,channelId); - fMuchStationMapX[febId][channelId] = fUnpackPar->GetPadX(febId,channelId); -// LOG(info) << "Value of GetPadY " << fUnpackPar->GetPadY(febId,channelId); - fMuchStationMapY[febId][channelId] = fUnpackPar->GetPadY(febId,channelId); - } - } - - return kTRUE; -} - -void CbmTSMonitorMuch::CreateHistograms() -{ - THttpServer* server = FairRunOnline::Instance()->GetHttpServer(); - - TString sHistName{""}; - TString title{""}; - - sHistName = "hMessageTypeMuch"; - title = "Nb of message for each type; Type"; - TH1I* hMessageType = new TH1I(sHistName, title, 16, 0., 16.); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_NOP, "NOP"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_HIT, "HIT"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_EPOCH, "EPOCH"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_SYNC, "SYNC"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_AUX, "AUX"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_EPOCH2, "EPOCH2"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_GET4, "GET4"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_SYS, "SYS"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_GET4_SLC, "MSG_GET4_SLC"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_GET4_32B, "MSG_GET4_32B"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_GET4_SYS, "MSG_GET4_SYS"); - hMessageType->GetXaxis()->SetBinLabel(1 + 15, "GET4 Hack 32B"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_NOP, "NOP"); - fHM->Add(sHistName.Data(), hMessageType); - if (server) server->Register("/MuchRaw", fHM->H1(sHistName.Data())); - - sHistName = "hSysMessTypeMuch"; - title = "Nb of system message for each type; System Type"; - TH1I* hSysMessType = new TH1I(sHistName, title, 17, 0., 17.); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_START, "DAQ START"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_FINISH, "DAQ FINISH"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_NX_PARITY, "NX PARITY"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_SYNC_PARITY, "SYNC PARITY"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_RESUME, "DAQ RESUME"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_FIFO_RESET, "FIFO RESET"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_USER, "USER"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_PCTIME, "PCTIME"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_ADC, "ADC"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_PACKETLOST, "PACKET LOST"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_GET4_EVENT, "GET4 ERROR"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_CLOSYSYNC_ERROR, "CLOSYSYNC ERROR"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_TS156_SYNC, "TS156 SYNC"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_GDPB_UNKWN, "UNKW GET4 MSG"); - hSysMessType->GetXaxis()->SetBinLabel(1 + 16, "GET4 Hack 32B"); - fHM->Add(sHistName.Data(), hSysMessType); - if (server) server->Register("/MuchRaw", fHM->H1(sHistName.Data())); - - // Number of rqte bins = - // 9 for the sub-unit decade - // + 9 for each unit of each decade * 10 for the subdecade range - // + 1 for the closing bin top edge - const Int_t iNbDecadesRate = 9; - const Int_t iNbStepsDecade = 9; - const Int_t iNbSubStepsInStep = 10; - const Int_t iNbBinsRate = iNbStepsDecade - + iNbStepsDecade * iNbSubStepsInStep * iNbDecadesRate - + 1; - Double_t dBinsRate[iNbBinsRate]; - // First fill sub-unit decade - for( Int_t iSubU = 0; iSubU < iNbStepsDecade; iSubU ++ ) - dBinsRate[ iSubU ] = 0.1 * ( 1 + iSubU ); - std::cout << std::endl; - // Then fill the main decades - Double_t dSubstepSize = 1.0 / iNbSubStepsInStep; - for( Int_t iDecade = 0; iDecade < iNbDecadesRate; iDecade ++) - { - Double_t dBase = std::pow( 10, iDecade ); - Int_t iDecadeIdx = iNbStepsDecade - + iDecade * iNbStepsDecade * iNbSubStepsInStep; - for( Int_t iStep = 0; iStep < iNbStepsDecade; iStep++ ) - { - Int_t iStepIdx = iDecadeIdx + iStep * iNbSubStepsInStep; - for( Int_t iSubStep = 0; iSubStep < iNbSubStepsInStep; iSubStep++ ) - { - dBinsRate[ iStepIdx + iSubStep ] = dBase * (1 + iStep) - + dBase * dSubstepSize * iSubStep; - } // for( Int_t iSubStep = 0; iSubStep < iNbSubStepsInStep; iSubStep++ ) - } // for( Int_t iStep = 0; iStep < iNbStepsDecade; iStep++ ) - } // for( Int_t iDecade = 0; iDecade < iNbDecadesRate; iDecade ++) - dBinsRate[ iNbBinsRate - 1 ] = std::pow( 10, iNbDecadesRate ); - - TString sNdpbTag = ""; - TString sDateHistName{""}; - for( Int_t dpbId = 0; dpbId < fNrOfNdpbs; dpbId++) - {// looping on all the nDPBS IDs - - if( dpbId < fUnpackPar->GetNrOfnDpbsModA() ) - { - sNdpbTag = Form("%04X", fUnpackPar->GetNdpbIdA(dpbId) ); - } // if( dpbId < fUnpackPar->GetNrOfnDpbsModA() ) - else - { - sNdpbTag = Form("%04X", fUnpackPar->GetNdpbIdB(dpbId - fNrOfNdpbsA) ); - } // else of if( dpbId < fUnpackPar->GetNrOfnDpbsModA() ) - - for( Int_t febId = 0; febId < fNrOfFebsPerNdpb; febId++) - {// looping on all the FEB IDs - sHistName = Form("Chan_Counts_Much_n%s_f%1u", sNdpbTag.Data(), febId); - title = Form("Channel counts Much nDPB %s FEB %02u; channel; Counts", - sNdpbTag.Data(), febId); - fHM->Add( sHistName.Data(), new TH1F( sHistName.Data(), title.Data(), 128, 0, 128) ); - if (server) server->Register("/MuchRaw", fHM->H1(sHistName.Data())); - - sHistName = Form("Raw_ADC_Much_n%s_f%1u", sNdpbTag.Data(), febId); - title = Form("Raw ADC Much nDPB %s FEB %02u; channel; ADC value", - sNdpbTag.Data(), febId); - fHM->Add( sHistName.Data(), new TH2F( sHistName.Data(), title.Data(), 128, 0, 128, 4096, 0, 4096) ); - if (server) server->Register("/MuchRaw", fHM->H2(sHistName.Data())); - - sHistName = Form("FebRate_n%s_f%1u", sNdpbTag.Data(), febId); - title = Form("Counts per second in nDPB %s FEB %02u; Time[s] ; Counts", - sNdpbTag.Data(), febId); - fHM->Add( sHistName.Data(), new TH1F( sHistName.Data(), title.Data(), 1800, 0, 1800 ) ); - if (server) server->Register("/MuchRaw", fHM->H1(sHistName.Data())); - - if( 0 < fiBinSizeDatePlots && 0 < fiRunStartDateTimeSec ) { - sDateHistName = Form("FebRateDate_n%s_f%1u", sNdpbTag.Data(), febId); - fHM->Add(sDateHistName.Data(), new TH1F(sDateHistName.Data(), title.Data(), - (5400 / fiBinSizeDatePlots), - fiRunStartDateTimeSec -10, fiRunStartDateTimeSec + 5400 - 10)); - ( fHM->H1(sDateHistName.Data()) )->GetXaxis()->SetTimeDisplay(1); - if (server) - server->Register("/MuchRaw", fHM->H1(sDateHistName.Data())); - - sHistName = Form("HitDtDate_n%s_f%1u", sNdpbTag.Data(), febId ); - title = Form("Inverse Hit distance VS time in second in nDPB %s FEB %02u; Time[s] ; F [Hz]; Counts", - sNdpbTag.Data(), febId ); - fHM->Add(sHistName.Data(), new TH2F(sHistName.Data(), title.Data(), - (5400 / 2*fiBinSizeDatePlots), - fiRunStartDateTimeSec -10, fiRunStartDateTimeSec + 5400 - 10, - iNbBinsRate - 1, dBinsRate )); - ( fHM->H2(sHistName.Data()) )->GetXaxis()->SetTimeDisplay(1); - if (server) - server->Register("/MuchRaw", fHM->H2(sHistName.Data())); - } // if( 0 < fiBinSizeDatePlots && 0 < fiRunStartDateTimeSec ) - - sHistName = Form("HitMissEvo_n%s_f%1u", sNdpbTag.Data(), febId); - title = Form("Minimal hit loss per second in nDPB %s FEB %02u; Time[s] ; Min Loss", - sNdpbTag.Data(), febId); - fHM->Add( sHistName.Data(), new TH1F( sHistName.Data(), title.Data(), 1800, 0, 1800 ) ); - if (server) server->Register("/MuchRaw", fHM->H1(sHistName.Data())); - - } // for( Int_t febId = 0; febId < fNrOfFebsPerNdpb; febId++) - } // for( Int_t dpbId = 0; dpbId < fNrOfNdpbs; dpbId++) - - sHistName = "Pad_Distribution"; - title = "Pad_Distribution; Sectors in Horizontal Direction; Channels in Vertical Direction"; - fHM->Add( sHistName.Data(), new TH2F(sHistName.Data(), title.Data(), 79, -0.5, 78.5, 23, -0.5, 22.5) ); - -/* TH2* histPadDistr = fHM->H2("Pad_Distribution"); - for( Int_t iFeb = 0; iFeb < 15; iFeb ++) - for( Int_t iChan = 0; iChan < 128; iChan ++) - { - Int_t sector = fUnpackPar->GetPadX(iFeb, iChan); - Int_t channel = fUnpackPar->GetPadY(iFeb, iChan); - if(!(sector<0||channel<0)){ - - histPadDistr->Fill((78-sector),(22-channel), (iFeb + 1)); - if (sector==25 && channel==0) cout << "Pad X value" << fUnpackPar->GetPadX(iFeb, iChan) << "Pad Y value" << fUnpackPar->GetPadY(iFeb, iChan) << endl; - } - } -// Int_t iFeb = 3, iChan =32; - -*/ - if (server) server->Register("/MuchRaw", fHM->H2(sHistName.Data())); - - if (server) - server->RegisterCommand("/Reset_All_MUCH", "bResetMuchHistos=kTRUE"); - if (server) - server->Restrict("/Reset_All_Much", "allow=admin"); - - /** Create summary Canvases for CERN 2016 **/ - Double_t w = 10; - Double_t h = 10; - Int_t iNbPadsPerDpb = fNrOfFebsPerNdpb/2 + fNrOfFebsPerNdpb%2; - - TCanvas* cMuchChCounts = new TCanvas("cMuchChCounts", "MUCH Channels counts", w, h); - cMuchChCounts->Divide( fNrOfNdpbs/2 + fNrOfNdpbs%2, fNrOfFebsPerNdpb ); - - TCanvas* cMuchFebRate = new TCanvas("cMuchFebRate", "MUCH FEB rate", w, h); - cMuchFebRate->Divide( fNrOfNdpbs/2 + fNrOfNdpbs%2, fNrOfFebsPerNdpb ); - - TH1* histPnt = NULL; - for( Int_t dpbId = 0; dpbId < fNrOfNdpbs; dpbId++) - {// looping on all the nDPBS IDs - if( dpbId < fUnpackPar->GetNrOfnDpbsModA() ) - { - sNdpbTag = Form("%04X", fUnpackPar->GetNdpbIdA(dpbId) ); - } // if( dpbId < fUnpackPar->GetNrOfnDpbsModA() ) - else - { - sNdpbTag = Form("%04X", fUnpackPar->GetNdpbIdB(dpbId - fNrOfNdpbsA) ); - } // else of if( dpbId < fUnpackPar->GetNrOfnDpbsModA() ) - - for( Int_t febId = 0; febId < fNrOfFebsPerNdpb; febId++) - {// looping on all the FEB IDs - cMuchChCounts->cd( 1 + dpbId * iNbPadsPerDpb + febId/2 ); - gPad->SetLogy(); - sHistName = Form("Chan_Counts_Much_n%s_f%1u", sNdpbTag.Data(), febId); - histPnt = fHM->H1(sHistName.Data()); - - if( 0 == febId%2 ) - { - histPnt->SetLineColor( kRed ); // => Change color for 1st of the 2/pad! - histPnt->Draw(); - } // if( 0 == febId%2 ) - else - { - histPnt->SetLineColor( kBlue ); // => Change color for 1nd of the 2/pad! - histPnt->Draw("same"); - } // if( 0 == febId%2 ) - - cMuchFebRate->cd( 1 + dpbId * iNbPadsPerDpb + febId/2 ); - gPad->SetLogy(); - sHistName = Form("FebRate_n%s_f%1u", sNdpbTag.Data(), febId); - histPnt = fHM->H1(sHistName.Data()); - - if( 0 == febId%2 ) - { - histPnt->SetLineColor( kRed ); // => Change color for 1st of the 2/pad! - histPnt->Draw(); - } // if( 0 == febId%2 ) - else - { - histPnt->SetLineColor( kBlue ); // => Change color for 1nd of the 2/pad! - histPnt->Draw("same"); - } // if( 0 == febId%2 ) - } // for( Int_t febId = 0; febId < fNrOfFebsPerNdpb; febId++) - } // for( Int_t dpbId = 0; dpbId < fNrOfNdpbs; dpbId++) - - /** Recovers/Create Ms Size Canvase for CERN 2016 **/ - // Try to recover canvas in case it was created already by another monitor - // If not existing, create it - fcMsSizeAll = dynamic_cast<TCanvas *>( gROOT->FindObject( "cMsSizeAll" ) ); - if( NULL == fcMsSizeAll ) - { - fcMsSizeAll = new TCanvas("cMsSizeAll", "Evolution of MS size in last 300 s", w, h); - fcMsSizeAll->Divide( 4, 4 ); - LOG(info) << "Created MS size canvas in MUCH monitor"; - } // if( NULL == fcMsSizeAll ) - else LOG(info) << "Recovered MS size canvas in MUCH monitor"; - - /*****************************/ - - for( Int_t dpbId = 0; dpbId < fNrOfNdpbs; dpbId++) - { - if( dpbId < fUnpackPar->GetNrOfnDpbsModA() ) - { - sNdpbTag = Form("%04X", fUnpackPar->GetNdpbIdA(dpbId) ); - } // if( dpbId < fUnpackPar->GetNrOfnDpbsModA() ) - else - { - sNdpbTag = Form("%04X", fUnpackPar->GetNdpbIdB(dpbId - fNrOfNdpbsA) ); - } // else of if( dpbId < fUnpackPar->GetNrOfnDpbsModA() ) - for( Int_t febId = 0; febId < fNrOfFebsPerNdpb; febId++) - { - if( 0 < fiBinSizeDatePlots && 0 < fiRunStartDateTimeSec ) { - sDateHistName = Form("FebRateDate_n%s_f%1u", sNdpbTag.Data(), febId); - fFebRateDate_nDPB.push_back(fHM->H1(sDateHistName.Data())); - - sHistName = Form("HitDtDate_n%s_f%1u", sNdpbTag.Data(), febId ); - fHitDtDate_nDPB.push_back(fHM->H2(sHistName.Data())); - fdLastHitTime_nDPB.push_back( -1.0 ); - } // if( 0 < fiBinSizeDatePlots && 0 < fiRunStartDateTimeSec ) - - } // for( Int_t febId = 0; febId < fNrOfFebsPerNdpb; febId++) - } // for( Int_t dpbId = 0; dpbId < fNrOfNdpbs; dpbId++) - - - fHistMessType = fHM->H1("hMessageTypeMuch"); - fHistSysMessType = fHM->H1("hSysMessTypeMuch"); - - std::vector<TH1*> Chan_Counts_Much; - std::vector<TH2*> Raw_ADC_Much; - std::vector<TH1*> FebRate; - std::vector<TH1*> HitMissEvo; -/* - TString sHistName{""}; - TString title{""}; - TString sNdpbTag(""); -*/ - for( Int_t dpbId = 0; dpbId < fNrOfNdpbs; dpbId++) - {// looping on all the nDPBS IDs - if( dpbId < fUnpackPar->GetNrOfnDpbsModA() ) - { - sNdpbTag = Form("%04X", fUnpackPar->GetNdpbIdA(dpbId) ); - } // if( dpbId < fUnpackPar->GetNrOfnDpbsModA() ) - else - { - sNdpbTag = Form("%04X", fUnpackPar->GetNdpbIdB(dpbId - fNrOfNdpbsA) ); - } // else of if( dpbId < fUnpackPar->GetNrOfnDpbsModA() ) - for( Int_t febId = 0; febId < fNrOfFebsPerNdpb; febId++) - {// looping on all the FEB IDs - sHistName = Form("Chan_Counts_Much_n%s_f%1u", sNdpbTag.Data(), febId); - fChan_Counts_Much.push_back(fHM->H1(sHistName.Data())); - sHistName = Form("Raw_ADC_Much_n%s_f%1u", sNdpbTag.Data(), febId); - fRaw_ADC_Much.push_back(fHM->H2(sHistName.Data())); - sHistName = Form("FebRate_n%s_f%1u", sNdpbTag.Data(), febId); - fFebRate.push_back(fHM->H1(sHistName.Data())); - sHistName = Form("HitMissEvo_n%s_f%1u", sNdpbTag.Data(), febId); - fHitMissEvo.push_back(fHM->H1(sHistName.Data())); - } // for( Int_t febId = 0; febId < fNrOfFebsPerNdpb; febId++) - } // for( Int_t dpbId = 0; dpbId < fNrOfNdpbs; dpbId++) - fHistPadDistr = fHM->H2("Pad_Distribution"); - - for( Int_t component = 0; component < kiMaxNbFlibLinks; component ++ ) - { - fhMsSz[ component ] = NULL; - fhMsSzTime[ component ] = NULL; - } -} - -Bool_t CbmTSMonitorMuch::DoUnpack(const fles::Timeslice& ts, size_t component) -{ - THttpServer* server = FairRunOnline::Instance()->GetHttpServer(); - - if (bResetMuchHistos) { - ResetAllHistos(); - bResetMuchHistos = kFALSE; - } - - LOG(debug) << "Timeslice contains " << ts.num_microslices(component) - << "microslices."; - - if( component < kiMaxNbFlibLinks ) - if( NULL == fhMsSz[ component ] ) - { - TString sMsSzName = Form("MsSz_link_%02lu", component); - TString sMsSzTitle = Form("Size of MS for nDPB of link %02lu; Ms Size [bytes]", component); - fHM->Add(sMsSzName.Data(), new TH1F( sMsSzName.Data(), sMsSzTitle.Data(), - 160000, 0., 20000. ) ); - fhMsSz[ component ] = fHM->H1(sMsSzName.Data()); - if (server) server->Register("/FlibRaw", fhMsSz[ component ] ); - sMsSzName = Form("MsSzTime_link_%02lu", component); - sMsSzTitle = Form("Size of MS vs time for gDPB of link %02lu; Time[s] ; Ms Size [bytes]", component); - fHM->Add(sMsSzName.Data(), new TProfile( sMsSzName.Data(), sMsSzTitle.Data(), - 15000, 0., 300. ) ); - fhMsSzTime[ component ] = fHM->P1(sMsSzName.Data()); - if (server) server->Register("/FlibRaw", fhMsSzTime[ component ] ); - if( NULL != fcMsSizeAll ) - { - fcMsSizeAll->cd( 1 + component ); - gPad->SetLogy(); - fhMsSzTime[ component ]->Draw("hist le0"); - } // if( NULL != fcMsSizeAll ) - LOG(info) << "Added MS size histo for component: " << component - << " (nDPB)"; - } // if( NULL == fhMsSz[ component ] ) - - Int_t messageType = -111; - // Loop over microslices - size_t numCompMsInTs = ts.num_microslices(component); - for (size_t m = 0; m < numCompMsInTs; ++m) - { - // Ignore overlap ms if number defined by user - if( numCompMsInTs - fuOverlapMsNb <= m ) - continue; - - constexpr uint32_t kuBytesPerMessage = 8; - - auto msDescriptor = ts.descriptor(component, m); - fEquipmentId = msDescriptor.eq_id; - const uint8_t* msContent = reinterpret_cast<const uint8_t*>(ts.content(component, m)); - - uint32_t size = msDescriptor.size; - LOG(debug) << "Microslice: " << msDescriptor.idx - << " has size: " << size; - - if( component < kiMaxNbFlibLinks ) - { - if( fdStartTimeMsSz < 0 ) - fdStartTimeMsSz = (1e-9) * static_cast<double>(msDescriptor.idx); - fhMsSz[ component ]->Fill( size ); - fhMsSzTime[ component ]->Fill( (1e-9) * static_cast<double>( msDescriptor.idx) - fdStartTimeMsSz, size); - } - - // If not integer number of message in input buffer, print warning/error - if( 0 != (size % kuBytesPerMessage) ) - LOG(error) << "The input microslice buffer does NOT " - << "contain only complete nDPB messages!"; - - // Compute the number of complete messages in the input microslice buffer - uint32_t uNbMessages = (size - (size % kuBytesPerMessage) ) - / kuBytesPerMessage; - - // Prepare variables for the loop on contents - const uint64_t* pInBuff = reinterpret_cast<const uint64_t*>( msContent ); - UInt_t uNdpbIdx; - UInt_t uFebBase; - for (uint32_t uIdx = 0; uIdx < uNbMessages; uIdx ++) - { - // Fill message - uint64_t ulData = static_cast<uint64_t>( pInBuff[uIdx] ); - ngdpb::Message mess( ulData ); - - if( 0 == uIdx ) - { - Int_t rocId = mess.getRocNumber(); - // First check if nDPB is mapped - if( fNdpbIdIndexMap.end() == fNdpbIdIndexMap.find( rocId ) ) - { - LOG(fatal) << "Unmapped nDPB Id " << std::hex << rocId << std::dec; - } // if( fNdpbIdIndexMap.end() == fNdpbIdIndexMap.find( rocId ) ) - uNdpbIdx = fNdpbIdIndexMap[rocId]; - uFebBase = uNdpbIdx * fUnpackPar->GetNrOfFebsPerNdpb(); - } // if( 0 == uIdx ) - - if(gLogger->IsLogNeeded( fair::Severity::debug )) { - mess.printDataCout(); - } - - // Increment counter for different message types - // and fill the corresponding histogram - messageType = mess.getMessageType(); - fMsgCounter[messageType]++; - fHistMessType->Fill(messageType); - - switch( messageType ) { - case ngdpb::MSG_HIT: - FillHitInfo(mess, uNdpbIdx, uFebBase); - break; - case ngdpb::MSG_EPOCH: - FillEpochInfo(mess, uNdpbIdx, uFebBase); - break; - case ngdpb::MSG_SYNC: - // Do nothing, this message is just there to make sure we get all Epochs - break; - case ngdpb::MSG_SYS: - // Just keep track of which type of System message we receive - fHistSysMessType->Fill(mess.getSysMesType()); - break; - default: - LOG(error) << "Message type " << std::hex << std::setw(2) - << static_cast< uint16_t >( mess.getMessageType() ) - << " not yet include in nXYTER unpacker."; - } - - - - } // for (uint32_t uIdx = 0; uIdx < uNbMessages; uIdx ++) - - } - - - return kTRUE; -} - -void CbmTSMonitorMuch::FillHitInfo(ngdpb::Message mess, UInt_t /*uNdpbIdx*/, UInt_t uFebBase) -{ - // --- Get absolute time, NXYTER and channel number - Int_t rocId = mess.getRocNumber(); - Int_t nxyterId = mess.getNxNumber(); - Int_t nxChannel = mess.getNxChNum(); - Int_t charge = mess.getNxAdcValue(); - - LOG(debug) << "Hit: " << rocId << ", " << nxyterId - << ", " << nxChannel << ", " << charge; - - //here converting channel number into the MUCH Digi. - -/* - Int_t address = CreateAddress(uFebBase,nxyterId,0, 0, 0, 0, nxChannel); - if (address){ - LOG(debug) << "Got address for hit"; - } - else { - LOG(error) << "Unknown Roc Id " << rocId << " or nxyterId "<< nxyterId << " or channelId " - << nxChannel; - } -*/ - Int_t channelNr = uFebBase + nxyterId; - fChan_Counts_Much[channelNr]->Fill(nxChannel); - fRaw_ADC_Much[channelNr]->Fill(nxChannel, charge); - fHistPadDistr->Fill(nxChannel,charge); - - if( fCurrentEpoch.end() != fCurrentEpoch.find( rocId ) ) { - if( fCurrentEpoch[rocId].end() != fCurrentEpoch[rocId].find( nxyterId ) ) { - Double_t dHitFullTime = mess.getMsgFullTimeD( fCurrentEpoch[rocId][nxyterId] ); - - if( fdStartTime <= 0 ) - { - fdStartTime = dHitFullTime; - - LOG(info) << "Start time set to " << (fdStartTime/1e9) - << " s using first hit on channel " << nxChannel - << " of FEB " << nxyterId - << " on nDPB " << fNdpbIdIndexMap[rocId] - << " in epoch " << fCurrentEpoch[rocId][nxyterId]; - } - - if( 0 < fdStartTime ) - { - fFebRate[channelNr]->Fill( 1e-9*( dHitFullTime - fdStartTime) ); - - // General Time (date + time) rate evolution - // Add offset of -1H as the filenames were using some times offset by 1 hour (Summer time?!?) - if( 0 < fiBinSizeDatePlots && 0 < fiRunStartDateTimeSec ) - { - fFebRateDate_nDPB[channelNr]->Fill( - 1e-9 * ( dHitFullTime - fdStartTime ) + fiRunStartDateTimeSec ); - if( 0 < fdLastHitTime_nDPB[ channelNr ] ) - fHitDtDate_nDPB[ channelNr ]->Fill( - 1e-9 * ( dHitFullTime - fdStartTime ) + fiRunStartDateTimeSec, - 1e9/( dHitFullTime - fdLastHitTime_nDPB[ channelNr ] ) - ); - fdLastHitTime_nDPB[ channelNr ] = dHitFullTime; - } // if( 0 < fiBinSizeDatePlots && 0 < fiRunStartDateTimeSec ) - } - } - } - -} - -Int_t CbmTSMonitorMuch::CreateAddress(Int_t febBase, Int_t febId, Int_t stationId, - Int_t layerId, Int_t sideId, Int_t moduleId, Int_t channelId) -{ - Int_t febNr = febBase + febId; - Int_t sector = fUnpackPar->GetPadX(febNr, channelId); - Int_t channel = fUnpackPar->GetPadY(febNr, channelId); - - Int_t address = CbmMuchAddress::GetAddress(stationId, layerId, sideId, moduleId, sector, channel); - if(!(sector<0||channel<0)){ - - fHistPadDistr->Fill(78-sector,22-channel); - - } -// fHM->H2("Pad_Distribution")->Fill(sector,channel); - - return address; -} - -void CbmTSMonitorMuch::FillEpochInfo(ngdpb::Message mess, UInt_t /*uNdpbIdx*/, UInt_t uFebBase) -{ - Int_t rocId = mess.getRocNumber(); - Int_t nxyterId = mess.getEpochNxNum(); - - UInt_t uEpochVal = mess.getEpochNumber(); - fCurrentEpoch[rocId][nxyterId] = uEpochVal; - fCurrentEpochTime = mess.getMsgFullTimeD( uEpochVal ); - - if( fdStartTime <= 0 ) - { - Int_t channelNr = uFebBase + nxyterId; - fHitMissEvo[channelNr]->Fill( fCurrentEpochTime - fdStartTime, mess.getEpochMissed() ); - } - - fNofEpochs++; - LOG(debug) << "Epoch message " - << fNofEpochs << ", epoch " << uEpochVal - << ", time " << std::setprecision(9) << std::fixed - << fCurrentEpochTime * 1.e-9 << " s " - << " for board ID " << std::hex << std::setw(4) << rocId << std::dec; -} - -void CbmTSMonitorMuch::Reset() -{ -} - -void CbmTSMonitorMuch::Finish() -{ - TString message_type; - - for (unsigned int i=0; i< fMsgCounter.size(); ++i) { - switch(i) { - case 0: message_type ="NOP"; break; - case 1: message_type ="HIT"; break; - case 2: message_type ="EPOCH"; break; - case 3: message_type ="SYNC"; break; - case 4: message_type ="AUX"; break; - case 5: message_type ="EPOCH2"; break; - case 6: message_type ="GET4"; break; - case 7: message_type ="SYS"; break; - case 8: message_type ="GET4_SLC"; break; - case 9: message_type ="GET4_32B"; break; - case 10: message_type ="GET4_SYS"; break; - } - LOG(info) << message_type << " messages: " - << fMsgCounter[i]; - } - - LOG(info) << "-------------------------------------"; - for( auto it = fCurrentEpoch.begin(); it != fCurrentEpoch.end(); ++it) - for( auto itN = (it->second).begin(); itN != (it->second).end(); ++itN) - LOG(info) << "Last epoch for nDPB: " - << std::hex << std::setw(4) << it->first << std::dec - << " , FEB " << std::setw(4) << itN->first - << " => " << itN->second; - LOG(info) << "-------------------------------------"; - - gDirectory->mkdir("Much_Raw"); - gDirectory->cd("Much_Raw"); - - TString sNdpbTag(""); - for( Int_t dpbId = 0; dpbId < fNrOfNdpbs; dpbId++) - {// looping on all the nDPBS IDs - if( dpbId < fUnpackPar->GetNrOfnDpbsModA() ) - { - sNdpbTag = Form("%04X", fUnpackPar->GetNdpbIdA(dpbId) ); - } // if( dpbId < fUnpackPar->GetNrOfnDpbsModA() ) - else - { - sNdpbTag = Form("%04X", fUnpackPar->GetNdpbIdB(dpbId - fNrOfNdpbsA) ); - } // else of if( dpbId < fUnpackPar->GetNrOfnDpbsModA() ) - for( Int_t febId = 0; febId < fNrOfFebsPerNdpb; febId++) - {// looping on all the FEB IDs - fHM->H1( Form("Chan_Counts_Much_n%s_f%1u", sNdpbTag.Data(), febId) )->Write(); - fHM->H2( Form("Raw_ADC_Much_n%s_f%1u", sNdpbTag.Data(), febId) )->Write(); - fHM->H1( Form("FebRate_n%s_f%1u", sNdpbTag.Data(), febId) )->Write(); - fHM->H1( Form("HitMissEvo_n%s_f%1u", sNdpbTag.Data(), febId) )->Write(); - if( 0 < fiBinSizeDatePlots && 0 < fiRunStartDateTimeSec ) - { - fHM->H1( Form("FebRateDate_n%s_f%1u", sNdpbTag.Data(), febId) )->Write(); - fHM->H2( Form("HitDtDate_n%s_f%1u", sNdpbTag.Data(), febId) )->Write(); - } // if( 0 < fiBinSizeDatePlots && 0 < fiRunStartDateTimeSec ) - } // for( Int_t febId = 0; febId < fNrOfFebsPerNdpb; febId++) - } // for( Int_t dpbId = 0; dpbId < fNrOfNdpbs; dpbId++) - fHM->H2("Pad_Distribution")->Write(); - gDirectory->cd(".."); - - gDirectory->mkdir("Flib_Raw"); - gDirectory->cd("Flib_Raw"); - for( UInt_t uLinks = 0; uLinks < kiMaxNbFlibLinks; uLinks ++) - { - TString sMsSzName = Form("MsSz_link_%02u", uLinks); - if( fHM->Exists(sMsSzName.Data() ) ) - fHM->H1( sMsSzName.Data() )->Write(); - - sMsSzName = Form("MsSzTime_link_%02u", uLinks); - if( fHM->Exists(sMsSzName.Data() ) ) - fHM->P1( sMsSzName.Data() )->Write(); - } // for( UInt_t uLinks = 0; uLinks < 16; uLinks ++) - gDirectory->cd(".."); - -} - - -void CbmTSMonitorMuch::FillOutput(boost::any) -{ -} - -void CbmTSMonitorMuch::ResetAllHistos() -{ - LOG(info) << "Reseting all MUCH histograms."; - fHM->H1("hMessageTypeMuch")->Reset(); - fHM->H1("hSysMessTypeMuch")->Reset(); - - TString sNdpbTag(""); - for( Int_t dpbId = 0; dpbId < fNrOfNdpbs; dpbId++) - {// looping on all the nDPBS IDs - if( dpbId < fUnpackPar->GetNrOfnDpbsModA() ) - { - sNdpbTag = Form("%04X", fUnpackPar->GetNdpbIdA(dpbId) ); - } // if( dpbId < fUnpackPar->GetNrOfnDpbsModA() ) - else - { - sNdpbTag = Form("%04X", fUnpackPar->GetNdpbIdB(dpbId - fNrOfNdpbsA) ); - } // else of if( dpbId < fUnpackPar->GetNrOfnDpbsModA() ) - for( Int_t febId = 0; febId < fNrOfFebsPerNdpb; febId++) - {// looping on all the FEB IDs - fHM->H1( Form("Chan_Counts_Much_n%s_f%1u", sNdpbTag.Data(), febId) )->Reset(); - fHM->H2( Form("Raw_ADC_Much_n%s_f%1u", sNdpbTag.Data(), febId) )->Reset(); - fHM->H1( Form("FebRate_n%s_f%1u", sNdpbTag.Data(), febId) )->Reset(); - fHM->H1( Form("HitMissEvo_n%s_f%1u", sNdpbTag.Data(), febId) )->Reset(); - if( 0 < fiBinSizeDatePlots && 0 < fiRunStartDateTimeSec ) - { - fHM->H1( Form("FebRateDate_n%s_f%1u", sNdpbTag.Data(), febId) )->Reset(); - fHM->H2( Form("HitDtDate_n%s_f%1u", sNdpbTag.Data(), febId) )->Reset(); - } // if( 0 < fiBinSizeDatePlots && 0 < fiRunStartDateTimeSec ) - } // for( Int_t febId = 0; febId < fNrOfFebsPerNdpb; febId++) - } // for( Int_t dpbId = 0; dpbId < fNrOfNdpbs; dpbId++) - fHM->H2("Pad_Distribution")->Write(); - - for (UInt_t uLinks = 0; uLinks < kiMaxNbFlibLinks; uLinks++) { - TString sMsSzName = Form("MsSz_link_%02u", uLinks); - if (fHM->Exists(sMsSzName.Data())) - fHM->H1(sMsSzName.Data())->Reset(); - - sMsSzName = Form("MsSzTime_link_%02u", uLinks); - if (fHM->Exists(sMsSzName.Data())) - fHM->P1(sMsSzName.Data())->Reset(); - } // for( UInt_t uLinks = 0; uLinks < 16; uLinks ++) - - fdStartTime = -1; -} - -void CbmTSMonitorMuch::SetRunStart( Int_t dateIn, Int_t timeIn, Int_t iBinSize ) -{ - TDatime * fRunStartDateTime = new TDatime( dateIn, timeIn); - fiRunStartDateTimeSec = fRunStartDateTime->Convert(); - fiBinSizeDatePlots = iBinSize; - - LOG(info) << "Assigned new MUCH Run Start Date-Time: " << fRunStartDateTime->AsString(); -} - -ClassImp(CbmTSMonitorMuch) diff --git a/beamtime/cern2016/unpacker/CbmTSMonitorMuch.h b/beamtime/cern2016/unpacker/CbmTSMonitorMuch.h deleted file mode 100644 index 74b7b1cbf1b5339bdb37552893a50c98f13f026a..0000000000000000000000000000000000000000 --- a/beamtime/cern2016/unpacker/CbmTSMonitorMuch.h +++ /dev/null @@ -1,113 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmTSMonitorMuch ----- -// ----- Created 11.11.2016 by V. Singhal and A. Kumar ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CbmTSMonitorMuch_H -#define CbmTSMonitorMuch_H - -#include "Timeslice.hpp" -#include "rocMess_wGet4v1.h" - -#include "CbmTSUnpack.h" -#include "CbmHistManager.h" - -#include <vector> -#include <map> - -class CbmMuchUnpackPar; // Unpaker Class which will read the MuchUnpackPar.par - -class CbmTSMonitorMuch: public CbmTSUnpack -{ -public: - - CbmTSMonitorMuch(); - virtual ~CbmTSMonitorMuch(); - - virtual Bool_t Init(); - - virtual Bool_t DoUnpack(const fles::Timeslice& ts, size_t component); - - virtual void Reset(); - - virtual void Finish(); - - void SetParContainers(); - - Bool_t InitContainers(); - - Bool_t ReInitContainers(); - - void FillOutput(boost::any); - - void SetRunStart( Int_t dateIn, Int_t timeIn, Int_t iBinSize = 5 ); - - void ResetAllHistos(); - - void SetMsOverlap(size_t uOverlapMsNb = 1) { fuOverlapMsNb = uOverlapMsNb; } - size_t GetMsOverlap() { return fuOverlapMsNb; } - -private: - size_t fuOverlapMsNb; /** Ignore Overlap Ms: all fuOverlapMsNb MS at the end of timeslice **/ - - Int_t fNrOfNdpbs; // Total number of NDPBs in the system - Int_t fNrOfNdpbsA; // Total number of NDPBs for GEM A - Int_t fNrOfNdpbsB; // Total number of NDPBs for GEM B - Int_t fNrOfFebsPerNdpb; // Number of FEBs per NDPB - - std::vector<int> fMsgCounter; - std::map<UInt_t, UInt_t> fNdpbIdIndexMap; - - Int_t fMuchStationMapX[16][128]; //fMuchStationMap for map of row number via getX - Int_t fMuchStationMapY[16][128]; // For map of column number via getY> - - CbmHistManager* fHM; ///< Histogram manager - - std::map<Int_t, std::map<Int_t, UInt_t> > fCurrentEpoch; // Current epoch (first epoch in the stream initialises the map item) - Int_t fNofEpochs; /** Current epoch marker for each ROC **/ - Double_t fCurrentEpochTime; /** Time stamp of current epoch **/ - Double_t fdStartTime; /** Time of first valid hit (epoch available), used as reference for evolution plots**/ - Double_t fdStartTimeMsSz; /** Time of first microslice, used as reference for evolution plots**/ - TCanvas* fcMsSizeAll; - - Int_t fEquipmentId; - - CbmMuchUnpackPar* fUnpackPar; //! - - std::vector<TH1*> fFebRateDate_nDPB; - std::vector<TH2*> fHitDtDate_nDPB; - std::vector<Double_t> fdLastHitTime_nDPB; - Int_t fiRunStartDateTimeSec; - Int_t fiBinSizeDatePlots; - - TH1* fHistMessType; - TH1* fHistSysMessType; - - std::vector<TH1*> fChan_Counts_Much; - std::vector<TH2*> fRaw_ADC_Much; - std::vector<TH1*> fFebRate; - std::vector<TH1*> fHitMissEvo; - - TH2* fHistPadDistr; - - static const Int_t kiMaxNbFlibLinks = 16; - TH1* fhMsSz[kiMaxNbFlibLinks]; - TProfile* fhMsSzTime[kiMaxNbFlibLinks]; - - void CreateHistograms(); - - void FillHitInfo(ngdpb::Message, UInt_t uNdpbIdx, UInt_t uFebBase); - void FillEpochInfo(ngdpb::Message, UInt_t uNdpbIdx, UInt_t uFebBase); - - Int_t CreateAddress(Int_t febBase, Int_t febId, Int_t stationId, Int_t layerId, Int_t sideId, - Int_t moduleId, Int_t channelId); - - CbmTSMonitorMuch(const CbmTSMonitorMuch&); - CbmTSMonitorMuch operator=(const CbmTSMonitorMuch&); - - ClassDef(CbmTSMonitorMuch, 1) -}; - -#endif diff --git a/beamtime/cern2016/unpacker/CbmTSMonitorTof.cxx b/beamtime/cern2016/unpacker/CbmTSMonitorTof.cxx deleted file mode 100644 index 77ad192ef611abb2c9c83af3f2cfeccd12e40877..0000000000000000000000000000000000000000 --- a/beamtime/cern2016/unpacker/CbmTSMonitorTof.cxx +++ /dev/null @@ -1,1214 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmTSMonitorTof ----- -// ----- Created 27.10.2016 by P.-A. Loizeau ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#include "CbmTSMonitorTof.h" -#include "CbmTofUnpackPar.h" - -#include "CbmFlibCern2016Source.h" -#include "CbmHistManager.h" - -#include "FairLogger.h" -#include "FairRootManager.h" -#include "FairRun.h" -#include "FairRuntimeDb.h" -#include "FairRunOnline.h" - -#include "TClonesArray.h" -#include "TString.h" -#include "THttpServer.h" -#include "Rtypes.h" -#include "TH1.h" -#include "TCanvas.h" -#include "THStack.h" -#include "TROOT.h" -#include "TStyle.h" -#include "TPaveStats.h" -#include "TDatime.h" - -#include <iostream> -#include <stdint.h> -#include <iomanip> - -static Int_t iMess = 0; -Bool_t bResetTofHistos = kFALSE; - - -CbmTSMonitorTof::CbmTSMonitorTof() : - CbmTSUnpack(), - fuMsAcceptsPercent(100), - fuOverlapMsNb(0), - fuMinNbGdpb(), - fuCurrNbGdpb(0), - fNrOfGdpbs(0), - fNrOfFebsPerGdpb(0), - fNrOfGet4PerFeb(0), - fNrOfChannelsPerGet4(0), - fNrOfGet4(0), - fNrOfGet4PerGdpb(0), - fDiamondGdpb(0), - fDiamondFeet(0), - fDiamondChanA(0), - fDiamondChanB(0), - fDiamondChanC(0), - fDiamondChanD(0), - fDiamondTimeLastReset(-1), - fiDiamCountsLastTs(0), - fiDiamSpillOnThr(10), - fiDiamSpillOffThr(3), - fiTsUnderOff(0), - fiTsUnderOffThr(10), - fdDiamondLastTime(-1.), - fdDiamondTimeLastTs(-1.), - fbSpillOn(kFALSE), - fSpillIdx(0), - fbBeamTuningMode( kFALSE), - fbEpochSuppModeOn(kFALSE), - fvmEpSupprBuffer(), - fGdpbId(0), - fGdpbNr(0), - fGet4Id(0), - fGet4Nr(0), - fMsgCounter(11, 0), // length of enum MessageTypes initialized with 0 - fGdpbIdIndexMap(), - fHM(new CbmHistManager()), - fCurrentEpoch(NULL), - fNofEpochs(0), - fCurrentEpochTime(0.), - fdStartTime(-1.), - fdStartTimeMsSz(-1.), - fcMsSizeAll(NULL), - fTsLastHit(), - fEquipmentId(0), - fUnpackPar(NULL), - fHistMessType(NULL), - fHistSysMessType(NULL), - fHistGet4MessType(NULL), - fHistGet4ChanErrors(NULL), - fHistGet4EpochFlags(NULL), - fHistDiamond(NULL), - fHistDiamondSpill(NULL), - fHistDiamondSpillLength(NULL), - fHistDiamondSpillCount(NULL), - fHistDiamondSpillQA(NULL), - fRaw_Tot_gDPB(), - fChCount_gDPB(), - fChannelRate_gDPB(), - fFeetRate_gDPB(), - fFeetRateDate_gDPB(), - fiRunStartDateTimeSec( -1 ), - fiBinSizeDatePlots( -1 ) -{ -} - -CbmTSMonitorTof::~CbmTSMonitorTof() -{ - delete fHM; //TODO: Who deletes the histograms stored in the CbmHistManager??? - delete[] fCurrentEpoch; -} - -Bool_t CbmTSMonitorTof::Init() -{ - LOG(info) << "Initializing Get4 monitor"; - - FairRootManager* ioman = FairRootManager::Instance(); - if (ioman == NULL) { - LOG(fatal) << "No FairRootManager instance"; - } - - return kTRUE; -} - -void CbmTSMonitorTof::SetParContainers() -{ - LOG(info) << "Setting parameter containers for " << GetName(); - fUnpackPar = - (CbmTofUnpackPar*) (FairRun::Instance()->GetRuntimeDb()->getContainer( - "CbmTofUnpackPar")); - -} - -Bool_t CbmTSMonitorTof::InitContainers() -{ - LOG(info) << "Init parameter containers for " << GetName(); - Bool_t initOK = ReInitContainers(); - - CreateHistograms(); - - fCurrentEpoch = new Int_t[fNrOfGdpbs * fNrOfGet4PerGdpb]; - for (UInt_t i = 0; i < fNrOfGdpbs; ++i) { - for (UInt_t j = 0; j < fNrOfGet4PerGdpb; ++j) { - fCurrentEpoch[GetArrayIndex(i, j)] = -111; - } - } - - return initOK; -} - -Bool_t CbmTSMonitorTof::ReInitContainers() -{ - LOG(info) << "ReInit parameter containers for " << GetName(); - - fNrOfGdpbs = fUnpackPar->GetNrOfRocs(); - LOG(info) << "Nr. of Tof GDPBs: " << fNrOfGdpbs; - fuMinNbGdpb = fNrOfGdpbs; - - fNrOfFebsPerGdpb = fUnpackPar->GetNrOfFebsPerGdpb(); - LOG(info) << "Nr. of FEBS per Tof GDPB: " << fNrOfFebsPerGdpb; - - fNrOfGet4PerFeb = fUnpackPar->GetNrOfGet4PerFeb(); - LOG(info) << "Nr. of GET4 per Tof FEB: " << fNrOfGet4PerFeb; - - fNrOfChannelsPerGet4 = fUnpackPar->GetNrOfChannelsPerGet4(); - LOG(info) << "Nr. of channels per GET4: " << fNrOfChannelsPerGet4; - - fNrOfGet4 = fNrOfGdpbs * fNrOfFebsPerGdpb * fNrOfGet4PerFeb; - LOG(info) << "Nr. of GET4s: " << fNrOfGet4; - - fNrOfGet4PerGdpb = fNrOfFebsPerGdpb * fNrOfGet4PerFeb; - LOG(info) << "Nr. of GET4s per GDPB: " << fNrOfGet4PerGdpb; - - fGdpbIdIndexMap.clear(); - for (UInt_t i = 0; i < fNrOfGdpbs; ++i) { - fGdpbIdIndexMap[fUnpackPar->GetRocId(i)] = i; - LOG(info) << "GDPB Id of TOF " << i << " : " << fUnpackPar->GetRocId(i); - } - UInt_t NrOfChannels = fUnpackPar->GetNumberOfChannels(); - LOG(info) << "Nr. of mapped Tof channels: " << NrOfChannels; - std::stringstream ss; - for (UInt_t i = 0; i< NrOfChannels; ++i) { - if(i%8 == 0) - ss << "\n"; - ss << Form(" 0x%08x",fUnpackPar->GetChannelToDetUIdMap(i)); - } - LOG(info) << ss.str(); - - LOG(info) << "Plot Channel Rate => " - << (fUnpackPar->IsChannelRateEnabled() ? "ON" : "OFF"); - - if( fbEpochSuppModeOn ) - fvmEpSupprBuffer.resize( fNrOfGet4 ); - - return kTRUE; -} - -void CbmTSMonitorTof::CreateHistograms() -{ - THttpServer* server = FairRunOnline::Instance()->GetHttpServer(); -// server->SetJSROOT("https://root.cern.ch/js/latest"); - - TString name { "" }; - TString title { "" }; - - name = "hMessageType"; - title = "Nb of message for each type; Type"; - // Test Big Data readout with plotting - TH1I* hMessageType = new TH1I(name, title, 16, 0., 16.); - // TH1I* hMessageType = new TH1I(name, title, 16, -0.5, 15.5); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_NOP, "NOP"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_HIT, "HIT"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_EPOCH, "EPOCH"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_SYNC, "SYNC"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_AUX, "AUX"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_EPOCH2, "EPOCH2"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_GET4, "GET4"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_SYS, "SYS"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_GET4_SLC, - "MSG_GET4_SLC"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_GET4_32B, - "MSG_GET4_32B"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_GET4_SYS, - "MSG_GET4_SYS"); - hMessageType->GetXaxis()->SetBinLabel(1 + 15, "GET4 Hack 32B"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_NOP, "NOP"); - fHM->Add(name.Data(), hMessageType); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - - name = "hSysMessType"; - title = "Nb of system message for each type; System Type"; - TH1I* hSysMessType = new TH1I(name, title, 17, 0., 17.); -// TH1I* hSysMessType = new TH1I(name, title, 17, -0.5, 16.5); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_START, - "DAQ START"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_FINISH, - "DAQ FINISH"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_NX_PARITY, - "NX PARITY"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_SYNC_PARITY, - "SYNC PARITY"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_RESUME, - "DAQ RESUME"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_FIFO_RESET, - "FIFO RESET"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_USER, "USER"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_PCTIME, "PCTIME"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_ADC, "ADC"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_PACKETLOST, - "PACKET LOST"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_GET4_EVENT, - "GET4 ERROR"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_CLOSYSYNC_ERROR, - "CLOSYSYNC ERROR"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_TS156_SYNC, - "TS156 SYNC"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_GDPB_UNKWN, - "UNKW GET4 MSG"); - hSysMessType->GetXaxis()->SetBinLabel(1 + 16, "GET4 Hack 32B"); - fHM->Add(name.Data(), hSysMessType); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - - name = "hGet4MessType"; - title = "Nb of message for each type per GET4; GET4 chip # ; Type"; - TH2I* hGet4MessType = new TH2I(name, title, fNrOfGet4, 0., fNrOfGet4, 5, 0., - 5.); -// TH2I* hGet4MessType = new TH2I(name, title, uNbFeets*feetv1::kuChipPerFeet, -0.5, uNbFeets*feetv1::kuChipPerFeet -0.5, 5, -0.5, 4.5); - hGet4MessType->GetYaxis()->SetBinLabel(1 + ngdpb::GET4_32B_EPOCH, "EPOCH"); - hGet4MessType->GetYaxis()->SetBinLabel(1 + ngdpb::GET4_32B_SLCM, "S.C. M"); - hGet4MessType->GetYaxis()->SetBinLabel(1 + ngdpb::GET4_32B_ERROR, "ERROR"); - hGet4MessType->GetYaxis()->SetBinLabel(1 + ngdpb::GET4_32B_DATA, "DATA 32b"); - hGet4MessType->GetYaxis()->SetBinLabel(1 + ngdpb::GET4_32B_DATA + 1, - "DATA 24b"); - fHM->Add(name.Data(), hGet4MessType); - if (server) - server->Register("/TofRaw", fHM->H2(name.Data())); - - name = "hGet4ChanErrors"; - title = "Error messages per GET4 channel; GET4 channel # ; Error"; - TH2I* hGet4ChanErrors = new TH2I(name, title, - fNrOfGet4 * fNrOfChannelsPerGet4, 0., fNrOfGet4 * fNrOfChannelsPerGet4, - 32, 0., 32.); -// TH2I* hGet4ChanErrors = new TH2I(name, title, uNbFeets*feetv1::kuChanPerFeet*2, -0.5, uNbFeets*feetv1::kuChanPerFeet -0.5, 32, -0.5, 31.5); - hGet4ChanErrors->GetYaxis()->SetBinLabel(1, "0x00: Readout Init "); - hGet4ChanErrors->GetYaxis()->SetBinLabel(2, "0x01: Sync "); - hGet4ChanErrors->GetYaxis()->SetBinLabel(3, "0x02: Epoch count sync"); - hGet4ChanErrors->GetYaxis()->SetBinLabel(4, "0x03: Epoch "); - hGet4ChanErrors->GetYaxis()->SetBinLabel(5, "0x04: FIFO Write "); - hGet4ChanErrors->GetYaxis()->SetBinLabel(6, "0x05: Lost event "); - hGet4ChanErrors->GetYaxis()->SetBinLabel(7, "0x06: Channel state "); - hGet4ChanErrors->GetYaxis()->SetBinLabel(8, "0x07: Token Ring state"); - hGet4ChanErrors->GetYaxis()->SetBinLabel(9, "0x08: Token "); - hGet4ChanErrors->GetYaxis()->SetBinLabel(10, "0x09: Error Readout "); - hGet4ChanErrors->GetYaxis()->SetBinLabel(11, "0x0a: SPI "); - hGet4ChanErrors->GetYaxis()->SetBinLabel(12, "0x0b: DLL Lock error "); // <- From GET4 v1.2 - hGet4ChanErrors->GetYaxis()->SetBinLabel(13, "0x0c: DLL Reset invoc."); // <- From GET4 v1.2 - hGet4ChanErrors->GetYaxis()->SetBinLabel(14, "0x11: Overwrite "); - hGet4ChanErrors->GetYaxis()->SetBinLabel(15, "0x12: ToT out of range"); - hGet4ChanErrors->GetYaxis()->SetBinLabel(16, "0x13: Event Discarded "); - hGet4ChanErrors->GetYaxis()->SetBinLabel(17, "0x7f: Unknown "); - hGet4ChanErrors->GetYaxis()->SetBinLabel(18, - "Corrupt error or unsupported yet"); - fHM->Add(name.Data(), hGet4ChanErrors); - if (server) - server->Register("/TofRaw", fHM->H2(name.Data())); - - name = "hGet4EpochFlags"; - title = "Epoch flags per GET4; GET4 chip # ; Type"; - TH2I* hGet4EpochFlags = new TH2I(name, title, fNrOfGet4, 0., fNrOfGet4, 4, 0., - 4.); -// hEpochFlags = new TH2I(name, title, uNbFeets*feetv1::kuChipPerFeet, -0.5, uNbFeets*feetv1::kuChipPerFeet -0.5, 4, -0.5, 3.5); - hGet4EpochFlags->GetYaxis()->SetBinLabel(1, "SYNC"); - hGet4EpochFlags->GetYaxis()->SetBinLabel(2, "Ep LOSS"); - hGet4EpochFlags->GetYaxis()->SetBinLabel(3, "Da LOSS"); - hGet4EpochFlags->GetYaxis()->SetBinLabel(4, "MISSMAT"); - fHM->Add(name.Data(), hGet4EpochFlags); - if (server) - server->Register("/TofRaw", fHM->H2(name.Data())); - - if (fUnpackPar->IsChannelRateEnabled()) { - for (UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; uGdpb++) { - const Int_t iNbBinsRate = 82; - Double_t dBinsRate[iNbBinsRate] = { 1e0, 2e0, 3e0, 4e0, 5e0, 6e0, 7e0, - 8e0, 9e0, 1e1, 2e1, 3e1, 4e1, 5e1, 6e1, 7e1, 8e1, 9e1, 1e2, 2e2, 3e2, - 4e2, 5e2, 6e2, 7e2, 8e2, 9e2, 1e3, 2e3, 3e3, 4e3, 5e3, 6e3, 7e3, 8e3, - 9e3, 1e4, 2e4, 3e4, 4e4, 5e4, 6e4, 7e4, 8e4, 9e4, 1e5, 2e5, 3e5, 4e5, - 5e5, 6e5, 7e5, 8e5, 9e5, 1e6, 2e6, 3e6, 4e6, 5e6, 6e6, 7e6, 8e6, 9e6, - 1e7, 2e7, 3e7, 4e7, 5e7, 6e7, 7e7, 8e7, 9e7, 1e8, 2e8, 3e8, 4e8, 5e8, - 6e8, 7e8, 8e8, 9e8, 1e9 }; - name = Form("ChannelRate_gDPB_%02u", uGdpb); - title = Form("Channel instant rate gDPB %02u; Dist[ns] ; Channel", uGdpb); - fHM->Add(name.Data(), - new TH2F(name.Data(), title.Data(), iNbBinsRate - 1, dBinsRate, 96, 0, - 96)); - if (server) - server->Register("/TofRaw", fHM->H2(name.Data())); - LOG(info) << "Adding the rate histos"; - } // for( UInt_t uGdpb = 0; uGdpb < fuMinNbGdpb; uGdpb ++) - } - - for (UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; uGdpb++) { - name = Form("Raw_Tot_gDPB_%02u", uGdpb); - title = Form("Raw TOT gDPB %02u; channel; TOT [bin]", uGdpb); - fHM->Add(name.Data(), - new TH2F(name.Data(), title.Data(), 96, 0, 96, 256, 0, 256)); - if (server) - server->Register("/TofRaw", fHM->H2(name.Data())); - - name = Form("ChCount_gDPB_%02u", uGdpb); - title = Form("Channel counts gDPB %02u; channel; Hits", uGdpb); - fHM->Add(name.Data(), new TH1I(name.Data(), title.Data(), 96, 0, 96)); - - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - - for (UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; uFeet++) { - name = Form("FeetRate_gDPB_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "Counts per second in Feet %1u of gDPB %02u; Time[s] ; Counts", uFeet, - uGdpb); - fHM->Add(name.Data(), new TH1F(name.Data(), title.Data(), 1800, 0, 1800)); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - if( 0 < fiBinSizeDatePlots && 0 < fiRunStartDateTimeSec ) { - name = Form("FeetRateDate_gDPB_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "Counts per second in Feet %1u of gDPB %02u; Time[s] ; Counts", uFeet, - uGdpb); - fHM->Add(name.Data(), new TH1F(name.Data(), title.Data(), (5400 / fiBinSizeDatePlots), -10, 5400 - 10)); - ( fHM->H1(name.Data()) )->GetXaxis()->SetTimeDisplay(1); - ( fHM->H1(name.Data()) )->GetXaxis()->SetTimeOffset( fiRunStartDateTimeSec ); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - } // if( 0 < fiBinSizeDatePlots && 0 < fiRunStartDateTimeSec ) - } // for( UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; uFeet ++) - } // for( UInt_t uGdpb = 0; uGdpb < fuMinNbGdpb; uGdpb ++) - - name = "hDiamond"; - title = "Counts per diamond in last 10s; X [pad]; Y [pad]; Counts"; - TH2I* hDiamond = new TH2I(name, title, 2, 0., 2, 2, 0., 2.); - fHM->Add(name.Data(), hDiamond); - if (server) - server->Register("/TofRaw", fHM->H2(name.Data())); - - name = "hDiamondSpill"; - title = "Counts per diamond in Current Spill; X [pad]; Y [pad]; Counts"; - TH2I* hDiamondSpill = new TH2I(name, title, 2, 0., 2, 2, 0., 2.); - fHM->Add(name.Data(), hDiamondSpill); - if (server) - server->Register("/TofRaw", fHM->H2(name.Data())); - - name = "hDiamondSpillLength"; - title = "Length of spill interval as found from diamond; Length [s]; Counts"; - TH1* hDiamondSpillLength = new TH1F(name, title, 3000, 0., 300.); - fHM->Add(name.Data(), hDiamondSpillLength); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - - name = "hDiamondSpillCount"; - title = "Total counts in diamond in each spill; Spill; Counts"; - TH1* hDiamondSpillCount = new TH1F(name, title, 300, 0., 300.); - fHM->Add(name.Data(), hDiamondSpillCount); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - - name = "hDiamondSpillQA"; - title = "Total counts in diamond per spill VS Spill length; Length [s]; Counts"; - TH2* hDiamondSpillQA = new TH2F(name, title, 120, 0., 120., 150, 0., 150000.); - fHM->Add(name.Data(), hDiamondSpillQA); - if (server) - server->Register("/TofRaw", fHM->H2(name.Data())); - - if (server) - server->RegisterCommand("/Reset_All_TOF", "bResetTofHistos=kTRUE"); - if (server) - server->Restrict("/Reset_All_TOF", "allow=admin"); - - /** Create summary Canvases for CERN 2016 **/ - Double_t w = 10; - Double_t h = 10; - TCanvas* cSummary = new TCanvas("cSummary", "gDPB Monitoring Summary", w, h); - cSummary->Divide(2, 3); - - // 1st Column: Messages types - cSummary->cd(1); - gPad->SetLogy(); - hMessageType->Draw(); - - cSummary->cd(2); - gPad->SetLogy(); - hSysMessType->Draw(); - - cSummary->cd(3); - gPad->SetLogz(); - hGet4MessType->Draw("colz"); - - // 2nd Column: GET4 Errors + Epoch flags + - cSummary->cd(4); - gPad->SetLogz(); - hGet4ChanErrors->Draw("colz"); - - cSummary->cd(5); - gPad->SetLogz(); - hGet4EpochFlags->Draw("colz"); - - cSummary->cd(6); - hDiamondSpill->Draw("col text"); - - - /** Create FEET rates Canvase for CERN 2016 **/ - TCanvas* cFeeRates = new TCanvas("cFeeRates", "gDPB Monitoring FEET rates", w, h); - cFeeRates->Divide(fNrOfFebsPerGdpb, fNrOfGdpbs ); - - TH1* histPnt = NULL; - for( UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; ++uGdpb ) { - for (UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; ++uFeet ) { - name = Form("FeetRate_gDPB_g%02u_f%1u", uGdpb, uFeet); - histPnt = fHM->H1(name.Data()); - - cFeeRates->cd( 1 + uGdpb * fNrOfFebsPerGdpb + uFeet ); - gPad->SetLogy(); - - histPnt->Draw(); - } // for (UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; ++uFeet ) - } // for( UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; ++uGdpb ) - - /** Recovers/Create Ms Size Canvase for CERN 2016 **/ - // Try to recover canvas in case it was created already by another monitor - // If not existing, create it - fcMsSizeAll = dynamic_cast<TCanvas *>( gROOT->FindObject( "cMsSizeAll" ) ); - if( NULL == fcMsSizeAll ) - { - fcMsSizeAll = new TCanvas("cMsSizeAll", "Evolution of MS size in last 300 s", w, h); - fcMsSizeAll->Divide( 4, 4 ); - LOG(info) << "Created MS size canvas in TOF monitor"; - } // if( NULL == fcMsSizeAll ) - else LOG(info) << "Recovered MS size canvas in TOF monitor"; - - /** Create beam tuning Canvases for CERN 2016 **/ - TCanvas* cBeamTunning = new TCanvas("cBeamTunning", "USTC D1 rate + DIam Rate + Diam centering", w, h); - cBeamTunning->Divide(2, 2); - - gStyle->Reset(); - - cBeamTunning->cd(1); - histPnt = fHM->H1( "FeetRate_gDPB_g00_f0" ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogy(); - histPnt->Draw(); - - cBeamTunning->cd(2); - histPnt = fHM->H1( "FeetRate_gDPB_g00_f2" ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogy(); - histPnt->Draw(); - - cBeamTunning->cd(3); - gPad->SetGridx(); - gPad->SetGridy(); - hDiamondSpillCount->Draw("text90"); - - cBeamTunning->cd(4); - hDiamondSpill->Draw("col text"); - /*****************************/ - - - fHistMessType = fHM->H1("hMessageType"); - fHistSysMessType = fHM->H1("hSysMessType"); - fHistGet4MessType = fHM->H2("hGet4MessType"); - fHistGet4ChanErrors = fHM->H2("hGet4ChanErrors"); - fHistGet4EpochFlags = fHM->H2("hGet4EpochFlags"); - fHistDiamond = fHM->H2("hDiamond"); - fHistDiamondSpill = fHM->H2("hDiamondSpill"); - fHistDiamondSpillLength = fHM->H1("hDiamondSpillLength"); - fHistDiamondSpillCount = fHM->H1("hDiamondSpillCount"); - fHistDiamondSpillQA = fHM->H2("hDiamondSpillQA"); - - for (UInt_t i = 0; i < fNrOfGdpbs; ++i) { - name = Form("Raw_Tot_gDPB_%02u", i); - fRaw_Tot_gDPB.push_back(fHM->H2(name.Data())); - name = Form("ChCount_gDPB_%02u", i); - fChCount_gDPB.push_back(fHM->H1(name.Data())); - name = Form("ChannelRate_gDPB_%02u", i); - if (fUnpackPar->IsChannelRateEnabled()) { - fChannelRate_gDPB.push_back(fHM->H2(name.Data())); - } - for (UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; uFeet++) { - name = Form("FeetRate_gDPB_g%02u_f%1u", i, uFeet); - fFeetRate_gDPB.push_back(fHM->H1(name.Data())); - if( 0 < fiBinSizeDatePlots && 0 < fiRunStartDateTimeSec ) { - name = Form("FeetRateDate_gDPB_g%02u_f%1u", i, uFeet); - fFeetRateDate_gDPB.push_back(fHM->H1(name.Data())); - } // if( 0 < fiBinSizeDatePlots && 0 < fiRunStartDateTimeSec ) - } // for( UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; uFeet ++) - } - /*****************************/ - - LOG(info) << "Leaving CreateHistograms"; -} - -Bool_t CbmTSMonitorTof::DoUnpack(const fles::Timeslice& ts, - size_t component) -{ - THttpServer* server = FairRunOnline::Instance()->GetHttpServer(); - - if (bResetTofHistos) { - ResetAllHistos(); - bResetTofHistos = kFALSE; - } - - LOG(debug1) << "Timeslice contains " << ts.num_microslices(component) - << "microslices."; - - // Getting the pointer to the correct histogram needs a lot more time then - // the actual filling procedure. If one gets the pointer in a loop this kills - // the performance. A test shows that extracting the pointer from the CbmHistManger - // is slower by a factor of 20-100 (depending on the number of histos managed by the - // CbmHistManager) compared to using the pointer directly - // So get the pointer once outside the loop and use it in the loop - - TString sMsSzName = Form("MsSz_link_%02lu", component); - TH1* hMsSz = NULL; - TProfile* hMsSzTime = NULL; - if (fHM->Exists(sMsSzName.Data())) { - hMsSz = fHM->H1(sMsSzName.Data()); - sMsSzName = Form("MsSzTime_link_%02lu", component); - hMsSzTime = fHM->P1(sMsSzName.Data()); - } // if( fHM->Exists(sMsSzName.Data() ) ) - else { - TString sMsSzTitle = Form( - "Size of MS for gDPB of link %02lu; Ms Size [bytes]", component); - fHM->Add(sMsSzName.Data(), - new TH1F(sMsSzName.Data(), sMsSzTitle.Data(), 160000, 0., 20000.)); - hMsSz = fHM->H1(sMsSzName.Data()); - if (server) - server->Register("/FlibRaw", hMsSz); - sMsSzName = Form("MsSzTime_link_%02lu", component); - sMsSzTitle = Form( - "Size of MS vs time for gDPB of link %02lu; Time[s] ; Ms Size [bytes]", - component); - fHM->Add(sMsSzName.Data(), - new TProfile(sMsSzName.Data(), sMsSzTitle.Data(), 15000, 0., 300.)); - hMsSzTime = fHM->P1(sMsSzName.Data()); - if (server) - server->Register("/FlibRaw", hMsSzTime); - if( NULL != fcMsSizeAll ) - { - fcMsSizeAll->cd( 1 + component ); - gPad->SetLogy(); - hMsSzTime->Draw("hist le0"); - } // if( NULL != fcMsSizeAll ) - LOG(info) << "Added MS size histo for component: " << component << " (gDPB)"; - } // else of if( fHM->Exists(sMsSzName.Data() ) ) - - // Initialize spill detection - fiDiamCountsLastTs = 0; - - Int_t messageType = -111; - // Loop over microslices - size_t numCompMsInTs = ts.num_microslices(component); - for (size_t m = 0; m < numCompMsInTs; ++m) { - if (fuMsAcceptsPercent < m) - continue; - - // Ignore overlap ms if number defined by user - if( numCompMsInTs - fuOverlapMsNb <= m ) - continue; - - constexpr uint32_t kuBytesPerMessage = 8; - - auto msDescriptor = ts.descriptor(component, m); - fEquipmentId = msDescriptor.eq_id; - const uint8_t* msContent = reinterpret_cast<const uint8_t*>(ts.content( - component, m)); - - uint32_t size = msDescriptor.size; - if (size > 0) - LOG(debug) << "Microslice: " << msDescriptor.idx << " has size: " << size; - - if( fdStartTimeMsSz < 0 ) - fdStartTimeMsSz = (1e-9) * static_cast<double>(msDescriptor.idx); - hMsSz->Fill(size); - hMsSzTime->Fill((1e-9) * static_cast<double>(msDescriptor.idx) - fdStartTimeMsSz, size); - - // If not integer number of message in input buffer, print warning/error - if (0 != (size % kuBytesPerMessage)) - LOG(error) << "The input microslice buffer does NOT " - << "contain only complete nDPB messages!"; - - // Compute the number of complete messages in the input microslice buffer - uint32_t uNbMessages = (size - (size % kuBytesPerMessage)) - / kuBytesPerMessage; - - // Prepare variables for the loop on contents - const uint64_t* pInBuff = reinterpret_cast<const uint64_t*>(msContent); - for (uint32_t uIdx = 0; uIdx < uNbMessages; uIdx++) { - // Fill message - uint64_t ulData = static_cast<uint64_t>(pInBuff[uIdx]); - ngdpb::Message mess(ulData); - - if (gLogger->IsLogNeeded( fair::Severity::debug2 )) { - mess.printDataCout(); - } - - // Increment counter for different message types - // and fill the corresponding histogram - messageType = mess.getMessageType(); - fMsgCounter[messageType]++; - fHistMessType->Fill(messageType); - - fGdpbId = mess.getRocNumber(); - fGdpbNr = fGdpbIdIndexMap[fGdpbId]; - - fGet4Id = mess.getGdpbGenChipId(); - fGet4Nr = (fGdpbNr * fNrOfGet4PerGdpb) + fGet4Id; - - // Jump most data in Beam tuning mode - if( fbBeamTuningMode ) - { - if( fGdpbNr != fDiamondGdpb ) - break; -// if( fGet4Id / fNrOfGet4PerFeb != fDiamondFeet ) -// continue; - } // if( fbBeamTuningMode ) - - switch (messageType) { - case ngdpb::MSG_HIT: - // FillHitInfo(mess); - LOG(error) << "Message type " << messageType - << " not yet included in unpacker."; - break; - case ngdpb::MSG_EPOCH: - // FillEpochInfo(mess); - LOG(error) << "Message type " << messageType - << " not yet included in unpacker."; - break; - case ngdpb::MSG_SYS: - fHistSysMessType->Fill(mess.getSysMesType()); - break; - case ngdpb::MSG_EPOCH2: - fHistGet4MessType->Fill(fGet4Nr, ngdpb::GET4_32B_EPOCH); - FillEpochInfo(mess); - break; - case ngdpb::MSG_GET4: - fHistGet4MessType->Fill(fGet4Nr, ngdpb::GET4_32B_DATA + 1); - PrintGenInfo(mess); - break; - case ngdpb::MSG_GET4_32B: - fHistGet4MessType->Fill(fGet4Nr, ngdpb::GET4_32B_DATA); - if( fbEpochSuppModeOn ) - fvmEpSupprBuffer[fGet4Nr].push_back( mess ); - else FillHitInfo(mess); - break; - case ngdpb::MSG_GET4_SLC: - fHistGet4MessType->Fill(fGet4Nr, ngdpb::GET4_32B_SLCM); - PrintSlcInfo(mess); - break; - case ngdpb::MSG_GET4_SYS: { - fHistSysMessType->Fill(mess.getGdpbSysSubType()); - if (ngdpb::SYSMSG_GET4_EVENT == mess.getGdpbSysSubType()) { - fHistGet4MessType->Fill(fGet4Nr, ngdpb::GET4_32B_ERROR); - Int_t dFullChId = fGet4Nr * fNrOfChannelsPerGet4 + mess.getGdpbHitChanId(); - switch (mess.getGdpbSysErrData()) { - case ngdpb::GET4_V1X_ERR_READ_INIT: - fHistGet4ChanErrors->Fill(dFullChId, 0); - break; - case ngdpb::GET4_V1X_ERR_SYNC: - fHistGet4ChanErrors->Fill(dFullChId, 1); - break; - case ngdpb::GET4_V1X_ERR_EP_CNT_SYNC: - fHistGet4ChanErrors->Fill(dFullChId, 2); - break; - case ngdpb::GET4_V1X_ERR_EP: - fHistGet4ChanErrors->Fill(dFullChId, 3); - break; - case ngdpb::GET4_V1X_ERR_FIFO_WRITE: - fHistGet4ChanErrors->Fill(dFullChId, 4); - break; - case ngdpb::GET4_V1X_ERR_LOST_EVT: - fHistGet4ChanErrors->Fill(dFullChId, 5); - break; - case ngdpb::GET4_V1X_ERR_CHAN_STATE: - fHistGet4ChanErrors->Fill(dFullChId, 6); - break; - case ngdpb::GET4_V1X_ERR_TOK_RING_ST: - fHistGet4ChanErrors->Fill(dFullChId, 7); - break; - case ngdpb::GET4_V1X_ERR_TOKEN: - fHistGet4ChanErrors->Fill(dFullChId, 8); - break; - case ngdpb::GET4_V1X_ERR_READOUT_ERR: - fHistGet4ChanErrors->Fill(dFullChId, 9); - break; - case ngdpb::GET4_V1X_ERR_SPI: - fHistGet4ChanErrors->Fill(dFullChId, 10); - break; - case ngdpb::GET4_V1X_ERR_DLL_LOCK: - fHistGet4ChanErrors->Fill(dFullChId, 11); - break; - case ngdpb::GET4_V1X_ERR_DLL_RESET: - fHistGet4ChanErrors->Fill(dFullChId, 12); - break; - case ngdpb::GET4_V1X_ERR_TOT_OVERWRT: - fHistGet4ChanErrors->Fill(dFullChId, 13); - break; - case ngdpb::GET4_V1X_ERR_TOT_RANGE: - fHistGet4ChanErrors->Fill(dFullChId, 14); - break; - case ngdpb::GET4_V1X_ERR_EVT_DISCARD: - fHistGet4ChanErrors->Fill(dFullChId, 15); - break; - case ngdpb::GET4_V1X_ERR_UNKNOWN: - fHistGet4ChanErrors->Fill(dFullChId, 16); - break; - default: // Corrupt error or not yet supported error - fHistGet4ChanErrors->Fill(dFullChId, 17); - break; - } // Switch( mess.getGdpbSysErrData() ) - - } - if (100 > iMess++) - PrintSysInfo(mess); - break; - } - default: - if (100 > iMess++) - LOG(error) << "Message (" << iMess << ") type " << std::hex - << std::setw(2) << static_cast<uint16_t>(messageType) - << " not yet included in Get4 unpacker."; - if (100 == iMess) - LOG(error) << "Stop reporting MSG errors... "; - } // switch( mess.getMessageType() ) - } // for (uint32_t uIdx = 0; uIdx < uNbMessages; uIdx ++) - } // for (size_t m = 0; m < ts.num_microslices(component); ++m) - - // Spill detection using Diamond - if( !fbSpillOn && (fiDiamSpillOnThr < fiDiamCountsLastTs) ) - { - fbSpillOn = kTRUE; - fiTsUnderOff = 0; - - if( 0 < fdDiamondTimeLastTs ) - { - fHistDiamondSpillLength->Fill( fdDiamondLastTime - fdDiamondTimeLastTs ); - fHistDiamondSpillCount->Fill( fSpillIdx, fHistDiamondSpill->GetEntries() ); - fHistDiamondSpillQA->Fill( fdDiamondLastTime - fdDiamondTimeLastTs, - fHistDiamondSpill->GetEntries() ); - } // if( 0 < fdDiamondTimeLastTs ) - fdDiamondTimeLastTs = fdDiamondLastTime; - fSpillIdx++; - fHistDiamondSpill->Reset(); - } // if( !fbSpillOn && (fiDiamSpillOnThr < fiDiamCountsLastTs) ) - else if( fbSpillOn ) - { - if( fiDiamCountsLastTs < fiDiamSpillOffThr ) - { - fiTsUnderOff ++; - if( fiTsUnderOffThr < fiTsUnderOff ) - fbSpillOn = kFALSE; - } // if( fiDiamCountsLastTs < fiDiamSpillOffThr ) - else fiTsUnderOff = 0; - } // else if( fbSpillOn ) - - return kTRUE; -} - -void CbmTSMonitorTof::FillHitInfo(ngdpb::Message mess) -{ - Int_t channel = mess.getGdpbHitChanId(); - Int_t tot = mess.getGdpbHit32Tot(); - ULong_t hitTime = mess.getMsgFullTime(0); - - Int_t curEpochGdpbGet4 = fCurrentEpoch[fGet4Nr]; - - if (curEpochGdpbGet4 != -111) { - - if( fbEpochSuppModeOn ) - curEpochGdpbGet4 --; // In Ep. Suppr. Mode, receive following epoch instead of previous - - Int_t channelNr = fGet4Id * fNrOfChannelsPerGet4 + channel; - fRaw_Tot_gDPB[fGdpbNr]->Fill(channelNr, tot); - fChCount_gDPB[fGdpbNr]->Fill(channelNr); - - if (fUnpackPar->IsChannelRateEnabled()) { - // Check if at least one hit before in this gDPB - if (fTsLastHit.end() != fTsLastHit.find(fGdpbNr)) { - // Check if at least one hit before in this Get4 - if (fTsLastHit[fGdpbNr].end() != fTsLastHit[fGdpbNr].find(fGet4Id)) { - // Check if at least one hit before in this channel - if (fTsLastHit[fGdpbNr][fGet4Id].end() - != fTsLastHit[fGdpbNr][fGet4Id].find(channel)) { - fChannelRate_gDPB[fGdpbNr]->Fill( - 1e9 - / (mess.getMsgFullTimeD(curEpochGdpbGet4) - - fTsLastHit[fGdpbNr][fGet4Id][channel]), - fGet4Id * fNrOfChannelsPerGet4 + channel); - } // if( fTsLastHit[gdpbId][get4Id].end() != fTsLastHit[gdpbId][get4Id].find( channel ) ) - } // if( fTsLastHit[gdpbId].end() != fTsLastHit[gdpbId].find( get4Id ) ) - } // if( fTsLastHit.end() != fTsLastHit.find( gdpbId ) ) - - fTsLastHit[fGdpbNr][fGet4Id][channel] = mess.getMsgFullTimeD( - curEpochGdpbGet4); - } // if( fUnpackPar->IsChannelRateEnabled() ) - - // In Run rate evolution - if (fdStartTime < 0) - fdStartTime = mess.getMsgFullTimeD(curEpochGdpbGet4); - - if (0 < fdStartTime) - { - fFeetRate_gDPB[(fGdpbNr * fNrOfFebsPerGdpb) + (fGet4Id / fNrOfGet4PerFeb)]->Fill( - 1e-9 * (mess.getMsgFullTimeD(curEpochGdpbGet4) - fdStartTime)); - - // General Time (date + time) rate evolution - // Add offset of -1H as the filenames were using some times offset by 1 hour (Summer time?!?) - if( 0 < fiBinSizeDatePlots && 0 < fiRunStartDateTimeSec ) { - fFeetRateDate_gDPB[(fGdpbNr * fNrOfFebsPerGdpb) + (fGet4Id / fNrOfGet4PerFeb)]->Fill( - 1e-9 * (mess.getMsgFullTimeD(curEpochGdpbGet4) - fdStartTime) ); - } // if( 0 < fiBinSizeDatePlots && 0 < fiRunStartDateTimeSec ) - } - - if (fDiamondGdpb == fGdpbNr - && (fGet4Id / fNrOfGet4PerFeb == fDiamondFeet)) { - UInt_t uChanInGdpb = fGet4Id * fNrOfChannelsPerGet4 + channel; - Int_t increment = static_cast<CbmFlibCern2016Source*>(FairRunOnline::Instance()->GetSource())->GetNofTSSinceLastTS(); - if (fDiamondChanA == uChanInGdpb) - { - fHistDiamond->Fill(0., 0., increment); - fHistDiamondSpill->Fill(0., 0., increment); - } // if (fDiamondChanA == uChanInGdpb) - else if (fDiamondChanB == uChanInGdpb) - { - fHistDiamond->Fill(1., 0., increment); - fHistDiamondSpill->Fill(1., 0., increment); - } // else if (fDiamondChanB == uChanInGdpb) - else if (fDiamondChanC == uChanInGdpb) - { - fHistDiamond->Fill(0., 1., increment); - fHistDiamondSpill->Fill(0., 1., increment); - } // else if (fDiamondChanC == uChanInGdpb) - else if (fDiamondChanD == uChanInGdpb) - { - fHistDiamond->Fill(1., 1., increment); - fHistDiamondSpill->Fill(1., 1., increment); - } // else if (fDiamondChanD == uChanInGdpb) - - if( fDiamondChanA == uChanInGdpb || fDiamondChanB == uChanInGdpb || - fDiamondChanC == uChanInGdpb || fDiamondChanD == uChanInGdpb ) - { - fiDiamCountsLastTs ++; - fdDiamondLastTime = 1e-9 * mess.getMsgFullTimeD(curEpochGdpbGet4); - } // if channel match one of the diamond ones - - } // if( fDiamondGdpb == gdpbNr && ( get4Id/fNrOfGet4PerFeb == fDiamondFeet ) ) - - hitTime = mess.getMsgFullTime(curEpochGdpbGet4); - Int_t Ft = mess.getGdpbHitFineTs(); - - if (100 > iMess++) - LOG(debug) << "Hit: " << Form("0x%08x ", fGdpbId) << ", " << fGet4Id - << ", " << channel << ", " << tot << ", epoch " - << curEpochGdpbGet4 << ", FullTime " - << hitTime << ", FineTime " << Ft; - } // if( fCurrentEpoch[rocId].end() != fCurrentEpoch[rocId].find( get4Id ) ) - //} // if( fCurrentEpoch.end() != fCurrentEpoch.find( rocId ) ) - //} // if( fGdpbIdIndexMap.end() != fGdpbIdIndexMap.find( rocId ) ) - else - LOG(warning) << "Found hit in gdpbId w/o epoch yet: " - << Form("0x%08x g4 %02u", fGdpbId, fGet4Nr); -} - -void CbmTSMonitorTof::FillEpochInfo(ngdpb::Message mess) -{ - Int_t epochNr = mess.getEpoch2Number(); - fCurrentEpoch[fGet4Nr] = epochNr; - - if (100 > iMess++) - LOG(debug) << "Epoch message for get4 " << fGet4Nr << " with epoch number " - << fCurrentEpoch[fGet4Nr]; - - - if( fbEpochSuppModeOn ) - { - Int_t iBufferSize = fvmEpSupprBuffer[fGet4Nr].size(); - if( 0 < iBufferSize ) - { - LOG(debug) << "Now processing stored messages for for get4 " << fGet4Nr << " with epoch number " - << (fCurrentEpoch[fGet4Nr] - 1); - - for( Int_t iMsgIdx = 0; iMsgIdx < iBufferSize; iMsgIdx++ ) - { - FillHitInfo( fvmEpSupprBuffer[fGet4Nr][ iMsgIdx ] ); - } // for( Int_t iMsgIdx = 0; iMsgIdx < iBufferSize; iMsgIdx++ ) - - fvmEpSupprBuffer[fGet4Nr].clear(); - } // if( 0 < fvmEpSupprBuffer[fGet4Nr] ) - } // if( fbEpochSuppModeOn ) - - if (1 == mess.getGdpbEpSync()) - fHistGet4EpochFlags->Fill(fGet4Nr, 0); - if (1 == mess.getGdpbEpDataLoss()) - fHistGet4EpochFlags->Fill(fGet4Nr, 1); - if (1 == mess.getGdpbEpEpochLoss()) - fHistGet4EpochFlags->Fill(fGet4Nr, 2); - if (1 == mess.getGdpbEpMissmatch()) - fHistGet4EpochFlags->Fill(fGet4Nr, 3); - - fCurrentEpochTime = mess.getMsgFullTime(epochNr); - fNofEpochs++; - - - if (fDiamondGdpb == fGdpbNr - && (fGet4Id / fNrOfGet4PerFeb == fDiamondFeet)) { - if (10 - < ((mess.getMsgFullTimeD(epochNr) / 1e9) - - fDiamondTimeLastReset)) { - fHistDiamond->Reset(); - fDiamondTimeLastReset = mess.getMsgFullTimeD(epochNr) / 1e9; - } // if( 1e10 < ( mess.getMsgFullTimeD( fCurrentEpoch[rocId][get4Id] ) - fDiamondTimeLastReset ) - } // if( fDiamondGdpb == gdpbNr && ( get4Id/fNrOfGet4PerFeb == fDiamondFeet ) ) - - /* - LOG(debug) << "Epoch message " - << fNofEpochs << ", epoch " << static_cast<Int_t>(fCurrentEpoch[gdpbId][get4Id]) - << ", time " << std::setprecision(9) << std::fixed - << Double_t(fCurrentEpochTime) * 1.e-9 << " s " - << " for board ID " << std::hex << std::setw(4) << gdpbId << std::dec - << " and chip " << mess.getEpoch2ChipNumber(); - */ -} - -void CbmTSMonitorTof::PrintSlcInfo(ngdpb::Message mess) -{ - LOG(info) << "GET4 Slow Control message, epoch " - << static_cast<Int_t>(fCurrentEpoch[fGet4Nr]) << ", time " << std::setprecision(9) - << std::fixed << Double_t(fCurrentEpochTime) * 1.e-9 << " s " - << " for board ID " << std::hex << std::setw(4) << fGdpbId - << std::dec << "\n" - << " +++++++ > Chip = " - << std::setw(2) << mess.getGdpbGenChipId() << ", Chan = " - << std::setw(1) << mess.getGdpbSlcChan() << ", Edge = " - << std::setw(1) << mess.getGdpbSlcEdge() << ", Type = " - << std::setw(1) << mess.getGdpbSlcType() << ", Data = " - << std::hex << std::setw(6) << mess.getGdpbSlcData() - << std::dec << ", Type = " << mess.getGdpbSlcCrc(); - -} - -void CbmTSMonitorTof::PrintGenInfo(ngdpb::Message mess) -{ - Int_t mType = mess.getMessageType(); - Int_t channel = mess.getGdpbHitChanId(); - uint64_t uData = mess.getData(); - - if (100 > iMess++) - LOG(info) << "Get4 MSG type " << mType << " from gdpbId " << fGdpbId - << ", getId " << fGet4Id << ", (hit channel) " << channel - << " data " << std::hex << uData; -//Form(" data 0x%01Fx ",uData) -} - -void CbmTSMonitorTof::PrintSysInfo(ngdpb::Message mess) -{ - LOG(debug) << "GET4 System message, epoch " - << static_cast<Int_t>(fCurrentEpoch[fGet4Nr]) << ", time " << std::setprecision(9) - << std::fixed << Double_t(fCurrentEpochTime) * 1.e-9 << " s " - << " for board ID " << std::hex << std::setw(4) << fGdpbId - << std::dec; - - switch (mess.getGdpbSysSubType()) { - case ngdpb::SYSMSG_GET4_EVENT: { - uint32_t uData = mess.getGdpbSysErrData(); - if (ngdpb::GET4_V1X_ERR_TOT_OVERWRT == uData - || ngdpb::GET4_V1X_ERR_TOT_RANGE == uData - || ngdpb::GET4_V1X_ERR_EVT_DISCARD == uData) - LOG(debug) << " +++++++ > gDPB: " << std::hex << std::setw(4) << fGdpbId - << std::dec << ", Chip = " << std::setw(2) - << mess.getGdpbGenChipId() << ", Chan = " << std::setw(1) - << mess.getGdpbSysErrChanId() << ", Edge = " - << std::setw(1) << mess.getGdpbSysErrEdge() << ", Empt = " - << std::setw(1) << mess.getGdpbSysErrUnused() - << ", Data = " << std::hex << std::setw(2) << uData - << std::dec << " -- GET4 V1 Error Event"; - else - LOG(info) << " +++++++ >gDPB: " << std::hex << std::setw(4) << fGdpbId - << std::dec << ", Chip = " << std::setw(2) - << mess.getGdpbGenChipId() << ", Chan = " << std::setw(1) - << mess.getGdpbSysErrChanId() << ", Edge = " - << std::setw(1) << mess.getGdpbSysErrEdge() << ", Empt = " - << std::setw(1) << mess.getGdpbSysErrUnused() - << ", Data = " << std::hex << std::setw(2) << uData - << std::dec << " -- GET4 V1 Error Event"; - break; - } // case ngdpb::SYSMSG_GET4_EVENT - case ngdpb::SYSMSG_CLOSYSYNC_ERROR: - LOG(info) << "Closy synchronization error"; - break; - case ngdpb::SYSMSG_TS156_SYNC: - LOG(debug) << "156.25MHz timestamp reset"; - break; - case ngdpb::SYSMSG_GDPB_UNKWN: - LOG(info) << "Unknown GET4 message, data: " << std::hex << std::setw(8) - << mess.getGdpbSysUnkwData() << std::dec; - break; - } // switch( getGdpbSysSubType() ) -} - -void CbmTSMonitorTof::Reset() -{ -} - -void CbmTSMonitorTof::Finish() -{ - TString message_type; - - for (unsigned int i = 0; i < fMsgCounter.size(); ++i) { - switch (i) { - case 0: - message_type = "NOP"; - break; - case 1: - message_type = "HIT"; - break; - case 2: - message_type = "EPOCH"; - break; - case 3: - message_type = "SYNC"; - break; - case 4: - message_type = "AUX"; - break; - case 5: - message_type = "EPOCH2"; - break; - case 6: - message_type = "GET4"; - break; - case 7: - message_type = "SYS"; - break; - case 8: - message_type = "GET4_SLC"; - break; - case 9: - message_type = "GET4_32B"; - break; - case 10: - message_type = "GET4_SYS"; - break; - default: - message_type = "UNKNOWN"; - break; - } // switch(i) - LOG(info) << message_type << " messages: " << fMsgCounter[i]; - } // for (unsigned int i=0; i< fMsgCounter.size(); ++i) - - LOG(info) << "-------------------------------------"; - for (UInt_t i = 0; i < fNrOfGdpbs; ++i) { - for (UInt_t j = 0; j < fNrOfGet4PerGdpb; ++j) { - LOG(info) << "Last epoch for gDPB: " << std::hex << std::setw(4) << i - << std::dec << " , GET4 " << std::setw(4) << j << " => " - << fCurrentEpoch[GetArrayIndex(i, j)]; - } - } - LOG(info) << "-------------------------------------"; - - gDirectory->mkdir("Tof_Raw_gDPB"); - gDirectory->cd("Tof_Raw_gDPB"); - for (UInt_t uGdpb = 0; uGdpb < fuMinNbGdpb; uGdpb++) { - fHM->H2(Form("Raw_Tot_gDPB_%02u", uGdpb))->Write(); - fHM->H1(Form("ChCount_gDPB_%02u", uGdpb))->Write(); - if (fUnpackPar->IsChannelRateEnabled()) - fHM->H2(Form("ChannelRate_gDPB_%02u", uGdpb))->Write(); - for (UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; uFeet++) { - fHM->H1(Form("FeetRate_gDPB_g%02u_f%1u", uGdpb, uFeet))->Write(); - if( 0 < fiBinSizeDatePlots && 0 < fiRunStartDateTimeSec ) { - fHM->H1(Form("FeetRateDate_gDPB_g%02u_f%1u", uGdpb, uFeet))->Write(); - } - } - } // for( UInt_t uGdpb = 0; uGdpb < fuMinNbGdpb; uGdpb ++) - fHM->H1("hMessageType")->Write(); - fHM->H1("hSysMessType")->Write(); - fHM->H2("hGet4MessType")->Write(); - fHM->H2("hGet4ChanErrors")->Write(); - fHM->H2("hGet4EpochFlags")->Write(); - fHM->H1("hDiamondSpillLength")->Write(); - fHM->H1("hDiamondSpillCount")->Write(); - fHM->H1("hDiamondSpillQA")->Write(); - - gDirectory->cd(".."); - - gDirectory->mkdir("Flib_Raw"); - gDirectory->cd("Flib_Raw"); - for (UInt_t uLinks = 0; uLinks < 16; uLinks++) { - TString sMsSzName = Form("MsSz_link_%02u", uLinks); - if (fHM->Exists(sMsSzName.Data())) - fHM->H1(sMsSzName.Data())->Write(); - - sMsSzName = Form("MsSzTime_link_%02u", uLinks); - if (fHM->Exists(sMsSzName.Data())) - fHM->P1(sMsSzName.Data())->Write(); - } // for( UInt_t uLinks = 0; uLinks < 16; uLinks ++) - gDirectory->cd(".."); - -} - -void CbmTSMonitorTof::FillOutput(boost::any) -{ -} - -void CbmTSMonitorTof::SetDiamondChannels( UInt_t uGdpb, UInt_t uFeet, UInt_t uChannelA, - UInt_t uChannelB, UInt_t uChannelC, UInt_t uChannelD) -{ - fDiamondGdpb = uGdpb; - fDiamondFeet = uFeet; - fDiamondChanA = uChannelA; - fDiamondChanB = uChannelB; - fDiamondChanC = uChannelC; - fDiamondChanD = uChannelD; -} - - -void CbmTSMonitorTof::ResetAllHistos() -{ - LOG(info) << "Reseting all TOF histograms."; - fHM->H1("hMessageType")->Reset(); - fHM->H1("hSysMessType")->Reset(); - fHM->H2("hGet4MessType")->Reset(); - fHM->H2("hGet4ChanErrors")->Reset(); - fHM->H2("hGet4EpochFlags")->Reset(); - fHM->H1("hDiamondSpillLength")->Reset(); - fHM->H1("hDiamondSpillCount")->Reset(); - fHM->H2("hDiamondSpillQA")->Reset(); - fSpillIdx = 0; - - for (UInt_t uGdpb = 0; uGdpb < fuMinNbGdpb; uGdpb++) { - fHM->H2(Form("Raw_Tot_gDPB_%02u", uGdpb))->Reset(); - fHM->H1(Form("ChCount_gDPB_%02u", uGdpb))->Reset(); - if (fUnpackPar->IsChannelRateEnabled()) - fHM->H2(Form("ChannelRate_gDPB_%02u", uGdpb))->Reset(); - for (UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; uFeet++) { - fHM->H1(Form("FeetRate_gDPB_g%02u_f%1u", uGdpb, uFeet))->Reset(); - } // for( UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; uFeet ++) - } // for( UInt_t uGdpb = 0; uGdpb < fuMinNbGdpb; uGdpb ++) - - for (UInt_t uLinks = 0; uLinks < 16; uLinks++) { - TString sMsSzName = Form("MsSz_link_%02u", uLinks); - if (fHM->Exists(sMsSzName.Data())) - fHM->H1(sMsSzName.Data())->Reset(); - - sMsSzName = Form("MsSzTime_link_%02u", uLinks); - if (fHM->Exists(sMsSzName.Data())) - fHM->P1(sMsSzName.Data())->Reset(); - } // for( UInt_t uLinks = 0; uLinks < 16; uLinks ++) - - fdStartTime = -1; - fdStartTimeMsSz = -1; -} - -void CbmTSMonitorTof::SetRunStart( Int_t dateIn, Int_t timeIn, Int_t iBinSize ) -{ - TDatime * fRunStartDateTime = new TDatime( dateIn, timeIn); - fiRunStartDateTimeSec = fRunStartDateTime->Convert(); - fiBinSizeDatePlots = iBinSize; - - LOG(info) << "Assigned new TOF Run Start Date-Time: " << fRunStartDateTime->AsString(); -} - -ClassImp(CbmTSMonitorTof) diff --git a/beamtime/cern2016/unpacker/CbmTSMonitorTof.h b/beamtime/cern2016/unpacker/CbmTSMonitorTof.h deleted file mode 100644 index 65ed170b77b8d9b86b97240fa87a5ef1d1fd1d9e..0000000000000000000000000000000000000000 --- a/beamtime/cern2016/unpacker/CbmTSMonitorTof.h +++ /dev/null @@ -1,183 +0,0 @@ -#// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmTSMonitorTof ----- -// ----- Created 11.11.2016 by P.-A. Loizeau ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CbmTSMonitorTof_H -#define CbmTSMonitorTof_H - -#include "Timeslice.hpp" -#include "rocMess_wGet4v1.h" - -#include "CbmTSUnpack.h" -#include "CbmHistManager.h" - -#include "TClonesArray.h" -#include "Rtypes.h" - -#include <vector> -#include <map> - -class CbmTofUnpackPar; - -class CbmTSMonitorTof: public CbmTSUnpack { - public: - - CbmTSMonitorTof(); - virtual ~CbmTSMonitorTof(); - - virtual Bool_t Init(); - - virtual Bool_t DoUnpack(const fles::Timeslice& ts, size_t component); - - virtual void Reset(); - - virtual void Finish(); - - void SetParContainers(); - - Bool_t InitContainers(); - - Bool_t ReInitContainers(); - - void FillOutput(boost::any); - - void SetMsLimitLevel(size_t uAcceptBoundaryPct = 100) { - fuMsAcceptsPercent = uAcceptBoundaryPct; - } - size_t GetMsLimitLevel() { - return fuMsAcceptsPercent; - } - - void SetMsOverlap(size_t uOverlapMsNb = 1) { - fuOverlapMsNb = uOverlapMsNb; - } - size_t GetMsOverlap() { - return fuOverlapMsNb; - } - - void SetDiamondChannels( UInt_t uGdpb = 0, UInt_t uFeet = 2, UInt_t uChannelA = 78, - UInt_t uChannelB = 70, UInt_t uChannelC = 94, UInt_t uChannelD = 86 ); - void SetDiamondPerTsSpillOnThr( Int_t iThrIn = 10 ) { fiDiamSpillOnThr = iThrIn; } - void SetDiamondPerTsSpillOffThr( Int_t iThrIn = 3 ) { fiDiamSpillOffThr = iThrIn; } - void SetDiamondTsNbSpillOffThr( Int_t iThrIn = 10 ) { fiTsUnderOffThr = iThrIn; } - - void SetEpochSuppressedMode( Bool_t bEnable = kTRUE ) { fbEpochSuppModeOn = bEnable; } - - void SetBeamTuningMode( Bool_t bEnable = kTRUE ) { fbBeamTuningMode = bEnable; } - - void SetRunStart( Int_t dateIn, Int_t timeIn, Int_t iBinSize = 5 ); - - void ResetAllHistos(); - - private: - - size_t fuMsAcceptsPercent; /** Reject Ms with index inside TS above this, assumes 100 MS per TS **/ - size_t fuOverlapMsNb; /** Ignore Overlap Ms: all fuOverlapMsNb MS at the end of timeslice **/ - UInt_t fuMinNbGdpb; - UInt_t fuCurrNbGdpb; - - UInt_t fNrOfGdpbs; // Total number of GDPBs in the system - UInt_t fNrOfFebsPerGdpb; // Number of FEBs per GDPB - UInt_t fNrOfGet4PerFeb; // Number of GET4s per FEB - UInt_t fNrOfChannelsPerGet4; // Number of channels in each GET4 - - UInt_t fNrOfGet4; // Total number of Get4 chips in the system - UInt_t fNrOfGet4PerGdpb; // Number of GET4s per GDPB - - UInt_t fDiamondGdpb; - UInt_t fDiamondFeet; - UInt_t fDiamondChanA; - UInt_t fDiamondChanB; - UInt_t fDiamondChanC; - UInt_t fDiamondChanD; - Int_t fDiamondTimeLastReset; - Int_t fiDiamCountsLastTs; - Int_t fiDiamSpillOnThr; - Int_t fiDiamSpillOffThr; - Int_t fiTsUnderOff; - Int_t fiTsUnderOffThr; - Double_t fdDiamondLastTime; - Double_t fdDiamondTimeLastTs; - Bool_t fbSpillOn; - UInt_t fSpillIdx; - Bool_t fbBeamTuningMode; - - Bool_t fbEpochSuppModeOn; - - std::vector< std::vector < ngdpb::Message > > fvmEpSupprBuffer; - - UInt_t fGdpbId; // Id (hex number)of the GDPB which is read from the message - UInt_t fGdpbNr; // running number (0 to fNrOfGdpbs) of the GDPB in the - UInt_t fGet4Id; // running number (0 to fNrOfGet4PerGdpb) of the Get4 chip of a unique GDPB - UInt_t fGet4Nr; // running number (0 to fNrOfGet4) of the Get4 chip in the system - - std::vector<int> fMsgCounter; - - std::map<UInt_t, UInt_t> fGdpbIdIndexMap; - - CbmHistManager* fHM; ///< Histogram manager - - /** Current epoch marker for each GDPB and GET4 - * (first epoch in the stream initializes the map item) - * pointer points to an array of size fNrOfGdpbs * fNrOfGet4PerGdpb - * The correct array index is calculated using the function - * GetArrayIndex(gdpbId, get4Id) - **/ - Int_t* fCurrentEpoch; //! - - Int_t fNofEpochs; /** Current epoch marker for each ROC **/ - ULong_t fCurrentEpochTime; /** Time stamp of current epoch **/ - Double_t fdStartTime; /** Time of first valid hit (epoch available), used as reference for evolution plots**/ - Double_t fdStartTimeMsSz; /** Time of first microslice, used as reference for evolution plots**/ - TCanvas* fcMsSizeAll; - - /** Used only if the channel rate plots are enabled **/ - /** Last Hit time for each ROC/GET4/Channel (first hit in the stream initializes the map item) **/ - std::map<Int_t, std::map<Int_t, std::map<Int_t, Double_t> > > fTsLastHit; // * 6.25 ns - - Int_t fEquipmentId; - - CbmTofUnpackPar* fUnpackPar; //! - - TH1* fHistMessType; - TH1* fHistSysMessType; - TH2* fHistGet4MessType; - TH2* fHistGet4ChanErrors; - TH2* fHistGet4EpochFlags; - TH2* fHistDiamond; - TH2* fHistDiamondSpill; - TH1* fHistDiamondSpillLength; - TH1* fHistDiamondSpillCount; - TH2* fHistDiamondSpillQA; - - std::vector<TH2*> fRaw_Tot_gDPB; - std::vector<TH1*> fChCount_gDPB; - std::vector<TH2*> fChannelRate_gDPB; - std::vector<TH1*> fFeetRate_gDPB; - - std::vector<TH1*> fFeetRateDate_gDPB; - Int_t fiRunStartDateTimeSec; - Int_t fiBinSizeDatePlots; - - void CreateHistograms(); - - void FillHitInfo(ngdpb::Message); - void FillEpochInfo(ngdpb::Message); - void PrintSlcInfo(ngdpb::Message); - void PrintSysInfo(ngdpb::Message); - void PrintGenInfo(ngdpb::Message); - - inline Int_t GetArrayIndex(Int_t gdpbId, Int_t get4Id) { - return gdpbId * fNrOfGet4PerGdpb + get4Id; - } - - CbmTSMonitorTof(const CbmTSMonitorTof&); - CbmTSMonitorTof operator=(const CbmTSMonitorTof&); - - ClassDef(CbmTSMonitorTof, 1) -}; - -#endif diff --git a/beamtime/cern2016/unpacker/CbmTSMonitorTofLegacy.cxx b/beamtime/cern2016/unpacker/CbmTSMonitorTofLegacy.cxx deleted file mode 100644 index be97b5ec98c6ecf281ce261fef5c39ebe2c9d00a..0000000000000000000000000000000000000000 --- a/beamtime/cern2016/unpacker/CbmTSMonitorTofLegacy.cxx +++ /dev/null @@ -1,1072 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmTSMonitorTofLegacy ----- -// ----- Created 27.10.2016 by P.-A. Loizeau ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#include "CbmTSMonitorTofLegacy.h" -#include "CbmTofUnpackPar.h" -//#include "CbmTofDigiExp.h" - -//#include "CbmTbDaqBuffer.h" - -//#include "CbmFiberHodoAddress.h" -#include "CbmHistManager.h" - -#include "FairLogger.h" -#include "FairRootManager.h" -#include "FairRun.h" -#include "FairRuntimeDb.h" -#include "FairRunOnline.h" - -#include "TClonesArray.h" -#include "TString.h" -#include "THttpServer.h" -#include "Rtypes.h" -#include "TH1.h" -#include "TCanvas.h" -#include "THStack.h" -#include "TROOT.h" - -#include <iostream> -#include <stdint.h> -#include <iomanip> - -static Int_t iMess=0; - -CbmTSMonitorTofLegacy::CbmTSMonitorTofLegacy() - : CbmTSUnpack(), - fuMsAcceptsPercent(100), - fuMinNbGdpb(), - fuCurrNbGdpb( 0 ), - fNrOfGdpbs(0), - fNrOfFebsPerGdpb(0), - fNrOfGet4PerFeb(0), - fNrOfChannelsPerGet4(0), - fNrOfGet4(0), - fNrOfGet4PerGdpb(0), - fDiamondGdpb(0), - fDiamondFeet(0), - fDiamondChanA(0), - fDiamondChanB(0), - fDiamondChanC(0), - fDiamondChanD(0), - fDiamondTimeLastReset(-1), - fMsgCounter(11,0), // length of enum MessageTypes initialized with 0 - fGdpbIdIndexMap(), - fHM(new CbmHistManager()), - fCurrentEpoch(), - fNofEpochs(0), - fCurrentEpochTime(0.), - fdStartTime(-1.), - fTsLastHit(), - fEquipmentId(0), - fUnpackPar(NULL) -{ -} - -CbmTSMonitorTofLegacy::~CbmTSMonitorTofLegacy() -{ -} - -Bool_t CbmTSMonitorTofLegacy::Init() -{ - LOG(info) << "Initializing Get4 monitor"; - - FairRootManager* ioman = FairRootManager::Instance(); - if (ioman == NULL) { - LOG(fatal) << "No FairRootManager instance"; - } - - return kTRUE; -} - -void CbmTSMonitorTofLegacy::SetParContainers() -{ - LOG(info) << "Setting parameter containers for " << GetName(); - fUnpackPar = (CbmTofUnpackPar*)(FairRun::Instance()->GetRuntimeDb()->getContainer("CbmTofUnpackPar")); - -} - -Bool_t CbmTSMonitorTofLegacy::InitContainers() -{ - LOG(info) << "Init parameter containers for " << GetName(); - Bool_t initOK = ReInitContainers(); - - CreateHistograms(); - - return initOK; -} - -Bool_t CbmTSMonitorTofLegacy::ReInitContainers() -{ - LOG(info) << "ReInit parameter containers for " << GetName(); - - fNrOfGdpbs = fUnpackPar->GetNrOfRocs(); - LOG(info) << "Nr. of Tof GDPBs: " << fNrOfGdpbs; - fuMinNbGdpb = fNrOfGdpbs; - - fNrOfFebsPerGdpb = fUnpackPar->GetNrOfFebsPerGdpb(); - LOG(info) << "Nr. of FEBS per Tof GDPB: " << fNrOfFebsPerGdpb; - - fNrOfGet4PerFeb = fUnpackPar->GetNrOfGet4PerFeb(); - LOG(info) << "Nr. of GET4 per Tof FEB: " << fNrOfGet4PerFeb; - - fNrOfChannelsPerGet4 = fUnpackPar->GetNrOfChannelsPerGet4(); - LOG(info) << "Nr. of channels per GET4: " << fNrOfChannelsPerGet4; - - fNrOfGet4 = fNrOfGdpbs * fNrOfFebsPerGdpb * fNrOfGet4PerFeb; - LOG(info) << "Nr. of GET4s: " << fNrOfGet4; - - fNrOfGet4PerGdpb = fNrOfFebsPerGdpb * fNrOfGet4PerFeb; - LOG(info) << "Nr. of GET4s per GDPB: " << fNrOfGet4PerGdpb; - - - fGdpbIdIndexMap.clear(); - for (UInt_t i = 0; i< fNrOfGdpbs; ++i) { - fGdpbIdIndexMap[fUnpackPar->GetRocId(i)] = i; - LOG(info) << "GDPB Id of TOF " << i - << " : " << fUnpackPar->GetRocId(i); - } - UInt_t NrOfChannels = fUnpackPar->GetNumberOfChannels(); - LOG(info) << "Nr. of mapped Tof channels: " << NrOfChannels; - std::stringstream ss; - for (UInt_t i = 0; i< NrOfChannels; ++i) { - if(i%8 == 0) - ss << "\n"; - ss << Form(" 0x%08x",fUnpackPar->GetChannelToDetUIdMap(i)); - } - LOG(info) << ss.str(); - - LOG(info) << "Plot Channel Rate => " << ( fUnpackPar->IsChannelRateEnabled() ? "ON" : "OFF"); - - return kTRUE; -} - -void CbmTSMonitorTofLegacy::CreateHistograms() -{ - THttpServer* server = FairRunOnline::Instance()->GetHttpServer(); - - TString name{""}; - TString title{""}; - - name = "hMessageType"; - title = "Nb of message for each type; Type"; - // Test Big Data readout with plotting - TH1I* hMessageType = new TH1I(name, title, 16, 0., 16.); - // TH1I* hMessageType = new TH1I(name, title, 16, -0.5, 15.5); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_NOP, "NOP"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_HIT, "HIT"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_EPOCH, "EPOCH"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_SYNC, "SYNC"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_AUX, "AUX"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_EPOCH2, "EPOCH2"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_GET4, "GET4"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_SYS, "SYS"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_GET4_SLC, "MSG_GET4_SLC"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_GET4_32B, "MSG_GET4_32B"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_GET4_SYS, "MSG_GET4_SYS"); - hMessageType->GetXaxis()->SetBinLabel(1 + 15, "GET4 Hack 32B"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_NOP, "NOP"); - fHM->Add(name.Data(), hMessageType); - if (server) server->Register("/TofRaw", fHM->H1(name.Data())); - - name = "hSysMessType"; - title = "Nb of system message for each type; System Type"; - TH1I* hSysMessType = new TH1I(name, title, 17, 0., 17.); -// TH1I* hSysMessType = new TH1I(name, title, 17, -0.5, 16.5); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_START, "DAQ START"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_FINISH, "DAQ FINISH"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_NX_PARITY, "NX PARITY"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_SYNC_PARITY, "SYNC PARITY"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_RESUME, "DAQ RESUME"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_FIFO_RESET, "FIFO RESET"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_USER, "USER"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_PCTIME, "PCTIME"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_ADC, "ADC"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_PACKETLOST, "PACKET LOST"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_GET4_EVENT, "GET4 ERROR"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_CLOSYSYNC_ERROR, "CLOSYSYNC ERROR"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_TS156_SYNC, "TS156 SYNC"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_GDPB_UNKWN, "UNKW GET4 MSG"); - hSysMessType->GetXaxis()->SetBinLabel(1 + 16, "GET4 Hack 32B"); - fHM->Add(name.Data(), hSysMessType); - if (server) server->Register("/TofRaw", fHM->H1(name.Data())); - - name = "hGet4MessType"; - title = "Nb of message for each type per GET4; GET4 chip # ; Type"; - TH2I* hGet4MessType = new TH2I(name, title, fNrOfGet4, 0., fNrOfGet4, 5 , 0., 5.); -// TH2I* hGet4MessType = new TH2I(name, title, uNbFeets*feetv1::kuChipPerFeet, -0.5, uNbFeets*feetv1::kuChipPerFeet -0.5, 5, -0.5, 4.5); - hGet4MessType->GetYaxis()->SetBinLabel(1 + ngdpb::GET4_32B_EPOCH, "EPOCH"); - hGet4MessType->GetYaxis()->SetBinLabel(1 + ngdpb::GET4_32B_SLCM, "S.C. M"); - hGet4MessType->GetYaxis()->SetBinLabel(1 + ngdpb::GET4_32B_ERROR, "ERROR"); - hGet4MessType->GetYaxis()->SetBinLabel(1 + ngdpb::GET4_32B_DATA, "DATA 32b"); - hGet4MessType->GetYaxis()->SetBinLabel(1 + ngdpb::GET4_32B_DATA+1,"DATA 24b"); - fHM->Add(name.Data(), hGet4MessType); - if (server) server->Register("/TofRaw", fHM->H2(name.Data())); - - name = "hGet4ChanErrors"; - title = "Error messages per GET4 channel; GET4 channel # ; Error"; - TH2I* hGet4ChanErrors = new TH2I(name, title, fNrOfGet4*fNrOfChannelsPerGet4 , 0., fNrOfGet4*fNrOfChannelsPerGet4, 32, 0., 32.); -// TH2I* hGet4ChanErrors = new TH2I(name, title, uNbFeets*feetv1::kuChanPerFeet*2, -0.5, uNbFeets*feetv1::kuChanPerFeet -0.5, 32, -0.5, 31.5); - hGet4ChanErrors->GetYaxis()->SetBinLabel(1, "0x00: Readout Init "); - hGet4ChanErrors->GetYaxis()->SetBinLabel(2, "0x01: Sync "); - hGet4ChanErrors->GetYaxis()->SetBinLabel(3, "0x02: Epoch count sync"); - hGet4ChanErrors->GetYaxis()->SetBinLabel(4, "0x03: Epoch "); - hGet4ChanErrors->GetYaxis()->SetBinLabel(5, "0x04: FIFO Write "); - hGet4ChanErrors->GetYaxis()->SetBinLabel(6, "0x05: Lost event "); - hGet4ChanErrors->GetYaxis()->SetBinLabel(7, "0x06: Channel state "); - hGet4ChanErrors->GetYaxis()->SetBinLabel(8, "0x07: Token Ring state"); - hGet4ChanErrors->GetYaxis()->SetBinLabel(9, "0x08: Token "); - hGet4ChanErrors->GetYaxis()->SetBinLabel(10, "0x09: Error Readout "); - hGet4ChanErrors->GetYaxis()->SetBinLabel(11, "0x0a: SPI "); - hGet4ChanErrors->GetYaxis()->SetBinLabel(12, "0x0b: DLL Lock error "); // <- From GET4 v1.2 - hGet4ChanErrors->GetYaxis()->SetBinLabel(13, "0x0c: DLL Reset invoc."); // <- From GET4 v1.2 - hGet4ChanErrors->GetYaxis()->SetBinLabel(14, "0x11: Overwrite "); - hGet4ChanErrors->GetYaxis()->SetBinLabel(15, "0x12: ToT out of range"); - hGet4ChanErrors->GetYaxis()->SetBinLabel(16, "0x13: Event Discarded "); - hGet4ChanErrors->GetYaxis()->SetBinLabel(17, "0x7f: Unknown "); - hGet4ChanErrors->GetYaxis()->SetBinLabel(18, "Corrupt error or unsupported yet"); - fHM->Add(name.Data(), hGet4ChanErrors); - if (server) server->Register("/TofRaw", fHM->H2(name.Data())); - - name = "hGet4EpochFlags"; - title = "Epoch flags per GET4; GET4 chip # ; Type"; - TH2I* hGet4EpochFlags = new TH2I(name, title, fNrOfGet4, 0., fNrOfGet4, 4 , 0., 4.); -// hEpochFlags = new TH2I(name, title, uNbFeets*feetv1::kuChipPerFeet, -0.5, uNbFeets*feetv1::kuChipPerFeet -0.5, 4, -0.5, 3.5); - hGet4EpochFlags->GetYaxis()->SetBinLabel(1, "SYNC"); - hGet4EpochFlags->GetYaxis()->SetBinLabel(2, "Ep LOSS"); - hGet4EpochFlags->GetYaxis()->SetBinLabel(3, "Da LOSS"); - hGet4EpochFlags->GetYaxis()->SetBinLabel(4, "MISSMAT"); - fHM->Add(name.Data(), hGet4EpochFlags); - if (server) server->Register("/TofRaw", fHM->H2(name.Data())); - - Double_t w = 10; - Double_t h = 10; - - TCanvas* c1 = new TCanvas("c1", "Test canvas c1", w, h); - c1->Divide( 2, 2 ); - - c1->cd(1); - gPad->SetLogy(); - hMessageType->Draw(); - - c1->cd(2); - hSysMessType->Draw(); - - c1->cd(3); - hGet4MessType->Draw("colz"); - gPad->SetLogz(); - - - c1->cd(4); - hGet4ChanErrors->Draw("colz"); - - /* - - hDataAvail = new TH1I( "hDataAvail", - "Data available before readout; # Data Avail [msg]; Checks []", - 32769, -0.5, 32769 - 0.5); - - hChannelCounts = new TH1I("hChannelCounts", - "Hit counts per channel; Channel # []; Counts []", - uNbFeets*feetv1::kuChanPerFeet, -0.5, uNbFeets*feetv1::kuChanPerFeet - 0.5); - - hEpochCounts = new TH1I("hEpochCounts", - "Epoch counts per channel (chips); Channel # []; Counts []", - uNbFeets*feetv1::kuChipPerFeet, -0.5, uNbFeets*feetv1::kuChanPerFeet - 0.5); - - hTotDistribution = new TH2I("hTotDistribution", - "Distribution of TOT counts per channel; Channel # []; TOT [bin]", - uNbFeets*feetv1::kuChanPerFeet, -0.5, uNbFeets*feetv1::kuChanPerFeet - 0.5, - feetv1::kuTotBinsNb, -0.5, feetv1::kuTotBinsNb - 0.5); - - hTsDistribution = new TH2I("hTsDistribution", - "Distribution of TS counts per channel; Channel # []; Ts [bin]", - uNbFeets*feetv1::kuChanPerFeet, -0.5, uNbFeets*feetv1::kuChanPerFeet - 0.5, - feetv1::kuTsBinsNb/16, -0.5, feetv1::kuTsBinsNb - 0.5); - - hEpochDistribution = new TH2I("hEpochDistribution", - "Distribution of Epochs per chip; Chip # []; Epoch [bin]", - uNbFeets*feetv1::kuChipPerFeet, -0.5, uNbFeets*feetv1::kuChipPerFeet - 0.5, - 4096, -0.5, 0x7FFFFFFF - 0.5); - */ - /* - hChanCoinc = new TH2I("hChanCoinc", - "Channels coincidences; Channel A # []; Channel B # []", - uNbFeets*feetv1::kuChanPerFeet, -0.5, uNbFeets*feetv1::kuChanPerFeet - 0.5, - uNbFeets*feetv1::kuChanPerFeet, -0.5, uNbFeets*feetv1::kuChanPerFeet - 0.5); - */ -/* - hTimeDiffNext = new TH2I("hTimeDiffNext", - "Time difference to next channel; First Channel # []; TS(Ch + 1) - TS (Ch) [Bin]", - uNbFeets*feetv1::kuChanPerFeet - 1, -0.5, uNbFeets*feetv1::kuChanPerFeet - 1.5, -*/ - // 1025, -512.5, +512.5); - // 10250, -5120.5, +5120.5); - // 10251, -10250.5, +10250.5); - - if( fUnpackPar->IsChannelRateEnabled() ) { - for( UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; uGdpb ++) - { - const Int_t iNbBinsRate = 82; - Double_t dBinsRate[iNbBinsRate] = - { 1e0, 2e0, 3e0, 4e0, 5e0, 6e0, 7e0, 8e0, 9e0, - 1e1, 2e1, 3e1, 4e1, 5e1, 6e1, 7e1, 8e1, 9e1, - 1e2, 2e2, 3e2, 4e2, 5e2, 6e2, 7e2, 8e2, 9e2, - 1e3, 2e3, 3e3, 4e3, 5e3, 6e3, 7e3, 8e3, 9e3, - 1e4, 2e4, 3e4, 4e4, 5e4, 6e4, 7e4, 8e4, 9e4, - 1e5, 2e5, 3e5, 4e5, 5e5, 6e5, 7e5, 8e5, 9e5, - 1e6, 2e6, 3e6, 4e6, 5e6, 6e6, 7e6, 8e6, 9e6, - 1e7, 2e7, 3e7, 4e7, 5e7, 6e7, 7e7, 8e7, 9e7, - 1e8, 2e8, 3e8, 4e8, 5e8, 6e8, 7e8, 8e8, 9e8, - 1e9 }; - name = Form("ChannelRate_gDPB_%02u", uGdpb); - title = Form("Channel instant rate gDPB %02u; Dist[ns] ; Channel", uGdpb); - fHM->Add(name.Data(), new TH2F(name.Data(), title.Data(), - iNbBinsRate-1, dBinsRate, 96, 0, 96) ); - if (server) server->Register("/TofRaw", fHM->H2(name.Data())); - LOG(info) << "Adding the rate histos"; - } // for( UInt_t uGdpb = 0; uGdpb < fuMinNbGdpb; uGdpb ++) - } - - for( UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; uGdpb ++) - { - name = Form("Raw_Tot_gDPB_%02u", uGdpb); - title = Form("Raw TOT gDPB %02u; channel; TOT [bin]", uGdpb); - fHM->Add(name.Data(), new TH2F(name.Data(), title.Data(), 96, 0, 96, 256, 0, 256) ); - if (server) server->Register("/TofRaw", fHM->H2(name.Data())); - - name = Form("ChCount_gDPB_%02u", uGdpb); - title = Form("Channel counts gDPB %02u; channel; Hits", uGdpb); - fHM->Add(name.Data(), new TH1I(name.Data(), title.Data(), 96, 0, 96 ) ); - - if (server) server->Register("/TofRaw", fHM->H1(name.Data())); - - for( UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; uFeet ++) - { - name = Form("FeetRate_gDPB_g%02u_f%1u", uGdpb, uFeet); - title = Form("Counts per second in Feet %1u of gDPB %02u; Time[s] ; Counts", uFeet, uGdpb); - fHM->Add(name.Data(), new TH1F( name.Data(), title.Data(), - 1800, 0, 1800 ) ); - if (server) server->Register("/TofRaw", fHM->H1(name.Data())); - } // for( UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; uFeet ++) - } // for( UInt_t uGdpb = 0; uGdpb < fuMinNbGdpb; uGdpb ++) - - if (server) server->RegisterCommand( "/Reset_ChCount_gDPB_00", "/TofRaw/ChCount_gDPB_00/->Reset()" ); - if (server) server->Restrict("/Reset_ChCount_gDPB_00","allow=admin"); - if (server) server->RegisterCommand( "/Reset_All_TOF", "ResetAllHistos()" ); - if (server) server->Restrict("/Reset_All_TOF","allow=admin"); - - - /** Create summary Canvases for CERN 2016 **/ - name = "stackRate_g00"; - THStack * stackRateA = new THStack( name, "Sum of counts vs Time per FEET for gDPB 1"); - fHM->H1( "FeetRate_gDPB_g00_f0" )->SetLineColor( kBlack ); // => Make stack + color! - stackRateA->Add( fHM->H1( "FeetRate_gDPB_g00_f0" ) ); - fHM->H1( "FeetRate_gDPB_g00_f1" )->SetLineColor( kRed ); // => Make stack + color! - stackRateA->Add( fHM->H1( "FeetRate_gDPB_g00_f1" ) ); - fHM->H1( "FeetRate_gDPB_g00_f2" )->SetLineColor( kBlue ); // => Make stack + color! - stackRateA->Add( fHM->H1( "FeetRate_gDPB_g00_f2" ) ); - fHM->Add(name.Data(), stackRateA); - if (server) server->Register("/TofRaw", stackRateA); - - name = "stackRate_g01"; - THStack * stackRateB = new THStack( name, "Sum of counts vs Time per FEET for gDPB 2"); - fHM->H1( "FeetRate_gDPB_g01_f0" )->SetLineColor( kBlack ); // => Make stack + color! - stackRateB->Add( fHM->H1( "FeetRate_gDPB_g01_f0" ) ); - fHM->H1( "FeetRate_gDPB_g01_f1" )->SetLineColor( kRed ); // => Make stack + color! - stackRateB->Add( fHM->H1( "FeetRate_gDPB_g01_f1" ) ); - fHM->H1( "FeetRate_gDPB_g01_f2" )->SetLineColor( kBlue ); // => Make stack + color! - stackRateB->Add( fHM->H1( "FeetRate_gDPB_g01_f2" ) ); - fHM->Add(name.Data(), stackRateB); - if (server) server->Register("/TofRaw", stackRateB); - - TCanvas* cSummary = new TCanvas("cSummary", "gDPB Monitoring Summary", w, h); - cSummary->Divide( 4, 3 ); - - // 1st Column: Messages types - cSummary->cd(1); - gPad->SetLogy(); - hMessageType->Draw(); - - cSummary->cd(5); - gPad->SetLogy(); - hSysMessType->Draw(); - - cSummary->cd(9); - gPad->SetLogz(); - hGet4MessType->Draw("colz"); - - // 2nd Column: GET4 Errors + Epoch flags + - cSummary->cd(2); - gPad->SetLogz(); - hGet4ChanErrors->Draw("colz"); - - cSummary->cd(6); - gPad->SetLogz(); - hGet4EpochFlags->Draw("colz"); - - cSummary->cd(10); -// gPad->SetLogz(); -// hGet4MessType->Draw("colz"); - - cSummary->cd(4); - hGet4ChanErrors->Draw("colz"); - - // 3rd & 4th Column: Sum of counts vs Time per FEET - cSummary->cd(3); - gPad->SetLogy(); - stackRateA->Draw("nostack"); - - cSummary->cd(4); - gPad->SetLogy(); - stackRateB->Draw("nostack"); - - cSummary->cd(7); - gPad->SetLogy(); - name = "stackRate_g02"; - THStack * stackRateC = new THStack( name, "Sum of counts vs Time per FEET for gDPB 3"); - fHM->H1( "FeetRate_gDPB_g02_f0" )->SetLineColor( kBlack );// => Make stack + color! - stackRateC->Add( fHM->H1( "FeetRate_gDPB_g02_f0" ) ); - fHM->H1( "FeetRate_gDPB_g02_f1" )->SetLineColor( kRed ); // => Make stack + color! - stackRateC->Add( fHM->H1( "FeetRate_gDPB_g02_f1" ) ); - fHM->H1( "FeetRate_gDPB_g02_f2" )->SetLineColor( kBlue ); // => Make stack + color! - stackRateC->Add( fHM->H1( "FeetRate_gDPB_g02_f2" ) ); - stackRateC->Draw("nostack"); - fHM->Add(name.Data(), stackRateC); - if (server) server->Register("/TofRaw", stackRateC); - - cSummary->cd(8); - gPad->SetLogy(); - name = "stackRate_g03"; - THStack * stackRateD = new THStack( name, "Sum of counts vs Time per FEET for gDPB 4"); - fHM->H1( "FeetRate_gDPB_g03_f0" )->SetLineColor( kBlack );// => Make stack + color! - stackRateD->Add( fHM->H1( "FeetRate_gDPB_g03_f0" ) ); - fHM->H1( "FeetRate_gDPB_g03_f1" )->SetLineColor( kRed ); // => Make stack + color! - stackRateD->Add( fHM->H1( "FeetRate_gDPB_g03_f1" ) ); - fHM->H1( "FeetRate_gDPB_g03_f2" )->SetLineColor( kBlue ); // => Make stack + color! - stackRateD->Add( fHM->H1( "FeetRate_gDPB_g03_f2" ) ); - stackRateD->Draw("nostack"); - fHM->Add(name.Data(), stackRateD); - if (server) server->Register("/TofRaw", stackRateD); - - cSummary->cd(11); - gPad->SetLogy(); - name = "stackRate_g04"; - THStack * stackRateE = new THStack( name, "Sum of counts vs Time per FEET for gDPB 5"); - fHM->H1( "FeetRate_gDPB_g04_f0" )->SetLineColor( kBlack ); // => Make stack + color! - stackRateE->Add( fHM->H1( "FeetRate_gDPB_g04_f0" ) ); - fHM->H1( "FeetRate_gDPB_g04_f1" )->SetLineColor( kRed ); // => Make stack + color! - stackRateE->Add( fHM->H1( "FeetRate_gDPB_g04_f1" ) ); - fHM->H1( "FeetRate_gDPB_g04_f2" )->SetLineColor( kBlue ); // => Make stack + color! - stackRateE->Add( fHM->H1( "FeetRate_gDPB_g04_f2" ) ); - stackRateE->Draw("nostack"); - fHM->Add(name.Data(), stackRateE); - if (server) server->Register("/TofRaw", stackRateE); - - cSummary->cd(12); - gPad->SetLogy(); - name = "stackRate_g05"; - THStack * stackRateF = new THStack( name, "Sum of counts vs Time per FEET for gDPB 6"); - fHM->H1( "FeetRate_gDPB_g05_f0" )->SetLineColor( kBlack ); // => Make stack + color! - stackRateF->Add( fHM->H1( "FeetRate_gDPB_g05_f0" ) ); - fHM->H1( "FeetRate_gDPB_g05_f1" )->SetLineColor( kRed ); // => Make stack + color! - stackRateF->Add( fHM->H1( "FeetRate_gDPB_g05_f1" ) ); - fHM->H1( "FeetRate_gDPB_g05_f2" )->SetLineColor( kBlue ); // => Make stack + color! - stackRateF->Add( fHM->H1( "FeetRate_gDPB_g05_f2" ) ); - stackRateF->Draw("nostack"); - fHM->Add(name.Data(), stackRateF); - if (server) server->Register("/TofRaw", stackRateF); - - name = "hDiamond"; - title = "Counts per diamond in last 10s; X [pad]; Y [pad]; Counts"; - TH2I* hDiamond = new TH2I(name, title, 2, 0., 2, 2 , 0., 2.); - fHM->Add(name.Data(), hDiamond); - if (server) server->Register("/TofRaw", fHM->H2(name.Data())); - - /*****************************/ - - LOG(info) << "Leaving CreateHistograms"; -} - -Bool_t CbmTSMonitorTofLegacy::DoUnpack(const fles::Timeslice& ts, size_t component) -{ - THttpServer* server = FairRunOnline::Instance()->GetHttpServer(); - - LOG(debug1) << "Timeslice contains " << ts.num_microslices(component) - << "microslices."; - - - // Getting the pointer to the correct histogram needs a lot more time then - // the actual filling procedure. If one gets the pointer in a loop this kills - // the performance. A test shows that extracting the pointer from the CbmHistManger - // is slower by a factor of 20-100 (depending on the number of histos managed by the - // CbmHistManager) compared to using the pointer directly - // So get the pointer once outside the loop and use it in the loop - - TH1* histMessType = fHM->H1("hMessageType"); - TH1* histSysMessType = fHM->H1("hSysMessType"); - TH2* histGet4MessType = fHM->H2("hGet4MessType"); - TH2* histGet4ChanErrors = fHM->H2("hGet4ChanErrors"); - TH2* histGet4EpochFlags = fHM->H2("hGet4EpochFlags"); - - std::vector<TH2*> Raw_Tot_gDPB; - std::vector<TH1*> ChCount_gDPB; - std::vector<TH2*> ChannelRate_gDPB; - std::vector<TH1*> FeetRate_gDPB; - - for(UInt_t i=0; i<fNrOfGdpbs; ++i) { - TString name = Form("Raw_Tot_gDPB_%02u", i); - Raw_Tot_gDPB.push_back(fHM->H2(name.Data())); - name = Form("ChCount_gDPB_%02u", i); - ChCount_gDPB.push_back(fHM->H1(name.Data())); - name = Form("ChannelRate_gDPB_%02u", i); - if( fUnpackPar->IsChannelRateEnabled() ) { - ChannelRate_gDPB.push_back(fHM->H2(name.Data())); - } - for( UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; uFeet ++) - { - name = Form("FeetRate_gDPB_g%02u_f%1u", i, uFeet); - FeetRate_gDPB.push_back(fHM->H1(name.Data())); - } // for( UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; uFeet ++) - } - TH2* histDiamond = fHM->H2("hDiamond"); - - - TString sMsSzName = Form("MsSz_link_%02lu", component); - TH1* hMsSz = NULL; - TProfile* hMsSzTime = NULL; - if( fHM->Exists(sMsSzName.Data() ) ) - { - hMsSz = fHM->H1(sMsSzName.Data()); - sMsSzName = Form("MsSzTime_link_%02lu", component); - hMsSzTime = fHM->P1(sMsSzName.Data()); - } // if( fHM->Exists(sMsSzName.Data() ) ) - else - { - TString sMsSzTitle = Form("Size of MS for gDPB of link %02lu; Ms Size [bytes]", component); - fHM->Add(sMsSzName.Data(), new TH1F( sMsSzName.Data(), sMsSzTitle.Data(), - 160000, 0., 20000. ) ); - hMsSz = fHM->H1(sMsSzName.Data()); - if (server) server->Register("/FlibRaw", hMsSz ); - sMsSzName = Form("MsSzTime_link_%02lu", component); - sMsSzTitle = Form("Size of MS vs time for gDPB of link %02lu; Time[s] ; Ms Size [bytes]", component); - fHM->Add(sMsSzName.Data(), new TProfile( sMsSzName.Data(), sMsSzTitle.Data(), - 15000, 0., 300. ) ); - hMsSzTime = fHM->P1(sMsSzName.Data()); - if (server) server->Register("/FlibRaw", hMsSzTime ); - LOG(info) << "Added MS size histo for component: " << component - << " (gDPB)"; - } // else of if( fHM->Exists(sMsSzName.Data() ) ) - - Int_t messageType = -111; - // Loop over microslices - for (size_t m = 0; m < ts.num_microslices(component); ++m) - { - if( fuMsAcceptsPercent < m ) - continue; - - constexpr uint32_t kuBytesPerMessage = 8; - - auto msDescriptor = ts.descriptor(component, m); - fEquipmentId = msDescriptor.eq_id; - const uint8_t* msContent = reinterpret_cast<const uint8_t*>(ts.content(component, m)); - - uint32_t size = msDescriptor.size; - if(size>0) - LOG(debug) << "Microslice: " << msDescriptor.idx - << " has size: " << size; - - hMsSz->Fill( size ); - hMsSzTime->Fill( (1e-9) * static_cast<double>( msDescriptor.idx) , size); -// LOG(info) << "Test: " << ((1e-9) * static_cast<double>( msDescriptor.idx)) -// << " s for size: " << size; - - // If not integer number of message in input buffer, print warning/error - if( 0 != (size % kuBytesPerMessage) ) - LOG(error) << "The input microslice buffer does NOT " - << "contain only complete nDPB messages!"; - - // Compute the number of complete messages in the input microslice buffer - uint32_t uNbMessages = (size - (size % kuBytesPerMessage) ) - / kuBytesPerMessage; - - // Prepare variables for the loop on contents - const uint64_t* pInBuff = reinterpret_cast<const uint64_t*>( msContent ); - for (uint32_t uIdx = 0; uIdx < uNbMessages; uIdx ++) - { - // Fill message - uint64_t ulData = static_cast<uint64_t>( pInBuff[uIdx] ); - ngdpb::Message mess( ulData ); - - if(gLogger->IsLogNeeded( fair::Severity::debug )) { - mess.printDataCout(); - } - - // Increment counter for different message types - // and fill the corresponding histogram - messageType = mess.getMessageType(); - fMsgCounter[messageType]++; - histMessType->Fill(messageType); - - Int_t rocId = fGdpbIdIndexMap[mess.getRocNumber()]; - Int_t get4Id = mess.getGdpbGenChipId(); - Int_t get4Nr = (rocId*fNrOfGet4PerGdpb) + get4Id; - - switch( messageType ) - { - case ngdpb::MSG_HIT: - // FillHitInfo(mess); - LOG(error) << "Message type " << messageType - << " not yet included in unpacker."; - break; - case ngdpb::MSG_EPOCH: - // FillEpochInfo(mess); - LOG(error) << "Message type " << messageType - << " not yet included in unpacker."; - break; - case ngdpb::MSG_SYS: - histSysMessType->Fill(mess.getSysMesType()); - break; - case ngdpb::MSG_EPOCH2: - histGet4MessType->Fill(get4Nr, ngdpb::GET4_32B_EPOCH); - FillEpochInfo(mess, histGet4EpochFlags); - break; - case ngdpb::MSG_GET4: - histGet4MessType->Fill(get4Nr, ngdpb::GET4_32B_DATA + 1); - PrintGenInfo(mess); - break; - case ngdpb::MSG_GET4_32B: - histGet4MessType->Fill(get4Nr, ngdpb::GET4_32B_DATA); - FillHitInfo(mess, Raw_Tot_gDPB, ChCount_gDPB, ChannelRate_gDPB, FeetRate_gDPB, histDiamond); - break; - case ngdpb::MSG_GET4_SLC: - histGet4MessType->Fill(get4Nr, ngdpb::GET4_32B_SLCM); - PrintSlcInfo(mess); - break; - case ngdpb::MSG_GET4_SYS: - { - histSysMessType->Fill( mess.getGdpbSysSubType() ); - if( ngdpb::SYSMSG_GET4_EVENT == mess.getGdpbSysSubType() ) { - histGet4MessType->Fill(get4Nr, ngdpb::GET4_32B_ERROR); - Int_t dFullChId = (rocId*fNrOfGet4PerGdpb - + get4Id)*fNrOfChannelsPerGet4 - + mess.getGdpbHitChanId(); - switch( mess.getGdpbSysErrData() ) - { - case ngdpb::GET4_V1X_ERR_READ_INIT: - histGet4ChanErrors->Fill( dFullChId, 0); - break; - case ngdpb::GET4_V1X_ERR_SYNC: - histGet4ChanErrors->Fill( dFullChId, 1); - break; - case ngdpb::GET4_V1X_ERR_EP_CNT_SYNC: - histGet4ChanErrors->Fill( dFullChId, 2); - break; - case ngdpb::GET4_V1X_ERR_EP: - histGet4ChanErrors->Fill( dFullChId, 3); - break; - case ngdpb::GET4_V1X_ERR_FIFO_WRITE: - histGet4ChanErrors->Fill( dFullChId, 4); - break; - case ngdpb::GET4_V1X_ERR_LOST_EVT: - histGet4ChanErrors->Fill( dFullChId, 5); - break; - case ngdpb::GET4_V1X_ERR_CHAN_STATE: - histGet4ChanErrors->Fill( dFullChId, 6); - break; - case ngdpb::GET4_V1X_ERR_TOK_RING_ST: - histGet4ChanErrors->Fill( dFullChId, 7); - break; - case ngdpb::GET4_V1X_ERR_TOKEN: - histGet4ChanErrors->Fill( dFullChId, 8); - break; - case ngdpb::GET4_V1X_ERR_READOUT_ERR: - histGet4ChanErrors->Fill( dFullChId, 9); - break; - case ngdpb::GET4_V1X_ERR_SPI: - histGet4ChanErrors->Fill( dFullChId, 10); - break; - case ngdpb::GET4_V1X_ERR_DLL_LOCK: - histGet4ChanErrors->Fill( dFullChId, 11); - break; - case ngdpb::GET4_V1X_ERR_DLL_RESET: - histGet4ChanErrors->Fill( dFullChId, 12); - break; - case ngdpb::GET4_V1X_ERR_TOT_OVERWRT: - histGet4ChanErrors->Fill( dFullChId, 13); - break; - case ngdpb::GET4_V1X_ERR_TOT_RANGE: - histGet4ChanErrors->Fill( dFullChId, 14); - break; - case ngdpb::GET4_V1X_ERR_EVT_DISCARD: - histGet4ChanErrors->Fill( dFullChId, 15); - break; - case ngdpb::GET4_V1X_ERR_UNKNOWN: - histGet4ChanErrors->Fill( dFullChId, 16); - break; - default: // Corrupt error or not yet supported error - histGet4ChanErrors->Fill( dFullChId, 17); - break; - } // Switch( mess.getGdpbSysErrData() ) - - } - if(100 > iMess++) - PrintSysInfo(mess); - break; - } - default: - if(100 > iMess++) - LOG(error) << "Message ("<<iMess<<") type " << std::hex << std::setw(2) - << static_cast< uint16_t >( messageType ) - << " not yet included in Get4 unpacker."; - if(100 == iMess) - LOG(error) << "Stop reporting MSG errors... "; - } // switch( mess.getMessageType() ) - } // for (uint32_t uIdx = 0; uIdx < uNbMessages; uIdx ++) - } // for (size_t m = 0; m < ts.num_microslices(component); ++m) - - return kTRUE; -} - -void CbmTSMonitorTofLegacy::FillHitInfo(ngdpb::Message mess, - std::vector<TH2*> Raw_Tot_gDPB, - std::vector<TH1*> ChCount_gDPB, - std::vector<TH2*> ChannelRate_gDPB, - std::vector<TH1*> FeetRate_gDPB, - TH2* histDiamond -) - { - // --- Get absolute time, NXYTER and channel number - Int_t rocId = mess.getRocNumber(); - Int_t get4Id = mess.getGdpbGenChipId(); - Int_t channel = mess.getGdpbHitChanId(); - Int_t tot = mess.getGdpbHit32Tot(); - ULong_t hitTime = mess.getMsgFullTime( 0 ); - - if( fGdpbIdIndexMap.end() != fGdpbIdIndexMap.find( rocId ) ) - { - // Check if at least one epoch before in this gDPB - if( fCurrentEpoch.end() != fCurrentEpoch.find( rocId ) ) - { - UInt_t gdpbNr = fGdpbIdIndexMap[ rocId ]; - Raw_Tot_gDPB[gdpbNr]->Fill( get4Id*fNrOfChannelsPerGet4 + channel, tot); - ChCount_gDPB[gdpbNr]->Fill( get4Id*fNrOfChannelsPerGet4 + channel ); - - // Check if at least one epoch before in this GET4 - if( fCurrentEpoch[rocId].end() != fCurrentEpoch[rocId].find( get4Id ) ) - { - if( fUnpackPar->IsChannelRateEnabled() ) - { - // Check if at least one hit before in this gDPB - if( fTsLastHit.end() != fTsLastHit.find( rocId ) ) - { - // Check if at least one hit before in this Get4 - if( fTsLastHit[rocId].end() != fTsLastHit[rocId].find( get4Id ) ) - { - // Check if at least one hit before in this channel - if( fTsLastHit[rocId][get4Id].end() != fTsLastHit[rocId][get4Id].find( channel ) ) - { - ChannelRate_gDPB[gdpbNr]->Fill( ( mess.getMsgFullTimeD( fCurrentEpoch[rocId][get4Id] ) - - fTsLastHit[rocId][get4Id][channel] ), - get4Id*fNrOfChannelsPerGet4 + channel); - } // if( fTsLastHit[rocId][get4Id].end() != fTsLastHit[rocId][get4Id].find( channel ) ) - } // if( fTsLastHit[rocId].end() != fTsLastHit[rocId].find( get4Id ) ) - } // if( fTsLastHit.end() != fTsLastHit.find( rocId ) ) - - fTsLastHit[rocId][get4Id][channel] = mess.getMsgFullTimeD( fCurrentEpoch[rocId][get4Id] ); - } // if( fUnpackPar->IsChannelRateEnabled() ) - - if( fdStartTime < 0 ) - fdStartTime = mess.getMsgFullTimeD( fCurrentEpoch[rocId][get4Id] ); - - if( 0 < fdStartTime ) - FeetRate_gDPB[ (gdpbNr*fNrOfFebsPerGdpb) + (get4Id / fNrOfGet4PerFeb) ]->Fill( - 1e-9*( mess.getMsgFullTimeD( fCurrentEpoch[rocId][get4Id] ) - - fdStartTime) ); - - if( fDiamondGdpb == gdpbNr && ( get4Id/fNrOfGet4PerFeb == fDiamondFeet ) ) - { - UInt_t uChanInGdpb = get4Id * fNrOfChannelsPerGet4 + channel; - if( fDiamondChanA == uChanInGdpb ) - histDiamond->Fill( 0., 0.); - else if( fDiamondChanB == uChanInGdpb ) - histDiamond->Fill( 1., 0.); - else if( fDiamondChanC == uChanInGdpb ) - histDiamond->Fill( 0., 1.); - else if( fDiamondChanD == uChanInGdpb ) - histDiamond->Fill( 1., 1.); - - if( 10 < ( (mess.getMsgFullTimeD( fCurrentEpoch[rocId][get4Id] )/1e9) - fDiamondTimeLastReset ) ) - { - histDiamond->Reset(); - fDiamondTimeLastReset = mess.getMsgFullTimeD( fCurrentEpoch[rocId][get4Id] )/1e9; - } // if( 1e10 < ( mess.getMsgFullTimeD( fCurrentEpoch[rocId][get4Id] ) - fDiamondTimeLastReset ) - - } // if( fDiamondGdpb == gdpbNr && ( get4Id/fNrOfGet4PerFeb == fDiamondFeet ) ) - - hitTime = mess.getMsgFullTime(fCurrentEpoch[rocId][get4Id]); - Int_t Ft = mess.getGdpbHitFineTs(); - - if(100 > iMess++) - LOG(debug) << "Hit: " << Form("0x%08x ",rocId) << ", " << get4Id - << ", " << channel << ", " << tot - << ", epoch " << fCurrentEpoch[rocId][get4Id] - << ", FullTime " << hitTime - << ", FineTime " << Ft; - } // if( fCurrentEpoch[rocId].end() != fCurrentEpoch[rocId].find( get4Id ) ) - } // if( fCurrentEpoch.end() != fCurrentEpoch.find( rocId ) ) - } // if( fGdpbIdIndexMap.end() != fGdpbIdIndexMap.find( rocId ) ) - else LOG(warning) << "found unmapped rocId w/o epoch yet: " << Form("0x%08x ",rocId); -} - -void CbmTSMonitorTofLegacy::FillEpochInfo(ngdpb::Message mess, TH2* EpochFlags) -{ - Int_t rocId = mess.getRocNumber(); - Int_t get4Id = mess.getGdpbGenChipId(); - - Int_t gdpbIdx = fGdpbIdIndexMap[rocId]; - Int_t get4Nr = (gdpbIdx*fNrOfGet4PerGdpb) + get4Id; - - fCurrentEpoch[rocId][get4Id] = mess.getEpoch2Number(); - - // LOG(info) << "Epoch message for ROC " << rocId << " with epoch number " - // << fCurrentEpoch[rocId]; - - if( 1 == mess.getGdpbEpSync() ) - EpochFlags->Fill( get4Nr, 0 ); - if( 1 == mess.getGdpbEpDataLoss() ) - EpochFlags->Fill( get4Nr, 1 ); - if( 1 == mess.getGdpbEpEpochLoss() ) - EpochFlags->Fill( get4Nr, 2 ); - if( 1 == mess.getGdpbEpMissmatch() ) - EpochFlags->Fill( get4Nr, 3 ); - -/* - if( 0 == gdpbIdx && 0 == mess.getEpoch2Number() % 20000 ) // Try to force update every 1s - { - dynamic_cast< TCanvas * >(gROOT->FindObjectAny( "cSummary" ) )->cd(3); - gPad->Modified(); - gPad->Update(); - } -*/ - - fCurrentEpochTime = mess.getMsgFullTime(fCurrentEpoch[rocId][get4Id]); - fNofEpochs++; -/* - LOG(debug) << "Epoch message " - << fNofEpochs << ", epoch " << static_cast<Int_t>(fCurrentEpoch[rocId][get4Id]) - << ", time " << std::setprecision(9) << std::fixed - << Double_t(fCurrentEpochTime) * 1.e-9 << " s " - << " for board ID " << std::hex << std::setw(4) << rocId << std::dec - << " and chip " << mess.getEpoch2ChipNumber(); -*/ -} - -void CbmTSMonitorTofLegacy::PrintSlcInfo(ngdpb::Message mess) -{ - Int_t rocId = mess.getRocNumber(); - Int_t get4Id = mess.getGdpbGenChipId(); - - if( fGdpbIdIndexMap.end() != fGdpbIdIndexMap.find( rocId ) ) - LOG(info) << "GET4 Slow Control message, epoch " << static_cast<Int_t>(fCurrentEpoch[rocId][get4Id]) - << ", time " << std::setprecision(9) << std::fixed - << Double_t(fCurrentEpochTime) * 1.e-9 << " s " - << " for board ID " << std::hex << std::setw(4) << rocId << std::dec - << "\n" - << " +++++++ > Chip = " << std::setw(2) << mess.getGdpbGenChipId() - << ", Chan = " << std::setw(1) << mess.getGdpbSlcChan() - << ", Edge = " << std::setw(1) << mess.getGdpbSlcEdge() - << ", Type = " << std::setw(1) << mess.getGdpbSlcType() - << ", Data = " << std::hex << std::setw(6) << mess.getGdpbSlcData() << std::dec - << ", Type = " << mess.getGdpbSlcCrc(); - -} - -void CbmTSMonitorTofLegacy::PrintGenInfo(ngdpb::Message mess) -{ - Int_t mType = mess.getMessageType(); - Int_t rocId = mess.getRocNumber(); - Int_t get4Id = mess.getGdpbGenChipId(); - Int_t channel = mess.getGdpbHitChanId(); - uint64_t uData = mess.getData(); - - if(100 > iMess++) - LOG(info) << "Get4 MSG type "<<mType<<" from rocId "<<rocId<<", getId "<<get4Id - << ", (hit channel) "<< channel << " data " << std::hex - << uData; -} - -void CbmTSMonitorTofLegacy::PrintSysInfo(ngdpb::Message mess) -{ - Int_t rocId = mess.getRocNumber(); - Int_t get4Id = mess.getGdpbGenChipId(); - - if( fGdpbIdIndexMap.end() != fGdpbIdIndexMap.find( rocId ) ) - LOG(debug) << "GET4 System message, epoch " << static_cast<Int_t>(fCurrentEpoch[rocId][get4Id]) - << ", time " << std::setprecision(9) << std::fixed - << Double_t(fCurrentEpochTime) * 1.e-9 << " s " - << " for board ID " << std::hex << std::setw(4) << rocId << std::dec; - - switch( mess.getGdpbSysSubType() ) - { - case ngdpb::SYSMSG_GET4_EVENT: - { - uint32_t uData = mess.getGdpbSysErrData(); - if( ngdpb::GET4_V1X_ERR_TOT_OVERWRT == uData || - ngdpb::GET4_V1X_ERR_TOT_RANGE == uData || - ngdpb::GET4_V1X_ERR_EVT_DISCARD == uData ) - LOG(debug) << " +++++++ > gDPB: " - << std::hex << std::setw(4) << rocId << std::dec - << ", Chip = " << std::setw(2) << mess.getGdpbGenChipId() - << ", Chan = " << std::setw(1) << mess.getGdpbSysErrChanId() - << ", Edge = " << std::setw(1) << mess.getGdpbSysErrEdge() - << ", Empt = " << std::setw(1) << mess.getGdpbSysErrUnused() - << ", Data = " << std::hex << std::setw(2) << uData << std::dec - << " -- GET4 V1 Error Event"; - else LOG(info) << " +++++++ >gDPB: " - << std::hex << std::setw(4) << rocId << std::dec - << ", Chip = " << std::setw(2) << mess.getGdpbGenChipId() - << ", Chan = " << std::setw(1) << mess.getGdpbSysErrChanId() - << ", Edge = " << std::setw(1) << mess.getGdpbSysErrEdge() - << ", Empt = " << std::setw(1) << mess.getGdpbSysErrUnused() - << ", Data = " << std::hex << std::setw(2) << uData << std::dec - << " -- GET4 V1 Error Event"; - break; - } // case ngdpb::SYSMSG_GET4_EVENT - case ngdpb::SYSMSG_CLOSYSYNC_ERROR: - LOG(info) << "Closy synchronization error"; - break; - case ngdpb::SYSMSG_TS156_SYNC: - LOG(debug) << "156.25MHz timestamp reset"; - break; - case ngdpb::SYSMSG_GDPB_UNKWN: - LOG(info) << "Unknown GET4 message, data: " << std::hex << std::setw(8) - << mess.getGdpbSysUnkwData() << std::dec; - break; - } // switch( getGdpbSysSubType() ) -} - -void CbmTSMonitorTofLegacy::Reset() -{ -} - -void CbmTSMonitorTofLegacy::Finish() -{ - TString message_type; - - for (unsigned int i=0; i< fMsgCounter.size(); ++i) - { - switch(i) - { - case 0: message_type ="NOP"; break; - case 1: message_type ="HIT"; break; - case 2: message_type ="EPOCH"; break; - case 3: message_type ="SYNC"; break; - case 4: message_type ="AUX"; break; - case 5: message_type ="EPOCH2"; break; - case 6: message_type ="GET4"; break; - case 7: message_type ="SYS"; break; - case 8: message_type ="GET4_SLC"; break; - case 9: message_type ="GET4_32B"; break; - case 10: message_type ="GET4_SYS"; break; - default: message_type ="UNKNOWN"; break; - } // switch(i) - LOG(info) << message_type << " messages: " - << fMsgCounter[i]; - } // for (unsigned int i=0; i< fMsgCounter.size(); ++i) - - LOG(info) << "-------------------------------------"; - for( auto it = fCurrentEpoch.begin(); it != fCurrentEpoch.end(); ++it) - for( auto itG = (it->second).begin(); itG != (it->second).end(); ++itG) - LOG(info) << "Last epoch for gDPB: " - << std::hex << std::setw(4) << it->first << std::dec - << " , GET4 " << std::setw(4) << itG->first - << " => " << itG->second; - LOG(info) << "-------------------------------------"; - - - gDirectory->mkdir("Tof_Raw_gDPB"); - gDirectory->cd("Tof_Raw_gDPB"); - for( UInt_t uGdpb = 0; uGdpb < fuMinNbGdpb; uGdpb ++) - { - fHM->H2( Form("Raw_Tot_gDPB_%02u", uGdpb) )->Write(); - fHM->H1( Form("ChCount_gDPB_%02u", uGdpb) )->Write(); - if( fUnpackPar->IsChannelRateEnabled() ) - fHM->H2( Form("ChannelRate_gDPB_%02u", uGdpb) )->Write(); - for( UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; uFeet ++) - { - fHM->H1( Form("FeetRate_gDPB_g%02u_f%1u", uGdpb, uFeet) )->Write(); - } // for( UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; uFeet ++) - } // for( UInt_t uGdpb = 0; uGdpb < fuMinNbGdpb; uGdpb ++) - gDirectory->cd(".."); - - gDirectory->mkdir("Flib_Raw"); - gDirectory->cd("Flib_Raw"); - for( UInt_t uLinks = 0; uLinks < 16; uLinks ++) - { - TString sMsSzName = Form("MsSz_link_%02u", uLinks); - if( fHM->Exists(sMsSzName.Data() ) ) - fHM->H1( sMsSzName.Data() )->Write(); - - sMsSzName = Form("MsSzTime_link_%02u", uLinks); - if( fHM->Exists(sMsSzName.Data() ) ) - fHM->P1( sMsSzName.Data() )->Write(); - } // for( UInt_t uLinks = 0; uLinks < 16; uLinks ++) - gDirectory->cd(".."); - -} - - -void CbmTSMonitorTofLegacy::FillOutput(boost::any) -{ -} - - - -void CbmTSMonitorTofLegacy::SetDiamondChannels( UInt_t uGdpb, UInt_t uFeet, UInt_t uChannelA, - UInt_t uChannelB, UInt_t uChannelC, UInt_t uChannelD) -{ - fDiamondGdpb = uGdpb; - fDiamondFeet = uFeet; - fDiamondChanA = uChannelA; - fDiamondChanB = uChannelB; - fDiamondChanC = uChannelC; - fDiamondChanD = uChannelD; -} - -void CbmTSMonitorTofLegacy::ResetAllHistos() -{ - fHM->H1( "hMessageType" )->Reset(); - fHM->H1( "hSysMessType" )->Reset(); - fHM->H2( "hGet4MessType" )->Reset(); - fHM->H2( "hGet4ChanErrors" )->Reset(); - fHM->H2( "hGet4EpochFlags")->Reset(); - - for( UInt_t uGdpb = 0; uGdpb < fuMinNbGdpb; uGdpb ++) - { - fHM->H2( Form("Raw_Tot_gDPB_%02u", uGdpb) )->Reset(); - fHM->H1( Form("ChCount_gDPB_%02u", uGdpb) )->Reset(); - if( fUnpackPar->IsChannelRateEnabled() ) - fHM->H2( Form("ChannelRate_gDPB_%02u", uGdpb) )->Reset(); - for( UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; uFeet ++) - { - fHM->H1( Form("FeetRate_gDPB_g%02u_f%1u", uGdpb, uFeet) )->Reset(); - } // for( UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; uFeet ++) - } // for( UInt_t uGdpb = 0; uGdpb < fuMinNbGdpb; uGdpb ++) - - for( UInt_t uLinks = 0; uLinks < 16; uLinks ++) - { - TString sMsSzName = Form("MsSz_link_%02u", uLinks); - if( fHM->Exists(sMsSzName.Data() ) ) - fHM->H1( sMsSzName.Data() )->Reset(); - - sMsSzName = Form("MsSzTime_link_%02u", uLinks); - if( fHM->Exists(sMsSzName.Data() ) ) - fHM->P1( sMsSzName.Data() )->Reset(); - } // for( UInt_t uLinks = 0; uLinks < 16; uLinks ++) -} - -ClassImp(CbmTSMonitorTofLegacy) diff --git a/beamtime/cern2016/unpacker/CbmTSMonitorTofLegacy.h b/beamtime/cern2016/unpacker/CbmTSMonitorTofLegacy.h deleted file mode 100644 index 738aab439e73695fb540e587912eb105e63cd214..0000000000000000000000000000000000000000 --- a/beamtime/cern2016/unpacker/CbmTSMonitorTofLegacy.h +++ /dev/null @@ -1,116 +0,0 @@ -#// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmTSMonitorTof ----- -// ----- Created 11.11.2016 by P.-A. Loizeau ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CbmTSMonitorTofLegacy_H -#define CbmTSMonitorTofLegacy_H - -#include "Timeslice.hpp" -#include "rocMess_wGet4v1.h" - -#include "CbmTSUnpack.h" -#include "CbmHistManager.h" - -#include "TClonesArray.h" -#include "Rtypes.h" - -#include <vector> -#include <map> - -class CbmTofUnpackPar; - -class CbmTSMonitorTofLegacy : public CbmTSUnpack -{ -public: - - CbmTSMonitorTofLegacy(); - virtual ~CbmTSMonitorTofLegacy(); - - virtual Bool_t Init(); - - virtual Bool_t DoUnpack(const fles::Timeslice& ts, size_t component); - - virtual void Reset(); - - virtual void Finish(); - - void SetParContainers(); - - Bool_t InitContainers(); - - Bool_t ReInitContainers(); - - - void FillOutput(boost::any); - - void SetMsLimitLevel( size_t uAcceptBoundaryPct = 100 ) { fuMsAcceptsPercent = uAcceptBoundaryPct; } - size_t GetMsLimitLevel( ) { return fuMsAcceptsPercent; } - - void SetDiamondChannels( UInt_t uGdpb = 0, UInt_t uFeet = 2, UInt_t uChannelA = 78, - UInt_t uChannelB = 70, UInt_t uChannelC = 94, UInt_t uChannelD = 86 ); - - void ResetAllHistos(); - -private: - - size_t fuMsAcceptsPercent; /** Reject Ms with index inside TS above this, assumes 100 MS per TS **/ - UInt_t fuMinNbGdpb; - UInt_t fuCurrNbGdpb; - - UInt_t fNrOfGdpbs; // Total number of GDPBs in the system - UInt_t fNrOfFebsPerGdpb; // Number of FEBs per GDPB - UInt_t fNrOfGet4PerFeb; // Number of GET4s per FEB - UInt_t fNrOfChannelsPerGet4; // Number of channels in each GET4 - - UInt_t fNrOfGet4; // Total number of Get4 chips in the system - UInt_t fNrOfGet4PerGdpb; // Number of GET4s per GDPB - - UInt_t fDiamondGdpb; - UInt_t fDiamondFeet; - UInt_t fDiamondChanA; - UInt_t fDiamondChanB; - UInt_t fDiamondChanC; - UInt_t fDiamondChanD; - UInt_t fDiamondTimeLastReset; - - std::vector<int> fMsgCounter; - - std::map<UInt_t, UInt_t> fGdpbIdIndexMap; - - CbmHistManager* fHM; ///< Histogram manager - - /** Current epoch marker for each ROC and GET4 (first epoch in the stream initialises the map item) **/ - std::map<Int_t, std::map<Int_t, UInt_t> > fCurrentEpoch; - Int_t fNofEpochs; /** Current epoch marker for each ROC **/ - ULong_t fCurrentEpochTime; /** Time stamp of current epoch **/ - Double_t fdStartTime; /** Time of first valid hit (epoch available), used as reference for evolution plots**/ - - /** Used only if the channel rate plots are enabled **/ - /** Last Hit time for each ROC/GET4/Channel (first hit in the stream initialises the map item) **/ - std::map<Int_t, std::map<Int_t, std::map<Int_t, Double_t> > > fTsLastHit; // * 6.25 ns - - Int_t fEquipmentId; - - CbmTofUnpackPar* fUnpackPar; //! - - void CreateHistograms(); - - void FillHitInfo(ngdpb::Message, std::vector<TH2*>, - std::vector<TH1*>, std::vector<TH2*>, - std::vector<TH1*>, TH2* - ); - void FillEpochInfo(ngdpb::Message, TH2*); - void PrintSlcInfo(ngdpb::Message); - void PrintSysInfo(ngdpb::Message); - void PrintGenInfo(ngdpb::Message); - - CbmTSMonitorTofLegacy(const CbmTSMonitorTofLegacy&); - CbmTSMonitorTofLegacy operator=(const CbmTSMonitorTofLegacy&); - - ClassDef(CbmTSMonitorTofLegacy, 1) -}; - -#endif diff --git a/beamtime/cern2016/unpacker/CbmTSUnpackFHodo.cxx b/beamtime/cern2016/unpacker/CbmTSUnpackFHodo.cxx deleted file mode 100644 index f780ceef84e81ea9135a168f3bd014a466ec8cc9..0000000000000000000000000000000000000000 --- a/beamtime/cern2016/unpacker/CbmTSUnpackFHodo.cxx +++ /dev/null @@ -1,320 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmTSUnpackTest ----- -// ----- Created 07.11.2014 by F. Uhlig ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#include "CbmTSUnpackFHodo.h" -#include "CbmFHodoUnpackPar.h" - -#include "CbmTbDaqBuffer.h" - -#include "CbmFiberHodoAddress.h" -#include "CbmHistManager.h" - -#include "FairLogger.h" -#include "FairRootManager.h" -#include "FairRun.h" -#include "FairRuntimeDb.h" - -#include "TClonesArray.h" -#include "TString.h" - -#include <iostream> -#include <stdint.h> -#include <iomanip> - -using std::hex; -using std::dec; - -CbmTSUnpackFHodo::CbmTSUnpackFHodo() - : CbmTSUnpack(), - fMsgCounter(11,0), // length of enum MessageTypes initialized with 0 - fHodoStationMap(), - fHodoFiber(), - fHodoPlane(), - fHodoPixel(), - fHM(new CbmHistManager()), - fCurrentEpoch(), - fNofEpochs(0), - fCurrentEpochTime(0.), - fEquipmentId(0), - fFiberHodoRaw(new TClonesArray("CbmNxyterRawMessage", 10)), - fFiberHodoDigi(new TClonesArray("CbmFiberHodoDigi", 10)), - fRawMessage(NULL), - fDigi(NULL), - fBuffer(CbmTbDaqBuffer::Instance()), - fCreateRawMessage(kFALSE), - fUnpackPar(NULL) -{ -} - -CbmTSUnpackFHodo::~CbmTSUnpackFHodo() -{ -} - -Bool_t CbmTSUnpackFHodo::Init() -{ - LOG(info) << "Initializing flib nxyter unpacker"; - - FairRootManager* ioman = FairRootManager::Instance(); - if (ioman == NULL) { - LOG(fatal) << "No FairRootManager instance"; - } - - if (fCreateRawMessage) { - ioman->Register("FiberHodoRawMessage", "fiberhodo raw data", fFiberHodoRaw, kTRUE); - } - ioman->Register("FiberHodoDigi", "fiber hodo digi", fFiberHodoDigi, kTRUE); - - CreateHistograms(); - return kTRUE; -} - -void CbmTSUnpackFHodo::SetParContainers() -{ - LOG(info) << "Setting parameter containers for " << GetName(); - fUnpackPar = (CbmFHodoUnpackPar*)(FairRun::Instance()->GetRuntimeDb()->getContainer("CbmFHodoUnpackPar")); -} - - -Bool_t CbmTSUnpackFHodo::InitContainers() -{ - LOG(info) << "Init parameter containers for " << GetName(); - return ReInitContainers(); - -} - -Bool_t CbmTSUnpackFHodo::ReInitContainers() -{ - LOG(info) << "ReInit parameter containers for " << GetName(); - - Int_t nrOfRocs = fUnpackPar->GetNrOfRocs(); - - LOG(info) << "Nr. of Rocs: " << nrOfRocs; - - fHodoStationMap.clear(); - for (Int_t i = 0; i< nrOfRocs; ++i) { - fHodoStationMap[fUnpackPar->GetRocId(i)] = i; - LOG(info) << "Roc Id of fiber hodo station " << i - << " : " << fUnpackPar->GetRocId(i); - } - - Int_t nrOfChannels = fUnpackPar->GetNumberOfChannels(); - - for (Int_t i = 0; i< nrOfRocs; ++i) { - fHodoFiber[i] = fUnpackPar->GetChannelToFiberMap(i); - fHodoPixel[i] = fUnpackPar->GetChannelToPixelMap(i); - fHodoPlane[i] = fUnpackPar->GetChannelToPlaneMap(i); - } - - LOG(info) << "Nr. of Channels: " << nrOfChannels; - - return kTRUE; -} - -void CbmTSUnpackFHodo::CreateHistograms() -{ - fHM->Add("Raw_ADC_FrontHodo", - new TH2F("Raw_ADC_FrontHodo", - "Raw_ADC_FrontHodo;channel;ADC value", 128, 0, 127, 4096, 0, 4095)); - fHM->Add("Raw_ADC_RearHodo", - new TH2F("Raw_ADC_RearHodo", - "Raw_ADC_RearHodo;channel;ADC value", 128, 0, 127, 4096, 0, 4095)); -} - -Bool_t CbmTSUnpackFHodo::DoUnpack(const fles::Timeslice& ts, size_t component) -{ - - LOG(debug) << "Timeslice contains " << ts.num_microslices(component) - << "microslices."; - - // Loop over microslices - for (size_t m = 0; m < ts.num_microslices(component); ++m) - { - - constexpr uint32_t kuBytesPerMessage = 8; - - auto msDescriptor = ts.descriptor(component, m); - fEquipmentId = msDescriptor.eq_id; - const uint8_t* msContent = reinterpret_cast<const uint8_t*>(ts.content(component, m)); - - uint32_t size = msDescriptor.size; - LOG(debug) << "Microslice: " << msDescriptor.idx - << " has size: " << size; - - // If not integer number of message in input buffer, print warning/error - if( 0 != (size % kuBytesPerMessage) ) - LOG(error) << "The input microslice buffer does NOT " - << "contain only complete nDPB messages!"; - - // Compute the number of complete messages in the input microslice buffer - uint32_t uNbMessages = (size - (size % kuBytesPerMessage) ) - / kuBytesPerMessage; - - // Prepare variables for the loop on contents - const uint64_t* pInBuff = reinterpret_cast<const uint64_t*>( msContent ); - for (uint32_t uIdx = 0; uIdx < uNbMessages; uIdx ++) - { - // Fill message - uint64_t ulData = static_cast<uint64_t>( pInBuff[uIdx] ); - ngdpb::Message mess( ulData ); - - if(gLogger->IsLogNeeded( fair::Severity::debug )) { - mess.printDataCout(); - } - - // Increment counter for different message types - fMsgCounter[mess.getMessageType()]++; - - switch(mess.getMessageType()) { - case ngdpb::MSG_HIT: - FillHitInfo(mess); - break; - case ngdpb::MSG_EPOCH: - FillEpochInfo(mess); - break; - case ngdpb::MSG_SYNC: - // Do nothing, this message is just there to make sure we get all Epochs - break; - default: - LOG(error) << "Message type " << std::hex << std::setw(2) - << static_cast< uint16_t >( mess.getMessageType() ) - << " not yet include in nXYTER unpacker."; - } - - - - } // for (uint32_t uIdx = 0; uIdx < uNbMessages; uIdx ++) - - } - - - return kTRUE; -} - -void CbmTSUnpackFHodo::FillHitInfo(ngdpb::Message mess) -{ - // --- Get absolute time, NXYTER and channel number - Int_t rocId = mess.getRocNumber(); - Int_t nxyterId = mess.getNxNumber(); - Int_t nxChannel = mess.getNxChNum(); - Int_t charge = mess.getNxAdcValue(); - ULong_t hitTime = mess.getMsgFullTime(fCurrentEpoch[rocId]); - - if (fCreateRawMessage) { - fRawMessage = new( (*fFiberHodoRaw)[fFiberHodoRaw->GetEntriesFast()] ) - CbmNxyterRawMessage(fEquipmentId, - rocId*4 + nxyterId, //TODO check - nxChannel, - fCurrentEpoch[rocId], // note the trick - mess.getNxTs(), - charge, - mess.getNxLastEpoch(), - mess.getNxPileup(), - mess.getNxOverflow()); - } - - LOG(debug) << "Hit: " << rocId << ", " << nxyterId - << ", " << nxChannel << ", " << charge; - - if (fHodoStationMap.find(rocId) != fHodoStationMap.end()) { - Int_t station = fHodoStationMap[rocId]; - Int_t plane = fHodoPlane[nxChannel]; - Int_t fiber = fHodoFiber[nxChannel]; - - Int_t address = CbmFiberHodoAddress::GetAddress(station, plane, fiber); - - - LOG(debug) << "Create digi with time " << hitTime - << " at epoch " << fCurrentEpoch[rocId]; - - fDigi = new CbmFiberHodoDigi(address, charge, hitTime); - - fBuffer->InsertData<CbmFiberHodoDigi>(fDigi); - - if ( 0 == station ) { - fHM->H2("Raw_ADC_FrontHodo")->Fill(nxChannel,charge); - } else { - fHM->H2("Raw_ADC_RearHodo")->Fill(nxChannel,charge); - } - } else { - LOG(error) << "Unknown Roc Id " << rocId; - } - -} - -void CbmTSUnpackFHodo::FillEpochInfo(ngdpb::Message mess) -{ - Int_t rocId = mess.getRocNumber(); - fCurrentEpoch[rocId] = mess.getEpochNumber(); - - // LOG(info) << "Epoch message for ROC " << rocId << " with epoch number " - // << fCurrentEpoch[rocId]; - - fCurrentEpochTime = mess.getMsgFullTime(fCurrentEpoch[rocId]); - fNofEpochs++; - LOG(debug) << "Epoch message " - << fNofEpochs << ", epoch " << static_cast<Int_t>(fCurrentEpoch[rocId]) - << ", time " << std::setprecision(9) << std::fixed - << Double_t(fCurrentEpochTime) * 1.e-9 << " s " - << " for board ID " << std::hex << std::setw(4) << rocId << std::dec; - -} - -void CbmTSUnpackFHodo::Reset() -{ - if (fCreateRawMessage) { - fFiberHodoRaw->Clear(); - } - fFiberHodoDigi->Clear(); -} - -void CbmTSUnpackFHodo::Finish() -{ - TString message_type; - - for (unsigned int i=0; i< fMsgCounter.size(); ++i) { - switch(i) { - case 0: message_type ="NOP"; break; - case 1: message_type ="HIT"; break; - case 2: message_type ="EPOCH"; break; - case 3: message_type ="SYNC"; break; - case 4: message_type ="AUX"; break; - case 5: message_type ="EPOCH2"; break; - case 6: message_type ="GET4"; break; - case 7: message_type ="SYS"; break; - case 8: message_type ="GET4_SLC"; break; - case 9: message_type ="GET4_32B"; break; - case 10: message_type ="GET4_SYS"; break; - } - LOG(info) << message_type << " messages: " - << fMsgCounter[i]; - } - - LOG(info) << "-------------------------------------"; - for( auto it = fCurrentEpoch.begin(); it != fCurrentEpoch.end(); ++it) - LOG(info) << "Last epoch for nDPB: " - << std::hex << std::setw(4) << it->first - << " => " << it->second ; - LOG(info) << "-------------------------------------"; - - gDirectory->mkdir("Hodo_Raw"); - gDirectory->cd("Hodo_Raw"); - fHM->H2("Raw_ADC_FrontHodo")->Write(); - fHM->H2("Raw_ADC_RearHodo")->Write(); - gDirectory->cd(".."); - -} - - -void CbmTSUnpackFHodo::FillOutput(boost::any digi) -{ - - new( (*fFiberHodoDigi)[fFiberHodoDigi->GetEntriesFast()] ) - CbmFiberHodoDigi(*(boost::any_cast<CbmFiberHodoDigi*>(digi))); - -} - -ClassImp(CbmTSUnpackFHodo) diff --git a/beamtime/cern2016/unpacker/CbmTSUnpackFHodo.h b/beamtime/cern2016/unpacker/CbmTSUnpackFHodo.h deleted file mode 100644 index 98f712788f224ab5d36927ec7197d37e5aa4380c..0000000000000000000000000000000000000000 --- a/beamtime/cern2016/unpacker/CbmTSUnpackFHodo.h +++ /dev/null @@ -1,92 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmTSUnpackTest ----- -// ----- Created 20.06.2016 by F. Uhlig ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CBMTSUNPACKTEST_H -#define CBMTSUNPACKTEST_H - -#include "Timeslice.hpp" -#include "rocMess_wGet4v1.h" - -#include "CbmTSUnpack.h" -#include "CbmHistManager.h" -#include "CbmNxyterRawMessage.h" -#include "CbmFiberHodoDigi.h" -#include "CbmTbDaqBuffer.h" - -#include "TClonesArray.h" - -#include <vector> -#include <map> - -class CbmFHodoUnpackPar; - -class CbmTSUnpackFHodo : public CbmTSUnpack -{ -public: - - CbmTSUnpackFHodo(); - virtual ~CbmTSUnpackFHodo(); - - virtual Bool_t Init(); - - virtual Bool_t DoUnpack(const fles::Timeslice& ts, size_t component); - - virtual void Reset(); - - virtual void Finish(); - - void SetParContainers(); - - Bool_t InitContainers(); - - Bool_t ReInitContainers(); - - void FillOutput(boost::any); - - void CreateRawMessageOutput(Bool_t val) {fCreateRawMessage=val;} - -private: - - std::vector<int> fMsgCounter; - - std::map<int,int> fHodoStationMap; - - Int_t fHodoFiber[128]; /** Mapping from fiber hodoscope feb channel to fiber number **/ - Int_t fHodoPlane[128]; /** Mapping from fiber hodoscope feb channel to plane number 1=X, 2=Y **/ - Int_t fHodoPixel[128]; /** Mapping from fiber hodoscope feb channel to pixel number **/ - - CbmHistManager* fHM; ///< Histogram manager - - std::map<Int_t, UInt_t> fCurrentEpoch; // Current epoch (first epoch in the stream initialises the map item) - Int_t fNofEpochs; /** Current epoch marker for each ROC **/ - ULong_t fCurrentEpochTime; /** Time stamp of current epoch **/ - - Int_t fEquipmentId; - - TClonesArray* fFiberHodoRaw; - TClonesArray* fFiberHodoDigi; - CbmNxyterRawMessage* fRawMessage; - CbmFiberHodoDigi* fDigi; - - CbmTbDaqBuffer* fBuffer; - - Bool_t fCreateRawMessage; - - CbmFHodoUnpackPar* fUnpackPar; //! - - void CreateHistograms(); - - void FillHitInfo(ngdpb::Message); - void FillEpochInfo(ngdpb::Message); - - CbmTSUnpackFHodo(const CbmTSUnpackFHodo&); - CbmTSUnpackFHodo operator=(const CbmTSUnpackFHodo&); - - ClassDef(CbmTSUnpackFHodo, 1) -}; - -#endif diff --git a/beamtime/cern2016/unpacker/CbmTSUnpackMuch.cxx b/beamtime/cern2016/unpacker/CbmTSUnpackMuch.cxx deleted file mode 100644 index 10ecb708e3b55ba9fff1bd8784af8b949322165e..0000000000000000000000000000000000000000 --- a/beamtime/cern2016/unpacker/CbmTSUnpackMuch.cxx +++ /dev/null @@ -1,521 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmTSUnpackMuch ----- -// ----- Created 11.11.2016 by V. Singhal and A. Kumar ----- -// ----- ----- -// ----------------------------------------------------------------------------- -#include "CbmTSUnpackMuch.h" -#include "CbmMuchUnpackPar.h" -#include "CbmTbDaqBuffer.h" -#include "CbmMuchAddress.h" -#include "FairLogger.h" -#include "FairRootManager.h" -#include "FairRun.h" -#include "FairRuntimeDb.h" -#include "TClonesArray.h" -#include "TString.h" - -#include <iostream> -#include <stdint.h> -#include <iomanip> - -class CbmMuchAddress; -using std::hex; -using std::dec; -using namespace std; - -CbmTSUnpackMuch::CbmTSUnpackMuch() - : CbmTSUnpack(), - fuOverlapMsNb(0), - fMsgCounter(11,0), // length of enum MessageTypes initialized with 0 - fNdpbIdIndexMapA(), - fNdpbIdIndexMapB(), - fMuchStationMapX(), - fMuchStationMapY(), - fCurrentEpoch(), - fNofEpochs(0), - fCurrentEpochTime(0.), - fdStartTime( -1 ), - fEquipmentId(0), - fMuchRaw(new TClonesArray("CbmNxyterRawMessageForMUCH", 10)), - fMuchDigi(nullptr), - fRawMessage(NULL), - fDigi(NULL), - fBuffer(CbmTbDaqBuffer::Instance()), - fCreateRawMessage(kFALSE), - fUnpackPar(NULL) -{ -} - -CbmTSUnpackMuch::~CbmTSUnpackMuch() -{ -} - -Bool_t CbmTSUnpackMuch::Init() -{ - LOG(info) << "Initializing flib nxyter unpacker for MUCH"; - FairRootManager* ioman = FairRootManager::Instance(); - if (ioman == NULL) { - LOG(fatal) << "No FairRootManager instance"; - } - //Commented due to (Error in <TTree::Bronch>: TClonesArray with no class defined in branch: cbmout.MUCH raw data.MuchRawMessage) - - if (fCreateRawMessage) { - ioman->Register("MuchRawMessage", "MUCH raw data", fMuchRaw, kTRUE); - } - fMuchDigi = RegisterOutput<CbmMuchBeamTimeDigi>("CbmMuchBeamTimeDigi"); -// ioman->Register("MuchDigi", "Sps Much digi", fMuchDigi, kTRUE); - - //Bellow line is for creating ASCII file - //std::cout << "AFCK Nu" << " " << "FEB Nu" - // << " " << "Channel" << " " << "ADC Value" <<" " << "Absolute Time" << " " << " Sector X " << " Channel Y" << std::endl; - - // CreateHistograms(); - return kTRUE; -} - -void CbmTSUnpackMuch::SetParContainers() -{ - LOG(info) << "Setting parameter containers for " << GetName(); - fUnpackPar = (CbmMuchUnpackPar*)(FairRun::Instance()->GetRuntimeDb()->getContainer("CbmMuchUnpackPar")); -} - - -Bool_t CbmTSUnpackMuch::InitContainers() -{ - LOG(info) << "Init parameter containers for " << GetName(); - return ReInitContainers(); - -} - -Bool_t CbmTSUnpackMuch::ReInitContainers() -{ - LOG(info) << "ReInit parameter containers for " << GetName(); - - Int_t NrOfnDpbsModA = fUnpackPar->GetNrOfnDpbsModA(); - - LOG(info) << "Nr. of nDPBs Mod. A: " << NrOfnDpbsModA; - - Int_t NrOfnDpbsModB = fUnpackPar->GetNrOfnDpbsModB(); - - LOG(info) << "Nr. of nDPBs Mod. B: " << NrOfnDpbsModB; - - fNdpbIdIndexMapA.clear(); - fNdpbIdIndexMapB.clear(); - - for (Int_t i = 0; i< NrOfnDpbsModA; ++i) - { - fNdpbIdIndexMapA[fUnpackPar->GetNdpbIdA(i)] = i; - LOG(info) << "nDPB Id of MUCH " << i - << " : 0x" << std::hex << fUnpackPar->GetNdpbIdA(i) - << std::dec; - } // for (Int_t i = 0; i< NrOfnDpbsModA; ++i) - - - for (Int_t i = 0; i< NrOfnDpbsModB; ++i) - { - fNdpbIdIndexMapB[fUnpackPar->GetNdpbIdB(i)] = i; - LOG(info) << "nDPB Id of MUCH " << i - << " : 0x" << std::hex << fUnpackPar->GetNdpbIdB(i) - << std::dec; - } // for (Int_t i = 0; i< NrOfnDpbsModA; ++i) - Int_t NrOfFebs = fUnpackPar->GetNrOfFebs(); - - LOG(info) << "Nr. of FEBs : " << NrOfFebs; - - Int_t NrOfChannels = fUnpackPar->GetNrOfChannels(); - LOG(info) << "Nr. of Channels : " << NrOfChannels; - - // Need to clear the 2 Arrays fMuchStationMapX and MapY - // log all the DPBs number - // Filling all the Mapping values in the 2 X and Y arrays - // Int_t nrOfChannels = fUnpackPar->GetNumberOfChannels(); - - /* - for (Int_t febId = 0 ; febId<NrOfFebs; febId++){// looping on all the FEB IDs - Int_t febNrA = fUnpackPar->GetFebsIdsFromArrayA(febId); - Int_t febNrB = fUnpackPar->GetFebsIdsFromArrayB(febId); - for (Int_t channelId=0; channelId<NrOfChannels; channelId++){ - - //Have to check GetPadX and GetPadY values. - // LOG(info) << "Value of GetPadX " << fUnpackPar->GetPadX(febId,channelId); - fMuchStationMapXA[febId][channelId] = fUnpackPar->GetPadX(febNrA,channelId); - // LOG(info) << "Value of GetPadY " << fUnpackPar->GetPadY(febId,channelId); - fMuchStationMapYA[febId][channelId] = fUnpackPar->GetPadY(febNrA,channelId); - fMuchStationMapXB[febId][channelId] = fUnpackPar->GetPadX(febNrB,channelId); - // LOG(info) << "Value of GetPadY " << fUnpackPar->GetPadY(febId,channelId); - fMuchStationMapYB[febId][channelId] = fUnpackPar->GetPadY(febNrB,channelId); - } - }*/ //To Do think if required then create MuchStationMap - - return kTRUE; - -} -//----------------------------------------------------------------// -Bool_t CbmTSUnpackMuch::DoUnpack(const fles::Timeslice& ts, size_t component) -{ - LOG(debug) << "Timeslice contains " << ts.num_microslices(component) - << " microslices."; - - Int_t messageType = -111; - // Loop over microslices - size_t numCompMsInTs = ts.num_microslices(component); - for (size_t m = 0; m < numCompMsInTs; ++m) - { - // Ignore overlap ms if number defined by user - if( numCompMsInTs - fuOverlapMsNb <= m ) - continue; - - constexpr uint32_t kuBytesPerMessage = 8; - auto msDescriptor = ts.descriptor(component, m); - fEquipmentId = msDescriptor.eq_id; - const uint8_t* msContent = reinterpret_cast<const uint8_t*>(ts.content(component, m)); - uint32_t size = msDescriptor.size; - LOG(debug) << "Microslice: " << msDescriptor.idx - << " has size: " << size; - - // If not integer number of message in input buffer, print warning/error - if( 0 != (size % kuBytesPerMessage) ) - LOG(error) << "The input microslice buffer does NOT " - << "contain only complete nDPB messages!"; - - // Compute the number of complete messages in the input microslice buffer - uint32_t uNbMessages = (size - (size % kuBytesPerMessage) ) - / kuBytesPerMessage; - - // Prepare variables for the loop on contents - const uint64_t* pInBuff = reinterpret_cast<const uint64_t*>( msContent ); - for (uint32_t uIdx = 0; uIdx < uNbMessages; uIdx ++) - { - // Fill message - uint64_t ulData = static_cast<uint64_t>( pInBuff[uIdx] ); - ngdpb::Message mess( ulData ); - - if(gLogger->IsLogNeeded( fair::Severity::debug )) { - mess.printDataCout(); - } - - // Increment counter for different message types - // and fill the corresponding histogram - messageType = mess.getMessageType(); - fMsgCounter[messageType]++; - - switch( messageType ) { - case ngdpb::MSG_HIT: - FillHitInfo(mess); - break; - case ngdpb::MSG_EPOCH: - FillEpochInfo(mess); - break; - case ngdpb::MSG_SYNC: - // Do nothing, this message is just there to make sure we get all Epochs - break; - case ngdpb::MSG_SYS: - // Just keep track of which type of System message we receive - // histSysMessType->Fill(mess.getSysMesType()); - break; - default: - LOG(error) << "Message type " << std::hex << std::setw(2) - << static_cast< uint16_t >( mess.getMessageType() ) - << " not yet include in nXYTER unpacker."; - } - } // for (uint32_t uIdx = 0; uIdx < uNbMessages; uIdx ++) - } - return kTRUE; -} -//--------------------------------------------------------------------// - -void CbmTSUnpackMuch::FillHitInfo(ngdpb::Message mess){ - // --- Get absolute time, NXYTER and channel number - Int_t rocId = mess.getRocNumber(); - Int_t nxyterId = mess.getNxNumber(); - Int_t nxChannel = mess.getNxChNum(); - Int_t charge = mess.getNxAdcValue(); - - // First check if nDPB is mapped - // if(!((fNdpbIdIndexMapA.end() == fNdpbIdIndexMapA.find( rocId ))||(fNdpbIdIndexMapB.end() == fNdpbIdIndexMapB.find( rocId )))) - //LOG(fatal) << "Unmapped nDPB Id " << std::hex << rocId << std::dec; - //Below creating Digi if mess is at GEM1 Roc - if( !(fNdpbIdIndexMapA.end() == fNdpbIdIndexMapA.find( rocId )) ) { - ULong_t hitTime = mess.getMsgFullTime(fCurrentEpoch[rocId][nxyterId]); - //Commented due to (Error in <TTree::Bronch>: TClonesArray with no class defined in branch: cbmout.MUCH raw data.MuchRawMessage) - if (fCreateRawMessage) { - new( (*fMuchRaw)[fMuchRaw->GetEntriesFast()] ) - CbmNxyterRawMessage(fEquipmentId, - rocId*4 + nxyterId, //TODO check - nxChannel, - fCurrentEpoch[rocId][nxyterId], // note the trick - mess.getNxTs(), - charge, - mess.getNxLastEpoch(), - mess.getNxPileup(), - mess.getNxOverflow()); - - }//if (fCreateRawMessage) - - LOG(debug) << "Hit: " << rocId << ", " << nxyterId - << ", " << nxChannel << ", " << charge; - //Bellow line is for creating ASCII file - - // --- Compute detector element for GEM 1 - Int_t station = 0; - Int_t layer = 0; - Int_t sector = 0; - Int_t channel = 0; - - // --- Construct unique address - //UInt_t address = CreateAddress(rocId,nxyterId,0, 0, 0, 0, nxChannel); - - Int_t SysFebNum = fNdpbIdIndexMapA[rocId]*fUnpackPar->GetNrOfFebsPerNdpb() + nxyterId; - //Below if condition is due to FEB connected in reverse direction due to FLEX cable. - //This has to be implemented in the *.par file - //if (SysFebNum==7||SysFebNum==8||SysFebNum==9||SysFebNum==10||SysFebNum==11){ - // nxChannel=127-nxChannel; - //}//if (SysFebNum ... - - //converted SysFebNum into the febNr as per the MuchUnpackPar.par file - Int_t febNr = fUnpackPar->GetFebsIdsFromArrayA(SysFebNum); - sector = fUnpackPar->GetPadX(febNr, nxChannel); - channel = fUnpackPar->GetPadY(febNr, nxChannel); - //Bellow line is for creating ASCII file - //cout << sector << " " << channel << std::endl; - UInt_t address = CbmMuchAddress::GetAddress(station, layer, 0, 0, sector, channel); - - // UInt_t address = CbmMuchAddress::GetAddress(station, layer, 0, 0, sector, channel); - //cout<< "Address \t"<<address << " Charge\t "<< charge <<" "<<hitTime<< endl; - - // --- Create digi - fDigi = new CbmMuchBeamTimeDigi(address, charge, hitTime); - fDigi->SetPadX(sector); - fDigi->SetPadY(channel); - fDigi->SetRocId(rocId); - fDigi->SetNxId(nxyterId); - fDigi->SetNxCh(nxChannel); - - - LOG(debug) << "MUCH message: rocId " << rocId << " NXYTER " << nxyterId - << " channel " << nxChannel << " charge " << charge << " time " - << hitTime; - - LOG(debug) << "Create digi with time " << hitTime - << " at epoch " << fCurrentEpoch[rocId][nxyterId]; - //Creating digi in CbmMuchBeamtimeDigi format - //CbmMuchBeamTimeDigi::CbmMuchBeamTimeDigi() - // : CbmDigi(), fData(0), fTime(0), fMatch(0), fPadX(-1), fPadY(-1), fRocId(-1), fNxId(-1), fNxCh(-1) - - //if(fDigi = new CbmMuchBeamTimeDigi(0,address, charge, hitTime); - //Commented due to (Error in <TTree::Bronch>: TClonesArray with no class defined in branch: cbmout.MUCH raw data.MuchRawMessage) - - if(!fBuffer) cout << "------------- NULL pointer ------------- " << endl; - if(!fBuffer) cout << "------------- NULL pointer ------------- " << endl; - if(!fBuffer) {cout << "------------- NULL pointer ------------- " << endl;return;} - - fBuffer->InsertData<CbmMuchBeamTimeDigi>(fDigi); - }//( !(fNdpbIdIndexMapA.end() == fNdpbIdIndexMapA.find( rocId )) - else { - if( !(fNdpbIdIndexMapB.end() == fNdpbIdIndexMapB.find( rocId)) ){ - - ULong_t hitTime = mess.getMsgFullTime(fCurrentEpoch[rocId][nxyterId]); - //Commented due to (Error in <TTree::Bronch>: TClonesArray with no class defined in branch: cbmout.MUCH raw data.MuchRawMessage) - if (fCreateRawMessage) { - new( (*fMuchRaw)[fMuchRaw->GetEntriesFast()] ) - CbmNxyterRawMessage(fEquipmentId, - rocId*4 + nxyterId, //TODO check - nxChannel, - fCurrentEpoch[rocId][nxyterId], // note the trick - mess.getNxTs(), - charge, - mess.getNxLastEpoch(), - mess.getNxPileup(), - mess.getNxOverflow()); - - }//if (fCreateRawMessage) - - LOG(debug) << "Hit: " << rocId << ", " << nxyterId - << ", " << nxChannel << ", " << charge; - //Bellow line is for creating ASCII file - - // --- Compute detector element for GEM2 - Int_t station = 0; - Int_t layer = 1; - Int_t sector = 0; - Int_t channel = 0; - - // --- Construct unique address - //UInt_t address = CreateAddress(rocId,nxyterId,0, 0, 0, 0, nxChannel); - - Int_t SysFebNum = fNdpbIdIndexMapB[rocId]*fUnpackPar->GetNrOfFebsPerNdpb() + nxyterId; - //Below conditions as per GEM 2 module connections - //if (SysFebNum==7||SysFebNum==8||SysFebNum==9||SysFebNum==10||SysFebNum==11){ - //nxChannel=127-nxChannel; - //}//if (SysFebNum ... - - //converted SysFebNum into the febNr as per the MuchUnpackPar.par file - Int_t febNr = fUnpackPar->GetFebsIdsFromArrayB(SysFebNum); - sector = fUnpackPar->GetPadX(febNr, nxChannel); - channel = fUnpackPar->GetPadY(febNr, nxChannel); - //Bellow line is for creating ASCII file - //cout << sector << " " << channel << std::endl; - UInt_t address = CbmMuchAddress::GetAddress(station, layer, 0, 0, sector, channel); - - // UInt_t address = CbmMuchAddress::GetAddress(station, layer, 0, 0, sector, channel); - //cout<< "Address \t"<<address << " Charge\t "<< charge <<" "<<hitTime<< endl; - - // --- Create digi - fDigi = new CbmMuchBeamTimeDigi(address, charge, hitTime); - fDigi->SetPadX(sector); - fDigi->SetPadY(channel); - fDigi->SetRocId(rocId); - fDigi->SetNxId(nxyterId); - fDigi->SetNxCh(nxChannel); - - - LOG(debug) << "MUCH message: rocId " << rocId << " NXYTER " << nxyterId - << " channel " << nxChannel << " charge " << charge << " time " - << hitTime; - - LOG(debug) << "Create digi with time " << hitTime - << " at epoch " << fCurrentEpoch[rocId][nxyterId]; - //Creating digi in CbmMuchBeamtimeDigi format - //CbmMuchBeamTimeDigi::CbmMuchBeamTimeDigi() - // : CbmDigi(), fData(0), fTime(0), fMatch(0), fPadX(-1), fPadY(-1), fRocId(-1), fNxId(-1), fNxCh(-1) - - //if(fDigi = new CbmMuchBeamTimeDigi(0,address, charge, hitTime); - //Commented due to (Error in <TTree::Bronch>: TClonesArray with no class defined in branch: cbmout.MUCH raw data.MuchRawMessage) - - if(!fBuffer) cout << "------------- NULL pointer ------------- " << endl; - if(!fBuffer) cout << "------------- NULL pointer ------------- " << endl; - if(!fBuffer) {cout << "------------- NULL pointer ------------- " << endl;return;} - - fBuffer->InsertData<CbmMuchBeamTimeDigi>(fDigi); - }//( !(fNdpbIdIndexMapB.end() == fNdpbIdIndexMapB.find( rocId)) - else { - LOG(fatal) << "Unmapped nDPB Id " << std::hex << rocId << std::dec; - } // if( fNdpbIdIndexMap.end() == fNdpbIdIndexMap.find( rocId ) ) - - } - - - /*new( (*fMuchDigi)[fMuchDigi->GetEntriesFast()] ) CbmSpsMuchDigi(*(dynamic_cast<CbmSpsMuchDigi*>(fDigi)));*/ - LOG(debug) << "Number of Digis created till now " << fMuchDigi->size() << endl; - //}//sid comment - //else { - //LOG(error) << "Unknown Roc Id " << rocId << " or nxyterId "<< nxyterId << " or channelId "<< nxChannel; - //} - // fHM->H2("Raw_ADC_Much")->Fill(nxChannel,charge); - // fHM->H2("Pad_Distribution")->Fill(nxChannel,charge); - -}//void CbmTSUnpackMuch::FillHitInfo(ngdpb::Message mess){ -//-----------------------------------------------------------------------// - - -/* - - Int_t CbmTSUnpackMuch::CreateAddress(Int_t rocId, Int_t febId, Int_t stationId, Int_t layerId, Int_t sideId, Int_t moduleId, Int_t channelId) - { - - Int_t SysFebNum = fNdpbIdIndexMap[rocId]*fUnpackPar->GetNrOfFebsPerNdpb() + febId; - //Below if condition is due to FEB connected in reverse direction due to FLEX cable. - if (SysFebNum==7||SysFebNum==8||SysFebNum==9||SysFebNum==10||SysFebNum==11){ - channelId=127-channelId; - } - - //converted SysFebNum into the febNr as per the MuchUnpackPar.par file - Int_t febNr = fUnpackPar->GetFebsIdsFromArray(SysFebNum); - Int_t sector = fUnpackPar->GetPadX(febNr, channelId); - Int_t channel = fUnpackPar->GetPadY(febNr, channelId); - //Bellow line is for creating ASCII file - //cout << sector << " " << channel << std::endl; - Int_t address = CbmMuchAddress::GetAddress(stationId, layerId, sideId, moduleId, sector, channel); - return address; -} -*/ -void CbmTSUnpackMuch::FillEpochInfo(ngdpb::Message mess) -{ - Int_t rocId = mess.getRocNumber(); - Int_t nxyterId = mess.getEpochNxNum(); - - // First check if nDPB is mapped - if( fNdpbIdIndexMapA.end() == fNdpbIdIndexMapA.find( rocId ) || fNdpbIdIndexMapB.end() == fNdpbIdIndexMapB.find( rocId )) - { - //bellow should be FATAL error, converting it into INFO - LOG(debug) << "Unmapped nDPB Id " << std::hex << rocId << std::dec; - } // if( fNdpbIdIndexMap.end() == fNdpbIdIndexMap.find( rocId ) ) - - fCurrentEpoch[rocId][nxyterId] = mess.getEpochNumber(); - - // LOG(info) << "Epoch message for ROC " << rocId << " with epoch number " - // << fCurrentEpoch[rocId]; - fCurrentEpochTime = mess.getMsgFullTime(fCurrentEpoch[rocId][nxyterId]); - fNofEpochs++; - LOG(debug) << "Epoch message " - << fNofEpochs << ", epoch " << static_cast<Int_t>(fCurrentEpoch[rocId][nxyterId]) - << ", time " << std::setprecision(9) << std::fixed - << Double_t(fCurrentEpochTime) * 1.e-9 << " s " - << " for board ID " << std::hex << std::setw(4) << rocId << std::dec; - -} - -void CbmTSUnpackMuch::Reset() -{ - if (fCreateRawMessage) { - fMuchRaw->Clear(); - } -// fMuchDigi->Clear(); - fMuchDigi->clear(); -} - -void CbmTSUnpackMuch::Finish() -{ - TString message_type; - - for (unsigned int i=0; i< fMsgCounter.size(); ++i) { - switch(i) { - case 0: message_type ="NOP"; break; - case 1: message_type ="HIT"; break; - case 2: message_type ="EPOCH"; break; - case 3: message_type ="SYNC"; break; - case 4: message_type ="AUX"; break; - case 5: message_type ="EPOCH2"; break; - case 6: message_type ="GET4"; break; - case 7: message_type ="SYS"; break; - case 8: message_type ="GET4_SLC"; break; - case 9: message_type ="GET4_32B"; break; - case 10: message_type ="GET4_SYS"; break; - } - LOG(info) << message_type << " messages: " - << fMsgCounter[i]; - } - LOG(info) << "-------------------------------------"; - for( auto it = fCurrentEpoch.begin(); it != fCurrentEpoch.end(); ++it) - for( auto itN = (it->second).begin(); itN != (it->second).end(); ++itN) - LOG(info) << "Last epoch for nDPB: " - << std::hex << std::setw(4) << it->first << std::dec - << " , FEB " << std::setw(4) << itN->first - << " => " << itN->second; - LOG(info) << "-------------------------------------"; - - -/* gDirectory->mkdir("Much_Raw"); - gDirectory->cd("Much_Raw"); - fHM->H2("Raw_ADC_Much")->Write(); - fHM->H2("Pad_Distribution")->Write(); - gDirectory->cd(".."); -*/ -} - - -void CbmTSUnpackMuch::FillOutput(boost::any _digi) -{ - - CbmMuchBeamTimeDigi* digi = boost::any_cast<CbmMuchBeamTimeDigi*>(_digi); - fMuchDigi->emplace_back(*(digi)); -/* - new( (*fMuchDigi)[fMuchDigi->GetEntriesFast()] ) -CbmMuchBeamTimeDigi(*(boost::any_cast<CbmMuchBeamTimeDigi*>(digi))); -*/ - // Delete object pointed by digi after using it - delete digi; -} - -ClassImp(CbmTSUnpackMuch) diff --git a/beamtime/cern2016/unpacker/CbmTSUnpackMuch.h b/beamtime/cern2016/unpacker/CbmTSUnpackMuch.h deleted file mode 100644 index 373e168720fe9f88b5a7ad7b085d292250738a3a..0000000000000000000000000000000000000000 --- a/beamtime/cern2016/unpacker/CbmTSUnpackMuch.h +++ /dev/null @@ -1,98 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmTSUnpackMuch ----- -// ----- Created 11.11.2016 by V. Singhal and A. Kumar ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CBMTSUNPACKMUCH_H -#define CBMTSUNPACKMUCH_H - -#include "Timeslice.hpp" -#include "rocMess_wGet4v1.h" - -#include "CbmTSUnpack.h" -#include "CbmNxyterRawMessage.h" -//#include "CbmSpsMuchDigi.h" //Created a new Much Digi File for the SPS beamtime2016 - -#include "CbmMuchBeamTimeDigi.h" //Created a new Much Digi File for the SPS beamtime2016 -#include "CbmTbDaqBuffer.h" - -#include "TClonesArray.h" - -#include <vector> -#include <map> - -//class CbmFHodoUnpackPar; -class CbmMuchUnpackPar; // Unpaker Class which will read the MuchUnpackPar.par -//class CbmMuchBeamTimeDigi; -class CbmTSUnpackMuch: public CbmTSUnpack -{ - public: - - CbmTSUnpackMuch(); - virtual ~CbmTSUnpackMuch(); - - virtual Bool_t Init(); - - virtual Bool_t DoUnpack(const fles::Timeslice& ts, size_t component); - - virtual void Reset(); - - virtual void Finish(); - - void SetParContainers(); - - Bool_t InitContainers(); - - Bool_t ReInitContainers(); - - void FillOutput(boost::any); - - void CreateRawMessageOutput(Bool_t val) {fCreateRawMessage=val;} - - // Int_t CreateAddress(Int_t rocId, Int_t febId, Int_t stationId, Int_t layerId, Int_t sideId, Int_t moduleId, Int_t channelId); - - void SetMsOverlap(size_t uOverlapMsNb = 1) { fuOverlapMsNb = uOverlapMsNb; } - size_t GetMsOverlap() { return fuOverlapMsNb; } - - private: - size_t fuOverlapMsNb; /** Ignore Overlap Ms: all fuOverlapMsNb MS at the end of timeslice **/ - - std::vector<int> fMsgCounter; - std::map<UInt_t, UInt_t> fNdpbIdIndexMapA; - std::map<UInt_t, UInt_t> fNdpbIdIndexMapB; - - Int_t fMuchStationMapX[16][128]; //fMuchStationMap for map of row number via getX - Int_t fMuchStationMapY[16][128]; // For map of column number via getY> - - //CbmHistManager* fHM; ///< Histogram manager - std::map<Int_t, std::map<Int_t, UInt_t> > fCurrentEpoch; // Current epoch (first epoch in the stream initialises the map item) - // std::map<Int_t, UInt_t> fCurrentEpoch; // Current epoch (first epoch in the stream initialises the map item) - Int_t fNofEpochs; /** Current epoch marker for each ROC **/ - ULong_t fCurrentEpochTime; /** Time stamp of current epoch **/ - Double_t fdStartTime; /** Time of first valid hit (epoch available), used as reference for evolution plots**/ - - Int_t fEquipmentId; - - TClonesArray* fMuchRaw; - std::vector<CbmMuchBeamTimeDigi>* fMuchDigi; - CbmNxyterRawMessage* fRawMessage; - //CbmSpsMuchDigi* fDigi; //If CbmSpsMuchDigi will not work then will use this. - CbmMuchBeamTimeDigi* fDigi; - CbmTbDaqBuffer* fBuffer; - - Bool_t fCreateRawMessage; - - CbmMuchUnpackPar* fUnpackPar; //! - - void FillHitInfo(ngdpb::Message); - void FillEpochInfo(ngdpb::Message); - - CbmTSUnpackMuch(const CbmTSUnpackMuch&); - CbmTSUnpackMuch operator=(const CbmTSUnpackMuch&); - - ClassDef(CbmTSUnpackMuch, 1) - }; - -#endif diff --git a/beamtime/cern2016/unpacker/CbmTSUnpackTof.cxx b/beamtime/cern2016/unpacker/CbmTSUnpackTof.cxx deleted file mode 100644 index 9433f8ef3a9810b682b7c7cd0b9f6290f0b1d2a5..0000000000000000000000000000000000000000 --- a/beamtime/cern2016/unpacker/CbmTSUnpackTof.cxx +++ /dev/null @@ -1,672 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmTSUnpackTof ----- -// ----- Created 27.10.2016 by P.-A. Loizeau ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#include "CbmTSUnpackTof.h" -#include "CbmTofUnpackPar.h" -#include "CbmTofDigi.h" -#include "CbmTbEvent.h" - -#include "CbmFormatDecHexPrintout.h" - -#include "CbmTbDaqBuffer.h" - -//#include "CbmFiberHodoAddress.h" -#include "CbmHistManager.h" - -#include "FairLogger.h" -#include "FairRootManager.h" -#include "FairRun.h" -#include "FairRuntimeDb.h" - -#include "TClonesArray.h" -#include "TString.h" - -#include <iostream> -#include <stdint.h> -#include <iomanip> - -const UInt_t kuNbChanGet4 = 4; -static UInt_t kuNbChanAfck = 128; //96; // FIXME - should be read from parameter file -static Int_t iMess=0; -// const Double_t FineTimeConvFactor=0.048828; (VF) unused -static Double_t RefTime=0.; -static Double_t LastDigiTime=0.; -static Double_t FirstDigiTimeDif=0.; -static Double_t EvTime0=0.; -const Int_t DetMask = 0x0001FFFF; - - -CbmTSUnpackTof::CbmTSUnpackTof( UInt_t uNbGdpb ) - : CbmTSUnpack(), - fuMsAcceptsPercent(100), - fuOverlapMsNb(0), - fuMinNbGdpb( uNbGdpb ), - fuCurrNbGdpb( 0 ), - fMsgCounter(11,0), // length of enum MessageTypes initialized with 0 - fGdpbIdIndexMap(), - fHM(new CbmHistManager()), - fCurrentEpoch(), - fNofEpochs(0), - fCurrentEpochTime(0.), - fEquipmentId(0), - fdTShiftRef(0.), -// fFiberHodoRaw(new TClonesArray("CbmNxyterRawMessage", 10)), - fTofDigi(nullptr), -// fRawMessage(NULL), - fDigi(NULL), - fBuffer(CbmTbDaqBuffer::Instance()), - fUnpackPar(NULL), - fbEpochSuppModeOn(kFALSE), - fvmEpSupprBuffer() -{ -} - -CbmTSUnpackTof::~CbmTSUnpackTof() -{ -} - -Bool_t CbmTSUnpackTof::Init() -{ - LOG(info) << "Initializing flib Get4 unpacker"; - - FairRootManager* ioman = FairRootManager::Instance(); - if (ioman == NULL) { - LOG(fatal) << "No FairRootManager instance"; - } - - fTofDigi = RegisterOutput<CbmTofDigi>("CbmTofDigi"); -// fTofDigi= new TClonesArray("CbmTofDigi", 10); - if (fTofDigi == NULL) { - LOG(fatal) << "No Digi vector "; - } -// ioman->Register("CbmTofDigi", "Tof raw Digi", fTofDigi, kTRUE); - - /* - CbmTbEvent * fEventHeader = (CbmTbEvent *)ioman->GetObject("EventHeader."); - if (NULL == fEventHeader) { - LOG(fatal) << "No EventHeader TClonesarray "; - } - */ - - fUnpackPar = (CbmTofUnpackPar*)(FairRun::Instance()); - - CreateHistograms(); - - return kTRUE; -} - -void CbmTSUnpackTof::SetParContainers() -{ - LOG(info) << "Setting parameter containers for " << GetName(); - fUnpackPar = (CbmTofUnpackPar*)(FairRun::Instance()->GetRuntimeDb()->getContainer("CbmTofUnpackPar")); - -} - -Bool_t CbmTSUnpackTof::InitContainers() -{ - LOG(info) << "Init parameter containers for " << GetName(); - return ReInitContainers(); -} - -Bool_t CbmTSUnpackTof::ReInitContainers() -{ - LOG(info) << "ReInit parameter containers for " << GetName(); - Int_t nrOfRocs = fUnpackPar->GetNrOfRocs(); - kuNbChanAfck = fUnpackPar->GetNrOfFebsPerGdpb() - * fUnpackPar->GetNrOfGet4PerFeb() - * fUnpackPar->GetNrOfChannelsPerGet4(); - LOG(info) << "Nr. of Tof Rocs: " << nrOfRocs - << ", Nr of Channel/Roc: "<< kuNbChanAfck; - - fGdpbIdIndexMap.clear(); - for (Int_t i = 0; i< nrOfRocs; ++i) { - fGdpbIdIndexMap[fUnpackPar->GetRocId(i)] = i; - LOG(info) << "Roc Id of TOF " << i - << " : " << fUnpackPar->GetRocId(i); - } - Int_t NrOfChannels = fUnpackPar->GetNumberOfChannels(); - //Int_t fNrOfGet4 = NrOfChannels/4; - LOG(info) << "Nr. of mapped Tof channels: " << NrOfChannels; - std::stringstream ss; - for (Int_t i = 0; i< NrOfChannels; ++i) { - if(i%8 == 0) - ss << "\n"; - ss << Form(" 0x%08x",fUnpackPar->GetChannelToDetUIdMap(i)); - } - LOG(info) << ss.str(); - if( fbEpochSuppModeOn ) - { - fvmEpSupprBuffer.resize( nrOfRocs ); - for (Int_t i = 0; i< nrOfRocs; ++i) { - Int_t nrOfGet4 = fUnpackPar->GetNrOfFebsPerGdpb()*fUnpackPar->GetNrOfGet4PerFeb(); - fvmEpSupprBuffer[i].resize( nrOfGet4 ); - } - } - return kTRUE; -} - -void CbmTSUnpackTof::CreateHistograms() -{ - LOG(info) << "create Histos for " << fuMinNbGdpb <<" Rocs "; - - fHM->Add( Form("Raw_TDig-EvT0"), - new TH1F( Form("Raw_TDig-EvT0"), - Form("Raw digi time difference to 1st digi ; time [ns]; cts"), - 100, 0, 50.) ); - - fHM->Add( Form("Raw_TDig-Ref0"), - new TH1F( Form("Raw_TDig-Ref0"), - Form("Raw digi time difference to Ref ; time [ns]; cts"), - 5000, 0, 500000) ); - - fHM->Add( Form("Raw_TDig-Ref"), - new TH1F( Form("Raw_TDig-Ref"), - Form("Raw digi time difference to Ref ; time [ns]; cts"), - 5000, 0, 50000) ); - - fHM->Add( Form("Raw_TRef-Dig0"), - new TH1F( Form("Raw_TRef-Dig0"), - Form("Raw Ref time difference to last digi ; time [ns]; cts"), - 9999, -500000000, 500000000) ); - fHM->Add( Form("Raw_TRef-Dig1"), - new TH1F( Form("Raw_TRef-Dig1"), - Form("Raw Ref time difference to last digi ; time [ns]; cts"), - 9999, -5000000, 5000000) ); - fHM->Add( Form("Raw_Digi-LastDigi"), - new TH1F( Form("Raw_Digi-LastDigi"), - Form("Raw Digi time difference to last digi ; time [ns]; cts"), - 9999, -5000000, 5000000) ); - - for( UInt_t uGdpb = 0; uGdpb < fuMinNbGdpb; uGdpb ++) - { - fHM->Add( Form("Raw_Tot_gDPB_%02u", uGdpb), - new TH2F( Form("Raw_Tot_gDPB_%02u", uGdpb), - Form("Raw TOT gDPB %02u; channel; TOT [bin]", uGdpb), - kuNbChanAfck, 0, kuNbChanAfck, 256, 0, 255) ); - fHM->Add( Form("ChCount_gDPB_%02u", uGdpb), - new TH1I( Form("ChCount_gDPB_%02u", uGdpb), - Form("Channel counts gDPB %02u; channel; Hits", uGdpb), - kuNbChanAfck, 0, kuNbChanAfck ) ); - } // for( UInt_t uGdpb = 0; uGdpb < fuMinNbGdpb; uGdpb ++) -} - -Bool_t CbmTSUnpackTof::DoUnpack(const fles::Timeslice& ts, size_t component) -{ - - LOG(debug) << "Timeslice contains " << ts.num_microslices(component) - << " microslices of component " << component; - - // Loop over microslices - size_t numCompMsInTs = ts.num_microslices(component); - for (size_t m = 0; m < numCompMsInTs; ++m) - { - // if( fuMsAcceptsPercent < m ) continue; - - // Ignore overlap ms if number defined by user - if( numCompMsInTs - fuOverlapMsNb <= m ) - continue; - - constexpr uint32_t kuBytesPerMessage = 8; - - auto msDescriptor = ts.descriptor(component, m); - fEquipmentId = msDescriptor.eq_id; - const uint8_t* msContent = reinterpret_cast<const uint8_t*>(ts.content(component, m)); - - uint32_t size = msDescriptor.size; - if(size>0) - LOG(debug1) << "Microslice "<<m<<": " << msDescriptor.idx - << " has size: " << size; - - // If not integer number of message in input buffer, print warning/error - if( 0 != (size % kuBytesPerMessage) ) - LOG(error) << "The input microslice buffer does NOT " - << "contain only complete nDPB messages!" ; - - // Compute the number of complete messages in the input microslice buffer - uint32_t uNbMessages = (size - (size % kuBytesPerMessage) ) - / kuBytesPerMessage; - - // Prepare variables for the loop on contents - const uint64_t* pInBuff = reinterpret_cast<const uint64_t*>( msContent ); - for (uint32_t uIdx = 0; uIdx < uNbMessages; uIdx ++) - { - // Fill message - uint64_t ulData = static_cast<uint64_t>( pInBuff[uIdx] ); - ngdpb::Message mess( ulData ); - - if(gLogger->IsLogNeeded( fair::Severity::debug1 )) { - mess.printDataCout(); - } - - // Increment counter for different message types - fMsgCounter[mess.getMessageType()]++; - - switch(mess.getMessageType()) { - case ngdpb::MSG_HIT: - // FillHitInfo(mess); - LOG(error) << "Message type " << mess.getMessageType() - << " not yet included in unpacker."; - break; - case ngdpb::MSG_EPOCH: - // FillEpochInfo(mess); - LOG(error) << "Message type " << mess.getMessageType() - << " not yet included in unpacker."; - break; - case ngdpb::MSG_EPOCH2: - FillEpochInfo(mess); - break; - case ngdpb::MSG_GET4: - PrintGenInfo(mess); - break; - case ngdpb::MSG_GET4_32B: - if( fbEpochSuppModeOn ) - { - Int_t rocId = mess.getRocNumber(); - Int_t get4Id = mess.getGdpbGenChipId(); - // Int_t fGet4Nr = fGdpbIdIndexMap[rocId]*kuNbChanAfck + get4Id*kuNbChanGet4; - fvmEpSupprBuffer[fGdpbIdIndexMap[rocId]][get4Id].push_back( mess ); - } - else FillHitInfo(mess); - break; - case ngdpb::MSG_GET4_SLC: - PrintSlcInfo(mess); - break; - case ngdpb::MSG_GET4_SYS: - if(100 > iMess++) - PrintSysInfo(mess); - break; - - case ngdpb::MSG_STAR_TRI: - FillStarTrigInfo(mess); - break; - - default: - if(100 > iMess++) - LOG(error) << "Message ("<<iMess<<") type " << std::hex << std::setw(2) - << static_cast< uint16_t >( mess.getMessageType() ) - << " not yet included in Get4 unpacker."; - if(100 == iMess) - LOG(error) << "Stop reporting MSG errors... "; - } - - } // for (uint32_t uIdx = 0; uIdx < uNbMessages; uIdx ++) - - } - - - return kTRUE; -} - -void CbmTSUnpackTof::FillHitInfo(ngdpb::Message mess) -{ - // --- Get absolute time, NXYTER and channel number - Int_t rocId = mess.getRocNumber(); - Int_t get4Id = mess.getGdpbGenChipId(); - Int_t channel = mess.getGdpbHitChanId(); - Int_t tot = mess.getGdpbHit32Tot(); - ULong_t hitTime = mess.getMsgFullTime( 0 ); - - if( fGdpbIdIndexMap.end() != fGdpbIdIndexMap.find( rocId ) ) - { - fHM->H2( Form("Raw_Tot_gDPB_%02u", fGdpbIdIndexMap[ rocId ]) ) - ->Fill( get4Id*kuNbChanGet4 + channel, tot); - fHM->H1( Form("ChCount_gDPB_%02u", fGdpbIdIndexMap[ rocId ]) ) - ->Fill( get4Id*kuNbChanGet4 + channel ); - - - Int_t curEpochGdpbGet4 = fCurrentEpoch[rocId][get4Id]; - if( fbEpochSuppModeOn ) - curEpochGdpbGet4 --; // In Ep. Suppr. Mode, receive following epoch instead of previous - hitTime = mess.getMsgFullTime(curEpochGdpbGet4); - - Int_t Ft = mess.getGdpbHitFineTs(); - - if(100 > iMess++) - LOG(debug) << "Hit: " << Form("0x%08x ",rocId) << ", " << get4Id - << ", " << channel << ", " << tot - << ", epoch " << fCurrentEpoch[rocId][get4Id] - << ", FullTime " << hitTime - << ", FineTime " << Ft; - - Int_t iChan = fGdpbIdIndexMap[rocId]*kuNbChanAfck + get4Id*kuNbChanGet4 + channel; - if (iChan > fUnpackPar->GetNumberOfChannels()){ - LOG(error) << "Invalid mapping index "<<iChan - <<", from " << fGdpbIdIndexMap[rocId] - <<", " << get4Id - <<", " << channel; - return; - } - Int_t iChanUId = fUnpackPar->GetChannelToDetUIdMap( iChan ); - if(0==iChanUId) return; // Hit not mapped to digi - - Double_t dTime = mess.getMsgFullTimeD( curEpochGdpbGet4 ); - Double_t dTot = tot; // in ps ? - - fHM->H1( Form("Raw_Digi-LastDigi") ) - ->Fill( dTime - LastDigiTime); - - LastDigiTime = dTime; - - if( (iChanUId & DetMask) == 0x00005006 ) dTime += fdTShiftRef; - - LOG(debug) << Form("Insert 0x%08x digi with time ",iChanUId)<< dTime<<Form(", Tot %4.0f",dTot) - << " into buffer with "<<fBuffer->GetSize()<<" data from " - <<Form("%11.1f to %11.1f ",fBuffer->GetTimeFirst(),fBuffer->GetTimeLast()) - << " at epoch " << fCurrentEpoch[rocId][get4Id]; - fDigi = new CbmTofDigi(iChanUId, dTime, dTot); - - fBuffer->InsertData<CbmTofDigi>(fDigi); - - }else - LOG(warning) << "found rocId: " << Form("0x%08x ",rocId); - -} - -void CbmTSUnpackTof::FillEpochInfo(ngdpb::Message mess) -{ - Int_t rocId = mess.getRocNumber(); - Int_t get4Id = mess.getGdpbGenChipId(); - // Int_t fGet4Nr = fGdpbIdIndexMap[rocId]*kuNbChanAfck + get4Id*kuNbChanGet4; - fCurrentEpoch[rocId][get4Id] = mess.getEpoch2Number(); - if( fbEpochSuppModeOn ) - { - Int_t iBufferSize = fvmEpSupprBuffer[fGdpbIdIndexMap[rocId]][get4Id].size(); - if( 0 < iBufferSize ) - { - LOG(debug) << "Now processing stored messages for roc " <<rocId<<", get4 "<<get4Id<< " with epoch number " - << (fCurrentEpoch[fGdpbIdIndexMap[rocId]][get4Id] - 1); - for( Int_t iMsgIdx = 0; iMsgIdx < iBufferSize; iMsgIdx++ ) - { - FillHitInfo( fvmEpSupprBuffer[fGdpbIdIndexMap[rocId]][get4Id][ iMsgIdx ] ); - } // for( Int_t iMsgIdx = 0; iMsgIdx < iBufferSize; iMsgIdx++ ) - fvmEpSupprBuffer[fGdpbIdIndexMap[rocId]][get4Id].clear(); - } // if( 0 < fvmEpSupprBuffer[fGet4Nr] ) - } // if( fbEpochSuppModeOn ) - - if( fGdpbIdIndexMap.end() == fGdpbIdIndexMap.find( rocId ) ) - { - fGdpbIdIndexMap[ rocId ] = fuCurrNbGdpb; - fuCurrNbGdpb ++; - - if( fuMinNbGdpb < fuCurrNbGdpb ) - { - // Add new histo - fHM->Add( Form("Raw_Tot_gDPB_%02u", fuMinNbGdpb), - new TH2F( Form("Raw_Tot_gDPB_%02u", fuMinNbGdpb), - Form("Raw TOT gDPB %02u; channel; TOT [bin]", fuMinNbGdpb), - kuNbChanAfck, 0, kuNbChanAfck, 256, 0, 255) ); - - fHM->Add( Form("ChCount_gDPB_%02u", fuMinNbGdpb), - new TH1I( Form("ChCount_gDPB_%02u", fuMinNbGdpb), - Form("Channel counts gDPB %02u; channel; Hits", fuMinNbGdpb), - kuNbChanAfck, 0, kuNbChanAfck ) ); - LOG(info)<<" Add histos for gDPB "<<fuMinNbGdpb<<", rocID "<<rocId; - // increase fuMinNbGdpb - fuMinNbGdpb++; - } // if( fuMinNbGdpb < fuCurrNbGdpb ) - } // if( std::map::end == fGdpbIdIndexMap.find( rocId ) ) - - // LOG(info) << "Epoch message for ROC " << rocId << " with epoch number " - // << fCurrentEpoch[rocId]; - - fCurrentEpochTime = mess.getMsgFullTime(fCurrentEpoch[rocId][get4Id]); - fNofEpochs++; - LOG(debug1) << "Epoch message " - << fNofEpochs << ", epoch " << static_cast<Int_t>(fCurrentEpoch[rocId][get4Id]) - << ", time " << std::setprecision(9) << std::fixed - << Double_t(fCurrentEpochTime) * 1.e-9 << " s " - << " for board ID " << std::hex << std::setw(4) << rocId << std::dec - << " and chip " << mess.getEpoch2ChipNumber(); - -} - -void CbmTSUnpackTof::PrintSlcInfo(ngdpb::Message mess) -{ - Int_t rocId = mess.getRocNumber(); - Int_t get4Id = mess.getGdpbGenChipId(); - - if( fGdpbIdIndexMap.end() != fGdpbIdIndexMap.find( rocId ) ) - LOG(info) << "GET4 Slow Control message, epoch " << static_cast<Int_t>(fCurrentEpoch[rocId][get4Id]) - << ", time " << std::setprecision(9) << std::fixed - << Double_t(fCurrentEpochTime) * 1.e-9 << " s " - << " for board ID " << std::hex << std::setw(4) << rocId << std::dec - << "\n" - << " +++++++ > Chip = " << std::setw(2) << mess.getGdpbGenChipId() - << ", Chan = " << std::setw(1) << mess.getGdpbSlcChan() - << ", Edge = " << std::setw(1) << mess.getGdpbSlcEdge() - << ", Type = " << std::setw(1) << mess.getGdpbSlcType() - << ", Data = " << std::hex << std::setw(6) << mess.getGdpbSlcData() << std::dec - << ", Type = " << mess.getGdpbSlcCrc(); - -} - -void CbmTSUnpackTof::PrintGenInfo(ngdpb::Message mess) -{ - Int_t mType = mess.getMessageType(); - Int_t rocId = mess.getRocNumber(); - Int_t get4Id = mess.getGdpbGenChipId(); - Int_t channel = mess.getGdpbHitChanId(); - uint64_t uData = mess.getData(); - if(100 > iMess++) - LOG(info) << "Get4 MSG type "<<mType<<" from rocId "<<rocId<<", getId "<<get4Id - << ", (hit channel) "<<channel -// <<Form(" hex data %0llx ",uData); - << " hex data " << FormatHexPrintout( uData, 0, '0' ); -} - -void CbmTSUnpackTof::PrintSysInfo(ngdpb::Message mess) -{ - Int_t rocId = mess.getRocNumber(); - Int_t get4Id = mess.getGdpbGenChipId(); - - if( fGdpbIdIndexMap.end() != fGdpbIdIndexMap.find( rocId ) ) - LOG(info) << "GET4 System message, epoch " << static_cast<Int_t>(fCurrentEpoch[rocId][get4Id]) - << ", time " << std::setprecision(9) << std::fixed - << Double_t(fCurrentEpochTime) * 1.e-9 << " s " - << " for board ID " << std::hex << std::setw(4) << rocId << std::dec; - - switch( mess.getGdpbSysSubType() ) - { - case ngdpb::SYSMSG_GET4_EVENT: - { - LOG(info) << " +++++++ > Chip = " << std::setw(2) << mess.getGdpbGenChipId() - << ", Chan = " << std::setw(1) << mess.getGdpbSysErrChanId() - << ", Edge = " << std::setw(1) << mess.getGdpbSysErrEdge() - << ", Empt = " << std::setw(1) << mess.getGdpbSysErrUnused() - << ", Data = " << std::hex << std::setw(2) << mess.getGdpbSysErrData() << std::dec - << " -- GET4 V1 Error Event"; - break; - } // - case ngdpb::SYSMSG_CLOSYSYNC_ERROR: - LOG(info) << "Closy synchronization error"; - break; - case ngdpb::SYSMSG_TS156_SYNC: - LOG(info) << "156.25MHz timestamp reset"; - break; - case ngdpb::SYSMSG_GDPB_UNKWN: - LOG(info) << "Unknown GET4 message, data: " << std::hex << std::setw(8) - << mess.getGdpbSysUnkwData() << std::dec; - break; - } // switch( getGdpbSysSubType() ) -} - -void CbmTSUnpackTof::Reset() -{ - // fFiberHodoRaw->Clear(); -// fTofDigi->Clear(); - fTofDigi->clear(); -} - -void CbmTSUnpackTof::Finish() -{ - TString message_type; - - for (unsigned int i=0; i< fMsgCounter.size(); ++i) { - switch(i) { - case 0: message_type ="NOP"; break; - case 1: message_type ="HIT"; break; - case 2: message_type ="EPOCH"; break; - case 3: message_type ="SYNC"; break; - case 4: message_type ="AUX"; break; - case 5: message_type ="EPOCH2"; break; - case 6: message_type ="GET4"; break; - case 7: message_type ="SYS"; break; - case 8: message_type ="GET4_SLC"; break; - case 9: message_type ="GET4_32B"; break; - case 10: message_type ="GET4_SYS"; break; - default: message_type ="UNKNOWN"; break; - } - LOG(info) << message_type << " messages: " - << fMsgCounter[i]; - } - - LOG(info) << "-------------------------------------"; - for( auto it = fCurrentEpoch.begin(); it != fCurrentEpoch.end(); ++it) - for( auto itG = (it->second).begin(); itG != (it->second).end(); ++itG) - LOG(info) << "Last epoch for gDPB: " - << std::hex << std::setw(4) << it->first - << " , GET4 " << std::setw(4) << itG->first - << " => " << itG->second; - LOG(info) << "-------------------------------------"; - - - gDirectory->mkdir("Tof_Raw_gDPB"); - gDirectory->cd("Tof_Raw_gDPB"); - fHM->H1( Form("Raw_TDig-Ref0") )->Write(); - fHM->H1( Form("Raw_TDig-Ref") )->Write(); - fHM->H1( Form("Raw_TRef-Dig0") )->Write(); - fHM->H1( Form("Raw_TRef-Dig1") )->Write(); - fHM->H1( Form("Raw_Digi-LastDigi") )->Write(); - for( UInt_t uGdpb = 0; uGdpb < fuMinNbGdpb; uGdpb ++) - { - fHM->H2( Form("Raw_Tot_gDPB_%02u", uGdpb) )->Write(); - fHM->H1( Form("ChCount_gDPB_%02u", uGdpb) )->Write(); - } // for( UInt_t uGdpb = 0; uGdpb < fuMinNbGdpb; uGdpb ++) - gDirectory->cd(".."); - -} - - -void CbmTSUnpackTof::FillOutput(boost::any _digi) -{ - CbmTofDigi* digi = boost::any_cast<CbmTofDigi*>(_digi); - if(100 > iMess++) - LOG(debug) << "Fill digi vector with " - <<Form("0x%08x",digi->GetAddress()) - <<" at " << (Int_t)fTofDigi->size(); - - -// new( (*fTofDigi)[fTofDigi->GetEntriesFast()] ) -// CbmTofDigi(*(boost::any_cast<CbmTofDigi*>(digi))); - fTofDigi->emplace_back(*(digi)); - //CbmTofDigi((CbmTofDigi *)digi); - - if(0==fTofDigi->size()) EvTime0=digi->GetTime(); - else - fHM->H1( Form("Raw_TDig-EvT0") ) - ->Fill( digi->GetTime() - EvTime0); - - if( (digi->GetAddress() & DetMask) != 0x00005006 ) { - fHM->H1( Form("Raw_TDig-Ref0") ) - ->Fill( digi->GetTime() - RefTime); - fHM->H1( Form("Raw_TDig-Ref") ) - ->Fill( digi->GetTime() - RefTime); - } - else RefTime=digi->GetTime(); - - delete digi; - -} - -static ULong64_t fulGdpbTsMsb; -static ULong64_t fulGdpbTsLsb; -static ULong64_t fulStarTsMsb; -static ULong64_t fulStarTsMid; -static ULong64_t fulGdpbTsFullLast; -static ULong64_t fulStarTsFullLast; -static UInt_t fuStarTokenLast; -static UInt_t fuStarDaqCmdLast; -static UInt_t fuStarTrigCmdLast; - -void CbmTSUnpackTof::FillStarTrigInfo(ngdpb::Message mess) -{ - Int_t iMsgIndex = mess.getStarTrigMsgIndex(); - - switch( iMsgIndex ) - { - case 0: - fulGdpbTsMsb = mess.getGdpbTsMsbStarA(); - break; - case 1: - fulGdpbTsLsb = mess.getGdpbTsLsbStarB(); - fulStarTsMsb = mess.getStarTsMsbStarB(); - break; - case 2: - fulStarTsMid = mess.getStarTsMidStarC(); - break; - case 3: - { - ULong64_t ulNewGdpbTsFull = ( fulGdpbTsMsb << 24 ) - + ( fulGdpbTsLsb ); - ULong64_t ulNewStarTsFull = ( fulStarTsMsb << 48 ) - + ( fulStarTsMid << 8 ) - + mess.getStarTsLsbStarD(); - UInt_t uNewToken = mess.getStarTokenStarD(); - UInt_t uNewDaqCmd = mess.getStarDaqCmdStarD(); - UInt_t uNewTrigCmd = mess.getStarTrigCmdStarD(); - if( ( uNewToken == fuStarTokenLast ) && ( ulNewGdpbTsFull == fulGdpbTsFullLast ) && - ( ulNewStarTsFull == fulStarTsFullLast ) && ( uNewDaqCmd == fuStarDaqCmdLast ) && - ( uNewTrigCmd == fuStarTrigCmdLast ) ) - { - LOG(debug) << "Possible error: identical STAR tokens found twice in a row => ignore 2nd! " - << Form("token = %5u ", fuStarTokenLast ) - << Form("gDPB ts = %12llu ", fulGdpbTsFullLast ) - << Form("STAR ts = %12llu ", fulStarTsFullLast ) - << Form("DAQ cmd = %2u ", fuStarDaqCmdLast ) - << Form("TRG cmd = %2u ", fuStarTrigCmdLast ); - return; - } // if exactly same message repeated - - if( (uNewToken != fuStarTokenLast + 1) && - 0 < fulGdpbTsFullLast && 0 < fulStarTsFullLast && - ( 4095 != fuStarTokenLast || 1 != uNewToken) ) - LOG(warning) << "Possible error: STAR token did not increase by exactly 1! " - << Form("old = %5u vs new = %5u ", fuStarTokenLast, uNewToken) - << Form("old = %12llu vs new = %12llu ", fulGdpbTsFullLast, ulNewGdpbTsFull) - << Form("old = %12llu vs new = %12llu ", fulStarTsFullLast, ulNewStarTsFull) - << Form("old = %2u vs new = %2u ", fuStarDaqCmdLast, uNewDaqCmd) - << Form("old = %2u vs new = %2u ", fuStarTrigCmdLast, uNewTrigCmd); - - fulGdpbTsFullLast = ulNewGdpbTsFull; - fulStarTsFullLast = ulNewStarTsFull; - fuStarTokenLast = uNewToken; - fuStarDaqCmdLast = uNewDaqCmd; - fuStarTrigCmdLast = uNewTrigCmd; - Double_t dTot = 1.; - Double_t dTime = fulGdpbTsFullLast * 6.25; - if (FirstDigiTimeDif==0. && LastDigiTime!=0.) { - FirstDigiTimeDif=dTime-LastDigiTime; - LOG(info) << "Default fake digi time shift initialized to " << FirstDigiTimeDif; - } - dTime -= FirstDigiTimeDif; - dTime += fdTShiftRef; - LOG(debug) << "Insert fake digi with time " << dTime<<", Tot "<<dTot; - fHM->H1( Form("Raw_TRef-Dig0") ) - ->Fill( dTime - LastDigiTime); - fHM->H1( Form("Raw_TRef-Dig1") ) - ->Fill( dTime - LastDigiTime); - - fDigi = new CbmTofDigi(0x00005006, dTime, dTot); // fake start counter signal - fBuffer->InsertData<CbmTofDigi>(fDigi); - break; - } // case 3 - default: - LOG(fatal) << "Unknown Star Trigger messageindex: " << iMsgIndex; - } // switch( iMsgIndex ) -} - -ClassImp(CbmTSUnpackTof) diff --git a/beamtime/cern2016/unpacker/CbmTSUnpackTof.h b/beamtime/cern2016/unpacker/CbmTSUnpackTof.h deleted file mode 100644 index 7d92e411d71d83507c6ab65db63e15088e160755..0000000000000000000000000000000000000000 --- a/beamtime/cern2016/unpacker/CbmTSUnpackTof.h +++ /dev/null @@ -1,108 +0,0 @@ -// ----- ----- -// ----- CbmTSUnpackTof ----- -// ----- Created 27.10.2016 by P.-A. Loizeau ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CbmTSUnpackTof_H -#define CbmTSUnpackTof_H - -#include "Timeslice.hpp" -#include "rocMess_wGet4v1.h" - -#include "CbmTSUnpack.h" -#include "CbmHistManager.h" -#include "CbmNxyterRawMessage.h" -#include "CbmTofDigi.h" -#include "CbmTbDaqBuffer.h" - -#include "TClonesArray.h" - -#include <vector> -#include <map> - -class CbmTofUnpackPar; - -class CbmTSUnpackTof : public CbmTSUnpack -{ -public: - - CbmTSUnpackTof( UInt_t uNbGdpb = 1 ); - virtual ~CbmTSUnpackTof(); - - virtual Bool_t Init(); - - virtual Bool_t DoUnpack(const fles::Timeslice& ts, size_t component); - - virtual void Reset(); - - virtual void Finish(); - - void SetParContainers(); - - Bool_t InitContainers(); - - Bool_t ReInitContainers(); - - - void FillOutput(boost::any); - - void SetEpochSuppressedMode( Bool_t bEnable = kTRUE ) { fbEpochSuppModeOn = bEnable; } - - void SetMsLimitLevel( size_t uAcceptBoundaryPct = 100 ) { fuMsAcceptsPercent = uAcceptBoundaryPct; } - size_t GetMsLimitLevel( ) { return fuMsAcceptsPercent; } - - void SetMsOverlap(size_t uOverlapMsNb = 1) { fuOverlapMsNb = uOverlapMsNb; } - size_t GetMsOverlap() { return fuOverlapMsNb; } - - inline void SetTShiftRef(Double_t val) {fdTShiftRef = val;} - -private: - - size_t fuMsAcceptsPercent; /** Reject Ms with index inside TS above this, assumes 100 MS per TS **/ - size_t fuOverlapMsNb; /** Ignore Overlap Ms: all fuOverlapMsNb MS at the end of timeslice **/ - UInt_t fuMinNbGdpb; - UInt_t fuCurrNbGdpb; - - std::vector<int> fMsgCounter; - std::map<UInt_t, UInt_t> fGdpbIdIndexMap; - - CbmHistManager* fHM; ///< Histogram manager - - /** Current epoch marker for each ROC and GET4 (first epoch in the stream initialises the map item) **/ - std::map<Int_t, std::map<Int_t, UInt_t> > fCurrentEpoch; - Int_t fNofEpochs; /** Current epoch marker for each ROC **/ - ULong_t fCurrentEpochTime; /** Time stamp of current epoch **/ - - Int_t fEquipmentId; - Double_t fdTShiftRef; - -// TClonesArray* fFiberHodoRaw; - std::vector<CbmTofDigi>* fTofDigi; -// CbmNxyterRawMessage* fRawMessage; - CbmTofDigi* fDigi; - - CbmTbDaqBuffer* fBuffer; - - CbmTofUnpackPar* fUnpackPar; //! - - void CreateHistograms(); - - Bool_t fbEpochSuppModeOn; - - std::vector< std::vector< std::vector < ngdpb::Message > > > fvmEpSupprBuffer; - - void FillHitInfo(ngdpb::Message); - void FillStarTrigInfo(ngdpb::Message); - void FillEpochInfo(ngdpb::Message); - void PrintSlcInfo(ngdpb::Message); - void PrintSysInfo(ngdpb::Message); - void PrintGenInfo(ngdpb::Message); - - CbmTSUnpackTof(const CbmTSUnpackTof&); - CbmTSUnpackTof operator=(const CbmTSUnpackTof&); - - ClassDef(CbmTSUnpackTof, 1) -}; - -#endif diff --git a/beamtime/cern2017/CMakeLists.txt b/beamtime/cern2017/CMakeLists.txt deleted file mode 100644 index c2ff2cef232cb5eacf9a1b7f4500712318357591..0000000000000000000000000000000000000000 --- a/beamtime/cern2017/CMakeLists.txt +++ /dev/null @@ -1,60 +0,0 @@ -Set(INCLUDE_DIRECTORIES - ${CBMBASE_DIR} - - ${CBMDATA_DIR}/raw - - ${CBMROOT_SOURCE_DIR}/beamtime/base - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/unpacker - ${CMAKE_CURRENT_SOURCE_DIR}/param -) - -Set(SYSTEM_INCLUDE_DIRECTORIES - ${BASE_INCLUDE_DIRECTORIES} - ${Boost_INCLUDE_DIR} - ${ROOT_INCLUDE_DIR} - ${IPC_INCLUDE_DIRECTORY} - ${CBMROOT_SOURCE_DIR}/external/flib_dpb/flib_dpb - ${CMAKE_SOURCE_DIR}/external/cppzmq -) - -Include_Directories(${INCLUDE_DIRECTORIES}) -Include_Directories(SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES}) - - -Set(LINK_DIRECTORIES - ${ROOT_LIBRARY_DIR} - ${FAIRROOT_LIBRARY_DIR} - ${Boost_LIBRARY_DIRS} -) - -Link_Directories( - ${LINK_DIRECTORIES} -) - -Set(SRCS - unpacker/StsXyterRawMessage.cxx - unpacker/StsXyterBetaMessage.cxx - - unpacker/CbmCern2017MonitorRawSts.cxx - unpacker/CbmCern2017MonitorBetaSts.cxx - unpacker/CbmCern2017MonitorSts.cxx - unpacker/CbmCern2017MonitorHodo.cxx - - param/CbmCern2017ContFact.cxx - param/CbmCern2017UnpackParSts.cxx - param/CbmCern2017UnpackParHodo.cxx -) - -If(_UINT8_T_EXIST) - Add_Definitions(-DHAVE_UINT8_T_HEADER_FILE) - Set(DEFINITIONS HAVE_UINT8_T_HEADER_FILE) -EndIf() - -Set(LINKDEF CbmBeamtimeCern2017LinkDef.h ) -Set(LIBRARY_NAME CbmBeamtimeCern2017) -Set(DEPENDENCIES - CbmData CbmBase CbmBeamtimeBase fles_ipc Eve Base -) - -GENERATE_LIBRARY() diff --git a/beamtime/cern2017/CbmBeamtimeCern2017LinkDef.h b/beamtime/cern2017/CbmBeamtimeCern2017LinkDef.h deleted file mode 100644 index fb65119ad4fb3ba0caf65edcb65a8b3856d8c698..0000000000000000000000000000000000000000 --- a/beamtime/cern2017/CbmBeamtimeCern2017LinkDef.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifdef __CINT__ - -#pragma link off all globals; -#pragma link off all classes; -#pragma link off all functions; - -#pragma link C++ class stsxyter::RawMessage; -#pragma link C++ class stsxyter::BetaMessage; - -//#pragma link C++ class CbmCern2017UnpackerSts; -//#pragma link C++ class CbmCern2017UnpackerMuch; - -#pragma link C++ class CbmCern2017MonitorRawSts; -#pragma link C++ class CbmCern2017MonitorBetaSts; -#pragma link C++ class CbmCern2017MonitorSts; -//#pragma link C++ class CbmCern2017MonitorMuch; -#pragma link C++ class CbmCern2017MonitorHodo; - -#pragma link C++ class CbmCern2017ContFact; -#pragma link C++ class CbmCern2017UnpackParSts; -//#pragma link C++ class CbmCern2017UnpackParMuch; -#pragma link C++ class CbmCern2017UnpackParHodo; - -#endif diff --git a/beamtime/cern2017/param/CbmCern2017ContFact.cxx b/beamtime/cern2017/param/CbmCern2017ContFact.cxx deleted file mode 100644 index 0fc9ab0aa910bef346eea51da55e3dddb6d7f57d..0000000000000000000000000000000000000000 --- a/beamtime/cern2017/param/CbmCern2017ContFact.cxx +++ /dev/null @@ -1,78 +0,0 @@ -///////////////////////////////////////////////////////////// -// -// CbmCern2017ContFact -// -// Factory for the parameter containers in libFlibCern2017 -// -///////////////////////////////////////////////////////////// - -#include "CbmCern2017ContFact.h" - - -#include "CbmCern2017UnpackParSts.h" -//#include "CbmMuchUnpackPar.h" -#include "CbmCern2017UnpackParHodo.h" - -#include "FairRuntimeDb.h" - -ClassImp(CbmCern2017ContFact) - -static CbmCern2017ContFact gCbmCern2017ContFact; - -CbmCern2017ContFact::CbmCern2017ContFact() { - // Constructor (called when the library is loaded) - fName="CbmCern2017ContFact"; - fTitle="Factory for parameter containers for fles CERN 2017 library"; - setAllContainers(); - FairRuntimeDb::instance()->addContFactory(this); -} - -void CbmCern2017ContFact::setAllContainers() { - /** Creates the Container objects with all accepted contexts and adds them to - * the list of containers for the fles test library.*/ - - FairContainer* p= new FairContainer("CbmCern2017UnpackParSts", - "Sts Unpack Parameters", - "TestDefaultContext"); - p->addContext("TestNonDefaultContext"); - - containers->Add(p); -/* - FairContainer* p2= new FairContainer("CbmCern2017UnpackParMuch", - "Much Unpack Parameters", - "TestDefaultContext"); - p2->addContext("TestNonDefaultContext"); - - containers->Add(p2); -*/ - - FairContainer* p3= new FairContainer("CbmCern2017UnpackParHodo", - "Hodo Unpack Parameters", - "TestDefaultContext"); - p3->addContext("TestNonDefaultContext"); - - containers->Add(p3); - -} - -FairParSet* CbmCern2017ContFact::createContainer(FairContainer* c) { - /** Calls the constructor of the corresponding parameter container. - * For an actual context, which is not an empty string and not the default context - * of this container, the name is concatinated with the context. */ - const char* name=c->GetName(); - FairParSet* p=0; - if (strcmp(name,"CbmCern2017UnpackParSts")==0) { - p=new CbmCern2017UnpackParSts(c->getConcatName().Data(),c->GetTitle(),c->getContext()); - } -/* - if (strcmp(name,"CbmCern2017UnpackParMuch")==0) { - p=new CbmCern2017UnpackParMuch(c->getConcatName().Data(),c->GetTitle(),c->getContext()); - } -*/ - if (strcmp(name,"CbmCern2017UnpackParHodo")==0) { - p=new CbmCern2017UnpackParHodo(c->getConcatName().Data(),c->GetTitle(),c->getContext()); - } - - return p; -} - diff --git a/beamtime/cern2017/param/CbmCern2017ContFact.h b/beamtime/cern2017/param/CbmCern2017ContFact.h deleted file mode 100644 index b49c382198a969338f1e08965858457ae4c53ed4..0000000000000000000000000000000000000000 --- a/beamtime/cern2017/param/CbmCern2017ContFact.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef CBMCERN2017CONTFACT_H -#define CBMCERN2017CONTFACT_H - -#include "FairContFact.h" - -class FairContainer; -class FairParSet; - -class CbmCern2017ContFact : public FairContFact { -private: - void setAllContainers(); - CbmCern2017ContFact(const CbmCern2017ContFact&); - CbmCern2017ContFact& operator=(const CbmCern2017ContFact&); -public: - CbmCern2017ContFact(); - ~CbmCern2017ContFact() {} - FairParSet* createContainer(FairContainer*); - ClassDef(CbmCern2017ContFact,0) // Factory for all TRD parameter containers -}; - -#endif /* !CBMCERN2017CONTFACT_H */ diff --git a/beamtime/cern2017/param/CbmCern2017UnpackParHodo.cxx b/beamtime/cern2017/param/CbmCern2017UnpackParHodo.cxx deleted file mode 100644 index 9aa957fe15d0f17d5ba521415cd12f7c039e5b18..0000000000000000000000000000000000000000 --- a/beamtime/cern2017/param/CbmCern2017UnpackParHodo.cxx +++ /dev/null @@ -1,284 +0,0 @@ -// ------------------------------------------------------------------------- -// ----- CbmCern2017UnpackParHodo source file ----- -// ----- Created 25/07/17 by P.-A. Loizeau ----- -// ------------------------------------------------------------------------- - -#include "CbmCern2017UnpackParHodo.h" - -#include "FairParamList.h" -#include "FairDetParIo.h" -#include "FairParIo.h" -#include "FairLogger.h" - -#include "TString.h" - -using namespace std; -// ----- Standard constructor ------------------------------------------ -CbmCern2017UnpackParHodo::CbmCern2017UnpackParHodo(const char* name, - const char* title, - const char* context) : - FairParGenericSet(name, title, context), - fuNrOfDpbs( 0 ), - fiDbpIdArray(), - fuNbElinksPerDpb( 0 ), - fuNbStsXyters( 0 ), - fuNbChanPerAsic( 0 ), - fiElinkToAsicMap(), - fiChannelToFiberMap(), - fiChannelToPixelMap(), - fiChannelToPlaneMap(), - fuAsicIdxHodo1( 0 ), - fuAsicIdxHodo2( 0 ), - fbSwapHodo1XY( kFALSE ), - fbSwapHodo2XY( kFALSE ), - fbInvertHodo1X( kFALSE ), - fbInvertHodo1Y( kFALSE ), - fbInvertHodo2X( kFALSE ), - fbInvertHodo2Y( kFALSE ) -{ - detName="Hodo"; -} -// ------------------------------------------------------------------------- - - - -// ----- Destructor ---------------------------------------------------- -CbmCern2017UnpackParHodo::~CbmCern2017UnpackParHodo() -{ -} -// ------------------------------------------------------------------------- - - -// ----- Public method clear ------------------------------------------- -void CbmCern2017UnpackParHodo::clear() -{ - status = kFALSE; - resetInputVersions(); -} -// ------------------------------------------------------------------------- - -// ------------------------------------------------------------------------- - -void CbmCern2017UnpackParHodo::putParams(FairParamList* l) -{ - if (!l) return; - -#ifdef VERSION_GREATER_160601 - l->add("NrOfDpbs", fuNrOfDpbs ); - l->add("DbpIdArray", fiDbpIdArray); - l->add("NbElinksPerDpb", fuNbElinksPerDpb ); - l->add("NbStsXyters", fuNbStsXyters ); - l->add("NbChanPerAsic", fuNbChanPerAsic ); - l->add("ElinkToAsicMap", fiElinkToAsicMap); - - l->add("ChannelToFiberMap", fiChannelToFiberMap); - l->add("ChannelToPixelMap", fiChannelToPixelMap); - l->add("ChannelToPlaneMap", fiChannelToPlaneMap); - - l->add("AsicIdxHodo1", fuAsicIdxHodo1); - l->add("AsicIdxHodo2", fuAsicIdxHodo2); - l->add("SwapHodo1XY", fbSwapHodo1XY); - l->add("SwapHodo2XY", fbSwapHodo2XY); - l->add("InvertHodo1X", fbInvertHodo1X); - l->add("InvertHodo1Y", fbInvertHodo1Y); - l->add("InvertHodo2X", fbInvertHodo2X); - l->add("InvertHodo2Y", fbInvertHodo2Y); - -#else - Int_t iNrOfDpbs = fuNrOfDpbs; - Int_t iNbElinksPerDpb = fuNbElinksPerDpb; - Int_t iNbStsXyters = fuNbStsXyters; - Int_t iNbChanPerAsic = fuNbChanPerAsic; - - l->add("NrOfDpbs", iNrOfDpbs ); - l->add("DbpIdArray", fiDbpIdArray); - l->add("NbElinksPerDpb", iNbElinksPerDpb ); - l->add("NbStsXyters", iNbStsXyters ); - l->add("NbChanPerAsic", iNbChanPerAsic ); - l->add("ElinkToAsicMap", fiElinkToAsicMap); - - l->add("ChannelToFiberMap", fiChannelToFiberMap); - l->add("ChannelToPixelMap", fiChannelToPixelMap); - l->add("ChannelToPlaneMap", fiChannelToPlaneMap); - - Int_t iAsicIdxHodo1 = fuAsicIdxHodo1; - Int_t iAsicIdxHodo2 = fuAsicIdxHodo2; - l->add("AsicIdxHodo1", iAsicIdxHodo1); - l->add("AsicIdxHodo2", iAsicIdxHodo2); - l->add("SwapHodo1XY", fbSwapHodo1XY); - l->add("SwapHodo2XY", fbSwapHodo2XY); - l->add("InvertHodo1X", fbInvertHodo1X); - l->add("InvertHodo1Y", fbInvertHodo1Y); - l->add("InvertHodo2X", fbInvertHodo2X); - l->add("InvertHodo2Y", fbInvertHodo2Y); -#endif // VERSION_GREATER_160601 -} - -// ------------------------------------------------------------------------- - -Bool_t CbmCern2017UnpackParHodo::getParams(FairParamList* l) { - - if (!l) return kFALSE; - -#ifdef VERSION_GREATER_160601 - if ( ! l->fill("NrOfDpbs", &fuNrOfDpbs ) ) return kFALSE; - - fiDbpIdArray.Set( fuNrOfDpbs ); - if ( ! l->fill("DbpIdArray", &fiDbpIdArray ) ) return kFALSE; - - if ( ! l->fill("NbElinksPerDpb", &fuNbElinksPerDpb ) ) return kFALSE; - - if ( ! l->fill("NbStsXyters", &fuNbStsXyters ) ) return kFALSE; - - if ( ! l->fill("NbChanPerAsic", &fuNbChanPerAsic ) ) return kFALSE; - - fiElinkToAsicMap.Set( fuNrOfDpbs * fuNbElinksPerDpb ); - if ( ! l->fill("ElinkToAsicMap", &fiElinkToAsicMap ) ) return kFALSE; - - fiChannelToFiberMap.Set(fuNbChanPerAsic); - fiChannelToPixelMap.Set(fuNbChanPerAsic); - fiChannelToPlaneMap.Set(fuNbChanPerAsic); - if ( ! l->fill("ChannelToFiberMap", &fiChannelToFiberMap) ) return kFALSE; - if ( ! l->fill("ChannelToPixelMap", &fiChannelToPixelMap) ) return kFALSE; - if ( ! l->fill("ChannelToPlaneMap", &fiChannelToPlaneMap) ) return kFALSE; - - if ( ! l->fill("AsicIdxHodo1", &fuAsicIdxHodo1 ) ) return kFALSE; - if ( ! l->fill("AsicIdxHodo2", &fuAsicIdxHodo2 ) ) return kFALSE; - Int_t iSwapHodo1XY = 0; - Int_t iSwapHodo2XY = 0; - Int_t iInvertHodo1X = 0; - Int_t iInvertHodo1Y = 0; - Int_t iInvertHodo2X = 0; - Int_t iInvertHodo2Y = 0; - if ( ! l->fill("SwapHodo1XY", &iSwapHodo1XY ) ) return kFALSE; - if ( ! l->fill("SwapHodo2XY", &iSwapHodo2XY ) ) return kFALSE; - if ( ! l->fill("InvertHodo1X", &iInvertHodo1X ) ) return kFALSE; - if ( ! l->fill("InvertHodo1Y", &iInvertHodo1Y ) ) return kFALSE; - if ( ! l->fill("InvertHodo2X", &iInvertHodo2X ) ) return kFALSE; - if ( ! l->fill("InvertHodo2Y", &iInvertHodo2Y ) ) return kFALSE; - fbSwapHodo1XY = iSwapHodo1XY; - fbSwapHodo2XY = iSwapHodo2XY; - fbInvertHodo1X = iInvertHodo1X; - fbInvertHodo1Y = iInvertHodo1Y; - fbInvertHodo2X = iInvertHodo2X; - fbInvertHodo2Y = iInvertHodo2Y; -#else - Int_t iNrOfDpbs = 0; - Int_t iNbElinksPerDpb = 0; - Int_t iNbStsXyters = 0; - Int_t iNbChanPerAsic = 0; - - if ( ! l->fill("NrOfDpbs", &iNrOfDpbs ) ) return kFALSE; - fuNrOfDpbs = iNrOfDpbs; - - fiDbpIdArray.Set( fuNrOfDpbs ); - if ( ! l->fill("DbpIdArray", &fiDbpIdArray ) ) return kFALSE; - - if ( ! l->fill("NbElinksPerDpb", &iNbElinksPerDpb ) ) return kFALSE; - fuNbElinksPerDpb = iNbElinksPerDpb; - - if ( ! l->fill("NbStsXyters", &iNbStsXyters ) ) return kFALSE; - fuNbStsXyters = iNbStsXyters; - - if ( ! l->fill("NbChanPerAsic", &iNbChanPerAsic ) ) return kFALSE; - fuNbChanPerAsic = iNbChanPerAsic; - - fiElinkToAsicMap.Set( fuNrOfDpbs * fuNbElinksPerDpb ); - if ( ! l->fill("ElinkToAsicMap", &fiElinkToAsicMap ) ) return kFALSE; - - fiChannelToFiberMap.Set(fuNbChanPerAsic); - fiChannelToPixelMap.Set(fuNbChanPerAsic); - fiChannelToPlaneMap.Set(fuNbChanPerAsic); - if ( ! l->fill("ChannelToFiberMap", &fiChannelToFiberMap) ) return kFALSE; - if ( ! l->fill("ChannelToPixelMap", &fiChannelToPixelMap) ) return kFALSE; - if ( ! l->fill("ChannelToPlaneMap", &fiChannelToPlaneMap) ) return kFALSE; - - Int_t iAsicIdxHodo1 = 0; - Int_t iAsicIdxHodo2 = 0; - Int_t iSwapHodo1XY = 0; - Int_t iSwapHodo2XY = 0; - Int_t iInvertHodo1X = 0; - Int_t iInvertHodo1Y = 0; - Int_t iInvertHodo2X = 0; - Int_t iInvertHodo2Y = 0; - if ( ! l->fill("AsicIdxHodo1", &iAsicIdxHodo1 ) ) return kFALSE; - if ( ! l->fill("AsicIdxHodo2", &iAsicIdxHodo2 ) ) return kFALSE; - if ( ! l->fill("SwapHodo1XY", &iSwapHodo1XY ) ) return kFALSE; - if ( ! l->fill("SwapHodo2XY", &iSwapHodo2XY ) ) return kFALSE; - if ( ! l->fill("InvertHodo1X", &iInvertHodo1X ) ) return kFALSE; - if ( ! l->fill("InvertHodo1Y", &iInvertHodo1Y ) ) return kFALSE; - if ( ! l->fill("InvertHodo2X", &iInvertHodo2X ) ) return kFALSE; - if ( ! l->fill("InvertHodo2Y", &iInvertHodo2Y ) ) return kFALSE; - fuAsicIdxHodo1 = iAsicIdxHodo1; - fuAsicIdxHodo2 = iAsicIdxHodo2; - fbSwapHodo1XY = iSwapHodo1XY; - fbSwapHodo2XY = iSwapHodo2XY; - fbInvertHodo1X = iInvertHodo1X; - fbInvertHodo1Y = iInvertHodo1Y; - fbInvertHodo2X = iInvertHodo2X; - fbInvertHodo2Y = iInvertHodo2Y; - -#endif // VERSION_GREATER_160601 - - return kTRUE; -} -// ------------------------------------------------------------------------- -UInt_t CbmCern2017UnpackParHodo::GetDpbId( UInt_t uDpbIdx ) -{ - if( uDpbIdx < fuNrOfDpbs ) - return fiDbpIdArray[ uDpbIdx ]; - else - { - LOG(warning) << "CbmCern2017UnpackParHodo::GetDpbId => Index out of bound, " - << "returning crazy value!"; - return 0xFFFFFFFF; - } // else of if( uDpbIdx < fuNrOfDpbs ) -} -UInt_t CbmCern2017UnpackParHodo::GetElinkToAsicIdx( UInt_t uElinkIdx ) -{ - if( uElinkIdx < fuNrOfDpbs * fuNbElinksPerDpb ) - return fiElinkToAsicMap[ uElinkIdx ]; - else - { - LOG(warning) << "CbmCern2017UnpackParHodo::GetElinkToAsicIdx => Index out of bound, " - << "returning crazy value!"; - return (fuNbStsXyters + 1); - } // else of if( uDpbIdx < fuNrOfDpbs ) -} -// ------------------------------------------------------------------------- -Int_t CbmCern2017UnpackParHodo::GetChannelToFiberMap(UInt_t channel) -{ - if( channel < fuNbChanPerAsic ) - return fiChannelToFiberMap[channel]; - else return -1; -} -Int_t CbmCern2017UnpackParHodo::GetChannelToPixelMap(UInt_t channel) -{ - if( channel < fuNbChanPerAsic ) - return fiChannelToPixelMap[channel]; - else return -1; -} -Int_t CbmCern2017UnpackParHodo::GetChannelToPlaneMap(UInt_t channel) -{ - if( channel < fuNbChanPerAsic ) - return fiChannelToPlaneMap[channel]; - else return -1; -} -Bool_t CbmCern2017UnpackParHodo::GetChannelToPlaneMapHodo1(UInt_t channel) -{ - // Should throw error when invalid channel leading to -1! - Bool_t bChanInY = (1 == GetChannelToPlaneMap( channel ) ); - if( fbSwapHodo1XY ) - return !bChanInY; - else return bChanInY; -} -Bool_t CbmCern2017UnpackParHodo::GetChannelToPlaneMapHodo2(UInt_t channel) -{ - // Should throw error when invalid channel leading to -1! - Bool_t bChanInY = (1 == GetChannelToPlaneMap( channel ) ); - if( fbSwapHodo2XY ) - return !bChanInY; - else return bChanInY; -} - -ClassImp(CbmCern2017UnpackParHodo) diff --git a/beamtime/cern2017/param/CbmCern2017UnpackParHodo.h b/beamtime/cern2017/param/CbmCern2017UnpackParHodo.h deleted file mode 100644 index 350c8387d2697f3cda8687c45a4926880add6975..0000000000000000000000000000000000000000 --- a/beamtime/cern2017/param/CbmCern2017UnpackParHodo.h +++ /dev/null @@ -1,85 +0,0 @@ -// ------------------------------------------------------------------------- -// ----- CbmCern2017UnpackParHodo header file ----- -// ----- Created 25/07/17 by P.-A. Loizeau ----- -// ------------------------------------------------------------------------- - -#ifndef CBMCERN2017UNPACKPARHODO_H -#define CBMCERN2017UNPACKPARHODO_H - -#include "FairParGenericSet.h" - -#include "TArrayI.h" - -class FairParIo; -class FairParamList; - - -class CbmCern2017UnpackParHodo : public FairParGenericSet -{ - - public: - - /** Standard constructor **/ - CbmCern2017UnpackParHodo(const char* name = "CbmCern2017UnpackParHodo", - const char* title = "Hodo unpacker parameters", - const char* context = "Default"); - - - /** Destructor **/ - virtual ~CbmCern2017UnpackParHodo(); - - /** Reset all parameters **/ - virtual void clear(); - - void putParams(FairParamList*); - Bool_t getParams(FairParamList*); - - UInt_t GetNrOfDpbs() { return fuNrOfDpbs; } - UInt_t GetDpbId( UInt_t uDpbIdx ); - UInt_t GetNbElinksPerDpb() { return fuNbElinksPerDpb; } - UInt_t GetNbStsXyters() { return fuNbStsXyters; } - UInt_t GetNbChanPerAsic() { return fuNbChanPerAsic; } - UInt_t GetElinkToAsicIdx( UInt_t uElinkIdx ); - - Int_t GetChannelToFiberMap(UInt_t channel); - Int_t GetChannelToPixelMap(UInt_t channel); - Int_t GetChannelToPlaneMap(UInt_t channel); - - UInt_t GetAsicIndexHodo1() { return fuAsicIdxHodo1; } - UInt_t GetAsicIndexHodo2() { return fuAsicIdxHodo2; } - - Bool_t IsXySwappedHodo1() { return fbSwapHodo1XY; } - Bool_t IsXySwappedHodo2() { return fbSwapHodo2XY; } - Bool_t IsXInvertedHodo1() { return fbInvertHodo1X; } - Bool_t IsYInvertedHodo1() { return fbInvertHodo1Y; } - Bool_t IsXInvertedHodo2() { return fbInvertHodo1X; } - Bool_t IsYInvertedHodo2() { return fbInvertHodo2Y; } - - Bool_t GetChannelToPlaneMapHodo1(UInt_t channel); - Bool_t GetChannelToPlaneMapHodo2(UInt_t channel); - - private: - - UInt_t fuNrOfDpbs; // Total number of STS DPBs in system - TArrayI fiDbpIdArray; // Array to hold the unique IDs (equipment ID) for all STS DPBs - UInt_t fuNbElinksPerDpb; // Number of elinks connected to each DPB - UInt_t fuNbStsXyters; // Number of StsXyter ASICs - UInt_t fuNbChanPerAsic; // Number of channels per StsXyter ASIC - TArrayI fiElinkToAsicMap; // Array to hold for each link the corresponding ASIC index [fuNrOfDpbs * fuNbElinksPerDpb] - - TArrayI fiChannelToFiberMap; // Array which stores the corresponding fiber for each channel - TArrayI fiChannelToPixelMap; // Array which stores the corresponding pixel for each channel - TArrayI fiChannelToPlaneMap; // Array which stores the corresponding side for each channel - - UInt_t fuAsicIdxHodo1; // Index of StsXyter ASIC for Hodoscope 1 - UInt_t fuAsicIdxHodo2; // Index of StsXyter ASIC for Hodoscope 2 - Bool_t fbSwapHodo1XY; // Flag indicating wether the X and Y axis of Hodoscope 1 are swapped - Bool_t fbSwapHodo2XY; // Flag indicating wether the X and Y axis of Hodoscope 2 are swapped - Bool_t fbInvertHodo1X; // Flag indicating wether the X axis of Hodoscope 1 is inverted - Bool_t fbInvertHodo1Y; // Flag indicating wether the Y axis of Hodoscope 1 is inverted - Bool_t fbInvertHodo2X; // Flag indicating wether the X axis of Hodoscope 2 is inverted - Bool_t fbInvertHodo2Y; // Flag indicating wether the Y axis of Hodoscope 2 is inverted - - ClassDef(CbmCern2017UnpackParHodo,1); -}; -#endif // CBMCERN2017UNPACKPARHODO_H diff --git a/beamtime/cern2017/param/CbmCern2017UnpackParSts.cxx b/beamtime/cern2017/param/CbmCern2017UnpackParSts.cxx deleted file mode 100644 index 18e8eeed060177145c4b32d903733b6239894842..0000000000000000000000000000000000000000 --- a/beamtime/cern2017/param/CbmCern2017UnpackParSts.cxx +++ /dev/null @@ -1,184 +0,0 @@ -// ------------------------------------------------------------------------- -// ----- CbmCern2017UnpackParSts source file ----- -// ----- Created 25/07/17 by P.-A. Loizeau ----- -// ------------------------------------------------------------------------- - -#include "CbmCern2017UnpackParSts.h" - -#include "FairParamList.h" -#include "FairDetParIo.h" -#include "FairParIo.h" -#include "FairLogger.h" - -#include "TString.h" - -using namespace std; -// ----- Standard constructor ------------------------------------------ -CbmCern2017UnpackParSts::CbmCern2017UnpackParSts(const char* name, - const char* title, - const char* context) : - FairParGenericSet(name, title, context), - fuNrOfDpbs( 0 ), - fiDbpIdArray(), - fuNbElinksPerDpb( 0 ), - fuNbStsXyters( 0 ), - fuNbChanPerAsic( 0 ), - fiElinkToAsicMap(), - fuAsicIdxSts1N( 0 ), - fuAsicIdxSts1P( 0 ), - fuAsicIdxSts2N( 0 ), - fuAsicIdxSts2P( 0 ) -{ - detName="Much"; -} -// ------------------------------------------------------------------------- - - - -// ----- Destructor ---------------------------------------------------- -CbmCern2017UnpackParSts::~CbmCern2017UnpackParSts() -{ -} -// ------------------------------------------------------------------------- - - -// ----- Public method clear ------------------------------------------- -void CbmCern2017UnpackParSts::clear() -{ - status = kFALSE; - resetInputVersions(); -} -// ------------------------------------------------------------------------- - -// ------------------------------------------------------------------------- - -void CbmCern2017UnpackParSts::putParams(FairParamList* l) -{ - if (!l) return; - -#ifdef VERSION_GREATER_160601 - l->add("NrOfDpbs", fuNrOfDpbs ); - l->add("DbpIdArray", fiDbpIdArray); - l->add("NbElinksPerDpb", fuNbElinksPerDpb ); - l->add("NbStsXyters", fuNbStsXyters ); - l->add("NbChanPerAsic", fuNbChanPerAsic ); - l->add("ElinkToAsicMap", fiElinkToAsicMap); - - l->add("AsicIdxSts1N", fuAsicIdxSts1N); - l->add("AsicIdxSts1P", fuAsicIdxSts1P); - l->add("AsicIdxSts2N", fuAsicIdxSts2N); - l->add("AsicIdxSts2P", fuAsicIdxSts2P); -#else - Int_t iNrOfDpbs = fuNrOfDpbs; - Int_t iNbElinksPerDpb = fuNbElinksPerDpb; - Int_t iNbStsXyters = fuNbStsXyters; - Int_t iNbChanPerAsic = fuNbChanPerAsic; - - l->add("NrOfDpbs", iNrOfDpbs ); - l->add("DbpIdArray", fiDbpIdArray); - l->add("NbElinksPerDpb", iNbElinksPerDpb ); - l->add("NbStsXyters", iNbStsXyters ); - l->add("NbChanPerAsic", iNbChanPerAsic ); - l->add("ElinkToAsicMap", fiElinkToAsicMap); - - Int_t iAsicIdxSts1N = fuAsicIdxSts1N; - Int_t iAsicIdxSts1P = fuAsicIdxSts1P; - Int_t iAsicIdxSts2N = fuAsicIdxSts2N; - Int_t iAsicIdxSts2P = fuAsicIdxSts2P; - l->add("AsicIdxSts1N", iAsicIdxSts1N); - l->add("AsicIdxSts1P", iAsicIdxSts1P); - l->add("AsicIdxSts2N", iAsicIdxSts2N); - l->add("AsicIdxSts2P", iAsicIdxSts2P); -#endif // VERSION_GREATER_160601 -} - -// ------------------------------------------------------------------------- - -Bool_t CbmCern2017UnpackParSts::getParams(FairParamList* l) { - - if (!l) return kFALSE; - -#ifdef VERSION_GREATER_160601 - if ( ! l->fill("NrOfDpbs", &fuNrOfDpbs ) ) return kFALSE; - - fiDbpIdArray.Set( fuNrOfDpbs ); - if ( ! l->fill("DbpIdArray", &fiDbpIdArray ) ) return kFALSE; - - if ( ! l->fill("NbElinksPerDpb", &fuNbElinksPerDpb ) ) return kFALSE; - - if ( ! l->fill("NbStsXyters", &fuNbStsXyters ) ) return kFALSE; - - if ( ! l->fill("NbChanPerAsic", &fuNbChanPerAsic ) ) return kFALSE; - - fiElinkToAsicMap.Set( fuNrOfDpbs * fuNbElinksPerDpb ); - if ( ! l->fill("ElinkToAsicMap", &fiElinkToAsicMap ) ) return kFALSE; - - if ( ! l->fill("AsicIdxSts1N", &fuAsicIdxSts1N ) ) return kFALSE; - if ( ! l->fill("AsicIdxSts1P", &fuAsicIdxSts1P ) ) return kFALSE; - if ( ! l->fill("AsicIdxSts2N", &fuAsicIdxSts2N ) ) return kFALSE; - if ( ! l->fill("AsicIdxSts2P", &fuAsicIdxSts2P ) ) return kFALSE; -#else - Int_t iNrOfDpbs = 0; - Int_t iNbElinksPerDpb = 0; - Int_t iNbStsXyters = 0; - Int_t iNbChanPerAsic = 0; - - if ( ! l->fill("NrOfDpbs", &iNrOfDpbs ) ) return kFALSE; - fuNrOfDpbs = iNrOfDpbs; - - fiDbpIdArray.Set( fuNrOfDpbs ); - if ( ! l->fill("DbpIdArray", &fiDbpIdArray ) ) return kFALSE; - - if ( ! l->fill("NbElinksPerDpb", &iNbElinksPerDpb ) ) return kFALSE; - fuNbElinksPerDpb = iNbElinksPerDpb; - - if ( ! l->fill("NbStsXyters", &iNbStsXyters ) ) return kFALSE; - fuNbStsXyters = iNbStsXyters; - - if ( ! l->fill("NbChanPerAsic", &iNbChanPerAsic ) ) return kFALSE; - fuNbChanPerAsic = iNbChanPerAsic; - - fiElinkToAsicMap.Set( fuNrOfDpbs * fuNbElinksPerDpb ); - if ( ! l->fill("ElinkToAsicMap", &fiElinkToAsicMap ) ) return kFALSE; - - Int_t iAsicIdxSts1N = 0; - Int_t iAsicIdxSts1P = 0; - Int_t iAsicIdxSts2N = 0; - Int_t iAsicIdxSts2P = 0; - if ( ! l->fill("AsicIdxSts1N", &iAsicIdxSts1N ) ) return kFALSE; - if ( ! l->fill("AsicIdxSts1P", &iAsicIdxSts1P ) ) return kFALSE; - if ( ! l->fill("AsicIdxSts2N", &iAsicIdxSts2N ) ) return kFALSE; - if ( ! l->fill("AsicIdxSts2P", &iAsicIdxSts2P ) ) return kFALSE; - fuAsicIdxSts1N = iAsicIdxSts1N; - fuAsicIdxSts1P = iAsicIdxSts1P; - fuAsicIdxSts2N = iAsicIdxSts2N; - fuAsicIdxSts2P = iAsicIdxSts2P; -#endif // VERSION_GREATER_160601 - - return kTRUE; -} -// ------------------------------------------------------------------------- -UInt_t CbmCern2017UnpackParSts::GetDpbId( UInt_t uDpbIdx ) -{ - if( uDpbIdx < fuNrOfDpbs ) - return fiDbpIdArray[ uDpbIdx ]; - else - { - LOG(warning) << "CbmCern2017UnpackParSts::GetDpbId => Index out of bound, " - << "returning crazy value!"; - return 0xFFFFFFFF; - } // else of if( uDpbIdx < fuNrOfDpbs ) -} -UInt_t CbmCern2017UnpackParSts::GetElinkToAsicIdx( UInt_t uElinkIdx ) -{ - if( uElinkIdx < fuNrOfDpbs * fuNbElinksPerDpb ) - return fiElinkToAsicMap[ uElinkIdx ]; - else - { - LOG(warning) << "CbmCern2017UnpackParSts::GetElinkToAsicIdx => Index out of bound, " - << "returning crazy value!"; - return (fuNbStsXyters + 1); - } // else of if( uDpbIdx < fuNrOfDpbs ) -} - -ClassImp(CbmCern2017UnpackParSts) diff --git a/beamtime/cern2017/param/CbmCern2017UnpackParSts.h b/beamtime/cern2017/param/CbmCern2017UnpackParSts.h deleted file mode 100644 index b1a1b3d756a93c85413c82a9293449cb3a2c1453..0000000000000000000000000000000000000000 --- a/beamtime/cern2017/param/CbmCern2017UnpackParSts.h +++ /dev/null @@ -1,65 +0,0 @@ -// ------------------------------------------------------------------------- -// ----- CbmCern2017UnpackParSts header file ----- -// ----- Created 25/07/17 by P.-A. Loizeau ----- -// ------------------------------------------------------------------------- - -#ifndef CBMCERN2017UNPACKPARSTS_H -#define CBMCERN2017UNPACKPARSTS_H - -#include "FairParGenericSet.h" - -#include "TArrayI.h" - -class FairParIo; -class FairParamList; - - -class CbmCern2017UnpackParSts : public FairParGenericSet -{ - - public: - - /** Standard constructor **/ - CbmCern2017UnpackParSts(const char* name = "CbmCern2017UnpackParSts", - const char* title = "Sts unpacker parameters", - const char* context = "Default"); - - - /** Destructor **/ - virtual ~CbmCern2017UnpackParSts(); - - /** Reset all parameters **/ - virtual void clear(); - - void putParams(FairParamList*); - Bool_t getParams(FairParamList*); - - UInt_t GetNrOfDpbs() { return fuNrOfDpbs; } - UInt_t GetDpbId( UInt_t uDpbIdx ); - UInt_t GetNbElinksPerDpb() { return fuNbElinksPerDpb; } - UInt_t GetNbStsXyters() { return fuNbStsXyters; } - UInt_t GetNbChanPerAsic() { return fuNbChanPerAsic; } - UInt_t GetElinkToAsicIdx( UInt_t uElinkIdx ); - - UInt_t GetAsicIndexSts1N() { return fuAsicIdxSts1N; } - UInt_t GetAsicIndexSts1P() { return fuAsicIdxSts1P; } - UInt_t GetAsicIndexSts2N() { return fuAsicIdxSts2N; } - UInt_t GetAsicIndexSts2P() { return fuAsicIdxSts2P; } - - private: - - UInt_t fuNrOfDpbs; // Total number of STS DPBs in system - TArrayI fiDbpIdArray; // Array to hold the unique IDs (equipment ID) for all STS DPBs - UInt_t fuNbElinksPerDpb; // Number of elinks connected to each DPB - UInt_t fuNbStsXyters; // Number of StsXyter ASICs - UInt_t fuNbChanPerAsic; // Number of channels per StsXyter ASIC - TArrayI fiElinkToAsicMap; // Array to hold for each link the corresponding ASIC index [fuNrOfDpbs * fuNbElinksPerDpb] - - UInt_t fuAsicIdxSts1N; // Index of StsXyter ASIC for STS sensor 1 side N - UInt_t fuAsicIdxSts1P; // Index of StsXyter ASIC for STS sensor 1 side P - UInt_t fuAsicIdxSts2N; // Index of StsXyter ASIC for STS sensor 2 side N - UInt_t fuAsicIdxSts2P; // Index of StsXyter ASIC for STS sensor 2 side P - - ClassDef(CbmCern2017UnpackParSts,1); -}; -#endif // CBMCERN2017UNPACKPARSTS_H diff --git a/beamtime/cern2017/unpacker/CRCpp_CRC.h b/beamtime/cern2017/unpacker/CRCpp_CRC.h deleted file mode 100644 index 0ba0496ca83154600e84af3783a46fa178a6cbb7..0000000000000000000000000000000000000000 --- a/beamtime/cern2017/unpacker/CRCpp_CRC.h +++ /dev/null @@ -1,1699 +0,0 @@ -/** - @file CRC.h - @author Daniel Bahr - @version 0.2.0.6 - @copyright - @parblock - CRC++ - Copyright (c) 2016, Daniel Bahr - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - * Neither the name of CRC++ nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - @endparblock -*/ - -/* - CRC++ can be configured by setting various #defines before #including this header file: - - #define crcpp_uint8 - Specifies the type used to store CRCs that have a width of 8 bits or less. - This type is not used in CRC calculations. Defaults to ::std::uint8_t. - #define crcpp_uint16 - Specifies the type used to store CRCs that have a width between 9 and 16 bits (inclusive). - This type is not used in CRC calculations. Defaults to ::std::uint16_t. - #define crcpp_uint32 - Specifies the type used to store CRCs that have a width between 17 and 32 bits (inclusive). - This type is not used in CRC calculations. Defaults to ::std::uint32_t. - #define crcpp_uint64 - Specifies the type used to store CRCs that have a width between 33 and 64 bits (inclusive). - This type is not used in CRC calculations. Defaults to ::std::uint64_t. - #define crcpp_size - This type is used for loop iteration and function signatures only. Defaults to ::std::size_t. - #define CRCPP_USE_NAMESPACE - Define to place all CRC++ code within the ::CRCPP namespace. - #define CRCPP_BRANCHLESS - Define to enable a branchless CRC implementation. The branchless implementation uses a single integer - multiplication in the bit-by-bit calculation instead of a small conditional. The branchless implementation - may be faster on processor architectures which support single-instruction integer multiplication. - #define CRCPP_USE_CPP11 - Define to enables C++11 features (move semantics, constexpr, static_assert, etc.). - #define CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS - Define to include definitions for little-used CRCs. -*/ - -#ifndef CRCPP_CRC_H_ -#define CRCPP_CRC_H_ - -#include <climits> // Includes CHAR_BIT -#ifdef CRCPP_USE_CPP11 -#include <cstddef> // Includes ::std::size_t -#include <cstdint> // Includes ::std::uint8_t, ::std::uint16_t, ::std::uint32_t, ::std::uint64_t -#else -#include <stddef.h> // Includes size_t -#include <stdint.h> // Includes uint8_t, uint16_t, uint32_t, uint64_t -#endif -#include <limits> // Includes ::std::numeric_limits -#include <utility> // Includes ::std::move - -#ifndef crcpp_uint8 -# ifdef CRCPP_USE_CPP11 - /// @brief Unsigned 8-bit integer definition, used primarily for parameter definitions. -# define crcpp_uint8 ::std::uint8_t -# else - /// @brief Unsigned 8-bit integer definition, used primarily for parameter definitions. -# define crcpp_uint8 uint8_t -# endif -#endif - -#ifndef crcpp_uint16 -# ifdef CRCPP_USE_CPP11 - /// @brief Unsigned 16-bit integer definition, used primarily for parameter definitions. -# define crcpp_uint16 ::std::uint16_t -# else - /// @brief Unsigned 16-bit integer definition, used primarily for parameter definitions. -# define crcpp_uint16 uint16_t -# endif -#endif - -#ifndef crcpp_uint32 -# ifdef CRCPP_USE_CPP11 - /// @brief Unsigned 32-bit integer definition, used primarily for parameter definitions. -# define crcpp_uint32 ::std::uint32_t -# else - /// @brief Unsigned 32-bit integer definition, used primarily for parameter definitions. -# define crcpp_uint32 uint32_t -# endif -#endif - -#ifndef crcpp_uint64 -# ifdef CRCPP_USE_CPP11 - /// @brief Unsigned 64-bit integer definition, used primarily for parameter definitions. -# define crcpp_uint64 ::std::uint64_t -# else - /// @brief Unsigned 64-bit integer definition, used primarily for parameter definitions. -# define crcpp_uint64 uint64_t -# endif -#endif - -#ifndef crcpp_size -# ifdef CRCPP_USE_CPP11 - /// @brief Unsigned size definition, used for specifying data sizes. -# define crcpp_size ::std::size_t -# else - /// @brief Unsigned size definition, used for specifying data sizes. -# define crcpp_size size_t -# endif -#endif - -#ifdef CRCPP_USE_CPP11 - /// @brief Compile-time expression definition. -# define crcpp_constexpr constexpr -#else - /// @brief Compile-time expression definition. -# define crcpp_constexpr const -#endif - -#ifdef CRCPP_USE_NAMESPACE -namespace CRCPP -{ -#endif - -/** - @brief Static class for computing CRCs. - @note This class supports computation of full and multi-part CRCs, using a bit-by-bit algorithm or a - byte-by-byte lookup table. The CRCs are calculated using as many optimizations as is reasonable. - If compiling with C++11, the constexpr keyword is used liberally so that many calculations are - performed at compile-time instead of at runtime. -*/ -class CRC -{ -public: - // Forward declaration - template <typename CRCType, crcpp_uint16 CRCWidth> - struct Table; - - /** - @brief CRC parameters. - */ - template <typename CRCType, crcpp_uint16 CRCWidth> - struct Parameters - { - CRCType polynomial; ///< CRC polynomial - CRCType initialValue; ///< Initial CRC value - CRCType finalXOR; ///< Value to XOR with the final CRC - bool reflectInput; ///< true to reflect all input bytes - bool reflectOutput; ///< true to reflect the output CRC (reflection occurs before the final XOR) - - Table<CRCType, CRCWidth> MakeTable() const; - }; - - /** - @brief CRC lookup table. After construction, the CRC parameters are fixed. - @note A CRC table can be used for multiple CRC calculations. - */ - template <typename CRCType, crcpp_uint16 CRCWidth> - struct Table - { - // Constructors are intentionally NOT marked explicit. - Table(const Parameters<CRCType, CRCWidth> & parameters); - -#ifdef CRCPP_USE_CPP11 - Table(Parameters<CRCType, CRCWidth> && parameters); -#endif - - const Parameters<CRCType, CRCWidth> & GetParameters() const; - - const CRCType * GetTable() const; - - CRCType operator[](unsigned char index) const; - - private: - void InitTable(); - - Parameters<CRCType, CRCWidth> parameters; ///< CRC parameters used to construct the table - CRCType table[1 << CHAR_BIT]; ///< CRC lookup table - }; - - // The number of bits in CRCType must be at least as large as CRCWidth. - // CRCType must be an unsigned integer type or a custom type with operator overloads. - template <typename CRCType, crcpp_uint16 CRCWidth> - static CRCType Calculate(const void * data, crcpp_size size, const Parameters<CRCType, CRCWidth> & parameters); - - template <typename CRCType, crcpp_uint16 CRCWidth> - static CRCType Calculate(const void * data, crcpp_size size, const Parameters<CRCType, CRCWidth> & parameters, CRCType crc); - - template <typename CRCType, crcpp_uint16 CRCWidth> - static CRCType Calculate(const void * data, crcpp_size size, const Table<CRCType, CRCWidth> & lookupTable); - - template <typename CRCType, crcpp_uint16 CRCWidth> - static CRCType Calculate(const void * data, crcpp_size size, const Table<CRCType, CRCWidth> & lookupTable, CRCType crc); - - // Common CRCs up to 64 bits. - // Note: Check values are the computed CRCs when given an ASCII input of "123456789" (without null terminator) -#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS - static const Parameters< crcpp_uint8, 4> & CRC_4_ITU(); - static const Parameters< crcpp_uint8, 5> & CRC_5_EPC(); - static const Parameters< crcpp_uint8, 5> & CRC_5_ITU(); - static const Parameters< crcpp_uint8, 5> & CRC_5_USB(); - static const Parameters< crcpp_uint8, 6> & CRC_6_CDMA2000A(); - static const Parameters< crcpp_uint8, 6> & CRC_6_CDMA2000B(); - static const Parameters< crcpp_uint8, 6> & CRC_6_ITU(); - static const Parameters< crcpp_uint8, 7> & CRC_7(); -#endif - static const Parameters< crcpp_uint8, 8> & CRC_8(); -#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS - static const Parameters< crcpp_uint8, 8> & CRC_8_EBU(); - static const Parameters< crcpp_uint8, 8> & CRC_8_MAXIM(); - static const Parameters< crcpp_uint8, 8> & CRC_8_WCDMA(); - static const Parameters<crcpp_uint16, 10> & CRC_10(); - static const Parameters<crcpp_uint16, 10> & CRC_10_CDMA2000(); - static const Parameters<crcpp_uint16, 11> & CRC_11(); - static const Parameters<crcpp_uint16, 12> & CRC_12_CDMA2000(); - static const Parameters<crcpp_uint16, 12> & CRC_12_DECT(); - static const Parameters<crcpp_uint16, 12> & CRC_12_UMTS(); - static const Parameters<crcpp_uint16, 13> & CRC_13_BBC(); - static const Parameters<crcpp_uint16, 15> & CRC_15(); - static const Parameters<crcpp_uint16, 15> & CRC_15_MPT1327(); -#endif - static const Parameters<crcpp_uint16, 16> & CRC_16_ARC(); - static const Parameters<crcpp_uint16, 16> & CRC_16_BUYPASS(); - static const Parameters<crcpp_uint16, 16> & CRC_16_CCITTFALSE(); -#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS - static const Parameters<crcpp_uint16, 16> & CRC_16_CDMA2000(); - static const Parameters<crcpp_uint16, 16> & CRC_16_DECTR(); - static const Parameters<crcpp_uint16, 16> & CRC_16_DECTX(); - static const Parameters<crcpp_uint16, 16> & CRC_16_DNP(); -#endif - static const Parameters<crcpp_uint16, 16> & CRC_16_GENIBUS(); - static const Parameters<crcpp_uint16, 16> & CRC_16_KERMIT(); -#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS - static const Parameters<crcpp_uint16, 16> & CRC_16_MAXIM(); - static const Parameters<crcpp_uint16, 16> & CRC_16_MODBUS(); - static const Parameters<crcpp_uint16, 16> & CRC_16_T10DIF(); - static const Parameters<crcpp_uint16, 16> & CRC_16_USB(); -#endif - static const Parameters<crcpp_uint16, 16> & CRC_16_X25(); - static const Parameters<crcpp_uint16, 16> & CRC_16_XMODEM(); -#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS - static const Parameters<crcpp_uint32, 17> & CRC_17_CAN(); - static const Parameters<crcpp_uint32, 21> & CRC_21_CAN(); - static const Parameters<crcpp_uint32, 24> & CRC_24(); - static const Parameters<crcpp_uint32, 24> & CRC_24_FLEXRAYA(); - static const Parameters<crcpp_uint32, 24> & CRC_24_FLEXRAYB(); - static const Parameters<crcpp_uint32, 30> & CRC_30(); -#endif - static const Parameters<crcpp_uint32, 32> & CRC_32(); - static const Parameters<crcpp_uint32, 32> & CRC_32_BZIP2(); -#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS - static const Parameters<crcpp_uint32, 32> & CRC_32_C(); -#endif - static const Parameters<crcpp_uint32, 32> & CRC_32_MPEG2(); - static const Parameters<crcpp_uint32, 32> & CRC_32_POSIX(); -#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS - static const Parameters<crcpp_uint32, 32> & CRC_32_Q(); - static const Parameters<crcpp_uint64, 40> & CRC_40_GSM(); - static const Parameters<crcpp_uint64, 64> & CRC_64(); -#endif - -#ifdef CRCPP_USE_CPP11 - CRC() = delete; - CRC(const CRC & other) = delete; - CRC & operator=(const CRC & other) = delete; - CRC(CRC && other) = delete; - CRC & operator=(CRC && other) = delete; -#endif - -private: -#ifndef CRCPP_USE_CPP11 - CRC(); - CRC(const CRC & other); - CRC & operator=(const CRC & other); -#endif - - template <typename IntegerType> - static IntegerType Reflect(IntegerType value, crcpp_uint16 numBits); - - template <typename CRCType, crcpp_uint16 CRCWidth> - static CRCType Finalize(CRCType remainder, CRCType finalXOR, bool reflectOutput); - - template <typename CRCType, crcpp_uint16 CRCWidth> - static CRCType UndoFinalize(CRCType remainder, CRCType finalXOR, bool reflectOutput); - - template <typename CRCType, crcpp_uint16 CRCWidth> - static CRCType CalculateRemainder(const void * data, crcpp_size size, const Parameters<CRCType, CRCWidth> & parameters, CRCType remainder); - - template <typename CRCType, crcpp_uint16 CRCWidth> - static CRCType CalculateRemainder(const void * data, crcpp_size size, const Table<CRCType, CRCWidth> & lookupTable, CRCType remainder); - - template <typename IntegerType> - static crcpp_constexpr IntegerType BoundedConstexprValue(IntegerType x); -}; - -/** - @brief Returns a CRC lookup table construct using these CRC parameters. - @note This function primarily exists to allow use of the auto keyword instead of instantiating - a table directly, since template parameters are not inferred in constructors. - @tparam CRCType Integer type for storing the CRC result - @tparam CRCWidth Number of bits in the CRC - @return CRC lookup table -*/ -template <typename CRCType, crcpp_uint16 CRCWidth> -inline CRC::Table<CRCType, CRCWidth> CRC::Parameters<CRCType, CRCWidth>::MakeTable() const -{ - // This should take advantage of RVO and optimize out the copy. - return CRC::Table<CRCType, CRCWidth>(*this); -} - -/** - @brief Constructs a CRC table from a set of CRC parameters - @param[in] parameters CRC parameters - @tparam CRCType Integer type for storing the CRC result - @tparam CRCWidth Number of bits in the CRC -*/ -template <typename CRCType, crcpp_uint16 CRCWidth> -inline CRC::Table<CRCType, CRCWidth>::Table(const Parameters<CRCType, CRCWidth> & parametersIn) : - parameters(parametersIn) -{ - InitTable(); -} - -#ifdef CRCPP_USE_CPP11 -/** - @brief Constructs a CRC table from a set of CRC parameters - @param[in] parameters CRC parameters - @tparam CRCType Integer type for storing the CRC result - @tparam CRCWidth Number of bits in the CRC -*/ -template <typename CRCType, crcpp_uint16 CRCWidth> -inline CRC::Table<CRCType, CRCWidth>::Table(Parameters<CRCType, CRCWidth> && parametersIn) : - parameters(::std::move(parametersIn)) -{ - InitTable(); -} -#endif - -/** - @brief Gets the CRC parameters used to construct the CRC table - @tparam CRCType Integer type for storing the CRC result - @tparam CRCWidth Number of bits in the CRC - @return CRC parameters -*/ -template <typename CRCType, crcpp_uint16 CRCWidth> -inline const CRC::Parameters<CRCType, CRCWidth> & CRC::Table<CRCType, CRCWidth>::GetParameters() const -{ - return parameters; -} - -/** - @brief Gets the CRC table - @tparam CRCType Integer type for storing the CRC result - @tparam CRCWidth Number of bits in the CRC - @return CRC table -*/ -template <typename CRCType, crcpp_uint16 CRCWidth> -inline const CRCType * CRC::Table<CRCType, CRCWidth>::GetTable() const -{ - return table; -} - -/** - @brief Gets an entry in the CRC table - @param[in] index Index into the CRC table - @tparam CRCType Integer type for storing the CRC result - @tparam CRCWidth Number of bits in the CRC - @return CRC table entry -*/ -template <typename CRCType, crcpp_uint16 CRCWidth> -inline CRCType CRC::Table<CRCType, CRCWidth>::operator[](unsigned char index) const -{ - return table[index]; -} - -/** - @brief Initializes a CRC table. - @tparam CRCType Integer type for storing the CRC result - @tparam CRCWidth Number of bits in the CRC -*/ -template <typename CRCType, crcpp_uint16 CRCWidth> -inline void CRC::Table<CRCType, CRCWidth>::InitTable() -{ - // For masking off the bits for the CRC (in the event that the number of bits in CRCType is larger than CRCWidth) - static crcpp_constexpr CRCType BIT_MASK((CRCType(1) << (CRCWidth - CRCType(1))) | - ((CRCType(1) << (CRCWidth - CRCType(1))) - CRCType(1))); - - static crcpp_constexpr CRCType SHIFT(CRC::BoundedConstexprValue(CHAR_BIT - CRCWidth)); - - CRCType crc; - unsigned char byte = 0; - - // Loop over each dividend (each possible number storable in an unsigned char) - do - { - crc = CRC::CalculateRemainder<CRCType, CRCWidth>(&byte, sizeof(byte), parameters, CRCType(0)); - - // This mask might not be necessary; all unit tests pass with this line commented out, - // but that might just be a coincidence based on the CRC parameters used for testing. - // In any case, this is harmless to leave in and only adds a single machine instruction per loop iteration. - crc &= BIT_MASK; - - if (!parameters.reflectInput && CRCWidth < CHAR_BIT) - { - // Undo the special operation at the end of the CalculateRemainder() - // function for non-reflected CRCs < CHAR_BIT. - crc <<= SHIFT; - } - - table[byte] = crc; - } - while (++byte); -} - -/** - @brief Computes a CRC. - @param[in] data Data over which CRC will be computed - @param[in] size Size of the data - @param[in] parameters CRC parameters - @tparam CRCType Integer type for storing the CRC result - @tparam CRCWidth Number of bits in the CRC - @return CRC -*/ -template <typename CRCType, crcpp_uint16 CRCWidth> -inline CRCType CRC::Calculate(const void * data, crcpp_size size, const Parameters<CRCType, CRCWidth> & parameters) -{ - CRCType remainder = CalculateRemainder(data, size, parameters, parameters.initialValue); - - // No need to mask the remainder here; the mask will be applied in the Finalize() function. - - return Finalize<CRCType, CRCWidth>(remainder, parameters.finalXOR, parameters.reflectInput != parameters.reflectOutput); -} -/** - @brief Appends additional data to a previous CRC calculation. - @note This function can be used to compute multi-part CRCs. - @param[in] data Data over which CRC will be computed - @param[in] size Size of the data - @param[in] parameters CRC parameters - @param[in] crc CRC from a previous calculation - @tparam CRCType Integer type for storing the CRC result - @tparam CRCWidth Number of bits in the CRC - @return CRC -*/ -template <typename CRCType, crcpp_uint16 CRCWidth> -inline CRCType CRC::Calculate(const void * data, crcpp_size size, const Parameters<CRCType, CRCWidth> & parameters, CRCType crc) -{ - CRCType remainder = UndoFinalize<CRCType, CRCWidth>(crc, parameters.finalXOR, parameters.reflectInput != parameters.reflectOutput); - - remainder = CalculateRemainder(data, size, parameters, remainder); - - // No need to mask the remainder here; the mask will be applied in the Finalize() function. - - return Finalize<CRCType, CRCWidth>(remainder, parameters.finalXOR, parameters.reflectInput != parameters.reflectOutput); -} - -/** - @brief Computes a CRC via a lookup table. - @param[in] data Data over which CRC will be computed - @param[in] size Size of the data - @param[in] lookupTable CRC lookup table - @tparam CRCType Integer type for storing the CRC result - @tparam CRCWidth Number of bits in the CRC - @return CRC -*/ -template <typename CRCType, crcpp_uint16 CRCWidth> -inline CRCType CRC::Calculate(const void * data, crcpp_size size, const Table<CRCType, CRCWidth> & lookupTable) -{ - const Parameters<CRCType, CRCWidth> & parameters = lookupTable.GetParameters(); - - CRCType remainder = CalculateRemainder(data, size, lookupTable, parameters.initialValue); - - // No need to mask the remainder here; the mask will be applied in the Finalize() function. - - return Finalize<CRCType, CRCWidth>(remainder, parameters.finalXOR, parameters.reflectInput != parameters.reflectOutput); -} - -/** - @brief Appends additional data to a previous CRC calculation using a lookup table. - @note This function can be used to compute multi-part CRCs. - @param[in] data Data over which CRC will be computed - @param[in] size Size of the data - @param[in] lookupTable CRC lookup table - @param[in] crc CRC from a previous calculation - @tparam CRCType Integer type for storing the CRC result - @tparam CRCWidth Number of bits in the CRC - @return CRC -*/ -template <typename CRCType, crcpp_uint16 CRCWidth> -inline CRCType CRC::Calculate(const void * data, crcpp_size size, const Table<CRCType, CRCWidth> & lookupTable, CRCType crc) -{ - const Parameters<CRCType, CRCWidth> & parameters = lookupTable.GetParameters(); - - CRCType remainder = UndoFinalize<CRCType, CRCWidth>(crc, parameters.finalXOR, parameters.reflectInput != parameters.reflectOutput); - - remainder = CalculateRemainder(data, size, lookupTable, remainder); - - // No need to mask the remainder here; the mask will be applied in the Finalize() function. - - return Finalize<CRCType, CRCWidth>(remainder, parameters.finalXOR, parameters.reflectInput != parameters.reflectOutput); -} - -/** - @brief Reflects (i.e. reverses the bits within) an integer value. - @param[in] value Value to reflect - @param[in] numBits Number of bits in the integer which will be reflected - @tparam IntegerType Integer type of the value being reflected - @return Reflected value -*/ -template <typename IntegerType> -inline IntegerType CRC::Reflect(IntegerType value, crcpp_uint16 numBits) -{ - IntegerType reversedValue(0); - - for (crcpp_uint16 i = 0; i < numBits; ++i) - { - reversedValue = (reversedValue << 1) | (value & 1); - value >>= 1; - } - - return reversedValue; -} - -/** - @brief Computes the final reflection and XOR of a CRC remainder. - @param[in] remainder CRC remainder to reflect and XOR - @param[in] finalXOR Final value to XOR with the remainder - @param[in] reflectOutput true to reflect each byte of the remainder before the XOR - @tparam CRCType Integer type for storing the CRC result - @tparam CRCWidth Number of bits in the CRC - @return Final CRC -*/ -template <typename CRCType, crcpp_uint16 CRCWidth> -inline CRCType CRC::Finalize(CRCType remainder, CRCType finalXOR, bool reflectOutput) -{ - // For masking off the bits for the CRC (in the event that the number of bits in CRCType is larger than CRCWidth) - static crcpp_constexpr CRCType BIT_MASK = (CRCType(1) << (CRCWidth - CRCType(1))) | - ((CRCType(1) << (CRCWidth - CRCType(1))) - CRCType(1)); - - if (reflectOutput) - { - remainder = Reflect(remainder, CRCWidth); - } - - return (remainder ^ finalXOR) & BIT_MASK; -} - -/** - @brief Undoes the process of computing the final reflection and XOR of a CRC remainder. - @note This function allows for computation of multi-part CRCs - @note Calling UndoFinalize() followed by Finalize() (or vice versa) will always return the original remainder value: - - CRCType x = ...; - CRCType y = Finalize(x, finalXOR, reflectOutput); - CRCType z = UndoFinalize(y, finalXOR, reflectOutput); - assert(x == z); - - @param[in] crc Reflected and XORed CRC - @param[in] finalXOR Final value XORed with the remainder - @param[in] reflectOutput true if the remainder is to be reflected - @tparam CRCType Integer type for storing the CRC result - @tparam CRCWidth Number of bits in the CRC - @return Un-finalized CRC remainder -*/ -template <typename CRCType, crcpp_uint16 CRCWidth> -inline CRCType CRC::UndoFinalize(CRCType crc, CRCType finalXOR, bool reflectOutput) -{ - // For masking off the bits for the CRC (in the event that the number of bits in CRCType is larger than CRCWidth) - static crcpp_constexpr CRCType BIT_MASK = (CRCType(1) << (CRCWidth - CRCType(1))) | - ((CRCType(1) << (CRCWidth - CRCType(1))) - CRCType(1)); - - crc = (crc & BIT_MASK) ^ finalXOR; - - if (reflectOutput) - { - crc = Reflect(crc, CRCWidth); - } - - return crc; -} - -/** - @brief Computes a CRC remainder. - @param[in] data Data over which the remainder will be computed - @param[in] size Size of the data - @param[in] parameters CRC parameters - @param[in] remainder Running CRC remainder. Can be an initial value or the result of a previous CRC remainder calculation. - @tparam CRCType Integer type for storing the CRC result - @tparam CRCWidth Number of bits in the CRC - @return CRC remainder -*/ -template <typename CRCType, crcpp_uint16 CRCWidth> -inline CRCType CRC::CalculateRemainder(const void * data, crcpp_size size, const Parameters<CRCType, CRCWidth> & parameters, CRCType remainder) -{ -#ifdef CRCPP_USE_CPP11 - // This static_assert is put here because this function will always be compiled in no matter what - // the template parameters are and whether or not a table lookup or bit-by-bit algorithm is used. - static_assert(::std::numeric_limits<CRCType>::digits >= CRCWidth, "CRCType is too small to contain a CRC of width CRCWidth."); -#else - // Catching this compile-time error is very important. Sadly, the compiler error will be very cryptic, but it's - // better than nothing. - enum { static_assert_failed_CRCType_is_too_small_to_contain_a_CRC_of_width_CRCWidth = 1 / (::std::numeric_limits<CRCType>::digits >= CRCWidth ? 1 : 0) }; -#endif - - const unsigned char * current = reinterpret_cast<const unsigned char *>(data); - - // Slightly different implementations based on the parameters. The current implementations try to eliminate as much - // computation from the inner loop (looping over each bit) as possible. - if (parameters.reflectInput) - { - CRCType polynomial = CRC::Reflect(parameters.polynomial, CRCWidth); - while (size--) - { - remainder ^= *current++; - - // An optimizing compiler might choose to unroll this loop. - for (crcpp_size i = 0; i < CHAR_BIT; ++i) - { -#ifdef CRCPP_BRANCHLESS - // Clever way to avoid a branch at the expense of a multiplication. This code is equivalent to the following: - // if (remainder & 1) - // remainder = (remainder >> 1) ^ polynomial; - // else - // remainder >>= 1; - remainder = (remainder >> 1) ^ ((remainder & 1) * polynomial); -#else - remainder = (remainder & 1) ? ((remainder >> 1) ^ polynomial) : (remainder >> 1); -#endif - } - } - } - else if (CRCWidth >= CHAR_BIT) - { - static crcpp_constexpr CRCType CRC_WIDTH_MINUS_ONE(CRCWidth - CRCType(1)); -#ifndef CRCPP_BRANCHLESS - static crcpp_constexpr CRCType CRC_HIGHEST_BIT_MASK(CRCType(1) << CRC_WIDTH_MINUS_ONE); -#endif - static crcpp_constexpr CRCType SHIFT(BoundedConstexprValue(CRCWidth - CHAR_BIT)); - - while (size--) - { - remainder ^= (static_cast<CRCType>(*current++) << SHIFT); - - // An optimizing compiler might choose to unroll this loop. - for (crcpp_size i = 0; i < CHAR_BIT; ++i) - { -#ifdef CRCPP_BRANCHLESS - // Clever way to avoid a branch at the expense of a multiplication. This code is equivalent to the following: - // if (remainder & CRC_HIGHEST_BIT_MASK) - // remainder = (remainder << 1) ^ parameters.polynomial; - // else - // remainder <<= 1; - remainder = (remainder << 1) ^ (((remainder >> CRC_WIDTH_MINUS_ONE) & 1) * parameters.polynomial); -#else - remainder = (remainder & CRC_HIGHEST_BIT_MASK) ? ((remainder << 1) ^ parameters.polynomial) : (remainder << 1); -#endif - } - } - } - else - { - static crcpp_constexpr CRCType CHAR_BIT_MINUS_ONE(CHAR_BIT - 1); -#ifndef CRCPP_BRANCHLESS - static crcpp_constexpr CRCType CHAR_BIT_HIGHEST_BIT_MASK(CRCType(1) << CHAR_BIT_MINUS_ONE); -#endif - static crcpp_constexpr CRCType SHIFT(BoundedConstexprValue(CHAR_BIT - CRCWidth)); - - CRCType polynomial = parameters.polynomial << SHIFT; - remainder <<= SHIFT; - - while (size--) - { - remainder ^= *current++; - - // An optimizing compiler might choose to unroll this loop. - for (crcpp_size i = 0; i < CHAR_BIT; ++i) - { -#ifdef CRCPP_BRANCHLESS - // Clever way to avoid a branch at the expense of a multiplication. This code is equivalent to the following: - // if (remainder & CHAR_BIT_HIGHEST_BIT_MASK) - // remainder = (remainder << 1) ^ polynomial; - // else - // remainder <<= 1; - remainder = (remainder << 1) ^ (((remainder >> CHAR_BIT_MINUS_ONE) & 1) * polynomial); -#else - remainder = (remainder & CHAR_BIT_HIGHEST_BIT_MASK) ? ((remainder << 1) ^ polynomial) : (remainder << 1); -#endif - } - } - - remainder >>= SHIFT; - } - - return remainder; -} - -/** - @brief Computes a CRC remainder using lookup table. - @param[in] data Data over which the remainder will be computed - @param[in] size Size of the data - @param[in] lookupTable CRC lookup table - @param[in] remainder Running CRC remainder. Can be an initial value or the result of a previous CRC remainder calculation. - @tparam CRCType Integer type for storing the CRC result - @tparam CRCWidth Number of bits in the CRC - @return CRC remainder -*/ -template <typename CRCType, crcpp_uint16 CRCWidth> -inline CRCType CRC::CalculateRemainder(const void * data, crcpp_size size, const Table<CRCType, CRCWidth> & lookupTable, CRCType remainder) -{ - const unsigned char * current = reinterpret_cast<const unsigned char *>(data); - - if (lookupTable.GetParameters().reflectInput) - { - while (size--) - { -#if defined(WIN32) || defined(_WIN32) || defined(WINCE) - // Disable warning about data loss when doing (remainder >> CHAR_BIT) when - // remainder is one byte long. The algorithm is still correct in this case, - // though it's possible that one additional machine instruction will be executed. -# pragma warning (push) -# pragma warning (disable : 4333) -#endif - remainder = (remainder >> CHAR_BIT) ^ lookupTable[static_cast<unsigned char>(remainder ^ *current++)]; -#if defined(WIN32) || defined(_WIN32) || defined(WINCE) -# pragma warning (pop) -#endif - } - } - else if (CRCWidth >= CHAR_BIT) - { - static crcpp_constexpr CRCType SHIFT(BoundedConstexprValue(CRCWidth - CHAR_BIT)); - - while (size--) - { - remainder = (remainder << CHAR_BIT) ^ lookupTable[static_cast<unsigned char>((remainder >> SHIFT) ^ *current++)]; - } - } - else - { - static crcpp_constexpr CRCType SHIFT(BoundedConstexprValue(CHAR_BIT - CRCWidth)); - - remainder <<= SHIFT; - - while (size--) - { - // Note: no need to mask here since remainder is guaranteed to fit in a single byte. - remainder = lookupTable[static_cast<unsigned char>(remainder ^ *current++)]; - } - - remainder >>= SHIFT; - } - - return remainder; -} - -/** - @brief Function to force a compile-time expression to be >= 0. - @note This function is used to avoid compiler warnings because all constexpr values are evaluated - in a function even in a branch will never be executed. This also means we don't need pragmas - to get rid of warnings, but it still can be computed at compile-time. Win-win! - @param[in] x Compile-time expression to bound - @tparam CRCType Integer type for storing the CRC result - @tparam CRCWidth Number of bits in the CRC - @return Non-negative compile-time expression -*/ -template <typename IntegerType> -inline crcpp_constexpr IntegerType CRC::BoundedConstexprValue(IntegerType x) -{ - return (x < IntegerType(0)) ? IntegerType(0) : x; -} - -#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS -/** - @brief Returns a set of parameters for CRC-4 ITU. - @note The parameters are static and are delayed-constructed to reduce memory footprint. - @note CRC-4 ITU has the following parameters and check value: - - polynomial = 0x3 - - initial value = 0x0 - - final XOR = 0x0 - - reflect input = true - - reflect output = true - - check value = 0x7 - @return CRC-4 ITU parameters -*/ -inline const CRC::Parameters<crcpp_uint8, 4> & CRC::CRC_4_ITU() -{ - static const Parameters<crcpp_uint8, 4> parameters = { 0x3, 0x0, 0x0, true, true }; - return parameters; -} - -/** - @brief Returns a set of parameters for CRC-5 EPC. - @note The parameters are static and are delayed-constructed to reduce memory footprint. - @note CRC-5 EPC has the following parameters and check value: - - polynomial = 0x09 - - initial value = 0x09 - - final XOR = 0x00 - - reflect input = false - - reflect output = false - - check value = 0x00 - @return CRC-5 EPC parameters -*/ -inline const CRC::Parameters<crcpp_uint8, 5> & CRC::CRC_5_EPC() -{ - static const Parameters<crcpp_uint8, 5> parameters = { 0x09, 0x09, 0x00, false, false }; - return parameters; -} - -/** - @brief Returns a set of parameters for CRC-5 ITU. - @note The parameters are static and are delayed-constructed to reduce memory footprint. - @note CRC-5 ITU has the following parameters and check value: - - polynomial = 0x15 - - initial value = 0x00 - - final XOR = 0x00 - - reflect input = true - - reflect output = true - - check value = 0x07 - @return CRC-5 ITU parameters -*/ -inline const CRC::Parameters<crcpp_uint8, 5> & CRC::CRC_5_ITU() -{ - static const Parameters<crcpp_uint8, 5> parameters = { 0x15, 0x00, 0x00, true, true }; - return parameters; -} - -/** - @brief Returns a set of parameters for CRC-5 USB. - @note The parameters are static and are delayed-constructed to reduce memory footprint. - @note CRC-5 USB has the following parameters and check value: - - polynomial = 0x05 - - initial value = 0x1F - - final XOR = 0x1F - - reflect input = true - - reflect output = true - - check value = 0x19 - @return CRC-5 USB parameters -*/ -inline const CRC::Parameters<crcpp_uint8, 5> & CRC::CRC_5_USB() -{ - static const Parameters<crcpp_uint8, 5> parameters = { 0x05, 0x1F, 0x1F, true, true }; - return parameters; -} - -/** - @brief Returns a set of parameters for CRC-6 CDMA2000-A. - @note The parameters are static and are delayed-constructed to reduce memory footprint. - @note CRC-6 CDMA2000-A has the following parameters and check value: - - polynomial = 0x27 - - initial value = 0x3F - - final XOR = 0x00 - - reflect input = false - - reflect output = false - - check value = 0x0D - @return CRC-6 CDMA2000-A parameters -*/ -inline const CRC::Parameters<crcpp_uint8, 6> & CRC::CRC_6_CDMA2000A() -{ - static const Parameters<crcpp_uint8, 6> parameters = { 0x27, 0x3F, 0x00, false, false }; - return parameters; -} - -/** - @brief Returns a set of parameters for CRC-6 CDMA2000-B. - @note The parameters are static and are delayed-constructed to reduce memory footprint. - @note CRC-6 CDMA2000-A has the following parameters and check value: - - polynomial = 0x07 - - initial value = 0x3F - - final XOR = 0x00 - - reflect input = false - - reflect output = false - - check value = 0x3B - @return CRC-6 CDMA2000-B parameters -*/ -inline const CRC::Parameters<crcpp_uint8, 6> & CRC::CRC_6_CDMA2000B() -{ - static const Parameters<crcpp_uint8, 6> parameters = { 0x07, 0x3F, 0x00, false, false }; - return parameters; -} - -/** - @brief Returns a set of parameters for CRC-6 ITU. - @note The parameters are static and are delayed-constructed to reduce memory footprint. - @note CRC-6 ITU has the following parameters and check value: - - polynomial = 0x03 - - initial value = 0x00 - - final XOR = 0x00 - - reflect input = true - - reflect output = true - - check value = 0x06 - @return CRC-6 ITU parameters -*/ -inline const CRC::Parameters<crcpp_uint8, 6> & CRC::CRC_6_ITU() -{ - static const Parameters<crcpp_uint8, 6> parameters = { 0x03, 0x00, 0x00, true, true }; - return parameters; -} - -/** - @brief Returns a set of parameters for CRC-7 JEDEC. - @note The parameters are static and are delayed-constructed to reduce memory footprint. - @note CRC-7 JEDEC has the following parameters and check value: - - polynomial = 0x09 - - initial value = 0x00 - - final XOR = 0x00 - - reflect input = false - - reflect output = false - - check value = 0x75 - @return CRC-7 JEDEC parameters -*/ -inline const CRC::Parameters<crcpp_uint8, 7> & CRC::CRC_7() -{ - static const Parameters<crcpp_uint8, 7> parameters = { 0x09, 0x00, 0x00, false, false }; - return parameters; -} -#endif // CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS - -/** - @brief Returns a set of parameters for CRC-8 SMBus. - @note The parameters are static and are delayed-constructed to reduce memory footprint. - @note CRC-8 SMBus has the following parameters and check value: - - polynomial = 0x07 - - initial value = 0x00 - - final XOR = 0x00 - - reflect input = false - - reflect output = false - - check value = 0xF4 - @return CRC-8 SMBus parameters -*/ -inline const CRC::Parameters<crcpp_uint8, 8> & CRC::CRC_8() -{ - static const Parameters<crcpp_uint8, 8> parameters = { 0x07, 0x00, 0x00, false, false }; - return parameters; -} - -#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS -/** - @brief Returns a set of parameters for CRC-8 EBU (aka CRC-8 AES). - @note The parameters are static and are delayed-constructed to reduce memory footprint. - @note CRC-8 EBU has the following parameters and check value: - - polynomial = 0x1D - - initial value = 0xFF - - final XOR = 0x00 - - reflect input = true - - reflect output = true - - check value = 0x97 - @return CRC-8 EBU parameters -*/ -inline const CRC::Parameters<crcpp_uint8, 8> & CRC::CRC_8_EBU() -{ - static const Parameters<crcpp_uint8, 8> parameters = { 0x1D, 0xFF, 0x00, true, true }; - return parameters; -} - -/** - @brief Returns a set of parameters for CRC-8 MAXIM (aka CRC-8 DOW-CRC). - @note The parameters are static and are delayed-constructed to reduce memory footprint. - @note CRC-8 MAXIM has the following parameters and check value: - - polynomial = 0x31 - - initial value = 0x00 - - final XOR = 0x00 - - reflect input = true - - reflect output = true - - check value = 0xA1 - @return CRC-8 MAXIM parameters -*/ -inline const CRC::Parameters<crcpp_uint8, 8> & CRC::CRC_8_MAXIM() -{ - static const Parameters<crcpp_uint8, 8> parameters = { 0x31, 0x00, 0x00, true, true }; - return parameters; -} - -/** - @brief Returns a set of parameters for CRC-8 WCDMA. - @note The parameters are static and are delayed-constructed to reduce memory footprint. - @note CRC-8 WCDMA has the following parameters and check value: - - polynomial = 0x9B - - initial value = 0x00 - - final XOR = 0x00 - - reflect input = true - - reflect output = true - - check value = 0x25 - @return CRC-8 WCDMA parameters -*/ -inline const CRC::Parameters<crcpp_uint8, 8> & CRC::CRC_8_WCDMA() -{ - static const Parameters<crcpp_uint8, 8> parameters = { 0x9B, 0x00, 0x00, true, true }; - return parameters; -} - -/** - @brief Returns a set of parameters for CRC-10 ITU. - @note The parameters are static and are delayed-constructed to reduce memory footprint. - @note CRC-10 ITU has the following parameters and check value: - - polynomial = 0x233 - - initial value = 0x000 - - final XOR = 0x000 - - reflect input = false - - reflect output = false - - check value = 0x199 - @return CRC-10 ITU parameters -*/ -inline const CRC::Parameters<crcpp_uint16, 10> & CRC::CRC_10() -{ - static const Parameters<crcpp_uint16, 10> parameters = { 0x233, 0x000, 0x000, false, false }; - return parameters; -} - -/** - @brief Returns a set of parameters for CRC-10 CDMA2000. - @note The parameters are static and are delayed-constructed to reduce memory footprint. - @note CRC-10 CDMA2000 has the following parameters and check value: - - polynomial = 0x3D9 - - initial value = 0x3FF - - final XOR = 0x000 - - reflect input = false - - reflect output = false - - check value = 0x233 - @return CRC-10 CDMA2000 parameters -*/ -inline const CRC::Parameters<crcpp_uint16, 10> & CRC::CRC_10_CDMA2000() -{ - static const Parameters<crcpp_uint16, 10> parameters = { 0x3D9, 0x3FF, 0x000, false, false }; - return parameters; -} - -/** - @brief Returns a set of parameters for CRC-11 FlexRay. - @note The parameters are static and are delayed-constructed to reduce memory footprint. - @note CRC-11 FlexRay has the following parameters and check value: - - polynomial = 0x385 - - initial value = 0x01A - - final XOR = 0x000 - - reflect input = false - - reflect output = false - - check value = 0x5A3 - @return CRC-11 FlexRay parameters -*/ -inline const CRC::Parameters<crcpp_uint16, 11> & CRC::CRC_11() -{ - static const Parameters<crcpp_uint16, 11> parameters = { 0x385, 0x01A, 0x000, false, false }; - return parameters; -} - -/** - @brief Returns a set of parameters for CRC-12 CDMA2000. - @note The parameters are static and are delayed-constructed to reduce memory footprint. - @note CRC-12 CDMA2000 has the following parameters and check value: - - polynomial = 0xF13 - - initial value = 0xFFF - - final XOR = 0x000 - - reflect input = false - - reflect output = false - - check value = 0xD4D - @return CRC-12 CDMA2000 parameters -*/ -inline const CRC::Parameters<crcpp_uint16, 12> & CRC::CRC_12_CDMA2000() -{ - static const Parameters<crcpp_uint16, 12> parameters = { 0xF13, 0xFFF, 0x000, false, false }; - return parameters; -} - -/** - @brief Returns a set of parameters for CRC-12 DECT (aka CRC-12 X-CRC). - @note The parameters are static and are delayed-constructed to reduce memory footprint. - @note CRC-12 DECT has the following parameters and check value: - - polynomial = 0x80F - - initial value = 0x000 - - final XOR = 0x000 - - reflect input = false - - reflect output = false - - check value = 0xF5B - @return CRC-12 DECT parameters -*/ -inline const CRC::Parameters<crcpp_uint16, 12> & CRC::CRC_12_DECT() -{ - static const Parameters<crcpp_uint16, 12> parameters = { 0x80F, 0x000, 0x000, false, false }; - return parameters; -} - -/** - @brief Returns a set of parameters for CRC-12 UMTS (aka CRC-12 3GPP). - @note The parameters are static and are delayed-constructed to reduce memory footprint. - @note CRC-12 UMTS has the following parameters and check value: - - polynomial = 0x80F - - initial value = 0x000 - - final XOR = 0x000 - - reflect input = false - - reflect output = true - - check value = 0xDAF - @return CRC-12 UMTS parameters -*/ -inline const CRC::Parameters<crcpp_uint16, 12> & CRC::CRC_12_UMTS() -{ - static const Parameters<crcpp_uint16, 12> parameters = { 0x80F, 0x000, 0x000, false, true }; - return parameters; -} - -/** - @brief Returns a set of parameters for CRC-13 BBC. - @note The parameters are static and are delayed-constructed to reduce memory footprint. - @note CRC-13 BBC has the following parameters and check value: - - polynomial = 0x1CF5 - - initial value = 0x0000 - - final XOR = 0x0000 - - reflect input = false - - reflect output = false - - check value = 0x04FA - @return CRC-13 BBC parameters -*/ -inline const CRC::Parameters<crcpp_uint16, 13> & CRC::CRC_13_BBC() -{ - static const Parameters<crcpp_uint16, 13> parameters = { 0x1CF5, 0x0000, 0x0000, false, false }; - return parameters; -} - -/** - @brief Returns a set of parameters for CRC-15 CAN. - @note The parameters are static and are delayed-constructed to reduce memory footprint. - @note CRC-15 CAN has the following parameters and check value: - - polynomial = 0x4599 - - initial value = 0x0000 - - final XOR = 0x0000 - - reflect input = false - - reflect output = false - - check value = 0x059E - @return CRC-15 CAN parameters -*/ -inline const CRC::Parameters<crcpp_uint16, 15> & CRC::CRC_15() -{ - static const Parameters<crcpp_uint16, 15> parameters = { 0x4599, 0x0000, 0x0000, false, false }; - return parameters; -} - -/** - @brief Returns a set of parameters for CRC-15 MPT1327. - @note The parameters are static and are delayed-constructed to reduce memory footprint. - @note CRC-15 MPT1327 has the following parameters and check value: - - polynomial = 0x6815 - - initial value = 0x0000 - - final XOR = 0x0001 - - reflect input = false - - reflect output = false - - check value = 0x2566 - @return CRC-15 MPT1327 parameters -*/ -inline const CRC::Parameters<crcpp_uint16, 15> & CRC::CRC_15_MPT1327() -{ - static const Parameters<crcpp_uint16, 15> parameters = { 0x6815, 0x0000, 0x0001, false, false }; - return parameters; -} -#endif // CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS - -/** - @brief Returns a set of parameters for CRC-16 ARC (aka CRC-16 IBM, CRC-16 LHA). - @note The parameters are static and are delayed-constructed to reduce memory footprint. - @note CRC-16 ARC has the following parameters and check value: - - polynomial = 0x8005 - - initial value = 0x0000 - - final XOR = 0x0000 - - reflect input = true - - reflect output = true - - check value = 0xBB3D - @return CRC-16 ARC parameters -*/ -inline const CRC::Parameters<crcpp_uint16, 16> & CRC::CRC_16_ARC() -{ - static const Parameters<crcpp_uint16, 16> parameters = { 0x8005, 0x0000, 0x0000, true, true }; - return parameters; -} - -/** - @brief Returns a set of parameters for CRC-16 BUYPASS (aka CRC-16 VERIFONE, CRC-16 UMTS). - @note The parameters are static and are delayed-constructed to reduce memory footprint. - @note CRC-16 BUYPASS has the following parameters and check value: - - polynomial = 0x8005 - - initial value = 0x0000 - - final XOR = 0x0000 - - reflect input = false - - reflect output = false - - check value = 0xFEE8 - @return CRC-16 BUYPASS parameters -*/ -inline const CRC::Parameters<crcpp_uint16, 16> & CRC::CRC_16_BUYPASS() -{ - static const Parameters<crcpp_uint16, 16> parameters = { 0x8005, 0x0000, 0x0000, false, false }; - return parameters; -} - -/** - @brief Returns a set of parameters for CRC-16 CCITT FALSE. - @note The parameters are static and are delayed-constructed to reduce memory footprint. - @note CRC-16 CCITT FALSE has the following parameters and check value: - - polynomial = 0x1021 - - initial value = 0xFFFF - - final XOR = 0x0000 - - reflect input = false - - reflect output = false - - check value = 0x29B1 - @return CRC-16 CCITT FALSE parameters -*/ -inline const CRC::Parameters<crcpp_uint16, 16> & CRC::CRC_16_CCITTFALSE() -{ - static const Parameters<crcpp_uint16, 16> parameters = { 0x1021, 0xFFFF, 0x0000, false, false }; - return parameters; -} - -#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS -/** - @brief Returns a set of parameters for CRC-16 CDMA2000. - @note The parameters are static and are delayed-constructed to reduce memory footprint. - @note CRC-16 CDMA2000 has the following parameters and check value: - - polynomial = 0xC867 - - initial value = 0xFFFF - - final XOR = 0x0000 - - reflect input = false - - reflect output = false - - check value = 0x4C06 - @return CRC-16 CDMA2000 parameters -*/ -inline const CRC::Parameters<crcpp_uint16, 16> & CRC::CRC_16_CDMA2000() -{ - static const Parameters<crcpp_uint16, 16> parameters = { 0xC867, 0xFFFF, 0x0000, false, false }; - return parameters; -} - -/** - @brief Returns a set of parameters for CRC-16 DECT-R (aka CRC-16 R-CRC). - @note The parameters are static and are delayed-constructed to reduce memory footprint. - @note CRC-16 DECT-R has the following parameters and check value: - - polynomial = 0x0589 - - initial value = 0x0000 - - final XOR = 0x0001 - - reflect input = false - - reflect output = false - - check value = 0x007E - @return CRC-16 DECT-R parameters -*/ -inline const CRC::Parameters<crcpp_uint16, 16> & CRC::CRC_16_DECTR() -{ - static const Parameters<crcpp_uint16, 16> parameters = { 0x0589, 0x0000, 0x0001, false, false }; - return parameters; -} - -/** - @brief Returns a set of parameters for CRC-16 DECT-X (aka CRC-16 X-CRC). - @note The parameters are static and are delayed-constructed to reduce memory footprint. - @note CRC-16 DECT-X has the following parameters and check value: - - polynomial = 0x0589 - - initial value = 0x0000 - - final XOR = 0x0000 - - reflect input = false - - reflect output = false - - check value = 0x007F - @return CRC-16 DECT-X parameters -*/ -inline const CRC::Parameters<crcpp_uint16, 16> & CRC::CRC_16_DECTX() -{ - static const Parameters<crcpp_uint16, 16> parameters = { 0x0589, 0x0000, 0x0000, false, false }; - return parameters; -} - -/** - @brief Returns a set of parameters for CRC-16 DNP. - @note The parameters are static and are delayed-constructed to reduce memory footprint. - @note CRC-16 DNP has the following parameters and check value: - - polynomial = 0x3D65 - - initial value = 0x0000 - - final XOR = 0xFFFF - - reflect input = true - - reflect output = true - - check value = 0xEA82 - @return CRC-16 DNP parameters -*/ -inline const CRC::Parameters<crcpp_uint16, 16> & CRC::CRC_16_DNP() -{ - static const Parameters<crcpp_uint16, 16> parameters = { 0x3D65, 0x0000, 0xFFFF, true, true }; - return parameters; -} -#endif // CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS - -/** - @brief Returns a set of parameters for CRC-16 GENIBUS (aka CRC-16 EPC, CRC-16 I-CODE, CRC-16 DARC). - @note The parameters are static and are delayed-constructed to reduce memory footprint. - @note CRC-16 GENIBUS has the following parameters and check value: - - polynomial = 0x1021 - - initial value = 0xFFFF - - final XOR = 0xFFFF - - reflect input = false - - reflect output = false - - check value = 0xD64E - @return CRC-16 GENIBUS parameters -*/ -inline const CRC::Parameters<crcpp_uint16, 16> & CRC::CRC_16_GENIBUS() -{ - static const Parameters<crcpp_uint16, 16> parameters = { 0x1021, 0xFFFF, 0xFFFF, false, false }; - return parameters; -} - -/** - @brief Returns a set of parameters for CRC-16 KERMIT (aka CRC-16 CCITT, CRC-16 CCITT-TRUE). - @note The parameters are static and are delayed-constructed to reduce memory footprint. - @note CRC-16 KERMIT has the following parameters and check value: - - polynomial = 0x1021 - - initial value = 0x0000 - - final XOR = 0x0000 - - reflect input = true - - reflect output = true - - check value = 0x2189 - @return CRC-16 KERMIT parameters -*/ -inline const CRC::Parameters<crcpp_uint16, 16> & CRC::CRC_16_KERMIT() -{ - static const Parameters<crcpp_uint16, 16> parameters = { 0x1021, 0x0000, 0x0000, true, true }; - return parameters; -} - -#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS -/** - @brief Returns a set of parameters for CRC-16 MAXIM. - @note The parameters are static and are delayed-constructed to reduce memory footprint. - @note CRC-16 MAXIM has the following parameters and check value: - - polynomial = 0x8005 - - initial value = 0x0000 - - final XOR = 0xFFFF - - reflect input = true - - reflect output = true - - check value = 0x44C2 - @return CRC-16 MAXIM parameters -*/ -inline const CRC::Parameters<crcpp_uint16, 16> & CRC::CRC_16_MAXIM() -{ - static const Parameters<crcpp_uint16, 16> parameters = { 0x8005, 0x0000, 0xFFFF, true, true }; - return parameters; -} - -/** - @brief Returns a set of parameters for CRC-16 MODBUS. - @note The parameters are static and are delayed-constructed to reduce memory footprint. - @note CRC-16 MODBUS has the following parameters and check value: - - polynomial = 0x8005 - - initial value = 0xFFFF - - final XOR = 0x0000 - - reflect input = true - - reflect output = true - - check value = 0x4B37 - @return CRC-16 MODBUS parameters -*/ -inline const CRC::Parameters<crcpp_uint16, 16> & CRC::CRC_16_MODBUS() -{ - static const Parameters<crcpp_uint16, 16> parameters = { 0x8005, 0xFFFF, 0x0000, true, true }; - return parameters; -} - -/** - @brief Returns a set of parameters for CRC-16 T10-DIF. - @note The parameters are static and are delayed-constructed to reduce memory footprint. - @note CRC-16 T10-DIF has the following parameters and check value: - - polynomial = 0x8BB7 - - initial value = 0x0000 - - final XOR = 0x0000 - - reflect input = false - - reflect output = false - - check value = 0xD0DB - @return CRC-16 T10-DIF parameters -*/ -inline const CRC::Parameters<crcpp_uint16, 16> & CRC::CRC_16_T10DIF() -{ - static const Parameters<crcpp_uint16, 16> parameters = { 0x8BB7, 0x0000, 0x0000, false, false }; - return parameters; -} - -/** - @brief Returns a set of parameters for CRC-16 USB. - @note The parameters are static and are delayed-constructed to reduce memory footprint. - @note CRC-16 USB has the following parameters and check value: - - polynomial = 0x8005 - - initial value = 0xFFFF - - final XOR = 0xFFFF - - reflect input = true - - reflect output = true - - check value = 0xB4C8 - @return CRC-16 USB parameters -*/ -inline const CRC::Parameters<crcpp_uint16, 16> & CRC::CRC_16_USB() -{ - static const Parameters<crcpp_uint16, 16> parameters = { 0x8005, 0xFFFF, 0xFFFF, true, true }; - return parameters; -} -#endif // CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS - -/** - @brief Returns a set of parameters for CRC-16 X-25 (aka CRC-16 IBM-SDLC, CRC-16 ISO-HDLC, CRC-16 B). - @note The parameters are static and are delayed-constructed to reduce memory footprint. - @note CRC-16 X-25 has the following parameters and check value: - - polynomial = 0x1021 - - initial value = 0xFFFF - - final XOR = 0xFFFF - - reflect input = true - - reflect output = true - - check value = 0x906E - @return CRC-16 X-25 parameters -*/ -inline const CRC::Parameters<crcpp_uint16, 16> & CRC::CRC_16_X25() -{ - static const Parameters<crcpp_uint16, 16> parameters = { 0x1021, 0xFFFF, 0xFFFF, true, true }; - return parameters; -} - -/** - @brief Returns a set of parameters for CRC-16 XMODEM (aka CRC-16 ZMODEM, CRC-16 ACORN, CRC-16 LTE). - @note The parameters are static and are delayed-constructed to reduce memory footprint. - @note CRC-16 XMODEM has the following parameters and check value: - - polynomial = 0x1021 - - initial value = 0x0000 - - final XOR = 0x0000 - - reflect input = false - - reflect output = false - - check value = 0x31C3 - @return CRC-16 XMODEM parameters -*/ -inline const CRC::Parameters<crcpp_uint16, 16> & CRC::CRC_16_XMODEM() -{ - static const Parameters<crcpp_uint16, 16> parameters = { 0x1021, 0x0000, 0x0000, false, false }; - return parameters; -} - -#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS -/** - @brief Returns a set of parameters for CRC-17 CAN. - @note The parameters are static and are delayed-constructed to reduce memory footprint. - @note CRC-17 CAN has the following parameters and check value: - - polynomial = 0x1685B - - initial value = 0x00000 - - final XOR = 0x00000 - - reflect input = false - - reflect output = false - - check value = 0x04F03 - @return CRC-17 CAN parameters -*/ -inline const CRC::Parameters<crcpp_uint32, 17> & CRC::CRC_17_CAN() -{ - static const Parameters<crcpp_uint32, 17> parameters = { 0x1685B, 0x00000, 0x00000, false, false }; - return parameters; -} - -/** - @brief Returns a set of parameters for CRC-21 CAN. - @note The parameters are static and are delayed-constructed to reduce memory footprint. - @note CRC-21 CAN has the following parameters and check value: - - polynomial = 0x102899 - - initial value = 0x000000 - - final XOR = 0x000000 - - reflect input = false - - reflect output = false - - check value = 0x0ED841 - @return CRC-21 CAN parameters -*/ -inline const CRC::Parameters<crcpp_uint32, 21> & CRC::CRC_21_CAN() -{ - static const Parameters<crcpp_uint32, 21> parameters = { 0x102899, 0x000000, 0x000000, false, false }; - return parameters; -} - -/** - @brief Returns a set of parameters for CRC-24 OPENPGP. - @note The parameters are static and are delayed-constructed to reduce memory footprint. - @note CRC-24 OPENPGP has the following parameters and check value: - - polynomial = 0x864CFB - - initial value = 0xB704CE - - final XOR = 0x000000 - - reflect input = false - - reflect output = false - - check value = 0x21CF02 - @return CRC-24 OPENPGP parameters -*/ -inline const CRC::Parameters<crcpp_uint32, 24> & CRC::CRC_24() -{ - static const Parameters<crcpp_uint32, 24> parameters = { 0x864CFB, 0xB704CE, 0x000000, false, false }; - return parameters; -} - -/** - @brief Returns a set of parameters for CRC-24 FlexRay-A. - @note The parameters are static and are delayed-constructed to reduce memory footprint. - @note CRC-24 FlexRay-A has the following parameters and check value: - - polynomial = 0x5D6DCB - - initial value = 0xFEDCBA - - final XOR = 0x000000 - - reflect input = false - - reflect output = false - - check value = 0x7979BD - @return CRC-24 FlexRay-A parameters -*/ -inline const CRC::Parameters<crcpp_uint32, 24> & CRC::CRC_24_FLEXRAYA() -{ - static const Parameters<crcpp_uint32, 24> parameters = { 0x5D6DCB, 0xFEDCBA, 0x000000, false, false }; - return parameters; -} - -/** - @brief Returns a set of parameters for CRC-24 FlexRay-B. - @note The parameters are static and are delayed-constructed to reduce memory footprint. - @note CRC-24 FlexRay-B has the following parameters and check value: - - polynomial = 0x5D6DCB - - initial value = 0xABCDEF - - final XOR = 0x000000 - - reflect input = false - - reflect output = false - - check value = 0x1F23B8 - @return CRC-24 FlexRay-B parameters -*/ -inline const CRC::Parameters<crcpp_uint32, 24> & CRC::CRC_24_FLEXRAYB() -{ - static const Parameters<crcpp_uint32, 24> parameters = { 0x5D6DCB, 0xABCDEF, 0x000000, false, false }; - return parameters; -} - -/** - @brief Returns a set of parameters for CRC-30 CDMA. - @note The parameters are static and are delayed-constructed to reduce memory footprint. - @note CRC-30 CDMA has the following parameters and check value: - - polynomial = 0x2030B9C7 - - initial value = 0x3FFFFFFF - - final XOR = 0x00000000 - - reflect input = false - - reflect output = false - - check value = 0x3B3CB540 - @return CRC-30 CDMA parameters -*/ -inline const CRC::Parameters<crcpp_uint32, 30> & CRC::CRC_30() -{ - static const Parameters<crcpp_uint32, 30> parameters = { 0x2030B9C7, 0x3FFFFFFF, 0x00000000, false, false }; - return parameters; -} -#endif // CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS - -/** - @brief Returns a set of parameters for CRC-32 (aka CRC-32 ADCCP, CRC-32 PKZip). - @note The parameters are static and are delayed-constructed to reduce memory footprint. - @note CRC-32 has the following parameters and check value: - - polynomial = 0x04C11DB7 - - initial value = 0xFFFFFFFF - - final XOR = 0xFFFFFFFF - - reflect input = true - - reflect output = true - - check value = 0xCBF43926 - @return CRC-32 parameters -*/ -inline const CRC::Parameters<crcpp_uint32, 32> & CRC::CRC_32() -{ - static const Parameters<crcpp_uint32, 32> parameters = { 0x04C11DB7, 0xFFFFFFFF, 0xFFFFFFFF, true, true }; - return parameters; -} - -/** - @brief Returns a set of parameters for CRC-32 BZIP2 (aka CRC-32 AAL5, CRC-32 DECT-B, CRC-32 B-CRC). - @note The parameters are static and are delayed-constructed to reduce memory footprint. - @note CRC-32 BZIP2 has the following parameters and check value: - - polynomial = 0x04C11DB7 - - initial value = 0xFFFFFFFF - - final XOR = 0xFFFFFFFF - - reflect input = false - - reflect output = false - - check value = 0xFC891918 - @return CRC-32 BZIP2 parameters -*/ -inline const CRC::Parameters<crcpp_uint32, 32> & CRC::CRC_32_BZIP2() -{ - static const Parameters<crcpp_uint32, 32> parameters = { 0x04C11DB7, 0xFFFFFFFF, 0xFFFFFFFF, false, false }; - return parameters; -} - -#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS -/** - @brief Returns a set of parameters for CRC-32 C (aka CRC-32 ISCSI, CRC-32 Castagnoli, CRC-32 Interlaken). - @note The parameters are static and are delayed-constructed to reduce memory footprint. - @note CRC-32 C has the following parameters and check value: - - polynomial = 0x1EDC6F41 - - initial value = 0xFFFFFFFF - - final XOR = 0xFFFFFFFF - - reflect input = true - - reflect output = true - - check value = 0xE3069283 - @return CRC-32 C parameters -*/ -inline const CRC::Parameters<crcpp_uint32, 32> & CRC::CRC_32_C() -{ - static const Parameters<crcpp_uint32, 32> parameters = { 0x1EDC6F41, 0xFFFFFFFF, 0xFFFFFFFF, true, true }; - return parameters; -} -#endif - -/** - @brief Returns a set of parameters for CRC-32 MPEG-2. - @note The parameters are static and are delayed-constructed to reduce memory footprint. - @note CRC-32 MPEG-2 has the following parameters and check value: - - polynomial = 0x04C11DB7 - - initial value = 0xFFFFFFFF - - final XOR = 0x00000000 - - reflect input = false - - reflect output = false - - check value = 0x0376E6E7 - @return CRC-32 MPEG-2 parameters -*/ -inline const CRC::Parameters<crcpp_uint32, 32> & CRC::CRC_32_MPEG2() -{ - static const Parameters<crcpp_uint32, 32> parameters = { 0x04C11DB7, 0xFFFFFFFF, 0x00000000, false, false }; - return parameters; -} - -/** - @brief Returns a set of parameters for CRC-32 POSIX. - @note The parameters are static and are delayed-constructed to reduce memory footprint. - @note CRC-32 POSIX has the following parameters and check value: - - polynomial = 0x04C11DB7 - - initial value = 0x00000000 - - final XOR = 0xFFFFFFFF - - reflect input = false - - reflect output = false - - check value = 0x765E7680 - @return CRC-32 POSIX parameters -*/ -inline const CRC::Parameters<crcpp_uint32, 32> & CRC::CRC_32_POSIX() -{ - static const Parameters<crcpp_uint32, 32> parameters = { 0x04C11DB7, 0x00000000, 0xFFFFFFFF, false, false }; - return parameters; -} - -#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS -/** - @brief Returns a set of parameters for CRC-32 Q. - @note The parameters are static and are delayed-constructed to reduce memory footprint. - @note CRC-32 Q has the following parameters and check value: - - polynomial = 0x814141AB - - initial value = 0x00000000 - - final XOR = 0x00000000 - - reflect input = false - - reflect output = false - - check value = 0x3010BF7F - @return CRC-32 Q parameters -*/ -inline const CRC::Parameters<crcpp_uint32, 32> & CRC::CRC_32_Q() -{ - static const Parameters<crcpp_uint32, 32> parameters = { 0x814141AB, 0x00000000, 0x00000000, false, false }; - return parameters; -} - -/** - @brief Returns a set of parameters for CRC-40 GSM. - @note The parameters are static and are delayed-constructed to reduce memory footprint. - @note CRC-40 GSM has the following parameters and check value: - - polynomial = 0x0004820009 - - initial value = 0x0000000000 - - final XOR = 0xFFFFFFFFFF - - reflect input = false - - reflect output = false - - check value = 0xD4164FC646 - @return CRC-40 GSM parameters -*/ -inline const CRC::Parameters<crcpp_uint64, 40> & CRC::CRC_40_GSM() -{ - static const Parameters<crcpp_uint64, 40> parameters = { 0x0004820009, 0x0000000000, 0xFFFFFFFFFF, false, false }; - return parameters; -} - -/** - @brief Returns a set of parameters for CRC-64 ECMA. - @note The parameters are static and are delayed-constructed to reduce memory footprint. - @note CRC-64 ECMA has the following parameters and check value: - - polynomial = 0x42F0E1EBA9EA3693 - - initial value = 0x0000000000000000 - - final XOR = 0x0000000000000000 - - reflect input = false - - reflect output = false - - check value = 0x6C40DF5F0B497347 - @return CRC-64 ECMA parameters -*/ -inline const CRC::Parameters<crcpp_uint64, 64> & CRC::CRC_64() -{ - static const Parameters<crcpp_uint64, 64> parameters = { 0x42F0E1EBA9EA3693, 0x0000000000000000, 0x0000000000000000, false, false }; - return parameters; -} -#endif // CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS - -#ifdef CRCPP_USE_NAMESPACE -} -#endif - -#endif // CRCPP_CRC_H_ diff --git a/beamtime/cern2017/unpacker/CbmCern2017MonitorBetaSts.cxx b/beamtime/cern2017/unpacker/CbmCern2017MonitorBetaSts.cxx deleted file mode 100644 index 68b9a240387bee3ce1fd23951dc747e097e88c38..0000000000000000000000000000000000000000 --- a/beamtime/cern2017/unpacker/CbmCern2017MonitorBetaSts.cxx +++ /dev/null @@ -1,1710 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmCern2017MonitorBetaSts ----- -// ----- Created 24/11/17 by P.-A. Loizeau ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#include "CbmCern2017MonitorBetaSts.h" - -// Data - -// CbmRoot -#include "CbmCern2017UnpackParSts.h" -#include "CbmHistManager.h" - -// FairRoot -#include "FairLogger.h" -#include "FairRootManager.h" -#include "FairRun.h" -#include "FairRuntimeDb.h" -#include "FairRunOnline.h" - -// Root -#include "TClonesArray.h" -#include "TString.h" -#include "TRandom.h" -#include "THttpServer.h" -#include "TROOT.h" -#include "TStyle.h" -#include <TFile.h> - -// C++11 - -// C/C++ -#include <iostream> -#include <stdint.h> -#include <iomanip> - -Bool_t bCern2017ResetStsHistosBeta = kFALSE; -Bool_t bCern2017WriteStsHistosBeta = kFALSE; - -CbmCern2017MonitorBetaSts::CbmCern2017MonitorBetaSts() : - CbmTSUnpack(), - fuOverlapMsNb(0), - fUnpackPar(NULL), - fuNrOfDpbs(0), - fDpbIdIndexMap(), - fuNbElinksPerDpb(0), - fuNbStsXyters(0), - fuNbChanPerAsic(0), - fvuElinkToAsic(), - fbPrintMessages( kFALSE ), - fPrintMessCtrl( stsxyter::BetaMessagePrintMask::msg_print_Human ), - fbChanHitDtEna( kFALSE ), - fmMsgCounter(), - fuCurrentEquipmentId(0), - fuCurrDpbId(0), - fuCurrDpbIdx(0), - fiRunStartDateTimeSec(-1), - fiBinSizeDatePlots(-1), - fvuCurrentTsMsb(), - fvuCurrentTsMsbCycle(), - fvuCurrentTsMsbOver(), - fvulChanLastHitTime(), - fvdChanLastHitTime(), - fvuChanNbHitsInMs(), - fvdChanLastHitTimeInMs(), - fvusChanLastHitAdcInMs(), - fvmChanHitsInTs(), - fdStartTime(-1.0), - fdStartTimeMsSz(-1.0), - ftStartTimeUnix( std::chrono::steady_clock::now() ), - fbBetaFormat( kFALSE ), - fvuElinkLastTsHit(), - fvmHitsInTs(), - fvulChanLastSortedHitTime(), - fHM(new CbmHistManager()), - fhStsMessType(NULL), - fhStsSysMessType(NULL), - fhStsMessTypePerDpb(NULL), - fhStsSysMessTypePerDpb(NULL), - fhStsMessTypePerElink(NULL), - fhStsSysMessTypePerElink(NULL), - fhStsChanCounts(), - fhStsChanRawAdc(), - fhStsChanRawAdcProf(), - fhStsChanRawTs(), - fhStsChanMissEvt(), - fhStsChanOverDiff(), - fhStsChanHitRateEvo(), - fhStsXyterRateEvo(), - fhStsChanHitRateEvoLong(), - fhStsXyterRateEvoLong(), - fhStsChanHitDt(), - fhStsChanHitDtNeg(), - fhStsChanHitsPerMs(), - fhStsChanSameMs(), - fpStsChanSameMsTimeDiff(), - fhStsChanSameMsTimeDiff(), - fbPulserTimeDiffOn(kFALSE), - fuPulserMaxNbMicroslices(100), - fvuPulserAsic(), - fvuPulserChan(), - fhStsPulserChansTimeDiff(), - fhStsPulserChansTimeDiffEvo(), - fhStsPulserChansSortedTimeDiff(), - fhStsPulserChansSortedTimeDiffEvo(), - fhStsAsicTsMsb(NULL), - fhStsAsicTsMsbMaj(NULL), - fhStsElinkTsMsbCrc(), - fhStsElinkTsMsbMaj(), - fbLongHistoEnable( kFALSE ), - fuLongHistoNbSeconds( 0 ), - fuLongHistoBinSizeSec( 0 ), - fuLongHistoBinNb( 0 ), - fhFebRateEvoLong(), - fhFebChRateEvoLong(), - fcMsSizeAll(NULL) -{ -} - -CbmCern2017MonitorBetaSts::~CbmCern2017MonitorBetaSts() -{ -} - -Bool_t CbmCern2017MonitorBetaSts::Init() -{ - LOG(info) << "Initializing flib StsXyter unpacker for STS"; - - FairRootManager* ioman = FairRootManager::Instance(); - if (ioman == NULL) { - LOG(fatal) << "No FairRootManager instance"; - } - - return kTRUE; -} - -void CbmCern2017MonitorBetaSts::SetParContainers() -{ - LOG(info) << "Setting parameter containers for " << GetName(); - fUnpackPar = (CbmCern2017UnpackParSts*)(FairRun::Instance()->GetRuntimeDb()->getContainer("CbmCern2017UnpackParSts")); -} - - -Bool_t CbmCern2017MonitorBetaSts::InitContainers() -{ - LOG(info) << "Init parameter containers for " << GetName(); - - Bool_t bReInit = ReInitContainers(); - CreateHistograms(); - - return bReInit; -} - -Bool_t CbmCern2017MonitorBetaSts::ReInitContainers() -{ - LOG(info) << "ReInit parameter containers for " << GetName(); - - fuNrOfDpbs = fUnpackPar->GetNrOfDpbs(); - fuNbElinksPerDpb = fUnpackPar->GetNbElinksPerDpb(); - fuNbStsXyters = fUnpackPar->GetNbStsXyters(); - fuNbChanPerAsic = fUnpackPar->GetNbChanPerAsic(); - - - LOG(info) << "Nr. of STS DPBs: " << fuNrOfDpbs; - - fDpbIdIndexMap.clear(); - fvuElinkToAsic.resize( fuNrOfDpbs ); - for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - { - fDpbIdIndexMap[ fUnpackPar->GetDpbId( uDpb ) ] = uDpb; - LOG(info) << "Eq. ID for DPB #" << std::setw(2) << uDpb << " = " - << std::setw(4) << std::hex << fUnpackPar->GetDpbId( uDpb ) - << std::dec - << " => " << fDpbIdIndexMap[ fUnpackPar->GetDpbId( uDpb ) ]; - - fvuElinkToAsic[uDpb].resize( fuNbElinksPerDpb ); - for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink ) - fvuElinkToAsic[uDpb][uElink] = fUnpackPar->GetElinkToAsicIdx( uDpb * fuNbElinksPerDpb + uElink ); - } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - - LOG(info) << "Nr. eLinks per DPB: " << fuNbElinksPerDpb; - LOG(info) << "Nr. of StsXyter ASICs: " << fuNbStsXyters; - LOG(info) << "Nb. channels per ASIC: " << fuNbChanPerAsic; - - for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - { - LOG(info) << "ASIC ID for eLinks in DPB #" << std::setw(2) << uDpb << ": "; - - for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink ) - { - if( 0 == uElink % 10 ) - LOG(info) << "\n" - << "------> "; - - LOG(info) << std::setw( 5 ) << fvuElinkToAsic[uDpb][uElink] << " "; - } // for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink ) - LOG(info) << ""; - } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - - // Internal status initialization - fvuCurrentTsMsb.resize( fuNrOfDpbs ); - fvuCurrentTsMsbCycle.resize( fuNrOfDpbs ); - fvuCurrentTsMsbOver.resize( fuNrOfDpbs ); - fvuElinkLastTsHit.resize( fuNrOfDpbs ); - for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - { - fvuCurrentTsMsb[uDpb].resize( fuNbElinksPerDpb ); - fvuCurrentTsMsbCycle[uDpb].resize( fuNbElinksPerDpb ); - fvuCurrentTsMsbOver[uDpb].resize( fuNbElinksPerDpb ); - fvuElinkLastTsHit[uDpb].resize( fuNbElinksPerDpb ); - for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink ) - { - fvuCurrentTsMsb[uDpb][uElink] = 0; - fvuCurrentTsMsbCycle[uDpb][uElink] = 0; - fvuCurrentTsMsbOver[uDpb][uElink] = 0; - fvuElinkLastTsHit[uDpb][uElink] = 0; - } // for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink ) - } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - - fvulChanLastHitTime.resize( fuNbStsXyters ); - fvdChanLastHitTime.resize( fuNbStsXyters ); - fvuChanNbHitsInMs.resize( fuNbStsXyters ); - fvdChanLastHitTimeInMs.resize( fuNbStsXyters ); - fvusChanLastHitAdcInMs.resize( fuNbStsXyters ); - fvmChanHitsInTs.resize( fuNbStsXyters ); - fvulChanLastSortedHitTime.resize( fuNbStsXyters ); - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fvulChanLastHitTime[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvdChanLastHitTime[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvuChanNbHitsInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvdChanLastHitTimeInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvusChanLastHitAdcInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvmChanHitsInTs[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvulChanLastSortedHitTime[ uXyterIdx ].resize( fuNbChanPerAsic ); - for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - { - fvulChanLastHitTime[ uXyterIdx ][ uChan ] = 0; - fvdChanLastHitTime[ uXyterIdx ][ uChan ] = -1.0; - fvulChanLastSortedHitTime[ uXyterIdx ][ uChan ] = 0; - - fvuChanNbHitsInMs[ uXyterIdx ][ uChan ].resize( fuPulserMaxNbMicroslices ); - fvdChanLastHitTimeInMs[ uXyterIdx ][ uChan ].resize( fuPulserMaxNbMicroslices ); - fvusChanLastHitAdcInMs[ uXyterIdx ][ uChan ].resize( fuPulserMaxNbMicroslices ); - fvmChanHitsInTs[ uXyterIdx ][ uChan ].clear(); - for( UInt_t uMsIdx = 0; uMsIdx < fuPulserMaxNbMicroslices; ++uMsIdx ) - { - fvuChanNbHitsInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = 0; - fvdChanLastHitTimeInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = -1.0; - fvusChanLastHitAdcInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = 0; - } // for( UInt_t uMsIdx = 0; uMsIdx < fuPulserMaxNbMicroslices; ++uMsIdx ) - } // for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - LOG(info) << "CbmCern2017MonitorBetaSts::ReInitContainers => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs.size() << " VS " << fuNbStsXyters; - LOG(info) << "CbmCern2017MonitorBetaSts::ReInitContainers => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs[ 0 ].size() << " VS " << fuNbChanPerAsic; - LOG(info) << "CbmCern2017MonitorBetaSts::ReInitContainers => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs[ 0 ][ 0 ].size() << " VS " << fuPulserMaxNbMicroslices; - return kTRUE; -} - -void CbmCern2017MonitorBetaSts::CreateHistograms() -{ - THttpServer* server = FairRunOnline::Instance()->GetHttpServer(); - - TString sHistName{""}; - TString title{""}; - - sHistName = "hStsMessageType"; - title = "Nb of message for each type; Type"; - fhStsMessType = new TH1I(sHistName, title, 5, 0., 5.); - fhStsMessType->GetXaxis()->SetBinLabel( 1, "Dummy"); - fhStsMessType->GetXaxis()->SetBinLabel( 2, "Hit"); - fhStsMessType->GetXaxis()->SetBinLabel( 3, "TsMsb"); - fhStsMessType->GetXaxis()->SetBinLabel( 4, "ReadDataAck"); - fhStsMessType->GetXaxis()->SetBinLabel( 5, "Ack"); -/* *** Missing int + MessType OP!!!! **** - fhStsMessType->GetXaxis()->SetBinLabel(1 + stsxyter::BetaMessType::Dummy, "Dummy"); - fhStsMessType->GetXaxis()->SetBinLabel(1 + stsxyter::BetaMessType::Hit, "Hit"); - fhStsMessType->GetXaxis()->SetBinLabel(1 + stsxyter::BetaMessType::TsMsb, "TsMsb"); - fhStsMessType->GetXaxis()->SetBinLabel(1 + stsxyter::BetaMessType::ReadDataAck, "ReadDataAck"); - fhStsMessType->GetXaxis()->SetBinLabel(1 + stsxyter::BetaMessType::Ack, "Ack"); -*/ - fHM->Add(sHistName.Data(), fhStsMessType); - if( server ) server->Register("/StsRaw", fhStsMessType ); - - sHistName = "hStsSysMessType"; - title = "Nb of system message for each type; System Type"; - fhStsSysMessType = new TH1I(sHistName, title, 17, 0., 17.); -/* - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_START, "DAQ START"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_FINISH, "DAQ FINISH"); - hSysMessType->GetXaxis()->SetBinLabel(1 + 16, "GET4 Hack 32B"); -*/ - fHM->Add(sHistName.Data(), fhStsSysMessType); - if( server ) server->Register("/StsRaw", fhStsSysMessType ); - - sHistName = "hStsMessageTypePerDpb"; - title = "Nb of message of each type for each DPB; DPB; Type"; - fhStsMessTypePerDpb = new TH2I(sHistName, title, fuNrOfDpbs, 0, fuNrOfDpbs, 5, 0., 5.); - fhStsMessTypePerDpb->GetYaxis()->SetBinLabel( 1, "Dummy"); - fhStsMessTypePerDpb->GetYaxis()->SetBinLabel( 2, "Hit"); - fhStsMessTypePerDpb->GetYaxis()->SetBinLabel( 3, "TsMsb"); - fhStsMessTypePerDpb->GetYaxis()->SetBinLabel( 4, "ReadDataAck"); - fhStsMessTypePerDpb->GetYaxis()->SetBinLabel( 5, "Ack"); -/* *** Missing int + MessType OP!!!! **** - fhStsMessType->GetYaxis()->SetBinLabel(1 + stsxyter::BetaMessType::Dummy, "Dummy"); - fhStsMessType->GetYaxis()->SetBinLabel(1 + stsxyter::BetaMessType::Hit, "Hit"); - fhStsMessType->GetYaxis()->SetBinLabel(1 + stsxyter::BetaMessType::TsMsb, "TsMsb"); - fhStsMessType->GetYaxis()->SetBinLabel(1 + stsxyter::BetaMessType::ReadDataAck, "ReadDataAck"); - fhStsMessType->GetYaxis()->SetBinLabel(1 + stsxyter::BetaMessType::Ack, "Ack"); -*/ - fHM->Add(sHistName.Data(), fhStsMessTypePerDpb); - if( server ) server->Register("/StsRaw", fhStsMessTypePerDpb ); - - sHistName = "hStsSysMessTypePerDpb"; - title = "Nb of system message of each type for each DPB; DPB; System Type"; - fhStsSysMessTypePerDpb = new TH2I(sHistName, title, fuNrOfDpbs, 0, fuNrOfDpbs, 17, 0., 17.); -/* - hSysMessType->GetYaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_START, "DAQ START"); - hSysMessType->GetYaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_FINISH, "DAQ FINISH"); - hSysMessType->GetYaxis()->SetBinLabel(1 + 16, "GET4 Hack 32B"); -*/ - fHM->Add(sHistName.Data(), fhStsSysMessTypePerDpb); - if( server ) server->Register("/StsRaw", fhStsSysMessTypePerDpb ); - - sHistName = "hStsMessageTypePerElink"; - title = "Nb of message of each type for each eLink; eLink; Type"; - fhStsMessTypePerElink = new TH2I(sHistName, title, fuNrOfDpbs * fuNbElinksPerDpb, 0, fuNrOfDpbs * fuNbElinksPerDpb, 5, 0., 5.); - fhStsMessTypePerElink->GetYaxis()->SetBinLabel( 1, "Dummy"); - fhStsMessTypePerElink->GetYaxis()->SetBinLabel( 2, "Hit"); - fhStsMessTypePerElink->GetYaxis()->SetBinLabel( 3, "TsMsb"); - fhStsMessTypePerElink->GetYaxis()->SetBinLabel( 4, "ReadDataAck"); - fhStsMessTypePerElink->GetYaxis()->SetBinLabel( 5, "Ack"); -/* *** Missing int + MessType OP!!!! **** - fhStsMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::BetaMessType::Dummy, "Dummy"); - fhStsMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::BetaMessType::Hit, "Hit"); - fhStsMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::BetaMessType::TsMsb, "TsMsb"); - fhStsMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::BetaMessType::ReadDataAck, "ReadDataAck"); - fhStsMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::BetaMessType::Ack, "Ack"); -*/ - fHM->Add(sHistName.Data(), fhStsMessTypePerElink); - if( server ) server->Register("/StsRaw", fhStsMessTypePerElink ); - - sHistName = "hStsSysMessTypePerElink"; - title = "Nb of system message of each type for each eLink; eLink; System Type"; - fhStsSysMessTypePerElink = new TH2I(sHistName, title, fuNrOfDpbs * fuNbElinksPerDpb, 0, fuNrOfDpbs * fuNbElinksPerDpb, 17, 0., 17.); -/* - fhStsSysMessTypePerElink->GetYaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_START, "DAQ START"); - fhStsSysMessTypePerElink->GetYaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_FINISH, "DAQ FINISH"); - fhStsSysMessTypePerElink->GetYaxis()->SetBinLabel(1 + 16, "GET4 Hack 32B"); -*/ - fHM->Add(sHistName.Data(), fhStsSysMessTypePerElink); - if( server ) server->Register("/StsRaw", fhStsSysMessTypePerElink ); - - // Number of rate bins = - // 9 for the sub-unit decade - // + 9 for each unit of each decade * 10 for the subdecade range - // + 1 for the closing bin top edge - const Int_t iNbDecadesRate = 9; - const Int_t iNbStepsDecade = 9; - const Int_t iNbSubStepsInStep = 10; - const Int_t iNbBinsRate = iNbStepsDecade - + iNbStepsDecade * iNbSubStepsInStep * iNbDecadesRate - + 1; - Double_t dBinsRate[iNbBinsRate]; - // First fill sub-unit decade - for( Int_t iSubU = 0; iSubU < iNbStepsDecade; iSubU ++ ) - dBinsRate[ iSubU ] = 0.1 * ( 1 + iSubU ); - std::cout << std::endl; - // Then fill the main decades - Double_t dSubstepSize = 1.0 / iNbSubStepsInStep; - for( Int_t iDecade = 0; iDecade < iNbDecadesRate; iDecade ++) - { - Double_t dBase = std::pow( 10, iDecade ); - Int_t iDecadeIdx = iNbStepsDecade - + iDecade * iNbStepsDecade * iNbSubStepsInStep; - for( Int_t iStep = 0; iStep < iNbStepsDecade; iStep++ ) - { - Int_t iStepIdx = iDecadeIdx + iStep * iNbSubStepsInStep; - for( Int_t iSubStep = 0; iSubStep < iNbSubStepsInStep; iSubStep++ ) - { - dBinsRate[ iStepIdx + iSubStep ] = dBase * (1 + iStep) - + dBase * dSubstepSize * iSubStep; - } // for( Int_t iSubStep = 0; iSubStep < iNbSubStepsInStep; iSubStep++ ) - } // for( Int_t iStep = 0; iStep < iNbStepsDecade; iStep++ ) - } // for( Int_t iDecade = 0; iDecade < iNbDecadesRate; iDecade ++) - dBinsRate[ iNbBinsRate - 1 ] = std::pow( 10, iNbDecadesRate ); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - // Channel counts - sHistName = Form( "hStsChanCounts_%03u", uXyterIdx ); - title = Form( "Hits Count per channel, StsXyter #%03u; Channel; Hits []", uXyterIdx ); - fhStsChanCounts.push_back( new TH1I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - fHM->Add(sHistName.Data(), fhStsChanCounts[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhStsChanCounts[ uXyterIdx ] ); - - // Raw Adc Distribution - sHistName = Form( "hStsChanRawAdc_%03u", uXyterIdx ); - title = Form( "Raw Adc distribution per channel, StsXyter #%03u; Channel []; Adc []; Hits []", uXyterIdx ); - fhStsChanRawAdc.push_back( new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - stsxyter::kuBetaHitNbAdcBins, -0.5, stsxyter::kuBetaHitNbAdcBins -0.5 ) ); - fHM->Add(sHistName.Data(), fhStsChanRawAdc[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhStsChanRawAdc[ uXyterIdx ] ); - - // Raw Adc Distribution profile - sHistName = Form( "hStsChanRawAdcProfc_%03u", uXyterIdx ); - title = Form( "Raw Adc prodile per channel, StsXyter #%03u; Channel []; Adc []", uXyterIdx ); - fhStsChanRawAdcProf.push_back( new TProfile(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - fHM->Add(sHistName.Data(), fhStsChanRawAdcProf[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhStsChanRawAdcProf[ uXyterIdx ] ); - - // Raw Ts Distribution - sHistName = Form( "hStsChanRawTs_%03u", uXyterIdx ); - title = Form( "Raw Timestamp distribution per channel, StsXyter #%03u; Channel []; Ts []; Hits []", uXyterIdx ); - fhStsChanRawTs.push_back( new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - stsxyter::kuBetaHitNbTsBins, -0.5, stsxyter::kuBetaHitNbTsBins -0.5 ) ); - fHM->Add(sHistName.Data(), fhStsChanRawTs[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhStsChanRawTs[ uXyterIdx ] ); - - // Missed event flag - sHistName = Form( "hStsChanMissEvt_%03u", uXyterIdx ); - title = Form( "Missed Event flags per channel, StsXyter #%03u; Channel []; Miss Evt []; Hits []", uXyterIdx ); - fhStsChanMissEvt.push_back( new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - 2, -0.5, 1.5 ) ); - fHM->Add(sHistName.Data(), fhStsChanMissEvt[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhStsChanMissEvt[ uXyterIdx ] ); - - // MSB correction from Overlap difference - sHistName = Form( "hStsChanOverDiff_%03u", uXyterIdx ); - title = Form( "MSB correction from Overlap difference, per channel, StsXyter #%03u; Channel []; Over. diff. [MSB corr bin]; Hits []", uXyterIdx ); - fhStsChanOverDiff.push_back( new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - stsxyter::kuBetaHitNbOverBins, -0.5, stsxyter::kuBetaHitNbOverBins - 0.5 ) ); - fHM->Add(sHistName.Data(), fhStsChanOverDiff[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhStsChanOverDiff[ uXyterIdx ] ); - - // Hit rates evo per channel - sHistName = Form( "hStsChanRateEvo_%03u", uXyterIdx ); - title = Form( "Hits per second & channel in StsXyter #%03u; Time [s]; Channel []; Hits []", uXyterIdx ); - fhStsChanHitRateEvo.push_back( new TH2I( sHistName, title, - 1800, 0, 1800, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - fHM->Add(sHistName.Data(), fhStsChanHitRateEvo[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhStsChanHitRateEvo[ uXyterIdx ] ); - - // Hit rates evo per StsXyter - sHistName = Form( "hStsXyterRateEvo_%03u", uXyterIdx ); - title = Form( "Hits per second in StsXyter #%03u; Time [s]; Hits []", uXyterIdx ); - fhStsXyterRateEvo.push_back( new TH1I(sHistName, title, 1800, 0, 1800 ) ); - fHM->Add(sHistName.Data(), fhStsXyterRateEvo[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhStsXyterRateEvo[ uXyterIdx ] ); - - // Hit rates evo per channel, 1 minute bins, 24h - sHistName = Form( "hStsChanRateEvoLong_%03u", uXyterIdx ); - title = Form( "Hits per second & channel in StsXyter #%03u; Time [min]; Channel []; Hits []", uXyterIdx ); - fhStsChanHitRateEvoLong.push_back( new TH2D( sHistName, title, - 1440, 0, 1440, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - fHM->Add(sHistName.Data(), fhStsChanHitRateEvoLong[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhStsChanHitRateEvoLong[ uXyterIdx ] ); - - // Hit rates evo per StsXyter, 1 minute bins, 24h - sHistName = Form( "hStsXyterRateEvoLong_%03u", uXyterIdx ); - title = Form( "Hits per second in StsXyter #%03u; Time [min]; Hits []", uXyterIdx ); - fhStsXyterRateEvoLong.push_back( new TH1D(sHistName, title, 1440, 0, 1440 ) ); - fHM->Add(sHistName.Data(), fhStsXyterRateEvoLong[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhStsXyterRateEvoLong[ uXyterIdx ] ); - - // Hit distance in time for each channel - if( fbChanHitDtEna ) - { - sHistName = Form( "hStsChanHitDt_%03u", uXyterIdx ); - title = Form( "Time diff between hits on same channel in StsXyter #%03u; t_hit - t_prev [ns]; Channel []; Hits []", uXyterIdx ); - fhStsChanHitDt.push_back( new TH2I( sHistName, title, - iNbBinsRate - 1, dBinsRate, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - fHM->Add(sHistName.Data(), fhStsChanHitDt[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhStsChanHitDt[ uXyterIdx ] ); - sHistName = Form( "hStsChanHitDtNeg_%03u", uXyterIdx ); - title = Form( "Time diff between hits on same channel in StsXyter #%03u; t_prev - t_hit [ns]; Channel []; Hits []", uXyterIdx ); - fhStsChanHitDtNeg.push_back( new TH2I( sHistName, title, - iNbBinsRate - 1, dBinsRate, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - fHM->Add(sHistName.Data(), fhStsChanHitDtNeg[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhStsChanHitDtNeg[ uXyterIdx ] ); - - } // if( fbChanHitDtEna ) - - sHistName = Form( "hStsChanHitsPerMs_%03u", uXyterIdx ); - title = Form( "Nb of hits per channel in each MS in StsXyter #%03u; Nb Hits in MS []; Channel []; MS []", uXyterIdx ); - fhStsChanHitsPerMs.push_back( new TH2I( sHistName, title, - 100, -0.5, 99.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - fHM->Add(sHistName.Data(), fhStsChanHitsPerMs[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhStsChanHitsPerMs[ uXyterIdx ] ); - - sHistName = Form( "hStsChanSameMs_%03u", uXyterIdx ); - title = Form( "Nb of MS with hits in both channels in StsXyter #%03u; Channel A []; Channel B []; Coinc. MS []", uXyterIdx ); - fhStsChanSameMs.push_back( new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - fHM->Add(sHistName.Data(), fhStsChanHitsPerMs[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhStsChanSameMs[ uXyterIdx ] ); - - sHistName = Form( "pStsChanSameMsTimeDiff_%03u", uXyterIdx ); - title = Form( "Mean Time difference of channels when hits in same MS in StsXyter #%03u; Channel A []; Channel B []; Mean time diff [bins]", uXyterIdx ); - fpStsChanSameMsTimeDiff.push_back( new TProfile2D( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - - sHistName = Form( "hStsChanSameMsTimeDiff_%03u", uXyterIdx ); - title = Form( "Mean Time difference of channels when hits in same MS in StsXyter #%03u; Channel A []; Channel B []; Mean time diff [bins]", uXyterIdx ); - fhStsChanSameMsTimeDiff.push_back( new TH2D( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - fHM->Add(sHistName.Data(), fhStsChanSameMsTimeDiff[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhStsChanSameMsTimeDiff[ uXyterIdx ] ); - - if( kTRUE == fbLongHistoEnable ) - { - UInt_t uAlignedLimit = fuLongHistoNbSeconds - (fuLongHistoNbSeconds % fuLongHistoBinSizeSec); - fuLongHistoBinNb = uAlignedLimit / fuLongHistoBinSizeSec; - - sHistName = Form( "hFebRateEvoLong_%03u", uXyterIdx ); - title = Form( "Mean rate VS run time in same MS in StsXyter #%03u; Time in run [s]; Rate [1/s]", uXyterIdx ); - fhFebRateEvoLong.push_back( new TH1D( sHistName, title, - fuLongHistoBinNb, -0.5, uAlignedLimit - 0.5) ); - fHM->Add(sHistName.Data(), fhFebRateEvoLong[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhFebRateEvoLong[ uXyterIdx ] ); - - sHistName = Form( "hFebChRateEvoLong_%03u", uXyterIdx ); - title = Form( "Mean rate per channel VS run time in StsXyter #%03u; Time in run [s]; Channel []; Rare [1/s]", uXyterIdx ); - fhFebChRateEvoLong.push_back( new TH2D( sHistName, title, - fuLongHistoBinNb, -0.5, uAlignedLimit - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - fHM->Add(sHistName.Data(), fhFebChRateEvoLong[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhFebChRateEvoLong[ uXyterIdx ] ); - } // if( kTRUE == fbLongHistoEnable ) - - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - - if( kTRUE == fbPulserTimeDiffOn ) - { - UInt_t uNbPulserChans = fvuPulserAsic.size(); - UInt_t uNbBinEvo = 32768 + 1; - Double_t dMaxEdgeEvo = stsxyter::kdBetaClockCycleNs - * static_cast< Double_t >( uNbBinEvo ) / 2.0; - Double_t dMinEdgeEvo = dMaxEdgeEvo * -1.0; - fhStsPulserChansSortedTimeDiff.resize( uNbPulserChans - 1 ); - fhStsPulserChansSortedTimeDiffEvo.resize( uNbPulserChans - 1 ); - for( UInt_t uChA = 0; uChA < uNbPulserChans - 1; ++uChA ) - { - fhStsPulserChansSortedTimeDiff[ uChA ].resize( uNbPulserChans ); - fhStsPulserChansSortedTimeDiffEvo[ uChA ].resize( uNbPulserChans ); - - for( UInt_t uChB = uChA + 1; uChB < uNbPulserChans; ++uChB ) - { - sHistName = Form( "hStsPulserChansTimeDiff_%02u_%03u_%02u_%03u", - fvuPulserAsic[uChA], fvuPulserChan[uChA], - fvuPulserAsic[uChB], fvuPulserChan[uChB] ); - title = Form( "Time diff for hits in same MS from ASIC %02d ch %03d and ASIC %02d ch %03d; tB - tA [ns]; Counts", - fvuPulserAsic[uChA], fvuPulserChan[uChA], - fvuPulserAsic[uChB], fvuPulserChan[uChB] ); -// TH1 * pHist = new TH1I(sHistName, title, 16385, -51203.125, 51203.125); - TH1 * pHist = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - fHM->Add(sHistName.Data(), pHist); - if( server ) server->Register("/StsRaw", pHist ); - fhStsPulserChansTimeDiff.push_back( pHist ); - - sHistName = Form( "hStsPulserChansSortedTimeDiff_%02u_%03u_%02u_%03u", - fvuPulserAsic[uChA], fvuPulserChan[uChA], - fvuPulserAsic[uChB], fvuPulserChan[uChB] ); - title = Form( "Time diff for hits in same MS from ASIC %02d ch %03d and ASIC %02d ch %03d; tB - tA [ns]; Counts", - fvuPulserAsic[uChA], fvuPulserChan[uChA], - fvuPulserAsic[uChB], fvuPulserChan[uChB] ); -// TH1 * pHist = new TH1I(sHistName, title, 16385, -51203.125, 51203.125); - pHist = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - fHM->Add(sHistName.Data(), pHist); - if( server ) server->Register("/StsRaw", pHist ); - fhStsPulserChansSortedTimeDiff[ uChA ][ uChB ] = pHist; - - if( kTRUE == fbLongHistoEnable ) - { - UInt_t uAlignedLimit = fuLongHistoNbSeconds - (fuLongHistoNbSeconds % fuLongHistoBinSizeSec); - sHistName = Form( "hStsPulserChansTimeDiffEvo_%02u_%03u_%02u_%03u", - fvuPulserAsic[uChA], fvuPulserChan[uChA], - fvuPulserAsic[uChB], fvuPulserChan[uChB] ); - title = Form( "Time diff for hits in same MS from ASIC %02d ch %03d and ASIC %02d ch %03d, vs time in run; Time in run [min]; tB - tA [ns]; Counts", - fvuPulserAsic[uChA], fvuPulserChan[uChA], - fvuPulserAsic[uChB], fvuPulserChan[uChB] ); - TH2 * pHistEvo = new TH2I( sHistName, title, - fuLongHistoBinNb, -0.5, uAlignedLimit - 0.5, - uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - fHM->Add(sHistName.Data(), pHistEvo); - if( server ) server->Register("/StsRaw", pHistEvo ); - fhStsPulserChansTimeDiffEvo.push_back( pHistEvo ); - - sHistName = Form( "hStsPulserChansSortedTimeDiffEvo_%02u_%03u_%02u_%03u", - fvuPulserAsic[uChA], fvuPulserChan[uChA], - fvuPulserAsic[uChB], fvuPulserChan[uChB] ); - title = Form( "Time diff for hits in same MS from ASIC %02d ch %03d and ASIC %02d ch %03d, vs time in run; Time in run [min]; tB - tA [ns]; Counts", - fvuPulserAsic[uChA], fvuPulserChan[uChA], - fvuPulserAsic[uChB], fvuPulserChan[uChB] ); - pHistEvo = new TH2I( sHistName, title, - fuLongHistoBinNb, -0.5, uAlignedLimit - 0.5, - uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - fHM->Add(sHistName.Data(), pHistEvo); - if( server ) server->Register("/StsRaw", pHistEvo ); - fhStsPulserChansSortedTimeDiffEvo[ uChA ][ uChB ] = pHistEvo; - } // if( kTRUE == fbLongHistoEnable ) - } // for( UInt_t uChB = uChA + 1; uChB < uNbPulserChans; ++uChB ) - } // for( UInt_t uChA = 0; uChA < uNbPulserChans - 1; ++uChA ) - } // if( kTRUE == fbPulserTimeDiffOn ) - - // Distribution of the TS_MSB per StsXyter - sHistName = "hStsAsicTsMsb"; - title = "Raw Timestamp Msb distribution per StsXyter; Ts MSB []; StsXyter []; Hits []"; - fhStsAsicTsMsb = new TH2I( sHistName, title, stsxyter::kuBetaTsMsbNbTsBins, -0.5, stsxyter::kuBetaTsMsbNbTsBins - 0.5, - fuNbStsXyters, -0.5, fuNbStsXyters - 0.5 ); - fHM->Add(sHistName.Data(), fhStsAsicTsMsb ); - if( server ) server->Register("/StsRaw", fhStsAsicTsMsb ); - - // Nb values in agreement in TS MSB messages, per StsXyter - sHistName = "hStsAsicTsMsbMaj"; - title = "Nb values in agreement in TS MSB messages, per StsXyter; StsXyter []; Majority? []; Mess. []"; - fhStsAsicTsMsbMaj = new TH2I( sHistName, title, fuNbStsXyters, -0.5, fuNbStsXyters - 0.5, - 3, 0.5, 3.5); - fHM->Add(sHistName.Data(), fhStsAsicTsMsbMaj ); - if( server ) server->Register("/StsRaw", fhStsAsicTsMsbMaj ); - - for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - { - // CRC good or bad in TS MSB messages, per (DPB, eLink) pairs - sHistName = Form( "hStsElinkTsMsbCrc_d%02u", uDpb ); - title = Form( "CRC test in TS MSB, per eLink, DPB #%02u; eLink []; CRC Match? []; Mess. []", uDpb); - fhStsElinkTsMsbCrc.push_back( new TH2I( sHistName, title, fuNbElinksPerDpb, -0.5, fuNbElinksPerDpb - 0.5, - 2, -0.5, 1.5) ); - fHM->Add(sHistName.Data(), fhStsElinkTsMsbCrc[ uDpb ] ); - if( server ) server->Register("/StsRaw", fhStsElinkTsMsbCrc[ uDpb ] ); - - // Nb values in agreement in TS MSB messages, per (DPB, eLink) pairs - sHistName = Form( "hStsElinkTsMsbMaj_d%02u", uDpb ); - title = Form( "Nb values in agreement in TS MSB, per eLink, DPB #%02u; eLink []; Majority? []; Mess. []", uDpb); - fhStsElinkTsMsbMaj.push_back( new TH2I( sHistName, title, fuNbElinksPerDpb, -0.5, fuNbElinksPerDpb - 0.5, - 3, 0.5, 3.5) ); - fHM->Add(sHistName.Data(), fhStsElinkTsMsbMaj[ uDpb ] ); - if( server ) server->Register("/StsRaw", fhStsElinkTsMsbMaj[ uDpb ] ); - } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - - // Miscroslice properties histos - for( Int_t component = 0; component < kiMaxNbFlibLinks; component ++ ) - { - fhMsSz[ component ] = NULL; - fhMsSzTime[ component ] = NULL; - } // for( Int_t component = 0; component < kiMaxNbFlibLinks; component ++ ) - - // Online histo browser commands - if( server ) - { - server->RegisterCommand("/Reset_All_Sts", "bCern2017ResetStsHistosBeta=kTRUE"); - server->RegisterCommand("/Write_All_Sts", "bCern2017WriteStsHistosBeta=kTRUE"); - - server->Restrict("/Reset_All_Sts", "allow=admin"); - server->Restrict("/Write_All_Sts", "allow=admin"); - } // if( server ) - - /** Create summary Canvases for CERN 2017 **/ - Double_t w = 10; - Double_t h = 10; - - // Summary per StsXyter - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - TCanvas* cStsSumm = new TCanvas( Form("cStsSum_%03u", uXyterIdx ), - Form("Summary plots for StsXyter %03u", uXyterIdx ), - w, h); - cStsSumm->Divide( 2, 2 ); - - cStsSumm->cd(1); - gPad->SetLogy(); - fhStsChanCounts[ uXyterIdx ]->Draw(); - - cStsSumm->cd(2); - gPad->SetLogz(); - fhStsChanRawAdc[ uXyterIdx ]->Draw( "colz" ); - - cStsSumm->cd(3); - gPad->SetLogz(); - fhStsChanRawTs[ uXyterIdx ]->Draw( "colz" ); - - cStsSumm->cd(4); - gPad->SetLogy(); - fhStsXyterRateEvo[ uXyterIdx ]->Draw(); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - - // Pulser testing - if( kTRUE == fbPulserTimeDiffOn ) - { - UInt_t uNbPulserPlots = fhStsPulserChansTimeDiff.size(); - TCanvas* cStsPulser = new TCanvas( "cStsPulser" , "Summary plots for StsXyter pulser testing", - w, h); - cStsPulser->Divide( 2, uNbPulserPlots/2 + uNbPulserPlots%2 ); - - for( UInt_t uPulserPlot = 0; uPulserPlot < uNbPulserPlots; ++uPulserPlot) - { - cStsPulser->cd( 1 + uPulserPlot ); - gPad->SetLogy(); - gPad->SetGridx(); - gPad->SetGridy(); - fhStsPulserChansTimeDiff[ uPulserPlot ]->Draw(); - gStyle->SetOptStat("emruo"); - fhStsPulserChansTimeDiff[ uPulserPlot ]->SetStats(1); - } // for( UInt_t uPulserPlot = 0; uPulserPlot < uNbPulserPlots; ++uPulserPlot) - - if( kTRUE == fbLongHistoEnable ) - { - TCanvas* cStsPulserEvo = new TCanvas( "cStsPulserEvo" , "Summary plots for StsXyter pulser testing vs time", - w, h); - cStsPulserEvo->Divide( 2, uNbPulserPlots/2 + uNbPulserPlots%2 ); - - for( UInt_t uPulserPlot = 0; uPulserPlot < uNbPulserPlots; ++uPulserPlot) - { - cStsPulserEvo->cd( 1 + uPulserPlot ); - gPad->SetGridx(); - gPad->SetGridy(); - fhStsPulserChansTimeDiffEvo[ uPulserPlot ]->Draw( "colz" ); - gStyle->SetOptStat("emruo"); - fhStsPulserChansTimeDiffEvo[ uPulserPlot ]->SetStats(1); - } // for( UInt_t uPulserPlot = 0; uPulserPlot < uNbPulserPlots; ++uPulserPlot) - } // if( kTRUE == fbLongHistoEnable ) - } // if( kTRUE == fbPulserTimeDiffOn ) - - // Long duration rate monitoring - if( kTRUE == fbLongHistoEnable ) - { - TCanvas* cStsLongRate = new TCanvas( "cStsLongRate" , "Long duration rate plots for StsXyter", - w, h); - cStsLongRate->Divide( 2, fuNbStsXyters ); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - cStsLongRate->cd( 1 + 2 * uXyterIdx ); - gPad->SetLogy(); - gPad->SetGridx(); - gPad->SetGridy(); - fhFebRateEvoLong[ uXyterIdx ]->Draw( "hist" ); - - cStsLongRate->cd( 2 + 2 * uXyterIdx ); - gPad->SetLogz(); - gPad->SetGridx(); - gPad->SetGridy(); - fhFebChRateEvoLong[ uXyterIdx ]->Draw( "colz" ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - } // if( kTRUE == fbLongHistoEnable ) - -/* - Int_t iNbPadsPerDpb = fuNbElinksPerDpb/2 + fuNbElinksPerDpb%2; - TCanvas* cMuchChCounts = new TCanvas("cMuchChCounts", "MUCH Channels counts", w, h); - cMuchChCounts->Divide( fNrOfNdpbs/2 + fNrOfNdpbs%2, fNrOfFebsPerNdpb ); - - TCanvas* cMuchFebRate = new TCanvas("cMuchFebRate", "MUCH FEB rate", w, h); - cMuchFebRate->Divide( fNrOfNdpbs/2 + fNrOfNdpbs%2, fNrOfFebsPerNdpb ); - - TH1* histPnt = NULL; - for( Int_t dpbId = 0; dpbId < fNrOfNdpbs; dpbId++) - {// looping on all the nDPBS IDs - if( dpbId < fUnpackPar->GetNrOfnDpbsModA() ) - { - sNdpbTag = Form("%04X", fUnpackPar->GetNdpbIdA(dpbId) ); - } // if( dpbId < fUnpackPar->GetNrOfnDpbsModA() ) - else - { - sNdpbTag = Form("%04X", fUnpackPar->GetNdpbIdB(dpbId - fNrOfNdpbsA) ); - } // else of if( dpbId < fUnpackPar->GetNrOfnDpbsModA() ) - - for( Int_t febId = 0; febId < fNrOfFebsPerNdpb; febId++) - {// looping on all the FEB IDs - cMuchChCounts->cd( 1 + dpbId * iNbPadsPerDpb + febId/2 ); - gPad->SetLogy(); - sHistName = Form("Chan_Counts_Much_n%s_f%1u", sNdpbTag.Data(), febId); - histPnt = fHM->H1(sHistName.Data()); - - if( 0 == febId%2 ) - { - histPnt->SetLineColor( kRed ); // => Change color for 1st of the 2/pad! - histPnt->Draw(); - } // if( 0 == febId%2 ) - else - { - histPnt->SetLineColor( kBlue ); // => Change color for 1nd of the 2/pad! - histPnt->Draw("same"); - } // if( 0 == febId%2 ) - - cMuchFebRate->cd( 1 + dpbId * iNbPadsPerDpb + febId/2 ); - gPad->SetLogy(); - sHistName = Form("FebRate_n%s_f%1u", sNdpbTag.Data(), febId); - histPnt = fHM->H1(sHistName.Data()); - - if( 0 == febId%2 ) - { - histPnt->SetLineColor( kRed ); // => Change color for 1st of the 2/pad! - histPnt->Draw(); - } // if( 0 == febId%2 ) - else - { - histPnt->SetLineColor( kBlue ); // => Change color for 1nd of the 2/pad! - histPnt->Draw("same"); - } // if( 0 == febId%2 ) - } // for( Int_t febId = 0; febId < fNrOfFebsPerNdpb; febId++) - } // for( Int_t dpbId = 0; dpbId < fNrOfNdpbs; dpbId++) -*/ - - /** Recovers/Create Ms Size Canvase for CERN 2016 **/ - // Try to recover canvas in case it was created already by another monitor - // If not existing, create it - fcMsSizeAll = dynamic_cast<TCanvas *>( gROOT->FindObject( "cMsSizeAll" ) ); - if( NULL == fcMsSizeAll ) - { - fcMsSizeAll = new TCanvas("cMsSizeAll", "Evolution of MS size in last 300 s", w, h); - fcMsSizeAll->Divide( 4, 4 ); - LOG(info) << "Created MS size canvas in STS monitor"; - } // if( NULL == fcMsSizeAll ) - else LOG(info) << "Recovered MS size canvas in STS monitor"; - - /*****************************/ -} - -Bool_t CbmCern2017MonitorBetaSts::DoUnpack(const fles::Timeslice& ts, size_t component) -{ - THttpServer* server = FairRunOnline::Instance()->GetHttpServer(); - - if( bCern2017ResetStsHistosBeta ) - { - ResetAllHistos(); - bCern2017ResetStsHistosBeta = kFALSE; - } // if( bCern2017ResetStsHistosBeta ) - if( bCern2017WriteStsHistosBeta ) - { - SaveAllHistos( "data/StsHistos.root" ); - bCern2017WriteStsHistosBeta = kFALSE; - } // if( bCern2017WriteStsHistosBeta ) - - LOG(debug) << "Timeslice contains " << ts.num_microslices(component) - << "microslices."; - - if( component < kiMaxNbFlibLinks ) - if( NULL == fhMsSz[ component ] ) - { - TString sMsSzName = Form("MsSz_link_%02lu", component); - TString sMsSzTitle = Form("Size of MS for nDPB of link %02lu; Ms Size [bytes]", component); - fhMsSz[ component ] = new TH1F( sMsSzName.Data(), sMsSzTitle.Data(), 160000, 0., 20000. ); - fHM->Add(sMsSzName.Data(), fhMsSz[ component ] ); - if (server) server->Register("/FlibRaw", fhMsSz[ component ] ); - sMsSzName = Form("MsSzTime_link_%02lu", component); - sMsSzTitle = Form("Size of MS vs time for gDPB of link %02lu; Time[s] ; Ms Size [bytes]", component); - fhMsSzTime[ component ] = new TProfile( sMsSzName.Data(), sMsSzTitle.Data(), 15000, 0., 300. ); - fHM->Add( sMsSzName.Data(), fhMsSzTime[ component ] ); - if (server) server->Register("/FlibRaw", fhMsSzTime[ component ] ); - if( NULL != fcMsSizeAll ) - { - fcMsSizeAll->cd( 1 + component ); - gPad->SetLogy(); - fhMsSzTime[ component ]->Draw("hist le0"); - } // if( NULL != fcMsSizeAll ) - LOG(info) << "Added MS size histo for component: " << component - << " (DPB)"; - } // if( NULL == fhMsSz[ component ] ) - -// Int_t messageType = -111; - // Loop over microslices - size_t numCompMsInTs = ts.num_microslices(component); - - if( fuPulserMaxNbMicroslices < numCompMsInTs ) - { - fuPulserMaxNbMicroslices = numCompMsInTs; - - fvuChanNbHitsInMs.resize( fuNbStsXyters ); - fvdChanLastHitTimeInMs.resize( fuNbStsXyters ); - fvusChanLastHitAdcInMs.resize( fuNbStsXyters ); - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fvuChanNbHitsInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvdChanLastHitTimeInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvusChanLastHitAdcInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - { - fvuChanNbHitsInMs[ uXyterIdx ][ uChan ].resize( fuPulserMaxNbMicroslices ); - fvdChanLastHitTimeInMs[ uXyterIdx ][ uChan ].resize( fuPulserMaxNbMicroslices ); - fvusChanLastHitAdcInMs[ uXyterIdx ][ uChan ].resize( fuPulserMaxNbMicroslices ); - for( UInt_t uMsIdx = 0; uMsIdx < fuPulserMaxNbMicroslices; ++uMsIdx ) - { - fvuChanNbHitsInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = 0; - fvdChanLastHitTimeInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = -1.0; - fvusChanLastHitAdcInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = 0; - } // for( UInt_t uMsIdx = 0; uMsIdx < fuPulserMaxNbMicroslices; ++uMsIdx ) - } // for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - LOG(info) << "CbmCern2017MonitorBetaSts::DoUnpack => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs.size() << " VS " << fuNbStsXyters; - LOG(info) << "CbmCern2017MonitorBetaSts::DoUnpack => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs[ 0 ].size() << " VS " << fuNbChanPerAsic; - LOG(info) << "CbmCern2017MonitorBetaSts::DoUnpack => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs[ 0 ][ 0 ].size() << " VS " << fuPulserMaxNbMicroslices; - } // if( fuPulserMaxNbMicroslices < numCompMsInTs ) - - for( size_t m = 0; m < numCompMsInTs; ++m ) - { - // Ignore overlap ms if number defined by user - if( numCompMsInTs - fuOverlapMsNb <= m ) - continue; - - auto msDescriptor = ts.descriptor(component, m); - fuCurrentEquipmentId = msDescriptor.eq_id; - const uint8_t* msContent = reinterpret_cast<const uint8_t*>(ts.content(component, m)); - - uint32_t size = msDescriptor.size; - LOG(debug) << "Microslice: " << msDescriptor.idx - << " from EqId " << std::hex << fuCurrentEquipmentId << std::dec - << " has size: " << size; - - fuCurrDpbId = static_cast< uint32_t >( fuCurrentEquipmentId & 0xFFFF ); - fuCurrDpbIdx = fDpbIdIndexMap[ fuCurrDpbId ]; - - if( component < kiMaxNbFlibLinks ) - { - if( fdStartTimeMsSz < 0 ) - fdStartTimeMsSz = (1e-9) * static_cast<double>(msDescriptor.idx); - fhMsSz[ component ]->Fill( size ); - fhMsSzTime[ component ]->Fill( (1e-9) * static_cast<double>( msDescriptor.idx) - fdStartTimeMsSz, size); - } // if( component < kiMaxNbFlibLinks ) - - if( 0 == component && 0 == ( ( msDescriptor.idx / 1000000000 ) % 10 ) - && 0 == ( ( msDescriptor.idx / 100000 ) ) %50000 ) - { - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fhStsChanSameMsTimeDiff[uXyterIdx]->Reset(); - TH2* tempProj = fpStsChanSameMsTimeDiff[uXyterIdx]->ProjectionXY( ); - fhStsChanSameMsTimeDiff[uXyterIdx]->Add( tempProj ); - delete tempProj; -/* - for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - for( UInt_t uChanB = uChan + 1; uChanB < fuNbChanPerAsic; ++uChanB ) - if( 0 < fpStsChanSameMsTimeDiff[uXyterIdx]->GetBinEntries( fpStsChanSameMsTimeDiff[uXyterIdx]->GetBin( uChan, uChanB ) ) ) - { - LOG(debug) << "Microslice Index = " << (msDescriptor.idx / 1000000000) - << "s, ASIC " << uXyterIdx << " Chan " << uChan << " VS " << uChanB - << " Entries " << fpStsChanSameMsTimeDiff[uXyterIdx]->GetBinEntries( fpStsChanSameMsTimeDiff[uXyterIdx]->GetBin( uChan, uChanB ) ) - << " Mean time diff "<< fpStsChanSameMsTimeDiff[uXyterIdx]->GetBinContent( uChan, uChanB ) - << " Error " << fpStsChanSameMsTimeDiff[uXyterIdx]->GetBinError( uChan, uChanB ); - } // if( 0 < fpStsChanSameMsTimeDiff[uXyterIdx]->GetBinEntries( uChan, uChanB ) ) -*/ - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - } // if( 0 == ( ( msDescriptor.idx / 1e-9 ) % 10 ) ) - - // If not integer number of message in input buffer, print warning/error - if( 0 != (size % kuBytesPerMessage) ) - LOG(error) << "The input microslice buffer does NOT " - << "contain only complete nDPB messages!"; - - // Compute the number of complete messages in the input microslice buffer - uint32_t uNbMessages = (size - (size % kuBytesPerMessage) ) - / kuBytesPerMessage; - - // Prepare variables for the loop on contents - const uint32_t* pInBuff = reinterpret_cast<const uint32_t*>( msContent ); - for( uint32_t uIdx = 0; uIdx < uNbMessages; ++uIdx ) - { - // Fill message - uint32_t ulData = static_cast<uint32_t>(pInBuff[uIdx]); - - stsxyter::BetaMessage mess( static_cast< uint32_t >( ulData & 0xFFFFFFFF ) ); - - // Print message if requested - if( fbPrintMessages ) - mess.PrintMess( std::cout, fPrintMessCtrl ); - - // Extract the eLink and Asic indices - UShort_t usElinkIdx = mess.GetLinkIndex(); - if( fuNbElinksPerDpb <= usElinkIdx ) - { - LOG(fatal) << "CbmCern2017MonitorBetaSts::DoUnpack => " - << "eLink index out of bounds!"; - } // if( fuNbElinksPerDpb <= usElinkIdx ) - UInt_t uAsicIdx = fvuElinkToAsic[fuCurrDpbIdx][usElinkIdx]; - - stsxyter::BetaMessType typeMess = mess.GetMessType(); - fmMsgCounter[ typeMess ] ++; - fhStsMessType->Fill( static_cast< uint16_t > (typeMess) ); - fhStsMessTypePerDpb->Fill( fuCurrDpbIdx, static_cast< uint16_t > (typeMess) ); - fhStsMessTypePerElink->Fill( fuCurrDpbIdx * fuNbElinksPerDpb + usElinkIdx, - static_cast< uint16_t > (typeMess) ); - - switch( typeMess ) - { - case stsxyter::BetaMessType::Hit : - { - FillHitInfo( mess, usElinkIdx, uAsicIdx, m ); - break; - } // case stsxyter::BetaMessType::Hit : - case stsxyter::BetaMessType::TsMsb : - { - FillTsMsbInfo( mess, usElinkIdx, uAsicIdx ); - break; - } // case stsxyter::BetaMessType::TsMsb : - case stsxyter::BetaMessType::Dummy : - { - if( kTRUE == fbBetaFormat ) - { - // In beta data format, a dummy hit indicates a TS overflow => TS_MSB increase by 1 - fvuCurrentTsMsb[fuCurrDpbIdx][0] ++; - fvuElinkLastTsHit[fuCurrDpbIdx][0] = 0; - } // if( kTRUE == fbBetaFormat ) - break; - } // case stsxyter::BetaMessType::Dummy / ReadDataAck / Ack : - default: - { - LOG(fatal) << "CbmCern2017MonitorBetaSts::DoUnpack => " - << "Unknown message type, should never happen, stopping here!"; - } - } // switch( mess.GetMessType() ) - } // for( uint32_t uIdx = 0; uIdx < uNbMessages; ++uIdx ) - } // for( size_t m = 0; m < numCompMsInTs; ++m ) - - - // End of TS, check if stuff to do with the hits inside each MS - // Usefull for low rate pulser tests - // Need to do it only when last DPB is processed, as they are done one by one - if( fuCurrDpbIdx == fuNrOfDpbs - 1 ) - { - for( UInt_t uMsIdx = 0; uMsIdx < fuPulserMaxNbMicroslices; ++uMsIdx ) - { -/* - if( kTRUE == fbPulserTimeDiffOn ) - { - UInt_t uNbPulserChans = fvuPulserAsic.size(); - UInt_t uHistoIdx = 0; - for( UInt_t uChA = 0; uChA < uNbPulserChans; ++uChA ) - for( UInt_t uChB = uChA + 1; uChB < uNbPulserChans; ++uChB ) - { - if( 0 < fvuChanNbHitsInMs[ fvuPulserAsic[uChA] ][ fvuPulserChan[uChA] ][ uMsIdx ] && - 0 < fvuChanNbHitsInMs[ fvuPulserAsic[uChB] ][ fvuPulserChan[uChB] ][ uMsIdx ] ) - { - Double_t dTimeDiff = fvdChanLastHitTimeInMs[ fvuPulserAsic[uChB] ][ fvuPulserChan[uChB] ][ uMsIdx ] - - fvdChanLastHitTimeInMs[ fvuPulserAsic[uChA] ][ fvuPulserChan[uChA] ][ uMsIdx ]; - Short_t sAdcDiff = static_cast< Short_t >( fvusChanLastHitAdcInMs[ fvuPulserAsic[uChB] ][ fvuPulserChan[uChB] ][ uMsIdx ] ) - - static_cast< Short_t >( fvusChanLastHitAdcInMs[ fvuPulserAsic[uChA] ][ fvuPulserChan[uChA] ][ uMsIdx ] ); - - if( dTimeDiff < -102406.25 || 102406.25 < dTimeDiff ) - LOG(info) << "CbmCern2017MonitorBetaSts::DoUnpack =>" - << " ASIC A" << fvuPulserAsic[uChA] << " chan A " << fvuPulserChan[uChA] - << " tA " << fvdChanLastHitTimeInMs[ fvuPulserAsic[uChA] ][ fvuPulserChan[uChA] ][ uMsIdx ] - << " ASIC B" << fvuPulserAsic[uChB] << " chan B " << fvuPulserChan[uChB] - << " tB " << fvdChanLastHitTimeInMs[ fvuPulserAsic[uChB] ][ fvuPulserChan[uChB] ][ uMsIdx ] - << " dt " << dTimeDiff; - - if( dTimeDiff < -102406.25 ) - dTimeDiff += 102406.25; - else if( 102406.25 < dTimeDiff ) - dTimeDiff -= 102406.25; - - fhStsPulserChansTimeDiff[ uHistoIdx ]->Fill( dTimeDiff ); - } // Both pulser channels got data in last MS - uHistoIdx ++; - } // Loop on channel pairs - } // if( kTRUE == fbPulserTimeDiffOn ) -*/ - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - { - fhStsChanHitsPerMs[uXyterIdx]->Fill( fvuChanNbHitsInMs[ uXyterIdx ][ uChan ][ uMsIdx ], uChan ); - - // Coincidences between - if( fvuChanNbHitsInMs[ uXyterIdx ][ uChan ][ uMsIdx ] ) - for( UInt_t uChanB = uChan + 1; uChanB < fuNbChanPerAsic; ++uChanB ) - if( fvuChanNbHitsInMs[ uXyterIdx ][ uChanB ][ uMsIdx ] ) - { - fhStsChanSameMs[ uXyterIdx ]->Fill( uChan, uChanB ); - Double_t dTimeDiff = fvdChanLastHitTimeInMs[ uXyterIdx ][ uChanB ][ uMsIdx ] - - fvdChanLastHitTimeInMs[ uXyterIdx ][ uChan ][ uMsIdx ]; - - fpStsChanSameMsTimeDiff[ uXyterIdx ]->Fill( uChan, uChanB, dTimeDiff ); - } // if( fvuChanNbHitsInMs[ uXyterIdx ][ uChanB ] ) - -/* - // Pulser test: Coincidences between different FEEs (maybe on different DPBs) - for( UInt_t uXyterIdxB = uXyterIdx; uXyterIdxB < fuNbStsXyters; ++uXyterIdxB ) - { - for( UInt_t uChanB = 0; uChanB < fuNbChanPerAsic; ++uChanB ) - { - } // for( UInt_t uChanB = 0; uChanB < fuNbChanPerAsic; ++uChanB ) - } // for( UInt_t uXyterIdxB = uXyterIdx; uXyterIdxB < fuNbStsXyters; ++uXyterIdxB ) -*/ - // Ok to reset as we only compare to channels with higher indices (or channels in ASICs with higher indices) - fvuChanNbHitsInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = 0; - fvdChanLastHitTimeInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = -1.0; - fvusChanLastHitAdcInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = 0; - } // for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - } // for( UInt_t uMsIdx = 0; uMsIdx < fuPulserMaxNbMicroslices; ++uMsIdx ) - - if( kTRUE == fbPulserTimeDiffOn ) - { - UInt_t uNbPulserChans = fvuPulserAsic.size(); - UInt_t uHistoIdx = 0; - std::chrono::steady_clock::time_point tNow = std::chrono::steady_clock::now(); - Double_t dUnixTimeInRun = std::chrono::duration_cast< std::chrono::seconds >(tNow - ftStartTimeUnix).count(); - for( UInt_t uChA = 0; uChA < uNbPulserChans; ++uChA ) - for( UInt_t uChB = uChA + 1; uChB < uNbPulserChans; ++uChB ) - { - if( 0 < fvmChanHitsInTs[ fvuPulserAsic[uChA] ][ fvuPulserChan[uChA] ].size() && - 0 < fvmChanHitsInTs[ fvuPulserAsic[uChB] ][ fvuPulserChan[uChB] ].size() ) - { - std::multiset< stsxyter::BetaHit >::iterator itClosestHitB = fvmChanHitsInTs[ fvuPulserAsic[uChB] ][ fvuPulserChan[uChB] ].begin(); - for( std::multiset< stsxyter::BetaHit >::iterator itHitA = fvmChanHitsInTs[ fvuPulserAsic[uChA] ][ fvuPulserChan[uChA] ].begin(); - itHitA != fvmChanHitsInTs[ fvuPulserAsic[uChA] ][ fvuPulserChan[uChA] ].end(); - ++itHitA ) - { - Double_t dClosestTimeDiff = 1e12; - - for( std::multiset< stsxyter::BetaHit >::iterator itHitB = itClosestHitB ; - itHitB != fvmChanHitsInTs[ fvuPulserAsic[uChB] ][ fvuPulserChan[uChB] ].end(); - ++itHitB ) - { - Double_t dTimeDiff = static_cast< Double_t >( (*itHitB).GetTs() ) - - static_cast< Double_t >( (*itHitA).GetTs() ); - - if( TMath::Abs( dTimeDiff ) < TMath::Abs( dClosestTimeDiff ) ) - { - dClosestTimeDiff = dTimeDiff; - itClosestHitB = itHitB; - } // if( TMath::Abs( dTimeDiff ) < TMath::Abs( dClosestTimeDiff ) ) - } // Loop on hits in channel B, starting from match to previous channel A hit - - Double_t dTimeDiff = dClosestTimeDiff * stsxyter::kdBetaClockCycleNs; -/* - Short_t sAdcDiff = static_cast< Short_t >( (*itClosestHitB).GetAdc() ) - - static_cast< Short_t >( (*itHitA).GetAdc() ); -*/ - fhStsPulserChansTimeDiff[ uHistoIdx ]->Fill( dTimeDiff ); - if( fbLongHistoEnable ) - { -// Double_t dTimeSinceStartSec = ( (*itHitA).GetTs() * stsxyter::kdBetaClockCycleNs - fdStartTime )* 1e-9; - fhStsPulserChansTimeDiffEvo[ uHistoIdx ]->Fill( dUnixTimeInRun, dTimeDiff ); - } // if( fbLongHistoEnable ) - } // Loop on hits in channel A - } // Both pulser channels got data in last TS - uHistoIdx ++; - } // Loop on channel pairs - - // Clean up the buffers now that we used the data - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - fvmChanHitsInTs[ uXyterIdx ][ uChan ].clear(); - } // if( kTRUE == fbPulserTimeDiffOn ) - - // Time differences plotting using the fully time sorted hits - if( 0 < fvmHitsInTs.size() ) - { - ULong64_t ulLastHitTime = ( *( fvmHitsInTs.rbegin() ) ).GetTs(); - std::multiset< stsxyter::BetaHit >::iterator it; - UInt_t uNbPulserChans = fvuPulserAsic.size(); - std::chrono::steady_clock::time_point tNow = std::chrono::steady_clock::now(); - Double_t dUnixTimeInRun = std::chrono::duration_cast< std::chrono::seconds >(tNow - ftStartTimeUnix).count(); - for( it = fvmHitsInTs.begin(); - it != fvmHitsInTs.end() && (*it).GetTs() < ulLastHitTime - 320; // 32 * 3.125 ns = 1000 ns - ++it ) - { - UShort_t usAsicIdx = (*it).GetAsic(); - UShort_t usChanIdx = (*it).GetChan(); - fvulChanLastSortedHitTime[ usAsicIdx ][ usChanIdx ] = (*it).GetTs(); - - for( UInt_t uChA = 0; uChA < uNbPulserChans; ++uChA ) - if( fvuPulserAsic[uChA] == usAsicIdx && fvuPulserChan[uChA] == usChanIdx ) - { - for( UInt_t uChB = 0; uChB < uNbPulserChans; ++uChB ) - { - if( uChB == uChA ) - continue; - - if( 0 == fvulChanLastSortedHitTime[ fvuPulserAsic[uChB] ][ fvuPulserChan[uChB] ] ) - continue; - - Double_t dTimeDiff; - if( uChA < uChB ) - dTimeDiff = fvulChanLastSortedHitTime[ fvuPulserAsic[uChB] ][ fvuPulserChan[uChB] ] - - fvulChanLastSortedHitTime[ usAsicIdx ][ usChanIdx ]; - else dTimeDiff = fvulChanLastSortedHitTime[ usAsicIdx ][ usChanIdx ] - - fvulChanLastSortedHitTime[ fvuPulserAsic[uChB] ][ fvuPulserChan[uChB] ]; - dTimeDiff *= stsxyter::kdBetaClockCycleNs; - - if( uChA < uChB ) - { - fhStsPulserChansSortedTimeDiff[ uChA ][ uChB ]->Fill( dTimeDiff ); - if( fbLongHistoEnable ) - fhStsPulserChansSortedTimeDiffEvo[ uChA ][ uChB ]->Fill( dUnixTimeInRun, dTimeDiff ); - } // if( uChA < uChB ) - else - { - fhStsPulserChansSortedTimeDiff[ uChB ][ uChA ]->Fill( dTimeDiff ); - if( fbLongHistoEnable ) - fhStsPulserChansSortedTimeDiffEvo[ uChB ][ uChA ]->Fill( dUnixTimeInRun, dTimeDiff ); - } // else of if( uChA < uChB ) - } // for( UInt_t uChB = 0; uChB < uNbPulserChans; ++uChB ) - - break; // leaves the loop - } // if( fvuPulserAsic[uChA] == usAsicIdx && fvuPulserChan[uChA] == usChanIdx ) - } // loop on hits untils hits within 100 ns of last one or last one itself are reached - - // Remove all hits which were already used - fvmHitsInTs.erase( fvmHitsInTs.begin(), it ); - } // if( 0 < fvmHitsInTs.size() ) - } // if( fuCurrDpbIdx == fuNrOfDpbs - 1 ) - - if( kTRUE == fbBetaFormat && 0 == ts.index() % 1000 && fuCurrDpbIdx == fuNrOfDpbs - 1) - { - for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - LOG(info) << "eDPB " << std::setw(2) << uDpb - << " eLink " << std::setw(2) << 0 - << " current TS cycle counter is " << std::setw(12) << fvuCurrentTsMsb[uDpb][0] - << "\n" - << " current sorted buffer size is " << fvmHitsInTs.size() - << " First hit TS is " << ( *( fvmHitsInTs.begin() ) ).GetTs() - << " Last hit TS is " << ( *( fvmHitsInTs.rbegin() ) ).GetTs(); - } // if( kTRUE == fbBetaFormat && 0 == ts.descriptor.index % 10000 ) - - return kTRUE; -} - -void CbmCern2017MonitorBetaSts::FillHitInfo( stsxyter::BetaMessage mess, const UShort_t & usElinkIdx, const UInt_t & uAsicIdx, const UInt_t & uMsIdx ) -{ - UShort_t usChan = mess.GetHitChannel(); - UShort_t usRawAdc = mess.GetHitAdc(); -// UShort_t usFullTs = mess.GetHitTimeFull(); - UShort_t usTsOver = mess.GetHitTimeOver(); - UShort_t usRawTs = mess.GetHitTime(); - - if( 0xFFFF == uAsicIdx ) - return; - - fhStsChanCounts[ uAsicIdx ]->Fill( usChan ); - fhStsChanRawAdc[ uAsicIdx ]->Fill( usChan, usRawAdc ); - fhStsChanRawAdcProf[ uAsicIdx ]->Fill( usChan, usRawAdc ); - fhStsChanRawTs[ uAsicIdx ]->Fill( usChan, usRawTs ); - fhStsChanMissEvt[ uAsicIdx ]->Fill( usChan, mess.IsHitMissedEvts() ); - - // Compute the Full time stamp -/* - if( fvuCurrentTsMsbOver[fuCurrDpbIdx][usElinkIdx] == usTsOver ) - { - // Hit stamped in same TsMsb as sent to eLink - // Need TS cycle counter as otherwise period of only 102.400 us!!! - fvulChanLastHitTime[ uAsicIdx ][ usChan ] = usRawTs - + stsxyter::kuBetaHitNbTsBins * static_cast<ULong64_t>( fvuCurrentTsMsb[fuCurrDpbIdx][usElinkIdx] ) - + stsxyter::kuTsCycleNbBins * static_cast<ULong64_t>( fvuCurrentTsMsbCycle[fuCurrDpbIdx][usElinkIdx] ); - } // if( (fvuCurrentTsMsb[fuCurrDpbIdx][usElinkIdx] & stsxyter::kusBetaMaskTsMsbOver) == usTsOver ) - else if( (fvuCurrentTsMsb[fuCurrDpbIdx][usElinkIdx] & stsxyter::kusBetaMaskTsMsbOver) - == ((usTsOver + 1) % (stsxyter::kusBetaMaskTsMsbOver + 1)) ) - { - // Hit stamped in previous TsMsb compared to last Ts_MSB on same eLink - // Need TS cycle counter as otherwise period of only 102.400 us!!! - fvulChanLastHitTime[ uAsicIdx ][ usChan ] = usRawTs; - if( 0 == fvuCurrentTsMsb[fuCurrDpbIdx][usElinkIdx] ) - { - if( 0 == fvuCurrentTsMsbCycle[fuCurrDpbIdx][usElinkIdx] ) - { - // TO BE CHECKED - LOG(warning) << "CbmCern2017MonitorBetaSts::FillHitInfo => " - << "Ignore Hit as coming from TS_MSB before system start!"; - return; - } // if( 0 == fvuCurrentTsMsbCycle[fuCurrDpbIdx][usElinkIdx] ) - - fvulChanLastHitTime[ uAsicIdx ][ usChan ] += - stsxyter::kuBetaHitNbTsBins * static_cast<ULong64_t>( fvuCurrentTsMsb[fuCurrDpbIdx][usElinkIdx] - + stsxyter::kuTsCycleNbBins - 1 ) - + stsxyter::kuTsCycleNbBins * static_cast<ULong64_t>( fvuCurrentTsMsbCycle[fuCurrDpbIdx][usElinkIdx] - 1 ); - } // if( 0 == fvuCurrentTsMsb[fuCurrDpbIdx][usElinkIdx] ) - else fvulChanLastHitTime[ uAsicIdx ][ usChan ] += - stsxyter::kuBetaHitNbTsBins * static_cast<ULong64_t>( fvuCurrentTsMsb[fuCurrDpbIdx][usElinkIdx] - 1 ) - + stsxyter::kuTsCycleNbBins * static_cast<ULong64_t>( fvuCurrentTsMsbCycle[fuCurrDpbIdx][usElinkIdx] ); - - } // else if overlap bit from hit are exactly 1 unit behind the one from last Ts_Msb - else - { - // Overlap is neither matching nor 1 less than bits from TS_MSB - // Should not happen if I understood properly how the ASIC behaves ?!? - LOG(fatal) << "CbmCern2017MonitorBetaSts::FillHitInfo => " - << "TS overlap bits from hit not fitting the ones from last TS MSB on this eLink! \n" - << "Hit Overlap: 0x" << std::hex << usTsOver << " Full TS: 0x" << usFullTs << "\n" - << "MSB Overlap: 0x" << (fvuCurrentTsMsb[fuCurrDpbIdx][usElinkIdx] & stsxyter::kusBetaMaskTsMsbOver) - << " Ts Msb: 0x" << fvuCurrentTsMsb[fuCurrDpbIdx][usElinkIdx] << "\n" - << "Other eLinks: \n"; - for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink ) - LOG(fatal) << std::setw(3) << std::dec << uElink << " => " - << std::hex << "0x" << (fvuCurrentTsMsb[fuCurrDpbIdx][uElink] & stsxyter::kusBetaMaskTsMsbOver) - << " => " << "0x" << (fvuCurrentTsMsb[fuCurrDpbIdx][uElink] & stsxyter::kusBetaMaskTsMsbOver) << "\n"; - LOG(fatal) << std::dec; - return; - } // else of overlap checks -*/ - // Use TS w/o overlap bits as they will anyway come from the TS_MSB - fvulChanLastHitTime[ uAsicIdx ][ usChan ] = usRawTs; - - if( kFALSE == fbBetaFormat ) - { - // Overlap need to be used to correct the TS_MSB - // Formula used here gives the following correction table - /* - * | TS MSB Over - * | 0 | 1 | 2 | 3 - * _____|___|___|___|___ - * H 0 | 0 | 1 | 2 | 3 - * I ___|___|___|___|___ - * T 1 | 3 | 0 | 1 | 2 - * ____|___|___|___|___ - * O 2 | 2 | 3 | 0 | 1 - * V ___|___|___|___|___ - * E 3 | 1 | 2 | 3 | 0 - * R | | | | - */ - UInt_t uTsMsbCorr = ( stsxyter::kuBetaHitNbOverBins + fvuCurrentTsMsbOver[fuCurrDpbIdx][usElinkIdx] - usTsOver ) - % stsxyter::kuBetaHitNbOverBins; - fhStsChanOverDiff[ uAsicIdx ]->Fill( usChan, uTsMsbCorr ); - - // Need TS cycle counter as otherwise period of only 102.400 us!!! - // => Check if we need also a TS MSB cycle correction - if( fvuCurrentTsMsb[fuCurrDpbIdx][usElinkIdx] < uTsMsbCorr ) - { - if( 0 == fvuCurrentTsMsbCycle[fuCurrDpbIdx][usElinkIdx] ) - { - // TO BE CHECKED - LOG(warning) << "CbmCern2017MonitorBetaSts::FillHitInfo => " - << "Ignore Hit as coming from TS_MSB before system start!"; - return; - } // if( 0 == fvuCurrentTsMsbCycle[fuCurrDpbIdx][usElinkIdx] ) - - fvulChanLastHitTime[ uAsicIdx ][ usChan ] += - stsxyter::kuBetaHitNbTsBins * static_cast<ULong64_t>( fvuCurrentTsMsb[fuCurrDpbIdx][usElinkIdx] - + stsxyter::kuBetaHitNbTsBins - uTsMsbCorr ) - // + stsxyter::kuTsCycleNbBins * static_cast<ULong64_t>( fvuCurrentTsMsbCycle[fuCurrDpbIdx][usElinkIdx] - 1 ) - ; - } // if( fvuCurrentTsMsb[fuCurrDpbIdx][usElinkIdx] < uTsMsbCorr ) - else fvulChanLastHitTime[ uAsicIdx ][ usChan ] += - stsxyter::kuBetaHitNbTsBins * static_cast<ULong64_t>( fvuCurrentTsMsb[fuCurrDpbIdx][usElinkIdx] - uTsMsbCorr ) - // + stsxyter::kuTsCycleNbBins * static_cast<ULong64_t>( fvuCurrentTsMsbCycle[fuCurrDpbIdx][usElinkIdx] ) - ; - } // if( kFALSE == fbBetaFormat ) - else - { -// if( usRawTs < fvuElinkLastTsHit[fuCurrDpbIdx][usElinkIdx] ) -// fvuCurrentTsMsb[fuCurrDpbIdx][usElinkIdx]++; - - fvulChanLastHitTime[ uAsicIdx ][ usChan ] += - static_cast<ULong64_t>( stsxyter::kuBetaHitNbTsBins ) - * static_cast<ULong64_t>( fvuCurrentTsMsb[fuCurrDpbIdx][0]); - - fvuElinkLastTsHit[fuCurrDpbIdx][usElinkIdx] = usRawTs; - } // else of if( kFALSE == fbBetaFormat ) - - // Convert the Hit time in bins to Hit time in ns - Double_t dHitTimeNs = fvulChanLastHitTime[ uAsicIdx ][ usChan ] * stsxyter::kdBetaClockCycleNs; - - - // If needed fill the hit interval plots - if( fbChanHitDtEna ) - { - Double_t dDeltaT = dHitTimeNs - fvdChanLastHitTime[ uAsicIdx ][ usChan ]; - if( 0 == dDeltaT ) - fhStsChanHitDtNeg[ uAsicIdx ]->Fill( 1, usChan ); - else if( 0 < dDeltaT ) - fhStsChanHitDt[ uAsicIdx ]->Fill( dDeltaT, usChan ); - else fhStsChanHitDtNeg[ uAsicIdx ]->Fill( -dDeltaT, usChan ); - } // if( fbChanHitDtEna ) - - // Store new value of Hit time in ns - fvdChanLastHitTime[ uAsicIdx ][ usChan ] = fvulChanLastHitTime[ uAsicIdx ][ usChan ]; - - // Pulser and MS - fvuChanNbHitsInMs[ uAsicIdx ][ usChan ][ uMsIdx ] ++; - fvdChanLastHitTimeInMs[ uAsicIdx ][ usChan ][ uMsIdx ] = dHitTimeNs; - fvusChanLastHitAdcInMs[ uAsicIdx ][ usChan ][ uMsIdx ] = usRawAdc; - fvmChanHitsInTs[ uAsicIdx ][ usChan ].insert( stsxyter::BetaHit( fvulChanLastHitTime[ uAsicIdx ][ usChan ], usRawAdc ) ); - fvmHitsInTs.insert( stsxyter::BetaHit( fvulChanLastHitTime[ uAsicIdx ][ usChan ], usRawAdc, uAsicIdx, usChan ) ); - - // Check Starting point of histos with time as X axis - if( -1 == fdStartTime ) - fdStartTime = fvdChanLastHitTime[ uAsicIdx ][ usChan ]; - - // Fill histos with time as X axis - Double_t dTimeSinceStartSec = (fvdChanLastHitTime[ uAsicIdx ][ usChan ] - fdStartTime)* 1e-9; - Double_t dTimeSinceStartMin = dTimeSinceStartSec / 60.0; - fhStsChanHitRateEvo[ uAsicIdx ]->Fill( dTimeSinceStartSec , usChan ); - fhStsXyterRateEvo[ uAsicIdx ]->Fill( dTimeSinceStartSec ); - fhStsChanHitRateEvoLong[ uAsicIdx ]->Fill( dTimeSinceStartMin, usChan, 1.0/60.0 ); - fhStsXyterRateEvoLong[ uAsicIdx ]->Fill( dTimeSinceStartMin, 1.0/60.0 ); - - if( kTRUE == fbLongHistoEnable ) - { - std::chrono::steady_clock::time_point tNow = std::chrono::steady_clock::now(); - Double_t dUnixTimeInRun = std::chrono::duration_cast< std::chrono::seconds >(tNow - ftStartTimeUnix).count(); - fhFebRateEvoLong[ uAsicIdx ]->Fill( dUnixTimeInRun , 1.0 / fuLongHistoBinSizeSec ); - fhFebChRateEvoLong[ uAsicIdx ]->Fill( dUnixTimeInRun , usChan, 1.0 / fuLongHistoBinSizeSec ); - } // if( kTRUE == fbLongHistoEnable ) - -} - -void CbmCern2017MonitorBetaSts::FillTsMsbInfo( stsxyter::BetaMessage mess, const UShort_t & usElinkIdx, const UInt_t & uAsicIdx ) -{ - UShort_t usVal = mess.GetTsMsbVal(); - - // Update Status counters - if( usVal < fvuCurrentTsMsb[fuCurrDpbIdx][usElinkIdx] ) - fvuCurrentTsMsbCycle[fuCurrDpbIdx][usElinkIdx] ++; - fvuCurrentTsMsb[fuCurrDpbIdx][usElinkIdx] = usVal; - - fhStsAsicTsMsb->Fill( fvuCurrentTsMsb[fuCurrDpbIdx][usElinkIdx], uAsicIdx ); - fhStsAsicTsMsbMaj->Fill( uAsicIdx, 3 ); - fhStsElinkTsMsbMaj[fuCurrDpbIdx]->Fill( usElinkIdx, 3 ); - - // Update the overlap bits for this eLink - fvuCurrentTsMsbOver[fuCurrDpbIdx][usElinkIdx] = fvuCurrentTsMsb[fuCurrDpbIdx][usElinkIdx] - & stsxyter::kusBetaMaskTsMsbOver; -} - -void CbmCern2017MonitorBetaSts::Reset() -{ -} - -void CbmCern2017MonitorBetaSts::Finish() -{ - - LOG(info) << "-------------------------------------"; - LOG(info) << "CbmCern2017MonitorBetaSts statistics are "; - LOG(info) << " Hit messages: " << fmMsgCounter[ stsxyter::BetaMessType::Hit ] << "\n" - << " Ts MSB messages: " << fmMsgCounter[ stsxyter::BetaMessType::TsMsb ] << "\n" - << " Dummy messages: " << fmMsgCounter[ stsxyter::BetaMessType::Dummy ]; - - LOG(info) << "-------------------------------------"; - - SaveAllHistos(); - -} - - -void CbmCern2017MonitorBetaSts::FillOutput(boost::any) -{ -} - -void CbmCern2017MonitorBetaSts::SaveAllHistos( TString sFileName ) -{ - TDirectory * oldDir = NULL; - TFile * histoFile = NULL; - if( "" != sFileName ) - { - // Store current directory position to allow restore later - oldDir = gDirectory; - // open separate histo file in recreate mode - histoFile = new TFile( sFileName , "RECREATE"); - histoFile->cd(); - } // if( "" != sFileName ) - - gDirectory->mkdir("Sts_Raw"); - gDirectory->cd("Sts_Raw"); - - fhStsMessType->Write(); - fhStsSysMessType->Write(); - fhStsMessTypePerDpb->Write(); - fhStsSysMessTypePerDpb->Write(); - fhStsMessTypePerElink->Write(); - fhStsSysMessTypePerElink->Write(); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fhStsChanCounts[ uXyterIdx ]->Write(); - fhStsChanRawAdc[ uXyterIdx ]->Write(); - fhStsChanRawAdcProf[ uXyterIdx ]->Write(); - fhStsChanRawTs[ uXyterIdx ]->Write(); - fhStsChanMissEvt[ uXyterIdx ]->Write(); - fhStsChanOverDiff[ uXyterIdx ]->Write(); - fhStsChanHitRateEvo[ uXyterIdx ]->Write(); - fhStsXyterRateEvo[ uXyterIdx ]->Write(); - fhStsChanHitRateEvoLong[ uXyterIdx ]->Write(); - fhStsXyterRateEvoLong[ uXyterIdx ]->Write(); - if( fbChanHitDtEna ) - { - fhStsChanHitDt[ uXyterIdx ]->Write(); - fhStsChanHitDtNeg[ uXyterIdx ]->Write(); - } // if( fbChanHitDtEna ) - fhStsChanHitsPerMs[ uXyterIdx ]->Write(); - fhStsChanSameMs[ uXyterIdx ]->Write(); - fpStsChanSameMsTimeDiff[ uXyterIdx ]->Write(); - fhStsChanSameMsTimeDiff[ uXyterIdx ]->Write(); - if( kTRUE == fbLongHistoEnable ) - { - fhFebRateEvoLong[ uXyterIdx ]->Write(); - fhFebChRateEvoLong[ uXyterIdx ]->Write(); - } // if( kTRUE == fbLongHistoEnable ) - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - - if( kTRUE == fbPulserTimeDiffOn ) - { - UInt_t uNbPulserChans = fvuPulserAsic.size(); - UInt_t uHistoIdx = 0; - for( UInt_t uChA = 0; uChA < uNbPulserChans - 1; ++uChA ) - for( UInt_t uChB = uChA + 1; uChB < uNbPulserChans; ++uChB ) - { - fhStsPulserChansTimeDiff[ uHistoIdx ]->Write(); - if( fbLongHistoEnable ) - fhStsPulserChansTimeDiffEvo[ uHistoIdx ]->Write(); - uHistoIdx ++; - - fhStsPulserChansSortedTimeDiff[ uChA ][ uChB ]->Write(); - fhStsPulserChansSortedTimeDiffEvo[ uChA ][ uChB ]->Write(); - } // Loop on channel pairs - } // if( kTRUE == fbPulserTimeDiffOn ) - - fhStsAsicTsMsb->Write(); - fhStsAsicTsMsbMaj->Write(); - - for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - { - fhStsElinkTsMsbCrc[ uDpb ]->Write(); - fhStsElinkTsMsbMaj[ uDpb ]->Write(); - } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - - gDirectory->cd(".."); - - // Flib Histos - gDirectory->mkdir("Flib_Raw"); - gDirectory->cd("Flib_Raw"); - for( UInt_t uLinks = 0; uLinks < kiMaxNbFlibLinks; uLinks ++) - { - TString sMsSzName = Form("MsSz_link_%02u", uLinks); - if( fHM->Exists(sMsSzName.Data() ) ) - fHM->H1( sMsSzName.Data() )->Write(); - - sMsSzName = Form("MsSzTime_link_%02u", uLinks); - if( fHM->Exists(sMsSzName.Data() ) ) - fHM->P1( sMsSzName.Data() )->Write(); - } // for( UInt_t uLinks = 0; uLinks < 16; uLinks ++) - gDirectory->cd(".."); - - if( "" != sFileName ) - { - // Restore original directory position - histoFile->Close(); - oldDir->cd(); - } // if( "" != sFileName ) - -} -void CbmCern2017MonitorBetaSts::ResetAllHistos() -{ - LOG(info) << "Reseting all STS histograms."; - - fhStsMessType->Reset(); - fhStsSysMessType->Reset(); - fhStsMessTypePerDpb->Reset(); - fhStsSysMessTypePerDpb->Reset(); - fhStsMessTypePerElink->Reset(); - fhStsSysMessTypePerElink->Reset(); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fhStsChanCounts[ uXyterIdx ]->Reset(); - fhStsChanRawAdc[ uXyterIdx ]->Reset(); - fhStsChanRawAdcProf[ uXyterIdx ]->Reset(); - fhStsChanRawTs[ uXyterIdx ]->Reset(); - fhStsChanMissEvt[ uXyterIdx ]->Reset(); - fhStsChanOverDiff[ uXyterIdx ]->Reset(); - fhStsChanHitRateEvo[ uXyterIdx ]->Reset(); - fhStsXyterRateEvo[ uXyterIdx ]->Reset(); - fhStsChanHitRateEvoLong[ uXyterIdx ]->Reset(); - fhStsXyterRateEvoLong[ uXyterIdx ]->Reset(); - if( fbChanHitDtEna ) - { - fhStsChanHitDt[ uXyterIdx ]->Reset(); - fhStsChanHitDtNeg[ uXyterIdx ]->Reset(); - } // if( fbChanHitDtEna ) - fhStsChanHitsPerMs[ uXyterIdx ]->Reset(); - fhStsChanSameMs[ uXyterIdx ]->Reset(); - fpStsChanSameMsTimeDiff[ uXyterIdx ]->Reset(); - fhStsChanSameMsTimeDiff[ uXyterIdx ]->Reset(); - if( kTRUE == fbLongHistoEnable ) - { - ftStartTimeUnix = std::chrono::steady_clock::now(); - fhFebRateEvoLong[ uXyterIdx ]->Reset(); - fhFebChRateEvoLong[ uXyterIdx ]->Reset(); - } // if( kTRUE == fbLongHistoEnable ) - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - - if( kTRUE == fbPulserTimeDiffOn ) - { - UInt_t uNbPulserChans = fvuPulserAsic.size(); - UInt_t uHistoIdx = 0; - for( UInt_t uChA = 0; uChA < uNbPulserChans - 1; ++uChA ) - for( UInt_t uChB = uChA + 1; uChB < uNbPulserChans; ++uChB ) - { - fhStsPulserChansTimeDiff[ uHistoIdx ]->Reset(); - if( fbLongHistoEnable ) - fhStsPulserChansTimeDiffEvo[ uHistoIdx ]->Reset(); - uHistoIdx ++; - - fhStsPulserChansSortedTimeDiff[ uChA ][ uChB ]->Write(); - fhStsPulserChansSortedTimeDiffEvo[ uChA ][ uChB ]->Write(); - } // Loop on channel pairs - } // if( kTRUE == fbPulserTimeDiffOn ) - - fhStsAsicTsMsb->Reset(); - fhStsAsicTsMsbMaj->Reset(); - - for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - { - fhStsElinkTsMsbCrc[ uDpb ]->Reset(); - fhStsElinkTsMsbMaj[ uDpb ]->Reset(); - } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - - for( UInt_t uLinks = 0; uLinks < kiMaxNbFlibLinks; ++uLinks ) - { - TString sMsSzName = Form("MsSz_link_%02u", uLinks); - if( fHM->Exists(sMsSzName.Data() ) ) - fHM->H1( sMsSzName.Data() )->Reset(); - - sMsSzName = Form("MsSzTime_link_%02u", uLinks); - if( fHM->Exists(sMsSzName.Data() ) ) - fHM->P1( sMsSzName.Data() )->Reset(); - } // for( UInt_t uLinks = 0; uLinks < kiMaxNbFlibLinks; ++uLinks ) - - fdStartTime = -1; - fdStartTimeMsSz = -1; -} - -void CbmCern2017MonitorBetaSts::SetRunStart( Int_t dateIn, Int_t timeIn, Int_t iBinSize ) -{ - TDatime * fRunStartDateTime = new TDatime( dateIn, timeIn); - fiRunStartDateTimeSec = fRunStartDateTime->Convert(); - fiBinSizeDatePlots = iBinSize; - - LOG(info) << "Assigned new MUCH Run Start Date-Time: " << fRunStartDateTime->AsString(); -} -void CbmCern2017MonitorBetaSts::SetPulserChannels( UInt_t uAsicA, UInt_t uChanA, UInt_t uAsicB, UInt_t uChanB, - UInt_t uAsicC, UInt_t uChanC, UInt_t uAsicD, UInt_t uChanD, - UInt_t uMaxNbMicroslices ) -{ -/* - THttpServer* server = FairRunOnline::Instance()->GetHttpServer(); - TString sHistName{""}; - TString title{""}; -*/ - fuPulserMaxNbMicroslices = uMaxNbMicroslices; - - UInt_t uNbChans = 4; - - fvuPulserAsic.resize( uNbChans ); - fvuPulserChan.resize( uNbChans ); - fvuPulserAsic[0] = uAsicA; - fvuPulserChan[0] = uChanA; - fvuPulserAsic[1] = uAsicB; - fvuPulserChan[1] = uChanB; - fvuPulserAsic[2] = uAsicC; - fvuPulserChan[2] = uChanC; - fvuPulserAsic[3] = uAsicD; - fvuPulserChan[3] = uChanD; -/* - // Remove old histos - if( kTRUE == fbPulserTimeDiffOn ) - { - for( Int_t iIdx = 0; iIdx < fhStsPulserChansTimeDiff.size(); ++iIdx ) - delete fhStsPulserChansTimeDiff[ iIdx ]; - } // if( kTRUE == fbPulserTimeDiffOn ) - fhStsPulserChansTimeDiff.clear(); - - for( UInt_t uChA = 0; uChA < uNbChans; ++uChA ) - for( UInt_t uChB = uChA + 1; uChB < uNbChans; ++uChB ) - { - sHistName = Form( "hStsPulserTimeDiff_%02u_%03u_%02u_%03u", - fvuPulserAsic[uChA], fvuPulserChan[uChA], - fvuPulserAsic[uChB], fvuPulserChan[uChB] ); - title = "Time diff for hits in same MS from ASIC %02d ch %03d and ASIC %02d ch %03d; tB - tA [ns]; Counts"; - TH1 * pHist = new TH1I(sHistName, title, 16385, -51203.125, 51203.125); - - fHM->Add(sHistName.Data(), pHist); - if( server ) server->Register("/StsRaw", pHist ); - fhStsPulserChansTimeDiff.push_back( pHist ); - } // Loop on pairs of channels -*/ - fbPulserTimeDiffOn = kTRUE; -} - -void CbmCern2017MonitorBetaSts::SetLongDurationLimits( UInt_t uDurationSeconds, UInt_t uBinSize ) -{ - fbLongHistoEnable = kTRUE; - fuLongHistoNbSeconds = uDurationSeconds; - fuLongHistoBinSizeSec = uBinSize; -} - -ClassImp(CbmCern2017MonitorBetaSts) diff --git a/beamtime/cern2017/unpacker/CbmCern2017MonitorBetaSts.h b/beamtime/cern2017/unpacker/CbmCern2017MonitorBetaSts.h deleted file mode 100644 index 76a7d2df0598b46c1185a090575503933e64b606..0000000000000000000000000000000000000000 --- a/beamtime/cern2017/unpacker/CbmCern2017MonitorBetaSts.h +++ /dev/null @@ -1,188 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmCern2017MonitorBetaSts ----- -// ----- Created 25/07/17 by P.-A. Loizeau ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CBMCERN2017MONITORBETASTS_H -#define CBMCERN2017MONITORBETASTS_H - -#include "Timeslice.hpp" - -// Data -#include "StsXyterBetaMessage.h" -#include "StsXyterBetaHit.h" - -// CbmRoot -#include "CbmTSUnpack.h" -#include "CbmHistManager.h" - -// C++11 -#include <chrono> - -// C/C++ -#include <vector> -#include <set> -#include <map> - -class CbmCern2017UnpackParSts; - -class CbmCern2017MonitorBetaSts: public CbmTSUnpack -{ -public: - - CbmCern2017MonitorBetaSts(); - virtual ~CbmCern2017MonitorBetaSts(); - - virtual Bool_t Init(); - - virtual Bool_t DoUnpack(const fles::Timeslice& ts, size_t component); - - virtual void Reset(); - - virtual void Finish(); - - void SetParContainers(); - - Bool_t InitContainers(); - - Bool_t ReInitContainers(); - - void FillOutput(boost::any); - - void SetRunStart( Int_t dateIn, Int_t timeIn, Int_t iBinSize = 5 ); - - void ResetAllHistos(); - void SaveAllHistos( TString sFileName = "" ); - - void SetMsOverlap(size_t uOverlapMsNb = 1) { fuOverlapMsNb = uOverlapMsNb; } - size_t GetMsOverlap() { return fuOverlapMsNb; } - - void SetPrintMessage( Bool_t bPrintMessOn = kTRUE, - stsxyter::BetaMessagePrintMask ctrl = stsxyter::BetaMessagePrintMask::msg_print_Hex | - stsxyter::BetaMessagePrintMask::msg_print_Human ) - { fbPrintMessages = bPrintMessOn; fPrintMessCtrl = ctrl; } - void EnableChanHitDtPlot( Bool_t bEnable = kTRUE ) { fbChanHitDtEna = bEnable; } - void SetPulserChannels( UInt_t uAsicA, UInt_t uChanA, UInt_t uAsicB, UInt_t uChanB, - UInt_t uAsicC, UInt_t uChanC, UInt_t uAsicD, UInt_t uChanD, - UInt_t uMaxNbMicroslices = 100 ); - void SetLongDurationLimits( UInt_t uDurationSeconds = 3600, UInt_t uBinSize = 1 ); - void SetBetaFormatMode( Bool_t bEnable = kTRUE ) { fbBetaFormat = bEnable; } - -private: - size_t fuOverlapMsNb; /** Ignore Overlap Ms: all fuOverlapMsNb MS at the end of timeslice **/ - - // Parameters - CbmCern2017UnpackParSts* fUnpackPar; //! - UInt_t fuNrOfDpbs; //! Total number of Sts DPBs in system - std::map<UInt_t, UInt_t> fDpbIdIndexMap; //! Map of DPB Identifier to DPB index - UInt_t fuNbElinksPerDpb; //! Number of possible eLinks per DPB - UInt_t fuNbStsXyters; //! Number of StsXyter ASICs - UInt_t fuNbChanPerAsic; //! Number of channels per StsXyter ASIC => should be constant somewhere!!!! - std::vector< std::vector< UInt_t > > fvuElinkToAsic; //! Vector holding for each link the corresponding ASIC index [fuNrOfDpbs * fuNbElinksPerDpb] - - // Constants - static const Int_t kiMaxNbFlibLinks = 16; - static const UInt_t kuBytesPerMessage = 4; - - // Internal Control/status of monitor - // Task configuration values - Bool_t fbPrintMessages; - stsxyter::BetaMessagePrintMask fPrintMessCtrl; - Bool_t fbChanHitDtEna; - // Current data properties - std::map< stsxyter::BetaMessType, UInt_t > fmMsgCounter; - UInt_t fuCurrentEquipmentId; //! Current equipment ID, tells from which DPB the current MS is originating - UInt_t fuCurrDpbId; //! Temp holder until Current equipment ID is properly filled in MS - UInt_t fuCurrDpbIdx; //! Index of the DPB from which the MS currently unpacked is coming - Int_t fiRunStartDateTimeSec; //! Start of run time since "epoch" in s, for the plots with date as X axis - Int_t fiBinSizeDatePlots; //! Bin size in s for the plots with date as X axis -// std::vector< std::vector< UInt_t > > fvuCurrentTsMsb; //! Current TS MSB for each eLink - std::vector< std::vector< ULong64_t > > fvuCurrentTsMsb; //! Current TS MSB for each eLink - std::vector< std::vector< UInt_t > > fvuCurrentTsMsbCycle; //! Current TS MSB cycle for each eLink - std::vector< std::vector< UInt_t > > fvuCurrentTsMsbOver; //! Current TS MSB overlap bits for each eLink - std::vector< std::vector< ULong64_t > > fvulChanLastHitTime; //! Last hit time in bins for each Channel - std::vector< std::vector<Double_t> > fvdChanLastHitTime; //! Last hit time in ns for each Channel - std::vector< std::vector< std::vector< UInt_t > > > fvuChanNbHitsInMs; //! Number of hits in each MS for each Channel - std::vector< std::vector< std::vector< Double_t > > > fvdChanLastHitTimeInMs; //! Last hit time in bins in each MS for each Channel - std::vector< std::vector< std::vector< UShort_t > > > fvusChanLastHitAdcInMs; //! Last hit ADC in bins in each MS for each Channel - std::vector< std::vector< std::multiset< stsxyter::BetaHit > > > fvmChanHitsInTs; //! All hits (time & ADC) in bins in last TS for each Channel - // Starting state book-keeping - Double_t fdStartTime; /** Time of first valid hit (TS_MSB available), used as reference for evolution plots**/ - Double_t fdStartTimeMsSz; /** Time of first microslice, used as reference for evolution plots**/ - std::chrono::steady_clock::time_point ftStartTimeUnix; /** Time of run Start from UNIX system, used as reference for long evolution plots against reception time **/ - // Data format control - Bool_t fbBetaFormat; - std::vector< std::vector< UInt_t > > fvuElinkLastTsHit; //! TS from last hit for each eLink - // Hits time-sorting - std::multiset< stsxyter::BetaHit > fvmHitsInTs; //! All hits (time in bins, ADC in bins, asic, channel) in last TS, sorted by multiset with "<" operator - std::vector< std::vector< ULong64_t > > fvulChanLastSortedHitTime; //! Last sorted hit time in bins for each Channel - - // Histograms - CbmHistManager* fHM; //! Histogram manager - TH1* fhStsMessType; - TH1* fhStsSysMessType; - TH2* fhStsMessTypePerDpb; - TH2* fhStsSysMessTypePerDpb; - TH2* fhStsMessTypePerElink; - TH2* fhStsSysMessTypePerElink; - - std::vector<TH1*> fhStsChanCounts; - std::vector<TH2*> fhStsChanRawAdc; - std::vector<TProfile*> fhStsChanRawAdcProf; - std::vector<TH2*> fhStsChanRawTs; - std::vector<TH2*> fhStsChanMissEvt; - std::vector<TH2*> fhStsChanOverDiff; - std::vector<TH2*> fhStsChanHitRateEvo; - std::vector<TH1*> fhStsXyterRateEvo; - std::vector<TH2*> fhStsChanHitRateEvoLong; - std::vector<TH1*> fhStsXyterRateEvoLong; - std::vector<TH2*> fhStsChanHitDt; - std::vector<TH2*> fhStsChanHitDtNeg; - std::vector<TH2*> fhStsChanHitsPerMs; - std::vector<TH2*> fhStsChanSameMs; - std::vector<TProfile2D*> fpStsChanSameMsTimeDiff; - std::vector<TH2*> fhStsChanSameMsTimeDiff; - - Bool_t fbPulserTimeDiffOn; - UInt_t fuPulserMaxNbMicroslices; - std::vector<UInt_t> fvuPulserAsic; - std::vector<UInt_t> fvuPulserChan; - std::vector<TH1*> fhStsPulserChansTimeDiff; - std::vector<TH2*> fhStsPulserChansTimeDiffEvo; - - std::vector< std::vector< TH1* > > fhStsPulserChansSortedTimeDiff; - std::vector< std::vector< TH2* > > fhStsPulserChansSortedTimeDiffEvo; - - TH2* fhStsAsicTsMsb; - TH2* fhStsAsicTsMsbMaj; - std::vector<TH2*> fhStsElinkTsMsbCrc; - std::vector<TH2*> fhStsElinkTsMsbMaj; - - Bool_t fbLongHistoEnable; - UInt_t fuLongHistoNbSeconds; - UInt_t fuLongHistoBinSizeSec; - UInt_t fuLongHistoBinNb; - std::vector<TH1*> fhFebRateEvoLong; - std::vector<TH2*> fhFebChRateEvoLong; -/* - std::vector<TH1*> fhFebRateEvoDate; -*/ - - TCanvas* fcMsSizeAll; - TH1* fhMsSz[kiMaxNbFlibLinks]; - TProfile* fhMsSzTime[kiMaxNbFlibLinks]; - - void CreateHistograms(); - - void FillHitInfo( stsxyter::BetaMessage mess, const UShort_t & usElinkIdx, const UInt_t & uAsicIdx, const UInt_t & uMsIdx ); - void FillTsMsbInfo( stsxyter::BetaMessage mess, const UShort_t & usElinkIdx, const UInt_t & uAsicIdx ); - - CbmCern2017MonitorBetaSts(const CbmCern2017MonitorBetaSts&); - CbmCern2017MonitorBetaSts operator=(const CbmCern2017MonitorBetaSts&); - - ClassDef(CbmCern2017MonitorBetaSts, 1) -}; - -#endif // CBMCERN2017MONITORBETASTS_H diff --git a/beamtime/cern2017/unpacker/CbmCern2017MonitorHodo.cxx b/beamtime/cern2017/unpacker/CbmCern2017MonitorHodo.cxx deleted file mode 100644 index 6d7a045c267abc407d3749c8be7def1dd0eca315..0000000000000000000000000000000000000000 --- a/beamtime/cern2017/unpacker/CbmCern2017MonitorHodo.cxx +++ /dev/null @@ -1,1958 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmCern2017MonitorHodo ----- -// ----- Created 14/12/17 by P.-A. Loizeau ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#include "CbmCern2017MonitorHodo.h" - -// Data - -// CbmRoot -#include "CbmCern2017UnpackParHodo.h" -#include "CbmHistManager.h" - -// FairRoot -#include "FairLogger.h" -#include "FairRootManager.h" -#include "FairRun.h" -#include "FairRuntimeDb.h" -#include "FairRunOnline.h" - -// Root -#include "TClonesArray.h" -#include "TString.h" -#include "TRandom.h" -#include "THttpServer.h" -#include "TROOT.h" -#include "TStyle.h" -#include <TFile.h> - -// C++11 - -// C/C++ -#include <iostream> -#include <stdint.h> -#include <iomanip> - -Bool_t bCern2017ResetHodoHistos = kFALSE; -Bool_t bCern2017WriteHodoHistos = kFALSE; - -CbmCern2017MonitorHodo::CbmCern2017MonitorHodo() : - CbmTSUnpack(), - fuOverlapMsNb(0), - fUnpackPar(NULL), - fuNrOfDpbs(0), - fDpbIdIndexMap(), - fuNbElinksPerDpb(0), - fuNbStsXyters(0), - fuNbChanPerAsic(0), - fvuElinkToAsic(), - fbPrintMessages( kFALSE ), - fPrintMessCtrl( stsxyter::BetaMessagePrintMask::msg_print_Human ), - fmMsgCounter(), - fuCurrentEquipmentId(0), - fuCurrDpbId(0), - fuCurrDpbIdx(0), - fiRunStartDateTimeSec(-1), - fiBinSizeDatePlots(-1), - fvuCurrentTsMsb(), - fvuCurrentTsMsbCycle(), - fvuCurrentTsMsbOver(), - fvulChanLastHitTime(), - fvdChanLastHitTime(), - fvdMsTime(), - fvuChanNbHitsInMs(), - fvdChanLastHitTimeInMs(), - fvusChanLastHitAdcInMs(), - fvmChanHitsInTs(), - fdStartTime(-1.0), - fdStartTimeMsSz(-1.0), - ftStartTimeUnix( std::chrono::steady_clock::now() ), - fbBetaFormat( kFALSE ), - fvuElinkLastTsHit(), - fvmHitsInTs(), - fLastSortedHit1X(), - fLastSortedHit1Y(), - fLastSortedHit2X(), - fLastSortedHit2Y(), - fuMaxNbMicroslices(100), - fbLongHistoEnable( kFALSE ), - fuLongHistoNbSeconds( 0 ), - fuLongHistoBinSizeSec( 0 ), - fuLongHistoBinNb( 0 ), - fHM(new CbmHistManager()), - fhHodoMessType(NULL), - fhHodoSysMessType(NULL), - fhHodoMessTypePerDpb(NULL), - fhHodoSysMessTypePerDpb(NULL), - fhHodoMessTypePerElink(NULL), - fhHodoSysMessTypePerElink(NULL), - fhHodoChanCntRaw(), - fhHodoChanAdcRaw(), - fhHodoChanAdcRawProf(), - fhHodoChanRawTs(), - fhHodoChanMissEvt(), - fhHodoChanHitRateEvo(), - fhHodoFebRateEvo(), - fhHodoChanHitRateEvoLong(), - fhHodoFebRateEvoLong(), - fhHodoChanCounts1X(NULL), - fhHodoChanCounts1Y(NULL), - fhHodoChanCounts2X(NULL), - fhHodoChanCounts2Y(NULL), - fhHodoChanAdcRaw1X(NULL), - fhHodoChanAdcRaw1Y(NULL), - fhHodoChanAdcRaw2X(NULL), - fhHodoChanAdcRaw2Y(NULL), - fhHodoChanHitRateEvo1X(NULL), - fhHodoChanHitRateEvo1Y(NULL), - fhHodoChanHitRateEvo2X(NULL), - fhHodoChanHitRateEvo2Y(NULL), - fhHodoRateEvo1X(NULL), - fhHodoRateEvo1Y(NULL), - fhHodoRateEvo2X(NULL), - fhHodoRateEvo2Y(NULL), - fhHodoSameMs1XY(NULL), - fhHodoSameMs2XY(NULL), - fhHodoSameMsX1X2(NULL), - fhHodoSameMsY1Y2(NULL), - fhHodoSameMsX1Y2(NULL), - fhHodoSameMsY1X2(NULL), - fhHodoSameMsCntEvoX1Y1(NULL), - fhHodoSameMsCntEvoX2Y2(NULL), - fhHodoSameMsCntEvoX1X2(NULL), - fhHodoSameMsCntEvoY1Y2(NULL), - fhHodoSameMsCntEvoX1Y2(NULL), - fhHodoSameMsCntEvoY1X2(NULL), - fhHodoSameMsCntEvoX1Y1X2Y2(NULL), - fhHodoSortedDtX1Y1(NULL), - fhHodoSortedDtX2Y2(NULL), - fhHodoSortedDtX1X2(NULL), - fhHodoSortedDtY1Y2(NULL), - fhHodoSortedDtX1Y2(NULL), - fhHodoSortedDtY1X2(NULL), - fhHodoSortedMapX1Y1(NULL), - fhHodoSortedMapX2Y2(NULL), - fhHodoSortedMapX1X2(NULL), - fhHodoSortedMapY1Y2(NULL), - fhHodoSortedMapX1Y2(NULL), - fhHodoSortedMapY1X2(NULL), - fhHodoFebTsMsb(NULL), - fcMsSizeAll(NULL) -{ -} - -CbmCern2017MonitorHodo::~CbmCern2017MonitorHodo() -{ -} - -Bool_t CbmCern2017MonitorHodo::Init() -{ - LOG(info) << "Initializing flib StsXyter unpacker for STS"; - - FairRootManager* ioman = FairRootManager::Instance(); - if (ioman == NULL) { - LOG(fatal) << "No FairRootManager instance"; - } - - return kTRUE; -} - -void CbmCern2017MonitorHodo::SetParContainers() -{ - LOG(info) << "Setting parameter containers for " << GetName(); - fUnpackPar = (CbmCern2017UnpackParHodo*)(FairRun::Instance()->GetRuntimeDb()->getContainer("CbmCern2017UnpackParHodo")); -} - - -Bool_t CbmCern2017MonitorHodo::InitContainers() -{ - LOG(info) << "Init parameter containers for " << GetName(); - - Bool_t bReInit = ReInitContainers(); - CreateHistograms(); - - return bReInit; -} - -Bool_t CbmCern2017MonitorHodo::ReInitContainers() -{ - LOG(info) << "ReInit parameter containers for " << GetName(); - - fuNrOfDpbs = fUnpackPar->GetNrOfDpbs(); - fuNbElinksPerDpb = fUnpackPar->GetNbElinksPerDpb(); - fuNbStsXyters = fUnpackPar->GetNbStsXyters(); - fuNbChanPerAsic = fUnpackPar->GetNbChanPerAsic(); - - - LOG(info) << "Nr. of STS DPBs: " << fuNrOfDpbs; - - fDpbIdIndexMap.clear(); - fvuElinkToAsic.resize( fuNrOfDpbs ); - for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - { - fDpbIdIndexMap[ fUnpackPar->GetDpbId( uDpb ) ] = uDpb; - LOG(info) << "Eq. ID for DPB #" << std::setw(2) << uDpb << " = " - << std::setw(4) << std::hex << fUnpackPar->GetDpbId( uDpb ) - << std::dec - << " => " << fDpbIdIndexMap[ fUnpackPar->GetDpbId( uDpb ) ]; - - fvuElinkToAsic[uDpb].resize( fuNbElinksPerDpb ); - for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink ) - fvuElinkToAsic[uDpb][uElink] = fUnpackPar->GetElinkToAsicIdx( uDpb * fuNbElinksPerDpb + uElink ); - } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - - LOG(info) << "Nr. eLinks per DPB: " << fuNbElinksPerDpb; - LOG(info) << "Nr. of StsXyter ASICs: " << fuNbStsXyters; - LOG(info) << "Nb. channels per ASIC: " << fuNbChanPerAsic; - - for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - { - LOG(info) << "ASIC ID for eLinks in DPB #" << std::setw(2) << uDpb << ": "; - - for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink ) - { - if( 0 == uElink % 10 ) - LOG(info) << "\n" - << "------> "; - - LOG(info) << std::setw( 5 ) << fvuElinkToAsic[uDpb][uElink] << " "; - } // for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink ) - LOG(info) << ""; - } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - - LOG(info) << "ASCIC Idx for Hodo 1: " << fUnpackPar->GetAsicIndexHodo1(); - LOG(info) << "ASCIC Idx for Hodo 2: " << fUnpackPar->GetAsicIndexHodo2(); - - LOG(info) << "XY swapped in Hodo 1: " << fUnpackPar->IsXySwappedHodo1(); - LOG(info) << "XY swapped in Hodo 2: " << fUnpackPar->IsXySwappedHodo2(); - - LOG(info) << "X axis inverted in Hodo 1: " << fUnpackPar->IsXInvertedHodo1(); - LOG(info) << "X axis inverted in Hodo 1: " << fUnpackPar->IsYInvertedHodo1(); - LOG(info) << "X axis inverted in Hodo 2: " << fUnpackPar->IsXInvertedHodo2(); - LOG(info) << "X axis inverted in Hodo 2: " << fUnpackPar->IsYInvertedHodo2(); - - // Internal status initialization - fvuCurrentTsMsb.resize( fuNrOfDpbs ); - fvuCurrentTsMsbCycle.resize( fuNrOfDpbs ); - fvuCurrentTsMsbOver.resize( fuNrOfDpbs ); - fvuElinkLastTsHit.resize( fuNrOfDpbs ); - for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - { - fvuCurrentTsMsb[uDpb].resize( fuNbElinksPerDpb ); - fvuCurrentTsMsbCycle[uDpb].resize( fuNbElinksPerDpb ); - fvuCurrentTsMsbOver[uDpb].resize( fuNbElinksPerDpb ); - fvuElinkLastTsHit[uDpb].resize( fuNbElinksPerDpb ); - for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink ) - { - fvuCurrentTsMsb[uDpb][uElink] = 0; - fvuCurrentTsMsbCycle[uDpb][uElink] = 0; - fvuCurrentTsMsbOver[uDpb][uElink] = 0; - fvuElinkLastTsHit[uDpb][uElink] = 0; - } // for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink ) - } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - - fvulChanLastHitTime.resize( fuNbStsXyters ); - fvdChanLastHitTime.resize( fuNbStsXyters ); - fvdMsTime.resize( fuMaxNbMicroslices ); - fvuChanNbHitsInMs.resize( fuNbStsXyters ); - fvdChanLastHitTimeInMs.resize( fuNbStsXyters ); - fvusChanLastHitAdcInMs.resize( fuNbStsXyters ); - fvmChanHitsInTs.resize( fuNbStsXyters ); - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fvulChanLastHitTime[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvdChanLastHitTime[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvuChanNbHitsInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvdChanLastHitTimeInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvusChanLastHitAdcInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvmChanHitsInTs[ uXyterIdx ].resize( fuNbChanPerAsic ); - for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - { - fvulChanLastHitTime[ uXyterIdx ][ uChan ] = 0; - fvdChanLastHitTime[ uXyterIdx ][ uChan ] = -1.0; - - fvuChanNbHitsInMs[ uXyterIdx ][ uChan ].resize( fuMaxNbMicroslices ); - fvdChanLastHitTimeInMs[ uXyterIdx ][ uChan ].resize( fuMaxNbMicroslices ); - fvusChanLastHitAdcInMs[ uXyterIdx ][ uChan ].resize( fuMaxNbMicroslices ); - fvmChanHitsInTs[ uXyterIdx ][ uChan ].clear(); - for( UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx ) - { - fvuChanNbHitsInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = 0; - fvdChanLastHitTimeInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = -1.0; - fvusChanLastHitAdcInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = 0; - } // for( UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx ) - } // for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - LOG(info) << "CbmCern2017MonitorHodo::ReInitContainers => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs.size() << " VS " << fuNbStsXyters; - LOG(info) << "CbmCern2017MonitorHodo::ReInitContainers => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs[ 0 ].size() << " VS " << fuNbChanPerAsic; - LOG(info) << "CbmCern2017MonitorHodo::ReInitContainers => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs[ 0 ][ 0 ].size() << " VS " << fuMaxNbMicroslices; - return kTRUE; -} - -void CbmCern2017MonitorHodo::CreateHistograms() -{ - THttpServer* server = FairRunOnline::Instance()->GetHttpServer(); - - TString sHistName{""}; - TString title{""}; - - sHistName = "hStsMessageType"; - title = "Nb of message for each type; Type"; - fhHodoMessType = new TH1I(sHistName, title, 5, 0., 5.); - fhHodoMessType->GetXaxis()->SetBinLabel( 1, "Dummy"); - fhHodoMessType->GetXaxis()->SetBinLabel( 2, "Hit"); - fhHodoMessType->GetXaxis()->SetBinLabel( 3, "TsMsb"); - fhHodoMessType->GetXaxis()->SetBinLabel( 4, "ReadDataAck"); - fhHodoMessType->GetXaxis()->SetBinLabel( 5, "Ack"); -/* *** Missing int + MessType OP!!!! **** - fhHodoMessType->GetXaxis()->SetBinLabel(1 + stsxyter::BetaMessType::Dummy, "Dummy"); - fhHodoMessType->GetXaxis()->SetBinLabel(1 + stsxyter::BetaMessType::Hit, "Hit"); - fhHodoMessType->GetXaxis()->SetBinLabel(1 + stsxyter::BetaMessType::TsMsb, "TsMsb"); - fhHodoMessType->GetXaxis()->SetBinLabel(1 + stsxyter::BetaMessType::ReadDataAck, "ReadDataAck"); - fhHodoMessType->GetXaxis()->SetBinLabel(1 + stsxyter::BetaMessType::Ack, "Ack"); -*/ - fHM->Add(sHistName.Data(), fhHodoMessType); - if( server ) server->Register("/StsRaw", fhHodoMessType ); - - sHistName = "hStsSysMessType"; - title = "Nb of system message for each type; System Type"; - fhHodoSysMessType = new TH1I(sHistName, title, 17, 0., 17.); -/* - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_START, "DAQ START"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_FINISH, "DAQ FINISH"); - hSysMessType->GetXaxis()->SetBinLabel(1 + 16, "GET4 Hack 32B"); -*/ - fHM->Add(sHistName.Data(), fhHodoSysMessType); - if( server ) server->Register("/StsRaw", fhHodoSysMessType ); - - sHistName = "hStsMessageTypePerDpb"; - title = "Nb of message of each type for each DPB; DPB; Type"; - fhHodoMessTypePerDpb = new TH2I(sHistName, title, fuNrOfDpbs, 0, fuNrOfDpbs, 5, 0., 5.); - fhHodoMessTypePerDpb->GetYaxis()->SetBinLabel( 1, "Dummy"); - fhHodoMessTypePerDpb->GetYaxis()->SetBinLabel( 2, "Hit"); - fhHodoMessTypePerDpb->GetYaxis()->SetBinLabel( 3, "TsMsb"); - fhHodoMessTypePerDpb->GetYaxis()->SetBinLabel( 4, "ReadDataAck"); - fhHodoMessTypePerDpb->GetYaxis()->SetBinLabel( 5, "Ack"); -/* *** Missing int + MessType OP!!!! **** - fhHodoMessType->GetYaxis()->SetBinLabel(1 + stsxyter::BetaMessType::Dummy, "Dummy"); - fhHodoMessType->GetYaxis()->SetBinLabel(1 + stsxyter::BetaMessType::Hit, "Hit"); - fhHodoMessType->GetYaxis()->SetBinLabel(1 + stsxyter::BetaMessType::TsMsb, "TsMsb"); - fhHodoMessType->GetYaxis()->SetBinLabel(1 + stsxyter::BetaMessType::ReadDataAck, "ReadDataAck"); - fhHodoMessType->GetYaxis()->SetBinLabel(1 + stsxyter::BetaMessType::Ack, "Ack"); -*/ - fHM->Add(sHistName.Data(), fhHodoMessTypePerDpb); - if( server ) server->Register("/StsRaw", fhHodoMessTypePerDpb ); - - sHistName = "hStsSysMessTypePerDpb"; - title = "Nb of system message of each type for each DPB; DPB; System Type"; - fhHodoSysMessTypePerDpb = new TH2I(sHistName, title, fuNrOfDpbs, 0, fuNrOfDpbs, 17, 0., 17.); -/* - hSysMessType->GetYaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_START, "DAQ START"); - hSysMessType->GetYaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_FINISH, "DAQ FINISH"); - hSysMessType->GetYaxis()->SetBinLabel(1 + 16, "GET4 Hack 32B"); -*/ - fHM->Add(sHistName.Data(), fhHodoSysMessTypePerDpb); - if( server ) server->Register("/StsRaw", fhHodoSysMessTypePerDpb ); - - sHistName = "hStsMessageTypePerElink"; - title = "Nb of message of each type for each eLink; eLink; Type"; - fhHodoMessTypePerElink = new TH2I(sHistName, title, fuNrOfDpbs * fuNbElinksPerDpb, 0, fuNrOfDpbs * fuNbElinksPerDpb, 5, 0., 5.); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel( 1, "Dummy"); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel( 2, "Hit"); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel( 3, "TsMsb"); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel( 4, "ReadDataAck"); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel( 5, "Ack"); -/* *** Missing int + MessType OP!!!! **** - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::BetaMessType::Dummy, "Dummy"); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::BetaMessType::Hit, "Hit"); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::BetaMessType::TsMsb, "TsMsb"); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::BetaMessType::ReadDataAck, "ReadDataAck"); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::BetaMessType::Ack, "Ack"); -*/ - fHM->Add(sHistName.Data(), fhHodoMessTypePerElink); - if( server ) server->Register("/StsRaw", fhHodoMessTypePerElink ); - - sHistName = "hStsSysMessTypePerElink"; - title = "Nb of system message of each type for each eLink; eLink; System Type"; - fhHodoSysMessTypePerElink = new TH2I(sHistName, title, fuNrOfDpbs * fuNbElinksPerDpb, 0, fuNrOfDpbs * fuNbElinksPerDpb, 17, 0., 17.); -/* - fhHodoSysMessTypePerElink->GetYaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_START, "DAQ START"); - fhHodoSysMessTypePerElink->GetYaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_FINISH, "DAQ FINISH"); - fhHodoSysMessTypePerElink->GetYaxis()->SetBinLabel(1 + 16, "GET4 Hack 32B"); -*/ - fHM->Add(sHistName.Data(), fhHodoSysMessTypePerElink); - if( server ) server->Register("/StsRaw", fhHodoSysMessTypePerElink ); - -/* - // Number of rate bins = - // 9 for the sub-unit decade - // + 9 for each unit of each decade * 10 for the subdecade range - // + 1 for the closing bin top edge - const Int_t iNbDecadesRate = 9; - const Int_t iNbStepsDecade = 9; - const Int_t iNbSubStepsInStep = 10; - const Int_t iNbBinsRate = iNbStepsDecade - + iNbStepsDecade * iNbSubStepsInStep * iNbDecadesRate - + 1; - Double_t dBinsRate[iNbBinsRate]; - // First fill sub-unit decade - for( Int_t iSubU = 0; iSubU < iNbStepsDecade; iSubU ++ ) - dBinsRate[ iSubU ] = 0.1 * ( 1 + iSubU ); - std::cout << std::endl; - // Then fill the main decades - Double_t dSubstepSize = 1.0 / iNbSubStepsInStep; - for( Int_t iDecade = 0; iDecade < iNbDecadesRate; iDecade ++) - { - Double_t dBase = std::pow( 10, iDecade ); - Int_t iDecadeIdx = iNbStepsDecade - + iDecade * iNbStepsDecade * iNbSubStepsInStep; - for( Int_t iStep = 0; iStep < iNbStepsDecade; iStep++ ) - { - Int_t iStepIdx = iDecadeIdx + iStep * iNbSubStepsInStep; - for( Int_t iSubStep = 0; iSubStep < iNbSubStepsInStep; iSubStep++ ) - { - dBinsRate[ iStepIdx + iSubStep ] = dBase * (1 + iStep) - + dBase * dSubstepSize * iSubStep; - } // for( Int_t iSubStep = 0; iSubStep < iNbSubStepsInStep; iSubStep++ ) - } // for( Int_t iStep = 0; iStep < iNbStepsDecade; iStep++ ) - } // for( Int_t iDecade = 0; iDecade < iNbDecadesRate; iDecade ++) - dBinsRate[ iNbBinsRate - 1 ] = std::pow( 10, iNbDecadesRate ); -*/ - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - // Channel counts - sHistName = Form( "hHodoChanCntRaw_%03u", uXyterIdx ); - title = Form( "Hits Count per channel, StsXyter #%03u; Channel; Hits []", uXyterIdx ); - fhHodoChanCntRaw.push_back( new TH1I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - fHM->Add(sHistName.Data(), fhHodoChanCntRaw[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhHodoChanCntRaw[ uXyterIdx ] ); - - // Raw Adc Distribution - sHistName = Form( "hHodoChanAdcRaw_%03u", uXyterIdx ); - title = Form( "Raw Adc distribution per channel, StsXyter #%03u; Channel []; Adc []; Hits []", uXyterIdx ); - fhHodoChanAdcRaw.push_back( new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - stsxyter::kuBetaHitNbAdcBins, -0.5, stsxyter::kuBetaHitNbAdcBins -0.5 ) ); - fHM->Add(sHistName.Data(), fhHodoChanAdcRaw[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhHodoChanAdcRaw[ uXyterIdx ] ); - - // Raw Adc Distribution profile - sHistName = Form( "hHodoChanAdcRawProfc_%03u", uXyterIdx ); - title = Form( "Raw Adc prodile per channel, StsXyter #%03u; Channel []; Adc []", uXyterIdx ); - fhHodoChanAdcRawProf.push_back( new TProfile(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - fHM->Add(sHistName.Data(), fhHodoChanAdcRawProf[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhHodoChanAdcRawProf[ uXyterIdx ] ); - - // Raw Ts Distribution - sHistName = Form( "hHodoChanRawTs_%03u", uXyterIdx ); - title = Form( "Raw Timestamp distribution per channel, StsXyter #%03u; Channel []; Ts []; Hits []", uXyterIdx ); - fhHodoChanRawTs.push_back( new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - stsxyter::kuBetaHitNbTsBins, -0.5, stsxyter::kuBetaHitNbTsBins -0.5 ) ); - fHM->Add(sHistName.Data(), fhHodoChanRawTs[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhHodoChanRawTs[ uXyterIdx ] ); - - // Missed event flag - sHistName = Form( "hHodoChanMissEvt_%03u", uXyterIdx ); - title = Form( "Missed Event flags per channel, StsXyter #%03u; Channel []; Miss Evt []; Hits []", uXyterIdx ); - fhHodoChanMissEvt.push_back( new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - 2, -0.5, 1.5 ) ); - fHM->Add(sHistName.Data(), fhHodoChanMissEvt[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhHodoChanMissEvt[ uXyterIdx ] ); - - // Hit rates evo per channel - sHistName = Form( "hStsChanRateEvo_%03u", uXyterIdx ); - title = Form( "Hits per second & channel in StsXyter #%03u; Time [s]; Channel []; Hits []", uXyterIdx ); - fhHodoChanHitRateEvo.push_back( new TH2I( sHistName, title, - 1800, 0, 1800, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - fHM->Add(sHistName.Data(), fhHodoChanHitRateEvo[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhHodoChanHitRateEvo[ uXyterIdx ] ); - - // Hit rates evo per StsXyter - sHistName = Form( "hHodoFebRateEvo_%03u", uXyterIdx ); - title = Form( "Hits per second in StsXyter #%03u; Time [s]; Hits []", uXyterIdx ); - fhHodoFebRateEvo.push_back( new TH1I(sHistName, title, 1800, 0, 1800 ) ); - fHM->Add(sHistName.Data(), fhHodoFebRateEvo[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhHodoFebRateEvo[ uXyterIdx ] ); - - // Hit rates evo per channel, 1 minute bins, 24h - sHistName = Form( "hStsChanRateEvoLong_%03u", uXyterIdx ); - title = Form( "Hits per second & channel in StsXyter #%03u; Time [min]; Channel []; Hits []", uXyterIdx ); - fhHodoChanHitRateEvoLong.push_back( new TH2D( sHistName, title, - 1440, 0, 1440, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - fHM->Add(sHistName.Data(), fhHodoChanHitRateEvoLong[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhHodoChanHitRateEvoLong[ uXyterIdx ] ); - - // Hit rates evo per StsXyter, 1 minute bins, 24h - sHistName = Form( "hHodoFebRateEvoLong_%03u", uXyterIdx ); - title = Form( "Hits per second in StsXyter #%03u; Time [min]; Hits []", uXyterIdx ); - fhHodoFebRateEvoLong.push_back( new TH1D(sHistName, title, 1440, 0, 1440 ) ); - fHM->Add(sHistName.Data(), fhHodoFebRateEvoLong[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhHodoFebRateEvoLong[ uXyterIdx ] ); -/* - if( kTRUE == fbLongHistoEnable ) - { - UInt_t uAlignedLimit = fuLongHistoNbSeconds - (fuLongHistoNbSeconds % fuLongHistoBinSizeSec); - fuLongHistoBinNb = uAlignedLimit / fuLongHistoBinSizeSec; - - sHistName = Form( "hFebRateEvoLong_%03u", uXyterIdx ); - title = Form( "Mean rate VS run time in same MS in StsXyter #%03u; Time in run [s]; Rate [1/s]", uXyterIdx ); - fhFebRateEvoLong.push_back( new TH1D( sHistName, title, - fuLongHistoBinNb, -0.5, uAlignedLimit - 0.5) ); - fHM->Add(sHistName.Data(), fhFebRateEvoLong[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhFebRateEvoLong[ uXyterIdx ] ); - - sHistName = Form( "hFebChRateEvoLong_%03u", uXyterIdx ); - title = Form( "Mean rate per channel VS run time in StsXyter #%03u; Time in run [s]; Channel []; Rare [1/s]", uXyterIdx ); - fhFebChRateEvoLong.push_back( new TH2D( sHistName, title, - fuLongHistoBinNb, -0.5, uAlignedLimit - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - fHM->Add(sHistName.Data(), fhFebChRateEvoLong[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhFebChRateEvoLong[ uXyterIdx ] ); - } // if( kTRUE == fbLongHistoEnable ) -*/ - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - - // Channel counts for each of the hodoscope planes - sHistName = "hHodoChanCounts1X"; - title = "Channel counts for hodoscope 1 axis X; X channel []; Hits []"; - fhHodoChanCounts1X = new TH1I( sHistName, title, fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - fHM->Add(sHistName.Data(), fhHodoChanCounts1X ); - if( server ) server->Register("/StsRaw", fhHodoChanCounts1X ); - sHistName = "hHodoChanCounts1Y"; - title = "Channel counts for hodoscope 1 axis Y; Y channel []; Hits []"; - fhHodoChanCounts1Y = new TH1I( sHistName, title, fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - fHM->Add(sHistName.Data(), fhHodoChanCounts1Y ); - if( server ) server->Register("/StsRaw", fhHodoChanCounts1Y ); - sHistName = "hHodoChanCounts2X"; - title = "Channel counts for hodoscope 2 axis X; X channel []; Hits []"; - fhHodoChanCounts2X = new TH1I( sHistName, title, fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - fHM->Add(sHistName.Data(), fhHodoChanCounts2X ); - if( server ) server->Register("/StsRaw", fhHodoChanCounts2X ); - sHistName = "hHodoChanCounts2Y"; - title = "Channel counts for hodoscope 2 axis Y; Y channel []; Hits []"; - fhHodoChanCounts2Y = new TH1I( sHistName, title, fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - fHM->Add(sHistName.Data(), fhHodoChanCounts2Y ); - if( server ) server->Register("/StsRaw", fhHodoChanCounts2Y ); - - // Raw ADC distributions for each of the hodoscope planes - sHistName = "hHodoChanAdcRaw1X"; - title = "Raw ADC distributions for hodoscope 1 axis X; X channel []; ADC [bin]; Hits []"; - fhHodoChanAdcRaw1X = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - stsxyter::kuBetaHitNbAdcBins, -0.5, stsxyter::kuBetaHitNbAdcBins -0.5 ); - fHM->Add(sHistName.Data(), fhHodoChanAdcRaw1X ); - if( server ) server->Register("/StsRaw", fhHodoChanAdcRaw1X ); - sHistName = "hHodoChanAdcRaw1Y"; - title = "Raw ADC distributions for hodoscope 1 axis Y; Y channel []; ADC [bin]; Hits []"; - fhHodoChanAdcRaw1Y = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - stsxyter::kuBetaHitNbAdcBins, -0.5, stsxyter::kuBetaHitNbAdcBins -0.5 ); - fHM->Add(sHistName.Data(), fhHodoChanAdcRaw1Y ); - if( server ) server->Register("/StsRaw", fhHodoChanAdcRaw1Y ); - sHistName = "hHodoChanAdcRaw2X"; - title = "Raw ADC distributions for hodoscope 2 axis X; X channel []; ADC [bin]; Hits []"; - fhHodoChanAdcRaw2X = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - stsxyter::kuBetaHitNbAdcBins, -0.5, stsxyter::kuBetaHitNbAdcBins -0.5 ); - fHM->Add(sHistName.Data(), fhHodoChanAdcRaw2X ); - if( server ) server->Register("/StsRaw", fhHodoChanAdcRaw2X ); - sHistName = "hHodoChanAdcRaw2Y"; - title = "Raw ADC distributions for hodoscope 2 axis Y; Y channel []; ADC [bin]; Hits []"; - fhHodoChanAdcRaw2Y = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - stsxyter::kuBetaHitNbAdcBins, -0.5, stsxyter::kuBetaHitNbAdcBins -0.5 ); - fHM->Add(sHistName.Data(), fhHodoChanAdcRaw2Y ); - if( server ) server->Register("/StsRaw", fhHodoChanAdcRaw2Y ); - - // Hit rate Evo for each channel of each of the hodoscope planes - sHistName = "hHodoChanHitRateEvo1X"; - title = "Hits per second & channel in Hodo 1 X axis; Time [s]; Channel []; Hits []"; - fhHodoChanHitRateEvo1X = new TH2I( sHistName, title, - 1800, 0, 1800, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - fHM->Add(sHistName.Data(), fhHodoChanHitRateEvo1X ); - if( server ) server->Register("/StsRaw", fhHodoChanHitRateEvo1X ); - sHistName = "hHodoChanHitRateEvo1Y"; - title = "Hits per second & channel in Hodo 1 Y axis; Time [s]; Channel []; Hits []"; - fhHodoChanHitRateEvo1Y = new TH2I( sHistName, title, - 1800, 0, 1800, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - fHM->Add(sHistName.Data(), fhHodoChanHitRateEvo1Y ); - if( server ) server->Register("/StsRaw", fhHodoChanHitRateEvo1Y ); - sHistName = "hHodoChanHitRateEvo2X"; - title = "Hits per second & channel in Hodo 2 X axis; Time [s]; Channel []; Hits []"; - fhHodoChanHitRateEvo2X = new TH2I( sHistName, title, - 1800, 0, 1800, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - fHM->Add(sHistName.Data(), fhHodoChanHitRateEvo2X ); - if( server ) server->Register("/StsRaw", fhHodoChanHitRateEvo2X ); - sHistName = "hHodoChanHitRateEvo2Y"; - title = "Hits per second & channel in Hodo 2 Y axis; Time [s]; Channel []; Hits []"; - fhHodoChanHitRateEvo2Y = new TH2I( sHistName, title, - 1800, 0, 1800, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - fHM->Add(sHistName.Data(), fhHodoChanHitRateEvo2Y ); - if( server ) server->Register("/StsRaw", fhHodoChanHitRateEvo2Y ); - - // Hit rate Evo for each channel of each of the hodoscope planes - sHistName = "fhHodoRateEvo1X"; - title = "Hits per second in Hodoscope 1 X axis; Time [s]; Hits []"; - fhHodoRateEvo1X = new TH1I(sHistName, title, 1800, 0, 1800 ); - fHM->Add(sHistName.Data(), fhHodoRateEvo1X ); - if( server ) server->Register("/StsRaw", fhHodoRateEvo1X ); - sHistName = "hHodoRateEvo1Y"; - title = "Hits per second in Hodoscope 1 Y axis; Time [s]; Hits []"; - fhHodoRateEvo1Y = new TH1I(sHistName, title, 1800, 0, 1800 ); - fHM->Add(sHistName.Data(), fhHodoRateEvo1Y ); - if( server ) server->Register("/StsRaw", fhHodoRateEvo1Y ); - sHistName = "fhHodoRateEvo2X"; - title = "Hits per second in Hodoscope 2 X axis; Time [s]; Hits []"; - fhHodoRateEvo2X = new TH1I(sHistName, title, 1800, 0, 1800 ); - fHM->Add(sHistName.Data(), fhHodoRateEvo2X ); - if( server ) server->Register("/StsRaw", fhHodoRateEvo2X ); - sHistName = "hHodoRateEvo2Y"; - title = "Hits per second in Hodoscope 2 Y axis; Time [s]; Hits []"; - fhHodoRateEvo2Y = new TH1I(sHistName, title, 1800, 0, 1800 ); - fHM->Add(sHistName.Data(), fhHodoRateEvo2Y ); - if( server ) server->Register("/StsRaw", fhHodoRateEvo2Y ); - - // Coincidence map for each hodoscope - sHistName = "hHodoSameMs1XY"; - title = "MS with hits in both channels for hodoscope 1 axis X and Y; X channel []; Y channel []; MS []"; - fhHodoSameMs1XY = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - fHM->Add(sHistName.Data(), fhHodoSameMs1XY ); - if( server ) server->Register("/StsRaw", fhHodoSameMs1XY ); - sHistName = "hHodoSameMs2XY"; - title = "MS with hits in both channels for hodoscope 2 axis X and Y; X channel []; Y channel []; MS []"; - fhHodoSameMs2XY = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - fHM->Add(sHistName.Data(), fhHodoSameMs2XY ); - if( server ) server->Register("/StsRaw", fhHodoSameMs2XY ); - - // Coincidence map between some axis of the hodoscopes - sHistName = "hHodoSameMsX1X2"; - title = "MS with hits in both channels for hodoscope 1 and 2 axis X; X channel Hodo 1 []; X channel Hodo 2 []; MS []"; - fhHodoSameMsX1X2 = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - fHM->Add(sHistName.Data(), fhHodoSameMsX1X2 ); - if( server ) server->Register("/StsRaw", fhHodoSameMsX1X2 ); - sHistName = "fhHodoSameMsY1Y2"; - title = "MS with hits in both channels for hodoscope 1 and 2 axis Y; Y channel Hodo 1 []; Y channel Hodo 2 []; MS []"; - fhHodoSameMsY1Y2 = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - fHM->Add(sHistName.Data(), fhHodoSameMsY1Y2 ); - if( server ) server->Register("/StsRaw", fhHodoSameMsY1Y2 ); - sHistName = "hHodoSameMsX1Y2"; - title = "MS with hits in both channels for hodoscope 1 axis X and 2 axis Y; X channel Hodo 1 []; Y channel Hodo 2 []; MS []"; - fhHodoSameMsX1Y2 = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - fHM->Add(sHistName.Data(), fhHodoSameMsX1Y2 ); - if( server ) server->Register("/StsRaw", fhHodoSameMsX1Y2 ); - sHistName = "fhHodoSameMsY1X2"; - title = "MS with hits in both channels for hodoscope 1 axis Y and 2 axis X; Y channel Hodo 1 []; X channel Hodo 2 []; MS []"; - fhHodoSameMsY1X2 = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - fHM->Add(sHistName.Data(), fhHodoSameMsY1X2 ); - if( server ) server->Register("/StsRaw", fhHodoSameMsY1X2 ); - - // Coincidence counts evolution between some axis of the hodoscopes - sHistName = "hHodoSameMsCntEvoX1Y1"; - title = "Nb of MS with hits in both X1 and Y1 per s; Time [s]; MS with both []"; - fhHodoSameMsCntEvoX1Y1 = new TH1I(sHistName, title, 1800, 0, 1800 ); - fHM->Add(sHistName.Data(), fhHodoSameMsCntEvoX1Y1 ); - if( server ) server->Register("/StsRaw", fhHodoSameMsCntEvoX1Y1 ); - - sHistName = "hHodoSameMsCntEvoX2Y2"; - title = "Nb of MS with hits in both X2 and Y2 per s; Time [s]; MS with both []"; - fhHodoSameMsCntEvoX2Y2 = new TH1I(sHistName, title, 1800, 0, 1800 ); - fHM->Add(sHistName.Data(), fhHodoSameMsCntEvoX2Y2 ); - if( server ) server->Register("/StsRaw", fhHodoSameMsCntEvoX2Y2 ); - - sHistName = "fhHodoSameMsCntEvoX1X2"; - title = "Nb of MS with hits in both X1 and X2 per s; Time [s]; MS with both []"; - fhHodoSameMsCntEvoX1X2 = new TH1I(sHistName, title, 1800, 0, 1800 ); - fHM->Add(sHistName.Data(), fhHodoSameMsCntEvoX1X2 ); - if( server ) server->Register("/StsRaw", fhHodoSameMsCntEvoX1X2 ); - - sHistName = "fhHodoSameMsCntEvoY1Y2"; - title = "Nb of MS with hits in both Y1 and Y2 per s; Time [s]; MS with both []"; - fhHodoSameMsCntEvoY1Y2 = new TH1I(sHistName, title, 1800, 0, 1800 ); - fHM->Add(sHistName.Data(), fhHodoSameMsCntEvoY1Y2 ); - if( server ) server->Register("/StsRaw", fhHodoSameMsCntEvoY1Y2 ); - - sHistName = "hHodoSameMsCntEvoX1Y2"; - title = "Nb of MS with hits in both X1 and Y2 per s; Time [s]; MS with both []"; - fhHodoSameMsCntEvoX1Y2 = new TH1I(sHistName, title, 1800, 0, 1800 ); - fHM->Add(sHistName.Data(), fhHodoSameMsCntEvoX1Y2 ); - if( server ) server->Register("/StsRaw", fhHodoSameMsCntEvoX1Y2 ); - - sHistName = "hHodoSameMsCntEvoY1X2"; - title = "Nb of MS with hits in both Y1 and X2 per s; Time [s]; MS with both []"; - fhHodoSameMsCntEvoY1X2 = new TH1I(sHistName, title, 1800, 0, 1800 ); - fHM->Add(sHistName.Data(), fhHodoSameMsCntEvoY1X2 ); - if( server ) server->Register("/StsRaw", fhHodoSameMsCntEvoY1X2 ); - - sHistName = "hHodoSameMsCntEvoX1Y1X2Y2"; - title = "Nb of MS with hits in both X1, Y1, X2 and Y2 per s; Time [s]; MS with both []"; - fhHodoSameMsCntEvoX1Y1X2Y2 = new TH1I(sHistName, title, 1800, 0, 1800 ); - fHM->Add(sHistName.Data(), fhHodoSameMsCntEvoX1Y1X2Y2 ); - if( server ) server->Register("/StsRaw", fhHodoSameMsCntEvoX1Y1X2Y2 ); - -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - - UInt_t uNbBinEvo = 32768 + 1; - Double_t dMaxEdgeEvo = stsxyter::kdBetaClockCycleNs - * static_cast< Double_t >( uNbBinEvo ) / 2.0; - Double_t dMinEdgeEvo = dMaxEdgeEvo * -1.0; - - sHistName = "fhHodoSortedDtX1Y1"; - title = "Time diff for hits Hodo 1 X and Hodo 1 Y; tY1 - tX1 [ns]; Counts"; - fhHodoSortedDtX1Y1 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - fHM->Add(sHistName.Data(), fhHodoSortedDtX1Y1); - if( server ) server->Register("/StsRaw", fhHodoSortedDtX1Y1 ); - - sHistName = "fhHodoSortedDtX2Y2"; - title = "Time diff for hits Hodo 2 X and Hodo 2 Y; tY2 - tX2 [ns]; Counts"; - fhHodoSortedDtX2Y2 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - fHM->Add(sHistName.Data(), fhHodoSortedDtX2Y2); - if( server ) server->Register("/StsRaw", fhHodoSortedDtX2Y2 ); - - sHistName = "fhHodoSortedDtX1X2"; - title = "Time diff for hits Hodo 1 X and Hodo 2 X; tX2 - tX1 [ns]; Counts"; - fhHodoSortedDtX1X2 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - fHM->Add(sHistName.Data(), fhHodoSortedDtX1X2); - if( server ) server->Register("/StsRaw", fhHodoSortedDtX1X2 ); - - sHistName = "fhHodoSortedDtY1Y2"; - title = "Time diff for hits Hodo 1 Y and Hodo 2 Y; tY2 - tY1 [ns]; Counts"; - fhHodoSortedDtY1Y2 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - fHM->Add(sHistName.Data(), fhHodoSortedDtY1Y2); - if( server ) server->Register("/StsRaw", fhHodoSortedDtY1Y2 ); - - sHistName = "fhHodoSortedDtX1Y2"; - title = "Time diff for hits Hodo 1 X and Hodo 2 Y; tY2 - tX1 [ns]; Counts"; - fhHodoSortedDtX1Y2 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - fHM->Add(sHistName.Data(), fhHodoSortedDtX1Y2); - if( server ) server->Register("/StsRaw", fhHodoSortedDtX1Y2 ); - - sHistName = "fhHodoSortedDtY1X2"; - title = "Time diff for hits Hodo 1 Y and Hodo 2 X; tY2 - tY1 [ns]; Counts"; - fhHodoSortedDtY1X2 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - fHM->Add(sHistName.Data(), fhHodoSortedDtY1X2); - if( server ) server->Register("/StsRaw", fhHodoSortedDtY1X2 ); - - sHistName = "fhHodoSortedMapX1Y1"; - title = "Sorted hits in coincidence for hodoscope 1 axis Y and 2 axis X; Y channel Hodo 1 []; X channel Hodo 2 []; MS []"; - fhHodoSortedMapX1Y1 = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - fHM->Add(sHistName.Data(), fhHodoSortedMapX1Y1 ); - if( server ) server->Register("/StsRaw", fhHodoSortedMapX1Y1 ); - - sHistName = "fhHodoSortedMapX2Y2"; - title = "Sorted hits in coincidence for hodoscope 1 axis Y and 2 axis X; Y channel Hodo 1 []; X channel Hodo 2 []; MS []"; - fhHodoSortedMapX2Y2 = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - fHM->Add(sHistName.Data(), fhHodoSortedMapX2Y2 ); - if( server ) server->Register("/StsRaw", fhHodoSortedMapX2Y2 ); - - sHistName = "fhHodoSortedMapX1X2"; - title = "Sorted hits in coincidence for hodoscope 1 axis Y and 2 axis X; Y channel Hodo 1 []; X channel Hodo 2 []; MS []"; - fhHodoSortedMapX1X2 = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - fHM->Add(sHistName.Data(), fhHodoSortedMapX1X2 ); - if( server ) server->Register("/StsRaw", fhHodoSortedMapX1X2 ); - - sHistName = "fhHodoSortedMapY1Y2"; - title = "Sorted hits in coincidence for hodoscope 1 axis Y and 2 axis X; Y channel Hodo 1 []; X channel Hodo 2 []; MS []"; - fhHodoSortedMapY1Y2 = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - fHM->Add(sHistName.Data(), fhHodoSortedMapY1Y2 ); - if( server ) server->Register("/StsRaw", fhHodoSortedMapY1Y2 ); - - sHistName = "fhHodoSortedMapX1Y2"; - title = "Sorted hits in coincidence for hodoscope 1 axis Y and 2 axis X; Y channel Hodo 1 []; X channel Hodo 2 []; MS []"; - fhHodoSortedMapX1Y2 = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - fHM->Add(sHistName.Data(), fhHodoSortedMapX1Y2 ); - if( server ) server->Register("/StsRaw", fhHodoSortedMapX1Y2 ); - - sHistName = "fhHodoSortedMapY1X2"; - title = "Sorted hits in coincidence for hodoscope 1 axis Y and 2 axis X; Y channel Hodo 1 []; X channel Hodo 2 []; MS []"; - fhHodoSortedMapY1X2 = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - fHM->Add(sHistName.Data(), fhHodoSortedMapY1X2 ); - if( server ) server->Register("/StsRaw", fhHodoSortedMapY1X2 ); - -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - - // Distribution of the TS_MSB per StsXyter - sHistName = "hHodoFebTsMsb"; - title = "Raw Timestamp Msb distribution per StsXyter; Ts MSB []; StsXyter []; Hits []"; - fhHodoFebTsMsb = new TH2I( sHistName, title, stsxyter::kuBetaTsMsbNbTsBins, -0.5, stsxyter::kuBetaTsMsbNbTsBins - 0.5, - fuNbStsXyters, -0.5, fuNbStsXyters - 0.5 ); - fHM->Add(sHistName.Data(), fhHodoFebTsMsb ); - if( server ) server->Register("/StsRaw", fhHodoFebTsMsb ); - - // Miscroslice properties histos - for( Int_t component = 0; component < kiMaxNbFlibLinks; component ++ ) - { - fhMsSz[ component ] = NULL; - fhMsSzTime[ component ] = NULL; - } // for( Int_t component = 0; component < kiMaxNbFlibLinks; component ++ ) - - // Online histo browser commands - if( server ) - { - server->RegisterCommand("/Reset_All_Hodo", "bCern2017ResetHodoHistos=kTRUE"); - server->RegisterCommand("/Write_All_Hodo", "bCern2017WriteHodoHistos=kTRUE"); - - server->Restrict("/Reset_All_Hodo", "allow=admin"); - server->Restrict("/Write_All_Hodo", "allow=admin"); - } // if( server ) - - /** Create summary Canvases for CERN 2017 **/ - Double_t w = 10; - Double_t h = 10; - - // Summary per StsXyter - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - TCanvas* cStsSumm = new TCanvas( Form("cStsSum_%03u", uXyterIdx ), - Form("Summary plots for StsXyter %03u", uXyterIdx ), - w, h); - cStsSumm->Divide( 2, 2 ); - - cStsSumm->cd(1); - gPad->SetLogy(); - fhHodoChanCntRaw[ uXyterIdx ]->Draw(); - - cStsSumm->cd(2); - gPad->SetLogz(); - fhHodoChanAdcRaw[ uXyterIdx ]->Draw( "colz" ); - - cStsSumm->cd(3); - gPad->SetLogz(); - fhHodoChanRawTs[ uXyterIdx ]->Draw( "colz" ); - - cStsSumm->cd(4); - gPad->SetLogy(); - fhHodoFebRateEvo[ uXyterIdx ]->Draw(); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - -//====================================================================// - TCanvas* cHodoCounts = new TCanvas( "cHodoCounts", - "Hodoscopes counts per axis", - w, h); - cHodoCounts->Divide( 2, 2 ); - - cHodoCounts->cd(1); - gPad->SetLogz(); - fhHodoChanCounts1X->Draw( "" ); - - cHodoCounts->cd(2); - gPad->SetLogz(); - fhHodoChanCounts1Y->Draw( "" ); - - cHodoCounts->cd(3); - gPad->SetLogz(); - fhHodoChanCounts2X->Draw( "" ); - - cHodoCounts->cd(4); - gPad->SetLogz(); - fhHodoChanCounts2Y->Draw( "" ); -//====================================================================// - -//====================================================================// - TCanvas* cHodoAdc = new TCanvas( "cHodoAdc", - "Hodoscopes ADC distributions per axis", - w, h); - cHodoAdc->Divide( 2, 2 ); - - cHodoAdc->cd(1); - gPad->SetLogz(); - fhHodoChanAdcRaw1X->Draw( "colz" ); - - cHodoAdc->cd(2); - gPad->SetLogz(); - fhHodoChanAdcRaw1Y->Draw( "colz" ); - - cHodoAdc->cd(3); - gPad->SetLogz(); - fhHodoChanAdcRaw2X->Draw( "colz" ); - - cHodoAdc->cd(4); - gPad->SetLogz(); - fhHodoChanAdcRaw2Y->Draw( "colz" ); -//====================================================================// - -//====================================================================// - TCanvas* cHodoRates = new TCanvas( "cHodoRates", - "Hodoscopes rates per axis", - w, h); - cHodoRates->Divide( 2, 2 ); - - cHodoRates->cd(1); - gPad->SetLogz(); - fhHodoRateEvo1X->Draw( "" ); - - cHodoRates->cd(2); - gPad->SetLogz(); - fhHodoRateEvo1Y->Draw( "" ); - - cHodoRates->cd(3); - gPad->SetLogz(); - fhHodoRateEvo2X->Draw( "" ); - - cHodoRates->cd(4); - gPad->SetLogz(); - fhHodoRateEvo2Y->Draw( "" ); -//====================================================================// - -//====================================================================// - TCanvas* cHodoRatesEvo = new TCanvas( "cHodoRatesEvo", - "Hodoscopes rates evolutionper axis", - w, h); - cHodoRatesEvo->Divide( 2, 2 ); - - cHodoRatesEvo->cd(1); - gPad->SetLogz(); - fhHodoChanHitRateEvo1X->Draw( "colz" ); - - cHodoRatesEvo->cd(2); - gPad->SetLogz(); - fhHodoChanHitRateEvo1Y->Draw( "colz" ); - - cHodoRatesEvo->cd(3); - gPad->SetLogz(); - fhHodoChanHitRateEvo2X->Draw( "colz" ); - - cHodoRatesEvo->cd(4); - gPad->SetLogz(); - fhHodoChanHitRateEvo2Y->Draw( "colz" ); -//====================================================================// - -//====================================================================// - TCanvas* cHodoMaps = new TCanvas( "cHodoMaps", - "Hodoscopes coincidence maps", - w, h); - cHodoMaps->Divide( 2, 3 ); - - cHodoMaps->cd(1); - gPad->SetLogz(); - fhHodoSameMs1XY->Draw( "colz" ); - - cHodoMaps->cd(2); - gPad->SetLogz(); - fhHodoSameMs2XY->Draw( "colz" ); - - cHodoMaps->cd(3); - gPad->SetLogz(); - fhHodoSameMsX1X2->Draw( "colz" ); - - cHodoMaps->cd(4); - gPad->SetLogz(); - fhHodoSameMsY1Y2->Draw( "colz" ); - - cHodoMaps->cd(5); - gPad->SetLogz(); - fhHodoSameMsX1Y2->Draw( "colz" ); - - cHodoMaps->cd(6); - gPad->SetLogz(); - fhHodoSameMsY1X2->Draw( "colz" ); -//====================================================================// - -//====================================================================// - TCanvas* cHodoCoincEvo = new TCanvas( "cHodoCoincEvo", - "Hodoscopes coincidence rate evolution", - w, h); - cHodoCoincEvo->Divide( 2, 4 ); - - cHodoCoincEvo->cd(1); - gPad->SetLogz(); - fhHodoSameMsCntEvoX1Y1->Draw( "colz" ); - - cHodoCoincEvo->cd(2); - gPad->SetLogz(); - fhHodoSameMsCntEvoX2Y2->Draw( "colz" ); - - cHodoCoincEvo->cd(3); - gPad->SetLogz(); - fhHodoSameMsCntEvoX1X2->Draw( "colz" ); - - cHodoCoincEvo->cd(4); - gPad->SetLogz(); - fhHodoSameMsCntEvoY1Y2->Draw( "colz" ); - - cHodoCoincEvo->cd(5); - gPad->SetLogz(); - fhHodoSameMsCntEvoX1Y2->Draw( "colz" ); - - cHodoCoincEvo->cd(6); - gPad->SetLogz(); - fhHodoSameMsCntEvoY1X2->Draw( "colz" ); - - cHodoCoincEvo->cd(7); - gPad->SetLogz(); - fhHodoSameMsCntEvoX1Y1X2Y2->Draw( "colz" ); -//====================================================================// - - // Long duration rate monitoring -/* - if( kTRUE == fbLongHistoEnable ) - { - TCanvas* cStsLongRate = new TCanvas( "cStsLongRate" , "Long duration rate plots for StsXyter", - w, h); - cStsLongRate->Divide( 2, fuNbStsXyters ); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - cStsLongRate->cd( 1 + 2 * uXyterIdx ); - gPad->SetLogy(); - gPad->SetGridx(); - gPad->SetGridy(); - fhFebRateEvoLong[ uXyterIdx ]->Draw( "hist" ); - - cStsLongRate->cd( 2 + 2 * uXyterIdx ); - gPad->SetLogz(); - gPad->SetGridx(); - gPad->SetGridy(); - fhFebChRateEvoLong[ uXyterIdx ]->Draw( "colz" ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - } // if( kTRUE == fbLongHistoEnable ) -*/ -/* - Int_t iNbPadsPerDpb = fuNbElinksPerDpb/2 + fuNbElinksPerDpb%2; - TCanvas* cMuchChCounts = new TCanvas("cMuchChCounts", "MUCH Channels counts", w, h); - cMuchChCounts->Divide( fNrOfNdpbs/2 + fNrOfNdpbs%2, fNrOfFebsPerNdpb ); - - TCanvas* cMuchFebRate = new TCanvas("cMuchFebRate", "MUCH FEB rate", w, h); - cMuchFebRate->Divide( fNrOfNdpbs/2 + fNrOfNdpbs%2, fNrOfFebsPerNdpb ); - - TH1* histPnt = NULL; - for( Int_t dpbId = 0; dpbId < fNrOfNdpbs; dpbId++) - {// looping on all the nDPBS IDs - if( dpbId < fUnpackPar->GetNrOfnDpbsModA() ) - { - sNdpbTag = Form("%04X", fUnpackPar->GetNdpbIdA(dpbId) ); - } // if( dpbId < fUnpackPar->GetNrOfnDpbsModA() ) - else - { - sNdpbTag = Form("%04X", fUnpackPar->GetNdpbIdB(dpbId - fNrOfNdpbsA) ); - } // else of if( dpbId < fUnpackPar->GetNrOfnDpbsModA() ) - - for( Int_t febId = 0; febId < fNrOfFebsPerNdpb; febId++) - {// looping on all the FEB IDs - cMuchChCounts->cd( 1 + dpbId * iNbPadsPerDpb + febId/2 ); - gPad->SetLogy(); - sHistName = Form("Chan_Counts_Much_n%s_f%1u", sNdpbTag.Data(), febId); - histPnt = fHM->H1(sHistName.Data()); - - if( 0 == febId%2 ) - { - histPnt->SetLineColor( kRed ); // => Change color for 1st of the 2/pad! - histPnt->Draw(); - } // if( 0 == febId%2 ) - else - { - histPnt->SetLineColor( kBlue ); // => Change color for 1nd of the 2/pad! - histPnt->Draw("same"); - } // if( 0 == febId%2 ) - - cMuchFebRate->cd( 1 + dpbId * iNbPadsPerDpb + febId/2 ); - gPad->SetLogy(); - sHistName = Form("FebRate_n%s_f%1u", sNdpbTag.Data(), febId); - histPnt = fHM->H1(sHistName.Data()); - - if( 0 == febId%2 ) - { - histPnt->SetLineColor( kRed ); // => Change color for 1st of the 2/pad! - histPnt->Draw(); - } // if( 0 == febId%2 ) - else - { - histPnt->SetLineColor( kBlue ); // => Change color for 1nd of the 2/pad! - histPnt->Draw("same"); - } // if( 0 == febId%2 ) - } // for( Int_t febId = 0; febId < fNrOfFebsPerNdpb; febId++) - } // for( Int_t dpbId = 0; dpbId < fNrOfNdpbs; dpbId++) -*/ - - /** Recovers/Create Ms Size Canvase for CERN 2016 **/ - // Try to recover canvas in case it was created already by another monitor - // If not existing, create it - fcMsSizeAll = dynamic_cast<TCanvas *>( gROOT->FindObject( "cMsSizeAll" ) ); - if( NULL == fcMsSizeAll ) - { - fcMsSizeAll = new TCanvas("cMsSizeAll", "Evolution of MS size in last 300 s", w, h); - fcMsSizeAll->Divide( 4, 4 ); - LOG(info) << "Created MS size canvas in STS monitor"; - } // if( NULL == fcMsSizeAll ) - else LOG(info) << "Recovered MS size canvas in STS monitor"; - - /*****************************/ -} - -Bool_t CbmCern2017MonitorHodo::DoUnpack(const fles::Timeslice& ts, size_t component) -{ - THttpServer* server = FairRunOnline::Instance()->GetHttpServer(); - - if( bCern2017ResetHodoHistos ) - { - ResetAllHistos(); - bCern2017ResetHodoHistos = kFALSE; - } // if( bCern2017ResetHodoHistos ) - if( bCern2017WriteHodoHistos ) - { - SaveAllHistos( "data/HodoHistos.root" ); - bCern2017WriteHodoHistos = kFALSE; - } // if( bCern2017WriteHodoHistos ) - - LOG(debug) << "Timeslice contains " << ts.num_microslices(component) - << "microslices."; - - if( component < kiMaxNbFlibLinks ) - if( NULL == fhMsSz[ component ] ) - { - TString sMsSzName = Form("MsSz_link_%02lu", component); - TString sMsSzTitle = Form("Size of MS for nDPB of link %02lu; Ms Size [bytes]", component); - fhMsSz[ component ] = new TH1F( sMsSzName.Data(), sMsSzTitle.Data(), 160000, 0., 20000. ); - fHM->Add(sMsSzName.Data(), fhMsSz[ component ] ); - if (server) server->Register("/FlibRaw", fhMsSz[ component ] ); - sMsSzName = Form("MsSzTime_link_%02lu", component); - sMsSzTitle = Form("Size of MS vs time for gDPB of link %02lu; Time[s] ; Ms Size [bytes]", component); - fhMsSzTime[ component ] = new TProfile( sMsSzName.Data(), sMsSzTitle.Data(), 15000, 0., 300. ); - fHM->Add( sMsSzName.Data(), fhMsSzTime[ component ] ); - if (server) server->Register("/FlibRaw", fhMsSzTime[ component ] ); - if( NULL != fcMsSizeAll ) - { - fcMsSizeAll->cd( 1 + component ); - gPad->SetLogy(); - fhMsSzTime[ component ]->Draw("hist le0"); - } // if( NULL != fcMsSizeAll ) - LOG(info) << "Added MS size histo for component: " << component - << " (DPB)"; - } // if( NULL == fhMsSz[ component ] ) - -// Int_t messageType = -111; - // Loop over microslices - size_t numCompMsInTs = ts.num_microslices(component); - - if( fuMaxNbMicroslices < numCompMsInTs ) - { - fuMaxNbMicroslices = numCompMsInTs; - - fvdMsTime.resize( fuMaxNbMicroslices ); - fvuChanNbHitsInMs.resize( fuNbStsXyters ); - fvdChanLastHitTimeInMs.resize( fuNbStsXyters ); - fvusChanLastHitAdcInMs.resize( fuNbStsXyters ); - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fvuChanNbHitsInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvdChanLastHitTimeInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvusChanLastHitAdcInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - { - fvuChanNbHitsInMs[ uXyterIdx ][ uChan ].resize( fuMaxNbMicroslices ); - fvdChanLastHitTimeInMs[ uXyterIdx ][ uChan ].resize( fuMaxNbMicroslices ); - fvusChanLastHitAdcInMs[ uXyterIdx ][ uChan ].resize( fuMaxNbMicroslices ); - for( UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx ) - { - fvuChanNbHitsInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = 0; - fvdChanLastHitTimeInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = -1.0; - fvusChanLastHitAdcInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = 0; - } // for( UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx ) - } // for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - LOG(info) << "CbmCern2017MonitorHodo::DoUnpack => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs.size() << " VS " << fuNbStsXyters; - LOG(info) << "CbmCern2017MonitorHodo::DoUnpack => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs[ 0 ].size() << " VS " << fuNbChanPerAsic; - LOG(info) << "CbmCern2017MonitorHodo::DoUnpack => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs[ 0 ][ 0 ].size() << " VS " << fuMaxNbMicroslices; - } // if( fuMaxNbMicroslices < numCompMsInTs ) - - for( size_t m = 0; m < numCompMsInTs; ++m ) - { - // Ignore overlap ms if number defined by user - if( numCompMsInTs - fuOverlapMsNb <= m ) - continue; - - auto msDescriptor = ts.descriptor(component, m); - fuCurrentEquipmentId = msDescriptor.eq_id; - const uint8_t* msContent = reinterpret_cast<const uint8_t*>(ts.content(component, m)); - Double_t dMsTime = (1e-9) * static_cast<double>(msDescriptor.idx); - - uint32_t size = msDescriptor.size; - LOG(debug) << "Microslice: " << msDescriptor.idx - << " from EqId " << std::hex << fuCurrentEquipmentId << std::dec - << " has size: " << size; - - fuCurrDpbId = static_cast< uint32_t >( fuCurrentEquipmentId & 0xFFFF ); - fuCurrDpbIdx = fDpbIdIndexMap[ fuCurrDpbId ]; - - if( component < kiMaxNbFlibLinks ) - { - if( fdStartTimeMsSz < 0 ) - fdStartTimeMsSz = dMsTime; - fhMsSz[ component ]->Fill( size ); - fhMsSzTime[ component ]->Fill( dMsTime - fdStartTimeMsSz, size); - } // if( component < kiMaxNbFlibLinks ) - - // Store MS time for coincidence plots - fvdMsTime[ m ] = dMsTime; - - // If not integer number of message in input buffer, print warning/error - if( 0 != (size % kuBytesPerMessage) ) - LOG(error) << "The input microslice buffer does NOT " - << "contain only complete nDPB messages!"; - - // Compute the number of complete messages in the input microslice buffer - uint32_t uNbMessages = (size - (size % kuBytesPerMessage) ) - / kuBytesPerMessage; - - // Prepare variables for the loop on contents - const uint32_t* pInBuff = reinterpret_cast<const uint32_t*>( msContent ); - for( uint32_t uIdx = 0; uIdx < uNbMessages; ++uIdx ) - { - // Fill message - uint32_t ulData = static_cast<uint32_t>(pInBuff[uIdx]); - - stsxyter::BetaMessage mess( static_cast< uint32_t >( ulData & 0xFFFFFFFF ) ); - - // Print message if requested - if( fbPrintMessages ) - mess.PrintMess( std::cout, fPrintMessCtrl ); - - // Extract the eLink and Asic indices - UShort_t usElinkIdx = mess.GetLinkIndex(); - if( fuNbElinksPerDpb <= usElinkIdx ) - { - LOG(fatal) << "CbmCern2017MonitorHodo::DoUnpack => " - << "eLink index out of bounds!"; - } // if( fuNbElinksPerDpb <= usElinkIdx ) - UInt_t uAsicIdx = fvuElinkToAsic[fuCurrDpbIdx][usElinkIdx]; - - stsxyter::BetaMessType typeMess = mess.GetMessType(); - fmMsgCounter[ typeMess ] ++; - fhHodoMessType->Fill( static_cast< uint16_t > (typeMess) ); - fhHodoMessTypePerDpb->Fill( fuCurrDpbIdx, static_cast< uint16_t > (typeMess) ); - fhHodoMessTypePerElink->Fill( fuCurrDpbIdx * fuNbElinksPerDpb + usElinkIdx, - static_cast< uint16_t > (typeMess) ); - - switch( typeMess ) - { - case stsxyter::BetaMessType::Hit : - { - FillHitInfo( mess, usElinkIdx, uAsicIdx, m ); - break; - } // case stsxyter::BetaMessType::Hit : - case stsxyter::BetaMessType::TsMsb : - { - FillTsMsbInfo( mess, usElinkIdx, uAsicIdx ); - break; - } // case stsxyter::BetaMessType::TsMsb : - case stsxyter::BetaMessType::Dummy : - { - if( kTRUE == fbBetaFormat ) - { - // In beta data format, a dummy hit indicates a TS overflow => TS_MSB increase by 1 - fvuCurrentTsMsb[fuCurrDpbIdx][0] ++; - fvuElinkLastTsHit[fuCurrDpbIdx][0] = 0; - } // if( kTRUE == fbBetaFormat ) - break; - } // case stsxyter::BetaMessType::Dummy / ReadDataAck / Ack : - default: - { - LOG(fatal) << "CbmCern2017MonitorHodo::DoUnpack => " - << "Unknown message type, should never happen, stopping here!"; - } - } // switch( mess.GetMessType() ) - } // for( uint32_t uIdx = 0; uIdx < uNbMessages; ++uIdx ) - } // for( size_t m = 0; m < numCompMsInTs; ++m ) - - - // End of TS, check if stuff to do with the hits inside each MS - // Usefull for low rate pulser tests - // Need to do it only when last DPB is processed, as they are done one by one - if( fuCurrDpbIdx == fuNrOfDpbs - 1 ) - { - for( UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx ) - { - std::vector< Bool_t> bHodo1X( fuNbChanPerAsic/2, kFALSE); - std::vector< Bool_t> bHodo1Y( fuNbChanPerAsic/2, kFALSE); - std::vector< Bool_t> bHodo2X( fuNbChanPerAsic/2, kFALSE); - std::vector< Bool_t> bHodo2Y( fuNbChanPerAsic/2, kFALSE); - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - if( fUnpackPar->GetAsicIndexHodo1() == uXyterIdx ) - { - // Hodo 1 - // Loop on one Axis - for( UInt_t uChan = 0; uChan < fuNbChanPerAsic/2; ++uChan ) - if( fvuChanNbHitsInMs[ uXyterIdx ][ uChan ][ uMsIdx ] ) - // Loop on Second axis - for( UInt_t uChanB = fuNbChanPerAsic/2; uChanB < fuNbChanPerAsic; ++uChanB ) - if( fvuChanNbHitsInMs[ uXyterIdx ][ uChanB ][ uMsIdx ] ) - { - if( fUnpackPar->IsXySwappedHodo1() ) - { - // Maybe add cross check for invalide mapping index! - bHodo1X[ fUnpackPar->GetChannelToFiberMap( uChanB ) ] = kTRUE; - bHodo1Y[ fUnpackPar->GetChannelToFiberMap( uChan ) ] = kTRUE; - } // if( fUnpackPar->IsXySwappedHodo1() ) - else - { - // Maybe add cross check for invalide mapping index! - bHodo1X[ fUnpackPar->GetChannelToFiberMap( uChan ) ] = kTRUE; - bHodo1Y[ fUnpackPar->GetChannelToFiberMap( uChanB ) ] = kTRUE; - } // else of if( fUnpackPar->IsXySwappedHodo1() ) - } // if( fvuChanNbHitsInMs[ uXyterIdx ][ uChanB ][ uMsIdx ] ) - } // if( fUnpackPar->GetAsicIndexHodo1() == uXyterIdx ) - else if( fUnpackPar->GetAsicIndexHodo2() == uXyterIdx ) - { - // Hodo 2 - // Loop on one Axis - for( UInt_t uChan = 0; uChan < fuNbChanPerAsic/2; ++uChan ) - if( fvuChanNbHitsInMs[ uXyterIdx ][ uChan ][ uMsIdx ] ) - // Loop on Second axis - for( UInt_t uChanB = fuNbChanPerAsic/2; uChanB < fuNbChanPerAsic; ++uChanB ) - if( fvuChanNbHitsInMs[ uXyterIdx ][ uChanB ][ uMsIdx ] ) - { - if( fUnpackPar->IsXySwappedHodo2() ) - { - // Maybe add cross check for invalide mapping index! - bHodo2X[ fUnpackPar->GetChannelToFiberMap( uChanB ) ] = kTRUE; - bHodo2Y[ fUnpackPar->GetChannelToFiberMap( uChan ) ] = kTRUE; - } // if( fUnpackPar->IsXySwappedHodo2() ) - else - { - // Maybe add cross check for invalide mapping index! - bHodo2X[ fUnpackPar->GetChannelToFiberMap( uChan ) ] = kTRUE; - bHodo2Y[ fUnpackPar->GetChannelToFiberMap( uChanB ) ] = kTRUE; - } // else of if( fUnpackPar->IsXySwappedHodo2() ) - } // if( fvuChanNbHitsInMs[ uXyterIdx ][ uChanB ][ uMsIdx ] ) - } // else if( fUnpackPar->GetAsicIndexHodo2() == uXyterIdx ) -/* - for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - { - fhHodoChanHitsPerMs[uXyterIdx]->Fill( fvuChanNbHitsInMs[ uXyterIdx ][ uChan ][ uMsIdx ], uChan ); - - // Coincidences between - if( fvuChanNbHitsInMs[ uXyterIdx ][ uChan ][ uMsIdx ] ) - for( UInt_t uChanB = uChan + 1; uChanB < fuNbChanPerAsic; ++uChanB ) - if( fvuChanNbHitsInMs[ uXyterIdx ][ uChanB ][ uMsIdx ] ) - { - fhHodoChanSameMs[ uXyterIdx ]->Fill( uChan, uChanB ); - Double_t dTimeDiff = fvdChanLastHitTimeInMs[ uXyterIdx ][ uChanB ][ uMsIdx ] - - fvdChanLastHitTimeInMs[ uXyterIdx ][ uChan ][ uMsIdx ]; - - fpStsChanSameMsTimeDiff[ uXyterIdx ]->Fill( uChan, uChanB, dTimeDiff ); - } // if( fvuChanNbHitsInMs[ uXyterIdx ][ uChanB ] ) - // Ok to reset as we only compare to channels with higher indices (or channels in ASICs with higher indices) - fvuChanNbHitsInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = 0; - fvdChanLastHitTimeInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = -1.0; - fvusChanLastHitAdcInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = 0; - } // for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) -*/ - for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - { - // Reset counters - fvuChanNbHitsInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = 0; - fvdChanLastHitTimeInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = -1.0; - fvusChanLastHitAdcInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = 0; - } // for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - - Bool_t bHitInHodo1X = kFALSE; - Bool_t bHitInHodo1Y = kFALSE; - Bool_t bHitInHodo2X = kFALSE; - Bool_t bHitInHodo2Y = kFALSE; - for( UInt_t uChan = 0; uChan < fuNbChanPerAsic/2; ++uChan ) - { - if( bHodo1X[ uChan ] ) - bHitInHodo1X = kTRUE; - - if( bHodo1Y[ uChan ] ) - bHitInHodo1Y = kTRUE; - - if( bHodo2X[ uChan ] ) - bHitInHodo2X = kTRUE; - - if( bHodo2Y[ uChan ] ) - bHitInHodo2Y = kTRUE; - - for( UInt_t uChanB = 0; uChanB < fuNbChanPerAsic/2; ++uChanB ) - { - if( bHodo1X[ uChan ] && bHodo1Y[ uChanB ] ) - fhHodoSameMs1XY->Fill( uChan, uChanB); - - if( bHodo2X[ uChan ] && bHodo2Y[ uChanB ] ) - fhHodoSameMs2XY->Fill( uChan, uChanB ); - - if( bHodo1X[ uChan ] && bHodo2X[ uChanB ] ) - fhHodoSameMsX1X2->Fill( uChan, uChanB ); - - if( bHodo1Y[ uChan ] && bHodo2Y[ uChanB ] ) - fhHodoSameMsY1Y2->Fill( uChan, uChanB ); - - if( bHodo1X[ uChan ] && bHodo2Y[ uChanB ] ) - fhHodoSameMsX1Y2->Fill( uChan, uChanB ); - - if( bHodo1Y[ uChan ] && bHodo2X[ uChanB ] ) - fhHodoSameMsY1X2->Fill( uChan, uChanB ); - } // for( UInt_t uChanB = 0; uChanB < fuNbChanPerAsic/2; ++uChanB ) - } // for( UInt_t uChan = 0; uChan < fuNbChanPerAsic/2; ++uChan ) - - if( bHitInHodo1X && bHitInHodo1Y ) - fhHodoSameMsCntEvoX1Y1->Fill( fvdMsTime[ uMsIdx ] - fdStartTimeMsSz ); - - if( bHitInHodo2X && bHitInHodo2Y ) - fhHodoSameMsCntEvoX2Y2->Fill( fvdMsTime[ uMsIdx ] - fdStartTimeMsSz ); - - if( bHitInHodo1X && bHitInHodo2X ) - fhHodoSameMsCntEvoX1X2->Fill( fvdMsTime[ uMsIdx ] - fdStartTimeMsSz ); - - if( bHitInHodo1Y && bHitInHodo2Y ) - fhHodoSameMsCntEvoY1Y2->Fill( fvdMsTime[ uMsIdx ] - fdStartTimeMsSz ); - - if( bHitInHodo1X && bHitInHodo2Y ) - fhHodoSameMsCntEvoX1Y2->Fill( fvdMsTime[ uMsIdx ] - fdStartTimeMsSz ); - - if( bHitInHodo1Y && bHitInHodo2X ) - fhHodoSameMsCntEvoY1X2->Fill( fvdMsTime[ uMsIdx ] - fdStartTimeMsSz ); - - if( bHitInHodo1X && bHitInHodo1Y && bHitInHodo2X && bHitInHodo2Y) - fhHodoSameMsCntEvoX1Y1X2Y2->Fill( fvdMsTime[ uMsIdx ] - fdStartTimeMsSz ); - - fvdMsTime[ uMsIdx ] = 0.0; - } // for( UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx ) - - - // Time differences plotting using the fully time sorted hits - if( 0 < fvmHitsInTs.size() ) - { - ULong64_t ulLastHitTime = ( *( fvmHitsInTs.rbegin() ) ).GetTs(); - std::multiset< stsxyter::BetaHit >::iterator it; - -// std::chrono::steady_clock::time_point tNow = std::chrono::steady_clock::now(); -// Double_t dUnixTimeInRun = std::chrono::duration_cast< std::chrono::seconds >(tNow - ftStartTimeUnix).count(); - - Double_t dCoincBorder = 50.0; // ns, +/- - - for( it = fvmHitsInTs.begin(); - it != fvmHitsInTs.end() && (*it).GetTs() < ulLastHitTime - 320; // 32 * 3.125 ns = 1000 ns - ++it ) - { - UShort_t usAsicIdx = (*it).GetAsic(); - UShort_t usChanIdx = (*it).GetChan(); - ULong64_t ulHitTs = (*it).GetTs(); - - Bool_t bHitInX = usChanIdx < fuNbChanPerAsic/2; - UInt_t uFiberIdx = fUnpackPar->GetChannelToFiberMap( usChanIdx ); - - if( fUnpackPar->GetAsicIndexHodo1() == usAsicIdx ) - { - if( fUnpackPar->IsXySwappedHodo1() ) - bHitInX = !bHitInX; - - if( bHitInX ) - { - fLastSortedHit1X = (*it); - - Double_t dDtX1Y1 = ( fLastSortedHit1Y.GetTs() - ulHitTs ) * stsxyter::kdBetaClockCycleNs; - Double_t dDtX1X2 = ( fLastSortedHit2X.GetTs() - ulHitTs ) * stsxyter::kdBetaClockCycleNs; - Double_t dDtX1Y2 = ( fLastSortedHit2Y.GetTs() - ulHitTs ) * stsxyter::kdBetaClockCycleNs; - - fhHodoSortedDtX1Y1->Fill( dDtX1Y1 ); - fhHodoSortedDtX1X2->Fill( dDtX1X2 ); - fhHodoSortedDtX1Y2->Fill( dDtX1Y2 ); - - if( TMath::Abs( dDtX1Y1 ) < dCoincBorder ) - fhHodoSortedMapX1Y1->Fill( uFiberIdx, fUnpackPar->GetChannelToFiberMap( fLastSortedHit1Y.GetChan() ) ); - if( TMath::Abs( dDtX1X2 ) < dCoincBorder ) - fhHodoSortedMapX1X2->Fill( uFiberIdx, fUnpackPar->GetChannelToFiberMap( fLastSortedHit2X.GetChan() ) ); - if( TMath::Abs( dDtX1Y2 ) < dCoincBorder ) - fhHodoSortedMapX1Y2->Fill( uFiberIdx, fUnpackPar->GetChannelToFiberMap( fLastSortedHit2Y.GetChan() ) ); - } // if( bHitInX ) - else - { - fLastSortedHit1Y = (*it); - - Double_t dDtX1Y1 = ( ulHitTs - fLastSortedHit1X.GetTs() ) * stsxyter::kdBetaClockCycleNs; - Double_t dDtY1Y2 = ( fLastSortedHit2Y.GetTs() - ulHitTs ) * stsxyter::kdBetaClockCycleNs; - Double_t dDtY1X2 = ( fLastSortedHit2X.GetTs() - ulHitTs ) * stsxyter::kdBetaClockCycleNs; - - fhHodoSortedDtX1Y1->Fill( dDtX1Y1 ); - fhHodoSortedDtY1Y2->Fill( dDtY1Y2 ); - fhHodoSortedDtY1X2->Fill( dDtY1X2 ); - - if( TMath::Abs( dDtX1Y1 ) < dCoincBorder ) - fhHodoSortedMapX1Y1->Fill( fUnpackPar->GetChannelToFiberMap( fLastSortedHit1X.GetChan() ), uFiberIdx ); - if( TMath::Abs( dDtY1Y2 ) < dCoincBorder ) - fhHodoSortedMapY1Y2->Fill( uFiberIdx, fUnpackPar->GetChannelToFiberMap( fLastSortedHit2Y.GetChan() ) ); - if( TMath::Abs( dDtY1X2 ) < dCoincBorder ) - fhHodoSortedMapY1X2->Fill( uFiberIdx, fUnpackPar->GetChannelToFiberMap( fLastSortedHit2X.GetChan() ) ); - } // else of if( bHitInX ) - } // if( fUnpackPar->GetAsicIndexHodo1() == usAsicIdx ) - else if( fUnpackPar->GetAsicIndexHodo2() == usAsicIdx ) - { - if( fUnpackPar->IsXySwappedHodo2() ) - bHitInX = !bHitInX; - - if( bHitInX ) - { - fLastSortedHit2X = (*it); - - Double_t dDtX2Y2 = ( fLastSortedHit2Y.GetTs() - ulHitTs ) * stsxyter::kdBetaClockCycleNs; - Double_t dDtX1X2 = ( ulHitTs - fLastSortedHit1X.GetTs() ) * stsxyter::kdBetaClockCycleNs; - Double_t dDtY1X2 = ( ulHitTs - fLastSortedHit1Y.GetTs() ) * stsxyter::kdBetaClockCycleNs; - - fhHodoSortedDtX2Y2->Fill( dDtX2Y2 ); - fhHodoSortedDtX1X2->Fill( dDtX1X2 ); - fhHodoSortedDtY1X2->Fill( dDtY1X2 ); - - if( TMath::Abs( dDtX2Y2 ) < dCoincBorder ) - fhHodoSortedMapX2Y2->Fill( uFiberIdx, fUnpackPar->GetChannelToFiberMap( fLastSortedHit2Y.GetChan() ) ); - if( TMath::Abs( dDtX1X2 ) < dCoincBorder ) - fhHodoSortedMapX1X2->Fill( fUnpackPar->GetChannelToFiberMap( fLastSortedHit1X.GetChan() ), uFiberIdx ); - if( TMath::Abs( dDtY1X2 ) < dCoincBorder ) - fhHodoSortedMapY1X2->Fill( fUnpackPar->GetChannelToFiberMap( fLastSortedHit1Y.GetChan() ), uFiberIdx ); - } // if( bHitInX ) - else - { - fLastSortedHit2Y = (*it); - - Double_t dDtX2Y2 = ( ulHitTs - fLastSortedHit1X.GetTs() ) * stsxyter::kdBetaClockCycleNs; - Double_t dDtY1Y2 = ( ulHitTs - fLastSortedHit1Y.GetTs() ) * stsxyter::kdBetaClockCycleNs; - Double_t dDtX1Y2 = ( ulHitTs - fLastSortedHit2X.GetTs() ) * stsxyter::kdBetaClockCycleNs; - - fhHodoSortedDtX2Y2->Fill( dDtX2Y2 ); - fhHodoSortedDtY1Y2->Fill( dDtY1Y2 ); - fhHodoSortedDtX1Y2->Fill( dDtX1Y2 ); - - if( TMath::Abs( dDtX2Y2 ) < dCoincBorder ) - fhHodoSortedMapX2Y2->Fill( fUnpackPar->GetChannelToFiberMap( fLastSortedHit2X.GetChan() ), uFiberIdx ); - if( TMath::Abs( dDtY1Y2 ) < dCoincBorder ) - fhHodoSortedMapY1Y2->Fill( fUnpackPar->GetChannelToFiberMap( fLastSortedHit1Y.GetChan() ), uFiberIdx ); - if( TMath::Abs( dDtX1Y2 ) < dCoincBorder ) - fhHodoSortedMapX1Y2->Fill( fUnpackPar->GetChannelToFiberMap( fLastSortedHit1X.GetChan() ), uFiberIdx ); - } // else of if( bHitInX ) - } // else if( fUnpackPar->GetAsicIndexHodo2() == usAsicIdx ) - } // loop on hits untils hits within 100 ns of last one or last one itself are reached - - // Remove all hits which were already used - fvmHitsInTs.erase( fvmHitsInTs.begin(), it ); - } // if( 0 < fvmHitsInTs.size() ) - } // if( fuCurrDpbIdx == fuNrOfDpbs - 1 ) - - if( kTRUE == fbBetaFormat && 0 == ts.index() % 1000 && fuCurrDpbIdx == fuNrOfDpbs - 1) - { - for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - LOG(info) << "eDPB " << std::setw(2) << uDpb - << " eLink " << std::setw(2) << 0 - << " current TS cycle counter is " << std::setw(12) << fvuCurrentTsMsb[uDpb][0] - << "\n" - << " current sorted buffer size is " << fvmHitsInTs.size() - << " First hit TS is " << ( *( fvmHitsInTs.begin() ) ).GetTs() - << " Last hit TS is " << ( *( fvmHitsInTs.rbegin() ) ).GetTs(); - - } // if( kTRUE == fbBetaFormat && 0 == ts.descriptor.index % 10000 ) - - return kTRUE; -} - -void CbmCern2017MonitorHodo::FillHitInfo( stsxyter::BetaMessage mess, const UShort_t & usElinkIdx, const UInt_t & uAsicIdx, const UInt_t & uMsIdx ) -{ - UShort_t usChan = mess.GetHitChannel(); - UShort_t usRawAdc = mess.GetHitAdc(); -// UShort_t usFullTs = mess.GetHitTimeFull(); -// UShort_t usTsOver = mess.GetHitTimeOver(); - UShort_t usRawTs = mess.GetHitTime(); - - fhHodoChanCntRaw[ uAsicIdx ]->Fill( usChan ); - fhHodoChanAdcRaw[ uAsicIdx ]->Fill( usChan, usRawAdc ); - fhHodoChanAdcRawProf[ uAsicIdx ]->Fill( usChan, usRawAdc ); - fhHodoChanRawTs[ uAsicIdx ]->Fill( usChan, usRawTs ); - fhHodoChanMissEvt[ uAsicIdx ]->Fill( usChan, mess.IsHitMissedEvts() ); - - // Use TS w/o overlap bits as they will anyway come from the TS_MSB - fvulChanLastHitTime[ uAsicIdx ][ usChan ] = usRawTs; - - -// if( usRawTs < fvuElinkLastTsHit[fuCurrDpbIdx][usElinkIdx] ) -// fvuCurrentTsMsb[fuCurrDpbIdx][usElinkIdx]++; - - fvulChanLastHitTime[ uAsicIdx ][ usChan ] += - static_cast<ULong64_t>( stsxyter::kuBetaHitNbTsBins ) - * static_cast<ULong64_t>( fvuCurrentTsMsb[fuCurrDpbIdx][0]); - - fvuElinkLastTsHit[fuCurrDpbIdx][usElinkIdx] = usRawTs; - - // Convert the Hit time in bins to Hit time in ns - Double_t dHitTimeNs = fvulChanLastHitTime[ uAsicIdx ][ usChan ] * stsxyter::kdBetaClockCycleNs; - - // Store new value of Hit time in ns - fvdChanLastHitTime[ uAsicIdx ][ usChan ] = fvulChanLastHitTime[ uAsicIdx ][ usChan ]; - - // Pulser and MS - fvuChanNbHitsInMs[ uAsicIdx ][ usChan ][ uMsIdx ] ++; - fvdChanLastHitTimeInMs[ uAsicIdx ][ usChan ][ uMsIdx ] = dHitTimeNs; - fvusChanLastHitAdcInMs[ uAsicIdx ][ usChan ][ uMsIdx ] = usRawAdc; - fvmChanHitsInTs[ uAsicIdx ][ usChan ].insert( stsxyter::BetaHit( fvulChanLastHitTime[ uAsicIdx ][ usChan ], usRawAdc ) ); - fvmHitsInTs.insert( stsxyter::BetaHit( fvulChanLastHitTime[ uAsicIdx ][ usChan ], usRawAdc, uAsicIdx, usChan ) ); - - // Check Starting point of histos with time as X axis - if( -1 == fdStartTime ) - fdStartTime = fvdChanLastHitTime[ uAsicIdx ][ usChan ]; - - // Fill histos with time as X axis - Double_t dTimeSinceStartSec = (fvdChanLastHitTime[ uAsicIdx ][ usChan ] - fdStartTime)* 1e-9; - Double_t dTimeSinceStartMin = dTimeSinceStartSec / 60.0; - fhHodoChanHitRateEvo[ uAsicIdx ]->Fill( dTimeSinceStartSec , usChan ); - fhHodoFebRateEvo[ uAsicIdx ]->Fill( dTimeSinceStartSec ); - fhHodoChanHitRateEvoLong[ uAsicIdx ]->Fill( dTimeSinceStartMin, usChan, 1.0/60.0 ); - fhHodoFebRateEvoLong[ uAsicIdx ]->Fill( dTimeSinceStartMin, 1.0/60.0 ); -/* - if( kTRUE == fbLongHistoEnable ) - { - std::chrono::steady_clock::time_point tNow = std::chrono::steady_clock::now(); - Double_t dUnixTimeInRun = std::chrono::duration_cast< std::chrono::seconds >(tNow - ftStartTimeUnix).count(); - fhFebRateEvoLong[ uAsicIdx ]->Fill( dUnixTimeInRun , 1.0 / fuLongHistoBinSizeSec ); - fhFebChRateEvoLong[ uAsicIdx ]->Fill( dUnixTimeInRun , usChan, 1.0 / fuLongHistoBinSizeSec ); - } // if( kTRUE == fbLongHistoEnable ) -*/ - // Fill histos for single Hodos - UInt_t uFiberInHodo = fUnpackPar->GetChannelToFiberMap( usChan ); - if( fUnpackPar->GetAsicIndexHodo1() == uAsicIdx ) - { - // Hodo 1 - if( fUnpackPar->GetChannelToPlaneMapHodo1( usChan ) ) - { - // Y - fhHodoChanCounts1Y->Fill( uFiberInHodo ); - fhHodoChanAdcRaw1Y->Fill( uFiberInHodo, usRawAdc ); - fhHodoChanHitRateEvo1Y->Fill( dTimeSinceStartMin, uFiberInHodo, 1.0/60.0 ); - fhHodoRateEvo1Y->Fill( dTimeSinceStartMin, 1.0/60.0 ); - } // if( fUnpackPar->GetChannelToPlaneMapHodo1( usChan ) ) - else - { - // X - fhHodoChanCounts1X->Fill( uFiberInHodo ); - fhHodoChanAdcRaw1X->Fill( uFiberInHodo, usRawAdc ); - fhHodoChanHitRateEvo1X->Fill( dTimeSinceStartMin, uFiberInHodo, 1.0/60.0 ); - fhHodoRateEvo1X->Fill( dTimeSinceStartMin, 1.0/60.0 ); - } // else of if( fUnpackPar->GetChannelToPlaneMapHodo1( usChan ) ) - } // if( fUnpackPar->GetAsicIndexHodo1() == uAsicIdx ) - else if( fUnpackPar->GetAsicIndexHodo2() == uAsicIdx ) - { - // Hodo 2 - if( fUnpackPar->GetChannelToPlaneMapHodo2( usChan ) ) - { - // Y - fhHodoChanCounts2Y->Fill( uFiberInHodo ); - fhHodoChanAdcRaw2Y->Fill( uFiberInHodo, usRawAdc ); - fhHodoChanHitRateEvo2Y->Fill( dTimeSinceStartMin, uFiberInHodo, 1.0/60.0 ); - fhHodoRateEvo2Y->Fill( dTimeSinceStartMin, 1.0/60.0 ); - } // if( fUnpackPar->GetChannelToPlaneMapHodo2( usChan ) ) - else - { - // X - fhHodoChanCounts2X->Fill( uFiberInHodo ); - fhHodoChanAdcRaw2X->Fill( uFiberInHodo, usRawAdc ); - fhHodoChanHitRateEvo2X->Fill( dTimeSinceStartMin, uFiberInHodo, 1.0/60.0 ); - fhHodoRateEvo2X->Fill( dTimeSinceStartMin, 1.0/60.0 ); - } // else of if( fUnpackPar->GetChannelToPlaneMapHodo2( usChan ) ) - } // else if( fUnpackPar->GetAsicIndexHodo2() == uAsicIdx ) - -} - -void CbmCern2017MonitorHodo::FillTsMsbInfo( stsxyter::BetaMessage mess, const UShort_t & usElinkIdx, const UInt_t & uAsicIdx ) -{ - UShort_t usVal = mess.GetTsMsbVal(); - - // Update Status counters - if( usVal < fvuCurrentTsMsb[fuCurrDpbIdx][usElinkIdx] ) - fvuCurrentTsMsbCycle[fuCurrDpbIdx][usElinkIdx] ++; - fvuCurrentTsMsb[fuCurrDpbIdx][usElinkIdx] = usVal; - - fhHodoFebTsMsb->Fill( fvuCurrentTsMsb[fuCurrDpbIdx][usElinkIdx], uAsicIdx ); - - // Update the overlap bits for this eLink - fvuCurrentTsMsbOver[fuCurrDpbIdx][usElinkIdx] = fvuCurrentTsMsb[fuCurrDpbIdx][usElinkIdx] - & stsxyter::kusBetaMaskTsMsbOver; -} - -void CbmCern2017MonitorHodo::Reset() -{ -} - -void CbmCern2017MonitorHodo::Finish() -{ - - LOG(info) << "-------------------------------------"; - LOG(info) << "CbmCern2017MonitorHodo statistics are "; - LOG(info) << " Hit messages: " << fmMsgCounter[ stsxyter::BetaMessType::Hit ] << "\n" - << " Ts MSB messages: " << fmMsgCounter[ stsxyter::BetaMessType::TsMsb ] << "\n" - << " Dummy messages: " << fmMsgCounter[ stsxyter::BetaMessType::Dummy ]; - - LOG(info) << "-------------------------------------"; - - SaveAllHistos(); - -} - - -void CbmCern2017MonitorHodo::FillOutput(boost::any) -{ -} - -void CbmCern2017MonitorHodo::SaveAllHistos( TString sFileName ) -{ - TDirectory * oldDir = NULL; - TFile * histoFile = NULL; - if( "" != sFileName ) - { - // Store current directory position to allow restore later - oldDir = gDirectory; - // open separate histo file in recreate mode - histoFile = new TFile( sFileName , "RECREATE"); - histoFile->cd(); - } // if( "" != sFileName ) - - gDirectory->mkdir("Sts_Raw"); - gDirectory->cd("Sts_Raw"); - - fhHodoMessType->Write(); - fhHodoSysMessType->Write(); - fhHodoMessTypePerDpb->Write(); - fhHodoSysMessTypePerDpb->Write(); - fhHodoMessTypePerElink->Write(); - fhHodoSysMessTypePerElink->Write(); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fhHodoChanCntRaw[ uXyterIdx ]->Write(); - fhHodoChanAdcRaw[ uXyterIdx ]->Write(); - fhHodoChanAdcRawProf[ uXyterIdx ]->Write(); - fhHodoChanRawTs[ uXyterIdx ]->Write(); - fhHodoChanMissEvt[ uXyterIdx ]->Write(); - fhHodoChanHitRateEvo[ uXyterIdx ]->Write(); - fhHodoFebRateEvo[ uXyterIdx ]->Write(); - fhHodoChanHitRateEvoLong[ uXyterIdx ]->Write(); - fhHodoFebRateEvoLong[ uXyterIdx ]->Write(); -/* - if( kTRUE == fbLongHistoEnable ) - { - fhFebRateEvoLong[ uXyterIdx ]->Write(); - fhFebChRateEvoLong[ uXyterIdx ]->Write(); - } // if( kTRUE == fbLongHistoEnable ) -*/ - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - - fhHodoChanCounts1X->Write(); - fhHodoChanCounts1Y->Write(); - fhHodoChanCounts2X->Write(); - fhHodoChanCounts2Y->Write(); - fhHodoChanAdcRaw1X->Write(); - fhHodoChanAdcRaw1Y->Write(); - fhHodoChanAdcRaw2X->Write(); - fhHodoChanAdcRaw2Y->Write(); - fhHodoChanHitRateEvo1X->Write(); - fhHodoChanHitRateEvo1Y->Write(); - fhHodoChanHitRateEvo2X->Write(); - fhHodoChanHitRateEvo2Y->Write(); - fhHodoRateEvo1X->Write(); - fhHodoRateEvo1Y->Write(); - fhHodoRateEvo1X->Write(); - fhHodoRateEvo2Y->Write(); - fhHodoSameMs1XY->Write(); - fhHodoSameMs2XY->Write(); - fhHodoSameMsX1X2->Write(); - fhHodoSameMsY1Y2->Write(); - fhHodoSameMsX1Y2->Write(); - fhHodoSameMsY1X2->Write(); - - fhHodoSameMsCntEvoX1Y1->Write(); - fhHodoSameMsCntEvoX2Y2->Write(); - fhHodoSameMsCntEvoX1X2->Write(); - fhHodoSameMsCntEvoY1Y2->Write(); - fhHodoSameMsCntEvoX1Y2->Write(); - fhHodoSameMsCntEvoY1X2->Write(); - fhHodoSameMsCntEvoX1Y1X2Y2->Write(); - - fhHodoSortedDtX1Y1->Write(); - fhHodoSortedDtX2Y2->Write(); - fhHodoSortedDtX1X2->Write(); - fhHodoSortedDtY1Y2->Write(); - fhHodoSortedDtX1Y2->Write(); - fhHodoSortedDtY1X2->Write(); - fhHodoSortedMapX1Y1->Write(); - fhHodoSortedMapX2Y2->Write(); - fhHodoSortedMapX1X2->Write(); - fhHodoSortedMapY1Y2->Write(); - fhHodoSortedMapX1Y2->Write(); - fhHodoSortedMapY1X2->Write(); - - fhHodoFebTsMsb->Write(); - - gDirectory->cd(".."); - - // Flib Histos - gDirectory->mkdir("Flib_Raw"); - gDirectory->cd("Flib_Raw"); - for( UInt_t uLinks = 0; uLinks < kiMaxNbFlibLinks; uLinks ++) - { - TString sMsSzName = Form("MsSz_link_%02u", uLinks); - if( fHM->Exists(sMsSzName.Data() ) ) - fHM->H1( sMsSzName.Data() )->Write(); - - sMsSzName = Form("MsSzTime_link_%02u", uLinks); - if( fHM->Exists(sMsSzName.Data() ) ) - fHM->P1( sMsSzName.Data() )->Write(); - } // for( UInt_t uLinks = 0; uLinks < 16; uLinks ++) - gDirectory->cd(".."); - - if( "" != sFileName ) - { - // Restore original directory position - histoFile->Close(); - oldDir->cd(); - } // if( "" != sFileName ) - -} -void CbmCern2017MonitorHodo::ResetAllHistos() -{ - LOG(info) << "Reseting all STS histograms."; - - fhHodoMessType->Reset(); - fhHodoSysMessType->Reset(); - fhHodoMessTypePerDpb->Reset(); - fhHodoSysMessTypePerDpb->Reset(); - fhHodoMessTypePerElink->Reset(); - fhHodoSysMessTypePerElink->Reset(); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fhHodoChanCntRaw[ uXyterIdx ]->Reset(); - fhHodoChanAdcRaw[ uXyterIdx ]->Reset(); - fhHodoChanAdcRawProf[ uXyterIdx ]->Reset(); - fhHodoChanRawTs[ uXyterIdx ]->Reset(); - fhHodoChanMissEvt[ uXyterIdx ]->Reset(); - fhHodoChanHitRateEvo[ uXyterIdx ]->Reset(); - fhHodoFebRateEvo[ uXyterIdx ]->Reset(); - fhHodoChanHitRateEvoLong[ uXyterIdx ]->Reset(); - fhHodoFebRateEvoLong[ uXyterIdx ]->Reset(); -/* - if( kTRUE == fbLongHistoEnable ) - { - ftStartTimeUnix = std::chrono::steady_clock::now(); - fhFebRateEvoLong[ uXyterIdx ]->Reset(); - fhFebChRateEvoLong[ uXyterIdx ]->Reset(); - } // if( kTRUE == fbLongHistoEnable ) -*/ - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - - fhHodoChanCounts1X->Reset(); - fhHodoChanCounts1Y->Reset(); - fhHodoChanCounts2X->Reset(); - fhHodoChanCounts2Y->Reset(); - fhHodoChanAdcRaw1X->Reset(); - fhHodoChanAdcRaw1Y->Reset(); - fhHodoChanAdcRaw2X->Reset(); - fhHodoChanAdcRaw2Y->Reset(); - fhHodoChanHitRateEvo1X->Reset(); - fhHodoChanHitRateEvo1Y->Reset(); - fhHodoChanHitRateEvo2X->Reset(); - fhHodoChanHitRateEvo2Y->Reset(); - fhHodoRateEvo1X->Reset(); - fhHodoRateEvo1Y->Reset(); - fhHodoRateEvo1X->Reset(); - fhHodoRateEvo2Y->Reset(); - fhHodoSameMs1XY->Reset(); - fhHodoSameMs2XY->Reset(); - fhHodoSameMsX1X2->Reset(); - fhHodoSameMsY1Y2->Reset(); - fhHodoSameMsX1Y2->Reset(); - fhHodoSameMsY1X2->Reset(); - - fhHodoSameMsCntEvoX1Y1->Reset(); - fhHodoSameMsCntEvoX2Y2->Reset(); - fhHodoSameMsCntEvoX1X2->Reset(); - fhHodoSameMsCntEvoY1Y2->Reset(); - fhHodoSameMsCntEvoX1Y2->Reset(); - fhHodoSameMsCntEvoY1X2->Reset(); - fhHodoSameMsCntEvoX1Y1X2Y2->Reset(); - - fhHodoSortedDtX1Y1->Reset(); - fhHodoSortedDtX2Y2->Reset(); - fhHodoSortedDtX1X2->Reset(); - fhHodoSortedDtY1Y2->Reset(); - fhHodoSortedDtX1Y2->Reset(); - fhHodoSortedDtY1X2->Reset(); - fhHodoSortedMapX1Y1->Reset(); - fhHodoSortedMapX2Y2->Reset(); - fhHodoSortedMapX1X2->Reset(); - fhHodoSortedMapY1Y2->Reset(); - fhHodoSortedMapX1Y2->Reset(); - fhHodoSortedMapY1X2->Reset(); - - fhHodoFebTsMsb->Reset(); - - for( UInt_t uLinks = 0; uLinks < kiMaxNbFlibLinks; ++uLinks ) - { - TString sMsSzName = Form("MsSz_link_%02u", uLinks); - if( fHM->Exists(sMsSzName.Data() ) ) - fHM->H1( sMsSzName.Data() )->Reset(); - - sMsSzName = Form("MsSzTime_link_%02u", uLinks); - if( fHM->Exists(sMsSzName.Data() ) ) - fHM->P1( sMsSzName.Data() )->Reset(); - } // for( UInt_t uLinks = 0; uLinks < kiMaxNbFlibLinks; ++uLinks ) - - fdStartTime = -1; - fdStartTimeMsSz = -1; -} - -void CbmCern2017MonitorHodo::SetRunStart( Int_t dateIn, Int_t timeIn, Int_t iBinSize ) -{ - TDatime * fRunStartDateTime = new TDatime( dateIn, timeIn); - fiRunStartDateTimeSec = fRunStartDateTime->Convert(); - fiBinSizeDatePlots = iBinSize; - - LOG(info) << "Assigned new MUCH Run Start Date-Time: " << fRunStartDateTime->AsString(); -} - -void CbmCern2017MonitorHodo::SetLongDurationLimits( UInt_t uDurationSeconds, UInt_t uBinSize ) -{ - fbLongHistoEnable = kTRUE; - fuLongHistoNbSeconds = uDurationSeconds; - fuLongHistoBinSizeSec = uBinSize; -} - -ClassImp(CbmCern2017MonitorHodo) diff --git a/beamtime/cern2017/unpacker/CbmCern2017MonitorHodo.h b/beamtime/cern2017/unpacker/CbmCern2017MonitorHodo.h deleted file mode 100644 index 05e2940050e74b9f46251eb29ea0a76e0e432932..0000000000000000000000000000000000000000 --- a/beamtime/cern2017/unpacker/CbmCern2017MonitorHodo.h +++ /dev/null @@ -1,209 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmCern2017MonitorHodo ----- -// ----- Created 14/12/17 by P.-A. Loizeau ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CBMCERN2017MONITORHODO_H -#define CBMCERN2017MONITORHODO_H - -#include "Timeslice.hpp" - -// Data -#include "StsXyterBetaMessage.h" -#include "StsXyterBetaHit.h" - -// CbmRoot -#include "CbmTSUnpack.h" -#include "CbmHistManager.h" - -// C++11 -#include <chrono> - -// C/C++ -#include <vector> -#include <set> -#include <map> - -class CbmCern2017UnpackParHodo; - -class CbmCern2017MonitorHodo: public CbmTSUnpack -{ -public: - - CbmCern2017MonitorHodo(); - virtual ~CbmCern2017MonitorHodo(); - - virtual Bool_t Init(); - - virtual Bool_t DoUnpack(const fles::Timeslice& ts, size_t component); - - virtual void Reset(); - - virtual void Finish(); - - void SetParContainers(); - - Bool_t InitContainers(); - - Bool_t ReInitContainers(); - - void FillOutput(boost::any); - - void SetRunStart( Int_t dateIn, Int_t timeIn, Int_t iBinSize = 5 ); - - void ResetAllHistos(); - void SaveAllHistos( TString sFileName = "" ); - - void SetMsOverlap(size_t uOverlapMsNb = 1) { fuOverlapMsNb = uOverlapMsNb; } - size_t GetMsOverlap() { return fuOverlapMsNb; } - - void SetPrintMessage( Bool_t bPrintMessOn = kTRUE, - stsxyter::BetaMessagePrintMask ctrl = stsxyter::BetaMessagePrintMask::msg_print_Hex | - stsxyter::BetaMessagePrintMask::msg_print_Human ) - { fbPrintMessages = bPrintMessOn; fPrintMessCtrl = ctrl; } - void SetLongDurationLimits( UInt_t uDurationSeconds = 3600, UInt_t uBinSize = 1 ); - void SetBetaFormatMode( Bool_t bEnable = kTRUE ) { fbBetaFormat = bEnable; } - -private: - size_t fuOverlapMsNb; /** Ignore Overlap Ms: all fuOverlapMsNb MS at the end of timeslice **/ - - // Parameters - CbmCern2017UnpackParHodo* fUnpackPar; //! - UInt_t fuNrOfDpbs; //! Total number of Sts DPBs in system - std::map<UInt_t, UInt_t> fDpbIdIndexMap; //! Map of DPB Identifier to DPB index - UInt_t fuNbElinksPerDpb; //! Number of possible eLinks per DPB - UInt_t fuNbStsXyters; //! Number of StsXyter ASICs - UInt_t fuNbChanPerAsic; //! Number of channels per StsXyter ASIC => should be constant somewhere!!!! - std::vector< std::vector< UInt_t > > fvuElinkToAsic; //! Vector holding for each link the corresponding ASIC index [fuNrOfDpbs * fuNbElinksPerDpb] - - // Constants - static const Int_t kiMaxNbFlibLinks = 16; - static const UInt_t kuBytesPerMessage = 4; - - // Internal Control/status of monitor - // Task configuration values - Bool_t fbPrintMessages; - stsxyter::BetaMessagePrintMask fPrintMessCtrl; - // Current data properties - std::map< stsxyter::BetaMessType, UInt_t > fmMsgCounter; - UInt_t fuCurrentEquipmentId; //! Current equipment ID, tells from which DPB the current MS is originating - UInt_t fuCurrDpbId; //! Temp holder until Current equipment ID is properly filled in MS - UInt_t fuCurrDpbIdx; //! Index of the DPB from which the MS currently unpacked is coming - Int_t fiRunStartDateTimeSec; //! Start of run time since "epoch" in s, for the plots with date as X axis - Int_t fiBinSizeDatePlots; //! Bin size in s for the plots with date as X axis -// std::vector< std::vector< UInt_t > > fvuCurrentTsMsb; //! Current TS MSB for each eLink - std::vector< std::vector< ULong64_t > > fvuCurrentTsMsb; //! Current TS MSB for each eLink - std::vector< std::vector< UInt_t > > fvuCurrentTsMsbCycle; //! Current TS MSB cycle for each eLink - std::vector< std::vector< UInt_t > > fvuCurrentTsMsbOver; //! Current TS MSB overlap bits for each eLink - std::vector< std::vector< ULong64_t > > fvulChanLastHitTime; //! Last hit time in bins for each Channel - std::vector< std::vector<Double_t> > fvdChanLastHitTime; //! Last hit time in ns for each Channel - std::vector< Double_t > fvdMsTime; //! Header time of each MS - std::vector< std::vector< std::vector< UInt_t > > > fvuChanNbHitsInMs; //! Number of hits in each MS for each Channel - std::vector< std::vector< std::vector< Double_t > > > fvdChanLastHitTimeInMs; //! Last hit time in bins in each MS for each Channel - std::vector< std::vector< std::vector< UShort_t > > > fvusChanLastHitAdcInMs; //! Last hit ADC in bins in each MS for each Channel - std::vector< std::vector< std::multiset< stsxyter::BetaHit > > > fvmChanHitsInTs; //! All hits (time & ADC) in bins in last TS for each Channel - // Starting state book-keeping - Double_t fdStartTime; /** Time of first valid hit (TS_MSB available), used as reference for evolution plots**/ - Double_t fdStartTimeMsSz; /** Time of first microslice, used as reference for evolution plots**/ - std::chrono::steady_clock::time_point ftStartTimeUnix; /** Time of run Start from UNIX system, used as reference for long evolution plots against reception time **/ - // Data format control - Bool_t fbBetaFormat; - std::vector< std::vector< UInt_t > > fvuElinkLastTsHit; //! TS from last hit for each eLink - // Hits time-sorting - std::multiset< stsxyter::BetaHit > fvmHitsInTs; //! All hits (time in bins, ADC in bins, asic, channel) in last TS, sorted by multiset with "<" operator - stsxyter::BetaHit fLastSortedHit1X; //! Last sorted hit for Hodo 1 X - stsxyter::BetaHit fLastSortedHit1Y; //! Last sorted hit for Hodo 1 Y - stsxyter::BetaHit fLastSortedHit2X; //! Last sorted hit for Hodo 2 X - stsxyter::BetaHit fLastSortedHit2Y; //! Last sorted hit for Hodo 2 Y - // Coincidence histos - UInt_t fuMaxNbMicroslices; - // Rate evolution histos - Bool_t fbLongHistoEnable; - UInt_t fuLongHistoNbSeconds; - UInt_t fuLongHistoBinSizeSec; - UInt_t fuLongHistoBinNb; - - // Histograms - CbmHistManager* fHM; //! Histogram manager - TH1* fhHodoMessType; - TH1* fhHodoSysMessType; - TH2* fhHodoMessTypePerDpb; - TH2* fhHodoSysMessTypePerDpb; - TH2* fhHodoMessTypePerElink; - TH2* fhHodoSysMessTypePerElink; - - std::vector<TH1 *> fhHodoChanCntRaw; - std::vector<TH2 *> fhHodoChanAdcRaw; - std::vector<TProfile*> fhHodoChanAdcRawProf; - std::vector<TH2*> fhHodoChanRawTs; - std::vector<TH2*> fhHodoChanMissEvt; - std::vector<TH2*> fhHodoChanHitRateEvo; - std::vector<TH1*> fhHodoFebRateEvo; - std::vector<TH2*> fhHodoChanHitRateEvoLong; - std::vector<TH1*> fhHodoFebRateEvoLong; - - TH1 * fhHodoChanCounts1X; - TH1 * fhHodoChanCounts1Y; - TH1 * fhHodoChanCounts2X; - TH1 * fhHodoChanCounts2Y; - TH2 * fhHodoChanAdcRaw1X; - TH2 * fhHodoChanAdcRaw1Y; - TH2 * fhHodoChanAdcRaw2X; - TH2 * fhHodoChanAdcRaw2Y; - TH2 * fhHodoChanHitRateEvo1X; - TH2 * fhHodoChanHitRateEvo1Y; - TH2 * fhHodoChanHitRateEvo2X; - TH2 * fhHodoChanHitRateEvo2Y; - TH1 * fhHodoRateEvo1X; - TH1 * fhHodoRateEvo1Y; - TH1 * fhHodoRateEvo2X; - TH1 * fhHodoRateEvo2Y; - TH2 * fhHodoSameMs1XY; - TH2 * fhHodoSameMs2XY; - TH2 * fhHodoSameMsX1X2; - TH2 * fhHodoSameMsY1Y2; - TH2 * fhHodoSameMsX1Y2; - TH2 * fhHodoSameMsY1X2; - - TH1 * fhHodoSameMsCntEvoX1Y1; - TH1 * fhHodoSameMsCntEvoX2Y2; - TH1 * fhHodoSameMsCntEvoX1X2; - TH1 * fhHodoSameMsCntEvoY1Y2; - TH1 * fhHodoSameMsCntEvoX1Y2; - TH1 * fhHodoSameMsCntEvoY1X2; - TH1 * fhHodoSameMsCntEvoX1Y1X2Y2; - - // Coincidences in sorted hits - TH1 * fhHodoSortedDtX1Y1; - TH1 * fhHodoSortedDtX2Y2; - TH1 * fhHodoSortedDtX1X2; - TH1 * fhHodoSortedDtY1Y2; - TH1 * fhHodoSortedDtX1Y2; - TH1 * fhHodoSortedDtY1X2; - TH2 * fhHodoSortedMapX1Y1; - TH2 * fhHodoSortedMapX2Y2; - TH2 * fhHodoSortedMapX1X2; - TH2 * fhHodoSortedMapY1Y2; - TH2 * fhHodoSortedMapX1Y2; - TH2 * fhHodoSortedMapY1X2; - - TH2* fhHodoFebTsMsb; - - TCanvas* fcMsSizeAll; - TH1* fhMsSz[kiMaxNbFlibLinks]; - TProfile* fhMsSzTime[kiMaxNbFlibLinks]; - - void CreateHistograms(); - - void FillHitInfo( stsxyter::BetaMessage mess, const UShort_t & usElinkIdx, const UInt_t & uAsicIdx, const UInt_t & uMsIdx ); - void FillTsMsbInfo( stsxyter::BetaMessage mess, const UShort_t & usElinkIdx, const UInt_t & uAsicIdx ); - - CbmCern2017MonitorHodo(const CbmCern2017MonitorHodo&); - CbmCern2017MonitorHodo operator=(const CbmCern2017MonitorHodo&); - - ClassDef(CbmCern2017MonitorHodo, 1) -}; - -#endif // CBMCERN2017MONITORHODO_H diff --git a/beamtime/cern2017/unpacker/CbmCern2017MonitorRawSts.cxx b/beamtime/cern2017/unpacker/CbmCern2017MonitorRawSts.cxx deleted file mode 100644 index c3ce6a09e21007f087bbd88b23310acd1b288c3b..0000000000000000000000000000000000000000 --- a/beamtime/cern2017/unpacker/CbmCern2017MonitorRawSts.cxx +++ /dev/null @@ -1,1481 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmCern2017MonitorRawSts ----- -// ----- Created 25/07/17 by P.-A. Loizeau ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#include "CbmCern2017MonitorRawSts.h" - -// Data - -// CbmRoot -#include "CbmCern2017UnpackParSts.h" -#include "CbmHistManager.h" - -// FairRoot -#include "FairLogger.h" -#include "FairRootManager.h" -#include "FairRun.h" -#include "FairRuntimeDb.h" -#include "FairRunOnline.h" - -// Root -#include "TClonesArray.h" -#include "TString.h" -#include "TRandom.h" -#include "THttpServer.h" -#include "TROOT.h" -#include <TFile.h> - -// C++11 - -// C/C++ -#include <iostream> -#include <stdint.h> -#include <iomanip> - -Bool_t bCern2017ResetRawStsHistos = kFALSE; -Bool_t bCern2017WriteRawStsHistos = kFALSE; - -CbmCern2017MonitorRawSts::CbmCern2017MonitorRawSts() : - CbmTSUnpack(), - fuOverlapMsNb(0), - fUnpackPar(NULL), - fuNrOfDpbs(0), - fDpbIdIndexMap(), - fuNbElinksPerDpb(0), - fuNbStsXyters(0), - fuNbChanPerAsic(0), - fvuElinkToAsic(), - fbPrintRawMessages( kFALSE ), - fPrintMessCtrl( stsxyter::RawMessagePrintMask::msg_print_Human ), - fbChanHitDtEna( kFALSE ), - fmMsgCounter(), - fuCurrentEquipmentId(0), - fuCurrDpbId(0), - fuCurrDpbIdx(0), - fiRunStartDateTimeSec(-1), - fiBinSizeDatePlots(-1), - fvuCurrentTsMsb(), - fvuCurrentTsMsbCycle(), - fvuCurrentTsMsbOver(), - fvulChanLastHitTime(), - fvdChanLastHitTime(), - fvuChanNbHitsInMs(), - fvdChanLastHitTimeInMs(), - fvusChanLastHitAdcInMs(), - fdStartTime(-1.0), - fdStartTimeMsSz(-1.0), - ftStartTimeUnix( std::chrono::steady_clock::now() ), - fHM(new CbmHistManager()), - fhStsMessType(NULL), - fhStsSysMessType(NULL), - fhStsMessTypePerDpb(NULL), - fhStsSysMessTypePerDpb(NULL), - fhStsChanCounts(), - fhStsChanRawAdc(), - fhStsChanRawAdcProf(), - fhStsChanRawTs(), - fhStsChanMissEvt(), - fhStsChanOverDiff(), - fhStsChanHitRateEvo(), - fhStsXyterRateEvo(), - fhStsChanHitRateEvoLong(), - fhStsXyterRateEvoLong(), - fhStsChanHitDt(), - fhStsChanHitDtNeg(), - fhStsChanHitsPerMs(), - fhStsChanSameMs(), - fpStsChanSameMsTimeDiff(), - fhStsChanSameMsTimeDiff(), - fbPulserTimeDiffOn(kFALSE), - fuPulserMaxNbMicroslices(100), - fvuPulserAsic(), - fvuPulserChan(), - fhStsPulserChansTimeDiff(), - fhStsAsicTsMsb(NULL), - fhStsAsicTsMsbMaj(NULL), - fhStsElinkTsMsbCrc(), - fhStsElinkTsMsbMaj(), - fbLongHistoEnable( kFALSE ), - fuLongHistoNbSeconds( 0 ), - fuLongHistoBinSizeSec( 0 ), - fuLongHistoBinNb( 0 ), - fhFebRateEvoLong(), - fhFebChRateEvoLong(), - fcMsSizeAll(NULL) -{ -} - -CbmCern2017MonitorRawSts::~CbmCern2017MonitorRawSts() -{ -} - -Bool_t CbmCern2017MonitorRawSts::Init() -{ - LOG(info) << "Initializing flib StsXyter unpacker for STS"; - - FairRootManager* ioman = FairRootManager::Instance(); - if (ioman == NULL) { - LOG(fatal) << "No FairRootManager instance"; - } - - return kTRUE; -} - -void CbmCern2017MonitorRawSts::SetParContainers() -{ - LOG(info) << "Setting parameter containers for " << GetName(); - fUnpackPar = (CbmCern2017UnpackParSts*)(FairRun::Instance()->GetRuntimeDb()->getContainer("CbmCern2017UnpackParSts")); -} - - -Bool_t CbmCern2017MonitorRawSts::InitContainers() -{ - LOG(info) << "Init parameter containers for " << GetName(); - - Bool_t bReInit = ReInitContainers(); - CreateHistograms(); - - return bReInit; -} - -Bool_t CbmCern2017MonitorRawSts::ReInitContainers() -{ - LOG(info) << "ReInit parameter containers for " << GetName(); - - fuNrOfDpbs = fUnpackPar->GetNrOfDpbs(); - fuNbElinksPerDpb = fUnpackPar->GetNbElinksPerDpb(); - fuNbStsXyters = fUnpackPar->GetNbStsXyters(); - fuNbChanPerAsic = fUnpackPar->GetNbChanPerAsic(); - - - LOG(info) << "Nr. of STS DPBs: " << fuNrOfDpbs; - - fDpbIdIndexMap.clear(); - fvuElinkToAsic.resize( fuNrOfDpbs ); - for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - { - fDpbIdIndexMap[ fUnpackPar->GetDpbId( uDpb ) ] = uDpb; - LOG(info) << "Eq. ID for DPB #" << std::setw(2) << uDpb << " = " - << std::setw(4) << std::hex << fUnpackPar->GetDpbId( uDpb ) - << std::dec - << " => " << fDpbIdIndexMap[ fUnpackPar->GetDpbId( uDpb ) ]; - - fvuElinkToAsic[uDpb].resize( fuNbElinksPerDpb ); - for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink ) - fvuElinkToAsic[uDpb][uElink] = fUnpackPar->GetElinkToAsicIdx( uDpb * fuNbElinksPerDpb + uElink ); - } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - - LOG(info) << "Nr. eLinks per DPB: " << fuNbElinksPerDpb; - LOG(info) << "Nr. of StsXyter ASICs: " << fuNbStsXyters; - LOG(info) << "Nb. channels per ASIC: " << fuNbChanPerAsic; - - for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - { - LOG(info) << "ASIC ID for eLinks in DPB #" << std::setw(2) << uDpb << ": "; - - for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink ) - { - if( 0 == uElink % 10 ) - LOG(info) << "\n" - << "------> "; - - LOG(info) << std::setw( 5 ) << fvuElinkToAsic[uDpb][uElink] << " "; - } // for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink ) - LOG(info) << ""; - } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - - // Internal status initialization - fvuCurrentTsMsb.resize( fuNrOfDpbs ); - fvuCurrentTsMsbCycle.resize( fuNrOfDpbs ); - fvuCurrentTsMsbOver.resize( fuNrOfDpbs ); - for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - { - fvuCurrentTsMsb[uDpb].resize( fuNbElinksPerDpb ); - fvuCurrentTsMsbCycle[uDpb].resize( fuNbElinksPerDpb ); - fvuCurrentTsMsbOver[uDpb].resize( fuNbElinksPerDpb ); - for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink ) - { - fvuCurrentTsMsb[uDpb][uElink] = 0; - fvuCurrentTsMsbCycle[uDpb][uElink] = 0; - fvuCurrentTsMsbOver[uDpb][uElink] = 0; - } // for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink ) - } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - - fvulChanLastHitTime.resize( fuNbStsXyters ); - fvdChanLastHitTime.resize( fuNbStsXyters ); - fvuChanNbHitsInMs.resize( fuNbStsXyters ); - fvdChanLastHitTimeInMs.resize( fuNbStsXyters ); - fvusChanLastHitAdcInMs.resize( fuNbStsXyters ); - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fvulChanLastHitTime[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvdChanLastHitTime[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvuChanNbHitsInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvdChanLastHitTimeInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvusChanLastHitAdcInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - { - fvulChanLastHitTime[ uXyterIdx ][ uChan ] = 0; - fvdChanLastHitTime[ uXyterIdx ][ uChan ] = -1.0; - - fvuChanNbHitsInMs[ uXyterIdx ][ uChan ].resize( fuPulserMaxNbMicroslices ); - fvdChanLastHitTimeInMs[ uXyterIdx ][ uChan ].resize( fuPulserMaxNbMicroslices ); - fvusChanLastHitAdcInMs[ uXyterIdx ][ uChan ].resize( fuPulserMaxNbMicroslices ); - for( UInt_t uMsIdx = 0; uMsIdx < fuPulserMaxNbMicroslices; ++uMsIdx ) - { - fvuChanNbHitsInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = 0; - fvdChanLastHitTimeInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = -1.0; - fvusChanLastHitAdcInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = 0; - } // for( UInt_t uMsIdx = 0; uMsIdx < fuPulserMaxNbMicroslices; ++uMsIdx ) - } // for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - LOG(info) << "CbmCern2017MonitorRawSts::ReInitContainers => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs.size() << " VS " << fuNbStsXyters; - LOG(info) << "CbmCern2017MonitorRawSts::ReInitContainers => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs[ 0 ].size() << " VS " << fuNbChanPerAsic; - LOG(info) << "CbmCern2017MonitorRawSts::ReInitContainers => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs[ 0 ][ 0 ].size() << " VS " << fuPulserMaxNbMicroslices; - return kTRUE; -} - -void CbmCern2017MonitorRawSts::CreateHistograms() -{ - THttpServer* server = FairRunOnline::Instance()->GetHttpServer(); - - TString sHistName{""}; - TString title{""}; - - sHistName = "hStsMessageType"; - title = "Nb of message for each type; Type"; - fhStsMessType = new TH1I(sHistName, title, 5, 0., 5.); - fhStsMessType->GetXaxis()->SetBinLabel( 1, "Dummy"); - fhStsMessType->GetXaxis()->SetBinLabel( 2, "Hit"); - fhStsMessType->GetXaxis()->SetBinLabel( 3, "TsMsb"); - fhStsMessType->GetXaxis()->SetBinLabel( 4, "ReadDataAck"); - fhStsMessType->GetXaxis()->SetBinLabel( 5, "Ack"); -/* *** Missing int + MessType OP!!!! **** - fhStsMessType->GetXaxis()->SetBinLabel(1 + stsxyter::MessType::Dummy, "Dummy"); - fhStsMessType->GetXaxis()->SetBinLabel(1 + stsxyter::MessType::Hit, "Hit"); - fhStsMessType->GetXaxis()->SetBinLabel(1 + stsxyter::MessType::TsMsb, "TsMsb"); - fhStsMessType->GetXaxis()->SetBinLabel(1 + stsxyter::MessType::ReadDataAck, "ReadDataAck"); - fhStsMessType->GetXaxis()->SetBinLabel(1 + stsxyter::MessType::Ack, "Ack"); -*/ - fHM->Add(sHistName.Data(), fhStsMessType); - if( server ) server->Register("/StsRaw", fhStsMessType ); - - sHistName = "hStsSysMessType"; - title = "Nb of system message for each type; System Type"; - fhStsSysMessType = new TH1I(sHistName, title, 17, 0., 17.); -/* - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_START, "DAQ START"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_FINISH, "DAQ FINISH"); - hSysMessType->GetXaxis()->SetBinLabel(1 + 16, "GET4 Hack 32B"); -*/ - fHM->Add(sHistName.Data(), fhStsSysMessType); - if( server ) server->Register("/StsRaw", fhStsSysMessType ); - - sHistName = "hStsMessageTypePerDpb"; - title = "Nb of message of each type for each DPB; DPB; Type"; - fhStsMessTypePerDpb = new TH2I(sHistName, title, fuNrOfDpbs, 0, fuNrOfDpbs, 5, 0., 5.); - fhStsMessTypePerDpb->GetYaxis()->SetBinLabel( 1, "Dummy"); - fhStsMessTypePerDpb->GetYaxis()->SetBinLabel( 2, "Hit"); - fhStsMessTypePerDpb->GetYaxis()->SetBinLabel( 3, "TsMsb"); - fhStsMessTypePerDpb->GetYaxis()->SetBinLabel( 4, "ReadDataAck"); - fhStsMessTypePerDpb->GetYaxis()->SetBinLabel( 5, "Ack"); -/* *** Missing int + MessType OP!!!! **** - fhStsMessType->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Dummy, "Dummy"); - fhStsMessType->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Hit, "Hit"); - fhStsMessType->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::TsMsb, "TsMsb"); - fhStsMessType->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::ReadDataAck, "ReadDataAck"); - fhStsMessType->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Ack, "Ack"); -*/ - fHM->Add(sHistName.Data(), fhStsMessTypePerDpb); - if( server ) server->Register("/StsRaw", fhStsMessTypePerDpb ); - - sHistName = "hStsSysMessTypePerDpb"; - title = "Nb of system message of each type for each DPB; DPB; System Type"; - fhStsSysMessTypePerDpb = new TH2I(sHistName, title, fuNrOfDpbs, 0, fuNrOfDpbs, 17, 0., 17.); -/* - hSysMessType->GetYaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_START, "DAQ START"); - hSysMessType->GetYaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_FINISH, "DAQ FINISH"); - hSysMessType->GetYaxis()->SetBinLabel(1 + 16, "GET4 Hack 32B"); -*/ - fHM->Add(sHistName.Data(), fhStsSysMessTypePerDpb); - if( server ) server->Register("/StsRaw", fhStsSysMessTypePerDpb ); - - // Number of rate bins = - // 9 for the sub-unit decade - // + 9 for each unit of each decade * 10 for the subdecade range - // + 1 for the closing bin top edge - const Int_t iNbDecadesRate = 9; - const Int_t iNbStepsDecade = 9; - const Int_t iNbSubStepsInStep = 10; - const Int_t iNbBinsRate = iNbStepsDecade - + iNbStepsDecade * iNbSubStepsInStep * iNbDecadesRate - + 1; - Double_t dBinsRate[iNbBinsRate]; - // First fill sub-unit decade - for( Int_t iSubU = 0; iSubU < iNbStepsDecade; iSubU ++ ) - dBinsRate[ iSubU ] = 0.1 * ( 1 + iSubU ); - std::cout << std::endl; - // Then fill the main decades - Double_t dSubstepSize = 1.0 / iNbSubStepsInStep; - for( Int_t iDecade = 0; iDecade < iNbDecadesRate; iDecade ++) - { - Double_t dBase = std::pow( 10, iDecade ); - Int_t iDecadeIdx = iNbStepsDecade - + iDecade * iNbStepsDecade * iNbSubStepsInStep; - for( Int_t iStep = 0; iStep < iNbStepsDecade; iStep++ ) - { - Int_t iStepIdx = iDecadeIdx + iStep * iNbSubStepsInStep; - for( Int_t iSubStep = 0; iSubStep < iNbSubStepsInStep; iSubStep++ ) - { - dBinsRate[ iStepIdx + iSubStep ] = dBase * (1 + iStep) - + dBase * dSubstepSize * iSubStep; - } // for( Int_t iSubStep = 0; iSubStep < iNbSubStepsInStep; iSubStep++ ) - } // for( Int_t iStep = 0; iStep < iNbStepsDecade; iStep++ ) - } // for( Int_t iDecade = 0; iDecade < iNbDecadesRate; iDecade ++) - dBinsRate[ iNbBinsRate - 1 ] = std::pow( 10, iNbDecadesRate ); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - // Channel counts - sHistName = Form( "hStsChanCounts_%03u", uXyterIdx ); - title = Form( "Hits Count per channel, StsXyter #%03u; Channel; Hits []", uXyterIdx ); - fhStsChanCounts.push_back( new TH1I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - fHM->Add(sHistName.Data(), fhStsChanCounts[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhStsChanCounts[ uXyterIdx ] ); - - // Raw Adc Distribution - sHistName = Form( "hStsChanRawAdc_%03u", uXyterIdx ); - title = Form( "Raw Adc distribution per channel, StsXyter #%03u; Channel []; Adc []; Hits []", uXyterIdx ); - fhStsChanRawAdc.push_back( new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - stsxyter::kuRawHitNbAdcBins, -0.5, stsxyter::kuRawHitNbAdcBins -0.5 ) ); - fHM->Add(sHistName.Data(), fhStsChanRawAdc[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhStsChanRawAdc[ uXyterIdx ] ); - - // Raw Adc Distribution profile - sHistName = Form( "hStsChanRawAdcProfc_%03u", uXyterIdx ); - title = Form( "Raw Adc prodile per channel, StsXyter #%03u; Channel []; Adc []", uXyterIdx ); - fhStsChanRawAdcProf.push_back( new TProfile(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - fHM->Add(sHistName.Data(), fhStsChanRawAdcProf[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhStsChanRawAdcProf[ uXyterIdx ] ); - - // Raw Ts Distribution - sHistName = Form( "hStsChanRawTs_%03u", uXyterIdx ); - title = Form( "Raw Timestamp distribution per channel, StsXyter #%03u; Channel []; Ts []; Hits []", uXyterIdx ); - fhStsChanRawTs.push_back( new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - stsxyter::kuRawHitNbTsBins, -0.5, stsxyter::kuRawHitNbTsBins -0.5 ) ); - fHM->Add(sHistName.Data(), fhStsChanRawTs[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhStsChanRawTs[ uXyterIdx ] ); - - // Missed event flag - sHistName = Form( "hStsChanMissEvt_%03u", uXyterIdx ); - title = Form( "Missed Event flags per channel, StsXyter #%03u; Channel []; Miss Evt []; Hits []", uXyterIdx ); - fhStsChanMissEvt.push_back( new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - 2, -0.5, 1.5 ) ); - fHM->Add(sHistName.Data(), fhStsChanMissEvt[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhStsChanMissEvt[ uXyterIdx ] ); - - // MSB correction from Overlap difference - sHistName = Form( "hStsChanOverDiff_%03u", uXyterIdx ); - title = Form( "MSB correction from Overlap difference, per channel, StsXyter #%03u; Channel []; Over. diff. [MSB corr bin]; Hits []", uXyterIdx ); - fhStsChanOverDiff.push_back( new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - stsxyter::kuRawHitNbOverBins, -0.5, stsxyter::kuRawHitNbOverBins - 0.5 ) ); - fHM->Add(sHistName.Data(), fhStsChanOverDiff[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhStsChanOverDiff[ uXyterIdx ] ); - - // Hit rates evo per channel - sHistName = Form( "hStsChanRateEvo_%03u", uXyterIdx ); - title = Form( "Hits per second & channel in StsXyter #%03u; Time [s]; Channel []; Hits []", uXyterIdx ); - fhStsChanHitRateEvo.push_back( new TH2I( sHistName, title, - 1800, 0, 1800, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - fHM->Add(sHistName.Data(), fhStsChanHitRateEvo[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhStsChanHitRateEvo[ uXyterIdx ] ); - - // Hit rates evo per StsXyter - sHistName = Form( "hStsXyterRateEvo_%03u", uXyterIdx ); - title = Form( "Hits per second in StsXyter #%03u; Time [s]; Hits []", uXyterIdx ); - fhStsXyterRateEvo.push_back( new TH1I(sHistName, title, 1800, 0, 1800 ) ); - fHM->Add(sHistName.Data(), fhStsXyterRateEvo[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhStsXyterRateEvo[ uXyterIdx ] ); - - // Hit rates evo per channel, 1 minute bins, 24h - sHistName = Form( "hStsChanRateEvoLong_%03u", uXyterIdx ); - title = Form( "Hits per second & channel in StsXyter #%03u; Time [min]; Channel []; Hits []", uXyterIdx ); - fhStsChanHitRateEvoLong.push_back( new TH2D( sHistName, title, - 1440, 0, 1440, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - fHM->Add(sHistName.Data(), fhStsChanHitRateEvoLong[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhStsChanHitRateEvoLong[ uXyterIdx ] ); - - // Hit rates evo per StsXyter, 1 minute bins, 24h - sHistName = Form( "hStsXyterRateEvoLong_%03u", uXyterIdx ); - title = Form( "Hits per second in StsXyter #%03u; Time [min]; Hits []", uXyterIdx ); - fhStsXyterRateEvoLong.push_back( new TH1D(sHistName, title, 1440, 0, 1440 ) ); - fHM->Add(sHistName.Data(), fhStsXyterRateEvoLong[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhStsXyterRateEvoLong[ uXyterIdx ] ); - - // Hit distance in time for each channel - if( fbChanHitDtEna ) - { - sHistName = Form( "hStsChanHitDt_%03u", uXyterIdx ); - title = Form( "Time diff between hits on same channel in StsXyter #%03u; t_hit - t_prev [ns]; Channel []; Hits []", uXyterIdx ); - fhStsChanHitDt.push_back( new TH2I( sHistName, title, - iNbBinsRate - 1, dBinsRate, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - fHM->Add(sHistName.Data(), fhStsChanHitDt[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhStsChanHitDt[ uXyterIdx ] ); - sHistName = Form( "hStsChanHitDtNeg_%03u", uXyterIdx ); - title = Form( "Time diff between hits on same channel in StsXyter #%03u; t_prev - t_hit [ns]; Channel []; Hits []", uXyterIdx ); - fhStsChanHitDtNeg.push_back( new TH2I( sHistName, title, - iNbBinsRate - 1, dBinsRate, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - fHM->Add(sHistName.Data(), fhStsChanHitDtNeg[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhStsChanHitDtNeg[ uXyterIdx ] ); - - } // if( fbChanHitDtEna ) - - sHistName = Form( "hStsChanHitsPerMs_%03u", uXyterIdx ); - title = Form( "Nb of hits per channel in each MS in StsXyter #%03u; Nb Hits in MS []; Channel []; MS []", uXyterIdx ); - fhStsChanHitsPerMs.push_back( new TH2I( sHistName, title, - 100, -0.5, 99.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - fHM->Add(sHistName.Data(), fhStsChanHitsPerMs[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhStsChanHitsPerMs[ uXyterIdx ] ); - - sHistName = Form( "hStsChanSameMs_%03u", uXyterIdx ); - title = Form( "Nb of MS with hits in both channels in StsXyter #%03u; Channel A []; Channel B []; Coinc. MS []", uXyterIdx ); - fhStsChanSameMs.push_back( new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - fHM->Add(sHistName.Data(), fhStsChanHitsPerMs[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhStsChanSameMs[ uXyterIdx ] ); - - sHistName = Form( "pStsChanSameMsTimeDiff_%03u", uXyterIdx ); - title = Form( "Mean Time difference of channels when hits in same MS in StsXyter #%03u; Channel A []; Channel B []; Mean time diff [bins]", uXyterIdx ); - fpStsChanSameMsTimeDiff.push_back( new TProfile2D( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - - sHistName = Form( "hStsChanSameMsTimeDiff_%03u", uXyterIdx ); - title = Form( "Mean Time difference of channels when hits in same MS in StsXyter #%03u; Channel A []; Channel B []; Mean time diff [bins]", uXyterIdx ); - fhStsChanSameMsTimeDiff.push_back( new TH2D( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - fHM->Add(sHistName.Data(), fhStsChanSameMsTimeDiff[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhStsChanSameMsTimeDiff[ uXyterIdx ] ); - - if( kTRUE == fbLongHistoEnable ) - { - UInt_t uAlignedLimit = fuLongHistoNbSeconds - (fuLongHistoNbSeconds % fuLongHistoBinSizeSec); - fuLongHistoBinNb = uAlignedLimit / fuLongHistoBinSizeSec; - - sHistName = Form( "hFebRateEvoLong_%03u", uXyterIdx ); - title = Form( "Mean rate VS run time in same MS in StsXyter #%03u; Time in run [s]; Rate [1/s]", uXyterIdx ); - fhFebRateEvoLong.push_back( new TH1D( sHistName, title, - fuLongHistoBinNb, -0.5, uAlignedLimit - 0.5) ); - fHM->Add(sHistName.Data(), fhFebRateEvoLong[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhFebRateEvoLong[ uXyterIdx ] ); - - sHistName = Form( "hFebChRateEvoLong_%03u", uXyterIdx ); - title = Form( "Mean rate per channel VS run time in StsXyter #%03u; Time in run [s]; Channel []; Rare [1/s]", uXyterIdx ); - fhFebChRateEvoLong.push_back( new TH2D( sHistName, title, - fuLongHistoBinNb, -0.5, uAlignedLimit - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - fHM->Add(sHistName.Data(), fhFebChRateEvoLong[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhFebChRateEvoLong[ uXyterIdx ] ); - } // if( kTRUE == fbLongHistoEnable ) - - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - - if( kTRUE == fbPulserTimeDiffOn ) - { - UInt_t uNbPulserChans = fvuPulserAsic.size(); - for( UInt_t uChA = 0; uChA < uNbPulserChans; ++uChA ) - for( UInt_t uChB = uChA + 1; uChB < uNbPulserChans; ++uChB ) - { - sHistName = Form( "hStsPulserTimeDiff_%02u_%03u_%02u_%03u", - fvuPulserAsic[uChA], fvuPulserChan[uChA], - fvuPulserAsic[uChB], fvuPulserChan[uChB] ); - title = Form( "Time diff for hits in same MS from ASIC %02d ch %03d and ASIC %02d ch %03d; tB - tA [ns]; Counts", - fvuPulserAsic[uChA], fvuPulserChan[uChA], - fvuPulserAsic[uChB], fvuPulserChan[uChB] ); -// TH1 * pHist = new TH1I(sHistName, title, 16385, -51203.125, 51203.125); - TH1 * pHist = new TH1I(sHistName, title, 32769, -102406.25, 102406.25 ); - - fHM->Add(sHistName.Data(), pHist); - if( server ) server->Register("/StsRaw", pHist ); - fhStsPulserChansTimeDiff.push_back( pHist ); - } // Loop on pairs of channels - } // if( kTRUE == fbPulserTimeDiffOn ) - - // Distribution of the TS_MSB per StsXyter - sHistName = "hStsAsicTsMsb"; - title = "Raw Timestamp Msb distribution per StsXyter; Ts MSB []; StsXyter []; Hits []"; - fhStsAsicTsMsb = new TH2I( sHistName, title, stsxyter::kuRawTsMsbNbTsBins, -0.5, stsxyter::kuRawTsMsbNbTsBins - 0.5, - fuNbStsXyters, -0.5, fuNbStsXyters - 0.5 ); - fHM->Add(sHistName.Data(), fhStsAsicTsMsb ); - if( server ) server->Register("/StsRaw", fhStsAsicTsMsb ); - - // Nb values in agreement in TS MSB messages, per StsXyter - sHistName = "hStsAsicTsMsbMaj"; - title = "Nb values in agreement in TS MSB messages, per StsXyter; StsXyter []; Majority? []; Mess. []"; - fhStsAsicTsMsbMaj = new TH2I( sHistName, title, fuNbStsXyters, -0.5, fuNbStsXyters - 0.5, - 3, 0.5, 3.5); - fHM->Add(sHistName.Data(), fhStsAsicTsMsbMaj ); - if( server ) server->Register("/StsRaw", fhStsAsicTsMsbMaj ); - - for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - { - // CRC good or bad in TS MSB messages, per (DPB, eLink) pairs - sHistName = Form( "hStsElinkTsMsbCrc_d%02u", uDpb ); - title = Form( "CRC test in TS MSB, per eLink, DPB #%02u; eLink []; CRC Match? []; Mess. []", uDpb); - fhStsElinkTsMsbCrc.push_back( new TH2I( sHistName, title, fuNbElinksPerDpb, -0.5, fuNbElinksPerDpb - 0.5, - 2, -0.5, 1.5) ); - fHM->Add(sHistName.Data(), fhStsElinkTsMsbCrc[ uDpb ] ); - if( server ) server->Register("/StsRaw", fhStsElinkTsMsbCrc[ uDpb ] ); - - // Nb values in agreement in TS MSB messages, per (DPB, eLink) pairs - sHistName = Form( "hStsElinkTsMsbMaj_d%02u", uDpb ); - title = Form( "Nb values in agreement in TS MSB, per eLink, DPB #%02u; eLink []; Majority? []; Mess. []", uDpb); - fhStsElinkTsMsbMaj.push_back( new TH2I( sHistName, title, fuNbElinksPerDpb, -0.5, fuNbElinksPerDpb - 0.5, - 3, 0.5, 3.5) ); - fHM->Add(sHistName.Data(), fhStsElinkTsMsbMaj[ uDpb ] ); - if( server ) server->Register("/StsRaw", fhStsElinkTsMsbMaj[ uDpb ] ); - } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - - // Miscroslice properties histos - for( Int_t component = 0; component < kiMaxNbFlibLinks; component ++ ) - { - fhMsSz[ component ] = NULL; - fhMsSzTime[ component ] = NULL; - } // for( Int_t component = 0; component < kiMaxNbFlibLinks; component ++ ) - - // Online histo browser commands - if( server ) - { - server->RegisterCommand("/Reset_All_Sts", "bCern2017ResetRawStsHistos=kTRUE"); - server->RegisterCommand("/Write_All_Sts", "bCern2017WriteRawStsHistos=kTRUE"); - - server->Restrict("/Reset_All_Sts", "allow=admin"); - server->Restrict("/Write_All_Sts", "allow=admin"); - } // if( server ) - - /** Create summary Canvases for CERN 2017 **/ - Double_t w = 10; - Double_t h = 10; - - // Summary per StsXyter - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - TCanvas* cStsSumm = new TCanvas( Form("cStsSum_%03u", uXyterIdx ), - Form("Summary plots for StsXyter %03u", uXyterIdx ), - w, h); - cStsSumm->Divide( 2, 2 ); - - cStsSumm->cd(1); - gPad->SetLogy(); - fhStsChanCounts[ uXyterIdx ]->Draw(); - - cStsSumm->cd(2); - gPad->SetLogz(); - fhStsChanRawAdc[ uXyterIdx ]->Draw( "colz" ); - - cStsSumm->cd(3); - gPad->SetLogz(); - fhStsChanRawTs[ uXyterIdx ]->Draw( "colz" ); - - cStsSumm->cd(4); - gPad->SetLogy(); - fhStsXyterRateEvo[ uXyterIdx ]->Draw(); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - - // Pulser testing - if( kTRUE == fbPulserTimeDiffOn ) - { - UInt_t uNbPulserPlots = fhStsPulserChansTimeDiff.size(); - TCanvas* cStsPulser = new TCanvas( "cStsPulser" , "Summary plots for StsXyter pulser testing", - w, h); - cStsPulser->Divide( 2, uNbPulserPlots/2 + uNbPulserPlots%2 ); - - for( UInt_t uPulserPlot = 0; uPulserPlot < uNbPulserPlots; ++uPulserPlot) - { - cStsPulser->cd( 1 + uPulserPlot ); - gPad->SetLogy(); - gPad->SetGridx(); - gPad->SetGridy(); - fhStsPulserChansTimeDiff[ uPulserPlot ]->Draw(); - } // for( UInt_t uPulserPlot = 0; uPulserPlot < uNbPulserPlots; ++uPulserPlot) - } // if( kTRUE == fbPulserTimeDiffOn ) - - // Long duration rate monitoring - if( kTRUE == fbLongHistoEnable ) - { - TCanvas* cStsLongRate = new TCanvas( "cStsLongRate" , "Long duration rate plots for StsXyter", - w, h); - cStsLongRate->Divide( 2, fuNbStsXyters ); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - cStsLongRate->cd( 1 + 2 * uXyterIdx ); - gPad->SetLogy(); - gPad->SetGridx(); - gPad->SetGridy(); - fhFebRateEvoLong[ uXyterIdx ]->Draw( "hist" ); - - cStsLongRate->cd( 2 + 2 * uXyterIdx ); - gPad->SetLogz(); - gPad->SetGridx(); - gPad->SetGridy(); - fhFebChRateEvoLong[ uXyterIdx ]->Draw( "colz" ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - } // if( kTRUE == fbLongHistoEnable ) - -/* - Int_t iNbPadsPerDpb = fuNbElinksPerDpb/2 + fuNbElinksPerDpb%2; - TCanvas* cMuchChCounts = new TCanvas("cMuchChCounts", "MUCH Channels counts", w, h); - cMuchChCounts->Divide( fNrOfNdpbs/2 + fNrOfNdpbs%2, fNrOfFebsPerNdpb ); - - TCanvas* cMuchFebRate = new TCanvas("cMuchFebRate", "MUCH FEB rate", w, h); - cMuchFebRate->Divide( fNrOfNdpbs/2 + fNrOfNdpbs%2, fNrOfFebsPerNdpb ); - - TH1* histPnt = NULL; - for( Int_t dpbId = 0; dpbId < fNrOfNdpbs; dpbId++) - {// looping on all the nDPBS IDs - if( dpbId < fUnpackPar->GetNrOfnDpbsModA() ) - { - sNdpbTag = Form("%04X", fUnpackPar->GetNdpbIdA(dpbId) ); - } // if( dpbId < fUnpackPar->GetNrOfnDpbsModA() ) - else - { - sNdpbTag = Form("%04X", fUnpackPar->GetNdpbIdB(dpbId - fNrOfNdpbsA) ); - } // else of if( dpbId < fUnpackPar->GetNrOfnDpbsModA() ) - - for( Int_t febId = 0; febId < fNrOfFebsPerNdpb; febId++) - {// looping on all the FEB IDs - cMuchChCounts->cd( 1 + dpbId * iNbPadsPerDpb + febId/2 ); - gPad->SetLogy(); - sHistName = Form("Chan_Counts_Much_n%s_f%1u", sNdpbTag.Data(), febId); - histPnt = fHM->H1(sHistName.Data()); - - if( 0 == febId%2 ) - { - histPnt->SetLineColor( kRed ); // => Change color for 1st of the 2/pad! - histPnt->Draw(); - } // if( 0 == febId%2 ) - else - { - histPnt->SetLineColor( kBlue ); // => Change color for 1nd of the 2/pad! - histPnt->Draw("same"); - } // if( 0 == febId%2 ) - - cMuchFebRate->cd( 1 + dpbId * iNbPadsPerDpb + febId/2 ); - gPad->SetLogy(); - sHistName = Form("FebRate_n%s_f%1u", sNdpbTag.Data(), febId); - histPnt = fHM->H1(sHistName.Data()); - - if( 0 == febId%2 ) - { - histPnt->SetLineColor( kRed ); // => Change color for 1st of the 2/pad! - histPnt->Draw(); - } // if( 0 == febId%2 ) - else - { - histPnt->SetLineColor( kBlue ); // => Change color for 1nd of the 2/pad! - histPnt->Draw("same"); - } // if( 0 == febId%2 ) - } // for( Int_t febId = 0; febId < fNrOfFebsPerNdpb; febId++) - } // for( Int_t dpbId = 0; dpbId < fNrOfNdpbs; dpbId++) -*/ - - /** Recovers/Create Ms Size Canvase for CERN 2016 **/ - // Try to recover canvas in case it was created already by another monitor - // If not existing, create it - fcMsSizeAll = dynamic_cast<TCanvas *>( gROOT->FindObject( "cMsSizeAll" ) ); - if( NULL == fcMsSizeAll ) - { - fcMsSizeAll = new TCanvas("cMsSizeAll", "Evolution of MS size in last 300 s", w, h); - fcMsSizeAll->Divide( 4, 4 ); - LOG(info) << "Created MS size canvas in STS monitor"; - } // if( NULL == fcMsSizeAll ) - else LOG(info) << "Recovered MS size canvas in STS monitor"; - - /*****************************/ -} - -Bool_t CbmCern2017MonitorRawSts::DoUnpack(const fles::Timeslice& ts, size_t component) -{ - THttpServer* server = FairRunOnline::Instance()->GetHttpServer(); - - if( bCern2017ResetRawStsHistos ) - { - ResetAllHistos(); - bCern2017ResetRawStsHistos = kFALSE; - } // if( bCern2017ResetRawStsHistos ) - if( bCern2017WriteRawStsHistos ) - { - SaveAllHistos( "data/StsHistos.root" ); - bCern2017WriteRawStsHistos = kFALSE; - } // if( bCern2017WriteRawStsHistos ) - - LOG(debug) << "Timeslice contains " << ts.num_microslices(component) - << "microslices."; - - if( component < kiMaxNbFlibLinks ) - if( NULL == fhMsSz[ component ] ) - { - TString sMsSzName = Form("MsSz_link_%02lu", component); - TString sMsSzTitle = Form("Size of MS for nDPB of link %02lu; Ms Size [bytes]", component); - fhMsSz[ component ] = new TH1F( sMsSzName.Data(), sMsSzTitle.Data(), 160000, 0., 20000. ); - fHM->Add(sMsSzName.Data(), fhMsSz[ component ] ); - if (server) server->Register("/FlibRaw", fhMsSz[ component ] ); - sMsSzName = Form("MsSzTime_link_%02lu", component); - sMsSzTitle = Form("Size of MS vs time for gDPB of link %02lu; Time[s] ; Ms Size [bytes]", component); - fhMsSzTime[ component ] = new TProfile( sMsSzName.Data(), sMsSzTitle.Data(), 15000, 0., 300. ); - fHM->Add( sMsSzName.Data(), fhMsSzTime[ component ] ); - if (server) server->Register("/FlibRaw", fhMsSzTime[ component ] ); - if( NULL != fcMsSizeAll ) - { - fcMsSizeAll->cd( 1 + component ); - gPad->SetLogy(); - fhMsSzTime[ component ]->Draw("hist le0"); - } // if( NULL != fcMsSizeAll ) - LOG(info) << "Added MS size histo for component: " << component - << " (DPB)"; - } // if( NULL == fhMsSz[ component ] ) - -// Int_t messageType = -111; - // Loop over microslices - size_t numCompMsInTs = ts.num_microslices(component); - - if( fuPulserMaxNbMicroslices < numCompMsInTs ) - { - fuPulserMaxNbMicroslices = numCompMsInTs; - - fvuChanNbHitsInMs.resize( fuNbStsXyters ); - fvdChanLastHitTimeInMs.resize( fuNbStsXyters ); - fvusChanLastHitAdcInMs.resize( fuNbStsXyters ); - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fvuChanNbHitsInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvdChanLastHitTimeInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvusChanLastHitAdcInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - { - fvuChanNbHitsInMs[ uXyterIdx ][ uChan ].resize( fuPulserMaxNbMicroslices ); - fvdChanLastHitTimeInMs[ uXyterIdx ][ uChan ].resize( fuPulserMaxNbMicroslices ); - fvusChanLastHitAdcInMs[ uXyterIdx ][ uChan ].resize( fuPulserMaxNbMicroslices ); - for( UInt_t uMsIdx = 0; uMsIdx < fuPulserMaxNbMicroslices; ++uMsIdx ) - { - fvuChanNbHitsInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = 0; - fvdChanLastHitTimeInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = -1.0; - fvusChanLastHitAdcInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = 0; - } // for( UInt_t uMsIdx = 0; uMsIdx < fuPulserMaxNbMicroslices; ++uMsIdx ) - } // for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - LOG(info) << "CbmCern2017MonitorRawSts::DoUnpack => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs.size() << " VS " << fuNbStsXyters; - LOG(info) << "CbmCern2017MonitorRawSts::DoUnpack => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs[ 0 ].size() << " VS " << fuNbChanPerAsic; - LOG(info) << "CbmCern2017MonitorRawSts::DoUnpack => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs[ 0 ][ 0 ].size() << " VS " << fuPulserMaxNbMicroslices; - } // if( fuPulserMaxNbMicroslices < numCompMsInTs ) - - for( size_t m = 0; m < numCompMsInTs; ++m ) - { - // Ignore overlap ms if number defined by user - if( numCompMsInTs - fuOverlapMsNb <= m ) - continue; - - auto msDescriptor = ts.descriptor(component, m); - fuCurrentEquipmentId = msDescriptor.eq_id; - const uint8_t* msContent = reinterpret_cast<const uint8_t*>(ts.content(component, m)); - - uint32_t size = msDescriptor.size; - LOG(debug) << "Microslice: " << msDescriptor.idx - << " has size: " << size; - - if( component < kiMaxNbFlibLinks ) - { - if( fdStartTimeMsSz < 0 ) - fdStartTimeMsSz = (1e-9) * static_cast<double>(msDescriptor.idx); - fhMsSz[ component ]->Fill( size ); - fhMsSzTime[ component ]->Fill( (1e-9) * static_cast<double>( msDescriptor.idx) - fdStartTimeMsSz, size); - } // if( component < kiMaxNbFlibLinks ) - - if( 0 == component && 0 == ( ( msDescriptor.idx / 1000000000 ) % 10 ) - && 0 == ( ( msDescriptor.idx / 100000 ) ) %50000 ) - { - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fhStsChanSameMsTimeDiff[uXyterIdx]->Reset(); - TH2* tempProj = fpStsChanSameMsTimeDiff[uXyterIdx]->ProjectionXY( ); - fhStsChanSameMsTimeDiff[uXyterIdx]->Add( tempProj ); - delete tempProj; -/* - for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - for( UInt_t uChanB = uChan + 1; uChanB < fuNbChanPerAsic; ++uChanB ) - if( 0 < fpStsChanSameMsTimeDiff[uXyterIdx]->GetBinEntries( fpStsChanSameMsTimeDiff[uXyterIdx]->GetBin( uChan, uChanB ) ) ) - { - LOG(debug) << "Microslice Index = " << (msDescriptor.idx / 1000000000) - << "s, ASIC " << uXyterIdx << " Chan " << uChan << " VS " << uChanB - << " Entries " << fpStsChanSameMsTimeDiff[uXyterIdx]->GetBinEntries( fpStsChanSameMsTimeDiff[uXyterIdx]->GetBin( uChan, uChanB ) ) - << " Mean time diff "<< fpStsChanSameMsTimeDiff[uXyterIdx]->GetBinContent( uChan, uChanB ) - << " Error " << fpStsChanSameMsTimeDiff[uXyterIdx]->GetBinError( uChan, uChanB ); - } // if( 0 < fpStsChanSameMsTimeDiff[uXyterIdx]->GetBinEntries( uChan, uChanB ) ) -*/ - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - } // if( 0 == ( ( msDescriptor.idx / 1e-9 ) % 10 ) ) - - // If not integer number of message in input buffer, print warning/error - if( 0 != (size % kuBytesPerRawMessage) ) - LOG(error) << "The input microslice buffer does NOT " - << "contain only complete nDPB messages!"; - - // Compute the number of complete messages in the input microslice buffer - uint32_t uNbRawMessages = (size - (size % kuBytesPerRawMessage) ) - / kuBytesPerRawMessage; - - // Prepare variables for the loop on contents - const uint64_t* pInBuff = reinterpret_cast<const uint64_t*>( msContent ); - for( uint32_t uIdx = 0; uIdx < uNbRawMessages; ++uIdx ) - { - // Fill message - uint64_t ulData = static_cast<uint64_t>(pInBuff[uIdx]); - - // temp solution until the DPB ID is moved to the equipment ID field in MS header - // The ID is the same in all messages, so no need to do it for each - if( 0 == uIdx ) - { -// fuCurrDpbId = static_cast< uint32_t >( (ulData >> 32) & 0xFFFFFFFF ); - fuCurrDpbId = static_cast< uint32_t >( (ulData >> 48) & 0xFFFF ); - fuCurrDpbIdx = fDpbIdIndexMap[ fuCurrDpbId ]; -/* - LOG(info) << "CbmCern2017MonitorRawSts::DoUnpack => " - << "Data in DPB " << fuCurrDpbIdx - << " With ID " << std::setw(8) << std::hex << fuCurrDpbId << std::dec - << " VS " << std::setw(8) << std::hex << fUnpackPar->GetDpbId( 0 ) << std::dec - << " or " << std::setw(8) << std::hex << fUnpackPar->GetDpbId( 1 ) << std::dec - << " " << ( fUnpackPar->GetDpbId( 1 ) - fuCurrDpbId ); -*/ - } // if( 0 == uIdx ) - - stsxyter::RawMessage mess( static_cast< uint32_t >( ulData & 0xFFFFFFFF ) ); - - // Print message if requested - if( fbPrintRawMessages ) - mess.PrintMess( std::cout, fPrintMessCtrl ); - - // Extract the eLink and Asic indices - UShort_t usElinkIdx = mess.GetLinkIndex(); - if( fuNbElinksPerDpb <= usElinkIdx ) - { - LOG(fatal) << "CbmCern2017MonitorRawSts::DoUnpack => " - << "eLink index out of bounds!"; - } // if( fuNbElinksPerDpb <= usElinkIdx ) - UInt_t uAsicIdx = fvuElinkToAsic[fuCurrDpbIdx][usElinkIdx]; - - stsxyter::RawMessType typeMess = mess.GetRawMessType(); - fmMsgCounter[ typeMess ] ++; - fhStsMessType->Fill( static_cast< uint16_t > (typeMess) ); - fhStsMessTypePerDpb->Fill( fuCurrDpbIdx, static_cast< uint16_t > (typeMess) ); - - switch( typeMess ) - { - case stsxyter::RawMessType::Hit : - { - FillHitInfo( mess, usElinkIdx, uAsicIdx, m ); - break; - } // case stsxyter::RawMessType::Hit : - case stsxyter::RawMessType::TsMsb : - { - FillTsMsbInfo( mess, usElinkIdx, uAsicIdx ); - break; - } // case stsxyter::RawMessType::TsMsb : - case stsxyter::RawMessType::Dummy : - case stsxyter::RawMessType::ReadDataAck : - case stsxyter::RawMessType::Ack : - { - break; - } // case stsxyter::RawMessType::Dummy / ReadDataAck / Ack : - default: - { - LOG(fatal) << "CbmCern2017MonitorRawSts::DoUnpack => " - << "Unknown message type, should never happen, stopping here!"; - } - } // switch( mess.GetRawMessType() ) - } // for( uint32_t uIdx = 0; uIdx < uNbRawMessages; ++uIdx ) - } // for( size_t m = 0; m < numCompMsInTs; ++m ) - - - // End of TS, check if stuff to do with the hits inside each MS - // Usefull for low rate pulser tests - // Need to do it only when last DPB is processed, as they are done one by one - if( fuCurrDpbIdx == fuNrOfDpbs - 1 ) - for( UInt_t uMsIdx = 0; uMsIdx < fuPulserMaxNbMicroslices; ++uMsIdx ) - { - if( kTRUE == fbPulserTimeDiffOn ) - { - UInt_t uNbPulserChans = fvuPulserAsic.size(); - UInt_t uHistoIdx = 0; - for( UInt_t uChA = 0; uChA < uNbPulserChans; ++uChA ) - for( UInt_t uChB = uChA + 1; uChB < uNbPulserChans; ++uChB ) - { - if( 0 < fvuChanNbHitsInMs[ fvuPulserAsic[uChA] ][ fvuPulserChan[uChA] ][ uMsIdx ] && - 0 < fvuChanNbHitsInMs[ fvuPulserAsic[uChB] ][ fvuPulserChan[uChB] ][ uMsIdx ] ) - { - Double_t dTimeDiff = fvdChanLastHitTimeInMs[ fvuPulserAsic[uChB] ][ fvuPulserChan[uChB] ][ uMsIdx ] - - fvdChanLastHitTimeInMs[ fvuPulserAsic[uChA] ][ fvuPulserChan[uChA] ][ uMsIdx ]; -/* - Short_t sAdcDiff = static_cast< Short_t >( fvusChanLastHitAdcInMs[ fvuPulserAsic[uChB] ][ fvuPulserChan[uChB] ][ uMsIdx ] ) - - static_cast< Short_t >( fvusChanLastHitAdcInMs[ fvuPulserAsic[uChA] ][ fvuPulserChan[uChA] ][ uMsIdx ] ); -*/ -/* - if( dTimeDiff < -51203.125 ) - dTimeDiff += 51203.125; - else if( 51203.125 < dTimeDiff ) - dTimeDiff -= 51203.125; -*/ - if( dTimeDiff < -102406.25 || 102406.25 < dTimeDiff ) - LOG(info) << "CbmCern2017MonitorRawSts::DoUnpack =>" - << " ASIC A" << fvuPulserAsic[uChA] << " chan A " << fvuPulserChan[uChA] << " tA " << fvdChanLastHitTimeInMs[ fvuPulserAsic[uChA] ][ fvuPulserChan[uChA] ][ uMsIdx ] - << " ASIC B" << fvuPulserAsic[uChB] << " chan B " << fvuPulserChan[uChB] << " tB " << fvdChanLastHitTimeInMs[ fvuPulserAsic[uChB] ][ fvuPulserChan[uChB] ][ uMsIdx ] - << " dt " << dTimeDiff; - - if( dTimeDiff < -102406.25 ) - dTimeDiff += 102406.25; - else if( 102406.25 < dTimeDiff ) - dTimeDiff -= 102406.25; - - fhStsPulserChansTimeDiff[ uHistoIdx ]->Fill( dTimeDiff ); - } // Both pulser channels got data in last MS - uHistoIdx ++; - } // Loop on channel pairs - } // if( kTRUE == fbPulserTimeDiffOn ) - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - { - fhStsChanHitsPerMs[uXyterIdx]->Fill( fvuChanNbHitsInMs[ uXyterIdx ][ uChan ][ uMsIdx ], uChan ); - - // Coincidences between - if( fvuChanNbHitsInMs[ uXyterIdx ][ uChan ][ uMsIdx ] ) - for( UInt_t uChanB = uChan + 1; uChanB < fuNbChanPerAsic; ++uChanB ) - if( fvuChanNbHitsInMs[ uXyterIdx ][ uChanB ][ uMsIdx ] ) - { - fhStsChanSameMs[ uXyterIdx ]->Fill( uChan, uChanB ); - Double_t dTimeDiff = fvdChanLastHitTimeInMs[ uXyterIdx ][ uChanB ][ uMsIdx ] - - fvdChanLastHitTimeInMs[ uXyterIdx ][ uChan ][ uMsIdx ]; - - fpStsChanSameMsTimeDiff[ uXyterIdx ]->Fill( uChan, uChanB, dTimeDiff ); - } // if( fvuChanNbHitsInMs[ uXyterIdx ][ uChanB ] ) - -/* - // Pulser test: Coincidences between different FEEs (maybe on different DPBs) - for( UInt_t uXyterIdxB = uXyterIdx; uXyterIdxB < fuNbStsXyters; ++uXyterIdxB ) - { - for( UInt_t uChanB = 0; uChanB < fuNbChanPerAsic; ++uChanB ) - { - } // for( UInt_t uChanB = 0; uChanB < fuNbChanPerAsic; ++uChanB ) - } // for( UInt_t uXyterIdxB = uXyterIdx; uXyterIdxB < fuNbStsXyters; ++uXyterIdxB ) -*/ - // Ok to reset as we only compare to channels with higher indices (or channels in ASICs with higher indices) - fvuChanNbHitsInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = 0; - fvdChanLastHitTimeInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = -1.0; - fvusChanLastHitAdcInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = 0; - } // for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - } // for( UInt_t uMsIdx = 0; uMsIdx < fuPulserMaxNbMicroslices; ++uMsIdx ) - - return kTRUE; -} - -void CbmCern2017MonitorRawSts::FillHitInfo( stsxyter::RawMessage mess, const UShort_t & usElinkIdx, const UInt_t & uAsicIdx, const UInt_t & uMsIdx ) -{ - UShort_t usChan = mess.GetHitChannel(); - UShort_t usRawAdc = mess.GetHitAdc(); -// UShort_t usFullTs = mess.GetHitTimeFull(); - UShort_t usTsOver = mess.GetHitTimeOver(); - UShort_t usRawTs = mess.GetHitTime(); - - fhStsChanCounts[ uAsicIdx ]->Fill( usChan ); - fhStsChanRawAdc[ uAsicIdx ]->Fill( usChan, usRawAdc ); - fhStsChanRawAdcProf[ uAsicIdx ]->Fill( usChan, usRawAdc ); - fhStsChanRawTs[ uAsicIdx ]->Fill( usChan, usRawTs ); - fhStsChanMissEvt[ uAsicIdx ]->Fill( usChan, mess.IsHitMissedEvts() ); - - // Compute the Full time stamp -/* - if( fvuCurrentTsMsbOver[fuCurrDpbIdx][usElinkIdx] == usTsOver ) - { - // Hit stamped in same TsMsb as sent to eLink - // Need TS cycle counter as otherwise period of only 102.400 us!!! - fvulChanLastHitTime[ uAsicIdx ][ usChan ] = usRawTs - + stsxyter::kuRawHitNbTsBins * static_cast<ULong64_t>( fvuCurrentTsMsb[fuCurrDpbIdx][usElinkIdx] ) - + stsxyter::kuRawTsCycleNbBins * static_cast<ULong64_t>( fvuCurrentTsMsbCycle[fuCurrDpbIdx][usElinkIdx] ); - } // if( (fvuCurrentTsMsb[fuCurrDpbIdx][usElinkIdx] & stsxyter::kusRawMaskTsMsbOver) == usTsOver ) - else if( (fvuCurrentTsMsb[fuCurrDpbIdx][usElinkIdx] & stsxyter::kusRawMaskTsMsbOver) - == ((usTsOver + 1) % (stsxyter::kusRawMaskTsMsbOver + 1)) ) - { - // Hit stamped in previous TsMsb compared to last Ts_MSB on same eLink - // Need TS cycle counter as otherwise period of only 102.400 us!!! - fvulChanLastHitTime[ uAsicIdx ][ usChan ] = usRawTs; - if( 0 == fvuCurrentTsMsb[fuCurrDpbIdx][usElinkIdx] ) - { - if( 0 == fvuCurrentTsMsbCycle[fuCurrDpbIdx][usElinkIdx] ) - { - // TO BE CHECKED - LOG(warning) << "CbmCern2017MonitorRawSts::FillHitInfo => " - << "Ignore Hit as coming from TS_MSB before system start!"; - return; - } // if( 0 == fvuCurrentTsMsbCycle[fuCurrDpbIdx][usElinkIdx] ) - - fvulChanLastHitTime[ uAsicIdx ][ usChan ] += - stsxyter::kuRawHitNbTsBins * static_cast<ULong64_t>( fvuCurrentTsMsb[fuCurrDpbIdx][usElinkIdx] - + stsxyter::kuRawTsCycleNbBins - 1 ) - + stsxyter::kuRawTsCycleNbBins * static_cast<ULong64_t>( fvuCurrentTsMsbCycle[fuCurrDpbIdx][usElinkIdx] - 1 ); - } // if( 0 == fvuCurrentTsMsb[fuCurrDpbIdx][usElinkIdx] ) - else fvulChanLastHitTime[ uAsicIdx ][ usChan ] += - stsxyter::kuRawHitNbTsBins * static_cast<ULong64_t>( fvuCurrentTsMsb[fuCurrDpbIdx][usElinkIdx] - 1 ) - + stsxyter::kuRawTsCycleNbBins * static_cast<ULong64_t>( fvuCurrentTsMsbCycle[fuCurrDpbIdx][usElinkIdx] ); - - } // else if overlap bit from hit are exactly 1 unit behind the one from last Ts_Msb - else - { - // Overlap is neither matching nor 1 less than bits from TS_MSB - // Should not happen if I understood properly how the ASIC behaves ?!? - LOG(fatal) << "CbmCern2017MonitorRawSts::FillHitInfo => " - << "TS overlap bits from hit not fitting the ones from last TS MSB on this eLink! \n" - << "Hit Overlap: 0x" << std::hex << usTsOver << " Full TS: 0x" << usFullTs << "\n" - << "MSB Overlap: 0x" << (fvuCurrentTsMsb[fuCurrDpbIdx][usElinkIdx] & stsxyter::kusRawMaskTsMsbOver) - << " Ts Msb: 0x" << fvuCurrentTsMsb[fuCurrDpbIdx][usElinkIdx] << "\n" - << "Other eLinks: \n"; - for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink ) - LOG(fatal) << std::setw(3) << std::dec << uElink << " => " - << std::hex << "0x" << (fvuCurrentTsMsb[fuCurrDpbIdx][uElink] & stsxyter::kusRawMaskTsMsbOver) - << " => " << "0x" << (fvuCurrentTsMsb[fuCurrDpbIdx][uElink] & stsxyter::kusRawMaskTsMsbOver) << "\n"; - LOG(fatal) << std::dec; - return; - } // else of overlap checks -*/ - // Use TS w/o overlap bits as they will anyway come from the TS_MSB - fvulChanLastHitTime[ uAsicIdx ][ usChan ] = usRawTs; - // Overlap need to be used to correct the TS_MSB - // Formula used here gives the following correction table - /* - * | TS MSB Over - * | 0 | 1 | 2 | 3 - * _____|___|___|___|___ - * H 0 | 0 | 1 | 2 | 3 - * I ___|___|___|___|___ - * T 1 | 3 | 0 | 1 | 2 - * ____|___|___|___|___ - * O 2 | 2 | 3 | 0 | 1 - * V ___|___|___|___|___ - * E 3 | 1 | 2 | 3 | 0 - * R | | | | - */ - UInt_t uTsMsbCorr = ( stsxyter::kuRawHitNbOverBins + fvuCurrentTsMsbOver[fuCurrDpbIdx][usElinkIdx] - usTsOver ) - % stsxyter::kuRawHitNbOverBins; - fhStsChanOverDiff[ uAsicIdx ]->Fill( usChan, uTsMsbCorr ); - - // Need TS cycle counter as otherwise period of only 102.400 us!!! - // => Check if we need also a TS MSB cycle correction - if( fvuCurrentTsMsb[fuCurrDpbIdx][usElinkIdx] < uTsMsbCorr ) - { - if( 0 == fvuCurrentTsMsbCycle[fuCurrDpbIdx][usElinkIdx] ) - { - // TO BE CHECKED - LOG(warning) << "CbmCern2017MonitorRawSts::FillHitInfo => " - << "Ignore Hit as coming from TS_MSB before system start!"; - return; - } // if( 0 == fvuCurrentTsMsbCycle[fuCurrDpbIdx][usElinkIdx] ) - - fvulChanLastHitTime[ uAsicIdx ][ usChan ] += - stsxyter::kuRawHitNbTsBins * static_cast<ULong64_t>( fvuCurrentTsMsb[fuCurrDpbIdx][usElinkIdx] - + stsxyter::kuRawHitNbTsBins - uTsMsbCorr ) -// + stsxyter::kuRawTsCycleNbBins * static_cast<ULong64_t>( fvuCurrentTsMsbCycle[fuCurrDpbIdx][usElinkIdx] - 1 ) - ; - } // if( fvuCurrentTsMsb[fuCurrDpbIdx][usElinkIdx] < uTsMsbCorr ) - else fvulChanLastHitTime[ uAsicIdx ][ usChan ] += - stsxyter::kuRawHitNbTsBins * static_cast<ULong64_t>( fvuCurrentTsMsb[fuCurrDpbIdx][usElinkIdx] - uTsMsbCorr ) -// + stsxyter::kuRawTsCycleNbBins * static_cast<ULong64_t>( fvuCurrentTsMsbCycle[fuCurrDpbIdx][usElinkIdx] ) - ; - - // Convert the Hit time in bins to Hit time in ns - Double_t dHitTimeNs = fvulChanLastHitTime[ uAsicIdx ][ usChan ] * stsxyter::kdRawClockCycleNs; - - - // If needed fill the hit interval plots - if( fbChanHitDtEna ) - { - Double_t dDeltaT = dHitTimeNs - fvdChanLastHitTime[ uAsicIdx ][ usChan ]; - if( 0 == dDeltaT ) - fhStsChanHitDtNeg[ uAsicIdx ]->Fill( 1, usChan ); - else if( 0 < dDeltaT ) - fhStsChanHitDt[ uAsicIdx ]->Fill( dDeltaT, usChan ); - else fhStsChanHitDtNeg[ uAsicIdx ]->Fill( -dDeltaT, usChan ); - } // if( fbChanHitDtEna ) - - // Store new value of Hit time in ns - fvdChanLastHitTime[ uAsicIdx ][ usChan ] = fvulChanLastHitTime[ uAsicIdx ][ usChan ]; - - // Pulser and MS - fvuChanNbHitsInMs[ uAsicIdx ][ usChan ][ uMsIdx ] ++; - fvdChanLastHitTimeInMs[ uAsicIdx ][ usChan ][ uMsIdx ] = dHitTimeNs; - fvusChanLastHitAdcInMs[ uAsicIdx ][ usChan ][ uMsIdx ] = usRawAdc; - - // Check Starting point of histos with time as X axis - if( -1 == fdStartTime ) - fdStartTime = fvdChanLastHitTime[ uAsicIdx ][ usChan ]; - - // Fill histos with time as X axis - Double_t dTimeSinceStartSec = (fvdChanLastHitTime[ uAsicIdx ][ usChan ] - fdStartTime)* 1e-9; - Double_t dTimeSinceStartMin = dTimeSinceStartSec / 60.0; - fhStsChanHitRateEvo[ uAsicIdx ]->Fill( dTimeSinceStartSec , usChan ); - fhStsXyterRateEvo[ uAsicIdx ]->Fill( dTimeSinceStartSec ); - fhStsChanHitRateEvoLong[ uAsicIdx ]->Fill( dTimeSinceStartMin, usChan, 1.0/60.0 ); - fhStsXyterRateEvoLong[ uAsicIdx ]->Fill( dTimeSinceStartMin, 1.0/60.0 ); - - if( kTRUE == fbLongHistoEnable ) - { - std::chrono::steady_clock::time_point tNow = std::chrono::steady_clock::now(); - Double_t dUnixTimeInRun = std::chrono::duration_cast< std::chrono::seconds >(tNow - ftStartTimeUnix).count(); - fhFebRateEvoLong[ uAsicIdx ]->Fill( dUnixTimeInRun , 1.0 / fuLongHistoBinSizeSec ); - fhFebChRateEvoLong[ uAsicIdx ]->Fill( dUnixTimeInRun , usChan, 1.0 / fuLongHistoBinSizeSec ); - } // if( kTRUE == fbLongHistoEnable ) - -} - -void CbmCern2017MonitorRawSts::FillTsMsbInfo( stsxyter::RawMessage mess, const UShort_t & usElinkIdx, const UInt_t & uAsicIdx ) -{ - UShort_t usValA = mess.GetTsMsbValA(); -// UShort_t usValB = mess.GetTsMsbValB(); -// UShort_t usValC = mess.GetTsMsbValC(); - bool bCrcCheck = mess.TsMsbCrcCheck(); - - // Fill CRC check histo as independent of other data processing - fhStsElinkTsMsbCrc[fuCurrDpbIdx]->Fill( usElinkIdx, ( bCrcCheck ? 1 : 0 ) ); - - if( bCrcCheck ) - { - // Everything ok - - // Update Status counters - if( usValA < fvuCurrentTsMsb[fuCurrDpbIdx][usElinkIdx] ) - fvuCurrentTsMsbCycle[fuCurrDpbIdx][usElinkIdx] ++; - fvuCurrentTsMsb[fuCurrDpbIdx][usElinkIdx] = usValA; - - fhStsAsicTsMsb->Fill( fvuCurrentTsMsb[fuCurrDpbIdx][usElinkIdx], uAsicIdx ); - fhStsAsicTsMsbMaj->Fill( uAsicIdx, 3 ); - fhStsElinkTsMsbMaj[fuCurrDpbIdx]->Fill( usElinkIdx, 3 ); - } // if( bCrcCheck ) - else - { - // Either nor 3 agreement or bad CRC - UShort_t uMajVal = 0; - mess.GetTsMsbValCorr( uMajVal ); - if( stsxyter::kusRawInvalidTsMsb == uMajVal ) - { - // No majority => value cannot be recovered & used - LOG(warning) << "CbmCern2017MonitorRawSts::FillTsMsbInfo => " - << " Ignoring value for DPB " << fuCurrDpbIdx - << " and link " << usElinkIdx << " (ASIC " << uAsicIdx << ") " - << " as not majority can be found!! CRC check " << bCrcCheck; - - fhStsAsicTsMsbMaj->Fill( uAsicIdx, 1 ); - fhStsElinkTsMsbMaj[fuCurrDpbIdx]->Fill( usElinkIdx, 1 ); - - return; - } // if( stsxyter::kusRawInvalidTsMsb == uMajVal ) - - // Update Status counters - if( uMajVal < fvuCurrentTsMsb[fuCurrDpbIdx][usElinkIdx] ) - fvuCurrentTsMsbCycle[fuCurrDpbIdx][usElinkIdx] ++; - fvuCurrentTsMsb[fuCurrDpbIdx][usElinkIdx] = uMajVal; - - fhStsAsicTsMsb->Fill( fvuCurrentTsMsb[fuCurrDpbIdx][usElinkIdx], uAsicIdx ); - - // Get majority count used (should be 2 or 3) - UShort_t uMajCnt = mess. GetTsMsbMajCnt(); - fhStsAsicTsMsbMaj->Fill( uAsicIdx, uMajCnt ); - fhStsElinkTsMsbMaj[fuCurrDpbIdx]->Fill( usElinkIdx, uMajCnt ); - } // else of if( bCrcCheck ) - - // Update the overlap bits for this eLink - fvuCurrentTsMsbOver[fuCurrDpbIdx][usElinkIdx] = fvuCurrentTsMsb[fuCurrDpbIdx][usElinkIdx] - & stsxyter::kusRawMaskTsMsbOver; -} - -void CbmCern2017MonitorRawSts::Reset() -{ -} - -void CbmCern2017MonitorRawSts::Finish() -{ - - LOG(info) << "-------------------------------------"; - LOG(info) << "CbmCern2017MonitorRawSts statistics are "; - LOG(info) << " Hit messages: " << fmMsgCounter[ stsxyter::RawMessType::Hit ] << "\n" - << " Ts MSB messages: " << fmMsgCounter[ stsxyter::RawMessType::TsMsb ] << "\n" - << " Dummy messages: " << fmMsgCounter[ stsxyter::RawMessType::TsMsb ] << "\n" - << " Read Ack messages: " << fmMsgCounter[ stsxyter::RawMessType::TsMsb ] << "\n" - << " Ack messages: " << fmMsgCounter[ stsxyter::RawMessType::TsMsb ]; - - LOG(info) << "-------------------------------------"; - - SaveAllHistos(); - -} - - -void CbmCern2017MonitorRawSts::FillOutput(boost::any) -{ -} - -void CbmCern2017MonitorRawSts::SaveAllHistos( TString sFileName ) -{ - TDirectory * oldDir = NULL; - TFile * histoFile = NULL; - if( "" != sFileName ) - { - // Store current directory position to allow restore later - oldDir = gDirectory; - // open separate histo file in recreate mode - histoFile = new TFile( sFileName , "RECREATE"); - histoFile->cd(); - } // if( "" != sFileName ) - - gDirectory->mkdir("Sts_Raw"); - gDirectory->cd("Sts_Raw"); - - fhStsMessType->Write(); - fhStsSysMessType->Write(); - fhStsMessTypePerDpb->Write(); - fhStsSysMessTypePerDpb->Write(); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fhStsChanCounts[ uXyterIdx ]->Write(); - fhStsChanRawAdc[ uXyterIdx ]->Write(); - fhStsChanRawAdcProf[ uXyterIdx ]->Write(); - fhStsChanRawTs[ uXyterIdx ]->Write(); - fhStsChanMissEvt[ uXyterIdx ]->Write(); - fhStsChanOverDiff[ uXyterIdx ]->Write(); - fhStsChanHitRateEvo[ uXyterIdx ]->Write(); - fhStsXyterRateEvo[ uXyterIdx ]->Write(); - fhStsChanHitRateEvoLong[ uXyterIdx ]->Write(); - fhStsXyterRateEvoLong[ uXyterIdx ]->Write(); - if( fbChanHitDtEna ) - { - fhStsChanHitDt[ uXyterIdx ]->Write(); - fhStsChanHitDtNeg[ uXyterIdx ]->Write(); - } // if( fbChanHitDtEna ) - fhStsChanHitsPerMs[ uXyterIdx ]->Write(); - fhStsChanSameMs[ uXyterIdx ]->Write(); - fpStsChanSameMsTimeDiff[ uXyterIdx ]->Write(); - fhStsChanSameMsTimeDiff[ uXyterIdx ]->Write(); - if( kTRUE == fbLongHistoEnable ) - { - fhFebRateEvoLong[ uXyterIdx ]->Write(); - fhFebChRateEvoLong[ uXyterIdx ]->Write(); - } // if( kTRUE == fbLongHistoEnable ) - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - - if( kTRUE == fbPulserTimeDiffOn ) - { - UInt_t uNbPulserChans = fvuPulserAsic.size(); - UInt_t uHistoIdx = 0; - for( UInt_t uChA = 0; uChA < uNbPulserChans; ++uChA ) - for( UInt_t uChB = uChA + 1; uChB < uNbPulserChans; ++uChB ) - { - fhStsPulserChansTimeDiff[ uHistoIdx ]->Write(); - uHistoIdx ++; - } // Loop on channel pairs - } // if( kTRUE == fbPulserTimeDiffOn ) - - fhStsAsicTsMsb->Write(); - fhStsAsicTsMsbMaj->Write(); - - for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - { - fhStsElinkTsMsbCrc[ uDpb ]->Write(); - fhStsElinkTsMsbMaj[ uDpb ]->Write(); - } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - - gDirectory->cd(".."); - - // Flib Histos - gDirectory->mkdir("Flib_Raw"); - gDirectory->cd("Flib_Raw"); - for( UInt_t uLinks = 0; uLinks < kiMaxNbFlibLinks; uLinks ++) - { - TString sMsSzName = Form("MsSz_link_%02u", uLinks); - if( fHM->Exists(sMsSzName.Data() ) ) - fHM->H1( sMsSzName.Data() )->Write(); - - sMsSzName = Form("MsSzTime_link_%02u", uLinks); - if( fHM->Exists(sMsSzName.Data() ) ) - fHM->P1( sMsSzName.Data() )->Write(); - } // for( UInt_t uLinks = 0; uLinks < 16; uLinks ++) - gDirectory->cd(".."); - - if( "" != sFileName ) - { - // Restore original directory position - histoFile->Close(); - oldDir->cd(); - } // if( "" != sFileName ) - -} -void CbmCern2017MonitorRawSts::ResetAllHistos() -{ - LOG(info) << "Reseting all STS histograms."; - - fhStsMessType->Reset(); - fhStsSysMessType->Reset(); - fhStsMessTypePerDpb->Reset(); - fhStsSysMessTypePerDpb->Reset(); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fhStsChanCounts[ uXyterIdx ]->Reset(); - fhStsChanRawAdc[ uXyterIdx ]->Reset(); - fhStsChanRawAdcProf[ uXyterIdx ]->Reset(); - fhStsChanRawTs[ uXyterIdx ]->Reset(); - fhStsChanMissEvt[ uXyterIdx ]->Reset(); - fhStsChanOverDiff[ uXyterIdx ]->Reset(); - fhStsChanHitRateEvo[ uXyterIdx ]->Reset(); - fhStsXyterRateEvo[ uXyterIdx ]->Reset(); - fhStsChanHitRateEvoLong[ uXyterIdx ]->Reset(); - fhStsXyterRateEvoLong[ uXyterIdx ]->Reset(); - if( fbChanHitDtEna ) - { - fhStsChanHitDt[ uXyterIdx ]->Reset(); - fhStsChanHitDtNeg[ uXyterIdx ]->Reset(); - } // if( fbChanHitDtEna ) - fhStsChanHitsPerMs[ uXyterIdx ]->Reset(); - fhStsChanSameMs[ uXyterIdx ]->Reset(); - fpStsChanSameMsTimeDiff[ uXyterIdx ]->Reset(); - fhStsChanSameMsTimeDiff[ uXyterIdx ]->Reset(); - if( kTRUE == fbLongHistoEnable ) - { - ftStartTimeUnix = std::chrono::steady_clock::now(); - fhFebRateEvoLong[ uXyterIdx ]->Reset(); - fhFebChRateEvoLong[ uXyterIdx ]->Reset(); - } // if( kTRUE == fbLongHistoEnable ) - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - - if( kTRUE == fbPulserTimeDiffOn ) - { - UInt_t uNbPulserChans = fvuPulserAsic.size(); - UInt_t uHistoIdx = 0; - for( UInt_t uChA = 0; uChA < uNbPulserChans; ++uChA ) - for( UInt_t uChB = uChA + 1; uChB < uNbPulserChans; ++uChB ) - { - fhStsPulserChansTimeDiff[ uHistoIdx ]->Reset(); - uHistoIdx ++; - } // Loop on channel pairs - } // if( kTRUE == fbPulserTimeDiffOn ) - - fhStsAsicTsMsb->Reset(); - fhStsAsicTsMsbMaj->Reset(); - - for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - { - fhStsElinkTsMsbCrc[ uDpb ]->Reset(); - fhStsElinkTsMsbMaj[ uDpb ]->Reset(); - } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - - for( UInt_t uLinks = 0; uLinks < kiMaxNbFlibLinks; ++uLinks ) - { - TString sMsSzName = Form("MsSz_link_%02u", uLinks); - if( fHM->Exists(sMsSzName.Data() ) ) - fHM->H1( sMsSzName.Data() )->Reset(); - - sMsSzName = Form("MsSzTime_link_%02u", uLinks); - if( fHM->Exists(sMsSzName.Data() ) ) - fHM->P1( sMsSzName.Data() )->Reset(); - } // for( UInt_t uLinks = 0; uLinks < kiMaxNbFlibLinks; ++uLinks ) - - fdStartTime = -1; - fdStartTimeMsSz = -1; -} - -void CbmCern2017MonitorRawSts::SetRunStart( Int_t dateIn, Int_t timeIn, Int_t iBinSize ) -{ - TDatime * fRunStartDateTime = new TDatime( dateIn, timeIn); - fiRunStartDateTimeSec = fRunStartDateTime->Convert(); - fiBinSizeDatePlots = iBinSize; - - LOG(info) << "Assigned new MUCH Run Start Date-Time: " << fRunStartDateTime->AsString(); -} -void CbmCern2017MonitorRawSts::SetPulserChannels( UInt_t uAsicA, UInt_t uChanA, UInt_t uAsicB, UInt_t uChanB, - UInt_t uAsicC, UInt_t uChanC, UInt_t uAsicD, UInt_t uChanD, - UInt_t uMaxNbMicroslices ) -{ -/* - THttpServer* server = FairRunOnline::Instance()->GetHttpServer(); - TString sHistName{""}; - TString title{""}; -*/ - fuPulserMaxNbMicroslices = uMaxNbMicroslices; - - UInt_t uNbChans = 4; - - fvuPulserAsic.resize( uNbChans ); - fvuPulserChan.resize( uNbChans ); - fvuPulserAsic[0] = uAsicA; - fvuPulserChan[0] = uChanA; - fvuPulserAsic[1] = uAsicB; - fvuPulserChan[1] = uChanB; - fvuPulserAsic[2] = uAsicC; - fvuPulserChan[2] = uChanC; - fvuPulserAsic[3] = uAsicD; - fvuPulserChan[3] = uChanD; -/* - // Remove old histos - if( kTRUE == fbPulserTimeDiffOn ) - { - for( Int_t iIdx = 0; iIdx < fhStsPulserChansTimeDiff.size(); ++iIdx ) - delete fhStsPulserChansTimeDiff[ iIdx ]; - } // if( kTRUE == fbPulserTimeDiffOn ) - fhStsPulserChansTimeDiff.clear(); - - for( UInt_t uChA = 0; uChA < uNbChans; ++uChA ) - for( UInt_t uChB = uChA + 1; uChB < uNbChans; ++uChB ) - { - sHistName = Form( "hStsPulserTimeDiff_%02u_%03u_%02u_%03u", - fvuPulserAsic[uChA], fvuPulserChan[uChA], - fvuPulserAsic[uChB], fvuPulserChan[uChB] ); - title = "Time diff for hits in same MS from ASIC %02d ch %03d and ASIC %02d ch %03d; tB - tA [ns]; Counts"; - TH1 * pHist = new TH1I(sHistName, title, 16385, -51203.125, 51203.125); - - fHM->Add(sHistName.Data(), pHist); - if( server ) server->Register("/StsRaw", pHist ); - fhStsPulserChansTimeDiff.push_back( pHist ); - } // Loop on pairs of channels -*/ - fbPulserTimeDiffOn = kTRUE; -} - -void CbmCern2017MonitorRawSts::SetLongDurationLimits( UInt_t uDurationSeconds, UInt_t uBinSize ) -{ - fbLongHistoEnable = kTRUE; - fuLongHistoNbSeconds = uDurationSeconds; - fuLongHistoBinSizeSec = uBinSize; -} - -ClassImp(CbmCern2017MonitorRawSts) diff --git a/beamtime/cern2017/unpacker/CbmCern2017MonitorRawSts.h b/beamtime/cern2017/unpacker/CbmCern2017MonitorRawSts.h deleted file mode 100644 index 796fc3371170e7f459026f35b7db1bfb99bb1fdc..0000000000000000000000000000000000000000 --- a/beamtime/cern2017/unpacker/CbmCern2017MonitorRawSts.h +++ /dev/null @@ -1,172 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmCern2017MonitorRawSts ----- -// ----- Created 25/07/17 by P.-A. Loizeau ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CBMCERN2017MONITORRAWSTS_H -#define CBMCERN2017MONITORRAWSTS_H - -#include "Timeslice.hpp" - -// Data -#include "StsXyterRawMessage.h" - -// CbmRoot -#include "CbmTSUnpack.h" -#include "CbmHistManager.h" - -// C++11 -#include <chrono> - -// C/C++ -#include <vector> -#include <map> - -class CbmCern2017UnpackParSts; - -class CbmCern2017MonitorRawSts: public CbmTSUnpack -{ -public: - - CbmCern2017MonitorRawSts(); - virtual ~CbmCern2017MonitorRawSts(); - - virtual Bool_t Init(); - - virtual Bool_t DoUnpack(const fles::Timeslice& ts, size_t component); - - virtual void Reset(); - - virtual void Finish(); - - void SetParContainers(); - - Bool_t InitContainers(); - - Bool_t ReInitContainers(); - - void FillOutput(boost::any); - - void SetRunStart( Int_t dateIn, Int_t timeIn, Int_t iBinSize = 5 ); - - void ResetAllHistos(); - void SaveAllHistos( TString sFileName = "" ); - - void SetMsOverlap(size_t uOverlapMsNb = 1) { fuOverlapMsNb = uOverlapMsNb; } - size_t GetMsOverlap() { return fuOverlapMsNb; } - - void SetPrintMessage( Bool_t bPrintMessOn = kTRUE, - stsxyter::RawMessagePrintMask ctrl = stsxyter::RawMessagePrintMask::msg_print_Hex | - stsxyter::RawMessagePrintMask::msg_print_Crc | - stsxyter::RawMessagePrintMask::msg_print_Human ) - { fbPrintRawMessages = bPrintMessOn; fPrintMessCtrl = ctrl; } - void EnableChanHitDtPlot( Bool_t bEnable = kTRUE ) { fbChanHitDtEna = bEnable; } - void SetPulserChannels( UInt_t uAsicA, UInt_t uChanA, UInt_t uAsicB, UInt_t uChanB, - UInt_t uAsicC, UInt_t uChanC, UInt_t uAsicD, UInt_t uChanD, - UInt_t uMaxNbMicroslices = 100 ); - void SetLongDurationLimits( UInt_t uDurationSeconds = 3600, UInt_t uBinSize = 1 ); - -private: - size_t fuOverlapMsNb; /** Ignore Overlap Ms: all fuOverlapMsNb MS at the end of timeslice **/ - - // Parameters - CbmCern2017UnpackParSts* fUnpackPar; //! - UInt_t fuNrOfDpbs; //! Total number of Sts DPBs in system - std::map<UInt_t, UInt_t> fDpbIdIndexMap; //! Map of DPB Identifier to DPB index - UInt_t fuNbElinksPerDpb; //! Number of possible eLinks per DPB - UInt_t fuNbStsXyters; //! Number of StsXyter ASICs - UInt_t fuNbChanPerAsic; //! Number of channels per StsXyter ASIC => should be constant somewhere!!!! - std::vector< std::vector< UInt_t > > fvuElinkToAsic; //! Vector holding for each link the corresponding ASIC index [fuNrOfDpbs * fuNbElinksPerDpb] - - // Constants - static const Int_t kiMaxNbFlibLinks = 16; - static const UInt_t kuBytesPerRawMessage = 8; - - // Internal Control/status of monitor - // Task configuration values - Bool_t fbPrintRawMessages; - stsxyter::RawMessagePrintMask fPrintMessCtrl; - Bool_t fbChanHitDtEna; - // Current data properties - std::map< stsxyter::RawMessType, UInt_t > fmMsgCounter; - UInt_t fuCurrentEquipmentId; //! Current equipment ID, tells from which DPB the current MS is originating - UInt_t fuCurrDpbId; //! Temp holder until Current equipment ID is properly filled in MS - UInt_t fuCurrDpbIdx; //! Index of the DPB from which the MS currently unpacked is coming - Int_t fiRunStartDateTimeSec; //! Start of run time since "epoch" in s, for the plots with date as X axis - Int_t fiBinSizeDatePlots; //! Bin size in s for the plots with date as X axis - std::vector< std::vector< UInt_t > > fvuCurrentTsMsb; //! Current TS MSB for each eLink - std::vector< std::vector< UInt_t > > fvuCurrentTsMsbCycle; //! Current TS MSB cycle for each eLink - std::vector< std::vector< UInt_t > > fvuCurrentTsMsbOver; //! Current TS MSB overlap bits for each eLink - std::vector< std::vector< ULong64_t > > fvulChanLastHitTime; //! Last hit time in bins for each Channel - std::vector< std::vector<Double_t> > fvdChanLastHitTime; //! Last hit time in ns for each Channel - std::vector< std::vector< std::vector< UInt_t > > > fvuChanNbHitsInMs; //! Number of hits in each MS for each Channel - std::vector< std::vector< std::vector< Double_t > > > fvdChanLastHitTimeInMs; //! Last hit time in bins in each MS for each Channel - std::vector< std::vector< std::vector< UShort_t > > > fvusChanLastHitAdcInMs; //! Last hit ADC in bins in each MS for each Channel - // Starting state book-keeping - Double_t fdStartTime; /** Time of first valid hit (TS_MSB available), used as reference for evolution plots**/ - Double_t fdStartTimeMsSz; /** Time of first microslice, used as reference for evolution plots**/ - std::chrono::steady_clock::time_point ftStartTimeUnix; /** Time of run Start from UNIX system, used as reference for long evolution plots against reception time **/ - - // Historgrams - CbmHistManager* fHM; //! Histogram manager - TH1* fhStsMessType; - TH1* fhStsSysMessType; - TH2* fhStsMessTypePerDpb; - TH2* fhStsSysMessTypePerDpb; - - std::vector<TH1*> fhStsChanCounts; - std::vector<TH2*> fhStsChanRawAdc; - std::vector<TProfile*> fhStsChanRawAdcProf; - std::vector<TH2*> fhStsChanRawTs; - std::vector<TH2*> fhStsChanMissEvt; - std::vector<TH2*> fhStsChanOverDiff; - std::vector<TH2*> fhStsChanHitRateEvo; - std::vector<TH1*> fhStsXyterRateEvo; - std::vector<TH2*> fhStsChanHitRateEvoLong; - std::vector<TH1*> fhStsXyterRateEvoLong; - std::vector<TH2*> fhStsChanHitDt; - std::vector<TH2*> fhStsChanHitDtNeg; - std::vector<TH2*> fhStsChanHitsPerMs; - std::vector<TH2*> fhStsChanSameMs; - std::vector<TProfile2D*> fpStsChanSameMsTimeDiff; - std::vector<TH2*> fhStsChanSameMsTimeDiff; - - Bool_t fbPulserTimeDiffOn; - UInt_t fuPulserMaxNbMicroslices; - std::vector<UInt_t> fvuPulserAsic; - std::vector<UInt_t> fvuPulserChan; - std::vector<TH1*> fhStsPulserChansTimeDiff; - - TH2* fhStsAsicTsMsb; - TH2* fhStsAsicTsMsbMaj; - std::vector<TH2*> fhStsElinkTsMsbCrc; - std::vector<TH2*> fhStsElinkTsMsbMaj; - - Bool_t fbLongHistoEnable; - UInt_t fuLongHistoNbSeconds; - UInt_t fuLongHistoBinSizeSec; - UInt_t fuLongHistoBinNb; - std::vector<TH1*> fhFebRateEvoLong; - std::vector<TH2*> fhFebChRateEvoLong; -/* - std::vector<TH1*> fhFebRateEvoDate; -*/ - - TCanvas* fcMsSizeAll; - TH1* fhMsSz[kiMaxNbFlibLinks]; - TProfile* fhMsSzTime[kiMaxNbFlibLinks]; - - void CreateHistograms(); - - void FillHitInfo( stsxyter::RawMessage mess, const UShort_t & usElinkIdx, const UInt_t & uAsicIdx, const UInt_t & uMsIdx ); - void FillTsMsbInfo( stsxyter::RawMessage mess, const UShort_t & usElinkIdx, const UInt_t & uAsicIdx ); - - CbmCern2017MonitorRawSts(const CbmCern2017MonitorRawSts&); - CbmCern2017MonitorRawSts operator=(const CbmCern2017MonitorRawSts&); - - ClassDef(CbmCern2017MonitorRawSts, 1) -}; - -#endif // CBMCERN2017MONITORRAWSTS_H diff --git a/beamtime/cern2017/unpacker/CbmCern2017MonitorSts.cxx b/beamtime/cern2017/unpacker/CbmCern2017MonitorSts.cxx deleted file mode 100644 index 5d17c3780912c68ec03937865f7b7d4a1d5734ed..0000000000000000000000000000000000000000 --- a/beamtime/cern2017/unpacker/CbmCern2017MonitorSts.cxx +++ /dev/null @@ -1,1655 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmCern2017MonitorSts ----- -// ----- Created 24/11/17 by P.-A. Loizeau ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#include "CbmCern2017MonitorSts.h" - -// Data - -// CbmRoot -#include "CbmCern2017UnpackParSts.h" -#include "CbmHistManager.h" - -// FairRoot -#include "FairLogger.h" -#include "FairRootManager.h" -#include "FairRun.h" -#include "FairRuntimeDb.h" -#include "FairRunOnline.h" - -// Root -#include "TClonesArray.h" -#include "TString.h" -#include "TRandom.h" -#include "THttpServer.h" -#include "TROOT.h" -#include "TStyle.h" -#include <TFile.h> - -// C++11 - -// C/C++ -#include <iostream> -#include <stdint.h> -#include <iomanip> - -Bool_t bCern2017ResetStsHistos = kFALSE; -Bool_t bCern2017WriteStsHistos = kFALSE; - -CbmCern2017MonitorSts::CbmCern2017MonitorSts() : - CbmTSUnpack(), - fuOverlapMsNb(0), - fUnpackPar(NULL), - fuNrOfDpbs(0), - fDpbIdIndexMap(), - fuNbElinksPerDpb(0), - fuNbStsXyters(0), - fuNbChanPerAsic(0), - fvuElinkToAsic(), - fbPrintMessages( kFALSE ), - fPrintMessCtrl( stsxyter::MessagePrintMask::msg_print_Human ), - fbChanHitDtEna( kFALSE ), - fulCurrentTsIdx( 0 ), - fulCurrentMsIdx( 0 ), - fmMsgCounter(), - fuCurrentEquipmentId(0), - fuCurrDpbId(0), - fuCurrDpbIdx(0), - fiRunStartDateTimeSec(-1), - fiBinSizeDatePlots(-1), - fvulCurrentTsMsb(), - fvuCurrentTsMsbCycle(), - fvuElinkLastTsHit(), - fvulChanLastHitTime(), - fvdChanLastHitTime(), - fvuChanNbHitsInMs(), - fvdChanLastHitTimeInMs(), - fvusChanLastHitAdcInMs(), - fvmChanHitsInTs(), - fdStartTime(-1.0), - fdStartTimeMsSz(-1.0), - ftStartTimeUnix( std::chrono::steady_clock::now() ), - fHM(new CbmHistManager()), - fhStsMessType(NULL), - fhStsSysMessType(NULL), - fhStsMessTypePerDpb(NULL), - fhStsSysMessTypePerDpb(NULL), - fhStsDpbRawTsMsb(NULL), - fhStsDpbRawTsMsbSx(NULL), - fhStsDpbRawTsMsbDpb(NULL), - fhStsMessTypePerElink(NULL), - fhStsSysMessTypePerElink(NULL), - fhStsChanCounts(), - fhStsChanRawAdc(), - fhStsChanRawAdcProf(), - fhStsChanRawTs(), - fhStsChanMissEvt(), - fhStsChanHitRateEvo(), - fhStsXyterRateEvo(), - fhStsChanHitRateEvoLong(), - fhStsXyterRateEvoLong(), - fhStsChanHitDt(), - fhStsChanHitDtNeg(), - fhStsChanHitsPerMs(), - fhStsChanSameMs(), - fpStsChanSameMsTimeDiff(), - fhStsChanSameMsTimeDiff(), - fbPulserTimeDiffOn(kFALSE), - fuPulserMaxNbMicroslices(100), - fvuPulserAsic(), - fvuPulserChan(), - fhStsPulserChansTimeDiff(), - fhStsPulserChansTimeDiffEvo(), - fhStsPulserChansTimeDiffAdc(), - fhStsAsicTsMsb(NULL), - fhStsAsicTsMsbMaj(NULL), - fhStsElinkTsMsbCrc(), - fhStsElinkTsMsbMaj(), - fbLongHistoEnable( kFALSE ), - fuLongHistoNbSeconds( 0 ), - fuLongHistoBinSizeSec( 0 ), - fuLongHistoBinNb( 0 ), - fhFebRateEvoLong(), - fhFebChRateEvoLong(), - fcMsSizeAll(NULL) -{ -} - -CbmCern2017MonitorSts::~CbmCern2017MonitorSts() -{ -} - -Bool_t CbmCern2017MonitorSts::Init() -{ - LOG(info) << "Initializing flib StsXyter unpacker for STS"; - - FairRootManager* ioman = FairRootManager::Instance(); - if (ioman == NULL) { - LOG(fatal) << "No FairRootManager instance"; - } - - return kTRUE; -} - -void CbmCern2017MonitorSts::SetParContainers() -{ - LOG(info) << "Setting parameter containers for " << GetName(); - fUnpackPar = (CbmCern2017UnpackParSts*)(FairRun::Instance()->GetRuntimeDb()->getContainer("CbmCern2017UnpackParSts")); -} - - -Bool_t CbmCern2017MonitorSts::InitContainers() -{ - LOG(info) << "Init parameter containers for " << GetName(); - - Bool_t bReInit = ReInitContainers(); - CreateHistograms(); - - return bReInit; -} - -Bool_t CbmCern2017MonitorSts::ReInitContainers() -{ - LOG(info) << "ReInit parameter containers for " << GetName(); - - LOG(info) << "Nr. of Overlap MS: " << fuOverlapMsNb; - - fuNrOfDpbs = fUnpackPar->GetNrOfDpbs(); - fuNbElinksPerDpb = fUnpackPar->GetNbElinksPerDpb(); - fuNbStsXyters = fUnpackPar->GetNbStsXyters(); - fuNbChanPerAsic = fUnpackPar->GetNbChanPerAsic(); - - - LOG(info) << "Nr. of STS DPBs: " << fuNrOfDpbs; - - fDpbIdIndexMap.clear(); - fvuElinkToAsic.resize( fuNrOfDpbs ); - for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - { - fDpbIdIndexMap[ fUnpackPar->GetDpbId( uDpb ) ] = uDpb; - LOG(info) << "Eq. ID for DPB #" << std::setw(2) << uDpb << " = " - << std::setw(4) << std::hex << fUnpackPar->GetDpbId( uDpb ) - << std::dec - << " => " << fDpbIdIndexMap[ fUnpackPar->GetDpbId( uDpb ) ]; - - fvuElinkToAsic[uDpb].resize( fuNbElinksPerDpb ); - for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink ) - fvuElinkToAsic[uDpb][uElink] = fUnpackPar->GetElinkToAsicIdx( uDpb * fuNbElinksPerDpb + uElink ); - } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - - LOG(info) << "Nr. eLinks per DPB: " << fuNbElinksPerDpb; - LOG(info) << "Nr. of StsXyter ASICs: " << fuNbStsXyters; - LOG(info) << "Nb. channels per ASIC: " << fuNbChanPerAsic; - - for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - { - LOG(info) << "ASIC ID for eLinks in DPB #" << std::setw(2) << uDpb << ": "; - - for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink ) - { - if( 0 == uElink % 10 ) - LOG(info) << "\n" - << "------> "; - - LOG(info) << std::setw( 5 ) << fvuElinkToAsic[uDpb][uElink] << " "; - } // for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink ) - LOG(info) << ""; - } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - - LOG(info) << "Counter size for TS: " << stsxyter::kuHitNbTsBins; - LOG(info) << "Counter size for TS_MSB: " << stsxyter::kuTsMsbNbTsBins; - LOG(info) << "Counter size for cycles: " << stsxyter::kulTsCycleNbBins; - - // Internal status initialization - fvulCurrentTsMsb.resize( fuNrOfDpbs ); - fvuCurrentTsMsbCycle.resize( fuNrOfDpbs ); - fvuElinkLastTsHit.resize( fuNrOfDpbs ); - for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - { - fvulCurrentTsMsb[uDpb] = 0; - fvuCurrentTsMsbCycle[uDpb] = 0; - fvuElinkLastTsHit[uDpb] = 0; - } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - - fvulChanLastHitTime.resize( fuNbStsXyters ); - fvdChanLastHitTime.resize( fuNbStsXyters ); - fvuChanNbHitsInMs.resize( fuNbStsXyters ); - fvdChanLastHitTimeInMs.resize( fuNbStsXyters ); - fvusChanLastHitAdcInMs.resize( fuNbStsXyters ); - fvmChanHitsInTs.resize( fuNbStsXyters ); - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fvulChanLastHitTime[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvdChanLastHitTime[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvuChanNbHitsInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvdChanLastHitTimeInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvusChanLastHitAdcInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvmChanHitsInTs[ uXyterIdx ].resize( fuNbChanPerAsic ); - for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - { - fvulChanLastHitTime[ uXyterIdx ][ uChan ] = 0; - fvdChanLastHitTime[ uXyterIdx ][ uChan ] = -1.0; - - fvuChanNbHitsInMs[ uXyterIdx ][ uChan ].resize( fuPulserMaxNbMicroslices ); - fvdChanLastHitTimeInMs[ uXyterIdx ][ uChan ].resize( fuPulserMaxNbMicroslices ); - fvusChanLastHitAdcInMs[ uXyterIdx ][ uChan ].resize( fuPulserMaxNbMicroslices ); - fvmChanHitsInTs[ uXyterIdx ][ uChan ].clear(); - for( UInt_t uMsIdx = 0; uMsIdx < fuPulserMaxNbMicroslices; ++uMsIdx ) - { - fvuChanNbHitsInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = 0; - fvdChanLastHitTimeInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = -1.0; - fvusChanLastHitAdcInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = 0; - } // for( UInt_t uMsIdx = 0; uMsIdx < fuPulserMaxNbMicroslices; ++uMsIdx ) - } // for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - LOG(info) << "CbmCern2017MonitorSts::ReInitContainers => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs.size() << " VS " << fuNbStsXyters; - LOG(info) << "CbmCern2017MonitorSts::ReInitContainers => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs[ 0 ].size() << " VS " << fuNbChanPerAsic; - LOG(info) << "CbmCern2017MonitorSts::ReInitContainers => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs[ 0 ][ 0 ].size() << " VS " << fuPulserMaxNbMicroslices; - return kTRUE; -} - -void CbmCern2017MonitorSts::CreateHistograms() -{ - THttpServer* server = FairRunOnline::Instance()->GetHttpServer(); - - TString sHistName{""}; - TString title{""}; - - sHistName = "hStsMessageType"; - title = "Nb of message for each type; Type"; - fhStsMessType = new TH1I(sHistName, title, 5, 0., 5.); - fhStsMessType->GetXaxis()->SetBinLabel( 1, "Dummy"); - fhStsMessType->GetXaxis()->SetBinLabel( 2, "Hit"); - fhStsMessType->GetXaxis()->SetBinLabel( 3, "TsMsb"); - fhStsMessType->GetXaxis()->SetBinLabel( 4, "Epoch"); - fhStsMessType->GetXaxis()->SetBinLabel( 5, "Empty"); -/* *** Missing int + MessType OP!!!! **** - fhStsMessType->GetXaxis()->SetBinLabel(1 + stsxyter::MessType::Dummy, "Dummy"); - fhStsMessType->GetXaxis()->SetBinLabel(1 + stsxyter::MessType::Hit, "Hit"); - fhStsMessType->GetXaxis()->SetBinLabel(1 + stsxyter::MessType::TsMsb, "TsMsb"); - fhStsMessType->GetXaxis()->SetBinLabel(1 + stsxyter::MessType::ReadDataAck, "ReadDataAck"); - fhStsMessType->GetXaxis()->SetBinLabel(1 + stsxyter::MessType::Ack, "Ack"); -*/ - fHM->Add(sHistName.Data(), fhStsMessType); - if( server ) server->Register("/StsRaw", fhStsMessType ); - - sHistName = "hStsSysMessType"; - title = "Nb of system message for each type; System Type"; - fhStsSysMessType = new TH1I(sHistName, title, 17, 0., 17.); -/* - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_START, "DAQ START"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_FINISH, "DAQ FINISH"); - hSysMessType->GetXaxis()->SetBinLabel(1 + 16, "GET4 Hack 32B"); -*/ - fHM->Add(sHistName.Data(), fhStsSysMessType); - if( server ) server->Register("/StsRaw", fhStsSysMessType ); - - sHistName = "hStsMessageTypePerDpb"; - title = "Nb of message of each type for each DPB; DPB; Type"; - fhStsMessTypePerDpb = new TH2I(sHistName, title, fuNrOfDpbs, 0, fuNrOfDpbs, 5, 0., 5.); - fhStsMessTypePerDpb->GetYaxis()->SetBinLabel( 1, "Dummy"); - fhStsMessTypePerDpb->GetYaxis()->SetBinLabel( 2, "Hit"); - fhStsMessTypePerDpb->GetYaxis()->SetBinLabel( 3, "TsMsb"); - fhStsMessTypePerDpb->GetYaxis()->SetBinLabel( 4, "Epoch"); - fhStsMessTypePerDpb->GetYaxis()->SetBinLabel( 5, "Empty"); -/* *** Missing int + MessType OP!!!! **** - fhStsMessType->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Dummy, "Dummy"); - fhStsMessType->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Hit, "Hit"); - fhStsMessType->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::TsMsb, "TsMsb"); - fhStsMessType->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::ReadDataAck, "ReadDataAck"); - fhStsMessType->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Ack, "Ack"); -*/ - fHM->Add(sHistName.Data(), fhStsMessTypePerDpb); - if( server ) server->Register("/StsRaw", fhStsMessTypePerDpb ); - - sHistName = "hStsSysMessTypePerDpb"; - title = "Nb of system message of each type for each DPB; DPB; System Type"; - fhStsSysMessTypePerDpb = new TH2I(sHistName, title, fuNrOfDpbs, 0, fuNrOfDpbs, 17, 0., 17.); -/* - hSysMessType->GetYaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_START, "DAQ START"); - hSysMessType->GetYaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_FINISH, "DAQ FINISH"); - hSysMessType->GetYaxis()->SetBinLabel(1 + 16, "GET4 Hack 32B"); -*/ - fHM->Add(sHistName.Data(), fhStsSysMessTypePerDpb); - if( server ) server->Register("/StsRaw", fhStsSysMessTypePerDpb ); - - sHistName = "hStsDpbRawTsMsb"; - title = "Raw TsMsb distribution for each DPB; DPB; TS MSB [Bins]"; - fhStsDpbRawTsMsb = new TH2I( sHistName, title, - fuNrOfDpbs, 0, fuNrOfDpbs, - stsxyter::kuTsMsbNbTsBins, 0., stsxyter::kuTsMsbNbTsBins); - if( server ) server->Register("/StsRaw", fhStsDpbRawTsMsb ); - - sHistName = "hStsDpbRawTsMsbSx"; - title = "Raw TsMsb distribution for each DPB; DPB; TS MSB [Bins]"; - fhStsDpbRawTsMsbSx = new TH2I( sHistName, title, - fuNrOfDpbs, 0, fuNrOfDpbs, - 0x1F , 0., 0x1F ); - if( server ) server->Register("/StsRaw", fhStsDpbRawTsMsbSx ); - - sHistName = "hStsDpbRawTsMsbDpb"; - title = "Raw TsMsb distribution for each DPB; DPB; TS MSB [Bins]"; - fhStsDpbRawTsMsbDpb = new TH2I( sHistName, title, - fuNrOfDpbs, 0, fuNrOfDpbs, - stsxyter::kuTsMsbNbTsBins >> 5, 0., stsxyter::kuTsMsbNbTsBins >> 5 ); - if( server ) server->Register("/StsRaw", fhStsDpbRawTsMsbDpb ); - - sHistName = "hStsMessageTypePerElink"; - title = "Nb of message of each type for each eLink; eLink; Type"; - fhStsMessTypePerElink = new TH2I(sHistName, title, fuNrOfDpbs * fuNbElinksPerDpb, 0, fuNrOfDpbs * fuNbElinksPerDpb, 5, 0., 5.); - fhStsMessTypePerElink->GetYaxis()->SetBinLabel( 1, "Dummy"); - fhStsMessTypePerElink->GetYaxis()->SetBinLabel( 2, "Hit"); - fhStsMessTypePerElink->GetYaxis()->SetBinLabel( 3, "TsMsb"); - fhStsMessTypePerElink->GetYaxis()->SetBinLabel( 4, "ReadDataAck"); - fhStsMessTypePerElink->GetYaxis()->SetBinLabel( 5, "Ack"); -/* *** Missing int + MessType OP!!!! **** - fhStsMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Dummy, "Dummy"); - fhStsMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Hit, "Hit"); - fhStsMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::TsMsb, "TsMsb"); - fhStsMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::ReadDataAck, "ReadDataAck"); - fhStsMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Ack, "Ack"); -*/ - fHM->Add(sHistName.Data(), fhStsMessTypePerElink); - if( server ) server->Register("/StsRaw", fhStsMessTypePerElink ); - - sHistName = "hStsSysMessTypePerElink"; - title = "Nb of system message of each type for each eLink; eLink; System Type"; - fhStsSysMessTypePerElink = new TH2I(sHistName, title, fuNrOfDpbs * fuNbElinksPerDpb, 0, fuNrOfDpbs * fuNbElinksPerDpb, 17, 0., 17.); -/* - fhStsSysMessTypePerElink->GetYaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_START, "DAQ START"); - fhStsSysMessTypePerElink->GetYaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_FINISH, "DAQ FINISH"); - fhStsSysMessTypePerElink->GetYaxis()->SetBinLabel(1 + 16, "GET4 Hack 32B"); -*/ - fHM->Add(sHistName.Data(), fhStsSysMessTypePerElink); - if( server ) server->Register("/StsRaw", fhStsSysMessTypePerElink ); - - // Number of rate bins = - // 9 for the sub-unit decade - // + 9 for each unit of each decade * 10 for the subdecade range - // + 1 for the closing bin top edge - const Int_t iNbDecadesRate = 9; - const Int_t iNbStepsDecade = 9; - const Int_t iNbSubStepsInStep = 10; - const Int_t iNbBinsRate = iNbStepsDecade - + iNbStepsDecade * iNbSubStepsInStep * iNbDecadesRate - + 1; - Double_t dBinsRate[iNbBinsRate]; - // First fill sub-unit decade - for( Int_t iSubU = 0; iSubU < iNbStepsDecade; iSubU ++ ) - dBinsRate[ iSubU ] = 0.1 * ( 1 + iSubU ); - std::cout << std::endl; - // Then fill the main decades - Double_t dSubstepSize = 1.0 / iNbSubStepsInStep; - for( Int_t iDecade = 0; iDecade < iNbDecadesRate; iDecade ++) - { - Double_t dBase = std::pow( 10, iDecade ); - Int_t iDecadeIdx = iNbStepsDecade - + iDecade * iNbStepsDecade * iNbSubStepsInStep; - for( Int_t iStep = 0; iStep < iNbStepsDecade; iStep++ ) - { - Int_t iStepIdx = iDecadeIdx + iStep * iNbSubStepsInStep; - for( Int_t iSubStep = 0; iSubStep < iNbSubStepsInStep; iSubStep++ ) - { - dBinsRate[ iStepIdx + iSubStep ] = dBase * (1 + iStep) - + dBase * dSubstepSize * iSubStep; - } // for( Int_t iSubStep = 0; iSubStep < iNbSubStepsInStep; iSubStep++ ) - } // for( Int_t iStep = 0; iStep < iNbStepsDecade; iStep++ ) - } // for( Int_t iDecade = 0; iDecade < iNbDecadesRate; iDecade ++) - dBinsRate[ iNbBinsRate - 1 ] = std::pow( 10, iNbDecadesRate ); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - // Channel counts - sHistName = Form( "hStsChanCounts_%03u", uXyterIdx ); - title = Form( "Hits Count per channel, StsXyter #%03u; Channel; Hits []", uXyterIdx ); - fhStsChanCounts.push_back( new TH1I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - fHM->Add(sHistName.Data(), fhStsChanCounts[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhStsChanCounts[ uXyterIdx ] ); - - // Raw Adc Distribution - sHistName = Form( "hStsChanRawAdc_%03u", uXyterIdx ); - title = Form( "Raw Adc distribution per channel, StsXyter #%03u; Channel []; Adc []; Hits []", uXyterIdx ); - fhStsChanRawAdc.push_back( new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - stsxyter::kuHitNbAdcBins, -0.5, stsxyter::kuHitNbAdcBins -0.5 ) ); - fHM->Add(sHistName.Data(), fhStsChanRawAdc[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhStsChanRawAdc[ uXyterIdx ] ); - - // Raw Adc Distribution profile - sHistName = Form( "hStsChanRawAdcProfc_%03u", uXyterIdx ); - title = Form( "Raw Adc prodile per channel, StsXyter #%03u; Channel []; Adc []", uXyterIdx ); - fhStsChanRawAdcProf.push_back( new TProfile(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - fHM->Add(sHistName.Data(), fhStsChanRawAdcProf[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhStsChanRawAdcProf[ uXyterIdx ] ); - - // Raw Ts Distribution - sHistName = Form( "hStsChanRawTs_%03u", uXyterIdx ); - title = Form( "Raw Timestamp distribution per channel, StsXyter #%03u; Channel []; Ts []; Hits []", uXyterIdx ); - fhStsChanRawTs.push_back( new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - stsxyter::kuHitNbTsBins, -0.5, stsxyter::kuHitNbTsBins -0.5 ) ); - fHM->Add(sHistName.Data(), fhStsChanRawTs[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhStsChanRawTs[ uXyterIdx ] ); - - // Missed event flag - sHistName = Form( "hStsChanMissEvt_%03u", uXyterIdx ); - title = Form( "Missed Event flags per channel, StsXyter #%03u; Channel []; Miss Evt []; Hits []", uXyterIdx ); - fhStsChanMissEvt.push_back( new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - 2, -0.5, 1.5 ) ); - fHM->Add(sHistName.Data(), fhStsChanMissEvt[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhStsChanMissEvt[ uXyterIdx ] ); - - // Hit rates evo per channel - sHistName = Form( "hStsChanRateEvo_%03u", uXyterIdx ); - title = Form( "Hits per second & channel in StsXyter #%03u; Time [s]; Channel []; Hits []", uXyterIdx ); - fhStsChanHitRateEvo.push_back( new TH2I( sHistName, title, - 1800, 0, 1800, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - fHM->Add(sHistName.Data(), fhStsChanHitRateEvo[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhStsChanHitRateEvo[ uXyterIdx ] ); - - // Hit rates evo per StsXyter - sHistName = Form( "hStsXyterRateEvo_%03u", uXyterIdx ); - title = Form( "Hits per second in StsXyter #%03u; Time [s]; Hits []", uXyterIdx ); - fhStsXyterRateEvo.push_back( new TH1I(sHistName, title, 1800, 0, 1800 ) ); - fHM->Add(sHistName.Data(), fhStsXyterRateEvo[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhStsXyterRateEvo[ uXyterIdx ] ); - - // Hit rates evo per channel, 1 minute bins, 24h - sHistName = Form( "hStsChanRateEvoLong_%03u", uXyterIdx ); - title = Form( "Hits per second & channel in StsXyter #%03u; Time [min]; Channel []; Hits []", uXyterIdx ); - fhStsChanHitRateEvoLong.push_back( new TH2D( sHistName, title, - 1440, 0, 1440, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - fHM->Add(sHistName.Data(), fhStsChanHitRateEvoLong[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhStsChanHitRateEvoLong[ uXyterIdx ] ); - - // Hit rates evo per StsXyter, 1 minute bins, 24h - sHistName = Form( "hStsXyterRateEvoLong_%03u", uXyterIdx ); - title = Form( "Hits per second in StsXyter #%03u; Time [min]; Hits []", uXyterIdx ); - fhStsXyterRateEvoLong.push_back( new TH1D(sHistName, title, 1440, 0, 1440 ) ); - fHM->Add(sHistName.Data(), fhStsXyterRateEvoLong[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhStsXyterRateEvoLong[ uXyterIdx ] ); - - // Hit distance in time for each channel - if( fbChanHitDtEna ) - { - sHistName = Form( "hStsChanHitDt_%03u", uXyterIdx ); - title = Form( "Time diff between hits on same channel in StsXyter #%03u; t_hit - t_prev [ns]; Channel []; Hits []", uXyterIdx ); - fhStsChanHitDt.push_back( new TH2I( sHistName, title, - iNbBinsRate - 1, dBinsRate, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - fHM->Add(sHistName.Data(), fhStsChanHitDt[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhStsChanHitDt[ uXyterIdx ] ); - sHistName = Form( "hStsChanHitDtNeg_%03u", uXyterIdx ); - title = Form( "Time diff between hits on same channel in StsXyter #%03u; t_prev - t_hit [ns]; Channel []; Hits []", uXyterIdx ); - fhStsChanHitDtNeg.push_back( new TH2I( sHistName, title, - iNbBinsRate - 1, dBinsRate, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - fHM->Add(sHistName.Data(), fhStsChanHitDtNeg[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhStsChanHitDtNeg[ uXyterIdx ] ); - - } // if( fbChanHitDtEna ) - - sHistName = Form( "hStsChanHitsPerMs_%03u", uXyterIdx ); - title = Form( "Nb of hits per channel in each MS in StsXyter #%03u; Nb Hits in MS []; Channel []; MS []", uXyterIdx ); - fhStsChanHitsPerMs.push_back( new TH2I( sHistName, title, - 100, -0.5, 99.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - fHM->Add(sHistName.Data(), fhStsChanHitsPerMs[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhStsChanHitsPerMs[ uXyterIdx ] ); - - sHistName = Form( "hStsChanSameMs_%03u", uXyterIdx ); - title = Form( "Nb of MS with hits in both channels in StsXyter #%03u; Channel A []; Channel B []; Coinc. MS []", uXyterIdx ); - fhStsChanSameMs.push_back( new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - fHM->Add(sHistName.Data(), fhStsChanHitsPerMs[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhStsChanSameMs[ uXyterIdx ] ); - - sHistName = Form( "pStsChanSameMsTimeDiff_%03u", uXyterIdx ); - title = Form( "Mean Time difference of channels when hits in same MS in StsXyter #%03u; Channel A []; Channel B []; Mean time diff [bins]", uXyterIdx ); - fpStsChanSameMsTimeDiff.push_back( new TProfile2D( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - - sHistName = Form( "hStsChanSameMsTimeDiff_%03u", uXyterIdx ); - title = Form( "Mean Time difference of channels when hits in same MS in StsXyter #%03u; Channel A []; Channel B []; Mean time diff [bins]", uXyterIdx ); - fhStsChanSameMsTimeDiff.push_back( new TH2D( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - fHM->Add(sHistName.Data(), fhStsChanSameMsTimeDiff[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhStsChanSameMsTimeDiff[ uXyterIdx ] ); - - if( kTRUE == fbLongHistoEnable ) - { - UInt_t uAlignedLimit = fuLongHistoNbSeconds - (fuLongHistoNbSeconds % fuLongHistoBinSizeSec); - fuLongHistoBinNb = uAlignedLimit / fuLongHistoBinSizeSec; - - sHistName = Form( "hFebRateEvoLong_%03u", uXyterIdx ); - title = Form( "Mean rate VS run time in same MS in StsXyter #%03u; Time in run [s]; Rate [1/s]", uXyterIdx ); - fhFebRateEvoLong.push_back( new TH1D( sHistName, title, - fuLongHistoBinNb, -0.5, uAlignedLimit - 0.5) ); - fHM->Add(sHistName.Data(), fhFebRateEvoLong[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhFebRateEvoLong[ uXyterIdx ] ); - - sHistName = Form( "hFebChRateEvoLong_%03u", uXyterIdx ); - title = Form( "Mean rate per channel VS run time in StsXyter #%03u; Time in run [s]; Channel []; Rare [1/s]", uXyterIdx ); - fhFebChRateEvoLong.push_back( new TH2D( sHistName, title, - fuLongHistoBinNb, -0.5, uAlignedLimit - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - fHM->Add(sHistName.Data(), fhFebChRateEvoLong[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhFebChRateEvoLong[ uXyterIdx ] ); - } // if( kTRUE == fbLongHistoEnable ) - - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - - if( kTRUE == fbPulserTimeDiffOn ) - { - UInt_t uNbPulserChans = fvuPulserAsic.size(); - UInt_t uNbBinEvo = 32768 + 1; - Double_t dMaxEdgeEvo = stsxyter::kdClockCycleNs - * static_cast< Double_t >( uNbBinEvo ) / 2.0; - Double_t dMinEdgeEvo = dMaxEdgeEvo * -1.0; - for( UInt_t uChA = 0; uChA < uNbPulserChans; ++uChA ) - for( UInt_t uChB = uChA + 1; uChB < uNbPulserChans; ++uChB ) - { - sHistName = Form( "hStsPulserTimeDiff_%02u_%03u_%02u_%03u", - fvuPulserAsic[uChA], fvuPulserChan[uChA], - fvuPulserAsic[uChB], fvuPulserChan[uChB] ); - title = Form( "Time diff for hits in same MS from ASIC %02d ch %03d and ASIC %02d ch %03d; tB - tA [ns]; Counts", - fvuPulserAsic[uChA], fvuPulserChan[uChA], - fvuPulserAsic[uChB], fvuPulserChan[uChB] ); -// TH1 * pHist = new TH1I(sHistName, title, 16385, -51203.125, 51203.125); - TH1 * pHist = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - fHM->Add(sHistName.Data(), pHist); - if( server ) server->Register("/StsRaw", pHist ); - fhStsPulserChansTimeDiff.push_back( pHist ); - - if( kTRUE == fbLongHistoEnable ) - { - UInt_t uAlignedLimit = fuLongHistoNbSeconds - (fuLongHistoNbSeconds % fuLongHistoBinSizeSec); - sHistName = Form( "hStsPulserChansTimeDiffEvo_%02u_%03u_%02u_%03u", - fvuPulserAsic[uChA], fvuPulserChan[uChA], - fvuPulserAsic[uChB], fvuPulserChan[uChB] ); - title = Form( "Time diff for hits in same MS from ASIC %02d ch %03d and ASIC %02d ch %03d, vs time in run; Time in run [min]; tB - tA [ns]; Counts", - fvuPulserAsic[uChA], fvuPulserChan[uChA], - fvuPulserAsic[uChB], fvuPulserChan[uChB] ); - TH2 * pHistEvo = new TH2I( sHistName, title, - fuLongHistoBinNb, -0.5, uAlignedLimit - 0.5, - uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - fHM->Add(sHistName.Data(), pHistEvo); - if( server ) server->Register("/StsRaw", pHistEvo ); - fhStsPulserChansTimeDiffEvo.push_back( pHistEvo ); - } // if( kTRUE == fbLongHistoEnable ) - - sHistName = Form( "hStsPulserChansTimeDiffAdc_%02u_%03u_%02u_%03u", - fvuPulserAsic[uChA], fvuPulserChan[uChA], - fvuPulserAsic[uChB], fvuPulserChan[uChB] ); - title = Form( "Time diff vs Adc Diff for hits in same MS from ASIC %02d ch %03d and ASIC %02d ch %03d; tB - tA [ns]; Adc diff [a.u.]; Counts", - fvuPulserAsic[uChA], fvuPulserChan[uChA], - fvuPulserAsic[uChB], fvuPulserChan[uChB] ); - TH2 * pHistAdc = new TH2I( sHistName, title, - uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo, - 2*stsxyter::kuHitNbAdcBins + 1, -0.5 - stsxyter::kuHitNbAdcBins, stsxyter::kuHitNbAdcBins + 0.5 ); - fhStsPulserChansTimeDiffAdc.push_back( pHistAdc ); - if( server ) server->Register("/StsRaw", pHistAdc ); - } // Loop on pairs of channels - } // if( kTRUE == fbPulserTimeDiffOn ) - - // Distribution of the TS_MSB per StsXyter - sHistName = "hStsAsicTsMsb"; - title = "Raw Timestamp Msb distribution per StsXyter; Ts MSB []; StsXyter []; Hits []"; - fhStsAsicTsMsb = new TH2I( sHistName, title, stsxyter::kuTsMsbNbTsBins, -0.5, stsxyter::kuTsMsbNbTsBins - 0.5, - fuNbStsXyters, -0.5, fuNbStsXyters - 0.5 ); - fHM->Add(sHistName.Data(), fhStsAsicTsMsb ); - if( server ) server->Register("/StsRaw", fhStsAsicTsMsb ); - - // Nb values in agreement in TS MSB messages, per StsXyter - sHistName = "hStsAsicTsMsbMaj"; - title = "Nb values in agreement in TS MSB messages, per StsXyter; StsXyter []; Majority? []; Mess. []"; - fhStsAsicTsMsbMaj = new TH2I( sHistName, title, fuNbStsXyters, -0.5, fuNbStsXyters - 0.5, - 3, 0.5, 3.5); - fHM->Add(sHistName.Data(), fhStsAsicTsMsbMaj ); - if( server ) server->Register("/StsRaw", fhStsAsicTsMsbMaj ); - - for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - { - // CRC good or bad in TS MSB messages, per (DPB, eLink) pairs - sHistName = Form( "hStsElinkTsMsbCrc_d%02u", uDpb ); - title = Form( "CRC test in TS MSB, per eLink, DPB #%02u; eLink []; CRC Match? []; Mess. []", uDpb); - fhStsElinkTsMsbCrc.push_back( new TH2I( sHistName, title, fuNbElinksPerDpb, -0.5, fuNbElinksPerDpb - 0.5, - 2, -0.5, 1.5) ); - fHM->Add(sHistName.Data(), fhStsElinkTsMsbCrc[ uDpb ] ); - if( server ) server->Register("/StsRaw", fhStsElinkTsMsbCrc[ uDpb ] ); - - // Nb values in agreement in TS MSB messages, per (DPB, eLink) pairs - sHistName = Form( "hStsElinkTsMsbMaj_d%02u", uDpb ); - title = Form( "Nb values in agreement in TS MSB, per eLink, DPB #%02u; eLink []; Majority? []; Mess. []", uDpb); - fhStsElinkTsMsbMaj.push_back( new TH2I( sHistName, title, fuNbElinksPerDpb, -0.5, fuNbElinksPerDpb - 0.5, - 3, 0.5, 3.5) ); - fHM->Add(sHistName.Data(), fhStsElinkTsMsbMaj[ uDpb ] ); - if( server ) server->Register("/StsRaw", fhStsElinkTsMsbMaj[ uDpb ] ); - } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - - // Miscroslice properties histos - for( Int_t component = 0; component < kiMaxNbFlibLinks; component ++ ) - { - fhMsSz[ component ] = NULL; - fhMsSzTime[ component ] = NULL; - } // for( Int_t component = 0; component < kiMaxNbFlibLinks; component ++ ) - - // Online histo browser commands - if( server ) - { - server->RegisterCommand("/Reset_All_Sts", "bCern2017ResetStsHistos=kTRUE"); - server->RegisterCommand("/Write_All_Sts", "bCern2017WriteStsHistos=kTRUE"); - - server->Restrict("/Reset_All_Sts", "allow=admin"); - server->Restrict("/Write_All_Sts", "allow=admin"); - } // if( server ) - - /** Create summary Canvases for CERN 2017 **/ - Double_t w = 10; - Double_t h = 10; - - // Summary per StsXyter - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - TCanvas* cStsSumm = new TCanvas( Form("cStsSum_%03u", uXyterIdx ), - Form("Summary plots for StsXyter %03u", uXyterIdx ), - w, h); - cStsSumm->Divide( 2, 2 ); - - cStsSumm->cd(1); - gPad->SetLogy(); - fhStsChanCounts[ uXyterIdx ]->Draw(); - - cStsSumm->cd(2); - gPad->SetLogz(); - fhStsChanRawAdc[ uXyterIdx ]->Draw( "colz" ); - - cStsSumm->cd(3); - gPad->SetLogz(); - fhStsChanRawTs[ uXyterIdx ]->Draw( "colz" ); - - cStsSumm->cd(4); - gPad->SetLogy(); - fhStsXyterRateEvo[ uXyterIdx ]->Draw(); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - - // Pulser testing - if( kTRUE == fbPulserTimeDiffOn ) - { - UInt_t uNbPulserPlots = fhStsPulserChansTimeDiff.size(); - TCanvas* cStsPulser = new TCanvas( "cStsPulser" , "Summary plots for StsXyter pulser testing", - w, h); - cStsPulser->Divide( 2, uNbPulserPlots/2 + uNbPulserPlots%2 ); - - for( UInt_t uPulserPlot = 0; uPulserPlot < uNbPulserPlots; ++uPulserPlot) - { - cStsPulser->cd( 1 + uPulserPlot ); - gPad->SetLogy(); - gPad->SetGridx(); - gPad->SetGridy(); - fhStsPulserChansTimeDiff[ uPulserPlot ]->Draw(); - gStyle->SetOptStat("emruo"); - fhStsPulserChansTimeDiff[ uPulserPlot ]->SetStats(1); - } // for( UInt_t uPulserPlot = 0; uPulserPlot < uNbPulserPlots; ++uPulserPlot) - - if( kTRUE == fbLongHistoEnable ) - { - TCanvas* cStsPulserEvo = new TCanvas( "cStsPulserEvo" , "Summary plots for StsXyter pulser testing vs time", - w, h); - cStsPulserEvo->Divide( 2, uNbPulserPlots/2 + uNbPulserPlots%2 ); - - for( UInt_t uPulserPlot = 0; uPulserPlot < uNbPulserPlots; ++uPulserPlot) - { - cStsPulserEvo->cd( 1 + uPulserPlot ); - gPad->SetGridx(); - gPad->SetGridy(); - fhStsPulserChansTimeDiffEvo[ uPulserPlot ]->Draw( "colz" ); - gStyle->SetOptStat("emruo"); - fhStsPulserChansTimeDiffEvo[ uPulserPlot ]->SetStats(1); - } // for( UInt_t uPulserPlot = 0; uPulserPlot < uNbPulserPlots; ++uPulserPlot) - } // if( kTRUE == fbLongHistoEnable ) - } // if( kTRUE == fbPulserTimeDiffOn ) - - // Long duration rate monitoring - if( kTRUE == fbLongHistoEnable ) - { - TCanvas* cStsLongRate = new TCanvas( "cStsLongRate" , "Long duration rate plots for StsXyter", - w, h); - cStsLongRate->Divide( 2, fuNbStsXyters ); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - cStsLongRate->cd( 1 + 2 * uXyterIdx ); - gPad->SetLogy(); - gPad->SetGridx(); - gPad->SetGridy(); - fhFebRateEvoLong[ uXyterIdx ]->Draw( "hist" ); - - cStsLongRate->cd( 2 + 2 * uXyterIdx ); - gPad->SetLogz(); - gPad->SetGridx(); - gPad->SetGridy(); - fhFebChRateEvoLong[ uXyterIdx ]->Draw( "colz" ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - } // if( kTRUE == fbLongHistoEnable ) - -/* - Int_t iNbPadsPerDpb = fuNbElinksPerDpb/2 + fuNbElinksPerDpb%2; - TCanvas* cMuchChCounts = new TCanvas("cMuchChCounts", "MUCH Channels counts", w, h); - cMuchChCounts->Divide( fNrOfNdpbs/2 + fNrOfNdpbs%2, fNrOfFebsPerNdpb ); - - TCanvas* cMuchFebRate = new TCanvas("cMuchFebRate", "MUCH FEB rate", w, h); - cMuchFebRate->Divide( fNrOfNdpbs/2 + fNrOfNdpbs%2, fNrOfFebsPerNdpb ); - - TH1* histPnt = NULL; - for( Int_t dpbId = 0; dpbId < fNrOfNdpbs; dpbId++) - {// looping on all the nDPBS IDs - if( dpbId < fUnpackPar->GetNrOfnDpbsModA() ) - { - sNdpbTag = Form("%04X", fUnpackPar->GetNdpbIdA(dpbId) ); - } // if( dpbId < fUnpackPar->GetNrOfnDpbsModA() ) - else - { - sNdpbTag = Form("%04X", fUnpackPar->GetNdpbIdB(dpbId - fNrOfNdpbsA) ); - } // else of if( dpbId < fUnpackPar->GetNrOfnDpbsModA() ) - - for( Int_t febId = 0; febId < fNrOfFebsPerNdpb; febId++) - {// looping on all the FEB IDs - cMuchChCounts->cd( 1 + dpbId * iNbPadsPerDpb + febId/2 ); - gPad->SetLogy(); - sHistName = Form("Chan_Counts_Much_n%s_f%1u", sNdpbTag.Data(), febId); - histPnt = fHM->H1(sHistName.Data()); - - if( 0 == febId%2 ) - { - histPnt->SetLineColor( kRed ); // => Change color for 1st of the 2/pad! - histPnt->Draw(); - } // if( 0 == febId%2 ) - else - { - histPnt->SetLineColor( kBlue ); // => Change color for 1nd of the 2/pad! - histPnt->Draw("same"); - } // if( 0 == febId%2 ) - - cMuchFebRate->cd( 1 + dpbId * iNbPadsPerDpb + febId/2 ); - gPad->SetLogy(); - sHistName = Form("FebRate_n%s_f%1u", sNdpbTag.Data(), febId); - histPnt = fHM->H1(sHistName.Data()); - - if( 0 == febId%2 ) - { - histPnt->SetLineColor( kRed ); // => Change color for 1st of the 2/pad! - histPnt->Draw(); - } // if( 0 == febId%2 ) - else - { - histPnt->SetLineColor( kBlue ); // => Change color for 1nd of the 2/pad! - histPnt->Draw("same"); - } // if( 0 == febId%2 ) - } // for( Int_t febId = 0; febId < fNrOfFebsPerNdpb; febId++) - } // for( Int_t dpbId = 0; dpbId < fNrOfNdpbs; dpbId++) -*/ - - /** Recovers/Create Ms Size Canvase for CERN 2016 **/ - // Try to recover canvas in case it was created already by another monitor - // If not existing, create it - fcMsSizeAll = dynamic_cast<TCanvas *>( gROOT->FindObject( "cMsSizeAll" ) ); - if( NULL == fcMsSizeAll ) - { - fcMsSizeAll = new TCanvas("cMsSizeAll", "Evolution of MS size in last 300 s", w, h); - fcMsSizeAll->Divide( 4, 4 ); - LOG(info) << "Created MS size canvas in STS monitor"; - } // if( NULL == fcMsSizeAll ) - else LOG(info) << "Recovered MS size canvas in STS monitor"; - - /*****************************/ -} - -Bool_t CbmCern2017MonitorSts::DoUnpack(const fles::Timeslice& ts, size_t component) -{ - THttpServer* server = FairRunOnline::Instance()->GetHttpServer(); - - if( bCern2017ResetStsHistos ) - { - ResetAllHistos(); - bCern2017ResetStsHistos = kFALSE; - } // if( bCern2017ResetStsHistos ) - if( bCern2017WriteStsHistos ) - { - SaveAllHistos( "data/StsHistos.root" ); - bCern2017WriteStsHistos = kFALSE; - } // if( bCern2017WriteStsHistos ) - - LOG(debug) << "Timeslice contains " << ts.num_microslices(component) - << "microslices."; - - if( component < kiMaxNbFlibLinks ) - if( NULL == fhMsSz[ component ] ) - { - TString sMsSzName = Form("MsSz_link_%02lu", component); - TString sMsSzTitle = Form("Size of MS for nDPB of link %02lu; Ms Size [bytes]", component); - fhMsSz[ component ] = new TH1F( sMsSzName.Data(), sMsSzTitle.Data(), 160000, 0., 20000. ); - fHM->Add(sMsSzName.Data(), fhMsSz[ component ] ); - if (server) server->Register("/FlibRaw", fhMsSz[ component ] ); - sMsSzName = Form("MsSzTime_link_%02lu", component); - sMsSzTitle = Form("Size of MS vs time for gDPB of link %02lu; Time[s] ; Ms Size [bytes]", component); - fhMsSzTime[ component ] = new TProfile( sMsSzName.Data(), sMsSzTitle.Data(), 15000, 0., 300. ); - fHM->Add( sMsSzName.Data(), fhMsSzTime[ component ] ); - if (server) server->Register("/FlibRaw", fhMsSzTime[ component ] ); - if( NULL != fcMsSizeAll ) - { - fcMsSizeAll->cd( 1 + component ); - gPad->SetLogy(); - fhMsSzTime[ component ]->Draw("hist le0"); - } // if( NULL != fcMsSizeAll ) - LOG(info) << "Added MS size histo for component: " << component - << " (DPB)"; - } // if( NULL == fhMsSz[ component ] ) - -// Int_t messageType = -111; - // Loop over microslices - size_t numCompMsInTs = ts.num_microslices(component); -/* - if( fulCurrentTsIdx + 1 != ts.index() && 0 == component) - LOG(info) << "Missed TS from " << fulCurrentTsIdx - << " to " << ts.index(); -*/ - fulCurrentTsIdx = ts.index(); - - if( fuPulserMaxNbMicroslices < numCompMsInTs ) - { - fuPulserMaxNbMicroslices = numCompMsInTs; - - fvuChanNbHitsInMs.resize( fuNbStsXyters ); - fvdChanLastHitTimeInMs.resize( fuNbStsXyters ); - fvusChanLastHitAdcInMs.resize( fuNbStsXyters ); - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fvuChanNbHitsInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvdChanLastHitTimeInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvusChanLastHitAdcInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - { - fvuChanNbHitsInMs[ uXyterIdx ][ uChan ].resize( fuPulserMaxNbMicroslices ); - fvdChanLastHitTimeInMs[ uXyterIdx ][ uChan ].resize( fuPulserMaxNbMicroslices ); - fvusChanLastHitAdcInMs[ uXyterIdx ][ uChan ].resize( fuPulserMaxNbMicroslices ); - for( UInt_t uMsIdx = 0; uMsIdx < fuPulserMaxNbMicroslices; ++uMsIdx ) - { - fvuChanNbHitsInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = 0; - fvdChanLastHitTimeInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = -1.0; - fvusChanLastHitAdcInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = 0; - } // for( UInt_t uMsIdx = 0; uMsIdx < fuPulserMaxNbMicroslices; ++uMsIdx ) - } // for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - LOG(info) << "CbmCern2017MonitorSts::DoUnpack => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs.size() << " VS " << fuNbStsXyters; - LOG(info) << "CbmCern2017MonitorSts::DoUnpack => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs[ 0 ].size() << " VS " << fuNbChanPerAsic; - LOG(info) << "CbmCern2017MonitorSts::DoUnpack => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs[ 0 ][ 0 ].size() << " VS " << fuPulserMaxNbMicroslices; - } // if( fuPulserMaxNbMicroslices < numCompMsInTs ) - - for( size_t m = 0; m < numCompMsInTs; ++m ) - { - // Ignore overlap ms if number defined by user - if( numCompMsInTs - fuOverlapMsNb <= m ) - continue; - - auto msDescriptor = ts.descriptor(component, m); - fuCurrentEquipmentId = msDescriptor.eq_id; - const uint8_t* msContent = reinterpret_cast<const uint8_t*>(ts.content(component, m)); - - uint32_t size = msDescriptor.size; - fulCurrentMsIdx = msDescriptor.idx; - LOG(debug) << "Microslice: " << fulCurrentMsIdx - << " from EqId " << std::hex << fuCurrentEquipmentId << std::dec - << " has size: " << size; - - fuCurrDpbId = static_cast< uint32_t >( fuCurrentEquipmentId & 0xFFFF ); - fuCurrDpbIdx = fDpbIdIndexMap[ fuCurrDpbId ]; - - if( component < kiMaxNbFlibLinks ) - { - if( fdStartTimeMsSz < 0 ) - fdStartTimeMsSz = (1e-9) * static_cast<double>(fulCurrentMsIdx); - fhMsSz[ component ]->Fill( size ); - fhMsSzTime[ component ]->Fill( (1e-9) * static_cast<double>( fulCurrentMsIdx) - fdStartTimeMsSz, size); - } // if( component < kiMaxNbFlibLinks ) - - if( 0 == component && 0 == ( ( fulCurrentMsIdx / 1000000000 ) % 10 ) - && 0 == ( ( fulCurrentMsIdx / 100000 ) ) %50000 ) - { - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fhStsChanSameMsTimeDiff[uXyterIdx]->Reset(); - TH2* tempProj = fpStsChanSameMsTimeDiff[uXyterIdx]->ProjectionXY( ); - fhStsChanSameMsTimeDiff[uXyterIdx]->Add( tempProj ); - delete tempProj; -/* - for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - for( UInt_t uChanB = uChan + 1; uChanB < fuNbChanPerAsic; ++uChanB ) - if( 0 < fpStsChanSameMsTimeDiff[uXyterIdx]->GetBinEntries( fpStsChanSameMsTimeDiff[uXyterIdx]->GetBin( uChan, uChanB ) ) ) - { - LOG(debug) << "Microslice Index = " << (fulCurrentMsIdx / 1000000000) - << "s, ASIC " << uXyterIdx << " Chan " << uChan << " VS " << uChanB - << " Entries " << fpStsChanSameMsTimeDiff[uXyterIdx]->GetBinEntries( fpStsChanSameMsTimeDiff[uXyterIdx]->GetBin( uChan, uChanB ) ) - << " Mean time diff "<< fpStsChanSameMsTimeDiff[uXyterIdx]->GetBinContent( uChan, uChanB ) - << " Error " << fpStsChanSameMsTimeDiff[uXyterIdx]->GetBinError( uChan, uChanB ); - } // if( 0 < fpStsChanSameMsTimeDiff[uXyterIdx]->GetBinEntries( uChan, uChanB ) ) -*/ - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - } // if( 0 == ( ( fulCurrentMsIdx / 1e-9 ) % 10 ) ) - - // If not integer number of message in input buffer, print warning/error - if( 0 != (size % kuBytesPerMessage) ) - LOG(error) << "The input microslice buffer does NOT " - << "contain only complete nDPB messages!"; - - // Compute the number of complete messages in the input microslice buffer - uint32_t uNbMessages = (size - (size % kuBytesPerMessage) ) - / kuBytesPerMessage; - - // Prepare variables for the loop on contents - const uint32_t* pInBuff = reinterpret_cast<const uint32_t*>( msContent ); - - for( uint32_t uIdx = 0; uIdx < uNbMessages; ++uIdx ) - { - // Fill message - uint32_t ulData = static_cast<uint32_t>(pInBuff[uIdx]); - - stsxyter::Message mess( static_cast< uint32_t >( ulData & 0xFFFFFFFF ) ); - - // Print message if requested - if( fbPrintMessages ) - mess.PrintMess( std::cout, fPrintMessCtrl ); - - - stsxyter::MessType typeMess = mess.GetMessType(); - fmMsgCounter[ typeMess ] ++; - fhStsMessType->Fill( static_cast< uint16_t > (typeMess) ); - fhStsMessTypePerDpb->Fill( fuCurrDpbIdx, static_cast< uint16_t > (typeMess) ); - - switch( typeMess ) - { - case stsxyter::MessType::Hit : - { - // Extract the eLink and Asic indices => Should GO IN the fill method now that obly hits are link/asic specific! - UShort_t usElinkIdx = mess.GetLinkIndex(); - if( fuNbElinksPerDpb <= usElinkIdx ) - { - LOG(fatal) << "CbmCern2017MonitorSts::DoUnpack => " - << "eLink index out of bounds!" - << usElinkIdx << " VS " << fuNbElinksPerDpb; - } // if( fuNbElinksPerDpb <= usElinkIdx ) - fhStsMessTypePerElink->Fill( fuCurrDpbIdx * fuNbElinksPerDpb + usElinkIdx, - static_cast< uint16_t > (typeMess) ); - - UInt_t uAsicIdx = fvuElinkToAsic[fuCurrDpbIdx][usElinkIdx]; - - FillHitInfo( mess, usElinkIdx, uAsicIdx, m ); - break; - } // case stsxyter::MessType::Hit : - case stsxyter::MessType::TsMsb : - { - FillTsMsbInfo( mess, uIdx, m ); - break; - } // case stsxyter::MessType::TsMsb : - case stsxyter::MessType::Epoch : - { - // The first message in the TS is a special ones: EPOCH - FillEpochInfo( mess ); - - if( 0 < uIdx ) - LOG(info) << "CbmCern2017MonitorSts::DoUnpack => " - << "EPOCH message at unexpected position in MS: message " - << uIdx << " VS message 0 expected!"; - break; - } // case stsxyter::MessType::TsMsb : - case stsxyter::MessType::Empty : - { -// FillTsMsbInfo( mess ); - break; - } // case stsxyter::MessType::TsMsb : - case stsxyter::MessType::Dummy : - { - break; - } // case stsxyter::MessType::Dummy / ReadDataAck / Ack : - default: - { - LOG(fatal) << "CbmCern2017MonitorSts::DoUnpack => " - << "Unknown message type, should never happen, stopping here!"; - } - } // switch( mess.GetMessType() ) - - } // for( uint32_t uIdx = 0; uIdx < uNbMessages; ++uIdx ) -/* - LOG(info) << " Finished MS " << std::setw( 12 ) << fulCurrentMsIdx - << " for DPB " << std::setw( 2 ) << fuCurrDpbIdx; -*/ - } // for( size_t m = 0; m < numCompMsInTs; ++m ) - - - // End of TS, check if stuff to do with the hits inside each MS - // Usefull for low rate pulser tests - // Need to do it only when last DPB is processed, as they are done one by one - if( fuCurrDpbIdx == fuNrOfDpbs - 1 ) - { - for( UInt_t uMsIdx = 0; uMsIdx < fuPulserMaxNbMicroslices; ++uMsIdx ) - { -/* - if( kTRUE == fbPulserTimeDiffOn ) - { - UInt_t uNbPulserChans = fvuPulserAsic.size(); - UInt_t uHistoIdx = 0; - for( UInt_t uChA = 0; uChA < uNbPulserChans; ++uChA ) - for( UInt_t uChB = uChA + 1; uChB < uNbPulserChans; ++uChB ) - { - if( 0 < fvuChanNbHitsInMs[ fvuPulserAsic[uChA] ][ fvuPulserChan[uChA] ][ uMsIdx ] && - 0 < fvuChanNbHitsInMs[ fvuPulserAsic[uChB] ][ fvuPulserChan[uChB] ][ uMsIdx ] ) - { - Double_t dTimeDiff = fvdChanLastHitTimeInMs[ fvuPulserAsic[uChB] ][ fvuPulserChan[uChB] ][ uMsIdx ] - - fvdChanLastHitTimeInMs[ fvuPulserAsic[uChA] ][ fvuPulserChan[uChA] ][ uMsIdx ]; - Short_t sAdcDiff = static_cast< Short_t >( fvusChanLastHitAdcInMs[ fvuPulserAsic[uChB] ][ fvuPulserChan[uChB] ][ uMsIdx ] ) - - static_cast< Short_t >( fvusChanLastHitAdcInMs[ fvuPulserAsic[uChA] ][ fvuPulserChan[uChA] ][ uMsIdx ] ); - - if( dTimeDiff < -102406.25 || 102406.25 < dTimeDiff ) - LOG(info) << "CbmCern2017MonitorSts::DoUnpack =>" - << " ASIC A" << fvuPulserAsic[uChA] << " chan A " << fvuPulserChan[uChA] - << " tA " << fvdChanLastHitTimeInMs[ fvuPulserAsic[uChA] ][ fvuPulserChan[uChA] ][ uMsIdx ] - << " ASIC B" << fvuPulserAsic[uChB] << " chan B " << fvuPulserChan[uChB] - << " tB " << fvdChanLastHitTimeInMs[ fvuPulserAsic[uChB] ][ fvuPulserChan[uChB] ][ uMsIdx ] - << " dt " << dTimeDiff; - - if( dTimeDiff < -102406.25 ) - dTimeDiff += 102406.25; - else if( 102406.25 < dTimeDiff ) - dTimeDiff -= 102406.25; - - fhStsPulserChansTimeDiff[ uHistoIdx ]->Fill( dTimeDiff ); - } // Both pulser channels got data in last MS - uHistoIdx ++; - } // Loop on channel pairs - } // if( kTRUE == fbPulserTimeDiffOn ) -*/ - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - { - fhStsChanHitsPerMs[uXyterIdx]->Fill( fvuChanNbHitsInMs[ uXyterIdx ][ uChan ][ uMsIdx ], uChan ); - - // Coincidences between - if( fvuChanNbHitsInMs[ uXyterIdx ][ uChan ][ uMsIdx ] ) - for( UInt_t uChanB = uChan + 1; uChanB < fuNbChanPerAsic; ++uChanB ) - if( fvuChanNbHitsInMs[ uXyterIdx ][ uChanB ][ uMsIdx ] ) - { - fhStsChanSameMs[ uXyterIdx ]->Fill( uChan, uChanB ); - Double_t dTimeDiff = fvdChanLastHitTimeInMs[ uXyterIdx ][ uChanB ][ uMsIdx ] - - fvdChanLastHitTimeInMs[ uXyterIdx ][ uChan ][ uMsIdx ]; - - fpStsChanSameMsTimeDiff[ uXyterIdx ]->Fill( uChan, uChanB, dTimeDiff ); - } // if( fvuChanNbHitsInMs[ uXyterIdx ][ uChanB ] ) - -/* - // Pulser test: Coincidences between different FEEs (maybe on different DPBs) - for( UInt_t uXyterIdxB = uXyterIdx; uXyterIdxB < fuNbStsXyters; ++uXyterIdxB ) - { - for( UInt_t uChanB = 0; uChanB < fuNbChanPerAsic; ++uChanB ) - { - } // for( UInt_t uChanB = 0; uChanB < fuNbChanPerAsic; ++uChanB ) - } // for( UInt_t uXyterIdxB = uXyterIdx; uXyterIdxB < fuNbStsXyters; ++uXyterIdxB ) -*/ - // Ok to reset as we only compare to channels with higher indices (or channels in ASICs with higher indices) - fvuChanNbHitsInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = 0; - fvdChanLastHitTimeInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = -1.0; - fvusChanLastHitAdcInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = 0; - } // for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - } // for( UInt_t uMsIdx = 0; uMsIdx < fuPulserMaxNbMicroslices; ++uMsIdx ) - - if( kTRUE == fbPulserTimeDiffOn ) - { - UInt_t uNbPulserChans = fvuPulserAsic.size(); - UInt_t uHistoIdx = 0; - std::chrono::steady_clock::time_point tNow = std::chrono::steady_clock::now(); - Double_t dUnixTimeInRun = std::chrono::duration_cast< std::chrono::seconds >(tNow - ftStartTimeUnix).count(); - for( UInt_t uChA = 0; uChA < uNbPulserChans; ++uChA ) - for( UInt_t uChB = uChA + 1; uChB < uNbPulserChans; ++uChB ) - { - if( 0 < fvmChanHitsInTs[ fvuPulserAsic[uChA] ][ fvuPulserChan[uChA] ].size() && - 0 < fvmChanHitsInTs[ fvuPulserAsic[uChB] ][ fvuPulserChan[uChB] ].size() ) - { - std::multiset< stsxyter::FinalHit >::iterator itClosestHitB = fvmChanHitsInTs[ fvuPulserAsic[uChB] ][ fvuPulserChan[uChB] ].begin(); - for( std::multiset< stsxyter::FinalHit >::iterator itHitA = fvmChanHitsInTs[ fvuPulserAsic[uChA] ][ fvuPulserChan[uChA] ].begin(); - itHitA != fvmChanHitsInTs[ fvuPulserAsic[uChA] ][ fvuPulserChan[uChA] ].end(); - ++itHitA ) - { - Double_t dClosestTimeDiff = 1e9; - Bool_t bFoundClosest = kFALSE; - - for( std::multiset< stsxyter::FinalHit >::iterator itHitB = itClosestHitB ; - itHitB != fvmChanHitsInTs[ fvuPulserAsic[uChB] ][ fvuPulserChan[uChB] ].end(); - ++itHitB ) - { - Double_t dTimeDiff = static_cast< Double_t >( (*itHitB).GetTs() ) - - static_cast< Double_t >( (*itHitA).GetTs() ); - - if( TMath::Abs( dTimeDiff ) < TMath::Abs( dClosestTimeDiff ) ) - { - dClosestTimeDiff = dTimeDiff; - itClosestHitB = itHitB; - bFoundClosest = kTRUE; - } // if( TMath::Abs( dTimeDiff ) < TMath::Abs( dClosestTimeDiff ) ) - } // Loop on hits in channel B, starting from match to previous channel A hit - - if( kFALSE == bFoundClosest ) - continue; - - Double_t dTimeDiff = dClosestTimeDiff * stsxyter::kdClockCycleNs; - Short_t sAdcDiff = static_cast< Short_t >( (*itClosestHitB).GetAdc() ) - - static_cast< Short_t >( (*itHitA).GetAdc() ); -/* - LOG(info) << "( " << std::setw( 2 ) << fvuPulserAsic[uChA] - << ", " << std::setw( 3 ) << fvuPulserChan[uChA] - << ")-( " << std::setw( 2 ) << fvuPulserAsic[uChB] - << ", " << std::setw( 3 ) << fvuPulserChan[uChB] - << ") ADC " << std::setw( 3 ) << sAdcDiff - << " dT " << std::setw( 7 ) << dTimeDiff - << " T_A " << std::setw( 12 ) << (*itHitA).GetTs() - << " T_B " << std::setw( 12 ) << (*itClosestHitB).GetTs(); -*/ - fhStsPulserChansTimeDiff[ uHistoIdx ]->Fill( dTimeDiff ); - fhStsPulserChansTimeDiffAdc[ uHistoIdx ]->Fill( dTimeDiff, sAdcDiff ); - if( fbLongHistoEnable ) - { -// Double_t dTimeSinceStartSec = ( (*itHitA).GetTs() * stsxyter::kdClockCycleNs - fdStartTime )* 1e-9; - fhStsPulserChansTimeDiffEvo[ uHistoIdx ]->Fill( dUnixTimeInRun, dTimeDiff ); - } // if( fbLongHistoEnable ) - } // Loop on hits in channel A - } // Both pulser channels got data in last TS - uHistoIdx ++; - } // Loop on channel pairs - - // Clean up the buffers now that we used the data - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - fvmChanHitsInTs[ uXyterIdx ][ uChan ].clear(); - } // if( kTRUE == fbPulserTimeDiffOn ) - - } // if( fuCurrDpbIdx == fuNrOfDpbs - 1 ) - - if( 0 == ts.index() % 1000 && fuCurrDpbIdx == fuNrOfDpbs - 1 ) - { - for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - { - Double_t dTsMsbTime = - static_cast<ULong64_t>( stsxyter::kuHitNbTsBins ) - * static_cast<ULong64_t>( fvulCurrentTsMsb[fuCurrDpbIdx]) - + static_cast<ULong64_t>( stsxyter::kulTsCycleNbBins ) - * static_cast<ULong64_t>( fvuCurrentTsMsbCycle[fuCurrDpbIdx] ); - dTsMsbTime *= stsxyter::kdClockCycleNs * 1e-9; - - LOG(info) << "End of TS " << std::setw(7) << ts.index() - << " eDPB " << std::setw(2) << uDpb - << " current TS MSB counter is " << std::setw(12) << fvulCurrentTsMsb[uDpb] - << " current TS MSB cycle counter is " << std::setw(12) << fvuCurrentTsMsbCycle[uDpb] - << " current TS MSB time is " << std::setw(12) << dTsMsbTime << " s"; - } - } // if( 0 == ts.index() % 1000 && fuCurrDpbIdx == fuNrOfDpbs - 1 ) - - return kTRUE; -} - -void CbmCern2017MonitorSts::FillHitInfo( stsxyter::Message mess, const UShort_t & /*usElinkIdx*/, const UInt_t & uAsicIdx, const UInt_t & uMsIdx ) -{ - UShort_t usChan = mess.GetHitChannel(); - UShort_t usRawAdc = mess.GetHitAdc(); -// UShort_t usFullTs = mess.GetHitTimeFull(); -// UShort_t usTsOver = mess.GetHitTimeOver(); - UShort_t usRawTs = mess.GetHitTime(); - - fhStsChanCounts[ uAsicIdx ]->Fill( usChan ); - fhStsChanRawAdc[ uAsicIdx ]->Fill( usChan, usRawAdc ); - fhStsChanRawAdcProf[ uAsicIdx ]->Fill( usChan, usRawAdc ); - fhStsChanRawTs[ uAsicIdx ]->Fill( usChan, usRawTs ); - fhStsChanMissEvt[ uAsicIdx ]->Fill( usChan, mess.IsHitMissedEvts() ); - - // Compute the Full time stamp - -// Long64_t ulOldHitTime = fvulChanLastHitTime[ uAsicIdx ][ usChan ]; -// Double_t dOldHitTime = fvdChanLastHitTime[ uAsicIdx ][ usChan ]; - - // Use TS w/o overlap bits as they will anyway come from the TS_MSB - fvulChanLastHitTime[ uAsicIdx ][ usChan ] = usRawTs; - -// if( usRawTs < fvuElinkLastTsHit[fuCurrDpbIdx] ) -// fvulCurrentTsMsb[fuCurrDpbIdx]++; - fvulChanLastHitTime[ uAsicIdx ][ usChan ] += - static_cast<ULong64_t>( stsxyter::kuHitNbTsBins ) - * static_cast<ULong64_t>( fvulCurrentTsMsb[fuCurrDpbIdx]) - + static_cast<ULong64_t>( stsxyter::kulTsCycleNbBins ) - * static_cast<ULong64_t>( fvuCurrentTsMsbCycle[fuCurrDpbIdx] ) - ; - - fvuElinkLastTsHit[fuCurrDpbIdx] = usRawTs; - - // Convert the Hit time in bins to Hit time in ns - Double_t dHitTimeNs = fvulChanLastHitTime[ uAsicIdx ][ usChan ] * stsxyter::kdClockCycleNs; - - - // If needed fill the hit interval plots - if( fbChanHitDtEna ) - { - Double_t dDeltaT = dHitTimeNs - fvdChanLastHitTime[ uAsicIdx ][ usChan ]; - if( 0 == dDeltaT ) - fhStsChanHitDtNeg[ uAsicIdx ]->Fill( 1, usChan ); - else if( 0 < dDeltaT ) - fhStsChanHitDt[ uAsicIdx ]->Fill( dDeltaT, usChan ); - else fhStsChanHitDtNeg[ uAsicIdx ]->Fill( -dDeltaT, usChan ); - } // if( fbChanHitDtEna ) - - // Store new value of Hit time in ns - fvdChanLastHitTime[ uAsicIdx ][ usChan ] = fvulChanLastHitTime[ uAsicIdx ][ usChan ] * stsxyter::kdClockCycleNs; -/* - LOG(info) << " Asic " << std::setw( 2 ) << uAsicIdx - << " Channel " << std::setw( 3 ) << usChan - << " Diff to last hit " << std::setw( 12 ) << ( fvulChanLastHitTime[ uAsicIdx ][ usChan ] - ulOldHitTime) - << " in s " << std::setw( 12 ) << ( fvdChanLastHitTime[ uAsicIdx ][ usChan ] - dOldHitTime) * 1e-9; -*/ - // Pulser and MS - fvuChanNbHitsInMs[ uAsicIdx ][ usChan ][ uMsIdx ] ++; - fvdChanLastHitTimeInMs[ uAsicIdx ][ usChan ][ uMsIdx ] = dHitTimeNs; - fvusChanLastHitAdcInMs[ uAsicIdx ][ usChan ][ uMsIdx ] = usRawAdc; - fvmChanHitsInTs[ uAsicIdx ][ usChan ].insert( stsxyter::FinalHit( fvulChanLastHitTime[ uAsicIdx ][ usChan ], usRawAdc, uAsicIdx, usChan ) ); - -/* - LOG(info) << " TS " << std::setw( 12 ) << fulCurrentTsIdx - << " MS " << std::setw( 12 ) << fulCurrentMsIdx - << " MsInTs " << std::setw( 3 ) << uMsIdx - << " Asic " << std::setw( 2 ) << uAsicIdx - << " Channel " << std::setw( 3 ) << usChan - << " ADC " << std::setw( 3 ) << usRawAdc - << " TS " << std::setw( 3 ) << usRawTs // 9 bits TS - << " SX TsMsb " << std::setw( 2 ) << ( fvulCurrentTsMsb[fuCurrDpbIdx] & 0x1F ) // Total StsXyter TS = 14 bits => 9b Hit TS + lower 5b TS_MSB after DPB - << " DPB TsMsb " << std::setw( 6 ) << ( fvulCurrentTsMsb[fuCurrDpbIdx] >> 5 ) // Total StsXyter TS = 14 bits => 9b Hit TS + lower 5b of TS_MSB after DPB - << " TsMsb " << std::setw( 7 ) << fvulCurrentTsMsb[fuCurrDpbIdx] - << " MsbCy " << std::setw( 4 ) << fvuCurrentTsMsbCycle[fuCurrDpbIdx] - << " Time " << std::setw ( 12 ) << fvulChanLastHitTime[ uAsicIdx ][ usChan ]; -*/ - // Check Starting point of histos with time as X axis - if( -1 == fdStartTime ) - fdStartTime = fvdChanLastHitTime[ uAsicIdx ][ usChan ]; - - // Fill histos with time as X axis - Double_t dTimeSinceStartSec = (fvdChanLastHitTime[ uAsicIdx ][ usChan ] - fdStartTime)* 1e-9; - Double_t dTimeSinceStartMin = dTimeSinceStartSec / 60.0; - fhStsChanHitRateEvo[ uAsicIdx ]->Fill( dTimeSinceStartSec , usChan ); - fhStsXyterRateEvo[ uAsicIdx ]->Fill( dTimeSinceStartSec ); - fhStsChanHitRateEvoLong[ uAsicIdx ]->Fill( dTimeSinceStartMin, usChan, 1.0/60.0 ); - fhStsXyterRateEvoLong[ uAsicIdx ]->Fill( dTimeSinceStartMin, 1.0/60.0 ); - - if( kTRUE == fbLongHistoEnable ) - { - std::chrono::steady_clock::time_point tNow = std::chrono::steady_clock::now(); - Double_t dUnixTimeInRun = std::chrono::duration_cast< std::chrono::seconds >(tNow - ftStartTimeUnix).count(); - fhFebRateEvoLong[ uAsicIdx ]->Fill( dUnixTimeInRun , 1.0 / fuLongHistoBinSizeSec ); - fhFebChRateEvoLong[ uAsicIdx ]->Fill( dUnixTimeInRun , usChan, 1.0 / fuLongHistoBinSizeSec ); - } // if( kTRUE == fbLongHistoEnable ) - -} - -void CbmCern2017MonitorSts::FillTsMsbInfo( stsxyter::Message mess, UInt_t uMessIdx, UInt_t /*uMsIdx*/ ) -{ - UInt_t uVal = mess.GetTsMsbVal(); -/* - if( 0 == fuCurrDpbIdx ) - LOG(info) << " TS " << std::setw( 12 ) << fulCurrentTsIdx - << " MS " << std::setw( 12 ) << fulCurrentMsIdx - << " MsInTs " << std::setw( 3 ) << uMsIdx - << " DPB " << std::setw( 2 ) << fuCurrDpbIdx - << " Mess " << std::setw( 5 ) << uMessIdx - << " TsMsb " << std::setw( 5 ) << uVal; -*/ -/* - if( (uVal != fvulCurrentTsMsb[fuCurrDpbIdx] + 1) && 0 < uVal && - !( 1 == uMessIdx && usVal == fvulCurrentTsMsb[fuCurrDpbIdx] ) ) // 1st TS_MSB in MS is always a repeat of the last one in previous MS! - { - LOG(info) << "TS MSB not increasing by 1! TS " << std::setw( 12 ) << fulCurrentTsIdx - << " MS " << std::setw( 12 ) << fulCurrentMsIdx - << " MsInTs " << std::setw( 3 ) << uMsIdx - << " DPB " << std::setw( 2 ) << fuCurrDpbIdx - << " Mess " << std::setw( 5 ) << uMessIdx - << " Old TsMsb " << std::setw( 5 ) << fvulCurrentTsMsb[fuCurrDpbIdx] - << " new TsMsb " << std::setw( 5 ) << uVal - << " Diff " << std::setw( 5 ) << uVal - fvulCurrentTsMsb[fuCurrDpbIdx] - << " Old MsbCy " << std::setw( 5 ) << fvuCurrentTsMsbCycle[fuCurrDpbIdx]; - } // if( (uVal != fvulCurrentTsMsb[fuCurrDpbIdx] + 1) && 0 < uVal ) -*/ - - // Update Status counters - if( uVal < fvulCurrentTsMsb[fuCurrDpbIdx] ) - { - - LOG(info) << " TS " << std::setw( 12 ) << fulCurrentTsIdx - << " MS " << std::setw( 12 ) << fulCurrentMsIdx - << " DPB " << std::setw( 2 ) << fuCurrDpbIdx - << " Old TsMsb " << std::setw( 5 ) << fvulCurrentTsMsb[fuCurrDpbIdx] - << " Old MsbCy " << std::setw( 5 ) << fvuCurrentTsMsbCycle[fuCurrDpbIdx] - << " new TsMsb " << std::setw ( 5 ) << uVal; - - fvuCurrentTsMsbCycle[fuCurrDpbIdx] ++; - } // if( uVal < fvulCurrentTsMsb[fuCurrDpbIdx] ) - fvulCurrentTsMsb[fuCurrDpbIdx] = uVal; - - if( 1 < uMessIdx ) - { - fhStsDpbRawTsMsb->Fill( fuCurrDpbIdx, fvulCurrentTsMsb[fuCurrDpbIdx] ); - fhStsDpbRawTsMsbSx->Fill( fuCurrDpbIdx, ( fvulCurrentTsMsb[fuCurrDpbIdx] & 0x1F ) ); - fhStsDpbRawTsMsbDpb->Fill( fuCurrDpbIdx, ( fvulCurrentTsMsb[fuCurrDpbIdx] >> 5 ) ); - } // if( 0 < uMessIdx ) - -// fhStsAsicTsMsb->Fill( fvulCurrentTsMsb[fuCurrDpbIdx], uAsicIdx ); -} - -void CbmCern2017MonitorSts::FillEpochInfo( stsxyter::Message /*mess*/ ) -{ -// UShort_t usVal = mess.GetTsMsbVal(); -/* - // Update Status counters - if( usVal < fvulCurrentTsMsb[fuCurrDpbIdx] ) - fvuCurrentTsMsbCycle[fuCurrDpbIdx] ++; - fvulCurrentTsMsb[fuCurrDpbIdx] = usVal; - -// fhStsAsicTsMsb->Fill( fvulCurrentTsMsb[fuCurrDpbIdx], uAsicIdx ); -*/ -} - -void CbmCern2017MonitorSts::Reset() -{ -} - -void CbmCern2017MonitorSts::Finish() -{ - - LOG(info) << "-------------------------------------"; - LOG(info) << "CbmCern2017MonitorSts statistics are "; - LOG(info) << " Hit messages: " << fmMsgCounter[ stsxyter::MessType::Hit ] << "\n" - << " Ts MSB messages: " << fmMsgCounter[ stsxyter::MessType::TsMsb ] << "\n" - << " Dummy messages: " << fmMsgCounter[ stsxyter::MessType::Dummy ] << "\n" - << " Epoch messages: " << fmMsgCounter[ stsxyter::MessType::Epoch ] << "\n" - << " Empty messages: " << fmMsgCounter[ stsxyter::MessType::Empty ]; - - LOG(info) << "-------------------------------------"; - - SaveAllHistos(); - -} - - -void CbmCern2017MonitorSts::FillOutput(boost::any) -{ -} - -void CbmCern2017MonitorSts::SaveAllHistos( TString sFileName ) -{ - TDirectory * oldDir = NULL; - TFile * histoFile = NULL; - if( "" != sFileName ) - { - // Store current directory position to allow restore later - oldDir = gDirectory; - // open separate histo file in recreate mode - histoFile = new TFile( sFileName , "RECREATE"); - histoFile->cd(); - } // if( "" != sFileName ) - - gDirectory->mkdir("Sts_Raw"); - gDirectory->cd("Sts_Raw"); - - fhStsMessType->Write(); - fhStsSysMessType->Write(); - fhStsMessTypePerDpb->Write(); - fhStsSysMessTypePerDpb->Write(); - fhStsDpbRawTsMsb->Write(); - fhStsDpbRawTsMsbSx->Write(); - fhStsDpbRawTsMsbDpb->Write(); - fhStsMessTypePerElink->Write(); - fhStsSysMessTypePerElink->Write(); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fhStsChanCounts[ uXyterIdx ]->Write(); - fhStsChanRawAdc[ uXyterIdx ]->Write(); - fhStsChanRawAdcProf[ uXyterIdx ]->Write(); - fhStsChanRawTs[ uXyterIdx ]->Write(); - fhStsChanMissEvt[ uXyterIdx ]->Write(); - fhStsChanHitRateEvo[ uXyterIdx ]->Write(); - fhStsXyterRateEvo[ uXyterIdx ]->Write(); - fhStsChanHitRateEvoLong[ uXyterIdx ]->Write(); - fhStsXyterRateEvoLong[ uXyterIdx ]->Write(); - if( fbChanHitDtEna ) - { - fhStsChanHitDt[ uXyterIdx ]->Write(); - fhStsChanHitDtNeg[ uXyterIdx ]->Write(); - } // if( fbChanHitDtEna ) - fhStsChanHitsPerMs[ uXyterIdx ]->Write(); - fhStsChanSameMs[ uXyterIdx ]->Write(); - fpStsChanSameMsTimeDiff[ uXyterIdx ]->Write(); - fhStsChanSameMsTimeDiff[ uXyterIdx ]->Write(); - if( kTRUE == fbLongHistoEnable ) - { - fhFebRateEvoLong[ uXyterIdx ]->Write(); - fhFebChRateEvoLong[ uXyterIdx ]->Write(); - } // if( kTRUE == fbLongHistoEnable ) - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - - if( kTRUE == fbPulserTimeDiffOn ) - { - UInt_t uNbPulserChans = fvuPulserAsic.size(); - UInt_t uHistoIdx = 0; - for( UInt_t uChA = 0; uChA < uNbPulserChans; ++uChA ) - for( UInt_t uChB = uChA + 1; uChB < uNbPulserChans; ++uChB ) - { - fhStsPulserChansTimeDiff[ uHistoIdx ]->Write(); - uHistoIdx ++; - } // Loop on channel pairs - } // if( kTRUE == fbPulserTimeDiffOn ) - - fhStsAsicTsMsb->Write(); - fhStsAsicTsMsbMaj->Write(); - - for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - { - fhStsElinkTsMsbCrc[ uDpb ]->Write(); - fhStsElinkTsMsbMaj[ uDpb ]->Write(); - } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - - gDirectory->cd(".."); - - // Flib Histos - gDirectory->mkdir("Flib_Raw"); - gDirectory->cd("Flib_Raw"); - for( UInt_t uLinks = 0; uLinks < kiMaxNbFlibLinks; uLinks ++) - { - TString sMsSzName = Form("MsSz_link_%02u", uLinks); - if( fHM->Exists(sMsSzName.Data() ) ) - fHM->H1( sMsSzName.Data() )->Write(); - - sMsSzName = Form("MsSzTime_link_%02u", uLinks); - if( fHM->Exists(sMsSzName.Data() ) ) - fHM->P1( sMsSzName.Data() )->Write(); - } // for( UInt_t uLinks = 0; uLinks < 16; uLinks ++) - gDirectory->cd(".."); - - if( "" != sFileName ) - { - // Restore original directory position - histoFile->Close(); - oldDir->cd(); - } // if( "" != sFileName ) - -} -void CbmCern2017MonitorSts::ResetAllHistos() -{ - LOG(info) << "Reseting all STS histograms."; - - fhStsMessType->Reset(); - fhStsSysMessType->Reset(); - fhStsMessTypePerDpb->Reset(); - fhStsSysMessTypePerDpb->Reset(); - fhStsDpbRawTsMsb->Reset(); - fhStsDpbRawTsMsbSx->Reset(); - fhStsDpbRawTsMsbDpb->Reset(); - fhStsMessTypePerElink->Reset(); - fhStsSysMessTypePerElink->Reset(); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fhStsChanCounts[ uXyterIdx ]->Reset(); - fhStsChanRawAdc[ uXyterIdx ]->Reset(); - fhStsChanRawAdcProf[ uXyterIdx ]->Reset(); - fhStsChanRawTs[ uXyterIdx ]->Reset(); - fhStsChanMissEvt[ uXyterIdx ]->Reset(); - fhStsChanHitRateEvo[ uXyterIdx ]->Reset(); - fhStsXyterRateEvo[ uXyterIdx ]->Reset(); - fhStsChanHitRateEvoLong[ uXyterIdx ]->Reset(); - fhStsXyterRateEvoLong[ uXyterIdx ]->Reset(); - if( fbChanHitDtEna ) - { - fhStsChanHitDt[ uXyterIdx ]->Reset(); - fhStsChanHitDtNeg[ uXyterIdx ]->Reset(); - } // if( fbChanHitDtEna ) - fhStsChanHitsPerMs[ uXyterIdx ]->Reset(); - fhStsChanSameMs[ uXyterIdx ]->Reset(); - fpStsChanSameMsTimeDiff[ uXyterIdx ]->Reset(); - fhStsChanSameMsTimeDiff[ uXyterIdx ]->Reset(); - if( kTRUE == fbLongHistoEnable ) - { - ftStartTimeUnix = std::chrono::steady_clock::now(); - fhFebRateEvoLong[ uXyterIdx ]->Reset(); - fhFebChRateEvoLong[ uXyterIdx ]->Reset(); - } // if( kTRUE == fbLongHistoEnable ) - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - - if( kTRUE == fbPulserTimeDiffOn ) - { - UInt_t uNbPulserChans = fvuPulserAsic.size(); - UInt_t uHistoIdx = 0; - for( UInt_t uChA = 0; uChA < uNbPulserChans; ++uChA ) - for( UInt_t uChB = uChA + 1; uChB < uNbPulserChans; ++uChB ) - { - fhStsPulserChansTimeDiff[ uHistoIdx ]->Reset(); - uHistoIdx ++; - } // Loop on channel pairs - } // if( kTRUE == fbPulserTimeDiffOn ) - - fhStsAsicTsMsb->Reset(); - fhStsAsicTsMsbMaj->Reset(); - - for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - { - fhStsElinkTsMsbCrc[ uDpb ]->Reset(); - fhStsElinkTsMsbMaj[ uDpb ]->Reset(); - } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - - for( UInt_t uLinks = 0; uLinks < kiMaxNbFlibLinks; ++uLinks ) - { - TString sMsSzName = Form("MsSz_link_%02u", uLinks); - if( fHM->Exists(sMsSzName.Data() ) ) - fHM->H1( sMsSzName.Data() )->Reset(); - - sMsSzName = Form("MsSzTime_link_%02u", uLinks); - if( fHM->Exists(sMsSzName.Data() ) ) - fHM->P1( sMsSzName.Data() )->Reset(); - } // for( UInt_t uLinks = 0; uLinks < kiMaxNbFlibLinks; ++uLinks ) - - fdStartTime = -1; - fdStartTimeMsSz = -1; -} - -void CbmCern2017MonitorSts::SetRunStart( Int_t dateIn, Int_t timeIn, Int_t iBinSize ) -{ - TDatime * fRunStartDateTime = new TDatime( dateIn, timeIn); - fiRunStartDateTimeSec = fRunStartDateTime->Convert(); - fiBinSizeDatePlots = iBinSize; - - LOG(info) << "Assigned new MUCH Run Start Date-Time: " << fRunStartDateTime->AsString(); -} -void CbmCern2017MonitorSts::SetPulserChannels( UInt_t uAsicA, UInt_t uChanA, UInt_t uAsicB, UInt_t uChanB, - UInt_t uAsicC, UInt_t uChanC, UInt_t uAsicD, UInt_t uChanD, - UInt_t uMaxNbMicroslices ) -{ -/* - THttpServer* server = FairRunOnline::Instance()->GetHttpServer(); - TString sHistName{""}; - TString title{""}; -*/ - fuPulserMaxNbMicroslices = uMaxNbMicroslices; - - UInt_t uNbChans = 4; - - fvuPulserAsic.resize( uNbChans ); - fvuPulserChan.resize( uNbChans ); - fvuPulserAsic[0] = uAsicA; - fvuPulserChan[0] = uChanA; - fvuPulserAsic[1] = uAsicB; - fvuPulserChan[1] = uChanB; - fvuPulserAsic[2] = uAsicC; - fvuPulserChan[2] = uChanC; - fvuPulserAsic[3] = uAsicD; - fvuPulserChan[3] = uChanD; -/* - // Remove old histos - if( kTRUE == fbPulserTimeDiffOn ) - { - for( Int_t iIdx = 0; iIdx < fhStsPulserChansTimeDiff.size(); ++iIdx ) - delete fhStsPulserChansTimeDiff[ iIdx ]; - } // if( kTRUE == fbPulserTimeDiffOn ) - fhStsPulserChansTimeDiff.clear(); - - for( UInt_t uChA = 0; uChA < uNbChans; ++uChA ) - for( UInt_t uChB = uChA + 1; uChB < uNbChans; ++uChB ) - { - sHistName = Form( "hStsPulserTimeDiff_%02u_%03u_%02u_%03u", - fvuPulserAsic[uChA], fvuPulserChan[uChA], - fvuPulserAsic[uChB], fvuPulserChan[uChB] ); - title = "Time diff for hits in same MS from ASIC %02d ch %03d and ASIC %02d ch %03d; tB - tA [ns]; Counts"; - TH1 * pHist = new TH1I(sHistName, title, 16385, -51203.125, 51203.125); - - fHM->Add(sHistName.Data(), pHist); - if( server ) server->Register("/StsRaw", pHist ); - fhStsPulserChansTimeDiff.push_back( pHist ); - } // Loop on pairs of channels -*/ - LOG(info) << "Set pulser channels to: " - << "( " << fvuPulserAsic[0] << "' " << fvuPulserChan[0] <<") " - << "( " << fvuPulserAsic[1] << "' " << fvuPulserChan[1] <<") " - << "( " << fvuPulserAsic[2] << "' " << fvuPulserChan[2] <<") " - << "( " << fvuPulserAsic[3] << "' " << fvuPulserChan[3] <<") "; - - fbPulserTimeDiffOn = kTRUE; -} - -void CbmCern2017MonitorSts::SetLongDurationLimits( UInt_t uDurationSeconds, UInt_t uBinSize ) -{ - fbLongHistoEnable = kTRUE; - fuLongHistoNbSeconds = uDurationSeconds; - fuLongHistoBinSizeSec = uBinSize; -} - -ClassImp(CbmCern2017MonitorSts) diff --git a/beamtime/cern2017/unpacker/CbmCern2017MonitorSts.h b/beamtime/cern2017/unpacker/CbmCern2017MonitorSts.h deleted file mode 100644 index 6f260571a24f00c0f99464543103dfd6d7b2dc7e..0000000000000000000000000000000000000000 --- a/beamtime/cern2017/unpacker/CbmCern2017MonitorSts.h +++ /dev/null @@ -1,187 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmCern2017MonitorSts ----- -// ----- Created 25/07/17 by P.-A. Loizeau ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CBMCERN2017MONITORSTS_H -#define CBMCERN2017MONITORSTS_H - -#include "Timeslice.hpp" - -// Data -#include "StsXyterMessage.h" -#include "StsXyterFinalHit.h" - -// CbmRoot -#include "CbmTSUnpack.h" -#include "CbmHistManager.h" - -// C++11 -#include <chrono> - -// C/C++ -#include <vector> -#include <set> -#include <map> - -class CbmCern2017UnpackParSts; - -class CbmCern2017MonitorSts: public CbmTSUnpack -{ -public: - - CbmCern2017MonitorSts(); - virtual ~CbmCern2017MonitorSts(); - - virtual Bool_t Init(); - - virtual Bool_t DoUnpack(const fles::Timeslice& ts, size_t component); - - virtual void Reset(); - - virtual void Finish(); - - void SetParContainers(); - - Bool_t InitContainers(); - - Bool_t ReInitContainers(); - - void FillOutput(boost::any); - - void SetRunStart( Int_t dateIn, Int_t timeIn, Int_t iBinSize = 5 ); - - void ResetAllHistos(); - void SaveAllHistos( TString sFileName = "" ); - - void SetMsOverlap(size_t uOverlapMsNb = 1) { fuOverlapMsNb = uOverlapMsNb; } - size_t GetMsOverlap() { return fuOverlapMsNb; } - - void SetPrintMessage( Bool_t bPrintMessOn = kTRUE, - stsxyter::MessagePrintMask ctrl = stsxyter::MessagePrintMask::msg_print_Hex | - stsxyter::MessagePrintMask::msg_print_Human ) - { fbPrintMessages = bPrintMessOn; fPrintMessCtrl = ctrl; } - void EnableChanHitDtPlot( Bool_t bEnable = kTRUE ) { fbChanHitDtEna = bEnable; } - void SetPulserChannels( UInt_t uAsicA, UInt_t uChanA, UInt_t uAsicB, UInt_t uChanB, - UInt_t uAsicC, UInt_t uChanC, UInt_t uAsicD, UInt_t uChanD, - UInt_t uMaxNbMicroslices = 100 ); - void SetLongDurationLimits( UInt_t uDurationSeconds = 3600, UInt_t uBinSize = 1 ); - -private: - size_t fuOverlapMsNb; /** Ignore Overlap Ms: all fuOverlapMsNb MS at the end of timeslice **/ - - // Parameters - CbmCern2017UnpackParSts* fUnpackPar; //! - UInt_t fuNrOfDpbs; //! Total number of Sts DPBs in system - std::map<UInt_t, UInt_t> fDpbIdIndexMap; //! Map of DPB Identifier to DPB index - UInt_t fuNbElinksPerDpb; //! Number of possible eLinks per DPB - UInt_t fuNbStsXyters; //! Number of StsXyter ASICs - UInt_t fuNbChanPerAsic; //! Number of channels per StsXyter ASIC => should be constant somewhere!!!! - std::vector< std::vector< UInt_t > > fvuElinkToAsic; //! Vector holding for each link the corresponding ASIC index [fuNrOfDpbs * fuNbElinksPerDpb] - - // Constants - static const Int_t kiMaxNbFlibLinks = 16; - static const UInt_t kuBytesPerMessage = 4; - - // Internal Control/status of monitor - // Task configuration values - Bool_t fbPrintMessages; - stsxyter::MessagePrintMask fPrintMessCtrl; - Bool_t fbChanHitDtEna; - // TS/MS info - ULong64_t fulCurrentTsIdx; - ULong64_t fulCurrentMsIdx; - // Current data properties - std::map< stsxyter::MessType, UInt_t > fmMsgCounter; - UInt_t fuCurrentEquipmentId; //! Current equipment ID, tells from which DPB the current MS is originating - UInt_t fuCurrDpbId; //! Temp holder until Current equipment ID is properly filled in MS - UInt_t fuCurrDpbIdx; //! Index of the DPB from which the MS currently unpacked is coming - Int_t fiRunStartDateTimeSec; //! Start of run time since "epoch" in s, for the plots with date as X axis - Int_t fiBinSizeDatePlots; //! Bin size in s for the plots with date as X axis -// std::vector< std::vector< UInt_t > > fvuCurrentTsMsb; //! Current TS MSB for each eLink - // Data format control - std::vector< ULong64_t > fvulCurrentTsMsb; //! Current TS MSB for each DPB - std::vector< UInt_t > fvuCurrentTsMsbCycle; //! Current TS MSB cycle for DPB - std::vector< UInt_t > fvuElinkLastTsHit; //! TS from last hit for DPB - // Hits comparison - std::vector< std::vector< ULong64_t > > fvulChanLastHitTime; //! Last hit time in bins for each Channel - std::vector< std::vector<Double_t> > fvdChanLastHitTime; //! Last hit time in ns for each Channel - std::vector< std::vector< std::vector< UInt_t > > > fvuChanNbHitsInMs; //! Number of hits in each MS for each Channel - std::vector< std::vector< std::vector< Double_t > > > fvdChanLastHitTimeInMs; //! Last hit time in bins in each MS for each Channel - std::vector< std::vector< std::vector< UShort_t > > > fvusChanLastHitAdcInMs; //! Last hit ADC in bins in each MS for each Channel - std::vector< std::vector< std::multiset< stsxyter::FinalHit > > > fvmChanHitsInTs; //! All hits (time & ADC) in bins in last TS for each Channel - // Starting state book-keeping - Double_t fdStartTime; /** Time of first valid hit (TS_MSB available), used as reference for evolution plots**/ - Double_t fdStartTimeMsSz; /** Time of first microslice, used as reference for evolution plots**/ - std::chrono::steady_clock::time_point ftStartTimeUnix; /** Time of run Start from UNIX system, used as reference for long evolution plots against reception time **/ - - // Histograms - CbmHistManager* fHM; //! Histogram manager - TH1* fhStsMessType; - TH1* fhStsSysMessType; - TH2* fhStsMessTypePerDpb; - TH2* fhStsSysMessTypePerDpb; - TH2* fhStsDpbRawTsMsb; - TH2* fhStsDpbRawTsMsbSx; - TH2* fhStsDpbRawTsMsbDpb; - TH2* fhStsMessTypePerElink; - TH2* fhStsSysMessTypePerElink; - - std::vector<TH1*> fhStsChanCounts; - std::vector<TH2*> fhStsChanRawAdc; - std::vector<TProfile*> fhStsChanRawAdcProf; - std::vector<TH2*> fhStsChanRawTs; - std::vector<TH2*> fhStsChanMissEvt; - std::vector<TH2*> fhStsChanHitRateEvo; - std::vector<TH1*> fhStsXyterRateEvo; - std::vector<TH2*> fhStsChanHitRateEvoLong; - std::vector<TH1*> fhStsXyterRateEvoLong; - std::vector<TH2*> fhStsChanHitDt; - std::vector<TH2*> fhStsChanHitDtNeg; - std::vector<TH2*> fhStsChanHitsPerMs; - std::vector<TH2*> fhStsChanSameMs; - std::vector<TProfile2D*> fpStsChanSameMsTimeDiff; - std::vector<TH2*> fhStsChanSameMsTimeDiff; - - Bool_t fbPulserTimeDiffOn; - UInt_t fuPulserMaxNbMicroslices; - std::vector<UInt_t> fvuPulserAsic; - std::vector<UInt_t> fvuPulserChan; - std::vector<TH1*> fhStsPulserChansTimeDiff; - std::vector<TH2*> fhStsPulserChansTimeDiffEvo; - std::vector<TH2*> fhStsPulserChansTimeDiffAdc; - - TH2* fhStsAsicTsMsb; - TH2* fhStsAsicTsMsbMaj; - std::vector<TH2*> fhStsElinkTsMsbCrc; - std::vector<TH2*> fhStsElinkTsMsbMaj; - - Bool_t fbLongHistoEnable; - UInt_t fuLongHistoNbSeconds; - UInt_t fuLongHistoBinSizeSec; - UInt_t fuLongHistoBinNb; - std::vector<TH1*> fhFebRateEvoLong; - std::vector<TH2*> fhFebChRateEvoLong; -/* - std::vector<TH1*> fhFebRateEvoDate; -*/ - - TCanvas* fcMsSizeAll; - TH1* fhMsSz[kiMaxNbFlibLinks]; - TProfile* fhMsSzTime[kiMaxNbFlibLinks]; - - void CreateHistograms(); - - void FillHitInfo( stsxyter::Message mess, const UShort_t & usElinkIdx, const UInt_t & uAsicIdx, const UInt_t & uMsIdx ); - void FillTsMsbInfo( stsxyter::Message mess, UInt_t uMessIdx = 0, UInt_t uMsIdx = 0); - void FillEpochInfo( stsxyter::Message mess ); - - CbmCern2017MonitorSts(const CbmCern2017MonitorSts&); - CbmCern2017MonitorSts operator=(const CbmCern2017MonitorSts&); - - ClassDef(CbmCern2017MonitorSts, 1) -}; - -#endif // CBMCERN2017MONITORSTS_H diff --git a/beamtime/cern2017/unpacker/StsXyterBetaHit.h b/beamtime/cern2017/unpacker/StsXyterBetaHit.h deleted file mode 100644 index 4c9e378d2959884e2ce247646b64068a32a3dab0..0000000000000000000000000000000000000000 --- a/beamtime/cern2017/unpacker/StsXyterBetaHit.h +++ /dev/null @@ -1,49 +0,0 @@ -/************************************************************ - * - ************************************************************/ - -#ifndef STSXYTERBETAHIT_H -#define STSXYTERBETAHIT_H - -// C/C++ headers -#include <stdint.h> -#include <iostream> - -namespace stsxyter { - - class BetaHit { - private: - - - protected: - uint64_t fulLongTs; // (Software-)Extended TS, in clock cycles - uint16_t fusRawAdc; // Raw ADC value - uint16_t fusAsicIdx; // ASIC Index - uint16_t fusChanIdx; // channel Index - - public: - - BetaHit(const BetaHit& src) : - fulLongTs(src.fulLongTs), fusRawAdc(src.fusRawAdc), fusAsicIdx(src.fusAsicIdx), fusChanIdx(src.fusChanIdx) {} - - BetaHit( uint64_t ulLongTsIn, uint16_t usRawAdcIn, uint16_t usAsicIdxIn = 0, uint16_t usChanIdxIn = 0 ) : - fulLongTs( ulLongTsIn ), fusRawAdc( usRawAdcIn ), fusAsicIdx( usAsicIdxIn ), fusChanIdx( usChanIdxIn ) {} - BetaHit() : BetaHit( 0, 0, 0, 0) {} - - virtual ~BetaHit() {}; - - void assign(const BetaHit& src) { fulLongTs = src.fulLongTs; fusRawAdc = src.fusRawAdc; - fusAsicIdx = src.fusAsicIdx; fusChanIdx = src.fusChanIdx;} - - BetaHit& operator=(const BetaHit& src) { assign(src); return *this; } - bool operator<(const BetaHit& other) const { return fulLongTs < other.fulLongTs; } - - inline void reset() { fulLongTs = 0; fusRawAdc = 0; fusAsicIdx = 0; fusChanIdx = 0; } - - inline uint64_t GetTs() const { return fulLongTs; } - inline uint16_t GetAdc() const { return fusRawAdc; } - inline uint16_t GetAsic() const { return fusAsicIdx; } - inline uint16_t GetChan() const { return fusChanIdx; } - }; -} -#endif // STSXYTERBETAHIT_H diff --git a/beamtime/cern2017/unpacker/StsXyterBetaMessage.cxx b/beamtime/cern2017/unpacker/StsXyterBetaMessage.cxx deleted file mode 100644 index 2d717c6103a2760997ff2c6b760465580e8e7d0f..0000000000000000000000000000000000000000 --- a/beamtime/cern2017/unpacker/StsXyterBetaMessage.cxx +++ /dev/null @@ -1,129 +0,0 @@ - -#include "StsXyterBetaMessage.h" - -// tools - - -// C++11 - -// C/C++ -#include <iomanip> -#include <vector> - -// Namespace -using namespace stsxyter; // Class own namespace -// Namespaces alias -//namespace sxm = stsxyter::BetaMessage; - - -//************************* Messages OP ************************************// -//---------------------------------------------------------------------------- -bool BetaMessage::PrintMess(std::ostream& os, BetaMessagePrintMask ctrl ) const -{ - bool bPrintHex = static_cast< bool >(ctrl & BetaMessagePrintMask::msg_print_Hex); - bool bPrintHuman = static_cast< bool >(ctrl & BetaMessagePrintMask::msg_print_Human); - bool bPrintPrefix = static_cast< bool >(ctrl & BetaMessagePrintMask::msg_print_Prefix); - bool bPrintData = static_cast< bool >(ctrl & BetaMessagePrintMask::msg_print_Data); - - - if( bPrintHex ) - { - const uint8_t* cArrByt = reinterpret_cast<const uint8_t*> ( &fuData ); - - // Set fill char to 0 and read previous state - char cPrev = os.fill( '0' ); - os << "BE = " << std::hex - << std::setw(2) << static_cast< uint16_t >( cArrByt[0] ) << ":" - << std::setw(2) << static_cast< uint16_t >( cArrByt[1] ) << ":" - << std::setw(2) << static_cast< uint16_t >( cArrByt[2] ) << ":" - << std::setw(2) << static_cast< uint16_t >( cArrByt[3] ) - << " LE = " << std::hex - << std::setw(2) << static_cast< uint16_t >( cArrByt[3] ) << ":" - << std::setw(2) << static_cast< uint16_t >( cArrByt[2] ) << ":" - << std::setw(2) << static_cast< uint16_t >( cArrByt[1] ) << ":" - << std::setw(2) << static_cast< uint16_t >( cArrByt[0] ) - << std::dec << " => "; - - // Restore fill char to original - os.fill( cPrev ); - } // if( ctrl & msg_print_Hex ) - - /// Print Link index - os << " Lnk: " << std::setw( 3 ) << GetLinkIndex(); - - if( bPrintHuman ) - { - switch( GetMessType() ) - { - case BetaMessType::Hit : - { - std::cout << " Ch: " << std::setw(3) << GetHitChannel() - << " Adc: " << std::setw(2) << GetHitAdc() - << " Ts Full: " << std::setw(4) << GetHitTimeFull() - << " Ts Over: " << std::hex << GetHitTimeOver() << std::dec - << " Ts: " << std::setw(3) << GetHitTime() - << " Missed? " << IsHitMissedEvts(); - break; - } // case BetaMessType::Hit - case BetaMessType::TsMsb : - { - std::cout << " TS_MSB: " << std::setw(2) << GetTsMsbVal() - << " (Over= " << std::hex << (GetTsMsbVal()) << std::dec << ")"; - break; - } // case BetaMessType::TsMsb - default: - { - } // default - } // switch( GetMessType() ) - } // if( bPrintHuman ) - - if( bPrintPrefix ) - { - switch( GetMessType() ) - { - case BetaMessType::Hit : - { - break; - } // case BetaMessType::Hit - case BetaMessType::TsMsb : - { - break; - } // case BetaMessType::TsMsb - default: - { - } // default - } // switch( GetMessType() ) - } // if( bPrintPrefix ) - - if( bPrintData ) - { - switch( GetMessType() ) - { - case BetaMessType::Hit : - { - break; - } // case BetaMessType::Hit - case BetaMessType::TsMsb : - { - break; - } // case BetaMessType::TsMsb - default: - { - } // default - } // switch( GetMessType() ) - } // if( bPrintData ) - - // Finish with a new line => 1 line per message printout - os << std::endl; - - return true; -} -//---------------------------------------------------------------------------- -//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -//**************************************************************************// - - -//*********************** Private methods **********************************// -//---------------------------------------------------------------------------- -//---------------------------------------------------------------------------- -//**************************************************************************// diff --git a/beamtime/cern2017/unpacker/StsXyterBetaMessage.h b/beamtime/cern2017/unpacker/StsXyterBetaMessage.h deleted file mode 100644 index abaf28f3dc6d8c08abb5b3e436b394f61544ad6b..0000000000000000000000000000000000000000 --- a/beamtime/cern2017/unpacker/StsXyterBetaMessage.h +++ /dev/null @@ -1,225 +0,0 @@ -/************************************************************ - * - ************************************************************/ - -#ifndef STSXYTERBETAMESSAGE_H -#define STSXYTERBETAMESSAGE_H - -// C/C++ headers -#include <stdint.h> -#include <iostream> - -namespace stsxyter { - -// tools: Use to this allow bitwise operations on C++11 enums -// This needs to be included in the same namespace to work... -#include "bitmask_operators.hpp" - - /// Constants and other auxiliary stuff - /// Field full info object - struct BetaMessField - { - uint16_t fusPos; //! Start bit index - uint16_t fusLen; //! Field length - - BetaMessField( uint16_t usPos, uint16_t usLen ) : - fusPos( usPos ), - fusLen( usLen ) - { }; - }; - /// Message types - enum class BetaMessType : uint16_t - { - Dummy, - Hit, - TsMsb - }; - /// Printout control - enum class BetaMessagePrintMask : uint16_t - { - msg_print_Prefix = (0x1 << 0), - msg_print_Data = (0x1 << 1), - msg_print_Hex = (0x1 << 2), - msg_print_Human = (0x1 << 3) - }; - ENABLE_BITMASK_OPERATORS( stsxyter::BetaMessagePrintMask ) // Preproc macro! - - /// Fields position (Start bit index) - static const uint16_t kusBetaPosNotHitFlag = 31; - static const uint16_t kusBetaPosLinkIndex = 22; - // Hit message - static const uint16_t kusBetaPosHitChannel = 15; - static const uint16_t kusBetaPosHitAdc = 10; - static const uint16_t kusBetaPosHitTsOver = 9; - static const uint16_t kusBetaPosHitTs = 1; - static const uint16_t kusBetaPosHitEmFlag = 0; - // Non-hit messages - static const uint16_t kusBetaPosTsMsbFlag = 22; - // TS_MSB message - static const uint16_t kusBetaPosTsMsbVal = 0; - - /// Fields length (bits) - static const uint16_t kusBetaLenNotHitFlag = 1; - static const uint16_t kusBetaLenLinkIndex = 9; - // Hit message - static const uint16_t kusBetaLenHitChannel = 7; - static const uint16_t kusBetaLenHitAdc = 5; - static const uint16_t kusBetaLenHitTsFull = 9; // Includes 1 bit overlap with TS message ? - static const uint16_t kusBetaLenHitTsOver = 1; // 2 bit overlap with TS message - static const uint16_t kusBetaLenHitTs = 8; - static const uint16_t kusBetaLenHitEmFlag = 1; - // Other message - static const uint16_t kusBetaLenTsMsbFlag = 1; - // TS_MSB message - static const uint16_t kusBetaLenTsMsbVal = 13; - - /// Fields Info - static const BetaMessField kBetaFieldLinkIndex( kusBetaPosLinkIndex, kusBetaLenLinkIndex ); - static const BetaMessField kBetaFieldNotHitFlag( kusBetaPosNotHitFlag, kusBetaLenNotHitFlag ); - // Hit message - static const BetaMessField kBetaFieldHitChannel( kusBetaPosHitChannel, kusBetaLenHitChannel ); - static const BetaMessField kBetaFieldHitAdc ( kusBetaPosHitAdc, kusBetaLenHitAdc ); - static const BetaMessField kBetaFieldHitTsFull ( kusBetaPosHitTs, kusBetaLenHitTsFull ); - static const BetaMessField kBetaFieldHitTsOver ( kusBetaPosHitTsOver, kusBetaLenHitTsOver ); - static const BetaMessField kBetaFieldHitTs ( kusBetaPosHitTs, kusBetaLenHitTs ); - static const BetaMessField kBetaFieldHitEmFlag ( kusBetaPosHitEmFlag, kusBetaLenHitEmFlag ); - // Non-hit messages - static const BetaMessField kBetaFieldTsMsbFlag ( kusBetaPosTsMsbFlag, kusBetaLenTsMsbFlag ); - // TS_MSB message - static const BetaMessField kBetaFieldTsMsbVal ( kusBetaPosTsMsbVal, kusBetaLenTsMsbVal ); - - /// Status/properties constants - static const uint32_t kuBetaHitNbAdcBins = 1 << kusBetaLenHitAdc; - static const uint32_t kuBetaHitNbTsBins = 1 << kusBetaLenHitTs; - static const uint32_t kuBetaHitNbOverBins = 1 << kusBetaLenHitTsOver; - static const uint32_t kuBetaTsMsbNbTsBins = 1 << kusBetaLenTsMsbVal; - static const uint32_t kuBetaTsCycleNbBins = kuBetaTsMsbNbTsBins * kuBetaHitNbTsBins; - static const uint16_t kusBetaInvalidTsMsb = kuBetaTsMsbNbTsBins; - static const uint16_t kusBetaMaskTsMsbOver = (1 << kusBetaLenHitTsOver) - 1; - static const double kdBetaClockCycleNs = 3.125; // ns, equivalent to 2*160 MHz clock - - class BetaMessage { - private: - - - protected: - uint32_t fuData; // main and only storage field for the message - - public: - BetaMessage() : fuData(0) {} - - BetaMessage(const BetaMessage& src) : fuData(src.fuData) {} - - BetaMessage( uint32_t uDataIn ) : fuData( uDataIn ) {} - - virtual ~BetaMessage() {}; - - void assign(const BetaMessage& src) { fuData = src.fuData; } - - BetaMessage& operator=(const BetaMessage& src) { assign(src); return *this; } - - inline void reset() { fuData = 0; } - - // --------------------------- Accessors --------------------------------- - inline uint32_t GetData() const { return fuData; } - inline void SetData( uint32_t uValue) { fuData = uValue; } - - inline uint32_t GetField(uint32_t uShift, uint32_t uLen) const - { return ( fuData >> uShift) & ( ( (static_cast<uint32_t>( 1 ) ) << uLen ) - 1); } - - inline uint8_t GetBit(uint32_t uShift) const - { return ( fuData >> uShift) & 1; } - - inline uint32_t GetFieldBE(uint32_t uShift, uint32_t uLen) const - { return ( DataBE() >> uShift ) & ( ( ( static_cast<uint32_t>( 1 ) ) << uLen ) - 1 ); } - inline uint8_t GetBitBE(uint32_t uShift) const - { return (DataBE() >> uShift) & 1; } - inline uint32_t DataBE() const - { return ( ( fuData & 0x000000FF ) << 24) + - ( ( fuData & 0x0000FF00 ) << 8) + - ( ( fuData >> 8) & 0x0000FF00 ) + - ( ( fuData >> 24) & 0x000000FF ); - } - - // --------------------------- Setters --------------------------------------- - inline void SetField(uint32_t uShift, uint32_t uLen, uint32_t uValue) - { fuData = ( fuData & ~( ( ( ( static_cast< uint32_t >( 1 ) ) << uLen) - 1) << uShift ) ) - | ( ( static_cast< uint64_t >( uValue ) ) << uShift ); } - - inline void SetBit(uint32_t uShift, uint8_t uValue) - { fuData = uValue ? ( fuData | ( ( static_cast< uint32_t >( 1 ) ) << uShift ) ) : - ( fuData & ~( ( static_cast< uint32_t >( 1 ) ) << uShift ) ) ; } - - // --------------------------- Simplified Acc_or/Setters --------------------- - inline uint32_t GetField( BetaMessField field ) const { return GetField( field.fusPos, field.fusLen ); } - inline uint8_t GetBit( BetaMessField field ) const { return GetBit( field.fusPos ); } - inline bool GetFlag( BetaMessField field ) const { return ( 1 == GetBit( field.fusPos ) ); } - inline uint32_t GetFieldBE( BetaMessField field ) const { return GetFieldBE( field.fusPos, field.fusLen ); } - inline uint8_t GetBitBE( BetaMessField field ) const { return GetBitBE( field.fusPos ); } - - inline void SetField( BetaMessField field, uint32_t uValue ) { SetField( field.fusPos, field.fusLen, uValue ); } - inline void SetBit( BetaMessField field, uint8_t ucValue ) { SetBit( field.fusPos, ucValue ); } - - // --------------------------- common fields --------------------------------- - //! For all data: Returns the (global) index of the eLink on which the message was received (n bit field) - inline uint16_t GetLinkIndex() const { return GetField( kBetaFieldLinkIndex ); } - //! Check if the message if a Hit Message - inline bool IsHit() const { return !GetFlag( kBetaFieldNotHitFlag ); } - //! Check if the message if a Dummy Hit Message - inline bool IsDummy() const { return IsHit() && ( 0 == GetHitAdc() ); } - //! Check if the message if a Ts_Msb - inline bool IsTsMsb() const { return (!IsHit() ); } - //! Returns the message type, see enum BetaMessType - inline BetaMessType GetMessType() const { return !GetFlag( kBetaFieldNotHitFlag ) ? ( 0 == GetHitAdc() ? BetaMessType::Dummy : - BetaMessType::Hit ) : - BetaMessType::TsMsb; } - - // ------------------------ Hit message fields ------------------------------- - //! For Hit data: Returns StsXYTER channel number (7 bit field) - inline uint16_t GetHitChannel() const { return GetField( kBetaFieldHitChannel ); } - - //! For Hit data: Returns ADC value (5 bit field) - inline uint16_t GetHitAdc() const { return GetField( kBetaFieldHitAdc ); } - - //! For Hit data: Returns Full timestamp (10 bit field including 2 bits overlap) - inline uint16_t GetHitTimeFull() const { return GetField( kBetaFieldHitTsFull ); } - - //! For Hit data: Returns timestamp overlap bits (2 bits field, overlap with 2 LSBs of TS_MSB message) - inline uint16_t GetHitTimeOver() const { return GetField( kBetaFieldHitTsOver ); } - - //! For Hit data: Returns timestamp (8 bit field, 2 MSB bits overlap removed) - inline uint16_t GetHitTime() const { return GetField( kBetaFieldHitTs ); } - - //! For Hit data: Returns Missed event flag (1 bit field) - inline bool IsHitMissedEvts() const { return GetFlag( kBetaFieldHitEmFlag ); } - - //! For Hit data: Sets StsXYTER channel number (7 bit field) - inline void SetHitChannel( uint16_t usVal ) { SetField( kBetaFieldHitChannel, usVal ); } - - //! For Hit data: Sets ADC value (5 bit field) - inline void SetHitAdc( uint16_t usVal ) { SetField( kBetaFieldHitAdc, usVal ); } - - //! For Hit data: Sets Full timestamp (10 bit field including 2 bits overlap) - inline void SetHitTimeFull( uint16_t usVal ) { SetField( kBetaFieldHitTsFull, usVal ); } - - //! For Hit data: Sets timestamp overlap bits (2 bits field, overlap with 2 LSBs of TS_MSB message) - inline void SetHitTimeOver( uint16_t usVal ) { SetField( kBetaFieldHitTsOver, usVal ); } - - //! For Hit data: Sets Full timestamp (8 bit field, 2 MSB bits overlap removed) - inline void SetHitTime( uint16_t usVal ) { SetField( kBetaFieldHitTs, usVal ); } - - //! For Hit data: Sets Missed event flag (1 bit field) - inline void SetHitMissEvtsFlag( bool bVal) { SetBit( kBetaFieldHitEmFlag, bVal ); } - - // ------------------------ TS_MSB message fields ---------------------------- - //! For TS MSB data: Returns the TS MSB 13 bit field) - inline uint16_t GetTsMsbVal() const { return GetField( kBetaFieldTsMsbVal ); } - - //! For TS MSB data: Sets the TS MSB (13 bit field) - inline void SetTsMsbVal( uint16_t usVal ) { SetField( kBetaFieldTsMsbVal, usVal ); } - - // ------------------------ General OP --------------------------------------- - bool PrintMess( std::ostream& os, BetaMessagePrintMask ctrl = BetaMessagePrintMask::msg_print_Human ) const; - }; -} -#endif // STSXYTERBETAMESSAGE_H diff --git a/beamtime/cern2017/unpacker/StsXyterRawMessage.cxx b/beamtime/cern2017/unpacker/StsXyterRawMessage.cxx deleted file mode 100644 index a1205fd67dc8f9eb80129b74aa778392f56c018b..0000000000000000000000000000000000000000 --- a/beamtime/cern2017/unpacker/StsXyterRawMessage.cxx +++ /dev/null @@ -1,529 +0,0 @@ - -#include "StsXyterRawMessage.h" - -// tools -#ifndef USE_VHDL_CRC - #define CRCPP_USE_NAMESPACE - #define CRCPP_USE_CPP11 - #include "CRCpp_CRC.h" -#endif // not USE_VHDL_CRC - -// C++11 - -// C/C++ -#include <iomanip> -#include <vector> - -// Namespace -using namespace stsxyter; // Class own namespace -// Namespaces alias -//namespace sxm = stsxyter::RawMessage; - -/* -static const uint16_t kusCrcTable3_x5[ 256 ] = - { - 0x7, 0x4, 0x1, 0x2, 0x0, 0x3, 0x6, 0x5, - 0x2, 0x1, 0x4, 0x7, 0x5, 0x6, 0x3, 0x0, - 0x6, 0x5, 0x0, 0x3, 0x1, 0x2, 0x7, 0x4, - 0x3, 0x0, 0x5, 0x6, 0x4, 0x7, 0x2, 0x1, - 0x5, 0x6, 0x3, 0x0, 0x2, 0x1, 0x4, 0x7, - 0x0, 0x3, 0x6, 0x5, 0x7, 0x4, 0x1, 0x2, - 0x4, 0x7, 0x2, 0x1, 0x3, 0x0, 0x5, 0x6, - 0x1, 0x2, 0x7, 0x4, 0x6, 0x5, 0x0, 0x3, - 0x3, 0x0, 0x5, 0x6, 0x4, 0x7, 0x2, 0x1, - 0x6, 0x5, 0x0, 0x3, 0x1, 0x2, 0x7, 0x4, - 0x2, 0x1, 0x4, 0x7, 0x5, 0x6, 0x3, 0x0, - 0x7, 0x4, 0x1, 0x2, 0x0, 0x3, 0x6, 0x5, - 0x1, 0x2, 0x7, 0x4, 0x6, 0x5, 0x0, 0x3, - 0x4, 0x7, 0x2, 0x1, 0x3, 0x0, 0x5, 0x6, - 0x0, 0x3, 0x6, 0x5, 0x7, 0x4, 0x1, 0x2, - 0x5, 0x6, 0x3, 0x0, 0x2, 0x1, 0x4, 0x7, - 0x4, 0x7, 0x2, 0x1, 0x3, 0x0, 0x5, 0x6, - 0x1, 0x2, 0x7, 0x4, 0x6, 0x5, 0x0, 0x3, - 0x5, 0x6, 0x3, 0x0, 0x2, 0x1, 0x4, 0x7, - 0x0, 0x3, 0x6, 0x5, 0x7, 0x4, 0x1, 0x2, - 0x6, 0x5, 0x0, 0x3, 0x1, 0x2, 0x7, 0x4, - 0x3, 0x0, 0x5, 0x6, 0x4, 0x7, 0x2, 0x1, - 0x7, 0x4, 0x1, 0x2, 0x0, 0x3, 0x6, 0x5, - 0x2, 0x1, 0x4, 0x7, 0x5, 0x6, 0x3, 0x0, - 0x0, 0x3, 0x6, 0x5, 0x7, 0x4, 0x1, 0x2, - 0x5, 0x6, 0x3, 0x0, 0x2, 0x1, 0x4, 0x7, - 0x1, 0x2, 0x7, 0x4, 0x6, 0x5, 0x0, 0x3, - 0x4, 0x7, 0x2, 0x1, 0x3, 0x0, 0x5, 0x6, - 0x2, 0x1, 0x4, 0x7, 0x5, 0x6, 0x3, 0x0, - 0x7, 0x4, 0x1, 0x2, 0x0, 0x3, 0x6, 0x5, - 0x3, 0x0, 0x5, 0x6, 0x4, 0x7, 0x2, 0x1, - 0x6, 0x5, 0x0, 0x3, 0x1, 0x2, 0x7, 0x4 - }; -static const uint16_t kusCrcTable4_x9[ 256 ] = - { - 0x4, 0x7, 0x2, 0x1, 0x8, 0xb, 0xe, 0xd, - 0xf, 0xc, 0x9, 0xa, 0x3, 0x0, 0x5, 0x6, - 0x1, 0x2, 0x7, 0x4, 0xd, 0xe, 0xb, 0x8, - 0xa, 0x9, 0xc, 0xf, 0x6, 0x5, 0x0, 0x3, - 0xe, 0xd, 0x8, 0xb, 0x2, 0x1, 0x4, 0x7, - 0x5, 0x6, 0x3, 0x0, 0x9, 0xa, 0xf, 0xc, - 0xb, 0x8, 0xd, 0xe, 0x7, 0x4, 0x1, 0x2, - 0x0, 0x3, 0x6, 0x5, 0xc, 0xf, 0xa, 0x9, - 0x3, 0x0, 0x5, 0x6, 0xf, 0xc, 0x9, 0xa, - 0x8, 0xb, 0xe, 0xd, 0x4, 0x7, 0x2, 0x1, - 0x6, 0x5, 0x0, 0x3, 0xa, 0x9, 0xc, 0xf, - 0xd, 0xe, 0xb, 0x8, 0x1, 0x2, 0x7, 0x4, - 0x9, 0xa, 0xf, 0xc, 0x5, 0x6, 0x3, 0x0, - 0x2, 0x1, 0x4, 0x7, 0xe, 0xd, 0x8, 0xb, - 0xc, 0xf, 0xa, 0x9, 0x0, 0x3, 0x6, 0x5, - 0x7, 0x4, 0x1, 0x2, 0xb, 0x8, 0xd, 0xe, - 0xa, 0x9, 0xc, 0xf, 0x6, 0x5, 0x0, 0x3, - 0x1, 0x2, 0x7, 0x4, 0xd, 0xe, 0xb, 0x8, - 0xf, 0xc, 0x9, 0xa, 0x3, 0x0, 0x5, 0x6, - 0x4, 0x7, 0x2, 0x1, 0x8, 0xb, 0xe, 0xd, - 0x0, 0x3, 0x6, 0x5, 0xc, 0xf, 0xa, 0x9, - 0xb, 0x8, 0xd, 0xe, 0x7, 0x4, 0x1, 0x2, - 0x5, 0x6, 0x3, 0x0, 0x9, 0xa, 0xf, 0xc, - 0xe, 0xd, 0x8, 0xb, 0x2, 0x1, 0x4, 0x7, - 0xd, 0xe, 0xb, 0x8, 0x1, 0x2, 0x7, 0x4, - 0x6, 0x5, 0x0, 0x3, 0xa, 0x9, 0xc, 0xf, - 0x8, 0xb, 0xe, 0xd, 0x4, 0x7, 0x2, 0x1, - 0x3, 0x0, 0x5, 0x6, 0xf, 0xc, 0x9, 0xa, - 0x7, 0x4, 0x1, 0x2, 0xb, 0x8, 0xd, 0xe, - 0xc, 0xf, 0xa, 0x9, 0x0, 0x3, 0x6, 0x5, - 0x2, 0x1, 0x4, 0x7, 0xe, 0xd, 0x8, 0xb, - 0x9, 0xa, 0xf, 0xc, 0x5, 0x6, 0x3, 0x0 - } -*/ - -#ifndef USE_VHDL_CRC -// CRC constants, hopefully computed at compile/initialization time -///< CRC polynomial, 0x5 = 101 (Koopman) => 1011 = 0x0B (full) => 011 = 0x03 (Here) -static const CRCPP::CRC::Parameters< std::uint8_t, 3 > par_crc3_5 = { 0x03, 0x01, 0x01, true, true }; -static const CRCPP::CRC::Table< std::uint8_t, 3 > table_crc3_5( par_crc3_5 ); -///< CRC polynomial, 0x9 = 1001 (Koopman) => 10011 = 0x13 (full) => 0011 = 0x03 (Here) -static const CRCPP::CRC::Parameters< std::uint8_t, 4 > par_crc4_9 = { 0x03, 0x00, 0x00, true, true }; -static const CRCPP::CRC::Table< std::uint8_t, 4 > table_crc4_9( par_crc4_9 ); -#endif // not USE_VHDL_CRC - -//************************* Messages OP ************************************// -//+++++++++++++++++++++++++ Hit message OP +++++++++++++++++++++++++++++++++++ -//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -//+++++++++++++++++++++++++ TS_MSB message OP ++++++++++++++++++++++++++++++++ -//---------------------------------------------------------------------------- -uint16_t RawMessage::TsMsbCrcCalc() const -{ -#ifdef USE_VHDL_CRC - return VhdlCalcCrc4Pol9Len20( GetTsMsbCrcInput() ); -#else - return CalcCrc4Pol9Len20( GetTsMsbCrcInput() ); -#endif //USE_VHDL_CRC -} -//---------------------------------------------------------------------------- -bool RawMessage::TsMsbCrcCheck() const -{ - return ( TsMsbCrcCalc() == GetTsMsbCrc() ); -} -//---------------------------------------------------------------------------- -bool RawMessage::TsMsbTsCheck() const -{ - uint16_t uValA = GetTsMsbValA(); - return ( TsMsbCrcCheck() && - ( GetTsMsbValB() == uValA ) && - ( GetTsMsbValC() == uValA ) ); -} -//---------------------------------------------------------------------------- -uint16_t RawMessage::GetTsMsbMajCnt() const -{ - uint16_t uValA = GetTsMsbValA(); - uint16_t uValB = GetTsMsbValB(); - uint16_t uValC = GetTsMsbValC(); - - uint16_t uMajCnt = 1; // 0 pair => 1 agreeing value (each with itself) - if( uValA == uValB ) - uMajCnt ++; - if( uValA == uValC ) - uMajCnt ++; - else if( uValB == uValC ) - uMajCnt ++; - - return uMajCnt; -} -//---------------------------------------------------------------------------- -bool RawMessage::GetTsMsbValCorr( uint16_t & uVal ) const -{ - uint16_t uValA = GetTsMsbValA(); - - // Check if TS integrity ok - // if yes just give first copy of it and return true - if( TsMsbTsCheck() ) - { - uVal = uValA; - return true; - } // if( TsMsbTsCheck() ) - - uint16_t uValB = GetTsMsbValB(); - - // Majority decision: - // - if any two values are same, give it as 3rd one either minority or same - // - if no two value identical, give invalid TS bigger than allowed - if( uValA == uValB ) - uVal = uValA; - else - { - uint16_t uValC = GetTsMsbValC(); - if( uValA == uValC ) - uVal = uValA; - else if( uValB == uValC ) - uVal = uValB; - else uVal = kusRawInvalidTsMsb; - } // else of if( uValA == uValB ) - - return false; -} -//---------------------------------------------------------------------------- -//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -//+++++++++++++++++++++++++ Read Data Ack message OP +++++++++++++++++++++++++ -//---------------------------------------------------------------------------- -uint16_t RawMessage::RdDataCrcCalc() const -{ -#ifdef USE_VHDL_CRC - return VhdlCalcCrc3Pol5Len21( GetRdDataCrcInput() ); -#else - return CalcCrc3Pol5Len21( GetRdDataCrcInput() ); -#endif //USE_VHDL_CRC -} -//---------------------------------------------------------------------------- -bool RawMessage::RdDataCrcCheck() const -{ - return ( RdDataCrcCalc() == GetRdDataCrc() ); -} -//---------------------------------------------------------------------------- -//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -//+++++++++++++++++++++++++ Ack message OP +++++++++++++++++++++++++++++++++++ -//---------------------------------------------------------------------------- -uint16_t RawMessage::AckCrcCalc() const -{ -#ifdef USE_VHDL_CRC - return VhdlCalcCrc4Pol9Len20( GetAckCrcInput() ); -#else - return CalcCrc4Pol9Len20( GetAckCrcInput() ); -#endif //USE_VHDL_CRC -} -//---------------------------------------------------------------------------- -bool RawMessage::AckCrcCheck() const -{ - return ( AckCrcCalc() == GetAckCrc() ); -} -//---------------------------------------------------------------------------- -//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -//+++++++++++++++++++++++++ Ack message OP +++++++++++++++++++++++++++++++++++ -//---------------------------------------------------------------------------- -bool RawMessage::PrintMess(std::ostream& os, RawMessagePrintMask ctrl ) const -{ - bool bPrintHex = static_cast< bool >(ctrl & RawMessagePrintMask::msg_print_Hex); - bool bPrintCrc = static_cast< bool >(ctrl & RawMessagePrintMask::msg_print_Crc); - bool bPrintHuman = static_cast< bool >(ctrl & RawMessagePrintMask::msg_print_Human); - bool bPrintPrefix = static_cast< bool >(ctrl & RawMessagePrintMask::msg_print_Prefix); - bool bPrintData = static_cast< bool >(ctrl & RawMessagePrintMask::msg_print_Data); - - - if( bPrintHex ) - { - const uint8_t* cArrByt = reinterpret_cast<const uint8_t*> ( &fuData ); - - // Set fill char to 0 and read previous state - char cPrev = os.fill( '0' ); - os << "BE = " << std::hex - << std::setw(2) << static_cast< uint16_t >( cArrByt[0] ) << ":" - << std::setw(2) << static_cast< uint16_t >( cArrByt[1] ) << ":" - << std::setw(2) << static_cast< uint16_t >( cArrByt[2] ) << ":" - << std::setw(2) << static_cast< uint16_t >( cArrByt[3] ) - << " LE = " << std::hex - << std::setw(2) << static_cast< uint16_t >( cArrByt[3] ) << ":" - << std::setw(2) << static_cast< uint16_t >( cArrByt[2] ) << ":" - << std::setw(2) << static_cast< uint16_t >( cArrByt[1] ) << ":" - << std::setw(2) << static_cast< uint16_t >( cArrByt[0] ) - << std::dec << " => "; - - // Restore fill char to original - os.fill( cPrev ); - } // if( ctrl & msg_print_Hex ) - - /// Print Link index - os << " Lnk: " << std::setw( 3 ) << GetLinkIndex(); - - /// CRC debugging - if( bPrintCrc ) - { - switch( GetRawMessType() ) - { - case RawMessType::Hit : - { - // No CRC => Nothing to check - os << " -A- Hit " - << " "; - break; - } // case RawMessType::Hit - case RawMessType::TsMsb : - { - uint16_t usMessCrc = GetTsMsbCrc(); - uint16_t usCrcCal = TsMsbCrcCalc(); - bool bCrcCheck = TsMsbCrcCheck(); - - os << " -B- TS MSB CRC: " << std::setw(2) << usMessCrc - << " Calc: " << std::setw(2) << usCrcCal - << " check: " << bCrcCheck - << " Input: " << std::hex << std::setw(6) - << GetTsMsbCrcInput() - << std::dec; - - break; - } // case RawMessType::TsMsb - case RawMessType::ReadDataAck : - { - uint16_t usMessCrc = GetRdDataCrc(); - uint16_t usCrcCal = RdDataCrcCalc(); - bool bCrcCheck = RdDataCrcCheck(); - - os << " -C- Read Data ACK CRC: " << std::setw(2) << usMessCrc - << " Calc: " << std::setw(2) << usCrcCal - << " check: " << bCrcCheck - << " Input: " << std::hex << std::setw(6) - << GetRdDataCrcInput() - << std::dec; - break; - } // case RawMessType::ReadDataAck - case RawMessType::Ack : - { - uint16_t usMessCrc = GetAckCrc(); - uint16_t usCrcCal = AckCrcCalc(); - bool bCrcCheck = AckCrcCheck(); - - os << " -D- ACK CRC: " << std::setw(2) << usMessCrc - << " Calc: " << std::setw(2) << usCrcCal - << " check: " << bCrcCheck - << " Input: " << std::hex << std::setw(6) - << GetAckCrcInput() - << std::dec; - break; - } // case RawMessType::Ack - default: - { - } // default - } // switch( GetRawMessType() ) - } // if( bPrintCrc ) - - if( bPrintHuman ) - { - switch( GetRawMessType() ) - { - case RawMessType::Hit : - { - std::cout << " Ch: " << std::setw(3) << GetHitChannel() - << " Adc: " << std::setw(2) << GetHitAdc() - << " Ts Full: " << std::setw(4) << GetHitTimeFull() - << " Ts Over: " << std::hex << GetHitTimeOver() << std::dec - << " Ts: " << std::setw(3) << GetHitTime() - << " Missed? " << IsHitMissedEvts(); - break; - } // case RawMessType::Hit - case RawMessType::TsMsb : - { - std::cout << " TS A: " << std::setw(2) << GetTsMsbValA() - << " (Over= " << std::hex << (GetTsMsbValA() & 0x3) << std::dec << ")" - << " TS B: " << std::setw(2) << GetTsMsbValB() - << " (Over= " << std::hex << (GetTsMsbValB() & 0x3) << std::dec << ")" - << " TS C: " << std::setw(2) << GetTsMsbValC() - << " (Over= " << std::hex << (GetTsMsbValC() & 0x3) << std::dec << ")"; - break; - } // case RawMessType::TsMsb - case RawMessType::ReadDataAck : - { - break; - } // case RawMessType::ReadDataAck - case RawMessType::Ack : - { - break; - } // case RawMessType::Ack - default: - { - } // default - } // switch( GetRawMessType() ) - } // if( bPrintHuman ) - - if( bPrintPrefix ) - { - switch( GetRawMessType() ) - { - case RawMessType::Hit : - { - break; - } // case RawMessType::Hit - case RawMessType::TsMsb : - { - break; - } // case RawMessType::TsMsb - case RawMessType::ReadDataAck : - { - break; - } // case RawMessType::ReadDataAck - case RawMessType::Ack : - { - break; - } // case RawMessType::Ack - default: - { - } // default - } // switch( GetRawMessType() ) - } // if( bPrintPrefix ) - - if( bPrintData ) - { - switch( GetRawMessType() ) - { - case RawMessType::Hit : - { - break; - } // case RawMessType::Hit - case RawMessType::TsMsb : - { - break; - } // case RawMessType::TsMsb - case RawMessType::ReadDataAck : - { - break; - } // case RawMessType::ReadDataAck - case RawMessType::Ack : - { - break; - } // case RawMessType::Ack - default: - { - } // default - } // switch( GetRawMessType() ) - } // if( bPrintData ) - - // Finish with a new line => 1 line per message printout - os << std::endl; - - return true; -} -//---------------------------------------------------------------------------- -//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -//**************************************************************************// - - -//*********************** Private methods **********************************// -//---------------------------------------------------------------------------- -#ifndef USE_VHDL_CRC -uint16_t RawMessage::CalcCrc3Pol5Len21( uint32_t uVal ) const -{ - uint32_t uValMask = uVal & ( (1 << 21) - 1 ); - return CRCPP::CRC::Calculate( &uValMask, sizeof(uValMask), table_crc3_5); -} -//---------------------------------------------------------------------------- -uint16_t RawMessage::CalcCrc4Pol9Len20( uint32_t uVal ) const -{ - uint32_t uValMask = uVal & ( (1 << 20) - 1 ); - return CRCPP::CRC::Calculate( &uValMask, sizeof(uValMask), table_crc4_9); -} -#endif // not USE_VHDL_CRC -//---------------------------------------------------------------------------- -uint16_t RawMessage::VhdlCalcCrc3Pol5Len21( uint32_t uVal ) const -{ -/* - function crc3_d21 ( - constant data_in : std_logic_vector(20 downto 0); - constant crc_in : std_logic_vector(2 downto 0)) - return std_logic_vector is - - variable lfsr_q : std_logic_vector(2 downto 0); - variable lfsr_c : std_logic_vector(2 downto 0); - - begin -- function crc3_d21 - - lfsr_q := crc_in; - lfsr_c(0) := lfsr_q(0) xor data_in(0) xor data_in(2) xor data_in(3) xor data_in(4) xor data_in(7) xor data_in(9) xor data_in(10) xor data_in(11) xor data_in(14) xor data_in(16) xor data_in(17) xor data_in(18); - lfsr_c(1) := lfsr_q(1) xor data_in(0) xor data_in(1) xor data_in(2) xor data_in(5) xor data_in(7) xor data_in(8) xor data_in(9) xor data_in(12) xor data_in(14) xor data_in(15) xor data_in(16) xor data_in(19); - lfsr_c(2) := lfsr_q(2) xor data_in(1) xor data_in(2) xor data_in(3) xor data_in(6) xor data_in(8) xor data_in(9) xor data_in(10) xor data_in(13) xor data_in(15) xor data_in(16) xor data_in(17) xor data_in(20); - return lfsr_c; - end function crc3_d21; -*/ - uint16_t usCrcInit = 0x07; - - const uint16_t usNbBitsCrc = 3; - const uint16_t usNbBitsVal = 21; - std::vector< bool > vbCrcInit( usNbBitsCrc, false); - std::vector< bool > vbVal( usNbBitsVal, false); - std::vector< bool > vbCrc( usNbBitsCrc, false); - - for( uint16_t uBit = 0; uBit < usNbBitsCrc; uBit ++) - { - vbCrcInit[ uBit ] = ( usCrcInit >> uBit ) & 0x1; - vbCrc[ uBit ] = false; - } // for( uint16_t uBit = 0, uBit < usNbBitsCrc; uBit ++) - - for( uint16_t uBit = 0; uBit < usNbBitsVal; uBit ++) - vbVal[ uBit ] = ( uVal >> uBit ) & 0x1; - - vbCrc[ 0 ] = vbCrcInit[ 0 ] ^ vbVal[ 0 ] ^ vbVal[ 2 ] ^ vbVal[ 3 ] ^ vbVal[ 4 ] ^ vbVal[ 7 ] ^ vbVal[ 9 ] ^ vbVal[ 10 ] ^ vbVal[ 11 ] ^ vbVal[ 14 ] ^ vbVal[ 16 ] ^ vbVal[ 17 ] ^ vbVal[ 18 ]; - vbCrc[ 1 ] = vbCrcInit[ 1 ] ^ vbVal[ 0 ] ^ vbVal[ 1 ] ^ vbVal[ 2 ] ^ vbVal[ 5 ] ^ vbVal[ 7 ] ^ vbVal[ 8 ] ^ vbVal[ 9 ] ^ vbVal[ 12 ] ^ vbVal[ 14 ] ^ vbVal[ 15 ] ^ vbVal[ 16 ] ^ vbVal[ 19 ]; - vbCrc[ 2 ] = vbCrcInit[ 2 ] ^ vbVal[ 1 ] ^ vbVal[ 2 ] ^ vbVal[ 3 ] ^ vbVal[ 6 ] ^ vbVal[ 8 ] ^ vbVal[ 9 ] ^ vbVal[ 10 ] ^ vbVal[ 13 ] ^ vbVal[ 15 ] ^ vbVal[ 16 ] ^ vbVal[ 17 ] ^ vbVal[ 20 ]; - - uint16_t usCrc = 0x00; - for( uint16_t uBit = 0; uBit < usNbBitsCrc; uBit ++) - usCrc += ( vbCrc[ uBit ] ? ( 0x1 << uBit ) : 0 ); - - return usCrc; -} -//---------------------------------------------------------------------------- -uint16_t RawMessage::VhdlCalcCrc4Pol9Len20( uint32_t uVal ) const -{ -/* - function crc4_d20 ( - constant data_in : std_logic_vector(19 downto 0); - constant crc_in : std_logic_vector(3 downto 0)) - return std_logic_vector is - - variable lfsr_q : std_logic_vector(3 downto 0); - variable lfsr_c : std_logic_vector(3 downto 0); - - begin -- function crc16_d24 - - lfsr_q := crc_in; - - lfsr_c(0) := lfsr_q(2) xor lfsr_q(3) xor data_in(0) xor data_in(3) xor data_in(4) xor data_in(6) xor data_in(8) xor data_in(9) xor data_in(10) xor data_in(11) xor data_in(15) xor data_in(18) xor data_in(19); - lfsr_c(1) := lfsr_q(0) xor lfsr_q(2) xor data_in(0) xor data_in(1) xor data_in(3) xor data_in(5) xor data_in(6) xor data_in(7) xor data_in(8) xor data_in(12) xor data_in(15) xor data_in(16) xor data_in(18); - lfsr_c(2) := lfsr_q(0) xor lfsr_q(1) xor lfsr_q(3) xor data_in(1) xor data_in(2) xor data_in(4) xor data_in(6) xor data_in(7) xor data_in(8) xor data_in(9) xor data_in(13) xor data_in(16) xor data_in(17) xor data_in(19); - lfsr_c(3) := lfsr_q(1) xor lfsr_q(2) xor data_in(2) xor data_in(3) xor data_in(5) xor data_in(7) xor data_in(8) xor data_in(9) xor data_in(10) xor data_in(14) xor data_in(17) xor data_in(18); - - return lfsr_c; - end function crc4_d20; -*/ - uint16_t usCrcInit = 0x0F; - - const uint16_t usNbBitsCrc = 4; - const uint16_t usNbBitsVal = 20; - std::vector< bool > vbCrcInit( usNbBitsCrc, false); - std::vector< bool > vbVal( usNbBitsVal, false); - std::vector< bool > vbCrc( usNbBitsCrc, false); - - for( uint16_t uBit = 0; uBit < usNbBitsCrc; uBit ++) - { - vbCrcInit[ uBit ] = ( usCrcInit >> uBit ) & 0x1; - vbCrc[ uBit ] = false; - } // for( uint16_t uBit = 0, uBit < usNbBitsCrc; uBit ++) - - for( uint16_t uBit = 0; uBit < usNbBitsVal; uBit ++) - vbVal[ uBit ] = ( uVal >> uBit ) & 0x1; - - vbCrc[ 0 ] = vbCrcInit[ 2 ] ^ vbCrcInit[ 3 ] ^ vbVal[ 0 ] ^ vbVal[ 3 ] ^ vbVal[ 4 ] ^ vbVal[ 6 ] ^ vbVal[ 8 ] ^ vbVal[ 9 ] ^ vbVal[ 10 ] ^ vbVal[ 11 ] ^ vbVal[ 15 ] ^ vbVal[ 18 ] ^ vbVal[ 19 ]; - vbCrc[ 1 ] = vbCrcInit[ 0 ] ^ vbCrcInit[ 2 ] ^ vbVal[ 0 ] ^ vbVal[ 1 ] ^ vbVal[ 3 ] ^ vbVal[ 5 ] ^ vbVal[ 6 ] ^ vbVal[ 7 ] ^ vbVal[ 8 ] ^ vbVal[ 12 ] ^ vbVal[ 15 ] ^ vbVal[ 16 ] ^ vbVal[ 18 ]; - vbCrc[ 2 ] = vbCrcInit[ 0 ] ^ vbCrcInit[ 1 ] ^ vbCrcInit[ 3 ] ^ vbVal[ 1 ] ^ vbVal[ 2 ] ^ vbVal[ 4 ] ^ vbVal[ 6 ] ^ vbVal[ 7 ] ^ vbVal[ 8 ] ^ vbVal[ 9 ] ^ vbVal[ 13 ] ^ vbVal[ 16 ] ^ vbVal[ 17 ] ^ vbVal[ 19 ]; - vbCrc[ 3 ] = vbCrcInit[ 1 ] ^ vbCrcInit[ 2 ] ^ vbVal[ 2 ] ^ vbVal[ 3 ] ^ vbVal[ 5 ] ^ vbVal[ 7 ] ^ vbVal[ 8 ] ^ vbVal[ 9 ] ^ vbVal[ 10 ] ^ vbVal[ 14 ] ^ vbVal[ 17 ] ^ vbVal[ 18 ]; - - uint16_t usCrc = 0x00; - for( uint16_t uBit = 0; uBit < usNbBitsCrc; uBit ++) - usCrc += ( vbCrc[ uBit ] ? ( 0x1 << uBit ) : 0 ); - - return usCrc; -} -//---------------------------------------------------------------------------- -//**************************************************************************// diff --git a/beamtime/cern2017/unpacker/StsXyterRawMessage.h b/beamtime/cern2017/unpacker/StsXyterRawMessage.h deleted file mode 100644 index e58ed7f540e0d2dfb25772024f97291c6704e30d..0000000000000000000000000000000000000000 --- a/beamtime/cern2017/unpacker/StsXyterRawMessage.h +++ /dev/null @@ -1,378 +0,0 @@ -/************************************************************ - * - ************************************************************/ - -#ifndef STSXYTERRAWMESSAGE_H -#define STSXYTERRAWMESSAGE_H - -// C/C++ headers -#include <stdint.h> -#include <iostream> - -// Switch to VHDL-like bitwise CRC if defined -// CrcCpp implementation otherwise -#define USE_VHDL_CRC - -namespace stsxyter { - -// tools: Use to this allow bitwise operations on C++11 enums -// This needs to be included in the same namespace to work... -#include "bitmask_operators.hpp" - - /// Constants and other auxiliary stuff - /// Field full info object - struct RawMessField - { - uint16_t fusPos; //! Start bit index - uint16_t fusLen; //! Field length - - RawMessField( uint16_t usPos, uint16_t usLen ) : - fusPos( usPos ), - fusLen( usLen ) - { }; - }; - /// Raw Message types - enum class RawMessType : uint16_t - { - Dummy, - Hit, - TsMsb, - ReadDataAck, - Ack - }; - /// Printout control - enum class RawMessagePrintMask : uint16_t - { - msg_print_Prefix = (0x1 << 0), - msg_print_Data = (0x1 << 1), - msg_print_Hex = (0x1 << 2), - msg_print_Human = (0x1 << 3), - msg_print_Crc = (0x1 << 4) - }; - ENABLE_BITMASK_OPERATORS( stsxyter::RawMessagePrintMask ) // Preproc macro! - - /// Fields position (Start bit index) - static const uint16_t kusRawPosLinkIndex = 24; - static const uint16_t kusRawPosNotHitFlag = 23; - // Hit message - static const uint16_t kusRawPosHitChannel = 16; - static const uint16_t kusRawPosHitAdc = 11; - static const uint16_t kusRawPosHitTsOver = 9; - static const uint16_t kusRawPosHitTs = 1; - static const uint16_t kusRawPosHitEmFlag = 0; - // Non-hit messages - static const uint16_t kusRawPosTsMsbFlag = 22; - // TS_MSB message - static const uint16_t kusRawPosTsMsbValA = 16; - static const uint16_t kusRawPosTsMsbValB = 10; - static const uint16_t kusRawPosTsMsbValC = 4; - static const uint16_t kusRawPosTsMsbCrc = 0; - // Control messages - static const uint16_t kusRawPosRdDataFlag = 21; - // Read Data Ack message - static const uint16_t kusRawPosRdDataVal = 6; - static const uint16_t kusRawPosRdDataSeqN = 3; - static const uint16_t kusRawPosRdDataCrc = 0; - // Ack messages - static const uint16_t kusRawPosAckValAck = 19; - static const uint16_t kusRawPosAckSeqNb = 15; - static const uint16_t kusRawPosAckCpFlag = 14; - static const uint16_t kusRawPosAckStatus = 10; - static const uint16_t kusRawPosAckTime = 4; - static const uint16_t kusRawPosAckCrc = 0; - - /// Fields length (bits) - static const uint16_t kusRawLenLinkIndex = 8; - static const uint16_t kusRawLenRawMess = 24; - static const uint16_t kusRawLenNotHitFlag = 1; - // Hit message - static const uint16_t kusRawLenHitChannel = 7; - static const uint16_t kusRawLenHitAdc = 5; - static const uint16_t kusRawLenHitTsFull = 10; // Includes 2 bit overlap with TS message - static const uint16_t kusRawLenHitTsOver = 2; // 2 bit overlap with TS message - static const uint16_t kusRawLenHitTs = 8; - static const uint16_t kusRawLenHitEmFlag = 1; - // Other message - static const uint16_t kusRawLenTsMsbFlag = 1; - // TS_MSB message - static const uint16_t kusRawLenTsMsbValA = 6; - static const uint16_t kusRawLenTsMsbValB = 6; - static const uint16_t kusRawLenTsMsbValC = 6; - static const uint16_t kusRawLenTsMsbCrc = 4; - // Control messages - static const uint16_t kusRawLenRdDataFlag = 1; - // Read Data Ack message - static const uint16_t kusRawLenRdDataVal = 15; - static const uint16_t kusRawLenRdDataSeqN = 3; - static const uint16_t kusRawLenRdDataCrc = 3; - // Ack messages - static const uint16_t kusRawLenAckValAck = 2; - static const uint16_t kusRawLenAckSeqNb = 4; - static const uint16_t kusRawLenAckCpFlag = 1; - static const uint16_t kusRawLenAckStatus = 4; - static const uint16_t kusRawLenAckTime = 6; - static const uint16_t kusRawLenAckCrc = 4; - - /// Fields Info - static const RawMessField kRawFieldLinkIndex( kusRawPosLinkIndex, kusRawLenLinkIndex ); - static const RawMessField kRawFieldNotHitFlag( kusRawPosNotHitFlag, kusRawLenNotHitFlag ); - // Hit message - static const RawMessField kRawFieldHitChannel( kusRawPosHitChannel, kusRawLenHitChannel ); - static const RawMessField kRawFieldHitAdc ( kusRawPosHitAdc, kusRawLenHitAdc ); - static const RawMessField kRawFieldHitTsFull ( kusRawPosHitTs, kusRawLenHitTsFull ); - static const RawMessField kRawFieldHitTsOver ( kusRawPosHitTsOver, kusRawLenHitTsOver ); - static const RawMessField kRawFieldHitTs ( kusRawPosHitTs, kusRawLenHitTs ); - static const RawMessField kRawFieldHitEmFlag ( kusRawPosHitEmFlag, kusRawLenHitEmFlag ); - // Non-hit messages - static const RawMessField kRawFieldTsMsbFlag ( kusRawPosTsMsbFlag, kusRawLenTsMsbFlag ); - // TS_MSB message - static const RawMessField kRawFieldTsMsbValA ( kusRawPosTsMsbValA, kusRawLenTsMsbValA ); - static const RawMessField kRawFieldTsMsbValB ( kusRawPosTsMsbValB, kusRawLenTsMsbValB ); - static const RawMessField kRawFieldTsMsbValC ( kusRawPosTsMsbValC, kusRawLenTsMsbValC ); - static const RawMessField kRawFieldTsMsbCrc ( kusRawPosTsMsbCrc, kusRawLenTsMsbCrc ); - // Control messages - static const RawMessField kRawFieldRdDataFlag( kusRawPosRdDataFlag, kusRawLenRdDataFlag ); - // Read Data Ack message - static const RawMessField kRawFieldRdDataVal ( kusRawPosRdDataVal, kusRawLenRdDataVal ); - static const RawMessField kRawFieldRdDataSeqN( kusRawPosRdDataSeqN, kusRawLenRdDataSeqN ); - static const RawMessField kRawFieldRdDataCrc ( kusRawPosRdDataCrc, kusRawLenRdDataCrc ); - // Ack messages - static const RawMessField kRawFieldAckValAck ( kusRawPosAckValAck, kusRawLenAckValAck ); - static const RawMessField kRawFieldAckSeqNb ( kusRawPosAckSeqNb, kusRawLenAckSeqNb ); - static const RawMessField kRawFieldAckCpFlag ( kusRawPosAckCpFlag, kusRawLenAckCpFlag); - static const RawMessField kRawFieldAckStatus ( kusRawPosAckStatus, kusRawLenAckStatus ); - static const RawMessField kRawFieldAckTime ( kusRawPosAckTime, kusRawLenAckTime ); - static const RawMessField kRawFieldAckCrc ( kusRawPosAckCrc, kusRawLenAckCrc ); - - /// Status/properties constants - static const uint32_t kuRawHitNbAdcBins = 1 << kusRawLenHitAdc; - static const uint32_t kuRawHitNbTsBins = 1 << kusRawLenHitTs; - static const uint32_t kuRawHitNbOverBins = 1 << kusRawLenHitTsOver; - static const uint32_t kuRawTsMsbNbTsBins = 1 << kusRawLenTsMsbValA; - static const uint32_t kuRawTsCycleNbBins = kuRawTsMsbNbTsBins * kuRawHitNbTsBins; - static const uint16_t kusRawInvalidTsMsb = kuRawTsMsbNbTsBins; - static const uint16_t kusRawMaskTsMsbOver = (1 << kusRawLenHitTsOver) - 1; - static const double kdRawClockCycleNs = 6.25; // ns, equivalent to 160 MHz clock - - class RawMessage { - private: -#ifndef USE_VHDL_CRC - uint16_t CalcCrc3Pol5Len21( uint32_t uVal ) const; - uint16_t CalcCrc4Pol9Len20( uint32_t uVal ) const; -#endif // not USE_VHDL_CRC - uint16_t VhdlCalcCrc3Pol5Len21( uint32_t uVal ) const; - uint16_t VhdlCalcCrc4Pol9Len20( uint32_t uVal ) const; - - - protected: - uint32_t fuData; // main and only storage field for the message - - public: - RawMessage() : fuData(0) {} - - RawMessage(const RawMessage& src) : fuData(src.fuData) {} - - RawMessage( uint32_t uDataIn ) : fuData( uDataIn ) {} - - virtual ~RawMessage() {}; - - void assign(const RawMessage& src) { fuData = src.fuData; } - - RawMessage& operator=(const RawMessage& src) { assign(src); return *this; } - - inline void reset() { fuData = 0; } - - // --------------------------- Accessors --------------------------------- - inline uint32_t GetData() const { return fuData; } - inline void SetData( uint32_t uValue) { fuData = uValue; } - - inline uint32_t GetField(uint32_t uShift, uint32_t uLen) const - { return ( fuData >> uShift) & ( ( (static_cast<uint32_t>( 1 ) ) << uLen ) - 1); } - - inline uint8_t GetBit(uint32_t uShift) const - { return ( fuData >> uShift) & 1; } - - inline uint32_t GetFieldBE(uint32_t uShift, uint32_t uLen) const - { return ( DataBE() >> uShift ) & ( ( ( static_cast<uint32_t>( 1 ) ) << uLen ) - 1 ); } - inline uint8_t GetBitBE(uint32_t uShift) const - { return (DataBE() >> uShift) & 1; } - inline uint32_t DataBE() const - { return ( ( fuData & 0x000000FF ) << 24) + - ( ( fuData & 0x0000FF00 ) << 8) + - ( ( fuData >> 8) & 0x0000FF00 ) + - ( ( fuData >> 24) & 0x000000FF ); - } - - // --------------------------- Setters --------------------------------------- - inline void SetField(uint32_t uShift, uint32_t uLen, uint32_t uValue) - { fuData = ( fuData & ~( ( ( ( static_cast< uint32_t >( 1 ) ) << uLen) - 1) << uShift ) ) - | ( ( static_cast< uint64_t >( uValue ) ) << uShift ); } - - inline void SetBit(uint32_t uShift, uint8_t uValue) - { fuData = uValue ? ( fuData | ( ( static_cast< uint32_t >( 1 ) ) << uShift ) ) : - ( fuData & ~( ( static_cast< uint32_t >( 1 ) ) << uShift ) ) ; } - - // --------------------------- Simplified Acc_or/Setters --------------------- - inline uint32_t GetField( RawMessField field ) const { return GetField( field.fusPos, field.fusLen ); } - inline uint8_t GetBit( RawMessField field ) const { return GetBit( field.fusPos ); } - inline bool GetFlag( RawMessField field ) const { return ( 1 == GetBit( field.fusPos ) ); } - inline uint32_t GetFieldBE( RawMessField field ) const { return GetFieldBE( field.fusPos, field.fusLen ); } - inline uint8_t GetBitBE( RawMessField field ) const { return GetBitBE( field.fusPos ); } - - inline void SetField( RawMessField field, uint32_t uValue ) { SetField( field.fusPos, field.fusLen, uValue ); } - inline void SetBit( RawMessField field, uint8_t ucValue ) { SetBit( field.fusPos, ucValue ); } - - // --------------------------- common fields --------------------------------- - //! For all data: Returns the (global) index of the eLink on which the message was received (n bit field) - inline uint16_t GetLinkIndex() const { return GetField( kRawFieldLinkIndex ); } - //! Check if the message if a Hit Message - inline bool IsHit() const { return !GetFlag( kRawFieldNotHitFlag ); } - //! Check if the message if a Dummy Hit Message - inline bool IsDummy() const { return IsHit() && ( 0 == GetHitAdc() ); } - //! Check if the message if a Ts_Msb - inline bool IsTsMsb() const { return (!IsHit() ) && GetFlag( kRawFieldTsMsbFlag ); } - //! Check if the message if a Hit Message - inline bool IsReadDataAck() const { return (!IsHit() ) && (!IsTsMsb() ) - && GetFlag( kRawFieldRdDataFlag ); } - //! Returns the message type, see enum MessType - inline RawMessType GetRawMessType() const { return !GetFlag( kRawFieldNotHitFlag ) ? ( 0 == GetHitAdc() ? RawMessType::Dummy : - RawMessType::Hit ) : - GetFlag( kRawFieldTsMsbFlag ) ? RawMessType::TsMsb : - GetFlag( kRawFieldRdDataFlag ) ? RawMessType::ReadDataAck : - RawMessType::Ack; } - - // ------------------------ Hit message fields ------------------------------- - //! For Hit data: Returns StsXYTER channel number (7 bit field) - inline uint16_t GetHitChannel() const { return GetField( kRawFieldHitChannel ); } - - //! For Hit data: Returns ADC value (5 bit field) - inline uint16_t GetHitAdc() const { return GetField( kRawFieldHitAdc ); } - - //! For Hit data: Returns Full timestamp (10 bit field including 2 bits overlap) - inline uint16_t GetHitTimeFull() const { return GetField( kRawFieldHitTsFull ); } - - //! For Hit data: Returns timestamp overlap bits (2 bits field, overlap with 2 LSBs of TS_MSB message) - inline uint16_t GetHitTimeOver() const { return GetField( kRawFieldHitTsOver ); } - - //! For Hit data: Returns timestamp (8 bit field, 2 MSB bits overlap removed) - inline uint16_t GetHitTime() const { return GetField( kRawFieldHitTs ); } - - //! For Hit data: Returns Missed event flag (1 bit field) - inline bool IsHitMissedEvts() const { return GetFlag( kRawFieldHitEmFlag ); } - - //! For Hit data: Sets StsXYTER channel number (7 bit field) - inline void SetHitChannel( uint16_t usVal ) { SetField( kRawFieldHitChannel, usVal ); } - - //! For Hit data: Sets ADC value (5 bit field) - inline void SetHitAdc( uint16_t usVal ) { SetField( kRawFieldHitAdc, usVal ); } - - //! For Hit data: Sets Full timestamp (10 bit field including 2 bits overlap) - inline void SetHitTimeFull( uint16_t usVal ) { SetField( kRawFieldHitTsFull, usVal ); } - - //! For Hit data: Sets timestamp overlap bits (2 bits field, overlap with 2 LSBs of TS_MSB message) - inline void SetHitTimeOver( uint16_t usVal ) { SetField( kRawFieldHitTsOver, usVal ); } - - //! For Hit data: Sets Full timestamp (8 bit field, 2 MSB bits overlap removed) - inline void SetHitTime( uint16_t usVal ) { SetField( kRawFieldHitTs, usVal ); } - - //! For Hit data: Sets Missed event flag (1 bit field) - inline void SetHitMissEvtsFlag( bool bVal) { SetBit( kRawFieldHitEmFlag, bVal ); } - - // ------------------------ TS_MSB message fields ---------------------------- - //! For TS MSB data: Returns 1st copy of the TS MSB (6 bit field) - inline uint16_t GetTsMsbValA() const { return GetField( kRawFieldTsMsbValA ); } - //! For TS MSB data: Returns 2nd copy of the TS MSB (6 bit field) - inline uint16_t GetTsMsbValB() const { return GetField( kRawFieldTsMsbValB ); } - //! For TS MSB data: Returns 3rd copy of the TS MSB (6 bit field) - inline uint16_t GetTsMsbValC() const { return GetField( kRawFieldTsMsbValC ); } - //! For TS MSB data: Returns message CRC (4 bit field) - inline uint16_t GetTsMsbCrc() const { return GetField( kRawFieldTsMsbCrc ); } - //! For TS MSB data: Returns data protected by CRC (20 bit field) - inline uint32_t GetTsMsbCrcInput() const { return GetField( kRawFieldTsMsbValC.fusPos, - kusRawLenRawMess - kRawFieldTsMsbCrc.fusLen ); } - - //! For TS MSB data: Sets 1st copy of the TS MSB (6 bit field) - inline void SetTsMsbValA( uint16_t usVal ) { SetField( kRawFieldTsMsbValA, usVal ); } - //! For TS MSB data: Sets 2nd copy of the TS MSB (6 bit field) - inline void SetTsMsbValB( uint16_t usVal ) { SetField( kRawFieldTsMsbValB, usVal ); } - //! For TS MSB data: Sets 3rd copy of the TS MSB (6 bit field) - inline void SetTsMsbValC( uint16_t usVal ) { SetField( kRawFieldTsMsbValC, usVal ); } - //! For TS MSB data: Sets message CRC (4 bit field) - inline void SetTsMsbCRC( uint16_t usVal ) { SetField( kRawFieldTsMsbCrc, usVal ); } - - // ------------------------ Read Data Ack message fields --------------------- - //! For Read Data Ack data: Returns read value (15 bit field) - inline uint16_t GetRdDataVal() const { return GetField( kRawFieldRdDataVal ); } - //! For Read Data Ack data: Returns Sequence Number (3 bit field) - inline uint16_t GetRdDataSeqN() const { return GetField( kRawFieldRdDataSeqN ); } - //! For Read Data Ack data: Returns message CRC (3 bit field) - inline uint16_t GetRdDataCrc() const { return GetField( kRawFieldRdDataCrc ); } - //! For Read Data Ack data: Returns data protected by CRC (21 bit field) - inline uint32_t GetRdDataCrcInput() const { return GetField( kRawFieldRdDataSeqN.fusPos, - kusRawLenRawMess - kRawFieldRdDataCrc.fusLen ); } - - //! For Read Data Ack data: Sets read value (15 bit field) - inline void SetRdDataVal( uint16_t usVal ) { SetField( kRawFieldRdDataVal, usVal ); } - //! For Read Data Ack data: Sets Sequence Number (3 bit field) - inline void SetRdDataSeqN( uint16_t usVal ) { SetField( kRawFieldRdDataSeqN, usVal ); } - //! For Read Data Ack data: Sets message CRC (3 bit field) - inline void SetRdDataCrc( uint16_t usVal ) { SetField( kRawFieldRdDataCrc, usVal ); } - - // ------------------------ Ack message fields ------------------------------- - //! For Ack data: Returns ACK value (2 bit field) - inline uint16_t GetAckVal() const { return GetField( kRawFieldAckValAck ); } - //! For Ack data: Returns Sequence Number (4 bit field) - inline uint16_t GetAckSeqNb() const { return GetField( kRawFieldAckSeqNb ); } - //! For Ack data: Returns config parity flag (1 bit field) - inline uint16_t GetAckCpFlag() const { return GetFlag( kRawFieldAckCpFlag ); } - //! For Ack data: Returns ACK status (4 bit field) - inline uint16_t GetAckStatus() const { return GetField( kRawFieldAckStatus ); } - //! For Ack data: Returns ACK time (6 bit field) - inline uint16_t GetAckTime() const { return GetField( kRawFieldAckTime ); } - //! For Ack data: Returns message CRC (4 bit field) - inline uint16_t GetAckCrc() const { return GetField( kRawFieldAckCrc ); } - //! For Ack data: Returns data protected by CRC (20 bit field) - inline uint32_t GetAckCrcInput() const { return GetField( kRawFieldAckTime.fusPos, - kusRawLenRawMess - kRawFieldAckCrc.fusLen ); } - - //! For Ack data: Sets ACK value (2 bit field) - inline void SetAckVal( uint16_t usVal ) { SetField( kRawFieldAckValAck, usVal ); } - //! For Ack data: Sets Sequence Number (4 bit field) - inline void SetAckSeqNb( uint16_t usVal ) { SetField( kRawFieldAckSeqNb, usVal ); } - //! For Ack data: Sets config parity flag (1 bit field) - inline void SetAckCpFlag( uint16_t usVal ) { SetBit( kRawFieldAckCpFlag, usVal ); } - //! For Ack data: Sets ACK status (4 bit field) - inline void SetAckStatus( uint16_t usVal ) { SetField( kRawFieldAckStatus, usVal ); } - //! For Ack data: Sets ACK time (6 bit field) - inline void SetAckTime( uint16_t usVal ) { SetField( kRawFieldAckTime, usVal ); } - //! For Ack data: Sets message CRC (4 bit field) - inline void SetAckCrc( uint16_t usVal ) { SetField( kRawFieldAckCrc, usVal ); } - - // ------------------------ Hit message OP ----------------------------------- - // ------------------------ TS_MSB message OP -------------------------------- - //! For TS MSB data: computes message 4b 0x9 CRC - uint16_t TsMsbCrcCalc() const; - //! For TS MSB data: check if 4b 0x9 CRC is ok - bool TsMsbCrcCheck() const; - //! For TS MSB data: check if CRC is ok and all 3 TS copies agree - bool TsMsbTsCheck() const; - //! For TS MSB data: count how many values are agreeing, possible are 1 (none), 2 or 3 - uint16_t GetTsMsbMajCnt() const; - //! For TS MSB data: check TS integrity and try to correct by majority if corrupted - bool GetTsMsbValCorr( uint16_t & uVal ) const; - // ------------------------ Read Data Ack message OP ------------------------- - //! For Read Data Sck data: computes message 3b 0x5 CRC - uint16_t RdDataCrcCalc() const; - //! For Read Data Sck data: check if 3b 0x5 CRC is ok - bool RdDataCrcCheck() const; - // ------------------------ Ack message OP ----------------------------------- - //! For Ack data: computes message 4b 0x9 CRC - uint16_t AckCrcCalc() const; - //! For Ack data: check if 4b 0x9 CRC is ok - bool AckCrcCheck() const; - - // ------------------------ General OP --------------------------------------- - bool PrintMess( std::ostream& os, RawMessagePrintMask ctrl = RawMessagePrintMask::msg_print_Human ) const; - }; -} -#endif // STSXYTERRAWMESSAGE_H diff --git a/beamtime/cosy2014/CMakeLists.txt b/beamtime/cosy2014/CMakeLists.txt deleted file mode 100644 index e23790cc598f65c4018a3404d24aac86f462e356..0000000000000000000000000000000000000000 --- a/beamtime/cosy2014/CMakeLists.txt +++ /dev/null @@ -1,115 +0,0 @@ -# Create a library called "libCbmBeamtime" which includes the source files given in -# the array . -# The extension is already found. Any number of sources could be listed here. - -Set(INCLUDE_DIRECTORIES - ${CBMBASE_DIR} - - ${CBMDATA_DIR} - ${CBMDATA_DIR}/base - ${CBMDATA_DIR}/mvd - ${CBMDATA_DIR}/sts - ${CBMDATA_DIR}/rich - ${CBMDATA_DIR}/much - ${CBMDATA_DIR}/trd - ${CBMDATA_DIR}/tof - ${CBMDATA_DIR}/psd - - ${CBMROOT_SOURCE_DIR}/beamtime/data - ${CBMROOT_SOURCE_DIR}/beamtime/data/fhodo - ${CBMROOT_SOURCE_DIR}/beamtime/base - ${CBMROOT_SOURCE_DIR}/beamtime/roclight - - ${CBMDETECTORBASE_DIR}/sts - - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/fhodo - ${CMAKE_CURRENT_SOURCE_DIR}/reco - ${CMAKE_CURRENT_SOURCE_DIR}/unpacker -) - - -Set(SYSTEM_INCLUDE_DIRECTORIES - ${BASE_INCLUDE_DIRECTORIES} - ${Boost_INCLUDE_DIR} -) - -Include_Directories( - ${INCLUDE_DIRECTORIES} -) - -Include_Directories( - SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES} -) - -Set(LINK_DIRECTORIES - ${ROOT_LIBRARY_DIR} - ${Boost_LIBRARY_DIRS} - ${FAIRROOT_LIBRARY_DIR} -) - -Link_Directories( - ${LINK_DIRECTORIES} -) - -Set(SRCS - CbmSourceLmd.cxx - CbmSourceLmdNew.cxx - CbmLmdDebug.cxx - - CbmDaqMap.cxx - CbmDaqMapCosy2014.cxx - CbmDaqMapCosy2014Much.cxx - CbmDaqMapCosy2013.cxx - - unpacker/CbmROCUnpackAux.cxx - unpacker/CbmROCUnpackDummy.cxx - unpacker/CbmROCUnpackEpoch.cxx - unpacker/CbmROCUnpackSystemMessage.cxx - unpacker/CbmROCUnpackSts.cxx - unpacker/CbmROCUnpackHodo.cxx - unpacker/CbmROCUnpackMuch.cxx - - fhodo/CbmFiberHodoClusterFinder.cxx - fhodo/CbmHodoRawHistos.cxx - - reco/CbmStsHodoCorrelations.cxx - reco/CbmMuchRawHistos.cxx - - sts/reco/cosy/StsCosyBL.cxx - sts/reco/cosy/StsCosyClusterFinder.cxx - sts/reco/cosy/StsCosyHitFinder.cxx - sts/reco/cosy/StsCosyAnalysis.cxx - - sts/settings/StsAlignment.cxx - sts/settings/StsClusterSet.cxx - sts/settings/StsHitSet.cxx -) - -# Add artificial dependency which delays the compilation of the defined file -# until the libRoc.so is produced which is needed for the linking of the -# beamtime library. I couldn't find any better solution for the problem up -# to now. -Set_Source_Files_Properties(PROPERTIES CbmRocSource.cxx PROPERTIES - OBJECT_DEPENDS ${LIBRARY_OUTPUT_PATH}/libRoc.so -) - -If(_UINT8_T_EXIST) -# Add_Definitions(-DHAVE_UINT8_T_HEADER_FILE) - Set(DEFINITIONS HAVE_UINT8_T_HEADER_FILE) -EndIf() - -Set(LINKDEF CbmBeamtimeCosy2014LinkDef.h) -Set(LIBRARY_NAME CbmBeamtimeCosy2014) -Set(DEPENDENCIES - CbmBeamtimeBase - CbmBeamtimeData - CbmRocLight - CbmStsBase -# CbmSts - CbmData - CbmBase - Base -) - -GENERATE_LIBRARY() diff --git a/beamtime/cosy2014/CbmBeamtimeCosy2014LinkDef.h b/beamtime/cosy2014/CbmBeamtimeCosy2014LinkDef.h deleted file mode 100644 index ad43bcf2e22dbe845b3816412c60f1bc1910014a..0000000000000000000000000000000000000000 --- a/beamtime/cosy2014/CbmBeamtimeCosy2014LinkDef.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifdef __CINT__ - -#pragma link off all globals; -#pragma link off all classes; -#pragma link off all functions; - -#pragma link C++ class CbmDaqMap; -#pragma link C++ class CbmDaqMapCosy2014; -#pragma link C++ class CbmDaqMapCosy2014Much; -#pragma link C++ class CbmDaqMapCosy2013; -#pragma link C++ class CbmSourceLmd; -#pragma link C++ class CbmSourceLmdNew; -#pragma link C++ class CbmLmdDebug; -#pragma link C++ class CbmROCUnpackSts+; -#pragma link C++ class CbmROCUnpackHodo+; -#pragma link C++ class CbmROCUnpackMuch+; -#pragma link C++ class CbmROCUnpackAux+; -#pragma link C++ class CbmROCUnpackDummy+; -#pragma link C++ class CbmROCUnpackEpoch+; -#pragma link C++ class CbmROCUnpackSystemMessage; - -#pragma link C++ class CbmFiberHodoClusterFinder+; -#pragma link C++ class CbmHodoRawHistos; -#pragma link C++ class CbmStsHodoCorrelations; -#pragma link C++ class CbmMuchRawHistos+; - -#pragma link C++ class StsCosyBL+; -#pragma link C++ class StsCosyClusterFinder; -#pragma link C++ class StsCosyHitFinder; -#pragma link C++ class StsCosyAnalysis; - -#pragma link C++ class StsAlignment; -#pragma link C++ class StsClusterSet; -#pragma link C++ class StsHitSet; - -#endif diff --git a/beamtime/cosy2014/CbmDaqMap.cxx b/beamtime/cosy2014/CbmDaqMap.cxx deleted file mode 100644 index d0e7ef8867d1022f3a777b3f3ec030f105c599d5..0000000000000000000000000000000000000000 --- a/beamtime/cosy2014/CbmDaqMap.cxx +++ /dev/null @@ -1,36 +0,0 @@ -/**@file CbmDaqMap.cxx - **@date 11.12.2013 - **@author V. Friese <v.friese@gsi.de> - **/ -#include "CbmDaqMap.h" -#include <TObject.h> // for TObject - -// ----- Default Constructor ---------------------------------------------- -CbmDaqMap::CbmDaqMap() - : TObject(), - fRun(-1) -{ -} -// --------------------------------------------------------------------------- - - - - -// ----- Standard Constructor --------------------------------------------- -CbmDaqMap::CbmDaqMap(Int_t iRun) - : TObject(), - fRun(iRun) -{ -} -// --------------------------------------------------------------------------- - - - -// ----- Destructor ------------------------------------------------------ -CbmDaqMap::~CbmDaqMap() -{ -} -// --------------------------------------------------------------------------- - -ClassImp(CbmDaqMap) - diff --git a/beamtime/cosy2014/CbmDaqMap.h b/beamtime/cosy2014/CbmDaqMap.h deleted file mode 100644 index 81ed919a7ee01a1208f4099526db845e61e0d1a7..0000000000000000000000000000000000000000 --- a/beamtime/cosy2014/CbmDaqMap.h +++ /dev/null @@ -1,94 +0,0 @@ -/**@file CbmDaqMap.h - **@date 03.012.2009 - **author V. Friese <v.friese@gsi.de> - ** - ** Provides the mapping of DAQ channel to detector channel - ** - ** At the moment: implemented only for STS stations - **/ - - - -#ifndef CBMDAQMAP_H -#define CBMDAQMAP_H 1 - -#include <Rtypes.h> // for ClassDef -#include <RtypesCore.h> // for Int_t, Bool_t -#include <TObject.h> // for TObject -#include "CbmDefs.h" - -class CbmDaqMap : public TObject -{ - - - public: - - /** Default constructor **/ - CbmDaqMap(); - - - /** Standard constructor - **@param iRun run number - **/ - CbmDaqMap(Int_t iRun); - - - /** Destructor **/ - virtual ~CbmDaqMap(); - - - /** Set trun number */ - void SetRun(Int_t iRun) { fRun = iRun; } - - - /** System Id from ROC Id **/ - virtual ECbmModuleId GetSystemId(Int_t rocId) = 0; - - - /** STS station from ROC Id **/ - virtual Int_t GetStsStation(Int_t rocId) = 0; - - /** MUCH station from ROC Id **/ - virtual Int_t GetMuchStation(Int_t rocId) = 0; - - /** Fiber Hodoscope station from ROC Id **/ - virtual Int_t GetFiberHodoStation(Int_t rocId) = 0; - - /** STS sensor side from ROC and NXYTER Id **/ - virtual Int_t GetStsSensorSide(Int_t rocId) = 0; - - /** STS channel from ROC, NXYTER and NXYTER channel **/ - virtual Int_t GetStsChannel(Int_t rocId, Int_t nxId, Int_t nxChannel) = 0; - - /** Fiber Hodoscope channel from ROC, NXYTER and NXYTER channel **/ - virtual Int_t GetFiberHodoChannel(Int_t rocId, Int_t nxId, Int_t nxChannel) = 0; - - - /** Mapping - **@param iRoc ROC number (from hit message) - **@param iNx NXYter number (from hit message) - **@param iId Channel ID (from hit message) - **@param iStation Station number (return) - **@param iSector Sector number ( return) - **@param iSide Front side (0) / Back side (1) ( return) - **@param iChannel Channel number (return) - **/ - virtual Bool_t Map(Int_t iRoc, Int_t iNx, Int_t iId, - Int_t& iStation, Int_t& iSector, - Int_t& iSide, Int_t& iChannel) = 0; - - - - protected: - - Int_t fRun; /** Run number **/ - - ClassDef(CbmDaqMap,0); - -}; - -#endif - - - - diff --git a/beamtime/cosy2014/CbmDaqMapCosy2013.cxx b/beamtime/cosy2014/CbmDaqMapCosy2013.cxx deleted file mode 100644 index a7af9716536802cac744fd54e94a5df600349ab8..0000000000000000000000000000000000000000 --- a/beamtime/cosy2014/CbmDaqMapCosy2013.cxx +++ /dev/null @@ -1,298 +0,0 @@ -/**@file CbmDaqMapCosy2013.cxx - **@date 11.12.2013 - **@author V. Friese <v.friese@gsi.de> - **/ -#include "CbmDaqMapCosy2013.h" - -#include <TMathBase.h> // for Even -#include <FairLogger.h> // for Logger, LOG -#include "CbmDefs.h" // for kHodo, kMuch, kSts - -// ----- Default Constructor ---------------------------------------------- -CbmDaqMapCosy2013::CbmDaqMapCosy2013() - : CbmDaqMap(), - fFiberHodoFiber(), - fFiberHodoPlane(), - fFiberHodoPixel() -{ - InitializeFiberHodoMapping(); -} -// --------------------------------------------------------------------------- - - - -// ----- Standard Constructor --------------------------------------------- -CbmDaqMapCosy2013::CbmDaqMapCosy2013(Int_t iRun) - : CbmDaqMap(iRun), - fFiberHodoFiber(), - fFiberHodoPlane(), - fFiberHodoPixel() -{ - InitializeFiberHodoMapping(); -} -// --------------------------------------------------------------------------- - - - -// ----- Destructor ------------------------------------------------------ -CbmDaqMapCosy2013::~CbmDaqMapCosy2013() { } -// --------------------------------------------------------------------------- - - -// ----- Get System ------------------------------------------------------ -ECbmModuleId CbmDaqMapCosy2013::GetSystemId(Int_t rocId) { - ECbmModuleId systemId = ECbmModuleId::kNotExist; - if ( rocId >= 0 && rocId <= 4 ) systemId = ECbmModuleId::kMuch; - else if ( rocId == 5 || rocId == 6 ) systemId = ECbmModuleId::kHodo; - else if ( rocId >= 7 || rocId <= 12 ) systemId = ECbmModuleId::kSts; - else LOG(warn) << GetName() << ": Unknown ROC id " << rocId; - return systemId; -} -// --------------------------------------------------------------------------- - - -// ----- Get STS station number ------------------------------------------ -Int_t CbmDaqMapCosy2013::GetStsStation(Int_t rocId) { - if ( rocId < 7 || rocId > 12 ) { - LOG(error) << GetName() << ": Illegal STS ROC Id " << rocId; - return -1; - } - return ( (rocId-0.1) / 2 - 3 ); -} -// --------------------------------------------------------------------------- - - -// ----- Get MUCH station number ------------------------------------------ -Int_t CbmDaqMapCosy2013::GetMuchStation(Int_t rocId) { - Int_t station = -1; - if ( rocId == 0 || rocId == 1 ) station = 0; - else if ( rocId == 2 ) station = 1; - else if ( rocId == 3 || rocId == 4 ) station = 2; - else LOG(error) << GetName() << ": Illegal MUCH ROC Id " << rocId; - return station; -} -// --------------------------------------------------------------------------- - -// ----- Get Fiber Hodoscope station number ------------------------------ -Int_t CbmDaqMapCosy2013::GetFiberHodoStation(Int_t rocId) { - if ( rocId < 5 || rocId > 6 ) { - LOG(error) << GetName() << ": Illegal Fiber Hodoscope ROC Id " << rocId; - return -1; - } - return ( rocId - 5 ); -} -// --------------------------------------------------------------------------- - - - -// ---- Get STS sensor side ----------------------------------------------- -Int_t CbmDaqMapCosy2013::GetStsSensorSide(Int_t rocId) { - return ( TMath::Even(rocId) ? 0 : 1 ); -} -// --------------------------------------------------------------------------- - - -/* -// ----- Get STS channel number ------------------------------------------ -Int_t CbmDaqMapCosy2013::GetStsChannel(Int_t rocId, Int_t nxId, Int_t nxChannel) { - Int_t channel = -1; - if ( rocId >= 7 && rocId <= 10 ) channel = nxChannel + nxId / 2 * 127; - else channel = nxChannel; - return channel; -} -// --------------------------------------------------------------------------- -*/ - -// ----- Get STS channel number ------------------------------------------ -Int_t CbmDaqMapCosy2013::GetStsChannel(Int_t rocId, Int_t nxId, Int_t nxChannel) { - - Int_t channel = -1; - - if (rocId == 7 ){ //sts0 p-side - if (nxId == 0) channel = ((nxChannel < 64) ? (2 * nxChannel - 4 * (nxChannel % 2) + 3) : (2 * nxChannel + 1)); // even - if (nxId == 2) channel = ((nxChannel < 64) ? (252 - 2 * nxChannel + 4 * (nxChannel % 2)) : (254 -2 * nxChannel)); // odd - } - - if (rocId == 8 ){ //sts0 n-side - if (nxId == 0) channel = ((nxChannel < 64) ? (253 - 2 * nxChannel + 4 * (nxChannel % 2)) : (255 - 2 * nxChannel)); // even - if (nxId == 2) channel = ((nxChannel < 64) ? (2 * nxChannel + 2 - 4 * (nxChannel % 2)) : (2 * nxChannel)); // odd - } - - if (rocId == 9){ //sts1 p-side - if (nxId == 0) channel = 256 - ((nxChannel < 64) ? (2 * nxChannel - 4 * (nxChannel % 2) + 3) : (2 * nxChannel + 1)); // even - if (nxId == 2) channel = 256 - ((nxChannel < 64) ? (252 - 2 * nxChannel + 4 * (nxChannel % 2)) : (254 -2 * nxChannel)); // odd - } - - if (rocId == 10){ //sts1 n-side - if (nxId == 0) channel = 256 - ((nxChannel < 64) ? (253 - 2 * nxChannel + 4 * (nxChannel % 2)) : (255 - 2 * nxChannel)); // even - if (nxId == 2) channel = 256 - ((nxChannel < 64) ? (2 * nxChannel + 2 - 4 * (nxChannel % 2)) : (2 * nxChannel)); // odd - } - - if (rocId == 11) { //sts2 p-side - if (nxId == 0) channel = 128 - ((nxChannel < 64) ? (nxChannel + 2 * ((nxChannel + 1) % 2) - 1) : nxChannel); - } - - if (rocId == 12) { //sts2 n-side - if (nxId == 0) channel = 128 - ((nxChannel < 64) ? (127 - nxChannel) : (- nxChannel + 126 + 2 * (nxChannel % 2))); - } - - return channel; -} -// --------------------------------------------------------------------------- - - -// ----- Get STS channel number ------------------------------------------ -Int_t CbmDaqMapCosy2013::GetFiberHodoChannel(Int_t /*rocId*/, Int_t /*nxId*/, Int_t /*nxChannel*/) { - Int_t channel = -1; - return channel; -} -// --------------------------------------------------------------------------- - - - -// ----- Mapping --------------------------------------------------------- -Bool_t CbmDaqMapCosy2013::Map(Int_t iRoc, Int_t iNx, Int_t iId, - Int_t& iStation, Int_t& iSector, - Int_t& iSide, Int_t& iChannel) { - - // --- Valid ROC Id - if ( iRoc < 0 || iRoc > 12 ) - LOG(fatal) << GetName() << ": UInvalid ROC Id " << iRoc; - - - // --- ROC 0 to 4 are MUCH - // --- Not implemented yet - if ( iRoc <= 4 ) { - iStation = -1; - iSector = 0; - iSide = 0; - - return kTRUE; - } - - - // --- ROC 5 to 6: Hodoscope - else if ( iRoc <= 6 ) { - if (iNx == 0) { - iStation = iRoc -5; - iSector = 0; - iSide = fFiberHodoPlane[iId]; - iChannel = fFiberHodoFiber[iId]; - return kTRUE; - } else { - LOG(fatal) << GetName() << ": Unknown Nxyter Id " << iNx - << " for Roc Id " << iRoc; - } - } - - // --- ROC 7 to 12: STS - else { - - // --- STS station 0 (reference) - if ( iRoc == 7 || iRoc == 8 ) { - iStation = 0; - iSector = 0; - iSide = 8 - iRoc; - // iChannel = iId + iNx / 2 * 127; - } - - // --- STS station 1 (reference) - else if ( iRoc == 9 || iRoc == 10 ) { - iStation = 1; - iSector = 0; - iSide = 10 - iRoc; - // iChannel = iId + iNx / 2 * 127; - } - - // --- STS station 2 (OUT) - else if ( iRoc == 11 || iRoc == 12 ) { - iStation = 2; - iSector = 0; - iSide = 12 - iRoc; - // iChannel = iId; - } - - else LOG(fatal) << GetName() << ": Unknown ROC Id " << iRoc; - - } // --- ROC 7 to 12 - - - return kTRUE; -} -// --------------------------------------------------------------------------- - -// --------------------------------------------------------------------------- -void CbmDaqMapCosy2013::InitializeFiberHodoMapping() -{ - // This code was copied from the Go4 analysis used for previous beamtimes - for (Int_t i=0; i<128; i++) { - fFiberHodoFiber[i] = -1; - fFiberHodoPlane[i] = -1; - fFiberHodoPixel[i] = -1; - } - - for (Int_t ifiber=1; ifiber<=64; ifiber++) { - // Calculate fiber number [1..64] from feb channel - // lcn: linearconnectornumber, is the wire number on one of the - // flat cables. [1..16] - // each 16 fibers go to one connector. - // fibersubnr[0..15] linear fiber counter in groups of 16 - - Int_t fibersubnr=(ifiber-1)%16; - - Int_t lcn=15-fibersubnr*2; - if (fibersubnr>=8) lcn=(fibersubnr-7)*2; - - Int_t channel=-1; - Int_t cable=(ifiber-1)/16+1; - Int_t pixel= ((lcn-1)/2)*8 +((lcn-1)%2); - if (cable==1) { - channel=(lcn-1)*4+0; - pixel=pixel+1; - } - if (cable==2) { - channel=(lcn-1)*4+2; - pixel=pixel+3; - } - if (cable==3) { - channel=(lcn-1)*4+1; - pixel=pixel+5; - } - if (cable==4) { - channel=(lcn-1)*4+3; - pixel=pixel+7; - } - - // new code to resolve cabling problem during cern-oct12 - int ifiber_bis = ifiber; - if (ifiber <= 8 ) ifiber_bis = ifiber + 56; else - if (ifiber <= 16 ) ifiber_bis = ifiber + 40; else - if (ifiber <= 24 ) ifiber_bis = ifiber + 24; else - if (ifiber <= 32 ) ifiber_bis = ifiber + 8; else - if (ifiber <= 40 ) ifiber_bis = ifiber - 8; else - if (ifiber <= 48 ) ifiber_bis = ifiber - 24; else - if (ifiber <= 56 ) ifiber_bis = ifiber - 40; else - if (ifiber <= 64 ) ifiber_bis = ifiber - 56; - - // and swap at the end - ifiber_bis = 65 - ifiber_bis; - - fFiberHodoFiber[channel] = ifiber_bis - 1; - fFiberHodoPlane[channel] = 0; - fFiberHodoPixel[channel] = pixel; - - fFiberHodoFiber[channel+64] = ifiber_bis - 1; - fFiberHodoPlane[channel+64] = 1; - fFiberHodoPixel[channel+64] = pixel; - - } - - for (Int_t i=0; i<128; i++) { - LOG(debug) << "Channel[" << i << "]: " << fFiberHodoFiber[i] << ", " - << fFiberHodoPlane[i] << ", " << fFiberHodoPixel[i]; - } - -} - -ClassImp(CbmDaqMapCosy2013) - diff --git a/beamtime/cosy2014/CbmDaqMapCosy2013.h b/beamtime/cosy2014/CbmDaqMapCosy2013.h deleted file mode 100644 index a2d3a417c0f594c5cbcf80b2c102b3b53ef94b4e..0000000000000000000000000000000000000000 --- a/beamtime/cosy2014/CbmDaqMapCosy2013.h +++ /dev/null @@ -1,84 +0,0 @@ -/**@file CbmDaqMapCosy2013.h - **@date 03.012.2009 - **author V. Friese <v.friese@gsi.de> - ** - ** Provides the mapping of DAQ channel to detector channel - ** - ** At the moment: implemented only for STS stations - **/ - - - -#ifndef CBMDAQMAPCOSY2013_H -#define CBMDAQMAPCOSY2013_H 1 - -#include <Rtypes.h> // for ClassDef -#include <RtypesCore.h> // for Int_t, Bool_t -#include "CbmDaqMap.h" // for CbmDaqMap - -class CbmDaqMapCosy2013 : public CbmDaqMap -{ - - - public: - - /** Default constructor **/ - CbmDaqMapCosy2013(); - - /** Standard constructor - **@param iRun run number - **/ - CbmDaqMapCosy2013(Int_t iRun); - - /** Destructor **/ - virtual ~CbmDaqMapCosy2013(); - - /** System Id from ROC Id **/ - ECbmModuleId GetSystemId(Int_t rocId); - - /** STS station from ROC Id **/ - Int_t GetStsStation(Int_t rocId); - - /** MUCH station from ROC Id **/ - Int_t GetMuchStation(Int_t rocId); - - /** Fiber Hodoscope station from ROC Id **/ - Int_t GetFiberHodoStation(Int_t rocId); - - /** STS sensor side from ROC and NXYTER Id **/ - Int_t GetStsSensorSide(Int_t rocId); - - /** STS channel from ROC, NXYTER and NXYTER channel **/ - Int_t GetStsChannel(Int_t rocId, Int_t nxId, Int_t nxChannel); - - /** Fiber Hodoscope channel from ROC, NXYTER and NXYTER channel **/ - Int_t GetFiberHodoChannel(Int_t rocId, Int_t nxId, Int_t nxChannel); - - - /** Mapping - **@param iRoc ROC number (from hit message) - **@param iNx NXYter number (from hit message) - **@param iId Channel ID (from hit message) - **@param iStation Station number (return) - **@param iSector Sector number ( return) - **@param iSide Front side (0) / Back side (1) ( return) - **@param iChannel Channel number (return) - **/ - Bool_t Map(Int_t iRoc, Int_t iNx, Int_t iId, - Int_t& iStation, Int_t& iSector, Int_t& iSide, Int_t& iChannel); - - - - private: - - void InitializeFiberHodoMapping(); - - Int_t fFiberHodoFiber[128]; /** Mapping from fiber hodoscope feb channel to fiber number **/ - Int_t fFiberHodoPlane[128]; /** Mapping from fiber hodoscope feb channel to plane number 1=X, 2=Y **/ - Int_t fFiberHodoPixel[128]; /** Mapping from fiber hodoscope feb channel to pixel number **/ - - ClassDef(CbmDaqMapCosy2013,1); - -}; - -#endif diff --git a/beamtime/cosy2014/CbmDaqMapCosy2014.cxx b/beamtime/cosy2014/CbmDaqMapCosy2014.cxx deleted file mode 100644 index ff22658fe6b47733196f3c4c40548a280c5892f2..0000000000000000000000000000000000000000 --- a/beamtime/cosy2014/CbmDaqMapCosy2014.cxx +++ /dev/null @@ -1,446 +0,0 @@ -/**@file CbmDaqMapCosy2014.cxx - **@date 11.12.2013 - **@author V. Friese <v.friese@gsi.de> - **/ -#include "CbmDaqMapCosy2014.h" - -#include <TMathBase.h> // for Even -#include <FairLogger.h> // for Logger, LOG -#include <iostream> // for cout, endl -#include "CbmDefs.h" // for kSts, kHodo - -using std::cout; -using std::endl; - -// ----- Default Constructor ---------------------------------------------- -CbmDaqMapCosy2014::CbmDaqMapCosy2014() - : CbmDaqMap(), - fFiberHodoFiber(), - fFiberHodoPlane(), - fFiberHodoPixel(), - fRocToSystem(), - fRocToStsStation(), - fRocToHodoStation(), - fStsStrip() -{ - InitializeFiberHodoMapping(); - InitializeRocToSystemArray(); - InitializeRocToStsStation(); - InitializeRocToHodoStation(); - InitializeStsMapping(); - fRun = 1; -} -// --------------------------------------------------------------------------- - - - -// ----- Standard Constructor --------------------------------------------- -CbmDaqMapCosy2014::CbmDaqMapCosy2014(Int_t iRun) - : CbmDaqMap(iRun), - fFiberHodoFiber(), - fFiberHodoPlane(), - fFiberHodoPixel(), - fRocToSystem(), - fRocToStsStation(), - fRocToHodoStation(), - fStsStrip() -{ - InitializeFiberHodoMapping(); - InitializeRocToSystemArray(); - InitializeRocToStsStation(); - InitializeRocToHodoStation(); - InitializeStsMapping(); - fRun = iRun; -} -// --------------------------------------------------------------------------- - - - -// ----- Destructor ------------------------------------------------------ -CbmDaqMapCosy2014::~CbmDaqMapCosy2014() { } -// --------------------------------------------------------------------------- - - -// ----- Get System ------------------------------------------------------ -ECbmModuleId CbmDaqMapCosy2014::GetSystemId(Int_t rocId) -{ - - if ( rocId < 0 || rocId >= fMaxNumRoc ) { - LOG(warn) << GetName() << ": Unknown ROC id " << rocId - ; - return ECbmModuleId::kNotExist; - } else { - return fRocToSystem[rocId]; - } -} -// --------------------------------------------------------------------------- - - -// ----- Get STS station number ------------------------------------------ -Int_t CbmDaqMapCosy2014::GetStsStation(Int_t rocId) -{ - Int_t station = fRocToStsStation[rocId]; - - if ( -1 == station) { - LOG(error) << GetName() << ": Illegal STS ROC Id " << rocId; - } - - return station; -} -// --------------------------------------------------------------------------- - - -// ----- Get MUCH station number ------------------------------------------ -Int_t CbmDaqMapCosy2014::GetMuchStation(Int_t /*rocId*/) -{ - // No MUCH in the STS setup - Int_t station = -1; - return station; -} -// --------------------------------------------------------------------------- - -// ----- Get Fiber Hodoscope station number ------------------------------ -Int_t CbmDaqMapCosy2014::GetFiberHodoStation(Int_t rocId) -{ - Int_t station = fRocToHodoStation[rocId]; - - if ( -1 == station) { - LOG(error) << GetName() << ": Illegal Hodo ROC Id " << rocId; - } - - return station; -} -// --------------------------------------------------------------------------- - - - -// ---- Get STS sensor side ----------------------------------------------- -Int_t CbmDaqMapCosy2014::GetStsSensorSide(Int_t rocId) { - return ( TMath::Even(rocId) ? 1 : 0 ); -} -// --------------------------------------------------------------------------- - -// ----- Get STS channel number ------------------------------------------ -Int_t CbmDaqMapCosy2014::GetStsChannel(Int_t rocId, Int_t nxId, Int_t nxChannel) { - - Int_t channel = -1; - - if (rocId == 2){ //sts1 p-side - if (nxId == 0) channel = 256 - ((nxChannel < 64) ? (2 * nxChannel - 4 * (nxChannel % 2) + 3) : (2 * nxChannel + 1)); // even - if (nxId == 2) channel = 256 - ((nxChannel < 64) ? (252 - 2 * nxChannel + 4 * (nxChannel % 2)) : (254 -2 * nxChannel)); // odd - } - - if (rocId == 3){ //sts1 n-side - if (nxId == 0) channel = 256 - ((nxChannel < 64) ? (253 - 2 * nxChannel + 4 * (nxChannel % 2)) : (255 - 2 * nxChannel)); // even - if (nxId == 2) channel = 256 - ((nxChannel < 64) ? (2 * nxChannel + 2 - 4 * (nxChannel % 2)) : (2 * nxChannel)); // odd - } - - if (rocId == 4 ){ //sts0 p-side - if (nxId == 0) channel = ((nxChannel < 64) ? (2 * nxChannel - 4 * (nxChannel % 2) + 3) : (2 * nxChannel + 1)); // even - if (nxId == 2) channel = ((nxChannel < 64) ? (252 - 2 * nxChannel + 4 * (nxChannel % 2)) : (254 -2 * nxChannel)); // odd - } - - if (rocId == 5 ){ //sts0 n-side - if (nxId == 0) channel = ((nxChannel < 64) ? (253 - 2 * nxChannel + 4 * (nxChannel % 2)) : (255 - 2 * nxChannel)); // even - if (nxId == 2) channel = ((nxChannel < 64) ? (2 * nxChannel + 2 - 4 * (nxChannel % 2)) : (2 * nxChannel)); // odd - } - - - // station which was in until run53 -if ( fRun < 54) - { - if (rocId == 6) { //sts2 p-side - if (nxId == 0) channel = 128 - ((nxChannel < 64) ? (nxChannel + 2 * ((nxChannel + 1) % 2) - 1) : nxChannel); - } - - if (rocId == 7) { //sts2 n-side - if (nxId == 0) channel = 128 - ((nxChannel < 64) ? (127 - nxChannel) : (- nxChannel + 126 + 2 * (nxChannel % 2))); - } - } - else - { - - //station which is in since run54 - - if (rocId == 6) { //sts2 p-side - if(TMath::Even(nxChannel))nxChannel+=1;else nxChannel-=1; - if (nxId == 0) channel = nxChannel; - } - - if (rocId == 7) { //sts2 n-side - if(TMath::Even(nxChannel))nxChannel+=1;else nxChannel-=1; - if (nxId == 0) channel = nxChannel; - } - } - - return channel; -} -// --------------------------------------------------------------------------- - - -// ----- Get STS channel number ------------------------------------------ -Int_t CbmDaqMapCosy2014::GetFiberHodoChannel(Int_t /*rocId*/, Int_t /*nxId*/, Int_t /*nxChannel*/) { - Int_t channel = -1; - return channel; -} -// --------------------------------------------------------------------------- - - - -// ----- Mapping --------------------------------------------------------- -Bool_t CbmDaqMapCosy2014::Map(Int_t iRoc, Int_t iNx, Int_t iId, - Int_t& iStation, Int_t& iSector, - Int_t& iSide, Int_t& iChannel) -{ - // --- Valid ROC Id - if ( iRoc < 0 || iRoc >= fMaxNumRoc ) { - LOG(fatal) << GetName() << ": Invalid ROC id " << iRoc; - } - - // --- ROC 0 to 1: Hodoscope - if ( 0 == iRoc ) { - if ( iNx == 0) { - iStation = iRoc; - iSector = 0; - iSide = fFiberHodoPlane[iId]; - iChannel = fFiberHodoFiber[iId]; - return kTRUE; - } else { - LOG(fatal) << GetName() << ": Unknown Nxyter Id " << iNx - << " for Roc Id " << iRoc; - } - } else if ( 1 == iRoc ) { - if ( iNx-2 == 0) { - iStation = iRoc; - iSector = 0; - iSide = fFiberHodoPlane[iId]; - iChannel = fFiberHodoFiber[iId]; - return kTRUE; - } else { - LOG(fatal) << GetName() << ": Unknown Nxyter Id " << iNx - << " for Roc Id " << iRoc; - - } - // ROC 2 to 7: Sts - } else { - if ( iNx == 2 ) iNx = 1; // there is no nxyter 1, but there is a array index 1 - iStation = fRocToStsStation[iRoc]; - iSector = 0; - iSide = GetStsSensorSide(iRoc); - Int_t arrayIndex= iStation*2 + iRoc%2; - iChannel = fStsStrip[arrayIndex][iNx][iId]; - return kTRUE; - } - - return kTRUE; -} -// --------------------------------------------------------------------------- - -// --------------------------------------------------------------------------- -void CbmDaqMapCosy2014::InitializeFiberHodoMapping() -{ - // This code was copied from the Go4 analysis used for previous beamtimes - for (Int_t i=0; i<128; i++) { - fFiberHodoFiber[i] = -1; - fFiberHodoPlane[i] = -1; - fFiberHodoPixel[i] = -1; - } - - for (Int_t ifiber=1; ifiber<=64; ifiber++) { - // Calculate fiber number [1..64] from feb channel - // lcn: linearconnectornumber, is the wire number on one of the - // flat cables. [1..16] - // each 16 fibers go to one connector. - // fibersubnr[0..15] linear fiber counter in groups of 16 - - Int_t fibersubnr=(ifiber-1)%16; - - Int_t lcn=15-fibersubnr*2; - if (fibersubnr>=8) lcn=(fibersubnr-7)*2; - - Int_t channel=-1; - Int_t cable=(ifiber-1)/16+1; - Int_t pixel= ((lcn-1)/2)*8 +((lcn-1)%2); - if (cable==1) { - channel=(lcn-1)*4+0; - pixel=pixel+1; - } - if (cable==2) { - channel=(lcn-1)*4+2; - pixel=pixel+3; - } - if (cable==3) { - channel=(lcn-1)*4+1; - pixel=pixel+5; - } - if (cable==4) { - channel=(lcn-1)*4+3; - pixel=pixel+7; - } - - // new code to resolve cabling problem during cern-oct12 - int ifiber_bis = ifiber; - if (ifiber <= 8 ) ifiber_bis = ifiber + 56; else - if (ifiber <= 16 ) ifiber_bis = ifiber + 40; else - if (ifiber <= 24 ) ifiber_bis = ifiber + 24; else - if (ifiber <= 32 ) ifiber_bis = ifiber + 8; else - if (ifiber <= 40 ) ifiber_bis = ifiber - 8; else - if (ifiber <= 48 ) ifiber_bis = ifiber - 24; else - if (ifiber <= 56 ) ifiber_bis = ifiber - 40; else - if (ifiber <= 64 ) ifiber_bis = ifiber - 56; - - // and swap at the end - ifiber_bis = 65 - ifiber_bis; - - fFiberHodoFiber[channel] = ifiber_bis - 1; - fFiberHodoPlane[channel] = 0; - fFiberHodoPixel[channel] = pixel; - - fFiberHodoFiber[channel+64] = ifiber_bis - 1; - fFiberHodoPlane[channel+64] = 1; - fFiberHodoPixel[channel+64] = pixel; - - } - - for (Int_t i=0; i<128; i++) { - LOG(debug) << "Channel[" << i << "]: " << fFiberHodoFiber[i] << ", " - << fFiberHodoPlane[i] << ", " << fFiberHodoPixel[i]; - } - -} - -void CbmDaqMapCosy2014::InitializeRocToSystemArray() -{ - fRocToSystem[0] = ECbmModuleId::kHodo; - fRocToSystem[1] = ECbmModuleId::kHodo; - fRocToSystem[2] = ECbmModuleId::kSts; - fRocToSystem[3] = ECbmModuleId::kSts; - fRocToSystem[4] = ECbmModuleId::kSts; - fRocToSystem[5] = ECbmModuleId::kSts; - fRocToSystem[6] = ECbmModuleId::kSts; - fRocToSystem[7] = ECbmModuleId::kSts; -} - -void CbmDaqMapCosy2014::InitializeRocToStsStation() -{ - fRocToStsStation[0] = -1; - fRocToStsStation[1] = -1; - fRocToStsStation[2] = 0; - fRocToStsStation[3] = 0; - fRocToStsStation[4] = 2; - fRocToStsStation[5] = 2; - fRocToStsStation[6] = 1; - fRocToStsStation[7] = 1; -} - -void CbmDaqMapCosy2014::InitializeRocToHodoStation() -{ - fRocToHodoStation[0] = 0; - fRocToHodoStation[1] = 1; - fRocToHodoStation[2] = -1; - fRocToHodoStation[3] = -1; - fRocToHodoStation[4] = -1; - fRocToHodoStation[5] = -1; - fRocToHodoStation[6] = -1; - fRocToHodoStation[7] = -1; -} - -void CbmDaqMapCosy2014::InitializeStsMapping() -{ - - Int_t arrayIndex; - Int_t evenChannel; - Int_t oddChannel; - - // Fill Array for RocId 2 - // RocId 2 belongs to the first Roc of station 1 - // sts1 p-side - arrayIndex = 0; - for(Int_t nxChannel = 0; nxChannel < 128; ++nxChannel) { - evenChannel = 256 - ((nxChannel < 64) ? (2 * nxChannel - 4 * (nxChannel % 2) + 3) : (2 * nxChannel + 1)); // even - oddChannel = 256 - ((nxChannel < 64) ? (252 - 2 * nxChannel + 4 * (nxChannel % 2)) : (254 -2 * nxChannel)); // odd - - fStsStrip[arrayIndex][0][nxChannel] = evenChannel; - fStsStrip[arrayIndex][1][nxChannel] = oddChannel; - } - - // Fill Array for RocId 3 - // RocId 3 belongs to the second Roc of station 1 - // sts1 n-side - arrayIndex = 1; - for(Int_t nxChannel = 0; nxChannel < 128; ++nxChannel) { - evenChannel = 256 - ((nxChannel < 64) ? (253 - 2 * nxChannel + 4 * (nxChannel % 2)) : (255 - 2 * nxChannel)); // even - oddChannel = 256 - ((nxChannel < 64) ? (2 * nxChannel + 2 - 4 * (nxChannel % 2)) : (2 * nxChannel)); // odd - fStsStrip[arrayIndex][0][nxChannel] = evenChannel; - fStsStrip[arrayIndex][1][nxChannel] = oddChannel; - } - - // Fill Array for RocId 4 - // RocId 4 belongs to the first Roc of station 0 - // sts0 p-side - arrayIndex = 4; - for(Int_t nxChannel = 0; nxChannel < 128; ++nxChannel) { - evenChannel = ((nxChannel < 64) ? (2 * nxChannel - 4 * (nxChannel % 2) + 3) : (2 * nxChannel + 1)); // even - oddChannel = ((nxChannel < 64) ? (252 - 2 * nxChannel + 4 * (nxChannel % 2)) : (254 -2 * nxChannel)); // odd - fStsStrip[arrayIndex][0][nxChannel] = evenChannel; - fStsStrip[arrayIndex][1][nxChannel] = oddChannel; - } - - // Fill Array for RocId 5 - // RocId 5 belongs to the second Roc of station 0 - // sts0 n-side - arrayIndex = 5; - for(Int_t nxChannel = 0; nxChannel < 128; ++nxChannel) { - evenChannel = ((nxChannel < 64) ? (253 - 2 * nxChannel + 4 * (nxChannel % 2)) : (255 - 2 * nxChannel)); // even - oddChannel = ((nxChannel < 64) ? (2 * nxChannel + 2 - 4 * (nxChannel % 2)) : (2 * nxChannel)); // odd - fStsStrip[arrayIndex][0][nxChannel] = evenChannel; - fStsStrip[arrayIndex][1][nxChannel] = oddChannel; - } - - if ( fRun < 54 ) { - // Fill Array for RocId 6 - // RocId 6 belongs to the first Roc of station 3 - // sts3 p-side - arrayIndex = 2; - for(Int_t nxChannel = 0; nxChannel < 128; ++nxChannel) { - evenChannel = 128 - ((nxChannel < 64) ? (nxChannel + 2 * ((nxChannel + 1) % 2) - 1) : nxChannel); - fStsStrip[arrayIndex][0][nxChannel] = evenChannel; - fStsStrip[arrayIndex][1][nxChannel] = -1; - } - - // Fill Array for RocId 7 - // RocId 7 belongs to the second Roc of station 3 - // sts3 n-side - arrayIndex = 3; - for(Int_t nxChannel = 0; nxChannel < 128; ++nxChannel) { - evenChannel = 128 - ((nxChannel < 64) ? (127 - nxChannel) : (- nxChannel + 126 + 2 * (nxChannel % 2))); - fStsStrip[arrayIndex][0][nxChannel] = evenChannel; - fStsStrip[arrayIndex][1][nxChannel] = -1; - } - - } else { - // Fill Array for RocId 6 - // RocId 6 belongs to the first Roc of station 3 - // sts3 p-side - arrayIndex = 2; - for(Int_t nxChannel = 0; nxChannel < 128; ++nxChannel) { - fStsStrip[arrayIndex][0][nxChannel] = nxChannel; - fStsStrip[arrayIndex][1][nxChannel] = -1; - } - - // Fill Array for RocId 7 - // RocId 7 belongs to the second Roc of station 3 - // sts3 n-side - arrayIndex = 3; - for(Int_t nxChannel = 0; nxChannel < 128; ++nxChannel) { - fStsStrip[arrayIndex][0][nxChannel] = nxChannel; - fStsStrip[arrayIndex][1][nxChannel] = -1; - } - - } - - -} - -ClassImp(CbmDaqMapCosy2014) - diff --git a/beamtime/cosy2014/CbmDaqMapCosy2014.h b/beamtime/cosy2014/CbmDaqMapCosy2014.h deleted file mode 100644 index 3da7d39fb671b34b2165dcfc33f9ff251970d820..0000000000000000000000000000000000000000 --- a/beamtime/cosy2014/CbmDaqMapCosy2014.h +++ /dev/null @@ -1,108 +0,0 @@ -/**@file CbmDaqMap.h - **@date 03.012.2009 - **author V. Friese <v.friese@gsi.de> - ** - ** Provides the mapping of DAQ channel to detector channel - ** - ** At the moment: implemented only for STS stations - **/ - - - -#ifndef CBMDAQMAPCOSY2014_H -#define CBMDAQMAPCOSY2014_H 1 - -#include <Rtypes.h> // for ClassDef -#include <RtypesCore.h> // for Int_t, Bool_t -#include "CbmDaqMap.h" // for CbmDaqMap -#include "CbmDefs.h" - -#include <map> - -class CbmDaqMapCosy2014 : public CbmDaqMap -{ - - public: - - /** Default constructor **/ - CbmDaqMapCosy2014(); - - /** Standard constructor - **@param iRun run number - **/ - CbmDaqMapCosy2014(Int_t iRun); - - /** Destructor **/ - virtual ~CbmDaqMapCosy2014(); - - /** System Id from ROC Id **/ - ECbmModuleId GetSystemId(Int_t rocId); - - /** STS station from ROC Id **/ - Int_t GetStsStation(Int_t rocId); - - /** MUCH station from ROC Id **/ - Int_t GetMuchStation(Int_t rocId); - - /** Fiber Hodoscope station from ROC Id **/ - Int_t GetFiberHodoStation(Int_t rocId); - - /** STS sensor side from ROC and NXYTER Id **/ - Int_t GetStsSensorSide(Int_t rocId); - - /** STS channel from ROC, NXYTER and NXYTER channel **/ - Int_t GetStsChannel(Int_t rocId, Int_t nxId, Int_t nxChannel); - - /** Fiber Hodoscope channel from ROC, NXYTER and NXYTER channel **/ - Int_t GetFiberHodoChannel(Int_t rocId, Int_t nxId, Int_t nxChannel); - - - /** Mapping - **@param iRoc ROC number (from hit message) - **@param iNx NXYter number (from hit message) - **@param iId Channel ID (from hit message) - **@param iStation Station number (return) - **@param iSector Sector number ( return) - **@param iSide Front side (0) / Back side (1) ( return) - **@param iChannel Channel number (return) - **/ - Bool_t Map(Int_t iRoc, Int_t iNx, Int_t iId, - Int_t& iStation, Int_t& iSector, Int_t& iSide, Int_t& iChannel); - - - - private: - - void InitializeFiberHodoMapping(); - void InitializeStsMapping(); - void InitializeRocToSystemArray(); - void InitializeRocToStsStation(); - void InitializeRocToHodoStation(); - - static const Int_t fMaxNyterChannels=128; - static const Int_t fMaxNumRoc = 8; - static const Int_t fMaxStsRoc = 6; - - /** Mapping from fiber hodoscope feb channel to fiber number **/ - Int_t fFiberHodoFiber[fMaxNyterChannels]; - /** Mapping from fiber hodoscope feb channel to plane number 1=X, 2=Y **/ - Int_t fFiberHodoPlane[fMaxNyterChannels]; - /** Mapping from fiber hodoscope feb channel to pixel number **/ - Int_t fFiberHodoPixel[fMaxNyterChannels]; - - std::map<Int_t, ECbmModuleId> fRocToSystem; //! - Int_t fRocToStsStation[fMaxNumRoc]; //! - Int_t fRocToHodoStation[fMaxNumRoc]; //! - - // Sts strip from RocId, NxyterId, NxyterCh - Int_t fStsStrip[fMaxStsRoc][2][fMaxNyterChannels]; - - ClassDef(CbmDaqMapCosy2014,3); - -}; - -#endif - - - - diff --git a/beamtime/cosy2014/CbmDaqMapCosy2014Much.cxx b/beamtime/cosy2014/CbmDaqMapCosy2014Much.cxx deleted file mode 100644 index bfd4c6bff6c71ebade0c096afad3eaaf654b1c8b..0000000000000000000000000000000000000000 --- a/beamtime/cosy2014/CbmDaqMapCosy2014Much.cxx +++ /dev/null @@ -1,302 +0,0 @@ -/**@file CbmDaqMapCosy2014Much.cxx - **@date 16.12.2014 - **@author V. Friese <v.friese@gsi.de> - **/ -#include "CbmDaqMapCosy2014Much.h" - -#include <TMathBase.h> // for Even -#include <FairLogger.h> // for Logger, LOG -#include <iostream> // for cout, endl -#include "CbmDefs.h" // for kHodo, kMuch -#include "MuchRealSize.h" // for xl, yl - -using std::cout; -using std::endl; - -// ----- Default Constructor ---------------------------------------------- -CbmDaqMapCosy2014Much::CbmDaqMapCosy2014Much() - : CbmDaqMap(), - fFiberHodoFiber(), - fFiberHodoPlane(), - fFiberHodoPixel() -{ - InitializeFiberHodoMapping(); -} -// --------------------------------------------------------------------------- - - - -// ----- Standard Constructor --------------------------------------------- -CbmDaqMapCosy2014Much::CbmDaqMapCosy2014Much(Int_t iRun) - : CbmDaqMap(iRun), - fFiberHodoFiber(), - fFiberHodoPlane(), - fFiberHodoPixel() -{ - InitializeFiberHodoMapping(); -} -// --------------------------------------------------------------------------- - - - -// ----- Destructor ------------------------------------------------------ -CbmDaqMapCosy2014Much::~CbmDaqMapCosy2014Much() { } -// --------------------------------------------------------------------------- - - -// ----- Get System ------------------------------------------------------ -ECbmModuleId CbmDaqMapCosy2014Much::GetSystemId(Int_t rocId) -{ - ECbmModuleId systemId = ECbmModuleId::kNotExist; - - // --- ROC 0 and 1 are MUCH - if ( rocId >= 0 && rocId <= 2 ) systemId = ECbmModuleId::kMuch; - // --- ROC 3 is HODO - else if ( rocId == 3 ) systemId = ECbmModuleId::kHodo; - // --- other ROC ids will be ignored - else { - //LOG(warn) << GetName() << ": Unknown ROC id " << rocId - //; - } - - return systemId; -} -// --------------------------------------------------------------------------- - - -// ----- Get STS station number ------------------------------------------ -Int_t CbmDaqMapCosy2014Much::GetStsStation(Int_t rocId) -{ - if ( rocId == 2 || rocId == 3 ) { - return 1; - } else if ( rocId == 4 || rocId == 5 ) { - return 0; - } else if ( rocId == 6 || rocId == 7 ) { - return 2; - } else { - LOG(error) << GetName() << ": Illegal STS ROC Id " << rocId; - return -1; - } -} -// --------------------------------------------------------------------------- - - -// ----- Get MUCH station number ------------------------------------------ -Int_t CbmDaqMapCosy2014Much::GetMuchStation(Int_t rocId) { - Int_t station = -1; - if ( rocId == 0 || rocId == 1 ) station = 0; - else if ( rocId == 2 ) station = 1; - else if ( rocId == 3 || rocId == 4 ) station = 2; - else LOG(error) << GetName() << ": Illegal MUCH ROC Id " << rocId; - return station; -} -// --------------------------------------------------------------------------- - -// ----- Get Fiber Hodoscope station number ------------------------------ -Int_t CbmDaqMapCosy2014Much::GetFiberHodoStation(Int_t rocId) { - if ( rocId < 0 || rocId > 1 ) { - LOG(error) << GetName() << ": Illegal Fiber Hodoscope ROC Id " << rocId; - return -1; - } - return ( rocId ); -} -// --------------------------------------------------------------------------- - - - -// ---- Get STS sensor side ----------------------------------------------- -Int_t CbmDaqMapCosy2014Much::GetStsSensorSide(Int_t rocId) { - return ( TMath::Even(rocId) ? 1 : 0 ); -} -// --------------------------------------------------------------------------- - -// ----- Get STS channel number ------------------------------------------ -Int_t CbmDaqMapCosy2014Much::GetStsChannel(Int_t rocId, Int_t nxId, Int_t nxChannel) { - - Int_t channel = -1; - - if (rocId == 2){ //sts1 p-side - if (nxId == 0) channel = 256 - ((nxChannel < 64) ? (2 * nxChannel - 4 * (nxChannel % 2) + 3) : (2 * nxChannel + 1)); // even - if (nxId == 2) channel = 256 - ((nxChannel < 64) ? (252 - 2 * nxChannel + 4 * (nxChannel % 2)) : (254 -2 * nxChannel)); // odd - } - - if (rocId == 3){ //sts1 n-side - if (nxId == 0) channel = 256 - ((nxChannel < 64) ? (253 - 2 * nxChannel + 4 * (nxChannel % 2)) : (255 - 2 * nxChannel)); // even - if (nxId == 2) channel = 256 - ((nxChannel < 64) ? (2 * nxChannel + 2 - 4 * (nxChannel % 2)) : (2 * nxChannel)); // odd - } - - if (rocId == 4 ){ //sts0 p-side - if (nxId == 0) channel = ((nxChannel < 64) ? (2 * nxChannel - 4 * (nxChannel % 2) + 3) : (2 * nxChannel + 1)); // even - if (nxId == 2) channel = ((nxChannel < 64) ? (252 - 2 * nxChannel + 4 * (nxChannel % 2)) : (254 -2 * nxChannel)); // odd - } - - if (rocId == 5 ){ //sts0 n-side - if (nxId == 0) channel = ((nxChannel < 64) ? (253 - 2 * nxChannel + 4 * (nxChannel % 2)) : (255 - 2 * nxChannel)); // even - if (nxId == 2) channel = ((nxChannel < 64) ? (2 * nxChannel + 2 - 4 * (nxChannel % 2)) : (2 * nxChannel)); // odd - } - - if (rocId == 6) { //sts2 p-side - if (nxId == 0) channel = 128 - ((nxChannel < 64) ? (nxChannel + 2 * ((nxChannel + 1) % 2) - 1) : nxChannel); - } - - if (rocId == 7) { //sts2 n-side - if (nxId == 0) channel = 128 - ((nxChannel < 64) ? (127 - nxChannel) : (- nxChannel + 126 + 2 * (nxChannel % 2))); - } - - return channel; -} -// --------------------------------------------------------------------------- - - -// ----- Get STS channel number ------------------------------------------ -Int_t CbmDaqMapCosy2014Much::GetFiberHodoChannel(Int_t /*rocId*/, Int_t /*nxId*/, Int_t /*nxChannel*/) { - Int_t channel = -1; - return channel; -} -// --------------------------------------------------------------------------- - - - -// ----- Mapping --------------------------------------------------------- -Bool_t CbmDaqMapCosy2014Much::Map(Int_t iRoc, Int_t iNx, Int_t iId, - Int_t& iStation, Int_t& iSector, - Int_t& iSide, Int_t& iChannel) { - - // --- ROC 3: Hodoscope - if ( 3 == iRoc ) { - if ( iNx-2 == 0) { - iStation = 1; - iSector = 0; - iSide = fFiberHodoPlane[iId]; - iChannel = fFiberHodoFiber[iId]; - return kTRUE; - } else { - LOG(fatal) << GetName() << ": Unknown Nxyter Id " << iNx - << " for Roc Id " << iRoc; - } - LOG(info) << "Map: HODO station " << iStation << " sector " << iSector - << " side " << iSide << " channel " << iChannel; - } - - // -- ROC 0 to 1: MUCH Station - else if ( iRoc == 0 || iRoc == 1 ) { - - // Get FEB number - Int_t febId = GetFebId(iRoc, iNx); - if ( febId < 0 || febId > 14 ) { - LOG(fatal) << "Illegal FEB ID " << febId << "( ROC " << iRoc - << ", NXYTER " << iNx << ")"; - return kFALSE; - } - - // Get pad x coordinate - Int_t xPad = xl[febId][iId]; - - // Get pad y coordinate - Int_t yPad = yl[febId][iId]; - - // Return values - iStation = 0; - iSector = 0; - iSide = xPad; - iChannel = yPad; - - - return kTRUE; - - } - - return kTRUE; -} -// --------------------------------------------------------------------------- - - -// --- Get FEB ID ----------------------------------------------------------- -Int_t CbmDaqMapCosy2014Much::GetFebId(Int_t rocId, Int_t nxyterId) { - - if ( rocId == 0 && nxyterId == 0) return 0; - if ( rocId == 0 && nxyterId == 2) return 1; - if ( rocId == 1 && nxyterId == 0) return 4; - if ( rocId == 1 && nxyterId == 2) return 2; - - return -1; - -} -// --------------------------------------------------------------------------- - - -// --------------------------------------------------------------------------- -void CbmDaqMapCosy2014Much::InitializeFiberHodoMapping() -{ - // This code was copied from the Go4 analysis used for previous beamtimes - for (Int_t i=0; i<128; i++) { - fFiberHodoFiber[i] = -1; - fFiberHodoPlane[i] = -1; - fFiberHodoPixel[i] = -1; - } - - for (Int_t ifiber=1; ifiber<=64; ifiber++) { - // Calculate fiber number [1..64] from feb channel - // lcn: linearconnectornumber, is the wire number on one of the - // flat cables. [1..16] - // each 16 fibers go to one connector. - // fibersubnr[0..15] linear fiber counter in groups of 16 - - Int_t fibersubnr=(ifiber-1)%16; - - Int_t lcn=15-fibersubnr*2; - if (fibersubnr>=8) lcn=(fibersubnr-7)*2; - - Int_t channel=-1; - Int_t cable=(ifiber-1)/16+1; - Int_t pixel= ((lcn-1)/2)*8 +((lcn-1)%2); - if (cable==1) { - channel=(lcn-1)*4+0; - pixel=pixel+1; - } - if (cable==2) { - channel=(lcn-1)*4+2; - pixel=pixel+3; - } - if (cable==3) { - channel=(lcn-1)*4+1; - pixel=pixel+5; - } - if (cable==4) { - channel=(lcn-1)*4+3; - pixel=pixel+7; - } - - // new code to resolve cabling problem during cern-oct12 - int ifiber_bis = ifiber; - if (ifiber <= 8 ) ifiber_bis = ifiber + 56; else - if (ifiber <= 16 ) ifiber_bis = ifiber + 40; else - if (ifiber <= 24 ) ifiber_bis = ifiber + 24; else - if (ifiber <= 32 ) ifiber_bis = ifiber + 8; else - if (ifiber <= 40 ) ifiber_bis = ifiber - 8; else - if (ifiber <= 48 ) ifiber_bis = ifiber - 24; else - if (ifiber <= 56 ) ifiber_bis = ifiber - 40; else - if (ifiber <= 64 ) ifiber_bis = ifiber - 56; - - // and swap at the end - ifiber_bis = 65 - ifiber_bis; - - fFiberHodoFiber[channel] = ifiber_bis - 1; - fFiberHodoPlane[channel] = 0; - fFiberHodoPixel[channel] = pixel; - - fFiberHodoFiber[channel+64] = ifiber_bis - 1; - fFiberHodoPlane[channel+64] = 1; - fFiberHodoPixel[channel+64] = pixel; - - } - - for (Int_t i=0; i<128; i++) { - LOG(debug) << "Channel[" << i << "]: " << fFiberHodoFiber[i] << ", " - << fFiberHodoPlane[i] << ", " << fFiberHodoPixel[i]; - } - -} - -ClassImp(CbmDaqMapCosy2014Much) - diff --git a/beamtime/cosy2014/CbmDaqMapCosy2014Much.h b/beamtime/cosy2014/CbmDaqMapCosy2014Much.h deleted file mode 100644 index ccfebd3c0132dcdcccfbb25351576ccbf0e7dc65..0000000000000000000000000000000000000000 --- a/beamtime/cosy2014/CbmDaqMapCosy2014Much.h +++ /dev/null @@ -1,92 +0,0 @@ -/**@file CbmDaqMapCosy2014Much.h - **@date 16.12.2014 - **author V. Friese <v.friese@gsi.de> - ** - ** Provides the mapping of DAQ channel to detector channel - ** - ** Valid for the MUCH setup of COSY beam test DEC 2014 - **/ - - - -#ifndef CBMDAQMAPCOSY2014MUCH_H -#define CBMDAQMAPCOSY2014MUCH_H 1 - -#include <Rtypes.h> // for ClassDef -#include <RtypesCore.h> // for Int_t, Bool_t -#include "CbmDaqMap.h" // for CbmDaqMap - -class CbmDaqMapCosy2014Much : public CbmDaqMap -{ - - public: - - /** Default constructor **/ - CbmDaqMapCosy2014Much(); - - /** Standard constructor - **@param iRun run number - **/ - CbmDaqMapCosy2014Much(Int_t iRun); - - /** Destructor **/ - virtual ~CbmDaqMapCosy2014Much(); - - /** System Id from ROC Id **/ - ECbmModuleId GetSystemId(Int_t rocId); - - /** STS station from ROC Id **/ - Int_t GetStsStation(Int_t rocId); - - /** MUCH station from ROC Id **/ - Int_t GetMuchStation(Int_t rocId); - - /** Fiber Hodoscope station from ROC Id **/ - Int_t GetFiberHodoStation(Int_t rocId); - - /** STS sensor side from ROC and NXYTER Id **/ - Int_t GetStsSensorSide(Int_t rocId); - - /** STS channel from ROC, NXYTER and NXYTER channel **/ - Int_t GetStsChannel(Int_t rocId, Int_t nxId, Int_t nxChannel); - - /** Fiber Hodoscope channel from ROC, NXYTER and NXYTER channel **/ - Int_t GetFiberHodoChannel(Int_t rocId, Int_t nxId, Int_t nxChannel); - - - /** Mapping - **@param iRoc ROC number (from hit message) - **@param iNx NXYter number (from hit message) - **@param iId Channel ID (from hit message) - **@param iStation Station number (return) - **@param iSector Sector number ( return) - **@param iSide Front side (0) / Back side (1) ( return) - **@param iChannel Channel number (return) - **/ - Bool_t Map(Int_t iRoc, Int_t iNx, Int_t iId, - Int_t& iStation, Int_t& iSector, Int_t& iSide, Int_t& iChannel); - - - - private: - - void InitializeFiberHodoMapping(); - - // --- Get FEB ID (used in the channel map) from ROC and NXYTER ID - Int_t GetFebId(Int_t rocId, Int_t nxyterId); - - Int_t fFiberHodoFiber[128]; /** Mapping from fiber hodoscope feb channel to fiber number **/ - Int_t fFiberHodoPlane[128]; /** Mapping from fiber hodoscope feb channel to plane number 1=X, 2=Y **/ - Int_t fFiberHodoPixel[128]; /** Mapping from fiber hodoscope feb channel to pixel number **/ - - - - ClassDef(CbmDaqMapCosy2014Much,1); - -}; - -#endif - - - - diff --git a/beamtime/cosy2014/CbmLmdDebug.cxx b/beamtime/cosy2014/CbmLmdDebug.cxx deleted file mode 100644 index a413afcbc6fa55b1e540fd2f1a4a4e8cf9780366..0000000000000000000000000000000000000000 --- a/beamtime/cosy2014/CbmLmdDebug.cxx +++ /dev/null @@ -1,231 +0,0 @@ - /** @file CbmLmdDebug.cxx - ** @author Volker Friese <v.friese@gsi.de> - ** @date 17.12.2014 - **/ -#include "CbmLmdDebug.h" -#include <TMathBase.h> // for Max -#include <TString.h> // for TString -#include <FairLogger.h> // for Logger, LOG -#include <stddef.h> // for NULL -#include <iomanip> // for setw, __iom_t6, setprecision, __iom_t5 -#include <iostream> // for right, fixed -#include <TStopwatch.h> // for TStopwatch -#include "roc/Iterator.h" // for Iterator -#include "roc/Message.h" // for Message, MSG_AUX, MSG_EPOCH, MSG_HIT - -using namespace std; - -// ----- Constructor --------------------------------------------------- -CbmLmdDebug::CbmLmdDebug(const char* fileName) : - fLmdFileName(fileName), - fRocIter(), - fCurrentMessage(), - fCurrentEpoch(), - fNofHitNxy(), - fNofSync(), - fLastMsgType(-1), - fLastMsgRocId(-1), - fLastMsgNxyId(-1), - fLastMsgTime(0), - fTimeStart(0), - fTimeStop(0), - fMaxTimeDisorder(0) -{ - for (Int_t iType = 0; iType < 8; iType++) fNofMsgType[iType] = 0; - Init(); -} -// ------------------------------------------------------------------------- - - -// ----- Destructor ---------------------------------------------------- -CbmLmdDebug::~CbmLmdDebug() { -} -// ------------------------------------------------------------------------- - - - -// ----- Initialisation ------------------------------------------------ -Bool_t CbmLmdDebug::Init() { - - // --- Open input file - fRocIter = new roc::Iterator(fLmdFileName.Data()); - - // --- Get first message - if ( ! fRocIter->next() ) { - LOG(error) << GetName() << "::Init: input file does not exist " - << "or is empty!"; - return kFALSE; - } - fCurrentMessage = &fRocIter->msg(); - - return kTRUE; -} -// ------------------------------------------------------------------------- - - -// ----- Execution ----------------------------------------------------- -Int_t CbmLmdDebug::Run(Int_t maxMessages) { - - // --- Message counter and time - TStopwatch timer; - timer.Start(); - Int_t nMessages = 0; - - // --- Signal end of file if there are no more messages - if ( ! fCurrentMessage ) { - LOG(info) << GetName() << ": End of input file reached."; - return nMessages; - } - - // --- Message loop - while ( fCurrentMessage ) { - nMessages++; - - // --- Message type, ROC and NXYTER ID - Int_t msgType = fCurrentMessage->getMessageType(); - Int_t rocId = fCurrentMessage->getRocNumber(); - Int_t nxyId = fCurrentMessage->getNxNumber(); - - // --- If EPOCH message: update current epoch for the ROC - if ( fCurrentMessage->isEpochMsg() ) { - fCurrentEpoch[rocId] = fCurrentMessage->getEpochNumber(); - LOG(debug2) << "EPOCH " << fCurrentMessage->getEpochNumber() - << " for ROC " << rocId; - } - - - // --- Message type counter - fNofMsgType[msgType]++; - - // --- Hit counter per NXYTER - if ( fCurrentMessage->isHitMsg() ) { - pair<Int_t, Int_t> rocnx(rocId, nxyId); - fNofHitNxy[rocnx]++; - } - - // --- Sync counter per ROC - if ( fCurrentMessage->isSyncMsg() ) fNofSync[rocId]++; - - // --- Message full time - ULong_t msgTime = fCurrentMessage->getMsgFullTime(fCurrentEpoch[rocId]); - - - // --- Update run start and stop time - if ( nMessages == 1 ) fTimeStart = msgTime; - fTimeStop = TMath::Max(fTimeStop, msgTime); - - // --- Message to screen for proper LOG level - switch ( msgType ) { - case roc::MSG_SYNC: - LOG(debug) << "SYNC Message at t = " << msgTime << " ROC " << rocId - << " NXYTER " << nxyId; break; - case roc::MSG_SYS: - LOG(debug) << "SYS Message at t = " << msgTime << " ROC " << rocId - << " NXYTER " << nxyId; break; - case roc::MSG_EPOCH: - LOG(debug1) << "EPOCH Message at t = " << msgTime << " ROC " << rocId - << " NXYTER " << nxyId << " epoch number " - << fCurrentMessage->getEpochNumber(); break; - case roc::MSG_HIT: - LOG(debug2) << "HIT Message at t = " << msgTime << " ROC " << rocId - << " NXYTER " << nxyId; break; - case roc::MSG_AUX: - LOG(debug2) << "AUX Message at t = " << msgTime << " ROC " << rocId - << " NXYTER " << nxyId; break; - default: break; - } - - // --- Compare time to previous message - Long64_t tDif = fLastMsgTime - msgTime; - if ( tDif > 0 ) { // Message is before previous message - fMaxTimeDisorder = TMath::Max(fMaxTimeDisorder, tDif); - if ( tDif > 1e5 ) { - LOG(debug3) << "Time disorder by " << tDif << " ns "; - LOG(debug3) << "Previous message: type " << fLastMsgType - << " ROC " << fLastMsgRocId << " NXYTER " << fLastMsgNxyId - << " time " << fLastMsgTime; - LOG(debug3) << "Current message: type " << msgType - << " ROC " << rocId << " NXYTER " << nxyId - << " time " << msgTime; - } //? disorder > 100 mus - } //? message before previous message - - // --- Store message info for comparison - SetLastMessage(); - - // --- Get next ROC message - if ( fRocIter->next() ) fCurrentMessage = &fRocIter->msg(); - else fCurrentMessage = NULL; - - // --- Stop if required number of messages are read - if ( maxMessages >= 0 && nMessages >= maxMessages ) break; - } // message loop - - - timer.Stop(); - LOG(info) << "End of run; " << nMessages << " messages read"; - LOG(info) << "Start time : " << fixed << setprecision(4) << fTimeStart * 1.e-9 << " s "; - LOG(info) << "Stop time : " << fTimeStop * 1.e-9 << " s "; - Double_t deltaT = (fTimeStop - fTimeStart) / 1.e9; - LOG(info) << "Duration : " << deltaT << " s"; - - LOG(info) << "Max. time disorder " << fMaxTimeDisorder << " ns "; - PrintStats(); - LOG(info) << "CPU time " << timer.CpuTime() << " s, real time " - << timer.RealTime() << " s"; - return nMessages; -} -// ------------------------------------------------------------------------- - - - -/// ----- Statistics ---------------------------------------------------- -void CbmLmdDebug::PrintStats() { - - // --- Messages per Type - const char* names[8] - = { "NOP", "HIT", "EPOCH", "SYNC", "AUX", "EPOCH2", "GET4", "SYS" }; - LOG(info); - LOG(info) << "Messages per message type: "; - for (Int_t i=0; i<8; i++) - LOG(info) << setw(6) << names[i] << " " - << setw(10) << right << fNofMsgType[i]; - - // --- Hit messages per NXYTER - LOG(info); - LOG(info) << "Hit messages per ROC/NXYTER: "; - map<pair<Int_t, Int_t>, UInt_t>::iterator itHit; - for (itHit = fNofHitNxy.begin(); itHit != fNofHitNxy.end(); itHit++) { - Int_t rocId = itHit->first.first; - Int_t nxyId = itHit->first.second; - UInt_t nMsg = itHit->second; - LOG(info) << " ROC " << setw(2) << rocId << " NXYTER " << nxyId - << " HIT " << setw(12) << right << nMsg; - } - - // --- Sync messages per ROC - LOG(info); - LOG(info) << "Sync messages per ROC: "; - map<Int_t, UInt_t>::iterator itSync; - for (itSync = fNofSync.begin(); itSync != fNofSync.end(); itSync++) { - Int_t rocId = itSync->first; - UInt_t nMsg = itSync->second; - LOG(info) << " ROC " << setw(2) << rocId - << " SYNC " << setw(12) << right << nMsg; - } - LOG(info); - -} -// ------------------------------------------------------------------------- - - -// ----- Store message info -------------------------------------------- -void CbmLmdDebug::SetLastMessage() { - fLastMsgType = fCurrentMessage->getMessageType(); - fLastMsgRocId = fCurrentMessage->getRocNumber(); - fLastMsgNxyId = fCurrentMessage->getNxNumber(); - fLastMsgTime = fCurrentMessage->getMsgFullTime(fCurrentEpoch[fLastMsgRocId]); -} -// ------------------------------------------------------------------------- - -ClassImp(CbmLmdDebug) diff --git a/beamtime/cosy2014/CbmLmdDebug.h b/beamtime/cosy2014/CbmLmdDebug.h deleted file mode 100644 index 56de3f6008833a2912daa0e6b910e6cb9b4f15fc..0000000000000000000000000000000000000000 --- a/beamtime/cosy2014/CbmLmdDebug.h +++ /dev/null @@ -1,86 +0,0 @@ -/** @file CbmLmdDebug.h - ** @author Volker Friese <v.friese@gsi.de> - ** @date 17.12.2014 - **/ - -#ifndef CBMLMDDEBUG_H -#define CBMLMDDEBUG_H 1 - -#include <Rtypes.h> // for ClassDef -#include <RtypesCore.h> // for Int_t, UInt_t, ULong_t, Bool_t, Long64_t -#include <stdint.h> // for uint32_t -#include <map> // for map -#include <utility> // for pair -#include <TObject.h> // for TObject -#include <TString.h> // for TString - -namespace roc { class Iterator; } -namespace roc { class Message; } - -/** @class CbmLmdDebug - ** @brief Read and analyse message stream from lmd file - ** @author Volker Friese <v.friese@gsi.de> - ** @since 17.12.2014 - ** @version 1.0 - ** - ** This lightweight class reads messages from a lmd file and does some - ** basic statistics and log output for debugging purposes. - **/ -class CbmLmdDebug: public TObject { - - public: - - CbmLmdDebug(const char* fileName = ""); - - virtual ~CbmLmdDebug(); - - /** Initialisation **/ - virtual Bool_t Init(); - - /** Execution - ** @param nMessages Messages to be read. -1 means all in the file. - **/ - virtual Int_t Run(Int_t nMessages = -1); - - - private: - - TString fLmdFileName; ///< Name of input lmd file - roc::Iterator* fRocIter; ///< ROC iterator - roc::Message* fCurrentMessage; //! Current ROC message - - /** Current epoch marker for each ROC **/ - std::map<Int_t, uint32_t> fCurrentEpoch; - - // Counters - UInt_t fNofMsgType[8]; ///< Messages per type - std::map<std::pair<Int_t, Int_t>, UInt_t> fNofHitNxy; ///< Hit messages per NXYTER - std::map<Int_t, UInt_t> fNofSync; ///< Sync messages per ROC - - // Last message info - Int_t fLastMsgType; - Int_t fLastMsgRocId; - Int_t fLastMsgNxyId; - ULong_t fLastMsgTime; - - // Run start and end time - ULong_t fTimeStart; - ULong_t fTimeStop; - - Long64_t fMaxTimeDisorder; ///< Maximal time disordering of messages - - - // Print statistics - void PrintStats(); - - // Store message info - void SetLastMessage(); - - CbmLmdDebug(const CbmLmdDebug&); - CbmLmdDebug& operator=(const CbmLmdDebug&); - - ClassDef(CbmLmdDebug,1); - -}; - -#endif /* CBMLMDDEBUG_H */ diff --git a/beamtime/cosy2014/CbmRocSource.cxx b/beamtime/cosy2014/CbmRocSource.cxx deleted file mode 100644 index 29b517af043c0e55810b62179489f87c4f341249..0000000000000000000000000000000000000000 --- a/beamtime/cosy2014/CbmRocSource.cxx +++ /dev/null @@ -1,361 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmRocSource ----- -// ----- Created 01.11.2013 by F. Uhlig ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#include "CbmRocSource.h" -#include "CbmDaqMap.h" -#include "much/CbmMuchAddress.h" -#include "fhodo/CbmFiberHodoAddress.h" -#include "CbmDetectorList.h" -#include "CbmHistManager.h" - -#include "FairLogger.h" -#include "FairRunOnline.h" - -#include "TH1D.h" -#include "TCanvas.h" - -#include <boost/lexical_cast.hpp> - -#include <iostream> -#include <iomanip> - -using std::cout; -using std::endl; -using std::map; - -CbmRocSource::CbmRocSource() - : FairSource(), - fInputFileName(""), - fNofMessages(0), - fRocIter(NULL), - fCurrentMessage(NULL), - fHM(NULL) -{ -} - -CbmRocSource::CbmRocSource(const char * inFile) - : FairSource(), - fInputFileName(inFile), - fNofMessages(0), - fRocIter(NULL), - fCurrentMessage(NULL), - fHM(NULL) -{ -} - - -CbmRocSource::CbmRocSource(const CbmRocSource& source) - : FairSource(source) -{ -} - - -CbmRocSource::~CbmRocSource() -{ - delete fDaqMap; -} - - -Bool_t CbmRocSource::Init() -{ - - cout << endl << endl; - LOG(info) << "===== " << GetName() << ": Intialising ..."; - - fDaqMap = new CbmDaqMap(); - - for (Int_t iRoc = 7; iRoc < 13; iRoc++) - LOG(info) << "ROC " << iRoc << " Station " << fDaqMap->GetStsStation(iRoc); - - - // Check and open input file - LOG(info) << "===== Opening file " << fInputFileName; - fRocIter = new roc::Iterator(fInputFileName.Data()); - - if ( ! fRocIter->next() ) { - LOG(error) << GetName() << "::Init: input file does not exist " - << "or is empty!"; - return kFALSE; - } - fCurrentMessage = &fRocIter->msg(); - fNofMessages++; - - // Initialise counters - for (Int_t iType = 0; iType < 8; iType++) fNofMessType[iType] = 0; - for (Int_t iRoc = 0; iRoc < 20; iRoc++) - for (Int_t iNx = 0; iNx < 5; iNx++ ) - fNofMessRoc[iRoc][iNx] = 0; - fTimeStart = 0; - fTimeStop = 0; - - // Create histogram - fHM = new CbmHistManager(); - string xy[2] = {"X","Y"}; - string name = "Hodo"; - string name1, name2; - for (Int_t i=0; i<2; ++i) { - for (Int_t j=0; j<2; ++j) { - name1 = name + boost::lexical_cast<std::string>(i) + xy[j]; - name2 = name1 + ";Fiber number; Counts"; - fHM->Add(name1, new TH1D(name1.c_str(), name2.c_str(), 64, 0., 64. )); - } - } - fHM->Add("HitTime", new TH1D("HitTime", "Hit time", 4000, 8., 12. )); - - LOG(info) << "===== Initialisation done. "; - - return kTRUE; -} - - - - -Int_t CbmRocSource::ReadEvent() -{ - - LOG(info) << "Read event " << fNofMessages; - - - // No action if no message available - if ( ! fCurrentMessage ) { - LOG(error) << "No more messages in input file."; - return 1; - } - - const char* names[8] = { "NOP", "HIT", "EPOCH", "SYNC", "AUX", "EPOCH2", "GET4", "SYS" }; - Int_t nMessages = 0; - - - // --- Loop over messages until event end - while (fCurrentMessage) { - - // --- ROC and NXYTER Id and message type - uint8_t type = fCurrentMessage->getMessageType(); - Int_t rocId = fCurrentMessage->getRocNumber(); - //LOG(info) << "Message " << nMessages << " " << type - // << " " << rocId << " "; - - - // ---- Do some statistics - nMessages++; - if ( type >= 0 && type < 8 ) fNofMessType[type]++; - - // --- Treat epoch markers - if ( fCurrentMessage->isEpochMsg() ) ProcessEpochMarker(); - - - // --- Hit messages - if ( fCurrentMessage->isHitMsg() ) { - - // --- Increase counters - Int_t nxId = fCurrentMessage->getNxNumber(); - fNofMessRoc[rocId][nxId]++; - - // --- A hit message should be preceded by an epoch marker - if ( fCurrentEpoch.find(rocId) == fCurrentEpoch.end() ) { - LOG(fatal) << GetName() - << ": Hit message without previous epoch marker for ROC " - << rocId; - } - - // --- Get system identifier - Int_t systemId = fDaqMap->GetSystemId(rocId); - - // --- Treat MUCH messages - switch (systemId) { - case kSTS: ProcessStsMessage(); break; - case kMUCH: ProcessMuchMessage(); break; - case kFHODO: ProcessHodoMessage(); break; - default: break; - } - - - } // ? Hit message - - - // Next ROC message - if ( fRocIter->next() ) fCurrentMessage = &fRocIter->msg(); - else fCurrentMessage = NULL; - - } // Message loop - - LOG(info) << "Messages read: " << nMessages; - for (Int_t i=0; i<8; i++) - LOG(info) << setw(6) << names[i] << " " - << setw(10) << right << fNofMessType[i]; - - - Double_t deltaT = (fTimeStop - fTimeStart) / 1.e9; - LOG(info) << "Start time : " << fTimeStart * 1.e-9 << " s "; - LOG(info) << "Stop time : " << fTimeStop * 1.e-9 << " s "; - LOG(info) << "Duration : " << deltaT << " s"; - - for (Int_t iRoc = 0; iRoc < 13; iRoc ++) - for (Int_t iNx = 0; iNx < 3; iNx +=2 ) { - LOG(info) << " ROC " << setw(2) << iRoc << " NXYTER " << iNx << " Messages " - << setw(12) << right << fNofMessRoc[iRoc][iNx] << " Rate " - << setw(12) << setprecision(4) << fixed << right - << Double_t(fNofMessRoc[iRoc][iNx]) / deltaT - << " /s "; - } - - TCanvas* c1 = new TCanvas("c1", "First canvas", 800, 600); - c1->Divide(2,3); - c1->cd(1); - fHM->H1("HitTime")->Draw(); - c1->cd(3); - fHM->H1("Hodo0X")->Draw(); - c1->cd(4); - fHM->H1("Hodo0Y")->Draw(); - c1->cd(5); - fHM->H1("Hodo1X")->Draw(); - c1->cd(6); - fHM->H1("Hodo1Y")->Draw(); - c1->Update(); - return 1; -} - - -// ----- Process an epoch marker ---------------------------------------- -void CbmRocSource::ProcessEpochMarker() { - - Int_t rocId = fCurrentMessage->getRocNumber(); - fCurrentEpoch[rocId] = fCurrentMessage->getEpochNumber(); - if ( rocId ) return; // Further action only for ROC Id 0 - - fCurrentEpochTime = fCurrentMessage->getMsgFullTime(fCurrentEpoch[rocId]); - fNofEpochs++; - LOG(debug) << GetName() << ": Epoch message " - << fNofEpochs << ", epoch " << Int_t(fCurrentEpoch[rocId]) - << ", time " << std::setprecision(9) << std::fixed - << fCurrentEpochTime << " s"; - - // --- Start and stop time - if ( fTimeStart == 0 || fTimeStart > fCurrentEpochTime ) - fTimeStart = fCurrentEpochTime; - if ( fTimeStop < fCurrentEpochTime ) fTimeStop = fCurrentEpochTime; - -} -// -------------------------------------------------------------------------- - - - -// ----- Process a HODO hit message ------------------------------------- -void CbmRocSource::ProcessHodoMessage() -{ - // --- Get absolute time, NXYTER and channel number - Int_t rocId = fCurrentMessage->getRocNumber(); - ULong_t hitTime = fCurrentMessage->getMsgFullTime(fCurrentEpoch[rocId]); - Int_t nxyterId = fCurrentMessage->getNxNumber(); - Int_t nxChannel = fCurrentMessage->getNxChNum(); - Int_t charge = fCurrentMessage->getNxAdcValue(); - - Int_t iStation; - Int_t iSector; - Int_t iPlane; - Int_t iFiber; - - fDaqMap->Map(rocId, nxyterId, nxChannel, iStation, iSector, iPlane, iFiber); - - if (iStation == 1) { - if (iPlane == 1) { - fHM->H1("Hodo1X")->Fill(iFiber); - } else { - fHM->H1("Hodo1Y")->Fill(iFiber); - } - } else { - if (iPlane == 1) { - fHM->H1("Hodo0X")->Fill(iFiber); - } else { - fHM->H1("Hodo0Y")->Fill(iFiber); - } - } - - - LOG(debug) << "Roc, Nxyter, Channel: " << rocId << ", " << nxyterId - << ", " << nxChannel; - LOG(debug) << "Station, Plane, Fiber: " << iStation << ", " << iPlane - << ", " << iFiber; - -} -// -------------------------------------------------------------------------- - - - -// ----- Process a MUCH hit message ------------------------------------- -void CbmRocSource::ProcessMuchMessage() { - - // --- Get absolute time, NXYTER and channel number - Int_t rocId = fCurrentMessage->getRocNumber(); - ULong_t hitTime = fCurrentMessage->getMsgFullTime(fCurrentEpoch[rocId]); - Int_t nxyterId = fCurrentMessage->getNxNumber(); - Int_t nxChannel = fCurrentMessage->getNxChNum(); - Int_t charge = fCurrentMessage->getNxAdcValue(); - - // --- Get detector element from DaqMap - Int_t station = fDaqMap->GetMuchStation(rocId); - Int_t layer = 0; - Int_t side = 0; - Int_t module = 0; - Int_t sector = nxyterId; - Int_t channel = nxChannel; - - // --- Construct unique address - UInt_t address = CbmMuchAddress::GetAddress(station, layer, side, - module, sector, channel); - - // --- Create digi - - // Fill time histogram for ROC 9 NX 0 - if ( rocId == 3 && nxyterId == 0 ) { - Double_t tRel = Double_t(hitTime-fTimeStart) *1.e-9; - LOG(debug2) << hitTime << " " << fTimeStart << " " << tRel; - fHM->H1("HitTime")->Fill(tRel); - } - - -} -// -------------------------------------------------------------------------- - - - -// ----- Process a STS hit message -------------------------------------- -void CbmRocSource::ProcessStsMessage() { - - // --- Get absolute time, NXYTER and channel number - Int_t rocId = fCurrentMessage->getRocNumber(); - ULong_t hitTime = fCurrentMessage->getMsgFullTime(fCurrentEpoch[rocId]); - Int_t nxyterId = fCurrentMessage->getNxNumber(); - Int_t nxChannel = fCurrentMessage->getNxChNum(); - Int_t charge = fCurrentMessage->getNxAdcValue(); - - /* - // Fill time histogram for ROC 9 NX 0 - if ( rocId == 9 && nxyterId == 0 ) { - Double_t tRel = Double_t(hitTime-fTimeStart) *1.e-9; - LOG(debug2) << hitTime << " " << fTimeStart << " " << tRel; - fhHitTime->Fill(tRel); - } - */ - - -} -// -------------------------------------------------------------------------- - - -void CbmRocSource::Close() -{ - LOG(info) << GetName() << ": Closing."; - delete fRocIter; - fHM->WriteToFile(); -} - -void CbmRocSource::Reset() -{ -} - -ClassImp(CbmRocSource) diff --git a/beamtime/cosy2014/CbmRocSource.h b/beamtime/cosy2014/CbmRocSource.h deleted file mode 100644 index 22a477eb4c4c113d34a6a0ed7e32f786b132f75c..0000000000000000000000000000000000000000 --- a/beamtime/cosy2014/CbmRocSource.h +++ /dev/null @@ -1,69 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmRocSource ----- -// ----- Created 05.11.2013 by F. Uhlig ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CBMROCSOURCE_H -#define CBMROCSOURCE_H - -#include "FairSource.h" - -#include "roc/Message.h" -#include "roc/Iterator.h" - -#include <map> -#include "TString.h" - -class CbmDaqMap; -class CbmHistManager; - -class CbmRocSource : public FairSource -{ - public: - CbmRocSource(); - CbmRocSource(const char *); - CbmRocSource(const CbmRocSource& source); - virtual ~CbmRocSource(); - - virtual Bool_t Init(); - virtual Int_t ReadEvent(); - virtual void Close(); - - virtual void Reset(); - - void AddFile(const char * fname) { fInputFileName = fname;} - - private: - - TString fInputFileName; /** Name of input LMD file **/ - Int_t fNofMessages; /** Number of processed ROC messages **/ - std::map<Int_t, uint32_t> fCurrentEpoch; /** Current epoch marker for each ROC **/ -// uint32_t fCurrentEpoch; /** Current epoch marker **/ - ULong_t fCurrentEpochTime; /** Time stamp of current epoch **/ - Int_t fNofEpochs; /** Number of epoch messages **/ - CbmDaqMap* fDaqMap; /** Mapping from electronics to detectors **/ - - ULong_t fTimeStart; - ULong_t fTimeStop; - - roc::Iterator* fRocIter; //! ROC iterator - roc::Message* fCurrentMessage; //! Current ROC message - - Int_t fNofMessType[8]; // Number of message per message type - Int_t fNofMessRoc[20][5]; // Number of messages per ROC and NXYTER - - void ProcessEpochMarker(); - void ProcessHodoMessage(); - void ProcessMuchMessage(); - void ProcessStsMessage(); - - - CbmHistManager* fHM; - - ClassDef(CbmRocSource, 0) -}; - - -#endif diff --git a/beamtime/cosy2014/CbmSourceLmd.cxx b/beamtime/cosy2014/CbmSourceLmd.cxx deleted file mode 100644 index 6b892ec4ed23e20c78796ec96b9a05f4cd7ac974..0000000000000000000000000000000000000000 --- a/beamtime/cosy2014/CbmSourceLmd.cxx +++ /dev/null @@ -1,893 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmSourceLmd ----- -// ----- Created 13.12.2013 by V. Friese ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#include "CbmSourceLmd.h" -#include "CbmAuxDigi.h" -#include "CbmStsDigi.h" -#include "CbmStsAddress.h" -#include "CbmMuchBeamTimeDigi.h" -#include "CbmDaqMap.h" -#include "CbmTbDaqBuffer.h" -#include "CbmTbEvent.h" -#include "CbmModuleList.h" - -#include "much/CbmMuchAddress.h" -#include "fhodo/CbmFiberHodoAddress.h" -#include "fhodo/CbmFiberHodoDigi.h" - -#include "FairLogger.h" -#include "FairRunOnline.h" -#include "FairEventHeader.h" - -#include "TClonesArray.h" - -#include <iostream> -#include <iomanip> - -using std::cout; -using std::endl; -using std::map; -using std::setprecision; -using std::setw; -using std::fixed; -using std::right; - -CbmSourceLmd::CbmSourceLmd() - : FairSource(), - fInputFileName(""), - fInputFileList(), - fFileCounter(0), - fReadInTimeStep(1e9), - fPersistence(kTRUE), - fEventTimeWindow(500.), - fBuffer(CbmTbDaqBuffer::Instance()), - fDaqMap(NULL), - fRocIter(NULL), - fTimeStart(0), - fTimeStop(0), - fCurrentEpochTime(0), - fStartEpoch(0), - fCurrentEpoch(), - fCurrentBufferTime(0), - fCurrentMessage(NULL), - fTimeBufferFill(0), - fTimeBufferOut(0.), - fCurrentEvent(NULL), - fCurrentDigi(), - fNofMessages(0), - fNofEpochs(0), - fNofEvents(0), - fNofMessType(), - fNofMessRoc(), - fNofHitMsg(), - fNofDigis(), - fNofAux(0), - fHodoDigis(nullptr), - fHodoBaselineDigis(nullptr), - fStsDigis(nullptr), - fStsBaselineDigis(nullptr), - fMuchDigis(nullptr), - fMuchBaselineDigis(nullptr), - fAuxDigis(nullptr), - fBaselineData(kFALSE), - fBaselineRoc(), - fTriggeredMode(kFALSE), - fRocNumber1(6), - fRocNumber2(7) -{ - // --- Initialise counters - for (Int_t iType = 0; iType < 8; iType++) { fNofMessType[iType] = 0; } - for (Int_t iRoc = 0; iRoc < 20; iRoc++) - for (Int_t iNx = 0; iNx < 5; iNx++ ) { - fNofMessRoc[iRoc][iNx] = 0; - } -} - -CbmSourceLmd::CbmSourceLmd(const char* inFile) - : FairSource(), - fInputFileName(inFile), - fInputFileList(new TObjString(inFile)), - fFileCounter(0), - fReadInTimeStep(1e9), - fPersistence(kTRUE), - fEventTimeWindow(500.), - fBuffer(CbmTbDaqBuffer::Instance()), - fDaqMap(NULL), - fRocIter(NULL), - fTimeStart(0), - fTimeStop(0), - fCurrentEpochTime(0), - fStartEpoch(0), - fCurrentEpoch(), - fCurrentBufferTime(0), - fCurrentMessage(NULL), - fTimeBufferFill(0), - fTimeBufferOut(0.), - fCurrentEvent(NULL), - fCurrentDigi(), - fNofMessages(0), - fNofEpochs(0), - fNofEvents(0), - fNofMessType(), - fNofMessRoc(), - fNofHitMsg(), - fNofDigis(), - fNofAux(0), - fHodoDigis(nullptr), - fHodoBaselineDigis(nullptr), - fStsDigis(nullptr), - fStsBaselineDigis(nullptr), - fMuchDigis(nullptr), - fMuchBaselineDigis(nullptr), - fAuxDigis(nullptr), - fBaselineData(kFALSE), - fBaselineRoc(), - fTriggeredMode(kFALSE), - fRocNumber1(6), - fRocNumber2(7) -{ - // --- Initialise counters - for (Int_t iType = 0; iType < 8; iType++) { fNofMessType[iType] = 0; } - for (Int_t iRoc = 0; iRoc < 20; iRoc++) - for (Int_t iNx = 0; iNx < 5; iNx++ ) { - fNofMessRoc[iRoc][iNx] = 0; - } -} - -/* - * PAL: Comment copy constructor as does not seem to be used in any macro -CbmSourceLmd::CbmSourceLmd(const CbmSourceLmd& source) - : FairSource(source) -{ -} -*/ - -CbmSourceLmd::~CbmSourceLmd() -{ - // delete fDaqMap; -} - - -// ----- Fill the buffer up to a given time ----------------------------- -Bool_t CbmSourceLmd::FillBuffer(ULong_t time) -{ - - // --- Signal end of file if there are no more messages - if ( ! fCurrentMessage ) { - LOG(info) << GetName() << ": End of input file reached."; - return kFALSE; - } - - Int_t nMessages = 0; - while ( fCurrentMessage ) { - nMessages++; - - // --- Message type counters - Int_t msgType = fCurrentMessage->getMessageType(); - if ( msgType < 0 || msgType > 7 ) { - LOG(error) << GetName() << ": Skipping mesage with unknwon type " - << msgType; - continue; - } - fNofMessType[msgType]++; - - // --- Treat system messages - if ( fCurrentMessage->isSysMsg() ) { ProcessSystemMessage(); } - - // --- Treat epoch markers - if ( fCurrentMessage->isEpochMsg() ) { ProcessEpochMarker(); } - - // --- Treat AUX messages - if ( fCurrentMessage->isAuxMsg() ) { - - if (!fBaselineData) { - // --- ROC Id and channel number - Int_t rocId = fCurrentMessage->getRocNumber(); - Int_t channel = fCurrentMessage->getAuxChNum(); - fNofAux++; - - // --- Check for epoch marker for this ROC - if ( fCurrentEpoch.find(rocId) == fCurrentEpoch.end() ) - LOG(fatal) << GetName() - << ": Hit message without previous epoch marker for ROC " - << rocId; - - // --- Get absolute time - ULong_t auxTime = fCurrentMessage->getMsgFullTime(fCurrentEpoch[rocId]); - - // --- Jump out of loop of hit time is after time limit - if (auxTime > time) { break; } - - // --- Create AuxDigi and send it to the buffer - CbmAuxDigi* digi = new CbmAuxDigi(rocId, channel, auxTime); - fBuffer->InsertData<CbmAuxDigi>(digi); - } - - } //? AUX message - - // --- Treat hit messages - if ( fCurrentMessage->isHitMsg() ) { - - // --- ROC and NXYTER number; increase counter - Int_t rocId = fCurrentMessage->getRocNumber(); - Int_t nxyId = fCurrentMessage->getNxNumber(); - fNofMessRoc[rocId][nxyId]++; - - // --- Check for epoch marker for this ROC - if ( fCurrentEpoch.find(rocId) == fCurrentEpoch.end() ) - LOG(fatal) << GetName() - << ": Hit message without previous epoch marker for ROC " - << rocId; - - // --- Get absolute time - ULong_t hitTime = fCurrentMessage->getMsgFullTime(fCurrentEpoch[rocId]); - - // --- Jump out of loop of hit time is after time limit - if (hitTime > time) { break; } - - // --- Process hit message (detector dependent) - ECbmModuleId systemId = fDaqMap->GetSystemId(rocId); - switch (systemId) { - case ECbmModuleId::kSts: - ProcessStsMessage(); - break; - case ECbmModuleId::kMuch: - ProcessMuchMessage(); - break; - case ECbmModuleId::kHodo: - ProcessHodoMessage(); - break; - default: - break; - } - - } //? Hit message - - // --- Get next ROC message - if ( fRocIter->next() ) { - fCurrentMessage = &fRocIter->msg(); - } else { - // Check if there is another file in the list - fFileCounter += 1; - if ( fInputFileList.GetSize() > fFileCounter ) { - TObjString* tmp = - dynamic_cast<TObjString*>(fInputFileList.At(fFileCounter)); - fInputFileName = tmp->GetString(); - LOG(info) << GetName() << ": Opening next file " - << fInputFileName; - // Normally one should delete the old object before, but this - // doesn't work and result in a crash when creating a new iterator - fRocIter = new roc::Iterator(fInputFileName.Data()); - if ( ! fRocIter->next() ) { - LOG(error) << GetName() << "::Init: input file does not exist " - << "or is empty!"; - return kFALSE; - } - fCurrentMessage = &fRocIter->msg(); - } else { - fCurrentMessage = NULL; - } - } - } //- message loop - - // --- Update buffer fill time - fTimeBufferFill = time; - - // --- Set buffer retrieval time to one time step before fill time. - fTimeBufferOut = Double_t(time - fReadInTimeStep); - - // --- End of input: retrieval time equals fill time - if ( ! fCurrentMessage ) { - LOG(info) << GetName() << ": End of input reached."; - fTimeBufferOut = Double_t(time); - } - - // --- Status info - LOG(info) << GetName() << ": Buffer fill time " << fixed - << setprecision(3) << Double_t(fTimeBufferFill) * 1.e-9 - << " s, retrieval up to " << fTimeBufferOut * 1.e-9 - << " s, " << nMessages << " messages processed"; - fBuffer->PrintStatus(); - fNofMessages += nMessages; - - return kTRUE; -} -// -------------------------------------------------------------------------- - - - -// ----- Get next data -------------------------------------------------- -CbmTbDaqBuffer::Data CbmSourceLmd::GetNextData() -{ - - // --- Retrieve next data from the buffer. - CbmTbDaqBuffer::Data digi = fBuffer->GetNextData(fTimeBufferOut); - - // --- If no data: fill the buffer with next time step - // --- N.b.: fCurrentMessage = NULL means no more data in input and - // --- retrieval of buffer up to the fill time. - while ( ( digi.first.empty() ) && fCurrentMessage ) { - FillBuffer(fTimeBufferFill + fReadInTimeStep); - digi = fBuffer->GetNextData(fTimeBufferOut); - } - - // --- If the digi pointer is NULL; the input is exhausted and the buffer - // --- is empty. - return digi; -} -// -------------------------------------------------------------------------- - - - -// ----- Initialisation ------------------------------------------------- -Bool_t CbmSourceLmd::Init() -{ - - cout << endl; - LOG(info) << "====================================================="; - LOG(info) << GetName() << ": Initialising ..."; - - if ( NULL == fDaqMap ) { - LOG(fatal) << "No DaqMap defined."; - } - - // --- Register output branches - FairRootManager* ioman = FairRootManager::Instance(); - assert ( ioman ); - - // --- Branch for digis - fHodoDigis = new std::vector<CbmFiberHodoDigi>; - ioman->RegisterAny("HodoDigi", fHodoDigis, fPersistence); - - fHodoBaselineDigis = new std::vector<CbmFiberHodoDigi>; - ioman->RegisterAny("HodoBaselineDigi", fHodoBaselineDigis, fPersistence); - - fStsDigis = new std::vector<CbmStsDigi>; - ioman->RegisterAny("StsDigi", fStsDigis, fPersistence); - - fStsBaselineDigis = new std::vector<CbmStsDigi>; - ioman->RegisterAny("StsBaselineDigi", fStsBaselineDigis, fPersistence); - - fMuchDigis = new std::vector<CbmMuchBeamTimeDigi>; - ioman->RegisterAny("MuchDigi", fMuchDigis, fPersistence); - - fMuchBaselineDigis = new std::vector<CbmMuchBeamTimeDigi>; - ioman->RegisterAny("MuchBaselineDigi", fMuchBaselineDigis, fPersistence); - - fAuxDigis = new std::vector<CbmAuxDigi>; - ioman->RegisterAny("AuxDigi", fAuxDigis, fPersistence); - - // --- Get event header from Run - fCurrentEvent = dynamic_cast<CbmTbEvent*> (FairRunOnline::Instance()->GetEventHeader()); - if ( ! fCurrentEvent ) { - LOG(fatal) << "No event header in run!"; - return kFALSE; - } - LOG(info) << "Init : event header at " << fCurrentEvent; - ioman->Register("EventHeader.", "Event", fCurrentEvent, kTRUE); - - // --- Open input file and get first message - TObjString* tmp = - dynamic_cast<TObjString*>(fInputFileList.At(fFileCounter)); - fInputFileName = tmp->GetString(); - LOG(info) << GetName() << ": Opening file " << fInputFileName; - fRocIter = new roc::Iterator(fInputFileName.Data()); - if ( ! fRocIter->next() ) { - LOG(error) << GetName() << "::Init: input file does not exist " - << "or is empty!"; - return kFALSE; - } - fCurrentMessage = &fRocIter->msg(); - if ( fCurrentMessage->getMessageType() != roc::MSG_EPOCH ) { - LOG(error) << GetName() << ": First message is not epoch marker!"; - return kFALSE; - } - - // --- Get start time and set initial buffer fill time - Int_t epoch = fCurrentMessage->getEpochNumber(); - ULong_t time = fCurrentMessage->getMsgFullTime(epoch); - LOG(info) << GetName() << ": First message: epoch " << epoch << " time " - << setprecision(9) << Double_t(time) * 1.e-9 << " s"; - - // --- Set initial buffer fill time (rounded to next read-in time step) - fTimeBufferFill = ULong_t( Double_t(time) / Double_t(fReadInTimeStep) ) - * fReadInTimeStep; - fTimeBufferOut = fTimeBufferFill - fReadInTimeStep; - - // --- Read the first digi from the buffer - fCurrentDigi = GetNextData(); - if ( fCurrentDigi.first.empty() ) { - LOG(error) << GetName() << ": No hit data in input!"; - return kFALSE; - } - - LOG(info) << GetName() << ": Initialisation done. "; - LOG(info) << "====================================================="; - cout << endl; - - return kTRUE; -} -// -------------------------------------------------------------------------- - - - -// ----- Event loop ----------------------------------------------------- -// Action: Digis are retrieved from the buffer one by one. -// If their time is within the association window, they are added to the -// event. If not, the event loop is stopped. -Int_t CbmSourceLmd::ReadEvent(UInt_t) -{ - - if ( ! fCurrentEvent ) { - LOG(fatal) << "No pointer to event header! " << fCurrentEvent; - } - - // The next block is needed do to the problem that the TClonesArray is - // very large after usage (2.5 M entries). This somehow slows down - // the Clear of the container even if no entries are inside by 2-3 orders - // of magnitude which slows down the execution of the whole program by - // more then a factor of 10. - // TODO: - // It has to be checked if this is a bug in Root by producing a small - // example program to demonstarete the issue - if (fStsBaselineDigis->size() > 1000) { - fStsBaselineDigis->clear(); - fStsBaselineDigis->resize(10); - } - if (fHodoBaselineDigis->size() > 1000) { - fHodoBaselineDigis->clear(); - fHodoBaselineDigis->resize(10); - } - if (fMuchBaselineDigis->size() > 1000) { - fMuchBaselineDigis->clear(); - fMuchBaselineDigis->resize(10); - } - -/* - // --- Clear output arrays - fHodoDigis->clear(); - fHodoBaselineDigis->clear(); - fStsDigis->clear(); - fStsBaselineDigis->clear(); - fMuchDigis->clear(); - fMuchBaselineDigis->clear(); - fAuxDigis->clear(); -*/ - -/* - // --- Clear output arrays - fHodoDigis->Delete(); - fHodoBaselineDigis->Delete(); - fStsDigis->Delete(); - fStsBaselineDigis->Delete(); - fMuchDigis->Delete(); - fMuchBaselineDigis->Delete(); - fAuxDigis->Delete(); -*/ - // --- Clrear event header - fCurrentEvent->Clear(); - - - // Loop over digis - while ( kTRUE ) { - - ECbmModuleId systemId = fCurrentDigi.second; - Double_t _time{0.}; - if ( systemId == ECbmModuleId::kSts ) { - _time = boost::any_cast<CbmStsDigi*>(fCurrentDigi.first)->GetTime(); - } else if ( systemId == ECbmModuleId::kMuch ) { - _time = boost::any_cast<CbmMuchBeamTimeDigi*>(fCurrentDigi.first)->GetTime(); - } else if ( systemId == ECbmModuleId::kHodo ) { - _time = boost::any_cast<CbmFiberHodoDigi*>(fCurrentDigi.first)->GetTime(); - } else if ( systemId == static_cast<ECbmModuleId>(999) ) { - _time = boost::any_cast<CbmAuxDigi*>(fCurrentDigi.first)->GetTime(); - } - - // --- If event is empty or time of digi matches to event, add digi to event. - Double_t tDif = TMath::Abs(_time - fCurrentEvent->GetTime() ); - if ( fCurrentEvent->IsEmpty() || tDif < fEventTimeWindow ) { - - // --- Update event object -// fCurrentEvent->AddDigi(fCurrentDigi); - - // --- Copy digi to output array - if ( systemId == ECbmModuleId::kSts ) { - CbmStsDigi* _tmpdigi = boost::any_cast<CbmStsDigi*>(fCurrentDigi.first); -// LOG(info) << _tmpdigi->ToString(); - fCurrentEvent->AddDigi<CbmStsDigi>(_tmpdigi); - fStsDigis->emplace_back(*(_tmpdigi)); - delete _tmpdigi; - fNofDigis[ToIntegralType(ECbmModuleId::kSts)]++; - LOG(debug) << "STS digis " << fNofDigis[ToIntegralType(ECbmModuleId::kSts)]; - } //? STS digi - else if ( systemId == ECbmModuleId::kMuch ) { - CbmMuchBeamTimeDigi* _tmpdigi = boost::any_cast<CbmMuchBeamTimeDigi*>(fCurrentDigi.first); - fCurrentEvent->AddDigi<CbmMuchBeamTimeDigi>(_tmpdigi); - fMuchDigis->emplace_back(*(_tmpdigi)); - fNofDigis[ToIntegralType(ECbmModuleId::kMuch)]++; - LOG(debug) << "MUCH digis " << fNofDigis[ToIntegralType(ECbmModuleId::kMuch)]; - } //? MUCH digi - else if ( systemId == ECbmModuleId::kHodo ) { - CbmFiberHodoDigi* _tmpdigi = boost::any_cast<CbmFiberHodoDigi*>(fCurrentDigi.first); - fCurrentEvent->AddDigi<CbmFiberHodoDigi>(_tmpdigi); - fHodoDigis->emplace_back(*(_tmpdigi)); - delete _tmpdigi; - fNofDigis[ToIntegralType(ECbmModuleId::kHodo)]++; - LOG(debug) << "HODO digis " << fNofDigis[ToIntegralType(ECbmModuleId::kHodo)]; - } //? HODO digi - else if ( systemId == static_cast<ECbmModuleId>(999)) { // I know I should not hardcode numbers.... - CbmAuxDigi* _tmpdigi = boost::any_cast<CbmAuxDigi*>(fCurrentDigi.first); - Int_t val = _tmpdigi->GetRocId(); - if ( val == 666 ) { - LOG(info) << "In Old Aux RocId: "<< val; - Int_t retval = FillBaselineDataContainer(); - fNofEvents++; - return retval; - } else { - fCurrentEvent->AddDigi<CbmAuxDigi>(_tmpdigi); - fAuxDigis->emplace_back(*(_tmpdigi)); - delete _tmpdigi; - } - } - - // --- Delete current digi from memory and get next one - fCurrentDigi = GetNextData(); - if ( fCurrentDigi.first.empty() ) { - LOG(info) << "No more input data. End the run."; - return 1; // no more data; trigger end of run - } - } //? Digi belongs to event? - - // --- If digi does not belong to current event: stop event loop. - else { - if ( FairLogger::GetLogger()->IsLogNeeded(fair::Severity::debug1) ) fCurrentEvent->Print(); - fNofEvents++; - return 0; - } - - } //- event loop over digis - - LOG(info) << "===== Leaving Exec. "; - - return 0; -} - -// ----- Process a system message ---------------------------------------- -void CbmSourceLmd::ProcessSystemMessage() -{ - if (fCurrentMessage->getSysMesType() == roc::SYSMSG_USER) { - // --- Get absolute time and Roc number - Int_t rocId = fCurrentMessage->getRocNumber(); - ULong_t hitTime = fCurrentMessage->getMsgFullTime(fCurrentEpoch[rocId]); - CbmAuxDigi* digi; - - switch(fCurrentMessage->getSysMesData()) { - case roc::SYSMSG_USER_CALIBR_ON: - if ( !fBaselineData ) { - fBaselineData = kTRUE; - // --- Create AuxDigi and send it to the buffer - digi = new CbmAuxDigi(666, 666, hitTime); - fBuffer->InsertData<CbmAuxDigi>(digi); - LOG(info) << " Switching now to baseline mode at " << - setprecision(9) << Double_t(hitTime) * 1.e-9 << " s"; - } - if (fTriggeredMode) { - fBaselineRoc.insert(fRocNumber1); - fBaselineRoc.insert(fRocNumber2); - LOG(info) << "Triggered mode"; - LOG(info) << "ROC " << fRocNumber1 << " now in baseline mode"; - LOG(info) << "ROC " << fRocNumber2 << " now in baseline mode"; - } - fBaselineRoc.insert(rocId); - LOG(info) << "ROC " << rocId << " now in baseline mode"; - break; - case roc::SYSMSG_USER_CALIBR_OFF: - if (fTriggeredMode) { - fBaselineRoc.erase(fRocNumber1); - fBaselineRoc.erase(fRocNumber2); - LOG(info) << "Triggered mode"; - LOG(info) << "ROC " << fRocNumber1 << " now in normal mode"; - LOG(info) << "ROC " << fRocNumber2 << " now in normal mode"; - } - fBaselineRoc.erase(rocId); - LOG(info) << "ROC " << rocId << " now in normal mode"; - if ( fBaselineRoc.empty() ) { - digi = new CbmAuxDigi(999, 999, hitTime); - fBuffer->InsertData<CbmAuxDigi>(digi); - fBaselineData = kFALSE; - LOG(info) << "Switching back to normal mode at " << - setprecision(9) << Double_t(hitTime) * 1.e-9 << " s"; - } - break; - case roc::SYSMSG_USER_RECONFIGURE: - LOG(debug) << "Found USER_RECONFIGURE at ";//; - break; - default: - LOG(error) << "Found unknown system message at ";//; - break; - } - } -} -// ----- Process an epoch marker ---------------------------------------- -void CbmSourceLmd::ProcessEpochMarker() -{ - - Int_t rocId = fCurrentMessage->getRocNumber(); - fCurrentEpoch[rocId] = fCurrentMessage->getEpochNumber(); - if ( rocId ) { return; } // Further action only for ROC Id 0 - - fCurrentEpochTime = fCurrentMessage->getMsgFullTime(fCurrentEpoch[rocId]); - fNofEpochs++; - LOG(debug) << GetName() << ": Epoch message " - << fNofEpochs << ", epoch " << Int_t(fCurrentEpoch[rocId]) - << ", time " << std::setprecision(9) << std::fixed - << Double_t(fCurrentEpochTime) * 1.e-9 << " s"; - - // --- Start and stop time - if ( fTimeStart == 0 || fTimeStart > fCurrentEpochTime ) { - fTimeStart = fCurrentEpochTime; - } - if ( fTimeStop < fCurrentEpochTime ) { fTimeStop = fCurrentEpochTime; } - -} -// -------------------------------------------------------------------------- - - - -// ----- Process a HODO hit message ------------------------------------- -void CbmSourceLmd::ProcessHodoMessage() -{ - - // --- Increment message counter - fNofHitMsg[ToIntegralType(ECbmModuleId::kHodo)]++; - - // --- Get absolute time, NXYTER and channel number - Int_t rocId = fCurrentMessage->getRocNumber(); - ULong_t hitTime = fCurrentMessage->getMsgFullTime(fCurrentEpoch[rocId]); - Int_t nxyterId = fCurrentMessage->getNxNumber(); - Int_t nxChannel = fCurrentMessage->getNxChNum(); - Int_t charge = fCurrentMessage->getNxAdcValue(); - - Int_t iStation; - Int_t iSector; - Int_t iPlane; - Int_t iFiber; - - fDaqMap->Map(rocId, nxyterId, nxChannel, iStation, iSector, iPlane, iFiber); - Int_t address = CbmFiberHodoAddress::GetAddress(iStation, iPlane, iFiber); - - // --- Create a HODO digi and send it to the buffer - CbmFiberHodoDigi* digi = new CbmFiberHodoDigi(address, charge, hitTime); - - // In case of normal data insert the digi into the buffer. - // In case of baseline data insert the digi only if the roc - // is already in baseline mode. - if (!fBaselineData) { - fBuffer->InsertData<CbmFiberHodoDigi>(digi); - } else { - std::set<Int_t>::iterator it; - it = fBaselineRoc.find(rocId); - if (it != fBaselineRoc.end() ) { fBuffer->InsertData<CbmFiberHodoDigi>(digi); } - } - -} -// -------------------------------------------------------------------------- - - - -// ----- Process a MUCH hit message ------------------------------------- -void CbmSourceLmd::ProcessMuchMessage() -{ - - // --- Increment message counter - fNofHitMsg[ToIntegralType(ECbmModuleId::kMuch)]++; - - // --- Get absolute time, NXYTER and channel number - Int_t rocId = fCurrentMessage->getRocNumber(); - ULong_t hitTime = fCurrentMessage->getMsgFullTime(fCurrentEpoch[rocId]); - Int_t nxyterId = fCurrentMessage->getNxNumber(); - Int_t nxChannel = fCurrentMessage->getNxChNum(); - Int_t charge = fCurrentMessage->getNxAdcValue(); - - LOG(debug2) << "MUCH mssage at " << hitTime; - - // --- Get detector element from DaqMap - Int_t station = fDaqMap->GetMuchStation(rocId); - Int_t layer = 0; - Int_t side = 0; - Int_t module = 0; - Int_t sector = nxyterId; - Int_t channel = nxChannel; - - // --- Construct unique address - UInt_t address = CbmMuchAddress::GetAddress(station, layer, side, - module, sector, channel); - - // --- Create digi - CbmMuchBeamTimeDigi* digi = new CbmMuchBeamTimeDigi(address, charge, hitTime); - LOG(debug2) << "MUCH digi at " << digi->GetTime(); - - // In case of normal data insert the digi into the buffer. - // In case of baseline data insert the digi only if the roc - // is already in baseline mode. - if (!fBaselineData) { - fBuffer->InsertData<CbmMuchBeamTimeDigi>(digi); - } else { - std::set<Int_t>::iterator it; - it = fBaselineRoc.find(rocId); - if (it != fBaselineRoc.end() ) {fBuffer->InsertData<CbmMuchBeamTimeDigi>(digi); } - } - -} -// -------------------------------------------------------------------------- - - - -// ----- Process a STS hit message -------------------------------------- -void CbmSourceLmd::ProcessStsMessage() -{ - - // --- Increment message counter - fNofHitMsg[ToIntegralType(ECbmModuleId::kSts)]++; - - // --- Get absolute time, NXYTER and channel number - Int_t rocId = fCurrentMessage->getRocNumber(); - ULong64_t hitTime = fCurrentMessage->getMsgFullTime(fCurrentEpoch[rocId]); - Int_t nxyterId = fCurrentMessage->getNxNumber(); - Int_t nxChannel = fCurrentMessage->getNxChNum(); - Int_t charge = fCurrentMessage->getNxAdcValue(); - - // --- Get detector element from DaqMap - Int_t station = fDaqMap->GetStsStation(rocId); -/* Int_t sector = 0;*/ - Int_t side = fDaqMap->GetStsSensorSide(rocId); - Int_t channel = fDaqMap->GetStsChannel(rocId, nxyterId, nxChannel); - - // --- Create a STS digi and send it to the buffer - UInt_t address = CbmStsAddress::GetAddress(station, - 0, // ladder - 0, // halfladder - 0, // module - 0, // sensor - side); - CbmStsDigi* digi = new CbmStsDigi(address, channel, hitTime, charge); - - - // In case of normal data insert the digi into the buffer. - // In case of baseline data insert the digi only if the roc - // is already in baseline mode. - if (!fBaselineData) { - fBuffer->InsertData<CbmStsDigi>(digi); - } else { - std::set<Int_t>::iterator it; - it = fBaselineRoc.find(rocId); - if (it != fBaselineRoc.end() ) {fBuffer->InsertData<CbmStsDigi>(digi); } - } - -} -// -------------------------------------------------------------------------- - - -void CbmSourceLmd::Close() -{ - - cout << endl; - LOG(info) << "====================================================="; - fBuffer->PrintStatus(); - LOG(info) << GetName() << ": Run Summary"; - - cout << endl; - LOG(info) << "Messages in input: " << fNofMessages; - Double_t deltaT = (fTimeStop - fTimeStart) / 1.e9; - LOG(info) << "Start time : " << fTimeStart * 1.e-9 << " s "; - LOG(info) << "Stop time : " << fTimeStop * 1.e-9 << " s "; - LOG(info) << "Duration : " << deltaT << " s"; - - const char* names[8] = { "NOP", "HIT", "EPOCH", "SYNC", "AUX", "EPOCH2", "GET4", "SYS" }; - cout << endl; - LOG(info) << "Messages per message type: "; - for (Int_t i=0; i<8; i++) - LOG(info) << setw(6) << names[i] << " " - << setw(10) << right << fNofMessType[i]; - - cout << endl; - LOG(info) << "Hit messages per ROC/NXYTER: "; - for (Int_t iRoc = 0; iRoc < 13; iRoc ++) - for (Int_t iNx = 0; iNx < 3; iNx +=2 ) { - LOG(info) << " ROC " << setw(2) << iRoc << " NXYTER " << iNx << " Messages " - << setw(12) << right << fNofMessRoc[iRoc][iNx] << " Rate " - << setw(12) << setprecision(4) << fixed << right - << Double_t(fNofMessRoc[iRoc][iNx]) / deltaT - << " /s "; - } - - cout << endl; - LOG(info) << "Hit messages and digis per system: "; - for (ECbmModuleId iSys = ECbmModuleId::kRef; iSys < ECbmModuleId::kNofSystems; ++iSys) { - TString sysName = CbmModuleList::GetModuleNameCaps(iSys); - LOG(info) << setw(5) << sysName << ": Messages " << fNofHitMsg[ToIntegralType(iSys)] - << ", Digis " << fNofDigis[ToIntegralType(iSys)]; - } - LOG(info) << "AUX : Messages " << fNofMessType[roc::MSG_AUX] << ", Digis " - << fNofAux; - - - LOG(info) << "Total number of events: " << fNofEvents; - - delete fRocIter; -} - -void CbmSourceLmd::Reset() -{ -} - -Int_t CbmSourceLmd::FillBaselineDataContainer() -{ - - // --- Clear output arrays - fHodoDigis->clear(); - fHodoBaselineDigis->clear(); - fStsDigis->clear(); - fStsBaselineDigis->clear(); - fMuchDigis->clear(); - fMuchBaselineDigis->clear(); - fAuxDigis->clear(); - - // --- Clrear event header - fCurrentEvent->Clear(); - - LOG(info) << "Event type is now: " << fCurrentEvent->GetEventType(); - fCurrentEvent->SetEventType(1); - LOG(info) << "Event type is now: " << fCurrentEvent->GetEventType(); - - Int_t _nofevents = fNofDigis[ToIntegralType(ECbmModuleId::kDummyDet)]; - // Loop over digis - while ( kTRUE ) { - - ECbmModuleId systemId = fCurrentDigi.second; - - // --- Copy digi to output array - if ( systemId == ECbmModuleId::kSts ) { - CbmStsDigi* _tmpdigi = boost::any_cast<CbmStsDigi*>(fCurrentDigi.first); - fStsBaselineDigis->emplace_back(*(_tmpdigi)); - delete _tmpdigi; - fNofDigis[ToIntegralType(ECbmModuleId::kDummyDet)]++; - } else if ( systemId == ECbmModuleId::kMuch ) { - CbmMuchBeamTimeDigi* _tmpdigi = boost::any_cast<CbmMuchBeamTimeDigi*>(fCurrentDigi.first); - fMuchBaselineDigis->emplace_back(*(_tmpdigi)); - fNofDigis[ToIntegralType(ECbmModuleId::kDummyDet)]++; - } else if ( systemId == ECbmModuleId::kHodo ) { - CbmFiberHodoDigi* _tmpdigi = boost::any_cast<CbmFiberHodoDigi*>(fCurrentDigi.first); - fHodoBaselineDigis->emplace_back(*(_tmpdigi)); - delete _tmpdigi; - fNofDigis[ToIntegralType(ECbmModuleId::kDummyDet)]++; - } else if ( systemId == static_cast<ECbmModuleId>(999)) { // I know I should not hardcode numbers.... - // check if this is a misused auxmessage to set/unset basline - // calibration - CbmAuxDigi* _tmpdigi = boost::any_cast<CbmAuxDigi*>(fCurrentDigi.first); - Int_t val = _tmpdigi->GetRocId(); - if ( val == 999 ) { - LOG(info) << "Aux RocId: "<< val; - LOG(info) << "Leaving FillBaselineDataContainer after " - << (fNofDigis[ToIntegralType(ECbmModuleId::kDummyDet)] - _nofevents) << " events"; - return 0; - } - } else { - // LOG(error) << "Between baseline start and end marker there should be only sts data"; - } -// } else { - // LOG(error) << "Between baseline start and end marker there should be only sts data"; - - fCurrentDigi = GetNextData(); - if ( fCurrentDigi.first.empty() ) { - LOG(info) << "No more input data. End the run."; - return 1; // no more data; trigger end of run - } - } -} - -ClassImp(CbmSourceLmd) diff --git a/beamtime/cosy2014/CbmSourceLmd.h b/beamtime/cosy2014/CbmSourceLmd.h deleted file mode 100644 index 8874ac26c5863b4e26ce949b385505e639aabb50..0000000000000000000000000000000000000000 --- a/beamtime/cosy2014/CbmSourceLmd.h +++ /dev/null @@ -1,157 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmSourceLmd ----- -// ----- Created 13.12.2013 by V. Friese ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CBMSOURCELMD_H -#define CBMSOURCELMD_H - -#include "FairSource.h" - -#include "CbmTbDaqBuffer.h" -#include "CbmDefs.h" - -#include "CbmAuxDigi.h" -#include "CbmStsDigi.h" -#include "CbmMuchBeamTimeDigi.h" -#include "CbmFiberHodoDigi.h" - -#include "TList.h" -#include "TString.h" -#include "TObjString.h" - -#include "roc/Message.h" -#include "roc/Iterator.h" - -#include <map> -#include <set> -#include <vector> - -class CbmDaqMap; -class CbmTbEvent; - -class CbmSourceLmd : public FairSource -{ - public: - CbmSourceLmd(); - CbmSourceLmd(const char *); -// CbmSourceLmd(const CbmSourceLmd& source); - virtual ~CbmSourceLmd(); - - virtual Bool_t Init(); - Int_t ReadEvent(UInt_t); - - Source_Type GetSourceType() {return kONLINE;} - - virtual void SetParUnpackers() {;} - - virtual Bool_t InitUnpackers() {return kTRUE;} - - virtual Bool_t ReInitUnpackers() {return kTRUE;} - - virtual void Close(); - virtual void Reset(); - - void SetReadInTimeStep(ULong_t step) { fReadInTimeStep = step; } - void SetPersistence(Bool_t persistence = kTRUE) { fPersistence = persistence; } - - void SetEventTimeWindow(Double_t window) { fEventTimeWindow = window; } - void SetTriggeredMode(Bool_t mode) { fTriggeredMode = mode; } - void SetTriggeredRocNumber(Int_t Nr1, Int_t Nr2) { fRocNumber1 = Nr1; fRocNumber2 = Nr2; } - - void AddFile(const char * fname) { - fInputFileList.Add(new TObjString(fname)); - } - - void SetDaqMap(CbmDaqMap* daqMap) - { fDaqMap = daqMap; } - - private: - - // --- Settings - TString fInputFileName; ///< Name of lmd input file - TList fInputFileList; ///< List of input files - Int_t fFileCounter; ///< Counter the actual file in list - ULong_t fReadInTimeStep; ///< Time step in which data from input are read - Bool_t fPersistence; ///< Flag for file storage of output arrays - Double_t fEventTimeWindow; ///< Time window for association of digi to event - - // --- Auxiliary classes - CbmTbDaqBuffer* fBuffer; ///< Digi buffer instance - CbmDaqMap* fDaqMap; ///< Mapping from electronics to detectors - roc::Iterator* fRocIter; ///< ROC iterator - - - // --- Status - ULong_t fTimeStart; - ULong_t fTimeStop; - ULong_t fCurrentEpochTime; /** Time stamp of current epoch **/ - UInt_t fStartEpoch; ///< Number of first epoch - std::map<Int_t, uint32_t> fCurrentEpoch; /** Current epoch marker for each ROC **/ - ULong_t fCurrentBufferTime; ///< Time limit of current buffer - roc::Message* fCurrentMessage; //! Current ROC message - ULong_t fTimeBufferFill; ///< Time up to which the buffer was filled - Double_t fTimeBufferOut; ///< Time up to which data from the buffer can be retrieved - - // --- Event status - CbmTbEvent* fCurrentEvent; ///< Pointer to current event - CbmTbDaqBuffer::Data fCurrentDigi; ///< Pointer to current digi read from buffer - - - // --- Counters - Int_t fNofMessages; ///< Number of processed ROC messages - Int_t fNofEpochs; ///< Number of processed ROC epochs messages - Int_t fNofEvents; ///< Number of built events - Int_t fNofMessType[8]; ///< Number of message per message type - Int_t fNofMessRoc[20][5]; ///< Number of messages per ROC and NXYTER - Int_t fNofHitMsg[ToIntegralType(ECbmModuleId::kNofSystems)]; ///< Number of hit messages per detector system - Int_t fNofDigis[ToIntegralType(ECbmModuleId::kNofSystems)]; ///< Number of created digis per detector system - Int_t fNofAux; ///< Number of AUX messages - - - // --- Output arrays - std::vector <CbmFiberHodoDigi>* fHodoDigis; ///< Output array of CbmHodoDigi - std::vector <CbmFiberHodoDigi>* fHodoBaselineDigis; ///< Output array for baseline calib. - std::vector <CbmStsDigi>* fStsDigis; ///< Output array of CbmStsDigi - std::vector <CbmStsDigi>* fStsBaselineDigis; ///< Output array for baseline calib. - std::vector <CbmMuchBeamTimeDigi>* fMuchDigis; ///< Output array of CbmMuchDigi - std::vector <CbmMuchBeamTimeDigi>* fMuchBaselineDigis; ///< Output array for baseline calib. - std::vector <CbmAuxDigi>* fAuxDigis; ///< Output array of CbmAuxDigi - - Bool_t fBaselineData; ///< Flag if the data is for baseline calibration - std::set<Int_t> fBaselineRoc; ///< List of RocIds which already signaled changin of readout status - Bool_t fTriggeredMode; ///< Flag if data is taken in triggered mode - - Int_t fRocNumber1, fRocNumber2; ///< Number of ROC for external trigger - - void ProcessSystemMessage(); - void ProcessEpochMarker(); - void ProcessHodoMessage(); - void ProcessMuchMessage(); - void ProcessStsMessage(); - - /** Fill the buffer from the input - ** @param time Maximal time of input data - ** @return kFALSE if end of input is reached - **/ - Bool_t FillBuffer(ULong_t time); - - - /** Get next digi from the buffer. - ** If necessary, refill the buffer. - ** @return Pointer to next digi object. NULL if no more available. - **/ - CbmTbDaqBuffer::Data GetNextData(); - - Int_t FillBaselineDataContainer(); - - CbmSourceLmd(const CbmSourceLmd& source); - CbmSourceLmd& operator=(const CbmSourceLmd&); - - ClassDef(CbmSourceLmd, 0) -}; - - -#endif diff --git a/beamtime/cosy2014/CbmSourceLmdNew.cxx b/beamtime/cosy2014/CbmSourceLmdNew.cxx deleted file mode 100644 index a1656c2c241185497b3a1820bdd25b1ccc7ada25..0000000000000000000000000000000000000000 --- a/beamtime/cosy2014/CbmSourceLmdNew.cxx +++ /dev/null @@ -1,584 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmSourceLmdNew ----- -// ----- Created 10.11.2014 by F. Uhlig ----- -// ----- ----- -// ----------------------------------------------------------------------------- -#include "CbmSourceLmdNew.h" -#include <FairSource.h> // for FairSource -#include <TList.h> // for TList -#include <TObjString.h> // for TObjString -#include <TObject.h> // for TObject -#include <TString.h> // for TString, operator<< -#include <stddef.h> // for NULL -#include <iomanip> // for setw, setprecision, __iom_t6, __iom_t5 -#include <ios> // for right, fixed -#include "CbmAuxDigi.h" // for CbmAuxDigi -#include "CbmDaqMap.h" // for CbmDaqMap -#include "CbmModuleList.h" // for CbmModuleList -#include "CbmROCUnpack.h" // for CbmROCUnpack -#include "CbmTbDaqBuffer.h" // for CbmTbDaqBuffer -#include "CbmTbEvent.h" // for CbmTbEvent -#include "CbmTbEventBuilder.h" // for CbmTbEventBuilder -#include <FairEventHeader.h> // for FairEventHeader -#include <FairLogger.h> // for FairLogger -#include <FairRunOnline.h> // for FairRunOnline -#include "roc/Iterator.h" // for Iterator -#include "roc/Message.h" // for Message, MSG_AUX, MSG_EPOCH -#include <boost/any.hpp> - -using std::map; -using std::setprecision; -using std::setw; -using std::fixed; -using std::right; - -CbmSourceLmdNew::CbmSourceLmdNew() - : FairSource(), - fInputFileName(""), - fInputFileList(), - fFileCounter(0), - fReadInTimeStep(1e9), - fPersistence(kTRUE), - fAuxOffset(1000), - fBuffer(CbmTbDaqBuffer::Instance()), - fDaqMap(NULL), - fRocIter(NULL), - fEventBuilder(NULL), - fTimeStart(0), - fTimeStop(0), - fCurrentEpochTime(0), - fStartEpoch(0), - fCurrentEpoch(), - fCurrentBufferTime(0), - fCurrentMessage(NULL), - fTimeBufferFill(0), - fTimeBufferOut(0.), - fCurrentDigi(), - fNofMessages(0), - fNofEpochs(0), - fNofEvents(0), - fNofMessType(), - fNofMessRoc(), - fNofHitMsg(), - fNofDigis(), - fNofBLDigis(), - fNofDiscardedDigis(), - fNofAux(0), - fNofDiscardedAux(0), - fNofIgnoredMessages(0), - fBaselineDataFill(kFALSE), - fBaselineDataRetrieve(kFALSE), - fBaselineRoc(), - fTriggeredMode(kFALSE), - fUnpackers(), - fNofBaselineDigis(0) -{ - // --- Initialise counters - for (Int_t iType = 0; iType < 8; iType++) { fNofMessType[iType] = 0; } - for (Int_t iRoc = 0; iRoc < 20; iRoc++) - for (Int_t iNx = 0; iNx < 5; iNx++ ) { - fNofMessRoc[iRoc][iNx] = 0; - } - for (ECbmModuleId idet = ECbmModuleId::kRef; idet < ECbmModuleId::kNofSystems; ++idet) { - fNofHitMsg[idet] = 0; - } -} - -CbmSourceLmdNew::CbmSourceLmdNew(const char* inFile) - : FairSource(), - fInputFileName(inFile), - fInputFileList(new TObjString(inFile)), - fFileCounter(0), - fReadInTimeStep(1e9), - fPersistence(kTRUE), - fAuxOffset(1000), - fBuffer(CbmTbDaqBuffer::Instance()), - fDaqMap(NULL), - fRocIter(NULL), - fEventBuilder(NULL), - fTimeStart(0), - fTimeStop(0), - fCurrentEpochTime(0), - fStartEpoch(0), - fCurrentEpoch(), - fCurrentBufferTime(0), - fCurrentMessage(NULL), - fTimeBufferFill(0), - fTimeBufferOut(0.), - fCurrentDigi(), - fNofMessages(0), - fNofEpochs(0), - fNofEvents(0), - fNofMessType(), - fNofMessRoc(), - fNofHitMsg(), - fNofDigis(), - fNofBLDigis(), - fNofDiscardedDigis(), - fNofAux(0), - fNofDiscardedAux(0), - fNofIgnoredMessages(0), - fBaselineDataFill(kFALSE), - fBaselineDataRetrieve(kFALSE), - fBaselineRoc(), - fTriggeredMode(kFALSE), - fUnpackers(), - fNofBaselineDigis(0) -{ - // --- Initialise counters - for (Int_t iType = 0; iType < 8; iType++) { fNofMessType[iType] = 0; } - for (Int_t iRoc = 0; iRoc < 20; iRoc++) - for (Int_t iNx = 0; iNx < 5; iNx++ ) { - fNofMessRoc[iRoc][iNx] = 0; - } - for (ECbmModuleId idet = ECbmModuleId::kRef; idet < ECbmModuleId::kNofSystems; ++idet) { - fNofHitMsg[idet] = 0; - } -} - -/* - * PAL: Comment copy constructor as does not seem to be used in any macro -CbmSourceLmdNew::CbmSourceLmdNew(const CbmSourceLmdNew& source) - : FairSource(source) -{ -} -*/ - -CbmSourceLmdNew::~CbmSourceLmdNew() -{ - // delete fDaqMap; -} - - -// ----- Fill the buffer up to a given time ----------------------------- -Bool_t CbmSourceLmdNew::FillBuffer(ULong_t time) -{ - - // --- Signal end of file if there are no more messages - if ( ! fCurrentMessage ) { - LOG(info) << GetName() << ": End of input file reached."; - return kFALSE; - } - - Int_t nMessages = 0; - while ( fCurrentMessage ) { - nMessages++; - - // Extract needed info from the message - Int_t msgType = fCurrentMessage->getMessageType(); - Int_t rocId = fCurrentMessage->getRocNumber(); - Int_t nxyId = fCurrentMessage->getNxNumber(); - ULong_t hitTime = fCurrentMessage->getMsgFullTime(fCurrentEpoch[rocId]); - - // --- Jump out of loop of hit time is after time limit - if (hitTime > time) { break; } - - // Ignore all messages with unknown system ID - ECbmModuleId systemId = fDaqMap->GetSystemId(rocId); - if ( systemId == ECbmModuleId::kNotExist ) { - fNofIgnoredMessages++; - LOG(debug) << "ROC id " << rocId << " system ID " << systemId - << ": ignoring message"; - GetNextMessage(); - continue; - } - - // Count number of messages for the different types - fNofMessType[msgType]++; - - // To define a unique number needed for calling the correct - // unpacker calculate such a number from the message type (which - // is 1 for hit messages and the unique system id) - if ( fCurrentMessage->isHitMsg() ) { - // --- ROC number defines the system - fNofHitMsg[systemId]++; - fNofMessRoc[rocId][nxyId]++; - if ( systemId >= ECbmModuleId::kRef ) msgType = msgType*10 + ToIntegralType(systemId); - } - - // call the registered unpacker for the - // message type of the current message - std::map<Int_t, CbmROCUnpack*>::iterator it=fUnpackers.find(msgType); - if (it == fUnpackers.end()) { - LOG(error) << "Skipping message with unknown type " - << msgType << " ROC " << rocId; - continue; - } else { - it->second->DoUnpack(fCurrentMessage, hitTime); - } - - GetNextMessage(); - - } //- message loop - - // --- Update buffer fill time - fTimeBufferFill = time; - - // --- Set buffer retrieval time to one time step before fill time. - fTimeBufferOut = Double_t(time - fReadInTimeStep); - - // --- End of input: retrieval time equals fill time - if ( ! fCurrentMessage ) { - LOG(info) << GetName() << ": End of input reached."; - fTimeBufferOut = Double_t(time); - } - - // --- Status info - LOG(info) << GetName() << ": Buffer fill time " << fixed - << setprecision(3) << Double_t(fTimeBufferFill) * 1.e-9 - << " s, retrieval up to " << fTimeBufferOut * 1.e-9 - << " s, " << nMessages << " messages processed"; - fBuffer->PrintStatus(); - fNofMessages += nMessages; - - return kTRUE; -} -// -------------------------------------------------------------------------- - - - -// ----- Get next data -------------------------------------------------- -CbmTbDaqBuffer::Data CbmSourceLmdNew::GetNextData() -{ - - // --- Retrieve next data from the buffer. - CbmTbDaqBuffer::Data digi = fBuffer->GetNextData(fTimeBufferOut); - - // --- If no data: fill the buffer with next time step - // --- N.b.: fCurrentMessage = NULL means no more data in input and - // --- retrieval of buffer up to the fill time. - while ( digi.first.empty() && fCurrentMessage ) { - FillBuffer(fTimeBufferFill + fReadInTimeStep); - digi = fBuffer->GetNextData(fTimeBufferOut); - } - - // --- If the digi pointer is NULL; the input is exhausted and the buffer - // --- is empty. - return digi; -} -// -------------------------------------------------------------------------- - - -Bool_t CbmSourceLmdNew::GetNextMessage() { - - if ( fRocIter->next() ) fCurrentMessage = &fRocIter->msg(); - - else { // No new message - - // Check if there is another file in the list of files - // and open this file if one exits - fFileCounter += 1; - if ( fInputFileList.GetSize() > fFileCounter ) { - Bool_t success = OpenInputFileAndGetFirstMessage(); - if (!success) { - fCurrentMessage = NULL; - return kFALSE; - } - } - else fCurrentMessage = NULL; - - } //? No new message - return kTRUE; - - - -} -// -------------------------------------------------------------------------- - - - -// ----- Initialisation ------------------------------------------------- -Bool_t CbmSourceLmdNew::Init() -{ - - LOG(info); - LOG(info) << "====================================================="; - LOG(info) << GetName() << ": Initialising ..."; - - if ( NULL == fEventBuilder ) { - LOG(fatal) << "No event builder defined."; - } - - fEventBuilder->Init(); - - if ( NULL == fDaqMap ) { - LOG(fatal) << "No DaqMap defined."; - } - - // Call the init of all registered unpackers - for (std::map<Int_t, CbmROCUnpack*>::iterator it=fUnpackers.begin(); it!=fUnpackers.end(); ++it) { - LOG(info) << "Initialize " << it->second->GetName() << - " for message type " << it->first; - it->second->Init(); - it->second->SetPersistence(fPersistence); - } - - Bool_t success=OpenInputFileAndGetFirstMessage(); - if (!success) return kFALSE; - - if ( fCurrentMessage->getMessageType() != roc::MSG_EPOCH ) { - LOG(error) << GetName() << ": First message is not epoch marker!"; - return kFALSE; - } - - // --- Get start time and set initial buffer fill time - Int_t epoch = fCurrentMessage->getEpochNumber(); - ULong_t time = fCurrentMessage->getMsgFullTime(epoch); - LOG(info) << GetName() << ": First message: epoch " << epoch << " time " - << setprecision(9) << Double_t(time) * 1.e-9 << " s"; - - // --- Set initial buffer fill time (rounded to next read-in time step) - fTimeBufferFill = ULong_t( Double_t(time) / Double_t(fReadInTimeStep) ) - * fReadInTimeStep; - fTimeBufferOut = fTimeBufferFill - fReadInTimeStep; - - // --- Read the first digi from the buffer - fCurrentDigi = GetNextData(); - if ( fCurrentDigi.first.empty() ) { - LOG(error) << GetName() << ": No hit data in input!"; - return kFALSE; - } - - LOG(info) << GetName() << ": Initialisation done. "; - LOG(info) << "====================================================="; - LOG(info); - - return kTRUE; -} -// -------------------------------------------------------------------------- - - - -// ----- Event loop ----------------------------------------------------- -// Action: Digis are retrieved from the buffer one by one. -// If their time is within the association window, they are added to the -// event. If not, the event loop is stopped. -Int_t CbmSourceLmdNew::ReadEvent(UInt_t) -{ - - // The TClonesArrays and everything else is cleared when FairRunOnline - // calls the Reset function right before calling ReadEvent - - // Loop over digis - while ( kTRUE ) { - - // here one should call a more generic function from a separate - // class which defines if a digi belonges to the event or not - - if ( fEventBuilder->IsInEvent(fCurrentDigi.first) ) { - - // --- Copy digi to output array - ECbmModuleId systemId = fCurrentDigi.second; //->GetSystemId(); - Int_t msgType = -1; - if ( static_cast<ECbmModuleId>(999) == systemId ) { // hardcoded number - Int_t val = boost::any_cast<CbmAuxDigi*>(fCurrentDigi.first)->GetRocId(); - if ( val == 666 ) { - CbmTbEvent* CurrentEvent = - dynamic_cast<CbmTbEvent*> (FairRunOnline::Instance()->GetEventHeader()); - - LOG(info) << "Event type is now: " - << CurrentEvent->GetEventType(); - CurrentEvent->SetEventType(1); - LOG(info) << "Event type is now: " - << CurrentEvent->GetEventType(); - fBaselineDataRetrieve = kTRUE; - LOG(info) << "In Old Aux RocId: "<< val; - // FillBaselineDataContainer(); - fNofEvents++; - fNofBaselineDigis = fNofDigis[ToIntegralType(ECbmModuleId::kDummyDet)]; - // remove special aux digi which should not end up in output - delete boost::any_cast<CbmAuxDigi*>(fCurrentDigi); - fCurrentDigi = GetNextData(); - return 0; - } else if ( val == 999 ) { - fBaselineDataRetrieve = kFALSE; - LOG(info) << "Aux RocId: "<< val; - LOG(info) << "Filling " - << ( fNofDigis[ToIntegralType(ECbmModuleId::kDummyDet)] - fNofBaselineDigis ) - << " for this baseline event"; - // remove special aux digi which should not end up in output - delete boost::any_cast<CbmAuxDigi*>(fCurrentDigi); - fCurrentDigi = GetNextData(); - return 0; - } else { - msgType = 4; // This is an Aux digi - fNofAux++; - } - } else { - msgType = ToIntegralType(systemId) + 10; // to get the correct unpacker - } - - std::map<Int_t, CbmROCUnpack*>::iterator it=fUnpackers.find(msgType); - if (it == fUnpackers.end()) { - LOG(error) << "Skipping digi with unknown id " - << msgType; - continue; - } else { - it->second->FillOutput(fCurrentDigi); - if ( kTRUE == fBaselineDataRetrieve ) { - fNofDigis[ToIntegralType(ECbmModuleId::kDummyDet)]++; - fNofBLDigis[ToIntegralType(systemId)]++; - } else { - fNofDigis[ToIntegralType(systemId)]++; - } - } - - - // --- Delete current digi from memory and get next one - // TODO: Chexk if this is a memory leak - // delete fCurrentDigi; - fCurrentDigi = GetNextData(); - if ( fCurrentDigi.first.empty() ) { - LOG(info) << "No more input data. End the run."; - return 1; // no more data; trigger end of run - } - } //? Digi belongs to event? - - // --- If digi does not belong to current event: stop event loop. - else { - if ( FairLogger::GetLogger()->IsLogNeeded(fair::Severity::debug1) ) { - fEventBuilder->PrintCurrentEvent(); - } - fNofEvents++; - return 0; - } - - } //- event loop over digis - - LOG(info) << "===== Leaving Exec. "; - - return 0; -} -// -------------------------------------------------------------------------- - -void CbmSourceLmdNew::Close() -{ - - // Call the finish function for all registered unpackers - // write histos, etc. - for (std::map<Int_t, CbmROCUnpack*>::iterator it=fUnpackers.begin(); it!=fUnpackers.end(); ++it) { - it->second->Finish(); - } - - LOG(info); - LOG(info) << "====================================================="; - fBuffer->PrintStatus(); - LOG(info) << GetName() << ": Run Summary"; - - LOG(info); - LOG(info) << "Messages in input: " << fNofMessages; - Double_t deltaT = (fTimeStop - fTimeStart) / 1.e9; - LOG(info) << "Start time : " << fTimeStart * 1.e-9 << " s "; - LOG(info) << "Stop time : " << fTimeStop * 1.e-9 << " s "; - LOG(info) << "Duration : " << deltaT << " s"; - LOG(info) << "Ignored messages: " << fNofIgnoredMessages; - - - const char* names[8] = { "NOP", "HIT", "EPOCH", "SYNC", "AUX", "EPOCH2", "GET4", "SYS" }; - LOG(info); - LOG(info) << "Messages per message type: "; - for (Int_t i=0; i<8; i++) - LOG(info) << setw(6) << names[i] << " " - << setw(10) << right << fNofMessType[i]; - - LOG(info); - LOG(info) << "Hit messages per ROC/NXYTER: "; - for (Int_t iRoc = 0; iRoc < 13; iRoc ++) - for (Int_t iNx = 0; iNx < 3; iNx +=2 ) { - LOG(info) << " ROC " << setw(2) << iRoc << " NXYTER " << iNx << " Messages " - << setw(12) << right << fNofMessRoc[iRoc][iNx] << " Rate " - << setw(12) << setprecision(4) << fixed << right - << Double_t(fNofMessRoc[iRoc][iNx]) / deltaT - << " /s "; - } - - LOG(info); - LOG(info) << "Hit messages and digis per system: "; - for (ECbmModuleId iSys = ECbmModuleId::kRef; iSys < ECbmModuleId::kNofSystems; ++iSys) { - TString sysName = CbmModuleList::GetModuleNameCaps(iSys); - LOG(info) << setw(5) << sysName << ": Messages " << fNofHitMsg[iSys] - << ", Digis " << fNofDigis[ToIntegralType(iSys)] - << ", BaselineDigis " << fNofBLDigis[ToIntegralType(iSys)] - << ", discarded Digis " << fNofDiscardedDigis[ToIntegralType(iSys)]; - } - LOG(info) << "AUX : Messages " << fNofMessType[roc::MSG_AUX] << ", Digis " - << fNofAux << ", discarded Digis " << fNofDiscardedAux; - - - LOG(info) << "Total number of events: " << fNofEvents; - - delete fRocIter; -} - -void CbmSourceLmdNew::Reset() -{ - // Call the init of all registered unpackers - for (std::map<Int_t, CbmROCUnpack*>::iterator it=fUnpackers.begin(); it!=fUnpackers.end(); ++it) { - it->second->Reset(); - } - - fEventBuilder->Reset(); -} - - -void CbmSourceLmdNew::AddBaselineRoc(Int_t rocNr) { - // fBaselineData is set to kTRUE after the first call of this function - // so the two rocs which are triggered should be set to basline mode - if ( fTriggeredMode && !fBaselineDataFill ) { - fBaselineRoc.insert(11); - fBaselineRoc.insert(12); - LOG(info) << "Triggered mode"; - LOG(info) << "ROC 11" << " now in baseline mode"; - LOG(info) << "ROC 12" << " now in baseline mode"; - } - fBaselineRoc.insert(rocNr); -} - -Bool_t CbmSourceLmdNew::RemoveBaselineRoc(Int_t rocNr) -{ - // Triggered mode and triggered rocs still in set - if (fTriggeredMode && fBaselineRoc.find(11) != fBaselineRoc.end()) { - fBaselineRoc.erase(11); - fBaselineRoc.erase(12); - LOG(info) << "Triggered mode"; - LOG(info) << "ROC 11" << " now in normal mode"; - LOG(info) << "ROC 12" << " now in normal mode"; - } - fBaselineRoc.erase(rocNr); - Bool_t empty = fBaselineRoc.empty(); - return empty; -} - -Bool_t CbmSourceLmdNew::IsBaselineFill(Int_t rocNr) -{ - std::set<Int_t>::iterator it; - if ( fBaselineRoc.find(rocNr) == fBaselineRoc.end() ) { - return kFALSE; - } else { - return kTRUE; - } -} - -Bool_t CbmSourceLmdNew::OpenInputFileAndGetFirstMessage() -{ - TObjString* tmp = - dynamic_cast<TObjString*>(fInputFileList.At(fFileCounter)); - fInputFileName = tmp->GetString(); - LOG(info) << GetName() << ": Opening file " - << fInputFileName; - // Normally one should delete the old object before, but this - // doesn't work and result in a crash when creating a new iterator - fRocIter = new roc::Iterator(fInputFileName.Data()); - if ( ! fRocIter->next() ) { - LOG(error) << GetName() << "::Init: input file does not exist " - << "or is empty!"; - return kFALSE; - } - fCurrentMessage = &fRocIter->msg(); - - return kTRUE; -} - - -ClassImp(CbmSourceLmdNew) diff --git a/beamtime/cosy2014/CbmSourceLmdNew.h b/beamtime/cosy2014/CbmSourceLmdNew.h deleted file mode 100644 index 8a29e89058493e089a63f495ef8580ec5e1c8eef..0000000000000000000000000000000000000000 --- a/beamtime/cosy2014/CbmSourceLmdNew.h +++ /dev/null @@ -1,222 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmSourceLmdNew ----- -// ----- Created 10.11.2014 by F. Uhlig ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CBMSOURCELMDNEW_H -#define CBMSOURCELMDNEW_H - -#include <Rtypes.h> // for ClassDef -#include <RtypesCore.h> // for Int_t, Bool_t, ULong_t, kTRUE, UInt_t -#include <FairLogger.h> // for Logger, LOG -#include <stdint.h> // for uint32_t -#include <map> // for map, operator==, map<>::iterator -#include <set> // for set -#include <utility> // for pair -#include "CbmDefs.h" // for kNofSystems -#include <FairSource.h> // for FairSource, Source_Type, kONLINE -#include <TList.h> // for TList -#include <TObjString.h> // for TObjString -#include <TString.h> // for TString -#include <boost/any.hpp> -#include "CbmTbDaqBuffer.h" -#include <roc/Iterator.h> -#include <roc/Message.h> -class CbmDaqMap; -class CbmROCUnpack; -class CbmTbEventBuilder; - -class CbmSourceLmdNew : public FairSource -{ - public: - CbmSourceLmdNew(); - CbmSourceLmdNew(const char *); -// CbmSourceLmdNew(const CbmSourceLmdNew& source); - virtual ~CbmSourceLmdNew(); - - /** Get time offset for AUX - ** @value AUX time offset (will be added to the AUX time stamp) [ns] - ** - ** The time stamp of the AUX messages is generated on the ROCs, - ** whereas that of the HIT messages is generated on the NXYTERS. - ** Both clocks differ by a constant delay - the AUX come earlier. - ** This is corrected for when producing digis out of the messages. - ** The offset value will be added to the AUX time stamp (by the - ** AUX unpacker), i.e. the AUX will be delayed by this amount. - **/ - ULong_t GetAuxOffset() const { return fAuxOffset; } - - virtual Bool_t Init(); - - Int_t ReadEvent(UInt_t); - - Source_Type GetSourceType() {return kONLINE;} - - virtual void SetParUnpackers() {;} - - virtual Bool_t InitUnpackers() {return kTRUE;} - - virtual Bool_t ReInitUnpackers() {return kTRUE;} - - virtual void Close(); - - virtual void Reset(); - - void SetReadInTimeStep(ULong_t step) { fReadInTimeStep = step; } - void SetPersistence(Bool_t persistence = kTRUE) { fPersistence = persistence; } - - void SetTriggeredMode(Bool_t mode) { fTriggeredMode = mode; } - - void AddFile(const char * fname) - { fInputFileList.Add(new TObjString(fname)); } - - void AddUnpacker(CbmROCUnpack* unpacker, Int_t messageType) - { fUnpackers.insert(std::pair<Int_t,CbmROCUnpack*>(messageType,unpacker));} - - - /** Set the time offset of AUX messages - ** @param offset Time offset of AUX w.r.t. HIT [ns] - ** - ** The time stamp of the AUX messages is generated on the ROCs, - ** whereas that of the HIT messages is generated on the NXYTERS. - ** Both clocks differ by a constant delay - the AUX come earlier. - ** This is corrected for when producing digis out of the messages. - ** The offset value will be added to the AUX time stamp, i.e. - ** they will be delayed by this amount. - **/ - void SetAuxOffset(ULong_t offset) { fAuxOffset = offset; } - - - void SetEventBuilder(CbmTbEventBuilder* eventBuilder) - { fEventBuilder = eventBuilder; } - - void SetDaqMap(CbmDaqMap* daqMap) - { fDaqMap = daqMap; } - - CbmDaqMap* GetDaqMap() { return fDaqMap; } - - void SetBaselineFill(Bool_t baseline) { fBaselineDataFill = baseline; } - Bool_t IsBaselineFill() { return fBaselineDataFill; } - Bool_t IsBaselineFill(Int_t rocNr); - void AddBaselineRoc(Int_t rocNr); - Bool_t RemoveBaselineRoc(Int_t rocNr); - - void SetBaselineRetrieve(Bool_t baseline) { fBaselineDataRetrieve = baseline; } - Bool_t IsBaselineRetrieve() { return fBaselineDataRetrieve; } - - void SetEpoch(Int_t rocNr, uint32_t epochNr) - { fCurrentEpoch[rocNr] = epochNr; } - - void CheckCurrentEpoch(Int_t rocNr) - { - if ( fCurrentEpoch.find(rocNr) == fCurrentEpoch.end() ) { - LOG(fatal) << GetName() - << ": Hit message without previous epoch marker for ROC " - << rocNr; - } - } - - void SetStartTime(ULong_t time) - { fTimeStart = time; } - - void SetStopTime(ULong_t time) - { fTimeStop = time; } - - ULong_t GetStartTime() - { return fTimeStart; } - - ULong_t GetStopTime() - { return fTimeStop; } - - void AddDiscardedDigi(ECbmModuleId system) { fNofDiscardedDigis[ToIntegralType(system)]++; } - void AddDiscardedAux() { fNofDiscardedAux++; } - - private: - - // --- Settings - TString fInputFileName; ///< Name of lmd input file - TList fInputFileList; ///< List of input files - Int_t fFileCounter; ///< Counter the actual file in list - ULong_t fReadInTimeStep; ///< Time step in which data from input are read - Bool_t fPersistence; ///< Flag for file storage of output arrays - ULong_t fAuxOffset; ///< Offset of AUX w.r.t. HIT messages - - // --- Auxiliary classes - CbmTbDaqBuffer* fBuffer; ///< Digi buffer instance - CbmDaqMap* fDaqMap; ///< Mapping from electronics to detectors - roc::Iterator* fRocIter; ///< ROC iterator - CbmTbEventBuilder* fEventBuilder; ///< EventBuilder - - // --- Status - ULong_t fTimeStart; - ULong_t fTimeStop; - ULong_t fCurrentEpochTime; ///< Time stamp of current epoch **/ - UInt_t fStartEpoch; ///< Number of first epoch - - /** Current epoch marker for each ROC **/ - std::map<Int_t, uint32_t> fCurrentEpoch; - - ULong_t fCurrentBufferTime; ///< Time limit of current buffer - roc::Message* fCurrentMessage; //! Current ROC message - ULong_t fTimeBufferFill; ///< Time up to which the buffer was filled - Double_t fTimeBufferOut; ///< Time up to which data from the buffer can be retrieved - - // --- Event status - CbmTbDaqBuffer::Data fCurrentDigi; ///< Pointer to current digi read from buffer - - // --- Counters - Int_t fNofMessages; ///< Number of processed ROC messages - Int_t fNofEpochs; ///< Number of processed ROC epochs messages - Int_t fNofEvents; ///< Number of built events - Int_t fNofMessType[8]; ///< Number of message per message type - Int_t fNofMessRoc[20][5]; ///< Number of messages per ROC and NXYTER - std::map<ECbmModuleId, Int_t> fNofHitMsg; ///< Number of hit messages per detector system - Int_t fNofDigis[ToIntegralType(ECbmModuleId::kNofSystems)]; ///< Number of created digis per detector system - Int_t fNofBLDigis[ToIntegralType(ECbmModuleId::kNofSystems)]; ///< Number of created baseline digis per detector system - Int_t fNofDiscardedDigis[ToIntegralType(ECbmModuleId::kNofSystems)]; ///< Number of created discarded digis per detector system - Int_t fNofAux; ///< Number of AUX messages - Int_t fNofDiscardedAux; ///< Number of discarded AUX messages - Int_t fNofIgnoredMessages; ///< Number of ignores due to unknown system ID - - Bool_t fBaselineDataFill; ///< Flag if the data is for baseline calibration - Bool_t fBaselineDataRetrieve; ///< Flag if the data is for baseline calibration - std::set<Int_t> fBaselineRoc; ///< List of RocIds which already signaled changin of readout status - Bool_t fTriggeredMode; ///< Flag if data is taken in triggered mode - - std::map<Int_t, CbmROCUnpack*> fUnpackers; - - Int_t fNofBaselineDigis; ///< - - /** Fill the buffer from the input - ** @param time Maximal time of input data - ** @return kFALSE if end of input is reached - **/ - Bool_t FillBuffer(ULong_t time); - - - /** Get next digi from the buffer. - ** If necessary, refill the buffer. - ** @return Pointer to next digi object. NULL if no more available. - **/ - CbmTbDaqBuffer::Data GetNextData(); - - - /** Get next message from the roc::iterator **/ - Bool_t GetNextMessage(); - - /** Open a new input file and - ** read the first message from the file - ** @return ???? - **/ - Bool_t OpenInputFileAndGetFirstMessage(); - - CbmSourceLmdNew(const CbmSourceLmdNew& source); - CbmSourceLmdNew& operator=(const CbmSourceLmdNew&); - - ClassDef(CbmSourceLmdNew, 0) -}; - - -#endif diff --git a/beamtime/cosy2014/MuchRealSize.h b/beamtime/cosy2014/MuchRealSize.h deleted file mode 100644 index 961f9e5766d9cbc9052bdaa5427b451ca9b1fec0..0000000000000000000000000000000000000000 --- a/beamtime/cosy2014/MuchRealSize.h +++ /dev/null @@ -1,455 +0,0 @@ -#ifndef REALSIZE_H -#define REALSIZE_H - - // real size GEM -Int_t xl[15][128]= - -{ - -{-3,-3,2,4,2,4,2,4,2,4, -2,4,2,4,2,4,1,5,1,5, -1,5,1,5,1,5,1,5,1,5, -0,3,0,3,0,3,0,3,0,3, -0,3,0,3,2,4,2,4,2,4, -2,4,2,4,2,4,2,4,1,5, -1,5,1,5,1,5,1,5,1,5, -1,5,0,3,0,3,0,3,0,3, -0,3,0,3,0,3,2,4,2,4, -2,4,2,4,2,4,2,4,2,4, -1,5,1,5,1,5,1,5,1,5, -1,5,1,5,0,3,0,3,0,3, -0,3,0,3,0,3,0,3}, - -{ 11,12, -11,12,11,12,11,12,10,12,10,12, -10,12,10,11,10,11,10,11,10,13, -9,13,9,13,9,13,9,13,9,13, -9,13,9,14,8,14,8,14,8,14, -8,14,8,14,8,14,8,15,7,15, -7,15,7,15,7,15,7,15,7,15, --3,16,7,16,6,16,6,16,6,16, -6,16,6,16,6,12,6,12,11,12, -11,12,11,12,10,12,10,12,10,11, -10,11,10,11,10,11,10,13,9,13, -9,13,9,13,9,13,9,13,9,13, -9,14,8,14,8,14,8,14,8,14, -8,14,8,14,8,-3}, - - - - -{19,22,19,22, -19,22,19,22,19,22,19,22,19,22, -18,21,18,21,18,21,18,21,18,21, -18,21,18,21,17,20,17,20,17,20, -17,20,17,20,17,20,17,20,19,22, -19,22,19,22,19,22,19,22,19,22, -19,22,18,21,18,21,18,21,18,21, -18,21,18,21,18,21,17,20,17,20, -17,20,17,20,17,20,17,20,17,20, -19,22,19,22,19,22,19,22,19,22, -19,22,19,22,18,21,18,21,18,21, -18,21,18,21,18,21,18,21,17,20, -17,20,17,20,17,20,17,20,17,20, -17,20,-3,-3}, - -{1,3,1,3,1,3,1,3,1,3, -1,3,1,3,2,4,2,4,2,4, -2,4,2,4,2,4,2,4,0,5, -0,5,0,5,0,5,0,5,0,5, -0,5,1,3,1,3,1,3,1,3, -1,3,1,3,1,3,2,4,2,4, -2,4,2,4,2,4,2,4,2,4, -0,5,0,5,0,5,0,5,0,5, -0,5,0,5,1,3,1,3,1,3, -1,3,1,3,1,3,1,3,2,4, -2,4,2,4,2,4,2,4,2,4, -2,4,0,5,0,5,0,5,0,5, -0,5,0,5,0,5,-3,-3}, - -{7,15, -7,15,7,15,7,15,7,15,7,15, -7,15,6,16,6,16,6,16,6,16, -6,16,6,16,6,16,11,12,11,12, -11,12,10,12,10,12,10,12,10,12, -10,11,10,11,10,11,9,11,9,13, -9,13,9,13,9,13,9,13,9,13, --3,13,8,14,8,14,8,14,8,14, -8,14,8,14,8,14,7,15,7,15, -7,15,7,15,7,15,7,15,7,15, -6,16,6,16,6,16,6,16,6,16, -6,16,6,16,11,12,11,12,11,12, -10,12,10,12,10,12,10,12,10,11, -10,11,10,11,-3,11}, - -{19,22, -19,22,19,22,19,22,19,22,19,22, -19,22,18,21,18,21,18,21,18,21, -18,21,18,21,18,21,17,20,17,20, -17,20,17,20,17,20,17,20,17,20, -19,22,19,22,19,22,19,22,19,22, -19,22,19,22,18,21,18,21,18,21, -18,21,18,21,18,21,18,21,17,20, -17,20,17,20,17,20,17,20,17,20, -17,-3,19,20,19,19,22,22,19,22, -19,22,19,22,19,22,18,22,18,21, -18,21,18,21,18,21,18,21,18,21, -17,21,17,20,17,20,17,20,17,20, -17,20,17,20,-3,20}, - -{6,6,6,6, -6,6,6,7,7,7,7,7,7,7, -8,8,8,8,8,8,8,9,9,9, -9,9,9,9,10,10,10,10,10,10, -10,11,11,11,0,3,0,3,0,3, -0,3,0,3,0,3,0,3,1,4, -1,4,1,4,1,4,1,4,1,4, -1,4,2,5,2,5,2,5,2,5, -2,5,2,5,2,5,6,6,6,6, -6,6,6,7,7,7,7,7,7,7, -8,8,8,8,8,8,8,9,9,9, -9,9,9,9,10,10,10,10,10,10, -10,11,11,11,0,3,0,3,0,3, -0,3,0,3}, - -{9,13,9,13,9,13, -9,13,9,13,9,13,9,13,8,14, -8,14,8,14,8,14,8,14,8,14, -8,14,7,15,7,15,7,15,7,15, -7,15,7,15,7,15,6,16,6,16, -6,16,6,16,6,16,6,16,6,16, -11,12,11,12,11,12,-3,12,10,12, -10,12,10,12,10,11,10,11,10,11, -10,11,9,13,9,13,9,13,9,13, -9,13,9,13,9,13,8,14,8,14, -8,14,8,14,8,14,8,14,8,14, -7,15,7,15,7,15,7,15,7,15, -7,15,7,15,6,16,6,16,6,16, -6,16} , - - -{16,16,16,16,16,16,16,16, -15,16,15,16,15,15,14,15,14,15, -14,15,14,14,13,14,13,14,13,13, -12,13,12,13,12,13,12,12,11,12, -11,12,20,11,20,11,20,22,20,22, -20,22,20,22,20,22,19,22,19,22, -19,21,19,21,19,21,19,21,19,21, -18,21,18,21,18,18,17,18,17,18, -17,18,17,17,16,17,16,17,16,16, -15,16,15,16,15,16,15,15,14,15, -14,14,15,14,13,14,13,14,13,14, -13,13,12,13,12,13,12,12,11,12, -11,12,20,12,20,11,20,11,20,22}, - -{0,3,0,4,1,-3,1,4,1,4, -1,4,1,4,1,4,1,4,-3,5, -2,5,2,5,2,5,2,5,2,5, -2,5,6,6,6,6,6,6,6,-3, -7,7,7,7,7,7,8,8,8,8, -8,8,8,9,9,9,9,9,9,9, -10,10,10,10,10,10,10,11,11,11, -0,3,0,3,0,3,0,3,0,3, -0,3,0,3,1,4,1,4,1,4, -1,4,1,4,1,4,1,4,2,5, -2,5,2,5,2,5,2,5,2,5, -2,5,6,6,6,6,6,6,6,7, -7,7,7,7,7,7,8,8}, - -{19,22, -19,18,22,18,22,22,18,22,18,22, -18,21,18,21,18,21,17,21,17,21, -17,21,17,21,17,20,17,20,17,20, -16,19,16,19,16,19,16,19,16,19, -15,16,15,16,15,15,14,15,14,15, -14,15,14,14,13,14,13,14,-3,13, -13,13,20,13,20,12,20,12,20,12, -20,12,20,12,20,12,19,12,19,11, -19,11,19,11,19,11,19,22,19,22, -18,22,18,22,18,22,18,22,18,22, -18,21,18,21,17,21,17,21,17,21, -17,21,17,21,16,17,16,-3,16,16, -15,16,15,16,15,16}, - - -{8,10,8,10,8, -11,8,11,8,11,9,2,9,2,9, -2,9,2,9,2,9,2,9,2,10, -1,10,2,10,3,10,4,10,5,0, -1,0,2,0,3,0,4,0,5,0, -1,0,5,0,4,0,3,0,2,0, -5,0,4,1,3,1,2,0,1,1, -4,1,4,1,4,1,4,0,1,1, -2,1,3,1,4,2,5,2,4,3, -4,3,4,3,4,3,4,3,5,3, -5,3,1,3,2,0,3,3,5,5, -5,5,5,5,-3,5,-3,-3,-3,-3, -5,-3,4,5,-3,-3,4,-3,1,0, -2,-3,3}, - -{12,15,12,15, -12,15,12,15,12,14,12,14,12,14, -11,14,11,14,11,14,11,14,21,13, -21,13,21,13,21,13,21,13,21,13, -17,13,20,22,19,22,18,22,17,22, -20,22,21,22,19,22,18,22,17,22, -20,22,19,22,18,22,17,21,21,22, -19,21,20,21,19,21,18,21,17,22, -21,20,20,20,19,20,18,20,17,20, -19,20,19,20,19,20,19,20,18,19, -18,19,18,19,18,22,21,19,18,18, -17,18,-3,18,19,18,18,17,17,17, -17,-3,17,17,17,17,18,17,19,-3, -20,-3,21,22}, - -{11,11,11,10,10,11, -11,11,11,11,11,11,11,11,11,10, -11,9,20,9,9,10,10,10,10,10, -10,10,10,10,10,10,10,10,9,9, -9,9,8,8,9,9,9,9,9,9, -9,9,9,8,8,8,8,8,8,8, -8,8,8,8,8,8,8,7,-3,-3, --3,-3,-3,-3,-3,-3,-3,-3,-3,-3, --3,-3,-3,-3,-3,-3,-3,-3,-3,-3, --3,-3,-3,-3,-3,-3,-3,-3,-3,-3, --3,6,7,6,6,7,7,7,7,7, -7,7,7,7,7,7,7,7,6,7, -6,6,6,6,6,6,6,6,6,6, -6,6}, - -{16,16,16,16,16,16,16,16, -16,16,16,16,16,-3,-3,-3,-3,-3, --3,-3,-3,-3,-3,-3,-3,15,15,15, -15,15,15,15,15,15,15,15,15,15, -16,16,15,16,-3,15,-3,-3,-3,-3, --3,-3,-3,-3,-3,-3,-3,-3,-3,-3, --3,-3,-3,-3,-3,-3,-3,15,14,14, -14,14,14,14,14,14,14,14,14,14, -13,13,13,13,14,13,13,13,14,14, -13,13,13,13,12,12,12,14,12,13, -12,12,11,12,13,12,12,12,12,12, -12,12,12,13,12,13,-3,-3,-3,-3, --3,-3,-3,-3,-3,-3,-3,-3,-3,-3} - -}; - - -/// y mapping GEM -Int_t yl[15][128] = { -{-3,-3,0,0,1,1,2,2,3,3, -4,4,5,5,6,6,6,0,5,1, -4,2,3,3,2,4,1,5,0,6, -6,6,5,5,4,4,3,3,2,2, -1,1,0,0,7,7,8,8,9,9, -10,10,11,11,12,12,13,13,13,7, -12,8,11,9,10,10,9,11,8,12, -7,13,13,13,12,12,11,11,10,10, -9,9,8,8,7,7,14,14,15,15, -16,16,17,17,18,18,19,19,20,20, -20,14,19,15,18,16,17,17,16,18, -15,19,14,20,20,20,19,19,18,18, -17,17,16,16,15,15,14,14}, - -{0,6, -1,5,2,4,3,3,6,2,5,1, -4,0,3,6,2,5,1,4,0,0, -6,1,5,2,4,3,3,4,2,5, -1,6,0,0,6,1,5,2,4,3, -3,4,2,5,1,6,0,0,6,1, -5,2,4,3,3,4,2,5,1,6, --3,0,0,1,6,2,5,3,4,4, -3,5,2,6,1,13,0,12,7,11, -8,10,9,9,13,8,12,7,11,13, -10,12,9,11,8,10,7,7,13,8, -12,9,11,10,10,11,9,12,8,13, -7,7,13,8,12,9,11,10,10,11, -9,12,8,13,7,-3}, - -{6,2,5,1, -4,0,3,3,2,4,1,5,0,6, -6,6,5,5,4,4,3,3,2,2, -1,1,0,0,6,6,5,5,4,4, -3,3,2,2,1,1,0,0,13,9, -12,8,11,7,10,10,9,11,8,12, -7,13,13,13,12,12,11,11,10,10, -9,9,8,8,7,7,13,13,12,12, -11,11,10,10,9,9,8,8,7,7, -20,16,19,15,18,14,17,17,16,18, -15,19,14,20,20,20,19,19,18,18, -17,17,16,16,15,15,14,14,20,20, -19,19,18,18,17,17,16,16,15,15, -14,14,-3,-3}, - -{25,21,26,22,27,23, -24,24,23,25,22,26,21,27,21,21, -22,22,23,23,24,24,25,25,26,26, -27,27,27,21,26,22,25,23,24,24, -23,25,22,26,21,27,32,28,33,29, -34,30,31,31,30,32,29,33,28,34, -28,28,29,29,30,30,31,31,32,32, -33,33,34,34,34,28,33,29,32,30, -31,31,30,32,29,33,28,34,38,35, -37,36,36,37,35,38,39,39,40,40, -41,41,35,35,36,36,37,37,38,38, -39,39,40,40,41,41,41,35,40,36, -39,37,38,38,37,39,36,40,35,41, --3,-3}, - -{13,7,12,8,11,9,10,10, -9,11,8,12,7,13,13,7,12,8, -11,9,10,10,9,11,8,12,7,13, -14,20,15,19,16,18,20,17,19,16, -18,15,17,14,16,20,15,19,14,18, -20,17,19,14,18,15,17,16,16,17, -15,18,14,19,-3,20,20,14,19,15, -18,16,17,17,16,18,15,19,14,20, -20,14,19,15,18,16,17,17,16,18, -15,19,14,20,20,14,19,15,18,16, -17,17,16,18,15,19,14,20,21,27, -22,26,23,25,27,24,26,23,25,22, -24,21,23,27,22,26,21,25,-3,24}, - -{27,24,26,25,25,26,24,27,23,23, -22,22,21,21,27,27,26,26,25,25, -24,24,23,23,22,22,21,21,27,27, -26,26,25,25,24,24,23,23,22,22, -21,21,34,31,33,32,32,33,31,34, -30,30,29,29,28,28,34,34,33,33, -32,32,31,31,30,30,29,29,28,28, -34,34,33,33,32,32,31,31,30,30, -29,29,28,-3,41,28,40,39,38,39, -38,40,37,41,36,37,35,36,41,35, -40,41,39,40,38,39,37,38,36,37, -35,36,41,35,40,41,39,40,38,39, -37,38,36,37,35,36,-3,35}, - -{35,28, -37,29,39,30,41,35,36,37,38,39, -40,41,35,36,37,38,39,40,41,35, -36,37,38,39,40,41,35,36,37,38, -39,40,41,35,36,37,48,42,47,43, -46,44,45,45,44,46,43,47,42,48, -42,42,43,43,44,44,45,45,46,46, -47,47,48,48,42,42,43,43,44,44, -45,45,46,46,47,47,48,48,42,43, -44,45,46,47,48,42,43,44,45,46, -47,48,42,43,44,45,46,47,48,42, -43,44,45,46,47,48,42,43,44,45, -46,47,48,42,43,44,55,49,54,50, -53,51,52,52,51,53}, -{27,21,26,22, -25,23,24,24,23,25,22,26,21,27, -27,21,26,22,25,23,24,24,23,25, -22,26,21,27,27,21,26,22,25,23, -24,24,23,25,22,26,21,27,27,21, -26,22,25,23,24,24,23,25,22,26, -21,27,28,34,29,33,30,32,-3,31, -34,30,33,29,32,28,31,34,30,33, -29,32,28,31,34,28,33,29,32,30, -31,31,30,32,29,33,28,34,34,28, -33,29,32,30,31,31,30,32,29,33, -28,34,34,28,33,29,32,30,31,31, -30,32,29,33,28,34,34,28,33,29, -32,30,31,31}, -{34,41,33,40,32,39, -35,38,40,37,38,36,36,41,41,39, -39,37,37,35,35,40,40,38,38,36, -36,41,41,39,39,37,37,35,35,40, -40,38,38,36,48,41,47,39,46,42, -45,43,44,44,43,45,42,46,48,47, -47,48,46,48,45,47,44,46,43,45, -42,44,47,43,45,42,43,48,48,46, -46,44,44,42,42,47,47,45,45,43, -43,48,48,46,46,44,44,42,42,47, -47,45,45,48,43,43,48,46,46,44, -44,42,42,47,47,45,45,43,43,48, -48,46,46,44,55,42,54,47,53,45, -52,49}, -{50,54,49,49,49,-3,50,50, -51,51,52,52,53,53,54,54,55,55, --3,49,50,50,51,51,52,52,53,53, -54,54,55,55,49,50,51,52,53,54, -55,-3,50,51,52,53,54,55,49,50, -51,52,53,54,55,49,50,51,52,53, -54,55,49,50,51,52,53,54,55,49, -50,51,62,56,61,57,60,58,59,59, -58,60,57,61,56,62,56,56,57,57, -58,58,59,59,60,60,61,61,62,62, -56,56,57,57,58,58,59,59,60,60, -61,61,62,62,56,57,58,59,60,61, -62,56,57,58,59,60,61,62,57,56}, - -{50,50,49,54,51,55,52,53,53,54, -52,55,51,55,50,54,49,53,55,52, -54,51,53,50,52,49,51,51,50,50, -49,49,55,55,54,54,53,53,51,52, -49,51,54,52,52,50,50,55,55,53, -53,51,51,49,49,54,54,52,52,50, --3,55,50,53,62,49,61,55,60,54, -59,53,58,52,57,51,56,50,62,49, -61,55,60,54,59,53,58,52,57,56, -56,57,62,58,61,59,60,60,59,61, -58,62,57,62,56,61,62,60,61,59, -60,58,58,57,56,56,61,59,59,-3, -57,62,62,60,61,58,60,56}, -{58,61, -59,62,60,56,61,57,62,58,56,63, -57,64,58,65,59,66,60,67,61,68, -62,69,56,72,57,72,58,72,59,72, -60,72,72,73,73,73,71,73,70,73, -69,73,68,74,74,74,67,74,66,74, -65,74,64,75,63,75,63,75,64,75, -75,75,65,63,66,64,67,65,68,66, -76,76,69,76,70,76,71,76,70,76, -71,67,63,68,64,69,65,70,66,71, -67,63,68,64,69,77,70,77,77,77, -71,67,65,69,66,71,68,-3,70,-3, --3,-3,-3,77,-3,77,78,-3,-3,78, --3,78,78,78,-3,78}, -{62,59,61,58,60,57,59,56,58,62, -57,61,56,60,62,59,61,58,60,57, -59,56,73,62,72,61,71,60,70,59, -69,58,68,57,71,56,72,72,72,71, -72,70,72,69,73,73,74,74,73,68, -73,67,73,66,74,65,74,64,74,63, -74,67,75,75,67,66,75,65,75,64, -75,63,75,76,76,71,76,70,76,69, -76,68,76,67,66,66,65,65,64,64, -63,63,71,71,70,70,69,69,67,77, -77,68,64,68,70,66,-3,65,77,63, -77,69,77,68,65,-3,63,67,78,66, -78,64,78,-3,78,-3,78,78}, -{71,78,70,77,76,76, -69,75,68,74,67,73,66,72,65,78, -64,78,77,77,76,75,74,73,72,71, -70,69,68,67,66,65,64,63,75,74, -73,72,76,77,71,70,69,68,67,66, -65,64,63,75,74,73,72,71,70,69, -68,67,66,65,64,78,63,77,-3,-3, --3,-3,-3,-3,-3,-3,-3,-3,-3,-3, --3,-3,-3,-3,-3,-3,-3,-3,-3,-3, --3,-3,-3,-3,-3,-3,-3,-3,-3,-3, --3,78,76,77,76,78,74,75,72,73, -70,71,68,69,66,67,64,65,75,63, -73,74,71,72,69,70,67,68,65,66, -63,64}, -{73,72,71,74,69,70,68,67, -66,65,64,63,75,-3,-3,-3,-3,-3, --3,-3,-3,-3,-3,-3,-3,74,73,72, -71,70,69,68,67,66,65,64,63,75, -76,78,76,77,-3,78,-3,-3,-3,-3, --3,-3,-3,-3,-3,-3,-3,-3,-3,-3, --3,-3,-3,-3,-3,-3,-3,77,73,72, -71,70,69,74,68,67,66,65,64,63, -73,71,70,69,75,74,68,67,76,77, -66,65,64,63,73,72,71,78,70,78, -69,68,77,78,75,77,74,67,66,65, -64,63,75,76,76,77,-3,-3,-3,-3, --3,-3,-3,-3,-3,-3,-3,-3,-3,-3} - - -}; - - - -#endif diff --git a/beamtime/cosy2014/fhodo/CbmFiberHodoBLCalibrator.cxx b/beamtime/cosy2014/fhodo/CbmFiberHodoBLCalibrator.cxx deleted file mode 100644 index 52c000597c68119d2f2f4e93e4bbc242028dc98a..0000000000000000000000000000000000000000 --- a/beamtime/cosy2014/fhodo/CbmFiberHodoBLCalibrator.cxx +++ /dev/null @@ -1,164 +0,0 @@ -#include "CbmFiberHodoBLCalibrator.h" - -#include "CbmFiberHodoDigi.h" -#include "CbmFiberHodoAddress.h" - -#include "FairLogger.h" -#include "FairRunAna.h" -#include "FairRunOnline.h" -#include "FairRuntimeDb.h" - -#include "TClonesArray.h" - -CbmFiberHodoBLCalibrator::CbmFiberHodoBLCalibrator() -:FairTask("CbmFiberHodoBLCalibrator"), - fBaselineDigis(NULL), - fBaselines() -{ - LOG(debug) << "Default Constructor of CbmFiberHodoBLCalibrator"; -} - - -CbmFiberHodoBLCalibrator::~CbmFiberHodoBLCalibrator() -{ - LOG(debug) << "Destructor of CbmFiberHodoBLCalibrator"; - for( Int_t iStation = 0; iStation < fBaselines.size(); iStation++ ) { - for( Int_t iSide = 0; iSide < fBaselines.at( iStation ).size(); iSide++ ) { - for( Int_t iStrip = 0; iStrip < fBaselines.at( iStation ).at( iSide ).size(); iStrip++ ) { - TH1F * baselineHist = fBaselines.at( iStation ).at( iSide ).at( iStrip ); - if( baselineHist ) { - delete baselineHist; - } - baselineHist = NULL; - } - } - } - fBaselines.clear(); -} - - - -void CbmFiberHodoBLCalibrator::SetParContainers() -{ - -} - - - -InitStatus CbmFiberHodoBLCalibrator::Init() -{ - // Get a handle from the IO manager - FairRootManager* ioman = FairRootManager::Instance(); - - // Get a pointer to the previous already existing data level - - fBaselineDigis = (TClonesArray*) ioman->GetObject("HodoBaselineDigi"); - if ( ! fBaselineDigis ) { - LOG(error) << "No input data object HodoBaselineDigi found!"; - LOG(error) << " Task CbmFiberHodoBLCalibrator will be inactive"; - return kERROR; - } - - Int_t kBaselineMinAdc = 0; - Int_t kBaselineMaxAdc = 4096; - Int_t kBaselineNBins = 4096; - - Int_t kNStations = 2; // TODO: from where do I get the number of stations? - Int_t kNSides = 2; // TODO: from where do I get the number of sides per station? - Int_t kNStrips = 64; // TODO: from where do I get the number of strips per station side? - - fBaselines.resize( kNStations ); - - for( Int_t iStation = 0; iStation < fBaselines.size(); iStation++ ) { - fBaselines.at( iStation ).resize( kNSides ); - for( Int_t iSide = 0; iSide < fBaselines.at( iStation ).size(); iSide++ ) { - fBaselines.at( iStation ).at( iSide ).resize( kNStrips ); - for( Int_t iStrip = 0; iStrip < fBaselines.at( iStation ).at( iSide ).size(); iStrip++ ) { - const char * nametitle = Form( "fh_blhist_sta%d_side%d_str%d", iStation, iSide, iStrip ); - fBaselines.at( iStation ).at( iSide ).at( iStrip ) = new TH1F( nametitle, nametitle, kBaselineNBins, kBaselineMinAdc, kBaselineMaxAdc ); - } - } - } - - return kSUCCESS; -} - - - -InitStatus CbmFiberHodoBLCalibrator::ReInit() -{ - LOG(debug) << "Initilization of CbmFiberHodoBLCalibrator"; - return kSUCCESS; -} - - - -void CbmFiberHodoBLCalibrator::Exec(Option_t* /*option*/) -{ - - - Int_t nBaselineEntries = fBaselineDigis->GetEntriesFast(); - if( nBaselineEntries ) { // TODO: Check here in a proper way if the event is a baseline event - - - /* Baseline data should be taken from only one iteration of the baseline measurement - * (i.e. data from several different iterations of baseline calibration should not be mixed up) - * Therefore the baseline histograms should be zeroed before filling them with the data of the - * next calibration iteration */ - for( Int_t iStation = 0; iStation < fBaselines.size(); iStation++ ) { - for( Int_t iSide = 0; iSide < fBaselines.at( iStation ).size(); iSide++ ) { - for( Int_t iStrip = 0; iStrip < fBaselines.at( iStation ).at( iSide ).size(); iStrip++ ) { - fBaselines.at( iStation ).at( iSide ).at( iStrip )->Reset(); - } - } - } - - for( Int_t iDigi = 0; iDigi < nBaselineEntries; ++iDigi ) { - CbmFiberHodoDigi* digi = static_cast< CbmFiberHodoDigi * >( fBaselineDigis->At( iDigi ) ); - - Int_t address = digi->GetAddress(); - Int_t station = CbmFiberHodoAddress::GetStationId(address); - Int_t side = CbmFiberHodoAddress::GetSideId(address); - Int_t strip = CbmFiberHodoAddress::GetStripId(address); - Double_t adc = digi->GetCharge(); - - fBaselines.at( station ).at( side ).at( strip )->Fill( adc ); - } - - for( Int_t iStation = 0; iStation < fBaselines.size(); iStation++ ) { - for( Int_t iSide = 0; iSide < fBaselines.at( iStation ).size(); iSide++ ) { - for( Int_t iStrip = 0; iStrip < fBaselines.at( iStation ).at( iSide ).size(); iStrip++ ) { - TH1F * blHist = fBaselines.at( iStation ).at( iSide ).at( iStrip ); - if( blHist->GetEntries() ) { - Double_t bl = GetBlPos( blHist ); - LOG(info) << "Baseline of station " << iStation << " side " << iSide << " strip " << iStrip << " is " << bl; - } - } - } - } - } - -} - - - -void CbmFiberHodoBLCalibrator::Finish() -{ -} - - - -Double_t CbmFiberHodoBLCalibrator::GetBlPos( TH1F * hist ) -{ - Int_t medianBin = 1; - - Double_t * integral = hist->GetIntegral(); - while( integral[ medianBin + 1 ] <= 0.5 ) { - medianBin++; - } - - return hist->GetXaxis()->GetBinCenter( medianBin ); -} - - -ClassImp(CbmFiberHodoBLCalibrator) diff --git a/beamtime/cosy2014/fhodo/CbmFiberHodoBLCalibrator.h b/beamtime/cosy2014/fhodo/CbmFiberHodoBLCalibrator.h deleted file mode 100644 index 209e976aa9438d32e547d9b0c6dcd58f7b2194de..0000000000000000000000000000000000000000 --- a/beamtime/cosy2014/fhodo/CbmFiberHodoBLCalibrator.h +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef CBMFIBERHODOBLCALIBRATOR_H -#define CBMFIBERHODOBLCALIBRATOR_H - -#include "FairTask.h" - -#include "TH1F.h" -#include <vector> - -class TClonesArray; - -class CbmFiberHodoBLCalibrator : public FairTask -{ - public: - - /** Default constructor **/ - CbmFiberHodoBLCalibrator(); - - /** Destructor **/ - ~CbmFiberHodoBLCalibrator(); - - /** Initiliazation of task at the beginning of a run **/ - virtual InitStatus Init(); - - /** ReInitiliazation of task when the runID changes **/ - virtual InitStatus ReInit(); - - /** Executed for each event. **/ - virtual void Exec(Option_t* opt); - - /** Load the parameter container from the runtime database **/ - virtual void SetParContainers(); - - /** Finish task called at the end of the run **/ - virtual void Finish(); - - private: - - /** Input array from previous already existing data level **/ - TClonesArray* fBaselineDigis; - - std::vector< std::vector < std::vector < TH1F * > > > fBaselines; - - static Double_t GetBlPos( TH1F * hist ); - - CbmFiberHodoBLCalibrator(const CbmFiberHodoBLCalibrator&); - CbmFiberHodoBLCalibrator operator=(const CbmFiberHodoBLCalibrator&); - - ClassDef(CbmFiberHodoBLCalibrator,1); -}; - -#endif diff --git a/beamtime/cosy2014/fhodo/CbmFiberHodoClusterFinder.cxx b/beamtime/cosy2014/fhodo/CbmFiberHodoClusterFinder.cxx deleted file mode 100644 index 423dc0b5e462f662a0eef3a97736d21e2588ceec..0000000000000000000000000000000000000000 --- a/beamtime/cosy2014/fhodo/CbmFiberHodoClusterFinder.cxx +++ /dev/null @@ -1,389 +0,0 @@ -#include "CbmFiberHodoClusterFinder.h" - -#include <FairTask.h> // for InitStatus, kSUCCESS, FairTask, kERROR -#include <TH1.h> // for TH1F -#include <TH2.h> // for TH2F -#include <TMathBase.h> // for Abs -#include <TString.h> // for TString -#include <FairLogger.h> // for LOG -#include <stddef.h> // for NULL -#include "CbmFiberHodoAddress.h" // for CbmFiberHodoAddress -#include "CbmFiberHodoCluster.h" // for CbmFiberHodoCluster -#include "CbmFiberHodoDigi.h" // for CbmFiberHodoDigi -#include <FairRootManager.h> // for FairRootManager -#include <FairRunAna.h> // for FairRunAna -#include <TClonesArray.h> // for TClonesArray -#include <TMath.h> // for Sqrt - -using std::map; -using std::set; -using namespace std; - -// ---- Default constructor ------------------------------------------- -CbmFiberHodoClusterFinder::CbmFiberHodoClusterFinder() - :FairTask("FiberHodoClusterFinder",1), - fDigis(NULL), - fClusters(NULL), - finalClusters(NULL), - fDigiMap(), - fInputLevelName("HodoCalibDigi"), - hodo1_pos(NULL), - hodo2_pos(NULL), - hodo1_xcor(NULL), - hodo2_xcor(NULL), - hodo1_ycor(NULL), - hodo2_ycor(NULL), - hodo1x(NULL), - hodo1y(NULL), - hodo2x(NULL), - hodo2y(NULL), - hodo_xx(NULL), - hodo_yy(NULL), - hodo1_pos_nocut(NULL), - hodo1x_nocut(NULL), - hodo1y_nocut(NULL) -{ -} -// -------------------------------------------------------------------- - -// ---- Destructor ---------------------------------------------------- -CbmFiberHodoClusterFinder::~CbmFiberHodoClusterFinder() -{ - - if(fClusters){ - fClusters->Clear("C"); - fClusters->Delete(); - delete fClusters; - } - if(finalClusters){ - finalClusters->Clear("C"); - finalClusters->Delete(); - delete finalClusters; - } -} - -// ---- Initialisation ---------------------------------------------- -void CbmFiberHodoClusterFinder::SetParContainers() -{ - - // Get Base Container - FairRunAna* ana = FairRunAna::Instance(); - /*FairRuntimeDb* rtdb =*/ ana->GetRuntimeDb(); - -} -// -------------------------------------------------------------------- - -// ---- ReInit ------------------------------------------------------- -InitStatus CbmFiberHodoClusterFinder::ReInit(){ - - FairRunAna* ana = FairRunAna::Instance(); - /*FairRuntimeDb* rtdb =*/ ana->GetRuntimeDb(); - - return kSUCCESS; -} -// -------------------------------------------------------------------- - -// ---- Init ---------------------------------------------------------- -InitStatus CbmFiberHodoClusterFinder::Init() -{ - - FairRootManager *ioman = FairRootManager::Instance(); - - fDigis = ioman->InitObjectAs<std::vector<CbmFiberHodoDigi> const *>(fInputLevelName); - -// fDigis =(TClonesArray *) ioman->GetObject(fInputLevelName); - if ( ! fDigis ) { - LOG(error) << "No FiberHodoDigi array!"; - LOG(error) << "Task will be inactive"; - return kERROR; - } - - finalClusters = new TClonesArray("CbmFiberHodoCluster", 100); - ioman->Register("FiberHodoCluster","TRD",finalClusters,IsOutputBranchPersistent("FiberHodoCluster")); - - fClusters = new TClonesArray("CbmFiberHodoCluster", 100); - ioman->Register("FiberHodoClusterCandidate","TRD",fClusters,IsOutputBranchPersistent("FiberHodoClusterCandidate")); - - hodo1x = new TH1F("hodo1x", "Hodo 1 x", 64, 0., 64.); - hodo1y = new TH1F("hodo1y", "Hodo 1 y", 64, 0., 64.); - hodo1x_nocut = new TH1F("hodo1x_nocut", "Hodo 1 x, nocut", 64, 0., 64.); - hodo1y_nocut = new TH1F("hodo1y_nocut", "Hodo 1 y, nocut", 64, 0., 64.); - hodo2x = new TH1F("hodo2x", "Hodo 2 x", 64, 0., 64.); - hodo2y = new TH1F("hodo2y", "Hodo 2 y", 64, 0., 64.); - - hodo1_pos = new TH2F("xy1", "y vs. x Hodo 1", 64, 0., 64., 64, 0., 64.); - hodo1_pos_nocut = new TH2F("xy1_nocut", "y vs. x Hodo 1, nocut", 64, 0., 64., 64, 0., 64.); - hodo2_pos = new TH2F("xy2", "y vs. x Hodo 2", 64, 0., 64., 64, 0., 64.); - - hodo1_xcor = new TH2F("x1deltax", "deltax vs. x1", 64, 0., 64., 32, -32., 32.); - hodo2_xcor = new TH2F("x2deltax", "deltax vs. x2", 64, 0., 64., 32, -32., 32.); - - hodo1_ycor = new TH2F("y1deltay", "deltay vs. y1", 64, 0., 64., 32, -32., 32.); - hodo2_ycor = new TH2F("y2deltay", "deltay vs. y2", 64, 0., 64., 32, -32., 32.); - - hodo_xx = new TH2F("xx", "x2 vs. x1", 64, 0., 64., 64, 0., 64.); - hodo_yy = new TH2F("yy", "y2 vs. y1", 64, 0., 64., 64, 0., 64.); - - return kSUCCESS; - -} -// -------------------------------------------------------------------- - -// ---- Exec ---------------------------------------------------------- -void CbmFiberHodoClusterFinder::Exec(Option_t* /*option*/) -{ - - fClusters->Clear(); - finalClusters->Clear(); - - map<Int_t, set<const CbmFiberHodoDigi*, classcomp> >::iterator mapIt; - for (mapIt=fDigiMap.begin(); mapIt!=fDigiMap.end(); mapIt++) - { - ((*mapIt).second).clear(); - } - fDigiMap.clear(); - - set<Int_t> layerSet; - - const CbmFiberHodoDigi* digi = NULL; - - // sort all digis according the detector layer into different sets - // defining a order functor for the set should result in a set which - // is already ordered from small to big strip numbers - - map<const CbmFiberHodoDigi*, Int_t> fIndices; - - Int_t nofDigis = fDigis->size(); - - for (Int_t iDigi=0; iDigi < nofDigis; iDigi++ ) - { - // cout << " CbmFiberHodoClusterFinder:: Clear all output structures/container" << endl; - digi = &(fDigis->at(iDigi)); - Int_t layer = CbmFiberHodoAddress::GetLayerAddress(digi->GetAddress()); - if(digi->GetCharge() > 100) - { - layerSet.insert(layer); - fDigiMap[layer].insert(digi); - fIndices.at(digi)=iDigi; - } - } - set <const CbmFiberHodoDigi*, classcomp> digiSet; - - // cout << " loop over all detector layers and for each detector layer loop over the " << endl; - // already sorted strips to do the cluster finding. A cluster is defined by - // neighboring strips which are above the threshold - // TODO: Decide if the condition of the ADC threshold should be done here or - // in the unpacking - // Check if the set is realy ordered with increasing strip number - for (set<Int_t>::iterator i = layerSet.begin(); i != layerSet.end(); i++) - { - digiSet = fDigiMap[*i]; - Bool_t newCluster = kTRUE; - Int_t fiberNr = -1; - Int_t fiberNrPrev = -1; -/* Int_t cluster_size =0;*/ - Double_t time = -1; - Double_t timePrev = -1; - for (set<const CbmFiberHodoDigi*, classcomp>::iterator j = digiSet.begin(); j != digiSet.end(); j++) - { - if (newCluster) - { - new ((*fClusters)[fClusters->GetEntriesFast()]) - CbmFiberHodoCluster(fIndices[*j]); - fiberNrPrev = CbmFiberHodoAddress::GetStripId((*j)->GetAddress()); - newCluster = kFALSE; - digi = &(fDigis->at(fIndices.at(*j))); - timePrev = digi->GetTime(); - } - else - { - // check if the next fiber is a direct neighbor of the previos one - fiberNr = CbmFiberHodoAddress::GetStripId((*j)->GetAddress()); - digi = &(fDigis->at(fIndices.at(*j))); - time = digi->GetTime(); - if (1 == fiberNr-fiberNrPrev && TMath::Abs(time -timePrev)< 40 ) - { - fiberNrPrev = fiberNr; - CbmFiberHodoCluster* cluster = (CbmFiberHodoCluster*) fClusters->Last(); - Int_t index = fIndices[(*j)]; - cluster->AddDigi(index); - } - else - { - new ((*fClusters)[fClusters->GetEntriesFast()]) - CbmFiberHodoCluster(fIndices[*j]); - fiberNrPrev = CbmFiberHodoAddress::GetStripId((*j)->GetAddress()); - newCluster = kFALSE; - } - } - } - } - if(nofDigis>0) - { - Int_t nofClusterCandidates = fClusters->GetEntriesFast(); - int clust[4]={0,0,0,0}; - for (Int_t iclus = 0; iclus < nofClusterCandidates; iclus++) - { - const CbmFiberHodoCluster* cluster = static_cast<const CbmFiberHodoCluster*>(fClusters->At(iclus)); -/* Int_t nofFiber = cluster->GetNofDigis();*/ - const CbmFiberHodoDigi* hodoDigi = &(fDigis->at(cluster->GetDigi(0))); - int layer= CbmFiberHodoAddress::GetLayerAddress(hodoDigi->GetAddress()); -/* int fiber = CbmFiberHodoAddress::GetStripId(hodoDigi->GetAddress());*/ - if(layer>2) - { - if(layer==16) - clust[2]++; - if(layer==17) - clust[3]++; - } - else - clust[layer]++; - - } - - for(Int_t iclus = 0; iclus < nofClusterCandidates; iclus++) { - const CbmFiberHodoCluster* cluster = static_cast<const CbmFiberHodoCluster*>(fClusters->At(iclus)); - Int_t nofFiber = cluster->GetNofDigis(); - if(nofFiber>2) - return; - double strip = 0.; - double time = 0.; - Double_t charge = 0.; - for (Int_t i = 0; i < nofFiber; ++i) { - const CbmFiberHodoDigi* hodoDigi = &(fDigis->at(cluster->GetDigi(i))); - strip += CbmFiberHodoAddress::GetStripId(hodoDigi->GetAddress()); - time += hodoDigi->GetTime(); - charge += hodoDigi->GetCharge(); - } - Int_t size = finalClusters->GetEntriesFast(); - CbmFiberHodoCluster* new_cluster = new ((*finalClusters)[size]) CbmFiberHodoCluster(); - for (Int_t i = 0; i < nofFiber; ++i) { - const CbmFiberHodoDigi* hodo_digi = &(fDigis->at(cluster->GetDigi(i))); - if (i == 0) { - new_cluster->SetAddress(hodo_digi->GetAddress()); - new_cluster->AddDigi(cluster->GetDigi(i)); - } - } - new_cluster->SetMean(strip/nofFiber); - new_cluster->SetTime(time/nofFiber); - new_cluster->SetCharge(charge); - new_cluster->SetMeanError(nofFiber / TMath::Sqrt(12.)); - } - } - - - Double_t x1 = 0; - Double_t x2 = 0; - Double_t y1 = 0; - Double_t y2 = 0; - Double_t pos; - - Double_t charge_x1 = 0.; - Double_t charge_x2 = 0.; - Double_t charge_y1 = 0.; - Double_t charge_y2 = 0.; - Double_t charge = 0.; - Int_t address; - Int_t layerID; - CbmFiberHodoCluster* hodoClust = NULL; - - for ( UInt_t iClust=0; iClust < static_cast<UInt_t>(finalClusters->GetEntriesFast()); ++iClust) { - hodoClust = static_cast<CbmFiberHodoCluster*>(finalClusters->At(iClust)); - address = hodoClust->GetAddress(); - layerID = CbmFiberHodoAddress::GetLayerAddress(address); - pos = hodoClust->GetMean(); - charge = hodoClust->GetCharge(); - - switch (layerID) { - case 0: - if (charge > charge_x1 ) { - x1=64-pos; - charge_x1 = charge; - } - break; - case 16: - if (charge > charge_y1 ) { - y1=pos; - charge_y1 = charge; - } - break; - case 1: - if (charge > charge_x2 ) { - x2=pos; - charge_x2 = charge; - } - break; - case 17: - if (charge > charge_y2 ) { - y2=pos; - charge_y2 = charge; - } - break; - } - - } - - if ( charge_x1 > 0. && charge_y1 > 0.) { - hodo1_pos->Fill(x1, y1); - hodo1x->Fill(x1); - hodo1y->Fill(y1); - } - if ( charge_x2 > 0. && charge_y2 > 0.) { - hodo2_pos->Fill(x2, y2); - hodo2x->Fill(x2); - hodo2y->Fill(y2); - } - if ( charge_x1 > 0. && charge_y1 > 0. && charge_x2 > 0. && charge_y2 > 0.) { - hodo_xx->Fill(x1, x2); - hodo_yy->Fill(y1, y2); - hodo1_xcor->Fill(x1, x1-x2); - hodo2_xcor->Fill(x2, x1-x2); - hodo1_ycor->Fill(y1, y1-y2); - hodo2_ycor->Fill(y2, y1-y2); - } - - // Double_t x1; - // Double_t y1; - for(Int_t iclust=0; iclust<finalClusters->GetEntriesFast(); ++iclust ) { - layerID = CbmFiberHodoAddress::GetLayerAddress(static_cast<CbmFiberHodoCluster*>(finalClusters->At(iclust))->GetAddress()); - switch (layerID) { - case 0: - x1=64-static_cast<CbmFiberHodoCluster*>(finalClusters->At(iclust))->GetMean(); - break; - case 16: - y1=static_cast<CbmFiberHodoCluster*>(finalClusters->At(iclust))->GetMean(); - break; - } - hodo1_pos_nocut->Fill(x1, y1); - hodo1x_nocut->Fill(x1); - hodo1y_nocut->Fill(y1); - } - - -} -// -------------------------------------------------------------------- - - // ---- Finish -------------------------------------------------------- - void CbmFiberHodoClusterFinder::Finish() - { - hodo1_pos->Write(); - hodo2_pos->Write(); - hodo_xx->Write(); - hodo_yy->Write(); - hodo1_xcor->Write(); - hodo2_xcor->Write(); - hodo1_ycor->Write(); - hodo2_ycor->Write(); - hodo1x->Write(); - hodo1y->Write(); - hodo2x->Write(); - hodo2y->Write(); - - } - - - - - - ClassImp(CbmFiberHodoClusterFinder) - diff --git a/beamtime/cosy2014/fhodo/CbmFiberHodoClusterFinder.h b/beamtime/cosy2014/fhodo/CbmFiberHodoClusterFinder.h deleted file mode 100644 index 75367daaf4ee80a61f7bc65bf2af861b90b1999c..0000000000000000000000000000000000000000 --- a/beamtime/cosy2014/fhodo/CbmFiberHodoClusterFinder.h +++ /dev/null @@ -1,93 +0,0 @@ -/** CbmFiberHodoClusterFinder.h - ** - ** Task to find neighboring fibres which are above - ** the base line. - ** Create as an output an array of - ** the digis belonging to the cluster. - **/ - -#ifndef CBMFIBERHODOCLUSTERFINDER_H -#define CBMFIBERHODOCLUSTERFINDER_H - -#include <Rtypes.h> // for ClassDef -#include <RtypesCore.h> // for Int_t, Option_t -#include <map> // for map -#include <set> // for set -#include "CbmFiberHodoAddress.h" // for CbmFiberHodoAddress -#include "CbmFiberHodoDigi.h" // for CbmFiberHodoDigi -#include <FairTask.h> // for InitStatus, FairTask -#include <TString.h> // for TString -#include <vector> - -class TH1F; -class TH2F; -class TMemberInspector; - -struct classcomp { - bool operator() (const CbmFiberHodoDigi* lhs, const CbmFiberHodoDigi* rhs) const - {return CbmFiberHodoAddress::GetStripId(lhs->GetAddress()) < CbmFiberHodoAddress::GetStripId(rhs->GetAddress());} -}; - -class CbmFiberHodoClusterFinder : public FairTask -{ - - public: - - /** - * Default constructor. - */ - CbmFiberHodoClusterFinder(); - - /** - * Default destructor. - */ - ~CbmFiberHodoClusterFinder(); - - /** Initialisation **/ - virtual InitStatus ReInit(); - virtual InitStatus Init(); - virtual void SetParContainers(); - - /** Executed task **/ - virtual void Exec(Option_t * option); - - /** Finish task **/ - virtual void Finish(); - - void SetInputDataLevelName(TString name) { fInputLevelName = name; } - - private: - - const std::vector<CbmFiberHodoDigi>* fDigis; /** Input array of CbmFiberHodoDigi **/ - TClonesArray* fClusters; /** candidates array of CbmFiberHodoCluster **/ - TClonesArray* finalClusters; /** Output array of CbmFiberHodoCluster **/ - - std::map<Int_t, std::set<const CbmFiberHodoDigi*, classcomp> > fDigiMap; /** digis per hodo layer **/ - - TString fInputLevelName; - - TH2F* hodo1_pos; - TH2F* hodo2_pos; - - TH2F* hodo1_xcor; - TH2F* hodo2_xcor; - - TH2F* hodo1_ycor; - TH2F* hodo2_ycor; - TH1F* hodo1x; - TH1F* hodo1y; - TH1F* hodo2x; - TH1F* hodo2y; - TH2F* hodo_xx; - TH2F* hodo_yy; - TH2F* hodo1_pos_nocut; - TH1F* hodo1x_nocut; - TH1F* hodo1y_nocut; - - CbmFiberHodoClusterFinder(const CbmFiberHodoClusterFinder&); - CbmFiberHodoClusterFinder& operator=(const CbmFiberHodoClusterFinder&); - - ClassDef(CbmFiberHodoClusterFinder,2); - -}; -#endif diff --git a/beamtime/cosy2014/fhodo/CbmHodoRawHistos.cxx b/beamtime/cosy2014/fhodo/CbmHodoRawHistos.cxx deleted file mode 100644 index 8ec20e188447cfd033ca05d2b13af21752be33e0..0000000000000000000000000000000000000000 --- a/beamtime/cosy2014/fhodo/CbmHodoRawHistos.cxx +++ /dev/null @@ -1,133 +0,0 @@ -#include "CbmHodoRawHistos.h" - -#include <FairRootManager.h> // for FairRootManager -#include <FairTask.h> // for InitStatus, kSUCCESS, FairTask, kERROR -#include <TH2.h> // for TH2, TH2F -#include <FairLogger.h> // for LOG -#include <stddef.h> // for NULL -#include <set> // for set -#include "CbmFiberHodoAddress.h" // for CbmFiberHodoAddress -#include "CbmFiberHodoDigi.h" // for CbmFiberHodoDigi -#include "CbmHistManager.h" // for CbmHistManager -#include <TClonesArray.h> // for TClonesArray - -using std::set; - -// ---- Default constructor ------------------------------------------- -CbmHodoRawHistos::CbmHodoRawHistos() - : FairTask("CbmHodoRawHistos"), - fHodoDigi(nullptr), - fHM(new CbmHistManager()) -{ -} - -// ---- Destructor ---------------------------------------------------- -CbmHodoRawHistos::~CbmHodoRawHistos() -{ -} - -// ---- Initialisation ---------------------------------------------- -void CbmHodoRawHistos::SetParContainers() -{ -} - -// ---- Init ---------------------------------------------------------- -InitStatus CbmHodoRawHistos::Init() -{ - LOG(debug) << "Initilization of CbmHodoRawHistos"; - - // Get a handle from the IO manager - FairRootManager* ioman = FairRootManager::Instance(); - - // Get a pointer to the previous already existing data level - - - fHodoDigi = ioman->InitObjectAs<std::vector<CbmFiberHodoDigi> const*>("HodoDigi"); -// fHodoDigi = (TClonesArray*) ioman->GetObject("HodoDigi"); - if ( ! fHodoDigi ) { - LOG(error) << "No branch HodoDigi found!"; - LOG(error) << "Task CbmHodoRawHistos will be inactive"; - return kERROR; - } - - // Do whatever else is needed at the initilization stage - // Create histograms to be filled - // initialize variables - - CreateHistograms(); - - return kSUCCESS; - -} - -// ---- ReInit ------------------------------------------------------- -void CbmHodoRawHistos::CreateHistograms() -{ -/* TString hodo[2] = { "FrontHodo", "RearHodo"}; */ - fHM->Add("ADC_FrontHodo_X", - new TH2F("ADC_FrontHodo_X", - "ADC_FrontHodo_X;channel;ADC value", 64, 0, 63, 4096, 0, 4095)); - fHM->Add("ADC_RearHodo_X", - new TH2F("ADC_RearHodo_X", - "ADC_RearHodo_X;channel;ADC value", 64, 0, 63, 4096, 0, 4095)); - fHM->Add("ADC_FrontHodo_Y", - new TH2F("ADC_FrontHodo_Y", - "ADC_FrontHodo_Y;channel;ADC value", 64, 0, 63, 4096, 0, 4095)); - fHM->Add("ADC_RearHodo_Y", - new TH2F("ADC_RearHodo_Y", - "ADC_RearHodo_Y;channel;ADC value", 64, 0, 63, 4096, 0, 4095)); -} - - -// ---- ReInit ------------------------------------------------------- -InitStatus CbmHodoRawHistos::ReInit() -{ - return kSUCCESS; -} - -// ---- Exec ---------------------------------------------------------- -void CbmHodoRawHistos::Exec(Option_t* /*option*/) -{ - - const CbmFiberHodoDigi* digi = NULL; - Int_t address = -1; - Int_t station = -1; - Int_t side = -1; - Int_t strip = -1; - Double_t adc = -1.; - UInt_t nofHodoDigis = fHodoDigi->size(); - for (UInt_t iDigi=0; iDigi < nofHodoDigis; ++iDigi) { - digi = &(fHodoDigi->at(iDigi)); - adc = digi->GetCharge(); - address = digi->GetAddress(); - station = CbmFiberHodoAddress::GetStationId(address); - strip = CbmFiberHodoAddress::GetStripId(address); - side = CbmFiberHodoAddress::GetSideId(address); - - if ( 0 == station ) { - if ( 0 == side) { - fHM->H2("ADC_FrontHodo_X")->Fill(strip,adc); - } else { - fHM->H2("ADC_FrontHodo_Y")->Fill(strip,adc); - } - } else { - if ( 0 == side) { - fHM->H2("ADC_RearHodo_X")->Fill(strip,adc); - } else { - fHM->H2("ADC_RearHodo_Y")->Fill(strip,adc); - } - } - } - -} - -// ---- Finish -------------------------------------------------------- -void CbmHodoRawHistos::Finish() -{ - fHM->H2("ADC_FrontHodo_X")->Write(); - fHM->H2("ADC_RearHodo_X")->Write(); - fHM->H2("ADC_FrontHodo_Y")->Write(); - fHM->H2("ADC_RearHodo_Y")->Write(); -} - -ClassImp(CbmHodoRawHistos) diff --git a/beamtime/cosy2014/fhodo/CbmHodoRawHistos.h b/beamtime/cosy2014/fhodo/CbmHodoRawHistos.h deleted file mode 100644 index f1d00f68ec54780749c08b7cd982a0933ba19f05..0000000000000000000000000000000000000000 --- a/beamtime/cosy2014/fhodo/CbmHodoRawHistos.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef CBMHODORAWHISTOS_H -#define CBMHODORAWHISTOS_H - -#include <Rtypes.h> // for ClassDef -#include <RtypesCore.h> // for Option_t -#include <FairTask.h> // for InitStatus, FairTask -#include <vector> - -#include "CbmFiberHodoDigi.h" -#include "CbmHistManager.h" // for RootCling - -class TClonesArray; - -class CbmHodoRawHistos : public FairTask -{ - public: - - /** Default constructor **/ - CbmHodoRawHistos(); - - /** Destructor **/ - ~CbmHodoRawHistos(); - - - /** Initiliazation of task at the beginning of a run **/ - virtual InitStatus Init(); - - /** ReInitiliazation of task when the runID changes **/ - virtual InitStatus ReInit(); - - - /** Executed for each event. **/ - virtual void Exec(Option_t* opt); - - /** Load the parameter container from the runtime database **/ - virtual void SetParContainers(); - - /** Finish task called at the end of the run **/ - virtual void Finish(); - - private: - - /** Input array from previous already existing data level **/ - // - const std::vector<CbmFiberHodoDigi>* fHodoDigi; - - CbmHistManager* fHM; - - void CreateHistograms(); - - CbmHodoRawHistos(const CbmHodoRawHistos&); - CbmHodoRawHistos operator=(const CbmHodoRawHistos&); - - ClassDef(CbmHodoRawHistos,1); -}; - -#endif diff --git a/beamtime/cosy2014/reco/CbmMuchRawHistos.cxx b/beamtime/cosy2014/reco/CbmMuchRawHistos.cxx deleted file mode 100644 index b52f028320180d59bb3b1b531a8badde89cf3018..0000000000000000000000000000000000000000 --- a/beamtime/cosy2014/reco/CbmMuchRawHistos.cxx +++ /dev/null @@ -1,119 +0,0 @@ -#include "CbmMuchRawHistos.h" - -#include <FairRootManager.h> // for FairRootManager -#include <FairTask.h> // for InitStatus, kSUCCESS, FairTask, kERROR -#include <TH2.h> // for TH2F, TH2 -#include <FairLogger.h> // for Logger, LOG -#include <stddef.h> // for NULL -#include <set> // for set -#include "CbmHistManager.h" // for CbmHistManager -#include "CbmMuchBeamTimeDigi.h" // for CbmMuchBeamTimeDigi -#include <TClonesArray.h> // for TClonesArray -#include <TString.h> // for TString, operator+ -#include "CbmDigiManager.h" - -using std::set; - -// ---- Default constructor ------------------------------------------- -CbmMuchRawHistos::CbmMuchRawHistos() - : FairTask("CbmMuchRawHistos"), - fHM(new CbmHistManager()), - fNofEvents(0) -{ -} - -// ---- Destructor ---------------------------------------------------- -CbmMuchRawHistos::~CbmMuchRawHistos() -{ -} - -// ---- Initialisation ---------------------------------------------- -void CbmMuchRawHistos::SetParContainers() -{ -} - -// ---- Init ---------------------------------------------------------- -InitStatus CbmMuchRawHistos::Init() -{ - LOG(info) << GetName() << ": Initialising..."; - - // Get a handle from the IO manager - FairRootManager* ioman = FairRootManager::Instance(); - - // Get the input digis - fDigiVec = ioman->InitObjectAs<std::vector<CbmMuchBeamTimeDigi> const *>("MuchDigi"); - if ( ! fDigiVec ) { - fDigiArr = dynamic_cast<TClonesArray*>(ioman->GetObject("MuchDigi")); - if ( ! fDigiArr ) { - LOG(error) << "No branch MuchDigi found!"; - LOG(error) << "Task CbmMuchRawHistos will be inactive"; - return kERROR; - } - } - - CreateHistograms(); - - return kSUCCESS; - -} - -// ----- Create histograms --------------------------------------------- -void CbmMuchRawHistos::CreateHistograms() -{ - - TString name; - TString title; - - name = "hits_much"; - title = name + ";padX;padY"; - fHM->Add(name.Data(), new TH2F(name, title, 23, -0.5, 22.5, 78, -0.5, 77.5)); - - name = "MUCH ADC vs channel"; - title = name + ";channel;ADC"; - fHM->Add(name.Data(), new TH2F(name, title, 128, -0.5, 127.5, 4096, -0.5, 4095.5)); -} -// ------------------------------------------------------------------------- - - -// ---- ReInit ------------------------------------------------------- -InitStatus CbmMuchRawHistos::ReInit() -{ - return kSUCCESS; -} - -// ---- Exec ---------------------------------------------------------- -void CbmMuchRawHistos::Exec(Option_t* /*option*/) -{ - - - const CbmMuchBeamTimeDigi* digi = nullptr; -/* Int_t adc = -1;*/ - - Int_t nDigis = (fDigiVec ? fDigiVec->size() : - (fDigiArr ? fDigiArr->GetEntriesFast() : 0)); - for (Int_t iDigi = 0; iDigi < nDigis; iDigi++) { - if ( fDigiVec ) digi = &(fDigiVec->at(iDigi)); - else if ( fDigiArr ) digi = dynamic_cast<CbmMuchBeamTimeDigi*>(fDigiArr->At(iDigi)); - if ( ! digi ) continue; - fHM->H2("hits_much")->Fill(Double_t(digi->GetPadX()), - Double_t(digi->GetPadY())); - } - - fNofEvents++; - if ( ! (fNofEvents%1000) ) - LOG(info) << GetName() << ": event " << fNofEvents << ", digis " - << nDigis; - else - LOG(info) << GetName() << ": event " << fNofEvents << ", digis " - << nDigis; - -} - -// ---- Finish -------------------------------------------------------- -void CbmMuchRawHistos::Finish() -{ - - fHM->H2("hits_much")->Write(); -} - -ClassImp(CbmMuchRawHistos) diff --git a/beamtime/cosy2014/reco/CbmMuchRawHistos.h b/beamtime/cosy2014/reco/CbmMuchRawHistos.h deleted file mode 100644 index c44bb193b8170dee726c14cae7095e2671acc9e6..0000000000000000000000000000000000000000 --- a/beamtime/cosy2014/reco/CbmMuchRawHistos.h +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef CBMMUCHRAWHISTOS_H -#define CBMMUCHRAWHISTOS_H - -#include <Rtypes.h> // for ClassDef -#include <RtypesCore.h> // for Option_t, ULong_t -#include <vector> -#include "CbmMuchBeamTimeDigi.h" -#include "FairTask.h" // for InitStatus, FairTask - -#include "CbmHistManager.h" // for RootCling - -class TClonesArray; - -class CbmMuchRawHistos : public FairTask -{ - public: - - /** Default constructor **/ - CbmMuchRawHistos(); - - /** Destructor **/ - ~CbmMuchRawHistos(); - - - /** Initiliazation of task at the beginning of a run **/ - virtual InitStatus Init(); - - /** ReInitiliazation of task when the runID changes **/ - virtual InitStatus ReInit(); - - - /** Executed for each event. **/ - virtual void Exec(Option_t* opt); - - /** Load the parameter container from the runtime database **/ - virtual void SetParContainers(); - - /** Finish task called at the end of the run **/ - virtual void Finish(); - - private: - - const std::vector<CbmMuchBeamTimeDigi>* fDigiVec = nullptr; - TClonesArray* fDigiArr = nullptr; - - CbmHistManager* fHM; ///< Histogram manager - - ULong_t fNofEvents; ///< Event counter - - void CreateHistograms(); - - CbmMuchRawHistos(const CbmMuchRawHistos&); - CbmMuchRawHistos operator=(const CbmMuchRawHistos&); - - ClassDef(CbmMuchRawHistos,1); -}; - -#endif diff --git a/beamtime/cosy2014/reco/CbmStsBLCalibrator.cxx b/beamtime/cosy2014/reco/CbmStsBLCalibrator.cxx deleted file mode 100644 index ea3a23114dd56545473a2f47603dc68b9825a215..0000000000000000000000000000000000000000 --- a/beamtime/cosy2014/reco/CbmStsBLCalibrator.cxx +++ /dev/null @@ -1,161 +0,0 @@ -#include "CbmStsBLCalibrator.h" -#include "FairLogger.h" -#include "TClonesArray.h" -#include "CbmStsDigi.h" -#include "CbmStsAddress.h" - - - -CbmStsBLCalibrator::CbmStsBLCalibrator() -:FairTask("CbmStsBLCalibrator"), - fBaselineDigis(NULL), - fBaselines() -{ - LOG(debug) << "Default Constructor of CbmStsBLCalibrator"; -} - - - -CbmStsBLCalibrator::~CbmStsBLCalibrator() -{ - LOG(debug) << "Destructor of CbmStsBLCalibrator"; -} - - - -void CbmStsBLCalibrator::SetParContainers() -{ - // Load all necessary parameter containers from the runtime data base - - /* - FairRunAna* ana = FairRunAna::Instance(); - FairRuntimeDb* rtdb=ana->GetRuntimeDb(); - - <CbmStsBLCalibratorDataMember> = (<ClassPointer>*) - (rtdb->getContainer("<ContainerName>")); - */ -} - - - -InitStatus CbmStsBLCalibrator::Init() -{ - // Get a handle from the IO manager - FairRootManager* ioman = FairRootManager::Instance(); - - // Get a pointer to the previous already existing data level - - fBaselineDigis = (TClonesArray*) ioman->GetObject("StsBaselineDigi"); - if ( ! fBaselineDigis ) { - LOG(error) << "No input data object StsBaselineDigi found!"; - LOG(error) << " Task CbmStsBLCalibrator will be inactive"; - return kERROR; - } - - Int_t kNStations = 3; // TODO: from where do I get the number of stations? - Int_t kNSides = 2; // TODO: from where do I get the number of sides per station? - Int_t kNStrips = 1024; // TODO: from where do I get the number of strips per station side? - - fBaselines.resize( kNStations ); - - for( Int_t iStation = 0; iStation < fBaselines.size(); iStation++ ) { - fBaselines.at( iStation ).resize( kNSides ); - for( Int_t iSide = 0; iSide < fBaselines.at( iStation ).size(); iSide++ ) { - fBaselines.at( iStation ).at( iSide ).resize( kNStrips ); - for( Int_t iStrip = 0; iStrip < fBaselines.at( iStation ).at( iSide ).size(); iStrip++ ) { - const char * nametitle = Form( "blhist_sta%d_side%d_str%d", iStation, iSide, iStrip ); - fBaselines.at( iStation ).at( iSide ).at( iStrip ) = new TH1F( nametitle, nametitle, kBaselineNBins, kBaselineMinAdc, kBaselineMaxAdc ); - } - } - } - - return kSUCCESS; -} - - - -InitStatus CbmStsBLCalibrator::ReInit() -{ - LOG(debug) << "Initilization of CbmStsBLCalibrator"; - return kSUCCESS; -} - - - -void CbmStsBLCalibrator::Exec(Option_t* /*option*/) -{ - - Int_t nBaselineEntries = fBaselineDigis->GetEntriesFast(); - if( nBaselineEntries ) { // TODO: Check here in a proper way if the event is a baseline event - - /* Baseline data should be taken from only one iteration of the baseline measurement - * (i.e. data from several different iterations of baseline calibration should not be mixed up) - * Therefore the baseline histograms should be zeroed before filling them with the data of the - * next calibration iteration */ - for( Int_t iStation = 0; iStation < fBaselines.size(); iStation++ ) { - for( Int_t iSide = 0; iSide < fBaselines.at( iStation ).size(); iSide++ ) { - for( Int_t iStrip = 0; iStrip < fBaselines.at( iStation ).at( iSide ).size(); iStrip++ ) { - fBaselines.at( iStation ).at( iSide ).at( iStrip )->Reset(); - } - } - } - - for( Int_t iDigi = 0; iDigi < nBaselineEntries; ++iDigi ) { - CbmStsDigi * digi = static_cast< CbmStsDigi * >( fBaselineDigis->At( iDigi ) ); - Int_t station = CbmStsAddress::GetElementId( digi->GetAddress(), kStsUnit ); - Int_t side = CbmStsAddress::GetElementId( digi->GetAddress(), kStsSide ); - Int_t strip = digi->GetChannel(); - Double_t adc = digi->GetCharge(); - fBaselines.at( station ).at( side ).at( strip )->Fill( adc ); - } - - for( Int_t iStation = 0; iStation < fBaselines.size(); iStation++ ) { - for( Int_t iSide = 0; iSide < fBaselines.at( iStation ).size(); iSide++ ) { - for( Int_t iStrip = 0; iStrip < fBaselines.at( iStation ).at( iSide ).size(); iStrip++ ) { - TH1F * blHist = fBaselines.at( iStation ).at( iSide ).at( iStrip ); - if( blHist->GetEntries() ) { - Double_t bl = GetBlPos( blHist ); - LOG(info) << "Baseline of station " << iStation << " side " << iSide << " strip " << iStrip << " is " << bl; - } - } - } - } - } - -} - - - -void CbmStsBLCalibrator::Finish() -{ - - for( Int_t iStation = 0; iStation < fBaselines.size(); iStation++ ) { - for( Int_t iSide = 0; iSide < fBaselines.at( iStation ).size(); iSide++ ) { - for( Int_t iStrip = 0; iStrip < fBaselines.at( iStation ).at( iSide ).size(); iStrip++ ) { - TH1F * baselineHist = fBaselines.at( iStation ).at( iSide ).at( iStrip ); - if( baselineHist ) { - delete baselineHist; - } - baselineHist = 0; - } - } - } - fBaselines.clear(); -} - - - -Double_t CbmStsBLCalibrator::GetBlPos( TH1F * hist ) -{ - Int_t medianBin = 1; - - Double_t * integral = hist->GetIntegral(); - while( integral[ medianBin + 1 ] <= 0.5 ) { - medianBin++; - } - - return hist->GetXaxis()->GetBinCenter( medianBin ); -} - - -ClassImp(CbmStsBLCalibrator) diff --git a/beamtime/cosy2014/reco/CbmStsBLCalibrator.h b/beamtime/cosy2014/reco/CbmStsBLCalibrator.h deleted file mode 100644 index b659218bfb2389d357e85f1f87ff50eb44be004e..0000000000000000000000000000000000000000 --- a/beamtime/cosy2014/reco/CbmStsBLCalibrator.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef CBMSTSBLCALIBRATOR_H -#define CBMSTSBLCALIBRATOR_H - -#include "FairTask.h" - -#include "TH1F.h" -#include <vector> - - -class TClonesArray; - -class CbmStsBLCalibrator : public FairTask -{ - public: - - /** Default constructor **/ - CbmStsBLCalibrator(); - - /** Destructor **/ - ~CbmStsBLCalibrator(); - - /** Initiliazation of task at the beginning of a run **/ - virtual InitStatus Init(); - - /** ReInitiliazation of task when the runID changes **/ - virtual InitStatus ReInit(); - - /** Executed for each event. **/ - virtual void Exec(Option_t* opt); - - /** Load the parameter container from the runtime database **/ - virtual void SetParContainers(); - - /** Finish task called at the end of the run **/ - virtual void Finish(); - - private: - - /** Input array from previous already existing data level **/ - TClonesArray* fBaselineDigis; - - static const Int_t kBaselineMinAdc = 0; - static const Int_t kBaselineMaxAdc = 4096; - static const Int_t kBaselineNBins = 4096; - - std::vector< std::vector < std::vector < TH1F * > > > fBaselines; - - static Double_t GetBlPos( TH1F * hist ); - - CbmStsBLCalibrator(const CbmStsBLCalibrator&); - CbmStsBLCalibrator operator=(const CbmStsBLCalibrator&); - - ClassDef(CbmStsBLCalibrator,1); -}; - -#endif diff --git a/beamtime/cosy2014/reco/CbmStsHodoCorrelations.cxx b/beamtime/cosy2014/reco/CbmStsHodoCorrelations.cxx deleted file mode 100644 index cb87d8ddd70e9703d682d6dcebd54fef9c9190be..0000000000000000000000000000000000000000 --- a/beamtime/cosy2014/reco/CbmStsHodoCorrelations.cxx +++ /dev/null @@ -1,208 +0,0 @@ -#include "CbmStsHodoCorrelations.h" - -#include <FairRootManager.h> // for FairRootManager -#include <FairTask.h> // for InitStatus, kERROR, kSUCCESS, FairTask -#include <TH2.h> // for TH2F -#include <FairLogger.h> // for LOG -#include <stddef.h> // for NULL -#include <set> // for set -#include "CbmFiberHodoAddress.h" // for CbmFiberHodoAddress -#include "CbmFiberHodoCluster.h" // for CbmFiberHodoCluster -#include "CbmStsAddress.h" // for GetElementId, kStsSide -#include "CbmStsDigi.h" // for CbmStsDigi -#include "CbmStsSetup.h" // for CbmStsSetup -#include <TClonesArray.h> // for TClonesArray -#include "CbmDigiManager.h" - -using std::set; - -// ---- Default constructor ------------------------------------------- -CbmStsHodoCorrelations::CbmStsHodoCorrelations() - : FairTask("CbmStsHodoCorrelations"), - fHodoCluster(NULL), - hodo1_pos_sts0(NULL), - hodo2_pos_sts0(NULL), - hodo1_pos_sts1(NULL), - hodo2_pos_sts1(NULL), - hodo1_pos_sts2(NULL), - hodo2_pos_sts2(NULL) -{ -} - -// ---- Destructor ---------------------------------------------------- -CbmStsHodoCorrelations::~CbmStsHodoCorrelations() -{ -} - -// ---- Initialisation ---------------------------------------------- -void CbmStsHodoCorrelations::SetParContainers() -{ - LOG(debug) << "SetParContainers of CbmStsHodoCorrelations"; - // Load all necessary parameter containers from the runtime data base - /* - FairRunAna* ana = FairRunAna::Instance(); - FairRuntimeDb* rtdb=ana->GetRuntimeDb(); - - <CbmStsHodoCorrelationsDataMember> = (<ClassPointer>*) - (rtdb->getContainer("<ContainerName>")); - */ -} - -// ---- Init ---------------------------------------------------------- -InitStatus CbmStsHodoCorrelations::Init() -{ - LOG(debug) << "Initilization of CbmStsHodoCorrelations"; - - // Get a handle from the IO manager - FairRootManager* ioman = FairRootManager::Instance(); - - // Get a pointer to the previous already existing data level - fDigiMan = CbmDigiManager::Instance(); - fDigiMan->Init(); - if ( ! fDigiMan->IsPresent(ECbmModuleId::kSts) ) { - LOG(error) << "No branch StsDigi found!"; - LOG(error) << "Task CbmStsHodoCorrelations will be inactive"; - return kERROR; - } - - fHodoCluster = (TClonesArray*) ioman->GetObject("FiberHodoCluster"); - if ( ! fHodoCluster ) { - LOG(error) << "No branch FiberHodoCluster found!"; - LOG(error) << "Task CbmStsHodoCorrelations will be inactive"; - return kERROR; - } - - - // Do whatever else is needed at the initilization stage - // Create histograms to be filled - // initialize variables - - hodo1_pos_sts0 = new TH2F("xy1_sts0", "y vs. x Hodo 1, if sts0", 64, 0., 64., 64, 0., 64.); - hodo2_pos_sts0 = new TH2F("xy2_sts0", "y vs. x Hodo 2, if sts0", 64, 0., 64., 64, 0., 64.); - - hodo1_pos_sts1 = new TH2F("xy1_sts1", "y vs. x Hodo 1, if sts1", 64, 0., 64., 64, 0., 64.); - hodo2_pos_sts1 = new TH2F("xy2_sts1", "y vs. x Hodo 2, if sts1", 64, 0., 64., 64, 0., 64.); - - hodo1_pos_sts2 = new TH2F("xy1_sts2", "y vs. x Hodo 1, if sts2", 64, 0., 64., 64, 0., 64.); - hodo2_pos_sts2 = new TH2F("xy2_sts2", "y vs. x Hodo 2, if sts2", 64, 0., 64., 64, 0., 64.); - - return kSUCCESS; - -} - -// ---- ReInit ------------------------------------------------------- -InitStatus CbmStsHodoCorrelations::ReInit() -{ - return kSUCCESS; -} - -// ---- Exec ---------------------------------------------------------- -void CbmStsHodoCorrelations::Exec(Option_t* /*option*/) -{ - - UInt_t nofStsDigis = fDigiMan->GetNofDigis(ECbmModuleId::kSts); - UInt_t nofHodoClusters = fHodoCluster->GetEntriesFast(); - - UInt_t St0S0 = 0; - UInt_t St0S1 = 0; - UInt_t St1S0 = 0; - UInt_t St1S1 = 0; - UInt_t St2S0 = 0; - UInt_t St2S1 = 0; - - // check if there is a coincidence between p- and n-side of sts0 - const CbmStsDigi* stsDigi = NULL; - for ( UInt_t iDigi=0; iDigi < nofStsDigis; ++iDigi) { - stsDigi = fDigiMan->Get<CbmStsDigi>(iDigi); - UInt_t stsAddress = stsDigi->GetAddress(); - UInt_t station = CbmStsSetup::Instance()->GetStationNumber(stsAddress); - UInt_t side = CbmStsAddress::GetElementId(stsAddress, kStsSide); - - if ( 0 == station && 0 == side ) St0S0++; - if ( 0 == station && 1 == side ) St0S1++; - if ( 1 == station && 0 == side ) St1S0++; - if ( 1 == station && 1 == side ) St1S1++; - if ( 2 == station && 0 == side ) St2S0++; - if ( 2 == station && 1 == side ) St2S1++; - } - - Double_t x1 = 0; - Double_t x2 = 0; - Double_t y1 = 0; - Double_t y2 = 0; - Double_t pos; - - Double_t charge_x1 = 0.; - Double_t charge_x2 = 0.; - Double_t charge_y1 = 0.; - Double_t charge_y2 = 0.; - Double_t charge = 0.; - Int_t address; - Int_t layerID; - CbmFiberHodoCluster* hodoClust = NULL; - - for ( UInt_t iClust=0; iClust < nofHodoClusters; ++iClust) { - hodoClust = static_cast<CbmFiberHodoCluster*>(fHodoCluster->At(iClust)); - address = hodoClust->GetAddress(); - layerID = CbmFiberHodoAddress::GetLayerAddress(address); - pos = hodoClust->GetMean(); - charge = hodoClust->GetCharge(); - - switch (layerID) { - case 0: - if (charge > charge_x1 ) { - x1=64-pos; - charge_x1 = charge; - } - break; - case 16: - if (charge > charge_y1 ) { - y1=pos; - charge_y1 = charge; - } - break; - case 1: - if (charge > charge_x2 ) { - x2=pos; - charge_x2 = charge; - } - break; - case 17: - if (charge > charge_y2 ) { - y2=pos; - charge_y2 = charge; - } - break; - } - - } - - if ( charge_x1 > 0. && charge_y1 > 0. ) { - - if ( St0S0 > 0 && St0S1 > 0 ) { - hodo1_pos_sts0->Fill(x1, y1); - hodo2_pos_sts0->Fill(x2, y2); - } - if ( St1S0 > 0 && St1S1 > 0 ) { - hodo1_pos_sts1->Fill(x1, y1); - hodo2_pos_sts1->Fill(x2, y2); - } - if ( St2S0 > 0 && St2S1 > 0 && St1S0 > 0 && St1S1 > 0 && St0S0 > 0 && St0S1 > 0) { - hodo1_pos_sts2->Fill(x1, y1); - hodo2_pos_sts2->Fill(x2, y2); - } - } -} - -// ---- Finish -------------------------------------------------------- -void CbmStsHodoCorrelations::Finish() -{ - hodo1_pos_sts0->Write(); - hodo2_pos_sts0->Write(); - hodo1_pos_sts1->Write(); - hodo2_pos_sts1->Write(); - hodo1_pos_sts2->Write(); - hodo2_pos_sts2->Write(); -} - -ClassImp(CbmStsHodoCorrelations) diff --git a/beamtime/cosy2014/reco/CbmStsHodoCorrelations.h b/beamtime/cosy2014/reco/CbmStsHodoCorrelations.h deleted file mode 100644 index 261ffce1b24751a2817115cc40556d0c6cfd617c..0000000000000000000000000000000000000000 --- a/beamtime/cosy2014/reco/CbmStsHodoCorrelations.h +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef CBMSTSHODOCORRELATIONS_H -#define CBMSTSHODOCORRELATIONS_H - -#include <Rtypes.h> // for ClassDef -#include <RtypesCore.h> // for Option_t -#include "FairTask.h" // for InitStatus, FairTask - -class TClonesArray; -class TH2F; -class CbmDigiManager; - -class CbmStsHodoCorrelations : public FairTask -{ - public: - - /** Default constructor **/ - CbmStsHodoCorrelations(); - - /** Destructor **/ - ~CbmStsHodoCorrelations(); - - - /** Initiliazation of task at the beginning of a run **/ - virtual InitStatus Init(); - - /** ReInitiliazation of task when the runID changes **/ - virtual InitStatus ReInit(); - - - /** Executed for each event. **/ - virtual void Exec(Option_t* opt); - - /** Load the parameter container from the runtime database **/ - virtual void SetParContainers(); - - /** Finish task called at the end of the run **/ - virtual void Finish(); - - private: - - CbmDigiManager* fDigiMan = nullptr; //! - - /** Output array to new data level**/ - TClonesArray* fHodoCluster; - - TH2F* hodo1_pos_sts0; - TH2F* hodo2_pos_sts0; - TH2F* hodo1_pos_sts1; - TH2F* hodo2_pos_sts1; - TH2F* hodo1_pos_sts2; - TH2F* hodo2_pos_sts2; - - CbmStsHodoCorrelations(const CbmStsHodoCorrelations&); - CbmStsHodoCorrelations operator=(const CbmStsHodoCorrelations&); - - ClassDef(CbmStsHodoCorrelations,1); -}; - -#endif diff --git a/beamtime/cosy2014/sts/reco/cosy/StsCosyAnalysis.cxx b/beamtime/cosy2014/sts/reco/cosy/StsCosyAnalysis.cxx deleted file mode 100644 index 0c6cd1c7baf11bcff614b31af76a3ac41ae1ef89..0000000000000000000000000000000000000000 --- a/beamtime/cosy2014/sts/reco/cosy/StsCosyAnalysis.cxx +++ /dev/null @@ -1,597 +0,0 @@ -#include "StsCosyAnalysis.h" - -#include <FairTask.h> // for kERROR, kSUCCESS, FairTask, InitStatus -#include <TFile.h> // for TFile -#include <TH1.h> // for TH1F -#include <TH2.h> // for TH2F -#include <TMathBase.h> // for Abs -#include <FairLogger.h> // for LOG, Logger -#include <stdio.h> // for NULL, sprintf -#include <iostream> // for operator<<, basic_ostream, endl, cout -#include <map> // for map -#include <utility> // for pair, __unwrap_reference<>::type, mak... -#include "CbmStsHit.h" // for CbmStsHit -#include "CbmStsSetup.h" // for CbmStsSetup -#include <FairRootManager.h> // for FairRootManager -#include <TClonesArray.h> // for TClonesArray -#include <TF1.h> // for TF1 -#include <TGraphErrors.h> // for TGraphErrors -#include <TTree.h> // for TTree -#include <TVector3.h> // for TVector3 - -using std::cout; -using std::endl; -using std::vector; - -StsCosyAnalysis::StsCosyAnalysis() : - FairTask("StsCosyAnalysis",1), - fHits(NULL), - fChain(new TChain("cbmsim")), - fMapPts(), - XY_events(), - proj_events(), - X_STS1(), - Y_STS1(), - X_proj(), - Y_proj(), - resX(), - resY(), - X_ResX(), - Y_ResY(), - chi2X(NULL), - chi2Y(NULL), - chi2XY(NULL), - XY(), - XY_eff(NULL), - XY_woSTS1(), - XY_STS1projection(NULL), - XY_STS1projection_select(NULL), - XX_STS_0_1(NULL), - XX_STS_0_2(NULL), - XX_STS_0_2woSTS1(NULL), - XX_STS_2_1(NULL), - YY_STS_0_1(NULL), - YY_STS_0_2(NULL), - YY_STS_0_2woSTS1(NULL), - YY_STS_2_1(NULL), - NofTracks(NULL), - fChi2X(1e9), - fChi2Y(1e9), - fX(), - fY(), - fXbin(300.), - fYbin(400.), - fAlignName(""), - fCutName(""), - fNofDet(5), - fTimeLimit(), - fTimeShift(), - fTrackSelectType(0), - fEventSelectType(0), - fEvent(0) -{ -// fChain = new TChain("cbmsim"); - fTimeLimit[0] = 16; - fTimeLimit[1] = 16; - fTimeLimit[2] = 16; - - fTimeShift[0] = 0; - fTimeShift[1] = -16; - fTimeShift[2] = -16; -// fXbin = 300; // 300 �m -// fYbin = 400; // 400 �m - -// fCutName = ""; -} - -StsCosyAnalysis::~StsCosyAnalysis() -{ - if ( fHits ) { - fHits->Delete(); - delete fHits; - } -} - - -InitStatus StsCosyAnalysis::Init() { - - // Get RootManager - FairRootManager* ioman = FairRootManager::Instance(); - if ( ! ioman ) - { - LOG(fatal) << "StsCosyAnalysis::Init: noRootManager !"; - return kFATAL; - } - // Get input arrays - - fHits =(TClonesArray *) ioman->GetObject("StsHit"); - if ( ! fHits ) { - LOG(error) << "No StsHits array!"; - LOG(error) << "Task will be inactive"; - return kERROR; - } - - for(int i=0;i<fNofDet;i++) - fMapPts.insert(make_pair(i,vector<CbmStsHit*>())); - - for (Int_t i=0;i<3;i++) - { - Char_t inName[25]; - sprintf(inName,"ResX%i",i); - resX[i] = new TH1F(inName,inName,200, -0.1,0.1); - - sprintf(inName,"ResY%i",i); - resY[i] = new TH1F(inName,inName,200, -0.1,0.1); - - sprintf(inName,"XY_STS_%i",i); - if(i==0 || i==2)XY[i] = new TH2F(inName,inName,100, -1, 1,100, -1, 1); - else XY[i] = new TH2F(inName,inName,100, -1.5, 1.5,100, -1.5, 1.5); - - sprintf(inName,"XvsResX_STS_%i",i); - X_ResX[i] = new TH2F(inName,inName,400, -1, 1,400, -0.1, 0.1); - - sprintf(inName,"YvsResY_STS_%i",i); - Y_ResY[i] = new TH2F(inName,inName,400, -1, 1,400, -0.1, 0.1); - } - - XX_STS_0_1 = new TH2F("XX_STS_0_1","XX_STS_0_1",100,-1,1,100,-1,1); - XX_STS_0_2 = (TH2F*)XX_STS_0_1->Clone("XX_STS_0_2");XX_STS_0_2->SetTitle("XX_STS_0_2"); - XX_STS_0_2woSTS1 = (TH2F*)XX_STS_0_1->Clone("XX_STS_0_2woSTS1");XX_STS_0_2woSTS1->SetTitle("XX_STS_0_2woSTS1"); - XX_STS_2_1 = (TH2F*)XX_STS_0_1->Clone("XX_STS_2_1");XX_STS_2_1->SetTitle("XX_STS_2_1"); - - YY_STS_0_1 = new TH2F("YY_STS_0_1","YY_STS_0_1",100,-1.5,1.5,100,-1.5,1.5); - YY_STS_0_2 = (TH2F*)YY_STS_0_1->Clone("YY_STS_0_2");YY_STS_0_2->SetTitle("YY_STS_0_2"); - YY_STS_0_2woSTS1 = (TH2F*)YY_STS_0_1->Clone("YY_STS_0_2woSTS1");YY_STS_0_2woSTS1->SetTitle("YY_STS_0_2woSTS1"); - YY_STS_2_1 = (TH2F*)YY_STS_0_1->Clone("YY_STS_2_1");YY_STS_2_1->SetTitle("YY_STS_2_1"); - - chi2X = new TH1F("chi2X","chi2X",100, 0, 1000); - chi2XY = new TH2F("chi2XY","chi2XY",300, -10, 300,300, -10, 300); - chi2Y = (TH1F*)chi2X->Clone("chi2Y");chi2Y->SetTitle("chi2Y"); - - XY_woSTS1[0] = new TH2F("XY_STS0_woSTS1","XY_STS0_woSTS1",100, -1, 1,100, -1, 1); - XY_woSTS1[1] = new TH2F("XY_STS2_woSTS1","XY_STS2_woSTS1",100, -1, 1,100, -1, 1); - - Int_t nXbins = 30000/fXbin; - Int_t nYbins = 30000/fYbin; - - XY_eff = new TH2F("XYforEff_STS1","XYforEff_STS1",nXbins, -1.5, 1.5, nYbins, -1.5, 1.5); - XY_STS1projection = (TH2F*)XY_eff->Clone("XY_STS1projection");XY_STS1projection->SetTitle("XY_STS1projection"); - XY_STS1projection_select = (TH2F*)XY_eff->Clone("XY_STS1projection_select");XY_STS1projection_select->SetTitle("XY_STS1projection_select"); - - NofTracks = new TH1F("NofTracks","NofTracks", 101, -0.5, 100.5); - - if(fCutName != "" ){ - LOG(info) << "Use inpute file for time cuts " << fCutName; - TFile *file_cuts = new TFile(fCutName); - - - TTree *timeHit0 = (TTree*)file_cuts ->Get("STS0-STS1"); - timeHit0->SetBranchAddress("TimeLimit",&fTimeLimit[0]); - timeHit0->SetBranchAddress("TimeShift",&fTimeShift[0]); - timeHit0->GetEntry(0); - - TTree *timeHit1 = (TTree*)file_cuts ->Get("STS0-STS2"); - timeHit1->SetBranchAddress("TimeLimit",&fTimeLimit[1]); - timeHit1->SetBranchAddress("TimeShift",&fTimeShift[1]); - timeHit1->GetEntry(0); - - TTree *timeHit2 = (TTree*)file_cuts ->Get("STS2-STS1"); - timeHit2->SetBranchAddress("TimeLimit",&fTimeLimit[2]); - timeHit2->SetBranchAddress("TimeShift",&fTimeShift[2]); - timeHit2->GetEntry(0); - file_cuts->Close(); - } - - TFile *file = new TFile(fAlignName); - if ( !file ) { - LOG(error) << "No alignment file!"; - return kERROR; - } - - TTree *tree = (TTree*)file->Get("Alignment"); - - tree->SetBranchAddress("dX0",&fX[0]); - tree->SetBranchAddress("dX1",&fX[1]); - tree->SetBranchAddress("dX2",&fX[2]); - - tree->SetBranchAddress("dY0",&fY[0]); - tree->SetBranchAddress("dY1",&fY[1]); - tree->SetBranchAddress("dY2",&fY[2]); - - tree->GetEntry(0); - file->Close(); - - fEvent = 0; - - cout << "-I- StsCosyAnalysis: Intialisation successfull " << kSUCCESS<< endl; - return kSUCCESS; - -} - -// ----- Public method Exec -------------------------------------------- -void StsCosyAnalysis::Exec(Option_t*) { - - Reset(); - CbmStsHit* hit = NULL; - Int_t nofHits = fHits->GetEntries(); - - if(fEvent%100000 == 0)cout << "-I- StsCosyAnalysis: ----- " << fEvent << endl; - - // Loop over hits - for (Int_t iHit=0; iHit<nofHits; iHit++) - { - hit = (CbmStsHit*) fHits->At(iHit); - - // Determine sector type and channel numbers - Int_t detId = CbmStsSetup::Instance()->GetStationNumber(hit->GetAddress()); - vector<CbmStsHit*>& vlist = fMapPts[detId]; - vlist.push_back((CbmStsHit*) hit); - } - - - // Find the tracks - FindTracks(); - - fEvent++; - -} - - -Bool_t StsCosyAnalysis::FindTracks(){ - - vector<CbmStsHit*>& v_sts0 = fMapPts[0]; - vector<CbmStsHit*>& v_sts1 = fMapPts[1]; - vector<CbmStsHit*>& v_sts2 = fMapPts[2]; - - CbmStsHit* pt0=NULL; - CbmStsHit* pt1=NULL; - CbmStsHit* pt2=NULL; - - TVector3 sts0_pos, sts1_pos, sts2_pos; - int Npoints = 3; - - double x[Npoints]; - double ex[Npoints]; - double z[Npoints]; - double ez[Npoints]; -// double z2[Npoints]; -// double ez2[Npoints]; - double y[Npoints]; - double ey[Npoints]; - - Double_t Xnew; - Double_t Ynew; - - for(UInt_t i=0; i< v_sts0.size() ; i++) - { - pt0 = (CbmStsHit*) v_sts0[i]; - pt0->Position(sts0_pos); - x[0]= sts0_pos.X()-fX[0]; - y[0]= sts0_pos.Y()-fY[0]; - XY_woSTS1[0]->Fill(x[0],y[0]); - } - for(UInt_t i=0; i< v_sts2.size() ; i++) - { - pt0 = (CbmStsHit*) v_sts2[i]; - pt0->Position(sts2_pos); - x[0]= sts2_pos.X()-fX[2]; - y[0]= sts2_pos.Y()-fY[2]; - XY_woSTS1[1]->Fill(x[0],y[0]); - } - - if((fEventSelectType == 1 && (v_sts0.size()==1 && v_sts2.size()==1)) || fEventSelectType == 0)// = 1 - selection of the 1-hit events - for(UInt_t i=0; i< v_sts0.size() ; i++) - { - -Int_t tracks = 0; - -Double_t Chi2X = 1e9; -Double_t Chi2Y = 1e9; -Double_t ResX[3]; -Double_t ResY[3]; -Double_t Xarr[3]; -Double_t Yarr[3]; - -Bool_t trigger = kFALSE; - - - pt0 = (CbmStsHit*) v_sts0[i]; - pt0->Position(sts0_pos); - x[0]= sts0_pos.X()-fX[0]; - y[0]= sts0_pos.Y()-fY[0]; - z[0]= sts0_pos.Z(); - ex[0]= pt0->GetDx(); - ey[0]= pt0->GetDy(); - ez[0]= 0.5; - - for(UInt_t k=0; k< v_sts2.size() ; k++) - { - pt2 = (CbmStsHit*) v_sts2[k]; - - if(TMath::Abs(pt0->GetTime()-pt2->GetTime()- fTimeShift[1])>fTimeLimit[1])continue; - pt2->Position(sts2_pos); - x[2]= (sts2_pos.X()-fX[2]); - y[2]= sts2_pos.Y()-fY[2]; - z[2]= sts2_pos.Z(); - ex[2]= pt2->GetDx(); - ey[2]= pt2->GetDy(); - ez[2]= 0.5; - -double xx[2], yy[2], zz[2], dxx[2], dyy[2], dzz[2]; - - xx[0]=x[0]; - yy[0]=y[0]; - zz[0]=z[0]; - - xx[1]=x[2]; - yy[1]=y[2]; - zz[1]=z[2]; - - dxx[0]=ex[0]; - dyy[0]=ey[0]; - dzz[0]=ez[0]; - - dxx[1]=ex[2]; - dyy[1]=ey[2]; - dzz[1]=ez[2]; - - TGraphErrors* graph; - TGraphErrors* graph1; - graph = new TGraphErrors(2,zz,xx,dzz,dxx); - graph1 = new TGraphErrors(2,zz,yy,dzz,dyy); - TF1 *fit = new TF1("fit", "[0] + [1]*x"); - graph->Fit("fit","QME"); - TF1 *fit1 = new TF1("fit1", "[0] + [1]*x"); - graph1->Fit("fit1","QME"); - - XX_STS_0_2woSTS1->Fill(x[0],x[2]); - YY_STS_0_2woSTS1->Fill(y[0],y[2]); - - Xnew = fit->GetParameter(0)+fit->GetParameter(1)*99.3; - Ynew = fit1->GetParameter(0)+fit1->GetParameter(1)*99.3; - - XY_STS1projection->Fill(Xnew,Ynew); - - proj_events.push_back(fEvent); - X_proj.push_back(Xnew); - Y_proj.push_back(Ynew); - - graph1->Delete(); - graph->Delete(); - fit->Delete(); - fit1->Delete(); - - if(fEventSelectType == 1 && v_sts1.size()!=1) continue; // selection of 1-hit events - - for(UInt_t j=0; j< v_sts1.size() ; j++) - { - pt1 = (CbmStsHit*) v_sts1[j]; - if(TMath::Abs(pt0->GetTime()-pt1->GetTime() - fTimeShift[0])>fTimeLimit[0])continue; - if(TMath::Abs(pt2->GetTime()-pt1->GetTime()- fTimeShift[2])>fTimeLimit[2])continue; - pt1->Position(sts1_pos); - x[1]= sts1_pos.X()-fX[1]; - y[1]= sts1_pos.Y()-fY[1]; - z[1]= sts1_pos.Z(); - ex[1]= pt1->GetDx(); - ey[1]= pt1->GetDy(); - ez[1]= 0.5; - - // Fit data numerically: - // --------------------- - TGraphErrors* gr; - TGraphErrors* gr1; - gr = new TGraphErrors(Npoints,z,x,ez,ex); - - TF1 *fitt = new TF1("fitt", "[0] + [1]*x"); - gr->Fit("fitt","QME"); - - double xChi2 = fitt->GetChisquare(); - double xNdof = fitt->GetNDF(); - double p0 = fitt->GetParameter(0); - double p1 = fitt->GetParameter(1); -// double Prob = fitt->GetProb(); - - gr1 = new TGraphErrors(Npoints,z,y,ez,ey); - - TF1 *fitt1 = new TF1("fitt1", "[0] + [1]*x"); - gr1->Fit("fitt1","QME"); - - double yChi2 = fitt1->GetChisquare(); - double yNdof = fitt1->GetNDF(); -// double yProb = fitt1->GetProb(); - double p2 = fitt1->GetParameter(0); - double p3 = fitt1->GetParameter(1); - - gr1->Delete(); - gr->Delete(); - fitt->Delete(); - fitt1->Delete(); - - if(xChi2/xNdof > fChi2X || yChi2/yNdof > fChi2Y)continue; - -if(fTrackSelectType == 1) // selection of the best track per event (best chi2/ndf) -{ - if(Chi2X > xChi2/xNdof && Chi2Y > yChi2/yNdof) - { - Chi2X = xChi2/xNdof; Chi2Y = yChi2/yNdof; - for(int m=0; m<3; m++) - { - Xarr[m]=x[m];ResX[m]=x[m]-p0-p1*z[m]; - Yarr[m]=y[m];ResY[m]=y[m]-p2-p3*z[m]; - trigger = kTRUE; - } - } -} -else if(fTrackSelectType == 0) // use all tracks -{ - for(int m=0; m<3; m++) - { - resX[m]->Fill(x[m]-p0-p1*z[m]); - resY[m]->Fill(y[m]-p2-p3*z[m]); - - X_ResX[m]->Fill(x[m],x[m]-p0-p1*z[m]); - Y_ResY[m]->Fill(x[m],y[m]-p2-p3*z[m]); - XY[m]->Fill(x[m],y[m]); - } - XY_events.push_back(fEvent); - X_STS1.push_back(x[1]); - Y_STS1.push_back(y[1]); - - chi2Y->Fill(Chi2Y); - chi2X->Fill(Chi2X); - - XX_STS_0_1->Fill(x[0],x[1]); - XX_STS_0_2->Fill(x[0],x[2]); - XX_STS_2_1->Fill(x[2],x[1]); - YY_STS_0_1->Fill(y[0],y[1]); - YY_STS_0_2->Fill(y[0],y[2]); - YY_STS_2_1->Fill(y[2],y[1]); -} -tracks++; - - }//!sts2 - }//!sts1 - NofTracks->Fill(tracks); - if(tracks==0)continue; - if(!trigger)continue; - if(fTrackSelectType == 1) - { - for(int m=0; m<3; m++) - { - resX[m]->Fill(ResX[m]); - resY[m]->Fill(ResY[m]); - - X_ResX[m]->Fill(Xarr[m],ResX[m]); - Y_ResY[m]->Fill(Yarr[m],ResY[m]); - XY[m]->Fill(Xarr[m],Yarr[m]); - } - - XY_events.push_back(fEvent); - X_STS1.push_back(Xarr[1]); - Y_STS1.push_back(Yarr[1]); - - chi2Y->Fill(Chi2Y); - chi2X->Fill(Chi2X); - chi2XY->Fill(Chi2X,Chi2Y); - - XX_STS_0_1->Fill(Xarr[0],Xarr[1]); - XX_STS_0_2->Fill(Xarr[0],Xarr[2]); - XX_STS_2_1->Fill(Xarr[2],Xarr[1]); - YY_STS_0_1->Fill(Yarr[0],Yarr[1]); - YY_STS_0_2->Fill(Yarr[0],Yarr[2]); - YY_STS_2_1->Fill(Yarr[2],Yarr[1]); - } - }//!sts0 - - - return kTRUE; -} - - -void StsCosyAnalysis::Reset() { - fMapPts.clear(); -} - - -void StsCosyAnalysis::Finish(){ - - Double_t dX[3], dY[3]; - - for(Int_t i=0;i<3;i++) - { - TF1 *fitX = new TF1("fitX", "gaus"); - resX[i]->Fit("fitX","QME"); - dX[i] = fitX->GetParameter(2); - - TF1 *fitY = new TF1("fitY", "gaus"); - resY[i]->Fit("fitY","QME"); - dY[i] = fitY->GetParameter(2); - - fitX->Delete(); - fitY->Delete(); - } - - TTree * data = new TTree("Resolution", "Resolution"); - data->Branch("dX0", &dX[0], "dX0/D"); - data->Branch("dX1", &dX[1], "dX1/D"); - data->Branch("dX2", &dX[2], "dX2/D"); - - data->Branch("dY0", &dY[0], "dY0/D"); - data->Branch("dY1", &dY[1], "dY1/D"); - data->Branch("dY2", &dY[2], "dY2/D"); - - data->Fill(); - data->Write(); - - for(Int_t i=0;i<3;i++){resX[i]->Write(); X_ResX[i]->Write(); resY[i]->Write();Y_ResY[i]->Write();} - for(Int_t i=0;i<3;i++){XY[i]->Write();} - - XY_woSTS1[0]->Write(); - XY_woSTS1[1]->Write(); - - XX_STS_0_1->Write(); - YY_STS_0_1->Write(); - - XX_STS_0_2->Write(); - YY_STS_0_2->Write(); - - XX_STS_2_1->Write(); - YY_STS_2_1->Write(); - - XX_STS_0_2woSTS1->Write(); - YY_STS_0_2woSTS1->Write(); - - chi2X->Write(); - chi2Y->Write(); - chi2XY->Write(); - - NofTracks->Write(); - - Double_t NofProjections = 0; - - vector <Int_t> select_events; - vector <Double_t> X_select, Y_select; - - for(UInt_t i=0; i< proj_events.size(); i++) { - for(UInt_t j=0; j< XY_events.size(); j++) { - if(TMath::Abs(X_STS1[j]-X_proj[i]) > fXbin*1e-4 || TMath::Abs(Y_STS1[j]-Y_proj[i]) > fYbin*1e-4) continue; - select_events.push_back(proj_events[i]); - X_select.push_back(X_proj[i]); - Y_select.push_back(Y_proj[i]); - XY_STS1projection_select->Fill(X_proj[i],Y_proj[i]); - } - } - for(UInt_t j=0; j< XY_events.size(); j++) XY_eff->Fill(X_STS1[j],Y_STS1[j]); - - XY_eff->Write(); - XY_STS1projection->Write(); - XY_STS1projection_select->Write(); - - for(UInt_t i=0; i< select_events.size(); i++) { - for(UInt_t j=0; j< XY_events.size(); j++) { - if(select_events[i] != XY_events[i]) continue; - NofProjections++; - } - } - - Double_t NofP = select_events.size() + (XY_events.size()-NofProjections); - - LOG(info); - cout << "Acceptance procedure: event selection" << endl; - cout << "Limits " << fXbin << " um x " << fYbin << " um" << endl; - cout << "----------------- Number of hits in STS3 = " << XY_events.size() << endl; - cout << "Number of projections in STS3 acceptance = " << NofP << endl; - cout << "------------------------------ Efficency = " << XY_events.size()/NofP*100. << "%" << endl; - - - LOG(info); - LOG(info) << "====================================================="; - LOG(info) << GetName() << ": Finish"; - LOG(info) << "====================================================="; - LOG(info); -} - - - - -ClassImp(StsCosyAnalysis) diff --git a/beamtime/cosy2014/sts/reco/cosy/StsCosyAnalysis.h b/beamtime/cosy2014/sts/reco/cosy/StsCosyAnalysis.h deleted file mode 100644 index 486283b7b3d8736ae65ead2655e45bf2cdb096c9..0000000000000000000000000000000000000000 --- a/beamtime/cosy2014/sts/reco/cosy/StsCosyAnalysis.h +++ /dev/null @@ -1,111 +0,0 @@ -/** class StsCosyAnalysis.h - *@author Olga Bertini @ Anna Senger <a.senger@gsi.de> - ** - ** - **/ - - -#ifndef STSCOSYANALYSIS_H -#define STSCOSYANALYSIS_H 1 - -#include <Rtypes.h> // for ClassDef -#include <RtypesCore.h> // for Double_t, Int_t, Bool_t, Option_t -#include <TChain.h> // for TChain -#include <TString.h> // for TString -#include <map> // for map -#include <vector> // for vector -#include <FairTask.h> // for FairTask, InitStatus - -#include "TH1.h" // for RootCling -#include "TH2.h" // for RootCling - -class CbmStsHit; -class TClonesArray; - -class StsCosyAnalysis : public FairTask -{ - - public: - - StsCosyAnalysis(); - ~StsCosyAnalysis(); - virtual InitStatus Init(); - virtual void Exec(Option_t* opt); - Int_t GetEntries () { return fChain->GetEntries();} - - void SetChi2Cut(Double_t chi2x, Double_t chi2y){fChi2X=chi2x;fChi2Y=chi2y;} - - void SetAlignFileName(TString name){fAlignName = name;} - void SetCutFileName(TString name){fCutName = name;} - - void SetNofDetectors(Int_t NofH){fNofDet=NofH;} - void SetTimeLimit(Double_t timeArr[3]) { for(int i=0; i<3; i++)fTimeLimit[i]=timeArr[i]; } - void SetTimeShift(Double_t timeArr[3]) { for(int i=0; i<3; i++)fTimeShift[i]=timeArr[i]; } - - void SetTrackSelectType(Int_t type) {fTrackSelectType = type;} - void SetCoordPrecision(Double_t x, Double_t y){fXbin = x; fYbin = y;} - void SetEventSelectType(Int_t type) {fEventSelectType = type;} - - private: - - TClonesArray* fHits; - TChain *fChain; - - - StsCosyAnalysis(const StsCosyAnalysis&); - StsCosyAnalysis operator=(const StsCosyAnalysis&); - - void Reset(); - void Finish(); - - Bool_t FindTracks(); - - // Map for layered hits - std::map< Int_t , std:: - vector<CbmStsHit*> > fMapPts; //! - - std::vector <Int_t> XY_events, proj_events; - std::vector <Double_t> X_STS1, Y_STS1, X_proj, Y_proj; - - TH1F* resX[3]; - TH1F* resY[3]; - TH2F* X_ResX[3]; - TH2F* Y_ResY[3]; - TH1F* chi2X; - TH1F* chi2Y; - TH2F* chi2XY; - - TH2F * XY[3]; - TH2F * XY_eff; - TH2F * XY_woSTS1[2]; - TH2F * XY_STS1projection; - TH2F * XY_STS1projection_select; - - TH2F *XX_STS_0_1; - TH2F *XX_STS_0_2; - TH2F *XX_STS_0_2woSTS1; - TH2F *XX_STS_2_1; - - TH2F *YY_STS_0_1; - TH2F *YY_STS_0_2; - TH2F *YY_STS_0_2woSTS1; - TH2F *YY_STS_2_1; - - TH1F* NofTracks; - - Double_t fChi2X, fChi2Y; - Double_t fX[3], fY[3]; // alignment - Double_t fXbin, fYbin; // in Xm - - TString fAlignName; - TString fCutName; - - Int_t fNofDet; - Double_t fTimeLimit[3]; - Double_t fTimeShift[3]; - Int_t fTrackSelectType, fEventSelectType, fEvent; - ClassDef(StsCosyAnalysis,1); - -}; - -#endif diff --git a/beamtime/cosy2014/sts/reco/cosy/StsCosyBL.cxx b/beamtime/cosy2014/sts/reco/cosy/StsCosyBL.cxx deleted file mode 100644 index 97ef8bd93cb7518f86d1e3eb79fe780447f1edc7..0000000000000000000000000000000000000000 --- a/beamtime/cosy2014/sts/reco/cosy/StsCosyBL.cxx +++ /dev/null @@ -1,569 +0,0 @@ -#include "StsCosyBL.h" - -#include <FairRun.h> // for FairRun -#include <FairTask.h> // for InitStatus, kSUCCESS, FairTask, kERROR -#include <TAxis.h> // for TAxis -#include <TFile.h> // for TFile -#include <TH1.h> // for TH1F -#include <TH2.h> // for TH2F -#include <TString.h> // for Form -#include <FairLogger.h> // for LOG, Logger -#include <stdio.h> // for sprintf, NULL -#include <iostream> // for operator<<, endl, basic_ostream, cout -#include "CbmFiberHodoAddress.h" // for CbmFiberHodoAddress -#include "CbmFiberHodoDigi.h" // for CbmFiberHodoDigi -#include "CbmStsAddress.h" // for GetElementId, kStsSide -#include "CbmStsDigi.h" // for CbmStsDigi -#include "CbmStsSetup.h" // for CbmStsSetup -#include <FairRootManager.h> // for FairRootManager -#include <FairRunAna.h> // for FairRunAna -#include <FairRunOnline.h> // for FairRunOnline -#include <TClonesArray.h> // for TClonesArray - -using namespace std; - - -// ---- Default constructor ------------------------------------------- -StsCosyBL::StsCosyBL() - :FairTask("StsCosyBL",1), - auxDigis(nullptr), - fDigis(nullptr), - fBLDigis(nullptr), - hBLDigis(nullptr), - hDigis(nullptr), - cDigis(nullptr), - chDigis(nullptr), - fChain(new TChain("cbmsim")), - outFile(NULL), - baseline_ch(), - raw_ch(), - raw_ch_woBL(), - calibr_ch(), - calibr_ch1D(), - hodo_baseline_ch(), - hodo_calib_ch(), - calib(kFALSE), - hodo_calib(kFALSE), - fTriggeredMode(kFALSE), - fTriggeredStation(1), - fNofEvent(0), - base_line_array(), - hodo_BL_array() -{ - LOG(debug) << "Default Constructor of StsCosyBL"; -} - -// ---- Destructor ---------------------------------------------------- -StsCosyBL::~StsCosyBL() -{ - delete cDigis; - delete fChain; - if(fDigis){ - - } - LOG(debug) << "Destructor of StsCosyBL"; -} - -// ---- Initialisation ---------------------------------------------- -void StsCosyBL::SetParContainers() -{ - LOG(debug) << "SetParContainers of StsCosyBL"; -} - -// ---- Init ---------------------------------------------------------- -InitStatus StsCosyBL::Init() -{ - LOG(debug) << "Initilization of StsCosyBL"; - - // Get a handle from the IO manager - FairRootManager* ioman = FairRootManager::Instance(); - - // Get a pointer to the previous already existing data level - - fDigis = ioman->InitObjectAs<std::vector<CbmStsDigi> const *>("StsDigi"); - fBLDigis = ioman->InitObjectAs<std::vector<CbmStsDigi> const *>("StsBaselineDigi"); - hBLDigis = ioman->InitObjectAs<std::vector<CbmFiberHodoDigi> const *>("HodoBaselineDigi"); - hDigis = ioman->InitObjectAs<std::vector<CbmFiberHodoDigi> const *>("HodoDigi"); - auxDigis = ioman->InitObjectAs<std::vector<CbmAuxDigi> const *>("AuxDigi"); - - /* - fDigis = (TClonesArray*) ioman->GetObject("StsDigi"); - fBLDigis = (TClonesArray*) ioman->GetObject("StsBaselineDigi"); - hBLDigis = (TClonesArray*) ioman->GetObject("HodoBaselineDigi"); - hDigis = (TClonesArray*) ioman->GetObject("HodoDigi"); - auxDigis= (TClonesArray*) ioman->GetObject("AuxDigi"); - */ - - if ( ! fDigis ) - { - LOG(error) << "No InputDataLevelName array!\n StsCosyBL will be inactive"; - return kERROR; - } - - calib = kFALSE; - hodo_calib = kFALSE; - - Int_t NStations = 3; // TODO: from where do I get the number of stations? - Int_t NSides = 2; // TODO: from where do I get the number of sides per station? - Int_t NStrips = 1024; // TODO: from where do I get the number of strips per station side? - - base_line_array.resize(NStations ); - for( UInt_t iStation = 0; iStation < base_line_array.size(); iStation++ ) - { - base_line_array.at( iStation ).resize( NSides ); - for( UInt_t iSide = 0; iSide < base_line_array.at( iStation ).size(); iSide++ ) - { - base_line_array.at( iStation ).at( iSide ).resize( NStrips ); - for( UInt_t iStrip = 0; iStrip < base_line_array.at( iStation ).at( iSide ).size(); iStrip++ ) - { - base_line_array.at( iStation ).at( iSide ).at(iStrip)=0; - } - } - } - - Int_t hStations = 2; // TODO: from where do I get the number of stations? - Int_t hSides = 2; // TODO: from where do I get the number of sides per station? - Int_t hStrips = 64; // TODO: from where do I get the number of strips per station side? - - hodo_BL_array.resize(hStations ); - for( UInt_t iStation = 0; iStation < hodo_BL_array.size(); iStation++ ) - { - hodo_BL_array.at( iStation ).resize(hSides ); - for( UInt_t iSide = 0; iSide < hodo_BL_array.at( iStation ).size(); iSide++ ) - { - hodo_BL_array.at( iStation ).at( iSide ).resize( hStrips ); - for( UInt_t iStrip = 0; iStrip < hodo_BL_array.at( iStation ).at( iSide ).size(); iStrip++ ) - { - hodo_BL_array.at( iStation ).at( iSide ).at(iStrip)=0; - } - } - } - - - for(int i =0; i<3;i++) - { - for(int s=0; s<2; s++) - { - Char_t inName[200]; - sprintf(inName,"base_line_vs_channel_STS%i_side%i",i,s); - baseline_ch[i][s] = new TH2F(inName, inName, 300, 0,300, 2000, -10, 3000); - - sprintf(inName,"raw_charge_vs_channel_STS%i_side%i_ifBL",i,s); - raw_ch[i][s] = new TH2F(inName, inName, 300, 0,300, 2000, -10, 3000); - - sprintf(inName,"raw_charge_vs_channel_STS%i_side%i_all",i,s); - raw_ch_woBL[i][s] = new TH2F(inName, inName, 300, 0,300, 2000, -10, 3000); - - sprintf(inName,"calibr_charge_vs_channel_STS%i_side%i",i,s); - calibr_ch[i][s] = new TH2F(inName, inName, 300, 0,300, 2000, -10, 3000); - - sprintf(inName,"calibr_charge_vs_channel_STS%i_side%i_1D",i,s); - calibr_ch1D[i][s] = new TH1F(inName, inName, 2000, -10, 3000); - } - } - - for(int i =0; i<2;i++) - { - for(int s=0; s<2; s++) - { - Char_t inName[200]; - sprintf(inName,"base_line_vs_channel_Hodo%i_side%i",i,s); - hodo_baseline_ch[i][s] = new TH2F(inName, inName, kBaselineNBins, kBaselineMinAdc, kBaselineMaxAdc, 2000, -10, 3000); - - sprintf(inName,"calibr_charge_vs_channel_Hodo%i_side%i",i,s); - hodo_calib_ch[i][s] = new TH2F(inName, inName, kBaselineNBins, kBaselineMinAdc, kBaselineMaxAdc, 2000, -10, 3000); - } - } - - fNofEvent = 0; - - cDigis = new std::vector<CbmStsDigi>; - ioman->RegisterAny("StsCalibDigi", cDigis, - IsOutputBranchPersistent("StsCalibDigi")); - - chDigis = new std::vector<CbmFiberHodoDigi>; - ioman->RegisterAny("HodoCalibDigi", chDigis, - IsOutputBranchPersistent("HodoCalibDigi")); - - /* - cDigis = RegisterOutput<CbmStsDigi>("StsCalibDigi"); - chDigis = RegisterOutput<CbmFiberHodoDigi>("HodoCalibDigi"); - - cDigis = new TClonesArray("CbmStsDigi", 100); - ioman->Register("StsCalibDigi", "Calibrated", cDigis, IsOutputBranchPersistent("StsCalibDigi")); - chDigis = new TClonesArray("CbmFiberHodoDigi", 100); - ioman->Register("HodoCalibDigi", "HodoCalibrated", chDigis, IsOutputBranchPersistent("HodoCalibDigi")); - */ - return kSUCCESS; - -} - -// ---- ReInit ------------------------------------------------------- -InitStatus StsCosyBL::ReInit() -{ - LOG(debug) << "Reinitilization of StsCosyBL"; - return kSUCCESS; -} - -// ---- Exec ---------------------------------------------------------- -void StsCosyBL::Exec(Option_t*) -{ - - /* - cDigis->Clear(); - chDigis->Clear(); - */ - cDigis->clear(); - chDigis->clear(); - - -// int fNDigis =0; -// int hNDigis =0; - - - { - Int_t nofSTS = fDigis->size(); - const CbmStsDigi* StsDigi = NULL; - for (Int_t iDigi=0; iDigi < nofSTS; iDigi++ ) - { - StsDigi = &(fDigis->at(iDigi)); - int station = CbmStsSetup::Instance()->GetStationNumber(StsDigi->GetAddress()); - int side = CbmStsAddress::GetElementId(StsDigi->GetAddress(),kStsSide); - int ch = StsDigi->GetChannel(); - raw_ch_woBL[station][side]->Fill(ch,StsDigi->GetCharge()); - } - } - - if (0 < fBLDigis->size() && 0 < hBLDigis->size() ) { - BaseLine(fBLDigis, base_line_array); - HodoBaseLine(hBLDigis,hodo_BL_array); - } else { - if(calib==kTRUE && hodo_calib ==kTRUE) { - Int_t nofSTS = fDigis->size(); - Int_t nofHodo = hDigis->size(); - - const CbmStsDigi* StsDigi = nullptr; - const CbmFiberHodoDigi* HodoDigi = nullptr; - for (Int_t iDigi=0; iDigi < nofHodo; iDigi++ ) { - HodoDigi = &(hDigis->at(iDigi)); - - Int_t system = CbmFiberHodoAddress::GetStationId(HodoDigi->GetAddress()); - Int_t layer = CbmFiberHodoAddress::GetSideId(HodoDigi->GetAddress()); - Int_t fiberNr = CbmFiberHodoAddress::GetStripId( HodoDigi->GetAddress()); - - double adc = -HodoDigi->GetCharge() + hodo_BL_array.at(system).at(layer).at(fiberNr); - - hodo_baseline_ch[system][layer] ->Fill(fiberNr, hodo_BL_array.at(system).at(layer).at(fiberNr)); - hodo_calib_ch[system][layer]->Fill(fiberNr,adc); - - if(adc>0) { - - chDigis->emplace_back(HodoDigi->GetAddress(), adc,HodoDigi->GetTime()); - /* - new ( (*chDigis)[hNDigis] )CbmFiberHodoDigi(HodoDigi->GetAddress(), adc,HodoDigi->GetTime()); - hNDigis++; - */ - } - else return; - - } - - // int sts[3]={0,0,0}; - // int side_sts[3][2]={0,0,0,0,0,0}; - - for (Int_t iDigi=0; iDigi < nofSTS; iDigi++ ) { - StsDigi = &(fDigis->at(iDigi)); - - int station = CbmStsSetup::Instance()->GetStationNumber(StsDigi->GetAddress()); - int side = CbmStsAddress::GetElementId(StsDigi->GetAddress(),kStsSide); - int ch = StsDigi->GetChannel(); - - double adc = -StsDigi->GetCharge() + base_line_array.at(station).at(side).at(ch); - - raw_ch[station][side]->Fill(ch,StsDigi->GetCharge()); - baseline_ch[station][side] ->Fill(ch, base_line_array.at(station).at(side).at(ch)); - - //if(station==fTriggeredStation && (ch < 21 || ch > 27))continue; //cut strip area - - calibr_ch[station][side]->Fill(ch,(UShort_t)adc); - calibr_ch1D[station][side]->Fill((UShort_t)adc); - - if(fTriggeredMode && station==fTriggeredStation) { - cDigis->emplace_back(StsDigi->GetAddress(), - StsDigi->GetChannel(), - StsDigi->GetTime(), adc); - /* - new ( (*cDigis)[fNDigis] ) CbmStsDigi(StsDigi->GetAddress(), - StsDigi->GetChannel(), - StsDigi->GetTime(), adc); - fNDigis++; - */ - } else if(adc>0) { - cDigis->emplace_back(StsDigi->GetAddress(), - StsDigi->GetChannel(), - StsDigi->GetTime(), (UShort_t)adc); - /* - new ( (*cDigis)[fNDigis] ) CbmStsDigi(StsDigi->GetAddress(), - StsDigi->GetChannel(), - StsDigi->GetTime(), (UShort_t)adc); - fNDigis++; - */ - } - else return; - } - - } - } - - - LOG(debug) << "Exec of StsCosyBL"; -// Reset(); -} - - void StsCosyBL::FinishEvent() - { - //Reset(); - // cout << "---I ------------- FinishEvent" << endl; -} - - - - -// ---- Finish -------------------------------------------------------- -void StsCosyBL::Finish() -{ - LOG(debug) << "Finish of StsCosyBL"; - - // Write standard file - FairRun* ana = FairRunAna::Instance(); - if ( ! ana ) { - ana = FairRunOnline::Instance(); - } - TFile* fout = ana->GetOutputFile(); - - for(int i =0; i<3;i++) { - for(int s=0; s<2; s++) { - baseline_ch[i][s]->Write(); - raw_ch_woBL[i][s]->Write(); - raw_ch[i][s]->Write(); - calibr_ch[i][s]->Write(); - calibr_ch1D[i][s]->Write(); - } - } - - for(int i =0; i<2;i++) { - for(int s=0; s<2; s++) { - hodo_baseline_ch[i][s]->Write(); - hodo_calib_ch[i][s]->Write(); - } - } - - if (fout) fout->Write(); - - LOG(info); - LOG(info) << "====================================================="; - LOG(info) << GetName() << ": Finish"; - LOG(info); - LOG(info) << "====================================================="; - LOG(info); - -} - - -void StsCosyBL::BaseLine(const std::vector<CbmStsDigi>* fBaselineDigis, vector< vector < vector < double> > >) -{ - - //BLInit(); - Int_t kNStations = 3; // TODO: from where do I get the number of stations? - Int_t kNSides = 2; // TODO: from where do I get the number of sides per station? - Int_t kNStrips = 1024; // TODO: from where do I get the number of strips per station side? - - vector< vector < vector < TH1F * > > > fBaselines; - fBaselines.resize( kNStations ); - - for( UInt_t iStation = 0; iStation < fBaselines.size(); iStation++ ) - { - fBaselines.at( iStation ).resize( kNSides ); - for( UInt_t iSide = 0; iSide < fBaselines.at( iStation ).size(); iSide++ ) - { - fBaselines.at( iStation ).at( iSide ).resize( kNStrips ); - for( UInt_t iStrip = 0; iStrip < fBaselines.at( iStation ).at( iSide ).size(); iStrip++ ) - { - const char * nametitle = Form( "blhist_sta%d_side%d_str%d", iStation, iSide, iStrip ); - fBaselines.at( iStation ).at( iSide ).at( iStrip ) = new TH1F( nametitle, nametitle, kBaselineNBins, kBaselineMinAdc, kBaselineMaxAdc ); - } - } - } - - cout << "---------CALIBRATION ---------ON ------------------- " << endl; - calib=kTRUE; - Int_t nBaselineEntries = fBaselineDigis->size(); - if( nBaselineEntries ) - { // TODO: Check here in a proper way if the event is a baseline event - - /* Baseline data should be taken from only one iteration of the baseline measurement - * (i.e. data from several different iterations of baseline calibration should not be mixed up) - * Therefore the baseline histograms should be zeroed before filling them with the data of the - * next calibration iteration */ - for( UInt_t iStation = 0; iStation < fBaselines.size(); iStation++ ) - { - for( UInt_t iSide = 0; iSide < fBaselines.at( iStation ).size(); iSide++ ) - { - for( UInt_t iStrip = 0; iStrip < fBaselines.at( iStation ).at( iSide ).size(); iStrip++ ) - { - fBaselines.at( iStation ).at( iSide ).at( iStrip )->Reset(); - } - } - } - - for( Int_t iDigi = 0; iDigi < nBaselineEntries; ++iDigi ) - { - const CbmStsDigi * digi = &(fBaselineDigis->at(iDigi)); - Int_t station = CbmStsSetup::Instance()->GetStationNumber( digi->GetAddress() ); - Int_t side = CbmStsAddress::GetElementId( digi->GetAddress(), kStsSide ); - Int_t strip = digi->GetChannel(); - Double_t adc = digi->GetCharge(); - fBaselines.at( station ).at( side ).at( strip )->Fill( adc ); - - } - - for( UInt_t iStation = 0; iStation < fBaselines.size(); iStation++ ) - { - for( UInt_t iSide = 0; iSide < fBaselines.at( iStation ).size(); iSide++ ) - { - for( UInt_t iStrip = 0; iStrip < fBaselines.at( iStation ).at( iSide ).size(); iStrip++ ) - { - TH1F * blHist = fBaselines.at( iStation ).at( iSide ).at( iStrip ); - if( blHist->GetEntries() ) - { - Double_t bl = GetBlPos( blHist ); - base_line_array.at(iStation).at(iSide).at(iStrip)=bl; - // LOG(info) << "Baseline of station " << iStation << " side " << iSide << " strip " << iStrip << " is " << base_line_array.at(iStation).at(iSide).at(iStrip) - //; - } - if(blHist) - { - blHist->Delete(); - } - } - } - } - } - // BLClean(); - cout << "---------CALIBRATION ---------OFF ------------------- " << endl; - -} - -void StsCosyBL::HodoBaseLine(const std::vector<CbmFiberHodoDigi>* fBaselineDigis, vector< vector < vector < double> > >) -{ - - Int_t hStations = 2; // TODO: from where do I get the number of stations? - Int_t hSides = 2; // TODO: from where do I get the number of sides per station? - Int_t hStrips = 64; // TODO: from where do I get the number of strips per station side? - vector< vector < vector < TH1F * > > > fBaselines; - - fBaselines.resize(hStations ); - for( UInt_t iStation = 0; iStation < fBaselines.size(); iStation++ ) - { - fBaselines.at( iStation ).resize(hSides ); - for( UInt_t iSide = 0; iSide < fBaselines.at( iStation ).size(); iSide++ ) - { - fBaselines.at( iStation ).at( iSide ).resize( hStrips ); - for( UInt_t iStrip = 0; iStrip < fBaselines.at( iStation ).at( iSide ).size(); iStrip++ ) - { - const char * nametitle = Form( "blhist_sta%d_side%d_str%d", iStation, iSide, iStrip ); - fBaselines.at( iStation ).at( iSide ).at(iStrip)=new TH1F( nametitle, nametitle, kBaselineNBins, kBaselineMinAdc, kBaselineMaxAdc ); - } - } - } - - cout << "---------HODO------------CALIBRATION ---------ON ------------------- " << endl; - hodo_calib=kTRUE; - Int_t nBaselineEntries = fBaselineDigis->size(); - if( nBaselineEntries ) - { // TODO: Check here in a proper way if the event is a baseline event - - /* Baseline data should be taken from only one iteration of the baseline measurement - * (i.e. data from several different iterations of baseline calibration should not be mixed up) - * Therefore the baseline histograms should be zeroed before filling them with the data of the - * next calibration iteration */ - for( UInt_t iStation = 0; iStation < fBaselines.size(); iStation++ ) - { - for( UInt_t iSide = 0; iSide < fBaselines.at(iStation).size(); iSide++ ) - { - for( UInt_t iStrip = 0; iStrip < fBaselines.at(iStation).at( iSide ).size(); iStrip++ ) - { - fBaselines.at(iStation).at( iSide ).at( iStrip )->Reset(); - } - } - } - - for( Int_t iDigi = 0; iDigi < nBaselineEntries; ++iDigi ) - { - const CbmFiberHodoDigi * digi = &(fBaselineDigis->at(iDigi)); - Int_t station = CbmFiberHodoAddress::GetStationId(digi->GetAddress()); - Int_t side = CbmFiberHodoAddress::GetSideId(digi->GetAddress()); - Int_t strip = CbmFiberHodoAddress::GetStripId(digi->GetAddress()); - - Double_t adc = digi->GetCharge(); - fBaselines.at(station).at( side ).at( strip )->Fill( adc ); - - } - for( UInt_t iStation = 0; iStation < fBaselines.size(); iStation++ ) - { - for( UInt_t iSide = 0; iSide < fBaselines.at(iStation).size(); iSide++ ) - { - for( UInt_t iStrip = 0; iStrip < fBaselines.at(iStation).at( iSide ).size(); iStrip++ ) - { - TH1F * blHist = fBaselines.at(iStation).at( iSide ).at( iStrip ); - if( blHist->GetEntries() ) - { - Double_t bl = GetBlPos( blHist ); - hodo_BL_array.at(iStation).at(iSide).at(iStrip)=bl; - // if(iSide ==0 || iSide ==1 || iSide==16 ||iSide ==17) - // LOG(info) << "Baseline of hodo " << " layer " << iSide << " strip " << iStrip << " is " << hodo_BL_array.at(iSide).at(iStrip); - } - if(blHist) - { - blHist->Delete(); - } - } - } - } - } - // BLClean(); - cout << "---------HODO-------------CALIBRATION ---------OFF ------------------- " << endl; - -} - -Double_t StsCosyBL::GetBlPos( TH1F * hist ) -{ - Int_t medianBin = 1; - - Double_t * integral = hist->GetIntegral(); - while( integral[ medianBin + 1 ] <= 0.5 ) { - medianBin++; - } - - return hist->GetXaxis()->GetBinCenter( medianBin ); -} - -void StsCosyBL::Reset() -{ - /* - if (cDigis) { - cDigis->Clear(); - } - if (chDigis) { - chDigis->Clear(); - } - */ - if (cDigis) { - cDigis->clear(); - } - if (chDigis) { - chDigis->clear(); - } -} - -ClassImp(StsCosyBL) diff --git a/beamtime/cosy2014/sts/reco/cosy/StsCosyBL.h b/beamtime/cosy2014/sts/reco/cosy/StsCosyBL.h deleted file mode 100644 index 45070366aaa5bdf2367dbf5cc1a43efd4ad6f98f..0000000000000000000000000000000000000000 --- a/beamtime/cosy2014/sts/reco/cosy/StsCosyBL.h +++ /dev/null @@ -1,108 +0,0 @@ -#ifndef STSCOSYBL_H -#define STSCOSYBL_H - -#include <Rtypes.h> // for ClassDef -#include <RtypesCore.h> // for Int_t, Bool_t, Double_t, Option_t -#include <TChain.h> // for TChain -#include <vector> // for vector -#include <FairTask.h> // for InitStatus, FairTask - -#include "CbmAuxDigi.h" -#include "CbmStsDigi.h" -#include "CbmFiberHodoDigi.h" - -class TFile; -class TH1F; -class TH2F; - -class StsCosyBL : public FairTask -{ - public: - - /** Default constructor **/ - StsCosyBL(); - - /** Constructor with parameters (Optional) - // StsCosyBL(Int_t verbose); - **/ - - /** Destructor **/ - ~StsCosyBL(); - - - /** Initiliazation of task at the beginning of a run **/ - virtual InitStatus Init(); - - /** ReInitiliazation of task when the runID changes **/ - virtual InitStatus ReInit(); - - - /** Executed for each event. **/ - virtual void Exec(Option_t* opt); - - /** Load the parameter container from the runtime database **/ - virtual void SetParContainers(); - - /** Recursive FinishEvent of subtasks **/ - virtual void FinishEvent(); - - /** Finish task called at the end of the run **/ - virtual void Finish(); - // virtual Int_t AddFile( const char* name ); - void BLInit(); - void BLClean(); - void BaseLine(const std::vector<CbmStsDigi>* fBaselineDigis, - std::vector< std::vector < std::vector < double> > > base_line_array); - void HodoBaseLine(const std::vector<CbmFiberHodoDigi>* fBaselineDigis, - std::vector< std::vector < std::vector < double> > > base_line); - - void SetTriggeredMode(Bool_t mode) { fTriggeredMode = mode; } - void SetTriggeredStation(Int_t station) { fTriggeredStation = station ; } - - virtual void Reset(); - - Int_t GetEntries () { return fChain->GetEntries();} - - private: - const std::vector<CbmAuxDigi>* auxDigis; - const std::vector<CbmStsDigi>* fDigis; - const std::vector<CbmStsDigi>* fBLDigis; - const std::vector<CbmFiberHodoDigi>* hBLDigis; - const std::vector<CbmFiberHodoDigi>* hDigis; - std::vector<CbmStsDigi>* cDigis; - std::vector<CbmFiberHodoDigi>* chDigis; - - TChain *fChain; //! - TFile *outFile; //! - static Double_t GetBlPos( TH1F * hist ); - static const Int_t kBaselineMinAdc = 0; - static const Int_t kBaselineMaxAdc = 4096; - static const Int_t kBaselineNBins = 4096; - - - TH2F *baseline_ch[3][2]; //! - TH2F *raw_ch[3][2]; //! - TH2F *raw_ch_woBL[3][2]; //! - TH2F *calibr_ch[3][2]; //! - TH1F *calibr_ch1D[3][2]; //! - - TH2F *hodo_baseline_ch[2][2]; //! - TH2F *hodo_calib_ch[2][2]; //! - - Bool_t calib; - Bool_t hodo_calib; - - Bool_t fTriggeredMode; ///< Flag if data is taken in triggered mode - Int_t fTriggeredStation; - Int_t fNofEvent; - - std::vector< std::vector < std::vector < double> > > base_line_array; - std::vector< std::vector < std::vector < double> > > hodo_BL_array; - - StsCosyBL(const StsCosyBL&); - StsCosyBL operator=(const StsCosyBL&); - - ClassDef(StsCosyBL,2); -}; - -#endif diff --git a/beamtime/cosy2014/sts/reco/cosy/StsCosyClusterFinder.cxx b/beamtime/cosy2014/sts/reco/cosy/StsCosyClusterFinder.cxx deleted file mode 100644 index 21de7aaf02ca7230c34c5d3fe152cd3839e49fda..0000000000000000000000000000000000000000 --- a/beamtime/cosy2014/sts/reco/cosy/StsCosyClusterFinder.cxx +++ /dev/null @@ -1,359 +0,0 @@ -#include "StsCosyClusterFinder.h" - -#include <FairTask.h> // for kSUCCESS, InitStatus, FairTask, kERROR -#include <TFile.h> // for TFile -#include <TH1.h> // for TH1F -#include <TMathBase.h> // for Abs -#include <TTree.h> // for TTree -#include <FairLogger.h> // for LOG, Logger -#include <stdio.h> // for NULL, sprintf -#include <iostream> // for operator<<, basic_ostream, endl, cout -#include "CbmStsAddress.h" // for GetElementId, kStsSide -#include "CbmStsCluster.h" // for CbmStsCluster -#include "CbmStsDigi.h" // for CbmStsDigi -#include "CbmStsSetup.h" // for CbmStsSetup -#include <FairRootManager.h> // for FairRootManager -#include <TClonesArray.h> // for TClonesArray -#include <TMath.h> // for Sqrt - -using std::map; -using std::set; -using namespace std; - -// ---- Default constructor ------------------------------------------- -StsCosyClusterFinder::StsCosyClusterFinder() - :FairTask("StsCosyClusterFinder",1), - fDigis(NULL), - fClusters(NULL), - finalClusters(NULL), - fTriggeredMode(kFALSE), - fTriggeredStation(1), - fChargeMinStrip(), - fChargeMaxStrip(), - fChargeMinCluster(), - fTimeLimit(), - fTimeShift(), - fCutName(""), - cluster_size(), - fEvent(0), - fDigiMap() -{ - for(int i=0; i<3; i++) - { - fTimeLimit[i]= 40.; - fTimeShift[i]= 0.; - - fChargeMinStrip[i]= 50.; - fChargeMaxStrip[i]= 500.; - - fChargeMinCluster[i]= 100.; - fCutName = ""; - } -} -// -------------------------------------------------------------------- - -// ---- Destructor ---------------------------------------------------- -StsCosyClusterFinder::~StsCosyClusterFinder() -{ - - if(fClusters){ - fClusters->Clear("C"); - fClusters->Delete(); - delete fClusters; - } - if(finalClusters){ - finalClusters->Clear("C"); - finalClusters->Delete(); - delete finalClusters; - } - -} - -// ---- Initialisation ---------------------------------------------- -void StsCosyClusterFinder::SetParContainers() -{ - - // Get Base Container -/* - FairRunAna* ana = FairRunAna::Instance(); - FairRuntimeDb* rtdb=ana->GetRuntimeDb(); -*/ -} -// -------------------------------------------------------------------- - -// ---- ReInit ------------------------------------------------------- -InitStatus StsCosyClusterFinder::ReInit(){ - -/* - FairRunAna* ana = FairRunAna::Instance(); - FairRuntimeDb* rtdb=ana->GetRuntimeDb(); -*/ - - return kSUCCESS; -} -// -------------------------------------------------------------------- - -// ---- Init ---------------------------------------------------------- -InitStatus StsCosyClusterFinder::Init() -{ - - FairRootManager *ioman = FairRootManager::Instance(); - - - // fDigis =(TClonesArray *) ioman->GetObject("StsCalibDigi"); - fDigis = ioman->InitObjectAs<std::vector<CbmStsDigi> const *>("StsCalibDigi"); - - if ( ! fDigis ) { - LOG(error) << "No StsDigi array!"; - LOG(error) << "Task will be inactive"; - return kERROR; - } - - finalClusters = new TClonesArray("CbmStsCluster", 100); - ioman->Register("StsCluster","STS",finalClusters,IsOutputBranchPersistent("StsCluster")); - - fClusters = new TClonesArray("CbmStsCluster", 100); - ioman->Register("StsClusterCandidate","STS",fClusters,IsOutputBranchPersistent("StsClusterCandidate")); - - if(fCutName != ""){ - - TFile *file = new TFile(fCutName); - - LOG(info) << "Use inpute file for time cuts " << fCutName; - - TTree *sts0 = (TTree*)file->Get("STS0"); - sts0->SetBranchAddress("TimeLimit",&fTimeLimit[0]); - sts0->SetBranchAddress("TimeShift",&fTimeShift[0]); - sts0->GetEntry(0); - - TTree * sts1 = (TTree*)file->Get("STS1"); - sts1->SetBranchAddress("TimeLimit",&fTimeLimit[1]); - sts1->SetBranchAddress("TimeShift",&fTimeShift[1]); - sts1->GetEntry(0); - - TTree * sts2 = (TTree*)file->Get("STS2"); - sts2->SetBranchAddress("TimeLimit",&fTimeLimit[2]); - sts2->SetBranchAddress("TimeShift",&fTimeShift[2]); - sts2->GetEntry(0); - } - - for(int i =0; i<3;i++)for(int ii =0; ii<2;ii++) - { - Char_t inName[25]; - sprintf(inName,"cluster_size_STS%i_side%i",i,ii); - cluster_size[i][ii] = new TH1F(inName, inName, 100, -0.5, 99.5); - } - - fEvent = 0; - - cout << "-I- StsCosyClusterFinder: Intialisation successfull " << kSUCCESS<< endl; - - return kSUCCESS; - -} -// -------------------------------------------------------------------- - -// ---- Exec ---------------------------------------------------------- -void StsCosyClusterFinder::Exec(Option_t*) -{ - if(fEvent%100000 == 0)cout << "-I- StsCosyClusterFinder: ----- " << fEvent << endl; - - fClusters->Delete(); - finalClusters->Delete(); - - map<Int_t, set<const CbmStsDigi*, classcomp1> >::iterator mapIt; - for (mapIt=fDigiMap.begin(); mapIt!=fDigiMap.end(); mapIt++) - { - ((*mapIt).second).clear(); - } - fDigiMap.clear(); - - Int_t nofDigis = fDigis->size(); - - fEvent++; - - if (0 == nofDigis) return; - - set<Int_t> layerSet; - - const CbmStsDigi* digi = NULL; - - map<const CbmStsDigi*, Int_t> fIndices; - - - for (Int_t iDigi=0; iDigi < nofDigis; iDigi++ ) - { - digi = &(fDigis->at(iDigi)); - int station = CbmStsSetup::Instance()->GetStationNumber(digi->GetAddress()); - int side = CbmStsAddress::GetElementId(digi->GetAddress(),kStsSide); - Int_t layer= 2*station+side; - - if(digi->GetCharge() > fChargeMinStrip[station] && digi->GetCharge() < fChargeMaxStrip[station]) - { - layerSet.insert(layer); - fDigiMap[layer].insert(digi); - fIndices.at(digi)=iDigi; - } - } - - set <const CbmStsDigi*, classcomp1> digiSet; - - for (set<Int_t>::iterator i = layerSet.begin(); i != layerSet.end(); i++) - { - digiSet = fDigiMap.at(*i); - Bool_t newCluster = kTRUE; - Int_t stripNr = -1; - Int_t stripNrPrev = -1; - CbmStsCluster* cluster=NULL; - Double_t time = -1; - Double_t timePrev = -1; - - for (set<const CbmStsDigi*, classcomp1>::iterator j = digiSet.begin(); j != digiSet.end(); j++) - { - if (newCluster) - { - Int_t size = fClusters->GetEntriesFast(); - cluster = new ((*fClusters)[size]) CbmStsCluster(); - Int_t index = fIndices[(*j)]; - //----time---- - digi = &(fDigis->at(index)); - // digi = static_cast<CbmStsDigi*>(fDigis->At(index)); - timePrev = digi->GetTime(); - - cluster->AddDigi(index); - stripNrPrev = (*j)->GetChannel(); - newCluster = kFALSE; - } - else - { - Int_t index = fIndices[(*j)]; - digi = &(fDigis->at(index)); - //digi = static_cast<CbmStsDigi*>(fDigis->At(index)); - time = digi->GetTime(); - stripNr = (*j)->GetChannel(); - - int station = CbmStsSetup::Instance()->GetStationNumber(digi->GetAddress()); -// int side = CbmStsAddress::GetElementId(digi->GetAddress(),kStsSide); - - Bool_t TrCl = kTRUE; - - if(fTriggeredMode && station==fTriggeredStation) - { - if(TMath::Abs(time - timePrev) > 1)TrCl=kFALSE; - } - if (1 == stripNr-stripNrPrev && TMath::Abs(time - timePrev- fTimeShift[station])< fTimeLimit[station] && TrCl) - { - stripNrPrev = stripNr; - timePrev = time; - cluster = (CbmStsCluster*) fClusters->Last(); - cluster->AddDigi(index); - } - else if(TrCl) - { - Int_t size = fClusters->GetEntriesFast(); - cluster = new ((*fClusters)[size]) CbmStsCluster(); - index = fIndices[(*j)]; - cluster->AddDigi(index); - stripNrPrev = (*j)->GetChannel(); - newCluster = kFALSE; - } - } - } - } - - if(nofDigis>0) - { - Int_t nofClusterCandidates = fClusters->GetEntriesFast(); -// int clust[6]={0,0,0,0,0,0}; -// Int_t layer=0; - for (Int_t iclus = 0; iclus < nofClusterCandidates; iclus++) - { - Double_t chanNr = 0; - Double_t chanADC = 0.; -// Double_t adc = 100.; - Double_t sumW = 0; - Double_t sumWX = 0; - Double_t error = 0; -// layer=0; - Double_t chanNrMean = 0; - const CbmStsCluster* cluster = static_cast<const CbmStsCluster*>(fClusters->At(iclus)); - Int_t nofStrips = cluster->GetNofDigis(); - - //if(nofStrips > 1)continue; //produce only 1 strip cluster - -// Double_t time = -999.; - double mean_time = 0.; - - int station = 0; - int side = 0; - for(int st=0; st<nofStrips; st++) - { - const CbmStsDigi* temp_digi = &(fDigis->at(cluster->GetDigi(st))); - station = CbmStsSetup::Instance()->GetStationNumber(temp_digi->GetAddress()); - side = CbmStsAddress::GetElementId(temp_digi->GetAddress(),kStsSide); - int ch = temp_digi->GetChannel(); -// layer = 2*station+side; - chanNr += ch; - chanADC = temp_digi->GetCharge(); - sumW += chanADC; - sumWX += ch * chanADC; - error += (chanADC * chanADC); - -// time = temp_digi->GetTime(); - mean_time+=temp_digi->GetTime(); - - //if(chanADC > adc){adc=chanADC; mean_time=time;} - } - chanNrMean = chanNr/(Double_t)nofStrips; - if(sumW < fChargeMinCluster[station]){continue;} - - Int_t size = finalClusters->GetEntriesFast(); - CbmStsCluster* new_cluster = new ((*finalClusters)[size]) CbmStsCluster(); - - for (Int_t i = 0; i < nofStrips; ++i) - { - Int_t digi_index=cluster->GetDigi(i); - const CbmStsDigi* temp_digi = &(fDigis->at(digi_index)); - if (i == 0) - { - new_cluster->SetAddress(temp_digi->GetAddress()); - } - new_cluster->AddDigi(digi_index); - - } - //new_cluster->SetCentre(sumWX / sumW); - //new_cluster->SetProperties(sumW,chanNrMean,0.,mean_time/nofStrips); - //new_cluster->SetProperties(0.,0.,0.,mean_time); - //new_cluster->SetCentreError((1. / (sumW)) * TMath::Sqrt(error)); - - new_cluster->SetProperties(sumW, chanNrMean, (1./(sumW))*TMath::Sqrt(error), mean_time/nofStrips); - - cluster_size[station][side]->Fill(new_cluster->GetNofDigis()); - } - } - fIndices.clear(); - digiSet.clear(); - layerSet.clear(); - -} -// -------------------------------------------------------------------- - - // ---- Finish -------------------------------------------------------- - void StsCosyClusterFinder::Finish() - { - for(int i=0; i<3; i++)for(int j=0; j<2; j++)cluster_size[i][j]->Write(); - - LOG(info); - LOG(info) << "====================================================="; - LOG(info) << GetName() << ": Finish"; - LOG(info) << "====================================================="; - LOG(info); - - } - - - - - - ClassImp(StsCosyClusterFinder) - diff --git a/beamtime/cosy2014/sts/reco/cosy/StsCosyClusterFinder.h b/beamtime/cosy2014/sts/reco/cosy/StsCosyClusterFinder.h deleted file mode 100644 index 81f7a2dfc584bef33f0fc3ae3a4d4d03ef253713..0000000000000000000000000000000000000000 --- a/beamtime/cosy2014/sts/reco/cosy/StsCosyClusterFinder.h +++ /dev/null @@ -1,100 +0,0 @@ -/** StsCosyClusterFinder.h - *@author Florian Uhlig <f.uhlig@gsi.de> - ** - ** Task to find neighboring fibres which are above - ** the base line. - ** Create as an output an array of - ** the digis belonging to the cluster. - ** - ** 2015 Anna Senger <a.senger@gsi.de> - **/ - -#ifndef STSCOSYCLUSTERFINDER_H -#define STSCOSYCLUSTERFINDER_H - -#include <Rtypes.h> // for ClassDef -#include <RtypesCore.h> // for Double_t, Int_t, Bool_t, Option_t -#include <TString.h> // for TString -#include <map> // for map -#include <set> // for set -#include <vector> -#include "CbmStsDigi.h" // for CbmStsDigi -#include <FairTask.h> // for InitStatus, FairTask - - -class TH1F; - - -struct classcomp1 { - bool operator() (const CbmStsDigi* lhs, const CbmStsDigi* rhs) const - {return lhs->GetChannel() < rhs->GetChannel();} -}; - -class StsCosyClusterFinder : public FairTask -{ - - public: - - /** - * Default constructor. - */ - StsCosyClusterFinder(); - - /** - * Default destructor. - */ - ~StsCosyClusterFinder(); - - /** Initialisation **/ - virtual InitStatus ReInit(); - virtual InitStatus Init(); - virtual void SetParContainers(); - - /** Executed task **/ - virtual void Exec(Option_t * option); - - void SetTriggeredMode(Bool_t mode) { fTriggeredMode = mode; } - void SetTriggeredStation(Int_t station) { fTriggeredStation = station ; } - - void SetChargeLimitsStrip(Double_t min[3], Double_t max[3]) { for(int i=0; i<3; i++){fChargeMinStrip[i] = min[i]; fChargeMaxStrip[i] = max[i];} } - void SetChargeMinCluster(Double_t min[3]) { for(int i=0; i<3; i++)fChargeMinCluster[i]=min[i]; } - - void SetTimeLimit(Double_t time[3]) { for(int i=0; i<3; i++)fTimeLimit[i]=time[i]; } - void SetTimeShift(Double_t time[3]) { for(int i=0; i<3; i++)fTimeShift[i]=time[i]; } - - void SetCutFileName(TString name){fCutName = name;} - -/** Finish task **/ - virtual void Finish(); - - private: - - const std::vector<CbmStsDigi>* fDigis; /** Input array of CbmStsDigi **/ - TClonesArray* fClusters; /** candidates array of CbmStsCluster **/ - TClonesArray* finalClusters; /** Output array of CbmStsCluster **/ - - Bool_t fTriggeredMode; ///< Flag if data is taken in triggered mode - Int_t fTriggeredStation; - - Double_t fChargeMinStrip[3]; - Double_t fChargeMaxStrip[3]; - Double_t fChargeMinCluster[3]; - - Double_t fTimeLimit[3]; - Double_t fTimeShift[3]; - - TString fCutName; - - TH1F* cluster_size[3][2]; //! - - Int_t fEvent; - - std::map<Int_t, std::set<const CbmStsDigi*, classcomp1> > fDigiMap; /** digis per hodo layer **/ - - StsCosyClusterFinder(const StsCosyClusterFinder&); - StsCosyClusterFinder& operator=(const StsCosyClusterFinder&); - - ClassDef(StsCosyClusterFinder,1); - -}; -#endif diff --git a/beamtime/cosy2014/sts/reco/cosy/StsCosyHitFinder.cxx b/beamtime/cosy2014/sts/reco/cosy/StsCosyHitFinder.cxx deleted file mode 100644 index bc1877fc4104239612746c02f47752027a11bf83..0000000000000000000000000000000000000000 --- a/beamtime/cosy2014/sts/reco/cosy/StsCosyHitFinder.cxx +++ /dev/null @@ -1,365 +0,0 @@ -#include "StsCosyHitFinder.h" - -#include <FairTask.h> // for kSUCCESS, InitStatus, FairTask, kERROR -#include <TFile.h> // for TFile -#include <TH1.h> // for TH1F -#include <TMathBase.h> // for Abs -#include <TTree.h> // for TTree -#include <FairLogger.h> // for LOG, Logger -#include <stdio.h> // for sprintf, NULL -#include <iostream> // for operator<<, basic_ostream, endl, cout -#include <map> // for map -#include <set> // for set -#include <vector> // for vector -#include "CbmStsAddress.h" // for GetElementId, kStsSide -#include "CbmStsCluster.h" // for CbmStsCluster -#include "CbmStsHit.h" // for CbmStsHit -#include "CbmStsSetup.h" // for CbmStsSetup -#include <FairRootManager.h> // for FairRootManager -#include <TClonesArray.h> // for TClonesArray -#include <TMath.h> // for DegToRad, Tan -#include <TVector3.h> // for TVector3 - -using std::map; -using std::set; -using namespace std; - -// ---- Default constructor ------------------------------------------- -StsCosyHitFinder::StsCosyHitFinder() - :FairTask("StsCosyHitFinder",1), - stsClusters(NULL), - fHits(NULL), - fChain(new TChain("cbmsim")), - fSensorId(13), - fZ0(25.3), - fZ1(99.3), - fZ2(140.7), - fTimeLimit(), - fTimeShift(), - cluster_size(), - fCutName(""), - fEvent(0) -{ -// fChain = new TChain("cbmsim"); - - //--------------- Cosy 2013 - //fZ0 = 25.4; // STS1 - //fZ1 = 70.9; // STS2 - //fZ2 = 123.4; // STS0 - - //--------------- Cosy 2014 -// fZ0 = 25.3; // STS1 -// fZ1 = 99.3; // STS3 -// fZ2 = 140.7; // STS0 - - //--------------- Cosy 2014 - fTimeLimit[0] = 16.; - fTimeLimit[1] = 14.; - fTimeLimit[2] = 22.; - - fTimeShift[0] = -3.; - fTimeShift[1] = 3.; - fTimeShift[2] = -6.; - - fCutName = ""; -} -// -------------------------------------------------------------------- - -// ---- Destructor ---------------------------------------------------- -StsCosyHitFinder::~StsCosyHitFinder() -{ - if (fHits){ - fHits->Delete(); - delete fHits; - } - if(stsClusters){ - stsClusters->Clear("C"); - stsClusters->Delete(); - delete stsClusters; - } - -} - -// ---- Initialisation ---------------------------------------------- -void StsCosyHitFinder::SetParContainers() -{ - - // Get Base Container -/* - FairRunAna* ana = FairRunAna::Instance(); - FairRuntimeDb* rtdb=ana->GetRuntimeDb(); -*/ -} -// -------------------------------------------------------------------- - -// ---- ReInit ------------------------------------------------------- -InitStatus StsCosyHitFinder::ReInit(){ - -/* - FairRunAna* ana = FairRunAna::Instance(); - FairRuntimeDb* rtdb=ana->GetRuntimeDb(); -*/ - - return kSUCCESS; -} -// -------------------------------------------------------------------- - -// ---- Init ---------------------------------------------------------- -InitStatus StsCosyHitFinder::Init() -{ - - FairRootManager *ioman = FairRootManager::Instance(); - - fHits = new TClonesArray("CbmStsHit", 1000); - ioman->Register("StsHit", "Hit in STS", fHits, IsOutputBranchPersistent("StsHit")); - - stsClusters =(TClonesArray *) ioman->GetObject("StsCluster"); - if ( !stsClusters ) { - LOG(error) << "No StsCluster array!"; - LOG(error) << "Task will be inactive"; - return kERROR; - } - - if(fCutName != ""){ - LOG(info) << "Use inpute file for time cuts " << fCutName; - TFile *file = new TFile(fCutName); - - TTree *cluster = (TTree*)file->Get("Cluster cuts"); - cluster->SetBranchAddress("TimeLimit",fTimeLimit); - cluster->SetBranchAddress("TimeShift",fTimeShift); - cluster->GetEntry(0); - - } - fEvent = 0; - - for(int i =0; i<3;i++)for(int ii =0; ii<2;ii++) - { - Char_t inName[25]; - sprintf(inName,"cluster_size_STS%i_side%i",i,ii); - cluster_size[i][ii] = new TH1F(inName, inName, 100, -0.5, 99.5); - } - - - cout << "-I- StsCosyHitFinder: Intialisation successfull " << kSUCCESS<< endl; - - return kSUCCESS; - -} -// -------------------------------------------------------------------- - -// ---- Exec ---------------------------------------------------------- -void StsCosyHitFinder::Exec(Option_t*) -{ - fHits->Clear(); -// if(fEvent%100000 == 0)cout << "-I- StsCosyHitFinder: ----- " << fEvent << endl; - - Int_t nofSTSClusters = stsClusters->GetEntries(); - - if(nofSTSClusters<1) - return; - - vector<int> sts_0p, sts_0n, sts_1p, sts_1n, sts_2p, sts_2n; - -// double x=-100; -// double y=-100; - int clust[6]={0,0,0,0,0,0}; - - for (Int_t iclus = 0; iclus < nofSTSClusters; iclus++) - { - int layer =-1; - const CbmStsCluster* cluster = static_cast<const CbmStsCluster*>(stsClusters->At(iclus)); -// Int_t nofStrips = cluster->GetNofDigis(); - -// double adc=-100; - - int station = CbmStsSetup::Instance()->GetStationNumber(cluster->GetAddress()); - int side = CbmStsAddress::GetElementId(cluster->GetAddress(),kStsSide); -// int ch = CbmStsAddress::GetElementId(cluster->GetAddress(),kStsChannel); - - layer = 2*station+side; - - clust[layer]++; - - if(layer ==0) - sts_0n.push_back(iclus); - if(layer ==1) - sts_0p.push_back(iclus); - if(layer ==2) - sts_1n.push_back(iclus); - if(layer ==3) - sts_1p.push_back(iclus); - if(layer ==4) - sts_2n.push_back(iclus); - if(layer ==5) - sts_2p.push_back(iclus); - } - - for(UInt_t i=0; i< sts_0n.size(); i++) - { - Int_t frontClusterId = sts_0n[i]; - const CbmStsCluster* frontCluster = static_cast<const CbmStsCluster*>(stsClusters->At(sts_0n[i])); - //Double_t frontChannel = frontCluster->GetMean(); - Double_t frontChannel = frontCluster->GetPosition(); - Double_t front_time = frontCluster->GetTime(); - for(UInt_t k=0; k< sts_0p.size(); k++) - { - Int_t backClusterId = sts_0p[k]; - const CbmStsCluster* backCluster = static_cast<const CbmStsCluster*>(stsClusters->At(sts_0p[k])); - //Double_t backChannel = backCluster->GetMean(); - Double_t backChannel = backCluster->GetPosition(); - Double_t back_time = backCluster->GetTime(); - if(TMath::Abs(back_time - front_time - fTimeShift[0]) < fTimeLimit[0]) - { - - Double_t xHit = (frontChannel - 127)*0.005; - Double_t yHit = (backChannel-127)*0.005; - - Double_t zHit = fZ0; - TVector3 pos(xHit, yHit, zHit); - TVector3 dpos; - //dpos.SetXYZ(frontCluster->GetMeanError()*0.005,backCluster->GetMeanError()*0.005, 0.); - - Double_t global[] = {xHit, yHit, zHit}; - Double_t error[] = { 0.0017, 0.0017, 0.}; - - Int_t size = fHits->GetEntriesFast(); - /* - new ((*fHits)[size]) CbmStsHit(frontCluster->GetAddress(), - pos, dpos, 0, frontClusterId, backClusterId, - 0, 0, 1,(back_time + front_time)/2.); - */ - - Double_t hitTimeError = 0.5 * TMath::Abs(back_time - front_time); - - new ((*fHits)[size]) CbmStsHit(frontCluster->GetAddress(), - global, error, 0, frontClusterId, backClusterId, - (back_time + front_time)/2., hitTimeError); - - - cluster_size[0][0]->Fill(frontCluster->GetNofDigis()); - cluster_size[0][1]->Fill(backCluster->GetNofDigis()); - } - } - } - - for(UInt_t i=0; i< sts_1n.size(); i++) - { - Int_t frontClusterId = sts_1n[i]; - const CbmStsCluster* frontCluster = static_cast<const CbmStsCluster*>(stsClusters->At(sts_1n[i])); - //Double_t frontChannel = frontCluster->GetMean(); - Double_t frontChannel = frontCluster->GetPosition(); - Double_t front_time = frontCluster->GetTime(); - for(UInt_t k=0; k< sts_1p.size(); k++) - { - Int_t backClusterId = sts_1p[k]; - const CbmStsCluster* backCluster = static_cast<const CbmStsCluster*>(stsClusters->At(sts_1p[k])); - //Double_t backChannel = backCluster->GetMean(); - Double_t backChannel = backCluster->GetPosition(); - if(fSensorId==19)backChannel-=63; - Double_t back_time = backCluster->GetTime(); - //if ((!fTriggeredMode && TMath::Abs(back_time -front_time - fTimeShift[1]) < fTimeLimit[1]) || fTriggeredMode) - if (TMath::Abs(back_time -front_time - fTimeShift[1]) < fTimeLimit[1]) - { - - Double_t zHit = fZ1; - - Double_t xHit = (frontChannel - 34)*0.0058; - Double_t yHit = (frontChannel - backChannel)*0.0058/TMath::Tan(7.5*TMath::DegToRad()); - - TVector3 pos(xHit, yHit, zHit); - TVector3 dpos; - //dpos.SetXYZ(frontCluster->GetMeanError()*0.0058,backCluster->GetMeanError()*0.0058, 0.); - dpos.SetXYZ(0.0017, 0.0017, 0.); - - Double_t global[] = {xHit, yHit, zHit}; - Double_t error[] = { 0.0017, 0.0017, 0.}; - - Int_t size = fHits->GetEntriesFast(); - /* - new ((*fHits)[size]) CbmStsHit(frontCluster->GetAddress(), - pos, dpos, 0, frontClusterId, backClusterId, - 0, 0, 2,(back_time + front_time)/2.); - */ - Double_t hitTimeError = 0.5 * TMath::Abs(back_time - front_time); - - new ((*fHits)[size]) CbmStsHit(frontCluster->GetAddress(), - global, error, 0, frontClusterId, backClusterId, - (back_time + front_time)/2., hitTimeError); - - cluster_size[1][0]->Fill(frontCluster->GetNofDigis()); - cluster_size[1][1]->Fill(backCluster->GetNofDigis()); - } - } - } - - for(UInt_t i=0; i< sts_2n.size(); i++) - { - Int_t frontClusterId = sts_2n[i]; - const CbmStsCluster* frontCluster = static_cast<const CbmStsCluster*>(stsClusters->At(sts_2n[i])); - //Double_t frontChannel = frontCluster->GetMean(); - Double_t frontChannel = frontCluster->GetPosition(); - Double_t front_time = frontCluster->GetTime(); - for(UInt_t k=0; k< sts_2p.size(); k++) - { - Int_t backClusterId = sts_2p[k]; - const CbmStsCluster* backCluster = static_cast<const CbmStsCluster*>(stsClusters->At(sts_2p[k])); - //Double_t backChannel = backCluster->GetMean(); - Double_t backChannel = backCluster->GetPosition(); - Double_t back_time = backCluster->GetTime(); - if(TMath::Abs(back_time -front_time - fTimeShift[2]) < fTimeLimit[2]) - { - Double_t zHit = fZ2; - - Double_t xHit = (frontChannel-127)*0.005; - Double_t yHit = (128-backChannel)*0.005; - TVector3 pos(xHit, yHit, zHit); - TVector3 dpos; - //dpos.SetXYZ(frontCluster->GetMeanError()*0.005,backCluster->GetMeanError()*0.005, 0.); - dpos.SetXYZ(0.0017, 0.0017, 0.); - - Double_t global[] = {xHit, yHit, zHit}; - Double_t error[] = { 0.0017, 0.0017, 0.}; - - Int_t size = fHits->GetEntriesFast(); - /* - new ((*fHits)[size]) CbmStsHit(frontCluster->GetAddress(), - pos, dpos, 0, frontClusterId, backClusterId, - 0, 0, 3,(back_time + front_time)/2.); - */ - Double_t hitTimeError = 0.5 * TMath::Abs(back_time - front_time); - - new ((*fHits)[size]) CbmStsHit(frontCluster->GetAddress(), - global, error, 0, frontClusterId, backClusterId, - (back_time + front_time)/2., hitTimeError); - - cluster_size[2][0]->Fill(frontCluster->GetNofDigis()); - cluster_size[2][1]->Fill(backCluster->GetNofDigis()); - } - } - } - - fEvent++; - - stsClusters->Clear(); - -} -// -------------------------------------------------------------------- - - // ---- Finish -------------------------------------------------------- - void StsCosyHitFinder::Finish() - { - for(int i=0; i<3; i++)for(int j=0; j<2; j++)cluster_size[i][j]->Write(); - - LOG(info); - LOG(info) << "====================================================="; - LOG(info) << GetName() << ": Finish"; - LOG(info) << "====================================================="; - LOG(info); - } - - - - - - ClassImp(StsCosyHitFinder) - diff --git a/beamtime/cosy2014/sts/reco/cosy/StsCosyHitFinder.h b/beamtime/cosy2014/sts/reco/cosy/StsCosyHitFinder.h deleted file mode 100644 index d430a45f84198e2f8a9d651f716b71d641812f55..0000000000000000000000000000000000000000 --- a/beamtime/cosy2014/sts/reco/cosy/StsCosyHitFinder.h +++ /dev/null @@ -1,85 +0,0 @@ -/** StsCosyHitFinder.h - *@author Florian Uhlig <f.uhlig@gsi.de> - ** - ** Task to find neighboring fibres which are above - ** the base line. - ** Create as an output an array of - ** the digis belonging to the cluster. - ** - ** 2015 Anna Senger <a.senger@gsi.de> - **/ - -#ifndef STSCOSYHITFINDER_H -#define STSCOSYHITFINDER_H - -#include <Rtypes.h> // for ClassDef -#include <RtypesCore.h> // for Double_t, Int_t, Option_t -#include <TChain.h> // for TChain -#include <TString.h> // for TString -#include <FairTask.h> // for InitStatus, FairTask - -class TClonesArray; -class TH1F; - -class StsCosyHitFinder : public FairTask -{ - - public: - - /** - * Default constructor. - */ - StsCosyHitFinder(); - - /** - * Default destructor. - */ - ~StsCosyHitFinder(); - - /** Initialisation **/ - virtual InitStatus ReInit(); - virtual InitStatus Init(); - virtual void SetParContainers(); - - /** Executed task **/ - virtual void Exec(Option_t * option); - Int_t GetEntries () { return fChain->GetEntries();} - - void SetZ(Double_t z0, Double_t z1, Double_t z2) { fZ0 = z0; fZ1 = z1; fZ2 = z2; } - - void SetTimeLimit(Double_t time[3]) { for(int i=0; i<3; i++)fTimeLimit[i]=time[i]; } - void SetTimeShift(Double_t time[3]) { for(int i=0; i<3; i++)fTimeShift[i]=time[i]; } - - void SetSensorId(Int_t sensor) { fSensorId=sensor; } //13 for W13, 10 for W10, 18 for W18 - - void SetCutFileName(TString name){fCutName = name;} - - /** Finish task **/ - virtual void Finish(); - - private: - - TClonesArray* stsClusters; /** Input array of CbmStsCluster **/ - - TClonesArray* fHits; /** Output array of CbmHits **/ - - TChain *fChain; - - Int_t fSensorId; - Double_t fZ0, fZ1, fZ2; - Double_t fTimeLimit[3]; - Double_t fTimeShift[3]; - - TH1F* cluster_size[3][2]; //! - - TString fCutName; - - Int_t fEvent; - - StsCosyHitFinder(const StsCosyHitFinder&); - StsCosyHitFinder& operator=(const StsCosyHitFinder&); - - ClassDef(StsCosyHitFinder,1); - -}; -#endif diff --git a/beamtime/cosy2014/sts/reco/cosy/StsCosyTrack.cxx b/beamtime/cosy2014/sts/reco/cosy/StsCosyTrack.cxx deleted file mode 100644 index 66f5ee0493ecc79f61fcc0ac21742e71c9181b43..0000000000000000000000000000000000000000 --- a/beamtime/cosy2014/sts/reco/cosy/StsCosyTrack.cxx +++ /dev/null @@ -1,364 +0,0 @@ -#include <iostream> - -#include "TClonesArray.h" - -#include "FairRootManager.h" -#include "FairLogger.h" - -#include "StsCosyTrack.h" -#include "CbmStsHit.h" -#include "CbmStsAddress.h" - -#include "TMath.h" -#include "TF1.h" -#include "TGraphErrors.h" - -using std::cout; -using std::endl; - - - -StsCosyTrack::StsCosyTrack() : - FairTask("StsCosyTrack",1), - fHits(NULL), - fDigiArray(NULL), - fNDigis(0), - fAlignment(kFALSE), - fChi2X(1000), - fChi2Y(1000) -{ - fChain = new TChain("cbmsim"); -} - -StsCosyTrack::~StsCosyTrack() -{ - if ( fHits ) { - fHits->Delete(); - delete fHits; - } - if ( fDigiArray ) { - fDigiArray->Delete(); - delete fDigiArray; - } - -} - - -InitStatus StsCosyTrack::Init() { - - // Get RootManager - FairRootManager* ioman = FairRootManager::Instance(); - if ( ! ioman ) - { - LOG(fatal) << "StsCosyTrack::Init: noRootManager !"; - return kFATAL; - } - // Get input arrays - - fHits =(TClonesArray *) ioman->GetObject("StsHit"); - if ( ! fHits ) { - LOG(error) << "No StsHits array!"; - LOG(error) << "Task will be inactive"; - return kERROR; - } - - for(int i=0;i<5;i++) - fMapPts.insert(make_pair(i,vector<CbmStsHit*>())); - - for (Int_t i=0;i<5;i++) - { - Char_t buf[25]; - sprintf(buf,"ResX%i",i); - h_resX[i] = new TH1F(buf,buf,4000, -1,1); - sprintf(buf,"ResY%i",i); - h_resY[i] = new TH1F(buf,buf,4000, -1,1); - sprintf(buf,"PullX%i",i); - h_pullX[i] = new TH1F(buf,buf,400, -100.,100.); - sprintf(buf,"PullY%i",i); - h_pullY[i] = new TH1F(buf,buf,400, -100.,100.); - sprintf(buf,"XY_sts_%i",i); - XY[i] = new TH2D(buf,buf,400, -1, 1,400, -1, 1); - } - - for (Int_t i=0;i<3;i++) - { - Char_t buf[25]; - sprintf(buf,"chi2change_sts_%i",i); - chi_change[i]= new TH1F(buf,buf,1000, -1,1000); - } - - h_chi2 = new TH1F("chi2","chi2",400, 0.,20.); - h_pchi2 = new TH1F("pchi2","pchi2",400, 0.,1.); - y_chi2 = new TH1F("Ychi2","Ychi2",400, 0.,20.); - y_pchi2 = new TH1F("Ypchi2","Ypchi2",400, 0.,1.); - - h_xx01 = new TH2F("XX01","XX01",400, -2.,2.,400, -2.,2.); - h_xx21 = (TH2F*)h_xx01->Clone("XX21"); - h_xx02 = (TH2F*)h_xx01->Clone("XX02"); - h_yy01 = (TH2F*)h_xx01->Clone("YY01"); - h_yy21 = (TH2F*)h_xx01->Clone("YY21"); - h_yy02 = (TH2F*)h_xx01->Clone("YY02"); - - cout << "-I- StsCosyTrack: Intialisation successfull " << kSUCCESS<< endl; - return kSUCCESS; - -} - -// ----- Public method Exec -------------------------------------------- -void StsCosyTrack::Exec(Option_t* /*opt*/) { - - Reset(); - CbmStsHit* hit = NULL; - Int_t nofHits = fHits->GetEntries(); - - int hit_is[5]={-1,-1,-1,-1,-1}; - - if(nofHits<5)return; - - // Loop over hits - for (Int_t iHit=0; iHit<nofHits; iHit++) - { - hit = (CbmStsHit*) fHits->At(iHit); - - // Determine sector type and channel numbers - /** - ** PAL, 19/06/15: Deprecated in rev 7648, to remove once checked - Int_t detId = hit->GetSectorNr(); - **/ - /** - // PAL, 19/06/15, TODO: check best way to keep track of the detector ID - // For now use the frontDigiId of CbmStsHit instead of the deprecated SectorNb - *** PAL, 25/08/15: frontDigiId Deprecated in rev 8277 => Try to use directly the frontCluster Address - Int_t detId = hit->GetFrontDigiId(); - **/ - // Addr(Side, Station) Detector Index detID - // (1, 0) Hodo 1 0 - // (1, 1) Hodo 2 4 - // (0, 0) Hodo 1 1 - // (0, 1) Hodo 2 3 - // (0, 2) Hodo 3 2 - Int_t iFrontSide = CbmStsAddress::GetElementId(hit->GetAddress(),kStsSide); - Int_t iFrontStation = CbmStsAddress::GetElementId(hit->GetAddress(),kStsStation); - Int_t detId; - if( 1 == iFrontSide ) - { - // Hodoscope Hit - if( 0 == iFrontStation ) - detId = 0; - else if( 1 == iFrontStation ) - detId = 4; - else continue; // Unknown address, just jump for now, need error - } // if( 1 == iFrontSide ) - else - { - // STS hit - if( 0 == iFrontStation ) - detId = 1; - else if( 1 == iFrontStation ) - detId = 3; - else if( 2 == iFrontStation ) - detId = 2; - else continue; // Unknown address, just jump for now, need error - } // else of if( 1 == iFrontSide ) - - vector<CbmStsHit*>& vlist = fMapPts[detId]; - vlist.push_back((CbmStsHit*) hit); - } - - // Check the content per detector - for (int idet=0; idet<5;idet++) - { - // get the vector - vector<CbmStsHit*>& v = fMapPts[idet]; - // select at least 1 points per detector - if (v.size()==0) return ; - // select multiplicity per detector - //if (v.size()>1) return ; - - // cout << "-I- StsCosyTrack idet# " << idet << " has " << v.size() << " hits " << endl; - } - - // Find the tracks - FindTracks(); - -} - - -Bool_t StsCosyTrack::FindTracks(){ - - Double_t align[2][3]; - for(int i=0; i<2; i++)for(int j=0; j<3; j++)align[i][j]=0; - - if(fAlignment) - { - - align[0][0] = 0.00722846; - align[0][1] = -0.104797; - align[0][2] = 0.00385107; - - align[1][0] = -0.00437047; - align[1][1] = 0.0421997; - align[1][2] = -0.00237545; - } - - - // Check the content per detector - for (int idet=0; idet<5;idet++) - { - // get the vector - vector<CbmStsHit*>& v = fMapPts[idet]; - // select at least 1 points per detector - if (v.size()==0) return kFALSE; - } - - -// vector<CbmStsHit*>& v_hodo0 = fMapPts[0]; -// vector<CbmStsHit*>& v_hodo1 = fMapPts[4]; - vector<CbmStsHit*>& v_sts0 = fMapPts[1]; - vector<CbmStsHit*>& v_sts2 = fMapPts[2]; - vector<CbmStsHit*>& v_sts1 = fMapPts[3]; - - CbmStsHit* pt0=NULL; - CbmStsHit* pt1=NULL; - CbmStsHit* pt2=NULL; - - TVector3 sts0_pos, sts1_pos, sts2_pos; - int Npoints = 3; - - double x[Npoints]; - double ex[Npoints]; - double z[Npoints]; - double ez[Npoints]; - double y[Npoints]; - double ey[Npoints]; - - for(Int_t i=0; i< v_sts0.size() ; i++) - { - pt0 = (CbmStsHit*) v_sts0[i]; - pt0->Position(sts0_pos); - x[0]= sts0_pos.X()-align[0][0]; - y[0]= sts0_pos.Y()-align[1][0]; - z[0]= sts0_pos.Z(); - ex[0]= pt0->GetDx(); - ey[0]= pt0->GetDy(); - ez[0]= 0.5; - for(Int_t j=0; j< v_sts2.size() ; j++) - { - pt1 = (CbmStsHit*) v_sts2[j]; - pt1->Position(sts1_pos); - x[1]= sts1_pos.X()-align[0][1]; - y[1]= sts1_pos.Y()-align[1][1]; - z[1]= sts1_pos.Z(); - ex[1]= pt1->GetDx(); - ey[1]= pt1->GetDy(); - ez[1]= 0.5; - for(Int_t k=0; k< v_sts1.size() ; k++) - { - pt2 = (CbmStsHit*) v_sts1[k]; - pt2->Position(sts2_pos); - x[2]= sts2_pos.X()-align[0][2]; - y[2]= sts2_pos.Y()-align[1][2]; - z[2]= sts2_pos.Z(); - ex[2]= pt2->GetDx(); - ey[2]= pt2->GetDy(); - ez[2]= 0.5; - - h_xx01->Fill(x[0],x[1]); - h_xx21->Fill(x[2],x[1]); - h_xx02->Fill(x[0],x[2]); - h_yy01->Fill(y[0],y[1]); - h_yy21->Fill(y[2],y[1]); - h_yy02->Fill(y[0],y[2]); - - // Fit data numerically: - // --------------------- - TGraphErrors* graph = new TGraphErrors(Npoints,z,x,ez,ex); - TF1 *fit = new TF1("fit", "[0] + [1]*x"); - - graph->Fit("fit","Q"); - - double Chi2 = fit->GetChisquare(); - double Ndof = fit->GetNDF(); - double p0 = fit->GetParameter(0); - double p1 = fit->GetParameter(1); - double Prob = fit->GetProb(); - - h_chi2->Fill(Chi2/Ndof); - h_pchi2->Fill(Prob); - - TGraphErrors* graph1 = new TGraphErrors(Npoints,z,y,ez,ey); - TF1 *fit1 = new TF1("fit1", "[0] + [1]*x"); - graph1->Fit("fit1","Q"); - - double yChi2 = fit1->GetChisquare(); - double yNdof = fit1->GetNDF(); - double yProb = fit1->GetProb(); - double p2 = fit1->GetParameter(0); - double p3 = fit1->GetParameter(1); - - y_chi2->Fill(yChi2/yNdof); - y_pchi2->Fill(yProb); - - graph1->Delete(); - graph->Delete(); - fit->Delete(); - fit1->Delete(); - - if(Chi2/Ndof > fChi2X || yChi2/yNdof > fChi2Y)continue; - - h_resX[0]->Fill(x[0]-p0-p1*z[0]); - h_resX[1]->Fill(x[1]-p0-p1*z[1]); - h_resX[2]->Fill(x[2]-p0-p1*z[2]); - - h_resY[0]->Fill(y[0]-p2-p3*z[0]); - h_resY[1]->Fill(y[1]-p2-p3*z[1]); - h_resY[2]->Fill(y[2]-p2-p3*z[2]); - - XY[0]->Fill(x[0],y[0]); - XY[1]->Fill(x[1],y[1]); - XY[2]->Fill(x[2],y[2]); - - }//!sts2 - }//!sts1 - }//!sts0 - - return kTRUE; -} - - -void StsCosyTrack::Reset() { - fNDigis = 0; - if ( fDigiArray ) fDigiArray->Delete(); - fMapPts.clear(); -} - - -void StsCosyTrack::Finish(){ - - h_chi2->Write(); - h_pchi2->Write(); - - y_chi2->Write(); - y_pchi2->Write(); - - for(Int_t i=0;i<3;i++){h_resX[i]->Write(); h_resY[i]->Write();} - - - h_xx01->Write(); - h_xx21->Write(); - h_xx02->Write(); - - h_yy01->Write(); - h_yy21->Write(); - h_yy02->Write(); - - for(Int_t i=0;i<3;i++)XY[i]->Write(); - - // TFile *fout = FairRunAna::Instance()->GetOutputFile(); - // if (fout) fout->Write(); -} - - - - -ClassImp(StsCosyTrack) diff --git a/beamtime/cosy2014/sts/reco/cosy/StsCosyTrack.h b/beamtime/cosy2014/sts/reco/cosy/StsCosyTrack.h deleted file mode 100644 index bbc8a23379695fc87066999efdbede93d2e5abd6..0000000000000000000000000000000000000000 --- a/beamtime/cosy2014/sts/reco/cosy/StsCosyTrack.h +++ /dev/null @@ -1,79 +0,0 @@ -#ifndef STSCOSYTRACK_H -#define STSCOSYTRACK_H 1 - - -#include "FairTask.h" - -#include "TH1F.h" -#include "TH2F.h" - -#include <map> -#include <vector> - -class TClonesArray; -class CbmStsCosyPoint; -class CbmStsHit; - -class StsCosyTrack : public FairTask -{ - - public: - - StsCosyTrack(); - ~StsCosyTrack(); - virtual InitStatus Init(); - virtual void Exec(Option_t* opt); - Int_t GetEntries () { return fChain->GetEntries();} - - void SetAlignment(Bool_t mode){fAlignment = mode;} - void SetChi2Cut(Double_t chi2x, Double_t chi2y){fChi2X=chi2x;fChi2Y=chi2y;} - - private: - - Int_t fNDigis; - TClonesArray* fPointArray; //! - TClonesArray* fMCTrack; //! - TClonesArray* fDigiArray; - TClonesArray* fHits; - TChain *fChain; - - - StsCosyTrack(const StsCosyTrack&); - StsCosyTrack operator=(const StsCosyTrack&); - - void Reset(); - void Finish(); - - Bool_t FindTracks(); - Bool_t TestFit(); - - // Map for layered hits - std::map< Int_t , std::vector<CbmStsHit*> > fMapPts; //! - - TH1F* h_resX[5]; - TH1F* h_resY[5]; - TH1F* h_pullX[5]; - TH1F* h_pullY[5]; - TH1F *chi_change[3]; - - TH1F* h_chi2; - TH1F* h_pchi2; - TH1F* y_chi2; - TH1F* y_pchi2; - - TH2F * h_xx01; - TH2F * h_xx21; - TH2F * h_xx02; - TH2F * h_yy01; - TH2F * h_yy21; - TH2F * h_yy02; - TH2D * XY[5]; - - Bool_t fAlignment; - Double_t fChi2X, fChi2Y; - - ClassDef(StsCosyTrack,1); - -}; - -#endif diff --git a/beamtime/cosy2014/sts/settings/StsAlignment.cxx b/beamtime/cosy2014/sts/settings/StsAlignment.cxx deleted file mode 100644 index 7d2634602b8cb2e029a90098ebe709503ce6faae..0000000000000000000000000000000000000000 --- a/beamtime/cosy2014/sts/settings/StsAlignment.cxx +++ /dev/null @@ -1,345 +0,0 @@ -#include "StsAlignment.h" - -#include <FairTask.h> // for kSUCCESS, FairTask, InitStatus, kERROR -#include <TFile.h> // for TFile -#include <TH1.h> // for TH1F -#include <TMathBase.h> // for Abs -#include <FairLogger.h> // for LOG, Logger -#include <stdio.h> // for sprintf, NULL -#include <iostream> // for operator<<, basic_ostream, endl, cout -#include <utility> // for pair, __unwrap_reference<>::type, mak... -#include <vector> // for vector -#include "CbmStsHit.h" // for CbmStsHit -#include "CbmStsSetup.h" // for CbmStsSetup -#include <FairRootManager.h> // for FairRootManager -#include <TClonesArray.h> // for TClonesArray -#include <TF1.h> // for TF1 -#include <TGraphErrors.h> // for TGraphErrors -#include <TTree.h> // for TTree -#include <TVector3.h> // for TVector3 - -using std::cout; -using std::endl; -using std::vector; - -StsAlignment::StsAlignment() : - FairTask("StsAlignment",1), - fHits(NULL), - fChain(new TChain("cbmsim")), - fMapPts(), - fTimeLimits(), - fTimeShifts(), - resX(), - resY(), - fChi2X(1e6), - fChi2Y(1e6), - fZ(), - fdZ(), - fCutName(""), - fNofDet(3), - fEvent(0) -{ -// fChain = new TChain("cbmsim"); - fTimeLimits[0] = 16; - fTimeLimits[1] = 16; - fTimeLimits[2] = 16; - - fTimeShifts[0] = 0; - fTimeShifts[1] = -16; - fTimeShifts[2] = -16; - -/* - fEvent = 0; - - fCutName = ""; -*/ -} - -StsAlignment::~StsAlignment() -{ - if ( fHits ) { - fHits->Delete(); - delete fHits; - } -} - - -InitStatus StsAlignment::Init() { - - // Get RootManager - FairRootManager* ioman = FairRootManager::Instance(); - if ( ! ioman ) - { - LOG(fatal) << "StsAlignment::Init: noRootManager !"; - return kFATAL; - } - // Get input arrays - - fHits =(TClonesArray *) ioman->GetObject("StsHit"); - if ( ! fHits ) { - LOG(error) << "No StsHits array!"; - LOG(error) << "Task will be inactive"; - return kERROR; - } - - for(int i=0;i<fNofDet;i++) - fMapPts.insert(make_pair(i,vector<CbmStsHit*>())); - - for (Int_t i=0;i<3;i++) - { - Char_t buf[25]; - sprintf(buf,"ResX_STS%i",i); - resX[i] = new TH1F(buf,buf,400, -1,1); - - sprintf(buf,"ResY_STS%i",i); - resY[i] = new TH1F(buf,buf,400, -1,1); - } - - if(fCutName != "" ){ - LOG(info) << "Use inpute file for time cuts " << fCutName; - TFile *file_cuts = new TFile(fCutName); - - - TTree *timeHit0 = (TTree*)file_cuts ->Get("STS0-STS1"); - timeHit0->SetBranchAddress("TimeLimit",&fTimeLimits[0]); - timeHit0->SetBranchAddress("TimeShift",&fTimeShifts[0]); - timeHit0->GetEntry(0); - - TTree *timeHit1 = (TTree*)file_cuts ->Get("STS0-STS2"); - timeHit1->SetBranchAddress("TimeLimit",&fTimeLimits[1]); - timeHit1->SetBranchAddress("TimeShift",&fTimeShifts[1]); - timeHit1->GetEntry(0); - - TTree *timeHit2 = (TTree*)file_cuts ->Get("STS2-STS1"); - timeHit2->SetBranchAddress("TimeLimit",&fTimeLimits[2]); - timeHit2->SetBranchAddress("TimeShift",&fTimeShifts[2]); - timeHit2->GetEntry(0); - } - - - cout << "-I- StsAlignment: Intialisation successfull " << kSUCCESS<< endl; - return kSUCCESS; - -} - -// ----- Public method Exec -------------------------------------------- -void StsAlignment::Exec(Option_t*) { - - Reset(); - - if(fEvent%100000 == 0)cout << "----- " << fEvent << endl; - - - CbmStsHit* hit = NULL; - - Int_t nofHits = fHits->GetEntries(); - - // Loop over hits - for (Int_t iHit=0; iHit<nofHits; iHit++) - { - hit = (CbmStsHit*) fHits->At(iHit); - - Int_t detId = CbmStsSetup::Instance()->GetStationNumber(hit->GetAddress()); - vector<CbmStsHit*>& vlist = fMapPts[detId]; - vlist.push_back((CbmStsHit*) hit); - } - - // Find the tracks - FindTracks(); - - fEvent++; -} - - -Bool_t StsAlignment::FindTracks(){ - - // Check the content per detector - for (int idet=0; idet<fNofDet;idet++) - { - // get the vector - vector<CbmStsHit*>& v = fMapPts[idet]; - // select at least 1 points per detector - if (v.size()==0) return kFALSE; - } - - vector<CbmStsHit*>& v_sts0 = fMapPts[0]; - vector<CbmStsHit*>& v_sts1 = fMapPts[1]; - vector<CbmStsHit*>& v_sts2 = fMapPts[2]; - - CbmStsHit* pt0=NULL; - CbmStsHit* pt1=NULL; - CbmStsHit* pt2=NULL; - - - TVector3 sts0_pos, sts1_pos, sts2_pos; - int Npoints = fNofDet; - - double x[Npoints]; - double ex[Npoints]; - double z[Npoints]; - double ez[Npoints]; - double y[Npoints]; - double ey[Npoints]; - - - for(UInt_t i=0; i< v_sts0.size() ; i++) // STS1 @ Cosy2014 - { - pt0 = (CbmStsHit*) v_sts0[i]; - pt0->Position(sts0_pos); - x[0]= sts0_pos.X(); - y[0]= sts0_pos.Y(); - z[0]= sts0_pos.Z(); - ex[0]= pt0->GetDx(); - ey[0]= pt0->GetDy(); - ez[0]= 0.5; - fZ[0] = z[0]; - fdZ[0] = ez[0]; - - for(UInt_t j=0; j< v_sts1.size() ; j++) // STS3 @ Cosy2014 - { - pt1 = (CbmStsHit*) v_sts1[j]; - if(TMath::Abs(pt0->GetTime()-pt1->GetTime() - fTimeShifts[0])>fTimeLimits[0])continue; - - pt1->Position(sts1_pos); - x[1]= sts1_pos.X(); - y[1]= sts1_pos.Y(); - z[1]= sts1_pos.Z(); - ex[1]= pt1->GetDx(); - ey[1]= pt1->GetDy(); - ez[1]= 0.5; - fZ[1] = z[1]; - fdZ[1] = ez[1]; - - for(UInt_t k=0; k< v_sts2.size() ; k++) // STS0 @ Cosy2014 - { - pt2 = (CbmStsHit*) v_sts2[k]; - if(TMath::Abs(pt0->GetTime()-pt2->GetTime()- fTimeShifts[1])>fTimeLimits[1])continue; - if(TMath::Abs(pt2->GetTime()-pt1->GetTime()- fTimeShifts[2])>fTimeLimits[2])continue; - - pt2->Position(sts2_pos); - x[2]= sts2_pos.X(); - y[2]= sts2_pos.Y(); - z[2]= sts2_pos.Z(); - ex[2]= pt2->GetDx(); - ey[2]= pt2->GetDy(); - ez[2]= 0.5; - fZ[2] = z[2]; - fdZ[2] = ez[2]; - - // Fit data numerically: - // --------------------- - TGraphErrors* graph; - TGraphErrors* graph1; - graph = new TGraphErrors(Npoints,z,x,ez,ex); - - TF1 *fit = new TF1("fit", "pol1"); - graph->Fit("fit","QME"); - - double xChi2 = fit->GetChisquare(); - double xNdof = fit->GetNDF(); - double p0 = fit->GetParameter(0); - double p1 = fit->GetParameter(1); - - graph1 = new TGraphErrors(Npoints,z,y,ez,ey); - - TF1 *fit1 = new TF1("fit1", "pol1"); - graph1->Fit("fit1","QME"); - - double yChi2 = fit1->GetChisquare(); - double yNdof = fit1->GetNDF(); - double p2 = fit1->GetParameter(0); - double p3 = fit1->GetParameter(1); - - graph1->Delete(); - graph->Delete(); - fit->Delete(); - fit1->Delete(); - - if(xChi2/xNdof > fChi2X || yChi2/yNdof > fChi2Y)continue; - for(int m=0; m<Npoints; m++) - { - resX[m]->Fill(x[m]-p0-p1*z[m]); - resY[m]->Fill(y[m]-p2-p3*z[m]); - } - }//!sts1 //STS0 @ Cosy2014 - }//!sts2 //STS3 @ Cosy2014 - }//!sts0 //STS1 @ Cosy2014 - - return kTRUE; -} - -void StsAlignment::Reset() { - fMapPts.clear(); -} - - -void StsAlignment::Finish(){ - - Double_t X[3], Y[3]; - Double_t dX[3], dY[3]; - - // Fit residuals - -for(Int_t i=0;i<3;i++) - { - TF1 *fitX = new TF1("fitX", "gaus"); - resX[i]->Fit("fitX","QME"); - X[i] = fitX->GetParameter(1); - dX[i] = fitX->GetParameter(2); - fitX->Delete(); - - TF1 *fitY = new TF1("fitY", "gaus"); - resY[i]->Fit("fitY","QME"); - Y[i] = fitY->GetParameter(1); - dY[i] = fitY->GetParameter(2); - fitY->Delete(); - } - - // Calculate alignment parameters - LOG(info); - LOG(info) << "====================================================="; - LOG(info) << GetName() << ": Finish. Calculate alignment parameters"; - LOG(info) << "====================================================="; - LOG(info); - -TF1 *fitX = new TF1("fitX", "pol1"); -TF1 *fitY = new TF1("fitY", "pol1"); -TGraphErrors* graphX = new TGraphErrors(3,fZ, X, fdZ, dX); -TGraphErrors* graphY = new TGraphErrors(3,fZ, Y, fdZ, dY); -graphX->Fit("fitX", "QEM"); -graphY->Fit("fitY", "QEM"); - - -Double_t X0=X[0]-fitX->GetParameter(0)-fitX->GetParameter(1)*fZ[0]; -Double_t X1=X[1]-fitX->GetParameter(0)-fitX->GetParameter(1)*fZ[1]; -Double_t X2=X[2]-fitX->GetParameter(0)-fitX->GetParameter(1)*fZ[2]; - -Double_t Y0=Y[0]-fitY->GetParameter(0)-fitY->GetParameter(1)*fZ[0]; -Double_t Y1=Y[1]-fitY->GetParameter(0)-fitY->GetParameter(1)*fZ[1]; -Double_t Y2=Y[2]-fitY->GetParameter(0)-fitY->GetParameter(1)*fZ[2]; - -TTree * data = new TTree("Alignment", "Alignment"); - data->Branch("dX0", &X0, "X0/D"); - data->Branch("dX1", &X1, "X1/D"); - data->Branch("dX2", &X2, "X2/D"); - - data->Branch("dY0", &Y0, "Y0/D"); - data->Branch("dY1", &Y1, "Y1/D"); - data->Branch("dY2", &Y2, "Y2/D"); - - data->Fill(); - data->Write(); - - for(Int_t i=0;i<3;i++){resX[i]->Write(); resY[i]->Write();} - - LOG(info); - LOG(info) << "====================================================="; - LOG(info) << GetName() << ": Finish"; - LOG(info) << "====================================================="; - LOG(info); -} - - - - -ClassImp(StsAlignment) diff --git a/beamtime/cosy2014/sts/settings/StsAlignment.h b/beamtime/cosy2014/sts/settings/StsAlignment.h deleted file mode 100644 index 9ea34f20978b135a51333813863ecb2b713e4ed0..0000000000000000000000000000000000000000 --- a/beamtime/cosy2014/sts/settings/StsAlignment.h +++ /dev/null @@ -1,78 +0,0 @@ -/** StsAlignment.h - *@author Anna Senger <a.senger@gsi.de> - ** - ** Task to calculate alignment parameters. - **/ - -#ifndef STSALIGNMENT_H -#define STSALIGNMENT_H 1 - -#include <Rtypes.h> // for ClassDef -#include <RtypesCore.h> // for Double_t, Int_t, Bool_t, Option_t -#include <TChain.h> // for TChain -#include <TString.h> // for TString -#include <map> // for map -#include <vector> // for vector -#include <FairTask.h> // for FairTask, InitStatus - -#include "TH1.h" // for RootCling - -class CbmStsHit; -class TClonesArray; - - -class StsAlignment : public FairTask -{ - - public: - - StsAlignment(); - ~StsAlignment(); - virtual InitStatus Init(); - virtual void Exec(Option_t* opt); - Int_t GetEntries () { return fChain->GetEntries();} - - void SetCutFileName(TString name){fCutName = name;} - - void SetChi2Cut(Double_t chi2x, Double_t chi2y){fChi2X=chi2x;fChi2Y=chi2y;} - void SetNofDetectors(Int_t NofD){fNofDet=NofD;} - void SetTimeLimit(Double_t time[3]) { for(int i=0; i<3; i++)fTimeLimits[i]=time[i]; } - void SetTimeShift(Double_t time[3]) { for(int i=0; i<3; i++)fTimeShifts[i]=time[i]; } - - private: - - TClonesArray* fHits; - TChain *fChain; - - - StsAlignment(const StsAlignment&); - StsAlignment operator=(const StsAlignment&); - - void Reset(); - void Finish(); - - Bool_t FindTracks(); - - // Map for layered hits - std::map< Int_t , std::vector<CbmStsHit*> > fMapPts; //! - - Double_t fTimeLimits[3]; - Double_t fTimeShifts[3]; - - TH1F* resX[3]; - TH1F* resY[3]; - - Double_t fChi2X, fChi2Y; - Double_t fZ[3]; - Double_t fdZ[3]; - - TString fCutName; - - Int_t fNofDet; - Int_t fEvent; - - ClassDef(StsAlignment,1); - -}; - -#endif diff --git a/beamtime/cosy2014/sts/settings/StsClusterSet.cxx b/beamtime/cosy2014/sts/settings/StsClusterSet.cxx deleted file mode 100755 index 362caa906749c07b59c54dceb324b35db5a74a82..0000000000000000000000000000000000000000 --- a/beamtime/cosy2014/sts/settings/StsClusterSet.cxx +++ /dev/null @@ -1,253 +0,0 @@ -#include "StsClusterSet.h" - -#include <FairTask.h> // for InitStatus, kSUCCESS, FairTask, kERROR -#include <TH1.h> // for TH1F -#include <TTree.h> // for TTree -#include <FairLogger.h> // for LOG -#include <stdio.h> // for sprintf, NULL -#include <iostream> // for operator<<, basic_ostream, endl, cout -#include "CbmStsAddress.h" // for GetElementId, kStsSide -#include "CbmStsDigi.h" // for CbmStsDigi -#include "CbmStsSetup.h" // for CbmStsSetup -#include <FairRootManager.h> // for FairRootManager -#include <TClonesArray.h> // for TClonesArray -#include <TF1.h> // for TF1 -#include "CbmDigiManager.h" - -using std::map; -using std::set; -using namespace std; - -// ---- Default constructor ------------------------------------------- -StsClusterSet::StsClusterSet() - :FairTask("StsClusterSet",1), - time_diff_strips(), - cluster_adc(), - fChargeMinStrip(), - fChargeMaxStrip(), - fDigiMap(), - fEvent(0) -{ - for(int i=0; i<3; i++) - { - fChargeMinStrip[i]= 50.; - fChargeMaxStrip[i]= 500.; - } -} -// -------------------------------------------------------------------- - -// ---- Destructor ---------------------------------------------------- -StsClusterSet::~StsClusterSet() -{ - -} - -// ---- Initialisation ---------------------------------------------- -void StsClusterSet::SetParContainers() -{ - - // Get Base Container -/* - FairRunAna* ana = FairRunAna::Instance(); - FairRuntimeDb* rtdb=ana->GetRuntimeDb(); -*/ -} -// -------------------------------------------------------------------- - -// ---- ReInit ------------------------------------------------------- -InitStatus StsClusterSet::ReInit(){ - -/* - FairRunAna* ana = FairRunAna::Instance(); - FairRuntimeDb* rtdb=ana->GetRuntimeDb(); -*/ - - return kSUCCESS; -} -// -------------------------------------------------------------------- - -// ---- Init ---------------------------------------------------------- -InitStatus StsClusterSet::Init() -{ - -// FairRootManager *ioman = FairRootManager::Instance(); - - fDigiMan = CbmDigiManager::Instance(); - fDigiMan->Init(); - if ( ! fDigiMan->IsPresent(ECbmModuleId::kSts) ) { - LOG(error) << "No StsDigi array!"; - LOG(error) << "Task will be inactive"; - return kERROR; - } - - // Time differences between strips - time cut cluster building - - for(int i =0; i<3;i++) - { - Char_t inName[200]; - sprintf(inName,"strips_time_diff_STS%i",i); - time_diff_strips[i] = new TH1F(inName, inName, 1000, -1000, 1000); - for(int ii =0; ii<2;ii++) - { - sprintf(inName,"cluster_charge_STS%i_side%i",i,ii); - cluster_adc[i][ii] = new TH1F(inName, inName, 1000, 0, 1000); - } - } - - fEvent = 0; - - return kSUCCESS; - -} -// -------------------------------------------------------------------- - -// ---- Exec ---------------------------------------------------------- -void StsClusterSet::Exec(Option_t*) -{ - - if(fEvent%100000 == 0)cout << "----- " << fEvent << endl; - - for (auto mapIt=fDigiMap.begin(); mapIt!=fDigiMap.end(); mapIt++) - { - ((*mapIt).second).clear(); - } - fDigiMap.clear(); - - set<Int_t> layerSet; - - const CbmStsDigi* digi = NULL; -// CbmStsDigi* digi2 = NULL; - - map<const CbmStsDigi*, Int_t> fIndices; - - Int_t nofDigis = fDigiMan->GetNofDigis(ECbmModuleId::kSts); - - for (Int_t iDigi=0; iDigi < nofDigis; iDigi++ ) - { - digi = fDigiMan->Get<CbmStsDigi>(iDigi); - int station = CbmStsSetup::Instance()->GetStationNumber(digi->GetAddress()); - int side = CbmStsAddress::GetElementId(digi->GetAddress(),kStsSide); - Int_t layer= 2*station+side; - - if(digi->GetCharge() > fChargeMinStrip[station] && digi->GetCharge() < fChargeMaxStrip[station]) - { - layerSet.insert(layer); - fDigiMap[layer].insert(digi); - fIndices[digi]=iDigi; - } - } - - set <const CbmStsDigi*, classcomp2> digiSet; - - for (set<Int_t>::iterator i = layerSet.begin(); i != layerSet.end(); i++) - { - digiSet = fDigiMap[*i]; - Bool_t newCluster = kTRUE; - Bool_t Cluster = kFALSE; - Int_t stripNr = -1; - Int_t stripNrPrev = -1; -// Int_t cluster_size =0; - Double_t time = -1; - Double_t timePrev = -1; - Double_t sumW = 0; - int station = -1; - int side = -1; - for (set<const CbmStsDigi*, classcomp2>::iterator j = digiSet.begin(); j != digiSet.end(); j++) - { - if (newCluster) - { - Int_t index = fIndices[(*j)]; - //----time---- - digi = fDigiMan->Get<CbmStsDigi>(index); - timePrev = digi->GetTime(); - stripNrPrev = (*j)->GetChannel(); - sumW = digi->GetCharge(); - newCluster = kFALSE; - } - else - { - Int_t index = fIndices[(*j)]; - digi = fDigiMan->Get<CbmStsDigi>(index); - time = digi->GetTime(); - stripNr = (*j)->GetChannel(); - station = CbmStsSetup::Instance()->GetStationNumber(digi->GetAddress()); - side = CbmStsAddress::GetElementId(digi->GetAddress(),kStsSide); - - if(1 == stripNr-stripNrPrev) - { - time_diff_strips[station]->Fill(time - timePrev); - sumW += digi->GetCharge(); - Cluster = kTRUE; - } - } - } - if(station < 0 || side < 0)continue; - if(Cluster || (!newCluster && !Cluster))cluster_adc[station][side]->Fill(sumW); - } - - fEvent++; - - -} -// -------------------------------------------------------------------- - - // ---- Finish -------------------------------------------------------- - void StsClusterSet::Finish() - { - - Double_t dT0, dT1, dT2; - Double_t T0, T1, T2; - - // Fit residuals - -for(Int_t i=0;i<3;i++) - { - TF1 *fit = new TF1("fit", "gaus"); - time_diff_strips[i]->Fit("fit","QME"); - - if(i==0){ - T0 = fit->GetParameter(1); - dT0 = fit->GetParameter(2)*2.;} - else if(i==1){ - T1 = fit->GetParameter(1); - dT1 = fit->GetParameter(2)*2.;} - else { - T2 = fit->GetParameter(1); - dT2 = fit->GetParameter(2)*2.;} - - fit->Delete(); - } - - TTree * sts0 = new TTree("STS0","STS0"); - - sts0->Branch("TimeLimit", &dT0, "dT0/D"); - sts0->Branch("TimeShift", &T0, "T0/D"); - - sts0->Fill(); - sts0->Write(); - - TTree * sts1 = new TTree("STS1","STS1"); - - sts1->Branch("TimeLimit", &dT1, "dT1/D"); - sts1->Branch("TimeShift", &T1, "T1/D"); - - sts1->Fill(); - sts1->Write(); - - TTree * sts2 = new TTree("STS2","STS2"); - - sts2->Branch("TimeLimit", &dT2, "dT2/D"); - sts2->Branch("TimeShift", &T2, "T2/D"); - - sts2->Fill(); - sts2->Write(); - - for(int i =0; i<3;i++) - time_diff_strips[i]->Write(); - for(int i=0; i<3; i++)for(int j=0; j<2; j++)cluster_adc[i][j]->Write(); - - - } - - ClassImp(StsClusterSet) - diff --git a/beamtime/cosy2014/sts/settings/StsClusterSet.h b/beamtime/cosy2014/sts/settings/StsClusterSet.h deleted file mode 100644 index 54a67be61c5fe33a8c215c96018ad933230dff7c..0000000000000000000000000000000000000000 --- a/beamtime/cosy2014/sts/settings/StsClusterSet.h +++ /dev/null @@ -1,77 +0,0 @@ -/** StsClusterSet.h - *@author Anna Senger <a.senger@gsi.de> - ** - ** Task to calculate time differences for the cluster building. - **/ - -#ifndef STSCLUSTERSET_H -#define STSCLUSTERSET_H - -#include <Rtypes.h> // for ClassDef -#include <RtypesCore.h> // for Double_t, Int_t, Option_t -#include <map> // for map -#include <set> // for set -#include "CbmStsDigi.h" // for CbmStsDigi -#include <FairTask.h> // for InitStatus, FairTask - -#include "TH1.h" // for RootCling -#include "TClonesArray.h"//for RootCling - -class CbmDigiManager; - -struct classcomp2 { - bool operator() (const CbmStsDigi* lhs, const CbmStsDigi* rhs) const - {return lhs->GetChannel() < rhs->GetChannel();} -}; - -class StsClusterSet : public FairTask -{ - - public: - - /** - * Default constructor. - */ - StsClusterSet(); - - /** - * Default destructor. - */ - ~StsClusterSet(); - - /** Initialisation **/ - virtual InitStatus ReInit(); - virtual InitStatus Init(); - virtual void SetParContainers(); - - /** Executed task **/ - virtual void Exec(Option_t * option); - - /** Selection of the strips with signal charge **/ - void SetChargeLimitsStrip(Double_t min[3], Double_t max[3]) { for(int i=0; i<3; i++){fChargeMinStrip[i] = min[i]; fChargeMaxStrip[i] = max[i];} } - - /** Finish task **/ - virtual void Finish(); - - private: - - CbmDigiManager* fDigiMan = nullptr; //! - - TH1F *time_diff_strips[3]; - TH1F* cluster_adc[3][2]; //! - - - Double_t fChargeMinStrip[3]; - Double_t fChargeMaxStrip[3]; - - std::map<Int_t, std::set<const CbmStsDigi*, classcomp2> > fDigiMap; //! /** digis per hodo layer **/ - - Int_t fEvent; - - StsClusterSet(const StsClusterSet&); - StsClusterSet& operator=(const StsClusterSet&); - - ClassDef(StsClusterSet,1); - -}; -#endif diff --git a/beamtime/cosy2014/sts/settings/StsHitSet.cxx b/beamtime/cosy2014/sts/settings/StsHitSet.cxx deleted file mode 100755 index e3d886c795ddd52964968ab84867a34c0c064595..0000000000000000000000000000000000000000 --- a/beamtime/cosy2014/sts/settings/StsHitSet.cxx +++ /dev/null @@ -1,262 +0,0 @@ -#include "StsHitSet.h" - -#include <FairTask.h> // for InitStatus, kSUCCESS, FairTask, kERROR -#include <TH1.h> // for TH1F -#include <TTree.h> // for TTree -#include <FairLogger.h> // for LOG -#include <stdio.h> // for sprintf, NULL -#include <iostream> // for operator<<, basic_ostream, endl, cout -#include <map> // for map -#include <set> // for set -#include <vector> // for vector -#include "CbmStsAddress.h" // for GetElementId, kStsSide -#include "CbmStsCluster.h" // for CbmStsCluster -#include "CbmStsSetup.h" // for CbmStsSetup -#include <FairRootManager.h> // for FairRootManager -#include <TClonesArray.h> // for TClonesArray -#include <TF1.h> // for TF1 - -using std::map; -using std::set; -using namespace std; - -// ---- Default constructor ------------------------------------------- -StsHitSet::StsHitSet() - :FairTask("StsHitSet",1), - stsClusters(NULL), - fChain(new TChain("cbmsim")), - sts_time_diff(), - cluster_time_diff(), - fEvent(0) -{ -// fChain = new TChain("cbmsim"); - // outFile=NULL; -} -// -------------------------------------------------------------------- - -// ---- Destructor ---------------------------------------------------- -StsHitSet::~StsHitSet() -{ - if(stsClusters){ - stsClusters->Clear("C"); - stsClusters->Delete(); - delete stsClusters; - - } -} - -// ---- Initialisation ---------------------------------------------- -void StsHitSet::SetParContainers() -{ - - // Get Base Container -/* - FairRunAna* ana = FairRunAna::Instance(); - FairRuntimeDb* rtdb=ana->GetRuntimeDb(); -*/ -} -// -------------------------------------------------------------------- - -// ---- ReInit ------------------------------------------------------- -InitStatus StsHitSet::ReInit(){ - -/* - FairRunAna* ana = FairRunAna::Instance(); - FairRuntimeDb* rtdb=ana->GetRuntimeDb(); -*/ - return kSUCCESS; -} -// -------------------------------------------------------------------- - -// ---- Init ---------------------------------------------------------- -InitStatus StsHitSet::Init() -{ - - FairRootManager *ioman = FairRootManager::Instance(); - - stsClusters =(TClonesArray *) ioman->GetObject("StsCluster"); - if ( !stsClusters ) { - LOG(error) << "No StsCluster array!"; - LOG(error) << "Task will be inactive"; - return kERROR; - } - - // Time differences between p and n side - time cut setting for hit building - -for (Int_t i=0;i<3;i++) - { - Char_t buf[25]; - sprintf(buf,"cluster_time_diff_STS%i",i); - cluster_time_diff[i]= new TH1F(buf, buf, 400, -1000, 1000); - } - - // Time differences between hits in different sensors - for hit selection from the same event - - sts_time_diff[0] = (TH1F*)cluster_time_diff[0]->Clone("time_diff_between_STS01"); - sts_time_diff[0]->SetTitle("time_diff_between_STS01"); - - sts_time_diff[1] = (TH1F*)cluster_time_diff[0]->Clone("time_diff_between_STS02"); - sts_time_diff[1]->SetTitle("time_diff_between_STS02"); - - sts_time_diff[2] = (TH1F*)cluster_time_diff[0]->Clone("time_diff_between_STS21"); - sts_time_diff[2]->SetTitle("time_diff_between_STS21"); - - fEvent = 0; - - return kSUCCESS; - -} -// -------------------------------------------------------------------- - -// ---- Exec ---------------------------------------------------------- -void StsHitSet::Exec(Option_t*) -{ - - if(fEvent%100000 == 0)cout << "----- " << fEvent << endl; - - Int_t nofSTSClusters = stsClusters->GetEntries(); - - vector<double> sts_0, sts_1, sts_2; - - for (Int_t i = 0; i < nofSTSClusters; i++) - { -// int layer =-1; - const CbmStsCluster* cluster = static_cast<const CbmStsCluster*>(stsClusters->At(i)); - int station = CbmStsSetup::Instance()->GetStationNumber(cluster->GetAddress()); - int side = CbmStsAddress::GetElementId(cluster->GetAddress(),kStsSide); - if(side==1)continue; - - Double_t front_time = cluster->GetTime(); - for (Int_t j = 0; j < nofSTSClusters; j++) - { - if(i==j)continue; - - const CbmStsCluster* cluster2 = static_cast<const CbmStsCluster*>(stsClusters->At(j)); - int station2 = CbmStsSetup::Instance()->GetStationNumber(cluster2->GetAddress()); - if(station != station2)continue; - - int side2 = CbmStsAddress::GetElementId(cluster2->GetAddress(),kStsSide); - if(side2 == side)continue; - - Double_t back_time = cluster2->GetTime(); - cluster_time_diff[station]->Fill(back_time-front_time); - Double_t Cluster_time = (back_time + front_time)/2.; - if(station==0)sts_0.push_back(Cluster_time); - else if(station==1)sts_1.push_back(Cluster_time); - else if(station==2)sts_2.push_back(Cluster_time); - } - } - for(UInt_t i=0; i<sts_0.size(); i++) - { - Double_t time0 = sts_0[i]; - for(UInt_t j=0; j<sts_1.size(); j++) - { - Double_t time1 = sts_1[j]; - sts_time_diff[0]->Fill(time0-time1); - } - for(UInt_t j=0; j<sts_2.size(); j++) - { - Double_t time1 = sts_2[j]; - sts_time_diff[1]->Fill(time0-time1); - } - } - for(UInt_t i=0; i<sts_2.size(); i++) - { - Double_t time0 = sts_2[i]; - for(UInt_t j=0; j<sts_1.size(); j++) - { - Double_t time1 = sts_1[j]; - sts_time_diff[2]->Fill(time0-time1); - } - } - - stsClusters->Clear(); - - fEvent++; - -} -// -------------------------------------------------------------------- - - // ---- Finish -------------------------------------------------------- - void StsHitSet::Finish() - { - - Double_t dT[3], dT0, dT1, dT2; - Double_t T[3], T0, T1, T2; - -for(Int_t i=0;i<3;i++) - { - TF1 *fit = new TF1("fit", "gaus"); - cluster_time_diff[i]->Fit("fit","QME"); - T[i] = fit->GetParameter(1); - dT[i] = fit->GetParameter(2)*2.; - - fit->Delete(); - } - - TTree * timeCluster = new TTree("Cluster cuts","Cluster cuts"); - - timeCluster->Branch("TimeLimit", dT, "dT[3]/D"); - timeCluster->Branch("TimeShift", T, "T[3]/D"); - - timeCluster->Fill(); - timeCluster->Write(); - -for(Int_t i=0;i<3;i++) - { - TF1 *fit = new TF1("fit", "gaus"); - sts_time_diff[i]->Fit("fit","QME"); - - if(i==0) - { - T0 = fit->GetParameter(1); - dT0 = fit->GetParameter(2)*2.;} - else if(i==1) - { - T1 = fit->GetParameter(1); - dT1 = fit->GetParameter(2)*2.;} - else - { - T2 = fit->GetParameter(1); - dT2 = fit->GetParameter(2)*2.;} - - fit->Delete(); - } - - TTree * timeHit0 = new TTree("STS0-STS1","STS0-STS1"); - - timeHit0->Branch("TimeLimit", &dT0, "dT0/D"); - timeHit0->Branch("TimeShift", &T0, "T0/D"); - - timeHit0->Fill(); - timeHit0->Write(); - - TTree * timeHit1 = new TTree("STS0-STS2","STS0-STS2"); - - timeHit1->Branch("TimeLimit", &dT1, "dT1/D"); - timeHit1->Branch("TimeShift", &T1, "T1/D"); - - timeHit1->Fill(); - timeHit1->Write(); - - TTree * timeHit2 = new TTree("STS2-STS1","STS2-STS1"); - - timeHit2->Branch("TimeLimit", &dT2, "dT2/D"); - timeHit2->Branch("TimeShift", &T2, "T2/D"); - - timeHit2->Fill(); - timeHit2->Write(); - - - - for(int i=0; i<3; i++)cluster_time_diff[i]->Write(); - for(int i=0; i<3; i++)sts_time_diff[i]->Write(); - - } - - - - - - ClassImp(StsHitSet) - diff --git a/beamtime/cosy2014/sts/settings/StsHitSet.h b/beamtime/cosy2014/sts/settings/StsHitSet.h deleted file mode 100755 index b7882f11112f7657a57a69264443cf32a653bbe0..0000000000000000000000000000000000000000 --- a/beamtime/cosy2014/sts/settings/StsHitSet.h +++ /dev/null @@ -1,62 +0,0 @@ -/** StsHitSet.h - *@author Anna Senger <a.senger@gsi.de> - ** - ** Task to calculate sets for the hit building. - **/ - -#ifndef STSHITSET_H -#define STSHITSET_H - -#include <Rtypes.h> // for ClassDef -#include <RtypesCore.h> // for Int_t, Option_t -#include <TChain.h> // for TChain -#include <FairTask.h> // for InitStatus, FairTask - -#include "TH1.h" // for RootCling - -class TClonesArray; - -class StsHitSet : public FairTask -{ - - public: - - /** - * Default constructor. - */ - StsHitSet(); - - /** - * Default destructor. - */ - ~StsHitSet(); - - /** Initialisation **/ - virtual InitStatus ReInit(); - virtual InitStatus Init(); - virtual void SetParContainers(); - - /** Executed task **/ - virtual void Exec(Option_t * option); - Int_t GetEntries () { return fChain->GetEntries();} - - /** Finish task **/ - virtual void Finish(); - - private: - - TClonesArray* stsClusters; /** Input array of CbmStsCluster **/ - - TChain *fChain; - - TH1F *sts_time_diff[3]; - TH1F *cluster_time_diff[3]; - - StsHitSet(const StsHitSet&); - StsHitSet& operator=(const StsHitSet&); - Int_t fEvent; - - ClassDef(StsHitSet,1); - -}; -#endif diff --git a/beamtime/cosy2014/unpacker/CbmROCUnpackAux.cxx b/beamtime/cosy2014/unpacker/CbmROCUnpackAux.cxx deleted file mode 100644 index 306b1c4deb668b3de5105f600ac96cfaf3b0cb2e..0000000000000000000000000000000000000000 --- a/beamtime/cosy2014/unpacker/CbmROCUnpackAux.cxx +++ /dev/null @@ -1,87 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmROCUnpackAux ----- -// ----- Created 14.12.2014 by F. Uhlig ----- -// ----- ----- -// ----------------------------------------------------------------------------- -#include "CbmROCUnpackAux.h" - -#include <FairRootManager.h> // for FairRootManager -#include <stddef.h> // for NULL -#include "CbmAuxDigi.h" // for CbmAuxDigi -#include "CbmSourceLmdNew.h" // for CbmSourceLmdNew -#include "CbmTbDaqBuffer.h" // for CbmTbDaqBuffer -#include <FairRunOnline.h> // for FairRunOnline -#include <TClonesArray.h> // for TClonesArray -#include "roc/Message.h" // for Message -#include <boost/any.hpp> - -using boost::any_cast; - -CbmROCUnpackAux::CbmROCUnpackAux() - : CbmROCUnpack(), - fSource(nullptr), - fBuffer(CbmTbDaqBuffer::Instance()), - fAuxDigis(nullptr) -{ -} - -CbmROCUnpackAux::~CbmROCUnpackAux() -{ -} - - -Bool_t CbmROCUnpackAux::Init() -{ - FairRunOnline* online = FairRunOnline::Instance(); - fSource = static_cast<CbmSourceLmdNew*>(online->GetSource()); - -// FairRootManager* ioman = FairRootManager::Instance(); - - fAuxDigis = RegisterOutput<CbmAuxDigi>("AuxDigi"); -// ioman->Register("AuxDigi", "AUX data", fAuxDigis, fPersistence); - - return kTRUE; - -} - -Bool_t CbmROCUnpackAux::DoUnpack(roc::Message* Message, ULong_t hitTime) -{ - if (!fSource->IsBaselineFill()) { - // --- ROC Id and channel number - Int_t rocId = Message->getRocNumber(); - Int_t channel = Message->getAuxChNum(); - - fSource->CheckCurrentEpoch(rocId); - ULong_t offset = fSource->GetAuxOffset(); - - // --- Create AuxDigi and send it to the buffer - CbmAuxDigi* digi = new CbmAuxDigi(rocId, channel, hitTime + offset); - fBuffer->InsertData<CbmAuxDigi>(digi); - } else { - fSource->AddDiscardedAux(); - } - - return kTRUE; -} - -void CbmROCUnpackAux::FillOutput(boost::any _digi) -{ - CbmAuxDigi* digi = boost::any_cast<CbmAuxDigi*>(_digi); -/* - new( (*fAuxDigis)[fAuxDigis->GetEntriesFast()]) - CbmAuxDigi(*(boost::any_cast<CbmAuxDigi*>(digi))); -*/ - fAuxDigis->emplace_back(*(digi)); - - delete digi; -} - - -void CbmROCUnpackAux::Reset() -{ -// fAuxDigis->Clear(); - fAuxDigis->clear(); -} - -ClassImp(CbmROCUnpackAux) diff --git a/beamtime/cosy2014/unpacker/CbmROCUnpackAux.h b/beamtime/cosy2014/unpacker/CbmROCUnpackAux.h deleted file mode 100644 index b9e006629208b7cd0578e3b40546215ba6541c1f..0000000000000000000000000000000000000000 --- a/beamtime/cosy2014/unpacker/CbmROCUnpackAux.h +++ /dev/null @@ -1,48 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmROCUnpackAux ----- -// ----- Created 14.12.2014 by F. Uhlig ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CBMROCUNPACKAUX_H -#define CBMROCUNPACKAUX_H - -#include <Rtypes.h> // for THashConsistencyHolder, ClassDef -#include <RtypesCore.h> // for Bool_t, ULong_t -#include "CbmROCUnpack.h" // for CbmROCUnpack -#include <boost/any.hpp> -#include <vector> -#include "CbmAuxDigi.h" - -class CbmSourceLmdNew; -class CbmTbDaqBuffer; - -namespace roc { class Message; } - -class CbmROCUnpackAux : public CbmROCUnpack -{ - public: - - CbmROCUnpackAux(); - virtual ~CbmROCUnpackAux(); - - virtual Bool_t Init(); - virtual Bool_t DoUnpack(roc::Message* Message, ULong_t hitTime); - virtual void FillOutput(boost::any); - virtual void Reset(); - virtual void Finish() {;} - - private: - - CbmSourceLmdNew* fSource; - CbmTbDaqBuffer* fBuffer; - std::vector<CbmAuxDigi>* fAuxDigis; ///< Output array of CbmAuxDigi - - CbmROCUnpackAux(const CbmROCUnpackAux&); - CbmROCUnpackAux& operator=(const CbmROCUnpackAux&); - - ClassDef(CbmROCUnpackAux, 2) -}; - -#endif diff --git a/beamtime/cosy2014/unpacker/CbmROCUnpackDummy.cxx b/beamtime/cosy2014/unpacker/CbmROCUnpackDummy.cxx deleted file mode 100644 index 81190301494a3e9b6643a165117f95c899fb525f..0000000000000000000000000000000000000000 --- a/beamtime/cosy2014/unpacker/CbmROCUnpackDummy.cxx +++ /dev/null @@ -1,35 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmROCUnpackDummy ----- -// ----- Created 14.12.2014 by F. Uhlig ----- -// ----- ----- -// ----------------------------------------------------------------------------- -#include "CbmROCUnpackDummy.h" - -namespace roc { class Message; } - -CbmROCUnpackDummy::CbmROCUnpackDummy() - : CbmROCUnpack() -{ -} - -CbmROCUnpackDummy::~CbmROCUnpackDummy() -{ -} - - -Bool_t CbmROCUnpackDummy::Init() -{ - return kTRUE; -} - -Bool_t CbmROCUnpackDummy::DoUnpack(roc::Message* /*Message*/, ULong_t /*hitTime*/) -{ - return kTRUE; -} - -void CbmROCUnpackDummy::Reset() -{ -} - -ClassImp(CbmROCUnpackDummy) diff --git a/beamtime/cosy2014/unpacker/CbmROCUnpackDummy.h b/beamtime/cosy2014/unpacker/CbmROCUnpackDummy.h deleted file mode 100644 index 579cac7da27cec9e824f2a4560e6845a4da2a4a1..0000000000000000000000000000000000000000 --- a/beamtime/cosy2014/unpacker/CbmROCUnpackDummy.h +++ /dev/null @@ -1,36 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmROCUnpackDummy ----- -// ----- Created 14.12.2014 by F. Uhlig ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CBMROCUNPACKDUMMY_H -#define CBMROCUNPACKDUMMY_H - -#include <Rtypes.h> // for ClassDef -#include <RtypesCore.h> // for Bool_t, ULong_t -#include "CbmROCUnpack.h" // for CbmROCUnpack -#include <boost/any.hpp> - -namespace roc { class Message; } - -class CbmROCUnpackDummy : public CbmROCUnpack -{ - public: - - CbmROCUnpackDummy(); - virtual ~CbmROCUnpackDummy(); - - virtual Bool_t Init(); - virtual Bool_t DoUnpack(roc::Message* Message, ULong_t hitTime); - virtual void FillOutput(boost::any) {;} - virtual void Reset(); - virtual void Finish() {;} - - private: - - ClassDef(CbmROCUnpackDummy, 1) -}; - -#endif diff --git a/beamtime/cosy2014/unpacker/CbmROCUnpackEpoch.cxx b/beamtime/cosy2014/unpacker/CbmROCUnpackEpoch.cxx deleted file mode 100644 index 11ded0583aba6743662a7b7005190fa6afb01c5a..0000000000000000000000000000000000000000 --- a/beamtime/cosy2014/unpacker/CbmROCUnpackEpoch.cxx +++ /dev/null @@ -1,68 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmROCUnpackEpoch ----- -// ----- Created 13.12.2014 by F. Uhlig ----- -// ----- ----- -// ----------------------------------------------------------------------------- -#include "CbmROCUnpackEpoch.h" - -#include <FairLogger.h> // for Logger, LOG -#include <stddef.h> // for NULL -#include <iomanip> // for setprecision, __iom_t5 -#include <ios> // for fixed -#include "CbmSourceLmdNew.h" // for CbmSourceLmdNew -#include <FairRunOnline.h> // for FairRunOnline -#include "roc/Message.h" // for Message - - -CbmROCUnpackEpoch::CbmROCUnpackEpoch() - : CbmROCUnpack(), - fSource(NULL), - fNofEpochs(0) -{ -} - -CbmROCUnpackEpoch::~CbmROCUnpackEpoch() -{ -} - - -Bool_t CbmROCUnpackEpoch::Init() -{ - FairRunOnline* online = FairRunOnline::Instance(); - fSource = static_cast<CbmSourceLmdNew*>(online->GetSource()); - return kTRUE; -} - -Bool_t CbmROCUnpackEpoch::DoUnpack(roc::Message* Message, ULong_t /*hitTime*/) -{ - - Int_t rocId = Message->getRocNumber(); - fSource->SetEpoch(rocId, Message->getEpochNumber()); - - if ( rocId ) { return kTRUE; } // Further action only for ROC Id 0 - - ULong_t currentEpochTime = Message->getMsgFullTime(Message->getEpochNumber()); - fNofEpochs++; - LOG(debug) << GetName() << ": Epoch message " - << fNofEpochs << ", epoch " << Int_t(Message->getEpochNumber()) - << ", time " << std::setprecision(9) << std::fixed - << Double_t(currentEpochTime) * 1.e-9 << " s"; - - // --- Start and stop time - if ( fSource->GetStartTime() == 0 || - fSource->GetStartTime() > currentEpochTime ) { - fSource->SetStartTime(currentEpochTime); - } - if ( fSource->GetStopTime() < currentEpochTime ) { - fSource->SetStopTime(currentEpochTime); - } - - return kTRUE; -} - -void CbmROCUnpackEpoch::Reset() -{ -} - -ClassImp(CbmROCUnpackEpoch) diff --git a/beamtime/cosy2014/unpacker/CbmROCUnpackEpoch.h b/beamtime/cosy2014/unpacker/CbmROCUnpackEpoch.h deleted file mode 100644 index 47ff16129643dd3e9d13806cb67b678ed3738e5d..0000000000000000000000000000000000000000 --- a/beamtime/cosy2014/unpacker/CbmROCUnpackEpoch.h +++ /dev/null @@ -1,44 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmROCUnpackEpoch ----- -// ----- Created 13.12.2014 by F. Uhlig ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CBMROCUNPACKEPOCH_H -#define CBMROCUNPACKEPOCH_H - -#include <Rtypes.h> // for ClassDef -#include <RtypesCore.h> // for Bool_t, Int_t, ULong_t -#include "CbmROCUnpack.h" -#include <boost/any.hpp> - -namespace roc { class Message; } - -class CbmSourceLmdNew; - -class CbmROCUnpackEpoch : public CbmROCUnpack -{ - public: - - CbmROCUnpackEpoch(); - virtual ~CbmROCUnpackEpoch(); - - virtual Bool_t Init(); - virtual Bool_t DoUnpack(roc::Message* Message, ULong_t hitTime); - virtual void FillOutput(boost::any) {;} - virtual void Reset(); - virtual void Finish() {;} - - private: - - CbmSourceLmdNew* fSource; - Int_t fNofEpochs; - - CbmROCUnpackEpoch(const CbmROCUnpackEpoch&); - CbmROCUnpackEpoch& operator=(const CbmROCUnpackEpoch&); - - ClassDef(CbmROCUnpackEpoch, 1) -}; - -#endif diff --git a/beamtime/cosy2014/unpacker/CbmROCUnpackHodo.cxx b/beamtime/cosy2014/unpacker/CbmROCUnpackHodo.cxx deleted file mode 100644 index bb14407695c717c70c5255a57906a9de56c47b81..0000000000000000000000000000000000000000 --- a/beamtime/cosy2014/unpacker/CbmROCUnpackHodo.cxx +++ /dev/null @@ -1,180 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmROCUnpackHodo ----- -// ----- Created 14.12.2014 by F. Uhlig ----- -// ----- ----- -// ----------------------------------------------------------------------------- -#include "CbmROCUnpackHodo.h" - -#include <TH2.h> // for TH2, TH2F -#include <stddef.h> // for NULL -#include "CbmDaqMap.h" // for CbmDaqMap -#include "CbmDefs.h" // for kHodo -#include "CbmFiberHodoAddress.h" // for CbmFiberHodoAddress -#include "CbmFiberHodoDigi.h" // for CbmFiberHodoDigi -#include "CbmHistManager.h" // for CbmHistManager -#include "CbmSourceLmdNew.h" // for CbmSourceLmdNew -#include "CbmTbDaqBuffer.h" // for CbmTbDaqBuffer -#include <FairRootManager.h> // for FairRootManager -#include <FairRunOnline.h> // for FairRunOnline -#include <TClonesArray.h> // for TClonesArray -#include <TDirectory.h> // for TDirectory, gDirectory -#include "roc/Message.h" // for Message - -CbmROCUnpackHodo::CbmROCUnpackHodo() - : CbmROCUnpack(), - fBuffer(CbmTbDaqBuffer::Instance()), - fDaqMap(NULL), - fSource(NULL), -// fHodoDigis(new TClonesArray("CbmFiberHodoDigi", 10)), -// fHodoBaselineDigis(new TClonesArray("CbmFiberHodoDigi", 10)), - fHodoDigis(nullptr), - fHodoBaselineDigis(nullptr), - fHM(new CbmHistManager()) -{ -} - -CbmROCUnpackHodo::~CbmROCUnpackHodo() -{ -} - - -Bool_t CbmROCUnpackHodo::Init() -{ - FairRunOnline* online = FairRunOnline::Instance(); - fSource = static_cast<CbmSourceLmdNew*>(online->GetSource()); - - fDaqMap = fSource->GetDaqMap(); - -// FairRootManager* ioman = FairRootManager::Instance(); - fHodoDigis = RegisterOutput<CbmFiberHodoDigi>("HodoDigi"); - fHodoBaselineDigis = RegisterOutput<CbmFiberHodoDigi>("HodoBaselineDigi"); - -/* - ioman->Register("HodoDigi", "HODO raw data", fHodoDigis, fPersistence); - ioman->Register("HodoBaselineDigi", "HODO baseline data", - fHodoBaselineDigis, fPersistence); -*/ - - CreateHistograms(); - - return kTRUE; - -} - -void CbmROCUnpackHodo::CreateHistograms() -{ - fHM->Add("Raw_ADC_FrontHodo", - new TH2F("Raw_ADC_FrontHodo", - "Raw_ADC_FrontHodo;channel;ADC value", 128, 0, 127, 4096, 0, 4095)); - fHM->Add("Raw_ADC_RearHodo", - new TH2F("Raw_ADC_RearHodo", - "Raw_ADC_RearHodo;channel;ADC value", 128, 0, 127, 4096, 0, 4095)); -} - -Bool_t CbmROCUnpackHodo::DoUnpack(roc::Message* Message, ULong_t hitTime) -{ - - // --- Get absolute time, NXYTER and channel number - Int_t rocId = Message->getRocNumber(); - Int_t nxyterId = Message->getNxNumber(); - Int_t nxChannel = Message->getNxChNum(); - - Int_t charge = Message->getNxAdcValue(); - - Int_t station = fDaqMap->GetFiberHodoStation(rocId); - - if ( 0 == station ) { - fHM->H2("Raw_ADC_FrontHodo")->Fill(nxChannel,charge); - } else { - fHM->H2("Raw_ADC_RearHodo")->Fill(nxChannel,charge); - } - - // --- Check for epoch marker for this ROC - fSource->CheckCurrentEpoch(rocId); - - Int_t iStation; - Int_t iSector; - Int_t iPlane; - Int_t iFiber; - - fDaqMap->Map(rocId, nxyterId, nxChannel, iStation, iSector, iPlane, iFiber); - Int_t address = CbmFiberHodoAddress::GetAddress(iStation, iPlane, iFiber); - - // --- Create a HODO digi and send it to the buffer - CbmFiberHodoDigi* digi = new CbmFiberHodoDigi(address, charge, hitTime); - - - // In case of normal data insert the digi into the buffer. - // In case of baseline data insert the digi only if the roc - // is already in baseline mode. - if ( !fSource->IsBaselineFill() ) { - fBuffer->InsertData<CbmFiberHodoDigi>(digi); - } else { - if ( fSource->IsBaselineFill(rocId) ) { - fBuffer->InsertData<CbmFiberHodoDigi>(digi); - } else { - fSource->AddDiscardedDigi(ECbmModuleId::kHodo); - } - } - - return kTRUE; -} - -void CbmROCUnpackHodo::FillOutput(boost::any _digi) -{ - CbmFiberHodoDigi* digi = boost::any_cast<CbmFiberHodoDigi*>(_digi); - - if ( !fSource->IsBaselineRetrieve() ) { - fHodoDigis->emplace_back(*digi); -/* - new( (*fHodoDigis)[fHodoDigis->GetEntriesFast()]) - CbmFiberHodoDigi(*(boost::any_cast<CbmFiberHodoDigi*>(digi))); -*/ - } else { - fHodoBaselineDigis->emplace_back(*digi); -/* - new( (*fHodoBaselineDigis)[fHodoBaselineDigis->GetEntriesFast()]) - CbmFiberHodoDigi(*(boost::any_cast<CbmFiberHodoDigi*>(digi))); -*/ - } - delete digi; -} - -void CbmROCUnpackHodo::Reset() -{ - // The next block is needed do to the problem that the TClonesArray is - // very large after usage (2.5 M entries). This somehow slows down - // the Clear of the container even if no entries are inside by 2-3 orders - // of magnitude which slows down the execution of the whole program by - // more then a factor of 10. - // TODO: - // It has to be checked if this is a bug in Root by producing a small - // example program to demonstarete the issue - if (fHodoBaselineDigis->size() > 1000) { - fHodoBaselineDigis->resize(10); -/* - fHodoBaselineDigis->Delete(); - fHodoBaselineDigis->Expand(10); -*/ - } - - // --- Clear output arrays -/* - fHodoDigis->Clear(); - fHodoBaselineDigis->Clear(); -*/ - fHodoDigis->clear(); - fHodoBaselineDigis->clear(); -} - -void CbmROCUnpackHodo::Finish() -{ - gDirectory->mkdir("Hodo_Raw"); - gDirectory->cd("Hodo_Raw"); - fHM->H2("Raw_ADC_FrontHodo")->Write(); - fHM->H2("Raw_ADC_RearHodo")->Write(); - gDirectory->cd(".."); -} - -ClassImp(CbmROCUnpackHodo) diff --git a/beamtime/cosy2014/unpacker/CbmROCUnpackHodo.h b/beamtime/cosy2014/unpacker/CbmROCUnpackHodo.h deleted file mode 100644 index 7fa8af846e9600908b9962fe31aa4c49a6a819e4..0000000000000000000000000000000000000000 --- a/beamtime/cosy2014/unpacker/CbmROCUnpackHodo.h +++ /dev/null @@ -1,56 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmROCUnpackHodo ----- -// ----- Created 14.12.2014 by F. Uhlig ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CBMROCUNPACKHODO_H -#define CBMROCUNPACKHODO_H - -#include <Rtypes.h> // for ClassDef -#include <RtypesCore.h> // for Bool_t, ULong_t -#include "CbmROCUnpack.h" // for CbmROCUnpack -#include <boost/any.hpp> -#include <vector> -#include "CbmFiberHodoDigi.h" - -#include "CbmHistManager.h" // for RootCling - -class CbmDaqMap; -class CbmSourceLmdNew; -class CbmTbDaqBuffer; - -namespace roc { class Message; } - -class CbmROCUnpackHodo : public CbmROCUnpack -{ - public: - - CbmROCUnpackHodo(); - virtual ~CbmROCUnpackHodo(); - - virtual Bool_t Init(); - virtual Bool_t DoUnpack(roc::Message* Message, ULong_t hitTime); - virtual void FillOutput(boost::any); - virtual void Reset(); - virtual void Finish(); - - private: - - CbmTbDaqBuffer* fBuffer; ///< Digi buffer instance - CbmDaqMap* fDaqMap; ///< Mapping from electronics to detectors - CbmSourceLmdNew* fSource; - std::vector<CbmFiberHodoDigi>* fHodoDigis; ///< Output array of CbmHodoDigi - std::vector<CbmFiberHodoDigi>* fHodoBaselineDigis; ///< Output array for baseline calib. - CbmHistManager* fHM; ///< Histogram manager - - void CreateHistograms(); - - CbmROCUnpackHodo(const CbmROCUnpackHodo&); - CbmROCUnpackHodo& operator=(const CbmROCUnpackHodo&); - - ClassDef(CbmROCUnpackHodo, 2) -}; - -#endif diff --git a/beamtime/cosy2014/unpacker/CbmROCUnpackMuch.cxx b/beamtime/cosy2014/unpacker/CbmROCUnpackMuch.cxx deleted file mode 100644 index eb63586a72f793768262e0859fd120018b4f0d56..0000000000000000000000000000000000000000 --- a/beamtime/cosy2014/unpacker/CbmROCUnpackMuch.cxx +++ /dev/null @@ -1,163 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmROCUnpackMuch ----- -// ----- Created 13.12.2014 by F. Uhlig ----- -// ----- ----- -// ----------------------------------------------------------------------------- -#include "CbmROCUnpackMuch.h" - -#include "CbmMuchBeamTimeDigi.h" -#include "CbmTbDaqBuffer.h" -#include "CbmSourceLmdNew.h" -#include "CbmDaqMap.h" - -#include "CbmMuchAddress.h" - -#include "FairRunOnline.h" -#include "FairLogger.h" - -#include "TClonesArray.h" - -CbmROCUnpackMuch::CbmROCUnpackMuch() - : CbmROCUnpack(), - fBuffer(CbmTbDaqBuffer::Instance()), - fDaqMap(NULL), - fSource(NULL), - fMuchDigis(nullptr), - fMuchBaselineDigis(nullptr) -{ -} - -CbmROCUnpackMuch::~CbmROCUnpackMuch() -{ -} - - -Bool_t CbmROCUnpackMuch::Init() -{ - FairRunOnline* online = FairRunOnline::Instance(); - fSource = static_cast<CbmSourceLmdNew*>(online->GetSource()); - - fDaqMap = fSource->GetDaqMap(); - -// FairRootManager* ioman = FairRootManager::Instance(); - fMuchDigis = RegisterOutput<CbmMuchBeamTimeDigi>("MuchDigi"); - fMuchBaselineDigis = RegisterOutput<CbmMuchBeamTimeDigi>("MuchBaselineDigi"); - -/* - ioman->Register("MuchDigi", "MUCH raw data", fMuchDigis, fPersistence); - ioman->Register("MuchBaselineDigi", "MUCH baseline data", - fMuchBaselineDigis, fPersistence); -*/ - return kTRUE; -} - -Bool_t CbmROCUnpackMuch::DoUnpack(roc::Message* Message, ULong_t hitTime) -{ - - // --- Get absolute time, NXYTER and channel number - Int_t rocId = Message->getRocNumber(); - Int_t nxyterId = Message->getNxNumber(); - Int_t nxChannel = Message->getNxChNum(); - Int_t charge = Message->getNxAdcValue(); - - // --- Get detector element from DaqMap - Int_t station = 0; - Int_t layer = 0; - Int_t sector = 0; - Int_t channel = 0; - - fDaqMap->Map(rocId, nxyterId, nxChannel, - station, layer, sector, channel); - - // --- Construct unique address - UInt_t address = CbmMuchAddress::GetAddress(station, layer, 0, - 0, sector, channel); - - // --- Create digi - CbmMuchBeamTimeDigi* digi = new CbmMuchBeamTimeDigi(address, charge, hitTime); - digi->SetPadX(sector); - digi->SetPadY(channel); - digi->SetRocId(rocId); - digi->SetNxId(nxyterId); - digi->SetNxCh(nxChannel); - - - LOG(debug) << "MUCH message: rocId " << rocId << " NXYTER " << nxyterId - << " channel " << nxChannel << " charge " << charge << " time " - << hitTime; - LOG(debug) << "MUCH digi: station " << CbmMuchAddress::GetElementId(address, kMuchStation) - << " layer " << CbmMuchAddress::GetElementId(address, kMuchLayer) - << " layerside " << CbmMuchAddress::GetElementId(address, kMuchLayerSide) - << " module " << CbmMuchAddress::GetElementId(address, kMuchModule) - << " sector " << CbmMuchAddress::GetElementId(address, kMuchSector) - << " channel " << CbmMuchAddress::GetElementId(address, kMuchChannel); - LOG(debug) << "MUCH digi: pad x " << digi->GetPadX() << " pad y" << digi->GetPadY() - << " ROC " << digi->GetRocId() << " NXYTER " << digi->GetNxId(); - LOG(debug); - - - - // In case of normal data insert the digi into the buffer. - // In case of baseline data insert the digi only if the roc - // is already in baseline mode. - if ( !fSource->IsBaselineFill() ) { - fBuffer->InsertData<CbmMuchBeamTimeDigi>(digi); - } else { - if ( fSource->IsBaselineFill(rocId) ) { - fBuffer->InsertData<CbmMuchBeamTimeDigi>(digi); - } else { - fSource->AddDiscardedDigi(ECbmModuleId::kMuch); - } - } - - return kTRUE; -} - -void CbmROCUnpackMuch::FillOutput(boost::any _digi) -{ - CbmMuchBeamTimeDigi* digi = boost::any_cast<CbmMuchBeamTimeDigi*>(_digi); - - if ( !fSource->IsBaselineRetrieve() ) { - fMuchDigis->emplace_back(*digi); -/* - new( (*fMuchDigis)[fMuchDigis->GetEntriesFast()]) - CbmMuchBeamTimeDigi(*(boost::any_cast<CbmMuchBeamTimeDigi*>(digi))); -*/ - } else { - fMuchBaselineDigis->emplace_back(*digi); -/* - new( (*fMuchBaselineDigis)[fMuchBaselineDigis->GetEntriesFast()]) - CbmMuchBeamTimeDigi(*(boost::any_cast<CbmMuchBeamTimeDigi*>(digi))); -*/ - } - delete digi; -} - -void CbmROCUnpackMuch::Reset() -{ - // The next block is needed do to the problem that the TClonesArray is - // very large after usage (2.5 M entries). This somehow slows down - // the Clear of the container even if no entries are inside by 2-3 orders - // of magnitude which slows down the execution of the whole program by - // more then a factor of 10. - // TODO: - // It has to be checked if this is a bug in Root by producing a small - // example program to demonstarete the issue - if (fMuchBaselineDigis->size() > 1000) { - fMuchBaselineDigis->resize(10); -/* - fMuchBaselineDigis->Delete(); - fMuchBaselineDigis->Expand(10); -*/ - } -/* - fMuchDigis->Clear(); - fMuchBaselineDigis->Clear(); -*/ - fMuchDigis->clear(); - fMuchBaselineDigis->clear(); - -} - -ClassImp(CbmROCUnpackMuch) diff --git a/beamtime/cosy2014/unpacker/CbmROCUnpackMuch.h b/beamtime/cosy2014/unpacker/CbmROCUnpackMuch.h deleted file mode 100644 index 0f87c653f559dd36394467315d8a2342968ffa53..0000000000000000000000000000000000000000 --- a/beamtime/cosy2014/unpacker/CbmROCUnpackMuch.h +++ /dev/null @@ -1,51 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmROCUnpackMuch ----- -// ----- Created 14.12.2014 by F. Uhlig ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CBMROCUNPACKMUCH_H -#define CBMROCUNPACKMUCH_H - -#include "roc/Message.h" - -#include "CbmROCUnpack.h" -#include <boost/any.hpp> -#include <vector> -#include "CbmMuchBeamTimeDigi.h" - -namespace roc { class Message; } - -class CbmTbDaqBuffer; -class CbmDaqMap; -class CbmSourceLmdNew; - -class CbmROCUnpackMuch : public CbmROCUnpack -{ - public: - - CbmROCUnpackMuch(); - virtual ~CbmROCUnpackMuch(); - - virtual Bool_t Init(); - virtual Bool_t DoUnpack(roc::Message* Message, ULong_t hitTime); - virtual void FillOutput(boost::any); - virtual void Reset(); - virtual void Finish() {;} - - private: - - CbmTbDaqBuffer* fBuffer; ///< Digi buffer instance - CbmDaqMap* fDaqMap; ///< Mapping from electronics to detectors - CbmSourceLmdNew* fSource; - std::vector<CbmMuchBeamTimeDigi>* fMuchDigis; ///< Output array of CbmMuchDigi - std::vector<CbmMuchBeamTimeDigi>* fMuchBaselineDigis; ///< Output array for baseline calib. - - CbmROCUnpackMuch(const CbmROCUnpackMuch&); - CbmROCUnpackMuch& operator=(const CbmROCUnpackMuch&); - - ClassDef(CbmROCUnpackMuch, 2) -}; - -#endif diff --git a/beamtime/cosy2014/unpacker/CbmROCUnpackSts.cxx b/beamtime/cosy2014/unpacker/CbmROCUnpackSts.cxx deleted file mode 100644 index 32d2278f04a60c6bc994fe9e84502f475909ca11..0000000000000000000000000000000000000000 --- a/beamtime/cosy2014/unpacker/CbmROCUnpackSts.cxx +++ /dev/null @@ -1,162 +0,0 @@ -#// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmROCUnpackSts ----- -// ----- Created 13.12.2014 by F. Uhlig ----- -// ----- ----- -// ----------------------------------------------------------------------------- -#include "CbmROCUnpackSts.h" - -#include "CbmStsDigi.h" -#include "CbmTbDaqBuffer.h" -#include "CbmSourceLmdNew.h" -#include "CbmDaqMap.h" - -#include "CbmStsAddress.h" - -#include "FairRunOnline.h" -#include "FairLogger.h" -#include "FairRootManager.h" - -#include "TClonesArray.h" - -CbmROCUnpackSts::CbmROCUnpackSts() -: CbmROCUnpack(), - fBuffer(CbmTbDaqBuffer::Instance()), - fDaqMap(NULL), - fSource(NULL), - fStsDigis(nullptr), - fStsBaselineDigis(nullptr) -{ -} - -CbmROCUnpackSts::~CbmROCUnpackSts() -{ -} - - -Bool_t CbmROCUnpackSts::Init() -{ - FairRunOnline* online = FairRunOnline::Instance(); - fSource = static_cast<CbmSourceLmdNew*>(online->GetSource()); - - fDaqMap = fSource->GetDaqMap(); - -// FairRootManager* ioman = FairRootManager::Instance(); - fStsDigis = RegisterOutput<CbmStsDigi>("StsDigi"); - fStsBaselineDigis = RegisterOutput<CbmStsDigi>("StsBaselineDigi"); - -/* - ioman->Register("StsDigi", "STS raw data", fStsDigis, fPersistence); - ioman->Register("StsBaselineDigi", "STS baseline data", - fStsBaselineDigis, fPersistence); -*/ - - return kTRUE; -} - -Bool_t CbmROCUnpackSts::DoUnpack(roc::Message* Message, ULong_t hitTime) -{ - // --- Get absolute time, NXYTER and channel number - Int_t rocId = Message->getRocNumber(); - // ULong64_t hitTime = fCurrentMessage->getMsgFullTime(fCurrentEpoch[rocId]); - Int_t nxyterId = Message->getNxNumber(); - Int_t nxChannel = Message->getNxChNum(); - Int_t charge = Message->getNxAdcValue(); - - // --- Check for epoch marker for this ROC - fSource->CheckCurrentEpoch(rocId); - - // --- Get detector element from DaqMap - Int_t station = fDaqMap->GetStsStation(rocId); - Int_t sector = 0; - Int_t side = fDaqMap->GetStsSensorSide(rocId); - Int_t channel = fDaqMap->GetStsChannel(rocId, nxyterId, nxChannel); - - - Int_t iStation; - Int_t iSector; - Int_t iPlane; - Int_t iFiber; - - fDaqMap->Map(rocId, nxyterId, nxChannel, iStation, iSector, iPlane, iFiber); - - if( station != iStation || sector != iSector || - side != iPlane || channel != iFiber ) { - LOG(info) << "Roc, Nxyter: " << rocId << ", " << nxyterId; - LOG(info) << "Station: " << station << ", " << iStation; - LOG(info) << "Sector: " << sector << ", " << iSector; - LOG(info) << "Side: " << side << ", " << iPlane; - LOG(info) << "Channel: " << channel << ", " << iFiber; - } - // --- Create a STS digi and send it to the buffer - UInt_t address = CbmStsAddress::GetAddress(station, - 0, // ladder - 0, // halfladder - 0, // module - 0, // sensor - side); - CbmStsDigi* digi = new CbmStsDigi(address, channel, hitTime, charge); - - - // In case of normal data insert the digi into the buffer. - // In case of baseline data insert the digi only if the roc - // is already in baseline mode. - if ( !fSource->IsBaselineFill() ) { - fBuffer->InsertData<CbmStsDigi>(digi); - } else { - if ( fSource->IsBaselineFill(rocId) ) { - fBuffer->InsertData<CbmStsDigi>(digi); - } else { - fSource->AddDiscardedDigi(ECbmModuleId::kSts); - } - } - - return kTRUE; -} - -void CbmROCUnpackSts::FillOutput(boost::any _digi) -{ - CbmStsDigi* digi = boost::any_cast<CbmStsDigi*>(_digi); - - if ( !fSource->IsBaselineRetrieve() ) { - fStsDigis->emplace_back(*digi); -/* - new( (*fStsDigis)[fStsDigis->GetEntriesFast()]) - CbmStsDigi(*(boost::any_cast<CbmStsDigi*>(digi))); -*/ - } else { - fStsBaselineDigis->emplace_back(*digi); -/* - new( (*fStsBaselineDigis)[fStsBaselineDigis->GetEntriesFast()]) - CbmStsDigi(*(boost::any_cast<CbmStsDigi*>(digi))); -*/ - } - delete digi; -} - -void CbmROCUnpackSts::Reset() -{ - // The next block is needed do to the problem that the TClonesArray is - // very large after usage (2.5 M entries). This somehow slows down - // the Clear of the container even if no entries are inside by 2-3 orders - // of magnitude which slows down the execution of the whole program by - // more then a factor of 10. - // TODO: - // It has to be checked if this is a bug in Root by producing a small - // example program to demonstarete the issue - if (fStsBaselineDigis->size() > 1000) { - fStsBaselineDigis->resize(10); -/* - fStsBaselineDigis->Delete(); - fStsBaselineDigis->Expand(10); -*/ - } -/* - fStsDigis->Clear(); - fStsBaselineDigis->Clear(); -*/ - fStsDigis->clear(); - fStsBaselineDigis->clear(); -} - -ClassImp(CbmROCUnpackSts) diff --git a/beamtime/cosy2014/unpacker/CbmROCUnpackSts.h b/beamtime/cosy2014/unpacker/CbmROCUnpackSts.h deleted file mode 100644 index 8003c187e46239f7ee35d5aeed77cb504e11c18c..0000000000000000000000000000000000000000 --- a/beamtime/cosy2014/unpacker/CbmROCUnpackSts.h +++ /dev/null @@ -1,50 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmROCUnpackSts ----- -// ----- Created 10.11.2014 by F. Uhlig ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CBMROCUNPACKSTS_H -#define CBMROCUNPACKSTS_H - -#include "roc/Message.h" - -#include "CbmROCUnpack.h" -#include <boost/any.hpp> -#include <vector> -#include "CbmStsDigi.h" - -namespace roc { class Message; } - -class CbmTbDaqBuffer; -class CbmDaqMap; -class CbmSourceLmdNew; - -class CbmROCUnpackSts : public CbmROCUnpack -{ - public: - - CbmROCUnpackSts(); - virtual ~CbmROCUnpackSts(); - - virtual Bool_t Init(); - virtual Bool_t DoUnpack(roc::Message* Message, ULong_t hitTime); - virtual void FillOutput(boost::any); - virtual void Reset(); - virtual void Finish() {;} - private: - - CbmTbDaqBuffer* fBuffer; ///< Digi buffer instance - CbmDaqMap* fDaqMap; ///< Mapping from electronics to detectors - CbmSourceLmdNew* fSource; - std::vector<CbmStsDigi>* fStsDigis; ///< Output array of CbmStsDigi - std::vector<CbmStsDigi>* fStsBaselineDigis; ///< Output array for baseline calib. - - CbmROCUnpackSts(const CbmROCUnpackSts&); - CbmROCUnpackSts& operator=(const CbmROCUnpackSts&); - - ClassDef(CbmROCUnpackSts, 2) -}; - -#endif diff --git a/beamtime/cosy2014/unpacker/CbmROCUnpackSystemMessage.cxx b/beamtime/cosy2014/unpacker/CbmROCUnpackSystemMessage.cxx deleted file mode 100644 index 3af4cd4d324c71c5016db730a180600402046ddc..0000000000000000000000000000000000000000 --- a/beamtime/cosy2014/unpacker/CbmROCUnpackSystemMessage.cxx +++ /dev/null @@ -1,102 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmROCUnpackSystemMessage ----- -// ----- Created 07.11.2014 by F. Uhlig ----- -// ----- ----- -// ----------------------------------------------------------------------------- -#include "CbmROCUnpackSystemMessage.h" - -#include <FairLogger.h> // for Logger, LOG -#include <stddef.h> // for NULL -#include <iomanip> // for setprecision, __iom_t5 -#include "CbmAuxDigi.h" // for CbmAuxDigi -#include "CbmSourceLmdNew.h" // for CbmSourceLmdNew -#include "CbmTbDaqBuffer.h" // for CbmTbDaqBuffer -#include <FairRunOnline.h> // for FairRunOnline -#include "roc/Message.h" // for Message, SYSMSG_USER, SYSMSG_USER_CAL... - -using std::setprecision; - -CbmROCUnpackSystemMessage::CbmROCUnpackSystemMessage() - : CbmROCUnpack(), - fBuffer(CbmTbDaqBuffer::Instance()), - fSource(NULL) -{ -} - -CbmROCUnpackSystemMessage::~CbmROCUnpackSystemMessage() -{ -} - - -Bool_t CbmROCUnpackSystemMessage::Init() -{ - FairRunOnline* online = FairRunOnline::Instance(); - fSource = static_cast<CbmSourceLmdNew*>(online->GetSource()); - return kTRUE; -} - - -Bool_t CbmROCUnpackSystemMessage::DoUnpack(roc::Message* message, ULong_t hitTime) -{ - - if (message->getSysMesType() == roc::SYSMSG_USER) { - // --- Get absolute time and Roc number - CbmAuxDigi* digi; - Int_t rocId = message->getRocNumber(); - - switch(message->getSysMesData()) { - case roc::SYSMSG_USER_CALIBR_ON: - { - if ( !fSource->IsBaselineFill() ) { - // --- Create AuxDigi and send it to the buffer - digi = new CbmAuxDigi(666, 666, hitTime); - fBuffer->InsertData<CbmAuxDigi>(digi); - LOG(info) << " Switching now to baseline mode at " << - setprecision(9) << Double_t(hitTime) * 1.e-9 << " s"; - fSource->AddBaselineRoc(rocId); - LOG(info) << "ROC " << rocId << " now in baseline mode"; - fSource->SetBaselineFill(kTRUE); - } - fSource->AddBaselineRoc(rocId); - LOG(info) << "ROC " << rocId << " now in baseline mode"; - break; - } - case roc::SYSMSG_USER_CALIBR_OFF: - { - if ( fSource->IsBaselineFill() ) { - Bool_t isEmpty=fSource->RemoveBaselineRoc(rocId); - LOG(info) << "ROC " << rocId << " now in normal mode"; - if ( isEmpty ) { - digi = new CbmAuxDigi(999, 999, hitTime); - fBuffer->InsertData<CbmAuxDigi>(digi); - fSource->SetBaselineFill(kFALSE); - LOG(info) << "Switching back to normal mode at " << - setprecision(9) << Double_t(hitTime) * 1.e-9 << " s"; - } - } - break; - } - case roc::SYSMSG_USER_RECONFIGURE: - { - LOG(debug) << "Found USER_RECONFIGURE at "; - break; - } - default: - { - LOG(error) << "Found unknown system message at "; - break; - } - } - } - - return kTRUE; -} - - -void CbmROCUnpackSystemMessage::Reset() -{ -} - - -ClassImp(CbmROCUnpackSystemMessage) diff --git a/beamtime/cosy2014/unpacker/CbmROCUnpackSystemMessage.h b/beamtime/cosy2014/unpacker/CbmROCUnpackSystemMessage.h deleted file mode 100644 index 3b1b85fabad2a402f4e5343a84615c1cfb7c886e..0000000000000000000000000000000000000000 --- a/beamtime/cosy2014/unpacker/CbmROCUnpackSystemMessage.h +++ /dev/null @@ -1,47 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmROCUnpackSystemMessage ----- -// ----- Created 10.11.2014 by F. Uhlig ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CBMROCUNPACKSYSTEMMESSAGE_H -#define CBMROCUNPACKSYSTEMMESSAGE_H - -#include <Rtypes.h> // ClassDef -#include <RtypesCore.h> // for Bool_t, ULong_t -#include "CbmROCUnpack.h" // for CbmROCUnpack -#include <boost/any.hpp> - -class CbmSourceLmdNew; -class CbmTbDaqBuffer; - -namespace roc { class Message; } - -class CbmTbDaqBuffer; -class CbmSourceLmdNew; -class CbmROCUnpackSystemMessage : public CbmROCUnpack -{ - public: - - CbmROCUnpackSystemMessage(); - virtual ~CbmROCUnpackSystemMessage(); - - virtual Bool_t Init(); - virtual Bool_t DoUnpack(roc::Message* Message, ULong_t hitTime); - virtual void FillOutput(boost::any) {;} - virtual void Reset(); - virtual void Finish() {;} - - private: - - CbmTbDaqBuffer* fBuffer; - CbmSourceLmdNew* fSource; - - CbmROCUnpackSystemMessage(const CbmROCUnpackSystemMessage&); - CbmROCUnpackSystemMessage& operator=(const CbmROCUnpackSystemMessage&); - - ClassDef(CbmROCUnpackSystemMessage, 1) -}; - -#endif diff --git a/beamtime/cosy2017/CMakeLists.txt b/beamtime/cosy2017/CMakeLists.txt deleted file mode 100644 index c9ed7b8269d3d32f2bcac660464e32381879eb50..0000000000000000000000000000000000000000 --- a/beamtime/cosy2017/CMakeLists.txt +++ /dev/null @@ -1,60 +0,0 @@ -# Create a library called "CbmFlibCosy2017" which includes the source files given in -# the array . -# The extension is already found. Any number of sources could be listed here. - -Set(INCLUDE_DIRECTORIES - ${CBMBASE_DIR} - - ${CBMDATA_DIR} - ${CBMDATA_DIR}/sts - - ${CBMROOT_SOURCE_DIR}/beamtime/base - ${CBMROOT_SOURCE_DIR}/beamtime/data/raw - - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/unpacker - ${CMAKE_CURRENT_SOURCE_DIR}/param -) - -Set(SYSTEM_INCLUDE_DIRECTORIES - ${BASE_INCLUDE_DIRECTORIES} - ${Boost_INCLUDE_DIR} - ${ROOT_INCLUDE_DIR} - ${IPC_INCLUDE_DIRECTORY} - ${CBMROOT_SOURCE_DIR}/external/flib_dpb/flib_dpb - ${CMAKE_SOURCE_DIR}/external/cppzmq -) - -Include_Directories(${INCLUDE_DIRECTORIES}) -Include_Directories(SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES}) - - -Set(LINK_DIRECTORIES - ${ROOT_LIBRARY_DIR} - ${FAIRROOT_LIBRARY_DIR} - ${Boost_LIBRARY_DIRS} -) - -Link_Directories( - ${LINK_DIRECTORIES} -) - -Set(SRCS - unpacker/CbmTsMonitorSts.cxx - - param/CbmStsUnpackPar.cxx - param/CbmFlesCosy2017ContFact.cxx -) - -If(_UINT8_T_EXIST) - Add_Definitions(-DHAVE_UINT8_T_HEADER_FILE) - Set(DEFINITIONS HAVE_UINT8_T_HEADER_FILE) -EndIf() - -Set(LINKDEF CbmBeamtimeCosy2017LinkDef.h ) -Set(LIBRARY_NAME CbmBeamtimeCosy2017) -Set(DEPENDENCIES - CbmData CbmBase CbmBeamtimeBase fles_ipc Eve Base -) - -GENERATE_LIBRARY() diff --git a/beamtime/cosy2017/CbmBeamtimeCosy2017LinkDef.h b/beamtime/cosy2017/CbmBeamtimeCosy2017LinkDef.h deleted file mode 100644 index 10f8f4b63d8b2a39132d86cd43c58d61772dab20..0000000000000000000000000000000000000000 --- a/beamtime/cosy2017/CbmBeamtimeCosy2017LinkDef.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifdef __CINT__ - -#pragma link off all globals; -#pragma link off all classes; -#pragma link off all functions; - -#pragma link C++ class CbmTsMonitorSts; -#pragma link C++ class CbmStsUnpackPar; -#pragma link C++ class CbmFlesCosy2017ContFact; - -#endif diff --git a/beamtime/cosy2017/param/CbmFlesCosy2017ContFact.cxx b/beamtime/cosy2017/param/CbmFlesCosy2017ContFact.cxx deleted file mode 100644 index 17d8a56da54b1ef6fdb7e06d704d93e5a7fe05a6..0000000000000000000000000000000000000000 --- a/beamtime/cosy2017/param/CbmFlesCosy2017ContFact.cxx +++ /dev/null @@ -1,50 +0,0 @@ -///////////////////////////////////////////////////////////// -// -// CbmFlesCosy2017ContFact -// -// Factory for the parameter containers in libFlesTest -// -///////////////////////////////////////////////////////////// - -#include "CbmFlesCosy2017ContFact.h" - -#include "CbmStsUnpackPar.h" - -#include "FairRuntimeDb.h" - -ClassImp(CbmFlesCosy2017ContFact) - -static CbmFlesCosy2017ContFact gCbmFlesCosy2017ContFact; - -CbmFlesCosy2017ContFact::CbmFlesCosy2017ContFact() { - // Constructor (called when the library is loaded) - fName="CbmFlesCosy2017ContFact"; - fTitle="Factory for parameter containers for fles cosy 2017 library"; - setAllContainers(); - FairRuntimeDb::instance()->addContFactory(this); -} - -void CbmFlesCosy2017ContFact::setAllContainers() { - /** Creates the Container objects with all accepted contexts and adds them to - * the list of containers for the fles test library.*/ - - FairContainer* p1= new FairContainer("CbmStsUnpackPar", - "STS Unpack Parameters", - "TestDefaultContext"); - p1->addContext("TestNonDefaultContext"); - - containers->Add(p1); -} - -FairParSet* CbmFlesCosy2017ContFact::createContainer(FairContainer* c) { - /** Calls the constructor of the corresponding parameter container. - * For an actual context, which is not an empty string and not the default context - * of this container, the name is concatinated with the context. */ - const char* name=c->GetName(); - FairParSet* p=0; - if (strcmp(name,"CbmStsUnpackPar")==0) { - p=new CbmStsUnpackPar(c->getConcatName().Data(),c->GetTitle(),c->getContext()); - } - return p; -} - diff --git a/beamtime/cosy2017/param/CbmFlesCosy2017ContFact.h b/beamtime/cosy2017/param/CbmFlesCosy2017ContFact.h deleted file mode 100644 index b59578b8654bb72019ccbb480032867a4e30af21..0000000000000000000000000000000000000000 --- a/beamtime/cosy2017/param/CbmFlesCosy2017ContFact.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef CBMFLESCOSY2017CONTFACT_H -#define CBMFLESCOSY2017CONTFACT_H - -#include "FairContFact.h" - -class FairContainer; -class FairParSet; - -class CbmFlesCosy2017ContFact : public FairContFact { -private: - void setAllContainers(); - CbmFlesCosy2017ContFact(const CbmFlesCosy2017ContFact&); - CbmFlesCosy2017ContFact& operator=(const CbmFlesCosy2017ContFact&); -public: - CbmFlesCosy2017ContFact(); - ~CbmFlesCosy2017ContFact() {} - FairParSet* createContainer(FairContainer*); - ClassDef(CbmFlesCosy2017ContFact,0) // Factory for all COSY 2017 parameter containers -}; - -#endif /* !CBMFLESCOSY2017CONTFACT_H */ diff --git a/beamtime/cosy2017/param/CbmStsUnpackPar.cxx b/beamtime/cosy2017/param/CbmStsUnpackPar.cxx deleted file mode 100644 index 27007020e750e48eeef2f35e5f04094ab3a5fa13..0000000000000000000000000000000000000000 --- a/beamtime/cosy2017/param/CbmStsUnpackPar.cxx +++ /dev/null @@ -1,142 +0,0 @@ -// ------------------------------------------------------------------------- -// ----- CbmStsUnpackPar source file ----- -// ----- Created 08.03.2017 by P.-A. Loizeau ----- -// ------------------------------------------------------------------------- - -#include "CbmStsUnpackPar.h" - -#include "FairParamList.h" -#include "FairDetParIo.h" -#include "FairParIo.h" -#include "FairLogger.h" - -#include "TString.h" - -using namespace std; -// ----- Standard constructor ------------------------------------------ -CbmStsUnpackPar::CbmStsUnpackPar(const char* name, - const char* title, - const char* context) - : FairParGenericSet(name, title, context), - fNrOfnDpbsModA(-1), - fnDbpsIdsArrayA(), - fNrOfnDpbsModB(-1), - fnDbpsIdsArrayB(), - fuNbFebPerNdpb(-1), - fNrOfFebs(-1), - fnFebsIdsArrayA(), - fnFebsIdsArrayB(), - fNrOfChannels(-1), - fChannelsToPadX(), - fChannelsToPadY() -{ - detName="Much"; -} -// ------------------------------------------------------------------------- - - - -// ----- Destructor ---------------------------------------------------- -CbmStsUnpackPar::~CbmStsUnpackPar() -{ -} -// ------------------------------------------------------------------------- - - -// ----- Public method clear ------------------------------------------- -void CbmStsUnpackPar::clear() -{ - status = kFALSE; - resetInputVersions(); -} -// ------------------------------------------------------------------------- - -// ------------------------------------------------------------------------- - -void CbmStsUnpackPar::putParams(FairParamList* l) -{ - if (!l) return; - l->add("NrOfnDpbsModA", fNrOfnDpbsModA); - l->add("nDbpsIdsArrayA", fnDbpsIdsArrayA); - l->add("NrOfnDpbsModB", fNrOfnDpbsModB); - l->add("nDbpsIdsArrayB", fnDbpsIdsArrayB); - l->add("NbFebPerNdpb", fuNbFebPerNdpb); - l->add("NrOfFebs", fNrOfFebs); - l->add("nFebsIdsArrayA", fnFebsIdsArrayA); - l->add("nFebsIdsArrayB", fnFebsIdsArrayB); - l->add("NrOfChannels", fNrOfChannels); - l->add("ChannelsToPadX", fChannelsToPadX); - l->add("ChannelsToPadY", fChannelsToPadY); -} - -//------------------------------------------------------ - -Bool_t CbmStsUnpackPar::getParams(FairParamList* l) { - - if (!l) return kFALSE; - - LOG(info)<< " Before CbmStsUnpackPar GetParams at NrOfnDpbs "; - if ( ! l->fill("NrOfnDpbsModA", &fNrOfnDpbsModA) ) return kFALSE; - LOG(info)<< " After CbmStsUnpackPar GetParams at NrOfnDpbs "; - - fnDbpsIdsArrayA.Set(fNrOfnDpbsModA); - if ( ! l->fill("nDbpsIdsArrayA", &fnDbpsIdsArrayA) ) return kFALSE; - - - - LOG(info)<< " Before CbmStsUnpackPar GetParams at NrOfnDpbs for GEM2 "; - if ( ! l->fill("NrOfnDpbsModB", &fNrOfnDpbsModB) ) return kFALSE; - LOG(info)<< " After CbmStsUnpackPar GetParams at NrOfnDpbs "; - - fnDbpsIdsArrayB.Set(fNrOfnDpbsModB); - if ( ! l->fill("nDbpsIdsArrayB", &fnDbpsIdsArrayB) ) return kFALSE; - - if ( ! l->fill("NbFebPerNdpb", &fuNbFebPerNdpb) ) return kFALSE; - - if ( ! l->fill("NrOfFebs", &fNrOfFebs) ) return kFALSE; - - fnFebsIdsArrayA.Set(fNrOfFebs); - if ( ! l->fill("nFebsIdsArrayA", &fnFebsIdsArrayA) ) return kFALSE; - - fnFebsIdsArrayB.Set(fNrOfFebs); - if ( ! l->fill("nFebsIdsArrayB", &fnFebsIdsArrayB) ) return kFALSE; - - if ( ! l->fill("NrOfChannels", &fNrOfChannels) ) return kFALSE; - - fChannelsToPadX.Set(fNrOfFebs*fNrOfChannels); - if ( ! l->fill("ChannelsToPadX", &fChannelsToPadX) ) return kFALSE; - - fChannelsToPadY.Set(fNrOfFebs*fNrOfChannels); - if ( ! l->fill("ChannelsToPadY", &fChannelsToPadY) ) return kFALSE; - - return kTRUE; -} - - -Int_t CbmStsUnpackPar::GetPadX(Int_t febid, Int_t channelid) -{ - if( fChannelsToPadX.GetSize () <= (febid*fNrOfChannels)+channelid ) - { - LOG(debug) << "CbmStsUnpackPar::GetPadX => Index out of bounds: " - << ((febid*fNrOfChannels)+channelid) << " VS " << fChannelsToPadX.GetSize() - << " (" << febid << " and " << channelid << ")"; - return -2; - } // if( fChannelsToPadX.GetSize () <= (febid*fNrOfChannels)+channelid ) - - - return fChannelsToPadX[(febid*fNrOfChannels)+channelid]; -} -Int_t CbmStsUnpackPar::GetPadY(Int_t febid, Int_t channelid) -{ - if( fChannelsToPadY.GetSize() <= (febid*fNrOfChannels)+channelid ) - { - LOG(debug) << "CbmStsUnpackPar::GetPadY => Index out of bounds: " - << ((febid*fNrOfChannels)+channelid) << " VS " << fChannelsToPadY.GetSize() - << " (" << febid << " and " << channelid << ")"; - return -2; - } // if( fChannelsToPadY.GetSize () <= (febid*fNrOfChannels)+channelid ) - - return fChannelsToPadY[(febid*fNrOfChannels)+channelid]; -} - -ClassImp(CbmStsUnpackPar) diff --git a/beamtime/cosy2017/param/CbmStsUnpackPar.h b/beamtime/cosy2017/param/CbmStsUnpackPar.h deleted file mode 100644 index 6a1369c28c25cfa752414d574b5ba99d2aea92f4..0000000000000000000000000000000000000000 --- a/beamtime/cosy2017/param/CbmStsUnpackPar.h +++ /dev/null @@ -1,71 +0,0 @@ -// ------------------------------------------------------------------------- -// ----- CbmStsUnpackPar header file ----- -// ----- Created 08.03.2017 by P.-A. Loizeau ----- -// ------------------------------------------------------------------------- - -#ifndef CBMMUCHUNPACKPAR_H -#define CBMMUCHUNPACKPAR_H - -#include "FairParGenericSet.h" - -#include "TArrayI.h" - -class FairParIo; -class FairParamList; - - -class CbmStsUnpackPar : public FairParGenericSet -{ - - public: - - /** Standard constructor **/ - CbmStsUnpackPar(const char* name = "CbmStsUnpackPar", - const char* title = "STS unpacker parameters", - const char* context = "Default"); - - - /** Destructor **/ - virtual ~CbmStsUnpackPar(); - - /** Reset all parameters **/ - virtual void clear(); - - void putParams(FairParamList*); - Bool_t getParams(FairParamList*); - - Int_t GetNrOfnDpbsModA() { return fNrOfnDpbsModA; } - Int_t GetNrOfnDpbsModB() { return fNrOfnDpbsModB; } - inline Int_t GetNdpbIdA(Int_t i) { return fnDbpsIdsArrayA[i]; } - inline Int_t GetNdpbIdB(Int_t i) { return fnDbpsIdsArrayB[i]; } - - Int_t GetNrOfFebsPerNdpb() { return fuNbFebPerNdpb; } - Int_t GetNrOfFebs() { return fNrOfFebs; } - inline Int_t GetFebsIdsFromArrayA(Int_t i) { return fnFebsIdsArrayA[i]; } - inline Int_t GetFebsIdsFromArrayB(Int_t i) { return fnFebsIdsArrayB[i]; } - Int_t GetNrOfChannels() {return fNrOfChannels;} - - Int_t GetPadX(Int_t febid, Int_t channelid); - Int_t GetPadY(Int_t febid, Int_t channelid); - - // Int_t GetChannelToPixelMap(Int_t channel) {return fChannelToPixelMap[channel];} - // Int_t GetChannelToPlaneMap(Int_t channel) {return fChannelToPlaneMap[channel];} - - private: - - Int_t fNrOfnDpbsModA; // Total number of nDPBs in GEM Module 1 - TArrayI fnDbpsIdsArrayA; // Array to hold the unique IDs for all GEM nDPBs - Int_t fNrOfnDpbsModB; // Total number of nDPBs in GEM Module 2 - TArrayI fnDbpsIdsArrayB; // Array to hold the unique IDs for all GEM nDPBs - Int_t fuNbFebPerNdpb; // Number of FEBs for all nDPB - Int_t fNrOfFebs; // Number of FEBs for all nDPB - TArrayI fnFebsIdsArrayA; // Array to hold FEB IDs connected to 1 nDPB - TArrayI fnFebsIdsArrayB; // Array to hold FEB IDs connected to 1 nDPB - Int_t fNrOfChannels; - TArrayI fChannelsToPadX; // Array which stores the corresponding x position of PAD of entire module A - TArrayI fChannelsToPadY; // Array which stores the corresponding y position of PAD of entire module A - - - ClassDef(CbmStsUnpackPar,1); -}; -#endif diff --git a/beamtime/cosy2017/unpacker/CbmTsMonitorSts.cxx b/beamtime/cosy2017/unpacker/CbmTsMonitorSts.cxx deleted file mode 100644 index 06d1566ee554332241f3c0a0ec32f4a3cbbae2c4..0000000000000000000000000000000000000000 --- a/beamtime/cosy2017/unpacker/CbmTsMonitorSts.cxx +++ /dev/null @@ -1,979 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmTsMonitorSts ----- -// ----- Created 08.03.2017 by P.-A. Loizeau ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#include "CbmTsMonitorSts.h" -#include "CbmStsUnpackPar.h" - -#include "CbmStsAddress.h" -#include "CbmHistManager.h" - -#include "FairLogger.h" -#include "FairRootManager.h" -#include "FairRun.h" -#include "FairRuntimeDb.h" -#include "FairRunOnline.h" - -#include "TClonesArray.h" -#include "TString.h" -#include "TRandom.h" -#include "THttpServer.h" -#include "TROOT.h" -#include <TFile.h> - -#include <iostream> -#include <stdint.h> -#include <iomanip> - -using std::hex; -using std::dec; -using namespace std; - -Bool_t bResetStsHistos = kFALSE; -Bool_t bSaveStsHistos = kFALSE; -Bool_t bUpdateAdcHistosSts = kFALSE; - -CbmTsMonitorSts::CbmTsMonitorSts() - : CbmTSUnpack(), - fNrOfNdpbs(0), - fNrOfNdpbsA(0), - fNrOfNdpbsB(0), - fNrOfFebsPerNdpb(0), - fMsgCounter(11,0), // length of enum MessageTypes initialized with 0 - fNdpbIdIndexMap(), - fHM(new CbmHistManager()), - fCurrentEpoch(), - fNofEpochs(0), - fCurrentEpochTime(0.), - fdStartTime( -1 ), - fdStartTimeMsSz(-1.), - fcMsSizeAll(NULL), - fEquipmentId(0), - fUnpackPar(NULL), - fFebRateDate_nDPB(), - fHitDtDate_nDPB(), - fHitDt_nDPB(), - fdLastHitTime_nDPB(), - fiRunStartDateTimeSec( -1 ), - fiBinSizeDatePlots( -1 ), - fHistMessType(NULL), - fHistSysMessType(NULL), - fChan_Counts_Sts(), - fRaw_ADC_Sts(), - fFebRate(), - fHitMissEvo(), - fADC_Mean_Sts(), - fADC_Rms_Sts(), - fADC_Skew_Sts(), - fADC_Kurt_Sts() -{ -} - -CbmTsMonitorSts::~CbmTsMonitorSts() -{ -} - -Bool_t CbmTsMonitorSts::Init() -{ - LOG(info) << "Initializing flib nxyter unpacker for STS"; - - FairRootManager* ioman = FairRootManager::Instance(); - if (ioman == NULL) { - LOG(fatal) << "No FairRootManager instance"; - } - - return kTRUE; -} - -void CbmTsMonitorSts::SetParContainers() -{ - LOG(info) << "Setting parameter containers for " << GetName(); - fUnpackPar = (CbmStsUnpackPar*)(FairRun::Instance()->GetRuntimeDb()->getContainer("CbmStsUnpackPar")); -} - - -Bool_t CbmTsMonitorSts::InitContainers() -{ - LOG(info) << "Init parameter containers for " << GetName(); - - Bool_t bReInit = ReInitContainers(); - CreateHistograms(); - - return bReInit; -} - -Bool_t CbmTsMonitorSts::ReInitContainers() -{ - LOG(info) << "ReInit parameter containers for " << GetName(); - - fNrOfNdpbsA = fUnpackPar->GetNrOfnDpbsModA(); - fNrOfNdpbsB = fUnpackPar->GetNrOfnDpbsModB(); - fNrOfNdpbs = fNrOfNdpbsA + fNrOfNdpbsB; - fNrOfFebsPerNdpb = fUnpackPar->GetNrOfFebsPerNdpb(); - - LOG(info) << "Nr. of nDPBs Mod. A: " << fNrOfNdpbsA; - - LOG(info) << "Nr. of nDPBs Mod. B: " << fNrOfNdpbsB; - - fNdpbIdIndexMap.clear(); - for (Int_t i = 0; i< fNrOfNdpbsA; ++i) - { - fNdpbIdIndexMap[fUnpackPar->GetNdpbIdA(i)] = i; - LOG(info) << "nDPB Id of STS A " << i - << " : 0x" << std::hex << fUnpackPar->GetNdpbIdA(i) - << std::dec; - } // for (Int_t i = 0; i< NrOfnDpbsModA; ++i) - for (Int_t i = 0; i< fNrOfNdpbsB; ++i) - { - fNdpbIdIndexMap[fUnpackPar->GetNdpbIdB(i)] = i + fNrOfNdpbsA; - LOG(info) << "nDPB Id of STS B " << i - << " : 0x" << std::hex << fUnpackPar->GetNdpbIdB(i) - << std::dec; - } // for (Int_t i = 0; i< NrOfnDpbsModB; ++i) - - Int_t NrOfFebs = fUnpackPar->GetNrOfFebs(); - - LOG(info) << "Nr. of FEBs : " << NrOfFebs; - - Int_t NrOfChannels = fUnpackPar->GetNrOfChannels(); - LOG(info) << "Nr. of Channels : " << NrOfChannels; - - return kTRUE; -} - -void CbmTsMonitorSts::CreateHistograms() -{ - THttpServer* server = FairRunOnline::Instance()->GetHttpServer(); - - TString sHistName{""}; - TString title{""}; - - sHistName = "hMessageTypeSts"; - title = "Nb of message for each type; Type"; - TH1I* hMessageType = new TH1I(sHistName, title, 16, 0., 16.); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_NOP, "NOP"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_HIT, "HIT"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_EPOCH, "EPOCH"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_SYNC, "SYNC"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_AUX, "AUX"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_EPOCH2, "EPOCH2"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_GET4, "GET4"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_SYS, "SYS"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_GET4_SLC, "MSG_GET4_SLC"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_GET4_32B, "MSG_GET4_32B"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_GET4_SYS, "MSG_GET4_SYS"); - hMessageType->GetXaxis()->SetBinLabel(1 + 15, "GET4 Hack 32B"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_NOP, "NOP"); - fHM->Add(sHistName.Data(), hMessageType); - if (server) server->Register("/StsRaw", fHM->H1(sHistName.Data())); - - sHistName = "hSysMessTypeSts"; - title = "Nb of system message for each type; System Type"; - TH1I* hSysMessType = new TH1I(sHistName, title, 17, 0., 17.); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_START, "DAQ START"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_FINISH, "DAQ FINISH"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_NX_PARITY, "NX PARITY"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_SYNC_PARITY, "SYNC PARITY"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_RESUME, "DAQ RESUME"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_FIFO_RESET, "FIFO RESET"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_USER, "USER"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_PCTIME, "PCTIME"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_ADC, "ADC"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_PACKETLOST, "PACKET LOST"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_GET4_EVENT, "GET4 ERROR"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_CLOSYSYNC_ERROR, "CLOSYSYNC ERROR"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_TS156_SYNC, "TS156 SYNC"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_GDPB_UNKWN, "UNKW GET4 MSG"); - hSysMessType->GetXaxis()->SetBinLabel(1 + 16, "GET4 Hack 32B"); - fHM->Add(sHistName.Data(), hSysMessType); - if (server) server->Register("/StsRaw", fHM->H1(sHistName.Data())); - - // Number of rqte bins = - // 9 for the sub-unit decade - // + 9 for each unit of each decade * 10 for the subdecade range - // + 1 for the closing bin top edge - const Int_t iNbDecadesRate = 9; - const Int_t iNbStepsDecade = 9; - const Int_t iNbSubStepsInStep = 10; - const Int_t iNbBinsRate = iNbStepsDecade - + iNbStepsDecade * iNbSubStepsInStep * iNbDecadesRate - + 1; - Double_t dBinsRate[iNbBinsRate]; - Double_t dBinsDt[iNbBinsRate]; - // First fill sub-unit decade - for( Int_t iSubU = 0; iSubU < iNbStepsDecade; iSubU ++ ) - { - dBinsRate[ iSubU ] = 0.1 * ( 1 + iSubU ); - dBinsDt[ iSubU ] = 10 * dBinsRate[ iSubU ] ; - } // for( Int_t iSubU = 0; iSubU < iNbStepsDecade; iSubU ++ ) - std::cout << std::endl; - // Then fill the main decades - Double_t dSubstepSize = 1.0 / iNbSubStepsInStep; - for( Int_t iDecade = 0; iDecade < iNbDecadesRate; iDecade ++) - { - Double_t dBase = std::pow( 10, iDecade ); - Int_t iDecadeIdx = iNbStepsDecade - + iDecade * iNbStepsDecade * iNbSubStepsInStep; - for( Int_t iStep = 0; iStep < iNbStepsDecade; iStep++ ) - { - Int_t iStepIdx = iDecadeIdx + iStep * iNbSubStepsInStep; - for( Int_t iSubStep = 0; iSubStep < iNbSubStepsInStep; iSubStep++ ) - { - dBinsRate[ iStepIdx + iSubStep ] = dBase * (1 + iStep) - + dBase * dSubstepSize * iSubStep; - dBinsDt[ iStepIdx + iSubStep ] = 10 * dBinsRate[ iStepIdx + iSubStep ] ; - } // for( Int_t iSubStep = 0; iSubStep < iNbSubStepsInStep; iSubStep++ ) - } // for( Int_t iStep = 0; iStep < iNbStepsDecade; iStep++ ) - } // for( Int_t iDecade = 0; iDecade < iNbDecadesRate; iDecade ++) - dBinsRate[ iNbBinsRate - 1 ] = std::pow( 10, iNbDecadesRate ); - dBinsDt[ iNbBinsRate - 1 ] = 10 * dBinsRate[ iNbBinsRate - 1 ] ; - - TString sNdpbTag = ""; - TString sDateHistName{""}; - for( Int_t dpbId = 0; dpbId < fNrOfNdpbs; dpbId++) - {// looping on all the nDPBS IDs - - if( dpbId < fUnpackPar->GetNrOfnDpbsModA() ) - { - sNdpbTag = Form("%04X", fUnpackPar->GetNdpbIdA(dpbId) ); - } // if( dpbId < fUnpackPar->GetNrOfnDpbsModA() ) - else - { - sNdpbTag = Form("%04X", fUnpackPar->GetNdpbIdB(dpbId - fNrOfNdpbsA) ); - } // else of if( dpbId < fUnpackPar->GetNrOfnDpbsModA() ) - - for( Int_t febId = 0; febId < fNrOfFebsPerNdpb; febId++) - {// looping on all the FEB IDs - sHistName = Form("Chan_Counts_Sts_n%s_f%1u", sNdpbTag.Data(), febId); - title = Form("Channel counts Sts nDPB %s FEB %02u; channel; Counts", - sNdpbTag.Data(), febId); - fHM->Add( sHistName.Data(), new TH1F( sHistName.Data(), title.Data(), kiNbChanFebF, 0, kiNbChanFebF) ); - if (server) server->Register("/StsRaw", fHM->H1(sHistName.Data())); - - sHistName = Form("Raw_ADC_Sts_n%s_f%1u", sNdpbTag.Data(), febId); - title = Form("Raw ADC Sts nDPB %s FEB %02u; channel; ADC value", - sNdpbTag.Data(), febId); - fHM->Add( sHistName.Data(), new TH2F( sHistName.Data(), title.Data(), - kiNbChanFebF, 0, kiNbChanFebF, 4096, 0, 4096) ); - if (server) server->Register("/StsRaw", fHM->H2(sHistName.Data())); - - sHistName = Form("ADC_Mean_Sts_n%s_f%1u", sNdpbTag.Data(), febId); - title = Form("ADC Mean Sts nDPB %s FEB %02u; channel; ADC Mean value", - sNdpbTag.Data(), febId); - fHM->Add( sHistName.Data(), new TH1F( sHistName.Data(), title.Data(), kiNbChanFebF, 0, kiNbChanFebF ) ); - if (server) server->Register("/StsRaw", fHM->H1(sHistName.Data())); - sHistName = Form("ADC_Rms_Sts_n%s_f%1u", sNdpbTag.Data(), febId); - title = Form("ADC RMS Sts nDPB %s FEB %02u; channel; ADC RMS value", - sNdpbTag.Data(), febId); - fHM->Add( sHistName.Data(), new TH1F( sHistName.Data(), title.Data(), kiNbChanFebF, 0, kiNbChanFebF ) ); - if (server) server->Register("/StsRaw", fHM->H1(sHistName.Data())); - sHistName = Form("ADC_Skew_Sts_n%s_f%1u", sNdpbTag.Data(), febId); - title = Form("ADC Skewness Sts nDPB %s FEB %02u; channel; ADC Skewness value", - sNdpbTag.Data(), febId); - fHM->Add( sHistName.Data(), new TH1F( sHistName.Data(), title.Data(), kiNbChanFebF, 0, kiNbChanFebF ) ); - if (server) server->Register("/StsRaw", fHM->H1(sHistName.Data())); - sHistName = Form("ADC_Kurt_Sts_n%s_f%1u", sNdpbTag.Data(), febId); - title = Form("ADC Kurtosis Sts nDPB %s FEB %02u; channel; ADC Kurtosis value", - sNdpbTag.Data(), febId); - fHM->Add( sHistName.Data(), new TH1F( sHistName.Data(), title.Data(), kiNbChanFebF, 0, kiNbChanFebF ) ); - if (server) server->Register("/StsRaw", fHM->H1(sHistName.Data())); - - sHistName = Form("FebRate_n%s_f%1u", sNdpbTag.Data(), febId); - title = Form("Counts per second in nDPB %s FEB %02u; Time[s] ; Counts", - sNdpbTag.Data(), febId); - fHM->Add( sHistName.Data(), new TH1F( sHistName.Data(), title.Data(), 1800, 0, 1800 ) ); - if (server) server->Register("/StsRaw", fHM->H1(sHistName.Data())); - - if( 0 < fiBinSizeDatePlots && 0 < fiRunStartDateTimeSec ) { - sDateHistName = Form("FebRateDate_n%s_f%1u", sNdpbTag.Data(), febId); - fHM->Add(sDateHistName.Data(), new TH1F(sDateHistName.Data(), title.Data(), - (5400 / fiBinSizeDatePlots), - fiRunStartDateTimeSec -10, fiRunStartDateTimeSec + 5400 - 10)); - ( fHM->H1(sDateHistName.Data()) )->GetXaxis()->SetTimeDisplay(1); - if (server) - server->Register("/StsRaw", fHM->H1(sDateHistName.Data())); - - sHistName = Form("HitDtDate_n%s_f%1u", sNdpbTag.Data(), febId ); - title = Form("Inverse Hit distance VS time in second in nDPB %s FEB %02u; Time[s] ; F [Hz]; Counts", - sNdpbTag.Data(), febId ); - fHM->Add(sHistName.Data(), new TH2F(sHistName.Data(), title.Data(), - (5400 / 2*fiBinSizeDatePlots), - fiRunStartDateTimeSec -10, fiRunStartDateTimeSec + 5400 - 10, - iNbBinsRate - 1, dBinsRate )); - ( fHM->H2(sHistName.Data()) )->GetXaxis()->SetTimeDisplay(1); - if (server) - server->Register("/StsRaw", fHM->H2(sHistName.Data())); - - sHistName = Form("HitDt_n%s_f%1u", sNdpbTag.Data(), febId ); - title = Form("Hit distance in nDPB %s FEB %02u; dT [ns]; Counts", - sNdpbTag.Data(), febId ); - fHM->Add(sHistName.Data(), new TH1F(sHistName.Data(), title.Data(), - iNbBinsRate - 1, dBinsDt )); // 1ns to 10s - if (server) - server->Register("/StsRaw", fHM->H1(sHistName.Data())); - } // if( 0 < fiBinSizeDatePlots && 0 < fiRunStartDateTimeSec ) - - sHistName = Form("HitMissEvo_n%s_f%1u", sNdpbTag.Data(), febId); - title = Form("Minimal hit loss per second in nDPB %s FEB %02u; Time[s] ; Min Loss", - sNdpbTag.Data(), febId); - fHM->Add( sHistName.Data(), new TH1F( sHistName.Data(), title.Data(), 1800, 0, 1800 ) ); - if (server) server->Register("/StsRaw", fHM->H1(sHistName.Data())); - - } // for( Int_t febId = 0; febId < fNrOfFebsPerNdpb; febId++) - } // for( Int_t dpbId = 0; dpbId < fNrOfNdpbs; dpbId++) - - sHistName = "Pad_Distribution"; - title = "Pad_Distribution; Sectors in Horizontal Direction; Channels in Vertical Direction"; - fHM->Add( sHistName.Data(), new TH2F(sHistName.Data(), title.Data(), 79, -0.5, 78.5, 23, -0.5, 22.5) ); - if (server) server->Register("/StsRaw", fHM->H2(sHistName.Data())); - - if (server) - { - server->RegisterCommand("/Reset_All_Sts", "bResetStsHistos=kTRUE"); - server->Restrict("/Reset_All_Sts", "allow=admin"); - - server->RegisterCommand("/Save_All_Sts", "bSaveStsHistos=kTRUE"); - server->Restrict("/Save_All_Sts", "allow=admin"); - - server->RegisterCommand("/Updt_Adc_Sts", "bUpdateAdcHistosSts=kTRUE"); - server->Restrict("/Updt_Adc_Sts", "allow=admin"); - } // if (server) - - /** Create summary Canvases for CERN 2016 **/ - Double_t w = 10; - Double_t h = 10; - Int_t iNbPadsPerDpb = fNrOfFebsPerNdpb/2 + fNrOfFebsPerNdpb%2; - - TCanvas* cStsChCounts = new TCanvas("cStsChCounts", "STS Channels counts", w, h); - cStsChCounts->Divide( fNrOfNdpbs/2 + fNrOfNdpbs%2, fNrOfFebsPerNdpb ); - - TCanvas* cStsFebRate = new TCanvas("cStsFebRate", "STS FEB rate", w, h); - cStsFebRate->Divide( fNrOfNdpbs/2 + fNrOfNdpbs%2, fNrOfFebsPerNdpb ); - - TH1* histPnt = NULL; - for( Int_t dpbId = 0; dpbId < fNrOfNdpbs; dpbId++) - {// looping on all the nDPBS IDs - if( dpbId < fUnpackPar->GetNrOfnDpbsModA() ) - { - sNdpbTag = Form("%04X", fUnpackPar->GetNdpbIdA(dpbId) ); - } // if( dpbId < fUnpackPar->GetNrOfnDpbsModA() ) - else - { - sNdpbTag = Form("%04X", fUnpackPar->GetNdpbIdB(dpbId - fNrOfNdpbsA) ); - } // else of if( dpbId < fUnpackPar->GetNrOfnDpbsModA() ) - - for( Int_t febId = 0; febId < fNrOfFebsPerNdpb; febId++) - {// looping on all the FEB IDs - cStsChCounts->cd( 1 + dpbId * iNbPadsPerDpb + febId/2 ); - gPad->SetLogy(); - sHistName = Form("Chan_Counts_Sts_n%s_f%1u", sNdpbTag.Data(), febId); - histPnt = fHM->H1(sHistName.Data()); - - if( 0 == febId%2 ) - { - histPnt->SetLineColor( kRed ); // => Change color for 1st of the 2/pad! - histPnt->Draw(); - } // if( 0 == febId%2 ) - else - { - histPnt->SetLineColor( kBlue ); // => Change color for 1nd of the 2/pad! - histPnt->Draw("same"); - } // if( 0 == febId%2 ) - - cStsFebRate->cd( 1 + dpbId * iNbPadsPerDpb + febId/2 ); - gPad->SetLogy(); - sHistName = Form("FebRate_n%s_f%1u", sNdpbTag.Data(), febId); - histPnt = fHM->H1(sHistName.Data()); - - if( 0 == febId%2 ) - { - histPnt->SetLineColor( kRed ); // => Change color for 1st of the 2/pad! - histPnt->Draw(); - } // if( 0 == febId%2 ) - else - { - histPnt->SetLineColor( kBlue ); // => Change color for 1nd of the 2/pad! - histPnt->Draw("same"); - } // if( 0 == febId%2 ) - - // ADC statistical properties per channel - /// Maybe use some option to switch these canvases ON/OFF - TCanvas* cStsFebAdcStats = new TCanvas( Form("AdcStats_n%s_f%1u", sNdpbTag.Data(), febId), - Form("ADC statistical properties n%s f%1u", sNdpbTag.Data(), febId), - w, h); -// cStsFebAdcStats->Divide( 2, 3 ); - cStsFebAdcStats->Divide( 2, 2 ); - - cStsFebAdcStats->cd(1); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogy(); - sHistName = Form("FebRate_n%s_f%1u", sNdpbTag.Data(), febId); - histPnt = fHM->H1(sHistName.Data()); - histPnt->Draw(); - - cStsFebAdcStats->cd(2); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - sHistName = Form("Raw_ADC_Sts_n%s_f%1u", sNdpbTag.Data(), febId); - histPnt = fHM->H2(sHistName.Data()); - histPnt->Draw("colz"); - - cStsFebAdcStats->cd(3); - gPad->SetGridx(); - gPad->SetGridy(); - sHistName = Form("ADC_Mean_Sts_n%s_f%1u", sNdpbTag.Data(), febId); - histPnt = fHM->H1(sHistName.Data()); - histPnt->Draw("hist"); - - cStsFebAdcStats->cd(4); - gPad->SetGridx(); - gPad->SetGridy(); - sHistName = Form("ADC_Rms_Sts_n%s_f%1u", sNdpbTag.Data(), febId); - histPnt = fHM->H1(sHistName.Data()); - histPnt->Draw("hist"); -/* - cStsFebAdcStats->cd(5); - gPad->SetGridx(); - gPad->SetGridy(); - sHistName = Form("ADC_Skew_Sts_n%s_f%1u", sNdpbTag.Data(), febId); - histPnt = fHM->H1(sHistName.Data()); - histPnt->Draw("hist"); - - cStsFebAdcStats->cd(6); - gPad->SetGridx(); - gPad->SetGridy(); - sHistName = Form("ADC_Kurt_Sts_n%s_f%1u", sNdpbTag.Data(), febId); - histPnt = fHM->H1(sHistName.Data()); - histPnt->Draw("hist"); -*/ - } // for( Int_t febId = 0; febId < fNrOfFebsPerNdpb; febId++) - } // for( Int_t dpbId = 0; dpbId < fNrOfNdpbs; dpbId++) - - /** Recovers/Create Ms Size Canvase for COSY 2017 **/ - // Try to recover canvas in case it was created already by another monitor - // If not existing, create it - fcMsSizeAll = dynamic_cast<TCanvas *>( gROOT->FindObject( "cMsSizeAll" ) ); - if( NULL == fcMsSizeAll ) - { - fcMsSizeAll = new TCanvas("cMsSizeAll", "Evolution of MS size in last 300 s", w, h); - fcMsSizeAll->Divide( 4, 4 ); - LOG(info) << "Created MS size canvas in STS monitor"; - } // if( NULL == fcMsSizeAll ) - else LOG(info) << "Recovered MS size canvas in STS monitor"; - /***************************************************/ - - /** Save pointers to each histogram in class members to speed up access **/ - fHistMessType = fHM->H1("hMessageTypeSts"); - fHistSysMessType = fHM->H1("hSysMessTypeSts"); - - for( Int_t dpbId = 0; dpbId < fNrOfNdpbs; dpbId++) - {// looping on all the nDPBS IDs - if( dpbId < fUnpackPar->GetNrOfnDpbsModA() ) - { - sNdpbTag = Form("%04X", fUnpackPar->GetNdpbIdA(dpbId) ); - } // if( dpbId < fUnpackPar->GetNrOfnDpbsModA() ) - else - { - sNdpbTag = Form("%04X", fUnpackPar->GetNdpbIdB(dpbId - fNrOfNdpbsA) ); - } // else of if( dpbId < fUnpackPar->GetNrOfnDpbsModA() ) - for( Int_t febId = 0; febId < fNrOfFebsPerNdpb; febId++) - {// looping on all the FEB IDs - sHistName = Form("Chan_Counts_Sts_n%s_f%1u", sNdpbTag.Data(), febId); - fChan_Counts_Sts.push_back(fHM->H1(sHistName.Data())); - sHistName = Form("Raw_ADC_Sts_n%s_f%1u", sNdpbTag.Data(), febId); - fRaw_ADC_Sts.push_back(fHM->H2(sHistName.Data())); - sHistName = Form("FebRate_n%s_f%1u", sNdpbTag.Data(), febId); - fFebRate.push_back(fHM->H1(sHistName.Data())); - sHistName = Form("HitMissEvo_n%s_f%1u", sNdpbTag.Data(), febId); - fHitMissEvo.push_back(fHM->H1(sHistName.Data())); - - if( 0 < fiBinSizeDatePlots && 0 < fiRunStartDateTimeSec ) - { - sDateHistName = Form("FebRateDate_n%s_f%1u", sNdpbTag.Data(), febId); - fFebRateDate_nDPB.push_back(fHM->H1(sDateHistName.Data())); - - sHistName = Form("HitDtDate_n%s_f%1u", sNdpbTag.Data(), febId ); - fHitDtDate_nDPB.push_back(fHM->H2(sHistName.Data())); - fdLastHitTime_nDPB.push_back( -1.0 ); - - sHistName = Form("HitDt_n%s_f%1u", sNdpbTag.Data(), febId ); - fHitDt_nDPB.push_back(fHM->H1(sHistName.Data())); - } // if( 0 < fiBinSizeDatePlots && 0 < fiRunStartDateTimeSec ) - - sHistName = Form("ADC_Mean_Sts_n%s_f%1u", sNdpbTag.Data(), febId); - fADC_Mean_Sts.push_back(fHM->H1(sHistName.Data())); - sHistName = Form("ADC_Rms_Sts_n%s_f%1u", sNdpbTag.Data(), febId); - fADC_Rms_Sts.push_back(fHM->H1(sHistName.Data())); - sHistName = Form("ADC_Skew_Sts_n%s_f%1u", sNdpbTag.Data(), febId); - fADC_Skew_Sts.push_back(fHM->H1(sHistName.Data())); - sHistName = Form("ADC_Kurt_Sts_n%s_f%1u", sNdpbTag.Data(), febId); - fADC_Kurt_Sts.push_back(fHM->H1(sHistName.Data())); - } // for( Int_t febId = 0; febId < fNrOfFebsPerNdpb; febId++) - } // for( Int_t dpbId = 0; dpbId < fNrOfNdpbs; dpbId++) - - for( Int_t component = 0; component < kiMaxNbFlibLinks; component ++ ) - { - fhMsSz[ component ] = NULL; - fhMsSzTime[ component ] = NULL; - } // for( Int_t component = 0; component < kiMaxNbFlibLinks; component ++ ) - /*************************************************************************/ -} - -Bool_t CbmTsMonitorSts::DoUnpack(const fles::Timeslice& ts, size_t component) -{ - THttpServer* server = FairRunOnline::Instance()->GetHttpServer(); - - if( bResetStsHistos ) - { - LOG(info) << "Start resetting histos "; - ResetAllHistos(); - bResetStsHistos = kFALSE; - } // if( bResetStsHistos ) - - if( bSaveStsHistos ) - { - LOG(info) << "Start saving histos "; - SaveAllHistos(); - bSaveStsHistos = kFALSE; - } // if( bSaveStsHistos ) - - if( bUpdateAdcHistosSts ) - { - LOG(info) << "Start updatting ADC stats histos "; - UpdateAdcStatHistos(); - bUpdateAdcHistosSts = kFALSE; - } // if( bUpdateAdcHistosSts ) - - LOG(debug) << "Timeslice contains " << ts.num_microslices(component) - << "microslices."; - - if( component < kiMaxNbFlibLinks ) - if( NULL == fhMsSz[ component ] ) - { - TString sMsSzName = Form("MsSz_link_%02lu", component); - TString sMsSzTitle = Form("Size of MS for nDPB of link %02lu; Ms Size [bytes]", component); - fHM->Add(sMsSzName.Data(), new TH1F( sMsSzName.Data(), sMsSzTitle.Data(), - 160000, 0., 20000. ) ); - fhMsSz[ component ] = fHM->H1(sMsSzName.Data()); - if (server) server->Register("/FlibRaw", fhMsSz[ component ] ); - sMsSzName = Form("MsSzTime_link_%02lu", component); - sMsSzTitle = Form("Size of MS vs time for gDPB of link %02lu; Time[s] ; Ms Size [bytes]", component); - fHM->Add(sMsSzName.Data(), new TProfile( sMsSzName.Data(), sMsSzTitle.Data(), - 15000, 0., 300. ) ); - fhMsSzTime[ component ] = fHM->P1(sMsSzName.Data()); - if (server) server->Register("/FlibRaw", fhMsSzTime[ component ] ); - if( NULL != fcMsSizeAll ) - { - fcMsSizeAll->cd( 1 + component ); - gPad->SetLogy(); - fhMsSzTime[ component ]->Draw("hist le0"); - } // if( NULL != fcMsSizeAll ) - LOG(info) << "Added MS size histo for component: " << component - << " (nDPB)"; - } // if( NULL == fhMsSz[ component ] ) - - Int_t messageType = -111; - // Loop over microslices - for (size_t m = 0; m < ts.num_microslices(component); ++m) - { - constexpr uint32_t kuBytesPerMessage = 8; - - auto msDescriptor = ts.descriptor(component, m); - fEquipmentId = msDescriptor.eq_id; - const uint8_t* msContent = reinterpret_cast<const uint8_t*>(ts.content(component, m)); - - uint32_t size = msDescriptor.size; - LOG(debug) << "Microslice: " << msDescriptor.idx - << " has size: " << size; - - if( component < kiMaxNbFlibLinks ) - { - if( fdStartTimeMsSz < 0 ) - fdStartTimeMsSz = (1e-9) * static_cast<double>(msDescriptor.idx); - fhMsSz[ component ]->Fill( size ); - fhMsSzTime[ component ]->Fill( (1e-9) * static_cast<double>( msDescriptor.idx) - fdStartTimeMsSz, size); - } // if( component < kiMaxNbFlibLinks ) - - // If not integer number of message in input buffer, print warning/error - if( 0 != (size % kuBytesPerMessage) ) - LOG(error) << "The input microslice buffer does NOT " - << "contain only complete nDPB messages!"; - - // Compute the number of complete messages in the input microslice buffer - uint32_t uNbMessages = (size - (size % kuBytesPerMessage) ) - / kuBytesPerMessage; - - // Prepare variables for the loop on contents - const uint64_t* pInBuff = reinterpret_cast<const uint64_t*>( msContent ); - UInt_t uNdpbIdx; - UInt_t uFebBase; - for (uint32_t uIdx = 0; uIdx < uNbMessages; uIdx ++) - { - // Fill message - uint64_t ulData = static_cast<uint64_t>( pInBuff[uIdx] ); - ngdpb::Message mess( ulData ); - - if( 0 == uIdx ) - { - Int_t rocId = mess.getRocNumber(); - // First check if nDPB is mapped - if( fNdpbIdIndexMap.end() == fNdpbIdIndexMap.find( rocId ) ) - { - LOG(fatal) << "Unmapped nDPB Id " << std::hex << rocId << std::dec; - } // if( fNdpbIdIndexMap.end() == fNdpbIdIndexMap.find( rocId ) ) - uNdpbIdx = fNdpbIdIndexMap[rocId]; - uFebBase = uNdpbIdx * fNrOfFebsPerNdpb; - } // if( 0 == uIdx ) - - if(gLogger->IsLogNeeded( fair::Severity::debug )) - { - mess.printDataCout(); - } // if(gLogger->IsLogNeeded( fair::Severity::debug )) - - // Increment counter for different message types - // and fill the corresponding histogram - messageType = mess.getMessageType(); - fMsgCounter[messageType]++; - fHistMessType->Fill(messageType); - - switch( messageType ) - { - case ngdpb::MSG_HIT: - FillHitInfo(mess, uNdpbIdx, uFebBase); - break; - case ngdpb::MSG_EPOCH: - FillEpochInfo(mess, uNdpbIdx, uFebBase); - break; - case ngdpb::MSG_SYNC: - // Do nothing, this message is just there to make sure we get all Epochs - break; - case ngdpb::MSG_SYS: - // Just keep track of which type of System message we receive - fHistSysMessType->Fill(mess.getSysMesType()); - break; - default: - LOG(error) << "Message type " << std::hex << std::setw(2) - << static_cast< uint16_t >( mess.getMessageType() ) - << " not yet include in nXYTER unpacker."; - } // switch( messageType ) - } // for (uint32_t uIdx = 0; uIdx < uNbMessages; uIdx ++) - } // for (size_t m = 0; m < ts.num_microslices(component); ++m) - - return kTRUE; -} - -void CbmTsMonitorSts::FillHitInfo(ngdpb::Message mess, UInt_t /*uNdpbIdx*/, UInt_t uFebBase) -{ - // --- Get absolute time, NXYTER and channel number - Int_t rocId = mess.getRocNumber(); - Int_t nxyterId = mess.getNxNumber(); - Int_t nxChannel = mess.getNxChNum(); - Int_t charge = mess.getNxAdcValue(); - - LOG(debug) << "Hit: " << rocId << ", " << nxyterId - << ", " << nxChannel << ", " << charge; - - //here converting channel number into the STS Digi. - -/* - Int_t address = CreateAddress(uFebBase,nxyterId,0, 0, 0, 0, nxChannel); - if (address){ - LOG(debug) << "Got address for hit"; - } - else { - LOG(error) << "Unknown Roc Id " << rocId << " or nxyterId "<< nxyterId << " or channelId " - << nxChannel; - } -*/ - Int_t iFebNr = uFebBase + nxyterId; - fChan_Counts_Sts[iFebNr]->Fill(nxChannel); - fRaw_ADC_Sts[iFebNr]->Fill(nxChannel, charge); - - if( fCurrentEpoch.end() != fCurrentEpoch.find( rocId ) ) - { - if( fCurrentEpoch[rocId].end() != fCurrentEpoch[rocId].find( nxyterId ) ) - { - Double_t dHitFullTime = mess.getMsgFullTimeD( fCurrentEpoch[rocId][nxyterId] ); - - if( fdStartTime <= 0 ) - { - fdStartTime = dHitFullTime; - - LOG(info) << "Start time set to " << (fdStartTime/1e9) - << " s using first hit on channel " << nxChannel - << " of FEB " << nxyterId - << " on nDPB " << fNdpbIdIndexMap[rocId] - << " in epoch " << fCurrentEpoch[rocId][nxyterId]; - } // if( fdStartTime <= 0 ) - - if( 0 < fdStartTime ) - { - fFebRate[iFebNr]->Fill( 1e-9*( dHitFullTime - fdStartTime) ); - - // General Time (date + time) rate evolution - // Add offset of -1H as the filenames were using some times offset by 1 hour (Summer time?!?) - if( 0 < fiBinSizeDatePlots && 0 < fiRunStartDateTimeSec ) - { - fFebRateDate_nDPB[iFebNr]->Fill( - 1e-9 * ( dHitFullTime - fdStartTime ) + fiRunStartDateTimeSec ); - if( 0 < fdLastHitTime_nDPB[ iFebNr ] ) - { - Double_t dTimeDiff = dHitFullTime - fdLastHitTime_nDPB[ iFebNr ]; - fHitDtDate_nDPB[ iFebNr ]->Fill( - 1e-9 * ( dHitFullTime - fdStartTime ) + fiRunStartDateTimeSec, - 1e9/( dTimeDiff ) - ); - if( 0 != dTimeDiff ) - fHitDt_nDPB[ iFebNr ]->Fill( std::abs(dTimeDiff) ); // need abs due to messages not time sorted - } // if( 0 < fdLastHitTime_nDPB[ channelNr ] ) - fdLastHitTime_nDPB[ iFebNr ] = dHitFullTime; - } // if( 0 < fiBinSizeDatePlots && 0 < fiRunStartDateTimeSec ) - } // if( 0 < fdStartTime ) - } // if( fCurrentEpoch[rocId].end() != fCurrentEpoch[rocId].find( nxyterId ) ) - } // if( fCurrentEpoch.end() != fCurrentEpoch.find( rocId ) ) - -} - -/* -Int_t CbmTsMonitorSts::CreateAddress(Int_t febBase, Int_t febId, Int_t stationId, - Int_t layerId, Int_t sideId, Int_t moduleId, Int_t channelId) -{ - Int_t febNr = febBase + febId; - Int_t sector = fUnpackPar->GetPadX(febNr, channelId); - Int_t channel = fUnpackPar->GetPadY(febNr, channelId); - - Int_t address = CbmStsAddress::GetAddress(stationId, layerId, sideId, moduleId, sector, channel); - if(!(sector<0||channel<0)){ - - fHistPadDistr->Fill(78-sector,22-channel); - - } - -// fHM->H2("Pad_Distribution")->Fill(sector,channel); - return address; - return 0; -} -*/ - -void CbmTsMonitorSts::FillEpochInfo(ngdpb::Message mess, UInt_t /*uNdpbIdx*/, UInt_t uFebBase) -{ - Int_t rocId = mess.getRocNumber(); - Int_t nxyterId = mess.getEpochNxNum(); - - UInt_t uEpochVal = mess.getEpochNumber(); - fCurrentEpoch[rocId][nxyterId] = uEpochVal; - fCurrentEpochTime = mess.getMsgFullTimeD( uEpochVal ); - - if( fdStartTime <= 0 ) - { - Int_t channelNr = uFebBase + nxyterId; - fHitMissEvo[channelNr]->Fill( fCurrentEpochTime - fdStartTime, mess.getEpochMissed() ); - } - - fNofEpochs++; - LOG(debug) << "Epoch message " - << fNofEpochs << ", epoch " << uEpochVal - << ", time " << std::setprecision(9) << std::fixed - << fCurrentEpochTime * 1.e-9 << " s " - << " for board ID " << std::hex << std::setw(4) << rocId << std::dec; -} - -void CbmTsMonitorSts::Reset() -{ -} - -void CbmTsMonitorSts::Finish() -{ - TString message_type; - - for (unsigned int i=0; i< fMsgCounter.size(); ++i) { - switch(i) { - case 0: message_type ="NOP"; break; - case 1: message_type ="HIT"; break; - case 2: message_type ="EPOCH"; break; - case 3: message_type ="SYNC"; break; - case 4: message_type ="AUX"; break; - case 5: message_type ="EPOCH2"; break; - case 6: message_type ="GET4"; break; - case 7: message_type ="SYS"; break; - case 8: message_type ="GET4_SLC"; break; - case 9: message_type ="GET4_32B"; break; - case 10: message_type ="GET4_SYS"; break; - } - LOG(info) << message_type << " messages: " - << fMsgCounter[i]; - } - - LOG(info) << "-------------------------------------"; - for( auto it = fCurrentEpoch.begin(); it != fCurrentEpoch.end(); ++it) - for( auto itN = (it->second).begin(); itN != (it->second).end(); ++itN) - LOG(info) << "Last epoch for nDPB: " - << std::hex << std::setw(4) << it->first << std::dec - << " , FEB " << std::setw(4) << itN->first - << " => " << itN->second; - LOG(info) << "-------------------------------------"; - - UpdateAdcStatHistos(); - SaveAllHistos(); -} - - -void CbmTsMonitorSts::FillOutput(boost::any) -{ -} - -void CbmTsMonitorSts::ResetAllHistos() -{ - LOG(info) << "Reseting all STS histograms."; - fHistMessType ->Reset(); - fHistSysMessType->Reset(); - - for( Int_t dpbId = 0; dpbId < fNrOfNdpbs; dpbId++) - {// looping on all the nDPBS IDs - for( Int_t febId = 0; febId < fNrOfFebsPerNdpb; febId++) - {// looping on all the FEB IDs - UInt_t uFebBase = dpbId * fNrOfFebsPerNdpb; - Int_t iFebNr = uFebBase + febId; - fChan_Counts_Sts[iFebNr]->Reset(); - fRaw_ADC_Sts [iFebNr]->Reset(); - fFebRate [iFebNr]->Reset(); - fHitMissEvo [iFebNr]->Reset(); - - if( 0 < fiBinSizeDatePlots && 0 < fiRunStartDateTimeSec ) - { - fFebRateDate_nDPB[iFebNr]->Reset(); - fHitDtDate_nDPB [iFebNr]->Reset(); - fHitDt_nDPB [iFebNr]->Reset(); - } // if( 0 < fiBinSizeDatePlots && 0 < fiRunStartDateTimeSec ) - } // for( Int_t febId = 0; febId < fNrOfFebsPerNdpb; febId++) - } // for( Int_t dpbId = 0; dpbId < fNrOfNdpbs; dpbId++) - - for (UInt_t uLinks = 0; uLinks < kiMaxNbFlibLinks; uLinks++) - { - if( NULL != fhMsSz[uLinks] ) - fhMsSz[uLinks]->Reset(); - if( NULL != fhMsSzTime[uLinks] ) - fhMsSzTime[uLinks]->Reset(); - } // for( UInt_t uLinks = 0; uLinks < 16; uLinks ++) - - fdStartTime = -1; - LOG(info) << "Reset most histos done!"; -} - -void CbmTsMonitorSts::SaveAllHistos() -{ - TDirectory * oldDir = gDirectory; - - TFile * histoFile = new TFile("data/histos_test.root", "RECREATE"); - - histoFile->cd(); - histoFile->mkdir("Sts_Raw"); - histoFile->cd("Sts_Raw"); - - fHistMessType ->Reset(); - fHistSysMessType->Reset(); - - for( Int_t dpbId = 0; dpbId < fNrOfNdpbs; dpbId++) - {// looping on all the nDPBS IDs - for( Int_t febId = 0; febId < fNrOfFebsPerNdpb; febId++) - {// looping on all the FEB IDs - UInt_t uFebBase = dpbId * fNrOfFebsPerNdpb; - Int_t iFebNr = uFebBase + febId; - - fChan_Counts_Sts[iFebNr]->Write(); - fRaw_ADC_Sts [iFebNr]->Write(); - fFebRate [iFebNr]->Write(); - fHitMissEvo [iFebNr]->Write(); - - if( 0 < fiBinSizeDatePlots && 0 < fiRunStartDateTimeSec ) - { - fFebRateDate_nDPB[iFebNr]->Write(); - fHitDtDate_nDPB [iFebNr]->Write(); - fHitDt_nDPB [iFebNr]->Write(); - } // if( 0 < fiBinSizeDatePlots && 0 < fiRunStartDateTimeSec ) - - fADC_Mean_Sts[iFebNr]->Write(); - fADC_Rms_Sts [iFebNr]->Write(); - fADC_Skew_Sts[iFebNr]->Write(); - fADC_Kurt_Sts[iFebNr]->Write(); - } // for( Int_t febId = 0; febId < fNrOfFebsPerNdpb; febId++) - } // for( Int_t dpbId = 0; dpbId < fNrOfNdpbs; dpbId++) - histoFile->cd(".."); - - histoFile->mkdir("Flib_Raw"); - histoFile->cd("Flib_Raw"); - for (UInt_t uLinks = 0; uLinks < kiMaxNbFlibLinks; uLinks++) - { - if( NULL != fhMsSz[uLinks] ) - fhMsSz[uLinks]->Write(); - if( NULL != fhMsSzTime[uLinks] ) - fhMsSzTime[uLinks]->Write(); - } // for( UInt_t uLinks = 0; uLinks < 16; uLinks ++) - histoFile->cd(".."); - - histoFile->Close(); - - oldDir->cd(); - - LOG(info) << "Save all histos done!"; -} - -void CbmTsMonitorSts::UpdateAdcStatHistos() -{ - TH1 * phChanAdcProj = NULL; - for( Int_t dpbId = 0; dpbId < fNrOfNdpbs; dpbId++) - {// looping on all the nDPBS IDs - for( Int_t febId = 0; febId < fNrOfFebsPerNdpb; febId++) - {// looping on all the FEB IDs - UInt_t uFebBase = dpbId * fNrOfFebsPerNdpb; - Int_t channelNr = uFebBase + febId; - - // First reset plots before update - fADC_Mean_Sts[channelNr]->Reset(); - fADC_Rms_Sts [channelNr]->Reset(); - fADC_Skew_Sts[channelNr]->Reset(); - fADC_Kurt_Sts[channelNr]->Reset(); - - for( Int_t iChanId = 0; iChanId < kiNbChanFebF; iChanId ++) - {// looping on all channels - phChanAdcProj = fRaw_ADC_Sts[channelNr]->ProjectionY( Form("_py_%03d", iChanId), - 1 + iChanId, - 1 + iChanId ); - if( 0 < phChanAdcProj->GetEntries() ) - { - fADC_Mean_Sts[channelNr]->Fill( iChanId, phChanAdcProj->GetMean() ); - fADC_Rms_Sts [channelNr]->Fill( iChanId, phChanAdcProj->GetRMS() ); - fADC_Skew_Sts[channelNr]->Fill( iChanId, phChanAdcProj->GetSkewness() ); - fADC_Kurt_Sts[channelNr]->Fill( iChanId, phChanAdcProj->GetKurtosis() ); - } // if( 0 < phChanAdcProj->GetEntries() ) - else - { - fADC_Mean_Sts[channelNr]->Fill( iChanId, 0.0 ); - fADC_Rms_Sts [channelNr]->Fill( iChanId, 0.0 ); - fADC_Skew_Sts[channelNr]->Fill( iChanId, 0.0 ); - fADC_Kurt_Sts[channelNr]->Fill( iChanId, 0.0 ); - } // else of if( 0 < phChanAdcProj->GetEntries() ) - - delete phChanAdcProj; - } - } // for( Int_t febId = 0; febId < fNrOfFebsPerNdpb; febId++) - } // for( Int_t dpbId = 0; dpbId < fNrOfNdpbs; dpbId++) - - LOG(info) << "Update of ADC stats histos done!"; -} - -void CbmTsMonitorSts::SetRunStart( Int_t dateIn, Int_t timeIn, Int_t iBinSize ) -{ - TDatime * fRunStartDateTime = new TDatime( dateIn, timeIn); - fiRunStartDateTimeSec = fRunStartDateTime->Convert(); - fiBinSizeDatePlots = iBinSize; - - LOG(info) << "Assigned new STS Run Start Date-Time: " << fRunStartDateTime->AsString(); -} - -ClassImp(CbmTsMonitorSts) diff --git a/beamtime/cosy2017/unpacker/CbmTsMonitorSts.h b/beamtime/cosy2017/unpacker/CbmTsMonitorSts.h deleted file mode 100644 index 9a1b9591ea6676b5d59dbc9af4266e933731757f..0000000000000000000000000000000000000000 --- a/beamtime/cosy2017/unpacker/CbmTsMonitorSts.h +++ /dev/null @@ -1,115 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmTsMonitorSts ----- -// ----- Created 08.03.2017 by P.-A. Loizeau ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CbmTsMonitorSts_H -#define CbmTsMonitorSts_H - -#include "Timeslice.hpp" -#include "rocMess_wGet4v1.h" - -#include "CbmTSUnpack.h" -#include "CbmHistManager.h" - -#include <vector> -#include <map> - -class CbmStsUnpackPar; // Unpacker Class which will read the StsUnpackPar.par - -class CbmTsMonitorSts: public CbmTSUnpack -{ -public: - - CbmTsMonitorSts(); - virtual ~CbmTsMonitorSts(); - - virtual Bool_t Init(); - - virtual Bool_t DoUnpack(const fles::Timeslice& ts, size_t component); - - virtual void Reset(); - - virtual void Finish(); - - void SetParContainers(); - - Bool_t InitContainers(); - - Bool_t ReInitContainers(); - - void FillOutput(boost::any); - - void SetRunStart( Int_t dateIn, Int_t timeIn, Int_t iBinSize = 5 ); - - void ResetAllHistos(); - - void SaveAllHistos(); - - void UpdateAdcStatHistos(); - -private: - static const Int_t kiNbChanFebF = 128; - - Int_t fNrOfNdpbs; // Total number of NDPBs in the system - Int_t fNrOfNdpbsA; // Total number of NDPBs for GEM A - Int_t fNrOfNdpbsB; // Total number of NDPBs for GEM B - Int_t fNrOfFebsPerNdpb; // Number of FEBs per NDPB - - std::vector<int> fMsgCounter; - std::map<UInt_t, UInt_t> fNdpbIdIndexMap; - - CbmHistManager* fHM; ///< Histogram manager - - std::map<Int_t, std::map<Int_t, UInt_t> > fCurrentEpoch; // Current epoch (first epoch in the stream initialises the map item) - Int_t fNofEpochs; /** Current epoch marker for each ROC **/ - Double_t fCurrentEpochTime; /** Time stamp of current epoch **/ - Double_t fdStartTime; /** Time of first valid hit (epoch available), used as reference for evolution plots**/ - Double_t fdStartTimeMsSz; /** Time of first microslice, used as reference for evolution plots**/ - TCanvas* fcMsSizeAll; - - Int_t fEquipmentId; - - CbmStsUnpackPar* fUnpackPar; //! - - std::vector<TH1*> fFebRateDate_nDPB; - std::vector<TH2*> fHitDtDate_nDPB; - std::vector<TH1*> fHitDt_nDPB; - std::vector<Double_t> fdLastHitTime_nDPB; - Int_t fiRunStartDateTimeSec; - Int_t fiBinSizeDatePlots; - - TH1* fHistMessType; - TH1* fHistSysMessType; - - std::vector<TH1*> fChan_Counts_Sts; - std::vector<TH2*> fRaw_ADC_Sts; - std::vector<TH1*> fFebRate; - std::vector<TH1*> fHitMissEvo; - - std::vector<TH1*> fADC_Mean_Sts; - std::vector<TH1*> fADC_Rms_Sts; - std::vector<TH1*> fADC_Skew_Sts; - std::vector<TH1*> fADC_Kurt_Sts; - - static const Int_t kiMaxNbFlibLinks = 16; - TH1* fhMsSz[kiMaxNbFlibLinks]; - TProfile* fhMsSzTime[kiMaxNbFlibLinks]; - - void CreateHistograms(); - - void FillHitInfo(ngdpb::Message, UInt_t uNdpbIdx, UInt_t uFebBase); - void FillEpochInfo(ngdpb::Message, UInt_t uNdpbIdx, UInt_t uFebBase); - - Int_t CreateAddress(Int_t febBase, Int_t febId, Int_t stationId, Int_t layerId, Int_t sideId, - Int_t moduleId, Int_t channelId); - - CbmTsMonitorSts(const CbmTsMonitorSts&); - CbmTsMonitorSts operator=(const CbmTsMonitorSts&); - - ClassDef(CbmTsMonitorSts, 1) -}; - -#endif diff --git a/beamtime/cosy2018/CMakeLists.txt b/beamtime/cosy2018/CMakeLists.txt deleted file mode 100644 index 3393dbe479ea0de2f1798d23dad902717cf118be..0000000000000000000000000000000000000000 --- a/beamtime/cosy2018/CMakeLists.txt +++ /dev/null @@ -1,64 +0,0 @@ -Set(INCLUDE_DIRECTORIES - ${CBMBASE_DIR} - - ${CBMDATA_DIR} - ${CBMDATA_DIR}/beamtime - ${CBMDATA_DIR}/beamtime/fhodo - ${CBMDATA_DIR}/raw - ${CBMDATA_DIR}/sts - ${CBMDATA_DIR}/much - - ${CBMROOT_SOURCE_DIR}/beamtime/base - - ${CBMROOT_SOURCE_DIR}/beamtime/cern2017/param - - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURREN_SOURCE_DIR}/unpacker -) - -Set(SYSTEM_INCLUDE_DIRECTORIES - ${BASE_INCLUDE_DIRECTORIES} - ${Boost_INCLUDE_DIR} - ${ROOT_INCLUDE_DIR} - ${IPC_INCLUDE_DIRECTORY} - ${CBMROOT_SOURCE_DIR}/external/flib_dpb/flib_dpb - ${CMAKE_SOURCE_DIR}/external/cppzmq -) - -Include_Directories(${INCLUDE_DIRECTORIES}) -Include_Directories(SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES}) - - -Set(LINK_DIRECTORIES - ${ROOT_LIBRARY_DIR} - ${FAIRROOT_LIBRARY_DIR} - ${Boost_LIBRARY_DIRS} -) - -Link_Directories( - ${LINK_DIRECTORIES} -) - -Set(SRCS - unpacker/CbmCosy2018MonitorSts.cxx - unpacker/CbmCosy2018MonitorHodo.cxx - unpacker/CbmCosy2018MonitorSetup.cxx - unpacker/CbmCosy2018MonitorDupli.cxx - unpacker/CbmCosy2018MonitorSetupGood.cxx - unpacker/CbmCosy2018MonitorEfficiency.cxx - unpacker/CbmCosy2018MonitorPulser.cxx - unpacker/CbmCosy2018MonitorScan.cxx -) - -If(_UINT8_T_EXIST) - Add_Definitions(-DHAVE_UINT8_T_HEADER_FILE) - Set(DEFINITIONS HAVE_UINT8_T_HEADER_FILE) -EndIf() - -Set(LINKDEF CbmBeamtimeCosy2018LinkDef.h ) -Set(LIBRARY_NAME CbmBeamtimeCosy2018) -Set(DEPENDENCIES - CbmBeamtimeCern2017 CbmBase CbmBeamtimeBase fles_ipc Eve Base -) - -GENERATE_LIBRARY() diff --git a/beamtime/cosy2018/CbmBeamtimeCosy2018LinkDef.h b/beamtime/cosy2018/CbmBeamtimeCosy2018LinkDef.h deleted file mode 100644 index 6a9d503d6242686635656647f1d3182bbb3a4e07..0000000000000000000000000000000000000000 --- a/beamtime/cosy2018/CbmBeamtimeCosy2018LinkDef.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifdef __CINT__ - -#pragma link off all globals; -#pragma link off all classes; -#pragma link off all functions; - -#pragma link C++ class CbmCosy2018MonitorSts; -#pragma link C++ class CbmCosy2018MonitorHodo; -#pragma link C++ class CbmCosy2018MonitorSetup; -#pragma link C++ class CbmCosy2018MonitorDupli+; -#pragma link C++ class CbmCosy2018MonitorSetupGood; -#pragma link C++ class CbmCosy2018MonitorEfficiency; -#pragma link C++ class CbmCosy2018MonitorPulser; -#pragma link C++ class CbmCosy2018MonitorScan+; - -#endif diff --git a/beamtime/cosy2018/unpacker/CbmCosy2018MonitorDupli.cxx b/beamtime/cosy2018/unpacker/CbmCosy2018MonitorDupli.cxx deleted file mode 100644 index 0ab4c9cf7222b24303252db77e8b17c2c72a1151..0000000000000000000000000000000000000000 --- a/beamtime/cosy2018/unpacker/CbmCosy2018MonitorDupli.cxx +++ /dev/null @@ -1,3989 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmCosy2018MonitorDupli ----- -// ----- Created 27/02/18 by P.-A. Loizeau ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#include "CbmCosy2018MonitorDupli.h" - -// Data - -// CbmRoot -#include "CbmCern2017UnpackParHodo.h" -#include "CbmCern2017UnpackParSts.h" -#include "CbmHistManager.h" - -// FairRoot -#include "FairLogger.h" -#include "FairRootManager.h" -#include "FairRun.h" -#include "FairRuntimeDb.h" -#include "FairRunOnline.h" - -// Root -#include "TClonesArray.h" -#include "TString.h" -#include "TRandom.h" -#include "THttpServer.h" -#include "TROOT.h" -#include "TStyle.h" -#include "THStack.h" -#include <TFile.h> - -// C++11 - -// C/C++ -#include <iostream> -#include <stdint.h> -#include <iomanip> - -Bool_t bCosy2018ResetDupliHistos = kFALSE; -Bool_t bCosy2018WriteDupliHistos = kFALSE; -Bool_t bCosy2018PrintMessDupliHistos = kFALSE; - -CbmCosy2018MonitorDupli::CbmCosy2018MonitorDupli() : - CbmTSUnpack(), - fuOverlapMsNb(0), - fUnpackParHodo(NULL), - fUnpackParSts(NULL), - fuNrOfDpbs(0), - fDpbIdIndexMap(), - fuNbElinksPerDpb(0), - fuNbStsXyters(0), - fuNbChanPerAsic(0), - fvuElinkToAsic(), - fsHistoFileFullname( "data/SetupHistos.root" ), - fbPrintMessages( kFALSE ), - fPrintMessCtrl( stsxyter::MessagePrintMask::msg_print_Human ), - fbDualStsEna( kFALSE ), - fkuNbPrintMessages(5000), - fuPrintMessagesIdx(fkuNbPrintMessages), - fulCurrentTsIdx( 0 ), - fulCurrentMsIdx( 0 ), - fmMsgCounter(), - fuCurrentEquipmentId(0), - fuCurrDpbId(0), - fuCurrDpbIdx(0), - fiRunStartDateTimeSec(-1), - fiBinSizeDatePlots(-1), - fvulCurrentTsMsb(), - fvuCurrentTsMsbCycle(), - fvuElinkLastTsHit(), - fvulChanLastHitTime(), - fvdChanLastHitTime(), - fvdMsTime(), - fvuChanNbHitsInMs(), - fvdChanLastHitTimeInMs(), - fvusChanLastHitAdcInMs(), -// fvmChanHitsInTs(), - fdStartTime(-1.0), - fdStartTimeMsSz(-1.0), - ftStartTimeUnix( std::chrono::steady_clock::now() ), - fvmHitsInTs(), - fLastSortedHit1X(), - fLastSortedHit1Y(), - fLastSortedHit2X(), - fLastSortedHit2Y(), - fLastSortedHit1N(), - fLastSortedHit1P(), - fLastSortedHit2N(), - fLastSortedHit2P(), - fuMaxNbMicroslices(100), - fbLongHistoEnable( kFALSE ), - fuLongHistoNbSeconds( 0 ), - fuLongHistoBinSizeSec( 0 ), - fuLongHistoBinNb( 0 ), - fHM(new CbmHistManager()), - fhHodoMessType(NULL), - fhHodoSysMessType(NULL), - fhHodoMessTypePerDpb(NULL), - fhHodoSysMessTypePerDpb(NULL), - fhHodoMessTypePerElink(NULL), - fhHodoSysMessTypePerElink(NULL), - fhStsRawAdcCombine(NULL), - fhStsRawAdc(), - fhHodoChanCntRaw(), - fhHodoChanAdcRaw(), - fhHodoChanAdcRawProf(), - fhHodoChanRawTs(), - fhHodoChanMissEvt(), - fhHodoChanMissEvtEvo(), - fhHodoChanHitRateEvo(), - fhHodoFebRateEvo(), - fhHodoFebMissEvtEvo(), - fhHodoChanHitRateEvoLong(), - fhHodoFebRateEvoLong(), - fdCoincBorderHodo( 50.0 ), - fdCoincBorderSts( 75.0 ), - fdCoincBorder( 150.0 ), - fhSetupSortedDtX1Y1(NULL), - fhSetupSortedDtX2Y2(NULL), - fhSetupSortedDtN1P1(NULL), - fhSetupSortedDtN2P2(NULL), - fhSetupSortedDtX1Y1X2Y2(NULL), - fhSetupSortedDtN1P1N2P2(NULL), - fhSetupSortedDtX1Y1X2Y2N1P1(NULL), - fhSetupSortedDtX1Y1X2Y2N2P2(NULL), - fhSetupSortedDtH1H2S1S2(NULL), - fhSetupSortedMapX1Y1(NULL), - fhSetupSortedMapX2Y2(NULL), - fhSetupSortedMapN1P1(NULL), - fhSetupSortedMapN2P2(NULL), - fhSetupSortedCntEvoX1Y1(NULL), - fhSetupSortedCntEvoX2Y2(NULL), - fhSetupSortedCntEvoN1P1(NULL), - fhSetupSortedCntEvoN2P2(NULL), - fhBothHodoSortedDtX1Y1(NULL), - fhBothHodoSortedDtX2Y2(NULL), - fhBothHodoSortedDtX1Y1X2Y2N1P1(NULL), - fhBothHodoSortedDtX1Y1X2Y2N2P2(NULL), - fhBothHodoSortedDtH1H2S1S2(NULL), - fhBothHodoSortedMapX1Y1(NULL), - fhBothHodoSortedMapX2Y2(NULL), - fhBothHodoSortedCntEvoX1Y1(NULL), - fhBothHodoSortedCntEvoX2Y2(NULL), - fhH1H2S1SortedDtX1Y1(NULL), - fhH1H2S1SortedDtX2Y2(NULL), - fhH1H2S1SortedDtN1P1(NULL), - fhH1H2S1SortedDtN2P2(NULL), - fhH1H2S1SortedMapX1Y1(NULL), - fhH1H2S1SortedMapX2Y2(NULL), - fhH1H2S1SortedMapN1P1(NULL), - fhH1H2S1SortedMapN2P2(NULL), - fhH1H2S1SortedCntEvoX1Y1(NULL), - fhH1H2S1SortedCntEvoX2Y2(NULL), - fhH1H2S1SortedCntEvoN1P1(NULL), - fhH1H2S1SortedCntEvoN2P2(NULL), - fhH1H2S2SortedDtX1Y1(NULL), - fhH1H2S2SortedDtX2Y2(NULL), - fhH1H2S2SortedDtN1P1(NULL), - fhH1H2S2SortedDtN2P2(NULL), - fhH1H2S2SortedMapX1Y1(NULL), - fhH1H2S2SortedMapX2Y2(NULL), - fhH1H2S2SortedMapN1P1(NULL), - fhH1H2S2SortedMapN2P2(NULL), - fhH1H2S2SortedCntEvoX1Y1(NULL), - fhH1H2S2SortedCntEvoX2Y2(NULL), - fhH1H2S2SortedCntEvoN1P1(NULL), - fhH1H2S2SortedCntEvoN2P2(NULL), - fhSystSortedDtX1Y1(NULL), - fhSystSortedDtX2Y2(NULL), - fhSystSortedDtN1P1(NULL), - fhSystSortedDtN2P2(NULL), - fhSystSortedDtX1Y1X2Y2(NULL), - fhSystSortedMapX1Y1(NULL), - fhSystSortedMapX2Y2(NULL), - fhSystSortedMapN1P1(NULL), - fhSystSortedMapN2P2(NULL), - fhSystSortedCntEvoX1Y1(NULL), - fhSystSortedCntEvoX2Y2(NULL), - fhSystSortedCntEvoN1P1(NULL), - fhSystSortedCntEvoN2P2(NULL), - fhSystSortedDtN1X1vsN1X2(NULL), - fhSystSortedDtP1X1vsP1X2(NULL), - fhSystSortedDtN1X1vsP1X1(NULL), - fhSystSortedDtSts1Hodo1vsSts1Hodo2(NULL), - fhSystSortedDtSts2Hodo1vsSts2Hodo2(NULL), - fhSystSortedDtAllVsMapX1(NULL), - fhSystSortedDtAllVsMapY1(NULL), - fhSystSortedDtAllVsMapX2(NULL), - fhSystSortedDtAllVsMapY2(NULL), - fhSetupSortedDtX1(NULL), - fhSetupSortedDtY1(NULL), - fhSetupSortedDtX2(NULL), - fhSetupSortedDtY2(NULL), - fhSetupSortedDtN1(NULL), - fhSetupSortedDtP1(NULL), - fhSetupSortedDtN2(NULL), - fhSetupSortedDtP2(NULL), - fvulTimeLastHitAsicChan(), - fviAdcLastHitAsicChan(), - fvuNbSameHitAsicChan(), - fvuNbSameFullHitAsicChan(), - fvulStartTimeLastS(), - fvuNbHitDiffTsAsicLastS(), - fvuNbHitSameTsAsicLastS(), - fvuNbHitSameTsAdcAsicLastS(), - fhSetupSortedTsFirstDuplicateChan(), - fhSetupSortedTsGoodChan(), - fhSetupSortedNbSameTsChan(), - fhSetupSortedSameTsAdcChan(), - fhSetupSortedSameTsAdcDiff(), - fhSetupSortedRatioSameTsChan(), - fhSetupSortedNbConsSameTsChan(), - fhSetupSortedNbConsSameTsAdcChan(), - fhSetupSortedNbConsSameTsVsTsAdc(), - fhSetupSortedAsicRatioSameTsVsFlux(), - fhSetupSortedAsicRatioSameTsAdcVsFlux(), - fhSetupSortedAsicRatioSameAdcSameTsVsFlux(), - fhRatioSameTsSpillEvo(), - fhRatioSameTsAdcSpillEvo(), - fhRatioSameAdcSameTsSpillEvo(), - fhFractionHitsAsicSpillEvo(), - fhFractionGoodHitsSpillEvo(), - fhFractionDupliHitsSpillEvo(), - fhFractionTsMsbSpillEvo(), - fhFractionEpochSpillEvo(), - fhFractionEmptySpillEvo(), - fhFractionHitsAsicEvo(), - fhFractionGoodHitsEvo(), - fhFractionDupliHitsEvo(), - fhFractionTsMsbEvo(), - fhFractionEpochEvo(), - fhFractionEmptyEvo(), - fhFractionAsics( NULL ), - fhFractionTypes( NULL ), - fvuNbSameFullHitAsic(), - fvuNbDiffFullHitAsic(), - fvuLastHitBufferIdx(), - fvmLastHitsAsic(), - fhAsicDuplicDtLastHits(), - fhAsicDuplicCompTs(), - fhAsicDuplicTsLsb(), - fhAsicDuplicTsMsbAsic(), - fhAsicDuplicCompTsBitThere(), - fhAsicDuplicTsLsbBitThere(), - fhAsicDuplicTsMsbBitThere(), - fhAsicDuplicTs(), - fhAsicGoodTs(), - fhAsicDuplicTsMsb(), - fhAsicGoodTsMsb(), - fhAsicDuplicTsFull(), - fhAsicGoodTsFull(), - fhAsicDuplicTsBitPattern(), - fhAsicGoodTsBitPattern(), - fhAsicDuplicTsEvoAsic0Chan01( NULL ), - fhAsicGoodTsEvoAsic0Chan01( NULL ), - fhAsicGoodTsMsbEvoAsic0Chan01( NULL ), - fhAsicGoodTsFullEvoAsic0Chan01( NULL ), - fhAsicGoodTsFullEvoProfAsic0Chan01( NULL ), - fhAsicDuplicTsEvoAsic0Chan09( NULL ), - fhAsicGoodTsEvoAsic0Chan09( NULL ), - fhAsicGoodTsFullEvoProfAsic0Chan09( NULL ), - fhAsicDuplicTsEvoAsic0Chan16( NULL ), - fhAsicGoodTsEvoAsic0Chan16( NULL ), - fhAsicGoodTsFullEvoProfAsic0Chan16( NULL ), - fuPulseIdx( 0 ), - fuPulseIdxMax( 32000 ), - fhAsicMissedChanIdVsPulseIdx( NULL ), - fhAsicMissedChanGroupVsPulseIdx( NULL ), - fhHodoChanCntGood(), - fhHodoChanGoodHitRateEvo(), - fhHodoX1SpillEvo(NULL), - fhHodoY1SpillEvo(NULL), - fhHodoX2SpillEvo(NULL), - fhHodoY2SpillEvo(NULL), - fdSpillEvoLength( 700.0 ), - fhHodoX1SpillEvoProf(NULL), - fhHodoY1SpillEvoProf(NULL), - fhHodoX2SpillEvoProf(NULL), - fhHodoY2SpillEvoProf(NULL), - fcMsSizeAll(NULL), - fvuAsicTimeLastPulse(), - fvbPulseThereChan(), - fhPulseChanCountEvo(), - fhHodoChanHitRateEvoZoom(NULL), - fuNbTsMsbSinceLastHit(0), - fuNbHitsLastTsMsb(0) -{ -} - -CbmCosy2018MonitorDupli::~CbmCosy2018MonitorDupli() -{ -} - -Bool_t CbmCosy2018MonitorDupli::Init() -{ - LOG(info) << "Initializing flib StsXyter unpacker for STS"; - - FairRootManager* ioman = FairRootManager::Instance(); - if (ioman == NULL) { - LOG(fatal) << "No FairRootManager instance"; - } - - return kTRUE; -} - -void CbmCosy2018MonitorDupli::SetParContainers() -{ - LOG(info) << "Setting parameter containers for " << GetName(); - fUnpackParHodo = (CbmCern2017UnpackParHodo*)(FairRun::Instance()->GetRuntimeDb()->getContainer("CbmCern2017UnpackParHodo")); - fUnpackParSts = (CbmCern2017UnpackParSts*)(FairRun::Instance()->GetRuntimeDb()->getContainer("CbmCern2017UnpackParSts")); -} - - -Bool_t CbmCosy2018MonitorDupli::InitContainers() -{ - LOG(info) << "Init parameter containers for " << GetName(); - - Bool_t bReInit = ReInitContainers(); - CreateHistograms(); - - return bReInit; -} - -Bool_t CbmCosy2018MonitorDupli::ReInitContainers() -{ - LOG(info) << "ReInit parameter containers for " << GetName(); - - fuNrOfDpbs = fUnpackParHodo->GetNrOfDpbs(); - fuNbElinksPerDpb = fUnpackParHodo->GetNbElinksPerDpb(); - fuNbStsXyters = fUnpackParHodo->GetNbStsXyters(); - fuNbChanPerAsic = fUnpackParHodo->GetNbChanPerAsic(); - - - LOG(info) << "Nr. of STS DPBs: " << fuNrOfDpbs; - - fDpbIdIndexMap.clear(); - fvuElinkToAsic.resize( fuNrOfDpbs ); - for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - { - fDpbIdIndexMap[ fUnpackParHodo->GetDpbId( uDpb ) ] = uDpb; - LOG(info) << "Eq. ID for DPB #" << std::setw(2) << uDpb << " = " - << std::setw(4) << std::hex << fUnpackParHodo->GetDpbId( uDpb ) - << std::dec - << " => " << fDpbIdIndexMap[ fUnpackParHodo->GetDpbId( uDpb ) ]; - - fvuElinkToAsic[uDpb].resize( fuNbElinksPerDpb ); - for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink ) - fvuElinkToAsic[uDpb][uElink] = fUnpackParHodo->GetElinkToAsicIdx( uDpb * fuNbElinksPerDpb + uElink ); - } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - - LOG(info) << "Nr. eLinks per DPB: " << fuNbElinksPerDpb; - LOG(info) << "Nr. of StsXyter ASICs: " << fuNbStsXyters; - LOG(info) << "Nb. channels per ASIC: " << fuNbChanPerAsic; - - for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - { - LOG(info) << "ASIC ID for eLinks in DPB #" << std::setw(2) << uDpb << ": "; - - std::stringstream ss; - for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink ) - { - if( 0 == uElink % 10 ) - ss << "\n------> "; - - ss << std::setw( 5 ) << fvuElinkToAsic[uDpb][uElink] << " "; - } // for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink ) - LOG(info) << ss.str(); - } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - - LOG(info) << "ASIC Idx for Hodo 1: " << fUnpackParHodo->GetAsicIndexHodo1(); - LOG(info) << "ASIC Idx for Hodo 2: " << fUnpackParHodo->GetAsicIndexHodo2(); - - LOG(info) << "XY swapped in Hodo 1: " << fUnpackParHodo->IsXySwappedHodo1(); - LOG(info) << "XY swapped in Hodo 2: " << fUnpackParHodo->IsXySwappedHodo2(); - - LOG(info) << "X axis inverted in Hodo 1: " << fUnpackParHodo->IsXInvertedHodo1(); - LOG(info) << "X axis inverted in Hodo 1: " << fUnpackParHodo->IsYInvertedHodo1(); - LOG(info) << "X axis inverted in Hodo 2: " << fUnpackParHodo->IsXInvertedHodo2(); - LOG(info) << "X axis inverted in Hodo 2: " << fUnpackParHodo->IsYInvertedHodo2(); - - // Internal status initialization - fvulCurrentTsMsb.resize( fuNrOfDpbs ); - fvuCurrentTsMsbCycle.resize( fuNrOfDpbs ); - fvuElinkLastTsHit.resize( fuNrOfDpbs ); - for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - { - fvulCurrentTsMsb[uDpb] = 0; - fvuCurrentTsMsbCycle[uDpb] = 0; -/* - fvuElinkLastTsHit[uDpb].resize( fuNbElinksPerDpb ); - for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink ) - { - fvuElinkLastTsHit[uDpb][uElink] = 0; - } // for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink ) -*/ - } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - - fvulChanLastHitTime.resize( fuNbStsXyters ); - fvdChanLastHitTime.resize( fuNbStsXyters ); - fvdMsTime.resize( fuMaxNbMicroslices ); - fvuChanNbHitsInMs.resize( fuNbStsXyters ); - fvdChanLastHitTimeInMs.resize( fuNbStsXyters ); - fvusChanLastHitAdcInMs.resize( fuNbStsXyters ); -// fvmChanHitsInTs.resize( fuNbStsXyters ); - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fvulChanLastHitTime[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvdChanLastHitTime[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvuChanNbHitsInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvdChanLastHitTimeInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvusChanLastHitAdcInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); -// fvmChanHitsInTs[ uXyterIdx ].resize( fuNbChanPerAsic ); - for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - { - fvulChanLastHitTime[ uXyterIdx ][ uChan ] = 0; - fvdChanLastHitTime[ uXyterIdx ][ uChan ] = -1.0; - - fvuChanNbHitsInMs[ uXyterIdx ][ uChan ].resize( fuMaxNbMicroslices ); - fvdChanLastHitTimeInMs[ uXyterIdx ][ uChan ].resize( fuMaxNbMicroslices ); - fvusChanLastHitAdcInMs[ uXyterIdx ][ uChan ].resize( fuMaxNbMicroslices ); -// fvmChanHitsInTs[ uXyterIdx ][ uChan ].clear(); - for( UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx ) - { - fvuChanNbHitsInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = 0; - fvdChanLastHitTimeInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = -1.0; - fvusChanLastHitAdcInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = 0; - } // for( UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx ) - } // for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - LOG(info) << "CbmCosy2018MonitorDupli::ReInitContainers => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs.size() << " VS " << fuNbStsXyters; - LOG(info) << "CbmCosy2018MonitorDupli::ReInitContainers => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs[ 0 ].size() << " VS " << fuNbChanPerAsic; - LOG(info) << "CbmCosy2018MonitorDupli::ReInitContainers => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs[ 0 ][ 0 ].size() << " VS " << fuMaxNbMicroslices; - - /// Counting of hits without proper timestamp - fvulTimeLastHitAsicChan.resize( fuNbStsXyters ); - fviAdcLastHitAsicChan.resize( fuNbStsXyters ); - fvuNbSameHitAsicChan.resize( fuNbStsXyters ); - fvuNbSameFullHitAsicChan.resize( fuNbStsXyters ); - fvulStartTimeLastS.resize( fuNbStsXyters ); - fvuNbHitDiffTsAsicLastS.resize( fuNbStsXyters ); - fvuNbHitSameTsAsicLastS.resize( fuNbStsXyters ); - fvuNbHitSameTsAdcAsicLastS.resize( fuNbStsXyters ); - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fvulTimeLastHitAsicChan[ uXyterIdx ].resize( fuNbChanPerAsic ); - fviAdcLastHitAsicChan[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvuNbSameHitAsicChan[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvuNbSameFullHitAsicChan[ uXyterIdx ].resize( fuNbChanPerAsic ); - for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - { - fvulTimeLastHitAsicChan[ uXyterIdx ][ uChan ] = 0; - fviAdcLastHitAsicChan[ uXyterIdx ][ uChan ] = 0; - fvuNbSameHitAsicChan[ uXyterIdx ][ uChan ] = 0; - fvuNbSameFullHitAsicChan[ uXyterIdx ][ uChan ] = 0; - } // for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - - fvulStartTimeLastS[ uXyterIdx ] = 0; - fvuNbHitDiffTsAsicLastS[ uXyterIdx ] = 0; - fvuNbHitSameTsAsicLastS[ uXyterIdx ] = 0; - fvuNbHitSameTsAdcAsicLastS[ uXyterIdx ] = 0; - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - - fvuAsicTimeLastPulse.resize( fuNbStsXyters ); - fvbPulseThereChan.resize( fuNbStsXyters ); - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fvuAsicTimeLastPulse[ uXyterIdx ] = 0; - fvbPulseThereChan[ uXyterIdx ].resize( fuNbChanPerAsic ); - for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - { - fvbPulseThereChan[ uXyterIdx ][ uChan ] = kFALSE; - } // for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - - fvuNbSameFullHitAsic.resize( fuNbStsXyters ); - fvuNbDiffFullHitAsic.resize( fuNbStsXyters ); - fvuLastHitBufferIdx.resize( fuNbStsXyters ); - fvmLastHitsAsic.resize( fuNbStsXyters ); - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fvuNbSameFullHitAsic[ uXyterIdx ] = 0; - fvuNbDiffFullHitAsic[ uXyterIdx ] = 0; - fvuLastHitBufferIdx[ uXyterIdx ] = 0; - fvmLastHitsAsic[ uXyterIdx ].resize( fuNbChanPerAsic ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - - LOG(info) << "CbmCosy2018MonitorDupli::ReInitContainers => Dual STS mode: " << fbDualStsEna; - return kTRUE; -} - -void CbmCosy2018MonitorDupli::CreateHistograms() -{ - TString sHistName{""}; - TString title{""}; - - sHistName = "hHodoMessageType"; - title = "Nb of message for each type; Type"; - fhHodoMessType = new TH1I(sHistName, title, 5, 0., 5.); - fhHodoMessType->GetXaxis()->SetBinLabel( 1, "Dummy"); - fhHodoMessType->GetXaxis()->SetBinLabel( 2, "Hit"); - fhHodoMessType->GetXaxis()->SetBinLabel( 3, "TsMsb"); - fhHodoMessType->GetXaxis()->SetBinLabel( 4, "Epoch"); - fhHodoMessType->GetXaxis()->SetBinLabel( 5, "Empty"); -/* *** Missing int + MessType OP!!!! **** - fhHodoMessType->GetXaxis()->SetBinLabel(1 + stsxyter::MessType::Dummy, "Dummy"); - fhHodoMessType->GetXaxis()->SetBinLabel(1 + stsxyter::MessType::Hit, "Hit"); - fhHodoMessType->GetXaxis()->SetBinLabel(1 + stsxyter::MessType::TsMsb, "TsMsb"); - fhHodoMessType->GetXaxis()->SetBinLabel(1 + stsxyter::MessType::ReadDataAck, "ReadDataAck"); - fhHodoMessType->GetXaxis()->SetBinLabel(1 + stsxyter::MessType::Ack, "Ack"); -*/ - - sHistName = "hHodoSysMessType"; - title = "Nb of system message for each type; System Type"; - fhHodoSysMessType = new TH1I(sHistName, title, 17, 0., 17.); -/* - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_START, "DAQ START"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_FINISH, "DAQ FINISH"); - hSysMessType->GetXaxis()->SetBinLabel(1 + 16, "GET4 Hack 32B"); -*/ - - sHistName = "hHodoMessageTypePerDpb"; - title = "Nb of message of each type for each DPB; DPB; Type"; - fhHodoMessTypePerDpb = new TH2I(sHistName, title, fuNrOfDpbs, 0, fuNrOfDpbs, 5, 0., 5.); - fhHodoMessTypePerDpb->GetYaxis()->SetBinLabel( 1, "Dummy"); - fhHodoMessTypePerDpb->GetYaxis()->SetBinLabel( 2, "Hit"); - fhHodoMessTypePerDpb->GetYaxis()->SetBinLabel( 3, "TsMsb"); - fhHodoMessTypePerDpb->GetYaxis()->SetBinLabel( 4, "Epoch"); - fhHodoMessTypePerDpb->GetYaxis()->SetBinLabel( 5, "Empty"); -/* *** Missing int + MessType OP!!!! **** - fhHodoMessType->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Dummy, "Dummy"); - fhHodoMessType->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Hit, "Hit"); - fhHodoMessType->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::TsMsb, "TsMsb"); - fhHodoMessType->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::ReadDataAck, "ReadDataAck"); - fhHodoMessType->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Ack, "Ack"); -*/ - - sHistName = "hHodoSysMessTypePerDpb"; - title = "Nb of system message of each type for each DPB; DPB; System Type"; - fhHodoSysMessTypePerDpb = new TH2I(sHistName, title, fuNrOfDpbs, 0, fuNrOfDpbs, 17, 0., 17.); -/* - hSysMessType->GetYaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_START, "DAQ START"); - hSysMessType->GetYaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_FINISH, "DAQ FINISH"); - hSysMessType->GetYaxis()->SetBinLabel(1 + 16, "GET4 Hack 32B"); -*/ - - sHistName = "hHodoMessageTypePerElink"; - title = "Nb of message of each type for each eLink; eLink; Type"; - fhHodoMessTypePerElink = new TH2I(sHistName, title, fuNrOfDpbs * fuNbElinksPerDpb, 0, fuNrOfDpbs * fuNbElinksPerDpb, 5, 0., 5.); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel( 1, "Dummy"); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel( 2, "Hit"); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel( 3, "TsMsb"); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel( 4, "ReadDataAck"); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel( 5, "Ack"); -/* *** Missing int + MessType OP!!!! **** - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Dummy, "Dummy"); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Hit, "Hit"); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::TsMsb, "TsMsb"); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::ReadDataAck, "ReadDataAck"); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Ack, "Ack"); -*/ - - sHistName = "hHodoSysMessTypePerElink"; - title = "Nb of system message of each type for each eLink; eLink; System Type"; - fhHodoSysMessTypePerElink = new TH2I(sHistName, title, fuNrOfDpbs * fuNbElinksPerDpb, 0, fuNrOfDpbs * fuNbElinksPerDpb, 17, 0., 17.); -/* - fhHodoSysMessTypePerElink->GetYaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_START, "DAQ START"); - fhHodoSysMessTypePerElink->GetYaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_FINISH, "DAQ FINISH"); - fhHodoSysMessTypePerElink->GetYaxis()->SetBinLabel(1 + 16, "GET4 Hack 32B"); -*/ - - // Number of rate bins = - // 9 for the sub-unit decade - // + 9 for each unit of each decade * 10 for the subdecade range - // + 1 for the closing bin top edge - const Int_t iNbDecadesRate = 9; - const Int_t iNbStepsDecade = 9; - const Int_t iNbSubStepsInStep = 10; - const Int_t iNbBinsRate = iNbStepsDecade - + iNbStepsDecade * iNbSubStepsInStep * iNbDecadesRate - + 1; - Double_t dBinsRate[iNbBinsRate]; - // First fill sub-unit decade - for( Int_t iSubU = 0; iSubU < iNbStepsDecade; iSubU ++ ) - dBinsRate[ iSubU ] = 0.1 * ( 1 + iSubU ); - std::cout << std::endl; - // Then fill the main decades - Double_t dSubstepSize = 1.0 / iNbSubStepsInStep; - for( Int_t iDecade = 0; iDecade < iNbDecadesRate; iDecade ++) - { - Double_t dBase = std::pow( 10, iDecade ); - Int_t iDecadeIdx = iNbStepsDecade - + iDecade * iNbStepsDecade * iNbSubStepsInStep; - for( Int_t iStep = 0; iStep < iNbStepsDecade; iStep++ ) - { - Int_t iStepIdx = iDecadeIdx + iStep * iNbSubStepsInStep; - for( Int_t iSubStep = 0; iSubStep < iNbSubStepsInStep; iSubStep++ ) - { - dBinsRate[ iStepIdx + iSubStep ] = dBase * (1 + iStep) - + dBase * dSubstepSize * iSubStep; - } // for( Int_t iSubStep = 0; iSubStep < iNbSubStepsInStep; iSubStep++ ) - } // for( Int_t iStep = 0; iStep < iNbStepsDecade; iStep++ ) - } // for( Int_t iDecade = 0; iDecade < iNbDecadesRate; iDecade ++) - dBinsRate[ iNbBinsRate - 1 ] = std::pow( 10, iNbDecadesRate ); - - UInt_t uAlignedLimit = fuLongHistoNbSeconds - (fuLongHistoNbSeconds % fuLongHistoBinSizeSec); - fuLongHistoBinNb = uAlignedLimit / fuLongHistoBinSizeSec; - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - // Channel counts - sHistName = Form( "hHodoChanCntRaw_%03u", uXyterIdx ); - title = Form( "Hits Count per channel, StsXyter #%03u; Channel; Hits []", uXyterIdx ); - fhHodoChanCntRaw.push_back( new TH1I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - - // Raw Adc Distribution - sHistName = Form( "hHodoChanAdcRaw_%03u", uXyterIdx ); - title = Form( "Raw Adc distribution per channel, StsXyter #%03u; Channel []; Adc []; Hits []", uXyterIdx ); - fhHodoChanAdcRaw.push_back( new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - stsxyter::kuHitNbAdcBins, -0.5, stsxyter::kuHitNbAdcBins -0.5 ) ); - - // Raw Adc Distribution profile - sHistName = Form( "hHodoChanAdcRawProfc_%03u", uXyterIdx ); - title = Form( "Raw Adc prodile per channel, StsXyter #%03u; Channel []; Adc []", uXyterIdx ); - fhHodoChanAdcRawProf.push_back( new TProfile(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - - // Raw Ts Distribution - sHistName = Form( "hHodoChanRawTs_%03u", uXyterIdx ); - title = Form( "Raw Timestamp distribution per channel, StsXyter #%03u; Channel []; Ts []; Hits []", uXyterIdx ); - fhHodoChanRawTs.push_back( new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - stsxyter::kuHitNbTsBins, -0.5, stsxyter::kuHitNbTsBins -0.5 ) ); - - // Missed event flag - sHistName = Form( "hHodoChanMissEvt_%03u", uXyterIdx ); - title = Form( "Missed Event flags per channel, StsXyter #%03u; Channel []; Miss Evt []; Hits []", uXyterIdx ); - fhHodoChanMissEvt.push_back( new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - 2, -0.5, 1.5 ) ); - - // Missed event flag counts evolution - - sHistName = Form( "hHodoChanMissEvtEvo_%03u", uXyterIdx ); - title = Form( "Missed Evt flags per second & channel in StsXyter #%03u; Time [s]; Channel []; Missed Evt flags []", uXyterIdx ); - fhHodoChanMissEvtEvo.push_back( new TH2I( sHistName, title, - 1800, 0, 1800, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - - // Missed event flag counts evo per StsXyter - - sHistName = Form( "hHodoFebMissEvtEvo%03u", uXyterIdx ); - title = Form( "Missed Evt flags per second in StsXyter #%03u; Time [s]; Missed Evt flags []", uXyterIdx ); - fhHodoFebMissEvtEvo.push_back( new TH1I(sHistName, title, 1800, 0, 1800 ) ); - - // Hit rates evo per channel - sHistName = Form( "hHodoChanRateEvo_%03u", uXyterIdx ); - title = Form( "Hits per second & channel in StsXyter #%03u; Time [s]; Channel []; Hits []", uXyterIdx ); - fhHodoChanHitRateEvo.push_back( new TH2I( sHistName, title, - 1800, 0, 1800, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - - // Hit rates evo per StsXyter - sHistName = Form( "hHodoFebRateEvo_%03u", uXyterIdx ); - title = Form( "Hits per second in StsXyter #%03u; Time [s]; Hits []", uXyterIdx ); - fhHodoFebRateEvo.push_back( new TH1I(sHistName, title, 1800, 0, 1800 ) ); - - // Hit rates evo per channel, 1 minute bins, 24h - sHistName = Form( "hHodoChanRateEvoLong_%03u", uXyterIdx ); - title = Form( "Hits per second & channel in StsXyter #%03u; Time [min]; Channel []; Hits []", uXyterIdx ); - fhHodoChanHitRateEvoLong.push_back( new TH2D( sHistName, title, - fuLongHistoBinNb, -0.5, uAlignedLimit - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - - // Hit rates evo per StsXyter, 1 minute bins, 24h - sHistName = Form( "hHodoFebRateEvoLong_%03u", uXyterIdx ); - title = Form( "Hits per second in StsXyter #%03u; Time [min]; Hits []", uXyterIdx ); - fhHodoFebRateEvoLong.push_back( new TH1D(sHistName, title, fuLongHistoBinNb, -0.5, uAlignedLimit - 0.5 ) ); - -/* - if( kTRUE == fbLongHistoEnable ) - { - - sHistName = Form( "hFebRateEvoLong_%03u", uXyterIdx ); - title = Form( "Mean rate VS run time in same MS in StsXyter #%03u; Time in run [s]; Rate [1/s]", uXyterIdx ); - fhFebRateEvoLong.push_back( new TH1D( sHistName, title, - fuLongHistoBinNb, -0.5, uAlignedLimit - 0.5) ); - if( server ) server->Register("/StsRaw", fhFebRateEvoLong[ uXyterIdx ] ); - - sHistName = Form( "hFebChRateEvoLong_%03u", uXyterIdx ); - title = Form( "Mean rate per channel VS run time in StsXyter #%03u; Time in run [s]; Channel []; Rare [1/s]", uXyterIdx ); - fhFebChRateEvoLong.push_back( new TH2D( sHistName, title, - fuLongHistoBinNb, -0.5, uAlignedLimit - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - if( server ) server->Register("/StsRaw", fhFebChRateEvoLong[ uXyterIdx ] ); - } // if( kTRUE == fbLongHistoEnable ) -*/ - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - - UInt_t uNbBinEvo = 32768 + 1; - Double_t dMaxEdgeEvo = stsxyter::kdClockCycleNs - * static_cast< Double_t >( uNbBinEvo ) / 2.0; - Double_t dMinEdgeEvo = dMaxEdgeEvo * -1.0; - - UInt_t uNbBinDtHodo = static_cast<UInt_t>( fdCoincBorderHodo/stsxyter::kdClockCycleNs ); - UInt_t uNbBinDtBothHodo = static_cast<UInt_t>( 2*fdCoincBorderHodo/stsxyter::kdClockCycleNs ); - UInt_t uNbBinDtSts = static_cast<UInt_t>( fdCoincBorderSts/stsxyter::kdClockCycleNs ); -// UInt_t uNbBinDtSyst = static_cast<UInt_t>( fdCoincBorder/stsxyter::kdClockCycleNs ); - - /// Coincidences inside each detector ----------------------------/// - sHistName = "fhSetupSortedDtX1Y1"; - title = "Time diff for hits Hodo 1 X and Hodo 1 Y; tY1 - tX1 [ns]; Counts"; - fhSetupSortedDtX1Y1 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhSetupSortedDtX2Y2"; - title = "Time diff for hits Hodo 2 X and Hodo 2 Y; tY2 - tX2 [ns]; Counts"; - fhSetupSortedDtX2Y2 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhSetupSortedDtN1P1"; - title = "Time diff for hits Sts 1 N and Sts 1 P; tP1 - tN1 [ns]; Counts"; - fhSetupSortedDtN1P1 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhSetupSortedDtN2P2"; - title = "Time diff for hits Sts 2 N and Sts 2 P; tP2 - tN2 [ns]; Counts"; - fhSetupSortedDtN2P2 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhSetupSortedDtX1Y1X2Y2"; - title = "Time diff for hits Hodo 1 (X,Y) vs Hodo 2 (X,Y); t<X2,Y2> - t<X1,Y1> [ns]; Counts"; - fhSetupSortedDtX1Y1X2Y2 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhSetupSortedDtN1P1N2P2"; - title = "Time diff for hits STS 1 (N,P) vs STS 2 (N,P); t<N2,P2> - t<N1,P1> [ns]; Counts"; - fhSetupSortedDtN1P1N2P2 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhSetupSortedDtX1Y1X2Y2N1P1"; - title = "Time diff for hits Hodo (X1,Y1,X2,Y2) vs Sts 1 (N,P); t<N1,P1> - t<X1,Y1,X2,Y2> [ns]; Counts"; - fhSetupSortedDtX1Y1X2Y2N1P1 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhSetupSortedDtX1Y1X2Y2N2P2"; - title = "Time diff for hits Hodo (X1,Y1,X2,Y2) vs Sts 2 (N,P); t<N2,P2> - t<X1,Y1,X2,Y2> [ns]; Counts"; - fhSetupSortedDtX1Y1X2Y2N2P2 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhSetupSortedDtH1H2S1S2"; - title = "Time diff for hits Hodo (X1,Y1,X2,Y2) vs Sts (N1,P1,N2,P2); t<N1,P1,N2,P2> - t<X1,Y1,X2,Y2> [ns]; Counts"; - fhSetupSortedDtH1H2S1S2 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhSetupSortedMapX1Y1"; - title = "Sorted hits in coincidence for hodoscope 1 axis X and Y; X channel Hodo 1 []; Y channel Hodo 1 []; hits []"; - fhSetupSortedMapX1Y1 = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhSetupSortedMapX2Y2"; - title = "Sorted hits in coincidence for hodoscope 2 axis X and Y; X channel Hodo 2 []; Y channel Hodo 2 []; hits []"; - fhSetupSortedMapX2Y2 = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhSetupSortedMapN1P1"; - title = "Sorted hits in coincidence for Sts 1 sides N and P; N channel Sts 1 []; P channel Sts 1 []; hits []"; - fhSetupSortedMapN1P1 = new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - - sHistName = "fhSetupSortedMapN2P2"; - title = "Sorted hits in coincidence for Sts 2 sides N and P; N channel Sts 2 []; P channel Sts 2 []; hits []"; - fhSetupSortedMapN2P2 = new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - - // Coincidence counts evolution between some axis of the hodoscopes - sHistName = "hSetupSortedCntEvoX1Y1"; - title = "Nb of coincidences in both X1 and Y1 per s; Time [s]; X1-Y1 coincidences []"; - fhSetupSortedCntEvoX1Y1 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "hSetupSortedCntEvoX2Y2"; - title = "Nb of coincidences in both X2 and Y2 per s; Time [s]; X2-Y2 coincidences []"; - fhSetupSortedCntEvoX2Y2 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "hSetupSortedCntEvoN1P1"; - title = "Nb of coincidences in both N1 and P1 per s; Time [s]; N1-P1 coincidences []"; - fhSetupSortedCntEvoN1P1 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "hSetupSortedCntEvoN2P2"; - title = "Nb of coincidences in both N2 and P2 per s; Time [s]; N2-P2 coincidences []"; - fhSetupSortedCntEvoN2P2 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - /// Coincidences between hodoscopes ------------------------------/// - sHistName = "fhBothHodoSortedDtX1Y1"; - title = "Time diff for hits Hodo 1 X and Hodo 1 Y; tY1 - tX1 [ns]; Counts"; - fhBothHodoSortedDtX1Y1 = new TH1I(sHistName, title, uNbBinDtHodo, -fdCoincBorderHodo, fdCoincBorderHodo ); - - sHistName = "fhBothHodoSortedDtX2Y2"; - title = "Time diff for hits Hodo 2 X and Hodo 2 Y; tY2 - tX2 [ns]; Counts"; - fhBothHodoSortedDtX2Y2 = new TH1I(sHistName, title, uNbBinDtHodo, -fdCoincBorderHodo, fdCoincBorderHodo ); - - sHistName = "fhBothHodoSortedDtX1Y1X2Y2N1P1"; - title = "Time diff for hits Hodo (X1,Y1,X2,Y2) vs Sts 1 (N,P); t<N1,P1> - t<X1,Y1,X2,Y2> [ns]; Counts"; - fhBothHodoSortedDtX1Y1X2Y2N1P1 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhBothHodoSortedDtX1Y1X2Y2N2P2"; - title = "Time diff for hits Hodo (X1,Y1,X2,Y2) vs Sts 2 (N,P); t<N2,P2> - t<X1,Y1,X2,Y2> [ns]; Counts"; - fhBothHodoSortedDtX1Y1X2Y2N2P2 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhBothHodoSortedDtH1H2S1S2"; - title = "Time diff for hits Hodo (X1,Y1,X2,Y2) vs Sts (N1,P1,N2,P2); t<N1,P1,N2,P2> - t<X1,Y1,X2,Y2> [ns]; Counts"; - fhBothHodoSortedDtH1H2S1S2 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhBothHodoSortedMapX1Y1"; - title = "Sorted hits in coincidence for hodoscope 1 axis X and Y; X channel Hodo 1 []; Y channel Hodo 1 []; hits []"; - fhBothHodoSortedMapX1Y1 = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhBothHodoSortedMapX2Y2"; - title = "Sorted hits in coincidence for hodoscope 2 axis X and Y; X channel Hodo 2 []; Y channel Hodo 2 []; hits []"; - fhBothHodoSortedMapX2Y2 = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - // Coincidence counts evolution between some axis of the hodoscopes - sHistName = "hBothHodoSortedCntEvoX1Y1"; - title = "Nb of coincidences in both X1 and Y1 per s; Time [s]; X1-Y1 coincidences []"; - fhBothHodoSortedCntEvoX1Y1 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "hBothHodoSortedCntEvoX2Y2"; - title = "Nb of coincidences in both X2 and Y2 per s; Time [s]; X2-Y2 coincidences []"; - fhBothHodoSortedCntEvoX2Y2 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - /// Coincidences between hodoscopes and STS 1 --------------------/// - sHistName = "fhH1H2S1SortedDtX1Y1"; - title = "Time diff for hits Hodo 1 X and Hodo 1 Y; tY1 - tX1 [ns]; Counts"; - fhH1H2S1SortedDtX1Y1 = new TH1I(sHistName, title, uNbBinDtHodo, -fdCoincBorderHodo, fdCoincBorderHodo ); - - sHistName = "fhH1H2S1SortedDtX2Y2"; - title = "Time diff for hits Hodo 2 X and Hodo 2 Y; tY2 - tX2 [ns]; Counts"; - fhH1H2S1SortedDtX2Y2 = new TH1I(sHistName, title, uNbBinDtHodo, -fdCoincBorderHodo, fdCoincBorderHodo ); - - sHistName = "fhH1H2S1SortedDtN1P1"; - title = "Time diff for hits Sts 1 N and Sts 1 P; tP1 - tN1 [ns]; Counts"; - fhH1H2S1SortedDtN1P1 = new TH1I(sHistName, title, uNbBinDtSts, -fdCoincBorderSts, fdCoincBorderSts ); - - sHistName = "fhH1H2S1SortedDtN2P2"; - title = "Time diff for hits Sts 2 N and Sts 1 P; tP2 - tN2 [ns]; Counts"; - fhH1H2S1SortedDtN2P2 = new TH1I(sHistName, title, uNbBinDtSts, -fdCoincBorderSts, fdCoincBorderSts ); - - sHistName = "fhH1H2S1SortedMapX1Y1"; - title = "Sorted hits in coincidence for hodoscope 1 axis X and Y; X channel Hodo 1 []; Y channel Hodo 1 []; hits []"; - fhH1H2S1SortedMapX1Y1 = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhH1H2S1SortedMapX2Y2"; - title = "Sorted hits in coincidence for hodoscope 2 axis X and Y; X channel Hodo 2 []; Y channel Hodo 2 []; hits []"; - fhH1H2S1SortedMapX2Y2 = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhH1H2S1SortedMapN1P1"; - title = "Sorted hits in coincidence for Sts 1 sides N and P; N channel Sts 1 []; P channel Sts 1 []; hits []"; - fhH1H2S1SortedMapN1P1 = new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - - sHistName = "fhH1H2S1SortedMapN2P2"; - title = "Sorted hits in coincidence for Sts 2 sides N and P; N channel Sts 2 []; P channel Sts 2 []; hits []"; - fhH1H2S1SortedMapN2P2 = new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - - sHistName = "hH1H2S1SortedCntEvoX1Y1"; - title = "Nb of coincidences in both X1 and Y1 per s; Time [s]; X1-Y1 coincidences []"; - fhH1H2S1SortedCntEvoX1Y1 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "hH1H2S1SortedCntEvoX2Y2"; - title = "Nb of coincidences in both X2 and Y2 per s; Time [s]; X2-Y2 coincidences []"; - fhH1H2S1SortedCntEvoX2Y2 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "hH1H2S1SortedCntEvoN1P1"; - title = "Nb of coincidences in both N1 and P1 per s; Time [s]; N1-P1 coincidences []"; - fhH1H2S1SortedCntEvoN1P1 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "hH1H2S1SortedCntEvoN2P2"; - title = "Nb of coincidences in both N2 and P2 per s; Time [s]; N2-P2 coincidences []"; - fhH1H2S1SortedCntEvoN2P2 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - /// Coincidences between hodoscopes and STS 2 --------------------/// - sHistName = "fhH1H2S2SortedDtX1Y1"; - title = "Time diff for hits Hodo 1 X and Hodo 1 Y; tY1 - tX1 [ns]; Counts"; - fhH1H2S2SortedDtX1Y1 = new TH1I(sHistName, title, uNbBinDtHodo, -fdCoincBorderHodo, fdCoincBorderHodo ); - - sHistName = "fhH1H2S2SortedDtX2Y2"; - title = "Time diff for hits Hodo 2 X and Hodo 2 Y; tY2 - tX2 [ns]; Counts"; - fhH1H2S2SortedDtX2Y2 = new TH1I(sHistName, title, uNbBinDtHodo, -fdCoincBorderHodo, fdCoincBorderHodo ); - - sHistName = "fhH1H2S2SortedDtN1P1"; - title = "Time diff for hits Sts 1 N and Sts 1 P; tP1 - tN1 [ns]; Counts"; - fhH1H2S2SortedDtN1P1 = new TH1I(sHistName, title, uNbBinDtSts, -fdCoincBorderSts, fdCoincBorderSts ); - - sHistName = "fhH1H2S2SortedDtN2P2"; - title = "Time diff for hits Sts 2 N and Sts 1 P; tP2 - tN2 [ns]; Counts"; - fhH1H2S2SortedDtN2P2 = new TH1I(sHistName, title, uNbBinDtSts, -fdCoincBorderSts, fdCoincBorderSts ); - - sHistName = "fhH1H2S2SortedMapX1Y1"; - title = "Sorted hits in coincidence for hodoscope 1 axis X and Y; X channel Hodo 1 []; Y channel Hodo 1 []; hits []"; - fhH1H2S2SortedMapX1Y1 = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhH1H2S2SortedMapX2Y2"; - title = "Sorted hits in coincidence for hodoscope 2 axis X and Y; X channel Hodo 2 []; Y channel Hodo 2 []; hits []"; - fhH1H2S2SortedMapX2Y2 = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhH1H2S2SortedMapN1P1"; - title = "Sorted hits in coincidence for Sts 1 sides N and P; N channel Sts 1 []; P channel Sts 1 []; hits []"; - fhH1H2S2SortedMapN1P1 = new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - - sHistName = "fhH1H2S2SortedMapN2P2"; - title = "Sorted hits in coincidence for Sts 2 sides N and P; N channel Sts 2 []; P channel Sts 2 []; hits []"; - fhH1H2S2SortedMapN2P2 = new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - - sHistName = "hH1H2S2SortedCntEvoX1Y1"; - title = "Nb of coincidences in both X1 and Y1 per s; Time [s]; X1-Y1 coincidences []"; - fhH1H2S2SortedCntEvoX1Y1 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "hH1H2S2SortedCntEvoX2Y2"; - title = "Nb of coincidences in both X2 and Y2 per s; Time [s]; X2-Y2 coincidences []"; - fhH1H2S2SortedCntEvoX2Y2 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "hH1H2S2SortedCntEvoN1P1"; - title = "Nb of coincidences in both N1 and P1 per s; Time [s]; N1-P1 coincidences []"; - fhH1H2S2SortedCntEvoN1P1 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "hH1H2S2SortedCntEvoN2P2"; - title = "Nb of coincidences in both N2 and P2 per s; Time [s]; N2-P2 coincidences []"; - fhH1H2S2SortedCntEvoN2P2 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - /// Coincidences between hodoscopes and both STS -----------------/// - sHistName = "fhSystSortedDtX1Y1"; - title = "Time diff for hits Hodo 1 X and Hodo 1 Y; tY1 - tX1 [ns]; Counts"; - fhSystSortedDtX1Y1 = new TH1I(sHistName, title, uNbBinDtHodo, -fdCoincBorderHodo, fdCoincBorderHodo ); - - sHistName = "fhSystSortedDtX2Y2"; - title = "Time diff for hits Hodo 2 X and Hodo 2 Y; tY2 - tX2 [ns]; Counts"; - fhSystSortedDtX2Y2 = new TH1I(sHistName, title, uNbBinDtHodo, -fdCoincBorderHodo, fdCoincBorderHodo ); - - sHistName = "fhSystSortedDtN1P1"; - title = "Time diff for hits Sts 1 N and Sts 1 P; tP1 - tN1 [ns]; Counts"; - fhSystSortedDtN1P1 = new TH1I(sHistName, title, uNbBinDtSts, -fdCoincBorderSts, fdCoincBorderSts ); - - sHistName = "fhSystSortedDtN2P2"; - title = "Time diff for hits Sts 2 N and Sts 1 P; tP2 - tN2 [ns]; Counts"; - fhSystSortedDtN2P2 = new TH1I(sHistName, title, uNbBinDtSts, -fdCoincBorderSts, fdCoincBorderSts ); - - sHistName = "fhSystSortedDtX1Y1X2Y2"; - title = "Time diff for hits Hodo 1 (X,Y) vs Hodo 2 (X,Y); t<X2,Y2> - t<X1,Y1> [ns]; Counts"; - fhSystSortedDtX1Y1X2Y2 = new TH1I(sHistName, title, uNbBinDtBothHodo, -2*fdCoincBorderHodo, 2*fdCoincBorderHodo ); - - sHistName = "fhSystSortedMapX1Y1"; - title = "Sorted hits in coincidence for hodoscope 1 axis X and Y; X channel Hodo 1 []; Y channel Hodo 1 []; hits []"; - fhSystSortedMapX1Y1 = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhSystSortedMapX2Y2"; - title = "Sorted hits in coincidence for hodoscope 2 axis X and Y; X channel Hodo 2 []; Y channel Hodo 2 []; hits []"; - fhSystSortedMapX2Y2 = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhSystSortedMapN1P1"; - title = "Sorted hits in coincidence for Sts 1 sides N and P; N channel Sts 1 []; P channel Sts 1 []; hits []"; - fhSystSortedMapN1P1 = new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - - sHistName = "fhSystSortedMapN2P2"; - title = "Sorted hits in coincidence for Sts 2 sides N and P; N channel Sts 2 []; P channel Sts 2 []; hits []"; - fhSystSortedMapN2P2 = new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - - // Coincidence counts evolution between some axis of the hodoscopes - sHistName = "hSystSortedCntEvoX1Y1"; - title = "Nb of coincidences in both X1 and Y1 per s; Time [s]; X1-Y1 coincidences []"; - fhSystSortedCntEvoX1Y1 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "hSystSortedCntEvoX2Y2"; - title = "Nb of coincidences in both X2 and Y2 per s; Time [s]; X2-Y2 coincidences []"; - fhSystSortedCntEvoX2Y2 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "hSystSortedCntEvoN1P1"; - title = "Nb of coincidences in both N1 and P1 per s; Time [s]; N1-P1 coincidences []"; - fhSystSortedCntEvoN1P1 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "hSystSortedCntEvoN2P2"; - title = "Nb of coincidences in both N2 and P2 per s; Time [s]; N2-P2 coincidences []"; - fhSystSortedCntEvoN2P2 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "fhSystSortedDtN1X1vsN1X2"; - title = "Time diff (N1 vs X1) vs (N1 vs X2); tN1 - tX1 [ns]; tN1 - tX2 [ns]; Counts"; - fhSystSortedDtN1X1vsN1X2 = new TH2I(sHistName, title, 200, -400, 400, 200, -400, 400 ); - - sHistName = "fhSystSortedDtP1X1vsP1X2"; - title = "Time diff (P1 vs X1) vs (P1 vs X2); tP1 - tX1 [ns]; tP1 - tX2 [ns]; Counts"; - fhSystSortedDtP1X1vsP1X2 = new TH2I(sHistName, title, 200, -400, 400, 200, -400, 400 ); - - sHistName = "fhSystSortedDtN1X1vsP1X1"; - title = "Time diff (N1 vs X1) vs (P1 vs X1); tN1 - tX1 [ns]; tP1 - tX1 [ns]; Counts"; - fhSystSortedDtN1X1vsP1X1 = new TH2I(sHistName, title, 200, -400, 400, 200, -400, 400 ); - - sHistName = "fhSystSortedDtSts1Hodo1vsSts1Hodo2"; - title = "Time diff (Sts1 vs Hodo1) vs (Sts1 vs Hodo2); t<N1,P1> - t<X1,Y1> [ns]; t<N1,P1> - t<X2,Y2> [ns]; Counts"; - fhSystSortedDtSts1Hodo1vsSts1Hodo2 = new TH2I(sHistName, title, 200, -400, 400, 200, -400, 400 ); - - sHistName = "fhSystSortedDtSts2Hodo1vsSts2Hodo2"; - title = "Time diff (Sts2 vs Hodo1) vs (Sts2 vs Hodo2); t<N2,P2> - t<X1,Y1> [ns]; t<N2,P2> - t<X2,Y2> [ns]; Counts"; - fhSystSortedDtSts2Hodo1vsSts2Hodo2 = new TH2I(sHistName, title, 200, -400, 400, 200, -400, 400 ); - - sHistName = "fhSystSortedDtAllVsMapX1"; - title = "Time diff Hodo (X1,Y1,X2,Y2) Sts 1 (N,P) vs Hodo 1 axis X; t<N1,P1> - t<X1,Y1,X2,Y2> [ns]; X channel Hodo 1 []; hits []"; - fhSystSortedDtAllVsMapX1 = new TH2I( sHistName, title, - static_cast< Int_t >(2*fdCoincBorder), -fdCoincBorder, fdCoincBorder, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhSystSortedDtAllVsMapY1"; - title = "Time diff Hodo (X1,Y1,X2,Y2) Sts 1 (N,P) vs Hodo 1 axis Y; t<N1,P1> - t<X1,Y1,X2,Y2> [ns]; Y channel Hodo 1 []; hits []"; - fhSystSortedDtAllVsMapY1 = new TH2I( sHistName, title, - static_cast< Int_t >(2*fdCoincBorder), -fdCoincBorder, fdCoincBorder, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhSystSortedDtAllVsMapX2"; - title = "Time diff Hodo (X1,Y1,X2,Y2) Sts 1 (N,P) vs Hodo 2 axis X; t<N1,P1> - t<X1,Y1,X2,Y2> [ns]; X channel Hodo 2 []; hits []"; - fhSystSortedDtAllVsMapX2 = new TH2I( sHistName, title, - static_cast< Int_t >(2*fdCoincBorder), -fdCoincBorder, fdCoincBorder, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhSystSortedDtAllVsMapY2"; - title = "Time diff Hodo (X1,Y1,X2,Y2) Sts 1 (N,P) vs Hodo 2 axis Y; t<N1,P1> - t<X1,Y1,X2,Y2> [ns]; Y channel Hodo 2 []; hits []"; - fhSystSortedDtAllVsMapY2 = new TH2I( sHistName, title, - static_cast< Int_t >(2*fdCoincBorder), -fdCoincBorder, fdCoincBorder, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - sHistName = "fhSetupSortedDtX1"; - title = "Time diff for consecutive hits in Hodo 1 X; tX1n - tX1 [ns]; Counts"; - fhSetupSortedDtX1 = new TH1I(sHistName, title, uNbBinEvo, -0.5, 2*dMaxEdgeEvo -0.5 ); - - sHistName = "fhSetupSortedDtY1"; - title = "Time diff for consecutive hits in Hodo 1 Y; tY1n - tY1 [ns]; Counts"; - fhSetupSortedDtY1 = new TH1I(sHistName, title, uNbBinEvo, -0.5, 2*dMaxEdgeEvo -0.5); - - sHistName = "fhSetupSortedDtX2"; - title = "Time diff for consecutive hits in Hodo 2 X; tX2n - tX2 [ns]; Counts"; - fhSetupSortedDtX2 = new TH1I(sHistName, title, uNbBinEvo, -0.5, 2*dMaxEdgeEvo -0.5); - - sHistName = "fhSetupSortedDtY2"; - title = "Time diff for consecutive hits in Hodo 2 Y; tY2n - tY2 [ns]; Counts"; - fhSetupSortedDtY2 = new TH1I(sHistName, title, uNbBinEvo, -0.5, 2*dMaxEdgeEvo -0.5); - - sHistName = "fhSetupSortedDtN1"; - title = "Time diff for consecutive hits in Sts 1 Y; tN1n - tN1 [ns]; Counts"; - fhSetupSortedDtN1 = new TH1I(sHistName, title, uNbBinEvo, -0.5, 2*dMaxEdgeEvo -0.5); - - sHistName = "fhSetupSortedDtP1"; - title = "Time diff for consecutive hits in Sts 1 Y; tP1n - tP1 [ns]; Counts"; - fhSetupSortedDtP1 = new TH1I(sHistName, title, uNbBinEvo, -0.5, 2*dMaxEdgeEvo -0.5); - - sHistName = "fhSetupSortedDtN2"; - title = "Time diff for consecutive hits in Sts 1 Y; tN2n - tN2 [ns]; Counts"; - fhSetupSortedDtN2 = new TH1I(sHistName, title, uNbBinEvo, -0.5, 2*dMaxEdgeEvo -0.5); - - sHistName = "fhSetupSortedDtP2"; - title = "Time diff for consecutive hits in Sts 1 Y; tP2n - tP2 [ns]; Counts"; - fhSetupSortedDtP2 = new TH1I(sHistName, title, uNbBinEvo, -0.5, 2*dMaxEdgeEvo -0.5); -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - - -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - Double_t dAdcMinMax = stsxyter::kuHitNbAdcBins + 0.5; - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - sHistName = Form( "fhSetupSortedTsFirstDuplicateChan%02u", uXyterIdx); - title = Form( "TS of first duplicate hit in a burst per channel Asic %02u; Channel []; TS [bin]; Bursts []", uXyterIdx); - fhSetupSortedTsFirstDuplicateChan.push_back( new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - 512, -0.5, 511.5 ) ); - - sHistName = Form( "fhSetupSortedTsGoodChan%02u", uXyterIdx); - title = Form( "TS of non duplicated hits per channel Asic %02u; Channel []; TS [bin]; Bursts []", uXyterIdx); - fhSetupSortedTsGoodChan.push_back( new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - 512, -0.5, 511.5 ) ); - - sHistName = Form( "fhSetupSortedNbSameTsChan%02u", uXyterIdx); - title = Form( "Nb Hits with same TS per second & channel Asic %02u; Time [s]; Channel []; Hits []", uXyterIdx); - fhSetupSortedNbSameTsChan.push_back( new TH2I( sHistName, title, - 1800, 0, 1800, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - - sHistName = Form( "fhSetupSortedSameTsAdcChan%02u", uXyterIdx); - title = Form( "Adc distribution per channel for Hits with same TS Asic %02u; Channel []; Adc []; Hits []", uXyterIdx); - fhSetupSortedSameTsAdcChan.push_back( new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - stsxyter::kuHitNbAdcBins, -0.5, stsxyter::kuHitNbAdcBins -0.5 ) ); - - sHistName = Form( "fhSetupSortedSameTsAdcDiff%02u", uXyterIdx); - title = Form( "Adc difference vs consecutive hit idx per channel for Hits with same TS Asic %02u; Nb same TS before []; Adc diff []; Hits []", uXyterIdx); - fhSetupSortedSameTsAdcDiff.push_back( new TH2I(sHistName, title, - 256, -0.5, 255.5, - 2*dAdcMinMax, -dAdcMinMax, dAdcMinMax ) ); - - sHistName = Form( "fhSetupSortedRatioSameTsChan%02u", uXyterIdx); - title = Form( "Ratio Hits with same TS per second & channel Asic %02u; Time [s]; Channel []; Hits []", uXyterIdx); - fhSetupSortedRatioSameTsChan.push_back( new TProfile2D( sHistName, title, - 1800, 0, 1800, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - - sHistName = Form( "fhSetupSortedNbConsSameTsChan%02u", uXyterIdx); - title = Form( "Nb consecutive Hits with same TS per channel Asic %02u; Channel []; Hits with same TS []; []", uXyterIdx); - fhSetupSortedNbConsSameTsChan.push_back( new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - 256, -0.5, 255.5 ) ); - - sHistName = Form( "fhSetupSortedNbConsSameTsAdcChan%02u", uXyterIdx); - title = Form( "Nb consecutive Hits with same TS and ADC per channel Asic %02u; Channel []; Hits with same TS and ADC []; []", uXyterIdx); - fhSetupSortedNbConsSameTsAdcChan.push_back( new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - 256, -0.5, 255.5 ) ); - - sHistName = Form( "fhSetupSortedNbConsSameTsVsTsAdc%02u", uXyterIdx); - title = Form( "Nb consecutive Hits with same TS vs same TS and ADC Asic %02u; Hits with same TS []; Hits with same TS and ADC []; []", uXyterIdx); - fhSetupSortedNbConsSameTsVsTsAdc.push_back( new TH2I(sHistName, title, - 256, -0.5, 255.5, - 256, -0.5, 255.5 ) ); - - sHistName = Form( "fhSetupSortedAsicRatioSameTsVsFlux%02u", uXyterIdx); - title = Form( "Ratio of hits with same TS vs Hit flux Asic %02u; Hits flux [1/s]; Same Ts / All Hits []; []", uXyterIdx); - fhSetupSortedAsicRatioSameTsVsFlux.push_back( new TH2I(sHistName, title, - iNbBinsRate - 1, dBinsRate, - 101, -0.005, 1.005 ) ); - - sHistName = Form( "fhSetupSortedAsicRatioSameTsAdcVsFlux%02u", uXyterIdx); - title = Form( "Ratio of hits with same TS and ADC vs Hit flux Asic %02u; Hits flux [1/s]; Same Ts and ADC / All Hits []; []", uXyterIdx); - fhSetupSortedAsicRatioSameTsAdcVsFlux.push_back( new TH2I(sHistName, title, - iNbBinsRate - 1, dBinsRate, - 101, -0.005, 1.005 ) ); - - sHistName = Form( "fhSetupSortedAsicRatioSameAdcSameTsVsFlux%02u", uXyterIdx); - title = Form( "Ratio of hits with same ADC among same TS vs Hit flux Asic %02u; Hits flux [1/s]; Same TS and ADC / Same TS []; []", uXyterIdx); - fhSetupSortedAsicRatioSameAdcSameTsVsFlux.push_back( new TH2I(sHistName, title, - iNbBinsRate - 1, dBinsRate, - 101, -0.005, 1.005 ) ); - - sHistName = Form( "fhRatioSameTsSpillEvo%02u", uXyterIdx); - title = Form( "Ratio of hits with same TS Hits vs time Asic %02u; time [s]; channel []; Same Ts / All Hits []; []", uXyterIdx); - fhRatioSameTsSpillEvo.push_back( new TProfile2D(sHistName, title, - 70000, 0, 70.0, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - - sHistName = Form( "fhRatioSameTsAdcSpillEvo%02u", uXyterIdx); - title = Form( "Ratio of hits with same ADC and same TS hits vs time Asic %02u; time [s]; channel []; Same Ts and ADC / All Hits []; []", uXyterIdx); - fhRatioSameTsAdcSpillEvo.push_back( new TProfile2D(sHistName, title, - 70000, 0, 70.0, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - - sHistName = Form( "fhRatioSameAdcSameTsSpillEvo%02u", uXyterIdx); - title = Form( "Ratio of hits with same ADC among same TS vs time Asic %02u; time [s]; channel []; Same TS and ADC / Same TS []; []", uXyterIdx); - fhRatioSameAdcSameTsSpillEvo.push_back( new TProfile2D(sHistName, title, - 70000, 0, 70.0, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - - sHistName = Form( "fhFractionHitsAsicSpillEvo%02u", uXyterIdx); - title = Form( "Fraction of all hits vs time for Asic %02u; time [s]; Hits in Asic %02u []", uXyterIdx, uXyterIdx); - fhFractionHitsAsicSpillEvo.push_back( new TProfile(sHistName, title, 210000, 0, 210.0 ) ); - - sHistName = Form( "fhFractionHitsAsicEvo%02u", uXyterIdx); - title = Form( "Fraction of all hits vs time for Asic %02u; time [s]; Hits in Asic %02u []", uXyterIdx, uXyterIdx); - fhFractionHitsAsicEvo.push_back( new TProfile(sHistName, title, 1800, 0, 1800 ) ); - - // Channel counts - sHistName = Form( "hHodoChanCntGood_%03u", uXyterIdx ); - title = Form( "Good Hits Count per channel, StsXyter #%03u; Channel; Good Hits []", uXyterIdx ); - fhHodoChanCntGood.push_back( new TH1I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - // Hit rates evo per channel - sHistName = Form( "hHodoChanGoodRateEvo_%03u", uXyterIdx ); - title = Form( "Good Hits per second & channel in StsXyter #%03u; Time [s]; Channel []; Good Hits []", uXyterIdx ); - fhHodoChanGoodHitRateEvo.push_back( new TH2I( sHistName, title, - 1800, 0, 1800, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - for( UInt_t uDpbIdx = 0; uDpbIdx < fuNrOfDpbs; ++uDpbIdx ) - { - sHistName = Form( "fhFractionGoodHitsSpillEvo%02u", uDpbIdx); - title = Form( "Fraction of good hits vs time Dpb %02u; time [s]; Good Hits []", uDpbIdx); - fhFractionGoodHitsSpillEvo.push_back( new TProfile(sHistName, title, 300000, 0, 300.0 ) ); - - sHistName = Form( "fhFractionDupliHitsSpillEvo%02u", uDpbIdx); - title = Form( "Fraction of fake hits vs time Dpb %02u; time [s]; Dupli Hits []", uDpbIdx); - fhFractionDupliHitsSpillEvo.push_back( new TProfile(sHistName, title, 300000, 0, 300.0 ) ); - - sHistName = Form( "fhFractionTsMsbSpillEvo%02u", uDpbIdx); - title = Form( "Fraction of TS MSB vs time Dpb %02u; time [s]; TS MSB []", uDpbIdx); - fhFractionTsMsbSpillEvo.push_back( new TProfile(sHistName, title, 300000, 0, 300.0 ) ); - - sHistName = Form( "fhFractionEpochSpillEvo%02u", uDpbIdx); - title = Form( "Fraction of Epoch vs time Dpb %02u; time [s]; Epoch []", uDpbIdx); - fhFractionEpochSpillEvo.push_back( new TProfile(sHistName, title, 300000, 0, 300.0 ) ); - - sHistName = Form( "fhFractionEmptySpillEvo%02u", uDpbIdx); - title = Form( "Fraction of Empty vs time Dpb %02u; time [s]; Empty []", uDpbIdx); - fhFractionEmptySpillEvo.push_back( new TProfile(sHistName, title, 300000, 0, 300.0 ) ); - - sHistName = Form( "fhFractionGoodHitsEvo%02u", uDpbIdx); - title = Form( "Fraction of good hits vs time Dpb %02u; time [s]; Good Hits []", uDpbIdx); - fhFractionGoodHitsEvo.push_back( new TProfile(sHistName, title, 1800, 0, 1800 ) ); - - sHistName = Form( "fhFractionDupliHitsEvo%02u", uDpbIdx); - title = Form( "Fraction of fake hits vs time Dpb %02u; time [s]; Dupli Hits []", uDpbIdx); - fhFractionDupliHitsEvo.push_back( new TProfile(sHistName, title, 1800, 0, 1800 ) ); - - sHistName = Form( "fhFractionTsMsbEvo%02u", uDpbIdx); - title = Form( "Fraction of TS MSB vs time Dpb %02u; time [s]; TS MSB []", uDpbIdx); - fhFractionTsMsbEvo.push_back( new TProfile(sHistName, title, 1800, 0, 1800 ) ); - - sHistName = Form( "fhFractionEpochEvo%02u", uDpbIdx); - title = Form( "Fraction of Epoch vs time Dpb %02u; time [s]; Epoch []", uDpbIdx); - fhFractionEpochEvo.push_back( new TProfile(sHistName, title, 1800, 0, 1800 ) ); - - sHistName = Form( "fhFractionEmptyEvo%02u", uDpbIdx); - title = Form( "Fraction of Empty vs time Dpb %02u; time [s]; Empty []", uDpbIdx); - fhFractionEmptyEvo.push_back( new TProfile(sHistName, title, 1800, 0, 1800 ) ); - } // for( UInt_t uDpbIdx = 0; uDpbIdx < fuNrOfDpbs; ++uDpbIdx ) -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - sHistName = "fhFractionAsics"; - title = "Fraction of all hits per Asic; Asic []; Hits fraction []"; - fhFractionAsics = new TProfile(sHistName, title, fuNbStsXyters, 0, fuNbStsXyters ); - - sHistName = "fhFractionTypes"; - title = "Fraction of data per Type; ; Msg fraction []"; - fhFractionTypes = new TProfile(sHistName, title, 5, 0, 5 ); - fhFractionTypes->GetXaxis()->SetBinLabel( 1, "Good Hit"); - fhFractionTypes->GetXaxis()->SetBinLabel( 2, "Dupli Hit"); - fhFractionTypes->GetXaxis()->SetBinLabel( 3, "TsMsb"); - fhFractionTypes->GetXaxis()->SetBinLabel( 4, "Epoch"); - fhFractionTypes->GetXaxis()->SetBinLabel( 5, "Empty"); -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - - if(uXyterIdx == 2) - { - for( UInt_t uChannelIdx = 0; uChannelIdx < fuNbChanPerAsic; ++uChannelIdx ) - { - // Channel RawAdc - sHistName = Form( "hStsRawAdc_%03u", uChannelIdx ); - title = Form( "Hits Adc per channel, StsXyter #%03u; Channel; Hits []", uChannelIdx ); - fhStsRawAdc.push_back( new TH1I(sHistName, title, - stsxyter::kuHitNbAdcBins, -0.5, stsxyter::kuHitNbAdcBins -0.5 ) ); - } - } - - sHistName = Form( "fhAsicDuplicDtLastHits%02u", uXyterIdx); - title = "Time diff Between duplicated hit and previous hits; tDupli - tPrevN [bins]; Nth Previous hit [N]"; - fhAsicDuplicDtLastHits.push_back( new TH2I( sHistName, title, - 2048, -0.5, 2047.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - - sHistName = Form( "fhAsicDuplicCompTs%02u", uXyterIdx); - title = "ASIC Compared TS of duplicated hit and previous hits; Nth Previous hit [N]; Comp TS [bin]"; - fhAsicDuplicCompTs.push_back( new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - 128, -0.5, 127.5 ) ); - - sHistName = Form( "fhAsicDuplicTsLsb%02u", uXyterIdx); - title = "TS LSB of duplicated hit and previous hits; Nth Previous hit [N]; TS LSB [bins]"; - fhAsicDuplicTsLsb.push_back( new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - 256, -0.5, 255.5 ) ); - - sHistName = Form( "fhAsicDuplicTsMsbAsic%02u", uXyterIdx); - title = "ASIC TS MSB of duplicated hit and previous hits; Nth Previous hit [N]; TS MSB [bins]"; - fhAsicDuplicTsMsbAsic.push_back( new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - 64, -0.5, 63.5 ) ); - - sHistName = Form( "fhAsicDuplicCompTsBitThere%02u", uXyterIdx); - title = "Bits present in ASIC Compared TS of duplicated hit and N previous hits; Ns Previous hit [N]; Bit"; - fhAsicDuplicCompTsBitThere.push_back( new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - 7, -0.5, 6.5 ) ); - - sHistName = Form( "fhAsicDuplicTsLsbBitThere%02u", uXyterIdx); - title = "Bits present in TS LSB of duplicated hit and N previous hits; Ns Previous hit [N]; Bit"; - fhAsicDuplicTsLsbBitThere.push_back( new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - 8, -0.5, 7.5 ) ); - - sHistName = Form( "fhAsicDuplicTsMsbBitThere%02u", uXyterIdx); - title = "Bits present in ASIC TS MSB of duplicated hit and N previous hits; Ns Previous hit [N]; Bit"; - fhAsicDuplicTsMsbBitThere.push_back( new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - 6, -0.5, 5.5 ) ); - - sHistName = Form( "fhAsicDuplicTs%02u", uXyterIdx); - title = "TS of duplicated hit vs its channel index; Channel []; TS [bins]"; - fhAsicDuplicTs.push_back( new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - 256, -0.5, 255.5 ) ); - - sHistName = Form( "fhAsicGoodTs%02u", uXyterIdx); - title = "TS of good hit vs its channel index; Channel []; TS [bins]"; - fhAsicGoodTs.push_back( new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - 256, -0.5, 255.5 ) ); - - sHistName = Form( "fhAsicDuplicTsMsb%02u", uXyterIdx); - title = "TS MSB of duplicated hit vs its channel index; Channel []; TS_MSB [bins]"; - fhAsicDuplicTsMsb.push_back( new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - 256, -0.5, 255.5 ) ); - - sHistName = Form( "fhAsicGoodTsMsb%02u", uXyterIdx); - title = "TS MSB of good hit vs its channel index; Channel []; TS_MSB [bins]"; - fhAsicGoodTsMsb.push_back( new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - 256, -0.5, 255.5 ) ); - - sHistName = Form( "fhAsicDuplicTsFull%02u", uXyterIdx); - title = "Full TS of duplicated hit vs its channel index; Channel []; TS + TS_MSB [bins]"; - fhAsicDuplicTsFull.push_back( new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - 16384, -0.5, 16383.5 ) ); - - sHistName = Form( "fhAsicGoodTsFull%02u", uXyterIdx); - title = "Full TS of good hit vs its channel index; Channel []; TS + TS_MSB [bins]"; - fhAsicGoodTsFull.push_back( new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - 16384, -0.5, 16383.5 ) ); - - sHistName = Form( "fhAsicDuplicTsBitPattern%02u", uXyterIdx); - title = "Bits pattern in duplicated hit; TS Bit; ON/OFF?"; - fhAsicDuplicTsBitPattern.push_back( new TH2I( sHistName, title, - 14, -0.5, 13.5, - 2, -0.5, 1.5 ) ); - - sHistName = Form( "fhAsicGoodTsBitPattern%02u", uXyterIdx); - title = "Bits pattern in good hit; TS Bit; ON/OFF?"; - fhAsicGoodTsBitPattern.push_back( new TH2I( sHistName, title, - 14, -0.5, 13.5, - 2, -0.5, 1.5 ) ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - - sHistName = "hStsRawAdcCombine"; - title = "ADC histogram combined"; - fhStsRawAdcCombine = new TH1I(sHistName, title, stsxyter::kuHitNbAdcBins, -0.5, stsxyter::kuHitNbAdcBins -0.5); - - sHistName = "fhAsicDuplicTsEvoAsic0Chan01"; - title = "TS of duplicated hits vs time in run for ASIC 0 chan 1; time in run [s]; TS + TS_MSB [bins]"; - fhAsicDuplicTsEvoAsic0Chan01 = new TH2I( sHistName, title, - 2*4096, -0.5, 4095.5, - 2048, -0.5, 4095.5 ); - sHistName = "fhAsicGoodTsEvoAsic0Chan01"; - title = "TS of good hits vs time in run for ASIC 0 chan 1; time in run [s]; TS + TS_MSB [bins]"; - fhAsicGoodTsEvoAsic0Chan01 = new TH2I( sHistName, title, - 2*4096, -0.5, 4095.5, - 2048, -0.5, 4095.5 ); - sHistName = "fhAsicGoodTsMsbEvoAsic0Chan01"; - title = "TS MSB of good hits vs time in run for ASIC 0 chan 1; time in run [s]; TS_MSB[0 - 7] [bins]"; - fhAsicGoodTsMsbEvoAsic0Chan01 = new TH2I( sHistName, title, - 2*4096, -0.5, 4095.5, - 256, -0.5, 255.5 ); - sHistName = "fhAsicGoodTsFullEvoAsic0Chan01"; - title = "Full TS of good hits vs time in run for ASIC 0 chan 1; time in run [s]; TS + TS_MSB [bins]"; - fhAsicGoodTsFullEvoAsic0Chan01 = new TH2I( sHistName, title, - 4*900, -0.5, 899.5, - 16384, -0.5, 16383.5 ); - sHistName = "fhAsicGoodTsFullEvoProfAsic0Chan01"; - title = "Full TS of good hits vs time in run for ASIC 0 chan 1; time in run [s]; TS + TS_MSB [bins]"; - fhAsicGoodTsFullEvoProfAsic0Chan01 = new TProfile( sHistName, title, - 4*3600, -0.5, 3599.5 ); - - sHistName = "fhAsicDuplicTsEvoAsic0Chan09"; - title = "TS of duplicated hits vs time in run for ASIC 0 chan 9; time in run [s]; TS + TS_MSB [bins]"; - fhAsicDuplicTsEvoAsic0Chan09 = new TH2I( sHistName, title, - 2*4096, -0.5, 4095.5, - 2048, -0.5, 4095.5 ); - sHistName = "fhAsicGoodTsEvoAsic0Chan09"; - title = "TS of good hits vs time in run for ASIC 0 chan 9; time in run [s]; TS + TS_MSB [bins]"; - fhAsicGoodTsEvoAsic0Chan09 = new TH2I( sHistName, title, - 2*4096, -0.5, 4095.5, - 2048, -0.5, 4095.5 ); - sHistName = "fhAsicGoodTsFullEvoProfAsic0Chan09"; - title = "Full TS of good hits vs time in run for ASIC 0 chan 9; time in run [s]; TS + TS_MSB [bins]"; - fhAsicGoodTsFullEvoProfAsic0Chan09 = new TProfile( sHistName, title, - 4*3600, -0.5, 3599.5 ); - - sHistName = "fhAsicDuplicTsEvoAsic0Chan16"; - title = "TS of duplicated hits vs time in run for ASIC 0 chan 16; time in run [s]; TS + TS_MSB [bins]"; - fhAsicDuplicTsEvoAsic0Chan16 = new TH2I( sHistName, title, - 2*4096, -0.5, 4095.5, - 2048, -0.5, 4095.5 ); - sHistName = "fhAsicGoodTsEvoAsic0Chan16"; - title = "TS of good hits vs time in run for ASIC 0 chan 16; time in run [s]; TS + TS_MSB [bins]"; - fhAsicGoodTsEvoAsic0Chan16 = new TH2I( sHistName, title, - 2*4096, -0.5, 4095.5, - 2048, -0.5, 4095.5 ); - sHistName = "fhAsicGoodTsFullEvoProfAsic0Chan16"; - title = "Full TS of good hits vs time in run for ASIC 0 chan 16; time in run [s]; TS + TS_MSB [bins]"; - fhAsicGoodTsFullEvoProfAsic0Chan16 = new TProfile( sHistName, title, - 4*3600, -0.5, 3599.5 ); - - - sHistName = "fhAsicMissedChanIdVsPulseIdx"; - title = "Channels present VS pulse Idx; Pulse Idx []; Channel Id []"; - fhAsicMissedChanIdVsPulseIdx = new TH2I( sHistName, title, - fuPulseIdxMax, -0.5, fuPulseIdxMax - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - - sHistName = "fhAsicMissedChanGroupVsPulseIdx"; - title = "Channels group present VS pulse Idx; Pulse Idx []; Channel Grp []"; - fhAsicMissedChanGroupVsPulseIdx = new TProfile( sHistName, title, - fuPulseIdxMax, -0.5, fuPulseIdxMax - 0.5 ); - - -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - sHistName = "fhHodoX1SpillEvo"; - title = "Hodo X1 counts vs time in spill; time [s]; X1 channel []; Hits []"; - fhHodoX1SpillEvo = new TH2I(sHistName, title, - 70000, 0, 70.0, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhHodoY1SpillEvo"; - title = "Hodo Y1 counts vs time in spill; time [s]; Y1 channel []; Hits []"; - fhHodoY1SpillEvo = new TH2I(sHistName, title, - 70000, 0, 70.0, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - sHistName = "fhHodoX2SpillEvo"; - title = "Hodo X2 counts vs time in spill; time [s]; X2 channel []; Hits []"; - fhHodoX2SpillEvo = new TH2I(sHistName, title, - 70000, 0, 70.0, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - sHistName = "fhHodoY2SpillEvo"; - title = "Hodo Y2 counts vs time in spill; time [s]; Y2 channel []; Hits []"; - fhHodoY2SpillEvo = new TH2I(sHistName, title, - 70000, 0, 70.0, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhHodoX1SpillEvoProf"; - title = "Hodo X1 counts vs time in spill; time [s]; X1 channel []; Hits []"; - fhHodoX1SpillEvoProf = new TProfile(sHistName, title, - 10*fdSpillEvoLength, 0, fdSpillEvoLength); - - sHistName = "fhHodoY1SpillEvoProf"; - title = "Hodo Y1 counts vs time in spill; time [s]; Y1 channel []; Hits []"; - fhHodoY1SpillEvoProf = new TProfile(sHistName, title, - 10*fdSpillEvoLength, 0, fdSpillEvoLength); - sHistName = "fhHodoX2SpillEvoProf"; - title = "Hodo X2 counts vs time in spill; time [s]; X2 channel []; Hits []"; - fhHodoX2SpillEvoProf = new TProfile(sHistName, title, - 10*fdSpillEvoLength, 0, fdSpillEvoLength); - sHistName = "fhHodoY2SpillEvoProf"; - title = "Hodo Y2 counts vs time in spill; time [s]; Y2 channel []; Hits []"; - fhHodoY2SpillEvoProf = new TProfile(sHistName, title, - 10*fdSpillEvoLength, 0, fdSpillEvoLength); - -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - sHistName = Form( "fhPulseChanCountEvo%02u", uXyterIdx); - title = Form( "Number of channels per pulse vs time for ASIC %02u; time [s]; Channels []; Pulses []", uXyterIdx); - fhPulseChanCountEvo.push_back( new TH2D( sHistName, title, - 300, 0, 300.0, - fuNbChanPerAsic, 0.5, fuNbChanPerAsic + 0.5 ) ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - - sHistName = "fhHodoChanHitRateEvoZoom"; - title = "Hits per second & channel in StsXyter 000; Time [s]; Channel []; Hits []"; - fhHodoChanHitRateEvoZoom = new TH2I( sHistName, title, - 2000, 0, 50, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - -/* - // Distribution of the TS_MSB per StsXyter - sHistName = "hHodoFebTsMsb"; - title = "Raw Timestamp Msb distribution per StsXyter; Ts MSB []; StsXyter []; Hits []"; - fhHodoFebTsMsb = new TH2I( sHistName, title, stsxyter::kuTsMsbNbTsBins, -0.5, stsxyter::kuTsMsbNbTsBins - 0.5, - fuNbStsXyters, -0.5, fuNbStsXyters - 0.5 ); - if( server ) server->Register("/StsRaw", fhHodoFebTsMsb ); -*/ - // Miscroslice properties histos - for( Int_t component = 0; component < kiMaxNbFlibLinks; component ++ ) - { - fhMsSz[ component ] = NULL; - fhMsSzTime[ component ] = NULL; - } // for( Int_t component = 0; component < kiMaxNbFlibLinks; component ++ ) - - // Online histo browser commands - THttpServer* server = FairRunOnline::Instance()->GetHttpServer(); - if( server ) - { - server->Register("/HodoRaw", fhHodoMessType ); - server->Register("/HodoRaw", fhHodoSysMessType ); - server->Register("/HodoRaw", fhHodoMessTypePerDpb ); - server->Register("/HodoRaw", fhHodoSysMessTypePerDpb ); - server->Register("/HodoRaw", fhHodoMessTypePerElink ); - server->Register("/HodoRaw", fhHodoSysMessTypePerElink ); - server->Register("/HodoRaw", fhStsRawAdcCombine ); - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - - if(uXyterIdx == 2) - { - for( UInt_t uChannelIdx = 0; uChannelIdx < fuNbChanPerAsic; ++uChannelIdx ) - { - if( server ) server->Register("/HodoRaw", fhStsRawAdc[ uChannelIdx ] ); - } - } - server->Register("/HodoRaw", fhHodoChanCntRaw[ uXyterIdx ] ); - server->Register("/HodoRaw", fhHodoChanAdcRaw[ uXyterIdx ] ); - server->Register("/HodoRaw", fhHodoChanAdcRawProf[ uXyterIdx ] ); - server->Register("/HodoRaw", fhHodoChanRawTs[ uXyterIdx ] ); - server->Register("/HodoRaw", fhHodoChanMissEvt[ uXyterIdx ] ); - server->Register("/HodoRaw", fhHodoChanMissEvtEvo[ uXyterIdx ] ); - server->Register("/HodoRaw", fhHodoFebMissEvtEvo[ uXyterIdx ] ); - server->Register("/HodoRaw", fhHodoChanHitRateEvo[ uXyterIdx ] ); - server->Register("/HodoRaw", fhHodoFebRateEvo[ uXyterIdx ] ); - server->Register("/HodoRaw", fhHodoChanHitRateEvoLong[ uXyterIdx ] ); - server->Register("/HodoRaw", fhHodoFebRateEvoLong[ uXyterIdx ] ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - server->Register("/Setup", fhSetupSortedDtX1Y1 ); - server->Register("/Setup", fhSetupSortedDtX2Y2 ); - server->Register("/Setup", fhSetupSortedDtN1P1 ); - server->Register("/Setup", fhSetupSortedDtN2P2 ); - server->Register("/Setup", fhSetupSortedDtX1Y1X2Y2 ); - server->Register("/Setup", fhSetupSortedDtX1Y1X2Y2N1P1 ); - server->Register("/Setup", fhSetupSortedDtX1Y1X2Y2N2P2 ); - server->Register("/Setup", fhSetupSortedDtH1H2S1S2 ); - server->Register("/Setup", fhSetupSortedMapX1Y1 ); - server->Register("/Setup", fhSetupSortedMapX2Y2 ); - server->Register("/Setup", fhSetupSortedMapN1P1 ); - server->Register("/Setup", fhSetupSortedMapN2P2 ); - server->Register("/Setup", fhSetupSortedCntEvoX1Y1 ); - server->Register("/Setup", fhSetupSortedCntEvoX2Y2 ); - server->Register("/Setup", fhSetupSortedCntEvoN1P1 ); - server->Register("/Setup", fhSetupSortedCntEvoN2P2 ); - - server->Register("/HodoBoth", fhBothHodoSortedDtX1Y1 ); - server->Register("/HodoBoth", fhBothHodoSortedDtX2Y2 ); - server->Register("/HodoBoth", fhBothHodoSortedDtX1Y1X2Y2N1P1 ); - server->Register("/HodoBoth", fhBothHodoSortedDtX1Y1X2Y2N2P2 ); - server->Register("/HodoBoth", fhBothHodoSortedMapX1Y1 ); - server->Register("/HodoBoth", fhBothHodoSortedMapX2Y2 ); - server->Register("/HodoBoth", fhBothHodoSortedCntEvoX1Y1 ); - server->Register("/HodoBoth", fhBothHodoSortedCntEvoX2Y2 ); - - server->Register("/H1H2S1", fhH1H2S1SortedDtX1Y1 ); - server->Register("/H1H2S1", fhH1H2S1SortedDtX2Y2 ); - server->Register("/H1H2S1", fhH1H2S1SortedDtN1P1 ); - server->Register("/H1H2S1", fhH1H2S1SortedDtN2P2 ); - server->Register("/H1H2S1", fhH1H2S1SortedMapX1Y1 ); - server->Register("/H1H2S1", fhH1H2S1SortedMapX2Y2 ); - server->Register("/H1H2S1", fhH1H2S1SortedMapN1P1 ); - server->Register("/H1H2S1", fhH1H2S1SortedMapN2P2 ); - server->Register("/H1H2S1", fhH1H2S1SortedCntEvoX1Y1 ); - server->Register("/H1H2S1", fhH1H2S1SortedCntEvoX2Y2 ); - server->Register("/H1H2S1", fhH1H2S1SortedCntEvoN1P1 ); - server->Register("/H1H2S1", fhH1H2S1SortedCntEvoN2P2 ); - - server->Register("/H1H2S2", fhH1H2S2SortedDtX1Y1 ); - server->Register("/H1H2S2", fhH1H2S2SortedDtX2Y2 ); - server->Register("/H1H2S2", fhH1H2S2SortedDtN1P1 ); - server->Register("/H1H2S2", fhH1H2S2SortedDtN2P2 ); - server->Register("/H1H2S2", fhH1H2S2SortedMapX1Y1 ); - server->Register("/H1H2S2", fhH1H2S2SortedMapX2Y2 ); - server->Register("/H1H2S2", fhH1H2S2SortedMapN1P1 ); - server->Register("/H1H2S2", fhH1H2S2SortedMapN2P2 ); - server->Register("/H1H2S2", fhH1H2S2SortedCntEvoX1Y1 ); - server->Register("/H1H2S2", fhH1H2S2SortedCntEvoX2Y2 ); - server->Register("/H1H2S2", fhH1H2S2SortedCntEvoN1P1 ); - server->Register("/H1H2S2", fhH1H2S2SortedCntEvoN2P2 ); - - server->Register("/Syst", fhSystSortedDtX1Y1 ); - server->Register("/Syst", fhSystSortedDtX2Y2 ); - server->Register("/Syst", fhSystSortedDtN1P1 ); - server->Register("/Syst", fhSystSortedDtN2P2 ); - server->Register("/Syst", fhSystSortedDtX1Y1X2Y2 ); - server->Register("/Syst", fhSystSortedMapX1Y1 ); - server->Register("/Syst", fhSystSortedMapX2Y2 ); - server->Register("/Syst", fhSystSortedMapN1P1 ); - server->Register("/Syst", fhSystSortedMapN2P2 ); - server->Register("/Syst", fhSystSortedCntEvoX1Y1 ); - server->Register("/Syst", fhSystSortedCntEvoX2Y2 ); - server->Register("/Syst", fhSystSortedCntEvoN1P1 ); - server->Register("/Syst", fhSystSortedCntEvoN2P2 ); - - server->Register("/Syst", fhSystSortedDtN1X1vsN1X2 ); - server->Register("/Syst", fhSystSortedDtP1X1vsP1X2 ); - server->Register("/Syst", fhSystSortedDtN1X1vsP1X1 ); - server->Register("/Syst", fhSystSortedDtSts1Hodo1vsSts1Hodo2 ); - server->Register("/Syst", fhSystSortedDtSts2Hodo1vsSts2Hodo2 ); - - server->Register("/Syst", fhSystSortedDtAllVsMapX1 ); - server->Register("/Syst", fhSystSortedDtAllVsMapY1 ); - server->Register("/Syst", fhSystSortedDtAllVsMapX2 ); - server->Register("/Syst", fhSystSortedDtAllVsMapY2 ); - - server->Register("/FebDt", fhSetupSortedDtX1 ); - server->Register("/FebDt", fhSetupSortedDtY1 ); - server->Register("/FebDt", fhSetupSortedDtX2 ); - server->Register("/FebDt", fhSetupSortedDtY2 ); - server->Register("/FebDt", fhSetupSortedDtN1 ); - server->Register("/FebDt", fhSetupSortedDtP1 ); - server->Register("/FebDt", fhSetupSortedDtN2 ); - server->Register("/FebDt", fhSetupSortedDtP2 ); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - server->Register("/FebDupli", fhSetupSortedNbSameTsChan[ uXyterIdx ] ); - server->Register("/FebDupli", fhSetupSortedSameTsAdcChan[ uXyterIdx ] ); - server->Register("/FebDupli", fhSetupSortedSameTsAdcDiff[ uXyterIdx ] ); - server->Register("/FebDupli", fhSetupSortedRatioSameTsChan[ uXyterIdx ] ); - server->Register("/FebDupli", fhSetupSortedNbConsSameTsChan[ uXyterIdx ] ); - server->Register("/FebDupli", fhSetupSortedNbConsSameTsAdcChan[ uXyterIdx ] ); - server->Register("/FebDupli", fhSetupSortedNbConsSameTsVsTsAdc[ uXyterIdx ] ); - - server->Register("/FebDupli", fhSetupSortedAsicRatioSameTsVsFlux[ uXyterIdx ] ); - server->Register("/FebDupli", fhSetupSortedAsicRatioSameTsAdcVsFlux[ uXyterIdx ] ); - server->Register("/FebDupli", fhSetupSortedAsicRatioSameAdcSameTsVsFlux[ uXyterIdx ] ); - - server->Register("/FebDupli", fhRatioSameTsSpillEvo[ uXyterIdx ] ); - server->Register("/FebDupli", fhRatioSameTsAdcSpillEvo[ uXyterIdx ] ); - server->Register("/FebDupli", fhRatioSameAdcSameTsSpillEvo[ uXyterIdx ] ); - - server->Register("/FebDupli", fhSetupSortedTsFirstDuplicateChan[ uXyterIdx ] ); - server->Register("/FebDupli", fhSetupSortedTsGoodChan[ uXyterIdx ] ); - - server->Register("/FebDupli", fhAsicDuplicDtLastHits[ uXyterIdx ] ); - server->Register("/FebDupli", fhAsicDuplicCompTs[ uXyterIdx ] ); - server->Register("/FebDupli", fhAsicDuplicTsLsb[ uXyterIdx ] ); - server->Register("/FebDupli", fhAsicDuplicTsMsbAsic[ uXyterIdx ] ); - server->Register("/FebDupli", fhAsicDuplicCompTsBitThere[ uXyterIdx ] ); - server->Register("/FebDupli", fhAsicDuplicTsLsbBitThere[ uXyterIdx ] ); - server->Register("/FebDupli", fhAsicDuplicTsMsbBitThere[ uXyterIdx ] ); - server->Register("/FebDupli", fhAsicDuplicTs[ uXyterIdx ] ); - server->Register("/FebDupli", fhAsicGoodTs[ uXyterIdx ] ); - server->Register("/FebDupli", fhAsicDuplicTsMsb[ uXyterIdx ] ); - server->Register("/FebDupli", fhAsicGoodTsMsb[ uXyterIdx ] ); - server->Register("/FebDupli", fhAsicDuplicTsFull[ uXyterIdx ] ); - server->Register("/FebDupli", fhAsicGoodTsFull[ uXyterIdx ] ); - server->Register("/FebDupli", fhAsicDuplicTsBitPattern[ uXyterIdx ] ); - server->Register("/FebDupli", fhAsicGoodTsBitPattern[ uXyterIdx ] ); - - server->Register("/Data", fhFractionHitsAsicSpillEvo[ uXyterIdx ] ); - server->Register("/Data", fhFractionHitsAsicEvo[ uXyterIdx ] ); - server->Register("/Data", fhHodoChanCntGood[ uXyterIdx ] ); - server->Register("/Data", fhHodoChanGoodHitRateEvo[ uXyterIdx ] ); - - server->Register("/Data", fhPulseChanCountEvo[ uXyterIdx ] ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - - server->Register("/FebDupli", fhAsicDuplicTsEvoAsic0Chan01 ); - server->Register("/FebDupli", fhAsicGoodTsEvoAsic0Chan01 ); - server->Register("/FebDupli", fhAsicGoodTsMsbEvoAsic0Chan01 ); - server->Register("/FebDupli", fhAsicGoodTsFullEvoAsic0Chan01 ); - server->Register("/FebDupli", fhAsicGoodTsFullEvoProfAsic0Chan01 ); - server->Register("/FebDupli", fhAsicDuplicTsEvoAsic0Chan09 ); - server->Register("/FebDupli", fhAsicGoodTsEvoAsic0Chan09 ); - server->Register("/FebDupli", fhAsicGoodTsFullEvoProfAsic0Chan09 ); - server->Register("/FebDupli", fhAsicDuplicTsEvoAsic0Chan16 ); - server->Register("/FebDupli", fhAsicGoodTsEvoAsic0Chan16 ); - server->Register("/FebDupli", fhAsicGoodTsFullEvoProfAsic0Chan16 ); - - server->Register("/FebDupli", fhAsicMissedChanIdVsPulseIdx ); - server->Register("/FebDupli", fhAsicMissedChanGroupVsPulseIdx ); - - for( UInt_t uDpbIdx = 0; uDpbIdx < fuNrOfDpbs; ++uDpbIdx ) - { - server->Register("/Data", fhFractionGoodHitsSpillEvo[ uDpbIdx ] ); - server->Register("/Data", fhFractionDupliHitsSpillEvo[ uDpbIdx ] ); - server->Register("/Data", fhFractionTsMsbSpillEvo[ uDpbIdx ] ); - server->Register("/Data", fhFractionEpochSpillEvo[ uDpbIdx ] ); - server->Register("/Data", fhFractionEmptySpillEvo[ uDpbIdx ] ); - - server->Register("/Data", fhFractionGoodHitsEvo[ uDpbIdx ] ); - server->Register("/Data", fhFractionDupliHitsEvo[ uDpbIdx ] ); - server->Register("/Data", fhFractionTsMsbEvo[ uDpbIdx ] ); - server->Register("/Data", fhFractionEpochEvo[ uDpbIdx ] ); - server->Register("/Data", fhFractionEmptyEvo[ uDpbIdx ] ); - } // for( UInt_t uDpbIdx = 0; uDpbIdx < fuNrOfDpbs; ++uDpbIdx ) - server->Register("/Data", fhFractionAsics ); - server->Register("/Data", fhFractionTypes ); - - server->Register("/Spill", fhHodoX1SpillEvo ); - server->Register("/Spill", fhHodoY1SpillEvo ); - server->Register("/Spill", fhHodoX2SpillEvo ); - server->Register("/Spill", fhHodoY2SpillEvo ); - server->Register("/Spill", fhHodoX1SpillEvoProf ); - server->Register("/Spill", fhHodoY1SpillEvoProf ); - server->Register("/Spill", fhHodoX2SpillEvoProf ); - server->Register("/Spill", fhHodoY2SpillEvoProf ); - - server->Register("/FebDupli", fhHodoChanHitRateEvoZoom ); - - - server->RegisterCommand("/Reset_All_Hodo", "bCosy2018ResetDupliHistos=kTRUE"); - server->RegisterCommand("/Write_All_Hodo", "bCosy2018WriteDupliHistos=kTRUE"); - server->RegisterCommand("/Print_Messages", "bCosy2018PrintMessDupliHistos=kTRUE"); - - server->Restrict("/Reset_All_Hodo", "allow=admin"); - server->Restrict("/Write_All_Hodo", "allow=admin"); - } // if( server ) - - /** Create summary Canvases for CERN 2017 **/ - Double_t w = 10; - Double_t h = 10; - Double_t w1 = 10; - Double_t h1 = 10; - - // Summary per StsXyter - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - - // Summary per StsXyter - if(fuNbStsXyters == 2) - { - for( UInt_t uChannelIdx = 0; uChannelIdx < fuNbChanPerAsic; ++uChannelIdx ) - { - TCanvas* cStsSumm1 = new TCanvas( Form("cStsSum1_%03u", uChannelIdx ), - Form("Summary plots for StsXyter %03u", uChannelIdx ), - w1, h1); - cStsSumm1->cd(); - fhStsRawAdc[ uChannelIdx ]->Draw(); - - } - } - - - TCanvas* cStsSumm = new TCanvas( Form("cStsSum_%03u", uXyterIdx ), - Form("Summary plots for StsXyter %03u", uXyterIdx ), - w, h); - cStsSumm->Divide( 2, 2 ); - - cStsSumm->cd(1); - gPad->SetLogy(); - fhHodoChanCntRaw[ uXyterIdx ]->Draw(); - - cStsSumm->cd(2); - gPad->SetLogz(); - fhHodoChanAdcRaw[ uXyterIdx ]->Draw( "colz" ); - - cStsSumm->cd(3); - gPad->SetLogz(); - fhHodoChanHitRateEvo[ uXyterIdx ]->Draw( "colz" ); - - cStsSumm->cd(4); -// gPad->SetLogy(); - fhHodoChanAdcRawProf[ uXyterIdx ]->Draw(); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - -//====================================================================// - -//====================================================================// - TCanvas* cSetupSortedDt = new TCanvas( "cSetupSortedDt", - "Hodoscopes coincidence maps", - w, h); - if( kTRUE == fbDualStsEna ) - cSetupSortedDt->Divide( 4, 3 ); - else cSetupSortedDt->Divide( 3, 3 ); - - cSetupSortedDt->cd(1); - gPad->SetGridx(); - gPad->SetLogy(); - fhSetupSortedDtX1Y1->Draw( "" ); - - cSetupSortedDt->cd(2); - gPad->SetGridx(); - gPad->SetLogy(); - fhSetupSortedDtX2Y2->Draw( "" ); - - cSetupSortedDt->cd(3); - gPad->SetGridx(); - gPad->SetLogy(); - fhSetupSortedDtN1P1->Draw( "" ); - - cSetupSortedDt->cd(4 + ( kTRUE == fbDualStsEna ? 1 : 0 ) ); - gPad->SetGridx(); - gPad->SetLogy(); - fhBothHodoSortedDtX1Y1->Draw( "" ); - - cSetupSortedDt->cd(5 + ( kTRUE == fbDualStsEna ? 1 : 0 ) ); - gPad->SetGridx(); - gPad->SetLogy(); - fhBothHodoSortedDtX2Y2->Draw( "" ); -/* - cSetupSortedDt->cd(6 + ( kTRUE == fbDualStsEna ? 1 : 0 ) ); - gPad->SetGridx(); - gPad->SetLogy(); - fhSetupSortedDtN1P1->Draw( "" ); -*/ - cSetupSortedDt->cd(7 + ( kTRUE == fbDualStsEna ? 2 : 0 ) ); - gPad->SetGridx(); - gPad->SetLogy(); - fhSystSortedDtX1Y1->Draw( "" ); - - cSetupSortedDt->cd(8 + ( kTRUE == fbDualStsEna ? 2 : 0 ) ); - gPad->SetGridx(); - gPad->SetLogy(); - fhSystSortedDtX2Y2->Draw( "" ); - - cSetupSortedDt->cd(9 + ( kTRUE == fbDualStsEna ? 2 : 0 ) ); - gPad->SetGridx(); - gPad->SetLogy(); - fhSystSortedDtN1P1->Draw( "" ); - - if( kTRUE == fbDualStsEna ) - { - cSetupSortedDt->cd(4); - gPad->SetGridx(); - gPad->SetLogy(); - fhSetupSortedDtN2P2->Draw( "colz" ); -/* - cSetupSortedDt->cd(8); - gPad->SetGridx(); - gPad->SetLogy(); - fhSetupSortedDtN2P2->Draw( "colz" ); -*/ - - cSetupSortedDt->cd(12); - gPad->SetGridx(); - gPad->SetLogy(); - fhSystSortedDtN2P2->Draw( "colz" ); - } // if( kTRUE == fbDualStsEna ) -//====================================================================// - -//====================================================================// - TCanvas* cSetupSortedMaps = new TCanvas( "cSetupSortedMaps", - "Hodoscopes coincidence maps", - w, h); - - if( kTRUE == fbDualStsEna ) - cSetupSortedMaps->Divide( 4, 3 ); - else cSetupSortedMaps->Divide( 3, 3 ); - - cSetupSortedMaps->cd(1); - gPad->SetLogz(); - fhSetupSortedMapX1Y1->Draw( "colz" ); - - cSetupSortedMaps->cd(2); - gPad->SetLogz(); - fhSetupSortedMapX2Y2->Draw( "colz" ); - - cSetupSortedMaps->cd(3); - gPad->SetLogz(); - fhSetupSortedMapN1P1->Draw( "colz" ); - - cSetupSortedMaps->cd(4 + ( kTRUE == fbDualStsEna ? 1 : 0 ) ); - gPad->SetLogz(); - fhBothHodoSortedMapX1Y1->Draw( "colz" ); - - cSetupSortedMaps->cd(5 + ( kTRUE == fbDualStsEna ? 1 : 0 ) ); - gPad->SetLogz(); - fhBothHodoSortedMapX2Y2->Draw( "colz" ); -/* - cSetupSortedMaps->cd(6 + ( kTRUE == fbDualStsEna ? 1 : 0 ) ); - gPad->SetLogz(); - fhBothHodoSortedMapN1P1->Draw( "colz" ); -*/ - cSetupSortedMaps->cd(7 + ( kTRUE == fbDualStsEna ? 2 : 0 ) ); - gPad->SetLogz(); - fhSystSortedMapX1Y1->Draw( "colz" ); - - cSetupSortedMaps->cd(8 + ( kTRUE == fbDualStsEna ? 2 : 0 ) ); - gPad->SetLogz(); - fhSystSortedMapX2Y2->Draw( "colz" ); - - cSetupSortedMaps->cd(9 + ( kTRUE == fbDualStsEna ? 2 : 0 ) ); - gPad->SetLogz(); - fhSystSortedMapN1P1->Draw( "colz" ); - - if( kTRUE == fbDualStsEna ) - { - cSetupSortedMaps->cd(4); - gPad->SetLogz(); - fhSetupSortedMapN2P2->Draw( "colz" ); -/* - cSetupSortedMaps->cd(8); - gPad->SetLogz(); - fhBothHodoSortedMapN2P2->Draw( "colz" ); -*/ - - cSetupSortedMaps->cd(12); - gPad->SetLogz(); - fhSystSortedMapN2P2->Draw( "colz" ); - } // if( kTRUE == fbDualStsEna ) -//====================================================================// - -//====================================================================// - TCanvas* cSetupSortedCoincEvo = new TCanvas( "cSetupSortedCoincEvo", - "Hodoscopes coincidence rate evolution", - w, h); - cSetupSortedCoincEvo->Divide( 3, 3 ); - - cSetupSortedCoincEvo->cd(1); - gPad->SetGridy(); - gPad->SetLogy(); - fhSetupSortedCntEvoX1Y1->Draw( "" ); - - cSetupSortedCoincEvo->cd(2); - gPad->SetGridy(); - gPad->SetLogy(); - fhSetupSortedCntEvoX2Y2->Draw( "" ); - - cSetupSortedCoincEvo->cd(3); - gPad->SetGridy(); - gPad->SetLogy(); - fhSetupSortedCntEvoN1P1->Draw( "" ); - - cSetupSortedCoincEvo->cd(4); - gPad->SetGridy(); - gPad->SetLogy(); - fhBothHodoSortedCntEvoX1Y1->Draw( "" ); - - cSetupSortedCoincEvo->cd(5); - gPad->SetGridy(); - gPad->SetLogy(); - fhBothHodoSortedCntEvoX2Y2->Draw( "" ); -/* - cSetupSortedCoincEvo->cd(6); - gPad->SetGridy(); - gPad->SetLogy(); - fhSetupSortedCntEvoN1P1->Draw( "" ); -*/ - cSetupSortedCoincEvo->cd(7); - gPad->SetGridy(); - gPad->SetLogy(); - fhSystSortedCntEvoX1Y1->Draw( "" ); - - cSetupSortedCoincEvo->cd(8); - gPad->SetGridy(); - gPad->SetLogy(); - fhSystSortedCntEvoX2Y2->Draw( "" ); - - cSetupSortedCoincEvo->cd(9); - gPad->SetGridy(); - gPad->SetLogy(); - fhSystSortedCntEvoN1P1->Draw( "" ); -//====================================================================// - -//====================================================================// - TCanvas* cSetupCoinQaDt = new TCanvas( "cSetupCoinQaDt", - "Hodoscopes coincidence quality", - w, h); - cSetupCoinQaDt->Divide( 2, 2 ); - - cSetupCoinQaDt->cd(1); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhSystSortedDtN1X1vsN1X2->Draw( "colz" ); - - cSetupCoinQaDt->cd(2); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhSystSortedDtP1X1vsP1X2->Draw( "colz" ); - - cSetupCoinQaDt->cd(3); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhSystSortedDtN1X1vsP1X1->Draw( "colz" ); - - cSetupCoinQaDt->cd(4); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhSystSortedDtSts1Hodo1vsSts1Hodo2->Draw( "colz" ); - -//====================================================================// - TCanvas* cSetupCoinQa = new TCanvas( "cSetupCoinQa", - "Hodoscopes coincidence quality", - w, h); - cSetupCoinQa->Divide( 2, 2 ); - - cSetupCoinQa->cd(1); - gPad->SetLogz(); - fhSystSortedDtAllVsMapX1->Draw( "colz" ); - - cSetupCoinQa->cd(2); - gPad->SetLogz(); - fhSystSortedDtAllVsMapY1->Draw( "colz" ); - - cSetupCoinQa->cd(3); - gPad->SetLogz(); - fhSystSortedDtAllVsMapX2->Draw( "colz" ); - - cSetupCoinQa->cd(4); - gPad->SetLogz(); - fhSystSortedDtAllVsMapY2->Draw( "colz" ); -//====================================================================// - -//====================================================================// - TCanvas* cFebDt = new TCanvas( "cFebDt", - "Hodoscopes coincidence quality", - w, h); - - if( kTRUE == fbDualStsEna ) - cFebDt->Divide( 2, 4 ); - else cFebDt->Divide( 2, 3 ); - - cFebDt->cd(1); - gPad->SetLogy(); - fhSetupSortedDtX1->Draw( "" ); - - cFebDt->cd(2); - gPad->SetLogy(); - fhSetupSortedDtY1->Draw( "" ); - - cFebDt->cd(3); - gPad->SetLogy(); - fhSetupSortedDtX2->Draw( "" ); - - cFebDt->cd(4); - gPad->SetLogy(); - fhSetupSortedDtY2->Draw( "" ); - - cFebDt->cd(5); - gPad->SetLogy(); - fhSetupSortedDtN1->Draw( "" ); - - cFebDt->cd(6); - gPad->SetLogy(); - fhSetupSortedDtP1->Draw( "" ); - - if( kTRUE == fbDualStsEna ) - { - cFebDt->cd(7); - gPad->SetLogy(); - fhSetupSortedDtN2->Draw( "" ); - - cFebDt->cd(8); - gPad->SetLogy(); - fhSetupSortedDtP2->Draw( "" ); - } // if( kTRUE == fbDualStsEna ) -//====================================================================// - -//====================================================================// - TCanvas* cFebSameTs = new TCanvas( "cFebSameTs", - "Hodoscopes coincidence quality", - w, h); - - cFebSameTs->Divide( 2, fuNbStsXyters/2 + fuNbStsXyters%2 ); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - cFebSameTs->cd(1 + uXyterIdx ); - gPad->SetLogz(); - fhSetupSortedNbSameTsChan[ uXyterIdx ]->Draw( "colz" ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) -//====================================================================// - -//====================================================================// - TCanvas* cFebSameTsAdc = new TCanvas( "cFebSameTsAdc", - "Hodoscopes coincidence quality", - w, h); - - cFebSameTsAdc->Divide( 2, fuNbStsXyters/2 + fuNbStsXyters%2 ); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - cFebSameTsAdc->cd(1 + uXyterIdx ); - gPad->SetLogz(); - fhSetupSortedSameTsAdcChan[ uXyterIdx ]->Draw( "colz" ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) -//====================================================================// - -//====================================================================// - TCanvas* cFebDupliVsChan = new TCanvas( "cFebDupliVsChan", - "Hodoscopes coincidence quality", - w, h); - - cFebDupliVsChan->Divide( fuNbStsXyters, 3 ); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - cFebDupliVsChan->cd( 1 + uXyterIdx ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhSetupSortedNbConsSameTsChan[ uXyterIdx ]->Draw( "colz" ); - - cFebDupliVsChan->cd( 1 + fuNbStsXyters +uXyterIdx ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhSetupSortedNbConsSameTsAdcChan[ uXyterIdx ]->Draw( "colz" ); - - cFebDupliVsChan->cd( 1 + 2*fuNbStsXyters + uXyterIdx ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhSetupSortedNbConsSameTsVsTsAdc[ uXyterIdx ]->Draw( "colz" ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) -//====================================================================// - -//====================================================================// - TCanvas* cFebDupliVsRate = new TCanvas( "cFebDupliVsRate", - "Hodoscopes coincidence quality", - w, h); - - cFebDupliVsRate->Divide( fuNbStsXyters, 3 ); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - cFebDupliVsRate->cd( 1 + uXyterIdx ); -// gPad->SetGridx(); -// gPad->SetGridy(); - gPad->SetLogx(); - gPad->SetLogz(); - fhSetupSortedAsicRatioSameTsVsFlux[ uXyterIdx ]->Draw( "colz" ); - - cFebDupliVsRate->cd( 1 + fuNbStsXyters + uXyterIdx ); -// gPad->SetGridx(); -// gPad->SetGridy(); - gPad->SetLogx(); - gPad->SetLogz(); - fhSetupSortedAsicRatioSameTsAdcVsFlux[ uXyterIdx ]->Draw( "colz" ); - - cFebDupliVsRate->cd( 1 + 2*fuNbStsXyters + uXyterIdx ); -// gPad->SetGridx(); -// gPad->SetGridy(); - gPad->SetLogx(); - gPad->SetLogz(); - fhSetupSortedAsicRatioSameAdcSameTsVsFlux[ uXyterIdx ]->Draw( "colz" ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) -//====================================================================// - -//====================================================================// - TCanvas* cDataShares = new TCanvas( "cDataShares", - "Data share per ASIC or type", - w, h); - - cDataShares->Divide( 2 + fuNrOfDpbs, 2 ); - - Color_t colorsList[10] = { kBlue, kRed, kGreen, kMagenta, kYellow, - kGray, kOrange, kCyan, kSpring - 6, kPink +9 }; - - cDataShares->cd( 1 ); - gPad->SetGridx(); - gPad->SetGridy(); - fhFractionAsics->Draw("hist"); - - cDataShares->cd( 2 ); - gPad->SetGridx(); - gPad->SetGridy(); - THStack * stackShareAsicSpill = new THStack( "hsShareAsicSpill", "Fraction of hits for each ASIC" ); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fhFractionHitsAsicSpillEvo[ uXyterIdx ]->SetLineColor( colorsList[uXyterIdx] ); - fhFractionHitsAsicSpillEvo[ uXyterIdx ]->SetFillColor( colorsList[uXyterIdx] ); - - stackShareAsicSpill->Add( fhFractionHitsAsicSpillEvo[ uXyterIdx ] ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - stackShareAsicSpill->Draw( ",hist" ); - - cDataShares->cd( 3 + fuNrOfDpbs ); - gPad->SetGridx(); - gPad->SetGridy(); - fhFractionTypes->Draw("hist"); - - cDataShares->cd( 4 + fuNrOfDpbs ); - gPad->SetGridx(); - gPad->SetGridy(); - THStack * stackShareAsic = new THStack( "hsShareAsic", "Fraction of hits for each ASIC" ); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fhFractionHitsAsicEvo[ uXyterIdx ]->SetLineColor( colorsList[uXyterIdx] ); - fhFractionHitsAsicEvo[ uXyterIdx ]->SetFillColor( colorsList[uXyterIdx] ); - - stackShareAsic->Add( fhFractionHitsAsicEvo[ uXyterIdx ] ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - stackShareAsic->Draw( ",hist" ); - - THStack * stackShareTypesSpill[ fuNrOfDpbs ]; - THStack * stackShareTypes[ fuNrOfDpbs ]; - for( UInt_t uDpbIdx = 0; uDpbIdx < fuNrOfDpbs; ++uDpbIdx ) - { - cDataShares->cd( 3 + uDpbIdx ); - gPad->SetGridx(); - gPad->SetGridy(); - - stackShareTypesSpill[ uDpbIdx ] = new THStack( Form( "hsShareTypes%02uSpill", uDpbIdx), - Form( "Fraction of message types for DPB %02u", uDpbIdx ) ); - - fhFractionGoodHitsSpillEvo[ uDpbIdx ]->SetLineColor( colorsList[ 0 ] ); - fhFractionGoodHitsSpillEvo[ uDpbIdx ]->SetFillColor( colorsList[ 0 ] ); - stackShareTypesSpill[ uDpbIdx ]->Add( fhFractionGoodHitsSpillEvo[ uDpbIdx ] ); - - fhFractionDupliHitsSpillEvo[ uDpbIdx ]->SetLineColor( colorsList[ 1 ] ); - fhFractionDupliHitsSpillEvo[ uDpbIdx ]->SetFillColor( colorsList[ 1 ] ); - stackShareTypesSpill[ uDpbIdx ]->Add( fhFractionDupliHitsSpillEvo[ uDpbIdx ] ); - - fhFractionTsMsbSpillEvo[ uDpbIdx ]->SetLineColor( colorsList[ 2 ] ); - fhFractionTsMsbSpillEvo[ uDpbIdx ]->SetFillColor( colorsList[ 2 ] ); - stackShareTypesSpill[ uDpbIdx ]->Add( fhFractionTsMsbSpillEvo[ uDpbIdx ] ); - - fhFractionEpochSpillEvo[ uDpbIdx ]->SetLineColor( colorsList[ 3 ] ); - fhFractionEpochSpillEvo[ uDpbIdx ]->SetFillColor( colorsList[ 3 ] ); - stackShareTypesSpill[ uDpbIdx ]->Add( fhFractionEpochSpillEvo[ uDpbIdx ] ); - - fhFractionEmptySpillEvo[ uDpbIdx ]->SetLineColor( colorsList[ 4 ] ); - fhFractionEmptySpillEvo[ uDpbIdx ]->SetFillColor( colorsList[ 4 ] ); - stackShareTypesSpill[ uDpbIdx ]->Add( fhFractionEmptySpillEvo[ uDpbIdx ] ); - - stackShareTypesSpill[ uDpbIdx ]->Draw( ",hist" ); - - cDataShares->cd( 5 + fuNrOfDpbs + uDpbIdx ); - gPad->SetGridx(); - gPad->SetGridy(); - - stackShareTypes[ uDpbIdx ] = new THStack( Form( "hsShareTypes%02u", uDpbIdx), - Form( "Fraction of message types for DPB %02u", uDpbIdx ) ); - - fhFractionGoodHitsEvo[ uDpbIdx ]->SetLineColor( colorsList[ 0 ] ); - fhFractionGoodHitsEvo[ uDpbIdx ]->SetFillColor( colorsList[ 0 ] ); - stackShareTypes[ uDpbIdx ]->Add( dynamic_cast< TH1 * >( fhFractionGoodHitsEvo[ uDpbIdx ] ) ); - stackShareTypes[ uDpbIdx ]->Draw("hist"); - - fhFractionDupliHitsEvo[ uDpbIdx ]->SetLineColor( colorsList[ 1 ] ); - fhFractionDupliHitsEvo[ uDpbIdx ]->SetFillColor( colorsList[ 1 ] ); - stackShareTypes[ uDpbIdx ]->Add( fhFractionDupliHitsEvo[ uDpbIdx ] ); - stackShareTypes[ uDpbIdx ]->Draw("hist"); - - fhFractionTsMsbEvo[ uDpbIdx ]->SetLineColor( colorsList[ 2 ] ); - fhFractionTsMsbEvo[ uDpbIdx ]->SetFillColor( colorsList[ 2 ] ); - stackShareTypes[ uDpbIdx ]->Add( fhFractionTsMsbEvo[ uDpbIdx ] ); - stackShareTypes[ uDpbIdx ]->Draw("hist"); - - fhFractionEpochEvo[ uDpbIdx ]->SetLineColor( colorsList[ 3 ] ); - fhFractionEpochEvo[ uDpbIdx ]->SetFillColor( colorsList[ 3 ] ); - stackShareTypes[ uDpbIdx ]->Add( fhFractionEpochEvo[ uDpbIdx ] ); - stackShareTypes[ uDpbIdx ]->Draw("hist"); - - fhFractionEmptyEvo[ uDpbIdx ]->SetLineColor( colorsList[ 4 ] ); - fhFractionEmptyEvo[ uDpbIdx ]->SetFillColor( colorsList[ 4 ] ); - stackShareTypes[ uDpbIdx ]->Add( fhFractionEmptyEvo[ uDpbIdx ] ); - stackShareTypes[ uDpbIdx ]->Draw("hist"); - - stackShareTypes[ uDpbIdx ]->Draw( ",hist" ); - } // for( UInt_t uDpbIdx = 0; uDpbIdx < fuNrOfDpbs; ++uDpbIdx ) - -//====================================================================// - -//====================================================================// - TCanvas* cFebDupliDtPrev = new TCanvas( "cFebDupliDtPrev", - "Duplicate dt to previous hits", - w, h); - - cFebDupliDtPrev->Divide( 2, 3 ); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - cFebDupliDtPrev->cd( 1 + uXyterIdx ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhAsicDuplicDtLastHits[ uXyterIdx ]->Draw( "colz" ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) -//====================================================================// - -//====================================================================// - TCanvas* cFebDupliPrevCompTs = new TCanvas( "cFebDupliPrevCompTs", - "Duplicate and previous hits TS used in comparator", - w, h); - - cFebDupliPrevCompTs->Divide( 2, 3 ); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - cFebDupliPrevCompTs->cd( 1 + uXyterIdx ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhAsicDuplicCompTs[ uXyterIdx ]->Draw( "colz" ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) -//====================================================================// - -//====================================================================// - TCanvas* cFebDupliPrevTsLsb = new TCanvas( "cFebDupliPrevTsLsb", - "Duplicate and previous hits Ts LSB", - w, h); - - cFebDupliPrevTsLsb->Divide( 2, 3 ); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - cFebDupliPrevTsLsb->cd( 1 + uXyterIdx ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhAsicDuplicTsLsb[ uXyterIdx ]->Draw( "colz" ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) -//====================================================================// - -//====================================================================// - TCanvas* cFebDupliPrevTsMsb = new TCanvas( "cFebDupliPrevTsMsb", - "Duplicate and previous hits Ts MSB", - w, h); - - cFebDupliPrevTsMsb->Divide( 2, 3 ); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - cFebDupliPrevTsMsb->cd( 1 + uXyterIdx ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhAsicDuplicTsMsbAsic[ uXyterIdx ]->Draw( "colz" ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) -//====================================================================// - -//====================================================================// - TCanvas* cFebDupliTsScan = new TCanvas( "cFebDupliTsScan", - "Duplicate TS scan", - w, h); - - cFebDupliTsScan->Divide( 2, 3 ); - - cFebDupliTsScan->cd( 1 ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhAsicGoodTs[ 0 ]->Draw( "colz" ); - - cFebDupliTsScan->cd( 2 ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhAsicDuplicTs[ 0 ]->Draw( "colz" ); - - cFebDupliTsScan->cd( 3 ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhAsicGoodTsMsb[ 0 ]->Draw( "colz" ); - - cFebDupliTsScan->cd( 4 ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhAsicDuplicTsMsb[ 0 ]->Draw( "colz" ); - - cFebDupliTsScan->cd( 5 ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhAsicGoodTsFull[ 0 ]->Draw( "colz" ); - - cFebDupliTsScan->cd( 6 ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhAsicDuplicTsFull[ 0 ]->Draw( "colz" ); -//====================================================================// - - // Long duration rate monitoring -/* - if( kTRUE == fbLongHistoEnable ) - { - TCanvas* cStsLongRate = new TCanvas( "cStsLongRate" , "Long duration rate plots for StsXyter", - w, h); - cStsLongRate->Divide( 2, fuNbStsXyters ); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - cStsLongRate->cd( 1 + 2 * uXyterIdx ); - gPad->SetLogy(); - gPad->SetGridx(); - gPad->SetGridy(); - fhFebRateEvoLong[ uXyterIdx ]->Draw( "hist" ); - - cStsLongRate->cd( 2 + 2 * uXyterIdx ); - gPad->SetLogz(); - gPad->SetGridx(); - gPad->SetGridy(); - fhFebChRateEvoLong[ uXyterIdx ]->Draw( "colz" ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - } // if( kTRUE == fbLongHistoEnable ) -*/ -/* - Int_t iNbPadsPerDpb = fuNbElinksPerDpb/2 + fuNbElinksPerDpb%2; - TCanvas* cMuchChCounts = new TCanvas("cMuchChCounts", "MUCH Channels counts", w, h); - cMuchChCounts->Divide( fNrOfNdpbs/2 + fNrOfNdpbs%2, fNrOfFebsPerNdpb ); - - TCanvas* cMuchFebRate = new TCanvas("cMuchFebRate", "MUCH FEB rate", w, h); - cMuchFebRate->Divide( fNrOfNdpbs/2 + fNrOfNdpbs%2, fNrOfFebsPerNdpb ); - - TH1* histPnt = NULL; - for( Int_t dpbId = 0; dpbId < fNrOfNdpbs; dpbId++) - {// looping on all the nDPBS IDs - if( dpbId < fUnpackParHodo->GetNrOfnDpbsModA() ) - { - sNdpbTag = Form("%04X", fUnpackParHodo->GetNdpbIdA(dpbId) ); - } // if( dpbId < fUnpackParHodo->GetNrOfnDpbsModA() ) - else - { - sNdpbTag = Form("%04X", fUnpackParHodo->GetNdpbIdB(dpbId - fNrOfNdpbsA) ); - } // else of if( dpbId < fUnpackParHodo->GetNrOfnDpbsModA() ) - - for( Int_t febId = 0; febId < fNrOfFebsPerNdpb; febId++) - {// looping on all the FEB IDs - cMuchChCounts->cd( 1 + dpbId * iNbPadsPerDpb + febId/2 ); - gPad->SetLogy(); - sHistName = Form("Chan_Counts_Much_n%s_f%1u", sNdpbTag.Data(), febId); - histPnt = fHM->H1(sHistName.Data()); - - if( 0 == febId%2 ) - { - histPnt->SetLineColor( kRed ); // => Change color for 1st of the 2/pad! - histPnt->Draw(); - } // if( 0 == febId%2 ) - else - { - histPnt->SetLineColor( kBlue ); // => Change color for 1nd of the 2/pad! - histPnt->Draw("same"); - } // if( 0 == febId%2 ) - - cMuchFebRate->cd( 1 + dpbId * iNbPadsPerDpb + febId/2 ); - gPad->SetLogy(); - sHistName = Form("FebRate_n%s_f%1u", sNdpbTag.Data(), febId); - histPnt = fHM->H1(sHistName.Data()); - - if( 0 == febId%2 ) - { - histPnt->SetLineColor( kRed ); // => Change color for 1st of the 2/pad! - histPnt->Draw(); - } // if( 0 == febId%2 ) - else - { - histPnt->SetLineColor( kBlue ); // => Change color for 1nd of the 2/pad! - histPnt->Draw("same"); - } // if( 0 == febId%2 ) - } // for( Int_t febId = 0; febId < fNrOfFebsPerNdpb; febId++) - } // for( Int_t dpbId = 0; dpbId < fNrOfNdpbs; dpbId++) -*/ - - /** Recovers/Create Ms Size Canvase for CERN 2016 **/ - // Try to recover canvas in case it was created already by another monitor - // If not existing, create it - fcMsSizeAll = dynamic_cast<TCanvas *>( gROOT->FindObject( "cMsSizeAll" ) ); - if( NULL == fcMsSizeAll ) - { - fcMsSizeAll = new TCanvas("cMsSizeAll", "Evolution of MS size in last 300 s", w, h); - fcMsSizeAll->Divide( 4, 4 ); - LOG(info) << "Created MS size canvas in STS monitor"; - } // if( NULL == fcMsSizeAll ) - else LOG(info) << "Recovered MS size canvas in STS monitor"; - - /*****************************/ -} - -Bool_t CbmCosy2018MonitorDupli::DoUnpack(const fles::Timeslice& ts, size_t component) -{ - THttpServer* server = FairRunOnline::Instance()->GetHttpServer(); - - if( bCosy2018ResetDupliHistos ) - { - ResetAllHistos(); - bCosy2018ResetDupliHistos = kFALSE; - } // if( bCosy2018ResetDupliHistos ) - if( bCosy2018WriteDupliHistos ) - { - SaveAllHistos( fsHistoFileFullname ); - bCosy2018WriteDupliHistos = kFALSE; - } // if( bCosy2018WriteDupliHistos ) - if( bCosy2018PrintMessDupliHistos ) - { - fuPrintMessagesIdx = 0; - bCosy2018PrintMessDupliHistos = kFALSE; - } // if( bCosy2018PrintMessDupliHistos ) - - LOG(debug) << "Timeslice contains " << ts.num_microslices(component) - << "microslices."; - - if( component < kiMaxNbFlibLinks ) - if( NULL == fhMsSz[ component ] ) - { - TString sMsSzName = Form("MsSz_link_%02lu", component); - TString sMsSzTitle = Form("Size of MS for nDPB of link %02lu; Ms Size [bytes]", component); - fhMsSz[ component ] = new TH1F( sMsSzName.Data(), sMsSzTitle.Data(), 160000, 0., 20000. ); - fHM->Add(sMsSzName.Data(), fhMsSz[ component ] ); - if (server) server->Register("/FlibRaw", fhMsSz[ component ] ); - sMsSzName = Form("MsSzTime_link_%02lu", component); - sMsSzTitle = Form("Size of MS vs time for gDPB of link %02lu; Time[s] ; Ms Size [bytes]", component); - fhMsSzTime[ component ] = new TProfile( sMsSzName.Data(), sMsSzTitle.Data(), 15000, 0., 300. ); - fHM->Add( sMsSzName.Data(), fhMsSzTime[ component ] ); - if (server) server->Register("/FlibRaw", fhMsSzTime[ component ] ); - if( NULL != fcMsSizeAll ) - { - fcMsSizeAll->cd( 1 + component ); - gPad->SetLogy(); - fhMsSzTime[ component ]->Draw("hist le0"); - } // if( NULL != fcMsSizeAll ) - LOG(info) << "Added MS size histo for component: " << component - << " (DPB)"; - } // if( NULL == fhMsSz[ component ] ) - -// Int_t messageType = -111; - // Loop over microslices - size_t numCompMsInTs = ts.num_microslices(component); -/* - if( fulCurrentTsIdx + 1 != ts.index() && 0 == component) - LOG(info) << "Missed TS from " << fulCurrentTsIdx - << " to " << ts.index(); -*/ - fulCurrentTsIdx = ts.index(); - - if( fuMaxNbMicroslices < numCompMsInTs ) - { - fuMaxNbMicroslices = numCompMsInTs; - - fvdMsTime.resize( fuMaxNbMicroslices ); - fvuChanNbHitsInMs.resize( fuNbStsXyters ); - fvdChanLastHitTimeInMs.resize( fuNbStsXyters ); - fvusChanLastHitAdcInMs.resize( fuNbStsXyters ); - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fvuChanNbHitsInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvdChanLastHitTimeInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvusChanLastHitAdcInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - { - fvuChanNbHitsInMs[ uXyterIdx ][ uChan ].resize( fuMaxNbMicroslices ); - fvdChanLastHitTimeInMs[ uXyterIdx ][ uChan ].resize( fuMaxNbMicroslices ); - fvusChanLastHitAdcInMs[ uXyterIdx ][ uChan ].resize( fuMaxNbMicroslices ); - for( UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx ) - { - fvuChanNbHitsInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = 0; - fvdChanLastHitTimeInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = -1.0; - fvusChanLastHitAdcInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = 0; - } // for( UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx ) - } // for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - LOG(info) << "CbmCosy2018MonitorDupli::DoUnpack => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs.size() << " VS " << fuNbStsXyters; - LOG(info) << "CbmCosy2018MonitorDupli::DoUnpack => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs[ 0 ].size() << " VS " << fuNbChanPerAsic; - LOG(info) << "CbmCosy2018MonitorDupli::DoUnpack => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs[ 0 ][ 0 ].size() << " VS " << fuMaxNbMicroslices; - } // if( fuMaxNbMicroslices < numCompMsInTs ) - - for( size_t m = 0; m < numCompMsInTs; ++m ) - { - // Ignore overlap ms if number defined by user - if( numCompMsInTs - fuOverlapMsNb <= m ) - continue; - - auto msDescriptor = ts.descriptor(component, m); - fuCurrentEquipmentId = msDescriptor.eq_id; - const uint8_t* msContent = reinterpret_cast<const uint8_t*>(ts.content(component, m)); - - uint32_t size = msDescriptor.size; - fulCurrentMsIdx = msDescriptor.idx; - Double_t dMsTime = (1e-9) * static_cast<double>(fulCurrentMsIdx); - LOG(debug) << "Microslice: " << fulCurrentMsIdx - << " from EqId " << std::hex << fuCurrentEquipmentId << std::dec - << " has size: " << size; - - fuCurrDpbId = static_cast< uint32_t >( fuCurrentEquipmentId & 0xFFFF ); - fuCurrDpbIdx = fDpbIdIndexMap[ fuCurrDpbId ]; - - if( component < kiMaxNbFlibLinks ) - { - if( fdStartTimeMsSz < 0 ) - fdStartTimeMsSz = dMsTime; - fhMsSz[ component ]->Fill( size ); - fhMsSzTime[ component ]->Fill( dMsTime - fdStartTimeMsSz, size); - } // if( component < kiMaxNbFlibLinks ) - - // Store MS time for coincidence plots - fvdMsTime[ m ] = dMsTime; - - // If not integer number of message in input buffer, print warning/error - if( 0 != (size % kuBytesPerMessage) ) - LOG(error) << "The input microslice buffer does NOT " - << "contain only complete nDPB messages!"; - - // Compute the number of complete messages in the input microslice buffer - uint32_t uNbMessages = (size - (size % kuBytesPerMessage) ) - / kuBytesPerMessage; - - // Prepare variables for the loop on contents - const uint32_t* pInBuff = reinterpret_cast<const uint32_t*>( msContent ); - - for( uint32_t uIdx = 0; uIdx < uNbMessages; ++uIdx ) - { - // Fill message - uint32_t ulData = static_cast<uint32_t>(pInBuff[uIdx]); - - stsxyter::Message mess( static_cast< uint32_t >( ulData & 0xFFFFFFFF ) ); - - // Print message if requested - if( fbPrintMessages ) - mess.PrintMess( std::cout, fPrintMessCtrl ); - - stsxyter::MessType typeMess = mess.GetMessType(); - fmMsgCounter[ typeMess ] ++; - fhHodoMessType->Fill( static_cast< uint16_t > (typeMess) ); - fhHodoMessTypePerDpb->Fill( fuCurrDpbIdx, static_cast< uint16_t > (typeMess) ); - - switch( typeMess ) - { - case stsxyter::MessType::Hit : - { - // Extract the eLink and Asic indices => Should GO IN the fill method now that obly hits are link/asic specific! - UShort_t usElinkIdx = mess.GetLinkIndex(); - if( fuNbElinksPerDpb <= usElinkIdx ) - { - LOG(fatal) << "CbmCosy2018MonitorDupli::DoUnpack => " - << "eLink index out of bounds!" - << usElinkIdx << " VS " << fuNbElinksPerDpb; - } // if( fuNbElinksPerDpb <= usElinkIdx ) - fhHodoMessTypePerElink->Fill( fuCurrDpbIdx * fuNbElinksPerDpb + usElinkIdx, - static_cast< uint16_t > (typeMess) ); - - UInt_t uAsicIdx = fvuElinkToAsic[fuCurrDpbIdx][usElinkIdx]; - - FillHitInfo( mess, usElinkIdx, uAsicIdx, m ); - break; - } // case stsxyter::MessType::Hit : - case stsxyter::MessType::TsMsb : - { - FillTsMsbInfo( mess, uIdx, m ); - - Double_t dTsMsbTime = ( ( static_cast<ULong64_t>( stsxyter::kuHitNbTsBins ) - * static_cast<ULong64_t>( fvulCurrentTsMsb[fuCurrDpbIdx]) - + static_cast<ULong64_t>( stsxyter::kulTsCycleNbBins ) - * static_cast<ULong64_t>( fvuCurrentTsMsbCycle[fuCurrDpbIdx] ) - ) * stsxyter::kdClockCycleNs - - fdStartTime - )* 1e-9; - - fhFractionGoodHitsSpillEvo[ fuCurrDpbIdx ]->Fill( dTsMsbTime, 0.0 ); - fhFractionDupliHitsSpillEvo[ fuCurrDpbIdx ]->Fill( dTsMsbTime, 0.0 ); - fhFractionTsMsbSpillEvo[ fuCurrDpbIdx ]->Fill( dTsMsbTime, 1.0 ); - fhFractionEpochSpillEvo[ fuCurrDpbIdx ]->Fill( dTsMsbTime, 0.0 ); - fhFractionEmptySpillEvo[ fuCurrDpbIdx ]->Fill( dTsMsbTime, 0.0 ); - - fhFractionGoodHitsEvo[ fuCurrDpbIdx ]->Fill( dTsMsbTime, 0.0 ); - fhFractionDupliHitsEvo[ fuCurrDpbIdx ]->Fill( dTsMsbTime, 0.0 ); - fhFractionTsMsbEvo[ fuCurrDpbIdx ]->Fill( dTsMsbTime, 1.0 ); - fhFractionEpochEvo[ fuCurrDpbIdx ]->Fill( dTsMsbTime, 0.0 ); - fhFractionEmptyEvo[ fuCurrDpbIdx ]->Fill( dTsMsbTime, 0.0 ); - - fhFractionTypes->Fill( 0., 0.0 ); // Good Hit - fhFractionTypes->Fill( 1., 0.0 ); // Dupli Hit - fhFractionTypes->Fill( 2., 1.0 ); // Ts MSB - fhFractionTypes->Fill( 3., 0.0 ); // Epoch - fhFractionTypes->Fill( 4., 0.0 ); // Empty - - break; - } // case stsxyter::MessType::TsMsb : - case stsxyter::MessType::Epoch : - { - // The first message in the TS is a special ones: EPOCH - FillEpochInfo( mess ); - - Double_t dTsMsbTime = ( ( static_cast<ULong64_t>( stsxyter::kuHitNbTsBins ) - * static_cast<ULong64_t>( fvulCurrentTsMsb[fuCurrDpbIdx]) - + static_cast<ULong64_t>( stsxyter::kulTsCycleNbBins ) - * static_cast<ULong64_t>( fvuCurrentTsMsbCycle[fuCurrDpbIdx] ) - ) * stsxyter::kdClockCycleNs - - fdStartTime - )* 1e-9; - - fhFractionGoodHitsSpillEvo[ fuCurrDpbIdx ]->Fill( dTsMsbTime, 0.0 ); - fhFractionDupliHitsSpillEvo[ fuCurrDpbIdx ]->Fill( dTsMsbTime, 0.0 ); - fhFractionTsMsbSpillEvo[ fuCurrDpbIdx ]->Fill( dTsMsbTime, 0.0 ); - fhFractionEpochSpillEvo[ fuCurrDpbIdx ]->Fill( dTsMsbTime, 1.0 ); - fhFractionEmptySpillEvo[ fuCurrDpbIdx ]->Fill( dTsMsbTime, 0.0 ); - - fhFractionGoodHitsEvo[ fuCurrDpbIdx ]->Fill( dTsMsbTime, 0.0 ); - fhFractionDupliHitsEvo[ fuCurrDpbIdx ]->Fill( dTsMsbTime, 0.0 ); - fhFractionTsMsbEvo[ fuCurrDpbIdx ]->Fill( dTsMsbTime, 0.0 ); - fhFractionEpochEvo[ fuCurrDpbIdx ]->Fill( dTsMsbTime, 1.0 ); - fhFractionEmptyEvo[ fuCurrDpbIdx ]->Fill( dTsMsbTime, 0.0 ); - - fhFractionTypes->Fill( 0., 0.0 ); // Good Hit - fhFractionTypes->Fill( 1., 0.0 ); // Dupli Hit - fhFractionTypes->Fill( 2., 0.0 ); // Ts MSB - fhFractionTypes->Fill( 3., 1.0 ); // Epoch - fhFractionTypes->Fill( 4., 0.0 ); // Empty - - if( 0 < uIdx ) - LOG(info) << "CbmCosy2018MonitorDupli::DoUnpack => " - << "EPOCH message at unexpected position in MS: message " - << uIdx << " VS message 0 expected!"; - break; - } // case stsxyter::MessType::TsMsb : - case stsxyter::MessType::Empty : - { -// FillTsMsbInfo( mess ); - - Double_t dTsMsbTime = ( ( static_cast<ULong64_t>( stsxyter::kuHitNbTsBins ) - * static_cast<ULong64_t>( fvulCurrentTsMsb[fuCurrDpbIdx]) - + static_cast<ULong64_t>( stsxyter::kulTsCycleNbBins ) - * static_cast<ULong64_t>( fvuCurrentTsMsbCycle[fuCurrDpbIdx] ) - ) * stsxyter::kdClockCycleNs - - fdStartTime - )* 1e-9; - - fhFractionGoodHitsSpillEvo[ fuCurrDpbIdx ]->Fill( dTsMsbTime, 0.0 ); - fhFractionDupliHitsSpillEvo[ fuCurrDpbIdx ]->Fill( dTsMsbTime, 0.0 ); - fhFractionTsMsbSpillEvo[ fuCurrDpbIdx ]->Fill( dTsMsbTime, 0.0 ); - fhFractionEpochSpillEvo[ fuCurrDpbIdx ]->Fill( dTsMsbTime, 0.0 ); - fhFractionEmptySpillEvo[ fuCurrDpbIdx ]->Fill( dTsMsbTime, 1.0 ); - - fhFractionGoodHitsEvo[ fuCurrDpbIdx ]->Fill( dTsMsbTime, 0.0 ); - fhFractionDupliHitsEvo[ fuCurrDpbIdx ]->Fill( dTsMsbTime, 0.0 ); - fhFractionTsMsbEvo[ fuCurrDpbIdx ]->Fill( dTsMsbTime, 0.0 ); - fhFractionEpochEvo[ fuCurrDpbIdx ]->Fill( dTsMsbTime, 0.0 ); - fhFractionEmptyEvo[ fuCurrDpbIdx ]->Fill( dTsMsbTime, 1.0 ); - - fhFractionTypes->Fill( 0., 0.0 ); // Good Hit - fhFractionTypes->Fill( 1., 0.0 ); // Dupli Hit - fhFractionTypes->Fill( 2., 0.0 ); // Ts MSB - fhFractionTypes->Fill( 3., 0.0 ); // Epoch - fhFractionTypes->Fill( 4., 1.0 ); // Empty - - break; - } // case stsxyter::MessType::Empty : - case stsxyter::MessType::Dummy : - { - break; - } // case stsxyter::MessType::Dummy / ReadDataAck / Ack : - default: - { - LOG(fatal) << "CbmCosy2018MonitorDupli::DoUnpack => " - << "Unknown message type, should never happen, stopping here!"; - } - } // switch( mess.GetMessType() ) - } // for( uint32_t uIdx = 0; uIdx < uNbMessages; ++uIdx ) - - // Sort the buffer of hits - std::sort( fvmHitsInTs.begin(), fvmHitsInTs.end() ); - - // Time differences plotting using the fully time sorted hits -/* - Double_t dLastTimeX1 = -1e12; - Double_t dLastTimeY1 = -1e12; - Double_t dLastTimeX2 = -1e12; - Double_t dLastTimeY2 = -1e12; - Double_t dLastTimeN1 = -1e12; - Double_t dLastTimeP1 = -1e12; - Double_t dLastTimeN2 = -1e12; - Double_t dLastTimeP2 = -1e12; - Double_t dDtX1Y1 = -1e12; - Double_t dDtX2Y2 = -1e12; - Double_t dDtN1P1 = -1e12; - Double_t dDtN2P2 = -1e12; - Double_t dDtX1Y1X2Y2 = -1e12; - Double_t dDtN1P1N2P2 = -1e12; - Double_t dDtX1Y1X2Y2N1P1 = -1e12; - Double_t dDtX1Y1X2Y2N2P2 = -1e12; - Double_t dDtH1H2S1S2 = -1e12; -*/ - if( 0 < fvmHitsInTs.size() ) - { -// ULong64_t ulLastHitTime = ( *( fvmHitsInTs.rbegin() ) ).GetTs(); - std::vector< stsxyter::FinalHit >::iterator it; - -// std::chrono::steady_clock::time_point tNow = std::chrono::steady_clock::now(); -// Double_t dUnixTimeInRun = std::chrono::duration_cast< std::chrono::seconds >(tNow - ftStartTimeUnix).count(); - - for( it = fvmHitsInTs.begin(); - it != fvmHitsInTs.end(); -// it != fvmHitsInTs.end() && (*it).GetTs() < ulLastHitTime - 320; // 32 * 3.125 ns = 1000 ns - ++it ) - { - UShort_t usAsicIdx = (*it).GetAsic(); - UShort_t usChanIdx = (*it).GetChan(); - ULong64_t ulHitTs = (*it).GetTs(); - UShort_t usHitAdc = (*it).GetAdc(); - -// Bool_t bHitInX = usChanIdx < fuNbChanPerAsic/2; - - Double_t dTimeSinceStartSec = (ulHitTs * stsxyter::kdClockCycleNs - fdStartTime)* 1e-9; - - if( 0 == ulHitTs - fvulTimeLastHitAsicChan[ usAsicIdx ][ usChanIdx ] || - ( 0 < fvuNbSameFullHitAsicChan[ usAsicIdx ][ usChanIdx ] && - 0 == ( ulHitTs - fvulTimeLastHitAsicChan[ usAsicIdx ][ usChanIdx ] ) % 512 ) ) - { - fhFractionGoodHitsSpillEvo[ fuCurrDpbIdx ]->Fill( dTimeSinceStartSec, 0.0 ); - fhFractionDupliHitsSpillEvo[ fuCurrDpbIdx ]->Fill( dTimeSinceStartSec, 1.0 ); - fhFractionTsMsbSpillEvo[ fuCurrDpbIdx ]->Fill( dTimeSinceStartSec, 0.0 ); - fhFractionEpochSpillEvo[ fuCurrDpbIdx ]->Fill( dTimeSinceStartSec, 0.0 ); - fhFractionEmptySpillEvo[ fuCurrDpbIdx ]->Fill( dTimeSinceStartSec, 0.0 ); - - fhFractionGoodHitsEvo[ fuCurrDpbIdx ]->Fill( dTimeSinceStartSec, 0.0 ); - fhFractionDupliHitsEvo[ fuCurrDpbIdx ]->Fill( dTimeSinceStartSec, 1.0 ); - fhFractionTsMsbEvo[ fuCurrDpbIdx ]->Fill( dTimeSinceStartSec, 0.0 ); - fhFractionEpochEvo[ fuCurrDpbIdx ]->Fill( dTimeSinceStartSec, 0.0 ); - fhFractionEmptyEvo[ fuCurrDpbIdx ]->Fill( dTimeSinceStartSec, 0.0 ); - - fhFractionTypes->Fill( 0., 0.0 ); // Good Hit - fhFractionTypes->Fill( 1., 1.0 ); // Dupli Hit - fhFractionTypes->Fill( 2., 0.0 ); // Ts MSB - fhFractionTypes->Fill( 3., 0.0 ); // Epoch - fhFractionTypes->Fill( 4., 0.0 ); // Empty - - if( 0 == fviAdcLastHitAsicChan[ usAsicIdx ][ usChanIdx ] - usHitAdc ) - { - fvuNbSameFullHitAsicChan[ usAsicIdx ][ usChanIdx ] ++; - fvuNbHitSameTsAdcAsicLastS[ usAsicIdx ] ++; - - fhRatioSameTsAdcSpillEvo[ usAsicIdx ]->Fill( dTimeSinceStartSec, usChanIdx, 1.0 ); - fhRatioSameAdcSameTsSpillEvo[ usAsicIdx ]->Fill( dTimeSinceStartSec, usChanIdx, 1.0 ); - - if( 0 == fvuNbSameFullHitAsic[ usAsicIdx ] && 1 < fvuNbDiffFullHitAsic[ usAsicIdx ] ) - { - UInt_t uBitPattComp = 0; - UInt_t uBitPattLsb = 0; - UInt_t uBitPattMsb = 0; - ULong64_t ulDuplHitTs = fvmLastHitsAsic[ usAsicIdx ][ fvuLastHitBufferIdx[ usAsicIdx ] ].GetTs(); - - fhAsicDuplicTs[ usAsicIdx ]->Fill( usChanIdx, ( ulDuplHitTs & 0x000FF ) ); - fhAsicDuplicTsMsb[ usAsicIdx ]->Fill( usChanIdx, ( ulDuplHitTs & 0x0FF00 ) >> 8 ); - fhAsicDuplicTsFull[ usAsicIdx ]->Fill( usChanIdx, ( ulDuplHitTs & 0x03FFF ) ); - - if( 0 == usAsicIdx ) - { - if( 0 == usChanIdx ) - fhAsicDuplicTsEvoAsic0Chan01->Fill( dTimeSinceStartSec, ( ulDuplHitTs & 0x00FFF ) ); - else if( 20 == usChanIdx ) - fhAsicDuplicTsEvoAsic0Chan09->Fill( dTimeSinceStartSec, ( ulDuplHitTs & 0x00FFF ) ); - else if( 99 == usChanIdx ) - fhAsicDuplicTsEvoAsic0Chan16->Fill( dTimeSinceStartSec, ( ulDuplHitTs & 0x00FFF ) ); - } // if( 0 == usAsicIdx ) - - for( UInt_t uBit = 0; uBit < 14; ++uBit ) - { - fhAsicDuplicTsBitPattern[ usAsicIdx ]->Fill( uBit, ( ( ulDuplHitTs >> uBit ) & 0x1) ); - } // for( UInt_t uBit = 0; uBit < 14; ++uBit ) - - for( UInt_t uPrevHit = 0; uPrevHit < fuNbChanPerAsic; ++uPrevHit ) - { - UInt_t uBufferIdx = ( fvuLastHitBufferIdx[ usAsicIdx ] < uPrevHit ) ? - ( fvuLastHitBufferIdx[ usAsicIdx ] - uPrevHit + fuNbChanPerAsic ): - ( fvuLastHitBufferIdx[ usAsicIdx ] - uPrevHit ); - - ULong64_t ulPrevHitTs = fvmLastHitsAsic[ usAsicIdx ][ uBufferIdx ].GetTs(); - UInt_t uCompTs = ( ulPrevHitTs & 0x01FC0 ) >> 6; - UInt_t uTsLsb = ( ulPrevHitTs & 0x000FF ); - UInt_t uTsMsb = ( ulPrevHitTs & 0x03F00 ) >> 8; - - uBitPattComp |= uCompTs; - uBitPattLsb |= uTsLsb; - uBitPattMsb |= uTsMsb; - - Double_t dDt = static_cast< Double_t >(ulDuplHitTs) - static_cast< Double_t >(ulPrevHitTs); - - if( 2048 < dDt ) - break; - - fhAsicDuplicDtLastHits[ usAsicIdx ]->Fill( dDt, uPrevHit ); - fhAsicDuplicCompTs[ usAsicIdx ]->Fill( uPrevHit, uCompTs ); - fhAsicDuplicTsLsb[ usAsicIdx ]->Fill( uPrevHit, uTsLsb ); - fhAsicDuplicTsMsbAsic[ usAsicIdx ]->Fill( uPrevHit, uTsMsb ); - - for( UInt_t uBit = 0; uBit < 8; ++uBit ) - { - if( 1 == ( ( uBitPattComp >> uBit ) & 0x1) ) - fhAsicDuplicCompTsBitThere[ usAsicIdx ]->Fill( uPrevHit, uBit ); - - if( 1 == ( ( uBitPattLsb >> uBit ) & 0x1) ) - fhAsicDuplicTsLsbBitThere[ usAsicIdx ]->Fill( uPrevHit, uBit ); - - if( 1 == ( ( uBitPattMsb >> uBit ) & 0x1) ) - fhAsicDuplicTsMsbBitThere[ usAsicIdx ]->Fill( uPrevHit, uBit ); - } // for( UInt_t uBit = 0; uBit < 8; ++uBit ) - } // for( UInt_t uPrevHit = 0; uPrevHit < fuNbChanPerAsic; ++uPrevHit ) - } // if( 0 == fvuNbSameFullHitAsic[ usAsicIdx ] && 1 < fvuNbDiffFullHitAsic[ usAsicIdx ] ) - fvuNbSameFullHitAsic[ usAsicIdx ] ++; - fvuNbDiffFullHitAsic[ usAsicIdx ] = 0; - } // if( 0 == fviAdcLastHitAsicChan[ usAsicIdx ][ usChanIdx ] - usHitAdc ) - else - { - fhSetupSortedNbConsSameTsAdcChan[ usAsicIdx ]->Fill( usChanIdx, fvuNbSameFullHitAsicChan[ usAsicIdx ][ usChanIdx ] ); - fhSetupSortedNbConsSameTsVsTsAdc[ usAsicIdx ]->Fill( fvuNbSameHitAsicChan[ usAsicIdx ][ usChanIdx ], - fvuNbSameFullHitAsicChan[ usAsicIdx ][ usChanIdx ] ); - fvuNbSameFullHitAsicChan[ usAsicIdx ][ usChanIdx ] = 0; - - fhRatioSameAdcSameTsSpillEvo[ usAsicIdx ]->Fill( dTimeSinceStartSec, usChanIdx, 0.0 ); - } // else of if( 0 == fviAdcLastHitAsicChan[ usAsicIdx ][ usChanIdx ] - usHitAdc ) - - fvuNbSameHitAsicChan[ usAsicIdx ][ usChanIdx ] ++; - fvuNbHitSameTsAsicLastS[ usAsicIdx ] ++; -/* - LOG(info) << Form("Bad Hit on asic %u chan %3u, #%3u => TS %9llu ADC %2u VS TS %9llu ADC %2u", - usAsicIdx, usChanIdx, fvuNbSameHitAsicChan[ usAsicIdx ][ usChanIdx ], - ulHitTs, usHitAdc, - fvulTimeLastHitAsicChan[ usAsicIdx ][ usChanIdx ], - fviAdcLastHitAsicChan[ usAsicIdx ][ usChanIdx ] ); -*/ - fhSetupSortedNbSameTsChan[ usAsicIdx ]->Fill( dTimeSinceStartSec, usChanIdx ); - fhSetupSortedSameTsAdcChan[ usAsicIdx ]->Fill( usChanIdx, usHitAdc ); - fhSetupSortedSameTsAdcChan[ usAsicIdx ]->Fill( usChanIdx, fviAdcLastHitAsicChan[ usAsicIdx ][ usChanIdx ] ); - fhSetupSortedSameTsAdcDiff[ usAsicIdx ]->Fill( fvuNbSameHitAsicChan[ usAsicIdx ][ usChanIdx ], - static_cast< Int_t >( usHitAdc ) - - fviAdcLastHitAsicChan[ usAsicIdx ][ usChanIdx ] ); - fhSetupSortedRatioSameTsChan[ usAsicIdx ]->Fill( dTimeSinceStartSec, usChanIdx, 1.0 ); - - fhRatioSameTsSpillEvo[ usAsicIdx ]->Fill( dTimeSinceStartSec, usChanIdx, 1.0 ); - - if( 1 == fvuNbSameHitAsicChan[ usAsicIdx ][ usChanIdx ] ) - fhSetupSortedTsFirstDuplicateChan[ usAsicIdx ]->Fill( usChanIdx, ulHitTs % 512 ); - } // if( 0 == ulHitTs - fvulTimeLastHitAsicChan[ usAsicIdx ][ usChanIdx ] ) - else - { - fhFractionGoodHitsSpillEvo[ fuCurrDpbIdx ]->Fill( dTimeSinceStartSec, 1.0 ); - fhFractionDupliHitsSpillEvo[ fuCurrDpbIdx ]->Fill( dTimeSinceStartSec, 0.0 ); - fhFractionTsMsbSpillEvo[ fuCurrDpbIdx ]->Fill( dTimeSinceStartSec, 0.0 ); - fhFractionEpochSpillEvo[ fuCurrDpbIdx ]->Fill( dTimeSinceStartSec, 0.0 ); - fhFractionEmptySpillEvo[ fuCurrDpbIdx ]->Fill( dTimeSinceStartSec, 0.0 ); - - fhFractionGoodHitsEvo[ fuCurrDpbIdx ]->Fill( dTimeSinceStartSec, 1.0 ); - fhFractionDupliHitsEvo[ fuCurrDpbIdx ]->Fill( dTimeSinceStartSec, 0.0 ); - fhFractionTsMsbEvo[ fuCurrDpbIdx ]->Fill( dTimeSinceStartSec, 0.0 ); - fhFractionEpochEvo[ fuCurrDpbIdx ]->Fill( dTimeSinceStartSec, 0.0 ); - fhFractionEmptyEvo[ fuCurrDpbIdx ]->Fill( dTimeSinceStartSec, 0.0 ); - - fhFractionTypes->Fill( 0., 1.0 ); // Good Hit - fhFractionTypes->Fill( 1., 0.0 ); // Dupli Hit - fhFractionTypes->Fill( 2., 0.0 ); // Ts MSB - fhFractionTypes->Fill( 3., 0.0 ); // Epoch - fhFractionTypes->Fill( 4., 0.0 ); // Empty -/* - if( 100 < fvuNbSameHitAsicChan[ usAsicIdx ][ usChanIdx ] ) - LOG(fatal) << " More than 100 consecutive hits with same TS on asic" - << usAsicIdx << " chan " << usChanIdx - << " => " << fvuNbSameHitAsicChan[ usAsicIdx ][ usChanIdx ]; -*/ - fhSetupSortedNbConsSameTsVsTsAdc[ usAsicIdx ]->Fill( fvuNbSameHitAsicChan[ usAsicIdx ][ usChanIdx ], - fvuNbSameFullHitAsicChan[ usAsicIdx ][ usChanIdx ] ); - - fhSetupSortedNbConsSameTsChan[ usAsicIdx ]->Fill( usChanIdx, fvuNbSameHitAsicChan[ usAsicIdx ][ usChanIdx ] ); - fvuNbSameHitAsicChan[ usAsicIdx ][ usChanIdx ] = 0; - - fhSetupSortedNbConsSameTsAdcChan[ usAsicIdx ]->Fill( usChanIdx, fvuNbSameFullHitAsicChan[ usAsicIdx ][ usChanIdx ] ); - fvuNbSameFullHitAsicChan[ usAsicIdx ][ usChanIdx ] = 0; - - fhSetupSortedRatioSameTsChan[ usAsicIdx ]->Fill( dTimeSinceStartSec, usChanIdx, 0.0 ); - - fhRatioSameTsSpillEvo[ usAsicIdx ]->Fill( dTimeSinceStartSec, usChanIdx, 0.0 ); - fhRatioSameTsAdcSpillEvo[ usAsicIdx ]->Fill( dTimeSinceStartSec, usChanIdx, 0.0 ); - - fhHodoChanCntGood[ usAsicIdx ]->Fill( usChanIdx, usHitAdc ); - fhHodoChanGoodHitRateEvo[ usAsicIdx ]->Fill( dTimeSinceStartSec, usChanIdx ); - - fvuNbHitDiffTsAsicLastS[ usAsicIdx ]++; - - fhSetupSortedTsGoodChan[ usAsicIdx ]->Fill( usChanIdx, ulHitTs % 512 ); - - if( 0 < fvuNbDiffFullHitAsic[ usAsicIdx ] ) - { - fhAsicGoodTs[ usAsicIdx ]->Fill( usChanIdx, ( ulHitTs & 0x000FF ) ); - fhAsicGoodTsMsb[ usAsicIdx ]->Fill( usChanIdx, ( ulHitTs & 0x0FF00 ) >> 8 ); - fhAsicGoodTsFull[ usAsicIdx ]->Fill( usChanIdx, ( ulHitTs & 0x03FFF ) ); - if( 0 == usAsicIdx ) - { - if( 0 == usChanIdx ) - { - fhAsicGoodTsEvoAsic0Chan01->Fill( dTimeSinceStartSec, ( ulHitTs & 0x00FFF ) ); - fhAsicGoodTsMsbEvoAsic0Chan01->Fill( dTimeSinceStartSec, ( ulHitTs & 0x0FF00 ) >> 8 ); - fhAsicGoodTsFullEvoAsic0Chan01->Fill( dTimeSinceStartSec, ( ulHitTs & 0x03FFF ) ); - fhAsicGoodTsFullEvoProfAsic0Chan01->Fill( dTimeSinceStartSec, ( ulHitTs & 0x03FFF ) ); - } //if( 3 == usChanIdx ) - else if( 20 == usChanIdx ) - { - fhAsicGoodTsEvoAsic0Chan09->Fill( dTimeSinceStartSec, ( ulHitTs & 0x00FFF ) ); - fhAsicGoodTsFullEvoProfAsic0Chan09->Fill( dTimeSinceStartSec, ( ulHitTs & 0x03FFF ) ); - } // else if( 20 == usChanIdx ) - else if( 99 == usChanIdx ) - { - fhAsicGoodTsEvoAsic0Chan16->Fill( dTimeSinceStartSec, ( ulHitTs & 0x00FFF ) ); - fhAsicGoodTsFullEvoProfAsic0Chan16->Fill( dTimeSinceStartSec, ( ulHitTs & 0x03FFF ) ); - } // else if( 99 == usChanIdx ) - } // if( 0 == usAsicIdx ) - - for( UInt_t uBit = 0; uBit < 14; ++uBit ) - { - fhAsicGoodTsBitPattern[ usAsicIdx ]->Fill( uBit, ( ( ulHitTs >> uBit ) & 0x1) ); - } // for( UInt_t uBit = 0; uBit < 14; ++uBit ) - } // if( 0 < fvuNbDiffFullHitAsic[ usAsicIdx ] ) - - fvuNbSameFullHitAsic[ usAsicIdx ] = 0; - fvuNbDiffFullHitAsic[ usAsicIdx ] ++; - fvuLastHitBufferIdx[ usAsicIdx ] = ( fvuLastHitBufferIdx[ usAsicIdx ] + 1 ) % fuNbChanPerAsic; - fvmLastHitsAsic[ usAsicIdx ][ fvuLastHitBufferIdx[ usAsicIdx ] ] = (*it); - } // else of if( 0 == ulHitTs - fvulTimeLastHitAsicChan[ usAsicIdx ][ usChanIdx ] ) - fvulTimeLastHitAsicChan[ usAsicIdx ][ usChanIdx ] = ulHitTs; - fviAdcLastHitAsicChan[ usAsicIdx ][ usChanIdx ] = usHitAdc; - - if( 0 == usAsicIdx && fuPulseIdx < fuPulseIdxMax ) - { - fhAsicMissedChanIdVsPulseIdx->Fill( fuPulseIdx, usChanIdx ); - switch( usChanIdx ) - { - case 31: - fhAsicMissedChanGroupVsPulseIdx->Fill( fuPulseIdx, 0 ); - break; - case 35: - fhAsicMissedChanGroupVsPulseIdx->Fill( fuPulseIdx, 1 ); - break; - case 39: - fhAsicMissedChanGroupVsPulseIdx->Fill( fuPulseIdx, 2 ); - break; - default: - break; - } // switch( usChanIdx ) - } // if( 0 == usAsicIdx && fuPulseIdx < fuPulseIdxMax ) - } // loop on hits untils hits within 100 ns of last one or last one itself are reached - fuPulseIdx ++; - - // Remove all hits which were already used - fvmHitsInTs.erase( fvmHitsInTs.begin(), it ); - } // if( 0 < fvmHitsInTs.size() ) - } // for( size_t m = 0; m < numCompMsInTs; ++m ) - - // End of TS, check if stuff to do with the hits inside each MS - // Usefull for low rate pulser tests - // Need to do it only when last DPB is processed, as they are done one by one - if( fuCurrDpbIdx == fuNrOfDpbs - 1 ) - { - for( UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx ) - { - fvdMsTime[ uMsIdx ] = 0.0; - } // for( UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx ) - } // if( fuCurrDpbIdx == fuNrOfDpbs - 1 ) - - if( 0 == ts.index() % 1000 && fuCurrDpbIdx == fuNrOfDpbs - 1 ) - { - for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - { - Double_t dTsMsbTime = - static_cast<ULong64_t>( stsxyter::kuHitNbTsBins ) - * static_cast<ULong64_t>( fvulCurrentTsMsb[fuCurrDpbIdx]) - + static_cast<ULong64_t>( stsxyter::kulTsCycleNbBins ) - * static_cast<ULong64_t>( fvuCurrentTsMsbCycle[fuCurrDpbIdx] ); - dTsMsbTime *= stsxyter::kdClockCycleNs * 1e-9; - - LOG(info) << "End of TS " << std::setw(7) << ts.index() - << " eDPB " << std::setw(2) << uDpb - << " current TS MSB counter is " << std::setw(12) << fvulCurrentTsMsb[uDpb] - << " current TS MSB cycle counter is " << std::setw(12) << fvuCurrentTsMsbCycle[uDpb] - << " current TS MSB time is " << std::setw(12) << dTsMsbTime << " s"; - } - } // if( 0 == ts.index() % 1000 && fuCurrDpbIdx == fuNrOfDpbs - 1 ) - - return kTRUE; -} - -void CbmCosy2018MonitorDupli::FillHitInfo( stsxyter::Message mess, const UShort_t & /*usElinkIdx*/, const UInt_t & uAsicIdx, const UInt_t & uMsIdx ) -{ - UShort_t usChan = mess.GetHitChannel(); - UShort_t usRawAdc = mess.GetHitAdc(); -// UShort_t usFullTs = mess.GetHitTimeFull(); -// UShort_t usTsOver = mess.GetHitTimeOver(); - UShort_t usRawTs = mess.GetHitTime(); - // ajit - if(uAsicIdx == 2)fhStsRawAdc[ usChan ]->Fill( usRawAdc ); - if(uAsicIdx == 2) fhStsRawAdcCombine->Fill(usRawAdc); - - fhHodoChanCntRaw[ uAsicIdx ]->Fill( usChan ); - fhHodoChanAdcRaw[ uAsicIdx ]->Fill( usChan, usRawAdc ); - fhHodoChanAdcRawProf[ uAsicIdx ]->Fill( usChan, usRawAdc ); - fhHodoChanRawTs[ uAsicIdx ]->Fill( usChan, usRawTs ); - fhHodoChanMissEvt[ uAsicIdx ]->Fill( usChan, mess.IsHitMissedEvts() ); - - // Compute the Full time stamp -// Long64_t ulOldHitTime = fvulChanLastHitTime[ uAsicIdx ][ usChan ]; -// Double_t dOldHitTime = fvdChanLastHitTime[ uAsicIdx ][ usChan ]; - - // Use TS w/o overlap bits as they will anyway come from the TS_MSB - fvulChanLastHitTime[ uAsicIdx ][ usChan ] = usRawTs; - - fvulChanLastHitTime[ uAsicIdx ][ usChan ] += - static_cast<ULong64_t>( stsxyter::kuHitNbTsBins ) - * static_cast<ULong64_t>( fvulCurrentTsMsb[fuCurrDpbIdx]) - + static_cast<ULong64_t>( stsxyter::kulTsCycleNbBins ) - * static_cast<ULong64_t>( fvuCurrentTsMsbCycle[fuCurrDpbIdx] ) - ; - -// fvuElinkLastTsHit[fuCurrDpbIdx] = usRawTs; - - // Convert the Hit time in bins to Hit time in ns - Double_t dHitTimeNs = fvulChanLastHitTime[ uAsicIdx ][ usChan ] * stsxyter::kdClockCycleNs; -/* - // If needed fill the hit interval plots - if( fbChanHitDtEna ) - { - Double_t dDeltaT = dHitTimeNs - fvdChanLastHitTime[ uAsicIdx ][ usChan ]; - if( 0 == dDeltaT ) - fhStsChanHitDtNeg[ uAsicIdx ]->Fill( 1, usChan ); - else if( 0 < dDeltaT ) - fhStsChanHitDt[ uAsicIdx ]->Fill( dDeltaT, usChan ); - else fhStsChanHitDtNeg[ uAsicIdx ]->Fill( -dDeltaT, usChan ); - } // if( fbChanHitDtEna ) -*/ - // Store new value of Hit time in ns - fvdChanLastHitTime[ uAsicIdx ][ usChan ] = fvulChanLastHitTime[ uAsicIdx ][ usChan ] * stsxyter::kdClockCycleNs; -/* - LOG(info) << " Asic " << std::setw( 2 ) << uAsicIdx - << " Channel " << std::setw( 3 ) << usChan - << " Diff to last hit " << std::setw( 12 ) << ( fvulChanLastHitTime[ uAsicIdx ][ usChan ] - ulOldHitTime) - << " in s " << std::setw( 12 ) << ( fvdChanLastHitTime[ uAsicIdx ][ usChan ] - dOldHitTime) * 1e-9; -*/ - // Pulser and MS - fvuChanNbHitsInMs[ uAsicIdx ][ usChan ][ uMsIdx ] ++; - fvdChanLastHitTimeInMs[ uAsicIdx ][ usChan ][ uMsIdx ] = dHitTimeNs; - fvusChanLastHitAdcInMs[ uAsicIdx ][ usChan ][ uMsIdx ] = usRawAdc; -/* - fvmChanHitsInTs[ uAsicIdx ][ usChan ].insert( stsxyter::FinalHit( fvulChanLastHitTime[ uAsicIdx ][ usChan ], - usRawAdc, uAsicIdx, usChan ) ); -*/ - fvmHitsInTs.push_back( stsxyter::FinalHit( fvulChanLastHitTime[ uAsicIdx ][ usChan ], usRawAdc, uAsicIdx, usChan ) ); - - - if( fuPrintMessagesIdx < fkuNbPrintMessages ) -// if( ( 5949 == fulCurrentTsIdx ) ) - { - LOG(info) << " TS " << std::setw( 12 ) << fulCurrentTsIdx - << " MS " << std::setw( 12 ) << fulCurrentMsIdx - << " MsInTs " << std::setw( 3 ) << uMsIdx - << " eLINK " << std::setw( 3 ) << mess.GetLinkIndex() - << " Asic " << std::setw( 2 ) << uAsicIdx - << " Channel " << std::setw( 3 ) << usChan - << " ADC " << std::setw( 3 ) << usRawAdc - << " TS " << std::setw( 3 ) << usRawTs // 9 bits TS - << " TsMsb " << std::setw( 7 ) << fvulCurrentTsMsb[fuCurrDpbIdx] - << " MsbCy " << std::setw( 4 ) << fvuCurrentTsMsbCycle[fuCurrDpbIdx] - << " Time " << std::setw ( 12 ) << fvulChanLastHitTime[ uAsicIdx ][ usChan ]; - fuPrintMessagesIdx++; - } // if( fuPrintMessagesIdx < kuNbPrintMessages ) - - // Check Starting point of histos with time as X axis - if( -1 == fdStartTime ) - fdStartTime = fvdChanLastHitTime[ uAsicIdx ][ usChan ]; - - // Fill histos with time as X axis - Double_t dTimeSinceStartSec = (fvdChanLastHitTime[ uAsicIdx ][ usChan ] - fdStartTime)* 1e-9; - Double_t dTimeSinceStartMin = dTimeSinceStartSec / 60.0; - fhHodoChanHitRateEvo[ uAsicIdx ]->Fill( dTimeSinceStartSec , usChan ); - if( 0 == uAsicIdx ) - fhHodoChanHitRateEvoZoom->Fill( dTimeSinceStartSec , usChan ); - fhHodoFebRateEvo[ uAsicIdx ]->Fill( dTimeSinceStartSec ); - fhHodoChanHitRateEvoLong[ uAsicIdx ]->Fill( dTimeSinceStartMin, usChan, 1.0/60.0 ); - fhHodoFebRateEvoLong[ uAsicIdx ]->Fill( dTimeSinceStartMin, 1.0/60.0 ); - if( mess.IsHitMissedEvts() ) - { - fhHodoChanMissEvtEvo[ uAsicIdx ]->Fill( dTimeSinceStartSec , usChan ); - fhHodoFebMissEvtEvo[ uAsicIdx ]->Fill( dTimeSinceStartSec ); - } // if( mess.IsHitMissedEvts() ) -/* - if( kTRUE == fbLongHistoEnable ) - { - std::chrono::steady_clock::time_point tNow = std::chrono::steady_clock::now(); - Double_t dUnixTimeInRun = std::chrono::duration_cast< std::chrono::seconds >(tNow - ftStartTimeUnix).count(); - fhFebRateEvoLong[ uAsicIdx ]->Fill( dUnixTimeInRun , 1.0 / fuLongHistoBinSizeSec ); - fhFebChRateEvoLong[ uAsicIdx ]->Fill( dUnixTimeInRun , usChan, 1.0 / fuLongHistoBinSizeSec ); - } // if( kTRUE == fbLongHistoEnable ) -*/ - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - if( uXyterIdx == uAsicIdx ) - { - fhFractionHitsAsicSpillEvo[ uXyterIdx ]->Fill( dTimeSinceStartSec, 1.0 ); - fhFractionHitsAsicEvo[ uXyterIdx ]->Fill( dTimeSinceStartSec, 1.0 ); - fhFractionAsics->Fill( uXyterIdx, 1.0); - } - else - { - fhFractionHitsAsicSpillEvo[ uXyterIdx ]->Fill( dTimeSinceStartSec, 0.0 ); - fhFractionHitsAsicEvo[ uXyterIdx ]->Fill( dTimeSinceStartSec, 0.0 ); - fhFractionAsics->Fill( uXyterIdx, 0.0 ); - } - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) -/* - if( 596.51 < dTimeSinceStartSec && dTimeSinceStartSec < 597.07 && - 0 == uAsicIdx && 3 == usChan ) - LOG(info) << " TS " << std::setw( 12 ) << fulCurrentTsIdx - << " MS " << std::setw( 12 ) << fulCurrentMsIdx - << " ADC " << std::setw( 3 ) << usRawAdc - << " TS " << std::setw( 3 ) << usRawTs // 9 bits TS - << " SX TsMsb " << std::setw( 2 ) << ( fvulCurrentTsMsb[fuCurrDpbIdx] & 0x1F ) // Total StsXyter TS = 14 bits => 9b Hit TS + lower 5b TS_MSB after DPB - << " DPB TsMsb " << std::setw( 6 ) << ( fvulCurrentTsMsb[fuCurrDpbIdx] >> 5 ) // Total StsXyter TS = 14 bits => 9b Hit TS + lower 5b of TS_MSB after DPB - << " TsMsb " << std::setw( 7 ) << fvulCurrentTsMsb[fuCurrDpbIdx] - << " MsbCy " << std::setw( 4 ) << fvuCurrentTsMsbCycle[fuCurrDpbIdx] - << " Time " << std::setw ( 12 ) << fvulChanLastHitTime[ uAsicIdx ][ usChan ] - << " Time " << std::setw ( 5 ) << dTimeSinceStartSec; -*/ - - // Print TS jumps -// if( (ulOldHitTime & 0x00003C00) != (fvulChanLastHitTime[ uAsicIdx ][ usChan ] & 0x00003C00) && ( 255 != (ulOldHitTime & 0xFF) ) && (255 != (usRawTs & 0xFF) )) -/* - if( 0 == usChan && - ( ( (ulOldHitTime & 0x00003FFF) + 2 < (fvulChanLastHitTime[ uAsicIdx ][ usChan ] & 0x00003FFF ) ) || - ( (ulOldHitTime & 0x00003FFF) > (fvulChanLastHitTime[ uAsicIdx ][ usChan ] & 0x00003FFF ) + 2 ) ) && - ( ( 11620 > (fvulChanLastHitTime[ uAsicIdx ][ usChan ] & 0x00003FFF ) ) || - ( 11630 < (fvulChanLastHitTime[ uAsicIdx ][ usChan ] & 0x00003FFF ) ) ) - ) - { - Long64_t ulNewHitTime = fvulChanLastHitTime[ uAsicIdx ][ usChan ]; - LOG(info) << " Old Hit chan " << std::setw( 3 ) << usChan - << " TS " << std::setw( 3 ) << (ulOldHitTime & 0xFF) // 8 bits TS - << " Full TS " << std::setw( 5 ) << (ulOldHitTime & 0x3FFF) // Total StsXyter TS = 14 bits => 9b Hit TS + lower 5b of TS_MSB after DPB - << " SX TsMsb " << std::setw( 2 ) << ( ( ulOldHitTime >> 8 ) & 0x3 ) // 2 lower bits of TS_MSB from overlap bits in hit frame or from DPB - << " DPB TsMsb " << std::setw( 9 ) << ( (ulOldHitTime >> 10 ) & 0xF ) // 4 (+16) higher bits of TS_MSB from DPB - << " TsMsb " << std::setw( 9 ) << (ulOldHitTime >> 8) - << " MsbCy " << std::setw( 4 ) << fvuCurrentTsMsbCycle[fuCurrDpbIdx] - << " Time " << std::setw ( 12 ) << ulOldHitTime - << " Time " << std::setw ( 5 ) << (ulOldHitTime * stsxyter::kdClockCycleNs - fdStartTime)* 1e-9; - LOG(info) << " New Hit chan " << std::setw( 3 ) << usChan - << " TS " << std::setw( 3 ) << (ulNewHitTime & 0xFF) // 8 bits TS - << " Full TS " << std::setw( 5 ) << (ulNewHitTime & 0x3FFF) // Total StsXyter TS = 14 bits => 9b Hit TS + lower 5b of TS_MSB after DPB - << " SX TsMsb " << std::setw( 2 ) << ( ( ulNewHitTime >> 8 ) & 0x3 ) // 2 lower bits of TS_MSB from overlap bits in hit frame or from DPB - << " DPB TsMsb " << std::setw( 9 ) << ( (ulNewHitTime >> 10 ) & 0xF ) // 4 (+16) higher bits of TS_MSB from DPB - << " TsMsb " << std::setw( 9 ) << (ulNewHitTime >> 8) - << " MsbCy " << std::setw( 4 ) << fvuCurrentTsMsbCycle[fuCurrDpbIdx] - << " Time " << std::setw ( 12 ) << fvulChanLastHitTime[ uAsicIdx ][ usChan ] - << " Time " << std::setw ( 5 ) << dTimeSinceStartSec; - } // if( ulOldHitTime & 0x00003C00 != fvulChanLastHitTime[ uAsicIdx ][ usChan ] & 0x00003C00 ) -*/ - if( 0 == usChan ) - { -/* - if( 22.2 < dTimeSinceStartSec && dTimeSinceStartSec < 22.6 ) -// if( (443.574 < dTimeSinceStartSec && dTimeSinceStartSec < 443.575) || 32 != fuNbTsMsbSinceLastHit ) -// if( 32 != fuNbTsMsbSinceLastHit ) - { - Long64_t ulNewHitTime = fvulChanLastHitTime[ uAsicIdx ][ usChan ]; - LOG(info) << fuNbTsMsbSinceLastHit << " TS_MSB since last hit on channel 0 "; - LOG(info) << " New Hit chan " << std::setw( 3 ) << usChan - << " TS " << std::setw( 3 ) << (ulNewHitTime & 0xFF) // 8 bits TS - << " Full TS " << std::setw( 5 ) << (ulNewHitTime & 0x3FFF) // Total StsXyter TS = 14 bits => 9b Hit TS + lower 5b of TS_MSB after DPB - << " SX TsMsb " << std::setw( 2 ) << ( ( ulNewHitTime >> 8 ) & 0x3 ) // 2 lower bits of TS_MSB from overlap bits in hit frame or from DPB - << " DPB TsMsb " << std::setw( 9 ) << ( (ulNewHitTime >> 10 ) & 0xF ) // 4 (+16) higher bits of TS_MSB from DPB - << " TsMsb " << std::setw( 9 ) << (ulNewHitTime >> 8) - << " MsbCy " << std::setw( 4 ) << fvuCurrentTsMsbCycle[fuCurrDpbIdx] - << " Time " << std::setw ( 12 ) << fvulChanLastHitTime[ uAsicIdx ][ usChan ] - << " Time " << std::setw ( 5 ) << dTimeSinceStartSec; - } // if( 443.573 < dTimeSinceStartSec && dTimeSinceStartSec < 443.672 ) -*/ - fuNbTsMsbSinceLastHit = 0; - } // if( 0 == usChan ) - fuNbHitsLastTsMsb++; - - /// Pulse counting for pulser - if( 0 == fvuAsicTimeLastPulse[ uAsicIdx ] ) - { - /// Update the time of last Pulse - fvuAsicTimeLastPulse[ uAsicIdx ] = fvulChanLastHitTime[ uAsicIdx ][ usChan ]; - fvbPulseThereChan[ uAsicIdx ][ usChan ] = kTRUE; - } // if( 0 == fvuAsicTimeLastPulse[ uAsicIdx ] ) - else if( fvulChanLastHitTime[ uAsicIdx ][ usChan ] - fvuAsicTimeLastPulse[ uAsicIdx ] < 10 ) - { - fvbPulseThereChan[ uAsicIdx ][ usChan ] = kTRUE; - } // if( fvulChanLastHitTime[ uAsicIdx ][ usChan ] - fvuAsicTimeLastPulse[ uAsicIdx ] < 10 ) - else - { - UInt_t uNbChanThere = 0; - for( UInt_t uChanLoop = 0; uChanLoop < fuNbChanPerAsic; ++uChanLoop ) - { - if( kTRUE == fvbPulseThereChan[ uAsicIdx ][ uChanLoop ] ) - uNbChanThere++; - fvbPulseThereChan[ uAsicIdx ][ uChanLoop ] = kFALSE; - } // for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - - /// Fill the count histo - fhPulseChanCountEvo[ uAsicIdx ]->Fill( dTimeSinceStartSec, uNbChanThere ); - - /// Update the time of last Pulse - fvuAsicTimeLastPulse[ uAsicIdx ] = fvulChanLastHitTime[ uAsicIdx ][ usChan ]; - fvbPulseThereChan[ uAsicIdx ][ usChan ] = kTRUE; - } // else of if( fvulChanLastHitTime[ uAsicIdx ][ usChan ] - fvuAsicTimeLastPulse[ uAsicIdx ] < 10 ) -} - -void CbmCosy2018MonitorDupli::FillTsMsbInfo( stsxyter::Message mess, UInt_t /*uMessIdx*/, UInt_t /*uMsIdx*/ ) -{ - UInt_t uVal = mess.GetTsMsbVal(); -/* - if( 0 == fuCurrDpbIdx ) - LOG(info) << " TS " << std::setw( 12 ) << fulCurrentTsIdx - << " MS " << std::setw( 12 ) << fulCurrentMsIdx - << " MsInTs " << std::setw( 3 ) << uMsIdx - << " DPB " << std::setw( 2 ) << fuCurrDpbIdx - << " Mess " << std::setw( 5 ) << uMessIdx - << " TsMsb " << std::setw( 5 ) << uVal; -*/ - -/* - if( (uVal != fvulCurrentTsMsb[fuCurrDpbIdx] + 1) && 0 < uVal && - !( 1 == uMessIdx && usVal == fvulCurrentTsMsb[fuCurrDpbIdx] ) ) // 1st TS_MSB in MS is always a repeat of the last one in previous MS! - { - LOG(info) << "TS MSB not increasing by 1! TS " << std::setw( 12 ) << fulCurrentTsIdx - << " MS " << std::setw( 12 ) << fulCurrentMsIdx - << " MsInTs " << std::setw( 3 ) << uMsIdx - << " DPB " << std::setw( 2 ) << fuCurrDpbIdx - << " Mess " << std::setw( 5 ) << uMessIdx - << " Old TsMsb " << std::setw( 5 ) << fvulCurrentTsMsb[fuCurrDpbIdx] - << " new TsMsb " << std::setw( 5 ) << uVal - << " Diff " << std::setw( 5 ) << uVal - fvulCurrentTsMsb[fuCurrDpbIdx] - << " Old MsbCy " << std::setw( 5 ) << fvuCurrentTsMsbCycle[fuCurrDpbIdx]; - } // if( (uVal != fvulCurrentTsMsb[fuCurrDpbIdx] + 1) && 0 < uVal ) -*/ - if( uVal != fvulCurrentTsMsb[fuCurrDpbIdx] ) - fuNbTsMsbSinceLastHit++; - - // Update Status counters - if( uVal < fvulCurrentTsMsb[fuCurrDpbIdx] ) - { - - LOG(info) << " TS " << std::setw( 12 ) << fulCurrentTsIdx - << " MS " << std::setw( 12 ) << fulCurrentMsIdx - << " DPB " << std::setw( 2 ) << fuCurrDpbIdx - << " Old TsMsb " << std::setw( 5 ) << fvulCurrentTsMsb[fuCurrDpbIdx] - << " Old MsbCy " << std::setw( 5 ) << fvuCurrentTsMsbCycle[fuCurrDpbIdx] - << " new TsMsb " << std::setw ( 5 ) << uVal; - - fvuCurrentTsMsbCycle[fuCurrDpbIdx] ++; - } // if( uVal < fvulCurrentTsMsb[fuCurrDpbIdx] ) - fvulCurrentTsMsb[fuCurrDpbIdx] = uVal; -/* - if( 1 < uMessIdx ) - { - fhStsDpbRawTsMsb->Fill( fuCurrDpbIdx, fvulCurrentTsMsb[fuCurrDpbIdx] ); - fhStsDpbRawTsMsbSx->Fill( fuCurrDpbIdx, ( fvulCurrentTsMsb[fuCurrDpbIdx] & 0x1F ) ); - fhStsDpbRawTsMsbDpb->Fill( fuCurrDpbIdx, ( fvulCurrentTsMsb[fuCurrDpbIdx] >> 5 ) ); - } // if( 0 < uMessIdx ) -*/ -// fhStsAsicTsMsb->Fill( fvulCurrentTsMsb[fuCurrDpbIdx], uAsicIdx ); - - ULong64_t ulNewTsMsbTime = static_cast< ULong64_t >( stsxyter::kuHitNbTsBins ) - * static_cast< ULong64_t >( fvulCurrentTsMsb[fuCurrDpbIdx]) - + static_cast< ULong64_t >( stsxyter::kulTsCycleNbBins ) - * static_cast< ULong64_t >( fvuCurrentTsMsbCycle[fuCurrDpbIdx] ); - - // Check Starting point of histos with time as X axis - if( 0 < fdStartTime ) - { -// Double_t dTimeSinceStartSec = ( ulNewTsMsbTime * stsxyter::kdClockCycleNs - fdStartTime)* 1e-9; -/* -// if( 443.573 < dTimeSinceStartSec && dTimeSinceStartSec < 443.672 ) - if( 443.574 < dTimeSinceStartSec && dTimeSinceStartSec < 443.575 ) - LOG(info) << " TS " << std::setw( 12 ) << fulCurrentTsIdx - << " MS " << std::setw( 12 ) << fulCurrentMsIdx - << " TsMsb " << std::setw( 9 ) << uVal - << " MsbCy " << std::setw( 5 ) << fvuCurrentTsMsbCycle[fuCurrDpbIdx] - << " Time " << std::setw ( 12 ) << ulNewTsMsbTime - << " Time " << std::setw ( 5 ) << dTimeSinceStartSec - << " Nb Hits last TS_MSB " << fuNbHitsLastTsMsb; -*/ - fuNbHitsLastTsMsb = 0; - } // if( 0 < fdStartTime ) - - - Double_t dUpdatePeriodInSec = 1; - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - Double_t dTimeInS = ( ulNewTsMsbTime - fvulStartTimeLastS[ uXyterIdx ] ) - * stsxyter::kdClockCycleNs - * 1e-9; - - if( dUpdatePeriodInSec <= dTimeInS || (ulNewTsMsbTime < fvulStartTimeLastS[ uXyterIdx ] ) ) - { - UInt_t uNbHitsTotal = fvuNbHitDiffTsAsicLastS[ uXyterIdx ] + fvuNbHitSameTsAsicLastS[ uXyterIdx ]; - if( 0 < uNbHitsTotal && dTimeInS < 2 * dUpdatePeriodInSec ) - { - Double_t dRate = static_cast< Double_t >( uNbHitsTotal ) / dTimeInS; - Double_t dRatioSameTs = static_cast< Double_t >( fvuNbHitSameTsAsicLastS[ uXyterIdx ] ) - / uNbHitsTotal; - Double_t dRatioSameTsAdc = static_cast< Double_t >( fvuNbHitSameTsAdcAsicLastS[ uXyterIdx ] ) - / uNbHitsTotal; - Double_t dRatioSameAdcSameTs = static_cast< Double_t >( fvuNbHitSameTsAdcAsicLastS[ uXyterIdx ] ) - / fvuNbHitSameTsAsicLastS[ uXyterIdx ]; - - fhSetupSortedAsicRatioSameTsVsFlux[ uXyterIdx ]->Fill( dRate, dRatioSameTs ); - fhSetupSortedAsicRatioSameTsAdcVsFlux[ uXyterIdx ]->Fill( dRate, dRatioSameTsAdc ); - fhSetupSortedAsicRatioSameAdcSameTsVsFlux[ uXyterIdx ]->Fill( dRate, dRatioSameAdcSameTs ); -/* - LOG(info) << "Here we are " << dTimeInS - << " " << uNbHitsTotal - << " " << dRate; -*/ - } // if( 0 < uNbHitsTotal && dTimeInS < 2 * dUpdatePeriodInSec ) - - fvulStartTimeLastS[ uXyterIdx ] = ulNewTsMsbTime; - fvuNbHitDiffTsAsicLastS[ uXyterIdx ] = 0; - fvuNbHitSameTsAsicLastS[ uXyterIdx ] = 0; - fvuNbHitSameTsAdcAsicLastS[ uXyterIdx ] = 0; - } // if( dUpdatePeriodInSec <= dTimeInS || (ulNewTsMsbTime < fvulStartTimeLastS[ uXyterIdx ] ) ) - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) -} - -void CbmCosy2018MonitorDupli::FillEpochInfo( stsxyter::Message /*mess*/ ) -{ -// UInt_t uVal = mess.GetTsMsbVal(); -/* - // Update Status counters - if( usVal < fvulCurrentTsMsb[fuCurrDpbIdx] ) - fvuCurrentTsMsbCycle[fuCurrDpbIdx] ++; - fvulCurrentTsMsb[fuCurrDpbIdx] = usVal; - -// fhStsAsicTsMsb->Fill( fvulCurrentTsMsb[fuCurrDpbIdx], uAsicIdx ); -*/ -} - -void CbmCosy2018MonitorDupli::Reset() -{ -} - -void CbmCosy2018MonitorDupli::Finish() -{ - - LOG(info) << "-------------------------------------"; - LOG(info) << "CbmCosy2018MonitorDupli statistics are "; - LOG(info) << " Hit messages: " << fmMsgCounter[ stsxyter::MessType::Hit ] << "\n" - << " Ts MSB messages: " << fmMsgCounter[ stsxyter::MessType::TsMsb ] << "\n" - << " Dummy messages: " << fmMsgCounter[ stsxyter::MessType::Dummy ] << "\n" - << " Epoch messages: " << fmMsgCounter[ stsxyter::MessType::Epoch ] << "\n" - << " Empty messages: " << fmMsgCounter[ stsxyter::MessType::Empty ]; - - LOG(info) << "-------------------------------------"; - - SaveAllHistos( fsHistoFileFullname ); - LOG(info) << "CbmCosy2018MonitorDupli done saving histos "; - LOG(info) << "-------------------------------------"; - -// SaveAllHistos(); - -} - - -void CbmCosy2018MonitorDupli::FillOutput(boost::any) -{ -} - -void CbmCosy2018MonitorDupli::SaveAllHistos( TString sFileName ) -{ - /*******************************************************************/ - TCanvas* cFebRatioDupli = new TCanvas( "cFebRatioDupli", - "Hodoscopes coincidence quality", - 800, 600); - cFebRatioDupli->Divide( 2, fuNbStsXyters/2 + fuNbStsXyters%2 ); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - cFebRatioDupli->cd(1 + uXyterIdx ); - gPad->SetLogz(); - fhSetupSortedNbSameTsChan[ uXyterIdx ]->Draw( "colz" ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - /*******************************************************************/ - - TDirectory * oldDir = NULL; - TFile * histoFile = NULL; - if( "" != sFileName ) - { - // Store current directory position to allow restore later - oldDir = gDirectory; - // open separate histo file in recreate mode - histoFile = new TFile( sFileName , "RECREATE"); - histoFile->cd(); - } // if( "" != sFileName ) - - gDirectory->mkdir("Sts_Raw"); - gDirectory->cd("Sts_Raw"); - - fhHodoMessType->Write(); - fhHodoSysMessType->Write(); - fhHodoMessTypePerDpb->Write(); - fhHodoSysMessTypePerDpb->Write(); - fhHodoMessTypePerElink->Write(); - fhHodoSysMessTypePerElink->Write(); - fhStsRawAdcCombine->Write(); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - if(uXyterIdx == 2) - { - for( UInt_t uChannelIdx = 0; uChannelIdx < fuNbChanPerAsic; ++uChannelIdx ) - { - fhStsRawAdc[ uChannelIdx ]->Write(); - } - } - - fhHodoChanCntRaw[ uXyterIdx ]->Write(); - fhHodoChanAdcRaw[ uXyterIdx ]->Write(); - fhHodoChanAdcRawProf[ uXyterIdx ]->Write(); - fhHodoChanRawTs[ uXyterIdx ]->Write(); - fhHodoChanMissEvt[ uXyterIdx ]->Write(); - fhHodoChanMissEvtEvo[ uXyterIdx ]->Write(); - fhHodoFebMissEvtEvo[ uXyterIdx ]->Write(); - fhHodoChanHitRateEvo[ uXyterIdx ]->Write(); - fhHodoFebRateEvo[ uXyterIdx ]->Write(); - fhHodoChanHitRateEvoLong[ uXyterIdx ]->Write(); - fhHodoFebRateEvoLong[ uXyterIdx ]->Write(); -/* - if( kTRUE == fbLongHistoEnable ) - { - fhFebRateEvoLong[ uXyterIdx ]->Write(); - fhFebChRateEvoLong[ uXyterIdx ]->Write(); - } // if( kTRUE == fbLongHistoEnable ) -*/ - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - fhHodoChanHitRateEvoZoom->Write(); - -/* - fhSetupSortedDtX1Y1->Write(); - fhSetupSortedDtX2Y2->Write(); - fhSetupSortedDtN1P1->Write(); - fhSetupSortedDtN2P2->Write(); - fhSetupSortedDtX1Y1X2Y2->Write(); - fhSetupSortedDtN1P1N2P2->Write(); - fhSetupSortedDtX1Y1X2Y2N1P1->Write(); - fhSetupSortedDtX1Y1X2Y2N2P2->Write(); - fhSetupSortedDtH1H2S1S2->Write(); - fhSetupSortedMapX1Y1->Write(); - fhSetupSortedMapX2Y2->Write(); - fhSetupSortedMapN1P1->Write(); - fhSetupSortedMapN2P2->Write(); - fhSetupSortedCntEvoX1Y1->Write(); - fhSetupSortedCntEvoX2Y2->Write(); - fhSetupSortedCntEvoN1P1->Write(); - fhSetupSortedCntEvoN2P2->Write(); - - fhBothHodoSortedDtX1Y1->Write(); - fhBothHodoSortedDtX2Y2->Write(); - fhBothHodoSortedDtX1Y1X2Y2N1P1->Write(); - fhBothHodoSortedDtX1Y1X2Y2N2P2->Write(); - fhBothHodoSortedDtH1H2S1S2->Write(); - fhBothHodoSortedMapX1Y1->Write(); - fhBothHodoSortedMapX2Y2->Write(); - fhBothHodoSortedCntEvoX1Y1->Write(); - fhBothHodoSortedCntEvoX2Y2->Write(); - - fhH1H2S1SortedDtX1Y1->Write(); - fhH1H2S1SortedDtX2Y2->Write(); - fhH1H2S1SortedDtN1P1->Write(); - fhH1H2S1SortedDtN2P2->Write(); - fhH1H2S1SortedMapX1Y1->Write(); - fhH1H2S1SortedMapX2Y2->Write(); - fhH1H2S1SortedMapN1P1->Write(); - fhH1H2S1SortedMapN2P2->Write(); - fhH1H2S1SortedCntEvoX1Y1->Write(); - fhH1H2S1SortedCntEvoX2Y2->Write(); - fhH1H2S1SortedCntEvoN1P1->Write(); - fhH1H2S1SortedCntEvoN2P2->Write(); - - fhH1H2S2SortedDtX1Y1->Write(); - fhH1H2S2SortedDtX2Y2->Write(); - fhH1H2S2SortedDtN1P1->Write(); - fhH1H2S2SortedDtN2P2->Write(); - fhH1H2S2SortedMapX1Y1->Write(); - fhH1H2S2SortedMapX2Y2->Write(); - fhH1H2S2SortedMapN1P1->Write(); - fhH1H2S2SortedMapN2P2->Write(); - fhH1H2S2SortedCntEvoX1Y1->Write(); - fhH1H2S2SortedCntEvoX2Y2->Write(); - fhH1H2S2SortedCntEvoN1P1->Write(); - fhH1H2S2SortedCntEvoN2P2->Write(); - - fhSystSortedDtX1Y1->Write(); - fhSystSortedDtX2Y2->Write(); - fhSystSortedDtN1P1->Write(); - fhSystSortedDtN2P2->Write(); - fhSystSortedDtX1Y1X2Y2 ->Write(); - fhSystSortedMapX1Y1->Write(); - fhSystSortedMapX2Y2->Write(); - fhSystSortedMapN1P1->Write(); - fhSystSortedMapN2P2->Write(); - fhSystSortedCntEvoX1Y1->Write(); - fhSystSortedCntEvoX2Y2->Write(); - fhSystSortedCntEvoN1P1->Write(); - fhSystSortedCntEvoN2P2->Write(); - - fhSystSortedDtN1X1vsN1X2->Write(); - fhSystSortedDtP1X1vsP1X2->Write(); - fhSystSortedDtN1X1vsP1X1->Write(); - fhSystSortedDtSts1Hodo1vsSts1Hodo2->Write(); - fhSystSortedDtSts2Hodo1vsSts2Hodo2->Write(); - fhSystSortedDtAllVsMapX1->Write(); - fhSystSortedDtAllVsMapY1->Write(); - fhSystSortedDtAllVsMapX2->Write(); - fhSystSortedDtAllVsMapY2->Write(); - - fhSetupSortedDtX1->Write(); - fhSetupSortedDtY1->Write(); - fhSetupSortedDtX2->Write(); - fhSetupSortedDtY2->Write(); - fhSetupSortedDtN1->Write(); - fhSetupSortedDtP1->Write(); - fhSetupSortedDtN2->Write(); - fhSetupSortedDtP2->Write(); -*/ - - gDirectory->cd(".."); - - gDirectory->mkdir("Sts_Dupli"); - gDirectory->cd("Sts_Dupli"); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fhSetupSortedNbSameTsChan[ uXyterIdx ]->Write(); - fhSetupSortedSameTsAdcChan[ uXyterIdx ]->Write(); - fhSetupSortedSameTsAdcDiff[ uXyterIdx ]->Write(); - fhSetupSortedRatioSameTsChan[ uXyterIdx ]->Write(); - fhSetupSortedNbConsSameTsChan[ uXyterIdx ]->Write(); - fhSetupSortedNbConsSameTsAdcChan[ uXyterIdx ]->Write(); - fhSetupSortedNbConsSameTsVsTsAdc[ uXyterIdx ]->Write(); -/* - fhSetupSortedAsicRatioSameTsVsFlux[ uXyterIdx ]->Write(); - fhSetupSortedAsicRatioSameTsAdcVsFlux[ uXyterIdx ]->Write(); - fhSetupSortedAsicRatioSameAdcSameTsVsFlux[ uXyterIdx ]->Write(); -*/ - fhRatioSameTsSpillEvo[ uXyterIdx ]->Write(); - fhRatioSameTsAdcSpillEvo[ uXyterIdx ]->Write(); - fhRatioSameAdcSameTsSpillEvo[ uXyterIdx ]->Write(); - - fhSetupSortedTsFirstDuplicateChan[ uXyterIdx ]->Write(); - fhSetupSortedTsGoodChan[ uXyterIdx ]->Write(); - - fhFractionHitsAsicSpillEvo[ uXyterIdx ]->Write(); - fhFractionHitsAsicEvo[ uXyterIdx ]->Write(); - - fhAsicDuplicDtLastHits[ uXyterIdx ]->Write(); - fhAsicDuplicCompTs[ uXyterIdx ]->Write(); - fhAsicDuplicTsLsb[ uXyterIdx ]->Write(); - fhAsicDuplicTsMsbAsic[ uXyterIdx ]->Write(); - - fhAsicDuplicTs[ uXyterIdx ]->Write(); - fhAsicGoodTs[ uXyterIdx ]->Write(); - fhAsicDuplicTsMsb[ uXyterIdx ]->Write(); - fhAsicGoodTsMsb[ uXyterIdx ]->Write(); - fhAsicDuplicTsFull[ uXyterIdx ]->Write(); - fhAsicGoodTsFull[ uXyterIdx ]->Write(); - - fhHodoChanCntGood[ uXyterIdx ]->Write(); - fhHodoChanGoodHitRateEvo[ uXyterIdx ]->Write(); - fhPulseChanCountEvo[ uXyterIdx ]->Write(); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - fhAsicGoodTsEvoAsic0Chan01->Write(); - fhAsicGoodTsMsbEvoAsic0Chan01->Write(); - fhAsicGoodTsFullEvoAsic0Chan01->Write(); - fhAsicGoodTsFullEvoProfAsic0Chan01->Write(); - fhAsicDuplicTsEvoAsic0Chan01->Write(); - fhAsicGoodTsEvoAsic0Chan09->Write(); - fhAsicDuplicTsEvoAsic0Chan09->Write(); - fhAsicGoodTsFullEvoProfAsic0Chan09->Write(); - fhAsicGoodTsEvoAsic0Chan16->Write(); - fhAsicDuplicTsEvoAsic0Chan16->Write(); - fhAsicGoodTsFullEvoProfAsic0Chan16->Write(); - fhAsicMissedChanIdVsPulseIdx->Write(); - fhAsicMissedChanGroupVsPulseIdx->Write(); - - for( UInt_t uDpbIdx = 0; uDpbIdx < fuNrOfDpbs; ++uDpbIdx ) - { - fhFractionGoodHitsSpillEvo[ uDpbIdx ]->Write(); - fhFractionDupliHitsSpillEvo[ uDpbIdx ]->Write(); - fhFractionTsMsbSpillEvo[ uDpbIdx ]->Write(); - fhFractionEpochSpillEvo[ uDpbIdx ]->Write(); - fhFractionEmptySpillEvo[ uDpbIdx ]->Write(); - - fhFractionGoodHitsEvo[ uDpbIdx ]->Write(); - fhFractionDupliHitsEvo[ uDpbIdx ]->Write(); - fhFractionTsMsbEvo[ uDpbIdx ]->Write(); - fhFractionEpochEvo[ uDpbIdx ]->Write(); - fhFractionEmptyEvo[ uDpbIdx ]->Write(); - } // for( UInt_t uDpbIdx = 0; uDpbIdx < fuNrOfDpbs; ++uDpbIdx ) - fhFractionAsics->Write(); - fhFractionTypes->Write(); - - cFebRatioDupli->Write(); - delete cFebRatioDupli; - - gDirectory->cd(".."); - - // Flib Histos - gDirectory->mkdir("Flib_Raw"); - gDirectory->cd("Flib_Raw"); - for( UInt_t uLinks = 0; uLinks < kiMaxNbFlibLinks; uLinks ++) - { - TString sMsSzName = Form("MsSz_link_%02u", uLinks); - if( fHM->Exists(sMsSzName.Data() ) ) - fHM->H1( sMsSzName.Data() )->Write(); - - sMsSzName = Form("MsSzTime_link_%02u", uLinks); - if( fHM->Exists(sMsSzName.Data() ) ) - fHM->P1( sMsSzName.Data() )->Write(); - } // for( UInt_t uLinks = 0; uLinks < 16; uLinks ++) - - TH1 * pMissedTsH1 = dynamic_cast< TH1 * >( gROOT->FindObjectAny( "Missed_TS" ) ); - if( NULL != pMissedTsH1 ) - pMissedTsH1->Write(); - - TProfile * pMissedTsEvoP = dynamic_cast< TProfile * >( gROOT->FindObjectAny( "Missed_TS_Evo" ) ); - if( NULL != pMissedTsEvoP ) - pMissedTsEvoP->Write(); - - gDirectory->cd(".."); - - if( "" != sFileName ) - { - // Restore original directory position - histoFile->Close(); - oldDir->cd(); - } // if( "" != sFileName ) - -} -void CbmCosy2018MonitorDupli::ResetAllHistos() -{ - LOG(info) << "Reseting all STS histograms."; - - fhHodoMessType->Reset(); - fhHodoSysMessType->Reset(); - fhHodoMessTypePerDpb->Reset(); - fhHodoSysMessTypePerDpb->Reset(); - fhHodoMessTypePerElink->Reset(); - fhHodoSysMessTypePerElink->Reset(); - fhStsRawAdcCombine->Reset(); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - if(uXyterIdx == 2) - { - for( UInt_t uChannelIdx = 0; uChannelIdx < fuNbChanPerAsic; ++uChannelIdx ) - { - fhStsRawAdc[ uChannelIdx ]->Reset(); - } - } - - fhHodoChanCntRaw[ uXyterIdx ]->Reset(); - fhHodoChanAdcRaw[ uXyterIdx ]->Reset(); - fhHodoChanAdcRawProf[ uXyterIdx ]->Reset(); - fhHodoChanRawTs[ uXyterIdx ]->Reset(); - fhHodoChanMissEvt[ uXyterIdx ]->Reset(); - fhHodoChanMissEvtEvo[ uXyterIdx ]->Reset(); - fhHodoFebMissEvtEvo[ uXyterIdx ]->Reset(); - fhHodoChanHitRateEvo[ uXyterIdx ]->Reset(); - fhHodoFebRateEvo[ uXyterIdx ]->Reset(); - fhHodoChanHitRateEvoLong[ uXyterIdx ]->Reset(); - fhHodoFebRateEvoLong[ uXyterIdx ]->Reset(); -/* - if( kTRUE == fbLongHistoEnable ) - { - ftStartTimeUnix = std::chrono::steady_clock::now(); - fhFebRateEvoLong[ uXyterIdx ]->Reset(); - fhFebChRateEvoLong[ uXyterIdx ]->Reset(); - } // if( kTRUE == fbLongHistoEnable ) -*/ - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - fhHodoChanHitRateEvoZoom->Reset(); - - fhSetupSortedDtX1Y1->Reset(); - fhSetupSortedDtX2Y2->Reset(); - fhSetupSortedDtN1P1->Reset(); - fhSetupSortedDtN2P2->Reset(); - fhSetupSortedDtX1Y1X2Y2->Reset(); - fhSetupSortedDtN1P1N2P2->Reset(); - fhSetupSortedDtX1Y1X2Y2N1P1->Reset(); - fhSetupSortedDtX1Y1X2Y2N2P2->Reset(); - fhSetupSortedDtH1H2S1S2->Reset(); - fhSetupSortedMapX1Y1->Reset(); - fhSetupSortedMapX2Y2->Reset(); - fhSetupSortedMapN1P1->Reset(); - fhSetupSortedMapN2P2->Reset(); - fhSetupSortedCntEvoX1Y1->Reset(); - fhSetupSortedCntEvoX2Y2->Reset(); - fhSetupSortedCntEvoN1P1->Reset(); - fhSetupSortedCntEvoN2P2->Reset(); - - fhBothHodoSortedDtX1Y1->Reset(); - fhBothHodoSortedDtX2Y2->Reset(); - fhBothHodoSortedDtX1Y1X2Y2N1P1->Reset(); - fhBothHodoSortedDtX1Y1X2Y2N2P2->Reset(); - fhBothHodoSortedDtH1H2S1S2->Reset(); - fhBothHodoSortedMapX1Y1->Reset(); - fhBothHodoSortedMapX2Y2->Reset(); - fhBothHodoSortedCntEvoX1Y1->Reset(); - fhBothHodoSortedCntEvoX2Y2->Reset(); - - fhH1H2S1SortedDtX1Y1->Reset(); - fhH1H2S1SortedDtX2Y2->Reset(); - fhH1H2S1SortedDtN1P1->Reset(); - fhH1H2S1SortedDtN2P2->Reset(); - fhH1H2S1SortedMapX1Y1->Reset(); - fhH1H2S1SortedMapX2Y2->Reset(); - fhH1H2S1SortedMapN1P1->Reset(); - fhH1H2S1SortedMapN2P2->Reset(); - fhH1H2S1SortedCntEvoX1Y1->Reset(); - fhH1H2S1SortedCntEvoX2Y2->Reset(); - fhH1H2S1SortedCntEvoN1P1->Reset(); - fhH1H2S1SortedCntEvoN2P2->Reset(); - - fhH1H2S2SortedDtX1Y1->Reset(); - fhH1H2S2SortedDtX2Y2->Reset(); - fhH1H2S2SortedDtN1P1->Reset(); - fhH1H2S2SortedDtN2P2->Reset(); - fhH1H2S2SortedMapX1Y1->Reset(); - fhH1H2S2SortedMapX2Y2->Reset(); - fhH1H2S2SortedMapN1P1->Reset(); - fhH1H2S2SortedMapN2P2->Reset(); - fhH1H2S2SortedCntEvoX1Y1->Reset(); - fhH1H2S2SortedCntEvoX2Y2->Reset(); - fhH1H2S2SortedCntEvoN1P1->Reset(); - fhH1H2S2SortedCntEvoN2P2->Reset(); - - fhSystSortedDtX1Y1->Reset(); - fhSystSortedDtX2Y2->Reset(); - fhSystSortedDtN1P1->Reset(); - fhSystSortedDtN2P2->Reset(); - fhSystSortedDtX1Y1X2Y2 ->Reset(); - fhSystSortedMapX1Y1->Reset(); - fhSystSortedMapX2Y2->Reset(); - fhSystSortedMapN1P1->Reset(); - fhSystSortedMapN2P2->Reset(); - fhSystSortedCntEvoX1Y1->Reset(); - fhSystSortedCntEvoX2Y2->Reset(); - fhSystSortedCntEvoN1P1->Reset(); - fhSystSortedCntEvoN2P2->Reset(); - - fhSystSortedDtN1X1vsN1X2->Reset(); - fhSystSortedDtP1X1vsP1X2->Reset(); - fhSystSortedDtN1X1vsP1X1->Reset(); - fhSystSortedDtSts1Hodo1vsSts1Hodo2->Reset(); - fhSystSortedDtSts2Hodo1vsSts2Hodo2->Reset(); - fhSystSortedDtAllVsMapX1->Reset(); - fhSystSortedDtAllVsMapY1->Reset(); - fhSystSortedDtAllVsMapX2->Reset(); - fhSystSortedDtAllVsMapY2->Reset(); - - fhSetupSortedDtX1->Reset(); - fhSetupSortedDtY1->Reset(); - fhSetupSortedDtX2->Reset(); - fhSetupSortedDtY2->Reset(); - fhSetupSortedDtN1->Reset(); - fhSetupSortedDtP1->Reset(); - fhSetupSortedDtN2->Reset(); - fhSetupSortedDtP2->Reset(); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fhSetupSortedNbSameTsChan[ uXyterIdx ]->Reset(); - fhSetupSortedSameTsAdcChan[ uXyterIdx ]->Reset(); - fhSetupSortedSameTsAdcDiff[ uXyterIdx ]->Reset(); - fhSetupSortedRatioSameTsChan[ uXyterIdx ]->Reset(); - fhSetupSortedNbConsSameTsChan[ uXyterIdx ]->Reset(); - fhSetupSortedNbConsSameTsAdcChan[ uXyterIdx ]->Reset(); - fhSetupSortedNbConsSameTsVsTsAdc[ uXyterIdx ]->Reset(); - - fhSetupSortedAsicRatioSameTsVsFlux[ uXyterIdx ]->Reset(); - fhSetupSortedAsicRatioSameTsAdcVsFlux[ uXyterIdx ]->Reset(); - fhSetupSortedAsicRatioSameAdcSameTsVsFlux[ uXyterIdx ]->Reset(); - - fhRatioSameTsSpillEvo[ uXyterIdx ]->Reset(); - fhRatioSameTsAdcSpillEvo[ uXyterIdx ]->Reset(); - fhRatioSameAdcSameTsSpillEvo[ uXyterIdx ]->Reset(); - - fhSetupSortedTsFirstDuplicateChan[ uXyterIdx ]->Reset(); - fhSetupSortedTsGoodChan[ uXyterIdx ]->Reset(); - - fhFractionHitsAsicSpillEvo[ uXyterIdx ]->Reset(); - fhFractionHitsAsicEvo[ uXyterIdx ]->Reset(); - - fhAsicDuplicDtLastHits[ uXyterIdx ]->Reset(); - fhAsicDuplicCompTs[ uXyterIdx ]->Reset(); - fhAsicDuplicTsLsb[ uXyterIdx ]->Reset(); - fhAsicDuplicTsMsbAsic[ uXyterIdx ]->Reset(); - fhAsicDuplicCompTsBitThere[ uXyterIdx ]->Reset(); - fhAsicDuplicTsLsbBitThere[ uXyterIdx ]->Reset(); - fhAsicDuplicTsMsbBitThere[ uXyterIdx ]->Reset(); - fhAsicDuplicTs[ uXyterIdx ]->Reset(); - fhAsicGoodTs[ uXyterIdx ]->Reset(); - fhAsicDuplicTsMsb[ uXyterIdx ]->Reset(); - fhAsicGoodTsMsb[ uXyterIdx ]->Reset(); - fhAsicDuplicTsFull[ uXyterIdx ]->Reset(); - fhAsicGoodTsFull[ uXyterIdx ]->Reset(); - fhAsicDuplicTsBitPattern[ uXyterIdx ]->Reset(); - fhAsicGoodTsBitPattern[ uXyterIdx ]->Reset(); - - fhHodoChanCntGood[ uXyterIdx ]->Reset(); - fhHodoChanGoodHitRateEvo[ uXyterIdx ]->Reset(); - fhPulseChanCountEvo[ uXyterIdx ]->Reset(); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - - fhAsicGoodTsEvoAsic0Chan01->Reset(); - fhAsicGoodTsMsbEvoAsic0Chan01->Reset(); - fhAsicGoodTsFullEvoAsic0Chan01->Reset(); - fhAsicGoodTsFullEvoProfAsic0Chan01->Reset(); - fhAsicDuplicTsEvoAsic0Chan01->Reset(); - fhAsicGoodTsEvoAsic0Chan09->Reset(); - fhAsicDuplicTsEvoAsic0Chan09->Reset(); - fhAsicGoodTsFullEvoProfAsic0Chan09->Reset(); - fhAsicGoodTsEvoAsic0Chan16->Reset(); - fhAsicDuplicTsEvoAsic0Chan16->Reset(); - fhAsicGoodTsFullEvoProfAsic0Chan16->Reset(); - fuPulseIdx = 0; - fhAsicMissedChanIdVsPulseIdx->Reset(); - fhAsicMissedChanGroupVsPulseIdx->Reset(); - - for( UInt_t uDpbIdx = 0; uDpbIdx < fuNrOfDpbs; ++uDpbIdx ) - { - fhFractionGoodHitsSpillEvo[ uDpbIdx ]->Reset(); - fhFractionDupliHitsSpillEvo[ uDpbIdx ]->Reset(); - fhFractionTsMsbSpillEvo[ uDpbIdx ]->Reset(); - fhFractionEpochSpillEvo[ uDpbIdx ]->Reset(); - fhFractionEmptySpillEvo[ uDpbIdx ]->Reset(); - - fhFractionGoodHitsEvo[ uDpbIdx ]->Reset(); - fhFractionDupliHitsEvo[ uDpbIdx ]->Reset(); - fhFractionTsMsbEvo[ uDpbIdx ]->Reset(); - fhFractionEpochEvo[ uDpbIdx ]->Reset(); - fhFractionEmptyEvo[ uDpbIdx ]->Reset(); - } // for( UInt_t uDpbIdx = 0; uDpbIdx < fuNrOfDpbs; ++uDpbIdx ) - fhFractionAsics->Reset(); - fhFractionTypes->Reset(); - - for( UInt_t uLinks = 0; uLinks < kiMaxNbFlibLinks; ++uLinks ) - { - TString sMsSzName = Form("MsSz_link_%02u", uLinks); - if( fHM->Exists(sMsSzName.Data() ) ) - fHM->H1( sMsSzName.Data() )->Reset(); - - sMsSzName = Form("MsSzTime_link_%02u", uLinks); - if( fHM->Exists(sMsSzName.Data() ) ) - fHM->P1( sMsSzName.Data() )->Reset(); - } // for( UInt_t uLinks = 0; uLinks < kiMaxNbFlibLinks; ++uLinks ) - - fdStartTime = -1; - fdStartTimeMsSz = -1; -} - -void CbmCosy2018MonitorDupli::SetRunStart( Int_t dateIn, Int_t timeIn, Int_t iBinSize ) -{ - TDatime * fRunStartDateTime = new TDatime( dateIn, timeIn); - fiRunStartDateTimeSec = fRunStartDateTime->Convert(); - fiBinSizeDatePlots = iBinSize; - - LOG(info) << "Assigned new MUCH Run Start Date-Time: " << fRunStartDateTime->AsString(); -} - -void CbmCosy2018MonitorDupli::SetLongDurationLimits( UInt_t uDurationSeconds, UInt_t uBinSize ) -{ - fbLongHistoEnable = kTRUE; - fuLongHistoNbSeconds = uDurationSeconds; - fuLongHistoBinSizeSec = uBinSize; -} - -ClassImp(CbmCosy2018MonitorDupli) diff --git a/beamtime/cosy2018/unpacker/CbmCosy2018MonitorDupli.h b/beamtime/cosy2018/unpacker/CbmCosy2018MonitorDupli.h deleted file mode 100644 index d40a8023949d6f6c3eb7f63fe067fc1edc7bd1da..0000000000000000000000000000000000000000 --- a/beamtime/cosy2018/unpacker/CbmCosy2018MonitorDupli.h +++ /dev/null @@ -1,390 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmCosy2018MonitorDupli ----- -// ----- Created 27/02/18 by P.-A. Loizeau ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CBMCOSY2018MONITORFAKES_H -#define CBMCOSY2018MONITORFAKES_H - -#include "Timeslice.hpp" - -// Data -#include "StsXyterMessage.h" -#include "StsXyterFinalHit.h" - -// CbmRoot -#include "CbmTSUnpack.h" -#include "CbmHistManager.h" - -// C++11 -#include <chrono> - -// C/C++ -#include <vector> -#include <set> -#include <map> - -class CbmCern2017UnpackParHodo; -class CbmCern2017UnpackParSts; - -class CbmCosy2018MonitorDupli: public CbmTSUnpack -{ -public: - - CbmCosy2018MonitorDupli(); - virtual ~CbmCosy2018MonitorDupli(); - - virtual Bool_t Init(); - - virtual Bool_t DoUnpack(const fles::Timeslice& ts, size_t component); - - virtual void Reset(); - - virtual void Finish(); - - void SetParContainers(); - - Bool_t InitContainers(); - - Bool_t ReInitContainers(); - - void FillOutput(boost::any); - - void SetRunStart( Int_t dateIn, Int_t timeIn, Int_t iBinSize = 5 ); - - void ResetAllHistos(); - void SaveAllHistos( TString sFileName = "" ); - void SetHistoFileName( TString sFileName = "data/SetupHistos.root" ) { fsHistoFileFullname = sFileName; } - - void SetMsOverlap(size_t uOverlapMsNb = 1) { fuOverlapMsNb = uOverlapMsNb; } - size_t GetMsOverlap() { return fuOverlapMsNb; } - - void SetPrintMessage( Bool_t bPrintMessOn = kTRUE, - stsxyter::MessagePrintMask ctrl = stsxyter::MessagePrintMask::msg_print_Hex | - stsxyter::MessagePrintMask::msg_print_Human ) - { fbPrintMessages = bPrintMessOn; fPrintMessCtrl = ctrl; } - void EnableDualStsMode( Bool_t bEnable = kTRUE ) { fbDualStsEna = bEnable; } - void SetLongDurationLimits( UInt_t uDurationSeconds = 3600, UInt_t uBinSize = 1 ); - void SetCoincidenceBorderHodo( Double_t dNewValue ){ fdCoincBorderHodo = dNewValue;} - void SetCoincidenceBorderSts( Double_t dNewValue ){ fdCoincBorderSts = dNewValue;} - void SetCoincidenceBorder( Double_t dNewValue ){ fdCoincBorder = dNewValue;} - -private: - size_t fuOverlapMsNb; /** Ignore Overlap Ms: all fuOverlapMsNb MS at the end of timeslice **/ - - // Parameters - CbmCern2017UnpackParHodo* fUnpackParHodo; //! - CbmCern2017UnpackParSts* fUnpackParSts; //! - UInt_t fuNrOfDpbs; //! Total number of Sts DPBs in system - std::map<UInt_t, UInt_t> fDpbIdIndexMap; //! Map of DPB Identifier to DPB index - UInt_t fuNbElinksPerDpb; //! Number of possible eLinks per DPB - UInt_t fuNbStsXyters; //! Number of StsXyter ASICs - UInt_t fuNbChanPerAsic; //! Number of channels per StsXyter ASIC => should be constant somewhere!!!! - std::vector< std::vector< UInt_t > > fvuElinkToAsic; //! Vector holding for each link the corresponding ASIC index [fuNrOfDpbs * fuNbElinksPerDpb] - - // Constants - static const Int_t kiMaxNbFlibLinks = 16; - static const UInt_t kuBytesPerMessage = 4; - - // Internal Control/status of monitor - // Histo File name and path - TString fsHistoFileFullname; - // Task configuration values - Bool_t fbPrintMessages; - stsxyter::MessagePrintMask fPrintMessCtrl; - Bool_t fbDualStsEna; - const UInt_t fkuNbPrintMessages = 5000; - UInt_t fuPrintMessagesIdx; - // TS/MS info - ULong64_t fulCurrentTsIdx; - ULong64_t fulCurrentMsIdx; - // Current data properties - std::map< stsxyter::MessType, UInt_t > fmMsgCounter; - UInt_t fuCurrentEquipmentId; //! Current equipment ID, tells from which DPB the current MS is originating - UInt_t fuCurrDpbId; //! Temp holder until Current equipment ID is properly filled in MS - UInt_t fuCurrDpbIdx; //! Index of the DPB from which the MS currently unpacked is coming - Int_t fiRunStartDateTimeSec; //! Start of run time since "epoch" in s, for the plots with date as X axis - Int_t fiBinSizeDatePlots; //! Bin size in s for the plots with date as X axis - - // Data format control - std::vector< ULong64_t > fvulCurrentTsMsb; //! Current TS MSB for each DPB - std::vector< UInt_t > fvuCurrentTsMsbCycle; //! Current TS MSB cycle for DPB - std::vector< UInt_t > fvuElinkLastTsHit; //! TS from last hit for DPB - // Hits comparison - std::vector< std::vector< ULong64_t > > fvulChanLastHitTime; //! Last hit time in bins for each Channel - std::vector< std::vector< Double_t > > fvdChanLastHitTime; //! Last hit time in ns for each Channel - std::vector< Double_t > fvdMsTime; //! Header time of each MS - std::vector< std::vector< std::vector< UInt_t > > > fvuChanNbHitsInMs; //! Number of hits in each MS for each Channel - std::vector< std::vector< std::vector< Double_t > > > fvdChanLastHitTimeInMs; //! Last hit time in bins in each MS for each Channel - std::vector< std::vector< std::vector< UShort_t > > > fvusChanLastHitAdcInMs; //! Last hit ADC in bins in each MS for each Channel -// std::vector< std::vector< std::multiset< stsxyter::FinalHit > > > fvmChanHitsInTs; //! All hits (time & ADC) in bins in last TS for each Channel - // Starting state book-keeping - Double_t fdStartTime; /** Time of first valid hit (TS_MSB available), used as reference for evolution plots**/ - Double_t fdStartTimeMsSz; /** Time of first microslice, used as reference for evolution plots**/ - std::chrono::steady_clock::time_point ftStartTimeUnix; /** Time of run Start from UNIX system, used as reference for long evolution plots against reception time **/ - - // Hits time-sorting - std::vector< stsxyter::FinalHit > fvmHitsInTs; //! All hits (time in bins, ADC in bins, asic, channel) in last TS, sorted by multiset with "<" operator - stsxyter::FinalHit fLastSortedHit1X; //! Last sorted hit for Hodo 1 X - stsxyter::FinalHit fLastSortedHit1Y; //! Last sorted hit for Hodo 1 Y - stsxyter::FinalHit fLastSortedHit2X; //! Last sorted hit for Hodo 2 X - stsxyter::FinalHit fLastSortedHit2Y; //! Last sorted hit for Hodo 2 Y - stsxyter::FinalHit fLastSortedHit1N; //! Last sorted hit for STS 1 N - stsxyter::FinalHit fLastSortedHit1P; //! Last sorted hit for STS 1 P - stsxyter::FinalHit fLastSortedHit2N; //! Last sorted hit for STS 2 N - stsxyter::FinalHit fLastSortedHit2P; //! Last sorted hit for STS 2 P - // Coincidence histos - UInt_t fuMaxNbMicroslices; - // Rate evolution histos - Bool_t fbLongHistoEnable; - UInt_t fuLongHistoNbSeconds; - UInt_t fuLongHistoBinSizeSec; - UInt_t fuLongHistoBinNb; - - // Histograms - CbmHistManager* fHM; //! Histogram manager - TH1* fhHodoMessType; - TH1* fhHodoSysMessType; - TH2* fhHodoMessTypePerDpb; - TH2* fhHodoSysMessTypePerDpb; -/* - TH2* fhStsDpbRawTsMsb; - TH2* fhStsDpbRawTsMsbSx; - TH2* fhStsDpbRawTsMsbDpb; -*/ - TH2* fhHodoMessTypePerElink; - TH2* fhHodoSysMessTypePerElink; - - TH1* fhStsRawAdcCombine; // ajit - - std::vector<TH1*> fhStsRawAdc; // ajit - - - std::vector<TH1 *> fhHodoChanCntRaw; - std::vector<TH2 *> fhHodoChanAdcRaw; - std::vector<TProfile*> fhHodoChanAdcRawProf; - std::vector<TH2*> fhHodoChanRawTs; - std::vector<TH2*> fhHodoChanMissEvt; - std::vector<TH2*> fhHodoChanMissEvtEvo; - std::vector<TH2*> fhHodoChanHitRateEvo; - std::vector<TH1*> fhHodoFebRateEvo; - std::vector<TH1*> fhHodoFebMissEvtEvo; - std::vector<TH2*> fhHodoChanHitRateEvoLong; - std::vector<TH1*> fhHodoFebRateEvoLong; - - // Coincidences in sorted hits - Double_t fdCoincBorderHodo; // ns, +/- - Double_t fdCoincBorderSts; // ns, +/- - Double_t fdCoincBorder; // ns, +/- - // Single detector maps - TH1 * fhSetupSortedDtX1Y1; - TH1 * fhSetupSortedDtX2Y2; - TH1 * fhSetupSortedDtN1P1; - TH1 * fhSetupSortedDtN2P2; - TH1 * fhSetupSortedDtX1Y1X2Y2; - TH1 * fhSetupSortedDtN1P1N2P2; - TH1 * fhSetupSortedDtX1Y1X2Y2N1P1; - TH1 * fhSetupSortedDtX1Y1X2Y2N2P2; - TH1 * fhSetupSortedDtH1H2S1S2; - TH2 * fhSetupSortedMapX1Y1; - TH2 * fhSetupSortedMapX2Y2; - TH2 * fhSetupSortedMapN1P1; - TH2 * fhSetupSortedMapN2P2; - TH1 * fhSetupSortedCntEvoX1Y1; - TH1 * fhSetupSortedCntEvoX2Y2; - TH1 * fhSetupSortedCntEvoN1P1; - TH1 * fhSetupSortedCntEvoN2P2; - - // Full Hodo maps - TH1 * fhBothHodoSortedDtX1Y1; - TH1 * fhBothHodoSortedDtX2Y2; - TH1 * fhBothHodoSortedDtX1Y1X2Y2N1P1; - TH1 * fhBothHodoSortedDtX1Y1X2Y2N2P2; - TH1 * fhBothHodoSortedDtH1H2S1S2; - TH2 * fhBothHodoSortedMapX1Y1; - TH2 * fhBothHodoSortedMapX2Y2; - TH1 * fhBothHodoSortedCntEvoX1Y1; - TH1 * fhBothHodoSortedCntEvoX2Y2; - - // H + Sn maps - TH1 * fhH1H2S1SortedDtX1Y1; - TH1 * fhH1H2S1SortedDtX2Y2; - TH1 * fhH1H2S1SortedDtN1P1; - TH1 * fhH1H2S1SortedDtN2P2; - TH2 * fhH1H2S1SortedMapX1Y1; - TH2 * fhH1H2S1SortedMapX2Y2; - TH2 * fhH1H2S1SortedMapN1P1; - TH2 * fhH1H2S1SortedMapN2P2; - TH1 * fhH1H2S1SortedCntEvoX1Y1; - TH1 * fhH1H2S1SortedCntEvoX2Y2; - TH1 * fhH1H2S1SortedCntEvoN1P1; - TH1 * fhH1H2S1SortedCntEvoN2P2; - - TH1 * fhH1H2S2SortedDtX1Y1; - TH1 * fhH1H2S2SortedDtX2Y2; - TH1 * fhH1H2S2SortedDtN1P1; - TH1 * fhH1H2S2SortedDtN2P2; - TH2 * fhH1H2S2SortedMapX1Y1; - TH2 * fhH1H2S2SortedMapX2Y2; - TH2 * fhH1H2S2SortedMapN1P1; - TH2 * fhH1H2S2SortedMapN2P2; - TH1 * fhH1H2S2SortedCntEvoX1Y1; - TH1 * fhH1H2S2SortedCntEvoX2Y2; - TH1 * fhH1H2S2SortedCntEvoN1P1; - TH1 * fhH1H2S2SortedCntEvoN2P2; - - // Full System maps - TH1 * fhSystSortedDtX1Y1; - TH1 * fhSystSortedDtX2Y2; - TH1 * fhSystSortedDtN1P1; - TH1 * fhSystSortedDtN2P2; - TH1 * fhSystSortedDtX1Y1X2Y2; - TH2 * fhSystSortedMapX1Y1; - TH2 * fhSystSortedMapX2Y2; - TH2 * fhSystSortedMapN1P1; - TH2 * fhSystSortedMapN2P2; - TH1 * fhSystSortedCntEvoX1Y1; - TH1 * fhSystSortedCntEvoX2Y2; - TH1 * fhSystSortedCntEvoN1P1; - TH1 * fhSystSortedCntEvoN2P2; - - TH2 * fhSystSortedDtN1X1vsN1X2; - TH2 * fhSystSortedDtP1X1vsP1X2; - TH2 * fhSystSortedDtN1X1vsP1X1; - TH2 * fhSystSortedDtSts1Hodo1vsSts1Hodo2; - TH2 * fhSystSortedDtSts2Hodo1vsSts2Hodo2; - TH2 * fhSystSortedDtAllVsMapX1; - TH2 * fhSystSortedDtAllVsMapY1; - TH2 * fhSystSortedDtAllVsMapX2; - TH2 * fhSystSortedDtAllVsMapY2; - - TH1 * fhSetupSortedDtX1; - TH1 * fhSetupSortedDtY1; - TH1 * fhSetupSortedDtX2; - TH1 * fhSetupSortedDtY2; - TH1 * fhSetupSortedDtN1; - TH1 * fhSetupSortedDtP1; - TH1 * fhSetupSortedDtN2; - TH1 * fhSetupSortedDtP2; - - /// Counting hits without proper timestamp - std::vector< std::vector< ULong64_t > > fvulTimeLastHitAsicChan; - std::vector< std::vector< Int_t > > fviAdcLastHitAsicChan; - std::vector< std::vector< UInt_t > > fvuNbSameHitAsicChan; - std::vector< std::vector< UInt_t > > fvuNbSameFullHitAsicChan; - - std::vector< ULong64_t > fvulStartTimeLastS; - std::vector< UInt_t > fvuNbHitDiffTsAsicLastS; - std::vector< UInt_t > fvuNbHitSameTsAsicLastS; - std::vector< UInt_t > fvuNbHitSameTsAdcAsicLastS; - - std::vector< TH2 * > fhSetupSortedTsFirstDuplicateChan; - std::vector< TH2 * > fhSetupSortedTsGoodChan; - std::vector< TH2 * > fhSetupSortedNbSameTsChan; - std::vector< TH2 * > fhSetupSortedSameTsAdcChan; - std::vector< TH2 * > fhSetupSortedSameTsAdcDiff; - std::vector< TProfile2D * > fhSetupSortedRatioSameTsChan; - std::vector< TH2 * > fhSetupSortedNbConsSameTsChan; - std::vector< TH2 * > fhSetupSortedNbConsSameTsAdcChan; - std::vector< TH2 * > fhSetupSortedNbConsSameTsVsTsAdc; - - std::vector< TH2 * > fhSetupSortedAsicRatioSameTsVsFlux; - std::vector< TH2 * > fhSetupSortedAsicRatioSameTsAdcVsFlux; - std::vector< TH2 * > fhSetupSortedAsicRatioSameAdcSameTsVsFlux; - - std::vector< TProfile2D * > fhRatioSameTsSpillEvo; - std::vector< TProfile2D * > fhRatioSameTsAdcSpillEvo; - std::vector< TProfile2D * > fhRatioSameAdcSameTsSpillEvo; - - std::vector< TProfile * > fhFractionHitsAsicSpillEvo; - std::vector< TProfile * > fhFractionGoodHitsSpillEvo; - std::vector< TProfile * > fhFractionDupliHitsSpillEvo; - std::vector< TProfile * > fhFractionTsMsbSpillEvo; - std::vector< TProfile * > fhFractionEpochSpillEvo; - std::vector< TProfile * > fhFractionEmptySpillEvo; - std::vector< TProfile * > fhFractionHitsAsicEvo; - std::vector< TProfile * > fhFractionGoodHitsEvo; - std::vector< TProfile * > fhFractionDupliHitsEvo; - std::vector< TProfile * > fhFractionTsMsbEvo; - std::vector< TProfile * > fhFractionEpochEvo; - std::vector< TProfile * > fhFractionEmptyEvo; - TProfile * fhFractionAsics; - TProfile * fhFractionTypes; - - std::vector< UInt_t > fvuNbSameFullHitAsic; - std::vector< UInt_t > fvuNbDiffFullHitAsic; - std::vector< UInt_t > fvuLastHitBufferIdx; - std::vector< std::vector< stsxyter::FinalHit > > fvmLastHitsAsic; //! last 128 hits (time in bins, ADC in bins, asic, channel) - std::vector< TH2 * > fhAsicDuplicDtLastHits; - std::vector< TH2 * > fhAsicDuplicCompTs; - std::vector< TH2 * > fhAsicDuplicTsLsb; - std::vector< TH2 * > fhAsicDuplicTsMsbAsic; - std::vector< TH2 * > fhAsicDuplicCompTsBitThere; - std::vector< TH2 * > fhAsicDuplicTsLsbBitThere; - std::vector< TH2 * > fhAsicDuplicTsMsbBitThere; - std::vector< TH2 * > fhAsicDuplicTs; - std::vector< TH2 * > fhAsicGoodTs; - std::vector< TH2 * > fhAsicDuplicTsMsb; - std::vector< TH2 * > fhAsicGoodTsMsb; - std::vector< TH2 * > fhAsicDuplicTsFull; - std::vector< TH2 * > fhAsicGoodTsFull; - std::vector< TH2 * > fhAsicDuplicTsBitPattern; - std::vector< TH2 * > fhAsicGoodTsBitPattern; - - TH2 * fhAsicDuplicTsEvoAsic0Chan01; - TH2 * fhAsicGoodTsEvoAsic0Chan01; - TH2 * fhAsicGoodTsMsbEvoAsic0Chan01; - TH2 * fhAsicGoodTsFullEvoAsic0Chan01; - TProfile * fhAsicGoodTsFullEvoProfAsic0Chan01; - TH2 * fhAsicDuplicTsEvoAsic0Chan09; - TH2 * fhAsicGoodTsEvoAsic0Chan09; - TProfile * fhAsicGoodTsFullEvoProfAsic0Chan09; - TH2 * fhAsicDuplicTsEvoAsic0Chan16; - TH2 * fhAsicGoodTsEvoAsic0Chan16; - TProfile * fhAsicGoodTsFullEvoProfAsic0Chan16; - UInt_t fuPulseIdx; - UInt_t fuPulseIdxMax; - TH2 * fhAsicMissedChanIdVsPulseIdx; - TProfile * fhAsicMissedChanGroupVsPulseIdx; - - std::vector<TH1 *> fhHodoChanCntGood; - std::vector<TH2 *> fhHodoChanGoodHitRateEvo; - - TH2 * fhHodoX1SpillEvo; - TH2 * fhHodoY1SpillEvo; - TH2 * fhHodoX2SpillEvo; - TH2 * fhHodoY2SpillEvo; - - Double_t fdSpillEvoLength; - TProfile * fhHodoX1SpillEvoProf; - TProfile * fhHodoY1SpillEvoProf; - TProfile * fhHodoX2SpillEvoProf; - TProfile * fhHodoY2SpillEvoProf; - - TCanvas* fcMsSizeAll; - TH1* fhMsSz[kiMaxNbFlibLinks]; - TProfile* fhMsSzTime[kiMaxNbFlibLinks]; - - std::vector< ULong64_t > fvuAsicTimeLastPulse; - std::vector< std::vector< Bool_t > > fvbPulseThereChan; - std::vector< TH2 * > fhPulseChanCountEvo; - - TH2* fhHodoChanHitRateEvoZoom; - UInt_t fuNbTsMsbSinceLastHit; - UInt_t fuNbHitsLastTsMsb; - - void CreateHistograms(); - - void FillHitInfo( stsxyter::Message mess, const UShort_t & usElinkIdx, const UInt_t & uAsicIdx, const UInt_t & uMsIdx ); - void FillTsMsbInfo( stsxyter::Message mess, UInt_t uMessIdx = 0, UInt_t uMsIdx = 0); - void FillEpochInfo( stsxyter::Message mess ); - - CbmCosy2018MonitorDupli(const CbmCosy2018MonitorDupli&); - CbmCosy2018MonitorDupli operator=(const CbmCosy2018MonitorDupli&); - - ClassDef(CbmCosy2018MonitorDupli, 1) -}; - -#endif // CBMCOSY2018MONITORFAKES_H diff --git a/beamtime/cosy2018/unpacker/CbmCosy2018MonitorEfficiency.cxx b/beamtime/cosy2018/unpacker/CbmCosy2018MonitorEfficiency.cxx deleted file mode 100644 index 1b48cc646669424da113164b2b3f0571bc4f118e..0000000000000000000000000000000000000000 --- a/beamtime/cosy2018/unpacker/CbmCosy2018MonitorEfficiency.cxx +++ /dev/null @@ -1,6236 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmCosy2018MonitorEfficiency ----- -// ----- Created 27/02/18 by P.-A. Loizeau ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#include "CbmCosy2018MonitorEfficiency.h" - -// Data - -// CbmRoot -#include "CbmCern2017UnpackParHodo.h" -#include "CbmCern2017UnpackParSts.h" -#include "CbmHistManager.h" - -// FairRoot -#include "FairLogger.h" -#include "FairRootManager.h" -#include "FairRun.h" -#include "FairRuntimeDb.h" -#include "FairRunOnline.h" - -// Root -#include "TClonesArray.h" -#include "TString.h" -#include "TRandom.h" -#include "THttpServer.h" -#include "TROOT.h" -#include "TStyle.h" -#include "TMath.h" -#include <TFile.h> - -// C++11 - -// C/C++ -#include <iostream> -#include <stdint.h> -#include <iomanip> - -Cosy2018TestCluster::Cosy2018TestCluster( stsxyter::FinalHit hitFirst ) : - fvHits( 1, hitFirst ), - fdMeanTime( hitFirst.GetTs() * stsxyter::kdClockCycleNs ), - fusTotalAdc( hitFirst.GetAdc() ), - fusFirstChannel( hitFirst.GetChan() ), - fusLastChannel( hitFirst.GetChan() ), - fdWeightedCenter( hitFirst.GetChan() ) -{ -} -Bool_t Cosy2018TestCluster::CheckAddHit( stsxyter::FinalHit hitCandidate ) -{ - /// First check if within cut at +/- 40 ns - Double_t dDt = hitCandidate.GetTs() * stsxyter::kdClockCycleNs - fdMeanTime; - if( -40.0 < dDt && dDt < 40.0 ) - { - UShort_t usChan = hitCandidate.GetChan(); - - /// Then check if we are inside cluster or at +/- 1 channel - if( fusFirstChannel <= usChan + 1 && - usChan <= fusLastChannel + 1 ) - { - fdMeanTime = ( fdMeanTime * fvHits.size() + hitCandidate.GetTs() * stsxyter::kdClockCycleNs ) / ( fvHits.size() + 1 ); - - fdWeightedCenter = fdWeightedCenter * fusTotalAdc + usChan * hitCandidate.GetAdc(); - - fusTotalAdc += hitCandidate.GetAdc(); - - fdWeightedCenter /= fusTotalAdc; - - if( usChan < fusFirstChannel ) - fusFirstChannel = usChan; - else if( fusLastChannel < usChan ) - fusLastChannel = usChan; - - - fvHits.push_back( hitCandidate ); - - return kTRUE; - } // if ch within [ First -1; Last + 1] - } // if( -40.0 < dDt && dDt < 40.0 ) - - return kFALSE; -} - - -Bool_t bCosy2018ResetEfficiency = kFALSE; -Bool_t bCosy2018WriteEfficiency = kFALSE; - -CbmCosy2018MonitorEfficiency::CbmCosy2018MonitorEfficiency() : - CbmTSUnpack(), - fuOverlapMsNb(0), - fUnpackParHodo(NULL), - fUnpackParSts(NULL), - fuNrOfDpbs(0), - fDpbIdIndexMap(), - fuNbElinksPerDpb(0), - fuNbStsXyters(0), - fuNbChanPerAsic(0), - fvuElinkToAsic(), - fsHistoFileFullname( "data/SetupHistos.root" ), - fbPrintMessages( kFALSE ), - fPrintMessCtrl( stsxyter::MessagePrintMask::msg_print_Human ), - fbDualStsEna( kFALSE ), - fbDeadCorrEna( kFALSE ), - fulCurrentTsIdx( 0 ), - fulCurrentMsIdx( 0 ), - fmMsgCounter(), - fuCurrentEquipmentId(0), - fuCurrDpbId(0), - fuCurrDpbIdx(0), - fiRunStartDateTimeSec(-1), - fiBinSizeDatePlots(-1), - fvulCurrentTsMsb(), - fvuCurrentTsMsbCycle(), - fvuElinkLastTsHit(), - fvulChanLastHitTime(), - fvdChanLastHitTime(), - fvdMsTime(), - fvuChanNbHitsInMs(), - fvdChanLastHitTimeInMs(), - fvusChanLastHitAdcInMs(), -// fvmChanHitsInTs(), - fdStartTime(-1.0), - fdStartTimeMsSz(-1.0), - ftStartTimeUnix( std::chrono::steady_clock::now() ), - fvmHitsInTs(), - fLastSortedHit1X(), - fLastSortedHit1Y(), - fLastSortedHit2X(), - fLastSortedHit2Y(), - fLastSortedHit1N(), - fLastSortedHit1P(), - fLastSortedHit2N(), - fLastSortedHit2P(), - fuMaxNbMicroslices(100), - fbLongHistoEnable( kFALSE ), - fuLongHistoNbSeconds( 0 ), - fuLongHistoBinSizeSec( 0 ), - fuLongHistoBinNb( 0 ), - fHM(new CbmHistManager()), - fhHodoMessType(NULL), - fhHodoSysMessType(NULL), - fhHodoMessTypePerDpb(NULL), - fhHodoSysMessTypePerDpb(NULL), - fhHodoMessTypePerElink(NULL), - fhHodoSysMessTypePerElink(NULL), - fhHodoChanCntRaw(), - fhHodoChanCntRawGood(), - fhHodoChanAdcRaw(), - fhHodoChanAdcRawProf(), - fhHodoChanRawTs(), - fhHodoChanMissEvt(), - fhHodoChanMissEvtEvo(), - fhHodoChanHitRateEvo(), - fhHodoFebRateEvo(), - fhHodoFebMissEvtEvo(), - fhHodoChanHitRateEvoLong(), - fhHodoFebRateEvoLong(), - fdCoincCenterHodo( 0.0 ), - fdCoincBorderHodo( 50.0 ), - fdCoincMinHodo( fdCoincCenterHodo - fdCoincBorderHodo ), - fdCoincMaxHodo( fdCoincCenterHodo + fdCoincBorderHodo ), - fdCoincCenterHodoBoth( 0.0 ), - fdCoincBorderHodoBoth( 100.0 ), - fdCoincMinHodoBoth( fdCoincCenterHodoBoth - fdCoincBorderHodoBoth ), - fdCoincMaxHodoBoth( fdCoincCenterHodoBoth + fdCoincBorderHodoBoth ), - fdCoincCenterSts1( 0.0 ), - fdCoincBorderSts1( 75.0 ), - fdCoincMinSts1( fdCoincCenterSts1 - fdCoincBorderSts1 ), - fdCoincMaxSts1( fdCoincCenterSts1 + fdCoincBorderSts1 ), - fdCoincCenterSts2( 0.0 ), - fdCoincBorderSts2( 75.0 ), - fdCoincMinSts2( fdCoincCenterSts2 - fdCoincBorderSts2 ), - fdCoincMaxSts2( fdCoincCenterSts2 + fdCoincBorderSts2 ), - fdCoincCenterHodoS1( 0.0 ), - fdCoincBorderHodoS1( 50.0 ), - fdCoincMinHodoS1( fdCoincCenterHodoS1 - fdCoincBorderHodoS1 ), - fdCoincMaxHodoS1( fdCoincCenterHodoS1 + fdCoincBorderHodoS1 ), - fdCoincCenterHodoS2( 0.0 ), - fdCoincBorderHodoS2( 50.0 ), - fdCoincMinHodoS2( fdCoincCenterHodoS2 - fdCoincBorderHodoS1 ), - fdCoincMaxHodoS2( fdCoincCenterHodoS2 + fdCoincBorderHodoS1 ), - fdCoincCenter( 0.0 ), - fdCoincBorder( 150.0 ), - fdCoincMin( fdCoincCenter - fdCoincBorder ), - fdCoincMax( fdCoincCenter + fdCoincBorder ), - fhSetupSortedDtX1Y1(NULL), - fhSetupSortedDtX2Y2(NULL), - fhSetupSortedDtN1P1(NULL), - fhSetupSortedDtN2P2(NULL), - fhSetupSortedDtX1Y1X2Y2(NULL), - fhSetupSortedDtN1P1N2P2(NULL), - fhSetupSortedDtX1Y1X2Y2N1P1(NULL), - fhSetupSortedDtX1Y1X2Y2N2P2(NULL), - fhSetupSortedDtH1H2S1S2(NULL), - fhSetupSortedMapX1Y1(NULL), - fhSetupSortedMapX2Y2(NULL), - fhSetupSortedMapN1P1(NULL), - fhSetupSortedMapN2P2(NULL), - fhSetupSortedCntEvoX1Y1(NULL), - fhSetupSortedCntEvoX2Y2(NULL), - fhSetupSortedCntEvoN1P1(NULL), - fhSetupSortedCntEvoN2P2(NULL), - fhSetupSortedDtX1(NULL), - fhSetupSortedDtY1(NULL), - fhSetupSortedDtX2(NULL), - fhSetupSortedDtY2(NULL), - fhSetupSortedDtN1(NULL), - fhSetupSortedDtP1(NULL), - fhSetupSortedDtN2(NULL), - fhSetupSortedDtP2(NULL), - fvulTimeLastHitAsicChan(), - fviAdcLastHitAsicChan(), - fvuNbSameHitAsicChan(), - fvuNbSameFullHitAsicChan(), - fvulStartTimeLastS(), - fvuNbHitDiffTsAsicLastS(), - fvuNbHitSameTsAsicLastS(), - fvuNbHitSameTsAdcAsicLastS(), - fvbAsicHasDuplicInMs(), - fhSetupSortedNbSameTsChan(), - fhSetupSortedSameTsAdcChan(), - fhSetupSortedSameTsAdcDiff(), - fhSetupSortedRatioSameTsChan(), - fhSetupSortedNbConsSameTsChan(), - fhSetupSortedNbConsSameTsAdcChan(), - fhSetupSortedNbConsSameTsVsTsAdc(), - fhSetupSortedAsicRatioSameTsVsFlux(), - fhSetupSortedAsicRatioSameTsAdcVsFlux(), - fhSetupSortedAsicRatioSameAdcSameTsVsFlux(), - fhSetupSortedCleanMsDtH1H2S1S2(NULL), - fhRatioMsDuplicateQuality(NULL), - fhEvoMsDuplicateQuality(), - fhSizeCleanMs(), - fhHodoX1SpillEvo(NULL), - fhHodoY1SpillEvo(NULL), - fhHodoX2SpillEvo(NULL), - fhHodoY2SpillEvo(NULL), - fdSpillEvoLength( 700.0 ), - fhHodoX1SpillEvoProf(NULL), - fhHodoY1SpillEvoProf(NULL), - fhHodoX2SpillEvoProf(NULL), - fhHodoY2SpillEvoProf(NULL), - fdStereoAngleTan( TMath::Tan( kdStereoAngle * TMath::DegToRad() ) ), - fdStripRangeNP( TMath::Ceil( kdSensorsSzY * fdStereoAngleTan / kdPitchMm ) ), - fiStripsOffsetN1( 69 ), - fiStripsOffsetP1( -69 ), - fiStripsOffsetN2( 69 ), - fiStripsOffsetP2( -69 ), - fhStsSortedMapS1(NULL), - fhStsSortedMapS2(NULL), - fhStsSortedMapS1Coinc(NULL), - fhStsSortedMapS2Coinc(NULL), - fdPosZH1( 0.0 ), - fdPosZH2( 1.0 ), - fdPosZS1( 0.5 ), - fdPosZS2( 0.5 ), - fdRatioZS1( fdPosZS1 / ( fdPosZH2 / fdPosZH1 ) ), - fdRatioZS2( fdPosZS2 / ( fdPosZH2 / fdPosZH1 ) ), - fdOffsetS1X( 0.0 ), - fdOffsetS1Y( 0.0 ), - fdOffsetS2X( 0.0 ), - fdOffsetS2Y( 0.0 ), - fvPairsH1(), - fvPairsH2(), - fvPairsS1(), - fvPairsS2(), - fvPairsHodo(), - fvPairsHodoS1(), - fvPairsHodoS2(), - fvPairsHodoS1S2(), - fvPairsHodoS2S1(), - fhNbY1CoincPerX1(NULL), - fhNbY2CoincPerX2(NULL), - fhNbP1CoincPerN1(NULL), - fhNbP2CoincPerN2(NULL), - fhNbH2CoincPerH1(NULL), - fhNbS1CoincPerHodo(NULL), - fhNbS2CoincPerHodo(NULL), - fhNbS1CoincPerHodoS2(NULL), - fhNbS2CoincPerHodoS1(NULL), - fhNbS1CoincPerHodoGeoCut(NULL), - fhNbS2CoincPerHodoGeoCut(NULL), - fhNbS1CoincPerHodoS2GeoCut(NULL), - fhNbS2CoincPerHodoS1GeoCut(NULL), - fhChanMapAllMatchS1(NULL), - fhChanMapAllMatchS2(NULL), - fhChanMapBestMatchS1(NULL), - fhChanMapBestMatchS2(NULL), - fhDtAllPairsS1(NULL), - fhDtAllPairsS2(NULL), - fhDtAllPairsHodoS1(NULL), - fhDtAllPairsHodoS2(NULL), - fhDtBestPairsH1(NULL), - fhDtBestPairsH2(NULL), - fhDtBestPairsS1(NULL), - fhDtBestPairsS2(NULL), - fhDtBestPairsHodo(NULL), - fhDtBestPairsHodoS1(NULL), - fhDtBestPairsHodoS2(NULL), - fhDtBestPairsHodoS1S2(NULL), - fhDtBestPairsHodoS2S1(NULL), - fhDtBestPairsHodoS1GeoCut(NULL), - fhDtBestPairsHodoS2GeoCut(NULL), - fhDtBestPairsHodoS1S2GeoCut(NULL), - fhDtBestPairsHodoS2S1GeoCut(NULL), - fhMapBestPairsH1(NULL), - fhMapBestPairsH2(NULL), - fhMapBestPairsS1(NULL), - fhMapBestPairsS2(NULL), - fhMapBestPairsHodo_H1(NULL), - fhMapBestPairsHodo_H2(NULL), - fhMapBestPairsHodo_ProjS1(NULL), - fhMapBestPairsHodo_ProjS2(NULL), - fhMapBestPairsHodoS1_H1(NULL), - fhMapBestPairsHodoS1_H2(NULL), - fhMapBestPairsHodoS1_S1(NULL), - fhMapBestPairsHodoS1_Proj(NULL), - fhMapBestPairsHodoS2_H1(NULL), - fhMapBestPairsHodoS2_H2(NULL), - fhMapBestPairsHodoS2_S2(NULL), - fhMapBestPairsHodoS2_Proj(NULL), - fhMapBestPairsHodoS1S2_H1(NULL), - fhMapBestPairsHodoS1S2_H2(NULL), - fhMapBestPairsHodoS1S2_S1(NULL), - fhMapBestPairsHodoS1S2_Proj(NULL), - fhMapBestPairsHodoS2S1_H1(NULL), - fhMapBestPairsHodoS2S1_H2(NULL), - fhMapBestPairsHodoS2S1_S2(NULL), - fhMapBestPairsHodoS2S1_Proj(NULL), - fhMapBestPairsHodoGeoCutS1_H1(NULL), - fhMapBestPairsHodoGeoCutS1_H2(NULL), - fhMapBestPairsHodoGeoCutS1_Proj(NULL), - fhMapBestPairsHodoGeoCutS2_H1(NULL), - fhMapBestPairsHodoGeoCutS2_H2(NULL), - fhMapBestPairsHodoGeoCutS2_Proj(NULL), - fhMapBestPairsHodoS1GeoCut_H1(NULL), - fhMapBestPairsHodoS1GeoCut_H2(NULL), - fhMapBestPairsHodoS1GeoCut_S1(NULL), - fhMapBestPairsHodoS1GeoCut_Proj(NULL), - fhMapBestPairsHodoS2GeoCut_H1(NULL), - fhMapBestPairsHodoS2GeoCut_H2(NULL), - fhMapBestPairsHodoS2GeoCut_S2(NULL), - fhMapBestPairsHodoS2GeoCut_Proj(NULL), - fhMapBestPairsHodoS1S2GeoCut_H1(NULL), - fhMapBestPairsHodoS1S2GeoCut_H2(NULL), - fhMapBestPairsHodoS1S2GeoCut_S1(NULL), - fhMapBestPairsHodoS1S2GeoCut_Proj(NULL), - fhMapBestPairsHodoS2S1GeoCut_H1(NULL), - fhMapBestPairsHodoS2S1GeoCut_H2(NULL), - fhMapBestPairsHodoS2S1GeoCut_S2(NULL), - fhMapBestPairsHodoS2S1GeoCut_Proj(NULL), - fhResidualsBestPairsHodoS1(NULL), - fhResidualsBestPairsHodoS2(NULL), - fhResidualsBestPairsHodoS1S2(NULL), - fhResidualsBestPairsHodoS2S1(NULL), - fhResidualsBestPairsHodoS1GeoCut(NULL), - fhResidualsBestPairsHodoS2GeoCut(NULL), - fhResidualsBestPairsHodoS1S2GeoCut(NULL), - fhResidualsBestPairsHodoS2S1GeoCut(NULL), - fhAdcRawBestPairsHodoS1N(NULL), - fhAdcRawBestPairsHodoS1P(NULL), - fhAdcRawBestPairsHodoS2N(NULL), - fhAdcRawBestPairsHodoS2P(NULL), - fhAdcRawBestPairsHodoS1S2N(NULL), - fhAdcRawBestPairsHodoS1S2P(NULL), - fhAdcRawBestPairsHodoS2S1N(NULL), - fhAdcRawBestPairsHodoS2S1P(NULL), - fhEfficiency(NULL), - fhEfficiencyMapS1(NULL), - fhEfficiencyMapS2(NULL), - fhEfficiencyMapS1S2(NULL), - fhEfficiencyMapS2S1(NULL), - fhEfficiencyMapS1GeoCut(NULL), - fhEfficiencyMapS2GeoCut(NULL), - fhEfficiencyMapS1S2GeoCut(NULL), - fhEfficiencyMapS2S1GeoCut(NULL), - fcCanvasProjectionMaps(NULL), - fcCanvasEfficiencyMaps(NULL), - fcMsSizeAll(NULL), - fhTestBoundariesSensor1(NULL), - fhTestBoundariesSensor2(NULL), - fhTestBoundariesSensor1NoDead(NULL), - fhTestBoundariesSensor2NoDead(NULL), - fhTestChanMatchSensor1(NULL), - fhTestChanMatchSensor2(NULL), - fhTestChanMapSensor1(NULL), - fhTestChanMapSensor2(NULL), - fhTestChanMapPhysSensor1(NULL), - fhTestChanMapPhysSensor2(NULL), - fvHitsS1N(), - fvHitsS1P(), - fvHitsS2N(), - fvHitsS2P(), - fhTestMapHodoS1N(NULL), - fhTestMapHodoS1P(NULL), - fhTestMapHodoS2N(NULL), - fhTestMapHodoS2P(NULL), - ///++++++++ Adrian ADC analysis, to be moved in other class! +++++/// - fhDtNeighborChansS1N(NULL), - fhDtNeighborChansS1P(NULL), - fhDtNeighborChansS2N(NULL), - fhDtNeighborChansS2P(NULL), - fvLastHitChanS1N(), - fvLastHitChanS1P(), - fvLastHitChanS2N(), - fvLastHitChanS2P(), - fvClustersS1N(), - fvClustersS1P(), - fvClustersS2N(), - fvClustersS2P(), - fhClusterAdcVsSizeS1N(NULL), - fhClusterAdcVsSizeS1P(NULL), - fhClusterAdcVsSizeS2N(NULL), - fhClusterAdcVsSizeS2P(NULL), - fhClusterAdcVsSizeS1N_MatchS1(NULL), - fhClusterAdcVsSizeS1P_MatchS1(NULL), - fhClusterAdcVsSizeS2N_MatchS2(NULL), - fhClusterAdcVsSizeS2P_MatchS2(NULL), - fhClusterS1N_CenterNbMatchS1P(NULL), - fhClusterS1P_CenterNbMatchS1N(NULL), - fhClusterS2N_CenterNbMatchS2P(NULL), - fhClusterS2P_CenterNbMatchS2N(NULL), - fhClusterS1N_AdcNbMatchS1P(NULL), - fhClusterS1P_AdcNbMatchS1N(NULL), - fhClusterS2N_AdcNbMatchS2P(NULL), - fhClusterS2P_AdcNbMatchS2N(NULL), - fhDtNeighborChansH1X(NULL), - fhDtNeighborChansH1Y(NULL), - fhDtNeighborChansH2X(NULL), - fhDtNeighborChansH2Y(NULL), - fvLastHitChanH1X(), - fvLastHitChanH1Y(), - fvLastHitChanH2X(), - fvLastHitChanH2Y(), - fvClustersH1X(), - fvClustersH1Y(), - fvClustersH2X(), - fvClustersH2Y(), - fhClusterAdcVsSizeH1X(NULL), - fhClusterAdcVsSizeH1Y(NULL), - fhClusterAdcVsSizeH2X(NULL), - fhClusterAdcVsSizeH2Y(NULL), - fhClusterPosition_MatchH1(NULL), - fhClusterPosition_MatchH2(NULL) - ///+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// -{ -} - -CbmCosy2018MonitorEfficiency::~CbmCosy2018MonitorEfficiency() -{ -} - -Bool_t CbmCosy2018MonitorEfficiency::Init() -{ - LOG(info) << "Initializing flib StsXyter unpacker for STS"; - - FairRootManager* ioman = FairRootManager::Instance(); - if (ioman == NULL) { - LOG(fatal) << "No FairRootManager instance"; - } - - return kTRUE; -} - -void CbmCosy2018MonitorEfficiency::SetParContainers() -{ - LOG(info) << "Setting parameter containers for " << GetName(); - fUnpackParHodo = (CbmCern2017UnpackParHodo*)(FairRun::Instance()->GetRuntimeDb()->getContainer("CbmCern2017UnpackParHodo")); - fUnpackParSts = (CbmCern2017UnpackParSts*)(FairRun::Instance()->GetRuntimeDb()->getContainer("CbmCern2017UnpackParSts")); -} - - -Bool_t CbmCosy2018MonitorEfficiency::InitContainers() -{ - LOG(info) << "Init parameter containers for " << GetName(); - - Bool_t bReInit = ReInitContainers(); - CreateHistograms(); - - return bReInit; -} - -Bool_t CbmCosy2018MonitorEfficiency::ReInitContainers() -{ - LOG(info) << "ReInit parameter containers for " << GetName(); - - fuNrOfDpbs = fUnpackParHodo->GetNrOfDpbs(); - fuNbElinksPerDpb = fUnpackParHodo->GetNbElinksPerDpb(); - fuNbStsXyters = fUnpackParHodo->GetNbStsXyters(); - fuNbChanPerAsic = fUnpackParHodo->GetNbChanPerAsic(); - - - LOG(info) << "Nr. of STS DPBs: " << fuNrOfDpbs; - - fDpbIdIndexMap.clear(); - fvuElinkToAsic.resize( fuNrOfDpbs ); - for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - { - fDpbIdIndexMap[ fUnpackParHodo->GetDpbId( uDpb ) ] = uDpb; - LOG(info) << "Eq. ID for DPB #" << std::setw(2) << uDpb << " = " - << std::setw(4) << std::hex << fUnpackParHodo->GetDpbId( uDpb ) - << std::dec - << " => " << fDpbIdIndexMap[ fUnpackParHodo->GetDpbId( uDpb ) ]; - - fvuElinkToAsic[uDpb].resize( fuNbElinksPerDpb ); - for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink ) - fvuElinkToAsic[uDpb][uElink] = fUnpackParHodo->GetElinkToAsicIdx( uDpb * fuNbElinksPerDpb + uElink ); - } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - - LOG(info) << "Nr. eLinks per DPB: " << fuNbElinksPerDpb; - LOG(info) << "Nr. of StsXyter ASICs: " << fuNbStsXyters; - LOG(info) << "Nb. channels per ASIC: " << fuNbChanPerAsic; - - for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - { - LOG(info) << "ASIC ID for eLinks in DPB #" << std::setw(2) << uDpb << ": "; - - std::stringstream ss; - for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink ) - { - if( 0 == uElink % 10 ) - ss << "\n------> "; - - ss << std::setw( 5 ) << fvuElinkToAsic[uDpb][uElink] << " "; - } // for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink ) - LOG(info) << ss.str(); - } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - - LOG(info) << "ASIC Idx for Hodo 1: " << fUnpackParHodo->GetAsicIndexHodo1(); - LOG(info) << "ASIC Idx for Hodo 2: " << fUnpackParHodo->GetAsicIndexHodo2(); - - LOG(info) << "XY swapped in Hodo 1: " << fUnpackParHodo->IsXySwappedHodo1(); - LOG(info) << "XY swapped in Hodo 2: " << fUnpackParHodo->IsXySwappedHodo2(); - - LOG(info) << "X axis inverted in Hodo 1: " << fUnpackParHodo->IsXInvertedHodo1(); - LOG(info) << "X axis inverted in Hodo 1: " << fUnpackParHodo->IsYInvertedHodo1(); - LOG(info) << "X axis inverted in Hodo 2: " << fUnpackParHodo->IsXInvertedHodo2(); - LOG(info) << "X axis inverted in Hodo 2: " << fUnpackParHodo->IsYInvertedHodo2(); - - LOG(info) << "STS Tan(alpha): " << fdStereoAngleTan; - LOG(info) << "STS strip range NP: " << fdStripRangeNP; - - // Internal status initialization - fvulCurrentTsMsb.resize( fuNrOfDpbs ); - fvuCurrentTsMsbCycle.resize( fuNrOfDpbs ); - fvuElinkLastTsHit.resize( fuNrOfDpbs ); - for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - { - fvulCurrentTsMsb[uDpb] = 0; - fvuCurrentTsMsbCycle[uDpb] = 0; -/* - fvuElinkLastTsHit[uDpb].resize( fuNbElinksPerDpb ); - for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink ) - { - fvuElinkLastTsHit[uDpb][uElink] = 0; - } // for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink ) -*/ - } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - - fvulChanLastHitTime.resize( fuNbStsXyters ); - fvdChanLastHitTime.resize( fuNbStsXyters ); - fvdMsTime.resize( fuMaxNbMicroslices ); - fvuChanNbHitsInMs.resize( fuNbStsXyters ); - fvdChanLastHitTimeInMs.resize( fuNbStsXyters ); - fvusChanLastHitAdcInMs.resize( fuNbStsXyters ); -// fvmChanHitsInTs.resize( fuNbStsXyters ); - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fvulChanLastHitTime[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvdChanLastHitTime[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvuChanNbHitsInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvdChanLastHitTimeInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvusChanLastHitAdcInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); -// fvmChanHitsInTs[ uXyterIdx ].resize( fuNbChanPerAsic ); - for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - { - fvulChanLastHitTime[ uXyterIdx ][ uChan ] = 0; - fvdChanLastHitTime[ uXyterIdx ][ uChan ] = -1.0; - - fvuChanNbHitsInMs[ uXyterIdx ][ uChan ].resize( fuMaxNbMicroslices ); - fvdChanLastHitTimeInMs[ uXyterIdx ][ uChan ].resize( fuMaxNbMicroslices ); - fvusChanLastHitAdcInMs[ uXyterIdx ][ uChan ].resize( fuMaxNbMicroslices ); -// fvmChanHitsInTs[ uXyterIdx ][ uChan ].clear(); - for( UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx ) - { - fvuChanNbHitsInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = 0; - fvdChanLastHitTimeInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = -1.0; - fvusChanLastHitAdcInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = 0; - } // for( UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx ) - } // for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - LOG(info) << "CbmCosy2018MonitorEfficiency::ReInitContainers => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs.size() << " VS " << fuNbStsXyters; - LOG(info) << "CbmCosy2018MonitorEfficiency::ReInitContainers => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs[ 0 ].size() << " VS " << fuNbChanPerAsic; - LOG(info) << "CbmCosy2018MonitorEfficiency::ReInitContainers => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs[ 0 ][ 0 ].size() << " VS " << fuMaxNbMicroslices; - - /// Counting of hits without proper timestamp - fvulTimeLastHitAsicChan.resize( fuNbStsXyters ); - fviAdcLastHitAsicChan.resize( fuNbStsXyters ); - fvuNbSameHitAsicChan.resize( fuNbStsXyters ); - fvuNbSameFullHitAsicChan.resize( fuNbStsXyters ); - fvulStartTimeLastS.resize( fuNbStsXyters ); - fvuNbHitDiffTsAsicLastS.resize( fuNbStsXyters ); - fvuNbHitSameTsAsicLastS.resize( fuNbStsXyters ); - fvuNbHitSameTsAdcAsicLastS.resize( fuNbStsXyters ); - fvbAsicHasDuplicInMs.resize( fuNbStsXyters ); - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fvulTimeLastHitAsicChan[ uXyterIdx ].resize( fuNbChanPerAsic ); - fviAdcLastHitAsicChan[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvuNbSameHitAsicChan[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvuNbSameFullHitAsicChan[ uXyterIdx ].resize( fuNbChanPerAsic ); - for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - { - fvulTimeLastHitAsicChan[ uXyterIdx ][ uChan ] = 0; - fviAdcLastHitAsicChan[ uXyterIdx ][ uChan ] = 0; - fvuNbSameHitAsicChan[ uXyterIdx ][ uChan ] = 0; - fvuNbSameFullHitAsicChan[ uXyterIdx ][ uChan ] = 0; - } // for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - - fvulStartTimeLastS[ uXyterIdx ] = 0; - fvuNbHitDiffTsAsicLastS[ uXyterIdx ] = 0; - fvuNbHitSameTsAsicLastS[ uXyterIdx ] = 0; - fvuNbHitSameTsAdcAsicLastS[ uXyterIdx ] = 0; - fvbAsicHasDuplicInMs[ uXyterIdx ] = kFALSE; - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - - fvLastHitChanS1N.resize( fuNbChanPerAsic ); - fvLastHitChanS1P.resize( fuNbChanPerAsic ); - fvLastHitChanS2N.resize( fuNbChanPerAsic ); - fvLastHitChanS2P.resize( fuNbChanPerAsic ); - - fvLastHitChanH1X.resize( fuNbChanPerAsic/2 ); - fvLastHitChanH1Y.resize( fuNbChanPerAsic/2 ); - fvLastHitChanH2X.resize( fuNbChanPerAsic/2 ); - fvLastHitChanH2Y.resize( fuNbChanPerAsic/2 ); - - LOG(info) << "CbmCosy2018MonitorEfficiency::ReInitContainers => Dual STS mode: " << fbDualStsEna; - return kTRUE; -} - -void CbmCosy2018MonitorEfficiency::SetCoincidenceBorderHodo( Double_t dCenterPos, Double_t dBorderVal ) -{ - fdCoincCenterHodo = dCenterPos; - fdCoincBorderHodo = dBorderVal; - fdCoincMinHodo = dCenterPos - dBorderVal; - fdCoincMaxHodo = dCenterPos + dBorderVal; -} -void CbmCosy2018MonitorEfficiency::SetCoincidenceBorderHodoBoth( Double_t dCenterPos, Double_t dBorderVal ) -{ - fdCoincCenterHodoBoth = dCenterPos; - fdCoincBorderHodoBoth = dBorderVal; - fdCoincMinHodoBoth = dCenterPos - dBorderVal; - fdCoincMaxHodoBoth = dCenterPos + dBorderVal; -} -void CbmCosy2018MonitorEfficiency::SetCoincidenceBorderSts1( Double_t dCenterPos, Double_t dBorderVal ) -{ - fdCoincCenterSts1 = dCenterPos; - fdCoincBorderSts1 = dBorderVal; - fdCoincMinSts1 = dCenterPos - dBorderVal; - fdCoincMaxSts1 = dCenterPos + dBorderVal; -} -void CbmCosy2018MonitorEfficiency::SetCoincidenceBorderSts2( Double_t dCenterPos, Double_t dBorderVal ) -{ - fdCoincCenterSts2 = dCenterPos; - fdCoincBorderSts2 = dBorderVal; - fdCoincMinSts2 = dCenterPos - dBorderVal; - fdCoincMaxSts2 = dCenterPos + dBorderVal; -} -void CbmCosy2018MonitorEfficiency::SetCoincidenceBorderHodoSts1( Double_t dCenterPos, Double_t dBorderVal ) -{ - fdCoincCenterHodoS1 = dCenterPos; - fdCoincBorderHodoS1 = dBorderVal; - fdCoincMinHodoS1 = dCenterPos - dBorderVal; - fdCoincMaxHodoS1 = dCenterPos + dBorderVal; -} -void CbmCosy2018MonitorEfficiency::SetCoincidenceBorderHodoSts2( Double_t dCenterPos, Double_t dBorderVal ) -{ - fdCoincCenterHodoS2 = dCenterPos; - fdCoincBorderHodoS2 = dBorderVal; - fdCoincMinHodoS2 = dCenterPos - dBorderVal; - fdCoincMaxHodoS2 = dCenterPos + dBorderVal; -} -void CbmCosy2018MonitorEfficiency::SetCoincidenceBorder( Double_t dCenterPos, Double_t dBorderVal ) -{ - fdCoincCenter = dCenterPos; - fdCoincBorder = dBorderVal; - fdCoincMin = dCenterPos - dBorderVal; - fdCoincMax = dCenterPos + dBorderVal; -} - -void CbmCosy2018MonitorEfficiency::SetPositionsMmZ( Double_t dPosH1, Double_t dPosH2, Double_t dPosS1, Double_t dPosS2 ) -{ - if( dPosH1 == dPosH2 ) - LOG(fatal) << "CbmCosy2018MonitorEfficiency::SetPositionsZ => Hodo 1 and 2 cannot have the same Z position " - << "as projection to STS would lead to a division by 0!!! " - << dPosH1 << " VS " << dPosH2; - - fdPosZH1 = dPosH1; - fdPosZH2 = dPosH2; - fdPosZS1 = dPosS1; - fdPosZS2 = dPosS2; - fdRatioZS1 = ( fdPosZS1 - fdPosZH1 ) / ( fdPosZH2 - fdPosZH1 ); - fdRatioZS2 = ( fdPosZS2 - fdPosZH1 ) / ( fdPosZH2 - fdPosZH1 ); -} - -void CbmCosy2018MonitorEfficiency::CreateHistograms() -{ - LOG(info) << "Create histograms for " << GetName(); - - TString sHistName{""}; - TString title{""}; - - sHistName = "hHodoMessageType"; - title = "Nb of message for each type; Type"; - fhHodoMessType = new TH1I(sHistName, title, 5, 0., 5.); - fhHodoMessType->GetXaxis()->SetBinLabel( 1, "Dummy"); - fhHodoMessType->GetXaxis()->SetBinLabel( 2, "Hit"); - fhHodoMessType->GetXaxis()->SetBinLabel( 3, "TsMsb"); - fhHodoMessType->GetXaxis()->SetBinLabel( 4, "Epoch"); - fhHodoMessType->GetXaxis()->SetBinLabel( 5, "Empty"); -/* *** Missing int + MessType OP!!!! **** - fhHodoMessType->GetXaxis()->SetBinLabel(1 + stsxyter::MessType::Dummy, "Dummy"); - fhHodoMessType->GetXaxis()->SetBinLabel(1 + stsxyter::MessType::Hit, "Hit"); - fhHodoMessType->GetXaxis()->SetBinLabel(1 + stsxyter::MessType::TsMsb, "TsMsb"); - fhHodoMessType->GetXaxis()->SetBinLabel(1 + stsxyter::MessType::ReadDataAck, "ReadDataAck"); - fhHodoMessType->GetXaxis()->SetBinLabel(1 + stsxyter::MessType::Ack, "Ack"); -*/ - - sHistName = "hHodoSysMessType"; - title = "Nb of system message for each type; System Type"; - fhHodoSysMessType = new TH1I(sHistName, title, 17, 0., 17.); -/* - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_START, "DAQ START"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_FINISH, "DAQ FINISH"); - hSysMessType->GetXaxis()->SetBinLabel(1 + 16, "GET4 Hack 32B"); -*/ - - sHistName = "hHodoMessageTypePerDpb"; - title = "Nb of message of each type for each DPB; DPB; Type"; - fhHodoMessTypePerDpb = new TH2I(sHistName, title, fuNrOfDpbs, 0, fuNrOfDpbs, 5, 0., 5.); - fhHodoMessTypePerDpb->GetYaxis()->SetBinLabel( 1, "Dummy"); - fhHodoMessTypePerDpb->GetYaxis()->SetBinLabel( 2, "Hit"); - fhHodoMessTypePerDpb->GetYaxis()->SetBinLabel( 3, "TsMsb"); - fhHodoMessTypePerDpb->GetYaxis()->SetBinLabel( 4, "Epoch"); - fhHodoMessTypePerDpb->GetYaxis()->SetBinLabel( 5, "Empty"); -/* *** Missing int + MessType OP!!!! **** - fhHodoMessType->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Dummy, "Dummy"); - fhHodoMessType->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Hit, "Hit"); - fhHodoMessType->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::TsMsb, "TsMsb"); - fhHodoMessType->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::ReadDataAck, "ReadDataAck"); - fhHodoMessType->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Ack, "Ack"); -*/ - - sHistName = "hHodoSysMessTypePerDpb"; - title = "Nb of system message of each type for each DPB; DPB; System Type"; - fhHodoSysMessTypePerDpb = new TH2I(sHistName, title, fuNrOfDpbs, 0, fuNrOfDpbs, 17, 0., 17.); -/* - hSysMessType->GetYaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_START, "DAQ START"); - hSysMessType->GetYaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_FINISH, "DAQ FINISH"); - hSysMessType->GetYaxis()->SetBinLabel(1 + 16, "GET4 Hack 32B"); -*/ - - sHistName = "hHodoMessageTypePerElink"; - title = "Nb of message of each type for each eLink; eLink; Type"; - fhHodoMessTypePerElink = new TH2I(sHistName, title, fuNrOfDpbs * fuNbElinksPerDpb, 0, fuNrOfDpbs * fuNbElinksPerDpb, 5, 0., 5.); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel( 1, "Dummy"); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel( 2, "Hit"); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel( 3, "TsMsb"); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel( 4, "ReadDataAck"); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel( 5, "Ack"); -/* *** Missing int + MessType OP!!!! **** - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Dummy, "Dummy"); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Hit, "Hit"); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::TsMsb, "TsMsb"); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::ReadDataAck, "ReadDataAck"); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Ack, "Ack"); -*/ - - sHistName = "hHodoSysMessTypePerElink"; - title = "Nb of system message of each type for each eLink; eLink; System Type"; - fhHodoSysMessTypePerElink = new TH2I(sHistName, title, fuNrOfDpbs * fuNbElinksPerDpb, 0, fuNrOfDpbs * fuNbElinksPerDpb, 17, 0., 17.); -/* - fhHodoSysMessTypePerElink->GetYaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_START, "DAQ START"); - fhHodoSysMessTypePerElink->GetYaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_FINISH, "DAQ FINISH"); - fhHodoSysMessTypePerElink->GetYaxis()->SetBinLabel(1 + 16, "GET4 Hack 32B"); -*/ - - // Number of rate bins = - // 9 for the sub-unit decade - // + 9 for each unit of each decade * 10 for the subdecade range - // + 1 for the closing bin top edge - const Int_t iNbDecadesRate = 9; - const Int_t iNbStepsDecade = 9; - const Int_t iNbSubStepsInStep = 10; - const Int_t iNbBinsRate = iNbStepsDecade - + iNbStepsDecade * iNbSubStepsInStep * iNbDecadesRate - + 1; - Double_t dBinsRate[iNbBinsRate]; - // First fill sub-unit decade - for( Int_t iSubU = 0; iSubU < iNbStepsDecade; iSubU ++ ) - dBinsRate[ iSubU ] = 0.1 * ( 1 + iSubU ); - std::cout << std::endl; - // Then fill the main decades - Double_t dSubstepSize = 1.0 / iNbSubStepsInStep; - for( Int_t iDecade = 0; iDecade < iNbDecadesRate; iDecade ++) - { - Double_t dBase = std::pow( 10, iDecade ); - Int_t iDecadeIdx = iNbStepsDecade - + iDecade * iNbStepsDecade * iNbSubStepsInStep; - for( Int_t iStep = 0; iStep < iNbStepsDecade; iStep++ ) - { - Int_t iStepIdx = iDecadeIdx + iStep * iNbSubStepsInStep; - for( Int_t iSubStep = 0; iSubStep < iNbSubStepsInStep; iSubStep++ ) - { - dBinsRate[ iStepIdx + iSubStep ] = dBase * (1 + iStep) - + dBase * dSubstepSize * iSubStep; - } // for( Int_t iSubStep = 0; iSubStep < iNbSubStepsInStep; iSubStep++ ) - } // for( Int_t iStep = 0; iStep < iNbStepsDecade; iStep++ ) - } // for( Int_t iDecade = 0; iDecade < iNbDecadesRate; iDecade ++) - dBinsRate[ iNbBinsRate - 1 ] = std::pow( 10, iNbDecadesRate ); - - UInt_t uAlignedLimit = fuLongHistoNbSeconds - (fuLongHistoNbSeconds % fuLongHistoBinSizeSec); - fuLongHistoBinNb = uAlignedLimit / fuLongHistoBinSizeSec; - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - // Channel counts - sHistName = Form( "hHodoChanCntRaw_%03u", uXyterIdx ); - title = Form( "Hits Count per channel, StsXyter #%03u; Channel; Hits []", uXyterIdx ); - fhHodoChanCntRaw.push_back( new TH1I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - - sHistName = Form( "hHodoChanCntRawGood_%03u", uXyterIdx ); - title = Form( "Hits Count per channel in good MS, StsXyter #%03u; Channel; Hits []", uXyterIdx ); - fhHodoChanCntRawGood.push_back( new TH1I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - - // Raw Adc Distribution - sHistName = Form( "hHodoChanAdcRaw_%03u", uXyterIdx ); - title = Form( "Raw Adc distribution per channel, StsXyter #%03u; Channel []; Adc []; Hits []", uXyterIdx ); - fhHodoChanAdcRaw.push_back( new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - stsxyter::kuHitNbAdcBins, -0.5, stsxyter::kuHitNbAdcBins -0.5 ) ); - - // Raw Adc Distribution profile - sHistName = Form( "hHodoChanAdcRawProfc_%03u", uXyterIdx ); - title = Form( "Raw Adc prodile per channel, StsXyter #%03u; Channel []; Adc []", uXyterIdx ); - fhHodoChanAdcRawProf.push_back( new TProfile(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - - // Raw Ts Distribution - sHistName = Form( "hHodoChanRawTs_%03u", uXyterIdx ); - title = Form( "Raw Timestamp distribution per channel, StsXyter #%03u; Channel []; Ts []; Hits []", uXyterIdx ); - fhHodoChanRawTs.push_back( new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - stsxyter::kuHitNbTsBins, -0.5, stsxyter::kuHitNbTsBins -0.5 ) ); - - // Missed event flag - sHistName = Form( "hHodoChanMissEvt_%03u", uXyterIdx ); - title = Form( "Missed Event flags per channel, StsXyter #%03u; Channel []; Miss Evt []; Hits []", uXyterIdx ); - fhHodoChanMissEvt.push_back( new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - 2, -0.5, 1.5 ) ); - - // Missed event flag counts evolution - - sHistName = Form( "hHodoChanMissEvtEvo_%03u", uXyterIdx ); - title = Form( "Missed Evt flags per second & channel in StsXyter #%03u; Time [s]; Channel []; Missed Evt flags []", uXyterIdx ); - fhHodoChanMissEvtEvo.push_back( new TH2I( sHistName, title, - 1800, 0, 1800, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - - // Missed event flag counts evo per StsXyter - - sHistName = Form( "hHodoFebMissEvtEvo%03u", uXyterIdx ); - title = Form( "Missed Evt flags per second in StsXyter #%03u; Time [s]; Missed Evt flags []", uXyterIdx ); - fhHodoFebMissEvtEvo.push_back( new TH1I(sHistName, title, 1800, 0, 1800 ) ); - - // Hit rates evo per channel - sHistName = Form( "hHodoChanRateEvo_%03u", uXyterIdx ); - title = Form( "Hits per second & channel in StsXyter #%03u; Time [s]; Channel []; Hits []", uXyterIdx ); - fhHodoChanHitRateEvo.push_back( new TH2I( sHistName, title, - 1800, 0, 1800, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - - // Hit rates evo per StsXyter - sHistName = Form( "hHodoFebRateEvo_%03u", uXyterIdx ); - title = Form( "Hits per second in StsXyter #%03u; Time [s]; Hits []", uXyterIdx ); - fhHodoFebRateEvo.push_back( new TH1I(sHistName, title, 1800, 0, 1800 ) ); - - // Hit rates evo per channel, 1 minute bins, 24h - sHistName = Form( "hHodoChanRateEvoLong_%03u", uXyterIdx ); - title = Form( "Hits per second & channel in StsXyter #%03u; Time [min]; Channel []; Hits []", uXyterIdx ); - fhHodoChanHitRateEvoLong.push_back( new TH2D( sHistName, title, - fuLongHistoBinNb, -0.5, uAlignedLimit - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - - // Hit rates evo per StsXyter, 1 minute bins, 24h - sHistName = Form( "hHodoFebRateEvoLong_%03u", uXyterIdx ); - title = Form( "Hits per second in StsXyter #%03u; Time [min]; Hits []", uXyterIdx ); - fhHodoFebRateEvoLong.push_back( new TH1D(sHistName, title, - fuLongHistoBinNb, -0.5, uAlignedLimit - 0.5 ) ); - - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - - UInt_t uNbBinEvo = 32768 + 1; - Double_t dMaxEdgeEvo = stsxyter::kdClockCycleNs - * static_cast< Double_t >( uNbBinEvo ) / 2.0; - Double_t dMinEdgeEvo = dMaxEdgeEvo * -1.0; - - UInt_t uNbBinDtHodo = static_cast<UInt_t>( (fdCoincMaxHodo - fdCoincMinHodo )/stsxyter::kdClockCycleNs ); - UInt_t uNbBinDtBothHodo = static_cast<UInt_t>( (fdCoincMaxHodoBoth - fdCoincMinHodoBoth)/stsxyter::kdClockCycleNs ); - UInt_t uNbBinDtSts1 = static_cast<UInt_t>( (fdCoincMaxSts1 - fdCoincMinSts1 )/stsxyter::kdClockCycleNs ); - UInt_t uNbBinDtSts2 = static_cast<UInt_t>( (fdCoincMaxSts2 - fdCoincMinSts2 )/stsxyter::kdClockCycleNs ); - UInt_t uNbBinDtHodoS1 = static_cast<UInt_t>( (fdCoincMaxHodoS1 - fdCoincMinHodoS1 )/stsxyter::kdClockCycleNs ); - UInt_t uNbBinDtHodoS2 = static_cast<UInt_t>( (fdCoincMaxHodoS2 - fdCoincMinHodoS2 )/stsxyter::kdClockCycleNs ); -// UInt_t uNbBinDtSyst = static_cast<UInt_t>( (fdCoincMax - fdCoincMin )/stsxyter::kdClockCycleNs ); - - /// Coincidences inside each detector ----------------------------/// - sHistName = "fhSetupSortedDtX1Y1"; - title = "Time diff for hits Hodo 1 X and Hodo 1 Y; tY1 - tX1 [ns]; Counts"; - fhSetupSortedDtX1Y1 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhSetupSortedDtX2Y2"; - title = "Time diff for hits Hodo 2 X and Hodo 2 Y; tY2 - tX2 [ns]; Counts"; - fhSetupSortedDtX2Y2 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhSetupSortedDtN1P1"; - title = "Time diff for hits Sts 1 N and Sts 1 P; tP1 - tN1 [ns]; Counts"; - fhSetupSortedDtN1P1 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhSetupSortedDtN2P2"; - title = "Time diff for hits Sts 2 N and Sts 2 P; tP2 - tN2 [ns]; Counts"; - fhSetupSortedDtN2P2 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhSetupSortedDtX1Y1X2Y2"; - title = "Time diff for hits Hodo 1 (X,Y) vs Hodo 2 (X,Y); t<X2,Y2> - t<X1,Y1> [ns]; Counts"; - fhSetupSortedDtX1Y1X2Y2 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhSetupSortedDtN1P1N2P2"; - title = "Time diff for hits STS 1 (N,P) vs STS 2 (N,P); t<N2,P2> - t<N1,P1> [ns]; Counts"; - fhSetupSortedDtN1P1N2P2 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhSetupSortedDtX1Y1X2Y2N1P1"; - title = "Time diff for hits Hodo (X1,Y1,X2,Y2) vs Sts 1 (N,P); t<N1,P1> - t<X1,Y1,X2,Y2> [ns]; Counts"; - fhSetupSortedDtX1Y1X2Y2N1P1 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhSetupSortedDtX1Y1X2Y2N2P2"; - title = "Time diff for hits Hodo (X1,Y1,X2,Y2) vs Sts 2 (N,P); t<N2,P2> - t<X1,Y1,X2,Y2> [ns]; Counts"; - fhSetupSortedDtX1Y1X2Y2N2P2 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhSetupSortedDtH1H2S1S2"; - title = "Time diff for hits Hodo (X1,Y1,X2,Y2) vs Sts (N1,P1,N2,P2); t<N1,P1,N2,P2> - t<X1,Y1,X2,Y2> [ns]; Counts"; - fhSetupSortedDtH1H2S1S2 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhSetupSortedMapX1Y1"; - title = "Sorted hits in coincidence for hodoscope 1 axis X and Y; X channel Hodo 1 []; Y channel Hodo 1 []; hits []"; - fhSetupSortedMapX1Y1 = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhSetupSortedMapX2Y2"; - title = "Sorted hits in coincidence for hodoscope 2 axis X and Y; X channel Hodo 2 []; Y channel Hodo 2 []; hits []"; - fhSetupSortedMapX2Y2 = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhSetupSortedMapN1P1"; - title = "Sorted hits in coincidence for Sts 1 sides N and P; N channel Sts 1 []; P channel Sts 1 []; hits []"; - fhSetupSortedMapN1P1 = new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - - sHistName = "fhSetupSortedMapN2P2"; - title = "Sorted hits in coincidence for Sts 2 sides N and P; N channel Sts 2 []; P channel Sts 2 []; hits []"; - fhSetupSortedMapN2P2 = new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - - // Coincidence counts evolution between some axis of the hodoscopes - sHistName = "hSetupSortedCntEvoX1Y1"; - title = "Nb of coincidences in both X1 and Y1 per s; Time [s]; X1-Y1 coincidences []"; - fhSetupSortedCntEvoX1Y1 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "hSetupSortedCntEvoX2Y2"; - title = "Nb of coincidences in both X2 and Y2 per s; Time [s]; X2-Y2 coincidences []"; - fhSetupSortedCntEvoX2Y2 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "hSetupSortedCntEvoN1P1"; - title = "Nb of coincidences in both N1 and P1 per s; Time [s]; N1-P1 coincidences []"; - fhSetupSortedCntEvoN1P1 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "hSetupSortedCntEvoN2P2"; - title = "Nb of coincidences in both N2 and P2 per s; Time [s]; N2-P2 coincidences []"; - fhSetupSortedCntEvoN2P2 = new TH1I(sHistName, title, 1800, 0, 1800 ); - -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - sHistName = "fhSetupSortedDtX1"; - title = "Time diff for consecutive hits in Hodo 1 X; tX1n - tX1 [ns]; Counts"; - fhSetupSortedDtX1 = new TH1I(sHistName, title, uNbBinEvo, -0.5, 2*dMaxEdgeEvo -0.5 ); - - sHistName = "fhSetupSortedDtY1"; - title = "Time diff for consecutive hits in Hodo 1 Y; tY1n - tY1 [ns]; Counts"; - fhSetupSortedDtY1 = new TH1I(sHistName, title, uNbBinEvo, -0.5, 2*dMaxEdgeEvo -0.5); - - sHistName = "fhSetupSortedDtX2"; - title = "Time diff for consecutive hits in Hodo 2 X; tX2n - tX2 [ns]; Counts"; - fhSetupSortedDtX2 = new TH1I(sHistName, title, uNbBinEvo, -0.5, 2*dMaxEdgeEvo -0.5); - - sHistName = "fhSetupSortedDtY2"; - title = "Time diff for consecutive hits in Hodo 2 Y; tY2n - tY2 [ns]; Counts"; - fhSetupSortedDtY2 = new TH1I(sHistName, title, uNbBinEvo, -0.5, 2*dMaxEdgeEvo -0.5); - - sHistName = "fhSetupSortedDtN1"; - title = "Time diff for consecutive hits in Sts 1 Y; tN1n - tN1 [ns]; Counts"; - fhSetupSortedDtN1 = new TH1I(sHistName, title, uNbBinEvo, -0.5, 2*dMaxEdgeEvo -0.5); - - sHistName = "fhSetupSortedDtP1"; - title = "Time diff for consecutive hits in Sts 1 Y; tP1n - tP1 [ns]; Counts"; - fhSetupSortedDtP1 = new TH1I(sHistName, title, uNbBinEvo, -0.5, 2*dMaxEdgeEvo -0.5); - - sHistName = "fhSetupSortedDtN2"; - title = "Time diff for consecutive hits in Sts 1 Y; tN2n - tN2 [ns]; Counts"; - fhSetupSortedDtN2 = new TH1I(sHistName, title, uNbBinEvo, -0.5, 2*dMaxEdgeEvo -0.5); - - sHistName = "fhSetupSortedDtP2"; - title = "Time diff for consecutive hits in Sts 1 Y; tP2n - tP2 [ns]; Counts"; - fhSetupSortedDtP2 = new TH1I(sHistName, title, uNbBinEvo, -0.5, 2*dMaxEdgeEvo -0.5); -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - - -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - Double_t dAdcMinMax = stsxyter::kuHitNbAdcBins + 0.5; - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - sHistName = Form( "fhSetupSortedNbSameTsChan%02u", uXyterIdx); - title = Form( "Nb Hits with same TS per second & channel Asic %02u; Time [s]; Channel []; Hits []", uXyterIdx); - fhSetupSortedNbSameTsChan.push_back( new TH2I( sHistName, title, - 1800, 0, 1800, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - - sHistName = Form( "fhSetupSortedSameTsAdcChan%02u", uXyterIdx); - title = Form( "Adc distribution per channel for Hits with same TS Asic %02u; Channel []; Adc []; Hits []", uXyterIdx); - fhSetupSortedSameTsAdcChan.push_back( new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - stsxyter::kuHitNbAdcBins, -0.5, stsxyter::kuHitNbAdcBins -0.5 ) ); - - sHistName = Form( "fhSetupSortedSameTsAdcDiff%02u", uXyterIdx); - title = Form( "Adc difference vs consecutive hit idx per channel for Hits with same TS Asic %02u; Nb same TS before []; Adc diff []; Hits []", uXyterIdx); - fhSetupSortedSameTsAdcDiff.push_back( new TH2I(sHistName, title, - 256, -0.5, 255.5, - 2*dAdcMinMax, -dAdcMinMax, dAdcMinMax ) ); - - sHistName = Form( "fhSetupSortedRatioSameTsChan%02u", uXyterIdx); - title = Form( "Ratio Hits with same TS per second & channel Asic %02u; Time [s]; Channel []; Hits []", uXyterIdx); - fhSetupSortedRatioSameTsChan.push_back( new TProfile2D( sHistName, title, - 1800, 0, 1800, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - - sHistName = Form( "fhSetupSortedNbConsSameTsChan%02u", uXyterIdx); - title = Form( "Nb consecutive Hits with same TS per channel Asic %02u; Channel []; Hits with same TS []; []", uXyterIdx); - fhSetupSortedNbConsSameTsChan.push_back( new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - 1024, -0.5, 10240.5 ) ); - - sHistName = Form( "fhSetupSortedNbConsSameTsAdcChan%02u", uXyterIdx); - title = Form( "Nb consecutive Hits with same TS and ADC per channel Asic %02u; Channel []; Hits with same TS and ADC []; []", uXyterIdx); - fhSetupSortedNbConsSameTsAdcChan.push_back( new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - 256, -0.5, 255.5 ) ); - - sHistName = Form( "fhSetupSortedNbConsSameTsVsTsAdc%02u", uXyterIdx); - title = Form( "Nb consecutive Hits with same TS vs same TS and ADC Asic %02u; Hits with same TS []; Hits with same TS and ADC []; []", uXyterIdx); - fhSetupSortedNbConsSameTsVsTsAdc.push_back( new TH2I(sHistName, title, - 256, -0.5, 255.5, - 256, -0.5, 255.5 ) ); - - sHistName = Form( "fhSetupSortedAsicRatioSameTsVsFlux%02u", uXyterIdx); - title = Form( "Ratio of hits with same TS vs Hit flux Asic %02u; Hits flux [1/s]; Same Ts / All Hits []; []", uXyterIdx); - fhSetupSortedAsicRatioSameTsVsFlux.push_back( new TH2I(sHistName, title, - iNbBinsRate - 1, dBinsRate, - 101, -0.005, 1.005 ) ); - - sHistName = Form( "fhSetupSortedAsicRatioSameTsAdcVsFlux%02u", uXyterIdx); - title = Form( "Ratio of hits with same TS and ADC vs Hit flux Asic %02u; Hits flux [1/s]; Same Ts and ADC / All Hits []; []", uXyterIdx); - fhSetupSortedAsicRatioSameTsAdcVsFlux.push_back( new TH2I(sHistName, title, - iNbBinsRate - 1, dBinsRate, - 101, -0.005, 1.005 ) ); - - sHistName = Form( "fhSetupSortedAsicRatioSameAdcSameTsVsFlux%02u", uXyterIdx); - title = Form( "Ratio of hits with same ADC amond same TS vs Hit flux Asic %02u; Hits flux [1/s]; Same TS and ADC / Same TS []; []", uXyterIdx); - fhSetupSortedAsicRatioSameAdcSameTsVsFlux.push_back( new TH2I(sHistName, title, - iNbBinsRate - 1, dBinsRate, - 101, -0.005, 1.005 ) ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - sHistName = "fhHodoX1SpillEvo"; - title = "Hodo X1 counts vs time in spill; time [s]; X1 channel []; Hits []"; - fhHodoX1SpillEvo = new TH2I(sHistName, title, - 70000, 0, 70.0, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhHodoY1SpillEvo"; - title = "Hodo Y1 counts vs time in spill; time [s]; Y1 channel []; Hits []"; - fhHodoY1SpillEvo = new TH2I(sHistName, title, - 70000, 0, 70.0, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - sHistName = "fhHodoX2SpillEvo"; - title = "Hodo X2 counts vs time in spill; time [s]; X2 channel []; Hits []"; - fhHodoX2SpillEvo = new TH2I(sHistName, title, - 70000, 0, 70.0, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - sHistName = "fhHodoY2SpillEvo"; - title = "Hodo Y2 counts vs time in spill; time [s]; Y2 channel []; Hits []"; - fhHodoY2SpillEvo = new TH2I(sHistName, title, - 70000, 0, 70.0, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhHodoX1SpillEvoProf"; - title = "Hodo X1 counts vs time in spill; time [s]; X1 channel []; Hits []"; - fhHodoX1SpillEvoProf = new TProfile(sHistName, title, - 10*fdSpillEvoLength, 0, fdSpillEvoLength); - - sHistName = "fhHodoY1SpillEvoProf"; - title = "Hodo Y1 counts vs time in spill; time [s]; Y1 channel []; Hits []"; - fhHodoY1SpillEvoProf = new TProfile(sHistName, title, - 10*fdSpillEvoLength, 0, fdSpillEvoLength); - sHistName = "fhHodoX2SpillEvoProf"; - title = "Hodo X2 counts vs time in spill; time [s]; X2 channel []; Hits []"; - fhHodoX2SpillEvoProf = new TProfile(sHistName, title, - 10*fdSpillEvoLength, 0, fdSpillEvoLength); - sHistName = "fhHodoY2SpillEvoProf"; - title = "Hodo Y2 counts vs time in spill; time [s]; Y2 channel []; Hits []"; - fhHodoY2SpillEvoProf = new TProfile(sHistName, title, - 10*fdSpillEvoLength, 0, fdSpillEvoLength); - -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - - sHistName = "fhRatioMsDuplicateQuality"; - title = "Fraction of MS with a given number od ASICs without duplicated hits; Clean Asics Nb []; MS fraction []"; - fhRatioMsDuplicateQuality = new TProfile(sHistName, title, fuNbStsXyters + 1, 0, fuNbStsXyters + 1 ); - - for( UInt_t uXyterIdx = 0; uXyterIdx <= fuNbStsXyters; ++uXyterIdx ) - { - sHistName = Form( "fhEvoMsDuplicateQuality%02u", uXyterIdx); - title = Form( "Fraction of MS with %02u ASICs without duplicate hits vs time; time [s]; MS fraction []", uXyterIdx); - fhEvoMsDuplicateQuality.push_back( new TProfile(sHistName, title, 300000, 0, 300.0 ) ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - - sHistName = "fhSizeCleanMs"; - title = "Size in Hits of MS without duplicated hits; Size [Hits]; MS Nb []"; - fhSizeCleanMs = new TH1I(sHistName, title, 500000, 0, 500000 ); -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - - Double_t dMapSizeMmX = kdSensorsSzX + 100 * kdPitchMm; - Double_t dMapSizeMmY = kdSensorsSzY + 100 * kdPitchMm; - Int_t iNbBinsX = dMapSizeMmX / kdPitchMm; // 58 um bin - Int_t iNbBinsY = dMapSizeMmY / kdPitchMm / 7.54; // 116 um bin - - Double_t dMapProjSizeMmXY = 70; - Int_t iMapProjNbBinsXY = 140; -/* - iNbBinsX / 4, -dMapSizeMmX, dMapSizeMmX, - iNbBinsY / 4, -dMapSizeMmY, dMapSizeMmY ); -*/ - - sHistName = "fhStsSortedMapS1"; - title = "Sorted hits in coincidence for Sts 1 axis X and Y; X1 [mm]; Y1 [mm]; Hits []"; - fhStsSortedMapS1 = new TH2I( sHistName, title, - iNbBinsX, -dMapSizeMmX / 2.0, dMapSizeMmX / 2.0, - iNbBinsY, -dMapSizeMmY / 2.0, dMapSizeMmY / 2.0 ); - - if( kTRUE == fbDualStsEna ) - { - sHistName = "fhStsSortedMapS2"; - title = "Sorted hits in coincidence for Sts 2 axis X and Y; X2 [mm]; Y2 [mm]; Hits []"; - fhStsSortedMapS2 = new TH2I( sHistName, title, - iNbBinsX, -dMapSizeMmX / 2.0, dMapSizeMmX / 2.0, - iNbBinsY, -dMapSizeMmY / 2.0, dMapSizeMmY / 2.0 ); - - sHistName = "fhStsSortedMapS1Coinc"; - title = "Sorted hits in coincidence for Sts 1 axis X and Y if Sts2 in coinc; X1 [mm]; Y1 [mm]; Hits []"; - fhStsSortedMapS1Coinc = new TH2I( sHistName, title, - iNbBinsX, -dMapSizeMmX / 2.0, dMapSizeMmX / 2.0, - iNbBinsY, -dMapSizeMmY / 2.0, dMapSizeMmY / 2.0 ); - - sHistName = "fhStsSortedMapS2Coinc"; - title = "Sorted hits in coincidence for Sts 2 axis X and Y if Sts1 in coinc; X2 [mm]; Y2 [mm]; Hits []"; - fhStsSortedMapS2Coinc = new TH2I( sHistName, title, - iNbBinsX, -dMapSizeMmX / 2.0, dMapSizeMmX / 2.0, - iNbBinsY, -dMapSizeMmY / 2.0, dMapSizeMmY / 2.0 ); - } // if( kTRUE == fbDualStsEna ) -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - sHistName = "fhNbY1CoincPerX1"; - title = "Nb of Y1 hits in coincidence with each X1 hit; Y1 Hits in window [Hits]; Counts []"; - fhNbY1CoincPerX1 = new TH1I(sHistName, title, 256, 0, 256 ); - - sHistName = "fhNbY2CoincPerX2"; - title = "Nb of Y2 hits in coincidence with each X2 hit; Y2 Hits in window [Hits]; Counts []"; - fhNbY2CoincPerX2 = new TH1I(sHistName, title, 256, 0, 256 ); - - sHistName = "fhNbP1CoincPerN1"; - title = "Nb of P1 hits in coincidence with each N1 hit; P1 Hits in window [Hits]; Counts []"; - fhNbP1CoincPerN1 = new TH1I(sHistName, title, 256, 0, 256 ); - - sHistName = "fhNbP2CoincPerN2"; - title = "Nb of P2 hits in coincidence with each N2 hit; P2 Hits in window [Hits]; Counts []"; - fhNbP2CoincPerN2 = new TH1I(sHistName, title, 256, 0, 256 ); - - sHistName = "fhNbH2CoincPerH1"; - title = "Nb of H2 hit pairs in coincidence with each H1 hit pair; H2 pairs in window [Hit pairs]; Counts []"; - fhNbH2CoincPerH1 = new TH1I(sHistName, title, 256, 0, 256 ); - - sHistName = "fhNbS1CoincPerHodo"; - title = "Nb of S1 hit pairs in coincidence with each Hodo pair; S1 pairs in window [Hit pairs]; Counts []"; - fhNbS1CoincPerHodo = new TH1I(sHistName, title, 256, 0, 256 ); - - sHistName = "fhNbS2CoincPerHodo"; - title = "Nb of S2 hit pairs in coincidence with each Hodo pair; S2 pairs in window [Hit pairs]; Counts []"; - fhNbS2CoincPerHodo = new TH1I(sHistName, title, 256, 0, 256 ); - - sHistName = "fhNbS1CoincPerHodoS2"; - title = "Nb of S1 hit pairs in coincidence with each Hodo pair if matching STS 2 Hit; S1 pairs in window [Hit pairs]; Counts []"; - fhNbS1CoincPerHodoS2 = new TH1I(sHistName, title, 256, 0, 256 ); - - sHistName = "fhNbS2CoincPerHodoS1"; - title = "Nb of S2 hit pairs in coincidence with each Hodo pair if matching STS 1 Hit; S2 pairs in window [Hit pairs]; Counts []"; - fhNbS2CoincPerHodoS1 = new TH1I(sHistName, title, 256, 0, 256 ); - - sHistName = "fhNbS1CoincPerHodoGeoCut"; - title = "Nb of S1 hit pairs in coincidence with each Hodo pair, w/ GeoCut; S1 pairs in window [Hit pairs]; Counts []"; - fhNbS1CoincPerHodoGeoCut = new TH1I(sHistName, title, 256, 0, 256 ); - - sHistName = "fhNbS2CoincPerHodoGeoCut"; - title = "Nb of S2 hit pairs in coincidence with each Hodo pair, w/ GeoCut; S2 pairs in window [Hit pairs]; Counts []"; - fhNbS2CoincPerHodoGeoCut = new TH1I(sHistName, title, 256, 0, 256 ); - - sHistName = "fhNbS1CoincPerHodoS2GeoCut"; - title = "Nb of S1 hit pairs in coincidence with each Hodo pair if matching STS 2 Hit, w/ GeoCut; S1 pairs in window [Hit pairs]; Counts []"; - fhNbS1CoincPerHodoS2GeoCut = new TH1I(sHistName, title, 256, 0, 256 ); - - sHistName = "fhNbS2CoincPerHodoS1GeoCut"; - title = "Nb of S2 hit pairs in coincidence with each Hodo pair if matching STS 1 Hit, w/ GeoCut; S2 pairs in window [Hit pairs]; Counts []"; - fhNbS2CoincPerHodoS1GeoCut = new TH1I(sHistName, title, 256, 0, 256 ); - -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - sHistName = "fhChanMapAllMatchS1"; - title = "Map of channels in dt coincidence for Sts 1 sides N and P; N channel Sts 1 []; P channel Sts 1 []; hits []"; - fhChanMapAllMatchS1 = new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - - sHistName = "fhChanMapAllMatchS2"; - title = "Map of channels in dt coincidence for Sts 2 sides N and P; N channel Sts 2 []; P channel Sts 2 []; hits []"; - fhChanMapAllMatchS2 = new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - - sHistName = "fhChanMapBestMatchS1"; - title = "Map of channels in best dt coincidence for Sts 1 sides N and P; N channel Sts 1 []; P channel Sts 1 []; hits []"; - fhChanMapBestMatchS1 = new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - - sHistName = "fhChanMapBestMatchS2"; - title = "Map of channels in best dt coincidence for Sts 2 sides N and P; N channel Sts 2 []; P channel Sts 2 []; hits []"; - fhChanMapBestMatchS2 = new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - sHistName = "fhDtAllPairsS1"; - title = "Time diff for pair of hits Sts 1 N and Sts 1 P; tP1 - tN1 [ns]; Counts"; - fhDtAllPairsS1 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhDtAllPairsS2"; - title = "Time diff for pair of hits Sts 2 N and Sts 1 P; tP2 - tN2 [ns]; Counts"; - fhDtAllPairsS2 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhDtAllPairsHodoS1"; - title = "Time diff for pairs of hits Hodo (1,2) vs STS 1 (N,P); t<N1,P1> - t<H1,H2> [ns]; Counts"; - fhDtAllPairsHodoS1 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhDtAllPairsHodoS2"; - title = "Time diff for pairs of hits Hodo (1,2) vs STS 2 (N,P); t<N2,P2> - t<H1,H2> [ns]; Counts"; - fhDtAllPairsHodoS2 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhDtBestPairsH1"; - title = "Time diff for best pair of hits Hodo 1 X and Hodo 1 Y; tY1 - tX1 [ns]; Counts"; - fhDtBestPairsH1 = new TH1I(sHistName, title, uNbBinDtHodo, fdCoincMinHodo, fdCoincMaxHodo ); - - sHistName = "fhDtBestPairsH2"; - title = "Time diff for best pair of hits Hodo 1 X and Hodo 1 Y; tY1 - tX1 [ns]; Counts"; - fhDtBestPairsH2 = new TH1I(sHistName, title, uNbBinDtHodo, fdCoincMinHodo, fdCoincMaxHodo ); - - sHistName = "fhDtBestPairsS1"; - title = "Time diff for best pair of hits Sts 1 N and Sts 1 P; tP1 - tN1 [ns]; Counts"; - fhDtBestPairsS1 = new TH1I(sHistName, title, uNbBinDtSts1, fdCoincMinSts1, fdCoincMaxSts1 ); - - sHistName = "fhDtBestPairsS2"; - title = "Time diff for best pair of hits Sts 2 N and Sts 1 P; tP2 - tN2 [ns]; Counts"; - fhDtBestPairsS2 = new TH1I(sHistName, title, uNbBinDtSts2, fdCoincMinSts2, fdCoincMaxSts2 ); - - sHistName = "fhDtBestPairsHodo"; - title = "Time diff for best pair of hits Hodo 1 (X,Y) vs Hodo 2 (X,Y); t<X2,Y2> - t<X1,Y1> [ns]; Counts"; - fhDtBestPairsHodo = new TH1I(sHistName, title, uNbBinDtBothHodo, fdCoincMinHodoBoth, fdCoincMaxHodoBoth ); - - sHistName = "fhDtBestPairsHodoS1"; - title = "Time diff for best pair of hits Hodo (1,2) vs STS 1 (N,P); t<N1,P1> - t<H1,H2> [ns]; Counts"; - fhDtBestPairsHodoS1 = new TH1I(sHistName, title, uNbBinDtHodoS1, fdCoincMinHodoS1, fdCoincMaxHodoS1 ); - - sHistName = "fhDtBestPairsHodoS2"; - title = "Time diff for best pair of hits Hodo (1,2) vs STS 2 (N,P); t<N2,P2> - t<H1,H2> [ns]; Counts"; - fhDtBestPairsHodoS2 = new TH1I(sHistName, title, uNbBinDtHodoS2, fdCoincMinHodoS2, fdCoincMaxHodoS2 ); - - sHistName = "fhDtBestPairsHodoS1S2"; - title = "Time diff for best pair of hits Hodo (1,2) vs STS 1 (N,P) if matching STS 2 Hit; t<N1,P1>|S2 - t<H1,H2> [ns]; Counts"; - fhDtBestPairsHodoS1S2 = new TH1I(sHistName, title, uNbBinDtHodoS1, fdCoincMinHodoS1, fdCoincMaxHodoS1 ); - - sHistName = "fhDtBestPairsHodoS2S1"; - title = "Time diff for best pair of hits Hodo (1,2) vs STS 2 (N,P) if matching STS 1 Hit; t<N2,P2>|S1 - t<H1,H2> [ns]; Counts"; - fhDtBestPairsHodoS2S1 = new TH1I(sHistName, title, uNbBinDtHodoS2, fdCoincMinHodoS2, fdCoincMaxHodoS2 ); -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - sHistName = "fhMapBestPairsH1"; - title = "Position for best pair of hits in Hodo 1 X and Hodo 1 Y; X1 [mm]; Y1 [mm]; Hits []"; - fhMapBestPairsH1 = new TH2I( sHistName, title, - kiNbFibers, -kdHodoSzXY / 2.0, kdHodoSzXY / 2.0, - kiNbFibers, -kdHodoSzXY / 2.0, kdHodoSzXY / 2.0 ); - - sHistName = "fhMapBestPairsH2"; - title = "Position for best pair of hits in Hodo 2 X and Hodo 2 Y; X2 [mm]; Y2 [mm]; Hits []"; - fhMapBestPairsH2 = new TH2I( sHistName, title, - kiNbFibers, -kdHodoSzXY / 2.0, kdHodoSzXY / 2.0, - kiNbFibers, -kdHodoSzXY / 2.0, kdHodoSzXY / 2.0 ); - - sHistName = "fhMapBestPairsS1"; - title = "Position for best pair of hits in Sts 1 axis X and Y; X1 [mm]; Y1 [mm]; Hits []"; - fhMapBestPairsS1 = new TH2I( sHistName, title, - iNbBinsX, -dMapSizeMmX / 2.0, dMapSizeMmX / 2.0, - iNbBinsY, -dMapSizeMmY / 2.0, dMapSizeMmY / 2.0 ); - - sHistName = "fhMapBestPairsS2"; - title = "Position for best pair of hits in Sts 1 axis X and Y; X2 [mm]; Y2 [mm]; Hits []"; - fhMapBestPairsS2 = new TH2I( sHistName, title, - iNbBinsX, -dMapSizeMmX / 2.0, dMapSizeMmX / 2.0, - iNbBinsY, -dMapSizeMmY / 2.0, dMapSizeMmY / 2.0 ); - - sHistName = "fhMapBestPairsHodo_H1"; - title = "Position in Hodo 1 for best pair of hits in Hodo 1 and 2; X1 [mm]; Y1 [mm]; Hits []"; - fhMapBestPairsHodo_H1 = new TH2I( sHistName, title, - kiNbFibers, -kdHodoSzXY / 2.0, kdHodoSzXY / 2.0, - kiNbFibers, -kdHodoSzXY / 2.0, kdHodoSzXY / 2.0 ); - - sHistName = "fhMapBestPairsHodo_H2"; - title = "Position in Hodo 2 for best pair of hits in Hodo 1 and 2; X2 [mm]; Y2 [mm]; Hits []"; - fhMapBestPairsHodo_H2 = new TH2I( sHistName, title, - kiNbFibers, -kdHodoSzXY / 2.0, kdHodoSzXY / 2.0, - kiNbFibers, -kdHodoSzXY / 2.0, kdHodoSzXY / 2.0 ); - - sHistName = "fhMapBestPairsHodo_ProjS1"; - title = "Position in Proj in STS 1 for best pair of Hodo Hits; Xp [mm]; Yp [mm]; Hits []"; - fhMapBestPairsHodo_ProjS1 = new TH2I( sHistName, title, - iMapProjNbBinsXY, -dMapProjSizeMmXY / 2.0, dMapProjSizeMmXY / 2.0, - iMapProjNbBinsXY, -dMapProjSizeMmXY / 2.0, dMapProjSizeMmXY / 2.0 ); - - sHistName = "fhMapBestPairsHodo_ProjS2"; - title = "Position in Proj in STS 2 for best pair of Hodo Hits; Xp [mm]; Yp [mm]; Hits []"; - fhMapBestPairsHodo_ProjS2 = new TH2I( sHistName, title, - iMapProjNbBinsXY, -dMapProjSizeMmXY / 2.0, dMapProjSizeMmXY / 2.0, - iMapProjNbBinsXY, -dMapProjSizeMmXY / 2.0, dMapProjSizeMmXY / 2.0 ); - - sHistName = "fhMapBestPairsHodoS1_H1"; - title = "Position in Hodo 1 for best pair of hits in STS 1 and Hodo; X1 [mm]; Y1 [mm]; Hits []"; - fhMapBestPairsHodoS1_H1 = new TH2I( sHistName, title, - kiNbFibers, -kdHodoSzXY / 2.0, kdHodoSzXY / 2.0, - kiNbFibers, -kdHodoSzXY / 2.0, kdHodoSzXY / 2.0 ); - - sHistName = "fhMapBestPairsHodoS1_H2"; - title = "Position in Hodo 2 for best pair of hits in STS 1 and Hodo; X2 [mm]; Y2 [mm]; Hits []"; - fhMapBestPairsHodoS1_H2 = new TH2I( sHistName, title, - kiNbFibers, -kdHodoSzXY / 2.0, kdHodoSzXY / 2.0, - kiNbFibers, -kdHodoSzXY / 2.0, kdHodoSzXY / 2.0 ); - - sHistName = "fhMapBestPairsHodoS1_S1"; - title = "Position in STS 1 for best pair of hits in Sts 1 and Hodo; X1 [mm]; Y1 [mm]; Hits []"; - fhMapBestPairsHodoS1_S1 = new TH2I( sHistName, title, - iNbBinsX, -dMapSizeMmX / 2.0, dMapSizeMmX / 2.0, - iNbBinsY, -dMapSizeMmY / 2.0, dMapSizeMmY / 2.0 ); - - sHistName = "fhMapBestPairsHodoS1_Proj"; - title = "Position in Proj in STS 1 for best pair of hits in Sts 1 and Hodo; Xp [mm]; Yp [mm]; Hits []"; - fhMapBestPairsHodoS1_Proj = new TH2I( sHistName, title, - iMapProjNbBinsXY, -dMapProjSizeMmXY / 2.0, dMapProjSizeMmXY / 2.0, - iMapProjNbBinsXY, -dMapProjSizeMmXY / 2.0, dMapProjSizeMmXY / 2.0 ); - - sHistName = "fhMapBestPairsHodoS2_H1"; - title = "Position in Hodo 1 for best pair of hits in STS 2 and Hodo; X1 [mm]; Y1 [mm]; Hits []"; - fhMapBestPairsHodoS2_H1 = new TH2I( sHistName, title, - kiNbFibers, -kdHodoSzXY / 2.0, kdHodoSzXY / 2.0, - kiNbFibers, -kdHodoSzXY / 2.0, kdHodoSzXY / 2.0 ); - - sHistName = "fhMapBestPairsHodoS2_H2"; - title = "Position in Hodo 2 for best pair of hits in STS 2 and Hodo; X2 [mm]; Y2 [mm]; Hits []"; - fhMapBestPairsHodoS2_H2 = new TH2I( sHistName, title, - kiNbFibers, -kdHodoSzXY / 2.0, kdHodoSzXY / 2.0, - kiNbFibers, -kdHodoSzXY / 2.0, kdHodoSzXY / 2.0 ); - - sHistName = "fhMapBestPairsHodoS2_S2"; - title = "Position in STS 2 for best pair of hits in Sts 2 and Hodo; X2 [mm]; Y2 [mm]; Hits []"; - fhMapBestPairsHodoS2_S2 = new TH2I( sHistName, title, - iNbBinsX, -dMapSizeMmX / 2.0, dMapSizeMmX / 2.0, - iNbBinsY, -dMapSizeMmY / 2.0, dMapSizeMmY / 2.0 ); - - sHistName = "fhMapBestPairsHodoS2_Proj"; - title = "Position in Proj in STS 2 for best pair of hits in Sts 2 and Hodo; Xp [mm]; Yp [mm]; Hits []"; - fhMapBestPairsHodoS2_Proj = new TH2I( sHistName, title, - iMapProjNbBinsXY, -dMapProjSizeMmXY / 2.0, dMapProjSizeMmXY / 2.0, - iMapProjNbBinsXY, -dMapProjSizeMmXY / 2.0, dMapProjSizeMmXY / 2.0 ); - - sHistName = "fhMapBestPairsHodoS1S2_H1"; - title = "Position in Hodo 1 for best pair of hits in Sts 1 and Hodo is STS2 match; X1 [mm]; Y1 [mm]; Hits []"; - fhMapBestPairsHodoS1S2_H1 = new TH2I( sHistName, title, - kiNbFibers, -kdHodoSzXY / 2.0, kdHodoSzXY / 2.0, - kiNbFibers, -kdHodoSzXY / 2.0, kdHodoSzXY / 2.0 ); - - sHistName = "fhMapBestPairsHodoS1S2_H2"; - title = "Position in Hodo 2 for best pair of hits in Sts 1 and Hodo is STS2 match; X2 [mm]; Y2 [mm]; Hits []"; - fhMapBestPairsHodoS1S2_H2 = new TH2I( sHistName, title, - kiNbFibers, -kdHodoSzXY / 2.0, kdHodoSzXY / 2.0, - kiNbFibers, -kdHodoSzXY / 2.0, kdHodoSzXY / 2.0 ); - - sHistName = "fhMapBestPairsHodoS1S2_S1"; - title = "Position in STS 1 for best pair of hits in Sts 1 and Hodo is STS2 match; X1 [mm]; Y1 [mm]; Hits []"; - fhMapBestPairsHodoS1S2_S1 = new TH2I( sHistName, title, - iNbBinsX, -dMapSizeMmX / 2.0, dMapSizeMmX / 2.0, - iNbBinsY, -dMapSizeMmY / 2.0, dMapSizeMmY / 2.0 ); - - sHistName = "fhMapBestPairsHodoS1S2_Proj"; - title = "Position in Proj in STS 1 for best pair of hits in Sts 1 and Hodo is STS2 match; Xp [mm]; Yp [mm]; Hits []"; - fhMapBestPairsHodoS1S2_Proj = new TH2I( sHistName, title, - iMapProjNbBinsXY, -dMapProjSizeMmXY / 2.0, dMapProjSizeMmXY / 2.0, - iMapProjNbBinsXY, -dMapProjSizeMmXY / 2.0, dMapProjSizeMmXY / 2.0 ); - - sHistName = "fhMapBestPairsHodoS2S1_H1"; - title = "Position in Hodo 1 for best pair of hits in Sts 2 and Hodo id STS1 match; X1 [mm]; Y1 [mm]; Hits []"; - fhMapBestPairsHodoS2S1_H1 = new TH2I( sHistName, title, - kiNbFibers, -kdHodoSzXY / 2.0, kdHodoSzXY / 2.0, - kiNbFibers, -kdHodoSzXY / 2.0, kdHodoSzXY / 2.0 ); - - sHistName = "fhMapBestPairsHodoS2S1_H2"; - title = "Position in Hodo 2 for best pair of hits in Sts 2 and Hodo id STS1 match; X2 [mm]; Y2 [mm]; Hits []"; - fhMapBestPairsHodoS2S1_H2 = new TH2I( sHistName, title, - kiNbFibers, -kdHodoSzXY / 2.0, kdHodoSzXY / 2.0, - kiNbFibers, -kdHodoSzXY / 2.0, kdHodoSzXY / 2.0 ); - - sHistName = "fhMapBestPairsHodoS2S1_S2"; - title = "Position in STS 2 for best pair of hits in Sts 2 and Hodo id STS1 match; X2 [mm]; Y2 [mm]; Hits []"; - fhMapBestPairsHodoS2S1_S2 = new TH2I( sHistName, title, - iNbBinsX, -dMapSizeMmX / 2.0, dMapSizeMmX / 2.0, - iNbBinsY, -dMapSizeMmY / 2.0, dMapSizeMmY / 2.0 ); - - sHistName = "fhMapBestPairsHodoS2S1_Proj"; - title = "Position in Proj in STS 2 for best pair of hits in Sts 2 and Hodo id STS1 match; Xp [mm]; Yp [mm]; Hits []"; - fhMapBestPairsHodoS2S1_Proj = new TH2I( sHistName, title, - iMapProjNbBinsXY, -dMapProjSizeMmXY / 2.0, dMapProjSizeMmXY / 2.0, - iMapProjNbBinsXY, -dMapProjSizeMmXY / 2.0, dMapProjSizeMmXY / 2.0 ); -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - sHistName = "fhResidualsBestPairsHodoS1"; - title = "Residuals in STS 1 for best pair of hits in Sts 1 and Hodo; X1- X1p [mm]; Y1 - Y1p [mm]; Hits []"; - fhResidualsBestPairsHodoS1 = new TH2I( sHistName, title, - iNbBinsX * 2, -dMapSizeMmX * 2 / 2.0, dMapSizeMmX * 2 / 2.0, - iNbBinsY * 3, -dMapSizeMmY * 3 / 2.0, dMapSizeMmY * 3 / 2.0 ); - - sHistName = "fhResidualsBestPairsHodoS2"; - title = "Residuals in STS 2 for best pair of hits in Sts 2 and Hodo; X2 - X2p [mm]; Y2 - Y2p [mm]; Hits []"; - fhResidualsBestPairsHodoS2 = new TH2I( sHistName, title, - iNbBinsX * 2, -dMapSizeMmX * 2 / 2.0, dMapSizeMmX * 2 / 2.0, - iNbBinsY * 3, -dMapSizeMmY * 3 / 2.0, dMapSizeMmY * 3 / 2.0 ); - - sHistName = "fhResidualsBestPairsHodoS1S2"; - title = "Residuals in STS 1 for best pair of hits in Sts 1 and Hodo is STS2 match; X1- X1p [mm]; Y1 - Y1p [mm]; Hits []"; - fhResidualsBestPairsHodoS1S2 = new TH2I( sHistName, title, - iNbBinsX * 2, -dMapSizeMmX * 2 / 2.0, dMapSizeMmX * 2 / 2.0, - iNbBinsY * 3, -dMapSizeMmY * 3 / 2.0, dMapSizeMmY * 3 / 2.0 ); - - sHistName = "fhResidualsBestPairsHodoS2S1"; - title = "Residuals in STS 2 for best pair of hits in Sts 2 and Hodo id STS1 match; X2 - X2p [mm]; Y2 - Y2p [mm]; Hits []"; - fhResidualsBestPairsHodoS2S1 = new TH2I( sHistName, title, - iNbBinsX * 2, -dMapSizeMmX * 2 / 2.0, dMapSizeMmX * 2 / 2.0, - iNbBinsY * 3, -dMapSizeMmY * 3 / 2.0, dMapSizeMmY * 3 / 2.0 ); -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - sHistName = "fhAdcRawBestPairsHodoS1N"; - title = "Raw Adc distribution per channel, S1 N beat pair Hodo; Channel []; Adc []; Hits []"; - fhAdcRawBestPairsHodoS1N = new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - stsxyter::kuHitNbAdcBins, -0.5, stsxyter::kuHitNbAdcBins -0.5 ); - - sHistName = "fhAdcRawBestPairsHodoS1P"; - title = "Raw Adc distribution per channel, S1 P beat pair Hodo; Channel []; Adc []; Hits []"; - fhAdcRawBestPairsHodoS1P = new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - stsxyter::kuHitNbAdcBins, -0.5, stsxyter::kuHitNbAdcBins -0.5 ); - - sHistName = "fhAdcRawBestPairsHodoS2N"; - title = "Raw Adc distribution per channel, S2 N beat pair Hodo; Channel []; Adc []; Hits []"; - fhAdcRawBestPairsHodoS2N = new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - stsxyter::kuHitNbAdcBins, -0.5, stsxyter::kuHitNbAdcBins -0.5 ); - - sHistName = "fhAdcRawBestPairsHodoS2P"; - title = "Raw Adc distribution per channel, S2 P beat pair Hodo; Channel []; Adc []; Hits []"; - fhAdcRawBestPairsHodoS2P = new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - stsxyter::kuHitNbAdcBins, -0.5, stsxyter::kuHitNbAdcBins -0.5 ); - - sHistName = "fhAdcRawBestPairsHodoS1S2N"; - title = "Raw Adc distribution per channel, S1 N beat pair Hodo, if S2 hit OK; Channel []; Adc []; Hits []"; - fhAdcRawBestPairsHodoS1S2N = new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - stsxyter::kuHitNbAdcBins, -0.5, stsxyter::kuHitNbAdcBins -0.5 ); - - sHistName = "fhAdcRawBestPairsHodoS1S2P"; - title = "Raw Adc distribution per channel, S1 P beat pair Hodo, if S2 hit OK; Channel []; Adc []; Hits []"; - fhAdcRawBestPairsHodoS1S2P = new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - stsxyter::kuHitNbAdcBins, -0.5, stsxyter::kuHitNbAdcBins -0.5 ); - - sHistName = "fhAdcRawBestPairsHodoS2S1N"; - title = "Raw Adc distribution per channel, S2 N beat pair Hodo, if S1 hit OK; Channel []; Adc []; Hits []"; - fhAdcRawBestPairsHodoS2S1N = new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - stsxyter::kuHitNbAdcBins, -0.5, stsxyter::kuHitNbAdcBins -0.5 ); - - sHistName = "fhAdcRawBestPairsHodoS2S1P"; - title = "Raw Adc distribution per channel, S2 P beat pair Hodo, if S1 hit OK; Channel []; Adc []; Hits []"; - fhAdcRawBestPairsHodoS2S1P = new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - stsxyter::kuHitNbAdcBins, -0.5, stsxyter::kuHitNbAdcBins -0.5 ); - - -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - sHistName = "fhDtBestPairsHodoS1GeoCut"; - title = "Time diff for best pair of hits Hodo (1,2) vs STS 1 (N,P), w/ GeoCut; t<N1,P1> - t<H1,H2> [ns]; Counts"; - fhDtBestPairsHodoS1GeoCut = new TH1I(sHistName, title, uNbBinDtHodoS1, fdCoincMinHodoS1, fdCoincMaxHodoS1 ); - - sHistName = "fhDtBestPairsHodoS2GeoCut"; - title = "Time diff for best pair of hits Hodo (1,2) vs STS 2 (N,P), w/ GeoCut; t<N2,P2> - t<H1,H2> [ns]; Counts"; - fhDtBestPairsHodoS2GeoCut = new TH1I(sHistName, title, uNbBinDtHodoS2, fdCoincMinHodoS2, fdCoincMaxHodoS2 ); - - sHistName = "fhDtBestPairsHodoS1S2GeoCut"; - title = "Time diff for best pair of hits Hodo (1,2) vs STS 1 (N,P) if matching STS 2 Hit, w/ GeoCut; t<N1,P1>|S2 - t<H1,H2> [ns]; Counts"; - fhDtBestPairsHodoS1S2GeoCut = new TH1I(sHistName, title, uNbBinDtHodoS1, fdCoincMinHodoS1, fdCoincMaxHodoS1 ); - - sHistName = "fhDtBestPairsHodoS2S1GeoCut"; - title = "Time diff for best pair of hits Hodo (1,2) vs STS 2 (N,P) if matching STS 1 Hit, w/ GeoCut; t<N2,P2>|S1 - t<H1,H2> [ns]; Counts"; - fhDtBestPairsHodoS2S1GeoCut = new TH1I(sHistName, title, uNbBinDtHodoS2, fdCoincMinHodoS2, fdCoincMaxHodoS2 ); - -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - sHistName = "fhMapBestPairsHodoGeoCutS1_H1"; - title = "Position in Hodo 1 for best pair of hits in Hodo 1 and 2, if proj inside S1 area; X1 [mm]; Y1 [mm]; Hits []"; - fhMapBestPairsHodoGeoCutS1_H1 = new TH2I( sHistName, title, - kiNbFibers, -kdHodoSzXY / 2.0, kdHodoSzXY / 2.0, - kiNbFibers, -kdHodoSzXY / 2.0, kdHodoSzXY / 2.0 ); - - sHistName = "fhMapBestPairsHodoGeoCutS1_H2"; - title = "Position in Hodo 2 for best pair of hits in Hodo 1 and 2, if proj inside S1 area; X2 [mm]; Y2 [mm]; Hits []"; - fhMapBestPairsHodoGeoCutS1_H2 = new TH2I( sHistName, title, - kiNbFibers, -kdHodoSzXY / 2.0, kdHodoSzXY / 2.0, - kiNbFibers, -kdHodoSzXY / 2.0, kdHodoSzXY / 2.0 ); - - sHistName = "fhMapBestPairsHodoGeoCutS1_Proj"; - title = "Position in Proj in STS 1 for best pair of hits in Hodo 1 and 2, if proj inside S1 area; Xp [mm]; Yp [mm]; Hits []"; - fhMapBestPairsHodoGeoCutS1_Proj = new TH2I( sHistName, title, - iMapProjNbBinsXY, -dMapProjSizeMmXY / 2.0, dMapProjSizeMmXY / 2.0, - iMapProjNbBinsXY, -dMapProjSizeMmXY / 2.0, dMapProjSizeMmXY / 2.0 ); - - sHistName = "fhMapBestPairsHodoGeoCutS2_H1"; - title = "Position in Hodo 1 for best pair of hits in Hodo 1 and 2, if proj inside S2 area; X1 [mm]; Y1 [mm]; Hits []"; - fhMapBestPairsHodoGeoCutS2_H1 = new TH2I( sHistName, title, - kiNbFibers, -kdHodoSzXY / 2.0, kdHodoSzXY / 2.0, - kiNbFibers, -kdHodoSzXY / 2.0, kdHodoSzXY / 2.0 ); - - sHistName = "fhMapBestPairsHodoGeoCutS2_H2"; - title = "Position in Hodo 2 for best pair of hits in Hodo 1 and 2, if proj inside S2 area; X2 [mm]; Y2 [mm]; Hits []"; - fhMapBestPairsHodoGeoCutS2_H2 = new TH2I( sHistName, title, - kiNbFibers, -kdHodoSzXY / 2.0, kdHodoSzXY / 2.0, - kiNbFibers, -kdHodoSzXY / 2.0, kdHodoSzXY / 2.0 ); - - sHistName = "fhMapBestPairsHodoGeoCutS2_Proj"; - title = "Position in Proj in STS 2 for best pair of hits in Hodo 1 and 2, if proj inside S2 area; Xp [mm]; Yp [mm]; Hits []"; - fhMapBestPairsHodoGeoCutS2_Proj = new TH2I( sHistName, title, - iMapProjNbBinsXY, -dMapProjSizeMmXY / 2.0, dMapProjSizeMmXY / 2.0, - iMapProjNbBinsXY, -dMapProjSizeMmXY / 2.0, dMapProjSizeMmXY / 2.0 ); - - sHistName = "fhMapBestPairsHodoS1GeoCut_H1"; - title = "Position in Hodo 1 for best pair of hits in STS 1 and Hodo, w/ GeoCut; X1 [mm]; Y1 [mm]; Hits []"; - fhMapBestPairsHodoS1GeoCut_H1 = new TH2I( sHistName, title, - kiNbFibers, -kdHodoSzXY / 2.0, kdHodoSzXY / 2.0, - kiNbFibers, -kdHodoSzXY / 2.0, kdHodoSzXY / 2.0 ); - - sHistName = "fhMapBestPairsHodoS1GeoCut_H2"; - title = "Position in Hodo 2 for best pair of hits in STS 1 and Hodo, w/ GeoCut; X2 [mm]; Y2 [mm]; Hits []"; - fhMapBestPairsHodoS1GeoCut_H2 = new TH2I( sHistName, title, - kiNbFibers, -kdHodoSzXY / 2.0, kdHodoSzXY / 2.0, - kiNbFibers, -kdHodoSzXY / 2.0, kdHodoSzXY / 2.0 ); - - sHistName = "fhMapBestPairsHodoS1GeoCut_S1"; - title = "Position in STS 1 for best pair of hits in Sts 1 and Hodo, w/ GeoCut; X1 [mm]; Y1 [mm]; Hits []"; - fhMapBestPairsHodoS1GeoCut_S1 = new TH2I( sHistName, title, - iNbBinsX, -dMapSizeMmX / 2.0, dMapSizeMmX / 2.0, - iNbBinsY, -dMapSizeMmY / 2.0, dMapSizeMmY / 2.0 ); - - sHistName = "fhMapBestPairsHodoS1GeoCut_Proj"; - title = "Position in Proj in STS 1 for best pair of hits in Sts 1 and Hodo, w/ GeoCut; Xp [mm]; Yp [mm]; Hits []"; - fhMapBestPairsHodoS1GeoCut_Proj = new TH2I( sHistName, title, - iMapProjNbBinsXY, -dMapProjSizeMmXY / 2.0, dMapProjSizeMmXY / 2.0, - iMapProjNbBinsXY, -dMapProjSizeMmXY / 2.0, dMapProjSizeMmXY / 2.0 ); - - sHistName = "fhMapBestPairsHodoS2GeoCut_H1"; - title = "Position in Hodo 1 for best pair of hits in STS 2 and Hodo, w/ GeoCut; X1 [mm]; Y1 [mm]; Hits []"; - fhMapBestPairsHodoS2GeoCut_H1 = new TH2I( sHistName, title, - kiNbFibers, -kdHodoSzXY / 2.0, kdHodoSzXY / 2.0, - kiNbFibers, -kdHodoSzXY / 2.0, kdHodoSzXY / 2.0 ); - - sHistName = "fhMapBestPairsHodoS2GeoCut_H2"; - title = "Position in Hodo 2 for best pair of hits in STS 2 and Hodo, w/ GeoCut; X2 [mm]; Y2 [mm]; Hits []"; - fhMapBestPairsHodoS2GeoCut_H2 = new TH2I( sHistName, title, - kiNbFibers, -kdHodoSzXY / 2.0, kdHodoSzXY / 2.0, - kiNbFibers, -kdHodoSzXY / 2.0, kdHodoSzXY / 2.0 ); - - sHistName = "fhMapBestPairsHodoS2GeoCut_S2"; - title = "Position in STS 2 for best pair of hits in Sts 2 and Hodo, w/ GeoCut; X2 [mm]; Y2 [mm]; Hits []"; - fhMapBestPairsHodoS2GeoCut_S2 = new TH2I( sHistName, title, - iNbBinsX, -dMapSizeMmX / 2.0, dMapSizeMmX / 2.0, - iNbBinsY, -dMapSizeMmY / 2.0, dMapSizeMmY / 2.0 ); - - sHistName = "fhMapBestPairsHodoS2GeoCut_Proj"; - title = "Position in Proj in STS 2 for best pair of hits in Sts 2 and Hodo, w/ GeoCut; Xp [mm]; Yp [mm]; Hits []"; - fhMapBestPairsHodoS2GeoCut_Proj = new TH2I( sHistName, title, - iMapProjNbBinsXY, -dMapProjSizeMmXY / 2.0, dMapProjSizeMmXY / 2.0, - iMapProjNbBinsXY, -dMapProjSizeMmXY / 2.0, dMapProjSizeMmXY / 2.0 ); - - sHistName = "fhMapBestPairsHodoS1S2GeoCut_H1"; - title = "Position in Hodo 1 for best pair of hits in Sts 1 and Hodo is STS2 match, w/ GeoCut; X1 [mm]; Y1 [mm]; Hits []"; - fhMapBestPairsHodoS1S2GeoCut_H1 = new TH2I( sHistName, title, - kiNbFibers, -kdHodoSzXY / 2.0, kdHodoSzXY / 2.0, - kiNbFibers, -kdHodoSzXY / 2.0, kdHodoSzXY / 2.0 ); - - sHistName = "fhMapBestPairsHodoS1S2GeoCut_H2"; - title = "Position in Hodo 2 for best pair of hits in Sts 1 and Hodo is STS2 match, w/ GeoCut; X2 [mm]; Y2 [mm]; Hits []"; - fhMapBestPairsHodoS1S2GeoCut_H2 = new TH2I( sHistName, title, - kiNbFibers, -kdHodoSzXY / 2.0, kdHodoSzXY / 2.0, - kiNbFibers, -kdHodoSzXY / 2.0, kdHodoSzXY / 2.0 ); - - sHistName = "fhMapBestPairsHodoS1S2GeoCut_S1"; - title = "Position in STS 1 for best pair of hits in Sts 1 and Hodo is STS2 match, w/ GeoCut; X1 [mm]; Y1 [mm]; Hits []"; - fhMapBestPairsHodoS1S2GeoCut_S1 = new TH2I( sHistName, title, - iNbBinsX, -dMapSizeMmX / 2.0, dMapSizeMmX / 2.0, - iNbBinsY, -dMapSizeMmY / 2.0, dMapSizeMmY / 2.0 ); - - sHistName = "fhMapBestPairsHodoS1S2GeoCut_Proj"; - title = "Position in Proj in STS 1 for best pair of hits in Sts 1 and Hodo is STS2 match, w/ GeoCut; Xp [mm]; Yp [mm]; Hits []"; - fhMapBestPairsHodoS1S2GeoCut_Proj = new TH2I( sHistName, title, - iMapProjNbBinsXY, -dMapProjSizeMmXY / 2.0, dMapProjSizeMmXY / 2.0, - iMapProjNbBinsXY, -dMapProjSizeMmXY / 2.0, dMapProjSizeMmXY / 2.0 ); - - sHistName = "fhMapBestPairsHodoS2S1GeoCut_H1"; - title = "Position in Hodo 1 for best pair of hits in Sts 2 and Hodo id STS1 match, w/ GeoCut; X1 [mm]; Y1 [mm]; Hits []"; - fhMapBestPairsHodoS2S1GeoCut_H1 = new TH2I( sHistName, title, - kiNbFibers, -kdHodoSzXY / 2.0, kdHodoSzXY / 2.0, - kiNbFibers, -kdHodoSzXY / 2.0, kdHodoSzXY / 2.0 ); - - sHistName = "fhMapBestPairsHodoS2S1GeoCut_H2"; - title = "Position in Hodo 2 for best pair of hits in Sts 2 and Hodo id STS1 match, w/ GeoCut; X2 [mm]; Y2 [mm]; Hits []"; - fhMapBestPairsHodoS2S1GeoCut_H2 = new TH2I( sHistName, title, - kiNbFibers, -kdHodoSzXY / 2.0, kdHodoSzXY / 2.0, - kiNbFibers, -kdHodoSzXY / 2.0, kdHodoSzXY / 2.0 ); - - sHistName = "fhMapBestPairsHodoS2S1GeoCut_S2"; - title = "Position in STS 2 for best pair of hits in Sts 2 and Hodo id STS1 match, w/ GeoCut; X2 [mm]; Y2 [mm]; Hits []"; - fhMapBestPairsHodoS2S1GeoCut_S2 = new TH2I( sHistName, title, - iNbBinsX, -dMapSizeMmX / 2.0, dMapSizeMmX / 2.0, - iNbBinsY, -dMapSizeMmY / 2.0, dMapSizeMmY / 2.0 ); - - sHistName = "fhMapBestPairsHodoS2S1GeoCut_Proj"; - title = "Position in Proj in STS 2 for best pair of hits in Sts 2 and Hodo id STS1 match, w/ GeoCut; Xp [mm]; Yp [mm]; Hits []"; - fhMapBestPairsHodoS2S1GeoCut_Proj = new TH2I( sHistName, title, - iMapProjNbBinsXY, -dMapProjSizeMmXY / 2.0, dMapProjSizeMmXY / 2.0, - iMapProjNbBinsXY, -dMapProjSizeMmXY / 2.0, dMapProjSizeMmXY / 2.0 ); - -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - sHistName = "fhResidualsBestPairsHodoS1GeoCut"; - title = "Residuals in STS 1 for best pair of hits in Sts 1 and Hodo, w/ GeoCut; X1- X1p [mm]; Y1 - Y1p [mm]; Hits []"; - fhResidualsBestPairsHodoS1GeoCut = new TH2I( sHistName, title, - iNbBinsX * 2, -dMapSizeMmX * 2 / 2.0, dMapSizeMmX * 2 / 2.0, - iNbBinsY * 3, -dMapSizeMmY * 3 / 2.0, dMapSizeMmY * 3 / 2.0 ); - - sHistName = "fhResidualsBestPairsHodoS2GeoCut"; - title = "Residuals in STS 2 for best pair of hits in Sts 2 and Hodo, w/ GeoCut; X2 - X2p [mm]; Y2 - Y2p [mm]; Hits []"; - fhResidualsBestPairsHodoS2GeoCut = new TH2I( sHistName, title, - iNbBinsX * 2, -dMapSizeMmX * 2 / 2.0, dMapSizeMmX * 2 / 2.0, - iNbBinsY * 3, -dMapSizeMmY * 3 / 2.0, dMapSizeMmY * 3 / 2.0 ); - - sHistName = "fhResidualsBestPairsHodoS1S2GeoCut"; - title = "Residuals in STS 1 for best pair of hits in Sts 1 and Hodo is STS2 match, w/ GeoCut; X1- X1p [mm]; Y1 - Y1p [mm]; Hits []"; - fhResidualsBestPairsHodoS1S2GeoCut = new TH2I( sHistName, title, - iNbBinsX * 2, -dMapSizeMmX * 2 / 2.0, dMapSizeMmX * 2 / 2.0, - iNbBinsY * 3, -dMapSizeMmY * 3 / 2.0, dMapSizeMmY * 3 / 2.0 ); - - sHistName = "fhResidualsBestPairsHodoS2S1GeoCut"; - title = "Residuals in STS 2 for best pair of hits in Sts 2 and Hodo id STS1 match, w/ GeoCut; X2 - X2p [mm]; Y2 - Y2p [mm]; Hits []"; - fhResidualsBestPairsHodoS2S1GeoCut = new TH2I( sHistName, title, - iNbBinsX * 2, -dMapSizeMmX * 2 / 2.0, dMapSizeMmX * 2 / 2.0, - iNbBinsY * 3, -dMapSizeMmY * 3 / 2.0, dMapSizeMmY * 3 / 2.0 ); -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - sHistName = "fhEfficiency"; - title = "Efficiency of the STS sensors, w/o other, w/ other, w/ Geo Cut; ; Efficiency []"; - fhEfficiency = new TProfile(sHistName, title, 8, 0, 8 ); - fhEfficiency->GetXaxis()->SetBinLabel( 1, "S1"); - fhEfficiency->GetXaxis()->SetBinLabel( 2, "S2"); - fhEfficiency->GetXaxis()->SetBinLabel( 3, "S1S2"); - fhEfficiency->GetXaxis()->SetBinLabel( 4, "S2S1"); - fhEfficiency->GetXaxis()->SetBinLabel( 5, "S1 GC"); - fhEfficiency->GetXaxis()->SetBinLabel( 6, "S2 GC"); - fhEfficiency->GetXaxis()->SetBinLabel( 7, "S1S2 GC"); - fhEfficiency->GetXaxis()->SetBinLabel( 8, "S2S1 GC"); - - sHistName = "fhEfficiencyMapS1"; - title = "STS 1 efficiency vs Position in Proj for Hodo pairs; Xp [mm]; Yp [mm]; Efficiency []"; - fhEfficiencyMapS1 = new TProfile2D( sHistName, title, - iMapProjNbBinsXY, -dMapProjSizeMmXY / 2.0, dMapProjSizeMmXY / 2.0, - iMapProjNbBinsXY, -dMapProjSizeMmXY / 2.0, dMapProjSizeMmXY / 2.0 ); - - sHistName = "fhEfficiencyMapS2"; - title = "STS 2 efficiency vs Position in Proj for Hodo pairs; Xp [mm]; Yp [mm]; Efficiency []"; - fhEfficiencyMapS2 = new TProfile2D( sHistName, title, - iMapProjNbBinsXY, -dMapProjSizeMmXY / 2.0, dMapProjSizeMmXY / 2.0, - iMapProjNbBinsXY, -dMapProjSizeMmXY / 2.0, dMapProjSizeMmXY / 2.0 ); - - sHistName = "fhEfficiencyMapS1S2"; - title = "STS 1 efficiency vs Position in Proj for Hodo pairs, if S2 match; Xp [mm]; Yp [mm]; Efficiency []"; - fhEfficiencyMapS1S2 = new TProfile2D( sHistName, title, - iMapProjNbBinsXY, -dMapProjSizeMmXY / 2.0, dMapProjSizeMmXY / 2.0, - iMapProjNbBinsXY, -dMapProjSizeMmXY / 2.0, dMapProjSizeMmXY / 2.0 ); - - sHistName = "fhEfficiencyMapS2S1"; - title = "STS 2 efficiency vs Position in Proj for Hodo pairs, if S1 match; Xp [mm]; Yp [mm]; Efficiency []"; - fhEfficiencyMapS2S1 = new TProfile2D( sHistName, title, - iMapProjNbBinsXY, -dMapProjSizeMmXY / 2.0, dMapProjSizeMmXY / 2.0, - iMapProjNbBinsXY, -dMapProjSizeMmXY / 2.0, dMapProjSizeMmXY / 2.0 ); - - sHistName = "fhEfficiencyMapS1GeoCut"; - title = "STS 1 efficiency vs Position in Proj for Hodo pairs, w/ GeoCut; Xp [mm]; Yp [mm]; Efficiency []"; - fhEfficiencyMapS1GeoCut = new TProfile2D( sHistName, title, - iMapProjNbBinsXY, -dMapProjSizeMmXY / 2.0, dMapProjSizeMmXY / 2.0, - iMapProjNbBinsXY, -dMapProjSizeMmXY / 2.0, dMapProjSizeMmXY / 2.0 ); - - sHistName = "fhEfficiencyMapS2GeoCut"; - title = "STS 2 efficiency vs Position in Proj for Hodo pairs, w/ GeoCut; Xp [mm]; Yp [mm]; Efficiency []"; - fhEfficiencyMapS2GeoCut = new TProfile2D( sHistName, title, - iMapProjNbBinsXY, -dMapProjSizeMmXY / 2.0, dMapProjSizeMmXY / 2.0, - iMapProjNbBinsXY, -dMapProjSizeMmXY / 2.0, dMapProjSizeMmXY / 2.0 ); - - sHistName = "fhEfficiencyMapS1S2GeoCut"; - title = "STS 1 efficiency vs Position in Proj for Hodo pairs, if S2 match, w/ GeoCut; Xp [mm]; Yp [mm]; Efficiency []"; - fhEfficiencyMapS1S2GeoCut = new TProfile2D( sHistName, title, - iMapProjNbBinsXY, -dMapProjSizeMmXY / 2.0, dMapProjSizeMmXY / 2.0, - iMapProjNbBinsXY, -dMapProjSizeMmXY / 2.0, dMapProjSizeMmXY / 2.0 ); - - sHistName = "fhEfficiencyMapS2S1GeoCut"; - title = "STS 2 efficiency vs Position in Proj for Hodo pairs, if S1 match, w/ GeoCut; Xp [mm]; Yp [mm]; Efficiency []"; - fhEfficiencyMapS2S1GeoCut = new TProfile2D( sHistName, title, - iMapProjNbBinsXY, -dMapProjSizeMmXY / 2.0, dMapProjSizeMmXY / 2.0, - iMapProjNbBinsXY, -dMapProjSizeMmXY / 2.0, dMapProjSizeMmXY / 2.0 ); - -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - sHistName = "fhTestBoundariesSensor1"; - title = "Map of sensor 1 boundaries, 10 um steps; Xp [mm]; Yp [mm]; Counts []"; - fhTestBoundariesSensor1 = new TH2I( sHistName, title, 240, -60, 60, 240, -60, 60 ); - - sHistName = "fhTestBoundariesSensor2"; - title = "Map of sensor 2boundaries, 10 um steps; Xp [mm]; Yp [mm]; Hits []"; - fhTestBoundariesSensor2 = new TH2I( sHistName, title, 240, -60, 60, 240, -60, 60 ); - - sHistName = "fhTestBoundariesSensor1NoDead"; - title = "Map of sensor 1 boundaries Dead out, 10 um steps; Xp [mm]; Yp [mm]; Hits []"; - fhTestBoundariesSensor1NoDead = new TH2I( sHistName, title, 240, -60, 60, 240, -60, 60 ); - - sHistName = "fhTestBoundariesSensor2NoDead"; - title = "Map of sensor 2 boundaries dead out, 10 um steps; Xp [mm]; Yp [mm]; Hits []"; - fhTestBoundariesSensor2NoDead = new TH2I( sHistName, title, 240, -60, 60, 240, -60, 60 ); - - sHistName = "fhTestChanMatchSensor1"; - title = "Map of sensor 1 N-P channels matchs; Chan N [mm]; Chan P [mm]; Hits []"; - fhTestChanMatchSensor1 = new TH2I( sHistName, title, 128, -0.5, 127.5, 128, -0.5, 127.5 ); - - sHistName = "fhTestChanMatchSensor2"; - title = "Map of sensor 2 N-P channels matchs; Chan N [mm]; Chan P [mm]; Hits []"; - fhTestChanMatchSensor2 = new TH2I( sHistName, title, 128, -0.5, 127.5, 128, -0.5, 127.5 ); - - sHistName = "fhTestChanMapSensor1"; - title = "Map of sensor 1 N-P channels pairs points; Xp [mm]; Yp [mm]; Hits []"; - fhTestChanMapSensor1 = new TH2I( sHistName, title, 240, -60, 60, 240, -60, 60 ); - - sHistName = "fhTestChanMapSensor2"; - title = "Map of sensor 2 N-P channels pairs points; Xp [mm]; Yp [mm]; Hits []"; - fhTestChanMapSensor2 = new TH2I( sHistName, title, 240, -60, 60, 240, -60, 60 ); - - sHistName = "fhTestChanMapPhysSensor1"; - title = "Map of sensor 1 N-P channels Physical pairs points; Xp [mm]; Yp [mm]; Hits []"; - fhTestChanMapPhysSensor1 = new TH2I( sHistName, title, 240, -60, 60, 240, -60, 60 ); - - sHistName = "fhTestChanMapPhysSensor2"; - title = "Map of sensor 2 N-P channels Physical pairs points; Xp [mm]; Yp [mm]; Hits []"; - fhTestChanMapPhysSensor2 = new TH2I( sHistName, title, 240, -60, 60, 240, -60, 60 ); - - for( Double_t dTestX = -60; dTestX < 60; dTestX += 0.01 ) - for( Double_t dTestY = -60; dTestY < 60; dTestY += 0.01 ) - { - if( CheckPointInsideSensor1( dTestX, dTestY ) ) - fhTestBoundariesSensor1->Fill( dTestX, dTestY ); - if( CheckPointInsideSensor2( dTestX, dTestY ) ) - fhTestBoundariesSensor2->Fill( dTestX, dTestY ); - - if( CheckPointInsideSensor1NoDead( dTestX, dTestY ) ) - fhTestBoundariesSensor1NoDead->Fill( dTestX, dTestY ); - if( CheckPointInsideSensor2NoDead( dTestX, dTestY ) ) - fhTestBoundariesSensor2NoDead->Fill( dTestX, dTestY ); - } // Loop on X,Y - - for( Int_t iTestN = 0; iTestN < 128; ++iTestN ) - for( Int_t iTestP = 0; iTestP < 128; ++iTestP ) - { - - Double_t dX, dY; - ComputeCoordinatesSensor1( iTestN, iTestP, dX, dY ); - fhTestChanMapSensor1->Fill( dX, dY ); - if( CheckPhysPairSensor1( iTestN, iTestP ) ) - { - fhTestChanMatchSensor1->Fill( iTestN, iTestP ); - fhTestChanMapPhysSensor1->Fill( dX, dY ); - } - - ComputeCoordinatesSensor2( iTestN, iTestP, dX, dY ); - fhTestChanMapSensor2->Fill( dX, dY ); - if( CheckPhysPairSensor2( iTestN, iTestP ) ) - { - fhTestChanMatchSensor2->Fill( iTestN, iTestP ); - fhTestChanMapPhysSensor2->Fill( dX, dY ); - } - } // Loop on N,P - -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - sHistName = "fhTestMapHodoS1N"; - title = "Position in Proj in STS 1 for Hodo pairs matching a hit in STS 1 N; Xp [mm]; Yp [mm]; Fraction of hits []"; - fhTestMapHodoS1N = new TProfile2D( sHistName, title, - iNbBinsX / 2, -dMapSizeMmX / 2.0, dMapSizeMmX / 2.0, - iNbBinsY / 2, -dMapSizeMmY / 2.0, dMapSizeMmY / 2.0 ); - sHistName = "fhTestMapHodoS1P"; - title = "Position in Proj in STS 1 for Hodo pairs matching a hit in STS 1 P; Xp [mm]; Yp [mm]; Fraction of hits []"; - fhTestMapHodoS1P = new TProfile2D( sHistName, title, - iNbBinsX / 2, -dMapSizeMmX / 2.0, dMapSizeMmX / 2.0, - iNbBinsY / 2, -dMapSizeMmY / 2.0, dMapSizeMmY / 2.0 ); - sHistName = "fhTestMapHodoS2N"; - title = "Position in Proj in STS 2 for Hodo pairs matching a hit in STS 2 N; Xp [mm]; Yp [mm]; Fraction of hits []"; - fhTestMapHodoS2N = new TProfile2D( sHistName, title, - iNbBinsX / 2, -dMapSizeMmX / 2.0, dMapSizeMmX / 2.0, - iNbBinsY / 2, -dMapSizeMmY / 2.0, dMapSizeMmY / 2.0 ); - sHistName = "fhTestMapHodoS2P"; - title = "Position in Proj in STS 2 for Hodo pairs matching a hit in STS 2 P; Xp [mm]; Yp [mm]; Fraction of hits []"; - fhTestMapHodoS2P = new TProfile2D( sHistName, title, - iNbBinsX / 2, -dMapSizeMmX / 2.0, dMapSizeMmX / 2.0, - iNbBinsY / 2, -dMapSizeMmY / 2.0, dMapSizeMmY / 2.0 ); -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - - ///++++++++ Adrian ADC analysis, to be moved in other class! +++++/// - sHistName = "fhDtNeighborChansS1N"; - title = "Dt to hits on neighbors, per channel, in STS 1 N; Dt( ch + 1 - ch) [ns]; Channel []; Counts []"; - fhDtNeighborChansS1N = new TH2I( sHistName, title, - 101, -50.5 * stsxyter::kdClockCycleNs, 50.5 * stsxyter::kdClockCycleNs, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - - sHistName = "fhDtNeighborChansS1P"; - title = "Dt to hits on neighbors, per channel, in STS 1 P; Dt( ch + 1 - ch) [ns]; Channel []; Counts []"; - fhDtNeighborChansS1P = new TH2I( sHistName, title, - 101, -50.5 * stsxyter::kdClockCycleNs, 50.5 * stsxyter::kdClockCycleNs, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - - sHistName = "fhDtNeighborChansS2N"; - title = "Dt to hits on neighbors, per channel, in STS 2 N; Dt( ch + 1 - ch) [ns]; Channel []; Counts []"; - fhDtNeighborChansS2N = new TH2I( sHistName, title, - 101, -50.5 * stsxyter::kdClockCycleNs, 50.5 * stsxyter::kdClockCycleNs, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - - sHistName = "fhDtNeighborChansS2P"; - title = "Dt to hits on neighbors, per channel, in STS 2 P; Dt( ch + 1 - ch) [ns]; Channel []; Counts []"; - fhDtNeighborChansS2P = new TH2I( sHistName, title, - 101, -50.5 * stsxyter::kdClockCycleNs, 50.5 * stsxyter::kdClockCycleNs, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - - // Adc Distribution - sHistName = "fhClusterAdcVsSizeS1N"; - title = "Adc distribution per cluster vs cluster size, STS 1 N; Adc []; Cluster Sz [Ch]; Cnts []"; - fhClusterAdcVsSizeS1N = new TH2I(sHistName, title, - 3*stsxyter::kuHitNbAdcBins, -0.5, 3*stsxyter::kuHitNbAdcBins -0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - sHistName = "fhClusterAdcVsSizeS1P"; - title = "Adc distribution per cluster vs cluster size, STS 1 P; Adc []; Cluster Sz [Ch]; Cnts []"; - fhClusterAdcVsSizeS1P = new TH2I(sHistName, title, - 3*stsxyter::kuHitNbAdcBins, -0.5, 3*stsxyter::kuHitNbAdcBins -0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - sHistName = "fhClusterAdcVsSizeS2N"; - title = "Adc distribution per cluster vs cluster size, STS 2 N; Adc []; Cluster Sz [Ch]; Cnts []"; - fhClusterAdcVsSizeS2N = new TH2I(sHistName, title, - 3*stsxyter::kuHitNbAdcBins, -0.5, 3*stsxyter::kuHitNbAdcBins -0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - sHistName = "fhClusterAdcVsSizeS2P"; - title = "Adc distribution per cluster vs cluster size, STS 2 P; Adc []; Cluster Sz [Ch]; Cnts []"; - fhClusterAdcVsSizeS2P = new TH2I(sHistName, title, - 3*stsxyter::kuHitNbAdcBins, -0.5, 3*stsxyter::kuHitNbAdcBins -0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - - sHistName = "fhClusterAdcVsSizeS1N_MatchS1"; - title = "Adc distribution per cluster vs cluster size, STS 1 N, if match with P side; Adc []; Cluster Sz [Ch]; Cnts []"; - fhClusterAdcVsSizeS1N_MatchS1 = new TH2I(sHistName, title, - 3*stsxyter::kuHitNbAdcBins, -0.5, 3*stsxyter::kuHitNbAdcBins -0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - sHistName = "fhClusterAdcVsSizeS1P_MatchS1"; - title = "Adc distribution per cluster vs cluster size, STS 1 P, if match with N side; Adc []; Cluster Sz [Ch]; Cnts []"; - fhClusterAdcVsSizeS1P_MatchS1 = new TH2I(sHistName, title, - 3*stsxyter::kuHitNbAdcBins, -0.5, 3*stsxyter::kuHitNbAdcBins -0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - sHistName = "fhClusterAdcVsSizeS2N_MatchS2"; - title = "Adc distribution per cluster vs cluster size, STS 2 N, if match with P side; Adc []; Cluster Sz [Ch]; Cnts []"; - fhClusterAdcVsSizeS2N_MatchS2 = new TH2I(sHistName, title, - 3*stsxyter::kuHitNbAdcBins, -0.5, 3*stsxyter::kuHitNbAdcBins -0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - sHistName = "fhClusterAdcVsSizeS2P_MatchS2"; - title = "Adc distribution per cluster vs cluster size, STS 2 P, if match with N side; Adc []; Cluster Sz [Ch]; Cnts []"; - fhClusterAdcVsSizeS2P_MatchS2 = new TH2I(sHistName, title, - 3*stsxyter::kuHitNbAdcBins, -0.5, 3*stsxyter::kuHitNbAdcBins -0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - - sHistName = "fhClusterS1N_CenterNbMatchS1P"; - title = "Nb match P side vs center strip, STS 1 N; Center [ch]; Nb Match [cluster]; Cnts []"; - fhClusterS1N_CenterNbMatchS1P = new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - sHistName = "fhClusterS1P_CenterNbMatchS1N"; - title = "Nb match N side vs center strip, STS 1 P; Center [ch]; Nb Match [cluster]; Cnts []"; - fhClusterS1P_CenterNbMatchS1N = new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - sHistName = "fhClusterS2N_CenterNbMatchS2P"; - title = "Nb match P side vs center strip, STS 2 N; Center [ch]; Nb Match [cluster]; Cnts []"; - fhClusterS2N_CenterNbMatchS2P = new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - sHistName = "fhClusterS2P_CenterNbMatchS2N"; - title = "Nb match N side vs center strip, STS 2 P; Center [ch]; Nb Match [cluster]; Cnts []"; - fhClusterS2P_CenterNbMatchS2N = new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - - sHistName = "fhClusterS1N_AdcNbMatchS1P"; - title = "Adc distribution per cluster vs Nb matches with P cluster, STS 1 N; Adc []; Nb Match [clusters]; Cnts []"; - fhClusterS1N_AdcNbMatchS1P = new TH2I(sHistName, title, - 3*stsxyter::kuHitNbAdcBins, -0.5, 3*stsxyter::kuHitNbAdcBins -0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - sHistName = "fhClusterS1P_AdcNbMatchS1N"; - title = "Adc distribution per cluster vs Nb matches with N cluster, STS 1 P; Adc []; Nb Match [clusters]; Cnts []"; - fhClusterS1P_AdcNbMatchS1N = new TH2I(sHistName, title, - 3*stsxyter::kuHitNbAdcBins, -0.5, 3*stsxyter::kuHitNbAdcBins -0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - sHistName = "fhClusterS2N_AdcNbMatchS2P"; - title = "Adc distribution per cluster vs Nb matches with P cluster, STS 2 N; Adc []; Nb Match [clusters]; Cnts []"; - fhClusterS2N_AdcNbMatchS2P = new TH2I(sHistName, title, - 3*stsxyter::kuHitNbAdcBins, -0.5, 3*stsxyter::kuHitNbAdcBins -0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - sHistName = "fhClusterS2P_AdcNbMatchS2N"; - title = "Adc distribution per cluster vs Nb matches with N cluster, STS 2 P; Adc []; Nb Match [clusters]; Cnts []"; - fhClusterS2P_AdcNbMatchS2N = new TH2I(sHistName, title, - 3*stsxyter::kuHitNbAdcBins, -0.5, 3*stsxyter::kuHitNbAdcBins -0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - - - sHistName = "fhDtNeighborChansH1X"; - title = "Dt to hits on neighbors, per channel, in Hodo 1 X; Dt( ch + 1 - ch) [ns]; Strip []; Counts []"; - fhDtNeighborChansH1X = new TH2I( sHistName, title, - 101, -50.5 * stsxyter::kdClockCycleNs, 50.5 * stsxyter::kdClockCycleNs, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhDtNeighborChansH1Y"; - title = "Dt to hits on neighbors, per channel, in Hodo 1 Y; Dt( ch + 1 - ch) [ns]; Channel []; Counts []"; - fhDtNeighborChansH1Y = new TH2I( sHistName, title, - 101, -50.5 * stsxyter::kdClockCycleNs, 50.5 * stsxyter::kdClockCycleNs, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhDtNeighborChansH2X"; - title = "Dt to hits on neighbors, per channel, in Hodo 2 X; Dt( ch + 1 - ch) [ns]; Channel []; Counts []"; - fhDtNeighborChansH2X = new TH2I( sHistName, title, - 101, -50.5 * stsxyter::kdClockCycleNs, 50.5 * stsxyter::kdClockCycleNs, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhDtNeighborChansH2Y"; - title = "Dt to hits on neighbors, per channel, in Hodo 2 Y; Dt( ch + 1 - ch) [ns]; Channel []; Counts []"; - fhDtNeighborChansH2Y = new TH2I( sHistName, title, - 101, -50.5 * stsxyter::kdClockCycleNs, 50.5 * stsxyter::kdClockCycleNs, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhClusterAdcVsSizeH1X"; - title = "Adc distribution per cluster vs cluster size, Hodo 1 X; Adc []; Cluster Sz [Ch]; Cnts []"; - fhClusterAdcVsSizeH1X = new TH2I(sHistName, title, - 3*stsxyter::kuHitNbAdcBins, -0.5, 3*stsxyter::kuHitNbAdcBins -0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - sHistName = "fhClusterAdcVsSizeH1Y"; - title = "Adc distribution per cluster vs cluster size, Hodo 1 Y; Adc []; Cluster Sz [Ch]; Cnts []"; - fhClusterAdcVsSizeH1Y = new TH2I(sHistName, title, - 3*stsxyter::kuHitNbAdcBins, -0.5, 3*stsxyter::kuHitNbAdcBins -0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - sHistName = "fhClusterAdcVsSizeH2X"; - title = "Adc distribution per cluster vs cluster size, Hodo 2 X; Adc []; Cluster Sz [Ch]; Cnts []"; - fhClusterAdcVsSizeH2X = new TH2I(sHistName, title, - 3*stsxyter::kuHitNbAdcBins, -0.5, 3*stsxyter::kuHitNbAdcBins -0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - sHistName = "fhClusterAdcVsSizeH2Y"; - title = "Adc distribution per cluster vs cluster size, Hodo 2 Y; Adc []; Cluster Sz [Ch]; Cnts []"; - fhClusterAdcVsSizeH2Y = new TH2I(sHistName, title, - 3*stsxyter::kuHitNbAdcBins, -0.5, 3*stsxyter::kuHitNbAdcBins -0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhClusterPosition_MatchH1"; - title = "Cluste position, Hodo 1 XY match; X []; Y []; Cnts []"; - fhClusterPosition_MatchH1 = new TH2I(sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - sHistName = "fhClusterPosition_MatchH2"; - title = "Cluste position, Hodo 2 XY match; X []; Y []; Cnts []"; - fhClusterPosition_MatchH2 = new TH2I(sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - ///+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - -/* - // Distribution of the TS_MSB per StsXyter - sHistName = "hHodoFebTsMsb"; - title = "Raw Timestamp Msb distribution per StsXyter; Ts MSB []; StsXyter []; Hits []"; - fhHodoFebTsMsb = new TH2I( sHistName, title, stsxyter::kuTsMsbNbTsBins, -0.5, stsxyter::kuTsMsbNbTsBins - 0.5, - fuNbStsXyters, -0.5, fuNbStsXyters - 0.5 ); - if( server ) server->Register("/StsRaw", fhHodoFebTsMsb ); -*/ - // Miscroslice properties histos - for( Int_t component = 0; component < kiMaxNbFlibLinks; component ++ ) - { - fhMsSz[ component ] = NULL; - fhMsSzTime[ component ] = NULL; - } // for( Int_t component = 0; component < kiMaxNbFlibLinks; component ++ ) - - // Online histo browser commands - THttpServer* server = FairRunOnline::Instance()->GetHttpServer(); - if( server ) - { - server->Register("/Test", fhTestBoundariesSensor1 ); - server->Register("/Test", fhTestBoundariesSensor2 ); - server->Register("/Test", fhTestBoundariesSensor1NoDead ); - server->Register("/Test", fhTestBoundariesSensor2NoDead ); - server->Register("/Test", fhTestChanMatchSensor1 ); - server->Register("/Test", fhTestChanMatchSensor2 ); - server->Register("/Test", fhTestChanMapSensor1 ); - server->Register("/Test", fhTestChanMapSensor2 ); - server->Register("/Test", fhTestChanMapPhysSensor1 ); - server->Register("/Test", fhTestChanMapPhysSensor2 ); - server->Register("/Test", fhTestMapHodoS1N ); - server->Register("/Test", fhTestMapHodoS1P ); - server->Register("/Test", fhTestMapHodoS2N ); - server->Register("/Test", fhTestMapHodoS2P ); - - server->Register("/HodoRaw", fhHodoMessType ); - server->Register("/HodoRaw", fhHodoSysMessType ); - server->Register("/HodoRaw", fhHodoMessTypePerDpb ); - server->Register("/HodoRaw", fhHodoSysMessTypePerDpb ); - server->Register("/HodoRaw", fhHodoMessTypePerElink ); - server->Register("/HodoRaw", fhHodoSysMessTypePerElink ); - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - server->Register("/HodoRaw", fhHodoChanCntRaw[ uXyterIdx ] ); - server->Register("/HodoRaw", fhHodoChanCntRawGood[ uXyterIdx ] ); - server->Register("/HodoRaw", fhHodoChanAdcRaw[ uXyterIdx ] ); - server->Register("/HodoRaw", fhHodoChanAdcRawProf[ uXyterIdx ] ); - server->Register("/HodoRaw", fhHodoChanRawTs[ uXyterIdx ] ); - server->Register("/HodoRaw", fhHodoChanMissEvt[ uXyterIdx ] ); - server->Register("/HodoRaw", fhHodoChanMissEvtEvo[ uXyterIdx ] ); - server->Register("/HodoRaw", fhHodoFebMissEvtEvo[ uXyterIdx ] ); - server->Register("/HodoRaw", fhHodoChanHitRateEvo[ uXyterIdx ] ); - server->Register("/HodoRaw", fhHodoFebRateEvo[ uXyterIdx ] ); - server->Register("/HodoRaw", fhHodoChanHitRateEvoLong[ uXyterIdx ] ); - server->Register("/HodoRaw", fhHodoFebRateEvoLong[ uXyterIdx ] ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - server->Register("/Setup", fhSetupSortedDtX1Y1 ); - server->Register("/Setup", fhSetupSortedDtX2Y2 ); - server->Register("/Setup", fhSetupSortedDtN1P1 ); - server->Register("/Setup", fhSetupSortedDtN2P2 ); - server->Register("/Setup", fhSetupSortedDtX1Y1X2Y2 ); - server->Register("/Setup", fhSetupSortedDtX1Y1X2Y2N1P1 ); - server->Register("/Setup", fhSetupSortedDtX1Y1X2Y2N2P2 ); - server->Register("/Setup", fhSetupSortedDtH1H2S1S2 ); - server->Register("/Setup", fhSetupSortedMapX1Y1 ); - server->Register("/Setup", fhSetupSortedMapX2Y2 ); - server->Register("/Setup", fhSetupSortedMapN1P1 ); - server->Register("/Setup", fhSetupSortedMapN2P2 ); - server->Register("/Setup", fhSetupSortedCntEvoX1Y1 ); - server->Register("/Setup", fhSetupSortedCntEvoX2Y2 ); - server->Register("/Setup", fhSetupSortedCntEvoN1P1 ); - server->Register("/Setup", fhSetupSortedCntEvoN2P2 ); - - server->Register("/Setup", fhStsSortedMapS1 ); - if( kTRUE == fbDualStsEna ) - { - server->Register("/Setup", fhStsSortedMapS2 ); - server->Register("/Setup", fhStsSortedMapS1Coinc ); - server->Register("/Setup", fhStsSortedMapS2Coinc ); - } // if( kTRUE == fbDualStsEna ) - - server->Register("/FebDt", fhSetupSortedDtX1 ); - server->Register("/FebDt", fhSetupSortedDtY1 ); - server->Register("/FebDt", fhSetupSortedDtX2 ); - server->Register("/FebDt", fhSetupSortedDtY2 ); - server->Register("/FebDt", fhSetupSortedDtN1 ); - server->Register("/FebDt", fhSetupSortedDtP1 ); - server->Register("/FebDt", fhSetupSortedDtN2 ); - server->Register("/FebDt", fhSetupSortedDtP2 ); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - server->Register("/FebDupli", fhSetupSortedNbSameTsChan[ uXyterIdx ] ); - server->Register("/FebDupli", fhSetupSortedSameTsAdcChan[ uXyterIdx ] ); - server->Register("/FebDupli", fhSetupSortedSameTsAdcDiff[ uXyterIdx ] ); - server->Register("/FebDupli", fhSetupSortedRatioSameTsChan[ uXyterIdx ] ); - server->Register("/FebDupli", fhSetupSortedNbConsSameTsChan[ uXyterIdx ] ); - server->Register("/FebDupli", fhSetupSortedNbConsSameTsAdcChan[ uXyterIdx ] ); - server->Register("/FebDupli", fhSetupSortedNbConsSameTsVsTsAdc[ uXyterIdx ] ); - - server->Register("/FebDupli", fhSetupSortedAsicRatioSameTsVsFlux[ uXyterIdx ] ); - server->Register("/FebDupli", fhSetupSortedAsicRatioSameTsAdcVsFlux[ uXyterIdx ] ); - server->Register("/FebDupli", fhSetupSortedAsicRatioSameAdcSameTsVsFlux[ uXyterIdx ] ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - - server->Register("/FebDupli", fhRatioMsDuplicateQuality ); - for( UInt_t uXyterIdx = 0; uXyterIdx <= fuNbStsXyters; ++uXyterIdx ) - { - server->Register("/FebDupli", fhEvoMsDuplicateQuality[ uXyterIdx ] ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - server->Register("/FebDupli", fhSizeCleanMs ); - - server->Register("/Spill", fhHodoX1SpillEvo ); - server->Register("/Spill", fhHodoY1SpillEvo ); - server->Register("/Spill", fhHodoX2SpillEvo ); - server->Register("/Spill", fhHodoY2SpillEvo ); - server->Register("/Spill", fhHodoX1SpillEvoProf ); - server->Register("/Spill", fhHodoY1SpillEvoProf ); - server->Register("/Spill", fhHodoX2SpillEvoProf ); - server->Register("/Spill", fhHodoY2SpillEvoProf ); - - server->Register("/Multi", fhNbY1CoincPerX1 ); - server->Register("/Multi", fhNbY2CoincPerX2 ); - server->Register("/Multi", fhNbP1CoincPerN1 ); - server->Register("/Multi", fhNbP2CoincPerN2 ); - server->Register("/Multi", fhNbH2CoincPerH1 ); - server->Register("/Multi", fhNbS1CoincPerHodo ); - server->Register("/Multi", fhNbS2CoincPerHodo ); - server->Register("/Multi", fhNbS1CoincPerHodoS2 ); - server->Register("/Multi", fhNbS2CoincPerHodoS1 ); - - server->Register("/Cuts", fhChanMapAllMatchS1 ); - server->Register("/Cuts", fhChanMapAllMatchS2 ); - server->Register("/Cuts", fhChanMapBestMatchS1 ); - server->Register("/Cuts", fhChanMapBestMatchS2 ); - - server->Register("/Cuts", fhDtAllPairsS1 ); - server->Register("/Cuts", fhDtAllPairsS2 ); - server->Register("/Cuts", fhDtAllPairsHodoS1 ); - server->Register("/Cuts", fhDtAllPairsHodoS2 ); - server->Register("/Cuts", fhDtBestPairsH1 ); - server->Register("/Cuts", fhDtBestPairsH2 ); - server->Register("/Cuts", fhDtBestPairsS1 ); - server->Register("/Cuts", fhDtBestPairsS2 ); - server->Register("/Cuts", fhDtBestPairsHodo ); - server->Register("/Cuts", fhDtBestPairsHodoS1 ); - server->Register("/Cuts", fhDtBestPairsHodoS2 ); - server->Register("/Cuts", fhDtBestPairsHodoS1S2 ); - server->Register("/Cuts", fhDtBestPairsHodoS2S1 ); - server->Register("/Cuts", fhMapBestPairsH1 ); - server->Register("/Cuts", fhMapBestPairsH2 ); - server->Register("/Cuts", fhMapBestPairsS1 ); - server->Register("/Cuts", fhMapBestPairsS2 ); - server->Register("/Cuts", fhMapBestPairsHodo_H1 ); - server->Register("/Cuts", fhMapBestPairsHodo_H2 ); - server->Register("/Cuts", fhMapBestPairsHodo_ProjS1 ); - server->Register("/Cuts", fhMapBestPairsHodo_ProjS2 ); - server->Register("/Cuts", fhMapBestPairsHodoS1_H1 ); - server->Register("/Cuts", fhMapBestPairsHodoS1_H2 ); - server->Register("/Cuts", fhMapBestPairsHodoS1_S1 ); - server->Register("/Cuts", fhMapBestPairsHodoS1_Proj ); - server->Register("/Cuts", fhMapBestPairsHodoS2_H1 ); - server->Register("/Cuts", fhMapBestPairsHodoS2_H2 ); - server->Register("/Cuts", fhMapBestPairsHodoS2_S2 ); - server->Register("/Cuts", fhMapBestPairsHodoS2_Proj ); - server->Register("/Cuts", fhMapBestPairsHodoS1S2_H1 ); - server->Register("/Cuts", fhMapBestPairsHodoS1S2_H2 ); - server->Register("/Cuts", fhMapBestPairsHodoS1S2_S1 ); - server->Register("/Cuts", fhMapBestPairsHodoS1S2_Proj ); - server->Register("/Cuts", fhMapBestPairsHodoS2S1_H1 ); - server->Register("/Cuts", fhMapBestPairsHodoS2S1_H2 ); - server->Register("/Cuts", fhMapBestPairsHodoS2S1_S2 ); - server->Register("/Cuts", fhMapBestPairsHodoS2S1_Proj ); - server->Register("/Cuts", fhResidualsBestPairsHodoS1 ); - server->Register("/Cuts", fhResidualsBestPairsHodoS2 ); - server->Register("/Cuts", fhResidualsBestPairsHodoS1S2 ); - server->Register("/Cuts", fhResidualsBestPairsHodoS2S1 ); - - server->Register("/Cuts", fhAdcRawBestPairsHodoS1N ); - server->Register("/Cuts", fhAdcRawBestPairsHodoS1P ); - server->Register("/Cuts", fhAdcRawBestPairsHodoS2N ); - server->Register("/Cuts", fhAdcRawBestPairsHodoS2P ); - server->Register("/Cuts", fhAdcRawBestPairsHodoS1S2N ); - server->Register("/Cuts", fhAdcRawBestPairsHodoS1S2P ); - server->Register("/Cuts", fhAdcRawBestPairsHodoS2S1N ); - server->Register("/Cuts", fhAdcRawBestPairsHodoS2S1P ); - - server->Register("/GeoCuts", fhDtBestPairsHodoS1GeoCut ); - server->Register("/GeoCuts", fhDtBestPairsHodoS2GeoCut ); - server->Register("/GeoCuts", fhDtBestPairsHodoS1S2GeoCut ); - server->Register("/GeoCuts", fhDtBestPairsHodoS2S1GeoCut ); - server->Register("/GeoCuts", fhMapBestPairsHodoGeoCutS1_H1 ); - server->Register("/GeoCuts", fhMapBestPairsHodoGeoCutS1_H2 ); - server->Register("/GeoCuts", fhMapBestPairsHodoGeoCutS1_Proj ); - server->Register("/GeoCuts", fhMapBestPairsHodoGeoCutS2_H1 ); - server->Register("/GeoCuts", fhMapBestPairsHodoGeoCutS2_H2 ); - server->Register("/GeoCuts", fhMapBestPairsHodoGeoCutS2_Proj ); - server->Register("/GeoCuts", fhMapBestPairsHodoS1GeoCut_H1 ); - server->Register("/GeoCuts", fhMapBestPairsHodoS1GeoCut_H2 ); - server->Register("/GeoCuts", fhMapBestPairsHodoS1GeoCut_S1 ); - server->Register("/GeoCuts", fhMapBestPairsHodoS1GeoCut_Proj ); - server->Register("/GeoCuts", fhMapBestPairsHodoS2GeoCut_H1 ); - server->Register("/GeoCuts", fhMapBestPairsHodoS2GeoCut_H2 ); - server->Register("/GeoCuts", fhMapBestPairsHodoS2GeoCut_S2 ); - server->Register("/GeoCuts", fhMapBestPairsHodoS2GeoCut_Proj ); - server->Register("/GeoCuts", fhMapBestPairsHodoS1S2GeoCut_H1 ); - server->Register("/GeoCuts", fhMapBestPairsHodoS1S2GeoCut_H2 ); - server->Register("/GeoCuts", fhMapBestPairsHodoS1S2GeoCut_S1 ); - server->Register("/GeoCuts", fhMapBestPairsHodoS1S2GeoCut_Proj ); - server->Register("/GeoCuts", fhMapBestPairsHodoS2S1GeoCut_H1 ); - server->Register("/GeoCuts", fhMapBestPairsHodoS2S1GeoCut_H2 ); - server->Register("/GeoCuts", fhMapBestPairsHodoS2S1GeoCut_S2 ); - server->Register("/GeoCuts", fhMapBestPairsHodoS2S1GeoCut_Proj ); - server->Register("/GeoCuts", fhResidualsBestPairsHodoS1GeoCut ); - server->Register("/GeoCuts", fhResidualsBestPairsHodoS2GeoCut ); - server->Register("/GeoCuts", fhResidualsBestPairsHodoS1S2GeoCut ); - server->Register("/GeoCuts", fhResidualsBestPairsHodoS2S1GeoCut ); - - server->Register("/Eff", fhEfficiency ); - server->Register("/Eff", fhEfficiencyMapS1 ); - server->Register("/Eff", fhEfficiencyMapS2 ); - server->Register("/Eff", fhEfficiencyMapS1S2 ); - server->Register("/Eff", fhEfficiencyMapS2S1 ); - server->Register("/Eff", fhEfficiencyMapS1GeoCut ); - server->Register("/Eff", fhEfficiencyMapS2GeoCut ); - server->Register("/Eff", fhEfficiencyMapS1S2GeoCut ); - server->Register("/Eff", fhEfficiencyMapS2S1GeoCut ); - - server->Register("/Adc", fhDtNeighborChansS1N ); - server->Register("/Adc", fhDtNeighborChansS1P ); - server->Register("/Adc", fhDtNeighborChansS2N ); - server->Register("/Adc", fhDtNeighborChansS2P ); - server->Register("/Adc", fhClusterAdcVsSizeS1N ); - server->Register("/Adc", fhClusterAdcVsSizeS1P ); - server->Register("/Adc", fhClusterAdcVsSizeS2N ); - server->Register("/Adc", fhClusterAdcVsSizeS2P ); - server->Register("/Adc", fhClusterAdcVsSizeS1N_MatchS1 ); - server->Register("/Adc", fhClusterAdcVsSizeS1P_MatchS1 ); - server->Register("/Adc", fhClusterAdcVsSizeS2N_MatchS2 ); - server->Register("/Adc", fhClusterAdcVsSizeS2P_MatchS2 ); - - server->Register("/Adc", fhClusterS1N_CenterNbMatchS1P ); - server->Register("/Adc", fhClusterS1P_CenterNbMatchS1N ); - server->Register("/Adc", fhClusterS2N_CenterNbMatchS2P ); - server->Register("/Adc", fhClusterS2P_CenterNbMatchS2N ); - server->Register("/Adc", fhClusterS1N_AdcNbMatchS1P ); - server->Register("/Adc", fhClusterS1P_AdcNbMatchS1N ); - server->Register("/Adc", fhClusterS2N_AdcNbMatchS2P ); - server->Register("/Adc", fhClusterS2P_AdcNbMatchS2N ); - - server->Register("/Adc", fhDtNeighborChansH1X ); - server->Register("/Adc", fhDtNeighborChansH1Y ); - server->Register("/Adc", fhDtNeighborChansH2X ); - server->Register("/Adc", fhDtNeighborChansH2Y ); - server->Register("/Adc", fhClusterAdcVsSizeH1X ); - server->Register("/Adc", fhClusterAdcVsSizeH1Y ); - server->Register("/Adc", fhClusterAdcVsSizeH2X ); - server->Register("/Adc", fhClusterAdcVsSizeH2Y ); - server->Register("/Adc", fhClusterPosition_MatchH1 ); - server->Register("/Adc", fhClusterPosition_MatchH2 ); - - server->RegisterCommand("/Reset_All_Hodo", "bCosy2018ResetEfficiency=kTRUE"); - server->RegisterCommand("/Write_All_Hodo", "bCosy2018WriteEfficiency=kTRUE"); - - server->Restrict("/Reset_All_Hodo", "allow=admin"); - server->Restrict("/Write_All_Hodo", "allow=admin"); - } // if( server ) - - /** Create summary Canvases for CERN 2017 **/ - Double_t w = 10; - Double_t h = 10; - - // Summary per StsXyter - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - TCanvas* cStsSumm = new TCanvas( Form("cStsSum_%03u", uXyterIdx ), - Form("Summary plots for StsXyter %03u", uXyterIdx ), - w, h); - cStsSumm->Divide( 2, 2 ); - - cStsSumm->cd(1); - gPad->SetLogy(); - fhHodoChanCntRaw[ uXyterIdx ]->Draw(); - - cStsSumm->cd(2); - gPad->SetLogz(); - fhHodoChanAdcRaw[ uXyterIdx ]->Draw( "colz" ); - - cStsSumm->cd(3); - gPad->SetLogz(); - fhHodoChanHitRateEvo[ uXyterIdx ]->Draw( "colz" ); - - cStsSumm->cd(4); -// gPad->SetLogy(); - fhHodoChanAdcRawProf[ uXyterIdx ]->Draw(); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - -//====================================================================// - -//====================================================================// - TCanvas* cSetupSortedDt = new TCanvas( "cSetupSortedDt", - "Hodoscopes coincidence maps", - w, h); - cSetupSortedDt->Divide( 3, 3 ); - - cSetupSortedDt->cd(1); - gPad->SetGridx(); - gPad->SetLogy(); - fhSetupSortedDtX1Y1->Draw( "" ); - - cSetupSortedDt->cd(2); - gPad->SetGridx(); - gPad->SetLogy(); - fhSetupSortedDtX2Y2->Draw( "" ); - - cSetupSortedDt->cd(3); - gPad->SetGridx(); - gPad->SetLogy(); - fhSetupSortedDtN1P1->Draw( "" ); - - cSetupSortedDt->cd(4 + ( kTRUE == fbDualStsEna ? 1 : 0 ) ); - gPad->SetGridx(); - gPad->SetLogy(); - fhSetupSortedDtX1Y1X2Y2->Draw( "" ); - - cSetupSortedDt->cd(5 + ( kTRUE == fbDualStsEna ? 1 : 0 ) ); - gPad->SetGridx(); - gPad->SetLogy(); - fhSetupSortedDtN1P1N2P2->Draw( "" ); - - cSetupSortedDt->cd(6 + ( kTRUE == fbDualStsEna ? 2 : 0 ) ); - gPad->SetGridx(); - gPad->SetLogy(); - fhSetupSortedDtX1Y1X2Y2N1P1->Draw( "" ); - - cSetupSortedDt->cd(7 + ( kTRUE == fbDualStsEna ? 2 : 0 ) ); - gPad->SetGridx(); - gPad->SetLogy(); - fhSetupSortedDtX1Y1X2Y2N2P2->Draw( "" ); - - cSetupSortedDt->cd(8 + ( kTRUE == fbDualStsEna ? 2 : 0 ) ); - gPad->SetGridx(); - gPad->SetLogy(); - fhSetupSortedDtH1H2S1S2->Draw( "" ); - - if( kTRUE == fbDualStsEna ) - { - cSetupSortedDt->cd(4); - gPad->SetGridx(); - gPad->SetLogy(); - fhSetupSortedDtN2P2->Draw( "colz" ); - } // if( kTRUE == fbDualStsEna ) -//====================================================================// - -//====================================================================// - TCanvas* cSetupSortedMaps = new TCanvas( "cSetupSortedMaps", - "Hodoscopes coincidence maps", - w, h); - - if( kTRUE == fbDualStsEna ) - cSetupSortedMaps->Divide( 2, 2 ); - else cSetupSortedMaps->Divide( 3, 1 ); - - cSetupSortedMaps->cd(1); - gPad->SetLogz(); - fhSetupSortedMapX1Y1->Draw( "colz" ); - - cSetupSortedMaps->cd(2); - gPad->SetLogz(); - fhSetupSortedMapX2Y2->Draw( "colz" ); - - cSetupSortedMaps->cd(3); - gPad->SetLogz(); - fhSetupSortedMapN1P1->Draw( "colz" ); - - if( kTRUE == fbDualStsEna ) - { - cSetupSortedMaps->cd(4); - gPad->SetLogz(); - fhSetupSortedMapN2P2->Draw( "colz" ); - } // if( kTRUE == fbDualStsEna ) -//====================================================================// - -//====================================================================// - TCanvas* cSetupSortedCoincEvo = new TCanvas( "cSetupSortedCoincEvo", - "Hodoscopes coincidence rate evolution", - w, h); - cSetupSortedCoincEvo->Divide( 2, 2 ); - - cSetupSortedCoincEvo->cd(1); - gPad->SetGridy(); - gPad->SetLogy(); - fhSetupSortedCntEvoX1Y1->Draw( "" ); - - cSetupSortedCoincEvo->cd(2); - gPad->SetGridy(); - gPad->SetLogy(); - fhSetupSortedCntEvoX2Y2->Draw( "" ); - - cSetupSortedCoincEvo->cd(3); - gPad->SetGridy(); - gPad->SetLogy(); - fhSetupSortedCntEvoN1P1->Draw( "" ); - - cSetupSortedCoincEvo->cd(4); - gPad->SetGridy(); - gPad->SetLogy(); - fhSetupSortedCntEvoN2P2->Draw( "" ); -//====================================================================// - -//====================================================================// - TCanvas* cFebDt = new TCanvas( "cFebDt", - "Hodoscopes coincidence quality", - w, h); - - if( kTRUE == fbDualStsEna ) - cFebDt->Divide( 2, 4 ); - else cFebDt->Divide( 2, 3 ); - - cFebDt->cd(1); - gPad->SetLogy(); - fhSetupSortedDtX1->Draw( "" ); - - cFebDt->cd(2); - gPad->SetLogy(); - fhSetupSortedDtY1->Draw( "" ); - - cFebDt->cd(3); - gPad->SetLogy(); - fhSetupSortedDtX2->Draw( "" ); - - cFebDt->cd(4); - gPad->SetLogy(); - fhSetupSortedDtY2->Draw( "" ); - - cFebDt->cd(5); - gPad->SetLogy(); - fhSetupSortedDtN1->Draw( "" ); - - cFebDt->cd(6); - gPad->SetLogy(); - fhSetupSortedDtP1->Draw( "" ); - - if( kTRUE == fbDualStsEna ) - { - cFebDt->cd(7); - gPad->SetLogy(); - fhSetupSortedDtN2->Draw( "" ); - - cFebDt->cd(8); - gPad->SetLogy(); - fhSetupSortedDtP2->Draw( "" ); - } // if( kTRUE == fbDualStsEna ) -//====================================================================// - -//====================================================================// - TCanvas* cFebSameTs = new TCanvas( "cFebSameTs", - "Hodoscopes coincidence quality", - w, h); - - cFebSameTs->Divide( 2, fuNbStsXyters/2 + fuNbStsXyters%2 ); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - cFebSameTs->cd(1 + uXyterIdx ); - gPad->SetLogz(); - fhSetupSortedNbSameTsChan[ uXyterIdx ]->Draw( "colz" ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) -//====================================================================// - -//====================================================================// - TCanvas* cFebSameTsAdc = new TCanvas( "cFebSameTsAdc", - "Hodoscopes coincidence quality", - w, h); - - cFebSameTsAdc->Divide( 2, fuNbStsXyters/2 + fuNbStsXyters%2 ); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - cFebSameTsAdc->cd(1 + uXyterIdx ); - gPad->SetLogz(); - fhSetupSortedSameTsAdcChan[ uXyterIdx ]->Draw( "colz" ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) -//====================================================================// - -//====================================================================// - TCanvas* cFebDupliVsChan = new TCanvas( "cFebDupliVsChan", - "Hodoscopes coincidence quality", - w, h); - - cFebDupliVsChan->Divide( fuNbStsXyters, 3 ); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - cFebDupliVsChan->cd( 1 + uXyterIdx ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhSetupSortedNbConsSameTsChan[ uXyterIdx ]->Draw( "colz" ); - - cFebDupliVsChan->cd( 1 + fuNbStsXyters +uXyterIdx ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhSetupSortedNbConsSameTsAdcChan[ uXyterIdx ]->Draw( "colz" ); - - cFebDupliVsChan->cd( 1 + 2*fuNbStsXyters + uXyterIdx ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhSetupSortedNbConsSameTsVsTsAdc[ uXyterIdx ]->Draw( "colz" ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) -//====================================================================// - -//====================================================================// - TCanvas* cFebDupliVsRate = new TCanvas( "cFebDupliVsRate", - "Hodoscopes coincidence quality", - w, h); - - cFebDupliVsRate->Divide( fuNbStsXyters, 3 ); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - cFebDupliVsRate->cd( 1 + uXyterIdx ); -// gPad->SetGridx(); -// gPad->SetGridy(); - gPad->SetLogx(); - gPad->SetLogz(); - fhSetupSortedAsicRatioSameTsVsFlux[ uXyterIdx ]->Draw( "colz" ); - - cFebDupliVsRate->cd( 1 + fuNbStsXyters + uXyterIdx ); -// gPad->SetGridx(); -// gPad->SetGridy(); - gPad->SetLogx(); - gPad->SetLogz(); - fhSetupSortedAsicRatioSameTsAdcVsFlux[ uXyterIdx ]->Draw( "colz" ); - - cFebDupliVsRate->cd( 1 + 2*fuNbStsXyters + uXyterIdx ); -// gPad->SetGridx(); -// gPad->SetGridy(); - gPad->SetLogx(); - gPad->SetLogz(); - fhSetupSortedAsicRatioSameAdcSameTsVsFlux[ uXyterIdx ]->Draw( "colz" ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) -//====================================================================// - -//====================================================================// - TCanvas* cStsMapXY = new TCanvas( "cStsMapXY", - "Sts XY maps", - w, h); - if( kTRUE == fbDualStsEna ) - { - cStsMapXY->Divide( 2, 2 ); - } // if( kTRUE == fbDualStsEna ) - - cStsMapXY->cd(1); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhStsSortedMapS1->Draw( "colz" ); - - if( kTRUE == fbDualStsEna ) - { - cStsMapXY->cd(2); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhStsSortedMapS2->Draw( "colz" ); - - cStsMapXY->cd(3); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhStsSortedMapS1Coinc->Draw( "colz" ); - - cStsMapXY->cd(4); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhStsSortedMapS2Coinc->Draw( "colz" ); - } // if( kTRUE == fbDualStsEna ) -//====================================================================// - -//====================================================================// - TCanvas* cStsCuts = new TCanvas( "cStsCuts", - "Sts cuts maps", - w, h); - - cStsCuts->Divide( 6, 4 ); - - // Single Det pairs - cStsCuts->cd(1); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhMapBestPairsHodo_H1->Draw( "colz" ); - - cStsCuts->cd(7); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhMapBestPairsHodo_H2->Draw( "colz" ); - - cStsCuts->cd(13); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhMapBestPairsS1->Draw( "colz" ); - - cStsCuts->cd(19); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhMapBestPairsS2->Draw( "colz" ); - - // Hodo 1 maps with cuts - cStsCuts->cd(2); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhMapBestPairsHodoS1_H1->Draw( "colz" ); - - cStsCuts->cd(8); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhMapBestPairsHodoS2_H1->Draw( "colz" ); - - cStsCuts->cd(14); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhMapBestPairsHodoS1S2_H1->Draw( "colz" ); - - cStsCuts->cd(20); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhMapBestPairsHodoS2S1_H1->Draw( "colz" ); - - // Hodo 2 maps with cuts - cStsCuts->cd(3); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhMapBestPairsHodoS1_H2->Draw( "colz" ); - - cStsCuts->cd(9); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhMapBestPairsHodoS2_H2->Draw( "colz" ); - - cStsCuts->cd(15); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhMapBestPairsHodoS1S2_H2->Draw( "colz" ); - - cStsCuts->cd(21); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhMapBestPairsHodoS2S1_H2->Draw( "colz" ); - - // Sts maps with cuts - cStsCuts->cd(4); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhMapBestPairsHodoS1_S1->Draw( "colz" ); - - cStsCuts->cd(10); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhMapBestPairsHodoS2_S2->Draw( "colz" ); - - cStsCuts->cd(16); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhMapBestPairsHodoS1S2_S1->Draw( "colz" ); - - cStsCuts->cd(22); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhMapBestPairsHodoS2S1_S2->Draw( "colz" ); - - // Projections on STS sencsor plane - cStsCuts->cd(5); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhMapBestPairsHodoS1_Proj->Draw( "colz" ); - - cStsCuts->cd(11); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhMapBestPairsHodoS2_Proj->Draw( "colz" ); - - cStsCuts->cd(17); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhMapBestPairsHodoS1S2_Proj->Draw( "colz" ); - - cStsCuts->cd(23); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhMapBestPairsHodoS2S1_Proj->Draw( "colz" ); - - // Residuals - cStsCuts->cd(6); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhResidualsBestPairsHodoS1->Draw( "colz" ); - - cStsCuts->cd(12); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhResidualsBestPairsHodoS2->Draw( "colz" ); - - cStsCuts->cd(18); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhResidualsBestPairsHodoS1S2->Draw( "colz" ); - - cStsCuts->cd(24); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhResidualsBestPairsHodoS2S1->Draw( "colz" ); -//====================================================================// - -//====================================================================// - fcCanvasProjectionMaps = new TCanvas( "cProjMap", - "Hodo pairs projection in STS sensor plane maps", - w, h); - fcCanvasProjectionMaps->Divide( 3, 2 ); - - // S1 - fcCanvasProjectionMaps->cd(1); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhMapBestPairsHodo_ProjS1->Draw( "colz" ); - - fcCanvasProjectionMaps->cd(2); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhMapBestPairsHodoS1_Proj->Draw( "colz" ); - - fcCanvasProjectionMaps->cd(3); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhMapBestPairsHodoS1GeoCut_Proj->Draw( "colz" ); - - // S1 - fcCanvasProjectionMaps->cd(4); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhMapBestPairsHodo_ProjS2->Draw( "colz" ); - - fcCanvasProjectionMaps->cd(5); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhMapBestPairsHodoS2_Proj->Draw( "colz" ); - - fcCanvasProjectionMaps->cd(6); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhMapBestPairsHodoS2GeoCut_Proj->Draw( "colz" ); -//====================================================================// - -//====================================================================// - fcCanvasEfficiencyMaps = new TCanvas( "cEffMap", - "Sts Efficiency maps", - w, h); - fcCanvasEfficiencyMaps->Divide( 4, 2 ); - - // S1 - fcCanvasEfficiencyMaps->cd(1); - gPad->SetGridx(); - gPad->SetGridy(); - fhEfficiencyMapS1->Draw( "colz" ); - - fcCanvasEfficiencyMaps->cd(2); - gPad->SetGridx(); - gPad->SetGridy(); - fhEfficiencyMapS1GeoCut->Draw( "colz" ); - - fcCanvasEfficiencyMaps->cd(3); - gPad->SetGridx(); - gPad->SetGridy(); - fhEfficiencyMapS1S2->Draw( "colz" ); - - fcCanvasEfficiencyMaps->cd(4); - gPad->SetGridx(); - gPad->SetGridy(); - fhEfficiencyMapS1S2GeoCut->Draw( "colz" ); - - // S1 - fcCanvasEfficiencyMaps->cd(5); - gPad->SetGridx(); - gPad->SetGridy(); - fhEfficiencyMapS2->Draw( "colz" ); - - fcCanvasEfficiencyMaps->cd(6); - gPad->SetGridx(); - gPad->SetGridy(); - fhEfficiencyMapS2GeoCut->Draw( "colz" ); - - fcCanvasEfficiencyMaps->cd(7); - gPad->SetGridx(); - gPad->SetGridy(); - fhEfficiencyMapS2S1->Draw( "colz" ); - - fcCanvasEfficiencyMaps->cd(8); - gPad->SetGridx(); - gPad->SetGridy(); - fhEfficiencyMapS2S1GeoCut->Draw( "colz" ); -//====================================================================// - - /** Recovers/Create Ms Size Canvase for CERN 2016 **/ - // Try to recover canvas in case it was created already by another monitor - // If not existing, create it - fcMsSizeAll = dynamic_cast<TCanvas *>( gROOT->FindObject( "cMsSizeAll" ) ); - if( NULL == fcMsSizeAll ) - { - fcMsSizeAll = new TCanvas("cMsSizeAll", "Evolution of MS size in last 300 s", w, h); - fcMsSizeAll->Divide( 4, 4 ); - LOG(info) << "Created MS size canvas in STS monitor"; - } // if( NULL == fcMsSizeAll ) - else LOG(info) << "Recovered MS size canvas in STS monitor"; - - /*****************************/ -} - -Bool_t CbmCosy2018MonitorEfficiency::DoUnpack(const fles::Timeslice& ts, size_t component) -{ - THttpServer* server = FairRunOnline::Instance()->GetHttpServer(); - - if( bCosy2018ResetEfficiency ) - { - ResetAllHistos(); - bCosy2018ResetEfficiency = kFALSE; - } // if( bCosy2018ResetEfficiency ) - if( bCosy2018WriteEfficiency ) - { - SaveAllHistos( fsHistoFileFullname ); - bCosy2018WriteEfficiency = kFALSE; - } // if( bCosy2018WriteEfficiency ) - - LOG(debug) << "Timeslice contains " << ts.num_microslices(component) - << "microslices."; - - if( component < kiMaxNbFlibLinks ) - if( NULL == fhMsSz[ component ] ) - { - TString sMsSzName = Form("MsSz_link_%02lu", component); - TString sMsSzTitle = Form("Size of MS for nDPB of link %02lu; Ms Size [bytes]", component); - fhMsSz[ component ] = new TH1F( sMsSzName.Data(), sMsSzTitle.Data(), 160000, 0., 20000. ); - fHM->Add(sMsSzName.Data(), fhMsSz[ component ] ); - if (server) server->Register("/FlibRaw", fhMsSz[ component ] ); - sMsSzName = Form("MsSzTime_link_%02lu", component); - sMsSzTitle = Form("Size of MS vs time for gDPB of link %02lu; Time[s] ; Ms Size [bytes]", component); - fhMsSzTime[ component ] = new TProfile( sMsSzName.Data(), sMsSzTitle.Data(), 15000, 0., 300. ); - fHM->Add( sMsSzName.Data(), fhMsSzTime[ component ] ); - if (server) server->Register("/FlibRaw", fhMsSzTime[ component ] ); - if( NULL != fcMsSizeAll ) - { - fcMsSizeAll->cd( 1 + component ); - gPad->SetLogy(); - fhMsSzTime[ component ]->Draw("hist le0"); - } // if( NULL != fcMsSizeAll ) - LOG(info) << "Added MS size histo for component: " << component - << " (DPB)"; - } // if( NULL == fhMsSz[ component ] ) - -// Int_t messageType = -111; - // Loop over microslices - size_t numCompMsInTs = ts.num_microslices(component); -/* - if( fulCurrentTsIdx + 1 != ts.index() && 0 == component) - LOG(info) << "Missed TS from " << fulCurrentTsIdx - << " to " << ts.index(); -*/ - fulCurrentTsIdx = ts.index(); - - if( fuMaxNbMicroslices < numCompMsInTs ) - { - fuMaxNbMicroslices = numCompMsInTs; - - fvdMsTime.resize( fuMaxNbMicroslices ); - fvuChanNbHitsInMs.resize( fuNbStsXyters ); - fvdChanLastHitTimeInMs.resize( fuNbStsXyters ); - fvusChanLastHitAdcInMs.resize( fuNbStsXyters ); - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fvuChanNbHitsInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvdChanLastHitTimeInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvusChanLastHitAdcInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - { - fvuChanNbHitsInMs[ uXyterIdx ][ uChan ].resize( fuMaxNbMicroslices ); - fvdChanLastHitTimeInMs[ uXyterIdx ][ uChan ].resize( fuMaxNbMicroslices ); - fvusChanLastHitAdcInMs[ uXyterIdx ][ uChan ].resize( fuMaxNbMicroslices ); - for( UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx ) - { - fvuChanNbHitsInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = 0; - fvdChanLastHitTimeInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = -1.0; - fvusChanLastHitAdcInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = 0; - } // for( UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx ) - } // for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - LOG(info) << "CbmCosy2018MonitorEfficiency::DoUnpack => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs.size() << " VS " << fuNbStsXyters; - LOG(info) << "CbmCosy2018MonitorEfficiency::DoUnpack => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs[ 0 ].size() << " VS " << fuNbChanPerAsic; - LOG(info) << "CbmCosy2018MonitorEfficiency::DoUnpack => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs[ 0 ][ 0 ].size() << " VS " << fuMaxNbMicroslices; - } // if( fuMaxNbMicroslices < numCompMsInTs ) - - for( size_t m = 0; m < numCompMsInTs; ++m ) - { - // Ignore overlap ms if number defined by user - if( numCompMsInTs - fuOverlapMsNb <= m ) - continue; - - auto msDescriptor = ts.descriptor(component, m); - fuCurrentEquipmentId = msDescriptor.eq_id; - const uint8_t* msContent = reinterpret_cast<const uint8_t*>(ts.content(component, m)); - - uint32_t size = msDescriptor.size; - fulCurrentMsIdx = msDescriptor.idx; - Double_t dMsTime = (1e-9) * static_cast<double>(fulCurrentMsIdx); - LOG(debug) << "Microslice: " << fulCurrentMsIdx - << " from EqId " << std::hex << fuCurrentEquipmentId << std::dec - << " has size: " << size; - - fuCurrDpbId = static_cast< uint32_t >( fuCurrentEquipmentId & 0xFFFF ); - fuCurrDpbIdx = fDpbIdIndexMap[ fuCurrDpbId ]; - - if( component < kiMaxNbFlibLinks ) - { - if( fdStartTimeMsSz < 0 ) - fdStartTimeMsSz = dMsTime; - fhMsSz[ component ]->Fill( size ); - fhMsSzTime[ component ]->Fill( dMsTime - fdStartTimeMsSz, size); - } // if( component < kiMaxNbFlibLinks ) - - // Store MS time for coincidence plots - fvdMsTime[ m ] = dMsTime; - - // If not integer number of message in input buffer, print warning/error - if( 0 != (size % kuBytesPerMessage) ) - LOG(error) << "The input microslice buffer does NOT " - << "contain only complete nDPB messages!"; - - // Compute the number of complete messages in the input microslice buffer - uint32_t uNbMessages = (size - (size % kuBytesPerMessage) ) - / kuBytesPerMessage; - - // Prepare variables for the loop on contents - const uint32_t* pInBuff = reinterpret_cast<const uint32_t*>( msContent ); - - for( uint32_t uIdx = 0; uIdx < uNbMessages; ++uIdx ) - { - // Fill message - uint32_t ulData = static_cast<uint32_t>(pInBuff[uIdx]); - - stsxyter::Message mess( static_cast< uint32_t >( ulData & 0xFFFFFFFF ) ); - - // Print message if requested - if( fbPrintMessages ) - mess.PrintMess( std::cout, fPrintMessCtrl ); - - stsxyter::MessType typeMess = mess.GetMessType(); - fmMsgCounter[ typeMess ] ++; - - fhHodoMessType->Fill( static_cast< uint16_t > (typeMess) ); - fhHodoMessTypePerDpb->Fill( fuCurrDpbIdx, static_cast< uint16_t > (typeMess) ); - - switch( typeMess ) - { - case stsxyter::MessType::Hit : - { - // Extract the eLink and Asic indices => Should GO IN the fill method now that obly hits are link/asic specific! - UShort_t usElinkIdx = mess.GetLinkIndex(); - if( fuNbElinksPerDpb <= usElinkIdx ) - { - LOG(fatal) << "CbmCosy2018MonitorEfficiency::DoUnpack => " - << "eLink index out of bounds!" - << usElinkIdx << " VS " << fuNbElinksPerDpb; - } // if( fuNbElinksPerDpb <= usElinkIdx ) - fhHodoMessTypePerElink->Fill( fuCurrDpbIdx * fuNbElinksPerDpb + usElinkIdx, - static_cast< uint16_t > (typeMess) ); - - UInt_t uAsicIdx = fvuElinkToAsic[fuCurrDpbIdx][usElinkIdx]; - - FillHitInfo( mess, usElinkIdx, uAsicIdx, m ); - break; - } // case stsxyter::MessType::Hit : - case stsxyter::MessType::TsMsb : - { - FillTsMsbInfo( mess, uIdx, m ); - break; - } // case stsxyter::MessType::TsMsb : - case stsxyter::MessType::Epoch : - { - // The first message in the TS is a special ones: EPOCH - FillEpochInfo( mess ); - - if( 0 < uIdx ) - LOG(info) << "CbmCosy2018MonitorEfficiency::DoUnpack => " - << "EPOCH message at unexpected position in MS: message " - << uIdx << " VS message 0 expected!"; - break; - } // case stsxyter::MessType::TsMsb : - case stsxyter::MessType::Empty : - { -// FillTsMsbInfo( mess ); - break; - } // case stsxyter::MessType::Empty : - case stsxyter::MessType::Dummy : - { - break; - } // case stsxyter::MessType::Dummy / ReadDataAck / Ack : - default: - { - LOG(fatal) << "CbmCosy2018MonitorEfficiency::DoUnpack => " - << "Unknown message type, should never happen, stopping here!"; - } - } // switch( mess.GetMessType() ) - } // for( uint32_t uIdx = 0; uIdx < uNbMessages; ++uIdx ) - - // Sort the buffer of hits - std::sort( fvmHitsInTs.begin(), fvmHitsInTs.end() ); - - // Time differences plotting using the fully time sorted hits - Double_t dLastTimeX1 = -1e12; - Double_t dLastTimeY1 = -1e12; - Double_t dLastTimeX2 = -1e12; - Double_t dLastTimeY2 = -1e12; - Double_t dLastTimeN1 = -1e12; - Double_t dLastTimeP1 = -1e12; - Double_t dLastTimeN2 = -1e12; - Double_t dLastTimeP2 = -1e12; - Double_t dDtX1Y1 = -1e12; - Double_t dDtX2Y2 = -1e12; - Double_t dDtN1P1 = -1e12; - Double_t dDtN2P2 = -1e12; - Double_t dDtX1Y1X2Y2 = -1e12; - Double_t dDtN1P1N2P2 = -1e12; - Double_t dDtX1Y1X2Y2N1P1 = -1e12; - Double_t dDtX1Y1X2Y2N2P2 = -1e12; - Double_t dDtH1H2S1S2 = -1e12; - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - fvbAsicHasDuplicInMs[ uXyterIdx ] = kFALSE; - Bool_t bDuplicatedHitsInMs = kFALSE; - if( 0 < fvmHitsInTs.size() ) - { - ULong64_t ulLastHitTime = ( *( fvmHitsInTs.rbegin() ) ).GetTs(); - std::vector< stsxyter::FinalHit >::iterator it; - -// std::chrono::steady_clock::time_point tNow = std::chrono::steady_clock::now(); -// Double_t dUnixTimeInRun = std::chrono::duration_cast< std::chrono::seconds >(tNow - ftStartTimeUnix).count(); - - for( it = fvmHitsInTs.begin(); - it != fvmHitsInTs.end() && (*it).GetTs() < ulLastHitTime - 320; // 320 * 3.125 ns = 1000 ns - ++it ) - { - UShort_t usAsicIdx = (*it).GetAsic(); - UShort_t usChanIdx = (*it).GetChan(); - ULong64_t ulHitTs = (*it).GetTs(); - UShort_t usHitAdc = (*it).GetAdc(); - -// Bool_t bHitInX = usChanIdx < fuNbChanPerAsic/2; - - Double_t dTimeSinceStartSec = (ulHitTs * stsxyter::kdClockCycleNs - fdStartTime)* 1e-9; - if( 0 == ulHitTs - fvulTimeLastHitAsicChan[ usAsicIdx ][ usChanIdx ] || - ( 0 < fvuNbSameFullHitAsicChan[ usAsicIdx ][ usChanIdx ] && - 0 == ( ulHitTs - fvulTimeLastHitAsicChan[ usAsicIdx ][ usChanIdx ] ) % 512 ) ) - { - if( 0 == fviAdcLastHitAsicChan[ usAsicIdx ][ usChanIdx ] - usHitAdc ) - { - fvuNbSameFullHitAsicChan[ usAsicIdx ][ usChanIdx ] ++; - fvuNbHitSameTsAdcAsicLastS[ usAsicIdx ] ++; - } // if( 0 == fviAdcLastHitAsicChan[ usAsicIdx ][ usChanIdx ] - usHitAdc ) - else - { - fhSetupSortedNbConsSameTsAdcChan[ usAsicIdx ]->Fill( usChanIdx, fvuNbSameFullHitAsicChan[ usAsicIdx ][ usChanIdx ] ); - fhSetupSortedNbConsSameTsVsTsAdc[ usAsicIdx ]->Fill( fvuNbSameHitAsicChan[ usAsicIdx ][ usChanIdx ], - fvuNbSameFullHitAsicChan[ usAsicIdx ][ usChanIdx ] ); - fvuNbSameFullHitAsicChan[ usAsicIdx ][ usChanIdx ] = 0; - } // else of if( 0 == fviAdcLastHitAsicChan[ usAsicIdx ][ usChanIdx ] - usHitAdc ) - - fvuNbSameHitAsicChan[ usAsicIdx ][ usChanIdx ] ++; - fvuNbHitSameTsAsicLastS[ usAsicIdx ] ++; -/* - LOG(info) << Form("Bad Hit on asic %u chan %3u, #%3u => TS %9llu ADC %2u VS TS %9llu ADC %2u", - usAsicIdx, usChanIdx, fvuNbSameHitAsicChan[ usAsicIdx ][ usChanIdx ], - ulHitTs, usHitAdc, - fvulTimeLastHitAsicChan[ usAsicIdx ][ usChanIdx ], - fviAdcLastHitAsicChan[ usAsicIdx ][ usChanIdx ] ); -*/ - fhSetupSortedNbSameTsChan[ usAsicIdx ]->Fill( dTimeSinceStartSec, usChanIdx ); - fhSetupSortedSameTsAdcChan[ usAsicIdx ]->Fill( usChanIdx, usHitAdc ); - fhSetupSortedSameTsAdcChan[ usAsicIdx ]->Fill( usChanIdx, fviAdcLastHitAsicChan[ usAsicIdx ][ usChanIdx ] ); - fhSetupSortedSameTsAdcDiff[ usAsicIdx ]->Fill( fvuNbSameHitAsicChan[ usAsicIdx ][ usChanIdx ], - static_cast< Int_t >( usHitAdc ) - - fviAdcLastHitAsicChan[ usAsicIdx ][ usChanIdx ] ); - fhSetupSortedRatioSameTsChan[ usAsicIdx ]->Fill( dTimeSinceStartSec, usChanIdx, 1.0 ); - - /// Jump the duplicated hits without updating the othe variables - fvbAsicHasDuplicInMs[ usAsicIdx ] = kTRUE; - bDuplicatedHitsInMs = kTRUE; - continue; - } // if( 0 == ulHitTs - fvulTimeLastHitAsicChan[ usAsicIdx ][ usChanIdx ] ) - else - { -/* - if( 100 < fvuNbSameHitAsicChan[ usAsicIdx ][ usChanIdx ] ) - LOG(fatal) << " More than 100 consecutive hits with same TS on asic" - << usAsicIdx << " chan " << usChanIdx - << " => " << fvuNbSameHitAsicChan[ usAsicIdx ][ usChanIdx ]; -*/ - fhSetupSortedNbConsSameTsVsTsAdc[ usAsicIdx ]->Fill( fvuNbSameHitAsicChan[ usAsicIdx ][ usChanIdx ], - fvuNbSameFullHitAsicChan[ usAsicIdx ][ usChanIdx ] ); - - fhSetupSortedNbConsSameTsChan[ usAsicIdx ]->Fill( usChanIdx, fvuNbSameHitAsicChan[ usAsicIdx ][ usChanIdx ] ); - fvuNbSameHitAsicChan[ usAsicIdx ][ usChanIdx ] = 0; - - fhSetupSortedNbConsSameTsAdcChan[ usAsicIdx ]->Fill( usChanIdx, fvuNbSameFullHitAsicChan[ usAsicIdx ][ usChanIdx ] ); - fvuNbSameFullHitAsicChan[ usAsicIdx ][ usChanIdx ] = 0; - - fhSetupSortedRatioSameTsChan[ usAsicIdx ]->Fill( dTimeSinceStartSec, usChanIdx, 0.0 ); - - fvuNbHitDiffTsAsicLastS[ usAsicIdx ]++; - } // else of if( 0 == ulHitTs - fvulTimeLastHitAsicChan[ usAsicIdx ][ usChanIdx ] ) - fvulTimeLastHitAsicChan[ usAsicIdx ][ usChanIdx ] = ulHitTs; - fviAdcLastHitAsicChan[ usAsicIdx ][ usChanIdx ] = usHitAdc; - } // loop on hits untils hits within 100 ns of last one or last one itself are reached - - // Remove all hits in case some duplicated ones where found - if( kTRUE == bDuplicatedHitsInMs ) - fvmHitsInTs.erase( fvmHitsInTs.begin(), fvmHitsInTs.end() ); - else fhSizeCleanMs->Fill( fvmHitsInTs.size() ); - - std::vector< stsxyter::FinalHit >::iterator itFirstMatchY1 = fvmHitsInTs.begin(); - std::vector< stsxyter::FinalHit >::iterator itFirstMatchY2 = fvmHitsInTs.begin(); - std::vector< stsxyter::FinalHit >::iterator itFirstMatchP1 = fvmHitsInTs.begin(); - std::vector< stsxyter::FinalHit >::iterator itFirstMatchP2 = fvmHitsInTs.begin(); - for( it = fvmHitsInTs.begin(); - it != fvmHitsInTs.end() && (*it).GetTs() < ulLastHitTime - 320; // 320 * 3.125 ns = 1000 ns - ++it ) - { - UShort_t usAsicIdx = (*it).GetAsic(); - UShort_t usChanIdx = (*it).GetChan(); - ULong64_t ulHitTs = (*it).GetTs(); -// UShort_t usHitAdc = (*it).GetAdc(); - - fhHodoChanCntRawGood[usAsicIdx]->Fill(usChanIdx); - - Bool_t bHitInX = usChanIdx < fuNbChanPerAsic/2; - - Double_t dTimeSinceStartSec = (ulHitTs * stsxyter::kdClockCycleNs - fdStartTime)* 1e-9; - if( fUnpackParHodo->GetAsicIndexHodo1() == usAsicIdx ) - { - if( fUnpackParHodo->IsXySwappedHodo1() ) - bHitInX = !bHitInX; - - if( bHitInX ) - { - Double_t dDtSameFeb = ( ulHitTs - dLastTimeX1 ) * stsxyter::kdClockCycleNs; - fhSetupSortedDtX1->Fill( dDtSameFeb ); - - fLastSortedHit1X = (*it); - dLastTimeX1 = ulHitTs; - - /// Compute fiber Idx of the last Hodo hits - UInt_t uFiberIdxX1 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit1X.GetChan() ); - if( fUnpackParHodo->IsXInvertedHodo1() ) - uFiberIdxX1 = fuNbChanPerAsic/2 - 1 - uFiberIdxX1; - UInt_t uFiberIdxY1 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit1Y.GetChan() ); - if( fUnpackParHodo->IsYInvertedHodo1() ) - uFiberIdxY1 = fuNbChanPerAsic/2 - 1 - uFiberIdxY1; - UInt_t uFiberIdxX2 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit2X.GetChan() ); - if( fUnpackParHodo->IsXInvertedHodo2() ) - uFiberIdxX2 = fuNbChanPerAsic/2 - 1 - uFiberIdxX2; - UInt_t uFiberIdxY2 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit2Y.GetChan() ); - if( fUnpackParHodo->IsYInvertedHodo2() ) - uFiberIdxY2 = fuNbChanPerAsic/2 - 1 - uFiberIdxY2; - - if( dTimeSinceStartSec < fdSpillEvoLength ) - { - fhHodoX1SpillEvo->Fill( dTimeSinceStartSec, uFiberIdxX1 ); - fhHodoX1SpillEvoProf->Fill( dTimeSinceStartSec, uFiberIdxX1 ); - } // if( dTimeSinceStartSec < fdSpillEvoLength ) - - dDtX1Y1 = ( dLastTimeY1 - dLastTimeX1 ) * stsxyter::kdClockCycleNs; - dDtX2Y2 = ( dLastTimeY2 - dLastTimeX2 ) * stsxyter::kdClockCycleNs; - dDtN1P1 = ( dLastTimeP1 - dLastTimeN1 ) * stsxyter::kdClockCycleNs; - dDtX1Y1X2Y2 = ( ( dLastTimeX2 + dLastTimeY2 ) - ( dLastTimeX1 + dLastTimeY1 ) ) - * stsxyter::kdClockCycleNs / 2.0; - dDtX1Y1X2Y2N1P1 = ( ( dLastTimeN1 + dLastTimeP1 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) / 4.0 - ) * stsxyter::kdClockCycleNs; - if( kTRUE == fbDualStsEna ) - { - dDtN2P2 = ( dLastTimeP2 - dLastTimeN2 ) * stsxyter::kdClockCycleNs; - dDtN1P1N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) - ( dLastTimeN1 + dLastTimeP1 ) ) - * stsxyter::kdClockCycleNs / 2.0; - dDtX1Y1X2Y2N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) / 4.0 - ) * stsxyter::kdClockCycleNs; - dDtH1H2S1S2 = ( ( dLastTimeN2 + dLastTimeP2 + dLastTimeN1 + dLastTimeP1 ) - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) - ) * stsxyter::kdClockCycleNs / 4.0; - } // if( kTRUE == fbDualStsEna ) - - fhSetupSortedDtX1Y1->Fill( dDtX1Y1 ); - fhSetupSortedDtX1Y1X2Y2->Fill( dDtX1Y1X2Y2 ); - fhSetupSortedDtX1Y1X2Y2N1P1->Fill( dDtX1Y1X2Y2N1P1 ); - if( kTRUE == fbDualStsEna ) - { - fhSetupSortedDtX1Y1X2Y2N2P2->Fill( dDtX1Y1X2Y2N2P2 ); - fhSetupSortedDtH1H2S1S2->Fill( dDtH1H2S1S2 ); - } // if( kTRUE == fbDualStsEna ) - - if( fdCoincMinHodo < dDtX1Y1 && dDtX1Y1 < fdCoincMaxHodo ) - { - fhSetupSortedMapX1Y1->Fill( uFiberIdxX1, uFiberIdxY1 ); - fhSetupSortedCntEvoX1Y1->Fill( dTimeSinceStartSec ); - } // if( fdCoincMinHodo < dDtX1Y1 && dDtX1Y1 < fdCoincMaxHodo ) - - /// Multiplicity estimation - UInt_t uNbY1CoincPerX1 = 0; - Double_t dDtHodo1 = 1e12; - Double_t dDtBestPair = 1e12; - std::vector< stsxyter::FinalHit >::iterator itBestY1 = fvmHitsInTs.end(); - for( std::vector< stsxyter::FinalHit >::iterator itY1 = itFirstMatchY1; itY1 != fvmHitsInTs.end(); ++itY1 ) - { - Bool_t bHitInY1 = ( (*itY1).GetChan() >= fuNbChanPerAsic/2 ) != fUnpackParHodo->IsXySwappedHodo1(); - - if( fUnpackParHodo->GetAsicIndexHodo1() == (*itY1).GetAsic() && bHitInY1 ) - { - dDtHodo1 = ( static_cast< Double_t >( (*itY1).GetTs() ) - static_cast< Double_t >( (*it).GetTs() ) - ) * stsxyter::kdClockCycleNs; - if( fdCoincMinHodo < dDtHodo1 ) - { - if( dDtHodo1 < fdCoincMaxHodo ) - { - uNbY1CoincPerX1 ++; - if( TMath::Abs( dDtHodo1 - fdCoincCenterHodo ) < dDtBestPair ) - { - itBestY1 = itY1; - dDtBestPair = TMath::Abs( dDtHodo1 - fdCoincCenterHodo ); - } // if( TMath::Abs( dDtHodo1 - fdCoincCenterHodo ) < dDtBestPair ) - } // if( dDtHodo1 < fdCoincMaxHodo ) - else break; - } // if( fdCoincMinHodo < dDtHodo1 ) - else itFirstMatchY1 = itY1; - } // if( fUnpackParHodo->GetAsicIndexHodo1() == (*itY1).GetAsic() && bHitInY1 ) - } // for( itY1 = itFirstMatchY1; itY1 != fvmHitsInTs.end(); ++itY1 ) - if( 0 < uNbY1CoincPerX1 ) - { - fvPairsH1.push_back( std::pair< stsxyter::FinalHit, stsxyter::FinalHit >( (*it), (*itBestY1) ) ); - - fhDtBestPairsH1->Fill( ( static_cast< Double_t >( (*itBestY1).GetTs() ) - static_cast< Double_t >( (*it).GetTs() ) - ) * stsxyter::kdClockCycleNs ); - - Double_t dPosX, dPosY; - ComputeCoordinatesHodo1( (*it).GetChan(), (*itBestY1).GetChan(), dPosX, dPosY ); - fhMapBestPairsH1->Fill( dPosX, dPosY ); - } // if( 0 < uNbY1CoincPerX1 ) - fhNbY1CoincPerX1->Fill( uNbY1CoincPerX1 ); - - ///++++++++ Adrian ADC analysis, to be moved in other class! +++++/// - if( 0 < uFiberIdxX1 ) - { - Double_t dDtPrevChan = ( static_cast< Double_t >( (*it).GetTs() ) - static_cast< Double_t >( fvLastHitChanH1X[ uFiberIdxX1 - 1].GetTs() ) - ) * stsxyter::kdClockCycleNs; - - fhDtNeighborChansH1X->Fill( dDtPrevChan, uFiberIdxX1 - 1 ); - } // if( 0 < (*it).GetChan() ) - if( uFiberIdxX1 < fuNbChanPerAsic/2 - 1 ) - { - Double_t dDtNextChan = ( static_cast< Double_t >( fvLastHitChanH1X[ uFiberIdxX1 + 1 ].GetTs() ) - static_cast< Double_t >( (*it).GetTs() ) - ) * stsxyter::kdClockCycleNs; - - fhDtNeighborChansH1X->Fill( dDtNextChan, uFiberIdxX1 ); - } // if( 0 < (*it).GetChan() ) - - fvLastHitChanH1X[ uFiberIdxX1 ] = (*it); - - Bool_t bFoundCluster = kFALSE; - for( UInt_t uCluster = 0; uCluster < fvClustersH1X.size(); ++uCluster ) - { - if( kTRUE == fvClustersH1X[ uCluster ].CheckAddHit( (*it) ) ) - { - bFoundCluster = kTRUE; - break; - } // if( kTRUE == fvClustersH1X[ uCluster ].CheckAddHit( (*it) ) ) - } // for( UInt_t uCluster = 0; uCluster < fvClustersH1X.size(); ++uCluster ) - if( kFALSE == bFoundCluster ) - { - Cosy2018TestCluster newClust( (*it) ); - fvClustersH1X.push_back( newClust ); - } // if( kFALSE == bFoundCluster ) - ///+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - } // if( bHitInX ) - else - { - Double_t dDtSameFeb = ( ulHitTs - dLastTimeY1 ) * stsxyter::kdClockCycleNs; - fhSetupSortedDtY1->Fill( dDtSameFeb ); - - fLastSortedHit1Y = (*it); - dLastTimeY1 = ulHitTs; - - /// Compute fiber Idx of the last Hodo hits - UInt_t uFiberIdxX1 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit1X.GetChan() ); - if( fUnpackParHodo->IsXInvertedHodo1() ) - uFiberIdxX1 = fuNbChanPerAsic/2 - 1 - uFiberIdxX1; - UInt_t uFiberIdxY1 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit1Y.GetChan() ); - if( fUnpackParHodo->IsYInvertedHodo1() ) - uFiberIdxY1 = fuNbChanPerAsic/2 - 1 - uFiberIdxY1; - UInt_t uFiberIdxX2 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit2X.GetChan() ); - if( fUnpackParHodo->IsXInvertedHodo2() ) - uFiberIdxX2 = fuNbChanPerAsic/2 - 1 - uFiberIdxX2; - UInt_t uFiberIdxY2 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit2Y.GetChan() ); - if( fUnpackParHodo->IsYInvertedHodo2() ) - uFiberIdxY2 = fuNbChanPerAsic/2 - 1 - uFiberIdxY2; - - if( dTimeSinceStartSec < fdSpillEvoLength ) - { - fhHodoY1SpillEvo->Fill( dTimeSinceStartSec, uFiberIdxY1 ); - fhHodoY1SpillEvoProf->Fill( dTimeSinceStartSec, uFiberIdxY1 ); - } // if( dTimeSinceStartSec < fdSpillEvoLength ) - - dDtX1Y1 = ( dLastTimeY1 - dLastTimeX1 ) * stsxyter::kdClockCycleNs; - dDtX2Y2 = ( dLastTimeY2 - dLastTimeX2 ) * stsxyter::kdClockCycleNs; - dDtN1P1 = ( dLastTimeP1 - dLastTimeN1 ) * stsxyter::kdClockCycleNs; - dDtX1Y1X2Y2 = ( ( dLastTimeX2 + dLastTimeY2 ) - ( dLastTimeX1 + dLastTimeY1 ) ) - * stsxyter::kdClockCycleNs / 2.0; - dDtX1Y1X2Y2N1P1 = ( ( dLastTimeN1 + dLastTimeP1 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) / 4.0 - ) * stsxyter::kdClockCycleNs; - if( kTRUE == fbDualStsEna ) - { - dDtN2P2 = ( dLastTimeP2 - dLastTimeN2 ) * stsxyter::kdClockCycleNs; - dDtN1P1N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) - ( dLastTimeN1 + dLastTimeP1 ) ) - * stsxyter::kdClockCycleNs / 2.0; - dDtX1Y1X2Y2N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) / 4.0 - ) * stsxyter::kdClockCycleNs; - dDtH1H2S1S2 = ( ( dLastTimeN2 + dLastTimeP2 + dLastTimeN1 + dLastTimeP1 ) - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) - ) * stsxyter::kdClockCycleNs / 4.0; - } // if( kTRUE == fbDualStsEna ) - - fhSetupSortedDtX1Y1->Fill( dDtX1Y1 ); - fhSetupSortedDtX1Y1X2Y2->Fill( dDtX1Y1X2Y2 ); - fhSetupSortedDtX1Y1X2Y2N1P1->Fill( dDtX1Y1X2Y2N1P1 ); - if( kTRUE == fbDualStsEna ) - { - fhSetupSortedDtX1Y1X2Y2N2P2->Fill( dDtX1Y1X2Y2N2P2 ); - fhSetupSortedDtH1H2S1S2->Fill( dDtH1H2S1S2 ); - } // if( kTRUE == fbDualStsEna ) - - if( fdCoincMinHodo < dDtX1Y1 && dDtX1Y1 < fdCoincMaxHodo ) - { - fhSetupSortedMapX1Y1->Fill( uFiberIdxX1, uFiberIdxY1 ); - fhSetupSortedCntEvoX1Y1->Fill( dTimeSinceStartSec ); - } // if( fdCoincMinHodo < dDtX1Y1 && dDtX1Y1 < fdCoincMaxHodo ) - - ///++++++++ Adrian ADC analysis, to be moved in other class! +++++/// - if( 0 < uFiberIdxY1 ) - { - Double_t dDtPrevChan = ( static_cast< Double_t >( (*it).GetTs() ) - static_cast< Double_t >( fvLastHitChanH1Y[ uFiberIdxY1 - 1].GetTs() ) - ) * stsxyter::kdClockCycleNs; - - fhDtNeighborChansH1Y->Fill( dDtPrevChan, uFiberIdxY1 - 1 ); - } // if( 0 < (*it).GetChan() ) - if( uFiberIdxY1 < fuNbChanPerAsic/2 - 1 ) - { - Double_t dDtNextChan = ( static_cast< Double_t >( fvLastHitChanH1Y[ uFiberIdxY1 + 1 ].GetTs() ) - static_cast< Double_t >( (*it).GetTs() ) - ) * stsxyter::kdClockCycleNs; - - fhDtNeighborChansH1Y->Fill( dDtNextChan, uFiberIdxY1 ); - } // if( 0 < (*it).GetChan() ) - - fvLastHitChanH1Y[ uFiberIdxY1 ] = (*it); - - Bool_t bFoundCluster = kFALSE; - for( UInt_t uCluster = 0; uCluster < fvClustersH1Y.size(); ++uCluster ) - { - if( kTRUE == fvClustersH1Y[ uCluster ].CheckAddHit( (*it) ) ) - { - bFoundCluster = kTRUE; - break; - } // if( kTRUE == fvClustersH1Y[ uCluster ].CheckAddHit( (*it) ) ) - } // for( UInt_t uCluster = 0; uCluster < fvClustersH1Y.size(); ++uCluster ) - if( kFALSE == bFoundCluster ) - { - Cosy2018TestCluster newClust( (*it) ); - fvClustersH1Y.push_back( newClust ); - } // if( kFALSE == bFoundCluster ) - ///+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - } // else of if( bHitInX ) - } // if( fUnpackParHodo->GetAsicIndexHodo1() == usAsicIdx ) - else if( fUnpackParHodo->GetAsicIndexHodo2() == usAsicIdx ) - { - if( fUnpackParHodo->IsXySwappedHodo2() ) - bHitInX = !bHitInX; - - if( bHitInX ) - { - Double_t dDtSameFeb = ( ulHitTs - dLastTimeX2 ) * stsxyter::kdClockCycleNs; - fhSetupSortedDtX2->Fill( dDtSameFeb ); - - fLastSortedHit2X = (*it); - dLastTimeX2 = ulHitTs; - - /// Compute fiber Idx of the last Hodo hits - UInt_t uFiberIdxX1 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit1X.GetChan() ); - if( fUnpackParHodo->IsXInvertedHodo1() ) - uFiberIdxX1 = fuNbChanPerAsic/2 - 1 - uFiberIdxX1; - UInt_t uFiberIdxY1 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit1Y.GetChan() ); - if( fUnpackParHodo->IsYInvertedHodo1() ) - uFiberIdxY1 = fuNbChanPerAsic/2 - 1 - uFiberIdxY1; - UInt_t uFiberIdxX2 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit2X.GetChan() ); - if( fUnpackParHodo->IsXInvertedHodo2() ) - uFiberIdxX2 = fuNbChanPerAsic/2 - 1 - uFiberIdxX2; - UInt_t uFiberIdxY2 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit2Y.GetChan() ); - if( fUnpackParHodo->IsYInvertedHodo2() ) - uFiberIdxY2 = fuNbChanPerAsic/2 - 1 - uFiberIdxY2; - - if( dTimeSinceStartSec < fdSpillEvoLength ) - { - fhHodoX2SpillEvo->Fill( dTimeSinceStartSec, uFiberIdxX2 ); - fhHodoX2SpillEvoProf->Fill( dTimeSinceStartSec, uFiberIdxX2 ); - } // if( dTimeSinceStartSec < fdSpillEvoLength ) - - dDtX1Y1 = ( dLastTimeY1 - dLastTimeX1 ) * stsxyter::kdClockCycleNs; - dDtX2Y2 = ( dLastTimeY2 - dLastTimeX2 ) * stsxyter::kdClockCycleNs; - dDtN1P1 = ( dLastTimeP1 - dLastTimeN1 ) * stsxyter::kdClockCycleNs; - dDtX1Y1X2Y2 = ( ( dLastTimeX2 + dLastTimeY2 ) - ( dLastTimeX1 + dLastTimeY1 ) ) - * stsxyter::kdClockCycleNs / 2.0; - dDtX1Y1X2Y2N1P1 = ( ( dLastTimeN1 + dLastTimeP1 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) / 4.0 - ) * stsxyter::kdClockCycleNs; - if( kTRUE == fbDualStsEna ) - { - dDtN2P2 = ( dLastTimeP2 - dLastTimeN2 ) * stsxyter::kdClockCycleNs; - dDtN1P1N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) - ( dLastTimeN1 + dLastTimeP1 ) ) - * stsxyter::kdClockCycleNs / 2.0; - dDtX1Y1X2Y2N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) / 4.0 - ) * stsxyter::kdClockCycleNs; - dDtH1H2S1S2 = ( ( dLastTimeN2 + dLastTimeP2 + dLastTimeN1 + dLastTimeP1 ) - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) - ) * stsxyter::kdClockCycleNs / 4.0; - } // if( kTRUE == fbDualStsEna ) - - fhSetupSortedDtX2Y2->Fill( dDtX2Y2 ); - fhSetupSortedDtX1Y1X2Y2->Fill( dDtX1Y1X2Y2 ); - fhSetupSortedDtX1Y1X2Y2N1P1->Fill( dDtX1Y1X2Y2N1P1 ); - if( kTRUE == fbDualStsEna ) - { - fhSetupSortedDtX1Y1X2Y2N2P2->Fill( dDtX1Y1X2Y2N2P2 ); - fhSetupSortedDtH1H2S1S2->Fill( dDtH1H2S1S2 ); - } // if( kTRUE == fbDualStsEna ) - - if( fdCoincMinHodo < dDtX2Y2 && dDtX2Y2 < fdCoincMaxHodo ) - { - fhSetupSortedMapX2Y2->Fill( uFiberIdxX2, uFiberIdxY2 ); - fhSetupSortedCntEvoX2Y2->Fill( dTimeSinceStartSec ); - } // if( fdCoincMinHodo < dDtX2Y2 && dDtX2Y2 < fdCoincMaxHodo ) - - /// Multiplicity estimation - UInt_t uNbY2CoincPerX2 = 0; - Double_t dDtHodo2 = 1e12; - Double_t dDtBestPair = 1e12; - std::vector< stsxyter::FinalHit >::iterator itBestY2 = fvmHitsInTs.end(); - for( std::vector< stsxyter::FinalHit >::iterator itY2 = itFirstMatchY2; itY2 != fvmHitsInTs.end(); ++itY2 ) - { - Bool_t bHitInY2 = ( (*itY2).GetChan() >= fuNbChanPerAsic/2 ) != fUnpackParHodo->IsXySwappedHodo2(); - - if( fUnpackParHodo->GetAsicIndexHodo2() == (*itY2).GetAsic() && bHitInY2 ) - { - dDtHodo2 = ( static_cast< Double_t >( (*itY2).GetTs() ) - static_cast< Double_t >( (*it).GetTs() ) - ) * stsxyter::kdClockCycleNs; - if( fdCoincMinHodo < dDtHodo2 ) - { - if( dDtHodo2 < fdCoincMaxHodo ) - { - uNbY2CoincPerX2 ++; - if( TMath::Abs( dDtHodo2 - fdCoincCenterHodo ) < dDtBestPair ) - { - itBestY2 = itY2; - dDtBestPair = TMath::Abs( dDtHodo2 - fdCoincCenterHodo ); - } // if( TMath::Abs( dDtHodo2 - fdCoincCenterHodo ) < dDtBestPair ) - } // if( dDtHodo2 < fdCoincMaxHodo ) - else break; - } // if( fdCoincMinHodo < dDtHodo2 ) - else itFirstMatchY2 = itY2; - } // if( fUnpackParHodo->GetAsicIndexHodo2() == (*itY2).GetAsic() && bHitInY2 ) - } // for( itY2 = itFirstMatchY1; itY2 != fvmHitsInTs.end(); ++itY2 ) - if( 0 < uNbY2CoincPerX2 ) - { - fvPairsH2.push_back( std::pair< stsxyter::FinalHit, stsxyter::FinalHit >( (*it), (*itBestY2) ) ); - - fhDtBestPairsH2->Fill( ( static_cast< Double_t >( (*itBestY2).GetTs() ) - static_cast< Double_t >( (*it).GetTs() ) - ) * stsxyter::kdClockCycleNs ); - - Double_t dPosX, dPosY; - ComputeCoordinatesHodo2( (*it).GetChan(), (*itBestY2).GetChan(), dPosX, dPosY ); - fhMapBestPairsH2->Fill( dPosX, dPosY ); - } // if( 0 < uNbY2CoincPerX2 ) - fhNbY2CoincPerX2->Fill( uNbY2CoincPerX2 ); - - ///++++++++ Adrian ADC analysis, to be moved in other class! +++++/// - if( 0 < uFiberIdxX2 ) - { - Double_t dDtPrevChan = ( static_cast< Double_t >( (*it).GetTs() ) - static_cast< Double_t >( fvLastHitChanH2X[ uFiberIdxX2 - 1].GetTs() ) - ) * stsxyter::kdClockCycleNs; - - fhDtNeighborChansH2X->Fill( dDtPrevChan, uFiberIdxX2 - 1 ); - } // if( 0 < (*it).GetChan() ) - if( uFiberIdxX2 < fuNbChanPerAsic/2 - 1 ) - { - Double_t dDtNextChan = ( static_cast< Double_t >( fvLastHitChanH2X[ uFiberIdxX2 + 1 ].GetTs() ) - static_cast< Double_t >( (*it).GetTs() ) - ) * stsxyter::kdClockCycleNs; - - fhDtNeighborChansH2X->Fill( dDtNextChan, uFiberIdxX2 ); - } // if( 0 < (*it).GetChan() ) - - fvLastHitChanH2X[ uFiberIdxX2 ] = (*it); - - Bool_t bFoundCluster = kFALSE; - for( UInt_t uCluster = 0; uCluster < fvClustersH2X.size(); ++uCluster ) - { - if( kTRUE == fvClustersH2X[ uCluster ].CheckAddHit( (*it) ) ) - { - bFoundCluster = kTRUE; - break; - } // if( kTRUE == fvClustersH2X[ uCluster ].CheckAddHit( (*it) ) ) - } // for( UInt_t uCluster = 0; uCluster < fvClustersH2X.size(); ++uCluster ) - if( kFALSE == bFoundCluster ) - { - Cosy2018TestCluster newClust( (*it) ); - fvClustersH2X.push_back( newClust ); - } // if( kFALSE == bFoundCluster ) - ///+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - } // if( bHitInX ) - else - { - Double_t dDtSameFeb = ( ulHitTs - dLastTimeY2 ) * stsxyter::kdClockCycleNs; - fhSetupSortedDtY2->Fill( dDtSameFeb ); - - fLastSortedHit2Y = (*it); - dLastTimeY2 = ulHitTs; - - /// Compute fiber Idx of the last Hodo hits - UInt_t uFiberIdxX1 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit1X.GetChan() ); - if( fUnpackParHodo->IsXInvertedHodo1() ) - uFiberIdxX1 = fuNbChanPerAsic/2 - 1 - uFiberIdxX1; - UInt_t uFiberIdxY1 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit1Y.GetChan() ); - if( fUnpackParHodo->IsYInvertedHodo1() ) - uFiberIdxY1 = fuNbChanPerAsic/2 - 1 - uFiberIdxY1; - UInt_t uFiberIdxX2 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit2X.GetChan() ); - if( fUnpackParHodo->IsXInvertedHodo2() ) - uFiberIdxX2 = fuNbChanPerAsic/2 - 1 - uFiberIdxX2; - UInt_t uFiberIdxY2 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit2Y.GetChan() ); - if( fUnpackParHodo->IsYInvertedHodo2() ) - uFiberIdxY2 = fuNbChanPerAsic/2 - 1 - uFiberIdxY2; - - if( dTimeSinceStartSec < fdSpillEvoLength ) - { - fhHodoY2SpillEvo->Fill( dTimeSinceStartSec, uFiberIdxY2 ); - fhHodoY2SpillEvoProf->Fill( dTimeSinceStartSec, uFiberIdxY2 ); - } // if( dTimeSinceStartSec < fdSpillEvoLength ) - - dDtX1Y1 = ( dLastTimeY1 - dLastTimeX1 ) * stsxyter::kdClockCycleNs; - dDtX2Y2 = ( dLastTimeY2 - dLastTimeX2 ) * stsxyter::kdClockCycleNs; - dDtN1P1 = ( dLastTimeP1 - dLastTimeN1 ) * stsxyter::kdClockCycleNs; - dDtX1Y1X2Y2 = ( ( dLastTimeX2 + dLastTimeY2 ) - ( dLastTimeX1 + dLastTimeY1 ) ) - * stsxyter::kdClockCycleNs / 2.0; - dDtX1Y1X2Y2N1P1 = ( ( dLastTimeN1 + dLastTimeP1 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) / 4.0 - ) * stsxyter::kdClockCycleNs; - if( kTRUE == fbDualStsEna ) - { - dDtN2P2 = ( dLastTimeP2 - dLastTimeN2 ) * stsxyter::kdClockCycleNs; - dDtN1P1N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) - ( dLastTimeN1 + dLastTimeP1 ) ) - * stsxyter::kdClockCycleNs / 2.0; - dDtX1Y1X2Y2N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) / 4.0 - ) * stsxyter::kdClockCycleNs; - dDtH1H2S1S2 = ( ( dLastTimeN2 + dLastTimeP2 + dLastTimeN1 + dLastTimeP1 ) - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) - ) * stsxyter::kdClockCycleNs / 4.0; - } // if( kTRUE == fbDualStsEna ) - - fhSetupSortedDtX2Y2->Fill( dDtX2Y2 ); - fhSetupSortedDtX1Y1X2Y2->Fill( dDtX1Y1X2Y2 ); - fhSetupSortedDtX1Y1X2Y2N1P1->Fill( dDtX1Y1X2Y2N1P1 ); - if( kTRUE == fbDualStsEna ) - { - fhSetupSortedDtX1Y1X2Y2N2P2->Fill( dDtX1Y1X2Y2N2P2 ); - fhSetupSortedDtH1H2S1S2->Fill( dDtH1H2S1S2 ); - } // if( kTRUE == fbDualStsEna ) - - if( fdCoincMinHodo < dDtX2Y2 && dDtX2Y2 < fdCoincMaxHodo ) - { - fhSetupSortedMapX2Y2->Fill( uFiberIdxX2, uFiberIdxY2 ); - fhSetupSortedCntEvoX2Y2->Fill( dTimeSinceStartSec ); - } // if( fdCoincMinHodo < dDtX2Y2 && dDtX2Y2 < fdCoincMaxHodo ) - - ///++++++++ Adrian ADC analysis, to be moved in other class! +++++/// - if( 0 < uFiberIdxY2 ) - { - Double_t dDtPrevChan = ( static_cast< Double_t >( (*it).GetTs() ) - static_cast< Double_t >( fvLastHitChanH2Y[ uFiberIdxY2 - 1].GetTs() ) - ) * stsxyter::kdClockCycleNs; - - fhDtNeighborChansH2Y->Fill( dDtPrevChan, uFiberIdxY2 - 1 ); - } // if( 0 < (*it).GetChan() ) - if( uFiberIdxY2 < fuNbChanPerAsic/2 - 1 ) - { - Double_t dDtNextChan = ( static_cast< Double_t >( fvLastHitChanH2Y[ uFiberIdxY2 + 1 ].GetTs() ) - static_cast< Double_t >( (*it).GetTs() ) - ) * stsxyter::kdClockCycleNs; - - fhDtNeighborChansH2Y->Fill( dDtNextChan, uFiberIdxY2 ); - } // if( 0 < (*it).GetChan() ) - - fvLastHitChanH2Y[ uFiberIdxY2 ] = (*it); - - Bool_t bFoundCluster = kFALSE; - for( UInt_t uCluster = 0; uCluster < fvClustersH2Y.size(); ++uCluster ) - { - if( kTRUE == fvClustersH2Y[ uCluster ].CheckAddHit( (*it) ) ) - { - bFoundCluster = kTRUE; - break; - } // if( kTRUE == fvClustersH2Y[ uCluster ].CheckAddHit( (*it) ) ) - } // for( UInt_t uCluster = 0; uCluster < fvClustersH2Y.size(); ++uCluster ) - if( kFALSE == bFoundCluster ) - { - Cosy2018TestCluster newClust( (*it) ); - fvClustersH2Y.push_back( newClust ); - } // if( kFALSE == bFoundCluster ) - ///+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - } // else of if( bHitInX ) - } // else if( fUnpackParHodo->GetAsicIndexHodo2() == usAsicIdx ) - else if( fUnpackParSts->GetAsicIndexSts1N() == usAsicIdx ) - { - Double_t dDtSameFeb = ( ulHitTs - dLastTimeN1 ) * stsxyter::kdClockCycleNs; - fhSetupSortedDtN1->Fill( dDtSameFeb ); - - fLastSortedHit1N = (*it); - dLastTimeN1 = ulHitTs; - - /// Compute fiber Idx of the last Hodo hits - UInt_t uFiberIdxX1 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit1X.GetChan() ); - if( fUnpackParHodo->IsXInvertedHodo1() ) - uFiberIdxX1 = fuNbChanPerAsic/2 - 1 - uFiberIdxX1; - UInt_t uFiberIdxY1 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit1Y.GetChan() ); - if( fUnpackParHodo->IsYInvertedHodo1() ) - uFiberIdxY1 = fuNbChanPerAsic/2 - 1 - uFiberIdxY1; - UInt_t uFiberIdxX2 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit2X.GetChan() ); - if( fUnpackParHodo->IsXInvertedHodo2() ) - uFiberIdxX2 = fuNbChanPerAsic/2 - 1 - uFiberIdxX2; - UInt_t uFiberIdxY2 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit2Y.GetChan() ); - if( fUnpackParHodo->IsYInvertedHodo2() ) - uFiberIdxY2 = fuNbChanPerAsic/2 - 1 - uFiberIdxY2; - - dDtX1Y1 = ( dLastTimeY1 - dLastTimeX1 ) * stsxyter::kdClockCycleNs; - dDtX2Y2 = ( dLastTimeY2 - dLastTimeX2 ) * stsxyter::kdClockCycleNs; - dDtN1P1 = ( dLastTimeP1 - dLastTimeN1 ) * stsxyter::kdClockCycleNs; - dDtX1Y1X2Y2 = ( ( dLastTimeX2 + dLastTimeY2 ) - ( dLastTimeX1 + dLastTimeY1 ) ) - * stsxyter::kdClockCycleNs / 2.0; - dDtX1Y1X2Y2N1P1 = ( ( dLastTimeN1 + dLastTimeP1 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) / 4.0 - ) * stsxyter::kdClockCycleNs; - if( kTRUE == fbDualStsEna ) - { - dDtN2P2 = ( dLastTimeP2 - dLastTimeN2 ) * stsxyter::kdClockCycleNs; - dDtN1P1N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) - ( dLastTimeN1 + dLastTimeP1 ) ) - * stsxyter::kdClockCycleNs / 2.0; - dDtX1Y1X2Y2N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) / 4.0 - ) * stsxyter::kdClockCycleNs; - dDtH1H2S1S2 = ( ( dLastTimeN2 + dLastTimeP2 + dLastTimeN1 + dLastTimeP1 ) - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) - ) * stsxyter::kdClockCycleNs / 4.0; - } // if( kTRUE == fbDualStsEna ) - - fhSetupSortedDtN1P1->Fill( dDtN1P1 ); - fhSetupSortedDtX1Y1X2Y2N1P1->Fill( dDtX1Y1X2Y2N1P1 ); - if( kTRUE == fbDualStsEna ) - { - fhSetupSortedDtN1P1N2P2->Fill( dDtN1P1N2P2 ); - fhSetupSortedDtH1H2S1S2->Fill( dDtH1H2S1S2 ); - } // if( kTRUE == fbDualStsEna ) - - if( fdCoincMinSts1 < dDtN1P1 && dDtN1P1 < fdCoincMaxSts1 ) - { - fhSetupSortedMapN1P1->Fill( fLastSortedHit1N.GetChan(), fLastSortedHit1P.GetChan() ); - fhSetupSortedCntEvoN1P1->Fill( dTimeSinceStartSec ); - - Double_t dX1, dY1; - ComputeCoordinatesSensor1( fLastSortedHit1N.GetChan(), fLastSortedHit1P.GetChan(), dX1, dY1 ); - fhStsSortedMapS1->Fill( dX1, dY1 ); - - if( TMath::Abs( dDtN1P1N2P2 ) < 2*fdCoincBorder && kTRUE == fbDualStsEna ) - { - Double_t dX2, dY2; - ComputeCoordinatesSensor2( fLastSortedHit2N.GetChan(), fLastSortedHit2P.GetChan(), dX2, dY2 ); - fhStsSortedMapS1Coinc->Fill( dX1, dY1 ); - fhStsSortedMapS2Coinc->Fill( dX2, dY2 ); - } // if( TMath::Abs( dDtN1P2 ) < fdCoincBorder && kTRUE == fbDualStsEna ) - } // if( fdCoincMinSts1 < dDtN1P1 && dDtN1P1 < fdCoincMaxSts1 ) - - /// Multiplicity estimation - UInt_t uNbP1CoincPerN1 = 0; - Double_t dDtSts1 = 1e12; - Double_t dDtBestPair = 1e12; - std::vector< stsxyter::FinalHit >::iterator itBestP1 = fvmHitsInTs.end(); - for( std::vector< stsxyter::FinalHit >::iterator itP1 = itFirstMatchP1; itP1 != fvmHitsInTs.end(); ++itP1 ) - { - if( fUnpackParSts->GetAsicIndexSts1P() == (*itP1).GetAsic() ) - { - dDtSts1 = ( static_cast< Double_t >( (*itP1).GetTs() ) - static_cast< Double_t >( (*it).GetTs() ) - ) * stsxyter::kdClockCycleNs; - if( fdCoincMinSts1 < dDtSts1 ) - { - if( dDtSts1 < fdCoincMaxSts1 ) - { - // Ignore unphysical pairs - if( kFALSE == CheckPhysPairSensor1( (*it).GetChan(), (*itP1).GetChan() ) ) - continue; - - uNbP1CoincPerN1 ++; - if( TMath::Abs( dDtSts1 - fdCoincCenterSts1 ) < dDtBestPair ) - { - itBestP1 = itP1; - dDtBestPair = TMath::Abs( dDtSts1 - fdCoincCenterSts1 ); - } // if( TMath::Abs( dDtSts1 - fdCoincCenterSts1 ) < dDtBestPair ) - }// if( dDtSts1 < fdCoincMaxSts1 ) - else break; - } // if( fdCoincMinSts < dDtSts1 ) - else itFirstMatchP1 = itP1; - } // if( fUnpackParSts->GetAsicIndexSts1P() == usAsicIdx ) - } // for( itP1 = itFirstMatchP1; itP1 != fvmHitsInTs.end(); ++itP1 ) - if( 0 < uNbP1CoincPerN1 ) - { - fvPairsS1.push_back( std::pair< stsxyter::FinalHit, stsxyter::FinalHit >( (*it), (*itBestP1) ) ); - fhDtBestPairsS1->Fill( ( static_cast< Double_t >( (*itBestP1).GetTs() ) - static_cast< Double_t >( (*it).GetTs() ) - ) * stsxyter::kdClockCycleNs ); - - fhChanMapBestMatchS1->Fill( (*it).GetChan(), (*itBestP1).GetChan() ); - - Double_t dPosX, dPosY; - ComputeCoordinatesSensor1( (*it).GetChan(), (*itBestP1).GetChan(), dPosX, dPosY ); - fhMapBestPairsS1->Fill( dPosX, dPosY ); - } // if( 0 < uNbP1CoincPerN1 ) - fhNbP1CoincPerN1->Fill( uNbP1CoincPerN1 ); - - fvHitsS1N.push_back( (*it) ); - - ///++++++++ Adrian ADC analysis, to be moved in other class! +++++/// - if( 0 < usChanIdx ) - { - Double_t dDtPrevChan = ( static_cast< Double_t >( (*it).GetTs() ) - static_cast< Double_t >( fvLastHitChanS1N[ usChanIdx - 1].GetTs() ) - ) * stsxyter::kdClockCycleNs; - - fhDtNeighborChansS1N->Fill( dDtPrevChan, usChanIdx - 1 ); - } // if( 0 < (*it).GetChan() ) - if( usChanIdx < fuNbChanPerAsic - 1 ) - { - Double_t dDtNextChan = ( static_cast< Double_t >( fvLastHitChanS1N[ usChanIdx + 1 ].GetTs() ) - static_cast< Double_t >( (*it).GetTs() ) - ) * stsxyter::kdClockCycleNs; - - fhDtNeighborChansS1N->Fill( dDtNextChan, usChanIdx ); - } // if( 0 < (*it).GetChan() ) - - fvLastHitChanS1N[ usChanIdx ] = (*it); - - Bool_t bFoundCluster = kFALSE; - for( UInt_t uCluster = 0; uCluster < fvClustersS1N.size(); ++uCluster ) - { - if( kTRUE == fvClustersS1N[ uCluster ].CheckAddHit( (*it) ) ) - { - bFoundCluster = kTRUE; - break; - } // if( kTRUE == fvClustersS1N[ uCluster ].CheckAddHit( (*it) ) ) - } // for( UInt_t uCluster = 0; uCluster < fvClustersS1N.size(); ++uCluster ) - if( kFALSE == bFoundCluster ) - { - Cosy2018TestCluster newClust( (*it) ); - fvClustersS1N.push_back( newClust ); - } // if( kFALSE == bFoundCluster ) - ///+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - } // if( fUnpackParSts->GetAsicIndexSts1N() == usAsicIdx ) - else if( fUnpackParSts->GetAsicIndexSts1P() == usAsicIdx ) - { - Double_t dDtSameFeb = ( ulHitTs - dLastTimeP1 ) * stsxyter::kdClockCycleNs; - fhSetupSortedDtP1->Fill( dDtSameFeb ); - - fLastSortedHit1P = (*it); - dLastTimeP1 = ulHitTs; - - /// Compute fiber Idx of the last Hodo hits - UInt_t uFiberIdxX1 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit1X.GetChan() ); - if( fUnpackParHodo->IsXInvertedHodo1() ) - uFiberIdxX1 = fuNbChanPerAsic/2 - 1 - uFiberIdxX1; - UInt_t uFiberIdxY1 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit1Y.GetChan() ); - if( fUnpackParHodo->IsYInvertedHodo1() ) - uFiberIdxY1 = fuNbChanPerAsic/2 - 1 - uFiberIdxY1; - UInt_t uFiberIdxX2 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit2X.GetChan() ); - if( fUnpackParHodo->IsXInvertedHodo2() ) - uFiberIdxX2 = fuNbChanPerAsic/2 - 1 - uFiberIdxX2; - UInt_t uFiberIdxY2 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit2Y.GetChan() ); - if( fUnpackParHodo->IsYInvertedHodo2() ) - uFiberIdxY2 = fuNbChanPerAsic/2 - 1 - uFiberIdxY2; - - dDtX1Y1 = ( dLastTimeY1 - dLastTimeX1 ) * stsxyter::kdClockCycleNs; - dDtX2Y2 = ( dLastTimeY2 - dLastTimeX2 ) * stsxyter::kdClockCycleNs; - dDtN1P1 = ( dLastTimeP1 - dLastTimeN1 ) * stsxyter::kdClockCycleNs; - dDtX1Y1X2Y2 = ( ( dLastTimeX2 + dLastTimeY2 ) - ( dLastTimeX1 + dLastTimeY1 ) ) - * stsxyter::kdClockCycleNs / 2.0; - dDtX1Y1X2Y2N1P1 = ( ( dLastTimeN1 + dLastTimeP1 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) / 4.0 - ) * stsxyter::kdClockCycleNs; - if( kTRUE == fbDualStsEna ) - { - dDtN2P2 = ( dLastTimeP2 - dLastTimeN2 ) * stsxyter::kdClockCycleNs; - dDtN1P1N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) - ( dLastTimeN1 + dLastTimeP1 ) ) - * stsxyter::kdClockCycleNs / 2.0; - dDtX1Y1X2Y2N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) / 4.0 - ) * stsxyter::kdClockCycleNs; - dDtH1H2S1S2 = ( ( dLastTimeN2 + dLastTimeP2 + dLastTimeN1 + dLastTimeP1 ) - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) - ) * stsxyter::kdClockCycleNs / 4.0; - } // if( kTRUE == fbDualStsEna ) - - fhSetupSortedDtN1P1->Fill( dDtN1P1 ); - fhSetupSortedDtX1Y1X2Y2N1P1->Fill( dDtX1Y1X2Y2N1P1 ); - if( kTRUE == fbDualStsEna ) - { - fhSetupSortedDtN1P1N2P2->Fill( dDtN1P1N2P2 ); - fhSetupSortedDtH1H2S1S2->Fill( dDtH1H2S1S2 ); - } // if( kTRUE == fbDualStsEna ) - - if( fdCoincMinSts1 < dDtN1P1 && dDtN1P1 < fdCoincMaxSts1 ) - { - fhSetupSortedMapN1P1->Fill( fLastSortedHit1N.GetChan(), fLastSortedHit1P.GetChan() ); - fhSetupSortedCntEvoN1P1->Fill( dTimeSinceStartSec ); - - Double_t dX1, dY1; - ComputeCoordinatesSensor1( fLastSortedHit1N.GetChan(), fLastSortedHit1P.GetChan(), dX1, dY1 ); - fhStsSortedMapS1->Fill( dX1, dY1 ); - - if( TMath::Abs( dDtN1P1N2P2 ) < 2*fdCoincBorder && kTRUE == fbDualStsEna ) - { - Double_t dX2, dY2; - ComputeCoordinatesSensor2( fLastSortedHit2N.GetChan(), fLastSortedHit2P.GetChan(), dX2, dY2 ); - fhStsSortedMapS1Coinc->Fill( dX1, dY1 ); - fhStsSortedMapS2Coinc->Fill( dX2, dY2 ); - } // if( TMath::Abs( dDtN1P2 ) < fdCoincBorder && kTRUE == fbDualStsEna ) - } // if( fdCoincMinSts1 < dDtN1P1 && dDtN1P1 < fdCoincMaxSts1 ) - - fvHitsS1P.push_back( (*it) ); - - ///++++++++ Adrian ADC analysis, to be moved in other class! +++++/// - if( 0 < usChanIdx ) - { - Double_t dDtPrevChan = ( static_cast< Double_t >( (*it).GetTs() ) - static_cast< Double_t >( fvLastHitChanS1P[ usChanIdx - 1].GetTs() ) - ) * stsxyter::kdClockCycleNs; - - fhDtNeighborChansS1P->Fill( dDtPrevChan, usChanIdx - 1 ); - } // if( 0 < (*it).GetChan() ) - if( usChanIdx < fuNbChanPerAsic - 1 ) - { - Double_t dDtNextChan = ( static_cast< Double_t >( fvLastHitChanS1P[ usChanIdx + 1 ].GetTs() ) - static_cast< Double_t >( (*it).GetTs() ) - ) * stsxyter::kdClockCycleNs; - - fhDtNeighborChansS1P->Fill( dDtNextChan, usChanIdx ); - } // if( 0 < (*it).GetChan() ) - - fvLastHitChanS1P[ usChanIdx ] = (*it); - - Bool_t bFoundCluster = kFALSE; - for( UInt_t uCluster = 0; uCluster < fvClustersS1P.size(); ++uCluster ) - { - if( kTRUE == fvClustersS1P[ uCluster ].CheckAddHit( (*it) ) ) - { - bFoundCluster = kTRUE; - break; - } // if( kTRUE == fvClustersS1P[ uCluster ].CheckAddHit( (*it) ) ) - } // for( UInt_t uCluster = 0; uCluster < fvClustersS1P.size(); ++uCluster ) - if( kFALSE == bFoundCluster ) - { - Cosy2018TestCluster newClust( (*it) ); - fvClustersS1P.push_back( newClust ); - } // if( kFALSE == bFoundCluster ) - ///+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - } // else if( fUnpackParSts->GetAsicIndexSts1P() == usAsicIdx ) - else if( kTRUE == fbDualStsEna ) - { - if( fUnpackParSts->GetAsicIndexSts2N() == usAsicIdx ) - { - Double_t dDtSameFeb = ( ulHitTs - dLastTimeN2 ) * stsxyter::kdClockCycleNs; - fhSetupSortedDtN2->Fill( dDtSameFeb ); - - fLastSortedHit2N = (*it); - dLastTimeN2 = ulHitTs; - - /// Compute fiber Idx of the last Hodo hits - UInt_t uFiberIdxX1 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit1X.GetChan() ); - if( fUnpackParHodo->IsXInvertedHodo1() ) - uFiberIdxX1 = fuNbChanPerAsic/2 - 1 - uFiberIdxX1; - UInt_t uFiberIdxY1 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit1Y.GetChan() ); - if( fUnpackParHodo->IsYInvertedHodo1() ) - uFiberIdxY1 = fuNbChanPerAsic/2 - 1 - uFiberIdxY1; - UInt_t uFiberIdxX2 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit2X.GetChan() ); - if( fUnpackParHodo->IsXInvertedHodo2() ) - uFiberIdxX2 = fuNbChanPerAsic/2 - 1 - uFiberIdxX2; - UInt_t uFiberIdxY2 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit2Y.GetChan() ); - if( fUnpackParHodo->IsYInvertedHodo2() ) - uFiberIdxY2 = fuNbChanPerAsic/2 - 1 - uFiberIdxY2; - - dDtX1Y1 = ( dLastTimeY1 - dLastTimeX1 ) * stsxyter::kdClockCycleNs; - dDtX2Y2 = ( dLastTimeY2 - dLastTimeX2 ) * stsxyter::kdClockCycleNs; - dDtN1P1 = ( dLastTimeP1 - dLastTimeN1 ) * stsxyter::kdClockCycleNs; - dDtN2P2 = ( dLastTimeP2 - dLastTimeN2 ) * stsxyter::kdClockCycleNs; - dDtX1Y1X2Y2 = ( ( dLastTimeX2 + dLastTimeY2 ) - ( dLastTimeX1 + dLastTimeY1 ) ) - * stsxyter::kdClockCycleNs / 2.0; - dDtN1P1N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) - ( dLastTimeN1 + dLastTimeP1 ) ) - * stsxyter::kdClockCycleNs / 2.0; - dDtX1Y1X2Y2N1P1 = ( ( dLastTimeN1 + dLastTimeP1 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) / 4.0 - ) * stsxyter::kdClockCycleNs; - dDtX1Y1X2Y2N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) / 4.0 - ) * stsxyter::kdClockCycleNs; - dDtH1H2S1S2 = ( ( dLastTimeN2 + dLastTimeP2 + dLastTimeN1 + dLastTimeP1 ) - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) - ) * stsxyter::kdClockCycleNs / 4.0; - - fhSetupSortedDtN2P2->Fill( dDtN2P2 ); - fhSetupSortedDtN1P1N2P2->Fill( dDtN1P1N2P2 ); - fhSetupSortedDtX1Y1X2Y2N2P2->Fill( dDtX1Y1X2Y2N2P2 ); - fhSetupSortedDtH1H2S1S2->Fill( dDtH1H2S1S2 ); - - if( fdCoincMinSts2 < dDtN2P2 && dDtN2P2 < fdCoincMaxSts2 ) - { - fhSetupSortedMapN2P2->Fill( fLastSortedHit2N.GetChan(), fLastSortedHit2P.GetChan() ); - fhSetupSortedCntEvoN2P2->Fill( dTimeSinceStartSec ); - - Double_t dX2, dY2; - ComputeCoordinatesSensor2( fLastSortedHit2N.GetChan(), fLastSortedHit2P.GetChan(), dX2, dY2 ); - fhStsSortedMapS2->Fill( dX2, dY2 ); - - if( TMath::Abs( dDtN1P1N2P2 ) < 2*fdCoincBorder ) - { - Double_t dX1, dY1; - ComputeCoordinatesSensor1( fLastSortedHit1N.GetChan(), fLastSortedHit1P.GetChan(), dX1, dY1 ); - fhStsSortedMapS1Coinc->Fill( dX1, dY1 ); - fhStsSortedMapS2Coinc->Fill( dX2, dY2 ); - } // if( TMath::Abs( dDtN1P2 ) < fdCoincBorder ) - } // if( fdCoincMinSts2 < dDtN2P2 && dDtN2P2 < fdCoincMaxSts2 ) - - /// Multiplicity estimation - UInt_t uNbP2CoincPerN2 = 0; - Double_t dDtSts2 = 1e12; - Double_t dDtBestPair = 1e12; - std::vector< stsxyter::FinalHit >::iterator itBestP2 = fvmHitsInTs.end(); - for( std::vector< stsxyter::FinalHit >::iterator itP2 = itFirstMatchP2; itP2 != fvmHitsInTs.end(); ++itP2 ) - { - if( fUnpackParSts->GetAsicIndexSts2P() == (*itP2).GetAsic() ) - { - dDtSts2 = ( static_cast< Double_t >( (*itP2).GetTs() ) - static_cast< Double_t >( (*it).GetTs() ) - ) * stsxyter::kdClockCycleNs; - if( fdCoincMinSts2 < dDtSts2 ) - { - if( dDtSts2 < fdCoincMaxSts2 ) - { - // Ignore unphysical pairs - if( kFALSE == CheckPhysPairSensor2( (*it).GetChan(), (*itP2).GetChan() ) ) - continue; - - uNbP2CoincPerN2 ++; - if( TMath::Abs( dDtSts2 - fdCoincCenterSts2 ) < dDtBestPair ) - { - itBestP2 = itP2; - dDtBestPair = TMath::Abs( dDtSts2 - fdCoincCenterSts2 ); - } // if( TMath::Abs( dDtSts2 - fdCoincCenterSts2 ) < dDtBestPair ) - } // if( dDtSts2 < fdCoincMaxSts2 ) - else break; - } // if( fdCoincMinSts2 < dDtSts2 ) - else itFirstMatchP2 = itP2; - } // if( fUnpackParSts->GetAsicIndexSts2P() == usAsicIdx ) - } // for( itP2 = itFirstMatchP2; itP2 != fvmHitsInTs.end(); ++itP2 ) - if( 0 < uNbP2CoincPerN2 ) - { - fvPairsS2.push_back( std::pair< stsxyter::FinalHit, stsxyter::FinalHit >( (*it), (*itBestP2) ) ); - fhDtBestPairsS2->Fill( ( static_cast< Double_t >( (*itBestP2).GetTs() ) - static_cast< Double_t >( (*it).GetTs() ) - ) * stsxyter::kdClockCycleNs ); - - Double_t dPosX, dPosY; - ComputeCoordinatesSensor1( (*it).GetChan(), (*itBestP2).GetChan(), dPosX, dPosY ); - fhMapBestPairsS2->Fill( dPosX, dPosY ); - } // if( 0 < uNbP2CoincPerN2 ) - fhNbP2CoincPerN2->Fill( uNbP2CoincPerN2 ); - - fvHitsS2N.push_back( (*it) ); - - ///++++++++ Adrian ADC analysis, to be moved in other class! +++++/// - if( 0 < usChanIdx ) - { - Double_t dDtPrevChan = ( static_cast< Double_t >( (*it).GetTs() ) - static_cast< Double_t >( fvLastHitChanS2N[ usChanIdx - 1].GetTs() ) - ) * stsxyter::kdClockCycleNs; - - fhDtNeighborChansS2N->Fill( dDtPrevChan, usChanIdx - 1 ); - } // if( 0 < (*it).GetChan() ) - if( usChanIdx < fuNbChanPerAsic - 1 ) - { - Double_t dDtNextChan = ( static_cast< Double_t >( fvLastHitChanS2N[ usChanIdx + 1].GetTs() ) - static_cast< Double_t >( (*it).GetTs() ) - ) * stsxyter::kdClockCycleNs; - - fhDtNeighborChansS2N->Fill( dDtNextChan, usChanIdx ); - } // if( 0 < (*it).GetChan() ) - - fvLastHitChanS2N[ usChanIdx ] = (*it); - - Bool_t bFoundCluster = kFALSE; - for( UInt_t uCluster = 0; uCluster < fvClustersS2N.size(); ++uCluster ) - { - if( kTRUE == fvClustersS2N[ uCluster ].CheckAddHit( (*it) ) ) - { - bFoundCluster = kTRUE; - break; - } // if( kTRUE == fvClustersS2N[ uCluster ].CheckAddHit( (*it) ) ) - } // for( UInt_t uCluster = 0; uCluster < fvClustersS2N.size(); ++uCluster ) - if( kFALSE == bFoundCluster ) - { - Cosy2018TestCluster newClust( (*it) ); - fvClustersS2N.push_back( newClust ); - } // if( kFALSE == bFoundCluster ) - ///+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - } // if( fUnpackParSts->GetAsicIndexSts2N() == usAsicIdx ) - else if( fUnpackParSts->GetAsicIndexSts2P() == usAsicIdx ) - { - Double_t dDtSameFeb = ( ulHitTs - dLastTimeP2 ) * stsxyter::kdClockCycleNs; - fhSetupSortedDtP2->Fill( dDtSameFeb ); - - fLastSortedHit2P = (*it); - dLastTimeP2 = ulHitTs; - - /// Compute fiber Idx of the last Hodo hits - UInt_t uFiberIdxX1 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit1X.GetChan() ); - if( fUnpackParHodo->IsXInvertedHodo1() ) - uFiberIdxX1 = fuNbChanPerAsic/2 - 1 - uFiberIdxX1; - UInt_t uFiberIdxY1 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit1Y.GetChan() ); - if( fUnpackParHodo->IsYInvertedHodo1() ) - uFiberIdxY1 = fuNbChanPerAsic/2 - 1 - uFiberIdxY1; - UInt_t uFiberIdxX2 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit2X.GetChan() ); - if( fUnpackParHodo->IsXInvertedHodo2() ) - uFiberIdxX2 = fuNbChanPerAsic/2 - 1 - uFiberIdxX2; - UInt_t uFiberIdxY2 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit2Y.GetChan() ); - if( fUnpackParHodo->IsYInvertedHodo2() ) - uFiberIdxY2 = fuNbChanPerAsic/2 - 1 - uFiberIdxY2; - - dDtX1Y1 = ( dLastTimeY1 - dLastTimeX1 ) * stsxyter::kdClockCycleNs; - dDtX2Y2 = ( dLastTimeY2 - dLastTimeX2 ) * stsxyter::kdClockCycleNs; - dDtN1P1 = ( dLastTimeP1 - dLastTimeN1 ) * stsxyter::kdClockCycleNs; - dDtN2P2 = ( dLastTimeP2 - dLastTimeN2 ) * stsxyter::kdClockCycleNs; - dDtX1Y1X2Y2 = ( ( dLastTimeX2 + dLastTimeY2 ) - ( dLastTimeX1 + dLastTimeY1 ) ) - * stsxyter::kdClockCycleNs / 2.0; - dDtN1P1N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) - ( dLastTimeN1 + dLastTimeP1 ) ) - * stsxyter::kdClockCycleNs / 2.0; - dDtX1Y1X2Y2N1P1 = ( ( dLastTimeN1 + dLastTimeP1 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) / 4.0 - ) * stsxyter::kdClockCycleNs; - dDtX1Y1X2Y2N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) / 4.0 - ) * stsxyter::kdClockCycleNs; - dDtH1H2S1S2 = ( ( dLastTimeN2 + dLastTimeP2 + dLastTimeN1 + dLastTimeP1 ) - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) - ) * stsxyter::kdClockCycleNs / 4.0; - - - fhSetupSortedDtN2P2->Fill( dDtN2P2 ); - fhSetupSortedDtN1P1N2P2->Fill( dDtN1P1N2P2 ); - fhSetupSortedDtX1Y1X2Y2N2P2->Fill( dDtX1Y1X2Y2N2P2 ); - fhSetupSortedDtH1H2S1S2->Fill( dDtH1H2S1S2 ); - - if( fdCoincMinSts2 < dDtN2P2 && dDtN2P2 < fdCoincMaxSts2 ) - { - fhSetupSortedMapN2P2->Fill( fLastSortedHit2N.GetChan(), fLastSortedHit2P.GetChan() ); - fhSetupSortedCntEvoN2P2->Fill( dTimeSinceStartSec ); - - Double_t dX2, dY2; - ComputeCoordinatesSensor2( fLastSortedHit2N.GetChan(), fLastSortedHit2P.GetChan(), dX2, dY2 ); - fhStsSortedMapS2->Fill( dX2, dY2 ); - - if( TMath::Abs( dDtN1P1N2P2 ) < 2*fdCoincBorder ) - { - Double_t dX1, dY1; - ComputeCoordinatesSensor1( fLastSortedHit1N.GetChan(), fLastSortedHit1P.GetChan(), dX1, dY1 ); - fhStsSortedMapS1Coinc->Fill( dX1, dY1 ); - fhStsSortedMapS2Coinc->Fill( dX2, dY2 ); - } // if( TMath::Abs( dDtN1P2 ) < fdCoincBorder ) - } // if( fdCoincMinSts2 < dDtN2P2 && dDtN2P2 < fdCoincMaxSts2 ) - - fvHitsS2P.push_back( (*it) ); - - ///++++++++ Adrian ADC analysis, to be moved in other class! +++++/// - if( 0 < usChanIdx ) - { - Double_t dDtPrevChan = ( static_cast< Double_t >( (*it).GetTs() ) - static_cast< Double_t >( fvLastHitChanS2P[ usChanIdx - 1].GetTs() ) - ) * stsxyter::kdClockCycleNs; - - fhDtNeighborChansS2P->Fill( dDtPrevChan, usChanIdx - 1 ); - } // if( 0 < (*it).GetChan() ) - if( usChanIdx < fuNbChanPerAsic - 1 ) - { - Double_t dDtNextChan = ( static_cast< Double_t >( fvLastHitChanS2P[ usChanIdx + 1].GetTs() ) - static_cast< Double_t >( (*it).GetTs() ) - ) * stsxyter::kdClockCycleNs; - - fhDtNeighborChansS2P->Fill( dDtNextChan, usChanIdx ); - } // if( 0 < (*it).GetChan() ) - - fvLastHitChanS2P[ usChanIdx ] = (*it); - - Bool_t bFoundCluster = kFALSE; - for( UInt_t uCluster = 0; uCluster < fvClustersS2P.size(); ++uCluster ) - { - if( kTRUE == fvClustersS2P[ uCluster ].CheckAddHit( (*it) ) ) - { - bFoundCluster = kTRUE; - break; - } // if( kTRUE == fvClustersS2P[ uCluster ].CheckAddHit( (*it) ) ) - } // for( UInt_t uCluster = 0; uCluster < fvClustersS2P.size(); ++uCluster ) - if( kFALSE == bFoundCluster ) - { - Cosy2018TestCluster newClust( (*it) ); - fvClustersS2P.push_back( newClust ); - } // if( kFALSE == bFoundCluster ) - ///+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - } // else if( fUnpackParSts->GetAsicIndexSts1P() == usAsicIdx ) - } // else if( kTRUE == fbDualStsEna ) - } // loop on hits untils hits within 100 ns of last one or last one itself are reached - - ///++++++++ Adrian ADC analysis, to be moved in other class! +++++/// - for( UInt_t uClusterN = 0; uClusterN < fvClustersS1N.size(); ++uClusterN ) - { - fhClusterAdcVsSizeS1N->Fill( fvClustersS1N[ uClusterN ].fusTotalAdc, fvClustersS1N[ uClusterN ].fvHits.size() ); - - UInt_t uNbMatches = 0; - for( UInt_t uClusterP = 0; uClusterP < fvClustersS1P.size(); ++uClusterP ) - { - Double_t dDtSts1 = fvClustersS1P[ uClusterP ].fdMeanTime - fvClustersS1N[ uClusterN ].fdMeanTime; - if( fdCoincMinSts1 < dDtSts1 ) - { - if( dDtSts1 < fdCoincMaxSts1 ) - { - // Ignore unphysical pairs - if( kFALSE == CheckPhysPairSensor1( fvClustersS1N[ uClusterN ].fdWeightedCenter, - fvClustersS1P[ uClusterP ].fdWeightedCenter ) ) - continue; - - fhClusterAdcVsSizeS1N_MatchS1->Fill( fvClustersS1N[ uClusterN ].fusTotalAdc, fvClustersS1N[ uClusterN ].fvHits.size() ); - fhClusterAdcVsSizeS1P_MatchS1->Fill( fvClustersS1P[ uClusterP ].fusTotalAdc, fvClustersS1P[ uClusterP ].fvHits.size() ); - - uNbMatches ++; - } // if( dDtSts1 < fdCoincMaxSts1 ) - } // if( fdCoincMinSts1 < dDtSts1 ) - } // for( UInt_t uClusterP = 0; uClusterP < fvClustersS1P.size(); ++uClusterP ) - - fhClusterS1N_CenterNbMatchS1P->Fill( fvClustersS1N[ uClusterN ].fdWeightedCenter, uNbMatches ); - fhClusterS1N_AdcNbMatchS1P->Fill( fvClustersS1N[ uClusterN ].fusTotalAdc, uNbMatches ); - } // for( UInt_t uClusterN = 0; uClusterN < fvClustersS1N.size(); ++uClusterN ) - - for( UInt_t uClusterP = 0; uClusterP < fvClustersS1P.size(); ++uClusterP ) - { - fhClusterAdcVsSizeS1P->Fill( fvClustersS1P[ uClusterP ].fusTotalAdc, fvClustersS1P[ uClusterP ].fvHits.size() ); - - UInt_t uNbMatches = 0; - for( UInt_t uClusterN = 0; uClusterN < fvClustersS1N.size(); ++uClusterN ) - { - Double_t dDtSts1 = fvClustersS1P[ uClusterP ].fdMeanTime - fvClustersS1N[ uClusterN ].fdMeanTime; - if( fdCoincMinSts1 < dDtSts1 ) - { - if( dDtSts1 < fdCoincMaxSts1 ) - { - // Ignore unphysical pairs - if( kFALSE == CheckPhysPairSensor1( fvClustersS1N[ uClusterN ].fdWeightedCenter, - fvClustersS1P[ uClusterP ].fdWeightedCenter ) ) - continue; - - fhClusterAdcVsSizeS1N_MatchS1->Fill( fvClustersS1N[ uClusterN ].fusTotalAdc, fvClustersS1N[ uClusterN ].fvHits.size() ); - fhClusterAdcVsSizeS1P_MatchS1->Fill( fvClustersS1P[ uClusterP ].fusTotalAdc, fvClustersS1P[ uClusterP ].fvHits.size() ); - - uNbMatches ++; - } // if( dDtSts1 < fdCoincMaxSts1 ) - } // if( fdCoincMinSts1 < dDtSts1 ) - } // for( UInt_t uClusterN = 0; uClusterN < fvClustersS1N.size(); ++uClusterN ) - - fhClusterS1P_CenterNbMatchS1N->Fill( fvClustersS1P[ uClusterP ].fdWeightedCenter, uNbMatches ); - fhClusterS1P_AdcNbMatchS1N->Fill( fvClustersS1P[ uClusterP ].fusTotalAdc, uNbMatches ); - } // for( UInt_t uClusterP = 0; uClusterP < fvClustersS1P.size(); ++uClusterP ) - - for( UInt_t uClusterN = 0; uClusterN < fvClustersS2N.size(); ++uClusterN ) - { - fhClusterAdcVsSizeS2N->Fill( fvClustersS2N[ uClusterN ].fusTotalAdc, fvClustersS2N[ uClusterN ].fvHits.size() ); - - UInt_t uNbMatches = 0; - for( UInt_t uClusterP = 0; uClusterP < fvClustersS2P.size(); ++uClusterP ) - { - Double_t dDtSts2 = fvClustersS2P[ uClusterP ].fdMeanTime - fvClustersS2N[ uClusterN ].fdMeanTime; - if( fdCoincMinSts2 < dDtSts2 ) - { - if( dDtSts2 < fdCoincMaxSts2 ) - { - // Ignore unphysical pairs - if( kFALSE == CheckPhysPairSensor1( fvClustersS2N[ uClusterN ].fdWeightedCenter, - fvClustersS2P[ uClusterP ].fdWeightedCenter ) ) - continue; - - fhClusterAdcVsSizeS2N_MatchS2->Fill( fvClustersS2N[ uClusterN ].fusTotalAdc, fvClustersS2N[ uClusterN ].fvHits.size() ); - fhClusterAdcVsSizeS2P_MatchS2->Fill( fvClustersS2P[ uClusterP ].fusTotalAdc, fvClustersS2P[ uClusterP ].fvHits.size() ); - - uNbMatches ++; - } // if( dDtSts2 < fdCoincMaxSts2 ) - } // if( fdCoincMinSts2 < dDtSts2 ) - } // for( UInt_t uClusterP = 0; uClusterP < fvClustersS2P.size(); ++uClusterP ) - - fhClusterS2N_CenterNbMatchS2P->Fill( fvClustersS2N[ uClusterN ].fdWeightedCenter, uNbMatches ); - fhClusterS2N_AdcNbMatchS2P->Fill( fvClustersS2N[ uClusterN ].fusTotalAdc, uNbMatches ); - } // for( UInt_t uClusterN = 0; uClusterN < fvClustersS2N.size(); ++uClusterN ) - - for( UInt_t uClusterP = 0; uClusterP < fvClustersS2P.size(); ++uClusterP ) - { - fhClusterAdcVsSizeS2P->Fill( fvClustersS2P[ uClusterP ].fusTotalAdc, fvClustersS2P[ uClusterP ].fvHits.size() ); - - UInt_t uNbMatches = 0; - for( UInt_t uClusterN = 0; uClusterN < fvClustersS2N.size(); ++uClusterN ) - { - Double_t dDtSts2 = fvClustersS2P[ uClusterP ].fdMeanTime - fvClustersS2N[ uClusterN ].fdMeanTime; - if( fdCoincMinSts2 < dDtSts2 ) - { - if( dDtSts2 < fdCoincMaxSts2 ) - { - // Ignore unphysical pairs - if( kFALSE == CheckPhysPairSensor1( fvClustersS2N[ uClusterN ].fdWeightedCenter, - fvClustersS2P[ uClusterP ].fdWeightedCenter ) ) - continue; - - uNbMatches ++; - } // if( dDtSts2 < fdCoincMaxSts2 ) - } // if( fdCoincMinSts2 < dDtSts2 ) - } // for( UInt_t uClusterN = 0; uClusterN < fvClustersS2N.size(); ++uClusterN ) - - fhClusterS2P_CenterNbMatchS2N->Fill( fvClustersS2P[ uClusterP ].fdWeightedCenter, uNbMatches ); - fhClusterS2P_AdcNbMatchS2N->Fill( fvClustersS2P[ uClusterP ].fusTotalAdc, uNbMatches ); - } // for( UInt_t uCluster = 0; uCluster < fvClustersS2P.size(); ++uCluster ) - fvClustersS1N.clear(); - fvClustersS1P.clear(); - fvClustersS2N.clear(); - fvClustersS2P.clear(); - - - for( UInt_t uClusterX = 0; uClusterX < fvClustersH1X.size(); ++uClusterX ) - { - fhClusterAdcVsSizeH1X->Fill( fvClustersH1X[ uClusterX ].fusTotalAdc, fvClustersH1X[ uClusterX ].fvHits.size() ); - - UInt_t uNbMatches = 0; - for( UInt_t uClusterY = 0; uClusterY < fvClustersH1Y.size(); ++uClusterY ) - { - Double_t dDtHodo1 = fvClustersH1Y[ uClusterY ].fdMeanTime - fvClustersH1X[ uClusterX ].fdMeanTime; - if( fdCoincMinHodo < dDtHodo1 ) - { - if( dDtHodo1 < fdCoincMaxHodo ) - { - UInt_t uFiberIdxX1 = fUnpackParHodo->GetChannelToFiberMap( fvClustersH1X[ uClusterX ].fdWeightedCenter ); - if( fUnpackParHodo->IsXInvertedHodo1() ) - uFiberIdxX1 = fuNbChanPerAsic/2 - 1 - uFiberIdxX1; - UInt_t uFiberIdxY1 = fUnpackParHodo->GetChannelToFiberMap( fvClustersH1Y[ uClusterY ].fdWeightedCenter ); - if( fUnpackParHodo->IsYInvertedHodo1() ) - uFiberIdxY1 = fuNbChanPerAsic/2 - 1 - uFiberIdxY1; - fhClusterPosition_MatchH1->Fill( uFiberIdxX1, uFiberIdxY1 ); - - uNbMatches ++; - } // if( dDtSts1 < fdCoincMaxSts1 ) - } // if( fdCoincMinSts1 < dDtSts1 ) - } // for( UInt_t uClusterY = 0; uClusterY < fvClustersH1Y.size(); ++uClusterY ) - } // for( UInt_t uClusterX = 0; uClusterX < fvClustersH1X.size(); ++uClusterX ) - - for( UInt_t uClusterY = 0; uClusterY < fvClustersH1Y.size(); ++uClusterY ) - { - fhClusterAdcVsSizeH1Y->Fill( fvClustersH1Y[ uClusterY ].fusTotalAdc, fvClustersH1Y[ uClusterY ].fvHits.size() ); - } // for( UInt_t uClusterY = 0; uClusterY < fvClustersH1Y.size(); ++uClusterY ) - - for( UInt_t uClusterX = 0; uClusterX < fvClustersH2X.size(); ++uClusterX ) - { - fhClusterAdcVsSizeH2X->Fill( fvClustersH2X[ uClusterX ].fusTotalAdc, fvClustersH2X[ uClusterX ].fvHits.size() ); - - UInt_t uNbMatches = 0; - for( UInt_t uClusterY = 0; uClusterY < fvClustersH2Y.size(); ++uClusterY ) - { - Double_t dDtHodo2 = fvClustersH2Y[ uClusterY ].fdMeanTime - fvClustersH2X[ uClusterX ].fdMeanTime; - if( fdCoincMinHodo < dDtHodo2 ) - { - if( dDtHodo2 < fdCoincMaxHodo ) - { - UInt_t uFiberIdxX2 = fUnpackParHodo->GetChannelToFiberMap( fvClustersH2X[ uClusterX ].fdWeightedCenter ); - if( fUnpackParHodo->IsXInvertedHodo2() ) - uFiberIdxX2 = fuNbChanPerAsic/2 - 1 - uFiberIdxX2; - UInt_t uFiberIdxY2 = fUnpackParHodo->GetChannelToFiberMap( fvClustersH2Y[ uClusterY ].fdWeightedCenter ); - if( fUnpackParHodo->IsYInvertedHodo2() ) - uFiberIdxY2 = fuNbChanPerAsic/2 - 1 - uFiberIdxY2; - fhClusterPosition_MatchH2->Fill( uFiberIdxX2, uFiberIdxY2 ); - - uNbMatches ++; - } // if( dDtSts2 < fdCoincMaxSts2 ) - } // if( fdCoincMinSts2 < dDtSts2 ) - } // for( UInt_t uClusterY = 0; uClusterY < fvClustersH2Y.size(); ++uClusterY ) - } // for( UInt_t uClusterX = 0; uClusterX < fvClustersH2X.size(); ++uClusterX ) - - for( UInt_t uClusterY = 0; uClusterY < fvClustersH2Y.size(); ++uClusterY ) - { - fhClusterAdcVsSizeH2Y->Fill( fvClustersH2Y[ uClusterY ].fusTotalAdc, fvClustersH2Y[ uClusterY ].fvHits.size() ); - } // for( UInt_t uCluster = 0; uCluster < fvClustersH2Y.size(); ++uCluster ) - - fvClustersH1X.clear(); - fvClustersH1Y.clear(); - fvClustersH2X.clear(); - fvClustersH2Y.clear(); - ///+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - - // Remove all hits which were already used - fvmHitsInTs.erase( fvmHitsInTs.begin(), it ); - - /// Build coincidence plot for all N1P1 pairs and all N2P2 pairs - for( UInt_t uHitN1 = 0; uHitN1 < fvHitsS1N.size(); ++uHitN1 ) - { - Double_t dDtBestPair = 1e12; -// UInt_t uBestAdc = 0; - UInt_t uIdxBest = fvHitsS1P.size(); - for( UInt_t uHitP1 = 0; uHitP1 < fvHitsS1P.size(); ++uHitP1 ) - { - Double_t dDtSts1 = ( static_cast< Double_t >( fvHitsS1P[ uHitP1 ].GetTs() ) - - static_cast< Double_t >( fvHitsS1N[ uHitN1 ].GetTs() ) - ) * stsxyter::kdClockCycleNs; - - fhDtAllPairsS1->Fill( dDtSts1 ); - if( fdCoincMinSts1 < dDtSts1 && dDtSts1 < fdCoincMaxSts1 ) - { - fhChanMapAllMatchS1->Fill( fvHitsS1N[ uHitN1 ].GetChan(), fvHitsS1P[ uHitP1 ].GetChan() ); - if( TMath::Abs( dDtSts1 - fdCoincCenterSts1 ) < dDtBestPair ) - { - uIdxBest = uHitP1; - dDtBestPair = TMath::Abs( dDtSts1 - fdCoincCenterSts1 ); - } // if( TMath::Abs( dDtSts1 - fdCoincCenterSts1 ) < dDtBestPair ) -/* - if( uBestAdc < fvHitsS1P[ uHitP1 ].GetAdc() ) - { - uIdxBest = uHitP1; - uBestAdc = fvHitsS1P[ uHitP1 ].GetAdc(); - } // if( uBestAdc < fvHitsS1P[ uHitP1 ].GetAdc() ) -*/ - }// if( fdCoincMinSts1 < dDtSts1 && dDtSts1 < fdCoincMaxSts1 ) - } // for( UInt_t uHitP1 = 0; uHitP1 < fvHitsS1P.size(); ++uHitP1 ) - - if( fvHitsS1P.size() != uIdxBest ) - fhChanMapBestMatchS1->Fill( fvHitsS1N[ uHitN1 ].GetChan(), fvHitsS1P[ uIdxBest ].GetChan() ); - } // for( UInt_t uHitN1 = 0; uHitN1 < fvHitsS1N.size(); ++uHitN1 ) - for( UInt_t uHitN2 = 0; uHitN2 < fvHitsS2N.size(); ++uHitN2 ) - { - Double_t dDtBestPair = 1e12; -// UInt_t uBestAdc = 0; - UInt_t uIdxBest = fvHitsS2P.size(); - for( UInt_t uHitP2 = 0; uHitP2 < fvHitsS2P.size(); ++uHitP2 ) - { - Double_t dDtSts2 = ( static_cast< Double_t >( fvHitsS2P[ uHitP2 ].GetTs() ) - - static_cast< Double_t >( fvHitsS2N[ uHitN2 ].GetTs() ) - ) * stsxyter::kdClockCycleNs; - - fhDtAllPairsS2->Fill( dDtSts2 ); - if( fdCoincMinSts2 < dDtSts2 && dDtSts2 < fdCoincMaxSts2 ) - { - fhChanMapAllMatchS2->Fill( fvHitsS2N[ uHitN2 ].GetChan(), fvHitsS2P[ uHitP2 ].GetChan() ); - - if( TMath::Abs( dDtSts2 - fdCoincCenterSts2 ) < dDtBestPair ) - { - uIdxBest = uHitP2; - dDtBestPair = TMath::Abs( dDtSts2 - fdCoincCenterSts2 ); - } // if( TMath::Abs( dDtSts2 - fdCoincCenterSts2 ) < dDtBestPair ) -/* - if( uBestAdc < fvHitsS2P[ uHitP2 ].GetAdc() ) - { - uIdxBest = uHitP2; - uBestAdc = fvHitsS2P[ uHitP2 ].GetAdc(); - } // if( uBestAdc < fvHitsS1P[ uHitP1 ].GetAdc() ) -*/ - }// if( fdCoincMinSts2 < dDtSts2 && dDtSts2 < fdCoincMaxSts2 ) - } // for( UInt_t uHitP2 = 0; uHitP2 < fvHitsS2P.size(); ++uHitP2 ) - - if( fvHitsS2P.size() != uIdxBest ) - fhChanMapBestMatchS2->Fill( fvHitsS2N[ uHitN2 ].GetChan(), fvHitsS2P[ uIdxBest ].GetChan() ); - } // for( UInt_t uHitN2 = 0; uHitN2 < fvHitsS2N.size(); ++uHitN2 ) - - /// Build Hodoscope pairs (~tracks) - UInt_t uFirstMatchH2 = 0; - for( UInt_t uPairH1 = 0; uPairH1 < fvPairsH1.size(); ++uPairH1 ) - { - UInt_t uNbH2CoincPerH1 = 0; -// Double_t dDtHodo = 1e12; - Double_t dDtBestPair = 1e12; - UInt_t uBestH2 = fvPairsH1.size(); - - for( UInt_t uPairH2 = uFirstMatchH2; uPairH2 < fvPairsH2.size(); ++uPairH2 ) - { - Double_t dDt = ( static_cast< Double_t >( fvPairsH2[ uPairH2 ].first.GetTs() ) - + static_cast< Double_t >( fvPairsH2[ uPairH2 ].second.GetTs() ) - - static_cast< Double_t >( fvPairsH1[ uPairH1 ].first.GetTs() ) - - static_cast< Double_t >( fvPairsH1[ uPairH1 ].second.GetTs() ) - ) * stsxyter::kdClockCycleNs / 2.0; - - if( fdCoincMinHodoBoth < dDt ) - { - if( dDt < fdCoincMaxHodoBoth ) - { - uNbH2CoincPerH1 ++; - if( TMath::Abs( dDt - fdCoincCenterHodo ) < dDtBestPair ) - { - uBestH2 = uPairH2; - dDtBestPair = TMath::Abs( dDt - fdCoincCenterHodo ); - } // if( TMath::Abs( dDt - fdCoincCenterHodo ) < dDtBestPair ) - } // if( dDt < fdCoincMaxHodoBoth ) - else break; - } // if( fdCoincMinHodoBoth < dDt ) - else uFirstMatchH2 = uPairH2; - } // for( UInt_t uPairH2 = uFirstMatchH2; uPairH2 < fvPairsH2.size(); ++uPairH2 ) - if( 0 < uNbH2CoincPerH1 ) - { - fvPairsHodo.push_back( std::pair< UInt_t, UInt_t >( uPairH1, uBestH2 ) ); - - fhDtBestPairsHodo->Fill( ( static_cast< Double_t >( fvPairsH2[ uBestH2 ].first.GetTs() ) - + static_cast< Double_t >( fvPairsH2[ uBestH2 ].second.GetTs() ) - - static_cast< Double_t >( fvPairsH1[ uPairH1 ].first.GetTs() ) - - static_cast< Double_t >( fvPairsH1[ uPairH1 ].second.GetTs() ) - ) * stsxyter::kdClockCycleNs / 2.0 ); - - Double_t dPosX, dPosY; - ComputeCoordinatesHodo1( fvPairsH1[ uPairH1 ].first.GetChan(), fvPairsH1[ uPairH1 ].second.GetChan(), dPosX, dPosY ); - fhMapBestPairsHodo_H1->Fill( dPosX, dPosY ); - - ComputeCoordinatesHodo2( fvPairsH2[ uBestH2 ].first.GetChan(), fvPairsH2[ uBestH2 ].second.GetChan(), dPosX, dPosY ); - fhMapBestPairsHodo_H2->Fill( dPosX, dPosY ); - } // if( 0 < uNbH2CoincPerH1 ) - fhNbH2CoincPerH1->Fill( uNbH2CoincPerH1 ); - } // for( UInt_t uPairH1 = 0; uPairH1 < fvPairsH1.size(); ++uPairH1 ) - - /// Loop on Hodoscope Pairs and check for each if a sensor pair is matching - UInt_t uFirstMatchS1 = 0; - UInt_t uFirstMatchS2 = 0; -// UInt_t uFirstMatchS1S2 = 0; -// UInt_t uFirstMatchS2S1 = 0; - UInt_t uFirstMatchS1N = 0; - UInt_t uFirstMatchS1P = 0; - UInt_t uFirstMatchS2N = 0; - UInt_t uFirstMatchS2P = 0; - for( UInt_t uPairHodo = 0; uPairHodo < fvPairsHodo.size(); ++uPairHodo ) - { - /// Compute Hodo pair coordinates - Double_t dPosXH1, dPosYH1; - ComputeCoordinatesHodo1( fvPairsH1[ fvPairsHodo[ uPairHodo ].first ].first.GetChan(), - fvPairsH1[ fvPairsHodo[ uPairHodo ].first ].second.GetChan(), - dPosXH1, dPosYH1 ); - - Double_t dPosXH2, dPosYH2; - ComputeCoordinatesHodo2( fvPairsH2[ fvPairsHodo[ uPairHodo ].second ].first.GetChan(), - fvPairsH2[ fvPairsHodo[ uPairHodo ].second ].second.GetChan(), - dPosXH2, dPosYH2 ); - - /// Check if projection within STS 1 active area - Double_t dProjXS1, dProjYS1; - ComputeProjectionSensor1( dPosXH1, dPosYH1, dPosXH2, dPosYH2, - dProjXS1, dProjYS1 ); - Bool_t bHodoTrkInS1 = ( kTRUE == fbDeadCorrEna ? - CheckPointInsideSensor1NoDead( dProjXS1 - fdOffsetS1X, dProjYS1 - fdOffsetS1Y) : - CheckPointInsideSensor1( dProjXS1 - fdOffsetS1X, dProjYS1 - fdOffsetS1Y) ); - fhMapBestPairsHodo_ProjS1->Fill( dProjXS1, dProjYS1 ); - - /// Check if projection within STS 2 active area - Double_t dProjXS2, dProjYS2; - ComputeProjectionSensor2( dPosXH1, dPosYH1, dPosXH2, dPosYH2, - dProjXS2, dProjYS2 ); - Bool_t bHodoTrkInS2 = ( kTRUE == fbDeadCorrEna ? - CheckPointInsideSensor2NoDead( dProjXS2 - fdOffsetS2X, dProjYS2 - fdOffsetS2Y): - CheckPointInsideSensor2( dProjXS2 - fdOffsetS2X, dProjYS2 - fdOffsetS2Y) ); - fhMapBestPairsHodo_ProjS2->Fill( dProjXS2, dProjYS2 ); - - /// Test coincidences with the P or N sides of the sensors - Double_t dDt_Side; - Bool_t bTestCoincFound = kFALSE; - /// S1N - for( UInt_t uHitS1N = uFirstMatchS1N; uHitS1N < fvHitsS1N.size(); ++uHitS1N ) - { - dDt_Side = ( static_cast< Double_t >( fvHitsS1N[ uHitS1N ].GetTs() ) - - ( static_cast< Double_t >( fvPairsH1[ fvPairsHodo[ uPairHodo ].first ].first.GetTs() ) - + static_cast< Double_t >( fvPairsH1[ fvPairsHodo[ uPairHodo ].first ].second.GetTs() ) - + static_cast< Double_t >( fvPairsH2[ fvPairsHodo[ uPairHodo ].second ].first.GetTs() ) - + static_cast< Double_t >( fvPairsH2[ fvPairsHodo[ uPairHodo ].second ].second.GetTs() ) - ) / 4.0 - ) * stsxyter::kdClockCycleNs; - if( fdCoincMinHodoS1 < dDt_Side ) - { - if( dDt_Side < fdCoincMaxHodoS1 ) - { - bTestCoincFound = kTRUE; - break; - } // if( dDt_Side < fdCoincMaxHodoS1 ) - else break; - } // if( fdCoincMinHodoS1 < dDt_Side ) - else uFirstMatchS1N = uHitS1N; - } // for( UInt uHitS1N = uFirstMatchS1N; uHitS1N < fvHitsS1N.size(); ++uHitS1N ) - if( kTRUE == bTestCoincFound ) - fhTestMapHodoS1N->Fill( dProjXS1, dProjYS1, 1.0 ); - else fhTestMapHodoS1N->Fill( dProjXS1, dProjYS1, 0.0 ); - /// S1P - bTestCoincFound = kFALSE; - for( UInt_t uHitS1P = uFirstMatchS1P; uHitS1P < fvHitsS1P.size(); ++uHitS1P ) - { - dDt_Side = ( static_cast< Double_t >( fvHitsS1P[ uHitS1P ].GetTs() ) - - ( static_cast< Double_t >( fvPairsH1[ fvPairsHodo[ uPairHodo ].first ].first.GetTs() ) - + static_cast< Double_t >( fvPairsH1[ fvPairsHodo[ uPairHodo ].first ].second.GetTs() ) - + static_cast< Double_t >( fvPairsH2[ fvPairsHodo[ uPairHodo ].second ].first.GetTs() ) - + static_cast< Double_t >( fvPairsH2[ fvPairsHodo[ uPairHodo ].second ].second.GetTs() ) - ) / 4.0 - ) * stsxyter::kdClockCycleNs; - if( fdCoincMinHodoS1 < dDt_Side ) - { - if( dDt_Side < fdCoincMaxHodoS1 ) - { - bTestCoincFound = kTRUE; - break; - } // if( dDt_Side < fdCoincMaxHodoS1 ) - else break; - } // if( fdCoincMinHodoS1 < dDt_Side ) - else uFirstMatchS1P = uHitS1P; - } // for( UInt uHitS1P = uFirstMatchS1P; uHitS1P < fvHitsS1P.size(); ++uHitS1P ) - if( kTRUE == bTestCoincFound ) - fhTestMapHodoS1P->Fill( dProjXS1, dProjYS1, 1.0 ); - else fhTestMapHodoS1P->Fill( dProjXS1, dProjYS1, 0.0 ); - /// S2N - bTestCoincFound = kFALSE; - for( UInt_t uHitS2N = uFirstMatchS2N; uHitS2N < fvHitsS2N.size(); ++uHitS2N ) - { - dDt_Side = ( static_cast< Double_t >( fvHitsS2N[ uHitS2N ].GetTs() ) - - ( static_cast< Double_t >( fvPairsH1[ fvPairsHodo[ uPairHodo ].first ].first.GetTs() ) - + static_cast< Double_t >( fvPairsH1[ fvPairsHodo[ uPairHodo ].first ].second.GetTs() ) - + static_cast< Double_t >( fvPairsH2[ fvPairsHodo[ uPairHodo ].second ].first.GetTs() ) - + static_cast< Double_t >( fvPairsH2[ fvPairsHodo[ uPairHodo ].second ].second.GetTs() ) - ) / 4.0 - ) * stsxyter::kdClockCycleNs; - if( fdCoincMinHodoS2 < dDt_Side ) - { - if( dDt_Side < fdCoincMaxHodoS2 ) - { - bTestCoincFound = kTRUE; - break; - } // if( dDt_Side < fdCoincMaxHodoS2 ) - else break; - } // if( fdCoincMinHodoS2 < dDt_Side ) - else uFirstMatchS2N = uHitS2N; - } // for( UInt uHitS2N = uFirstMatchS2N; uHitS2N < fvHitsS2N.size(); ++uHitS2N ) - if( kTRUE == bTestCoincFound ) - fhTestMapHodoS2N->Fill( dProjXS1, dProjYS1, 1.0 ); - else fhTestMapHodoS2N->Fill( dProjXS1, dProjYS1, 0.0 ); - /// S2P - bTestCoincFound = kFALSE; - for( UInt_t uHitS2P = uFirstMatchS2P; uHitS2P < fvHitsS2P.size(); ++uHitS2P ) - { - dDt_Side = ( static_cast< Double_t >( fvHitsS2P[ uHitS2P ].GetTs() ) - - ( static_cast< Double_t >( fvPairsH1[ fvPairsHodo[ uPairHodo ].first ].first.GetTs() ) - + static_cast< Double_t >( fvPairsH1[ fvPairsHodo[ uPairHodo ].first ].second.GetTs() ) - + static_cast< Double_t >( fvPairsH2[ fvPairsHodo[ uPairHodo ].second ].first.GetTs() ) - + static_cast< Double_t >( fvPairsH2[ fvPairsHodo[ uPairHodo ].second ].second.GetTs() ) - ) / 4.0 - ) * stsxyter::kdClockCycleNs; - if( fdCoincMinHodoS2 < dDt_Side ) - { - if( dDt_Side < fdCoincMaxHodoS2 ) - { - bTestCoincFound = kTRUE; - break; - } // if( dDt_Side < fdCoincMaxHodoS2 ) - else break; - } // if( fdCoincMinHodoS2 < dDt_Side ) - else uFirstMatchS2P = uHitS2P; - } // for( UInt uHitS2P = uFirstMatchS2P; uHitS2P < fvHitsS2P.size(); ++uHitS2P ) - if( kTRUE == bTestCoincFound ) - fhTestMapHodoS2P->Fill( dProjXS1, dProjYS1, 1.0 ); - else fhTestMapHodoS2P->Fill( dProjXS1, dProjYS1, 0.0 ); - - /// Coincidences with S1 - UInt_t uNbS1CoincPerHodo = 0; -// Double_t dDtS1 = 1e12; - Double_t dDtBestPairS1 = 1e12; - UInt_t uBestS1 = fvPairsS1.size(); - for( UInt_t uPairS1 = uFirstMatchS1; uPairS1 < fvPairsS1.size(); ++uPairS1 ) - { - Double_t dDt = ( ( static_cast< Double_t >( fvPairsS1[ uPairS1 ].first.GetTs() ) - + static_cast< Double_t >( fvPairsS1[ uPairS1 ].second.GetTs() ) - ) / 2.0 - - ( static_cast< Double_t >( fvPairsH1[ fvPairsHodo[ uPairHodo ].first ].first.GetTs() ) - + static_cast< Double_t >( fvPairsH1[ fvPairsHodo[ uPairHodo ].first ].second.GetTs() ) - + static_cast< Double_t >( fvPairsH2[ fvPairsHodo[ uPairHodo ].second ].first.GetTs() ) - + static_cast< Double_t >( fvPairsH2[ fvPairsHodo[ uPairHodo ].second ].second.GetTs() ) - ) / 4.0 - ) * stsxyter::kdClockCycleNs; - - fhDtAllPairsHodoS1->Fill( dDt ); - if( fdCoincMinHodoS1 < dDt ) - { - if( dDt < fdCoincMaxHodoS1 ) - { - uNbS1CoincPerHodo ++; - if( TMath::Abs( dDt - fdCoincCenter ) < dDtBestPairS1 ) - { - uBestS1 = uPairS1; - dDtBestPairS1 = TMath::Abs( dDt - fdCoincCenter ); - } // if( TMath::Abs( dDt - fdCoincCenter ) < dDtBestPairS1 ) - } // if( dDt < fdCoincMaxHodoS1 ) -// else break; - } // if( fdCoincMinHodoS1 < dDt ) -// else uFirstMatchS1 = uPairS1; - } // for( UInt_t uPairS1 = uFirstMatchS1; uPairS1 < fvPairsS1.size(); ++uPairS1 ) - - /// Coincidences with S2 - UInt_t uNbS2CoincPerHodo = 0; -// Double_t dDtS2 = 1e12; - Double_t dDtBestPairS2 = 1e12; - UInt_t uBestS2 = fvPairsS2.size(); - for( UInt_t uPairS2 = uFirstMatchS2; uPairS2 < fvPairsS2.size(); ++uPairS2 ) - { - Double_t dDt = ( ( static_cast< Double_t >( fvPairsS2[ uPairS2 ].first.GetTs() ) - + static_cast< Double_t >( fvPairsS2[ uPairS2 ].second.GetTs() ) - ) / 2.0 - - ( static_cast< Double_t >( fvPairsH1[ fvPairsHodo[ uPairHodo ].first ].first.GetTs() ) - + static_cast< Double_t >( fvPairsH1[ fvPairsHodo[ uPairHodo ].first ].second.GetTs() ) - + static_cast< Double_t >( fvPairsH2[ fvPairsHodo[ uPairHodo ].second ].first.GetTs() ) - + static_cast< Double_t >( fvPairsH2[ fvPairsHodo[ uPairHodo ].second ].second.GetTs() ) - ) / 4.0 - ) * stsxyter::kdClockCycleNs; - - fhDtAllPairsHodoS2->Fill( dDt ); - if( fdCoincMinHodoS2 < dDt ) - { - if( dDt < fdCoincMaxHodoS2 ) - { - uNbS2CoincPerHodo ++; - if( TMath::Abs( dDt - fdCoincCenter ) < dDtBestPairS2 ) - { - uBestS2 = uPairS2; - dDtBestPairS2 = TMath::Abs( dDt - fdCoincCenter ); - } // if( TMath::Abs( dDt - fdCoincCenter ) < dDtBestPairS2 ) - } // if( dDt < fdCoincMaxHodoS2 ) -// else break; - } // if( fdCoincMinHodoS2 < dDt ) -// else uFirstMatchS2 = uPairS2; - } // for( UInt_t uPairS2 = uFirstMatchS2; uPairS2 < fvPairsS2.size(); ++uPairS2 ) - - /// Histos filling - /// Without Geo cut - fhNbS1CoincPerHodo->Fill( uNbS1CoincPerHodo ); - if( 0 < uNbS1CoincPerHodo ) - { - fvPairsHodoS1.push_back( std::pair< UInt_t, UInt_t >( uPairHodo, uBestS1 ) ); - - fhDtBestPairsHodoS1->Fill( ( ( static_cast< Double_t >( fvPairsS1[ uBestS1 ].first.GetTs() ) - + static_cast< Double_t >( fvPairsS1[ uBestS1 ].second.GetTs() ) - ) / 2.0 - - ( static_cast< Double_t >( fvPairsH1[ fvPairsHodo[ uPairHodo ].first ].first.GetTs() ) - + static_cast< Double_t >( fvPairsH1[ fvPairsHodo[ uPairHodo ].first ].second.GetTs() ) - + static_cast< Double_t >( fvPairsH2[ fvPairsHodo[ uPairHodo ].second ].first.GetTs() ) - + static_cast< Double_t >( fvPairsH2[ fvPairsHodo[ uPairHodo ].second ].second.GetTs() ) - ) / 4.0 - ) * stsxyter::kdClockCycleNs ); - - fhMapBestPairsHodoS1_H1->Fill( dPosXH1, dPosYH1 ); - fhMapBestPairsHodoS1_H2->Fill( dPosXH2, dPosYH2 ); - - Double_t dPosXS1, dPosYS1; - ComputeCoordinatesSensor1( fvPairsS1[ uBestS1 ].first.GetChan(), - fvPairsS1[ uBestS1 ].second.GetChan(), - dPosXS1, dPosYS1 ); - fhMapBestPairsHodoS1_S1->Fill( dPosXS1, dPosYS1 ); - // Apply Position Offsets - dPosXS1 += fdOffsetS1X; - dPosYS1 += fdOffsetS1Y; - - fhMapBestPairsHodoS1_Proj->Fill( dProjXS1, dProjYS1 ); - fhResidualsBestPairsHodoS1->Fill( dPosXS1 - dProjXS1, dPosYS1 - dProjYS1 ); - - fhAdcRawBestPairsHodoS1N->Fill( fvPairsS1[ uBestS1 ].first.GetChan(), fvPairsS1[ uBestS1 ].first.GetAdc() ); - fhAdcRawBestPairsHodoS1P->Fill( fvPairsS1[ uBestS1 ].second.GetChan(), fvPairsS1[ uBestS1 ].second.GetAdc() ); - - /// Check for coincidences with S2 knowing that at least 1 matching S1 hit was found - fhNbS2CoincPerHodoS1->Fill( uNbS2CoincPerHodo ); - if( 0 < uNbS2CoincPerHodo ) - { - fvPairsHodoS2S1.push_back( std::pair< UInt_t, UInt_t >( uPairHodo, uBestS2 ) ); - - fhDtBestPairsHodoS2S1->Fill( ( ( static_cast< Double_t >( fvPairsS2[ uBestS2 ].first.GetTs() ) - + static_cast< Double_t >( fvPairsS2[ uBestS2 ].second.GetTs() ) - ) / 2.0 - - ( static_cast< Double_t >( fvPairsH1[ fvPairsHodo[ uPairHodo ].first ].first.GetTs() ) - + static_cast< Double_t >( fvPairsH1[ fvPairsHodo[ uPairHodo ].first ].second.GetTs() ) - + static_cast< Double_t >( fvPairsH2[ fvPairsHodo[ uPairHodo ].second ].first.GetTs() ) - + static_cast< Double_t >( fvPairsH2[ fvPairsHodo[ uPairHodo ].second ].second.GetTs() ) - ) / 4.0 - ) * stsxyter::kdClockCycleNs ); - - fhMapBestPairsHodoS2S1_H1->Fill( dPosXH1, dPosYH1 ); - fhMapBestPairsHodoS2S1_H2->Fill( dPosXH2, dPosYH2 ); - - Double_t dPosXS2, dPosYS2; - ComputeCoordinatesSensor2( fvPairsS2[ uBestS2 ].first.GetChan(), - fvPairsS2[ uBestS2 ].second.GetChan(), - dPosXS2, dPosYS2 ); - fhMapBestPairsHodoS2S1_S2->Fill( dPosXS2, dPosYS2 ); - // Apply Position Offsets - dPosXS2 += fdOffsetS2X; - dPosYS2 += fdOffsetS2Y; - - - fhMapBestPairsHodoS2S1_Proj->Fill( dProjXS2, dProjYS2 ); - fhResidualsBestPairsHodoS2S1->Fill( dPosXS2 - dProjXS2, dPosYS2 - dProjYS2 ); - - fhAdcRawBestPairsHodoS2S1N->Fill( fvPairsS2[ uBestS2 ].first.GetChan(), fvPairsS2[ uBestS2 ].first.GetAdc() ); - fhAdcRawBestPairsHodoS2S1P->Fill( fvPairsS2[ uBestS2 ].second.GetChan(), fvPairsS2[ uBestS2 ].second.GetAdc() ); - } // if( 0 < uNbS2CoincPerHodo ) - } // if( 0 < uNbS1CoincPerHodo ) - - fhNbS2CoincPerHodo->Fill( uNbS2CoincPerHodo ); - if( 0 < uNbS2CoincPerHodo ) - { - fvPairsHodoS2.push_back( std::pair< UInt_t, UInt_t >( uPairHodo, uBestS2 ) ); - - fhDtBestPairsHodoS2->Fill( ( ( static_cast< Double_t >( fvPairsS2[ uBestS2 ].first.GetTs() ) - + static_cast< Double_t >( fvPairsS2[ uBestS2 ].second.GetTs() ) - ) / 2.0 - - ( static_cast< Double_t >( fvPairsH1[ fvPairsHodo[ uPairHodo ].first ].first.GetTs() ) - + static_cast< Double_t >( fvPairsH1[ fvPairsHodo[ uPairHodo ].first ].second.GetTs() ) - + static_cast< Double_t >( fvPairsH2[ fvPairsHodo[ uPairHodo ].second ].first.GetTs() ) - + static_cast< Double_t >( fvPairsH2[ fvPairsHodo[ uPairHodo ].second ].second.GetTs() ) - ) / 4.0 - ) * stsxyter::kdClockCycleNs ); - - fhMapBestPairsHodoS2_H1->Fill( dPosXH1, dPosYH1 ); - fhMapBestPairsHodoS2_H2->Fill( dPosXH2, dPosYH2 ); - - Double_t dPosXS2, dPosYS2; - ComputeCoordinatesSensor2( fvPairsS2[ uBestS2 ].first.GetChan(), - fvPairsS2[ uBestS2 ].second.GetChan(), - dPosXS2, dPosYS2 ); - fhMapBestPairsHodoS2_S2->Fill( dPosXS2, dPosYS2 ); - // Apply Position Offsets - dPosXS2 += fdOffsetS2X; - dPosYS2 += fdOffsetS2Y; - - fhMapBestPairsHodoS2_Proj->Fill( dProjXS2, dProjYS2 ); - fhResidualsBestPairsHodoS2->Fill( dPosXS2 - dProjXS2, dPosYS2 - dProjYS2 ); - - fhAdcRawBestPairsHodoS2N->Fill( fvPairsS2[ uBestS2 ].first.GetChan(), fvPairsS2[ uBestS2 ].first.GetAdc() ); - fhAdcRawBestPairsHodoS2P->Fill( fvPairsS2[ uBestS2 ].second.GetChan(), fvPairsS2[ uBestS2 ].second.GetAdc() ); - - /// Check for coincidences with S1 knowing that at least 1 matching S2 hit was found - fhNbS1CoincPerHodoS2->Fill( uNbS1CoincPerHodo ); - if( 0 < uNbS1CoincPerHodo ) - { - fvPairsHodoS1S2.push_back( std::pair< UInt_t, UInt_t >( uPairHodo, uBestS1 ) ); - - fhDtBestPairsHodoS1S2->Fill( ( ( static_cast< Double_t >( fvPairsS1[ uBestS1 ].first.GetTs() ) - + static_cast< Double_t >( fvPairsS1[ uBestS1 ].second.GetTs() ) - ) / 2.0 - - ( static_cast< Double_t >( fvPairsH1[ fvPairsHodo[ uPairHodo ].first ].first.GetTs() ) - + static_cast< Double_t >( fvPairsH1[ fvPairsHodo[ uPairHodo ].first ].second.GetTs() ) - + static_cast< Double_t >( fvPairsH2[ fvPairsHodo[ uPairHodo ].second ].first.GetTs() ) - + static_cast< Double_t >( fvPairsH2[ fvPairsHodo[ uPairHodo ].second ].second.GetTs() ) - ) / 4.0 - ) * stsxyter::kdClockCycleNs ); - - fhMapBestPairsHodoS1S2_H1->Fill( dPosXH1, dPosYH1 ); - fhMapBestPairsHodoS1S2_H2->Fill( dPosXH2, dPosYH2 ); - - Double_t dPosXS1, dPosYS1; - ComputeCoordinatesSensor1( fvPairsS1[ uBestS1 ].first.GetChan(), - fvPairsS1[ uBestS1 ].second.GetChan(), - dPosXS1, dPosYS1 ); - fhMapBestPairsHodoS1S2_S1->Fill( dPosXS1, dPosYS1 ); - // Apply Position Offsets - dPosXS1 += fdOffsetS1X; - dPosYS1 += fdOffsetS1Y; - - fhMapBestPairsHodoS1S2_Proj->Fill( dProjXS1, dProjYS1 ); - fhResidualsBestPairsHodoS1S2->Fill( dPosXS1 - dProjXS1, dPosYS1 - dProjYS1 ); - - fhAdcRawBestPairsHodoS1S2N->Fill( fvPairsS1[ uBestS1 ].first.GetChan(), fvPairsS1[ uBestS1 ].first.GetAdc() ); - fhAdcRawBestPairsHodoS1S2P->Fill( fvPairsS1[ uBestS1 ].second.GetChan(), fvPairsS1[ uBestS1 ].second.GetAdc() ); - } // if( 0 < uNbS1CoincPerHodo ) - } // if( 0 < uNbS2CoincPerHodo ) - /// With Geo cut - if( bHodoTrkInS1 ) - { - fhMapBestPairsHodoGeoCutS1_H1->Fill( dPosXH1, dPosYH1 ); - fhMapBestPairsHodoGeoCutS1_H2->Fill( dPosXH2, dPosYH2 ); - fhMapBestPairsHodoGeoCutS1_Proj->Fill( dProjXS1, dProjYS1 ); - - fhNbS1CoincPerHodoGeoCut->Fill( uNbS1CoincPerHodo ); - if( 0 < uNbS1CoincPerHodo ) - { - fvPairsHodoS1.push_back( std::pair< UInt_t, UInt_t >( uPairHodo, uBestS1 ) ); - - fhDtBestPairsHodoS1GeoCut->Fill( ( ( static_cast< Double_t >( fvPairsS1[ uBestS1 ].first.GetTs() ) - + static_cast< Double_t >( fvPairsS1[ uBestS1 ].second.GetTs() ) - ) / 2.0 - - ( static_cast< Double_t >( fvPairsH1[ fvPairsHodo[ uPairHodo ].first ].first.GetTs() ) - + static_cast< Double_t >( fvPairsH1[ fvPairsHodo[ uPairHodo ].first ].second.GetTs() ) - + static_cast< Double_t >( fvPairsH2[ fvPairsHodo[ uPairHodo ].second ].first.GetTs() ) - + static_cast< Double_t >( fvPairsH2[ fvPairsHodo[ uPairHodo ].second ].second.GetTs() ) - ) / 4.0 - ) * stsxyter::kdClockCycleNs ); - - fhMapBestPairsHodoS1GeoCut_H1->Fill( dPosXH1, dPosYH1 ); - fhMapBestPairsHodoS1GeoCut_H2->Fill( dPosXH2, dPosYH2 ); - - Double_t dPosXS1, dPosYS1; - ComputeCoordinatesSensor1( fvPairsS1[ uBestS1 ].first.GetChan(), - fvPairsS1[ uBestS1 ].second.GetChan(), - dPosXS1, dPosYS1 ); - fhMapBestPairsHodoS1GeoCut_S1->Fill( dPosXS1, dPosYS1 ); - // Apply Position Offsets - dPosXS1 += fdOffsetS1X; - dPosYS1 += fdOffsetS1Y; - - fhMapBestPairsHodoS1GeoCut_Proj->Fill( dProjXS1, dProjYS1 ); - fhResidualsBestPairsHodoS1GeoCut->Fill( dPosXS1 - dProjXS1, dPosYS1 - dProjYS1 ); - - fhAdcRawBestPairsHodoS1N->Fill( fvPairsS1[ uBestS1 ].first.GetChan(), fvPairsS1[ uBestS1 ].first.GetAdc() ); - fhAdcRawBestPairsHodoS1P->Fill( fvPairsS1[ uBestS1 ].second.GetChan(), fvPairsS1[ uBestS1 ].second.GetAdc() ); - - if( bHodoTrkInS2 ) - { - /// Check for coincidences with S2 knowing that at least 1 matching S1 hit was found - fhNbS2CoincPerHodoS1GeoCut->Fill( uNbS2CoincPerHodo ); - if( 0 < uNbS2CoincPerHodo ) - { - fvPairsHodoS2S1.push_back( std::pair< UInt_t, UInt_t >( uPairHodo, uBestS2 ) ); - - fhDtBestPairsHodoS2S1GeoCut->Fill( ( ( static_cast< Double_t >( fvPairsS2[ uBestS2 ].first.GetTs() ) - + static_cast< Double_t >( fvPairsS2[ uBestS2 ].second.GetTs() ) - ) / 2.0 - - ( static_cast< Double_t >( fvPairsH1[ fvPairsHodo[ uPairHodo ].first ].first.GetTs() ) - + static_cast< Double_t >( fvPairsH1[ fvPairsHodo[ uPairHodo ].first ].second.GetTs() ) - + static_cast< Double_t >( fvPairsH2[ fvPairsHodo[ uPairHodo ].second ].first.GetTs() ) - + static_cast< Double_t >( fvPairsH2[ fvPairsHodo[ uPairHodo ].second ].second.GetTs() ) - ) / 4.0 - ) * stsxyter::kdClockCycleNs ); - - fhMapBestPairsHodoS2S1GeoCut_H1->Fill( dPosXH1, dPosYH1 ); - fhMapBestPairsHodoS2S1GeoCut_H2->Fill( dPosXH2, dPosYH2 ); - - Double_t dPosXS2, dPosYS2; - ComputeCoordinatesSensor2( fvPairsS2[ uBestS2 ].first.GetChan(), - fvPairsS2[ uBestS2 ].second.GetChan(), - dPosXS2, dPosYS2 ); - fhMapBestPairsHodoS2S1GeoCut_S2->Fill( dPosXS2, dPosYS2 ); - // Apply Position Offsets - dPosXS2 += fdOffsetS2X; - dPosYS2 += fdOffsetS2Y; - - - fhMapBestPairsHodoS2S1GeoCut_Proj->Fill( dProjXS2, dProjYS2 ); - fhResidualsBestPairsHodoS2S1GeoCut->Fill( dPosXS2 - dProjXS2, dPosYS2 - dProjYS2 ); - - fhAdcRawBestPairsHodoS2S1N->Fill( fvPairsS2[ uBestS2 ].first.GetChan(), fvPairsS2[ uBestS2 ].first.GetAdc() ); - fhAdcRawBestPairsHodoS2S1P->Fill( fvPairsS2[ uBestS2 ].second.GetChan(), fvPairsS2[ uBestS2 ].second.GetAdc() ); - } // if( 0 < uNbS2CoincPerHodo ) - } // if( bHodoTrkInS2 ) - } // if( 0 < uNbS1CoincPerHodo ) - } // if( bHodoTrkInS1 ) - - if( bHodoTrkInS2 ) - { - fhMapBestPairsHodoGeoCutS2_H1->Fill( dPosXH1, dPosYH1 ); - fhMapBestPairsHodoGeoCutS2_H2->Fill( dPosXH2, dPosYH2 ); - fhMapBestPairsHodoGeoCutS2_Proj->Fill( dProjXS2, dProjYS2 ); - - fhNbS2CoincPerHodoGeoCut->Fill( uNbS2CoincPerHodo ); - if( 0 < uNbS2CoincPerHodo ) - { - fvPairsHodoS2.push_back( std::pair< UInt_t, UInt_t >( uPairHodo, uBestS2 ) ); - - fhDtBestPairsHodoS2GeoCut->Fill( ( ( static_cast< Double_t >( fvPairsS2[ uBestS2 ].first.GetTs() ) - + static_cast< Double_t >( fvPairsS2[ uBestS2 ].second.GetTs() ) - ) / 2.0 - - ( static_cast< Double_t >( fvPairsH1[ fvPairsHodo[ uPairHodo ].first ].first.GetTs() ) - + static_cast< Double_t >( fvPairsH1[ fvPairsHodo[ uPairHodo ].first ].second.GetTs() ) - + static_cast< Double_t >( fvPairsH2[ fvPairsHodo[ uPairHodo ].second ].first.GetTs() ) - + static_cast< Double_t >( fvPairsH2[ fvPairsHodo[ uPairHodo ].second ].second.GetTs() ) - ) / 4.0 - ) * stsxyter::kdClockCycleNs ); - - fhMapBestPairsHodoS2GeoCut_H1->Fill( dPosXH1, dPosYH1 ); - fhMapBestPairsHodoS2GeoCut_H2->Fill( dPosXH2, dPosYH2 ); - - Double_t dPosXS2, dPosYS2; - ComputeCoordinatesSensor2( fvPairsS2[ uBestS2 ].first.GetChan(), - fvPairsS2[ uBestS2 ].second.GetChan(), - dPosXS2, dPosYS2 ); - fhMapBestPairsHodoS2GeoCut_S2->Fill( dPosXS2, dPosYS2 ); - // Apply Position Offsets - dPosXS2 += fdOffsetS2X; - dPosYS2 += fdOffsetS2Y; - - fhMapBestPairsHodoS2GeoCut_Proj->Fill( dProjXS2, dProjYS2 ); - fhResidualsBestPairsHodoS2GeoCut->Fill( dPosXS2 - dProjXS2, dPosYS2 - dProjYS2 ); - - fhAdcRawBestPairsHodoS2N->Fill( fvPairsS2[ uBestS2 ].first.GetChan(), fvPairsS2[ uBestS2 ].first.GetAdc() ); - fhAdcRawBestPairsHodoS2P->Fill( fvPairsS2[ uBestS2 ].second.GetChan(), fvPairsS2[ uBestS2 ].second.GetAdc() ); - - if( bHodoTrkInS1 ) - { - /// Check for coincidences with S1 knowing that at least 1 matching S2 hit was found - fhNbS1CoincPerHodoS2GeoCut->Fill( uNbS1CoincPerHodo ); - if( 0 < uNbS1CoincPerHodo ) - { - fvPairsHodoS1S2.push_back( std::pair< UInt_t, UInt_t >( uPairHodo, uBestS1 ) ); - - fhDtBestPairsHodoS1S2GeoCut->Fill( ( ( static_cast< Double_t >( fvPairsS1[ uBestS1 ].first.GetTs() ) - + static_cast< Double_t >( fvPairsS1[ uBestS1 ].second.GetTs() ) - ) / 2.0 - - ( static_cast< Double_t >( fvPairsH1[ fvPairsHodo[ uPairHodo ].first ].first.GetTs() ) - + static_cast< Double_t >( fvPairsH1[ fvPairsHodo[ uPairHodo ].first ].second.GetTs() ) - + static_cast< Double_t >( fvPairsH2[ fvPairsHodo[ uPairHodo ].second ].first.GetTs() ) - + static_cast< Double_t >( fvPairsH2[ fvPairsHodo[ uPairHodo ].second ].second.GetTs() ) - ) / 4.0 - ) * stsxyter::kdClockCycleNs ); - - fhMapBestPairsHodoS1S2GeoCut_H1->Fill( dPosXH1, dPosYH1 ); - fhMapBestPairsHodoS1S2GeoCut_H2->Fill( dPosXH2, dPosYH2 ); - - Double_t dPosXS1, dPosYS1; - ComputeCoordinatesSensor1( fvPairsS1[ uBestS1 ].first.GetChan(), - fvPairsS1[ uBestS1 ].second.GetChan(), - dPosXS1, dPosYS1 ); - fhMapBestPairsHodoS1S2GeoCut_S1->Fill( dPosXS1, dPosYS1 ); - // Apply Position Offsets - dPosXS1 += fdOffsetS1X; - dPosYS1 += fdOffsetS1Y; - - fhMapBestPairsHodoS1S2GeoCut_Proj->Fill( dProjXS1, dProjYS1 ); - fhResidualsBestPairsHodoS1S2GeoCut->Fill( dPosXS1 - dProjXS1, dPosYS1 - dProjYS1 ); - - fhAdcRawBestPairsHodoS1S2N->Fill( fvPairsS1[ uBestS1 ].first.GetChan(), fvPairsS1[ uBestS1 ].first.GetAdc() ); - fhAdcRawBestPairsHodoS1S2P->Fill( fvPairsS1[ uBestS1 ].second.GetChan(), fvPairsS1[ uBestS1 ].second.GetAdc() ); - } // if( 0 < uNbS1CoincPerHodo ) - } // if( bHodoTrkInS1 ) - } // if( 0 < uNbS2CoincPerHodo ) - } // if( bHodoTrkInS2 ) - - /// Fill the efficiency plots - if( 0 < uNbS1CoincPerHodo ) - { - fhEfficiency->Fill( 0., 1.0 ); - fhEfficiencyMapS1->Fill( dProjXS1, dProjYS1, 1.0 ); - if( 0 < uNbS2CoincPerHodo ) - { - fhEfficiency->Fill( 3., 1.0 ); - fhEfficiencyMapS2S1->Fill( dProjXS2, dProjYS2, 1.0 ); - } // if( 0 < uNbS2CoincPerHodo ) - else - { - fhEfficiency->Fill( 3., 0.0 ); - fhEfficiencyMapS2S1->Fill( dProjXS2, dProjYS2, 0.0 ); - } // else of if( 0 < uNbS2CoincPerHodo ) - } // if( 0 < uNbS1CoincPerHodo ) - else - { - fhEfficiency->Fill( 0., 0.0 ); - fhEfficiencyMapS1->Fill( dProjXS1, dProjYS1, 0.0 ); - } // else of if( 0 < uNbS1CoincPerHodo ) - - if( 0 < uNbS2CoincPerHodo ) - { - fhEfficiency->Fill( 1., 1.0 ); - fhEfficiencyMapS2->Fill( dProjXS2, dProjYS2, 1.0 ); - if( 0 < uNbS1CoincPerHodo ) - { - fhEfficiency->Fill( 2., 1.0 ); - fhEfficiencyMapS1S2->Fill( dProjXS1, dProjYS1, 1.0 ); - } // if( 0 < uNbS1CoincPerHodo ) - else - { - fhEfficiency->Fill( 2., 0.0 ); - fhEfficiencyMapS1S2->Fill( dProjXS1, dProjYS1, 0.0 ); - } // else of if( 0 < uNbS1CoincPerHodo ) - } // if( 0 < uNbS2CoincPerHodo ) - else - { - fhEfficiency->Fill( 1., 0.0 ); - fhEfficiencyMapS2->Fill( dProjXS2, dProjYS2, 0.0 ); - } // else of if( 0 < uNbS2CoincPerHodo ) - - if( bHodoTrkInS1 ) - { - if( 0 < uNbS1CoincPerHodo ) - { - fhEfficiency->Fill( 4., 1.0 ); - fhEfficiencyMapS1GeoCut->Fill( dProjXS1, dProjYS1, 1.0 ); - if( bHodoTrkInS2 ) - { - if( 0 < uNbS2CoincPerHodo ) - { - fhEfficiency->Fill( 7., 1.0 ); - fhEfficiencyMapS2S1GeoCut->Fill( dProjXS2, dProjYS2, 1.0 ); - } // if( 0 < uNbS2CoincPerHodo ) - else - { - fhEfficiency->Fill( 7., 0.0 ); - fhEfficiencyMapS2S1GeoCut->Fill( dProjXS2, dProjYS2, 0.0 ); - } // else of if( 0 < uNbS2CoincPerHodo ) - } // if( bHodoTrkInS2 ) - } // if( 0 < uNbS1CoincPerHodo ) - else - { - fhEfficiency->Fill( 4., 0.0 ); - fhEfficiencyMapS1GeoCut->Fill( dProjXS1, dProjYS1, 0.0 ); - } // else of if( 0 < uNbS1CoincPerHodo ) - } // if( bHodoTrkInS1 ) - - if( bHodoTrkInS2 ) - { - if( 0 < uNbS2CoincPerHodo ) - { - fhEfficiency->Fill( 5., 1.0 ); - fhEfficiencyMapS2GeoCut->Fill( dProjXS2, dProjYS2, 1.0 ); - if( bHodoTrkInS1 ) - { - if( 0 < uNbS1CoincPerHodo ) - { - fhEfficiency->Fill( 6., 1.0 ); - fhEfficiencyMapS1S2GeoCut->Fill( dProjXS1, dProjYS1, 1.0 ); - } // if( 0 < uNbS1CoincPerHodo ) - else - { - fhEfficiency->Fill( 6., 0.0 ); - fhEfficiencyMapS1S2GeoCut->Fill( dProjXS1, dProjYS1, 0.0 ); - } // else of if( 0 < uNbS1CoincPerHodo ) - } // if( bHodoTrkInS1 ) - } // if( 0 < uNbS2CoincPerHodo ) - else - { - fhEfficiency->Fill( 5., 0.0 ); - fhEfficiencyMapS2GeoCut->Fill( dProjXS2, dProjYS2, 0.0 ); - } // else of if( 0 < uNbS2CoincPerHodo ) - } // if( bHodoTrkInS2 ) - } // for( UInt_t uPairH1 = 0; uPairH1 < fvPairsH1.size(); ++uPairH1 ) - - /// Clear the Pairs storage - fvPairsH1.clear(); - fvPairsH2.clear(); - fvPairsS1.clear(); - fvPairsS2.clear(); - fvPairsHodo.clear(); - fvPairsHodoS1.clear(); - fvPairsHodoS2.clear(); - fvPairsHodoS1S2.clear(); - fvPairsHodoS2S1.clear(); - - fvHitsS1N.clear(); - fvHitsS1P.clear(); - fvHitsS2N.clear(); - fvHitsS2P.clear(); - - } // if( 0 < fvmHitsInTs.size() ) - - UInt_t uNbAsicCleanInMs = 0; - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - if( kFALSE == fvbAsicHasDuplicInMs[ uXyterIdx ] ) - uNbAsicCleanInMs++; - Double_t dTimeSinceStartSec = dMsTime - fdStartTimeMsSz; - for( UInt_t uXyterIdx = 0; uXyterIdx <= fuNbStsXyters; ++uXyterIdx ) - { - if( uXyterIdx == uNbAsicCleanInMs ) - { - fhRatioMsDuplicateQuality->Fill( uXyterIdx, 1.0 ); - fhEvoMsDuplicateQuality[ uXyterIdx ]->Fill( dTimeSinceStartSec, 1.0 ); - } // if( uXyterIdx == uNbAsicCleanInMs ) - else - { - fhRatioMsDuplicateQuality->Fill( uXyterIdx, 0.0 ); - fhEvoMsDuplicateQuality[ uXyterIdx ]->Fill( dTimeSinceStartSec, 0.0 ); - } // else of if( uXyterIdx != uNbAsicCleanInMs ) - } // for( UInt_t uXyterIdx = 0; uXyterIdx <= fuNbStsXyters; ++uXyterIdx ) - } // for( size_t m = 0; m < numCompMsInTs; ++m ) - - // End of TS, check if stuff to do with the hits inside each MS - // Usefull for low rate pulser tests - // Need to do it only when last DPB is processed, as they are done one by one - if( fuCurrDpbIdx == fuNrOfDpbs - 1 ) - { - for( UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx ) - { - fvdMsTime[ uMsIdx ] = 0.0; - } // for( UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx ) - } // if( fuCurrDpbIdx == fuNrOfDpbs - 1 ) - - if( 0 == ts.index() % 1000 && fuCurrDpbIdx == fuNrOfDpbs - 1 ) - { - for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - { - Double_t dTsMsbTime = - static_cast<ULong64_t>( stsxyter::kuHitNbTsBins ) - * static_cast<ULong64_t>( fvulCurrentTsMsb[fuCurrDpbIdx]) - + static_cast<ULong64_t>( stsxyter::kulTsCycleNbBins ) - * static_cast<ULong64_t>( fvuCurrentTsMsbCycle[fuCurrDpbIdx] ); - dTsMsbTime *= stsxyter::kdClockCycleNs * 1e-9; - - LOG(info) << "End of TS " << std::setw(7) << ts.index() - << " eDPB " << std::setw(2) << uDpb - << " current TS MSB counter is " << std::setw(12) << fvulCurrentTsMsb[uDpb] - << " current TS MSB cycle counter is " << std::setw(12) << fvuCurrentTsMsbCycle[uDpb] - << " current TS MSB time is " << std::setw(12) << dTsMsbTime << " s"; - } - } // if( 0 == ts.index() % 1000 && fuCurrDpbIdx == fuNrOfDpbs - 1 ) - - return kTRUE; -} - -void CbmCosy2018MonitorEfficiency::FillHitInfo( stsxyter::Message mess, const UShort_t & /*usElinkIdx*/, const UInt_t & uAsicIdx, const UInt_t & uMsIdx ) -{ - UShort_t usChan = mess.GetHitChannel(); - UShort_t usRawAdc = mess.GetHitAdc(); -// UShort_t usFullTs = mess.GetHitTimeFull(); -// UShort_t usTsOver = mess.GetHitTimeOver(); - UShort_t usRawTs = mess.GetHitTime(); - - fhHodoChanCntRaw[ uAsicIdx ]->Fill( usChan ); - fhHodoChanAdcRaw[ uAsicIdx ]->Fill( usChan, usRawAdc ); - fhHodoChanAdcRawProf[ uAsicIdx ]->Fill( usChan, usRawAdc ); - fhHodoChanRawTs[ uAsicIdx ]->Fill( usChan, usRawTs ); - fhHodoChanMissEvt[ uAsicIdx ]->Fill( usChan, mess.IsHitMissedEvts() ); - - // Compute the Full time stamp -// Long64_t ulOldHitTime = fvulChanLastHitTime[ uAsicIdx ][ usChan ]; -// Double_t dOldHitTime = fvdChanLastHitTime[ uAsicIdx ][ usChan ]; - - // Use TS w/o overlap bits as they will anyway come from the TS_MSB - fvulChanLastHitTime[ uAsicIdx ][ usChan ] = usRawTs; - - fvulChanLastHitTime[ uAsicIdx ][ usChan ] += - static_cast<ULong64_t>( stsxyter::kuHitNbTsBins ) - * static_cast<ULong64_t>( fvulCurrentTsMsb[fuCurrDpbIdx]) - + static_cast<ULong64_t>( stsxyter::kulTsCycleNbBins ) - * static_cast<ULong64_t>( fvuCurrentTsMsbCycle[fuCurrDpbIdx] ) - ; - -// fvuElinkLastTsHit[fuCurrDpbIdx] = usRawTs; - - // Convert the Hit time in bins to Hit time in ns - Double_t dHitTimeNs = fvulChanLastHitTime[ uAsicIdx ][ usChan ] * stsxyter::kdClockCycleNs; -/* - // If needed fill the hit interval plots - if( fbChanHitDtEna ) - { - Double_t dDeltaT = dHitTimeNs - fvdChanLastHitTime[ uAsicIdx ][ usChan ]; - if( 0 == dDeltaT ) - fhStsChanHitDtNeg[ uAsicIdx ]->Fill( 1, usChan ); - else if( 0 < dDeltaT ) - fhStsChanHitDt[ uAsicIdx ]->Fill( dDeltaT, usChan ); - else fhStsChanHitDtNeg[ uAsicIdx ]->Fill( -dDeltaT, usChan ); - } // if( fbChanHitDtEna ) -*/ - // Store new value of Hit time in ns - fvdChanLastHitTime[ uAsicIdx ][ usChan ] = fvulChanLastHitTime[ uAsicIdx ][ usChan ] * stsxyter::kdClockCycleNs; -/* - LOG(info) << " Asic " << std::setw( 2 ) << uAsicIdx - << " Channel " << std::setw( 3 ) << usChan - << " Diff to last hit " << std::setw( 12 ) << ( fvulChanLastHitTime[ uAsicIdx ][ usChan ] - ulOldHitTime) - << " in s " << std::setw( 12 ) << ( fvdChanLastHitTime[ uAsicIdx ][ usChan ] - dOldHitTime) * 1e-9; -*/ - // Pulser and MS - fvuChanNbHitsInMs[ uAsicIdx ][ usChan ][ uMsIdx ] ++; - fvdChanLastHitTimeInMs[ uAsicIdx ][ usChan ][ uMsIdx ] = dHitTimeNs; - fvusChanLastHitAdcInMs[ uAsicIdx ][ usChan ][ uMsIdx ] = usRawAdc; -/* - fvmChanHitsInTs[ uAsicIdx ][ usChan ].insert( stsxyter::FinalHit( fvulChanLastHitTime[ uAsicIdx ][ usChan ], - usRawAdc, uAsicIdx, usChan ) ); -*/ - fvmHitsInTs.push_back( stsxyter::FinalHit( fvulChanLastHitTime[ uAsicIdx ][ usChan ], usRawAdc, uAsicIdx, usChan ) ); - -/* - LOG(info) << " TS " << std::setw( 12 ) << fulCurrentTsIdx - << " MS " << std::setw( 12 ) << fulCurrentMsIdx - << " MsInTs " << std::setw( 3 ) << uMsIdx - << " Asic " << std::setw( 2 ) << uAsicIdx - << " Channel " << std::setw( 3 ) << usChan - << " ADC " << std::setw( 3 ) << usRawAdc - << " TS " << std::setw( 3 ) << usRawTs // 9 bits TS - << " SX TsMsb " << std::setw( 2 ) << ( fvulCurrentTsMsb[fuCurrDpbIdx] & 0x1F ) // Total StsXyter TS = 14 bits => 9b Hit TS + lower 5b TS_MSB after DPB - << " DPB TsMsb " << std::setw( 6 ) << ( fvulCurrentTsMsb[fuCurrDpbIdx] >> 5 ) // Total StsXyter TS = 14 bits => 9b Hit TS + lower 5b of TS_MSB after DPB - << " TsMsb " << std::setw( 7 ) << fvulCurrentTsMsb[fuCurrDpbIdx] - << " MsbCy " << std::setw( 4 ) << fvuCurrentTsMsbCycle[fuCurrDpbIdx] - << " Time " << std::setw ( 12 ) << fvulChanLastHitTime[ uAsicIdx ][ usChan ]; -*/ - // Check Starting point of histos with time as X axis - if( -1 == fdStartTime ) - fdStartTime = fvdChanLastHitTime[ uAsicIdx ][ usChan ]; - - // Fill histos with time as X axis - Double_t dTimeSinceStartSec = (fvdChanLastHitTime[ uAsicIdx ][ usChan ] - fdStartTime)* 1e-9; - Double_t dTimeSinceStartMin = dTimeSinceStartSec / 60.0; - fhHodoChanHitRateEvo[ uAsicIdx ]->Fill( dTimeSinceStartSec , usChan ); - fhHodoFebRateEvo[ uAsicIdx ]->Fill( dTimeSinceStartSec ); - fhHodoChanHitRateEvoLong[ uAsicIdx ]->Fill( dTimeSinceStartMin, usChan, 1.0/60.0 ); - fhHodoFebRateEvoLong[ uAsicIdx ]->Fill( dTimeSinceStartMin, 1.0/60.0 ); - if( mess.IsHitMissedEvts() ) - { - fhHodoChanMissEvtEvo[ uAsicIdx ]->Fill( dTimeSinceStartSec , usChan ); - fhHodoFebMissEvtEvo[ uAsicIdx ]->Fill( dTimeSinceStartSec ); - } // if( mess.IsHitMissedEvts() ) -/* - if( kTRUE == fbLongHistoEnable ) - { - std::chrono::steady_clock::time_point tNow = std::chrono::steady_clock::now(); - Double_t dUnixTimeInRun = std::chrono::duration_cast< std::chrono::seconds >(tNow - ftStartTimeUnix).count(); - fhFebRateEvoLong[ uAsicIdx ]->Fill( dUnixTimeInRun , 1.0 / fuLongHistoBinSizeSec ); - fhFebChRateEvoLong[ uAsicIdx ]->Fill( dUnixTimeInRun , usChan, 1.0 / fuLongHistoBinSizeSec ); - } // if( kTRUE == fbLongHistoEnable ) -*/ - -} - -void CbmCosy2018MonitorEfficiency::FillTsMsbInfo( stsxyter::Message mess, UInt_t /*uMessIdx*/, UInt_t /*uMsIdx*/ ) -{ - UInt_t uVal = mess.GetTsMsbVal(); -/* - if( 0 == fuCurrDpbIdx ) - LOG(info) << " TS " << std::setw( 12 ) << fulCurrentTsIdx - << " MS " << std::setw( 12 ) << fulCurrentMsIdx - << " MsInTs " << std::setw( 3 ) << uMsIdx - << " DPB " << std::setw( 2 ) << fuCurrDpbIdx - << " Mess " << std::setw( 5 ) << uMessIdx - << " TsMsb " << std::setw( 5 ) << uVal; -*/ -/* - if( (uVal != fvulCurrentTsMsb[fuCurrDpbIdx] + 1) && 0 < uVal && - !( 1 == uMessIdx && usVal == fvulCurrentTsMsb[fuCurrDpbIdx] ) ) // 1st TS_MSB in MS is always a repeat of the last one in previous MS! - { - LOG(info) << "TS MSB not increasing by 1! TS " << std::setw( 12 ) << fulCurrentTsIdx - << " MS " << std::setw( 12 ) << fulCurrentMsIdx - << " MsInTs " << std::setw( 3 ) << uMsIdx - << " DPB " << std::setw( 2 ) << fuCurrDpbIdx - << " Mess " << std::setw( 5 ) << uMessIdx - << " Old TsMsb " << std::setw( 5 ) << fvulCurrentTsMsb[fuCurrDpbIdx] - << " new TsMsb " << std::setw( 5 ) << uVal - << " Diff " << std::setw( 5 ) << uVal - fvulCurrentTsMsb[fuCurrDpbIdx] - << " Old MsbCy " << std::setw( 5 ) << fvuCurrentTsMsbCycle[fuCurrDpbIdx]; - } // if( (uVal != fvulCurrentTsMsb[fuCurrDpbIdx] + 1) && 0 < uVal ) -*/ - - // Update Status counters - if( uVal < fvulCurrentTsMsb[fuCurrDpbIdx] ) - { - - LOG(info) << " TS " << std::setw( 12 ) << fulCurrentTsIdx - << " MS " << std::setw( 12 ) << fulCurrentMsIdx - << " DPB " << std::setw( 2 ) << fuCurrDpbIdx - << " Old TsMsb " << std::setw( 5 ) << fvulCurrentTsMsb[fuCurrDpbIdx] - << " Old MsbCy " << std::setw( 5 ) << fvuCurrentTsMsbCycle[fuCurrDpbIdx] - << " new TsMsb " << std::setw ( 5 ) << uVal; - - fvuCurrentTsMsbCycle[fuCurrDpbIdx] ++; - } // if( uVal < fvulCurrentTsMsb[fuCurrDpbIdx] ) - fvulCurrentTsMsb[fuCurrDpbIdx] = uVal; -/* - if( 1 < uMessIdx ) - { - fhStsDpbRawTsMsb->Fill( fuCurrDpbIdx, fvulCurrentTsMsb[fuCurrDpbIdx] ); - fhStsDpbRawTsMsbSx->Fill( fuCurrDpbIdx, ( fvulCurrentTsMsb[fuCurrDpbIdx] & 0x1F ) ); - fhStsDpbRawTsMsbDpb->Fill( fuCurrDpbIdx, ( fvulCurrentTsMsb[fuCurrDpbIdx] >> 5 ) ); - } // if( 0 < uMessIdx ) -*/ -// fhStsAsicTsMsb->Fill( fvulCurrentTsMsb[fuCurrDpbIdx], uAsicIdx ); - - ULong64_t ulNewTsMsbTime = static_cast< ULong64_t >( stsxyter::kuHitNbTsBins ) - * static_cast< ULong64_t >( fvulCurrentTsMsb[fuCurrDpbIdx]) - + static_cast< ULong64_t >( stsxyter::kulTsCycleNbBins ) - * static_cast< ULong64_t >( fvuCurrentTsMsbCycle[fuCurrDpbIdx] ); - - Double_t dUpdatePeriodInSec = 1; - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - Double_t dTimeInS = ( ulNewTsMsbTime - fvulStartTimeLastS[ uXyterIdx ] ) - * stsxyter::kdClockCycleNs - * 1e-9; - if( dUpdatePeriodInSec <= dTimeInS || (ulNewTsMsbTime < fvulStartTimeLastS[ uXyterIdx ] ) ) - { - UInt_t uNbHitsTotal = fvuNbHitDiffTsAsicLastS[ uXyterIdx ] + fvuNbHitSameTsAsicLastS[ uXyterIdx ]; - if( 0 < uNbHitsTotal && dTimeInS < 2 * dUpdatePeriodInSec ) - { - Double_t dRate = static_cast< Double_t >( uNbHitsTotal ) / dTimeInS; - Double_t dRatioSameTs = static_cast< Double_t >( fvuNbHitSameTsAsicLastS[ uXyterIdx ] ) - / uNbHitsTotal; - Double_t dRatioSameTsAdc = static_cast< Double_t >( fvuNbHitSameTsAdcAsicLastS[ uXyterIdx ] ) - / uNbHitsTotal; - Double_t dRatioSameAdcSameTs = static_cast< Double_t >( fvuNbHitSameTsAdcAsicLastS[ uXyterIdx ] ) - / fvuNbHitSameTsAsicLastS[ uXyterIdx ]; - - fhSetupSortedAsicRatioSameTsVsFlux[ uXyterIdx ]->Fill( dRate, dRatioSameTs ); - fhSetupSortedAsicRatioSameTsAdcVsFlux[ uXyterIdx ]->Fill( dRate, dRatioSameTsAdc ); - fhSetupSortedAsicRatioSameAdcSameTsVsFlux[ uXyterIdx ]->Fill( dRate, dRatioSameAdcSameTs ); -/* - LOG(info) << "Here we are " << dTimeInS - << " " << uNbHitsTotal - << " " << dRate; -*/ - } // if( 0 < uNbHitsTotal && dTimeInS < 2 * dUpdatePeriodInSec ) - - fvulStartTimeLastS[ uXyterIdx ] = ulNewTsMsbTime; - fvuNbHitDiffTsAsicLastS[ uXyterIdx ] = 0; - fvuNbHitSameTsAsicLastS[ uXyterIdx ] = 0; - fvuNbHitSameTsAdcAsicLastS[ uXyterIdx ] = 0; - } // if( dUpdatePeriodInSec <= dTimeInS || (ulNewTsMsbTime < fvulStartTimeLastS[ uXyterIdx ] ) ) - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) -} - -void CbmCosy2018MonitorEfficiency::FillEpochInfo( stsxyter::Message /*mess*/ ) -{ -// UInt_t uVal = mess.GetTsMsbVal(); -/* - // Update Status counters - if( usVal < fvulCurrentTsMsb[fuCurrDpbIdx] ) - fvuCurrentTsMsbCycle[fuCurrDpbIdx] ++; - fvulCurrentTsMsb[fuCurrDpbIdx] = usVal; - -// fhStsAsicTsMsb->Fill( fvulCurrentTsMsb[fuCurrDpbIdx], uAsicIdx ); -*/ -} - -void CbmCosy2018MonitorEfficiency::Reset() -{ -} - -void CbmCosy2018MonitorEfficiency::Finish() -{ - - LOG(info) << "-------------------------------------"; - LOG(info) << "CbmCosy2018MonitorEfficiency statistics are "; - LOG(info) << " Hit messages: " << fmMsgCounter[ stsxyter::MessType::Hit ] << "\n" - << " Ts MSB messages: " << fmMsgCounter[ stsxyter::MessType::TsMsb ] << "\n" - << " Dummy messages: " << fmMsgCounter[ stsxyter::MessType::Dummy ] << "\n" - << " Epoch messages: " << fmMsgCounter[ stsxyter::MessType::Epoch ] << "\n" - << " Empty messages: " << fmMsgCounter[ stsxyter::MessType::Empty ]; - - LOG(info) << "-------------------------------------"; - - SaveAllHistos( fsHistoFileFullname ); - SaveAllHistos(); - -} - - -void CbmCosy2018MonitorEfficiency::FillOutput(boost::any) -{ -} - -void CbmCosy2018MonitorEfficiency::SaveAllHistos( TString sFileName ) -{ - /*******************************************************************/ - TCanvas* cFebRatioDupli = new TCanvas( "cFebRatioDupli", - "Hodoscopes coincidence quality", - 800, 600); - cFebRatioDupli->Divide( 2, fuNbStsXyters/2 + fuNbStsXyters%2 ); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - cFebRatioDupli->cd(1 + uXyterIdx ); - gPad->SetLogz(); - fhSetupSortedNbSameTsChan[ uXyterIdx ]->Draw( "colz" ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - /*******************************************************************/ - - TDirectory * oldDir = NULL; - TFile * histoFile = NULL; - if( "" != sFileName ) - { - // Store current directory position to allow restore later - oldDir = gDirectory; - // open separate histo file in recreate mode - histoFile = new TFile( sFileName , "RECREATE"); - histoFile->cd(); - } // if( "" != sFileName ) - - /***************************/ - gDirectory->mkdir("Sts_Raw"); - gDirectory->cd("Sts_Raw"); - - fhHodoMessType->Write(); - fhHodoSysMessType->Write(); - fhHodoMessTypePerDpb->Write(); - fhHodoSysMessTypePerDpb->Write(); - fhHodoMessTypePerElink->Write(); - fhHodoSysMessTypePerElink->Write(); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fhHodoChanCntRaw[ uXyterIdx ]->Write(); - fhHodoChanAdcRaw[ uXyterIdx ]->Write(); - fhHodoChanAdcRawProf[ uXyterIdx ]->Write(); - fhHodoChanRawTs[ uXyterIdx ]->Write(); - fhHodoChanMissEvt[ uXyterIdx ]->Write(); - fhHodoChanMissEvtEvo[ uXyterIdx ]->Write(); - fhHodoFebMissEvtEvo[ uXyterIdx ]->Write(); - fhHodoChanHitRateEvo[ uXyterIdx ]->Write(); - fhHodoFebRateEvo[ uXyterIdx ]->Write(); - fhHodoChanHitRateEvoLong[ uXyterIdx ]->Write(); - fhHodoFebRateEvoLong[ uXyterIdx ]->Write(); -/* - if( kTRUE == fbLongHistoEnable ) - { - fhFebRateEvoLong[ uXyterIdx ]->Write(); - fhFebChRateEvoLong[ uXyterIdx ]->Write(); - } // if( kTRUE == fbLongHistoEnable ) -*/ - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - - - fhSetupSortedDtX1Y1->Write(); - fhSetupSortedDtX2Y2->Write(); - fhSetupSortedDtN1P1->Write(); - fhSetupSortedDtN2P2->Write(); - fhSetupSortedDtX1Y1X2Y2->Write(); - fhSetupSortedDtN1P1N2P2->Write(); - fhSetupSortedDtX1Y1X2Y2N1P1->Write(); - fhSetupSortedDtX1Y1X2Y2N2P2->Write(); - fhSetupSortedDtH1H2S1S2->Write(); - fhSetupSortedCntEvoX1Y1->Write(); - fhSetupSortedCntEvoX2Y2->Write(); - fhSetupSortedCntEvoN1P1->Write(); - fhSetupSortedCntEvoN2P2->Write(); - - fhSetupSortedDtX1->Write(); - fhSetupSortedDtY1->Write(); - fhSetupSortedDtX2->Write(); - fhSetupSortedDtY2->Write(); - fhSetupSortedDtN1->Write(); - fhSetupSortedDtP1->Write(); - fhSetupSortedDtN2->Write(); - fhSetupSortedDtP2->Write(); - - gDirectory->cd(".."); - /***************************/ - - /***************************/ - gDirectory->mkdir("Sts_Dupli"); - gDirectory->cd("Sts_Dupli"); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fhSetupSortedNbSameTsChan[ uXyterIdx ]->Write(); - fhSetupSortedSameTsAdcChan[ uXyterIdx ]->Write(); - fhSetupSortedSameTsAdcDiff[ uXyterIdx ]->Write(); - fhSetupSortedRatioSameTsChan[ uXyterIdx ]->Write(); - fhSetupSortedNbConsSameTsChan[ uXyterIdx ]->Write(); - fhSetupSortedNbConsSameTsAdcChan[ uXyterIdx ]->Write(); - fhSetupSortedNbConsSameTsVsTsAdc[ uXyterIdx ]->Write(); - - fhSetupSortedAsicRatioSameTsVsFlux[ uXyterIdx ]->Write(); - fhSetupSortedAsicRatioSameTsAdcVsFlux[ uXyterIdx ]->Write(); - fhSetupSortedAsicRatioSameAdcSameTsVsFlux[ uXyterIdx ]->Write(); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - - fhRatioMsDuplicateQuality->Write(); - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fhEvoMsDuplicateQuality[ uXyterIdx ]->Write(); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - - cFebRatioDupli->Write(); - delete cFebRatioDupli; - - gDirectory->cd(".."); - /***************************/ - - /***************************/ - gDirectory->mkdir("Sts_Maps"); - gDirectory->cd("Sts_Maps"); - - fhSetupSortedMapX1Y1->Write(); - fhSetupSortedMapX2Y2->Write(); - fhSetupSortedMapN1P1->Write(); - fhSetupSortedMapN2P2->Write(); - fhStsSortedMapS1->Write(); - if( kTRUE == fbDualStsEna ) - { - fhStsSortedMapS2->Write(); - fhStsSortedMapS1Coinc->Write(); - fhStsSortedMapS2Coinc->Write(); - } // if( kTRUE == fbDualStsEna ) - - gDirectory->cd(".."); - /***************************/ - - /***************************/ - gDirectory->mkdir("Sts_Cuts"); - gDirectory->cd("Sts_Cuts"); - - fhDtAllPairsS1->Write(); - fhDtAllPairsS2->Write(); - fhDtAllPairsHodoS1->Write(); - fhDtAllPairsHodoS2->Write(); - fhDtBestPairsH1->Write(); - fhDtBestPairsH2->Write(); - fhDtBestPairsS1->Write(); - fhDtBestPairsS2->Write(); - fhDtBestPairsHodo->Write(); - fhDtBestPairsHodoS1->Write(); - fhDtBestPairsHodoS2->Write(); - fhDtBestPairsHodoS1S2->Write(); - fhDtBestPairsHodoS2S1->Write(); - - fhMapBestPairsH1->Write(); - fhMapBestPairsH2->Write(); - fhMapBestPairsS1->Write(); - fhMapBestPairsS2->Write(); - fhMapBestPairsHodo_H1->Write(); - fhMapBestPairsHodo_H2->Write(); - fhMapBestPairsHodo_ProjS1->Write(); - fhMapBestPairsHodo_ProjS2->Write(); - fhMapBestPairsHodoS1_H1->Write(); - fhMapBestPairsHodoS1_H2->Write(); - fhMapBestPairsHodoS1_S1->Write(); - fhMapBestPairsHodoS1_Proj->Write(); - fhMapBestPairsHodoS2_H1->Write(); - fhMapBestPairsHodoS2_H2->Write(); - fhMapBestPairsHodoS2_S2->Write(); - fhMapBestPairsHodoS2_Proj->Write(); - fhMapBestPairsHodoS1S2_H1->Write(); - fhMapBestPairsHodoS1S2_H2->Write(); - fhMapBestPairsHodoS1S2_S1->Write(); - fhMapBestPairsHodoS1S2_Proj->Write(); - fhMapBestPairsHodoS2S1_H1->Write(); - fhMapBestPairsHodoS2S1_H2->Write(); - fhMapBestPairsHodoS2S1_S2->Write(); - fhMapBestPairsHodoS2S1_Proj->Write(); - - fhResidualsBestPairsHodoS1->Write(); - fhResidualsBestPairsHodoS2->Write(); - fhResidualsBestPairsHodoS1S2->Write(); - fhResidualsBestPairsHodoS2S1->Write(); - - fhAdcRawBestPairsHodoS1N->Write(); - fhAdcRawBestPairsHodoS1P->Write(); - fhAdcRawBestPairsHodoS2N->Write(); - fhAdcRawBestPairsHodoS2P->Write(); - fhAdcRawBestPairsHodoS1S2N->Write(); - fhAdcRawBestPairsHodoS1S2P->Write(); - fhAdcRawBestPairsHodoS2S1N->Write(); - fhAdcRawBestPairsHodoS2S1P->Write(); - - gDirectory->cd(".."); - /***************************/ - - /***************************/ - gDirectory->mkdir("Sts_GeoCuts"); - gDirectory->cd("Sts_GeoCuts"); - - fhDtBestPairsHodoS1GeoCut->Write(); - fhDtBestPairsHodoS2GeoCut->Write(); - fhDtBestPairsHodoS1S2GeoCut->Write(); - fhDtBestPairsHodoS2S1GeoCut->Write(); - - fhMapBestPairsHodoGeoCutS1_H1->Write(); - fhMapBestPairsHodoGeoCutS1_H2->Write(); - fhMapBestPairsHodoGeoCutS1_Proj->Write(); - fhMapBestPairsHodoGeoCutS2_H1->Write(); - fhMapBestPairsHodoGeoCutS2_H2->Write(); - fhMapBestPairsHodoGeoCutS2_Proj->Write(); - - fhMapBestPairsHodoS1GeoCut_H1->Write(); - fhMapBestPairsHodoS1GeoCut_H2->Write(); - fhMapBestPairsHodoS1GeoCut_S1->Write(); - fhMapBestPairsHodoS1GeoCut_Proj->Write(); - fhMapBestPairsHodoS2GeoCut_H1->Write(); - fhMapBestPairsHodoS2GeoCut_H2->Write(); - fhMapBestPairsHodoS2GeoCut_S2->Write(); - fhMapBestPairsHodoS2GeoCut_Proj->Write(); - fhMapBestPairsHodoS1S2GeoCut_H1->Write(); - fhMapBestPairsHodoS1S2GeoCut_H2->Write(); - fhMapBestPairsHodoS1S2GeoCut_S1->Write(); - fhMapBestPairsHodoS1S2GeoCut_Proj->Write(); - fhMapBestPairsHodoS2S1GeoCut_H1->Write(); - fhMapBestPairsHodoS2S1GeoCut_H2->Write(); - fhMapBestPairsHodoS2S1GeoCut_S2->Write(); - fhMapBestPairsHodoS2S1GeoCut_Proj->Write(); - - fhResidualsBestPairsHodoS1GeoCut->Write(); - fhResidualsBestPairsHodoS2GeoCut->Write(); - fhResidualsBestPairsHodoS1S2GeoCut->Write(); - fhResidualsBestPairsHodoS2S1GeoCut->Write(); - - gDirectory->cd(".."); - /***************************/ - - /***************************/ - gDirectory->mkdir("Sts_Eff"); - gDirectory->cd("Sts_Eff"); - - fhEfficiency->Write(); - fhEfficiencyMapS1->Write(); - fhEfficiencyMapS2->Write(); - fhEfficiencyMapS1S2->Write(); - fhEfficiencyMapS2S1->Write(); - fhEfficiencyMapS1GeoCut->Write(); - fhEfficiencyMapS2GeoCut->Write(); - fhEfficiencyMapS1S2GeoCut->Write(); - fhEfficiencyMapS2S1GeoCut->Write(); - - gDirectory->cd(".."); - /***************************/ - - ///++++++++ Adrian ADC analysis, to be moved in other class! +++++/// - gDirectory->mkdir("Adc"); - gDirectory->cd("Adc"); - - fhDtNeighborChansS1N->Write(); - fhDtNeighborChansS1P->Write(); - fhDtNeighborChansS2N->Write(); - fhDtNeighborChansS2P->Write(); - - fhClusterAdcVsSizeS1N->Write(); - fhClusterAdcVsSizeS1P->Write(); - fhClusterAdcVsSizeS2N->Write(); - fhClusterAdcVsSizeS2P->Write(); - - fhClusterAdcVsSizeS1N_MatchS1->Write(); - fhClusterAdcVsSizeS1P_MatchS1->Write(); - fhClusterAdcVsSizeS2N_MatchS2->Write(); - fhClusterAdcVsSizeS2P_MatchS2->Write(); - - fhClusterS1N_CenterNbMatchS1P->Write(); - fhClusterS1P_CenterNbMatchS1N->Write(); - fhClusterS2N_CenterNbMatchS2P->Write(); - fhClusterS2P_CenterNbMatchS2N->Write(); - - fhClusterS1N_AdcNbMatchS1P->Write(); - fhClusterS1P_AdcNbMatchS1N->Write(); - fhClusterS2N_AdcNbMatchS2P->Write(); - fhClusterS2P_AdcNbMatchS2N->Write(); - - fhDtNeighborChansH1X->Write(); - fhDtNeighborChansH1Y->Write(); - fhDtNeighborChansH2X->Write(); - fhDtNeighborChansH2Y->Write(); - - fhClusterAdcVsSizeH1X->Write(); - fhClusterAdcVsSizeH1Y->Write(); - fhClusterAdcVsSizeH2X->Write(); - fhClusterAdcVsSizeH2Y->Write(); - fhClusterPosition_MatchH1->Write(); - fhClusterPosition_MatchH2->Write(); - - gDirectory->cd(".."); - ///+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - - /***************************/ - // Flib Histos - gDirectory->mkdir("Flib_Raw"); - gDirectory->cd("Flib_Raw"); - for( UInt_t uLinks = 0; uLinks < kiMaxNbFlibLinks; uLinks ++) - { - TString sMsSzName = Form("MsSz_link_%02u", uLinks); - if( fHM->Exists(sMsSzName.Data() ) ) - fHM->H1( sMsSzName.Data() )->Write(); - - sMsSzName = Form("MsSzTime_link_%02u", uLinks); - if( fHM->Exists(sMsSzName.Data() ) ) - fHM->P1( sMsSzName.Data() )->Write(); - } // for( UInt_t uLinks = 0; uLinks < 16; uLinks ++) - - TH1 * pMissedTsH1 = dynamic_cast< TH1 * >( gROOT->FindObjectAny( "Missed_TS" ) ); - if( NULL != pMissedTsH1 ) - pMissedTsH1->Write(); - - TProfile * pMissedTsEvoP = dynamic_cast< TProfile * >( gROOT->FindObjectAny( "Missed_TS_Evo" ) ); - if( NULL != pMissedTsEvoP ) - pMissedTsEvoP->Write(); - - gDirectory->cd(".."); - /***************************/ - - if( "" != sFileName ) - { - // Restore original directory position - histoFile->Close(); - oldDir->cd(); - } // if( "" != sFileName ) - -} -void CbmCosy2018MonitorEfficiency::ResetAllHistos() -{ - LOG(info) << "Reseting all STS histograms."; - - fhHodoMessType->Reset(); - fhHodoSysMessType->Reset(); - fhHodoMessTypePerDpb->Reset(); - fhHodoSysMessTypePerDpb->Reset(); - fhHodoMessTypePerElink->Reset(); - fhHodoSysMessTypePerElink->Reset(); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fhHodoChanCntRaw[ uXyterIdx ]->Reset(); - fhHodoChanAdcRaw[ uXyterIdx ]->Reset(); - fhHodoChanAdcRawProf[ uXyterIdx ]->Reset(); - fhHodoChanRawTs[ uXyterIdx ]->Reset(); - fhHodoChanMissEvt[ uXyterIdx ]->Reset(); - fhHodoChanMissEvtEvo[ uXyterIdx ]->Reset(); - fhHodoFebMissEvtEvo[ uXyterIdx ]->Reset(); - fhHodoChanHitRateEvo[ uXyterIdx ]->Reset(); - fhHodoFebRateEvo[ uXyterIdx ]->Reset(); - fhHodoChanHitRateEvoLong[ uXyterIdx ]->Reset(); - fhHodoFebRateEvoLong[ uXyterIdx ]->Reset(); -/* - if( kTRUE == fbLongHistoEnable ) - { - ftStartTimeUnix = std::chrono::steady_clock::now(); - fhFebRateEvoLong[ uXyterIdx ]->Reset(); - fhFebChRateEvoLong[ uXyterIdx ]->Reset(); - } // if( kTRUE == fbLongHistoEnable ) -*/ - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - - fhSetupSortedDtX1Y1->Reset(); - fhSetupSortedDtX2Y2->Reset(); - fhSetupSortedDtN1P1->Reset(); - fhSetupSortedDtN2P2->Reset(); - fhSetupSortedDtX1Y1X2Y2->Reset(); - fhSetupSortedDtN1P1N2P2->Reset(); - fhSetupSortedDtX1Y1X2Y2N1P1->Reset(); - fhSetupSortedDtX1Y1X2Y2N2P2->Reset(); - fhSetupSortedDtH1H2S1S2->Reset(); - fhSetupSortedCntEvoX1Y1->Reset(); - fhSetupSortedCntEvoX2Y2->Reset(); - fhSetupSortedCntEvoN1P1->Reset(); - fhSetupSortedCntEvoN2P2->Reset(); - - fhSetupSortedDtX1->Reset(); - fhSetupSortedDtY1->Reset(); - fhSetupSortedDtX2->Reset(); - fhSetupSortedDtY2->Reset(); - fhSetupSortedDtN1->Reset(); - fhSetupSortedDtP1->Reset(); - fhSetupSortedDtN2->Reset(); - fhSetupSortedDtP2->Reset(); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fhSetupSortedNbSameTsChan[ uXyterIdx ]->Reset(); - fhSetupSortedSameTsAdcChan[ uXyterIdx ]->Reset(); - fhSetupSortedSameTsAdcDiff[ uXyterIdx ]->Reset(); - fhSetupSortedRatioSameTsChan[ uXyterIdx ]->Reset(); - fhSetupSortedNbConsSameTsChan[ uXyterIdx ]->Reset(); - fhSetupSortedNbConsSameTsAdcChan[ uXyterIdx ]->Reset(); - fhSetupSortedNbConsSameTsVsTsAdc[ uXyterIdx ]->Reset(); - - fhSetupSortedAsicRatioSameTsVsFlux[ uXyterIdx ]->Reset(); - fhSetupSortedAsicRatioSameTsAdcVsFlux[ uXyterIdx ]->Reset(); - fhSetupSortedAsicRatioSameAdcSameTsVsFlux[ uXyterIdx ]->Reset(); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - - fhRatioMsDuplicateQuality->Reset(); - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fhEvoMsDuplicateQuality[ uXyterIdx ]->Reset(); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - - fhSetupSortedMapX1Y1->Reset(); - fhSetupSortedMapX2Y2->Reset(); - fhSetupSortedMapN1P1->Reset(); - fhSetupSortedMapN2P2->Reset(); - fhStsSortedMapS1->Reset(); - if( kTRUE == fbDualStsEna ) - { - fhStsSortedMapS2->Reset(); - fhStsSortedMapS1Coinc->Reset(); - fhStsSortedMapS2Coinc->Reset(); - } // if( kTRUE == fbDualStsEna ) - - fhDtAllPairsS1->Reset(); - fhDtAllPairsS2->Reset(); - fhDtAllPairsHodoS1->Reset(); - fhDtAllPairsHodoS2->Reset(); - fhDtBestPairsH1->Reset(); - fhDtBestPairsH2->Reset(); - fhDtBestPairsS1->Reset(); - fhDtBestPairsS2->Reset(); - fhDtBestPairsHodo->Reset(); - fhDtBestPairsHodoS1->Reset(); - fhDtBestPairsHodoS2->Reset(); - fhDtBestPairsHodoS1S2->Reset(); - fhDtBestPairsHodoS2S1->Reset(); - fhMapBestPairsH1->Reset(); - fhMapBestPairsH2->Reset(); - fhMapBestPairsS1->Reset(); - fhMapBestPairsS2->Reset(); - fhMapBestPairsHodo_H1->Reset(); - fhMapBestPairsHodo_H2->Reset(); - fhMapBestPairsHodo_ProjS1->Reset(); - fhMapBestPairsHodo_ProjS2->Reset(); - fhMapBestPairsHodoS1_H1->Reset(); - fhMapBestPairsHodoS1_H2->Reset(); - fhMapBestPairsHodoS1_S1->Reset(); - fhMapBestPairsHodoS1_Proj->Reset(); - fhMapBestPairsHodoS2_H1->Reset(); - fhMapBestPairsHodoS2_H2->Reset(); - fhMapBestPairsHodoS2_S2->Reset(); - fhMapBestPairsHodoS2_Proj->Reset(); - fhMapBestPairsHodoS1S2_H1->Reset(); - fhMapBestPairsHodoS1S2_H2->Reset(); - fhMapBestPairsHodoS1S2_S1->Reset(); - fhMapBestPairsHodoS1S2_Proj->Reset(); - fhMapBestPairsHodoS2S1_H1->Reset(); - fhMapBestPairsHodoS2S1_H2->Reset(); - fhMapBestPairsHodoS2S1_S2->Reset(); - fhMapBestPairsHodoS2S1_Proj->Reset(); - fhResidualsBestPairsHodoS1->Reset(); - fhResidualsBestPairsHodoS2->Reset(); - fhResidualsBestPairsHodoS1S2->Reset(); - fhResidualsBestPairsHodoS2S1->Reset(); - - fhDtBestPairsHodoS1GeoCut->Reset(); - fhDtBestPairsHodoS2GeoCut->Reset(); - fhDtBestPairsHodoS1S2GeoCut->Reset(); - fhDtBestPairsHodoS2S1GeoCut->Reset(); - - fhMapBestPairsHodoGeoCutS1_H1->Reset(); - fhMapBestPairsHodoGeoCutS1_H2->Reset(); - fhMapBestPairsHodoGeoCutS2_H1->Reset(); - fhMapBestPairsHodoGeoCutS2_H2->Reset(); - fhMapBestPairsHodoS1GeoCut_H1->Reset(); - fhMapBestPairsHodoS1GeoCut_H2->Reset(); - fhMapBestPairsHodoS1GeoCut_S1->Reset(); - fhMapBestPairsHodoS1GeoCut_Proj->Reset(); - fhMapBestPairsHodoS2GeoCut_H1->Reset(); - fhMapBestPairsHodoS2GeoCut_H2->Reset(); - fhMapBestPairsHodoS2GeoCut_S2->Reset(); - fhMapBestPairsHodoS2GeoCut_Proj->Reset(); - fhMapBestPairsHodoS1S2GeoCut_H1->Reset(); - fhMapBestPairsHodoS1S2GeoCut_H2->Reset(); - fhMapBestPairsHodoS1S2GeoCut_S1->Reset(); - fhMapBestPairsHodoS1S2GeoCut_Proj->Reset(); - fhMapBestPairsHodoS2S1GeoCut_H1->Reset(); - fhMapBestPairsHodoS2S1GeoCut_H2->Reset(); - fhMapBestPairsHodoS2S1GeoCut_S2->Reset(); - fhMapBestPairsHodoS2S1GeoCut_Proj->Reset(); - - fhResidualsBestPairsHodoS1GeoCut->Reset(); - fhResidualsBestPairsHodoS2GeoCut->Reset(); - fhResidualsBestPairsHodoS1S2GeoCut->Reset(); - fhResidualsBestPairsHodoS2S1GeoCut->Reset(); - - ///++++++++ Adrian ADC analysis, to be moved in other class! +++++/// - fhDtNeighborChansS1N->Reset(); - fhDtNeighborChansS1P->Reset(); - fhDtNeighborChansS2N->Reset(); - fhDtNeighborChansS2P->Reset(); - - fhClusterAdcVsSizeS1N->Reset(); - fhClusterAdcVsSizeS1P->Reset(); - fhClusterAdcVsSizeS2N->Reset(); - fhClusterAdcVsSizeS2P->Reset(); - - fhClusterAdcVsSizeS1N_MatchS1->Reset(); - fhClusterAdcVsSizeS1P_MatchS1->Reset(); - fhClusterAdcVsSizeS2N_MatchS2->Reset(); - fhClusterAdcVsSizeS2P_MatchS2->Reset(); - - fhClusterS1N_CenterNbMatchS1P->Reset(); - fhClusterS1P_CenterNbMatchS1N->Reset(); - fhClusterS2N_CenterNbMatchS2P->Reset(); - fhClusterS2P_CenterNbMatchS2N->Reset(); - - fhClusterS1N_AdcNbMatchS1P->Reset(); - fhClusterS1P_AdcNbMatchS1N->Reset(); - fhClusterS2N_AdcNbMatchS2P->Reset(); - fhClusterS2P_AdcNbMatchS2N->Reset(); - - fhDtNeighborChansH1X->Reset(); - fhDtNeighborChansH1Y->Reset(); - fhDtNeighborChansH2X->Reset(); - fhDtNeighborChansH2Y->Reset(); - - fhClusterAdcVsSizeH1X->Reset(); - fhClusterAdcVsSizeH1Y->Reset(); - fhClusterAdcVsSizeH2X->Reset(); - fhClusterAdcVsSizeH2Y->Reset(); - fhClusterPosition_MatchH1->Reset(); - fhClusterPosition_MatchH2->Reset(); - ///+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - - for( UInt_t uLinks = 0; uLinks < kiMaxNbFlibLinks; ++uLinks ) - { - TString sMsSzName = Form("MsSz_link_%02u", uLinks); - if( fHM->Exists(sMsSzName.Data() ) ) - fHM->H1( sMsSzName.Data() )->Reset(); - - sMsSzName = Form("MsSzTime_link_%02u", uLinks); - if( fHM->Exists(sMsSzName.Data() ) ) - fHM->P1( sMsSzName.Data() )->Reset(); - } // for( UInt_t uLinks = 0; uLinks < kiMaxNbFlibLinks; ++uLinks ) - - fdStartTime = -1; - fdStartTimeMsSz = -1; -} - -void CbmCosy2018MonitorEfficiency::SetRunStart( Int_t dateIn, Int_t timeIn, Int_t iBinSize ) -{ - TDatime * fRunStartDateTime = new TDatime( dateIn, timeIn); - fiRunStartDateTimeSec = fRunStartDateTime->Convert(); - fiBinSizeDatePlots = iBinSize; - - LOG(info) << "Assigned new MUCH Run Start Date-Time: " << fRunStartDateTime->AsString(); -} - -void CbmCosy2018MonitorEfficiency::SetLongDurationLimits( UInt_t uDurationSeconds, UInt_t uBinSize ) -{ - fbLongHistoEnable = kTRUE; - fuLongHistoNbSeconds = uDurationSeconds; - fuLongHistoBinSizeSec = uBinSize; -} - -void CbmCosy2018MonitorEfficiency::ComputeCoordinatesHodo1( Int_t iChanX, Int_t iChanY, Double_t & dPosX, Double_t & dPosY ) -{ - dPosX = 0.0; - dPosY = 0.0; - - UInt_t uFiberIdxX1 = fUnpackParHodo->GetChannelToFiberMap( iChanX ); - if( fUnpackParHodo->IsXInvertedHodo1() ) - uFiberIdxX1 = fuNbChanPerAsic/2 - 1 - uFiberIdxX1; - - UInt_t uFiberIdxY1 = fUnpackParHodo->GetChannelToFiberMap( iChanY ); - if( fUnpackParHodo->IsYInvertedHodo1() ) - uFiberIdxY1 = fuNbChanPerAsic/2 - 1 - uFiberIdxY1; - - dPosX = kdPitchHodoMm * uFiberIdxX1 - kdHodoMidXY; - dPosY = kdPitchHodoMm * uFiberIdxY1 - kdHodoMidXY; -} - -void CbmCosy2018MonitorEfficiency::ComputeCoordinatesHodo2( Int_t iChanX, Int_t iChanY, Double_t & dPosX, Double_t & dPosY ) -{ - dPosX = 0.0; - dPosY = 0.0; - - UInt_t uFiberIdxX2 = fUnpackParHodo->GetChannelToFiberMap( iChanX ); - if( fUnpackParHodo->IsXInvertedHodo2() ) - uFiberIdxX2 = fuNbChanPerAsic/2 - 1 - uFiberIdxX2; - - UInt_t uFiberIdxY2 = fUnpackParHodo->GetChannelToFiberMap( iChanY ); - if( fUnpackParHodo->IsYInvertedHodo2() ) - uFiberIdxY2 = fuNbChanPerAsic/2 - 1 - uFiberIdxY2; - - dPosX = kdPitchHodoMm * uFiberIdxX2 - kdHodoMidXY; - dPosY = kdPitchHodoMm * uFiberIdxY2 - kdHodoMidXY; -} - -void CbmCosy2018MonitorEfficiency::ComputeCoordinatesSensor1( Int_t iChanN, Int_t iChanP, Double_t & dPosX, Double_t & dPosY ) -{ - dPosX = 0.0; - dPosY = 0.0; - - Int_t iCoordN = iChanN + fiStripsOffsetN1; - Int_t iCoordP = iChanP + fiStripsOffsetP1; - - // TODO: Add inversion to STS param -// if( fUnpackParSts->IsXInvertedS2() ) - iCoordN *= -1; -// if( fUnpackParSts->IsYInvertedS2() ) - iCoordP *= -1; - - dPosX = iCoordN * kdPitchMm; - dPosY = ( iCoordN + iCoordP ) * kdPitchMm / fdStereoAngleTan + kdSensorsSzY / 2.0; -} - -void CbmCosy2018MonitorEfficiency::ComputeCoordinatesSensor2( Int_t iChanN, Int_t iChanP, Double_t & dPosX, Double_t & dPosY ) -{ - dPosX = 0.0; - dPosY = 0.0; - - Int_t iCoordN = iChanN + fiStripsOffsetN2; - Int_t iCoordP = iChanP + fiStripsOffsetP2; - - // TODO: Add inversion to STS param -// if( fUnpackParSts->IsXInvertedS2() ) - iCoordN *= -1; -// if( fUnpackParSts->IsYInvertedS2() ) - iCoordP *= -1; - - dPosX = iCoordN * kdPitchMm; - dPosY = ( iCoordN + iCoordP ) * kdPitchMm / fdStereoAngleTan + kdSensorsSzY / 2.0; -} - -void CbmCosy2018MonitorEfficiency::ComputeProjectionSensor1( Double_t dPosXH1, Double_t dPosYH1, - Double_t dPosXH2, Double_t dPosYH2, - Double_t & dPosX, Double_t & dPosY ) -{ - dPosX = ( dPosXH2 - dPosXH1 ) * fdRatioZS1 + dPosXH1; - dPosY = ( dPosYH2 - dPosYH1 ) * fdRatioZS1 + dPosYH1; -} - -void CbmCosy2018MonitorEfficiency::ComputeProjectionSensor2( Double_t dPosXH1, Double_t dPosYH1, - Double_t dPosXH2, Double_t dPosYH2, - Double_t & dPosX, Double_t & dPosY ) -{ - dPosX = ( dPosXH2 - dPosXH1 ) * fdRatioZS2 + dPosXH1; - dPosY = ( dPosYH2 - dPosYH1 ) * fdRatioZS2 + dPosYH1; -} - -Bool_t CbmCosy2018MonitorEfficiency::CheckPhysPairSensor1( Int_t iChanN, Int_t iChanP ) -{ - // Position in P/N strips - Int_t iCoordN = iChanN + fiStripsOffsetN1; - Int_t iCoordP = iChanP + fiStripsOffsetP1; - - // TODO: Add inversion to STS param -// if( fUnpackParSts->IsXInvertedS2() ) - iCoordN *= -1; -// if( fUnpackParSts->IsYInvertedS2() ) - iCoordP *= -1; - -// if( iCoordP < - iCoordN - fdStripRangeNP / 2 || - iCoordN + fdStripRangeNP / 2 < iCoordP ) - if( iCoordP < - iCoordN - fdStripRangeNP || - iCoordN < iCoordP ) - return kFALSE; - else return kTRUE; -} -Bool_t CbmCosy2018MonitorEfficiency::CheckPhysPairSensor2( Int_t iChanN, Int_t iChanP ) -{ - // Position in P/N strips - Int_t iCoordN = iChanN + fiStripsOffsetN2; - Int_t iCoordP = iChanP + fiStripsOffsetP2; - - // TODO: Add inversion to STS param -// if( fUnpackParSts->IsXInvertedS2() ) - iCoordN *= -1; -// if( fUnpackParSts->IsYInvertedS2() ) - iCoordP *= -1; - -// if( iCoordP < - iCoordN - fdStripRangeNP / 2 || - iCoordN + fdStripRangeNP / 2 < iCoordP ) - if( iCoordP < -iCoordN - fdStripRangeNP || -iCoordN < iCoordP ) - return kFALSE; - else return kTRUE; -} - -Bool_t CbmCosy2018MonitorEfficiency::CheckPointInsideSensor1( Double_t dPosX, Double_t dPosY ) -{ - // Input Position in mm inside sensor frame - Double_t dCoordN = dPosX / kdPitchMm; - Double_t dCoordP = ( dPosY - kdSensorsSzY / 2.0 ) * fdStereoAngleTan / kdPitchMm - dPosX / kdPitchMm; - - // TODO: Add inversion to STS param -// if( fUnpackParSts->IsXInvertedS2() ) - dCoordN *= -1; -// if( fUnpackParSts->IsYInvertedS2() ) - dCoordP *= -1; - - Int_t iChanN = dCoordN - fiStripsOffsetN1; - Int_t iChanP = dCoordP - fiStripsOffsetP1; - - if( iChanN < 0 || 127 < iChanN || iChanP < 0 || 127 < iChanP ) - return kFALSE; - - return CheckPhysPairSensor1( iChanN, iChanP ); -} - -Bool_t CbmCosy2018MonitorEfficiency::CheckPointInsideSensor2( Double_t dPosX, Double_t dPosY ) -{ - // Input Position in mm inside sensor frame - Double_t dCoordN = dPosX / kdPitchMm; - Double_t dCoordP = ( dPosY - kdSensorsSzY / 2.0 ) * fdStereoAngleTan / kdPitchMm - dPosX / kdPitchMm; - - // TODO: Add inversion to STS param -// if( fUnpackParSts->IsXInvertedS2() ) - dCoordN *= -1; -// if( fUnpackParSts->IsYInvertedS2() ) - dCoordP *= -1; - - Int_t iChanN = dCoordN - fiStripsOffsetN2; - Int_t iChanP = dCoordP - fiStripsOffsetP2; - - if( iChanN < 0 || 127 < iChanN || iChanP < 0 || 127 < iChanP ) - return kFALSE; - - return CheckPhysPairSensor2( iChanN, iChanP ); -} - -Bool_t CbmCosy2018MonitorEfficiency::CheckPointInsideSensor1NoDead( Double_t dPosX, Double_t dPosY ) -{ - // Input Position in mm inside sensor frame - - Double_t dCoordN = dPosX / kdPitchMm; - Double_t dCoordP = ( dPosY - kdSensorsSzY / 2.0 ) * fdStereoAngleTan / kdPitchMm - dPosX / kdPitchMm; - - // TODO: Add inversion to STS param -// if( fUnpackParSts->IsXInvertedS2() ) - dCoordN *= -1; -// if( fUnpackParSts->IsYInvertedS2() ) - dCoordP *= -1; - - Int_t iChanN = dCoordN - fiStripsOffsetN1; - Int_t iChanP = dCoordP - fiStripsOffsetP1; - - if( iChanN < 0 || 127 < iChanN || iChanP < 0 || 127 < iChanP ) - return kFALSE; - - for( UInt_t uDeadN = 0; uDeadN < kuNbDeadStripsS1N; ++uDeadN ) - if( kuDeadStripsS1N[uDeadN] == static_cast<UInt_t>( iChanN ) ) - return kFALSE; - for( UInt_t uDeadP = 0; uDeadP < kuNbDeadStripsS1P; ++uDeadP ) - if( kuDeadStripsS1P[uDeadP] == static_cast<UInt_t>( iChanP ) ) - return kFALSE; - - return CheckPhysPairSensor1( iChanN, iChanP ); -} - -Bool_t CbmCosy2018MonitorEfficiency::CheckPointInsideSensor2NoDead( Double_t dPosX, Double_t dPosY ) -{ - // Position in mm inside sensor frame - - Double_t dCoordN = dPosX / kdPitchMm; - Double_t dCoordP = ( dPosY - kdSensorsSzY / 2.0 ) * fdStereoAngleTan / kdPitchMm - dPosX / kdPitchMm; - - // TODO: Add inversion to STS param -// if( fUnpackParSts->IsXInvertedS2() ) - dCoordN *= -1; -// if( fUnpackParSts->IsYInvertedS2() ) - dCoordP *= -1; - - Int_t iChanN = dCoordN - fiStripsOffsetN2; - Int_t iChanP = dCoordP - fiStripsOffsetP2; - - if( iChanN < 0 || 127 < iChanN || iChanP < 0 || 127 < iChanP ) - return kFALSE; - - for( UInt_t uDeadN = 0; uDeadN < kuNbDeadStripsS2N; ++uDeadN ) - if( kuDeadStripsS2N[uDeadN] == static_cast<UInt_t>( iChanN ) ) - return kFALSE; - for( UInt_t uDeadP = 0; uDeadP < kuNbDeadStripsS2P; ++uDeadP ) - if( kuDeadStripsS2P[uDeadP] == static_cast<UInt_t>( iChanP ) ) - return kFALSE; - - return CheckPhysPairSensor2( iChanN, iChanP ); -} - -ClassImp(CbmCosy2018MonitorEfficiency) diff --git a/beamtime/cosy2018/unpacker/CbmCosy2018MonitorEfficiency.h b/beamtime/cosy2018/unpacker/CbmCosy2018MonitorEfficiency.h deleted file mode 100644 index b441962f31b0021ca114e2d6334108248dc0edb6..0000000000000000000000000000000000000000 --- a/beamtime/cosy2018/unpacker/CbmCosy2018MonitorEfficiency.h +++ /dev/null @@ -1,576 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmCosy2018MonitorEfficiency ----- -// ----- Created 18/04/18 by P.-A. Loizeau ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CBMCOSY2018MONITOREFFICIENCY_H -#define CBMCOSY2018MONITOREFFICIENCY_H - -#include "Timeslice.hpp" - -// Data -#include "StsXyterMessage.h" -#include "StsXyterFinalHit.h" - -// CbmRoot -#include "CbmTSUnpack.h" -#include "CbmHistManager.h" - -// C++11 -#include <chrono> - -// C/C++ -#include <vector> -#include <set> -#include <map> - -class CbmCern2017UnpackParHodo; -class CbmCern2017UnpackParSts; - -///++++++++ Adrian ADC analysis, to be moved in other class! +++++/// -class Cosy2018TestCluster -{ -public: - Cosy2018TestCluster( stsxyter::FinalHit hitFirst ); - - Bool_t CheckAddHit( stsxyter::FinalHit hitCandidate ); - - std::vector< stsxyter::FinalHit > fvHits; - Double_t fdMeanTime; - UShort_t fusTotalAdc; - UShort_t fusFirstChannel; - UShort_t fusLastChannel; - Double_t fdWeightedCenter; - -}; -///+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - -class CbmCosy2018MonitorEfficiency: public CbmTSUnpack -{ -public: - - CbmCosy2018MonitorEfficiency(); - virtual ~CbmCosy2018MonitorEfficiency(); - - virtual Bool_t Init(); - - virtual Bool_t DoUnpack(const fles::Timeslice& ts, size_t component); - - virtual void Reset(); - - virtual void Finish(); - - void SetParContainers(); - - Bool_t InitContainers(); - - Bool_t ReInitContainers(); - - void FillOutput(boost::any); - - void SetRunStart( Int_t dateIn, Int_t timeIn, Int_t iBinSize = 5 ); - - void ResetAllHistos(); - void SaveAllHistos( TString sFileName = "" ); - void SetHistoFileName( TString sFileName = "data/SetupHistos.root" ) { fsHistoFileFullname = sFileName; } - - void SetMsOverlap(size_t uOverlapMsNb = 1) { fuOverlapMsNb = uOverlapMsNb; } - size_t GetMsOverlap() { return fuOverlapMsNb; } - - void SetPrintMessage( Bool_t bPrintMessOn = kTRUE, - stsxyter::MessagePrintMask ctrl = stsxyter::MessagePrintMask::msg_print_Hex | - stsxyter::MessagePrintMask::msg_print_Human ) - { fbPrintMessages = bPrintMessOn; fPrintMessCtrl = ctrl; } - void EnableDualStsMode( Bool_t bEnable = kTRUE ) { fbDualStsEna = bEnable; } - void SetLongDurationLimits( UInt_t uDurationSeconds = 3600, UInt_t uBinSize = 1 ); - void SetCoincidenceBorderHodo( Double_t dCenterPos, Double_t dBorderVal ); - void SetCoincidenceBorderHodoBoth( Double_t dCenterPos, Double_t dBorderVal ); - void SetCoincidenceBorderSts1( Double_t dCenterPos, Double_t dBorderVal ); - void SetCoincidenceBorderSts2( Double_t dCenterPos, Double_t dBorderVal ); - void SetCoincidenceBorderHodoSts1( Double_t dCenterPos, Double_t dBorderVal ); - void SetCoincidenceBorderHodoSts2( Double_t dCenterPos, Double_t dBorderVal ); - void SetCoincidenceBorder( Double_t dCenterPos, Double_t dBorderVal ); - - void SetStripsOffset1( Int_t iOffN, Int_t iOffP ) { fiStripsOffsetN1 = iOffN; fiStripsOffsetP1 = iOffP; } - void SetStripsOffset2( Int_t iOffN, Int_t iOffP ) { fiStripsOffsetN2 = iOffN; fiStripsOffsetP2 = iOffP; } - void SetPositionOffsetSts1( Double_t dOffsetX, Double_t dOffsetY ) { fdOffsetS1X = dOffsetX; fdOffsetS1Y = dOffsetY; } - void SetPositionOffsetSts2( Double_t dOffsetX, Double_t dOffsetY ) { fdOffsetS2X = dOffsetX; fdOffsetS2Y = dOffsetY; } - - void SetPositionsMmZ( Double_t dPosH1, Double_t dPosH2, Double_t dPosS1, Double_t dPosS2 ); - - void EnableDeadCorr( Bool_t bEnable = kTRUE ) { fbDeadCorrEna = bEnable; } - -private: - size_t fuOverlapMsNb; /** Ignore Overlap Ms: all fuOverlapMsNb MS at the end of timeslice **/ - - // Parameters - CbmCern2017UnpackParHodo* fUnpackParHodo; //! - CbmCern2017UnpackParSts* fUnpackParSts; //! - UInt_t fuNrOfDpbs; //! Total number of Sts DPBs in system - std::map<UInt_t, UInt_t> fDpbIdIndexMap; //! Map of DPB Identifier to DPB index - UInt_t fuNbElinksPerDpb; //! Number of possible eLinks per DPB - UInt_t fuNbStsXyters; //! Number of StsXyter ASICs - UInt_t fuNbChanPerAsic; //! Number of channels per StsXyter ASIC => should be constant somewhere!!!! - std::vector< std::vector< UInt_t > > fvuElinkToAsic; //! Vector holding for each link the corresponding ASIC index [fuNrOfDpbs * fuNbElinksPerDpb] - - // Constants - static const Int_t kiMaxNbFlibLinks = 16; - static const UInt_t kuBytesPerMessage = 4; - - // Internal Control/status of monitor - // Histo File name and path - TString fsHistoFileFullname; - // Task configuration values - Bool_t fbPrintMessages; - stsxyter::MessagePrintMask fPrintMessCtrl; - Bool_t fbDualStsEna; - Bool_t fbDeadCorrEna; - // TS/MS info - ULong64_t fulCurrentTsIdx; - ULong64_t fulCurrentMsIdx; - // Current data properties - std::map< stsxyter::MessType, UInt_t > fmMsgCounter; - UInt_t fuCurrentEquipmentId; //! Current equipment ID, tells from which DPB the current MS is originating - UInt_t fuCurrDpbId; //! Temp holder until Current equipment ID is properly filled in MS - UInt_t fuCurrDpbIdx; //! Index of the DPB from which the MS currently unpacked is coming - Int_t fiRunStartDateTimeSec; //! Start of run time since "epoch" in s, for the plots with date as X axis - Int_t fiBinSizeDatePlots; //! Bin size in s for the plots with date as X axis - - // Data format control - std::vector< ULong64_t > fvulCurrentTsMsb; //! Current TS MSB for each DPB - std::vector< UInt_t > fvuCurrentTsMsbCycle; //! Current TS MSB cycle for DPB - std::vector< UInt_t > fvuElinkLastTsHit; //! TS from last hit for DPB - // Hits comparison - std::vector< std::vector< ULong64_t > > fvulChanLastHitTime; //! Last hit time in bins for each Channel - std::vector< std::vector< Double_t > > fvdChanLastHitTime; //! Last hit time in ns for each Channel - std::vector< Double_t > fvdMsTime; //! Header time of each MS - std::vector< std::vector< std::vector< UInt_t > > > fvuChanNbHitsInMs; //! Number of hits in each MS for each Channel - std::vector< std::vector< std::vector< Double_t > > > fvdChanLastHitTimeInMs; //! Last hit time in bins in each MS for each Channel - std::vector< std::vector< std::vector< UShort_t > > > fvusChanLastHitAdcInMs; //! Last hit ADC in bins in each MS for each Channel -// std::vector< std::vector< std::multiset< stsxyter::FinalHit > > > fvmChanHitsInTs; //! All hits (time & ADC) in bins in last TS for each Channel - // Starting state book-keeping - Double_t fdStartTime; /** Time of first valid hit (TS_MSB available), used as reference for evolution plots**/ - Double_t fdStartTimeMsSz; /** Time of first microslice, used as reference for evolution plots**/ - std::chrono::steady_clock::time_point ftStartTimeUnix; /** Time of run Start from UNIX system, used as reference for long evolution plots against reception time **/ - - // Hits time-sorting - std::vector< stsxyter::FinalHit > fvmHitsInTs; //! All hits (time in bins, ADC in bins, asic, channel) in last TS, sorted by multiset with "<" operator - stsxyter::FinalHit fLastSortedHit1X; //! Last sorted hit for Hodo 1 X - stsxyter::FinalHit fLastSortedHit1Y; //! Last sorted hit for Hodo 1 Y - stsxyter::FinalHit fLastSortedHit2X; //! Last sorted hit for Hodo 2 X - stsxyter::FinalHit fLastSortedHit2Y; //! Last sorted hit for Hodo 2 Y - stsxyter::FinalHit fLastSortedHit1N; //! Last sorted hit for STS 1 N - stsxyter::FinalHit fLastSortedHit1P; //! Last sorted hit for STS 1 P - stsxyter::FinalHit fLastSortedHit2N; //! Last sorted hit for STS 2 N - stsxyter::FinalHit fLastSortedHit2P; //! Last sorted hit for STS 2 P - // Coincidence histos - UInt_t fuMaxNbMicroslices; - // Rate evolution histos - Bool_t fbLongHistoEnable; - UInt_t fuLongHistoNbSeconds; - UInt_t fuLongHistoBinSizeSec; - UInt_t fuLongHistoBinNb; - - // Histograms - CbmHistManager* fHM; //! Histogram manager - TH1* fhHodoMessType; - TH1* fhHodoSysMessType; - TH2* fhHodoMessTypePerDpb; - TH2* fhHodoSysMessTypePerDpb; -/* - TH2* fhStsDpbRawTsMsb; - TH2* fhStsDpbRawTsMsbSx; - TH2* fhStsDpbRawTsMsbDpb; -*/ - TH2* fhHodoMessTypePerElink; - TH2* fhHodoSysMessTypePerElink; - - std::vector<TH1 *> fhHodoChanCntRaw; - std::vector<TH1 *> fhHodoChanCntRawGood; - std::vector<TH2 *> fhHodoChanAdcRaw; - std::vector<TProfile*> fhHodoChanAdcRawProf; - std::vector<TH2*> fhHodoChanRawTs; - std::vector<TH2*> fhHodoChanMissEvt; - std::vector<TH2*> fhHodoChanMissEvtEvo; - std::vector<TH2*> fhHodoChanHitRateEvo; - std::vector<TH1*> fhHodoFebRateEvo; - std::vector<TH1*> fhHodoFebMissEvtEvo; - std::vector<TH2*> fhHodoChanHitRateEvoLong; - std::vector<TH1*> fhHodoFebRateEvoLong; - - // Coincidences in sorted hits - Double_t fdCoincCenterHodo; // ns - Double_t fdCoincBorderHodo; // ns, +/- - Double_t fdCoincMinHodo; // ns - Double_t fdCoincMaxHodo; // ns - Double_t fdCoincCenterHodoBoth; // ns - Double_t fdCoincBorderHodoBoth; // ns, +/- - Double_t fdCoincMinHodoBoth; // ns - Double_t fdCoincMaxHodoBoth; // ns - Double_t fdCoincCenterSts1; // ns - Double_t fdCoincBorderSts1; // ns, +/- - Double_t fdCoincMinSts1; // ns - Double_t fdCoincMaxSts1; // ns - Double_t fdCoincCenterSts2; // ns - Double_t fdCoincBorderSts2; // ns, +/- - Double_t fdCoincMinSts2; // ns - Double_t fdCoincMaxSts2; // ns - Double_t fdCoincCenterHodoS1; // ns - Double_t fdCoincBorderHodoS1; // ns, +/- - Double_t fdCoincMinHodoS1; // ns - Double_t fdCoincMaxHodoS1; // ns - Double_t fdCoincCenterHodoS2; // ns - Double_t fdCoincBorderHodoS2; // ns, +/- - Double_t fdCoincMinHodoS2; // ns - Double_t fdCoincMaxHodoS2; // ns - Double_t fdCoincCenter; // ns - Double_t fdCoincBorder; // ns, +/- - Double_t fdCoincMin; // ns - Double_t fdCoincMax; // ns - // Single detector maps - TH1 * fhSetupSortedDtX1Y1; - TH1 * fhSetupSortedDtX2Y2; - TH1 * fhSetupSortedDtN1P1; - TH1 * fhSetupSortedDtN2P2; - TH1 * fhSetupSortedDtX1Y1X2Y2; - TH1 * fhSetupSortedDtN1P1N2P2; - TH1 * fhSetupSortedDtX1Y1X2Y2N1P1; - TH1 * fhSetupSortedDtX1Y1X2Y2N2P2; - TH1 * fhSetupSortedDtH1H2S1S2; - TH2 * fhSetupSortedMapX1Y1; - TH2 * fhSetupSortedMapX2Y2; - TH2 * fhSetupSortedMapN1P1; - TH2 * fhSetupSortedMapN2P2; - TH1 * fhSetupSortedCntEvoX1Y1; - TH1 * fhSetupSortedCntEvoX2Y2; - TH1 * fhSetupSortedCntEvoN1P1; - TH1 * fhSetupSortedCntEvoN2P2; - - TH1 * fhSetupSortedDtX1; - TH1 * fhSetupSortedDtY1; - TH1 * fhSetupSortedDtX2; - TH1 * fhSetupSortedDtY2; - TH1 * fhSetupSortedDtN1; - TH1 * fhSetupSortedDtP1; - TH1 * fhSetupSortedDtN2; - TH1 * fhSetupSortedDtP2; - - /// Counting hits without proper timestamp - std::vector< std::vector< ULong64_t > > fvulTimeLastHitAsicChan; - std::vector< std::vector< Int_t > > fviAdcLastHitAsicChan; - std::vector< std::vector< UInt_t > > fvuNbSameHitAsicChan; - std::vector< std::vector< UInt_t > > fvuNbSameFullHitAsicChan; - - std::vector< ULong64_t > fvulStartTimeLastS; - std::vector< UInt_t > fvuNbHitDiffTsAsicLastS; - std::vector< UInt_t > fvuNbHitSameTsAsicLastS; - std::vector< UInt_t > fvuNbHitSameTsAdcAsicLastS; - - std::vector< Bool_t > fvbAsicHasDuplicInMs; - - std::vector< TH2 * > fhSetupSortedNbSameTsChan; - std::vector< TH2 * > fhSetupSortedSameTsAdcChan; - std::vector< TH2 * > fhSetupSortedSameTsAdcDiff; - std::vector< TProfile2D * > fhSetupSortedRatioSameTsChan; - std::vector< TH2 * > fhSetupSortedNbConsSameTsChan; - std::vector< TH2 * > fhSetupSortedNbConsSameTsAdcChan; - std::vector< TH2 * > fhSetupSortedNbConsSameTsVsTsAdc; - - std::vector< TH2 * > fhSetupSortedAsicRatioSameTsVsFlux; - std::vector< TH2 * > fhSetupSortedAsicRatioSameTsAdcVsFlux; - std::vector< TH2 * > fhSetupSortedAsicRatioSameAdcSameTsVsFlux; - - TH1 * fhSetupSortedCleanMsDtH1H2S1S2; - TProfile * fhRatioMsDuplicateQuality; - std::vector< TProfile * > fhEvoMsDuplicateQuality; - TH1 * fhSizeCleanMs; - - TH2 * fhHodoX1SpillEvo; - TH2 * fhHodoY1SpillEvo; - TH2 * fhHodoX2SpillEvo; - TH2 * fhHodoY2SpillEvo; - - Double_t fdSpillEvoLength; - TProfile * fhHodoX1SpillEvoProf; - TProfile * fhHodoY1SpillEvoProf; - TProfile * fhHodoX2SpillEvoProf; - TProfile * fhHodoY2SpillEvoProf; - - const Double_t kdStereoAngle = 7.5; // [Deg] - Double_t fdStereoAngleTan; - const Double_t kdPitchMm = 0.058; // [mm] - const Int_t kiNbStrips = 1024; - const Double_t kdSensorsSzX = 60; // [mm], active is 59.570 mm (kiNbStrips*kdPitchMm) - const Double_t kdSensorsSzY = 40; // [mm], active is 39.703 mm - Double_t fdStripRangeNP; - const Int_t kiNbFibers = 64; - const Double_t kdHodoSzXY = 64; // [mm] - const Double_t kdHodoMidXY = kdHodoSzXY / 2.0; // [mm] - const Double_t kdPitchHodoMm = kdHodoSzXY/ kiNbFibers; // [mm] - Int_t fiStripsOffsetN1; // of channel 0 relative to center strip - Int_t fiStripsOffsetP1; // of channel 0 relative to center strip - Int_t fiStripsOffsetN2; // of channel 0 relative to center strip - Int_t fiStripsOffsetP2; // of channel 0 relative to center strip - TH2 * fhStsSortedMapS1; - TH2 * fhStsSortedMapS2; - TH2 * fhStsSortedMapS1Coinc; - TH2 * fhStsSortedMapS2Coinc; - - ///------ Coincidence building and effciency measurement ---------/// - Double_t fdPosZH1; // [mm] - Double_t fdPosZH2; // [mm] - Double_t fdPosZS1; // [mm] - Double_t fdPosZS2; // [mm] - Double_t fdRatioZS1; - Double_t fdRatioZS2; - Double_t fdOffsetS1X; // [mm] - Double_t fdOffsetS1Y; // [mm] - Double_t fdOffsetS2X; // [mm] - Double_t fdOffsetS2Y; // [mm] - - std::vector< std::pair< stsxyter::FinalHit, stsxyter::FinalHit > > fvPairsH1; //! - std::vector< std::pair< stsxyter::FinalHit, stsxyter::FinalHit > > fvPairsH2; //! - std::vector< std::pair< stsxyter::FinalHit, stsxyter::FinalHit > > fvPairsS1; //! - std::vector< std::pair< stsxyter::FinalHit, stsxyter::FinalHit > > fvPairsS2; //! - std::vector< std::pair< UInt_t, UInt_t > > fvPairsHodo; - std::vector< std::pair< UInt_t, UInt_t > > fvPairsHodoS1; - std::vector< std::pair< UInt_t, UInt_t > > fvPairsHodoS2; - std::vector< std::pair< UInt_t, UInt_t > > fvPairsHodoS1S2; - std::vector< std::pair< UInt_t, UInt_t > > fvPairsHodoS2S1; - - TH1 * fhNbY1CoincPerX1; - TH1 * fhNbY2CoincPerX2; - TH1 * fhNbP1CoincPerN1; - TH1 * fhNbP2CoincPerN2; - TH1 * fhNbH2CoincPerH1; - TH1 * fhNbS1CoincPerHodo; - TH1 * fhNbS2CoincPerHodo; - TH1 * fhNbS1CoincPerHodoS2; - TH1 * fhNbS2CoincPerHodoS1; - TH1 * fhNbS1CoincPerHodoGeoCut; - TH1 * fhNbS2CoincPerHodoGeoCut; - TH1 * fhNbS1CoincPerHodoS2GeoCut; - TH1 * fhNbS2CoincPerHodoS1GeoCut; - - TH2 * fhChanMapAllMatchS1; - TH2 * fhChanMapAllMatchS2; - TH2 * fhChanMapBestMatchS1; - TH2 * fhChanMapBestMatchS2; - - TH1 * fhDtAllPairsS1; - TH1 * fhDtAllPairsS2; - TH1 * fhDtAllPairsHodoS1; - TH1 * fhDtAllPairsHodoS2; - TH1 * fhDtBestPairsH1; - TH1 * fhDtBestPairsH2; - TH1 * fhDtBestPairsS1; - TH1 * fhDtBestPairsS2; - TH1 * fhDtBestPairsHodo; - TH1 * fhDtBestPairsHodoS1; - TH1 * fhDtBestPairsHodoS2; - TH1 * fhDtBestPairsHodoS1S2; - TH1 * fhDtBestPairsHodoS2S1; - TH1 * fhDtBestPairsHodoS1GeoCut; - TH1 * fhDtBestPairsHodoS2GeoCut; - TH1 * fhDtBestPairsHodoS1S2GeoCut; - TH1 * fhDtBestPairsHodoS2S1GeoCut; - - TH2 * fhMapBestPairsH1; - TH2 * fhMapBestPairsH2; - TH2 * fhMapBestPairsS1; - TH2 * fhMapBestPairsS2; - TH2 * fhMapBestPairsHodo_H1; - TH2 * fhMapBestPairsHodo_H2; - TH2 * fhMapBestPairsHodo_ProjS1; - TH2 * fhMapBestPairsHodo_ProjS2; - TH2 * fhMapBestPairsHodoS1_H1; - TH2 * fhMapBestPairsHodoS1_H2; - TH2 * fhMapBestPairsHodoS1_S1; - TH2 * fhMapBestPairsHodoS1_Proj; - TH2 * fhMapBestPairsHodoS2_H1; - TH2 * fhMapBestPairsHodoS2_H2; - TH2 * fhMapBestPairsHodoS2_S2; - TH2 * fhMapBestPairsHodoS2_Proj; - TH2 * fhMapBestPairsHodoS1S2_H1; - TH2 * fhMapBestPairsHodoS1S2_H2; - TH2 * fhMapBestPairsHodoS1S2_S1; - TH2 * fhMapBestPairsHodoS1S2_Proj; - TH2 * fhMapBestPairsHodoS2S1_H1; - TH2 * fhMapBestPairsHodoS2S1_H2; - TH2 * fhMapBestPairsHodoS2S1_S2; - TH2 * fhMapBestPairsHodoS2S1_Proj; - - TH2 * fhMapBestPairsHodoGeoCutS1_H1; - TH2 * fhMapBestPairsHodoGeoCutS1_H2; - TH2 * fhMapBestPairsHodoGeoCutS1_Proj; - TH2 * fhMapBestPairsHodoGeoCutS2_H1; - TH2 * fhMapBestPairsHodoGeoCutS2_H2; - TH2 * fhMapBestPairsHodoGeoCutS2_Proj; - TH2 * fhMapBestPairsHodoS1GeoCut_H1; - TH2 * fhMapBestPairsHodoS1GeoCut_H2; - TH2 * fhMapBestPairsHodoS1GeoCut_S1; - TH2 * fhMapBestPairsHodoS1GeoCut_Proj; - TH2 * fhMapBestPairsHodoS2GeoCut_H1; - TH2 * fhMapBestPairsHodoS2GeoCut_H2; - TH2 * fhMapBestPairsHodoS2GeoCut_S2; - TH2 * fhMapBestPairsHodoS2GeoCut_Proj; - TH2 * fhMapBestPairsHodoS1S2GeoCut_H1; - TH2 * fhMapBestPairsHodoS1S2GeoCut_H2; - TH2 * fhMapBestPairsHodoS1S2GeoCut_S1; - TH2 * fhMapBestPairsHodoS1S2GeoCut_Proj; - TH2 * fhMapBestPairsHodoS2S1GeoCut_H1; - TH2 * fhMapBestPairsHodoS2S1GeoCut_H2; - TH2 * fhMapBestPairsHodoS2S1GeoCut_S2; - TH2 * fhMapBestPairsHodoS2S1GeoCut_Proj; - - TH2 * fhResidualsBestPairsHodoS1; - TH2 * fhResidualsBestPairsHodoS2; - TH2 * fhResidualsBestPairsHodoS1S2; - TH2 * fhResidualsBestPairsHodoS2S1; - TH2 * fhResidualsBestPairsHodoS1GeoCut; - TH2 * fhResidualsBestPairsHodoS2GeoCut; - TH2 * fhResidualsBestPairsHodoS1S2GeoCut; - TH2 * fhResidualsBestPairsHodoS2S1GeoCut; - - TH2 * fhAdcRawBestPairsHodoS1N; - TH2 * fhAdcRawBestPairsHodoS1P; - TH2 * fhAdcRawBestPairsHodoS2N; - TH2 * fhAdcRawBestPairsHodoS2P; - TH2 * fhAdcRawBestPairsHodoS1S2N; - TH2 * fhAdcRawBestPairsHodoS1S2P; - TH2 * fhAdcRawBestPairsHodoS2S1N; - TH2 * fhAdcRawBestPairsHodoS2S1P; - - TProfile * fhEfficiency; - TProfile2D * fhEfficiencyMapS1; - TProfile2D * fhEfficiencyMapS2; - TProfile2D * fhEfficiencyMapS1S2; - TProfile2D * fhEfficiencyMapS2S1; - TProfile2D * fhEfficiencyMapS1GeoCut; - TProfile2D * fhEfficiencyMapS2GeoCut; - TProfile2D * fhEfficiencyMapS1S2GeoCut; - TProfile2D * fhEfficiencyMapS2S1GeoCut; - - ///---------------------------------------------------------------/// - TCanvas * fcCanvasProjectionMaps; - TCanvas * fcCanvasEfficiencyMaps; - ///---------------------------------------------------------------/// - - - TCanvas* fcMsSizeAll; - TH1* fhMsSz[kiMaxNbFlibLinks]; - TProfile* fhMsSzTime[kiMaxNbFlibLinks]; - - TH2 * fhTestBoundariesSensor1; - TH2 * fhTestBoundariesSensor2; - TH2 * fhTestBoundariesSensor1NoDead; - TH2 * fhTestBoundariesSensor2NoDead; - TH2 * fhTestChanMatchSensor1; - TH2 * fhTestChanMatchSensor2; - TH2 * fhTestChanMapSensor1; - TH2 * fhTestChanMapSensor2; - TH2 * fhTestChanMapPhysSensor1; - TH2 * fhTestChanMapPhysSensor2; - - std::vector< stsxyter::FinalHit > fvHitsS1N; //! - std::vector< stsxyter::FinalHit > fvHitsS1P; //! - std::vector< stsxyter::FinalHit > fvHitsS2N; //! - std::vector< stsxyter::FinalHit > fvHitsS2P; //! - TProfile2D * fhTestMapHodoS1N; - TProfile2D * fhTestMapHodoS1P; - TProfile2D * fhTestMapHodoS2N; - TProfile2D * fhTestMapHodoS2P; - - ///++++++++ Adrian ADC analysis, to be moved in other class! +++++/// - TH2 * fhDtNeighborChansS1N; - TH2 * fhDtNeighborChansS1P; - TH2 * fhDtNeighborChansS2N; - TH2 * fhDtNeighborChansS2P; - std::vector< stsxyter::FinalHit > fvLastHitChanS1N; //! - std::vector< stsxyter::FinalHit > fvLastHitChanS1P; //! - std::vector< stsxyter::FinalHit > fvLastHitChanS2N; //! - std::vector< stsxyter::FinalHit > fvLastHitChanS2P; //! - std::vector< Cosy2018TestCluster > fvClustersS1N; //! - std::vector< Cosy2018TestCluster > fvClustersS1P; //! - std::vector< Cosy2018TestCluster > fvClustersS2N; //! - std::vector< Cosy2018TestCluster > fvClustersS2P; //! - TH2 * fhClusterAdcVsSizeS1N; - TH2 * fhClusterAdcVsSizeS1P; - TH2 * fhClusterAdcVsSizeS2N; - TH2 * fhClusterAdcVsSizeS2P; - TH2 * fhClusterAdcVsSizeS1N_MatchS1; - TH2 * fhClusterAdcVsSizeS1P_MatchS1; - TH2 * fhClusterAdcVsSizeS2N_MatchS2; - TH2 * fhClusterAdcVsSizeS2P_MatchS2; - TH2 * fhClusterS1N_CenterNbMatchS1P; - TH2 * fhClusterS1P_CenterNbMatchS1N; - TH2 * fhClusterS2N_CenterNbMatchS2P; - TH2 * fhClusterS2P_CenterNbMatchS2N; - TH2 * fhClusterS1N_AdcNbMatchS1P; - TH2 * fhClusterS1P_AdcNbMatchS1N; - TH2 * fhClusterS2N_AdcNbMatchS2P; - TH2 * fhClusterS2P_AdcNbMatchS2N; - - TH2 * fhDtNeighborChansH1X; - TH2 * fhDtNeighborChansH1Y; - TH2 * fhDtNeighborChansH2X; - TH2 * fhDtNeighborChansH2Y; - std::vector< stsxyter::FinalHit > fvLastHitChanH1X; //! - std::vector< stsxyter::FinalHit > fvLastHitChanH1Y; //! - std::vector< stsxyter::FinalHit > fvLastHitChanH2X; //! - std::vector< stsxyter::FinalHit > fvLastHitChanH2Y; //! - std::vector< Cosy2018TestCluster > fvClustersH1X; //! - std::vector< Cosy2018TestCluster > fvClustersH1Y; //! - std::vector< Cosy2018TestCluster > fvClustersH2X; //! - std::vector< Cosy2018TestCluster > fvClustersH2Y; //! - TH2 * fhClusterAdcVsSizeH1X; - TH2 * fhClusterAdcVsSizeH1Y; - TH2 * fhClusterAdcVsSizeH2X; - TH2 * fhClusterAdcVsSizeH2Y; - TH2 * fhClusterPosition_MatchH1; - TH2 * fhClusterPosition_MatchH2; - ///+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - - - void CreateHistograms(); - - void FillHitInfo( stsxyter::Message mess, const UShort_t & usElinkIdx, const UInt_t & uAsicIdx, const UInt_t & uMsIdx ); - void FillTsMsbInfo( stsxyter::Message mess, UInt_t uMessIdx = 0, UInt_t uMsIdx = 0); - void FillEpochInfo( stsxyter::Message mess ); - - void ComputeCoordinatesHodo1( Int_t iChanX, Int_t iChanY, Double_t & dPosX, Double_t & dPosY ); - void ComputeCoordinatesHodo2( Int_t iChanX, Int_t iChanY, Double_t & dPosX, Double_t & dPosY ); - void ComputeCoordinatesSensor1( Int_t iChanN, Int_t iChanP, Double_t & dPosX, Double_t & dPosY ); - void ComputeCoordinatesSensor2( Int_t iChanN, Int_t iChanP, Double_t & dPosX, Double_t & dPosY ); - void ComputeProjectionSensor1( Double_t dPosXH1, Double_t dPosYH1, - Double_t dPosXH2, Double_t dPosYH2, - Double_t & dPosX, Double_t & dPosY ); - void ComputeProjectionSensor2( Double_t dPosXH1, Double_t dPosYH1, - Double_t dPosXH2, Double_t dPosYH2, - Double_t & dPosX, Double_t & dPosY ); - - Bool_t CheckPhysPairSensor1( Int_t iChanN, Int_t iChanP ); // Position in P/N strips - Bool_t CheckPhysPairSensor2( Int_t iChanN, Int_t iChanP ); // Position in P/N strips - Bool_t CheckPointInsideSensor1( Double_t dPosX, Double_t dPosY ); // Position in mm inside sensor XY frame - Bool_t CheckPointInsideSensor2( Double_t dPosX, Double_t dPosY ); // Position in mm inside sensor XY frame - - static const UInt_t kuNbDeadStripsS1N = 4; - const UInt_t kuDeadStripsS1N[ kuNbDeadStripsS1N ] = { 124, 125, 126, 127 }; - static const UInt_t kuNbDeadStripsS1P = 5; - const UInt_t kuDeadStripsS1P[ kuNbDeadStripsS1P ] = { 1, 123, 124, 126, 127 }; - static const UInt_t kuNbDeadStripsS2N = 9 + 2; - const UInt_t kuDeadStripsS2N[ kuNbDeadStripsS2N ] = { 0, 1, 2, 3, 4, 6, 8, 10, 12, 126, 127 }; - static const UInt_t kuNbDeadStripsS2P = 8 + 3 + 4; - const UInt_t kuDeadStripsS2P[ kuNbDeadStripsS2P ] = { 0, 1, 2, 3, 4, 5, 6, 8, 36, 40, 64, 124, 125, 126, 127 }; - Bool_t CheckPointInsideSensor1NoDead( Double_t dPosX, Double_t dPosY ); // Position in mm inside sensor XY frame - Bool_t CheckPointInsideSensor2NoDead( Double_t dPosX, Double_t dPosY ); // Position in mm inside sensor XY frame - - CbmCosy2018MonitorEfficiency(const CbmCosy2018MonitorEfficiency&); - CbmCosy2018MonitorEfficiency operator=(const CbmCosy2018MonitorEfficiency&); - - ClassDef(CbmCosy2018MonitorEfficiency, 1) -}; - -#endif // CBMCOSY2018MONITOREFFICIENCY_H diff --git a/beamtime/cosy2018/unpacker/CbmCosy2018MonitorHodo.cxx b/beamtime/cosy2018/unpacker/CbmCosy2018MonitorHodo.cxx deleted file mode 100644 index 68052a7a588a2f6f6643defcd4d3bcb46c834cc0..0000000000000000000000000000000000000000 --- a/beamtime/cosy2018/unpacker/CbmCosy2018MonitorHodo.cxx +++ /dev/null @@ -1,1985 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmCosy2018MonitorHodo ----- -// ----- Created 15/02/18 by P.-A. Loizeau ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#include "CbmCosy2018MonitorHodo.h" - -// Data - -// CbmRoot -#include "CbmCern2017UnpackParHodo.h" -#include "CbmHistManager.h" - -// FairRoot -#include "FairLogger.h" -#include "FairRootManager.h" -#include "FairRun.h" -#include "FairRuntimeDb.h" -#include "FairRunOnline.h" - -// Root -#include "TClonesArray.h" -#include "TString.h" -#include "TRandom.h" -#include "THttpServer.h" -#include "TROOT.h" -#include "TStyle.h" -#include <TFile.h> - -// C++11 - -// C/C++ -#include <iostream> -#include <stdint.h> -#include <iomanip> - -Bool_t bCosy2018ResetHodoHistos = kFALSE; -Bool_t bCosy2018WriteHodoHistos = kFALSE; - -CbmCosy2018MonitorHodo::CbmCosy2018MonitorHodo() : - CbmTSUnpack(), - fuOverlapMsNb(0), - fUnpackPar(NULL), - fuNrOfDpbs(0), - fDpbIdIndexMap(), - fuNbElinksPerDpb(0), - fuNbStsXyters(0), - fuNbChanPerAsic(0), - fvuElinkToAsic(), - fbPrintMessages( kFALSE ), - fPrintMessCtrl( stsxyter::MessagePrintMask::msg_print_Human ), - fulCurrentTsIdx( 0 ), - fulCurrentMsIdx( 0 ), - fmMsgCounter(), - fuCurrentEquipmentId(0), - fuCurrDpbId(0), - fuCurrDpbIdx(0), - fiRunStartDateTimeSec(-1), - fiBinSizeDatePlots(-1), - fvulCurrentTsMsb(), - fvuCurrentTsMsbCycle(), - fvuElinkLastTsHit(), - fvulChanLastHitTime(), - fvdChanLastHitTime(), - fvdMsTime(), - fvuChanNbHitsInMs(), - fvdChanLastHitTimeInMs(), - fvusChanLastHitAdcInMs(), -// fvmChanHitsInTs(), - fdStartTime(-1.0), - fdStartTimeMsSz(-1.0), - ftStartTimeUnix( std::chrono::steady_clock::now() ), - fvmHitsInTs(), - fLastSortedHit1X(), - fLastSortedHit1Y(), - fLastSortedHit2X(), - fLastSortedHit2Y(), - fuMaxNbMicroslices(100), - fbLongHistoEnable( kFALSE ), - fuLongHistoNbSeconds( 0 ), - fuLongHistoBinSizeSec( 0 ), - fuLongHistoBinNb( 0 ), - fHM(new CbmHistManager()), - fhHodoMessType(NULL), - fhHodoSysMessType(NULL), - fhHodoMessTypePerDpb(NULL), - fhHodoSysMessTypePerDpb(NULL), - fhHodoMessTypePerElink(NULL), - fhHodoSysMessTypePerElink(NULL), - fhHodoChanCntRaw(), - fhHodoChanAdcRaw(), - fhHodoChanAdcRawProf(), - fhHodoChanRawTs(), - fhHodoChanMissEvt(), - fhHodoChanHitRateEvo(), - fhHodoFebRateEvo(), - fhHodoChanHitRateEvoLong(), - fhHodoFebRateEvoLong(), - fhHodoChanCounts1X(NULL), - fhHodoChanCounts1Y(NULL), - fhHodoChanCounts2X(NULL), - fhHodoChanCounts2Y(NULL), - fhHodoChanAdcRaw1X(NULL), - fhHodoChanAdcRaw1Y(NULL), - fhHodoChanAdcRaw2X(NULL), - fhHodoChanAdcRaw2Y(NULL), - fhHodoChanHitRateEvo1X(NULL), - fhHodoChanHitRateEvo1Y(NULL), - fhHodoChanHitRateEvo2X(NULL), - fhHodoChanHitRateEvo2Y(NULL), - fhHodoRateEvo1X(NULL), - fhHodoRateEvo1Y(NULL), - fhHodoRateEvo2X(NULL), - fhHodoRateEvo2Y(NULL), - fdCoincBorder( 50.0 ), - fhHodoSortedDtX1Y1(NULL), - fhHodoSortedDtX2Y2(NULL), - fhHodoSortedDtX1X2(NULL), - fhHodoSortedDtY1Y2(NULL), - fhHodoSortedDtX1Y2(NULL), - fhHodoSortedDtY1X2(NULL), - fhHodoSortedMapX1Y1(NULL), - fhHodoSortedMapX2Y2(NULL), - fhHodoSortedMapX1X2(NULL), - fhHodoSortedMapY1Y2(NULL), - fhHodoSortedMapX1Y2(NULL), - fhHodoSortedMapY1X2(NULL), - fhHodoSortedCntEvoX1Y1(NULL), - fhHodoSortedCntEvoX2Y2(NULL), - fhHodoSortedCntEvoX1X2(NULL), - fhHodoSortedCntEvoY1Y2(NULL), - fhHodoSortedCntEvoX1Y2(NULL), - fhHodoSortedCntEvoY1X2(NULL), -// fhHodoFebTsMsb(NULL), - fcMsSizeAll(NULL) -{ -} - -CbmCosy2018MonitorHodo::~CbmCosy2018MonitorHodo() -{ -} - -Bool_t CbmCosy2018MonitorHodo::Init() -{ - LOG(info) << "Initializing flib StsXyter unpacker for STS"; - - FairRootManager* ioman = FairRootManager::Instance(); - if (ioman == NULL) { - LOG(fatal) << "No FairRootManager instance"; - } - - return kTRUE; -} - -void CbmCosy2018MonitorHodo::SetParContainers() -{ - LOG(info) << "Setting parameter containers for " << GetName(); - fUnpackPar = (CbmCern2017UnpackParHodo*)(FairRun::Instance()->GetRuntimeDb()->getContainer("CbmCern2017UnpackParHodo")); -} - - -Bool_t CbmCosy2018MonitorHodo::InitContainers() -{ - LOG(info) << "Init parameter containers for " << GetName(); - - Bool_t bReInit = ReInitContainers(); - CreateHistograms(); - - return bReInit; -} - -Bool_t CbmCosy2018MonitorHodo::ReInitContainers() -{ - LOG(info) << "ReInit parameter containers for " << GetName(); - - fuNrOfDpbs = fUnpackPar->GetNrOfDpbs(); - fuNbElinksPerDpb = fUnpackPar->GetNbElinksPerDpb(); - fuNbStsXyters = fUnpackPar->GetNbStsXyters(); - fuNbChanPerAsic = fUnpackPar->GetNbChanPerAsic(); - - - LOG(info) << "Nr. of STS DPBs: " << fuNrOfDpbs; - - fDpbIdIndexMap.clear(); - fvuElinkToAsic.resize( fuNrOfDpbs ); - for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - { - fDpbIdIndexMap[ fUnpackPar->GetDpbId( uDpb ) ] = uDpb; - LOG(info) << "Eq. ID for DPB #" << std::setw(2) << uDpb << " = " - << std::setw(4) << std::hex << fUnpackPar->GetDpbId( uDpb ) - << std::dec - << " => " << fDpbIdIndexMap[ fUnpackPar->GetDpbId( uDpb ) ]; - - fvuElinkToAsic[uDpb].resize( fuNbElinksPerDpb ); - for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink ) - fvuElinkToAsic[uDpb][uElink] = fUnpackPar->GetElinkToAsicIdx( uDpb * fuNbElinksPerDpb + uElink ); - } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - - LOG(info) << "Nr. eLinks per DPB: " << fuNbElinksPerDpb; - LOG(info) << "Nr. of StsXyter ASICs: " << fuNbStsXyters; - LOG(info) << "Nb. channels per ASIC: " << fuNbChanPerAsic; - - for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - { - LOG(info) << "ASIC ID for eLinks in DPB #" << std::setw(2) << uDpb << ": "; - - std::stringstream ss; - for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink ) - { - if( 0 == uElink % 10 ) - ss << "\n------> "; - - ss << std::setw( 5 ) << fvuElinkToAsic[uDpb][uElink] << " "; - } // for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink ) - LOG(info) << ss.str(); - } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - - LOG(info) << "ASIC Idx for Hodo 1: " << fUnpackPar->GetAsicIndexHodo1(); - LOG(info) << "ASIC Idx for Hodo 2: " << fUnpackPar->GetAsicIndexHodo2(); - - LOG(info) << "XY swapped in Hodo 1: " << fUnpackPar->IsXySwappedHodo1(); - LOG(info) << "XY swapped in Hodo 2: " << fUnpackPar->IsXySwappedHodo2(); - - LOG(info) << "X axis inverted in Hodo 1: " << fUnpackPar->IsXInvertedHodo1(); - LOG(info) << "X axis inverted in Hodo 1: " << fUnpackPar->IsYInvertedHodo1(); - LOG(info) << "X axis inverted in Hodo 2: " << fUnpackPar->IsXInvertedHodo2(); - LOG(info) << "X axis inverted in Hodo 2: " << fUnpackPar->IsYInvertedHodo2(); - - // Internal status initialization - fvulCurrentTsMsb.resize( fuNrOfDpbs ); - fvuCurrentTsMsbCycle.resize( fuNrOfDpbs ); - fvuElinkLastTsHit.resize( fuNrOfDpbs ); - for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - { - fvulCurrentTsMsb[uDpb] = 0; - fvuCurrentTsMsbCycle[uDpb] = 0; -/* - fvuElinkLastTsHit[uDpb].resize( fuNbElinksPerDpb ); - for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink ) - { - fvuElinkLastTsHit[uDpb][uElink] = 0; - } // for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink ) -*/ - } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - - fvulChanLastHitTime.resize( fuNbStsXyters ); - fvdChanLastHitTime.resize( fuNbStsXyters ); - fvdMsTime.resize( fuMaxNbMicroslices ); - fvuChanNbHitsInMs.resize( fuNbStsXyters ); - fvdChanLastHitTimeInMs.resize( fuNbStsXyters ); - fvusChanLastHitAdcInMs.resize( fuNbStsXyters ); -// fvmChanHitsInTs.resize( fuNbStsXyters ); - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fvulChanLastHitTime[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvdChanLastHitTime[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvuChanNbHitsInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvdChanLastHitTimeInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvusChanLastHitAdcInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); -// fvmChanHitsInTs[ uXyterIdx ].resize( fuNbChanPerAsic ); - for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - { - fvulChanLastHitTime[ uXyterIdx ][ uChan ] = 0; - fvdChanLastHitTime[ uXyterIdx ][ uChan ] = -1.0; - - fvuChanNbHitsInMs[ uXyterIdx ][ uChan ].resize( fuMaxNbMicroslices ); - fvdChanLastHitTimeInMs[ uXyterIdx ][ uChan ].resize( fuMaxNbMicroslices ); - fvusChanLastHitAdcInMs[ uXyterIdx ][ uChan ].resize( fuMaxNbMicroslices ); -// fvmChanHitsInTs[ uXyterIdx ][ uChan ].clear(); - for( UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx ) - { - fvuChanNbHitsInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = 0; - fvdChanLastHitTimeInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = -1.0; - fvusChanLastHitAdcInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = 0; - } // for( UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx ) - } // for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - LOG(info) << "CbmCosy2018MonitorHodo::ReInitContainers => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs.size() << " VS " << fuNbStsXyters; - LOG(info) << "CbmCosy2018MonitorHodo::ReInitContainers => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs[ 0 ].size() << " VS " << fuNbChanPerAsic; - LOG(info) << "CbmCosy2018MonitorHodo::ReInitContainers => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs[ 0 ][ 0 ].size() << " VS " << fuMaxNbMicroslices; - return kTRUE; -} - -void CbmCosy2018MonitorHodo::CreateHistograms() -{ - TString sHistName{""}; - TString title{""}; - - sHistName = "hHodoMessageType"; - title = "Nb of message for each type; Type"; - fhHodoMessType = new TH1I(sHistName, title, 5, 0., 5.); - fhHodoMessType->GetXaxis()->SetBinLabel( 1, "Dummy"); - fhHodoMessType->GetXaxis()->SetBinLabel( 2, "Hit"); - fhHodoMessType->GetXaxis()->SetBinLabel( 3, "TsMsb"); - fhHodoMessType->GetXaxis()->SetBinLabel( 4, "Epoch"); - fhHodoMessType->GetXaxis()->SetBinLabel( 5, "Empty"); -/* *** Missing int + MessType OP!!!! **** - fhHodoMessType->GetXaxis()->SetBinLabel(1 + stsxyter::MessType::Dummy, "Dummy"); - fhHodoMessType->GetXaxis()->SetBinLabel(1 + stsxyter::MessType::Hit, "Hit"); - fhHodoMessType->GetXaxis()->SetBinLabel(1 + stsxyter::MessType::TsMsb, "TsMsb"); - fhHodoMessType->GetXaxis()->SetBinLabel(1 + stsxyter::MessType::ReadDataAck, "ReadDataAck"); - fhHodoMessType->GetXaxis()->SetBinLabel(1 + stsxyter::MessType::Ack, "Ack"); -*/ - fHM->Add(sHistName.Data(), fhHodoMessType); - - sHistName = "hHodoSysMessType"; - title = "Nb of system message for each type; System Type"; - fhHodoSysMessType = new TH1I(sHistName, title, 17, 0., 17.); -/* - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_START, "DAQ START"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_FINISH, "DAQ FINISH"); - hSysMessType->GetXaxis()->SetBinLabel(1 + 16, "GET4 Hack 32B"); -*/ - fHM->Add(sHistName.Data(), fhHodoSysMessType); - - sHistName = "hHodoMessageTypePerDpb"; - title = "Nb of message of each type for each DPB; DPB; Type"; - fhHodoMessTypePerDpb = new TH2I(sHistName, title, fuNrOfDpbs, 0, fuNrOfDpbs, 5, 0., 5.); - fhHodoMessTypePerDpb->GetYaxis()->SetBinLabel( 1, "Dummy"); - fhHodoMessTypePerDpb->GetYaxis()->SetBinLabel( 2, "Hit"); - fhHodoMessTypePerDpb->GetYaxis()->SetBinLabel( 3, "TsMsb"); - fhHodoMessTypePerDpb->GetYaxis()->SetBinLabel( 4, "Epoch"); - fhHodoMessTypePerDpb->GetYaxis()->SetBinLabel( 5, "Empty"); -/* *** Missing int + MessType OP!!!! **** - fhHodoMessType->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Dummy, "Dummy"); - fhHodoMessType->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Hit, "Hit"); - fhHodoMessType->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::TsMsb, "TsMsb"); - fhHodoMessType->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::ReadDataAck, "ReadDataAck"); - fhHodoMessType->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Ack, "Ack"); -*/ - fHM->Add(sHistName.Data(), fhHodoMessTypePerDpb); - - sHistName = "hHodoSysMessTypePerDpb"; - title = "Nb of system message of each type for each DPB; DPB; System Type"; - fhHodoSysMessTypePerDpb = new TH2I(sHistName, title, fuNrOfDpbs, 0, fuNrOfDpbs, 17, 0., 17.); -/* - hSysMessType->GetYaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_START, "DAQ START"); - hSysMessType->GetYaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_FINISH, "DAQ FINISH"); - hSysMessType->GetYaxis()->SetBinLabel(1 + 16, "GET4 Hack 32B"); -*/ - fHM->Add(sHistName.Data(), fhHodoSysMessTypePerDpb); - - sHistName = "hHodoMessageTypePerElink"; - title = "Nb of message of each type for each eLink; eLink; Type"; - fhHodoMessTypePerElink = new TH2I(sHistName, title, fuNrOfDpbs * fuNbElinksPerDpb, 0, fuNrOfDpbs * fuNbElinksPerDpb, 5, 0., 5.); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel( 1, "Dummy"); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel( 2, "Hit"); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel( 3, "TsMsb"); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel( 4, "ReadDataAck"); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel( 5, "Ack"); -/* *** Missing int + MessType OP!!!! **** - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Dummy, "Dummy"); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Hit, "Hit"); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::TsMsb, "TsMsb"); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::ReadDataAck, "ReadDataAck"); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Ack, "Ack"); -*/ - fHM->Add(sHistName.Data(), fhHodoMessTypePerElink); - - sHistName = "hHodoSysMessTypePerElink"; - title = "Nb of system message of each type for each eLink; eLink; System Type"; - fhHodoSysMessTypePerElink = new TH2I(sHistName, title, fuNrOfDpbs * fuNbElinksPerDpb, 0, fuNrOfDpbs * fuNbElinksPerDpb, 17, 0., 17.); -/* - fhHodoSysMessTypePerElink->GetYaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_START, "DAQ START"); - fhHodoSysMessTypePerElink->GetYaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_FINISH, "DAQ FINISH"); - fhHodoSysMessTypePerElink->GetYaxis()->SetBinLabel(1 + 16, "GET4 Hack 32B"); -*/ - fHM->Add(sHistName.Data(), fhHodoSysMessTypePerElink); - -/* - // Number of rate bins = - // 9 for the sub-unit decade - // + 9 for each unit of each decade * 10 for the subdecade range - // + 1 for the closing bin top edge - const Int_t iNbDecadesRate = 9; - const Int_t iNbStepsDecade = 9; - const Int_t iNbSubStepsInStep = 10; - const Int_t iNbBinsRate = iNbStepsDecade - + iNbStepsDecade * iNbSubStepsInStep * iNbDecadesRate - + 1; - Double_t dBinsRate[iNbBinsRate]; - // First fill sub-unit decade - for( Int_t iSubU = 0; iSubU < iNbStepsDecade; iSubU ++ ) - dBinsRate[ iSubU ] = 0.1 * ( 1 + iSubU ); - std::cout << std::endl; - // Then fill the main decades - Double_t dSubstepSize = 1.0 / iNbSubStepsInStep; - for( Int_t iDecade = 0; iDecade < iNbDecadesRate; iDecade ++) - { - Double_t dBase = std::pow( 10, iDecade ); - Int_t iDecadeIdx = iNbStepsDecade - + iDecade * iNbStepsDecade * iNbSubStepsInStep; - for( Int_t iStep = 0; iStep < iNbStepsDecade; iStep++ ) - { - Int_t iStepIdx = iDecadeIdx + iStep * iNbSubStepsInStep; - for( Int_t iSubStep = 0; iSubStep < iNbSubStepsInStep; iSubStep++ ) - { - dBinsRate[ iStepIdx + iSubStep ] = dBase * (1 + iStep) - + dBase * dSubstepSize * iSubStep; - } // for( Int_t iSubStep = 0; iSubStep < iNbSubStepsInStep; iSubStep++ ) - } // for( Int_t iStep = 0; iStep < iNbStepsDecade; iStep++ ) - } // for( Int_t iDecade = 0; iDecade < iNbDecadesRate; iDecade ++) - dBinsRate[ iNbBinsRate - 1 ] = std::pow( 10, iNbDecadesRate ); -*/ - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - // Channel counts - sHistName = Form( "hHodoChanCntRaw_%03u", uXyterIdx ); - title = Form( "Hits Count per channel, StsXyter #%03u; Channel; Hits []", uXyterIdx ); - fhHodoChanCntRaw.push_back( new TH1I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - fHM->Add(sHistName.Data(), fhHodoChanCntRaw[ uXyterIdx ] ); - - // Raw Adc Distribution - sHistName = Form( "hHodoChanAdcRaw_%03u", uXyterIdx ); - title = Form( "Raw Adc distribution per channel, StsXyter #%03u; Channel []; Adc []; Hits []", uXyterIdx ); - fhHodoChanAdcRaw.push_back( new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - stsxyter::kuHitNbAdcBins, -0.5, stsxyter::kuHitNbAdcBins -0.5 ) ); - fHM->Add(sHistName.Data(), fhHodoChanAdcRaw[ uXyterIdx ] ); - - // Raw Adc Distribution profile - sHistName = Form( "hHodoChanAdcRawProfc_%03u", uXyterIdx ); - title = Form( "Raw Adc prodile per channel, StsXyter #%03u; Channel []; Adc []", uXyterIdx ); - fhHodoChanAdcRawProf.push_back( new TProfile(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - fHM->Add(sHistName.Data(), fhHodoChanAdcRawProf[ uXyterIdx ] ); - - // Raw Ts Distribution - sHistName = Form( "hHodoChanRawTs_%03u", uXyterIdx ); - title = Form( "Raw Timestamp distribution per channel, StsXyter #%03u; Channel []; Ts []; Hits []", uXyterIdx ); - fhHodoChanRawTs.push_back( new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - stsxyter::kuHitNbTsBins, -0.5, stsxyter::kuHitNbTsBins -0.5 ) ); - fHM->Add(sHistName.Data(), fhHodoChanRawTs[ uXyterIdx ] ); - - // Missed event flag - sHistName = Form( "hHodoChanMissEvt_%03u", uXyterIdx ); - title = Form( "Missed Event flags per channel, StsXyter #%03u; Channel []; Miss Evt []; Hits []", uXyterIdx ); - fhHodoChanMissEvt.push_back( new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - 2, -0.5, 1.5 ) ); - fHM->Add(sHistName.Data(), fhHodoChanMissEvt[ uXyterIdx ] ); - - // Hit rates evo per channel - sHistName = Form( "hHodoChanRateEvo_%03u", uXyterIdx ); - title = Form( "Hits per second & channel in StsXyter #%03u; Time [s]; Channel []; Hits []", uXyterIdx ); - fhHodoChanHitRateEvo.push_back( new TH2I( sHistName, title, - 1800, 0, 1800, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - fHM->Add(sHistName.Data(), fhHodoChanHitRateEvo[ uXyterIdx ] ); - - // Hit rates evo per StsXyter - sHistName = Form( "hHodoFebRateEvo_%03u", uXyterIdx ); - title = Form( "Hits per second in StsXyter #%03u; Time [s]; Hits []", uXyterIdx ); - fhHodoFebRateEvo.push_back( new TH1I(sHistName, title, 1800, 0, 1800 ) ); - fHM->Add(sHistName.Data(), fhHodoFebRateEvo[ uXyterIdx ] ); - - // Hit rates evo per channel, 1 minute bins, 24h - sHistName = Form( "hHodoChanRateEvoLong_%03u", uXyterIdx ); - title = Form( "Hits per second & channel in StsXyter #%03u; Time [min]; Channel []; Hits []", uXyterIdx ); - fhHodoChanHitRateEvoLong.push_back( new TH2D( sHistName, title, - 1440, 0, 1440, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - fHM->Add(sHistName.Data(), fhHodoChanHitRateEvoLong[ uXyterIdx ] ); - - // Hit rates evo per StsXyter, 1 minute bins, 24h - sHistName = Form( "hHodoFebRateEvoLong_%03u", uXyterIdx ); - title = Form( "Hits per second in StsXyter #%03u; Time [min]; Hits []", uXyterIdx ); - fhHodoFebRateEvoLong.push_back( new TH1D(sHistName, title, 1440, 0, 1440 ) ); - fHM->Add(sHistName.Data(), fhHodoFebRateEvoLong[ uXyterIdx ] ); - -/* - if( kTRUE == fbLongHistoEnable ) - { - UInt_t uAlignedLimit = fuLongHistoNbSeconds - (fuLongHistoNbSeconds % fuLongHistoBinSizeSec); - fuLongHistoBinNb = uAlignedLimit / fuLongHistoBinSizeSec; - - sHistName = Form( "hFebRateEvoLong_%03u", uXyterIdx ); - title = Form( "Mean rate VS run time in same MS in StsXyter #%03u; Time in run [s]; Rate [1/s]", uXyterIdx ); - fhFebRateEvoLong.push_back( new TH1D( sHistName, title, - fuLongHistoBinNb, -0.5, uAlignedLimit - 0.5) ); - fHM->Add(sHistName.Data(), fhFebRateEvoLong[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhFebRateEvoLong[ uXyterIdx ] ); - - sHistName = Form( "hFebChRateEvoLong_%03u", uXyterIdx ); - title = Form( "Mean rate per channel VS run time in StsXyter #%03u; Time in run [s]; Channel []; Rare [1/s]", uXyterIdx ); - fhFebChRateEvoLong.push_back( new TH2D( sHistName, title, - fuLongHistoBinNb, -0.5, uAlignedLimit - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - fHM->Add(sHistName.Data(), fhFebChRateEvoLong[ uXyterIdx ] ); - if( server ) server->Register("/StsRaw", fhFebChRateEvoLong[ uXyterIdx ] ); - } // if( kTRUE == fbLongHistoEnable ) -*/ - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - - // Channel counts for each of the hodoscope planes - sHistName = "hHodoChanCounts1X"; - title = "Channel counts for hodoscope 1 axis X; X channel []; Hits []"; - fhHodoChanCounts1X = new TH1I( sHistName, title, fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - fHM->Add(sHistName.Data(), fhHodoChanCounts1X ); - - sHistName = "hHodoChanCounts1Y"; - title = "Channel counts for hodoscope 1 axis Y; Y channel []; Hits []"; - fhHodoChanCounts1Y = new TH1I( sHistName, title, fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - fHM->Add(sHistName.Data(), fhHodoChanCounts1Y ); - - sHistName = "hHodoChanCounts2X"; - title = "Channel counts for hodoscope 2 axis X; X channel []; Hits []"; - fhHodoChanCounts2X = new TH1I( sHistName, title, fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - fHM->Add(sHistName.Data(), fhHodoChanCounts2X ); - - sHistName = "hHodoChanCounts2Y"; - title = "Channel counts for hodoscope 2 axis Y; Y channel []; Hits []"; - fhHodoChanCounts2Y = new TH1I( sHistName, title, fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - fHM->Add(sHistName.Data(), fhHodoChanCounts2Y ); - - // Raw ADC distributions for each of the hodoscope planes - sHistName = "hHodoChanAdcRaw1X"; - title = "Raw ADC distributions for hodoscope 1 axis X; X channel []; ADC [bin]; Hits []"; - fhHodoChanAdcRaw1X = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - stsxyter::kuHitNbAdcBins, -0.5, stsxyter::kuHitNbAdcBins -0.5 ); - fHM->Add(sHistName.Data(), fhHodoChanAdcRaw1X ); - - sHistName = "hHodoChanAdcRaw1Y"; - title = "Raw ADC distributions for hodoscope 1 axis Y; Y channel []; ADC [bin]; Hits []"; - fhHodoChanAdcRaw1Y = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - stsxyter::kuHitNbAdcBins, -0.5, stsxyter::kuHitNbAdcBins -0.5 ); - fHM->Add(sHistName.Data(), fhHodoChanAdcRaw1Y ); - - sHistName = "hHodoChanAdcRaw2X"; - title = "Raw ADC distributions for hodoscope 2 axis X; X channel []; ADC [bin]; Hits []"; - fhHodoChanAdcRaw2X = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - stsxyter::kuHitNbAdcBins, -0.5, stsxyter::kuHitNbAdcBins -0.5 ); - fHM->Add(sHistName.Data(), fhHodoChanAdcRaw2X ); - - sHistName = "hHodoChanAdcRaw2Y"; - title = "Raw ADC distributions for hodoscope 2 axis Y; Y channel []; ADC [bin]; Hits []"; - fhHodoChanAdcRaw2Y = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - stsxyter::kuHitNbAdcBins, -0.5, stsxyter::kuHitNbAdcBins -0.5 ); - fHM->Add(sHistName.Data(), fhHodoChanAdcRaw2Y ); - - // Hit rate Evo for each channel of each of the hodoscope planes - sHistName = "hHodoChanHitRateEvo1X"; - title = "Hits per second & channel in Hodo 1 X axis; Time [s]; Channel []; Hits []"; - fhHodoChanHitRateEvo1X = new TH2I( sHistName, title, - 1800, 0, 1800, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - fHM->Add(sHistName.Data(), fhHodoChanHitRateEvo1X ); - - sHistName = "hHodoChanHitRateEvo1Y"; - title = "Hits per second & channel in Hodo 1 Y axis; Time [s]; Channel []; Hits []"; - fhHodoChanHitRateEvo1Y = new TH2I( sHistName, title, - 1800, 0, 1800, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - fHM->Add(sHistName.Data(), fhHodoChanHitRateEvo1Y ); - - sHistName = "hHodoChanHitRateEvo2X"; - title = "Hits per second & channel in Hodo 2 X axis; Time [s]; Channel []; Hits []"; - fhHodoChanHitRateEvo2X = new TH2I( sHistName, title, - 1800, 0, 1800, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - fHM->Add(sHistName.Data(), fhHodoChanHitRateEvo2X ); - - sHistName = "hHodoChanHitRateEvo2Y"; - title = "Hits per second & channel in Hodo 2 Y axis; Time [s]; Channel []; Hits []"; - fhHodoChanHitRateEvo2Y = new TH2I( sHistName, title, - 1800, 0, 1800, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - fHM->Add(sHistName.Data(), fhHodoChanHitRateEvo2Y ); - - // Hit rate Evo for each channel of each of the hodoscope planes - sHistName = "fhHodoRateEvo1X"; - title = "Hits per second in Hodoscope 1 X axis; Time [s]; Hits []"; - fhHodoRateEvo1X = new TH1I(sHistName, title, 1800, 0, 1800 ); - fHM->Add(sHistName.Data(), fhHodoRateEvo1X ); - - sHistName = "hHodoRateEvo1Y"; - title = "Hits per second in Hodoscope 1 Y axis; Time [s]; Hits []"; - fhHodoRateEvo1Y = new TH1I(sHistName, title, 1800, 0, 1800 ); - fHM->Add(sHistName.Data(), fhHodoRateEvo1Y ); - - sHistName = "fhHodoRateEvo2X"; - title = "Hits per second in Hodoscope 2 X axis; Time [s]; Hits []"; - fhHodoRateEvo2X = new TH1I(sHistName, title, 1800, 0, 1800 ); - fHM->Add(sHistName.Data(), fhHodoRateEvo2X ); - - sHistName = "hHodoRateEvo2Y"; - title = "Hits per second in Hodoscope 2 Y axis; Time [s]; Hits []"; - fhHodoRateEvo2Y = new TH1I(sHistName, title, 1800, 0, 1800 ); - fHM->Add(sHistName.Data(), fhHodoRateEvo2Y ); -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - - UInt_t uNbBinEvo = 32768 + 1; - Double_t dMaxEdgeEvo = stsxyter::kdClockCycleNs - * static_cast< Double_t >( uNbBinEvo ) / 2.0; - Double_t dMinEdgeEvo = dMaxEdgeEvo * -1.0; - - sHistName = "fhHodoSortedDtX1Y1"; - title = "Time diff for hits Hodo 1 X and Hodo 1 Y; tY1 - tX1 [ns]; Counts"; - fhHodoSortedDtX1Y1 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - fHM->Add(sHistName.Data(), fhHodoSortedDtX1Y1); - - sHistName = "fhHodoSortedDtX2Y2"; - title = "Time diff for hits Hodo 2 X and Hodo 2 Y; tY2 - tX2 [ns]; Counts"; - fhHodoSortedDtX2Y2 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - fHM->Add(sHistName.Data(), fhHodoSortedDtX2Y2); - - sHistName = "fhHodoSortedDtX1X2"; - title = "Time diff for hits Hodo 1 X and Hodo 2 X; tX2 - tX1 [ns]; Counts"; - fhHodoSortedDtX1X2 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - fHM->Add(sHistName.Data(), fhHodoSortedDtX1X2); - - sHistName = "fhHodoSortedDtY1Y2"; - title = "Time diff for hits Hodo 1 Y and Hodo 2 Y; tY2 - tY1 [ns]; Counts"; - fhHodoSortedDtY1Y2 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - fHM->Add(sHistName.Data(), fhHodoSortedDtY1Y2); - - sHistName = "fhHodoSortedDtX1Y2"; - title = "Time diff for hits Hodo 1 X and Hodo 2 Y; tY2 - tX1 [ns]; Counts"; - fhHodoSortedDtX1Y2 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - fHM->Add(sHistName.Data(), fhHodoSortedDtX1Y2); - - sHistName = "fhHodoSortedDtY1X2"; - title = "Time diff for hits Hodo 1 Y and Hodo 2 X; tY2 - tY1 [ns]; Counts"; - fhHodoSortedDtY1X2 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - fHM->Add(sHistName.Data(), fhHodoSortedDtY1X2); - - sHistName = "fhHodoSortedMapX1Y1"; - title = "Sorted hits in coincidence for hodoscope 1 axis X and Y; X channel Hodo 1 []; Y channel Hodo 1 []; MS []"; - fhHodoSortedMapX1Y1 = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - fHM->Add(sHistName.Data(), fhHodoSortedMapX1Y1 ); - - sHistName = "fhHodoSortedMapX2Y2"; - title = "Sorted hits in coincidence for hodoscope 2 axis X and Y; X channel Hodo 2 []; Y channel Hodo 2 []; MS []"; - fhHodoSortedMapX2Y2 = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - fHM->Add(sHistName.Data(), fhHodoSortedMapX2Y2 ); - - sHistName = "fhHodoSortedMapX1X2"; - title = "Sorted hits in coincidence for hodoscope 1 axis X and 2 axis X; X channel Hodo 1 []; X channel Hodo 2 []; MS []"; - fhHodoSortedMapX1X2 = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - fHM->Add(sHistName.Data(), fhHodoSortedMapX1X2 ); - - sHistName = "fhHodoSortedMapY1Y2"; - title = "Sorted hits in coincidence for hodoscope 1 axis Y and 2 axis Y; Y channel Hodo 1 []; Y channel Hodo 2 []; MS []"; - fhHodoSortedMapY1Y2 = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - fHM->Add(sHistName.Data(), fhHodoSortedMapY1Y2 ); - - sHistName = "fhHodoSortedMapX1Y2"; - title = "Sorted hits in coincidence for hodoscope 1 axis X and 2 axis Y; X channel Hodo 1 []; Y channel Hodo 2 []; MS []"; - fhHodoSortedMapX1Y2 = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - fHM->Add(sHistName.Data(), fhHodoSortedMapX1Y2 ); - - sHistName = "fhHodoSortedMapY1X2"; - title = "Sorted hits in coincidence for hodoscope 1 axis Y and 2 axis X; Y channel Hodo 1 []; X channel Hodo 2 []; MS []"; - fhHodoSortedMapY1X2 = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - fHM->Add(sHistName.Data(), fhHodoSortedMapY1X2 ); - - // Coincidence counts evolution between some axis of the hodoscopes - sHistName = "hHodoSortedCntEvoX1Y1"; - title = "Nb of coincidences in both X1 and Y1 per s; Time [s]; X1-Y1 coincidences []"; - fhHodoSortedCntEvoX1Y1 = new TH1I(sHistName, title, 1800, 0, 1800 ); - fHM->Add(sHistName.Data(), fhHodoSortedCntEvoX1Y1 ); - - sHistName = "hHodoSortedCntEvoX2Y2"; - title = "Nb of coincidences in both X2 and Y2 per s; Time [s]; X2-Y2 coincidences []"; - fhHodoSortedCntEvoX2Y2 = new TH1I(sHistName, title, 1800, 0, 1800 ); - fHM->Add(sHistName.Data(), fhHodoSortedCntEvoX2Y2 ); - - sHistName = "fhHodoSortedCntEvoX1X2"; - title = "Nb of coincidences in both X1 and X2 per s; Time [s]; X1-X2 coincidences []"; - fhHodoSortedCntEvoX1X2 = new TH1I(sHistName, title, 1800, 0, 1800 ); - fHM->Add(sHistName.Data(), fhHodoSortedCntEvoX1X2 ); - - sHistName = "fhHodoSortedCntEvoY1Y2"; - title = "Nb of coincidences in both Y1 and Y2 per s; Time [s]; Y1-Y2 coincidences []"; - fhHodoSortedCntEvoY1Y2 = new TH1I(sHistName, title, 1800, 0, 1800 ); - fHM->Add(sHistName.Data(), fhHodoSortedCntEvoY1Y2 ); - - sHistName = "hHodoSortedCntEvoX1Y2"; - title = "Nb of coincidences in both X1 and Y2 per s; Time [s]; X1-Y2 coincidences []"; - fhHodoSortedCntEvoX1Y2 = new TH1I(sHistName, title, 1800, 0, 1800 ); - fHM->Add(sHistName.Data(), fhHodoSortedCntEvoX1Y2 ); - - sHistName = "hHodoSortedCntEvoY1X2"; - title = "Nb of coincidences in both Y1 and X2 per s; Time [s]; Y1-X2 coincidences []"; - fhHodoSortedCntEvoY1X2 = new TH1I(sHistName, title, 1800, 0, 1800 ); - fHM->Add(sHistName.Data(), fhHodoSortedCntEvoY1X2 ); - -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// -/* - // Distribution of the TS_MSB per StsXyter - sHistName = "hHodoFebTsMsb"; - title = "Raw Timestamp Msb distribution per StsXyter; Ts MSB []; StsXyter []; Hits []"; - fhHodoFebTsMsb = new TH2I( sHistName, title, stsxyter::kuTsMsbNbTsBins, -0.5, stsxyter::kuTsMsbNbTsBins - 0.5, - fuNbStsXyters, -0.5, fuNbStsXyters - 0.5 ); - fHM->Add(sHistName.Data(), fhHodoFebTsMsb ); - if( server ) server->Register("/StsRaw", fhHodoFebTsMsb ); -*/ - // Miscroslice properties histos - for( Int_t component = 0; component < kiMaxNbFlibLinks; component ++ ) - { - fhMsSz[ component ] = NULL; - fhMsSzTime[ component ] = NULL; - } // for( Int_t component = 0; component < kiMaxNbFlibLinks; component ++ ) - - // Online histo browser commands - THttpServer* server = FairRunOnline::Instance()->GetHttpServer(); - if( server ) - { - server->Register("/HodoRaw", fhHodoMessType ); - server->Register("/HodoRaw", fhHodoSysMessType ); - server->Register("/HodoRaw", fhHodoMessTypePerDpb ); - server->Register("/HodoRaw", fhHodoSysMessTypePerDpb ); - server->Register("/HodoRaw", fhHodoMessTypePerElink ); - server->Register("/HodoRaw", fhHodoSysMessTypePerElink ); - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - server->Register("/HodoRaw", fhHodoChanCntRaw[ uXyterIdx ] ); - server->Register("/HodoRaw", fhHodoChanAdcRaw[ uXyterIdx ] ); - server->Register("/HodoRaw", fhHodoChanAdcRawProf[ uXyterIdx ] ); - server->Register("/HodoRaw", fhHodoChanRawTs[ uXyterIdx ] ); - server->Register("/HodoRaw", fhHodoChanMissEvt[ uXyterIdx ] ); - server->Register("/HodoRaw", fhHodoChanHitRateEvo[ uXyterIdx ] ); - server->Register("/HodoRaw", fhHodoFebRateEvo[ uXyterIdx ] ); - server->Register("/HodoRaw", fhHodoChanHitRateEvoLong[ uXyterIdx ] ); - server->Register("/HodoRaw", fhHodoFebRateEvoLong[ uXyterIdx ] ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - server->Register("/HodoRaw", fhHodoChanCounts1X ); - server->Register("/HodoRaw", fhHodoChanCounts1Y ); - server->Register("/HodoRaw", fhHodoChanCounts2X ); - server->Register("/HodoRaw", fhHodoChanCounts2Y ); - server->Register("/HodoRaw", fhHodoChanAdcRaw1X ); - server->Register("/HodoRaw", fhHodoChanAdcRaw1Y ); - server->Register("/HodoRaw", fhHodoChanAdcRaw2X ); - server->Register("/HodoRaw", fhHodoChanAdcRaw2Y ); - server->Register("/HodoRaw", fhHodoChanHitRateEvo1X ); - server->Register("/HodoRaw", fhHodoChanHitRateEvo1Y ); - server->Register("/HodoRaw", fhHodoChanHitRateEvo2X ); - server->Register("/HodoRaw", fhHodoChanHitRateEvo2Y ); - server->Register("/HodoRaw", fhHodoRateEvo1X ); - server->Register("/HodoRaw", fhHodoRateEvo1Y ); - server->Register("/HodoRaw", fhHodoRateEvo2X ); - server->Register("/HodoRaw", fhHodoRateEvo2Y ); - server->Register("/HodoRaw", fhHodoSortedDtX1Y1 ); - server->Register("/HodoRaw", fhHodoSortedDtX2Y2 ); - server->Register("/HodoRaw", fhHodoSortedDtX1X2 ); - server->Register("/HodoRaw", fhHodoSortedDtY1Y2 ); - server->Register("/HodoRaw", fhHodoSortedDtX1Y2 ); - server->Register("/HodoRaw", fhHodoSortedDtY1X2 ); - server->Register("/HodoRaw", fhHodoSortedMapX1Y1 ); - server->Register("/HodoRaw", fhHodoSortedMapX2Y2 ); - server->Register("/HodoRaw", fhHodoSortedMapX1X2 ); - server->Register("/HodoRaw", fhHodoSortedMapY1Y2 ); - server->Register("/HodoRaw", fhHodoSortedMapX1Y2 ); - server->Register("/HodoRaw", fhHodoSortedMapY1X2 ); - server->Register("/HodoRaw", fhHodoSortedCntEvoX1Y1 ); - server->Register("/HodoRaw", fhHodoSortedCntEvoX2Y2 ); - server->Register("/HodoRaw", fhHodoSortedCntEvoX1X2 ); - server->Register("/HodoRaw", fhHodoSortedCntEvoY1Y2 ); - server->Register("/HodoRaw", fhHodoSortedCntEvoX1Y2 ); - server->Register("/HodoRaw", fhHodoSortedCntEvoY1X2 ); - - server->RegisterCommand("/Reset_All_Hodo", "bCosy2018ResetHodoHistos=kTRUE"); - server->RegisterCommand("/Write_All_Hodo", "bCosy2018WriteHodoHistos=kTRUE"); - - server->Restrict("/Reset_All_Hodo", "allow=admin"); - server->Restrict("/Write_All_Hodo", "allow=admin"); - } // if( server ) - - /** Create summary Canvases for CERN 2017 **/ - Double_t w = 10; - Double_t h = 10; - - // Summary per StsXyter - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - TCanvas* cStsSumm = new TCanvas( Form("cStsSum_%03u", uXyterIdx ), - Form("Summary plots for StsXyter %03u", uXyterIdx ), - w, h); - cStsSumm->Divide( 2, 2 ); - - cStsSumm->cd(1); - gPad->SetLogy(); - fhHodoChanCntRaw[ uXyterIdx ]->Draw(); - - cStsSumm->cd(2); - gPad->SetLogz(); - fhHodoChanAdcRaw[ uXyterIdx ]->Draw( "colz" ); - - cStsSumm->cd(3); - gPad->SetLogz(); - fhHodoChanRawTs[ uXyterIdx ]->Draw( "colz" ); - - cStsSumm->cd(4); - gPad->SetLogy(); - fhHodoFebRateEvo[ uXyterIdx ]->Draw(); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - -//====================================================================// - TCanvas* cHodoCounts = new TCanvas( "cHodoCounts", - "Hodoscopes counts per axis", - w, h); - cHodoCounts->Divide( 2, 2 ); - - cHodoCounts->cd(1); - gPad->SetLogz(); - fhHodoChanCounts1X->Draw( "" ); - - cHodoCounts->cd(2); - gPad->SetLogz(); - fhHodoChanCounts1Y->Draw( "" ); - - cHodoCounts->cd(3); - gPad->SetLogz(); - fhHodoChanCounts2X->Draw( "" ); - - cHodoCounts->cd(4); - gPad->SetLogz(); - fhHodoChanCounts2Y->Draw( "" ); -//====================================================================// - -//====================================================================// - TCanvas* cHodoAdc = new TCanvas( "cHodoAdc", - "Hodoscopes ADC distributions per axis", - w, h); - cHodoAdc->Divide( 2, 2 ); - - cHodoAdc->cd(1); - gPad->SetLogz(); - fhHodoChanAdcRaw1X->Draw( "colz" ); - - cHodoAdc->cd(2); - gPad->SetLogz(); - fhHodoChanAdcRaw1Y->Draw( "colz" ); - - cHodoAdc->cd(3); - gPad->SetLogz(); - fhHodoChanAdcRaw2X->Draw( "colz" ); - - cHodoAdc->cd(4); - gPad->SetLogz(); - fhHodoChanAdcRaw2Y->Draw( "colz" ); -//====================================================================// - -//====================================================================// - TCanvas* cHodoRates = new TCanvas( "cHodoRates", - "Hodoscopes rates per axis", - w, h); - cHodoRates->Divide( 2, 2 ); - - cHodoRates->cd(1); - gPad->SetLogz(); - fhHodoRateEvo1X->Draw( "" ); - - cHodoRates->cd(2); - gPad->SetLogz(); - fhHodoRateEvo1Y->Draw( "" ); - - cHodoRates->cd(3); - gPad->SetLogz(); - fhHodoRateEvo2X->Draw( "" ); - - cHodoRates->cd(4); - gPad->SetLogz(); - fhHodoRateEvo2Y->Draw( "" ); -//====================================================================// - -//====================================================================// - TCanvas* cHodoRatesEvo = new TCanvas( "cHodoRatesEvo", - "Hodoscopes rates evolutionper axis", - w, h); - cHodoRatesEvo->Divide( 2, 2 ); - - cHodoRatesEvo->cd(1); - gPad->SetLogz(); - fhHodoChanHitRateEvo1X->Draw( "colz" ); - - cHodoRatesEvo->cd(2); - gPad->SetLogz(); - fhHodoChanHitRateEvo1Y->Draw( "colz" ); - - cHodoRatesEvo->cd(3); - gPad->SetLogz(); - fhHodoChanHitRateEvo2X->Draw( "colz" ); - - cHodoRatesEvo->cd(4); - gPad->SetLogz(); - fhHodoChanHitRateEvo2Y->Draw( "colz" ); -//====================================================================// - -//====================================================================// - TCanvas* cHodoSortedDt = new TCanvas( "cHodoSortedDt", - "Hodoscopes coincidence maps", - w, h); - cHodoSortedDt->Divide( 2, 3 ); - - cHodoSortedDt->cd(1); - gPad->SetLogy(); - fhHodoSortedDtX1Y1->Draw( "" ); - - cHodoSortedDt->cd(2); - gPad->SetLogy(); - fhHodoSortedDtX2Y2->Draw( "" ); - - cHodoSortedDt->cd(3); - gPad->SetLogy(); - fhHodoSortedDtX1X2->Draw( "" ); - - cHodoSortedDt->cd(4); - gPad->SetLogy(); - fhHodoSortedDtY1Y2->Draw( "" ); - - cHodoSortedDt->cd(5); - gPad->SetLogy(); - fhHodoSortedDtX1Y2->Draw( "" ); - - cHodoSortedDt->cd(6); - gPad->SetLogy(); - fhHodoSortedDtY1X2->Draw( "" ); -//====================================================================// - -//====================================================================// - TCanvas* cHodoSortedMaps = new TCanvas( "cHodoSortedMaps", - "Hodoscopes coincidence maps", - w, h); - cHodoSortedMaps->Divide( 2, 3 ); - - cHodoSortedMaps->cd(1); - gPad->SetLogz(); - fhHodoSortedMapX1Y1->Draw( "colz" ); - - cHodoSortedMaps->cd(2); - gPad->SetLogz(); - fhHodoSortedMapX2Y2->Draw( "colz" ); - - cHodoSortedMaps->cd(3); - gPad->SetLogz(); - fhHodoSortedMapX1X2->Draw( "colz" ); - - cHodoSortedMaps->cd(4); - gPad->SetLogz(); - fhHodoSortedMapY1Y2->Draw( "colz" ); - - cHodoSortedMaps->cd(5); - gPad->SetLogz(); - fhHodoSortedMapX1Y2->Draw( "colz" ); - - cHodoSortedMaps->cd(6); - gPad->SetLogz(); - fhHodoSortedMapY1X2->Draw( "colz" ); -//====================================================================// - -//====================================================================// - TCanvas* cHodoSortedCoincEvo = new TCanvas( "cHodoSortedCoincEvo", - "Hodoscopes coincidence rate evolution", - w, h); - cHodoSortedCoincEvo->Divide( 2, 3 ); - - cHodoSortedCoincEvo->cd(1); - gPad->SetGridy(); - gPad->SetLogy(); - fhHodoSortedCntEvoX1Y1->Draw( "colz" ); - - cHodoSortedCoincEvo->cd(2); - gPad->SetGridy(); - gPad->SetLogy(); - fhHodoSortedCntEvoX2Y2->Draw( "colz" ); - - cHodoSortedCoincEvo->cd(3); - gPad->SetGridy(); - gPad->SetLogy(); - fhHodoSortedCntEvoX1X2->Draw( "colz" ); - - cHodoSortedCoincEvo->cd(4); - gPad->SetGridy(); - gPad->SetLogy(); - fhHodoSortedCntEvoY1Y2->Draw( "colz" ); - - cHodoSortedCoincEvo->cd(5); - gPad->SetGridy(); - gPad->SetLogy(); - fhHodoSortedCntEvoX1Y2->Draw( "colz" ); - - cHodoSortedCoincEvo->cd(6); - gPad->SetGridy(); - gPad->SetLogy(); - fhHodoSortedCntEvoY1X2->Draw( "colz" ); -//====================================================================// - - // Long duration rate monitoring -/* - if( kTRUE == fbLongHistoEnable ) - { - TCanvas* cStsLongRate = new TCanvas( "cStsLongRate" , "Long duration rate plots for StsXyter", - w, h); - cStsLongRate->Divide( 2, fuNbStsXyters ); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - cStsLongRate->cd( 1 + 2 * uXyterIdx ); - gPad->SetLogy(); - gPad->SetGridx(); - gPad->SetGridy(); - fhFebRateEvoLong[ uXyterIdx ]->Draw( "hist" ); - - cStsLongRate->cd( 2 + 2 * uXyterIdx ); - gPad->SetLogz(); - gPad->SetGridx(); - gPad->SetGridy(); - fhFebChRateEvoLong[ uXyterIdx ]->Draw( "colz" ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - } // if( kTRUE == fbLongHistoEnable ) -*/ -/* - Int_t iNbPadsPerDpb = fuNbElinksPerDpb/2 + fuNbElinksPerDpb%2; - TCanvas* cMuchChCounts = new TCanvas("cMuchChCounts", "MUCH Channels counts", w, h); - cMuchChCounts->Divide( fNrOfNdpbs/2 + fNrOfNdpbs%2, fNrOfFebsPerNdpb ); - - TCanvas* cMuchFebRate = new TCanvas("cMuchFebRate", "MUCH FEB rate", w, h); - cMuchFebRate->Divide( fNrOfNdpbs/2 + fNrOfNdpbs%2, fNrOfFebsPerNdpb ); - - TH1* histPnt = NULL; - for( Int_t dpbId = 0; dpbId < fNrOfNdpbs; dpbId++) - {// looping on all the nDPBS IDs - if( dpbId < fUnpackPar->GetNrOfnDpbsModA() ) - { - sNdpbTag = Form("%04X", fUnpackPar->GetNdpbIdA(dpbId) ); - } // if( dpbId < fUnpackPar->GetNrOfnDpbsModA() ) - else - { - sNdpbTag = Form("%04X", fUnpackPar->GetNdpbIdB(dpbId - fNrOfNdpbsA) ); - } // else of if( dpbId < fUnpackPar->GetNrOfnDpbsModA() ) - - for( Int_t febId = 0; febId < fNrOfFebsPerNdpb; febId++) - {// looping on all the FEB IDs - cMuchChCounts->cd( 1 + dpbId * iNbPadsPerDpb + febId/2 ); - gPad->SetLogy(); - sHistName = Form("Chan_Counts_Much_n%s_f%1u", sNdpbTag.Data(), febId); - histPnt = fHM->H1(sHistName.Data()); - - if( 0 == febId%2 ) - { - histPnt->SetLineColor( kRed ); // => Change color for 1st of the 2/pad! - histPnt->Draw(); - } // if( 0 == febId%2 ) - else - { - histPnt->SetLineColor( kBlue ); // => Change color for 1nd of the 2/pad! - histPnt->Draw("same"); - } // if( 0 == febId%2 ) - - cMuchFebRate->cd( 1 + dpbId * iNbPadsPerDpb + febId/2 ); - gPad->SetLogy(); - sHistName = Form("FebRate_n%s_f%1u", sNdpbTag.Data(), febId); - histPnt = fHM->H1(sHistName.Data()); - - if( 0 == febId%2 ) - { - histPnt->SetLineColor( kRed ); // => Change color for 1st of the 2/pad! - histPnt->Draw(); - } // if( 0 == febId%2 ) - else - { - histPnt->SetLineColor( kBlue ); // => Change color for 1nd of the 2/pad! - histPnt->Draw("same"); - } // if( 0 == febId%2 ) - } // for( Int_t febId = 0; febId < fNrOfFebsPerNdpb; febId++) - } // for( Int_t dpbId = 0; dpbId < fNrOfNdpbs; dpbId++) -*/ - - /** Recovers/Create Ms Size Canvase for CERN 2016 **/ - // Try to recover canvas in case it was created already by another monitor - // If not existing, create it - fcMsSizeAll = dynamic_cast<TCanvas *>( gROOT->FindObject( "cMsSizeAll" ) ); - if( NULL == fcMsSizeAll ) - { - fcMsSizeAll = new TCanvas("cMsSizeAll", "Evolution of MS size in last 300 s", w, h); - fcMsSizeAll->Divide( 4, 4 ); - LOG(info) << "Created MS size canvas in STS monitor"; - } // if( NULL == fcMsSizeAll ) - else LOG(info) << "Recovered MS size canvas in STS monitor"; - - /*****************************/ -} - -Bool_t CbmCosy2018MonitorHodo::DoUnpack(const fles::Timeslice& ts, size_t component) -{ - THttpServer* server = FairRunOnline::Instance()->GetHttpServer(); - - if( bCosy2018ResetHodoHistos ) - { - ResetAllHistos(); - bCosy2018ResetHodoHistos = kFALSE; - } // if( bCosy2018ResetHodoHistos ) - if( bCosy2018WriteHodoHistos ) - { - SaveAllHistos( "data/HodoHistos.root" ); - bCosy2018WriteHodoHistos = kFALSE; - } // if( bCosy2018WriteHodoHistos ) - - LOG(debug) << "Timeslice contains " << ts.num_microslices(component) - << "microslices."; - - if( component < kiMaxNbFlibLinks ) - if( NULL == fhMsSz[ component ] ) - { - TString sMsSzName = Form("MsSz_link_%02lu", component); - TString sMsSzTitle = Form("Size of MS for nDPB of link %02lu; Ms Size [bytes]", component); - fhMsSz[ component ] = new TH1F( sMsSzName.Data(), sMsSzTitle.Data(), 160000, 0., 20000. ); - fHM->Add(sMsSzName.Data(), fhMsSz[ component ] ); - if (server) server->Register("/FlibRaw", fhMsSz[ component ] ); - sMsSzName = Form("MsSzTime_link_%02lu", component); - sMsSzTitle = Form("Size of MS vs time for gDPB of link %02lu; Time[s] ; Ms Size [bytes]", component); - fhMsSzTime[ component ] = new TProfile( sMsSzName.Data(), sMsSzTitle.Data(), 15000, 0., 300. ); - fHM->Add( sMsSzName.Data(), fhMsSzTime[ component ] ); - if (server) server->Register("/FlibRaw", fhMsSzTime[ component ] ); - if( NULL != fcMsSizeAll ) - { - fcMsSizeAll->cd( 1 + component ); - gPad->SetLogy(); - fhMsSzTime[ component ]->Draw("hist le0"); - } // if( NULL != fcMsSizeAll ) - LOG(info) << "Added MS size histo for component: " << component - << " (DPB)"; - } // if( NULL == fhMsSz[ component ] ) - -// Int_t messageType = -111; - // Loop over microslices - size_t numCompMsInTs = ts.num_microslices(component); -/* - if( fulCurrentTsIdx + 1 != ts.index() && 0 == component) - LOG(info) << "Missed TS from " << fulCurrentTsIdx - << " to " << ts.index(); -*/ - fulCurrentTsIdx = ts.index(); - - if( fuMaxNbMicroslices < numCompMsInTs ) - { - fuMaxNbMicroslices = numCompMsInTs; - - fvdMsTime.resize( fuMaxNbMicroslices ); - fvuChanNbHitsInMs.resize( fuNbStsXyters ); - fvdChanLastHitTimeInMs.resize( fuNbStsXyters ); - fvusChanLastHitAdcInMs.resize( fuNbStsXyters ); - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fvuChanNbHitsInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvdChanLastHitTimeInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvusChanLastHitAdcInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - { - fvuChanNbHitsInMs[ uXyterIdx ][ uChan ].resize( fuMaxNbMicroslices ); - fvdChanLastHitTimeInMs[ uXyterIdx ][ uChan ].resize( fuMaxNbMicroslices ); - fvusChanLastHitAdcInMs[ uXyterIdx ][ uChan ].resize( fuMaxNbMicroslices ); - for( UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx ) - { - fvuChanNbHitsInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = 0; - fvdChanLastHitTimeInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = -1.0; - fvusChanLastHitAdcInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = 0; - } // for( UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx ) - } // for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - LOG(info) << "CbmCosy2018MonitorHodo::DoUnpack => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs.size() << " VS " << fuNbStsXyters; - LOG(info) << "CbmCosy2018MonitorHodo::DoUnpack => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs[ 0 ].size() << " VS " << fuNbChanPerAsic; - LOG(info) << "CbmCosy2018MonitorHodo::DoUnpack => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs[ 0 ][ 0 ].size() << " VS " << fuMaxNbMicroslices; - } // if( fuMaxNbMicroslices < numCompMsInTs ) - - for( size_t m = 0; m < numCompMsInTs; ++m ) - { - // Ignore overlap ms if number defined by user - if( numCompMsInTs - fuOverlapMsNb <= m ) - continue; - - auto msDescriptor = ts.descriptor(component, m); - fuCurrentEquipmentId = msDescriptor.eq_id; - const uint8_t* msContent = reinterpret_cast<const uint8_t*>(ts.content(component, m)); - - uint32_t size = msDescriptor.size; - fulCurrentMsIdx = msDescriptor.idx; - Double_t dMsTime = (1e-9) * static_cast<double>(fulCurrentMsIdx); - LOG(debug) << "Microslice: " << fulCurrentMsIdx - << " from EqId " << std::hex << fuCurrentEquipmentId << std::dec - << " has size: " << size; - - fuCurrDpbId = static_cast< uint32_t >( fuCurrentEquipmentId & 0xFFFF ); - fuCurrDpbIdx = fDpbIdIndexMap[ fuCurrDpbId ]; - - if( component < kiMaxNbFlibLinks ) - { - if( fdStartTimeMsSz < 0 ) - fdStartTimeMsSz = dMsTime; - fhMsSz[ component ]->Fill( size ); - fhMsSzTime[ component ]->Fill( dMsTime - fdStartTimeMsSz, size); - } // if( component < kiMaxNbFlibLinks ) - - // Store MS time for coincidence plots - fvdMsTime[ m ] = dMsTime; - - // If not integer number of message in input buffer, print warning/error - if( 0 != (size % kuBytesPerMessage) ) - LOG(error) << "The input microslice buffer does NOT " - << "contain only complete nDPB messages!"; - - // Compute the number of complete messages in the input microslice buffer - uint32_t uNbMessages = (size - (size % kuBytesPerMessage) ) - / kuBytesPerMessage; - - // Prepare variables for the loop on contents - const uint32_t* pInBuff = reinterpret_cast<const uint32_t*>( msContent ); - - for( uint32_t uIdx = 0; uIdx < uNbMessages; ++uIdx ) - { - // Fill message - uint32_t ulData = static_cast<uint32_t>(pInBuff[uIdx]); - - stsxyter::Message mess( static_cast< uint32_t >( ulData & 0xFFFFFFFF ) ); - - // Print message if requested - if( fbPrintMessages ) - mess.PrintMess( std::cout, fPrintMessCtrl ); - - stsxyter::MessType typeMess = mess.GetMessType(); - fmMsgCounter[ typeMess ] ++; - fhHodoMessType->Fill( static_cast< uint16_t > (typeMess) ); - fhHodoMessTypePerDpb->Fill( fuCurrDpbIdx, static_cast< uint16_t > (typeMess) ); - - switch( typeMess ) - { - case stsxyter::MessType::Hit : - { - // Extract the eLink and Asic indices => Should GO IN the fill method now that obly hits are link/asic specific! - UShort_t usElinkIdx = mess.GetLinkIndex(); - if( fuNbElinksPerDpb <= usElinkIdx ) - { - LOG(fatal) << "CbmCosy2018MonitorHodo::DoUnpack => " - << "eLink index out of bounds!" - << usElinkIdx << " VS " << fuNbElinksPerDpb; - } // if( fuNbElinksPerDpb <= usElinkIdx ) - fhHodoMessTypePerElink->Fill( fuCurrDpbIdx * fuNbElinksPerDpb + usElinkIdx, - static_cast< uint16_t > (typeMess) ); - - UInt_t uAsicIdx = fvuElinkToAsic[fuCurrDpbIdx][usElinkIdx]; - if( ! ( fUnpackPar->GetAsicIndexHodo1() == uAsicIdx || - fUnpackPar->GetAsicIndexHodo2() == uAsicIdx ) ) - continue; - - FillHitInfo( mess, usElinkIdx, uAsicIdx, m ); - break; - } // case stsxyter::MessType::Hit : - case stsxyter::MessType::TsMsb : - { - FillTsMsbInfo( mess, uIdx, m ); - break; - } // case stsxyter::MessType::TsMsb : - case stsxyter::MessType::Epoch : - { - // The first message in the TS is a special ones: EPOCH - FillEpochInfo( mess ); - - if( 0 < uIdx ) - LOG(info) << "CbmCosy2018MonitorHodo::DoUnpack => " - << "EPOCH message at unexpected position in MS: message " - << uIdx << " VS message 0 expected!"; - break; - } // case stsxyter::MessType::TsMsb : - case stsxyter::MessType::Empty : - { -// FillTsMsbInfo( mess ); - break; - } // case stsxyter::MessType::Empty : - case stsxyter::MessType::Dummy : - { - break; - } // case stsxyter::MessType::Dummy / ReadDataAck / Ack : - default: - { - LOG(fatal) << "CbmCosy2018MonitorHodo::DoUnpack => " - << "Unknown message type, should never happen, stopping here!"; - } - } // switch( mess.GetMessType() ) - } // for( uint32_t uIdx = 0; uIdx < uNbMessages; ++uIdx ) - } // for( size_t m = 0; m < numCompMsInTs; ++m ) - - - // End of TS, check if stuff to do with the hits inside each MS - // Usefull for low rate pulser tests - // Need to do it only when last DPB is processed, as they are done one by one - if( fuCurrDpbIdx == fuNrOfDpbs - 1 ) - { - for( UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx ) - { - fvdMsTime[ uMsIdx ] = 0.0; - } // for( UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx ) - - - // Time differences plotting using the fully time sorted hits - if( 0 < fvmHitsInTs.size() ) - { - ULong64_t ulLastHitTime = ( *( fvmHitsInTs.rbegin() ) ).GetTs(); - std::multiset< stsxyter::FinalHit >::iterator it; - -// std::chrono::steady_clock::time_point tNow = std::chrono::steady_clock::now(); -// Double_t dUnixTimeInRun = std::chrono::duration_cast< std::chrono::seconds >(tNow - ftStartTimeUnix).count(); - - for( it = fvmHitsInTs.begin(); - it != fvmHitsInTs.end() && (*it).GetTs() < ulLastHitTime - 320; // 32 * 3.125 ns = 1000 ns - ++it ) - { - UShort_t usAsicIdx = (*it).GetAsic(); - UShort_t usChanIdx = (*it).GetChan(); - ULong64_t ulHitTs = (*it).GetTs(); - - Bool_t bHitInX = usChanIdx < fuNbChanPerAsic/2; - UInt_t uFiberIdx = fUnpackPar->GetChannelToFiberMap( usChanIdx ); - - Double_t dTimeSinceStartSec = (ulHitTs * stsxyter::kdClockCycleNs - fdStartTime)* 1e-9; - - if( fUnpackPar->GetAsicIndexHodo1() == usAsicIdx ) - { - if( fUnpackPar->IsXySwappedHodo1() ) - bHitInX = !bHitInX; - - if( bHitInX ) - { - if( fUnpackPar->IsXInvertedHodo1() ) - uFiberIdx = fuNbChanPerAsic/2 - 1 - uFiberIdx; - - fLastSortedHit1X = (*it); - - Double_t dDtX1Y1 = ( fLastSortedHit1Y.GetTs() * stsxyter::kdClockCycleNs - ulHitTs * stsxyter::kdClockCycleNs ); - Double_t dDtX1X2 = ( fLastSortedHit2X.GetTs() * stsxyter::kdClockCycleNs - ulHitTs * stsxyter::kdClockCycleNs ); - Double_t dDtX1Y2 = ( fLastSortedHit2Y.GetTs() * stsxyter::kdClockCycleNs - ulHitTs * stsxyter::kdClockCycleNs ); - - fhHodoSortedDtX1Y1->Fill( dDtX1Y1 ); - fhHodoSortedDtX1X2->Fill( dDtX1X2 ); - fhHodoSortedDtX1Y2->Fill( dDtX1Y2 ); - - if( TMath::Abs( dDtX1Y1 ) < fdCoincBorder ) - { - UInt_t uFiberIdxOther = fUnpackPar->GetChannelToFiberMap( fLastSortedHit1Y.GetChan() ); - if( fUnpackPar->IsYInvertedHodo1() ) - uFiberIdxOther = fuNbChanPerAsic/2 - 1 - uFiberIdxOther; - fhHodoSortedMapX1Y1->Fill( uFiberIdx, uFiberIdxOther ); - fhHodoSortedCntEvoX1Y1->Fill( dTimeSinceStartSec ); - } // if( TMath::Abs( dDtX1Y1 ) < fdCoincBorder ) - if( TMath::Abs( dDtX1X2 ) < fdCoincBorder ) - { - UInt_t uFiberIdxOther = fUnpackPar->GetChannelToFiberMap( fLastSortedHit2X.GetChan() ); - if( fUnpackPar->IsXInvertedHodo2() ) - uFiberIdxOther = fuNbChanPerAsic/2 - 1 - uFiberIdxOther; - fhHodoSortedMapX1X2->Fill( uFiberIdx, uFiberIdxOther ); - fhHodoSortedCntEvoX1X2->Fill( dTimeSinceStartSec ); - } // if( TMath::Abs( dDtX1X2 ) < fdCoincBorder ) - if( TMath::Abs( dDtX1Y2 ) < fdCoincBorder ) - { - UInt_t uFiberIdxOther = fUnpackPar->GetChannelToFiberMap( fLastSortedHit2Y.GetChan() ); - if( fUnpackPar->IsYInvertedHodo2() ) - uFiberIdxOther = fuNbChanPerAsic/2 - 1 - uFiberIdxOther; - fhHodoSortedMapX1Y2->Fill( uFiberIdx, uFiberIdxOther ); - fhHodoSortedCntEvoX1Y2->Fill( dTimeSinceStartSec ); - } // if( TMath::Abs( dDtX1Y2 ) < fdCoincBorder ) - } // if( bHitInX ) - else - { - if( fUnpackPar->IsYInvertedHodo1() ) - uFiberIdx = fuNbChanPerAsic/2 - 1 - uFiberIdx; - fLastSortedHit1Y = (*it); - - Double_t dDtX1Y1 = ( ulHitTs * stsxyter::kdClockCycleNs - fLastSortedHit1X.GetTs() * stsxyter::kdClockCycleNs ); - Double_t dDtY1Y2 = ( fLastSortedHit2Y.GetTs() * stsxyter::kdClockCycleNs - ulHitTs * stsxyter::kdClockCycleNs ); - Double_t dDtY1X2 = ( fLastSortedHit2X.GetTs() * stsxyter::kdClockCycleNs - ulHitTs * stsxyter::kdClockCycleNs ); - - fhHodoSortedDtX1Y1->Fill( dDtX1Y1 ); - fhHodoSortedDtY1Y2->Fill( dDtY1Y2 ); - fhHodoSortedDtY1X2->Fill( dDtY1X2 ); - - if( TMath::Abs( dDtX1Y1 ) < fdCoincBorder ) - { - UInt_t uFiberIdxOther = fUnpackPar->GetChannelToFiberMap( fLastSortedHit1X.GetChan() ); - if( fUnpackPar->IsXInvertedHodo1() ) - uFiberIdxOther = fuNbChanPerAsic/2 - 1 - uFiberIdxOther; - fhHodoSortedMapX1Y1->Fill( uFiberIdxOther, uFiberIdx ); - fhHodoSortedCntEvoX1Y1->Fill( dTimeSinceStartSec ); - } // if( TMath::Abs( dDtX1Y1 ) < fdCoincBorder ) - if( TMath::Abs( dDtY1Y2 ) < fdCoincBorder ) - { - UInt_t uFiberIdxOther = fUnpackPar->GetChannelToFiberMap( fLastSortedHit2Y.GetChan() ); - if( fUnpackPar->IsYInvertedHodo2() ) - uFiberIdxOther = fuNbChanPerAsic/2 - 1 - uFiberIdxOther; - fhHodoSortedMapY1Y2->Fill( uFiberIdx, uFiberIdxOther ); - fhHodoSortedCntEvoY1Y2->Fill( dTimeSinceStartSec ); - } // if( TMath::Abs( dDtY1Y2 ) < fdCoincBorder ) - if( TMath::Abs( dDtY1X2 ) < fdCoincBorder ) - { - UInt_t uFiberIdxOther = fUnpackPar->GetChannelToFiberMap( fLastSortedHit2X.GetChan() ); - if( fUnpackPar->IsXInvertedHodo2() ) - uFiberIdxOther = fuNbChanPerAsic/2 - 1 - uFiberIdxOther; - fhHodoSortedMapY1X2->Fill( uFiberIdx, uFiberIdxOther ); - fhHodoSortedCntEvoY1X2->Fill( dTimeSinceStartSec ); - } // if( TMath::Abs( dDtY1X2 ) < fdCoincBorder ) - } // else of if( bHitInX ) - } // if( fUnpackPar->GetAsicIndexHodo1() == usAsicIdx ) - else if( fUnpackPar->GetAsicIndexHodo2() == usAsicIdx ) - { - if( fUnpackPar->IsXySwappedHodo2() ) - bHitInX = !bHitInX; - - if( bHitInX ) - { - if( fUnpackPar->IsXInvertedHodo2() ) - uFiberIdx = fuNbChanPerAsic/2 - 1 - uFiberIdx; - - fLastSortedHit2X = (*it); - - Double_t dDtX2Y2 = ( fLastSortedHit2Y.GetTs() * stsxyter::kdClockCycleNs - ulHitTs * stsxyter::kdClockCycleNs ); - Double_t dDtX1X2 = ( ulHitTs * stsxyter::kdClockCycleNs - fLastSortedHit1X.GetTs() * stsxyter::kdClockCycleNs ); - Double_t dDtY1X2 = ( ulHitTs * stsxyter::kdClockCycleNs - fLastSortedHit1Y.GetTs() * stsxyter::kdClockCycleNs ); - - fhHodoSortedDtX2Y2->Fill( dDtX2Y2 ); - fhHodoSortedDtX1X2->Fill( dDtX1X2 ); - fhHodoSortedDtY1X2->Fill( dDtY1X2 ); - - if( TMath::Abs( dDtX2Y2 ) < fdCoincBorder ) - { - UInt_t uFiberIdxOther = fUnpackPar->GetChannelToFiberMap( fLastSortedHit2Y.GetChan() ); - if( fUnpackPar->IsYInvertedHodo2() ) - uFiberIdxOther = fuNbChanPerAsic/2 - 1 - uFiberIdxOther; - fhHodoSortedMapX2Y2->Fill( uFiberIdx, uFiberIdxOther ); - fhHodoSortedCntEvoX2Y2->Fill( dTimeSinceStartSec ); - } // if( TMath::Abs( dDtX2Y2 ) < fdCoincBorder ) - if( TMath::Abs( dDtX1X2 ) < fdCoincBorder ) - { - UInt_t uFiberIdxOther = fUnpackPar->GetChannelToFiberMap( fLastSortedHit1X.GetChan() ); - if( fUnpackPar->IsXInvertedHodo1() ) - uFiberIdxOther = fuNbChanPerAsic/2 - 1 - uFiberIdxOther; - fhHodoSortedMapX1X2->Fill( uFiberIdxOther, uFiberIdx ); - fhHodoSortedCntEvoX1X2->Fill( dTimeSinceStartSec ); - } // if( TMath::Abs( dDtX1X2 ) < fdCoincBorder ) - if( TMath::Abs( dDtY1X2 ) < fdCoincBorder ) - { - UInt_t uFiberIdxOther = fUnpackPar->GetChannelToFiberMap( fLastSortedHit1Y.GetChan() ); - if( fUnpackPar->IsYInvertedHodo1() ) - uFiberIdxOther = fuNbChanPerAsic/2 - 1 - uFiberIdxOther; - fhHodoSortedMapY1X2->Fill( uFiberIdxOther, uFiberIdx ); - fhHodoSortedCntEvoY1X2->Fill( dTimeSinceStartSec ); - } // if( TMath::Abs( dDtY1X2 ) < fdCoincBorder ) - } // if( bHitInX ) - else - { - if( fUnpackPar->IsYInvertedHodo2() ) - uFiberIdx = fuNbChanPerAsic/2 - 1 - uFiberIdx; - - fLastSortedHit2Y = (*it); - - Double_t dDtX2Y2 = ( ulHitTs * stsxyter::kdClockCycleNs - fLastSortedHit2X.GetTs() * stsxyter::kdClockCycleNs ); - Double_t dDtY1Y2 = ( ulHitTs * stsxyter::kdClockCycleNs - fLastSortedHit1Y.GetTs() * stsxyter::kdClockCycleNs ); - Double_t dDtX1Y2 = ( ulHitTs * stsxyter::kdClockCycleNs - fLastSortedHit1X.GetTs() * stsxyter::kdClockCycleNs ); - - fhHodoSortedDtX2Y2->Fill( dDtX2Y2 ); - fhHodoSortedDtY1Y2->Fill( dDtY1Y2 ); - fhHodoSortedDtX1Y2->Fill( dDtX1Y2 ); - - if( TMath::Abs( dDtX2Y2 ) < fdCoincBorder ) - { - UInt_t uFiberIdxOther = fUnpackPar->GetChannelToFiberMap( fLastSortedHit2X.GetChan() ); - if( fUnpackPar->IsXInvertedHodo2() ) - uFiberIdxOther = fuNbChanPerAsic/2 - 1 - uFiberIdxOther; - fhHodoSortedMapX2Y2->Fill( uFiberIdxOther, uFiberIdx ); - fhHodoSortedCntEvoX2Y2->Fill( dTimeSinceStartSec ); - } // if( TMath::Abs( dDtX2Y2 ) < fdCoincBorder ) - if( TMath::Abs( dDtY1Y2 ) < fdCoincBorder ) - { - UInt_t uFiberIdxOther = fUnpackPar->GetChannelToFiberMap( fLastSortedHit1Y.GetChan() ); - if( fUnpackPar->IsYInvertedHodo1() ) - uFiberIdxOther = fuNbChanPerAsic/2 - 1 - uFiberIdxOther; - fhHodoSortedMapY1Y2->Fill( uFiberIdxOther, uFiberIdx ); - fhHodoSortedCntEvoY1Y2->Fill( dTimeSinceStartSec ); - } // if( TMath::Abs( dDtY1Y2 ) < fdCoincBorder ) - if( TMath::Abs( dDtX1Y2 ) < fdCoincBorder ) - { - UInt_t uFiberIdxOther = fUnpackPar->GetChannelToFiberMap( fLastSortedHit1X.GetChan() ); - if( fUnpackPar->IsXInvertedHodo1() ) - uFiberIdxOther = fuNbChanPerAsic/2 - 1 - uFiberIdxOther; - fhHodoSortedMapX1Y2->Fill( uFiberIdxOther, uFiberIdx ); - fhHodoSortedCntEvoX1Y2->Fill( dTimeSinceStartSec ); - } // if( TMath::Abs( dDtX1Y2 ) < fdCoincBorder ) - } // else of if( bHitInX ) - } // else if( fUnpackPar->GetAsicIndexHodo2() == usAsicIdx ) - } // loop on hits untils hits within 100 ns of last one or last one itself are reached - - // Remove all hits which were already used - fvmHitsInTs.erase( fvmHitsInTs.begin(), it ); - } // if( 0 < fvmHitsInTs.size() ) -/* - // Remove all hits from this TS - for( UInt_t uAsicIdx = 0; uAsicIdx < fuNbStsXyters; ++uAsicIdx ) - for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - fvmChanHitsInTs[ uAsicIdx ][ uChan ].clear(); -*/ - } // if( fuCurrDpbIdx == fuNrOfDpbs - 1 ) - - if( 0 == ts.index() % 1000 && fuCurrDpbIdx == fuNrOfDpbs - 1 ) - { - for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - { - Double_t dTsMsbTime = - static_cast<ULong64_t>( stsxyter::kuHitNbTsBins ) - * static_cast<ULong64_t>( fvulCurrentTsMsb[fuCurrDpbIdx]) - + static_cast<ULong64_t>( stsxyter::kulTsCycleNbBins ) - * static_cast<ULong64_t>( fvuCurrentTsMsbCycle[fuCurrDpbIdx] ); - dTsMsbTime *= stsxyter::kdClockCycleNs * 1e-9; - - LOG(info) << "End of TS " << std::setw(7) << ts.index() - << " eDPB " << std::setw(2) << uDpb - << " current TS MSB counter is " << std::setw(12) << fvulCurrentTsMsb[uDpb] - << " current TS MSB cycle counter is " << std::setw(12) << fvuCurrentTsMsbCycle[uDpb] - << " current TS MSB time is " << std::setw(12) << dTsMsbTime << " s"; - } - } // if( 0 == ts.index() % 1000 && fuCurrDpbIdx == fuNrOfDpbs - 1 ) - - return kTRUE; -} - -void CbmCosy2018MonitorHodo::FillHitInfo( stsxyter::Message mess, const UShort_t & /*usElinkIdx*/, const UInt_t & uAsicIdx, const UInt_t & uMsIdx ) -{ - UShort_t usChan = mess.GetHitChannel(); - UShort_t usRawAdc = mess.GetHitAdc(); -// UShort_t usFullTs = mess.GetHitTimeFull(); -// Bool_t bMissedEvt = mess.IsHitMissedEvts(); - UShort_t usRawTs = mess.GetHitTime(); - - fhHodoChanCntRaw[ uAsicIdx ]->Fill( usChan ); - fhHodoChanAdcRaw[ uAsicIdx ]->Fill( usChan, usRawAdc ); - fhHodoChanAdcRawProf[ uAsicIdx ]->Fill( usChan, usRawAdc ); - fhHodoChanRawTs[ uAsicIdx ]->Fill( usChan, usRawTs ); - fhHodoChanMissEvt[ uAsicIdx ]->Fill( usChan, mess.IsHitMissedEvts() ); - - // Compute the Full time stamp -// Long64_t ulOldHitTime = fvulChanLastHitTime[ uAsicIdx ][ usChan ]; -// Double_t dOldHitTime = fvdChanLastHitTime[ uAsicIdx ][ usChan ]; - - // Use TS w/o overlap bits as they will anyway come from the TS_MSB - fvulChanLastHitTime[ uAsicIdx ][ usChan ] = usRawTs; - - fvulChanLastHitTime[ uAsicIdx ][ usChan ] += - static_cast<ULong64_t>( stsxyter::kuHitNbTsBins ) - * static_cast<ULong64_t>( fvulCurrentTsMsb[fuCurrDpbIdx]) - + static_cast<ULong64_t>( stsxyter::kulTsCycleNbBins ) - * static_cast<ULong64_t>( fvuCurrentTsMsbCycle[fuCurrDpbIdx] ) - ; - -// fvuElinkLastTsHit[fuCurrDpbIdx] = usRawTs; - - // Convert the Hit time in bins to Hit time in ns - Double_t dHitTimeNs = fvulChanLastHitTime[ uAsicIdx ][ usChan ] * stsxyter::kdClockCycleNs; -/* - // If needed fill the hit interval plots - if( fbChanHitDtEna ) - { - Double_t dDeltaT = dHitTimeNs - fvdChanLastHitTime[ uAsicIdx ][ usChan ]; - if( 0 == dDeltaT ) - fhStsChanHitDtNeg[ uAsicIdx ]->Fill( 1, usChan ); - else if( 0 < dDeltaT ) - fhStsChanHitDt[ uAsicIdx ]->Fill( dDeltaT, usChan ); - else fhStsChanHitDtNeg[ uAsicIdx ]->Fill( -dDeltaT, usChan ); - } // if( fbChanHitDtEna ) -*/ - // Store new value of Hit time in ns - fvdChanLastHitTime[ uAsicIdx ][ usChan ] = fvulChanLastHitTime[ uAsicIdx ][ usChan ] * stsxyter::kdClockCycleNs; -/* - LOG(info) << " Asic " << std::setw( 2 ) << uAsicIdx - << " Channel " << std::setw( 3 ) << usChan - << " Diff to last hit " << std::setw( 12 ) << ( fvulChanLastHitTime[ uAsicIdx ][ usChan ] - ulOldHitTime) - << " in s " << std::setw( 12 ) << ( fvdChanLastHitTime[ uAsicIdx ][ usChan ] - dOldHitTime) * 1e-9; -*/ - // Pulser and MS - fvuChanNbHitsInMs[ uAsicIdx ][ usChan ][ uMsIdx ] ++; - fvdChanLastHitTimeInMs[ uAsicIdx ][ usChan ][ uMsIdx ] = dHitTimeNs; - fvusChanLastHitAdcInMs[ uAsicIdx ][ usChan ][ uMsIdx ] = usRawAdc; -// fvmChanHitsInTs[ uAsicIdx ][ usChan ].insert( stsxyter::FinalHit( fvulChanLastHitTime[ uAsicIdx ][ usChan ], -// usRawAdc, uAsicIdx, usChan ) ); - fvmHitsInTs.insert( stsxyter::FinalHit( fvulChanLastHitTime[ uAsicIdx ][ usChan ], usRawAdc, uAsicIdx, usChan ) ); - -/* - LOG(info) << " TS " << std::setw( 12 ) << fulCurrentTsIdx - << " MS " << std::setw( 12 ) << fulCurrentMsIdx - << " MsInTs " << std::setw( 3 ) << uMsIdx - << " Asic " << std::setw( 2 ) << uAsicIdx - << " Channel " << std::setw( 3 ) << usChan - << " ADC " << std::setw( 3 ) << usRawAdc - << " TS " << std::setw( 3 ) << usRawTs // 9 bits TS - << " SX TsMsb " << std::setw( 2 ) << ( fvulCurrentTsMsb[fuCurrDpbIdx] & 0x1F ) // Total StsXyter TS = 14 bits => 9b Hit TS + lower 5b TS_MSB after DPB - << " DPB TsMsb " << std::setw( 6 ) << ( fvulCurrentTsMsb[fuCurrDpbIdx] >> 5 ) // Total StsXyter TS = 14 bits => 9b Hit TS + lower 5b of TS_MSB after DPB - << " TsMsb " << std::setw( 7 ) << fvulCurrentTsMsb[fuCurrDpbIdx] - << " MsbCy " << std::setw( 4 ) << fvuCurrentTsMsbCycle[fuCurrDpbIdx] - << " Time " << std::setw ( 12 ) << fvulChanLastHitTime[ uAsicIdx ][ usChan ]; -*/ - // Check Starting point of histos with time as X axis - if( -1 == fdStartTime ) - fdStartTime = fvdChanLastHitTime[ uAsicIdx ][ usChan ]; - - // Fill histos with time as X axis - Double_t dTimeSinceStartSec = (fvdChanLastHitTime[ uAsicIdx ][ usChan ] - fdStartTime)* 1e-9; - Double_t dTimeSinceStartMin = dTimeSinceStartSec / 60.0; - fhHodoChanHitRateEvo[ uAsicIdx ]->Fill( dTimeSinceStartSec , usChan ); - fhHodoFebRateEvo[ uAsicIdx ]->Fill( dTimeSinceStartSec ); - fhHodoChanHitRateEvoLong[ uAsicIdx ]->Fill( dTimeSinceStartMin, usChan, 1.0/60.0 ); - fhHodoFebRateEvoLong[ uAsicIdx ]->Fill( dTimeSinceStartMin, 1.0/60.0 ); -/* - if( kTRUE == fbLongHistoEnable ) - { - std::chrono::steady_clock::time_point tNow = std::chrono::steady_clock::now(); - Double_t dUnixTimeInRun = std::chrono::duration_cast< std::chrono::seconds >(tNow - ftStartTimeUnix).count(); - fhFebRateEvoLong[ uAsicIdx ]->Fill( dUnixTimeInRun , 1.0 / fuLongHistoBinSizeSec ); - fhFebChRateEvoLong[ uAsicIdx ]->Fill( dUnixTimeInRun , usChan, 1.0 / fuLongHistoBinSizeSec ); - } // if( kTRUE == fbLongHistoEnable ) -*/ - // Fill histos for single Hodos - UInt_t uFiberInHodo = fUnpackPar->GetChannelToFiberMap( usChan ); - if( fUnpackPar->GetAsicIndexHodo1() == uAsicIdx ) - { - // Hodo 1 - if( fUnpackPar->GetChannelToPlaneMapHodo1( usChan ) ) - { - // Y - fhHodoChanCounts1Y->Fill( uFiberInHodo ); - fhHodoChanAdcRaw1Y->Fill( uFiberInHodo, usRawAdc ); - fhHodoChanHitRateEvo1Y->Fill( dTimeSinceStartSec, uFiberInHodo ); - fhHodoRateEvo1Y->Fill( dTimeSinceStartSec ); -// fhHodoChanHitRateEvo1Y->Fill( dTimeSinceStartMin, uFiberInHodo, 1.0/60.0 ); -// fhHodoRateEvo1Y->Fill( dTimeSinceStartMin, 1.0/60.0 ); - } // if( fUnpackPar->GetChannelToPlaneMapHodo1( usChan ) ) - else - { - // X - fhHodoChanCounts1X->Fill( uFiberInHodo ); - fhHodoChanAdcRaw1X->Fill( uFiberInHodo, usRawAdc ); - fhHodoChanHitRateEvo1X->Fill( dTimeSinceStartSec, uFiberInHodo ); - fhHodoRateEvo1X->Fill( dTimeSinceStartSec ); -// fhHodoChanHitRateEvo1X->Fill( dTimeSinceStartMin, uFiberInHodo, 1.0/60.0 ); -// fhHodoRateEvo1X->Fill( dTimeSinceStartMin, 1.0/60.0 ); - } // else of if( fUnpackPar->GetChannelToPlaneMapHodo1( usChan ) ) - } // if( fUnpackPar->GetAsicIndexHodo1() == uAsicIdx ) - else if( fUnpackPar->GetAsicIndexHodo2() == uAsicIdx ) - { - // Hodo 2 - if( fUnpackPar->GetChannelToPlaneMapHodo2( usChan ) ) - { - // Y - fhHodoChanCounts2Y->Fill( uFiberInHodo ); - fhHodoChanAdcRaw2Y->Fill( uFiberInHodo, usRawAdc ); - fhHodoChanHitRateEvo2Y->Fill( dTimeSinceStartSec, uFiberInHodo ); - fhHodoRateEvo2Y->Fill( dTimeSinceStartSec ); -// fhHodoChanHitRateEvo2Y->Fill( dTimeSinceStartMin, uFiberInHodo, 1.0/60.0 ); -// fhHodoRateEvo2Y->Fill( dTimeSinceStartMin, 1.0/60.0 ); - } // if( fUnpackPar->GetChannelToPlaneMapHodo2( usChan ) ) - else - { - // X - fhHodoChanCounts2X->Fill( uFiberInHodo ); - fhHodoChanAdcRaw2X->Fill( uFiberInHodo, usRawAdc ); - fhHodoChanHitRateEvo2X->Fill( dTimeSinceStartSec, uFiberInHodo ); - fhHodoRateEvo2X->Fill( dTimeSinceStartSec ); -// fhHodoChanHitRateEvo2X->Fill( dTimeSinceStartMin, uFiberInHodo, 1.0/60.0 ); -// fhHodoRateEvo2X->Fill( dTimeSinceStartMin, 1.0/60.0 ); - } // else of if( fUnpackPar->GetChannelToPlaneMapHodo2( usChan ) ) - } // else if( fUnpackPar->GetAsicIndexHodo2() == uAsicIdx ) - -} - -void CbmCosy2018MonitorHodo::FillTsMsbInfo( stsxyter::Message mess, UInt_t /*uMessIdx*/, UInt_t /*uMsIdx*/ ) -{ - UInt_t uVal = mess.GetTsMsbVal(); -/* - if( 0 == fuCurrDpbIdx ) - LOG(info) << " TS " << std::setw( 12 ) << fulCurrentTsIdx - << " MS " << std::setw( 12 ) << fulCurrentMsIdx - << " MsInTs " << std::setw( 3 ) << uMsIdx - << " DPB " << std::setw( 2 ) << fuCurrDpbIdx - << " Mess " << std::setw( 5 ) << uMessIdx - << " TsMsb " << std::setw( 5 ) << uVal; -*/ -/* - if( (uVal != fvulCurrentTsMsb[fuCurrDpbIdx] + 1) && 0 < uVal && - !( 1 == uMessIdx && usVal == fvulCurrentTsMsb[fuCurrDpbIdx] ) ) // 1st TS_MSB in MS is always a repeat of the last one in previous MS! - { - LOG(info) << "TS MSB not increasing by 1! TS " << std::setw( 12 ) << fulCurrentTsIdx - << " MS " << std::setw( 12 ) << fulCurrentMsIdx - << " MsInTs " << std::setw( 3 ) << uMsIdx - << " DPB " << std::setw( 2 ) << fuCurrDpbIdx - << " Mess " << std::setw( 5 ) << uMessIdx - << " Old TsMsb " << std::setw( 5 ) << fvulCurrentTsMsb[fuCurrDpbIdx] - << " new TsMsb " << std::setw( 5 ) << uVal - << " Diff " << std::setw( 5 ) << uVal - fvulCurrentTsMsb[fuCurrDpbIdx] - << " Old MsbCy " << std::setw( 5 ) << fvuCurrentTsMsbCycle[fuCurrDpbIdx]; - } // if( (uVal != fvulCurrentTsMsb[fuCurrDpbIdx] + 1) && 0 < uVal ) -*/ - - // Update Status counters - if( uVal < fvulCurrentTsMsb[fuCurrDpbIdx] ) - { - - LOG(info) << " TS " << std::setw( 12 ) << fulCurrentTsIdx - << " MS " << std::setw( 12 ) << fulCurrentMsIdx - << " DPB " << std::setw( 2 ) << fuCurrDpbIdx - << " Old TsMsb " << std::setw( 5 ) << fvulCurrentTsMsb[fuCurrDpbIdx] - << " Old MsbCy " << std::setw( 5 ) << fvuCurrentTsMsbCycle[fuCurrDpbIdx] - << " new TsMsb " << std::setw ( 5 ) << uVal; - - fvuCurrentTsMsbCycle[fuCurrDpbIdx] ++; - } // if( uVal < fvulCurrentTsMsb[fuCurrDpbIdx] ) - fvulCurrentTsMsb[fuCurrDpbIdx] = uVal; -/* - if( 1 < uMessIdx ) - { - fhStsDpbRawTsMsb->Fill( fuCurrDpbIdx, fvulCurrentTsMsb[fuCurrDpbIdx] ); - fhStsDpbRawTsMsbSx->Fill( fuCurrDpbIdx, ( fvulCurrentTsMsb[fuCurrDpbIdx] & 0x1F ) ); - fhStsDpbRawTsMsbDpb->Fill( fuCurrDpbIdx, ( fvulCurrentTsMsb[fuCurrDpbIdx] >> 5 ) ); - } // if( 0 < uMessIdx ) -*/ -// fhStsAsicTsMsb->Fill( fvulCurrentTsMsb[fuCurrDpbIdx], uAsicIdx ); -} - -void CbmCosy2018MonitorHodo::FillEpochInfo( stsxyter::Message /*mess*/ ) -{ -// UInt_t uVal = mess.GetTsMsbVal(); -/* - // Update Status counters - if( usVal < fvulCurrentTsMsb[fuCurrDpbIdx] ) - fvuCurrentTsMsbCycle[fuCurrDpbIdx] ++; - fvulCurrentTsMsb[fuCurrDpbIdx] = usVal; - -// fhStsAsicTsMsb->Fill( fvulCurrentTsMsb[fuCurrDpbIdx], uAsicIdx ); -*/ -} - -void CbmCosy2018MonitorHodo::Reset() -{ -} - -void CbmCosy2018MonitorHodo::Finish() -{ - - LOG(info) << "-------------------------------------"; - LOG(info) << "CbmCosy2018MonitorHodo statistics are "; - LOG(info) << " Hit messages: " << fmMsgCounter[ stsxyter::MessType::Hit ] << "\n" - << " Ts MSB messages: " << fmMsgCounter[ stsxyter::MessType::TsMsb ] << "\n" - << " Dummy messages: " << fmMsgCounter[ stsxyter::MessType::Dummy ] << "\n" - << " Epoch messages: " << fmMsgCounter[ stsxyter::MessType::Epoch ] << "\n" - << " Empty messages: " << fmMsgCounter[ stsxyter::MessType::Empty ]; - - LOG(info) << "-------------------------------------"; - - SaveAllHistos( "data/HodoHistos.root" ); - SaveAllHistos(); - -} - - -void CbmCosy2018MonitorHodo::FillOutput(boost::any) -{ -} - -void CbmCosy2018MonitorHodo::SaveAllHistos( TString sFileName ) -{ - TDirectory * oldDir = NULL; - TFile * histoFile = NULL; - if( "" != sFileName ) - { - // Store current directory position to allow restore later - oldDir = gDirectory; - // open separate histo file in recreate mode - histoFile = new TFile( sFileName , "RECREATE"); - histoFile->cd(); - } // if( "" != sFileName ) - - gDirectory->mkdir("Sts_Raw"); - gDirectory->cd("Sts_Raw"); - - fhHodoMessType->Write(); - fhHodoSysMessType->Write(); - fhHodoMessTypePerDpb->Write(); - fhHodoSysMessTypePerDpb->Write(); - fhHodoMessTypePerElink->Write(); - fhHodoSysMessTypePerElink->Write(); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fhHodoChanCntRaw[ uXyterIdx ]->Write(); - fhHodoChanAdcRaw[ uXyterIdx ]->Write(); - fhHodoChanAdcRawProf[ uXyterIdx ]->Write(); - fhHodoChanRawTs[ uXyterIdx ]->Write(); - fhHodoChanMissEvt[ uXyterIdx ]->Write(); - fhHodoChanHitRateEvo[ uXyterIdx ]->Write(); - fhHodoFebRateEvo[ uXyterIdx ]->Write(); - fhHodoChanHitRateEvoLong[ uXyterIdx ]->Write(); - fhHodoFebRateEvoLong[ uXyterIdx ]->Write(); -/* - if( kTRUE == fbLongHistoEnable ) - { - fhFebRateEvoLong[ uXyterIdx ]->Write(); - fhFebChRateEvoLong[ uXyterIdx ]->Write(); - } // if( kTRUE == fbLongHistoEnable ) -*/ - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - - fhHodoChanCounts1X->Write(); - fhHodoChanCounts1Y->Write(); - fhHodoChanCounts2X->Write(); - fhHodoChanCounts2Y->Write(); - fhHodoChanAdcRaw1X->Write(); - fhHodoChanAdcRaw1Y->Write(); - fhHodoChanAdcRaw2X->Write(); - fhHodoChanAdcRaw2Y->Write(); - fhHodoChanHitRateEvo1X->Write(); - fhHodoChanHitRateEvo1Y->Write(); - fhHodoChanHitRateEvo2X->Write(); - fhHodoChanHitRateEvo2Y->Write(); - fhHodoRateEvo1X->Write(); - fhHodoRateEvo1Y->Write(); - fhHodoRateEvo1X->Write(); - fhHodoRateEvo2Y->Write(); - - fhHodoSortedDtX1Y1->Write(); - fhHodoSortedDtX2Y2->Write(); - fhHodoSortedDtX1X2->Write(); - fhHodoSortedDtY1Y2->Write(); - fhHodoSortedDtX1Y2->Write(); - fhHodoSortedDtY1X2->Write(); - fhHodoSortedMapX1Y1->Write(); - fhHodoSortedMapX2Y2->Write(); - fhHodoSortedMapX1X2->Write(); - fhHodoSortedMapY1Y2->Write(); - fhHodoSortedMapX1Y2->Write(); - fhHodoSortedMapY1X2->Write(); - -// fhHodoFebTsMsb->Write(); - - gDirectory->cd(".."); - - // Flib Histos - gDirectory->mkdir("Flib_Raw"); - gDirectory->cd("Flib_Raw"); - for( UInt_t uLinks = 0; uLinks < kiMaxNbFlibLinks; uLinks ++) - { - TString sMsSzName = Form("MsSz_link_%02u", uLinks); - if( fHM->Exists(sMsSzName.Data() ) ) - fHM->H1( sMsSzName.Data() )->Write(); - - sMsSzName = Form("MsSzTime_link_%02u", uLinks); - if( fHM->Exists(sMsSzName.Data() ) ) - fHM->P1( sMsSzName.Data() )->Write(); - } // for( UInt_t uLinks = 0; uLinks < 16; uLinks ++) - gDirectory->cd(".."); - - if( "" != sFileName ) - { - // Restore original directory position - histoFile->Close(); - oldDir->cd(); - } // if( "" != sFileName ) - -} -void CbmCosy2018MonitorHodo::ResetAllHistos() -{ - LOG(info) << "Reseting all STS histograms."; - - fhHodoMessType->Reset(); - fhHodoSysMessType->Reset(); - fhHodoMessTypePerDpb->Reset(); - fhHodoSysMessTypePerDpb->Reset(); - fhHodoMessTypePerElink->Reset(); - fhHodoSysMessTypePerElink->Reset(); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fhHodoChanCntRaw[ uXyterIdx ]->Reset(); - fhHodoChanAdcRaw[ uXyterIdx ]->Reset(); - fhHodoChanAdcRawProf[ uXyterIdx ]->Reset(); - fhHodoChanRawTs[ uXyterIdx ]->Reset(); - fhHodoChanMissEvt[ uXyterIdx ]->Reset(); - fhHodoChanHitRateEvo[ uXyterIdx ]->Reset(); - fhHodoFebRateEvo[ uXyterIdx ]->Reset(); - fhHodoChanHitRateEvoLong[ uXyterIdx ]->Reset(); - fhHodoFebRateEvoLong[ uXyterIdx ]->Reset(); -/* - if( kTRUE == fbLongHistoEnable ) - { - ftStartTimeUnix = std::chrono::steady_clock::now(); - fhFebRateEvoLong[ uXyterIdx ]->Reset(); - fhFebChRateEvoLong[ uXyterIdx ]->Reset(); - } // if( kTRUE == fbLongHistoEnable ) -*/ - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - - fhHodoChanCounts1X->Reset(); - fhHodoChanCounts1Y->Reset(); - fhHodoChanCounts2X->Reset(); - fhHodoChanCounts2Y->Reset(); - fhHodoChanAdcRaw1X->Reset(); - fhHodoChanAdcRaw1Y->Reset(); - fhHodoChanAdcRaw2X->Reset(); - fhHodoChanAdcRaw2Y->Reset(); - fhHodoChanHitRateEvo1X->Reset(); - fhHodoChanHitRateEvo1Y->Reset(); - fhHodoChanHitRateEvo2X->Reset(); - fhHodoChanHitRateEvo2Y->Reset(); - fhHodoRateEvo1X->Reset(); - fhHodoRateEvo1Y->Reset(); - fhHodoRateEvo1X->Reset(); - fhHodoRateEvo2Y->Reset(); - - fhHodoSortedDtX1Y1->Reset(); - fhHodoSortedDtX2Y2->Reset(); - fhHodoSortedDtX1X2->Reset(); - fhHodoSortedDtY1Y2->Reset(); - fhHodoSortedDtX1Y2->Reset(); - fhHodoSortedDtY1X2->Reset(); - fhHodoSortedMapX1Y1->Reset(); - fhHodoSortedMapX2Y2->Reset(); - fhHodoSortedMapX1X2->Reset(); - fhHodoSortedMapY1Y2->Reset(); - fhHodoSortedMapX1Y2->Reset(); - fhHodoSortedMapY1X2->Reset(); - -// fhHodoFebTsMsb->Reset(); - - for( UInt_t uLinks = 0; uLinks < kiMaxNbFlibLinks; ++uLinks ) - { - TString sMsSzName = Form("MsSz_link_%02u", uLinks); - if( fHM->Exists(sMsSzName.Data() ) ) - fHM->H1( sMsSzName.Data() )->Reset(); - - sMsSzName = Form("MsSzTime_link_%02u", uLinks); - if( fHM->Exists(sMsSzName.Data() ) ) - fHM->P1( sMsSzName.Data() )->Reset(); - } // for( UInt_t uLinks = 0; uLinks < kiMaxNbFlibLinks; ++uLinks ) - - fdStartTime = -1; - fdStartTimeMsSz = -1; -} - -void CbmCosy2018MonitorHodo::SetRunStart( Int_t dateIn, Int_t timeIn, Int_t iBinSize ) -{ - TDatime * fRunStartDateTime = new TDatime( dateIn, timeIn); - fiRunStartDateTimeSec = fRunStartDateTime->Convert(); - fiBinSizeDatePlots = iBinSize; - - LOG(info) << "Assigned new MUCH Run Start Date-Time: " << fRunStartDateTime->AsString(); -} - -void CbmCosy2018MonitorHodo::SetLongDurationLimits( UInt_t uDurationSeconds, UInt_t uBinSize ) -{ - fbLongHistoEnable = kTRUE; - fuLongHistoNbSeconds = uDurationSeconds; - fuLongHistoBinSizeSec = uBinSize; -} - -ClassImp(CbmCosy2018MonitorHodo) diff --git a/beamtime/cosy2018/unpacker/CbmCosy2018MonitorHodo.h b/beamtime/cosy2018/unpacker/CbmCosy2018MonitorHodo.h deleted file mode 100644 index 6893f495084289cbadf724373fc691b4193b6618..0000000000000000000000000000000000000000 --- a/beamtime/cosy2018/unpacker/CbmCosy2018MonitorHodo.h +++ /dev/null @@ -1,209 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmCosy2018MonitorHodo ----- -// ----- Created 15/02/18 by P.-A. Loizeau ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CBMCOSY2018MONITORHODO_H -#define CBMCOSY2018MONITORHODO_H - -#include "Timeslice.hpp" - -// Data -#include "StsXyterMessage.h" -#include "StsXyterFinalHit.h" - -// CbmRoot -#include "CbmTSUnpack.h" -#include "CbmHistManager.h" - -// C++11 -#include <chrono> - -// C/C++ -#include <vector> -#include <set> -#include <map> - -class CbmCern2017UnpackParHodo; - -class CbmCosy2018MonitorHodo: public CbmTSUnpack -{ -public: - - CbmCosy2018MonitorHodo(); - virtual ~CbmCosy2018MonitorHodo(); - - virtual Bool_t Init(); - - virtual Bool_t DoUnpack(const fles::Timeslice& ts, size_t component); - - virtual void Reset(); - - virtual void Finish(); - - void SetParContainers(); - - Bool_t InitContainers(); - - Bool_t ReInitContainers(); - - void FillOutput(boost::any); - - void SetRunStart( Int_t dateIn, Int_t timeIn, Int_t iBinSize = 5 ); - - void ResetAllHistos(); - void SaveAllHistos( TString sFileName = "" ); - - void SetMsOverlap(size_t uOverlapMsNb = 1) { fuOverlapMsNb = uOverlapMsNb; } - size_t GetMsOverlap() { return fuOverlapMsNb; } - - void SetPrintMessage( Bool_t bPrintMessOn = kTRUE, - stsxyter::MessagePrintMask ctrl = stsxyter::MessagePrintMask::msg_print_Hex | - stsxyter::MessagePrintMask::msg_print_Human ) - { fbPrintMessages = bPrintMessOn; fPrintMessCtrl = ctrl; } - void SetLongDurationLimits( UInt_t uDurationSeconds = 3600, UInt_t uBinSize = 1 ); - void SetCoincidenceBorder( Double_t dNewValue ){ fdCoincBorder = dNewValue;} - -private: - size_t fuOverlapMsNb; /** Ignore Overlap Ms: all fuOverlapMsNb MS at the end of timeslice **/ - - // Parameters - CbmCern2017UnpackParHodo* fUnpackPar; //! - UInt_t fuNrOfDpbs; //! Total number of Sts DPBs in system - std::map<UInt_t, UInt_t> fDpbIdIndexMap; //! Map of DPB Identifier to DPB index - UInt_t fuNbElinksPerDpb; //! Number of possible eLinks per DPB - UInt_t fuNbStsXyters; //! Number of StsXyter ASICs - UInt_t fuNbChanPerAsic; //! Number of channels per StsXyter ASIC => should be constant somewhere!!!! - std::vector< std::vector< UInt_t > > fvuElinkToAsic; //! Vector holding for each link the corresponding ASIC index [fuNrOfDpbs * fuNbElinksPerDpb] - - // Constants - static const Int_t kiMaxNbFlibLinks = 16; - static const UInt_t kuBytesPerMessage = 4; - - // Internal Control/status of monitor - // Task configuration values - Bool_t fbPrintMessages; - stsxyter::MessagePrintMask fPrintMessCtrl; - // TS/MS info - ULong64_t fulCurrentTsIdx; - ULong64_t fulCurrentMsIdx; - // Current data properties - std::map< stsxyter::MessType, UInt_t > fmMsgCounter; - UInt_t fuCurrentEquipmentId; //! Current equipment ID, tells from which DPB the current MS is originating - UInt_t fuCurrDpbId; //! Temp holder until Current equipment ID is properly filled in MS - UInt_t fuCurrDpbIdx; //! Index of the DPB from which the MS currently unpacked is coming - Int_t fiRunStartDateTimeSec; //! Start of run time since "epoch" in s, for the plots with date as X axis - Int_t fiBinSizeDatePlots; //! Bin size in s for the plots with date as X axis - - // Data format control - std::vector< ULong64_t > fvulCurrentTsMsb; //! Current TS MSB for each DPB - std::vector< UInt_t > fvuCurrentTsMsbCycle; //! Current TS MSB cycle for DPB - std::vector< UInt_t > fvuElinkLastTsHit; //! TS from last hit for DPB - - std::vector< std::vector< ULong64_t > > fvulChanLastHitTime; //! Last hit time in bins for each Channel - std::vector< std::vector< Double_t > > fvdChanLastHitTime; //! Last hit time in ns for each Channel - std::vector< Double_t > fvdMsTime; //! Header time of each MS - std::vector< std::vector< std::vector< UInt_t > > > fvuChanNbHitsInMs; //! Number of hits in each MS for each Channel - std::vector< std::vector< std::vector< Double_t > > > fvdChanLastHitTimeInMs; //! Last hit time in bins in each MS for each Channel - std::vector< std::vector< std::vector< UShort_t > > > fvusChanLastHitAdcInMs; //! Last hit ADC in bins in each MS for each Channel -// std::vector< std::vector< std::multiset< stsxyter::FinalHit > > > fvmChanHitsInTs; //! All hits (time & ADC) in bins in last TS for each Channel - // Starting state book-keeping - Double_t fdStartTime; /** Time of first valid hit (TS_MSB available), used as reference for evolution plots**/ - Double_t fdStartTimeMsSz; /** Time of first microslice, used as reference for evolution plots**/ - std::chrono::steady_clock::time_point ftStartTimeUnix; /** Time of run Start from UNIX system, used as reference for long evolution plots against reception time **/ - - // Hits time-sorting - std::multiset< stsxyter::FinalHit > fvmHitsInTs; //! All hits (time in bins, ADC in bins, asic, channel) in last TS, sorted by multiset with "<" operator - stsxyter::FinalHit fLastSortedHit1X; //! Last sorted hit for Hodo 1 X - stsxyter::FinalHit fLastSortedHit1Y; //! Last sorted hit for Hodo 1 Y - stsxyter::FinalHit fLastSortedHit2X; //! Last sorted hit for Hodo 2 X - stsxyter::FinalHit fLastSortedHit2Y; //! Last sorted hit for Hodo 2 Y - // Coincidence histos - UInt_t fuMaxNbMicroslices; - // Rate evolution histos - Bool_t fbLongHistoEnable; - UInt_t fuLongHistoNbSeconds; - UInt_t fuLongHistoBinSizeSec; - UInt_t fuLongHistoBinNb; - - // Histograms - CbmHistManager* fHM; //! Histogram manager - TH1* fhHodoMessType; - TH1* fhHodoSysMessType; - TH2* fhHodoMessTypePerDpb; - TH2* fhHodoSysMessTypePerDpb; -/* - TH2* fhStsDpbRawTsMsb; - TH2* fhStsDpbRawTsMsbSx; - TH2* fhStsDpbRawTsMsbDpb; -*/ - TH2* fhHodoMessTypePerElink; - TH2* fhHodoSysMessTypePerElink; - - std::vector<TH1 *> fhHodoChanCntRaw; - std::vector<TH2 *> fhHodoChanAdcRaw; - std::vector<TProfile*> fhHodoChanAdcRawProf; - std::vector<TH2*> fhHodoChanRawTs; - std::vector<TH2*> fhHodoChanMissEvt; - std::vector<TH2*> fhHodoChanHitRateEvo; - std::vector<TH1*> fhHodoFebRateEvo; - std::vector<TH2*> fhHodoChanHitRateEvoLong; - std::vector<TH1*> fhHodoFebRateEvoLong; - - TH1 * fhHodoChanCounts1X; - TH1 * fhHodoChanCounts1Y; - TH1 * fhHodoChanCounts2X; - TH1 * fhHodoChanCounts2Y; - TH2 * fhHodoChanAdcRaw1X; - TH2 * fhHodoChanAdcRaw1Y; - TH2 * fhHodoChanAdcRaw2X; - TH2 * fhHodoChanAdcRaw2Y; - TH2 * fhHodoChanHitRateEvo1X; - TH2 * fhHodoChanHitRateEvo1Y; - TH2 * fhHodoChanHitRateEvo2X; - TH2 * fhHodoChanHitRateEvo2Y; - TH1 * fhHodoRateEvo1X; - TH1 * fhHodoRateEvo1Y; - TH1 * fhHodoRateEvo2X; - TH1 * fhHodoRateEvo2Y; - - // Coincidences in sorted hits - Double_t fdCoincBorder; // ns, +/- - TH1 * fhHodoSortedDtX1Y1; - TH1 * fhHodoSortedDtX2Y2; - TH1 * fhHodoSortedDtX1X2; - TH1 * fhHodoSortedDtY1Y2; - TH1 * fhHodoSortedDtX1Y2; - TH1 * fhHodoSortedDtY1X2; - TH2 * fhHodoSortedMapX1Y1; - TH2 * fhHodoSortedMapX2Y2; - TH2 * fhHodoSortedMapX1X2; - TH2 * fhHodoSortedMapY1Y2; - TH2 * fhHodoSortedMapX1Y2; - TH2 * fhHodoSortedMapY1X2; - TH1 * fhHodoSortedCntEvoX1Y1; - TH1 * fhHodoSortedCntEvoX2Y2; - TH1 * fhHodoSortedCntEvoX1X2; - TH1 * fhHodoSortedCntEvoY1Y2; - TH1 * fhHodoSortedCntEvoX1Y2; - TH1 * fhHodoSortedCntEvoY1X2; - - TCanvas* fcMsSizeAll; - TH1* fhMsSz[kiMaxNbFlibLinks]; - TProfile* fhMsSzTime[kiMaxNbFlibLinks]; - - void CreateHistograms(); - - void FillHitInfo( stsxyter::Message mess, const UShort_t & usElinkIdx, const UInt_t & uAsicIdx, const UInt_t & uMsIdx ); - void FillTsMsbInfo( stsxyter::Message mess, UInt_t uMessIdx = 0, UInt_t uMsIdx = 0); - void FillEpochInfo( stsxyter::Message mess ); - - CbmCosy2018MonitorHodo(const CbmCosy2018MonitorHodo&); - CbmCosy2018MonitorHodo operator=(const CbmCosy2018MonitorHodo&); - - ClassDef(CbmCosy2018MonitorHodo, 1) -}; - -#endif // CBMCOSY2018MONITORHODO_H diff --git a/beamtime/cosy2018/unpacker/CbmCosy2018MonitorPulser.cxx b/beamtime/cosy2018/unpacker/CbmCosy2018MonitorPulser.cxx deleted file mode 100644 index 6f6d2f832c6795f7aac3fbc51e65da4e82110f22..0000000000000000000000000000000000000000 --- a/beamtime/cosy2018/unpacker/CbmCosy2018MonitorPulser.cxx +++ /dev/null @@ -1,1410 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmCosy2018MonitorPulser ----- -// ----- Created 11/05/18 by P.-A. Loizeau ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#include "CbmCosy2018MonitorPulser.h" - -// Data - -// CbmRoot -#include "CbmCern2017UnpackParHodo.h" -#include "CbmHistManager.h" - -// FairRoot -#include "FairLogger.h" -#include "FairRootManager.h" -#include "FairRun.h" -#include "FairRuntimeDb.h" -#include "FairRunOnline.h" - -// Root -#include "TClonesArray.h" -#include "TString.h" -#include "TRandom.h" -#include "THttpServer.h" -#include "TROOT.h" -#include "TStyle.h" -#include "TMath.h" -#include <TFile.h> - -// C++11 - -// C/C++ -#include <iostream> -#include <stdint.h> -#include <iomanip> - -Bool_t bCosy2018ResetPulser = kFALSE; -Bool_t bCosy2018WritePulser = kFALSE; - -CbmCosy2018MonitorPulser::CbmCosy2018MonitorPulser() : - CbmTSUnpack(), - fuOverlapMsNb(0), - fUnpackParHodo(NULL), - fuNrOfDpbs(0), - fDpbIdIndexMap(), - fuNbElinksPerDpb(0), - fuNbStsXyters(0), - fuNbChanPerAsic(0), - fvuElinkToAsic(), - fsHistoFileFullname( "data/SetupHistos.root" ), - fbPrintMessages( kFALSE ), - fPrintMessCtrl( stsxyter::MessagePrintMask::msg_print_Human ), - fulCurrentTsIdx( 0 ), - fulCurrentMsIdx( 0 ), - fmMsgCounter(), - fuCurrentEquipmentId(0), - fuCurrDpbId(0), - fuCurrDpbIdx(0), - fiRunStartDateTimeSec(-1), - fiBinSizeDatePlots(-1), - fvulCurrentTsMsb(), - fvuCurrentTsMsbCycle(), - fvuElinkLastTsHit(), - fvulChanLastHitTime(), - fvdChanLastHitTime(), - fvdMsTime(), - fvuChanNbHitsInMs(), - fvdChanLastHitTimeInMs(), - fvusChanLastHitAdcInMs(), -// fvmChanHitsInTs(), - fdStartTime(-1.0), - fdStartTimeMsSz(-1.0), - ftStartTimeUnix( std::chrono::steady_clock::now() ), - fvmHitsInTs(), - fvmAsicHitsInTs(), - fuMaxNbMicroslices(100), - fbLongHistoEnable( kFALSE ), - fuLongHistoNbSeconds( 0 ), - fuLongHistoBinSizeSec( 0 ), - fuLongHistoBinNb( 0 ), - fdCoincCenter( 0.0 ), - fdCoincBorder( 50.0 ), - fdCoincMin( fdCoincCenter - fdCoincBorder ), - fdCoincMax( fdCoincCenter + fdCoincBorder ), - fHM(new CbmHistManager()), - fhPulserMessType(NULL), - fhPulserSysMessType(NULL), - fhPulserMessTypePerDpb(NULL), - fhPulserSysMessTypePerDpb(NULL), - fhPulserMessTypePerElink(NULL), - fhPulserSysMessTypePerElink(NULL), - fhPulserChanCntRaw(), - fhPulserChanCntRawGood(), - fhPulserChanAdcRaw(), - fhPulserChanAdcRawProf(), - fhPulserChanRawTs(), - fhPulserChanMissEvt(), - fhPulserChanMissEvtEvo(), - fhPulserChanHitRateEvo(), - fhPulserFebRateEvo(), - fhPulserFebMissEvtEvo(), - fhPulserChanHitRateEvoLong(), - fhPulserFebRateEvoLong(), - fcMsSizeAll(NULL), - fdStartTs( 0.0 ), - fvmLastHitAsic(), - fhPulserTimeDiffPerAsic(), - fhPulserTimeDiffPerAsicPair(), - fhPulserTimeDiffEvoPerAsicPair(), - fhPulserTsLsbMatchPerAsicPair(), - fhPulserTsMsbMatchPerAsicPair(), - fhPulserIntervalAsic(), - fhPulserIntervalLongAsic() -{ -} - -CbmCosy2018MonitorPulser::~CbmCosy2018MonitorPulser() -{ -} - -Bool_t CbmCosy2018MonitorPulser::Init() -{ - LOG(info) << "Initializing flib StsXyter unpacker for STS"; - - FairRootManager* ioman = FairRootManager::Instance(); - if (ioman == NULL) { - LOG(fatal) << "No FairRootManager instance"; - } - - return kTRUE; -} - -void CbmCosy2018MonitorPulser::SetParContainers() -{ - LOG(info) << "Setting parameter containers for " << GetName(); - fUnpackParHodo = (CbmCern2017UnpackParHodo*)(FairRun::Instance()->GetRuntimeDb()->getContainer("CbmCern2017UnpackParHodo")); -} - - -Bool_t CbmCosy2018MonitorPulser::InitContainers() -{ - LOG(info) << "Init parameter containers for " << GetName(); - - Bool_t bReInit = ReInitContainers(); - CreateHistograms(); - - return bReInit; -} - -Bool_t CbmCosy2018MonitorPulser::ReInitContainers() -{ - LOG(info) << "ReInit parameter containers for " << GetName(); - - fuNrOfDpbs = fUnpackParHodo->GetNrOfDpbs(); - fuNbElinksPerDpb = fUnpackParHodo->GetNbElinksPerDpb(); - fuNbStsXyters = fUnpackParHodo->GetNbStsXyters(); - fuNbChanPerAsic = fUnpackParHodo->GetNbChanPerAsic(); - - - LOG(info) << "Nr. of STS DPBs: " << fuNrOfDpbs; - - fDpbIdIndexMap.clear(); - fvuElinkToAsic.resize( fuNrOfDpbs ); - for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - { - fDpbIdIndexMap[ fUnpackParHodo->GetDpbId( uDpb ) ] = uDpb; - LOG(info) << "Eq. ID for DPB #" << std::setw(2) << uDpb << " = " - << std::setw(4) << std::hex << fUnpackParHodo->GetDpbId( uDpb ) - << std::dec - << " => " << fDpbIdIndexMap[ fUnpackParHodo->GetDpbId( uDpb ) ]; - - fvuElinkToAsic[uDpb].resize( fuNbElinksPerDpb ); - for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink ) - fvuElinkToAsic[uDpb][uElink] = fUnpackParHodo->GetElinkToAsicIdx( uDpb * fuNbElinksPerDpb + uElink ); - } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - - LOG(info) << "Nr. eLinks per DPB: " << fuNbElinksPerDpb; - LOG(info) << "Nr. of StsXyter ASICs: " << fuNbStsXyters; - LOG(info) << "Nb. channels per ASIC: " << fuNbChanPerAsic; - - for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - { - LOG(info) << "ASIC ID for eLinks in DPB #" << std::setw(2) << uDpb << ": "; - - std::stringstream ss; - for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink ) - { - if( 0 == uElink % 10 ) - ss << "\n------> "; - - ss << std::setw( 5 ) << fvuElinkToAsic[uDpb][uElink] << " "; - } // for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink ) - LOG(info) << ss.str(); - } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - - // Internal status initialization - fvulCurrentTsMsb.resize( fuNrOfDpbs ); - fvuCurrentTsMsbCycle.resize( fuNrOfDpbs ); - fvuElinkLastTsHit.resize( fuNrOfDpbs ); - for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - { - fvulCurrentTsMsb[uDpb] = 0; - fvuCurrentTsMsbCycle[uDpb] = 0; -/* - fvuElinkLastTsHit[uDpb].resize( fuNbElinksPerDpb ); - for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink ) - { - fvuElinkLastTsHit[uDpb][uElink] = 0; - } // for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink ) -*/ - } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - - fvulChanLastHitTime.resize( fuNbStsXyters ); - fvdChanLastHitTime.resize( fuNbStsXyters ); - fvdMsTime.resize( fuMaxNbMicroslices ); - fvuChanNbHitsInMs.resize( fuNbStsXyters ); - fvdChanLastHitTimeInMs.resize( fuNbStsXyters ); - fvusChanLastHitAdcInMs.resize( fuNbStsXyters ); - fvmAsicHitsInTs.resize( fuNbStsXyters ); - fvmLastHitAsic.resize( fuNbStsXyters ); - fhPulserTimeDiffPerAsicPair.resize( fuNbStsXyters ); - fhPulserTimeDiffEvoPerAsicPair.resize( fuNbStsXyters ); - fhPulserTsLsbMatchPerAsicPair.resize( fuNbStsXyters ); - fhPulserTsMsbMatchPerAsicPair.resize( fuNbStsXyters ); - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fvulChanLastHitTime[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvdChanLastHitTime[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvuChanNbHitsInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvdChanLastHitTimeInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvusChanLastHitAdcInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvmAsicHitsInTs[ uXyterIdx ].clear(); - fhPulserTimeDiffPerAsicPair[ uXyterIdx ].clear(); - fhPulserTimeDiffEvoPerAsicPair[ uXyterIdx ].clear(); - fhPulserTsLsbMatchPerAsicPair[ uXyterIdx ].clear(); - fhPulserTsMsbMatchPerAsicPair[ uXyterIdx ].clear(); - for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - { - fvulChanLastHitTime[ uXyterIdx ][ uChan ] = 0; - fvdChanLastHitTime[ uXyterIdx ][ uChan ] = -1.0; - - fvuChanNbHitsInMs[ uXyterIdx ][ uChan ].resize( fuMaxNbMicroslices ); - fvdChanLastHitTimeInMs[ uXyterIdx ][ uChan ].resize( fuMaxNbMicroslices ); - fvusChanLastHitAdcInMs[ uXyterIdx ][ uChan ].resize( fuMaxNbMicroslices ); - for( UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx ) - { - fvuChanNbHitsInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = 0; - fvdChanLastHitTimeInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = -1.0; - fvusChanLastHitAdcInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = 0; - } // for( UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx ) - } // for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - LOG(info) << "CbmCosy2018MonitorPulser::ReInitContainers => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs.size() << " VS " << fuNbStsXyters; - LOG(info) << "CbmCosy2018MonitorPulser::ReInitContainers => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs[ 0 ].size() << " VS " << fuNbChanPerAsic; - LOG(info) << "CbmCosy2018MonitorPulser::ReInitContainers => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs[ 0 ][ 0 ].size() << " VS " << fuMaxNbMicroslices; - - return kTRUE; -} - -void CbmCosy2018MonitorPulser::SetCoincidenceBorder( Double_t dCenterPos, Double_t dBorderVal ) -{ - fdCoincCenter = dCenterPos; - fdCoincBorder = dBorderVal; - fdCoincMin = dCenterPos - dBorderVal; - fdCoincMax = dCenterPos + dBorderVal; -} - -void CbmCosy2018MonitorPulser::CreateHistograms() -{ - TString sHistName{""}; - TString title{""}; - - sHistName = "hPulserMessageType"; - title = "Nb of message for each type; Type"; - fhPulserMessType = new TH1I(sHistName, title, 5, 0., 5.); - fhPulserMessType->GetXaxis()->SetBinLabel( 1, "Dummy"); - fhPulserMessType->GetXaxis()->SetBinLabel( 2, "Hit"); - fhPulserMessType->GetXaxis()->SetBinLabel( 3, "TsMsb"); - fhPulserMessType->GetXaxis()->SetBinLabel( 4, "Epoch"); - fhPulserMessType->GetXaxis()->SetBinLabel( 5, "Empty"); -/* *** Missing int + MessType OP!!!! **** - fhPulserMessType->GetXaxis()->SetBinLabel(1 + stsxyter::MessType::Dummy, "Dummy"); - fhPulserMessType->GetXaxis()->SetBinLabel(1 + stsxyter::MessType::Hit, "Hit"); - fhPulserMessType->GetXaxis()->SetBinLabel(1 + stsxyter::MessType::TsMsb, "TsMsb"); - fhPulserMessType->GetXaxis()->SetBinLabel(1 + stsxyter::MessType::ReadDataAck, "ReadDataAck"); - fhPulserMessType->GetXaxis()->SetBinLabel(1 + stsxyter::MessType::Ack, "Ack"); -*/ - - sHistName = "hPulserSysMessType"; - title = "Nb of system message for each type; System Type"; - fhPulserSysMessType = new TH1I(sHistName, title, 17, 0., 17.); -/* - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_START, "DAQ START"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_FINISH, "DAQ FINISH"); - hSysMessType->GetXaxis()->SetBinLabel(1 + 16, "GET4 Hack 32B"); -*/ - - sHistName = "hPulserMessageTypePerDpb"; - title = "Nb of message of each type for each DPB; DPB; Type"; - fhPulserMessTypePerDpb = new TH2I(sHistName, title, fuNrOfDpbs, 0, fuNrOfDpbs, 5, 0., 5.); - fhPulserMessTypePerDpb->GetYaxis()->SetBinLabel( 1, "Dummy"); - fhPulserMessTypePerDpb->GetYaxis()->SetBinLabel( 2, "Hit"); - fhPulserMessTypePerDpb->GetYaxis()->SetBinLabel( 3, "TsMsb"); - fhPulserMessTypePerDpb->GetYaxis()->SetBinLabel( 4, "Epoch"); - fhPulserMessTypePerDpb->GetYaxis()->SetBinLabel( 5, "Empty"); -/* *** Missing int + MessType OP!!!! **** - fhPulserMessType->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Dummy, "Dummy"); - fhPulserMessType->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Hit, "Hit"); - fhPulserMessType->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::TsMsb, "TsMsb"); - fhPulserMessType->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::ReadDataAck, "ReadDataAck"); - fhPulserMessType->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Ack, "Ack"); -*/ - - sHistName = "hPulserSysMessTypePerDpb"; - title = "Nb of system message of each type for each DPB; DPB; System Type"; - fhPulserSysMessTypePerDpb = new TH2I(sHistName, title, fuNrOfDpbs, 0, fuNrOfDpbs, 17, 0., 17.); -/* - hSysMessType->GetYaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_START, "DAQ START"); - hSysMessType->GetYaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_FINISH, "DAQ FINISH"); - hSysMessType->GetYaxis()->SetBinLabel(1 + 16, "GET4 Hack 32B"); -*/ - - sHistName = "hPulserMessageTypePerElink"; - title = "Nb of message of each type for each eLink; eLink; Type"; - fhPulserMessTypePerElink = new TH2I(sHistName, title, fuNrOfDpbs * fuNbElinksPerDpb, 0, fuNrOfDpbs * fuNbElinksPerDpb, 5, 0., 5.); - fhPulserMessTypePerElink->GetYaxis()->SetBinLabel( 1, "Dummy"); - fhPulserMessTypePerElink->GetYaxis()->SetBinLabel( 2, "Hit"); - fhPulserMessTypePerElink->GetYaxis()->SetBinLabel( 3, "TsMsb"); - fhPulserMessTypePerElink->GetYaxis()->SetBinLabel( 4, "ReadDataAck"); - fhPulserMessTypePerElink->GetYaxis()->SetBinLabel( 5, "Ack"); -/* *** Missing int + MessType OP!!!! **** - fhPulserMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Dummy, "Dummy"); - fhPulserMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Hit, "Hit"); - fhPulserMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::TsMsb, "TsMsb"); - fhPulserMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::ReadDataAck, "ReadDataAck"); - fhPulserMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Ack, "Ack"); -*/ - - sHistName = "hPulserSysMessTypePerElink"; - title = "Nb of system message of each type for each eLink; eLink; System Type"; - fhPulserSysMessTypePerElink = new TH2I(sHistName, title, fuNrOfDpbs * fuNbElinksPerDpb, 0, fuNrOfDpbs * fuNbElinksPerDpb, 17, 0., 17.); -/* - fhPulserSysMessTypePerElink->GetYaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_START, "DAQ START"); - fhPulserSysMessTypePerElink->GetYaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_FINISH, "DAQ FINISH"); - fhPulserSysMessTypePerElink->GetYaxis()->SetBinLabel(1 + 16, "GET4 Hack 32B"); -*/ -/* - // Number of rate bins = - // 9 for the sub-unit decade - // + 9 for each unit of each decade * 10 for the subdecade range - // + 1 for the closing bin top edge - const Int_t iNbDecadesRate = 9; - const Int_t iNbStepsDecade = 9; - const Int_t iNbSubStepsInStep = 10; - const Int_t iNbBinsRate = iNbStepsDecade - + iNbStepsDecade * iNbSubStepsInStep * iNbDecadesRate - + 1; - Double_t dBinsRate[iNbBinsRate]; - // First fill sub-unit decade - for( Int_t iSubU = 0; iSubU < iNbStepsDecade; iSubU ++ ) - dBinsRate[ iSubU ] = 0.1 * ( 1 + iSubU ); - std::cout << std::endl; - // Then fill the main decades - Double_t dSubstepSize = 1.0 / iNbSubStepsInStep; - for( Int_t iDecade = 0; iDecade < iNbDecadesRate; iDecade ++) - { - Double_t dBase = std::pow( 10, iDecade ); - Int_t iDecadeIdx = iNbStepsDecade - + iDecade * iNbStepsDecade * iNbSubStepsInStep; - for( Int_t iStep = 0; iStep < iNbStepsDecade; iStep++ ) - { - Int_t iStepIdx = iDecadeIdx + iStep * iNbSubStepsInStep; - for( Int_t iSubStep = 0; iSubStep < iNbSubStepsInStep; iSubStep++ ) - { - dBinsRate[ iStepIdx + iSubStep ] = dBase * (1 + iStep) - + dBase * dSubstepSize * iSubStep; - } // for( Int_t iSubStep = 0; iSubStep < iNbSubStepsInStep; iSubStep++ ) - } // for( Int_t iStep = 0; iStep < iNbStepsDecade; iStep++ ) - } // for( Int_t iDecade = 0; iDecade < iNbDecadesRate; iDecade ++) - dBinsRate[ iNbBinsRate - 1 ] = std::pow( 10, iNbDecadesRate ); -*/ -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - UInt_t uAlignedLimit = fuLongHistoNbSeconds - (fuLongHistoNbSeconds % fuLongHistoBinSizeSec); - fuLongHistoBinNb = uAlignedLimit / fuLongHistoBinSizeSec; - - UInt_t uNbBinEvo = (32768 + 1) * 2; - Double_t dMaxEdgeEvo = stsxyter::kdClockCycleNs - * static_cast< Double_t >( uNbBinEvo ) / 2.0; - Double_t dMinEdgeEvo = dMaxEdgeEvo * -1.0; - -// UInt_t uNbBinDt = static_cast<UInt_t>( (fdCoincMax - fdCoincMin )/stsxyter::kdClockCycleNs ); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - // Channel counts - sHistName = Form( "hPulserChanCntRaw_%03u", uXyterIdx ); - title = Form( "Hits Count per channel, StsXyter #%03u; Channel; Hits []", uXyterIdx ); - fhPulserChanCntRaw.push_back( new TH1I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - - sHistName = Form( "hPulserChanCntRawGood_%03u", uXyterIdx ); - title = Form( "Hits Count per channel in good MS, StsXyter #%03u; Channel; Hits []", uXyterIdx ); - fhPulserChanCntRawGood.push_back( new TH1I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - - // Raw Adc Distribution - sHistName = Form( "hPulserChanAdcRaw_%03u", uXyterIdx ); - title = Form( "Raw Adc distribution per channel, StsXyter #%03u; Channel []; Adc []; Hits []", uXyterIdx ); - fhPulserChanAdcRaw.push_back( new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - stsxyter::kuHitNbAdcBins, -0.5, stsxyter::kuHitNbAdcBins -0.5 ) ); - - // Raw Adc Distribution profile - sHistName = Form( "hPulserChanAdcRawProfc_%03u", uXyterIdx ); - title = Form( "Raw Adc prodile per channel, StsXyter #%03u; Channel []; Adc []", uXyterIdx ); - fhPulserChanAdcRawProf.push_back( new TProfile(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - - // Raw Ts Distribution - sHistName = Form( "hPulserChanRawTs_%03u", uXyterIdx ); - title = Form( "Raw Timestamp distribution per channel, StsXyter #%03u; Channel []; Ts []; Hits []", uXyterIdx ); - fhPulserChanRawTs.push_back( new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - stsxyter::kuHitNbTsBins, -0.5, stsxyter::kuHitNbTsBins -0.5 ) ); - - // Missed event flag - sHistName = Form( "hPulserChanMissEvt_%03u", uXyterIdx ); - title = Form( "Missed Event flags per channel, StsXyter #%03u; Channel []; Miss Evt []; Hits []", uXyterIdx ); - fhPulserChanMissEvt.push_back( new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - 2, -0.5, 1.5 ) ); - - // Missed event flag counts evolution - - sHistName = Form( "hPulserChanMissEvtEvo_%03u", uXyterIdx ); - title = Form( "Missed Evt flags per second & channel in StsXyter #%03u; Time [s]; Channel []; Missed Evt flags []", uXyterIdx ); - fhPulserChanMissEvtEvo.push_back( new TH2I( sHistName, title, - 1800, 0, 1800, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - - // Missed event flag counts evo per StsXyter - - sHistName = Form( "hPulserFebMissEvtEvo%03u", uXyterIdx ); - title = Form( "Missed Evt flags per second in StsXyter #%03u; Time [s]; Missed Evt flags []", uXyterIdx ); - fhPulserFebMissEvtEvo.push_back( new TH1I(sHistName, title, 1800, 0, 1800 ) ); - - // Hit rates evo per channel - sHistName = Form( "hPulserChanRateEvo_%03u", uXyterIdx ); - title = Form( "Hits per second & channel in StsXyter #%03u; Time [s]; Channel []; Hits []", uXyterIdx ); - fhPulserChanHitRateEvo.push_back( new TH2I( sHistName, title, - 1800, 0, 1800, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - - // Hit rates evo per StsXyter - sHistName = Form( "hPulserFebRateEvo_%03u", uXyterIdx ); - title = Form( "Hits per second in StsXyter #%03u; Time [s]; Hits []", uXyterIdx ); - fhPulserFebRateEvo.push_back( new TH1I(sHistName, title, 1800, 0, 1800 ) ); - - // Hit rates evo per channel, 1 minute bins, 24h - sHistName = Form( "hPulserChanRateEvoLong_%03u", uXyterIdx ); - title = Form( "Hits per second & channel in StsXyter #%03u; Time [min]; Channel []; Hits []", uXyterIdx ); - fhPulserChanHitRateEvoLong.push_back( new TH2D( sHistName, title, - fuLongHistoBinNb, -0.5, uAlignedLimit - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - - // Hit rates evo per StsXyter, 1 minute bins, 24h - sHistName = Form( "hPulserFebRateEvoLong_%03u", uXyterIdx ); - title = Form( "Hits per second in StsXyter #%03u; Time [min]; Hits []", uXyterIdx ); - fhPulserFebRateEvoLong.push_back( new TH1D(sHistName, title, - fuLongHistoBinNb, -0.5, uAlignedLimit - 0.5 ) ); - - /// Coincidences inside each detector ----------------------------/// - sHistName = Form( "fhPulserTimeDiffPerAsic_%03u", uXyterIdx ); - title = Form( "Time diff for pulser hits between ASIC %03u and other ASICs; tn - t%03u [ns]; ASIC n; Counts", uXyterIdx, uXyterIdx ); - fhPulserTimeDiffPerAsic.push_back( new TH2I( sHistName, title, - uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo, - fuNbStsXyters, -0.5, fuNbStsXyters - 0.5 ) - ); - - for( UInt_t uXyterIdxB = 0; uXyterIdxB < fuNbStsXyters; ++uXyterIdxB ) - { - if( uXyterIdxB == uXyterIdx ) - { - sHistName = Form( "fhPulserTimeDiffSameAsic_%03u", uXyterIdx ); - title = Form( "Time diff for consecutive hits in ASIC %03u; tn - t [ns]; Counts", uXyterIdx ); - } // if( uXyterIdxB == uXyterIdx ) - else - { - sHistName = Form( "fhPulserTimeDiffPerAsicPair_%03u_%03u", uXyterIdx, uXyterIdxB ); - title = Form( "Time diff for pulser hits in ASIC %03u and %03u; tn - t [ns]; Counts", uXyterIdx, uXyterIdxB ); - } // else of if( uXyterIdxB == uXyterIdx ) - fhPulserTimeDiffPerAsicPair[ uXyterIdx ].push_back( new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ) ); - - if( uXyterIdxB == uXyterIdx ) - { - sHistName = Form( "fhPulserTimeDiffEvoSameAsic_%03u", uXyterIdx ); - title = Form( "Time diff for consecutive hits in ASIC %03u; Time in run [s]; tn - t [ns]; Counts", uXyterIdx ); - } // if( uXyterIdxB == uXyterIdx ) - else - { - sHistName = Form( "fhPulserTimeDiffEvoPerAsicPair_%03u_%03u", uXyterIdx, uXyterIdxB ); - title = Form( "Time diff for pulser hits in ASIC %03u and %03u; Time in run [s]; tn - t [ns]; Counts", uXyterIdx, uXyterIdxB ); - } // else of if( uXyterIdxB == uXyterIdx ) - fhPulserTimeDiffEvoPerAsicPair[ uXyterIdx ].push_back( new TH2I(sHistName, title, - 3600, 0, 18000, - 200, -100 * stsxyter::kdClockCycleNs, 100 * stsxyter::kdClockCycleNs ) ); - - sHistName = Form( "fhPulserTsLsbMatchPerAsicPair_%03u_%03u", uXyterIdx, uXyterIdxB ); - title = Form( "TS LSB for pulser hits in ASIC %03u and %03u; TS LSB %03u [bin]; TS LSB %03u [bin]", - uXyterIdx, uXyterIdxB, uXyterIdx, uXyterIdxB ); - fhPulserTsLsbMatchPerAsicPair[ uXyterIdx ].push_back( new TH2I(sHistName, title, 256, -0.5, 255.5, 256, -0.5, 255.5 ) ); - - sHistName = Form( "fhPulserTsMsbMatchPerAsicPair_%03u_%03u", uXyterIdx, uXyterIdxB ); - title = Form( "TS MSB for pulser hits in ASIC %03u and %03u; TS MSB %03u [bin]; TS MSB %03u [bin]", - uXyterIdx, uXyterIdxB, uXyterIdx, uXyterIdxB ); - fhPulserTsMsbMatchPerAsicPair[ uXyterIdx ].push_back( new TH2I(sHistName, title, 64, -0.5, 63.5, 64, -0.5, 63.5 ) ); - } // for( UInt_t uXyterIdxB = 0; uXyterIdxB < fuNbStsXyters; ++uXyterIdxB ) - - sHistName = Form( "fhPulserIntervalAsic_%03u", uXyterIdx ); - title = Form( "Time diff between consecutive hits in ASIC %03us; dt [ns]; Counts", uXyterIdx ); - fhPulserIntervalAsic.push_back( new TH1I( sHistName, title, 200, 0, 200 * stsxyter::kdClockCycleNs ) ); - - sHistName = Form( "fhPulserIntervalLongAsic_%03u", uXyterIdx ); - title = Form( "Time diff between consecutive hits in ASIC %03us; dt [ns]; Counts", uXyterIdx ); - fhPulserIntervalLongAsic.push_back( new TH1I( sHistName, title, 1e5, 0, 1e6 * stsxyter::kdClockCycleNs ) ); - -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - - -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - -/* - // Distribution of the TS_MSB per StsXyter - sHistName = "hPulserFebTsMsb"; - title = "Raw Timestamp Msb distribution per StsXyter; Ts MSB []; StsXyter []; Hits []"; - fhPulserFebTsMsb = new TH2I( sHistName, title, stsxyter::kuTsMsbNbTsBins, -0.5, stsxyter::kuTsMsbNbTsBins - 0.5, - fuNbStsXyters, -0.5, fuNbStsXyters - 0.5 ); - if( server ) server->Register("/StsRaw", fhPulserFebTsMsb ); -*/ - // Miscroslice properties histos - for( Int_t component = 0; component < kiMaxNbFlibLinks; component ++ ) - { - fhMsSz[ component ] = NULL; - fhMsSzTime[ component ] = NULL; - } // for( Int_t component = 0; component < kiMaxNbFlibLinks; component ++ ) - - // Online histo browser commands - THttpServer* server = FairRunOnline::Instance()->GetHttpServer(); - if( server ) - { - server->Register("/StsRaw", fhPulserMessType ); - server->Register("/StsRaw", fhPulserSysMessType ); - server->Register("/StsRaw", fhPulserMessTypePerDpb ); - server->Register("/StsRaw", fhPulserSysMessTypePerDpb ); - server->Register("/StsRaw", fhPulserMessTypePerElink ); - server->Register("/StsRaw", fhPulserSysMessTypePerElink ); - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - server->Register("/StsRaw", fhPulserChanCntRaw[ uXyterIdx ] ); - server->Register("/StsRaw", fhPulserChanCntRawGood[ uXyterIdx ] ); - server->Register("/StsRaw", fhPulserChanAdcRaw[ uXyterIdx ] ); - server->Register("/StsRaw", fhPulserChanAdcRawProf[ uXyterIdx ] ); - server->Register("/StsRaw", fhPulserChanRawTs[ uXyterIdx ] ); - server->Register("/StsRaw", fhPulserChanMissEvt[ uXyterIdx ] ); - server->Register("/StsRaw", fhPulserChanMissEvtEvo[ uXyterIdx ] ); - server->Register("/StsRaw", fhPulserFebMissEvtEvo[ uXyterIdx ] ); - server->Register("/StsRaw", fhPulserChanHitRateEvo[ uXyterIdx ] ); - server->Register("/StsRaw", fhPulserFebRateEvo[ uXyterIdx ] ); - server->Register("/StsRaw", fhPulserChanHitRateEvoLong[ uXyterIdx ] ); - server->Register("/StsRaw", fhPulserFebRateEvoLong[ uXyterIdx ] ); - - server->Register("/DtAsic", fhPulserTimeDiffPerAsic[ uXyterIdx ] ); - for( UInt_t uXyterIdxB = 0; uXyterIdxB < fuNbStsXyters; ++uXyterIdxB ) - { - if( uXyterIdxB == uXyterIdx ) - { - server->Register("/DtChan", fhPulserTimeDiffPerAsicPair[ uXyterIdx ][uXyterIdxB] ); - server->Register("/DtChan", fhPulserTimeDiffEvoPerAsicPair[ uXyterIdx ][uXyterIdxB] ); - } // if( uXyterIdxB == uXyterIdx ) - else - { - server->Register("/DtAsicPair", fhPulserTimeDiffPerAsicPair[ uXyterIdx ][uXyterIdxB] ); - server->Register("/DtAsicPair", fhPulserTimeDiffEvoPerAsicPair[ uXyterIdx ][uXyterIdxB] ); - } // else of if( uXyterIdxB == uXyterIdx ) - server->Register("/TsMatch", fhPulserTsLsbMatchPerAsicPair[ uXyterIdx ][uXyterIdxB] ); - server->Register("/TsMatch", fhPulserTsMsbMatchPerAsicPair[ uXyterIdx ][uXyterIdxB] ); - } // for( UInt_t uXyterIdxB = 0; uXyterIdxB < fuNbStsXyters; ++uXyterIdxB ) - server->Register("/DtPulses", fhPulserIntervalAsic[ uXyterIdx ] ); - server->Register("/DtPulses", fhPulserIntervalLongAsic[ uXyterIdx ] ); - - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - - server->RegisterCommand("/Reset_All_Pulser", "bCosy2018ResetPulser=kTRUE"); - server->RegisterCommand("/Write_All_Pulser", "bCosy2018WritePulser=kTRUE"); - - server->Restrict("/Reset_All_Pulser", "allow=admin"); - server->Restrict("/Write_All_Pulser", "allow=admin"); - } // if( server ) - - /** Create summary Canvases for CERN 2017 **/ - Double_t w = 10; - Double_t h = 10; - - // Summary per StsXyter - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - TCanvas* cStsSumm = new TCanvas( Form("cStsSum_%03u", uXyterIdx ), - Form("Summary plots for StsXyter %03u", uXyterIdx ), - w, h); - cStsSumm->Divide( 2, 2 ); - - cStsSumm->cd(1); - gPad->SetLogy(); - fhPulserChanCntRaw[ uXyterIdx ]->Draw(); - - cStsSumm->cd(2); - gPad->SetLogz(); - fhPulserChanAdcRaw[ uXyterIdx ]->Draw( "colz" ); - - cStsSumm->cd(3); - gPad->SetLogz(); - fhPulserChanHitRateEvo[ uXyterIdx ]->Draw( "colz" ); - - cStsSumm->cd(4); -// gPad->SetLogy(); - fhPulserChanAdcRawProf[ uXyterIdx ]->Draw(); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - -//====================================================================// - -//====================================================================// - TCanvas* cDtPerAsic = new TCanvas( "cDtPerAsic", - "Time Differences per ASIC", - w, h); - cDtPerAsic->Divide( fuNbStsXyters / 2 + fuNbStsXyters % 2, 2 ); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - cDtPerAsic->cd(1 + uXyterIdx); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhPulserTimeDiffPerAsic[ uXyterIdx ]->Draw( " colz" ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) -//====================================================================// - -//====================================================================// - TCanvas* cDtInAsic = new TCanvas( "cDtInAsic", - "Time Differences in ASIC", - w, h); - cDtInAsic->Divide( fuNbStsXyters / 2 + fuNbStsXyters % 2, 2 ); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - cDtInAsic->cd(1 + uXyterIdx); - gPad->SetGridx(); - gPad->SetLogy(); - fhPulserTimeDiffPerAsicPair[ uXyterIdx ][ uXyterIdx ]->Draw( "hist" ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) -//====================================================================// - -//====================================================================// - TCanvas* cDtAsicPairs = new TCanvas( "cDtAsicPairs", - "Time Differences in ASIC", - w, h); -// cDtAsicPairs->Divide( fuNbStsXyters / 3, 3 ); - cDtAsicPairs->Divide( 3 ); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters && uXyterIdx < 3; ++uXyterIdx ) - { - for( UInt_t uXyterIdxB = uXyterIdx + 1; uXyterIdxB < fuNbStsXyters; ++uXyterIdxB ) - { - cDtAsicPairs->cd( uXyterIdx + uXyterIdxB ); - gPad->SetGridx(); - gPad->SetLogy(); - fhPulserTimeDiffPerAsicPair[ uXyterIdx ][uXyterIdxB]->Draw( "hist" ); - } // for( UInt_t uXyterIdxB = 0; uXyterIdxB < fuNbStsXyters; ++uXyterIdxB ) - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) -//====================================================================// - -//====================================================================// - TCanvas* cTsLsbAsicPairs = new TCanvas( "cTsLsbAsicPairs", - "Time Differences in ASIC", - w, h); -// cDtAsicPairs->Divide( fuNbStsXyters / 3, 3 ); - cTsLsbAsicPairs->Divide( 3 ); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters && uXyterIdx < 3; ++uXyterIdx ) - { - for( UInt_t uXyterIdxB = uXyterIdx + 1; uXyterIdxB < fuNbStsXyters; ++uXyterIdxB ) - { - cTsLsbAsicPairs->cd( uXyterIdx + uXyterIdxB ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhPulserTsLsbMatchPerAsicPair[ uXyterIdx ][uXyterIdxB]->Draw( "colz" ); - } // for( UInt_t uXyterIdxB = 0; uXyterIdxB < fuNbStsXyters; ++uXyterIdxB ) - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) -//====================================================================// - -//====================================================================// - TCanvas* cTsMsbAsicPairs = new TCanvas( "cTsMsbAsicPairs", - "Time Differences in ASIC", - w, h); -// cDtAsicPairs->Divide( fuNbStsXyters / 3, 3 ); - cTsMsbAsicPairs->Divide( 3 ); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters && uXyterIdx < 3; ++uXyterIdx ) - { - for( UInt_t uXyterIdxB = uXyterIdx + 1; uXyterIdxB < fuNbStsXyters; ++uXyterIdxB ) - { - cTsMsbAsicPairs->cd( uXyterIdx + uXyterIdxB ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhPulserTsMsbMatchPerAsicPair[ uXyterIdx ][uXyterIdxB]->Draw( "colz" ); - } // for( UInt_t uXyterIdxB = 0; uXyterIdxB < fuNbStsXyters; ++uXyterIdxB ) - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) -//====================================================================// - -//====================================================================// - /** Recovers/Create Ms Size Canvase for CERN 2016 **/ - // Try to recover canvas in case it was created already by another monitor - // If not existing, create it - fcMsSizeAll = dynamic_cast<TCanvas *>( gROOT->FindObject( "cMsSizeAll" ) ); - if( NULL == fcMsSizeAll ) - { - fcMsSizeAll = new TCanvas("cMsSizeAll", "Evolution of MS size in last 300 s", w, h); - fcMsSizeAll->Divide( 4, 4 ); - LOG(info) << "Created MS size canvas in STS monitor"; - } // if( NULL == fcMsSizeAll ) - else LOG(info) << "Recovered MS size canvas in STS monitor"; -//====================================================================// - - /*****************************/ -} - -Bool_t CbmCosy2018MonitorPulser::DoUnpack(const fles::Timeslice& ts, size_t component) -{ - THttpServer* server = FairRunOnline::Instance()->GetHttpServer(); - - if( bCosy2018ResetPulser ) - { - ResetAllHistos(); - bCosy2018ResetPulser = kFALSE; - } // if( bCosy2018ResetPulser ) - if( bCosy2018WritePulser ) - { - SaveAllHistos( fsHistoFileFullname ); - bCosy2018WritePulser = kFALSE; - } // if( bCosy2018WritePulser ) - - LOG(debug) << "Timeslice contains " << ts.num_microslices(component) - << "microslices."; - - if( component < kiMaxNbFlibLinks ) - if( NULL == fhMsSz[ component ] ) - { - TString sMsSzName = Form("MsSz_link_%02lu", component); - TString sMsSzTitle = Form("Size of MS for nDPB of link %02lu; Ms Size [bytes]", component); - fhMsSz[ component ] = new TH1F( sMsSzName.Data(), sMsSzTitle.Data(), 160000, 0., 20000. ); - fHM->Add(sMsSzName.Data(), fhMsSz[ component ] ); - if (server) server->Register("/FlibRaw", fhMsSz[ component ] ); - sMsSzName = Form("MsSzTime_link_%02lu", component); - sMsSzTitle = Form("Size of MS vs time for gDPB of link %02lu; Time[s] ; Ms Size [bytes]", component); - fhMsSzTime[ component ] = new TProfile( sMsSzName.Data(), sMsSzTitle.Data(), 15000, 0., 300. ); - fHM->Add( sMsSzName.Data(), fhMsSzTime[ component ] ); - if (server) server->Register("/FlibRaw", fhMsSzTime[ component ] ); - if( NULL != fcMsSizeAll ) - { - fcMsSizeAll->cd( 1 + component ); - gPad->SetLogy(); - fhMsSzTime[ component ]->Draw("hist le0"); - } // if( NULL != fcMsSizeAll ) - LOG(info) << "Added MS size histo for component: " << component - << " (DPB)"; - } // if( NULL == fhMsSz[ component ] ) - -// Int_t messageType = -111; - // Loop over microslices - size_t numCompMsInTs = ts.num_microslices(component); -/* - if( fulCurrentTsIdx + 1 != ts.index() && 0 == component) - LOG(info) << "Missed TS from " << fulCurrentTsIdx - << " to " << ts.index(); -*/ - fulCurrentTsIdx = ts.index(); - - if( fuMaxNbMicroslices < numCompMsInTs ) - { - fuMaxNbMicroslices = numCompMsInTs; - - fvdMsTime.resize( fuMaxNbMicroslices ); - fvuChanNbHitsInMs.resize( fuNbStsXyters ); - fvdChanLastHitTimeInMs.resize( fuNbStsXyters ); - fvusChanLastHitAdcInMs.resize( fuNbStsXyters ); - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fvuChanNbHitsInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvdChanLastHitTimeInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvusChanLastHitAdcInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - { - fvuChanNbHitsInMs[ uXyterIdx ][ uChan ].resize( fuMaxNbMicroslices ); - fvdChanLastHitTimeInMs[ uXyterIdx ][ uChan ].resize( fuMaxNbMicroslices ); - fvusChanLastHitAdcInMs[ uXyterIdx ][ uChan ].resize( fuMaxNbMicroslices ); - for( UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx ) - { - fvuChanNbHitsInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = 0; - fvdChanLastHitTimeInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = -1.0; - fvusChanLastHitAdcInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = 0; - } // for( UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx ) - } // for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - LOG(info) << "CbmCosy2018MonitorPulser::DoUnpack => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs.size() << " VS " << fuNbStsXyters; - LOG(info) << "CbmCosy2018MonitorPulser::DoUnpack => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs[ 0 ].size() << " VS " << fuNbChanPerAsic; - LOG(info) << "CbmCosy2018MonitorPulser::DoUnpack => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs[ 0 ][ 0 ].size() << " VS " << fuMaxNbMicroslices; - } // if( fuMaxNbMicroslices < numCompMsInTs ) - - for( size_t m = 0; m < numCompMsInTs; ++m ) - { - // Ignore overlap ms if number defined by user - if( numCompMsInTs - fuOverlapMsNb <= m ) - continue; - - auto msDescriptor = ts.descriptor(component, m); - fuCurrentEquipmentId = msDescriptor.eq_id; - const uint8_t* msContent = reinterpret_cast<const uint8_t*>(ts.content(component, m)); - - uint32_t size = msDescriptor.size; - fulCurrentMsIdx = msDescriptor.idx; - Double_t dMsTime = (1e-9) * static_cast<double>(fulCurrentMsIdx); - LOG(debug) << "Microslice: " << fulCurrentMsIdx - << " from EqId " << std::hex << fuCurrentEquipmentId << std::dec - << " has size: " << size; - - fuCurrDpbId = static_cast< uint32_t >( fuCurrentEquipmentId & 0xFFFF ); - fuCurrDpbIdx = fDpbIdIndexMap[ fuCurrDpbId ]; - - if( component < kiMaxNbFlibLinks ) - { - if( fdStartTimeMsSz < 0 ) - fdStartTimeMsSz = dMsTime; - fhMsSz[ component ]->Fill( size ); - fhMsSzTime[ component ]->Fill( dMsTime - fdStartTimeMsSz, size); - } // if( component < kiMaxNbFlibLinks ) - - // Store MS time for coincidence plots - fvdMsTime[ m ] = dMsTime; - - // If not integer number of message in input buffer, print warning/error - if( 0 != (size % kuBytesPerMessage) ) - LOG(error) << "The input microslice buffer does NOT " - << "contain only complete nDPB messages!"; - - // Compute the number of complete messages in the input microslice buffer - uint32_t uNbMessages = (size - (size % kuBytesPerMessage) ) - / kuBytesPerMessage; - - // Prepare variables for the loop on contents - const uint32_t* pInBuff = reinterpret_cast<const uint32_t*>( msContent ); - - for( uint32_t uIdx = 0; uIdx < uNbMessages; ++uIdx ) - { - // Fill message - uint32_t ulData = static_cast<uint32_t>(pInBuff[uIdx]); - - stsxyter::Message mess( static_cast< uint32_t >( ulData & 0xFFFFFFFF ) ); - - // Print message if requested - if( fbPrintMessages ) - mess.PrintMess( std::cout, fPrintMessCtrl ); - - stsxyter::MessType typeMess = mess.GetMessType(); - fmMsgCounter[ typeMess ] ++; - fhPulserMessType->Fill( static_cast< uint16_t > (typeMess) ); - fhPulserMessTypePerDpb->Fill( fuCurrDpbIdx, static_cast< uint16_t > (typeMess) ); - - switch( typeMess ) - { - case stsxyter::MessType::Hit : - { - // Extract the eLink and Asic indices => Should GO IN the fill method now that obly hits are link/asic specific! - UShort_t usElinkIdx = mess.GetLinkIndex(); - if( fuNbElinksPerDpb <= usElinkIdx ) - { - LOG(fatal) << "CbmCosy2018MonitorPulser::DoUnpack => " - << "eLink index out of bounds!" - << usElinkIdx << " VS " << fuNbElinksPerDpb; - } // if( fuNbElinksPerDpb <= usElinkIdx ) - fhPulserMessTypePerElink->Fill( fuCurrDpbIdx * fuNbElinksPerDpb + usElinkIdx, - static_cast< uint16_t > (typeMess) ); - - UInt_t uAsicIdx = fvuElinkToAsic[fuCurrDpbIdx][usElinkIdx]; - - FillHitInfo( mess, usElinkIdx, uAsicIdx, m ); - break; - } // case stsxyter::MessType::Hit : - case stsxyter::MessType::TsMsb : - { - FillTsMsbInfo( mess, uIdx, m ); - break; - } // case stsxyter::MessType::TsMsb : - case stsxyter::MessType::Epoch : - { - // The first message in the TS is a special ones: EPOCH - FillEpochInfo( mess ); - - if( 0 < uIdx ) - LOG(info) << "CbmCosy2018MonitorPulser::DoUnpack => " - << "EPOCH message at unexpected position in MS: message " - << uIdx << " VS message 0 expected!"; - break; - } // case stsxyter::MessType::TsMsb : - case stsxyter::MessType::Empty : - { -// FillTsMsbInfo( mess ); - break; - } // case stsxyter::MessType::Empty : - case stsxyter::MessType::Dummy : - { - break; - } // case stsxyter::MessType::Dummy / ReadDataAck / Ack : - default: - { - LOG(fatal) << "CbmCosy2018MonitorPulser::DoUnpack => " - << "Unknown message type, should never happen, stopping here!"; - } - } // switch( mess.GetMessType() ) - } // for( uint32_t uIdx = 0; uIdx < uNbMessages; ++uIdx ) - } // for( size_t m = 0; m < numCompMsInTs; ++m ) - - // End of TS, check if stuff to do with the hits inside each MS - // Usefull for low rate pulser tests - // Need to do it only when last DPB is processed, as they are done one by one - if( fuCurrDpbIdx == fuNrOfDpbs - 1 ) - { - /// Pulses time difference calculation and plotting - // Sort the buffer of hits - std::sort( fvmHitsInTs.begin(), fvmHitsInTs.end() ); - - // Time differences plotting using the fully time sorted hits - if( 0 < fvmHitsInTs.size() ) - { -// ULong64_t ulLastHitTime = ( *( fvmHitsInTs.rbegin() ) ).GetTs(); - std::vector< stsxyter::FinalHit >::iterator it; - std::vector< stsxyter::FinalHit >::iterator itB; - -// std::chrono::steady_clock::time_point tNow = std::chrono::steady_clock::now(); -// Double_t dUnixTimeInRun = std::chrono::duration_cast< std::chrono::seconds >(tNow - ftStartTimeUnix).count(); - - for( it = fvmHitsInTs.begin(); - it != fvmHitsInTs.end(); -// it != fvmHitsInTs.end() && (*it).GetTs() < ulLastHitTime - 320; // 320 * 3.125 ns = 1000 ns - ++it ) - { - UShort_t usAsicIdx = (*it).GetAsic(); -// UShort_t usChanIdx = (*it).GetChan(); -// ULong64_t ulHitTs = (*it).GetTs(); -// UShort_t usHitAdc = (*it).GetAdc(); - -// Double_t dTimeSinceStartSec = (ulHitTs * stsxyter::kdClockCycleNs - fdStartTime)* 1e-9; - - fvmAsicHitsInTs[ usAsicIdx ].push_back( (*it) ); - } // loop on time sorted hits and split per asic - - // Remove all hits which were already used - fvmHitsInTs.erase( fvmHitsInTs.begin(), it ); - - for( UInt_t uAsic = 0; uAsic < fuNbStsXyters; uAsic++) - { - for( it = fvmAsicHitsInTs[ uAsic ].begin(); it != fvmAsicHitsInTs[ uAsic ].end(); ++it ) - { -// UShort_t usChanIdx = (*it).GetChan(); - if( 0.0 == fdStartTs ) - fdStartTs = (*it).GetTs() * stsxyter::kdClockCycleNs; - Double_t dTimeSinceStartSec = ( (*it).GetTs() * stsxyter::kdClockCycleNs - fdStartTs ) * 1e-9; - - for( UInt_t uAsicB = uAsic; uAsicB < fuNbStsXyters; uAsicB++) - { - for( itB = fvmAsicHitsInTs[ uAsicB ].begin(); itB != fvmAsicHitsInTs[ uAsicB ].end(); ++itB ) - { -// UShort_t usChanIdxB = (*itB).GetChan(); - Double_t dDt = ( static_cast< Double_t >( (*itB).GetTs() ) - static_cast< Double_t >( (*it).GetTs() ) - ) * stsxyter::kdClockCycleNs; - - fhPulserTimeDiffPerAsic[ uAsic ]->Fill( dDt, uAsicB ); - fhPulserTimeDiffPerAsicPair[ uAsic ][ uAsicB ]->Fill( dDt ); - fhPulserTimeDiffEvoPerAsicPair[ uAsic ][ uAsicB ]->Fill( dTimeSinceStartSec, dDt ); - - fhPulserTsLsbMatchPerAsicPair[ uAsic ][ uAsicB ]->Fill( (*it ).GetTs() & 0x000FF, - (*itB).GetTs() & 0x000FF ); - fhPulserTsMsbMatchPerAsicPair[ uAsic ][ uAsicB ]->Fill( ( (*it ).GetTs() & 0x03F00 ) >> 8, - ( (*itB).GetTs() & 0x03F00 ) >> 8 ); - } // for( it = fvmAsicHitsInTs[ uAsicB ].begin(); it != fvmAsicHitsInTs[ uAsicB ].end(); ++it ) - } // for( UInt_t uAsic = 0; uAsic < fuNbStsXyters; uAsic++) - - Double_t dDtPulse = ( static_cast< Double_t >( (*it).GetTs() ) - static_cast< Double_t >( fvmLastHitAsic[ uAsic ].GetTs() ) - ) * stsxyter::kdClockCycleNs; - fhPulserIntervalAsic[ uAsic ]->Fill( dDtPulse ); - fhPulserIntervalLongAsic[ uAsic ]->Fill( dDtPulse ); - fvmLastHitAsic[ uAsic ] = (*it); - } // for( it = fvmAsicHitsInTs[ uAsic ].begin(); it != fvmAsicHitsInTs[ uAsic ].end(); ++it ) - - /// Data in vector are not needed anymore as all possible matches are already checked - fvmAsicHitsInTs[ uAsic ].clear(); - } // for( UInt_t uAsic = 0; uAsic < fuNbStsXyters; uAsic++) - } // if( 0 < fvmHitsInTs.size() ) - - for( UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx ) - { - fvdMsTime[ uMsIdx ] = 0.0; - } // for( UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx ) - } // if( fuCurrDpbIdx == fuNrOfDpbs - 1 ) - - if( 0 == ts.index() % 1000 && fuCurrDpbIdx == fuNrOfDpbs - 1 ) - { - for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - { - Double_t dTsMsbTime = - static_cast<ULong64_t>( stsxyter::kuHitNbTsBins ) - * static_cast<ULong64_t>( fvulCurrentTsMsb[fuCurrDpbIdx]) - + static_cast<ULong64_t>( stsxyter::kulTsCycleNbBins ) - * static_cast<ULong64_t>( fvuCurrentTsMsbCycle[fuCurrDpbIdx] ); - dTsMsbTime *= stsxyter::kdClockCycleNs * 1e-9; - - LOG(info) << "End of TS " << std::setw(7) << ts.index() - << " eDPB " << std::setw(2) << uDpb - << " current TS MSB counter is " << std::setw(12) << fvulCurrentTsMsb[uDpb] - << " current TS MSB cycle counter is " << std::setw(12) << fvuCurrentTsMsbCycle[uDpb] - << " current TS MSB time is " << std::setw(12) << dTsMsbTime << " s"; - } - } // if( 0 == ts.index() % 1000 && fuCurrDpbIdx == fuNrOfDpbs - 1 ) - - return kTRUE; -} - -void CbmCosy2018MonitorPulser::FillHitInfo( stsxyter::Message mess, const UShort_t & /*usElinkIdx*/, const UInt_t & uAsicIdx, const UInt_t & uMsIdx ) -{ - UShort_t usChan = mess.GetHitChannel(); - UShort_t usRawAdc = mess.GetHitAdc(); -// UShort_t usFullTs = mess.GetHitTimeFull(); -// UShort_t usTsOver = mess.GetHitTimeOver(); - UShort_t usRawTs = mess.GetHitTime(); - - fhPulserChanCntRaw[ uAsicIdx ]->Fill( usChan ); - fhPulserChanAdcRaw[ uAsicIdx ]->Fill( usChan, usRawAdc ); - fhPulserChanAdcRawProf[ uAsicIdx ]->Fill( usChan, usRawAdc ); - fhPulserChanRawTs[ uAsicIdx ]->Fill( usChan, usRawTs ); - fhPulserChanMissEvt[ uAsicIdx ]->Fill( usChan, mess.IsHitMissedEvts() ); - - // Compute the Full time stamp -// Long64_t ulOldHitTime = fvulChanLastHitTime[ uAsicIdx ][ usChan ]; -// Double_t dOldHitTime = fvdChanLastHitTime[ uAsicIdx ][ usChan ]; - - // Use TS w/o overlap bits as they will anyway come from the TS_MSB - fvulChanLastHitTime[ uAsicIdx ][ usChan ] = usRawTs; - - fvulChanLastHitTime[ uAsicIdx ][ usChan ] += - static_cast<ULong64_t>( stsxyter::kuHitNbTsBins ) - * static_cast<ULong64_t>( fvulCurrentTsMsb[fuCurrDpbIdx]) - + static_cast<ULong64_t>( stsxyter::kulTsCycleNbBins ) - * static_cast<ULong64_t>( fvuCurrentTsMsbCycle[fuCurrDpbIdx] ) - ; - -// fvuElinkLastTsHit[fuCurrDpbIdx] = usRawTs; - - // Convert the Hit time in bins to Hit time in ns - Double_t dHitTimeNs = fvulChanLastHitTime[ uAsicIdx ][ usChan ] * stsxyter::kdClockCycleNs; -/* - // If needed fill the hit interval plots - if( fbChanHitDtEna ) - { - Double_t dDeltaT = dHitTimeNs - fvdChanLastHitTime[ uAsicIdx ][ usChan ]; - if( 0 == dDeltaT ) - fhStsChanHitDtNeg[ uAsicIdx ]->Fill( 1, usChan ); - else if( 0 < dDeltaT ) - fhStsChanHitDt[ uAsicIdx ]->Fill( dDeltaT, usChan ); - else fhStsChanHitDtNeg[ uAsicIdx ]->Fill( -dDeltaT, usChan ); - } // if( fbChanHitDtEna ) -*/ - // Store new value of Hit time in ns - fvdChanLastHitTime[ uAsicIdx ][ usChan ] = fvulChanLastHitTime[ uAsicIdx ][ usChan ] * stsxyter::kdClockCycleNs; -/* - LOG(info) << " Asic " << std::setw( 2 ) << uAsicIdx - << " Channel " << std::setw( 3 ) << usChan - << " Diff to last hit " << std::setw( 12 ) << ( fvulChanLastHitTime[ uAsicIdx ][ usChan ] - ulOldHitTime) - << " in s " << std::setw( 12 ) << ( fvdChanLastHitTime[ uAsicIdx ][ usChan ] - dOldHitTime) * 1e-9; -*/ - // Pulser and MS - fvuChanNbHitsInMs[ uAsicIdx ][ usChan ][ uMsIdx ] ++; - fvdChanLastHitTimeInMs[ uAsicIdx ][ usChan ][ uMsIdx ] = dHitTimeNs; - fvusChanLastHitAdcInMs[ uAsicIdx ][ usChan ][ uMsIdx ] = usRawAdc; -/* - fvmChanHitsInTs[ uAsicIdx ][ usChan ].insert( stsxyter::FinalHit( fvulChanLastHitTime[ uAsicIdx ][ usChan ], - usRawAdc, uAsicIdx, usChan ) ); -*/ - fvmHitsInTs.push_back( stsxyter::FinalHit( fvulChanLastHitTime[ uAsicIdx ][ usChan ], usRawAdc, uAsicIdx, usChan ) ); - -/* - LOG(info) << " TS " << std::setw( 12 ) << fulCurrentTsIdx - << " MS " << std::setw( 12 ) << fulCurrentMsIdx - << " MsInTs " << std::setw( 3 ) << uMsIdx - << " Asic " << std::setw( 2 ) << uAsicIdx - << " Channel " << std::setw( 3 ) << usChan - << " ADC " << std::setw( 3 ) << usRawAdc - << " TS " << std::setw( 3 ) << usRawTs // 9 bits TS - << " SX TsMsb " << std::setw( 2 ) << ( fvulCurrentTsMsb[fuCurrDpbIdx] & 0x1F ) // Total StsXyter TS = 14 bits => 9b Hit TS + lower 5b TS_MSB after DPB - << " DPB TsMsb " << std::setw( 6 ) << ( fvulCurrentTsMsb[fuCurrDpbIdx] >> 5 ) // Total StsXyter TS = 14 bits => 9b Hit TS + lower 5b of TS_MSB after DPB - << " TsMsb " << std::setw( 7 ) << fvulCurrentTsMsb[fuCurrDpbIdx] - << " MsbCy " << std::setw( 4 ) << fvuCurrentTsMsbCycle[fuCurrDpbIdx] - << " Time " << std::setw ( 12 ) << fvulChanLastHitTime[ uAsicIdx ][ usChan ]; -*/ - // Check Starting point of histos with time as X axis - if( -1 == fdStartTime ) - fdStartTime = fvdChanLastHitTime[ uAsicIdx ][ usChan ]; - - // Fill histos with time as X axis - Double_t dTimeSinceStartSec = (fvdChanLastHitTime[ uAsicIdx ][ usChan ] - fdStartTime)* 1e-9; - Double_t dTimeSinceStartMin = dTimeSinceStartSec / 60.0; - fhPulserChanHitRateEvo[ uAsicIdx ]->Fill( dTimeSinceStartSec , usChan ); - fhPulserFebRateEvo[ uAsicIdx ]->Fill( dTimeSinceStartSec ); - fhPulserChanHitRateEvoLong[ uAsicIdx ]->Fill( dTimeSinceStartMin, usChan, 1.0/60.0 ); - fhPulserFebRateEvoLong[ uAsicIdx ]->Fill( dTimeSinceStartMin, 1.0/60.0 ); - if( mess.IsHitMissedEvts() ) - { - fhPulserChanMissEvtEvo[ uAsicIdx ]->Fill( dTimeSinceStartSec , usChan ); - fhPulserFebMissEvtEvo[ uAsicIdx ]->Fill( dTimeSinceStartSec ); - } // if( mess.IsHitMissedEvts() ) -/* - if( kTRUE == fbLongHistoEnable ) - { - std::chrono::steady_clock::time_point tNow = std::chrono::steady_clock::now(); - Double_t dUnixTimeInRun = std::chrono::duration_cast< std::chrono::seconds >(tNow - ftStartTimeUnix).count(); - fhFebRateEvoLong[ uAsicIdx ]->Fill( dUnixTimeInRun , 1.0 / fuLongHistoBinSizeSec ); - fhFebChRateEvoLong[ uAsicIdx ]->Fill( dUnixTimeInRun , usChan, 1.0 / fuLongHistoBinSizeSec ); - } // if( kTRUE == fbLongHistoEnable ) -*/ - -} - -void CbmCosy2018MonitorPulser::FillTsMsbInfo( stsxyter::Message mess, UInt_t /*uMessIdx*/, UInt_t /*uMsIdx*/ ) -{ - UInt_t uVal = mess.GetTsMsbVal(); -/* - if( 0 == fuCurrDpbIdx ) - LOG(info) << " TS " << std::setw( 12 ) << fulCurrentTsIdx - << " MS " << std::setw( 12 ) << fulCurrentMsIdx - << " MsInTs " << std::setw( 3 ) << uMsIdx - << " DPB " << std::setw( 2 ) << fuCurrDpbIdx - << " Mess " << std::setw( 5 ) << uMessIdx - << " TsMsb " << std::setw( 5 ) << uVal; -*/ -/* - if( (uVal != fvulCurrentTsMsb[fuCurrDpbIdx] + 1) && 0 < uVal && - !( 1 == uMessIdx && usVal == fvulCurrentTsMsb[fuCurrDpbIdx] ) ) // 1st TS_MSB in MS is always a repeat of the last one in previous MS! - { - LOG(info) << "TS MSB not increasing by 1! TS " << std::setw( 12 ) << fulCurrentTsIdx - << " MS " << std::setw( 12 ) << fulCurrentMsIdx - << " MsInTs " << std::setw( 3 ) << uMsIdx - << " DPB " << std::setw( 2 ) << fuCurrDpbIdx - << " Mess " << std::setw( 5 ) << uMessIdx - << " Old TsMsb " << std::setw( 5 ) << fvulCurrentTsMsb[fuCurrDpbIdx] - << " new TsMsb " << std::setw( 5 ) << uVal - << " Diff " << std::setw( 5 ) << uVal - fvulCurrentTsMsb[fuCurrDpbIdx] - << " Old MsbCy " << std::setw( 5 ) << fvuCurrentTsMsbCycle[fuCurrDpbIdx]; - } // if( (uVal != fvulCurrentTsMsb[fuCurrDpbIdx] + 1) && 0 < uVal ) -*/ - - // Update Status counters - if( uVal < fvulCurrentTsMsb[fuCurrDpbIdx] ) - { - - LOG(info) << " TS " << std::setw( 12 ) << fulCurrentTsIdx - << " MS " << std::setw( 12 ) << fulCurrentMsIdx - << " DPB " << std::setw( 2 ) << fuCurrDpbIdx - << " Old TsMsb " << std::setw( 5 ) << fvulCurrentTsMsb[fuCurrDpbIdx] - << " Old MsbCy " << std::setw( 5 ) << fvuCurrentTsMsbCycle[fuCurrDpbIdx] - << " new TsMsb " << std::setw ( 5 ) << uVal; - - fvuCurrentTsMsbCycle[fuCurrDpbIdx] ++; - } // if( uVal < fvulCurrentTsMsb[fuCurrDpbIdx] ) - fvulCurrentTsMsb[fuCurrDpbIdx] = uVal; -/* - if( 1 < uMessIdx ) - { - fhStsDpbRawTsMsb->Fill( fuCurrDpbIdx, fvulCurrentTsMsb[fuCurrDpbIdx] ); - fhStsDpbRawTsMsbSx->Fill( fuCurrDpbIdx, ( fvulCurrentTsMsb[fuCurrDpbIdx] & 0x1F ) ); - fhStsDpbRawTsMsbDpb->Fill( fuCurrDpbIdx, ( fvulCurrentTsMsb[fuCurrDpbIdx] >> 5 ) ); - } // if( 0 < uMessIdx ) -*/ -// fhStsAsicTsMsb->Fill( fvulCurrentTsMsb[fuCurrDpbIdx], uAsicIdx ); -/* - ULong64_t ulNewTsMsbTime = static_cast< ULong64_t >( stsxyter::kuHitNbTsBins ) - * static_cast< ULong64_t >( fvulCurrentTsMsb[fuCurrDpbIdx]) - + static_cast< ULong64_t >( stsxyter::kulTsCycleNbBins ) - * static_cast< ULong64_t >( fvuCurrentTsMsbCycle[fuCurrDpbIdx] ); -*/ -} - -void CbmCosy2018MonitorPulser::FillEpochInfo( stsxyter::Message /*mess*/ ) -{ -// UInt_t uVal = mess.GetTsMsbVal(); -/* - // Update Status counters - if( usVal < fvulCurrentTsMsb[fuCurrDpbIdx] ) - fvuCurrentTsMsbCycle[fuCurrDpbIdx] ++; - fvulCurrentTsMsb[fuCurrDpbIdx] = usVal; - -// fhStsAsicTsMsb->Fill( fvulCurrentTsMsb[fuCurrDpbIdx], uAsicIdx ); -*/ -} - -void CbmCosy2018MonitorPulser::Reset() -{ -} - -void CbmCosy2018MonitorPulser::Finish() -{ - - LOG(info) << "-------------------------------------"; - LOG(info) << "CbmCosy2018MonitorPulser statistics are "; - LOG(info) << " Hit messages: " << fmMsgCounter[ stsxyter::MessType::Hit ] << "\n" - << " Ts MSB messages: " << fmMsgCounter[ stsxyter::MessType::TsMsb ] << "\n" - << " Dummy messages: " << fmMsgCounter[ stsxyter::MessType::Dummy ] << "\n" - << " Epoch messages: " << fmMsgCounter[ stsxyter::MessType::Epoch ] << "\n" - << " Empty messages: " << fmMsgCounter[ stsxyter::MessType::Empty ]; - - LOG(info) << "-------------------------------------"; - - SaveAllHistos( fsHistoFileFullname ); - SaveAllHistos(); - -} - - -void CbmCosy2018MonitorPulser::FillOutput(boost::any) -{ -} - -void CbmCosy2018MonitorPulser::SaveAllHistos( TString sFileName ) -{ - TDirectory * oldDir = NULL; - TFile * histoFile = NULL; - if( "" != sFileName ) - { - // Store current directory position to allow restore later - oldDir = gDirectory; - // open separate histo file in recreate mode - histoFile = new TFile( sFileName , "RECREATE"); - histoFile->cd(); - } // if( "" != sFileName ) - - /***************************/ - gDirectory->mkdir("Sts_Raw"); - gDirectory->cd("Sts_Raw"); - - fhPulserMessType->Write(); - fhPulserSysMessType->Write(); - fhPulserMessTypePerDpb->Write(); - fhPulserSysMessTypePerDpb->Write(); - fhPulserMessTypePerElink->Write(); - fhPulserSysMessTypePerElink->Write(); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fhPulserChanCntRaw[ uXyterIdx ]->Write(); - fhPulserChanAdcRaw[ uXyterIdx ]->Write(); - fhPulserChanAdcRawProf[ uXyterIdx ]->Write(); - fhPulserChanRawTs[ uXyterIdx ]->Write(); - fhPulserChanMissEvt[ uXyterIdx ]->Write(); - fhPulserChanMissEvtEvo[ uXyterIdx ]->Write(); - fhPulserFebMissEvtEvo[ uXyterIdx ]->Write(); - fhPulserChanHitRateEvo[ uXyterIdx ]->Write(); - fhPulserFebRateEvo[ uXyterIdx ]->Write(); - fhPulserChanHitRateEvoLong[ uXyterIdx ]->Write(); - fhPulserFebRateEvoLong[ uXyterIdx ]->Write(); -/* - if( kTRUE == fbLongHistoEnable ) - { - fhFebRateEvoLong[ uXyterIdx ]->Write(); - fhFebChRateEvoLong[ uXyterIdx ]->Write(); - } // if( kTRUE == fbLongHistoEnable ) -*/ - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - - gDirectory->cd(".."); - /***************************/ - - /***************************/ - // Flib Histos - gDirectory->mkdir("Flib_Raw"); - gDirectory->cd("Flib_Raw"); - for( UInt_t uLinks = 0; uLinks < kiMaxNbFlibLinks; uLinks ++) - { - TString sMsSzName = Form("MsSz_link_%02u", uLinks); - if( fHM->Exists(sMsSzName.Data() ) ) - fHM->H1( sMsSzName.Data() )->Write(); - - sMsSzName = Form("MsSzTime_link_%02u", uLinks); - if( fHM->Exists(sMsSzName.Data() ) ) - fHM->P1( sMsSzName.Data() )->Write(); - } // for( UInt_t uLinks = 0; uLinks < 16; uLinks ++) - - TH1 * pMissedTsH1 = dynamic_cast< TH1 * >( gROOT->FindObjectAny( "Missed_TS" ) ); - if( NULL != pMissedTsH1 ) - pMissedTsH1->Write(); - - TProfile * pMissedTsEvoP = dynamic_cast< TProfile * >( gROOT->FindObjectAny( "Missed_TS_Evo" ) ); - if( NULL != pMissedTsEvoP ) - pMissedTsEvoP->Write(); - - gDirectory->cd(".."); - /***************************/ - - if( "" != sFileName ) - { - // Restore original directory position - histoFile->Close(); - oldDir->cd(); - } // if( "" != sFileName ) - -} -void CbmCosy2018MonitorPulser::ResetAllHistos() -{ - LOG(info) << "Reseting all STS histograms."; - - fhPulserMessType->Reset(); - fhPulserSysMessType->Reset(); - fhPulserMessTypePerDpb->Reset(); - fhPulserSysMessTypePerDpb->Reset(); - fhPulserMessTypePerElink->Reset(); - fhPulserSysMessTypePerElink->Reset(); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fhPulserChanCntRaw[ uXyterIdx ]->Reset(); - fhPulserChanAdcRaw[ uXyterIdx ]->Reset(); - fhPulserChanAdcRawProf[ uXyterIdx ]->Reset(); - fhPulserChanRawTs[ uXyterIdx ]->Reset(); - fhPulserChanMissEvt[ uXyterIdx ]->Reset(); - fhPulserChanMissEvtEvo[ uXyterIdx ]->Reset(); - fhPulserFebMissEvtEvo[ uXyterIdx ]->Reset(); - fhPulserChanHitRateEvo[ uXyterIdx ]->Reset(); - fhPulserFebRateEvo[ uXyterIdx ]->Reset(); - fhPulserChanHitRateEvoLong[ uXyterIdx ]->Reset(); - fhPulserFebRateEvoLong[ uXyterIdx ]->Reset(); -/* - if( kTRUE == fbLongHistoEnable ) - { - ftStartTimeUnix = std::chrono::steady_clock::now(); - fhFebRateEvoLong[ uXyterIdx ]->Reset(); - fhFebChRateEvoLong[ uXyterIdx ]->Reset(); - } // if( kTRUE == fbLongHistoEnable ) -*/ - - fhPulserTimeDiffPerAsic[ uXyterIdx ]->Reset(); - for( UInt_t uXyterIdxB = 0; uXyterIdxB < fuNbStsXyters; ++uXyterIdxB ) - { - fhPulserTimeDiffPerAsicPair[ uXyterIdx ][uXyterIdxB]->Reset(); - fhPulserTimeDiffEvoPerAsicPair[ uXyterIdx ][uXyterIdxB]->Reset(); - fhPulserTsLsbMatchPerAsicPair[ uXyterIdx ][uXyterIdxB]->Reset(); - fhPulserTsMsbMatchPerAsicPair[ uXyterIdx ][uXyterIdxB]->Reset(); - } // for( UInt_t uXyterIdxB = 0; uXyterIdxB < fuNbStsXyters; ++uXyterIdxB ) - fhPulserIntervalAsic[ uXyterIdx ]->Reset(); - fhPulserIntervalLongAsic[ uXyterIdx ]->Reset(); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - - for( UInt_t uLinks = 0; uLinks < kiMaxNbFlibLinks; ++uLinks ) - { - TString sMsSzName = Form("MsSz_link_%02u", uLinks); - if( fHM->Exists(sMsSzName.Data() ) ) - fHM->H1( sMsSzName.Data() )->Reset(); - - sMsSzName = Form("MsSzTime_link_%02u", uLinks); - if( fHM->Exists(sMsSzName.Data() ) ) - fHM->P1( sMsSzName.Data() )->Reset(); - } // for( UInt_t uLinks = 0; uLinks < kiMaxNbFlibLinks; ++uLinks ) - - fdStartTime = -1; - fdStartTimeMsSz = -1; -} - -void CbmCosy2018MonitorPulser::SetRunStart( Int_t dateIn, Int_t timeIn, Int_t iBinSize ) -{ - TDatime * fRunStartDateTime = new TDatime( dateIn, timeIn); - fiRunStartDateTimeSec = fRunStartDateTime->Convert(); - fiBinSizeDatePlots = iBinSize; - - LOG(info) << "Assigned new MUCH Run Start Date-Time: " << fRunStartDateTime->AsString(); -} - -void CbmCosy2018MonitorPulser::SetLongDurationLimits( UInt_t uDurationSeconds, UInt_t uBinSize ) -{ - fbLongHistoEnable = kTRUE; - fuLongHistoNbSeconds = uDurationSeconds; - fuLongHistoBinSizeSec = uBinSize; -} - -ClassImp(CbmCosy2018MonitorPulser) diff --git a/beamtime/cosy2018/unpacker/CbmCosy2018MonitorPulser.h b/beamtime/cosy2018/unpacker/CbmCosy2018MonitorPulser.h deleted file mode 100644 index 0e80590303d1cbe97d3d1f824fca65cc743346c4..0000000000000000000000000000000000000000 --- a/beamtime/cosy2018/unpacker/CbmCosy2018MonitorPulser.h +++ /dev/null @@ -1,192 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmCosy2018MonitorPulser ----- -// ----- Created 11/05/18 by P.-A. Loizeau ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CBMCOSY2018MONITORPULSER_H -#define CBMCOSY2018MONITORPULSER_H - -#include "Timeslice.hpp" - -// Data -#include "StsXyterMessage.h" -#include "StsXyterFinalHit.h" - -// CbmRoot -#include "CbmTSUnpack.h" -#include "CbmHistManager.h" - -// C++11 -#include <chrono> - -// C/C++ -#include <vector> -#include <set> -#include <map> - -class CbmCern2017UnpackParHodo; -class CbmCern2017UnpackParSts; - -class CbmCosy2018MonitorPulser: public CbmTSUnpack -{ -public: - - CbmCosy2018MonitorPulser(); - virtual ~CbmCosy2018MonitorPulser(); - - virtual Bool_t Init(); - - virtual Bool_t DoUnpack(const fles::Timeslice& ts, size_t component); - - virtual void Reset(); - - virtual void Finish(); - - void SetParContainers(); - - Bool_t InitContainers(); - - Bool_t ReInitContainers(); - - void FillOutput(boost::any); - - void SetRunStart( Int_t dateIn, Int_t timeIn, Int_t iBinSize = 5 ); - - void ResetAllHistos(); - void SaveAllHistos( TString sFileName = "" ); - void SetHistoFileName( TString sFileName = "data/SetupHistos.root" ) { fsHistoFileFullname = sFileName; } - - void SetMsOverlap(size_t uOverlapMsNb = 1) { fuOverlapMsNb = uOverlapMsNb; } - size_t GetMsOverlap() { return fuOverlapMsNb; } - - void SetPrintMessage( Bool_t bPrintMessOn = kTRUE, - stsxyter::MessagePrintMask ctrl = stsxyter::MessagePrintMask::msg_print_Hex | - stsxyter::MessagePrintMask::msg_print_Human ) - { fbPrintMessages = bPrintMessOn; fPrintMessCtrl = ctrl; } - void SetLongDurationLimits( UInt_t uDurationSeconds = 3600, UInt_t uBinSize = 1 ); - void SetCoincidenceBorder( Double_t dCenterPos, Double_t dBorderVal ); - -private: - size_t fuOverlapMsNb; /** Ignore Overlap Ms: all fuOverlapMsNb MS at the end of timeslice **/ - - // Parameters - CbmCern2017UnpackParHodo* fUnpackParHodo; //! - UInt_t fuNrOfDpbs; //! Total number of Sts DPBs in system - std::map<UInt_t, UInt_t> fDpbIdIndexMap; //! Map of DPB Identifier to DPB index - UInt_t fuNbElinksPerDpb; //! Number of possible eLinks per DPB - UInt_t fuNbStsXyters; //! Number of StsXyter ASICs - UInt_t fuNbChanPerAsic; //! Number of channels per StsXyter ASIC => should be constant somewhere!!!! - std::vector< std::vector< UInt_t > > fvuElinkToAsic; //! Vector holding for each link the corresponding ASIC index [fuNrOfDpbs * fuNbElinksPerDpb] - - // Constants - static const Int_t kiMaxNbFlibLinks = 16; - static const UInt_t kuBytesPerMessage = 4; - - // Internal Control/status of monitor - // Histo File name and path - TString fsHistoFileFullname; - // Task configuration values - Bool_t fbPrintMessages; - stsxyter::MessagePrintMask fPrintMessCtrl; - // TS/MS info - ULong64_t fulCurrentTsIdx; - ULong64_t fulCurrentMsIdx; - // Current data properties - std::map< stsxyter::MessType, UInt_t > fmMsgCounter; //! - UInt_t fuCurrentEquipmentId; //! Current equipment ID, tells from which DPB the current MS is originating - UInt_t fuCurrDpbId; //! Temp holder until Current equipment ID is properly filled in MS - UInt_t fuCurrDpbIdx; //! Index of the DPB from which the MS currently unpacked is coming - Int_t fiRunStartDateTimeSec; //! Start of run time since "epoch" in s, for the plots with date as X axis - Int_t fiBinSizeDatePlots; //! Bin size in s for the plots with date as X axis - - // Data format control - std::vector< ULong64_t > fvulCurrentTsMsb; //! Current TS MSB for each DPB - std::vector< UInt_t > fvuCurrentTsMsbCycle; //! Current TS MSB cycle for DPB - std::vector< UInt_t > fvuElinkLastTsHit; //! TS from last hit for DPB - // Hits comparison - std::vector< std::vector< ULong64_t > > fvulChanLastHitTime; //! Last hit time in bins for each Channel - std::vector< std::vector< Double_t > > fvdChanLastHitTime; //! Last hit time in ns for each Channel - std::vector< Double_t > fvdMsTime; //! Header time of each MS - std::vector< std::vector< std::vector< UInt_t > > > fvuChanNbHitsInMs; //! Number of hits in each MS for each Channel - std::vector< std::vector< std::vector< Double_t > > > fvdChanLastHitTimeInMs; //! Last hit time in bins in each MS for each Channel - std::vector< std::vector< std::vector< UShort_t > > > fvusChanLastHitAdcInMs; //! Last hit ADC in bins in each MS for each Channel -// std::vector< std::vector< std::multiset< stsxyter::FinalHit > > > fvmChanHitsInTs; //! All hits (time & ADC) in bins in last TS for each Channel - // Starting state book-keeping - Double_t fdStartTime; /** Time of first valid hit (TS_MSB available), used as reference for evolution plots**/ - Double_t fdStartTimeMsSz; /** Time of first microslice, used as reference for evolution plots**/ - std::chrono::steady_clock::time_point ftStartTimeUnix; /** Time of run Start from UNIX system, used as reference for long evolution plots against reception time **/ - - // Hits time-sorting - std::vector< stsxyter::FinalHit > fvmHitsInTs; //! All hits (time in bins, ADC in bins, asic, channel) in last TS, sorted with "<" operator - std::vector< std::vector< stsxyter::FinalHit > > fvmAsicHitsInTs; //! All hits (time in bins, ADC in bins, asic, channel) in last TS, per ASIC, sorted with "<" operator - // Coincidence histos - UInt_t fuMaxNbMicroslices; - // Rate evolution histos - Bool_t fbLongHistoEnable; - UInt_t fuLongHistoNbSeconds; - UInt_t fuLongHistoBinSizeSec; - UInt_t fuLongHistoBinNb; - - // Coincidences in sorted hits - Double_t fdCoincCenter; // ns - Double_t fdCoincBorder; // ns, +/- - Double_t fdCoincMin; // ns - Double_t fdCoincMax; // ns - - // Histograms - CbmHistManager* fHM; //! Histogram manager - TH1* fhPulserMessType; - TH1* fhPulserSysMessType; - TH2* fhPulserMessTypePerDpb; - TH2* fhPulserSysMessTypePerDpb; -/* - TH2* fhStsDpbRawTsMsb; - TH2* fhStsDpbRawTsMsbSx; - TH2* fhStsDpbRawTsMsbDpb; -*/ - TH2* fhPulserMessTypePerElink; - TH2* fhPulserSysMessTypePerElink; - - std::vector<TH1 *> fhPulserChanCntRaw; - std::vector<TH1 *> fhPulserChanCntRawGood; - std::vector<TH2 *> fhPulserChanAdcRaw; - std::vector<TProfile*> fhPulserChanAdcRawProf; - std::vector<TH2*> fhPulserChanRawTs; - std::vector<TH2*> fhPulserChanMissEvt; - std::vector<TH2*> fhPulserChanMissEvtEvo; - std::vector<TH2*> fhPulserChanHitRateEvo; - std::vector<TH1*> fhPulserFebRateEvo; - std::vector<TH1*> fhPulserFebMissEvtEvo; - std::vector<TH2*> fhPulserChanHitRateEvoLong; - std::vector<TH1*> fhPulserFebRateEvoLong; - - TCanvas* fcMsSizeAll; - TH1* fhMsSz[kiMaxNbFlibLinks]; - TProfile* fhMsSzTime[kiMaxNbFlibLinks]; - - /// Pulser time difference histos - Double_t fdStartTs; //! Last hits in each ASIC - std::vector< stsxyter::FinalHit > fvmLastHitAsic; //! Last hits in each ASIC - std::vector<TH2 *> fhPulserTimeDiffPerAsic; //! - std::vector< std::vector<TH1 *> > fhPulserTimeDiffPerAsicPair; //! - std::vector< std::vector<TH2 *> > fhPulserTimeDiffEvoPerAsicPair; //! - std::vector< std::vector<TH2 *> > fhPulserTsLsbMatchPerAsicPair; //! - std::vector< std::vector<TH2 *> > fhPulserTsMsbMatchPerAsicPair; //! - std::vector<TH1 *> fhPulserIntervalAsic; //! - std::vector<TH1 *> fhPulserIntervalLongAsic; //! - - void CreateHistograms(); - - void FillHitInfo( stsxyter::Message mess, const UShort_t & usElinkIdx, const UInt_t & uAsicIdx, const UInt_t & uMsIdx ); - void FillTsMsbInfo( stsxyter::Message mess, UInt_t uMessIdx = 0, UInt_t uMsIdx = 0); - void FillEpochInfo( stsxyter::Message mess ); - - CbmCosy2018MonitorPulser(const CbmCosy2018MonitorPulser&); - CbmCosy2018MonitorPulser operator=(const CbmCosy2018MonitorPulser&); - - ClassDef(CbmCosy2018MonitorPulser, 1) -}; - -#endif // CBMCOSY2018MONITORPULSER_H diff --git a/beamtime/cosy2018/unpacker/CbmCosy2018MonitorScan.cxx b/beamtime/cosy2018/unpacker/CbmCosy2018MonitorScan.cxx deleted file mode 100644 index dcfb6a631174a6e4531e4cbeb0f00be1c3a53de8..0000000000000000000000000000000000000000 --- a/beamtime/cosy2018/unpacker/CbmCosy2018MonitorScan.cxx +++ /dev/null @@ -1,4545 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmCosy2018MonitorScan ----- -// ----- Created 27/02/18 by P.-A. Loizeau ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#include "CbmCosy2018MonitorScan.h" - -// Data - -// CbmRoot -#include "CbmCern2017UnpackParHodo.h" -#include "CbmCern2017UnpackParSts.h" -#include "CbmHistManager.h" - -// FairRoot -#include "FairLogger.h" -#include "FairRootManager.h" -#include "FairRun.h" -#include "FairRuntimeDb.h" -#include "FairRunOnline.h" - -// Root -#include "TClonesArray.h" -#include "TString.h" -#include "TRandom.h" -#include "THttpServer.h" -#include "TROOT.h" -#include "TStyle.h" -#include "THStack.h" -#include <TFile.h> - -// C++11 - -// C/C++ -#include <iostream> -#include <stdint.h> -#include <iomanip> - -Bool_t bCosy2018ResetScanHistos = kFALSE; -Bool_t bCosy2018WriteScanHistos = kFALSE; -Bool_t bCosy2018PrintMessScanHistos = kFALSE; - -CbmCosy2018MonitorScan::CbmCosy2018MonitorScan() : - CbmTSUnpack(), - fuOverlapMsNb(0), - fUnpackParHodo(NULL), - fUnpackParSts(NULL), - fuNrOfDpbs(0), - fDpbIdIndexMap(), - fuNbElinksPerDpb(0), - fuNbStsXyters(0), - fuNbChanPerAsic(0), - fvuElinkToAsic(), - fsHistoFileFullname( "data/SetupHistos.root" ), - fbPrintMessages( kFALSE ), - fPrintMessCtrl( stsxyter::MessagePrintMask::msg_print_Human ), - fbDualStsEna( kFALSE ), - fkuNbPrintMessages(5000), - fuPrintMessagesIdx(fkuNbPrintMessages), - fulCurrentTsIdx( 0 ), - fulCurrentMsIdx( 0 ), - fmMsgCounter(), - fuCurrentEquipmentId(0), - fuCurrDpbId(0), - fuCurrDpbIdx(0), - fiRunStartDateTimeSec(-1), - fiBinSizeDatePlots(-1), - fvulCurrentTsMsb(), - fvuCurrentTsMsbCycle(), - fvuElinkLastTsHit(), - fvulChanLastHitTime(), - fvdChanLastHitTime(), - fvdMsTime(), - fvuChanNbHitsInMs(), - fvdChanLastHitTimeInMs(), - fvusChanLastHitAdcInMs(), -// fvmChanHitsInTs(), - fdStartTime(-1.0), - fdStartTimeMsSz(-1.0), - ftStartTimeUnix( std::chrono::steady_clock::now() ), - fvmHitsInTs(), - fLastSortedHit1X(), - fLastSortedHit1Y(), - fLastSortedHit2X(), - fLastSortedHit2Y(), - fLastSortedHit1N(), - fLastSortedHit1P(), - fLastSortedHit2N(), - fLastSortedHit2P(), - fuMaxNbMicroslices(100), - fbLongHistoEnable( kFALSE ), - fuLongHistoNbSeconds( 0 ), - fuLongHistoBinSizeSec( 0 ), - fuLongHistoBinNb( 0 ), - fHM(new CbmHistManager()), - fhHodoMessType(NULL), - fhHodoSysMessType(NULL), - fhHodoMessTypePerDpb(NULL), - fhHodoSysMessTypePerDpb(NULL), - fhHodoMessTypePerElink(NULL), - fhHodoSysMessTypePerElink(NULL), - fhHodoChanCntRaw(), - fhHodoChanAdcRaw(), - fhHodoChanAdcRawProf(), - fhHodoChanRawTs(), - fhHodoChanMissEvt(), - fhHodoChanMissEvtEvo(), - fhHodoChanHitRateEvo(), - fhHodoFebRateEvo(), - fhHodoFebMissEvtEvo(), - fhHodoChanHitRateEvoLong(), - fhHodoFebRateEvoLong(), -/* - fdCoincBorderHodo( 50.0 ), - fdCoincBorderSts( 75.0 ), - fdCoincBorder( 150.0 ), - fhSetupSortedDtX1Y1(NULL), - fhSetupSortedDtX2Y2(NULL), - fhSetupSortedDtN1P1(NULL), - fhSetupSortedDtN2P2(NULL), - fhSetupSortedDtX1Y1X2Y2(NULL), - fhSetupSortedDtN1P1N2P2(NULL), - fhSetupSortedDtX1Y1X2Y2N1P1(NULL), - fhSetupSortedDtX1Y1X2Y2N2P2(NULL), - fhSetupSortedDtH1H2S1S2(NULL), - fhSetupSortedMapX1Y1(NULL), - fhSetupSortedMapX2Y2(NULL), - fhSetupSortedMapN1P1(NULL), - fhSetupSortedMapN2P2(NULL), - fhSetupSortedCntEvoX1Y1(NULL), - fhSetupSortedCntEvoX2Y2(NULL), - fhSetupSortedCntEvoN1P1(NULL), - fhSetupSortedCntEvoN2P2(NULL), - fhBothHodoSortedDtX1Y1(NULL), - fhBothHodoSortedDtX2Y2(NULL), - fhBothHodoSortedDtX1Y1X2Y2N1P1(NULL), - fhBothHodoSortedDtX1Y1X2Y2N2P2(NULL), - fhBothHodoSortedDtH1H2S1S2(NULL), - fhBothHodoSortedMapX1Y1(NULL), - fhBothHodoSortedMapX2Y2(NULL), - fhBothHodoSortedCntEvoX1Y1(NULL), - fhBothHodoSortedCntEvoX2Y2(NULL), - fhH1H2S1SortedDtX1Y1(NULL), - fhH1H2S1SortedDtX2Y2(NULL), - fhH1H2S1SortedDtN1P1(NULL), - fhH1H2S1SortedDtN2P2(NULL), - fhH1H2S1SortedMapX1Y1(NULL), - fhH1H2S1SortedMapX2Y2(NULL), - fhH1H2S1SortedMapN1P1(NULL), - fhH1H2S1SortedMapN2P2(NULL), - fhH1H2S1SortedCntEvoX1Y1(NULL), - fhH1H2S1SortedCntEvoX2Y2(NULL), - fhH1H2S1SortedCntEvoN1P1(NULL), - fhH1H2S1SortedCntEvoN2P2(NULL), - fhH1H2S2SortedDtX1Y1(NULL), - fhH1H2S2SortedDtX2Y2(NULL), - fhH1H2S2SortedDtN1P1(NULL), - fhH1H2S2SortedDtN2P2(NULL), - fhH1H2S2SortedMapX1Y1(NULL), - fhH1H2S2SortedMapX2Y2(NULL), - fhH1H2S2SortedMapN1P1(NULL), - fhH1H2S2SortedMapN2P2(NULL), - fhH1H2S2SortedCntEvoX1Y1(NULL), - fhH1H2S2SortedCntEvoX2Y2(NULL), - fhH1H2S2SortedCntEvoN1P1(NULL), - fhH1H2S2SortedCntEvoN2P2(NULL), - fhSystSortedDtX1Y1(NULL), - fhSystSortedDtX2Y2(NULL), - fhSystSortedDtN1P1(NULL), - fhSystSortedDtN2P2(NULL), - fhSystSortedDtX1Y1X2Y2(NULL), - fhSystSortedMapX1Y1(NULL), - fhSystSortedMapX2Y2(NULL), - fhSystSortedMapN1P1(NULL), - fhSystSortedMapN2P2(NULL), - fhSystSortedCntEvoX1Y1(NULL), - fhSystSortedCntEvoX2Y2(NULL), - fhSystSortedCntEvoN1P1(NULL), - fhSystSortedCntEvoN2P2(NULL), - fhSystSortedDtN1X1vsN1X2(NULL), - fhSystSortedDtP1X1vsP1X2(NULL), - fhSystSortedDtN1X1vsP1X1(NULL), - fhSystSortedDtSts1Hodo1vsSts1Hodo2(NULL), - fhSystSortedDtSts2Hodo1vsSts2Hodo2(NULL), - fhSystSortedDtAllVsMapX1(NULL), - fhSystSortedDtAllVsMapY1(NULL), - fhSystSortedDtAllVsMapX2(NULL), - fhSystSortedDtAllVsMapY2(NULL), - fhSetupSortedDtX1(NULL), - fhSetupSortedDtY1(NULL), - fhSetupSortedDtX2(NULL), - fhSetupSortedDtY2(NULL), - fhSetupSortedDtN1(NULL), - fhSetupSortedDtP1(NULL), - fhSetupSortedDtN2(NULL), - fhSetupSortedDtP2(NULL), - fvulTimeLastHitAsicChan(), - fviAdcLastHitAsicChan(), - fvuNbSameHitAsicChan(), - fvuNbSameFullHitAsicChan(), - fvulStartTimeLastS(), - fvuNbHitDiffTsAsicLastS(), - fvuNbHitSameTsAsicLastS(), - fvuNbHitSameTsAdcAsicLastS(), - fhSetupSortedTsFirstDuplicateChan(), - fhSetupSortedTsGoodChan(), - fhSetupSortedNbSameTsChan(), - fhSetupSortedSameTsAdcChan(), - fhSetupSortedSameTsAdcDiff(), - fhSetupSortedRatioSameTsChan(), - fhSetupSortedNbConsSameTsChan(), - fhSetupSortedNbConsSameTsAdcChan(), - fhSetupSortedNbConsSameTsVsTsAdc(), - fhSetupSortedAsicRatioSameTsVsFlux(), - fhSetupSortedAsicRatioSameTsAdcVsFlux(), - fhSetupSortedAsicRatioSameAdcSameTsVsFlux(), - fhRatioSameTsSpillEvo(), - fhRatioSameTsAdcSpillEvo(), - fhRatioSameAdcSameTsSpillEvo(), - fhFractionHitsAsicSpillEvo(), - fhFractionGoodHitsSpillEvo(), - fhFractionDupliHitsSpillEvo(), - fhFractionTsMsbSpillEvo(), - fhFractionEpochSpillEvo(), - fhFractionEmptySpillEvo(), - fhFractionHitsAsicEvo(), - fhFractionGoodHitsEvo(), - fhFractionDupliHitsEvo(), - fhFractionTsMsbEvo(), - fhFractionEpochEvo(), - fhFractionEmptyEvo(), - fhFractionAsics( NULL ), - fhFractionTypes( NULL ), - fvuNbSameFullHitAsic(), - fvuNbDiffFullHitAsic(), - fvuLastHitBufferIdx(), - fvmLastHitsAsic(), - fhAsicDuplicDtLastHits(), - fhAsicDuplicCompTs(), - fhAsicDuplicTsLsb(), - fhAsicDuplicTsMsbAsic(), - fhAsicDuplicCompTsBitThere(), - fhAsicDuplicTsLsbBitThere(), - fhAsicDuplicTsMsbBitThere(), - fhAsicDuplicTs(), - fhAsicGoodTs(), - fhAsicDuplicTsMsb(), - fhAsicGoodTsMsb(), - fhAsicDuplicTsFull(), - fhAsicGoodTsFull(), - fhAsicDuplicTsBitPattern(), - fhAsicGoodTsBitPattern(), - fhAsicDuplicTsEvoAsic0Chan01( NULL ), - fhAsicGoodTsEvoAsic0Chan01( NULL ), - fhAsicGoodTsMsbEvoAsic0Chan01( NULL ), - fhAsicGoodTsFullEvoAsic0Chan01( NULL ), - fhAsicGoodTsFullEvoProfAsic0Chan01( NULL ), - fhAsicDuplicTsEvoAsic0Chan09( NULL ), - fhAsicGoodTsEvoAsic0Chan09( NULL ), - fhAsicGoodTsFullEvoProfAsic0Chan09( NULL ), - fhAsicDuplicTsEvoAsic0Chan16( NULL ), - fhAsicGoodTsEvoAsic0Chan16( NULL ), - fhAsicGoodTsFullEvoProfAsic0Chan16( NULL ), - fuPulseIdx( 0 ), - fuPulseIdxMax( 32000 ), - fhAsicMissedChanIdVsPulseIdx( NULL ), - fhAsicMissedChanGroupVsPulseIdx( NULL ), - fhHodoChanCntGood(), - fhHodoChanGoodHitRateEvo(), - fhHodoX1SpillEvo(NULL), - fhHodoY1SpillEvo(NULL), - fhHodoX2SpillEvo(NULL), - fhHodoY2SpillEvo(NULL), - fdSpillEvoLength( 700.0 ), - fhHodoX1SpillEvoProf(NULL), - fhHodoY1SpillEvoProf(NULL), - fhHodoX2SpillEvoProf(NULL), - fhHodoY2SpillEvoProf(NULL), -*/ - fcMsSizeAll(NULL), -/* - fvuAsicTimeLastPulse(), - fvbPulseThereChan(), - fhPulseChanCountEvo(), -*/ - fhHodoChanHitRateEvoZoom(NULL), - fuNbTsMsbSinceLastHit(0), - fuNbHitsLastTsMsb(0), -/** STSXYTER v2.0 Bug, triggering condition detection **/ - fvdTimeLastHitsCoincWin(), - fvuIdxFirstHitCoincWin(), - fvuIdxLastHitCoincWin(), - fhCoincWinFlagEvo(), - fhCoincWinFlagEvoImpr2(), - fhCoincWinFlagEvoMoreCond(), - fhBadWinRatio(), ///add - fhBadDataRatio(), ///add -/** STSXYTER v2.0 Bug, triggering condition detection **/ - fhNbFiredChanPerMs(), - fhNbMultiHitChanPerMs() -{ -} - -CbmCosy2018MonitorScan::~CbmCosy2018MonitorScan() -{ -} - -Bool_t CbmCosy2018MonitorScan::Init() -{ - LOG(info) << "Initializing flib StsXyter unpacker for STS"; - - FairRootManager* ioman = FairRootManager::Instance(); - if (ioman == NULL) { - LOG(fatal) << "No FairRootManager instance"; - } - - return kTRUE; -} - -void CbmCosy2018MonitorScan::SetParContainers() -{ - LOG(info) << "Setting parameter containers for " << GetName(); - fUnpackParHodo = (CbmCern2017UnpackParHodo*)(FairRun::Instance()->GetRuntimeDb()->getContainer("CbmCern2017UnpackParHodo")); - fUnpackParSts = (CbmCern2017UnpackParSts*)(FairRun::Instance()->GetRuntimeDb()->getContainer("CbmCern2017UnpackParSts")); -} - - -Bool_t CbmCosy2018MonitorScan::InitContainers() -{ - LOG(info) << "Init parameter containers for " << GetName(); - - Bool_t bReInit = ReInitContainers(); - CreateHistograms(); - - return bReInit; -} - -Bool_t CbmCosy2018MonitorScan::ReInitContainers() -{ - LOG(info) << "ReInit parameter containers for " << GetName(); - - fuNrOfDpbs = fUnpackParHodo->GetNrOfDpbs(); - fuNbElinksPerDpb = fUnpackParHodo->GetNbElinksPerDpb(); - fuNbStsXyters = fUnpackParHodo->GetNbStsXyters(); - fuNbChanPerAsic = fUnpackParHodo->GetNbChanPerAsic(); - - - LOG(info) << "Nr. of STS DPBs: " << fuNrOfDpbs; - - fDpbIdIndexMap.clear(); - fvuElinkToAsic.resize( fuNrOfDpbs ); - for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - { - fDpbIdIndexMap[ fUnpackParHodo->GetDpbId( uDpb ) ] = uDpb; - LOG(info) << "Eq. ID for DPB #" << std::setw(2) << uDpb << " = " - << std::setw(4) << std::hex << fUnpackParHodo->GetDpbId( uDpb ) - << std::dec - << " => " << fDpbIdIndexMap[ fUnpackParHodo->GetDpbId( uDpb ) ]; - - fvuElinkToAsic[uDpb].resize( fuNbElinksPerDpb ); - for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink ) - fvuElinkToAsic[uDpb][uElink] = fUnpackParHodo->GetElinkToAsicIdx( uDpb * fuNbElinksPerDpb + uElink ); - } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - - LOG(info) << "Nr. eLinks per DPB: " << fuNbElinksPerDpb; - LOG(info) << "Nr. of StsXyter ASICs: " << fuNbStsXyters; - LOG(info) << "Nb. channels per ASIC: " << fuNbChanPerAsic; - - for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - { - LOG(info) << "ASIC ID for eLinks in DPB #" << std::setw(2) << uDpb << ": "; - - std::stringstream ss; - for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink ) - { - if( 0 == uElink % 10 ) - ss << "\n------> "; - - ss << std::setw( 5 ) << fvuElinkToAsic[uDpb][uElink] << " "; - } // for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink ) - LOG(info) << ss.str(); - } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - - LOG(info) << "ASIC Idx for Hodo 1: " << fUnpackParHodo->GetAsicIndexHodo1(); - LOG(info) << "ASIC Idx for Hodo 2: " << fUnpackParHodo->GetAsicIndexHodo2(); - - LOG(info) << "XY swapped in Hodo 1: " << fUnpackParHodo->IsXySwappedHodo1(); - LOG(info) << "XY swapped in Hodo 2: " << fUnpackParHodo->IsXySwappedHodo2(); - - LOG(info) << "X axis inverted in Hodo 1: " << fUnpackParHodo->IsXInvertedHodo1(); - LOG(info) << "X axis inverted in Hodo 1: " << fUnpackParHodo->IsYInvertedHodo1(); - LOG(info) << "X axis inverted in Hodo 2: " << fUnpackParHodo->IsXInvertedHodo2(); - LOG(info) << "X axis inverted in Hodo 2: " << fUnpackParHodo->IsYInvertedHodo2(); - - // Internal status initialization - fvulCurrentTsMsb.resize( fuNrOfDpbs ); - fvuCurrentTsMsbCycle.resize( fuNrOfDpbs ); - fvuElinkLastTsHit.resize( fuNrOfDpbs ); - for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - { - fvulCurrentTsMsb[uDpb] = 0; - fvuCurrentTsMsbCycle[uDpb] = 0; -/* - fvuElinkLastTsHit[uDpb].resize( fuNbElinksPerDpb ); - for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink ) - { - fvuElinkLastTsHit[uDpb][uElink] = 0; - } // for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink ) -*/ - } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - - fvulChanLastHitTime.resize( fuNbStsXyters ); - fvdChanLastHitTime.resize( fuNbStsXyters ); - fvdMsTime.resize( fuMaxNbMicroslices ); - fvuChanNbHitsInMs.resize( fuNbStsXyters ); - fvdChanLastHitTimeInMs.resize( fuNbStsXyters ); - fvusChanLastHitAdcInMs.resize( fuNbStsXyters ); -// fvmChanHitsInTs.resize( fuNbStsXyters ); - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fvulChanLastHitTime[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvdChanLastHitTime[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvuChanNbHitsInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvdChanLastHitTimeInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvusChanLastHitAdcInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); -// fvmChanHitsInTs[ uXyterIdx ].resize( fuNbChanPerAsic ); - for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - { - fvulChanLastHitTime[ uXyterIdx ][ uChan ] = 0; - fvdChanLastHitTime[ uXyterIdx ][ uChan ] = -1.0; - - fvuChanNbHitsInMs[ uXyterIdx ][ uChan ].resize( fuMaxNbMicroslices ); - fvdChanLastHitTimeInMs[ uXyterIdx ][ uChan ].resize( fuMaxNbMicroslices ); - fvusChanLastHitAdcInMs[ uXyterIdx ][ uChan ].resize( fuMaxNbMicroslices ); -// fvmChanHitsInTs[ uXyterIdx ][ uChan ].clear(); - for( UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx ) - { - fvuChanNbHitsInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = 0; - fvdChanLastHitTimeInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = -1.0; - fvusChanLastHitAdcInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = 0; - } // for( UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx ) - } // for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - LOG(info) << "CbmCosy2018MonitorScan::ReInitContainers => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs.size() << " VS " << fuNbStsXyters; - LOG(info) << "CbmCosy2018MonitorScan::ReInitContainers => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs[ 0 ].size() << " VS " << fuNbChanPerAsic; - LOG(info) << "CbmCosy2018MonitorScan::ReInitContainers => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs[ 0 ][ 0 ].size() << " VS " << fuMaxNbMicroslices; -/* - /// Counting of hits without proper timestamp - fvulTimeLastHitAsicChan.resize( fuNbStsXyters ); - fviAdcLastHitAsicChan.resize( fuNbStsXyters ); - fvuNbSameHitAsicChan.resize( fuNbStsXyters ); - fvuNbSameFullHitAsicChan.resize( fuNbStsXyters ); - fvulStartTimeLastS.resize( fuNbStsXyters ); - fvuNbHitDiffTsAsicLastS.resize( fuNbStsXyters ); - fvuNbHitSameTsAsicLastS.resize( fuNbStsXyters ); - fvuNbHitSameTsAdcAsicLastS.resize( fuNbStsXyters ); - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fvulTimeLastHitAsicChan[ uXyterIdx ].resize( fuNbChanPerAsic ); - fviAdcLastHitAsicChan[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvuNbSameHitAsicChan[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvuNbSameFullHitAsicChan[ uXyterIdx ].resize( fuNbChanPerAsic ); - for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - { - fvulTimeLastHitAsicChan[ uXyterIdx ][ uChan ] = 0; - fviAdcLastHitAsicChan[ uXyterIdx ][ uChan ] = 0; - fvuNbSameHitAsicChan[ uXyterIdx ][ uChan ] = 0; - fvuNbSameFullHitAsicChan[ uXyterIdx ][ uChan ] = 0; - } // for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - - fvulStartTimeLastS[ uXyterIdx ] = 0; - fvuNbHitDiffTsAsicLastS[ uXyterIdx ] = 0; - fvuNbHitSameTsAsicLastS[ uXyterIdx ] = 0; - fvuNbHitSameTsAdcAsicLastS[ uXyterIdx ] = 0; - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) -*/ -/* - fvuAsicTimeLastPulse.resize( fuNbStsXyters ); - fvbPulseThereChan.resize( fuNbStsXyters ); - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fvuAsicTimeLastPulse[ uXyterIdx ] = 0; - fvbPulseThereChan[ uXyterIdx ].resize( fuNbChanPerAsic ); - for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - { - fvbPulseThereChan[ uXyterIdx ][ uChan ] = kFALSE; - } // for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) -*/ -/* - fvuNbSameFullHitAsic.resize( fuNbStsXyters ); - fvuNbDiffFullHitAsic.resize( fuNbStsXyters ); - fvuLastHitBufferIdx.resize( fuNbStsXyters ); - fvmLastHitsAsic.resize( fuNbStsXyters ); - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fvuNbSameFullHitAsic[ uXyterIdx ] = 0; - fvuNbDiffFullHitAsic[ uXyterIdx ] = 0; - fvuLastHitBufferIdx[ uXyterIdx ] = 0; - fvmLastHitsAsic[ uXyterIdx ].resize( fuNbChanPerAsic ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) -*/ -/** STSXYTER v2.0 Bug, triggering condition detection **/ - fvulLastHitTs.resize( fuNbStsXyters ); - fvdTimeLastHitsCoincWin.resize( fuNbStsXyters ); - fvuIdxFirstHitCoincWin.resize( fuNbStsXyters ); - fvuIdxLastHitCoincWin.resize( fuNbStsXyters ); - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fvulLastHitTs[ uXyterIdx ].resize( fuNbChanPerAsic, 0 ); - fvdTimeLastHitsCoincWin[ uXyterIdx ].resize( kuNbHitCoincWinBug, 0.0 ); - fvuIdxFirstHitCoincWin[ uXyterIdx ] = kuNbHitCoincWinBug; - fvuIdxLastHitCoincWin[ uXyterIdx ] = kuNbHitCoincWinBug; - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - InitializeFvCoincWins2(); - InitializeFvCoincWinsMore(); -/** STSXYTER v2.0 Bug, triggering condition detection **/ - - fvbChanFiredInThisMs.resize( fuNbStsXyters ); - fvbChanCopiedInThisMs.resize( fuNbStsXyters ); - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fvbChanFiredInThisMs[ uXyterIdx ].resize( fuNbChanPerAsic, kFALSE ); - fvbChanCopiedInThisMs[ uXyterIdx ].resize( fuNbChanPerAsic, kFALSE ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - - LOG(info) << "CbmCosy2018MonitorScan::ReInitContainers => Dual STS mode: " << fbDualStsEna; - return kTRUE; -} - -/** STSXYTER v2.0 Bug, triggering condition detection **/ -//~v2 -void CbmCosy2018MonitorScan::InitializeFvCoincWins2() { - fvdTimeLastHitsCoincWin2.resize( fuNbStsXyters ); - fvuIdxFirstHitCoincWinA2.resize( fuNbStsXyters ); - fvuIdxFirstHitCoincWinB2.resize( fuNbStsXyters ); - fvuIdxFirstHitCoincWinC2.resize( fuNbStsXyters ); - fvuIdxLastHitCoincWin2.resize( fuNbStsXyters ); - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - //fvulLastHitTs[ uXyterIdx ].resize( fuNbChanPerAsic, 0 ); - fvdTimeLastHitsCoincWin2[ uXyterIdx ].resize( kuNbHitCoincWinBugMax, 0.0 ); - fvuIdxFirstHitCoincWinA2[ uXyterIdx ] = kuNbHitCoincWinBugMax; - fvuIdxFirstHitCoincWinB2[ uXyterIdx ] = kuNbHitCoincWinBugMax; - fvuIdxFirstHitCoincWinC2[ uXyterIdx ] = kuNbHitCoincWinBugMax; - fvuIdxLastHitCoincWin2[ uXyterIdx ] = kuNbHitCoincWinBugMax; - } - -} - -//~more conditions -void CbmCosy2018MonitorScan::InitializeFvCoincWinsMore() { - fvdTimeLastHitsCoincWinM.resize( fuNbStsXyters ); - fvuIdxFirstHitCoincWinM7.resize( fuNbStsXyters ); - fvuIdxFirstHitCoincWinM8.resize( fuNbStsXyters ); - fvuIdxFirstHitCoincWinM9.resize( fuNbStsXyters ); - fvuIdxFirstHitCoincWinM10.resize( fuNbStsXyters ); - fvuIdxFirstHitCoincWinM11.resize( fuNbStsXyters ); - fvuIdxLastHitCoincWinM.resize( fuNbStsXyters ); - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - //fvulLastHitTs[ uXyterIdx ].resize( fuNbChanPerAsic, 0 ); - fvdTimeLastHitsCoincWinM[ uXyterIdx ].resize( kuNbHitCoincWinBugM, 0.0 ); - fvuIdxFirstHitCoincWinM7[ uXyterIdx ] = kuNbHitCoincWinBugM; - fvuIdxFirstHitCoincWinM8[ uXyterIdx ] = kuNbHitCoincWinBugM; - fvuIdxFirstHitCoincWinM9[ uXyterIdx ] = kuNbHitCoincWinBugM; - fvuIdxFirstHitCoincWinM10[ uXyterIdx ] = kuNbHitCoincWinBugM; - fvuIdxFirstHitCoincWinM11[ uXyterIdx ] = kuNbHitCoincWinBugM; - fvuIdxLastHitCoincWinM[ uXyterIdx ] = kuNbHitCoincWinBugM; - } - -} - -/** STSXYTER v2.0 Bug, triggering condition detection **/ - -void CbmCosy2018MonitorScan::CreateHistograms() -{ - TString sHistName{""}; - TString title{""}; - - sHistName = "hHodoMessageType"; - title = "Nb of message for each type; Type"; - fhHodoMessType = new TH1I(sHistName, title, 5, 0., 5.); - fhHodoMessType->GetXaxis()->SetBinLabel( 1, "Dummy"); - fhHodoMessType->GetXaxis()->SetBinLabel( 2, "Hit"); - fhHodoMessType->GetXaxis()->SetBinLabel( 3, "TsMsb"); - fhHodoMessType->GetXaxis()->SetBinLabel( 4, "Epoch"); - fhHodoMessType->GetXaxis()->SetBinLabel( 5, "Empty"); -/* *** Missing int + MessType OP!!!! **** - fhHodoMessType->GetXaxis()->SetBinLabel(1 + stsxyter::MessType::Dummy, "Dummy"); - fhHodoMessType->GetXaxis()->SetBinLabel(1 + stsxyter::MessType::Hit, "Hit"); - fhHodoMessType->GetXaxis()->SetBinLabel(1 + stsxyter::MessType::TsMsb, "TsMsb"); - fhHodoMessType->GetXaxis()->SetBinLabel(1 + stsxyter::MessType::ReadDataAck, "ReadDataAck"); - fhHodoMessType->GetXaxis()->SetBinLabel(1 + stsxyter::MessType::Ack, "Ack"); -*/ - - sHistName = "hHodoSysMessType"; - title = "Nb of system message for each type; System Type"; - fhHodoSysMessType = new TH1I(sHistName, title, 17, 0., 17.); -/* - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_START, "DAQ START"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_FINISH, "DAQ FINISH"); - hSysMessType->GetXaxis()->SetBinLabel(1 + 16, "GET4 Hack 32B"); -*/ - - sHistName = "hHodoMessageTypePerDpb"; - title = "Nb of message of each type for each DPB; DPB; Type"; - fhHodoMessTypePerDpb = new TH2I(sHistName, title, fuNrOfDpbs, 0, fuNrOfDpbs, 5, 0., 5.); - fhHodoMessTypePerDpb->GetYaxis()->SetBinLabel( 1, "Dummy"); - fhHodoMessTypePerDpb->GetYaxis()->SetBinLabel( 2, "Hit"); - fhHodoMessTypePerDpb->GetYaxis()->SetBinLabel( 3, "TsMsb"); - fhHodoMessTypePerDpb->GetYaxis()->SetBinLabel( 4, "Epoch"); - fhHodoMessTypePerDpb->GetYaxis()->SetBinLabel( 5, "Empty"); -/* *** Missing int + MessType OP!!!! **** - fhHodoMessType->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Dummy, "Dummy"); - fhHodoMessType->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Hit, "Hit"); - fhHodoMessType->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::TsMsb, "TsMsb"); - fhHodoMessType->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::ReadDataAck, "ReadDataAck"); - fhHodoMessType->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Ack, "Ack"); -*/ - - sHistName = "hHodoSysMessTypePerDpb"; - title = "Nb of system message of each type for each DPB; DPB; System Type"; - fhHodoSysMessTypePerDpb = new TH2I(sHistName, title, fuNrOfDpbs, 0, fuNrOfDpbs, 17, 0., 17.); -/* - hSysMessType->GetYaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_START, "DAQ START"); - hSysMessType->GetYaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_FINISH, "DAQ FINISH"); - hSysMessType->GetYaxis()->SetBinLabel(1 + 16, "GET4 Hack 32B"); -*/ - - sHistName = "hHodoMessageTypePerElink"; - title = "Nb of message of each type for each eLink; eLink; Type"; - fhHodoMessTypePerElink = new TH2I(sHistName, title, fuNrOfDpbs * fuNbElinksPerDpb, 0, fuNrOfDpbs * fuNbElinksPerDpb, 5, 0., 5.); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel( 1, "Dummy"); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel( 2, "Hit"); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel( 3, "TsMsb"); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel( 4, "ReadDataAck"); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel( 5, "Ack"); -/* *** Missing int + MessType OP!!!! **** - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Dummy, "Dummy"); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Hit, "Hit"); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::TsMsb, "TsMsb"); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::ReadDataAck, "ReadDataAck"); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Ack, "Ack"); -*/ - - sHistName = "hHodoSysMessTypePerElink"; - title = "Nb of system message of each type for each eLink; eLink; System Type"; - fhHodoSysMessTypePerElink = new TH2I(sHistName, title, fuNrOfDpbs * fuNbElinksPerDpb, 0, fuNrOfDpbs * fuNbElinksPerDpb, 17, 0., 17.); -/* - fhHodoSysMessTypePerElink->GetYaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_START, "DAQ START"); - fhHodoSysMessTypePerElink->GetYaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_FINISH, "DAQ FINISH"); - fhHodoSysMessTypePerElink->GetYaxis()->SetBinLabel(1 + 16, "GET4 Hack 32B"); -*/ -/* - // Number of rate bins = - // 9 for the sub-unit decade - // + 9 for each unit of each decade * 10 for the subdecade range - // + 1 for the closing bin top edge - const Int_t iNbDecadesRate = 9; - const Int_t iNbStepsDecade = 9; - const Int_t iNbSubStepsInStep = 10; - const Int_t iNbBinsRate = iNbStepsDecade - + iNbStepsDecade * iNbSubStepsInStep * iNbDecadesRate - + 1; - Double_t dBinsRate[iNbBinsRate]; - // First fill sub-unit decade - for( Int_t iSubU = 0; iSubU < iNbStepsDecade; iSubU ++ ) - dBinsRate[ iSubU ] = 0.1 * ( 1 + iSubU ); - std::cout << std::endl; - // Then fill the main decades - Double_t dSubstepSize = 1.0 / iNbSubStepsInStep; - for( Int_t iDecade = 0; iDecade < iNbDecadesRate; iDecade ++) - { - Double_t dBase = std::pow( 10, iDecade ); - Int_t iDecadeIdx = iNbStepsDecade - + iDecade * iNbStepsDecade * iNbSubStepsInStep; - for( Int_t iStep = 0; iStep < iNbStepsDecade; iStep++ ) - { - Int_t iStepIdx = iDecadeIdx + iStep * iNbSubStepsInStep; - for( Int_t iSubStep = 0; iSubStep < iNbSubStepsInStep; iSubStep++ ) - { - dBinsRate[ iStepIdx + iSubStep ] = dBase * (1 + iStep) - + dBase * dSubstepSize * iSubStep; - } // for( Int_t iSubStep = 0; iSubStep < iNbSubStepsInStep; iSubStep++ ) - } // for( Int_t iStep = 0; iStep < iNbStepsDecade; iStep++ ) - } // for( Int_t iDecade = 0; iDecade < iNbDecadesRate; iDecade ++) - dBinsRate[ iNbBinsRate - 1 ] = std::pow( 10, iNbDecadesRate ); -*/ - UInt_t uAlignedLimit = fuLongHistoNbSeconds - (fuLongHistoNbSeconds % fuLongHistoBinSizeSec); - fuLongHistoBinNb = uAlignedLimit / fuLongHistoBinSizeSec; - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - // Channel counts - sHistName = Form( "hHodoChanCntRaw_%03u", uXyterIdx ); - title = Form( "Hits Count per channel, StsXyter #%03u; Channel; Hits []", uXyterIdx ); - fhHodoChanCntRaw.push_back( new TH1I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - - // Raw Adc Distribution - sHistName = Form( "hHodoChanAdcRaw_%03u", uXyterIdx ); - title = Form( "Raw Adc distribution per channel, StsXyter #%03u; Channel []; Adc []; Hits []", uXyterIdx ); - fhHodoChanAdcRaw.push_back( new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - stsxyter::kuHitNbAdcBins, -0.5, stsxyter::kuHitNbAdcBins -0.5 ) ); - - // Raw Adc Distribution profile - sHistName = Form( "hHodoChanAdcRawProfc_%03u", uXyterIdx ); - title = Form( "Raw Adc prodile per channel, StsXyter #%03u; Channel []; Adc []", uXyterIdx ); - fhHodoChanAdcRawProf.push_back( new TProfile(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - - // Raw Ts Distribution - sHistName = Form( "hHodoChanRawTs_%03u", uXyterIdx ); - title = Form( "Raw Timestamp distribution per channel, StsXyter #%03u; Channel []; Ts []; Hits []", uXyterIdx ); - fhHodoChanRawTs.push_back( new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - stsxyter::kuHitNbTsBins, -0.5, stsxyter::kuHitNbTsBins -0.5 ) ); - - // Missed event flag - sHistName = Form( "hHodoChanMissEvt_%03u", uXyterIdx ); - title = Form( "Missed Event flags per channel, StsXyter #%03u; Channel []; Miss Evt []; Hits []", uXyterIdx ); - fhHodoChanMissEvt.push_back( new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - 2, -0.5, 1.5 ) ); - - // Missed event flag counts evolution - - sHistName = Form( "hHodoChanMissEvtEvo_%03u", uXyterIdx ); - title = Form( "Missed Evt flags per second & channel in StsXyter #%03u; Time [s]; Channel []; Missed Evt flags []", uXyterIdx ); - fhHodoChanMissEvtEvo.push_back( new TH2I( sHistName, title, - 1800, 0, 1800, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - - // Missed event flag counts evo per StsXyter - - sHistName = Form( "hHodoFebMissEvtEvo%03u", uXyterIdx ); - title = Form( "Missed Evt flags per second in StsXyter #%03u; Time [s]; Missed Evt flags []", uXyterIdx ); - fhHodoFebMissEvtEvo.push_back( new TH1I(sHistName, title, 1800, 0, 1800 ) ); - - // Hit rates evo per channel - sHistName = Form( "hHodoChanRateEvo_%03u", uXyterIdx ); - title = Form( "Hits per second & channel in StsXyter #%03u; Time [s]; Channel []; Hits []", uXyterIdx ); - fhHodoChanHitRateEvo.push_back( new TH2I( sHistName, title, - 3600, 0, 1800, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - - // Hit rates evo per StsXyter - sHistName = Form( "hHodoFebRateEvo_%03u", uXyterIdx ); - title = Form( "Hits per second in StsXyter #%03u; Time [s]; Hits []", uXyterIdx ); - fhHodoFebRateEvo.push_back( new TH1I(sHistName, title, 1800, 0, 1800 ) ); - - // Hit rates evo per channel, 1 minute bins, 24h - sHistName = Form( "hHodoChanRateEvoLong_%03u", uXyterIdx ); - title = Form( "Hits per second & channel in StsXyter #%03u; Time [min]; Channel []; Hits []", uXyterIdx ); - fhHodoChanHitRateEvoLong.push_back( new TH2D( sHistName, title, - fuLongHistoBinNb, -0.5, uAlignedLimit - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - - // Hit rates evo per StsXyter, 1 minute bins, 24h - sHistName = Form( "hHodoFebRateEvoLong_%03u", uXyterIdx ); - title = Form( "Hits per second in StsXyter #%03u; Time [min]; Hits []", uXyterIdx ); - fhHodoFebRateEvoLong.push_back( new TH1D(sHistName, title, fuLongHistoBinNb, -0.5, uAlignedLimit - 0.5 ) ); - -/* - if( kTRUE == fbLongHistoEnable ) - { - - sHistName = Form( "hFebRateEvoLong_%03u", uXyterIdx ); - title = Form( "Mean rate VS run time in same MS in StsXyter #%03u; Time in run [s]; Rate [1/s]", uXyterIdx ); - fhFebRateEvoLong.push_back( new TH1D( sHistName, title, - fuLongHistoBinNb, -0.5, uAlignedLimit - 0.5) ); - if( server ) server->Register("/StsRaw", fhFebRateEvoLong[ uXyterIdx ] ); - - sHistName = Form( "hFebChRateEvoLong_%03u", uXyterIdx ); - title = Form( "Mean rate per channel VS run time in StsXyter #%03u; Time in run [s]; Channel []; Rare [1/s]", uXyterIdx ); - fhFebChRateEvoLong.push_back( new TH2D( sHistName, title, - fuLongHistoBinNb, -0.5, uAlignedLimit - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - if( server ) server->Register("/StsRaw", fhFebChRateEvoLong[ uXyterIdx ] ); - } // if( kTRUE == fbLongHistoEnable ) -*/ - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// -/* - UInt_t uNbBinEvo = 32768 + 1; - Double_t dMaxEdgeEvo = stsxyter::kdClockCycleNs - * static_cast< Double_t >( uNbBinEvo ) / 2.0; - Double_t dMinEdgeEvo = dMaxEdgeEvo * -1.0; - - UInt_t uNbBinDtHodo = static_cast<UInt_t>( fdCoincBorderHodo/stsxyter::kdClockCycleNs ); - UInt_t uNbBinDtBothHodo = static_cast<UInt_t>( 2*fdCoincBorderHodo/stsxyter::kdClockCycleNs ); - UInt_t uNbBinDtSts = static_cast<UInt_t>( fdCoincBorderSts/stsxyter::kdClockCycleNs ); - UInt_t uNbBinDtSyst = static_cast<UInt_t>( fdCoincBorder/stsxyter::kdClockCycleNs ); - - /// Coincidences inside each detector ----------------------------/// - sHistName = "fhSetupSortedDtX1Y1"; - title = "Time diff for hits Hodo 1 X and Hodo 1 Y; tY1 - tX1 [ns]; Counts"; - fhSetupSortedDtX1Y1 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhSetupSortedDtX2Y2"; - title = "Time diff for hits Hodo 2 X and Hodo 2 Y; tY2 - tX2 [ns]; Counts"; - fhSetupSortedDtX2Y2 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhSetupSortedDtN1P1"; - title = "Time diff for hits Sts 1 N and Sts 1 P; tP1 - tN1 [ns]; Counts"; - fhSetupSortedDtN1P1 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhSetupSortedDtN2P2"; - title = "Time diff for hits Sts 2 N and Sts 2 P; tP2 - tN2 [ns]; Counts"; - fhSetupSortedDtN2P2 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhSetupSortedDtX1Y1X2Y2"; - title = "Time diff for hits Hodo 1 (X,Y) vs Hodo 2 (X,Y); t<X2,Y2> - t<X1,Y1> [ns]; Counts"; - fhSetupSortedDtX1Y1X2Y2 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhSetupSortedDtN1P1N2P2"; - title = "Time diff for hits STS 1 (N,P) vs STS 2 (N,P); t<N2,P2> - t<N1,P1> [ns]; Counts"; - fhSetupSortedDtN1P1N2P2 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhSetupSortedDtX1Y1X2Y2N1P1"; - title = "Time diff for hits Hodo (X1,Y1,X2,Y2) vs Sts 1 (N,P); t<N1,P1> - t<X1,Y1,X2,Y2> [ns]; Counts"; - fhSetupSortedDtX1Y1X2Y2N1P1 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhSetupSortedDtX1Y1X2Y2N2P2"; - title = "Time diff for hits Hodo (X1,Y1,X2,Y2) vs Sts 2 (N,P); t<N2,P2> - t<X1,Y1,X2,Y2> [ns]; Counts"; - fhSetupSortedDtX1Y1X2Y2N2P2 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhSetupSortedDtH1H2S1S2"; - title = "Time diff for hits Hodo (X1,Y1,X2,Y2) vs Sts (N1,P1,N2,P2); t<N1,P1,N2,P2> - t<X1,Y1,X2,Y2> [ns]; Counts"; - fhSetupSortedDtH1H2S1S2 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhSetupSortedMapX1Y1"; - title = "Sorted hits in coincidence for hodoscope 1 axis X and Y; X channel Hodo 1 []; Y channel Hodo 1 []; hits []"; - fhSetupSortedMapX1Y1 = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhSetupSortedMapX2Y2"; - title = "Sorted hits in coincidence for hodoscope 2 axis X and Y; X channel Hodo 2 []; Y channel Hodo 2 []; hits []"; - fhSetupSortedMapX2Y2 = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhSetupSortedMapN1P1"; - title = "Sorted hits in coincidence for Sts 1 sides N and P; N channel Sts 1 []; P channel Sts 1 []; hits []"; - fhSetupSortedMapN1P1 = new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - - sHistName = "fhSetupSortedMapN2P2"; - title = "Sorted hits in coincidence for Sts 2 sides N and P; N channel Sts 2 []; P channel Sts 2 []; hits []"; - fhSetupSortedMapN2P2 = new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - - // Coincidence counts evolution between some axis of the hodoscopes - sHistName = "hSetupSortedCntEvoX1Y1"; - title = "Nb of coincidences in both X1 and Y1 per s; Time [s]; X1-Y1 coincidences []"; - fhSetupSortedCntEvoX1Y1 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "hSetupSortedCntEvoX2Y2"; - title = "Nb of coincidences in both X2 and Y2 per s; Time [s]; X2-Y2 coincidences []"; - fhSetupSortedCntEvoX2Y2 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "hSetupSortedCntEvoN1P1"; - title = "Nb of coincidences in both N1 and P1 per s; Time [s]; N1-P1 coincidences []"; - fhSetupSortedCntEvoN1P1 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "hSetupSortedCntEvoN2P2"; - title = "Nb of coincidences in both N2 and P2 per s; Time [s]; N2-P2 coincidences []"; - fhSetupSortedCntEvoN2P2 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - /// Coincidences between hodoscopes ------------------------------/// - sHistName = "fhBothHodoSortedDtX1Y1"; - title = "Time diff for hits Hodo 1 X and Hodo 1 Y; tY1 - tX1 [ns]; Counts"; - fhBothHodoSortedDtX1Y1 = new TH1I(sHistName, title, uNbBinDtHodo, -fdCoincBorderHodo, fdCoincBorderHodo ); - - sHistName = "fhBothHodoSortedDtX2Y2"; - title = "Time diff for hits Hodo 2 X and Hodo 2 Y; tY2 - tX2 [ns]; Counts"; - fhBothHodoSortedDtX2Y2 = new TH1I(sHistName, title, uNbBinDtHodo, -fdCoincBorderHodo, fdCoincBorderHodo ); - - sHistName = "fhBothHodoSortedDtX1Y1X2Y2N1P1"; - title = "Time diff for hits Hodo (X1,Y1,X2,Y2) vs Sts 1 (N,P); t<N1,P1> - t<X1,Y1,X2,Y2> [ns]; Counts"; - fhBothHodoSortedDtX1Y1X2Y2N1P1 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhBothHodoSortedDtX1Y1X2Y2N2P2"; - title = "Time diff for hits Hodo (X1,Y1,X2,Y2) vs Sts 2 (N,P); t<N2,P2> - t<X1,Y1,X2,Y2> [ns]; Counts"; - fhBothHodoSortedDtX1Y1X2Y2N2P2 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhBothHodoSortedDtH1H2S1S2"; - title = "Time diff for hits Hodo (X1,Y1,X2,Y2) vs Sts (N1,P1,N2,P2); t<N1,P1,N2,P2> - t<X1,Y1,X2,Y2> [ns]; Counts"; - fhBothHodoSortedDtH1H2S1S2 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhBothHodoSortedMapX1Y1"; - title = "Sorted hits in coincidence for hodoscope 1 axis X and Y; X channel Hodo 1 []; Y channel Hodo 1 []; hits []"; - fhBothHodoSortedMapX1Y1 = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhBothHodoSortedMapX2Y2"; - title = "Sorted hits in coincidence for hodoscope 2 axis X and Y; X channel Hodo 2 []; Y channel Hodo 2 []; hits []"; - fhBothHodoSortedMapX2Y2 = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - // Coincidence counts evolution between some axis of the hodoscopes - sHistName = "hBothHodoSortedCntEvoX1Y1"; - title = "Nb of coincidences in both X1 and Y1 per s; Time [s]; X1-Y1 coincidences []"; - fhBothHodoSortedCntEvoX1Y1 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "hBothHodoSortedCntEvoX2Y2"; - title = "Nb of coincidences in both X2 and Y2 per s; Time [s]; X2-Y2 coincidences []"; - fhBothHodoSortedCntEvoX2Y2 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - /// Coincidences between hodoscopes and STS 1 --------------------/// - sHistName = "fhH1H2S1SortedDtX1Y1"; - title = "Time diff for hits Hodo 1 X and Hodo 1 Y; tY1 - tX1 [ns]; Counts"; - fhH1H2S1SortedDtX1Y1 = new TH1I(sHistName, title, uNbBinDtHodo, -fdCoincBorderHodo, fdCoincBorderHodo ); - - sHistName = "fhH1H2S1SortedDtX2Y2"; - title = "Time diff for hits Hodo 2 X and Hodo 2 Y; tY2 - tX2 [ns]; Counts"; - fhH1H2S1SortedDtX2Y2 = new TH1I(sHistName, title, uNbBinDtHodo, -fdCoincBorderHodo, fdCoincBorderHodo ); - - sHistName = "fhH1H2S1SortedDtN1P1"; - title = "Time diff for hits Sts 1 N and Sts 1 P; tP1 - tN1 [ns]; Counts"; - fhH1H2S1SortedDtN1P1 = new TH1I(sHistName, title, uNbBinDtSts, -fdCoincBorderSts, fdCoincBorderSts ); - - sHistName = "fhH1H2S1SortedDtN2P2"; - title = "Time diff for hits Sts 2 N and Sts 1 P; tP2 - tN2 [ns]; Counts"; - fhH1H2S1SortedDtN2P2 = new TH1I(sHistName, title, uNbBinDtSts, -fdCoincBorderSts, fdCoincBorderSts ); - - sHistName = "fhH1H2S1SortedMapX1Y1"; - title = "Sorted hits in coincidence for hodoscope 1 axis X and Y; X channel Hodo 1 []; Y channel Hodo 1 []; hits []"; - fhH1H2S1SortedMapX1Y1 = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhH1H2S1SortedMapX2Y2"; - title = "Sorted hits in coincidence for hodoscope 2 axis X and Y; X channel Hodo 2 []; Y channel Hodo 2 []; hits []"; - fhH1H2S1SortedMapX2Y2 = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhH1H2S1SortedMapN1P1"; - title = "Sorted hits in coincidence for Sts 1 sides N and P; N channel Sts 1 []; P channel Sts 1 []; hits []"; - fhH1H2S1SortedMapN1P1 = new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - - sHistName = "fhH1H2S1SortedMapN2P2"; - title = "Sorted hits in coincidence for Sts 2 sides N and P; N channel Sts 2 []; P channel Sts 2 []; hits []"; - fhH1H2S1SortedMapN2P2 = new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - - sHistName = "hH1H2S1SortedCntEvoX1Y1"; - title = "Nb of coincidences in both X1 and Y1 per s; Time [s]; X1-Y1 coincidences []"; - fhH1H2S1SortedCntEvoX1Y1 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "hH1H2S1SortedCntEvoX2Y2"; - title = "Nb of coincidences in both X2 and Y2 per s; Time [s]; X2-Y2 coincidences []"; - fhH1H2S1SortedCntEvoX2Y2 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "hH1H2S1SortedCntEvoN1P1"; - title = "Nb of coincidences in both N1 and P1 per s; Time [s]; N1-P1 coincidences []"; - fhH1H2S1SortedCntEvoN1P1 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "hH1H2S1SortedCntEvoN2P2"; - title = "Nb of coincidences in both N2 and P2 per s; Time [s]; N2-P2 coincidences []"; - fhH1H2S1SortedCntEvoN2P2 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - /// Coincidences between hodoscopes and STS 2 --------------------/// - sHistName = "fhH1H2S2SortedDtX1Y1"; - title = "Time diff for hits Hodo 1 X and Hodo 1 Y; tY1 - tX1 [ns]; Counts"; - fhH1H2S2SortedDtX1Y1 = new TH1I(sHistName, title, uNbBinDtHodo, -fdCoincBorderHodo, fdCoincBorderHodo ); - - sHistName = "fhH1H2S2SortedDtX2Y2"; - title = "Time diff for hits Hodo 2 X and Hodo 2 Y; tY2 - tX2 [ns]; Counts"; - fhH1H2S2SortedDtX2Y2 = new TH1I(sHistName, title, uNbBinDtHodo, -fdCoincBorderHodo, fdCoincBorderHodo ); - - sHistName = "fhH1H2S2SortedDtN1P1"; - title = "Time diff for hits Sts 1 N and Sts 1 P; tP1 - tN1 [ns]; Counts"; - fhH1H2S2SortedDtN1P1 = new TH1I(sHistName, title, uNbBinDtSts, -fdCoincBorderSts, fdCoincBorderSts ); - - sHistName = "fhH1H2S2SortedDtN2P2"; - title = "Time diff for hits Sts 2 N and Sts 1 P; tP2 - tN2 [ns]; Counts"; - fhH1H2S2SortedDtN2P2 = new TH1I(sHistName, title, uNbBinDtSts, -fdCoincBorderSts, fdCoincBorderSts ); - - sHistName = "fhH1H2S2SortedMapX1Y1"; - title = "Sorted hits in coincidence for hodoscope 1 axis X and Y; X channel Hodo 1 []; Y channel Hodo 1 []; hits []"; - fhH1H2S2SortedMapX1Y1 = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhH1H2S2SortedMapX2Y2"; - title = "Sorted hits in coincidence for hodoscope 2 axis X and Y; X channel Hodo 2 []; Y channel Hodo 2 []; hits []"; - fhH1H2S2SortedMapX2Y2 = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhH1H2S2SortedMapN1P1"; - title = "Sorted hits in coincidence for Sts 1 sides N and P; N channel Sts 1 []; P channel Sts 1 []; hits []"; - fhH1H2S2SortedMapN1P1 = new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - - sHistName = "fhH1H2S2SortedMapN2P2"; - title = "Sorted hits in coincidence for Sts 2 sides N and P; N channel Sts 2 []; P channel Sts 2 []; hits []"; - fhH1H2S2SortedMapN2P2 = new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - - sHistName = "hH1H2S2SortedCntEvoX1Y1"; - title = "Nb of coincidences in both X1 and Y1 per s; Time [s]; X1-Y1 coincidences []"; - fhH1H2S2SortedCntEvoX1Y1 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "hH1H2S2SortedCntEvoX2Y2"; - title = "Nb of coincidences in both X2 and Y2 per s; Time [s]; X2-Y2 coincidences []"; - fhH1H2S2SortedCntEvoX2Y2 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "hH1H2S2SortedCntEvoN1P1"; - title = "Nb of coincidences in both N1 and P1 per s; Time [s]; N1-P1 coincidences []"; - fhH1H2S2SortedCntEvoN1P1 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "hH1H2S2SortedCntEvoN2P2"; - title = "Nb of coincidences in both N2 and P2 per s; Time [s]; N2-P2 coincidences []"; - fhH1H2S2SortedCntEvoN2P2 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - /// Coincidences between hodoscopes and both STS -----------------/// - sHistName = "fhSystSortedDtX1Y1"; - title = "Time diff for hits Hodo 1 X and Hodo 1 Y; tY1 - tX1 [ns]; Counts"; - fhSystSortedDtX1Y1 = new TH1I(sHistName, title, uNbBinDtHodo, -fdCoincBorderHodo, fdCoincBorderHodo ); - - sHistName = "fhSystSortedDtX2Y2"; - title = "Time diff for hits Hodo 2 X and Hodo 2 Y; tY2 - tX2 [ns]; Counts"; - fhSystSortedDtX2Y2 = new TH1I(sHistName, title, uNbBinDtHodo, -fdCoincBorderHodo, fdCoincBorderHodo ); - - sHistName = "fhSystSortedDtN1P1"; - title = "Time diff for hits Sts 1 N and Sts 1 P; tP1 - tN1 [ns]; Counts"; - fhSystSortedDtN1P1 = new TH1I(sHistName, title, uNbBinDtSts, -fdCoincBorderSts, fdCoincBorderSts ); - - sHistName = "fhSystSortedDtN2P2"; - title = "Time diff for hits Sts 2 N and Sts 1 P; tP2 - tN2 [ns]; Counts"; - fhSystSortedDtN2P2 = new TH1I(sHistName, title, uNbBinDtSts, -fdCoincBorderSts, fdCoincBorderSts ); - - sHistName = "fhSystSortedDtX1Y1X2Y2"; - title = "Time diff for hits Hodo 1 (X,Y) vs Hodo 2 (X,Y); t<X2,Y2> - t<X1,Y1> [ns]; Counts"; - fhSystSortedDtX1Y1X2Y2 = new TH1I(sHistName, title, uNbBinDtBothHodo, -2*fdCoincBorderHodo, 2*fdCoincBorderHodo ); - - sHistName = "fhSystSortedMapX1Y1"; - title = "Sorted hits in coincidence for hodoscope 1 axis X and Y; X channel Hodo 1 []; Y channel Hodo 1 []; hits []"; - fhSystSortedMapX1Y1 = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhSystSortedMapX2Y2"; - title = "Sorted hits in coincidence for hodoscope 2 axis X and Y; X channel Hodo 2 []; Y channel Hodo 2 []; hits []"; - fhSystSortedMapX2Y2 = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhSystSortedMapN1P1"; - title = "Sorted hits in coincidence for Sts 1 sides N and P; N channel Sts 1 []; P channel Sts 1 []; hits []"; - fhSystSortedMapN1P1 = new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - - sHistName = "fhSystSortedMapN2P2"; - title = "Sorted hits in coincidence for Sts 2 sides N and P; N channel Sts 2 []; P channel Sts 2 []; hits []"; - fhSystSortedMapN2P2 = new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - - // Coincidence counts evolution between some axis of the hodoscopes - sHistName = "hSystSortedCntEvoX1Y1"; - title = "Nb of coincidences in both X1 and Y1 per s; Time [s]; X1-Y1 coincidences []"; - fhSystSortedCntEvoX1Y1 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "hSystSortedCntEvoX2Y2"; - title = "Nb of coincidences in both X2 and Y2 per s; Time [s]; X2-Y2 coincidences []"; - fhSystSortedCntEvoX2Y2 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "hSystSortedCntEvoN1P1"; - title = "Nb of coincidences in both N1 and P1 per s; Time [s]; N1-P1 coincidences []"; - fhSystSortedCntEvoN1P1 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "hSystSortedCntEvoN2P2"; - title = "Nb of coincidences in both N2 and P2 per s; Time [s]; N2-P2 coincidences []"; - fhSystSortedCntEvoN2P2 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "fhSystSortedDtN1X1vsN1X2"; - title = "Time diff (N1 vs X1) vs (N1 vs X2); tN1 - tX1 [ns]; tN1 - tX2 [ns]; Counts"; - fhSystSortedDtN1X1vsN1X2 = new TH2I(sHistName, title, 200, -400, 400, 200, -400, 400 ); - - sHistName = "fhSystSortedDtP1X1vsP1X2"; - title = "Time diff (P1 vs X1) vs (P1 vs X2); tP1 - tX1 [ns]; tP1 - tX2 [ns]; Counts"; - fhSystSortedDtP1X1vsP1X2 = new TH2I(sHistName, title, 200, -400, 400, 200, -400, 400 ); - - sHistName = "fhSystSortedDtN1X1vsP1X1"; - title = "Time diff (N1 vs X1) vs (P1 vs X1); tN1 - tX1 [ns]; tP1 - tX1 [ns]; Counts"; - fhSystSortedDtN1X1vsP1X1 = new TH2I(sHistName, title, 200, -400, 400, 200, -400, 400 ); - - sHistName = "fhSystSortedDtSts1Hodo1vsSts1Hodo2"; - title = "Time diff (Sts1 vs Hodo1) vs (Sts1 vs Hodo2); t<N1,P1> - t<X1,Y1> [ns]; t<N1,P1> - t<X2,Y2> [ns]; Counts"; - fhSystSortedDtSts1Hodo1vsSts1Hodo2 = new TH2I(sHistName, title, 200, -400, 400, 200, -400, 400 ); - - sHistName = "fhSystSortedDtSts2Hodo1vsSts2Hodo2"; - title = "Time diff (Sts2 vs Hodo1) vs (Sts2 vs Hodo2); t<N2,P2> - t<X1,Y1> [ns]; t<N2,P2> - t<X2,Y2> [ns]; Counts"; - fhSystSortedDtSts2Hodo1vsSts2Hodo2 = new TH2I(sHistName, title, 200, -400, 400, 200, -400, 400 ); - - sHistName = "fhSystSortedDtAllVsMapX1"; - title = "Time diff Hodo (X1,Y1,X2,Y2) Sts 1 (N,P) vs Hodo 1 axis X; t<N1,P1> - t<X1,Y1,X2,Y2> [ns]; X channel Hodo 1 []; hits []"; - fhSystSortedDtAllVsMapX1 = new TH2I( sHistName, title, - static_cast< Int_t >(2*fdCoincBorder), -fdCoincBorder, fdCoincBorder, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhSystSortedDtAllVsMapY1"; - title = "Time diff Hodo (X1,Y1,X2,Y2) Sts 1 (N,P) vs Hodo 1 axis Y; t<N1,P1> - t<X1,Y1,X2,Y2> [ns]; Y channel Hodo 1 []; hits []"; - fhSystSortedDtAllVsMapY1 = new TH2I( sHistName, title, - static_cast< Int_t >(2*fdCoincBorder), -fdCoincBorder, fdCoincBorder, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhSystSortedDtAllVsMapX2"; - title = "Time diff Hodo (X1,Y1,X2,Y2) Sts 1 (N,P) vs Hodo 2 axis X; t<N1,P1> - t<X1,Y1,X2,Y2> [ns]; X channel Hodo 2 []; hits []"; - fhSystSortedDtAllVsMapX2 = new TH2I( sHistName, title, - static_cast< Int_t >(2*fdCoincBorder), -fdCoincBorder, fdCoincBorder, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhSystSortedDtAllVsMapY2"; - title = "Time diff Hodo (X1,Y1,X2,Y2) Sts 1 (N,P) vs Hodo 2 axis Y; t<N1,P1> - t<X1,Y1,X2,Y2> [ns]; Y channel Hodo 2 []; hits []"; - fhSystSortedDtAllVsMapY2 = new TH2I( sHistName, title, - static_cast< Int_t >(2*fdCoincBorder), -fdCoincBorder, fdCoincBorder, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - sHistName = "fhSetupSortedDtX1"; - title = "Time diff for consecutive hits in Hodo 1 X; tX1n - tX1 [ns]; Counts"; - fhSetupSortedDtX1 = new TH1I(sHistName, title, uNbBinEvo, -0.5, 2*dMaxEdgeEvo -0.5 ); - - sHistName = "fhSetupSortedDtY1"; - title = "Time diff for consecutive hits in Hodo 1 Y; tY1n - tY1 [ns]; Counts"; - fhSetupSortedDtY1 = new TH1I(sHistName, title, uNbBinEvo, -0.5, 2*dMaxEdgeEvo -0.5); - - sHistName = "fhSetupSortedDtX2"; - title = "Time diff for consecutive hits in Hodo 2 X; tX2n - tX2 [ns]; Counts"; - fhSetupSortedDtX2 = new TH1I(sHistName, title, uNbBinEvo, -0.5, 2*dMaxEdgeEvo -0.5); - - sHistName = "fhSetupSortedDtY2"; - title = "Time diff for consecutive hits in Hodo 2 Y; tY2n - tY2 [ns]; Counts"; - fhSetupSortedDtY2 = new TH1I(sHistName, title, uNbBinEvo, -0.5, 2*dMaxEdgeEvo -0.5); - - sHistName = "fhSetupSortedDtN1"; - title = "Time diff for consecutive hits in Sts 1 Y; tN1n - tN1 [ns]; Counts"; - fhSetupSortedDtN1 = new TH1I(sHistName, title, uNbBinEvo, -0.5, 2*dMaxEdgeEvo -0.5); - - sHistName = "fhSetupSortedDtP1"; - title = "Time diff for consecutive hits in Sts 1 Y; tP1n - tP1 [ns]; Counts"; - fhSetupSortedDtP1 = new TH1I(sHistName, title, uNbBinEvo, -0.5, 2*dMaxEdgeEvo -0.5); - - sHistName = "fhSetupSortedDtN2"; - title = "Time diff for consecutive hits in Sts 1 Y; tN2n - tN2 [ns]; Counts"; - fhSetupSortedDtN2 = new TH1I(sHistName, title, uNbBinEvo, -0.5, 2*dMaxEdgeEvo -0.5); - - sHistName = "fhSetupSortedDtP2"; - title = "Time diff for consecutive hits in Sts 1 Y; tP2n - tP2 [ns]; Counts"; - fhSetupSortedDtP2 = new TH1I(sHistName, title, uNbBinEvo, -0.5, 2*dMaxEdgeEvo -0.5); -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - - -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - Double_t dAdcMinMax = stsxyter::kuHitNbAdcBins + 0.5; - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - sHistName = Form( "fhSetupSortedTsFirstDuplicateChan%02u", uXyterIdx); - title = Form( "TS of first duplicate hit in a burst per channel Asic %02u; Channel []; TS [bin]; Bursts []", uXyterIdx); - fhSetupSortedTsFirstDuplicateChan.push_back( new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - 512, -0.5, 511.5 ) ); - - sHistName = Form( "fhSetupSortedTsGoodChan%02u", uXyterIdx); - title = Form( "TS of non duplicated hits per channel Asic %02u; Channel []; TS [bin]; Bursts []", uXyterIdx); - fhSetupSortedTsGoodChan.push_back( new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - 512, -0.5, 511.5 ) ); - - sHistName = Form( "fhSetupSortedNbSameTsChan%02u", uXyterIdx); - title = Form( "Nb Hits with same TS per second & channel Asic %02u; Time [s]; Channel []; Hits []", uXyterIdx); - fhSetupSortedNbSameTsChan.push_back( new TH2I( sHistName, title, - 1800, 0, 1800, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - - sHistName = Form( "fhSetupSortedSameTsAdcChan%02u", uXyterIdx); - title = Form( "Adc distribution per channel for Hits with same TS Asic %02u; Channel []; Adc []; Hits []", uXyterIdx); - fhSetupSortedSameTsAdcChan.push_back( new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - stsxyter::kuHitNbAdcBins, -0.5, stsxyter::kuHitNbAdcBins -0.5 ) ); - - sHistName = Form( "fhSetupSortedSameTsAdcDiff%02u", uXyterIdx); - title = Form( "Adc difference vs consecutive hit idx per channel for Hits with same TS Asic %02u; Nb same TS before []; Adc diff []; Hits []", uXyterIdx); - fhSetupSortedSameTsAdcDiff.push_back( new TH2I(sHistName, title, - 256, -0.5, 255.5, - 2*dAdcMinMax, -dAdcMinMax, dAdcMinMax ) ); - - sHistName = Form( "fhSetupSortedRatioSameTsChan%02u", uXyterIdx); - title = Form( "Ratio Hits with same TS per second & channel Asic %02u; Time [s]; Channel []; Hits []", uXyterIdx); - fhSetupSortedRatioSameTsChan.push_back( new TProfile2D( sHistName, title, - 1800, 0, 1800, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - - sHistName = Form( "fhSetupSortedNbConsSameTsChan%02u", uXyterIdx); - title = Form( "Nb consecutive Hits with same TS per channel Asic %02u; Channel []; Hits with same TS []; []", uXyterIdx); - fhSetupSortedNbConsSameTsChan.push_back( new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - 256, -0.5, 255.5 ) ); - - sHistName = Form( "fhSetupSortedNbConsSameTsAdcChan%02u", uXyterIdx); - title = Form( "Nb consecutive Hits with same TS and ADC per channel Asic %02u; Channel []; Hits with same TS and ADC []; []", uXyterIdx); - fhSetupSortedNbConsSameTsAdcChan.push_back( new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - 256, -0.5, 255.5 ) ); - - sHistName = Form( "fhSetupSortedNbConsSameTsVsTsAdc%02u", uXyterIdx); - title = Form( "Nb consecutive Hits with same TS vs same TS and ADC Asic %02u; Hits with same TS []; Hits with same TS and ADC []; []", uXyterIdx); - fhSetupSortedNbConsSameTsVsTsAdc.push_back( new TH2I(sHistName, title, - 256, -0.5, 255.5, - 256, -0.5, 255.5 ) ); - - sHistName = Form( "fhSetupSortedAsicRatioSameTsVsFlux%02u", uXyterIdx); - title = Form( "Ratio of hits with same TS vs Hit flux Asic %02u; Hits flux [1/s]; Same Ts / All Hits []; []", uXyterIdx); - fhSetupSortedAsicRatioSameTsVsFlux.push_back( new TH2I(sHistName, title, - iNbBinsRate - 1, dBinsRate, - 101, -0.005, 1.005 ) ); - - sHistName = Form( "fhSetupSortedAsicRatioSameTsAdcVsFlux%02u", uXyterIdx); - title = Form( "Ratio of hits with same TS and ADC vs Hit flux Asic %02u; Hits flux [1/s]; Same Ts and ADC / All Hits []; []", uXyterIdx); - fhSetupSortedAsicRatioSameTsAdcVsFlux.push_back( new TH2I(sHistName, title, - iNbBinsRate - 1, dBinsRate, - 101, -0.005, 1.005 ) ); - - sHistName = Form( "fhSetupSortedAsicRatioSameAdcSameTsVsFlux%02u", uXyterIdx); - title = Form( "Ratio of hits with same ADC among same TS vs Hit flux Asic %02u; Hits flux [1/s]; Same TS and ADC / Same TS []; []", uXyterIdx); - fhSetupSortedAsicRatioSameAdcSameTsVsFlux.push_back( new TH2I(sHistName, title, - iNbBinsRate - 1, dBinsRate, - 101, -0.005, 1.005 ) ); - - sHistName = Form( "fhRatioSameTsSpillEvo%02u", uXyterIdx); - title = Form( "Ratio of hits with same TS Hits vs time Asic %02u; time [s]; channel []; Same Ts / All Hits []; []", uXyterIdx); - fhRatioSameTsSpillEvo.push_back( new TProfile2D(sHistName, title, - 70000, 0, 70.0, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - - sHistName = Form( "fhRatioSameTsAdcSpillEvo%02u", uXyterIdx); - title = Form( "Ratio of hits with same ADC and same TS hits vs time Asic %02u; time [s]; channel []; Same Ts and ADC / All Hits []; []", uXyterIdx); - fhRatioSameTsAdcSpillEvo.push_back( new TProfile2D(sHistName, title, - 70000, 0, 70.0, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - - sHistName = Form( "fhRatioSameAdcSameTsSpillEvo%02u", uXyterIdx); - title = Form( "Ratio of hits with same ADC among same TS vs time Asic %02u; time [s]; channel []; Same TS and ADC / Same TS []; []", uXyterIdx); - fhRatioSameAdcSameTsSpillEvo.push_back( new TProfile2D(sHistName, title, - 70000, 0, 70.0, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - - sHistName = Form( "fhFractionHitsAsicSpillEvo%02u", uXyterIdx); - title = Form( "Fraction of all hits vs time for Asic %02u; time [s]; Hits in Asic %02u []", uXyterIdx, uXyterIdx); - fhFractionHitsAsicSpillEvo.push_back( new TProfile(sHistName, title, 210000, 0, 210.0 ) ); - - sHistName = Form( "fhFractionHitsAsicEvo%02u", uXyterIdx); - title = Form( "Fraction of all hits vs time for Asic %02u; time [s]; Hits in Asic %02u []", uXyterIdx, uXyterIdx); - fhFractionHitsAsicEvo.push_back( new TProfile(sHistName, title, 1800, 0, 1800 ) ); - - // Channel counts - sHistName = Form( "hHodoChanCntGood_%03u", uXyterIdx ); - title = Form( "Good Hits Count per channel, StsXyter #%03u; Channel; Good Hits []", uXyterIdx ); - fhHodoChanCntGood.push_back( new TH1I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - // Hit rates evo per channel - sHistName = Form( "hHodoChanGoodRateEvo_%03u", uXyterIdx ); - title = Form( "Good Hits per second & channel in StsXyter #%03u; Time [s]; Channel []; Good Hits []", uXyterIdx ); - fhHodoChanGoodHitRateEvo.push_back( new TH2I( sHistName, title, - 1800, 0, 1800, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - for( UInt_t uDpbIdx = 0; uDpbIdx < fuNrOfDpbs; ++uDpbIdx ) - { - sHistName = Form( "fhFractionGoodHitsSpillEvo%02u", uDpbIdx); - title = Form( "Fraction of good hits vs time Dpb %02u; time [s]; Good Hits []", uDpbIdx); - fhFractionGoodHitsSpillEvo.push_back( new TProfile(sHistName, title, 300000, 0, 300.0 ) ); - - sHistName = Form( "fhFractionDupliHitsSpillEvo%02u", uDpbIdx); - title = Form( "Fraction of fake hits vs time Dpb %02u; time [s]; Dupli Hits []", uDpbIdx); - fhFractionDupliHitsSpillEvo.push_back( new TProfile(sHistName, title, 300000, 0, 300.0 ) ); - - sHistName = Form( "fhFractionTsMsbSpillEvo%02u", uDpbIdx); - title = Form( "Fraction of TS MSB vs time Dpb %02u; time [s]; TS MSB []", uDpbIdx); - fhFractionTsMsbSpillEvo.push_back( new TProfile(sHistName, title, 300000, 0, 300.0 ) ); - - sHistName = Form( "fhFractionEpochSpillEvo%02u", uDpbIdx); - title = Form( "Fraction of Epoch vs time Dpb %02u; time [s]; Epoch []", uDpbIdx); - fhFractionEpochSpillEvo.push_back( new TProfile(sHistName, title, 300000, 0, 300.0 ) ); - - sHistName = Form( "fhFractionEmptySpillEvo%02u", uDpbIdx); - title = Form( "Fraction of Empty vs time Dpb %02u; time [s]; Empty []", uDpbIdx); - fhFractionEmptySpillEvo.push_back( new TProfile(sHistName, title, 300000, 0, 300.0 ) ); - - sHistName = Form( "fhFractionGoodHitsEvo%02u", uDpbIdx); - title = Form( "Fraction of good hits vs time Dpb %02u; time [s]; Good Hits []", uDpbIdx); - fhFractionGoodHitsEvo.push_back( new TProfile(sHistName, title, 1800, 0, 1800 ) ); - - sHistName = Form( "fhFractionDupliHitsEvo%02u", uDpbIdx); - title = Form( "Fraction of fake hits vs time Dpb %02u; time [s]; Dupli Hits []", uDpbIdx); - fhFractionDupliHitsEvo.push_back( new TProfile(sHistName, title, 1800, 0, 1800 ) ); - - sHistName = Form( "fhFractionTsMsbEvo%02u", uDpbIdx); - title = Form( "Fraction of TS MSB vs time Dpb %02u; time [s]; TS MSB []", uDpbIdx); - fhFractionTsMsbEvo.push_back( new TProfile(sHistName, title, 1800, 0, 1800 ) ); - - sHistName = Form( "fhFractionEpochEvo%02u", uDpbIdx); - title = Form( "Fraction of Epoch vs time Dpb %02u; time [s]; Epoch []", uDpbIdx); - fhFractionEpochEvo.push_back( new TProfile(sHistName, title, 1800, 0, 1800 ) ); - - sHistName = Form( "fhFractionEmptyEvo%02u", uDpbIdx); - title = Form( "Fraction of Empty vs time Dpb %02u; time [s]; Empty []", uDpbIdx); - fhFractionEmptyEvo.push_back( new TProfile(sHistName, title, 1800, 0, 1800 ) ); - } // for( UInt_t uDpbIdx = 0; uDpbIdx < fuNrOfDpbs; ++uDpbIdx ) -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - sHistName = "fhFractionAsics"; - title = "Fraction of all hits per Asic; Asic []; Hits fraction []"; - fhFractionAsics = new TProfile(sHistName, title, fuNbStsXyters, 0, fuNbStsXyters ); - - sHistName = "fhFractionTypes"; - title = "Fraction of data per Type; ; Msg fraction []"; - fhFractionTypes = new TProfile(sHistName, title, 5, 0, 5 ); - fhFractionTypes->GetXaxis()->SetBinLabel( 1, "Good Hit"); - fhFractionTypes->GetXaxis()->SetBinLabel( 2, "Dupli Hit"); - fhFractionTypes->GetXaxis()->SetBinLabel( 3, "TsMsb"); - fhFractionTypes->GetXaxis()->SetBinLabel( 4, "Epoch"); - fhFractionTypes->GetXaxis()->SetBinLabel( 5, "Empty"); -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - sHistName = Form( "fhAsicDuplicDtLastHits%02u", uXyterIdx); - title = "Time diff Between duplicated hit and previous hits; tDupli - tPrevN [bins]; Nth Previous hit [N]"; - fhAsicDuplicDtLastHits.push_back( new TH2I( sHistName, title, - 2048, -0.5, 2047.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - - sHistName = Form( "fhAsicDuplicCompTs%02u", uXyterIdx); - title = "ASIC Compared TS of duplicated hit and previous hits; Nth Previous hit [N]; Comp TS [bin]"; - fhAsicDuplicCompTs.push_back( new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - 128, -0.5, 127.5 ) ); - - sHistName = Form( "fhAsicDuplicTsLsb%02u", uXyterIdx); - title = "TS LSB of duplicated hit and previous hits; Nth Previous hit [N]; TS LSB [bins]"; - fhAsicDuplicTsLsb.push_back( new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - 256, -0.5, 255.5 ) ); - - sHistName = Form( "fhAsicDuplicTsMsbAsic%02u", uXyterIdx); - title = "ASIC TS MSB of duplicated hit and previous hits; Nth Previous hit [N]; TS MSB [bins]"; - fhAsicDuplicTsMsbAsic.push_back( new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - 64, -0.5, 63.5 ) ); - - sHistName = Form( "fhAsicDuplicCompTsBitThere%02u", uXyterIdx); - title = "Bits present in ASIC Compared TS of duplicated hit and N previous hits; Ns Previous hit [N]; Bit"; - fhAsicDuplicCompTsBitThere.push_back( new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - 7, -0.5, 6.5 ) ); - - sHistName = Form( "fhAsicDuplicTsLsbBitThere%02u", uXyterIdx); - title = "Bits present in TS LSB of duplicated hit and N previous hits; Ns Previous hit [N]; Bit"; - fhAsicDuplicTsLsbBitThere.push_back( new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - 8, -0.5, 7.5 ) ); - - sHistName = Form( "fhAsicDuplicTsMsbBitThere%02u", uXyterIdx); - title = "Bits present in ASIC TS MSB of duplicated hit and N previous hits; Ns Previous hit [N]; Bit"; - fhAsicDuplicTsMsbBitThere.push_back( new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - 6, -0.5, 5.5 ) ); - - sHistName = Form( "fhAsicDuplicTs%02u", uXyterIdx); - title = "TS of duplicated hit vs its channel index; Channel []; TS [bins]"; - fhAsicDuplicTs.push_back( new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - 256, -0.5, 255.5 ) ); - - sHistName = Form( "fhAsicGoodTs%02u", uXyterIdx); - title = "TS of good hit vs its channel index; Channel []; TS [bins]"; - fhAsicGoodTs.push_back( new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - 256, -0.5, 255.5 ) ); - - sHistName = Form( "fhAsicDuplicTsMsb%02u", uXyterIdx); - title = "TS MSB of duplicated hit vs its channel index; Channel []; TS_MSB [bins]"; - fhAsicDuplicTsMsb.push_back( new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - 256, -0.5, 255.5 ) ); - - sHistName = Form( "fhAsicGoodTsMsb%02u", uXyterIdx); - title = "TS MSB of good hit vs its channel index; Channel []; TS_MSB [bins]"; - fhAsicGoodTsMsb.push_back( new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - 256, -0.5, 255.5 ) ); - - sHistName = Form( "fhAsicDuplicTsFull%02u", uXyterIdx); - title = "Full TS of duplicated hit vs its channel index; Channel []; TS + TS_MSB [bins]"; - fhAsicDuplicTsFull.push_back( new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - 16384, -0.5, 16383.5 ) ); - - sHistName = Form( "fhAsicGoodTsFull%02u", uXyterIdx); - title = "Full TS of good hit vs its channel index; Channel []; TS + TS_MSB [bins]"; - fhAsicGoodTsFull.push_back( new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - 16384, -0.5, 16383.5 ) ); - - sHistName = Form( "fhAsicDuplicTsBitPattern%02u", uXyterIdx); - title = "Bits pattern in duplicated hit; TS Bit; ON/OFF?"; - fhAsicDuplicTsBitPattern.push_back( new TH2I( sHistName, title, - 14, -0.5, 13.5, - 2, -0.5, 1.5 ) ); - - sHistName = Form( "fhAsicGoodTsBitPattern%02u", uXyterIdx); - title = "Bits pattern in good hit; TS Bit; ON/OFF?"; - fhAsicGoodTsBitPattern.push_back( new TH2I( sHistName, title, - 14, -0.5, 13.5, - 2, -0.5, 1.5 ) ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - sHistName = "fhAsicDuplicTsEvoAsic0Chan01"; - title = "TS of duplicated hits vs time in run for ASIC 0 chan 1; time in run [s]; TS + TS_MSB [bins]"; - fhAsicDuplicTsEvoAsic0Chan01 = new TH2I( sHistName, title, - 2*4096, -0.5, 4095.5, - 2048, -0.5, 4095.5 ); - sHistName = "fhAsicGoodTsEvoAsic0Chan01"; - title = "TS of good hits vs time in run for ASIC 0 chan 1; time in run [s]; TS + TS_MSB [bins]"; - fhAsicGoodTsEvoAsic0Chan01 = new TH2I( sHistName, title, - 2*4096, -0.5, 4095.5, - 2048, -0.5, 4095.5 ); - sHistName = "fhAsicGoodTsMsbEvoAsic0Chan01"; - title = "TS MSB of good hits vs time in run for ASIC 0 chan 1; time in run [s]; TS_MSB[0 - 7] [bins]"; - fhAsicGoodTsMsbEvoAsic0Chan01 = new TH2I( sHistName, title, - 2*4096, -0.5, 4095.5, - 256, -0.5, 255.5 ); - sHistName = "fhAsicGoodTsFullEvoAsic0Chan01"; - title = "Full TS of good hits vs time in run for ASIC 0 chan 1; time in run [s]; TS + TS_MSB [bins]"; - fhAsicGoodTsFullEvoAsic0Chan01 = new TH2I( sHistName, title, - 4*900, -0.5, 899.5, - 16384, -0.5, 16383.5 ); - sHistName = "fhAsicGoodTsFullEvoProfAsic0Chan01"; - title = "Full TS of good hits vs time in run for ASIC 0 chan 1; time in run [s]; TS + TS_MSB [bins]"; - fhAsicGoodTsFullEvoProfAsic0Chan01 = new TProfile( sHistName, title, - 4*3600, -0.5, 3599.5 ); - - sHistName = "fhAsicDuplicTsEvoAsic0Chan09"; - title = "TS of duplicated hits vs time in run for ASIC 0 chan 9; time in run [s]; TS + TS_MSB [bins]"; - fhAsicDuplicTsEvoAsic0Chan09 = new TH2I( sHistName, title, - 2*4096, -0.5, 4095.5, - 2048, -0.5, 4095.5 ); - sHistName = "fhAsicGoodTsEvoAsic0Chan09"; - title = "TS of good hits vs time in run for ASIC 0 chan 9; time in run [s]; TS + TS_MSB [bins]"; - fhAsicGoodTsEvoAsic0Chan09 = new TH2I( sHistName, title, - 2*4096, -0.5, 4095.5, - 2048, -0.5, 4095.5 ); - sHistName = "fhAsicGoodTsFullEvoProfAsic0Chan09"; - title = "Full TS of good hits vs time in run for ASIC 0 chan 9; time in run [s]; TS + TS_MSB [bins]"; - fhAsicGoodTsFullEvoProfAsic0Chan09 = new TProfile( sHistName, title, - 4*3600, -0.5, 3599.5 ); - - sHistName = "fhAsicDuplicTsEvoAsic0Chan16"; - title = "TS of duplicated hits vs time in run for ASIC 0 chan 16; time in run [s]; TS + TS_MSB [bins]"; - fhAsicDuplicTsEvoAsic0Chan16 = new TH2I( sHistName, title, - 2*4096, -0.5, 4095.5, - 2048, -0.5, 4095.5 ); - sHistName = "fhAsicGoodTsEvoAsic0Chan16"; - title = "TS of good hits vs time in run for ASIC 0 chan 16; time in run [s]; TS + TS_MSB [bins]"; - fhAsicGoodTsEvoAsic0Chan16 = new TH2I( sHistName, title, - 2*4096, -0.5, 4095.5, - 2048, -0.5, 4095.5 ); - sHistName = "fhAsicGoodTsFullEvoProfAsic0Chan16"; - title = "Full TS of good hits vs time in run for ASIC 0 chan 16; time in run [s]; TS + TS_MSB [bins]"; - fhAsicGoodTsFullEvoProfAsic0Chan16 = new TProfile( sHistName, title, - 4*3600, -0.5, 3599.5 ); - - - sHistName = "fhAsicMissedChanIdVsPulseIdx"; - title = "Channels present VS pulse Idx; Pulse Idx []; Channel Id []"; - fhAsicMissedChanIdVsPulseIdx = new TH2I( sHistName, title, - fuPulseIdxMax, -0.5, fuPulseIdxMax - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - - sHistName = "fhAsicMissedChanGroupVsPulseIdx"; - title = "Channels group present VS pulse Idx; Pulse Idx []; Channel Grp []"; - fhAsicMissedChanGroupVsPulseIdx = new TProfile( sHistName, title, - fuPulseIdxMax, -0.5, fuPulseIdxMax - 0.5 ); - - -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - sHistName = "fhHodoX1SpillEvo"; - title = "Hodo X1 counts vs time in spill; time [s]; X1 channel []; Hits []"; - fhHodoX1SpillEvo = new TH2I(sHistName, title, - 70000, 0, 70.0, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhHodoY1SpillEvo"; - title = "Hodo Y1 counts vs time in spill; time [s]; Y1 channel []; Hits []"; - fhHodoY1SpillEvo = new TH2I(sHistName, title, - 70000, 0, 70.0, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - sHistName = "fhHodoX2SpillEvo"; - title = "Hodo X2 counts vs time in spill; time [s]; X2 channel []; Hits []"; - fhHodoX2SpillEvo = new TH2I(sHistName, title, - 70000, 0, 70.0, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - sHistName = "fhHodoY2SpillEvo"; - title = "Hodo Y2 counts vs time in spill; time [s]; Y2 channel []; Hits []"; - fhHodoY2SpillEvo = new TH2I(sHistName, title, - 70000, 0, 70.0, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhHodoX1SpillEvoProf"; - title = "Hodo X1 counts vs time in spill; time [s]; X1 channel []; Hits []"; - fhHodoX1SpillEvoProf = new TProfile(sHistName, title, - 10*fdSpillEvoLength, 0, fdSpillEvoLength); - - sHistName = "fhHodoY1SpillEvoProf"; - title = "Hodo Y1 counts vs time in spill; time [s]; Y1 channel []; Hits []"; - fhHodoY1SpillEvoProf = new TProfile(sHistName, title, - 10*fdSpillEvoLength, 0, fdSpillEvoLength); - sHistName = "fhHodoX2SpillEvoProf"; - title = "Hodo X2 counts vs time in spill; time [s]; X2 channel []; Hits []"; - fhHodoX2SpillEvoProf = new TProfile(sHistName, title, - 10*fdSpillEvoLength, 0, fdSpillEvoLength); - sHistName = "fhHodoY2SpillEvoProf"; - title = "Hodo Y2 counts vs time in spill; time [s]; Y2 channel []; Hits []"; - fhHodoY2SpillEvoProf = new TProfile(sHistName, title, - 10*fdSpillEvoLength, 0, fdSpillEvoLength); - -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - sHistName = Form( "fhPulseChanCountEvo%02u", uXyterIdx); - title = Form( "Number of channels per pulse vs time for ASIC %02u; time [s]; Channels []; Pulses []", uXyterIdx); - fhPulseChanCountEvo.push_back( new TH2D( sHistName, title, - 300, 0, 300.0, - fuNbChanPerAsic, 0.5, fuNbChanPerAsic + 0.5 ) ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// -*/ - sHistName = "fhHodoChanHitRateEvoZoom"; - title = "Hits per second & channel in StsXyter 000; Time [s]; Channel []; Hits []"; - fhHodoChanHitRateEvoZoom = new TH2I( sHistName, title, - 2000, 0, 50, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - -/** STSXYTER v2.0 Bug, triggering condition detection **/ - sHistName = "hCoincWinFlagEvo"; - title = "Evolution of STSXYTER v2.0 bug triggering condition flag; Time [s]; ASIC []; CoincWin flag [];"; - fhCoincWinFlagEvo = new TProfile2D( sHistName, title, - 3600, 0, 1800, - fuNbStsXyters, -0.5, fuNbStsXyters - 0.5 ); - sHistName = "hCoincWinFlagEvoImpr2"; - fhCoincWinFlagEvoImpr2 = new TProfile2D( sHistName, title, - 3600, 0, 1800, - fuNbStsXyters, -0.5, fuNbStsXyters - 0.5 ); - sHistName = "hCoincWinFlagEvoMoreCond"; - fhCoincWinFlagEvoMoreCond = new TProfile2D( sHistName, title, - 3600, 0, 1800, - fuNbStsXyters, -0.5, fuNbStsXyters - 0.5 ); - sHistName = "hCoincWinFlagEntriesEvoOn"; - title = "Evolution of STSXYTER v2.0 bug triggering condition flag; Time [s]; ASIC []; Entries [];"; - fhCoincWinFlagEntriesEvoOn = new TH2D( sHistName, title, - 1000, 0, 1000, - fuNbStsXyters, -0.5, fuNbStsXyters - 0.5 ); - sHistName = "hCoincWinFlagEntriesEvoOff"; - title = "Evolution of STSXYTER v2.0 bug triggering condition flag; Time [s]; ASIC []; Entries [];"; - fhCoincWinFlagEntriesEvoOff = new TH2D( sHistName, title, - 1000, 0, 1000, - fuNbStsXyters, -0.5, fuNbStsXyters - 0.5 ); - - sHistName = "hCoincWinFlagDiffEvo"; - title = "Evolution of STSXYTER v2.0 bug triggering condition flag; Time [s]; ASIC []; Entries [];"; - fhCoincWinFlagDiffEvo = new TH2D( sHistName, title, - 1000, 0, 1000, - 1500, 0, 6000 ); - - - sHistName = "hCoincWinFlagEntriesEvoOnA"; - title = "Evolution of STSXYTER v2.0 bug triggering condition flag; Time [s]; ASIC []; Entries [];"; - fhCoincWinFlagEntriesEvoOnA = new TH2D( sHistName, title, - 1000, 0, 1000, - fuNbStsXyters, -0.5, fuNbStsXyters - 0.5 ); - sHistName = "hCoincWinFlagEntriesEvoOffA"; - title = "Evolution of STSXYTER v2.0 bug triggering condition flag; Time [s]; ASIC []; Entries [];"; - fhCoincWinFlagEntriesEvoOffA = new TH2D( sHistName, title, - 1000, 0, 1000, - fuNbStsXyters, -0.5, fuNbStsXyters - 0.5 ); - - - sHistName = "hCoincWinFlagEntriesEvoOnB"; - title = "Evolution of STSXYTER v2.0 bug triggering condition flag; Time [s]; ASIC []; Entries [];"; - fhCoincWinFlagEntriesEvoOnB = new TH2D( sHistName, title, - 1000, 0, 1000, - fuNbStsXyters, -0.5, fuNbStsXyters - 0.5 ); - sHistName = "hCoincWinFlagEntriesEvoOffB"; - title = "Evolution of STSXYTER v2.0 bug triggering condition flag; Time [s]; ASIC []; Entries [];"; - fhCoincWinFlagEntriesEvoOffB = new TH2D( sHistName, title, - 1000, 0, 1000, - fuNbStsXyters, -0.5, fuNbStsXyters - 0.5 ); - - - sHistName = "hCoincWinFlagEntriesEvoOnC"; - title = "Evolution of STSXYTER v2.0 bug triggering condition flag; Time [s]; ASIC []; Entries [];"; - fhCoincWinFlagEntriesEvoOnC = new TH2D( sHistName, title, - 1000, 0, 1000, - fuNbStsXyters, -0.5, fuNbStsXyters - 0.5 ); - sHistName = "hCoincWinFlagEntriesEvoOffC"; - title = "Evolution of STSXYTER v2.0 bug triggering condition flag; Time [s]; ASIC []; Entries [];"; - fhCoincWinFlagEntriesEvoOffC = new TH2D( sHistName, title, - 1000, 0, 1000, - fuNbStsXyters, -0.5, fuNbStsXyters - 0.5 ); - - - sHistName = "hCoincWinFlagDiffEvoA2"; - title = "Evolution of STSXYTER v2.0 bug triggering condition flag; Time [s]; ASIC []; Entries [];"; - fhCoincWinFlagDiffEvoA2 = new TH2D( sHistName, title, - 1000, 0, 1000, - 1500, 0, 12000 ); - sHistName = "hCoincWinFlagDiffEvoB2"; - title = "Evolution of STSXYTER v2.0 bug triggering condition flag; Time [s]; ASIC []; Entries [];"; - fhCoincWinFlagDiffEvoB2 = new TH2D( sHistName, title, - 1000, 0, 1000, - 1500, 0, 12000 ); - sHistName = "hCoincWinFlagDiffEvoC2"; - title = "Evolution of STSXYTER v2.0 bug triggering condition flag; Time [s]; ASIC []; Entries [];"; - fhCoincWinFlagDiffEvoC2 = new TH2D( sHistName, title, - 1000, 0, 1000, - 1500, 0, 12000 ); - ///add below - sHistName = "hBadWinRatio"; - title = "Bad ratio in all STSXyters; Time in Run [s]; \"Bad\" ratio []"; - fhBadWinRatio = new TProfile( sHistName, title, - 3600, 0, 3600); - - sHistName = "fhBadDataRatio"; - title = "Bad data weighted ratio in all STSXyters; Time in Run [s]; \"Bad data\" ratio []"; - fhBadDataRatio = new TProfile( sHistName, title, - 3600, 0, 3600); - ///add above -/** STSXYTER v2.0 Bug, triggering condition detection **/ - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - sHistName = Form( "hNbFiredChanPerMs%02u", uXyterIdx); - title = Form( "Number of channels fired per MS vs time for ASIC %02u; time [s]; Fired Channels []; MS []", uXyterIdx); - fhNbFiredChanPerMs.push_back( new TH2D( sHistName, title, - 3600, 0, 1800, - fuNbChanPerAsic, 0.5, fuNbChanPerAsic + 0.5 ) ); - - sHistName = Form( "hNbMultiHitChanPerMs%02u", uXyterIdx); - title = Form( "Number of channels with copied hits per MS vs time for ASIC %02u; time [s]; Channels with copies []; MS []", uXyterIdx); - fhNbMultiHitChanPerMs.push_back( new TH2D( sHistName, title, - 3600, 0, 1800, - fuNbChanPerAsic, 0.5, fuNbChanPerAsic + 0.5 ) ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - - -/* - // Distribution of the TS_MSB per StsXyter - sHistName = "hHodoFebTsMsb"; - title = "Raw Timestamp Msb distribution per StsXyter; Ts MSB []; StsXyter []; Hits []"; - fhHodoFebTsMsb = new TH2I( sHistName, title, stsxyter::kuTsMsbNbTsBins, -0.5, stsxyter::kuTsMsbNbTsBins - 0.5, - fuNbStsXyters, -0.5, fuNbStsXyters - 0.5 ); - if( server ) server->Register("/StsRaw", fhHodoFebTsMsb ); -*/ - // Miscroslice properties histos - for( Int_t component = 0; component < kiMaxNbFlibLinks; component ++ ) - { - fhMsSz[ component ] = NULL; - fhMsSzTime[ component ] = NULL; - } // for( Int_t component = 0; component < kiMaxNbFlibLinks; component ++ ) - - // Online histo browser commands - THttpServer* server = FairRunOnline::Instance()->GetHttpServer(); - if( server ) - { - server->Register("/HodoRaw", fhHodoMessType ); - server->Register("/HodoRaw", fhHodoSysMessType ); - server->Register("/HodoRaw", fhHodoMessTypePerDpb ); - server->Register("/HodoRaw", fhHodoSysMessTypePerDpb ); - server->Register("/HodoRaw", fhHodoMessTypePerElink ); - server->Register("/HodoRaw", fhHodoSysMessTypePerElink ); - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - server->Register("/HodoRaw", fhHodoChanCntRaw[ uXyterIdx ] ); - server->Register("/HodoRaw", fhHodoChanAdcRaw[ uXyterIdx ] ); - server->Register("/HodoRaw", fhHodoChanAdcRawProf[ uXyterIdx ] ); - server->Register("/HodoRaw", fhHodoChanRawTs[ uXyterIdx ] ); - server->Register("/HodoRaw", fhHodoChanMissEvt[ uXyterIdx ] ); - server->Register("/HodoRaw", fhHodoChanMissEvtEvo[ uXyterIdx ] ); - server->Register("/HodoRaw", fhHodoFebMissEvtEvo[ uXyterIdx ] ); - server->Register("/HodoRaw", fhHodoChanHitRateEvo[ uXyterIdx ] ); - server->Register("/HodoRaw", fhHodoFebRateEvo[ uXyterIdx ] ); - server->Register("/HodoRaw", fhHodoChanHitRateEvoLong[ uXyterIdx ] ); - server->Register("/HodoRaw", fhHodoFebRateEvoLong[ uXyterIdx ] ); - - server->Register("/FebDupli", fhNbFiredChanPerMs[ uXyterIdx ] ); - server->Register("/FebDupli", fhNbMultiHitChanPerMs[ uXyterIdx ] ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) -/* - server->Register("/Setup", fhSetupSortedDtX1Y1 ); - server->Register("/Setup", fhSetupSortedDtX2Y2 ); - server->Register("/Setup", fhSetupSortedDtN1P1 ); - server->Register("/Setup", fhSetupSortedDtN2P2 ); - server->Register("/Setup", fhSetupSortedDtX1Y1X2Y2 ); - server->Register("/Setup", fhSetupSortedDtX1Y1X2Y2N1P1 ); - server->Register("/Setup", fhSetupSortedDtX1Y1X2Y2N2P2 ); - server->Register("/Setup", fhSetupSortedDtH1H2S1S2 ); - server->Register("/Setup", fhSetupSortedMapX1Y1 ); - server->Register("/Setup", fhSetupSortedMapX2Y2 ); - server->Register("/Setup", fhSetupSortedMapN1P1 ); - server->Register("/Setup", fhSetupSortedMapN2P2 ); - server->Register("/Setup", fhSetupSortedCntEvoX1Y1 ); - server->Register("/Setup", fhSetupSortedCntEvoX2Y2 ); - server->Register("/Setup", fhSetupSortedCntEvoN1P1 ); - server->Register("/Setup", fhSetupSortedCntEvoN2P2 ); - - server->Register("/HodoBoth", fhBothHodoSortedDtX1Y1 ); - server->Register("/HodoBoth", fhBothHodoSortedDtX2Y2 ); - server->Register("/HodoBoth", fhBothHodoSortedDtX1Y1X2Y2N1P1 ); - server->Register("/HodoBoth", fhBothHodoSortedDtX1Y1X2Y2N2P2 ); - server->Register("/HodoBoth", fhBothHodoSortedMapX1Y1 ); - server->Register("/HodoBoth", fhBothHodoSortedMapX2Y2 ); - server->Register("/HodoBoth", fhBothHodoSortedCntEvoX1Y1 ); - server->Register("/HodoBoth", fhBothHodoSortedCntEvoX2Y2 ); - - server->Register("/H1H2S1", fhH1H2S1SortedDtX1Y1 ); - server->Register("/H1H2S1", fhH1H2S1SortedDtX2Y2 ); - server->Register("/H1H2S1", fhH1H2S1SortedDtN1P1 ); - server->Register("/H1H2S1", fhH1H2S1SortedDtN2P2 ); - server->Register("/H1H2S1", fhH1H2S1SortedMapX1Y1 ); - server->Register("/H1H2S1", fhH1H2S1SortedMapX2Y2 ); - server->Register("/H1H2S1", fhH1H2S1SortedMapN1P1 ); - server->Register("/H1H2S1", fhH1H2S1SortedMapN2P2 ); - server->Register("/H1H2S1", fhH1H2S1SortedCntEvoX1Y1 ); - server->Register("/H1H2S1", fhH1H2S1SortedCntEvoX2Y2 ); - server->Register("/H1H2S1", fhH1H2S1SortedCntEvoN1P1 ); - server->Register("/H1H2S1", fhH1H2S1SortedCntEvoN2P2 ); - - server->Register("/H1H2S2", fhH1H2S2SortedDtX1Y1 ); - server->Register("/H1H2S2", fhH1H2S2SortedDtX2Y2 ); - server->Register("/H1H2S2", fhH1H2S2SortedDtN1P1 ); - server->Register("/H1H2S2", fhH1H2S2SortedDtN2P2 ); - server->Register("/H1H2S2", fhH1H2S2SortedMapX1Y1 ); - server->Register("/H1H2S2", fhH1H2S2SortedMapX2Y2 ); - server->Register("/H1H2S2", fhH1H2S2SortedMapN1P1 ); - server->Register("/H1H2S2", fhH1H2S2SortedMapN2P2 ); - server->Register("/H1H2S2", fhH1H2S2SortedCntEvoX1Y1 ); - server->Register("/H1H2S2", fhH1H2S2SortedCntEvoX2Y2 ); - server->Register("/H1H2S2", fhH1H2S2SortedCntEvoN1P1 ); - server->Register("/H1H2S2", fhH1H2S2SortedCntEvoN2P2 ); - - server->Register("/Syst", fhSystSortedDtX1Y1 ); - server->Register("/Syst", fhSystSortedDtX2Y2 ); - server->Register("/Syst", fhSystSortedDtN1P1 ); - server->Register("/Syst", fhSystSortedDtN2P2 ); - server->Register("/Syst", fhSystSortedDtX1Y1X2Y2 ); - server->Register("/Syst", fhSystSortedMapX1Y1 ); - server->Register("/Syst", fhSystSortedMapX2Y2 ); - server->Register("/Syst", fhSystSortedMapN1P1 ); - server->Register("/Syst", fhSystSortedMapN2P2 ); - server->Register("/Syst", fhSystSortedCntEvoX1Y1 ); - server->Register("/Syst", fhSystSortedCntEvoX2Y2 ); - server->Register("/Syst", fhSystSortedCntEvoN1P1 ); - server->Register("/Syst", fhSystSortedCntEvoN2P2 ); - - server->Register("/Syst", fhSystSortedDtN1X1vsN1X2 ); - server->Register("/Syst", fhSystSortedDtP1X1vsP1X2 ); - server->Register("/Syst", fhSystSortedDtN1X1vsP1X1 ); - server->Register("/Syst", fhSystSortedDtSts1Hodo1vsSts1Hodo2 ); - server->Register("/Syst", fhSystSortedDtSts2Hodo1vsSts2Hodo2 ); - - server->Register("/Syst", fhSystSortedDtAllVsMapX1 ); - server->Register("/Syst", fhSystSortedDtAllVsMapY1 ); - server->Register("/Syst", fhSystSortedDtAllVsMapX2 ); - server->Register("/Syst", fhSystSortedDtAllVsMapY2 ); - - server->Register("/FebDt", fhSetupSortedDtX1 ); - server->Register("/FebDt", fhSetupSortedDtY1 ); - server->Register("/FebDt", fhSetupSortedDtX2 ); - server->Register("/FebDt", fhSetupSortedDtY2 ); - server->Register("/FebDt", fhSetupSortedDtN1 ); - server->Register("/FebDt", fhSetupSortedDtP1 ); - server->Register("/FebDt", fhSetupSortedDtN2 ); - server->Register("/FebDt", fhSetupSortedDtP2 ); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - server->Register("/FebDupli", fhSetupSortedNbSameTsChan[ uXyterIdx ] ); - server->Register("/FebDupli", fhSetupSortedSameTsAdcChan[ uXyterIdx ] ); - server->Register("/FebDupli", fhSetupSortedSameTsAdcDiff[ uXyterIdx ] ); - server->Register("/FebDupli", fhSetupSortedRatioSameTsChan[ uXyterIdx ] ); - server->Register("/FebDupli", fhSetupSortedNbConsSameTsChan[ uXyterIdx ] ); - server->Register("/FebDupli", fhSetupSortedNbConsSameTsAdcChan[ uXyterIdx ] ); - server->Register("/FebDupli", fhSetupSortedNbConsSameTsVsTsAdc[ uXyterIdx ] ); - - server->Register("/FebDupli", fhSetupSortedAsicRatioSameTsVsFlux[ uXyterIdx ] ); - server->Register("/FebDupli", fhSetupSortedAsicRatioSameTsAdcVsFlux[ uXyterIdx ] ); - server->Register("/FebDupli", fhSetupSortedAsicRatioSameAdcSameTsVsFlux[ uXyterIdx ] ); - - server->Register("/FebDupli", fhRatioSameTsSpillEvo[ uXyterIdx ] ); - server->Register("/FebDupli", fhRatioSameTsAdcSpillEvo[ uXyterIdx ] ); - server->Register("/FebDupli", fhRatioSameAdcSameTsSpillEvo[ uXyterIdx ] ); - - server->Register("/FebDupli", fhSetupSortedTsFirstDuplicateChan[ uXyterIdx ] ); - server->Register("/FebDupli", fhSetupSortedTsGoodChan[ uXyterIdx ] ); - - server->Register("/FebDupli", fhAsicDuplicDtLastHits[ uXyterIdx ] ); - server->Register("/FebDupli", fhAsicDuplicCompTs[ uXyterIdx ] ); - server->Register("/FebDupli", fhAsicDuplicTsLsb[ uXyterIdx ] ); - server->Register("/FebDupli", fhAsicDuplicTsMsbAsic[ uXyterIdx ] ); - server->Register("/FebDupli", fhAsicDuplicCompTsBitThere[ uXyterIdx ] ); - server->Register("/FebDupli", fhAsicDuplicTsLsbBitThere[ uXyterIdx ] ); - server->Register("/FebDupli", fhAsicDuplicTsMsbBitThere[ uXyterIdx ] ); - server->Register("/FebDupli", fhAsicDuplicTs[ uXyterIdx ] ); - server->Register("/FebDupli", fhAsicGoodTs[ uXyterIdx ] ); - server->Register("/FebDupli", fhAsicDuplicTsMsb[ uXyterIdx ] ); - server->Register("/FebDupli", fhAsicGoodTsMsb[ uXyterIdx ] ); - server->Register("/FebDupli", fhAsicDuplicTsFull[ uXyterIdx ] ); - server->Register("/FebDupli", fhAsicGoodTsFull[ uXyterIdx ] ); - server->Register("/FebDupli", fhAsicDuplicTsBitPattern[ uXyterIdx ] ); - server->Register("/FebDupli", fhAsicGoodTsBitPattern[ uXyterIdx ] ); - - server->Register("/Data", fhFractionHitsAsicSpillEvo[ uXyterIdx ] ); - server->Register("/Data", fhFractionHitsAsicEvo[ uXyterIdx ] ); - server->Register("/Data", fhHodoChanCntGood[ uXyterIdx ] ); - server->Register("/Data", fhHodoChanGoodHitRateEvo[ uXyterIdx ] ); - - server->Register("/Data", fhPulseChanCountEvo[ uXyterIdx ] ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - - server->Register("/FebDupli", fhAsicDuplicTsEvoAsic0Chan01 ); - server->Register("/FebDupli", fhAsicGoodTsEvoAsic0Chan01 ); - server->Register("/FebDupli", fhAsicGoodTsMsbEvoAsic0Chan01 ); - server->Register("/FebDupli", fhAsicGoodTsFullEvoAsic0Chan01 ); - server->Register("/FebDupli", fhAsicGoodTsFullEvoProfAsic0Chan01 ); - server->Register("/FebDupli", fhAsicDuplicTsEvoAsic0Chan09 ); - server->Register("/FebDupli", fhAsicGoodTsEvoAsic0Chan09 ); - server->Register("/FebDupli", fhAsicGoodTsFullEvoProfAsic0Chan09 ); - server->Register("/FebDupli", fhAsicDuplicTsEvoAsic0Chan16 ); - server->Register("/FebDupli", fhAsicGoodTsEvoAsic0Chan16 ); - server->Register("/FebDupli", fhAsicGoodTsFullEvoProfAsic0Chan16 ); - - server->Register("/FebDupli", fhAsicMissedChanIdVsPulseIdx ); - server->Register("/FebDupli", fhAsicMissedChanGroupVsPulseIdx ); - - for( UInt_t uDpbIdx = 0; uDpbIdx < fuNrOfDpbs; ++uDpbIdx ) - { - server->Register("/Data", fhFractionGoodHitsSpillEvo[ uDpbIdx ] ); - server->Register("/Data", fhFractionDupliHitsSpillEvo[ uDpbIdx ] ); - server->Register("/Data", fhFractionTsMsbSpillEvo[ uDpbIdx ] ); - server->Register("/Data", fhFractionEpochSpillEvo[ uDpbIdx ] ); - server->Register("/Data", fhFractionEmptySpillEvo[ uDpbIdx ] ); - - server->Register("/Data", fhFractionGoodHitsEvo[ uDpbIdx ] ); - server->Register("/Data", fhFractionDupliHitsEvo[ uDpbIdx ] ); - server->Register("/Data", fhFractionTsMsbEvo[ uDpbIdx ] ); - server->Register("/Data", fhFractionEpochEvo[ uDpbIdx ] ); - server->Register("/Data", fhFractionEmptyEvo[ uDpbIdx ] ); - } // for( UInt_t uDpbIdx = 0; uDpbIdx < fuNrOfDpbs; ++uDpbIdx ) - server->Register("/Data", fhFractionAsics ); - server->Register("/Data", fhFractionTypes ); - - server->Register("/Spill", fhHodoX1SpillEvo ); - server->Register("/Spill", fhHodoY1SpillEvo ); - server->Register("/Spill", fhHodoX2SpillEvo ); - server->Register("/Spill", fhHodoY2SpillEvo ); - server->Register("/Spill", fhHodoX1SpillEvoProf ); - server->Register("/Spill", fhHodoY1SpillEvoProf ); - server->Register("/Spill", fhHodoX2SpillEvoProf ); - server->Register("/Spill", fhHodoY2SpillEvoProf ); -*/ - server->Register("/FebDupli", fhHodoChanHitRateEvoZoom ); - -/** STSXYTER v2.0 Bug, triggering condition detection **/ - server->Register("/Tagging", fhCoincWinFlagEvo ); - server->Register("/Tagging", fhCoincWinFlagEvoImpr2 ); - server->Register("/Tagging", fhCoincWinFlagEvoMoreCond ); - server->Register("/Tagging", fhCoincWinFlagEntriesEvoOn ); - server->Register("/Tagging", fhCoincWinFlagEntriesEvoOff ); - server->Register("/Tagging", fhCoincWinFlagDiffEvo ); - server->Register("/Tagging", fhCoincWinFlagEntriesEvoOnA ); - server->Register("/Tagging", fhCoincWinFlagEntriesEvoOffA ); - server->Register("/Tagging", fhCoincWinFlagEntriesEvoOnB ); - server->Register("/Tagging", fhCoincWinFlagEntriesEvoOffB ); - server->Register("/Tagging", fhCoincWinFlagEntriesEvoOnC ); - server->Register("/Tagging", fhCoincWinFlagEntriesEvoOffC ); - server->Register("/Tagging", fhCoincWinFlagDiffEvoA2 ); - server->Register("/Tagging", fhCoincWinFlagDiffEvoB2 ); - server->Register("/Tagging", fhCoincWinFlagDiffEvoC2 ); - server->Register("/Tagging", fhBadWinRatio ); - server->Register("/Tagging", fhBadDataRatio ); -/** STSXYTER v2.0 Bug, triggering condition detection **/ - - - server->RegisterCommand("/Reset_All_Hodo", "bCosy2018ResetScanHistos=kTRUE"); - server->RegisterCommand("/Write_All_Hodo", "bCosy2018WriteScanHistos=kTRUE"); - server->RegisterCommand("/Print_Messages", "bCosy2018PrintMessScanHistos=kTRUE"); - - server->Restrict("/Reset_All_Hodo", "allow=admin"); - server->Restrict("/Write_All_Hodo", "allow=admin"); - } // if( server ) - - /** Create summary Canvases for CERN 2017 **/ - Double_t w = 10; - Double_t h = 10; - - // Summary per StsXyter - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - TCanvas* cStsSumm = new TCanvas( Form("cStsSum_%03u", uXyterIdx ), - Form("Summary plots for StsXyter %03u", uXyterIdx ), - w, h); - cStsSumm->Divide( 2, 2 ); - - cStsSumm->cd(1); - gPad->SetLogy(); - fhHodoChanCntRaw[ uXyterIdx ]->Draw(); - - cStsSumm->cd(2); - gPad->SetLogz(); - fhHodoChanAdcRaw[ uXyterIdx ]->Draw( "colz" ); - - cStsSumm->cd(3); - gPad->SetLogz(); - fhHodoChanHitRateEvo[ uXyterIdx ]->Draw( "colz" ); - - cStsSumm->cd(4); -// gPad->SetLogy(); - fhHodoChanAdcRawProf[ uXyterIdx ]->Draw(); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - -//====================================================================// -/* -//====================================================================// - TCanvas* cSetupSortedDt = new TCanvas( "cSetupSortedDt", - "Hodoscopes coincidence maps", - w, h); - if( kTRUE == fbDualStsEna ) - cSetupSortedDt->Divide( 4, 3 ); - else cSetupSortedDt->Divide( 3, 3 ); - - cSetupSortedDt->cd(1); - gPad->SetGridx(); - gPad->SetLogy(); - fhSetupSortedDtX1Y1->Draw( "" ); - - cSetupSortedDt->cd(2); - gPad->SetGridx(); - gPad->SetLogy(); - fhSetupSortedDtX2Y2->Draw( "" ); - - cSetupSortedDt->cd(3); - gPad->SetGridx(); - gPad->SetLogy(); - fhSetupSortedDtN1P1->Draw( "" ); - - cSetupSortedDt->cd(4 + ( kTRUE == fbDualStsEna ? 1 : 0 ) ); - gPad->SetGridx(); - gPad->SetLogy(); - fhBothHodoSortedDtX1Y1->Draw( "" ); - - cSetupSortedDt->cd(5 + ( kTRUE == fbDualStsEna ? 1 : 0 ) ); - gPad->SetGridx(); - gPad->SetLogy(); - fhBothHodoSortedDtX2Y2->Draw( "" ); - -// cSetupSortedDt->cd(6 + ( kTRUE == fbDualStsEna ? 1 : 0 ) ); -// gPad->SetGridx(); -// gPad->SetLogy(); -// fhSetupSortedDtN1P1->Draw( "" ); - - cSetupSortedDt->cd(7 + ( kTRUE == fbDualStsEna ? 2 : 0 ) ); - gPad->SetGridx(); - gPad->SetLogy(); - fhSystSortedDtX1Y1->Draw( "" ); - - cSetupSortedDt->cd(8 + ( kTRUE == fbDualStsEna ? 2 : 0 ) ); - gPad->SetGridx(); - gPad->SetLogy(); - fhSystSortedDtX2Y2->Draw( "" ); - - cSetupSortedDt->cd(9 + ( kTRUE == fbDualStsEna ? 2 : 0 ) ); - gPad->SetGridx(); - gPad->SetLogy(); - fhSystSortedDtN1P1->Draw( "" ); - - if( kTRUE == fbDualStsEna ) - { - cSetupSortedDt->cd(4); - gPad->SetGridx(); - gPad->SetLogy(); - fhSetupSortedDtN2P2->Draw( "colz" ); - -// cSetupSortedDt->cd(8); -// gPad->SetGridx(); -// gPad->SetLogy(); -// fhSetupSortedDtN2P2->Draw( "colz" ); - - cSetupSortedDt->cd(12); - gPad->SetGridx(); - gPad->SetLogy(); - fhSystSortedDtN2P2->Draw( "colz" ); - } // if( kTRUE == fbDualStsEna ) -//====================================================================// - -//====================================================================// - TCanvas* cSetupSortedMaps = new TCanvas( "cSetupSortedMaps", - "Hodoscopes coincidence maps", - w, h); - - if( kTRUE == fbDualStsEna ) - cSetupSortedMaps->Divide( 4, 3 ); - else cSetupSortedMaps->Divide( 3, 3 ); - - cSetupSortedMaps->cd(1); - gPad->SetLogz(); - fhSetupSortedMapX1Y1->Draw( "colz" ); - - cSetupSortedMaps->cd(2); - gPad->SetLogz(); - fhSetupSortedMapX2Y2->Draw( "colz" ); - - cSetupSortedMaps->cd(3); - gPad->SetLogz(); - fhSetupSortedMapN1P1->Draw( "colz" ); - - cSetupSortedMaps->cd(4 + ( kTRUE == fbDualStsEna ? 1 : 0 ) ); - gPad->SetLogz(); - fhBothHodoSortedMapX1Y1->Draw( "colz" ); - - cSetupSortedMaps->cd(5 + ( kTRUE == fbDualStsEna ? 1 : 0 ) ); - gPad->SetLogz(); - fhBothHodoSortedMapX2Y2->Draw( "colz" ); - -// cSetupSortedMaps->cd(6 + ( kTRUE == fbDualStsEna ? 1 : 0 ) ); -// gPad->SetLogz(); -// fhBothHodoSortedMapN1P1->Draw( "colz" ); - - cSetupSortedMaps->cd(7 + ( kTRUE == fbDualStsEna ? 2 : 0 ) ); - gPad->SetLogz(); - fhSystSortedMapX1Y1->Draw( "colz" ); - - cSetupSortedMaps->cd(8 + ( kTRUE == fbDualStsEna ? 2 : 0 ) ); - gPad->SetLogz(); - fhSystSortedMapX2Y2->Draw( "colz" ); - - cSetupSortedMaps->cd(9 + ( kTRUE == fbDualStsEna ? 2 : 0 ) ); - gPad->SetLogz(); - fhSystSortedMapN1P1->Draw( "colz" ); - - if( kTRUE == fbDualStsEna ) - { - cSetupSortedMaps->cd(4); - gPad->SetLogz(); - fhSetupSortedMapN2P2->Draw( "colz" ); - -// cSetupSortedMaps->cd(8); -// gPad->SetLogz(); -// fhBothHodoSortedMapN2P2->Draw( "colz" ); - - cSetupSortedMaps->cd(12); - gPad->SetLogz(); - fhSystSortedMapN2P2->Draw( "colz" ); - } // if( kTRUE == fbDualStsEna ) -//====================================================================// - -//====================================================================// - TCanvas* cSetupSortedCoincEvo = new TCanvas( "cSetupSortedCoincEvo", - "Hodoscopes coincidence rate evolution", - w, h); - cSetupSortedCoincEvo->Divide( 3, 3 ); - - cSetupSortedCoincEvo->cd(1); - gPad->SetGridy(); - gPad->SetLogy(); - fhSetupSortedCntEvoX1Y1->Draw( "" ); - - cSetupSortedCoincEvo->cd(2); - gPad->SetGridy(); - gPad->SetLogy(); - fhSetupSortedCntEvoX2Y2->Draw( "" ); - - cSetupSortedCoincEvo->cd(3); - gPad->SetGridy(); - gPad->SetLogy(); - fhSetupSortedCntEvoN1P1->Draw( "" ); - - cSetupSortedCoincEvo->cd(4); - gPad->SetGridy(); - gPad->SetLogy(); - fhBothHodoSortedCntEvoX1Y1->Draw( "" ); - - cSetupSortedCoincEvo->cd(5); - gPad->SetGridy(); - gPad->SetLogy(); - fhBothHodoSortedCntEvoX2Y2->Draw( "" ); - -// cSetupSortedCoincEvo->cd(6); -// gPad->SetGridy(); -// gPad->SetLogy(); -// fhSetupSortedCntEvoN1P1->Draw( "" ); - - cSetupSortedCoincEvo->cd(7); - gPad->SetGridy(); - gPad->SetLogy(); - fhSystSortedCntEvoX1Y1->Draw( "" ); - - cSetupSortedCoincEvo->cd(8); - gPad->SetGridy(); - gPad->SetLogy(); - fhSystSortedCntEvoX2Y2->Draw( "" ); - - cSetupSortedCoincEvo->cd(9); - gPad->SetGridy(); - gPad->SetLogy(); - fhSystSortedCntEvoN1P1->Draw( "" ); -//====================================================================// - -//====================================================================// - TCanvas* cSetupCoinQaDt = new TCanvas( "cSetupCoinQaDt", - "Hodoscopes coincidence quality", - w, h); - cSetupCoinQaDt->Divide( 2, 2 ); - - cSetupCoinQaDt->cd(1); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhSystSortedDtN1X1vsN1X2->Draw( "colz" ); - - cSetupCoinQaDt->cd(2); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhSystSortedDtP1X1vsP1X2->Draw( "colz" ); - - cSetupCoinQaDt->cd(3); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhSystSortedDtN1X1vsP1X1->Draw( "colz" ); - - cSetupCoinQaDt->cd(4); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhSystSortedDtSts1Hodo1vsSts1Hodo2->Draw( "colz" ); - -//====================================================================// - TCanvas* cSetupCoinQa = new TCanvas( "cSetupCoinQa", - "Hodoscopes coincidence quality", - w, h); - cSetupCoinQa->Divide( 2, 2 ); - - cSetupCoinQa->cd(1); - gPad->SetLogz(); - fhSystSortedDtAllVsMapX1->Draw( "colz" ); - - cSetupCoinQa->cd(2); - gPad->SetLogz(); - fhSystSortedDtAllVsMapY1->Draw( "colz" ); - - cSetupCoinQa->cd(3); - gPad->SetLogz(); - fhSystSortedDtAllVsMapX2->Draw( "colz" ); - - cSetupCoinQa->cd(4); - gPad->SetLogz(); - fhSystSortedDtAllVsMapY2->Draw( "colz" ); -//====================================================================// - -//====================================================================// - TCanvas* cFebDt = new TCanvas( "cFebDt", - "Hodoscopes coincidence quality", - w, h); - - if( kTRUE == fbDualStsEna ) - cFebDt->Divide( 2, 4 ); - else cFebDt->Divide( 2, 3 ); - - cFebDt->cd(1); - gPad->SetLogy(); - fhSetupSortedDtX1->Draw( "" ); - - cFebDt->cd(2); - gPad->SetLogy(); - fhSetupSortedDtY1->Draw( "" ); - - cFebDt->cd(3); - gPad->SetLogy(); - fhSetupSortedDtX2->Draw( "" ); - - cFebDt->cd(4); - gPad->SetLogy(); - fhSetupSortedDtY2->Draw( "" ); - - cFebDt->cd(5); - gPad->SetLogy(); - fhSetupSortedDtN1->Draw( "" ); - - cFebDt->cd(6); - gPad->SetLogy(); - fhSetupSortedDtP1->Draw( "" ); - - if( kTRUE == fbDualStsEna ) - { - cFebDt->cd(7); - gPad->SetLogy(); - fhSetupSortedDtN2->Draw( "" ); - - cFebDt->cd(8); - gPad->SetLogy(); - fhSetupSortedDtP2->Draw( "" ); - } // if( kTRUE == fbDualStsEna ) -//====================================================================// - -//====================================================================// - TCanvas* cFebSameTs = new TCanvas( "cFebSameTs", - "Hodoscopes coincidence quality", - w, h); - - cFebSameTs->Divide( 2, fuNbStsXyters/2 + fuNbStsXyters%2 ); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - cFebSameTs->cd(1 + uXyterIdx ); - gPad->SetLogz(); - fhSetupSortedNbSameTsChan[ uXyterIdx ]->Draw( "colz" ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) -//====================================================================// - -//====================================================================// - TCanvas* cFebSameTsAdc = new TCanvas( "cFebSameTsAdc", - "Hodoscopes coincidence quality", - w, h); - - cFebSameTsAdc->Divide( 2, fuNbStsXyters/2 + fuNbStsXyters%2 ); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - cFebSameTsAdc->cd(1 + uXyterIdx ); - gPad->SetLogz(); - fhSetupSortedSameTsAdcChan[ uXyterIdx ]->Draw( "colz" ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) -//====================================================================// - -//====================================================================// - TCanvas* cFebDupliVsChan = new TCanvas( "cFebDupliVsChan", - "Hodoscopes coincidence quality", - w, h); - - cFebDupliVsChan->Divide( fuNbStsXyters, 3 ); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - cFebDupliVsChan->cd( 1 + uXyterIdx ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhSetupSortedNbConsSameTsChan[ uXyterIdx ]->Draw( "colz" ); - - cFebDupliVsChan->cd( 1 + fuNbStsXyters +uXyterIdx ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhSetupSortedNbConsSameTsAdcChan[ uXyterIdx ]->Draw( "colz" ); - - cFebDupliVsChan->cd( 1 + 2*fuNbStsXyters + uXyterIdx ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhSetupSortedNbConsSameTsVsTsAdc[ uXyterIdx ]->Draw( "colz" ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) -//====================================================================// - -//====================================================================// - TCanvas* cFebDupliVsRate = new TCanvas( "cFebDupliVsRate", - "Hodoscopes coincidence quality", - w, h); - - cFebDupliVsRate->Divide( fuNbStsXyters, 3 ); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - cFebDupliVsRate->cd( 1 + uXyterIdx ); -// gPad->SetGridx(); -// gPad->SetGridy(); - gPad->SetLogx(); - gPad->SetLogz(); - fhSetupSortedAsicRatioSameTsVsFlux[ uXyterIdx ]->Draw( "colz" ); - - cFebDupliVsRate->cd( 1 + fuNbStsXyters + uXyterIdx ); -// gPad->SetGridx(); -// gPad->SetGridy(); - gPad->SetLogx(); - gPad->SetLogz(); - fhSetupSortedAsicRatioSameTsAdcVsFlux[ uXyterIdx ]->Draw( "colz" ); - - cFebDupliVsRate->cd( 1 + 2*fuNbStsXyters + uXyterIdx ); -// gPad->SetGridx(); -// gPad->SetGridy(); - gPad->SetLogx(); - gPad->SetLogz(); - fhSetupSortedAsicRatioSameAdcSameTsVsFlux[ uXyterIdx ]->Draw( "colz" ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) -//====================================================================// - -//====================================================================// - TCanvas* cDataShares = new TCanvas( "cDataShares", - "Data share per ASIC or type", - w, h); - - cDataShares->Divide( 2 + fuNrOfDpbs, 2 ); - - Color_t colorsList[10] = { kBlue, kRed, kGreen, kMagenta, kYellow, - kGray, kOrange, kCyan, kSpring - 6, kPink +9 }; - - cDataShares->cd( 1 ); - gPad->SetGridx(); - gPad->SetGridy(); - fhFractionAsics->Draw("hist"); - - cDataShares->cd( 2 ); - gPad->SetGridx(); - gPad->SetGridy(); - THStack * stackShareAsicSpill = new THStack( "hsShareAsicSpill", "Fraction of hits for each ASIC" ); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fhFractionHitsAsicSpillEvo[ uXyterIdx ]->SetLineColor( colorsList[uXyterIdx] ); - fhFractionHitsAsicSpillEvo[ uXyterIdx ]->SetFillColor( colorsList[uXyterIdx] ); - - stackShareAsicSpill->Add( fhFractionHitsAsicSpillEvo[ uXyterIdx ] ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - stackShareAsicSpill->Draw( ",hist" ); - - cDataShares->cd( 3 + fuNrOfDpbs ); - gPad->SetGridx(); - gPad->SetGridy(); - fhFractionTypes->Draw("hist"); - - cDataShares->cd( 4 + fuNrOfDpbs ); - gPad->SetGridx(); - gPad->SetGridy(); - THStack * stackShareAsic = new THStack( "hsShareAsic", "Fraction of hits for each ASIC" ); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fhFractionHitsAsicEvo[ uXyterIdx ]->SetLineColor( colorsList[uXyterIdx] ); - fhFractionHitsAsicEvo[ uXyterIdx ]->SetFillColor( colorsList[uXyterIdx] ); - - stackShareAsic->Add( fhFractionHitsAsicEvo[ uXyterIdx ] ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - stackShareAsic->Draw( ",hist" ); - - THStack * stackShareTypesSpill[ fuNrOfDpbs ]; - THStack * stackShareTypes[ fuNrOfDpbs ]; - for( UInt_t uDpbIdx = 0; uDpbIdx < fuNrOfDpbs; ++uDpbIdx ) - { - cDataShares->cd( 3 + uDpbIdx ); - gPad->SetGridx(); - gPad->SetGridy(); - - stackShareTypesSpill[ uDpbIdx ] = new THStack( Form( "hsShareTypes%02uSpill", uDpbIdx), - Form( "Fraction of message types for DPB %02u", uDpbIdx ) ); - - fhFractionGoodHitsSpillEvo[ uDpbIdx ]->SetLineColor( colorsList[ 0 ] ); - fhFractionGoodHitsSpillEvo[ uDpbIdx ]->SetFillColor( colorsList[ 0 ] ); - stackShareTypesSpill[ uDpbIdx ]->Add( fhFractionGoodHitsSpillEvo[ uDpbIdx ] ); - - fhFractionDupliHitsSpillEvo[ uDpbIdx ]->SetLineColor( colorsList[ 1 ] ); - fhFractionDupliHitsSpillEvo[ uDpbIdx ]->SetFillColor( colorsList[ 1 ] ); - stackShareTypesSpill[ uDpbIdx ]->Add( fhFractionDupliHitsSpillEvo[ uDpbIdx ] ); - - fhFractionTsMsbSpillEvo[ uDpbIdx ]->SetLineColor( colorsList[ 2 ] ); - fhFractionTsMsbSpillEvo[ uDpbIdx ]->SetFillColor( colorsList[ 2 ] ); - stackShareTypesSpill[ uDpbIdx ]->Add( fhFractionTsMsbSpillEvo[ uDpbIdx ] ); - - fhFractionEpochSpillEvo[ uDpbIdx ]->SetLineColor( colorsList[ 3 ] ); - fhFractionEpochSpillEvo[ uDpbIdx ]->SetFillColor( colorsList[ 3 ] ); - stackShareTypesSpill[ uDpbIdx ]->Add( fhFractionEpochSpillEvo[ uDpbIdx ] ); - - fhFractionEmptySpillEvo[ uDpbIdx ]->SetLineColor( colorsList[ 4 ] ); - fhFractionEmptySpillEvo[ uDpbIdx ]->SetFillColor( colorsList[ 4 ] ); - stackShareTypesSpill[ uDpbIdx ]->Add( fhFractionEmptySpillEvo[ uDpbIdx ] ); - - stackShareTypesSpill[ uDpbIdx ]->Draw( ",hist" ); - - cDataShares->cd( 5 + fuNrOfDpbs + uDpbIdx ); - gPad->SetGridx(); - gPad->SetGridy(); - - stackShareTypes[ uDpbIdx ] = new THStack( Form( "hsShareTypes%02u", uDpbIdx), - Form( "Fraction of message types for DPB %02u", uDpbIdx ) ); - - fhFractionGoodHitsEvo[ uDpbIdx ]->SetLineColor( colorsList[ 0 ] ); - fhFractionGoodHitsEvo[ uDpbIdx ]->SetFillColor( colorsList[ 0 ] ); - stackShareTypes[ uDpbIdx ]->Add( dynamic_cast< TH1 * >( fhFractionGoodHitsEvo[ uDpbIdx ] ) ); - stackShareTypes[ uDpbIdx ]->Draw("hist"); - - fhFractionDupliHitsEvo[ uDpbIdx ]->SetLineColor( colorsList[ 1 ] ); - fhFractionDupliHitsEvo[ uDpbIdx ]->SetFillColor( colorsList[ 1 ] ); - stackShareTypes[ uDpbIdx ]->Add( fhFractionDupliHitsEvo[ uDpbIdx ] ); - stackShareTypes[ uDpbIdx ]->Draw("hist"); - - fhFractionTsMsbEvo[ uDpbIdx ]->SetLineColor( colorsList[ 2 ] ); - fhFractionTsMsbEvo[ uDpbIdx ]->SetFillColor( colorsList[ 2 ] ); - stackShareTypes[ uDpbIdx ]->Add( fhFractionTsMsbEvo[ uDpbIdx ] ); - stackShareTypes[ uDpbIdx ]->Draw("hist"); - - fhFractionEpochEvo[ uDpbIdx ]->SetLineColor( colorsList[ 3 ] ); - fhFractionEpochEvo[ uDpbIdx ]->SetFillColor( colorsList[ 3 ] ); - stackShareTypes[ uDpbIdx ]->Add( fhFractionEpochEvo[ uDpbIdx ] ); - stackShareTypes[ uDpbIdx ]->Draw("hist"); - - fhFractionEmptyEvo[ uDpbIdx ]->SetLineColor( colorsList[ 4 ] ); - fhFractionEmptyEvo[ uDpbIdx ]->SetFillColor( colorsList[ 4 ] ); - stackShareTypes[ uDpbIdx ]->Add( fhFractionEmptyEvo[ uDpbIdx ] ); - stackShareTypes[ uDpbIdx ]->Draw("hist"); - - stackShareTypes[ uDpbIdx ]->Draw( ",hist" ); - } // for( UInt_t uDpbIdx = 0; uDpbIdx < fuNrOfDpbs; ++uDpbIdx ) - -//====================================================================// - -//====================================================================// - TCanvas* cFebDupliDtPrev = new TCanvas( "cFebDupliDtPrev", - "Duplicate dt to previous hits", - w, h); - - cFebDupliDtPrev->Divide( 2, 3 ); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - cFebDupliDtPrev->cd( 1 + uXyterIdx ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhAsicDuplicDtLastHits[ uXyterIdx ]->Draw( "colz" ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) -//====================================================================// - -//====================================================================// - TCanvas* cFebDupliPrevCompTs = new TCanvas( "cFebDupliPrevCompTs", - "Duplicate and previous hits TS used in comparator", - w, h); - - cFebDupliPrevCompTs->Divide( 2, 3 ); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - cFebDupliPrevCompTs->cd( 1 + uXyterIdx ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhAsicDuplicCompTs[ uXyterIdx ]->Draw( "colz" ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) -//====================================================================// - -//====================================================================// - TCanvas* cFebDupliPrevTsLsb = new TCanvas( "cFebDupliPrevTsLsb", - "Duplicate and previous hits Ts LSB", - w, h); - - cFebDupliPrevTsLsb->Divide( 2, 3 ); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - cFebDupliPrevTsLsb->cd( 1 + uXyterIdx ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhAsicDuplicTsLsb[ uXyterIdx ]->Draw( "colz" ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) -//====================================================================// - -//====================================================================// - TCanvas* cFebDupliPrevTsMsb = new TCanvas( "cFebDupliPrevTsMsb", - "Duplicate and previous hits Ts MSB", - w, h); - - cFebDupliPrevTsMsb->Divide( 2, 3 ); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - cFebDupliPrevTsMsb->cd( 1 + uXyterIdx ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhAsicDuplicTsMsbAsic[ uXyterIdx ]->Draw( "colz" ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) -//====================================================================// - -//====================================================================// - TCanvas* cFebDupliTsScan = new TCanvas( "cFebDupliTsScan", - "Duplicate TS scan", - w, h); - - cFebDupliTsScan->Divide( 2, 3 ); - - cFebDupliTsScan->cd( 1 ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhAsicGoodTs[ 0 ]->Draw( "colz" ); - - cFebDupliTsScan->cd( 2 ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhAsicDuplicTs[ 0 ]->Draw( "colz" ); - - cFebDupliTsScan->cd( 3 ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhAsicGoodTsMsb[ 0 ]->Draw( "colz" ); - - cFebDupliTsScan->cd( 4 ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhAsicDuplicTsMsb[ 0 ]->Draw( "colz" ); - - cFebDupliTsScan->cd( 5 ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhAsicGoodTsFull[ 0 ]->Draw( "colz" ); - - cFebDupliTsScan->cd( 6 ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhAsicDuplicTsFull[ 0 ]->Draw( "colz" ); -//====================================================================// -*/ - // Long duration rate monitoring -/* - if( kTRUE == fbLongHistoEnable ) - { - TCanvas* cStsLongRate = new TCanvas( "cStsLongRate" , "Long duration rate plots for StsXyter", - w, h); - cStsLongRate->Divide( 2, fuNbStsXyters ); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - cStsLongRate->cd( 1 + 2 * uXyterIdx ); - gPad->SetLogy(); - gPad->SetGridx(); - gPad->SetGridy(); - fhFebRateEvoLong[ uXyterIdx ]->Draw( "hist" ); - - cStsLongRate->cd( 2 + 2 * uXyterIdx ); - gPad->SetLogz(); - gPad->SetGridx(); - gPad->SetGridy(); - fhFebChRateEvoLong[ uXyterIdx ]->Draw( "colz" ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - } // if( kTRUE == fbLongHistoEnable ) -*/ -/* - Int_t iNbPadsPerDpb = fuNbElinksPerDpb/2 + fuNbElinksPerDpb%2; - TCanvas* cMuchChCounts = new TCanvas("cMuchChCounts", "MUCH Channels counts", w, h); - cMuchChCounts->Divide( fNrOfNdpbs/2 + fNrOfNdpbs%2, fNrOfFebsPerNdpb ); - - TCanvas* cMuchFebRate = new TCanvas("cMuchFebRate", "MUCH FEB rate", w, h); - cMuchFebRate->Divide( fNrOfNdpbs/2 + fNrOfNdpbs%2, fNrOfFebsPerNdpb ); - - TH1* histPnt = NULL; - for( Int_t dpbId = 0; dpbId < fNrOfNdpbs; dpbId++) - {// looping on all the nDPBS IDs - if( dpbId < fUnpackParHodo->GetNrOfnDpbsModA() ) - { - sNdpbTag = Form("%04X", fUnpackParHodo->GetNdpbIdA(dpbId) ); - } // if( dpbId < fUnpackParHodo->GetNrOfnDpbsModA() ) - else - { - sNdpbTag = Form("%04X", fUnpackParHodo->GetNdpbIdB(dpbId - fNrOfNdpbsA) ); - } // else of if( dpbId < fUnpackParHodo->GetNrOfnDpbsModA() ) - - for( Int_t febId = 0; febId < fNrOfFebsPerNdpb; febId++) - {// looping on all the FEB IDs - cMuchChCounts->cd( 1 + dpbId * iNbPadsPerDpb + febId/2 ); - gPad->SetLogy(); - sHistName = Form("Chan_Counts_Much_n%s_f%1u", sNdpbTag.Data(), febId); - histPnt = fHM->H1(sHistName.Data()); - - if( 0 == febId%2 ) - { - histPnt->SetLineColor( kRed ); // => Change color for 1st of the 2/pad! - histPnt->Draw(); - } // if( 0 == febId%2 ) - else - { - histPnt->SetLineColor( kBlue ); // => Change color for 1nd of the 2/pad! - histPnt->Draw("same"); - } // if( 0 == febId%2 ) - - cMuchFebRate->cd( 1 + dpbId * iNbPadsPerDpb + febId/2 ); - gPad->SetLogy(); - sHistName = Form("FebRate_n%s_f%1u", sNdpbTag.Data(), febId); - histPnt = fHM->H1(sHistName.Data()); - - if( 0 == febId%2 ) - { - histPnt->SetLineColor( kRed ); // => Change color for 1st of the 2/pad! - histPnt->Draw(); - } // if( 0 == febId%2 ) - else - { - histPnt->SetLineColor( kBlue ); // => Change color for 1nd of the 2/pad! - histPnt->Draw("same"); - } // if( 0 == febId%2 ) - } // for( Int_t febId = 0; febId < fNrOfFebsPerNdpb; febId++) - } // for( Int_t dpbId = 0; dpbId < fNrOfNdpbs; dpbId++) -*/ - - /** Recovers/Create Ms Size Canvase for CERN 2016 **/ - // Try to recover canvas in case it was created already by another monitor - // If not existing, create it - fcMsSizeAll = dynamic_cast<TCanvas *>( gROOT->FindObject( "cMsSizeAll" ) ); - if( NULL == fcMsSizeAll ) - { - fcMsSizeAll = new TCanvas("cMsSizeAll", "Evolution of MS size in last 300 s", w, h); - fcMsSizeAll->Divide( 4, 4 ); - LOG(info) << "Created MS size canvas in STS monitor"; - } // if( NULL == fcMsSizeAll ) - else LOG(info) << "Recovered MS size canvas in STS monitor"; - - /*****************************/ -} - -Bool_t CbmCosy2018MonitorScan::DoUnpack(const fles::Timeslice& ts, size_t component) -{ - THttpServer* server = FairRunOnline::Instance()->GetHttpServer(); - - if( bCosy2018ResetScanHistos ) - { - ResetAllHistos(); - bCosy2018ResetScanHistos = kFALSE; - } // if( bCosy2018ResetScanHistos ) - if( bCosy2018WriteScanHistos ) - { - SaveAllHistos( fsHistoFileFullname ); - bCosy2018WriteScanHistos = kFALSE; - } // if( bCosy2018WriteScanHistos ) - if( bCosy2018PrintMessScanHistos ) - { - fuPrintMessagesIdx = 0; - bCosy2018PrintMessScanHistos = kFALSE; - } // if( bCosy2018PrintMessScanHistos ) - - LOG(debug) << "Timeslice contains " << ts.num_microslices(component) - << "microslices."; - - if( component < kiMaxNbFlibLinks ) - if( NULL == fhMsSz[ component ] ) - { - TString sMsSzName = Form("MsSz_link_%02lu", component); - TString sMsSzTitle = Form("Size of MS for nDPB of link %02lu; Ms Size [bytes]", component); - fhMsSz[ component ] = new TH1F( sMsSzName.Data(), sMsSzTitle.Data(), 160000, 0., 20000. ); - fHM->Add(sMsSzName.Data(), fhMsSz[ component ] ); - if (server) server->Register("/FlibRaw", fhMsSz[ component ] ); - sMsSzName = Form("MsSzTime_link_%02lu", component); - sMsSzTitle = Form("Size of MS vs time for gDPB of link %02lu; Time[s] ; Ms Size [bytes]", component); - fhMsSzTime[ component ] = new TProfile( sMsSzName.Data(), sMsSzTitle.Data(), 15000, 0., 300. ); - fHM->Add( sMsSzName.Data(), fhMsSzTime[ component ] ); - if (server) server->Register("/FlibRaw", fhMsSzTime[ component ] ); - if( NULL != fcMsSizeAll ) - { - fcMsSizeAll->cd( 1 + component ); - gPad->SetLogy(); - fhMsSzTime[ component ]->Draw("hist le0"); - } // if( NULL != fcMsSizeAll ) - LOG(info) << "Added MS size histo for component: " << component - << " (DPB)"; - } // if( NULL == fhMsSz[ component ] ) - -// Int_t messageType = -111; - // Loop over microslices - size_t numCompMsInTs = ts.num_microslices(component); -/* - if( fulCurrentTsIdx + 1 != ts.index() && 0 == component) - LOG(info) << "Missed TS from " << fulCurrentTsIdx - << " to " << ts.index(); -*/ - fulCurrentTsIdx = ts.index(); - - if( fuMaxNbMicroslices < numCompMsInTs ) - { - fuMaxNbMicroslices = numCompMsInTs; - - fvdMsTime.resize( fuMaxNbMicroslices ); - fvuChanNbHitsInMs.resize( fuNbStsXyters ); - fvdChanLastHitTimeInMs.resize( fuNbStsXyters ); - fvusChanLastHitAdcInMs.resize( fuNbStsXyters ); - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fvuChanNbHitsInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvdChanLastHitTimeInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvusChanLastHitAdcInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - { - fvuChanNbHitsInMs[ uXyterIdx ][ uChan ].resize( fuMaxNbMicroslices ); - fvdChanLastHitTimeInMs[ uXyterIdx ][ uChan ].resize( fuMaxNbMicroslices ); - fvusChanLastHitAdcInMs[ uXyterIdx ][ uChan ].resize( fuMaxNbMicroslices ); - for( UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx ) - { - fvuChanNbHitsInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = 0; - fvdChanLastHitTimeInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = -1.0; - fvusChanLastHitAdcInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = 0; - } // for( UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx ) - } // for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - LOG(info) << "CbmCosy2018MonitorScan::DoUnpack => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs.size() << " VS " << fuNbStsXyters; - LOG(info) << "CbmCosy2018MonitorScan::DoUnpack => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs[ 0 ].size() << " VS " << fuNbChanPerAsic; - LOG(info) << "CbmCosy2018MonitorScan::DoUnpack => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs[ 0 ][ 0 ].size() << " VS " << fuMaxNbMicroslices; - } // if( fuMaxNbMicroslices < numCompMsInTs ) - - for( size_t m = 0; m < numCompMsInTs; ++m ) - { - // Ignore overlap ms if number defined by user - if( numCompMsInTs - fuOverlapMsNb <= m ) - continue; - - auto msDescriptor = ts.descriptor(component, m); - fuCurrentEquipmentId = msDescriptor.eq_id; - const uint8_t* msContent = reinterpret_cast<const uint8_t*>(ts.content(component, m)); - - uint32_t size = msDescriptor.size; - fulCurrentMsIdx = msDescriptor.idx; - Double_t dMsTime = (1e-9) * static_cast<double>(fulCurrentMsIdx); - LOG(debug) << "Microslice: " << fulCurrentMsIdx - << " from EqId " << std::hex << fuCurrentEquipmentId << std::dec - << " has size: " << size; - - fuCurrDpbId = static_cast< uint32_t >( fuCurrentEquipmentId & 0xFFFF ); - fuCurrDpbIdx = fDpbIdIndexMap[ fuCurrDpbId ]; - - if( component < kiMaxNbFlibLinks ) - { - if( fdStartTimeMsSz < 0 ) - fdStartTimeMsSz = dMsTime; - fhMsSz[ component ]->Fill( size ); - fhMsSzTime[ component ]->Fill( dMsTime - fdStartTimeMsSz, size); - } // if( component < kiMaxNbFlibLinks ) - - // Store MS time for coincidence plots - fvdMsTime[ m ] = dMsTime; - - // If not integer number of message in input buffer, print warning/error - if( 0 != (size % kuBytesPerMessage) ) - LOG(error) << "The input microslice buffer does NOT " - << "contain only complete nDPB messages!"; - - // Compute the number of complete messages in the input microslice buffer - uint32_t uNbMessages = (size - (size % kuBytesPerMessage) ) - / kuBytesPerMessage; - - // Prepare variables for the loop on contents - const uint32_t* pInBuff = reinterpret_cast<const uint32_t*>( msContent ); - - for( uint32_t uIdx = 0; uIdx < uNbMessages; ++uIdx ) - { - // Fill message - uint32_t ulData = static_cast<uint32_t>(pInBuff[uIdx]); - - stsxyter::Message mess( static_cast< uint32_t >( ulData & 0xFFFFFFFF ) ); - - // Print message if requested - if( fbPrintMessages ) - mess.PrintMess( std::cout, fPrintMessCtrl ); - - stsxyter::MessType typeMess = mess.GetMessType(); - fmMsgCounter[ typeMess ] ++; - fhHodoMessType->Fill( static_cast< uint16_t > (typeMess) ); - fhHodoMessTypePerDpb->Fill( fuCurrDpbIdx, static_cast< uint16_t > (typeMess) ); - - switch( typeMess ) - { - case stsxyter::MessType::Hit : - { - // Extract the eLink and Asic indices => Should GO IN the fill method now that obly hits are link/asic specific! - UShort_t usElinkIdx = mess.GetLinkIndex(); - if( fuNbElinksPerDpb <= usElinkIdx ) - { - LOG(fatal) << "CbmCosy2018MonitorScan::DoUnpack => " - << "eLink index out of bounds!" - << usElinkIdx << " VS " << fuNbElinksPerDpb; - } // if( fuNbElinksPerDpb <= usElinkIdx ) - fhHodoMessTypePerElink->Fill( fuCurrDpbIdx * fuNbElinksPerDpb + usElinkIdx, - static_cast< uint16_t > (typeMess) ); - - UInt_t uAsicIdx = fvuElinkToAsic[fuCurrDpbIdx][usElinkIdx]; - - FillHitInfo( mess, usElinkIdx, uAsicIdx, m ); - break; - } // case stsxyter::MessType::Hit : - case stsxyter::MessType::TsMsb : - { - FillTsMsbInfo( mess, uIdx, m ); -/* - Double_t dTsMsbTime = ( ( static_cast<ULong64_t>( stsxyter::kuHitNbTsBins ) - * static_cast<ULong64_t>( fvulCurrentTsMsb[fuCurrDpbIdx]) - + static_cast<ULong64_t>( stsxyter::kulTsCycleNbBins ) - * static_cast<ULong64_t>( fvuCurrentTsMsbCycle[fuCurrDpbIdx] ) - ) * stsxyter::kdClockCycleNs - - fdStartTime - )* 1e-9; - - fhFractionGoodHitsSpillEvo[ fuCurrDpbIdx ]->Fill( dTsMsbTime, 0.0 ); - fhFractionDupliHitsSpillEvo[ fuCurrDpbIdx ]->Fill( dTsMsbTime, 0.0 ); - fhFractionTsMsbSpillEvo[ fuCurrDpbIdx ]->Fill( dTsMsbTime, 1.0 ); - fhFractionEpochSpillEvo[ fuCurrDpbIdx ]->Fill( dTsMsbTime, 0.0 ); - fhFractionEmptySpillEvo[ fuCurrDpbIdx ]->Fill( dTsMsbTime, 0.0 ); - - fhFractionGoodHitsEvo[ fuCurrDpbIdx ]->Fill( dTsMsbTime, 0.0 ); - fhFractionDupliHitsEvo[ fuCurrDpbIdx ]->Fill( dTsMsbTime, 0.0 ); - fhFractionTsMsbEvo[ fuCurrDpbIdx ]->Fill( dTsMsbTime, 1.0 ); - fhFractionEpochEvo[ fuCurrDpbIdx ]->Fill( dTsMsbTime, 0.0 ); - fhFractionEmptyEvo[ fuCurrDpbIdx ]->Fill( dTsMsbTime, 0.0 ); - - fhFractionTypes->Fill( 0., 0.0 ); // Good Hit - fhFractionTypes->Fill( 1., 0.0 ); // Dupli Hit - fhFractionTypes->Fill( 2., 1.0 ); // Ts MSB - fhFractionTypes->Fill( 3., 0.0 ); // Epoch - fhFractionTypes->Fill( 4., 0.0 ); // Empty -*/ - break; - } // case stsxyter::MessType::TsMsb : - case stsxyter::MessType::Epoch : - { - // The first message in the TS is a special ones: EPOCH - FillEpochInfo( mess ); -/* - Double_t dTsMsbTime = ( ( static_cast<ULong64_t>( stsxyter::kuHitNbTsBins ) - * static_cast<ULong64_t>( fvulCurrentTsMsb[fuCurrDpbIdx]) - + static_cast<ULong64_t>( stsxyter::kulTsCycleNbBins ) - * static_cast<ULong64_t>( fvuCurrentTsMsbCycle[fuCurrDpbIdx] ) - ) * stsxyter::kdClockCycleNs - - fdStartTime - )* 1e-9; - - fhFractionGoodHitsSpillEvo[ fuCurrDpbIdx ]->Fill( dTsMsbTime, 0.0 ); - fhFractionDupliHitsSpillEvo[ fuCurrDpbIdx ]->Fill( dTsMsbTime, 0.0 ); - fhFractionTsMsbSpillEvo[ fuCurrDpbIdx ]->Fill( dTsMsbTime, 0.0 ); - fhFractionEpochSpillEvo[ fuCurrDpbIdx ]->Fill( dTsMsbTime, 1.0 ); - fhFractionEmptySpillEvo[ fuCurrDpbIdx ]->Fill( dTsMsbTime, 0.0 ); - - fhFractionGoodHitsEvo[ fuCurrDpbIdx ]->Fill( dTsMsbTime, 0.0 ); - fhFractionDupliHitsEvo[ fuCurrDpbIdx ]->Fill( dTsMsbTime, 0.0 ); - fhFractionTsMsbEvo[ fuCurrDpbIdx ]->Fill( dTsMsbTime, 0.0 ); - fhFractionEpochEvo[ fuCurrDpbIdx ]->Fill( dTsMsbTime, 1.0 ); - fhFractionEmptyEvo[ fuCurrDpbIdx ]->Fill( dTsMsbTime, 0.0 ); - - fhFractionTypes->Fill( 0., 0.0 ); // Good Hit - fhFractionTypes->Fill( 1., 0.0 ); // Dupli Hit - fhFractionTypes->Fill( 2., 0.0 ); // Ts MSB - fhFractionTypes->Fill( 3., 1.0 ); // Epoch - fhFractionTypes->Fill( 4., 0.0 ); // Empty -*/ - if( 0 < uIdx ) - LOG(info) << "CbmCosy2018MonitorScan::DoUnpack => " - << "EPOCH message at unexpected position in MS: message " - << uIdx << " VS message 0 expected!"; - break; - } // case stsxyter::MessType::TsMsb : - case stsxyter::MessType::Empty : - { -// FillTsMsbInfo( mess ); -/* - Double_t dTsMsbTime = ( ( static_cast<ULong64_t>( stsxyter::kuHitNbTsBins ) - CheckCoincWinBug* static_cast<ULong64_t>( fvulCurrentTsMsb[fuCurrDpbIdx]) - + static_cast<ULong64_t>( stsxyter::kulTsCycleNbBins ) - * static_cast<ULong64_t>( fvuCurrentTsMsbCycle[fuCurrDpbIdx] ) - ) * stsxyter::kdClockCycleNs - - fdStartTime - )* 1e-9; - - fhFractionGoodHitsSpillEvo[ fuCurrDpbIdx ]->Fill( dTsMsbTime, 0.0 ); - fhFractionDupliHitsSpillEvo[ fuCurrDpbIdx ]->Fill( dTsMsbTime, 0.0 ); - fhFractionTsMsbSpillEvo[ fuCurrDpbIdx ]->Fill( dTsMsbTime, 0.0 ); - fhFractionEpochSpillEvo[ fuCurrDpbIdx ]->Fill( dTsMsbTime, 0.0 ); - fhFractionEmptySpillEvo[ fuCurrDpbIdx ]->Fill( dTsMsbTime, 1.0 ); - - fhFractionGoodHitsEvo[ fuCurrDpbIdx ]->Fill( dTsMsbTime, 0.0 ); - fhFractionDupliHitsEvo[ fuCurrDpbIdx ]->Fill( dTsMsbTime, 0.0 ); - fhFractionTsMsbEvo[ fuCurrDpbIdx ]->Fill( dTsMsbTime, 0.0 ); - fhFractionEpochEvo[ fuCurrDpbIdx ]->Fill( dTsMsbTime, 0.0 ); - fhFractionEmptyEvo[ fuCurrDpbIdx ]->Fill( dTsMsbTime, 1.0 ); - - fhFractionTypes->Fill( 0., 0.0 ); // Good Hit - fhFractionTypes->Fill( 1., 0.0 ); // Dupli Hit - fhFractionTypes->Fill( 2., 0.0 ); // Ts MSB - fhFractionTypes->Fill( 3., 0.0 ); // Epoch - fhFractionTypes->Fill( 4., 1.0 ); // Empty -*/ - break; - } // case stsxyter::MessType::Empty : - case stsxyter::MessType::Dummy : - { - break; - } // case stsxyter::MessType::Dummy / ReadDataAck / Ack : - default: - { - LOG(fatal) << "CbmCosy2018MonitorScan::DoUnpack => " - << "Unknown message type, should never happen, stopping here!"; - } - } // switch( mess.GetMessType() ) - } // for( uint32_t uIdx = 0; uIdx < uNbMessages; ++uIdx ) - -/* - // Time differences plotting using the fully time sorted hits - Double_t dLastTimeX1 = -1e12; - Double_t dLastTimeY1 = -1e12; - Double_t dLastTimeX2 = -1e12; - Double_t dLastTimeY2 = -1e12; - Double_t dLastTimeN1 = -1e12; - Double_t dLastTimeP1 = -1e12; - Double_t dLastTimeN2 = -1e12; - Double_t dLastTimeP2 = -1e12; - Double_t dDtX1Y1 = -1e12; - Double_t dDtX2Y2 = -1e12; - Double_t dDtN1P1 = -1e12; - Double_t dDtN2P2 = -1e12; - Double_t dDtX1Y1X2Y2 = -1e12; - Double_t dDtN1P1N2P2 = -1e12; - Double_t dDtX1Y1X2Y2N1P1 = -1e12; - Double_t dDtX1Y1X2Y2N2P2 = -1e12; - Double_t dDtH1H2S1S2 = -1e12; -*/ - if( 0 < fvmHitsInTs.size() ) - { - /// Sort the buffer of hits - std::sort( fvmHitsInTs.begin(), fvmHitsInTs.end() ); -/* - ULong64_t ulLastHitTime = ( *( fvmHitsInTs.rbegin() ) ).GetTs(); - std::vector< stsxyter::FinalHit >::iterator it; - - std::chrono::steady_clock::time_point tNow = std::chrono::steady_clock::now(); - Double_t dUnixTimeInRun = std::chrono::duration_cast< std::chrono::seconds >(tNow - ftStartTimeUnix).count(); - - for( it = fvmHitsInTs.begin(); - it != fvmHitsInTs.end(); -// it != fvmHitsInTs.end() && (*it).GetTs() < ulLastHitTime - 320; // 32 * 3.125 ns = 1000 ns - ++it ) - { - UShort_t usAsicIdx = (*it).GetAsic(); - UShort_t usChanIdx = (*it).GetChan(); - ULong64_t ulHitTs = (*it).GetTs(); - UShort_t usHitAdc = (*it).GetAdc(); - - Bool_t bHitInX = usChanIdx < fuNbChanPerAsic/2; - - Double_t dTimeSinceStartSec = (ulHitTs * stsxyter::kdClockCycleNs - fdStartTime)* 1e-9; - - if( 0 == ulHitTs - fvulTimeLastHitAsicChan[ usAsicIdx ][ usChanIdx ] || - ( 0 < fvuNbSameFullHitAsicChan[ usAsicIdx ][ usChanIdx ] && - 0 == ( ulHitTs - fvulTimeLastHitAsicChan[ usAsicIdx ][ usChanIdx ] ) % 512 ) ) - { - fhFractionGoodHitsSpillEvo[ fuCurrDpbIdx ]->Fill( dTimeSinceStartSec, 0.0 ); - fhFractionDupliHitsSpillEvo[ fuCurrDpbIdx ]->Fill( dTimeSinceStartSec, 1.0 ); - fhFractionTsMsbSpillEvo[ fuCurrDpbIdx ]->Fill( dTimeSinceStartSec, 0.0 ); - fhFractionEpochSpillEvo[ fuCurrDpbIdx ]->Fill( dTimeSinceStartSec, 0.0 ); - fhFractionEmptySpillEvo[ fuCurrDpbIdx ]->Fill( dTimeSinceStartSec, 0.0 ); - - fhFractionGoodHitsEvo[ fuCurrDpbIdx ]->Fill( dTimeSinceStartSec, 0.0 ); - fhFractionDupliHitsEvo[ fuCurrDpbIdx ]->Fill( dTimeSinceStartSec, 1.0 ); - fhFractionTsMsbEvo[ fuCurrDpbIdx ]->Fill( dTimeSinceStartSec, 0.0 ); - fhFractionEpochEvo[ fuCurrDpbIdx ]->Fill( dTimeSinceStartSec, 0.0 ); - fhFractionEmptyEvo[ fuCurrDpbIdx ]->Fill( dTimeSinceStartSec, 0.0 ); - - fhFractionTypes->Fill( 0., 0.0 ); // Good Hit - fhFractionTypes->Fill( 1., 1.0 ); // Dupli Hit - fhFractionTypes->Fill( 2., 0.0 ); // Ts MSB - fhFractionTypes->Fill( 3., 0.0 ); // Epoch - fhFractionTypes->Fill( 4., 0.0 ); // Empty - - if( 0 == fviAdcLastHitAsicChan[ usAsicIdx ][ usChanIdx ] - usHitAdc ) - { - fvuNbSameFullHitAsicChan[ usAsicIdx ][ usChanIdx ] ++; - fvuNbHitSameTsAdcAsicLastS[ usAsicIdx ] ++; - - fhRatioSameTsAdcSpillEvo[ usAsicIdx ]->Fill( dTimeSinceStartSec, usChanIdx, 1.0 ); - fhRatioSameAdcSameTsSpillEvo[ usAsicIdx ]->Fill( dTimeSinceStartSec, usChanIdx, 1.0 ); - - if( 0 == fvuNbSameFullHitAsic[ usAsicIdx ] && 1 < fvuNbDiffFullHitAsic[ usAsicIdx ] ) - { - UInt_t uBitPattComp = 0; - UInt_t uBitPattLsb = 0; - UInt_t uBitPattMsb = 0; - ULong64_t ulDuplHitTs = fvmLastHitsAsic[ usAsicIdx ][ fvuLastHitBufferIdx[ usAsicIdx ] ].GetTs(); - - fhAsicDuplicTs[ usAsicIdx ]->Fill( usChanIdx, ( ulDuplHitTs & 0x000FF ) ); - fhAsicDuplicTsMsb[ usAsicIdx ]->Fill( usChanIdx, ( ulDuplHitTs & 0x0FF00 ) >> 8 ); - fhAsicDuplicTsFull[ usAsicIdx ]->Fill( usChanIdx, ( ulDuplHitTs & 0x03FFF ) ); - - if( 0 == usAsicIdx ) - { - if( 0 == usChanIdx ) - fhAsicDuplicTsEvoAsic0Chan01->Fill( dTimeSinceStartSec, ( ulDuplHitTs & 0x00FFF ) ); - else if( 20 == usChanIdx ) - fhAsicDuplicTsEvoAsic0Chan09->Fill( dTimeSinceStartSec, ( ulDuplHitTs & 0x00FFF ) ); - else if( 99 == usChanIdx ) - fhAsicDuplicTsEvoAsic0Chan16->Fill( dTimeSinceStartSec, ( ulDuplHitTs & 0x00FFF ) ); - } // if( 0 == usAsicIdx ) - - for( UInt_t uBit = 0; uBit < 14; ++uBit ) - { - fhAsicDuplicTsBitPattern[ usAsicIdx ]->Fill( uBit, ( ( ulDuplHitTs >> uBit ) & 0x1) ); - } // for( UInt_t uBit = 0; uBit < 14; ++uBit ) - - for( UInt_t uPrevHit = 0; uPrevHit < fuNbChanPerAsic; ++uPrevHit ) - { - UInt_t uBufferIdx = ( fvuLastHitBufferIdx[ usAsicIdx ] < uPrevHit ) ? - ( fvuLastHitBufferIdx[ usAsicIdx ] - uPrevHit + fuNbChanPerAsic ): - ( fvuLastHitBufferIdx[ usAsicIdx ] - uPrevHit ); - - ULong64_t ulPrevHitTs = fvmLastHitsAsic[ usAsicIdx ][ uBufferIdx ].GetTs(); - UInt_t uCompTs = ( ulPrevHitTs & 0x01FC0 ) >> 6; - UInt_t uTsLsb = ( ulPrevHitTs & 0x000FF ); - UInt_t uTsMsb = ( ulPrevHitTs & 0x03F00 ) >> 8; - - uBitPattComp |= uCompTs; - uBitPattLsb |= uTsLsb; - uBitPattMsb |= uTsMsb; - - Double_t dDt = static_cast< Double_t >(ulDuplHitTs) - static_cast< Double_t >(ulPrevHitTs); - - if( 2048 < dDt ) - break; - - fhAsicDuplicDtLastHits[ usAsicIdx ]->Fill( dDt, uPrevHit ); - fhAsicDuplicCompTs[ usAsicIdx ]->Fill( uPrevHit, uCompTs ); - fhAsicDuplicTsLsb[ usAsicIdx ]->Fill( uPrevHit, uTsLsb ); - fhAsicDuplicTsMsbAsic[ usAsicIdx ]->Fill( uPrevHit, uTsMsb ); - - for( UInt_t uBit = 0; uBit < 8; ++uBit ) - { - if( 1 == ( ( uBitPattComp >> uBit ) & 0x1) ) - fhAsicDuplicCompTsBitThere[ usAsicIdx ]->Fill( uPrevHit, uBit ); - - if( 1 == ( ( uBitPattLsb >> uBit ) & 0x1) ) - fhAsicDuplicTsLsbBitThere[ usAsicIdx ]->Fill( uPrevHit, uBit ); - - if( 1 == ( ( uBitPattMsb >> uBit ) & 0x1) ) - fhAsicDuplicTsMsbBitThere[ usAsicIdx ]->Fill( uPrevHit, uBit ); - } // for( UInt_t uBit = 0; uBit < 8; ++uBit ) - } // for( UInt_t uPrevHit = 0; uPrevHit < fuNbChanPerAsic; ++uPrevHit ) - } // if( 0 == fvuNbSameFullHitAsic[ usAsicIdx ] && 1 < fvuNbDiffFullHitAsic[ usAsicIdx ] ) - fvuNbSameFullHitAsic[ usAsicIdx ] ++; - fvuNbDiffFullHitAsic[ usAsicIdx ] = 0; - } // if( 0 == fviAdcLastHitAsicChan[ usAsicIdx ][ usChanIdx ] - usHitAdc ) - else - { - fhSetupSortedNbConsSameTsAdcChan[ usAsicIdx ]->Fill( usChanIdx, fvuNbSameFullHitAsicChan[ usAsicIdx ][ usChanIdx ] ); - fhSetupSortedNbConsSameTsVsTsAdc[ usAsicIdx ]->Fill( fvuNbSameHitAsicChan[ usAsicIdx ][ usChanIdx ], - fvuNbSameFullHitAsicChan[ usAsicIdx ][ usChanIdx ] ); - fvuNbSameFullHitAsicChan[ usAsicIdx ][ usChanIdx ] = 0; - - fhRatioSameAdcSameTsSpillEvo[ usAsicIdx ]->Fill( dTimeSinceStartSec, usChanIdx, 0.0 ); - } // else of if( 0 == fviAdcLastHitAsicChan[ usAsicIdx ][ usChanIdx ] - usHitAdc ) - - fvuNbSameHitAsicChan[ usAsicIdx ][ usChanIdx ] ++; - fvuNbHitSameTsAsicLastS[ usAsicIdx ] ++; - - fhSetupSortedNbSameTsChan[ usAsicIdx ]->Fill( dTimeSinceStartSec, usChanIdx ); - fhSetupSortedSameTsAdcChan[ usAsicIdx ]->Fill( usChanIdx, usHitAdc ); - fhSetupSortedSameTsAdcChan[ usAsicIdx ]->Fill( usChanIdx, fviAdcLastHitAsicChan[ usAsicIdx ][ usChanIdx ] ); - fhSetupSortedSameTsAdcDiff[ usAsicIdx ]->Fill( fvuNbSameHitAsicChan[ usAsicIdx ][ usChanIdx ], - static_cast< Int_t >( usHitAdc ) - - fviAdcLastHitAsicChan[ usAsicIdx ][ usChanIdx ] ); - fhSetupSortedRatioSameTsChan[ usAsicIdx ]->Fill( dTimeSinceStartSec, usChanIdx, 1.0 ); - - fhRatioSameTsSpillEvo[ usAsicIdx ]->Fill( dTimeSinceStartSec, usChanIdx, 1.0 ); - - if( 1 == fvuNbSameHitAsicChan[ usAsicIdx ][ usChanIdx ] ) - fhSetupSortedTsFirstDuplicateChan[ usAsicIdx ]->Fill( usChanIdx, ulHitTs % 512 ); - } // if( 0 == ulHitTs - fvulTimeLastHitAsicChan[ usAsicIdx ][ usChanIdx ] ) - else - { - fhFractionGoodHitsSpillEvo[ fuCurrDpbIdx ]->Fill( dTimeSinceStartSec, 1.0 ); - fhFractionDupliHitsSpillEvo[ fuCurrDpbIdx ]->Fill( dTimeSinceStartSec, 0.0 ); - fhFractionTsMsbSpillEvo[ fuCurrDpbIdx ]->Fill( dTimeSinceStartSec, 0.0 ); - fhFractionEpochSpillEvo[ fuCurrDpbIdx ]->Fill( dTimeSinceStartSec, 0.0 ); - fhFractionEmptySpillEvo[ fuCurrDpbIdx ]->Fill( dTimeSinceStartSec, 0.0 ); - - fhFractionGoodHitsEvo[ fuCurrDpbIdx ]->Fill( dTimeSinceStartSec, 1.0 ); - fhFractionDupliHitsEvo[ fuCurrDpbIdx ]->Fill( dTimeSinceStartSec, 0.0 ); - fhFractionTsMsbEvo[ fuCurrDpbIdx ]->Fill( dTimeSinceStartSec, 0.0 ); - fhFractionEpochEvo[ fuCurrDpbIdx ]->Fill( dTimeSinceStartSec, 0.0 ); - fhFractionEmptyEvo[ fuCurrDpbIdx ]->Fill( dTimeSinceStartSec, 0.0 ); - - fhFractionTypes->Fill( 0., 1.0 ); // Good Hit - fhFractionTypes->Fill( 1., 0.0 ); // Dupli Hit - fhFractionTypes->Fill( 2., 0.0 ); // Ts MSB - fhFractionTypes->Fill( 3., 0.0 ); // Epoch - fhFractionTypes->Fill( 4., 0.0 ); // Empty - - fhSetupSortedNbConsSameTsVsTsAdc[ usAsicIdx ]->Fill( fvuNbSameHitAsicChan[ usAsicIdx ][ usChanIdx ], - fvuNbSameFullHitAsicChan[ usAsicIdx ][ usChanIdx ] ); - - fhSetupSortedNbConsSameTsChan[ usAsicIdx ]->Fill( usChanIdx, fvuNbSameHitAsicChan[ usAsicIdx ][ usChanIdx ] ); - fvuNbSameHitAsicChan[ usAsicIdx ][ usChanIdx ] = 0; - - fhSetupSortedNbConsSameTsAdcChan[ usAsicIdx ]->Fill( usChanIdx, fvuNbSameFullHitAsicChan[ usAsicIdx ][ usChanIdx ] ); - fvuNbSameFullHitAsicChan[ usAsicIdx ][ usChanIdx ] = 0; - - fhSetupSortedRatioSameTsChan[ usAsicIdx ]->Fill( dTimeSinceStartSec, usChanIdx, 0.0 ); - - fhRatioSameTsSpillEvo[ usAsicIdx ]->Fill( dTimeSinceStartSec, usChanIdx, 0.0 ); - fhRatioSameTsAdcSpillEvo[ usAsicIdx ]->Fill( dTimeSinceStartSec, usChanIdx, 0.0 ); - - fhHodoChanCntGood[ usAsicIdx ]->Fill( usChanIdx, usHitAdc ); - fhHodoChanGoodHitRateEvo[ usAsicIdx ]->Fill( dTimeSinceStartSec, usChanIdx ); - - fvuNbHitDiffTsAsicLastS[ usAsicIdx ]++; - - fhSetupSortedTsGoodChan[ usAsicIdx ]->Fill( usChanIdx, ulHitTs % 512 ); - - if( 0 < fvuNbDiffFullHitAsic[ usAsicIdx ] ) - { - fhAsicGoodTs[ usAsicIdx ]->Fill( usChanIdx, ( ulHitTs & 0x000FF ) ); - fhAsicGoodTsMsb[ usAsicIdx ]->Fill( usChanIdx, ( ulHitTs & 0x0FF00 ) >> 8 ); - fhAsicGoodTsFull[ usAsicIdx ]->Fill( usChanIdx, ( ulHitTs & 0x03FFF ) ); - if( 0 == usAsicIdx ) - { - if( 0 == usChanIdx ) - { - fhAsicGoodTsEvoAsic0Chan01->Fill( dTimeSinceStartSec, ( ulHitTs & 0x00FFF ) ); - fhAsicGoodTsMsbEvoAsic0Chan01->Fill( dTimeSinceStartSec, ( ulHitTs & 0x0FF00 ) >> 8 ); - fhAsicGoodTsFullEvoAsic0Chan01->Fill( dTimeSinceStartSec, ( ulHitTs & 0x03FFF ) ); - fhAsicGoodTsFullEvoProfAsic0Chan01->Fill( dTimeSinceStartSec, ( ulHitTs & 0x03FFF ) ); - } //if( 3 == usChanIdx ) - else if( 20 == usChanIdx ) - { - fhAsicGoodTsEvoAsic0Chan09->Fill( dTimeSinceStartSec, ( ulHitTs & 0x00FFF ) ); - fhAsicGoodTsFullEvoProfAsic0Chan09->Fill( dTimeSinceStartSec, ( ulHitTs & 0x03FFF ) ); - } // else if( 20 == usChanIdx ) - else if( 99 == usChanIdx ) - { - fhAsicGoodTsEvoAsic0Chan16->Fill( dTimeSinceStartSec, ( ulHitTs & 0x00FFF ) ); - fhAsicGoodTsFullEvoProfAsic0Chan16->Fill( dTimeSinceStartSec, ( ulHitTs & 0x03FFF ) ); - } // else if( 99 == usChanIdx ) - } // if( 0 == usAsicIdx ) - - for( UInt_t uBit = 0; uBit < 14; ++uBit ) - { - fhAsicGoodTsBitPattern[ usAsicIdx ]->Fill( uBit, ( ( ulHitTs >> uBit ) & 0x1) ); - } // for( UInt_t uBit = 0; uBit < 14; ++uBit ) - } // if( 0 < fvuNbDiffFullHitAsic[ usAsicIdx ] ) - - fvuNbSameFullHitAsic[ usAsicIdx ] = 0; - fvuNbDiffFullHitAsic[ usAsicIdx ] ++; - fvuLastHitBufferIdx[ usAsicIdx ] = ( fvuLastHitBufferIdx[ usAsicIdx ] + 1 ) % fuNbChanPerAsic; - fvmLastHitsAsic[ usAsicIdx ][ fvuLastHitBufferIdx[ usAsicIdx ] ] = (*it); - } // else of if( 0 == ulHitTs - fvulTimeLastHitAsicChan[ usAsicIdx ][ usChanIdx ] ) - fvulTimeLastHitAsicChan[ usAsicIdx ][ usChanIdx ] = ulHitTs; - fviAdcLastHitAsicChan[ usAsicIdx ][ usChanIdx ] = usHitAdc; - - if( 0 == usAsicIdx && fuPulseIdx < fuPulseIdxMax ) - { - fhAsicMissedChanIdVsPulseIdx->Fill( fuPulseIdx, usChanIdx ); - switch( usChanIdx ) - { - case 31: - fhAsicMissedChanGroupVsPulseIdx->Fill( fuPulseIdx, 0 ); - break; - case 35: - fhAsicMissedChanGroupVsPulseIdx->Fill( fuPulseIdx, 1 ); - break; - case 39: - fhAsicMissedChanGroupVsPulseIdx->Fill( fuPulseIdx, 2 ); - break; - default: - break; - } // switch( usChanIdx ) - } // if( 0 == usAsicIdx && fuPulseIdx < fuPulseIdxMax ) - } // loop on hits untils hits within 100 ns of last one or last one itself are reached - fuPulseIdx ++; -*/ - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - { - fvbChanFiredInThisMs[uXyterIdx][uChan] = kFALSE; - fvbChanCopiedInThisMs[uXyterIdx][uChan] = kFALSE; - } // for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - - Double_t dTimeSinceStartSec = 0; - std::vector< stsxyter::FinalHit >::iterator it; - - Bool_t bFlagOnInThisMs[fuNbStsXyters]; - for (UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx){ - bFlagOnInThisMs[uXyterIdx] = kFALSE; - } - - for( it = fvmHitsInTs.begin(); it != fvmHitsInTs.end(); ++it ) - { - UShort_t usAsicIdx = (*it).GetAsic(); - UShort_t usChanIdx = (*it).GetChan(); - ULong64_t ulHitTs = (*it).GetTs(); -// UShort_t usHitAdc = (*it).GetAdc(); - - /// Save the time of the first hit in MS (not necessarily time sorted) for plotting later - if( fvmHitsInTs.begin() == it ) - dTimeSinceStartSec = (ulHitTs * stsxyter::kdClockCycleNs - fdStartTime)* 1e-9; - - if( fvbChanFiredInThisMs[usAsicIdx][usChanIdx] ) - fvbChanCopiedInThisMs[usAsicIdx][usChanIdx] = kTRUE; - else fvbChanFiredInThisMs[usAsicIdx][usChanIdx] = kTRUE; - -/** STSXYTER v2.0 Bug, triggering condition detection **/ - /// Check if hit copy - Bool_t bIsNotCopy = kTRUE; - if( fvulLastHitTs[ usAsicIdx ][ usChanIdx ] == ulHitTs) - bIsNotCopy = kFALSE; - - fvulLastHitTs[ usAsicIdx ][ usChanIdx ] = ulHitTs; - - if( bIsNotCopy ) { - CheckCoincWinBug( usAsicIdx, ulHitTs * stsxyter::kdClockCycleNs, dTimeSinceStartSec ); - CheckCoincWinBugImproved2( usAsicIdx, ulHitTs * stsxyter::kdClockCycleNs, dTimeSinceStartSec ); - bFlagOnInThisMs[usAsicIdx] |= CheckCoincWinBugMoreCond( usAsicIdx, ulHitTs * stsxyter::kdClockCycleNs, dTimeSinceStartSec ); - } -/** STSXYTER v2.0 Bug, triggering condition detection **/ - } // for( it = fvmHitsInTs.begin(); it != fvmHitsInTs.end(); ++it ) - - Bool_t bFlagOnAnyMs = kFALSE; ///add - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - if( bFlagOnInThisMs[uXyterIdx] ) { - fhCoincWinFlagEvoMoreCond->Fill( dTimeSinceStartSec, uXyterIdx, 2. ); - } else { - fhCoincWinFlagEvoMoreCond->Fill( dTimeSinceStartSec, uXyterIdx, 0. ); - } - - bFlagOnAnyMs |= bFlagOnInThisMs[uXyterIdx];///add - - UInt_t uNbChanFired = 0; - UInt_t uNbChanCopied = 0; - for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - { - if( fvbChanFiredInThisMs[uXyterIdx][uChan] ) - uNbChanFired++; - if( fvbChanCopiedInThisMs[uXyterIdx][uChan] ) - uNbChanCopied++; - } // for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - fhNbFiredChanPerMs[ uXyterIdx ]->Fill( dTimeSinceStartSec, uNbChanFired ); - fhNbMultiHitChanPerMs[ uXyterIdx ]->Fill( dTimeSinceStartSec, uNbChanCopied ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - - fhBadWinRatio->Fill(dTimeSinceStartSec, bFlagOnAnyMs ? 1.0 : 0.0 ); ///add - fhBadDataRatio->Fill(dTimeSinceStartSec, bFlagOnAnyMs ? 1.0 : 0.0, fvmHitsInTs.size());///add - - // Remove all hits which were already used - fvmHitsInTs.erase( fvmHitsInTs.begin(), it ); - } // if( 0 < fvmHitsInTs.size() ) - - } // for( size_t m = 0; m < numCompMsInTs; ++m ) - - // End of TS, check if stuff to do with the hits inside each MS - // Usefull for low rate pulser tests - // Need to do it only when last DPB is processed, as they are done one by one - if( fuCurrDpbIdx == fuNrOfDpbs - 1 ) - { - for( UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx ) - { - fvdMsTime[ uMsIdx ] = 0.0; - } // for( UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx ) - } // if( fuCurrDpbIdx == fuNrOfDpbs - 1 ) - - if( 0 == ts.index() % 1000 && fuCurrDpbIdx == fuNrOfDpbs - 1 ) - { - for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - { - Double_t dTsMsbTime = - static_cast<ULong64_t>( stsxyter::kuHitNbTsBins ) - * static_cast<ULong64_t>( fvulCurrentTsMsb[fuCurrDpbIdx]) - + static_cast<ULong64_t>( stsxyter::kulTsCycleNbBins ) - * static_cast<ULong64_t>( fvuCurrentTsMsbCycle[fuCurrDpbIdx] ); - dTsMsbTime *= stsxyter::kdClockCycleNs * 1e-9; - - LOG(info) << "End of TS " << std::setw(7) << ts.index() - << " eDPB " << std::setw(2) << uDpb - << " current TS MSB counter is " << std::setw(12) << fvulCurrentTsMsb[uDpb] - << " current TS MSB cycle counter is " << std::setw(12) << fvuCurrentTsMsbCycle[uDpb] - << " current TS MSB time is " << std::setw(12) << dTsMsbTime << " s"; - } - } // if( 0 == ts.index() % 1000 && fuCurrDpbIdx == fuNrOfDpbs - 1 ) - - return kTRUE; -} - -void CbmCosy2018MonitorScan::FillHitInfo( stsxyter::Message mess, const UShort_t & /*usElinkIdx*/, const UInt_t & uAsicIdx, const UInt_t & uMsIdx ) -{ - UShort_t usChan = mess.GetHitChannel(); - UShort_t usRawAdc = mess.GetHitAdc(); -// UShort_t usFullTs = mess.GetHitTimeFull(); -// UShort_t usTsOver = mess.GetHitTimeOver(); - UShort_t usRawTs = mess.GetHitTime(); - - fhHodoChanCntRaw[ uAsicIdx ]->Fill( usChan ); - fhHodoChanAdcRaw[ uAsicIdx ]->Fill( usChan, usRawAdc ); - fhHodoChanAdcRawProf[ uAsicIdx ]->Fill( usChan, usRawAdc ); - fhHodoChanRawTs[ uAsicIdx ]->Fill( usChan, usRawTs ); - fhHodoChanMissEvt[ uAsicIdx ]->Fill( usChan, mess.IsHitMissedEvts() ); - - // Compute the Full time stamp -// Long64_t ulOldHitTime = fvulChanLastHitTime[ uAsicIdx ][ usChan ]; -// Double_t dOldHitTime = fvdChanLastHitTime[ uAsicIdx ][ usChan ]; - - // Use TS w/o overlap bits as they will anyway come from the TS_MSB - fvulChanLastHitTime[ uAsicIdx ][ usChan ] = usRawTs; - - fvulChanLastHitTime[ uAsicIdx ][ usChan ] += - static_cast<ULong64_t>( stsxyter::kuHitNbTsBins ) - * static_cast<ULong64_t>( fvulCurrentTsMsb[fuCurrDpbIdx]) - + static_cast<ULong64_t>( stsxyter::kulTsCycleNbBins ) - * static_cast<ULong64_t>( fvuCurrentTsMsbCycle[fuCurrDpbIdx] ) - ; - -// fvuElinkLastTsHit[fuCurrDpbIdx] = usRawTs; - - // Convert the Hit time in bins to Hit time in ns - Double_t dHitTimeNs = fvulChanLastHitTime[ uAsicIdx ][ usChan ] * stsxyter::kdClockCycleNs; -/* - // If needed fill the hit interval plots - if( fbChanHitDtEna ) - { - Double_t dDeltaT = dHitTimeNs - fvdChanLastHitTime[ uAsicIdx ][ usChan ]; - if( 0 == dDeltaT ) - fhStsChanHitDtNeg[ uAsicIdx ]->Fill( 1, usChan ); - else if( 0 < dDeltaT ) - fhStsChanHitDt[ uAsicIdx ]->Fill( dDeltaT, usChan ); - else fhStsChanHitDtNeg[ uAsicIdx ]->Fill( -dDeltaT, usChan ); - } // if( fbChanHitDtEna ) -*/ - - // Store new value of Hit time in ns - fvdChanLastHitTime[ uAsicIdx ][ usChan ] = fvulChanLastHitTime[ uAsicIdx ][ usChan ] * stsxyter::kdClockCycleNs; -/* - LOG(info) << " Asic " << std::setw( 2 ) << uAsicIdx - << " Channel " << std::setw( 3 ) << usChan - << " Diff to last hit " << std::setw( 12 ) << ( fvulChanLastHitTime[ uAsicIdx ][ usChan ] - ulOldHitTime) - << " in s " << std::setw( 12 ) << ( fvdChanLastHitTime[ uAsicIdx ][ usChan ] - dOldHitTime) * 1e-9; -*/ - // Pulser and MS - fvuChanNbHitsInMs[ uAsicIdx ][ usChan ][ uMsIdx ] ++; - fvdChanLastHitTimeInMs[ uAsicIdx ][ usChan ][ uMsIdx ] = dHitTimeNs; - fvusChanLastHitAdcInMs[ uAsicIdx ][ usChan ][ uMsIdx ] = usRawAdc; -/* - fvmChanHitsInTs[ uAsicIdx ][ usChan ].insert( stsxyter::FinalHit( fvulChanLastHitTime[ uAsicIdx ][ usChan ], - usRawAdc, uAsicIdx, usChan ) ); -*/ - - fvmHitsInTs.push_back( stsxyter::FinalHit( fvulChanLastHitTime[ uAsicIdx ][ usChan ], usRawAdc, uAsicIdx, usChan ) ); - - - if( fuPrintMessagesIdx < fkuNbPrintMessages ) -// if( ( 5949 == fulCurrentTsIdx ) ) - { - LOG(info) << " TS " << std::setw( 12 ) << fulCurrentTsIdx - << " MS " << std::setw( 12 ) << fulCurrentMsIdx - << " MsInTs " << std::setw( 3 ) << uMsIdx - << " eLINK " << std::setw( 3 ) << mess.GetLinkIndex() - << " Asic " << std::setw( 2 ) << uAsicIdx - << " Channel " << std::setw( 3 ) << usChan - << " ADC " << std::setw( 3 ) << usRawAdc - << " TS " << std::setw( 3 ) << usRawTs // 9 bits TS - << " TsMsb " << std::setw( 7 ) << fvulCurrentTsMsb[fuCurrDpbIdx] - << " MsbCy " << std::setw( 4 ) << fvuCurrentTsMsbCycle[fuCurrDpbIdx] - << " Time " << std::setw ( 12 ) << fvulChanLastHitTime[ uAsicIdx ][ usChan ]; - fuPrintMessagesIdx++; - } // if( fuPrintMessagesIdx < fkuNbPrintMessages ) - - // Check Starting point of histos with time as X axis - if( -1 == fdStartTime ) - fdStartTime = fvdChanLastHitTime[ uAsicIdx ][ usChan ]; - - // Fill histos with time as X axis - Double_t dTimeSinceStartSec = (fvdChanLastHitTime[ uAsicIdx ][ usChan ] - fdStartTime)* 1e-9; - Double_t dTimeSinceStartMin = dTimeSinceStartSec / 60.0; - fhHodoChanHitRateEvo[ uAsicIdx ]->Fill( dTimeSinceStartSec , usChan ); - if( 0 == uAsicIdx ) - fhHodoChanHitRateEvoZoom->Fill( dTimeSinceStartSec , usChan ); - fhHodoFebRateEvo[ uAsicIdx ]->Fill( dTimeSinceStartSec ); - fhHodoChanHitRateEvoLong[ uAsicIdx ]->Fill( dTimeSinceStartMin, usChan, 1.0/60.0 ); - fhHodoFebRateEvoLong[ uAsicIdx ]->Fill( dTimeSinceStartMin, 1.0/60.0 ); - if( mess.IsHitMissedEvts() ) - { - fhHodoChanMissEvtEvo[ uAsicIdx ]->Fill( dTimeSinceStartSec , usChan ); - fhHodoFebMissEvtEvo[ uAsicIdx ]->Fill( dTimeSinceStartSec ); - } // if( mess.IsHitMissedEvts() ) -/* - if( kTRUE == fbLongHistoEnable ) - { - std::chrono::steady_clock::time_point tNow = std::chrono::steady_clock::now(); - Double_t dUnixTimeInRun = std::chrono::duration_cast< std::chrono::seconds >(tNow - ftStartTimeUnix).count(); - fhFebRateEvoLong[ uAsicIdx ]->Fill( dUnixTimeInRun , 1.0 / fuLongHistoBinSizeSec ); - fhFebChRateEvoLong[ uAsicIdx ]->Fill( dUnixTimeInRun , usChan, 1.0 / fuLongHistoBinSizeSec ); - } // if( kTRUE == fbLongHistoEnable ) -*/ -/* - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - if( uXyterIdx == uAsicIdx ) - { - fhFractionHitsAsicSpillEvo[ uXyterIdx ]->Fill( dTimeSinceStartSec, 1.0 ); - fhFractionHitsAsicEvo[ uXyterIdx ]->Fill( dTimeSinceStartSec, 1.0 ); - fhFractionAsics->Fill( uXyterIdx, 1.0); - } - else - { - fhFractionHitsAsicSpillEvo[ uXyterIdx ]->Fill( dTimeSinceStartSec, 0.0 ); - fhFractionHitsAsicEvo[ uXyterIdx ]->Fill( dTimeSinceStartSec, 0.0 ); - fhFractionAsics->Fill( uXyterIdx, 0.0 ); - } - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) -*/ -/* - if( 596.51 < dTimeSinceStartSec && dTimeSinceStartSec < 597.07 && - 0 == uAsicIdx && 3 == usChan ) - LOG(info) << " TS " << std::setw( 12 ) << fulCurrentTsIdx - << " MS " << std::setw( 12 ) << fulCurrentMsIdx - << " ADC " << std::setw( 3 ) << usRawAdc - << " TS " << std::setw( 3 ) << usRawTs // 9 bits TS - << " SX TsMsb " << std::setw( 2 ) << ( fvulCurrentTsMsb[fuCurrDpbIdx] & 0x1F ) // Total StsXyter TS = 14 bits => 9b Hit TS + lower 5b TS_MSB after DPB - << " DPB TsMsb " << std::setw( 6 ) << ( fvulCurrentTsMsb[fuCurrDpbIdx] >> 5 ) // Total StsXyter TS = 14 bits => 9b Hit TS + lower 5b of TS_MSB after DPB - << " TsMsb " << std::setw( 7 ) << fvulCurrentTsMsb[fuCurrDpbIdx] - << " MsbCy " << std::setw( 4 ) << fvuCurrentTsMsbCycle[fuCurrDpbIdx] - << " Time " << std::setw ( 12 ) << fvulChanLastHitTime[ uAsicIdx ][ usChan ] - << " Time " << std::setw ( 5 ) << dTimeSinceStartSec; -*/ - - // Print TS jumps -// if( (ulOldHitTime & 0x00003C00) != (fvulChanLastHitTime[ uAsicIdx ][ usChan ] & 0x00003C00) && ( 255 != (ulOldHitTime & 0xFF) ) && (255 != (usRawTs & 0xFF) )) -/* - if( 0 == usChan && - ( ( (ulOldHitTime & 0x00003FFF) + 2 < (fvulChanLastHitTime[ uAsicIdx ][ usChan ] & 0x00003FFF ) ) || - ( (ulOldHitTime & 0x00003FFF) > (fvulChanLastHitTime[ uAsicIdx ][ usChan ] & 0x00003FFF ) + 2 ) ) && - ( ( 11620 > (fvulChanLastHitTime[ uAsicIdx ][ usChan ] & 0x00003FFF ) ) || - ( 11630 < (fvulChanLastHitTime[ uAsicIdx ][ usChan ] & 0x00003FFF ) ) ) - ) - { - Long64_t ulNewHitTime = fvulChanLastHitTime[ uAsicIdx ][ usChan ]; - LOG(info) << " Old Hit chan " << std::setw( 3 ) << usChan - << " TS " << std::setw( 3 ) << (ulOldHitTime & 0xFF) // 8 bits TS - << " Full TS " << std::setw( 5 ) << (ulOldHitTime & 0x3FFF) // Total StsXyter TS = 14 bits => 9b Hit TS + lower 5b of TS_MSB after DPB - << " SX TsMsb " << std::setw( 2 ) << ( ( ulOldHitTime >> 8 ) & 0x3 ) // 2 lower bits of TS_MSB from overlap bits in hit frame or from DPB - << " DPB TsMsb " << std::setw( 9 ) << ( (ulOldHitTime >> 10 ) & 0xF ) // 4 (+16) higher bits of TS_MSB from DPB - << " TsMsb " << std::setw( 9 ) << (ulOldHitTime >> 8) - << " MsbCy " << std::setw( 4 ) << fvuCurrentTsMsbCycle[fuCurrDpbIdx] - << " Time " << std::setw ( 12 ) << ulOldHitTime - << " Time " << std::setw ( 5 ) << (ulOldHitTime * stsxyter::kdClockCycleNs - fdStartTime)* 1e-9; - LOG(info) << " New Hit chan " << std::setw( 3 ) << usChan - << " TS " << std::setw( 3 ) << (ulNewHitTime & 0xFF) // 8 bits TS - << " Full TS " << std::setw( 5 ) << (ulNewHitTime & 0x3FFF) // Total StsXyter TS = 14 bits => 9b Hit TS + lower 5b of TS_MSB after DPB - << " SX TsMsb " << std::setw( 2 ) << ( ( ulNewHitTime >> 8 ) & 0x3 ) // 2 lower bits of TS_MSB from overlap bits in hit frame or from DPB - << " DPB TsMsb " << std::setw( 9 ) << ( (ulNewHitTime >> 10 ) & 0xF ) // 4 (+16) higher bits of TS_MSB from DPB - << " TsMsb " << std::setw( 9 ) << (ulNewHitTime >> 8) - << " MsbCy " << std::setw( 4 ) << fvuCurrentTsMsbCycle[fuCurrDpbIdx] - << " Time " << std::setw ( 12 ) << fvulChanLastHitTime[ uAsicIdx ][ usChan ] - << " Time " << std::setw ( 5 ) << dTimeSinceStartSec; - } // if( ulOldHitTime & 0x00003C00 != fvulChanLastHitTime[ uAsicIdx ][ usChan ] & 0x00003C00 ) -*/ - if( 0 == usChan ) - { -/* - if( 22.2 < dTimeSinceStartSec && dTimeSinceStartSec < 22.6 ) -// if( (443.574 < dTimeSinceStartSec && dTimeSinceStartSec < 443.575) || 32 != fuNbTsMsbSinceLastHit ) -// if( 32 != fuNbTsMsbSinceLastHit ) - { - Long64_t ulNewHitTime = fvulChanLastHitTime[ uAsicIdx ][ usChan ]; - LOG(info) << fuNbTsMsbSinceLastHit << " TS_MSB since last hit on channel 0 "; - LOG(info) << " New Hit chan " << std::setw( 3 ) << usChan - << " TS " << std::setw( 3 ) << (ulNewHitTime & 0xFF) // 8 bits TS - << " Full TS " << std::setw( 5 ) << (ulNewHitTime & 0x3FFF) // Total StsXyter TS = 14 bits => 9b Hit TS + lower 5b of TS_MSB after DPB - << " SX TsMsb " << std::setw( 2 ) << ( ( ulNewHitTime >> 8 ) & 0x3 ) // 2 lower bits of TS_MSB from overlap bits in hit frame or from DPB - << " DPB TsMsb " << std::setw( 9 ) << ( (ulNewHitTime >> 10 ) & 0xF ) // 4 (+16) higher bits of TS_MSB from DPB - << " TsMsb " << std::setw( 9 ) << (ulNewHitTime >> 8) - << " MsbCy " << std::setw( 4 ) << fvuCurrentTsMsbCycle[fuCurrDpbIdx] - << " Time " << std::setw ( 12 ) << fvulChanLastHitTime[ uAsicIdx ][ usChan ] - << " Time " << std::setw ( 5 ) << dTimeSinceStartSec; - } // if( 443.573 < dTimeSinceStartSec && dTimeSinceStartSec < 443.672 ) -*/ - fuNbTsMsbSinceLastHit = 0; - } // if( 0 == usChan ) - fuNbHitsLastTsMsb++; -/* - /// Pulse counting for pulser - if( 0 == fvuAsicTimeLastPulse[ uAsicIdx ] ) - { - /// Update the time of last Pulse - fvuAsicTimeLastPulse[ uAsicIdx ] = fvulChanLastHitTime[ uAsicIdx ][ usChan ]; - fvbPulseThereChan[ uAsicIdx ][ usChan ] = kTRUE; - } // if( 0 == fvuAsicTimeLastPulse[ uAsicIdx ] ) - else if( fvulChanLastHitTime[ uAsicIdx ][ usChan ] - fvuAsicTimeLastPulse[ uAsicIdx ] < 10 ) - { - fvbPulseThereChan[ uAsicIdx ][ usChan ] = kTRUE; - } // if( fvulChanLastHitTime[ uAsicIdx ][ usChan ] - fvuAsicTimeLastPulse[ uAsicIdx ] < 10 ) - else - { - UInt_t uNbChanThere = 0; - for( UInt_t uChanLoop = 0; uChanLoop < fuNbChanPerAsic; ++uChanLoop ) - { - if( kTRUE == fvbPulseThereChan[ uAsicIdx ][ uChanLoop ] ) - uNbChanThere++; - fvbPulseThereChan[ uAsicIdx ][ uChanLoop ] = kFALSE; - } // for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - - /// Fill the count histo - fhPulseChanCountEvo[ uAsicIdx ]->Fill( dTimeSinceStartSec, uNbChanThere ); - - /// Update the time of last Pulse - fvuAsicTimeLastPulse[ uAsicIdx ] = fvulChanLastHitTime[ uAsicIdx ][ usChan ]; - fvbPulseThereChan[ uAsicIdx ][ usChan ] = kTRUE; - } // else of if( fvulChanLastHitTime[ uAsicIdx ][ usChan ] - fvuAsicTimeLastPulse[ uAsicIdx ] < 10 ) -*/ -} - -void CbmCosy2018MonitorScan::FillTsMsbInfo( stsxyter::Message mess, UInt_t /*uMessIdx*/, UInt_t /*uMsIdx*/ ) -{ - UInt_t uVal = mess.GetTsMsbVal(); -/* - if( 0 == fuCurrDpbIdx ) - LOG(info) << " TS " << std::setw( 12 ) << fulCurrentTsIdx - << " MS " << std::setw( 12 ) << fulCurrentMsIdx - << " MsInTs " << std::setw( 3 ) << uMsIdx - << " DPB " << std::setw( 2 ) << fuCurrDpbIdx - << " Mess " << std::setw( 5 ) << uMessIdx - << " TsMsb " << std::setw( 5 ) << uVal; -*/ - -/* - if( (uVal != fvulCurrentTsMsb[fuCurrDpbIdx] + 1) && 0 < uVal && - !( 1 == uMessIdx && usVal == fvulCurrentTsMsb[fuCurrDpbIdx] ) ) // 1st TS_MSB in MS is always a repeat of the last one in previous MS! - { - LOG(info) << "TS MSB not increasing by 1! TS " << std::setw( 12 ) << fulCurrentTsIdx - << " MS " << std::setw( 12 ) << fulCurrentMsIdx - << " MsInTs " << std::setw( 3 ) << uMsIdx - << " DPB " << std::setw( 2 ) << fuCurrDpbIdx - << " Mess " << std::setw( 5 ) << uMessIdx - << " Old TsMsb " << std::setw( 5 ) << fvulCurrentTsMsb[fuCurrDpbIdx] - << " new TsMsb " << std::setw( 5 ) << uVal - << " Diff " << std::setw( 5 ) << uVal - fvulCurrentTsMsb[fuCurrDpbIdx] - << " Old MsbCy " << std::setw( 5 ) << fvuCurrentTsMsbCycle[fuCurrDpbIdx]; - } // if( (uVal != fvulCurrentTsMsb[fuCurrDpbIdx] + 1) && 0 < uVal ) -*/ - if( uVal != fvulCurrentTsMsb[fuCurrDpbIdx] ) - fuNbTsMsbSinceLastHit++; - - // Update Status counters - if( uVal < fvulCurrentTsMsb[fuCurrDpbIdx] ) - { - - LOG(info) << " TS " << std::setw( 12 ) << fulCurrentTsIdx - << " MS " << std::setw( 12 ) << fulCurrentMsIdx - << " DPB " << std::setw( 2 ) << fuCurrDpbIdx - << " Old TsMsb " << std::setw( 5 ) << fvulCurrentTsMsb[fuCurrDpbIdx] - << " Old MsbCy " << std::setw( 5 ) << fvuCurrentTsMsbCycle[fuCurrDpbIdx] - << " new TsMsb " << std::setw ( 5 ) << uVal; - - fvuCurrentTsMsbCycle[fuCurrDpbIdx] ++; - } // if( uVal < fvulCurrentTsMsb[fuCurrDpbIdx] ) - fvulCurrentTsMsb[fuCurrDpbIdx] = uVal; -/* - if( 1 < uMessIdx ) - { - fhStsDpbRawTsMsb->Fill( fuCurrDpbIdx, fvulCurrentTsMsb[fuCurrDpbIdx] ); - fhStsDpbRawTsMsbSx->Fill( fuCurrDpbIdx, ( fvulCurrentTsMsb[fuCurrDpbIdx] & 0x1F ) ); - fhStsDpbRawTsMsbDpb->Fill( fuCurrDpbIdx, ( fvulCurrentTsMsb[fuCurrDpbIdx] >> 5 ) ); - } // if( 0 < uMessIdx ) -*/ -// fhStsAsicTsMsb->Fill( fvulCurrentTsMsb[fuCurrDpbIdx], uAsicIdx ); -/* - ULong64_t ulNewTsMsbTime = static_cast< ULong64_t >( stsxyter::kuHitNbTsBins ) - * static_cast< ULong64_t >( fvulCurrentTsMsb[fuCurrDpbIdx]) - + static_cast< ULong64_t >( stsxyter::kulTsCycleNbBins ) - * static_cast< ULong64_t >( fvuCurrentTsMsbCycle[fuCurrDpbIdx] ); -*/ - // Check Starting point of histos with time as X axis - if( 0 < fdStartTime ) - { -// Double_t dTimeSinceStartSec = ( ulNewTsMsbTime * stsxyter::kdClockCycleNs - fdStartTime)* 1e-9; -/* -// if( 443.573 < dTimeSinceStartSec && dTimeSinceStartSec < 443.672 ) - if( 443.574 < dTimeSinceStartSec && dTimeSinceStartSec < 443.575 ) - LOG(info) << " TS " << std::setw( 12 ) << fulCurrentTsIdx - << " MS " << std::setw( 12 ) << fulCurrentMsIdx - << " TsMsb " << std::setw( 9 ) << uVal - << " MsbCy " << std::setw( 5 ) << fvuCurrentTsMsbCycle[fuCurrDpbIdx] - << " Time " << std::setw ( 12 ) << ulNewTsMsbTime - << " Time " << std::setw ( 5 ) << dTimeSinceStartSec - << " Nb Hits last TS_MSB " << fuNbHitsLastTsMsb; -*/ - fuNbHitsLastTsMsb = 0; - } // if( 0 < fdStartTime ) - -/* - Double_t dUpdatePeriodInSec = 1; - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - Double_t dTimeInS = ( ulNewTsMsbTime - fvulStartTimeLastS[ uXyterIdx ] ) - * stsxyter::kdClockCycleNs - * 1e-9; - - if( dUpdatePeriodInSec <= dTimeInS || (ulNewTsMsbTime < fvulStartTimeLastS[ uXyterIdx ] ) ) - { - UInt_t uNbHitsTotal = fvuNbHitDiffTsAsicLastS[ uXyterIdx ] + fvuNbHitSameTsAsicLastS[ uXyterIdx ]; - if( 0 < uNbHitsTotal && dTimeInS < 2 * dUpdatePeriodInSec ) - { - Double_t dRate = static_cast< Double_t >( uNbHitsTotal ) / dTimeInS; - Double_t dRatioSameTs = static_cast< Double_t >( fvuNbHitSameTsAsicLastS[ uXyterIdx ] ) - / uNbHitsTotal; - Double_t dRatioSameTsAdc = static_cast< Double_t >( fvuNbHitSameTsAdcAsicLastS[ uXyterIdx ] ) - / uNbHitsTotal; - Double_t dRatioSameAdcSameTs = static_cast< Double_t >( fvuNbHitSameTsAdcAsicLastS[ uXyterIdx ] ) - / fvuNbHitSameTsAsicLastS[ uXyterIdx ]; - - fhSetupSortedAsicRatioSameTsVsFlux[ uXyterIdx ]->Fill( dRate, dRatioSameTs ); - fhSetupSortedAsicRatioSameTsAdcVsFlux[ uXyterIdx ]->Fill( dRate, dRatioSameTsAdc ); - fhSetupSortedAsicRatioSameAdcSameTsVsFlux[ uXyterIdx ]->Fill( dRate, dRatioSameAdcSameTs ); - - } // if( 0 < uNbHitsTotal && dTimeInS < 2 * dUpdatePeriodInSec ) - - fvulStartTimeLastS[ uXyterIdx ] = ulNewTsMsbTime; - fvuNbHitDiffTsAsicLastS[ uXyterIdx ] = 0; - fvuNbHitSameTsAsicLastS[ uXyterIdx ] = 0; - fvuNbHitSameTsAdcAsicLastS[ uXyterIdx ] = 0; - } // if( dUpdatePeriodInSec <= dTimeInS || (ulNewTsMsbTime < fvulStartTimeLastS[ uXyterIdx ] ) ) - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) -*/ -} - -void CbmCosy2018MonitorScan::FillEpochInfo( stsxyter::Message /*mess*/ ) -{ -// UInt_t uVal = mess.GetTsMsbVal(); -/* - // Update Status counters - if( usVal < fvulCurrentTsMsb[fuCurrDpbIdx] ) - fvuCurrentTsMsbCycle[fuCurrDpbIdx] ++; - fvulCurrentTsMsb[fuCurrDpbIdx] = usVal; - -// fhStsAsicTsMsb->Fill( fvulCurrentTsMsb[fuCurrDpbIdx], uAsicIdx ); -*/ -} - -void CbmCosy2018MonitorScan::Reset() -{ -} - -void CbmCosy2018MonitorScan::Finish() -{ - - LOG(info) << "-------------------------------------"; - LOG(info) << "CbmCosy2018MonitorScan statistics are "; - LOG(info) << " Hit messages: " << fmMsgCounter[ stsxyter::MessType::Hit ] << "\n" - << " Ts MSB messages: " << fmMsgCounter[ stsxyter::MessType::TsMsb ] << "\n" - << " Dummy messages: " << fmMsgCounter[ stsxyter::MessType::Dummy ] << "\n" - << " Epoch messages: " << fmMsgCounter[ stsxyter::MessType::Epoch ] << "\n" - << " Empty messages: " << fmMsgCounter[ stsxyter::MessType::Empty ]; - - LOG(info) << "-------------------------------------"; - - SaveAllHistos( fsHistoFileFullname ); - LOG(info) << "CbmCosy2018MonitorScan done saving histos "; - LOG(info) << "-------------------------------------"; - -// SaveAllHistos(); - -} - - -void CbmCosy2018MonitorScan::FillOutput(boost::any) -{ -} - -void CbmCosy2018MonitorScan::SaveAllHistos( TString sFileName ) -{ - /*******************************************************************/ -/* - TCanvas* cFebRatioDupli = new TCanvas( "cFebRatioDupli", - "Hodoscopes coincidence quality", - 800, 600); - cFebRatioDupli->Divide( 2, fuNbStsXyters/2 + fuNbStsXyters%2 ); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - cFebRatioDupli->cd(1 + uXyterIdx ); - gPad->SetLogz(); - fhSetupSortedNbSameTsChan[ uXyterIdx ]->Draw( "colz" ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) -*/ - /*******************************************************************/ - - TDirectory * oldDir = NULL; - TFile * histoFile = NULL; - if( "" != sFileName ) - { - // Store current directory position to allow restore later - oldDir = gDirectory; - // open separate histo file in recreate mode - histoFile = new TFile( sFileName , "RECREATE"); - histoFile->cd(); - } // if( "" != sFileName ) - - gDirectory->mkdir("Sts_Raw"); - gDirectory->cd("Sts_Raw"); - - fhHodoMessType->Write(); - fhHodoSysMessType->Write(); - fhHodoMessTypePerDpb->Write(); - fhHodoSysMessTypePerDpb->Write(); - fhHodoMessTypePerElink->Write(); - fhHodoSysMessTypePerElink->Write(); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fhHodoChanCntRaw[ uXyterIdx ]->Write(); - fhHodoChanAdcRaw[ uXyterIdx ]->Write(); - fhHodoChanAdcRawProf[ uXyterIdx ]->Write(); - fhHodoChanRawTs[ uXyterIdx ]->Write(); - fhHodoChanMissEvt[ uXyterIdx ]->Write(); - fhHodoChanMissEvtEvo[ uXyterIdx ]->Write(); - fhHodoFebMissEvtEvo[ uXyterIdx ]->Write(); - fhHodoChanHitRateEvo[ uXyterIdx ]->Write(); - fhHodoFebRateEvo[ uXyterIdx ]->Write(); - fhHodoChanHitRateEvoLong[ uXyterIdx ]->Write(); - fhHodoFebRateEvoLong[ uXyterIdx ]->Write(); -/* - if( kTRUE == fbLongHistoEnable ) - { - fhFebRateEvoLong[ uXyterIdx ]->Write(); - fhFebChRateEvoLong[ uXyterIdx ]->Write(); - } // if( kTRUE == fbLongHistoEnable ) -*/ - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - fhHodoChanHitRateEvoZoom->Write(); - -/* - fhSetupSortedDtX1Y1->Write(); - fhSetupSortedDtX2Y2->Write(); - fhSetupSortedDtN1P1->Write(); - fhSetupSortedDtN2P2->Write(); - fhSetupSortedDtX1Y1X2Y2->Write(); - fhSetupSortedDtN1P1N2P2->Write(); - fhSetupSortedDtX1Y1X2Y2N1P1->Write(); - fhSetupSortedDtX1Y1X2Y2N2P2->Write(); - fhSetupSortedDtH1H2S1S2->Write(); - fhSetupSortedMapX1Y1->Write(); - fhSetupSortedMapX2Y2->Write(); - fhSetupSortedMapN1P1->Write(); - fhSetupSortedMapN2P2->Write(); - fhSetupSortedCntEvoX1Y1->Write(); - fhSetupSortedCntEvoX2Y2->Write(); - fhSetupSortedCntEvoN1P1->Write(); - fhSetupSortedCntEvoN2P2->Write(); - - fhBothHodoSortedDtX1Y1->Write(); - fhBothHodoSortedDtX2Y2->Write(); - fhBothHodoSortedDtX1Y1X2Y2N1P1->Write(); - fhBothHodoSortedDtX1Y1X2Y2N2P2->Write(); - fhBothHodoSortedDtH1H2S1S2->Write(); - fhBothHodoSortedMapX1Y1->Write(); - fhBothHodoSortedMapX2Y2->Write(); - fhBothHodoSortedCntEvoX1Y1->Write(); - fhBothHodoSortedCntEvoX2Y2->Write(); - - fhH1H2S1SortedDtX1Y1->Write(); - fhH1H2S1SortedDtX2Y2->Write(); - fhH1H2S1SortedDtN1P1->Write(); - fhH1H2S1SortedDtN2P2->Write(); - fhH1H2S1SortedMapX1Y1->Write(); - fhH1H2S1SortedMapX2Y2->Write(); - fhH1H2S1SortedMapN1P1->Write(); - fhH1H2S1SortedMapN2P2->Write(); - fhH1H2S1SortedCntEvoX1Y1->Write(); - fhH1H2S1SortedCntEvoX2Y2->Write(); - fhH1H2S1SortedCntEvoN1P1->Write(); - fhH1H2S1SortedCntEvoN2P2->Write(); - - fhH1H2S2SortedDtX1Y1->Write(); - fhH1H2S2SortedDtX2Y2->Write(); - fhH1H2S2SortedDtN1P1->Write(); - fhH1H2S2SortedDtN2P2->Write(); - fhH1H2S2SortedMapX1Y1->Write(); - fhH1H2S2SortedMapX2Y2->Write(); - fhH1H2S2SortedMapN1P1->Write(); - fhH1H2S2SortedMapN2P2->Write(); - fhH1H2S2SortedCntEvoX1Y1->Write(); - fhH1H2S2SortedCntEvoX2Y2->Write(); - fhH1H2S2SortedCntEvoN1P1->Write(); - fhH1H2S2SortedCntEvoN2P2->Write(); - - fhSystSortedDtX1Y1->Write(); - fhSystSortedDtX2Y2->Write(); - fhSystSortedDtN1P1->Write(); - fhSystSortedDtN2P2->Write(); - fhSystSortedDtX1Y1X2Y2 ->Write(); - fhSystSortedMapX1Y1->Write(); - fhSystSortedMapX2Y2->Write(); - fhSystSortedMapN1P1->Write(); - fhSystSortedMapN2P2->Write(); - fhSystSortedCntEvoX1Y1->Write(); - fhSystSortedCntEvoX2Y2->Write(); - fhSystSortedCntEvoN1P1->Write(); - fhSystSortedCntEvoN2P2->Write(); - - fhSystSortedDtN1X1vsN1X2->Write(); - fhSystSortedDtP1X1vsP1X2->Write(); - fhSystSortedDtN1X1vsP1X1->Write(); - fhSystSortedDtSts1Hodo1vsSts1Hodo2->Write(); - fhSystSortedDtSts2Hodo1vsSts2Hodo2->Write(); - fhSystSortedDtAllVsMapX1->Write(); - fhSystSortedDtAllVsMapY1->Write(); - fhSystSortedDtAllVsMapX2->Write(); - fhSystSortedDtAllVsMapY2->Write(); - - fhSetupSortedDtX1->Write(); - fhSetupSortedDtY1->Write(); - fhSetupSortedDtX2->Write(); - fhSetupSortedDtY2->Write(); - fhSetupSortedDtN1->Write(); - fhSetupSortedDtP1->Write(); - fhSetupSortedDtN2->Write(); - fhSetupSortedDtP2->Write(); -*/ - - gDirectory->cd(".."); - - /***************************/ -/** STSXYTER v2.0 Bug, triggering condition detection **/ - gDirectory->mkdir("Sts_Tagging"); - gDirectory->cd("Sts_Tagging"); - - fhCoincWinFlagEvo->Write(); - fhCoincWinFlagEvoImpr2->Write(); - fhCoincWinFlagEvoMoreCond->Write(); - fhCoincWinFlagEntriesEvoOn->Write(); - fhCoincWinFlagEntriesEvoOff->Write(); - fhCoincWinFlagDiffEvo->Write(); - - fhCoincWinFlagEntriesEvoOnA->Write(); - fhCoincWinFlagEntriesEvoOffA->Write(); - fhCoincWinFlagEntriesEvoOnB->Write(); - fhCoincWinFlagEntriesEvoOffB->Write(); - fhCoincWinFlagEntriesEvoOnC->Write(); - fhCoincWinFlagEntriesEvoOffC->Write(); - - fhCoincWinFlagDiffEvoA2->Write(); - fhCoincWinFlagDiffEvoB2->Write(); - fhCoincWinFlagDiffEvoC2->Write(); - - fhBadWinRatio->Write(); ///add - fhBadDataRatio->Write(); ///add - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fhNbFiredChanPerMs[ uXyterIdx ]->Write(); - fhNbMultiHitChanPerMs[ uXyterIdx ]->Write(); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - - gDirectory->cd(".."); -/** STSXYTER v2.0 Bug, triggering condition detection **/ - /***************************/ - -/* - gDirectory->mkdir("Sts_Dupli"); - gDirectory->cd("Sts_Dupli"); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fhSetupSortedNbSameTsChan[ uXyterIdx ]->Write(); - fhSetupSortedSameTsAdcChan[ uXyterIdx ]->Write(); - fhSetupSortedSameTsAdcDiff[ uXyterIdx ]->Write(); - fhSetupSortedRatioSameTsChan[ uXyterIdx ]->Write(); - fhSetupSortedNbConsSameTsChan[ uXyterIdx ]->Write(); - fhSetupSortedNbConsSameTsAdcChan[ uXyterIdx ]->Write(); - fhSetupSortedNbConsSameTsVsTsAdc[ uXyterIdx ]->Write(); - - fhSetupSortedAsicRatioSameTsVsFlux[ uXyterIdx ]->Write(); - fhSetupSortedAsicRatioSameTsAdcVsFlux[ uXyterIdx ]->Write(); - fhSetupSortedAsicRatioSameAdcSameTsVsFlux[ uXyterIdx ]->Write(); - - fhRatioSameTsSpillEvo[ uXyterIdx ]->Write(); - fhRatioSameTsAdcSpillEvo[ uXyterIdx ]->Write(); - fhRatioSameAdcSameTsSpillEvo[ uXyterIdx ]->Write(); - - fhSetupSortedTsFirstDuplicateChan[ uXyterIdx ]->Write(); - fhSetupSortedTsGoodChan[ uXyterIdx ]->Write(); - - fhFractionHitsAsicSpillEvo[ uXyterIdx ]->Write(); - fhFractionHitsAsicEvo[ uXyterIdx ]->Write(); - - fhAsicDuplicDtLastHits[ uXyterIdx ]->Write(); - fhAsicDuplicCompTs[ uXyterIdx ]->Write(); - fhAsicDuplicTsLsb[ uXyterIdx ]->Write(); - fhAsicDuplicTsMsbAsic[ uXyterIdx ]->Write(); - - fhAsicDuplicTs[ uXyterIdx ]->Write(); - fhAsicGoodTs[ uXyterIdx ]->Write(); - fhAsicDuplicTsMsb[ uXyterIdx ]->Write(); - fhAsicGoodTsMsb[ uXyterIdx ]->Write(); - fhAsicDuplicTsFull[ uXyterIdx ]->Write(); - fhAsicGoodTsFull[ uXyterIdx ]->Write(); - - fhHodoChanCntGood[ uXyterIdx ]->Write(); - fhHodoChanGoodHitRateEvo[ uXyterIdx ]->Write(); - fhPulseChanCountEvo[ uXyterIdx ]->Write(); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - fhAsicGoodTsEvoAsic0Chan01->Write(); - fhAsicGoodTsMsbEvoAsic0Chan01->Write(); - fhAsicGoodTsFullEvoAsic0Chan01->Write(); - fhAsicGoodTsFullEvoProfAsic0Chan01->Write(); - fhAsicDuplicTsEvoAsic0Chan01->Write(); - fhAsicGoodTsEvoAsic0Chan09->Write(); - fhAsicDuplicTsEvoAsic0Chan09->Write(); - fhAsicGoodTsFullEvoProfAsic0Chan09->Write(); - fhAsicGoodTsEvoAsic0Chan16->Write(); - fhAsicDuplicTsEvoAsic0Chan16->Write(); - fhAsicGoodTsFullEvoProfAsic0Chan16->Write(); - fhAsicMissedChanIdVsPulseIdx->Write(); - fhAsicMissedChanGroupVsPulseIdx->Write(); - - for( UInt_t uDpbIdx = 0; uDpbIdx < fuNrOfDpbs; ++uDpbIdx ) - { - fhFractionGoodHitsSpillEvo[ uDpbIdx ]->Write(); - fhFractionDupliHitsSpillEvo[ uDpbIdx ]->Write(); - fhFractionTsMsbSpillEvo[ uDpbIdx ]->Write(); - fhFractionEpochSpillEvo[ uDpbIdx ]->Write(); - fhFractionEmptySpillEvo[ uDpbIdx ]->Write(); - - fhFractionGoodHitsEvo[ uDpbIdx ]->Write(); - fhFractionDupliHitsEvo[ uDpbIdx ]->Write(); - fhFractionTsMsbEvo[ uDpbIdx ]->Write(); - fhFractionEpochEvo[ uDpbIdx ]->Write(); - fhFractionEmptyEvo[ uDpbIdx ]->Write(); - } // for( UInt_t uDpbIdx = 0; uDpbIdx < fuNrOfDpbs; ++uDpbIdx ) - fhFractionAsics->Write(); - fhFractionTypes->Write(); - - cFebRatioDupli->Write(); - delete cFebRatioDupli; - - gDirectory->cd(".."); -*/ - // Flib Histos - gDirectory->mkdir("Flib_Raw"); - gDirectory->cd("Flib_Raw"); - for( UInt_t uLinks = 0; uLinks < kiMaxNbFlibLinks; uLinks ++) - { - TString sMsSzName = Form("MsSz_link_%02u", uLinks); - if( fHM->Exists(sMsSzName.Data() ) ) - fHM->H1( sMsSzName.Data() )->Write(); - - sMsSzName = Form("MsSzTime_link_%02u", uLinks); - if( fHM->Exists(sMsSzName.Data() ) ) - fHM->P1( sMsSzName.Data() )->Write(); - } // for( UInt_t uLinks = 0; uLinks < 16; uLinks ++) - - TH1 * pMissedTsH1 = dynamic_cast< TH1 * >( gROOT->FindObjectAny( "Missed_TS" ) ); - if( NULL != pMissedTsH1 ) - pMissedTsH1->Write(); - - TProfile * pMissedTsEvoP = dynamic_cast< TProfile * >( gROOT->FindObjectAny( "Missed_TS_Evo" ) ); - if( NULL != pMissedTsEvoP ) - pMissedTsEvoP->Write(); - - gDirectory->cd(".."); - - if( "" != sFileName ) - { - // Restore original directory position - histoFile->Close(); - oldDir->cd(); - } // if( "" != sFileName ) - -} -void CbmCosy2018MonitorScan::ResetAllHistos() -{ - LOG(info) << "Reseting all STS histograms."; - - fhHodoMessType->Reset(); - fhHodoSysMessType->Reset(); - fhHodoMessTypePerDpb->Reset(); - fhHodoSysMessTypePerDpb->Reset(); - fhHodoMessTypePerElink->Reset(); - fhHodoSysMessTypePerElink->Reset(); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fhHodoChanCntRaw[ uXyterIdx ]->Reset(); - fhHodoChanAdcRaw[ uXyterIdx ]->Reset(); - fhHodoChanAdcRawProf[ uXyterIdx ]->Reset(); - fhHodoChanRawTs[ uXyterIdx ]->Reset(); - fhHodoChanMissEvt[ uXyterIdx ]->Reset(); - fhHodoChanMissEvtEvo[ uXyterIdx ]->Reset(); - fhHodoFebMissEvtEvo[ uXyterIdx ]->Reset(); - fhHodoChanHitRateEvo[ uXyterIdx ]->Reset(); - fhHodoFebRateEvo[ uXyterIdx ]->Reset(); - fhHodoChanHitRateEvoLong[ uXyterIdx ]->Reset(); - fhHodoFebRateEvoLong[ uXyterIdx ]->Reset(); -/* - if( kTRUE == fbLongHistoEnable ) - { - ftStartTimeUnix = std::chrono::steady_clock::now(); - fhFebRateEvoLong[ uXyterIdx ]->Reset(); - fhFebChRateEvoLong[ uXyterIdx ]->Reset(); - } // if( kTRUE == fbLongHistoEnable ) -*/ - fhNbFiredChanPerMs[ uXyterIdx ]->Reset(); - fhNbMultiHitChanPerMs[ uXyterIdx ]->Reset(); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - fhHodoChanHitRateEvoZoom->Reset(); -/* - fhSetupSortedDtX1Y1->Reset(); - fhSetupSortedDtX2Y2->Reset(); - fhSetupSortedDtN1P1->Reset(); - fhSetupSortedDtN2P2->Reset(); - fhSetupSortedDtX1Y1X2Y2->Reset(); - fhSetupSortedDtN1P1N2P2->Reset(); - fhSetupSortedDtX1Y1X2Y2N1P1->Reset(); - fhSetupSortedDtX1Y1X2Y2N2P2->Reset(); - fhSetupSortedDtH1H2S1S2->Reset(); - fhSetupSortedMapX1Y1->Reset(); - fhSetupSortedMapX2Y2->Reset(); - fhSetupSortedMapN1P1->Reset(); - fhSetupSortedMapN2P2->Reset(); - fhSetupSortedCntEvoX1Y1->Reset(); - fhSetupSortedCntEvoX2Y2->Reset(); - fhSetupSortedCntEvoN1P1->Reset(); - fhSetupSortedCntEvoN2P2->Reset(); - - fhBothHodoSortedDtX1Y1->Reset(); - fhBothHodoSortedDtX2Y2->Reset(); - fhBothHodoSortedDtX1Y1X2Y2N1P1->Reset(); - fhBothHodoSortedDtX1Y1X2Y2N2P2->Reset(); - fhBothHodoSortedDtH1H2S1S2->Reset(); - fhBothHodoSortedMapX1Y1->Reset(); - fhBothHodoSortedMapX2Y2->Reset(); - fhBothHodoSortedCntEvoX1Y1->Reset(); - fhBothHodoSortedCntEvoX2Y2->Reset(); - - fhH1H2S1SortedDtX1Y1->Reset(); - fhH1H2S1SortedDtX2Y2->Reset(); - fhH1H2S1SortedDtN1P1->Reset(); - fhH1H2S1SortedDtN2P2->Reset(); - fhH1H2S1SortedMapX1Y1->Reset(); - fhH1H2S1SortedMapX2Y2->Reset(); - fhH1H2S1SortedMapN1P1->Reset(); - fhH1H2S1SortedMapN2P2->Reset(); - fhH1H2S1SortedCntEvoX1Y1->Reset(); - fhH1H2S1SortedCntEvoX2Y2->Reset(); - fhH1H2S1SortedCntEvoN1P1->Reset(); - fhH1H2S1SortedCntEvoN2P2->Reset(); - - fhH1H2S2SortedDtX1Y1->Reset(); - fhH1H2S2SortedDtX2Y2->Reset(); - fhH1H2S2SortedDtN1P1->Reset(); - fhH1H2S2SortedDtN2P2->Reset(); - fhH1H2S2SortedMapX1Y1->Reset(); - fhH1H2S2SortedMapX2Y2->Reset(); - fhH1H2S2SortedMapN1P1->Reset(); - fhH1H2S2SortedMapN2P2->Reset(); - fhH1H2S2SortedCntEvoX1Y1->Reset(); - fhH1H2S2SortedCntEvoX2Y2->Reset(); - fhH1H2S2SortedCntEvoN1P1->Reset(); - fhH1H2S2SortedCntEvoN2P2->Reset(); - - fhSystSortedDtX1Y1->Reset(); - fhSystSortedDtX2Y2->Reset(); - fhSystSortedDtN1P1->Reset(); - fhSystSortedDtN2P2->Reset(); - fhSystSortedDtX1Y1X2Y2 ->Reset(); - fhSystSortedMapX1Y1->Reset(); - fhSystSortedMapX2Y2->Reset(); - fhSystSortedMapN1P1->Reset(); - fhSystSortedMapN2P2->Reset(); - fhSystSortedCntEvoX1Y1->Reset(); - fhSystSortedCntEvoX2Y2->Reset(); - fhSystSortedCntEvoN1P1->Reset(); - fhSystSortedCntEvoN2P2->Reset(); - - fhSystSortedDtN1X1vsN1X2->Reset(); - fhSystSortedDtP1X1vsP1X2->Reset(); - fhSystSortedDtN1X1vsP1X1->Reset(); - fhSystSortedDtSts1Hodo1vsSts1Hodo2->Reset(); - fhSystSortedDtSts2Hodo1vsSts2Hodo2->Reset(); - fhSystSortedDtAllVsMapX1->Reset(); - fhSystSortedDtAllVsMapY1->Reset(); - fhSystSortedDtAllVsMapX2->Reset(); - fhSystSortedDtAllVsMapY2->Reset(); - - fhSetupSortedDtX1->Reset(); - fhSetupSortedDtY1->Reset(); - fhSetupSortedDtX2->Reset(); - fhSetupSortedDtY2->Reset(); - fhSetupSortedDtN1->Reset(); - fhSetupSortedDtP1->Reset(); - fhSetupSortedDtN2->Reset(); - fhSetupSortedDtP2->Reset(); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fhSetupSortedNbSameTsChan[ uXyterIdx ]->Reset(); - fhSetupSortedSameTsAdcChan[ uXyterIdx ]->Reset(); - fhSetupSortedSameTsAdcDiff[ uXyterIdx ]->Reset(); - fhSetupSortedRatioSameTsChan[ uXyterIdx ]->Reset(); - fhSetupSortedNbConsSameTsChan[ uXyterIdx ]->Reset(); - fhSetupSortedNbConsSameTsAdcChan[ uXyterIdx ]->Reset(); - fhSetupSortedNbConsSameTsVsTsAdc[ uXyterIdx ]->Reset(); - - fhSetupSortedAsicRatioSameTsVsFlux[ uXyterIdx ]->Reset(); - fhSetupSortedAsicRatioSameTsAdcVsFlux[ uXyterIdx ]->Reset(); - fhSetupSortedAsicRatioSameAdcSameTsVsFlux[ uXyterIdx ]->Reset(); - - fhRatioSameTsSpillEvo[ uXyterIdx ]->Reset(); - fhRatioSameTsAdcSpillEvo[ uXyterIdx ]->Reset(); - fhRatioSameAdcSameTsSpillEvo[ uXyterIdx ]->Reset(); - - fhSetupSortedTsFirstDuplicateChan[ uXyterIdx ]->Reset(); - fhSetupSortedTsGoodChan[ uXyterIdx ]->Reset(); - - fhFractionHitsAsicSpillEvo[ uXyterIdx ]->Reset(); - fhFractionHitsAsicEvo[ uXyterIdx ]->Reset(); - - fhAsicDuplicDtLastHits[ uXyterIdx ]->Reset(); - fhAsicDuplicCompTs[ uXyterIdx ]->Reset(); - fhAsicDuplicTsLsb[ uXyterIdx ]->Reset(); - fhAsicDuplicTsMsbAsic[ uXyterIdx ]->Reset(); - fhAsicDuplicCompTsBitThere[ uXyterIdx ]->Reset(); - fhAsicDuplicTsLsbBitThere[ uXyterIdx ]->Reset(); - fhAsicDuplicTsMsbBitThere[ uXyterIdx ]->Reset(); - fhAsicDuplicTs[ uXyterIdx ]->Reset(); - fhAsicGoodTs[ uXyterIdx ]->Reset(); - fhAsicDuplicTsMsb[ uXyterIdx ]->Reset(); - fhAsicGoodTsMsb[ uXyterIdx ]->Reset(); - fhAsicDuplicTsFull[ uXyterIdx ]->Reset(); - fhAsicGoodTsFull[ uXyterIdx ]->Reset(); - fhAsicDuplicTsBitPattern[ uXyterIdx ]->Reset(); - fhAsicGoodTsBitPattern[ uXyterIdx ]->Reset(); - - fhHodoChanCntGood[ uXyterIdx ]->Reset(); - fhHodoChanGoodHitRateEvo[ uXyterIdx ]->Reset(); - fhPulseChanCountEvo[ uXyterIdx ]->Reset(); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - - fhAsicGoodTsEvoAsic0Chan01->Reset(); - fhAsicGoodTsMsbEvoAsic0Chan01->Reset(); - fhAsicGoodTsFullEvoAsic0Chan01->Reset(); - fhAsicGoodTsFullEvoProfAsic0Chan01->Reset(); - fhAsicDuplicTsEvoAsic0Chan01->Reset(); - fhAsicGoodTsEvoAsic0Chan09->Reset(); - fhAsicDuplicTsEvoAsic0Chan09->Reset(); - fhAsicGoodTsFullEvoProfAsic0Chan09->Reset(); - fhAsicGoodTsEvoAsic0Chan16->Reset(); - fhAsicDuplicTsEvoAsic0Chan16->Reset(); - fhAsicGoodTsFullEvoProfAsic0Chan16->Reset(); - fuPulseIdx = 0; - fhAsicMissedChanIdVsPulseIdx->Reset(); - fhAsicMissedChanGroupVsPulseIdx->Reset(); - - for( UInt_t uDpbIdx = 0; uDpbIdx < fuNrOfDpbs; ++uDpbIdx ) - { - fhFractionGoodHitsSpillEvo[ uDpbIdx ]->Reset(); - fhFractionDupliHitsSpillEvo[ uDpbIdx ]->Reset(); - fhFractionTsMsbSpillEvo[ uDpbIdx ]->Reset(); - fhFractionEpochSpillEvo[ uDpbIdx ]->Reset(); - fhFractionEmptySpillEvo[ uDpbIdx ]->Reset(); - - fhFractionGoodHitsEvo[ uDpbIdx ]->Reset(); - fhFractionDupliHitsEvo[ uDpbIdx ]->Reset(); - fhFractionTsMsbEvo[ uDpbIdx ]->Reset(); - fhFractionEpochEvo[ uDpbIdx ]->Reset(); - fhFractionEmptyEvo[ uDpbIdx ]->Reset(); - } // for( UInt_t uDpbIdx = 0; uDpbIdx < fuNrOfDpbs; ++uDpbIdx ) - fhFractionAsics->Reset(); - fhFractionTypes->Reset(); -*/ - -/** STSXYTER v2.0 Bug, triggering condition detection **/ - fhCoincWinFlagEvo->Reset(); - fhCoincWinFlagEvoImpr2->Reset(); - fhCoincWinFlagEvoMoreCond->Reset(); - fhCoincWinFlagEntriesEvoOn->Reset(); - fhCoincWinFlagEntriesEvoOff->Reset(); - fhCoincWinFlagDiffEvo->Reset(); - - fhCoincWinFlagDiffEvoA2->Reset(); - fhCoincWinFlagDiffEvoB2->Reset(); - fhCoincWinFlagDiffEvoC2->Reset(); - fhBadWinRatio->Reset(); - fhBadDataRatio->Reset(); -/** STSXYTER v2.0 Bug, triggering condition detection **/ - - for( UInt_t uLinks = 0; uLinks < kiMaxNbFlibLinks; ++uLinks ) - { - TString sMsSzName = Form("MsSz_link_%02u", uLinks); - if( fHM->Exists(sMsSzName.Data() ) ) - fHM->H1( sMsSzName.Data() )->Reset(); - - sMsSzName = Form("MsSzTime_link_%02u", uLinks); - if( fHM->Exists(sMsSzName.Data() ) ) - fHM->P1( sMsSzName.Data() )->Reset(); - } // for( UInt_t uLinks = 0; uLinks < kiMaxNbFlibLinks; ++uLinks ) - - fdStartTime = -1; - fdStartTimeMsSz = -1; -} - -void CbmCosy2018MonitorScan::SetRunStart( Int_t dateIn, Int_t timeIn, Int_t iBinSize ) -{ - TDatime * fRunStartDateTime = new TDatime( dateIn, timeIn); - fiRunStartDateTimeSec = fRunStartDateTime->Convert(); - fiBinSizeDatePlots = iBinSize; - - LOG(info) << "Assigned new MUCH Run Start Date-Time: " << fRunStartDateTime->AsString(); -} - -void CbmCosy2018MonitorScan::SetLongDurationLimits( UInt_t uDurationSeconds, UInt_t uBinSize ) -{ - fbLongHistoEnable = kTRUE; - fuLongHistoNbSeconds = uDurationSeconds; - fuLongHistoBinSizeSec = uBinSize; -} - -/** STSXYTER v2.0 Bug, triggering condition detection **/ -Bool_t CbmCosy2018MonitorScan::CheckCoincWinBug( UInt_t uAsicIdx, Double_t dNewHitTime, Double_t dTimeSinceStartSec ) -{ - /// Indices book-keeping - if( kuNbHitCoincWinBug == fvuIdxFirstHitCoincWin[ uAsicIdx ] && - kuNbHitCoincWinBug == fvuIdxLastHitCoincWin[ uAsicIdx ] ) - { - /// 1st iteration => Initialize both indices on first slot in array - fvuIdxFirstHitCoincWin[ uAsicIdx ] = 0; - fvuIdxLastHitCoincWin[ uAsicIdx ] = 0; - fvdTimeLastHitsCoincWin[ uAsicIdx ][ fvuIdxLastHitCoincWin[ uAsicIdx ] ] = dNewHitTime; - - /// Exit as we have less hits than needed to trigger the bug - return kFALSE; - } // if both indices are 0 => 1st hit in this ASIC - else if( kuNbHitCoincWinBug - 1 == fvuIdxLastHitCoincWin[ uAsicIdx ] - fvuIdxFirstHitCoincWin[ uAsicIdx ] || - fvuIdxFirstHitCoincWin[ uAsicIdx ] - 1 == fvuIdxLastHitCoincWin[ uAsicIdx ] ) - { - /// Running loop once the array is full => shift indices for both first and last hit - fvuIdxFirstHitCoincWin[ uAsicIdx ] = ( fvuIdxFirstHitCoincWin[ uAsicIdx ] + 1 ) % kuNbHitCoincWinBug; - fvuIdxLastHitCoincWin[ uAsicIdx ] = ( fvuIdxLastHitCoincWin[ uAsicIdx ] + 1 ) % kuNbHitCoincWinBug; - fvdTimeLastHitsCoincWin[ uAsicIdx ][ fvuIdxLastHitCoincWin[ uAsicIdx ] ] = dNewHitTime; - } // If we had already at least kuNbHitCoincWinBug hits - else - { - /// Still filling the array => shift only the index for last hit - fvuIdxLastHitCoincWin[ uAsicIdx ] = fvuIdxLastHitCoincWin[ uAsicIdx ] + 1; - fvdTimeLastHitsCoincWin[ uAsicIdx ][ fvuIdxLastHitCoincWin[ uAsicIdx ] ] = dNewHitTime; - - /// Exit as we have less hits than needed to trigger the bug - return kFALSE; - }// less than kuNbHitCoincWinBug hits - - Double_t dTimeDiff = fvdTimeLastHitsCoincWin[ uAsicIdx ][ fvuIdxLastHitCoincWin[ uAsicIdx ] ] - - fvdTimeLastHitsCoincWin[ uAsicIdx ][ fvuIdxFirstHitCoincWin[ uAsicIdx ] ]; - - if( dTimeDiff < 1e5 ) - fhCoincWinFlagDiffEvo->Fill( dTimeSinceStartSec, dTimeDiff ); - - /// Go around bug in FPGA - if( 3200 <= dTimeDiff && dTimeDiff <= 4500 ) - dTimeDiff -= 3200; - - if( kdCoincWinBugBeg <= dTimeDiff && dTimeDiff <= kdCoincWinBugEnd ) - { - fhCoincWinFlagEvo->Fill( dTimeSinceStartSec, uAsicIdx, 2. ); - fhCoincWinFlagEntriesEvoOn->Fill( dTimeSinceStartSec, uAsicIdx ); -// LOG(info) << "CbmCosy2018MonitorScan::CheckCoincWinBug => 2 ASIC " << uAsicIdx -// << " Time " << dTimeSinceStartSec << " TimeDiff " << dTimeDiff; - return kTRUE; - } // if( kdCoincWinBugBeg <= dTimeDiff && dTimeDiff <= kdCoincWinBugEnd ) - else - { - if( dTimeDiff < 1e5 ) - { - fhCoincWinFlagEvo->Fill( dTimeSinceStartSec, uAsicIdx, 0. ); - fhCoincWinFlagEntriesEvoOff->Fill( dTimeSinceStartSec, uAsicIdx ); -// LOG(info) << "CbmCosy2018MonitorScan::CheckCoincWinBug => 0 ASIC " << uAsicIdx -// << " Time " << dTimeSinceStartSec << " TimeDiff " << dTimeDiff; - } // if( dTimeDiff < 1e5 ) - return kFALSE; - } // else of if( kdCoincWinBugBeg <= dTimeDiff && dTimeDiff <= kdCoincWinBugEnd ) -} - - -//~v2 -Bool_t CbmCosy2018MonitorScan::CheckCoincWinBugImproved2( UInt_t uAsicIdx, Double_t dNewHitTime, Double_t dTimeSinceStartSec ) -{ - Bool_t bReturnFlag = kFALSE; - if( kuNbHitCoincWinBugMax == fvuIdxFirstHitCoincWinA2[ uAsicIdx ] && - kuNbHitCoincWinBugMax == fvuIdxFirstHitCoincWinB2[ uAsicIdx ] && - kuNbHitCoincWinBugMax == fvuIdxFirstHitCoincWinC2[ uAsicIdx ] && - kuNbHitCoincWinBugMax == fvuIdxLastHitCoincWin2[ uAsicIdx ] ) { - /// 1st iteration => Initialize both indices on first slot in array - fvuIdxFirstHitCoincWinA2[ uAsicIdx ] = 2; - fvuIdxFirstHitCoincWinB2[ uAsicIdx ] = 1; - fvuIdxFirstHitCoincWinC2[ uAsicIdx ] = 0; - fvuIdxLastHitCoincWin2[ uAsicIdx ] = 0; - fvdTimeLastHitsCoincWin2[ uAsicIdx ][ fvuIdxLastHitCoincWin2[ uAsicIdx ] ] = dNewHitTime; - - /// Exit as we have less hits than needed to trigger the bug - return kFALSE; - } /// if both indices are 0 => 1st hit in this ASIC - else if( kuNbHitCoincWinBugMax- 1 == fvuIdxLastHitCoincWin2[ uAsicIdx ] - fvuIdxFirstHitCoincWinC2[ uAsicIdx ] || - fvuIdxFirstHitCoincWinC2[ uAsicIdx ] - 1 == fvuIdxLastHitCoincWin2[ uAsicIdx ] ) - { - /// Running loop once the array is full => shift indices for both first and last hit - fvuIdxFirstHitCoincWinA2[ uAsicIdx ] = ( fvuIdxFirstHitCoincWinA2[ uAsicIdx ] + 1 ) % kuNbHitCoincWinBugMax; - fvuIdxFirstHitCoincWinB2[ uAsicIdx ] = ( fvuIdxFirstHitCoincWinB2[ uAsicIdx ] + 1 ) % kuNbHitCoincWinBugMax; - fvuIdxFirstHitCoincWinC2[ uAsicIdx ] = ( fvuIdxFirstHitCoincWinC2[ uAsicIdx ] + 1 ) % kuNbHitCoincWinBugMax; - fvuIdxLastHitCoincWin2[ uAsicIdx ] = ( fvuIdxLastHitCoincWin2[ uAsicIdx ] + 1 ) % kuNbHitCoincWinBugMax; - fvdTimeLastHitsCoincWin2[ uAsicIdx ][ fvuIdxLastHitCoincWin2[ uAsicIdx ] ] = dNewHitTime; - } // If we had already at least kuNbHitCoincWinBug hits - else - { - /// Still filling the array => shift only the index for last hit - fvuIdxLastHitCoincWin2[ uAsicIdx ] = fvuIdxLastHitCoincWin2[ uAsicIdx ] + 1; - fvdTimeLastHitsCoincWin2[ uAsicIdx ][ fvuIdxLastHitCoincWin2[ uAsicIdx ] ] = dNewHitTime; - - /// Exit as we have less hits than needed to trigger the bug - return kFALSE; - }// less than kuNbHitCoincWinBug hits - - if( bReturnFlag ) - return kFALSE; - - /// Compute the time difference between 1st and last for each condition - Double_t dTimeDiffA = fvdTimeLastHitsCoincWin2[ uAsicIdx ][ fvuIdxLastHitCoincWin2[ uAsicIdx ] ] - - fvdTimeLastHitsCoincWin2[ uAsicIdx ][ fvuIdxFirstHitCoincWinA2[ uAsicIdx ] ]; - Double_t dTimeDiffB = fvdTimeLastHitsCoincWin2[ uAsicIdx ][ fvuIdxLastHitCoincWin2[ uAsicIdx ] ] - - fvdTimeLastHitsCoincWin2[ uAsicIdx ][ fvuIdxFirstHitCoincWinB2[ uAsicIdx ] ]; - Double_t dTimeDiffC = fvdTimeLastHitsCoincWin2[ uAsicIdx ][ fvuIdxLastHitCoincWin2[ uAsicIdx ] ] - - fvdTimeLastHitsCoincWin2[ uAsicIdx ][ fvuIdxFirstHitCoincWinC2[ uAsicIdx ] ]; - - if( dTimeDiffA < 1e5 ) - fhCoincWinFlagDiffEvoA2->Fill( dTimeSinceStartSec, dTimeDiffA ); - if( dTimeDiffB < 1e5 ) - fhCoincWinFlagDiffEvoB2->Fill( dTimeSinceStartSec, dTimeDiffB ); - if( dTimeDiffC < 1e5 ) - fhCoincWinFlagDiffEvoC2->Fill( dTimeSinceStartSec, dTimeDiffC ); - - /// Go around bug in FPGA - if( 3200 <= dTimeDiffA && dTimeDiffA <= 4500 ) - dTimeDiffA -= 3200; - if( 3200 <= dTimeDiffB && dTimeDiffB <= 4500 ) - dTimeDiffB -= 3200; - if( 3200 <= dTimeDiffC && dTimeDiffC <= 4500 ) - dTimeDiffC -= 3200; - - - if(kdCoincWinBugBeg <= dTimeDiffA && dTimeDiffA <= kdCoincWinBugEndA ) - fhCoincWinFlagEntriesEvoOnA->Fill( dTimeSinceStartSec, uAsicIdx ); - else if( dTimeDiffA < 1e5 ) - fhCoincWinFlagEntriesEvoOffA->Fill( dTimeSinceStartSec, uAsicIdx ); - - if(kdCoincWinBugBeg <= dTimeDiffB && dTimeDiffB <= kdCoincWinBugEndB ) - fhCoincWinFlagEntriesEvoOnB->Fill( dTimeSinceStartSec, uAsicIdx ); - else if( dTimeDiffA < 1e5 ) - fhCoincWinFlagEntriesEvoOffB->Fill( dTimeSinceStartSec, uAsicIdx ); - - if(kdCoincWinBugBeg <= dTimeDiffC && dTimeDiffC <= kdCoincWinBugEndC ) - fhCoincWinFlagEntriesEvoOnC->Fill( dTimeSinceStartSec, uAsicIdx ); - else if( dTimeDiffA < 1e5 ) - fhCoincWinFlagEntriesEvoOffC->Fill( dTimeSinceStartSec, uAsicIdx ); - - /// Check conditions and set flag - if( (kdCoincWinBugBeg <= dTimeDiffA && dTimeDiffA <= kdCoincWinBugEndA ) || - (kdCoincWinBugBeg <= dTimeDiffB && dTimeDiffB <= kdCoincWinBugEndB ) || - (kdCoincWinBugBeg <= dTimeDiffC && dTimeDiffC <= kdCoincWinBugEndC ) ) { - fhCoincWinFlagEvoImpr2->Fill( dTimeSinceStartSec, uAsicIdx, 2. ); - - - return kTRUE; - } else { - if( dTimeDiffA < 1e5 ) { // exclude uncorrelated hits from the monitor plot, naturally provided later by the event building coincidence cut - fhCoincWinFlagEvoImpr2->Fill( dTimeSinceStartSec, uAsicIdx, 0. ); - } - return kFALSE; - } - -} - - -//~more conditions -Bool_t CbmCosy2018MonitorScan::CheckCoincWinBugMoreCond( UInt_t uAsicIdx, Double_t dNewHitTime, Double_t /*dTimeSinceStartSec*/ ) -{ - if( kuNbHitCoincWinBugM == fvuIdxFirstHitCoincWinM7[ uAsicIdx ] && - kuNbHitCoincWinBugM == fvuIdxFirstHitCoincWinM8[ uAsicIdx ] && - kuNbHitCoincWinBugM == fvuIdxFirstHitCoincWinM9[ uAsicIdx ] && - kuNbHitCoincWinBugM == fvuIdxFirstHitCoincWinM10[ uAsicIdx ] && - kuNbHitCoincWinBugM == fvuIdxFirstHitCoincWinM11[ uAsicIdx ] && - kuNbHitCoincWinBugM == fvuIdxLastHitCoincWinM[ uAsicIdx ] ) { - /// 1st iteration => Initialize both indices on first slot in array - fvuIdxFirstHitCoincWinM7[ uAsicIdx ] = 4; - fvuIdxFirstHitCoincWinM8[ uAsicIdx ] = 3; - fvuIdxFirstHitCoincWinM9[ uAsicIdx ] = 2; - fvuIdxFirstHitCoincWinM10[ uAsicIdx ] = 1; - fvuIdxFirstHitCoincWinM11[ uAsicIdx ] = 0; - fvuIdxLastHitCoincWinM[ uAsicIdx ] = 0; - fvdTimeLastHitsCoincWinM[ uAsicIdx ][ fvuIdxLastHitCoincWinM[ uAsicIdx ] ] = dNewHitTime; - - /// Exit as we have less hits than needed to trigger the bug - return kFALSE; - } /// if both indices are 0 => 1st hit in this ASIC - else if( kuNbHitCoincWinBugM- 1 == fvuIdxLastHitCoincWinM[ uAsicIdx ] - fvuIdxFirstHitCoincWinM11[ uAsicIdx ] || - fvuIdxFirstHitCoincWinM11[ uAsicIdx ] - 1 == fvuIdxLastHitCoincWinM[ uAsicIdx ] ) - { - /// Running loop once the array is full => shift indices for both first and last hit - fvuIdxFirstHitCoincWinM7[ uAsicIdx ] = ( fvuIdxFirstHitCoincWinM7[ uAsicIdx ] + 1 ) % kuNbHitCoincWinBugM; - fvuIdxFirstHitCoincWinM8[ uAsicIdx ] = ( fvuIdxFirstHitCoincWinM8[ uAsicIdx ] + 1 ) % kuNbHitCoincWinBugM; - fvuIdxFirstHitCoincWinM9[ uAsicIdx ] = ( fvuIdxFirstHitCoincWinM9[ uAsicIdx ] + 1 ) % kuNbHitCoincWinBugM; - fvuIdxFirstHitCoincWinM10[ uAsicIdx ] = ( fvuIdxFirstHitCoincWinM10[ uAsicIdx ] + 1 ) % kuNbHitCoincWinBugM; - fvuIdxFirstHitCoincWinM11[ uAsicIdx ] = ( fvuIdxFirstHitCoincWinM11[ uAsicIdx ] + 1 ) % kuNbHitCoincWinBugM; - fvuIdxLastHitCoincWinM[ uAsicIdx ] = ( fvuIdxLastHitCoincWinM[ uAsicIdx ] + 1 ) % kuNbHitCoincWinBugM; - fvdTimeLastHitsCoincWinM[ uAsicIdx ][ fvuIdxLastHitCoincWinM[ uAsicIdx ] ] = dNewHitTime; - } // If we had already at least kuNbHitCoincWinBug hits - else - { - /// Still filling the array => shift only the index for last hit - fvuIdxLastHitCoincWinM[ uAsicIdx ] = fvuIdxLastHitCoincWinM[ uAsicIdx ] + 1; - fvdTimeLastHitsCoincWinM[ uAsicIdx ][ fvuIdxLastHitCoincWinM[ uAsicIdx ] ] = dNewHitTime; - - /// Exit as we have less hits than needed to trigger the bug - return kFALSE; - }// less than kuNbHitCoincWinBug hits - - - /// Compute the time difference between 1st and last for each condition - Double_t dTimeDiff7 = fvdTimeLastHitsCoincWinM[ uAsicIdx ][ fvuIdxLastHitCoincWinM[ uAsicIdx ] ] - - fvdTimeLastHitsCoincWinM[ uAsicIdx ][ fvuIdxFirstHitCoincWinM7[ uAsicIdx ] ]; - Double_t dTimeDiff8 = fvdTimeLastHitsCoincWinM[ uAsicIdx ][ fvuIdxLastHitCoincWinM[ uAsicIdx ] ] - - fvdTimeLastHitsCoincWinM[ uAsicIdx ][ fvuIdxFirstHitCoincWinM8[ uAsicIdx ] ]; - Double_t dTimeDiff9 = fvdTimeLastHitsCoincWinM[ uAsicIdx ][ fvuIdxLastHitCoincWinM[ uAsicIdx ] ] - - fvdTimeLastHitsCoincWinM[ uAsicIdx ][ fvuIdxFirstHitCoincWinM9[ uAsicIdx ] ]; - Double_t dTimeDiff10 = fvdTimeLastHitsCoincWinM[ uAsicIdx ][ fvuIdxLastHitCoincWinM[ uAsicIdx ] ] - - fvdTimeLastHitsCoincWinM[ uAsicIdx ][ fvuIdxFirstHitCoincWinM10[ uAsicIdx ] ]; - Double_t dTimeDiff11 = fvdTimeLastHitsCoincWinM[ uAsicIdx ][ fvuIdxLastHitCoincWinM[ uAsicIdx ] ] - - fvdTimeLastHitsCoincWinM[ uAsicIdx ][ fvuIdxFirstHitCoincWinM11[ uAsicIdx ] ]; -/* - if( dTimeDiff7 < 1e5 ) - fhCoincWinFlagDiffEvoA2->Fill( dTimeSinceStartSec, dTimeDiffA ); - if( dTimeDiff8 < 1e5 ) - fhCoincWinFlagDiffEvoB2->Fill( dTimeSinceStartSec, dTimeDiffB ); - if( dTimeDiffC < 1e5 ) - fhCoincWinFlagDiffEvoC2->Fill( dTimeSinceStartSec, dTimeDiffC ); -*/ - /// Go around bug in FPGA - if( 3200 <= dTimeDiff7 && dTimeDiff7 <= 4500 ) - dTimeDiff7 -= 3200; - if( 3200 <= dTimeDiff8 && dTimeDiff8 <= 4500 ) - dTimeDiff8 -= 3200; - if( 3200 <= dTimeDiff9 && dTimeDiff9 <= 4500 ) - dTimeDiff9 -= 3200; - if( 3200 <= dTimeDiff10 && dTimeDiff10 <= 4500 ) - dTimeDiff10 -= 3200; - if( 3200 <= dTimeDiff11 && dTimeDiff11 <= 4500 ) - dTimeDiff11 -= 3200; - -/* - if(kdCoincWinBugBeg <= dTimeDiffA && dTimeDiffA <= kdCoincWinBugEndA ) - fhCoincWinFlagEntriesEvoOnA->Fill( dTimeSinceStartSec, uAsicIdx ); - else if( dTimeDiffA < 1e5 ) - fhCoincWinFlagEntriesEvoOffA->Fill( dTimeSinceStartSec, uAsicIdx ); - - if(kdCoincWinBugBeg <= dTimeDiffB && dTimeDiffB <= kdCoincWinBugEndB ) - fhCoincWinFlagEntriesEvoOnB->Fill( dTimeSinceStartSec, uAsicIdx ); - else if( dTimeDiffA < 1e5 ) - fhCoincWinFlagEntriesEvoOffB->Fill( dTimeSinceStartSec, uAsicIdx ); - - if(kdCoincWinBugBeg <= dTimeDiffC && dTimeDiffC <= kdCoincWinBugEndC ) - fhCoincWinFlagEntriesEvoOnC->Fill( dTimeSinceStartSec, uAsicIdx ); - else if( dTimeDiffA < 1e5 ) - fhCoincWinFlagEntriesEvoOffC->Fill( dTimeSinceStartSec, uAsicIdx ); -*/ - - /// Check conditions and set flag - if( (kdCoincWinBugBeg <= dTimeDiff7 && dTimeDiff7 <= kdCoincWinBugEndM7 ) || - (kdCoincWinBugBeg <= dTimeDiff8 && dTimeDiff8 <= kdCoincWinBugEndM8 ) || - (kdCoincWinBugBeg <= dTimeDiff9 && dTimeDiff9 <= kdCoincWinBugEndM9 ) || - (kdCoincWinBugBeg <= dTimeDiff10 && dTimeDiff10 <= kdCoincWinBugEndM10 ) || - (kdCoincWinBugBeg <= dTimeDiff11 && dTimeDiff11 <= kdCoincWinBugEndM11 ) - ) { -// fhCoincWinFlagEvoMoreCond->Fill( dTimeSinceStartSec, uAsicIdx, 2. ); - return kTRUE; - } else { - if( dTimeDiff7 < 1e5 ) { // exclude uncorrelated hits from the monitor plot, naturally provided later by the event building coincidence cut -// fhCoincWinFlagEvoMoreCond->Fill( dTimeSinceStartSec, uAsicIdx, 0. ); - } - return kFALSE; - } - -} - - - -/** STSXYTER v2.0 Bug, triggering condition detection **/ - -ClassImp(CbmCosy2018MonitorScan) diff --git a/beamtime/cosy2018/unpacker/CbmCosy2018MonitorScan.h b/beamtime/cosy2018/unpacker/CbmCosy2018MonitorScan.h deleted file mode 100644 index 38bc63fe15ec091a473a2976f0af8e9ba4d6a571..0000000000000000000000000000000000000000 --- a/beamtime/cosy2018/unpacker/CbmCosy2018MonitorScan.h +++ /dev/null @@ -1,484 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmCosy2018MonitorScan ----- -// ----- Created 27/02/18 by P.-A. Loizeau ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CBMCOSY2018MONITORSCAN_H -#define CBMCOSY2018MONITORSCAN_H - -#include "Timeslice.hpp" - -// Data -#include "StsXyterMessage.h" -#include "StsXyterFinalHit.h" - -// CbmRoot -#include "CbmTSUnpack.h" -#include "CbmHistManager.h" - -// C++11 -#include <chrono> - -// C/C++ -#include <vector> -#include <set> -#include <map> - -class CbmCern2017UnpackParHodo; -class CbmCern2017UnpackParSts; - -class CbmCosy2018MonitorScan: public CbmTSUnpack -{ -public: - - CbmCosy2018MonitorScan(); - virtual ~CbmCosy2018MonitorScan(); - - virtual Bool_t Init(); - - virtual Bool_t DoUnpack(const fles::Timeslice& ts, size_t component); - - virtual void Reset(); - - virtual void Finish(); - - void SetParContainers(); - - Bool_t InitContainers(); - - Bool_t ReInitContainers(); - - void FillOutput(boost::any); - - void SetRunStart( Int_t dateIn, Int_t timeIn, Int_t iBinSize = 5 ); - - void ResetAllHistos(); - void SaveAllHistos( TString sFileName = "" ); - void SetHistoFileName( TString sFileName = "data/SetupHistos.root" ) { fsHistoFileFullname = sFileName; } - - void SetMsOverlap(size_t uOverlapMsNb = 1) { fuOverlapMsNb = uOverlapMsNb; } - size_t GetMsOverlap() { return fuOverlapMsNb; } - - void SetPrintMessage( Bool_t bPrintMessOn = kTRUE, - stsxyter::MessagePrintMask ctrl = stsxyter::MessagePrintMask::msg_print_Hex | - stsxyter::MessagePrintMask::msg_print_Human ) - { fbPrintMessages = bPrintMessOn; fPrintMessCtrl = ctrl; } - void EnableDualStsMode( Bool_t bEnable = kTRUE ) { fbDualStsEna = bEnable; } - void SetLongDurationLimits( UInt_t uDurationSeconds = 3600, UInt_t uBinSize = 1 ); -/* - void SetCoincidenceBorderHodo( Double_t dNewValue ){ fdCoincBorderHodo = dNewValue;} - void SetCoincidenceBorderSts( Double_t dNewValue ){ fdCoincBorderSts = dNewValue;} - void SetCoincidenceBorder( Double_t dNewValue ){ fdCoincBorder = dNewValue;} -*/ -private: - size_t fuOverlapMsNb; /** Ignore Overlap Ms: all fuOverlapMsNb MS at the end of timeslice **/ - - // Parameters - CbmCern2017UnpackParHodo* fUnpackParHodo; //! - CbmCern2017UnpackParSts* fUnpackParSts; //! - UInt_t fuNrOfDpbs; //! Total number of Sts DPBs in system - std::map<UInt_t, UInt_t> fDpbIdIndexMap; //! Map of DPB Identifier to DPB index - UInt_t fuNbElinksPerDpb; //! Number of possible eLinks per DPB - UInt_t fuNbStsXyters; //! Number of StsXyter ASICs - UInt_t fuNbChanPerAsic; //! Number of channels per StsXyter ASIC => should be constant somewhere!!!! - std::vector< std::vector< UInt_t > > fvuElinkToAsic; //! Vector holding for each link the corresponding ASIC index [fuNrOfDpbs * fuNbElinksPerDpb] - - // Constants - static const Int_t kiMaxNbFlibLinks = 16; - static const UInt_t kuBytesPerMessage = 4; - - // Internal Control/status of monitor - // Histo File name and path - TString fsHistoFileFullname; - // Task configuration values - Bool_t fbPrintMessages; - stsxyter::MessagePrintMask fPrintMessCtrl; - Bool_t fbDualStsEna; - const UInt_t fkuNbPrintMessages = 5000; - UInt_t fuPrintMessagesIdx; - // TS/MS info - ULong64_t fulCurrentTsIdx; - ULong64_t fulCurrentMsIdx; - // Current data properties - std::map< stsxyter::MessType, UInt_t > fmMsgCounter; - UInt_t fuCurrentEquipmentId; //! Current equipment ID, tells from which DPB the current MS is originating - UInt_t fuCurrDpbId; //! Temp holder until Current equipment ID is properly filled in MS - UInt_t fuCurrDpbIdx; //! Index of the DPB from which the MS currently unpacked is coming - Int_t fiRunStartDateTimeSec; //! Start of run time since "epoch" in s, for the plots with date as X axis - Int_t fiBinSizeDatePlots; //! Bin size in s for the plots with date as X axis - - // Data format control - std::vector< ULong64_t > fvulCurrentTsMsb; //! Current TS MSB for each DPB - std::vector< UInt_t > fvuCurrentTsMsbCycle; //! Current TS MSB cycle for DPB - std::vector< UInt_t > fvuElinkLastTsHit; //! TS from last hit for DPB - // Hits comparison - std::vector< std::vector< ULong64_t > > fvulChanLastHitTime; //! Last hit time in bins for each Channel - std::vector< std::vector< Double_t > > fvdChanLastHitTime; //! Last hit time in ns for each Channel - std::vector< Double_t > fvdMsTime; //! Header time of each MS - std::vector< std::vector< std::vector< UInt_t > > > fvuChanNbHitsInMs; //! Number of hits in each MS for each Channel - std::vector< std::vector< std::vector< Double_t > > > fvdChanLastHitTimeInMs; //! Last hit time in bins in each MS for each Channel - std::vector< std::vector< std::vector< UShort_t > > > fvusChanLastHitAdcInMs; //! Last hit ADC in bins in each MS for each Channel -// std::vector< std::vector< std::multiset< stsxyter::FinalHit > > > fvmChanHitsInTs; //! All hits (time & ADC) in bins in last TS for each Channel - // Starting state book-keeping - Double_t fdStartTime; /** Time of first valid hit (TS_MSB available), used as reference for evolution plots**/ - Double_t fdStartTimeMsSz; /** Time of first microslice, used as reference for evolution plots**/ - std::chrono::steady_clock::time_point ftStartTimeUnix; /** Time of run Start from UNIX system, used as reference for long evolution plots against reception time **/ - - // Hits time-sorting - std::vector< stsxyter::FinalHit > fvmHitsInTs; //! All hits (time in bins, ADC in bins, asic, channel) in last TS, sorted by multiset with "<" operator - stsxyter::FinalHit fLastSortedHit1X; //! Last sorted hit for Hodo 1 X - stsxyter::FinalHit fLastSortedHit1Y; //! Last sorted hit for Hodo 1 Y - stsxyter::FinalHit fLastSortedHit2X; //! Last sorted hit for Hodo 2 X - stsxyter::FinalHit fLastSortedHit2Y; //! Last sorted hit for Hodo 2 Y - stsxyter::FinalHit fLastSortedHit1N; //! Last sorted hit for STS 1 N - stsxyter::FinalHit fLastSortedHit1P; //! Last sorted hit for STS 1 P - stsxyter::FinalHit fLastSortedHit2N; //! Last sorted hit for STS 2 N - stsxyter::FinalHit fLastSortedHit2P; //! Last sorted hit for STS 2 P - // Coincidence histos - UInt_t fuMaxNbMicroslices; - // Rate evolution histos - Bool_t fbLongHistoEnable; - UInt_t fuLongHistoNbSeconds; - UInt_t fuLongHistoBinSizeSec; - UInt_t fuLongHistoBinNb; - - // Histograms - CbmHistManager* fHM; //! Histogram manager - TH1* fhHodoMessType; - TH1* fhHodoSysMessType; - TH2* fhHodoMessTypePerDpb; - TH2* fhHodoSysMessTypePerDpb; -/* - TH2* fhStsDpbRawTsMsb; - TH2* fhStsDpbRawTsMsbSx; - TH2* fhStsDpbRawTsMsbDpb; -*/ - TH2* fhHodoMessTypePerElink; - TH2* fhHodoSysMessTypePerElink; - - std::vector<TH1 *> fhHodoChanCntRaw; - std::vector<TH2 *> fhHodoChanAdcRaw; - std::vector<TProfile*> fhHodoChanAdcRawProf; - std::vector<TH2*> fhHodoChanRawTs; - std::vector<TH2*> fhHodoChanMissEvt; - std::vector<TH2*> fhHodoChanMissEvtEvo; - std::vector<TH2*> fhHodoChanHitRateEvo; - std::vector<TH1*> fhHodoFebRateEvo; - std::vector<TH1*> fhHodoFebMissEvtEvo; - std::vector<TH2*> fhHodoChanHitRateEvoLong; - std::vector<TH1*> fhHodoFebRateEvoLong; -/* - // Coincidences in sorted hits - Double_t fdCoincBorderHodo; // ns, +/- - Double_t fdCoincBorderSts; // ns, +/- - Double_t fdCoincBorder; // ns, +/- - // Single detector maps - TH1 * fhSetupSortedDtX1Y1; - TH1 * fhSetupSortedDtX2Y2; - TH1 * fhSetupSortedDtN1P1; - TH1 * fhSetupSortedDtN2P2; - TH1 * fhSetupSortedDtX1Y1X2Y2; - TH1 * fhSetupSortedDtN1P1N2P2; - TH1 * fhSetupSortedDtX1Y1X2Y2N1P1; - TH1 * fhSetupSortedDtX1Y1X2Y2N2P2; - TH1 * fhSetupSortedDtH1H2S1S2; - TH2 * fhSetupSortedMapX1Y1; - TH2 * fhSetupSortedMapX2Y2; - TH2 * fhSetupSortedMapN1P1; - TH2 * fhSetupSortedMapN2P2; - TH1 * fhSetupSortedCntEvoX1Y1; - TH1 * fhSetupSortedCntEvoX2Y2; - TH1 * fhSetupSortedCntEvoN1P1; - TH1 * fhSetupSortedCntEvoN2P2; - - // Full Hodo maps - TH1 * fhBothHodoSortedDtX1Y1; - TH1 * fhBothHodoSortedDtX2Y2; - TH1 * fhBothHodoSortedDtX1Y1X2Y2N1P1; - TH1 * fhBothHodoSortedDtX1Y1X2Y2N2P2; - TH1 * fhBothHodoSortedDtH1H2S1S2; - TH2 * fhBothHodoSortedMapX1Y1; - TH2 * fhBothHodoSortedMapX2Y2; - TH1 * fhBothHodoSortedCntEvoX1Y1; - TH1 * fhBothHodoSortedCntEvoX2Y2; - - // H + Sn maps - TH1 * fhH1H2S1SortedDtX1Y1; - TH1 * fhH1H2S1SortedDtX2Y2; - TH1 * fhH1H2S1SortedDtN1P1; - TH1 * fhH1H2S1SortedDtN2P2; - TH2 * fhH1H2S1SortedMapX1Y1; - TH2 * fhH1H2S1SortedMapX2Y2; - TH2 * fhH1H2S1SortedMapN1P1; - TH2 * fhH1H2S1SortedMapN2P2; - TH1 * fhH1H2S1SortedCntEvoX1Y1; - TH1 * fhH1H2S1SortedCntEvoX2Y2; - TH1 * fhH1H2S1SortedCntEvoN1P1; - TH1 * fhH1H2S1SortedCntEvoN2P2; - - TH1 * fhH1H2S2SortedDtX1Y1; - TH1 * fhH1H2S2SortedDtX2Y2; - TH1 * fhH1H2S2SortedDtN1P1; - TH1 * fhH1H2S2SortedDtN2P2; - TH2 * fhH1H2S2SortedMapX1Y1; - TH2 * fhH1H2S2SortedMapX2Y2; - TH2 * fhH1H2S2SortedMapN1P1; - TH2 * fhH1H2S2SortedMapN2P2; - TH1 * fhH1H2S2SortedCntEvoX1Y1; - TH1 * fhH1H2S2SortedCntEvoX2Y2; - TH1 * fhH1H2S2SortedCntEvoN1P1; - TH1 * fhH1H2S2SortedCntEvoN2P2; - - // Full System maps - TH1 * fhSystSortedDtX1Y1; - TH1 * fhSystSortedDtX2Y2; - TH1 * fhSystSortedDtN1P1; - TH1 * fhSystSortedDtN2P2; - TH1 * fhSystSortedDtX1Y1X2Y2; - TH2 * fhSystSortedMapX1Y1; - TH2 * fhSystSortedMapX2Y2; - TH2 * fhSystSortedMapN1P1; - TH2 * fhSystSortedMapN2P2; - TH1 * fhSystSortedCntEvoX1Y1; - TH1 * fhSystSortedCntEvoX2Y2; - TH1 * fhSystSortedCntEvoN1P1; - TH1 * fhSystSortedCntEvoN2P2; - - TH2 * fhSystSortedDtN1X1vsN1X2; - TH2 * fhSystSortedDtP1X1vsP1X2; - TH2 * fhSystSortedDtN1X1vsP1X1; - TH2 * fhSystSortedDtSts1Hodo1vsSts1Hodo2; - TH2 * fhSystSortedDtSts2Hodo1vsSts2Hodo2; - TH2 * fhSystSortedDtAllVsMapX1; - TH2 * fhSystSortedDtAllVsMapY1; - TH2 * fhSystSortedDtAllVsMapX2; - TH2 * fhSystSortedDtAllVsMapY2; - - TH1 * fhSetupSortedDtX1; - TH1 * fhSetupSortedDtY1; - TH1 * fhSetupSortedDtX2; - TH1 * fhSetupSortedDtY2; - TH1 * fhSetupSortedDtN1; - TH1 * fhSetupSortedDtP1; - TH1 * fhSetupSortedDtN2; - TH1 * fhSetupSortedDtP2; - - /// Counting hits without proper timestamp - std::vector< std::vector< ULong64_t > > fvulTimeLastHitAsicChan; - std::vector< std::vector< Int_t > > fviAdcLastHitAsicChan; - std::vector< std::vector< UInt_t > > fvuNbSameHitAsicChan; - std::vector< std::vector< UInt_t > > fvuNbSameFullHitAsicChan; - - std::vector< ULong64_t > fvulStartTimeLastS; - std::vector< UInt_t > fvuNbHitDiffTsAsicLastS; - std::vector< UInt_t > fvuNbHitSameTsAsicLastS; - std::vector< UInt_t > fvuNbHitSameTsAdcAsicLastS; - - std::vector< TH2 * > fhSetupSortedTsFirstDuplicateChan; - std::vector< TH2 * > fhSetupSortedTsGoodChan; - std::vector< TH2 * > fhSetupSortedNbSameTsChan; - std::vector< TH2 * > fhSetupSortedSameTsAdcChan; - std::vector< TH2 * > fhSetupSortedSameTsAdcDiff; - std::vector< TProfile2D * > fhSetupSortedRatioSameTsChan; - std::vector< TH2 * > fhSetupSortedNbConsSameTsChan; - std::vector< TH2 * > fhSetupSortedNbConsSameTsAdcChan; - std::vector< TH2 * > fhSetupSortedNbConsSameTsVsTsAdc; - - std::vector< TH2 * > fhSetupSortedAsicRatioSameTsVsFlux; - std::vector< TH2 * > fhSetupSortedAsicRatioSameTsAdcVsFlux; - std::vector< TH2 * > fhSetupSortedAsicRatioSameAdcSameTsVsFlux; - - std::vector< TProfile2D * > fhRatioSameTsSpillEvo; - std::vector< TProfile2D * > fhRatioSameTsAdcSpillEvo; - std::vector< TProfile2D * > fhRatioSameAdcSameTsSpillEvo; - - std::vector< TProfile * > fhFractionHitsAsicSpillEvo; - std::vector< TProfile * > fhFractionGoodHitsSpillEvo; - std::vector< TProfile * > fhFractionDupliHitsSpillEvo; - std::vector< TProfile * > fhFractionTsMsbSpillEvo; - std::vector< TProfile * > fhFractionEpochSpillEvo; - std::vector< TProfile * > fhFractionEmptySpillEvo; - std::vector< TProfile * > fhFractionHitsAsicEvo; - std::vector< TProfile * > fhFractionGoodHitsEvo; - std::vector< TProfile * > fhFractionDupliHitsEvo; - std::vector< TProfile * > fhFractionTsMsbEvo; - std::vector< TProfile * > fhFractionEpochEvo; - std::vector< TProfile * > fhFractionEmptyEvo; - TProfile * fhFractionAsics; - TProfile * fhFractionTypes; - - std::vector< UInt_t > fvuNbSameFullHitAsic; - std::vector< UInt_t > fvuNbDiffFullHitAsic; - std::vector< UInt_t > fvuLastHitBufferIdx; - std::vector< std::vector< stsxyter::FinalHit > > fvmLastHitsAsic; //! last 128 hits (time in bins, ADC in bins, asic, channel) - std::vector< TH2 * > fhAsicDuplicDtLastHits; - std::vector< TH2 * > fhAsicDuplicCompTs; - std::vector< TH2 * > fhAsicDuplicTsLsb; - std::vector< TH2 * > fhAsicDuplicTsMsbAsic; - std::vector< TH2 * > fhAsicDuplicCompTsBitThere; - std::vector< TH2 * > fhAsicDuplicTsLsbBitThere; - std::vector< TH2 * > fhAsicDuplicTsMsbBitThere; - std::vector< TH2 * > fhAsicDuplicTs; - std::vector< TH2 * > fhAsicGoodTs; - std::vector< TH2 * > fhAsicDuplicTsMsb; - std::vector< TH2 * > fhAsicGoodTsMsb; - std::vector< TH2 * > fhAsicDuplicTsFull; - std::vector< TH2 * > fhAsicGoodTsFull; - std::vector< TH2 * > fhAsicDuplicTsBitPattern; - std::vector< TH2 * > fhAsicGoodTsBitPattern; - - TH2 * fhAsicDuplicTsEvoAsic0Chan01; - TH2 * fhAsicGoodTsEvoAsic0Chan01; - TH2 * fhAsicGoodTsMsbEvoAsic0Chan01; - TH2 * fhAsicGoodTsFullEvoAsic0Chan01; - TProfile * fhAsicGoodTsFullEvoProfAsic0Chan01; - TH2 * fhAsicDuplicTsEvoAsic0Chan09; - TH2 * fhAsicGoodTsEvoAsic0Chan09; - TProfile * fhAsicGoodTsFullEvoProfAsic0Chan09; - TH2 * fhAsicDuplicTsEvoAsic0Chan16; - TH2 * fhAsicGoodTsEvoAsic0Chan16; - TProfile * fhAsicGoodTsFullEvoProfAsic0Chan16; - UInt_t fuPulseIdx; - UInt_t fuPulseIdxMax; - TH2 * fhAsicMissedChanIdVsPulseIdx; - TProfile * fhAsicMissedChanGroupVsPulseIdx; - - std::vector<TH1 *> fhHodoChanCntGood; - std::vector<TH2 *> fhHodoChanGoodHitRateEvo; - - TH2 * fhHodoX1SpillEvo; - TH2 * fhHodoY1SpillEvo; - TH2 * fhHodoX2SpillEvo; - TH2 * fhHodoY2SpillEvo; - - Double_t fdSpillEvoLength; - TProfile * fhHodoX1SpillEvoProf; - TProfile * fhHodoY1SpillEvoProf; - TProfile * fhHodoX2SpillEvoProf; - TProfile * fhHodoY2SpillEvoProf; -*/ - TCanvas* fcMsSizeAll; - TH1* fhMsSz[kiMaxNbFlibLinks]; - TProfile* fhMsSzTime[kiMaxNbFlibLinks]; -/* - std::vector< ULong64_t > fvuAsicTimeLastPulse; - std::vector< std::vector< Bool_t > > fvbPulseThereChan; - std::vector< TH2 * > fhPulseChanCountEvo; -*/ - TH2* fhHodoChanHitRateEvoZoom; - UInt_t fuNbTsMsbSinceLastHit; - UInt_t fuNbHitsLastTsMsb; - -/** STSXYTER v2.0 Bug, triggering condition detection **/ - std::vector< std::vector< ULong64_t > > fvulLastHitTs; - static const UInt_t kuNbHitCoincWinBug = 7; - - static const UInt_t kuNbHitCoincWinBugMax = 9; //~v2 - static const UInt_t kuNbHitCoincWinBugM = 11; //~more conditions - - constexpr static const Double_t kdCoincWinBugBeg = 0; //ns - constexpr static const Double_t kdCoincWinBugEnd = 550; //ns - constexpr static const Double_t kdCoincWinBugEndA = 350; //ns - constexpr static const Double_t kdCoincWinBugEndB = 470; //ns - constexpr static const Double_t kdCoincWinBugEndC = 540; //ns - //~more conditions - /* constexpr static const Double_t kdCoincWinBugEndM7 = 308; //ns - constexpr static const Double_t kdCoincWinBugEndM8 = 372; //ns - constexpr static const Double_t kdCoincWinBugEndM9 = 436; //ns - constexpr static const Double_t kdCoincWinBugEndM10 = 500; //ns - constexpr static const Double_t kdCoincWinBugEndM11 = 560; //ns*/ - - //noise (wider) - constexpr static const Double_t kdCoincWinBugEndM7 = 410; //ns - constexpr static const Double_t kdCoincWinBugEndM8 = 470; //ns - constexpr static const Double_t kdCoincWinBugEndM9 = 540; //ns - constexpr static const Double_t kdCoincWinBugEndM10 = 600; //ns - constexpr static const Double_t kdCoincWinBugEndM11 = 670; //ns - - //main (more narrow) -/* constexpr static const Double_t kdCoincWinBugEndM7 = 320; //ns - constexpr static const Double_t kdCoincWinBugEndM8 = 380; //ns - constexpr static const Double_t kdCoincWinBugEndM9 = 450; //ns - constexpr static const Double_t kdCoincWinBugEndM10 = 510; //ns - constexpr static const Double_t kdCoincWinBugEndM11 = 570; //ns */ - //~more conditions end - std::vector< std::vector< Double_t > > fvdTimeLastHitsCoincWin; - std::vector< UInt_t > fvuIdxFirstHitCoincWin; - std::vector< UInt_t > fvuIdxLastHitCoincWin; - - std::vector< std::vector< Double_t > > fvdTimeLastHitsCoincWinA; - std::vector< UInt_t > fvuIdxFirstHitCoincWinA; - std::vector< UInt_t > fvuIdxLastHitCoincWinA; - std::vector< std::vector< Double_t > > fvdTimeLastHitsCoincWinB; - std::vector< UInt_t > fvuIdxFirstHitCoincWinB; - std::vector< UInt_t > fvuIdxLastHitCoincWinB; - std::vector< std::vector< Double_t > > fvdTimeLastHitsCoincWinC; - std::vector< UInt_t > fvuIdxFirstHitCoincWinC; - std::vector< UInt_t > fvuIdxLastHitCoincWinC; - - //~v2 - std::vector< std::vector< Double_t > > fvdTimeLastHitsCoincWin2; - std::vector< UInt_t > fvuIdxFirstHitCoincWinA2; - std::vector< UInt_t > fvuIdxFirstHitCoincWinB2; - std::vector< UInt_t > fvuIdxFirstHitCoincWinC2; - std::vector< UInt_t > fvuIdxLastHitCoincWin2; - - //~more conditions - std::vector< std::vector< Double_t > > fvdTimeLastHitsCoincWinM; - std::vector< UInt_t > fvuIdxFirstHitCoincWinM7; - std::vector< UInt_t > fvuIdxFirstHitCoincWinM8; - std::vector< UInt_t > fvuIdxFirstHitCoincWinM9; - std::vector< UInt_t > fvuIdxFirstHitCoincWinM10; - std::vector< UInt_t > fvuIdxFirstHitCoincWinM11; - std::vector< UInt_t > fvuIdxLastHitCoincWinM; - - TProfile2D* fhCoincWinFlagEvo; - TProfile2D* fhCoincWinFlagEvoImpr2; //~v2 - TProfile2D* fhCoincWinFlagEvoMoreCond; //~more conditions - - TH2D* fhCoincWinFlagEntriesEvoOnA; /// DEBUG - TH2D* fhCoincWinFlagEntriesEvoOnB; /// DEBUG - TH2D* fhCoincWinFlagEntriesEvoOnC; /// DEBUG - TH2D* fhCoincWinFlagEntriesEvoOffA; /// DEBUG - TH2D* fhCoincWinFlagEntriesEvoOffB; /// DEBUG - TH2D* fhCoincWinFlagEntriesEvoOffC; /// DEBUG - - TH2D* fhCoincWinFlagDiffEvoA2; /// DEBUG - TH2D* fhCoincWinFlagDiffEvoB2; /// DEBUG - TH2D* fhCoincWinFlagDiffEvoC2; /// DEBUG - - TH2D* fhCoincWinFlagEntriesEvoOn; /// DEBUG - TH2D* fhCoincWinFlagEntriesEvoOff; /// DEBUG - TH2D* fhCoincWinFlagDiffEvo; /// DEBUG - - TProfile* fhBadWinRatio; ///add - TProfile* fhBadDataRatio; ///add - - Bool_t CheckCoincWinBug( UInt_t uAsic, Double_t dNewHitTime, Double_t dTimeSinceStartSec ); - - Bool_t CheckCoincWinBugImproved2( UInt_t uAsic, Double_t dNewHitTime, Double_t dTimeSinceStartSec ); //~v2 - Bool_t CheckCoincWinBugMoreCond( UInt_t uAsic, Double_t dNewHitTime, Double_t dTimeSinceStartSec ); //~more conditions - void InitializeFvCoincWins2(); //~v2 - void InitializeFvCoincWinsMore(); //~more conditions -/** STSXYTER v2.0 Bug, triggering condition detection **/ - - std::vector< std::vector< Bool_t > > fvbChanFiredInThisMs; - std::vector< std::vector< Bool_t > > fvbChanCopiedInThisMs; - std::vector< TH2 * > fhNbFiredChanPerMs; - std::vector< TH2 * > fhNbMultiHitChanPerMs; - - void CreateHistograms(); - - void FillHitInfo( stsxyter::Message mess, const UShort_t & usElinkIdx, const UInt_t & uAsicIdx, const UInt_t & uMsIdx ); - void FillTsMsbInfo( stsxyter::Message mess, UInt_t uMessIdx = 0, UInt_t uMsIdx = 0); - void FillEpochInfo( stsxyter::Message mess ); - - CbmCosy2018MonitorScan(const CbmCosy2018MonitorScan&); - CbmCosy2018MonitorScan operator=(const CbmCosy2018MonitorScan&); - - ClassDef(CbmCosy2018MonitorScan, 1) -}; - -#endif // CBMCOSY2018MONITORSCAN_H diff --git a/beamtime/cosy2018/unpacker/CbmCosy2018MonitorSetup.cxx b/beamtime/cosy2018/unpacker/CbmCosy2018MonitorSetup.cxx deleted file mode 100644 index 13db9c4b55bd0b91701ede10ba25c118f691f66f..0000000000000000000000000000000000000000 --- a/beamtime/cosy2018/unpacker/CbmCosy2018MonitorSetup.cxx +++ /dev/null @@ -1,3667 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmCosy2018MonitorSetup ----- -// ----- Created 27/02/18 by P.-A. Loizeau ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#include "CbmCosy2018MonitorSetup.h" - -// Data - -// CbmRoot -#include "CbmCern2017UnpackParHodo.h" -#include "CbmCern2017UnpackParSts.h" -#include "CbmHistManager.h" - -// FairRoot -#include "FairLogger.h" -#include "FairRootManager.h" -#include "FairRun.h" -#include "FairRuntimeDb.h" -#include "FairRunOnline.h" - -// Root -#include "TClonesArray.h" -#include "TString.h" -#include "TRandom.h" -#include "THttpServer.h" -#include "TROOT.h" -#include "TStyle.h" -#include <TFile.h> - -// C++11 - -// C/C++ -#include <iostream> -#include <stdint.h> -#include <iomanip> - -Bool_t bCosy2018ResetSetupHistos_H = kFALSE; -Bool_t bCosy2018WriteSetupHistos_H = kFALSE; - -CbmCosy2018MonitorSetup::CbmCosy2018MonitorSetup() : - CbmTSUnpack(), - fuOverlapMsNb(0), - fUnpackParHodo(NULL), - fUnpackParSts(NULL), - fuNrOfDpbs(0), - fDpbIdIndexMap(), - fuNbElinksPerDpb(0), - fuNbStsXyters(0), - fuNbChanPerAsic(0), - fvuElinkToAsic(), - fsHistoFileFullname( "data/SetupHistos.root" ), - fbPrintMessages( kFALSE ), - fPrintMessCtrl( stsxyter::MessagePrintMask::msg_print_Human ), - fbDualStsEna( kFALSE ), - fulCurrentTsIdx( 0 ), - fulCurrentMsIdx( 0 ), - fmMsgCounter(), - fuCurrentEquipmentId(0), - fuCurrDpbId(0), - fuCurrDpbIdx(0), - fiRunStartDateTimeSec(-1), - fiBinSizeDatePlots(-1), - fvulCurrentTsMsb(), - fvuCurrentTsMsbCycle(), - fvuElinkLastTsHit(), - fvulChanLastHitTime(), - fvdChanLastHitTime(), - fvdMsTime(), - fvuChanNbHitsInMs(), - fvdChanLastHitTimeInMs(), - fvusChanLastHitAdcInMs(), -// fvmChanHitsInTs(), - fdStartTime(-1.0), - fdStartTimeMsSz(-1.0), - ftStartTimeUnix( std::chrono::steady_clock::now() ), - fvmHitsInTs(), - fLastSortedHit1X(), - fLastSortedHit1Y(), - fLastSortedHit2X(), - fLastSortedHit2Y(), - fLastSortedHit1N(), - fLastSortedHit1P(), - fLastSortedHit2N(), - fLastSortedHit2P(), - fuMaxNbMicroslices(100), - fbLongHistoEnable( kFALSE ), - fuLongHistoNbSeconds( 0 ), - fuLongHistoBinSizeSec( 0 ), - fuLongHistoBinNb( 0 ), - fHM(new CbmHistManager()), - fhHodoMessType(NULL), - fhHodoSysMessType(NULL), - fhHodoMessTypePerDpb(NULL), - fhHodoSysMessTypePerDpb(NULL), - fhHodoMessTypePerElink(NULL), - fhHodoSysMessTypePerElink(NULL), - fhHodoChanCntRaw(), - fhHodoChanAdcRaw(), - fhHodoChanAdcRawProf(), - fhHodoChanRawTs(), - fhHodoChanMissEvt(), - fhHodoChanMissEvtEvo(), - fhHodoChanHitRateEvo(), - fhHodoFebRateEvo(), - fhHodoFebMissEvtEvo(), - fhHodoChanHitRateEvoLong(), - fhHodoFebRateEvoLong(), - fdCoincBorderHodo( 50.0 ), - fdCoincBorderSts( 75.0 ), - fdCoincBorder( 150.0 ), - fhSetupSortedDtX1Y1(NULL), - fhSetupSortedDtX2Y2(NULL), - fhSetupSortedDtN1P1(NULL), - fhSetupSortedDtN2P2(NULL), - fhSetupSortedDtX1Y1X2Y2(NULL), - fhSetupSortedDtN1P1N2P2(NULL), - fhSetupSortedDtX1Y1X2Y2N1P1(NULL), - fhSetupSortedDtX1Y1X2Y2N2P2(NULL), - fhSetupSortedDtH1H2S1S2(NULL), - fhSetupSortedMapX1Y1(NULL), - fhSetupSortedMapX2Y2(NULL), - fhSetupSortedMapN1P1(NULL), - fhSetupSortedMapN2P2(NULL), - fhSetupSortedCntEvoX1Y1(NULL), - fhSetupSortedCntEvoX2Y2(NULL), - fhSetupSortedCntEvoN1P1(NULL), - fhSetupSortedCntEvoN2P2(NULL), - fhBothHodoSortedDtX1Y1(NULL), - fhBothHodoSortedDtX2Y2(NULL), - fhBothHodoSortedDtX1Y1X2Y2N1P1(NULL), - fhBothHodoSortedDtX1Y1X2Y2N2P2(NULL), - fhBothHodoSortedDtH1H2S1S2(NULL), - fhBothHodoSortedMapX1Y1(NULL), - fhBothHodoSortedMapX2Y2(NULL), - fhBothHodoSortedCntEvoX1Y1(NULL), - fhBothHodoSortedCntEvoX2Y2(NULL), - fhH1H2S1SortedDtX1Y1(NULL), - fhH1H2S1SortedDtX2Y2(NULL), - fhH1H2S1SortedDtN1P1(NULL), - fhH1H2S1SortedDtN2P2(NULL), - fhH1H2S1SortedMapX1Y1(NULL), - fhH1H2S1SortedMapX2Y2(NULL), - fhH1H2S1SortedMapN1P1(NULL), - fhH1H2S1SortedMapN2P2(NULL), - fhH1H2S1SortedCntEvoX1Y1(NULL), - fhH1H2S1SortedCntEvoX2Y2(NULL), - fhH1H2S1SortedCntEvoN1P1(NULL), - fhH1H2S1SortedCntEvoN2P2(NULL), - fhH1H2S2SortedDtX1Y1(NULL), - fhH1H2S2SortedDtX2Y2(NULL), - fhH1H2S2SortedDtN1P1(NULL), - fhH1H2S2SortedDtN2P2(NULL), - fhH1H2S2SortedMapX1Y1(NULL), - fhH1H2S2SortedMapX2Y2(NULL), - fhH1H2S2SortedMapN1P1(NULL), - fhH1H2S2SortedMapN2P2(NULL), - fhH1H2S2SortedCntEvoX1Y1(NULL), - fhH1H2S2SortedCntEvoX2Y2(NULL), - fhH1H2S2SortedCntEvoN1P1(NULL), - fhH1H2S2SortedCntEvoN2P2(NULL), - fhSystSortedDtX1Y1(NULL), - fhSystSortedDtX2Y2(NULL), - fhSystSortedDtN1P1(NULL), - fhSystSortedDtN2P2(NULL), - fhSystSortedDtX1Y1X2Y2(NULL), - fhSystSortedMapX1Y1(NULL), - fhSystSortedMapX2Y2(NULL), - fhSystSortedMapN1P1(NULL), - fhSystSortedMapN2P2(NULL), - fhSystSortedCntEvoX1Y1(NULL), - fhSystSortedCntEvoX2Y2(NULL), - fhSystSortedCntEvoN1P1(NULL), - fhSystSortedCntEvoN2P2(NULL), - fhSystSortedDtN1X1vsN1X2(NULL), - fhSystSortedDtP1X1vsP1X2(NULL), - fhSystSortedDtN1X1vsP1X1(NULL), - fhSystSortedDtSts1Hodo1vsSts1Hodo2(NULL), - fhSystSortedDtSts2Hodo1vsSts2Hodo2(NULL), - fhSystSortedDtAllVsMapX1(NULL), - fhSystSortedDtAllVsMapY1(NULL), - fhSystSortedDtAllVsMapX2(NULL), - fhSystSortedDtAllVsMapY2(NULL), - fhSetupSortedDtX1(NULL), - fhSetupSortedDtY1(NULL), - fhSetupSortedDtX2(NULL), - fhSetupSortedDtY2(NULL), - fhSetupSortedDtN1(NULL), - fhSetupSortedDtP1(NULL), - fhSetupSortedDtN2(NULL), - fhSetupSortedDtP2(NULL), - fvulTimeLastHitAsicChan(), - fviAdcLastHitAsicChan(), - fvuNbSameHitAsicChan(), - fvuNbSameFullHitAsicChan(), - fvulStartTimeLastS(), - fvuNbHitDiffTsAsicLastS(), - fvuNbHitSameTsAsicLastS(), - fvuNbHitSameTsAdcAsicLastS(), - fhSetupSortedNbSameTsChan(), - fhSetupSortedSameTsAdcChan(), - fhSetupSortedSameTsAdcDiff(), - fhSetupSortedRatioSameTsChan(), - fhSetupSortedNbConsSameTsChan(), - fhSetupSortedNbConsSameTsAdcChan(), - fhSetupSortedNbConsSameTsVsTsAdc(), - fhSetupSortedAsicRatioSameTsVsFlux(), - fhSetupSortedAsicRatioSameTsAdcVsFlux(), - fhSetupSortedAsicRatioSameAdcSameTsVsFlux(), - fhHodoX1SpillEvo(NULL), - fhHodoY1SpillEvo(NULL), - fhHodoX2SpillEvo(NULL), - fhHodoY2SpillEvo(NULL), - fdSpillEvoLength( 700.0 ), - fhHodoX1SpillEvoProf(NULL), - fhHodoY1SpillEvoProf(NULL), - fhHodoX2SpillEvoProf(NULL), - fhHodoY2SpillEvoProf(NULL), - fcMsSizeAll(NULL) -{ -} - -CbmCosy2018MonitorSetup::~CbmCosy2018MonitorSetup() -{ -} - -Bool_t CbmCosy2018MonitorSetup::Init() -{ - LOG(info) << "Initializing flib StsXyter unpacker for STS"; - - FairRootManager* ioman = FairRootManager::Instance(); - if (ioman == NULL) { - LOG(fatal) << "No FairRootManager instance"; - } - - return kTRUE; -} - -void CbmCosy2018MonitorSetup::SetParContainers() -{ - LOG(info) << "Setting parameter containers for " << GetName(); - fUnpackParHodo = (CbmCern2017UnpackParHodo*)(FairRun::Instance()->GetRuntimeDb()->getContainer("CbmCern2017UnpackParHodo")); - fUnpackParSts = (CbmCern2017UnpackParSts*)(FairRun::Instance()->GetRuntimeDb()->getContainer("CbmCern2017UnpackParSts")); -} - - -Bool_t CbmCosy2018MonitorSetup::InitContainers() -{ - LOG(info) << "Init parameter containers for " << GetName(); - - Bool_t bReInit = ReInitContainers(); - CreateHistograms(); - - return bReInit; -} - -Bool_t CbmCosy2018MonitorSetup::ReInitContainers() -{ - LOG(info) << "ReInit parameter containers for " << GetName(); - - fuNrOfDpbs = fUnpackParHodo->GetNrOfDpbs(); - fuNbElinksPerDpb = fUnpackParHodo->GetNbElinksPerDpb(); - fuNbStsXyters = fUnpackParHodo->GetNbStsXyters(); - fuNbChanPerAsic = fUnpackParHodo->GetNbChanPerAsic(); - - - LOG(info) << "Nr. of STS DPBs: " << fuNrOfDpbs; - - fDpbIdIndexMap.clear(); - fvuElinkToAsic.resize( fuNrOfDpbs ); - for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - { - fDpbIdIndexMap[ fUnpackParHodo->GetDpbId( uDpb ) ] = uDpb; - LOG(info) << "Eq. ID for DPB #" << std::setw(2) << uDpb << " = " - << std::setw(4) << std::hex << fUnpackParHodo->GetDpbId( uDpb ) - << std::dec - << " => " << fDpbIdIndexMap[ fUnpackParHodo->GetDpbId( uDpb ) ]; - - fvuElinkToAsic[uDpb].resize( fuNbElinksPerDpb ); - for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink ) - fvuElinkToAsic[uDpb][uElink] = fUnpackParHodo->GetElinkToAsicIdx( uDpb * fuNbElinksPerDpb + uElink ); - } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - - LOG(info) << "Nr. eLinks per DPB: " << fuNbElinksPerDpb; - LOG(info) << "Nr. of StsXyter ASICs: " << fuNbStsXyters; - LOG(info) << "Nb. channels per ASIC: " << fuNbChanPerAsic; - - for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - { - LOG(info) << "ASIC ID for eLinks in DPB #" << std::setw(2) << uDpb << ": "; - - std::stringstream ss; - for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink ) - { - if( 0 == uElink % 10 ) - ss << "\n------> "; - - ss << std::setw( 5 ) << fvuElinkToAsic[uDpb][uElink] << " "; - } // for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink ) - LOG(info) << ss.str(); - } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - - LOG(info) << "ASIC Idx for Hodo 1: " << fUnpackParHodo->GetAsicIndexHodo1(); - LOG(info) << "ASIC Idx for Hodo 2: " << fUnpackParHodo->GetAsicIndexHodo2(); - - LOG(info) << "XY swapped in Hodo 1: " << fUnpackParHodo->IsXySwappedHodo1(); - LOG(info) << "XY swapped in Hodo 2: " << fUnpackParHodo->IsXySwappedHodo2(); - - LOG(info) << "X axis inverted in Hodo 1: " << fUnpackParHodo->IsXInvertedHodo1(); - LOG(info) << "X axis inverted in Hodo 1: " << fUnpackParHodo->IsYInvertedHodo1(); - LOG(info) << "X axis inverted in Hodo 2: " << fUnpackParHodo->IsXInvertedHodo2(); - LOG(info) << "X axis inverted in Hodo 2: " << fUnpackParHodo->IsYInvertedHodo2(); - - // Internal status initialization - fvulCurrentTsMsb.resize( fuNrOfDpbs ); - fvuCurrentTsMsbCycle.resize( fuNrOfDpbs ); - fvuElinkLastTsHit.resize( fuNrOfDpbs ); - for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - { - fvulCurrentTsMsb[uDpb] = 0; - fvuCurrentTsMsbCycle[uDpb] = 0; -/* - fvuElinkLastTsHit[uDpb].resize( fuNbElinksPerDpb ); - for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink ) - { - fvuElinkLastTsHit[uDpb][uElink] = 0; - } // for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink ) -*/ - } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - - fvulChanLastHitTime.resize( fuNbStsXyters ); - fvdChanLastHitTime.resize( fuNbStsXyters ); - fvdMsTime.resize( fuMaxNbMicroslices ); - fvuChanNbHitsInMs.resize( fuNbStsXyters ); - fvdChanLastHitTimeInMs.resize( fuNbStsXyters ); - fvusChanLastHitAdcInMs.resize( fuNbStsXyters ); -// fvmChanHitsInTs.resize( fuNbStsXyters ); - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fvulChanLastHitTime[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvdChanLastHitTime[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvuChanNbHitsInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvdChanLastHitTimeInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvusChanLastHitAdcInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); -// fvmChanHitsInTs[ uXyterIdx ].resize( fuNbChanPerAsic ); - for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - { - fvulChanLastHitTime[ uXyterIdx ][ uChan ] = 0; - fvdChanLastHitTime[ uXyterIdx ][ uChan ] = -1.0; - - fvuChanNbHitsInMs[ uXyterIdx ][ uChan ].resize( fuMaxNbMicroslices ); - fvdChanLastHitTimeInMs[ uXyterIdx ][ uChan ].resize( fuMaxNbMicroslices ); - fvusChanLastHitAdcInMs[ uXyterIdx ][ uChan ].resize( fuMaxNbMicroslices ); -// fvmChanHitsInTs[ uXyterIdx ][ uChan ].clear(); - for( UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx ) - { - fvuChanNbHitsInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = 0; - fvdChanLastHitTimeInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = -1.0; - fvusChanLastHitAdcInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = 0; - } // for( UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx ) - } // for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - LOG(info) << "CbmCosy2018MonitorSetup::ReInitContainers => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs.size() << " VS " << fuNbStsXyters; - LOG(info) << "CbmCosy2018MonitorSetup::ReInitContainers => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs[ 0 ].size() << " VS " << fuNbChanPerAsic; - LOG(info) << "CbmCosy2018MonitorSetup::ReInitContainers => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs[ 0 ][ 0 ].size() << " VS " << fuMaxNbMicroslices; - - /// Counting of hits without proper timestamp - fvulTimeLastHitAsicChan.resize( fuNbStsXyters ); - fviAdcLastHitAsicChan.resize( fuNbStsXyters ); - fvuNbSameHitAsicChan.resize( fuNbStsXyters ); - fvuNbSameFullHitAsicChan.resize( fuNbStsXyters ); - fvulStartTimeLastS.resize( fuNbStsXyters ); - fvuNbHitDiffTsAsicLastS.resize( fuNbStsXyters ); - fvuNbHitSameTsAsicLastS.resize( fuNbStsXyters ); - fvuNbHitSameTsAdcAsicLastS.resize( fuNbStsXyters ); - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fvulTimeLastHitAsicChan[ uXyterIdx ].resize( fuNbChanPerAsic ); - fviAdcLastHitAsicChan[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvuNbSameHitAsicChan[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvuNbSameFullHitAsicChan[ uXyterIdx ].resize( fuNbChanPerAsic ); - for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - { - fvulTimeLastHitAsicChan[ uXyterIdx ][ uChan ] = 0; - fviAdcLastHitAsicChan[ uXyterIdx ][ uChan ] = 0; - fvuNbSameHitAsicChan[ uXyterIdx ][ uChan ] = 0; - fvuNbSameFullHitAsicChan[ uXyterIdx ][ uChan ] = 0; - } // for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - - fvulStartTimeLastS[ uXyterIdx ] = 0; - fvuNbHitDiffTsAsicLastS[ uXyterIdx ] = 0; - fvuNbHitSameTsAsicLastS[ uXyterIdx ] = 0; - fvuNbHitSameTsAdcAsicLastS[ uXyterIdx ] = 0; - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - - LOG(info) << "CbmCosy2018MonitorSetup::ReInitContainers => Dual STS mode: " << fbDualStsEna; - return kTRUE; -} - -void CbmCosy2018MonitorSetup::CreateHistograms() -{ - TString sHistName{""}; - TString title{""}; - - sHistName = "hHodoMessageType"; - title = "Nb of message for each type; Type"; - fhHodoMessType = new TH1I(sHistName, title, 5, 0., 5.); - fhHodoMessType->GetXaxis()->SetBinLabel( 1, "Dummy"); - fhHodoMessType->GetXaxis()->SetBinLabel( 2, "Hit"); - fhHodoMessType->GetXaxis()->SetBinLabel( 3, "TsMsb"); - fhHodoMessType->GetXaxis()->SetBinLabel( 4, "Epoch"); - fhHodoMessType->GetXaxis()->SetBinLabel( 5, "Empty"); -/* *** Missing int + MessType OP!!!! **** - fhHodoMessType->GetXaxis()->SetBinLabel(1 + stsxyter::MessType::Dummy, "Dummy"); - fhHodoMessType->GetXaxis()->SetBinLabel(1 + stsxyter::MessType::Hit, "Hit"); - fhHodoMessType->GetXaxis()->SetBinLabel(1 + stsxyter::MessType::TsMsb, "TsMsb"); - fhHodoMessType->GetXaxis()->SetBinLabel(1 + stsxyter::MessType::ReadDataAck, "ReadDataAck"); - fhHodoMessType->GetXaxis()->SetBinLabel(1 + stsxyter::MessType::Ack, "Ack"); -*/ - - sHistName = "hHodoSysMessType"; - title = "Nb of system message for each type; System Type"; - fhHodoSysMessType = new TH1I(sHistName, title, 17, 0., 17.); -/* - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_START, "DAQ START"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_FINISH, "DAQ FINISH"); - hSysMessType->GetXaxis()->SetBinLabel(1 + 16, "GET4 Hack 32B"); -*/ - - sHistName = "hHodoMessageTypePerDpb"; - title = "Nb of message of each type for each DPB; DPB; Type"; - fhHodoMessTypePerDpb = new TH2I(sHistName, title, fuNrOfDpbs, 0, fuNrOfDpbs, 5, 0., 5.); - fhHodoMessTypePerDpb->GetYaxis()->SetBinLabel( 1, "Dummy"); - fhHodoMessTypePerDpb->GetYaxis()->SetBinLabel( 2, "Hit"); - fhHodoMessTypePerDpb->GetYaxis()->SetBinLabel( 3, "TsMsb"); - fhHodoMessTypePerDpb->GetYaxis()->SetBinLabel( 4, "Epoch"); - fhHodoMessTypePerDpb->GetYaxis()->SetBinLabel( 5, "Empty"); -/* *** Missing int + MessType OP!!!! **** - fhHodoMessType->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Dummy, "Dummy"); - fhHodoMessType->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Hit, "Hit"); - fhHodoMessType->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::TsMsb, "TsMsb"); - fhHodoMessType->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::ReadDataAck, "ReadDataAck"); - fhHodoMessType->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Ack, "Ack"); -*/ - - sHistName = "hHodoSysMessTypePerDpb"; - title = "Nb of system message of each type for each DPB; DPB; System Type"; - fhHodoSysMessTypePerDpb = new TH2I(sHistName, title, fuNrOfDpbs, 0, fuNrOfDpbs, 17, 0., 17.); -/* - hSysMessType->GetYaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_START, "DAQ START"); - hSysMessType->GetYaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_FINISH, "DAQ FINISH"); - hSysMessType->GetYaxis()->SetBinLabel(1 + 16, "GET4 Hack 32B"); -*/ - - sHistName = "hHodoMessageTypePerElink"; - title = "Nb of message of each type for each eLink; eLink; Type"; - fhHodoMessTypePerElink = new TH2I(sHistName, title, fuNrOfDpbs * fuNbElinksPerDpb, 0, fuNrOfDpbs * fuNbElinksPerDpb, 5, 0., 5.); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel( 1, "Dummy"); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel( 2, "Hit"); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel( 3, "TsMsb"); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel( 4, "ReadDataAck"); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel( 5, "Ack"); -/* *** Missing int + MessType OP!!!! **** - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Dummy, "Dummy"); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Hit, "Hit"); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::TsMsb, "TsMsb"); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::ReadDataAck, "ReadDataAck"); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Ack, "Ack"); -*/ - - sHistName = "hHodoSysMessTypePerElink"; - title = "Nb of system message of each type for each eLink; eLink; System Type"; - fhHodoSysMessTypePerElink = new TH2I(sHistName, title, fuNrOfDpbs * fuNbElinksPerDpb, 0, fuNrOfDpbs * fuNbElinksPerDpb, 17, 0., 17.); -/* - fhHodoSysMessTypePerElink->GetYaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_START, "DAQ START"); - fhHodoSysMessTypePerElink->GetYaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_FINISH, "DAQ FINISH"); - fhHodoSysMessTypePerElink->GetYaxis()->SetBinLabel(1 + 16, "GET4 Hack 32B"); -*/ - - // Number of rate bins = - // 9 for the sub-unit decade - // + 9 for each unit of each decade * 10 for the subdecade range - // + 1 for the closing bin top edge - const Int_t iNbDecadesRate = 9; - const Int_t iNbStepsDecade = 9; - const Int_t iNbSubStepsInStep = 10; - const Int_t iNbBinsRate = iNbStepsDecade - + iNbStepsDecade * iNbSubStepsInStep * iNbDecadesRate - + 1; - Double_t dBinsRate[iNbBinsRate]; - // First fill sub-unit decade - for( Int_t iSubU = 0; iSubU < iNbStepsDecade; iSubU ++ ) - dBinsRate[ iSubU ] = 0.1 * ( 1 + iSubU ); - std::cout << std::endl; - // Then fill the main decades - Double_t dSubstepSize = 1.0 / iNbSubStepsInStep; - for( Int_t iDecade = 0; iDecade < iNbDecadesRate; iDecade ++) - { - Double_t dBase = std::pow( 10, iDecade ); - Int_t iDecadeIdx = iNbStepsDecade - + iDecade * iNbStepsDecade * iNbSubStepsInStep; - for( Int_t iStep = 0; iStep < iNbStepsDecade; iStep++ ) - { - Int_t iStepIdx = iDecadeIdx + iStep * iNbSubStepsInStep; - for( Int_t iSubStep = 0; iSubStep < iNbSubStepsInStep; iSubStep++ ) - { - dBinsRate[ iStepIdx + iSubStep ] = dBase * (1 + iStep) - + dBase * dSubstepSize * iSubStep; - } // for( Int_t iSubStep = 0; iSubStep < iNbSubStepsInStep; iSubStep++ ) - } // for( Int_t iStep = 0; iStep < iNbStepsDecade; iStep++ ) - } // for( Int_t iDecade = 0; iDecade < iNbDecadesRate; iDecade ++) - dBinsRate[ iNbBinsRate - 1 ] = std::pow( 10, iNbDecadesRate ); - - UInt_t uAlignedLimit = fuLongHistoNbSeconds - (fuLongHistoNbSeconds % fuLongHistoBinSizeSec); - fuLongHistoBinNb = uAlignedLimit / fuLongHistoBinSizeSec; - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - // Channel counts - sHistName = Form( "hHodoChanCntRaw_%03u", uXyterIdx ); - title = Form( "Hits Count per channel, StsXyter #%03u; Channel; Hits []", uXyterIdx ); - fhHodoChanCntRaw.push_back( new TH1I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - - // Raw Adc Distribution - sHistName = Form( "hHodoChanAdcRaw_%03u", uXyterIdx ); - title = Form( "Raw Adc distribution per channel, StsXyter #%03u; Channel []; Adc []; Hits []", uXyterIdx ); - fhHodoChanAdcRaw.push_back( new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - stsxyter::kuHitNbAdcBins, -0.5, stsxyter::kuHitNbAdcBins -0.5 ) ); - - // Raw Adc Distribution profile - sHistName = Form( "hHodoChanAdcRawProfc_%03u", uXyterIdx ); - title = Form( "Raw Adc prodile per channel, StsXyter #%03u; Channel []; Adc []", uXyterIdx ); - fhHodoChanAdcRawProf.push_back( new TProfile(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - - // Raw Ts Distribution - sHistName = Form( "hHodoChanRawTs_%03u", uXyterIdx ); - title = Form( "Raw Timestamp distribution per channel, StsXyter #%03u; Channel []; Ts []; Hits []", uXyterIdx ); - fhHodoChanRawTs.push_back( new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - stsxyter::kuHitNbTsBins, -0.5, stsxyter::kuHitNbTsBins -0.5 ) ); - - // Missed event flag - sHistName = Form( "hHodoChanMissEvt_%03u", uXyterIdx ); - title = Form( "Missed Event flags per channel, StsXyter #%03u; Channel []; Miss Evt []; Hits []", uXyterIdx ); - fhHodoChanMissEvt.push_back( new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - 2, -0.5, 1.5 ) ); - - // Missed event flag counts evolution - - sHistName = Form( "hHodoChanMissEvtEvo_%03u", uXyterIdx ); - title = Form( "Missed Evt flags per second & channel in StsXyter #%03u; Time [s]; Channel []; Missed Evt flags []", uXyterIdx ); - fhHodoChanMissEvtEvo.push_back( new TH2I( sHistName, title, - 1800, 0, 1800, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - - // Missed event flag counts evo per StsXyter - - sHistName = Form( "hHodoFebMissEvtEvo%03u", uXyterIdx ); - title = Form( "Missed Evt flags per second in StsXyter #%03u; Time [s]; Missed Evt flags []", uXyterIdx ); - fhHodoFebMissEvtEvo.push_back( new TH1I(sHistName, title, 1800, 0, 1800 ) ); - - // Hit rates evo per channel - sHistName = Form( "hHodoChanRateEvo_%03u", uXyterIdx ); - title = Form( "Hits per second & channel in StsXyter #%03u; Time [s]; Channel []; Hits []", uXyterIdx ); - fhHodoChanHitRateEvo.push_back( new TH2I( sHistName, title, - 1800, 0, 1800, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - - // Hit rates evo per StsXyter - sHistName = Form( "hHodoFebRateEvo_%03u", uXyterIdx ); - title = Form( "Hits per second in StsXyter #%03u; Time [s]; Hits []", uXyterIdx ); - fhHodoFebRateEvo.push_back( new TH1I(sHistName, title, 1800, 0, 1800 ) ); - - // Hit rates evo per channel, 1 minute bins, 24h - sHistName = Form( "hHodoChanRateEvoLong_%03u", uXyterIdx ); - title = Form( "Hits per second & channel in StsXyter #%03u; Time [min]; Channel []; Hits []", uXyterIdx ); - fhHodoChanHitRateEvoLong.push_back( new TH2D( sHistName, title, - fuLongHistoBinNb, -0.5, uAlignedLimit - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - - // Hit rates evo per StsXyter, 1 minute bins, 24h - sHistName = Form( "hHodoFebRateEvoLong_%03u", uXyterIdx ); - title = Form( "Hits per second in StsXyter #%03u; Time [min]; Hits []", uXyterIdx ); - fhHodoFebRateEvoLong.push_back( new TH1D(sHistName, title, - fuLongHistoBinNb, -0.5, uAlignedLimit - 0.5 ) ); - -/* - if( kTRUE == fbLongHistoEnable ) - { - sHistName = Form( "hFebRateEvoLong_%03u", uXyterIdx ); - title = Form( "Mean rate VS run time in same MS in StsXyter #%03u; Time in run [s]; Rate [1/s]", uXyterIdx ); - fhFebRateEvoLong.push_back( new TH1D( sHistName, title, - fuLongHistoBinNb, -0.5, uAlignedLimit - 0.5) ); - if( server ) server->Register("/StsRaw", fhFebRateEvoLong[ uXyterIdx ] ); - - sHistName = Form( "hFebChRateEvoLong_%03u", uXyterIdx ); - title = Form( "Mean rate per channel VS run time in StsXyter #%03u; Time in run [s]; Channel []; Rare [1/s]", uXyterIdx ); - fhFebChRateEvoLong.push_back( new TH2D( sHistName, title, - fuLongHistoBinNb, -0.5, uAlignedLimit - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - if( server ) server->Register("/StsRaw", fhFebChRateEvoLong[ uXyterIdx ] ); - } // if( kTRUE == fbLongHistoEnable ) -*/ - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - - UInt_t uNbBinEvo = 32768 + 1; - Double_t dMaxEdgeEvo = stsxyter::kdClockCycleNs - * static_cast< Double_t >( uNbBinEvo ) / 2.0; - Double_t dMinEdgeEvo = dMaxEdgeEvo * -1.0; - - UInt_t uNbBinDtHodo = static_cast<UInt_t>( fdCoincBorderHodo/stsxyter::kdClockCycleNs ); - UInt_t uNbBinDtBothHodo = static_cast<UInt_t>( 2*fdCoincBorderHodo/stsxyter::kdClockCycleNs ); - UInt_t uNbBinDtSts = static_cast<UInt_t>( fdCoincBorderSts/stsxyter::kdClockCycleNs ); -// UInt_t uNbBinDtSyst = static_cast<UInt_t>( fdCoincBorder/stsxyter::kdClockCycleNs ); - - /// Coincidences inside each detector ----------------------------/// - sHistName = "fhSetupSortedDtX1Y1"; - title = "Time diff for hits Hodo 1 X and Hodo 1 Y; tY1 - tX1 [ns]; Counts"; - fhSetupSortedDtX1Y1 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhSetupSortedDtX2Y2"; - title = "Time diff for hits Hodo 2 X and Hodo 2 Y; tY2 - tX2 [ns]; Counts"; - fhSetupSortedDtX2Y2 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhSetupSortedDtN1P1"; - title = "Time diff for hits Sts 1 N and Sts 1 P; tP1 - tN1 [ns]; Counts"; - fhSetupSortedDtN1P1 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhSetupSortedDtN2P2"; - title = "Time diff for hits Sts 2 N and Sts 2 P; tP2 - tN2 [ns]; Counts"; - fhSetupSortedDtN2P2 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhSetupSortedDtX1Y1X2Y2"; - title = "Time diff for hits Hodo 1 (X,Y) vs Hodo 2 (X,Y); t<X2,Y2> - t<X1,Y1> [ns]; Counts"; - fhSetupSortedDtX1Y1X2Y2 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhSetupSortedDtN1P1N2P2"; - title = "Time diff for hits STS 1 (N,P) vs STS 2 (N,P); t<N2,P2> - t<N1,P1> [ns]; Counts"; - fhSetupSortedDtN1P1N2P2 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhSetupSortedDtX1Y1X2Y2N1P1"; - title = "Time diff for hits Hodo (X1,Y1,X2,Y2) vs Sts 1 (N,P); t<N1,P1> - t<X1,Y1,X2,Y2> [ns]; Counts"; - fhSetupSortedDtX1Y1X2Y2N1P1 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhSetupSortedDtX1Y1X2Y2N2P2"; - title = "Time diff for hits Hodo (X1,Y1,X2,Y2) vs Sts 2 (N,P); t<N2,P2> - t<X1,Y1,X2,Y2> [ns]; Counts"; - fhSetupSortedDtX1Y1X2Y2N2P2 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhSetupSortedDtH1H2S1S2"; - title = "Time diff for hits Hodo (X1,Y1,X2,Y2) vs Sts (N1,P1,N2,P2); t<N1,P1,N2,P2> - t<X1,Y1,X2,Y2> [ns]; Counts"; - fhSetupSortedDtH1H2S1S2 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhSetupSortedMapX1Y1"; - title = "Sorted hits in coincidence for hodoscope 1 axis X and Y; X channel Hodo 1 []; Y channel Hodo 1 []; hits []"; - fhSetupSortedMapX1Y1 = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhSetupSortedMapX2Y2"; - title = "Sorted hits in coincidence for hodoscope 2 axis X and Y; X channel Hodo 2 []; Y channel Hodo 2 []; hits []"; - fhSetupSortedMapX2Y2 = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhSetupSortedMapN1P1"; - title = "Sorted hits in coincidence for Sts 1 sides N and P; N channel Sts 1 []; P channel Sts 1 []; hits []"; - fhSetupSortedMapN1P1 = new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - - sHistName = "fhSetupSortedMapN2P2"; - title = "Sorted hits in coincidence for Sts 2 sides N and P; N channel Sts 2 []; P channel Sts 2 []; hits []"; - fhSetupSortedMapN2P2 = new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - - // Coincidence counts evolution between some axis of the hodoscopes - sHistName = "hSetupSortedCntEvoX1Y1"; - title = "Nb of coincidences in both X1 and Y1 per s; Time [s]; X1-Y1 coincidences []"; - fhSetupSortedCntEvoX1Y1 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "hSetupSortedCntEvoX2Y2"; - title = "Nb of coincidences in both X2 and Y2 per s; Time [s]; X2-Y2 coincidences []"; - fhSetupSortedCntEvoX2Y2 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "hSetupSortedCntEvoN1P1"; - title = "Nb of coincidences in both N1 and P1 per s; Time [s]; N1-P1 coincidences []"; - fhSetupSortedCntEvoN1P1 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "hSetupSortedCntEvoN2P2"; - title = "Nb of coincidences in both N2 and P2 per s; Time [s]; N2-P2 coincidences []"; - fhSetupSortedCntEvoN2P2 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - /// Coincidences between hodoscopes ------------------------------/// - sHistName = "fhBothHodoSortedDtX1Y1"; - title = "Time diff for hits Hodo 1 X and Hodo 1 Y; tY1 - tX1 [ns]; Counts"; - fhBothHodoSortedDtX1Y1 = new TH1I(sHistName, title, uNbBinDtHodo, -fdCoincBorderHodo, fdCoincBorderHodo ); - - sHistName = "fhBothHodoSortedDtX2Y2"; - title = "Time diff for hits Hodo 2 X and Hodo 2 Y; tY2 - tX2 [ns]; Counts"; - fhBothHodoSortedDtX2Y2 = new TH1I(sHistName, title, uNbBinDtHodo, -fdCoincBorderHodo, fdCoincBorderHodo ); - - sHistName = "fhBothHodoSortedDtX1Y1X2Y2N1P1"; - title = "Time diff for hits Hodo (X1,Y1,X2,Y2) vs Sts 1 (N,P); t<N1,P1> - t<X1,Y1,X2,Y2> [ns]; Counts"; - fhBothHodoSortedDtX1Y1X2Y2N1P1 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhBothHodoSortedDtX1Y1X2Y2N2P2"; - title = "Time diff for hits Hodo (X1,Y1,X2,Y2) vs Sts 2 (N,P); t<N2,P2> - t<X1,Y1,X2,Y2> [ns]; Counts"; - fhBothHodoSortedDtX1Y1X2Y2N2P2 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhBothHodoSortedDtH1H2S1S2"; - title = "Time diff for hits Hodo (X1,Y1,X2,Y2) vs Sts (N1,P1,N2,P2); t<N1,P1,N2,P2> - t<X1,Y1,X2,Y2> [ns]; Counts"; - fhBothHodoSortedDtH1H2S1S2 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhBothHodoSortedMapX1Y1"; - title = "Sorted hits in coincidence for hodoscope 1 axis X and Y; X channel Hodo 1 []; Y channel Hodo 1 []; hits []"; - fhBothHodoSortedMapX1Y1 = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhBothHodoSortedMapX2Y2"; - title = "Sorted hits in coincidence for hodoscope 2 axis X and Y; X channel Hodo 2 []; Y channel Hodo 2 []; hits []"; - fhBothHodoSortedMapX2Y2 = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - // Coincidence counts evolution between some axis of the hodoscopes - sHistName = "hBothHodoSortedCntEvoX1Y1"; - title = "Nb of coincidences in both X1 and Y1 per s; Time [s]; X1-Y1 coincidences []"; - fhBothHodoSortedCntEvoX1Y1 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "hBothHodoSortedCntEvoX2Y2"; - title = "Nb of coincidences in both X2 and Y2 per s; Time [s]; X2-Y2 coincidences []"; - fhBothHodoSortedCntEvoX2Y2 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - /// Coincidences between hodoscopes and STS 1 --------------------/// - sHistName = "fhH1H2S1SortedDtX1Y1"; - title = "Time diff for hits Hodo 1 X and Hodo 1 Y; tY1 - tX1 [ns]; Counts"; - fhH1H2S1SortedDtX1Y1 = new TH1I(sHistName, title, uNbBinDtHodo, -fdCoincBorderHodo, fdCoincBorderHodo ); - - sHistName = "fhH1H2S1SortedDtX2Y2"; - title = "Time diff for hits Hodo 2 X and Hodo 2 Y; tY2 - tX2 [ns]; Counts"; - fhH1H2S1SortedDtX2Y2 = new TH1I(sHistName, title, uNbBinDtHodo, -fdCoincBorderHodo, fdCoincBorderHodo ); - - sHistName = "fhH1H2S1SortedDtN1P1"; - title = "Time diff for hits Sts 1 N and Sts 1 P; tP1 - tN1 [ns]; Counts"; - fhH1H2S1SortedDtN1P1 = new TH1I(sHistName, title, uNbBinDtSts, -fdCoincBorderSts, fdCoincBorderSts ); - - sHistName = "fhH1H2S1SortedDtN2P2"; - title = "Time diff for hits Sts 2 N and Sts 1 P; tP2 - tN2 [ns]; Counts"; - fhH1H2S1SortedDtN2P2 = new TH1I(sHistName, title, uNbBinDtSts, -fdCoincBorderSts, fdCoincBorderSts ); - - sHistName = "fhH1H2S1SortedMapX1Y1"; - title = "Sorted hits in coincidence for hodoscope 1 axis X and Y; X channel Hodo 1 []; Y channel Hodo 1 []; hits []"; - fhH1H2S1SortedMapX1Y1 = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhH1H2S1SortedMapX2Y2"; - title = "Sorted hits in coincidence for hodoscope 2 axis X and Y; X channel Hodo 2 []; Y channel Hodo 2 []; hits []"; - fhH1H2S1SortedMapX2Y2 = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhH1H2S1SortedMapN1P1"; - title = "Sorted hits in coincidence for Sts 1 sides N and P; N channel Sts 1 []; P channel Sts 1 []; hits []"; - fhH1H2S1SortedMapN1P1 = new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - - sHistName = "fhH1H2S1SortedMapN2P2"; - title = "Sorted hits in coincidence for Sts 2 sides N and P; N channel Sts 2 []; P channel Sts 2 []; hits []"; - fhH1H2S1SortedMapN2P2 = new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - - sHistName = "hH1H2S1SortedCntEvoX1Y1"; - title = "Nb of coincidences in both X1 and Y1 per s; Time [s]; X1-Y1 coincidences []"; - fhH1H2S1SortedCntEvoX1Y1 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "hH1H2S1SortedCntEvoX2Y2"; - title = "Nb of coincidences in both X2 and Y2 per s; Time [s]; X2-Y2 coincidences []"; - fhH1H2S1SortedCntEvoX2Y2 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "hH1H2S1SortedCntEvoN1P1"; - title = "Nb of coincidences in both N1 and P1 per s; Time [s]; N1-P1 coincidences []"; - fhH1H2S1SortedCntEvoN1P1 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "hH1H2S1SortedCntEvoN2P2"; - title = "Nb of coincidences in both N2 and P2 per s; Time [s]; N2-P2 coincidences []"; - fhH1H2S1SortedCntEvoN2P2 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - /// Coincidences between hodoscopes and STS 2 --------------------/// - sHistName = "fhH1H2S2SortedDtX1Y1"; - title = "Time diff for hits Hodo 1 X and Hodo 1 Y; tY1 - tX1 [ns]; Counts"; - fhH1H2S2SortedDtX1Y1 = new TH1I(sHistName, title, uNbBinDtHodo, -fdCoincBorderHodo, fdCoincBorderHodo ); - - sHistName = "fhH1H2S2SortedDtX2Y2"; - title = "Time diff for hits Hodo 2 X and Hodo 2 Y; tY2 - tX2 [ns]; Counts"; - fhH1H2S2SortedDtX2Y2 = new TH1I(sHistName, title, uNbBinDtHodo, -fdCoincBorderHodo, fdCoincBorderHodo ); - - sHistName = "fhH1H2S2SortedDtN1P1"; - title = "Time diff for hits Sts 1 N and Sts 1 P; tP1 - tN1 [ns]; Counts"; - fhH1H2S2SortedDtN1P1 = new TH1I(sHistName, title, uNbBinDtSts, -fdCoincBorderSts, fdCoincBorderSts ); - - sHistName = "fhH1H2S2SortedDtN2P2"; - title = "Time diff for hits Sts 2 N and Sts 1 P; tP2 - tN2 [ns]; Counts"; - fhH1H2S2SortedDtN2P2 = new TH1I(sHistName, title, uNbBinDtSts, -fdCoincBorderSts, fdCoincBorderSts ); - - sHistName = "fhH1H2S2SortedMapX1Y1"; - title = "Sorted hits in coincidence for hodoscope 1 axis X and Y; X channel Hodo 1 []; Y channel Hodo 1 []; hits []"; - fhH1H2S2SortedMapX1Y1 = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhH1H2S2SortedMapX2Y2"; - title = "Sorted hits in coincidence for hodoscope 2 axis X and Y; X channel Hodo 2 []; Y channel Hodo 2 []; hits []"; - fhH1H2S2SortedMapX2Y2 = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhH1H2S2SortedMapN1P1"; - title = "Sorted hits in coincidence for Sts 1 sides N and P; N channel Sts 1 []; P channel Sts 1 []; hits []"; - fhH1H2S2SortedMapN1P1 = new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - - sHistName = "fhH1H2S2SortedMapN2P2"; - title = "Sorted hits in coincidence for Sts 2 sides N and P; N channel Sts 2 []; P channel Sts 2 []; hits []"; - fhH1H2S2SortedMapN2P2 = new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - - sHistName = "hH1H2S2SortedCntEvoX1Y1"; - title = "Nb of coincidences in both X1 and Y1 per s; Time [s]; X1-Y1 coincidences []"; - fhH1H2S2SortedCntEvoX1Y1 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "hH1H2S2SortedCntEvoX2Y2"; - title = "Nb of coincidences in both X2 and Y2 per s; Time [s]; X2-Y2 coincidences []"; - fhH1H2S2SortedCntEvoX2Y2 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "hH1H2S2SortedCntEvoN1P1"; - title = "Nb of coincidences in both N1 and P1 per s; Time [s]; N1-P1 coincidences []"; - fhH1H2S2SortedCntEvoN1P1 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "hH1H2S2SortedCntEvoN2P2"; - title = "Nb of coincidences in both N2 and P2 per s; Time [s]; N2-P2 coincidences []"; - fhH1H2S2SortedCntEvoN2P2 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - /// Coincidences between hodoscopes and both STS -----------------/// - sHistName = "fhSystSortedDtX1Y1"; - title = "Time diff for hits Hodo 1 X and Hodo 1 Y; tY1 - tX1 [ns]; Counts"; - fhSystSortedDtX1Y1 = new TH1I(sHistName, title, uNbBinDtHodo, -fdCoincBorderHodo, fdCoincBorderHodo ); - - sHistName = "fhSystSortedDtX2Y2"; - title = "Time diff for hits Hodo 2 X and Hodo 2 Y; tY2 - tX2 [ns]; Counts"; - fhSystSortedDtX2Y2 = new TH1I(sHistName, title, uNbBinDtHodo, -fdCoincBorderHodo, fdCoincBorderHodo ); - - sHistName = "fhSystSortedDtN1P1"; - title = "Time diff for hits Sts 1 N and Sts 1 P; tP1 - tN1 [ns]; Counts"; - fhSystSortedDtN1P1 = new TH1I(sHistName, title, uNbBinDtSts, -fdCoincBorderSts, fdCoincBorderSts ); - - sHistName = "fhSystSortedDtN2P2"; - title = "Time diff for hits Sts 2 N and Sts 1 P; tP2 - tN2 [ns]; Counts"; - fhSystSortedDtN2P2 = new TH1I(sHistName, title, uNbBinDtSts, -fdCoincBorderSts, fdCoincBorderSts ); - - sHistName = "fhSystSortedDtX1Y1X2Y2"; - title = "Time diff for hits Hodo 1 (X,Y) vs Hodo 2 (X,Y); t<X2,Y2> - t<X1,Y1> [ns]; Counts"; - fhSystSortedDtX1Y1X2Y2 = new TH1I(sHistName, title, uNbBinDtBothHodo, -2*fdCoincBorderHodo, 2*fdCoincBorderHodo ); - - sHistName = "fhSystSortedMapX1Y1"; - title = "Sorted hits in coincidence for hodoscope 1 axis X and Y; X channel Hodo 1 []; Y channel Hodo 1 []; hits []"; - fhSystSortedMapX1Y1 = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhSystSortedMapX2Y2"; - title = "Sorted hits in coincidence for hodoscope 2 axis X and Y; X channel Hodo 2 []; Y channel Hodo 2 []; hits []"; - fhSystSortedMapX2Y2 = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhSystSortedMapN1P1"; - title = "Sorted hits in coincidence for Sts 1 sides N and P; N channel Sts 1 []; P channel Sts 1 []; hits []"; - fhSystSortedMapN1P1 = new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - - sHistName = "fhSystSortedMapN2P2"; - title = "Sorted hits in coincidence for Sts 2 sides N and P; N channel Sts 2 []; P channel Sts 2 []; hits []"; - fhSystSortedMapN2P2 = new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - - // Coincidence counts evolution between some axis of the hodoscopes - sHistName = "hSystSortedCntEvoX1Y1"; - title = "Nb of coincidences in both X1 and Y1 per s; Time [s]; X1-Y1 coincidences []"; - fhSystSortedCntEvoX1Y1 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "hSystSortedCntEvoX2Y2"; - title = "Nb of coincidences in both X2 and Y2 per s; Time [s]; X2-Y2 coincidences []"; - fhSystSortedCntEvoX2Y2 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "hSystSortedCntEvoN1P1"; - title = "Nb of coincidences in both N1 and P1 per s; Time [s]; N1-P1 coincidences []"; - fhSystSortedCntEvoN1P1 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "hSystSortedCntEvoN2P2"; - title = "Nb of coincidences in both N2 and P2 per s; Time [s]; N2-P2 coincidences []"; - fhSystSortedCntEvoN2P2 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "fhSystSortedDtN1X1vsN1X2"; - title = "Time diff (N1 vs X1) vs (N1 vs X2); tN1 - tX1 [ns]; tN1 - tX2 [ns]; Counts"; - fhSystSortedDtN1X1vsN1X2 = new TH2I(sHistName, title, 200, -400, 400, 200, -400, 400 ); - - sHistName = "fhSystSortedDtP1X1vsP1X2"; - title = "Time diff (P1 vs X1) vs (P1 vs X2); tP1 - tX1 [ns]; tP1 - tX2 [ns]; Counts"; - fhSystSortedDtP1X1vsP1X2 = new TH2I(sHistName, title, 200, -400, 400, 200, -400, 400 ); - - sHistName = "fhSystSortedDtN1X1vsP1X1"; - title = "Time diff (N1 vs X1) vs (P1 vs X1); tN1 - tX1 [ns]; tP1 - tX1 [ns]; Counts"; - fhSystSortedDtN1X1vsP1X1 = new TH2I(sHistName, title, 200, -400, 400, 200, -400, 400 ); - - sHistName = "fhSystSortedDtSts1Hodo1vsSts1Hodo2"; - title = "Time diff (Sts1 vs Hodo1) vs (Sts1 vs Hodo2); t<N1,P1> - t<X1,Y1> [ns]; t<N1,P1> - t<X2,Y2> [ns]; Counts"; - fhSystSortedDtSts1Hodo1vsSts1Hodo2 = new TH2I(sHistName, title, 200, -400, 400, 200, -400, 400 ); - - sHistName = "fhSystSortedDtSts2Hodo1vsSts2Hodo2"; - title = "Time diff (Sts2 vs Hodo1) vs (Sts2 vs Hodo2); t<N2,P2> - t<X1,Y1> [ns]; t<N2,P2> - t<X2,Y2> [ns]; Counts"; - fhSystSortedDtSts2Hodo1vsSts2Hodo2 = new TH2I(sHistName, title, 200, -400, 400, 200, -400, 400 ); - - sHistName = "fhSystSortedDtAllVsMapX1"; - title = "Time diff Hodo (X1,Y1,X2,Y2) Sts 1 (N,P) vs Hodo 1 axis X; t<N1,P1> - t<X1,Y1,X2,Y2> [ns]; X channel Hodo 1 []; hits []"; - fhSystSortedDtAllVsMapX1 = new TH2I( sHistName, title, - static_cast< Int_t >(2*fdCoincBorder), -fdCoincBorder, fdCoincBorder, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhSystSortedDtAllVsMapY1"; - title = "Time diff Hodo (X1,Y1,X2,Y2) Sts 1 (N,P) vs Hodo 1 axis Y; t<N1,P1> - t<X1,Y1,X2,Y2> [ns]; Y channel Hodo 1 []; hits []"; - fhSystSortedDtAllVsMapY1 = new TH2I( sHistName, title, - static_cast< Int_t >(2*fdCoincBorder), -fdCoincBorder, fdCoincBorder, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhSystSortedDtAllVsMapX2"; - title = "Time diff Hodo (X1,Y1,X2,Y2) Sts 1 (N,P) vs Hodo 2 axis X; t<N1,P1> - t<X1,Y1,X2,Y2> [ns]; X channel Hodo 2 []; hits []"; - fhSystSortedDtAllVsMapX2 = new TH2I( sHistName, title, - static_cast< Int_t >(2*fdCoincBorder), -fdCoincBorder, fdCoincBorder, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhSystSortedDtAllVsMapY2"; - title = "Time diff Hodo (X1,Y1,X2,Y2) Sts 1 (N,P) vs Hodo 2 axis Y; t<N1,P1> - t<X1,Y1,X2,Y2> [ns]; Y channel Hodo 2 []; hits []"; - fhSystSortedDtAllVsMapY2 = new TH2I( sHistName, title, - static_cast< Int_t >(2*fdCoincBorder), -fdCoincBorder, fdCoincBorder, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - sHistName = "fhSetupSortedDtX1"; - title = "Time diff for consecutive hits in Hodo 1 X; tX1n - tX1 [ns]; Counts"; - fhSetupSortedDtX1 = new TH1I(sHistName, title, uNbBinEvo, -0.5, 2*dMaxEdgeEvo -0.5 ); - - sHistName = "fhSetupSortedDtY1"; - title = "Time diff for consecutive hits in Hodo 1 Y; tY1n - tY1 [ns]; Counts"; - fhSetupSortedDtY1 = new TH1I(sHistName, title, uNbBinEvo, -0.5, 2*dMaxEdgeEvo -0.5); - - sHistName = "fhSetupSortedDtX2"; - title = "Time diff for consecutive hits in Hodo 2 X; tX2n - tX2 [ns]; Counts"; - fhSetupSortedDtX2 = new TH1I(sHistName, title, uNbBinEvo, -0.5, 2*dMaxEdgeEvo -0.5); - - sHistName = "fhSetupSortedDtY2"; - title = "Time diff for consecutive hits in Hodo 2 Y; tY2n - tY2 [ns]; Counts"; - fhSetupSortedDtY2 = new TH1I(sHistName, title, uNbBinEvo, -0.5, 2*dMaxEdgeEvo -0.5); - - sHistName = "fhSetupSortedDtN1"; - title = "Time diff for consecutive hits in Sts 1 Y; tN1n - tN1 [ns]; Counts"; - fhSetupSortedDtN1 = new TH1I(sHistName, title, uNbBinEvo, -0.5, 2*dMaxEdgeEvo -0.5); - - sHistName = "fhSetupSortedDtP1"; - title = "Time diff for consecutive hits in Sts 1 Y; tP1n - tP1 [ns]; Counts"; - fhSetupSortedDtP1 = new TH1I(sHistName, title, uNbBinEvo, -0.5, 2*dMaxEdgeEvo -0.5); - - sHistName = "fhSetupSortedDtN2"; - title = "Time diff for consecutive hits in Sts 1 Y; tN2n - tN2 [ns]; Counts"; - fhSetupSortedDtN2 = new TH1I(sHistName, title, uNbBinEvo, -0.5, 2*dMaxEdgeEvo -0.5); - - sHistName = "fhSetupSortedDtP2"; - title = "Time diff for consecutive hits in Sts 1 Y; tP2n - tP2 [ns]; Counts"; - fhSetupSortedDtP2 = new TH1I(sHistName, title, uNbBinEvo, -0.5, 2*dMaxEdgeEvo -0.5); -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - - -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - Double_t dAdcMinMax = stsxyter::kuHitNbAdcBins + 0.5; - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - sHistName = Form( "fhSetupSortedNbSameTsChan%02u", uXyterIdx); - title = Form( "Nb Hits with same TS per second & channel Asic %02u; Time [s]; Channel []; Hits []", uXyterIdx); - fhSetupSortedNbSameTsChan.push_back( new TH2I( sHistName, title, - 1800, 0, 1800, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - - sHistName = Form( "fhSetupSortedSameTsAdcChan%02u", uXyterIdx); - title = Form( "Adc distribution per channel for Hits with same TS Asic %02u; Channel []; Adc []; Hits []", uXyterIdx); - fhSetupSortedSameTsAdcChan.push_back( new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - stsxyter::kuHitNbAdcBins, -0.5, stsxyter::kuHitNbAdcBins -0.5 ) ); - - sHistName = Form( "fhSetupSortedSameTsAdcDiff%02u", uXyterIdx); - title = Form( "Adc difference vs consecutive hit idx per channel for Hits with same TS Asic %02u; Nb same TS before []; Adc diff []; Hits []", uXyterIdx); - fhSetupSortedSameTsAdcDiff.push_back( new TH2I(sHistName, title, - 256, -0.5, 255.5, - 2*dAdcMinMax, -dAdcMinMax, dAdcMinMax ) ); - - sHistName = Form( "fhSetupSortedRatioSameTsChan%02u", uXyterIdx); - title = Form( "Ratio Hits with same TS per second & channel Asic %02u; Time [s]; Channel []; Hits []", uXyterIdx); - fhSetupSortedRatioSameTsChan.push_back( new TProfile2D( sHistName, title, - 1800, 0, 1800, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - - sHistName = Form( "fhSetupSortedNbConsSameTsChan%02u", uXyterIdx); - title = Form( "Nb consecutive Hits with same TS per channel Asic %02u; Channel []; Hits with same TS []; []", uXyterIdx); - fhSetupSortedNbConsSameTsChan.push_back( new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - 256, -0.5, 255.5 ) ); - - sHistName = Form( "fhSetupSortedNbConsSameTsAdcChan%02u", uXyterIdx); - title = Form( "Nb consecutive Hits with same TS and ADC per channel Asic %02u; Channel []; Hits with same TS and ADC []; []", uXyterIdx); - fhSetupSortedNbConsSameTsAdcChan.push_back( new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - 256, -0.5, 255.5 ) ); - - sHistName = Form( "fhSetupSortedNbConsSameTsVsTsAdc%02u", uXyterIdx); - title = Form( "Nb consecutive Hits with same TS vs same TS and ADC Asic %02u; Hits with same TS []; Hits with same TS and ADC []; []", uXyterIdx); - fhSetupSortedNbConsSameTsVsTsAdc.push_back( new TH2I(sHistName, title, - 256, -0.5, 255.5, - 256, -0.5, 255.5 ) ); - - sHistName = Form( "fhSetupSortedAsicRatioSameTsVsFlux%02u", uXyterIdx); - title = Form( "Ratio of hits with same TS vs Hit flux Asic %02u; Hits flux [1/s]; Same Ts / All Hits []; []", uXyterIdx); - fhSetupSortedAsicRatioSameTsVsFlux.push_back( new TH2I(sHistName, title, - iNbBinsRate - 1, dBinsRate, - 101, -0.005, 1.005 ) ); - - sHistName = Form( "fhSetupSortedAsicRatioSameTsAdcVsFlux%02u", uXyterIdx); - title = Form( "Ratio of hits with same TS and ADC vs Hit flux Asic %02u; Hits flux [1/s]; Same Ts and ADC / All Hits []; []", uXyterIdx); - fhSetupSortedAsicRatioSameTsAdcVsFlux.push_back( new TH2I(sHistName, title, - iNbBinsRate - 1, dBinsRate, - 101, -0.005, 1.005 ) ); - - sHistName = Form( "fhSetupSortedAsicRatioSameAdcSameTsVsFlux%02u", uXyterIdx); - title = Form( "Ratio of hits with same ADC amond same TS vs Hit flux Asic %02u; Hits flux [1/s]; Same TS and ADC / Same TS []; []", uXyterIdx); - fhSetupSortedAsicRatioSameAdcSameTsVsFlux.push_back( new TH2I(sHistName, title, - iNbBinsRate - 1, dBinsRate, - 101, -0.005, 1.005 ) ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - sHistName = "fhHodoX1SpillEvo"; - title = "Hodo X1 counts vs time in spill; time [s]; X1 channel []; Hits []"; - fhHodoX1SpillEvo = new TH2I(sHistName, title, - 70000, 0, 70.0, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhHodoY1SpillEvo"; - title = "Hodo Y1 counts vs time in spill; time [s]; Y1 channel []; Hits []"; - fhHodoY1SpillEvo = new TH2I(sHistName, title, - 70000, 0, 70.0, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - sHistName = "fhHodoX2SpillEvo"; - title = "Hodo X2 counts vs time in spill; time [s]; X2 channel []; Hits []"; - fhHodoX2SpillEvo = new TH2I(sHistName, title, - 70000, 0, 70.0, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - sHistName = "fhHodoY2SpillEvo"; - title = "Hodo Y2 counts vs time in spill; time [s]; Y2 channel []; Hits []"; - fhHodoY2SpillEvo = new TH2I(sHistName, title, - 70000, 0, 70.0, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhHodoX1SpillEvoProf"; - title = "Hodo X1 counts vs time in spill; time [s]; X1 channel []; Hits []"; - fhHodoX1SpillEvoProf = new TProfile(sHistName, title, - 10*fdSpillEvoLength, 0, fdSpillEvoLength); - - sHistName = "fhHodoY1SpillEvoProf"; - title = "Hodo Y1 counts vs time in spill; time [s]; Y1 channel []; Hits []"; - fhHodoY1SpillEvoProf = new TProfile(sHistName, title, - 10*fdSpillEvoLength, 0, fdSpillEvoLength); - sHistName = "fhHodoX2SpillEvoProf"; - title = "Hodo X2 counts vs time in spill; time [s]; X2 channel []; Hits []"; - fhHodoX2SpillEvoProf = new TProfile(sHistName, title, - 10*fdSpillEvoLength, 0, fdSpillEvoLength); - sHistName = "fhHodoY2SpillEvoProf"; - title = "Hodo Y2 counts vs time in spill; time [s]; Y2 channel []; Hits []"; - fhHodoY2SpillEvoProf = new TProfile(sHistName, title, - 10*fdSpillEvoLength, 0, fdSpillEvoLength); - -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - -/* - // Distribution of the TS_MSB per StsXyter - sHistName = "hHodoFebTsMsb"; - title = "Raw Timestamp Msb distribution per StsXyter; Ts MSB []; StsXyter []; Hits []"; - fhHodoFebTsMsb = new TH2I( sHistName, title, stsxyter::kuTsMsbNbTsBins, -0.5, stsxyter::kuTsMsbNbTsBins - 0.5, - fuNbStsXyters, -0.5, fuNbStsXyters - 0.5 ); - if( server ) server->Register("/StsRaw", fhHodoFebTsMsb ); -*/ - // Miscroslice properties histos - for( Int_t component = 0; component < kiMaxNbFlibLinks; component ++ ) - { - fhMsSz[ component ] = NULL; - fhMsSzTime[ component ] = NULL; - } // for( Int_t component = 0; component < kiMaxNbFlibLinks; component ++ ) - - // Online histo browser commands - THttpServer* server = FairRunOnline::Instance()->GetHttpServer(); - if( server ) - { - server->Register("/HodoRaw", fhHodoMessType ); - server->Register("/HodoRaw", fhHodoSysMessType ); - server->Register("/HodoRaw", fhHodoMessTypePerDpb ); - server->Register("/HodoRaw", fhHodoSysMessTypePerDpb ); - server->Register("/HodoRaw", fhHodoMessTypePerElink ); - server->Register("/HodoRaw", fhHodoSysMessTypePerElink ); - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - server->Register("/HodoRaw", fhHodoChanCntRaw[ uXyterIdx ] ); - server->Register("/HodoRaw", fhHodoChanAdcRaw[ uXyterIdx ] ); - server->Register("/HodoRaw", fhHodoChanAdcRawProf[ uXyterIdx ] ); - server->Register("/HodoRaw", fhHodoChanRawTs[ uXyterIdx ] ); - server->Register("/HodoRaw", fhHodoChanMissEvt[ uXyterIdx ] ); - server->Register("/HodoRaw", fhHodoChanMissEvtEvo[ uXyterIdx ] ); - server->Register("/HodoRaw", fhHodoFebMissEvtEvo[ uXyterIdx ] ); - server->Register("/HodoRaw", fhHodoChanHitRateEvo[ uXyterIdx ] ); - server->Register("/HodoRaw", fhHodoFebRateEvo[ uXyterIdx ] ); - server->Register("/HodoRaw", fhHodoChanHitRateEvoLong[ uXyterIdx ] ); - server->Register("/HodoRaw", fhHodoFebRateEvoLong[ uXyterIdx ] ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - server->Register("/Setup", fhSetupSortedDtX1Y1 ); - server->Register("/Setup", fhSetupSortedDtX2Y2 ); - server->Register("/Setup", fhSetupSortedDtN1P1 ); - server->Register("/Setup", fhSetupSortedDtN2P2 ); - server->Register("/Setup", fhSetupSortedDtX1Y1X2Y2 ); - server->Register("/Setup", fhSetupSortedDtX1Y1X2Y2N1P1 ); - server->Register("/Setup", fhSetupSortedDtX1Y1X2Y2N2P2 ); - server->Register("/Setup", fhSetupSortedDtH1H2S1S2 ); - server->Register("/Setup", fhSetupSortedMapX1Y1 ); - server->Register("/Setup", fhSetupSortedMapX2Y2 ); - server->Register("/Setup", fhSetupSortedMapN1P1 ); - server->Register("/Setup", fhSetupSortedMapN2P2 ); - server->Register("/Setup", fhSetupSortedCntEvoX1Y1 ); - server->Register("/Setup", fhSetupSortedCntEvoX2Y2 ); - server->Register("/Setup", fhSetupSortedCntEvoN1P1 ); - server->Register("/Setup", fhSetupSortedCntEvoN2P2 ); - - server->Register("/HodoBoth", fhBothHodoSortedDtX1Y1 ); - server->Register("/HodoBoth", fhBothHodoSortedDtX2Y2 ); - server->Register("/HodoBoth", fhBothHodoSortedDtX1Y1X2Y2N1P1 ); - server->Register("/HodoBoth", fhBothHodoSortedDtX1Y1X2Y2N2P2 ); - server->Register("/HodoBoth", fhBothHodoSortedMapX1Y1 ); - server->Register("/HodoBoth", fhBothHodoSortedMapX2Y2 ); - server->Register("/HodoBoth", fhBothHodoSortedCntEvoX1Y1 ); - server->Register("/HodoBoth", fhBothHodoSortedCntEvoX2Y2 ); - - server->Register("/H1H2S1", fhH1H2S1SortedDtX1Y1 ); - server->Register("/H1H2S1", fhH1H2S1SortedDtX2Y2 ); - server->Register("/H1H2S1", fhH1H2S1SortedDtN1P1 ); - server->Register("/H1H2S1", fhH1H2S1SortedDtN2P2 ); - server->Register("/H1H2S1", fhH1H2S1SortedMapX1Y1 ); - server->Register("/H1H2S1", fhH1H2S1SortedMapX2Y2 ); - server->Register("/H1H2S1", fhH1H2S1SortedMapN1P1 ); - server->Register("/H1H2S1", fhH1H2S1SortedMapN2P2 ); - server->Register("/H1H2S1", fhH1H2S1SortedCntEvoX1Y1 ); - server->Register("/H1H2S1", fhH1H2S1SortedCntEvoX2Y2 ); - server->Register("/H1H2S1", fhH1H2S1SortedCntEvoN1P1 ); - server->Register("/H1H2S1", fhH1H2S1SortedCntEvoN2P2 ); - - server->Register("/H1H2S2", fhH1H2S2SortedDtX1Y1 ); - server->Register("/H1H2S2", fhH1H2S2SortedDtX2Y2 ); - server->Register("/H1H2S2", fhH1H2S2SortedDtN1P1 ); - server->Register("/H1H2S2", fhH1H2S2SortedDtN2P2 ); - server->Register("/H1H2S2", fhH1H2S2SortedMapX1Y1 ); - server->Register("/H1H2S2", fhH1H2S2SortedMapX2Y2 ); - server->Register("/H1H2S2", fhH1H2S2SortedMapN1P1 ); - server->Register("/H1H2S2", fhH1H2S2SortedMapN2P2 ); - server->Register("/H1H2S2", fhH1H2S2SortedCntEvoX1Y1 ); - server->Register("/H1H2S2", fhH1H2S2SortedCntEvoX2Y2 ); - server->Register("/H1H2S2", fhH1H2S2SortedCntEvoN1P1 ); - server->Register("/H1H2S2", fhH1H2S2SortedCntEvoN2P2 ); - - server->Register("/Syst", fhSystSortedDtX1Y1 ); - server->Register("/Syst", fhSystSortedDtX2Y2 ); - server->Register("/Syst", fhSystSortedDtN1P1 ); - server->Register("/Syst", fhSystSortedDtN2P2 ); - server->Register("/Syst", fhSystSortedDtX1Y1X2Y2 ); - server->Register("/Syst", fhSystSortedMapX1Y1 ); - server->Register("/Syst", fhSystSortedMapX2Y2 ); - server->Register("/Syst", fhSystSortedMapN1P1 ); - server->Register("/Syst", fhSystSortedMapN2P2 ); - server->Register("/Syst", fhSystSortedCntEvoX1Y1 ); - server->Register("/Syst", fhSystSortedCntEvoX2Y2 ); - server->Register("/Syst", fhSystSortedCntEvoN1P1 ); - server->Register("/Syst", fhSystSortedCntEvoN2P2 ); - - server->Register("/Syst", fhSystSortedDtN1X1vsN1X2 ); - server->Register("/Syst", fhSystSortedDtP1X1vsP1X2 ); - server->Register("/Syst", fhSystSortedDtN1X1vsP1X1 ); - server->Register("/Syst", fhSystSortedDtSts1Hodo1vsSts1Hodo2 ); - server->Register("/Syst", fhSystSortedDtSts2Hodo1vsSts2Hodo2 ); - - server->Register("/Syst", fhSystSortedDtAllVsMapX1 ); - server->Register("/Syst", fhSystSortedDtAllVsMapY1 ); - server->Register("/Syst", fhSystSortedDtAllVsMapX2 ); - server->Register("/Syst", fhSystSortedDtAllVsMapY2 ); - - server->Register("/FebDt", fhSetupSortedDtX1 ); - server->Register("/FebDt", fhSetupSortedDtY1 ); - server->Register("/FebDt", fhSetupSortedDtX2 ); - server->Register("/FebDt", fhSetupSortedDtY2 ); - server->Register("/FebDt", fhSetupSortedDtN1 ); - server->Register("/FebDt", fhSetupSortedDtP1 ); - server->Register("/FebDt", fhSetupSortedDtN2 ); - server->Register("/FebDt", fhSetupSortedDtP2 ); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - server->Register("/FebDupli", fhSetupSortedNbSameTsChan[ uXyterIdx ] ); - server->Register("/FebDupli", fhSetupSortedSameTsAdcChan[ uXyterIdx ] ); - server->Register("/FebDupli", fhSetupSortedSameTsAdcDiff[ uXyterIdx ] ); - server->Register("/FebDupli", fhSetupSortedRatioSameTsChan[ uXyterIdx ] ); - server->Register("/FebDupli", fhSetupSortedNbConsSameTsChan[ uXyterIdx ] ); - server->Register("/FebDupli", fhSetupSortedNbConsSameTsAdcChan[ uXyterIdx ] ); - server->Register("/FebDupli", fhSetupSortedNbConsSameTsVsTsAdc[ uXyterIdx ] ); - - server->Register("/FebDupli", fhSetupSortedAsicRatioSameTsVsFlux[ uXyterIdx ] ); - server->Register("/FebDupli", fhSetupSortedAsicRatioSameTsAdcVsFlux[ uXyterIdx ] ); - server->Register("/FebDupli", fhSetupSortedAsicRatioSameAdcSameTsVsFlux[ uXyterIdx ] ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - - server->Register("/Spill", fhHodoX1SpillEvo ); - server->Register("/Spill", fhHodoY1SpillEvo ); - server->Register("/Spill", fhHodoX2SpillEvo ); - server->Register("/Spill", fhHodoY2SpillEvo ); - server->Register("/Spill", fhHodoX1SpillEvoProf ); - server->Register("/Spill", fhHodoY1SpillEvoProf ); - server->Register("/Spill", fhHodoX2SpillEvoProf ); - server->Register("/Spill", fhHodoY2SpillEvoProf ); - - server->RegisterCommand("/Reset_All_Hodo", "bCosy2018ResetSetupHistos_H=kTRUE"); - server->RegisterCommand("/Write_All_Hodo", "bCosy2018WriteSetupHistos_H=kTRUE"); - - server->Restrict("/Reset_All_Hodo", "allow=admin"); - server->Restrict("/Write_All_Hodo", "allow=admin"); - } // if( server ) - - /** Create summary Canvases for CERN 2017 **/ - Double_t w = 10; - Double_t h = 10; - - // Summary per StsXyter - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - TCanvas* cStsSumm = new TCanvas( Form("cStsSum_%03u", uXyterIdx ), - Form("Summary plots for StsXyter %03u", uXyterIdx ), - w, h); - cStsSumm->Divide( 2, 2 ); - - cStsSumm->cd(1); - gPad->SetLogy(); - fhHodoChanCntRaw[ uXyterIdx ]->Draw(); - - cStsSumm->cd(2); - gPad->SetLogz(); - fhHodoChanAdcRaw[ uXyterIdx ]->Draw( "colz" ); - - cStsSumm->cd(3); - gPad->SetLogz(); - fhHodoChanHitRateEvo[ uXyterIdx ]->Draw( "colz" ); - - cStsSumm->cd(4); -// gPad->SetLogy(); - fhHodoChanAdcRawProf[ uXyterIdx ]->Draw(); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - -//====================================================================// - -//====================================================================// - TCanvas* cSetupSortedDt = new TCanvas( "cSetupSortedDt", - "Hodoscopes coincidence maps", - w, h); - if( kTRUE == fbDualStsEna ) - cSetupSortedDt->Divide( 4, 3 ); - else cSetupSortedDt->Divide( 3, 3 ); - - cSetupSortedDt->cd(1); - gPad->SetGridx(); - gPad->SetLogy(); - fhSetupSortedDtX1Y1->Draw( "" ); - - cSetupSortedDt->cd(2); - gPad->SetGridx(); - gPad->SetLogy(); - fhSetupSortedDtX2Y2->Draw( "" ); - - cSetupSortedDt->cd(3); - gPad->SetGridx(); - gPad->SetLogy(); - fhSetupSortedDtN1P1->Draw( "" ); - - cSetupSortedDt->cd(4 + ( kTRUE == fbDualStsEna ? 1 : 0 ) ); - gPad->SetGridx(); - gPad->SetLogy(); - fhBothHodoSortedDtX1Y1->Draw( "" ); - - cSetupSortedDt->cd(5 + ( kTRUE == fbDualStsEna ? 1 : 0 ) ); - gPad->SetGridx(); - gPad->SetLogy(); - fhBothHodoSortedDtX2Y2->Draw( "" ); -/* - cSetupSortedDt->cd(6 + ( kTRUE == fbDualStsEna ? 1 : 0 ) ); - gPad->SetGridx(); - gPad->SetLogy(); - fhSetupSortedDtN1P1->Draw( "" ); -*/ - cSetupSortedDt->cd(7 + ( kTRUE == fbDualStsEna ? 2 : 0 ) ); - gPad->SetGridx(); - gPad->SetLogy(); - fhSystSortedDtX1Y1->Draw( "" ); - - cSetupSortedDt->cd(8 + ( kTRUE == fbDualStsEna ? 2 : 0 ) ); - gPad->SetGridx(); - gPad->SetLogy(); - fhSystSortedDtX2Y2->Draw( "" ); - - cSetupSortedDt->cd(9 + ( kTRUE == fbDualStsEna ? 2 : 0 ) ); - gPad->SetGridx(); - gPad->SetLogy(); - fhSystSortedDtN1P1->Draw( "" ); - - if( kTRUE == fbDualStsEna ) - { - cSetupSortedDt->cd(4); - gPad->SetGridx(); - gPad->SetLogy(); - fhSetupSortedDtN2P2->Draw( "colz" ); -/* - cSetupSortedDt->cd(8); - gPad->SetGridx(); - gPad->SetLogy(); - fhSetupSortedDtN2P2->Draw( "colz" ); -*/ - - cSetupSortedDt->cd(12); - gPad->SetGridx(); - gPad->SetLogy(); - fhSystSortedDtN2P2->Draw( "colz" ); - } // if( kTRUE == fbDualStsEna ) -//====================================================================// - -//====================================================================// - TCanvas* cSetupSortedMaps = new TCanvas( "cSetupSortedMaps", - "Hodoscopes coincidence maps", - w, h); - - if( kTRUE == fbDualStsEna ) - cSetupSortedMaps->Divide( 4, 3 ); - else cSetupSortedMaps->Divide( 3, 3 ); - - cSetupSortedMaps->cd(1); - gPad->SetLogz(); - fhSetupSortedMapX1Y1->Draw( "colz" ); - - cSetupSortedMaps->cd(2); - gPad->SetLogz(); - fhSetupSortedMapX2Y2->Draw( "colz" ); - - cSetupSortedMaps->cd(3); - gPad->SetLogz(); - fhSetupSortedMapN1P1->Draw( "colz" ); - - cSetupSortedMaps->cd(4 + ( kTRUE == fbDualStsEna ? 1 : 0 ) ); - gPad->SetLogz(); - fhBothHodoSortedMapX1Y1->Draw( "colz" ); - - cSetupSortedMaps->cd(5 + ( kTRUE == fbDualStsEna ? 1 : 0 ) ); - gPad->SetLogz(); - fhBothHodoSortedMapX2Y2->Draw( "colz" ); -/* - cSetupSortedMaps->cd(6 + ( kTRUE == fbDualStsEna ? 1 : 0 ) ); - gPad->SetLogz(); - fhBothHodoSortedMapN1P1->Draw( "colz" ); -*/ - cSetupSortedMaps->cd(7 + ( kTRUE == fbDualStsEna ? 2 : 0 ) ); - gPad->SetLogz(); - fhSystSortedMapX1Y1->Draw( "colz" ); - - cSetupSortedMaps->cd(8 + ( kTRUE == fbDualStsEna ? 2 : 0 ) ); - gPad->SetLogz(); - fhSystSortedMapX2Y2->Draw( "colz" ); - - cSetupSortedMaps->cd(9 + ( kTRUE == fbDualStsEna ? 2 : 0 ) ); - gPad->SetLogz(); - fhSystSortedMapN1P1->Draw( "colz" ); - - if( kTRUE == fbDualStsEna ) - { - cSetupSortedMaps->cd(4); - gPad->SetLogz(); - fhSetupSortedMapN2P2->Draw( "colz" ); -/* - cSetupSortedMaps->cd(8); - gPad->SetLogz(); - fhBothHodoSortedMapN2P2->Draw( "colz" ); -*/ - - cSetupSortedMaps->cd(12); - gPad->SetLogz(); - fhSystSortedMapN2P2->Draw( "colz" ); - } // if( kTRUE == fbDualStsEna ) -//====================================================================// - -//====================================================================// - TCanvas* cSetupSortedCoincEvo = new TCanvas( "cSetupSortedCoincEvo", - "Hodoscopes coincidence rate evolution", - w, h); - cSetupSortedCoincEvo->Divide( 3, 3 ); - - cSetupSortedCoincEvo->cd(1); - gPad->SetGridy(); - gPad->SetLogy(); - fhSetupSortedCntEvoX1Y1->Draw( "" ); - - cSetupSortedCoincEvo->cd(2); - gPad->SetGridy(); - gPad->SetLogy(); - fhSetupSortedCntEvoX2Y2->Draw( "" ); - - cSetupSortedCoincEvo->cd(3); - gPad->SetGridy(); - gPad->SetLogy(); - fhSetupSortedCntEvoN1P1->Draw( "" ); - - cSetupSortedCoincEvo->cd(4); - gPad->SetGridy(); - gPad->SetLogy(); - fhBothHodoSortedCntEvoX1Y1->Draw( "" ); - - cSetupSortedCoincEvo->cd(5); - gPad->SetGridy(); - gPad->SetLogy(); - fhBothHodoSortedCntEvoX2Y2->Draw( "" ); -/* - cSetupSortedCoincEvo->cd(6); - gPad->SetGridy(); - gPad->SetLogy(); - fhSetupSortedCntEvoN1P1->Draw( "" ); -*/ - cSetupSortedCoincEvo->cd(7); - gPad->SetGridy(); - gPad->SetLogy(); - fhSystSortedCntEvoX1Y1->Draw( "" ); - - cSetupSortedCoincEvo->cd(8); - gPad->SetGridy(); - gPad->SetLogy(); - fhSystSortedCntEvoX2Y2->Draw( "" ); - - cSetupSortedCoincEvo->cd(9); - gPad->SetGridy(); - gPad->SetLogy(); - fhSystSortedCntEvoN1P1->Draw( "" ); -//====================================================================// - -//====================================================================// - TCanvas* cSetupCoinQaDt = new TCanvas( "cSetupCoinQaDt", - "Hodoscopes coincidence quality", - w, h); - cSetupCoinQaDt->Divide( 2, 2 ); - - cSetupCoinQaDt->cd(1); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhSystSortedDtN1X1vsN1X2->Draw( "colz" ); - - cSetupCoinQaDt->cd(2); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhSystSortedDtP1X1vsP1X2->Draw( "colz" ); - - cSetupCoinQaDt->cd(3); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhSystSortedDtN1X1vsP1X1->Draw( "colz" ); - - cSetupCoinQaDt->cd(4); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhSystSortedDtSts1Hodo1vsSts1Hodo2->Draw( "colz" ); - -//====================================================================// - TCanvas* cSetupCoinQa = new TCanvas( "cSetupCoinQa", - "Hodoscopes coincidence quality", - w, h); - cSetupCoinQa->Divide( 2, 2 ); - - cSetupCoinQa->cd(1); - gPad->SetLogz(); - fhSystSortedDtAllVsMapX1->Draw( "colz" ); - - cSetupCoinQa->cd(2); - gPad->SetLogz(); - fhSystSortedDtAllVsMapY1->Draw( "colz" ); - - cSetupCoinQa->cd(3); - gPad->SetLogz(); - fhSystSortedDtAllVsMapX2->Draw( "colz" ); - - cSetupCoinQa->cd(4); - gPad->SetLogz(); - fhSystSortedDtAllVsMapY2->Draw( "colz" ); -//====================================================================// - -//====================================================================// - TCanvas* cFebDt = new TCanvas( "cFebDt", - "Hodoscopes coincidence quality", - w, h); - - if( kTRUE == fbDualStsEna ) - cFebDt->Divide( 2, 4 ); - else cFebDt->Divide( 2, 3 ); - - cFebDt->cd(1); - gPad->SetLogy(); - fhSetupSortedDtX1->Draw( "" ); - - cFebDt->cd(2); - gPad->SetLogy(); - fhSetupSortedDtY1->Draw( "" ); - - cFebDt->cd(3); - gPad->SetLogy(); - fhSetupSortedDtX2->Draw( "" ); - - cFebDt->cd(4); - gPad->SetLogy(); - fhSetupSortedDtY2->Draw( "" ); - - cFebDt->cd(5); - gPad->SetLogy(); - fhSetupSortedDtN1->Draw( "" ); - - cFebDt->cd(6); - gPad->SetLogy(); - fhSetupSortedDtP1->Draw( "" ); - - if( kTRUE == fbDualStsEna ) - { - cFebDt->cd(7); - gPad->SetLogy(); - fhSetupSortedDtN2->Draw( "" ); - - cFebDt->cd(8); - gPad->SetLogy(); - fhSetupSortedDtP2->Draw( "" ); - } // if( kTRUE == fbDualStsEna ) -//====================================================================// - -//====================================================================// - TCanvas* cFebSameTs = new TCanvas( "cFebSameTs", - "Hodoscopes coincidence quality", - w, h); - - cFebSameTs->Divide( 2, fuNbStsXyters/2 + fuNbStsXyters%2 ); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - cFebSameTs->cd(1 + uXyterIdx ); - gPad->SetLogz(); - fhSetupSortedNbSameTsChan[ uXyterIdx ]->Draw( "colz" ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) -//====================================================================// - -//====================================================================// - TCanvas* cFebSameTsAdc = new TCanvas( "cFebSameTsAdc", - "Hodoscopes coincidence quality", - w, h); - - cFebSameTsAdc->Divide( 2, fuNbStsXyters/2 + fuNbStsXyters%2 ); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - cFebSameTsAdc->cd(1 + uXyterIdx ); - gPad->SetLogz(); - fhSetupSortedSameTsAdcChan[ uXyterIdx ]->Draw( "colz" ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) -//====================================================================// - -//====================================================================// - TCanvas* cFebDupliVsChan = new TCanvas( "cFebDupliVsChan", - "Hodoscopes coincidence quality", - w, h); - - cFebDupliVsChan->Divide( fuNbStsXyters, 3 ); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - cFebDupliVsChan->cd( 1 + uXyterIdx ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhSetupSortedNbConsSameTsChan[ uXyterIdx ]->Draw( "colz" ); - - cFebDupliVsChan->cd( 1 + fuNbStsXyters +uXyterIdx ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhSetupSortedNbConsSameTsAdcChan[ uXyterIdx ]->Draw( "colz" ); - - cFebDupliVsChan->cd( 1 + 2*fuNbStsXyters + uXyterIdx ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhSetupSortedNbConsSameTsVsTsAdc[ uXyterIdx ]->Draw( "colz" ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) -//====================================================================// - -//====================================================================// - TCanvas* cFebDupliVsRate = new TCanvas( "cFebDupliVsRate", - "Hodoscopes coincidence quality", - w, h); - - cFebDupliVsRate->Divide( fuNbStsXyters, 3 ); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - cFebDupliVsRate->cd( 1 + uXyterIdx ); -// gPad->SetGridx(); -// gPad->SetGridy(); - gPad->SetLogx(); - gPad->SetLogz(); - fhSetupSortedAsicRatioSameTsVsFlux[ uXyterIdx ]->Draw( "colz" ); - - cFebDupliVsRate->cd( 1 + fuNbStsXyters + uXyterIdx ); -// gPad->SetGridx(); -// gPad->SetGridy(); - gPad->SetLogx(); - gPad->SetLogz(); - fhSetupSortedAsicRatioSameTsAdcVsFlux[ uXyterIdx ]->Draw( "colz" ); - - cFebDupliVsRate->cd( 1 + 2*fuNbStsXyters + uXyterIdx ); -// gPad->SetGridx(); -// gPad->SetGridy(); - gPad->SetLogx(); - gPad->SetLogz(); - fhSetupSortedAsicRatioSameAdcSameTsVsFlux[ uXyterIdx ]->Draw( "colz" ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) -//====================================================================// - - // Long duration rate monitoring -/* - if( kTRUE == fbLongHistoEnable ) - { - TCanvas* cStsLongRate = new TCanvas( "cStsLongRate" , "Long duration rate plots for StsXyter", - w, h); - cStsLongRate->Divide( 2, fuNbStsXyters ); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - cStsLongRate->cd( 1 + 2 * uXyterIdx ); - gPad->SetLogy(); - gPad->SetGridx(); - gPad->SetGridy(); - fhFebRateEvoLong[ uXyterIdx ]->Draw( "hist" ); - - cStsLongRate->cd( 2 + 2 * uXyterIdx ); - gPad->SetLogz(); - gPad->SetGridx(); - gPad->SetGridy(); - fhFebChRateEvoLong[ uXyterIdx ]->Draw( "colz" ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - } // if( kTRUE == fbLongHistoEnable ) -*/ -/* - Int_t iNbPadsPerDpb = fuNbElinksPerDpb/2 + fuNbElinksPerDpb%2; - TCanvas* cMuchChCounts = new TCanvas("cMuchChCounts", "MUCH Channels counts", w, h); - cMuchChCounts->Divide( fNrOfNdpbs/2 + fNrOfNdpbs%2, fNrOfFebsPerNdpb ); - - TCanvas* cMuchFebRate = new TCanvas("cMuchFebRate", "MUCH FEB rate", w, h); - cMuchFebRate->Divide( fNrOfNdpbs/2 + fNrOfNdpbs%2, fNrOfFebsPerNdpb ); - - TH1* histPnt = NULL; - for( Int_t dpbId = 0; dpbId < fNrOfNdpbs; dpbId++) - {// looping on all the nDPBS IDs - if( dpbId < fUnpackParHodo->GetNrOfnDpbsModA() ) - { - sNdpbTag = Form("%04X", fUnpackParHodo->GetNdpbIdA(dpbId) ); - } // if( dpbId < fUnpackParHodo->GetNrOfnDpbsModA() ) - else - { - sNdpbTag = Form("%04X", fUnpackParHodo->GetNdpbIdB(dpbId - fNrOfNdpbsA) ); - } // else of if( dpbId < fUnpackParHodo->GetNrOfnDpbsModA() ) - - for( Int_t febId = 0; febId < fNrOfFebsPerNdpb; febId++) - {// looping on all the FEB IDs - cMuchChCounts->cd( 1 + dpbId * iNbPadsPerDpb + febId/2 ); - gPad->SetLogy(); - sHistName = Form("Chan_Counts_Much_n%s_f%1u", sNdpbTag.Data(), febId); - histPnt = fHM->H1(sHistName.Data()); - - if( 0 == febId%2 ) - { - histPnt->SetLineColor( kRed ); // => Change color for 1st of the 2/pad! - histPnt->Draw(); - } // if( 0 == febId%2 ) - else - { - histPnt->SetLineColor( kBlue ); // => Change color for 1nd of the 2/pad! - histPnt->Draw("same"); - } // if( 0 == febId%2 ) - - cMuchFebRate->cd( 1 + dpbId * iNbPadsPerDpb + febId/2 ); - gPad->SetLogy(); - sHistName = Form("FebRate_n%s_f%1u", sNdpbTag.Data(), febId); - histPnt = fHM->H1(sHistName.Data()); - - if( 0 == febId%2 ) - { - histPnt->SetLineColor( kRed ); // => Change color for 1st of the 2/pad! - histPnt->Draw(); - } // if( 0 == febId%2 ) - else - { - histPnt->SetLineColor( kBlue ); // => Change color for 1nd of the 2/pad! - histPnt->Draw("same"); - } // if( 0 == febId%2 ) - } // for( Int_t febId = 0; febId < fNrOfFebsPerNdpb; febId++) - } // for( Int_t dpbId = 0; dpbId < fNrOfNdpbs; dpbId++) -*/ - - /** Recovers/Create Ms Size Canvase for CERN 2016 **/ - // Try to recover canvas in case it was created already by another monitor - // If not existing, create it - fcMsSizeAll = dynamic_cast<TCanvas *>( gROOT->FindObject( "cMsSizeAll" ) ); - if( NULL == fcMsSizeAll ) - { - fcMsSizeAll = new TCanvas("cMsSizeAll", "Evolution of MS size in last 300 s", w, h); - fcMsSizeAll->Divide( 4, 4 ); - LOG(info) << "Created MS size canvas in STS monitor"; - } // if( NULL == fcMsSizeAll ) - else LOG(info) << "Recovered MS size canvas in STS monitor"; - - /*****************************/ -} - -Bool_t CbmCosy2018MonitorSetup::DoUnpack(const fles::Timeslice& ts, size_t component) -{ - THttpServer* server = FairRunOnline::Instance()->GetHttpServer(); - - if( bCosy2018ResetSetupHistos_H ) - { - ResetAllHistos(); - bCosy2018ResetSetupHistos_H = kFALSE; - } // if( bCosy2018ResetSetupHistos_H ) - if( bCosy2018WriteSetupHistos_H ) - { - SaveAllHistos( fsHistoFileFullname ); - bCosy2018WriteSetupHistos_H = kFALSE; - } // if( bCosy2018WriteSetupHistos_H ) - - LOG(debug) << "Timeslice contains " << ts.num_microslices(component) - << "microslices."; - - if( component < kiMaxNbFlibLinks ) - if( NULL == fhMsSz[ component ] ) - { - TString sMsSzName = Form("MsSz_link_%02lu", component); - TString sMsSzTitle = Form("Size of MS for nDPB of link %02lu; Ms Size [bytes]", component); - fhMsSz[ component ] = new TH1F( sMsSzName.Data(), sMsSzTitle.Data(), 160000, 0., 20000. ); - fHM->Add(sMsSzName.Data(), fhMsSz[ component ] ); - if (server) server->Register("/FlibRaw", fhMsSz[ component ] ); - sMsSzName = Form("MsSzTime_link_%02lu", component); - sMsSzTitle = Form("Size of MS vs time for gDPB of link %02lu; Time[s] ; Ms Size [bytes]", component); - fhMsSzTime[ component ] = new TProfile( sMsSzName.Data(), sMsSzTitle.Data(), 15000, 0., 300. ); - fHM->Add( sMsSzName.Data(), fhMsSzTime[ component ] ); - if (server) server->Register("/FlibRaw", fhMsSzTime[ component ] ); - if( NULL != fcMsSizeAll ) - { - fcMsSizeAll->cd( 1 + component ); - gPad->SetLogy(); - fhMsSzTime[ component ]->Draw("hist le0"); - } // if( NULL != fcMsSizeAll ) - LOG(info) << "Added MS size histo for component: " << component - << " (DPB)"; - } // if( NULL == fhMsSz[ component ] ) - -// Int_t messageType = -111; - // Loop over microslices - size_t numCompMsInTs = ts.num_microslices(component); -/* - if( fulCurrentTsIdx + 1 != ts.index() && 0 == component) - LOG(info) << "Missed TS from " << fulCurrentTsIdx - << " to " << ts.index(); -*/ - fulCurrentTsIdx = ts.index(); - - if( fuMaxNbMicroslices < numCompMsInTs ) - { - fuMaxNbMicroslices = numCompMsInTs; - - fvdMsTime.resize( fuMaxNbMicroslices ); - fvuChanNbHitsInMs.resize( fuNbStsXyters ); - fvdChanLastHitTimeInMs.resize( fuNbStsXyters ); - fvusChanLastHitAdcInMs.resize( fuNbStsXyters ); - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fvuChanNbHitsInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvdChanLastHitTimeInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvusChanLastHitAdcInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - { - fvuChanNbHitsInMs[ uXyterIdx ][ uChan ].resize( fuMaxNbMicroslices ); - fvdChanLastHitTimeInMs[ uXyterIdx ][ uChan ].resize( fuMaxNbMicroslices ); - fvusChanLastHitAdcInMs[ uXyterIdx ][ uChan ].resize( fuMaxNbMicroslices ); - for( UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx ) - { - fvuChanNbHitsInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = 0; - fvdChanLastHitTimeInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = -1.0; - fvusChanLastHitAdcInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = 0; - } // for( UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx ) - } // for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - LOG(info) << "CbmCosy2018MonitorSetup::DoUnpack => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs.size() << " VS " << fuNbStsXyters; - LOG(info) << "CbmCosy2018MonitorSetup::DoUnpack => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs[ 0 ].size() << " VS " << fuNbChanPerAsic; - LOG(info) << "CbmCosy2018MonitorSetup::DoUnpack => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs[ 0 ][ 0 ].size() << " VS " << fuMaxNbMicroslices; - } // if( fuMaxNbMicroslices < numCompMsInTs ) - - for( size_t m = 0; m < numCompMsInTs; ++m ) - { - // Ignore overlap ms if number defined by user - if( numCompMsInTs - fuOverlapMsNb <= m ) - continue; - - auto msDescriptor = ts.descriptor(component, m); - fuCurrentEquipmentId = msDescriptor.eq_id; - const uint8_t* msContent = reinterpret_cast<const uint8_t*>(ts.content(component, m)); - - uint32_t size = msDescriptor.size; - fulCurrentMsIdx = msDescriptor.idx; - Double_t dMsTime = (1e-9) * static_cast<double>(fulCurrentMsIdx); - LOG(debug) << "Microslice: " << fulCurrentMsIdx - << " from EqId " << std::hex << fuCurrentEquipmentId << std::dec - << " has size: " << size; - - fuCurrDpbId = static_cast< uint32_t >( fuCurrentEquipmentId & 0xFFFF ); - fuCurrDpbIdx = fDpbIdIndexMap[ fuCurrDpbId ]; - - if( component < kiMaxNbFlibLinks ) - { - if( fdStartTimeMsSz < 0 ) - fdStartTimeMsSz = dMsTime; - fhMsSz[ component ]->Fill( size ); - fhMsSzTime[ component ]->Fill( dMsTime - fdStartTimeMsSz, size); - } // if( component < kiMaxNbFlibLinks ) - - // Store MS time for coincidence plots - fvdMsTime[ m ] = dMsTime; - - // If not integer number of message in input buffer, print warning/error - if( 0 != (size % kuBytesPerMessage) ) - LOG(error) << "The input microslice buffer does NOT " - << "contain only complete nDPB messages!"; - - // Compute the number of complete messages in the input microslice buffer - uint32_t uNbMessages = (size - (size % kuBytesPerMessage) ) - / kuBytesPerMessage; - - // Prepare variables for the loop on contents - const uint32_t* pInBuff = reinterpret_cast<const uint32_t*>( msContent ); - - for( uint32_t uIdx = 0; uIdx < uNbMessages; ++uIdx ) - { - // Fill message - uint32_t ulData = static_cast<uint32_t>(pInBuff[uIdx]); - - stsxyter::Message mess( static_cast< uint32_t >( ulData & 0xFFFFFFFF ) ); - - // Print message if requested - if( fbPrintMessages ) - mess.PrintMess( std::cout, fPrintMessCtrl ); - - stsxyter::MessType typeMess = mess.GetMessType(); - fmMsgCounter[ typeMess ] ++; - fhHodoMessType->Fill( static_cast< uint16_t > (typeMess) ); - fhHodoMessTypePerDpb->Fill( fuCurrDpbIdx, static_cast< uint16_t > (typeMess) ); - - switch( typeMess ) - { - case stsxyter::MessType::Hit : - { - // Extract the eLink and Asic indices => Should GO IN the fill method now that obly hits are link/asic specific! - UShort_t usElinkIdx = mess.GetLinkIndex(); - if( fuNbElinksPerDpb <= usElinkIdx ) - { - LOG(fatal) << "CbmCosy2018MonitorSetup::DoUnpack => " - << "eLink index out of bounds!" - << usElinkIdx << " VS " << fuNbElinksPerDpb; - } // if( fuNbElinksPerDpb <= usElinkIdx ) - fhHodoMessTypePerElink->Fill( fuCurrDpbIdx * fuNbElinksPerDpb + usElinkIdx, - static_cast< uint16_t > (typeMess) ); - - UInt_t uAsicIdx = fvuElinkToAsic[fuCurrDpbIdx][usElinkIdx]; - - FillHitInfo( mess, usElinkIdx, uAsicIdx, m ); - break; - } // case stsxyter::MessType::Hit : - case stsxyter::MessType::TsMsb : - { - FillTsMsbInfo( mess, uIdx, m ); - break; - } // case stsxyter::MessType::TsMsb : - case stsxyter::MessType::Epoch : - { - // The first message in the TS is a special ones: EPOCH - FillEpochInfo( mess ); - - if( 0 < uIdx ) - LOG(info) << "CbmCosy2018MonitorSetup::DoUnpack => " - << "EPOCH message at unexpected position in MS: message " - << uIdx << " VS message 0 expected!"; - break; - } // case stsxyter::MessType::TsMsb : - case stsxyter::MessType::Empty : - { -// FillTsMsbInfo( mess ); - break; - } // case stsxyter::MessType::Empty : - case stsxyter::MessType::Dummy : - { - break; - } // case stsxyter::MessType::Dummy / ReadDataAck / Ack : - default: - { - LOG(fatal) << "CbmCosy2018MonitorSetup::DoUnpack => " - << "Unknown message type, should never happen, stopping here!"; - } - } // switch( mess.GetMessType() ) - } // for( uint32_t uIdx = 0; uIdx < uNbMessages; ++uIdx ) - - // Sort the buffer of hits - std::sort( fvmHitsInTs.begin(), fvmHitsInTs.end() ); - - // Time differences plotting using the fully time sorted hits - Double_t dLastTimeX1 = -1e12; - Double_t dLastTimeY1 = -1e12; - Double_t dLastTimeX2 = -1e12; - Double_t dLastTimeY2 = -1e12; - Double_t dLastTimeN1 = -1e12; - Double_t dLastTimeP1 = -1e12; - Double_t dLastTimeN2 = -1e12; - Double_t dLastTimeP2 = -1e12; - Double_t dDtX1Y1 = -1e12; - Double_t dDtX2Y2 = -1e12; - Double_t dDtN1P1 = -1e12; - Double_t dDtN2P2 = -1e12; - Double_t dDtX1Y1X2Y2 = -1e12; - Double_t dDtN1P1N2P2 = -1e12; - Double_t dDtX1Y1X2Y2N1P1 = -1e12; - Double_t dDtX1Y1X2Y2N2P2 = -1e12; - Double_t dDtH1H2S1S2 = -1e12; - if( 0 < fvmHitsInTs.size() ) - { - ULong64_t ulLastHitTime = ( *( fvmHitsInTs.rbegin() ) ).GetTs(); - std::vector< stsxyter::FinalHit >::iterator it; - -// std::chrono::steady_clock::time_point tNow = std::chrono::steady_clock::now(); -// Double_t dUnixTimeInRun = std::chrono::duration_cast< std::chrono::seconds >(tNow - ftStartTimeUnix).count(); - - for( it = fvmHitsInTs.begin(); - it != fvmHitsInTs.end() && (*it).GetTs() < ulLastHitTime - 320; // 32 * 3.125 ns = 1000 ns - ++it ) - { - UShort_t usAsicIdx = (*it).GetAsic(); - UShort_t usChanIdx = (*it).GetChan(); - ULong64_t ulHitTs = (*it).GetTs(); - UShort_t usHitAdc = (*it).GetAdc(); - - Bool_t bHitInX = usChanIdx < fuNbChanPerAsic/2; - - Double_t dTimeSinceStartSec = (ulHitTs * stsxyter::kdClockCycleNs - fdStartTime)* 1e-9; -// Bool_t bDuplicateHit = kFALSE; - if( 0 == ulHitTs - fvulTimeLastHitAsicChan[ usAsicIdx ][ usChanIdx ] ) - { -// bDuplicateHit = kTRUE; - if( 0 == fviAdcLastHitAsicChan[ usAsicIdx ][ usChanIdx ] - usHitAdc ) - { - fvuNbSameFullHitAsicChan[ usAsicIdx ][ usChanIdx ] ++; - fvuNbHitSameTsAdcAsicLastS[ usAsicIdx ] ++; - } // if( 0 == fviAdcLastHitAsicChan[ usAsicIdx ][ usChanIdx ] - usHitAdc ) - else - { - fhSetupSortedNbConsSameTsAdcChan[ usAsicIdx ]->Fill( usChanIdx, fvuNbSameFullHitAsicChan[ usAsicIdx ][ usChanIdx ] ); - fhSetupSortedNbConsSameTsVsTsAdc[ usAsicIdx ]->Fill( fvuNbSameHitAsicChan[ usAsicIdx ][ usChanIdx ], - fvuNbSameFullHitAsicChan[ usAsicIdx ][ usChanIdx ] ); - fvuNbSameFullHitAsicChan[ usAsicIdx ][ usChanIdx ] = 0; - } // else of if( 0 == fviAdcLastHitAsicChan[ usAsicIdx ][ usChanIdx ] - usHitAdc ) - - fvuNbSameHitAsicChan[ usAsicIdx ][ usChanIdx ] ++; - fvuNbHitSameTsAsicLastS[ usAsicIdx ] ++; -/* - LOG(info) << Form("Bad Hit on asic %u chan %3u, #%3u => TS %9llu ADC %2u VS TS %9llu ADC %2u", - usAsicIdx, usChanIdx, fvuNbSameHitAsicChan[ usAsicIdx ][ usChanIdx ], - ulHitTs, usHitAdc, - fvulTimeLastHitAsicChan[ usAsicIdx ][ usChanIdx ], - fviAdcLastHitAsicChan[ usAsicIdx ][ usChanIdx ] ); -*/ - fhSetupSortedNbSameTsChan[ usAsicIdx ]->Fill( dTimeSinceStartSec, usChanIdx ); - fhSetupSortedSameTsAdcChan[ usAsicIdx ]->Fill( usChanIdx, usHitAdc ); - fhSetupSortedSameTsAdcChan[ usAsicIdx ]->Fill( usChanIdx, fviAdcLastHitAsicChan[ usAsicIdx ][ usChanIdx ] ); - fhSetupSortedSameTsAdcDiff[ usAsicIdx ]->Fill( fvuNbSameHitAsicChan[ usAsicIdx ][ usChanIdx ], - static_cast< Int_t >( usHitAdc ) - - fviAdcLastHitAsicChan[ usAsicIdx ][ usChanIdx ] ); - fhSetupSortedRatioSameTsChan[ usAsicIdx ]->Fill( dTimeSinceStartSec, usChanIdx, 1.0 ); - } // if( 0 == ulHitTs - fvulTimeLastHitAsicChan[ usAsicIdx ][ usChanIdx ] ) - else - { -/* - if( 100 < fvuNbSameHitAsicChan[ usAsicIdx ][ usChanIdx ] ) - LOG(fatal) << " More than 100 consecutive hits with same TS on asic" - << usAsicIdx << " chan " << usChanIdx - << " => " << fvuNbSameHitAsicChan[ usAsicIdx ][ usChanIdx ]; -*/ - fhSetupSortedNbConsSameTsVsTsAdc[ usAsicIdx ]->Fill( fvuNbSameHitAsicChan[ usAsicIdx ][ usChanIdx ], - fvuNbSameFullHitAsicChan[ usAsicIdx ][ usChanIdx ] ); - - fhSetupSortedNbConsSameTsChan[ usAsicIdx ]->Fill( usChanIdx, fvuNbSameHitAsicChan[ usAsicIdx ][ usChanIdx ] ); - fvuNbSameHitAsicChan[ usAsicIdx ][ usChanIdx ] = 0; - - fhSetupSortedNbConsSameTsAdcChan[ usAsicIdx ]->Fill( usChanIdx, fvuNbSameFullHitAsicChan[ usAsicIdx ][ usChanIdx ] ); - fvuNbSameFullHitAsicChan[ usAsicIdx ][ usChanIdx ] = 0; - - fhSetupSortedRatioSameTsChan[ usAsicIdx ]->Fill( dTimeSinceStartSec, usChanIdx, 0.0 ); - - fvuNbHitDiffTsAsicLastS[ usAsicIdx ]++; - } // else of if( 0 == ulHitTs - fvulTimeLastHitAsicChan[ usAsicIdx ][ usChanIdx ] ) - fvulTimeLastHitAsicChan[ usAsicIdx ][ usChanIdx ] = ulHitTs; - fviAdcLastHitAsicChan[ usAsicIdx ][ usChanIdx ] = usHitAdc; - - if( fUnpackParHodo->GetAsicIndexHodo1() == usAsicIdx ) - { - if( fUnpackParHodo->IsXySwappedHodo1() ) - bHitInX = !bHitInX; - - if( bHitInX ) - { - Double_t dDtSameFeb = ( ulHitTs - dLastTimeX1 ) * stsxyter::kdClockCycleNs; - fhSetupSortedDtX1->Fill( dDtSameFeb ); - - fLastSortedHit1X = (*it); - dLastTimeX1 = ulHitTs; - - /// Compute fiber Idx of the last Hodo hits - UInt_t uFiberIdxX1 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit1X.GetChan() ); - if( fUnpackParHodo->IsXInvertedHodo1() ) - uFiberIdxX1 = fuNbChanPerAsic/2 - 1 - uFiberIdxX1; - UInt_t uFiberIdxY1 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit1Y.GetChan() ); - if( fUnpackParHodo->IsYInvertedHodo1() ) - uFiberIdxY1 = fuNbChanPerAsic/2 - 1 - uFiberIdxY1; - UInt_t uFiberIdxX2 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit2X.GetChan() ); - if( fUnpackParHodo->IsXInvertedHodo2() ) - uFiberIdxX2 = fuNbChanPerAsic/2 - 1 - uFiberIdxX2; - UInt_t uFiberIdxY2 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit2Y.GetChan() ); - if( fUnpackParHodo->IsYInvertedHodo2() ) - uFiberIdxY2 = fuNbChanPerAsic/2 - 1 - uFiberIdxY2; - - if( dTimeSinceStartSec < fdSpillEvoLength ) - { - fhHodoX1SpillEvo->Fill( dTimeSinceStartSec, uFiberIdxX1 ); - fhHodoX1SpillEvoProf->Fill( dTimeSinceStartSec, uFiberIdxX1 ); - } // if( dTimeSinceStartSec < fdSpillEvoLength ) - - dDtX1Y1 = ( dLastTimeY1 - dLastTimeX1 ) * stsxyter::kdClockCycleNs; - dDtX2Y2 = ( dLastTimeY2 - dLastTimeX2 ) * stsxyter::kdClockCycleNs; - dDtN1P1 = ( dLastTimeP1 - dLastTimeN1 ) * stsxyter::kdClockCycleNs; - dDtX1Y1X2Y2 = ( ( dLastTimeX2 + dLastTimeY2 ) - ( dLastTimeX1 + dLastTimeY1 ) ) - * stsxyter::kdClockCycleNs / 2.0; - dDtX1Y1X2Y2N1P1 = ( ( dLastTimeN1 + dLastTimeP1 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) / 4.0 - ) * stsxyter::kdClockCycleNs; - if( kTRUE == fbDualStsEna ) - { - dDtN2P2 = ( dLastTimeP2 - dLastTimeN2 ) * stsxyter::kdClockCycleNs; - dDtN1P1N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) - ( dLastTimeN1 + dLastTimeP1 ) ) - * stsxyter::kdClockCycleNs / 2.0; - dDtX1Y1X2Y2N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) / 4.0 - ) * stsxyter::kdClockCycleNs; - dDtH1H2S1S2 = ( ( dLastTimeN2 + dLastTimeP2 + dLastTimeN1 + dLastTimeP1 ) - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) - ) * stsxyter::kdClockCycleNs / 4.0; - } // if( kTRUE == fbDualStsEna ) - - fhSetupSortedDtX1Y1->Fill( dDtX1Y1 ); - fhSetupSortedDtX1Y1X2Y2->Fill( dDtX1Y1X2Y2 ); - fhSetupSortedDtX1Y1X2Y2N1P1->Fill( dDtX1Y1X2Y2N1P1 ); - if( kTRUE == fbDualStsEna ) - { - fhSetupSortedDtX1Y1X2Y2N2P2->Fill( dDtX1Y1X2Y2N2P2 ); - fhSetupSortedDtH1H2S1S2->Fill( dDtH1H2S1S2 ); - } // if( kTRUE == fbDualStsEna ) - - if( TMath::Abs( dDtX1Y1 ) < fdCoincBorderHodo ) - { - fhSetupSortedMapX1Y1->Fill( uFiberIdxX1, uFiberIdxY1 ); - fhSetupSortedCntEvoX1Y1->Fill( dTimeSinceStartSec ); - } // if( TMath::Abs( dDtX1Y1 ) < fdCoincBorderHodo ) - - if( TMath::Abs( dDtX1Y1 ) < fdCoincBorderHodo && - TMath::Abs( dDtX2Y2 ) < fdCoincBorderHodo && - TMath::Abs( dDtX1Y1X2Y2 ) < 2 * fdCoincBorderHodo ) - { - fhBothHodoSortedDtX1Y1->Fill( dDtX1Y1 ); - fhBothHodoSortedDtX2Y2->Fill( dDtX2Y2 ); - fhBothHodoSortedDtX1Y1X2Y2N1P1->Fill( dDtX1Y1X2Y2N1P1 ); - fhBothHodoSortedDtX1Y1X2Y2N2P2->Fill( dDtX1Y1X2Y2N2P2 ); - - fhBothHodoSortedMapX1Y1->Fill( uFiberIdxX1, uFiberIdxY1 ); - fhBothHodoSortedMapX2Y2->Fill( uFiberIdxX2, uFiberIdxY2 ); - fhBothHodoSortedCntEvoX1Y1->Fill( dTimeSinceStartSec ); - } // if( TMath::Abs( dDtX1Y1X2Y2 ) < 2 * fdCoincBorderHodo ) - - if( TMath::Abs( dDtX1Y1 ) < fdCoincBorderHodo && - TMath::Abs( dDtX2Y2 ) < fdCoincBorderHodo && - TMath::Abs( dDtN1P1 ) < fdCoincBorderSts && - TMath::Abs( dDtN2P2 ) < fdCoincBorderSts && - TMath::Abs( dDtX1Y1X2Y2 ) < 2 * fdCoincBorderHodo && - TMath::Abs( dDtN1P1N2P2 ) < 2 * fdCoincBorderSts && - TMath::Abs( dDtX1Y1X2Y2N1P1 ) < fdCoincBorder && - TMath::Abs( dDtX1Y1X2Y2N2P2 ) < fdCoincBorder && - TMath::Abs( dDtH1H2S1S2 ) < fdCoincBorder ) - { - fhSystSortedDtX1Y1->Fill( dDtX1Y1 ); - fhSystSortedDtX2Y2->Fill( dDtX2Y2 ); - fhSystSortedDtN1P1->Fill( dDtN1P1 ); - fhSystSortedDtN2P2->Fill( dDtN2P2 ); - fhSystSortedDtX1Y1X2Y2->Fill( dDtX1Y1X2Y2 ); - - fhSystSortedMapX1Y1->Fill( uFiberIdxX1, uFiberIdxY1 ); - fhSystSortedMapX2Y2->Fill( uFiberIdxX2, uFiberIdxY2 ); - fhSystSortedMapN1P1->Fill( fLastSortedHit1N.GetChan(), fLastSortedHit1P.GetChan() ); - fhSystSortedMapN2P2->Fill( fLastSortedHit2N.GetChan(), fLastSortedHit2P.GetChan() ); - fhSystSortedCntEvoX1Y1->Fill( dTimeSinceStartSec ); - fhSystSortedDtAllVsMapX1->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxX1 ); - fhSystSortedDtAllVsMapY1->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxY1 ); - fhSystSortedDtAllVsMapX2->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxX2 ); - fhSystSortedDtAllVsMapY2->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxY2 ); - - Double_t dDtN1X1 = ( dLastTimeN1 - dLastTimeX1 ) * stsxyter::kdClockCycleNs; - Double_t dDtN1X2 = ( dLastTimeN1 - dLastTimeX2 ) * stsxyter::kdClockCycleNs; - Double_t dDtP1X1 = ( dLastTimeP1 - dLastTimeX1 ) * stsxyter::kdClockCycleNs; - Double_t dDtP1X2 = ( dLastTimeP1 - dLastTimeX2 ) * stsxyter::kdClockCycleNs; - fhSystSortedDtN1X1vsN1X2->Fill( dDtN1X1, dDtN1X2 ); - fhSystSortedDtP1X1vsP1X2->Fill( dDtP1X1, dDtP1X2 ); - fhSystSortedDtN1X1vsP1X1->Fill( dDtN1X1, dDtP1X1 ); - - Double_t dDtX1Y1N1P1 = ( ( dLastTimeN1 + dLastTimeP1 ) / 2.0 - - ( dLastTimeX1 + dLastTimeY1 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - Double_t dDtX2Y2N1P1 = ( ( dLastTimeN1 + dLastTimeP1 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - fhSystSortedDtSts1Hodo1vsSts1Hodo2->Fill( dDtX1Y1N1P1, dDtX2Y2N1P1 ); - - Double_t dDtX1Y1N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) / 2.0 - - ( dLastTimeX1 + dLastTimeY1 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - Double_t dDtX2Y2N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - fhSystSortedDtSts2Hodo1vsSts2Hodo2->Fill( dDtX1Y1N2P2, dDtX2Y2N2P2 ); - } // if( TMath::Abs( dDtX1Y1X2Y2N1P1 ) < fdCoincBorder ) - } // if( bHitInX ) - else - { - Double_t dDtSameFeb = ( ulHitTs - dLastTimeY1 ) * stsxyter::kdClockCycleNs; - fhSetupSortedDtY1->Fill( dDtSameFeb ); - - fLastSortedHit1Y = (*it); - dLastTimeY1 = ulHitTs; - - /// Compute fiber Idx of the last Hodo hits - UInt_t uFiberIdxX1 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit1X.GetChan() ); - if( fUnpackParHodo->IsXInvertedHodo1() ) - uFiberIdxX1 = fuNbChanPerAsic/2 - 1 - uFiberIdxX1; - UInt_t uFiberIdxY1 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit1Y.GetChan() ); - if( fUnpackParHodo->IsYInvertedHodo1() ) - uFiberIdxY1 = fuNbChanPerAsic/2 - 1 - uFiberIdxY1; - UInt_t uFiberIdxX2 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit2X.GetChan() ); - if( fUnpackParHodo->IsXInvertedHodo2() ) - uFiberIdxX2 = fuNbChanPerAsic/2 - 1 - uFiberIdxX2; - UInt_t uFiberIdxY2 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit2Y.GetChan() ); - if( fUnpackParHodo->IsYInvertedHodo2() ) - uFiberIdxY2 = fuNbChanPerAsic/2 - 1 - uFiberIdxY2; - - if( dTimeSinceStartSec < fdSpillEvoLength ) - { - fhHodoY1SpillEvo->Fill( dTimeSinceStartSec, uFiberIdxY1 ); - fhHodoY1SpillEvoProf->Fill( dTimeSinceStartSec, uFiberIdxY1 ); - } // if( dTimeSinceStartSec < fdSpillEvoLength ) - - dDtX1Y1 = ( dLastTimeY1 - dLastTimeX1 ) * stsxyter::kdClockCycleNs; - dDtX2Y2 = ( dLastTimeY2 - dLastTimeX2 ) * stsxyter::kdClockCycleNs; - dDtN1P1 = ( dLastTimeP1 - dLastTimeN1 ) * stsxyter::kdClockCycleNs; - dDtX1Y1X2Y2 = ( ( dLastTimeX2 + dLastTimeY2 ) - ( dLastTimeX1 + dLastTimeY1 ) ) - * stsxyter::kdClockCycleNs / 2.0; - dDtX1Y1X2Y2N1P1 = ( ( dLastTimeN1 + dLastTimeP1 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) / 4.0 - ) * stsxyter::kdClockCycleNs; - if( kTRUE == fbDualStsEna ) - { - dDtN2P2 = ( dLastTimeP2 - dLastTimeN2 ) * stsxyter::kdClockCycleNs; - dDtN1P1N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) - ( dLastTimeN1 + dLastTimeP1 ) ) - * stsxyter::kdClockCycleNs / 2.0; - dDtX1Y1X2Y2N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) / 4.0 - ) * stsxyter::kdClockCycleNs; - dDtH1H2S1S2 = ( ( dLastTimeN2 + dLastTimeP2 + dLastTimeN1 + dLastTimeP1 ) - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) - ) * stsxyter::kdClockCycleNs / 4.0; - } // if( kTRUE == fbDualStsEna ) - - fhSetupSortedDtX1Y1->Fill( dDtX1Y1 ); - fhSetupSortedDtX1Y1X2Y2->Fill( dDtX1Y1X2Y2 ); - fhSetupSortedDtX1Y1X2Y2N1P1->Fill( dDtX1Y1X2Y2N1P1 ); - if( kTRUE == fbDualStsEna ) - { - fhSetupSortedDtX1Y1X2Y2N2P2->Fill( dDtX1Y1X2Y2N2P2 ); - fhSetupSortedDtH1H2S1S2->Fill( dDtH1H2S1S2 ); - } // if( kTRUE == fbDualStsEna ) - - if( TMath::Abs( dDtX1Y1 ) < fdCoincBorderHodo ) - { - fhSetupSortedMapX1Y1->Fill( uFiberIdxX1, uFiberIdxY1 ); - fhSetupSortedCntEvoX1Y1->Fill( dTimeSinceStartSec ); - } // if( TMath::Abs( dDtX1Y1 ) < fdCoincBorderHodo ) - - if( TMath::Abs( dDtX1Y1 ) < fdCoincBorderHodo && - TMath::Abs( dDtX2Y2 ) < fdCoincBorderHodo && - TMath::Abs( dDtX1Y1X2Y2 ) < 2 * fdCoincBorderHodo ) - { - fhBothHodoSortedDtX1Y1->Fill( dDtX1Y1 ); - fhBothHodoSortedDtX2Y2->Fill( dDtX2Y2 ); - fhBothHodoSortedDtX1Y1X2Y2N1P1->Fill( dDtX1Y1X2Y2N1P1 ); - fhBothHodoSortedDtX1Y1X2Y2N2P2->Fill( dDtX1Y1X2Y2N2P2 ); - - fhBothHodoSortedMapX1Y1->Fill( uFiberIdxX1, uFiberIdxY1 ); - fhBothHodoSortedMapX2Y2->Fill( uFiberIdxX2, uFiberIdxY2 ); - fhBothHodoSortedCntEvoX1Y1->Fill( dTimeSinceStartSec ); - } // if( TMath::Abs( dDtX1Y1X2Y2 ) < 2 * fdCoincBorderHodo ) - - if( TMath::Abs( dDtX1Y1 ) < fdCoincBorderHodo && - TMath::Abs( dDtX2Y2 ) < fdCoincBorderHodo && - TMath::Abs( dDtN1P1 ) < fdCoincBorderSts && - TMath::Abs( dDtN2P2 ) < fdCoincBorderSts && - TMath::Abs( dDtX1Y1X2Y2 ) < 2 * fdCoincBorderHodo && - TMath::Abs( dDtN1P1N2P2 ) < 2 * fdCoincBorderSts && - TMath::Abs( dDtX1Y1X2Y2N1P1 ) < fdCoincBorder && - TMath::Abs( dDtX1Y1X2Y2N2P2 ) < fdCoincBorder && - TMath::Abs( dDtH1H2S1S2 ) < fdCoincBorder ) - { - fhSystSortedDtX1Y1->Fill( dDtX1Y1 ); - fhSystSortedDtX2Y2->Fill( dDtX2Y2 ); - fhSystSortedDtN1P1->Fill( dDtN1P1 ); - fhSystSortedDtN2P2->Fill( dDtN2P2 ); - fhSystSortedDtX1Y1X2Y2->Fill( dDtX1Y1X2Y2 ); - - fhSystSortedMapX1Y1->Fill( uFiberIdxX1, uFiberIdxY1 ); - fhSystSortedMapX2Y2->Fill( uFiberIdxX2, uFiberIdxY2 ); - fhSystSortedMapN1P1->Fill( fLastSortedHit1N.GetChan(), fLastSortedHit1P.GetChan() ); - fhSystSortedMapN2P2->Fill( fLastSortedHit2N.GetChan(), fLastSortedHit2P.GetChan() ); - fhSystSortedCntEvoX1Y1->Fill( dTimeSinceStartSec ); - fhSystSortedDtAllVsMapX1->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxX1 ); - fhSystSortedDtAllVsMapY1->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxY1 ); - fhSystSortedDtAllVsMapX2->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxX2 ); - fhSystSortedDtAllVsMapY2->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxY2 ); - - Double_t dDtN1X1 = ( dLastTimeN1 - dLastTimeX1 ) * stsxyter::kdClockCycleNs; - Double_t dDtN1X2 = ( dLastTimeN1 - dLastTimeX2 ) * stsxyter::kdClockCycleNs; - Double_t dDtP1X1 = ( dLastTimeP1 - dLastTimeX1 ) * stsxyter::kdClockCycleNs; - Double_t dDtP1X2 = ( dLastTimeP1 - dLastTimeX2 ) * stsxyter::kdClockCycleNs; - fhSystSortedDtN1X1vsN1X2->Fill( dDtN1X1, dDtN1X2 ); - fhSystSortedDtP1X1vsP1X2->Fill( dDtP1X1, dDtP1X2 ); - fhSystSortedDtN1X1vsP1X1->Fill( dDtN1X1, dDtP1X1 ); - - Double_t dDtX1Y1N1P1 = ( ( dLastTimeN1 + dLastTimeP1 ) / 2.0 - - ( dLastTimeX1 + dLastTimeY1 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - Double_t dDtX2Y2N1P1 = ( ( dLastTimeN1 + dLastTimeP1 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - fhSystSortedDtSts1Hodo1vsSts1Hodo2->Fill( dDtX1Y1N1P1, dDtX2Y2N1P1 ); - - Double_t dDtX1Y1N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) / 2.0 - - ( dLastTimeX1 + dLastTimeY1 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - Double_t dDtX2Y2N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - fhSystSortedDtSts2Hodo1vsSts2Hodo2->Fill( dDtX1Y1N2P2, dDtX2Y2N2P2 ); - } // if( TMath::Abs( dDtX1Y1X2Y2N1P1 ) < fdCoincBorder ) - } // else of if( bHitInX ) - } // if( fUnpackParHodo->GetAsicIndexHodo1() == usAsicIdx ) - else if( fUnpackParHodo->GetAsicIndexHodo2() == usAsicIdx ) - { - if( fUnpackParHodo->IsXySwappedHodo2() ) - bHitInX = !bHitInX; - - if( bHitInX ) - { - Double_t dDtSameFeb = ( ulHitTs - dLastTimeX2 ) * stsxyter::kdClockCycleNs; - fhSetupSortedDtX2->Fill( dDtSameFeb ); - - fLastSortedHit2X = (*it); - dLastTimeX2 = ulHitTs; - - /// Compute fiber Idx of the last Hodo hits - UInt_t uFiberIdxX1 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit1X.GetChan() ); - if( fUnpackParHodo->IsXInvertedHodo1() ) - uFiberIdxX1 = fuNbChanPerAsic/2 - 1 - uFiberIdxX1; - UInt_t uFiberIdxY1 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit1Y.GetChan() ); - if( fUnpackParHodo->IsYInvertedHodo1() ) - uFiberIdxY1 = fuNbChanPerAsic/2 - 1 - uFiberIdxY1; - UInt_t uFiberIdxX2 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit2X.GetChan() ); - if( fUnpackParHodo->IsXInvertedHodo2() ) - uFiberIdxX2 = fuNbChanPerAsic/2 - 1 - uFiberIdxX2; - UInt_t uFiberIdxY2 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit2Y.GetChan() ); - if( fUnpackParHodo->IsYInvertedHodo2() ) - uFiberIdxY2 = fuNbChanPerAsic/2 - 1 - uFiberIdxY2; - - if( dTimeSinceStartSec < fdSpillEvoLength ) - { - fhHodoX2SpillEvo->Fill( dTimeSinceStartSec, uFiberIdxX2 ); - fhHodoX2SpillEvoProf->Fill( dTimeSinceStartSec, uFiberIdxX2 ); - } // if( dTimeSinceStartSec < fdSpillEvoLength ) - - dDtX1Y1 = ( dLastTimeY1 - dLastTimeX1 ) * stsxyter::kdClockCycleNs; - dDtX2Y2 = ( dLastTimeY2 - dLastTimeX2 ) * stsxyter::kdClockCycleNs; - dDtN1P1 = ( dLastTimeP1 - dLastTimeN1 ) * stsxyter::kdClockCycleNs; - dDtX1Y1X2Y2 = ( ( dLastTimeX2 + dLastTimeY2 ) - ( dLastTimeX1 + dLastTimeY1 ) ) - * stsxyter::kdClockCycleNs / 2.0; - dDtX1Y1X2Y2N1P1 = ( ( dLastTimeN1 + dLastTimeP1 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) / 4.0 - ) * stsxyter::kdClockCycleNs; - if( kTRUE == fbDualStsEna ) - { - dDtN2P2 = ( dLastTimeP2 - dLastTimeN2 ) * stsxyter::kdClockCycleNs; - dDtN1P1N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) - ( dLastTimeN1 + dLastTimeP1 ) ) - * stsxyter::kdClockCycleNs / 2.0; - dDtX1Y1X2Y2N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) / 4.0 - ) * stsxyter::kdClockCycleNs; - dDtH1H2S1S2 = ( ( dLastTimeN2 + dLastTimeP2 + dLastTimeN1 + dLastTimeP1 ) - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) - ) * stsxyter::kdClockCycleNs / 4.0; - } // if( kTRUE == fbDualStsEna ) - - fhSetupSortedDtX2Y2->Fill( dDtX2Y2 ); - fhSetupSortedDtX1Y1X2Y2->Fill( dDtX1Y1X2Y2 ); - fhSetupSortedDtX1Y1X2Y2N1P1->Fill( dDtX1Y1X2Y2N1P1 ); - if( kTRUE == fbDualStsEna ) - { - fhSetupSortedDtX1Y1X2Y2N2P2->Fill( dDtX1Y1X2Y2N2P2 ); - fhSetupSortedDtH1H2S1S2->Fill( dDtH1H2S1S2 ); - } // if( kTRUE == fbDualStsEna ) - - if( TMath::Abs( dDtX2Y2 ) < fdCoincBorderHodo ) - { - fhSetupSortedMapX2Y2->Fill( uFiberIdxX2, uFiberIdxY2 ); - fhSetupSortedCntEvoX2Y2->Fill( dTimeSinceStartSec ); - } // if( TMath::Abs( dDtX2Y2 ) < fdCoincBorderHodo ) - - if( TMath::Abs( dDtX1Y1 ) < fdCoincBorderHodo && - TMath::Abs( dDtX2Y2 ) < fdCoincBorderHodo && - TMath::Abs( dDtX1Y1X2Y2 ) < 2 * fdCoincBorderHodo ) - { - fhBothHodoSortedDtX1Y1->Fill( dDtX1Y1 ); - fhBothHodoSortedDtX2Y2->Fill( dDtX2Y2 ); - fhBothHodoSortedDtX1Y1X2Y2N1P1->Fill( dDtX1Y1X2Y2N1P1 ); - fhBothHodoSortedDtX1Y1X2Y2N2P2->Fill( dDtX1Y1X2Y2N2P2 ); - - fhBothHodoSortedMapX1Y1->Fill( uFiberIdxX1, uFiberIdxY1 ); - fhBothHodoSortedMapX2Y2->Fill( uFiberIdxX2, uFiberIdxY2 ); - fhBothHodoSortedCntEvoX2Y2->Fill( dTimeSinceStartSec ); - } // if( TMath::Abs( dDtX1Y1X2Y2 ) < 2 * fdCoincBorderHodo ) - - if( TMath::Abs( dDtX1Y1 ) < fdCoincBorderHodo && - TMath::Abs( dDtX2Y2 ) < fdCoincBorderHodo && - TMath::Abs( dDtN1P1 ) < fdCoincBorderSts && - TMath::Abs( dDtN2P2 ) < fdCoincBorderSts && - TMath::Abs( dDtX1Y1X2Y2 ) < 2 * fdCoincBorderHodo && - TMath::Abs( dDtN1P1N2P2 ) < 2 * fdCoincBorderSts && - TMath::Abs( dDtX1Y1X2Y2N1P1 ) < fdCoincBorder && - TMath::Abs( dDtX1Y1X2Y2N2P2 ) < fdCoincBorder && - TMath::Abs( dDtH1H2S1S2 ) < fdCoincBorder ) - { - fhSystSortedDtX1Y1->Fill( dDtX1Y1 ); - fhSystSortedDtX2Y2->Fill( dDtX2Y2 ); - fhSystSortedDtN1P1->Fill( dDtN1P1 ); - fhSystSortedDtN2P2->Fill( dDtN2P2 ); - fhSystSortedDtX1Y1X2Y2->Fill( dDtX1Y1X2Y2 ); - - fhSystSortedMapX1Y1->Fill( uFiberIdxX1, uFiberIdxY1 ); - fhSystSortedMapX2Y2->Fill( uFiberIdxX2, uFiberIdxY2 ); - fhSystSortedMapN1P1->Fill( fLastSortedHit1N.GetChan(), fLastSortedHit1P.GetChan() ); - fhSystSortedMapN2P2->Fill( fLastSortedHit2N.GetChan(), fLastSortedHit2P.GetChan() ); - fhSystSortedCntEvoX2Y2->Fill( dTimeSinceStartSec ); - fhSystSortedDtAllVsMapX1->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxX1 ); - fhSystSortedDtAllVsMapY1->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxY1 ); - fhSystSortedDtAllVsMapX2->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxX2 ); - fhSystSortedDtAllVsMapY2->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxY2 ); - - Double_t dDtN1X1 = ( dLastTimeN1 - dLastTimeX1 ) * stsxyter::kdClockCycleNs; - Double_t dDtN1X2 = ( dLastTimeN1 - dLastTimeX2 ) * stsxyter::kdClockCycleNs; - Double_t dDtP1X1 = ( dLastTimeP1 - dLastTimeX1 ) * stsxyter::kdClockCycleNs; - Double_t dDtP1X2 = ( dLastTimeP1 - dLastTimeX2 ) * stsxyter::kdClockCycleNs; - fhSystSortedDtN1X1vsN1X2->Fill( dDtN1X1, dDtN1X2 ); - fhSystSortedDtP1X1vsP1X2->Fill( dDtP1X1, dDtP1X2 ); - fhSystSortedDtN1X1vsP1X1->Fill( dDtN1X1, dDtP1X1 ); - - Double_t dDtX1Y1N1P1 = ( ( dLastTimeN1 + dLastTimeP1 ) / 2.0 - - ( dLastTimeX1 + dLastTimeY1 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - Double_t dDtX2Y2N1P1 = ( ( dLastTimeN1 + dLastTimeP1 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - fhSystSortedDtSts1Hodo1vsSts1Hodo2->Fill( dDtX1Y1N1P1, dDtX2Y2N1P1 ); - - Double_t dDtX1Y1N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) / 2.0 - - ( dLastTimeX1 + dLastTimeY1 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - Double_t dDtX2Y2N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - fhSystSortedDtSts2Hodo1vsSts2Hodo2->Fill( dDtX1Y1N2P2, dDtX2Y2N2P2 ); - } // if( TMath::Abs( dDtX1Y1X2Y2N1P1 ) < fdCoincBorder ) - } // if( bHitInX ) - else - { - Double_t dDtSameFeb = ( ulHitTs - dLastTimeY2 ) * stsxyter::kdClockCycleNs; - fhSetupSortedDtY2->Fill( dDtSameFeb ); - - fLastSortedHit2Y = (*it); - dLastTimeY2 = ulHitTs; - - /// Compute fiber Idx of the last Hodo hits - UInt_t uFiberIdxX1 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit1X.GetChan() ); - if( fUnpackParHodo->IsXInvertedHodo1() ) - uFiberIdxX1 = fuNbChanPerAsic/2 - 1 - uFiberIdxX1; - UInt_t uFiberIdxY1 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit1Y.GetChan() ); - if( fUnpackParHodo->IsYInvertedHodo1() ) - uFiberIdxY1 = fuNbChanPerAsic/2 - 1 - uFiberIdxY1; - UInt_t uFiberIdxX2 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit2X.GetChan() ); - if( fUnpackParHodo->IsXInvertedHodo2() ) - uFiberIdxX2 = fuNbChanPerAsic/2 - 1 - uFiberIdxX2; - UInt_t uFiberIdxY2 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit2Y.GetChan() ); - if( fUnpackParHodo->IsYInvertedHodo2() ) - uFiberIdxY2 = fuNbChanPerAsic/2 - 1 - uFiberIdxY2; - - if( dTimeSinceStartSec < fdSpillEvoLength ) - { - fhHodoY2SpillEvo->Fill( dTimeSinceStartSec, uFiberIdxY2 ); - fhHodoY2SpillEvoProf->Fill( dTimeSinceStartSec, uFiberIdxY2 ); - } // if( dTimeSinceStartSec < fdSpillEvoLength ) - - dDtX1Y1 = ( dLastTimeY1 - dLastTimeX1 ) * stsxyter::kdClockCycleNs; - dDtX2Y2 = ( dLastTimeY2 - dLastTimeX2 ) * stsxyter::kdClockCycleNs; - dDtN1P1 = ( dLastTimeP1 - dLastTimeN1 ) * stsxyter::kdClockCycleNs; - dDtX1Y1X2Y2 = ( ( dLastTimeX2 + dLastTimeY2 ) - ( dLastTimeX1 + dLastTimeY1 ) ) - * stsxyter::kdClockCycleNs / 2.0; - dDtX1Y1X2Y2N1P1 = ( ( dLastTimeN1 + dLastTimeP1 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) / 4.0 - ) * stsxyter::kdClockCycleNs; - if( kTRUE == fbDualStsEna ) - { - dDtN2P2 = ( dLastTimeP2 - dLastTimeN2 ) * stsxyter::kdClockCycleNs; - dDtN1P1N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) - ( dLastTimeN1 + dLastTimeP1 ) ) - * stsxyter::kdClockCycleNs / 2.0; - dDtX1Y1X2Y2N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) / 4.0 - ) * stsxyter::kdClockCycleNs; - dDtH1H2S1S2 = ( ( dLastTimeN2 + dLastTimeP2 + dLastTimeN1 + dLastTimeP1 ) - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) - ) * stsxyter::kdClockCycleNs / 4.0; - } // if( kTRUE == fbDualStsEna ) - - fhSetupSortedDtX2Y2->Fill( dDtX2Y2 ); - fhSetupSortedDtX1Y1X2Y2->Fill( dDtX1Y1X2Y2 ); - fhSetupSortedDtX1Y1X2Y2N1P1->Fill( dDtX1Y1X2Y2N1P1 ); - if( kTRUE == fbDualStsEna ) - { - fhSetupSortedDtX1Y1X2Y2N2P2->Fill( dDtX1Y1X2Y2N2P2 ); - fhSetupSortedDtH1H2S1S2->Fill( dDtH1H2S1S2 ); - } // if( kTRUE == fbDualStsEna ) - - if( TMath::Abs( dDtX2Y2 ) < fdCoincBorderHodo ) - { - fhSetupSortedMapX2Y2->Fill( uFiberIdxX2, uFiberIdxY2 ); - fhSetupSortedCntEvoX2Y2->Fill( dTimeSinceStartSec ); - } // if( TMath::Abs( dDtX2Y2 ) < fdCoincBorderHodo ) - - if( TMath::Abs( dDtX1Y1 ) < fdCoincBorderHodo && - TMath::Abs( dDtX2Y2 ) < fdCoincBorderHodo && - TMath::Abs( dDtX1Y1X2Y2 ) < 2 * fdCoincBorderHodo ) - { - fhBothHodoSortedDtX1Y1->Fill( dDtX1Y1 ); - fhBothHodoSortedDtX2Y2->Fill( dDtX2Y2 ); - fhBothHodoSortedDtX1Y1X2Y2N1P1->Fill( dDtX1Y1X2Y2N1P1 ); - fhBothHodoSortedDtX1Y1X2Y2N2P2->Fill( dDtX1Y1X2Y2N2P2 ); - - fhBothHodoSortedMapX1Y1->Fill( uFiberIdxX1, uFiberIdxY1 ); - fhBothHodoSortedMapX2Y2->Fill( uFiberIdxX2, uFiberIdxY2 ); - fhBothHodoSortedCntEvoX2Y2->Fill( dTimeSinceStartSec ); - } // if( TMath::Abs( dDtX1Y1X2Y2 ) < 2 * fdCoincBorderHodo ) - - if( TMath::Abs( dDtX1Y1 ) < fdCoincBorderHodo && - TMath::Abs( dDtX2Y2 ) < fdCoincBorderHodo && - TMath::Abs( dDtN1P1 ) < fdCoincBorderSts && - TMath::Abs( dDtN2P2 ) < fdCoincBorderSts && - TMath::Abs( dDtX1Y1X2Y2 ) < 2 * fdCoincBorderHodo && - TMath::Abs( dDtN1P1N2P2 ) < 2 * fdCoincBorderSts && - TMath::Abs( dDtX1Y1X2Y2N1P1 ) < fdCoincBorder && - TMath::Abs( dDtX1Y1X2Y2N2P2 ) < fdCoincBorder && - TMath::Abs( dDtH1H2S1S2 ) < fdCoincBorder ) - { - fhSystSortedDtX1Y1->Fill( dDtX1Y1 ); - fhSystSortedDtX2Y2->Fill( dDtX2Y2 ); - fhSystSortedDtN1P1->Fill( dDtN1P1 ); - fhSystSortedDtN2P2->Fill( dDtN2P2 ); - fhSystSortedDtX1Y1X2Y2->Fill( dDtX1Y1X2Y2 ); - - fhSystSortedMapX1Y1->Fill( uFiberIdxX1, uFiberIdxY1 ); - fhSystSortedMapX2Y2->Fill( uFiberIdxX2, uFiberIdxY2 ); - fhSystSortedMapN1P1->Fill( fLastSortedHit1N.GetChan(), fLastSortedHit1P.GetChan() ); - fhSystSortedMapN2P2->Fill( fLastSortedHit2N.GetChan(), fLastSortedHit2P.GetChan() ); - fhSystSortedCntEvoX2Y2->Fill( dTimeSinceStartSec ); - fhSystSortedDtAllVsMapX1->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxX1 ); - fhSystSortedDtAllVsMapY1->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxY1 ); - fhSystSortedDtAllVsMapX2->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxX2 ); - fhSystSortedDtAllVsMapY2->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxY2 ); - - Double_t dDtN1X1 = ( dLastTimeN1 - dLastTimeX1 ) * stsxyter::kdClockCycleNs; - Double_t dDtN1X2 = ( dLastTimeN1 - dLastTimeX2 ) * stsxyter::kdClockCycleNs; - Double_t dDtP1X1 = ( dLastTimeP1 - dLastTimeX1 ) * stsxyter::kdClockCycleNs; - Double_t dDtP1X2 = ( dLastTimeP1 - dLastTimeX2 ) * stsxyter::kdClockCycleNs; - fhSystSortedDtN1X1vsN1X2->Fill( dDtN1X1, dDtN1X2 ); - fhSystSortedDtP1X1vsP1X2->Fill( dDtP1X1, dDtP1X2 ); - fhSystSortedDtN1X1vsP1X1->Fill( dDtN1X1, dDtP1X1 ); - - Double_t dDtX1Y1N1P1 = ( ( dLastTimeN1 + dLastTimeP1 ) / 2.0 - - ( dLastTimeX1 + dLastTimeY1 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - Double_t dDtX2Y2N1P1 = ( ( dLastTimeN1 + dLastTimeP1 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - fhSystSortedDtSts1Hodo1vsSts1Hodo2->Fill( dDtX1Y1N1P1, dDtX2Y2N1P1 ); - - Double_t dDtX1Y1N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) / 2.0 - - ( dLastTimeX1 + dLastTimeY1 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - Double_t dDtX2Y2N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - fhSystSortedDtSts2Hodo1vsSts2Hodo2->Fill( dDtX1Y1N2P2, dDtX2Y2N2P2 ); - } // if( TMath::Abs( dDtX1Y1X2Y2N1P1 ) < fdCoincBorder ) - } // else of if( bHitInX ) - } // else if( fUnpackParHodo->GetAsicIndexHodo2() == usAsicIdx ) - else if( fUnpackParSts->GetAsicIndexSts1N() == usAsicIdx ) - { - Double_t dDtSameFeb = ( ulHitTs - dLastTimeN1 ) * stsxyter::kdClockCycleNs; - fhSetupSortedDtN1->Fill( dDtSameFeb ); - - fLastSortedHit1N = (*it); - dLastTimeN1 = ulHitTs; - - /// Compute fiber Idx of the last Hodo hits - UInt_t uFiberIdxX1 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit1X.GetChan() ); - if( fUnpackParHodo->IsXInvertedHodo1() ) - uFiberIdxX1 = fuNbChanPerAsic/2 - 1 - uFiberIdxX1; - UInt_t uFiberIdxY1 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit1Y.GetChan() ); - if( fUnpackParHodo->IsYInvertedHodo1() ) - uFiberIdxY1 = fuNbChanPerAsic/2 - 1 - uFiberIdxY1; - UInt_t uFiberIdxX2 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit2X.GetChan() ); - if( fUnpackParHodo->IsXInvertedHodo2() ) - uFiberIdxX2 = fuNbChanPerAsic/2 - 1 - uFiberIdxX2; - UInt_t uFiberIdxY2 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit2Y.GetChan() ); - if( fUnpackParHodo->IsYInvertedHodo2() ) - uFiberIdxY2 = fuNbChanPerAsic/2 - 1 - uFiberIdxY2; - - dDtX1Y1 = ( dLastTimeY1 - dLastTimeX1 ) * stsxyter::kdClockCycleNs; - dDtX2Y2 = ( dLastTimeY2 - dLastTimeX2 ) * stsxyter::kdClockCycleNs; - dDtN1P1 = ( dLastTimeP1 - dLastTimeN1 ) * stsxyter::kdClockCycleNs; - dDtX1Y1X2Y2 = ( ( dLastTimeX2 + dLastTimeY2 ) - ( dLastTimeX1 + dLastTimeY1 ) ) - * stsxyter::kdClockCycleNs / 2.0; - dDtX1Y1X2Y2N1P1 = ( ( dLastTimeN1 + dLastTimeP1 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) / 4.0 - ) * stsxyter::kdClockCycleNs; - if( kTRUE == fbDualStsEna ) - { - dDtN2P2 = ( dLastTimeP2 - dLastTimeN2 ) * stsxyter::kdClockCycleNs; - dDtN1P1N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) - ( dLastTimeN1 + dLastTimeP1 ) ) - * stsxyter::kdClockCycleNs / 2.0; - dDtX1Y1X2Y2N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) / 4.0 - ) * stsxyter::kdClockCycleNs; - dDtH1H2S1S2 = ( ( dLastTimeN2 + dLastTimeP2 + dLastTimeN1 + dLastTimeP1 ) - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) - ) * stsxyter::kdClockCycleNs / 4.0; - } // if( kTRUE == fbDualStsEna ) - - fhSetupSortedDtN1P1->Fill( dDtN1P1 ); - fhSetupSortedDtX1Y1X2Y2N1P1->Fill( dDtX1Y1X2Y2N1P1 ); - if( kTRUE == fbDualStsEna ) - { - fhSetupSortedDtN1P1N2P2->Fill( dDtN1P1N2P2 ); - fhSetupSortedDtX1Y1X2Y2N2P2->Fill( dDtX1Y1X2Y2N2P2 ); - fhSetupSortedDtH1H2S1S2->Fill( dDtH1H2S1S2 ); - } // if( kTRUE == fbDualStsEna ) - - if( TMath::Abs( dDtN1P1 ) < fdCoincBorderSts ) - { - fhSetupSortedMapN1P1->Fill( fLastSortedHit1N.GetChan(), fLastSortedHit1P.GetChan() ); - fhSetupSortedCntEvoN1P1->Fill( dTimeSinceStartSec ); - } // if( TMath::Abs( dDtN1P1 ) < fdCoincBorderSts ) - - if( TMath::Abs( dDtX1Y1 ) < fdCoincBorderHodo && - TMath::Abs( dDtX2Y2 ) < fdCoincBorderHodo && - TMath::Abs( dDtN1P1 ) < fdCoincBorderSts && - TMath::Abs( dDtN2P2 ) < fdCoincBorderSts && - TMath::Abs( dDtX1Y1X2Y2 ) < 2 * fdCoincBorderHodo && - TMath::Abs( dDtN1P1N2P2 ) < 2 * fdCoincBorderSts && - TMath::Abs( dDtX1Y1X2Y2N1P1 ) < fdCoincBorder && - TMath::Abs( dDtX1Y1X2Y2N2P2 ) < fdCoincBorder && - TMath::Abs( dDtH1H2S1S2 ) < fdCoincBorder ) - { - fhSystSortedDtX1Y1->Fill( dDtX1Y1 ); - fhSystSortedDtX2Y2->Fill( dDtX2Y2 ); - fhSystSortedDtN1P1->Fill( dDtN1P1 ); - fhSystSortedDtN2P2->Fill( dDtN2P2 ); - fhSystSortedDtX1Y1X2Y2->Fill( dDtX1Y1X2Y2 ); - - fhSystSortedMapX1Y1->Fill( uFiberIdxX1, uFiberIdxY1 ); - fhSystSortedMapX2Y2->Fill( uFiberIdxX2, uFiberIdxY2 ); - fhSystSortedMapN1P1->Fill( fLastSortedHit1N.GetChan(), fLastSortedHit1P.GetChan() ); - fhSystSortedMapN2P2->Fill( fLastSortedHit2N.GetChan(), fLastSortedHit2P.GetChan() ); - fhSystSortedCntEvoN1P1->Fill( dTimeSinceStartSec ); - fhSystSortedDtAllVsMapX1->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxX1 ); - fhSystSortedDtAllVsMapY1->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxY1 ); - fhSystSortedDtAllVsMapX2->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxX2 ); - fhSystSortedDtAllVsMapY2->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxY2 ); - - Double_t dDtN1X1 = ( dLastTimeN1 - dLastTimeX1 ) * stsxyter::kdClockCycleNs; - Double_t dDtN1X2 = ( dLastTimeN1 - dLastTimeX2 ) * stsxyter::kdClockCycleNs; - Double_t dDtP1X1 = ( dLastTimeP1 - dLastTimeX1 ) * stsxyter::kdClockCycleNs; - Double_t dDtP1X2 = ( dLastTimeP1 - dLastTimeX2 ) * stsxyter::kdClockCycleNs; - fhSystSortedDtN1X1vsN1X2->Fill( dDtN1X1, dDtN1X2 ); - fhSystSortedDtP1X1vsP1X2->Fill( dDtP1X1, dDtP1X2 ); - fhSystSortedDtN1X1vsP1X1->Fill( dDtN1X1, dDtP1X1 ); - - Double_t dDtX1Y1N1P1 = ( ( dLastTimeN1 + dLastTimeP1 ) / 2.0 - - ( dLastTimeX1 + dLastTimeY1 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - Double_t dDtX2Y2N1P1 = ( ( dLastTimeN1 + dLastTimeP1 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - fhSystSortedDtSts1Hodo1vsSts1Hodo2->Fill( dDtX1Y1N1P1, dDtX2Y2N1P1 ); - - Double_t dDtX1Y1N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) / 2.0 - - ( dLastTimeX1 + dLastTimeY1 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - Double_t dDtX2Y2N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - fhSystSortedDtSts2Hodo1vsSts2Hodo2->Fill( dDtX1Y1N2P2, dDtX2Y2N2P2 ); - } // if( TMath::Abs( dDtX1Y1X2Y2N1P1 ) < fdCoincBorder ) - } // if( fUnpackParSts->GetAsicIndexSts1N() == usAsicIdx ) - else if( fUnpackParSts->GetAsicIndexSts1P() == usAsicIdx ) - { - Double_t dDtSameFeb = ( ulHitTs - dLastTimeP1 ) * stsxyter::kdClockCycleNs; - fhSetupSortedDtP1->Fill( dDtSameFeb ); - - fLastSortedHit1P = (*it); - dLastTimeP1 = ulHitTs; - - /// Compute fiber Idx of the last Hodo hits - UInt_t uFiberIdxX1 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit1X.GetChan() ); - if( fUnpackParHodo->IsXInvertedHodo1() ) - uFiberIdxX1 = fuNbChanPerAsic/2 - 1 - uFiberIdxX1; - UInt_t uFiberIdxY1 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit1Y.GetChan() ); - if( fUnpackParHodo->IsYInvertedHodo1() ) - uFiberIdxY1 = fuNbChanPerAsic/2 - 1 - uFiberIdxY1; - UInt_t uFiberIdxX2 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit2X.GetChan() ); - if( fUnpackParHodo->IsXInvertedHodo2() ) - uFiberIdxX2 = fuNbChanPerAsic/2 - 1 - uFiberIdxX2; - UInt_t uFiberIdxY2 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit2Y.GetChan() ); - if( fUnpackParHodo->IsYInvertedHodo2() ) - uFiberIdxY2 = fuNbChanPerAsic/2 - 1 - uFiberIdxY2; - - dDtX1Y1 = ( dLastTimeY1 - dLastTimeX1 ) * stsxyter::kdClockCycleNs; - dDtX2Y2 = ( dLastTimeY2 - dLastTimeX2 ) * stsxyter::kdClockCycleNs; - dDtN1P1 = ( dLastTimeP1 - dLastTimeN1 ) * stsxyter::kdClockCycleNs; - dDtX1Y1X2Y2 = ( ( dLastTimeX2 + dLastTimeY2 ) - ( dLastTimeX1 + dLastTimeY1 ) ) - * stsxyter::kdClockCycleNs / 2.0; - dDtX1Y1X2Y2N1P1 = ( ( dLastTimeN1 + dLastTimeP1 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) / 4.0 - ) * stsxyter::kdClockCycleNs; - if( kTRUE == fbDualStsEna ) - { - dDtN2P2 = ( dLastTimeP2 - dLastTimeN2 ) * stsxyter::kdClockCycleNs; - dDtN1P1N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) - ( dLastTimeN1 + dLastTimeP1 ) ) - * stsxyter::kdClockCycleNs / 2.0; - dDtX1Y1X2Y2N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) / 4.0 - ) * stsxyter::kdClockCycleNs; - dDtH1H2S1S2 = ( ( dLastTimeN2 + dLastTimeP2 + dLastTimeN1 + dLastTimeP1 ) - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) - ) * stsxyter::kdClockCycleNs / 4.0; - } // if( kTRUE == fbDualStsEna ) - - fhSetupSortedDtN1P1->Fill( dDtN1P1 ); - fhSetupSortedDtX1Y1X2Y2N1P1->Fill( dDtX1Y1X2Y2N1P1 ); - if( kTRUE == fbDualStsEna ) - { - fhSetupSortedDtN1P1N2P2->Fill( dDtN1P1N2P2 ); - fhSetupSortedDtX1Y1X2Y2N2P2->Fill( dDtX1Y1X2Y2N2P2 ); - fhSetupSortedDtH1H2S1S2->Fill( dDtH1H2S1S2 ); - } // if( kTRUE == fbDualStsEna ) - - if( TMath::Abs( dDtN1P1 ) < fdCoincBorderSts ) - { - fhSetupSortedMapN1P1->Fill( fLastSortedHit1N.GetChan(), fLastSortedHit1P.GetChan() ); - fhSetupSortedCntEvoN1P1->Fill( dTimeSinceStartSec ); - } // if( TMath::Abs( dDtN1P1 ) < fdCoincBorderSts ) - - if( TMath::Abs( dDtX1Y1 ) < fdCoincBorderHodo && - TMath::Abs( dDtX2Y2 ) < fdCoincBorderHodo && - TMath::Abs( dDtN1P1 ) < fdCoincBorderSts && - TMath::Abs( dDtN2P2 ) < fdCoincBorderSts && - TMath::Abs( dDtX1Y1X2Y2 ) < 2 * fdCoincBorderHodo && - TMath::Abs( dDtN1P1N2P2 ) < 2 * fdCoincBorderSts && - TMath::Abs( dDtX1Y1X2Y2N1P1 ) < fdCoincBorder && - TMath::Abs( dDtX1Y1X2Y2N2P2 ) < fdCoincBorder && - TMath::Abs( dDtH1H2S1S2 ) < fdCoincBorder ) - { - fhSystSortedDtX1Y1->Fill( dDtX1Y1 ); - fhSystSortedDtX2Y2->Fill( dDtX2Y2 ); - fhSystSortedDtN1P1->Fill( dDtN1P1 ); - fhSystSortedDtN2P2->Fill( dDtN2P2 ); - fhSystSortedDtX1Y1X2Y2->Fill( dDtX1Y1X2Y2 ); - - fhSystSortedMapX1Y1->Fill( uFiberIdxX1, uFiberIdxY1 ); - fhSystSortedMapX2Y2->Fill( uFiberIdxX2, uFiberIdxY2 ); - fhSystSortedMapN1P1->Fill( fLastSortedHit1N.GetChan(), fLastSortedHit1P.GetChan() ); - fhSystSortedMapN2P2->Fill( fLastSortedHit2N.GetChan(), fLastSortedHit2P.GetChan() ); - fhSystSortedCntEvoN1P1->Fill( dTimeSinceStartSec ); - fhSystSortedDtAllVsMapX1->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxX1 ); - fhSystSortedDtAllVsMapY1->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxY1 ); - fhSystSortedDtAllVsMapX2->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxX2 ); - fhSystSortedDtAllVsMapY2->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxY2 ); - - Double_t dDtN1X1 = ( dLastTimeN1 - dLastTimeX1 ) * stsxyter::kdClockCycleNs; - Double_t dDtN1X2 = ( dLastTimeN1 - dLastTimeX2 ) * stsxyter::kdClockCycleNs; - Double_t dDtP1X1 = ( dLastTimeP1 - dLastTimeX1 ) * stsxyter::kdClockCycleNs; - Double_t dDtP1X2 = ( dLastTimeP1 - dLastTimeX2 ) * stsxyter::kdClockCycleNs; - fhSystSortedDtN1X1vsN1X2->Fill( dDtN1X1, dDtN1X2 ); - fhSystSortedDtP1X1vsP1X2->Fill( dDtP1X1, dDtP1X2 ); - fhSystSortedDtN1X1vsP1X1->Fill( dDtN1X1, dDtP1X1 ); - - Double_t dDtX1Y1N1P1 = ( ( dLastTimeN1 + dLastTimeP1 ) / 2.0 - - ( dLastTimeX1 + dLastTimeY1 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - Double_t dDtX2Y2N1P1 = ( ( dLastTimeN1 + dLastTimeP1 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - fhSystSortedDtSts1Hodo1vsSts1Hodo2->Fill( dDtX1Y1N1P1, dDtX2Y2N1P1 ); - - Double_t dDtX1Y1N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) / 2.0 - - ( dLastTimeX1 + dLastTimeY1 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - Double_t dDtX2Y2N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - fhSystSortedDtSts2Hodo1vsSts2Hodo2->Fill( dDtX1Y1N2P2, dDtX2Y2N2P2 ); - } // if( TMath::Abs( dDtX1Y1X2Y2N1P1 ) < fdCoincBorder ) - } // else if( fUnpackParSts->GetAsicIndexSts1P() == usAsicIdx ) - else if( kTRUE == fbDualStsEna ) - { - if( fUnpackParSts->GetAsicIndexSts2N() == usAsicIdx ) - { - Double_t dDtSameFeb = ( ulHitTs - dLastTimeN2 ) * stsxyter::kdClockCycleNs; - fhSetupSortedDtN2->Fill( dDtSameFeb ); - - fLastSortedHit2N = (*it); - dLastTimeN2 = ulHitTs; - - /// Compute fiber Idx of the last Hodo hits - UInt_t uFiberIdxX1 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit1X.GetChan() ); - if( fUnpackParHodo->IsXInvertedHodo1() ) - uFiberIdxX1 = fuNbChanPerAsic/2 - 1 - uFiberIdxX1; - UInt_t uFiberIdxY1 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit1Y.GetChan() ); - if( fUnpackParHodo->IsYInvertedHodo1() ) - uFiberIdxY1 = fuNbChanPerAsic/2 - 1 - uFiberIdxY1; - UInt_t uFiberIdxX2 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit2X.GetChan() ); - if( fUnpackParHodo->IsXInvertedHodo2() ) - uFiberIdxX2 = fuNbChanPerAsic/2 - 1 - uFiberIdxX2; - UInt_t uFiberIdxY2 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit2Y.GetChan() ); - if( fUnpackParHodo->IsYInvertedHodo2() ) - uFiberIdxY2 = fuNbChanPerAsic/2 - 1 - uFiberIdxY2; - - dDtX1Y1 = ( dLastTimeY1 - dLastTimeX1 ) * stsxyter::kdClockCycleNs; - dDtX2Y2 = ( dLastTimeY2 - dLastTimeX2 ) * stsxyter::kdClockCycleNs; - dDtN1P1 = ( dLastTimeP1 - dLastTimeN1 ) * stsxyter::kdClockCycleNs; - dDtN2P2 = ( dLastTimeP2 - dLastTimeN2 ) * stsxyter::kdClockCycleNs; - dDtX1Y1X2Y2 = ( ( dLastTimeX2 + dLastTimeY2 ) - ( dLastTimeX1 + dLastTimeY1 ) ) - * stsxyter::kdClockCycleNs / 2.0; - dDtN1P1N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) - ( dLastTimeN1 + dLastTimeP1 ) ) - * stsxyter::kdClockCycleNs / 2.0; - dDtX1Y1X2Y2N1P1 = ( ( dLastTimeN1 + dLastTimeP1 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) / 4.0 - ) * stsxyter::kdClockCycleNs; - dDtX1Y1X2Y2N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) / 4.0 - ) * stsxyter::kdClockCycleNs; - dDtH1H2S1S2 = ( ( dLastTimeN2 + dLastTimeP2 + dLastTimeN1 + dLastTimeP1 ) - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) - ) * stsxyter::kdClockCycleNs / 4.0; - - fhSetupSortedDtN2P2->Fill( dDtN2P2 ); - fhSetupSortedDtN1P1N2P2->Fill( dDtN1P1N2P2 ); - fhSetupSortedDtX1Y1X2Y2N2P2->Fill( dDtX1Y1X2Y2N2P2 ); - fhSetupSortedDtH1H2S1S2->Fill( dDtH1H2S1S2 ); - - if( TMath::Abs( dDtN2P2 ) < fdCoincBorderSts ) - { - fhSetupSortedMapN2P2->Fill( fLastSortedHit2N.GetChan(), fLastSortedHit2P.GetChan() ); - fhSetupSortedCntEvoN2P2->Fill( dTimeSinceStartSec ); - } // if( TMath::Abs( dDtN2P2 ) < fdCoincBorderSts ) - - if( TMath::Abs( dDtX1Y1 ) < fdCoincBorderHodo && - TMath::Abs( dDtX2Y2 ) < fdCoincBorderHodo && - TMath::Abs( dDtN1P1 ) < fdCoincBorderSts && - TMath::Abs( dDtN2P2 ) < fdCoincBorderSts && - TMath::Abs( dDtX1Y1X2Y2 ) < 2 * fdCoincBorderHodo && - TMath::Abs( dDtN1P1N2P2 ) < 2 * fdCoincBorderSts && - TMath::Abs( dDtX1Y1X2Y2N1P1 ) < fdCoincBorder && - TMath::Abs( dDtX1Y1X2Y2N2P2 ) < fdCoincBorder && - TMath::Abs( dDtH1H2S1S2 ) < fdCoincBorder ) - { - fhSystSortedDtX1Y1->Fill( dDtX1Y1 ); - fhSystSortedDtX2Y2->Fill( dDtX2Y2 ); - fhSystSortedDtN1P1->Fill( dDtN1P1 ); - fhSystSortedDtN2P2->Fill( dDtN2P2 ); - fhSystSortedDtX1Y1X2Y2->Fill( dDtX1Y1X2Y2 ); - - fhSystSortedMapX1Y1->Fill( uFiberIdxX1, uFiberIdxY1 ); - fhSystSortedMapX2Y2->Fill( uFiberIdxX2, uFiberIdxY2 ); - fhSystSortedMapN1P1->Fill( fLastSortedHit1N.GetChan(), fLastSortedHit1P.GetChan() ); - fhSystSortedMapN2P2->Fill( fLastSortedHit2N.GetChan(), fLastSortedHit2P.GetChan() ); - fhSystSortedCntEvoN1P1->Fill( dTimeSinceStartSec ); - fhSystSortedDtAllVsMapX1->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxX1 ); - fhSystSortedDtAllVsMapY1->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxY1 ); - fhSystSortedDtAllVsMapX2->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxX2 ); - fhSystSortedDtAllVsMapY2->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxY2 ); - - Double_t dDtN1X1 = ( dLastTimeN1 - dLastTimeX1 ) * stsxyter::kdClockCycleNs; - Double_t dDtN1X2 = ( dLastTimeN1 - dLastTimeX2 ) * stsxyter::kdClockCycleNs; - Double_t dDtP1X1 = ( dLastTimeP1 - dLastTimeX1 ) * stsxyter::kdClockCycleNs; - Double_t dDtP1X2 = ( dLastTimeP1 - dLastTimeX2 ) * stsxyter::kdClockCycleNs; - fhSystSortedDtN1X1vsN1X2->Fill( dDtN1X1, dDtN1X2 ); - fhSystSortedDtP1X1vsP1X2->Fill( dDtP1X1, dDtP1X2 ); - fhSystSortedDtN1X1vsP1X1->Fill( dDtN1X1, dDtP1X1 ); - - Double_t dDtX1Y1N1P1 = ( ( dLastTimeN1 + dLastTimeP1 ) / 2.0 - - ( dLastTimeX1 + dLastTimeY1 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - Double_t dDtX2Y2N1P1 = ( ( dLastTimeN1 + dLastTimeP1 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - fhSystSortedDtSts1Hodo1vsSts1Hodo2->Fill( dDtX1Y1N1P1, dDtX2Y2N1P1 ); - - Double_t dDtX1Y1N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) / 2.0 - - ( dLastTimeX1 + dLastTimeY1 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - Double_t dDtX2Y2N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - fhSystSortedDtSts2Hodo1vsSts2Hodo2->Fill( dDtX1Y1N2P2, dDtX2Y2N2P2 ); - } // if( TMath::Abs( dDtX1Y1X2Y2N1P1 ) < fdCoincBorder ) - } // if( fUnpackParSts->GetAsicIndexSts2N() == usAsicIdx ) - else if( fUnpackParSts->GetAsicIndexSts2P() == usAsicIdx ) - { - Double_t dDtSameFeb = ( ulHitTs - dLastTimeP2 ) * stsxyter::kdClockCycleNs; - fhSetupSortedDtP2->Fill( dDtSameFeb ); - - fLastSortedHit2P = (*it); - dLastTimeP2 = ulHitTs; - - /// Compute fiber Idx of the last Hodo hits - UInt_t uFiberIdxX1 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit1X.GetChan() ); - if( fUnpackParHodo->IsXInvertedHodo1() ) - uFiberIdxX1 = fuNbChanPerAsic/2 - 1 - uFiberIdxX1; - UInt_t uFiberIdxY1 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit1Y.GetChan() ); - if( fUnpackParHodo->IsYInvertedHodo1() ) - uFiberIdxY1 = fuNbChanPerAsic/2 - 1 - uFiberIdxY1; - UInt_t uFiberIdxX2 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit2X.GetChan() ); - if( fUnpackParHodo->IsXInvertedHodo2() ) - uFiberIdxX2 = fuNbChanPerAsic/2 - 1 - uFiberIdxX2; - UInt_t uFiberIdxY2 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit2Y.GetChan() ); - if( fUnpackParHodo->IsYInvertedHodo2() ) - uFiberIdxY2 = fuNbChanPerAsic/2 - 1 - uFiberIdxY2; - - dDtX1Y1 = ( dLastTimeY1 - dLastTimeX1 ) * stsxyter::kdClockCycleNs; - dDtX2Y2 = ( dLastTimeY2 - dLastTimeX2 ) * stsxyter::kdClockCycleNs; - dDtN1P1 = ( dLastTimeP1 - dLastTimeN1 ) * stsxyter::kdClockCycleNs; - dDtN2P2 = ( dLastTimeP2 - dLastTimeN2 ) * stsxyter::kdClockCycleNs; - dDtX1Y1X2Y2 = ( ( dLastTimeX2 + dLastTimeY2 ) - ( dLastTimeX1 + dLastTimeY1 ) ) - * stsxyter::kdClockCycleNs / 2.0; - dDtN1P1N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) - ( dLastTimeN1 + dLastTimeP1 ) ) - * stsxyter::kdClockCycleNs / 2.0; - dDtX1Y1X2Y2N1P1 = ( ( dLastTimeN1 + dLastTimeP1 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) / 4.0 - ) * stsxyter::kdClockCycleNs; - dDtX1Y1X2Y2N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) / 4.0 - ) * stsxyter::kdClockCycleNs; - dDtH1H2S1S2 = ( ( dLastTimeN2 + dLastTimeP2 + dLastTimeN1 + dLastTimeP1 ) - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) - ) * stsxyter::kdClockCycleNs / 4.0; - - - fhSetupSortedDtN2P2->Fill( dDtN2P2 ); - fhSetupSortedDtN1P1N2P2->Fill( dDtN1P1N2P2 ); - fhSetupSortedDtX1Y1X2Y2N2P2->Fill( dDtX1Y1X2Y2N2P2 ); - fhSetupSortedDtH1H2S1S2->Fill( dDtH1H2S1S2 ); - - if( TMath::Abs( dDtN2P2 ) < fdCoincBorderSts ) - { - fhSetupSortedMapN2P2->Fill( fLastSortedHit2N.GetChan(), fLastSortedHit2P.GetChan() ); - fhSetupSortedCntEvoN2P2->Fill( dTimeSinceStartSec ); - } // if( TMath::Abs( dDtN2P2 ) < fdCoincBorderSts ) - - if( TMath::Abs( dDtX1Y1 ) < fdCoincBorderHodo && - TMath::Abs( dDtX2Y2 ) < fdCoincBorderHodo && - TMath::Abs( dDtN1P1 ) < fdCoincBorderSts && - TMath::Abs( dDtN2P2 ) < fdCoincBorderSts && - TMath::Abs( dDtX1Y1X2Y2 ) < 2 * fdCoincBorderHodo && - TMath::Abs( dDtN1P1N2P2 ) < 2 * fdCoincBorderSts && - TMath::Abs( dDtX1Y1X2Y2N1P1 ) < fdCoincBorder && - TMath::Abs( dDtX1Y1X2Y2N2P2 ) < fdCoincBorder && - TMath::Abs( dDtH1H2S1S2 ) < fdCoincBorder ) - { - fhSystSortedDtX1Y1->Fill( dDtX1Y1 ); - fhSystSortedDtX2Y2->Fill( dDtX2Y2 ); - fhSystSortedDtN1P1->Fill( dDtN1P1 ); - fhSystSortedDtN2P2->Fill( dDtN2P2 ); - fhSystSortedDtX1Y1X2Y2->Fill( dDtX1Y1X2Y2 ); - - fhSystSortedMapX1Y1->Fill( uFiberIdxX1, uFiberIdxY1 ); - fhSystSortedMapX2Y2->Fill( uFiberIdxX2, uFiberIdxY2 ); - fhSystSortedMapN1P1->Fill( fLastSortedHit1N.GetChan(), fLastSortedHit1P.GetChan() ); - fhSystSortedMapN2P2->Fill( fLastSortedHit2N.GetChan(), fLastSortedHit2P.GetChan() ); - fhSystSortedCntEvoN1P1->Fill( dTimeSinceStartSec ); - fhSystSortedDtAllVsMapX1->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxX1 ); - fhSystSortedDtAllVsMapY1->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxY1 ); - fhSystSortedDtAllVsMapX2->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxX2 ); - fhSystSortedDtAllVsMapY2->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxY2 ); - - Double_t dDtN1X1 = ( dLastTimeN1 - dLastTimeX1 ) * stsxyter::kdClockCycleNs; - Double_t dDtN1X2 = ( dLastTimeN1 - dLastTimeX2 ) * stsxyter::kdClockCycleNs; - Double_t dDtP1X1 = ( dLastTimeP1 - dLastTimeX1 ) * stsxyter::kdClockCycleNs; - Double_t dDtP1X2 = ( dLastTimeP1 - dLastTimeX2 ) * stsxyter::kdClockCycleNs; - fhSystSortedDtN1X1vsN1X2->Fill( dDtN1X1, dDtN1X2 ); - fhSystSortedDtP1X1vsP1X2->Fill( dDtP1X1, dDtP1X2 ); - fhSystSortedDtN1X1vsP1X1->Fill( dDtN1X1, dDtP1X1 ); - - Double_t dDtX1Y1N1P1 = ( ( dLastTimeN1 + dLastTimeP1 ) / 2.0 - - ( dLastTimeX1 + dLastTimeY1 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - Double_t dDtX2Y2N1P1 = ( ( dLastTimeN1 + dLastTimeP1 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - fhSystSortedDtSts1Hodo1vsSts1Hodo2->Fill( dDtX1Y1N1P1, dDtX2Y2N1P1 ); - - Double_t dDtX1Y1N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) / 2.0 - - ( dLastTimeX1 + dLastTimeY1 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - Double_t dDtX2Y2N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - fhSystSortedDtSts2Hodo1vsSts2Hodo2->Fill( dDtX1Y1N2P2, dDtX2Y2N2P2 ); - } // if( TMath::Abs( dDtX1Y1X2Y2N1P1 ) < fdCoincBorder ) - } // else if( fUnpackParSts->GetAsicIndexSts1P() == usAsicIdx ) - } // else if( kTRUE == fbDualStsEna ) - } // loop on hits untils hits within 100 ns of last one or last one itself are reached - - // Remove all hits which were already used - fvmHitsInTs.erase( fvmHitsInTs.begin(), it ); - } // if( 0 < fvmHitsInTs.size() ) - } // for( size_t m = 0; m < numCompMsInTs; ++m ) - - // End of TS, check if stuff to do with the hits inside each MS - // Usefull for low rate pulser tests - // Need to do it only when last DPB is processed, as they are done one by one - if( fuCurrDpbIdx == fuNrOfDpbs - 1 ) - { - for( UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx ) - { - fvdMsTime[ uMsIdx ] = 0.0; - } // for( UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx ) - } // if( fuCurrDpbIdx == fuNrOfDpbs - 1 ) - - if( 0 == ts.index() % 1000 && fuCurrDpbIdx == fuNrOfDpbs - 1 ) - { - for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - { - Double_t dTsMsbTime = - static_cast<ULong64_t>( stsxyter::kuHitNbTsBins ) - * static_cast<ULong64_t>( fvulCurrentTsMsb[fuCurrDpbIdx]) - + static_cast<ULong64_t>( stsxyter::kulTsCycleNbBins ) - * static_cast<ULong64_t>( fvuCurrentTsMsbCycle[fuCurrDpbIdx] ); - dTsMsbTime *= stsxyter::kdClockCycleNs * 1e-9; - - LOG(info) << "End of TS " << std::setw(7) << ts.index() - << " eDPB " << std::setw(2) << uDpb - << " current TS MSB counter is " << std::setw(12) << fvulCurrentTsMsb[uDpb] - << " current TS MSB cycle counter is " << std::setw(12) << fvuCurrentTsMsbCycle[uDpb] - << " current TS MSB time is " << std::setw(12) << dTsMsbTime << " s"; - } - } // if( 0 == ts.index() % 1000 && fuCurrDpbIdx == fuNrOfDpbs - 1 ) - - return kTRUE; -} - -void CbmCosy2018MonitorSetup::FillHitInfo( stsxyter::Message mess, const UShort_t & /*usElinkIdx*/, const UInt_t & uAsicIdx, const UInt_t & uMsIdx ) -{ - UShort_t usChan = mess.GetHitChannel(); - UShort_t usRawAdc = mess.GetHitAdc(); -// UShort_t usFullTs = mess.GetHitTimeFull(); -// UShort_t usTsOver = mess.GetHitTimeOver(); - UShort_t usRawTs = mess.GetHitTime(); - - fhHodoChanCntRaw[ uAsicIdx ]->Fill( usChan ); - fhHodoChanAdcRaw[ uAsicIdx ]->Fill( usChan, usRawAdc ); - fhHodoChanAdcRawProf[ uAsicIdx ]->Fill( usChan, usRawAdc ); - fhHodoChanRawTs[ uAsicIdx ]->Fill( usChan, usRawTs ); - fhHodoChanMissEvt[ uAsicIdx ]->Fill( usChan, mess.IsHitMissedEvts() ); - - // Compute the Full time stamp -// Long64_t ulOldHitTime = fvulChanLastHitTime[ uAsicIdx ][ usChan ]; -// Double_t dOldHitTime = fvdChanLastHitTime[ uAsicIdx ][ usChan ]; - - // Use TS w/o overlap bits as they will anyway come from the TS_MSB - fvulChanLastHitTime[ uAsicIdx ][ usChan ] = usRawTs; - - fvulChanLastHitTime[ uAsicIdx ][ usChan ] += - static_cast<ULong64_t>( stsxyter::kuHitNbTsBins ) - * static_cast<ULong64_t>( fvulCurrentTsMsb[fuCurrDpbIdx]) - + static_cast<ULong64_t>( stsxyter::kulTsCycleNbBins ) - * static_cast<ULong64_t>( fvuCurrentTsMsbCycle[fuCurrDpbIdx] ) - ; - -// fvuElinkLastTsHit[fuCurrDpbIdx] = usRawTs; - - // Convert the Hit time in bins to Hit time in ns - Double_t dHitTimeNs = fvulChanLastHitTime[ uAsicIdx ][ usChan ] * stsxyter::kdClockCycleNs; -/* - // If needed fill the hit interval plots - if( fbChanHitDtEna ) - { - Double_t dDeltaT = dHitTimeNs - fvdChanLastHitTime[ uAsicIdx ][ usChan ]; - if( 0 == dDeltaT ) - fhStsChanHitDtNeg[ uAsicIdx ]->Fill( 1, usChan ); - else if( 0 < dDeltaT ) - fhStsChanHitDt[ uAsicIdx ]->Fill( dDeltaT, usChan ); - else fhStsChanHitDtNeg[ uAsicIdx ]->Fill( -dDeltaT, usChan ); - } // if( fbChanHitDtEna ) -*/ - // Store new value of Hit time in ns - fvdChanLastHitTime[ uAsicIdx ][ usChan ] = fvulChanLastHitTime[ uAsicIdx ][ usChan ] * stsxyter::kdClockCycleNs; -/* - LOG(info) << " Asic " << std::setw( 2 ) << uAsicIdx - << " Channel " << std::setw( 3 ) << usChan - << " Diff to last hit " << std::setw( 12 ) << ( fvulChanLastHitTime[ uAsicIdx ][ usChan ] - ulOldHitTime) - << " in s " << std::setw( 12 ) << ( fvdChanLastHitTime[ uAsicIdx ][ usChan ] - dOldHitTime) * 1e-9; -*/ - // Pulser and MS - fvuChanNbHitsInMs[ uAsicIdx ][ usChan ][ uMsIdx ] ++; - fvdChanLastHitTimeInMs[ uAsicIdx ][ usChan ][ uMsIdx ] = dHitTimeNs; - fvusChanLastHitAdcInMs[ uAsicIdx ][ usChan ][ uMsIdx ] = usRawAdc; -/* - fvmChanHitsInTs[ uAsicIdx ][ usChan ].insert( stsxyter::FinalHit( fvulChanLastHitTime[ uAsicIdx ][ usChan ], - usRawAdc, uAsicIdx, usChan ) ); -*/ - fvmHitsInTs.push_back( stsxyter::FinalHit( fvulChanLastHitTime[ uAsicIdx ][ usChan ], usRawAdc, uAsicIdx, usChan ) ); - -/* - LOG(info) << " TS " << std::setw( 12 ) << fulCurrentTsIdx - << " MS " << std::setw( 12 ) << fulCurrentMsIdx - << " MsInTs " << std::setw( 3 ) << uMsIdx - << " Asic " << std::setw( 2 ) << uAsicIdx - << " Channel " << std::setw( 3 ) << usChan - << " ADC " << std::setw( 3 ) << usRawAdc - << " TS " << std::setw( 3 ) << usRawTs // 9 bits TS - << " SX TsMsb " << std::setw( 2 ) << ( fvulCurrentTsMsb[fuCurrDpbIdx] & 0x1F ) // Total StsXyter TS = 14 bits => 9b Hit TS + lower 5b TS_MSB after DPB - << " DPB TsMsb " << std::setw( 6 ) << ( fvulCurrentTsMsb[fuCurrDpbIdx] >> 5 ) // Total StsXyter TS = 14 bits => 9b Hit TS + lower 5b of TS_MSB after DPB - << " TsMsb " << std::setw( 7 ) << fvulCurrentTsMsb[fuCurrDpbIdx] - << " MsbCy " << std::setw( 4 ) << fvuCurrentTsMsbCycle[fuCurrDpbIdx] - << " Time " << std::setw ( 12 ) << fvulChanLastHitTime[ uAsicIdx ][ usChan ]; -*/ - // Check Starting point of histos with time as X axis - if( -1 == fdStartTime ) - fdStartTime = fvdChanLastHitTime[ uAsicIdx ][ usChan ]; - - // Fill histos with time as X axis - Double_t dTimeSinceStartSec = (fvdChanLastHitTime[ uAsicIdx ][ usChan ] - fdStartTime)* 1e-9; - Double_t dTimeSinceStartMin = dTimeSinceStartSec / 60.0; - fhHodoChanHitRateEvo[ uAsicIdx ]->Fill( dTimeSinceStartSec , usChan ); - fhHodoFebRateEvo[ uAsicIdx ]->Fill( dTimeSinceStartSec ); - fhHodoChanHitRateEvoLong[ uAsicIdx ]->Fill( dTimeSinceStartMin, usChan, 1.0/60.0 ); - fhHodoFebRateEvoLong[ uAsicIdx ]->Fill( dTimeSinceStartMin, 1.0/60.0 ); - if( mess.IsHitMissedEvts() ) - { - fhHodoChanMissEvtEvo[ uAsicIdx ]->Fill( dTimeSinceStartSec , usChan ); - fhHodoFebMissEvtEvo[ uAsicIdx ]->Fill( dTimeSinceStartSec ); - } // if( mess.IsHitMissedEvts() ) -/* - if( kTRUE == fbLongHistoEnable ) - { - std::chrono::steady_clock::time_point tNow = std::chrono::steady_clock::now(); - Double_t dUnixTimeInRun = std::chrono::duration_cast< std::chrono::seconds >(tNow - ftStartTimeUnix).count(); - fhFebRateEvoLong[ uAsicIdx ]->Fill( dUnixTimeInRun , 1.0 / fuLongHistoBinSizeSec ); - fhFebChRateEvoLong[ uAsicIdx ]->Fill( dUnixTimeInRun , usChan, 1.0 / fuLongHistoBinSizeSec ); - } // if( kTRUE == fbLongHistoEnable ) -*/ - -} - -void CbmCosy2018MonitorSetup::FillTsMsbInfo( stsxyter::Message mess, UInt_t /*uMessIdx*/, UInt_t /*uMsIdx*/ ) -{ - UInt_t uVal = mess.GetTsMsbVal(); -/* - if( 0 == fuCurrDpbIdx ) - LOG(info) << " TS " << std::setw( 12 ) << fulCurrentTsIdx - << " MS " << std::setw( 12 ) << fulCurrentMsIdx - << " MsInTs " << std::setw( 3 ) << uMsIdx - << " DPB " << std::setw( 2 ) << fuCurrDpbIdx - << " Mess " << std::setw( 5 ) << uMessIdx - << " TsMsb " << std::setw( 5 ) << uVal; -*/ -/* - if( (uVal != fvulCurrentTsMsb[fuCurrDpbIdx] + 1) && 0 < uVal && - !( 1 == uMessIdx && usVal == fvulCurrentTsMsb[fuCurrDpbIdx] ) ) // 1st TS_MSB in MS is always a repeat of the last one in previous MS! - { - LOG(info) << "TS MSB not increasing by 1! TS " << std::setw( 12 ) << fulCurrentTsIdx - << " MS " << std::setw( 12 ) << fulCurrentMsIdx - << " MsInTs " << std::setw( 3 ) << uMsIdx - << " DPB " << std::setw( 2 ) << fuCurrDpbIdx - << " Mess " << std::setw( 5 ) << uMessIdx - << " Old TsMsb " << std::setw( 5 ) << fvulCurrentTsMsb[fuCurrDpbIdx] - << " new TsMsb " << std::setw( 5 ) << uVal - << " Diff " << std::setw( 5 ) << uVal - fvulCurrentTsMsb[fuCurrDpbIdx] - << " Old MsbCy " << std::setw( 5 ) << fvuCurrentTsMsbCycle[fuCurrDpbIdx]; - } // if( (uVal != fvulCurrentTsMsb[fuCurrDpbIdx] + 1) && 0 < uVal ) -*/ - - // Update Status counters - if( uVal < fvulCurrentTsMsb[fuCurrDpbIdx] ) - { - - LOG(info) << " TS " << std::setw( 12 ) << fulCurrentTsIdx - << " MS " << std::setw( 12 ) << fulCurrentMsIdx - << " DPB " << std::setw( 2 ) << fuCurrDpbIdx - << " Old TsMsb " << std::setw( 5 ) << fvulCurrentTsMsb[fuCurrDpbIdx] - << " Old MsbCy " << std::setw( 5 ) << fvuCurrentTsMsbCycle[fuCurrDpbIdx] - << " new TsMsb " << std::setw ( 5 ) << uVal; - - fvuCurrentTsMsbCycle[fuCurrDpbIdx] ++; - } // if( uVal < fvulCurrentTsMsb[fuCurrDpbIdx] ) - fvulCurrentTsMsb[fuCurrDpbIdx] = uVal; -/* - if( 1 < uMessIdx ) - { - fhStsDpbRawTsMsb->Fill( fuCurrDpbIdx, fvulCurrentTsMsb[fuCurrDpbIdx] ); - fhStsDpbRawTsMsbSx->Fill( fuCurrDpbIdx, ( fvulCurrentTsMsb[fuCurrDpbIdx] & 0x1F ) ); - fhStsDpbRawTsMsbDpb->Fill( fuCurrDpbIdx, ( fvulCurrentTsMsb[fuCurrDpbIdx] >> 5 ) ); - } // if( 0 < uMessIdx ) -*/ -// fhStsAsicTsMsb->Fill( fvulCurrentTsMsb[fuCurrDpbIdx], uAsicIdx ); - - ULong64_t ulNewTsMsbTime = static_cast< ULong64_t >( stsxyter::kuHitNbTsBins ) - * static_cast< ULong64_t >( fvulCurrentTsMsb[fuCurrDpbIdx]) - + static_cast< ULong64_t >( stsxyter::kulTsCycleNbBins ) - * static_cast< ULong64_t >( fvuCurrentTsMsbCycle[fuCurrDpbIdx] ); - - Double_t dUpdatePeriodInSec = 1; - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - Double_t dTimeInS = ( ulNewTsMsbTime - fvulStartTimeLastS[ uXyterIdx ] ) - * stsxyter::kdClockCycleNs - * 1e-9; - if( dUpdatePeriodInSec <= dTimeInS || (ulNewTsMsbTime < fvulStartTimeLastS[ uXyterIdx ] ) ) - { - UInt_t uNbHitsTotal = fvuNbHitDiffTsAsicLastS[ uXyterIdx ] + fvuNbHitSameTsAsicLastS[ uXyterIdx ]; - if( 0 < uNbHitsTotal && dTimeInS < 2 * dUpdatePeriodInSec ) - { - Double_t dRate = static_cast< Double_t >( uNbHitsTotal ) / dTimeInS; - Double_t dRatioSameTs = static_cast< Double_t >( fvuNbHitSameTsAsicLastS[ uXyterIdx ] ) - / uNbHitsTotal; - Double_t dRatioSameTsAdc = static_cast< Double_t >( fvuNbHitSameTsAdcAsicLastS[ uXyterIdx ] ) - / uNbHitsTotal; - Double_t dRatioSameAdcSameTs = static_cast< Double_t >( fvuNbHitSameTsAdcAsicLastS[ uXyterIdx ] ) - / fvuNbHitSameTsAsicLastS[ uXyterIdx ]; - - fhSetupSortedAsicRatioSameTsVsFlux[ uXyterIdx ]->Fill( dRate, dRatioSameTs ); - fhSetupSortedAsicRatioSameTsAdcVsFlux[ uXyterIdx ]->Fill( dRate, dRatioSameTsAdc ); - fhSetupSortedAsicRatioSameAdcSameTsVsFlux[ uXyterIdx ]->Fill( dRate, dRatioSameAdcSameTs ); -/* - LOG(info) << "Here we are " << dTimeInS - << " " << uNbHitsTotal - << " " << dRate; -*/ - } // if( 0 < uNbHitsTotal && dTimeInS < 2 * dUpdatePeriodInSec ) - - fvulStartTimeLastS[ uXyterIdx ] = ulNewTsMsbTime; - fvuNbHitDiffTsAsicLastS[ uXyterIdx ] = 0; - fvuNbHitSameTsAsicLastS[ uXyterIdx ] = 0; - fvuNbHitSameTsAdcAsicLastS[ uXyterIdx ] = 0; - } // if( dUpdatePeriodInSec <= dTimeInS || (ulNewTsMsbTime < fvulStartTimeLastS[ uXyterIdx ] ) ) - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) -} - -void CbmCosy2018MonitorSetup::FillEpochInfo( stsxyter::Message /*mess*/ ) -{ -// UInt_t uVal = mess.GetTsMsbVal(); -/* - // Update Status counters - if( usVal < fvulCurrentTsMsb[fuCurrDpbIdx] ) - fvuCurrentTsMsbCycle[fuCurrDpbIdx] ++; - fvulCurrentTsMsb[fuCurrDpbIdx] = usVal; - -// fhStsAsicTsMsb->Fill( fvulCurrentTsMsb[fuCurrDpbIdx], uAsicIdx ); -*/ -} - -void CbmCosy2018MonitorSetup::Reset() -{ -} - -void CbmCosy2018MonitorSetup::Finish() -{ - - LOG(info) << "-------------------------------------"; - LOG(info) << "CbmCosy2018MonitorSetup statistics are "; - LOG(info) << " Hit messages: " << fmMsgCounter[ stsxyter::MessType::Hit ] << "\n" - << " Ts MSB messages: " << fmMsgCounter[ stsxyter::MessType::TsMsb ] << "\n" - << " Dummy messages: " << fmMsgCounter[ stsxyter::MessType::Dummy ] << "\n" - << " Epoch messages: " << fmMsgCounter[ stsxyter::MessType::Epoch ] << "\n" - << " Empty messages: " << fmMsgCounter[ stsxyter::MessType::Empty ]; - - LOG(info) << "-------------------------------------"; - - SaveAllHistos( fsHistoFileFullname ); - SaveAllHistos(); - -} - - -void CbmCosy2018MonitorSetup::FillOutput(boost::any) -{ -} - -void CbmCosy2018MonitorSetup::SaveAllHistos( TString sFileName ) -{ - /*******************************************************************/ - TCanvas* cFebRatioDupli = new TCanvas( "cFebRatioDupli", - "Hodoscopes coincidence quality", - 800, 600); - cFebRatioDupli->Divide( 2, fuNbStsXyters/2 + fuNbStsXyters%2 ); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - cFebRatioDupli->cd(1 + uXyterIdx ); - gPad->SetLogz(); - fhSetupSortedNbSameTsChan[ uXyterIdx ]->Draw( "colz" ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - /*******************************************************************/ - - TDirectory * oldDir = NULL; - TFile * histoFile = NULL; - if( "" != sFileName ) - { - // Store current directory position to allow restore later - oldDir = gDirectory; - // open separate histo file in recreate mode - histoFile = new TFile( sFileName , "RECREATE"); - histoFile->cd(); - } // if( "" != sFileName ) - - gDirectory->mkdir("Sts_Raw"); - gDirectory->cd("Sts_Raw"); - - fhHodoMessType->Write(); - fhHodoSysMessType->Write(); - fhHodoMessTypePerDpb->Write(); - fhHodoSysMessTypePerDpb->Write(); - fhHodoMessTypePerElink->Write(); - fhHodoSysMessTypePerElink->Write(); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fhHodoChanCntRaw[ uXyterIdx ]->Write(); - fhHodoChanAdcRaw[ uXyterIdx ]->Write(); - fhHodoChanAdcRawProf[ uXyterIdx ]->Write(); - fhHodoChanRawTs[ uXyterIdx ]->Write(); - fhHodoChanMissEvt[ uXyterIdx ]->Write(); - fhHodoChanMissEvtEvo[ uXyterIdx ]->Write(); - fhHodoFebMissEvtEvo[ uXyterIdx ]->Write(); - fhHodoChanHitRateEvo[ uXyterIdx ]->Write(); - fhHodoFebRateEvo[ uXyterIdx ]->Write(); - fhHodoChanHitRateEvoLong[ uXyterIdx ]->Write(); - fhHodoFebRateEvoLong[ uXyterIdx ]->Write(); -/* - if( kTRUE == fbLongHistoEnable ) - { - fhFebRateEvoLong[ uXyterIdx ]->Write(); - fhFebChRateEvoLong[ uXyterIdx ]->Write(); - } // if( kTRUE == fbLongHistoEnable ) -*/ - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - - - fhSetupSortedDtX1Y1->Write(); - fhSetupSortedDtX2Y2->Write(); - fhSetupSortedDtN1P1->Write(); - fhSetupSortedDtN2P2->Write(); - fhSetupSortedDtX1Y1X2Y2->Write(); - fhSetupSortedDtN1P1N2P2->Write(); - fhSetupSortedDtX1Y1X2Y2N1P1->Write(); - fhSetupSortedDtX1Y1X2Y2N2P2->Write(); - fhSetupSortedDtH1H2S1S2->Write(); - fhSetupSortedMapX1Y1->Write(); - fhSetupSortedMapX2Y2->Write(); - fhSetupSortedMapN1P1->Write(); - fhSetupSortedMapN2P2->Write(); - fhSetupSortedCntEvoX1Y1->Write(); - fhSetupSortedCntEvoX2Y2->Write(); - fhSetupSortedCntEvoN1P1->Write(); - fhSetupSortedCntEvoN2P2->Write(); - - fhBothHodoSortedDtX1Y1->Write(); - fhBothHodoSortedDtX2Y2->Write(); - fhBothHodoSortedDtX1Y1X2Y2N1P1->Write(); - fhBothHodoSortedDtX1Y1X2Y2N2P2->Write(); - fhBothHodoSortedDtH1H2S1S2->Write(); - fhBothHodoSortedMapX1Y1->Write(); - fhBothHodoSortedMapX2Y2->Write(); - fhBothHodoSortedCntEvoX1Y1->Write(); - fhBothHodoSortedCntEvoX2Y2->Write(); - - fhH1H2S1SortedDtX1Y1->Write(); - fhH1H2S1SortedDtX2Y2->Write(); - fhH1H2S1SortedDtN1P1->Write(); - fhH1H2S1SortedDtN2P2->Write(); - fhH1H2S1SortedMapX1Y1->Write(); - fhH1H2S1SortedMapX2Y2->Write(); - fhH1H2S1SortedMapN1P1->Write(); - fhH1H2S1SortedMapN2P2->Write(); - fhH1H2S1SortedCntEvoX1Y1->Write(); - fhH1H2S1SortedCntEvoX2Y2->Write(); - fhH1H2S1SortedCntEvoN1P1->Write(); - fhH1H2S1SortedCntEvoN2P2->Write(); - - fhH1H2S2SortedDtX1Y1->Write(); - fhH1H2S2SortedDtX2Y2->Write(); - fhH1H2S2SortedDtN1P1->Write(); - fhH1H2S2SortedDtN2P2->Write(); - fhH1H2S2SortedMapX1Y1->Write(); - fhH1H2S2SortedMapX2Y2->Write(); - fhH1H2S2SortedMapN1P1->Write(); - fhH1H2S2SortedMapN2P2->Write(); - fhH1H2S2SortedCntEvoX1Y1->Write(); - fhH1H2S2SortedCntEvoX2Y2->Write(); - fhH1H2S2SortedCntEvoN1P1->Write(); - fhH1H2S2SortedCntEvoN2P2->Write(); - - fhSystSortedDtX1Y1->Write(); - fhSystSortedDtX2Y2->Write(); - fhSystSortedDtN1P1->Write(); - fhSystSortedDtN2P2->Write(); - fhSystSortedDtX1Y1X2Y2 ->Write(); - fhSystSortedMapX1Y1->Write(); - fhSystSortedMapX2Y2->Write(); - fhSystSortedMapN1P1->Write(); - fhSystSortedMapN2P2->Write(); - fhSystSortedCntEvoX1Y1->Write(); - fhSystSortedCntEvoX2Y2->Write(); - fhSystSortedCntEvoN1P1->Write(); - fhSystSortedCntEvoN2P2->Write(); - - fhSystSortedDtN1X1vsN1X2->Write(); - fhSystSortedDtP1X1vsP1X2->Write(); - fhSystSortedDtN1X1vsP1X1->Write(); - fhSystSortedDtSts1Hodo1vsSts1Hodo2->Write(); - fhSystSortedDtSts2Hodo1vsSts2Hodo2->Write(); - fhSystSortedDtAllVsMapX1->Write(); - fhSystSortedDtAllVsMapY1->Write(); - fhSystSortedDtAllVsMapX2->Write(); - fhSystSortedDtAllVsMapY2->Write(); - - fhSetupSortedDtX1->Write(); - fhSetupSortedDtY1->Write(); - fhSetupSortedDtX2->Write(); - fhSetupSortedDtY2->Write(); - fhSetupSortedDtN1->Write(); - fhSetupSortedDtP1->Write(); - fhSetupSortedDtN2->Write(); - fhSetupSortedDtP2->Write(); - - gDirectory->cd(".."); - - gDirectory->mkdir("Sts_Dupli"); - gDirectory->cd("Sts_Dupli"); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fhSetupSortedNbSameTsChan[ uXyterIdx ]->Write(); - fhSetupSortedSameTsAdcChan[ uXyterIdx ]->Write(); - fhSetupSortedSameTsAdcDiff[ uXyterIdx ]->Write(); - fhSetupSortedRatioSameTsChan[ uXyterIdx ]->Write(); - fhSetupSortedNbConsSameTsChan[ uXyterIdx ]->Write(); - fhSetupSortedNbConsSameTsAdcChan[ uXyterIdx ]->Write(); - fhSetupSortedNbConsSameTsVsTsAdc[ uXyterIdx ]->Write(); - - fhSetupSortedAsicRatioSameTsVsFlux[ uXyterIdx ]->Write(); - fhSetupSortedAsicRatioSameTsAdcVsFlux[ uXyterIdx ]->Write(); - fhSetupSortedAsicRatioSameAdcSameTsVsFlux[ uXyterIdx ]->Write(); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - - cFebRatioDupli->Write(); - - gDirectory->cd(".."); - - // Flib Histos - gDirectory->mkdir("Flib_Raw"); - gDirectory->cd("Flib_Raw"); - for( UInt_t uLinks = 0; uLinks < kiMaxNbFlibLinks; uLinks ++) - { - TString sMsSzName = Form("MsSz_link_%02u", uLinks); - if( fHM->Exists(sMsSzName.Data() ) ) - fHM->H1( sMsSzName.Data() )->Write(); - - sMsSzName = Form("MsSzTime_link_%02u", uLinks); - if( fHM->Exists(sMsSzName.Data() ) ) - fHM->P1( sMsSzName.Data() )->Write(); - } // for( UInt_t uLinks = 0; uLinks < 16; uLinks ++) - - TH1 * pMissedTsH1 = dynamic_cast< TH1 * >( gROOT->FindObjectAny( "Missed_TS" ) ); - if( NULL != pMissedTsH1 ) - pMissedTsH1->Write(); - - TProfile * pMissedTsEvoP = dynamic_cast< TProfile * >( gROOT->FindObjectAny( "Missed_TS_Evo" ) ); - if( NULL != pMissedTsEvoP ) - pMissedTsEvoP->Write(); - - gDirectory->cd(".."); - - if( "" != sFileName ) - { - // Restore original directory position - histoFile->Close(); - oldDir->cd(); - } // if( "" != sFileName ) - -} -void CbmCosy2018MonitorSetup::ResetAllHistos() -{ - LOG(info) << "Reseting all STS histograms."; - - fhHodoMessType->Reset(); - fhHodoSysMessType->Reset(); - fhHodoMessTypePerDpb->Reset(); - fhHodoSysMessTypePerDpb->Reset(); - fhHodoMessTypePerElink->Reset(); - fhHodoSysMessTypePerElink->Reset(); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fhHodoChanCntRaw[ uXyterIdx ]->Reset(); - fhHodoChanAdcRaw[ uXyterIdx ]->Reset(); - fhHodoChanAdcRawProf[ uXyterIdx ]->Reset(); - fhHodoChanRawTs[ uXyterIdx ]->Reset(); - fhHodoChanMissEvt[ uXyterIdx ]->Reset(); - fhHodoChanMissEvtEvo[ uXyterIdx ]->Reset(); - fhHodoFebMissEvtEvo[ uXyterIdx ]->Reset(); - fhHodoChanHitRateEvo[ uXyterIdx ]->Reset(); - fhHodoFebRateEvo[ uXyterIdx ]->Reset(); - fhHodoChanHitRateEvoLong[ uXyterIdx ]->Reset(); - fhHodoFebRateEvoLong[ uXyterIdx ]->Reset(); -/* - if( kTRUE == fbLongHistoEnable ) - { - ftStartTimeUnix = std::chrono::steady_clock::now(); - fhFebRateEvoLong[ uXyterIdx ]->Reset(); - fhFebChRateEvoLong[ uXyterIdx ]->Reset(); - } // if( kTRUE == fbLongHistoEnable ) -*/ - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - - fhSetupSortedDtX1Y1->Reset(); - fhSetupSortedDtX2Y2->Reset(); - fhSetupSortedDtN1P1->Reset(); - fhSetupSortedDtN2P2->Reset(); - fhSetupSortedDtX1Y1X2Y2->Reset(); - fhSetupSortedDtN1P1N2P2->Reset(); - fhSetupSortedDtX1Y1X2Y2N1P1->Reset(); - fhSetupSortedDtX1Y1X2Y2N2P2->Reset(); - fhSetupSortedDtH1H2S1S2->Reset(); - fhSetupSortedMapX1Y1->Reset(); - fhSetupSortedMapX2Y2->Reset(); - fhSetupSortedMapN1P1->Reset(); - fhSetupSortedMapN2P2->Reset(); - fhSetupSortedCntEvoX1Y1->Reset(); - fhSetupSortedCntEvoX2Y2->Reset(); - fhSetupSortedCntEvoN1P1->Reset(); - fhSetupSortedCntEvoN2P2->Reset(); - - fhBothHodoSortedDtX1Y1->Reset(); - fhBothHodoSortedDtX2Y2->Reset(); - fhBothHodoSortedDtX1Y1X2Y2N1P1->Reset(); - fhBothHodoSortedDtX1Y1X2Y2N2P2->Reset(); - fhBothHodoSortedDtH1H2S1S2->Reset(); - fhBothHodoSortedMapX1Y1->Reset(); - fhBothHodoSortedMapX2Y2->Reset(); - fhBothHodoSortedCntEvoX1Y1->Reset(); - fhBothHodoSortedCntEvoX2Y2->Reset(); - - fhH1H2S1SortedDtX1Y1->Reset(); - fhH1H2S1SortedDtX2Y2->Reset(); - fhH1H2S1SortedDtN1P1->Reset(); - fhH1H2S1SortedDtN2P2->Reset(); - fhH1H2S1SortedMapX1Y1->Reset(); - fhH1H2S1SortedMapX2Y2->Reset(); - fhH1H2S1SortedMapN1P1->Reset(); - fhH1H2S1SortedMapN2P2->Reset(); - fhH1H2S1SortedCntEvoX1Y1->Reset(); - fhH1H2S1SortedCntEvoX2Y2->Reset(); - fhH1H2S1SortedCntEvoN1P1->Reset(); - fhH1H2S1SortedCntEvoN2P2->Reset(); - - fhH1H2S2SortedDtX1Y1->Reset(); - fhH1H2S2SortedDtX2Y2->Reset(); - fhH1H2S2SortedDtN1P1->Reset(); - fhH1H2S2SortedDtN2P2->Reset(); - fhH1H2S2SortedMapX1Y1->Reset(); - fhH1H2S2SortedMapX2Y2->Reset(); - fhH1H2S2SortedMapN1P1->Reset(); - fhH1H2S2SortedMapN2P2->Reset(); - fhH1H2S2SortedCntEvoX1Y1->Reset(); - fhH1H2S2SortedCntEvoX2Y2->Reset(); - fhH1H2S2SortedCntEvoN1P1->Reset(); - fhH1H2S2SortedCntEvoN2P2->Reset(); - - fhSystSortedDtX1Y1->Reset(); - fhSystSortedDtX2Y2->Reset(); - fhSystSortedDtN1P1->Reset(); - fhSystSortedDtN2P2->Reset(); - fhSystSortedDtX1Y1X2Y2 ->Reset(); - fhSystSortedMapX1Y1->Reset(); - fhSystSortedMapX2Y2->Reset(); - fhSystSortedMapN1P1->Reset(); - fhSystSortedMapN2P2->Reset(); - fhSystSortedCntEvoX1Y1->Reset(); - fhSystSortedCntEvoX2Y2->Reset(); - fhSystSortedCntEvoN1P1->Reset(); - fhSystSortedCntEvoN2P2->Reset(); - - fhSystSortedDtN1X1vsN1X2->Reset(); - fhSystSortedDtP1X1vsP1X2->Reset(); - fhSystSortedDtN1X1vsP1X1->Reset(); - fhSystSortedDtSts1Hodo1vsSts1Hodo2->Reset(); - fhSystSortedDtSts2Hodo1vsSts2Hodo2->Reset(); - fhSystSortedDtAllVsMapX1->Reset(); - fhSystSortedDtAllVsMapY1->Reset(); - fhSystSortedDtAllVsMapX2->Reset(); - fhSystSortedDtAllVsMapY2->Reset(); - - fhSetupSortedDtX1->Reset(); - fhSetupSortedDtY1->Reset(); - fhSetupSortedDtX2->Reset(); - fhSetupSortedDtY2->Reset(); - fhSetupSortedDtN1->Reset(); - fhSetupSortedDtP1->Reset(); - fhSetupSortedDtN2->Reset(); - fhSetupSortedDtP2->Reset(); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fhSetupSortedNbSameTsChan[ uXyterIdx ]->Reset(); - fhSetupSortedSameTsAdcChan[ uXyterIdx ]->Reset(); - fhSetupSortedSameTsAdcDiff[ uXyterIdx ]->Reset(); - fhSetupSortedRatioSameTsChan[ uXyterIdx ]->Reset(); - fhSetupSortedNbConsSameTsChan[ uXyterIdx ]->Reset(); - fhSetupSortedNbConsSameTsAdcChan[ uXyterIdx ]->Reset(); - fhSetupSortedNbConsSameTsVsTsAdc[ uXyterIdx ]->Reset(); - - fhSetupSortedAsicRatioSameTsVsFlux[ uXyterIdx ]->Reset(); - fhSetupSortedAsicRatioSameTsAdcVsFlux[ uXyterIdx ]->Reset(); - fhSetupSortedAsicRatioSameAdcSameTsVsFlux[ uXyterIdx ]->Reset(); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - - for( UInt_t uLinks = 0; uLinks < kiMaxNbFlibLinks; ++uLinks ) - { - TString sMsSzName = Form("MsSz_link_%02u", uLinks); - if( fHM->Exists(sMsSzName.Data() ) ) - fHM->H1( sMsSzName.Data() )->Reset(); - - sMsSzName = Form("MsSzTime_link_%02u", uLinks); - if( fHM->Exists(sMsSzName.Data() ) ) - fHM->P1( sMsSzName.Data() )->Reset(); - } // for( UInt_t uLinks = 0; uLinks < kiMaxNbFlibLinks; ++uLinks ) - - fdStartTime = -1; - fdStartTimeMsSz = -1; -} - -void CbmCosy2018MonitorSetup::SetRunStart( Int_t dateIn, Int_t timeIn, Int_t iBinSize ) -{ - TDatime * fRunStartDateTime = new TDatime( dateIn, timeIn); - fiRunStartDateTimeSec = fRunStartDateTime->Convert(); - fiBinSizeDatePlots = iBinSize; - - LOG(info) << "Assigned new MUCH Run Start Date-Time: " << fRunStartDateTime->AsString(); -} - -void CbmCosy2018MonitorSetup::SetLongDurationLimits( UInt_t uDurationSeconds, UInt_t uBinSize ) -{ - fbLongHistoEnable = kTRUE; - fuLongHistoNbSeconds = uDurationSeconds; - fuLongHistoBinSizeSec = uBinSize; -} - -ClassImp(CbmCosy2018MonitorSetup) diff --git a/beamtime/cosy2018/unpacker/CbmCosy2018MonitorSetup.h b/beamtime/cosy2018/unpacker/CbmCosy2018MonitorSetup.h deleted file mode 100644 index 22dc2a69cdb0843704f92eee9c3349d6a2c2c334..0000000000000000000000000000000000000000 --- a/beamtime/cosy2018/unpacker/CbmCosy2018MonitorSetup.h +++ /dev/null @@ -1,315 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmCosy2018MonitorSetup ----- -// ----- Created 27/02/18 by P.-A. Loizeau ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CBMCOSY2018MONITORSETUP_H -#define CBMCOSY2018MONITORSETUP_H - -#include "Timeslice.hpp" - -// Data -#include "StsXyterMessage.h" -#include "StsXyterFinalHit.h" - -// CbmRoot -#include "CbmTSUnpack.h" -#include "CbmHistManager.h" - -// C++11 -#include <chrono> - -// C/C++ -#include <vector> -#include <set> -#include <map> - -class CbmCern2017UnpackParHodo; -class CbmCern2017UnpackParSts; - -class CbmCosy2018MonitorSetup: public CbmTSUnpack -{ -public: - - CbmCosy2018MonitorSetup(); - virtual ~CbmCosy2018MonitorSetup(); - - virtual Bool_t Init(); - - virtual Bool_t DoUnpack(const fles::Timeslice& ts, size_t component); - - virtual void Reset(); - - virtual void Finish(); - - void SetParContainers(); - - Bool_t InitContainers(); - - Bool_t ReInitContainers(); - - void FillOutput(boost::any); - - void SetRunStart( Int_t dateIn, Int_t timeIn, Int_t iBinSize = 5 ); - - void ResetAllHistos(); - void SaveAllHistos( TString sFileName = "" ); - void SetHistoFileName( TString sFileName = "data/SetupHistos.root" ) { fsHistoFileFullname = sFileName; } - - void SetMsOverlap(size_t uOverlapMsNb = 1) { fuOverlapMsNb = uOverlapMsNb; } - size_t GetMsOverlap() { return fuOverlapMsNb; } - - void SetPrintMessage( Bool_t bPrintMessOn = kTRUE, - stsxyter::MessagePrintMask ctrl = stsxyter::MessagePrintMask::msg_print_Hex | - stsxyter::MessagePrintMask::msg_print_Human ) - { fbPrintMessages = bPrintMessOn; fPrintMessCtrl = ctrl; } - void EnableDualStsMode( Bool_t bEnable = kTRUE ) { fbDualStsEna = bEnable; } - void SetLongDurationLimits( UInt_t uDurationSeconds = 3600, UInt_t uBinSize = 1 ); - void SetCoincidenceBorderHodo( Double_t dNewValue ){ fdCoincBorderHodo = dNewValue;} - void SetCoincidenceBorderSts( Double_t dNewValue ){ fdCoincBorderSts = dNewValue;} - void SetCoincidenceBorder( Double_t dNewValue ){ fdCoincBorder = dNewValue;} - -private: - size_t fuOverlapMsNb; /** Ignore Overlap Ms: all fuOverlapMsNb MS at the end of timeslice **/ - - // Parameters - CbmCern2017UnpackParHodo* fUnpackParHodo; //! - CbmCern2017UnpackParSts* fUnpackParSts; //! - UInt_t fuNrOfDpbs; //! Total number of Sts DPBs in system - std::map<UInt_t, UInt_t> fDpbIdIndexMap; //! Map of DPB Identifier to DPB index - UInt_t fuNbElinksPerDpb; //! Number of possible eLinks per DPB - UInt_t fuNbStsXyters; //! Number of StsXyter ASICs - UInt_t fuNbChanPerAsic; //! Number of channels per StsXyter ASIC => should be constant somewhere!!!! - std::vector< std::vector< UInt_t > > fvuElinkToAsic; //! Vector holding for each link the corresponding ASIC index [fuNrOfDpbs * fuNbElinksPerDpb] - - // Constants - static const Int_t kiMaxNbFlibLinks = 16; - static const UInt_t kuBytesPerMessage = 4; - - // Internal Control/status of monitor - // Histo File name and path - TString fsHistoFileFullname; - // Task configuration values - Bool_t fbPrintMessages; - stsxyter::MessagePrintMask fPrintMessCtrl; - Bool_t fbDualStsEna; - // TS/MS info - ULong64_t fulCurrentTsIdx; - ULong64_t fulCurrentMsIdx; - // Current data properties - std::map< stsxyter::MessType, UInt_t > fmMsgCounter; - UInt_t fuCurrentEquipmentId; //! Current equipment ID, tells from which DPB the current MS is originating - UInt_t fuCurrDpbId; //! Temp holder until Current equipment ID is properly filled in MS - UInt_t fuCurrDpbIdx; //! Index of the DPB from which the MS currently unpacked is coming - Int_t fiRunStartDateTimeSec; //! Start of run time since "epoch" in s, for the plots with date as X axis - Int_t fiBinSizeDatePlots; //! Bin size in s for the plots with date as X axis - - // Data format control - std::vector< ULong64_t > fvulCurrentTsMsb; //! Current TS MSB for each DPB - std::vector< UInt_t > fvuCurrentTsMsbCycle; //! Current TS MSB cycle for DPB - std::vector< UInt_t > fvuElinkLastTsHit; //! TS from last hit for DPB - // Hits comparison - std::vector< std::vector< ULong64_t > > fvulChanLastHitTime; //! Last hit time in bins for each Channel - std::vector< std::vector< Double_t > > fvdChanLastHitTime; //! Last hit time in ns for each Channel - std::vector< Double_t > fvdMsTime; //! Header time of each MS - std::vector< std::vector< std::vector< UInt_t > > > fvuChanNbHitsInMs; //! Number of hits in each MS for each Channel - std::vector< std::vector< std::vector< Double_t > > > fvdChanLastHitTimeInMs; //! Last hit time in bins in each MS for each Channel - std::vector< std::vector< std::vector< UShort_t > > > fvusChanLastHitAdcInMs; //! Last hit ADC in bins in each MS for each Channel -// std::vector< std::vector< std::multiset< stsxyter::FinalHit > > > fvmChanHitsInTs; //! All hits (time & ADC) in bins in last TS for each Channel - // Starting state book-keeping - Double_t fdStartTime; /** Time of first valid hit (TS_MSB available), used as reference for evolution plots**/ - Double_t fdStartTimeMsSz; /** Time of first microslice, used as reference for evolution plots**/ - std::chrono::steady_clock::time_point ftStartTimeUnix; /** Time of run Start from UNIX system, used as reference for long evolution plots against reception time **/ - - // Hits time-sorting - std::vector< stsxyter::FinalHit > fvmHitsInTs; //! All hits (time in bins, ADC in bins, asic, channel) in last TS, sorted by multiset with "<" operator - stsxyter::FinalHit fLastSortedHit1X; //! Last sorted hit for Hodo 1 X - stsxyter::FinalHit fLastSortedHit1Y; //! Last sorted hit for Hodo 1 Y - stsxyter::FinalHit fLastSortedHit2X; //! Last sorted hit for Hodo 2 X - stsxyter::FinalHit fLastSortedHit2Y; //! Last sorted hit for Hodo 2 Y - stsxyter::FinalHit fLastSortedHit1N; //! Last sorted hit for STS 1 N - stsxyter::FinalHit fLastSortedHit1P; //! Last sorted hit for STS 1 P - stsxyter::FinalHit fLastSortedHit2N; //! Last sorted hit for STS 2 N - stsxyter::FinalHit fLastSortedHit2P; //! Last sorted hit for STS 2 P - // Coincidence histos - UInt_t fuMaxNbMicroslices; - // Rate evolution histos - Bool_t fbLongHistoEnable; - UInt_t fuLongHistoNbSeconds; - UInt_t fuLongHistoBinSizeSec; - UInt_t fuLongHistoBinNb; - - // Histograms - CbmHistManager* fHM; //! Histogram manager - TH1* fhHodoMessType; - TH1* fhHodoSysMessType; - TH2* fhHodoMessTypePerDpb; - TH2* fhHodoSysMessTypePerDpb; -/* - TH2* fhStsDpbRawTsMsb; - TH2* fhStsDpbRawTsMsbSx; - TH2* fhStsDpbRawTsMsbDpb; -*/ - TH2* fhHodoMessTypePerElink; - TH2* fhHodoSysMessTypePerElink; - - std::vector<TH1 *> fhHodoChanCntRaw; - std::vector<TH2 *> fhHodoChanAdcRaw; - std::vector<TProfile*> fhHodoChanAdcRawProf; - std::vector<TH2*> fhHodoChanRawTs; - std::vector<TH2*> fhHodoChanMissEvt; - std::vector<TH2*> fhHodoChanMissEvtEvo; - std::vector<TH2*> fhHodoChanHitRateEvo; - std::vector<TH1*> fhHodoFebRateEvo; - std::vector<TH1*> fhHodoFebMissEvtEvo; - std::vector<TH2*> fhHodoChanHitRateEvoLong; - std::vector<TH1*> fhHodoFebRateEvoLong; - - // Coincidences in sorted hits - Double_t fdCoincBorderHodo; // ns, +/- - Double_t fdCoincBorderSts; // ns, +/- - Double_t fdCoincBorder; // ns, +/- - // Single detector maps - TH1 * fhSetupSortedDtX1Y1; - TH1 * fhSetupSortedDtX2Y2; - TH1 * fhSetupSortedDtN1P1; - TH1 * fhSetupSortedDtN2P2; - TH1 * fhSetupSortedDtX1Y1X2Y2; - TH1 * fhSetupSortedDtN1P1N2P2; - TH1 * fhSetupSortedDtX1Y1X2Y2N1P1; - TH1 * fhSetupSortedDtX1Y1X2Y2N2P2; - TH1 * fhSetupSortedDtH1H2S1S2; - TH2 * fhSetupSortedMapX1Y1; - TH2 * fhSetupSortedMapX2Y2; - TH2 * fhSetupSortedMapN1P1; - TH2 * fhSetupSortedMapN2P2; - TH1 * fhSetupSortedCntEvoX1Y1; - TH1 * fhSetupSortedCntEvoX2Y2; - TH1 * fhSetupSortedCntEvoN1P1; - TH1 * fhSetupSortedCntEvoN2P2; - - // Full Hodo maps - TH1 * fhBothHodoSortedDtX1Y1; - TH1 * fhBothHodoSortedDtX2Y2; - TH1 * fhBothHodoSortedDtX1Y1X2Y2N1P1; - TH1 * fhBothHodoSortedDtX1Y1X2Y2N2P2; - TH1 * fhBothHodoSortedDtH1H2S1S2; - TH2 * fhBothHodoSortedMapX1Y1; - TH2 * fhBothHodoSortedMapX2Y2; - TH1 * fhBothHodoSortedCntEvoX1Y1; - TH1 * fhBothHodoSortedCntEvoX2Y2; - - // H + Sn maps - TH1 * fhH1H2S1SortedDtX1Y1; - TH1 * fhH1H2S1SortedDtX2Y2; - TH1 * fhH1H2S1SortedDtN1P1; - TH1 * fhH1H2S1SortedDtN2P2; - TH2 * fhH1H2S1SortedMapX1Y1; - TH2 * fhH1H2S1SortedMapX2Y2; - TH2 * fhH1H2S1SortedMapN1P1; - TH2 * fhH1H2S1SortedMapN2P2; - TH1 * fhH1H2S1SortedCntEvoX1Y1; - TH1 * fhH1H2S1SortedCntEvoX2Y2; - TH1 * fhH1H2S1SortedCntEvoN1P1; - TH1 * fhH1H2S1SortedCntEvoN2P2; - - TH1 * fhH1H2S2SortedDtX1Y1; - TH1 * fhH1H2S2SortedDtX2Y2; - TH1 * fhH1H2S2SortedDtN1P1; - TH1 * fhH1H2S2SortedDtN2P2; - TH2 * fhH1H2S2SortedMapX1Y1; - TH2 * fhH1H2S2SortedMapX2Y2; - TH2 * fhH1H2S2SortedMapN1P1; - TH2 * fhH1H2S2SortedMapN2P2; - TH1 * fhH1H2S2SortedCntEvoX1Y1; - TH1 * fhH1H2S2SortedCntEvoX2Y2; - TH1 * fhH1H2S2SortedCntEvoN1P1; - TH1 * fhH1H2S2SortedCntEvoN2P2; - - // Full System maps - TH1 * fhSystSortedDtX1Y1; - TH1 * fhSystSortedDtX2Y2; - TH1 * fhSystSortedDtN1P1; - TH1 * fhSystSortedDtN2P2; - TH1 * fhSystSortedDtX1Y1X2Y2; - TH2 * fhSystSortedMapX1Y1; - TH2 * fhSystSortedMapX2Y2; - TH2 * fhSystSortedMapN1P1; - TH2 * fhSystSortedMapN2P2; - TH1 * fhSystSortedCntEvoX1Y1; - TH1 * fhSystSortedCntEvoX2Y2; - TH1 * fhSystSortedCntEvoN1P1; - TH1 * fhSystSortedCntEvoN2P2; - - TH2 * fhSystSortedDtN1X1vsN1X2; - TH2 * fhSystSortedDtP1X1vsP1X2; - TH2 * fhSystSortedDtN1X1vsP1X1; - TH2 * fhSystSortedDtSts1Hodo1vsSts1Hodo2; - TH2 * fhSystSortedDtSts2Hodo1vsSts2Hodo2; - TH2 * fhSystSortedDtAllVsMapX1; - TH2 * fhSystSortedDtAllVsMapY1; - TH2 * fhSystSortedDtAllVsMapX2; - TH2 * fhSystSortedDtAllVsMapY2; - - TH1 * fhSetupSortedDtX1; - TH1 * fhSetupSortedDtY1; - TH1 * fhSetupSortedDtX2; - TH1 * fhSetupSortedDtY2; - TH1 * fhSetupSortedDtN1; - TH1 * fhSetupSortedDtP1; - TH1 * fhSetupSortedDtN2; - TH1 * fhSetupSortedDtP2; - - /// Counting hits without proper timestamp - std::vector< std::vector< ULong64_t > > fvulTimeLastHitAsicChan; - std::vector< std::vector< Int_t > > fviAdcLastHitAsicChan; - std::vector< std::vector< UInt_t > > fvuNbSameHitAsicChan; - std::vector< std::vector< UInt_t > > fvuNbSameFullHitAsicChan; - - std::vector< ULong64_t > fvulStartTimeLastS; - std::vector< UInt_t > fvuNbHitDiffTsAsicLastS; - std::vector< UInt_t > fvuNbHitSameTsAsicLastS; - std::vector< UInt_t > fvuNbHitSameTsAdcAsicLastS; - - std::vector< TH2 * > fhSetupSortedNbSameTsChan; - std::vector< TH2 * > fhSetupSortedSameTsAdcChan; - std::vector< TH2 * > fhSetupSortedSameTsAdcDiff; - std::vector< TProfile2D * > fhSetupSortedRatioSameTsChan; - std::vector< TH2 * > fhSetupSortedNbConsSameTsChan; - std::vector< TH2 * > fhSetupSortedNbConsSameTsAdcChan; - std::vector< TH2 * > fhSetupSortedNbConsSameTsVsTsAdc; - - std::vector< TH2 * > fhSetupSortedAsicRatioSameTsVsFlux; - std::vector< TH2 * > fhSetupSortedAsicRatioSameTsAdcVsFlux; - std::vector< TH2 * > fhSetupSortedAsicRatioSameAdcSameTsVsFlux; - - TH2 * fhHodoX1SpillEvo; - TH2 * fhHodoY1SpillEvo; - TH2 * fhHodoX2SpillEvo; - TH2 * fhHodoY2SpillEvo; - - Double_t fdSpillEvoLength; - TProfile * fhHodoX1SpillEvoProf; - TProfile * fhHodoY1SpillEvoProf; - TProfile * fhHodoX2SpillEvoProf; - TProfile * fhHodoY2SpillEvoProf; - - TCanvas* fcMsSizeAll; - TH1* fhMsSz[kiMaxNbFlibLinks]; - TProfile* fhMsSzTime[kiMaxNbFlibLinks]; - - void CreateHistograms(); - - void FillHitInfo( stsxyter::Message mess, const UShort_t & usElinkIdx, const UInt_t & uAsicIdx, const UInt_t & uMsIdx ); - void FillTsMsbInfo( stsxyter::Message mess, UInt_t uMessIdx = 0, UInt_t uMsIdx = 0); - void FillEpochInfo( stsxyter::Message mess ); - - CbmCosy2018MonitorSetup(const CbmCosy2018MonitorSetup&); - CbmCosy2018MonitorSetup operator=(const CbmCosy2018MonitorSetup&); - - ClassDef(CbmCosy2018MonitorSetup, 1) -}; - -#endif // CBMCOSY2018MONITORSETUP_H diff --git a/beamtime/cosy2018/unpacker/CbmCosy2018MonitorSetupGood.cxx b/beamtime/cosy2018/unpacker/CbmCosy2018MonitorSetupGood.cxx deleted file mode 100644 index 373a9570135d74b0686b7e72bc4a9b1e5fc860a2..0000000000000000000000000000000000000000 --- a/beamtime/cosy2018/unpacker/CbmCosy2018MonitorSetupGood.cxx +++ /dev/null @@ -1,3947 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmCosy2018MonitorSetupGood ----- -// ----- Created 27/02/18 by P.-A. Loizeau ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#include "CbmCosy2018MonitorSetupGood.h" - -// Data - -// CbmRoot -#include "CbmCern2017UnpackParHodo.h" -#include "CbmCern2017UnpackParSts.h" -#include "CbmHistManager.h" - -// FairRoot -#include "FairLogger.h" -#include "FairRootManager.h" -#include "FairRun.h" -#include "FairRuntimeDb.h" -#include "FairRunOnline.h" - -// Root -#include "TClonesArray.h" -#include "TString.h" -#include "TRandom.h" -#include "THttpServer.h" -#include "TROOT.h" -#include "TStyle.h" -#include "TMath.h" -#include <TFile.h> - -// C++11 - -// C/C++ -#include <iostream> -#include <stdint.h> -#include <iomanip> - -Bool_t bCosy2018ResetSetupHistosGood = kFALSE; -Bool_t bCosy2018WriteSetupHistosGood = kFALSE; - -CbmCosy2018MonitorSetupGood::CbmCosy2018MonitorSetupGood() : - CbmTSUnpack(), - fuOverlapMsNb(0), - fUnpackParHodo(NULL), - fUnpackParSts(NULL), - fuNrOfDpbs(0), - fDpbIdIndexMap(), - fuNbElinksPerDpb(0), - fuNbStsXyters(0), - fuNbChanPerAsic(0), - fvuElinkToAsic(), - fsHistoFileFullname( "data/SetupHistos.root" ), - fbPrintMessages( kFALSE ), - fPrintMessCtrl( stsxyter::MessagePrintMask::msg_print_Human ), - fbDualStsEna( kFALSE ), - fulCurrentTsIdx( 0 ), - fulCurrentMsIdx( 0 ), - fmMsgCounter(), - fuCurrentEquipmentId(0), - fuCurrDpbId(0), - fuCurrDpbIdx(0), - fiRunStartDateTimeSec(-1), - fiBinSizeDatePlots(-1), - fvulCurrentTsMsb(), - fvuCurrentTsMsbCycle(), - fvuElinkLastTsHit(), - fvulChanLastHitTime(), - fvdChanLastHitTime(), - fvdMsTime(), - fvuChanNbHitsInMs(), - fvdChanLastHitTimeInMs(), - fvusChanLastHitAdcInMs(), -// fvmChanHitsInTs(), - fdStartTime(-1.0), - fdStartTimeMsSz(-1.0), - ftStartTimeUnix( std::chrono::steady_clock::now() ), - fvmHitsInTs(), - fLastSortedHit1X(), - fLastSortedHit1Y(), - fLastSortedHit2X(), - fLastSortedHit2Y(), - fLastSortedHit1N(), - fLastSortedHit1P(), - fLastSortedHit2N(), - fLastSortedHit2P(), - fuMaxNbMicroslices(100), - fbLongHistoEnable( kFALSE ), - fuLongHistoNbSeconds( 0 ), - fuLongHistoBinSizeSec( 0 ), - fuLongHistoBinNb( 0 ), - fHM(new CbmHistManager()), - fhHodoMessType(NULL), - fhHodoSysMessType(NULL), - fhHodoMessTypePerDpb(NULL), - fhHodoSysMessTypePerDpb(NULL), - fhHodoMessTypePerElink(NULL), - fhHodoSysMessTypePerElink(NULL), - fhHodoChanCntRaw(), - fhHodoChanAdcRaw(), - fhHodoChanAdcRawProf(), - fhHodoChanRawTs(), - fhHodoChanMissEvt(), - fhHodoChanMissEvtEvo(), - fhHodoChanHitRateEvo(), - fhHodoFebRateEvo(), - fhHodoFebMissEvtEvo(), - fhHodoChanHitRateEvoLong(), - fhHodoFebRateEvoLong(), - fdCoincBorderHodo( 50.0 ), - fdCoincBorderSts( 75.0 ), - fdCoincBorder( 150.0 ), - fhSetupSortedDtX1Y1(NULL), - fhSetupSortedDtX2Y2(NULL), - fhSetupSortedDtN1P1(NULL), - fhSetupSortedDtN2P2(NULL), - fhSetupSortedDtX1Y1X2Y2(NULL), - fhSetupSortedDtN1P1N2P2(NULL), - fhSetupSortedDtX1Y1X2Y2N1P1(NULL), - fhSetupSortedDtX1Y1X2Y2N2P2(NULL), - fhSetupSortedDtH1H2S1S2(NULL), - fhSetupSortedMapX1Y1(NULL), - fhSetupSortedMapX2Y2(NULL), - fhSetupSortedMapN1P1(NULL), - fhSetupSortedMapN2P2(NULL), - fhSetupSortedCntEvoX1Y1(NULL), - fhSetupSortedCntEvoX2Y2(NULL), - fhSetupSortedCntEvoN1P1(NULL), - fhSetupSortedCntEvoN2P2(NULL), - fhBothHodoSortedDtX1Y1(NULL), - fhBothHodoSortedDtX2Y2(NULL), - fhBothHodoSortedDtX1Y1X2Y2N1P1(NULL), - fhBothHodoSortedDtX1Y1X2Y2N2P2(NULL), - fhBothHodoSortedDtH1H2S1S2(NULL), - fhBothHodoSortedMapX1Y1(NULL), - fhBothHodoSortedMapX2Y2(NULL), - fhBothHodoSortedCntEvoX1Y1(NULL), - fhBothHodoSortedCntEvoX2Y2(NULL), - fhH1H2S1SortedDtX1Y1(NULL), - fhH1H2S1SortedDtX2Y2(NULL), - fhH1H2S1SortedDtN1P1(NULL), - fhH1H2S1SortedDtN2P2(NULL), - fhH1H2S1SortedMapX1Y1(NULL), - fhH1H2S1SortedMapX2Y2(NULL), - fhH1H2S1SortedMapN1P1(NULL), - fhH1H2S1SortedMapN2P2(NULL), - fhH1H2S1SortedCntEvoX1Y1(NULL), - fhH1H2S1SortedCntEvoX2Y2(NULL), - fhH1H2S1SortedCntEvoN1P1(NULL), - fhH1H2S1SortedCntEvoN2P2(NULL), - fhH1H2S2SortedDtX1Y1(NULL), - fhH1H2S2SortedDtX2Y2(NULL), - fhH1H2S2SortedDtN1P1(NULL), - fhH1H2S2SortedDtN2P2(NULL), - fhH1H2S2SortedMapX1Y1(NULL), - fhH1H2S2SortedMapX2Y2(NULL), - fhH1H2S2SortedMapN1P1(NULL), - fhH1H2S2SortedMapN2P2(NULL), - fhH1H2S2SortedCntEvoX1Y1(NULL), - fhH1H2S2SortedCntEvoX2Y2(NULL), - fhH1H2S2SortedCntEvoN1P1(NULL), - fhH1H2S2SortedCntEvoN2P2(NULL), - fhSystSortedDtX1Y1(NULL), - fhSystSortedDtX2Y2(NULL), - fhSystSortedDtN1P1(NULL), - fhSystSortedDtN2P2(NULL), - fhSystSortedDtX1Y1X2Y2(NULL), - fhSystSortedMapX1Y1(NULL), - fhSystSortedMapX2Y2(NULL), - fhSystSortedMapN1P1(NULL), - fhSystSortedMapN2P2(NULL), - fhSystSortedCntEvoX1Y1(NULL), - fhSystSortedCntEvoX2Y2(NULL), - fhSystSortedCntEvoN1P1(NULL), - fhSystSortedCntEvoN2P2(NULL), - fhSystSortedDtN1X1vsN1X2(NULL), - fhSystSortedDtP1X1vsP1X2(NULL), - fhSystSortedDtN1X1vsP1X1(NULL), - fhSystSortedDtSts1Hodo1vsSts1Hodo2(NULL), - fhSystSortedDtSts2Hodo1vsSts2Hodo2(NULL), - fhSystSortedDtAllVsMapX1(NULL), - fhSystSortedDtAllVsMapY1(NULL), - fhSystSortedDtAllVsMapX2(NULL), - fhSystSortedDtAllVsMapY2(NULL), - fhSetupSortedDtX1(NULL), - fhSetupSortedDtY1(NULL), - fhSetupSortedDtX2(NULL), - fhSetupSortedDtY2(NULL), - fhSetupSortedDtN1(NULL), - fhSetupSortedDtP1(NULL), - fhSetupSortedDtN2(NULL), - fhSetupSortedDtP2(NULL), - fvulTimeLastHitAsicChan(), - fviAdcLastHitAsicChan(), - fvuNbSameHitAsicChan(), - fvuNbSameFullHitAsicChan(), - fvulStartTimeLastS(), - fvuNbHitDiffTsAsicLastS(), - fvuNbHitSameTsAsicLastS(), - fvuNbHitSameTsAdcAsicLastS(), - fvbAsicHasDuplicInMs(), - fhSetupSortedNbSameTsChan(), - fhSetupSortedSameTsAdcChan(), - fhSetupSortedSameTsAdcDiff(), - fhSetupSortedRatioSameTsChan(), - fhSetupSortedNbConsSameTsChan(), - fhSetupSortedNbConsSameTsAdcChan(), - fhSetupSortedNbConsSameTsVsTsAdc(), - fhSetupSortedAsicRatioSameTsVsFlux(), - fhSetupSortedAsicRatioSameTsAdcVsFlux(), - fhSetupSortedAsicRatioSameAdcSameTsVsFlux(), - fhSetupSortedCleanMsDtH1H2S1S2(NULL), - fhRatioMsDuplicateQuality(NULL), - fhEvoMsDuplicateQuality(), - fhSizeCleanMs(NULL), - fhHodoX1SpillEvo(NULL), - fhHodoY1SpillEvo(NULL), - fhHodoX2SpillEvo(NULL), - fhHodoY2SpillEvo(NULL), - fdSpillEvoLength( 700.0 ), - fhHodoX1SpillEvoProf(NULL), - fhHodoY1SpillEvoProf(NULL), - fhHodoX2SpillEvoProf(NULL), - fhHodoY2SpillEvoProf(NULL), - fdStereoAngleTan( TMath::Tan( kdStereoAngle * TMath::DegToRad() ) ), - fiStripsOffsetN1( 69 ), - fiStripsOffsetP1( -69 ), - fiStripsOffsetN2( 69 ), - fiStripsOffsetP2( -69 ), - fhStsSortedMapS1(NULL), - fhStsSortedMapS2(NULL), - fhStsSortedMapS1Coinc(NULL), - fhStsSortedMapS2Coinc(NULL), - fcMsSizeAll(NULL) -{ -} - -CbmCosy2018MonitorSetupGood::~CbmCosy2018MonitorSetupGood() -{ -} - -Bool_t CbmCosy2018MonitorSetupGood::Init() -{ - LOG(info) << "Initializing flib StsXyter unpacker for STS"; - - FairRootManager* ioman = FairRootManager::Instance(); - if (ioman == NULL) { - LOG(fatal) << "No FairRootManager instance"; - } - - return kTRUE; -} - -void CbmCosy2018MonitorSetupGood::SetParContainers() -{ - LOG(info) << "Setting parameter containers for " << GetName(); - fUnpackParHodo = (CbmCern2017UnpackParHodo*)(FairRun::Instance()->GetRuntimeDb()->getContainer("CbmCern2017UnpackParHodo")); - fUnpackParSts = (CbmCern2017UnpackParSts*)(FairRun::Instance()->GetRuntimeDb()->getContainer("CbmCern2017UnpackParSts")); -} - - -Bool_t CbmCosy2018MonitorSetupGood::InitContainers() -{ - LOG(info) << "Init parameter containers for " << GetName(); - - Bool_t bReInit = ReInitContainers(); - CreateHistograms(); - - return bReInit; -} - -Bool_t CbmCosy2018MonitorSetupGood::ReInitContainers() -{ - LOG(info) << "ReInit parameter containers for " << GetName(); - - fuNrOfDpbs = fUnpackParHodo->GetNrOfDpbs(); - fuNbElinksPerDpb = fUnpackParHodo->GetNbElinksPerDpb(); - fuNbStsXyters = fUnpackParHodo->GetNbStsXyters(); - fuNbChanPerAsic = fUnpackParHodo->GetNbChanPerAsic(); - - - LOG(info) << "Nr. of STS DPBs: " << fuNrOfDpbs; - - fDpbIdIndexMap.clear(); - fvuElinkToAsic.resize( fuNrOfDpbs ); - for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - { - fDpbIdIndexMap[ fUnpackParHodo->GetDpbId( uDpb ) ] = uDpb; - LOG(info) << "Eq. ID for DPB #" << std::setw(2) << uDpb << " = " - << std::setw(4) << std::hex << fUnpackParHodo->GetDpbId( uDpb ) - << std::dec - << " => " << fDpbIdIndexMap[ fUnpackParHodo->GetDpbId( uDpb ) ]; - - fvuElinkToAsic[uDpb].resize( fuNbElinksPerDpb ); - for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink ) - fvuElinkToAsic[uDpb][uElink] = fUnpackParHodo->GetElinkToAsicIdx( uDpb * fuNbElinksPerDpb + uElink ); - } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - - LOG(info) << "Nr. eLinks per DPB: " << fuNbElinksPerDpb; - LOG(info) << "Nr. of StsXyter ASICs: " << fuNbStsXyters; - LOG(info) << "Nb. channels per ASIC: " << fuNbChanPerAsic; - - for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - { - LOG(info) << "ASIC ID for eLinks in DPB #" << std::setw(2) << uDpb << ": "; - - std::stringstream ss; - for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink ) - { - if( 0 == uElink % 10 ) - ss << "\n------> "; - - ss << std::setw( 5 ) << fvuElinkToAsic[uDpb][uElink] << " "; - } // for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink ) - LOG(info) << ss.str(); - } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - - LOG(info) << "ASIC Idx for Hodo 1: " << fUnpackParHodo->GetAsicIndexHodo1(); - LOG(info) << "ASIC Idx for Hodo 2: " << fUnpackParHodo->GetAsicIndexHodo2(); - - LOG(info) << "XY swapped in Hodo 1: " << fUnpackParHodo->IsXySwappedHodo1(); - LOG(info) << "XY swapped in Hodo 2: " << fUnpackParHodo->IsXySwappedHodo2(); - - LOG(info) << "X axis inverted in Hodo 1: " << fUnpackParHodo->IsXInvertedHodo1(); - LOG(info) << "X axis inverted in Hodo 1: " << fUnpackParHodo->IsYInvertedHodo1(); - LOG(info) << "X axis inverted in Hodo 2: " << fUnpackParHodo->IsXInvertedHodo2(); - LOG(info) << "X axis inverted in Hodo 2: " << fUnpackParHodo->IsYInvertedHodo2(); - - // Internal status initialization - fvulCurrentTsMsb.resize( fuNrOfDpbs ); - fvuCurrentTsMsbCycle.resize( fuNrOfDpbs ); - fvuElinkLastTsHit.resize( fuNrOfDpbs ); - for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - { - fvulCurrentTsMsb[uDpb] = 0; - fvuCurrentTsMsbCycle[uDpb] = 0; -/* - fvuElinkLastTsHit[uDpb].resize( fuNbElinksPerDpb ); - for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink ) - { - fvuElinkLastTsHit[uDpb][uElink] = 0; - } // for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink ) -*/ - } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - - fvulChanLastHitTime.resize( fuNbStsXyters ); - fvdChanLastHitTime.resize( fuNbStsXyters ); - fvdMsTime.resize( fuMaxNbMicroslices ); - fvuChanNbHitsInMs.resize( fuNbStsXyters ); - fvdChanLastHitTimeInMs.resize( fuNbStsXyters ); - fvusChanLastHitAdcInMs.resize( fuNbStsXyters ); -// fvmChanHitsInTs.resize( fuNbStsXyters ); - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fvulChanLastHitTime[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvdChanLastHitTime[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvuChanNbHitsInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvdChanLastHitTimeInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvusChanLastHitAdcInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); -// fvmChanHitsInTs[ uXyterIdx ].resize( fuNbChanPerAsic ); - for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - { - fvulChanLastHitTime[ uXyterIdx ][ uChan ] = 0; - fvdChanLastHitTime[ uXyterIdx ][ uChan ] = -1.0; - - fvuChanNbHitsInMs[ uXyterIdx ][ uChan ].resize( fuMaxNbMicroslices ); - fvdChanLastHitTimeInMs[ uXyterIdx ][ uChan ].resize( fuMaxNbMicroslices ); - fvusChanLastHitAdcInMs[ uXyterIdx ][ uChan ].resize( fuMaxNbMicroslices ); -// fvmChanHitsInTs[ uXyterIdx ][ uChan ].clear(); - for( UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx ) - { - fvuChanNbHitsInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = 0; - fvdChanLastHitTimeInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = -1.0; - fvusChanLastHitAdcInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = 0; - } // for( UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx ) - } // for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - LOG(info) << "CbmCosy2018MonitorSetupGood::ReInitContainers => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs.size() << " VS " << fuNbStsXyters; - LOG(info) << "CbmCosy2018MonitorSetupGood::ReInitContainers => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs[ 0 ].size() << " VS " << fuNbChanPerAsic; - LOG(info) << "CbmCosy2018MonitorSetupGood::ReInitContainers => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs[ 0 ][ 0 ].size() << " VS " << fuMaxNbMicroslices; - - /// Counting of hits without proper timestamp - fvulTimeLastHitAsicChan.resize( fuNbStsXyters ); - fviAdcLastHitAsicChan.resize( fuNbStsXyters ); - fvuNbSameHitAsicChan.resize( fuNbStsXyters ); - fvuNbSameFullHitAsicChan.resize( fuNbStsXyters ); - fvulStartTimeLastS.resize( fuNbStsXyters ); - fvuNbHitDiffTsAsicLastS.resize( fuNbStsXyters ); - fvuNbHitSameTsAsicLastS.resize( fuNbStsXyters ); - fvuNbHitSameTsAdcAsicLastS.resize( fuNbStsXyters ); - fvbAsicHasDuplicInMs.resize( fuNbStsXyters ); - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fvulTimeLastHitAsicChan[ uXyterIdx ].resize( fuNbChanPerAsic ); - fviAdcLastHitAsicChan[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvuNbSameHitAsicChan[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvuNbSameFullHitAsicChan[ uXyterIdx ].resize( fuNbChanPerAsic ); - for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - { - fvulTimeLastHitAsicChan[ uXyterIdx ][ uChan ] = 0; - fviAdcLastHitAsicChan[ uXyterIdx ][ uChan ] = 0; - fvuNbSameHitAsicChan[ uXyterIdx ][ uChan ] = 0; - fvuNbSameFullHitAsicChan[ uXyterIdx ][ uChan ] = 0; - } // for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - - fvulStartTimeLastS[ uXyterIdx ] = 0; - fvuNbHitDiffTsAsicLastS[ uXyterIdx ] = 0; - fvuNbHitSameTsAsicLastS[ uXyterIdx ] = 0; - fvuNbHitSameTsAdcAsicLastS[ uXyterIdx ] = 0; - fvbAsicHasDuplicInMs[ uXyterIdx ] = kFALSE; - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - - LOG(info) << "CbmCosy2018MonitorSetupGood::ReInitContainers => Dual STS mode: " << fbDualStsEna; - return kTRUE; -} - -void CbmCosy2018MonitorSetupGood::CreateHistograms() -{ - TString sHistName{""}; - TString title{""}; - - sHistName = "hHodoMessageType"; - title = "Nb of message for each type; Type"; - fhHodoMessType = new TH1I(sHistName, title, 5, 0., 5.); - fhHodoMessType->GetXaxis()->SetBinLabel( 1, "Dummy"); - fhHodoMessType->GetXaxis()->SetBinLabel( 2, "Hit"); - fhHodoMessType->GetXaxis()->SetBinLabel( 3, "TsMsb"); - fhHodoMessType->GetXaxis()->SetBinLabel( 4, "Epoch"); - fhHodoMessType->GetXaxis()->SetBinLabel( 5, "Empty"); -/* *** Missing int + MessType OP!!!! **** - fhHodoMessType->GetXaxis()->SetBinLabel(1 + stsxyter::MessType::Dummy, "Dummy"); - fhHodoMessType->GetXaxis()->SetBinLabel(1 + stsxyter::MessType::Hit, "Hit"); - fhHodoMessType->GetXaxis()->SetBinLabel(1 + stsxyter::MessType::TsMsb, "TsMsb"); - fhHodoMessType->GetXaxis()->SetBinLabel(1 + stsxyter::MessType::ReadDataAck, "ReadDataAck"); - fhHodoMessType->GetXaxis()->SetBinLabel(1 + stsxyter::MessType::Ack, "Ack"); -*/ - - sHistName = "hHodoSysMessType"; - title = "Nb of system message for each type; System Type"; - fhHodoSysMessType = new TH1I(sHistName, title, 17, 0., 17.); -/* - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_START, "DAQ START"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_FINISH, "DAQ FINISH"); - hSysMessType->GetXaxis()->SetBinLabel(1 + 16, "GET4 Hack 32B"); -*/ - - sHistName = "hHodoMessageTypePerDpb"; - title = "Nb of message of each type for each DPB; DPB; Type"; - fhHodoMessTypePerDpb = new TH2I(sHistName, title, fuNrOfDpbs, 0, fuNrOfDpbs, 5, 0., 5.); - fhHodoMessTypePerDpb->GetYaxis()->SetBinLabel( 1, "Dummy"); - fhHodoMessTypePerDpb->GetYaxis()->SetBinLabel( 2, "Hit"); - fhHodoMessTypePerDpb->GetYaxis()->SetBinLabel( 3, "TsMsb"); - fhHodoMessTypePerDpb->GetYaxis()->SetBinLabel( 4, "Epoch"); - fhHodoMessTypePerDpb->GetYaxis()->SetBinLabel( 5, "Empty"); -/* *** Missing int + MessType OP!!!! **** - fhHodoMessType->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Dummy, "Dummy"); - fhHodoMessType->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Hit, "Hit"); - fhHodoMessType->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::TsMsb, "TsMsb"); - fhHodoMessType->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::ReadDataAck, "ReadDataAck"); - fhHodoMessType->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Ack, "Ack"); -*/ - - sHistName = "hHodoSysMessTypePerDpb"; - title = "Nb of system message of each type for each DPB; DPB; System Type"; - fhHodoSysMessTypePerDpb = new TH2I(sHistName, title, fuNrOfDpbs, 0, fuNrOfDpbs, 17, 0., 17.); -/* - hSysMessType->GetYaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_START, "DAQ START"); - hSysMessType->GetYaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_FINISH, "DAQ FINISH"); - hSysMessType->GetYaxis()->SetBinLabel(1 + 16, "GET4 Hack 32B"); -*/ - - sHistName = "hHodoMessageTypePerElink"; - title = "Nb of message of each type for each eLink; eLink; Type"; - fhHodoMessTypePerElink = new TH2I(sHistName, title, fuNrOfDpbs * fuNbElinksPerDpb, 0, fuNrOfDpbs * fuNbElinksPerDpb, 5, 0., 5.); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel( 1, "Dummy"); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel( 2, "Hit"); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel( 3, "TsMsb"); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel( 4, "ReadDataAck"); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel( 5, "Ack"); -/* *** Missing int + MessType OP!!!! **** - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Dummy, "Dummy"); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Hit, "Hit"); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::TsMsb, "TsMsb"); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::ReadDataAck, "ReadDataAck"); - fhHodoMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Ack, "Ack"); -*/ - - sHistName = "hHodoSysMessTypePerElink"; - title = "Nb of system message of each type for each eLink; eLink; System Type"; - fhHodoSysMessTypePerElink = new TH2I(sHistName, title, fuNrOfDpbs * fuNbElinksPerDpb, 0, fuNrOfDpbs * fuNbElinksPerDpb, 17, 0., 17.); -/* - fhHodoSysMessTypePerElink->GetYaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_START, "DAQ START"); - fhHodoSysMessTypePerElink->GetYaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_FINISH, "DAQ FINISH"); - fhHodoSysMessTypePerElink->GetYaxis()->SetBinLabel(1 + 16, "GET4 Hack 32B"); -*/ - - // Number of rate bins = - // 9 for the sub-unit decade - // + 9 for each unit of each decade * 10 for the subdecade range - // + 1 for the closing bin top edge - const Int_t iNbDecadesRate = 9; - const Int_t iNbStepsDecade = 9; - const Int_t iNbSubStepsInStep = 10; - const Int_t iNbBinsRate = iNbStepsDecade - + iNbStepsDecade * iNbSubStepsInStep * iNbDecadesRate - + 1; - Double_t dBinsRate[iNbBinsRate]; - // First fill sub-unit decade - for( Int_t iSubU = 0; iSubU < iNbStepsDecade; iSubU ++ ) - dBinsRate[ iSubU ] = 0.1 * ( 1 + iSubU ); - std::cout << std::endl; - // Then fill the main decades - Double_t dSubstepSize = 1.0 / iNbSubStepsInStep; - for( Int_t iDecade = 0; iDecade < iNbDecadesRate; iDecade ++) - { - Double_t dBase = std::pow( 10, iDecade ); - Int_t iDecadeIdx = iNbStepsDecade - + iDecade * iNbStepsDecade * iNbSubStepsInStep; - for( Int_t iStep = 0; iStep < iNbStepsDecade; iStep++ ) - { - Int_t iStepIdx = iDecadeIdx + iStep * iNbSubStepsInStep; - for( Int_t iSubStep = 0; iSubStep < iNbSubStepsInStep; iSubStep++ ) - { - dBinsRate[ iStepIdx + iSubStep ] = dBase * (1 + iStep) - + dBase * dSubstepSize * iSubStep; - } // for( Int_t iSubStep = 0; iSubStep < iNbSubStepsInStep; iSubStep++ ) - } // for( Int_t iStep = 0; iStep < iNbStepsDecade; iStep++ ) - } // for( Int_t iDecade = 0; iDecade < iNbDecadesRate; iDecade ++) - dBinsRate[ iNbBinsRate - 1 ] = std::pow( 10, iNbDecadesRate ); - - UInt_t uAlignedLimit = fuLongHistoNbSeconds - (fuLongHistoNbSeconds % fuLongHistoBinSizeSec); - fuLongHistoBinNb = uAlignedLimit / fuLongHistoBinSizeSec; - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - // Channel counts - sHistName = Form( "hHodoChanCntRaw_%03u", uXyterIdx ); - title = Form( "Hits Count per channel, StsXyter #%03u; Channel; Hits []", uXyterIdx ); - fhHodoChanCntRaw.push_back( new TH1I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - - // Raw Adc Distribution - sHistName = Form( "hHodoChanAdcRaw_%03u", uXyterIdx ); - title = Form( "Raw Adc distribution per channel, StsXyter #%03u; Channel []; Adc []; Hits []", uXyterIdx ); - fhHodoChanAdcRaw.push_back( new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - stsxyter::kuHitNbAdcBins, -0.5, stsxyter::kuHitNbAdcBins -0.5 ) ); - - // Raw Adc Distribution profile - sHistName = Form( "hHodoChanAdcRawProfc_%03u", uXyterIdx ); - title = Form( "Raw Adc prodile per channel, StsXyter #%03u; Channel []; Adc []", uXyterIdx ); - fhHodoChanAdcRawProf.push_back( new TProfile(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - - // Raw Ts Distribution - sHistName = Form( "hHodoChanRawTs_%03u", uXyterIdx ); - title = Form( "Raw Timestamp distribution per channel, StsXyter #%03u; Channel []; Ts []; Hits []", uXyterIdx ); - fhHodoChanRawTs.push_back( new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - stsxyter::kuHitNbTsBins, -0.5, stsxyter::kuHitNbTsBins -0.5 ) ); - - // Missed event flag - sHistName = Form( "hHodoChanMissEvt_%03u", uXyterIdx ); - title = Form( "Missed Event flags per channel, StsXyter #%03u; Channel []; Miss Evt []; Hits []", uXyterIdx ); - fhHodoChanMissEvt.push_back( new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - 2, -0.5, 1.5 ) ); - - // Missed event flag counts evolution - - sHistName = Form( "hHodoChanMissEvtEvo_%03u", uXyterIdx ); - title = Form( "Missed Evt flags per second & channel in StsXyter #%03u; Time [s]; Channel []; Missed Evt flags []", uXyterIdx ); - fhHodoChanMissEvtEvo.push_back( new TH2I( sHistName, title, - 1800, 0, 1800, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - - // Missed event flag counts evo per StsXyter - - sHistName = Form( "hHodoFebMissEvtEvo%03u", uXyterIdx ); - title = Form( "Missed Evt flags per second in StsXyter #%03u; Time [s]; Missed Evt flags []", uXyterIdx ); - fhHodoFebMissEvtEvo.push_back( new TH1I(sHistName, title, 1800, 0, 1800 ) ); - - // Hit rates evo per channel - sHistName = Form( "hHodoChanRateEvo_%03u", uXyterIdx ); - title = Form( "Hits per second & channel in StsXyter #%03u; Time [s]; Channel []; Hits []", uXyterIdx ); - fhHodoChanHitRateEvo.push_back( new TH2I( sHistName, title, - 1800, 0, 1800, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - - // Hit rates evo per StsXyter - sHistName = Form( "hHodoFebRateEvo_%03u", uXyterIdx ); - title = Form( "Hits per second in StsXyter #%03u; Time [s]; Hits []", uXyterIdx ); - fhHodoFebRateEvo.push_back( new TH1I(sHistName, title, 1800, 0, 1800 ) ); - - // Hit rates evo per channel, 1 minute bins, 24h - sHistName = Form( "hHodoChanRateEvoLong_%03u", uXyterIdx ); - title = Form( "Hits per second & channel in StsXyter #%03u; Time [min]; Channel []; Hits []", uXyterIdx ); - fhHodoChanHitRateEvoLong.push_back( new TH2D( sHistName, title, - fuLongHistoBinNb, -0.5, uAlignedLimit - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - - // Hit rates evo per StsXyter, 1 minute bins, 24h - sHistName = Form( "hHodoFebRateEvoLong_%03u", uXyterIdx ); - title = Form( "Hits per second in StsXyter #%03u; Time [min]; Hits []", uXyterIdx ); - fhHodoFebRateEvoLong.push_back( new TH1D(sHistName, title, - fuLongHistoBinNb, -0.5, uAlignedLimit - 0.5 ) ); - -/* - if( kTRUE == fbLongHistoEnable ) - { - sHistName = Form( "hFebRateEvoLong_%03u", uXyterIdx ); - title = Form( "Mean rate VS run time in same MS in StsXyter #%03u; Time in run [s]; Rate [1/s]", uXyterIdx ); - fhFebRateEvoLong.push_back( new TH1D( sHistName, title, - fuLongHistoBinNb, -0.5, uAlignedLimit - 0.5) ); - if( server ) server->Register("/StsRaw", fhFebRateEvoLong[ uXyterIdx ] ); - - sHistName = Form( "hFebChRateEvoLong_%03u", uXyterIdx ); - title = Form( "Mean rate per channel VS run time in StsXyter #%03u; Time in run [s]; Channel []; Rare [1/s]", uXyterIdx ); - fhFebChRateEvoLong.push_back( new TH2D( sHistName, title, - fuLongHistoBinNb, -0.5, uAlignedLimit - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - if( server ) server->Register("/StsRaw", fhFebChRateEvoLong[ uXyterIdx ] ); - } // if( kTRUE == fbLongHistoEnable ) -*/ - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - - UInt_t uNbBinEvo = 32768 + 1; - Double_t dMaxEdgeEvo = stsxyter::kdClockCycleNs - * static_cast< Double_t >( uNbBinEvo ) / 2.0; - Double_t dMinEdgeEvo = dMaxEdgeEvo * -1.0; - - UInt_t uNbBinDtHodo = static_cast<UInt_t>( fdCoincBorderHodo/stsxyter::kdClockCycleNs ); - UInt_t uNbBinDtBothHodo = static_cast<UInt_t>( 2*fdCoincBorderHodo/stsxyter::kdClockCycleNs ); - UInt_t uNbBinDtSts = static_cast<UInt_t>( fdCoincBorderSts/stsxyter::kdClockCycleNs ); -// UInt_t uNbBinDtSyst = static_cast<UInt_t>( fdCoincBorder/stsxyter::kdClockCycleNs ); - - /// Coincidences inside each detector ----------------------------/// - sHistName = "fhSetupSortedDtX1Y1"; - title = "Time diff for hits Hodo 1 X and Hodo 1 Y; tY1 - tX1 [ns]; Counts"; - fhSetupSortedDtX1Y1 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhSetupSortedDtX2Y2"; - title = "Time diff for hits Hodo 2 X and Hodo 2 Y; tY2 - tX2 [ns]; Counts"; - fhSetupSortedDtX2Y2 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhSetupSortedDtN1P1"; - title = "Time diff for hits Sts 1 N and Sts 1 P; tP1 - tN1 [ns]; Counts"; - fhSetupSortedDtN1P1 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhSetupSortedDtN2P2"; - title = "Time diff for hits Sts 2 N and Sts 2 P; tP2 - tN2 [ns]; Counts"; - fhSetupSortedDtN2P2 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhSetupSortedDtX1Y1X2Y2"; - title = "Time diff for hits Hodo 1 (X,Y) vs Hodo 2 (X,Y); t<X2,Y2> - t<X1,Y1> [ns]; Counts"; - fhSetupSortedDtX1Y1X2Y2 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhSetupSortedDtN1P1N2P2"; - title = "Time diff for hits STS 1 (N,P) vs STS 2 (N,P); t<N2,P2> - t<N1,P1> [ns]; Counts"; - fhSetupSortedDtN1P1N2P2 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhSetupSortedDtX1Y1X2Y2N1P1"; - title = "Time diff for hits Hodo (X1,Y1,X2,Y2) vs Sts 1 (N,P); t<N1,P1> - t<X1,Y1,X2,Y2> [ns]; Counts"; - fhSetupSortedDtX1Y1X2Y2N1P1 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhSetupSortedDtX1Y1X2Y2N2P2"; - title = "Time diff for hits Hodo (X1,Y1,X2,Y2) vs Sts 2 (N,P); t<N2,P2> - t<X1,Y1,X2,Y2> [ns]; Counts"; - fhSetupSortedDtX1Y1X2Y2N2P2 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhSetupSortedDtH1H2S1S2"; - title = "Time diff for hits Hodo (X1,Y1,X2,Y2) vs Sts (N1,P1,N2,P2); t<N1,P1,N2,P2> - t<X1,Y1,X2,Y2> [ns]; Counts"; - fhSetupSortedDtH1H2S1S2 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhSetupSortedMapX1Y1"; - title = "Sorted hits in coincidence for hodoscope 1 axis X and Y; X channel Hodo 1 []; Y channel Hodo 1 []; hits []"; - fhSetupSortedMapX1Y1 = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhSetupSortedMapX2Y2"; - title = "Sorted hits in coincidence for hodoscope 2 axis X and Y; X channel Hodo 2 []; Y channel Hodo 2 []; hits []"; - fhSetupSortedMapX2Y2 = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhSetupSortedMapN1P1"; - title = "Sorted hits in coincidence for Sts 1 sides N and P; N channel Sts 1 []; P channel Sts 1 []; hits []"; - fhSetupSortedMapN1P1 = new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - - sHistName = "fhSetupSortedMapN2P2"; - title = "Sorted hits in coincidence for Sts 2 sides N and P; N channel Sts 2 []; P channel Sts 2 []; hits []"; - fhSetupSortedMapN2P2 = new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - - // Coincidence counts evolution between some axis of the hodoscopes - sHistName = "hSetupSortedCntEvoX1Y1"; - title = "Nb of coincidences in both X1 and Y1 per s; Time [s]; X1-Y1 coincidences []"; - fhSetupSortedCntEvoX1Y1 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "hSetupSortedCntEvoX2Y2"; - title = "Nb of coincidences in both X2 and Y2 per s; Time [s]; X2-Y2 coincidences []"; - fhSetupSortedCntEvoX2Y2 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "hSetupSortedCntEvoN1P1"; - title = "Nb of coincidences in both N1 and P1 per s; Time [s]; N1-P1 coincidences []"; - fhSetupSortedCntEvoN1P1 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "hSetupSortedCntEvoN2P2"; - title = "Nb of coincidences in both N2 and P2 per s; Time [s]; N2-P2 coincidences []"; - fhSetupSortedCntEvoN2P2 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - /// Coincidences between hodoscopes ------------------------------/// - sHistName = "fhBothHodoSortedDtX1Y1"; - title = "Time diff for hits Hodo 1 X and Hodo 1 Y; tY1 - tX1 [ns]; Counts"; - fhBothHodoSortedDtX1Y1 = new TH1I(sHistName, title, uNbBinDtHodo, -fdCoincBorderHodo, fdCoincBorderHodo ); - - sHistName = "fhBothHodoSortedDtX2Y2"; - title = "Time diff for hits Hodo 2 X and Hodo 2 Y; tY2 - tX2 [ns]; Counts"; - fhBothHodoSortedDtX2Y2 = new TH1I(sHistName, title, uNbBinDtHodo, -fdCoincBorderHodo, fdCoincBorderHodo ); - - sHistName = "fhBothHodoSortedDtX1Y1X2Y2N1P1"; - title = "Time diff for hits Hodo (X1,Y1,X2,Y2) vs Sts 1 (N,P); t<N1,P1> - t<X1,Y1,X2,Y2> [ns]; Counts"; - fhBothHodoSortedDtX1Y1X2Y2N1P1 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhBothHodoSortedDtX1Y1X2Y2N2P2"; - title = "Time diff for hits Hodo (X1,Y1,X2,Y2) vs Sts 2 (N,P); t<N2,P2> - t<X1,Y1,X2,Y2> [ns]; Counts"; - fhBothHodoSortedDtX1Y1X2Y2N2P2 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhBothHodoSortedDtH1H2S1S2"; - title = "Time diff for hits Hodo (X1,Y1,X2,Y2) vs Sts (N1,P1,N2,P2); t<N1,P1,N2,P2> - t<X1,Y1,X2,Y2> [ns]; Counts"; - fhBothHodoSortedDtH1H2S1S2 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhBothHodoSortedMapX1Y1"; - title = "Sorted hits in coincidence for hodoscope 1 axis X and Y; X channel Hodo 1 []; Y channel Hodo 1 []; hits []"; - fhBothHodoSortedMapX1Y1 = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhBothHodoSortedMapX2Y2"; - title = "Sorted hits in coincidence for hodoscope 2 axis X and Y; X channel Hodo 2 []; Y channel Hodo 2 []; hits []"; - fhBothHodoSortedMapX2Y2 = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - // Coincidence counts evolution between some axis of the hodoscopes - sHistName = "hBothHodoSortedCntEvoX1Y1"; - title = "Nb of coincidences in both X1 and Y1 per s; Time [s]; X1-Y1 coincidences []"; - fhBothHodoSortedCntEvoX1Y1 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "hBothHodoSortedCntEvoX2Y2"; - title = "Nb of coincidences in both X2 and Y2 per s; Time [s]; X2-Y2 coincidences []"; - fhBothHodoSortedCntEvoX2Y2 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - /// Coincidences between hodoscopes and STS 1 --------------------/// - sHistName = "fhH1H2S1SortedDtX1Y1"; - title = "Time diff for hits Hodo 1 X and Hodo 1 Y; tY1 - tX1 [ns]; Counts"; - fhH1H2S1SortedDtX1Y1 = new TH1I(sHistName, title, uNbBinDtHodo, -fdCoincBorderHodo, fdCoincBorderHodo ); - - sHistName = "fhH1H2S1SortedDtX2Y2"; - title = "Time diff for hits Hodo 2 X and Hodo 2 Y; tY2 - tX2 [ns]; Counts"; - fhH1H2S1SortedDtX2Y2 = new TH1I(sHistName, title, uNbBinDtHodo, -fdCoincBorderHodo, fdCoincBorderHodo ); - - sHistName = "fhH1H2S1SortedDtN1P1"; - title = "Time diff for hits Sts 1 N and Sts 1 P; tP1 - tN1 [ns]; Counts"; - fhH1H2S1SortedDtN1P1 = new TH1I(sHistName, title, uNbBinDtSts, -fdCoincBorderSts, fdCoincBorderSts ); - - sHistName = "fhH1H2S1SortedDtN2P2"; - title = "Time diff for hits Sts 2 N and Sts 1 P; tP2 - tN2 [ns]; Counts"; - fhH1H2S1SortedDtN2P2 = new TH1I(sHistName, title, uNbBinDtSts, -fdCoincBorderSts, fdCoincBorderSts ); - - sHistName = "fhH1H2S1SortedMapX1Y1"; - title = "Sorted hits in coincidence for hodoscope 1 axis X and Y; X channel Hodo 1 []; Y channel Hodo 1 []; hits []"; - fhH1H2S1SortedMapX1Y1 = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhH1H2S1SortedMapX2Y2"; - title = "Sorted hits in coincidence for hodoscope 2 axis X and Y; X channel Hodo 2 []; Y channel Hodo 2 []; hits []"; - fhH1H2S1SortedMapX2Y2 = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhH1H2S1SortedMapN1P1"; - title = "Sorted hits in coincidence for Sts 1 sides N and P; N channel Sts 1 []; P channel Sts 1 []; hits []"; - fhH1H2S1SortedMapN1P1 = new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - - sHistName = "fhH1H2S1SortedMapN2P2"; - title = "Sorted hits in coincidence for Sts 2 sides N and P; N channel Sts 2 []; P channel Sts 2 []; hits []"; - fhH1H2S1SortedMapN2P2 = new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - - sHistName = "hH1H2S1SortedCntEvoX1Y1"; - title = "Nb of coincidences in both X1 and Y1 per s; Time [s]; X1-Y1 coincidences []"; - fhH1H2S1SortedCntEvoX1Y1 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "hH1H2S1SortedCntEvoX2Y2"; - title = "Nb of coincidences in both X2 and Y2 per s; Time [s]; X2-Y2 coincidences []"; - fhH1H2S1SortedCntEvoX2Y2 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "hH1H2S1SortedCntEvoN1P1"; - title = "Nb of coincidences in both N1 and P1 per s; Time [s]; N1-P1 coincidences []"; - fhH1H2S1SortedCntEvoN1P1 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "hH1H2S1SortedCntEvoN2P2"; - title = "Nb of coincidences in both N2 and P2 per s; Time [s]; N2-P2 coincidences []"; - fhH1H2S1SortedCntEvoN2P2 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - /// Coincidences between hodoscopes and STS 2 --------------------/// - sHistName = "fhH1H2S2SortedDtX1Y1"; - title = "Time diff for hits Hodo 1 X and Hodo 1 Y; tY1 - tX1 [ns]; Counts"; - fhH1H2S2SortedDtX1Y1 = new TH1I(sHistName, title, uNbBinDtHodo, -fdCoincBorderHodo, fdCoincBorderHodo ); - - sHistName = "fhH1H2S2SortedDtX2Y2"; - title = "Time diff for hits Hodo 2 X and Hodo 2 Y; tY2 - tX2 [ns]; Counts"; - fhH1H2S2SortedDtX2Y2 = new TH1I(sHistName, title, uNbBinDtHodo, -fdCoincBorderHodo, fdCoincBorderHodo ); - - sHistName = "fhH1H2S2SortedDtN1P1"; - title = "Time diff for hits Sts 1 N and Sts 1 P; tP1 - tN1 [ns]; Counts"; - fhH1H2S2SortedDtN1P1 = new TH1I(sHistName, title, uNbBinDtSts, -fdCoincBorderSts, fdCoincBorderSts ); - - sHistName = "fhH1H2S2SortedDtN2P2"; - title = "Time diff for hits Sts 2 N and Sts 1 P; tP2 - tN2 [ns]; Counts"; - fhH1H2S2SortedDtN2P2 = new TH1I(sHistName, title, uNbBinDtSts, -fdCoincBorderSts, fdCoincBorderSts ); - - sHistName = "fhH1H2S2SortedMapX1Y1"; - title = "Sorted hits in coincidence for hodoscope 1 axis X and Y; X channel Hodo 1 []; Y channel Hodo 1 []; hits []"; - fhH1H2S2SortedMapX1Y1 = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhH1H2S2SortedMapX2Y2"; - title = "Sorted hits in coincidence for hodoscope 2 axis X and Y; X channel Hodo 2 []; Y channel Hodo 2 []; hits []"; - fhH1H2S2SortedMapX2Y2 = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhH1H2S2SortedMapN1P1"; - title = "Sorted hits in coincidence for Sts 1 sides N and P; N channel Sts 1 []; P channel Sts 1 []; hits []"; - fhH1H2S2SortedMapN1P1 = new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - - sHistName = "fhH1H2S2SortedMapN2P2"; - title = "Sorted hits in coincidence for Sts 2 sides N and P; N channel Sts 2 []; P channel Sts 2 []; hits []"; - fhH1H2S2SortedMapN2P2 = new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - - sHistName = "hH1H2S2SortedCntEvoX1Y1"; - title = "Nb of coincidences in both X1 and Y1 per s; Time [s]; X1-Y1 coincidences []"; - fhH1H2S2SortedCntEvoX1Y1 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "hH1H2S2SortedCntEvoX2Y2"; - title = "Nb of coincidences in both X2 and Y2 per s; Time [s]; X2-Y2 coincidences []"; - fhH1H2S2SortedCntEvoX2Y2 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "hH1H2S2SortedCntEvoN1P1"; - title = "Nb of coincidences in both N1 and P1 per s; Time [s]; N1-P1 coincidences []"; - fhH1H2S2SortedCntEvoN1P1 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "hH1H2S2SortedCntEvoN2P2"; - title = "Nb of coincidences in both N2 and P2 per s; Time [s]; N2-P2 coincidences []"; - fhH1H2S2SortedCntEvoN2P2 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - /// Coincidences between hodoscopes and both STS -----------------/// - sHistName = "fhSystSortedDtX1Y1"; - title = "Time diff for hits Hodo 1 X and Hodo 1 Y; tY1 - tX1 [ns]; Counts"; - fhSystSortedDtX1Y1 = new TH1I(sHistName, title, uNbBinDtHodo, -fdCoincBorderHodo, fdCoincBorderHodo ); - - sHistName = "fhSystSortedDtX2Y2"; - title = "Time diff for hits Hodo 2 X and Hodo 2 Y; tY2 - tX2 [ns]; Counts"; - fhSystSortedDtX2Y2 = new TH1I(sHistName, title, uNbBinDtHodo, -fdCoincBorderHodo, fdCoincBorderHodo ); - - sHistName = "fhSystSortedDtN1P1"; - title = "Time diff for hits Sts 1 N and Sts 1 P; tP1 - tN1 [ns]; Counts"; - fhSystSortedDtN1P1 = new TH1I(sHistName, title, uNbBinDtSts, -fdCoincBorderSts, fdCoincBorderSts ); - - sHistName = "fhSystSortedDtN2P2"; - title = "Time diff for hits Sts 2 N and Sts 1 P; tP2 - tN2 [ns]; Counts"; - fhSystSortedDtN2P2 = new TH1I(sHistName, title, uNbBinDtSts, -fdCoincBorderSts, fdCoincBorderSts ); - - sHistName = "fhSystSortedDtX1Y1X2Y2"; - title = "Time diff for hits Hodo 1 (X,Y) vs Hodo 2 (X,Y); t<X2,Y2> - t<X1,Y1> [ns]; Counts"; - fhSystSortedDtX1Y1X2Y2 = new TH1I(sHistName, title, uNbBinDtBothHodo, -2*fdCoincBorderHodo, 2*fdCoincBorderHodo ); - - sHistName = "fhSystSortedMapX1Y1"; - title = "Sorted hits in coincidence for hodoscope 1 axis X and Y; X channel Hodo 1 []; Y channel Hodo 1 []; hits []"; - fhSystSortedMapX1Y1 = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhSystSortedMapX2Y2"; - title = "Sorted hits in coincidence for hodoscope 2 axis X and Y; X channel Hodo 2 []; Y channel Hodo 2 []; hits []"; - fhSystSortedMapX2Y2 = new TH2I( sHistName, title, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhSystSortedMapN1P1"; - title = "Sorted hits in coincidence for Sts 1 sides N and P; N channel Sts 1 []; P channel Sts 1 []; hits []"; - fhSystSortedMapN1P1 = new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - - sHistName = "fhSystSortedMapN2P2"; - title = "Sorted hits in coincidence for Sts 2 sides N and P; N channel Sts 2 []; P channel Sts 2 []; hits []"; - fhSystSortedMapN2P2 = new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - - // Coincidence counts evolution between some axis of the hodoscopes - sHistName = "hSystSortedCntEvoX1Y1"; - title = "Nb of coincidences in both X1 and Y1 per s; Time [s]; X1-Y1 coincidences []"; - fhSystSortedCntEvoX1Y1 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "hSystSortedCntEvoX2Y2"; - title = "Nb of coincidences in both X2 and Y2 per s; Time [s]; X2-Y2 coincidences []"; - fhSystSortedCntEvoX2Y2 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "hSystSortedCntEvoN1P1"; - title = "Nb of coincidences in both N1 and P1 per s; Time [s]; N1-P1 coincidences []"; - fhSystSortedCntEvoN1P1 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "hSystSortedCntEvoN2P2"; - title = "Nb of coincidences in both N2 and P2 per s; Time [s]; N2-P2 coincidences []"; - fhSystSortedCntEvoN2P2 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "fhSystSortedDtN1X1vsN1X2"; - title = "Time diff (N1 vs X1) vs (N1 vs X2); tN1 - tX1 [ns]; tN1 - tX2 [ns]; Counts"; - fhSystSortedDtN1X1vsN1X2 = new TH2I(sHistName, title, 200, -400, 400, 200, -400, 400 ); - - sHistName = "fhSystSortedDtP1X1vsP1X2"; - title = "Time diff (P1 vs X1) vs (P1 vs X2); tP1 - tX1 [ns]; tP1 - tX2 [ns]; Counts"; - fhSystSortedDtP1X1vsP1X2 = new TH2I(sHistName, title, 200, -400, 400, 200, -400, 400 ); - - sHistName = "fhSystSortedDtN1X1vsP1X1"; - title = "Time diff (N1 vs X1) vs (P1 vs X1); tN1 - tX1 [ns]; tP1 - tX1 [ns]; Counts"; - fhSystSortedDtN1X1vsP1X1 = new TH2I(sHistName, title, 200, -400, 400, 200, -400, 400 ); - - sHistName = "fhSystSortedDtSts1Hodo1vsSts1Hodo2"; - title = "Time diff (Sts1 vs Hodo1) vs (Sts1 vs Hodo2); t<N1,P1> - t<X1,Y1> [ns]; t<N1,P1> - t<X2,Y2> [ns]; Counts"; - fhSystSortedDtSts1Hodo1vsSts1Hodo2 = new TH2I(sHistName, title, 200, -400, 400, 200, -400, 400 ); - - sHistName = "fhSystSortedDtSts2Hodo1vsSts2Hodo2"; - title = "Time diff (Sts2 vs Hodo1) vs (Sts2 vs Hodo2); t<N2,P2> - t<X1,Y1> [ns]; t<N2,P2> - t<X2,Y2> [ns]; Counts"; - fhSystSortedDtSts2Hodo1vsSts2Hodo2 = new TH2I(sHistName, title, 200, -400, 400, 200, -400, 400 ); - - sHistName = "fhSystSortedDtAllVsMapX1"; - title = "Time diff Hodo (X1,Y1,X2,Y2) Sts 1 (N,P) vs Hodo 1 axis X; t<N1,P1> - t<X1,Y1,X2,Y2> [ns]; X channel Hodo 1 []; hits []"; - fhSystSortedDtAllVsMapX1 = new TH2I( sHistName, title, - static_cast< Int_t >(2*fdCoincBorder), -fdCoincBorder, fdCoincBorder, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhSystSortedDtAllVsMapY1"; - title = "Time diff Hodo (X1,Y1,X2,Y2) Sts 1 (N,P) vs Hodo 1 axis Y; t<N1,P1> - t<X1,Y1,X2,Y2> [ns]; Y channel Hodo 1 []; hits []"; - fhSystSortedDtAllVsMapY1 = new TH2I( sHistName, title, - static_cast< Int_t >(2*fdCoincBorder), -fdCoincBorder, fdCoincBorder, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhSystSortedDtAllVsMapX2"; - title = "Time diff Hodo (X1,Y1,X2,Y2) Sts 1 (N,P) vs Hodo 2 axis X; t<N1,P1> - t<X1,Y1,X2,Y2> [ns]; X channel Hodo 2 []; hits []"; - fhSystSortedDtAllVsMapX2 = new TH2I( sHistName, title, - static_cast< Int_t >(2*fdCoincBorder), -fdCoincBorder, fdCoincBorder, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhSystSortedDtAllVsMapY2"; - title = "Time diff Hodo (X1,Y1,X2,Y2) Sts 1 (N,P) vs Hodo 2 axis Y; t<N1,P1> - t<X1,Y1,X2,Y2> [ns]; Y channel Hodo 2 []; hits []"; - fhSystSortedDtAllVsMapY2 = new TH2I( sHistName, title, - static_cast< Int_t >(2*fdCoincBorder), -fdCoincBorder, fdCoincBorder, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - sHistName = "fhSetupSortedDtX1"; - title = "Time diff for consecutive hits in Hodo 1 X; tX1n - tX1 [ns]; Counts"; - fhSetupSortedDtX1 = new TH1I(sHistName, title, uNbBinEvo, -0.5, 2*dMaxEdgeEvo -0.5 ); - - sHistName = "fhSetupSortedDtY1"; - title = "Time diff for consecutive hits in Hodo 1 Y; tY1n - tY1 [ns]; Counts"; - fhSetupSortedDtY1 = new TH1I(sHistName, title, uNbBinEvo, -0.5, 2*dMaxEdgeEvo -0.5); - - sHistName = "fhSetupSortedDtX2"; - title = "Time diff for consecutive hits in Hodo 2 X; tX2n - tX2 [ns]; Counts"; - fhSetupSortedDtX2 = new TH1I(sHistName, title, uNbBinEvo, -0.5, 2*dMaxEdgeEvo -0.5); - - sHistName = "fhSetupSortedDtY2"; - title = "Time diff for consecutive hits in Hodo 2 Y; tY2n - tY2 [ns]; Counts"; - fhSetupSortedDtY2 = new TH1I(sHistName, title, uNbBinEvo, -0.5, 2*dMaxEdgeEvo -0.5); - - sHistName = "fhSetupSortedDtN1"; - title = "Time diff for consecutive hits in Sts 1 Y; tN1n - tN1 [ns]; Counts"; - fhSetupSortedDtN1 = new TH1I(sHistName, title, uNbBinEvo, -0.5, 2*dMaxEdgeEvo -0.5); - - sHistName = "fhSetupSortedDtP1"; - title = "Time diff for consecutive hits in Sts 1 Y; tP1n - tP1 [ns]; Counts"; - fhSetupSortedDtP1 = new TH1I(sHistName, title, uNbBinEvo, -0.5, 2*dMaxEdgeEvo -0.5); - - sHistName = "fhSetupSortedDtN2"; - title = "Time diff for consecutive hits in Sts 1 Y; tN2n - tN2 [ns]; Counts"; - fhSetupSortedDtN2 = new TH1I(sHistName, title, uNbBinEvo, -0.5, 2*dMaxEdgeEvo -0.5); - - sHistName = "fhSetupSortedDtP2"; - title = "Time diff for consecutive hits in Sts 1 Y; tP2n - tP2 [ns]; Counts"; - fhSetupSortedDtP2 = new TH1I(sHistName, title, uNbBinEvo, -0.5, 2*dMaxEdgeEvo -0.5); -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - - -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - Double_t dAdcMinMax = stsxyter::kuHitNbAdcBins + 0.5; - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - sHistName = Form( "fhSetupSortedNbSameTsChan%02u", uXyterIdx); - title = Form( "Nb Hits with same TS per second & channel Asic %02u; Time [s]; Channel []; Hits []", uXyterIdx); - fhSetupSortedNbSameTsChan.push_back( new TH2I( sHistName, title, - 1800, 0, 1800, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - - sHistName = Form( "fhSetupSortedSameTsAdcChan%02u", uXyterIdx); - title = Form( "Adc distribution per channel for Hits with same TS Asic %02u; Channel []; Adc []; Hits []", uXyterIdx); - fhSetupSortedSameTsAdcChan.push_back( new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - stsxyter::kuHitNbAdcBins, -0.5, stsxyter::kuHitNbAdcBins -0.5 ) ); - - sHistName = Form( "fhSetupSortedSameTsAdcDiff%02u", uXyterIdx); - title = Form( "Adc difference vs consecutive hit idx per channel for Hits with same TS Asic %02u; Nb same TS before []; Adc diff []; Hits []", uXyterIdx); - fhSetupSortedSameTsAdcDiff.push_back( new TH2I(sHistName, title, - 256, -0.5, 255.5, - 2*dAdcMinMax, -dAdcMinMax, dAdcMinMax ) ); - - sHistName = Form( "fhSetupSortedRatioSameTsChan%02u", uXyterIdx); - title = Form( "Ratio Hits with same TS per second & channel Asic %02u; Time [s]; Channel []; Hits []", uXyterIdx); - fhSetupSortedRatioSameTsChan.push_back( new TProfile2D( sHistName, title, - 1800, 0, 1800, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - - sHistName = Form( "fhSetupSortedNbConsSameTsChan%02u", uXyterIdx); - title = Form( "Nb consecutive Hits with same TS per channel Asic %02u; Channel []; Hits with same TS []; []", uXyterIdx); - fhSetupSortedNbConsSameTsChan.push_back( new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - 1024, -0.5, 10240.5 ) ); - - sHistName = Form( "fhSetupSortedNbConsSameTsAdcChan%02u", uXyterIdx); - title = Form( "Nb consecutive Hits with same TS and ADC per channel Asic %02u; Channel []; Hits with same TS and ADC []; []", uXyterIdx); - fhSetupSortedNbConsSameTsAdcChan.push_back( new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - 256, -0.5, 255.5 ) ); - - sHistName = Form( "fhSetupSortedNbConsSameTsVsTsAdc%02u", uXyterIdx); - title = Form( "Nb consecutive Hits with same TS vs same TS and ADC Asic %02u; Hits with same TS []; Hits with same TS and ADC []; []", uXyterIdx); - fhSetupSortedNbConsSameTsVsTsAdc.push_back( new TH2I(sHistName, title, - 256, -0.5, 255.5, - 256, -0.5, 255.5 ) ); - - sHistName = Form( "fhSetupSortedAsicRatioSameTsVsFlux%02u", uXyterIdx); - title = Form( "Ratio of hits with same TS vs Hit flux Asic %02u; Hits flux [1/s]; Same Ts / All Hits []; []", uXyterIdx); - fhSetupSortedAsicRatioSameTsVsFlux.push_back( new TH2I(sHistName, title, - iNbBinsRate - 1, dBinsRate, - 101, -0.005, 1.005 ) ); - - sHistName = Form( "fhSetupSortedAsicRatioSameTsAdcVsFlux%02u", uXyterIdx); - title = Form( "Ratio of hits with same TS and ADC vs Hit flux Asic %02u; Hits flux [1/s]; Same Ts and ADC / All Hits []; []", uXyterIdx); - fhSetupSortedAsicRatioSameTsAdcVsFlux.push_back( new TH2I(sHistName, title, - iNbBinsRate - 1, dBinsRate, - 101, -0.005, 1.005 ) ); - - sHistName = Form( "fhSetupSortedAsicRatioSameAdcSameTsVsFlux%02u", uXyterIdx); - title = Form( "Ratio of hits with same ADC amond same TS vs Hit flux Asic %02u; Hits flux [1/s]; Same TS and ADC / Same TS []; []", uXyterIdx); - fhSetupSortedAsicRatioSameAdcSameTsVsFlux.push_back( new TH2I(sHistName, title, - iNbBinsRate - 1, dBinsRate, - 101, -0.005, 1.005 ) ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - sHistName = "fhHodoX1SpillEvo"; - title = "Hodo X1 counts vs time in spill; time [s]; X1 channel []; Hits []"; - fhHodoX1SpillEvo = new TH2I(sHistName, title, - 70000, 0, 70.0, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhHodoY1SpillEvo"; - title = "Hodo Y1 counts vs time in spill; time [s]; Y1 channel []; Hits []"; - fhHodoY1SpillEvo = new TH2I(sHistName, title, - 70000, 0, 70.0, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - sHistName = "fhHodoX2SpillEvo"; - title = "Hodo X2 counts vs time in spill; time [s]; X2 channel []; Hits []"; - fhHodoX2SpillEvo = new TH2I(sHistName, title, - 70000, 0, 70.0, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - sHistName = "fhHodoY2SpillEvo"; - title = "Hodo Y2 counts vs time in spill; time [s]; Y2 channel []; Hits []"; - fhHodoY2SpillEvo = new TH2I(sHistName, title, - 70000, 0, 70.0, - fuNbChanPerAsic/2, -0.5, fuNbChanPerAsic/2 - 0.5 ); - - sHistName = "fhHodoX1SpillEvoProf"; - title = "Hodo X1 counts vs time in spill; time [s]; X1 channel []; Hits []"; - fhHodoX1SpillEvoProf = new TProfile(sHistName, title, - 10*fdSpillEvoLength, 0, fdSpillEvoLength); - - sHistName = "fhHodoY1SpillEvoProf"; - title = "Hodo Y1 counts vs time in spill; time [s]; Y1 channel []; Hits []"; - fhHodoY1SpillEvoProf = new TProfile(sHistName, title, - 10*fdSpillEvoLength, 0, fdSpillEvoLength); - sHistName = "fhHodoX2SpillEvoProf"; - title = "Hodo X2 counts vs time in spill; time [s]; X2 channel []; Hits []"; - fhHodoX2SpillEvoProf = new TProfile(sHistName, title, - 10*fdSpillEvoLength, 0, fdSpillEvoLength); - sHistName = "fhHodoY2SpillEvoProf"; - title = "Hodo Y2 counts vs time in spill; time [s]; Y2 channel []; Hits []"; - fhHodoY2SpillEvoProf = new TProfile(sHistName, title, - 10*fdSpillEvoLength, 0, fdSpillEvoLength); - -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - - sHistName = "fhRatioMsDuplicateQuality"; - title = "Fraction of MS with a given number od ASICs without duplicated hits; Clean Asics Nb []; MS fraction []"; - fhRatioMsDuplicateQuality = new TProfile(sHistName, title, fuNbStsXyters + 1, 0, fuNbStsXyters + 1 ); - - for( UInt_t uXyterIdx = 0; uXyterIdx <= fuNbStsXyters; ++uXyterIdx ) - { - sHistName = Form( "fhEvoMsDuplicateQuality%02u", uXyterIdx); - title = Form( "Fraction of MS with %02u ASICs without duplicate hits vs time; time [s]; MS fraction []", uXyterIdx); - fhEvoMsDuplicateQuality.push_back( new TProfile(sHistName, title, 300000, 0, 300.0 ) ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - - sHistName = "fhSizeCleanMs"; - title = "Size in Hits of MS without duplicated hits; Size [Hits]; MS Nb []"; - fhSizeCleanMs = new TH1I(sHistName, title, 500000, 0, 500000 ); -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - - Double_t dMapSizeMmX = kdSensorsSzX + 100 * kdPitchMm; - Double_t dMapSizeMmY = kdSensorsSzY + 100 * kdPitchMm; - Int_t iNbBinsX = dMapSizeMmX / kdPitchMm; // 58 um bin - Int_t iNbBinsY = dMapSizeMmY / kdPitchMm / 7.54; // 116 um bin - sHistName = "fhStsSortedMapS1"; - title = "Sorted hits in coincidence for Sts 1 axis X and Y; X1 [mm]; Y1 [mm]; Hits []"; - fhStsSortedMapS1 = new TH2I( sHistName, title, - iNbBinsX, -dMapSizeMmX / 2.0, dMapSizeMmX / 2.0, - iNbBinsY, -dMapSizeMmY / 2.0, dMapSizeMmY / 2.0 ); - - if( kTRUE == fbDualStsEna ) - { - sHistName = "fhStsSortedMapS2"; - title = "Sorted hits in coincidence for Sts 2 axis X and Y; X2 [mm]; Y2 [mm]; Hits []"; - fhStsSortedMapS2 = new TH2I( sHistName, title, - iNbBinsX, -dMapSizeMmX / 2.0, dMapSizeMmX / 2.0, - iNbBinsY, -dMapSizeMmY / 2.0, dMapSizeMmY / 2.0 ); - - sHistName = "fhStsSortedMapS1Coinc"; - title = "Sorted hits in coincidence for Sts 1 axis X and Y if Sts2 in coinc; X1 [mm]; Y1 [mm]; Hits []"; - fhStsSortedMapS1Coinc = new TH2I( sHistName, title, - iNbBinsX, -dMapSizeMmX / 2.0, dMapSizeMmX / 2.0, - iNbBinsY, -dMapSizeMmY / 2.0, dMapSizeMmY / 2.0 ); - - sHistName = "fhStsSortedMapS2Coinc"; - title = "Sorted hits in coincidence for Sts 2 axis X and Y if Sts1 in coinc; X2 [mm]; Y2 [mm]; Hits []"; - fhStsSortedMapS2Coinc = new TH2I( sHistName, title, - iNbBinsX, -dMapSizeMmX / 2.0, dMapSizeMmX / 2.0, - iNbBinsY, -dMapSizeMmY / 2.0, dMapSizeMmY / 2.0 ); - } // if( kTRUE == fbDualStsEna ) -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - -/* - // Distribution of the TS_MSB per StsXyter - sHistName = "hHodoFebTsMsb"; - title = "Raw Timestamp Msb distribution per StsXyter; Ts MSB []; StsXyter []; Hits []"; - fhHodoFebTsMsb = new TH2I( sHistName, title, stsxyter::kuTsMsbNbTsBins, -0.5, stsxyter::kuTsMsbNbTsBins - 0.5, - fuNbStsXyters, -0.5, fuNbStsXyters - 0.5 ); - if( server ) server->Register("/StsRaw", fhHodoFebTsMsb ); -*/ - // Miscroslice properties histos - for( Int_t component = 0; component < kiMaxNbFlibLinks; component ++ ) - { - fhMsSz[ component ] = NULL; - fhMsSzTime[ component ] = NULL; - } // for( Int_t component = 0; component < kiMaxNbFlibLinks; component ++ ) - - // Online histo browser commands - THttpServer* server = FairRunOnline::Instance()->GetHttpServer(); - if( server ) - { - server->Register("/HodoRaw", fhHodoMessType ); - server->Register("/HodoRaw", fhHodoSysMessType ); - server->Register("/HodoRaw", fhHodoMessTypePerDpb ); - server->Register("/HodoRaw", fhHodoSysMessTypePerDpb ); - server->Register("/HodoRaw", fhHodoMessTypePerElink ); - server->Register("/HodoRaw", fhHodoSysMessTypePerElink ); - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - server->Register("/HodoRaw", fhHodoChanCntRaw[ uXyterIdx ] ); - server->Register("/HodoRaw", fhHodoChanAdcRaw[ uXyterIdx ] ); - server->Register("/HodoRaw", fhHodoChanAdcRawProf[ uXyterIdx ] ); - server->Register("/HodoRaw", fhHodoChanRawTs[ uXyterIdx ] ); - server->Register("/HodoRaw", fhHodoChanMissEvt[ uXyterIdx ] ); - server->Register("/HodoRaw", fhHodoChanMissEvtEvo[ uXyterIdx ] ); - server->Register("/HodoRaw", fhHodoFebMissEvtEvo[ uXyterIdx ] ); - server->Register("/HodoRaw", fhHodoChanHitRateEvo[ uXyterIdx ] ); - server->Register("/HodoRaw", fhHodoFebRateEvo[ uXyterIdx ] ); - server->Register("/HodoRaw", fhHodoChanHitRateEvoLong[ uXyterIdx ] ); - server->Register("/HodoRaw", fhHodoFebRateEvoLong[ uXyterIdx ] ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - server->Register("/Setup", fhSetupSortedDtX1Y1 ); - server->Register("/Setup", fhSetupSortedDtX2Y2 ); - server->Register("/Setup", fhSetupSortedDtN1P1 ); - server->Register("/Setup", fhSetupSortedDtN2P2 ); - server->Register("/Setup", fhSetupSortedDtX1Y1X2Y2 ); - server->Register("/Setup", fhSetupSortedDtX1Y1X2Y2N1P1 ); - server->Register("/Setup", fhSetupSortedDtX1Y1X2Y2N2P2 ); - server->Register("/Setup", fhSetupSortedDtH1H2S1S2 ); - server->Register("/Setup", fhSetupSortedMapX1Y1 ); - server->Register("/Setup", fhSetupSortedMapX2Y2 ); - server->Register("/Setup", fhSetupSortedMapN1P1 ); - server->Register("/Setup", fhSetupSortedMapN2P2 ); - server->Register("/Setup", fhSetupSortedCntEvoX1Y1 ); - server->Register("/Setup", fhSetupSortedCntEvoX2Y2 ); - server->Register("/Setup", fhSetupSortedCntEvoN1P1 ); - server->Register("/Setup", fhSetupSortedCntEvoN2P2 ); - - server->Register("/Setup", fhStsSortedMapS1 ); - if( kTRUE == fbDualStsEna ) - { - server->Register("/Setup", fhStsSortedMapS2 ); - server->Register("/Setup", fhStsSortedMapS1Coinc ); - server->Register("/Setup", fhStsSortedMapS2Coinc ); - } // if( kTRUE == fbDualStsEna ) - - server->Register("/HodoBoth", fhBothHodoSortedDtX1Y1 ); - server->Register("/HodoBoth", fhBothHodoSortedDtX2Y2 ); - server->Register("/HodoBoth", fhBothHodoSortedDtX1Y1X2Y2N1P1 ); - server->Register("/HodoBoth", fhBothHodoSortedDtX1Y1X2Y2N2P2 ); - server->Register("/HodoBoth", fhBothHodoSortedMapX1Y1 ); - server->Register("/HodoBoth", fhBothHodoSortedMapX2Y2 ); - server->Register("/HodoBoth", fhBothHodoSortedCntEvoX1Y1 ); - server->Register("/HodoBoth", fhBothHodoSortedCntEvoX2Y2 ); - - server->Register("/H1H2S1", fhH1H2S1SortedDtX1Y1 ); - server->Register("/H1H2S1", fhH1H2S1SortedDtX2Y2 ); - server->Register("/H1H2S1", fhH1H2S1SortedDtN1P1 ); - server->Register("/H1H2S1", fhH1H2S1SortedDtN2P2 ); - server->Register("/H1H2S1", fhH1H2S1SortedMapX1Y1 ); - server->Register("/H1H2S1", fhH1H2S1SortedMapX2Y2 ); - server->Register("/H1H2S1", fhH1H2S1SortedMapN1P1 ); - server->Register("/H1H2S1", fhH1H2S1SortedMapN2P2 ); - server->Register("/H1H2S1", fhH1H2S1SortedCntEvoX1Y1 ); - server->Register("/H1H2S1", fhH1H2S1SortedCntEvoX2Y2 ); - server->Register("/H1H2S1", fhH1H2S1SortedCntEvoN1P1 ); - server->Register("/H1H2S1", fhH1H2S1SortedCntEvoN2P2 ); - - server->Register("/H1H2S2", fhH1H2S2SortedDtX1Y1 ); - server->Register("/H1H2S2", fhH1H2S2SortedDtX2Y2 ); - server->Register("/H1H2S2", fhH1H2S2SortedDtN1P1 ); - server->Register("/H1H2S2", fhH1H2S2SortedDtN2P2 ); - server->Register("/H1H2S2", fhH1H2S2SortedMapX1Y1 ); - server->Register("/H1H2S2", fhH1H2S2SortedMapX2Y2 ); - server->Register("/H1H2S2", fhH1H2S2SortedMapN1P1 ); - server->Register("/H1H2S2", fhH1H2S2SortedMapN2P2 ); - server->Register("/H1H2S2", fhH1H2S2SortedCntEvoX1Y1 ); - server->Register("/H1H2S2", fhH1H2S2SortedCntEvoX2Y2 ); - server->Register("/H1H2S2", fhH1H2S2SortedCntEvoN1P1 ); - server->Register("/H1H2S2", fhH1H2S2SortedCntEvoN2P2 ); - - server->Register("/Syst", fhSystSortedDtX1Y1 ); - server->Register("/Syst", fhSystSortedDtX2Y2 ); - server->Register("/Syst", fhSystSortedDtN1P1 ); - server->Register("/Syst", fhSystSortedDtN2P2 ); - server->Register("/Syst", fhSystSortedDtX1Y1X2Y2 ); - server->Register("/Syst", fhSystSortedMapX1Y1 ); - server->Register("/Syst", fhSystSortedMapX2Y2 ); - server->Register("/Syst", fhSystSortedMapN1P1 ); - server->Register("/Syst", fhSystSortedMapN2P2 ); - server->Register("/Syst", fhSystSortedCntEvoX1Y1 ); - server->Register("/Syst", fhSystSortedCntEvoX2Y2 ); - server->Register("/Syst", fhSystSortedCntEvoN1P1 ); - server->Register("/Syst", fhSystSortedCntEvoN2P2 ); - - server->Register("/Syst", fhSystSortedDtN1X1vsN1X2 ); - server->Register("/Syst", fhSystSortedDtP1X1vsP1X2 ); - server->Register("/Syst", fhSystSortedDtN1X1vsP1X1 ); - server->Register("/Syst", fhSystSortedDtSts1Hodo1vsSts1Hodo2 ); - server->Register("/Syst", fhSystSortedDtSts2Hodo1vsSts2Hodo2 ); - - server->Register("/Syst", fhSystSortedDtAllVsMapX1 ); - server->Register("/Syst", fhSystSortedDtAllVsMapY1 ); - server->Register("/Syst", fhSystSortedDtAllVsMapX2 ); - server->Register("/Syst", fhSystSortedDtAllVsMapY2 ); - - server->Register("/FebDt", fhSetupSortedDtX1 ); - server->Register("/FebDt", fhSetupSortedDtY1 ); - server->Register("/FebDt", fhSetupSortedDtX2 ); - server->Register("/FebDt", fhSetupSortedDtY2 ); - server->Register("/FebDt", fhSetupSortedDtN1 ); - server->Register("/FebDt", fhSetupSortedDtP1 ); - server->Register("/FebDt", fhSetupSortedDtN2 ); - server->Register("/FebDt", fhSetupSortedDtP2 ); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - server->Register("/FebDupli", fhSetupSortedNbSameTsChan[ uXyterIdx ] ); - server->Register("/FebDupli", fhSetupSortedSameTsAdcChan[ uXyterIdx ] ); - server->Register("/FebDupli", fhSetupSortedSameTsAdcDiff[ uXyterIdx ] ); - server->Register("/FebDupli", fhSetupSortedRatioSameTsChan[ uXyterIdx ] ); - server->Register("/FebDupli", fhSetupSortedNbConsSameTsChan[ uXyterIdx ] ); - server->Register("/FebDupli", fhSetupSortedNbConsSameTsAdcChan[ uXyterIdx ] ); - server->Register("/FebDupli", fhSetupSortedNbConsSameTsVsTsAdc[ uXyterIdx ] ); - - server->Register("/FebDupli", fhSetupSortedAsicRatioSameTsVsFlux[ uXyterIdx ] ); - server->Register("/FebDupli", fhSetupSortedAsicRatioSameTsAdcVsFlux[ uXyterIdx ] ); - server->Register("/FebDupli", fhSetupSortedAsicRatioSameAdcSameTsVsFlux[ uXyterIdx ] ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - - server->Register("/FebDupli", fhRatioMsDuplicateQuality ); - for( UInt_t uXyterIdx = 0; uXyterIdx <= fuNbStsXyters; ++uXyterIdx ) - { - server->Register("/FebDupli", fhEvoMsDuplicateQuality[ uXyterIdx ] ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - server->Register("/FebDupli", fhSizeCleanMs ); - - server->Register("/Spill", fhHodoX1SpillEvo ); - server->Register("/Spill", fhHodoY1SpillEvo ); - server->Register("/Spill", fhHodoX2SpillEvo ); - server->Register("/Spill", fhHodoY2SpillEvo ); - server->Register("/Spill", fhHodoX1SpillEvoProf ); - server->Register("/Spill", fhHodoY1SpillEvoProf ); - server->Register("/Spill", fhHodoX2SpillEvoProf ); - server->Register("/Spill", fhHodoY2SpillEvoProf ); - - server->RegisterCommand("/Reset_All_Hodo", "bCosy2018ResetSetupHistosGood=kTRUE"); - server->RegisterCommand("/Write_All_Hodo", "bCosy2018WriteSetupHistosGood=kTRUE"); - - server->Restrict("/Reset_All_Hodo", "allow=admin"); - server->Restrict("/Write_All_Hodo", "allow=admin"); - } // if( server ) - - /** Create summary Canvases for CERN 2017 **/ - Double_t w = 10; - Double_t h = 10; - - // Summary per StsXyter - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - TCanvas* cStsSumm = new TCanvas( Form("cStsSum_%03u", uXyterIdx ), - Form("Summary plots for StsXyter %03u", uXyterIdx ), - w, h); - cStsSumm->Divide( 2, 2 ); - - cStsSumm->cd(1); - gPad->SetLogy(); - fhHodoChanCntRaw[ uXyterIdx ]->Draw(); - - cStsSumm->cd(2); - gPad->SetLogz(); - fhHodoChanAdcRaw[ uXyterIdx ]->Draw( "colz" ); - - cStsSumm->cd(3); - gPad->SetLogz(); - fhHodoChanHitRateEvo[ uXyterIdx ]->Draw( "colz" ); - - cStsSumm->cd(4); -// gPad->SetLogy(); - fhHodoChanAdcRawProf[ uXyterIdx ]->Draw(); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - -//====================================================================// - -//====================================================================// - TCanvas* cSetupSortedDt = new TCanvas( "cSetupSortedDt", - "Hodoscopes coincidence maps", - w, h); - if( kTRUE == fbDualStsEna ) - cSetupSortedDt->Divide( 4, 3 ); - else cSetupSortedDt->Divide( 3, 3 ); - - cSetupSortedDt->cd(1); - gPad->SetGridx(); - gPad->SetLogy(); - fhSetupSortedDtX1Y1->Draw( "" ); - - cSetupSortedDt->cd(2); - gPad->SetGridx(); - gPad->SetLogy(); - fhSetupSortedDtX2Y2->Draw( "" ); - - cSetupSortedDt->cd(3); - gPad->SetGridx(); - gPad->SetLogy(); - fhSetupSortedDtN1P1->Draw( "" ); - - cSetupSortedDt->cd(4 + ( kTRUE == fbDualStsEna ? 1 : 0 ) ); - gPad->SetGridx(); - gPad->SetLogy(); - fhBothHodoSortedDtX1Y1->Draw( "" ); - - cSetupSortedDt->cd(5 + ( kTRUE == fbDualStsEna ? 1 : 0 ) ); - gPad->SetGridx(); - gPad->SetLogy(); - fhBothHodoSortedDtX2Y2->Draw( "" ); -/* - cSetupSortedDt->cd(6 + ( kTRUE == fbDualStsEna ? 1 : 0 ) ); - gPad->SetGridx(); - gPad->SetLogy(); - fhSetupSortedDtN1P1->Draw( "" ); -*/ - cSetupSortedDt->cd(7 + ( kTRUE == fbDualStsEna ? 2 : 0 ) ); - gPad->SetGridx(); - gPad->SetLogy(); - fhSystSortedDtX1Y1->Draw( "" ); - - cSetupSortedDt->cd(8 + ( kTRUE == fbDualStsEna ? 2 : 0 ) ); - gPad->SetGridx(); - gPad->SetLogy(); - fhSystSortedDtX2Y2->Draw( "" ); - - cSetupSortedDt->cd(9 + ( kTRUE == fbDualStsEna ? 2 : 0 ) ); - gPad->SetGridx(); - gPad->SetLogy(); - fhSystSortedDtN1P1->Draw( "" ); - - if( kTRUE == fbDualStsEna ) - { - cSetupSortedDt->cd(4); - gPad->SetGridx(); - gPad->SetLogy(); - fhSetupSortedDtN2P2->Draw( "colz" ); -/* - cSetupSortedDt->cd(8); - gPad->SetGridx(); - gPad->SetLogy(); - fhSetupSortedDtN2P2->Draw( "colz" ); -*/ - - cSetupSortedDt->cd(12); - gPad->SetGridx(); - gPad->SetLogy(); - fhSystSortedDtN2P2->Draw( "colz" ); - } // if( kTRUE == fbDualStsEna ) -//====================================================================// - -//====================================================================// - TCanvas* cSetupSortedMaps = new TCanvas( "cSetupSortedMaps", - "Hodoscopes coincidence maps", - w, h); - - if( kTRUE == fbDualStsEna ) - cSetupSortedMaps->Divide( 4, 3 ); - else cSetupSortedMaps->Divide( 3, 3 ); - - cSetupSortedMaps->cd(1); - gPad->SetLogz(); - fhSetupSortedMapX1Y1->Draw( "colz" ); - - cSetupSortedMaps->cd(2); - gPad->SetLogz(); - fhSetupSortedMapX2Y2->Draw( "colz" ); - - cSetupSortedMaps->cd(3); - gPad->SetLogz(); - fhSetupSortedMapN1P1->Draw( "colz" ); - - cSetupSortedMaps->cd(4 + ( kTRUE == fbDualStsEna ? 1 : 0 ) ); - gPad->SetLogz(); - fhBothHodoSortedMapX1Y1->Draw( "colz" ); - - cSetupSortedMaps->cd(5 + ( kTRUE == fbDualStsEna ? 1 : 0 ) ); - gPad->SetLogz(); - fhBothHodoSortedMapX2Y2->Draw( "colz" ); -/* - cSetupSortedMaps->cd(6 + ( kTRUE == fbDualStsEna ? 1 : 0 ) ); - gPad->SetLogz(); - fhBothHodoSortedMapN1P1->Draw( "colz" ); -*/ - cSetupSortedMaps->cd(7 + ( kTRUE == fbDualStsEna ? 2 : 0 ) ); - gPad->SetLogz(); - fhSystSortedMapX1Y1->Draw( "colz" ); - - cSetupSortedMaps->cd(8 + ( kTRUE == fbDualStsEna ? 2 : 0 ) ); - gPad->SetLogz(); - fhSystSortedMapX2Y2->Draw( "colz" ); - - cSetupSortedMaps->cd(9 + ( kTRUE == fbDualStsEna ? 2 : 0 ) ); - gPad->SetLogz(); - fhSystSortedMapN1P1->Draw( "colz" ); - - if( kTRUE == fbDualStsEna ) - { - cSetupSortedMaps->cd(4); - gPad->SetLogz(); - fhSetupSortedMapN2P2->Draw( "colz" ); -/* - cSetupSortedMaps->cd(8); - gPad->SetLogz(); - fhBothHodoSortedMapN2P2->Draw( "colz" ); -*/ - - cSetupSortedMaps->cd(12); - gPad->SetLogz(); - fhSystSortedMapN2P2->Draw( "colz" ); - } // if( kTRUE == fbDualStsEna ) -//====================================================================// - -//====================================================================// - TCanvas* cSetupSortedCoincEvo = new TCanvas( "cSetupSortedCoincEvo", - "Hodoscopes coincidence rate evolution", - w, h); - cSetupSortedCoincEvo->Divide( 3, 3 ); - - cSetupSortedCoincEvo->cd(1); - gPad->SetGridy(); - gPad->SetLogy(); - fhSetupSortedCntEvoX1Y1->Draw( "" ); - - cSetupSortedCoincEvo->cd(2); - gPad->SetGridy(); - gPad->SetLogy(); - fhSetupSortedCntEvoX2Y2->Draw( "" ); - - cSetupSortedCoincEvo->cd(3); - gPad->SetGridy(); - gPad->SetLogy(); - fhSetupSortedCntEvoN1P1->Draw( "" ); - - cSetupSortedCoincEvo->cd(4); - gPad->SetGridy(); - gPad->SetLogy(); - fhBothHodoSortedCntEvoX1Y1->Draw( "" ); - - cSetupSortedCoincEvo->cd(5); - gPad->SetGridy(); - gPad->SetLogy(); - fhBothHodoSortedCntEvoX2Y2->Draw( "" ); -/* - cSetupSortedCoincEvo->cd(6); - gPad->SetGridy(); - gPad->SetLogy(); - fhSetupSortedCntEvoN1P1->Draw( "" ); -*/ - cSetupSortedCoincEvo->cd(7); - gPad->SetGridy(); - gPad->SetLogy(); - fhSystSortedCntEvoX1Y1->Draw( "" ); - - cSetupSortedCoincEvo->cd(8); - gPad->SetGridy(); - gPad->SetLogy(); - fhSystSortedCntEvoX2Y2->Draw( "" ); - - cSetupSortedCoincEvo->cd(9); - gPad->SetGridy(); - gPad->SetLogy(); - fhSystSortedCntEvoN1P1->Draw( "" ); -//====================================================================// - -//====================================================================// - TCanvas* cSetupCoinQaDt = new TCanvas( "cSetupCoinQaDt", - "Hodoscopes coincidence quality", - w, h); - cSetupCoinQaDt->Divide( 2, 2 ); - - cSetupCoinQaDt->cd(1); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhSystSortedDtN1X1vsN1X2->Draw( "colz" ); - - cSetupCoinQaDt->cd(2); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhSystSortedDtP1X1vsP1X2->Draw( "colz" ); - - cSetupCoinQaDt->cd(3); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhSystSortedDtN1X1vsP1X1->Draw( "colz" ); - - cSetupCoinQaDt->cd(4); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhSystSortedDtSts1Hodo1vsSts1Hodo2->Draw( "colz" ); - -//====================================================================// - TCanvas* cSetupCoinQa = new TCanvas( "cSetupCoinQa", - "Hodoscopes coincidence quality", - w, h); - cSetupCoinQa->Divide( 2, 2 ); - - cSetupCoinQa->cd(1); - gPad->SetLogz(); - fhSystSortedDtAllVsMapX1->Draw( "colz" ); - - cSetupCoinQa->cd(2); - gPad->SetLogz(); - fhSystSortedDtAllVsMapY1->Draw( "colz" ); - - cSetupCoinQa->cd(3); - gPad->SetLogz(); - fhSystSortedDtAllVsMapX2->Draw( "colz" ); - - cSetupCoinQa->cd(4); - gPad->SetLogz(); - fhSystSortedDtAllVsMapY2->Draw( "colz" ); -//====================================================================// - -//====================================================================// - TCanvas* cFebDt = new TCanvas( "cFebDt", - "Hodoscopes coincidence quality", - w, h); - - if( kTRUE == fbDualStsEna ) - cFebDt->Divide( 2, 4 ); - else cFebDt->Divide( 2, 3 ); - - cFebDt->cd(1); - gPad->SetLogy(); - fhSetupSortedDtX1->Draw( "" ); - - cFebDt->cd(2); - gPad->SetLogy(); - fhSetupSortedDtY1->Draw( "" ); - - cFebDt->cd(3); - gPad->SetLogy(); - fhSetupSortedDtX2->Draw( "" ); - - cFebDt->cd(4); - gPad->SetLogy(); - fhSetupSortedDtY2->Draw( "" ); - - cFebDt->cd(5); - gPad->SetLogy(); - fhSetupSortedDtN1->Draw( "" ); - - cFebDt->cd(6); - gPad->SetLogy(); - fhSetupSortedDtP1->Draw( "" ); - - if( kTRUE == fbDualStsEna ) - { - cFebDt->cd(7); - gPad->SetLogy(); - fhSetupSortedDtN2->Draw( "" ); - - cFebDt->cd(8); - gPad->SetLogy(); - fhSetupSortedDtP2->Draw( "" ); - } // if( kTRUE == fbDualStsEna ) -//====================================================================// - -//====================================================================// - TCanvas* cFebSameTs = new TCanvas( "cFebSameTs", - "Hodoscopes coincidence quality", - w, h); - - cFebSameTs->Divide( 2, fuNbStsXyters/2 + fuNbStsXyters%2 ); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - cFebSameTs->cd(1 + uXyterIdx ); - gPad->SetLogz(); - fhSetupSortedNbSameTsChan[ uXyterIdx ]->Draw( "colz" ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) -//====================================================================// - -//====================================================================// - TCanvas* cFebSameTsAdc = new TCanvas( "cFebSameTsAdc", - "Hodoscopes coincidence quality", - w, h); - - cFebSameTsAdc->Divide( 2, fuNbStsXyters/2 + fuNbStsXyters%2 ); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - cFebSameTsAdc->cd(1 + uXyterIdx ); - gPad->SetLogz(); - fhSetupSortedSameTsAdcChan[ uXyterIdx ]->Draw( "colz" ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) -//====================================================================// - -//====================================================================// - TCanvas* cFebDupliVsChan = new TCanvas( "cFebDupliVsChan", - "Hodoscopes coincidence quality", - w, h); - - cFebDupliVsChan->Divide( fuNbStsXyters, 3 ); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - cFebDupliVsChan->cd( 1 + uXyterIdx ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhSetupSortedNbConsSameTsChan[ uXyterIdx ]->Draw( "colz" ); - - cFebDupliVsChan->cd( 1 + fuNbStsXyters +uXyterIdx ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhSetupSortedNbConsSameTsAdcChan[ uXyterIdx ]->Draw( "colz" ); - - cFebDupliVsChan->cd( 1 + 2*fuNbStsXyters + uXyterIdx ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhSetupSortedNbConsSameTsVsTsAdc[ uXyterIdx ]->Draw( "colz" ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) -//====================================================================// - -//====================================================================// - TCanvas* cFebDupliVsRate = new TCanvas( "cFebDupliVsRate", - "Hodoscopes coincidence quality", - w, h); - - cFebDupliVsRate->Divide( fuNbStsXyters, 3 ); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - cFebDupliVsRate->cd( 1 + uXyterIdx ); -// gPad->SetGridx(); -// gPad->SetGridy(); - gPad->SetLogx(); - gPad->SetLogz(); - fhSetupSortedAsicRatioSameTsVsFlux[ uXyterIdx ]->Draw( "colz" ); - - cFebDupliVsRate->cd( 1 + fuNbStsXyters + uXyterIdx ); -// gPad->SetGridx(); -// gPad->SetGridy(); - gPad->SetLogx(); - gPad->SetLogz(); - fhSetupSortedAsicRatioSameTsAdcVsFlux[ uXyterIdx ]->Draw( "colz" ); - - cFebDupliVsRate->cd( 1 + 2*fuNbStsXyters + uXyterIdx ); -// gPad->SetGridx(); -// gPad->SetGridy(); - gPad->SetLogx(); - gPad->SetLogz(); - fhSetupSortedAsicRatioSameAdcSameTsVsFlux[ uXyterIdx ]->Draw( "colz" ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) -//====================================================================// - -//====================================================================// - TCanvas* cStsMapXY = new TCanvas( "cStsMapXY", - "Sts XY maps", - w, h); - if( kTRUE == fbDualStsEna ) - { - cStsMapXY->Divide( 2, 2 ); - } // if( kTRUE == fbDualStsEna ) - - cStsMapXY->cd(1); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhStsSortedMapS1->Draw( "colz" ); - - if( kTRUE == fbDualStsEna ) - { - cStsMapXY->cd(2); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhStsSortedMapS2->Draw( "colz" ); - - cStsMapXY->cd(3); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhStsSortedMapS1Coinc->Draw( "colz" ); - - cStsMapXY->cd(4); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhStsSortedMapS2Coinc->Draw( "colz" ); - } // if( kTRUE == fbDualStsEna ) -//====================================================================// - - // Long duration rate monitoring -/* - if( kTRUE == fbLongHistoEnable ) - { - TCanvas* cStsLongRate = new TCanvas( "cStsLongRate" , "Long duration rate plots for StsXyter", - w, h); - cStsLongRate->Divide( 2, fuNbStsXyters ); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - cStsLongRate->cd( 1 + 2 * uXyterIdx ); - gPad->SetLogy(); - gPad->SetGridx(); - gPad->SetGridy(); - fhFebRateEvoLong[ uXyterIdx ]->Draw( "hist" ); - - cStsLongRate->cd( 2 + 2 * uXyterIdx ); - gPad->SetLogz(); - gPad->SetGridx(); - gPad->SetGridy(); - fhFebChRateEvoLong[ uXyterIdx ]->Draw( "colz" ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - } // if( kTRUE == fbLongHistoEnable ) -*/ -/* - Int_t iNbPadsPerDpb = fuNbElinksPerDpb/2 + fuNbElinksPerDpb%2; - TCanvas* cMuchChCounts = new TCanvas("cMuchChCounts", "MUCH Channels counts", w, h); - cMuchChCounts->Divide( fNrOfNdpbs/2 + fNrOfNdpbs%2, fNrOfFebsPerNdpb ); - - TCanvas* cMuchFebRate = new TCanvas("cMuchFebRate", "MUCH FEB rate", w, h); - cMuchFebRate->Divide( fNrOfNdpbs/2 + fNrOfNdpbs%2, fNrOfFebsPerNdpb ); - - TH1* histPnt = NULL; - for( Int_t dpbId = 0; dpbId < fNrOfNdpbs; dpbId++) - {// looping on all the nDPBS IDs - if( dpbId < fUnpackParHodo->GetNrOfnDpbsModA() ) - { - sNdpbTag = Form("%04X", fUnpackParHodo->GetNdpbIdA(dpbId) ); - } // if( dpbId < fUnpackParHodo->GetNrOfnDpbsModA() ) - else - { - sNdpbTag = Form("%04X", fUnpackParHodo->GetNdpbIdB(dpbId - fNrOfNdpbsA) ); - } // else of if( dpbId < fUnpackParHodo->GetNrOfnDpbsModA() ) - - for( Int_t febId = 0; febId < fNrOfFebsPerNdpb; febId++) - {// looping on all the FEB IDs - cMuchChCounts->cd( 1 + dpbId * iNbPadsPerDpb + febId/2 ); - gPad->SetLogy(); - sHistName = Form("Chan_Counts_Much_n%s_f%1u", sNdpbTag.Data(), febId); - histPnt = fHM->H1(sHistName.Data()); - - if( 0 == febId%2 ) - { - histPnt->SetLineColor( kRed ); // => Change color for 1st of the 2/pad! - histPnt->Draw(); - } // if( 0 == febId%2 ) - else - { - histPnt->SetLineColor( kBlue ); // => Change color for 1nd of the 2/pad! - histPnt->Draw("same"); - } // if( 0 == febId%2 ) - - cMuchFebRate->cd( 1 + dpbId * iNbPadsPerDpb + febId/2 ); - gPad->SetLogy(); - sHistName = Form("FebRate_n%s_f%1u", sNdpbTag.Data(), febId); - histPnt = fHM->H1(sHistName.Data()); - - if( 0 == febId%2 ) - { - histPnt->SetLineColor( kRed ); // => Change color for 1st of the 2/pad! - histPnt->Draw(); - } // if( 0 == febId%2 ) - else - { - histPnt->SetLineColor( kBlue ); // => Change color for 1nd of the 2/pad! - histPnt->Draw("same"); - } // if( 0 == febId%2 ) - } // for( Int_t febId = 0; febId < fNrOfFebsPerNdpb; febId++) - } // for( Int_t dpbId = 0; dpbId < fNrOfNdpbs; dpbId++) -*/ - - /** Recovers/Create Ms Size Canvase for CERN 2016 **/ - // Try to recover canvas in case it was created already by another monitor - // If not existing, create it - fcMsSizeAll = dynamic_cast<TCanvas *>( gROOT->FindObject( "cMsSizeAll" ) ); - if( NULL == fcMsSizeAll ) - { - fcMsSizeAll = new TCanvas("cMsSizeAll", "Evolution of MS size in last 300 s", w, h); - fcMsSizeAll->Divide( 4, 4 ); - LOG(info) << "Created MS size canvas in STS monitor"; - } // if( NULL == fcMsSizeAll ) - else LOG(info) << "Recovered MS size canvas in STS monitor"; - - /*****************************/ -} - -Bool_t CbmCosy2018MonitorSetupGood::DoUnpack(const fles::Timeslice& ts, size_t component) -{ - THttpServer* server = FairRunOnline::Instance()->GetHttpServer(); - - if( bCosy2018ResetSetupHistosGood ) - { - ResetAllHistos(); - bCosy2018ResetSetupHistosGood = kFALSE; - } // if( bCosy2018ResetSetupHistosGood ) - if( bCosy2018WriteSetupHistosGood ) - { - SaveAllHistos( fsHistoFileFullname ); - bCosy2018WriteSetupHistosGood = kFALSE; - } // if( bCosy2018WriteSetupHistosGood ) - - LOG(debug) << "Timeslice contains " << ts.num_microslices(component) - << "microslices."; - - if( component < kiMaxNbFlibLinks ) - if( NULL == fhMsSz[ component ] ) - { - TString sMsSzName = Form("MsSz_link_%02lu", component); - TString sMsSzTitle = Form("Size of MS for nDPB of link %02lu; Ms Size [bytes]", component); - fhMsSz[ component ] = new TH1F( sMsSzName.Data(), sMsSzTitle.Data(), 160000, 0., 20000. ); - fHM->Add(sMsSzName.Data(), fhMsSz[ component ] ); - if (server) server->Register("/FlibRaw", fhMsSz[ component ] ); - sMsSzName = Form("MsSzTime_link_%02lu", component); - sMsSzTitle = Form("Size of MS vs time for gDPB of link %02lu; Time[s] ; Ms Size [bytes]", component); - fhMsSzTime[ component ] = new TProfile( sMsSzName.Data(), sMsSzTitle.Data(), 15000, 0., 300. ); - fHM->Add( sMsSzName.Data(), fhMsSzTime[ component ] ); - if (server) server->Register("/FlibRaw", fhMsSzTime[ component ] ); - if( NULL != fcMsSizeAll ) - { - fcMsSizeAll->cd( 1 + component ); - gPad->SetLogy(); - fhMsSzTime[ component ]->Draw("hist le0"); - } // if( NULL != fcMsSizeAll ) - LOG(info) << "Added MS size histo for component: " << component - << " (DPB)"; - } // if( NULL == fhMsSz[ component ] ) - -// Int_t messageType = -111; - // Loop over microslices - size_t numCompMsInTs = ts.num_microslices(component); -/* - if( fulCurrentTsIdx + 1 != ts.index() && 0 == component) - LOG(info) << "Missed TS from " << fulCurrentTsIdx - << " to " << ts.index(); -*/ - fulCurrentTsIdx = ts.index(); - - if( fuMaxNbMicroslices < numCompMsInTs ) - { - fuMaxNbMicroslices = numCompMsInTs; - - fvdMsTime.resize( fuMaxNbMicroslices ); - fvuChanNbHitsInMs.resize( fuNbStsXyters ); - fvdChanLastHitTimeInMs.resize( fuNbStsXyters ); - fvusChanLastHitAdcInMs.resize( fuNbStsXyters ); - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fvuChanNbHitsInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvdChanLastHitTimeInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvusChanLastHitAdcInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - { - fvuChanNbHitsInMs[ uXyterIdx ][ uChan ].resize( fuMaxNbMicroslices ); - fvdChanLastHitTimeInMs[ uXyterIdx ][ uChan ].resize( fuMaxNbMicroslices ); - fvusChanLastHitAdcInMs[ uXyterIdx ][ uChan ].resize( fuMaxNbMicroslices ); - for( UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx ) - { - fvuChanNbHitsInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = 0; - fvdChanLastHitTimeInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = -1.0; - fvusChanLastHitAdcInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = 0; - } // for( UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx ) - } // for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - LOG(info) << "CbmCosy2018MonitorSetupGood::DoUnpack => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs.size() << " VS " << fuNbStsXyters; - LOG(info) << "CbmCosy2018MonitorSetupGood::DoUnpack => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs[ 0 ].size() << " VS " << fuNbChanPerAsic; - LOG(info) << "CbmCosy2018MonitorSetupGood::DoUnpack => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs[ 0 ][ 0 ].size() << " VS " << fuMaxNbMicroslices; - } // if( fuMaxNbMicroslices < numCompMsInTs ) - - for( size_t m = 0; m < numCompMsInTs; ++m ) - { - // Ignore overlap ms if number defined by user - if( numCompMsInTs - fuOverlapMsNb <= m ) - continue; - - auto msDescriptor = ts.descriptor(component, m); - fuCurrentEquipmentId = msDescriptor.eq_id; - const uint8_t* msContent = reinterpret_cast<const uint8_t*>(ts.content(component, m)); - - uint32_t size = msDescriptor.size; - fulCurrentMsIdx = msDescriptor.idx; - Double_t dMsTime = (1e-9) * static_cast<double>(fulCurrentMsIdx); - LOG(debug) << "Microslice: " << fulCurrentMsIdx - << " from EqId " << std::hex << fuCurrentEquipmentId << std::dec - << " has size: " << size; - - fuCurrDpbId = static_cast< uint32_t >( fuCurrentEquipmentId & 0xFFFF ); - fuCurrDpbIdx = fDpbIdIndexMap[ fuCurrDpbId ]; - - if( component < kiMaxNbFlibLinks ) - { - if( fdStartTimeMsSz < 0 ) - fdStartTimeMsSz = dMsTime; - fhMsSz[ component ]->Fill( size ); - fhMsSzTime[ component ]->Fill( dMsTime - fdStartTimeMsSz, size); - } // if( component < kiMaxNbFlibLinks ) - - // Store MS time for coincidence plots - fvdMsTime[ m ] = dMsTime; - - // If not integer number of message in input buffer, print warning/error - if( 0 != (size % kuBytesPerMessage) ) - LOG(error) << "The input microslice buffer does NOT " - << "contain only complete nDPB messages!"; - - // Compute the number of complete messages in the input microslice buffer - uint32_t uNbMessages = (size - (size % kuBytesPerMessage) ) - / kuBytesPerMessage; - - // Prepare variables for the loop on contents - const uint32_t* pInBuff = reinterpret_cast<const uint32_t*>( msContent ); - - for( uint32_t uIdx = 0; uIdx < uNbMessages; ++uIdx ) - { - // Fill message - uint32_t ulData = static_cast<uint32_t>(pInBuff[uIdx]); - - stsxyter::Message mess( static_cast< uint32_t >( ulData & 0xFFFFFFFF ) ); - - // Print message if requested - if( fbPrintMessages ) - mess.PrintMess( std::cout, fPrintMessCtrl ); - - stsxyter::MessType typeMess = mess.GetMessType(); - fmMsgCounter[ typeMess ] ++; - fhHodoMessType->Fill( static_cast< uint16_t > (typeMess) ); - fhHodoMessTypePerDpb->Fill( fuCurrDpbIdx, static_cast< uint16_t > (typeMess) ); - - switch( typeMess ) - { - case stsxyter::MessType::Hit : - { - // Extract the eLink and Asic indices => Should GO IN the fill method now that obly hits are link/asic specific! - UShort_t usElinkIdx = mess.GetLinkIndex(); - if( fuNbElinksPerDpb <= usElinkIdx ) - { - LOG(fatal) << "CbmCosy2018MonitorSetupGood::DoUnpack => " - << "eLink index out of bounds!" - << usElinkIdx << " VS " << fuNbElinksPerDpb; - } // if( fuNbElinksPerDpb <= usElinkIdx ) - fhHodoMessTypePerElink->Fill( fuCurrDpbIdx * fuNbElinksPerDpb + usElinkIdx, - static_cast< uint16_t > (typeMess) ); - - UInt_t uAsicIdx = fvuElinkToAsic[fuCurrDpbIdx][usElinkIdx]; - - FillHitInfo( mess, usElinkIdx, uAsicIdx, m ); - break; - } // case stsxyter::MessType::Hit : - case stsxyter::MessType::TsMsb : - { - FillTsMsbInfo( mess, uIdx, m ); - break; - } // case stsxyter::MessType::TsMsb : - case stsxyter::MessType::Epoch : - { - // The first message in the TS is a special ones: EPOCH - FillEpochInfo( mess ); - - if( 0 < uIdx ) - LOG(info) << "CbmCosy2018MonitorSetupGood::DoUnpack => " - << "EPOCH message at unexpected position in MS: message " - << uIdx << " VS message 0 expected!"; - break; - } // case stsxyter::MessType::TsMsb : - case stsxyter::MessType::Empty : - { -// FillTsMsbInfo( mess ); - break; - } // case stsxyter::MessType::Empty : - case stsxyter::MessType::Dummy : - { - break; - } // case stsxyter::MessType::Dummy / ReadDataAck / Ack : - default: - { - LOG(fatal) << "CbmCosy2018MonitorSetupGood::DoUnpack => " - << "Unknown message type, should never happen, stopping here!"; - } - } // switch( mess.GetMessType() ) - } // for( uint32_t uIdx = 0; uIdx < uNbMessages; ++uIdx ) - - // Sort the buffer of hits - std::sort( fvmHitsInTs.begin(), fvmHitsInTs.end() ); - - // Time differences plotting using the fully time sorted hits - Double_t dLastTimeX1 = -1e12; - Double_t dLastTimeY1 = -1e12; - Double_t dLastTimeX2 = -1e12; - Double_t dLastTimeY2 = -1e12; - Double_t dLastTimeN1 = -1e12; - Double_t dLastTimeP1 = -1e12; - Double_t dLastTimeN2 = -1e12; - Double_t dLastTimeP2 = -1e12; - Double_t dDtX1Y1 = -1e12; - Double_t dDtX2Y2 = -1e12; - Double_t dDtN1P1 = -1e12; - Double_t dDtN2P2 = -1e12; - Double_t dDtX1Y1X2Y2 = -1e12; - Double_t dDtN1P1N2P2 = -1e12; - Double_t dDtX1Y1X2Y2N1P1 = -1e12; - Double_t dDtX1Y1X2Y2N2P2 = -1e12; - Double_t dDtH1H2S1S2 = -1e12; - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - fvbAsicHasDuplicInMs[ uXyterIdx ] = kFALSE; - Bool_t bDuplicatedHitsInMs = kFALSE; - if( 0 < fvmHitsInTs.size() ) - { - ULong64_t ulLastHitTime = ( *( fvmHitsInTs.rbegin() ) ).GetTs(); - std::vector< stsxyter::FinalHit >::iterator it; - -// std::chrono::steady_clock::time_point tNow = std::chrono::steady_clock::now(); -// Double_t dUnixTimeInRun = std::chrono::duration_cast< std::chrono::seconds >(tNow - ftStartTimeUnix).count(); - - for( it = fvmHitsInTs.begin(); - it != fvmHitsInTs.end() && (*it).GetTs() < ulLastHitTime - 320; // 320 * 3.125 ns = 1000 ns - ++it ) - { - UShort_t usAsicIdx = (*it).GetAsic(); - UShort_t usChanIdx = (*it).GetChan(); - ULong64_t ulHitTs = (*it).GetTs(); - UShort_t usHitAdc = (*it).GetAdc(); - -// Bool_t bHitInX = usChanIdx < fuNbChanPerAsic/2; - - Double_t dTimeSinceStartSec = (ulHitTs * stsxyter::kdClockCycleNs - fdStartTime)* 1e-9; - if( 0 == ulHitTs - fvulTimeLastHitAsicChan[ usAsicIdx ][ usChanIdx ] || - ( 0 < fvuNbSameFullHitAsicChan[ usAsicIdx ][ usChanIdx ] && - 0 == ( ulHitTs - fvulTimeLastHitAsicChan[ usAsicIdx ][ usChanIdx ] ) % 512 ) ) - { - if( 0 == fviAdcLastHitAsicChan[ usAsicIdx ][ usChanIdx ] - usHitAdc ) - { - fvuNbSameFullHitAsicChan[ usAsicIdx ][ usChanIdx ] ++; - fvuNbHitSameTsAdcAsicLastS[ usAsicIdx ] ++; - } // if( 0 == fviAdcLastHitAsicChan[ usAsicIdx ][ usChanIdx ] - usHitAdc ) - else - { - fhSetupSortedNbConsSameTsAdcChan[ usAsicIdx ]->Fill( usChanIdx, fvuNbSameFullHitAsicChan[ usAsicIdx ][ usChanIdx ] ); - fhSetupSortedNbConsSameTsVsTsAdc[ usAsicIdx ]->Fill( fvuNbSameHitAsicChan[ usAsicIdx ][ usChanIdx ], - fvuNbSameFullHitAsicChan[ usAsicIdx ][ usChanIdx ] ); - fvuNbSameFullHitAsicChan[ usAsicIdx ][ usChanIdx ] = 0; - } // else of if( 0 == fviAdcLastHitAsicChan[ usAsicIdx ][ usChanIdx ] - usHitAdc ) - - fvuNbSameHitAsicChan[ usAsicIdx ][ usChanIdx ] ++; - fvuNbHitSameTsAsicLastS[ usAsicIdx ] ++; -/* - LOG(info) << Form("Bad Hit on asic %u chan %3u, #%3u => TS %9llu ADC %2u VS TS %9llu ADC %2u", - usAsicIdx, usChanIdx, fvuNbSameHitAsicChan[ usAsicIdx ][ usChanIdx ], - ulHitTs, usHitAdc, - fvulTimeLastHitAsicChan[ usAsicIdx ][ usChanIdx ], - fviAdcLastHitAsicChan[ usAsicIdx ][ usChanIdx ] ); -*/ - fhSetupSortedNbSameTsChan[ usAsicIdx ]->Fill( dTimeSinceStartSec, usChanIdx ); - fhSetupSortedSameTsAdcChan[ usAsicIdx ]->Fill( usChanIdx, usHitAdc ); - fhSetupSortedSameTsAdcChan[ usAsicIdx ]->Fill( usChanIdx, fviAdcLastHitAsicChan[ usAsicIdx ][ usChanIdx ] ); - fhSetupSortedSameTsAdcDiff[ usAsicIdx ]->Fill( fvuNbSameHitAsicChan[ usAsicIdx ][ usChanIdx ], - static_cast< Int_t >( usHitAdc ) - - fviAdcLastHitAsicChan[ usAsicIdx ][ usChanIdx ] ); - fhSetupSortedRatioSameTsChan[ usAsicIdx ]->Fill( dTimeSinceStartSec, usChanIdx, 1.0 ); - - /// Jump the duplicated hits without updating the othe variables - fvbAsicHasDuplicInMs[ usAsicIdx ] = kTRUE; - bDuplicatedHitsInMs = kTRUE; - continue; - } // if( 0 == ulHitTs - fvulTimeLastHitAsicChan[ usAsicIdx ][ usChanIdx ] ) - else - { -/* - if( 100 < fvuNbSameHitAsicChan[ usAsicIdx ][ usChanIdx ] ) - LOG(fatal) << " More than 100 consecutive hits with same TS on asic" - << usAsicIdx << " chan " << usChanIdx - << " => " << fvuNbSameHitAsicChan[ usAsicIdx ][ usChanIdx ]; -*/ - fhSetupSortedNbConsSameTsVsTsAdc[ usAsicIdx ]->Fill( fvuNbSameHitAsicChan[ usAsicIdx ][ usChanIdx ], - fvuNbSameFullHitAsicChan[ usAsicIdx ][ usChanIdx ] ); - - fhSetupSortedNbConsSameTsChan[ usAsicIdx ]->Fill( usChanIdx, fvuNbSameHitAsicChan[ usAsicIdx ][ usChanIdx ] ); - fvuNbSameHitAsicChan[ usAsicIdx ][ usChanIdx ] = 0; - - fhSetupSortedNbConsSameTsAdcChan[ usAsicIdx ]->Fill( usChanIdx, fvuNbSameFullHitAsicChan[ usAsicIdx ][ usChanIdx ] ); - fvuNbSameFullHitAsicChan[ usAsicIdx ][ usChanIdx ] = 0; - - fhSetupSortedRatioSameTsChan[ usAsicIdx ]->Fill( dTimeSinceStartSec, usChanIdx, 0.0 ); - - fvuNbHitDiffTsAsicLastS[ usAsicIdx ]++; - } // else of if( 0 == ulHitTs - fvulTimeLastHitAsicChan[ usAsicIdx ][ usChanIdx ] ) - fvulTimeLastHitAsicChan[ usAsicIdx ][ usChanIdx ] = ulHitTs; - fviAdcLastHitAsicChan[ usAsicIdx ][ usChanIdx ] = usHitAdc; - } // loop on hits untils hits within 100 ns of last one or last one itself are reached - - // Remove all hits in case some duplicated ones where found - if( kTRUE == bDuplicatedHitsInMs ) - fvmHitsInTs.erase( fvmHitsInTs.begin(), fvmHitsInTs.end() ); - else fhSizeCleanMs->Fill( fvmHitsInTs.size() ); - - for( it = fvmHitsInTs.begin(); - it != fvmHitsInTs.end() && (*it).GetTs() < ulLastHitTime - 320; // 320 * 3.125 ns = 1000 ns - ++it ) - { - UShort_t usAsicIdx = (*it).GetAsic(); - UShort_t usChanIdx = (*it).GetChan(); - ULong64_t ulHitTs = (*it).GetTs(); -// UShort_t usHitAdc = (*it).GetAdc(); - - Bool_t bHitInX = usChanIdx < fuNbChanPerAsic/2; - - Double_t dTimeSinceStartSec = (ulHitTs * stsxyter::kdClockCycleNs - fdStartTime)* 1e-9; - if( fUnpackParHodo->GetAsicIndexHodo1() == usAsicIdx ) - { - if( fUnpackParHodo->IsXySwappedHodo1() ) - bHitInX = !bHitInX; - - if( bHitInX ) - { - Double_t dDtSameFeb = ( ulHitTs - dLastTimeX1 ) * stsxyter::kdClockCycleNs; - fhSetupSortedDtX1->Fill( dDtSameFeb ); - - fLastSortedHit1X = (*it); - dLastTimeX1 = ulHitTs; - - /// Compute fiber Idx of the last Hodo hits - UInt_t uFiberIdxX1 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit1X.GetChan() ); - if( fUnpackParHodo->IsXInvertedHodo1() ) - uFiberIdxX1 = fuNbChanPerAsic/2 - 1 - uFiberIdxX1; - UInt_t uFiberIdxY1 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit1Y.GetChan() ); - if( fUnpackParHodo->IsYInvertedHodo1() ) - uFiberIdxY1 = fuNbChanPerAsic/2 - 1 - uFiberIdxY1; - UInt_t uFiberIdxX2 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit2X.GetChan() ); - if( fUnpackParHodo->IsXInvertedHodo2() ) - uFiberIdxX2 = fuNbChanPerAsic/2 - 1 - uFiberIdxX2; - UInt_t uFiberIdxY2 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit2Y.GetChan() ); - if( fUnpackParHodo->IsYInvertedHodo2() ) - uFiberIdxY2 = fuNbChanPerAsic/2 - 1 - uFiberIdxY2; - - if( dTimeSinceStartSec < fdSpillEvoLength ) - { - fhHodoX1SpillEvo->Fill( dTimeSinceStartSec, uFiberIdxX1 ); - fhHodoX1SpillEvoProf->Fill( dTimeSinceStartSec, uFiberIdxX1 ); - } // if( dTimeSinceStartSec < fdSpillEvoLength ) - - dDtX1Y1 = ( dLastTimeY1 - dLastTimeX1 ) * stsxyter::kdClockCycleNs; - dDtX2Y2 = ( dLastTimeY2 - dLastTimeX2 ) * stsxyter::kdClockCycleNs; - dDtN1P1 = ( dLastTimeP1 - dLastTimeN1 ) * stsxyter::kdClockCycleNs; - dDtX1Y1X2Y2 = ( ( dLastTimeX2 + dLastTimeY2 ) - ( dLastTimeX1 + dLastTimeY1 ) ) - * stsxyter::kdClockCycleNs / 2.0; - dDtX1Y1X2Y2N1P1 = ( ( dLastTimeN1 + dLastTimeP1 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) / 4.0 - ) * stsxyter::kdClockCycleNs; - if( kTRUE == fbDualStsEna ) - { - dDtN2P2 = ( dLastTimeP2 - dLastTimeN2 ) * stsxyter::kdClockCycleNs; - dDtN1P1N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) - ( dLastTimeN1 + dLastTimeP1 ) ) - * stsxyter::kdClockCycleNs / 2.0; - dDtX1Y1X2Y2N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) / 4.0 - ) * stsxyter::kdClockCycleNs; - dDtH1H2S1S2 = ( ( dLastTimeN2 + dLastTimeP2 + dLastTimeN1 + dLastTimeP1 ) - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) - ) * stsxyter::kdClockCycleNs / 4.0; - } // if( kTRUE == fbDualStsEna ) - - fhSetupSortedDtX1Y1->Fill( dDtX1Y1 ); - fhSetupSortedDtX1Y1X2Y2->Fill( dDtX1Y1X2Y2 ); - fhSetupSortedDtX1Y1X2Y2N1P1->Fill( dDtX1Y1X2Y2N1P1 ); - if( kTRUE == fbDualStsEna ) - { - fhSetupSortedDtX1Y1X2Y2N2P2->Fill( dDtX1Y1X2Y2N2P2 ); - fhSetupSortedDtH1H2S1S2->Fill( dDtH1H2S1S2 ); - } // if( kTRUE == fbDualStsEna ) - - if( TMath::Abs( dDtX1Y1 ) < fdCoincBorderHodo ) - { - fhSetupSortedMapX1Y1->Fill( uFiberIdxX1, uFiberIdxY1 ); - fhSetupSortedCntEvoX1Y1->Fill( dTimeSinceStartSec ); - } // if( TMath::Abs( dDtX1Y1 ) < fdCoincBorderHodo ) - - if( TMath::Abs( dDtX1Y1 ) < fdCoincBorderHodo && - TMath::Abs( dDtX2Y2 ) < fdCoincBorderHodo && - TMath::Abs( dDtX1Y1X2Y2 ) < 2 * fdCoincBorderHodo ) - { - fhBothHodoSortedDtX1Y1->Fill( dDtX1Y1 ); - fhBothHodoSortedDtX2Y2->Fill( dDtX2Y2 ); - fhBothHodoSortedDtX1Y1X2Y2N1P1->Fill( dDtX1Y1X2Y2N1P1 ); - fhBothHodoSortedDtX1Y1X2Y2N2P2->Fill( dDtX1Y1X2Y2N2P2 ); - - fhBothHodoSortedMapX1Y1->Fill( uFiberIdxX1, uFiberIdxY1 ); - fhBothHodoSortedMapX2Y2->Fill( uFiberIdxX2, uFiberIdxY2 ); - fhBothHodoSortedCntEvoX1Y1->Fill( dTimeSinceStartSec ); - } // if( TMath::Abs( dDtX1Y1X2Y2 ) < 2 * fdCoincBorderHodo ) - - if( TMath::Abs( dDtX1Y1 ) < fdCoincBorderHodo && - TMath::Abs( dDtX2Y2 ) < fdCoincBorderHodo && - TMath::Abs( dDtN1P1 ) < fdCoincBorderSts && - TMath::Abs( dDtN2P2 ) < fdCoincBorderSts && - TMath::Abs( dDtX1Y1X2Y2 ) < 2 * fdCoincBorderHodo && - TMath::Abs( dDtN1P1N2P2 ) < 2 * fdCoincBorderSts && - TMath::Abs( dDtX1Y1X2Y2N1P1 ) < fdCoincBorder && - TMath::Abs( dDtX1Y1X2Y2N2P2 ) < fdCoincBorder && - TMath::Abs( dDtH1H2S1S2 ) < fdCoincBorder ) - { - fhSystSortedDtX1Y1->Fill( dDtX1Y1 ); - fhSystSortedDtX2Y2->Fill( dDtX2Y2 ); - fhSystSortedDtN1P1->Fill( dDtN1P1 ); - fhSystSortedDtN2P2->Fill( dDtN2P2 ); - fhSystSortedDtX1Y1X2Y2->Fill( dDtX1Y1X2Y2 ); - - fhSystSortedMapX1Y1->Fill( uFiberIdxX1, uFiberIdxY1 ); - fhSystSortedMapX2Y2->Fill( uFiberIdxX2, uFiberIdxY2 ); - fhSystSortedMapN1P1->Fill( fLastSortedHit1N.GetChan(), fLastSortedHit1P.GetChan() ); - fhSystSortedMapN2P2->Fill( fLastSortedHit2N.GetChan(), fLastSortedHit2P.GetChan() ); - fhSystSortedCntEvoX1Y1->Fill( dTimeSinceStartSec ); - fhSystSortedDtAllVsMapX1->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxX1 ); - fhSystSortedDtAllVsMapY1->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxY1 ); - fhSystSortedDtAllVsMapX2->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxX2 ); - fhSystSortedDtAllVsMapY2->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxY2 ); - - Double_t dDtN1X1 = ( dLastTimeN1 - dLastTimeX1 ) * stsxyter::kdClockCycleNs; - Double_t dDtN1X2 = ( dLastTimeN1 - dLastTimeX2 ) * stsxyter::kdClockCycleNs; - Double_t dDtP1X1 = ( dLastTimeP1 - dLastTimeX1 ) * stsxyter::kdClockCycleNs; - Double_t dDtP1X2 = ( dLastTimeP1 - dLastTimeX2 ) * stsxyter::kdClockCycleNs; - fhSystSortedDtN1X1vsN1X2->Fill( dDtN1X1, dDtN1X2 ); - fhSystSortedDtP1X1vsP1X2->Fill( dDtP1X1, dDtP1X2 ); - fhSystSortedDtN1X1vsP1X1->Fill( dDtN1X1, dDtP1X1 ); - - Double_t dDtX1Y1N1P1 = ( ( dLastTimeN1 + dLastTimeP1 ) / 2.0 - - ( dLastTimeX1 + dLastTimeY1 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - Double_t dDtX2Y2N1P1 = ( ( dLastTimeN1 + dLastTimeP1 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - fhSystSortedDtSts1Hodo1vsSts1Hodo2->Fill( dDtX1Y1N1P1, dDtX2Y2N1P1 ); - - Double_t dDtX1Y1N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) / 2.0 - - ( dLastTimeX1 + dLastTimeY1 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - Double_t dDtX2Y2N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - fhSystSortedDtSts2Hodo1vsSts2Hodo2->Fill( dDtX1Y1N2P2, dDtX2Y2N2P2 ); - } // if( TMath::Abs( dDtX1Y1X2Y2N1P1 ) < fdCoincBorder ) - } // if( bHitInX ) - else - { - Double_t dDtSameFeb = ( ulHitTs - dLastTimeY1 ) * stsxyter::kdClockCycleNs; - fhSetupSortedDtY1->Fill( dDtSameFeb ); - - fLastSortedHit1Y = (*it); - dLastTimeY1 = ulHitTs; - - /// Compute fiber Idx of the last Hodo hits - UInt_t uFiberIdxX1 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit1X.GetChan() ); - if( fUnpackParHodo->IsXInvertedHodo1() ) - uFiberIdxX1 = fuNbChanPerAsic/2 - 1 - uFiberIdxX1; - UInt_t uFiberIdxY1 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit1Y.GetChan() ); - if( fUnpackParHodo->IsYInvertedHodo1() ) - uFiberIdxY1 = fuNbChanPerAsic/2 - 1 - uFiberIdxY1; - UInt_t uFiberIdxX2 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit2X.GetChan() ); - if( fUnpackParHodo->IsXInvertedHodo2() ) - uFiberIdxX2 = fuNbChanPerAsic/2 - 1 - uFiberIdxX2; - UInt_t uFiberIdxY2 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit2Y.GetChan() ); - if( fUnpackParHodo->IsYInvertedHodo2() ) - uFiberIdxY2 = fuNbChanPerAsic/2 - 1 - uFiberIdxY2; - - if( dTimeSinceStartSec < fdSpillEvoLength ) - { - fhHodoY1SpillEvo->Fill( dTimeSinceStartSec, uFiberIdxY1 ); - fhHodoY1SpillEvoProf->Fill( dTimeSinceStartSec, uFiberIdxY1 ); - } // if( dTimeSinceStartSec < fdSpillEvoLength ) - - dDtX1Y1 = ( dLastTimeY1 - dLastTimeX1 ) * stsxyter::kdClockCycleNs; - dDtX2Y2 = ( dLastTimeY2 - dLastTimeX2 ) * stsxyter::kdClockCycleNs; - dDtN1P1 = ( dLastTimeP1 - dLastTimeN1 ) * stsxyter::kdClockCycleNs; - dDtX1Y1X2Y2 = ( ( dLastTimeX2 + dLastTimeY2 ) - ( dLastTimeX1 + dLastTimeY1 ) ) - * stsxyter::kdClockCycleNs / 2.0; - dDtX1Y1X2Y2N1P1 = ( ( dLastTimeN1 + dLastTimeP1 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) / 4.0 - ) * stsxyter::kdClockCycleNs; - if( kTRUE == fbDualStsEna ) - { - dDtN2P2 = ( dLastTimeP2 - dLastTimeN2 ) * stsxyter::kdClockCycleNs; - dDtN1P1N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) - ( dLastTimeN1 + dLastTimeP1 ) ) - * stsxyter::kdClockCycleNs / 2.0; - dDtX1Y1X2Y2N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) / 4.0 - ) * stsxyter::kdClockCycleNs; - dDtH1H2S1S2 = ( ( dLastTimeN2 + dLastTimeP2 + dLastTimeN1 + dLastTimeP1 ) - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) - ) * stsxyter::kdClockCycleNs / 4.0; - } // if( kTRUE == fbDualStsEna ) - - fhSetupSortedDtX1Y1->Fill( dDtX1Y1 ); - fhSetupSortedDtX1Y1X2Y2->Fill( dDtX1Y1X2Y2 ); - fhSetupSortedDtX1Y1X2Y2N1P1->Fill( dDtX1Y1X2Y2N1P1 ); - if( kTRUE == fbDualStsEna ) - { - fhSetupSortedDtX1Y1X2Y2N2P2->Fill( dDtX1Y1X2Y2N2P2 ); - fhSetupSortedDtH1H2S1S2->Fill( dDtH1H2S1S2 ); - } // if( kTRUE == fbDualStsEna ) - - if( TMath::Abs( dDtX1Y1 ) < fdCoincBorderHodo ) - { - fhSetupSortedMapX1Y1->Fill( uFiberIdxX1, uFiberIdxY1 ); - fhSetupSortedCntEvoX1Y1->Fill( dTimeSinceStartSec ); - } // if( TMath::Abs( dDtX1Y1 ) < fdCoincBorderHodo ) - - if( TMath::Abs( dDtX1Y1 ) < fdCoincBorderHodo && - TMath::Abs( dDtX2Y2 ) < fdCoincBorderHodo && - TMath::Abs( dDtX1Y1X2Y2 ) < 2 * fdCoincBorderHodo ) - { - fhBothHodoSortedDtX1Y1->Fill( dDtX1Y1 ); - fhBothHodoSortedDtX2Y2->Fill( dDtX2Y2 ); - fhBothHodoSortedDtX1Y1X2Y2N1P1->Fill( dDtX1Y1X2Y2N1P1 ); - fhBothHodoSortedDtX1Y1X2Y2N2P2->Fill( dDtX1Y1X2Y2N2P2 ); - - fhBothHodoSortedMapX1Y1->Fill( uFiberIdxX1, uFiberIdxY1 ); - fhBothHodoSortedMapX2Y2->Fill( uFiberIdxX2, uFiberIdxY2 ); - fhBothHodoSortedCntEvoX1Y1->Fill( dTimeSinceStartSec ); - } // if( TMath::Abs( dDtX1Y1X2Y2 ) < 2 * fdCoincBorderHodo ) - - if( TMath::Abs( dDtX1Y1 ) < fdCoincBorderHodo && - TMath::Abs( dDtX2Y2 ) < fdCoincBorderHodo && - TMath::Abs( dDtN1P1 ) < fdCoincBorderSts && - TMath::Abs( dDtN2P2 ) < fdCoincBorderSts && - TMath::Abs( dDtX1Y1X2Y2 ) < 2 * fdCoincBorderHodo && - TMath::Abs( dDtN1P1N2P2 ) < 2 * fdCoincBorderSts && - TMath::Abs( dDtX1Y1X2Y2N1P1 ) < fdCoincBorder && - TMath::Abs( dDtX1Y1X2Y2N2P2 ) < fdCoincBorder && - TMath::Abs( dDtH1H2S1S2 ) < fdCoincBorder ) - { - fhSystSortedDtX1Y1->Fill( dDtX1Y1 ); - fhSystSortedDtX2Y2->Fill( dDtX2Y2 ); - fhSystSortedDtN1P1->Fill( dDtN1P1 ); - fhSystSortedDtN2P2->Fill( dDtN2P2 ); - fhSystSortedDtX1Y1X2Y2->Fill( dDtX1Y1X2Y2 ); - - fhSystSortedMapX1Y1->Fill( uFiberIdxX1, uFiberIdxY1 ); - fhSystSortedMapX2Y2->Fill( uFiberIdxX2, uFiberIdxY2 ); - fhSystSortedMapN1P1->Fill( fLastSortedHit1N.GetChan(), fLastSortedHit1P.GetChan() ); - fhSystSortedMapN2P2->Fill( fLastSortedHit2N.GetChan(), fLastSortedHit2P.GetChan() ); - fhSystSortedCntEvoX1Y1->Fill( dTimeSinceStartSec ); - fhSystSortedDtAllVsMapX1->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxX1 ); - fhSystSortedDtAllVsMapY1->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxY1 ); - fhSystSortedDtAllVsMapX2->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxX2 ); - fhSystSortedDtAllVsMapY2->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxY2 ); - - Double_t dDtN1X1 = ( dLastTimeN1 - dLastTimeX1 ) * stsxyter::kdClockCycleNs; - Double_t dDtN1X2 = ( dLastTimeN1 - dLastTimeX2 ) * stsxyter::kdClockCycleNs; - Double_t dDtP1X1 = ( dLastTimeP1 - dLastTimeX1 ) * stsxyter::kdClockCycleNs; - Double_t dDtP1X2 = ( dLastTimeP1 - dLastTimeX2 ) * stsxyter::kdClockCycleNs; - fhSystSortedDtN1X1vsN1X2->Fill( dDtN1X1, dDtN1X2 ); - fhSystSortedDtP1X1vsP1X2->Fill( dDtP1X1, dDtP1X2 ); - fhSystSortedDtN1X1vsP1X1->Fill( dDtN1X1, dDtP1X1 ); - - Double_t dDtX1Y1N1P1 = ( ( dLastTimeN1 + dLastTimeP1 ) / 2.0 - - ( dLastTimeX1 + dLastTimeY1 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - Double_t dDtX2Y2N1P1 = ( ( dLastTimeN1 + dLastTimeP1 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - fhSystSortedDtSts1Hodo1vsSts1Hodo2->Fill( dDtX1Y1N1P1, dDtX2Y2N1P1 ); - - Double_t dDtX1Y1N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) / 2.0 - - ( dLastTimeX1 + dLastTimeY1 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - Double_t dDtX2Y2N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - fhSystSortedDtSts2Hodo1vsSts2Hodo2->Fill( dDtX1Y1N2P2, dDtX2Y2N2P2 ); - } // if( TMath::Abs( dDtX1Y1X2Y2N1P1 ) < fdCoincBorder ) - } // else of if( bHitInX ) - } // if( fUnpackParHodo->GetAsicIndexHodo1() == usAsicIdx ) - else if( fUnpackParHodo->GetAsicIndexHodo2() == usAsicIdx ) - { - if( fUnpackParHodo->IsXySwappedHodo2() ) - bHitInX = !bHitInX; - - if( bHitInX ) - { - Double_t dDtSameFeb = ( ulHitTs - dLastTimeX2 ) * stsxyter::kdClockCycleNs; - fhSetupSortedDtX2->Fill( dDtSameFeb ); - - fLastSortedHit2X = (*it); - dLastTimeX2 = ulHitTs; - - /// Compute fiber Idx of the last Hodo hits - UInt_t uFiberIdxX1 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit1X.GetChan() ); - if( fUnpackParHodo->IsXInvertedHodo1() ) - uFiberIdxX1 = fuNbChanPerAsic/2 - 1 - uFiberIdxX1; - UInt_t uFiberIdxY1 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit1Y.GetChan() ); - if( fUnpackParHodo->IsYInvertedHodo1() ) - uFiberIdxY1 = fuNbChanPerAsic/2 - 1 - uFiberIdxY1; - UInt_t uFiberIdxX2 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit2X.GetChan() ); - if( fUnpackParHodo->IsXInvertedHodo2() ) - uFiberIdxX2 = fuNbChanPerAsic/2 - 1 - uFiberIdxX2; - UInt_t uFiberIdxY2 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit2Y.GetChan() ); - if( fUnpackParHodo->IsYInvertedHodo2() ) - uFiberIdxY2 = fuNbChanPerAsic/2 - 1 - uFiberIdxY2; - - if( dTimeSinceStartSec < fdSpillEvoLength ) - { - fhHodoX2SpillEvo->Fill( dTimeSinceStartSec, uFiberIdxX2 ); - fhHodoX2SpillEvoProf->Fill( dTimeSinceStartSec, uFiberIdxX2 ); - } // if( dTimeSinceStartSec < fdSpillEvoLength ) - - dDtX1Y1 = ( dLastTimeY1 - dLastTimeX1 ) * stsxyter::kdClockCycleNs; - dDtX2Y2 = ( dLastTimeY2 - dLastTimeX2 ) * stsxyter::kdClockCycleNs; - dDtN1P1 = ( dLastTimeP1 - dLastTimeN1 ) * stsxyter::kdClockCycleNs; - dDtX1Y1X2Y2 = ( ( dLastTimeX2 + dLastTimeY2 ) - ( dLastTimeX1 + dLastTimeY1 ) ) - * stsxyter::kdClockCycleNs / 2.0; - dDtX1Y1X2Y2N1P1 = ( ( dLastTimeN1 + dLastTimeP1 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) / 4.0 - ) * stsxyter::kdClockCycleNs; - if( kTRUE == fbDualStsEna ) - { - dDtN2P2 = ( dLastTimeP2 - dLastTimeN2 ) * stsxyter::kdClockCycleNs; - dDtN1P1N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) - ( dLastTimeN1 + dLastTimeP1 ) ) - * stsxyter::kdClockCycleNs / 2.0; - dDtX1Y1X2Y2N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) / 4.0 - ) * stsxyter::kdClockCycleNs; - dDtH1H2S1S2 = ( ( dLastTimeN2 + dLastTimeP2 + dLastTimeN1 + dLastTimeP1 ) - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) - ) * stsxyter::kdClockCycleNs / 4.0; - } // if( kTRUE == fbDualStsEna ) - - fhSetupSortedDtX2Y2->Fill( dDtX2Y2 ); - fhSetupSortedDtX1Y1X2Y2->Fill( dDtX1Y1X2Y2 ); - fhSetupSortedDtX1Y1X2Y2N1P1->Fill( dDtX1Y1X2Y2N1P1 ); - if( kTRUE == fbDualStsEna ) - { - fhSetupSortedDtX1Y1X2Y2N2P2->Fill( dDtX1Y1X2Y2N2P2 ); - fhSetupSortedDtH1H2S1S2->Fill( dDtH1H2S1S2 ); - } // if( kTRUE == fbDualStsEna ) - - if( TMath::Abs( dDtX2Y2 ) < fdCoincBorderHodo ) - { - fhSetupSortedMapX2Y2->Fill( uFiberIdxX2, uFiberIdxY2 ); - fhSetupSortedCntEvoX2Y2->Fill( dTimeSinceStartSec ); - } // if( TMath::Abs( dDtX2Y2 ) < fdCoincBorderHodo ) - - if( TMath::Abs( dDtX1Y1 ) < fdCoincBorderHodo && - TMath::Abs( dDtX2Y2 ) < fdCoincBorderHodo && - TMath::Abs( dDtX1Y1X2Y2 ) < 2 * fdCoincBorderHodo ) - { - fhBothHodoSortedDtX1Y1->Fill( dDtX1Y1 ); - fhBothHodoSortedDtX2Y2->Fill( dDtX2Y2 ); - fhBothHodoSortedDtX1Y1X2Y2N1P1->Fill( dDtX1Y1X2Y2N1P1 ); - fhBothHodoSortedDtX1Y1X2Y2N2P2->Fill( dDtX1Y1X2Y2N2P2 ); - - fhBothHodoSortedMapX1Y1->Fill( uFiberIdxX1, uFiberIdxY1 ); - fhBothHodoSortedMapX2Y2->Fill( uFiberIdxX2, uFiberIdxY2 ); - fhBothHodoSortedCntEvoX2Y2->Fill( dTimeSinceStartSec ); - } // if( TMath::Abs( dDtX1Y1X2Y2 ) < 2 * fdCoincBorderHodo ) - - if( TMath::Abs( dDtX1Y1 ) < fdCoincBorderHodo && - TMath::Abs( dDtX2Y2 ) < fdCoincBorderHodo && - TMath::Abs( dDtN1P1 ) < fdCoincBorderSts && - TMath::Abs( dDtN2P2 ) < fdCoincBorderSts && - TMath::Abs( dDtX1Y1X2Y2 ) < 2 * fdCoincBorderHodo && - TMath::Abs( dDtN1P1N2P2 ) < 2 * fdCoincBorderSts && - TMath::Abs( dDtX1Y1X2Y2N1P1 ) < fdCoincBorder && - TMath::Abs( dDtX1Y1X2Y2N2P2 ) < fdCoincBorder && - TMath::Abs( dDtH1H2S1S2 ) < fdCoincBorder ) - { - fhSystSortedDtX1Y1->Fill( dDtX1Y1 ); - fhSystSortedDtX2Y2->Fill( dDtX2Y2 ); - fhSystSortedDtN1P1->Fill( dDtN1P1 ); - fhSystSortedDtN2P2->Fill( dDtN2P2 ); - fhSystSortedDtX1Y1X2Y2->Fill( dDtX1Y1X2Y2 ); - - fhSystSortedMapX1Y1->Fill( uFiberIdxX1, uFiberIdxY1 ); - fhSystSortedMapX2Y2->Fill( uFiberIdxX2, uFiberIdxY2 ); - fhSystSortedMapN1P1->Fill( fLastSortedHit1N.GetChan(), fLastSortedHit1P.GetChan() ); - fhSystSortedMapN2P2->Fill( fLastSortedHit2N.GetChan(), fLastSortedHit2P.GetChan() ); - fhSystSortedCntEvoX2Y2->Fill( dTimeSinceStartSec ); - fhSystSortedDtAllVsMapX1->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxX1 ); - fhSystSortedDtAllVsMapY1->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxY1 ); - fhSystSortedDtAllVsMapX2->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxX2 ); - fhSystSortedDtAllVsMapY2->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxY2 ); - - Double_t dDtN1X1 = ( dLastTimeN1 - dLastTimeX1 ) * stsxyter::kdClockCycleNs; - Double_t dDtN1X2 = ( dLastTimeN1 - dLastTimeX2 ) * stsxyter::kdClockCycleNs; - Double_t dDtP1X1 = ( dLastTimeP1 - dLastTimeX1 ) * stsxyter::kdClockCycleNs; - Double_t dDtP1X2 = ( dLastTimeP1 - dLastTimeX2 ) * stsxyter::kdClockCycleNs; - fhSystSortedDtN1X1vsN1X2->Fill( dDtN1X1, dDtN1X2 ); - fhSystSortedDtP1X1vsP1X2->Fill( dDtP1X1, dDtP1X2 ); - fhSystSortedDtN1X1vsP1X1->Fill( dDtN1X1, dDtP1X1 ); - - Double_t dDtX1Y1N1P1 = ( ( dLastTimeN1 + dLastTimeP1 ) / 2.0 - - ( dLastTimeX1 + dLastTimeY1 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - Double_t dDtX2Y2N1P1 = ( ( dLastTimeN1 + dLastTimeP1 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - fhSystSortedDtSts1Hodo1vsSts1Hodo2->Fill( dDtX1Y1N1P1, dDtX2Y2N1P1 ); - - Double_t dDtX1Y1N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) / 2.0 - - ( dLastTimeX1 + dLastTimeY1 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - Double_t dDtX2Y2N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - fhSystSortedDtSts2Hodo1vsSts2Hodo2->Fill( dDtX1Y1N2P2, dDtX2Y2N2P2 ); - } // if( TMath::Abs( dDtX1Y1X2Y2N1P1 ) < fdCoincBorder ) - } // if( bHitInX ) - else - { - Double_t dDtSameFeb = ( ulHitTs - dLastTimeY2 ) * stsxyter::kdClockCycleNs; - fhSetupSortedDtY2->Fill( dDtSameFeb ); - - fLastSortedHit2Y = (*it); - dLastTimeY2 = ulHitTs; - - /// Compute fiber Idx of the last Hodo hits - UInt_t uFiberIdxX1 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit1X.GetChan() ); - if( fUnpackParHodo->IsXInvertedHodo1() ) - uFiberIdxX1 = fuNbChanPerAsic/2 - 1 - uFiberIdxX1; - UInt_t uFiberIdxY1 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit1Y.GetChan() ); - if( fUnpackParHodo->IsYInvertedHodo1() ) - uFiberIdxY1 = fuNbChanPerAsic/2 - 1 - uFiberIdxY1; - UInt_t uFiberIdxX2 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit2X.GetChan() ); - if( fUnpackParHodo->IsXInvertedHodo2() ) - uFiberIdxX2 = fuNbChanPerAsic/2 - 1 - uFiberIdxX2; - UInt_t uFiberIdxY2 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit2Y.GetChan() ); - if( fUnpackParHodo->IsYInvertedHodo2() ) - uFiberIdxY2 = fuNbChanPerAsic/2 - 1 - uFiberIdxY2; - - if( dTimeSinceStartSec < fdSpillEvoLength ) - { - fhHodoY2SpillEvo->Fill( dTimeSinceStartSec, uFiberIdxY2 ); - fhHodoY2SpillEvoProf->Fill( dTimeSinceStartSec, uFiberIdxY2 ); - } // if( dTimeSinceStartSec < fdSpillEvoLength ) - - dDtX1Y1 = ( dLastTimeY1 - dLastTimeX1 ) * stsxyter::kdClockCycleNs; - dDtX2Y2 = ( dLastTimeY2 - dLastTimeX2 ) * stsxyter::kdClockCycleNs; - dDtN1P1 = ( dLastTimeP1 - dLastTimeN1 ) * stsxyter::kdClockCycleNs; - dDtX1Y1X2Y2 = ( ( dLastTimeX2 + dLastTimeY2 ) - ( dLastTimeX1 + dLastTimeY1 ) ) - * stsxyter::kdClockCycleNs / 2.0; - dDtX1Y1X2Y2N1P1 = ( ( dLastTimeN1 + dLastTimeP1 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) / 4.0 - ) * stsxyter::kdClockCycleNs; - if( kTRUE == fbDualStsEna ) - { - dDtN2P2 = ( dLastTimeP2 - dLastTimeN2 ) * stsxyter::kdClockCycleNs; - dDtN1P1N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) - ( dLastTimeN1 + dLastTimeP1 ) ) - * stsxyter::kdClockCycleNs / 2.0; - dDtX1Y1X2Y2N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) / 4.0 - ) * stsxyter::kdClockCycleNs; - dDtH1H2S1S2 = ( ( dLastTimeN2 + dLastTimeP2 + dLastTimeN1 + dLastTimeP1 ) - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) - ) * stsxyter::kdClockCycleNs / 4.0; - } // if( kTRUE == fbDualStsEna ) - - fhSetupSortedDtX2Y2->Fill( dDtX2Y2 ); - fhSetupSortedDtX1Y1X2Y2->Fill( dDtX1Y1X2Y2 ); - fhSetupSortedDtX1Y1X2Y2N1P1->Fill( dDtX1Y1X2Y2N1P1 ); - if( kTRUE == fbDualStsEna ) - { - fhSetupSortedDtX1Y1X2Y2N2P2->Fill( dDtX1Y1X2Y2N2P2 ); - fhSetupSortedDtH1H2S1S2->Fill( dDtH1H2S1S2 ); - } // if( kTRUE == fbDualStsEna ) - - if( TMath::Abs( dDtX2Y2 ) < fdCoincBorderHodo ) - { - fhSetupSortedMapX2Y2->Fill( uFiberIdxX2, uFiberIdxY2 ); - fhSetupSortedCntEvoX2Y2->Fill( dTimeSinceStartSec ); - } // if( TMath::Abs( dDtX2Y2 ) < fdCoincBorderHodo ) - - if( TMath::Abs( dDtX1Y1 ) < fdCoincBorderHodo && - TMath::Abs( dDtX2Y2 ) < fdCoincBorderHodo && - TMath::Abs( dDtX1Y1X2Y2 ) < 2 * fdCoincBorderHodo ) - { - fhBothHodoSortedDtX1Y1->Fill( dDtX1Y1 ); - fhBothHodoSortedDtX2Y2->Fill( dDtX2Y2 ); - fhBothHodoSortedDtX1Y1X2Y2N1P1->Fill( dDtX1Y1X2Y2N1P1 ); - fhBothHodoSortedDtX1Y1X2Y2N2P2->Fill( dDtX1Y1X2Y2N2P2 ); - - fhBothHodoSortedMapX1Y1->Fill( uFiberIdxX1, uFiberIdxY1 ); - fhBothHodoSortedMapX2Y2->Fill( uFiberIdxX2, uFiberIdxY2 ); - fhBothHodoSortedCntEvoX2Y2->Fill( dTimeSinceStartSec ); - } // if( TMath::Abs( dDtX1Y1X2Y2 ) < 2 * fdCoincBorderHodo ) - - if( TMath::Abs( dDtX1Y1 ) < fdCoincBorderHodo && - TMath::Abs( dDtX2Y2 ) < fdCoincBorderHodo && - TMath::Abs( dDtN1P1 ) < fdCoincBorderSts && - TMath::Abs( dDtN2P2 ) < fdCoincBorderSts && - TMath::Abs( dDtX1Y1X2Y2 ) < 2 * fdCoincBorderHodo && - TMath::Abs( dDtN1P1N2P2 ) < 2 * fdCoincBorderSts && - TMath::Abs( dDtX1Y1X2Y2N1P1 ) < fdCoincBorder && - TMath::Abs( dDtX1Y1X2Y2N2P2 ) < fdCoincBorder && - TMath::Abs( dDtH1H2S1S2 ) < fdCoincBorder ) - { - fhSystSortedDtX1Y1->Fill( dDtX1Y1 ); - fhSystSortedDtX2Y2->Fill( dDtX2Y2 ); - fhSystSortedDtN1P1->Fill( dDtN1P1 ); - fhSystSortedDtN2P2->Fill( dDtN2P2 ); - fhSystSortedDtX1Y1X2Y2->Fill( dDtX1Y1X2Y2 ); - - fhSystSortedMapX1Y1->Fill( uFiberIdxX1, uFiberIdxY1 ); - fhSystSortedMapX2Y2->Fill( uFiberIdxX2, uFiberIdxY2 ); - fhSystSortedMapN1P1->Fill( fLastSortedHit1N.GetChan(), fLastSortedHit1P.GetChan() ); - fhSystSortedMapN2P2->Fill( fLastSortedHit2N.GetChan(), fLastSortedHit2P.GetChan() ); - fhSystSortedCntEvoX2Y2->Fill( dTimeSinceStartSec ); - fhSystSortedDtAllVsMapX1->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxX1 ); - fhSystSortedDtAllVsMapY1->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxY1 ); - fhSystSortedDtAllVsMapX2->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxX2 ); - fhSystSortedDtAllVsMapY2->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxY2 ); - - Double_t dDtN1X1 = ( dLastTimeN1 - dLastTimeX1 ) * stsxyter::kdClockCycleNs; - Double_t dDtN1X2 = ( dLastTimeN1 - dLastTimeX2 ) * stsxyter::kdClockCycleNs; - Double_t dDtP1X1 = ( dLastTimeP1 - dLastTimeX1 ) * stsxyter::kdClockCycleNs; - Double_t dDtP1X2 = ( dLastTimeP1 - dLastTimeX2 ) * stsxyter::kdClockCycleNs; - fhSystSortedDtN1X1vsN1X2->Fill( dDtN1X1, dDtN1X2 ); - fhSystSortedDtP1X1vsP1X2->Fill( dDtP1X1, dDtP1X2 ); - fhSystSortedDtN1X1vsP1X1->Fill( dDtN1X1, dDtP1X1 ); - - Double_t dDtX1Y1N1P1 = ( ( dLastTimeN1 + dLastTimeP1 ) / 2.0 - - ( dLastTimeX1 + dLastTimeY1 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - Double_t dDtX2Y2N1P1 = ( ( dLastTimeN1 + dLastTimeP1 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - fhSystSortedDtSts1Hodo1vsSts1Hodo2->Fill( dDtX1Y1N1P1, dDtX2Y2N1P1 ); - - Double_t dDtX1Y1N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) / 2.0 - - ( dLastTimeX1 + dLastTimeY1 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - Double_t dDtX2Y2N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - fhSystSortedDtSts2Hodo1vsSts2Hodo2->Fill( dDtX1Y1N2P2, dDtX2Y2N2P2 ); - } // if( TMath::Abs( dDtX1Y1X2Y2N1P1 ) < fdCoincBorder ) - } // else of if( bHitInX ) - } // else if( fUnpackParHodo->GetAsicIndexHodo2() == usAsicIdx ) - else if( fUnpackParSts->GetAsicIndexSts1N() == usAsicIdx ) - { - Double_t dDtSameFeb = ( ulHitTs - dLastTimeN1 ) * stsxyter::kdClockCycleNs; - fhSetupSortedDtN1->Fill( dDtSameFeb ); - - fLastSortedHit1N = (*it); - dLastTimeN1 = ulHitTs; - - /// Compute fiber Idx of the last Hodo hits - UInt_t uFiberIdxX1 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit1X.GetChan() ); - if( fUnpackParHodo->IsXInvertedHodo1() ) - uFiberIdxX1 = fuNbChanPerAsic/2 - 1 - uFiberIdxX1; - UInt_t uFiberIdxY1 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit1Y.GetChan() ); - if( fUnpackParHodo->IsYInvertedHodo1() ) - uFiberIdxY1 = fuNbChanPerAsic/2 - 1 - uFiberIdxY1; - UInt_t uFiberIdxX2 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit2X.GetChan() ); - if( fUnpackParHodo->IsXInvertedHodo2() ) - uFiberIdxX2 = fuNbChanPerAsic/2 - 1 - uFiberIdxX2; - UInt_t uFiberIdxY2 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit2Y.GetChan() ); - if( fUnpackParHodo->IsYInvertedHodo2() ) - uFiberIdxY2 = fuNbChanPerAsic/2 - 1 - uFiberIdxY2; - - dDtX1Y1 = ( dLastTimeY1 - dLastTimeX1 ) * stsxyter::kdClockCycleNs; - dDtX2Y2 = ( dLastTimeY2 - dLastTimeX2 ) * stsxyter::kdClockCycleNs; - dDtN1P1 = ( dLastTimeP1 - dLastTimeN1 ) * stsxyter::kdClockCycleNs; - dDtX1Y1X2Y2 = ( ( dLastTimeX2 + dLastTimeY2 ) - ( dLastTimeX1 + dLastTimeY1 ) ) - * stsxyter::kdClockCycleNs / 2.0; - dDtX1Y1X2Y2N1P1 = ( ( dLastTimeN1 + dLastTimeP1 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) / 4.0 - ) * stsxyter::kdClockCycleNs; - if( kTRUE == fbDualStsEna ) - { - dDtN2P2 = ( dLastTimeP2 - dLastTimeN2 ) * stsxyter::kdClockCycleNs; - dDtN1P1N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) - ( dLastTimeN1 + dLastTimeP1 ) ) - * stsxyter::kdClockCycleNs / 2.0; - dDtX1Y1X2Y2N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) / 4.0 - ) * stsxyter::kdClockCycleNs; - dDtH1H2S1S2 = ( ( dLastTimeN2 + dLastTimeP2 + dLastTimeN1 + dLastTimeP1 ) - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) - ) * stsxyter::kdClockCycleNs / 4.0; - } // if( kTRUE == fbDualStsEna ) - - fhSetupSortedDtN1P1->Fill( dDtN1P1 ); - fhSetupSortedDtX1Y1X2Y2N1P1->Fill( dDtX1Y1X2Y2N1P1 ); - if( kTRUE == fbDualStsEna ) - { - fhSetupSortedDtN1P1N2P2->Fill( dDtN1P1N2P2 ); - fhSetupSortedDtH1H2S1S2->Fill( dDtH1H2S1S2 ); - } // if( kTRUE == fbDualStsEna ) - - if( TMath::Abs( dDtN1P1 ) < fdCoincBorderSts ) - { - fhSetupSortedMapN1P1->Fill( fLastSortedHit1N.GetChan(), fLastSortedHit1P.GetChan() ); - fhSetupSortedCntEvoN1P1->Fill( dTimeSinceStartSec ); - - Double_t dX1, dY1; - ComputeCoordinatesSensor1( fLastSortedHit1N.GetChan(), fLastSortedHit1P.GetChan(), dX1, dY1 ); - fhStsSortedMapS1->Fill( dX1, dY1 ); - - if( TMath::Abs( dDtN1P1N2P2 ) < 2*fdCoincBorder && kTRUE == fbDualStsEna ) - { - Double_t dX2, dY2; - ComputeCoordinatesSensor2( fLastSortedHit2N.GetChan(), fLastSortedHit2P.GetChan(), dX2, dY2 ); - fhStsSortedMapS1Coinc->Fill( dX1, dY1 ); - fhStsSortedMapS2Coinc->Fill( dX2, dY2 ); - } // if( TMath::Abs( dDtN1P2 ) < fdCoincBorder && kTRUE == fbDualStsEna ) - } // if( TMath::Abs( dDtN1P1 ) < fdCoincBorderSts ) - - if( TMath::Abs( dDtX1Y1 ) < fdCoincBorderHodo && - TMath::Abs( dDtX2Y2 ) < fdCoincBorderHodo && - TMath::Abs( dDtN1P1 ) < fdCoincBorderSts && - TMath::Abs( dDtN2P2 ) < fdCoincBorderSts && - TMath::Abs( dDtX1Y1X2Y2 ) < 2 * fdCoincBorderHodo && - TMath::Abs( dDtN1P1N2P2 ) < 2 * fdCoincBorderSts && - TMath::Abs( dDtX1Y1X2Y2N1P1 ) < fdCoincBorder && - TMath::Abs( dDtX1Y1X2Y2N2P2 ) < fdCoincBorder && - TMath::Abs( dDtH1H2S1S2 ) < fdCoincBorder ) - { - fhSystSortedDtX1Y1->Fill( dDtX1Y1 ); - fhSystSortedDtX2Y2->Fill( dDtX2Y2 ); - fhSystSortedDtN1P1->Fill( dDtN1P1 ); - fhSystSortedDtN2P2->Fill( dDtN2P2 ); - fhSystSortedDtX1Y1X2Y2->Fill( dDtX1Y1X2Y2 ); - - fhSystSortedMapX1Y1->Fill( uFiberIdxX1, uFiberIdxY1 ); - fhSystSortedMapX2Y2->Fill( uFiberIdxX2, uFiberIdxY2 ); - fhSystSortedMapN1P1->Fill( fLastSortedHit1N.GetChan(), fLastSortedHit1P.GetChan() ); - fhSystSortedMapN2P2->Fill( fLastSortedHit2N.GetChan(), fLastSortedHit2P.GetChan() ); - fhSystSortedCntEvoN1P1->Fill( dTimeSinceStartSec ); - fhSystSortedDtAllVsMapX1->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxX1 ); - fhSystSortedDtAllVsMapY1->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxY1 ); - fhSystSortedDtAllVsMapX2->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxX2 ); - fhSystSortedDtAllVsMapY2->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxY2 ); - - Double_t dDtN1X1 = ( dLastTimeN1 - dLastTimeX1 ) * stsxyter::kdClockCycleNs; - Double_t dDtN1X2 = ( dLastTimeN1 - dLastTimeX2 ) * stsxyter::kdClockCycleNs; - Double_t dDtP1X1 = ( dLastTimeP1 - dLastTimeX1 ) * stsxyter::kdClockCycleNs; - Double_t dDtP1X2 = ( dLastTimeP1 - dLastTimeX2 ) * stsxyter::kdClockCycleNs; - fhSystSortedDtN1X1vsN1X2->Fill( dDtN1X1, dDtN1X2 ); - fhSystSortedDtP1X1vsP1X2->Fill( dDtP1X1, dDtP1X2 ); - fhSystSortedDtN1X1vsP1X1->Fill( dDtN1X1, dDtP1X1 ); - - Double_t dDtX1Y1N1P1 = ( ( dLastTimeN1 + dLastTimeP1 ) / 2.0 - - ( dLastTimeX1 + dLastTimeY1 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - Double_t dDtX2Y2N1P1 = ( ( dLastTimeN1 + dLastTimeP1 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - fhSystSortedDtSts1Hodo1vsSts1Hodo2->Fill( dDtX1Y1N1P1, dDtX2Y2N1P1 ); - - Double_t dDtX1Y1N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) / 2.0 - - ( dLastTimeX1 + dLastTimeY1 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - Double_t dDtX2Y2N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - fhSystSortedDtSts2Hodo1vsSts2Hodo2->Fill( dDtX1Y1N2P2, dDtX2Y2N2P2 ); - } // if( TMath::Abs( dDtX1Y1X2Y2N1P1 ) < fdCoincBorder ) - } // if( fUnpackParSts->GetAsicIndexSts1N() == usAsicIdx ) - else if( fUnpackParSts->GetAsicIndexSts1P() == usAsicIdx ) - { - Double_t dDtSameFeb = ( ulHitTs - dLastTimeP1 ) * stsxyter::kdClockCycleNs; - fhSetupSortedDtP1->Fill( dDtSameFeb ); - - fLastSortedHit1P = (*it); - dLastTimeP1 = ulHitTs; - - /// Compute fiber Idx of the last Hodo hits - UInt_t uFiberIdxX1 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit1X.GetChan() ); - if( fUnpackParHodo->IsXInvertedHodo1() ) - uFiberIdxX1 = fuNbChanPerAsic/2 - 1 - uFiberIdxX1; - UInt_t uFiberIdxY1 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit1Y.GetChan() ); - if( fUnpackParHodo->IsYInvertedHodo1() ) - uFiberIdxY1 = fuNbChanPerAsic/2 - 1 - uFiberIdxY1; - UInt_t uFiberIdxX2 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit2X.GetChan() ); - if( fUnpackParHodo->IsXInvertedHodo2() ) - uFiberIdxX2 = fuNbChanPerAsic/2 - 1 - uFiberIdxX2; - UInt_t uFiberIdxY2 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit2Y.GetChan() ); - if( fUnpackParHodo->IsYInvertedHodo2() ) - uFiberIdxY2 = fuNbChanPerAsic/2 - 1 - uFiberIdxY2; - - dDtX1Y1 = ( dLastTimeY1 - dLastTimeX1 ) * stsxyter::kdClockCycleNs; - dDtX2Y2 = ( dLastTimeY2 - dLastTimeX2 ) * stsxyter::kdClockCycleNs; - dDtN1P1 = ( dLastTimeP1 - dLastTimeN1 ) * stsxyter::kdClockCycleNs; - dDtX1Y1X2Y2 = ( ( dLastTimeX2 + dLastTimeY2 ) - ( dLastTimeX1 + dLastTimeY1 ) ) - * stsxyter::kdClockCycleNs / 2.0; - dDtX1Y1X2Y2N1P1 = ( ( dLastTimeN1 + dLastTimeP1 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) / 4.0 - ) * stsxyter::kdClockCycleNs; - if( kTRUE == fbDualStsEna ) - { - dDtN2P2 = ( dLastTimeP2 - dLastTimeN2 ) * stsxyter::kdClockCycleNs; - dDtN1P1N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) - ( dLastTimeN1 + dLastTimeP1 ) ) - * stsxyter::kdClockCycleNs / 2.0; - dDtX1Y1X2Y2N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) / 4.0 - ) * stsxyter::kdClockCycleNs; - dDtH1H2S1S2 = ( ( dLastTimeN2 + dLastTimeP2 + dLastTimeN1 + dLastTimeP1 ) - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) - ) * stsxyter::kdClockCycleNs / 4.0; - } // if( kTRUE == fbDualStsEna ) - - fhSetupSortedDtN1P1->Fill( dDtN1P1 ); - fhSetupSortedDtX1Y1X2Y2N1P1->Fill( dDtX1Y1X2Y2N1P1 ); - if( kTRUE == fbDualStsEna ) - { - fhSetupSortedDtN1P1N2P2->Fill( dDtN1P1N2P2 ); - fhSetupSortedDtH1H2S1S2->Fill( dDtH1H2S1S2 ); - } // if( kTRUE == fbDualStsEna ) - - if( TMath::Abs( dDtN1P1 ) < fdCoincBorderSts ) - { - fhSetupSortedMapN1P1->Fill( fLastSortedHit1N.GetChan(), fLastSortedHit1P.GetChan() ); - fhSetupSortedCntEvoN1P1->Fill( dTimeSinceStartSec ); - - Double_t dX1, dY1; - ComputeCoordinatesSensor1( fLastSortedHit1N.GetChan(), fLastSortedHit1P.GetChan(), dX1, dY1 ); - fhStsSortedMapS1->Fill( dX1, dY1 ); - - if( TMath::Abs( dDtN1P1N2P2 ) < 2*fdCoincBorder && kTRUE == fbDualStsEna ) - { - Double_t dX2, dY2; - ComputeCoordinatesSensor2( fLastSortedHit2N.GetChan(), fLastSortedHit2P.GetChan(), dX2, dY2 ); - fhStsSortedMapS1Coinc->Fill( dX1, dY1 ); - fhStsSortedMapS2Coinc->Fill( dX2, dY2 ); - } // if( TMath::Abs( dDtN1P2 ) < fdCoincBorder && kTRUE == fbDualStsEna ) - } // if( TMath::Abs( dDtN1P1 ) < fdCoincBorderSts ) - - if( TMath::Abs( dDtX1Y1 ) < fdCoincBorderHodo && - TMath::Abs( dDtX2Y2 ) < fdCoincBorderHodo && - TMath::Abs( dDtN1P1 ) < fdCoincBorderSts && - TMath::Abs( dDtN2P2 ) < fdCoincBorderSts && - TMath::Abs( dDtX1Y1X2Y2 ) < 2 * fdCoincBorderHodo && - TMath::Abs( dDtN1P1N2P2 ) < 2 * fdCoincBorderSts && - TMath::Abs( dDtX1Y1X2Y2N1P1 ) < fdCoincBorder && - TMath::Abs( dDtX1Y1X2Y2N2P2 ) < fdCoincBorder && - TMath::Abs( dDtH1H2S1S2 ) < fdCoincBorder ) - { - fhSystSortedDtX1Y1->Fill( dDtX1Y1 ); - fhSystSortedDtX2Y2->Fill( dDtX2Y2 ); - fhSystSortedDtN1P1->Fill( dDtN1P1 ); - fhSystSortedDtN2P2->Fill( dDtN2P2 ); - fhSystSortedDtX1Y1X2Y2->Fill( dDtX1Y1X2Y2 ); - - fhSystSortedMapX1Y1->Fill( uFiberIdxX1, uFiberIdxY1 ); - fhSystSortedMapX2Y2->Fill( uFiberIdxX2, uFiberIdxY2 ); - fhSystSortedMapN1P1->Fill( fLastSortedHit1N.GetChan(), fLastSortedHit1P.GetChan() ); - fhSystSortedMapN2P2->Fill( fLastSortedHit2N.GetChan(), fLastSortedHit2P.GetChan() ); - fhSystSortedCntEvoN1P1->Fill( dTimeSinceStartSec ); - fhSystSortedDtAllVsMapX1->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxX1 ); - fhSystSortedDtAllVsMapY1->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxY1 ); - fhSystSortedDtAllVsMapX2->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxX2 ); - fhSystSortedDtAllVsMapY2->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxY2 ); - - Double_t dDtN1X1 = ( dLastTimeN1 - dLastTimeX1 ) * stsxyter::kdClockCycleNs; - Double_t dDtN1X2 = ( dLastTimeN1 - dLastTimeX2 ) * stsxyter::kdClockCycleNs; - Double_t dDtP1X1 = ( dLastTimeP1 - dLastTimeX1 ) * stsxyter::kdClockCycleNs; - Double_t dDtP1X2 = ( dLastTimeP1 - dLastTimeX2 ) * stsxyter::kdClockCycleNs; - fhSystSortedDtN1X1vsN1X2->Fill( dDtN1X1, dDtN1X2 ); - fhSystSortedDtP1X1vsP1X2->Fill( dDtP1X1, dDtP1X2 ); - fhSystSortedDtN1X1vsP1X1->Fill( dDtN1X1, dDtP1X1 ); - - Double_t dDtX1Y1N1P1 = ( ( dLastTimeN1 + dLastTimeP1 ) / 2.0 - - ( dLastTimeX1 + dLastTimeY1 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - Double_t dDtX2Y2N1P1 = ( ( dLastTimeN1 + dLastTimeP1 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - fhSystSortedDtSts1Hodo1vsSts1Hodo2->Fill( dDtX1Y1N1P1, dDtX2Y2N1P1 ); - - Double_t dDtX1Y1N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) / 2.0 - - ( dLastTimeX1 + dLastTimeY1 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - Double_t dDtX2Y2N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - fhSystSortedDtSts2Hodo1vsSts2Hodo2->Fill( dDtX1Y1N2P2, dDtX2Y2N2P2 ); - } // if( TMath::Abs( dDtX1Y1X2Y2N1P1 ) < fdCoincBorder ) - } // else if( fUnpackParSts->GetAsicIndexSts1P() == usAsicIdx ) - else if( kTRUE == fbDualStsEna ) - { - if( fUnpackParSts->GetAsicIndexSts2N() == usAsicIdx ) - { - Double_t dDtSameFeb = ( ulHitTs - dLastTimeN2 ) * stsxyter::kdClockCycleNs; - fhSetupSortedDtN2->Fill( dDtSameFeb ); - - fLastSortedHit2N = (*it); - dLastTimeN2 = ulHitTs; - - /// Compute fiber Idx of the last Hodo hits - UInt_t uFiberIdxX1 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit1X.GetChan() ); - if( fUnpackParHodo->IsXInvertedHodo1() ) - uFiberIdxX1 = fuNbChanPerAsic/2 - 1 - uFiberIdxX1; - UInt_t uFiberIdxY1 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit1Y.GetChan() ); - if( fUnpackParHodo->IsYInvertedHodo1() ) - uFiberIdxY1 = fuNbChanPerAsic/2 - 1 - uFiberIdxY1; - UInt_t uFiberIdxX2 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit2X.GetChan() ); - if( fUnpackParHodo->IsXInvertedHodo2() ) - uFiberIdxX2 = fuNbChanPerAsic/2 - 1 - uFiberIdxX2; - UInt_t uFiberIdxY2 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit2Y.GetChan() ); - if( fUnpackParHodo->IsYInvertedHodo2() ) - uFiberIdxY2 = fuNbChanPerAsic/2 - 1 - uFiberIdxY2; - - dDtX1Y1 = ( dLastTimeY1 - dLastTimeX1 ) * stsxyter::kdClockCycleNs; - dDtX2Y2 = ( dLastTimeY2 - dLastTimeX2 ) * stsxyter::kdClockCycleNs; - dDtN1P1 = ( dLastTimeP1 - dLastTimeN1 ) * stsxyter::kdClockCycleNs; - dDtN2P2 = ( dLastTimeP2 - dLastTimeN2 ) * stsxyter::kdClockCycleNs; - dDtX1Y1X2Y2 = ( ( dLastTimeX2 + dLastTimeY2 ) - ( dLastTimeX1 + dLastTimeY1 ) ) - * stsxyter::kdClockCycleNs / 2.0; - dDtN1P1N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) - ( dLastTimeN1 + dLastTimeP1 ) ) - * stsxyter::kdClockCycleNs / 2.0; - dDtX1Y1X2Y2N1P1 = ( ( dLastTimeN1 + dLastTimeP1 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) / 4.0 - ) * stsxyter::kdClockCycleNs; - dDtX1Y1X2Y2N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) / 4.0 - ) * stsxyter::kdClockCycleNs; - dDtH1H2S1S2 = ( ( dLastTimeN2 + dLastTimeP2 + dLastTimeN1 + dLastTimeP1 ) - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) - ) * stsxyter::kdClockCycleNs / 4.0; - - fhSetupSortedDtN2P2->Fill( dDtN2P2 ); - fhSetupSortedDtN1P1N2P2->Fill( dDtN1P1N2P2 ); - fhSetupSortedDtX1Y1X2Y2N2P2->Fill( dDtX1Y1X2Y2N2P2 ); - fhSetupSortedDtH1H2S1S2->Fill( dDtH1H2S1S2 ); - - if( TMath::Abs( dDtN2P2 ) < fdCoincBorderSts ) - { - fhSetupSortedMapN2P2->Fill( fLastSortedHit2N.GetChan(), fLastSortedHit2P.GetChan() ); - fhSetupSortedCntEvoN2P2->Fill( dTimeSinceStartSec ); - - Double_t dX2, dY2; - ComputeCoordinatesSensor2( fLastSortedHit2N.GetChan(), fLastSortedHit2P.GetChan(), dX2, dY2 ); - fhStsSortedMapS2->Fill( dX2, dY2 ); - - if( TMath::Abs( dDtN1P1N2P2 ) < 2*fdCoincBorder ) - { - Double_t dX1, dY1; - ComputeCoordinatesSensor1( fLastSortedHit1N.GetChan(), fLastSortedHit1P.GetChan(), dX1, dY1 ); - fhStsSortedMapS1Coinc->Fill( dX1, dY1 ); - fhStsSortedMapS2Coinc->Fill( dX2, dY2 ); - } // if( TMath::Abs( dDtN1P2 ) < fdCoincBorder ) - } // if( TMath::Abs( dDtN2P2 ) < fdCoincBorderSts ) - - if( TMath::Abs( dDtX1Y1 ) < fdCoincBorderHodo && - TMath::Abs( dDtX2Y2 ) < fdCoincBorderHodo && - TMath::Abs( dDtN1P1 ) < fdCoincBorderSts && - TMath::Abs( dDtN2P2 ) < fdCoincBorderSts && - TMath::Abs( dDtX1Y1X2Y2 ) < 2 * fdCoincBorderHodo && - TMath::Abs( dDtN1P1N2P2 ) < 2 * fdCoincBorderSts && - TMath::Abs( dDtX1Y1X2Y2N1P1 ) < fdCoincBorder && - TMath::Abs( dDtX1Y1X2Y2N2P2 ) < fdCoincBorder && - TMath::Abs( dDtH1H2S1S2 ) < fdCoincBorder ) - { - fhSystSortedDtX1Y1->Fill( dDtX1Y1 ); - fhSystSortedDtX2Y2->Fill( dDtX2Y2 ); - fhSystSortedDtN1P1->Fill( dDtN1P1 ); - fhSystSortedDtN2P2->Fill( dDtN2P2 ); - fhSystSortedDtX1Y1X2Y2->Fill( dDtX1Y1X2Y2 ); - - fhSystSortedMapX1Y1->Fill( uFiberIdxX1, uFiberIdxY1 ); - fhSystSortedMapX2Y2->Fill( uFiberIdxX2, uFiberIdxY2 ); - fhSystSortedMapN1P1->Fill( fLastSortedHit1N.GetChan(), fLastSortedHit1P.GetChan() ); - fhSystSortedMapN2P2->Fill( fLastSortedHit2N.GetChan(), fLastSortedHit2P.GetChan() ); - fhSystSortedCntEvoN1P1->Fill( dTimeSinceStartSec ); - fhSystSortedDtAllVsMapX1->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxX1 ); - fhSystSortedDtAllVsMapY1->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxY1 ); - fhSystSortedDtAllVsMapX2->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxX2 ); - fhSystSortedDtAllVsMapY2->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxY2 ); - - Double_t dDtN1X1 = ( dLastTimeN1 - dLastTimeX1 ) * stsxyter::kdClockCycleNs; - Double_t dDtN1X2 = ( dLastTimeN1 - dLastTimeX2 ) * stsxyter::kdClockCycleNs; - Double_t dDtP1X1 = ( dLastTimeP1 - dLastTimeX1 ) * stsxyter::kdClockCycleNs; - Double_t dDtP1X2 = ( dLastTimeP1 - dLastTimeX2 ) * stsxyter::kdClockCycleNs; - fhSystSortedDtN1X1vsN1X2->Fill( dDtN1X1, dDtN1X2 ); - fhSystSortedDtP1X1vsP1X2->Fill( dDtP1X1, dDtP1X2 ); - fhSystSortedDtN1X1vsP1X1->Fill( dDtN1X1, dDtP1X1 ); - - Double_t dDtX1Y1N1P1 = ( ( dLastTimeN1 + dLastTimeP1 ) / 2.0 - - ( dLastTimeX1 + dLastTimeY1 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - Double_t dDtX2Y2N1P1 = ( ( dLastTimeN1 + dLastTimeP1 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - fhSystSortedDtSts1Hodo1vsSts1Hodo2->Fill( dDtX1Y1N1P1, dDtX2Y2N1P1 ); - - Double_t dDtX1Y1N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) / 2.0 - - ( dLastTimeX1 + dLastTimeY1 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - Double_t dDtX2Y2N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - fhSystSortedDtSts2Hodo1vsSts2Hodo2->Fill( dDtX1Y1N2P2, dDtX2Y2N2P2 ); - } // if( TMath::Abs( dDtX1Y1X2Y2N1P1 ) < fdCoincBorder ) - } // if( fUnpackParSts->GetAsicIndexSts2N() == usAsicIdx ) - else if( fUnpackParSts->GetAsicIndexSts2P() == usAsicIdx ) - { - Double_t dDtSameFeb = ( ulHitTs - dLastTimeP2 ) * stsxyter::kdClockCycleNs; - fhSetupSortedDtP2->Fill( dDtSameFeb ); - - fLastSortedHit2P = (*it); - dLastTimeP2 = ulHitTs; - - /// Compute fiber Idx of the last Hodo hits - UInt_t uFiberIdxX1 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit1X.GetChan() ); - if( fUnpackParHodo->IsXInvertedHodo1() ) - uFiberIdxX1 = fuNbChanPerAsic/2 - 1 - uFiberIdxX1; - UInt_t uFiberIdxY1 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit1Y.GetChan() ); - if( fUnpackParHodo->IsYInvertedHodo1() ) - uFiberIdxY1 = fuNbChanPerAsic/2 - 1 - uFiberIdxY1; - UInt_t uFiberIdxX2 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit2X.GetChan() ); - if( fUnpackParHodo->IsXInvertedHodo2() ) - uFiberIdxX2 = fuNbChanPerAsic/2 - 1 - uFiberIdxX2; - UInt_t uFiberIdxY2 = fUnpackParHodo->GetChannelToFiberMap( fLastSortedHit2Y.GetChan() ); - if( fUnpackParHodo->IsYInvertedHodo2() ) - uFiberIdxY2 = fuNbChanPerAsic/2 - 1 - uFiberIdxY2; - - dDtX1Y1 = ( dLastTimeY1 - dLastTimeX1 ) * stsxyter::kdClockCycleNs; - dDtX2Y2 = ( dLastTimeY2 - dLastTimeX2 ) * stsxyter::kdClockCycleNs; - dDtN1P1 = ( dLastTimeP1 - dLastTimeN1 ) * stsxyter::kdClockCycleNs; - dDtN2P2 = ( dLastTimeP2 - dLastTimeN2 ) * stsxyter::kdClockCycleNs; - dDtX1Y1X2Y2 = ( ( dLastTimeX2 + dLastTimeY2 ) - ( dLastTimeX1 + dLastTimeY1 ) ) - * stsxyter::kdClockCycleNs / 2.0; - dDtN1P1N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) - ( dLastTimeN1 + dLastTimeP1 ) ) - * stsxyter::kdClockCycleNs / 2.0; - dDtX1Y1X2Y2N1P1 = ( ( dLastTimeN1 + dLastTimeP1 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) / 4.0 - ) * stsxyter::kdClockCycleNs; - dDtX1Y1X2Y2N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) / 4.0 - ) * stsxyter::kdClockCycleNs; - dDtH1H2S1S2 = ( ( dLastTimeN2 + dLastTimeP2 + dLastTimeN1 + dLastTimeP1 ) - - ( dLastTimeX2 + dLastTimeY2 + dLastTimeX1 + dLastTimeY1 ) - ) * stsxyter::kdClockCycleNs / 4.0; - - - fhSetupSortedDtN2P2->Fill( dDtN2P2 ); - fhSetupSortedDtN1P1N2P2->Fill( dDtN1P1N2P2 ); - fhSetupSortedDtX1Y1X2Y2N2P2->Fill( dDtX1Y1X2Y2N2P2 ); - fhSetupSortedDtH1H2S1S2->Fill( dDtH1H2S1S2 ); - - if( TMath::Abs( dDtN2P2 ) < fdCoincBorderSts ) - { - fhSetupSortedMapN2P2->Fill( fLastSortedHit2N.GetChan(), fLastSortedHit2P.GetChan() ); - fhSetupSortedCntEvoN2P2->Fill( dTimeSinceStartSec ); - - Double_t dX2, dY2; - ComputeCoordinatesSensor2( fLastSortedHit2N.GetChan(), fLastSortedHit2P.GetChan(), dX2, dY2 ); - fhStsSortedMapS2->Fill( dX2, dY2 ); - - if( TMath::Abs( dDtN1P1N2P2 ) < 2*fdCoincBorder ) - { - Double_t dX1, dY1; - ComputeCoordinatesSensor1( fLastSortedHit1N.GetChan(), fLastSortedHit1P.GetChan(), dX1, dY1 ); - fhStsSortedMapS1Coinc->Fill( dX1, dY1 ); - fhStsSortedMapS2Coinc->Fill( dX2, dY2 ); - } // if( TMath::Abs( dDtN1P2 ) < fdCoincBorder ) - } // if( TMath::Abs( dDtN2P2 ) < fdCoincBorderSts ) - - if( TMath::Abs( dDtX1Y1 ) < fdCoincBorderHodo && - TMath::Abs( dDtX2Y2 ) < fdCoincBorderHodo && - TMath::Abs( dDtN1P1 ) < fdCoincBorderSts && - TMath::Abs( dDtN2P2 ) < fdCoincBorderSts && - TMath::Abs( dDtX1Y1X2Y2 ) < 2 * fdCoincBorderHodo && - TMath::Abs( dDtN1P1N2P2 ) < 2 * fdCoincBorderSts && - TMath::Abs( dDtX1Y1X2Y2N1P1 ) < fdCoincBorder && - TMath::Abs( dDtX1Y1X2Y2N2P2 ) < fdCoincBorder && - TMath::Abs( dDtH1H2S1S2 ) < fdCoincBorder ) - { - fhSystSortedDtX1Y1->Fill( dDtX1Y1 ); - fhSystSortedDtX2Y2->Fill( dDtX2Y2 ); - fhSystSortedDtN1P1->Fill( dDtN1P1 ); - fhSystSortedDtN2P2->Fill( dDtN2P2 ); - fhSystSortedDtX1Y1X2Y2->Fill( dDtX1Y1X2Y2 ); - - fhSystSortedMapX1Y1->Fill( uFiberIdxX1, uFiberIdxY1 ); - fhSystSortedMapX2Y2->Fill( uFiberIdxX2, uFiberIdxY2 ); - fhSystSortedMapN1P1->Fill( fLastSortedHit1N.GetChan(), fLastSortedHit1P.GetChan() ); - fhSystSortedMapN2P2->Fill( fLastSortedHit2N.GetChan(), fLastSortedHit2P.GetChan() ); - fhSystSortedCntEvoN1P1->Fill( dTimeSinceStartSec ); - fhSystSortedDtAllVsMapX1->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxX1 ); - fhSystSortedDtAllVsMapY1->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxY1 ); - fhSystSortedDtAllVsMapX2->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxX2 ); - fhSystSortedDtAllVsMapY2->Fill( dDtX1Y1X2Y2N1P1, uFiberIdxY2 ); - - Double_t dDtN1X1 = ( dLastTimeN1 - dLastTimeX1 ) * stsxyter::kdClockCycleNs; - Double_t dDtN1X2 = ( dLastTimeN1 - dLastTimeX2 ) * stsxyter::kdClockCycleNs; - Double_t dDtP1X1 = ( dLastTimeP1 - dLastTimeX1 ) * stsxyter::kdClockCycleNs; - Double_t dDtP1X2 = ( dLastTimeP1 - dLastTimeX2 ) * stsxyter::kdClockCycleNs; - fhSystSortedDtN1X1vsN1X2->Fill( dDtN1X1, dDtN1X2 ); - fhSystSortedDtP1X1vsP1X2->Fill( dDtP1X1, dDtP1X2 ); - fhSystSortedDtN1X1vsP1X1->Fill( dDtN1X1, dDtP1X1 ); - - Double_t dDtX1Y1N1P1 = ( ( dLastTimeN1 + dLastTimeP1 ) / 2.0 - - ( dLastTimeX1 + dLastTimeY1 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - Double_t dDtX2Y2N1P1 = ( ( dLastTimeN1 + dLastTimeP1 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - fhSystSortedDtSts1Hodo1vsSts1Hodo2->Fill( dDtX1Y1N1P1, dDtX2Y2N1P1 ); - - Double_t dDtX1Y1N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) / 2.0 - - ( dLastTimeX1 + dLastTimeY1 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - Double_t dDtX2Y2N2P2 = ( ( dLastTimeN2 + dLastTimeP2 ) / 2.0 - - ( dLastTimeX2 + dLastTimeY2 ) / 2.0 - ) * stsxyter::kdClockCycleNs; - fhSystSortedDtSts2Hodo1vsSts2Hodo2->Fill( dDtX1Y1N2P2, dDtX2Y2N2P2 ); - } // if( TMath::Abs( dDtX1Y1X2Y2N1P1 ) < fdCoincBorder ) - } // else if( fUnpackParSts->GetAsicIndexSts1P() == usAsicIdx ) - } // else if( kTRUE == fbDualStsEna ) - } // loop on hits untils hits within 100 ns of last one or last one itself are reached - - // Remove all hits which were already used - fvmHitsInTs.erase( fvmHitsInTs.begin(), it ); - } // if( 0 < fvmHitsInTs.size() ) - - UInt_t uNbAsicCleanInMs = 0; - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - if( kFALSE == fvbAsicHasDuplicInMs[ uXyterIdx ] ) - uNbAsicCleanInMs++; - Double_t dTimeSinceStartSec = dMsTime - fdStartTimeMsSz; - for( UInt_t uXyterIdx = 0; uXyterIdx <= fuNbStsXyters; ++uXyterIdx ) - { - if( uXyterIdx == uNbAsicCleanInMs ) - { - fhRatioMsDuplicateQuality->Fill( uXyterIdx, 1.0 ); - fhEvoMsDuplicateQuality[ uXyterIdx ]->Fill( dTimeSinceStartSec, 1.0 ); - } // if( uXyterIdx == uNbAsicCleanInMs ) - else - { - fhRatioMsDuplicateQuality->Fill( uXyterIdx, 0.0 ); - fhEvoMsDuplicateQuality[ uXyterIdx ]->Fill( dTimeSinceStartSec, 0.0 ); - } // else of if( uXyterIdx != uNbAsicCleanInMs ) - } // for( UInt_t uXyterIdx = 0; uXyterIdx <= fuNbStsXyters; ++uXyterIdx ) - } // for( size_t m = 0; m < numCompMsInTs; ++m ) - - // End of TS, check if stuff to do with the hits inside each MS - // Usefull for low rate pulser tests - // Need to do it only when last DPB is processed, as they are done one by one - if( fuCurrDpbIdx == fuNrOfDpbs - 1 ) - { - for( UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx ) - { - fvdMsTime[ uMsIdx ] = 0.0; - } // for( UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx ) - } // if( fuCurrDpbIdx == fuNrOfDpbs - 1 ) - - if( 0 == ts.index() % 1000 && fuCurrDpbIdx == fuNrOfDpbs - 1 ) - { - for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - { - Double_t dTsMsbTime = - static_cast<ULong64_t>( stsxyter::kuHitNbTsBins ) - * static_cast<ULong64_t>( fvulCurrentTsMsb[fuCurrDpbIdx]) - + static_cast<ULong64_t>( stsxyter::kulTsCycleNbBins ) - * static_cast<ULong64_t>( fvuCurrentTsMsbCycle[fuCurrDpbIdx] ); - dTsMsbTime *= stsxyter::kdClockCycleNs * 1e-9; - - LOG(info) << "End of TS " << std::setw(7) << ts.index() - << " eDPB " << std::setw(2) << uDpb - << " current TS MSB counter is " << std::setw(12) << fvulCurrentTsMsb[uDpb] - << " current TS MSB cycle counter is " << std::setw(12) << fvuCurrentTsMsbCycle[uDpb] - << " current TS MSB time is " << std::setw(12) << dTsMsbTime << " s"; - } - } // if( 0 == ts.index() % 1000 && fuCurrDpbIdx == fuNrOfDpbs - 1 ) - - return kTRUE; -} - -void CbmCosy2018MonitorSetupGood::FillHitInfo( stsxyter::Message mess, const UShort_t & /*usElinkIdx*/, const UInt_t & uAsicIdx, const UInt_t & uMsIdx ) -{ - UShort_t usChan = mess.GetHitChannel(); - UShort_t usRawAdc = mess.GetHitAdc(); -// UShort_t usFullTs = mess.GetHitTimeFull(); -// UShort_t usTsOver = mess.GetHitTimeOver(); - UShort_t usRawTs = mess.GetHitTime(); - - fhHodoChanCntRaw[ uAsicIdx ]->Fill( usChan ); - fhHodoChanAdcRaw[ uAsicIdx ]->Fill( usChan, usRawAdc ); - fhHodoChanAdcRawProf[ uAsicIdx ]->Fill( usChan, usRawAdc ); - fhHodoChanRawTs[ uAsicIdx ]->Fill( usChan, usRawTs ); - fhHodoChanMissEvt[ uAsicIdx ]->Fill( usChan, mess.IsHitMissedEvts() ); - - // Compute the Full time stamp -// Long64_t ulOldHitTime = fvulChanLastHitTime[ uAsicIdx ][ usChan ]; -// Double_t dOldHitTime = fvdChanLastHitTime[ uAsicIdx ][ usChan ]; - - // Use TS w/o overlap bits as they will anyway come from the TS_MSB - fvulChanLastHitTime[ uAsicIdx ][ usChan ] = usRawTs; - - fvulChanLastHitTime[ uAsicIdx ][ usChan ] += - static_cast<ULong64_t>( stsxyter::kuHitNbTsBins ) - * static_cast<ULong64_t>( fvulCurrentTsMsb[fuCurrDpbIdx]) - + static_cast<ULong64_t>( stsxyter::kulTsCycleNbBins ) - * static_cast<ULong64_t>( fvuCurrentTsMsbCycle[fuCurrDpbIdx] ) - ; - -// fvuElinkLastTsHit[fuCurrDpbIdx] = usRawTs; - - // Convert the Hit time in bins to Hit time in ns - Double_t dHitTimeNs = fvulChanLastHitTime[ uAsicIdx ][ usChan ] * stsxyter::kdClockCycleNs; -/* - // If needed fill the hit interval plots - if( fbChanHitDtEna ) - { - Double_t dDeltaT = dHitTimeNs - fvdChanLastHitTime[ uAsicIdx ][ usChan ]; - if( 0 == dDeltaT ) - fhStsChanHitDtNeg[ uAsicIdx ]->Fill( 1, usChan ); - else if( 0 < dDeltaT ) - fhStsChanHitDt[ uAsicIdx ]->Fill( dDeltaT, usChan ); - else fhStsChanHitDtNeg[ uAsicIdx ]->Fill( -dDeltaT, usChan ); - } // if( fbChanHitDtEna ) -*/ - // Store new value of Hit time in ns - fvdChanLastHitTime[ uAsicIdx ][ usChan ] = fvulChanLastHitTime[ uAsicIdx ][ usChan ] * stsxyter::kdClockCycleNs; -/* - LOG(info) << " Asic " << std::setw( 2 ) << uAsicIdx - << " Channel " << std::setw( 3 ) << usChan - << " Diff to last hit " << std::setw( 12 ) << ( fvulChanLastHitTime[ uAsicIdx ][ usChan ] - ulOldHitTime) - << " in s " << std::setw( 12 ) << ( fvdChanLastHitTime[ uAsicIdx ][ usChan ] - dOldHitTime) * 1e-9; -*/ - // Pulser and MS - fvuChanNbHitsInMs[ uAsicIdx ][ usChan ][ uMsIdx ] ++; - fvdChanLastHitTimeInMs[ uAsicIdx ][ usChan ][ uMsIdx ] = dHitTimeNs; - fvusChanLastHitAdcInMs[ uAsicIdx ][ usChan ][ uMsIdx ] = usRawAdc; -/* - fvmChanHitsInTs[ uAsicIdx ][ usChan ].insert( stsxyter::FinalHit( fvulChanLastHitTime[ uAsicIdx ][ usChan ], - usRawAdc, uAsicIdx, usChan ) ); -*/ - fvmHitsInTs.push_back( stsxyter::FinalHit( fvulChanLastHitTime[ uAsicIdx ][ usChan ], usRawAdc, uAsicIdx, usChan ) ); - -/* - LOG(info) << " TS " << std::setw( 12 ) << fulCurrentTsIdx - << " MS " << std::setw( 12 ) << fulCurrentMsIdx - << " MsInTs " << std::setw( 3 ) << uMsIdx - << " Asic " << std::setw( 2 ) << uAsicIdx - << " Channel " << std::setw( 3 ) << usChan - << " ADC " << std::setw( 3 ) << usRawAdc - << " TS " << std::setw( 3 ) << usRawTs // 9 bits TS - << " SX TsMsb " << std::setw( 2 ) << ( fvulCurrentTsMsb[fuCurrDpbIdx] & 0x1F ) // Total StsXyter TS = 14 bits => 9b Hit TS + lower 5b TS_MSB after DPB - << " DPB TsMsb " << std::setw( 6 ) << ( fvulCurrentTsMsb[fuCurrDpbIdx] >> 5 ) // Total StsXyter TS = 14 bits => 9b Hit TS + lower 5b of TS_MSB after DPB - << " TsMsb " << std::setw( 7 ) << fvulCurrentTsMsb[fuCurrDpbIdx] - << " MsbCy " << std::setw( 4 ) << fvuCurrentTsMsbCycle[fuCurrDpbIdx] - << " Time " << std::setw ( 12 ) << fvulChanLastHitTime[ uAsicIdx ][ usChan ]; -*/ - // Check Starting point of histos with time as X axis - if( -1 == fdStartTime ) - fdStartTime = fvdChanLastHitTime[ uAsicIdx ][ usChan ]; - - // Fill histos with time as X axis - Double_t dTimeSinceStartSec = (fvdChanLastHitTime[ uAsicIdx ][ usChan ] - fdStartTime)* 1e-9; - Double_t dTimeSinceStartMin = dTimeSinceStartSec / 60.0; - fhHodoChanHitRateEvo[ uAsicIdx ]->Fill( dTimeSinceStartSec , usChan ); - fhHodoFebRateEvo[ uAsicIdx ]->Fill( dTimeSinceStartSec ); - fhHodoChanHitRateEvoLong[ uAsicIdx ]->Fill( dTimeSinceStartMin, usChan, 1.0/60.0 ); - fhHodoFebRateEvoLong[ uAsicIdx ]->Fill( dTimeSinceStartMin, 1.0/60.0 ); - if( mess.IsHitMissedEvts() ) - { - fhHodoChanMissEvtEvo[ uAsicIdx ]->Fill( dTimeSinceStartSec , usChan ); - fhHodoFebMissEvtEvo[ uAsicIdx ]->Fill( dTimeSinceStartSec ); - } // if( mess.IsHitMissedEvts() ) -/* - if( kTRUE == fbLongHistoEnable ) - { - std::chrono::steady_clock::time_point tNow = std::chrono::steady_clock::now(); - Double_t dUnixTimeInRun = std::chrono::duration_cast< std::chrono::seconds >(tNow - ftStartTimeUnix).count(); - fhFebRateEvoLong[ uAsicIdx ]->Fill( dUnixTimeInRun , 1.0 / fuLongHistoBinSizeSec ); - fhFebChRateEvoLong[ uAsicIdx ]->Fill( dUnixTimeInRun , usChan, 1.0 / fuLongHistoBinSizeSec ); - } // if( kTRUE == fbLongHistoEnable ) -*/ - -} - -void CbmCosy2018MonitorSetupGood::FillTsMsbInfo( stsxyter::Message mess, UInt_t /*uMessIdx*/, UInt_t /*uMsIdx*/ ) -{ - UInt_t uVal = mess.GetTsMsbVal(); -/* - if( 0 == fuCurrDpbIdx ) - LOG(info) << " TS " << std::setw( 12 ) << fulCurrentTsIdx - << " MS " << std::setw( 12 ) << fulCurrentMsIdx - << " MsInTs " << std::setw( 3 ) << uMsIdx - << " DPB " << std::setw( 2 ) << fuCurrDpbIdx - << " Mess " << std::setw( 5 ) << uMessIdx - << " TsMsb " << std::setw( 5 ) << uVal; -*/ -/* - if( (uVal != fvulCurrentTsMsb[fuCurrDpbIdx] + 1) && 0 < uVal && - !( 1 == uMessIdx && usVal == fvulCurrentTsMsb[fuCurrDpbIdx] ) ) // 1st TS_MSB in MS is always a repeat of the last one in previous MS! - { - LOG(info) << "TS MSB not increasing by 1! TS " << std::setw( 12 ) << fulCurrentTsIdx - << " MS " << std::setw( 12 ) << fulCurrentMsIdx - << " MsInTs " << std::setw( 3 ) << uMsIdx - << " DPB " << std::setw( 2 ) << fuCurrDpbIdx - << " Mess " << std::setw( 5 ) << uMessIdx - << " Old TsMsb " << std::setw( 5 ) << fvulCurrentTsMsb[fuCurrDpbIdx] - << " new TsMsb " << std::setw( 5 ) << uVal - << " Diff " << std::setw( 5 ) << uVal - fvulCurrentTsMsb[fuCurrDpbIdx] - << " Old MsbCy " << std::setw( 5 ) << fvuCurrentTsMsbCycle[fuCurrDpbIdx]; - } // if( (uVal != fvulCurrentTsMsb[fuCurrDpbIdx] + 1) && 0 < uVal ) -*/ - - // Update Status counters - if( uVal < fvulCurrentTsMsb[fuCurrDpbIdx] ) - { - - LOG(info) << " TS " << std::setw( 12 ) << fulCurrentTsIdx - << " MS " << std::setw( 12 ) << fulCurrentMsIdx - << " DPB " << std::setw( 2 ) << fuCurrDpbIdx - << " Old TsMsb " << std::setw( 5 ) << fvulCurrentTsMsb[fuCurrDpbIdx] - << " Old MsbCy " << std::setw( 5 ) << fvuCurrentTsMsbCycle[fuCurrDpbIdx] - << " new TsMsb " << std::setw ( 5 ) << uVal; - - fvuCurrentTsMsbCycle[fuCurrDpbIdx] ++; - } // if( uVal < fvulCurrentTsMsb[fuCurrDpbIdx] ) - fvulCurrentTsMsb[fuCurrDpbIdx] = uVal; -/* - if( 1 < uMessIdx ) - { - fhStsDpbRawTsMsb->Fill( fuCurrDpbIdx, fvulCurrentTsMsb[fuCurrDpbIdx] ); - fhStsDpbRawTsMsbSx->Fill( fuCurrDpbIdx, ( fvulCurrentTsMsb[fuCurrDpbIdx] & 0x1F ) ); - fhStsDpbRawTsMsbDpb->Fill( fuCurrDpbIdx, ( fvulCurrentTsMsb[fuCurrDpbIdx] >> 5 ) ); - } // if( 0 < uMessIdx ) -*/ -// fhStsAsicTsMsb->Fill( fvulCurrentTsMsb[fuCurrDpbIdx], uAsicIdx ); - - ULong64_t ulNewTsMsbTime = static_cast< ULong64_t >( stsxyter::kuHitNbTsBins ) - * static_cast< ULong64_t >( fvulCurrentTsMsb[fuCurrDpbIdx]) - + static_cast< ULong64_t >( stsxyter::kulTsCycleNbBins ) - * static_cast< ULong64_t >( fvuCurrentTsMsbCycle[fuCurrDpbIdx] ); - - Double_t dUpdatePeriodInSec = 1; - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - Double_t dTimeInS = ( ulNewTsMsbTime - fvulStartTimeLastS[ uXyterIdx ] ) - * stsxyter::kdClockCycleNs - * 1e-9; - if( dUpdatePeriodInSec <= dTimeInS || (ulNewTsMsbTime < fvulStartTimeLastS[ uXyterIdx ] ) ) - { - UInt_t uNbHitsTotal = fvuNbHitDiffTsAsicLastS[ uXyterIdx ] + fvuNbHitSameTsAsicLastS[ uXyterIdx ]; - if( 0 < uNbHitsTotal && dTimeInS < 2 * dUpdatePeriodInSec ) - { - Double_t dRate = static_cast< Double_t >( uNbHitsTotal ) / dTimeInS; - Double_t dRatioSameTs = static_cast< Double_t >( fvuNbHitSameTsAsicLastS[ uXyterIdx ] ) - / uNbHitsTotal; - Double_t dRatioSameTsAdc = static_cast< Double_t >( fvuNbHitSameTsAdcAsicLastS[ uXyterIdx ] ) - / uNbHitsTotal; - Double_t dRatioSameAdcSameTs = static_cast< Double_t >( fvuNbHitSameTsAdcAsicLastS[ uXyterIdx ] ) - / fvuNbHitSameTsAsicLastS[ uXyterIdx ]; - - fhSetupSortedAsicRatioSameTsVsFlux[ uXyterIdx ]->Fill( dRate, dRatioSameTs ); - fhSetupSortedAsicRatioSameTsAdcVsFlux[ uXyterIdx ]->Fill( dRate, dRatioSameTsAdc ); - fhSetupSortedAsicRatioSameAdcSameTsVsFlux[ uXyterIdx ]->Fill( dRate, dRatioSameAdcSameTs ); -/* - LOG(info) << "Here we are " << dTimeInS - << " " << uNbHitsTotal - << " " << dRate; -*/ - } // if( 0 < uNbHitsTotal && dTimeInS < 2 * dUpdatePeriodInSec ) - - fvulStartTimeLastS[ uXyterIdx ] = ulNewTsMsbTime; - fvuNbHitDiffTsAsicLastS[ uXyterIdx ] = 0; - fvuNbHitSameTsAsicLastS[ uXyterIdx ] = 0; - fvuNbHitSameTsAdcAsicLastS[ uXyterIdx ] = 0; - } // if( dUpdatePeriodInSec <= dTimeInS || (ulNewTsMsbTime < fvulStartTimeLastS[ uXyterIdx ] ) ) - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) -} - -void CbmCosy2018MonitorSetupGood::FillEpochInfo( stsxyter::Message /*mess*/ ) -{ -// UInt_t uVal = mess.GetTsMsbVal(); -/* - // Update Status counters - if( usVal < fvulCurrentTsMsb[fuCurrDpbIdx] ) - fvuCurrentTsMsbCycle[fuCurrDpbIdx] ++; - fvulCurrentTsMsb[fuCurrDpbIdx] = usVal; - -// fhStsAsicTsMsb->Fill( fvulCurrentTsMsb[fuCurrDpbIdx], uAsicIdx ); -*/ -} - -void CbmCosy2018MonitorSetupGood::Reset() -{ -} - -void CbmCosy2018MonitorSetupGood::Finish() -{ - - LOG(info) << "-------------------------------------"; - LOG(info) << "CbmCosy2018MonitorSetupGood statistics are "; - LOG(info) << " Hit messages: " << fmMsgCounter[ stsxyter::MessType::Hit ] << "\n" - << " Ts MSB messages: " << fmMsgCounter[ stsxyter::MessType::TsMsb ] << "\n" - << " Dummy messages: " << fmMsgCounter[ stsxyter::MessType::Dummy ] << "\n" - << " Epoch messages: " << fmMsgCounter[ stsxyter::MessType::Epoch ] << "\n" - << " Empty messages: " << fmMsgCounter[ stsxyter::MessType::Empty ]; - - LOG(info) << "-------------------------------------"; - - SaveAllHistos( fsHistoFileFullname ); - SaveAllHistos(); - -} - - -void CbmCosy2018MonitorSetupGood::FillOutput(boost::any) -{ -} - -void CbmCosy2018MonitorSetupGood::SaveAllHistos( TString sFileName ) -{ - /*******************************************************************/ - TCanvas* cFebRatioDupli = new TCanvas( "cFebRatioDupli", - "Hodoscopes coincidence quality", - 800, 600); - cFebRatioDupli->Divide( 2, fuNbStsXyters/2 + fuNbStsXyters%2 ); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - cFebRatioDupli->cd(1 + uXyterIdx ); - gPad->SetLogz(); - fhSetupSortedNbSameTsChan[ uXyterIdx ]->Draw( "colz" ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - /*******************************************************************/ - - TDirectory * oldDir = NULL; - TFile * histoFile = NULL; - if( "" != sFileName ) - { - // Store current directory position to allow restore later - oldDir = gDirectory; - // open separate histo file in recreate mode - histoFile = new TFile( sFileName , "RECREATE"); - histoFile->cd(); - } // if( "" != sFileName ) - - /***************************/ - gDirectory->mkdir("Sts_Raw"); - gDirectory->cd("Sts_Raw"); - - fhHodoMessType->Write(); - fhHodoSysMessType->Write(); - fhHodoMessTypePerDpb->Write(); - fhHodoSysMessTypePerDpb->Write(); - fhHodoMessTypePerElink->Write(); - fhHodoSysMessTypePerElink->Write(); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fhHodoChanCntRaw[ uXyterIdx ]->Write(); - fhHodoChanAdcRaw[ uXyterIdx ]->Write(); - fhHodoChanAdcRawProf[ uXyterIdx ]->Write(); - fhHodoChanRawTs[ uXyterIdx ]->Write(); - fhHodoChanMissEvt[ uXyterIdx ]->Write(); - fhHodoChanMissEvtEvo[ uXyterIdx ]->Write(); - fhHodoFebMissEvtEvo[ uXyterIdx ]->Write(); - fhHodoChanHitRateEvo[ uXyterIdx ]->Write(); - fhHodoFebRateEvo[ uXyterIdx ]->Write(); - fhHodoChanHitRateEvoLong[ uXyterIdx ]->Write(); - fhHodoFebRateEvoLong[ uXyterIdx ]->Write(); -/* - if( kTRUE == fbLongHistoEnable ) - { - fhFebRateEvoLong[ uXyterIdx ]->Write(); - fhFebChRateEvoLong[ uXyterIdx ]->Write(); - } // if( kTRUE == fbLongHistoEnable ) -*/ - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - - - fhSetupSortedDtX1Y1->Write(); - fhSetupSortedDtX2Y2->Write(); - fhSetupSortedDtN1P1->Write(); - fhSetupSortedDtN2P2->Write(); - fhSetupSortedDtX1Y1X2Y2->Write(); - fhSetupSortedDtN1P1N2P2->Write(); - fhSetupSortedDtX1Y1X2Y2N1P1->Write(); - fhSetupSortedDtX1Y1X2Y2N2P2->Write(); - fhSetupSortedDtH1H2S1S2->Write(); - fhSetupSortedCntEvoX1Y1->Write(); - fhSetupSortedCntEvoX2Y2->Write(); - fhSetupSortedCntEvoN1P1->Write(); - fhSetupSortedCntEvoN2P2->Write(); - - fhBothHodoSortedDtX1Y1->Write(); - fhBothHodoSortedDtX2Y2->Write(); - fhBothHodoSortedDtX1Y1X2Y2N1P1->Write(); - fhBothHodoSortedDtX1Y1X2Y2N2P2->Write(); - fhBothHodoSortedDtH1H2S1S2->Write(); - fhBothHodoSortedCntEvoX1Y1->Write(); - fhBothHodoSortedCntEvoX2Y2->Write(); - - fhH1H2S1SortedDtX1Y1->Write(); - fhH1H2S1SortedDtX2Y2->Write(); - fhH1H2S1SortedDtN1P1->Write(); - fhH1H2S1SortedDtN2P2->Write(); - fhH1H2S1SortedCntEvoX1Y1->Write(); - fhH1H2S1SortedCntEvoX2Y2->Write(); - fhH1H2S1SortedCntEvoN1P1->Write(); - fhH1H2S1SortedCntEvoN2P2->Write(); - - fhH1H2S2SortedDtX1Y1->Write(); - fhH1H2S2SortedDtX2Y2->Write(); - fhH1H2S2SortedDtN1P1->Write(); - fhH1H2S2SortedDtN2P2->Write(); - fhH1H2S2SortedCntEvoX1Y1->Write(); - fhH1H2S2SortedCntEvoX2Y2->Write(); - fhH1H2S2SortedCntEvoN1P1->Write(); - fhH1H2S2SortedCntEvoN2P2->Write(); - - fhSystSortedDtX1Y1->Write(); - fhSystSortedDtX2Y2->Write(); - fhSystSortedDtN1P1->Write(); - fhSystSortedDtN2P2->Write(); - fhSystSortedDtX1Y1X2Y2 ->Write(); - fhSystSortedCntEvoX1Y1->Write(); - fhSystSortedCntEvoX2Y2->Write(); - fhSystSortedCntEvoN1P1->Write(); - fhSystSortedCntEvoN2P2->Write(); - - fhSystSortedDtN1X1vsN1X2->Write(); - fhSystSortedDtP1X1vsP1X2->Write(); - fhSystSortedDtN1X1vsP1X1->Write(); - fhSystSortedDtSts1Hodo1vsSts1Hodo2->Write(); - fhSystSortedDtSts2Hodo1vsSts2Hodo2->Write(); - fhSystSortedDtAllVsMapX1->Write(); - fhSystSortedDtAllVsMapY1->Write(); - fhSystSortedDtAllVsMapX2->Write(); - fhSystSortedDtAllVsMapY2->Write(); - - fhSetupSortedDtX1->Write(); - fhSetupSortedDtY1->Write(); - fhSetupSortedDtX2->Write(); - fhSetupSortedDtY2->Write(); - fhSetupSortedDtN1->Write(); - fhSetupSortedDtP1->Write(); - fhSetupSortedDtN2->Write(); - fhSetupSortedDtP2->Write(); - - gDirectory->cd(".."); - /***************************/ - - /***************************/ - gDirectory->mkdir("Sts_Dupli"); - gDirectory->cd("Sts_Dupli"); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fhSetupSortedNbSameTsChan[ uXyterIdx ]->Write(); - fhSetupSortedSameTsAdcChan[ uXyterIdx ]->Write(); - fhSetupSortedSameTsAdcDiff[ uXyterIdx ]->Write(); - fhSetupSortedRatioSameTsChan[ uXyterIdx ]->Write(); - fhSetupSortedNbConsSameTsChan[ uXyterIdx ]->Write(); - fhSetupSortedNbConsSameTsAdcChan[ uXyterIdx ]->Write(); - fhSetupSortedNbConsSameTsVsTsAdc[ uXyterIdx ]->Write(); - - fhSetupSortedAsicRatioSameTsVsFlux[ uXyterIdx ]->Write(); - fhSetupSortedAsicRatioSameTsAdcVsFlux[ uXyterIdx ]->Write(); - fhSetupSortedAsicRatioSameAdcSameTsVsFlux[ uXyterIdx ]->Write(); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - - fhRatioMsDuplicateQuality->Write(); - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fhEvoMsDuplicateQuality[ uXyterIdx ]->Write(); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - - cFebRatioDupli->Write(); - delete cFebRatioDupli; - - gDirectory->cd(".."); - /***************************/ - - /***************************/ - gDirectory->mkdir("Sts_Maps"); - gDirectory->cd("Sts_Maps"); - - fhSetupSortedMapX1Y1->Write(); - fhSetupSortedMapX2Y2->Write(); - fhSetupSortedMapN1P1->Write(); - fhSetupSortedMapN2P2->Write(); - fhStsSortedMapS1->Write(); - if( kTRUE == fbDualStsEna ) - { - fhStsSortedMapS2->Write(); - fhStsSortedMapS1Coinc->Write(); - fhStsSortedMapS2Coinc->Write(); - } // if( kTRUE == fbDualStsEna ) - - fhBothHodoSortedMapX1Y1->Write(); - fhBothHodoSortedMapX2Y2->Write(); - - fhH1H2S1SortedMapX1Y1->Write(); - fhH1H2S1SortedMapX2Y2->Write(); - fhH1H2S1SortedMapN1P1->Write(); - fhH1H2S1SortedMapN2P2->Write(); - fhH1H2S2SortedMapX1Y1->Write(); - fhH1H2S2SortedMapX2Y2->Write(); - fhH1H2S2SortedMapN1P1->Write(); - fhH1H2S2SortedMapN2P2->Write(); - - fhSystSortedMapX1Y1->Write(); - fhSystSortedMapX2Y2->Write(); - fhSystSortedMapN1P1->Write(); - fhSystSortedMapN2P2->Write(); - - gDirectory->cd(".."); - /***************************/ - - /***************************/ - // Flib Histos - gDirectory->mkdir("Flib_Raw"); - gDirectory->cd("Flib_Raw"); - for( UInt_t uLinks = 0; uLinks < kiMaxNbFlibLinks; uLinks ++) - { - TString sMsSzName = Form("MsSz_link_%02u", uLinks); - if( fHM->Exists(sMsSzName.Data() ) ) - fHM->H1( sMsSzName.Data() )->Write(); - - sMsSzName = Form("MsSzTime_link_%02u", uLinks); - if( fHM->Exists(sMsSzName.Data() ) ) - fHM->P1( sMsSzName.Data() )->Write(); - } // for( UInt_t uLinks = 0; uLinks < 16; uLinks ++) - - TH1 * pMissedTsH1 = dynamic_cast< TH1 * >( gROOT->FindObjectAny( "Missed_TS" ) ); - if( NULL != pMissedTsH1 ) - pMissedTsH1->Write(); - - TProfile * pMissedTsEvoP = dynamic_cast< TProfile * >( gROOT->FindObjectAny( "Missed_TS_Evo" ) ); - if( NULL != pMissedTsEvoP ) - pMissedTsEvoP->Write(); - - gDirectory->cd(".."); - /***************************/ - - if( "" != sFileName ) - { - // Restore original directory position - histoFile->Close(); - oldDir->cd(); - } // if( "" != sFileName ) - -} -void CbmCosy2018MonitorSetupGood::ResetAllHistos() -{ - LOG(info) << "Reseting all STS histograms."; - - fhHodoMessType->Reset(); - fhHodoSysMessType->Reset(); - fhHodoMessTypePerDpb->Reset(); - fhHodoSysMessTypePerDpb->Reset(); - fhHodoMessTypePerElink->Reset(); - fhHodoSysMessTypePerElink->Reset(); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fhHodoChanCntRaw[ uXyterIdx ]->Reset(); - fhHodoChanAdcRaw[ uXyterIdx ]->Reset(); - fhHodoChanAdcRawProf[ uXyterIdx ]->Reset(); - fhHodoChanRawTs[ uXyterIdx ]->Reset(); - fhHodoChanMissEvt[ uXyterIdx ]->Reset(); - fhHodoChanMissEvtEvo[ uXyterIdx ]->Reset(); - fhHodoFebMissEvtEvo[ uXyterIdx ]->Reset(); - fhHodoChanHitRateEvo[ uXyterIdx ]->Reset(); - fhHodoFebRateEvo[ uXyterIdx ]->Reset(); - fhHodoChanHitRateEvoLong[ uXyterIdx ]->Reset(); - fhHodoFebRateEvoLong[ uXyterIdx ]->Reset(); -/* - if( kTRUE == fbLongHistoEnable ) - { - ftStartTimeUnix = std::chrono::steady_clock::now(); - fhFebRateEvoLong[ uXyterIdx ]->Reset(); - fhFebChRateEvoLong[ uXyterIdx ]->Reset(); - } // if( kTRUE == fbLongHistoEnable ) -*/ - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - - fhSetupSortedDtX1Y1->Reset(); - fhSetupSortedDtX2Y2->Reset(); - fhSetupSortedDtN1P1->Reset(); - fhSetupSortedDtN2P2->Reset(); - fhSetupSortedDtX1Y1X2Y2->Reset(); - fhSetupSortedDtN1P1N2P2->Reset(); - fhSetupSortedDtX1Y1X2Y2N1P1->Reset(); - fhSetupSortedDtX1Y1X2Y2N2P2->Reset(); - fhSetupSortedDtH1H2S1S2->Reset(); - fhSetupSortedCntEvoX1Y1->Reset(); - fhSetupSortedCntEvoX2Y2->Reset(); - fhSetupSortedCntEvoN1P1->Reset(); - fhSetupSortedCntEvoN2P2->Reset(); - - fhBothHodoSortedDtX1Y1->Reset(); - fhBothHodoSortedDtX2Y2->Reset(); - fhBothHodoSortedDtX1Y1X2Y2N1P1->Reset(); - fhBothHodoSortedDtX1Y1X2Y2N2P2->Reset(); - fhBothHodoSortedDtH1H2S1S2->Reset(); - fhBothHodoSortedCntEvoX1Y1->Reset(); - fhBothHodoSortedCntEvoX2Y2->Reset(); - - fhH1H2S1SortedDtX1Y1->Reset(); - fhH1H2S1SortedDtX2Y2->Reset(); - fhH1H2S1SortedDtN1P1->Reset(); - fhH1H2S1SortedDtN2P2->Reset(); - fhH1H2S1SortedCntEvoX1Y1->Reset(); - fhH1H2S1SortedCntEvoX2Y2->Reset(); - fhH1H2S1SortedCntEvoN1P1->Reset(); - fhH1H2S1SortedCntEvoN2P2->Reset(); - - fhH1H2S2SortedDtX1Y1->Reset(); - fhH1H2S2SortedDtX2Y2->Reset(); - fhH1H2S2SortedDtN1P1->Reset(); - fhH1H2S2SortedDtN2P2->Reset(); - fhH1H2S2SortedCntEvoX1Y1->Reset(); - fhH1H2S2SortedCntEvoX2Y2->Reset(); - fhH1H2S2SortedCntEvoN1P1->Reset(); - fhH1H2S2SortedCntEvoN2P2->Reset(); - - fhSystSortedDtX1Y1->Reset(); - fhSystSortedDtX2Y2->Reset(); - fhSystSortedDtN1P1->Reset(); - fhSystSortedDtN2P2->Reset(); - fhSystSortedDtX1Y1X2Y2 ->Reset(); - fhSystSortedCntEvoX1Y1->Reset(); - fhSystSortedCntEvoX2Y2->Reset(); - fhSystSortedCntEvoN1P1->Reset(); - fhSystSortedCntEvoN2P2->Reset(); - - fhSystSortedDtN1X1vsN1X2->Reset(); - fhSystSortedDtP1X1vsP1X2->Reset(); - fhSystSortedDtN1X1vsP1X1->Reset(); - fhSystSortedDtSts1Hodo1vsSts1Hodo2->Reset(); - fhSystSortedDtSts2Hodo1vsSts2Hodo2->Reset(); - fhSystSortedDtAllVsMapX1->Reset(); - fhSystSortedDtAllVsMapY1->Reset(); - fhSystSortedDtAllVsMapX2->Reset(); - fhSystSortedDtAllVsMapY2->Reset(); - - fhSetupSortedDtX1->Reset(); - fhSetupSortedDtY1->Reset(); - fhSetupSortedDtX2->Reset(); - fhSetupSortedDtY2->Reset(); - fhSetupSortedDtN1->Reset(); - fhSetupSortedDtP1->Reset(); - fhSetupSortedDtN2->Reset(); - fhSetupSortedDtP2->Reset(); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fhSetupSortedNbSameTsChan[ uXyterIdx ]->Reset(); - fhSetupSortedSameTsAdcChan[ uXyterIdx ]->Reset(); - fhSetupSortedSameTsAdcDiff[ uXyterIdx ]->Reset(); - fhSetupSortedRatioSameTsChan[ uXyterIdx ]->Reset(); - fhSetupSortedNbConsSameTsChan[ uXyterIdx ]->Reset(); - fhSetupSortedNbConsSameTsAdcChan[ uXyterIdx ]->Reset(); - fhSetupSortedNbConsSameTsVsTsAdc[ uXyterIdx ]->Reset(); - - fhSetupSortedAsicRatioSameTsVsFlux[ uXyterIdx ]->Reset(); - fhSetupSortedAsicRatioSameTsAdcVsFlux[ uXyterIdx ]->Reset(); - fhSetupSortedAsicRatioSameAdcSameTsVsFlux[ uXyterIdx ]->Reset(); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - - fhRatioMsDuplicateQuality->Reset(); - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fhEvoMsDuplicateQuality[ uXyterIdx ]->Reset(); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - - fhSetupSortedMapX1Y1->Reset(); - fhSetupSortedMapX2Y2->Reset(); - fhSetupSortedMapN1P1->Reset(); - fhSetupSortedMapN2P2->Reset(); - fhStsSortedMapS1->Reset(); - if( kTRUE == fbDualStsEna ) - { - fhStsSortedMapS2->Reset(); - fhStsSortedMapS1Coinc->Reset(); - fhStsSortedMapS2Coinc->Reset(); - } // if( kTRUE == fbDualStsEna ) - - fhBothHodoSortedMapX1Y1->Reset(); - fhBothHodoSortedMapX2Y2->Reset(); - - fhH1H2S1SortedMapX1Y1->Reset(); - fhH1H2S1SortedMapX2Y2->Reset(); - fhH1H2S1SortedMapN1P1->Reset(); - fhH1H2S1SortedMapN2P2->Reset(); - fhH1H2S2SortedMapX1Y1->Reset(); - fhH1H2S2SortedMapX2Y2->Reset(); - fhH1H2S2SortedMapN1P1->Reset(); - fhH1H2S2SortedMapN2P2->Reset(); - - fhSystSortedMapX1Y1->Reset(); - fhSystSortedMapX2Y2->Reset(); - fhSystSortedMapN1P1->Reset(); - fhSystSortedMapN2P2->Reset(); - - for( UInt_t uLinks = 0; uLinks < kiMaxNbFlibLinks; ++uLinks ) - { - TString sMsSzName = Form("MsSz_link_%02u", uLinks); - if( fHM->Exists(sMsSzName.Data() ) ) - fHM->H1( sMsSzName.Data() )->Reset(); - - sMsSzName = Form("MsSzTime_link_%02u", uLinks); - if( fHM->Exists(sMsSzName.Data() ) ) - fHM->P1( sMsSzName.Data() )->Reset(); - } // for( UInt_t uLinks = 0; uLinks < kiMaxNbFlibLinks; ++uLinks ) - - fdStartTime = -1; - fdStartTimeMsSz = -1; -} - -void CbmCosy2018MonitorSetupGood::SetRunStart( Int_t dateIn, Int_t timeIn, Int_t iBinSize ) -{ - TDatime * fRunStartDateTime = new TDatime( dateIn, timeIn); - fiRunStartDateTimeSec = fRunStartDateTime->Convert(); - fiBinSizeDatePlots = iBinSize; - - LOG(info) << "Assigned new MUCH Run Start Date-Time: " << fRunStartDateTime->AsString(); -} - -void CbmCosy2018MonitorSetupGood::SetLongDurationLimits( UInt_t uDurationSeconds, UInt_t uBinSize ) -{ - fbLongHistoEnable = kTRUE; - fuLongHistoNbSeconds = uDurationSeconds; - fuLongHistoBinSizeSec = uBinSize; -} - -void CbmCosy2018MonitorSetupGood::ComputeCoordinatesSensor1( Int_t iChanN, Int_t iChanP, Double_t & dPosX, Double_t & dPosY ) -{ - dPosX = 0.0; - dPosY = 0.0; - - Int_t iCoordN = iChanN + fiStripsOffsetN1; - Int_t iCoordP = 127 - (iChanP + fiStripsOffsetP1); - - dPosX = kdPitchMm * iCoordN; - dPosY = kdSensorsSzY / 2.0 - kdPitchMm * ( iCoordN - iCoordP ) / fdStereoAngleTan; -} - -void CbmCosy2018MonitorSetupGood::ComputeCoordinatesSensor2( Int_t iChanN, Int_t iChanP, Double_t & dPosX, Double_t & dPosY ) -{ - dPosX = 0.0; - dPosY = 0.0; - - Int_t iCoordN = iChanN + fiStripsOffsetN2; - Int_t iCoordP = 127 - (iChanP + fiStripsOffsetP2); - - dPosX = kdPitchMm * iCoordN; - dPosY = kdSensorsSzY / 2.0 - kdPitchMm * ( iCoordN - iCoordP ) / fdStereoAngleTan; -} - -ClassImp(CbmCosy2018MonitorSetupGood) diff --git a/beamtime/cosy2018/unpacker/CbmCosy2018MonitorSetupGood.h b/beamtime/cosy2018/unpacker/CbmCosy2018MonitorSetupGood.h deleted file mode 100644 index b31f875a8b50e789eaf9fcdc9c84b996ac4ae33d..0000000000000000000000000000000000000000 --- a/beamtime/cosy2018/unpacker/CbmCosy2018MonitorSetupGood.h +++ /dev/null @@ -1,343 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmCosy2018MonitorSetupGood ----- -// ----- Created 27/02/18 by P.-A. Loizeau ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CBMCOSY2018MONITORSETUPGOOD_H -#define CBMCOSY2018MONITORSETUPGOOD_H - -#include "Timeslice.hpp" - -// Data -#include "StsXyterMessage.h" -#include "StsXyterFinalHit.h" - -// CbmRoot -#include "CbmTSUnpack.h" -#include "CbmHistManager.h" - -// C++11 -#include <chrono> - -// C/C++ -#include <vector> -#include <set> -#include <map> - -class CbmCern2017UnpackParHodo; -class CbmCern2017UnpackParSts; - -class CbmCosy2018MonitorSetupGood: public CbmTSUnpack -{ -public: - - CbmCosy2018MonitorSetupGood(); - virtual ~CbmCosy2018MonitorSetupGood(); - - virtual Bool_t Init(); - - virtual Bool_t DoUnpack(const fles::Timeslice& ts, size_t component); - - virtual void Reset(); - - virtual void Finish(); - - void SetParContainers(); - - Bool_t InitContainers(); - - Bool_t ReInitContainers(); - - void FillOutput(boost::any); - - void SetRunStart( Int_t dateIn, Int_t timeIn, Int_t iBinSize = 5 ); - - void ResetAllHistos(); - void SaveAllHistos( TString sFileName = "" ); - void SetHistoFileName( TString sFileName = "data/SetupHistos.root" ) { fsHistoFileFullname = sFileName; } - - void SetMsOverlap(size_t uOverlapMsNb = 1) { fuOverlapMsNb = uOverlapMsNb; } - size_t GetMsOverlap() { return fuOverlapMsNb; } - - void SetPrintMessage( Bool_t bPrintMessOn = kTRUE, - stsxyter::MessagePrintMask ctrl = stsxyter::MessagePrintMask::msg_print_Hex | - stsxyter::MessagePrintMask::msg_print_Human ) - { fbPrintMessages = bPrintMessOn; fPrintMessCtrl = ctrl; } - void EnableDualStsMode( Bool_t bEnable = kTRUE ) { fbDualStsEna = bEnable; } - void SetLongDurationLimits( UInt_t uDurationSeconds = 3600, UInt_t uBinSize = 1 ); - void SetCoincidenceBorderHodo( Double_t dNewValue ){ fdCoincBorderHodo = dNewValue;} - void SetCoincidenceBorderSts( Double_t dNewValue ){ fdCoincBorderSts = dNewValue;} - void SetCoincidenceBorder( Double_t dNewValue ){ fdCoincBorder = dNewValue;} - - void SetStripsOffset1( Int_t iOffN, Int_t iOffP ) { fiStripsOffsetN1 = iOffN; fiStripsOffsetP1 = iOffP; } - void SetStripsOffset2( Int_t iOffN, Int_t iOffP ) { fiStripsOffsetN2 = iOffN; fiStripsOffsetP2 = iOffP; } - -private: - size_t fuOverlapMsNb; /** Ignore Overlap Ms: all fuOverlapMsNb MS at the end of timeslice **/ - - // Parameters - CbmCern2017UnpackParHodo* fUnpackParHodo; //! - CbmCern2017UnpackParSts* fUnpackParSts; //! - UInt_t fuNrOfDpbs; //! Total number of Sts DPBs in system - std::map<UInt_t, UInt_t> fDpbIdIndexMap; //! Map of DPB Identifier to DPB index - UInt_t fuNbElinksPerDpb; //! Number of possible eLinks per DPB - UInt_t fuNbStsXyters; //! Number of StsXyter ASICs - UInt_t fuNbChanPerAsic; //! Number of channels per StsXyter ASIC => should be constant somewhere!!!! - std::vector< std::vector< UInt_t > > fvuElinkToAsic; //! Vector holding for each link the corresponding ASIC index [fuNrOfDpbs * fuNbElinksPerDpb] - - // Constants - static const Int_t kiMaxNbFlibLinks = 16; - static const UInt_t kuBytesPerMessage = 4; - - // Internal Control/status of monitor - // Histo File name and path - TString fsHistoFileFullname; - // Task configuration values - Bool_t fbPrintMessages; - stsxyter::MessagePrintMask fPrintMessCtrl; - Bool_t fbDualStsEna; - // TS/MS info - ULong64_t fulCurrentTsIdx; - ULong64_t fulCurrentMsIdx; - // Current data properties - std::map< stsxyter::MessType, UInt_t > fmMsgCounter; - UInt_t fuCurrentEquipmentId; //! Current equipment ID, tells from which DPB the current MS is originating - UInt_t fuCurrDpbId; //! Temp holder until Current equipment ID is properly filled in MS - UInt_t fuCurrDpbIdx; //! Index of the DPB from which the MS currently unpacked is coming - Int_t fiRunStartDateTimeSec; //! Start of run time since "epoch" in s, for the plots with date as X axis - Int_t fiBinSizeDatePlots; //! Bin size in s for the plots with date as X axis - - // Data format control - std::vector< ULong64_t > fvulCurrentTsMsb; //! Current TS MSB for each DPB - std::vector< UInt_t > fvuCurrentTsMsbCycle; //! Current TS MSB cycle for DPB - std::vector< UInt_t > fvuElinkLastTsHit; //! TS from last hit for DPB - // Hits comparison - std::vector< std::vector< ULong64_t > > fvulChanLastHitTime; //! Last hit time in bins for each Channel - std::vector< std::vector< Double_t > > fvdChanLastHitTime; //! Last hit time in ns for each Channel - std::vector< Double_t > fvdMsTime; //! Header time of each MS - std::vector< std::vector< std::vector< UInt_t > > > fvuChanNbHitsInMs; //! Number of hits in each MS for each Channel - std::vector< std::vector< std::vector< Double_t > > > fvdChanLastHitTimeInMs; //! Last hit time in bins in each MS for each Channel - std::vector< std::vector< std::vector< UShort_t > > > fvusChanLastHitAdcInMs; //! Last hit ADC in bins in each MS for each Channel -// std::vector< std::vector< std::multiset< stsxyter::FinalHit > > > fvmChanHitsInTs; //! All hits (time & ADC) in bins in last TS for each Channel - // Starting state book-keeping - Double_t fdStartTime; /** Time of first valid hit (TS_MSB available), used as reference for evolution plots**/ - Double_t fdStartTimeMsSz; /** Time of first microslice, used as reference for evolution plots**/ - std::chrono::steady_clock::time_point ftStartTimeUnix; /** Time of run Start from UNIX system, used as reference for long evolution plots against reception time **/ - - // Hits time-sorting - std::vector< stsxyter::FinalHit > fvmHitsInTs; //! All hits (time in bins, ADC in bins, asic, channel) in last TS, sorted by multiset with "<" operator - stsxyter::FinalHit fLastSortedHit1X; //! Last sorted hit for Hodo 1 X - stsxyter::FinalHit fLastSortedHit1Y; //! Last sorted hit for Hodo 1 Y - stsxyter::FinalHit fLastSortedHit2X; //! Last sorted hit for Hodo 2 X - stsxyter::FinalHit fLastSortedHit2Y; //! Last sorted hit for Hodo 2 Y - stsxyter::FinalHit fLastSortedHit1N; //! Last sorted hit for STS 1 N - stsxyter::FinalHit fLastSortedHit1P; //! Last sorted hit for STS 1 P - stsxyter::FinalHit fLastSortedHit2N; //! Last sorted hit for STS 2 N - stsxyter::FinalHit fLastSortedHit2P; //! Last sorted hit for STS 2 P - // Coincidence histos - UInt_t fuMaxNbMicroslices; - // Rate evolution histos - Bool_t fbLongHistoEnable; - UInt_t fuLongHistoNbSeconds; - UInt_t fuLongHistoBinSizeSec; - UInt_t fuLongHistoBinNb; - - // Histograms - CbmHistManager* fHM; //! Histogram manager - TH1* fhHodoMessType; - TH1* fhHodoSysMessType; - TH2* fhHodoMessTypePerDpb; - TH2* fhHodoSysMessTypePerDpb; -/* - TH2* fhStsDpbRawTsMsb; - TH2* fhStsDpbRawTsMsbSx; - TH2* fhStsDpbRawTsMsbDpb; -*/ - TH2* fhHodoMessTypePerElink; - TH2* fhHodoSysMessTypePerElink; - - std::vector<TH1 *> fhHodoChanCntRaw; - std::vector<TH2 *> fhHodoChanAdcRaw; - std::vector<TProfile*> fhHodoChanAdcRawProf; - std::vector<TH2*> fhHodoChanRawTs; - std::vector<TH2*> fhHodoChanMissEvt; - std::vector<TH2*> fhHodoChanMissEvtEvo; - std::vector<TH2*> fhHodoChanHitRateEvo; - std::vector<TH1*> fhHodoFebRateEvo; - std::vector<TH1*> fhHodoFebMissEvtEvo; - std::vector<TH2*> fhHodoChanHitRateEvoLong; - std::vector<TH1*> fhHodoFebRateEvoLong; - - // Coincidences in sorted hits - Double_t fdCoincBorderHodo; // ns, +/- - Double_t fdCoincBorderSts; // ns, +/- - Double_t fdCoincBorder; // ns, +/- - // Single detector maps - TH1 * fhSetupSortedDtX1Y1; - TH1 * fhSetupSortedDtX2Y2; - TH1 * fhSetupSortedDtN1P1; - TH1 * fhSetupSortedDtN2P2; - TH1 * fhSetupSortedDtX1Y1X2Y2; - TH1 * fhSetupSortedDtN1P1N2P2; - TH1 * fhSetupSortedDtX1Y1X2Y2N1P1; - TH1 * fhSetupSortedDtX1Y1X2Y2N2P2; - TH1 * fhSetupSortedDtH1H2S1S2; - TH2 * fhSetupSortedMapX1Y1; - TH2 * fhSetupSortedMapX2Y2; - TH2 * fhSetupSortedMapN1P1; - TH2 * fhSetupSortedMapN2P2; - TH1 * fhSetupSortedCntEvoX1Y1; - TH1 * fhSetupSortedCntEvoX2Y2; - TH1 * fhSetupSortedCntEvoN1P1; - TH1 * fhSetupSortedCntEvoN2P2; - - // Full Hodo maps - TH1 * fhBothHodoSortedDtX1Y1; - TH1 * fhBothHodoSortedDtX2Y2; - TH1 * fhBothHodoSortedDtX1Y1X2Y2N1P1; - TH1 * fhBothHodoSortedDtX1Y1X2Y2N2P2; - TH1 * fhBothHodoSortedDtH1H2S1S2; - TH2 * fhBothHodoSortedMapX1Y1; - TH2 * fhBothHodoSortedMapX2Y2; - TH1 * fhBothHodoSortedCntEvoX1Y1; - TH1 * fhBothHodoSortedCntEvoX2Y2; - - // H + Sn maps - TH1 * fhH1H2S1SortedDtX1Y1; - TH1 * fhH1H2S1SortedDtX2Y2; - TH1 * fhH1H2S1SortedDtN1P1; - TH1 * fhH1H2S1SortedDtN2P2; - TH2 * fhH1H2S1SortedMapX1Y1; - TH2 * fhH1H2S1SortedMapX2Y2; - TH2 * fhH1H2S1SortedMapN1P1; - TH2 * fhH1H2S1SortedMapN2P2; - TH1 * fhH1H2S1SortedCntEvoX1Y1; - TH1 * fhH1H2S1SortedCntEvoX2Y2; - TH1 * fhH1H2S1SortedCntEvoN1P1; - TH1 * fhH1H2S1SortedCntEvoN2P2; - - TH1 * fhH1H2S2SortedDtX1Y1; - TH1 * fhH1H2S2SortedDtX2Y2; - TH1 * fhH1H2S2SortedDtN1P1; - TH1 * fhH1H2S2SortedDtN2P2; - TH2 * fhH1H2S2SortedMapX1Y1; - TH2 * fhH1H2S2SortedMapX2Y2; - TH2 * fhH1H2S2SortedMapN1P1; - TH2 * fhH1H2S2SortedMapN2P2; - TH1 * fhH1H2S2SortedCntEvoX1Y1; - TH1 * fhH1H2S2SortedCntEvoX2Y2; - TH1 * fhH1H2S2SortedCntEvoN1P1; - TH1 * fhH1H2S2SortedCntEvoN2P2; - - // Full System maps - TH1 * fhSystSortedDtX1Y1; - TH1 * fhSystSortedDtX2Y2; - TH1 * fhSystSortedDtN1P1; - TH1 * fhSystSortedDtN2P2; - TH1 * fhSystSortedDtX1Y1X2Y2; - TH2 * fhSystSortedMapX1Y1; - TH2 * fhSystSortedMapX2Y2; - TH2 * fhSystSortedMapN1P1; - TH2 * fhSystSortedMapN2P2; - TH1 * fhSystSortedCntEvoX1Y1; - TH1 * fhSystSortedCntEvoX2Y2; - TH1 * fhSystSortedCntEvoN1P1; - TH1 * fhSystSortedCntEvoN2P2; - - TH2 * fhSystSortedDtN1X1vsN1X2; - TH2 * fhSystSortedDtP1X1vsP1X2; - TH2 * fhSystSortedDtN1X1vsP1X1; - TH2 * fhSystSortedDtSts1Hodo1vsSts1Hodo2; - TH2 * fhSystSortedDtSts2Hodo1vsSts2Hodo2; - TH2 * fhSystSortedDtAllVsMapX1; - TH2 * fhSystSortedDtAllVsMapY1; - TH2 * fhSystSortedDtAllVsMapX2; - TH2 * fhSystSortedDtAllVsMapY2; - - TH1 * fhSetupSortedDtX1; - TH1 * fhSetupSortedDtY1; - TH1 * fhSetupSortedDtX2; - TH1 * fhSetupSortedDtY2; - TH1 * fhSetupSortedDtN1; - TH1 * fhSetupSortedDtP1; - TH1 * fhSetupSortedDtN2; - TH1 * fhSetupSortedDtP2; - - /// Counting hits without proper timestamp - std::vector< std::vector< ULong64_t > > fvulTimeLastHitAsicChan; - std::vector< std::vector< Int_t > > fviAdcLastHitAsicChan; - std::vector< std::vector< UInt_t > > fvuNbSameHitAsicChan; - std::vector< std::vector< UInt_t > > fvuNbSameFullHitAsicChan; - - std::vector< ULong64_t > fvulStartTimeLastS; - std::vector< UInt_t > fvuNbHitDiffTsAsicLastS; - std::vector< UInt_t > fvuNbHitSameTsAsicLastS; - std::vector< UInt_t > fvuNbHitSameTsAdcAsicLastS; - - std::vector< Bool_t > fvbAsicHasDuplicInMs; - - std::vector< TH2 * > fhSetupSortedNbSameTsChan; - std::vector< TH2 * > fhSetupSortedSameTsAdcChan; - std::vector< TH2 * > fhSetupSortedSameTsAdcDiff; - std::vector< TProfile2D * > fhSetupSortedRatioSameTsChan; - std::vector< TH2 * > fhSetupSortedNbConsSameTsChan; - std::vector< TH2 * > fhSetupSortedNbConsSameTsAdcChan; - std::vector< TH2 * > fhSetupSortedNbConsSameTsVsTsAdc; - - std::vector< TH2 * > fhSetupSortedAsicRatioSameTsVsFlux; - std::vector< TH2 * > fhSetupSortedAsicRatioSameTsAdcVsFlux; - std::vector< TH2 * > fhSetupSortedAsicRatioSameAdcSameTsVsFlux; - - TH1 * fhSetupSortedCleanMsDtH1H2S1S2; - TProfile * fhRatioMsDuplicateQuality; - std::vector< TProfile * > fhEvoMsDuplicateQuality; - TH1 * fhSizeCleanMs; - - TH2 * fhHodoX1SpillEvo; - TH2 * fhHodoY1SpillEvo; - TH2 * fhHodoX2SpillEvo; - TH2 * fhHodoY2SpillEvo; - - Double_t fdSpillEvoLength; - TProfile * fhHodoX1SpillEvoProf; - TProfile * fhHodoY1SpillEvoProf; - TProfile * fhHodoX2SpillEvoProf; - TProfile * fhHodoY2SpillEvoProf; - - const Double_t kdStereoAngle = 7.5; // [Deg] - Double_t fdStereoAngleTan; - const Double_t kdPitchMm = 0.058; // [mm] - const Int_t kiNbStrips = 1024; - const Double_t kdSensorsSzX = 60; // [mm], active is 59.570 mm (kiNbStrips*kdPitchMm) - const Double_t kdSensorsSzY = 40; // [mm], active is 39.703 mm - Int_t fiStripsOffsetN1; // of channel 0 relative to center strip - Int_t fiStripsOffsetP1; // of channel 0 relative to center strip - Int_t fiStripsOffsetN2; // of channel 0 relative to center strip - Int_t fiStripsOffsetP2; // of channel 0 relative to center strip - TH2 * fhStsSortedMapS1; - TH2 * fhStsSortedMapS2; - TH2 * fhStsSortedMapS1Coinc; - TH2 * fhStsSortedMapS2Coinc; - - TCanvas* fcMsSizeAll; - TH1* fhMsSz[kiMaxNbFlibLinks]; - TProfile* fhMsSzTime[kiMaxNbFlibLinks]; - - void CreateHistograms(); - - void FillHitInfo( stsxyter::Message mess, const UShort_t & usElinkIdx, const UInt_t & uAsicIdx, const UInt_t & uMsIdx ); - void FillTsMsbInfo( stsxyter::Message mess, UInt_t uMessIdx = 0, UInt_t uMsIdx = 0); - void FillEpochInfo( stsxyter::Message mess ); - - void ComputeCoordinatesSensor1( Int_t iChanN, Int_t iChanP, Double_t & dPosX, Double_t & dPosY ); - void ComputeCoordinatesSensor2( Int_t iChanN, Int_t iChanP, Double_t & dPosX, Double_t & dPosY ); - - CbmCosy2018MonitorSetupGood(const CbmCosy2018MonitorSetupGood&); - CbmCosy2018MonitorSetupGood operator=(const CbmCosy2018MonitorSetupGood&); - - ClassDef(CbmCosy2018MonitorSetupGood, 1) -}; - -#endif // CBMCOSY2018MONITORSETUPGOOD_H diff --git a/beamtime/cosy2018/unpacker/CbmCosy2018MonitorSts.cxx b/beamtime/cosy2018/unpacker/CbmCosy2018MonitorSts.cxx deleted file mode 100644 index 717afac550911bb4e85abb2066c5f8a31439d8fd..0000000000000000000000000000000000000000 --- a/beamtime/cosy2018/unpacker/CbmCosy2018MonitorSts.cxx +++ /dev/null @@ -1,1932 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmCosy2018MonitorSts ----- -// ----- Created 15/02/18 by P.-A. Loizeau ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#include "CbmCosy2018MonitorSts.h" - -// Data - -// CbmRoot -#include "CbmCern2017UnpackParSts.h" -#include "CbmHistManager.h" - -// FairRoot -#include "FairLogger.h" -#include "FairRootManager.h" -#include "FairRun.h" -#include "FairRuntimeDb.h" -#include "FairRunOnline.h" - -// Root -#include "TClonesArray.h" -#include "TString.h" -#include "TRandom.h" -#include "THttpServer.h" -#include "TROOT.h" -#include "TStyle.h" -#include "TMath.h" -#include <TFile.h> - -// C++11 - -// C/C++ -#include <iostream> -#include <stdint.h> -#include <iomanip> - -Bool_t bCosy2018ResetStsHistos = kFALSE; -Bool_t bCosy2018WriteStsHistos = kFALSE; - -CbmCosy2018MonitorSts::CbmCosy2018MonitorSts() : - CbmTSUnpack(), - fuOverlapMsNb(0), - fUnpackPar(NULL), - fuNrOfDpbs(0), - fDpbIdIndexMap(), - fuNbElinksPerDpb(0), - fuNbStsXyters(0), - fuNbChanPerAsic(0), - fvuElinkToAsic(), - fbPrintMessages( kFALSE ), - fPrintMessCtrl( stsxyter::MessagePrintMask::msg_print_Human ), - fbChanHitDtEna( kFALSE ), - fbDualStsEna( kFALSE ), - fulCurrentTsIdx( 0 ), - fulCurrentMsIdx( 0 ), - fmMsgCounter(), - fuCurrentEquipmentId(0), - fuCurrDpbId(0), - fuCurrDpbIdx(0), - fiRunStartDateTimeSec(-1), - fiBinSizeDatePlots(-1), - fvulCurrentTsMsb(), - fvuCurrentTsMsbCycle(), - fvuElinkLastTsHit(), - fvulChanLastHitTime(), - fvdChanLastHitTime(), - fvdMsTime(), - fvuChanNbHitsInMs(), - fvdChanLastHitTimeInMs(), - fvusChanLastHitAdcInMs(), -// fvmChanHitsInTs(), - fdStartTime(-1.0), - fdStartTimeMsSz(-1.0), - ftStartTimeUnix( std::chrono::steady_clock::now() ), - fvmHitsInTs(), - fLastSortedHit1N(), - fLastSortedHit1P(), - fLastSortedHit2N(), - fLastSortedHit2P(), - fuMaxNbMicroslices(100), - fHM(new CbmHistManager()), - fhStsMessType(NULL), - fhStsSysMessType(NULL), - fhStsMessTypePerDpb(NULL), - fhStsSysMessTypePerDpb(NULL), - fhStsDpbRawTsMsb(NULL), - fhStsDpbRawTsMsbSx(NULL), - fhStsDpbRawTsMsbDpb(NULL), - fhStsMessTypePerElink(NULL), - fhStsSysMessTypePerElink(NULL), - fhStsChanCounts(), - fhStsChanRawAdc(), - fhStsChanRawAdcProf(), - fhStsChanRawTs(), - fhStsChanMissEvt(), - fhStsChanHitRateEvo(), - fhStsXyterRateEvo(), - fhStsChanHitRateEvoLong(), - fhStsXyterRateEvoLong(), - fhStsChanHitDt(), - fhStsChanHitDtNeg(), - fhStsChanHitsPerMs(), - fhStsAsicTsMsb(NULL), - fbLongHistoEnable( kFALSE ), - fuLongHistoNbSeconds( 0 ), - fuLongHistoBinSizeSec( 0 ), - fuLongHistoBinNb( 0 ), - fhFebRateEvoLong(), - fhFebChRateEvoLong(), - fhStsSortedDtN1P1(NULL), - fhStsSortedDtN2P2(NULL), - fhStsSortedDtN1N2(NULL), - fhStsSortedDtP1P2(NULL), - fhStsSortedDtN1P2(NULL), - fhStsSortedDtP1N2(NULL), - fhStsSortedMapN1P1(NULL), - fhStsSortedMapN2P2(NULL), - fhStsSortedMapN1N2(NULL), - fhStsSortedMapP1P2(NULL), - fhStsSortedMapN1P2(NULL), - fhStsSortedMapP1N2(NULL), - fhStsSortedCntEvoN1P1(NULL), - fhStsSortedCntEvoN2P2(NULL), - fhStsSortedCntEvoN1N2(NULL), - fhStsSortedCntEvoP1P2(NULL), - fhStsSortedCntEvoN1P2(NULL), - fhStsSortedCntEvoP1N2(NULL), - fhStsSortedDtN1P1N2P2(NULL), - fhStsSortedMapN1P1Coinc(NULL), - fhStsSortedMapN2P2Coinc(NULL), - fhStsSortedDtVsDiffN(NULL), - fhStsSortedDtVsDiffP(NULL), - fdStereoAngleTan( TMath::Tan( kdStereoAngle * TMath::DegToRad() ) ), - fiStripsOffsetN1( 69 ), - fiStripsOffsetP1( -69 ), - fiStripsOffsetN2( 69 ), - fiStripsOffsetP2( -69 ), - fhStsSortedMapX1Y1(NULL), - fhStsSortedMapX2Y2(NULL), - fhStsSortedMapX1Y1Coinc(NULL), - fhStsSortedMapX2Y2Coinc(NULL), - fcMsSizeAll(NULL) -{ -} - -CbmCosy2018MonitorSts::~CbmCosy2018MonitorSts() -{ -} - -Bool_t CbmCosy2018MonitorSts::Init() -{ - LOG(info) << "Initializing flib StsXyter unpacker for STS"; - - FairRootManager* ioman = FairRootManager::Instance(); - if (ioman == NULL) { - LOG(fatal) << "No FairRootManager instance"; - } - - return kTRUE; -} - -void CbmCosy2018MonitorSts::SetParContainers() -{ - LOG(info) << "Setting parameter containers for " << GetName(); - fUnpackPar = (CbmCern2017UnpackParSts*)(FairRun::Instance()->GetRuntimeDb()->getContainer("CbmCern2017UnpackParSts")); -} - - -Bool_t CbmCosy2018MonitorSts::InitContainers() -{ - LOG(info) << "Init parameter containers for " << GetName(); - - Bool_t bReInit = ReInitContainers(); - CreateHistograms(); - - return bReInit; -} - -Bool_t CbmCosy2018MonitorSts::ReInitContainers() -{ - LOG(info) << "ReInit parameter containers for " << GetName(); - - LOG(info) << "Nr. of Overlap MS: " << fuOverlapMsNb; - - fuNrOfDpbs = fUnpackPar->GetNrOfDpbs(); - fuNbElinksPerDpb = fUnpackPar->GetNbElinksPerDpb(); - fuNbStsXyters = fUnpackPar->GetNbStsXyters(); - fuNbChanPerAsic = fUnpackPar->GetNbChanPerAsic(); - - - LOG(info) << "Nr. of STS DPBs: " << fuNrOfDpbs; - - fDpbIdIndexMap.clear(); - fvuElinkToAsic.resize( fuNrOfDpbs ); - for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - { - fDpbIdIndexMap[ fUnpackPar->GetDpbId( uDpb ) ] = uDpb; - LOG(info) << "Eq. ID for DPB #" << std::setw(2) << uDpb << " = " - << std::setw(4) << std::hex << fUnpackPar->GetDpbId( uDpb ) - << std::dec - << " => " << fDpbIdIndexMap[ fUnpackPar->GetDpbId( uDpb ) ]; - - fvuElinkToAsic[uDpb].resize( fuNbElinksPerDpb ); - for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink ) - fvuElinkToAsic[uDpb][uElink] = fUnpackPar->GetElinkToAsicIdx( uDpb * fuNbElinksPerDpb + uElink ); - } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - - LOG(info) << "Nr. eLinks per DPB: " << fuNbElinksPerDpb; - LOG(info) << "Nr. of StsXyter ASICs: " << fuNbStsXyters; - LOG(info) << "Nb. channels per ASIC: " << fuNbChanPerAsic; - - for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - { - LOG(info) << "ASIC ID for eLinks in DPB #" << std::setw(2) << uDpb << ": "; - - std::stringstream ss; - for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink ) - { - if( 0 == uElink % 10 ) - ss << "\n------> "; - - ss << std::setw( 5 ) << fvuElinkToAsic[uDpb][uElink] << " "; - } // for( UInt_t uElink = 0; uElink < fuNbElinksPerDpb; ++uElink ) - LOG(info) << ss.str(); - } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - - LOG(info) << "Counter size for TS: " << stsxyter::kuHitNbTsBins; - LOG(info) << "Counter size for TS_MSB: " << stsxyter::kuTsMsbNbTsBins; - LOG(info) << "Counter size for cycles: " << stsxyter::kulTsCycleNbBins; - - LOG(info) << "ASIC Idx for STS 1 N: " << fUnpackPar->GetAsicIndexSts1N(); - LOG(info) << "ASIC Idx for STS 1 P: " << fUnpackPar->GetAsicIndexSts1P(); - LOG(info) << "ASIC Idx for STS 2 N: " << fUnpackPar->GetAsicIndexSts2N(); - LOG(info) << "ASIC Idx for STS 2 P: " << fUnpackPar->GetAsicIndexSts2P(); - - // Internal status initialization - fvulCurrentTsMsb.resize( fuNrOfDpbs ); - fvuCurrentTsMsbCycle.resize( fuNrOfDpbs ); - fvuElinkLastTsHit.resize( fuNrOfDpbs ); - for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - { - fvulCurrentTsMsb[uDpb] = 0; - fvuCurrentTsMsbCycle[uDpb] = 0; - fvuElinkLastTsHit[uDpb] = 0; - } // for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - - fvulChanLastHitTime.resize( fuNbStsXyters ); - fvdChanLastHitTime.resize( fuNbStsXyters ); - fvuChanNbHitsInMs.resize( fuNbStsXyters ); - fvdChanLastHitTimeInMs.resize( fuNbStsXyters ); - fvusChanLastHitAdcInMs.resize( fuNbStsXyters ); -// fvmChanHitsInTs.resize( fuNbStsXyters ); - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fvulChanLastHitTime[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvdChanLastHitTime[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvuChanNbHitsInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvdChanLastHitTimeInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvusChanLastHitAdcInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); -// fvmChanHitsInTs[ uXyterIdx ].resize( fuNbChanPerAsic ); - for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - { - fvulChanLastHitTime[ uXyterIdx ][ uChan ] = 0; - fvdChanLastHitTime[ uXyterIdx ][ uChan ] = -1.0; - - fvuChanNbHitsInMs[ uXyterIdx ][ uChan ].resize( fuMaxNbMicroslices ); - fvdChanLastHitTimeInMs[ uXyterIdx ][ uChan ].resize( fuMaxNbMicroslices ); - fvusChanLastHitAdcInMs[ uXyterIdx ][ uChan ].resize( fuMaxNbMicroslices ); -// fvmChanHitsInTs[ uXyterIdx ][ uChan ].clear(); - for( UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx ) - { - fvuChanNbHitsInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = 0; - fvdChanLastHitTimeInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = -1.0; - fvusChanLastHitAdcInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = 0; - } // for( UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx ) - } // for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - LOG(info) << "CbmCosy2018MonitorSts::ReInitContainers => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs.size() << " VS " << fuNbStsXyters; - LOG(info) << "CbmCosy2018MonitorSts::ReInitContainers => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs[ 0 ].size() << " VS " << fuNbChanPerAsic; - LOG(info) << "CbmCosy2018MonitorSts::ReInitContainers => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs[ 0 ][ 0 ].size() << " VS " << fuMaxNbMicroslices; - return kTRUE; -} - -void CbmCosy2018MonitorSts::CreateHistograms() -{ - - TString sHistName{""}; - TString title{""}; - - sHistName = "hStsMessageType"; - title = "Nb of message for each type; Type"; - fhStsMessType = new TH1I(sHistName, title, 5, 0., 5.); - fhStsMessType->GetXaxis()->SetBinLabel( 1, "Dummy"); - fhStsMessType->GetXaxis()->SetBinLabel( 2, "Hit"); - fhStsMessType->GetXaxis()->SetBinLabel( 3, "TsMsb"); - fhStsMessType->GetXaxis()->SetBinLabel( 4, "Epoch"); - fhStsMessType->GetXaxis()->SetBinLabel( 5, "Empty"); -/* *** Missing int + MessType OP!!!! **** - fhStsMessType->GetXaxis()->SetBinLabel(1 + stsxyter::MessType::Dummy, "Dummy"); - fhStsMessType->GetXaxis()->SetBinLabel(1 + stsxyter::MessType::Hit, "Hit"); - fhStsMessType->GetXaxis()->SetBinLabel(1 + stsxyter::MessType::TsMsb, "TsMsb"); - fhStsMessType->GetXaxis()->SetBinLabel(1 + stsxyter::MessType::ReadDataAck, "ReadDataAck"); - fhStsMessType->GetXaxis()->SetBinLabel(1 + stsxyter::MessType::Ack, "Ack"); -*/ - - sHistName = "hStsSysMessType"; - title = "Nb of system message for each type; System Type"; - fhStsSysMessType = new TH1I(sHistName, title, 17, 0., 17.); -/* - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_START, "DAQ START"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_FINISH, "DAQ FINISH"); - hSysMessType->GetXaxis()->SetBinLabel(1 + 16, "GET4 Hack 32B"); -*/ - - sHistName = "hStsMessageTypePerDpb"; - title = "Nb of message of each type for each DPB; DPB; Type"; - fhStsMessTypePerDpb = new TH2I(sHistName, title, fuNrOfDpbs, 0, fuNrOfDpbs, 5, 0., 5.); - fhStsMessTypePerDpb->GetYaxis()->SetBinLabel( 1, "Dummy"); - fhStsMessTypePerDpb->GetYaxis()->SetBinLabel( 2, "Hit"); - fhStsMessTypePerDpb->GetYaxis()->SetBinLabel( 3, "TsMsb"); - fhStsMessTypePerDpb->GetYaxis()->SetBinLabel( 4, "Epoch"); - fhStsMessTypePerDpb->GetYaxis()->SetBinLabel( 5, "Empty"); -/* *** Missing int + MessType OP!!!! **** - fhStsMessType->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Dummy, "Dummy"); - fhStsMessType->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Hit, "Hit"); - fhStsMessType->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::TsMsb, "TsMsb"); - fhStsMessType->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::ReadDataAck, "ReadDataAck"); - fhStsMessType->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Ack, "Ack"); -*/ - - sHistName = "hStsSysMessTypePerDpb"; - title = "Nb of system message of each type for each DPB; DPB; System Type"; - fhStsSysMessTypePerDpb = new TH2I(sHistName, title, fuNrOfDpbs, 0, fuNrOfDpbs, 17, 0., 17.); -/* - hSysMessType->GetYaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_START, "DAQ START"); - hSysMessType->GetYaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_FINISH, "DAQ FINISH"); - hSysMessType->GetYaxis()->SetBinLabel(1 + 16, "GET4 Hack 32B"); -*/ - - sHistName = "hStsDpbRawTsMsb"; - title = "Raw TsMsb distribution for each DPB; DPB; TS MSB [Bins]"; - fhStsDpbRawTsMsb = new TH2I( sHistName, title, - fuNrOfDpbs, 0, fuNrOfDpbs, - stsxyter::kuTsMsbNbTsBins, 0., stsxyter::kuTsMsbNbTsBins); - - sHistName = "hStsDpbRawTsMsbSx"; - title = "Raw TsMsb distribution for each DPB; DPB; TS MSB [Bins]"; - fhStsDpbRawTsMsbSx = new TH2I( sHistName, title, - fuNrOfDpbs, 0, fuNrOfDpbs, - 0x1F , 0., 0x1F ); - - sHistName = "hStsDpbRawTsMsbDpb"; - title = "Raw TsMsb distribution for each DPB; DPB; TS MSB [Bins]"; - fhStsDpbRawTsMsbDpb = new TH2I( sHistName, title, - fuNrOfDpbs, 0, fuNrOfDpbs, - stsxyter::kuTsMsbNbTsBins >> 5, 0., stsxyter::kuTsMsbNbTsBins >> 5 ); - - sHistName = "hStsMessageTypePerElink"; - title = "Nb of message of each type for each eLink; eLink; Type"; - fhStsMessTypePerElink = new TH2I(sHistName, title, fuNrOfDpbs * fuNbElinksPerDpb, 0, fuNrOfDpbs * fuNbElinksPerDpb, 5, 0., 5.); - fhStsMessTypePerElink->GetYaxis()->SetBinLabel( 1, "Dummy"); - fhStsMessTypePerElink->GetYaxis()->SetBinLabel( 2, "Hit"); - fhStsMessTypePerElink->GetYaxis()->SetBinLabel( 3, "TsMsb"); - fhStsMessTypePerElink->GetYaxis()->SetBinLabel( 4, "ReadDataAck"); - fhStsMessTypePerElink->GetYaxis()->SetBinLabel( 5, "Ack"); -/* *** Missing int + MessType OP!!!! **** - fhStsMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Dummy, "Dummy"); - fhStsMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Hit, "Hit"); - fhStsMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::TsMsb, "TsMsb"); - fhStsMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::ReadDataAck, "ReadDataAck"); - fhStsMessTypePerElink->GetYaxis()->SetBinLabel(1 + stsxyter::MessType::Ack, "Ack"); -*/ - - sHistName = "hStsSysMessTypePerElink"; - title = "Nb of system message of each type for each eLink; eLink; System Type"; - fhStsSysMessTypePerElink = new TH2I(sHistName, title, fuNrOfDpbs * fuNbElinksPerDpb, 0, fuNrOfDpbs * fuNbElinksPerDpb, 17, 0., 17.); -/* - fhStsSysMessTypePerElink->GetYaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_START, "DAQ START"); - fhStsSysMessTypePerElink->GetYaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_FINISH, "DAQ FINISH"); - fhStsSysMessTypePerElink->GetYaxis()->SetBinLabel(1 + 16, "GET4 Hack 32B"); -*/ - - // Number of rate bins = - // 9 for the sub-unit decade - // + 9 for each unit of each decade * 10 for the subdecade range - // + 1 for the closing bin top edge - const Int_t iNbDecadesRate = 9; - const Int_t iNbStepsDecade = 9; - const Int_t iNbSubStepsInStep = 10; - const Int_t iNbBinsRate = iNbStepsDecade - + iNbStepsDecade * iNbSubStepsInStep * iNbDecadesRate - + 1; - Double_t dBinsRate[iNbBinsRate]; - // First fill sub-unit decade - for( Int_t iSubU = 0; iSubU < iNbStepsDecade; iSubU ++ ) - dBinsRate[ iSubU ] = 0.1 * ( 1 + iSubU ); - std::cout << std::endl; - // Then fill the main decades - Double_t dSubstepSize = 1.0 / iNbSubStepsInStep; - for( Int_t iDecade = 0; iDecade < iNbDecadesRate; iDecade ++) - { - Double_t dBase = std::pow( 10, iDecade ); - Int_t iDecadeIdx = iNbStepsDecade - + iDecade * iNbStepsDecade * iNbSubStepsInStep; - for( Int_t iStep = 0; iStep < iNbStepsDecade; iStep++ ) - { - Int_t iStepIdx = iDecadeIdx + iStep * iNbSubStepsInStep; - for( Int_t iSubStep = 0; iSubStep < iNbSubStepsInStep; iSubStep++ ) - { - dBinsRate[ iStepIdx + iSubStep ] = dBase * (1 + iStep) - + dBase * dSubstepSize * iSubStep; - } // for( Int_t iSubStep = 0; iSubStep < iNbSubStepsInStep; iSubStep++ ) - } // for( Int_t iStep = 0; iStep < iNbStepsDecade; iStep++ ) - } // for( Int_t iDecade = 0; iDecade < iNbDecadesRate; iDecade ++) - dBinsRate[ iNbBinsRate - 1 ] = std::pow( 10, iNbDecadesRate ); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - // Channel counts - sHistName = Form( "hStsChanCounts_%03u", uXyterIdx ); - title = Form( "Hits Count per channel, StsXyter #%03u; Channel; Hits []", uXyterIdx ); - fhStsChanCounts.push_back( new TH1I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - - // Raw Adc Distribution - sHistName = Form( "hStsChanRawAdc_%03u", uXyterIdx ); - title = Form( "Raw Adc distribution per channel, StsXyter #%03u; Channel []; Adc []; Hits []", uXyterIdx ); - fhStsChanRawAdc.push_back( new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - stsxyter::kuHitNbAdcBins, -0.5, stsxyter::kuHitNbAdcBins -0.5 ) ); - - // Raw Adc Distribution profile - sHistName = Form( "hStsChanRawAdcProfc_%03u", uXyterIdx ); - title = Form( "Raw Adc prodile per channel, StsXyter #%03u; Channel []; Adc []", uXyterIdx ); - fhStsChanRawAdcProf.push_back( new TProfile(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - - // Raw Ts Distribution - sHistName = Form( "hStsChanRawTs_%03u", uXyterIdx ); - title = Form( "Raw Timestamp distribution per channel, StsXyter #%03u; Channel []; Ts []; Hits []", uXyterIdx ); - fhStsChanRawTs.push_back( new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - stsxyter::kuHitNbTsBins, -0.5, stsxyter::kuHitNbTsBins -0.5 ) ); - - // Missed event flag - sHistName = Form( "hStsChanMissEvt_%03u", uXyterIdx ); - title = Form( "Missed Event flags per channel, StsXyter #%03u; Channel []; Miss Evt []; Hits []", uXyterIdx ); - fhStsChanMissEvt.push_back( new TH2I(sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - 2, -0.5, 1.5 ) ); - - // Hit rates evo per channel - sHistName = Form( "hStsChanRateEvo_%03u", uXyterIdx ); - title = Form( "Hits per second & channel in StsXyter #%03u; Time [s]; Channel []; Hits []", uXyterIdx ); - fhStsChanHitRateEvo.push_back( new TH2I( sHistName, title, - 1800, 0, 1800, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - - // Hit rates evo per StsXyter - sHistName = Form( "hStsXyterRateEvo_%03u", uXyterIdx ); - title = Form( "Hits per second in StsXyter #%03u; Time [s]; Hits []", uXyterIdx ); - fhStsXyterRateEvo.push_back( new TH1I(sHistName, title, 1800, 0, 1800 ) ); - - // Hit rates evo per channel, 1 minute bins, 24h - sHistName = Form( "hStsChanRateEvoLong_%03u", uXyterIdx ); - title = Form( "Hits per second & channel in StsXyter #%03u; Time [min]; Channel []; Hits []", uXyterIdx ); - fhStsChanHitRateEvoLong.push_back( new TH2D( sHistName, title, - 1440, 0, 1440, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - - // Hit rates evo per StsXyter, 1 minute bins, 24h - sHistName = Form( "hStsXyterRateEvoLong_%03u", uXyterIdx ); - title = Form( "Hits per second in StsXyter #%03u; Time [min]; Hits []", uXyterIdx ); - fhStsXyterRateEvoLong.push_back( new TH1D(sHistName, title, 1440, 0, 1440 ) ); - - // Hit distance in time for each channel - if( fbChanHitDtEna ) - { - sHistName = Form( "hStsChanHitDt_%03u", uXyterIdx ); - title = Form( "Time diff between hits on same channel in StsXyter #%03u; t_hit - t_prev [ns]; Channel []; Hits []", uXyterIdx ); - fhStsChanHitDt.push_back( new TH2I( sHistName, title, - iNbBinsRate - 1, dBinsRate, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - - sHistName = Form( "hStsChanHitDtNeg_%03u", uXyterIdx ); - title = Form( "Time diff between hits on same channel in StsXyter #%03u; t_prev - t_hit [ns]; Channel []; Hits []", uXyterIdx ); - fhStsChanHitDtNeg.push_back( new TH2I( sHistName, title, - iNbBinsRate - 1, dBinsRate, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - - } // if( fbChanHitDtEna ) - - sHistName = Form( "hStsChanHitsPerMs_%03u", uXyterIdx ); - title = Form( "Nb of hits per channel in each MS in StsXyter #%03u; Nb Hits in MS []; Channel []; MS []", uXyterIdx ); - fhStsChanHitsPerMs.push_back( new TH2I( sHistName, title, - 100, -0.5, 99.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - - if( kTRUE == fbLongHistoEnable ) - { - UInt_t uAlignedLimit = fuLongHistoNbSeconds - (fuLongHistoNbSeconds % fuLongHistoBinSizeSec); - fuLongHistoBinNb = uAlignedLimit / fuLongHistoBinSizeSec; - - sHistName = Form( "hFebRateEvoLong_%03u", uXyterIdx ); - title = Form( "Mean rate VS run time in same MS in StsXyter #%03u; Time in run [s]; Rate [1/s]", uXyterIdx ); - fhFebRateEvoLong.push_back( new TH1D( sHistName, title, - fuLongHistoBinNb, -0.5, uAlignedLimit - 0.5) ); - - sHistName = Form( "hFebChRateEvoLong_%03u", uXyterIdx ); - title = Form( "Mean rate per channel VS run time in StsXyter #%03u; Time in run [s]; Channel []; Rare [1/s]", uXyterIdx ); - fhFebChRateEvoLong.push_back( new TH2D( sHistName, title, - fuLongHistoBinNb, -0.5, uAlignedLimit - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ) ); - } // if( kTRUE == fbLongHistoEnable ) - - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - - UInt_t uNbBinEvo = 32768 + 1; - Double_t dMaxEdgeEvo = stsxyter::kdClockCycleNs - * static_cast< Double_t >( uNbBinEvo ) / 2.0; - Double_t dMinEdgeEvo = dMaxEdgeEvo * -1.0; - - sHistName = "fhStsSortedDtN1P1"; - title = "Time diff for hits Sts 1 N and Sts 1 P; tP1 - tN1 [ns]; Counts"; - fhStsSortedDtN1P1 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - if( kTRUE == fbDualStsEna ) - { - sHistName = "fhStsSortedDtN2P2"; - title = "Time diff for hits Sts 2 N and Sts 2 P; tP2 - tN2 [ns]; Counts"; - fhStsSortedDtN2P2 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhStsSortedDtN1N2"; - title = "Time diff for hits Sts 1 N and Sts 2 N; tN2 - tN1 [ns]; Counts"; - fhStsSortedDtN1N2 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhStsSortedDtP1P2"; - title = "Time diff for hits Sts 1 P and Sts 2 P; tP2 - tP1 [ns]; Counts"; - fhStsSortedDtP1P2 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhStsSortedDtN1P2"; - title = "Time diff for hits Sts 1 N and Sts 2 P; tP2 - tN1 [ns]; Counts"; - fhStsSortedDtN1P2 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhStsSortedDtP1N2"; - title = "Time diff for hits Sts 1 P and Sts 2 N; tP2 - tP1 [ns]; Counts"; - fhStsSortedDtP1N2 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - } // if( kTRUE == fbDualStsEna ) - - sHistName = "fhStsSortedMapN1P1"; - title = "Sorted hits in coincidence for Sts 1 axis N and P; N channel Sts 1 []; P channel Sts 1 []; Hits []"; - fhStsSortedMapN1P1 = new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - - if( kTRUE == fbDualStsEna ) - { - sHistName = "fhStsSortedMapN2P2"; - title = "Sorted hits in coincidence for Sts 2 axis N and P; N channel Sts 2 []; P channel Sts 2 []; Hits []"; - fhStsSortedMapN2P2 = new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - - sHistName = "fhStsSortedMapN1N2"; - title = "Sorted hits in coincidence for Sts 1 axis N and 2 axis N; N channel Sts 1 []; N channel Sts 2 []; Hits []"; - fhStsSortedMapN1N2 = new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - - sHistName = "fhStsSortedMapP1P2"; - title = "Sorted hits in coincidence for Sts 1 axis P and 2 axis P; P channel Sts 1 []; P channel Sts 2 []; Hits []"; - fhStsSortedMapP1P2 = new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - - sHistName = "fhStsSortedMapN1P2"; - title = "Sorted hits in coincidence for Sts 1 axis N and 2 axis P; N channel Sts 1 []; P channel Sts 2 []; Hits []"; - fhStsSortedMapN1P2 = new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - - sHistName = "fhStsSortedMapP1N2"; - title = "Sorted hits in coincidence for Sts 1 axis P and 2 axis N; P channel Sts 1 []; N channel Sts 2 []; Hits []"; - fhStsSortedMapP1N2 = new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - } // if( kTRUE == fbDualStsEna ) - - // Coincidence counts evolution between some axis of the sensors - sHistName = "hStsSortedCntEvoN1P1"; - title = "Nb of coincidences in both N1 and P1 per s; Time [s]; N1-P1 coincidences []"; - fhStsSortedCntEvoN1P1 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - if( kTRUE == fbDualStsEna ) - { - sHistName = "hStsSortedCntEvoN2P2"; - title = "Nb of coincidences in both N2 and P2 per s; Time [s]; N2-P2 coincidences []"; - fhStsSortedCntEvoN2P2 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "fhStsSortedCntEvoN1N2"; - title = "Nb of coincidences in both N1 and N2 per s; Time [s]; N1-N2 coincidences []"; - fhStsSortedCntEvoN1N2 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "fhStsSortedCntEvoP1P2"; - title = "Nb of coincidences in both P1 and P2 per s; Time [s]; P1-P2 coincidences []"; - fhStsSortedCntEvoP1P2 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "hStsSortedCntEvoN1P2"; - title = "Nb of coincidences in both N1 and P2 per s; Time [s]; N1-P2 coincidences []"; - fhStsSortedCntEvoN1P2 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - sHistName = "hStsSortedCntEvoP1N2"; - title = "Nb of coincidences in both P1 and N2 per s; Time [s]; P1-N2 coincidences []"; - fhStsSortedCntEvoP1N2 = new TH1I(sHistName, title, 1800, 0, 1800 ); - - /// STS1 STS2 correlations --------------------------------------- - sHistName = "fhStsSortedDtN1P1N2P2"; - title = "Time diff for hits Sts 1 <N,P> and Sts 2 <N,P>; t<N2,P2> - t<N1,P1> [ns]; Counts"; - fhStsSortedDtN1P1N2P2 = new TH1I(sHistName, title, uNbBinEvo, dMinEdgeEvo, dMaxEdgeEvo ); - - sHistName = "fhStsSortedMapN1P1Coinc"; - title = "Sorted hits in coincidence for Sts 1 axis N and P if Sts2 in coinc; N channel Sts 1 []; P channel Sts 1 []; Hits []"; - fhStsSortedMapN1P1Coinc = new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - - sHistName = "fhStsSortedMapN2P2Coinc"; - title = "Sorted hits in coincidence for Sts 2 axis N and P if Sts1 in coinc; N channel Sts 2 []; P channel Sts 2 []; Hits []"; - fhStsSortedMapN2P2Coinc = new TH2I( sHistName, title, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5, - fuNbChanPerAsic, -0.5, fuNbChanPerAsic - 0.5 ); - - UInt_t uNbBinDtDual = 250; - Double_t dMaxDtDual = 250; - UInt_t uNbBinChanDiffDual = 2*fuNbChanPerAsic + 1; - Double_t dMaxChanDiffDual = fuNbChanPerAsic + 0.5; - - sHistName = "fhStsSortedDtVsDiffN"; - title = "Channel diff in N vs Time diff between STS 1 and STS 2; t<N2,P2> - t<N1,P1> [ns]; N2 - N1 []; Hits []"; - fhStsSortedDtVsDiffN = new TH2I( sHistName, title, - uNbBinDtDual, -dMaxDtDual, dMaxDtDual, - uNbBinChanDiffDual, -dMaxChanDiffDual, dMaxChanDiffDual ); - - sHistName = "fhStsSortedDtVsDiffP"; - title = "Channel diff in P vs Time diff between STS 1 and STS 2; t<N2,P2> - t<N1,P1> [ns]; P2 - P1 []; Hits []"; - fhStsSortedDtVsDiffP = new TH2D( sHistName, title, - uNbBinDtDual, -dMaxDtDual, dMaxDtDual, - uNbBinChanDiffDual, -dMaxChanDiffDual, dMaxChanDiffDual ); - } // if( kTRUE == fbDualStsEna ) - - Double_t dMapSizeMmX = kdSensorsSzX + 10; - Double_t dMapSizeMmY = kdSensorsSzY + 10; - Int_t iNbBinsX = dMapSizeMmX / kdPitchMm; // 58 um bin - Int_t iNbBinsY = dMapSizeMmY / kdPitchMm / 8; // 116 um bin - sHistName = "fhStsSortedMapX1Y1"; - title = "Sorted hits in coincidence for Sts 1 axis X and Y; X1 [mm]; Y1 [mm]; Hits []"; - fhStsSortedMapX1Y1 = new TH2I( sHistName, title, - iNbBinsX, -dMapSizeMmX / 2.0, dMapSizeMmX / 2.0, - iNbBinsY, -dMapSizeMmY / 2.0, dMapSizeMmY / 2.0 ); - - if( kTRUE == fbDualStsEna ) - { - sHistName = "fhStsSortedMapX2Y2"; - title = "Sorted hits in coincidence for Sts 2 axis X and Y; X2 [mm]; Y2 [mm]; Hits []"; - fhStsSortedMapX2Y2 = new TH2I( sHistName, title, - iNbBinsX, -dMapSizeMmX / 2.0, dMapSizeMmX / 2.0, - iNbBinsY, -dMapSizeMmY / 2.0, dMapSizeMmY / 2.0 ); - - sHistName = "fhStsSortedMapX1Y1Coinc"; - title = "Sorted hits in coincidence for Sts 1 axis X and Y if Sts2 in coinc; X1 [mm]; Y1 [mm]; Hits []"; - fhStsSortedMapX1Y1Coinc = new TH2I( sHistName, title, - iNbBinsX, -dMapSizeMmX / 2.0, dMapSizeMmX / 2.0, - iNbBinsY, -dMapSizeMmY / 2.0, dMapSizeMmY / 2.0 ); - - sHistName = "fhStsSortedMapX2Y2Coinc"; - title = "Sorted hits in coincidence for Sts 2 axis X and Y if Sts1 in coinc; X2 [mm]; Y2 [mm]; Hits []"; - fhStsSortedMapX2Y2Coinc = new TH2I( sHistName, title, - iNbBinsX, -dMapSizeMmX / 2.0, dMapSizeMmX / 2.0, - iNbBinsY, -dMapSizeMmY / 2.0, dMapSizeMmY / 2.0 ); - } // if( kTRUE == fbDualStsEna ) - -///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// - - // Distribution of the TS_MSB per StsXyter - sHistName = "hStsAsicTsMsb"; - title = "Raw Timestamp Msb distribution per StsXyter; Ts MSB []; StsXyter []; Hits []"; - fhStsAsicTsMsb = new TH2I( sHistName, title, stsxyter::kuTsMsbNbTsBins, -0.5, stsxyter::kuTsMsbNbTsBins - 0.5, - fuNbStsXyters, -0.5, fuNbStsXyters - 0.5 ); - - // Miscroslice properties histos - for( Int_t component = 0; component < kiMaxNbFlibLinks; component ++ ) - { - fhMsSz[ component ] = NULL; - fhMsSzTime[ component ] = NULL; - } // for( Int_t component = 0; component < kiMaxNbFlibLinks; component ++ ) - - // Online histo browser commands - THttpServer* server = FairRunOnline::Instance()->GetHttpServer(); - - if( server ) - { - server->Register("/StsRaw", fhStsMessType ); - server->Register("/StsRaw", fhStsSysMessType ); - server->Register("/StsRaw", fhStsMessTypePerDpb ); - server->Register("/StsRaw", fhStsSysMessTypePerDpb ); - server->Register("/StsRaw", fhStsDpbRawTsMsb ); - server->Register("/StsRaw", fhStsDpbRawTsMsbSx ); - server->Register("/StsRaw", fhStsDpbRawTsMsbDpb ); - server->Register("/StsRaw", fhStsMessTypePerElink ); - server->Register("/StsRaw", fhStsSysMessTypePerElink ); - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - server->Register("/StsRaw", fhStsChanCounts[ uXyterIdx ] ); - server->Register("/StsRaw", fhStsChanRawAdc[ uXyterIdx ] ); - server->Register("/StsRaw", fhStsChanRawAdcProf[ uXyterIdx ] ); - server->Register("/StsRaw", fhStsChanRawTs[ uXyterIdx ] ); - server->Register("/StsRaw", fhStsChanMissEvt[ uXyterIdx ] ); - server->Register("/StsRaw", fhStsChanHitRateEvo[ uXyterIdx ] ); - server->Register("/StsRaw", fhStsXyterRateEvo[ uXyterIdx ] ); - server->Register("/StsRaw", fhStsChanHitRateEvoLong[ uXyterIdx ] ); - server->Register("/StsRaw", fhStsXyterRateEvoLong[ uXyterIdx ] ); - if( fbChanHitDtEna ) - { - server->Register("/StsRaw", fhStsChanHitDt[ uXyterIdx ] ); - server->Register("/StsRaw", fhStsChanHitDtNeg[ uXyterIdx ] ); - } // if( fbChanHitDtEna ) - server->Register("/StsRaw", fhStsChanHitsPerMs[ uXyterIdx ] ); - if( kTRUE == fbLongHistoEnable ) - { - server->Register("/StsRaw", fhFebRateEvoLong[ uXyterIdx ] ); - server->Register("/StsRaw", fhFebChRateEvoLong[ uXyterIdx ] ); - } // if( kTRUE == fbLongHistoEnable ) - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - - server->Register("/StsRaw", fhStsSortedDtN1P1 ); - if( kTRUE == fbDualStsEna ) - { - server->Register("/StsRaw", fhStsSortedDtN2P2 ); - server->Register("/StsRaw", fhStsSortedDtN1N2 ); - server->Register("/StsRaw", fhStsSortedDtP1P2 ); - server->Register("/StsRaw", fhStsSortedDtN1P2 ); - server->Register("/StsRaw", fhStsSortedDtP1N2 ); - } // if( kTRUE == fbDualStsEna ) - - server->Register("/StsRaw", fhStsSortedMapN1P1 ); - if( kTRUE == fbDualStsEna ) - { - server->Register("/StsRaw", fhStsSortedMapN2P2 ); - server->Register("/StsRaw", fhStsSortedMapN1N2 ); - server->Register("/StsRaw", fhStsSortedMapP1P2 ); - server->Register("/StsRaw", fhStsSortedMapN1P2 ); - server->Register("/StsRaw", fhStsSortedMapP1N2 ); - } // if( kTRUE == fbDualStsEna ) - - server->Register("/StsRaw", fhStsSortedCntEvoN1P1 ); - if( kTRUE == fbDualStsEna ) - { - server->Register("/StsRaw", fhStsSortedCntEvoN2P2 ); - server->Register("/StsRaw", fhStsSortedCntEvoN1N2 ); - server->Register("/StsRaw", fhStsSortedCntEvoP1P2 ); - server->Register("/StsRaw", fhStsSortedCntEvoN1P2 ); - server->Register("/StsRaw", fhStsSortedCntEvoP1N2 ); - - server->Register("/StsDual", fhStsSortedDtN1P1N2P2 ); - server->Register("/StsDual", fhStsSortedMapN1P1Coinc ); - server->Register("/StsDual", fhStsSortedMapN2P2Coinc ); - server->Register("/StsDual", fhStsSortedDtVsDiffN ); - server->Register("/StsDual", fhStsSortedDtVsDiffP ); - } // if( kTRUE == fbDualStsEna ) - - server->Register("/StsRaw", fhStsSortedMapX1Y1 ); - if( kTRUE == fbDualStsEna ) - { - server->Register("/StsRaw", fhStsSortedMapX2Y2 ); - server->Register("/StsDual", fhStsSortedMapX1Y1Coinc ); - server->Register("/StsDual", fhStsSortedMapX2Y2Coinc ); - } // if( kTRUE == fbDualStsEna ) - - - server->Register("/StsRaw", fhStsAsicTsMsb ); - server->RegisterCommand("/Reset_All_Sts", "bCosy2018ResetStsHistos=kTRUE"); - server->RegisterCommand("/Write_All_Sts", "bCosy2018WriteStsHistos=kTRUE"); - - server->Restrict("/Reset_All_Sts", "allow=admin"); - server->Restrict("/Write_All_Sts", "allow=admin"); - } // if( server ) - - /** Create summary Canvases for CERN 2017 **/ - Double_t w = 10; - Double_t h = 10; - - // Summary per StsXyter - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - TCanvas* cStsSumm = new TCanvas( Form("cStsSum_%03u", uXyterIdx ), - Form("Summary plots for StsXyter %03u", uXyterIdx ), - w, h); - cStsSumm->Divide( 2, 2 ); - - cStsSumm->cd(1); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogy(); - fhStsChanCounts[ uXyterIdx ]->Draw(); - - cStsSumm->cd(2); - gPad->SetLogz(); - fhStsChanRawAdc[ uXyterIdx ]->Draw( "colz" ); - - cStsSumm->cd(3); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhStsChanHitRateEvo[ uXyterIdx ]->Draw( "colz" ); - - cStsSumm->cd(4); - gPad->SetGridy(); -// gPad->SetLogy(); - fhStsChanRawAdcProf[ uXyterIdx ]->Draw(); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - - // Long duration rate monitoring - if( kTRUE == fbLongHistoEnable ) - { - TCanvas* cStsLongRate = new TCanvas( "cStsLongRate" , "Long duration rate plots for StsXyter", - w, h); - cStsLongRate->Divide( 2, fuNbStsXyters ); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - cStsLongRate->cd( 1 + 2 * uXyterIdx ); - gPad->SetLogy(); - gPad->SetGridx(); - gPad->SetGridy(); - fhFebRateEvoLong[ uXyterIdx ]->Draw( "hist" ); - - cStsLongRate->cd( 2 + 2 * uXyterIdx ); - gPad->SetLogz(); - gPad->SetGridx(); - gPad->SetGridy(); - fhFebChRateEvoLong[ uXyterIdx ]->Draw( "colz" ); - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - } // if( kTRUE == fbLongHistoEnable ) - - -//====================================================================// - TCanvas* cStsMaps = new TCanvas( "cStsMaps", - "Sts coincidence maps", - w, h); - if( kTRUE == fbDualStsEna ) - { - cStsMaps->Divide( 2, 3 ); - } // if( kTRUE == fbDualStsEna ) - - cStsMaps->cd(1); - gPad->SetLogz(); - fhStsSortedMapN1P1->Draw( "colz" ); - - if( kTRUE == fbDualStsEna ) - { - cStsMaps->cd(2); - gPad->SetLogz(); - fhStsSortedMapN2P2->Draw( "colz" ); - - cStsMaps->cd(3); - gPad->SetLogz(); - fhStsSortedMapN1N2->Draw( "colz" ); - - cStsMaps->cd(4); - gPad->SetLogz(); - fhStsSortedMapP1P2->Draw( "colz" ); - - cStsMaps->cd(5); - gPad->SetLogz(); - fhStsSortedMapN1P2->Draw( "colz" ); - - cStsMaps->cd(6); - gPad->SetLogz(); - fhStsSortedMapP1N2->Draw( "colz" ); - } // if( kTRUE == fbDualStsEna ) -//====================================================================// - -//====================================================================// - TCanvas* cStsCoincEvo = new TCanvas( "cStsCoincEvo", - "Sts coincidence rate evolution", - w, h); - if( kTRUE == fbDualStsEna ) - { - cStsCoincEvo->Divide( 2, 3 ); - } // if( kTRUE == fbDualStsEna ) - - cStsCoincEvo->cd(1); - gPad->SetLogz(); - fhStsSortedCntEvoN1P1->Draw( "colz" ); - - if( kTRUE == fbDualStsEna ) - { - cStsCoincEvo->cd(2); - gPad->SetLogz(); - fhStsSortedCntEvoN2P2->Draw( "colz" ); - - cStsCoincEvo->cd(3); - gPad->SetLogz(); - fhStsSortedCntEvoN1N2->Draw( "colz" ); - - cStsCoincEvo->cd(4); - gPad->SetLogz(); - fhStsSortedCntEvoP1P2->Draw( "colz" ); - - cStsCoincEvo->cd(5); - gPad->SetLogz(); - fhStsSortedCntEvoN1P2->Draw( "colz" ); - - cStsCoincEvo->cd(6); - gPad->SetLogz(); - fhStsSortedCntEvoP1N2->Draw( "colz" ); - } // if( kTRUE == fbDualStsEna ) -//====================================================================// - -//====================================================================// - if( kTRUE == fbDualStsEna ) - { - TCanvas* cStsDualDt = new TCanvas( "cStsDualDt", - "Sts dual sensor time diffs", - w, h); - cStsDualDt->Divide( 2, 2 ); - - cStsDualDt->cd(1); - gPad->SetGridx(); - gPad->SetLogy(); - fhStsSortedDtN1P1N2P2->Draw( "" ); - - cStsDualDt->cd(2); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhStsSortedDtVsDiffN->Draw( "colz" ); - - cStsDualDt->cd(4); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhStsSortedDtVsDiffP->Draw( "colz" ); - - } // if( kTRUE == fbDualStsEna ) -//====================================================================// - -//====================================================================// - TCanvas* cStsMapXY = new TCanvas( "cStsMapXY", - "Sts XY maps", - w, h); - if( kTRUE == fbDualStsEna ) - { - cStsMapXY->Divide( 2, 2 ); - } // if( kTRUE == fbDualStsEna ) - - cStsMapXY->cd(1); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhStsSortedMapX1Y1->Draw( "colz" ); - - if( kTRUE == fbDualStsEna ) - { - cStsMapXY->cd(2); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhStsSortedMapX2Y2->Draw( "colz" ); - - cStsMapXY->cd(3); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhStsSortedMapX1Y1Coinc->Draw( "colz" ); - - cStsMapXY->cd(4); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fhStsSortedMapX2Y2Coinc->Draw( "colz" ); - } // if( kTRUE == fbDualStsEna ) -//====================================================================// - - /** Recovers/Create Ms Size Canvase for CERN 2016 **/ - // Try to recover canvas in case it was created already by another monitor - // If not existing, create it - fcMsSizeAll = dynamic_cast<TCanvas *>( gROOT->FindObject( "cMsSizeAll" ) ); - if( NULL == fcMsSizeAll ) - { - fcMsSizeAll = new TCanvas("cMsSizeAll", "Evolution of MS size in last 300 s", w, h); - fcMsSizeAll->Divide( 4, 4 ); - LOG(info) << "Created MS size canvas in STS monitor"; - } // if( NULL == fcMsSizeAll ) - else LOG(info) << "Recovered MS size canvas in STS monitor"; - - /*****************************/ -} - -Bool_t CbmCosy2018MonitorSts::DoUnpack(const fles::Timeslice& ts, size_t component) -{ - THttpServer* server = FairRunOnline::Instance()->GetHttpServer(); - - if( bCosy2018ResetStsHistos ) - { - ResetAllHistos(); - bCosy2018ResetStsHistos = kFALSE; - } // if( bCosy2018ResetStsHistos ) - if( bCosy2018WriteStsHistos ) - { - SaveAllHistos( "data/StsHistos.root" ); - bCosy2018WriteStsHistos = kFALSE; - } // if( bCosy2018WriteStsHistos ) - - LOG(debug) << "Timeslice contains " << ts.num_microslices(component) - << "microslices."; - - if( component < kiMaxNbFlibLinks ) - if( NULL == fhMsSz[ component ] ) - { - TString sMsSzName = Form("MsSz_link_%02lu", component); - TString sMsSzTitle = Form("Size of MS for nDPB of link %02lu; Ms Size [bytes]", component); - fhMsSz[ component ] = new TH1F( sMsSzName.Data(), sMsSzTitle.Data(), 160000, 0., 20000. ); - fHM->Add(sMsSzName.Data(), fhMsSz[ component ] ); - if (server) server->Register("/FlibRaw", fhMsSz[ component ] ); - sMsSzName = Form("MsSzTime_link_%02lu", component); - sMsSzTitle = Form("Size of MS vs time for gDPB of link %02lu; Time[s] ; Ms Size [bytes]", component); - fhMsSzTime[ component ] = new TProfile( sMsSzName.Data(), sMsSzTitle.Data(), 15000, 0., 300. ); - fHM->Add( sMsSzName.Data(), fhMsSzTime[ component ] ); - if (server) server->Register("/FlibRaw", fhMsSzTime[ component ] ); - if( NULL != fcMsSizeAll ) - { - fcMsSizeAll->cd( 1 + component ); - gPad->SetLogy(); - fhMsSzTime[ component ]->Draw("hist le0"); - } // if( NULL != fcMsSizeAll ) - LOG(info) << "Added MS size histo for component: " << component - << " (DPB)"; - } // if( NULL == fhMsSz[ component ] ) - -// Int_t messageType = -111; - // Loop over microslices - size_t numCompMsInTs = ts.num_microslices(component); -/* - if( fulCurrentTsIdx + 1 != ts.index() && 0 == component) - LOG(info) << "Missed TS from " << fulCurrentTsIdx - << " to " << ts.index(); -*/ - fulCurrentTsIdx = ts.index(); - - if( fuMaxNbMicroslices < numCompMsInTs ) - { - fuMaxNbMicroslices = numCompMsInTs; - - fvdMsTime.resize( fuMaxNbMicroslices ); - fvuChanNbHitsInMs.resize( fuNbStsXyters ); - fvdChanLastHitTimeInMs.resize( fuNbStsXyters ); - fvusChanLastHitAdcInMs.resize( fuNbStsXyters ); - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fvuChanNbHitsInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvdChanLastHitTimeInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - fvusChanLastHitAdcInMs[ uXyterIdx ].resize( fuNbChanPerAsic ); - for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - { - fvuChanNbHitsInMs[ uXyterIdx ][ uChan ].resize( fuMaxNbMicroslices ); - fvdChanLastHitTimeInMs[ uXyterIdx ][ uChan ].resize( fuMaxNbMicroslices ); - fvusChanLastHitAdcInMs[ uXyterIdx ][ uChan ].resize( fuMaxNbMicroslices ); - for( UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx ) - { - fvuChanNbHitsInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = 0; - fvdChanLastHitTimeInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = -1.0; - fvusChanLastHitAdcInMs[ uXyterIdx ][ uChan ][ uMsIdx ] = 0; - } // for( UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx ) - } // for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - LOG(info) << "CbmCosy2018MonitorSts::DoUnpack => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs.size() << " VS " << fuNbStsXyters; - LOG(info) << "CbmCosy2018MonitorSts::DoUnpack => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs[ 0 ].size() << " VS " << fuNbChanPerAsic; - LOG(info) << "CbmCosy2018MonitorSts::DoUnpack => Changed fvuChanNbHitsInMs size " - << fvuChanNbHitsInMs[ 0 ][ 0 ].size() << " VS " << fuMaxNbMicroslices; - } // if( fuMaxNbMicroslices < numCompMsInTs ) - - for( size_t m = 0; m < numCompMsInTs; ++m ) - { - // Ignore overlap ms if number defined by user - if( numCompMsInTs - fuOverlapMsNb <= m ) - continue; - - auto msDescriptor = ts.descriptor(component, m); - fuCurrentEquipmentId = msDescriptor.eq_id; - const uint8_t* msContent = reinterpret_cast<const uint8_t*>(ts.content(component, m)); - - uint32_t size = msDescriptor.size; - fulCurrentMsIdx = msDescriptor.idx; - LOG(debug) << "Microslice: " << fulCurrentMsIdx - << " from EqId " << std::hex << fuCurrentEquipmentId << std::dec - << " has size: " << size; - - fuCurrDpbId = static_cast< uint32_t >( fuCurrentEquipmentId & 0xFFFF ); - fuCurrDpbIdx = fDpbIdIndexMap[ fuCurrDpbId ]; - - if( component < kiMaxNbFlibLinks ) - { - if( fdStartTimeMsSz < 0 ) - fdStartTimeMsSz = (1e-9) * static_cast<double>(fulCurrentMsIdx); - fhMsSz[ component ]->Fill( size ); - fhMsSzTime[ component ]->Fill( (1e-9) * static_cast<double>( fulCurrentMsIdx) - fdStartTimeMsSz, size); - } // if( component < kiMaxNbFlibLinks ) - - // If not integer number of message in input buffer, print warning/error - if( 0 != (size % kuBytesPerMessage) ) - LOG(error) << "The input microslice buffer does NOT " - << "contain only complete nDPB messages!"; - - // Compute the number of complete messages in the input microslice buffer - uint32_t uNbMessages = (size - (size % kuBytesPerMessage) ) - / kuBytesPerMessage; - - // Prepare variables for the loop on contents - const uint32_t* pInBuff = reinterpret_cast<const uint32_t*>( msContent ); - - for( uint32_t uIdx = 0; uIdx < uNbMessages; ++uIdx ) - { - // Fill message - uint32_t ulData = static_cast<uint32_t>(pInBuff[uIdx]); - - stsxyter::Message mess( static_cast< uint32_t >( ulData & 0xFFFFFFFF ) ); - - // Print message if requested - if( fbPrintMessages ) - mess.PrintMess( std::cout, fPrintMessCtrl ); - - stsxyter::MessType typeMess = mess.GetMessType(); - fmMsgCounter[ typeMess ] ++; - fhStsMessType->Fill( static_cast< uint16_t > (typeMess) ); - fhStsMessTypePerDpb->Fill( fuCurrDpbIdx, static_cast< uint16_t > (typeMess) ); - - switch( typeMess ) - { - case stsxyter::MessType::Hit : - { - // Extract the eLink and Asic indices => Should GO IN the fill method now that obly hits are link/asic specific! - UShort_t usElinkIdx = mess.GetLinkIndex(); - if( fuNbElinksPerDpb <= usElinkIdx ) - { - LOG(fatal) << "CbmCosy2018MonitorSts::DoUnpack => " - << "eLink index out of bounds!" - << usElinkIdx << " VS " << fuNbElinksPerDpb; - } // if( fuNbElinksPerDpb <= usElinkIdx ) - fhStsMessTypePerElink->Fill( fuCurrDpbIdx * fuNbElinksPerDpb + usElinkIdx, - static_cast< uint16_t > (typeMess) ); - - UInt_t uAsicIdx = fvuElinkToAsic[fuCurrDpbIdx][usElinkIdx]; - if( ! ( fUnpackPar->GetAsicIndexSts1N() == uAsicIdx || - fUnpackPar->GetAsicIndexSts1P() == uAsicIdx ) ) - { - if( kFALSE == fbDualStsEna ) - continue; - - if( ! ( fUnpackPar->GetAsicIndexSts2N() == uAsicIdx || - fUnpackPar->GetAsicIndexSts2P() == uAsicIdx ) ) - continue; - } // If neither P nor n side of STS sensor 1 - - FillHitInfo( mess, usElinkIdx, uAsicIdx, m ); - break; - } // case stsxyter::MessType::Hit : - case stsxyter::MessType::TsMsb : - { - FillTsMsbInfo( mess, uIdx, m ); - break; - } // case stsxyter::MessType::TsMsb : - case stsxyter::MessType::Epoch : - { - // The first message in the TS is a special ones: EPOCH - FillEpochInfo( mess ); - - if( 0 < uIdx ) - LOG(info) << "CbmCosy2018MonitorSts::DoUnpack => " - << "EPOCH message at unexpected position in MS: message " - << uIdx << " VS message 0 expected!"; - break; - } // case stsxyter::MessType::TsMsb : - case stsxyter::MessType::Empty : - { -// FillTsMsbInfo( mess ); - break; - } // case stsxyter::MessType::Empty : - case stsxyter::MessType::Dummy : - { - break; - } // case stsxyter::MessType::Dummy / ReadDataAck / Ack : - default: - { - LOG(fatal) << "CbmCosy2018MonitorSts::DoUnpack => " - << "Unknown message type, should never happen, stopping here!"; - } - } // switch( mess.GetMessType() ) - - } // for( uint32_t uIdx = 0; uIdx < uNbMessages; ++uIdx ) -/* - LOG(info) << " Finished MS " << std::setw( 12 ) << fulCurrentMsIdx - << " for DPB " << std::setw( 2 ) << fuCurrDpbIdx; -*/ - } // for( size_t m = 0; m < numCompMsInTs; ++m ) - - - // End of TS, check if stuff to do with the hits inside each MS - // Usefull for low rate pulser tests - // Need to do it only when last DPB is processed, as they are done one by one - if( fuCurrDpbIdx == fuNrOfDpbs - 1 ) - { - for( UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx ) - { - fvdMsTime[ uMsIdx ] = 0.0; - } // for( UInt_t uMsIdx = 0; uMsIdx < fuMaxNbMicroslices; ++uMsIdx ) - - - // Time differences plotting using the fully time sorted hits - Double_t dLastTimeN1 = -1e12; - Double_t dLastTimeP1 = -1e12; - Double_t dLastTimeN2 = -1e12; - Double_t dLastTimeP2 = -1e12; - if( 0 < fvmHitsInTs.size() ) - { - ULong64_t ulLastHitTime = ( *( fvmHitsInTs.rbegin() ) ).GetTs(); - std::multiset< stsxyter::FinalHit >::iterator it; - -// std::chrono::steady_clock::time_point tNow = std::chrono::steady_clock::now(); -// Double_t dUnixTimeInRun = std::chrono::duration_cast< std::chrono::seconds >(tNow - ftStartTimeUnix).count(); - - - for( it = fvmHitsInTs.begin(); - it != fvmHitsInTs.end() && (*it).GetTs() < ulLastHitTime - 320; // 32 * 3.125 ns = 1000 ns - ++it ) - { - UShort_t usAsicIdx = (*it).GetAsic(); - UShort_t usChanIdx = (*it).GetChan(); - ULong64_t ulHitTs = (*it).GetTs(); - - Double_t dTimeSinceStartSec = (ulHitTs * stsxyter::kdClockCycleNs - fdStartTime)* 1e-9; - - if( fUnpackPar->GetAsicIndexSts1N() == usAsicIdx ) - { - fLastSortedHit1N = (*it); - dLastTimeN1 = ulHitTs; - - Double_t dDtN1P1 = ( dLastTimeP1 - dLastTimeN1 ) * stsxyter::kdClockCycleNs; - fhStsSortedDtN1P1->Fill( dDtN1P1 ); - if( TMath::Abs( dDtN1P1 ) < fdCoincBorder ) - { - fhStsSortedMapN1P1->Fill( usChanIdx, fLastSortedHit1P.GetChan() ); - fhStsSortedCntEvoN1P1->Fill( dTimeSinceStartSec ); - - Double_t dX, dY; - ComputeCoordinatesSensor1( fLastSortedHit1N.GetChan(), fLastSortedHit1P.GetChan(), dX, dY ); - fhStsSortedMapX1Y1->Fill( dX, dY ); - } // if( TMath::Abs( dDtN1P1 ) < fdCoincBorder ) - - if( kTRUE == fbDualStsEna ) - { - Double_t dDtN1N2 = ( dLastTimeN2 - dLastTimeN1 ) * stsxyter::kdClockCycleNs; - Double_t dDtN1P2 = ( dLastTimeP2 - dLastTimeN1 ) * stsxyter::kdClockCycleNs; -// Double_t dDtP1P2 = ( dLastTimeP2 - dLastTimeP1 ) * stsxyter::kdClockCycleNs; -// Double_t dDtP1N2 = ( dLastTimeN2 - dLastTimeP1 ) * stsxyter::kdClockCycleNs; -// Double_t dDtN2P2 = ( dLastTimeP2 - dLastTimeN2 ) * stsxyter::kdClockCycleNs; - Double_t dDtN1P1N2P2 = ( dLastTimeN2 + dLastTimeP2 - ( dLastTimeN1 + dLastTimeP1 ) ) * stsxyter::kdClockCycleNs / 2.0; - - fhStsSortedDtN1N2->Fill( dDtN1N2 ); - fhStsSortedDtN1P2->Fill( dDtN1P2 ); - fhStsSortedDtN1P1N2P2->Fill( dDtN1P1N2P2 ); - Int_t iChanDiffN = static_cast< Int_t >( fLastSortedHit2N.GetChan() ) - - static_cast< Int_t >( fLastSortedHit1N.GetChan() ); - fhStsSortedDtVsDiffN->Fill( dDtN1P1N2P2, iChanDiffN ); - - if( TMath::Abs( dDtN1N2 ) < fdCoincBorder ) - { - fhStsSortedMapN1N2->Fill( usChanIdx, fLastSortedHit2N.GetChan() ); - fhStsSortedCntEvoN1N2->Fill( dTimeSinceStartSec ); - } // if( TMath::Abs( dDtN1N2 ) < fdCoincBorder ) - if( TMath::Abs( dDtN1P2 ) < fdCoincBorder ) - { - fhStsSortedMapN1P2->Fill( usChanIdx, fLastSortedHit2P.GetChan() ); - fhStsSortedCntEvoN1P2->Fill( dTimeSinceStartSec ); - } // if( TMath::Abs( dDtN1P2 ) < fdCoincBorder ) - - if( TMath::Abs( dDtN1P1N2P2 ) < 2*fdCoincBorder ) - { - fhStsSortedMapN1P1Coinc->Fill( fLastSortedHit1N.GetChan(), fLastSortedHit1P.GetChan() ); - fhStsSortedMapN2P2Coinc->Fill( fLastSortedHit2N.GetChan(), fLastSortedHit2P.GetChan() ); - - Double_t dX1, dY1, dX2, dY2; - ComputeCoordinatesSensor1( fLastSortedHit1N.GetChan(), fLastSortedHit1P.GetChan(), dX1, dY1 ); - ComputeCoordinatesSensor2( fLastSortedHit2N.GetChan(), fLastSortedHit2P.GetChan(), dX2, dY2 ); - fhStsSortedMapX1Y1Coinc->Fill( dX1, dY1 ); - fhStsSortedMapX2Y2Coinc->Fill( dX2, dY2 ); - } // if( TMath::Abs( dDtN1P2 ) < fdCoincBorder ) - } // if( kTRUE == fbDualStsEna ) - } // if( fUnpackPar->GetAsicIndexSts1N() == usAsicIdx ) - else if( fUnpackPar->GetAsicIndexSts1P() == usAsicIdx ) - { - fLastSortedHit1P = (*it); - dLastTimeP1 = ulHitTs; - - Double_t dDtN1P1 = ( dLastTimeP1 - dLastTimeN1 ) * stsxyter::kdClockCycleNs; - fhStsSortedDtN1P1->Fill( dDtN1P1 ); - if( TMath::Abs( dDtN1P1 ) < fdCoincBorder ) - { - fhStsSortedMapN1P1->Fill( fLastSortedHit1N.GetChan(), usChanIdx ); - fhStsSortedCntEvoN1P1->Fill( dTimeSinceStartSec ); - - Double_t dX, dY; - ComputeCoordinatesSensor1( fLastSortedHit1N.GetChan(), fLastSortedHit1P.GetChan(), dX, dY ); - fhStsSortedMapX1Y1->Fill( dX, dY ); - } - - if( kTRUE == fbDualStsEna ) - { -// Double_t dDtN1N2 = ( dLastTimeN2 - dLastTimeN1 ) * stsxyter::kdClockCycleNs; -// Double_t dDtN1P2 = ( dLastTimeP2 - dLastTimeN1 ) * stsxyter::kdClockCycleNs; - Double_t dDtP1P2 = ( dLastTimeP2 - dLastTimeP1 ) * stsxyter::kdClockCycleNs; - Double_t dDtP1N2 = ( dLastTimeN2 - dLastTimeP1 ) * stsxyter::kdClockCycleNs; -// Double_t dDtN2P2 = ( dLastTimeP2 - dLastTimeN2 ) * stsxyter::kdClockCycleNs; - Double_t dDtN1P1N2P2 = ( dLastTimeN2 + dLastTimeP2 - ( dLastTimeN1 + dLastTimeP1 ) ) * stsxyter::kdClockCycleNs / 2.0; - - fhStsSortedDtP1P2->Fill( dDtP1P2 ); - fhStsSortedDtP1N2->Fill( dDtP1N2 ); - fhStsSortedDtN1P1N2P2->Fill( dDtN1P1N2P2 ); - Int_t iChanDiffP = static_cast< Int_t >( fLastSortedHit2P.GetChan() ) - - static_cast< Int_t >( fLastSortedHit1P.GetChan() ); - fhStsSortedDtVsDiffP->Fill( dDtN1P1N2P2, iChanDiffP ); - - if( TMath::Abs( dDtP1P2 ) < fdCoincBorder ) - { - fhStsSortedMapP1P2->Fill( usChanIdx, fLastSortedHit2P.GetChan() ); - fhStsSortedCntEvoP1P2->Fill( dTimeSinceStartSec ); - } // if( TMath::Abs( dDtP1P2 ) < fdCoincBorder ) - if( TMath::Abs( dDtP1N2 ) < fdCoincBorder ) - { - fhStsSortedMapP1N2->Fill( usChanIdx, fLastSortedHit2N.GetChan() ); - fhStsSortedCntEvoP1N2->Fill( dTimeSinceStartSec ); - } // if( TMath::Abs( dDtP1N2 ) < fdCoincBorder ) - - if( TMath::Abs( dDtN1P1N2P2 ) < 2*fdCoincBorder ) - { - fhStsSortedMapN1P1Coinc->Fill( fLastSortedHit1N.GetChan(), fLastSortedHit1P.GetChan() ); - fhStsSortedMapN2P2Coinc->Fill( fLastSortedHit2N.GetChan(), fLastSortedHit2P.GetChan() ); - - Double_t dX1, dY1, dX2, dY2; - ComputeCoordinatesSensor1( fLastSortedHit1N.GetChan(), fLastSortedHit1P.GetChan(), dX1, dY1 ); - ComputeCoordinatesSensor2( fLastSortedHit2N.GetChan(), fLastSortedHit2P.GetChan(), dX2, dY2 ); - fhStsSortedMapX1Y1Coinc->Fill( dX1, dY1 ); - fhStsSortedMapX2Y2Coinc->Fill( dX2, dY2 ); - } // if( TMath::Abs( dDtN1P2 ) < fdCoincBorder ) - } // if( kTRUE == fbDualStsEna ) - } // else if( fUnpackPar->GetAsicIndexSts1P() == usAsicIdx ) - else if( kTRUE == fbDualStsEna ) - { - if( fUnpackPar->GetAsicIndexSts2N() == usAsicIdx ) - { - fLastSortedHit2N = (*it); - dLastTimeN2 = ulHitTs; - -// Double_t dDtN1P1 = ( dLastTimeP1 - dLastTimeN1 ) * stsxyter::kdClockCycleNs; - Double_t dDtN1N2 = ( dLastTimeN2 - dLastTimeN1 ) * stsxyter::kdClockCycleNs; -// Double_t dDtN1P2 = ( dLastTimeP2 - dLastTimeN1 ) * stsxyter::kdClockCycleNs; -// Double_t dDtP1P2 = ( dLastTimeP2 - dLastTimeP1 ) * stsxyter::kdClockCycleNs; - Double_t dDtP1N2 = ( dLastTimeN2 - dLastTimeP1 ) * stsxyter::kdClockCycleNs; - Double_t dDtN2P2 = ( dLastTimeP2 - dLastTimeN2 ) * stsxyter::kdClockCycleNs; - Double_t dDtN1P1N2P2 = ( dLastTimeN2 + dLastTimeP2 - ( dLastTimeN1 + dLastTimeP1 ) ) * stsxyter::kdClockCycleNs / 2.0; - - fhStsSortedDtN2P2->Fill( dDtN2P2 ); - fhStsSortedDtN1N2->Fill( dDtN1N2 ); - fhStsSortedDtP1N2->Fill( dDtP1N2 ); - fhStsSortedDtN1P1N2P2->Fill( dDtN1P1N2P2 ); - Int_t iChanDiffN = static_cast< Int_t >( fLastSortedHit2N.GetChan() ) - - static_cast< Int_t >( fLastSortedHit1N.GetChan() ); - fhStsSortedDtVsDiffN->Fill( dDtN1P1N2P2, iChanDiffN ); - - if( TMath::Abs( dDtN2P2 ) < fdCoincBorder ) - { - fhStsSortedMapN2P2->Fill( usChanIdx, fLastSortedHit2P.GetChan() ); - fhStsSortedCntEvoN2P2->Fill( dTimeSinceStartSec ); - - Double_t dX, dY; - ComputeCoordinatesSensor2( fLastSortedHit2N.GetChan(), fLastSortedHit2P.GetChan(), dX, dY ); - fhStsSortedMapX2Y2->Fill( dX, dY ); - } // if( TMath::Abs( dDtN2P2 ) < fdCoincBorder ) - if( TMath::Abs( dDtN1N2 ) < fdCoincBorder ) - { - fhStsSortedMapN1N2->Fill( fLastSortedHit1N.GetChan(), usChanIdx ); - fhStsSortedCntEvoN1N2->Fill( dTimeSinceStartSec ); - } // if( TMath::Abs( dDtN1N2 ) < fdCoincBorder ) - if( TMath::Abs( dDtP1N2 ) < fdCoincBorder ) - { - fhStsSortedMapP1N2->Fill( fLastSortedHit1P.GetChan(), usChanIdx ); - fhStsSortedCntEvoP1N2->Fill( dTimeSinceStartSec ); - } // if( TMath::Abs( dDtP1N2 ) < fdCoincBorder ) - - if( TMath::Abs( dDtN1P1N2P2 ) < 2*fdCoincBorder ) - { - fhStsSortedMapN1P1Coinc->Fill( fLastSortedHit1N.GetChan(), fLastSortedHit1P.GetChan() ); - fhStsSortedMapN2P2Coinc->Fill( fLastSortedHit2N.GetChan(), fLastSortedHit2P.GetChan() ); - - Double_t dX1, dY1, dX2, dY2; - ComputeCoordinatesSensor1( fLastSortedHit1N.GetChan(), fLastSortedHit1P.GetChan(), dX1, dY1 ); - ComputeCoordinatesSensor2( fLastSortedHit2N.GetChan(), fLastSortedHit2P.GetChan(), dX2, dY2 ); - fhStsSortedMapX1Y1Coinc->Fill( dX1, dY1 ); - fhStsSortedMapX2Y2Coinc->Fill( dX2, dY2 ); - } // if( TMath::Abs( dDtN1P2 ) < fdCoincBorder ) - } // if( fUnpackPar->GetAsicIndexSts2N() == usAsicIdx ) - else if( fUnpackPar->GetAsicIndexSts2P() == usAsicIdx ) - { - fLastSortedHit2P = (*it); - dLastTimeP2 = ulHitTs; - -// Double_t dDtN1P1 = ( dLastTimeP1 - dLastTimeN1 ) * stsxyter::kdClockCycleNs; -// Double_t dDtN1N2 = ( dLastTimeN2 - dLastTimeN1 ) * stsxyter::kdClockCycleNs; - Double_t dDtN1P2 = ( dLastTimeP2 - dLastTimeN1 ) * stsxyter::kdClockCycleNs; - Double_t dDtP1P2 = ( dLastTimeP2 - dLastTimeP1 ) * stsxyter::kdClockCycleNs; -// Double_t dDtP1N2 = ( dLastTimeN2 - dLastTimeP1 ) * stsxyter::kdClockCycleNs; - Double_t dDtN2P2 = ( dLastTimeP2 - dLastTimeN2 ) * stsxyter::kdClockCycleNs; - Double_t dDtN1P1N2P2 = ( dLastTimeN2 + dLastTimeP2 - ( dLastTimeN1 + dLastTimeP1 ) ) * stsxyter::kdClockCycleNs / 2.0; - - fhStsSortedDtN2P2->Fill( dDtN2P2 ); - fhStsSortedDtP1P2->Fill( dDtP1P2 ); - fhStsSortedDtN1P2->Fill( dDtN1P2 ); - fhStsSortedDtN1P1N2P2->Fill( dDtN1P1N2P2 ); - Int_t iChanDiffP = static_cast< Int_t >( fLastSortedHit2P.GetChan() ) - - static_cast< Int_t >( fLastSortedHit1P.GetChan() ); - fhStsSortedDtVsDiffP->Fill( dDtN1P1N2P2, iChanDiffP ); - - if( TMath::Abs( dDtN2P2 ) < fdCoincBorder ) - { - fhStsSortedMapN2P2->Fill( fLastSortedHit2N.GetChan(), usChanIdx ); - fhStsSortedCntEvoN2P2->Fill( dTimeSinceStartSec ); - - Double_t dX, dY; - ComputeCoordinatesSensor2( fLastSortedHit2N.GetChan(), fLastSortedHit2P.GetChan(), dX, dY ); - fhStsSortedMapX2Y2->Fill( dX, dY ); - } // if( TMath::Abs( dDtN2P2 ) < fdCoincBorder ) - if( TMath::Abs( dDtP1P2 ) < fdCoincBorder ) - { - fhStsSortedMapP1P2->Fill( fLastSortedHit1P.GetChan(), usChanIdx ); - fhStsSortedCntEvoP1P2->Fill( dTimeSinceStartSec ); - } // if( TMath::Abs( dDtP1P2 ) < fdCoincBorder ) - if( TMath::Abs( dDtN1P2 ) < fdCoincBorder ) - { - fhStsSortedMapN1P2->Fill( fLastSortedHit1N.GetChan(), usChanIdx ); - fhStsSortedCntEvoN1P2->Fill( dTimeSinceStartSec ); - } // if( TMath::Abs( dDtN1P2 ) < fdCoincBorder ) - - if( TMath::Abs( dDtN1P1N2P2 ) < 2*fdCoincBorder ) - { - fhStsSortedMapN1P1Coinc->Fill( fLastSortedHit1N.GetChan(), fLastSortedHit1P.GetChan() ); - fhStsSortedMapN2P2Coinc->Fill( fLastSortedHit2N.GetChan(), fLastSortedHit2P.GetChan() ); - - Double_t dX1, dY1, dX2, dY2; - ComputeCoordinatesSensor1( fLastSortedHit1N.GetChan(), fLastSortedHit1P.GetChan(), dX1, dY1 ); - ComputeCoordinatesSensor2( fLastSortedHit2N.GetChan(), fLastSortedHit2P.GetChan(), dX2, dY2 ); - fhStsSortedMapX1Y1Coinc->Fill( dX1, dY1 ); - fhStsSortedMapX2Y2Coinc->Fill( dX2, dY2 ); - } // if( TMath::Abs( dDtN1P2 ) < fdCoincBorder ) - } // else if( fUnpackPar->GetAsicIndexSts2P() == usAsicIdx ) - } // else if( kTRUE == fbDualStsEna ) - } // loop on hits untils hits within 100 ns of last one or last one itself are reached - - // Remove all hits which were already used - fvmHitsInTs.erase( fvmHitsInTs.begin(), it ); - } // if( 0 < fvmHitsInTs.size() ) - - // Remove all hits from this TS -/* - for( UInt_t uAsicIdx = 0; uAsicIdx < fuNbStsXyters; ++uAsicIdx ) - for( UInt_t uChan = 0; uChan < fuNbChanPerAsic; ++uChan ) - fvmChanHitsInTs[ uAsicIdx ][ uChan ].clear(); -*/ - } // if( fuCurrDpbIdx == fuNrOfDpbs - 1 ) - - if( 0 == ts.index() % 1000 && fuCurrDpbIdx == fuNrOfDpbs - 1 ) - { - for( UInt_t uDpb = 0; uDpb < fuNrOfDpbs; ++uDpb ) - { - Double_t dTsMsbTime = - static_cast<ULong64_t>( stsxyter::kuHitNbTsBins ) - * static_cast<ULong64_t>( fvulCurrentTsMsb[fuCurrDpbIdx]) - + static_cast<ULong64_t>( stsxyter::kulTsCycleNbBins ) - * static_cast<ULong64_t>( fvuCurrentTsMsbCycle[fuCurrDpbIdx] ); - dTsMsbTime *= stsxyter::kdClockCycleNs * 1e-9; - - LOG(info) << "End of TS " << std::setw(7) << ts.index() - << " eDPB " << std::setw(2) << uDpb - << " current TS MSB counter is " << std::setw(12) << fvulCurrentTsMsb[uDpb] - << " current TS MSB cycle counter is " << std::setw(12) << fvuCurrentTsMsbCycle[uDpb] - << " current TS MSB time is " << std::setw(12) << dTsMsbTime << " s"; - } - } // if( 0 == ts.index() % 1000 && fuCurrDpbIdx == fuNrOfDpbs - 1 ) - - return kTRUE; -} - -void CbmCosy2018MonitorSts::FillHitInfo( stsxyter::Message mess, const UShort_t & /*usElinkIdx*/, const UInt_t & uAsicIdx, const UInt_t & uMsIdx ) -{ - UShort_t usChan = mess.GetHitChannel(); - UShort_t usRawAdc = mess.GetHitAdc(); -// UShort_t usFullTs = mess.GetHitTimeFull(); -// Bool_t bMissedEvt = mess.IsHitMissedEvts(); - UShort_t usRawTs = mess.GetHitTime(); - - fhStsChanCounts[ uAsicIdx ]->Fill( usChan ); - fhStsChanRawAdc[ uAsicIdx ]->Fill( usChan, usRawAdc ); - fhStsChanRawAdcProf[ uAsicIdx ]->Fill( usChan, usRawAdc ); - fhStsChanRawTs[ uAsicIdx ]->Fill( usChan, usRawTs ); - fhStsChanMissEvt[ uAsicIdx ]->Fill( usChan, mess.IsHitMissedEvts() ); - - // Compute the Full time stamp -// Long64_t ulOldHitTime = fvulChanLastHitTime[ uAsicIdx ][ usChan ]; -// Double_t dOldHitTime = fvdChanLastHitTime[ uAsicIdx ][ usChan ]; - - // Use TS w/o overlap bits as they will anyway come from the TS_MSB - fvulChanLastHitTime[ uAsicIdx ][ usChan ] = usRawTs; - - fvulChanLastHitTime[ uAsicIdx ][ usChan ] += - static_cast<ULong64_t>( stsxyter::kuHitNbTsBins ) - * static_cast<ULong64_t>( fvulCurrentTsMsb[fuCurrDpbIdx]) - + static_cast<ULong64_t>( stsxyter::kulTsCycleNbBins ) - * static_cast<ULong64_t>( fvuCurrentTsMsbCycle[fuCurrDpbIdx] ) - ; - - fvuElinkLastTsHit[fuCurrDpbIdx] = usRawTs; - - // Convert the Hit time in bins to Hit time in ns - Double_t dHitTimeNs = fvulChanLastHitTime[ uAsicIdx ][ usChan ] * stsxyter::kdClockCycleNs; - - // If needed fill the hit interval plots - if( fbChanHitDtEna ) - { - Double_t dDeltaT = dHitTimeNs - fvdChanLastHitTime[ uAsicIdx ][ usChan ]; - if( 0 == dDeltaT ) - fhStsChanHitDtNeg[ uAsicIdx ]->Fill( 1, usChan ); - else if( 0 < dDeltaT ) - fhStsChanHitDt[ uAsicIdx ]->Fill( dDeltaT, usChan ); - else fhStsChanHitDtNeg[ uAsicIdx ]->Fill( -dDeltaT, usChan ); - } // if( fbChanHitDtEna ) - - // Store new value of Hit time in ns - fvdChanLastHitTime[ uAsicIdx ][ usChan ] = fvulChanLastHitTime[ uAsicIdx ][ usChan ] * stsxyter::kdClockCycleNs; -/* - LOG(info) << " Asic " << std::setw( 2 ) << uAsicIdx - << " Channel " << std::setw( 3 ) << usChan - << " Diff to last hit " << std::setw( 12 ) << ( fvulChanLastHitTime[ uAsicIdx ][ usChan ] - ulOldHitTime) - << " in s " << std::setw( 12 ) << ( fvdChanLastHitTime[ uAsicIdx ][ usChan ] - dOldHitTime) * 1e-9; -*/ - // Pulser and MS - fvuChanNbHitsInMs[ uAsicIdx ][ usChan ][ uMsIdx ] ++; - fvdChanLastHitTimeInMs[ uAsicIdx ][ usChan ][ uMsIdx ] = dHitTimeNs; - fvusChanLastHitAdcInMs[ uAsicIdx ][ usChan ][ uMsIdx ] = usRawAdc; -// fvmChanHitsInTs[ uAsicIdx ][ usChan ].insert( stsxyter::FinalHit( fvulChanLastHitTime[ uAsicIdx ][ usChan ], usRawAdc, uAsicIdx, usChan ) ); - fvmHitsInTs.insert( stsxyter::FinalHit( fvulChanLastHitTime[ uAsicIdx ][ usChan ], usRawAdc, uAsicIdx, usChan ) ); - -/* - LOG(info) << " TS " << std::setw( 12 ) << fulCurrentTsIdx - << " MS " << std::setw( 12 ) << fulCurrentMsIdx - << " MsInTs " << std::setw( 3 ) << uMsIdx - << " Asic " << std::setw( 2 ) << uAsicIdx - << " Channel " << std::setw( 3 ) << usChan - << " ADC " << std::setw( 3 ) << usRawAdc - << " TS " << std::setw( 3 ) << usRawTs // 9 bits TS - << " SX TsMsb " << std::setw( 2 ) << ( fvulCurrentTsMsb[fuCurrDpbIdx] & 0x1F ) // Total StsXyter TS = 14 bits => 9b Hit TS + lower 5b TS_MSB after DPB - << " DPB TsMsb " << std::setw( 6 ) << ( fvulCurrentTsMsb[fuCurrDpbIdx] >> 5 ) // Total StsXyter TS = 14 bits => 9b Hit TS + lower 5b of TS_MSB after DPB - << " TsMsb " << std::setw( 7 ) << fvulCurrentTsMsb[fuCurrDpbIdx] - << " MsbCy " << std::setw( 4 ) << fvuCurrentTsMsbCycle[fuCurrDpbIdx] - << " Time " << std::setw ( 12 ) << fvulChanLastHitTime[ uAsicIdx ][ usChan ]; -*/ - // Check Starting point of histos with time as X axis - if( -1 == fdStartTime ) - fdStartTime = fvdChanLastHitTime[ uAsicIdx ][ usChan ]; - - // Fill histos with time as X axis - Double_t dTimeSinceStartSec = (fvdChanLastHitTime[ uAsicIdx ][ usChan ] - fdStartTime)* 1e-9; - Double_t dTimeSinceStartMin = dTimeSinceStartSec / 60.0; - fhStsChanHitRateEvo[ uAsicIdx ]->Fill( dTimeSinceStartSec , usChan ); - fhStsXyterRateEvo[ uAsicIdx ]->Fill( dTimeSinceStartSec ); - fhStsChanHitRateEvoLong[ uAsicIdx ]->Fill( dTimeSinceStartMin, usChan, 1.0/60.0 ); - fhStsXyterRateEvoLong[ uAsicIdx ]->Fill( dTimeSinceStartMin, 1.0/60.0 ); - - if( kTRUE == fbLongHistoEnable ) - { - std::chrono::steady_clock::time_point tNow = std::chrono::steady_clock::now(); - Double_t dUnixTimeInRun = std::chrono::duration_cast< std::chrono::seconds >(tNow - ftStartTimeUnix).count(); - fhFebRateEvoLong[ uAsicIdx ]->Fill( dUnixTimeInRun , 1.0 / fuLongHistoBinSizeSec ); - fhFebChRateEvoLong[ uAsicIdx ]->Fill( dUnixTimeInRun , usChan, 1.0 / fuLongHistoBinSizeSec ); - } // if( kTRUE == fbLongHistoEnable ) - -} - -void CbmCosy2018MonitorSts::FillTsMsbInfo( stsxyter::Message mess, UInt_t uMessIdx, UInt_t /*uMsIdx*/ ) -{ - UInt_t uVal = mess.GetTsMsbVal(); -/* - if( 0 == fuCurrDpbIdx ) - LOG(info) << " TS " << std::setw( 12 ) << fulCurrentTsIdx - << " MS " << std::setw( 12 ) << fulCurrentMsIdx - << " MsInTs " << std::setw( 3 ) << uMsIdx - << " DPB " << std::setw( 2 ) << fuCurrDpbIdx - << " Mess " << std::setw( 5 ) << uMessIdx - << " TsMsb " << std::setw( 5 ) << uVal; -*/ -/* - if( (uVal != fvulCurrentTsMsb[fuCurrDpbIdx] + 1) && 0 < uVal && - !( 1 == uMessIdx && usVal == fvulCurrentTsMsb[fuCurrDpbIdx] ) ) // 1st TS_MSB in MS is always a repeat of the last one in previous MS! - { - LOG(info) << "TS MSB not increasing by 1! TS " << std::setw( 12 ) << fulCurrentTsIdx - << " MS " << std::setw( 12 ) << fulCurrentMsIdx - << " MsInTs " << std::setw( 3 ) << uMsIdx - << " DPB " << std::setw( 2 ) << fuCurrDpbIdx - << " Mess " << std::setw( 5 ) << uMessIdx - << " Old TsMsb " << std::setw( 5 ) << fvulCurrentTsMsb[fuCurrDpbIdx] - << " new TsMsb " << std::setw( 5 ) << uVal - << " Diff " << std::setw( 5 ) << uVal - fvulCurrentTsMsb[fuCurrDpbIdx] - << " Old MsbCy " << std::setw( 5 ) << fvuCurrentTsMsbCycle[fuCurrDpbIdx]; - } // if( (uVal != fvulCurrentTsMsb[fuCurrDpbIdx] + 1) && 0 < uVal ) -*/ - - // Update Status counters - if( uVal < fvulCurrentTsMsb[fuCurrDpbIdx] ) - { - - LOG(info) << " TS " << std::setw( 12 ) << fulCurrentTsIdx - << " MS " << std::setw( 12 ) << fulCurrentMsIdx - << " DPB " << std::setw( 2 ) << fuCurrDpbIdx - << " Old TsMsb " << std::setw( 5 ) << fvulCurrentTsMsb[fuCurrDpbIdx] - << " Old MsbCy " << std::setw( 5 ) << fvuCurrentTsMsbCycle[fuCurrDpbIdx] - << " new TsMsb " << std::setw ( 5 ) << uVal; - - fvuCurrentTsMsbCycle[fuCurrDpbIdx] ++; - } // if( uVal < fvulCurrentTsMsb[fuCurrDpbIdx] ) - fvulCurrentTsMsb[fuCurrDpbIdx] = uVal; - - if( 1 < uMessIdx ) - { - fhStsDpbRawTsMsb->Fill( fuCurrDpbIdx, fvulCurrentTsMsb[fuCurrDpbIdx] ); - fhStsDpbRawTsMsbSx->Fill( fuCurrDpbIdx, ( fvulCurrentTsMsb[fuCurrDpbIdx] & 0x1F ) ); - fhStsDpbRawTsMsbDpb->Fill( fuCurrDpbIdx, ( fvulCurrentTsMsb[fuCurrDpbIdx] >> 5 ) ); - } // if( 0 < uMessIdx ) - -// fhStsAsicTsMsb->Fill( fvulCurrentTsMsb[fuCurrDpbIdx], uAsicIdx ); -} - -void CbmCosy2018MonitorSts::FillEpochInfo( stsxyter::Message /*mess*/ ) -{ -// UInt_t uVal = mess.GetTsMsbVal(); -/* - // Update Status counters - if( usVal < fvulCurrentTsMsb[fuCurrDpbIdx] ) - fvuCurrentTsMsbCycle[fuCurrDpbIdx] ++; - fvulCurrentTsMsb[fuCurrDpbIdx] = usVal; - -// fhStsAsicTsMsb->Fill( fvulCurrentTsMsb[fuCurrDpbIdx], uAsicIdx ); -*/ -} - -void CbmCosy2018MonitorSts::Reset() -{ -} - -void CbmCosy2018MonitorSts::Finish() -{ - - LOG(info) << "-------------------------------------"; - LOG(info) << "CbmCosy2018MonitorSts statistics are "; - LOG(info) << " Hit messages: " << fmMsgCounter[ stsxyter::MessType::Hit ] << "\n" - << " Ts MSB messages: " << fmMsgCounter[ stsxyter::MessType::TsMsb ] << "\n" - << " Dummy messages: " << fmMsgCounter[ stsxyter::MessType::Dummy ] << "\n" - << " Epoch messages: " << fmMsgCounter[ stsxyter::MessType::Epoch ] << "\n" - << " Empty messages: " << fmMsgCounter[ stsxyter::MessType::Empty ]; - - LOG(info) << "-------------------------------------"; - - SaveAllHistos( "data/StsHistos.root" ); - SaveAllHistos(); - -} - - -void CbmCosy2018MonitorSts::FillOutput(boost::any) -{ -} - -void CbmCosy2018MonitorSts::SaveAllHistos( TString sFileName ) -{ - TDirectory * oldDir = NULL; - TFile * histoFile = NULL; - if( "" != sFileName ) - { - // Store current directory position to allow restore later - oldDir = gDirectory; - // open separate histo file in recreate mode - histoFile = new TFile( sFileName , "RECREATE"); - histoFile->cd(); - } // if( "" != sFileName ) - - gDirectory->mkdir("Sts_Raw"); - gDirectory->cd("Sts_Raw"); - - fhStsMessType->Write(); - fhStsSysMessType->Write(); - fhStsMessTypePerDpb->Write(); - fhStsSysMessTypePerDpb->Write(); - fhStsDpbRawTsMsb->Write(); - fhStsDpbRawTsMsbSx->Write(); - fhStsDpbRawTsMsbDpb->Write(); - fhStsMessTypePerElink->Write(); - fhStsSysMessTypePerElink->Write(); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fhStsChanCounts[ uXyterIdx ]->Write(); - fhStsChanRawAdc[ uXyterIdx ]->Write(); - fhStsChanRawAdcProf[ uXyterIdx ]->Write(); - fhStsChanRawTs[ uXyterIdx ]->Write(); - fhStsChanMissEvt[ uXyterIdx ]->Write(); - fhStsChanHitRateEvo[ uXyterIdx ]->Write(); - fhStsXyterRateEvo[ uXyterIdx ]->Write(); - fhStsChanHitRateEvoLong[ uXyterIdx ]->Write(); - fhStsXyterRateEvoLong[ uXyterIdx ]->Write(); - if( fbChanHitDtEna ) - { - fhStsChanHitDt[ uXyterIdx ]->Write(); - fhStsChanHitDtNeg[ uXyterIdx ]->Write(); - } // if( fbChanHitDtEna ) - fhStsChanHitsPerMs[ uXyterIdx ]->Write(); - if( kTRUE == fbLongHistoEnable ) - { - fhFebRateEvoLong[ uXyterIdx ]->Write(); - fhFebChRateEvoLong[ uXyterIdx ]->Write(); - } // if( kTRUE == fbLongHistoEnable ) - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - fhStsAsicTsMsb->Write(); - - gDirectory->cd(".."); - - gDirectory->mkdir("Sts_Map"); - gDirectory->cd("Sts_Map"); - // Coincidences in same MS (unsorted hits) - // Coincidences in sorted hits - fhStsSortedDtN1P1->Write(); - fhStsSortedMapN1P1->Write(); - fhStsSortedMapX1Y1->Write(); - if( kTRUE == fbDualStsEna ) - { - fhStsSortedDtN2P2->Write(); - fhStsSortedDtN1N2->Write(); - fhStsSortedDtP1P2->Write(); - fhStsSortedDtN1P2->Write(); - fhStsSortedDtP1N2->Write(); - fhStsSortedMapN2P2->Write(); - fhStsSortedMapN1N2->Write(); - fhStsSortedMapP1P2->Write(); - fhStsSortedMapN1P2->Write(); - fhStsSortedMapP1N2->Write(); - - fhStsSortedDtN1P1N2P2->Write(); - fhStsSortedMapN1P1Coinc->Write(); - fhStsSortedMapN2P2Coinc->Write(); - fhStsSortedDtVsDiffN->Write(); - fhStsSortedDtVsDiffP->Write(); - - fhStsSortedMapX2Y2->Write(); - fhStsSortedMapX1Y1Coinc->Write(); - fhStsSortedMapX2Y2Coinc->Write(); - } // if( kTRUE == fbDualStsEna ) - gDirectory->cd(".."); - - // Flib Histos - gDirectory->mkdir("Flib_Raw"); - gDirectory->cd("Flib_Raw"); - for( UInt_t uLinks = 0; uLinks < kiMaxNbFlibLinks; uLinks ++) - { - TString sMsSzName = Form("MsSz_link_%02u", uLinks); - if( fHM->Exists(sMsSzName.Data() ) ) - fHM->H1( sMsSzName.Data() )->Write(); - - sMsSzName = Form("MsSzTime_link_%02u", uLinks); - if( fHM->Exists(sMsSzName.Data() ) ) - fHM->P1( sMsSzName.Data() )->Write(); - } // for( UInt_t uLinks = 0; uLinks < 16; uLinks ++) - gDirectory->cd(".."); - - if( "" != sFileName ) - { - // Restore original directory position - histoFile->Close(); - oldDir->cd(); - } // if( "" != sFileName ) - -} -void CbmCosy2018MonitorSts::ResetAllHistos() -{ - LOG(info) << "Reseting all STS histograms."; - - fhStsMessType->Reset(); - fhStsSysMessType->Reset(); - fhStsMessTypePerDpb->Reset(); - fhStsSysMessTypePerDpb->Reset(); - fhStsDpbRawTsMsb->Reset(); - fhStsDpbRawTsMsbSx->Reset(); - fhStsDpbRawTsMsbDpb->Reset(); - fhStsMessTypePerElink->Reset(); - fhStsSysMessTypePerElink->Reset(); - - for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - { - fhStsChanCounts[ uXyterIdx ]->Reset(); - fhStsChanRawAdc[ uXyterIdx ]->Reset(); - fhStsChanRawAdcProf[ uXyterIdx ]->Reset(); - fhStsChanRawTs[ uXyterIdx ]->Reset(); - fhStsChanMissEvt[ uXyterIdx ]->Reset(); - fhStsChanHitRateEvo[ uXyterIdx ]->Reset(); - fhStsXyterRateEvo[ uXyterIdx ]->Reset(); - fhStsChanHitRateEvoLong[ uXyterIdx ]->Reset(); - fhStsXyterRateEvoLong[ uXyterIdx ]->Reset(); - if( fbChanHitDtEna ) - { - fhStsChanHitDt[ uXyterIdx ]->Reset(); - fhStsChanHitDtNeg[ uXyterIdx ]->Reset(); - } // if( fbChanHitDtEna ) - fhStsChanHitsPerMs[ uXyterIdx ]->Reset(); - if( kTRUE == fbLongHistoEnable ) - { - ftStartTimeUnix = std::chrono::steady_clock::now(); - fhFebRateEvoLong[ uXyterIdx ]->Reset(); - fhFebChRateEvoLong[ uXyterIdx ]->Reset(); - } // if( kTRUE == fbLongHistoEnable ) - } // for( UInt_t uXyterIdx = 0; uXyterIdx < fuNbStsXyters; ++uXyterIdx ) - fhStsAsicTsMsb->Reset(); - - // Coincidences in same MS (unsorted hits) - // Coincidences in sorted hits - fhStsSortedDtN1P1->Reset(); - fhStsSortedMapN1P1->Reset(); - fhStsSortedMapX1Y1->Reset(); - - if( kTRUE == fbDualStsEna ) - { - fhStsSortedDtN2P2->Reset(); - fhStsSortedDtN1N2->Reset(); - fhStsSortedDtP1P2->Reset(); - fhStsSortedDtN1P2->Reset(); - fhStsSortedDtP1N2->Reset(); - fhStsSortedMapN2P2->Reset(); - fhStsSortedMapN1N2->Reset(); - fhStsSortedMapP1P2->Reset(); - fhStsSortedMapN1P2->Reset(); - fhStsSortedMapP1N2->Reset(); - - fhStsSortedDtN1P1N2P2->Reset(); - fhStsSortedMapN1P1Coinc->Reset(); - fhStsSortedMapN2P2Coinc->Reset(); - fhStsSortedDtVsDiffN->Reset(); - fhStsSortedDtVsDiffP->Reset(); - - fhStsSortedMapX2Y2->Reset(); - fhStsSortedMapX1Y1Coinc->Reset(); - fhStsSortedMapX2Y2Coinc->Reset(); - } // if( kTRUE == fbDualStsEna ) - - for( UInt_t uLinks = 0; uLinks < kiMaxNbFlibLinks; ++uLinks ) - { - TString sMsSzName = Form("MsSz_link_%02u", uLinks); - if( fHM->Exists(sMsSzName.Data() ) ) - fHM->H1( sMsSzName.Data() )->Reset(); - - sMsSzName = Form("MsSzTime_link_%02u", uLinks); - if( fHM->Exists(sMsSzName.Data() ) ) - fHM->P1( sMsSzName.Data() )->Reset(); - } // for( UInt_t uLinks = 0; uLinks < kiMaxNbFlibLinks; ++uLinks ) - - fdStartTime = -1; - fdStartTimeMsSz = -1; -} - -void CbmCosy2018MonitorSts::SetRunStart( Int_t dateIn, Int_t timeIn, Int_t iBinSize ) -{ - TDatime * fRunStartDateTime = new TDatime( dateIn, timeIn); - fiRunStartDateTimeSec = fRunStartDateTime->Convert(); - fiBinSizeDatePlots = iBinSize; - - LOG(info) << "Assigned new MUCH Run Start Date-Time: " << fRunStartDateTime->AsString(); -} - -void CbmCosy2018MonitorSts::SetLongDurationLimits( UInt_t uDurationSeconds, UInt_t uBinSize ) -{ - fbLongHistoEnable = kTRUE; - fuLongHistoNbSeconds = uDurationSeconds; - fuLongHistoBinSizeSec = uBinSize; -} - -void CbmCosy2018MonitorSts::ComputeCoordinatesSensor1( Int_t iChanN, Int_t iChanP, Double_t & dPosX, Double_t & dPosY ) -{ - dPosX = 0.0; - dPosY = 0.0; - - Int_t iCoordN = iChanN + fiStripsOffsetN1; - Int_t iCoordP = 127 - (iChanP + fiStripsOffsetP1); - - dPosX = kdPitchMm * iCoordN; - dPosY = kdSensorsSzY / 2.0 - kdPitchMm * ( iCoordN - iCoordP ) / fdStereoAngleTan; -} - -void CbmCosy2018MonitorSts::ComputeCoordinatesSensor2( Int_t iChanN, Int_t iChanP, Double_t & dPosX, Double_t & dPosY ) -{ - dPosX = 0.0; - dPosY = 0.0; - - Int_t iCoordN = iChanN + fiStripsOffsetN2; - Int_t iCoordP = 127 - (iChanP + fiStripsOffsetP2); - - dPosX = kdPitchMm * iCoordN; - dPosY = kdSensorsSzY / 2.0 - kdPitchMm * ( iCoordN - iCoordP ) / fdStereoAngleTan; -} - -ClassImp(CbmCosy2018MonitorSts) diff --git a/beamtime/cosy2018/unpacker/CbmCosy2018MonitorSts.h b/beamtime/cosy2018/unpacker/CbmCosy2018MonitorSts.h deleted file mode 100644 index 487762ca01b82b0f62c4291ee8876cf7b1b8a505..0000000000000000000000000000000000000000 --- a/beamtime/cosy2018/unpacker/CbmCosy2018MonitorSts.h +++ /dev/null @@ -1,229 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmCosy2018MonitorSts ----- -// ----- Created 15/02/18 by P.-A. Loizeau ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CBMCOSY2018MONITORSTS_H -#define CBMCOSY2018MONITORSTS_H - -#include "Timeslice.hpp" - -// Data -#include "StsXyterMessage.h" -#include "StsXyterFinalHit.h" - -// CbmRoot -#include "CbmTSUnpack.h" -#include "CbmHistManager.h" - -// C++11 -#include <chrono> - -// C/C++ -#include <vector> -#include <set> -#include <map> - -class CbmCern2017UnpackParSts; - -class CbmCosy2018MonitorSts: public CbmTSUnpack -{ -public: - - CbmCosy2018MonitorSts(); - virtual ~CbmCosy2018MonitorSts(); - - virtual Bool_t Init(); - - virtual Bool_t DoUnpack(const fles::Timeslice& ts, size_t component); - - virtual void Reset(); - - virtual void Finish(); - - void SetParContainers(); - - Bool_t InitContainers(); - - Bool_t ReInitContainers(); - - void FillOutput(boost::any); - - void SetRunStart( Int_t dateIn, Int_t timeIn, Int_t iBinSize = 5 ); - - void ResetAllHistos(); - void SaveAllHistos( TString sFileName = "" ); - - void SetMsOverlap(size_t uOverlapMsNb = 1) { fuOverlapMsNb = uOverlapMsNb; } - size_t GetMsOverlap() { return fuOverlapMsNb; } - - void SetPrintMessage( Bool_t bPrintMessOn = kTRUE, - stsxyter::MessagePrintMask ctrl = stsxyter::MessagePrintMask::msg_print_Hex | - stsxyter::MessagePrintMask::msg_print_Human ) - { fbPrintMessages = bPrintMessOn; fPrintMessCtrl = ctrl; } - void EnableChanHitDtPlot( Bool_t bEnable = kTRUE ) { fbChanHitDtEna = bEnable; } - void EnableDualStsMode( Bool_t bEnable = kTRUE ) { fbDualStsEna = bEnable; } - void SetLongDurationLimits( UInt_t uDurationSeconds = 3600, UInt_t uBinSize = 1 ); - - void SetStripsOffset1( Int_t iOffN, Int_t iOffP ) { fiStripsOffsetN1 = iOffN; fiStripsOffsetP1 = iOffP; } - void SetStripsOffset2( Int_t iOffN, Int_t iOffP ) { fiStripsOffsetN2 = iOffN; fiStripsOffsetP2 = iOffP; } - -private: - size_t fuOverlapMsNb; /** Ignore Overlap Ms: all fuOverlapMsNb MS at the end of timeslice **/ - - // Parameters - CbmCern2017UnpackParSts* fUnpackPar; //! - UInt_t fuNrOfDpbs; //! Total number of Sts DPBs in system - std::map<UInt_t, UInt_t> fDpbIdIndexMap; //! Map of DPB Identifier to DPB index - UInt_t fuNbElinksPerDpb; //! Number of possible eLinks per DPB - UInt_t fuNbStsXyters; //! Number of StsXyter ASICs - UInt_t fuNbChanPerAsic; //! Number of channels per StsXyter ASIC => should be constant somewhere!!!! - std::vector< std::vector< UInt_t > > fvuElinkToAsic; //! Vector holding for each link the corresponding ASIC index [fuNrOfDpbs * fuNbElinksPerDpb] - - // Constants - static const Int_t kiMaxNbFlibLinks = 16; - static const UInt_t kuBytesPerMessage = 4; - - // Internal Control/status of monitor - // Task configuration values - Bool_t fbPrintMessages; - stsxyter::MessagePrintMask fPrintMessCtrl; - Bool_t fbChanHitDtEna; - Bool_t fbDualStsEna; - // TS/MS info - ULong64_t fulCurrentTsIdx; - ULong64_t fulCurrentMsIdx; - // Current data properties - std::map< stsxyter::MessType, UInt_t > fmMsgCounter; - UInt_t fuCurrentEquipmentId; //! Current equipment ID, tells from which DPB the current MS is originating - UInt_t fuCurrDpbId; //! Temp holder until Current equipment ID is properly filled in MS - UInt_t fuCurrDpbIdx; //! Index of the DPB from which the MS currently unpacked is coming - Int_t fiRunStartDateTimeSec; //! Start of run time since "epoch" in s, for the plots with date as X axis - Int_t fiBinSizeDatePlots; //! Bin size in s for the plots with date as X axis -// std::vector< std::vector< UInt_t > > fvuCurrentTsMsb; //! Current TS MSB for each eLink - // Data format control - std::vector< ULong64_t > fvulCurrentTsMsb; //! Current TS MSB for each DPB - std::vector< UInt_t > fvuCurrentTsMsbCycle; //! Current TS MSB cycle for DPB - std::vector< UInt_t > fvuElinkLastTsHit; //! TS from last hit for DPB - // Hits comparison - std::vector< std::vector< ULong64_t > > fvulChanLastHitTime; //! Last hit time in bins for each Channel - std::vector< std::vector< Double_t > > fvdChanLastHitTime; //! Last hit time in ns for each Channel - std::vector< Double_t > fvdMsTime; //! Header time of each MS - std::vector< std::vector< std::vector< UInt_t > > > fvuChanNbHitsInMs; //! Number of hits in each MS for each Channel - std::vector< std::vector< std::vector< Double_t > > > fvdChanLastHitTimeInMs; //! Last hit time in bins in each MS for each Channel - std::vector< std::vector< std::vector< UShort_t > > > fvusChanLastHitAdcInMs; //! Last hit ADC in bins in each MS for each Channel -// std::vector< std::vector< std::multiset< stsxyter::FinalHit > > > fvmChanHitsInTs; //! All hits (time & ADC) in bins in last TS for each Channel - // Starting state book-keeping - Double_t fdStartTime; /** Time of first valid hit (TS_MSB available), used as reference for evolution plots**/ - Double_t fdStartTimeMsSz; /** Time of first microslice, used as reference for evolution plots**/ - std::chrono::steady_clock::time_point ftStartTimeUnix; /** Time of run Start from UNIX system, used as reference for long evolution plots against reception time **/ - - // Hits time-sorting - std::multiset< stsxyter::FinalHit > fvmHitsInTs; //! All hits (time in bins, ADC in bins, asic, channel) in last TS, sorted by multiset with "<" operator - stsxyter::FinalHit fLastSortedHit1N; //! Last sorted hit for STS 1 N - stsxyter::FinalHit fLastSortedHit1P; //! Last sorted hit for STS 1 P - stsxyter::FinalHit fLastSortedHit2N; //! Last sorted hit for STS 2 N - stsxyter::FinalHit fLastSortedHit2P; //! Last sorted hit for STS 2 P - // Coincidence histos - UInt_t fuMaxNbMicroslices; - - // Histograms - CbmHistManager* fHM; //! Histogram manager - TH1* fhStsMessType; - TH1* fhStsSysMessType; - TH2* fhStsMessTypePerDpb; - TH2* fhStsSysMessTypePerDpb; - TH2* fhStsDpbRawTsMsb; - TH2* fhStsDpbRawTsMsbSx; - TH2* fhStsDpbRawTsMsbDpb; - TH2* fhStsMessTypePerElink; - TH2* fhStsSysMessTypePerElink; - - std::vector<TH1*> fhStsChanCounts; - std::vector<TH2*> fhStsChanRawAdc; - std::vector<TProfile*> fhStsChanRawAdcProf; - std::vector<TH2*> fhStsChanRawTs; - std::vector<TH2*> fhStsChanMissEvt; - std::vector<TH2*> fhStsChanHitRateEvo; - std::vector<TH1*> fhStsXyterRateEvo; - std::vector<TH2*> fhStsChanHitRateEvoLong; - std::vector<TH1*> fhStsXyterRateEvoLong; - std::vector<TH2*> fhStsChanHitDt; - std::vector<TH2*> fhStsChanHitDtNeg; - std::vector<TH2*> fhStsChanHitsPerMs; - TH2* fhStsAsicTsMsb; - - Bool_t fbLongHistoEnable; - UInt_t fuLongHistoNbSeconds; - UInt_t fuLongHistoBinSizeSec; - UInt_t fuLongHistoBinNb; - std::vector<TH1*> fhFebRateEvoLong; - std::vector<TH2*> fhFebChRateEvoLong; -/* - std::vector<TH1*> fhFebRateEvoDate; -*/ - - // Coincidences in sorted hits - Double_t fdCoincBorder = 50.0; // ns, +/- - TH1 * fhStsSortedDtN1P1; - TH1 * fhStsSortedDtN2P2; - TH1 * fhStsSortedDtN1N2; - TH1 * fhStsSortedDtP1P2; - TH1 * fhStsSortedDtN1P2; - TH1 * fhStsSortedDtP1N2; - TH2 * fhStsSortedMapN1P1; - TH2 * fhStsSortedMapN2P2; - TH2 * fhStsSortedMapN1N2; - TH2 * fhStsSortedMapP1P2; - TH2 * fhStsSortedMapN1P2; - TH2 * fhStsSortedMapP1N2; - TH1 * fhStsSortedCntEvoN1P1; - TH1 * fhStsSortedCntEvoN2P2; - TH1 * fhStsSortedCntEvoN1N2; - TH1 * fhStsSortedCntEvoP1P2; - TH1 * fhStsSortedCntEvoN1P2; - TH1 * fhStsSortedCntEvoP1N2; - - TH1 * fhStsSortedDtN1P1N2P2; - TH2 * fhStsSortedMapN1P1Coinc; - TH2 * fhStsSortedMapN2P2Coinc; - TH2 * fhStsSortedDtVsDiffN; - TH2 * fhStsSortedDtVsDiffP; - - const Double_t kdStereoAngle = 7.5; // [Deg] - Double_t fdStereoAngleTan; - const Double_t kdPitchMm = 0.058; // [mm] - const Int_t kiNbStrips = 1024; - const Double_t kdSensorsSzX = 60; // [mm], active is 59.570 mm (kiNbStrips*kdPitchMm) - const Double_t kdSensorsSzY = 40; // [mm], active is 39.703 mm - Int_t fiStripsOffsetN1; // of channel 0 relative to center strip - Int_t fiStripsOffsetP1; // of channel 0 relative to center strip - Int_t fiStripsOffsetN2; // of channel 0 relative to center strip - Int_t fiStripsOffsetP2; // of channel 0 relative to center strip - TH2 * fhStsSortedMapX1Y1; - TH2 * fhStsSortedMapX2Y2; - TH2 * fhStsSortedMapX1Y1Coinc; - TH2 * fhStsSortedMapX2Y2Coinc; - - TCanvas* fcMsSizeAll; - TH1* fhMsSz[kiMaxNbFlibLinks]; - TProfile* fhMsSzTime[kiMaxNbFlibLinks]; - - void CreateHistograms(); - - void FillHitInfo( stsxyter::Message mess, const UShort_t & usElinkIdx, const UInt_t & uAsicIdx, const UInt_t & uMsIdx ); - void FillTsMsbInfo( stsxyter::Message mess, UInt_t uMessIdx = 0, UInt_t uMsIdx = 0); - void FillEpochInfo( stsxyter::Message mess ); - - void ComputeCoordinatesSensor1( Int_t iChanN, Int_t iChanP, Double_t & dPosX, Double_t & dPosY ); - void ComputeCoordinatesSensor2( Int_t iChanN, Int_t iChanP, Double_t & dPosX, Double_t & dPosY ); - - CbmCosy2018MonitorSts(const CbmCosy2018MonitorSts&); - CbmCosy2018MonitorSts operator=(const CbmCosy2018MonitorSts&); - - ClassDef(CbmCosy2018MonitorSts, 1) -}; - -#endif // CBMCOSY2018MONITORSTS_H diff --git a/beamtime/data/CMakeLists.txt b/beamtime/data/CMakeLists.txt deleted file mode 100644 index 4948042b51160e3bee0ecc550a762a7572a9b95f..0000000000000000000000000000000000000000 --- a/beamtime/data/CMakeLists.txt +++ /dev/null @@ -1,64 +0,0 @@ -# Create a library called "libCbmBeamtime" which includes the source files given in -# the array . -# The extension is already found. Any number of sources could be listed here. - -Set(INCLUDE_DIRECTORIES - ${CBMDATA_DIR} - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/fhodo - ${CMAKE_CURRENT_SOURCE_DIR}/raw -) - - -Set(SYSTEM_INCLUDE_DIRECTORIES - ${BASE_INCLUDE_DIRECTORIES} - ${Boost_INCLUDE_DIR} -) - -Include_Directories( - ${INCLUDE_DIRECTORIES} -) - -Include_Directories( - SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES} -) - -Set(LINK_DIRECTORIES - ${ROOT_LIBRARY_DIR} - ${Boost_LIBRARY_DIRS} - ${FAIRROOT_LIBRARY_DIR} -) - -Link_Directories( - ${LINK_DIRECTORIES} -) - -Set(SRCS - CbmAuxDigi.cxx - CbmTbEvent.cxx - - fhodo/CbmFiberHodoDigi.cxx - fhodo/CbmFiberHodoCluster.cxx - fhodo/CbmFiberHodoAddress.cxx - - raw/CbmRawMessage.cxx - raw/CbmSpadicRawMessage.cxx - raw/CbmTrdRawMessage.cxx - raw/CbmNxyterRawMessage.cxx - raw/CbmNxyterRawSyncMessage.cxx - raw/CbmStsxyterRawHitMessage.cxx - raw/CbmTrbRawMessage.cxx -) - -Set(NO_DICT_SRCS - raw/rocMess_wGet4v1.cxx - CbmTofStarData.cxx -) - -Set(LINKDEF CbmBeamtimeDataLinkDef.h) -Set(LIBRARY_NAME CbmBeamtimeData) -Set(DEPENDENCIES -CbmData -) - -GENERATE_LIBRARY() diff --git a/beamtime/data/CbmAuxDigi.cxx b/beamtime/data/CbmAuxDigi.cxx deleted file mode 100644 index 7e86c2e4079a212f94f7e0799b14a0ca48b9e497..0000000000000000000000000000000000000000 --- a/beamtime/data/CbmAuxDigi.cxx +++ /dev/null @@ -1,25 +0,0 @@ -/** @file CbmAuxDigi.cxx - ** @author Volker Friese <v.friese@gsi.de> - ** @date 12.02.2014 - **/ - -#include "CbmAuxDigi.h" - - -// --- Default constructor ------------------------------------------------ -CbmAuxDigi::CbmAuxDigi() - : fRocId(0), fChannel(0), fTime(0) { -} -// -------------------------------------------------------------------------- - - - -// --- Standard constructor ----------------------------------------------- -CbmAuxDigi::CbmAuxDigi(UShort_t rocId, UShort_t channel, ULong64_t time) - : fRocId(rocId), fChannel(channel), fTime(time) { -} -// -------------------------------------------------------------------------- - - -ClassImp(CbmAuxDigi) - diff --git a/beamtime/data/CbmAuxDigi.h b/beamtime/data/CbmAuxDigi.h deleted file mode 100644 index cdfb6c0a4473e0374c9a88266d83c34f3613721f..0000000000000000000000000000000000000000 --- a/beamtime/data/CbmAuxDigi.h +++ /dev/null @@ -1,71 +0,0 @@ -/** @file CbmAuxDigi.h - ** @author Volker Friese <v.friese@gsi.de> - ** @date 12.02.2014 - **/ - -#ifndef CBMAUXDIGI_H -#define CBMAUXDIGI_H - -#include <Rtypes.h> -#include <RtypesCore.h> - -#include "CbmDefs.h" - -/** @class CbmAuxDigi - ** @brief Data class for data from AUX channels in ROCs - ** @author V.Friese <v.friese@gsi.de> - ** @version 1.0 - **/ -class CbmAuxDigi { - - public: - - /** Default constructor **/ - CbmAuxDigi(); - - - /** Standard constructor **/ - CbmAuxDigi(UShort_t rocId, UShort_t channel, ULong64_t time); - - - /** Destructor **/ - ~CbmAuxDigi() { }; - - - /** Get Address (dummy) - ** Abstract method from CbmDigi. Must be implemented in order to - ** treat AUX like digis, but does not have any meaning here. - **/ - Int_t GetAddress() const { return -1; } - - - /** Channel number **/ - UShort_t GetChannel() const { return fChannel; } - - - /** ROC number **/ - UShort_t GetRocId() const { return fRocId; } - - - /** System ID - ** Hardcoded to 999. Did not want to introduce a new item - ** in enum DetectorId. - **/ - static ECbmModuleId GetSystem() { return static_cast<ECbmModuleId>(999);} - - - /** Time [ns] **/ - Double_t GetTime() const { return Double_t(fTime); } - - std::string ToString() const { return std::string{""}; } - private: - - UShort_t fRocId; ///< ROC number - UShort_t fChannel; ///< AUX channel number (0 - 3) - ULong64_t fTime; ///< Time [ns] - - ClassDefNV(CbmAuxDigi, 2); -}; - - -#endif /* CBMAUXDIGI_H */ diff --git a/beamtime/data/CbmBeamtimeDataLinkDef.h b/beamtime/data/CbmBeamtimeDataLinkDef.h deleted file mode 100644 index ea19bb51f10c8e6dd65849d33eba5ee50ffc03c6..0000000000000000000000000000000000000000 --- a/beamtime/data/CbmBeamtimeDataLinkDef.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifdef __CINT__ - -#pragma link off all globals; -#pragma link off all classes; -#pragma link off all functions; - -#pragma link C++ class CbmAuxDigi; -#pragma link C++ class CbmTbEvent; - -#pragma link C++ class CbmFiberHodoDigi; -#pragma link C++ class CbmFiberHodoCluster; -#pragma link C++ class CbmFiberHodoAddress; - -#pragma link C++ class CbmRawMessage; -#pragma link C++ class CbmSpadicRawMessage; -#pragma link C++ class CbmTrdRawMessage; -#pragma link C++ class CbmNxyterRawMessage; -#pragma link C++ class CbmNxyterRawSyncMessage; -#pragma link C++ class CbmStsxyterRawHitMessage; -#pragma link C++ class CbmTrbRawMessage; - -#endif diff --git a/beamtime/data/CbmTbEvent.cxx b/beamtime/data/CbmTbEvent.cxx deleted file mode 100644 index 18b62272c6d7d6f79cd0c1f694b413af602fc489..0000000000000000000000000000000000000000 --- a/beamtime/data/CbmTbEvent.cxx +++ /dev/null @@ -1,75 +0,0 @@ -/**@file CbmTbEvent.cxx - **@date 26.06.2009 - **@author V. Friese <v.friese@gsi.de> - **/ - - -#include "CbmTbEvent.h" -#include "CbmModuleList.h" - -#include "FairLogger.h" - -#include <iomanip> - -using std::fixed; -using std::setprecision; - -// ----- Constructor ------------------------------------------------------ -CbmTbEvent::CbmTbEvent() - : FairEventHeader(), - fTimeStart(0.), - fTimeStop(0.), - fEpochTime(0.), - fNofData(0), - fTimeBc(), - fNofDigis(), - fNofAux(0), - fEventType(0), - fTimeSum(0.) -{ - Clear(); -} -// --------------------------------------------------------------------------- - -// ----- Reset event ----------------------------------------------------- -void CbmTbEvent::Clear(Option_t*) { - fEventTime = 0.; - fTimeStart = 0.; - fTimeStop = 0.; - fEpochTime = 0.; - fNofData = 0; - fNofAux = 0; - for (ECbmModuleId iSys = ECbmModuleId::kRef; iSys < ECbmModuleId::kNofSystems; ++iSys) - fNofDigis[iSys] = 0; - fTimeBc.clear(); - fEventType = 0; - fTimeSum = 0.; - -} -// --------------------------------------------------------------------------- - -// ----- Print ----------------------------------------------------------- -void CbmTbEvent::Print(Option_t* /*opt*/) const { - - std::stringstream ss; - ss << "Cbm Testbeam Event: " << setprecision(9) << fixed << "Event time " - << fEventTime << " s, duration " << setprecision(0) << GetDuration() - << " ns, Beam " << fTimeBc.size(); - for (ECbmModuleId iSys = ECbmModuleId::kRef; iSys < ECbmModuleId::kNofSystems; ++iSys) { - if ( fNofDigis.at(iSys) ) { - TString systemName = CbmModuleList::GetModuleNameCaps(iSys); - ss << ", " << systemName << " " << fNofDigis.at(iSys); - } - } - LOG(info) << ss.str() << ", AUX " << fNofAux; -} -// --------------------------------------------------------------------------- - -ClassImp(CbmTbEvent) - - - - - - - diff --git a/beamtime/data/CbmTbEvent.h b/beamtime/data/CbmTbEvent.h deleted file mode 100644 index 3b921fbbd79c291e2a031fc5070524a6bac110b1..0000000000000000000000000000000000000000 --- a/beamtime/data/CbmTbEvent.h +++ /dev/null @@ -1,137 +0,0 @@ -/**@file CbmTbEvent.h - **@date 26.06.2009 - **author V. Friese <v.friese@gsi.de> - ** - **Event header file for test beam data AUG09 - **Setup: 3 STS + GEM (MUCH) + RICH, 2 beam counters - ** - **/ - - -#ifndef CBMTBEVENT_H -#define CBMTBEVENT_H 1 - - -#include <Rtypes.h> -#include <RtypesCore.h> - -#include "CbmDefs.h" - -#include <FairEventHeader.h> -#include <FairLogger.h> - -#include <vector> -#include <utility> - -class CbmTbEvent : public FairEventHeader -{ - - public: - - /** Default constructor **/ - CbmTbEvent(); - - - /** Destructor (no action) **/ - virtual ~CbmTbEvent() { } - - - /** Accessors **/ - Double_t GetTime() const { return fEventTime; } - Double_t GetTimeStart() const { return fTimeStart; } - Double_t GetTimeStop() const { return fTimeStop; } - Double_t GetDuration() const { return fTimeStop - fTimeStart; } - Double_t GetEpochTime() const { return fEpochTime; } - Int_t GetNofAux() const { return fNofAux; } - Int_t GetNofData () const { return fNofData; } - Int_t GetNofDigis(ECbmModuleId systemId) const { return fNofDigis.at(systemId); } - Int_t GetNofBeam() const { return fTimeBc.size(); } - Double_t GetTimeBc() const { - return (fTimeBc.empty() ? 0. : fTimeBc[0]); } - Double_t GetTimeBc(UInt_t iBc) const { - return (fTimeBc.size() > iBc ? fTimeBc[iBc] : 0.); } - Int_t GetEventType() const { return fEventType; } - - void SetEventType(Int_t type) { fEventType = type; } - - /** Add a digi of type Digi to the event **/ - template <class Digi> - void AddDigi(Digi* digi) - { - Double_t digiTime = digi->GetTime(); - ECbmModuleId systemID = digi->GetSystem(); - - // --- Set event start and stop times for empty event. - if ( IsEmpty() ) { - fTimeStart = digiTime; - fTimeStop = digiTime; - } - - // --- For non-empty events: check time ordering - else { - if ( digiTime < fTimeStop ) { - LOG(fatal) << GetName() << ": time disorder. Event stop is " - << fTimeStop << ", digi time is " << digiTime; - return; - } - } - - // --- Set event stop time - fTimeStop = digiTime; - - // --- Calculate average event time - fNofData++; - fTimeSum += digiTime; - fEventTime = fTimeSum / Double_t(fNofData); - - // --- Increase digi counter - if ( systemID == static_cast<ECbmModuleId>(999) ) fNofAux++; - else fNofDigis[systemID]++; - - return; - } - - - /** Check for beam signal **/ - Bool_t IsBeam() const { return ( ! fTimeBc.empty() ); } - - - /** Check for good beam (only one beam counter signal) **/ - Bool_t IsGoodBeam() const { return ( fTimeBc.size() == 1 ); } - - - /** Check for empty event **/ - Bool_t IsEmpty() const { return (fNofData==0 ? kTRUE : kFALSE); } - - - /** Clear event **/ - void Clear(Option_t* = ""); - - - /** Print event **/ - virtual void Print(Option_t* opt = "") const; - - - - private: - - //Double_t fTime; /** Absolute event time [ns] **/ - Double_t fTimeStart; /** Time of first digi in event [ns] **/ - Double_t fTimeStop; /** Time of last digi in event [ns] **/ - Double_t fEpochTime; /** Time of epoch marker [ns] **/ - Int_t fNofData; ///< Total number of digis in event - std::vector<Double_t> fTimeBc; /** Time Of Beam Counter messages **/ - std::map<ECbmModuleId, Int_t> fNofDigis; ///< Number of digis per detector system -// Int_t fNofDigis[ToIntegralType(ECbmModuleId::kNofSystems)]; ///< Number of digis per detector system - Int_t fNofAux; ///< Number of AUX signals in event - Int_t fEventType; ///< Type of event 0=normal event,1=baseline - - Double_t fTimeSum; //! Transient. For calculation of tmean. - - ClassDef(CbmTbEvent,3); - -}; - - - -#endif diff --git a/beamtime/data/CbmTofStarData.cxx b/beamtime/data/CbmTofStarData.cxx deleted file mode 100644 index 4f5a12d7b4c66f290918f49ec62ff1d8e3a7bc65..0000000000000000000000000000000000000000 --- a/beamtime/data/CbmTofStarData.cxx +++ /dev/null @@ -1,161 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmTofStarData ----- -// ----- Created 13.01.2017 by P.-A. Loizeau ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#include "CbmTofStarData.h" - -#include <algorithm> - -/********************** CbmTofStarTrigger *****************************/ -CbmTofStarTrigger::CbmTofStarTrigger( ULong64_t ulGdpbTsFullIn, ULong64_t ulStarTsFullIn, - UInt_t uStarTokenIn, UInt_t uStarDaqCmdIn, - UInt_t uStarTrigCmdIn ) : - fulGdpbTsFull( ulGdpbTsFullIn ), - fulStarTsFull( ulStarTsFullIn ), - fuStarToken( uStarTokenIn ), - fusStarDaqCmd( uStarDaqCmdIn) , - fusStarTrigCmd( uStarTrigCmdIn ) -{ -} -//! strict weak ordering operator, assumes same TS cycle for both triggers -bool CbmTofStarTrigger::operator<(const CbmTofStarTrigger& other) const -{ - ULong64_t uThisTs = this->GetFullGdpbTs(); - ULong64_t uOtherTs = other.GetFullGdpbTs(); - - return uThisTs < uOtherTs; -} -UInt_t CbmTofStarTrigger::GetStarTrigerWord() const -{ - // trg_cmd|daq_cmd|tkn_hi|tkn_mid|tkn_lo - UInt_t uTrigWord = ( (fusStarTrigCmd & 0x00F) << 16 ) - + ( (fusStarDaqCmd & 0x00F) << 12 ) - + ( (fuStarToken & 0xFFF) ); - return uTrigWord; -} -UInt_t CbmTofStarTrigger::GetFullGdpbEpoch() const -{ - // trg_cmd|daq_cmd|tkn_hi|tkn_mid|tkn_lo - UInt_t uEpochIndex = (fulGdpbTsFull >> get4v1x::kuCtSize) - & get4v1x::kuEpochCounterSz; - return uEpochIndex; -} -//ClassImp(CbmTofStarTrigger) -/**********************************************************************/ -/********************** CbmTofStarSubevent ****************************/ -CbmTofStarSubevent::CbmTofStarSubevent() : - fbTriggerSet( kFALSE ), - fTrigger( CbmTofStarTrigger( 0, 0, 0, 0, 0) ), - fulEventStatusFlags( 0 ), - fvMsgBuffer() -{ -} -CbmTofStarSubevent::CbmTofStarSubevent( CbmTofStarTrigger triggerIn ) : - fbTriggerSet( kTRUE ), - fTrigger( triggerIn ), - fulEventStatusFlags( 0 ), - fvMsgBuffer() -{ -} -CbmTofStarSubevent::~CbmTofStarSubevent() -{ - ClearSubEvent(); -} -void CbmTofStarSubevent::ClearSubEvent() -{ - fbTriggerSet = kFALSE; - fulEventStatusFlags = 0; - fvMsgBuffer.clear(); -} -void * CbmTofStarSubevent::BuildOutput( Int_t & iOutputSizeBytes ) -{ - // If trigger not set, something is wrong, we just pass - if( kFALSE == fbTriggerSet ) - { - iOutputSizeBytes = 0; - return NULL; - } // if( kFALSE == fbTriggerSet ) - - iOutputSizeBytes = 0; - - // Size of output is - // 3 * Long64 for Header Star Token Info - // 1 * Long64 for Header Event Status Flags (version, bad/good, ...) - // n * Long64 for the n messages in Buffer: 1 Epoch + messages + 1 extra epoch in-between if needed - iOutputSizeBytes = 4 + fvMsgBuffer.size(); - iOutputSizeBytes *= sizeof( ULong64_t ); - UInt_t uMsgsToRead = fvMsgBuffer.size(); - - // Check if max size passed - // If it is the case, limit the number of data read + set Bad Event flag - if( kuMaxOutputSize < static_cast<uint32_t>(iOutputSizeBytes) ) - { - iOutputSizeBytes = kuMaxOutputSize; - uMsgsToRead = kuMaxNbMsgs; - fulEventStatusFlags |= kulFlagBadEvt; - } // if( kuMaxOutputSize < iOutputSizeBytes ) - - // Fills header info - fpulBuff[0] = fTrigger.GetFullGdpbTs(); - fpulBuff[1] = fTrigger.GetFullStarTs(); - fpulBuff[2] = (static_cast< ULong64_t >( fTrigger.GetStarToken() ) << 32) - + (static_cast< ULong64_t >( fTrigger.GetStarDaqCmd() ) << 16) - + (static_cast< ULong64_t >( fTrigger.GetStarTrigCmd() ) ); - fpulBuff[3] = fulEventStatusFlags; - - // does not work due to "error: cannot convert ‘ngdpb::Message’ to ‘long unsigned int’ in assignment" -// std::copy( fvMsgBuffer.begin(), fvMsgBuffer.begin() + uMsgsToRead, pulBuff + 4 ); - - // Unoptimized replacement: item by item copy - for( UInt_t uMsgIdx = 0; uMsgIdx < uMsgsToRead; uMsgIdx++) - fpulBuff[4 + uMsgIdx] = fvMsgBuffer[uMsgIdx].getData(); - - return static_cast< void * >( fpulBuff ); -} -Bool_t CbmTofStarSubevent::LoadInput( void * pBuff, Int_t iInputSizeBytes ) -{ - // Check input variables are properly defined - if( NULL == pBuff || 0 == iInputSizeBytes) - return kFALSE; - - Int_t iRestBytes = iInputSizeBytes % sizeof( ULong64_t ); - Int_t iInputSzLg = iInputSizeBytes / sizeof( ULong64_t ); - - - // Check event header is complete and buffer is multiple of 64b - if( iInputSzLg < 4 || 0 < iRestBytes ) - return kFALSE; - - // First clear subEvent content - ClearSubEvent(); - - // Read the header to the SubEvent members - ULong64_t * pulLongBuff = static_cast< ULong64_t * >(pBuff); - ULong64_t ulTrgGdpbFullTs = pulLongBuff[0]; - ULong64_t ulTrgStarFullTs = pulLongBuff[1]; - UInt_t uStarToken = (pulLongBuff[2] >> 32) & 0xFFF; - UInt_t uStarDaqCmdIn = (pulLongBuff[2] >> 16) & 0x00F; - UInt_t uStarTrigCmdIn = (pulLongBuff[2] ) & 0x00F; - fulEventStatusFlags = pulLongBuff[3]; - - fTrigger.SetFullGdpbTs( ulTrgGdpbFullTs ); - fTrigger.SetFullStarTs( ulTrgStarFullTs ); - fTrigger.SetStarToken( uStarToken ); - fTrigger.SetStarDaqCmd( uStarDaqCmdIn ); - fTrigger.SetStarTRigCmd(uStarTrigCmdIn ); - - // Read as many messages as left in the buffer and store them in the vector - UInt_t uMsgsToRead = iInputSzLg - 4; - for( UInt_t uMsgIdx = 0; uMsgIdx < uMsgsToRead; uMsgIdx++) - { - ngdpb::Message mess( pulLongBuff[4 + uMsgIdx] ); - fvMsgBuffer.push_back( mess ); - } // for( UInt_t uMsgIdx = 0; uMsgIdx < uMsgsToRead; uMsgIdx++) - - return kTRUE; -} -//ClassImp(CbmTofStarTrigger) -/**********************************************************************/ diff --git a/beamtime/data/CbmTofStarData.h b/beamtime/data/CbmTofStarData.h deleted file mode 100644 index c3d1350e4b3978e651c6d3a0e85f3276e03acc08..0000000000000000000000000000000000000000 --- a/beamtime/data/CbmTofStarData.h +++ /dev/null @@ -1,123 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmTofStarData ----- -// ----- Created 13.01.2017 by P.-A. Loizeau ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CbmTofStarData_H -#define CbmTofStarData_H - -#include "rocMess_wGet4v1.h" - -#include "Rtypes.h" - -#include <vector> - -class CbmTofStarTrigger -{ - // Methods implementation can be found at the end of CbmTsMonitorTofStar.cxx! - public: - // Constructors - CbmTofStarTrigger( ULong64_t ulGdpbTsFullIn, ULong64_t ulStarTsFullIn, - UInt_t uStarTokenIn, UInt_t uStarDaqCmdIn, - UInt_t uStarTrigCmdIn ); - - // Destructor - ~CbmTofStarTrigger() {}; - - // Setters - inline void SetFullGdpbTs( ULong64_t ulGdpbTsFullIn ){ fulGdpbTsFull = ulGdpbTsFullIn; } - inline void SetFullStarTs( ULong64_t ulStarTsFullIn ){ fulStarTsFull = ulStarTsFullIn; } - inline void SetStarToken( UInt_t uStarTokenIn ){ fuStarToken = uStarTokenIn; } - inline void SetStarDaqCmd( UInt_t uStarDaqCmdIn ){ fusStarDaqCmd = uStarDaqCmdIn; } - inline void SetStarTRigCmd(UInt_t uStarTrigCmdIn ){ fusStarTrigCmd = uStarTrigCmdIn; } - - // Accessors - inline ULong64_t GetFullGdpbTs() const { return fulGdpbTsFull;} - inline ULong64_t GetFullStarTs() const { return fulStarTsFull;} - inline UInt_t GetStarToken() const { return fuStarToken;} - inline UShort_t GetStarDaqCmd() const { return fusStarDaqCmd;} - inline UShort_t GetStarTrigCmd() const { return fusStarTrigCmd;} - UInt_t GetStarTrigerWord() const; - UInt_t GetFullGdpbEpoch() const; - - // Operators - bool operator<(const CbmTofStarTrigger& other) const; - - private: - ULong64_t fulGdpbTsFull; - ULong64_t fulStarTsFull; - UInt_t fuStarToken; - UShort_t fusStarDaqCmd; - UShort_t fusStarTrigCmd; - -// CbmTofStarTrigger(const CbmTofStarTrigger&); -// CbmTofStarTrigger operator=(const CbmTofStarTrigger&); - -// ClassDef(CbmTofStarTrigger, 1) -}; - -class CbmTofStarSubevent -{ - // Methods implementation can be found at the end of CbmTsMonitorTofStar.cxx! - public: - // Constructors - CbmTofStarSubevent(); - CbmTofStarSubevent( CbmTofStarTrigger triggerIn ); - - // Destructor - ~CbmTofStarSubevent(); - - // Setters - inline void SetTrigger( CbmTofStarTrigger triggerIn ){ fTrigger = triggerIn; fbTriggerSet = kTRUE; } - inline void SetBadEventFlag( Bool_t bFlagState = kTRUE ){ - bFlagState ? (fulEventStatusFlags |= kulFlagBadEvt) : - (fulEventStatusFlags &= ~(kulFlagBadEvt) ); } - inline void SetOverlapEventFlag( Bool_t bFlagState = kTRUE ){ - bFlagState ? (fulEventStatusFlags |= kulFlagOverlapEvt) : - (fulEventStatusFlags &= ~(kulFlagOverlapEvt) ); } - inline void SetEmptyEventFlag( Bool_t bFlagState = kTRUE ){ - bFlagState ? (fulEventStatusFlags |= kulFlagEmptyEvt) : - (fulEventStatusFlags &= ~(kulFlagEmptyEvt) ); } - inline void AddMsg( ngdpb::Message & msgIn){ fvMsgBuffer.push_back( msgIn ); } - - // Accessors - inline CbmTofStarTrigger GetTrigger() const { return fTrigger;} - inline Bool_t GetBadEventFlag() const { return (fulEventStatusFlags & kulFlagBadEvt); } - inline Bool_t GetOverlapEventFlag() const { return (fulEventStatusFlags & kulFlagOverlapEvt); } - inline Bool_t GetEmptyEventFlag() const { return (fulEventStatusFlags & kulFlagEmptyEvt); } - inline ngdpb::Message GetMsg( UInt_t uMsgIdx ) const; - inline UInt_t GetMsgBuffSize() const { return fvMsgBuffer.size();} - inline static uint32_t GetMaxOutputSize() { return kuMaxOutputSize;} - - // Content clearing - void ClearSubEvent(); - - // Sub-event output - void * BuildOutput( Int_t & iOutputSizeBytes ); - - // Sub-event input - Bool_t LoadInput( void * pBuff, Int_t iInputSizeBytes ); - - private: - static const uint32_t kuMaxOutputSize = 131072; // 2^17 - static const uint32_t kuMaxNbMsgs = 16380; // 4 * 64b in header => floor( (2^17 / 8 ) - 4) - static const uint64_t kulFlagBadEvt = 0x1 << 0; - static const uint64_t kulFlagOverlapEvt = 0x1 << 1; - static const uint64_t kulFlagEmptyEvt = 0x1 << 2; - - Bool_t fbTriggerSet; - CbmTofStarTrigger fTrigger; - ULong64_t fulEventStatusFlags; - std::vector< ngdpb::Message > fvMsgBuffer; - ULong64_t fpulBuff[kuMaxOutputSize]; - - - CbmTofStarSubevent(const CbmTofStarSubevent&); - CbmTofStarSubevent operator=(const CbmTofStarSubevent&); - -// ClassDef(CbmTofStarSubevent, 1) -}; - -#endif diff --git a/beamtime/data/fhodo/CbmFiberHodoAddress.cxx b/beamtime/data/fhodo/CbmFiberHodoAddress.cxx deleted file mode 100644 index c0a538ffd6064c8a5c89a4354f5e147473ce94f2..0000000000000000000000000000000000000000 --- a/beamtime/data/fhodo/CbmFiberHodoAddress.cxx +++ /dev/null @@ -1,6 +0,0 @@ -/** - * \file CbmFiberHodoAddress.cxx - * \author F. Uhlig <f.uhlig@gsi.de> - * \date 11.12.13 - **/ -#include "CbmFiberHodoAddress.h" diff --git a/beamtime/data/fhodo/CbmFiberHodoAddress.h b/beamtime/data/fhodo/CbmFiberHodoAddress.h deleted file mode 100644 index 88576daced9c7363e67b2bdaa412578b4aedd32f..0000000000000000000000000000000000000000 --- a/beamtime/data/fhodo/CbmFiberHodoAddress.h +++ /dev/null @@ -1,110 +0,0 @@ -/** - * \file CbmFiberHodoAddress.h - * \author F. Uhlig <f.uhlig@gsi.de> - * \date 11.12.13 - * \brief Helper class to convert unique channel ID back and forth. - * - * 3 2 1 shift length - * Current definition: 10987654321098765432109876543210 - * System ID (kFHODO=10) on bits 0-3 00000000000000000000000000001111 <<0 15 - * Station ID on bits 4-7 00000000000000000000000011110000 <<4 15 - * Side ID on bits 8-8 00000000000000000000000100000000 <<8 1 - * Strip ID on bits 9-14 00000000000000000111111000000000 <<9 63 - * - **/ - -#ifndef CBMFIBERHODODETECTORID_H -#define CBMFIBERHODODETECTORID_H 1 - -#include "CbmDefs.h" -#include <cassert> - -class CbmFiberHodoAddress -{ -public: - - /** - * \brief Return address from system ID, side and strip IDs. - * \param[in] stationId Station ID. - * \param[in] sideId Layer ID. - * \param[in] stripId Strip ID. - * \return Address from system ID, side and strip IDs. - **/ - static Int_t GetAddress(Int_t stationId, - Int_t sideId, - Int_t stripId) - { - assert(!(stationId < 0 || stationId > fgkStationIdLength - || sideId < 0 || sideId > fgkSideIdLength - || stripId < 0 || stripId > fgkStripIdLength)); - return (ToIntegralType(ECbmModuleId::kHodo) << fgkSystemIdShift) | (stationId << fgkStationIdShift) - | (sideId << fgkSideIdShift) | (stripId << fgkStripIdShift); - } - - /** - * \brief Return System identifier from address. - * \param[in] address Unique channel address. - * \return System identifier from address. - **/ - static Int_t GetSystemId(Int_t address) { - return (address & (fgkSystemIdLength << fgkSystemIdShift)) >> fgkSystemIdShift; - } - - /** - * \brief Return station ID from address. - * \param[in] address Unique channel address. - * \return Station ID from address. - **/ - static Int_t GetStationId(Int_t address) { - return (address & (fgkStationIdLength << fgkStationIdShift)) >> fgkStationIdShift; - } - - /** - * \brief Return side ID from address. - * \param[in] address Unique channel address. - * \return Layer ID from address. - **/ - static Int_t GetSideId(Int_t address) { - return (address & (fgkSideIdLength << fgkSideIdShift)) >> fgkSideIdShift; - } - - /** - * \brief Return strip ID from address. - * \param[in] address Unique channel address. - * \return Strip ID from address. - **/ - static Int_t GetStripId(Int_t address) { - return (address & (fgkStripIdLength << fgkStripIdShift)) >> fgkStripIdShift; - } - - /** - * \brief Return layer address from address. - * \param[in] address Unique channel address. - * \return layer address from address. - **/ - static Int_t GetLayerAddress(Int_t address) { - return (address & (fgkLayerAddressLength << fgkLayerAddressStart)) >> fgkLayerAddressStart; - } - - - -private: - - // Length of the index of the corresponding volume - static const Int_t fgkSystemIdLength = 15; // 2^4 - 1 - static const Int_t fgkStationIdLength = 15; // 2^4 - 1 - static const Int_t fgkSideIdLength = 1; // 2^1 - 1 - static const Int_t fgkStripIdLength = 63; // 2^6 - 1 - // Number of a start bit for each volume - static const Int_t fgkSystemIdShift = 0; - static const Int_t fgkStationIdShift = 4; - static const Int_t fgkSideIdShift = 8; - static const Int_t fgkStripIdShift = 9; - // Start bit and length for unique layer address. - // For unique layer address use all from station and side ID. - static const Int_t fgkLayerAddressStart = 4; - static const Int_t fgkLayerAddressLength = 31; // 2^5 - 1 - -}; - -#endif diff --git a/beamtime/data/fhodo/CbmFiberHodoCluster.cxx b/beamtime/data/fhodo/CbmFiberHodoCluster.cxx deleted file mode 100644 index 82f1aebe0c5eeae7da5319aaa5a3cf4a0b4ffd85..0000000000000000000000000000000000000000 --- a/beamtime/data/fhodo/CbmFiberHodoCluster.cxx +++ /dev/null @@ -1,20 +0,0 @@ -/** - * \file CbmFiberHodoCluster.cxx - * \author Florian Uhlig <f.uhlig@gsi.de> - * \brief Data Container for TRD clusters. - */ -#include "CbmFiberHodoCluster.h" - -CbmFiberHodoCluster::CbmFiberHodoCluster() - : CbmCluster() - , fTime(0.) - , fMean(0.) - , fMeanError(0.) - , fCharge(0.) -{ -} - - CbmFiberHodoCluster::~CbmFiberHodoCluster(){ -} - -ClassImp(CbmFiberHodoCluster) diff --git a/beamtime/data/fhodo/CbmFiberHodoCluster.h b/beamtime/data/fhodo/CbmFiberHodoCluster.h deleted file mode 100644 index 3f6d06d70502b56c6bd7bf26c973d61b5ffccf50..0000000000000000000000000000000000000000 --- a/beamtime/data/fhodo/CbmFiberHodoCluster.h +++ /dev/null @@ -1,75 +0,0 @@ -/** - * \file CbmFiberHodoCluster.h - * \author Florian Uhlig <f.uhlig@gsi.de> - * \brief Data Container for TRD clusters. - **/ - -#ifndef CBMFIBERHODOCLUSTER_H -#define CBMFIBERHODOCLUSTER_H - -#include "CbmCluster.h" - -class CbmFiberHodoCluster : public CbmCluster -{ -public: - - /** - * \brief Default constructor. - */ - CbmFiberHodoCluster(); - CbmFiberHodoCluster(Int_t index) - : CbmCluster() - , fTime(0.) - , fMean(0.) - , fMeanError(0.) - , fCharge(0.) - {AddDigi(index);} - - /** - * \brief Destructor. - */ - virtual ~CbmFiberHodoCluster(); - - void SetTime(Double_t time) - { - fTime = time; - } - void SetMean(Double_t mean) - { - fMean = mean; - } - void SetMeanError(Double_t meanError) - { - fMeanError = meanError; - } - Double_t GetTime() const - { - return fTime; - } - Double_t GetMean() const - { - return fMean; - } - Double_t GetMeanError() const - { - return fMeanError; - } - - Double_t GetCharge() { return fCharge; } - - void SetCharge(Double_t charge) { fCharge = charge; } - - private: - CbmFiberHodoCluster(const CbmFiberHodoCluster&); - CbmFiberHodoCluster& operator=(const CbmFiberHodoCluster&); - - Double_t fTime; // FIXME: Modify clustering algorithm and remove this parameter. - Double_t fMean; // FIXME: Modify clustering algorithm and remove this parameter. - Double_t fMeanError; // FIXME: Modify clustering algorithm and remove this parameter. - Double_t fCharge; - - ClassDef(CbmFiberHodoCluster, 3) - - -}; -#endif diff --git a/beamtime/data/fhodo/CbmFiberHodoDigi.cxx b/beamtime/data/fhodo/CbmFiberHodoDigi.cxx deleted file mode 100644 index 260d30e67e59a25f79585e251de4d3bf6ade3a1b..0000000000000000000000000000000000000000 --- a/beamtime/data/fhodo/CbmFiberHodoDigi.cxx +++ /dev/null @@ -1,35 +0,0 @@ -#include "CbmFiberHodoDigi.h" - -#include <sstream> -using std::endl; -using std::stringstream; - -CbmFiberHodoDigi::CbmFiberHodoDigi() - : fAddress(-1), - fCharge(-1.), - fTime(0) -{ -} - -CbmFiberHodoDigi::CbmFiberHodoDigi( - Int_t address, - Double_t charge, - ULong_t time) - : fAddress(address), - fCharge(charge), - fTime(time) -{ -} - -CbmFiberHodoDigi::~CbmFiberHodoDigi() -{ -} - -std::string CbmFiberHodoDigi::ToString() const { - stringstream ss; - ss << "CbmFiberHodoDigi: address=" << fAddress << " charge=" << fCharge - << " time=" << fTime << endl; - return ss.str(); -} - -ClassImp(CbmFiberHodoDigi) diff --git a/beamtime/data/fhodo/CbmFiberHodoDigi.h b/beamtime/data/fhodo/CbmFiberHodoDigi.h deleted file mode 100644 index c851f6a94af18526bfc408d1482d0a19de60724b..0000000000000000000000000000000000000000 --- a/beamtime/data/fhodo/CbmFiberHodoDigi.h +++ /dev/null @@ -1,92 +0,0 @@ -/** CbmFiberHodoDigi.h -**@author F.Uhlig <f.uhlig@gsi.de> -**@since 11.12.13 -**@version 1.0 -** -** Data class for digital fibre hodoskop information -** This hodoskope is used during test beamtimes for -** generating a trigger and for beam position control -** Data level: RAW -** -** The information is encoded into 8 bytes (1 Long64_t). -** Address: 25 bits -** - Station Nr. 4 bits -** - Sector Nr. 10 bits -** - Side (front/back) 1 bit -** - Channel Nr. 10 bits -** Charge (ADC): 12 bits -** Time (ns): 14 bits -** -** The time is relative to the event time. -**/ - -#ifndef CBMFIBERHODODIGI_H -#define CBMFIBERHODODIGI_H 1 - -#include <Rtypes.h> // for ClassDefNV - -#include "CbmFiberHodoAddress.h" -#include "CbmDefs.h" - -#include <string> - -class CbmFiberHodoDigi -{ -public: - /** - * \brief Default constructor. - */ - CbmFiberHodoDigi(); - - /** - * \brief Constructor with assignment. - * \param[in] address Unique channel address. - * \param[in] charge Charge. - * \param[in] time Absolute time [ns]. - */ - CbmFiberHodoDigi(Int_t address, Double_t charge, ULong_t time); - - /** - * \brief Destructor. - */ - ~CbmFiberHodoDigi(); - - /** - * \brief Inherited from CbmDigi. - */ - Int_t GetAddress() const { return fAddress; }; - - /** - * \brief Inherited from CbmDigi. - */ - Double_t GetCharge() const { return fCharge; } - - /** - * \brief Inherited from CbmDigi. - */ - static ECbmModuleId GetSystem() { return ECbmModuleId::kHodo; } - - /** - * \brief Inherited from CbmDigi. - */ - Double_t GetTime() const { return Double_t(fTime); } - - /** Accessors **/ - void SetAddress(Int_t address) { fAddress = address; } - void SetCharge(Double_t charge) { fCharge = charge; } - void SetTime(ULong_t time) { fTime = time; } - - /** Modifiers **/ - void AddCharge(Double_t charge) { fCharge += charge; } - - std::string ToString() const; - -private: - Int_t fAddress; ///< Unique channel address - Double_t fCharge; ///< Charge - ULong_t fTime; ///< Absolute time [ns] - - ClassDefNV(CbmFiberHodoDigi, 4); -}; - -#endif diff --git a/beamtime/data/raw/CbmNxyterRawMessage.cxx b/beamtime/data/raw/CbmNxyterRawMessage.cxx deleted file mode 100644 index 5b9f4bb797ff8dacab69583dacb743cc2a89231c..0000000000000000000000000000000000000000 --- a/beamtime/data/raw/CbmNxyterRawMessage.cxx +++ /dev/null @@ -1,45 +0,0 @@ -#include "CbmNxyterRawMessage.h" - -// ----- Default constructor ------------------------------------------- -CbmNxyterRawMessage::CbmNxyterRawMessage() - : CbmRawMessage(), - fADCvalue(0), - fLastEpoch(kFALSE), - fPileUp(kFALSE), - fOverflow(kFALSE) -{ -} - -// ------ Constructor ----------------------------------------------------- -CbmNxyterRawMessage::CbmNxyterRawMessage(Int_t FlibLink, Int_t FebId, Int_t ChannelId, - Int_t EpochMarker, Int_t Time, - Int_t ADCval, Bool_t lastEpoch, Bool_t pileUp, Bool_t overflow) - - : CbmRawMessage(FlibLink, FebId, ChannelId, EpochMarker, Time), - fADCvalue(ADCval), - fLastEpoch(lastEpoch), - fPileUp(pileUp), - fOverflow(overflow) -{ -} - -// ------------------------------------------------------------------------- - -ULong_t CbmNxyterRawMessage::GetFullTime() { - - Int_t epoch; - if (fLastEpoch) { - epoch = fEpochMarker - 1; - } else { - epoch = fEpochMarker; - } - - ULong_t result = ( ( static_cast<ULong_t>(epoch) << 14 ) | - ( fTime & 0x3fff ) - ); - - return result; - -} - -ClassImp(CbmNxyterRawMessage) diff --git a/beamtime/data/raw/CbmNxyterRawMessage.h b/beamtime/data/raw/CbmNxyterRawMessage.h deleted file mode 100644 index 114c824c1008106e4d0c2477cf51df034d1d28bd..0000000000000000000000000000000000000000 --- a/beamtime/data/raw/CbmNxyterRawMessage.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef CBMNXYTERRAWMESSAGE_H -#define CBMNXYTERRAWMESSAGE_H 1 - -#include "CbmRawMessage.h" - -class CbmNxyterRawMessage : public CbmRawMessage -{ - -public: - - /** Default constructor **/ - CbmNxyterRawMessage(); - - /** Constructor **/ - CbmNxyterRawMessage(Int_t FlibLink, Int_t FebId, Int_t ChannelId, - Int_t EpochMarker, Int_t Time, - Int_t ADCval, Bool_t lastEpoch, Bool_t pileUp, Bool_t overflow); - - /** Destructor **/ - virtual ~CbmNxyterRawMessage() { }; - - Int_t GetADCvalue() { return fADCvalue;} - - ULong_t GetFullTime(); - -private: - - Int_t fADCvalue; - Bool_t fLastEpoch; - Bool_t fPileUp; - Bool_t fOverflow; - - ClassDef(CbmNxyterRawMessage,2); - -}; - -#endif // CBMNXYTERRAWMESSAGE_H diff --git a/beamtime/data/raw/CbmNxyterRawSyncMessage.cxx b/beamtime/data/raw/CbmNxyterRawSyncMessage.cxx deleted file mode 100644 index d00a38e2ad306610807db0c6fe84ecbe67fa3a8e..0000000000000000000000000000000000000000 --- a/beamtime/data/raw/CbmNxyterRawSyncMessage.cxx +++ /dev/null @@ -1,23 +0,0 @@ -#include "CbmNxyterRawSyncMessage.h" - -// ----- Default constructor ------------------------------------------- -CbmNxyterRawSyncMessage::CbmNxyterRawSyncMessage() - : CbmRawMessage(), - fStFlag(0), - fData(0) -{ -} - -// ------ Constructor ----------------------------------------------------- -CbmNxyterRawSyncMessage::CbmNxyterRawSyncMessage(Int_t FlibLink, Int_t FebId, Int_t ChannelId, - Int_t EpochMarker, Int_t Time, - Int_t StFlag, Int_t Data) - : CbmRawMessage(FlibLink, FebId, ChannelId, EpochMarker, Time), - fStFlag(StFlag), - fData(Data) -{ -} - -// ------------------------------------------------------------------------- - -ClassImp(CbmNxyterRawSyncMessage) diff --git a/beamtime/data/raw/CbmNxyterRawSyncMessage.h b/beamtime/data/raw/CbmNxyterRawSyncMessage.h deleted file mode 100644 index dabe8112932211f6fa186d0e529661983730b8a8..0000000000000000000000000000000000000000 --- a/beamtime/data/raw/CbmNxyterRawSyncMessage.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef CBMNXYTERRAWSYNCMESSAGE_H -#define CBMNXYTERRAWSYNCMESSAGE_H 1 - -#include "CbmRawMessage.h" - -class CbmNxyterRawSyncMessage : public CbmRawMessage -{ -public: // methods - - /** Default constructor **/ - CbmNxyterRawSyncMessage(); - - - /** Constructor **/ - CbmNxyterRawSyncMessage(Int_t FlibLink, Int_t FebId, Int_t ChannelId, - Int_t EpochMarker, Int_t Time, - Int_t StFlag, Int_t Data); - - /** Destructor **/ - virtual ~CbmNxyterRawSyncMessage() { }; - -public: // data members - -private: // methods - -private: // data members - - Int_t fStFlag; - Int_t fData; - - ClassDef(CbmNxyterRawSyncMessage, 1); -}; - -#endif //CBMNXYTERRAWSYNCMESSAGE_H diff --git a/beamtime/data/raw/CbmRawMessage.cxx b/beamtime/data/raw/CbmRawMessage.cxx deleted file mode 100644 index b4386d27fd6b88f85fac5968bab1b74df1c1a81c..0000000000000000000000000000000000000000 --- a/beamtime/data/raw/CbmRawMessage.cxx +++ /dev/null @@ -1,33 +0,0 @@ -/** @file CbmRawMessage.cxx - ** @author Florian Uhlig <f.uhlig@gsi.de> - ** @date 15.08.2014 - **/ - -#include "CbmRawMessage.h" - -// ----- Default constructor ------------------------------------------- -CbmRawMessage::CbmRawMessage() - : TObject(), - fEquipmentID(-1), - fSourceAddress(-1), - fChannelID(-1), - fEpochMarker(-1), - fTime(-1) - -{ -} - -CbmRawMessage::CbmRawMessage(Int_t EquipmentID, Int_t SourceAddress, - Int_t ChannelId, - Int_t EpochMarker, Int_t Time) - : TObject(), - fEquipmentID(EquipmentID), - fSourceAddress(SourceAddress), - fChannelID(ChannelId), - fEpochMarker(EpochMarker), - fTime(Time) -{ -} - - -ClassImp(CbmRawMessage) diff --git a/beamtime/data/raw/CbmRawMessage.h b/beamtime/data/raw/CbmRawMessage.h deleted file mode 100644 index 221d35dd45256b12501cda9e5b04f905d451e348..0000000000000000000000000000000000000000 --- a/beamtime/data/raw/CbmRawMessage.h +++ /dev/null @@ -1,77 +0,0 @@ -/** @file CbmRawMessage.h - ** @author Florian Uhlig <f.uhlig@gsi.de> - ** @date 15.08.2014 - **/ - - -#ifndef CBMRAWMESSAGE_H -#define CBMRAWMESSAGE_H 1 - - -#include "TObject.h" - - -/** @class CbmDigi - ** @brief Base class for representation of raw information which comes from the FLIB ind CbmNet messages. - ** @author Florian Uhlig <f.uhlig@gsi.de> - ** @version 1.0 - ** - ** CbmRawMessage is a base class for the ROOT representation of - ** the smallest information unit delivered by the detector front-ends. - ** This data is packed into CbmNet messages in the FLIB and either read - ** from file or directly from memory. - ** The CbmRawMessage contains the complete information from a single hit of - *a single electronics channel and should be context free. - ** The absolute time and the unique channel number has to be - ** calculated in another data level, probably the Digi. - ** The information content is the FLIB link, the feb id within this link, the channel ID within this feb, - ** the corresponding epoch marker (0 if there was no previous one), and the - ** time stamp from the last epoch marker. - ** - **/ -class CbmRawMessage : public TObject -{ - - public: - - /** Default constructor **/ - CbmRawMessage(); - - /** Constructor **/ - CbmRawMessage(Int_t EquipmentID, Int_t SourceAdress, Int_t ChannelId, - Int_t EpochMarker, Int_t Time); - - - /** Copy constructor **/ - // CbmRawMessage(const CbmRawMessage&); - - - - /** Destructor **/ - virtual ~CbmRawMessage() { }; - - - /** Assignment operator **/ - // CbmRawMessage& operator=(const CbmRawMessage&); - - Int_t GetEquipmentID() { return fEquipmentID; } - Int_t GetSourceAddress() { return fSourceAddress; } - Int_t GetChannelID() { return fChannelID; } - Int_t GetEpochMarker() { return fEpochMarker; } - Int_t GetTime() { return fTime; } - - ULong_t GetFullTime() { return 0L;} - - protected: - - Int_t fEquipmentID; - Int_t fSourceAddress; - Int_t fChannelID; - Int_t fEpochMarker; - Int_t fTime; - - ClassDef(CbmRawMessage,2); - -}; - -#endif diff --git a/beamtime/data/raw/CbmSpadicRawMessage.cxx b/beamtime/data/raw/CbmSpadicRawMessage.cxx deleted file mode 100644 index 6f7c202cc7fe3fa48bbb9230adc1905e50df800e..0000000000000000000000000000000000000000 --- a/beamtime/data/raw/CbmSpadicRawMessage.cxx +++ /dev/null @@ -1,154 +0,0 @@ -/** @file CbmSpadicRawMessage.cxx - ** @author Florian Uhlig <f.uhlig@gsi.de> - ** @date 15.08.2014 - **/ - -#include "CbmSpadicRawMessage.h" - -#include "FairLogger.h" - -// ----- Default constructor ------------------------------------------- -CbmSpadicRawMessage::CbmSpadicRawMessage() - : CbmRawMessage(), - fIsHit(false), - fIsInfo(false), - fIsEpoch(false), - fIsEpochOutOfSynch(false), - fIsHitAborted(false), - fIsOverflow(false), - fIsStrange(false), - fSuperEpoch(-1), - fTriggerType(-1), - fInfoType(-1), - fStopType(-1), - fGroupId(-1), - fBufferOverflowCount(-1), - fNrSamples(-1), - fSamples() -{ -} - -CbmSpadicRawMessage::CbmSpadicRawMessage(Int_t EquipmentID, Int_t SourceAddress, Int_t ChannelId, - Int_t EpochMarker, Int_t Time, - Int_t SuperEpoch, Int_t TriggerType, - Int_t InfoType, Int_t StopType, - Int_t GroupId, Int_t BufferOverflowCounter, - Int_t NrSamples, Int_t* Samples) - : CbmRawMessage(EquipmentID, SourceAddress, ChannelId, EpochMarker, Time), - fIsHit(false), - fIsInfo(false), - fIsEpoch(false), - fIsEpochOutOfSynch(false), - fIsHitAborted(false), - fIsOverflow(false), - fIsStrange(false), - fSuperEpoch(SuperEpoch), - fTriggerType(TriggerType), - fInfoType(InfoType), - fStopType(StopType), - fGroupId(GroupId), - fBufferOverflowCount(BufferOverflowCounter), - fNrSamples(NrSamples), - fSamples() -{ - for (Int_t i = 0; i < NrSamples; ++i) { - fSamples[i] = Samples[i]; - } - -} -CbmSpadicRawMessage::CbmSpadicRawMessage(Int_t EquipmentID, Int_t SourceAddress, Int_t ChannelId, - Int_t EpochMarker, Int_t Time, - Int_t SuperEpoch, Int_t TriggerType, - Int_t InfoType, Int_t StopType, - Int_t GroupId, Int_t BufferOverflowCounter, - Int_t NrSamples, Int_t* Samples, - Bool_t isHit, Bool_t isInfo, Bool_t isEpoch, Bool_t isEpochOutOfSynch, Bool_t isHitAborted, Bool_t isOverflow, Bool_t isStrange) - : CbmRawMessage(EquipmentID, SourceAddress, ChannelId, EpochMarker, Time), - fIsHit(isHit), - fIsInfo(isInfo), - fIsEpoch(isEpoch), - fIsEpochOutOfSynch(isEpochOutOfSynch), - fIsHitAborted(isHitAborted), - fIsOverflow(isOverflow), - fIsStrange(isStrange), - fSuperEpoch(SuperEpoch), - fTriggerType(TriggerType), - fInfoType(InfoType), - fStopType(StopType), - fGroupId(GroupId), - fBufferOverflowCount(BufferOverflowCounter), - fNrSamples(NrSamples), - fSamples() -{ - for (Int_t i = 0; i < NrSamples; ++i) { - fSamples[i] = Samples[i]; - } - -} -// ------------------------------------------------------------------------- - -void CbmSpadicRawMessage::PrintMessage() -{ - LOG(info) << "CbmSpadicRawMessage::Print()"; - LOG(info) << - " fIsHit:" << Int_t(fIsHit) << - " fIsInfo:" << Int_t(fIsInfo) << - " fIsEpoch:" << Int_t(fIsEpoch) << - " fIsEpochOutOfSynch:" << Int_t(fIsEpochOutOfSynch) << - " fIsHitAborted:" << Int_t(fIsHitAborted) << - " fIsOverflow:" << Int_t(fIsOverflow) << - " fIsStrange:" << Int_t(fIsStrange); - LOG(info) << - " fSuperEpoch:" << fSuperEpoch << - " fTriggerType:" << fTriggerType << - " fInfoType:" << fInfoType << - " fStopType:" << fStopType << - " fGroupId:" << fGroupId << - " fBufferOverflowCount:" << fBufferOverflowCount << - " fNrSamples:" << fNrSamples; - std::stringstream ss; - for (Int_t i = 0; i < fNrSamples; i++) { - ss << " " << fSamples[i]; - } - LOG(info) << ss.str(); -} - -ULong_t CbmSpadicRawMessage::GetFullTime() -{ - // Spadic time counter runs with 17.5 MHz => time between conters is - // 1/17.5 MHz = 57,14 ns !!! - // Spadic counter has 2^12 bits - // Spadic epoch counter has also 2^12 bits - // => Overflow after 2^24 * 57,14 ns = 0,95s - // So we need to take care of this overflow. In the Spadic unpacker we - // have introduced a "SuperEpoch" counter which is increased by one for - // each overflow of the epoch counter. - // This works only reliable if we get the complete stream and are able - // to measure each of this overflows. - // So the absolute time in ns is calculated by the folowing formular - // time (ns) = (SuperEpoch * 2^24 + Epoch *2^12 + timecounter) * 1000/17.5 MHz - // To speed up the calculation we use here some bit operators described - // below. The result should be the same for both calculations - // - // (number << 1) will shift all bits to the left by one bit. - // This is a multiplication of the number by the factor 2^1. - // (number << 12) will shift all bits to the left by one bit. - // This is a multiplication of the number by the factor 2^12. - // The lower 12 bits are after the shift set to zero. - // (number & 0xFFF) will set all bit above bit 12 to zero - // (number1 | number2) will add both numbers bitwise - - ULong_t result1 = ( ( static_cast<ULong_t>(fSuperEpoch) << 24) | - ( static_cast<ULong_t>(fEpochMarker) << 12) | - ( fTime & 0xfff ) - ); - /* - ULong_t result2 = fSuperEpoch * 4096 * 4096 + fEpochMarker *4096 + fTime; - - LOG(info) << "Time: " << result1 << " : " << result2; - */ - - return result1; -} - -ClassImp(CbmSpadicRawMessage) diff --git a/beamtime/data/raw/CbmSpadicRawMessage.h b/beamtime/data/raw/CbmSpadicRawMessage.h deleted file mode 100644 index b2ca67425e4238dfffd7342fa247cf5f9179d773..0000000000000000000000000000000000000000 --- a/beamtime/data/raw/CbmSpadicRawMessage.h +++ /dev/null @@ -1,95 +0,0 @@ -/** @file CbmSpadicRawMessage.h - ** @author Florian Uhlig <f.uhlig@gsi.de> - ** @date 15.08.2014 - **/ - - -#ifndef CBMSPADICRAWMESSAGE_H -#define CBMSPADICRAWMESSAGE_H 1 - - -#include "CbmRawMessage.h" - - -/** @class CbmSpadicRawMessage - ** @brief Class for representation of raw spadic information, derrived from CbmRawMessage. - ** @author Florian Uhlig <f.uhlig@gsi.de> - ** @version 1.0 - ** - ** CbmSpadicRawMessage is a base class for the ROOT representation of - ** the smallest information unit delivered by the spadic front-ends. - ** The CbmSpadicRawMessage extends the CbmRawMessage by the spadic sample data and the number of samples. - ** a single electronics channel and should be context free. an - ** - **/ -class CbmSpadicRawMessage : public CbmRawMessage -{ - - public: - - /** Default constructor **/ - CbmSpadicRawMessage(); - - /** Constructor **/ - CbmSpadicRawMessage(Int_t EquipmentID, Int_t SourceAddress, Int_t ChannelId, - Int_t EpochMarker, Int_t Time, Int_t SuperEpoch, Int_t TriggerType, - Int_t InfoType, Int_t StopType, Int_t GroupId, Int_t BufferOverflowCounter, - Int_t NrSamples, Int_t* Samples); - - CbmSpadicRawMessage(Int_t EquipmentID, Int_t SourceAddress, Int_t ChannelId, - Int_t EpochMarker, Int_t Time, Int_t SuperEpoch, Int_t TriggerType, - Int_t InfoType, Int_t StopType, Int_t GroupId, Int_t BufferOverflowCounter, - Int_t NrSamples, Int_t* Samples, Bool_t isHit, Bool_t isInfo, Bool_t isEpoch, Bool_t isEpochOutOfSynch, Bool_t isHitAborted, Bool_t isOverflow, Bool_t isStrange); - - /** Destructor **/ - virtual ~CbmSpadicRawMessage() { }; - - Int_t GetNrSamples() { return fNrSamples; } - Int_t* GetSamples() { return fSamples; } - Int_t GetTriggerType() { return fTriggerType; } - Int_t GetStopType() { return fStopType; } - Int_t GetInfoType() { return fInfoType; } - Int_t GetGroupId() { return fGroupId; } - - ULong_t GetFullTime(); - Int_t GetSuperEpoch() { return fSuperEpoch; } - Int_t GetBufferOverflowCount() {return fBufferOverflowCount; } - /* - void SetHit(Bool_t stat) {fIsHit = stat; } - void SetInfo(Bool_t stat) {fIsInfo = stat; } - void SetEpoch(Bool_t stat) {fIsEpoch = stat; } - */ - Bool_t GetHit() { return fIsHit; } - Bool_t GetInfo() { return fIsInfo; } - Bool_t GetEpoch() { return fIsEpoch; } - Bool_t GetEpochOutOfSynch() { return fIsEpochOutOfSynch; } - Bool_t GetHitAborted() { return fIsHitAborted; } - Bool_t GetOverFlow() { return fIsOverflow; } - Bool_t GetStrange() { return fIsStrange; } - - void PrintMessage(); - - private: - - Bool_t fIsHit; - Bool_t fIsInfo; - Bool_t fIsEpoch; - Bool_t fIsEpochOutOfSynch; - Bool_t fIsHitAborted; - Bool_t fIsOverflow; - Bool_t fIsStrange; - - Int_t fSuperEpoch; - Int_t fTriggerType; - Int_t fInfoType; - Int_t fStopType; - Int_t fGroupId; - Int_t fBufferOverflowCount; - Int_t fNrSamples; - Int_t fSamples[32]; - - ClassDef(CbmSpadicRawMessage,8); - -}; - -#endif diff --git a/beamtime/data/raw/CbmStsxyterRawHitMessage.cxx b/beamtime/data/raw/CbmStsxyterRawHitMessage.cxx deleted file mode 100644 index f87e4e9e5ab87aaaf89451d41199146cf7ced6ff..0000000000000000000000000000000000000000 --- a/beamtime/data/raw/CbmStsxyterRawHitMessage.cxx +++ /dev/null @@ -1,18 +0,0 @@ -#include "CbmStsxyterRawHitMessage.h" - -CbmStsxyterRawHitMessage::CbmStsxyterRawHitMessage() -: CbmRawMessage(), - fAdcValue(0), - fParityError( kFALSE ) -{ -} - -CbmStsxyterRawHitMessage::CbmStsxyterRawHitMessage(Int_t EquipmentID, Int_t SourceAdress, Int_t ChannelId, - Int_t EpochMarker, Int_t Time, Int_t AdcValue, Bool_t ParityError) -: CbmRawMessage(EquipmentID, SourceAdress, ChannelId, EpochMarker, Time), - fAdcValue( AdcValue ), - fParityError( ParityError ) -{ -} - -ClassImp(CbmStsxyterRawHitMessage) diff --git a/beamtime/data/raw/CbmStsxyterRawHitMessage.h b/beamtime/data/raw/CbmStsxyterRawHitMessage.h deleted file mode 100644 index 64059ec715dc079ad91cec38892dc0bb4df51f3b..0000000000000000000000000000000000000000 --- a/beamtime/data/raw/CbmStsxyterRawHitMessage.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef CBMSTSXYTERRAWHITMESSAGE_H -#define CBMSTSXYTERRAWHITMESSAGE_H 1 - -#include "CbmRawMessage.h" - -class CbmStsxyterRawHitMessage : public CbmRawMessage -{ - -public: - CbmStsxyterRawHitMessage(); - CbmStsxyterRawHitMessage(Int_t EquipmentID, Int_t SourceAdress, Int_t ChannelId, - Int_t EpochMarker, Int_t Time, Int_t AdcValue, Bool_t ParityError ); - virtual ~CbmStsxyterRawHitMessage() { }; - Int_t GetAdcValue() const {return fAdcValue;} - Bool_t GetParityError() const {return fParityError;} - -private: - Int_t fAdcValue; - Bool_t fParityError; - - ClassDef(CbmStsxyterRawHitMessage,2); -}; - -#endif // CBMSTSXYTERRAWHITMESSAGE_H diff --git a/beamtime/data/raw/CbmTrbRawMessage.cxx b/beamtime/data/raw/CbmTrbRawMessage.cxx deleted file mode 100644 index 9d55b4198af263a33b9629d335462c0450fffe74..0000000000000000000000000000000000000000 --- a/beamtime/data/raw/CbmTrbRawMessage.cxx +++ /dev/null @@ -1,88 +0,0 @@ -#include "CbmTrbRawMessage.h" - -#include <iostream> - -// ----- Default constructor ------------------------------------------- -CbmTrbRawMessage::CbmTrbRawMessage() - : CbmRawMessage(), - fTDCfine(0), - fEdge(kFALSE), - fCorrection(0.), - fMicrosliceID(0) -{ -} - -// ------ Constructor ----------------------------------------------------- -CbmTrbRawMessage::CbmTrbRawMessage(Int_t FlibLink, Int_t FebId, - Int_t ChannelId, - Int_t EpochMarker, Int_t CoarseTime, - Int_t FineTime, Bool_t Edge, Double_t Correction, - Int_t MicrosliceID) - : CbmRawMessage(FlibLink, FebId, ChannelId, EpochMarker, CoarseTime), - fTDCfine(FineTime), - fEdge(Edge), - fCorrection(Correction), - fMicrosliceID(MicrosliceID) -{ -} - -// ------------------------------------------------------------------------- -void CbmTrbRawMessage::Print(Option_t*) const -{ - std::cout << "CbmTrbRawMessage: " - << "eqID=0x" << std::hex << fEquipmentID << std::dec << "\t" - << "msID=" << fMicrosliceID << "\t" - << "addr=" << fSourceAddress << "\t" - << "ch=" << fChannelID << "\t" - << "edge=" << fEdge << "\t" - << "ep=" << fEpochMarker << "\t" - << "ct=" << fTime << "\t" - << "ft=" << fTDCfine << "\t" - << "corr=" << fCorrection << std::endl; -} - -// ------------------------------------------------------------------------- - -void CbmTrbRawMessage::CopyMessage(CbmTrbRawMessage* source) -{ - /* From CbmRawMessage */ - fEquipmentID = source->GetEquipmentID(); - fSourceAddress = source->GetSourceAddress(); - fChannelID = source->GetChannelID(); - fEpochMarker = source->GetEpochMarker(); - fTime = source->GetTime(); - - /* From CbmTrbRawMessage */ - fTDCfine = source->GetTDCfine(); - fEdge = source->GetEdge(); - fCorrection = source->GetCorr(); - fMicrosliceID = source->GetMicrosliceID(); -} - -/* - * For information see comments in class CbmTrbCalibrator - * There you can find the info about how to compute full time from - * epoch, coarse, fine and correction. - */ -ULong_t CbmTrbRawMessage::GetFullTime() -{ - Double_t coarseUnit = 5.; - Double_t epochUnit = coarseUnit * 0x800; - - ULong_t time = fEpochMarker * epochUnit + fTime * coarseUnit + fCorrection; - - return time; -} - -Double_t CbmTrbRawMessage::GetFullTime2() const -{ - Double_t coarseUnit = 5.; // 5ns - Double_t epochUnit = coarseUnit * 0x800; - Double_t fineUnit = 0.005; // 5ps - - Double_t time = fEpochMarker * epochUnit + fTime * coarseUnit - fTDCfine * fineUnit + fCorrection; - - return time; -} - -ClassImp(CbmTrbRawMessage) diff --git a/beamtime/data/raw/CbmTrbRawMessage.h b/beamtime/data/raw/CbmTrbRawMessage.h deleted file mode 100644 index 700ee0f11510b9d8fdd17bac34c21366c8880054..0000000000000000000000000000000000000000 --- a/beamtime/data/raw/CbmTrbRawMessage.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef CBMTRBRAWMESSAGE_H -#define CBMTRBRAWMESSAGE_H 1 - - -#include "CbmRawMessage.h" - -class CbmTrbRawMessage : public CbmRawMessage -{ - - public: - - /** Default constructor **/ - CbmTrbRawMessage(); - - /** Constructor **/ - CbmTrbRawMessage(Int_t FlibLink, Int_t FebId, Int_t ChannelId, - Int_t EpochMarker, Int_t CoarseTime, - Int_t FineTime, Bool_t Edge, Double_t Correction=0., Int_t MicrosliceID=0); - - /** Destructor **/ - virtual ~CbmTrbRawMessage() { }; - - virtual void Print(Option_t* option="") const; - - void CopyMessage(CbmTrbRawMessage* source); - - Int_t GetTDCfine() { return fTDCfine;} - Int_t GetTDCcoarse() { return fTime;} - Int_t GetEdge() { return fEdge;} - Double_t GetCorr() { return fCorrection; } - Int_t GetMicrosliceID() const { return fMicrosliceID; } - - ULong_t GetFullTime(); - - Double_t GetFullTime2() const; - - private: - - /** Data members **/ - Int_t fTDCfine; - Bool_t fEdge; - Double_t fCorrection; - Int_t fMicrosliceID; - - ClassDef(CbmTrbRawMessage,2); - -}; - -#endif // CBMTRBRAWMESSAGE_H diff --git a/beamtime/data/raw/CbmTrdRawMessage.cxx b/beamtime/data/raw/CbmTrdRawMessage.cxx deleted file mode 100644 index 151559555a7648590d4b2cb0fa7ae9b90fdac590..0000000000000000000000000000000000000000 --- a/beamtime/data/raw/CbmTrdRawMessage.cxx +++ /dev/null @@ -1,41 +0,0 @@ -#include "CbmTrdRawMessage.h" - - -//___________________________________________________________________________ -CbmTrdRawMessage::CbmTrdRawMessage() - : CbmRawMessage() - ,fMeta(0) - ,fData(0) -{ -/** Default constructor - */ -} - -//___________________________________________________________________________ -CbmTrdRawMessage::CbmTrdRawMessage(UChar_t asicType, UChar_t messType, - UChar_t asicAddress, UChar_t chAddress, - UShort_t timeStamp, UInt_t data) - : CbmRawMessage() - ,fMeta(0) - ,fData(data) -{ - /** Pack readable data to a 64 bits word of the core message;\n - * 32 bits meta data structure \n - * MMMM.MMtt tttt.tttt ttAA.cccc aaaa.aaaa \n - * A - ASIC type 2 bits see CbmTrdAsicType definition\n - * M - Message type defined by implementation\n - * a - ASIC address in the module\n - * c - channel address in the ASIC\n - * t - time stamp within one epoch - * - * The last 14 bits should be kept for all inherited classes while the "M" and "t" bits can be realocated. - */ - - fMeta = timeStamp; fMeta<<=6; - fMeta|= (messType&0x3f); fMeta<<=2; - fMeta|= (asicType&0x3); fMeta<<=4; - fMeta|= (chAddress&0xf); fMeta<<=8; - fMeta|= asicAddress; -} - -ClassImp(CbmTrdRawMessage) diff --git a/beamtime/data/raw/CbmTrdRawMessage.h b/beamtime/data/raw/CbmTrdRawMessage.h deleted file mode 100644 index 6e5ecf22fe3f62fd6748bf8cc9187e40f230c198..0000000000000000000000000000000000000000 --- a/beamtime/data/raw/CbmTrdRawMessage.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef CBMTRDRAWMESSAGE_H -#define CBMTRDRAWMESSAGE_H - -#include "CbmRawMessage.h" - -class CbmTrdRawMessage : public CbmRawMessage -{ -public: - enum CbmTrdAsicType{ - kSPADIC20 = 0 //< SPADIC 2.0 - ,kSPADIC21 //< SPADIC 2.1 - ,kSPADIC22 //< SPADIC 2.2 - ,kFASP //< FASP 2.1 - }; - CbmTrdRawMessage(); - /** \brief Build the core of a TRD message - * \param[in] asicType define ASIC type according of the CbmTrdAsicType - * \param[in] messType define message type. ASIC specific - * \param[in] asicAddress unique address of the ASIC on the module - * \param[in] chAddress unique channel address on the ASIC - * \param[in] timeStamp time inside one epoch - * \param[in] data memory to be used during inheritance - */ - CbmTrdRawMessage(UChar_t asicType, UChar_t messType, - UChar_t asicAddress, UChar_t chAddress, - UShort_t timeStamp, UInt_t data=0); - - virtual UChar_t GetAddressAsic() const { return fMeta&0xff;} - virtual UChar_t GetAddressChannel() const { return (fMeta&0xf00)>>8;} - virtual CbmTrdAsicType GetAsicType() const = 0; // { return (fMeta&0x3000)>>12;} - virtual UChar_t GetMessType() const { return fMeta>>26;} - virtual UInt_t GetData() const { return fData;} - virtual UChar_t GetTimeStamp() const { return (fMeta&0x3ffc000)>>14;} - -protected: - UInt_t fMeta; //< Meta data describing the message - UInt_t fData; //< allocated for memory alignment; reserved for derived classes - - ClassDef(CbmTrdRawMessage, 1) // Abstract class for TRD raw messages -}; - -#endif diff --git a/beamtime/data/raw/rocMess_wGet4v1.cxx b/beamtime/data/raw/rocMess_wGet4v1.cxx deleted file mode 100644 index baae127806b60e4adbc525165fd07ecf7bb37d52..0000000000000000000000000000000000000000 --- a/beamtime/data/raw/rocMess_wGet4v1.cxx +++ /dev/null @@ -1,829 +0,0 @@ -#include "rocMess_wGet4v1.h" - -// C++11 headers -#include <cmath> - -// std C++ lib headers -#include <stdio.h> -#include <string.h> - -#include <iostream> -#include <sstream> -#include <iomanip> - -std::string FormatDecPrintout( uint64_t ulVal, char cFill = 0, uint uWidth = 0 ) -{ - std::stringstream ss; - - /// Set fill character and/or width if provided by user - if( 0 != cFill ) - ss << std::setfill( cFill ); - if( 0 < uWidth ) - ss << std::setw( uWidth ); - - /// push value - ss << ulVal; - - /// Restore fill character if needed - if( 0 != cFill ) - ss << std::setfill (' '); - - return ss.str(); -} - -std::string FormatHexPrintout( uint64_t ulVal, char cFill = 0, uint uWidth = 0, bool bUppercase = false ) -{ - std::stringstream ss; - - /// Set hex printout mode - ss << std::hex; - - /// Set fill character and/or width if provided by user - if( 0 != cFill ) - ss << std::setfill( cFill ); - if( 0 < uWidth ) - ss << std::setw( uWidth ); - if( bUppercase ) - ss << std::uppercase; - - /// push value - ss << ulVal - << std::dec; - - /// Restore fill character if needed - if( 0 != cFill ) - ss << std::setfill (' '); - - return ss.str(); -} - -//---------------------------------------------------------------------------- -//! strict weak ordering operator, assumes same epoch for both messages -bool ngdpb::Message::operator<(const ngdpb::Message& other) const -{ - uint64_t uThisTs = 0; - uint64_t uOtherTs = 0; - - uint32_t uThisType = this->getMessageType(); - uint32_t uOtherType = other.getMessageType(); - - // if both GET4 hit messages, use the full timestamp info - if( (MSG_GET4_32B == uThisType || MSG_GET4 == uThisType )&& - (MSG_GET4_32B == uOtherType || MSG_GET4 == uOtherType ) ) - { - uThisTs = this->getGdpbHitFullTs(); - uOtherTs = other.getGdpbHitFullTs(); - return uThisTs < uOtherTs; - } // both GET4 hit (32b or 24b) - - // First find the timestamp of the current message - if( MSG_GET4_32B == uThisType || MSG_GET4 == uThisType ) - { - uThisTs = ( this->getGdpbHitFullTs() ) / 20 + 512; - } // if Hit GET4 message (24 or 32b) - else if( MSG_GET4_SLC == uThisType || MSG_GET4_SYS == uThisType ) - { - uThisTs = 0; - } // if SLC or SYS GET4 message - else uThisTs = this->getMsgFullTime( 0 ); - - // Then find the timestamp of the current message - if( MSG_GET4_32B == uOtherType || MSG_GET4 == uOtherType ) - { - uOtherTs = ( this->getGdpbHitFullTs() ) / 20 + 512; - } // if Hit GET4 message (24 or 32b) - else if( MSG_GET4_SLC == uOtherType || MSG_GET4_SYS == uOtherType ) - { - uOtherTs = 0; - } // if SLC or SYS GET4 message - else uOtherTs = other.getMsgFullTime( 0 ); - - return uThisTs < uOtherTs; -} - -//---------------------------------------------------------------------------- -//! Returns expanded and adjusted time of message (in ns) -//! epoch should correspond to the message type - epoch2 for Get4, epoch for all others -//! With the DPBs, both GET4 and nXYTER systems operate at the same frequency of 160MHz. -//! When converting from GET4 to nXYTER clocks, one should take into account -//! that initial value of nDPB timestamp counter is 0x80 or 512 ns. Therefore such offset -//! should be applied during conversion => Is it really true? nXYTER or nDPB effect? -//! =====> see '///' lines - -uint64_t ngdpb::Message::getMsgFullTime(uint32_t epoch) const -{ -/* - switch (getMessageType()) { - case MSG_HIT: - return FullTimeStamp(getNxLastEpoch() ? epoch - 1 : epoch, getNxTs()); - case MSG_EPOCH: - return FullTimeStamp(getEpochNumber(), 0); - case MSG_SYNC: - return FullTimeStamp((getSyncEpochLSB() == (epoch & 0x1)) ? epoch : epoch - 1, getSyncTs()); - case MSG_AUX: - return FullTimeStamp((getAuxEpochLSB() == (epoch & 0x1)) ? epoch : epoch - 1, getAuxTs()); - case MSG_EPOCH2: -/// return FullTimeStamp2(getEpoch2Number(), 0) / 20 + 512; - return FullTimeStamp2(getEpoch2Number(), 0) / 20; - case MSG_GET4: -/// return FullTimeStamp2(epoch, getGet4Ts()) / 20 + 512; - return FullTimeStamp2(epoch, getGet4Ts()) / 20; - case MSG_SYS: - return FullTimeStamp(epoch, 0); - case MSG_GET4_32B: -/// return FullTimeStamp2(epoch, getGdpbHitFullTs()) / 20 + 512; - return FullTimeStamp2(epoch, getGdpbHitFullTs()) / 20; - case MSG_GET4_SLC: - case MSG_GET4_SYS: -/// return FullTimeStamp2(epoch, 0) / 20 + 512; - return FullTimeStamp2(epoch, 0) / 20; - } - return 0; -*/ - // Quick and dirty fix, maybe need to be carefully checked - // Use round to integer, maybe need check on sign? - return std::round( getMsgFullTimeD( epoch ) ); -} - -//---------------------------------------------------------------------------- -//! Returns expanded and adjusted time of message in double (in ns) -//! epoch should correspond to the message type - epoch2 for Get4, epoch for all others - -double ngdpb::Message::getMsgFullTimeD(uint32_t epoch) const -{ - switch (getMessageType()) { - case MSG_HIT: - if( 0 < epoch ) - return FullTimeStamp(getNxLastEpoch() ? epoch - 1 : epoch, getNxTs()) * (6.25 / 4.); // ignore the 2 last bits of NX TS (fine-time) - else return (getNxLastEpoch() ? -1 : FullTimeStamp( epoch, getNxTs()) * (6.25 / 4.) ); // ignore the 2 last bits of NX TS (fine-time) - case MSG_EPOCH: - return FullTimeStamp(getEpochNumber(), 0); // ignore the 2 last bits - case MSG_SYNC: - return FullTimeStamp((getSyncEpochLSB() == (epoch & 0x1)) ? epoch : epoch - 1, getSyncTs()) * (6.25 / 4.); - case MSG_AUX: - return FullTimeStamp((getAuxEpochLSB() == (epoch & 0x1)) ? epoch : epoch - 1, getAuxTs()) * (6.25 / 4.); - case MSG_EPOCH2: - return FullTimeStamp2(getEpoch2Number(), 0) * (6.25 / 128.); - case MSG_GET4: - return FullTimeStamp2(epoch, getGdpbHitFullTs()) * (6.25 / 128.); - case MSG_SYS: - if( SYSMSG_GET4_EVENT == getGdpbSysSubType() ) - return FullTimeStamp2(epoch, 0) * (6.25 / 128.); // Use epoch period of TOF!! - else return FullTimeStamp(epoch, 0) * (6.25 / 4.); // Use epoch period of NX TS - case MSG_GET4_32B: - return FullTimeStamp2(epoch, getGdpbHitFullTs()) * (6.25 / 128.); - case MSG_GET4_SLC: - case MSG_GET4_SYS: - return FullTimeStamp2(epoch, 0) * (6.25 / 128.); - } - - // If not already dealt with => unknown type - return 0.0; -} -//---------------------------------------------------------------------------- -//! Same as getMsgFullTime with Get4 v2.0 and higher fine time calculation -uint64_t ngdpb::Message::getMsgG4v2FullTime(uint32_t epoch) const -{ - return std::round( getMsgG4v2FullTimeD( epoch ) ); -} -//---------------------------------------------------------------------------- -//! Same as getMsgFullTimeD with Get4 v2.0 and higher fine time calculation -//! Harcoded constants should be implemented better as soon as their value is fixed -double ngdpb::Message::getMsgG4v2FullTimeD(uint32_t epoch) const -{ - switch (getMessageType()) { - case MSG_HIT: - if( 0 < epoch ) - return FullTimeStamp(getNxLastEpoch() ? epoch - 1 : epoch, getNxTs()) * (6.25 / 4.); // ignore the 2 last bits of NX TS (fine-time) - else return (getNxLastEpoch() ? -1 : FullTimeStamp( epoch, getNxTs()) * (6.25 / 4.) ); // ignore the 2 last bits of NX TS (fine-time) - case MSG_EPOCH: - return FullTimeStamp(getEpochNumber(), 0); // ignore the 2 last bits - case MSG_SYNC: - return FullTimeStamp((getSyncEpochLSB() == (epoch & 0x1)) ? epoch : epoch - 1, getSyncTs()) * (6.25 / 4.); - case MSG_AUX: - return FullTimeStamp((getAuxEpochLSB() == (epoch & 0x1)) ? epoch : epoch - 1, getAuxTs()) * (6.25 / 4.); - case MSG_EPOCH2: - return get4v1x::kdEpochInNs * static_cast<double_t>( getEpoch2Number() ); - case MSG_GET4: - return ( static_cast<double_t>(FullTimeStamp2(epoch, (getGdpbHitCoarse() << 7))) + ( static_cast<double_t>(getGdpbHitFineTs() - 8. ) * 128. /112.) ) - * (6.25 / 128.); /// TODO: hardcoded -> constant values!! - case MSG_SYS: - if( SYSMSG_GET4_EVENT == getGdpbSysSubType() ) - return get4v1x::kdEpochInNs * static_cast<double_t>( epoch ); // Use epoch period of TOF!! - else return FullTimeStamp(epoch, 0) * (6.25 / 4.); // Use epoch period of NX TS - case MSG_GET4_32B: -// return ( static_cast<double_t>(FullTimeStamp2(epoch, (getGdpbHitCoarse() << 7))) + static_cast<double_t>(getGdpbHitFineTs() ) ) -// * (6.25 / 112.); /// TODO: hardcoded -> constant values!! - return ( get4v1x::kdEpochInNs * static_cast<double_t>( epoch ) + static_cast<double_t>( getGdpbHitFullTs() ) * get4v1x::kdClockCycleSizeNs / 112. ); - case MSG_GET4_SLC: - case MSG_GET4_SYS: - return FullTimeStamp2(epoch, 0) * (6.25 / 128.); - } - - // If not already dealt with => unknown type - return 0.0; -} -//---------------------------------------------------------------------------- -//---------------------------------------------------------------------------- -//! Returns the time difference between two expanded time stamps - -uint64_t ngdpb::Message::CalcDistance(uint64_t start, uint64_t stop) -{ - if (start>stop) { - stop += 0x3FFFFFFFFFFFLLU; - if (start>stop) { - printf("Epochs overflow error in CalcDistance\n"); - return 0; - } - } - - return stop - start; -} - - -//---------------------------------------------------------------------------- -//! Returns the time difference between two expanded time stamps - -double ngdpb::Message::CalcDistanceD(double start, double stop) -{ - if (start>stop) { - stop += 0x3FFFFFFFFFFFLLU; - if (start>stop) { - printf("Epochs overflow error in CalcDistanceD\n"); - return 0.; - } - } - - return stop - start; -} - - - -//---------------------------------------------------------------------------- -//! Print message in human readable format to \a cout. -/*! - * Prints a one line representation of the message in to \a cout. - * See printData(std::ostream&, unsigned, uint32_t) const for full - * documentation. - */ - -void ngdpb::Message::printDataCout(unsigned kind, uint32_t epoch) const -{ - printData(msg_print_Cout, kind, epoch); -} - -//---------------------------------------------------------------------------- -//! Print message in human readable format to the Fairroot logger. -/*! - * Prints a one line representation of the message in to the Fairroot logger. - * TODO: Add coloring of possible - * See printData(std::ostream&, unsigned, uint32_t) const for full - * documentation. - */ - -void ngdpb::Message::printDataLog(unsigned kind, uint32_t epoch) const -{ - printData(msg_print_FairLog, kind, epoch); -} - -//---------------------------------------------------------------------------- -//! Print message in binary or human readable format to a stream. -/*! - * Prints a one line representation of the message in to a stream, selected by \a outType. - * The stream is \a cout if \a outType is kFALSE and \a FairLogger if \a outType is kTRUE. - * The parameter \a kind is mask with 4 bits - * \li ngdpb::msg_print_Prefix (1) - ROC number and message type - * \li ngdpb::msg_print_Data (2) - print all message specific data fields - * \li ngdpb::msg_print_Hex (4) - print data as hex dump - * \li ngdpb::msg_print_Human (8) - print in human readable format - * - * If bit msg_print_Human in \a kind is not set, raw format - * output is generated. All data fields are shown in hexadecimal. - * This is the format of choice when chasing hardware problems at the bit level. - * - * If bit msg_print_Human is set, a more human readable output is generated. - * The timestamp is shown as fully extended and adjusted time as - * returned by the getMsgFullTime(uint32_t) const method. - * All data fields are represented in decimal. - * - * \param os output stream - * \param kind mask determing output format - * \param epoch current epoch number (from last epoch message) - * - * Typical message output in human format looks like -\verbatim -Msg:7 Roc:1 SysType: 1 Nx:0 Data: 0 : DAQ started -Msg:7 Roc:1 SysType: 6 Nx:0 Data: 0 : FIFO reset -Msg:2 Roc:1 EPO @ 0.536870912 Epo: 32768 0x00008000 Miss: 0 -Msg:0 Roc:0 NOP (raw 80:40:82:0F:00:00) -Msg:2 Roc:1 EPO @ 0.646627328 Epo: 39467 0x00009a2b Miss: 0 -Msg:1 Roc:1 HIT @ 0.646614333 Nx:2 Chn: 12 Ts: 3389-e( 8) Adc:2726 Pu:0 Of:0 -Msg:1 Roc:1 HIT @ 0.646630717 Nx:2 Chn: 13 Ts: 3389 ( 0) Adc:2745 Pu:0 Of:0 -Msg:2 Roc:1 EPO @ 0.805306368 Epo: 49152 0x0000c000 Miss: 0 -Msg:3 Roc:1 SYN @ 0.805306408 Chn:2 Ts: 40 Data: 49152 0x00c000 Flag:0 -Msg:7 Roc:1 SysType: 2 Nx:0 Data: 0 : DAQ finished -\endverbatim - * - * Typical message output in binary format looks like -\verbatim -Msg:7 Roc:1 SysType: 1 Nx:0 Data: 0 : DAQ started -Msg:7 Roc:1 SysType: 6 Nx:0 Data: 0 : FIFO reset -Msg:2 Roc:1 Epoch:00008000 Missed:00 -Msg:1 Roc:1 Nx:2 Chn:0d Ts:3ec9 Last:1 Msb:7 Adc:a22 Pup:0 Oflw:0 -Msg:1 Roc:1 Nx:2 Chn:0e Ts:3ec9 Last:0 Msb:7 Adc:a18 Pup:0 Oflw:0 -Msg:0 Roc:0 NOP (raw 80:40:82:0F:00:00) -Msg:2 Roc:1 Epoch:00010000 Missed:00 -Msg:3 Roc:1 SyncChn:2 EpochLSB:0 Ts:0028 Data:010000 Flag:0 -Msg:7 Roc:1 SysType: 2 Nx:0 Data: 0 : DAQ finished -\endverbatim - */ - -//void ngdpb::Message::printData(std::ostream& os, unsigned kind, uint32_t epoch) const -void ngdpb::Message::printData(unsigned outType, unsigned kind, uint32_t epoch, std::ostream& os) const -{ - char buf[256]; - if (kind & msg_print_Hex) { - const uint8_t* arr = reinterpret_cast<const uint8_t*> ( &data ); - snprintf(buf, sizeof(buf), "BE= %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X LE= %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X ", - arr[0], arr[1], arr[2], arr[3], arr[4], arr[5], arr[6], arr[7], - arr[7], arr[6], arr[5], arr[4], arr[3], arr[2], arr[1], arr[0] ); -// os << buf; - if( msg_print_Cout == outType) - std::cout << buf; - else if( msg_print_File == outType ) - os << buf; - - snprintf(buf, sizeof(buf), " "); - } - - if (kind & msg_print_Human) { - double timeInSec = getMsgFullTimeD(epoch)/1.e9; - int fifoFill = 0; - - switch (getMessageType()) { - case MSG_HIT: - fifoFill = getNxLtsMsb() - ((getNxTs()>>11)&0x7); - if (getNxLastEpoch()) fifoFill += 8; - snprintf(buf, sizeof(buf), - "Msg:%u Roc:%04x ", getMessageType(), getRocNumber()); -// os << buf; - if( msg_print_Cout == outType) - std::cout << buf; - else if( msg_print_File == outType ) - os << buf; - - snprintf(buf, sizeof(buf), - "HIT @%15.9f Nx:%1u Chn:%3d Ts:%5d%s(%2d) Adc:%4d Pu:%d Of:%d", - timeInSec, getNxNumber(), getNxChNum(), getNxTs(), - (getNxLastEpoch() ? "-e" : " "), - fifoFill, getNxAdcValue(), getNxPileup(), getNxOverflow()); -// os << buf << std::endl; - if( msg_print_Cout == outType) - std::cout << buf << std::endl; - else if( msg_print_File == outType ) - os << buf << std::endl; - break; - case MSG_EPOCH: - snprintf(buf, sizeof(buf), - "Msg:%u Roc:%04x ", getMessageType(), getRocNumber()); -// os << buf; - if( msg_print_Cout == outType) - std::cout << buf; - else if( msg_print_File == outType ) - os << buf; - - snprintf(buf, sizeof(buf), - "EPO @%15.9f Nx:%1u Epo:%10u 0x%08x Miss: %3d%c", - timeInSec, getEpochNxNum(), getEpochNumber(), getEpochNumber(), - getEpochMissed(), (getEpochMissed()==0xff) ? '+' : ' '); -// os << buf << std::endl; - if( msg_print_Cout == outType) - std::cout << buf << std::endl; - else if( msg_print_File == outType ) - os << buf << std::endl; - break; - case MSG_SYNC: - snprintf(buf, sizeof(buf), - "Msg:%u Roc:%04x ", getMessageType(), getRocNumber()); -// os << buf; - if( msg_print_Cout == outType) - std::cout << buf; - else if( msg_print_File == outType ) - os << buf; - - snprintf(buf, sizeof(buf), - "SYN @%15.9f Nx:%1u Chn:%d Ts:%5d%s Data:%8d 0x%06x Flag:%d", - timeInSec, getSyncNxNum(), getSyncChNum(), getSyncTs(), - ((getSyncEpochLSB() != (epoch&0x1)) ? "-e" : " "), - getSyncData(), getSyncData(), getSyncStFlag()); -// os << buf << std::endl; - if( msg_print_Cout == outType) - std::cout << buf << std::endl; - else if( msg_print_File == outType ) - os << buf << std::endl; - break; - case MSG_AUX: - snprintf(buf, sizeof(buf), - "Msg:%u Roc:%04x ", getMessageType(), getRocNumber()); -// os << buf; - if( msg_print_Cout == outType) - std::cout << buf; - else if( msg_print_File == outType ) - os << buf; - - snprintf(buf, sizeof(buf), - "AUX @%15.9f Nx:%1u Chn:%d Ts:%5d%s Falling:%d Overflow:%d", - timeInSec, getAuxNxNum(), getAuxChNum(), getAuxTs(), - ((getAuxEpochLSB() != (epoch&0x1)) ? "-e" : " "), - getAuxFalling(), getAuxOverflow()); -// os << buf << std::endl; - if( msg_print_Cout == outType) - std::cout << buf << std::endl; - else if( msg_print_File == outType ) - os << buf << std::endl; - break; - case MSG_EPOCH2: - snprintf(buf, sizeof(buf), - "Msg:%u Roc:%04x ", getMessageType(), getRocNumber()); -// os << buf; - if( msg_print_Cout == outType) - std::cout << buf; - else if( msg_print_File == outType ) - os << buf; - - snprintf(buf, sizeof(buf), - "EPO2 @%17.11f Get4:%2d Epoche2:%10u 0x%08x StampTime:%2d Sync:%x Dataloss:%x Epochloss:%x Epochmissmatch:%x", - timeInSec, getEpoch2ChipNumber(), getEpoch2Number(), getEpoch2Number(), - getEpoch2StampTime(), getEpoch2Sync(), getEpoch2DataLost(), getEpoch2EpochLost(), getEpoch2EpochMissmatch()); -// os << buf << std::endl; - if( msg_print_Cout == outType) - std::cout << buf << std::endl; - else if( msg_print_File == outType ) - os << buf << std::endl; - break; - case MSG_GET4: - snprintf(buf, sizeof(buf), - "Msg:%u Roc:%04x ", getMessageType(), getRocNumber()); -// os << buf; - if( msg_print_Cout == outType) - std::cout << buf; - else if( msg_print_File == outType ) - os << buf; - - snprintf(buf, sizeof(buf), - "Get4 @%17.11f Get4:%2d Chn:%3d Edge:%1d Ts:%7d CRC8:%3d", - timeInSec, getGet4Number(), getGet4ChNum(), getGet4Edge(), getGet4Ts(), getGet4CRC() ); -// os << buf << std::endl; - if( msg_print_Cout == outType) - std::cout << buf << std::endl; - else if( msg_print_File == outType ) - os << buf << std::endl; - break; - default: - kind = kind & ~msg_print_Human; - if (kind==0) kind = msg_print_Prefix | msg_print_Data; - } - - // return, if message was correctly printed in human-readable form - if (kind & msg_print_Human) return; - } - - if (kind & msg_print_Prefix) { - snprintf(buf, sizeof(buf), "Msg:%2u Roc:%04x ", getMessageType(), getRocNumber()); -// os << buf; - if( msg_print_Cout == outType) - std::cout << buf; - else if( msg_print_File == outType ) - os << buf; - } - - if (kind & msg_print_Data) { - const uint8_t* arr = reinterpret_cast<const uint8_t*> ( &data ); - switch (getMessageType()) { - case MSG_NOP: - snprintf(buf, sizeof(buf), "NOP (raw %02X:%02X:%02X:%02X:%02X:%02X)", - arr[0], arr[1], arr[2], arr[3], arr[4], arr[5]); - break; - case MSG_HIT: - snprintf(buf, sizeof(buf), "Nx:%1u Chn:%02x Ts:%04x Last:%1x Msb:%1x Adc:%03x Pup:%1x Oflw:%1x", - getNxNumber(), getNxChNum(), getNxTs(), getNxLastEpoch(), - getNxLtsMsb(), getNxAdcValue(), getNxPileup(), - getNxOverflow()); - break; - case MSG_EPOCH: - snprintf(buf, sizeof(buf), "Nx:%1u Epoch:%08x Missed:%02x", - getEpochNxNum(), getEpochNumber(), getEpochMissed()); - break; - case MSG_SYNC: - snprintf(buf, sizeof(buf), "Nx:%1u SyncChn:%1x EpochLSB:%1x Ts:%04x Data:%06x Flag:%1x", - getSyncNxNum(), getSyncChNum(), getSyncEpochLSB(), getSyncTs(), - getSyncData(), getSyncStFlag()); - break; - case MSG_AUX: - snprintf(buf, sizeof(buf), "Nx:%1u AuxChn:%02x EpochLSB:%1x Ts:%04x Falling:%1x Overflow:%1x", - getAuxNxNum(), getAuxChNum(), getAuxEpochLSB(), getAuxTs(), - getAuxFalling(), getAuxOverflow()); - break; - case MSG_EPOCH2: - snprintf(buf, sizeof(buf), "Get4:0x%02x Link: %1u Epoche2:0x%08x StampTime:0x%x Sync:%x Dataloss:%x Epochloss:%x Epochmissmatch:%x", - getGdpbGenChipId(), getGdpbEpLinkId(), getGdpbEpEpochNb(), getGdpbEpStampTs(), getGdpbEpSync(), - getGdpbEpDataLoss(), getGdpbEpEpochLoss(), getGdpbEpMissmatch()); - break; - case MSG_GET4: - snprintf(buf, sizeof(buf), "Get4:0x%02x Chn:%1x Edge:%1x Ts:0x%05x CRC8:0x%02x", - getGdpbGenChipId(), getGdpbHitChanId(), getGdpbHit24Edge(), getGdpbHitFullTs(), getGdpbHitCrc() ); - break; - case MSG_SYS: { - char sysbuf[256]; - - switch (getSysMesType()) { - case SYSMSG_DAQ_START: - snprintf(sysbuf, sizeof(sysbuf), "DAQ started"); - break; - case SYSMSG_DAQ_FINISH: - snprintf(sysbuf, sizeof(sysbuf), "DAQ finished"); - break; - case SYSMSG_NX_PARITY: { - uint32_t nxb3_data = getSysMesData(); - uint32_t nxb3_flg = (nxb3_data>>31) & 0x01; - uint32_t nxb3_val = (nxb3_data>>24) & 0x7f; - uint32_t nxb2_flg = (nxb3_data>>23) & 0x01; - uint32_t nxb2_val = (nxb3_data>>16) & 0x7f; - uint32_t nxb1_flg = (nxb3_data>>15) & 0x01; - uint32_t nxb1_val = (nxb3_data>>8 ) & 0x7f; - uint32_t nxb0_flg = (nxb3_data>>7 ) & 0x01; - uint32_t nxb0_val = (nxb3_data ) & 0x7f; - snprintf(sysbuf, sizeof(sysbuf),"Nx:%1x %1d%1d%1d%1d:%02x:%02x:%02x:%02x nX parity error", getNxNumber(), - nxb3_flg, nxb2_flg, nxb1_flg, nxb0_flg, - nxb3_val, nxb2_val, nxb1_val, nxb0_val); - } - break; - case SYSMSG_SYNC_PARITY: - snprintf(sysbuf, sizeof(sysbuf), "SYNC parity error "); - break; - case SYSMSG_DAQ_RESUME: - snprintf(sysbuf, sizeof(sysbuf), "DAQ resume after high/low water"); - break; - case SYSMSG_FIFO_RESET: - snprintf(sysbuf, sizeof(sysbuf), "FIFO reset"); - break; - case SYSMSG_USER: { - const char* subtyp = ""; - if (getSysMesData()==SYSMSG_USER_CALIBR_ON) subtyp = "Calibration ON"; else - if (getSysMesData()==SYSMSG_USER_CALIBR_OFF) subtyp = "Calibration OFF"; else - if (getSysMesData()==SYSMSG_USER_RECONFIGURE) subtyp = "Reconfigure"; - snprintf(sysbuf, sizeof(sysbuf), "User message 0x%08x %s", getSysMesData(), subtyp); - break; - } - case SYSMSG_PACKETLOST: - snprintf(sysbuf, sizeof(sysbuf), "Packet lost"); - break; - case SYSMSG_GET4_EVENT: - { - break; - } // - case SYSMSG_CLOSYSYNC_ERROR: - snprintf(sysbuf, sizeof(sysbuf), "Closy synchronization error"); - break; - case SYSMSG_TS156_SYNC: - snprintf(sysbuf, sizeof(sysbuf), "156.25MHz timestamp reset"); - break; - case SYSMSG_GET4V1_32BIT_0: - case SYSMSG_GET4V1_32BIT_1: - case SYSMSG_GET4V1_32BIT_2: - case SYSMSG_GET4V1_32BIT_3: - case SYSMSG_GET4V1_32BIT_4: - case SYSMSG_GET4V1_32BIT_5: - case SYSMSG_GET4V1_32BIT_6: - case SYSMSG_GET4V1_32BIT_7: - case SYSMSG_GET4V1_32BIT_8: - case SYSMSG_GET4V1_32BIT_9: - case SYSMSG_GET4V1_32BIT_10: - case SYSMSG_GET4V1_32BIT_11: - case SYSMSG_GET4V1_32BIT_12: - case SYSMSG_GET4V1_32BIT_13: - case SYSMSG_GET4V1_32BIT_14: - case SYSMSG_GET4V1_32BIT_15: - { - break; - } // case SYSMSG_GET4V1_32BIT + channel! - default: - snprintf(sysbuf, sizeof(sysbuf), "unknown system message type "); - } // switch (getSysMesType()) - - snprintf(buf, sizeof(buf), "SysType:%2x Data:%8x : %s", getSysMesType(), getSysMesData(), sysbuf); - - break; - } // case MSG_SYS: - case MSG_GET4_SLC: - { - // GET4 slow control message, new "true" ROC support - snprintf(buf, sizeof(buf), - "Get4 Slow control, chip %02d => Chan:%01d Edge:%01d Type:%01x Data:0x%06x CRC:0x%02x", - getGdpbGenChipId(), 0x0, 0x0, 0x0, getGdpbSlcData(), getGdpbSlcCrc() ); - break; - } // case MSG_GET4_SLC: - case MSG_GET4_32B: - { - // 32b GET4 data event, new "true" ROC support - snprintf(buf, sizeof(buf), - "Get4 32 bits, Chip:0x%02x Dll %1d Channel %1d Ts:0x%03x Ft:0x%02x Tot:0x%02x", - getGdpbGenChipId(), getGdpbHit32DllLck(), getGdpbHitChanId(), - getGdpbHitCoarse(), getGdpbHitFineTs(), getGdpbHit32Tot() ); - - break; - } // case MSG_GET4_32B: - case MSG_GET4_SYS: - { - // GET4 system message, new "true" ROC support - char sysbuf[256]; - - switch( getGdpbSysSubType() ) - { - case SYSMSG_GET4_EVENT: - { - snprintf(sysbuf, sizeof(sysbuf), - "Get4:0x%02x Ch:0x%01x Edge:%01x Unused:%06x ErrCode:0x%02x - GET4 V1 Error Event", - getGdpbGenChipId(), getGdpbSysErrChanId(), getGdpbSysErrEdge(), getGdpbSysErrUnused(), getGdpbSysErrData()); - break; - } // - case SYSMSG_CLOSYSYNC_ERROR: - snprintf(sysbuf, sizeof(sysbuf), "Closy synchronization error"); - break; - case SYSMSG_TS156_SYNC: - snprintf(sysbuf, sizeof(sysbuf), "156.25MHz timestamp reset"); - break; - case SYSMSG_GDPB_UNKWN: - snprintf(sysbuf, sizeof(sysbuf), "Unknown GET4 message, data: 0x%08x", getGdpbSysUnkwData()); - break; - default: - snprintf(sysbuf, sizeof(sysbuf), "unknown system message type %u", getGdpbSysSubType()); - } // switch( getGdpbSysSubType() ) - snprintf(buf, sizeof(buf), "%s", sysbuf); - - break; - } // case MSG_GET4_SYS: - case MSG_STAR_TRI: - { - // STAR trigger token, spread over 4 messages - switch( getStarTrigMsgIndex() ) - { - case 0: - { - snprintf(buf, sizeof(buf), -// "STAR token A, gDPB TS MSB bits: 0x%010llx000000", -// getGdpbTsMsbStarA() ); - "STAR token A, gDPB TS MSB bits: 0x%s000000", - FormatHexPrintout( getGdpbTsMsbStarA(), 10, '0').c_str() ); - break; - } // case 1st message: - case 1: - { - snprintf(buf, sizeof(buf), -// "STAR token B, gDPB TS LSB bits: 0x0000000000%06llx, STAR TS MSB bits: 0x%04llx000000000000", -// getGdpbTsLsbStarB(), getStarTsMsbStarB() ); - "STAR token B, gDPB TS LSB bits: 0x0000000000%s, STAR TS MSB bits: 0x%s000000000000", - FormatHexPrintout( getGdpbTsLsbStarB(), 6, '0').c_str(), FormatHexPrintout( getStarTsMsbStarB(), 4, '0').c_str() ); - break; - } // case 2nd message: - case 2: - { - snprintf(buf, sizeof(buf), -// "STAR token C, , STAR TS Mid bits: 0x0000%010llx00", -// getStarTsMidStarC() ); - "STAR token C, , STAR TS Mid bits: 0x0000%s00", - FormatHexPrintout( getStarTsMidStarC(), 10, '0').c_str() ); - break; - } // case 3rd message: - case 3: - { - snprintf(buf, sizeof(buf), -// "STAR token D, , STAR TS LSB bits: 0x00000000000000%02llx" - "STAR token D, , STAR TS LSB bits: 0x00000000000000%s" - ", Token: %03x, DAQ: %1x; TRG:%1x", -// getStarTsLsbStarD(), - FormatHexPrintout( getStarTsLsbStarD(), 2, '0').c_str(), - getStarTokenStarD(), getStarDaqCmdStarD(), getStarTrigCmdStarD() ); - break; - } // case 4th message: - } // switch( getStarTrigMsgIndex() ) - - break; - } // case MSG_STAR_TRI: - default: - snprintf(buf, sizeof(buf), "Error - unexpected MessageType: %1x, full data %08X::%08X", - getMessageType(), getField(32, 32), getField(0, 32) ); - } - } - -// os << buf << std::endl; - if( msg_print_Cout == outType) - std::cout << buf << std::endl; - else if( msg_print_File == outType ) - os << buf << std::endl; -// else LOG(info) << sLogBuff << buf; -} - -uint32_t ngdpb::Message::RawSize(int fmt) -{ - switch (fmt) { - case formatNormal: return 8; - default: - std::cerr << "ngdpb::Message::RawSize => " - << " Deprecated format, nothing done!!" - << std::endl; - return 0; - } - return 8; -} - -bool ngdpb::Message::assign(void* src, int fmt) -{ - switch (fmt) { - case formatNormal: - memcpy(&data, src, 8); - return true; - default: - std::cerr << "ngdpb::Message::assign => " - << " Deprecated format, nothing done!!" - << std::endl; - return false; - } - - return false; -} - -bool ngdpb::Message::copyto(void* tgt, int fmt) -{ - switch (fmt) { - case formatNormal: - memcpy(tgt, &data, 8); - return true; - default: - std::cerr << "ngdpb::Message::assign => " - << " Deprecated format, nothing done!!" - << std::endl; - return false; - } - - return false; - -} - -/* -double ngdpb::Message::CalcGet4V10R24HitTimeDiff( - uint32_t epochA, uint32_t epochB, Message& messB) -{ - Double_t dTimeDiff = 0.0; - // if conditions needed to deal with unsigned int at full resolution - if( epochA < epochB) - dTimeDiff -= - ( epochB - epochA )*get4v1x::kdEpochInPs; - else dTimeDiff += - ( epochA - epochB )*get4v1x::kdEpochInPs; - // if conditions needed to deal with unsigned int at full resolution - if( this->getGet4Ts() < messB.getGet4Ts() ) - dTimeDiff -= - ( messB.getGet4Ts() - this->getGet4Ts() - )*get4v1x::kdBinSize; - else dTimeDiff += - ( this->getGet4Ts() - messB.getGet4Ts() - )*get4v1x::kdBinSize; - - return dTimeDiff; -} - -double ngdpb::Message::CalcGet4V10R32HitTimeDiff( - uint32_t epochA, uint32_t epochB, Message& messB) -{ - Double_t dTimeDiff = 0.0; - // if conditions needed to deal with unsigned int at full resolution - if( epochA < epochB) - dTimeDiff -= - ( epochB - epochA )*get4v1x::kdEpochInPs; - else dTimeDiff += - ( epochA - epochB )*get4v1x::kdEpochInPs; - // if conditions needed to deal with unsigned int at full resolution - if( this->getGet4V10R32HitTimeBin() < messB.getGet4V10R32HitTimeBin() ) - dTimeDiff -= - ( messB.getGet4V10R32HitTimeBin() - this->getGet4V10R32HitTimeBin() - )*get4v1x::kdBinSize; - else dTimeDiff += - ( this->getGet4V10R32HitTimeBin() - messB.getGet4V10R32HitTimeBin() - )*get4v1x::kdBinSize; - - return dTimeDiff; -} -*/ -//---------------------------------------------------------------------------- -/* -//! strict weak ordering operator, including epoch for both messages -bool ngdpb::FullMessage::operator<(const FullMessage& other) const -{ - if( other.fuExtendedEpoch == this->fuExtendedEpoch ) - // Same epoch => use Message (base) class ordering operator - return this->Message::operator<( other ); - else return this->fuExtendedEpoch < other.fuExtendedEpoch; - -} -*/ diff --git a/beamtime/data/raw/rocMess_wGet4v1.h b/beamtime/data/raw/rocMess_wGet4v1.h deleted file mode 100644 index 50d424f3ca01af594a8ea64457cfe7740dd15a9e..0000000000000000000000000000000000000000 --- a/beamtime/data/raw/rocMess_wGet4v1.h +++ /dev/null @@ -1,714 +0,0 @@ -#ifndef ROC_MESS_WGET4V1X_DEF_H -#define ROC_MESS_WGET4V1X_DEF_H - -#include <stdint.h> -#include <iostream> - -namespace get4v1x { - // Size of one clock cycle (=1 coarse bin) - const double kdClockCycleSize = 6250.0; //[ps] - const double kdClockCycleSizeNs = kdClockCycleSize / 1000.0; //[ns] - // TODO:For now make 100ps default, maybe need later an option for it - const double kdTotBinSize = 50.0; //ps - - const uint32_t kuFineTime = 0x0000007F; // Fine Counter value - const uint32_t kuFtShift = 0; // Fine Counter offset - const uint32_t kuCoarseTime = 0x0007FF80; // Coarse Counter value - const uint32_t kuCtShift = 7; // Coarse Counter offset - const uint32_t kuCtSize = 12; // Coarse Counter size in bits - - const uint32_t kuFineCounterSize = ( (kuFineTime>>kuFtShift)+1 ); - const uint32_t kuCoarseCounterSize = ( (kuCoarseTime>>kuCtShift)+1 ); - const uint32_t kuCoarseOverflowTest = kuCoarseCounterSize / 2 ; // Limit for overflow check - const uint32_t kuTotCounterSize = 256; - - // Nominal bin size of NL are neglected - const double kdBinSize = kdClockCycleSize / static_cast<double>(kuFineCounterSize); - // Epoch Size in bins - const uint32_t kuEpochInBins = kuFineTime + kuCoarseTime + 1; - // Epoch Size in ps - // alternatively: (kiCoarseTime>>kiCtShift + 1)*kdClockCycleSize - const double kdEpochInPs = static_cast<double>(kuEpochInBins)*kdBinSize; - const double kdEpochInNs = kdEpochInPs / 1000.0; - - // Epoch counter size in epoch - const uint32_t kuEpochCounterSz = 0x7FFFFFFF; - const double kdEpochCycleInS = static_cast<double>(kuEpochCounterSz) * (kdEpochInNs/1e9); - - const uint32_t kuChipIdMergedEpoch = 63; // 0x3F -} - -namespace ngdpb { - - - enum MessageFormat { - formatNormal = 4 // new message format with little-endian coding, 16-bit roc number (default) - }; - - enum MessageTypes { - MSG_NOP = 0, - MSG_HIT = 1, - MSG_EPOCH = 2, - MSG_SYNC = 3, - MSG_AUX = 4, - MSG_EPOCH2 = 5, - MSG_GET4 = 6, - MSG_SYS = 7, - MSG_GET4_SLC = 8, - MSG_GET4_32B = 9, - MSG_GET4_SYS = 10, - MSG_STAR_TRI = 0xD - }; - - enum SysMessageTypes { - SYSMSG_DAQ_START = 1, // indicates start daq in data stream - SYSMSG_DAQ_FINISH = 2, // stop daq - SYSMSG_NX_PARITY = 3, // nx_parity error - SYSMSG_SYNC_PARITY = 4, // sync parity error - SYSMSG_DAQ_RESUME = 5, // daq resume due to low/high water marker, only in udp case - SYSMSG_FIFO_RESET = 6, // FPGA fifo reset - SYSMSG_USER = 7, // user define message, generated by writing into ROC_ADDSYSMSG register - SYSMSG_PCTIME = 8, // contains value of time() function, indicates when message was created on PC - SYSMSG_ADC = 9, // contains feb1d (1 bit), channel id (7 bit) and adc value (24 bit), measured on PC - SYSMSG_PACKETLOST = 10, // inserted by udp transport when packet was lost at this place - SYSMSG_GET4_EVENT = 11, // GET4 event - SYSMSG_CLOSYSYNC_ERROR = 12, // added to data stream when the closy-sync-strobe does not match the rocs 156MHz timestamp counter - SYSMSG_TS156_SYNC = 13, // added when 156MHz timestamp counter is reset by a DLM - SYSMSG_GDPB_UNKWN = 15, // Raw data from gDPB in case of unknown message type from GET4 - SYSMSG_GET4V1_32BIT_0 = 240, // Get4 V1.0, 32bit mode, Raw messages - SYSMSG_GET4V1_32BIT_1 = 241, // Get4 V1.0, 32bit mode, Raw messages - SYSMSG_GET4V1_32BIT_2 = 242, // Get4 V1.0, 32bit mode, Raw messages - SYSMSG_GET4V1_32BIT_3 = 243, // Get4 V1.0, 32bit mode, Raw messages - SYSMSG_GET4V1_32BIT_4 = 244, // Get4 V1.0, 32bit mode, Raw messages - SYSMSG_GET4V1_32BIT_5 = 245, // Get4 V1.0, 32bit mode, Raw messages - SYSMSG_GET4V1_32BIT_6 = 246, // Get4 V1.0, 32bit mode, Raw messages - SYSMSG_GET4V1_32BIT_7 = 247, // Get4 V1.0, 32bit mode, Raw messages - SYSMSG_GET4V1_32BIT_8 = 248, // Get4 V1.0, 32bit mode, Raw messages - SYSMSG_GET4V1_32BIT_9 = 249, // Get4 V1.0, 32bit mode, Raw messages - SYSMSG_GET4V1_32BIT_10 = 250, // Get4 V1.0, 32bit mode, Raw messages - SYSMSG_GET4V1_32BIT_11 = 251, // Get4 V1.0, 32bit mode, Raw messages - SYSMSG_GET4V1_32BIT_12 = 252, // Get4 V1.0, 32bit mode, Raw messages - SYSMSG_GET4V1_32BIT_13 = 253, // Get4 V1.0, 32bit mode, Raw messages - SYSMSG_GET4V1_32BIT_14 = 254, // Get4 V1.0, 32bit mode, Raw messages - SYSMSG_GET4V1_32BIT_15 = 255, // Get4 V1.0, 32bit mode, Raw messages - }; - - enum SysMessageUserTypes { - SYSMSG_USER_CALIBR_ON = 7, - SYSMSG_USER_CALIBR_OFF = 8, - SYSMSG_USER_RECONFIGURE = 9, - SYSMSG_USER_ROCFEET_SYNC = 16 - }; - - enum MessagePrintMask { - msg_print_Prefix = 1, - msg_print_Data = 2, - msg_print_Hex = 4, - msg_print_Human = 8 - }; - - enum MessagePrintType { - msg_print_Cout = 1, - msg_print_FairLog = 2, - msg_print_File = 3 - }; - - enum Get4Message32bTypes { - GET4_32B_EPOCH = 0, - GET4_32B_SLCM = 1, - GET4_32B_ERROR = 2, - GET4_32B_DATA = 3 - }; - - enum Get4Message32bSlC { - GET4_32B_SLC_SCALER = 0, - GET4_32B_SLC_DEADT = 1, - GET4_32B_SLC_SPIREAD = 2, - GET4_32B_SLC_START_SEU = 3 - }; - - enum Get4Message32bErrors { - GET4_V1X_ERR_READ_INIT = 0x00, - GET4_V1X_ERR_SYNC = 0x01, - GET4_V1X_ERR_EP_CNT_SYNC = 0x02, - GET4_V1X_ERR_EP = 0x03, - GET4_V1X_ERR_FIFO_WRITE = 0x04, - GET4_V1X_ERR_LOST_EVT = 0x05, - GET4_V1X_ERR_CHAN_STATE = 0x06, - GET4_V1X_ERR_TOK_RING_ST = 0x07, - GET4_V1X_ERR_TOKEN = 0x08, - GET4_V1X_ERR_READOUT_ERR = 0x09, - GET4_V1X_ERR_SPI = 0x0A, - GET4_V1X_ERR_DLL_LOCK = 0x0B, - GET4_V1X_ERR_DLL_RESET = 0x0C, - GET4_V1X_ERR_TOT_OVERWRT = 0x11, - GET4_V1X_ERR_TOT_RANGE = 0x12, - GET4_V1X_ERR_EVT_DISCARD = 0x13, - GET4_V1X_ERR_ADD_RIS_EDG = 0x14, - GET4_V1X_ERR_UNPAIR_FALL = 0x15, - GET4_V1X_ERR_SEQUENCE_ER = 0x16, - GET4_V1X_ERR_UNKNOWN = 0x7F - }; - - // Max nb of each external trigger signal type - const uint32_t kuMaxSync = 2; // <- MAX_SYNC - const uint32_t kuMaxAux = 4; // <- MAX_AUX - - class Message { - - protected: - uint64_t data; // main and only storage field for the message - - public: - Message() : data(0) {} - - Message(const Message& src) : data(src.data) {} - - Message( uint64_t dataIn ) : data(dataIn) {} - - virtual ~Message() {}; - - void assign(const Message& src) { data = src.data; } - - Message& operator=(const Message& src) { assign(src); return *this; } - - inline void reset() { data = 0; } - - inline uint64_t getData() const { return data; } - inline void setData( uint64_t value) { data = value; } - - inline uint64_t getFieldLong(uint32_t shift, uint32_t len) const - { return (data >> shift) & (((static_cast<uint64_t>(1)) << len) - 1); } - - inline uint32_t getField(uint32_t shift, uint32_t len) const - { return (data >> shift) & (((static_cast<uint32_t>(1)) << len) - 1); } - - inline void setField(uint32_t shift, uint32_t len, uint32_t value) - { data = (data & ~((((static_cast<uint64_t>(1)) << len) - 1) << shift)) | ((static_cast<uint64_t>(value)) << shift); } - - inline uint8_t getBit(uint32_t shift) const - { return (data >> shift) & 1; } - - inline void setBit(uint32_t shift, uint8_t value) - { data = value ? (data | ((static_cast<uint64_t>(1)) << shift)) : (data & ~((static_cast<uint64_t>(1)) << shift)) ; } - - - inline uint32_t getFieldBE(uint32_t shift, uint32_t len) const - { return (dataBE() >> shift) & (((static_cast<uint32_t>(1)) << len) - 1); } - inline uint8_t getBitBE(uint32_t shift) const - { return (dataBE() >> shift) & 1; } - inline uint64_t dataBE() const - { return ((data&0x00000000000000FF)<<56)+ - ((data&0x000000000000FF00)<<40)+ - ((data&0x0000000000FF0000)<<24)+ - ((data&0x00000000FF000000)<< 8)+ - ((data>> 8)&0x00000000FF000000)+ - ((data>>24)&0x0000000000FF0000)+ - ((data>>40)&0x000000000000FF00)+ - ((data>>56)&0x00000000000000FF); - } - - // --------------------------- common fields --------------------------------- - - //! Returns the message type. Valid for all message types. 4 bit - inline uint8_t getMessageType() const { return getField(0, 4); } - - //! Returns the number of the sending ROC. Valid for all message types. - /*! - * The field has full 16 bits and allows to aggregate data of up to 64K ROC's - * in one message stream. - */ - inline uint16_t getRocNumber() const { return getField(48, 16); } - - //! Sets the message type field in the current message - inline void setMessageType(uint8_t v) { setField(0, 4, v); } - - //! Sets the ROC number field in the current message - inline void setRocNumber(uint16_t v) { setField(48, 16, v); } - - - // ---------- nXYTER Hit data access methods ---------------- - - //! For Hit data: Returns nXYTER number (2 bit field) - /*! - * A nDPB can support up to 4 nXYTER chips. - * This field identifies FEB as well as chip.. - */ -// inline uint8_t getNxNumber() const { return getField(6, 2); } - inline uint8_t getNxNumber() const { return getField(4, 2); } - - //! For Hit data: Returns 3 most significant bits of ROC LTS (3 bit field) - /*! - * The 3 MSBs of the ROC local time stamp counter at the time of data - * capture are stored in this field. A comparison of this number, - * which reflects the time of readout, and the 3 MSBs of the timestamp - * (returned by getNxLtsMsb() const), which reflects the time of the - * hit, allows to estimate the time the hit stayed in the nXYTER internal - * FIFOs. This in turn gives an indication of the data load in the - * nXYTER. - */ - inline uint8_t getNxLtsMsb() const { return getField(8, 3); } - - //! For Hit data: Returns nXYTER time stamp (14 bit field) - /*! - * Raw timestamp as delivered by the nXYTER. The last-epoch flag - * (returned by getNxLastEpoch() const) determines whether the - * hit belongs to the current or the last epoch. Use the - * getMsgFullTime(uint32_t) const method to determine the - * expanded and adjusted timestamp. - */ - inline uint16_t getNxTs() const { return getField(11, 14); } - - //! For Hit data: Returns nXYTER channel number (7 bit field) - inline uint8_t getNxChNum() const { return getField(25, 7); } - - // 1 bit unused - - //! For Hit data: Returns ADC value (12 bit field) - inline uint16_t getNxAdcValue() const { return getField(33, 12); } - - //! For Hit data: Returns nXYTER pileup flag (1 bit field) - /*! - * This flag is set when the nXYTER trigger circuit detected two hits - * during the peak sense time interval of the slow amplitude channel. - * This flag indicates that separation between two hits was smaller than - * what can be handled by the amplitude channel. \sa getNxOverflow() const - */ - inline uint8_t getNxPileup() const { return getBit(45); } - - //! For Hit data: Returns nXYTER overflow flag (1 bit field) - /*! - * This flag is set when a nXYTER channels detects a hit but this hit - * can't be stored because the 4 stage channel FIFO is full. This flag - * indicates that the hit data rate was higher than the chip can handle - * over a longer time. \sa getNxPileup() const - */ - inline uint8_t getNxOverflow() const { return getBit(46); } - - //! For Hit data: Returns nXYTER last-epoch flag (1 bit field) - /*! - * This flag is set when the hit actually belong to the previous epoch. - * Use the getMsgFullTime(uint32_t) const method to determine the - * expanded and adjusted timestamp. - */ - inline uint8_t getNxLastEpoch() const { return getBit(47); } - - - //! For Hit data: Sets nXYTER number (2 bit field) - inline void setNxNumber(uint8_t v) { setField(6, 2, v); } - - //! For Hit data: Sets 3 most significant bits of ROC LTS (3 bit field) - inline void setNxLtsMsb(uint8_t v) { setField(8, 3, v); } - - //! For Hit data: Sets nXYTER time stamp (14 bit field) - inline void setNxTs(uint16_t v) { setField(11, 14, v); } - - //! For Hit data: Sets nXYTER channel number (7 bit field) - inline void setNxChNum(uint8_t v) { setField(25, 7, v); } - - // 1 bit unused - - //! For Hit data: Sets ADC value (12 bit field) - inline void setNxAdcValue(uint16_t v) { setField(33, 12, v); } - - //! For Hit data: Sets nXYTER pileup flag (1 bit field) - inline void setNxPileup(uint8_t v) { setBit(45, v); } - - //! For Hit data: Sets nXYTER overflow flag (1 bit field) - inline void setNxOverflow(uint8_t v) { setBit(46,v ); } - - //! For Hit data: Sets nXYTER last-epoch flag (1 bit field) - inline void setNxLastEpoch(uint8_t v) { setBit(47, v); } - - // ---------- Epoch marker access methods ------------ - - //! For Epoch data: Returns nXYTER number (2 bit field) - /*! - * A nDPB can support up to 4 nXYTER chips. - * This field identifies FEB as well as chip. - */ - inline uint8_t getEpochNxNum() const { return getField(4, 2); } - - // 2 bit unused - - //! For Epoch data: Returns current epoch number (32 bit field) - // inline uint32_t getEpochNumber() const { return getField(8, 32); } - // on some machines 32-bit field is not working - inline uint32_t getEpochNumber() const { return data >> 8; } - - - //! For Epoch data: Returns number of missed hits (8 bit field) - inline uint8_t getEpochMissed() const { return getField(40, 8); } - - //! For Epoch data: Sets epoch number (32 bit field) - inline void setEpochNumber(uint32_t v) { setField(8, 32, v); } - - //! For Epoch data: Sets missed hits count (8 bit field) - inline void setEpochMissed(uint8_t v) { setField(40, 8, v); } - - - // ---------- Sync marker access methods ------------- - - //! For Sync data: Returns nXYTER number (2 bit field) - /*! - * A nDPB can support up to 4 nXYTER chips. - * This field identifies FEB as well as chip. - */ - inline uint8_t getSyncNxNum() const { return getField(4, 2); } - - //! For Sync data: Returns sync channel number (2 bit field) - inline uint8_t getSyncChNum() const { return getField(6, 2); } - - //! For Sync data: Returns sync time stamp (13 bit field, 2 ns bins) - inline uint16_t getSyncTs() const { return getField(8, 13) << 1; } - - //! For Sync data: Returns LSB of true epoch (1 bit field) - inline uint8_t getSyncEpochLSB() const { return getBit(21); } - - //! For Sync data: Returns sync message data (24 bit field) - inline uint32_t getSyncData() const { return getField(22, 24); } - - //! For Sync data: Returns sync status flags (2 bit field) - inline uint8_t getSyncStFlag() const { return getField(46, 2); } - - - //! For Sync data: Set sync channel number (2 bit field) - inline void setSyncChNum(uint8_t v) { setField(6, 2, v); } - - //! For Sync data: Set sync time stamp (13 bit field, 2 ns bins ) - inline void setSyncTs(uint16_t v) { setField(8, 13, v >> 1); } - - //! For Sync data: Set LSB of true epoch (1 bit field) - inline void setSyncEpochLSB(uint8_t v) { setBit(21, v); } - - //! For Sync data: Set sync message data (24 bit field) - inline void setSyncData(uint32_t v) { setField(22, 24, v); } - - //! For Sync data: Set sync status flags (2 bit field) - inline void setSyncStFlag(uint8_t v) { setField(46, 2, v); } - - - // ---------- AUX marker access methods -------------- - - //! For AUX data: Returns nXYTER number (2 bit field) - /*! - * A nDPB can support up to 4 nXYTER chips. - * This field identifies FEB as well as chip. - */ - inline uint8_t getAuxNxNum() const { return getField(4, 2); } - - //! For Aux data: Returns aux channel number (7 bit field) - inline uint8_t getAuxChNum() const { return getField(6, 7); } - - //! For Aux data: Returns aux time stamp (13 bit field, 2 ns bins) - inline uint16_t getAuxTs() const { return getField(13, 13) << 1; } - - //! For Aux data: Returns LSB of true epoch (1 bit field) - inline uint8_t getAuxEpochLSB() const { return getBit(26); } - - //! For Aux data: Returns falling edge flag (1 bit flag) - inline uint8_t getAuxFalling() const { return getBit(27); } - - //! For Aux data: Returns overflow flag (1 bit field) - inline uint8_t getAuxOverflow() const { return getBit(28); } - - - //! For Aux data: Set aux channel number (7 bit field) - inline void setAuxChNum(uint8_t v) { setField(6, 7, v); } - - //! For Aux data: Set aux time stamp (13 bit field) - inline void setAuxTs(uint16_t v) { setField(13, 13, v >> 1); } - - //! For Aux data: Set LSB of true epoch (1 bit field) - inline void setAuxEpochLSB(uint8_t v) { setBit(26, v); } - - //! For Aux data: Set falling edge flag (1 bit flag) - inline void setAuxFalling(uint8_t v) { setBit(27, v); } - - //! For Aux data: Set overflow flag (1 bit field) - inline void setAuxOverflow(uint8_t v) { setBit(28, v); } - - // ---------- Epoch2 marker access methods ------------ - - //! For Epoch2 data: Returns epoch missmatch flag (set in ROC when - //! ROC timestamp and timestamp send by GET4 did not match) (1 bit field) - inline uint32_t getEpoch2EpochMissmatch() const { return getBit(4); } - - //! For Epoch2 data: Returns epoch-lost flag (1 bit field) - inline uint32_t getEpoch2EpochLost() const { return getBit(5); } - - //! For Epoch2 data: Returns data-lost flag (1 bit field) - inline uint32_t getEpoch2DataLost() const { return getBit(6); } - - //! For Epoch2 data: Returns sync flag (1 bit field) - inline uint32_t getEpoch2Sync() const { return getBit(7); } - - //! For Epoch2 data: Returns the LTS156 bits 11 to 8. This - //! gives information at what time in the Epoche the epoche number - //! was set (2 bit field) - inline uint32_t getEpoch2StampTime() const { return getField(8, 2); } - - //! For Epoch2 data: Returns the epoch number (32 bit field) - // on some machines 32-bit field is not working - inline uint32_t getEpoch2Number() const { return (data >> 10) & 0xFFFFFFFF; } - - //! For Epoch2 data: Returns the number of the GET4 chip that send - //! the epoche message (6 bit field) - inline uint32_t getEpoch2ChipNumber() const { return getField(42, 6); } - - //! For Epoch2 data: Set epoch missmatch flag (1 bit field) - inline void setEpoch2EpochMissmatch(uint32_t v) { setBit(4, v); } - - //! For Epoch2 data: Set epoch-lost flag (1 bit field) - inline void setEpoch2EpochLost(uint32_t v) { setBit(5, v); } - - //! For Epoch2 data: Set data-lost flag (1 bit field) - inline void setEpoch2DataLost(uint32_t v) { setBit(6, v); } - - //! For Epoch2 data: Set sync flag (1 bit field) - inline void setEpoch2Sync(uint32_t v) { setBit(7, v); } - - //! For Epoch2 data: Set the LTS156 bits 11 to 8. This - //! gives information at what time in the Epoche the epoche number - //! was set (2 bit field) - inline void setEpoch2StampTime(uint32_t v) { setField(8, 2, v); } - - //! For Epoch2 data: Set the epoch number (32 bit field) - inline void setEpoch2Number(uint32_t v) { setField(10, 32, v); } - - //! For Epoch2 data: Set the number of the GET4 chip that send - //! the epoche message (6 bit field) - inline void setEpoch2ChipNumber(uint32_t v) { setField(42, 6, v); } - - // ---------- Get4 24b Hit data access methods ---------------- - - //! For Get4 data: Returns Get4 chip number (6 bit field) - inline uint8_t getGet4Number() const { return getField(38, 6); } - - //! For Get4 data: Returns Get4 channel number (2 bit field) - inline uint8_t getGet4ChNum() const { return getField(36, 2); } - - //! For Get4 data: Returns Get4 time stamp, 50 ps binning (19 bit field) - inline uint32_t getGet4Ts() const { return getField(17, 19); } - - //! For Get4 data: Returns Get4 fine time stamp, 50 ps binning (7 bit field) - inline uint32_t getGet4FineTs() const { return getField(17, 7); } - - //! For Get4 data: Returns Get4 coarse time stamp, 6.4 ns binning (12 bit field) - inline uint32_t getGet4CoarseTs() const { return getField(24, 12); } - - //! For Get4 data: Returns Get4 rising or falling edge (1 bit field) - inline uint32_t getGet4Edge() const { return getBit(16); } - - //! For Get4 data: Returns the CRC-8 of the rest of the message. - //! For details check the ROC documentation. (8 bit field) - inline uint32_t getGet4CRC() const { return getField(0, 8); } - - - //! For Get4 data: Sets Get4 chip number (6 bit field) - inline void setGet4Number(uint8_t v) { setField(38, 6, v); } - - //! For Get4 data: Sets Get4 channel number (2 bit field) - inline void setGet4ChNum(uint8_t v) { setField(36, 2, v); } - - //! For Get4 data: Sets Get4 time stamp, 50 ps binning (19 bit field) - inline void setGet4Ts(uint32_t v) { setField(17, 19, v); } - - //! For Get4 data: Sets Get4 rising or falling edge (1 bit field) - inline void setGet4Edge(uint32_t v) { setBit(16, v); } - - //! For Get4 data: Set the CRC-8 of the rest of the message - //! For details check the ROC documentation. (8 bit field) - inline void setGet4CRC(uint32_t v) { setField(0, 8, v); } - - // ---------- System message access methods ---------- - - // 2 bit unused - - //! For SysMes data: Returns system message subtype (8 bit field) - inline uint8_t getSysMesType() const { return getField(8, 8); } - - //! For SysMes data: Returns system message data (32 bit field) - // inline uint32_t getSysMesData() const { return getField(16, 32); } - // on some machine 32-bit field not working - inline uint32_t getSysMesData() const { return data >> 16; } - - //! For SysMes data: Set system message type (8 bit field) - inline void setSysMesType(uint8_t v) { setField(8, 8, v); } - - //! For SysMes data: Set system message data (32 bit field) - inline void setSysMesData(uint32_t v) { setField(16, 32, v); } - - // ---------- Get4 gDPB 24b/32b ALL access methods ------------------------ - inline uint16_t getGdpbGenChipId() const { return getField( 42, 6); } - inline void setGdpbGenChipId(uint32_t v) { setField(42, 6, v); } - - // ---------- Get4 gDPB 24b/32b Hit access methods ------------------------ -// inline uint16_t getGdpbHitChipId() const { return getField( 42, 6); } - inline uint16_t getGdpbHitChanId() const { return getField( 40, 2); } - inline uint32_t getGdpbHitFullTs() const { return getField( 21, 19); } - inline uint16_t getGdpbHitCrc() const { return getField( 4, 8); } - inline uint16_t getGdpbHitCoarse() const { return getField( 28, 12); } - inline uint16_t getGdpbHitFineTs() const { return getField( 21, 7); } - // ---------- Get4 gDPB 24b Hit access methods ---------------------------- - inline bool getGdpbHit24Edge() const { return getBit( 20 ); } - // ---------- Get4 gDPB 32b Hit access methods ---------------------------- - inline bool getGdpbHit32DllLck() const { return getBit( 20 ); } - inline uint16_t getGdpbHit32Tot() const { return getField( 12, 8); } - - // ---------- Get4 gDPB 24b/32b Epoch access methods ---------------------- -// inline uint16_t getGdpbEpChipId() const { return getField( 42, 6); } - inline bool getGdpbEpLinkId() const { return getBit( 41 ); } - inline uint32_t getGdpbEpEpochNb() const { return getField( 10, 31); } - inline uint16_t getGdpbEpStampTs() const { return getField( 8, 2); } - inline bool getGdpbEpSync() const { return getBit( 7 ); } - inline bool getGdpbEpDataLoss() const { return getBit( 6 ); } - inline bool getGdpbEpEpochLoss() const { return getBit( 5 ); } - inline bool getGdpbEpMissmatch() const { return getBit( 4 ); } - - // ---------- Get4 gDPB 24b/32b Slow cont. access methods ----------------- -// inline uint16_t getGdpbSlcChipId() const { return getField( 42, 6); } - inline uint32_t getGdpbSlcMess() const { return getField( 12, 29); } - inline uint32_t getGdpbSlcData() const { return getField( 12, 24); } - inline uint32_t getGdpbSlcType() const { return getField( 36, 2); } - inline uint32_t getGdpbSlcEdge() const { return getBit( 38 ); } - inline uint32_t getGdpbSlcChan() const { return getField( 39, 2); } - inline uint16_t getGdpbSlcCrc() const { return getField( 4, 8); } - - // ---------- Get4 gDPB System Msg access methods ------------------------- -// inline uint16_t getGdpbSysChipId() const { return getField( 42, 6); } - inline bool getGdpbSysLinkId() const { return getBit( 41 ); } - inline uint16_t getGdpbSysSubType() const { return getField( 37, 4); } - // ---------- Get4 gDPB 24b/32b Errors access methods --------------------- - inline bool getGdpbSysErrRoType() const { return getBit( 36 ); } - inline uint16_t getGdpbSysErrUnused() const { return getField( 14, 22); } - inline uint16_t getGdpbSysErrChanId() const { return getField( 12, 2); } - inline bool getGdpbSysErrEdge() const { return getBit( 11 ); } - inline uint16_t getGdpbSysErrData() const { return getField( 4, 7); } - // ---------- Get4 gDPB unknown msg type access methods ------------------- - inline uint32_t getGdpbSysUnkwData() const { return getField( 4, 32); } - - // ---------- STAR Trigger messages access methods ------------------------ - inline uint16_t getStarTrigMsgIndex() const { return getField( 4, 4 ); } - //++++// - inline uint64_t getGdpbTsMsbStarA() const { return getFieldLong( 8, 40 ); } - //++++// - inline uint64_t getGdpbTsLsbStarB() const { return getFieldLong( 24, 24 ); } - inline uint64_t getStarTsMsbStarB() const { return getFieldLong( 8, 16 ); } - //++++// - inline uint64_t getStarTsMidStarC() const { return getFieldLong( 8, 40 ); } - //++++// - inline uint64_t getStarTsLsbStarD() const { return getFieldLong( 40, 8 ); } - /// 12 bits in between are set to 0 - inline uint32_t getStarFillerD() const { return getField( 28, 12 ); } // Should be always 0 - inline uint32_t getStarTokenStarD() const { return getField( 8, 12 ); } - inline uint32_t getStarDaqCmdStarD() const { return getField( 20, 4 ); } - inline uint32_t getStarTrigCmdStarD() const { return getField( 24, 4 ); } - - // ---------- Common functions ----------------------- - - //! Returns \a true is message type is #MSG_NOP (filler message) - inline bool isNopMsg() const { return getMessageType() == MSG_NOP; } - //! Returns \a true is message type is #MSG_HIT (nXYTER hit data) - inline bool isHitMsg() const { return getMessageType() == MSG_HIT; } - //! Returns \a true is message type is #MSG_EPOCH (epoch marker) - inline bool isEpochMsg() const { return getMessageType() == MSG_EPOCH;} - //! Returns \a true is message type is #MSG_SYNC - inline bool isSyncMsg() const { return getMessageType() == MSG_SYNC; } - //! Returns \a true is message type is #MSG_AUX - inline bool isAuxMsg() const { return getMessageType() == MSG_AUX; } - //! Returns \a true is message type is #MSG_EPOCH2 (epoch2 marker) - inline bool isEpoch2Msg() const { return getMessageType() == MSG_EPOCH2;} - //! Returns \a true is message type is #MSG_GET4 (Get4 hit data) - inline bool isGet4Msg() const { return getMessageType() == MSG_GET4; } - //! Returns \a true is message type is #MSG_SYS (system message) - inline bool isSysMsg() const { return getMessageType() == MSG_SYS; } - //! Returns \a true is message type is #MSG_GET4_SLC (GET4 Slow Control) - inline bool isGet4SlCtrMsg() const { return getMessageType() == MSG_GET4_SLC; } - //! Returns \a true is message type is #MSG_GET4_32B (GET4 Hit Data in 32b mode) - inline bool isGet4Hit32Msg() const { return getMessageType() == MSG_GET4_32B; } - //! Returns \a true is message type is #MSG_GET4_SYS (GET4 system message) - inline bool isGet4SysMsg() const { return getMessageType() == MSG_GET4_SYS; } - //! Returns \a true is message type is #MSG_STAR_TRI (STAR Trigger message) - inline bool isStarTrigger() const { return getMessageType() == MSG_STAR_TRI;} - //! Returns \a true is message type is #MSG_SYS (system message) and subtype is 32bHack - inline bool isGet4Hack32Msg() const { return - ( (getMessageType() == MSG_SYS) && - (SYSMSG_GET4V1_32BIT_0 <= getSysMesType()) ); } - - //! Returns \a true if system message and subtype #ROC_SYSMSG_DAQ_START - inline bool isStartDaqMsg() const - { return isSysMsg() && (getSysMesType() == SYSMSG_DAQ_START); } - //! Returns \a true if system message and subtype #ROC_SYSMSG_DAQ_FINISH - inline bool isStopDaqMsg() const - { return isSysMsg() && (getSysMesType() == SYSMSG_DAQ_FINISH); } - - - void printDataCout(unsigned kind = msg_print_Prefix | msg_print_Data, uint32_t epoch = 0) const; - void printDataLog(unsigned kind = msg_print_Prefix | msg_print_Data, uint32_t epoch = 0) const; - -// void printData(std::ostream& os, unsigned kind = msg_print_Human, uint32_t epoch = 0) const; - void printData(unsigned outType = msg_print_Cout, unsigned kind = msg_print_Human, - uint32_t epoch = 0, std::ostream& os = std::cout ) const; - - uint64_t getMsgFullTime(uint32_t epoch) const; - - double getMsgFullTimeD(uint32_t epoch) const; - - uint64_t getMsgG4v2FullTime(uint32_t epoch) const; - - double getMsgG4v2FullTimeD(uint32_t epoch) const; - - //! Expanded timestamp for 160 MHz * 14 bit (12 + 2) epochs - inline static uint64_t FullTimeStamp(uint32_t epoch, uint16_t stamp) - { return (static_cast<uint64_t>(epoch) << 14) | (stamp & 0x3fff); } - - //! Expanded timestamp for 160 MHz * 19 bit (12 + 7) epochs - inline static uint64_t FullTimeStamp2(uint32_t epoch, uint32_t stamp) - { return (static_cast<uint64_t>(epoch) << 19) | (stamp & 0x7ffff); } - - - static uint64_t CalcDistance(uint64_t start, uint64_t stop); - - static double CalcDistanceD(double start, double stop); - - bool operator<(const ngdpb::Message& other) const; - - // -------------------- methods for working with different formats - - static uint32_t RawSize(int fmt); - - bool assign(void* src, int fmt = formatNormal); - - bool copyto(void* tgt, int fmt = formatNormal); - }; -/* - class FullMessage : public Message { - protected: - uint64_t fuExtendedEpoch; // Epoch of the message, extended with 32b epoch cycle counter - - public: - FullMessage() : Message(), fuExtendedEpoch(0) {} - - FullMessage(const Message& src, uint64_t uEpIn = 0) : Message(src), fuExtendedEpoch(uEpIn) {} - - FullMessage(const FullMessage& src) : Message(src), fuExtendedEpoch(src.fuExtendedEpoch) {} - - void assign(const FullMessage& src) { Message::assign(src); fuExtendedEpoch = src.fuExtendedEpoch; } - - FullMessage& operator=(const FullMessage& src) { assign(src); return *this; } - - bool operator<(const FullMessage& other) const; - - inline void reset() { Message::reset(); fuExtendedEpoch = 0; } - - inline uint64_t getExtendedEpoch() const {return fuExtendedEpoch; } - - // Works only for GET4 v2.XXX !!!!!! - inline double GetFullTimeNs() { return getMsgG4v2FullTimeD( fuExtendedEpoch ); } - }; -*/ -} - - -#endif // ROC_MESS_WGET4V1X_H diff --git a/beamtime/param/CMakeLists.txt b/beamtime/param/CMakeLists.txt deleted file mode 100644 index fe582ab1a2b5537af27f522ec4d0e966b0db17f2..0000000000000000000000000000000000000000 --- a/beamtime/param/CMakeLists.txt +++ /dev/null @@ -1,48 +0,0 @@ -# Create a library called "libCbmFlibReader" which includes the source files given in -# the array . -# The extension is already found. Any number of sources could be listed here. - -Set(INCLUDE_DIRECTORIES - ${CMAKE_CURRENT_SOURCE_DIR} - ${CBMBASE_DIR} -) - -Set(SYSTEM_INCLUDE_DIRECTORIES - ${BASE_INCLUDE_DIRECTORIES} - ${Boost_INCLUDE_DIR} - ${ROOT_INCLUDE_DIR} -) - -Include_Directories(${INCLUDE_DIRECTORIES}) -Include_Directories(SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES}) - - -Set(LINK_DIRECTORIES - ${ROOT_LIBRARY_DIR} - ${FAIRROOT_LIBRARY_DIR} - ${Boost_LIBRARY_DIRS} -) - -Link_Directories( - ${LINK_DIRECTORIES} -) - -Set(SRCS - CbmTofUnpackPar.cxx - CbmFHodoUnpackPar.cxx - CbmMuchUnpackPar.cxx - CbmFlesTestContFact.cxx -) - -If(_UINT8_T_EXIST) - Add_Definitions(-DHAVE_UINT8_T_HEADER_FILE) - Set(DEFINITIONS HAVE_UINT8_T_HEADER_FILE) -EndIf() - -Set(LINKDEF CbmBeamtimeParamLinkDef.h ) -Set(LIBRARY_NAME CbmBeamtimeParam) -Set(DEPENDENCIES - CbmBase Base -) - -GENERATE_LIBRARY() diff --git a/beamtime/param/CbmBeamtimeParamLinkDef.h b/beamtime/param/CbmBeamtimeParamLinkDef.h deleted file mode 100644 index 477d1644559d6c1568082517890bcb2dd1af01b0..0000000000000000000000000000000000000000 --- a/beamtime/param/CbmBeamtimeParamLinkDef.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifdef __CINT__ - -#pragma link off all globals; -#pragma link off all classes; -#pragma link off all functions; - -#pragma link C++ class CbmFHodoUnpackPar; -#pragma link C++ class CbmTofUnpackPar; -#pragma link C++ class CbmMuchUnpackPar; -#pragma link C++ class CbmFlesTestContFact; - -#endif diff --git a/beamtime/param/CbmFHodoUnpackPar.cxx b/beamtime/param/CbmFHodoUnpackPar.cxx deleted file mode 100644 index 214bd590f2030598b8e4b0dcb0f218e797687809..0000000000000000000000000000000000000000 --- a/beamtime/param/CbmFHodoUnpackPar.cxx +++ /dev/null @@ -1,85 +0,0 @@ -// ------------------------------------------------------------------------- -// ----- CbmFHodoUnpackPar source file ----- -// ----- Created 02/11/16 by F. Uhlig ----- -// ------------------------------------------------------------------------- - -#include "CbmFHodoUnpackPar.h" - -#include "FairParamList.h" -#include "FairDetParIo.h" -#include "FairParIo.h" -#include "FairLogger.h" - -#include "TString.h" - -// ----- Standard constructor ------------------------------------------ -CbmFHodoUnpackPar::CbmFHodoUnpackPar(const char* name, - const char* title, - const char* context) - : FairParGenericSet(name, title, context), - fNrOfRocs(-1), - fRocIdArray(), - fNrOfChannels(-1), - fChannelToFiberMap(), - fChannelToPixelMap(), - fChannelToPlaneMap() -{ - detName="FHodo"; -} -// ------------------------------------------------------------------------- - - - -// ----- Destructor ---------------------------------------------------- -CbmFHodoUnpackPar::~CbmFHodoUnpackPar() -{ -} -// ------------------------------------------------------------------------- - - -// ----- Public method clear ------------------------------------------- -void CbmFHodoUnpackPar::clear() -{ - status = kFALSE; - resetInputVersions(); -} -// ------------------------------------------------------------------------- - -// ------------------------------------------------------------------------- - -void CbmFHodoUnpackPar::putParams(FairParamList* l) -{ - if (!l) return; - l->add("NrOfRocs", fNrOfRocs); - l->add("RocIdArray", fRocIdArray); - l->add("NrOfChannels", fNrOfRocs); - l->add("ChannelToFiberMap", fChannelToFiberMap); - l->add("ChannelToPixelMap", fChannelToPixelMap); - l->add("ChannelToPlaneMap", fChannelToPlaneMap); -} - -//------------------------------------------------------ - -Bool_t CbmFHodoUnpackPar::getParams(FairParamList* l) { - - if (!l) return kFALSE; - - if ( ! l->fill("NrOfRocs", &fNrOfRocs) ) return kFALSE; - - fRocIdArray.Set(fNrOfRocs); - if ( ! l->fill("RocIdArray", &fRocIdArray) ) return kFALSE; - - if ( ! l->fill("NrOfChannels", &fNrOfChannels) ) return kFALSE; - - fChannelToFiberMap.Set(fNrOfChannels); - fChannelToPixelMap.Set(fNrOfChannels); - fChannelToPlaneMap.Set(fNrOfChannels); - if ( ! l->fill("ChannelToFiberMap", &fChannelToFiberMap) ) return kFALSE; - if ( ! l->fill("ChannelToPixelMap", &fChannelToPixelMap) ) return kFALSE; - if ( ! l->fill("ChannelToPlaneMap", &fChannelToPlaneMap) ) return kFALSE; - - return kTRUE; -} - - -ClassImp(CbmFHodoUnpackPar) diff --git a/beamtime/param/CbmFHodoUnpackPar.h b/beamtime/param/CbmFHodoUnpackPar.h deleted file mode 100644 index 7c37ad4f6609cb3ecb838b7f0320d2634e5a2d8e..0000000000000000000000000000000000000000 --- a/beamtime/param/CbmFHodoUnpackPar.h +++ /dev/null @@ -1,55 +0,0 @@ -// ------------------------------------------------------------------------- -// ----- CbmFHodoUnpackPar header file ----- -// ----- Created 02/11/16 by F. Uhlig ----- -// ------------------------------------------------------------------------- - -#ifndef CBMFHODOUNPACKPAR_H -#define CBMFHODOUNPACKPAR_H - -#include "FairParGenericSet.h" - -#include "TArrayI.h" - -class FairParIo; -class FairParamList; - - -class CbmFHodoUnpackPar : public FairParGenericSet -{ - - public: - - /** Standard constructor **/ - CbmFHodoUnpackPar(const char* name = "CbmFHodoUnpackPar", - const char* title = "FHodo unpacker parameters", - const char* context = "Default"); - - - /** Destructor **/ - virtual ~CbmFHodoUnpackPar(); - - /** Reset all parameters **/ - virtual void clear(); - - void putParams(FairParamList*); - Bool_t getParams(FairParamList*); - - Int_t GetNrOfRocs() { return fNrOfRocs; } - Int_t GetRocId(Int_t i) { return fRocIdArray[i]; } - Int_t GetNumberOfChannels() {return fNrOfChannels;} - Int_t GetChannelToFiberMap(Int_t channel) {return fChannelToFiberMap[channel];} - Int_t GetChannelToPixelMap(Int_t channel) {return fChannelToPixelMap[channel];} - Int_t GetChannelToPlaneMap(Int_t channel) {return fChannelToPlaneMap[channel];} - private: - - Int_t fNrOfRocs; // Total number of Rocs - TArrayI fRocIdArray; // Array to hold the unique IDs for all FHodo Rocs - - Int_t fNrOfChannels; - TArrayI fChannelToFiberMap; // Array which stores the corresponding fiber for each channel - TArrayI fChannelToPixelMap; // Array which stores the corresponding pixel for each channel - TArrayI fChannelToPlaneMap; // Array which stores the corresponding side for each channel - - ClassDef(CbmFHodoUnpackPar,1); -}; -#endif diff --git a/beamtime/param/CbmFlesTestContFact.cxx b/beamtime/param/CbmFlesTestContFact.cxx deleted file mode 100644 index e23e72f98a6893e4c8a74672becd4dc4af9167f4..0000000000000000000000000000000000000000 --- a/beamtime/param/CbmFlesTestContFact.cxx +++ /dev/null @@ -1,74 +0,0 @@ -///////////////////////////////////////////////////////////// -// -// CbmFlesTestContFact -// -// Factory for the parameter containers in libFlesTest -// -///////////////////////////////////////////////////////////// - -#include "CbmFlesTestContFact.h" - -#include "CbmFHodoUnpackPar.h" - -#include "CbmTofUnpackPar.h" - -#include "CbmMuchUnpackPar.h" - -#include "FairRuntimeDb.h" - -ClassImp(CbmFlesTestContFact) - -static CbmFlesTestContFact gCbmFlesTestContFact; - -CbmFlesTestContFact::CbmFlesTestContFact() { - // Constructor (called when the library is loaded) - fName="CbmFlesTestContFact"; - fTitle="Factory for parameter containers for fles test library"; - setAllContainers(); - FairRuntimeDb::instance()->addContFactory(this); -} - -void CbmFlesTestContFact::setAllContainers() { - /** Creates the Container objects with all accepted contexts and adds them to - * the list of containers for the fles test library.*/ - - FairContainer* p= new FairContainer("CbmFHodoUnpackPar", - "Fibre Hodoscope Unpack Parameters", - "TestDefaultContext"); - p->addContext("TestNonDefaultContext"); - - containers->Add(p); - - FairContainer* p2= new FairContainer("CbmTofUnpackPar", - "Tof Unpack Parameters", - "TestDefaultContext"); - p2->addContext("TestNonDefaultContext"); - - containers->Add(p2); - - FairContainer* p3 = new FairContainer("CbmMuchUnpackPar", - "Much Unpack Parameters", - "TestDefaultContext"); - p3->addContext("TestNonDefaultContext"); - - containers->Add(p3); -} - -FairParSet* CbmFlesTestContFact::createContainer(FairContainer* c) { - /** Calls the constructor of the corresponding parameter container. - * For an actual context, which is not an empty string and not the default context - * of this container, the name is concatinated with the context. */ - const char* name=c->GetName(); - FairParSet* p=0; - if (strcmp(name,"CbmFHodoUnpackPar")==0) { - p=new CbmFHodoUnpackPar(c->getConcatName().Data(),c->GetTitle(),c->getContext()); - } - if (strcmp(name,"CbmTofUnpackPar")==0) { - p=new CbmTofUnpackPar(c->getConcatName().Data(),c->GetTitle(),c->getContext()); - } - if (strcmp(name,"CbmMuchUnpackPar")==0) { - p=new CbmMuchUnpackPar(c->getConcatName().Data(),c->GetTitle(),c->getContext()); - } - return p; -} - diff --git a/beamtime/param/CbmFlesTestContFact.h b/beamtime/param/CbmFlesTestContFact.h deleted file mode 100644 index 6265e9b320be6bac55285bab36f32d29ef8d9224..0000000000000000000000000000000000000000 --- a/beamtime/param/CbmFlesTestContFact.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef CBMFLESTESTCONTFACT_H -#define CBMFLESTESTCONTFACT_H - -#include "FairContFact.h" - -class FairContainer; -class FairParSet; - -class CbmFlesTestContFact : public FairContFact { -private: - void setAllContainers(); - CbmFlesTestContFact(const CbmFlesTestContFact&); - CbmFlesTestContFact& operator=(const CbmFlesTestContFact&); -public: - CbmFlesTestContFact(); - ~CbmFlesTestContFact() {} - FairParSet* createContainer(FairContainer*); - ClassDef(CbmFlesTestContFact,0) // Factory for all TRD parameter containers -}; - -#endif /* !CBMFLESTESTCONTFACT_H */ diff --git a/beamtime/param/CbmMuchUnpackPar.cxx b/beamtime/param/CbmMuchUnpackPar.cxx deleted file mode 100644 index 861eab806f3eb84d2a84aa3300f0cb4d9ed424c6..0000000000000000000000000000000000000000 --- a/beamtime/param/CbmMuchUnpackPar.cxx +++ /dev/null @@ -1,142 +0,0 @@ -// ------------------------------------------------------------------------- -// ----- CbmMuchUnpackPar source file ----- -// ----- Created 11/11/16 by V. Singhal and A. Kumar ----- -// ------------------------------------------------------------------------- - -#include "CbmMuchUnpackPar.h" - -#include "FairParamList.h" -#include "FairDetParIo.h" -#include "FairParIo.h" -#include "FairLogger.h" - -#include "TString.h" - -using namespace std; -// ----- Standard constructor ------------------------------------------ -CbmMuchUnpackPar::CbmMuchUnpackPar(const char* name, - const char* title, - const char* context) - : FairParGenericSet(name, title, context), - fNrOfnDpbsModA(-1), - fnDbpsIdsArrayA(), - fNrOfnDpbsModB(-1), - fnDbpsIdsArrayB(), - fuNbFebPerNdpb(-1), - fNrOfFebs(-1), - fnFebsIdsArrayA(), - fnFebsIdsArrayB(), - fNrOfChannels(-1), - fChannelsToPadX(), - fChannelsToPadY() -{ - detName="Much"; -} -// ------------------------------------------------------------------------- - - - -// ----- Destructor ---------------------------------------------------- -CbmMuchUnpackPar::~CbmMuchUnpackPar() -{ -} -// ------------------------------------------------------------------------- - - -// ----- Public method clear ------------------------------------------- -void CbmMuchUnpackPar::clear() -{ - status = kFALSE; - resetInputVersions(); -} -// ------------------------------------------------------------------------- - -// ------------------------------------------------------------------------- - -void CbmMuchUnpackPar::putParams(FairParamList* l) -{ - if (!l) return; - l->add("NrOfnDpbsModA", fNrOfnDpbsModA); - l->add("nDbpsIdsArrayA", fnDbpsIdsArrayA); - l->add("NrOfnDpbsModB", fNrOfnDpbsModB); - l->add("nDbpsIdsArrayB", fnDbpsIdsArrayB); - l->add("NbFebPerNdpb", fuNbFebPerNdpb); - l->add("NrOfFebs", fNrOfFebs); - l->add("nFebsIdsArrayA", fnFebsIdsArrayA); - l->add("nFebsIdsArrayB", fnFebsIdsArrayB); - l->add("NrOfChannels", fNrOfChannels); - l->add("ChannelsToPadX", fChannelsToPadX); - l->add("ChannelsToPadY", fChannelsToPadY); -} - -//------------------------------------------------------ - -Bool_t CbmMuchUnpackPar::getParams(FairParamList* l) { - - if (!l) return kFALSE; - - LOG(info)<< " Before CbmMuchUnpackPar GetParams at NrOfnDpbs "; - if ( ! l->fill("NrOfnDpbsModA", &fNrOfnDpbsModA) ) return kFALSE; - LOG(info)<< " After CbmMuchUnpackPar GetParams at NrOfnDpbs "; - - fnDbpsIdsArrayA.Set(fNrOfnDpbsModA); - if ( ! l->fill("nDbpsIdsArrayA", &fnDbpsIdsArrayA) ) return kFALSE; - - - - LOG(info)<< " Before CbmMuchUnpackPar GetParams at NrOfnDpbs for GEM2 "; - if ( ! l->fill("NrOfnDpbsModB", &fNrOfnDpbsModB) ) return kFALSE; - LOG(info)<< " After CbmMuchUnpackPar GetParams at NrOfnDpbs "; - - fnDbpsIdsArrayB.Set(fNrOfnDpbsModB); - if ( ! l->fill("nDbpsIdsArrayB", &fnDbpsIdsArrayB) ) return kFALSE; - - if ( ! l->fill("NbFebPerNdpb", &fuNbFebPerNdpb) ) return kFALSE; - - if ( ! l->fill("NrOfFebs", &fNrOfFebs) ) return kFALSE; - - fnFebsIdsArrayA.Set(fNrOfFebs); - if ( ! l->fill("nFebsIdsArrayA", &fnFebsIdsArrayA) ) return kFALSE; - - fnFebsIdsArrayB.Set(fNrOfFebs); - if ( ! l->fill("nFebsIdsArrayB", &fnFebsIdsArrayB) ) return kFALSE; - - if ( ! l->fill("NrOfChannels", &fNrOfChannels) ) return kFALSE; - - fChannelsToPadX.Set(fNrOfFebs*fNrOfChannels); - if ( ! l->fill("ChannelsToPadX", &fChannelsToPadX) ) return kFALSE; - - fChannelsToPadY.Set(fNrOfFebs*fNrOfChannels); - if ( ! l->fill("ChannelsToPadY", &fChannelsToPadY) ) return kFALSE; - - return kTRUE; -} - - -Int_t CbmMuchUnpackPar::GetPadX(Int_t febid, Int_t channelid) -{ - if( fChannelsToPadX.GetSize () <= (febid*fNrOfChannels)+channelid ) - { - LOG(debug) << "CbmMuchUnpackPar::GetPadX => Index out of bounds: " - << ((febid*fNrOfChannels)+channelid) << " VS " << fChannelsToPadX.GetSize() - << " (" << febid << " and " << channelid << ")"; - return -2; - } // if( fChannelsToPadX.GetSize () <= (febid*fNrOfChannels)+channelid ) - - - return fChannelsToPadX[(febid*fNrOfChannels)+channelid]; -} -Int_t CbmMuchUnpackPar::GetPadY(Int_t febid, Int_t channelid) -{ - if( fChannelsToPadY.GetSize() <= (febid*fNrOfChannels)+channelid ) - { - LOG(debug) << "CbmMuchUnpackPar::GetPadY => Index out of bounds: " - << ((febid*fNrOfChannels)+channelid) << " VS " << fChannelsToPadY.GetSize() - << " (" << febid << " and " << channelid << ")"; - return -2; - } // if( fChannelsToPadY.GetSize () <= (febid*fNrOfChannels)+channelid ) - - return fChannelsToPadY[(febid*fNrOfChannels)+channelid]; -} - -ClassImp(CbmMuchUnpackPar) diff --git a/beamtime/param/CbmMuchUnpackPar.h b/beamtime/param/CbmMuchUnpackPar.h deleted file mode 100644 index c4f4228946c16bb11ea99524d06438a37d0e731a..0000000000000000000000000000000000000000 --- a/beamtime/param/CbmMuchUnpackPar.h +++ /dev/null @@ -1,71 +0,0 @@ -// ------------------------------------------------------------------------- -// ----- CbmMuchUnpackPar header file ----- -// ----- Created 11/11/16 by V. Singhal and A. Kumar ----- -// ------------------------------------------------------------------------- - -#ifndef CBMMUCHUNPACKPAR_H -#define CBMMUCHUNPACKPAR_H - -#include "FairParGenericSet.h" - -#include "TArrayI.h" - -class FairParIo; -class FairParamList; - - -class CbmMuchUnpackPar : public FairParGenericSet -{ - - public: - - /** Standard constructor **/ - CbmMuchUnpackPar(const char* name = "CbmMuchUnpackPar", - const char* title = "Much unpacker parameters", - const char* context = "Default"); - - - /** Destructor **/ - virtual ~CbmMuchUnpackPar(); - - /** Reset all parameters **/ - virtual void clear(); - - void putParams(FairParamList*); - Bool_t getParams(FairParamList*); - - Int_t GetNrOfnDpbsModA() { return fNrOfnDpbsModA; } - Int_t GetNrOfnDpbsModB() { return fNrOfnDpbsModB; } - inline Int_t GetNdpbIdA(Int_t i) { return fnDbpsIdsArrayA[i]; } - inline Int_t GetNdpbIdB(Int_t i) { return fnDbpsIdsArrayB[i]; } - - Int_t GetNrOfFebsPerNdpb() { return fuNbFebPerNdpb; } - Int_t GetNrOfFebs() { return fNrOfFebs; } - inline Int_t GetFebsIdsFromArrayA(Int_t i) { return fnFebsIdsArrayA[i]; } - inline Int_t GetFebsIdsFromArrayB(Int_t i) { return fnFebsIdsArrayB[i]; } - Int_t GetNrOfChannels() {return fNrOfChannels;} - - Int_t GetPadX(Int_t febid, Int_t channelid); - Int_t GetPadY(Int_t febid, Int_t channelid); - - // Int_t GetChannelToPixelMap(Int_t channel) {return fChannelToPixelMap[channel];} - // Int_t GetChannelToPlaneMap(Int_t channel) {return fChannelToPlaneMap[channel];} - - private: - - Int_t fNrOfnDpbsModA; // Total number of nDPBs in GEM Module 1 - TArrayI fnDbpsIdsArrayA; // Array to hold the unique IDs for all GEM nDPBs - Int_t fNrOfnDpbsModB; // Total number of nDPBs in GEM Module 2 - TArrayI fnDbpsIdsArrayB; // Array to hold the unique IDs for all GEM nDPBs - Int_t fuNbFebPerNdpb; // Number of FEBs for all nDPB - Int_t fNrOfFebs; // Number of FEBs for all nDPB - TArrayI fnFebsIdsArrayA; // Array to hold FEB IDs connected to 1 nDPB - TArrayI fnFebsIdsArrayB; // Array to hold FEB IDs connected to 1 nDPB - Int_t fNrOfChannels; - TArrayI fChannelsToPadX; // Array which stores the corresponding x position of PAD of entire module A - TArrayI fChannelsToPadY; // Array which stores the corresponding y position of PAD of entire module A - - - ClassDef(CbmMuchUnpackPar,1); -}; -#endif diff --git a/beamtime/param/CbmTofUnpackPar.cxx b/beamtime/param/CbmTofUnpackPar.cxx deleted file mode 100644 index c0c4468a6f3cf5ec95933abbabc7a84068592c20..0000000000000000000000000000000000000000 --- a/beamtime/param/CbmTofUnpackPar.cxx +++ /dev/null @@ -1,112 +0,0 @@ -// ------------------------------------------------------------------------- -// ----- CbmTofUnpackPar source file ----- -// ----- Created 02/11/16 by F. Uhlig ----- -// ------------------------------------------------------------------------- - -#include "CbmTofUnpackPar.h" - -#include "FairParamList.h" -#include "FairDetParIo.h" -#include "FairParIo.h" -#include "FairLogger.h" - -#include "TString.h" - -// ----- Standard constructor ------------------------------------------ -CbmTofUnpackPar::CbmTofUnpackPar(const char* name, - const char* title, - const char* context) - : FairParGenericSet(name, title, context), - fNrOfGdpb(-1), - fGdpbIdArray(), - fNrOfFebsPerGdpb(-1), - fNrOfGet4PerFeb(-1), - fNrOfChannelsPerGet4(-1), - fNrOfChannels(-1), - fChannelToDetUIdMap(), - fPlotChannelRate(0), - fiStarSortAndCut(0), - fiStarActiveMasksArray(), - fdStarTriggerDelay(), - fdStarTriggerWinSize() -{ - detName="Tof"; -} -// ------------------------------------------------------------------------- - - - -// ----- Destructor ---------------------------------------------------- -CbmTofUnpackPar::~CbmTofUnpackPar() -{ -} -// ------------------------------------------------------------------------- - - -// ----- Public method clear ------------------------------------------- -void CbmTofUnpackPar::clear() -{ - status = kFALSE; - resetInputVersions(); -} -// ------------------------------------------------------------------------- - -// ------------------------------------------------------------------------- - -void CbmTofUnpackPar::putParams(FairParamList* l) -{ - if (!l) return; - l->add("NrOfRocs", fNrOfGdpb); - l->add("RocIdArray", fGdpbIdArray); - l->add("NrOfFebsPerGdpb", fNrOfFebsPerGdpb); - l->add("NrOfGet4PerFeb", fNrOfGet4PerFeb); - l->add("NrOfChannelsPerGet4",fNrOfChannelsPerGet4); - l->add("NrOfChannels", fNrOfChannels); - l->add("ChannelToDetUIdMap", fChannelToDetUIdMap); - l->add("PlotChannelRate", fPlotChannelRate); - l->add("StarSortAndCut", fiStarSortAndCut); - l->add("StarActiveMasksArray", fiStarActiveMasksArray); - l->add("StarTriggerDelay", fdStarTriggerDelay); - l->add("StarTriggerWinSize", fdStarTriggerWinSize); -} - -//------------------------------------------------------ - -Bool_t CbmTofUnpackPar::getParams(FairParamList* l) { - - if (!l) return kFALSE; - - if ( ! l->fill("NrOfRocs", &fNrOfGdpb) ) return kFALSE; - - fGdpbIdArray.Set(fNrOfGdpb); - if ( ! l->fill("RocIdArray", &fGdpbIdArray) ) return kFALSE; - - if ( ! l->fill("NrOfFebsPerGdpb", &fNrOfFebsPerGdpb) ) return kFALSE; - if ( ! l->fill("NrOfGet4PerFeb", &fNrOfGet4PerFeb) ) return kFALSE; - if ( ! l->fill("NrOfChannelsPerGet4", &fNrOfChannelsPerGet4) ) return kFALSE; - - if ( ! l->fill("NrOfChannels", &fNrOfChannels) ) return kFALSE; - - fChannelToDetUIdMap.Set(fNrOfChannels); - - if ( ! l->fill("ChannelToDetUIdMap", &fChannelToDetUIdMap) ) return kFALSE; - -// if ( ! l->fill("PlotChannelRate", &fPlotChannelRate) ) return kFALSE; - l->fill("PlotChannelRate", &fPlotChannelRate); // Optionally read this flag, do not crash if not there - - l->fill("StarSortAndCut", &fiStarSortAndCut); // Optionally read this value, do not crash if not there - if( IsStarSortAndCutEnabled() ) - { - fiStarActiveMasksArray.Set(fNrOfGdpb); - fdStarTriggerDelay.Set(fNrOfGdpb); - fdStarTriggerWinSize.Set(fNrOfGdpb); - l->fill("StarActiveMasksArray", &fiStarActiveMasksArray); // Optionally read this value, do not crash if not there - l->fill("StarTriggerDelay", &fdStarTriggerDelay); // Optionally read this value, do not crash if not there - l->fill("StarTriggerWinSize", &fdStarTriggerWinSize); // Optionally read this value, do not crash if not there - } // if( IsStarSortAndCutEnabled() ) - - return kTRUE; -} - - -ClassImp(CbmTofUnpackPar) diff --git a/beamtime/param/CbmTofUnpackPar.h b/beamtime/param/CbmTofUnpackPar.h deleted file mode 100644 index 725819569b5f8fbbe0d62841d9a04b5b555a3cd9..0000000000000000000000000000000000000000 --- a/beamtime/param/CbmTofUnpackPar.h +++ /dev/null @@ -1,72 +0,0 @@ -// ------------------------------------------------------------------------- -// ----- CbmFHodoUnpackPar header file ----- -// ----- Created 02/11/16 by F. Uhlig ----- -// ------------------------------------------------------------------------- - -#ifndef CBMTOFUNPACKPAR_H -#define CBMTOFUNPACKPAR_H - -#include "FairParGenericSet.h" - -#include "TArrayI.h" -#include "TArrayD.h" - -class FairParIo; -class FairParamList; - - -class CbmTofUnpackPar : public FairParGenericSet -{ - - public: - - /** Standard constructor **/ - CbmTofUnpackPar(const char* name = "CbmTofUnpackPar", - const char* title = "Tof unpacker parameters", - const char* context = "Default"); - - - /** Destructor **/ - virtual ~CbmTofUnpackPar(); - - /** Reset all parameters **/ - virtual void clear(); - - void putParams(FairParamList*); - Bool_t getParams(FairParamList*); - - inline Int_t GetNrOfRocs() { return fNrOfGdpb; } - inline Int_t GetRocId(Int_t i) { return fGdpbIdArray[i]; } - inline Int_t GetNrOfFebsPerGdpb() { return fNrOfFebsPerGdpb; } - inline Int_t GetNrOfGet4PerFeb() {return fNrOfGet4PerFeb;} - inline Int_t GetNrOfChannelsPerGet4() {return fNrOfChannelsPerGet4;} - inline Int_t GetNumberOfChannels() {return fNrOfChannels;} - inline Int_t GetChannelToDetUIdMap(Int_t channel) {return fChannelToDetUIdMap[channel];} - inline Bool_t IsChannelRateEnabled() {return (1 == fPlotChannelRate);} - inline Bool_t IsStarSortAndCutEnabled() {return (1 == fiStarSortAndCut);} - inline UInt_t GetStarActiveMask(Int_t gdpb) { return (IsStarSortAndCutEnabled() ? static_cast<UInt_t>(fiStarActiveMasksArray[gdpb]) : 0); } - inline Double_t GetStarTriggDelay(Int_t gdpb) { return (IsStarSortAndCutEnabled() ? fdStarTriggerDelay[gdpb] : 0.0);} - inline Double_t GetStarTriggWinSize(Int_t gdpb) { return (IsStarSortAndCutEnabled() ? fdStarTriggerWinSize[gdpb] : 0.0);} - - private: - - Int_t fNrOfGdpb; // Total number of GDPBs - TArrayI fGdpbIdArray; // Array to hold the unique IDs for all Tof GDPBs - - Int_t fNrOfFebsPerGdpb; // Number of FEBs which are connected to one GDPB - Int_t fNrOfGet4PerFeb; // Number of GET4 chips which are connected to one FEB - Int_t fNrOfChannelsPerGet4; // Number of channels per GET4 - - Int_t fNrOfChannels; // Total number of Channels - TArrayI fChannelToDetUIdMap;// Array which stores the corresponding UIDs for each channel - - Int_t fPlotChannelRate; // Flag controlling wether rate plots for individual channels are filled - - Int_t fiStarSortAndCut; // STAR: Flag controlling wether data are time sorted and cut relative to a received STAR trigger - TArrayI fiStarActiveMasksArray; // STAR: Array to hold the GET4s masks for each gDPB, used to wait for epoch index - TArrayD fdStarTriggerDelay; // STAR: Array to hold for each gDPB the Delay in us to subtract when looking for beginning of coincidence of data with trigger window - TArrayD fdStarTriggerWinSize; // STAR: Array to hold for each gDPB the Size of the trigger window in us - - ClassDef(CbmTofUnpackPar,1); -}; -#endif diff --git a/beamtime/rich/CMakeLists.txt b/beamtime/rich/CMakeLists.txt deleted file mode 100644 index 047c1e0e6c810cf30a163dda1577d874bb694f53..0000000000000000000000000000000000000000 --- a/beamtime/rich/CMakeLists.txt +++ /dev/null @@ -1,72 +0,0 @@ -# Create a library called "libRich" which includes the source files given in -# the array . -# The extension is already found. Any number of sources could be listed here. - -Set(INCLUDE_DIRECTORIES -${CBMBASE_DIR} -${CBMBASE_DIR}/report -${CBMBASE_DIR}/draw -${CBMBASE_DIR}/utils - -${CBMDATA_DIR} -${CBMDATA_DIR}/rich - -${CBMROOT_SOURCE_DIR}/beamtime/data/raw - -${CMAKE_CURRENT_SOURCE_DIR} - -${CBMROOT_SOURCE_DIR}/reco/detectors/rich/fitter -${CBMROOT_SOURCE_DIR}/reco/detectors/rich -) - -Include_Directories( ${INCLUDE_DIRECTORIES}) - -Set(SYSTEM_INCLUDE_DIRECTORIES - ${BASE_INCLUDE_DIRECTORIES} - ${Boost_INCLUDE_DIR} -) -Include_Directories(SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES}) - -set(LINK_DIRECTORIES -${ROOT_LIBRARY_DIR} -${FAIRROOT_LIBRARY_DIR} -${Boost_LIBRARY_DIRS} -#${Vc_LIB_DIR} -${KFParticle_LIB_DIR} -) -link_directories( ${LINK_DIRECTORIES}) - -set(SRCS -CbmRichTrbUnpack.cxx -CbmRichTrbUnpack2.cxx -CbmTrbEdgeMatcher.cxx -CbmTrbCalibrator.cxx -CbmRichTrbEventBuilder.cxx -CbmRichProtoAnalysis.cxx -CbmRichEventDebug.cxx -CbmRichRingHitsAnalyser.cxx -CbmRichTrbRecoQa.cxx -CbmRichTrbPulserQa.cxx -CbmRichHitInfo.cxx -CbmRichTrbRecoQaStudyReport.cxx -) - -IF (SSE_FOUND) - ADD_DEFINITIONS(-DHAVE_SSE) - SET_SOURCE_FILES_PROPERTIES(${SRCS} PROPERTIES COMPILE_FLAGS "-msse -O3") - Message(STATUS "Rich will be compiled with SSE support") -ELSE (SSE_FOUND) - Message(STATUS "Rich will be compiled without SSE support") - SET_SOURCE_FILES_PROPERTIES(${SRCS} PROPERTIES COMPILE_FLAGS "-O3") -ENDIF (SSE_FOUND) - -# END SSE - -set(LINKDEF CbmRichBeamtimeLinkDef.h) - -Set(LIBRARY_NAME CbmRichBeamtime) -Set(DEPENDENCIES - CbmBase CbmData CbmRichBase Base -) - -GENERATE_LIBRARY() diff --git a/beamtime/rich/CbmRawEvent.h b/beamtime/rich/CbmRawEvent.h deleted file mode 100644 index b7503b8b274e1e9e3f4aaa703a207b0e779a74a6..0000000000000000000000000000000000000000 --- a/beamtime/rich/CbmRawEvent.h +++ /dev/null @@ -1,220 +0,0 @@ -#ifndef CBMRAWEVENT_H -#define CBMRAWEVENT_H - -#include <ostream> -#include <stdint.h> - -/* -The class describes the data format of an TRB3 event. A detailed description of the data format -can be found at http://jspc29.x-matter.uni-frankfurt.de/docu/trb3docu.pdf on page 96 -*/ - -using namespace std; - -enum CbmRawEventIndex { - CbmRawEventIndexSize = 0, - CbmRawEventIndexDecoding = 1, - CbmRawEventIndexId = 2, - CbmRawEventIndexSeqNr = 3, - CbmRawEventIndexDate = 4, - CbmRawEventIndexTime = 5, - CbmRawEventIndexRunNr = 6, - CbmRawEventIndexExpId = 7, - CbmRawEventIndexData = 8 -}; - -class CbmRawEvent -{ -public: - void* fData; - - CbmRawEvent(void* data) - : fData(data) - { - - } - - ~CbmRawEvent() - { - } - - void Print() - { - printf("-----------------------Raw event-----------------------"); - printf("HdrSize = %ld \n", HdrSize() ); - printf("HdrLen = %ld \n", HdrLen()); - printf("PaddedSize = %ld \n", PaddedSize()); - - printf("EVENT - size: 0x%08x decoding: 0x%08x id: 0x%08x seqNr: 0x%08x\n" - "date: %s time: %s runNr: 0x%08x expId: %s\n", - Size(), Decoding(), Id(), SeqNr(), - Date2charP(), Time2charP(), RunNr(), ExpId2charP() - ); - } - - void PrintTime() - { - printf("date and time: %s %s\n", Date2charP(), Time2charP()); - } - - size_t HdrLen(void) - { - return CbmRawEventIndexData; - } - - size_t HdrSize(void) - { - return HdrLen() * sizeof(uint32_t); - } - - void *Data() - { - return (void *) ((char *) fData + HdrSize()); - } - - void* End() - { - return (void *) ((char *) fData + PaddedSize()); - } - - size_t DataSize() - { - return Size() - HdrSize(); - } - - uint32_t Size() - { - return HdrValue(CbmRawEventIndexSize); - } - - uint32_t Decoding() - { - return HdrValue(CbmRawEventIndexDecoding); - } - - uint32_t Id() - { - return HdrValue(CbmRawEventIndexId); - } - - uint32_t SeqNr() - { - return HdrValue(CbmRawEventIndexSeqNr); - } - - uint32_t Date() - { - return HdrValue(CbmRawEventIndexDate); - } - - uint32_t Time() - { - return HdrValue(CbmRawEventIndexTime); - } - - uint32_t RunNr() - { - return HdrValue(CbmRawEventIndexRunNr); - } - - uint32_t ExpId() - { - return HdrValue(CbmRawEventIndexExpId); - } - - uint32_t HdrValue(unsigned idx) - { - uint32_t *hdr = Hdr(); - - if (IsSwapped()) { - uint32_t tmp0; - uint32_t tmp1; - - tmp0 = hdr[idx]; - ((char *) &tmp1)[0] = ((char *) &tmp0)[3]; - ((char *) &tmp1)[1] = ((char *) &tmp0)[2]; - ((char *) &tmp1)[2] = ((char *) &tmp0)[1]; - ((char *) &tmp1)[3] = ((char *) &tmp0)[0]; - return tmp1; - } else { - return hdr[idx]; - } - } - - uint32_t *Hdr() - { - return (uint32_t *) fData; - } - - int IsSwapped() - { - uint32_t *hdr = Hdr(); - - return hdr[CbmRawEventIndexDecoding] > 0xffffff; - } - - size_t PaddedSize() - { - uint32_t size = Size(); - uint32_t alignment = Alignment(); - return (size & (alignment - 1)) - ? (size & ~(alignment - 1)) + alignment : size; - } - - unsigned Alignment() - { - return 1 << (Decoding() >> 16 & 0xff); - } - - char *Date2charP() - { - time_t tempo; - struct tm *gmTime; - static char buffer[80]; - - tempo = time(NULL); - gmTime = gmtime(&tempo); - gmTime->tm_year = (Date() >> 16) & 0xff; - gmTime->tm_mon = (Date() >> 8) & 0xff; - gmTime->tm_mday = (Date() >> 0) & 0xff; - strftime(buffer, 80, "%Y-%m-%d", gmTime); - - return buffer; - } - - char *Time2charP() - { - time_t tempo; - struct tm *gmTime; - static char buffer[80]; - - tempo = time(NULL); - gmTime = gmtime(&tempo); - gmTime->tm_hour = (Time() >> 16) & 0xff; - gmTime->tm_min = (Time() >> 8) & 0xff; - gmTime->tm_sec = (Time() >> 0) & 0xff; - strftime(buffer, 80, "%H:%M:%S", gmTime); - - return buffer; - } - - char *ExpId2charP() - { - static char buffer[3]; - uint32_t expId; - - expId = ExpId(); - - buffer[0] = (expId >> 8) & 0xff; - buffer[1] = expId & 0xff; - buffer[2] = '\0'; - - return buffer; - } - - private: - CbmRawEvent(const CbmRawEvent&); - CbmRawEvent operator=(const CbmRawEvent&); -}; - -#endif // CBMRAWEVENT_H diff --git a/beamtime/rich/CbmRawSubEvent.h b/beamtime/rich/CbmRawSubEvent.h deleted file mode 100644 index 3a1964a76a498c54e3f29fb5de2b5f3eba4698f4..0000000000000000000000000000000000000000 --- a/beamtime/rich/CbmRawSubEvent.h +++ /dev/null @@ -1,190 +0,0 @@ -#ifndef CBMRAWSUBEVENT_H -#define CBMRAWSUBEVENT_H - -#include "TObject.h" // only for swab - fix it! -#include "CbmRawEvent.h" - -/* -The class describes the data format of an TRB3 subevent. A detailed description of the data format -can be found at http://jspc29.x-matter.uni-frankfurt.de/docu/trb3docu.pdf on page 96 -*/ - - -enum CbmRawSubEventIndex { - CbmRawSubEventIndexSize, - CbmRawSubEventIndexDecoding, - CbmRawSubEventIndexId, - CbmRawSubEventIndexTrigNr, - CbmRawSubEventIndexData -}; - -class CbmRawSubEvent -{ - -public: - void* fData; - - CbmRawSubEvent(void* data) - : fData(data) - { - - } - - ~CbmRawSubEvent() - { - } - - void Print() - { - printf("\nSUBEVENT - size: 0x%08x decoding: 0x%08x id: 0x%08x trigNr: 0x%08x trigTypeTRB3: 0x%01x\n", - Size(), SubDecoding(), SubId(), SubTrigNr(), SubTrigTypeTrb3()); - - for (unsigned int i = 0; i < SubDataSize() / sizeof(uint32_t); i++) { - if ( i % 4 == 0) { /* newline and the offset in the subEvt */ - if(i!=0) printf("\n"); - printf("%08lx:", i * sizeof(uint32_t)); - } - printf(" 0x%08x", SubDataValue(i)); - } - printf("\n"); - } - - void PrintHeaderOnly() - { - printf("SUBEVENT - size: 0x%08x decoding: 0x%08x id: 0x%08x trigNr: 0x%08x trigTypeTRB3: 0x%01x\n", - Size(), SubDecoding(), SubId(), SubTrigNr(), SubTrigTypeTrb3()); - } - - uint32_t SubDecoding() - { - return (Decoding() & 0xFFFFFF0F); - } - - uint32_t SubId() - { - return HdrValue(CbmRawSubEventIndexId); - } - - uint32_t SubTrigNr() - { - return HdrValue(CbmRawSubEventIndexTrigNr); - } - - uint32_t SubTrigTypeTrb3() - { - /* get trb3 trigger type info in bits 4...7*/ - return ((Decoding() & 0xF0) >> 4) ; - } - - size_t SubDataSize() - { - return Size() - SubHdrSize(); - } - - size_t SubHdrLen() - { - return CbmRawSubEventIndexData; - } - - size_t SubHdrSize(void) - { - return SubHdrLen() * sizeof(uint32_t); - } - - void *SubData() - { - return (void *) ((char *) fData + SubHdrSize()); - } - - uint32_t SubDataValue(unsigned idx) - { - uint32_t val; - - switch (Alignment()) { - case 4: - if (IsSwapped()) { - uint32_t tmp0; - uint32_t tmp1; - - tmp0 = ((uint32_t *) SubData())[idx]; - ((char *) &tmp1)[0] = ((char *) &tmp0)[3]; - ((char *) &tmp1)[1] = ((char *) &tmp0)[2]; - ((char *) &tmp1)[2] = ((char *) &tmp0)[1]; - ((char *) &tmp1)[3] = ((char *) &tmp0)[0]; - val = tmp1; - } else { - val = ((uint32_t *) SubData())[idx]; - } - break; - case 2: - if (IsSwapped()) { - uint16_t v; - swab(((uint16_t *) SubData()) + idx, &v, 2); - val = v; - } else { - val = ((uint16_t *) SubData())[idx]; - } - break; - default: - val = ((uint8_t *) SubData())[idx]; - break; - } - return val; - } - - - //same - uint32_t Decoding() - { - return HdrValue(CbmRawEventIndexDecoding); - } - - //same - uint32_t Size() - { - return HdrValue(CbmRawEventIndexSize); - } - //same - uint32_t *Hdr() - { - return (uint32_t *) fData; - } - //same - int IsSwapped() - { - uint32_t *hdr = Hdr(); - - return hdr[CbmRawEventIndexDecoding] > 0xffffff; - } - //same - uint32_t HdrValue(unsigned idx) - { - uint32_t *hdr = Hdr(); - - if (IsSwapped()) { - uint32_t tmp0; - uint32_t tmp1; - - tmp0 = hdr[idx]; - ((char *) &tmp1)[0] = ((char *) &tmp0)[3]; - ((char *) &tmp1)[1] = ((char *) &tmp0)[2]; - ((char *) &tmp1)[2] = ((char *) &tmp0)[1]; - ((char *) &tmp1)[3] = ((char *) &tmp0)[0]; - return tmp1; - } else { - return hdr[idx]; - } - } - //same - unsigned Alignment() - { - return 1 << (Decoding() >> 16 & 0xff); - } - - private: - CbmRawSubEvent(const CbmRawSubEvent&); - CbmRawSubEvent operator=(const CbmRawSubEvent&); - -}; - -#endif // CBMRAWSUBEVENT_H diff --git a/beamtime/rich/CbmRichBeamtimeLinkDef.h b/beamtime/rich/CbmRichBeamtimeLinkDef.h deleted file mode 100644 index e0b59d3a53802c1f6dcfe9f003eb8fb8b616e5b7..0000000000000000000000000000000000000000 --- a/beamtime/rich/CbmRichBeamtimeLinkDef.h +++ /dev/null @@ -1,25 +0,0 @@ -// $Id: RichLinkDef.h,v 1.16 2006/09/13 14:56:13 hoehne Exp $ - -#ifdef __CINT__ - -#pragma link off all globals; -#pragma link off all classes; -#pragma link off all functions; - -//prototype analysis (beamtime and lab) -#pragma link C++ class CbmRichTrbUnpack+; -#pragma link C++ class CbmRichTrbUnpack2+; -#pragma link C++ class CbmTrbEdgeMatcher+; -#pragma link C++ class CbmTrbCalibrator+; -#pragma link C++ class CbmRichTrbEventBuilder+; -#pragma link C++ class CbmRichProtoAnalysis+; -#pragma link C++ class CbmRichEventDebug+; -#pragma link C++ class CbmRichRingHitsAnalyser+; - -#pragma link C++ class CbmRichTrbRecoQa+; -#pragma link C++ class CbmRichTrbPulserQa+; -#pragma link C++ class CbmRichHitInfo+; -#pragma link C++ class CbmRichTrbRecoQaStudyReport+; - -#endif - diff --git a/beamtime/rich/CbmRichEpicsData.h b/beamtime/rich/CbmRichEpicsData.h deleted file mode 100644 index 7e6ff4025804af23a66a20bac9f45074b502d1bb..0000000000000000000000000000000000000000 --- a/beamtime/rich/CbmRichEpicsData.h +++ /dev/null @@ -1,218 +0,0 @@ -#ifndef CBMRICHEPICSDATA_H -#define CBMRICHEPICSDATA_H - -#include "TObject.h" - - - -class CbmRichEpicsData: public TObject -{ -public: - - CbmRichEpicsData(): - fCBM_BMP180_GetTemp(0.), - fCBM_BMP180_GetPressure(0.), - fDataFormatVersion(0), - fCBM_PWRSWITCH_GetCurrent00(0.), - fCBM_PWRSWITCH_GetCurrent01(0.), - fCBM_PWRSWITCH_GetCurrent02(0.), - fCBM_PWRSWITCH_GetCurrent03(0.), - fCBM_PWRSWITCH_GetCurrent04(0.), - fCBM_PWRSWITCH_GetCurrent05(0.), - fCBM_PWRSWITCH_GetCurrent06(0.), - fCBM_PWRSWITCH_GetCurrent07(0.), - fCBM_PWRSWITCH_GetCurrent08(0.), - fCBM_PWRSWITCH_GetCurrent09(0.), - fCBM_PWRSWITCH_GetCurrent0A(0.), - fCBM_PWRSWITCH_GetCurrent0B(0.), - fCBM_PWRSWITCH_GetCurrent0C(0.), - fCBM_PWRSWITCH_GetCurrent0D(0.), - fCBM_PWRSWITCH_GetCurrent0E(0.), - fCBM_PWRSWITCH_GetCurrent0F(0.), - fTimestampThresholdFile(0), - fOUTPUT_TERMINAL_VOLTAGE_U0(0.), - fMEASUREMENT_CURRENT_U0(0.), - fOUTPUT_TERMINAL_VOLTAGE_U1(0.), - fMEASUREMENT_CURRENT_U1(0.), - fOUTPUT_TERMINAL_VOLTAGE_U2(0.), - fMEASUREMENT_CURRENT_U2(0.), - fOUTPUT_TERMINAL_VOLTAGE_U3(0.), - fMEASUREMENT_CURRENT_U3(0.), - fOUTPUT_TERMINAL_VOLTAGE_U4(0.), - fMEASUREMENT_CURRENT_U4(0.), - fOUTPUT_TERMINAL_VOLTAGE_U5(0.), - fMEASUREMENT_CURRENT_U5(0.), - fOUTPUT_TERMINAL_VOLTAGE_U6(0.), - fMEASUREMENT_CURRENT_U6(0.), - fOUTPUT_TERMINAL_VOLTAGE_U7(0.), - fMEASUREMENT_CURRENT_U7(0.), - fOUTPUT_TERMINAL_VOLTAGE_U8(0.), - fMEASUREMENT_CURRENT_U8(0.), - fOUTPUT_TERMINAL_VOLTAGE_U9(0.), - fMEASUREMENT_CURRENT_U9(0.), - fOUTPUT_TERMINAL_VOLTAGE_U10(0.), - fMEASUREMENT_CURRENT_U10(0.), - fOUTPUT_TERMINAL_VOLTAGE_U11(0.), - fMEASUREMENT_CURRENT_U11(0.), - fOUTPUT_TERMINAL_VOLTAGE_U12(0.), - fMEASUREMENT_CURRENT_U12(0.), - fOUTPUT_TERMINAL_VOLTAGE_U13(0.), - fMEASUREMENT_CURRENT_U13(0.), - fOUTPUT_TERMINAL_VOLTAGE_U14(0.), - fMEASUREMENT_CURRENT_U14(0.), - fOUTPUT_TERMINAL_VOLTAGE_U15(0.), - fMEASUREMENT_CURRENT_U15(0.), - fCBM_RICH_Mirror_Pos_ActualPosition1(0.), - fCBM_RICH_Mirror_Pos_ActualPosition2(0.), - fCBM_RICH_Gas_O2(0.), - fCBM_RICH_Gas_H2O(0.), - fCBM_RICH_Gas_PT_1(0.), - fCBM_RICH_Gas_PTB(0.), - fCBM_RICH_Gas_PT_2(0.), - fCBM_RICH_Gas_PT_3(0.), - fCBM_RICH_Gas_TT_1(0.), - fCBM_RICH_Gas_TT_2(0.), - fCBM_RICH_Gas_PT_4(0.), - fCBM_RICH_Gas_FM_1(0.), - fCBM_RICH_Gas_RefrIndex(0.), - fPadiwaThresholdOffset(0) - { - ; - } - - /** - * \brief Print EPICS data. - */ - void Print(Option_t*) const - { - cout << "---EPICS DATA---" << endl; - cout << "fCBM_BMP180_GetTemp=" << fCBM_BMP180_GetTemp << " degrees C" << endl; - cout << "fCBM_BMP180_GetPressure=" << fCBM_BMP180_GetPressure << " Pa" <<endl; - cout << "fDataFormatVersion=" << fDataFormatVersion << endl; - cout << "fCBM_PWRSWITCH_GetCurrent [mA]: 00=" << fCBM_PWRSWITCH_GetCurrent00 << " 01=" << fCBM_PWRSWITCH_GetCurrent01 << - " 02=" << fCBM_PWRSWITCH_GetCurrent02 << " 03=" << fCBM_PWRSWITCH_GetCurrent03 << " 04=" << fCBM_PWRSWITCH_GetCurrent04 << - " 05=" << fCBM_PWRSWITCH_GetCurrent05 << " 06=" << fCBM_PWRSWITCH_GetCurrent06 << " 07=" << fCBM_PWRSWITCH_GetCurrent07 << - " 08=" << fCBM_PWRSWITCH_GetCurrent08 << " 08=" << fCBM_PWRSWITCH_GetCurrent08 << " 09=" << fCBM_PWRSWITCH_GetCurrent09 << - " 0A=" << fCBM_PWRSWITCH_GetCurrent0A << " 0B=" << fCBM_PWRSWITCH_GetCurrent0B << " 0C=" << fCBM_PWRSWITCH_GetCurrent0C << - " 0D=" << fCBM_PWRSWITCH_GetCurrent0D << " 0E=" << fCBM_PWRSWITCH_GetCurrent0E << " 0F=" << fCBM_PWRSWITCH_GetCurrent0F<< endl; - cout << "fTimestampThresholdFile=" << fTimestampThresholdFile << endl; - - cout << "(fOUTPUT_TERMINAL_VOLTAGE_U [V],fMEASUREMENT_CURRENT_U [uA]) " << - "U0=(" << fOUTPUT_TERMINAL_VOLTAGE_U0 << "," << fMEASUREMENT_CURRENT_U0 << ") " << - "U1=(" << fOUTPUT_TERMINAL_VOLTAGE_U1 << "," << fMEASUREMENT_CURRENT_U1 << ") " << - "U2=(" << fOUTPUT_TERMINAL_VOLTAGE_U2 << "," << fMEASUREMENT_CURRENT_U2 << ") " << - "U3=(" << fOUTPUT_TERMINAL_VOLTAGE_U3 << "," << fMEASUREMENT_CURRENT_U3 << ") " << - "U4=(" << fOUTPUT_TERMINAL_VOLTAGE_U4 << "," << fMEASUREMENT_CURRENT_U4 << ") " << - "U5=(" << fOUTPUT_TERMINAL_VOLTAGE_U5 << "," << fMEASUREMENT_CURRENT_U5 << ") " << - "U6=(" << fOUTPUT_TERMINAL_VOLTAGE_U6 << "," << fMEASUREMENT_CURRENT_U6 << ") " << - "U7=(" << fOUTPUT_TERMINAL_VOLTAGE_U7 << "," << fMEASUREMENT_CURRENT_U7 << ") " << - "U8=(" << fOUTPUT_TERMINAL_VOLTAGE_U8 << "," << fMEASUREMENT_CURRENT_U8 << ") " << - "U9=(" << fOUTPUT_TERMINAL_VOLTAGE_U9 << "," << fMEASUREMENT_CURRENT_U9 << ") " << - "U10=(" << fOUTPUT_TERMINAL_VOLTAGE_U10 << "," << fMEASUREMENT_CURRENT_U10 << ") " << - "U11=(" << fOUTPUT_TERMINAL_VOLTAGE_U11 << "," << fMEASUREMENT_CURRENT_U11 << ") " << - "U12=(" << fOUTPUT_TERMINAL_VOLTAGE_U12 << "," << fMEASUREMENT_CURRENT_U12 << ") " << - "U13=(" << fOUTPUT_TERMINAL_VOLTAGE_U13 << "," << fMEASUREMENT_CURRENT_U13 << ") " << - "U14=(" << fOUTPUT_TERMINAL_VOLTAGE_U14 << "," << fMEASUREMENT_CURRENT_U14 << ") " << - "U15=(" << fOUTPUT_TERMINAL_VOLTAGE_U15 << "," << fMEASUREMENT_CURRENT_U15 << ") " << endl; - - cout << "fCBM_RICH_Mirror_Pos_ActualPosition1=" << fCBM_RICH_Mirror_Pos_ActualPosition1 << " degrees" << endl; - cout << "fCBM_RICH_Mirror_Pos_ActualPosition2=" << fCBM_RICH_Mirror_Pos_ActualPosition2 << " degrees" <<endl; - cout << "fCBM_RICH_Gas_O2=" << fCBM_RICH_Gas_O2 << " ppm" << endl; - cout << "fCBM_RICH_Gas_H2O=" << fCBM_RICH_Gas_H2O << " ppm" << endl; - cout << "fCBM_RICH_Gas_PT_1=" << fCBM_RICH_Gas_PT_1 << endl; - cout << "fCBM_RICH_Gas_PTB=" << fCBM_RICH_Gas_PTB << endl; - cout << "fCBM_RICH_Gas_PT_2=" << fCBM_RICH_Gas_PT_2 << endl; - cout << "fCBM_RICH_Gas_PT_3=" << fCBM_RICH_Gas_PT_3 << endl; - cout << "fCBM_RICH_Gas_TT_1=" << fCBM_RICH_Gas_TT_1 << endl; - cout << "fCBM_RICH_Gas_TT_2=" << fCBM_RICH_Gas_TT_2 << endl; - cout << "fCBM_RICH_Gas_PT_4=" << fCBM_RICH_Gas_PT_4 << endl; - cout << "fCBM_RICH_Gas_FM_1=" << fCBM_RICH_Gas_FM_1 << endl; - cout << "fCBM_RICH_Gas_RefrIndex=" << fCBM_RICH_Gas_RefrIndex << endl; - cout << "fPadiwaThresholdOffset=" << fPadiwaThresholdOffset << endl; - } - - Double_t fCBM_BMP180_GetTemp; //Gas Temperatur in °C measured in Box - Double_t fCBM_BMP180_GetPressure; //Gas Pressure in Pa measured in Box - - Int_t fDataFormatVersion; //Data Format version: 0x00 - - Double_t fCBM_PWRSWITCH_GetCurrent00; //Current measured for Padiwa-Supply 1 in mA - Double_t fCBM_PWRSWITCH_GetCurrent01; //Current measured for Padiwa-Supply 2 in mA - Double_t fCBM_PWRSWITCH_GetCurrent02; //Current measured for Padiwa-Supply 3 in mA - Double_t fCBM_PWRSWITCH_GetCurrent03; //Current measured for Padiwa-Supply 4 in mA - Double_t fCBM_PWRSWITCH_GetCurrent04; //Current measured for Padiwa-Supply 5 in mA - Double_t fCBM_PWRSWITCH_GetCurrent05; //Current measured for Padiwa-Supply 6 in mA - Double_t fCBM_PWRSWITCH_GetCurrent06; //Current measured for Padiwa-Supply 7 in mA - Double_t fCBM_PWRSWITCH_GetCurrent07; //Current measured for Padiwa-Supply 8 in mA - Double_t fCBM_PWRSWITCH_GetCurrent08; //Current measured for Padiwa-Supply 9 in mA - Double_t fCBM_PWRSWITCH_GetCurrent09; //Current measured for Padiwa-Supply 10 in mA - Double_t fCBM_PWRSWITCH_GetCurrent0A; //Current measured for Padiwa-Supply 11 in mA - Double_t fCBM_PWRSWITCH_GetCurrent0B; //Current measured for Padiwa-Supply 12 in mA - Double_t fCBM_PWRSWITCH_GetCurrent0C; //Current measured for Padiwa-Supply 13 in mA - Double_t fCBM_PWRSWITCH_GetCurrent0D; //Current measured for Padiwa-Supply 14 in mA - Double_t fCBM_PWRSWITCH_GetCurrent0E; //Current measured for Padiwa-Supply 15 in mA - Double_t fCBM_PWRSWITCH_GetCurrent0F; //Current measured for Padiwa-Supply 16 in mA - - Int_t fTimestampThresholdFile; //Unix-Timestamp of Threshold file used (based on the time information found in the first line of the Threshold-Log file) - - Double_t fOUTPUT_TERMINAL_VOLTAGE_U0; //HV Voltage of PMT 1 in V - Double_t fMEASUREMENT_CURRENT_U0; //HV Current of PMT 1 in uA - Double_t fOUTPUT_TERMINAL_VOLTAGE_U1; //HV Voltage of PMT 2 in V - Double_t fMEASUREMENT_CURRENT_U1; //HV Current of PMT 2 in uA - Double_t fOUTPUT_TERMINAL_VOLTAGE_U2; //HV Voltage of PMT 3 in V - Double_t fMEASUREMENT_CURRENT_U2; //HV Current of PMT 3 in uA - Double_t fOUTPUT_TERMINAL_VOLTAGE_U3; //HV Voltage of PMT 4 in V - Double_t fMEASUREMENT_CURRENT_U3; //HV Current of PMT 4 in uA - Double_t fOUTPUT_TERMINAL_VOLTAGE_U4; //HV Voltage of PMT 5 in V - Double_t fMEASUREMENT_CURRENT_U4; //HV Current of PMT 5 in uA - Double_t fOUTPUT_TERMINAL_VOLTAGE_U5; //HV Voltage of PMT 6 in V - Double_t fMEASUREMENT_CURRENT_U5; //HV Current of PMT 6 in uA - Double_t fOUTPUT_TERMINAL_VOLTAGE_U6; //HV Voltage of PMT 7 in V - Double_t fMEASUREMENT_CURRENT_U6; //HV Current of PMT 7 in uA - Double_t fOUTPUT_TERMINAL_VOLTAGE_U7; //HV Voltage of PMT 8 in V - Double_t fMEASUREMENT_CURRENT_U7; //HV Current of PMT 8 in uA - Double_t fOUTPUT_TERMINAL_VOLTAGE_U8; //HV Voltage of PMT 9 in V - Double_t fMEASUREMENT_CURRENT_U8; //HV Current of PMT 9 in uA - Double_t fOUTPUT_TERMINAL_VOLTAGE_U9; //HV Voltage of PMT 10 in V - Double_t fMEASUREMENT_CURRENT_U9; //HV Current of PMT 10 in uA - Double_t fOUTPUT_TERMINAL_VOLTAGE_U10; //HV Voltage of PMT 11 in V - Double_t fMEASUREMENT_CURRENT_U10; //HV Current of PMT 11 in uA - Double_t fOUTPUT_TERMINAL_VOLTAGE_U11; //HV Voltage of PMT 12 in V - Double_t fMEASUREMENT_CURRENT_U11; //HV Current of PMT 12 in uA - Double_t fOUTPUT_TERMINAL_VOLTAGE_U12; //HV Voltage of PMT 13 in V - Double_t fMEASUREMENT_CURRENT_U12; //HV Current of PMT 13 in uA - Double_t fOUTPUT_TERMINAL_VOLTAGE_U13; //HV Voltage of PMT 14 in V - Double_t fMEASUREMENT_CURRENT_U13; //HV Current of PMT 14 in uA - Double_t fOUTPUT_TERMINAL_VOLTAGE_U14; //HV Voltage of PMT 15 in V - Double_t fMEASUREMENT_CURRENT_U14; //HV Current of PMT 15 in uA - Double_t fOUTPUT_TERMINAL_VOLTAGE_U15; //HV Voltage of PMT 16 in V - Double_t fMEASUREMENT_CURRENT_U15; //HV Current of PMT 16 in uA - - Double_t fCBM_RICH_Mirror_Pos_ActualPosition1; //Mirror Position 1 in ° - Double_t fCBM_RICH_Mirror_Pos_ActualPosition2; //Mirror Position 2 in ° - - Double_t fCBM_RICH_Gas_O2; //O2 concentration of gas in ppm - Double_t fCBM_RICH_Gas_H2O; //H2O concentration of gas in ppm - - Double_t fCBM_RICH_Gas_PT_1; // ? - Double_t fCBM_RICH_Gas_PTB; // ? - - Double_t fCBM_RICH_Gas_PT_2; // ? - Double_t fCBM_RICH_Gas_PT_3; // ? - - Double_t fCBM_RICH_Gas_TT_1; // ? - Double_t fCBM_RICH_Gas_TT_2; // ? - - Double_t fCBM_RICH_Gas_PT_4; // ? - Double_t fCBM_RICH_Gas_FM_1; //? - - Double_t fCBM_RICH_Gas_RefrIndex; //? - - Int_t fPadiwaThresholdOffset; // Padiwa Threshold offset +32768 - -private: - CbmRichEpicsData(const CbmRichEpicsData&); - CbmRichEpicsData operator=(const CbmRichEpicsData&); -}; - -#endif // CBMRICHEPICSDATA_H diff --git a/beamtime/rich/CbmRichEventDebug.cxx b/beamtime/rich/CbmRichEventDebug.cxx deleted file mode 100644 index ea6f040cdc7afade3d09c0b67474aa48792fd7b5..0000000000000000000000000000000000000000 --- a/beamtime/rich/CbmRichEventDebug.cxx +++ /dev/null @@ -1,81 +0,0 @@ -#include "CbmRichEventDebug.h" - -#include "FairLogger.h" - -#include "TClonesArray.h" -#include "TH1.h" -#include "TH2.h" -#include "TCanvas.h" -#include <TFile.h> -#include "CbmRichHit.h" - -CbmRichEventDebug::CbmRichEventDebug() - : FairTask(), - fRichHits(NULL), - fRichHitInfos(NULL), - fSingleEventFilled(kFALSE), - fOutHistoFile(""), - fHM(NULL) -{ - -} - -CbmRichEventDebug::~CbmRichEventDebug() -{ - -} - -InitStatus CbmRichEventDebug::Init() -{ - FairRootManager* manager = FairRootManager::Instance(); - - fRichHits = (TClonesArray*)manager->GetObject("RichHit"); - if (NULL == fRichHits) { Fatal("CbmRichEventDebug::Init","No RichHit array!"); } - - fRichHitInfos = (TClonesArray*)manager->GetObject("RichHitInfo"); - if (NULL == fRichHitInfos) { Fatal("CbmRichEventDebug::Init","No RichHitInfo array!"); } - - fHM = new CbmHistManager(); - fHM->Create1<TH1D>("fhNumOfHitsInEvent", "Number of hits in the event", 1000, 0, 1000); - fHM->Create2<TH2D>("fhSingleEvent", "Single event", 32, 0., 32., 32, 0., 32.); - - return kSUCCESS; -} - -void CbmRichEventDebug::Exec(Option_t* /*option*/) -{ - UInt_t numOfHits = fRichHits->GetEntriesFast(); - if (numOfHits > 0) { - fHM->H1("fhNumOfHitsInEvent")->Fill(numOfHits); - - LOG(info) << numOfHits << " hits."; - - //if (!fSingleEventFilled && numOfHits == 12) - { - for (UInt_t i=0; i<numOfHits; i++) { - CbmRichHit* theHit = static_cast<CbmRichHit*>(fRichHits->At(i)); - fHM->H2("fhSingleEvent")->Fill(theHit->GetX(), theHit->GetY()); - } - fSingleEventFilled = kTRUE; - } - - } -} - -void CbmRichEventDebug::Finish() -{ - new TCanvas("cNumOfHitsInEvent", "cNumOfHitsInEvent", 800, 800); - DrawH1(fHM->H1("fhNumOfHitsInEvent")); - - if (fSingleEventFilled) { - new TCanvas("cSingleEvent", "cSingleEvent", 800, 800); - DrawH2(fHM->H2("fhSingleEvent")); - } - - TFile* curHistoFile = new TFile(fOutHistoFile, "CREATE"); - LOG(info) << "Opening file " << fOutHistoFile << " for histograms"; - fHM->WriteToFile(); - curHistoFile->Close(); -} - -ClassImp(CbmRichEventDebug) diff --git a/beamtime/rich/CbmRichEventDebug.h b/beamtime/rich/CbmRichEventDebug.h deleted file mode 100644 index a7794854d5a8b3a181d59f65ce4ee49ab058b78e..0000000000000000000000000000000000000000 --- a/beamtime/rich/CbmRichEventDebug.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef CBMRICHEVENTDEBUG_H -#define CBMRICHEVENTDEBUG_H - -#include "FairTask.h" - -#include "CbmHistManager.h" -#include "CbmDrawHist.h" - -class TClonesArray; - - -class CbmRichEventDebug : public FairTask -{ -public: - CbmRichEventDebug(); - virtual ~CbmRichEventDebug(); - - virtual InitStatus Init(); - virtual void Exec(Option_t* option); - virtual void Finish(); - - void SetOutHistoFile(TString filename) {fOutHistoFile = filename;} - - -private: - - TClonesArray* fRichHits; // input - TClonesArray* fRichHitInfos; // input - - Bool_t fSingleEventFilled; - - TString fOutHistoFile; - - CbmHistManager* fHM; - - //TODO implement or get rid - CbmRichEventDebug(const CbmRichEventDebug&); - CbmRichEventDebug operator=(const CbmRichEventDebug&); - - ClassDef(CbmRichEventDebug, 1); -}; - - -#endif // CBMRICHEVENTDEBUG_H diff --git a/beamtime/rich/CbmRichHitInfo.cxx b/beamtime/rich/CbmRichHitInfo.cxx deleted file mode 100644 index 7d358be2b6630abb66be23bfec31b6d55e2dd7d2..0000000000000000000000000000000000000000 --- a/beamtime/rich/CbmRichHitInfo.cxx +++ /dev/null @@ -1,6 +0,0 @@ - -#include "CbmRichHitInfo.h" - - - -ClassImp(CbmRichHitInfo) diff --git a/beamtime/rich/CbmRichHitInfo.h b/beamtime/rich/CbmRichHitInfo.h deleted file mode 100644 index a2c37dda16b484bc497c48de9dfa98855a3c695e..0000000000000000000000000000000000000000 --- a/beamtime/rich/CbmRichHitInfo.h +++ /dev/null @@ -1,98 +0,0 @@ -#ifndef CBMRICHHITINFO_H -#define CBMRICHHITINFO_H - -#include "TObject.h" - -class CbmRichHitInfo : public TObject -{ -public: - CbmRichHitInfo(): - fPmtNum(0), - fPixelNum(0), - fX(0), - fY(0), - fXPixel(0), - fYPixel(0), - fTdcId(0), - fLeadingChannel(0), - fTrailingChannel(0), - fPadiwaNum(0), - fTrbNum(0), - fPmtTypeId(0) - { - - } - - CbmRichHitInfo(UInt_t pmtNum, UInt_t pixelNum, Double_t x, Double_t y, UInt_t xPixel, UInt_t yPixel, - UInt_t tdcId, UInt_t leadingChanel, UInt_t trailingChanel, UInt_t padiwaNum, UInt_t trbNum, UInt_t pmtTypeId): - fPmtNum(pmtNum), - fPixelNum(pixelNum), - fX(x), - fY(y), - fXPixel(xPixel), - fYPixel(yPixel), - fTdcId(tdcId), - fLeadingChannel(leadingChanel), - fTrailingChannel(trailingChanel), - fPadiwaNum(padiwaNum), - fTrbNum(trbNum), - fPmtTypeId(pmtTypeId) - { - - } - - virtual ~CbmRichHitInfo() - { - - } - - void Copy(CbmRichHitInfo* hitInfo) - { - fPmtNum = hitInfo->GetPmtNum(); - fPixelNum = hitInfo->GetPixelNum(); - fX = hitInfo->GetX(); - fY = hitInfo->GetY(); - fXPixel = hitInfo->GetXPixel(); - fYPixel = hitInfo->GetYPixel(); - fTdcId = hitInfo->GetTdcId(); - fLeadingChannel = hitInfo->GetLeadingChannel(); - fTrailingChannel = hitInfo->GetTrailingChannel(); - fPadiwaNum = hitInfo->GetPadiwaNum(); - fTrbNum = hitInfo->GetTrbNum(); - fPmtTypeId = hitInfo->GetPmtTypeId(); - } - - // avoid warnings - void Copy(TObject&) const {;} - - UInt_t GetPmtNum() const {return fPmtNum;} - UInt_t GetPixelNum() const {return fPixelNum;} - Double_t GetX() const {return fX;} - Double_t GetY() const {return fY;} - UInt_t GetXPixel() const {return fXPixel;} - UInt_t GetYPixel() const {return fYPixel;} - UInt_t GetTdcId() const {return fTdcId;} - UInt_t GetLeadingChannel() const {return fLeadingChannel;} - UInt_t GetTrailingChannel() const {return fTrailingChannel;} - UInt_t GetPadiwaNum() const {return fPadiwaNum;} - UInt_t GetTrbNum() const {return fTrbNum;} - UInt_t GetPmtTypeId() const {return fPmtTypeId;} - -private: - UInt_t fPmtNum; // PMT number - UInt_t fPixelNum; // Pixel number - Double_t fX; // X coordinate in cm - Double_t fY; // Y coordinate in cm - UInt_t fXPixel; // X coordinate in pixels - UInt_t fYPixel; // Y coordinate in pixels - UInt_t fTdcId; // TDC ID - UInt_t fLeadingChannel; // leading channel number - UInt_t fTrailingChannel; // trailing channel number - UInt_t fPadiwaNum; // PADIWA number - UInt_t fTrbNum; // TRB number - UInt_t fPmtTypeId; // type Id of PMT PMT-Type - - ClassDef(CbmRichHitInfo, 1) -}; - -#endif diff --git a/beamtime/rich/CbmRichProtoAnalysis.cxx b/beamtime/rich/CbmRichProtoAnalysis.cxx deleted file mode 100644 index 87175b1879b2a4d830f525dcd2ededcbc6fd9604..0000000000000000000000000000000000000000 --- a/beamtime/rich/CbmRichProtoAnalysis.cxx +++ /dev/null @@ -1,193 +0,0 @@ -#include "CbmRichProtoAnalysis.h" -#include "FairRootManager.h" -#include "FairLogger.h" - -#include "CbmRichTrbDefines.h" -#include "CbmRichTrbDigi.h" -#include "CbmRichTrbParam.h" - -#include "CbmRichHit.h" -#include "CbmRichHitInfo.h" - -#include "TCanvas.h" -#include "TH1.h" -#include "TF1.h" -#include "TClonesArray.h" -#include <TFile.h> - -#include "CbmUtils.h" - -// Uncomment if you want to have excessive printout (do not execute on many events, may produce Gb's of output) -#define DEBUGPRINT - -#define TESTEDTDC 0x0010 - -CbmRichProtoAnalysis::CbmRichProtoAnalysis() - : FairTask(), - fRichTrbDigi(NULL), - fRichHits(NULL), - fRichHitInfos(NULL), - numOfPairs(0), - numOfSingleEdges(0), - numOfSingleEdgesSync(0), - fHM(NULL), - fRunTitle(""), - fOutputDir(""), - fOutHistoFile("") -{ -} - -CbmRichProtoAnalysis::~CbmRichProtoAnalysis() -{ -} - -InitStatus CbmRichProtoAnalysis::Init() -{ - FairRootManager* manager = FairRootManager::Instance(); - fRichTrbDigi = (TClonesArray*)manager->GetObject("CbmRichTrbDigi"); - if (NULL == fRichTrbDigi) { Fatal("CbmRichProtoAnalysis::Init","No CbmRichTrbDigi array!"); } - - fRichHits = new TClonesArray("CbmRichHit", 10); - manager->Register("RichHit", "RICH", fRichHits, IsOutputBranchPersistent("RichHit")); - - fRichHitInfos = new TClonesArray("CbmRichHitInfo", 10); - manager->Register("RichHitInfo", "RICH", fRichHitInfos, IsOutputBranchPersistent("RichHitInfo")); - - InitHist(); - - return kSUCCESS; -} - -void CbmRichProtoAnalysis::InitHist() -{ - fHM = new CbmHistManager(); - fHM->Create1<TH1D>("fNumOfDigis", "fNumOfDigis", 200, 0, 200); - fHM->Create1<TH1D>("fNumOfDigisSent", "fNumOfDigis", 200, 0, 200); -} - -void CbmRichProtoAnalysis::DrawHist() -{ -} - -void CbmRichProtoAnalysis::Exec(Option_t* /*option*/) -{ - // Get the parameters object - CbmRichTrbParam* param = CbmRichTrbParam::Instance(); - - // Empty output TClonesArray - fRichHits->Clear(); - fRichHitInfos->Clear(); - - // Save the number of messages coming into this task in this event - Int_t nofDigisInEvent = fRichTrbDigi->GetEntries(); - - fHM->H1("fNumOfDigis")->Fill(nofDigisInEvent); -/* - if (nofDigisInEvent > 60) { - printf ("-----------------------------------------------------------------------------------------\n"); - for (Int_t i=0; i<nofDigisInEvent; i++) { - CbmRichTrbDigi* theDigit = static_cast<CbmRichTrbDigi*>(fRichTrbDigi->At(i)); - printf ("tdc %04x\tch %d\t%f\t\tch %d\t%f\n", theDigit->GetTDCid(), - theDigit->GetLeadingEdgeChannel(), theDigit->GetLeadingEdgeTimeStamp(), - theDigit->GetTrailingEdgeChannel(), theDigit->GetTrailingEdgeTimeStamp()); - } - } -*/ - - // Find the trigger (hodo) - Bool_t hodoFound = kFALSE; - Bool_t Cherenkov1Found = kFALSE; - Bool_t Cherenkov2Found = kFALSE; - for (Int_t i=0; i<nofDigisInEvent; i++) { - CbmRichTrbDigi* theDigit = static_cast<CbmRichTrbDigi*>(fRichTrbDigi->At(i)); - - if (theDigit->GetTDCid() == 0x0110 && theDigit->GetLeadingEdgeChannel() == 5) { - hodoFound = kTRUE; - //LOG(info) << "hodoFound = kTRUE"; - break; - } - if (theDigit->GetTDCid() == 0x0110 && theDigit->GetLeadingEdgeChannel() == 9) { - Cherenkov1Found = kTRUE; - //LOG(info) << "Cherenkov1Found = kTRUE"; - break; - } - if (theDigit->GetTDCid() == 0x0110 && theDigit->GetLeadingEdgeChannel() == 11) { - Cherenkov2Found = kTRUE; - //LOG(info) << "Cherenkov2Found = kTRUE"; - break; - } - - } - - if (!hodoFound && !Cherenkov1Found && !Cherenkov2Found) return; - - UInt_t counterDigisSent=0; - - for (Int_t i=0; i<nofDigisInEvent; i++) { - CbmRichTrbDigi* theDigit = static_cast<CbmRichTrbDigi*>(fRichTrbDigi->At(i)); - if (theDigit->GetHasLeadingEdge() && theDigit->GetHasTrailingEdge()) { - numOfPairs++; // Global - per run - - UInt_t curLch = theDigit->GetLeadingEdgeChannel(); - - CbmRichHitInfo* hitData = param->GetRichHitInfo(theDigit->GetTDCid(), curLch); - - // This happens if the beam detector signal appears (from tdc 0x0110, 0x0111, 0x0113); - // 0x0112 is skipped during unpacking - if (hitData == NULL) { - //printf ("Asking for param %04x ch %d\n", theDigit->GetTDCid(), curLch); - //printf ("hitData == NULL\n"); - continue; - } - - counterDigisSent++; - //printf (" ... %.8f\t%.8f\t%.8f\t%.8f\t", hitData->GetX(), hitData->GetY(), - // theDigit->GetLeadingEdgeTimeStamp(), theDigit->GetTOT()); - - new( (*fRichHits)[fRichHits->GetEntriesFast()] ) - CbmRichHit(hitData->GetX(), hitData->GetY(), - theDigit->GetLeadingEdgeTimeStamp(), theDigit->GetTOT()); - - //printf (" ... "); - - UInt_t counter2 = fRichHitInfos->GetEntries(); - new((*fRichHitInfos)[counter2]) CbmRichHitInfo(); - CbmRichHitInfo* newHitInfo = static_cast<CbmRichHitInfo*>(fRichHitInfos->At(counter2)); - - //printf (" ... "); - - newHitInfo->Copy(hitData); - - //printf (" ...\n"); - - } else { - if (theDigit->GetHasLeadingEdge() && !(theDigit->GetHasTrailingEdge()) && param->IsSyncChannel(theDigit->GetLeadingEdgeChannel())) { - numOfSingleEdgesSync++; - } else { - numOfSingleEdges++; - } - } - } - - fHM->H1("fNumOfDigisSent")->Fill(counterDigisSent); - -} - -void CbmRichProtoAnalysis::Finish() -{ - TFile* curHistoFile = new TFile(fOutHistoFile, "UPDATE"); - LOG(info) << "Opening file " << fOutHistoFile << " for histograms"; - fHM->WriteToFile(); - curHistoFile->Close(); - - UInt_t totalMessages = numOfPairs*2 + numOfSingleEdges + numOfSingleEdgesSync; - - LOG(info) << "[CbmRichProtoAnalysis] " << numOfPairs << " pairs; " << numOfSingleEdges << " single edges (not incl.) " - << numOfSingleEdgesSync << " sync messages; Total " << totalMessages << " messages"; - - LOG(info) << 100.*(Double_t)numOfPairs*2. / (Double_t)totalMessages << "%, " - << 100.*(Double_t)numOfSingleEdges / (Double_t)totalMessages << "%, " - << 100.*(Double_t)numOfSingleEdgesSync / (Double_t)totalMessages << "%"; -} - -ClassImp(CbmRichProtoAnalysis) diff --git a/beamtime/rich/CbmRichProtoAnalysis.h b/beamtime/rich/CbmRichProtoAnalysis.h deleted file mode 100644 index 2940768290fab6b7e6f005e6805b96321e89e14d..0000000000000000000000000000000000000000 --- a/beamtime/rich/CbmRichProtoAnalysis.h +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef CBMRICHPROTOANALYSIS_H -#define CBMRICHPROTOANALYSIS_H - -#include "FairTask.h" - -#include "CbmHistManager.h" -#include "CbmDrawHist.h" - -class TClonesArray; - -class CbmRichProtoAnalysis : public FairTask -{ -public: - - CbmRichProtoAnalysis(); - virtual ~CbmRichProtoAnalysis(); - - virtual InitStatus Init(); - virtual void Exec(Option_t* option); - virtual void Finish(); - void InitHist(); - void DrawHist(); - void SetRunTitle(TString title) { fRunTitle = title; } - void SetOutputDir(TString dir) {fOutputDir = dir;} - void SetOutHistoFile(TString filename) {fOutHistoFile = filename;} - - -private: - - TClonesArray* fRichTrbDigi; // input - TClonesArray* fRichHits; // output - TClonesArray* fRichHitInfos; // output - - Int_t numOfPairs; - Int_t numOfSingleEdges; - Int_t numOfSingleEdgesSync; - - CbmHistManager* fHM; - - TString fRunTitle; // Title of the run - TString fOutputDir; // output directory to store figures - TString fOutHistoFile; - - //TODO implement or get rid - CbmRichProtoAnalysis(const CbmRichProtoAnalysis&); - CbmRichProtoAnalysis operator=(const CbmRichProtoAnalysis&); - - ClassDef(CbmRichProtoAnalysis, 1); -}; - -#endif // CBMRICHPROTOANALYSIS_H diff --git a/beamtime/rich/CbmRichRingHitsAnalyser.cxx b/beamtime/rich/CbmRichRingHitsAnalyser.cxx deleted file mode 100644 index 3b3fabf9b5729f971767dc96a832b8016ff86421..0000000000000000000000000000000000000000 --- a/beamtime/rich/CbmRichRingHitsAnalyser.cxx +++ /dev/null @@ -1,434 +0,0 @@ -/* - * CbmRichRingHitsAnalyser.cxx - * - * Created on: Apr 15, 2015 - * Author: evovch - */ - -#include "CbmRichRingHitsAnalyser.h" - -#include "FairLogger.h" - -#include "TClonesArray.h" -#include "TH1.h" -#include "TH2.h" -#include "TCanvas.h" -#include <TFile.h> - -#include "CbmRichRing.h" -#include "CbmRichHit.h" -#include "CbmRichHitInfo.h" -#include "CbmRichTrbParam.h" - -#include <vector> -#include <fstream> -#include <math.h> - -CbmRichRingHitsAnalyser::CbmRichRingHitsAnalyser() - : FairTask(), - fRichHits(NULL), - fRichRings(NULL), - fRichHitInfos(NULL), - fWlsState(""), - fInputFileBasename(""), - fRingCutsFile(""), - fOutHistoFile(""), - fConditionsMap(), - fRingCondition(), - fApplyRingCcut(kFALSE), - fApplyRingRcut(kFALSE), - fHM(NULL) -{ - fRingCondition.cxmin = 0.; - fRingCondition.cxmax = 21.; - fRingCondition.cymin = 0.; - fRingCondition.cymax = 21.; - fRingCondition.rmin = 0.; - fRingCondition.rmax = 10.; -} - -CbmRichRingHitsAnalyser::~CbmRichRingHitsAnalyser() -{ -} - -InitStatus CbmRichRingHitsAnalyser::Init() -{ - FairRootManager* manager = FairRootManager::Instance(); - - fRichHits = (TClonesArray*)manager->GetObject("RichHit"); - if (NULL == fRichHits) { Fatal("CbmRichRingHitsAnalyser::Init","No RichHit array!"); } - - fRichRings = (TClonesArray*)manager->GetObject("RichRing"); - if (NULL == fRichRings) { Fatal("CbmRichRingHitsAnalyser::Init","No RichRing array!"); } - - fRichHitInfos = (TClonesArray*)manager->GetObject("RichHitInfo"); - if (NULL == fRichHitInfos) { Fatal("CbmRichRingHitsAnalyser::Init","No RichHitInfo array!"); } - - fHM = new CbmHistManager(); - - - TString histoName; - TString histoTitle; - - Double_t K, minWin, maxWin; - - K = 100.; // 1000/W=K, where W - desired bin width in ps. - minWin = -50.; - maxWin = 50.; - -/* - Int_t tdcNum; - for (tdcNum=1; tdcNum<=16; tdcNum++) { - for (Int_t i=0; i<16; i++) { - for (Int_t j=i; j<16; j++) { - histoName.Form("LeadingEdgeDiff_TDC%x0_%d_%d", tdcNum, i, j); - histoTitle.Form("LeadingEdgeDiff_TDC%x0_%d_%d;ns;Entries", tdcNum, i, j); - fHM->Create1<TH1D>(histoName.Data(), histoTitle.Data(), K*(maxWin-minWin), minWin, maxWin); - histoName.Form("LeadingEdgeDiff_TDC%x1_%d_%d", tdcNum, i, j); - histoTitle.Form("LeadingEdgeDiff_TDC%x1_%d_%d;ns;Entries", tdcNum, i, j); - fHM->Create1<TH1D>(histoName.Data(), histoTitle.Data(), K*(maxWin-minWin), minWin, maxWin); - histoName.Form("LeadingEdgeDiff_TDC%x2_%d_%d", tdcNum, i, j); - histoTitle.Form("LeadingEdgeDiff_TDC%x2_%d_%d;ns;Entries", tdcNum, i, j); - fHM->Create1<TH1D>(histoName.Data(), histoTitle.Data(), K*(maxWin-minWin), minWin, maxWin); - histoName.Form("LeadingEdgeDiff_TDC%x3_%d_%d", tdcNum, i, j); - histoTitle.Form("LeadingEdgeDiff_TDC%x3_%d_%d;ns;Entries", tdcNum, i, j); - fHM->Create1<TH1D>(histoName.Data(), histoTitle.Data(), K*(maxWin-minWin), minWin, maxWin); - } - } - } -*/ -/* - TString tdcIDs[16]; - tdcIDs[0] = "10"; tdcIDs[1] = "11"; tdcIDs[2] = "12"; tdcIDs[3] = "13"; - tdcIDs[4] = "20"; tdcIDs[5] = "21"; tdcIDs[6] = "22"; tdcIDs[7] = "23"; - tdcIDs[8] = "50"; tdcIDs[9] = "51"; tdcIDs[10] = "52"; tdcIDs[11] = "53"; - tdcIDs[12] = "60"; tdcIDs[13] = "61"; tdcIDs[14] = "62"; tdcIDs[15] = "63"; - - for (Int_t tdc1J=0; tdc1J<=15; tdc1J++) { - Int_t tdc2J = tdc1J; - for (Int_t ch1=0; ch1<=15; ch1++) { - for (Int_t ch2=ch1; ch2<=15; ch2++) { - histoName.Form("LeadingEdgeDiff_TDC%s_ch%d_TDC%s_ch%d", tdcIDs[tdc1J].Data(), ch1, tdcIDs[tdc2J].Data(), ch2); - histoTitle.Form("LeadingEdgeDiff_TDC%s_ch%d_TDC%s_ch%d", tdcIDs[tdc1J].Data(), ch1, tdcIDs[tdc2J].Data(), ch2); - fHM->Create1<TH1D>(histoName.Data(), histoTitle.Data(), K*(maxWin-minWin), minWin, maxWin); - //printf ("%s\n", histoName.Data()); - } - } - for (tdc2J=tdc1J+1; tdc2J<=15; tdc2J++) { - for (Int_t ch1=0; ch1<=15; ch1++) { - for (Int_t ch2=0; ch2<=15; ch2++) { - histoName.Form("LeadingEdgeDiff_TDC%s_ch%d_TDC%s_ch%d", tdcIDs[tdc1J].Data(), ch1, tdcIDs[tdc2J].Data(), ch2); - histoTitle.Form("LeadingEdgeDiff_TDC%s_ch%d_TDC%s_ch%d", tdcIDs[tdc1J].Data(), ch1, tdcIDs[tdc2J].Data(), ch2); - fHM->Create1<TH1D>(histoName.Data(), histoTitle.Data(), K*(maxWin-minWin), minWin, maxWin); - //printf ("%s\n", histoName.Data()); - } - } - } - } -*/ - - histoName.Form("hDistBetwDoubleRings"); - histoTitle.Form("hDistBetwDoubleRings"); - fHM->Create1<TH1D>(histoName.Data(), histoTitle.Data(), 200, 0, 100.); - - histoName.Form("hDeltaRdoubleRings"); - histoTitle.Form("hDeltaRdoubleRings"); - fHM->Create1<TH1D>(histoName.Data(), histoTitle.Data(), 200, 0, 100.); - - - histoName.Form("hNumOfRingInEvent"); - histoTitle.Form("hNumOfRingInEvent"); - fHM->Create1<TH1D>(histoName.Data(), histoTitle.Data(), 100, 0, 100); - - histoName.Form("hNumOfHitsOnRing"); - histoTitle.Form("hNumOfHitsOnRing"); - fHM->Create1<TH1D>(histoName.Data(), histoTitle.Data(), 100, 0, 100); -/* - histoName.Form("hNumOfHitsOnRing_PMT1"); - histoTitle.Form("hNumOfHitsOnRing_PMT1"); - fHM->Create1<TH1D>(histoName.Data(), histoTitle.Data(), 100, 0, 100); - histoName.Form("hNumOfHitsOnRing_PMT2"); - histoTitle.Form("hNumOfHitsOnRing_PMT2"); - fHM->Create1<TH1D>(histoName.Data(), histoTitle.Data(), 100, 0, 100); - histoName.Form("hNumOfHitsOnRing_PMT5"); - histoTitle.Form("hNumOfHitsOnRing_PMT5"); - fHM->Create1<TH1D>(histoName.Data(), histoTitle.Data(), 100, 0, 100); - histoName.Form("hNumOfHitsOnRing_PMT6"); - histoTitle.Form("hNumOfHitsOnRing_PMT6"); - fHM->Create1<TH1D>(histoName.Data(), histoTitle.Data(), 100, 0, 100); -*/ - histoName.Form("FirstPixelInRing"); - histoTitle.Form("FirstPixelInRing"); - fHM->Create1<TH1D>(histoName.Data(), histoTitle.Data(), 512, 0, 512); - - histoName.Form("ExponentaBudetTut"); - histoTitle.Form("ExponentaBudetTut"); - fHM->Create1<TH1D>(histoName.Data(), histoTitle.Data(), K*(maxWin-minWin), minWin, maxWin); - - // Histogram for rings centers - histoName.Form("RingsCenters1"); - histoTitle.Form("Centers of the found rings 1"); - fHM->Create2<TH2D>(histoName.Data(), histoTitle.Data(), 200, 0., 50., 200, 0., 50.); - - histoName.Form("RingsCenters2"); - histoTitle.Form("Centers of the found rings 2"); - fHM->Create2<TH2D>(histoName.Data(), histoTitle.Data(), 200, 0., 50., 200, 0., 50.); - - histoName.Form("RingsRadii"); - histoTitle.Form("Radii of the found rings"); - fHM->Create1<TH1D>(histoName.Data(), histoTitle.Data(), 200, 0., 10.); - - if (fApplyRingCcut || fApplyRingRcut) - { - // Read the full set of conditions - ifstream ifstr (fRingCutsFile.Data(), std::ios::in); - string curInfile; - TString root_CurInfile; - Double_t v_cxmin, v_cxmax, v_cymin, v_cymax, v_rmin, v_rmax; - while (!ifstr.eof()) { - ifstr >> curInfile >> v_cxmin >> v_cxmax >> v_cymin >> v_cymax >> v_rmin >> v_rmax; - root_CurInfile = curInfile; - ringCondition v_curCond; - v_curCond.cxmin = v_cxmin; - v_curCond.cxmax = v_cxmax; - v_curCond.cymin = v_cymin; - v_curCond.cymax = v_cymax; - v_curCond.rmin = v_rmin; - v_curCond.rmax = v_rmax; - fConditionsMap.insert(std::pair<TString, ringCondition>(root_CurInfile, v_curCond)); - //////printf ("Read: %s\t-\t%f\t%f\t%f\t%f\t%f\t%f\n", root_CurInfile.Data(), v_cxmin, v_cxmax, v_cymin, v_cymax, v_rmin, v_rmax); - } - - // Find the actual condition and use it - std::map<TString, ringCondition>::iterator iter; - iter = fConditionsMap.find(fInputFileBasename); - if (iter != fConditionsMap.end()) - { - fRingCondition = iter->second; - printf ("found condition for the current file.\n"); - printf ("\t%s\t-\t%f\t%f\t%f\t%f\t%f\t%f\n", iter->first.Data(), - fRingCondition.cxmin, fRingCondition.cxmax, fRingCondition.cymin, fRingCondition.cymax, fRingCondition.rmin, fRingCondition.rmax); - } - else - { - LOG(info) << "Can not find ring conditions for the current input file."; - } - } - - return kSUCCESS; -} - -void CbmRichRingHitsAnalyser::Exec(Option_t* /*option*/) -{ - // Get the parameters object - CbmRichTrbParam* param = CbmRichTrbParam::Instance(); - - Int_t numOfRings = fRichRings->GetEntriesFast(); -// Int_t numOfHits = fRichHits->GetEntriesFast(); - - fHM->H1("hNumOfRingInEvent")->Fill(numOfRings); - - std::vector< std::pair< CbmRichHit*, CbmRichHitInfo* > > listOfRingHitInfos; - - if (numOfRings == 1) { - CbmRichRing* theRing = static_cast<CbmRichRing*>(fRichRings->At(0)); - Int_t numOfHitsOnRing = theRing->GetNofHits(); - -// printf("Ring. nHits=%d\tx=%.4f\ty=%.4f\tr=%.4f\n", numOfHitsOnRing, theRing->GetCenterX(), theRing->GetCenterY(), theRing->GetRadius()); - - // Cut on the ring center - if (fApplyRingCcut) { - if ((theRing->GetCenterX() < fRingCondition.cxmin || theRing->GetCenterX() > fRingCondition.cxmax) || - (theRing->GetCenterY() < fRingCondition.cymin || theRing->GetCenterY() > fRingCondition.cymax)) - return; - } - - // Cut on the ring radius - if (fApplyRingRcut) { - if (theRing->GetRadius() < fRingCondition.rmin ||theRing->GetRadius() > fRingCondition.rmax) - return; - } - - // Fill the histos - if (theRing->GetRadius() < 4.85) - fHM->H2("RingsCenters1")->Fill(theRing->GetCenterX(), theRing->GetCenterY()); - else - fHM->H2("RingsCenters2")->Fill(theRing->GetCenterX(), theRing->GetCenterY()); - - fHM->H1("RingsRadii")->Fill(theRing->GetRadius()); - fHM->H1("hNumOfHitsOnRing")->Fill(numOfHitsOnRing); - - // Start analysis of pairs of hits - Int_t hitIndex1; - CbmRichHit* curHit1; - CbmRichHitInfo* curHitInfo1; - Int_t hitTDCid1; - Int_t hitChannel1; - -// Int_t hitIndex2; -// CbmRichHit* curHit2; -// CbmRichHitInfo* curHitInfo2; -// Int_t hitTDCid2; -// Int_t hitChannel2; - - TString histoName; - - // Get the first in time hit of the ring - Int_t firstHitIndex = -1; - Double_t minTimestamp = 0.; -/* - UInt_t num_PMT1=0; - UInt_t num_PMT2=0; - UInt_t num_PMT5=0; - UInt_t num_PMT6=0; -*/ - for (Int_t i=0; i<numOfHitsOnRing; i++) { - hitIndex1 = theRing->GetHit(i); - curHit1 = static_cast<CbmRichHit*>(fRichHits->At(hitIndex1)); - curHitInfo1 = static_cast<CbmRichHitInfo*>(fRichHitInfos->At(hitIndex1)); - hitTDCid1 = curHitInfo1->GetTdcId(); - hitChannel1 = curHitInfo1->GetLeadingChannel(); - - if (!param->isNormalPixel(hitTDCid1, hitChannel1)) - continue; - - if (param->isStudiedTDC(hitTDCid1)) - { -/* - if (hitTDCid1==0x0010 || hitTDCid1==0x0011 || hitTDCid1==0x0012 || hitTDCid1==0x0013) num_PMT1++; - if (hitTDCid1==0x0020 || hitTDCid1==0x0021 || hitTDCid1==0x0022 || hitTDCid1==0x0023) num_PMT2++; - if (hitTDCid1==0x0050 || hitTDCid1==0x0051 || hitTDCid1==0x0052 || hitTDCid1==0x0053) num_PMT5++; - if (hitTDCid1==0x0060 || hitTDCid1==0x0061 || hitTDCid1==0x0062 || hitTDCid1==0x0063) num_PMT6++; -*/ - if (firstHitIndex == -1) { - firstHitIndex = hitIndex1; - minTimestamp = curHit1->GetTime(); - } else { - if (curHit1->GetTime() < minTimestamp) { - firstHitIndex = hitIndex1; - minTimestamp = curHit1->GetTime(); - } - } - } - } - - if (firstHitIndex == -1) return; -/* - fHM->H1("hNumOfHitsOnRing_PMT1")->Fill(num_PMT1); - fHM->H1("hNumOfHitsOnRing_PMT2")->Fill(num_PMT2); - fHM->H1("hNumOfHitsOnRing_PMT5")->Fill(num_PMT5); - fHM->H1("hNumOfHitsOnRing_PMT6")->Fill(num_PMT6); -*/ - curHit1 = static_cast<CbmRichHit*>(fRichHits->At(firstHitIndex)); - curHitInfo1 = static_cast<CbmRichHitInfo*>(fRichHitInfos->At(firstHitIndex)); - hitTDCid1 = curHitInfo1->GetTdcId(); - hitChannel1 = curHitInfo1->GetLeadingChannel(); - fHM->H1("FirstPixelInRing")->Fill(param->TDCidToInteger(hitTDCid1)*16 + hitChannel1/2); - - for (Int_t i=0; i<numOfHitsOnRing; i++) { - // Get information about the first hit - hitIndex1 = theRing->GetHit(i); - curHit1 = static_cast<CbmRichHit*>(fRichHits->At(hitIndex1)); - curHitInfo1 = static_cast<CbmRichHitInfo*>(fRichHitInfos->At(hitIndex1)); - hitTDCid1 = curHitInfo1->GetTdcId(); - hitChannel1 = curHitInfo1->GetLeadingChannel(); - - if (hitIndex1 != firstHitIndex && param->isStudiedTDC(hitTDCid1)) { - - if (param->isNormalPixel(hitTDCid1, hitChannel1)) - fHM->H1("ExponentaBudetTut")->Fill(curHit1->GetTime()-minTimestamp); - - } - } -/* - for (Int_t i=0; i<numOfHitsOnRing-1; i++) { - - // Get information about the first hit - hitIndex1 = theRing->GetHit(i); - curHit1 = static_cast<CbmRichHit*>(fRichHits->At(hitIndex1)); - curHitInfo1 = static_cast<CbmRichHitInfo*>(fRichHitInfos->At(hitIndex1)); - hitTDCid1 = curHitInfo1->GetTdcId(); - hitChannel1 = curHitInfo1->GetLeadingChannel(); - - for (Int_t j=i+1; j<numOfHitsOnRing; j++) { - - // Get information about the second hit - hitIndex2 = theRing->GetHit(j); - curHit2 = static_cast<CbmRichHit*>(fRichHits->At(hitIndex2)); - curHitInfo2 = static_cast<CbmRichHitInfo*>(fRichHitInfos->At(hitIndex2)); - hitTDCid2 = curHitInfo2->GetTdcId(); - hitChannel2 = curHitInfo2->GetLeadingChannel(); - - //printf ("Considering pair of hits: tdc %04x ch %d time %f\t\ttdc %04x ch %d time %f\n", - // hitTDCid1, hitChannel1, curHit1->GetTimestamp(), hitTDCid2, hitChannel2, curHit2->GetTimestamp()); - - // Build the histograms for a certain TDC - // if (hitTDCid1 == hitTDCid2) - // { - // if (hitChannel1 <= hitChannel2) { - // histoName.Form("LeadingEdgeDiff_TDC%2x_%d_%d", hitTDCid1, hitChannel1/2, hitChannel2/2); - // fHM->H1(histoName.Data())->Fill(curHit1->GetTimestamp() - curHit2->GetTimestamp()); - // } else { - // //if (hitChannel1 == hitChannel2) { - // //} else { - // histoName.Form("LeadingEdgeDiff_TDC%2x_%d_%d", hitTDCid1, hitChannel2/2, hitChannel1/2); - // fHM->H1(histoName.Data())->Fill(curHit2->GetTimestamp() - curHit1->GetTimestamp()); - // //} - // } - // } - - if (param->isStudiedTDC(hitTDCid1) == kTRUE && param->isStudiedTDC(hitTDCid2) == kTRUE) - { - TString tdcID1; tdcID1.Form("%x", hitTDCid1); - TString tdcID2; tdcID2.Form("%x", hitTDCid2); - - UInt_t universalPixelID1 = param->TDCidToInteger(hitTDCid1)*32 + hitChannel1; - UInt_t universalPixelID2 = param->TDCidToInteger(hitTDCid2)*32 + hitChannel2; - - if (universalPixelID1 < universalPixelID2) { - histoName.Form("LeadingEdgeDiff_TDC%s_ch%d_TDC%s_ch%d", tdcID1.Data(), hitChannel1/2, tdcID2.Data(), hitChannel2/2); - fHM->H1(histoName.Data())->Fill(curHit1->GetTimestamp() - curHit2->GetTimestamp()); - } else { - histoName.Form("LeadingEdgeDiff_TDC%s_ch%d_TDC%s_ch%d", tdcID2.Data(), hitChannel2/2, tdcID1.Data(), hitChannel1/2); - fHM->H1(histoName.Data())->Fill(curHit2->GetTimestamp() - curHit1->GetTimestamp()); - } - - } - - } - } -*/ - - } else if (numOfRings == 2) { - CbmRichRing* theRing1 = static_cast<CbmRichRing*>(fRichRings->At(0)); - CbmRichRing* theRing2 = static_cast<CbmRichRing*>(fRichRings->At(1)); - - Double_t c1x = theRing1->GetCenterX(); - Double_t c1y = theRing1->GetCenterY(); - Double_t c2x = theRing2->GetCenterX(); - Double_t c2y = theRing2->GetCenterY(); - Double_t r1 = theRing1->GetRadius(); - Double_t r2 = theRing2->GetRadius(); - - Double_t distBetwCenters = sqrt( (c1x-c2x)*(c1x-c2x) + (c1y-c2y)*(c1y-c2y) ); - - fHM->H1("hDistBetwDoubleRings")->Fill(distBetwCenters); - fHM->H1("hDeltaRdoubleRings")->Fill(abs(r1-r2)); - } else if (numOfRings > 2) { - LOG(info) << "CbmRichRingHitsAnalyser::Exec More than two rings found. Skipping."; - //return; - } else { - LOG(debug) << "CbmRichRingHitsAnalyser::Exec No rings found"; - //return; - } -} - -void CbmRichRingHitsAnalyser::Finish() -{ - TFile* curHistoFile = new TFile(fOutHistoFile, "UPDATE"); - LOG(info) << "Opening file " << fOutHistoFile << " for histograms"; - fHM->WriteToFile(); - curHistoFile->Close(); -} - -ClassImp(CbmRichRingHitsAnalyser) diff --git a/beamtime/rich/CbmRichRingHitsAnalyser.h b/beamtime/rich/CbmRichRingHitsAnalyser.h deleted file mode 100644 index 3584b2dc686228da941f527b00ae8173e3ba41dc..0000000000000000000000000000000000000000 --- a/beamtime/rich/CbmRichRingHitsAnalyser.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * CbmRichRingHitsAnalyser.h - * - * Created on: Apr 15, 2015 - * Author: evovch - */ - - /* - * There is a known bug which has to be fixed: - * The conditions on the ring center and radius should somehow - * switch when analysis goes to the new file in the same run. - */ - -#ifndef RICH_PROTOTYPE_BEAMTIME_CBMRICHRINGHITSANALYSER_H_ -#define RICH_PROTOTYPE_BEAMTIME_CBMRICHRINGHITSANALYSER_H_ - -#include "FairTask.h" - -#include "CbmHistManager.h" -#include "CbmDrawHist.h" - -class TClonesArray; - -struct ringCondition -{ - Double_t cxmin; - Double_t cxmax; - Double_t cymin; - Double_t cymax; - Double_t rmin; - Double_t rmax; -}; - -class CbmRichRingHitsAnalyser : public FairTask -{ -public: - CbmRichRingHitsAnalyser(); - virtual ~CbmRichRingHitsAnalyser(); - - virtual InitStatus Init(); - virtual void Exec(Option_t* option); - virtual void Finish(); - - void SetApplyRingCcut(Bool_t doOrNot) {fApplyRingCcut=doOrNot;} - void SetApplyRingRcut(Bool_t doOrNot) {fApplyRingRcut=doOrNot;} - - void SetInputFileBasename(TString filename) {fInputFileBasename=filename;} - void SetRingCutsFile(TString filename) {fRingCutsFile=filename;} - void SetOutHistoFile(TString filename) {fOutHistoFile = filename;} - void SetWlsState(TString state) { fWlsState = state; } - -private: - TClonesArray* fRichHits; // input - TClonesArray* fRichRings; // input - - TClonesArray* fRichHitInfos; - - TString fWlsState; // "off" or "on" - - TString fInputFileBasename; // needed for conditions - TString fRingCutsFile; - TString fOutHistoFile; - - // Full table of conditions - std::map<TString, ringCondition> fConditionsMap; - // Current condition on ring center - for the current file - ringCondition fRingCondition; - - Bool_t fApplyRingCcut; - Bool_t fApplyRingRcut; - - CbmHistManager* fHM; - - //TODO implement or get rid - CbmRichRingHitsAnalyser(const CbmRichRingHitsAnalyser&); - CbmRichRingHitsAnalyser operator=(const CbmRichRingHitsAnalyser&); - - ClassDef(CbmRichRingHitsAnalyser, 1); -}; - -#endif // RICH_PROTOTYPE_BEAMTIME_CBMRICHRINGHITSANALYSER_H_ diff --git a/beamtime/rich/CbmRichTrbDefines.h b/beamtime/rich/CbmRichTrbDefines.h deleted file mode 100644 index b3f04fea4c61d089e92ffe640d1c3ae46c14b8c5..0000000000000000000000000000000000000000 --- a/beamtime/rich/CbmRichTrbDefines.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef CBMRICHTRBDEFINES_H -#define CBMRICHTRBDEFINES_H - - -#define EVENT_TIME_WINDOW 300. // Time window for building event in ns -#define NOF_RAW_EVENTS_IN_BUFFER 1000 // Maximum raw events in the buffer - -// for nov2014 beamtime - 33 channels per TDC: 0th channel - reference, then 16 pairs (leading/trailing) for one PADIWA channel -#define TRB_TDC3_CHANNELS 33 // - -#define TRB_TDC3_NUMTDC 4 // for nov2014 beamtime - 4 - -#define TRB_TDC3_NUMBOARDS 17 // for nov2014 beamtime - 17, for WU test setup - 1 - -#define TRB_TDC3_FINEBINS 0x400 //TODO check - -#define TRB_TDC3_COARSEUNIT 5. // 5 ns - -#define TRB_TDC3_COARSEBINS 0x800 // - -//#define INVERSEPOLARITY // if defined then leading channels are 2,4,6,... and corresponding trailing are 1,3,5,... - -// Maximum TOT in ns to build a pair. If TOT is positive and more than this value then two separate edges are sent to output. -#define POSITIVEPAIRWINDOW 40. -// Maximum in abs of a negative TOT to build a pair. If TOT is negative and in abs more than this value then two separate edges are sent to output. -#define NEGATIVEPAIRWINDOW 5. -// Hence a valid TOT for a pair is [-NEGATIVEPAIRINDOW; POSITIVEPAIRWINDOW] - -#define EVENTTIMEWINDOW 1000 - -#endif // CBMRICHTRBDEFINES_H diff --git a/beamtime/rich/CbmRichTrbEventBuilder.cxx b/beamtime/rich/CbmRichTrbEventBuilder.cxx deleted file mode 100644 index de3e2a2f4cd70ea7e1234dbb3a1c95b6391c0c64..0000000000000000000000000000000000000000 --- a/beamtime/rich/CbmRichTrbEventBuilder.cxx +++ /dev/null @@ -1,504 +0,0 @@ -#include "CbmRichTrbEventBuilder.h" -#include "FairRootManager.h" -#include "FairLogger.h" - -#include "CbmRichTrbDefines.h" -#include "CbmRichTrbDigi.h" -#include "CbmRichTrbParam.h" - -#include "CbmRichHit.h" -#include "CbmRichHitInfo.h" - -#include "TCanvas.h" -#include "TH1.h" -#include "TF1.h" -#include "TClonesArray.h" -#include <TFile.h> - -#include "CbmUtils.h" - -// Uncomment if you want to have excessive printout (do not execute on many events, may produce Gb's of output) -//#define DEBUGPRINT - -#define TESTEDTDC 0x0010 - -CbmRichTrbEventBuilder::CbmRichTrbEventBuilder() - : FairTask(), - fRichTrbDigi(NULL), - fRichHits(NULL), - fRichHitInfos(NULL), - numOfPairs(0), - numOfSingleEdges(0), - numOfSingleEdgesSync(0), - fHM(NULL), - fDrawHist(kFALSE), - fEventNum(0), - fRunTitle(""), - fOutputDir(""), - fOutHistoFile(""), - fWlsState(""), - lastTriggerTimestamp(0.), - lastRefTime(0.) -{ -} - -CbmRichTrbEventBuilder::~CbmRichTrbEventBuilder() -{ -} - -InitStatus CbmRichTrbEventBuilder::Init() -{ - FairRootManager* manager = FairRootManager::Instance(); - fRichTrbDigi = (TClonesArray*)manager->GetObject("CbmRichTrbDigi"); - if (NULL == fRichTrbDigi) { Fatal("CbmRichTrbEventBuilder::Init","No CbmRichTrbDigi array!"); } - - fRichHits = new TClonesArray("CbmRichHit", 10); - manager->Register("RichHit", "RICH", fRichHits, IsOutputBranchPersistent("RichHit")); - - fRichHitInfos = new TClonesArray("CbmRichHitInfo", 10); - manager->Register("RichHitInfo","RICH", fRichHitInfos, IsOutputBranchPersistent("RichHitInfo")); - - InitHist(); - - return kSUCCESS; -} - -void CbmRichTrbEventBuilder::InitHist() -{ - if (fDrawHist) - { - fHM = new CbmHistManager(); -// Double_t K, minWin, maxWin; (FU) not used - - TString histoName; - TString histoTitle; -/* (FU) not used - K = 100; // 1000/W=K, where W - desired bin width in ps. - minWin = -50.; - maxWin = 50.; -*/ -/* - histoName.Form("hRefChannel"); - histoTitle.Form("hRefChannel"); - fHM->Create1<TH1D>(histoName.Data(), histoTitle.Data(), 256, 0, 256); - - histoName.Form("hMeasuredChannel"); - histoTitle.Form("hMeasuredChannel"); - fHM->Create1<TH1D>(histoName.Data(), histoTitle.Data(), 256, 0, 256); - - histoName.Form("ExponentaBudetTut_laser"); - histoTitle.Form("ExponentaBudetTut_laser"); - fHM->Create1<TH1D>(histoName.Data(), histoTitle.Data(), K*(maxWin-minWin), minWin, maxWin); -*/ -/* - TString tdcIDs[16]; - tdcIDs[0] = "10"; tdcIDs[1] = "11"; tdcIDs[2] = "12"; tdcIDs[3] = "13"; - tdcIDs[4] = "20"; tdcIDs[5] = "21"; tdcIDs[6] = "22"; tdcIDs[7] = "23"; - tdcIDs[8] = "50"; tdcIDs[9] = "51"; tdcIDs[10] = "52"; tdcIDs[11] = "53"; - tdcIDs[12] = "60"; tdcIDs[13] = "61"; tdcIDs[14] = "62"; tdcIDs[15] = "63"; - - for (Int_t tdc1J=0; tdc1J<=15; tdc1J++) { - Int_t tdc2J = tdc1J; - for (Int_t ch1=0; ch1<=15; ch1++) { - for (Int_t ch2=ch1; ch2<=15; ch2++) { - histoName.Form("LeadingEdgeDiff_TDC%s_ch%d_TDC%s_ch%d", tdcIDs[tdc1J].Data(), ch1, tdcIDs[tdc2J].Data(), ch2); - histoTitle.Form("LeadingEdgeDiff_TDC%s_ch%d_TDC%s_ch%d", tdcIDs[tdc1J].Data(), ch1, tdcIDs[tdc2J].Data(), ch2); - fHM->Create1<TH1D>(histoName.Data(), histoTitle.Data(), K*(maxWin-minWin), minWin, maxWin); - //printf ("%s\n", histoName.Data()); - } - } - for (tdc2J=tdc1J+1; tdc2J<=15; tdc2J++) { - for (Int_t ch1=0; ch1<=15; ch1++) { - for (Int_t ch2=0; ch2<=15; ch2++) { - histoName.Form("LeadingEdgeDiff_TDC%s_ch%d_TDC%s_ch%d", tdcIDs[tdc1J].Data(), ch1, tdcIDs[tdc2J].Data(), ch2); - histoTitle.Form("LeadingEdgeDiff_TDC%s_ch%d_TDC%s_ch%d", tdcIDs[tdc1J].Data(), ch1, tdcIDs[tdc2J].Data(), ch2); - fHM->Create1<TH1D>(histoName.Data(), histoTitle.Data(), K*(maxWin-minWin), minWin, maxWin); - //printf ("%s\n", histoName.Data()); - } - } - } - } -*/ - - histoName.Form("fNumOfDigisInEvent"); - histoTitle.Form("Number of digits in event"); - fHM->Create1<TH1D>(histoName.Data(), histoTitle.Data(), 200, 0., 200.); - - histoName.Form("fNumOfDigisInEvent_pairOnly"); - histoTitle.Form("Number of digits (constructed as pait of hits) in event"); - fHM->Create1<TH1D>(histoName.Data(), histoTitle.Data(), 200, 0., 200.); - - for (unsigned int pixel=0; pixel<64; pixel++) - { - histoName.Form("fTriggCorrelation_pixel%d", pixel); - histoTitle.Form("Correlation with the trigger in pixel%d", pixel); - fHM->Create1<TH1D>(histoName.Data(), histoTitle.Data(), 1200, -200., 1000.); - - histoName.Form("fTriggCorrelation_inWin_pixel%d", pixel); - histoTitle.Form("Correlation with the trigger inside trigger window in pixel%d", pixel); - fHM->Create1<TH1D>(histoName.Data(), histoTitle.Data(), 1200, -200., 1000.); - - histoName.Form("fTriggCorrelation_wide_pixel%d", pixel); - histoTitle.Form("Correlation with the trigger in bigger window in pixel%d", pixel); - fHM->Create1<TH1D>(histoName.Data(), histoTitle.Data(), 848, -2000., 210000.); - - histoName.Form("fTriggCorrelation_inNoiseWin_pixel%d", pixel); - histoTitle.Form("Correlation with the trigger inside noise trigger window in pixel%d", pixel); - fHM->Create1<TH1D>(histoName.Data(), histoTitle.Data(), 848, -2000., 210000.); - } - - histoName.Form("fTriggCorrelation_allPixels"); - histoTitle.Form("Correlation with the trigger in all pixels"); - fHM->Create1<TH1D>(histoName.Data(), histoTitle.Data(), 1200, -200., 1000.); - - histoName.Form("fTriggCorrelation_inWin_allPixels"); - histoTitle.Form("Correlation with the trigger inside trigger window in all pixels"); - fHM->Create1<TH1D>(histoName.Data(), histoTitle.Data(), 1200, -200., 1000.); - - histoName.Form("fTriggCorrelation_wide_allPixels"); - histoTitle.Form("Correlation with the trigger in bigger window in all pixels"); - fHM->Create1<TH1D>(histoName.Data(), histoTitle.Data(), 848, -2000., 210000.); - - histoName.Form("fTriggCorrelation_inNoiseWin_allPixels"); - histoTitle.Form("Correlation with the trigger inside noise trigger window in all pixels"); - fHM->Create1<TH1D>(histoName.Data(), histoTitle.Data(), 848, -2000., 210000.); - - histoName.Form("fNumOfLightHitsInEvent"); - histoTitle.Form("Number of light hits in event"); - fHM->Create1<TH1D>(histoName.Data(), histoTitle.Data(), 20, 0., 20.); - - // Bin number 257 is for the number of events needed for normalisation - histoName.Form("fTotalNumOfLightHitsInPixel"); - histoTitle.Form("Total number of light hits in pixel"); - fHM->Create1<TH1D>(histoName.Data(), histoTitle.Data(), 257, 0., 257.); - - } -} - -void CbmRichTrbEventBuilder::DrawHist() -{ -} - -void CbmRichTrbEventBuilder::Exec(Option_t* /*option*/) -{ - // Get the parameters object - CbmRichTrbParam* param = CbmRichTrbParam::Instance(); - - // Save the number of messages coming into this task in this event - Int_t nofDigisInEvent = fRichTrbDigi->GetEntries(); - - // Empty output TClonesArray - fRichHits->Clear(); - fRichHitInfos->Clear(); - - // Just a string - TString curHistoName; - -#ifdef DEBUGPRINT - printf ("CbmRichTrbEventBuilder:EVENT %d - %d digis\n", fEventNum, nofDigisInEvent); -#endif - - // Number of pairs local for the current event - Int_t nOfPairsInEvent = 0; - - UInt_t hitTDCid1; - UInt_t hitChannel1; - Double_t hitTimestamp1; - - // Detect trigger timestamp here - //lastTriggerTimestamp = 0.; - // Loop over all the incoming digi and find the trigger message - for (Int_t i = 0; i < nofDigisInEvent; i++) - { - CbmRichTrbDigi* theDigit = static_cast<CbmRichTrbDigi*>(fRichTrbDigi->At(i)); - if (theDigit->GetTDCid() == TESTEDTDC && theDigit->GetLeadingEdgeChannel() == 0) { - lastTriggerTimestamp = theDigit->GetLeadingEdgeTimeStamp(); - } - } - - // Just to count - for (Int_t i=0; i<nofDigisInEvent; i++) { - CbmRichTrbDigi* theDigit = static_cast<CbmRichTrbDigi*>(fRichTrbDigi->At(i)); - if (theDigit->GetHasLeadingEdge() && theDigit->GetHasTrailingEdge()) { - numOfPairs++; // Global - per run - nOfPairsInEvent++; // Local - per event - } else { - if (theDigit->GetHasLeadingEdge() && !(theDigit->GetHasTrailingEdge()) && param->IsSyncChannel(theDigit->GetLeadingEdgeChannel())) { - numOfSingleEdgesSync++; - } else { - numOfSingleEdges++; - } - } - } - - fHM->H1("fNumOfDigisInEvent")->Fill(nofDigisInEvent); - fHM->H1("fNumOfDigisInEvent_pairOnly")->Fill(nOfPairsInEvent); - - UInt_t counterOfLightHits=0; - for (Int_t i=0; i<nofDigisInEvent; i++) { - CbmRichTrbDigi* theDigit = static_cast<CbmRichTrbDigi*>(fRichTrbDigi->At(i)); - hitTDCid1 = theDigit->GetTDCid(); - hitChannel1 = theDigit->GetLeadingEdgeChannel(); - hitTimestamp1 = theDigit->GetLeadingEdgeTimeStamp(); - - // First check that the hit is coming from one of the studied TDCs - if (!param->isStudiedTDC(hitTDCid1)) { - continue; - } - -/* - // Check that the hit is made of two edges (not a single edge) - thus skip sync messages - if (!(theDigit->GetHasLeadingEdge() && theDigit->GetHasTrailingEdge())) { - continue; - } -*/ - - if (param->IsSyncChannel(hitChannel1)) { - continue; - } - if (!(theDigit->GetHasLeadingEdge())) { - continue; - } - - UInt_t universalPixelID1 = (param->TDCidToInteger(hitTDCid1)*32 + hitChannel1)/2; //FIXME - fHM->H1("fTotalNumOfLightHitsInPixel")->Fill(universalPixelID1); - - //printf ("TDC %d ch %d id %d\n", hitTDCid1, hitChannel1, universalPixelID1); - - // Correlation with the trigger (SYNC message in TESTEDTDC) - TString hNam; - - hNam.Form("fTriggCorrelation_pixel%d", universalPixelID1); - fHM->H1(hNam.Data())->Fill(hitTimestamp1 - lastTriggerTimestamp); - - hNam.Form("fTriggCorrelation_wide_pixel%d", universalPixelID1); - fHM->H1(hNam.Data())->Fill(hitTimestamp1 - lastTriggerTimestamp); - - hNam.Form("fTriggCorrelation_allPixels"); - fHM->H1(hNam.Data())->Fill(hitTimestamp1 - lastTriggerTimestamp); - - hNam.Form("fTriggCorrelation_wide_allPixels"); - fHM->H1(hNam.Data())->Fill(hitTimestamp1 - lastTriggerTimestamp); - - // Here we cut hits using some window around trigger signal - Double_t distToTrig = hitTimestamp1 - lastTriggerTimestamp; - - if (distToTrig > -80. && distToTrig < 0.) { - hNam.Form("fTriggCorrelation_inWin_pixel%d", universalPixelID1); - fHM->H1(hNam.Data())->Fill(hitTimestamp1 - lastTriggerTimestamp); - hNam.Form("fTriggCorrelation_inWin_allPixels"); - fHM->H1(hNam.Data())->Fill(hitTimestamp1 - lastTriggerTimestamp); - // Count the number of light hits - counterOfLightHits++; - } - - if (distToTrig > 50000. && distToTrig < 150000.) { - hNam.Form("fTriggCorrelation_inNoiseWin_pixel%d", universalPixelID1); - fHM->H1(hNam.Data())->Fill(hitTimestamp1 - lastTriggerTimestamp); - hNam.Form("fTriggCorrelation_inNoiseWin_allPixels"); - fHM->H1(hNam.Data())->Fill(hitTimestamp1 - lastTriggerTimestamp); - } - - } - - fHM->H1("fNumOfLightHitsInEvent")->Fill(counterOfLightHits); - fHM->H1("fTotalNumOfLightHitsInPixel")->Fill(256.5); - -/* - // Find the trigger - Bool_t hodoFound = kFALSE; - Bool_t laserFound = kFALSE; - Bool_t ledFound = kFALSE; - for (Int_t i=0; i<nofDigisInEvent; i++) { - CbmRichTrbDigi* theDigit = static_cast<CbmRichTrbDigi*>(fRichTrbDigi->At(i)); - - if (theDigit->GetTDCid() == 0x0110 && theDigit->GetLeadingEdgeChannel() == 5) { - hodoFound = kTRUE; - //LOG(info) << "hodoFound = kTRUE"; - } - if (theDigit->GetTDCid() == 0x0110 && theDigit->GetLeadingEdgeChannel() == 15) { - laserFound = kTRUE; - //LOG(info) << "laserFound = kTRUE"; - } - if (theDigit->GetTDCid() == 0x0110 && theDigit->GetLeadingEdgeChannel() == 7) { - ledFound = kTRUE; - //LOG(info) << "ledFound = kTRUE"; - } - } - - //TODO choose which trigger to use - if (laserFound && !hodoFound && !ledFound) { - // go on - } else { - return; - } - - // Find first hit in the laser flash - reference - Int_t hitTDCidRef; - Int_t hitChannelRef; - Double_t hitTimestampRef; - Int_t firstHitIndex = -1; - Int_t minTDCidRef; - Int_t minChannelRef; - Double_t minTimestampRef = 0.; - Bool_t refFound = kFALSE; - - for (Int_t i=0; i<nofDigisInEvent; i++) - { - CbmRichTrbDigi* theDigitRef = static_cast<CbmRichTrbDigi*>(fRichTrbDigi->At(i)); - hitTDCidRef = theDigitRef->GetTDCid(); - hitChannelRef = theDigitRef->GetLeadingEdgeChannel(); - hitTimestampRef = theDigitRef->GetLeadingEdgeTimeStamp(); - - // First check that the hit is coming from one of the studied TDCs - if (!param->isStudiedTDC(hitTDCidRef)) { - continue; - } - // Check that the hit is made of two edges (not a single edge) - if (!(theDigitRef->GetHasLeadingEdge() && theDigitRef->GetHasTrailingEdge())) { - continue; - } - // Then check that the pixel is not bad - if (!param->isNormalPixel(hitTDCidRef, hitChannelRef)) { - continue; - } - // Additional cut - if (hitTDCidRef==0x0013 && (hitChannelRef==11 || hitChannelRef==15)) - continue; - - if (firstHitIndex == -1) { - firstHitIndex = i; - minTDCidRef = hitTDCidRef; - minChannelRef = hitChannelRef; - minTimestampRef = hitTimestampRef; - refFound = kTRUE; - } else { - if (hitTimestampRef < minTimestampRef) { - firstHitIndex = i; - minTDCidRef = hitTDCidRef; - minChannelRef = hitChannelRef; - minTimestampRef = hitTimestampRef; - refFound = kTRUE; - } - } - } - - // Fill only if the reference hit is found - if (refFound) { - for (Int_t i=0; i<nofDigisInEvent; i++) { - CbmRichTrbDigi* theDigit1 = static_cast<CbmRichTrbDigi*>(fRichTrbDigi->At(i)); - hitTDCid1 = theDigit1->GetTDCid(); - hitChannel1 = theDigit1->GetLeadingEdgeChannel(); - hitTimestamp1 = theDigit1->GetLeadingEdgeTimeStamp(); - - // First check that the hit is coming from one of the studied TDCs - if (!param->isStudiedTDC(hitTDCid1)) { - continue; - } - // Check that the hit is made of two edges (not a single edge) - if (!(theDigit1->GetHasLeadingEdge() && theDigit1->GetHasTrailingEdge())) { - continue; - } - // Then check that the pixel is not bad - if (!param->isNormalPixel(hitTDCid1, hitChannel1)) { - continue; - } - //FIXME Additional cut - tune according to needs - if (hitTDCid1==0x0013 && (hitChannel1==11 || hitChannel1==15)) { - continue; - } - - // Skip hit which is the same as reference - // Skip double hit - different hits coming from the same channel in the same event - if ((i == firstHitIndex) || (minTDCidRef==hitTDCid1 && minChannelRef==hitChannel1)) { - continue; - } - - fHM->H1("ExponentaBudetTut_laser")->Fill(hitTimestamp1 - minTimestampRef); - - if (hitTimestamp1 - minTimestampRef > 10.) { - fHM->H1("hRefChannel")->Fill(param->TDCidToInteger(minTDCidRef)*32+minChannelRef); - fHM->H1("hMeasuredChannel")->Fill(param->TDCidToInteger(hitTDCid1)*32+hitChannel1); - //printf ("ref: %x %d\t\tmeasured: %x %d\n", minTDCidRef, minChannelRef, hitTDCid1, hitChannel1); - } - - } - } - - TString histoName; - UInt_t hitTDCid2; - UInt_t hitChannel2; - - // Loop over the list of hits to extract the first hit for the pair - // -1 as we don't need to consider the last hit - there is no pair for the last hit anyway - for (Int_t i=0; i<nofDigisInEvent-1; i++) { - CbmRichTrbDigi* theDigit1 = static_cast<CbmRichTrbDigi*>(fRichTrbDigi->At(i)); - - // Check that the hit is made of two edges (not a single edge) - if (!(theDigit1->GetHasLeadingEdge() && theDigit1->GetHasTrailingEdge())) { - continue; - } - - // Inner loop over the list of hits (not full!) to extract the second hit for the pair - for (Int_t j=i+1; j<nofDigisInEvent; j++) { - CbmRichTrbDigi* theDigit2 = static_cast<CbmRichTrbDigi*>(fRichTrbDigi->At(j)); - - // Check that the hit is made of two edges (not a single edge) - if (!(theDigit2->GetHasLeadingEdge() && theDigit2->GetHasTrailingEdge())) { - continue; - } - - hitTDCid1 = theDigit1->GetTDCid(); - hitTDCid2 = theDigit2->GetTDCid(); - hitChannel1 = theDigit1->GetLeadingEdgeChannel(); - hitChannel2 = theDigit2->GetLeadingEdgeChannel(); - - //printf("considering pair TDC%04x ch%d TDC%04x ch%d\n", hitTDCid1, hitChannel1, hitTDCid2, hitChannel2); - if (param->isStudiedTDC(hitTDCid1) == kTRUE && param->isStudiedTDC(hitTDCid2) == kTRUE) - { - TString tdcID1; tdcID1.Form("%x", hitTDCid1); - TString tdcID2; tdcID2.Form("%x", hitTDCid2); - - UInt_t universalPixelID1 = param->TDCidToInteger(hitTDCid1)*32 + hitChannel1; - UInt_t universalPixelID2 = param->TDCidToInteger(hitTDCid2)*32 + hitChannel2; - if (universalPixelID1 < universalPixelID2) { - histoName.Form("LeadingEdgeDiff_TDC%s_ch%d_TDC%s_ch%d", tdcID1.Data(), hitChannel1/2, tdcID2.Data(), hitChannel2/2); - //printf ("%s\n", histoName.Data()); - fHM->H1(histoName.Data())->Fill(theDigit1->GetLeadingEdgeTimeStamp() - theDigit2->GetLeadingEdgeTimeStamp()); - } else { - histoName.Form("LeadingEdgeDiff_TDC%s_ch%d_TDC%s_ch%d", tdcID2.Data(), hitChannel2/2, tdcID1.Data(), hitChannel1/2); - //printf ("%s\n", histoName.Data()); - fHM->H1(histoName.Data())->Fill(theDigit2->GetLeadingEdgeTimeStamp() - theDigit1->GetLeadingEdgeTimeStamp()); - } - } - } - } -*/ - - fEventNum++; -} - -void CbmRichTrbEventBuilder::Finish() -{ - - // Double_t k = (Double_t)numOfSingleEdgesSync; - - UInt_t totalMessages = numOfPairs*2 + numOfSingleEdges + numOfSingleEdgesSync; - - LOG(info) << "[CbmRichTrbEventBuilder] " << numOfPairs << " pairs; " << numOfSingleEdges << " single edges (not incl.) " - << numOfSingleEdgesSync << " sync messages; Total " << totalMessages << " messages"; - - LOG(info) << 100.*(Double_t)numOfPairs*2. / (Double_t)totalMessages << "%, " - << 100.*(Double_t)numOfSingleEdges / (Double_t)totalMessages << "%, " - << 100.*(Double_t)numOfSingleEdgesSync / (Double_t)totalMessages << "%"; - - if (fDrawHist) { - DrawHist(); - TFile* curHistoFile = new TFile(fOutHistoFile, "UPDATE"); - LOG(info) << "Opening file " << fOutHistoFile << " for histograms"; - fHM->WriteToFile(); - curHistoFile->Close(); - } -} - -ClassImp(CbmRichTrbEventBuilder) diff --git a/beamtime/rich/CbmRichTrbEventBuilder.h b/beamtime/rich/CbmRichTrbEventBuilder.h deleted file mode 100644 index 6fa8ec43ae47975194e8d79821a9f33191a58f68..0000000000000000000000000000000000000000 --- a/beamtime/rich/CbmRichTrbEventBuilder.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef CBMRICHTRBEVENTBUILDER_H -#define CBMRICHTRBEVENTBUILDER_H - -#include "FairTask.h" - -#include "CbmHistManager.h" -#include "CbmDrawHist.h" - -class TClonesArray; - -class CbmRichTrbEventBuilder : public FairTask -{ -public: - - CbmRichTrbEventBuilder(); - virtual ~CbmRichTrbEventBuilder(); - - virtual InitStatus Init(); - virtual void Exec(Option_t* option); - virtual void Finish(); - void InitHist(); - void DrawHist(); - void SetRunTitle(TString title) { fRunTitle = title; } - void SetOutputDir(TString dir) {fOutputDir = dir;} - void SetOutHistoFile(TString filename) {fOutHistoFile = filename;} - void SetDrawHist(Bool_t value) { fDrawHist = value; } - void SetWlsState(TString state) { fWlsState = state; } - //void FitGaussAndDrawResults(TH1* h); - -private: - - TClonesArray* fRichTrbDigi; // input - TClonesArray* fRichHits; // output - TClonesArray* fRichHitInfos; // output - - Int_t numOfPairs; - Int_t numOfSingleEdges; - Int_t numOfSingleEdgesSync; - - CbmHistManager* fHM; - - Bool_t fDrawHist; // if TRUE histograms are drawn - - UInt_t fEventNum; // Event counter - - TString fRunTitle; // Title of the run - TString fOutputDir; // output directory to store figures - TString fOutHistoFile; - - TString fWlsState; // "off" or "on" - - // For WU analysis - Double_t lastTriggerTimestamp; - Double_t lastRefTime; - - //TODO implement or get rid - CbmRichTrbEventBuilder(const CbmRichTrbEventBuilder&); - CbmRichTrbEventBuilder operator=(const CbmRichTrbEventBuilder&); - - ClassDef(CbmRichTrbEventBuilder, 1); -}; - -#endif // CBMRICHTRBEVENTBUILDER_H diff --git a/beamtime/rich/CbmRichTrbParam.h b/beamtime/rich/CbmRichTrbParam.h deleted file mode 100644 index 088ada8c1312e135c7f2e29f215a22dc8e1afc06..0000000000000000000000000000000000000000 --- a/beamtime/rich/CbmRichTrbParam.h +++ /dev/null @@ -1,242 +0,0 @@ -#ifndef CBMRICHTRBPARAM_H -#define CBMRICHTRBPARAM_H - -#include <iostream> -#include <fstream> -#include <string> -#include <map> - -#include "FairLogger.h" - -#include "CbmRichHitInfo.h" -#include "CbmRichTrbDefines.h" - -using namespace std; - -class CbmRichTrbParam -{ -private: - - CbmRichTrbParam() : fMap() { - ReadMap(); - } - -public: - - static CbmRichTrbParam* Instance() { - static CbmRichTrbParam fInstance; - return &fInstance; - } - - ~CbmRichTrbParam() { - } - - CbmRichHitInfo* GetRichHitInfo(UInt_t tdcId, UInt_t leadingChannel) { - return fMap[tdcId][leadingChannel]; - } - - Bool_t IsPmtTrb(UInt_t trbId) const { - return (trbId==0x8015 || trbId==0x8025 || trbId==0x8035 || trbId==0x8045 || - trbId==0x8055 || trbId==0x8065 || trbId==0x8075 || trbId==0x8085 || - trbId==0x8095 || trbId==0x80a5 || trbId==0x80b5 || trbId==0x80c5 || - trbId==0x80d5 || trbId==0x80e5 || trbId==0x80f5 || trbId==0x8105 || trbId == 0x8115); - } - - Bool_t IsPmtTdc(UInt_t tdcId) const { - return ( ((tdcId & 0x000f) <= 3) && ((tdcId >> 8) == 0) ) || - (tdcId == 0x0100 || tdcId == 0x0101 || tdcId == 0x0102 || tdcId == 0x0103); - } - - UInt_t TDCidToInteger (UInt_t tdcId) const { - return ((((tdcId >> 4) & 0x00ff) - 1) * 4 + (tdcId & 0x000f)); - } - - UInt_t IntegerToTDCid (UInt_t index) const { - return (((index/4) + 1) << 4) + (index%4); - } - - // TDC actually has 33 channels with 0-th being a special channel for SYNC messages. - // I intentionally put TDC after TDC with step of 32 channels - channels from 1 to 32 (incl.) - // and then a section for 64 sync channels - one for each of 64 TDCs - UInt_t TDCandCHtoInteger(UInt_t tdcId, UInt_t ch) const { - if (ch == 0) { - return 64*32 + this->TDCidToInteger(tdcId); - } else { - return this->TDCidToInteger(tdcId) * 32 + ch-1; - } - } - - Bool_t IsSyncChannel(UInt_t ch/*, UInt_t tdcId=0xffff*/) const { - if (ch==0) return kTRUE; - return kFALSE; - } - - Bool_t IsLeadingEdgeChannel(UInt_t ch/*, UInt_t tdcId=0xffff*/) const { - #ifdef INVERSEPOLARITY - if (ch%2==0) return kTRUE; - #else - if (ch%2==1) return kTRUE; - #endif - // if (tdcId==.....) { - // } - return kFALSE; - } - - Bool_t isStudiedTDC(Int_t tdcID) - { - if (tdcID == 0x0010 || tdcID == 0x0011 || tdcID == 0x0012 || tdcID == 0x0013 || - tdcID == 0x0020 || tdcID == 0x0021 || tdcID == 0x0022 || tdcID == 0x0023 || - tdcID == 0x0050 || tdcID == 0x0051 || tdcID == 0x0052 || tdcID == 0x0053 || - tdcID == 0x0060 || tdcID == 0x0061 || tdcID == 0x0062 || tdcID == 0x0063) { - return kTRUE; - } else { - return kFALSE; - } - } - - Bool_t isNormalPixel_WLS_off(Int_t hitTDCid1, Int_t hitChannel1) - { - if ((hitTDCid1==0x0010 && hitChannel1/2==4) || - (hitTDCid1==0x0011 && hitChannel1/2==0) || - (hitTDCid1==0x0012 && hitChannel1/2==0) || - (hitTDCid1==0x0012 && hitChannel1/2==1) || - (hitTDCid1==0x0012 && hitChannel1/2==7) || - (hitTDCid1==0x0012 && hitChannel1/2==8) || - (hitTDCid1==0x0013 && hitChannel1/2==3) || - (hitTDCid1==0x0013 && hitChannel1/2==4) || - (hitTDCid1==0x0013 && hitChannel1/2==10) || - - (hitTDCid1==0x0020 && hitChannel1/2==10) || - (hitTDCid1==0x0020 && hitChannel1/2==14) || - (hitTDCid1==0x0022 && hitChannel1/2==0) || - (hitTDCid1==0x0023 && hitChannel1/2==14) || - - (hitTDCid1==0x0052 && hitChannel1/2==1) || - (hitTDCid1==0x0060 && hitChannel1/2==1) || - (hitTDCid1==0x0061 && hitChannel1/2==4) || - (hitTDCid1==0x0061 && hitChannel1/2==8) || - (hitTDCid1==0x0061 && hitChannel1/2==7) ) { - return kFALSE; - } else { - return kTRUE; - } - } - - Bool_t isNormalPixel_WLS_on(Int_t hitTDCid1, Int_t hitChannel1) - { - if ( hitTDCid1==0x0050 || hitTDCid1==0x0051 || hitTDCid1==0x0052 || hitTDCid1==0x0053 || - hitTDCid1==0x0060 || hitTDCid1==0x0061 || hitTDCid1==0x0062 || hitTDCid1==0x0063 || - - (hitTDCid1==0x0010 && hitChannel1/2==4) || - - (hitTDCid1==0x0011 && hitChannel1/2==0) || - (hitTDCid1==0x0011 && hitChannel1/2==4) || - - (hitTDCid1==0x0013 && hitChannel1/2==3) || - (hitTDCid1==0x0013 && hitChannel1/2==6) || - (hitTDCid1==0x0013 && hitChannel1/2==8) || - (hitTDCid1==0x0013 && hitChannel1/2==9) || - (hitTDCid1==0x0013 && hitChannel1/2==10) || - (hitTDCid1==0x0013 && hitChannel1/2==11) || - (hitTDCid1==0x0013 && hitChannel1/2==13) || - - (hitTDCid1==0x0020 && hitChannel1/2==0) || - (hitTDCid1==0x0020 && hitChannel1/2==4) || - (hitTDCid1==0x0020 && hitChannel1/2==7) || - (hitTDCid1==0x0020 && hitChannel1/2==10) || - (hitTDCid1==0x0020 && hitChannel1/2==14) || - - (hitTDCid1==0x0021 && hitChannel1/2==0) || - (hitTDCid1==0x0021 && hitChannel1/2==5) || - (hitTDCid1==0x0021 && hitChannel1/2==7) || - (hitTDCid1==0x0021 && hitChannel1/2==8) || - (hitTDCid1==0x0021 && hitChannel1/2==14) || - (hitTDCid1==0x0021 && hitChannel1/2==15) || - - (hitTDCid1==0x0022 && hitChannel1/2==0) || - (hitTDCid1==0x0022 && hitChannel1/2==4) || - - (hitTDCid1==0x0023 && hitChannel1/2==14) ) { - return kFALSE; - } else { - return kTRUE; - } - } - - Bool_t isNormalPixel(Int_t hitTDCid1, Int_t hitChannel1) - { - return (this->isNormalPixel_WLS_off(hitTDCid1, hitChannel1) && this->isNormalPixel_WLS_on(hitTDCid1, hitChannel1)); - } - - UInt_t GetCorrespondingLeadingEdgeChannel(UInt_t ch, UInt_t /*tdcId=0xffff*/) const - { - /*if (tdcId == 0x0110) { - return ch-1; - } else if (tdcId == 0x0111) { - if (ch == 2) return 1; - if (ch == 4) return 1; - if (ch == 6) return 5; - if (ch == 8) return 5; - if (ch == 16) return 13; - if (ch == 14) return 13; - } else if (tdcId == 0x0112) { - return ch-1; - } else if (tdcId == 0x0113) { - if (ch == 12) return 9; - if (ch == 10) return 9; - } else */{ - - #ifdef INVERSEPOLARITY - return ch+1; - #else // standard polarity - return ch-1; - #endif - } - } - - Bool_t IsReferenceTimeTdc(UInt_t tdcId) { - return (tdcId == 0x0110); - } - -private: - - map<UInt_t, map<UInt_t, CbmRichHitInfo*> > fMap; - - void ReadMap() - { - string line; - ifstream myfile ("pixel-coord_channel-register.ascii"); - if (myfile.is_open()) { - getline (myfile,line); - getline (myfile,line); - - while ( !myfile.eof() ){ - UInt_t pmtNum, pixelNum; - Double_t xmm, ymm; - UInt_t simpleX, simpleY, tdcId, chLeadingEdge, chTrailingEdge, padiwaNum, trbNum; - string pmtType; - myfile >> pmtNum >> pixelNum >> xmm >> ymm >> simpleX >> simpleY; - myfile >> std::hex >> tdcId; - myfile >> std::dec >> chLeadingEdge >> chTrailingEdge >> padiwaNum >> trbNum >> pmtType; - LOG(debug4) << pmtNum << " " << pixelNum << " " << xmm << " " << ymm << " " - << simpleX << " " << simpleY << " " << tdcId << " " << chLeadingEdge << " " << chTrailingEdge - << " " << padiwaNum << " " << trbNum << " " << pmtType; - UInt_t pmtTypeId = GetPmtTypeIdByString(pmtType); - fMap[tdcId][chLeadingEdge] = new CbmRichHitInfo(pmtNum, pixelNum, xmm / 10., ymm / 10., simpleX, simpleY, tdcId, chLeadingEdge, chTrailingEdge, padiwaNum, trbNum, pmtTypeId); - } - myfile.close(); - LOG(info) << "Imported pixel map from pixel-coord_channel-register.ascii"; - } else { - LOG(fatal) << "[CbmRichTrbParam::ReadMap] Failed to open ASCII map file."; - } - } - - UInt_t GetPmtTypeIdByString(const string& str) { - if ( str == "H12700") return 1; - else if (str == "H8500") return 2; - else return -1; - } - -}; - -#endif // CBMRICHTRBPARAM_H diff --git a/beamtime/rich/CbmRichTrbPulserQa.cxx b/beamtime/rich/CbmRichTrbPulserQa.cxx deleted file mode 100644 index 3aaec2ed7384ac95b4ea5a4f6dad7f845dc0cc71..0000000000000000000000000000000000000000 --- a/beamtime/rich/CbmRichTrbPulserQa.cxx +++ /dev/null @@ -1,66 +0,0 @@ -#include "CbmRichTrbPulserQa.h" -#include "FairRootManager.h" -#include "FairLogger.h" - -#include "TClonesArray.h" - -#include "TH1D.h" -#include "TH2D.h" -#include "TCanvas.h" -#include "CbmDrawHist.h" -#include "CbmRichHit.h" - -#include <iostream> -#include <vector> - -CbmRichTrbPulserQa::CbmRichTrbPulserQa() - : FairTask(), - fRichHits(NULL), - fEventNum(0) -{ -} - -CbmRichTrbPulserQa::~CbmRichTrbPulserQa() -{ -} - - -InitStatus CbmRichTrbPulserQa::Init() -{ - FairRootManager* manager = FairRootManager::Instance(); - fRichHits = (TClonesArray*)manager->GetObject("RichHit"); - if (NULL == fRichHits) { Fatal("CbmRichTrbPulserQa::Init","No RichHit array!"); } - - InitHist(); - - return kSUCCESS; -} - -void CbmRichTrbPulserQa::InitHist() -{ - //fhNofHitsInEvent = new TH1D("fhNofHitsInEvent", "fhNofHitsInEvent;Number of hits in event;Entries", 50, -0.5, 49.5); - -} - -void CbmRichTrbPulserQa::Exec( - Option_t* /*option*/) -{ - fEventNum++; - LOG(debug2) << "CbmRichTrbPulserQa : Event #" << fEventNum; - - -} - - -void CbmRichTrbPulserQa::DrawHist() -{ - new TCanvas("rich_trb_pulserqa_nof_hits_in_event", "rich_trb_pulserqa_nof_hits_in_event", 600, 600); - //DrawH1(fhNofHitsInEvent); -} - -void CbmRichTrbPulserQa::Finish() -{ - DrawHist(); -} - -ClassImp(CbmRichTrbPulserQa) diff --git a/beamtime/rich/CbmRichTrbPulserQa.h b/beamtime/rich/CbmRichTrbPulserQa.h deleted file mode 100644 index 98393468b1abf144acc03ee09ded858735b37f38..0000000000000000000000000000000000000000 --- a/beamtime/rich/CbmRichTrbPulserQa.h +++ /dev/null @@ -1,68 +0,0 @@ -#ifndef CBMRICHTRBPULSEROQA_H -#define CBMRICHTRBPULSEROQA_H - - -#include "FairTask.h" -#include <vector> - -using namespace std; - -class TClonesArray; -class TH1D; -class TH2D; - - -class CbmRichTrbPulserQa : public FairTask -{ -public: - /* - * Constructor. - */ - CbmRichTrbPulserQa(); - - /* - * Destractor. - */ - virtual ~CbmRichTrbPulserQa(); - - /** - * \brief Inherited from FairTask. - */ - virtual InitStatus Init(); - - /** - * \brief Inherited from FairTask. - */ - virtual void Exec( - Option_t* option); - - /** - * \brief Inherited from FairTask. - */ - virtual void Finish(); - - /* - * Histogram initialization. - */ - void InitHist(); - - /* - * Draw histograms. - */ - void DrawHist(); - - -private: - TClonesArray* fRichHits; // Array of RICH hits - - - UInt_t fEventNum; // Event counter - - - CbmRichTrbPulserQa(const CbmRichTrbPulserQa&); - CbmRichTrbPulserQa operator=(const CbmRichTrbPulserQa&); - - ClassDef(CbmRichTrbPulserQa, 1); -}; - -#endif diff --git a/beamtime/rich/CbmRichTrbRecoQa.cxx b/beamtime/rich/CbmRichTrbRecoQa.cxx deleted file mode 100644 index 33a03eb2eb8be3bacfb1a9eb07623be7f07389e6..0000000000000000000000000000000000000000 --- a/beamtime/rich/CbmRichTrbRecoQa.cxx +++ /dev/null @@ -1,470 +0,0 @@ -#include "CbmRichTrbRecoQa.h" -#include "FairRootManager.h" -#include "FairLogger.h" - -#include "TClonesArray.h" - -#include "TROOT.h" -#include "TFolder.h" -#include "TSystem.h" -#include "TH1D.h" -#include "TH2D.h" -#include "TF1.h" -#include "TCanvas.h" -#include "TFile.h" -#include "CbmDrawHist.h" -#include "CbmRichHit.h" -#include "CbmRichHitInfo.h" -#include "TEllipse.h" -#include "TLatex.h" -#include "CbmRichRingLight.h" -#include "CbmRichRingFitterCOP.h" -#include "CbmRichRingFitterEllipseTau.h" -#include "CbmRichConverter.h" -#include "CbmUtils.h" -#include "TStyle.h" - - -#include <iostream> -#include <vector> - -CbmRichTrbRecoQa::CbmRichTrbRecoQa() - : FairTask(), - fRichHits(NULL), - fRichRings(NULL), - fRichHitInfos(NULL), - fHM(NULL), - fEventNum(0), - fNofDrawnEvents(0), - fMaxNofEventsToDraw(0), - fOutputDir(""), - fRunTitle(""), - fDrawHist(kFALSE), - fCopFit(NULL), - fTauFit(NULL) -{ -} - -CbmRichTrbRecoQa::~CbmRichTrbRecoQa() -{ -} - -InitStatus CbmRichTrbRecoQa::Init() -{ - FairRootManager* manager = FairRootManager::Instance(); - fRichHits = (TClonesArray*)manager->GetObject("RichHit"); - if (NULL == fRichHits) { Fatal("CbmRichTrbRawQa::Init","No RichHit array!"); } - - fRichRings = (TClonesArray*)manager->GetObject("RichRing"); - if (NULL == fRichRings) { Fatal("CbmRichTrbRawQa::Init","No RichRing array!"); } - - fRichHitInfos = (TClonesArray*)manager->GetObject("RichHitInfo"); - if (NULL == fRichHitInfos) { Fatal("CbmRichTrbRawQa::Init","No RichHitInfo array!"); } - - fCopFit = new CbmRichRingFitterCOP(); - fTauFit = new CbmRichRingFitterEllipseTau(); - CbmRichConverter::Init(); - - InitHist(); - - return kSUCCESS; -} - -void CbmRichTrbRecoQa::InitHist() -{ - fHM = new CbmHistManager(); - - fHM->Create1<TH1D>("fhNofHitsInEvent", "fhNofHitsInEvent;Number of hits in event;Yield", 40, 0.5, 40.5); - fHM->Create1<TH1D>("fhNofHitsInRing", "fhNofHitsInRing;Number of hits in ring;Yield", 40, -0.5, 39.5); - fHM->Create2<TH2D>("fhHitsXYPixel", "fhHitsXYPixel;X [pixel];Y [pixel];Hits per pixel", 32, 0.5, 32.5, 32, 0.5, 32.5); - fHM->Create1<TH1D>("fhNofRingsInEvent", "fhNofRingsInEvent;# rings per event;Yield", 5, -0.5, 4.5); - fHM->Create1<TH1D>("fhBoverAEllipse", "fhBoverAEllipse;B/A;Yield", 200, 0.0, 1.0); - fHM->Create2<TH2D>("fhXcYcEllipse", "fhXcYcEllipse;X [cm];Y [cm];Yield", 200, 0., 21., 100, 0., 21.); - fHM->Create1<TH1D>("fhBaxisEllipse", "fhBaxisEllipse;B axis [cm];Yield", 200, 3.5, 5.5); - fHM->Create1<TH1D>("fhAaxisEllipse", "fhAaxisEllipse;A axis [cm];Yield", 200, 3.5, 5.5); - fHM->Create1<TH1D>("fhChi2Ellipse", "fhChi2Ellipse;#Chi^{2};Yield", 200, 0.0, 0.5); - fHM->Create1<TH1D>("fhPhiEllipse", "fhPhiEllipse;Ellipse rotation angle [rad];Yield", 100, -1.7, 1.7); - fHM->Create2<TH2D>("fhXcYcCircle", "fhXcYcCircle;X [cm];Y [cm];Yield", 200, 0., 21., 100, 0., 21.); - fHM->Create1<TH1D>("fhRadiusCircle", "fhRadiusCircle;Radius [cm];Yield", 200, 4.0, 5.0); - fHM->Create1<TH1D>("fhChi2Circle", "fhChi2Circle;#Chi^{2};Yield", 200, 0.0, 0.5); - fHM->Create1<TH1D>("fhDrCircle", "fhDrCircle;dR [cm];Yield", 200, -1.0, 1.0); - fHM->Create2<TH2D>("fhHitsXYPmt", "fhHitsXYPmt;PMT X;PMT Y;Hits in event per PMT", 4, 0.5, 32.5, 4, 0.5, 32.5); - fHM->Create1<TH1D>("fhNofHitsInEventAll", "fhNofHitsInEventAll;Number of hits in event;Yield", 40, 0.5, 40.5); - fHM->Create1<TH1D>("fhNofHitsInEventWithRing", "fhNofHitsInEventWithRing;Number of hits in event;Yield", 40, 0.5, 40.5); - - for (int i = 0; i < 16; i++) { - TString name, title; - // number of hits in reconstructed ring per PMT - name.Form("fhNofHitsInRingPmt_%i", i); - title.Form("fhNofHitsInRingPmt_%i;Number of hits in ring in PMT%i;Yield", i, i); - fHM->Create1<TH1D>(name.Data(), title.Data(), 15, -0.5, 14.5); - - // number of hits in event per PMT - name.Form("fhNofHitsInEventPmt_%i", i); - title.Form("fhNofHitsInEventPmt_%i;Number of hits in event in PMT%i;Yield", i, i); - fHM->Create1<TH1D>(name.Data(), title.Data(), 15, -0.5, 14.5); - } -} - -void CbmRichTrbRecoQa::Exec( - Option_t* /*option*/) -{ - fEventNum++; - LOG(debug2) << "CbmRichTrbRecoQa : Event #" << fEventNum; - - Int_t nofHitsInEvent = fRichHits->GetEntries(); - fHM->H1("fhNofHitsInEvent")->Fill(nofHitsInEvent); - - Int_t nofHitInfosInEvent = fRichHitInfos->GetEntries(); - for (Int_t iH = 0; iH < nofHitInfosInEvent; iH++) { - CbmRichHitInfo* hit = static_cast<CbmRichHitInfo*>(fRichHitInfos->At(iH)); - fHM->H2("fhHitsXYPixel")->Fill(hit->GetXPixel(), hit->GetYPixel()); - fHM->H2("fhHitsXYPmt")->Fill(hit->GetXPixel(), hit->GetYPixel()); - } - - Int_t nofRingsInEvent = fRichRings->GetEntries(); - fHM->H1("fhNofRingsInEvent")->Fill(nofRingsInEvent); - vector<CbmRichRingLight> fitCircleRing; - vector<CbmRichRingLight> fitEllipseRing; - for (Int_t iR = 0; iR < nofRingsInEvent; iR++) { - CbmRichRing* ring = static_cast<CbmRichRing*>(fRichRings->At(iR)); - - CbmRichRingLight ringL; - CbmRichConverter::CopyHitsToRingLight(ring, &ringL); - fTauFit->DoFit(&ringL); - FillHistEllipse(&ringL); - fitEllipseRing.push_back(ringL); - fCopFit->DoFit(&ringL); - FillHistCircle(&ringL); - fitCircleRing.push_back(ringL); - } - - FillNofHitsPmt(); - - fHM->H1("fhNofHitsInEventAll")->Fill(nofHitsInEvent); - if (nofRingsInEvent >= 1) fHM->H1("fhNofHitsInEventWithRing")->Fill(nofHitsInEvent); - - - if (nofHitsInEvent >= 5 && fNofDrawnEvents < fMaxNofEventsToDraw ) { - DrawEvent(fitCircleRing, fitEllipseRing); - } - - -} - -void CbmRichTrbRecoQa::FillHistEllipse( - CbmRichRingLight* ring) -{ - Double_t axisA = ring->GetAaxis(); - Double_t axisB = ring->GetBaxis(); - Double_t xcEllipse = ring->GetCenterX(); - Double_t ycEllipse = ring->GetCenterY(); - Int_t nofHitsRing = ring->GetNofHits(); - Double_t phi = ring->GetPhi(); - - fHM->H1("fhBoverAEllipse")->Fill(axisB/axisA); - fHM->H2("fhXcYcEllipse")->Fill(xcEllipse, ycEllipse); - fHM->H1("fhNofHitsInRing")->Fill(nofHitsRing); - fHM->H1("fhBaxisEllipse")->Fill(axisB); - fHM->H1("fhAaxisEllipse")->Fill(axisA); - fHM->H1("fhChi2Ellipse")->Fill(ring->GetChi2()/nofHitsRing); - fHM->H1("fhPhiEllipse")->Fill(phi); -} - -void CbmRichTrbRecoQa::FillHistCircle( - CbmRichRingLight* ring) -{ - Double_t radius = ring->GetRadius(); - Double_t xcCircle = ring->GetCenterX(); - Double_t ycCircle = ring->GetCenterY(); -// Int_t nofHitsRing = ring->GetNofHits(); - fHM->H2("fhXcYcCircle")->Fill(xcCircle, ycCircle); - fHM->H1("fhRadiusCircle")->Fill(radius); - fHM->H1("fhChi2Circle")->Fill(ring->GetChi2()/ring->GetNofHits()); - - for (Int_t iH = 0; iH < ring->GetNofHits(); iH++){ - Double_t xh = ring->GetHit(iH).fX; - Double_t yh = ring->GetHit(iH).fY; - Double_t dr = radius - sqrt((xcCircle - xh)*(xcCircle - xh) + (ycCircle - yh)*(ycCircle - yh)); - fHM->H1("fhDrCircle")->Fill(dr); - } -} - -void CbmRichTrbRecoQa::FillNofHitsPmt() -{ - //calculate number of hits in ring per PMT - Int_t nofRingsInEvent = fRichRings->GetEntries(); - for (Int_t iR = 0; iR < nofRingsInEvent; iR++) { - CbmRichRing* ring = static_cast<CbmRichRing*>(fRichRings->At(iR)); - Int_t nofHitsInRingPmt[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; - for (Int_t iH = 0; iH < ring->GetNofHits(); iH++){ - Int_t hitInd = ring->GetHit(iH); - CbmRichHit* hit = static_cast<CbmRichHit*>(fRichHits->At(hitInd)); - Int_t pmtId = hit->GetPmtId() - 1; - if (pmtId < 0 || pmtId >= 16) { - LOG(error) << "CbmRichTrbRecoQa::FillNofHitsPmt rings pmtId < 0 || pmtId > 16, pmtId:"<< pmtId; - continue; - } - nofHitsInRingPmt[pmtId]++; - }//iH - - for (int i = 0; i < 16; i++) { - TString name; - name.Form("fhNofHitsInRingPmt_%i", i); - fHM->H1(name.Data())->Fill(nofHitsInRingPmt[i]); - } - }//iR - - // number of hits in event perPMT - Int_t nofHitsInEventPmt[16] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - Int_t nofHits = fRichHits->GetEntriesFast(); - for (Int_t iH = 0; iH < nofHits; iH++) { - CbmRichHit* hit = static_cast<CbmRichHit*>(fRichHits->At(iH)); - Int_t pmtId = hit->GetPmtId() - 1; - if (pmtId < 0 || pmtId >= 16) { - LOG(error) << "CbmRichTrbRecoQa::FillNofHitsPmt events pmtId < 0 || pmtId > 16, pmtId:"<< pmtId; - continue; - } - nofHitsInEventPmt[pmtId]++; - } - - for (int i = 0; i < 16; i++) { - TString name; - name.Form("fhNofHitsInEventPmt_%i", i); - fHM->H1(name.Data())->Fill(nofHitsInEventPmt[i]); - } -} - -void CbmRichTrbRecoQa::DrawHist() -{ - { - fHM->CreateCanvas(fRunTitle + "_rich_trb_recoqa_nof_hits_in_event", fRunTitle + "_rich_trb_recoqa_nof_hits_in_event", 600, 600); - DrawH1(fHM->H1("fhNofHitsInEvent")); - FitGaussAndDrawResults(fHM->H1("fhNofHitsInEvent")); - } - - { - fHM->CreateCanvas(fRunTitle + "_rich_trb_recoqa_nof_rings_per_event", fRunTitle + "_rich_trb_recoqa_nof_rings_per_event", 600, 600); - DrawH1(fHM->H1("fhNofRingsInEvent")); - } - - { - fHM->CreateCanvas(fRunTitle + "_rich_trb_recoqa_nof_hits_per_ring", fRunTitle + "_rich_trb_recoqa_nof_hits_per_ring", 600, 600); - DrawH1(fHM->H1("fhNofHitsInRing")); - FitGaussAndDrawResults(fHM->H1("fhNofHitsInRing")); - } - - { - TCanvas* c = fHM->CreateCanvas(fRunTitle + "_rich_trb_recoqa_ellipse_param", fRunTitle + "_rich_trb_recoqa_ellipse_param", 1200, 800); - c->Divide(3, 2); - c->cd(1); - DrawH1(fHM->H1("fhBaxisEllipse"), kLinear, kLog); - FitGaussAndDrawResults(fHM->H1("fhBaxisEllipse")); - c->cd(2); - DrawH1(fHM->H1("fhAaxisEllipse"), kLinear, kLog); - FitGaussAndDrawResults(fHM->H1("fhAaxisEllipse")); - c->cd(3); - DrawH1(fHM->H1("fhBoverAEllipse")); - c->cd(4); - DrawH1(fHM->H1("fhChi2Ellipse")); - c->cd(5); - DrawH2(fHM->H2("fhXcYcEllipse")); - c->cd(6); - DrawH1(fHM->H1("fhPhiEllipse")); - } - - { - TCanvas* c = fHM->CreateCanvas(fRunTitle + "_rich_trb_recoqa_circle_param", fRunTitle + "_rich_trb_recoqa_circle_param", 800, 800); - c->Divide(2, 2); - c->cd(1); - DrawH2(fHM->H2("fhXcYcCircle")); - c->cd(2); - DrawH1(fHM->H1("fhRadiusCircle"), kLinear, kLog); - FitGaussAndDrawResults(fHM->H1("fhRadiusCircle")); - c->cd(3); - DrawH1(fHM->H1("fhChi2Circle")); - c->cd(4); - DrawH1(fHM->H1("fhDrCircle")); - FitGaussAndDrawResults(fHM->H1("fhDrCircle")); - } - - { - fHM->CreateCanvas(fRunTitle + "_rich_trb_recoqa_hits_xy_pixel", fRunTitle + "_rich_trb_recoqa_hits_xy_pixel", 800, 600); - DrawH2(fHM->H2("fhHitsXYPixel")); - } - - { - fHM->CreateCanvas(fRunTitle + "_rich_trb_recoqa_hits_xy_pmt", fRunTitle + "_rich_trb_recoqa_hits_xy_pmt", 800, 600); - TH2D* h = (TH2D*)fHM->H2("fhHitsXYPmt")->Clone(); - gStyle->SetPaintTextFormat("4.1f"); - h->Scale(100. / h->GetEntries()); - h->SetMarkerSize(3); - h->GetZaxis()->SetTitle("Hits in event per PMT [%]"); - DrawH2(h, kLinear, kLinear, kLinear, "text COLZ"); - } - - { - fHM->CreateCanvas(fRunTitle + "_rich_trb_recoqa_efficiency", fRunTitle + "_rich_trb_recoqa_efficiency", 800, 600); - TH1D* eff = Cbm::DivideH1(fHM->H1("fhNofHitsInEventWithRing"), fHM->H1("fhNofHitsInEventAll")); - DrawH1(eff); - } - - { //dashboard histogram - TCanvas* c = fHM->CreateCanvas(fRunTitle + "_rich_trb_recoqa_dashboard", fRunTitle + "_rich_trb_recoqa_dashboard", 1200, 600); - c->Divide(3, 2); - c->cd(1); - DrawH1(fHM->H1("fhNofHitsInEvent")); - c->cd(2); - DrawH1(fHM->H1("fhNofHitsInRing")); - c->cd(3); - DrawH1(fHM->H1("fhRadiusCircle"), kLinear, kLog); - c->cd(4); - DrawH2(fHM->H2("fhHitsXYPixel")); - c->cd(5); - TH2D* h = (TH2D*)fHM->H2("fhHitsXYPmt")->Clone(); - gStyle->SetPaintTextFormat("4.1f"); - h->Scale(100. / h->GetEntries()); - h->SetMarkerSize(3); - h->GetZaxis()->SetTitle("Hits in event per PMT [%]"); - DrawH2(h, kLinear, kLinear, kLinear, "text COLZ"); - c->cd(6); - TString str; - TLatex* latex = new TLatex(); - latex->DrawLatex(0.01, 0.9, (string("Run title: ") + fRunTitle).c_str()); - str.Form("Total number of events %d", (Int_t)fHM->H1("fhNofHitsInEvent")->GetEntries()); - latex->DrawLatex(0.01, 0.8, str.Data()); - TH1* hREv = fHM->H1("fhNofRingsInEvent"); - Int_t nofEvWithRing = hREv->GetEntries() - hREv->GetBinContent(1); - str.Form("Total number of events with ring %d (%.1f%%)", nofEvWithRing, 100. * nofEvWithRing / (Double_t)fHM->H1("fhNofHitsInEvent")->GetEntries()); - latex->DrawLatex(0.01, 0.7, str.Data()); - str.Form("Total number of rings %i", (Int_t)fHM->H1("fhNofHitsInRing")->GetEntries()); - latex->DrawLatex(0.01, 0.6, str.Data()); - str.Form("Total number of hits %i", (Int_t)fHM->H2("fhHitsXYPixel")->GetEntries()); - latex->DrawLatex(0.01, 0.5, str.Data()); - } - - { - TCanvas* c = fHM->CreateCanvas(fRunTitle + "_rich_trb_nofhits_in_ring_pmt_all", fRunTitle + "_rich_trb_nofhits_in_ring_pmt_all", 1200, 1200); - c->Divide(4, 4); - int count = 0; - for (int j = 0; j < 4; j++) { - for (int i = 0; i < 4; i++) { - c->cd(4 - j + 4 * i); - TString name; - name.Form("fhNofHitsInRingPmt_%i", count); - fHM->H1(name.Data()); - DrawH1(fHM->H1(name.Data()), kLinear, kLinear); - FitGaussAndDrawResults(fHM->H1(name.Data())); - count++; - } - } - } -} - - -void CbmRichTrbRecoQa::FitGaussAndDrawResults( - TH1* h) -{ - h->Fit("gaus", "Q"); - //h->Fit("gaus"); - TF1* fit = h->GetFunction("gaus"); - - Double_t sigma = (NULL != fit) ? fit->GetParameter(2) : 0.; - Double_t mean = (NULL != fit) ? fit->GetParameter(1) : 0.; - TString str; - str.Form("m=%.2f #sigma=%.2f", mean, sigma); - - h->SetTitle(str.Data()); - fit->SetLineColor(kBlack); -} - -void CbmRichTrbRecoQa::DrawHistFromFile(TString fileName) -{ - fHM = new CbmHistManager(); - TFile* file = new TFile(fileName, "READ"); - fHM->ReadFromFile(file); - DrawHist(); -} - -void CbmRichTrbRecoQa::DrawEvent( - const vector<CbmRichRingLight>& fitRingCircle, - const vector<CbmRichRingLight>& fitRingEllipse) -{ - TString ss; - ss.Form("rich_trb_recoqa_eventdisplay_%d", fNofDrawnEvents); - fNofDrawnEvents++; - TCanvas *c = fHM->CreateCanvas(ss.Data(), ss.Data(), 800, 800); - c->SetGrid(true, true); - TH2D* pad = new TH2D("pad", ";X [cm];Y [cm]", 1, 0.0, 21., 1, 0.0, 21.); - DrawH2(pad); - //gPad->SetLeftMargin(0.17); - gPad->SetRightMargin(0.12); - // gPad->SetBottomMargin(0.15); - pad->SetStats(false); - //pad->Draw(); - - //Draw event hits - Int_t nofHitsInEvent = fRichHits->GetEntries(); - for (Int_t iH = 0; iH < nofHitsInEvent; iH++){ - CbmRichHit* hit = static_cast<CbmRichHit*>(fRichHits->At(iH)); - TEllipse* hitDr = new TEllipse(hit->GetX(), hit->GetY(), 0.25); - hitDr->SetFillColor(kGreen); - hitDr->Draw(); - } - - //Draw all found rings and centers - if (fitRingCircle.size() != fitRingEllipse.size()) { - LOG(error) << "CbmRichTrbRecoQa::DrawEvent fitRingCircle.size() != fitRingEllipse.size()"; - } - - Int_t nofRings = fitRingCircle.size(); - for (Int_t iR = 0; iR < nofRings; iR++) { - CbmRichRingLight rC = fitRingCircle[iR]; - TEllipse* circle = new TEllipse(rC.GetCenterX(), rC.GetCenterY(), rC.GetRadius()); - circle->SetFillStyle(0); - circle->SetLineWidth(3); - circle->Draw(); - TEllipse* cCircle = new TEllipse(rC.GetCenterX(), rC.GetCenterY(), 0.15); - cCircle->Draw(); - - CbmRichRingLight rE = fitRingEllipse[iR]; - Double_t ePhi = rE.GetPhi() * 180 / TMath::Pi(); - TEllipse* ellipse = new TEllipse(rE.GetCenterX(), rE.GetCenterY(), rE.GetAaxis(), rE.GetBaxis(), 0., 360., ePhi); - ellipse->SetFillStyle(0); - ellipse->SetLineWidth(3); - ellipse->SetLineColor(kBlue); - ellipse->Draw(); - TEllipse* cEllipse = new TEllipse(rE.GetCenterX(), rE.GetCenterY(), 0.15); - cEllipse->Draw(); - - // Draw hits from the ring - for (int iH = 0; iH < rC.GetNofHits(); iH++){ - CbmRichHitLight hit = rC.GetHit(iH); - TEllipse* hitDr = new TEllipse(hit.fX, hit.fY, 0.15); - hitDr->SetFillColor(kRed); - hitDr->Draw(); - } - //Draw information - ss.Form("(x, y, A, B, #phi, n, B/A)=(%.1f, %.1f, %.2f, %.2f, %.2f, %i, %.2f)", - rE.GetCenterX(), rE.GetCenterY(), rE.GetAaxis(), rE.GetBaxis(), rE.GetPhi(), rE.GetNofHits(), rE.GetBaxis()/rE.GetAaxis()); - TLatex* latexEllipse = new TLatex(0.05, 22.5 - 1.0 * iR, ss.Data()); - latexEllipse->SetTextSize(0.03); - latexEllipse->Draw(); - - ss.Form("(x, y, R, n)=(%.1f, %.1f, %.2f, %i)", rC.GetCenterX(), rC.GetCenterY(), rC.GetRadius(), rE.GetNofHits()); - TLatex* latexCircle = new TLatex(0.05, 21.5 - 1.0 * iR, ss.Data()); - latexCircle->SetTextSize(0.03); - latexCircle->Draw(); - } -} - -void CbmRichTrbRecoQa::Finish() -{ - if (fDrawHist) { - DrawHist(); - } - fHM->SaveCanvasToImage(fOutputDir); - fHM->WriteToFile(); -} - -ClassImp(CbmRichTrbRecoQa) diff --git a/beamtime/rich/CbmRichTrbRecoQa.h b/beamtime/rich/CbmRichTrbRecoQa.h deleted file mode 100644 index 1cb52c2b5c05a567d68a60ddab9862d942a1ca47..0000000000000000000000000000000000000000 --- a/beamtime/rich/CbmRichTrbRecoQa.h +++ /dev/null @@ -1,139 +0,0 @@ -#ifndef CBMRICHTRBRECOQA_H -#define CBMRICHTRBRECOQA_H - -#include "FairTask.h" -#include "CbmRichRingLight.h" -#include "CbmHistManager.h" -#include <vector> -#include <string> - -using namespace std; - -class TClonesArray; -class TH1D; -class TH2D; -class TCanvas; -class CbmRichRing; - -class CbmRichRingFitterCOP; -class CbmRichRingFitterEllipseTau; - -class CbmRichTrbRecoQa : public FairTask -{ -public: - /* - * Constructor. - */ - CbmRichTrbRecoQa(); - - /* - * Destractor. - */ - virtual ~CbmRichTrbRecoQa(); - - /** - * \brief Inherited from FairTask. - */ - virtual InitStatus Init(); - - /** - * \brief Inherited from FairTask. - */ - virtual void Exec(Option_t* option); - - /** - * \brief Inherited from FairTask. - */ - virtual void Finish(); - - /* - * Histogram initialization. - */ - void InitHist(); - - /* - * Draw histograms. - */ - void DrawHist(); - - /* - * Draw current event (event display) - * \param fitRingCircle Fitted rings with COP algorithm. - * \param fitRingEllipse FittedRings with TAU ellipse fitter. - */ - void DrawEvent( - const vector<CbmRichRingLight>& fitRingCircle, - const vector<CbmRichRingLight>& fitRingEllipse); - - /* - * Fill histogramms for the circle fit. - */ - void FillHistCircle( - CbmRichRingLight* ring); - - /* - * Fill histogramms for the ellipse fit. - */ - void FillHistEllipse( - CbmRichRingLight* ring); - - /* - * - */ - void FillNofHitsPmt(); - - /* - * Fit histogramm with Gauss fit and put results to the title. - */ - void FitGaussAndDrawResults(TH1* h); - - /* - * Draw histograms from file - */ - void DrawHistFromFile(TString fileName); - - /* - * Set maximum number of events to draw - */ - void SetMaxNofEventsToDraw(UInt_t n) {fMaxNofEventsToDraw = n;} - - /* - * Set output directory for images. - */ - void SetOutputDir(string dir) {fOutputDir = dir;} - - /* - * Set run title. It is also a part of the file name of image files. - */ - void SetRunTitle(string title) {fRunTitle = title;} - - /* - * Set to TRUE if you want to draw histograms. - */ - void SetDrawHist(Bool_t b) {fDrawHist = b;} - -private: - - TClonesArray* fRichHits; // Array of RICH hits - TClonesArray* fRichRings; // Array of found RICH rings - TClonesArray* fRichHitInfos; // Array of CbmRichHitInfo - - CbmHistManager* fHM; // histogram manager, all the histogram are manager by HM - - UInt_t fEventNum; // Event counter - UInt_t fNofDrawnEvents; // Number of drawn events - UInt_t fMaxNofEventsToDraw; // maximum number of events to draw - string fOutputDir; // output directory to store figures - string fRunTitle; // Title of the run - Bool_t fDrawHist; // if TRUE histogramms are drawn - - CbmRichRingFitterCOP* fCopFit; - CbmRichRingFitterEllipseTau* fTauFit; - - CbmRichTrbRecoQa(const CbmRichTrbRecoQa&); - CbmRichTrbRecoQa operator=(const CbmRichTrbRecoQa&); - - ClassDef(CbmRichTrbRecoQa, 1); -}; - -#endif diff --git a/beamtime/rich/CbmRichTrbRecoQaStudyReport.cxx b/beamtime/rich/CbmRichTrbRecoQaStudyReport.cxx deleted file mode 100644 index b8cc0083709a01f9c3c047ec5fcb00336d218e3c..0000000000000000000000000000000000000000 --- a/beamtime/rich/CbmRichTrbRecoQaStudyReport.cxx +++ /dev/null @@ -1,162 +0,0 @@ - -#include "CbmRichTrbRecoQaStudyReport.h" -#include "CbmReportElement.h" -#include "CbmHistManager.h" -#include "CbmDrawHist.h" -#include "CbmUtils.h" -#include "TH1.h" -#include "TF1.h" -#include "TCanvas.h" -#include "TDirectory.h" -#include <vector> -#include <iostream> -#include <boost/assign/list_of.hpp> -#include "CbmUtils.h" - -using boost::assign::list_of; -using namespace std; - - -CbmRichTrbRecoQaStudyReport::CbmRichTrbRecoQaStudyReport(): - CbmStudyReport(), - fFitHist(true) -{ - SetReportName("rich_trb_reco_study_report"); - SetReportTitle("RICH study report"); -} - -CbmRichTrbRecoQaStudyReport::~CbmRichTrbRecoQaStudyReport() -{ -} - -void CbmRichTrbRecoQaStudyReport::Create() -{ - Out().precision(3); - Out() << R()->DocumentBegin(); - Out() << R()->Title(0, GetTitle()); - PrintCanvases(); - Out() << R()->DocumentEnd(); -} - -void CbmRichTrbRecoQaStudyReport::Draw() -{ - SetDefaultDrawStyle(); - { - CreateCanvas("rich_report_radius", "rich_report_radius", 600, 600); - FitGausAndDrawH1("fhRadiusCircle"); - } - - { - CreateCanvas("rich_report_hits_in_event", "rich_report_hits_in_event", 600, 600); - FitGausAndDrawH1("fhNofHitsInEvent"); - } - - { - CreateCanvas("rich_report_hits_in_ring", "rich_report_hits_in_ring", 600, 600); - FitGausAndDrawH1("fhNofHitsInRing"); - } - - { - CreateCanvas("rich_report_baxis", "rich_report_baxis", 600, 600); - FitGausAndDrawH1("fhBaxisEllipse"); - } - - { - CreateCanvas("rich_report_aaxis", "rich_report_aaxis", 600, 600); - FitGausAndDrawH1("fhAaxisEllipse"); - } - - { - CreateCanvas("rich_report_dr", "rich_report_dr", 600, 600); - FitGausAndDrawH1("fhDrCircle"); - } - - { - CreateCanvas("rich_report_boa", "rich_report_boa", 600, 600); - FitGausAndDrawH1("fhBoverAEllipse"); - } - - { // position G - TCanvas* canvas2 = CreateCanvas("rich_report_nofhits_pmt_posG", "rich_report_nofhits_pmt_posG", 1200, 1200); - canvas2->Divide(2,2); - canvas2->cd(1); - FitGausAndDrawH1("fhNofHitsInRingPmt_4"); - canvas2->cd(2); - FitGausAndDrawH1("fhNofHitsInRingPmt_0"); - canvas2->cd(3); - FitGausAndDrawH1("fhNofHitsInRingPmt_5"); - canvas2->cd(4); - FitGausAndDrawH1("fhNofHitsInRingPmt_1"); - } - - { // position H - TCanvas* canvas2 = CreateCanvas("rich_report_nofhits_pmt_posH", "rich_report_nofhits_pmt_posH", 1200, 1200); - canvas2->Divide(2,2); - canvas2->cd(1); - FitGausAndDrawH1("fhNofHitsInRingPmt_5"); - canvas2->cd(2); - FitGausAndDrawH1("fhNofHitsInRingPmt_1"); - canvas2->cd(3); - FitGausAndDrawH1("fhNofHitsInRingPmt_6"); - canvas2->cd(4); - FitGausAndDrawH1("fhNofHitsInRingPmt_2"); - } - - - DrawEfficiency(); - -} - -void CbmRichTrbRecoQaStudyReport::FitGausAndDrawH1( - const string& histName) -{ - Int_t nofStudies = HM().size(); - vector<TH1*> histos1(nofStudies); - vector<string> legendNames; - for (Int_t iStudy = 0; iStudy < nofStudies; iStudy++) { - histos1[iStudy] = HM()[iStudy]->H1(histName); - histos1[iStudy]->Scale(1./histos1[iStudy]->Integral()); - histos1[iStudy]->SetMaximum(histos1[iStudy]->GetMaximum() * 1.20); - - if (fFitHist) { - histos1[iStudy]->Fit("gaus", "Q"); - TF1* fit = histos1[iStudy]->GetFunction("gaus"); - Double_t sigma = (NULL != fit) ? fit->GetParameter(2) : 0.; - Double_t mean = (NULL != fit) ? fit->GetParameter(1) : 0.; - TString str; - str.Form(" (%.2f/%.3f)", mean, sigma); - legendNames.push_back(GetStudyNames()[iStudy] + string(str.Data())); - } else { - TString str; - str.Form(" (%.2f/%.3f)", histos1[iStudy]->GetMean(), histos1[iStudy]->GetRMS()); - TF1* fit = histos1[iStudy]->GetFunction("gaus"); - if (fit != NULL) fit->Delete(); - legendNames.push_back(GetStudyNames()[iStudy] + string(str.Data())); - } - } - DrawH1(histos1, legendNames, kLinear, kLinear, true, .5, .7, .99, .99); - if (fFitHist) { - for (Int_t iStudy = 0; iStudy < nofStudies; iStudy++) { - histos1[iStudy]->GetFunction("gaus")->SetLineColor(histos1[iStudy]->GetLineColor()); - } - } - gPad->SetGridx(true); - gPad->SetGridy(true); -} - -void CbmRichTrbRecoQaStudyReport::DrawEfficiency() -{ - Int_t nofStudies = HM().size(); - CreateCanvas("rich_report_efficiency", "rich_report_efficiency", 600, 600); - vector<TH1*> histos1(nofStudies); - vector<string> legendNames; - for (Int_t iStudy = 0; iStudy < nofStudies; iStudy++) { - histos1[iStudy] = Cbm::DivideH1(HM()[iStudy]->H1("fhNofHitsInEventWithRing"), HM()[iStudy]->H1("fhNofHitsInEventAll")); - TString str; - //str.Form(" (%.2f/%.2f)", mean, sigma); - legendNames.push_back(GetStudyNames()[iStudy] + string(str.Data())); - } - DrawH1(histos1, legendNames, kLinear, kLinear); -} - -ClassImp(CbmRichTrbRecoQaStudyReport) diff --git a/beamtime/rich/CbmRichTrbRecoQaStudyReport.h b/beamtime/rich/CbmRichTrbRecoQaStudyReport.h deleted file mode 100644 index f3eddfb66ce98d15b3197107e089687fd275787d..0000000000000000000000000000000000000000 --- a/beamtime/rich/CbmRichTrbRecoQaStudyReport.h +++ /dev/null @@ -1,49 +0,0 @@ - -#ifndef CBMRICHTRBRECOQASTUDYREPORT_H -#define CBMRICHTRBRECOQASTUDYREPORT_H - -#include "CbmStudyReport.h" -#include <string> -using std::string; -class TH1; - - -class CbmRichTrbRecoQaStudyReport : public CbmStudyReport -{ -public: - /** - * \brief Constructor. - */ - CbmRichTrbRecoQaStudyReport(); - - /** - * \brief Destructor. - */ - virtual ~CbmRichTrbRecoQaStudyReport(); - - void SetFitHist(Bool_t b) {fFitHist = b;} - -protected: - - Bool_t fFitHist; // if true -> histograms will be fitted by gaus - /** - * \brief Inherited from CbmLitStudyReport. - */ - void Create(); - - /** - * \brief Inherited from CbmLitStudyReport. - */ - void Draw(); - - - void FitGausAndDrawH1( - const string& histName); - - void DrawEfficiency(); - - - ClassDef(CbmRichTrbRecoQaStudyReport, 1) -}; - -#endif diff --git a/beamtime/rich/CbmRichTrbTimeMessage.h b/beamtime/rich/CbmRichTrbTimeMessage.h deleted file mode 100644 index b11e982774936e9f65898c861ba67cb2a80c93c4..0000000000000000000000000000000000000000 --- a/beamtime/rich/CbmRichTrbTimeMessage.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef CBMRICHTRBTIMEMESSAGE_H -#define CBMRICHTRBTIMEMESSAGE_H - -#include <ostream> -#include <stdint.h> - -using namespace std; - -class CbmRichTrbTimeMessage -{ -public: - CbmRichTrbTimeMessage(): - fChannelNum(0), - fEpochCounter(0), - fCoarseTime(0), - fFineTime(0) - { - - } - - CbmRichTrbTimeMessage(UInt_t chNum, UInt_t epoch, UInt_t coarse, UInt_t fine): - fChannelNum(chNum), - fEpochCounter(epoch), - fCoarseTime(coarse), - fFineTime(fine) - { - ; - } - - ~CbmRichTrbTimeMessage() - { - - } - - void SetParams(UInt_t chNum, UInt_t epoch, UInt_t coarse, UInt_t fine) - { - fChannelNum = chNum; - fEpochCounter = epoch; - fCoarseTime = coarse; - fFineTime = fine; - } - - UInt_t fChannelNum; - UInt_t fEpochCounter; - UInt_t fCoarseTime; - UInt_t fFineTime; -}; - -#endif diff --git a/beamtime/rich/CbmRichTrbUnpack.cxx b/beamtime/rich/CbmRichTrbUnpack.cxx deleted file mode 100644 index 9a5342c1e269fae84c97bc4660a681d65762e9e7..0000000000000000000000000000000000000000 --- a/beamtime/rich/CbmRichTrbUnpack.cxx +++ /dev/null @@ -1,758 +0,0 @@ -#include "CbmRichTrbUnpack.h" - -#include <fstream> -#include <vector> -#include <algorithm> -#include <queue> -#include "CbmTrbIterator.h" -#include "CbmTrbRawHit.h" -#include "CbmTrbOutputHit.h" -#include "CbmRichTrbParam.h" -#include "CbmTrbCalibrator.h" -#include "FairRootManager.h" -#include "CbmRichHit.h" -#include "CbmRichHitInfo.h" -#include "TClonesArray.h" -#include "CbmDrawHist.h" -#include "TFolder.h" -#include "CbmRichTrbTimeMessage.h" -#include "CbmRichEpicsData.h" - -#include "TH1D.h" -#include "TCanvas.h" - -#include "FairLogger.h" - -CbmRichTrbUnpack::CbmRichTrbUnpack(TString hldFileName) - : FairSource(), - fHldFileName(hldFileName), - fRichHits(NULL), - fRichHitInfos(NULL), - fDataPointer(NULL), - fDataSize(0), - fEventNum(0), - fNofHitsWithOneEdge(0), - fNofRawEvents(0), - fNofRawSubEvents(0), - fNofTimeDataMessages(0), - fSynchRefTime(0.), - fSynchOffsetTimeMap(), - fRawRichHits(), - fRawEventTimeHits(), - fRawFingerSciHits(), - fOutputRichHits(), - fOutputEventTimeHits(), - fOutputFingerSciHits(), - fhChannelEntries(), - fhEpoch(), - fhCoarseTime(), - fhFineTime(), - fhDeltaT(), - fhDiffHitTimeEventTime(), - fhNofRichHitsVsTrbNum(), - fhDiffHitTimeEventTimeAll(), - fhDiffFingerSciTimeEventTimeAll(), - fAnaType(kCbmRichBeamEvent), - fUseFingerSci(false), - fDrawHist(kFALSE) -{ -} - -CbmRichTrbUnpack::~CbmRichTrbUnpack() -{ - ; -} - -Bool_t CbmRichTrbUnpack::Init() -{ - LOG(info) << "CbmRichTrbUnpack::Init()"; - LOG(info) << "Input file name " << fHldFileName << endl; - - ReadInputFileToMemory(); - - FairRootManager* fManager = FairRootManager::Instance(); - - fRichHits = new TClonesArray("CbmRichHit"); - fManager->Register("RichHit","RICH", fRichHits, kTRUE); - - fRichHitInfos = new TClonesArray("CbmRichHitInfo"); - fManager->Register("RichHitInfo","RICH", fRichHitInfos, kTRUE); - - ReadEvents(); - - fhNofRichHitsVsTrbNum = new TH2D("fhNofRichHitsVsTrbNum", "fhNofRichHitsVsTrbNum;TRB number;Nof hits in event", TRB_TDC3_NUMBOARDS, .5, TRB_TDC3_NUMBOARDS + .5, 65, -0.5, 64.5); - fhDiffHitTimeEventTimeAll = new TH1D("fhDiffHitTimeEventTime", "fhDiffHitTimeEventTime;dT [ns];Entries", 200, -100., 100.); - fhDiffFingerSciTimeEventTimeAll = new TH1D("fhDiffFingerSciTimeEventTimeAll", "fhDiffFingerSciTimeEventTimeAll;dT [ns];Entries", 200, -100., 100.); - - TString hname, htitle; - for (Int_t iTrb = 0; iTrb < TRB_TDC3_NUMBOARDS; iTrb++){ - for (Int_t iTdc = 0; iTdc < TRB_TDC3_NUMTDC; iTdc++){ - hname.Form("fhDiffHitTimeEventTime_%d_%d", iTrb+1, iTdc); - htitle.Form("fhDiffHitTimeEventTime_%d_%d;dT [ns];Entries", iTrb+1, iTdc); - fhDiffHitTimeEventTime[iTrb][iTdc] = new TH1D( hname.Data(), htitle.Data(), 200, -100., 100.); - } - } - - return kTRUE; -} - -Int_t CbmRichTrbUnpack::ReadEvent(UInt_t) -{ - LOG(debug) << "Event #" << fEventNum; - - fRichHits->Clear(); - fRichHitInfos->Clear(); - - if (fOutputEventTimeHits.size() == 0) { - LOG(error) << "No reference time hits."; - return 1; - } - - BuildEvent(fEventNum); - - fEventNum++; - - if (fEventNum < fOutputEventTimeHits.size()){ - return 0; // still some data - } else { - return 1; // no more events - } -} - -void CbmRichTrbUnpack::Close() -{ - if (fDrawHist) { - CreateAndDrawQa(); - CreateAndDrawEventBuildDisplay(); - } - ClearAllBuffers(); -} - -void CbmRichTrbUnpack::Reset() -{ - -} - -void CbmRichTrbUnpack::ReadInputFileToMemory() -{ - streampos size; - ifstream file (fHldFileName.Data(), ios::in|ios::binary|ios::ate); - if (file.is_open()) { - size = file.tellg(); - fDataPointer = new Char_t[size]; - file.seekg (0, ios::beg); - file.read (fDataPointer, size); - file.close(); - LOG(info) << "The entire file content is in memory (" << size/(1024*1024) << " MB)"; - } else { - LOG(fatal) << "Unable to open file "; - } - fDataSize = (UInt_t) size; -} - -void CbmRichTrbUnpack::ReadEvents() -{ - CbmTrbIterator* trbIter = new CbmTrbIterator((void*)fDataPointer, fDataSize); - UInt_t maxNofRawEvents = 2000000000; - - // Loop through events - while (true) { - // Try to extract next event from the Iterator. If no events left - go out of the loop - CbmRawEvent* rawEvent = trbIter->NextEvent(); - if (rawEvent == NULL) break; - fNofRawEvents++; - - if (fNofRawEvents % 10000 == 0) LOG(info) << "Raw event # " << fNofRawEvents; - //rawEvent->Print(); - fSynchRefTime = -1.; - // Loop over subevents - while (true){ - CbmRawSubEvent* rawSubEvent = trbIter->NextSubEvent(); - if (rawSubEvent == NULL) break; - //rawSubEvent->Print(); - ProcessTdc(rawSubEvent); - fNofRawSubEvents++; - } - // Go out if exceed the limit of total number of raw hits - if (fNofRawEvents >= maxNofRawEvents){ - break; - } - } - - CreateOutputHits(); - delete[] fDataPointer; -} - -void CbmRichTrbUnpack::ProcessTdc(CbmRawSubEvent* rawSubEvent) -{ - UInt_t tdcDataIndex = 0; - UInt_t tdcData = 0x0; - UInt_t trbId = rawSubEvent->SubId(); - - while (true) { - tdcData = rawSubEvent->SubDataValue(tdcDataIndex); - UInt_t tdcNofWords = (tdcData >> 16) & 0xffff; - UInt_t tdcId = tdcData & 0xffff; - //printf("TDC DATA tdcNofWords = %i, ID = 0x%04x\n", tdcNofWords, tdcId); - if (tdcId == 0x5555) break; - if (tdcId == 0x7000 || tdcId == 0x7001 || tdcId == 0x7002 || tdcId == 0x7003){ - tdcDataIndex++; - continue; - } - - //read TDC words to array - UInt_t dataArray[tdcNofWords]; - for (UInt_t i = 0; i < tdcNofWords; i++) { - tdcDataIndex++; - tdcData = rawSubEvent->SubDataValue(tdcDataIndex); - dataArray[i] = tdcData; - } // for tdcNofWords - DecodeTdcData(dataArray, tdcNofWords, trbId, tdcId); - tdcDataIndex++; - } -} - -void CbmRichTrbUnpack::DecodeTdcData( - UInt_t* data, - UInt_t size, - UInt_t trbId, - UInt_t tdcId) -{ - // decode epics data - if (tdcId == 0x0112){ - DecodeEpicsData(data, size); - return; - } - //printf("TRBID=0x%04x, TDCID=0x%04x\n", trbId, tdcId); - - CbmRichTrbParam* param = CbmRichTrbParam::Instance(); - //Bool_t isPmtHit = CbmRichTrbParam::Instance()->IsPmtTrb(trbId); - Bool_t isPmtHit = CbmRichTrbParam::Instance()->IsPmtTdc(tdcId); - UInt_t curEpochCounter = 0; - queue<CbmRichTrbTimeMessage> mesQ; - - for (UInt_t i = 0; i < size; i++){ - UInt_t tdcData = data[i]; - UInt_t tdcTimeDataMarker = (tdcData >> 31) & 0x1; //1 bit - - if (tdcTimeDataMarker == 0x1) { //TIME DATA - fNofTimeDataMessages++; - UInt_t chNum = (tdcData >> 22) & 0x7f; // 7bits - UInt_t fineTime = (tdcData >> 12) & 0x3ff; // 10 bits //0x3ff - UInt_t edge = (tdcData >> 11) & 0x1; // 1bit - UInt_t coarseTime = (tdcData) & 0x7ff; // 1bits - - // Give the calibrator the read fine time so that it was taken into account - if ((trbId != 0x7005)) CbmTrbCalibrator::Instance()->AddFineTime(/*trbId, */tdcId, chNum, fineTime); - - LOG(debug) << "TIMEDATA chNum:" << chNum << ", fineTime:" << fineTime << ", edge:" << edge << ", coarseTime:" << coarseTime - << ", fullTime:" << fixed << GetFullTime(tdcId, chNum, curEpochCounter, coarseTime, fineTime); - - if ( param->IsSyncChannel(chNum) ) { // synchronization channel - Double_t time = GetFullTime(tdcId, chNum, curEpochCounter, coarseTime, fineTime); - if (fSynchRefTime == -1. ) { - fSynchRefTime = time; - } - if (fSynchRefTime != -1){ - fSynchOffsetTimeMap[tdcId] = fSynchRefTime - time; - } else{ - fSynchOffsetTimeMap[tdcId] = 0.; - } - } else { - if (tdcId == 0x7005) { //CTS - - } else if (tdcId == 0x0110) { // reference time TDC for event building - if ( (fAnaType == kCbmRichBeamEvent && chNum == 5) || // hodoscope (beam trigger) - (fAnaType == kCbmRichLaserPulserEvent && chNum == 7) || // UV LED - (fAnaType == kCbmRichLedPulserEvent && chNum == 15) ){ // Laser - - CbmTrbRawHit* rawHitRef = new CbmTrbRawHit(tdcId, chNum, curEpochCounter, coarseTime, fineTime, 0, 0, 0, 0); - fRawEventTimeHits.push_back(rawHitRef); - } - if (fUseFingerSci && chNum == 1) { - CbmTrbRawHit* rawFingerScif = new CbmTrbRawHit(tdcId, chNum, curEpochCounter, coarseTime, fineTime, 0, 0, 0, 0); - fRawFingerSciHits.push_back(rawFingerScif); - } - } else if ( isPmtHit ) { - if ( param->IsLeadingEdgeChannel(chNum) ) { // leading edge - mesQ.push( CbmRichTrbTimeMessage(chNum, curEpochCounter, coarseTime, fineTime) ); - } else { // trailing edge - if (!mesQ.empty()) { - CbmRichTrbTimeMessage tMes = mesQ.front(); - mesQ.pop(); - if (chNum - tMes.fChannelNum != 1) { - //LOG(error) << "Leading edge channel number - trailing edge channel number != 1. tdcId=" << hex << tdcId << dec << - // ", chNum=" << chNum << ", prevChNum=" << tMes.fChannelNum; - fNofHitsWithOneEdge++; - tMes = mesQ.front(); - mesQ.pop(); - } - if (chNum - tMes.fChannelNum == 1) { - CbmTrbRawHit* rawHit = new CbmTrbRawHit(tdcId, tMes.fChannelNum, tMes.fEpochCounter, tMes.fCoarseTime, tMes.fFineTime, - chNum, curEpochCounter, coarseTime, fineTime); - fRawRichHits.push_back(rawHit); - } else { - LOG(error) << "STILL Leading edge channel number - trailing edge channel number != 1. tdcId=" << hex << tdcId << dec << - ", chNum=" << chNum << ", prevChNum=" << tMes.fChannelNum; - // remove all elements from queue - queue<CbmRichTrbTimeMessage> empty; - swap( mesQ, empty ); - } - } else { // message queue is empty - fNofHitsWithOneEdge++; - //LOG(error) << "MESSAGE QUEUE is empty"; - } - } // is trailing edge - } //isPmtTrb - }//NOT SYNCH channel - - if (fineTime == 0x3ff) LOG(debug) << "-ERROR- Dummy fine time registered: " << fineTime; - }// if TIME DATA - - UInt_t tdcMarker = (tdcData >> 29) & 0x7; //3 bits - if (tdcMarker == 0x1) {// TDC header - // UInt_t randomCode = (tdcData >> 16) & 0xff; // 8bits - // UInt_t errorBits = (tdcData) & 0xffff; //16 bits - //printf("TDC HEADER randomCode:0x%02x, errorBits:0x%04x\n", randomCode, errorBits); - } else if (tdcMarker == 0x2) {// DEBUG - // UInt_t debugMode = (tdcData >> 24) & 0x1f; //5 - // UInt_t debugBits = (tdcData) & 0xffffff;//24 bits - //printf("DEBUG debugMode:%i, debugBits:0x%06x\n", debugMode, debugBits); - } else if (tdcMarker == 0x3){ // EPOCH counter - curEpochCounter = (tdcData) & 0xfffffff; //28 bits - //printf("EPOCH COUNTER epochCounter:0x%07x\n", curEpochCounter); - } - }// for loop -} - -void CbmRichTrbUnpack::DecodeEpicsData(UInt_t* data, UInt_t size) -{ - - if (size <= 4) return; - CbmRichEpicsData ed; - for (UInt_t i = 0; i < size; i++){ - if (i <= 3) continue; // MBS data and header - UInt_t tdcData = data[i]; - - if (i == 4) { // 0 - ed.fCBM_BMP180_GetTemp = (tdcData & 0x1ff) / 10.; //9 bits - ed.fCBM_BMP180_GetPressure = (tdcData << 9) & 0x1fffff; // 21 bits - ed.fDataFormatVersion = (tdcData << 30) & 0x3; // 2 bits - } else if (i == 5) { // 1 - ed.fCBM_PWRSWITCH_GetCurrent00 = tdcData & 0xffff; - ed.fCBM_PWRSWITCH_GetCurrent01 = (tdcData << 16) & 0xffff; - } else if (i == 6) { // 2 - ed.fCBM_PWRSWITCH_GetCurrent02 = tdcData & 0xffff; - ed.fCBM_PWRSWITCH_GetCurrent03 = (tdcData << 16) & 0xffff; - } else if (i == 7) { // 3 - ed.fCBM_PWRSWITCH_GetCurrent04 = tdcData & 0xffff; - ed.fCBM_PWRSWITCH_GetCurrent05 = (tdcData << 16) & 0xffff; - } else if (i == 8) { // 4 - ed.fCBM_PWRSWITCH_GetCurrent06 = tdcData & 0xffff; - ed.fCBM_PWRSWITCH_GetCurrent07 = (tdcData << 16) & 0xffff; - } else if (i == 9) { // 5 - ed.fCBM_PWRSWITCH_GetCurrent08 = tdcData & 0xffff; - ed.fCBM_PWRSWITCH_GetCurrent09 = (tdcData << 16) & 0xffff; - } else if (i == 10) { // 6 - ed.fCBM_PWRSWITCH_GetCurrent0A = tdcData & 0xffff; - ed.fCBM_PWRSWITCH_GetCurrent0B = (tdcData << 16) & 0xffff; - } else if (i == 11) { // 7 - ed.fCBM_PWRSWITCH_GetCurrent0C = tdcData & 0xffff; - ed.fCBM_PWRSWITCH_GetCurrent0D = (tdcData << 16) & 0xffff; - } else if (i == 12) { // 8 - ed.fCBM_PWRSWITCH_GetCurrent0E = tdcData & 0xffff; - ed.fCBM_PWRSWITCH_GetCurrent0F = (tdcData << 16) & 0xffff; - } else if (i == 13) { // 9 - ed.fTimestampThresholdFile = tdcData; - } else if (i == 14) { // 10 - ed.fOUTPUT_TERMINAL_VOLTAGE_U0 = (tdcData & 0xffff) / 100.; - ed.fMEASUREMENT_CURRENT_U0 = (tdcData << 16) & 0xffff; - } else if (i == 15) { // 11 - ed.fOUTPUT_TERMINAL_VOLTAGE_U1 = (tdcData & 0xffff) / 100.; - ed.fMEASUREMENT_CURRENT_U1 = (tdcData << 16) & 0xffff; - } else if (i == 16) { // 12 - ed.fOUTPUT_TERMINAL_VOLTAGE_U2 = (tdcData & 0xffff) / 100.; - ed.fMEASUREMENT_CURRENT_U2 = (tdcData << 16) & 0xffff; - } else if (i == 17) { // 13 - ed.fOUTPUT_TERMINAL_VOLTAGE_U3 = (tdcData & 0xffff) / 100.; - ed.fMEASUREMENT_CURRENT_U3 = (tdcData << 16) & 0xffff; - } else if (i == 18) { // 14 - ed.fOUTPUT_TERMINAL_VOLTAGE_U4 = (tdcData & 0xffff) / 100.; - ed.fMEASUREMENT_CURRENT_U4 = (tdcData << 16) & 0xffff; - } else if (i == 19) { // 15 - ed.fOUTPUT_TERMINAL_VOLTAGE_U5 = (tdcData & 0xffff) / 100.; - ed.fMEASUREMENT_CURRENT_U5 = (tdcData << 16) & 0xffff; - } else if (i == 20) { // 16 - ed.fOUTPUT_TERMINAL_VOLTAGE_U6 = (tdcData & 0xffff) / 100.; - ed.fMEASUREMENT_CURRENT_U6 = (tdcData << 16) & 0xffff; - } else if (i == 21) { // 17 - ed.fOUTPUT_TERMINAL_VOLTAGE_U7 = (tdcData & 0xffff) / 100.; - ed.fMEASUREMENT_CURRENT_U7 = (tdcData << 16) & 0xffff; - } else if (i == 22) { // 18 - ed.fOUTPUT_TERMINAL_VOLTAGE_U8 = (tdcData & 0xffff) / 100.; - ed.fMEASUREMENT_CURRENT_U8 = (tdcData << 16) & 0xffff; - } else if (i == 23) { // 19 - ed.fOUTPUT_TERMINAL_VOLTAGE_U9 = (tdcData & 0xffff) / 100.; - ed.fMEASUREMENT_CURRENT_U9 = (tdcData << 16) & 0xffff; - } else if (i == 24) { // 20 - ed.fOUTPUT_TERMINAL_VOLTAGE_U10 = (tdcData & 0xffff) / 100.; - ed.fMEASUREMENT_CURRENT_U10 = (tdcData << 16) & 0xffff; - } else if (i == 25) { // 21 - ed.fOUTPUT_TERMINAL_VOLTAGE_U11 = (tdcData & 0xffff) / 100.; - ed.fMEASUREMENT_CURRENT_U11 = (tdcData << 16) & 0xffff; - } else if (i == 26) { // 22 - ed.fOUTPUT_TERMINAL_VOLTAGE_U12 = (tdcData & 0xffff) / 100.; - ed.fMEASUREMENT_CURRENT_U12 = (tdcData << 16) & 0xffff; - } else if (i == 27) { // 23 - ed.fOUTPUT_TERMINAL_VOLTAGE_U13 = (tdcData & 0xffff) / 100.; - ed.fMEASUREMENT_CURRENT_U13 = (tdcData << 16) & 0xffff; - } else if (i == 28) { // 24 - ed.fOUTPUT_TERMINAL_VOLTAGE_U14 = (tdcData & 0xffff) / 100.; - ed.fMEASUREMENT_CURRENT_U14 = (tdcData << 16) & 0xffff; - } else if (i == 29) { // 25 - ed.fOUTPUT_TERMINAL_VOLTAGE_U15 = (tdcData & 0xffff) / 100.; - ed.fMEASUREMENT_CURRENT_U15 = (tdcData << 16) & 0xffff; - } else if (i == 30) { // 26 - ed.fCBM_RICH_Mirror_Pos_ActualPosition1 = (tdcData & 0xffff) / 100.; - ed.fCBM_RICH_Mirror_Pos_ActualPosition2 = ((tdcData << 16) & 0xffff) / 100.; - } else if (i == 31) { // 27 - ed.fCBM_RICH_Gas_O2 = (tdcData & 0xffff) / 32.; - ed.fCBM_RICH_Gas_H2O = ((tdcData << 16) & 0xffff) / 32.; - } else if (i == 32) { // 28 - ed.fCBM_RICH_Gas_PT_1 = (tdcData & 0xffff) / 12800.; - ed.fCBM_RICH_Gas_PTB = ((tdcData << 16) & 0xffff) / 32.; - } else if (i == 33) { // 29 - ed.fCBM_RICH_Gas_PT_2 = (tdcData & 0xffff) / 32.; - ed.fCBM_RICH_Gas_PT_3 = ((tdcData << 16) & 0xffff) / 32.; - } else if (i == 34) { // 30 - ed.fCBM_RICH_Gas_TT_1 = (tdcData & 0xffff) / 128.; - ed.fCBM_RICH_Gas_TT_2 = ((tdcData << 16) & 0xffff) / 128.; - } else if (i == 35) { // 31 - ed.fCBM_RICH_Gas_PT_4 = (tdcData & 0xffff) / 16384.; - ed.fCBM_RICH_Gas_FM_1 = ((tdcData << 16) & 0xffff) / 512.; - } else if (i == 36) { // 32 - ed.fCBM_RICH_Gas_RefrIndex = tdcData / 128.0e6; - } else if (i == 37) { // 33 - ed.fPadiwaThresholdOffset = (tdcData & 0xffff) - 32768; - } - //ed.Print(); - }// -} - -CbmTrbOutputHit* CbmRichTrbUnpack::CreateOutputHit(CbmTrbRawHit* h) -{ - Double_t lFullTime = this->GetFullTime(h->GetTdc(), h->GetLChannel(), h->GetLEpoch(), h->GetLCTime(), h->GetLFTime()); - Double_t tFullTime = this->GetFullTime(h->GetTdc(), h->GetTChannel(), h->GetTEpoch(), h->GetTCTime(), h->GetTFTime()); - return new CbmTrbOutputHit(h->GetTdc(), h->GetLChannel(), lFullTime, h->GetTChannel(), tFullTime); -} - -Double_t CbmRichTrbUnpack::GetFullTime(UShort_t TDC, UShort_t CH, UInt_t epoch, UShort_t coarseTime, UShort_t fineTime) -{ - Double_t coarseUnit = 5.; - Double_t epochUnit = coarseUnit * 0x800; - // UInt_t trb_index = (TDC >> 4) & 0x00FF - 1; - // UInt_t tdc_index = (TDC & 0x000F); - Double_t time = epoch * epochUnit + coarseTime * coarseUnit - CbmTrbCalibrator::Instance()->GetFineTimeCalibrated(TDC, CH, fineTime); - - if (CH != 0){ - if (fSynchOffsetTimeMap[TDC] > 150) { - LOG(error) << "CbmRichTrbUnpack::GetFullTime Synch Offset" << fSynchOffsetTimeMap[TDC] << "ns > 150 ns for TDC" << std::hex << TDC << std::dec; - } else { - time = time + fSynchOffsetTimeMap[TDC]; - } - } - - return time; -} - -void CbmRichTrbUnpack::CreateOutputHits() -{ - Int_t nofRichHits = fRawRichHits.size(); - fOutputRichHits.resize(nofRichHits); - for (int i = 0; i < nofRichHits; i++){ - fOutputRichHits[i] = CreateOutputHit(fRawRichHits[i]); - } - - Int_t nofRefHits = fRawEventTimeHits.size(); - fOutputEventTimeHits.resize(nofRefHits); - for (Int_t i = 0; i < nofRefHits; i++) { - fOutputEventTimeHits[i] = CreateOutputHit(fRawEventTimeHits[i]); - } - - if (fUseFingerSci) { - Int_t nofFingSciHits = fRawFingerSciHits.size(); - fOutputFingerSciHits.resize(nofFingSciHits); - for (Int_t i = 0; i < nofFingSciHits; i++) { - fOutputFingerSciHits[i] = CreateOutputHit(fRawFingerSciHits[i]); - } - std::sort(fOutputFingerSciHits.begin(), fOutputFingerSciHits.end(), CbmTrbOutputHitLeadingFullTimeComparatorLess()); - } - - - std::sort(fOutputRichHits.begin(), fOutputRichHits.end(), CbmTrbOutputHitLeadingFullTimeComparatorLess()); -} - -void CbmRichTrbUnpack::BuildEvent(Int_t refHitIndex) -{ - CbmRichTrbParam* param = CbmRichTrbParam::Instance(); - Int_t indmin, indmax; - Double_t eventTime = fOutputEventTimeHits[refHitIndex]->GetLFullTime(); - - // check finger-scintillator for event triggering - if (fUseFingerSci) { - FindMinMaxIndex(eventTime, EVENT_TIME_WINDOW, fOutputFingerSciHits,&indmin, &indmax); - Int_t size = indmax - indmin + 1; - if (size == 0){ - return; - } else { - CbmTrbOutputHit* h = fOutputFingerSciHits[indmin]; - fhDiffFingerSciTimeEventTimeAll->Fill(eventTime - h->GetLFullTime()); - } - } - - FindMinMaxIndex(eventTime, EVENT_TIME_WINDOW, fOutputRichHits,&indmin, &indmax); - // Int_t size = indmax - indmin + 1; - UInt_t nofHitsTrb[TRB_TDC3_NUMBOARDS]; - for (UInt_t i = 0; i < TRB_TDC3_NUMBOARDS; i++) { - nofHitsTrb[i] = 0; - } - for (Int_t iH = indmin; iH <= indmax; iH++) { - CbmTrbOutputHit* h = fOutputRichHits[iH]; - CbmRichHitInfo* data = param->GetRichHitInfo(h->GetTdc(), h->GetLChannel()); - - UShort_t trbInd = ( (h->GetTdc() >> 4) & 0x00FF ) - 1; - nofHitsTrb[trbInd]++; - - AddRichHitToOutputArray(trbInd, data); - - fhDiffHitTimeEventTimeAll->Fill(eventTime - h->GetLFullTime()); - - //UShort_t trbInd = ( (h->GetTrb() >> 4) & 0x00FF ) - 1; - UShort_t tdcInd = (h->GetTdc() & 0x000F); - fhDiffHitTimeEventTime[trbInd][tdcInd]->Fill(eventTime - h->GetLFullTime()); - - LOG(debug2) << data->GetX() << " " << data->GetY(); - LOG(debug2) <<fixed << iH << " " << hex << h->GetTdc() << dec << " " << h->GetLChannel() << " " << h->GetLFullTime(); - } - - for (UInt_t i = 0; i < TRB_TDC3_NUMBOARDS - 1; i++) { - fhNofRichHitsVsTrbNum->Fill(i+1, nofHitsTrb[i]); - } -} - -void CbmRichTrbUnpack::AddRichHitToOutputArray(UShort_t /*trbId*/, CbmRichHitInfo* hitInfo) -{ - UInt_t counter1 = fRichHits->GetEntries(); - new((*fRichHits)[counter1]) CbmRichHit(); - CbmRichHit* hit = static_cast<CbmRichHit*>(fRichHits->At(counter1)); - hit->SetX(hitInfo->GetX()); - hit->SetY(hitInfo->GetY()); - hit->SetPmtId(hitInfo->GetPmtNum()); - - UInt_t counter2 = fRichHitInfos->GetEntries(); - new((*fRichHitInfos)[counter2]) CbmRichHitInfo(); - CbmRichHitInfo* newHitInfo = static_cast<CbmRichHitInfo*>(fRichHitInfos->At(counter2)); - newHitInfo->Copy(hitInfo); - - if (fRichHits->GetEntries() != fRichHitInfos->GetEntries()){ - LOG(error) << "CbmRichTrbUnpack::AddRichHitToOutputArray: fRichHits->Entries() =" << - fRichHits->GetEntries() << "NOT EQUAL fRichHitInfos->Entries() = " << fRichHitInfos->GetEntries(); - } -} - -void CbmRichTrbUnpack::FindMinMaxIndex( - Double_t refTime, - Double_t windowT, - vector<CbmTrbOutputHit*>& hits, - Int_t *indmin, - Int_t *indmax) -{ - Double_t windowTime = 0.5 * windowT; - CbmTrbOutputHit* mpnt = new CbmTrbOutputHit(); - vector<CbmTrbOutputHit*>::iterator itmin, itmax; - - mpnt->SetLeadingFullTime(refTime - windowTime); - itmin = std::lower_bound(hits.begin(), hits.end(), mpnt, CbmTrbOutputHitLeadingFullTimeComparatorLess()); - - mpnt->SetLeadingFullTime(refTime + windowTime); - itmax = std::lower_bound(hits.begin(), hits.end(), mpnt, CbmTrbOutputHitLeadingFullTimeComparatorLess()) - 1; - - *indmin = itmin - hits.begin(); - *indmax = itmax - hits.begin(); -} - -void CbmRichTrbUnpack::ClearAllBuffers() -{ - for (UInt_t i = 0; i < fRawRichHits.size(); i++) { - delete fRawRichHits[i]; - } - fRawRichHits.clear(); - - for (UInt_t i = 0; i < fRawEventTimeHits.size(); i++) { - delete fRawEventTimeHits[i]; - } - fRawEventTimeHits.clear(); - - for (UInt_t i = 0; i < fRawFingerSciHits.size(); i++) { - delete fRawFingerSciHits[i]; - } - fRawFingerSciHits.clear(); - - for (UInt_t i = 0; i < fOutputRichHits.size(); i++) { - delete fOutputRichHits[i]; - } - fOutputRichHits.clear(); - - for (UInt_t i = 0; i < fOutputEventTimeHits.size(); i++) { - delete fOutputEventTimeHits[i]; - } - fOutputEventTimeHits.clear(); - - for (UInt_t i = 0; i < fOutputFingerSciHits.size(); i++) { - delete fOutputFingerSciHits[i]; - } - fOutputFingerSciHits.clear(); -} - -void CbmRichTrbUnpack::FillRawHitHist(CbmTrbRawHit* rh) -{ - UShort_t trbInd = ( (rh->GetTdc() >> 4) & 0x00FF ) - 1; - UShort_t tdcInd = (rh->GetTdc() & 0x000F); - - fhChannelEntries[trbInd][tdcInd]->Fill(rh->GetLChannel()); - fhChannelEntries[trbInd][tdcInd]->Fill(rh->GetTChannel()); - fhEpoch[trbInd][tdcInd]->Fill(rh->GetLEpoch()); - fhEpoch[trbInd][tdcInd]->Fill(rh->GetTEpoch()); - fhCoarseTime[trbInd][tdcInd]->Fill(rh->GetLCTime()); - fhCoarseTime[trbInd][tdcInd]->Fill(rh->GetTCTime()); - fhFineTime[trbInd][tdcInd]->Fill(rh->GetLFTime()); - fhFineTime[trbInd][tdcInd]->Fill(rh->GetTFTime()); -} - -void CbmRichTrbUnpack::FillOutputHitHist(CbmTrbOutputHit* outHit) -{ - UShort_t trbInd = ( (outHit->GetTdc() >> 4) & 0x00FF ) - 1; - UShort_t tdcInd = (outHit->GetTdc() & 0x000F); - fhDeltaT[trbInd][tdcInd]->Fill(outHit->GetDeltaT()); -} - -void CbmRichTrbUnpack::CreateAndDrawQa() -{ - LOG(info) << "Number of raw RICH hits = " << fRawRichHits.size(); - LOG(info) << "Number of output RICH hits = " << fOutputRichHits.size(); - LOG(info) << "Number of raw reference time hits = " << fRawEventTimeHits.size(); - LOG(info) << "Number of output reference time hits = " << fOutputEventTimeHits.size(); - LOG(info) << "Number of raw finger-sci hits = " << fRawFingerSciHits.size(); - LOG(info) << "Number of output finger-sci hits = " << fOutputFingerSciHits.size(); - LOG(info) << "Number of hits with one edge = " << fNofHitsWithOneEdge << ", " << 100. * fNofHitsWithOneEdge / fRawRichHits.size() << "%"; - LOG(info) << "Number of raw HLD events = " << fNofRawEvents; - LOG(info) << "Number of raw HLD sub events = " << fNofRawSubEvents; - LOG(info) << "Number of time data messages = " << fNofTimeDataMessages; - - TString hname, htitle; - for (Int_t iTrb = 0; iTrb < TRB_TDC3_NUMBOARDS; iTrb++){ - for (Int_t iTdc = 0; iTdc < TRB_TDC3_NUMTDC; iTdc++){ - hname.Form("hChannelEntries_%d_%d", iTrb+1, iTdc); - htitle.Form("hChannelEntries_%d_%d;Channel number;Entries", iTrb+1, iTdc); - fhChannelEntries[iTrb][iTdc] = new TH1D( hname.Data(), htitle.Data(), 33, -0.5, 32.5); - - hname.Form("hEpoch_%d_%d", iTrb+1, iTdc); - htitle.Form("hEpoch_%d_%d;Epoch counter;Entries", iTrb+1, iTdc); - fhEpoch[iTrb][iTdc] = new TH1D(hname, htitle, 1000, 0, 0); - - hname.Form("hCoraseTime_%d_%d", iTrb+1, iTdc); - htitle.Form("hCoraseTime_%d_%d;Coarse time;Entries", iTrb+1, iTdc); - fhCoarseTime[iTrb][iTdc] = new TH1D(hname, htitle, 2048, -0.5, 2047.5); - - hname.Form("hFineTime_%d_%d", iTrb+1, iTdc); - htitle.Form("hFineTime_%d_%d;Fine time;Entries", iTrb+1, iTdc); - fhFineTime[iTrb][iTdc] = new TH1D(hname, htitle, 1024, -0.5, 1023.5); - - hname.Form("hDeltaT_%d_%d", iTrb+1, iTdc); - htitle.Form("hDeltaT_%d_%d;DeltaT [ns];Entries", iTrb+1, iTdc); - fhDeltaT[iTrb][iTdc] = new TH1D(hname, htitle, 200, -20, 40); - } - } - - for (unsigned int i = 0; i < fRawRichHits.size(); i++) { - FillRawHitHist(fRawRichHits[i]); - } - - for (unsigned int i = 0; i < fOutputRichHits.size(); i++) { - FillOutputHitHist(fOutputRichHits[i]); - } - - TFolder* rootHistFolder = gROOT->GetRootFolder()->AddFolder("rich_trb_unpack_debug", "rich_trb_unpack_debug"); - TString cname; - for (Int_t iTrb = 0; iTrb < TRB_TDC3_NUMBOARDS; iTrb++){ - cname.Form("rich_trb_unpack_debug_trb%d", iTrb+1); - TCanvas* c = new TCanvas(cname.Data(), cname.Data(), 1500, 1000); - c->Divide(6, TRB_TDC3_NUMTDC); - for (Int_t iTdc = 0; iTdc < TRB_TDC3_NUMTDC; iTdc++) - { - c->cd(6*iTdc + 1); - DrawH1(fhChannelEntries[iTrb][iTdc]); - c->cd(6*iTdc + 2); - DrawH1(fhEpoch[iTrb][iTdc]); - c->cd(6*iTdc + 3); - DrawH1(fhCoarseTime[iTrb][iTdc]); - c->cd(6*iTdc + 4); - DrawH1(fhFineTime[iTrb][iTdc]); - c->cd(6*iTdc + 5); - DrawH1(fhDeltaT[iTrb][iTdc], kLinear, kLog); - c->cd(6*iTdc + 6); - DrawH1(fhDiffHitTimeEventTime[iTrb][iTdc], kLinear, kLog); - - //rootHistFolder->Add(c); - - //rootHistFolder->Add(fhChannelEntries[iTrb][iTdc]); - //rootHistFolder->Add(fhEpoch[iTrb][iTdc]); - //rootHistFolder->Add(fhCoarseTime[iTrb][iTdc]); - //rootHistFolder->Add(fhFineTime[iTrb][iTdc]); - rootHistFolder->Add(fhDeltaT[iTrb][iTdc]); - - } - } - - new TCanvas("rich_trb_unpack_debug_rich_hits_vs_trb_num", "rich_trb_unpack_debug_rich_hits_vs_trb_num", 1200, 800); - DrawH2(fhNofRichHitsVsTrbNum); - - new TCanvas("rich_trb_unpack_debug_diff_hittime_eventtime", "rich_trb_unpack_debug_diff_hittime_eventtime", 800, 800); - DrawH1(fhDiffHitTimeEventTimeAll); - - if (fUseFingerSci){ - new TCanvas("rich_trb_unpack_debug_diff_fingerscitime_eventtime", "rich_trb_unpack_debug_diff_fingerscitime_eventtime", 800, 800); - DrawH1(fhDiffFingerSciTimeEventTimeAll, kLinear, kLog); - } - - rootHistFolder->Add(fhNofRichHitsVsTrbNum); - rootHistFolder->Add(fhDiffHitTimeEventTimeAll); - rootHistFolder->Write(); -} - -void CbmRichTrbUnpack::CreateAndDrawEventBuildDisplay() -{ - Double_t minT = fOutputEventTimeHits[0]->GetLFullTime(); - Double_t maxT = fOutputEventTimeHits[ fOutputEventTimeHits.size() - 1 ]->GetLFullTime(); - TH1D* hRefTime = new TH1D("hRefTime", "hRefTime;Time [ns];Entries", 10000, 0., maxT - minT); - TH1D* hHitTime = new TH1D("hHitTime", "hHitTime;Time [ns];Entries", 10000, 0., maxT - minT); - TH1D* hDiffRefTime = new TH1D("hDiffRefTime", "hDiffRefTime;dT [ns];Entries", 2000, -10., 200000); - std::sort(fOutputEventTimeHits.begin(), fOutputEventTimeHits.end(), CbmTrbOutputHitLeadingFullTimeComparatorLess()); - for (unsigned int i = 0; i < fOutputEventTimeHits.size(); i++) { - hRefTime->Fill(fOutputEventTimeHits[i]->GetLFullTime() - minT); - - if (i != 0) hDiffRefTime->Fill( fOutputEventTimeHits[i]->GetLFullTime() - fOutputEventTimeHits[i-1]->GetLFullTime() ); - } - for (unsigned int i = 0; i < fOutputRichHits.size(); i++) { - hHitTime->Fill(fOutputRichHits[i]->GetLFullTime() - minT); - } - - new TCanvas("rich_trb_unpack_debug_ref_time", "rich_trb_unpack_debug_ref_time", 1600, 600); - DrawH1(hRefTime); - new TCanvas("rich_trb_unpack_debug_rich_hit_time", "rich_trb_unpack_debug_rich_hit_time", 1600, 600); - DrawH1(hHitTime); - new TCanvas("rich_trb_unpack_debug_delta_ref_time", "rich_trb_unpack_debug_delta_ref_time", 800, 800); - DrawH1(hDiffRefTime); -} - -ClassImp(CbmRichTrbUnpack) diff --git a/beamtime/rich/CbmRichTrbUnpack.h b/beamtime/rich/CbmRichTrbUnpack.h deleted file mode 100644 index 8bc60a596b39937b4425ab3fdd7134a045bb35f3..0000000000000000000000000000000000000000 --- a/beamtime/rich/CbmRichTrbUnpack.h +++ /dev/null @@ -1,246 +0,0 @@ -#ifndef CBMRICHTRBUNPACK_H -#define CBMRICHTRBUNPACK_H - -#include "CbmRichTrbDefines.h" - -#include <TString.h> -#include "FairSource.h" -#include <vector> -#include <map> - -using namespace std; - -class CbmRichHitInfo; -class CbmRawSubEvent; -class CbmTrbRawHit; -class CbmTrbOutputHit; -class TClonesArray; -class TH1D; -class TH2D; - -enum CbmRichAnaTypeEnum{ - kCbmRichBeamEvent, - kCbmRichLaserPulserEvent, - kCbmRichLedPulserEvent -}; - -class CbmRichTrbUnpack : public FairSource -{ -public: - /* - * Constructor. - * \param[in] hldFileName File name of input HLD file. - */ - CbmRichTrbUnpack(TString hldFileName); - - /* - * Destructor. - */ - virtual ~CbmRichTrbUnpack(); - - /* - * Inherited from FairSource. - */ - Bool_t Init(); - - /* - * Inherited from FairSource. - */ - Int_t ReadEvent(UInt_t); - - Source_Type GetSourceType() {return kONLINE;} - - virtual void SetParUnpackers() {;} - - virtual Bool_t InitUnpackers() {return kTRUE;} - - virtual Bool_t ReInitUnpackers() {return kTRUE;} - - - /* - * Inherited from FairSource. - */ - void Close(); - - /* - * Inherited from FairSource. - */ - void Reset(); - - /* - * Set what you want to analyze. - */ - void SetAnaType(CbmRichAnaTypeEnum type){fAnaType = type;} - - /* - * If TRUE histograms are drawn. - */ - void SetDrawHist(Bool_t b){fDrawHist = b;} - - /* - * Set to true if you wan to use finger-scintillator for event triggering - */ - void SetUseFingerSci(Bool_t b) {fUseFingerSci = b;} - -private: - TString fHldFileName; // file name of HLD file - - TClonesArray* fRichHits; // output array of RICH hits - TClonesArray* fRichHitInfos; // output array of CbmRichHitInfo hits - - Char_t* fDataPointer; // pointer to data - UInt_t fDataSize; // size of data - UInt_t fEventNum; // current event number - UInt_t fNofHitsWithOneEdge; // number of hits With one edge (leading or trailing) - UInt_t fNofRawEvents; // number of raw HLD events - UInt_t fNofRawSubEvents; // number of raw HLD sub events - UInt_t fNofTimeDataMessages;// number of time data messages - - Double_t fSynchRefTime; // Reference time for synchronization - map<UInt_t, Double_t> fSynchOffsetTimeMap; // first - TDCId, second - time offeset in ns - - vector<CbmTrbRawHit*> fRawRichHits; // raw hit from PMTs - vector<CbmTrbRawHit*> fRawEventTimeHits; // raw hits from reference time TDC - vector<CbmTrbRawHit*> fRawFingerSciHits; // fUseFingerSciTrigger must be true, RAW hits from finger-scintillator - - vector<CbmTrbOutputHit*> fOutputRichHits; // output hits from PMTs - vector<CbmTrbOutputHit*> fOutputEventTimeHits; // output hits from reference time TDC - vector<CbmTrbOutputHit*> fOutputFingerSciHits; // fUseFingerSciTrigger must be true, hits from finger-scintillator - - // Debug histograms - TH1D* fhChannelEntries[TRB_TDC3_NUMBOARDS][TRB_TDC3_NUMTDC]; - TH1D* fhEpoch[TRB_TDC3_NUMBOARDS][TRB_TDC3_NUMTDC]; - TH1D* fhCoarseTime[TRB_TDC3_NUMBOARDS][TRB_TDC3_NUMTDC]; - TH1D* fhFineTime[TRB_TDC3_NUMBOARDS][TRB_TDC3_NUMTDC]; - TH1D* fhDeltaT[TRB_TDC3_NUMBOARDS][TRB_TDC3_NUMTDC]; - TH1D* fhDiffHitTimeEventTime[TRB_TDC3_NUMBOARDS][TRB_TDC3_NUMTDC]; // Difference between reference event time and RICH hit time - TH2D* fhNofRichHitsVsTrbNum; // Number of RICH hit per event vs. TRB number (only real event count) - TH1D* fhDiffHitTimeEventTimeAll; // Difference between reference event time and RICH hit time - TH1D* fhDiffFingerSciTimeEventTimeAll; // Difference between finger-sci time and reference time hit - - CbmRichAnaTypeEnum fAnaType; // What do you want to analyza beam events, laser events, led events - Bool_t fUseFingerSci; //If you want to use finger-scintillator behind the rich box as a trigger for event building - - Bool_t fDrawHist; // if TRUE histograms wre drawn - - /* - * Read full input file to memory. - */ - void ReadInputFileToMemory(); - - /* - * Add CbmRichHit to the output TClonesArray. - * \param x X coordinate of the hit - * \param y Y coordinate of the hit - */ - void AddRichHitToOutputArray(UShort_t trbId, CbmRichHitInfo* hitInfo); - - /* - * Read all events and create output hits - */ - void ReadEvents(); - - /* - * Process TDC message for subevent - * \param subEvent Poiner to subEvent - */ - void ProcessTdc( - CbmRawSubEvent* subEvent); - /* - * Decode TDC data. - * \param data Array of TDC data words. - * \param size Number of words. - * \param trbId TRB ID. - * \param tdcId TDC ID. - */ - void DecodeTdcData( - UInt_t* data, - UInt_t size, - UInt_t trbId, - UInt_t tdcId); - - /* - * Decode EPICS data. - * \param data Array of TDC data words. - * \param size Number of words. - */ - void DecodeEpicsData( - UInt_t* data, - UInt_t size); - - /* - * Create CbmTrbOutputHits from Raw hits - */ - void CreateOutputHits(); - - /* - * Create CbmRichTrbOutputHit out of CbmTrbRawHit. - */ - CbmTrbOutputHit* CreateOutputHit( - CbmTrbRawHit* rawHit); - - /* - * Build event (create CbmRichHits) for the specified reference time hit. - * \param refHitIndex Index of reference time hit. - */ - void BuildEvent( - Int_t refHitIndex); - - /* - * Find min and max indecies of the time corridor in the output CbmRichTrbOutputHit array sorted by time. - * \param x0 Reference time. - * \param windowT Time window in ns. - * \param[in] hits array of hits - * \param[out] indmin Min index. - * \param[out] indmax Max index. - */ - void FindMinMaxIndex( - Double_t x0, - Double_t windowT, - vector<CbmTrbOutputHit*>& hits, - Int_t *indmin, - Int_t *indmax); - - /* - * Clear all buffers and used memory. - */ - void ClearAllBuffers(); - - /* - * Return time in ns. - */ - Double_t GetFullTime( - UShort_t TDC, - UShort_t CH, - UInt_t epoch, - UShort_t coarseTime, - UShort_t fineTime); - - /* - * Create and draw debug histogramms. - */ - void CreateAndDrawQa(); - - /* - * Fill histograms with CbmTrbRawHit data - */ - void FillRawHitHist(CbmTrbRawHit* rh); - - /* - * Fill histograms with CbmTrbOutputHit data - */ - void FillOutputHitHist(CbmTrbOutputHit* outHit); - - /* - * Create and draw event display for event building. - */ - void CreateAndDrawEventBuildDisplay(); - - - CbmRichTrbUnpack(const CbmRichTrbUnpack&); - CbmRichTrbUnpack operator=(const CbmRichTrbUnpack&); - - ClassDef(CbmRichTrbUnpack,1) -}; - -#endif diff --git a/beamtime/rich/CbmRichTrbUnpack2.cxx b/beamtime/rich/CbmRichTrbUnpack2.cxx deleted file mode 100644 index 8fb6a6101658437fff45bdd27b28fe3d635d9b1d..0000000000000000000000000000000000000000 --- a/beamtime/rich/CbmRichTrbUnpack2.cxx +++ /dev/null @@ -1,639 +0,0 @@ -#include "CbmRichTrbUnpack2.h" - -//TODO check which headers are really needed - -#include <iostream> -#include <map> - -#include <TClonesArray.h> -#include <TFile.h> - -#include "FairLogger.h" -#include "FairRootManager.h" - -#include "CbmTrbIterator.h" -#include "CbmTrbCalibrator.h" -#include "CbmRichTrbParam.h" -#include "CbmRawEvent.h" - -// Uncomment if you want to have excessive printout (do not execute on many events, may produce Gb's of output) -//#define DEBUGPRINT - -#define EVENTBUFMIN 200 -#define EVENTBUFLIMIT 500 - -CbmRichTrbUnpack2::CbmRichTrbUnpack2() : - FairSource(), - fOutHistoFile(), - fHldFiles(), - fNofRawEvents(0), - fMaxNofRawEvents(2000000000), - fTimestampsUnpacked(0), - fTimestampsNotUnpacked(0), - fSyncTimestampsUnpacked(0), - fSkippedTimestamps(0), - fPushedTimestamps(0), - fDataPointer(NULL), - fDataSize(0), - fTrbIter(NULL), - fNumPushed(0), - fLastSyncTime(0.), - fMainSyncTime(0.), - fCorr(0.), - fMainSyncDefined(kFALSE), - fHM(NULL), - fMessageBuffer(), - fEventStack(), - inGarbCollMode(kFALSE), - inFinalCleanup(kFALSE), - fCurNeventsInBuf(), - fTrbRawHits(new TClonesArray("CbmTrbRawMessage", 10)) -{ -} - -CbmRichTrbUnpack2::CbmRichTrbUnpack2(TString hldFileName) : - FairSource(), - fOutHistoFile(), - fHldFiles(), - fNofRawEvents(0), - fMaxNofRawEvents(2000000000), - fTimestampsUnpacked(0), - fTimestampsNotUnpacked(0), - fSyncTimestampsUnpacked(0), - fSkippedTimestamps(0), - fPushedTimestamps(0), - fDataPointer(NULL), - fDataSize(0), - fTrbIter(NULL), - fNumPushed(0), - fLastSyncTime(0.), - fMainSyncTime(0.), - fCorr(0.), - fMainSyncDefined(kFALSE), - fHM(NULL), - fMessageBuffer(), - fEventStack(), - inGarbCollMode(kFALSE), - inFinalCleanup(kFALSE), - fCurNeventsInBuf(), - fTrbRawHits(new TClonesArray("CbmTrbRawMessage", 10)) -{ - fHldFiles.push_back(hldFileName); -} - -CbmRichTrbUnpack2::~CbmRichTrbUnpack2() -{ -} - -Bool_t CbmRichTrbUnpack2::Init() -{ - LOG(info) << "CbmRichTrbUnpack::Init()"; - - FairRootManager* ioman = FairRootManager::Instance(); - if (ioman == NULL) { - LOG(fatal) << "No FairRootManager instance"; - } - ioman->Register("CbmTrbRawMessage", "TRB raw messages", fTrbRawHits, kTRUE); - - fHM = new CbmHistManager(); - - fHM->Create1<TH1D>("fMessagesInTDC", "Total number of messages in TDC", 64, 0., 64.); - fHM->Create1<TH1D>("fMessagesInChannel", "Total number of messages in channel", 2118, 0., 2118.); // should be 2112 - fHM->Create2<TH2D>("fHeatMapLeadingEdges", "Heat map built by leading edges", 32, 0., 32., 32, 0., 32.); - - // Read the first file - ReadNextInputFileToMemory(); - - return kTRUE; -} - -void CbmRichTrbUnpack2::Close() -{ - /* - if (!fMessageBuffer.empty()) { - printf ("Leftovers in the buffer:\n"); - for (auto iter : fMessageBuffer) - { - printf ("%f\n", this->GetFullTime(*iter.second)); - } - } - */ - - LOG(info) << "[CbmRichTrbUnpack2] left in the event building buffer: " << fMessageBuffer.size(); - - LOG(info) << "[CbmRichTrbUnpack2] Total " << fTimestampsUnpacked-fTimestampsNotUnpacked-fSyncTimestampsUnpacked-fSkippedTimestamps - << " timestamps unpacked not incl. " << fSyncTimestampsUnpacked - << " sync messages and not incl. " << fSkippedTimestamps - << " skipped (noise) messages and not incl. " << fTimestampsNotUnpacked - << " with fine time counter error."; - LOG(info) << "[CbmRichTrbUnpack2] Total " << fPushedTimestamps << " pushed messages."; - - TFile* curHistoFile = new TFile(fOutHistoFile, "UPDATE"); - LOG(info) << "Opening file " << fOutHistoFile << " for histograms"; - fHM->WriteToFile(); - curHistoFile->Close(); - -} - -void CbmRichTrbUnpack2::Reset() -{ - fTrbRawHits->Clear(); -} - -UInt_t CbmRichTrbUnpack2::ReadNextInputFileToMemory() -{ - if (fHldFiles.size() > 0) { - TString hldFileName = fHldFiles.front(); - fHldFiles.pop_front(); - - std::streampos size; - std::ifstream file (hldFileName.Data(), std::ios::in | std::ios::binary | std::ios::ate); - if (file.is_open()) { - size = file.tellg(); - - if (fDataPointer) - delete [] fDataPointer; - fDataPointer = new Char_t[size]; - - file.seekg (0, std::ios::beg); - file.read (fDataPointer, size); - file.close(); - LOG(info) << "The entire file " << hldFileName << " content is in memory (" << size / (1024 * 1024) << " MB)"; - } else { - LOG(fatal) << "Unable to open file " << hldFileName; - } - fDataSize = (UInt_t) size; - - if (fTrbIter) - delete fTrbIter; - fTrbIter = new CbmTrbIterator((void*) fDataPointer, fDataSize); - - return 0; // There is data available - } else { - if (fDataPointer) - delete [] fDataPointer; - if (fTrbIter) - delete fTrbIter; - return 1; // no more data - } -} - -// Read one raw 'event' into the buffer -Int_t CbmRichTrbUnpack2::ReadOneRawEvent() -{ - // Try to extract next event from the Iterator. If no events left - go out of the loop - - CbmRawEvent* rawEvent = fTrbIter->NextEvent(); - if (rawEvent == NULL) { // no more data - if (this->ReadNextInputFileToMemory() == 1) { - return 1; - } else { - rawEvent = fTrbIter->NextEvent(); - } - } - -// if (rawEvent->Size() > 8000) continue; // TODO uncomment? - - // End run if exceed the limit of total number of raw hits - if (fNofRawEvents >= fMaxNofRawEvents) - return 1; // no more data - - if (fNofRawEvents % 1000 == 0) - LOG(info) << "Raw event # " << fNofRawEvents/1000 << "k" << "---------------------------------------------------"; - -#ifdef DEBUGPRINT - //rawEvent->PrintTime(); - rawEvent->Print(); -#endif - - // Loop over subevents - while (true) { - CbmRawSubEvent* rawSubEvent = fTrbIter->NextSubEvent(); - if (rawSubEvent == NULL) - break; -#ifdef DEBUGPRINT - rawSubEvent->PrintHeaderOnly(); // PrintHeaderOnly() or Print() -#endif - ProcessSubEvent(rawSubEvent); - - } - - fNofRawEvents++; - - return 0; // still some data -} - -// Actually not _read_ event but produce (build) one event from the buffer of raw events -Int_t CbmRichTrbUnpack2::ReadEvent(UInt_t) -{ - // This shit is quite complicated... - // So, there are two modes - standard and "garbage collation" - // In standard mode we fill the buffer with the edges until - // there are at least EVENTBUFMIN recognisable events. - // Then we flush first event to the output. - // Next time when CbmRoot calls this method we will already - // have EVENTBUFMIN-1 events in the buffer. It will be again - // filled up. Then at some moment the number of event in the buffer - // may get quite high (EVENTBUFLIMIT) - we switch to "garbage - // collection" mode. In this mode we don't read any more data but - // simply flush event by event from the front of the buffer until - // the number of event in the buffer is again EVENTBUFMIN. - // Then, of cause, switch back to standard mode. - // Additional to that at some moment the source of edges - // may get empty. In this case we flush everything. - - Int_t goOn; - - std::multimap<Double_t, CbmTrbRawMessage*>::iterator iter; - std::multimap<Double_t, CbmTrbRawMessage*>::iterator curFirst; - Double_t winLeft, winRight; - - // Standard mode - if (!inGarbCollMode) - { - - UInt_t eventInd = 0; - - // Fill the buffer - do { - // Per-se read the "DAQ-event" - goOn = this->ReadOneRawEvent(); - - if (!fMessageBuffer.empty()) { - eventInd = 0; - - // Start the first event with the first edge in the buffer - curFirst = fMessageBuffer.begin(); - winLeft = this->GetFullTime(*curFirst->second); - winRight = winLeft + EVENTTIMEWINDOW; - - // Loop over the rest of the edges - for (iter = fMessageBuffer.begin(); iter != fMessageBuffer.end(); ++iter) { - - // Switch to next event. - // Here we count the number of events in the buffer - // The problem is that reading next "DAQ-event" - // not necessarily adds real event - it may add some edges - // to any existing event - still in the buffer (or already flushed). - if (this->GetFullTime(*iter->second) > winRight) { - curFirst = iter; - winLeft = this->GetFullTime(*curFirst->second); - winRight = winLeft + EVENTTIMEWINDOW; - eventInd++; - } - - //printf ("%d: tdc 0x%04x ch %d\t%f\n", eventInd, iter->second->GetSourceAddress(), iter->second->GetChannelID(), this->GetFullTime(*iter->second)); - - } - } - } while (goOn != 1 && eventInd < EVENTBUFMIN-1); - - //printf ("eventInd=%d\n", eventInd); - - // There are no more edges in the source - go to the third mode - cleanup - if (goOn == 1) { - inGarbCollMode = kTRUE; - fCurNeventsInBuf = eventInd+1; - inFinalCleanup = kTRUE; - printf ("inFinalCleanup = kTRUE\n"); - return 0; - } else { - curFirst = fMessageBuffer.begin(); - winLeft = this->GetFullTime(*curFirst->second); - winRight = winLeft + EVENTTIMEWINDOW; - for (iter = fMessageBuffer.begin(); iter != fMessageBuffer.end(); ++iter) { - - // switch to next event - if (this->GetFullTime(*iter->second) > winRight) { - this->PushEvent(fMessageBuffer.begin(), iter); - break; - } - - } - - // Switch to garbage collection mode - if (eventInd > EVENTBUFLIMIT || goOn == 1) { - inGarbCollMode = kTRUE; - fCurNeventsInBuf = eventInd+1; - return 0; - } - } - - } else { - // "Garbage collection" mode - curFirst = fMessageBuffer.begin(); - winLeft = this->GetFullTime(*curFirst->second); - winRight = winLeft + EVENTTIMEWINDOW; - //printf ("Garbage collection\twinLeft=%f\tfMessageBuffer size: %d\n", winLeft, fMessageBuffer.size()); - for (iter = fMessageBuffer.begin(); iter != fMessageBuffer.end(); ++iter) { - - if (this->GetFullTime(*iter->second) > winRight) { - this->PushEvent(fMessageBuffer.begin(), iter); - //printf ("fCurNeventsInBuf-- = %d--\n", fCurNeventsInBuf); - fCurNeventsInBuf--; - if (!inFinalCleanup && fCurNeventsInBuf == EVENTBUFMIN) - { - inGarbCollMode = kFALSE; - return 0; - } - //if ( inFinalCleanup && fCurNeventsInBuf == 0) return 1; - return 0; - - } - } - - // Very end comes here - this->PushEvent(fMessageBuffer.begin(), fMessageBuffer.end()); - return 1; - } - - return goOn; // 0 - still some data, 1 - no more events -} - -void CbmRichTrbUnpack2::PushEvent(std::multimap<Double_t, CbmTrbRawMessage*>::iterator firstEdge, - std::multimap<Double_t, CbmTrbRawMessage*>::iterator lastEdge) -{ - std::multimap<Double_t, CbmTrbRawMessage*>::iterator iter; - Int_t ind; - Int_t counter=0; - for (iter = firstEdge; iter != lastEdge; iter++) - { - counter++; - } - - // Here we skip single-hit events - if (counter > 0) { - for (iter = firstEdge; iter != lastEdge; /**/) - { -#ifdef DEBUGPRINT - //if (iter->second->GetSourceAddress() == 0x0110 || - // iter->second->GetSourceAddress() == 0x0111) - { - printf ("Pushing: tdc 0x%04x ch %d\t%f\n", iter->second->GetSourceAddress(), iter->second->GetChannelID(), this->GetFullTime(*iter->second)); - } -#endif - - ind = fTrbRawHits->GetEntriesFast(); - new ((*fTrbRawHits)[ind]) CbmTrbRawMessage(); - static_cast<CbmTrbRawMessage*>(fTrbRawHits->At(ind))->CopyMessage(iter->second); - - fPushedTimestamps++; - - fMessageBuffer.erase(iter++); - } - - fNumPushed++; - //LOG(info) << "Pushed " << fNumPushed << " events"; - } else { - for (iter = firstEdge; iter != lastEdge; /**/) - { -#ifdef DEBUGPRINT - printf ("Skipping(erasing): %f\n", this->GetFullTime(*iter->second)); -#endif - fSkippedTimestamps++; - fMessageBuffer.erase(iter++); - } - } - -/* - LOG(info) << "[CbmRichTrbUnpack2] Total " << fTimestampsUnpacked-fTimestampsNotUnpacked << " timestamps unpacked (not incl. " - << fTimestampsNotUnpacked << " with fine time counter error)."; - LOG(info) << "[CbmRichTrbUnpack2] " << fMessageBuffer.size() << " edges in the buffer."; -*/ -} - -void CbmRichTrbUnpack2::ProcessSubEvent(CbmRawSubEvent* subEvent) { - UInt_t tdcDataIndex = 0; - UInt_t tdcData = 0x0; - // UInt_t subEventId = subEvent->SubId(); - - fLastSyncTime = 0.; - fCorr = 0.; -// fMainSyncDefined = kFALSE; -// fMainSyncTime = 0.; - - // Loop over subsubevents - while (true) { - tdcData = subEvent->SubDataValue(tdcDataIndex); - UInt_t tdcNofWords = (tdcData >> 16) & 0xffff; - UInt_t subSubEventId = tdcData & 0xffff; -#ifdef DEBUGPRINT -// printf("0x%08x - SUBSUBEVENT HEADER tdcNofWords = %i, ID = 0x%04x\n", tdcData, tdcNofWords, subSubEventId); -#endif - - if (subSubEventId == 0x7000 || subSubEventId == 0x7001 || subSubEventId == 0x7002 || subSubEventId == 0x7003) { - tdcDataIndex++; - continue; - } - - // read TDC words to array - UInt_t dataArray[tdcNofWords]; - for (UInt_t i = 0; i < tdcNofWords; i++) { - tdcDataIndex++; - tdcData = subEvent->SubDataValue(tdcDataIndex); - dataArray[i] = tdcData; - } - - if (subSubEventId == 0x5555) { - ProcessSkip(dataArray, tdcNofWords, subSubEventId); - break; - } - - //FIXME temporarily skip messages from beam detector (tdc=0x0111) -// if (subSubEventId != 0x7005 && subSubEventId != 0x0112/* && subSubEventId != 0x0111 && subSubEventId != 0x0110*/) { // For beamtime data - if (subSubEventId == 0x0010 || subSubEventId == 0x0011 || subSubEventId == 0x0012 || subSubEventId == 0x0013) { // For Wuppertal Lab data - ProcessSubSubEvent(dataArray, tdcNofWords, subSubEventId); - } else { - ProcessSkip(dataArray, tdcNofWords, subSubEventId); - } - - tdcDataIndex++; - } - -} - -void CbmRichTrbUnpack2::ProcessSkip(UInt_t* /*data*/, UInt_t /*size*/, UInt_t /*subEventId*/) -{ -#ifdef DEBUGPRINT -// for (UInt_t i=0; i<size; i++) { printf ("0x%08x - skip\n", data[i]); } -#endif -} - -void CbmRichTrbUnpack2::ProcessSubSubEvent(UInt_t* data, UInt_t size, UInt_t subEventId) { - CbmRichTrbParam* param = CbmRichTrbParam::Instance(); - - UInt_t tdcId = subEventId; - - UInt_t curEpochCounter = 0; - - for (UInt_t i = 0; i < size; i++) { - UInt_t tdcData = data[i]; - UInt_t tdcTimeDataMarker = (tdcData >> 31) & 0x1; - - if (tdcTimeDataMarker == 0x1) // TIME DATA - { - fTimestampsUnpacked++; - - UInt_t channel = (tdcData >> 22) & 0x7f; - UInt_t fine = (tdcData >> 12) & 0x3ff; - UInt_t edge = (tdcData >> 11) & 0x1; - UInt_t coarse = (tdcData) & 0x7ff; - UInt_t epoch = curEpochCounter; - -#ifdef DEBUGPRINT -//temporary condition -//if (!param->IsSyncChannel(channel)) { - printf("0x%08x - TIMESTAMP", tdcData); -//} -#endif - - // Fix 0x3ff fine time counter value occurence - skip such a timestamp - if (fine == 0x3ff) { -#ifdef DEBUGPRINT - printf(" 0x3ff fine time counter value detected, skipping timestamp. tdc 0x00%x ch %d\n", tdcId, channel); -#endif - fTimestampsNotUnpacked++; - return; - } - - Double_t fullTime = GetFullTime(tdcId, channel, epoch, coarse, fine); - - if (tdcId != 0x0110 && tdcId != 0x0111 && tdcId != 0x0112 && tdcId != 0x0113 && tdcId != 0xc000) { - if (channel != 0) { - fHM->H1("fMessagesInTDC")->Fill(param->TDCidToInteger(tdcId)); - fHM->H1("fMessagesInChannel")->Fill(param->TDCandCHtoInteger(tdcId, channel)); -/* - if (param->TDCandCHtoInteger(tdcId, channel) == 2048) { - printf ("tdc 0x%04x ch %d edge %d epoch %08x coarse %08x fine %08x\n", tdcId, channel, edge, epoch, coarse, fine); - } -*/ - if (param->IsLeadingEdgeChannel(channel)) { - CbmRichHitInfo* hitInfo = param->GetRichHitInfo(tdcId, channel); - fHM->H2("fHeatMapLeadingEdges")->Fill(hitInfo->GetXPixel(), hitInfo->GetYPixel()); - } - } - } - - if (param->IsSyncChannel(channel)) { // SYNC MESSAGE PROCESSING - //CbmTrbCalibrator::Instance()->AddFineTime(tdcId, channel, fine); //TODO check - needed or not? - - // Between-TDC synchronization - fLastSyncTime = fullTime; - - // Here one can implement the case when the previous sync (10ms earlier) comes among the current messages. - - // 10 kHz - 100 000 ns, thres should be ~90 000 - // 5 kHz - 200 000 ns, thres should be ~150 000 - // 1.1 kHz - 909 090 ns, thres should be ~800 000 - if (fLastSyncTime-fMainSyncTime > 150000) { - fMainSyncDefined = kFALSE; - } - - if (!fMainSyncDefined) { - fMainSyncDefined = kTRUE; - fMainSyncTime = fullTime; - } - fCorr = fLastSyncTime-fMainSyncTime; -/* - switch (tdcId) { - case 0x0011: fHM->H1("fhCorrection_0x0011")->Fill(fCorr); break; - case 0x0012: fHM->H1("fhCorrection_0x0012")->Fill(fCorr); break; - case 0x0013: fHM->H1("fhCorrection_0x0013")->Fill(fCorr); break; - default: break; - } -*/ -#ifdef DEBUGPRINT - printf(" --- SYNC - tdc 0x%04x ch %d edge %d epoch %08x coarse %08x fine %08x = %f\tcorrection=%f\n", - tdcId, channel, edge, epoch, coarse, fine, fullTime/*+fCorr*/, fCorr); -#endif - fSyncTimestampsUnpacked++; - - } else if (param->IsLeadingEdgeChannel(channel)) { // LEADING EDGE PROCESSING -#ifdef DEBUGPRINT - printf(" --- LEAD - tdc 0x%04x ch %d edge %d epoch %08x coarse %08x fine %08x = %f\tcorrection=%f\n", - tdcId, channel, edge, epoch, coarse, fine, fullTime/*+fCorr*/, fCorr); -#endif - CbmTrbCalibrator::Instance()->AddFineTime(tdcId, channel, fine); - } else { // TRAILING EDGE PROCESSING -#ifdef DEBUGPRINT - printf(" --- TRAIL - tdc 0x%04x ch %d edge %d epoch %08x coarse %08x fine %08x = %f\tcorrection=%f\n", - tdcId, channel, edge, epoch, coarse, fine, fullTime/*+fCorr*/, fCorr); -#endif - CbmTrbCalibrator::Instance()->AddFineTime(tdcId, channel, fine); - } -/******* obsolete - // Important to keep it here - after fCorr computation - new ((*fTrbRawHits)[fTrbRawHits->GetEntriesFast()]) CbmTrbRawMessage( - 0, tdcId, channel, epoch, coarse, fine, edge, fCorr); -*/ - //TODO development workaround - //FIXME - here we skip sync messages so that they don't appear in event building - //if (!param->IsSyncChannel(channel)) - { - fMessageBuffer.insert( std::pair<Double_t, CbmTrbRawMessage*> (fullTime, new CbmTrbRawMessage(0, tdcId, channel, epoch, coarse, fine, edge, fCorr))); - //fMessageBuffer.insert( new CbmTrbRawMessage(0, tdcId, channel, epoch, coarse, fine, edge, fCorr) ); - } - - } // if TIME DATA - - UInt_t tdcMarker = (tdcData >> 29) & 0x7; //3 bits - if (tdcMarker == 0x1) { // TDC header - // UInt_t randomCode = (tdcData >> 16) & 0xff; // 8bits - // UInt_t errorBits = (tdcData) & 0xffff; //16 bits -#ifdef DEBUGPRINT -// printf("0x%08x - TDC HEADER randomCode:0x%02x, errorBits:0x%04x\n", tdcData, randomCode, errorBits); -#endif - } else if (tdcMarker == 0x2) { // DEBUG - // UInt_t debugMode = (tdcData >> 24) & 0x1f; //5 bits - // UInt_t debugBits = (tdcData) & 0xffffff; //24 bits -#ifdef DEBUGPRINT -// printf("0x%08x - DEBUG debugMode:%i, debugBits:0x%06x\n", tdcData, debugMode, debugBits); -#endif - } else if (tdcMarker == 0x3) { // EPOCH counter - curEpochCounter = (tdcData) & 0xfffffff; //28 bits -#ifdef DEBUGPRINT -// printf("0x%08x - EPOCH COUNTER epochCounter:0x%07x\n", tdcData, curEpochCounter); -#endif - } else { -#ifdef DEBUGPRINT - if (tdcTimeDataMarker != 0x1) printf("0x%08x - UNKNOWN\n", tdcData); -#endif - } - - } // for loop - -} - -Double_t CbmRichTrbUnpack2::GetFullTime(UInt_t tdcId, UInt_t channel, UInt_t epoch, UInt_t coarse, UInt_t fine) -{ -// This piece of code may be useful for debugging if at some moment calibrator class would start crashing. -// Otherwise keep it commented. -/* - UShort_t tailSize = 30; - Double_t fineTime = 0.; - - if (fine < tailSize) { // Left tail - 0 ns - fineTime = 0.; - } else if (fine > 512-tailSize) { // Right tail - 5 ns - fineTime = 5.; - } else { // Middle - linear function - fineTime = (Double_t)(fine-tailSize) * 5. / (512. - 2.*tailSize); - } - - return epoch * TRB_TDC3_COARSEUNIT * TRB_TDC3_COARSEBINS + coarse * TRB_TDC3_COARSEUNIT - fineTime; -*/ - return CbmTrbCalibrator::Instance()->GetFullTime(tdcId, channel, epoch, coarse, fine); -} - -Double_t CbmRichTrbUnpack2::GetFullTime(CbmTrbRawMessage rawMess) -{ - UInt_t epoch = rawMess.GetEpochMarker(); - UInt_t coarse = rawMess.GetTDCcoarse(); - UInt_t fine = rawMess.GetTDCfine(); - UInt_t channel = rawMess.GetChannelID(); - UInt_t tdcid = rawMess.GetSourceAddress(); - - return this->GetFullTime(tdcid, channel, epoch, coarse, fine); -} - -ClassImp(CbmRichTrbUnpack2) diff --git a/beamtime/rich/CbmRichTrbUnpack2.h b/beamtime/rich/CbmRichTrbUnpack2.h deleted file mode 100644 index 2dc42b268694b0afe3d687df6a509521e98211aa..0000000000000000000000000000000000000000 --- a/beamtime/rich/CbmRichTrbUnpack2.h +++ /dev/null @@ -1,137 +0,0 @@ -#ifndef CBMRICHTRBUNPACK2_H -#define CBMRICHTRBUNPACK2_H - -#include <TString.h> -#include "FairSource.h" - -#include "CbmHistManager.h" -#include "CbmDrawHist.h" -#include "CbmTrbRawMessage.h" - -#include <list> -#include <map> -#include <set> -#include <vector> - -class CbmRawSubEvent; -class TClonesArray; -class CbmTrbIterator; - -struct eventDesc -{ - eventDesc(): begin(), end(), firstTimestamp(-111.), ready(kFALSE) {} - std::multimap<Double_t, CbmTrbRawMessage*>::iterator begin; - std::multimap<Double_t, CbmTrbRawMessage*>::iterator end; - Double_t firstTimestamp; - Bool_t ready; -}; - -class CbmRichTrbUnpack2 : public FairSource -{ -public: // methods - - CbmRichTrbUnpack2(); - CbmRichTrbUnpack2(TString hldFileName); - virtual ~CbmRichTrbUnpack2(); - - Bool_t Init(); - Int_t ReadEvent(UInt_t); - - Source_Type GetSourceType() {return kONLINE;} - - virtual void SetParUnpackers() {;} - - virtual Bool_t InitUnpackers() {return kTRUE;} - - virtual Bool_t ReInitUnpackers() {return kTRUE;} - - void Close(); - void Reset(); - - // Add filename to the list of input files to be processed during the run - void AddInputFile(TString filename) { fHldFiles.push_back(filename); } - - void SetOutHistoFile(TString filename) {fOutHistoFile = filename;} - -private: // methods - - // Try to read the next input file. Return 0 in case of success, otherwize 1. - UInt_t ReadNextInputFileToMemory(); - - Int_t ReadOneRawEvent(); - void PushEvent(std::multimap<Double_t, CbmTrbRawMessage*>::iterator firstEdge, - std::multimap<Double_t, CbmTrbRawMessage*>::iterator lastEdge); - - void ProcessSubEvent(CbmRawSubEvent* subEvent); - void ProcessSubSubEvent(UInt_t* data, UInt_t size, UInt_t subEventId); - void ProcessSkip(UInt_t* data, UInt_t size, UInt_t subEventId); - - Double_t GetFullTime(UInt_t tdcId, UInt_t channel, UInt_t epoch, UInt_t coarse, UInt_t fine); - - // Overloaded method - Double_t GetFullTime(CbmTrbRawMessage rawMess); - - //TODO implement or get rid - CbmRichTrbUnpack2(const CbmRichTrbUnpack2&); - CbmRichTrbUnpack2 operator=(const CbmRichTrbUnpack2&); - -private: // data members - - TString fOutHistoFile; - - // List of input HLD files to be processed - std::list<TString> fHldFiles; - - // Counter of processed raw events - UInt_t fNofRawEvents; - - // Limiter on the number of raw events to be processed - UInt_t fMaxNofRawEvents; - - // Counter of timestamps being unpacked - UInt_t fTimestampsUnpacked; - - // Counter of erroneous timestamps - UInt_t fTimestampsNotUnpacked; - - // Counter of sync timestamps unpacked - UInt_t fSyncTimestampsUnpacked; - - // Counter of skipped timestamps (not sent to further analysis) - UInt_t fSkippedTimestamps; - - // Counter of pushed timestamps - UInt_t fPushedTimestamps; - - // Pointer and the size of the data in the memory (read from file) which is being processed - Char_t* fDataPointer; - UInt_t fDataSize; - - // Iterator over the CbmNet messages - ? - CbmTrbIterator* fTrbIter; - - // Number of pushed events - UInt_t fNumPushed; - - //Between-TDC synchronization - Double_t fLastSyncTime; - Double_t fMainSyncTime; - Double_t fCorr; - Bool_t fMainSyncDefined; - - CbmHistManager* fHM; - - std::multimap<Double_t, CbmTrbRawMessage*> fMessageBuffer; - std::vector<eventDesc> fEventStack; - - Bool_t inGarbCollMode; - Bool_t inFinalCleanup; - UInt_t fCurNeventsInBuf; - - // Output raw hits - TClonesArray* fTrbRawHits; - - ClassDef(CbmRichTrbUnpack2,1) -}; - -#endif // CBMRICHTRBUNPACK2_H diff --git a/beamtime/rich/CbmRichTrbUnpackQa.cxx b/beamtime/rich/CbmRichTrbUnpackQa.cxx deleted file mode 100644 index d6317855bc7c6b8533daaf740365f7ffaf26ec23..0000000000000000000000000000000000000000 --- a/beamtime/rich/CbmRichTrbUnpackQa.cxx +++ /dev/null @@ -1,346 +0,0 @@ -#include "CbmRichTrbUnpackQa.h" -#include "FairRootManager.h" -#include "FairLogger.h" - -#include "CbmRichTrbDefines.h" -#include "CbmRichTrbDigi.h" -#include "CbmRichTrbParam.h" - -#include "CbmRichHit.h" -#include "CbmRichHitInfo.h" - -#include "TCanvas.h" -#include "TH1.h" -#include "TF1.h" -#include "TClonesArray.h" - -#include "CbmUtils.h" - -// Uncomment if you want to have excessive printout (do not execute on many events, may produce Gb's of output) -//#define DEBUGPRINT - -CbmRichTrbUnpackQa::CbmRichTrbUnpackQa() - : FairTask(), - fRichTrbDigi(NULL), - fRichHits(NULL), - fRichHitInfos(NULL), - fEventNum(0), - fRunTitle(""), - fOutputDir(""), - fDrawHist(kFALSE), - fHM(NULL), - numOfPairs(0), - numOfSingleEdges(0), - numOfSingleEdgesSync(0), - lastBaseTimestamp(0.) -{ -} - -CbmRichTrbUnpackQa::~CbmRichTrbUnpackQa() -{ -} - -InitStatus CbmRichTrbUnpackQa::Init() -{ - FairRootManager* manager = FairRootManager::Instance(); - fRichTrbDigi = (TClonesArray*)manager->GetObject("CbmRichTrbDigi"); - if (NULL == fRichTrbDigi) { Fatal("CbmRichTrbUnpackQa::Init","No CbmRichTrbDigi array!"); } - - fRichHits = new TClonesArray("CbmRichHit", 10); - manager->Register("RichHit", "RICH", fRichHits, IsOutputBranchPersistent("RichHit")); - - fRichHitInfos = new TClonesArray("CbmRichHitInfo", 10); - manager->Register("RichHitInfo","RICH", fRichHitInfos, IsOutputBranchPersistent("RichHitInfo")); - - InitHist(); - - return kSUCCESS; -} - -void CbmRichTrbUnpackQa::InitHist() -{ - if (fDrawHist) - { - fHM = new CbmHistManager(); - - fHM->Create1<TH1D>("fhNofDigisInEvent", "fhNofDigisInEvent;Number of digis in event;Entries", 2000, 0, 2000); - fHM->Create1<TH1D>("fhTDCmessages", "fhTDCmessages;Number of messages for a given TDC;Entries", 105, -5, 100); - - Double_t K = 1.; - - fHM->Create1<TH1D>("fhTOT_channel_1-2", "fhTOT_channel_1-2;Time-over-threshold channels 1-2;Entries", 20*(POSITIVEPAIRWINDOW+NEGATIVEPAIRWINDOW), -K*NEGATIVEPAIRWINDOW, K*POSITIVEPAIRWINDOW); - fHM->Create1<TH1D>("fhTOT_channel_3-4", "fhTOT_channel_3-4;Time-over-threshold channels 3-4;Entries", 20*(POSITIVEPAIRWINDOW+NEGATIVEPAIRWINDOW), -K*NEGATIVEPAIRWINDOW, K*POSITIVEPAIRWINDOW); - fHM->Create1<TH1D>("fhTOT_channel_5-6", "fhTOT_channel_5-6;Time-over-threshold channels 5-6;Entries", 20*(POSITIVEPAIRWINDOW+NEGATIVEPAIRWINDOW), -K*NEGATIVEPAIRWINDOW, K*POSITIVEPAIRWINDOW); - fHM->Create1<TH1D>("fhTOT_channel_7-8", "fhTOT_channel_7-8;Time-over-threshold channels 7-8;Entries", 20*(POSITIVEPAIRWINDOW+NEGATIVEPAIRWINDOW), -K*NEGATIVEPAIRWINDOW, K*POSITIVEPAIRWINDOW); - fHM->Create1<TH1D>("fhTOT_channel_9-10", "fhTOT_channel_9-10;Time-over-threshold channels 9-10;Entries", 20*(POSITIVEPAIRWINDOW+NEGATIVEPAIRWINDOW), -K*NEGATIVEPAIRWINDOW, K*POSITIVEPAIRWINDOW); - fHM->Create1<TH1D>("fhTOT_channel_11-12", "fhTOT_channel_11-12;Time-over-threshold channels 11-12;Entries", 20*(POSITIVEPAIRWINDOW+NEGATIVEPAIRWINDOW), -K*NEGATIVEPAIRWINDOW, K*POSITIVEPAIRWINDOW); - fHM->Create1<TH1D>("fhTOT_channel_13-14", "fhTOT_channel_13-14;Time-over-threshold channels 13-14;Entries", 20*(POSITIVEPAIRWINDOW+NEGATIVEPAIRWINDOW), -K*NEGATIVEPAIRWINDOW, K*POSITIVEPAIRWINDOW); - fHM->Create1<TH1D>("fhTOT_channel_15-16", "fhTOT_channel_15-16;Time-over-threshold channels 15-16;Entries", 20*(POSITIVEPAIRWINDOW+NEGATIVEPAIRWINDOW), -K*NEGATIVEPAIRWINDOW, K*POSITIVEPAIRWINDOW); - fHM->Create1<TH1D>("fhTOT_channel_17-18", "fhTOT_channel_17-18;Time-over-threshold channels 17-18;Entries", 20*(POSITIVEPAIRWINDOW+NEGATIVEPAIRWINDOW), -K*NEGATIVEPAIRWINDOW, K*POSITIVEPAIRWINDOW); - fHM->Create1<TH1D>("fhTOT_channel_19-20", "fhTOT_channel_19-20;Time-over-threshold channels 19-20;Entries", 20*(POSITIVEPAIRWINDOW+NEGATIVEPAIRWINDOW), -K*NEGATIVEPAIRWINDOW, K*POSITIVEPAIRWINDOW); - fHM->Create1<TH1D>("fhTOT_channel_21-22", "fhTOT_channel_21-22;Time-over-threshold channels 21-22;Entries", 20*(POSITIVEPAIRWINDOW+NEGATIVEPAIRWINDOW), -K*NEGATIVEPAIRWINDOW, K*POSITIVEPAIRWINDOW); - fHM->Create1<TH1D>("fhTOT_channel_23-24", "fhTOT_channel_23-24;Time-over-threshold channels 23-24;Entries", 20*(POSITIVEPAIRWINDOW+NEGATIVEPAIRWINDOW), -K*NEGATIVEPAIRWINDOW, K*POSITIVEPAIRWINDOW); - fHM->Create1<TH1D>("fhTOT_channel_25-26", "fhTOT_channel_25-26;Time-over-threshold channels 25-26;Entries", 20*(POSITIVEPAIRWINDOW+NEGATIVEPAIRWINDOW), -K*NEGATIVEPAIRWINDOW, K*POSITIVEPAIRWINDOW); - fHM->Create1<TH1D>("fhTOT_channel_27-28", "fhTOT_channel_27-28;Time-over-threshold channels 27-28;Entries", 20*(POSITIVEPAIRWINDOW+NEGATIVEPAIRWINDOW), -K*NEGATIVEPAIRWINDOW, K*POSITIVEPAIRWINDOW); - fHM->Create1<TH1D>("fhTOT_channel_29-30", "fhTOT_channel_29-30;Time-over-threshold channels 29-30;Entries", 20*(POSITIVEPAIRWINDOW+NEGATIVEPAIRWINDOW), -K*NEGATIVEPAIRWINDOW, K*POSITIVEPAIRWINDOW); - fHM->Create1<TH1D>("fhTOT_channel_31-32", "fhTOT_channel_31-32;Time-over-threshold channels 31-32;Entries", 20*(POSITIVEPAIRWINDOW+NEGATIVEPAIRWINDOW), -K*NEGATIVEPAIRWINDOW, K*POSITIVEPAIRWINDOW); - - Double_t minWin = -1000.; - Double_t maxWin = 1000.; - - fHM->Create1<TH1D>("fhDelay_channel_1", "fhDelay_channel_1;Delay of the PMT front from the 'base' front - channels 1;Entries", 5*(maxWin-minWin), minWin, maxWin); - fHM->Create1<TH1D>("fhDelay_channel_3", "fhDelay_channel_3;Delay of the PMT front from the 'base' front - channels 3;Entries", 5*(maxWin-minWin), minWin, maxWin); - fHM->Create1<TH1D>("fhDelay_channel_5", "fhDelay_channel_5;Delay of the PMT front from the 'base' front - channels 5;Entries", 5*(maxWin-minWin), minWin, maxWin); - fHM->Create1<TH1D>("fhDelay_channel_7", "fhDelay_channel_7;Delay of the PMT front from the 'base' front - channels 7;Entries", 5*(maxWin-minWin), minWin, maxWin); - fHM->Create1<TH1D>("fhDelay_channel_9", "fhDelay_channel_9;Delay of the PMT front from the 'base' front - channels 9;Entries", 5*(maxWin-minWin), minWin, maxWin); - fHM->Create1<TH1D>("fhDelay_channel_11", "fhDelay_channel_11;Delay of the PMT front from the 'base' front - channels 11;Entries", 5*(maxWin-minWin), minWin, maxWin); - fHM->Create1<TH1D>("fhDelay_channel_13", "fhDelay_channel_13;Delay of the PMT front from the 'base' front - channels 13;Entries", 5*(maxWin-minWin), minWin, maxWin); - fHM->Create1<TH1D>("fhDelay_channel_15", "fhDelay_channel_15;Delay of the PMT front from the 'base' front - channels 15;Entries", 5*(maxWin-minWin), minWin, maxWin); - fHM->Create1<TH1D>("fhDelay_channel_17", "fhDelay_channel_17;Delay of the PMT front from the 'base' front - channels 17;Entries", 5*(maxWin-minWin), minWin, maxWin); - fHM->Create1<TH1D>("fhDelay_channel_19", "fhDelay_channel_19;Delay of the PMT front from the 'base' front - channels 19;Entries", 5*(maxWin-minWin), minWin, maxWin); - fHM->Create1<TH1D>("fhDelay_channel_21", "fhDelay_channel_21;Delay of the PMT front from the 'base' front - channels 21;Entries", 5*(maxWin-minWin), minWin, maxWin); - fHM->Create1<TH1D>("fhDelay_channel_23", "fhDelay_channel_23;Delay of the PMT front from the 'base' front - channels 23;Entries", 5*(maxWin-minWin), minWin, maxWin); - fHM->Create1<TH1D>("fhDelay_channel_25", "fhDelay_channel_25;Delay of the PMT front from the 'base' front - channels 25;Entries", 5*(maxWin-minWin), minWin, maxWin); - fHM->Create1<TH1D>("fhDelay_channel_27", "fhDelay_channel_27;Delay of the PMT front from the 'base' front - channels 27;Entries", 5*(maxWin-minWin), minWin, maxWin); - fHM->Create1<TH1D>("fhDelay_channel_29", "fhDelay_channel_29;Delay of the PMT front from the 'base' front - channels 29;Entries", 5*(maxWin-minWin), minWin, maxWin); - fHM->Create1<TH1D>("fhDelay_channel_31", "fhDelay_channel_31;Delay of the PMT front from the 'base' front - channels 31;Entries", 5*(maxWin-minWin), minWin, maxWin); - - fHM->Create1<TH1D>("fhHitRelativeTime", "fhHitRelativeTime;Timestamp of the hit relative to the base timestamp;Entries", 200, -1500000, 1500000); - - } -} - -void CbmRichTrbUnpackQa::DrawHist() -{ - if (fDrawHist) { - //TCanvas* c = new TCanvas(fRunTitle + "", fRunTitle + "_", 600, 600); - //DrawH1(fHM->H1("fhNofDigisInEvent")); - //FitGaussAndDrawResults(fHM->H1("fhNofHitsInEvent")); - //Cbm::SaveCanvasAsImage(c, string(fOutputDir.Data()), "png"); - - TCanvas* cTDC = new TCanvas(fRunTitle + "_TDCmessages", fRunTitle + "_TDCmessages", 800, 800); - DrawH1(fHM->H1("fhTDCmessages")); - // Cbm::SaveCanvasAsImage(cTDC, string(fOutputDir.Data()), "png"); - - TCanvas* cHitRelativeTime = new TCanvas(fRunTitle + "_HitRelativeTime", fRunTitle + "_HitRelativeTime", 800, 800); - DrawH1(fHM->H1("fhHitRelativeTime")); - - // TOT histograms - - TCanvas* cTOT1 = new TCanvas(fRunTitle + "_TOT_1-8", fRunTitle + "_TOT_1-8", 1400, 1400); - cTOT1->Divide(2, 2); - cTOT1->cd(1); DrawH1(fHM->H1("fhTOT_channel_1-2")); - cTOT1->cd(2); DrawH1(fHM->H1("fhTOT_channel_3-4")); - cTOT1->cd(3); DrawH1(fHM->H1("fhTOT_channel_5-6")); - cTOT1->cd(4); DrawH1(fHM->H1("fhTOT_channel_7-8")); - // Cbm::SaveCanvasAsImage(cTOT1, string(fOutputDir.Data()), "png"); - - TCanvas* cTOT2 = new TCanvas(fRunTitle + "_TOT_9-16", fRunTitle + "_TOT_9-16", 1400, 1400); - cTOT2->Divide(2, 2); - cTOT2->cd(1); DrawH1(fHM->H1("fhTOT_channel_9-10")); - cTOT2->cd(2); DrawH1(fHM->H1("fhTOT_channel_11-12")); - cTOT2->cd(3); DrawH1(fHM->H1("fhTOT_channel_13-14")); - cTOT2->cd(4); DrawH1(fHM->H1("fhTOT_channel_15-16")); - // Cbm::SaveCanvasAsImage(cTOT2, string(fOutputDir.Data()), "png"); - - TCanvas* cTOT3 = new TCanvas(fRunTitle + "_TOT_17-24", fRunTitle + "_TOT_17-24", 1400, 1400); - cTOT3->Divide(2, 2); - cTOT3->cd(1); DrawH1(fHM->H1("fhTOT_channel_17-18")); - cTOT3->cd(2); DrawH1(fHM->H1("fhTOT_channel_19-20")); - cTOT3->cd(3); DrawH1(fHM->H1("fhTOT_channel_21-22")); - cTOT3->cd(4); DrawH1(fHM->H1("fhTOT_channel_23-24")); - // Cbm::SaveCanvasAsImage(cTOT3, string(fOutputDir.Data()), "png"); - - TCanvas* cTOT4 = new TCanvas(fRunTitle + "_TOT_25-32", fRunTitle + "_TOT_25-32", 1400, 1400); - cTOT4->Divide(2, 2); - cTOT4->cd(1); DrawH1(fHM->H1("fhTOT_channel_25-26")); - cTOT4->cd(2); DrawH1(fHM->H1("fhTOT_channel_27-28")); - cTOT4->cd(3); DrawH1(fHM->H1("fhTOT_channel_29-30")); - cTOT4->cd(4); DrawH1(fHM->H1("fhTOT_channel_31-32")); - // Cbm::SaveCanvasAsImage(cTOT4, string(fOutputDir.Data()), "png"); - - - // Delay of the PMT front from the LED sync front histograms - - TCanvas* cDelay1 = new TCanvas(fRunTitle + "_LEDdelay_1,3,5,7", fRunTitle + "_LEDdelay_1,3,5,7", 1400, 1400); - cDelay1->Divide(2, 2); - cDelay1->cd(1); DrawH1(fHM->H1("fhDelay_channel_1")); - cDelay1->cd(2); DrawH1(fHM->H1("fhDelay_channel_3")); - cDelay1->cd(3); DrawH1(fHM->H1("fhDelay_channel_5")); - cDelay1->cd(4); DrawH1(fHM->H1("fhDelay_channel_7")); - // Cbm::SaveCanvasAsImage(cDelay1, string(fOutputDir.Data()), "png"); - - TCanvas* cDelay2 = new TCanvas(fRunTitle + "_LEDdelay_9,11,13,15", fRunTitle + "_LEDdelay_9,11,13,15", 1400, 1400); - cDelay2->Divide(2, 2); - cDelay2->cd(1); DrawH1(fHM->H1("fhDelay_channel_9")); - cDelay2->cd(2); DrawH1(fHM->H1("fhDelay_channel_11")); - cDelay2->cd(3); DrawH1(fHM->H1("fhDelay_channel_13")); - cDelay2->cd(4); DrawH1(fHM->H1("fhDelay_channel_15")); - // Cbm::SaveCanvasAsImage(cDelay2, string(fOutputDir.Data()), "png"); - - TCanvas* cDelay3 = new TCanvas(fRunTitle + "_LEDdelay_17,19,21,23", fRunTitle + "_LEDdelay_17,19,21,23", 1400, 1400); - cDelay3->Divide(2, 2); - cDelay3->cd(1); DrawH1(fHM->H1("fhDelay_channel_17")); - cDelay3->cd(2); DrawH1(fHM->H1("fhDelay_channel_19")); - cDelay3->cd(3); DrawH1(fHM->H1("fhDelay_channel_21")); - cDelay3->cd(4); DrawH1(fHM->H1("fhDelay_channel_23")); - // Cbm::SaveCanvasAsImage(cDelay3, string(fOutputDir.Data()), "png"); - - TCanvas* cDelay4 = new TCanvas(fRunTitle + "_LEDdelay_25,27,29,31", fRunTitle + "_LEDdelay_25,27,29,31", 1400, 1400); - cDelay4->Divide(2, 2); - cDelay4->cd(1); DrawH1(fHM->H1("fhDelay_channel_25")); - cDelay4->cd(2); DrawH1(fHM->H1("fhDelay_channel_27")); - cDelay4->cd(3); DrawH1(fHM->H1("fhDelay_channel_29")); - cDelay4->cd(4); DrawH1(fHM->H1("fhDelay_channel_31")); - // Cbm::SaveCanvasAsImage(cDelay4, string(fOutputDir.Data()), "png"); - - } -} - -void CbmRichTrbUnpackQa::Exec(Option_t* /*option*/) -{ - CbmRichTrbParam* param = CbmRichTrbParam::Instance(); - - Int_t nofDigisInEvent = fRichTrbDigi->GetEntries(); - if (fDrawHist) { - fHM->H1("fhNofDigisInEvent")->Fill(nofDigisInEvent); - } - - fRichHits->Clear(); - fRichHitInfos->Clear(); - - TString curHistoName; - -#ifdef DEBUGPRINT - printf ("EVENT %d -------------------------------------------------------------------------------------------------\n", fEventNum); -#endif - - lastBaseTimestamp = 0.; - - for (Int_t i = 0; i < nofDigisInEvent; i++) { - CbmRichTrbDigi* theDigit = static_cast<CbmRichTrbDigi*>(fRichTrbDigi->At(i)); - - if (theDigit->GetTDCid() == 0x0110 && theDigit->GetLeadingEdgeChannel() == 11) { - lastBaseTimestamp = theDigit->GetLeadingEdgeTimeStamp(); - } - - if (theDigit->GetHasLeadingEdge() && theDigit->GetHasTrailingEdge()) { - numOfPairs++; - -#ifdef DEBUGPRINT - printf ("pair:"); - printf (" LEAD - tdc 0x%04x ch %d = %f\t(%f)\n", - theDigit->GetTDCid(), theDigit->GetLeadingEdgeChannel(), theDigit->GetLeadingEdgeTimeStamp(), theDigit->GetLeadingEdgeTimeStamp()); - printf (" "); - printf (" TRAIL - tdc 0x%04x ch %d = %f\t(%f)\n", - theDigit->GetTDCid(), theDigit->GetTrailingEdgeChannel(), theDigit->GetTrailingEdgeTimeStamp(), theDigit->GetTrailingEdgeTimeStamp()); -#endif - - UInt_t curLch = theDigit->GetLeadingEdgeChannel(); - - if (fDrawHist) { - fHM->H1("fhTDCmessages")->Fill(param->TDCidToInteger(theDigit->GetTDCid())); - - if (theDigit->GetTDCid() == 0x0030) { - curHistoName.Form("fhTOT_channel_%d-%d", curLch, curLch+1); - fHM->H1(curHistoName.Data())->Fill(theDigit->GetTOT()); - } - - if (param->IsPmtTdc(theDigit->GetTDCid())) { - //if (theDigit->GetTDCid() == 0x0030) { - curHistoName.Form("fhDelay_channel_%d", curLch); - fHM->H1(curHistoName.Data())->Fill(theDigit->GetLeadingEdgeTimeStamp() - lastBaseTimestamp); - } - } - - if (param->IsPmtTdc(theDigit->GetTDCid())) { - Double_t hitRelativeTime = theDigit->GetLeadingEdgeTimeStamp() - lastBaseTimestamp; - - if (fDrawHist) { - if (lastBaseTimestamp != 0.) - fHM->H1("fhHitRelativeTime")->Fill(hitRelativeTime); - } -/* - if (hitRelativeTime >= -105. && hitRelativeTime <= -65.) { - - CbmRichHitInfo* hitData = param->GetRichHitInfo(theDigit->GetTDCid(), curLch); - new( (*fRichHits)[fRichHits->GetEntriesFast()] ) CbmRichHit(hitData->GetX(), hitData->GetY()); - - LOG(info) << "Create a hit"; - - UInt_t counter2 = fRichHitInfos->GetEntries(); - new((*fRichHitInfos)[counter2]) CbmRichHitInfo(); - CbmRichHitInfo* newHitInfo = static_cast<CbmRichHitInfo*>(fRichHitInfos->At(counter2)); - newHitInfo->Copy(hitData); - - } -*/ - } - - } - else { - if (theDigit->GetHasLeadingEdge() && !(theDigit->GetHasTrailingEdge()) && param->IsSyncChannel(theDigit->GetLeadingEdgeChannel())) { - numOfSingleEdgesSync++; - -#ifdef DEBUGPRINT - printf ("sync:"); - printf (" SYNC - tdc 0x%04x ch %d = %f\t(%f)\n", - theDigit->GetTDCid(), theDigit->GetLeadingEdgeChannel(), theDigit->GetLeadingEdgeTimeStamp(), theDigit->GetLeadingEdgeTimeStamp()); -#endif - } else { -#ifdef DEBUGPRINT - if (theDigit->GetHasLeadingEdge()) { - printf ("sing: LEAD - tdc 0x%04x ch %d = %f\t(%f)\n", - theDigit->GetTDCid(), theDigit->GetLeadingEdgeChannel(), theDigit->GetLeadingEdgeTimeStamp(), theDigit->GetLeadingEdgeTimeStamp()); - } else { - printf ("sing: TRAIL - tdc 0x%04x ch %d = %f\t(%f)\n", - theDigit->GetTDCid(), theDigit->GetTrailingEdgeChannel(), theDigit->GetTrailingEdgeTimeStamp(), theDigit->GetTrailingEdgeTimeStamp()); - } -#endif - numOfSingleEdges++; - } - } - } - - if (fEventNum % 1000 == 0) - LOG(info) << "CbmRichTrbUnpackQa : Event #" << fEventNum; - fEventNum++; - -} - -void CbmRichTrbUnpackQa::Finish() -{ - UInt_t totalMessages = numOfPairs*2 + numOfSingleEdges + numOfSingleEdgesSync; - - LOG(info) << "[CbmRichTrbUnpackQa] " << numOfPairs << " pairs; " << numOfSingleEdges << " single edges (not incl.) " - << numOfSingleEdgesSync << " sync messages; Total " << totalMessages << " messages"; - - LOG(info) << 100.*(Double_t)numOfPairs*2. / (Double_t)totalMessages << "%, " - << 100.*(Double_t)numOfSingleEdges / (Double_t)totalMessages << "%, " - << 100.*(Double_t)numOfSingleEdgesSync / (Double_t)totalMessages << "%"; - - if (fDrawHist) { - DrawHist(); - TFile* curHistoFile = new TFile(fOutHistoFile, "CREATE"); - LOG(info) << "Opening file " << fOutHistoFile << " for histograms"; - fHM->WriteToFile(); - curHistoFile->Close(); - } -} - -void CbmRichTrbUnpackQa::FitGaussAndDrawResults(TH1* h) -{ - h->Fit("gaus", "Q"); - //h->Fit("gaus"); - TF1* fit = h->GetFunction("gaus"); - - Double_t sigma = (NULL != fit) ? fit->GetParameter(2) : 0.; - Double_t mean = (NULL != fit) ? fit->GetParameter(1) : 0.; - TString str; - str.Form("m=%.2f #sigma=%.2f", mean, sigma); - - h->SetTitle(str.Data()); - fit->SetLineColor(kBlack); -} - -ClassImp(CbmRichTrbUnpackQa) diff --git a/beamtime/rich/CbmRichTrbUnpackQa.h b/beamtime/rich/CbmRichTrbUnpackQa.h deleted file mode 100644 index ac98c7479395859428bdca553e7b8006a5a68fea..0000000000000000000000000000000000000000 --- a/beamtime/rich/CbmRichTrbUnpackQa.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef CBMRICHTRBUNPACKQA_H -#define CBMRICHTRBUNPACKQA_H - -#include "FairTask.h" - -#include "CbmHistManager.h" -#include "CbmDrawHist.h" - -class TClonesArray; -class TH1D; - -class CbmRichTrbUnpackQa : public FairTask -{ -public: - - CbmRichTrbUnpackQa(); - virtual ~CbmRichTrbUnpackQa(); - - virtual InitStatus Init(); - virtual void Exec(Option_t* option); - virtual void Finish(); - void InitHist(); - void DrawHist(); - void SetRunTitle(TString title) { fRunTitle = title; } - void SetOutputDir(TString dir) {fOutputDir = dir;} - void SetOutHistoFile(TString filename) {fOutHistoFile = filename;} - void SetDrawHist(Bool_t value) { fDrawHist = value; } - void FitGaussAndDrawResults(TH1* h); - -private: - - TClonesArray* fRichTrbDigi; // input - TClonesArray* fRichHits; // output - TClonesArray* fRichHitInfos; // output - - Int_t numOfPairs; - Int_t numOfSingleEdges; - Int_t numOfSingleEdgesSync; - - CbmHistManager* fHM; - - Bool_t fDrawHist; // if TRUE histograms are drawn - - UInt_t fEventNum; // Event counter - - TString fRunTitle; // Title of the run - TString fOutputDir; // output directory to store figures - TString fOutHistoFile; - - // For event building - Double_t lastBaseTimestamp; - - ClassDef(CbmRichTrbUnpackQa, 1); -}; - -#endif // CBMRICHTRBUNPACKQA_H diff --git a/beamtime/rich/CbmTrbCalibrator.cxx b/beamtime/rich/CbmTrbCalibrator.cxx deleted file mode 100644 index 689162be61146cf882b1074bec409506eed2596a..0000000000000000000000000000000000000000 --- a/beamtime/rich/CbmTrbCalibrator.cxx +++ /dev/null @@ -1,441 +0,0 @@ -#include "CbmTrbCalibrator.h" - -#include "CbmRichTrbDefines.h" - -#include "FairLogger.h" -#include "TFile.h" -#include "TCanvas.h" -#include "CbmDrawHist.h" - -CbmTrbCalibrator* CbmTrbCalibrator::fInstance = 0; - -// By default the calibration tables are imported from the file -CbmTrbCalibrator::CbmTrbCalibrator() - : TObject(), - fCalibMode(etn_NOCALIB), - fTablesCreated(kFALSE), - fCalibrationPeriod(10000), - fTRBroot(NULL), - fInputFilename(""), - fInputCorrFilename(""), - fCalibrationDoneHisto(), - fhLeadingFineBuffer(), - fhLeadingFine(), - fhCalcBinWidth(), - fhCalBinTime(), - fFTcounter(), - fhFTcounter() -{ - for (Int_t i=0; i<32*4; i++) fCorrections[i] = 0.; -} - -CbmTrbCalibrator::~CbmTrbCalibrator() -{ -} - -CbmTrbCalibrator* CbmTrbCalibrator::Instance() -{ - if (!fInstance) fInstance = new CbmTrbCalibrator(); - return fInstance; -} - -void CbmTrbCalibrator::Export(const char* filename) -{ -/* - TH1I* calibrationEntries = new TH1I("abc", "abc", TRB_TDC3_CHANNELS*TRB_TDC3_NUMTDC*TRB_TDC3_NUMBOARDS, 0, TRB_TDC3_CHANNELS*TRB_TDC3_NUMTDC*TRB_TDC3_NUMBOARDS); - for (Int_t b=0; b<TRB_TDC3_NUMBOARDS; ++b) { - for (Int_t t=0; t<TRB_TDC3_NUMTDC; ++t) { - for (Int_t i=0; i<TRB_TDC3_CHANNELS; ++i) { - calibrationEntries->SetBinContent(b*TRB_TDC3_NUMTDC*TRB_TDC3_CHANNELS + t*TRB_TDC3_CHANNELS + i, fFTcounter[b][t][i]); - } - } - } - DrawH1(calibrationEntries); -*/ - - TDirectory* current = gDirectory; - TFile* old = gFile; - TFile* file = new TFile(filename, "RECREATE"); - - if (file == NULL || !(file->IsOpen())) - { - // error - } else { - file->cd(); - - if (fTRBroot) { - //gROOT->GetRootFolder()->ls(); - fTRBroot->Write(); - } - - file->Close(); - current->cd(); - } - - delete file; - - gFile = old; - gDirectory = current; -} - -// This method will overwrite the existing tables -void CbmTrbCalibrator::Import(/*const char* filename*/) -{ - LOG(info) << "Importing calibration tables from " << fInputFilename; - - TDirectory* current = gDirectory; - TFile* old = gFile; - TFile* file = new TFile(fInputFilename, "READ"); - - if (file == NULL || !(file->IsOpen())) - { - // error - } else { - - TString obname; - TFolder* TRBfolder = (TFolder*)file->Get("TRB"); - - for (Int_t b=0; b<TRB_TDC3_NUMBOARDS; ++b) { - obname.Form("TRB%02d", b+1); - TFolder* perTRBfolder = (TFolder*)(TRBfolder->FindObject(obname)); - - for (Int_t t=0; t<TRB_TDC3_NUMTDC; ++t) { - obname.Form("TDC%d", t); - TFolder* perTDCfolder = (TFolder*)(perTRBfolder->FindObject(obname)); - - for (Int_t i=0; i<TRB_TDC3_CHANNELS; ++i) { - obname.Form("FineTimeBuffer_%02d_%d_%02d", b+1, t, i); - TH1D* curHisto = (TH1D*)(perTDCfolder->FindObject(obname)); - fhLeadingFineBuffer[b][t][i] = curHisto; - - obname.Form("FineTime_%02d_%d_%02d", b+1, t, i); - curHisto = (TH1D*)(perTDCfolder->FindObject(obname)); - fhLeadingFine[b][t][i] = curHisto; - - obname.Form("BinWidth_%02d_%d_%02d", b+1, t, i); - curHisto = (TH1D*)(perTDCfolder->FindObject(obname)); - fhCalcBinWidth[b][t][i] = curHisto; - - obname.Form("CalTableBinTime_%02d_%d_%02d", b+1, t, i); - curHisto = (TH1D*)(perTDCfolder->FindObject(obname)); - fhCalBinTime[b][t][i] = curHisto; - } - - obname.Form("CalibrationDone_%02d_%d", b+1, t); - TH1C* curHisto2 = (TH1C*)(perTRBfolder->FindObject(obname)); - fCalibrationDoneHisto[b][t] = curHisto2; - } - } - - } - - delete file; - - gFile = old; - gDirectory = current; - - fTablesCreated = kTRUE; - - LOG(info) << "Calibration tables imported."; - - this->ImportCorrections(); -} - -void CbmTrbCalibrator::ImportCorrections() -{ - FILE* f = fopen (fInputCorrFilename.Data(), "r"); - if (f == NULL) { - LOG(error) << "Failed to open corrections table. Using zero corrections."; - return; - } - for (int tdc=0; tdc<16*4; tdc++) { - for (int ch=0; ch<32; ch+=2) { - int read = fscanf (f, "%lf\t%lf\n", &fCorrections[tdc*32+ch], &fCorrections[tdc*32+ch+1]); - if ( read != 2 ) LOG(error) << "Failed to read corrections for tdc " - << tdc << " ch " << ch; - } - } - fclose(f); - LOG(info) << "Correction tables imported."; -} - -// inTDCid - raw id, looks like 0x**** TDC - from 0 to 3 incl. -// inCHid - raw id of the channel - the same as CH - number of the channel from 0 to 32 incl. -void CbmTrbCalibrator::AddFineTime(UShort_t inTDCid, UShort_t inCHid, UShort_t fineCnt) -{ - // for etn_NOCALIB and etn_IDEAL this method is useless - - //printf (" CbmTrbCalibrator::AddFineTime TDC %x ch %d\n", inTDCid, inCHid); - - if (fCalibMode == etn_ONLINE) - { - if (!fTablesCreated) GenHistos(); - - UShort_t TRB = ((inTDCid >> 4) & 0x00FF) - 1; - UShort_t TDC = (inTDCid & 0x000F); - UShort_t CH = inCHid; - - LOG(debug3) << "AddFineTime: TDC" << std::hex << inTDCid << std::dec << " CH" << CH; - - fhLeadingFineBuffer[TRB][TDC][CH]->Fill(fineCnt); - fhLeadingFine[TRB][TDC][CH]->Fill(fineCnt); - - fFTcounter[TRB][TDC][CH]++; - fhFTcounter[TRB]->SetBinContent(CH+1, TDC+1, fhFTcounter[TRB]->GetBinContent(CH+1,TDC+1)+1); //FIXME - - if (fFTcounter[TRB][TDC][CH] >= fCalibrationPeriod - && fCalibrationDoneHisto[TRB][TDC]->GetBinContent(CH+1) == 0) - { - DoCalibrate(inTDCid, CH); - fFTcounter[TRB][TDC][CH] = 0; //TODO maybe comment? - } - } -} - -void CbmTrbCalibrator::ForceCalibration() -{ - LOG(info) << "Force calibration of all the channels of all TDCs which have at least one entry!"; - UShort_t TDCid; - for (UInt_t TRB=0; TRB<TRB_TDC3_NUMBOARDS; TRB++) { - for (UShort_t TDC=0; TDC<=3; TDC++) { // from 0x0??0 to 0x0??3 - for (UShort_t CH=0; CH<=32; CH++) { - TDCid = (TRB+1)*16+TDC; - if (fFTcounter[TRB][TDC][CH] > 0) { - DoCalibrate(TDCid, CH); - fFTcounter[TRB][TDC][CH] = 0; - } - } - } - } -} - -void CbmTrbCalibrator::DoCalibrate(UShort_t inTDCid, UShort_t inCHid) -{ - LOG(debug) << "DoCalibrate: TDC" << std::hex << inTDCid << std::dec << " CH" << inCHid; - - UShort_t TRB = ((inTDCid >> 4) & 0x00FF) - 1; - UShort_t TDC = (inTDCid & 0x000F); - UShort_t CH = inCHid; - - TH1* hfinecal = 0; - UInt_t sum; - Double_t binwidth; - Double_t binhits; - - hfinecal = fhLeadingFineBuffer[TRB][TDC][CH]; - sum = hfinecal->GetEntries(); - - for (Int_t fb=0; fb<TRB_TDC3_FINEBINS; ++fb) - { - binwidth = 1.; - binhits = hfinecal->GetBinContent(fb + 1); - if (sum) - binwidth = (TRB_TDC3_COARSEUNIT * binhits) / (Double_t)sum; - fhCalcBinWidth[TRB][TDC][CH]->SetBinContent(fb + 1, binwidth); - - Double_t calbintime = 1.; - if (fb == 0) - calbintime = fhCalcBinWidth[TRB][TDC][CH]->GetBinContent(fb + 1) / 2; - else - calbintime = fhCalBinTime[TRB][TDC][CH]->GetBinContent(fb) + - (fhCalcBinWidth[TRB][TDC][CH]->GetBinContent(fb) + fhCalcBinWidth[TRB][TDC][CH]->GetBinContent(fb + 1)) / 2; - - fhCalBinTime[TRB][TDC][CH]->SetBinContent(fb + 1, calbintime); - } - - fhLeadingFineBuffer[TRB][TDC][CH]->Reset(); - - fCalibrationDoneHisto[TRB][TDC]->SetBinContent(CH+1, 1); -} - -Double_t CbmTrbCalibrator::GetFineTimeCalibrated(UShort_t inTDCid, UShort_t inCHid, UShort_t fineCnt) -{ - // printf ("TDC %x CH %d fine %x\n", inTDCid, inCHid, fineCnt); - - // hard-code for special channel number 0 which is a reference channel. - // for this channel the ideal calibration is used - if (inCHid == 0) return GetAlmostLinearCalibratedFT(fineCnt); - - UShort_t TRB = ((inTDCid >> 4) & 0x00FF) - 1; - UShort_t TDC = (inTDCid & 0x000F); - - switch (fCalibMode) { - case etn_IMPORT: - if (!fTablesCreated) this->Import(); - if (fCalibrationDoneHisto[TRB][TDC]->GetBinContent(inCHid+1) == 1) - return GetRealCalibratedFT(inTDCid, inCHid, fineCnt); - else - return GetAlmostLinearCalibratedFT(fineCnt); // if the channel is not calibrated return time as if it was ideally calibrated - break; - case etn_ONLINE: - if (!fTablesCreated) this->GenHistos(); - if (fCalibrationDoneHisto[TRB][TDC]->GetBinContent(inCHid+1) == 1) - return GetRealCalibratedFT(inTDCid, inCHid, fineCnt); - else - return GetAlmostLinearCalibratedFT(fineCnt); // if the channel is not calibrated return time as if it was ideally calibrated - break; - case etn_NOCALIB: - return GetLinearCalibratedFT(fineCnt); - break; - case etn_IDEAL: - return GetAlmostLinearCalibratedFT(fineCnt); - break; - case etn_NOFINE: - return 0.; - break; - default: - return 0.; - break; - } -} - -// Per-channel corrections are introduced here -Double_t CbmTrbCalibrator::GetFullTime(UInt_t inTDCid, UInt_t inCHid, UInt_t epoch, UInt_t coarse, UInt_t fine) -{ - Double_t fullTimeCalibrated = epoch * TRB_TDC3_COARSEUNIT * TRB_TDC3_COARSEBINS + coarse * TRB_TDC3_COARSEUNIT - - this->GetFineTimeCalibrated(inTDCid, inCHid, fine); - - UInt_t TDCindex = ((((inTDCid >> 4) & 0x00ff) - 1) * 4 + (inTDCid & 0x000f)); - Double_t correction = 0.; - if (inCHid != 0) { - correction = fCorrections[TDCindex*32+inCHid-1]; - } - - return fullTimeCalibrated + correction; -} - -// etn_NOCALIB -Double_t CbmTrbCalibrator::GetLinearCalibratedFT(UShort_t fineCnt) -{ - return (Double_t)fineCnt * 5. / 512.; // counter * 5 ns / 512. 512 because there are 10 bits for fine time counter. -} - -// etn_IDEAL -Double_t CbmTrbCalibrator::GetAlmostLinearCalibratedFT(UShort_t fineCnt) -{ - UShort_t tailSize = 30; - - if (fineCnt < tailSize) { // Left tail - 0 ns - return 0.; - } else if (fineCnt > 512-tailSize) { // Right tail - 5 ns - return 5.; - } else { // Middle - linear function - return (Double_t)(fineCnt-tailSize) * 5. / (512. - 2.*tailSize); - } -} - -// etn_IMPORT || etn_ONLINE -Double_t CbmTrbCalibrator::GetRealCalibratedFT(UShort_t inTDCid, UShort_t inCHid, UShort_t fineCnt) -{ - UShort_t TRB = ((inTDCid >> 4) & 0x00FF) - 1; - UShort_t TDC = (inTDCid & 0x000F); - return fhCalBinTime[TRB][TDC][inCHid]->GetBinContent(fineCnt+1); -} - -void CbmTrbCalibrator::GenHistos() -{ - LOG(debug2) << "CbmTrbCalibrator::GenHistos"; - - TH1::AddDirectory(kFALSE); // Magic line which helps from crashes on new OS/gcc/fairsoft - - TString obname; - TString obtitle; - TString dirname; - - UInt_t tbins = TRB_TDC3_FINEBINS; - Int_t trange = TRB_TDC3_FINEBINS; - - fTRBroot = gROOT->GetRootFolder()->AddFolder("TRB", "TRB root folder"); - gROOT->GetListOfBrowsables()->Add(fTRBroot, "TRB"); - - TFolder* TRBfolders[TRB_TDC3_NUMBOARDS]; - TFolder* TDCfolders[TRB_TDC3_NUMBOARDS][TRB_TDC3_NUMTDC]; - - // TRBs are numerated starting from 1, but the arrays of histos are from 0 (as in any C++ code) - // TDCs are numerated from 0. One TRB has TDCs {0,1,2,3}. - // Channels are numerated from 0 and there are total 33 channels for each TDC. 0-th channel is the reference channel. - - for (Int_t b=0; b<TRB_TDC3_NUMBOARDS; ++b) { - - obname.Form("TRB%02d", b+1); - obtitle.Form("TRB%02d", b+1); - TRBfolders[b] = fTRBroot->AddFolder(obname, obtitle); - - obname.Form("fhFTcounter_%02d", b+1); - obtitle.Form("Counter of entries for all the channels of all the TDCs of TRB %d", b+1); - fhFTcounter[b] = new TH2D(obname.Data(), obtitle.Data(), TRB_TDC3_CHANNELS, 0, TRB_TDC3_CHANNELS, TRB_TDC3_NUMTDC, 0, TRB_TDC3_NUMTDC); - TRBfolders[b]->Add(fhFTcounter[b]); - - - for (Int_t t=0; t<TRB_TDC3_NUMTDC; ++t) { - - obname.Form("TDC%d", t); - obtitle.Form("TDC%d", t); - TDCfolders[b][t] = TRBfolders[b]->AddFolder(obname, obtitle); - - for (Int_t i=0; i<TRB_TDC3_CHANNELS; ++i) { - - obname.Form("FineTimeBuffer_%02d_%d_%02d", b+1, t, i); - obtitle.Form("Fine time Leading edge TRB %d TDC %d Channel %02d (calibration buffer)", b+1, t, i); - fhLeadingFineBuffer[b][t][i] = new TH1D(obname.Data(), obtitle.Data(), tbins, 0, trange); - TDCfolders[b][t]->Add(fhLeadingFineBuffer[b][t][i]); - - obname.Form("FineTime_%02d_%d_%02d", b+1, t, i); - obtitle.Form("Fine time Leading edge TRB %02d TDC %02d Channel %02d", b+1, t, i); - fhLeadingFine[b][t][i] = new TH1D(obname.Data(), obtitle.Data(), tbins, 0, trange); - TDCfolders[b][t]->Add(fhLeadingFine[b][t][i]); - - obname.Form("BinWidth_%02d_%d_%02d", b+1, t, i); - obtitle.Form("Binwidth Histogram of TRB %02d TDC %d Channel %02d", b+1, t, i); - fhCalcBinWidth[b][t][i] = new TH1D(obname.Data(), obtitle.Data(), TRB_TDC3_FINEBINS, 0, TRB_TDC3_FINEBINS); - - //! Reset time bin correction arrays - for (int fb=0; fb<TRB_TDC3_FINEBINS; ++fb) - fhCalcBinWidth[b][t][i]->SetBinContent(fb + 1, 1.0); - - TDCfolders[b][t]->Add(fhCalcBinWidth[b][t][i]); - - obname.Form("CalTableBinTime_%02d_%d_%02d", b+1, t, i); - obtitle.Form("Calibration Table of TRB %02d TDC %d Channel %02d", b+1, t, i); - fhCalBinTime[b][t][i] = new TH1D(obname.Data(), obtitle.Data(), TRB_TDC3_FINEBINS, 0, TRB_TDC3_FINEBINS); - - //! Reset time bin correction arrays - for (int fb=0; fb<TRB_TDC3_FINEBINS; ++fb) - fhCalBinTime[b][t][i]->SetBinContent(fb + 1, (Double_t)(TRB_TDC3_COARSEUNIT * fb) / (Double_t)TRB_TDC3_FINEBINS); - - TDCfolders[b][t]->Add(fhCalBinTime[b][t][i]); - - } // Channels - - obname.Form("CalibrationDone_%02d_%d", b+1, t); - obtitle.Form("Flag indicating that calibration is done for TRB %02d TDC %d", b+1, t); - fCalibrationDoneHisto[b][t] = new TH1C(obname.Data(), obtitle.Data(), TRB_TDC3_CHANNELS, 0, TRB_TDC3_CHANNELS); - - TRBfolders[b]->Add(fCalibrationDoneHisto[b][t]); - - } // TDCs - } // TRBs - - LOG(info) << "Histos created."; - fTablesCreated = kTRUE; - -} // end of method - -//TODO draw all 17, not 16 tables -void CbmTrbCalibrator::Draw(Option_t*) -{ - TCanvas* c[4]; - for (int t=0; t<4; t++) - { - TString obname; - obname.Form("Channels calibration flags of TDC%d of all TRBs", t); - c[t] = new TCanvas(obname, obname, 1000, 1000); - c[t]->Divide(4, 4); - for (int b=0; b<16; b++) { - c[t]->cd(b+1); - DrawH1(fCalibrationDoneHisto[b][t]); - } - } -} - -ClassImp(CbmTrbCalibrator) diff --git a/beamtime/rich/CbmTrbCalibrator.h b/beamtime/rich/CbmTrbCalibrator.h deleted file mode 100644 index ee15d6e0eed7089b92de9411815422559ab18be0..0000000000000000000000000000000000000000 --- a/beamtime/rich/CbmTrbCalibrator.h +++ /dev/null @@ -1,217 +0,0 @@ -#ifndef CBMTRBCALIBRATOR_H -#define CBMTRBCALIBRATOR_H - -#include "TObject.h" -#include "TFolder.h" -#include "TH1.h" -#include "TH2.h" -#include "TROOT.h" - -#include "CbmRichTrbDefines.h" - -enum enu_calibMode { - etn_IMPORT, // import calibration tables from the file and use them - etn_ONLINE, // use first data to calibrate; the channel has to get at least fCalibrationPeriod messages to get calibrated - etn_NOCALIB, // use linear function going from origin to (512, n) which means that the fine time is not calibrated - etn_IDEAL, // use almost linear function - close to real calibration but idealized - etn_NOFINE // ignore fine time counter at all -}; - -class CbmTrbCalibrator : public TObject -{ -public: // methods - /* - * Destructor. - */ - ~CbmTrbCalibrator(); - - /* - * Generate calibration tables. Not needed if they were imported from the external file. - */ - void GenHistos(); - - /* - * Singleton class object returner. - */ - static CbmTrbCalibrator* Instance(); - - /* - * - */ - void SetMode(enu_calibMode mode) { fCalibMode = mode; } - - /* - * Set the period of calibration. - */ - void SetCalibrationPeriod(UInt_t period) { fCalibrationPeriod = period; } - - /* - * Get the period of calibration. - */ - //UInt_t GetCalibrationPeriod() { return fCalibrationPeriod; } - - /* - * Add raw fine time received from TDC and unpacked by the CbmRichTrbUnpack. - */ - void AddFineTime(UShort_t inTDCid, UShort_t inCHid, UShort_t fineCnt); - - /* - * Return time in ns. - * Fine time counter is 10 bits => UShort_t is enough. - */ - Double_t GetFineTimeCalibrated(UShort_t inTDCid, UShort_t inCHid, UShort_t fineCnt); - - /* - * Return full time in ns. - * The calibration mode is chosen according to the singleton calibrator object state. - */ - Double_t GetFullTime(UInt_t inTDCid, UInt_t inCHid, UInt_t epoch, UInt_t coarse, UInt_t fine); - - /* - * Set the name of the file from which the calibration tables will be imported - */ - void SetInputFilename(TString filename) { fInputFilename = filename; } - - /* - * Set the name of the file from which the corrections will be imported. - */ - void SetCorrInputFilename(TString filename) { fInputCorrFilename = filename; } - - /* - * Import the calibration information from the root file. - */ - void Import(/*const char* filename = "calibration.root"*/); - - /* - * Export the calibration information into the root file. - */ - void Export(const char* filename = "calibration.root"); - - /* - * Import per-channel corrections from the external file - */ - void ImportCorrections(); - - /* - * Draw a canvas with the flags indicating whilch channels have been calibrated. - */ - void Draw(Option_t* =""); - - /* - * Force calibration of all the channels using the data already in the tables no matter what the period is. - */ - void ForceCalibration(); - -private: // methods - - /* - * Constructor - private because the class is singleton. - */ - CbmTrbCalibrator(); - - /* - * Pseudo-calibration - used during debug. - * Return time in ns. - * Fine time counter is 10 bits => UShort_t is enough. - * AlmostLinear has tails. - */ - Double_t GetLinearCalibratedFT(UShort_t fineCnt); - Double_t GetAlmostLinearCalibratedFT(UShort_t fineCnt); - - /* - * Return really calibrated fine time. DoCalibrate() should have been called before. - * If NextRawEvent() had been called for each event and calibrationPeriod is correctly defined - * then the object of this class automatically handles calibration. - * Return time in ns. - * Fine time counter is 10 bits => UShort_t is enough. - */ - Double_t GetRealCalibratedFT(UShort_t inTDCid, UShort_t inCHid, UShort_t fineCnt); - - /* - * Per se calibration of a certain channel of a certain TDC of a certain TRB basing on the buffer accumulated by AddFineTime(). - */ - void DoCalibrate(UShort_t inTDCid, UShort_t inCHid); - -private: // data members - - /* - * Current calibration mode (see description of enu_calibMode) - */ - enu_calibMode fCalibMode; - - /* - * True if calibration histograms have already been created - */ - Bool_t fTablesCreated; - - /* - * Minimum number of fine time counters taken into account to start calibration. - */ - UInt_t fCalibrationPeriod; - - /* - * Root folder for all the calibration data. - */ - TFolder* fTRBroot; - - /* - * Input file name - */ - TString fInputFilename; - - /* - * Name of the input file with per-channel corrections - */ - TString fInputCorrFilename; - - //FIXME temporary solution for 1 TRB setup - 8*8*2 - // Update for beamtime data - 4*4 PMTs camera. Each PMT 8*8 pixels. Each pixel has 2 edges. Thus 4*4*8*8*2 - Double_t fCorrections[4*4*8*8*2]; - - /* - * Calibration has already been done - use calibation table, - * Otherwise - use linear claibration. - */ - TH1C* fCalibrationDoneHisto[TRB_TDC3_NUMBOARDS][TRB_TDC3_NUMTDC]; - - /* - * Flushed after calibration. - */ - TH1D* fhLeadingFineBuffer[TRB_TDC3_NUMBOARDS][TRB_TDC3_NUMTDC][TRB_TDC3_CHANNELS]; - - /* - * Accumulates across all the received data. - */ - TH1D* fhLeadingFine[TRB_TDC3_NUMBOARDS][TRB_TDC3_NUMTDC][TRB_TDC3_CHANNELS]; - - /* - * Renewes at calibration. - * Initialized with `identity` (linear =1 function) before the first calibration. - */ - TH1D* fhCalcBinWidth[TRB_TDC3_NUMBOARDS][TRB_TDC3_NUMTDC][TRB_TDC3_CHANNELS]; - - /* - * Renewes at calibration. - * Initialized with `identity` (linear y=k*x function) before the first calibration. - */ - TH1D* fhCalBinTime[TRB_TDC3_NUMBOARDS][TRB_TDC3_NUMTDC][TRB_TDC3_CHANNELS]; - - /* - * For each channel - counter of fine time counters taken into accout for calibration. - */ - UInt_t fFTcounter[TRB_TDC3_NUMBOARDS][TRB_TDC3_NUMTDC][TRB_TDC3_CHANNELS]; - TH2D* fhFTcounter[TRB_TDC3_NUMBOARDS]; - - /* - * Pointer to the singleton class object. - */ - static CbmTrbCalibrator* fInstance; - - CbmTrbCalibrator(const CbmTrbCalibrator&); - CbmTrbCalibrator operator=(const CbmTrbCalibrator&); - - - ClassDef(CbmTrbCalibrator,1) -}; - -#endif // CBMTRBCALIBRATOR_H diff --git a/beamtime/rich/CbmTrbEdgeMatcher.cxx b/beamtime/rich/CbmTrbEdgeMatcher.cxx deleted file mode 100644 index a3c8133721a7dce0512bae90e6069ac31e83670e..0000000000000000000000000000000000000000 --- a/beamtime/rich/CbmTrbEdgeMatcher.cxx +++ /dev/null @@ -1,578 +0,0 @@ -#include "CbmTrbEdgeMatcher.h" - -//TODO check which headers are really needed -#include <cstdlib> - -#include <TClonesArray.h> -#include <TH1D.h> -#include <TCanvas.h> -#include "FairRootManager.h" -#include "FairLogger.h" - -#include "CbmRichTrbParam.h" -#include "CbmRichTrbDigi.h" -#include "CbmTrbRawMessage.h" -#include "CbmTrbCalibrator.h" - -// Uncomment if you want to have excessive printout (do not execute on many events, may produce Gb's of output) -//#define DEBUGPRINT - -CbmTrbEdgeMatcher::CbmTrbEdgeMatcher() - : FairTask(), - fTrbRawHits(NULL), - fRichTrbDigi(new TClonesArray("CbmRichTrbDigi", 10)), - tdcIdToStoredEdges(), - fTrBuf(), - fMultiCounter(0), - fDrawHist(kFALSE), - fhTtimeMinusLtime(), - fhTtimeMinusLtimeCH(), - fhMultiDist() -{ -} - -CbmTrbEdgeMatcher::~CbmTrbEdgeMatcher() -{ -} - -InitStatus CbmTrbEdgeMatcher::Init() -{ - FairRootManager* manager = FairRootManager::Instance(); - fTrbRawHits = (TClonesArray*)manager->GetObject("CbmTrbRawMessage"); - if (NULL == fTrbRawHits) { Fatal("CbmTrbEdgeMatcher","No CbmTrbRawMessage array!"); } - - manager->Register("CbmRichTrbDigi", "RICH TRB leading-trailing edge pairs", fRichTrbDigi, IsOutputBranchPersistent("CbmRichTrbDigi")); - - if (fDrawHist) - { - CbmRichTrbParam* param = CbmRichTrbParam::Instance(); - - TString histoName; - TString histoTitle; - - for (UInt_t i=0; i<68; i++) { - histoName.Form("fhTtimeMinusLtime - TDC %04x", param->IntegerToTDCid(i)); - histoTitle.Form("(Trailing time - Leading time) for TDC %04x", param->IntegerToTDCid(i)); - fhTtimeMinusLtime[i] = new TH1D(histoName, histoTitle, 4000, -50., 50.); - } - - for (UInt_t i=0; i<16; i++) { - histoName.Form("fhTtimeMinusLtime - TDC %04x CH%d - CH%d", DEBUGTDCID, i*2+2, i*2+1); - histoTitle.Form("(Trailing time - Leading time) for TDC %04x CH%d - CH%d", DEBUGTDCID, i*2+2, i*2+1); - fhTtimeMinusLtimeCH[i] = new TH1D(histoName, histoTitle, 4000, -50., 50.); - } - } - - fhMultiDist = new TH1D("123", "234", 20*(POSITIVEPAIRWINDOW+NEGATIVEPAIRWINDOW), -NEGATIVEPAIRWINDOW, POSITIVEPAIRWINDOW); - - return kSUCCESS; -} - -void CbmTrbEdgeMatcher::Exec(Option_t* /*option*/) -{ - CbmRichTrbParam* param = CbmRichTrbParam::Instance(); - - for (Int_t i=0; i<fTrbRawHits->GetEntries(); i++) { // for loop over the input raw hits - CbmTrbRawMessage* curTrbRawHit = static_cast<CbmTrbRawMessage*>(fTrbRawHits->At(i)); - - UInt_t tdcId = curTrbRawHit->GetSourceAddress(); - UInt_t channel = curTrbRawHit->GetChannelID(); - UInt_t fine = curTrbRawHit->GetTDCfine(); - UInt_t coarse = curTrbRawHit->GetTDCcoarse(); - UInt_t epoch = curTrbRawHit->GetEpochMarker(); -// Double_t corr = curTrbRawHit->GetCorr(); - - if (param->IsSyncChannel(channel)) { // SYNCH MESSAGE PROCESSING - - //TODO implement - - Double_t timestamp = GetFullTime(tdcId, channel, epoch, coarse, fine) /*+ corr*/; - - // This is channel zero, we suppose that here only leading edge is coming, so write an 'only-leading-edge' RichTrbDigi. - // Set channel to 0xffffffff if the edge is unavailable - - // Create leading-edge-only sync digi - new( (*fRichTrbDigi)[fRichTrbDigi->GetEntriesFast()] ) - CbmRichTrbDigi(tdcId, kTRUE, kFALSE, channel, 0xffffffff, timestamp, 0.0); - - } else if (param->IsLeadingEdgeChannel(channel)) { // LEADING EDGE PROCESSING - -#ifdef DEBUGPRINT - Double_t timestamp = GetFullTime(tdcId, channel, epoch, coarse, fine) /*+ corr*/; - printf ("Processing leading edge. tdc 0x00%x ch %d %f\n", tdcId, channel, timestamp); -#endif - - //FIXME -/* - if (tdcId == 0x0110 || tdcId == 0x0111) { - this->CreateLeadingEdgeOnlyDigi(*curTrbRawHit); - } -*/ - this->AddPossibleLeadingEdge(*curTrbRawHit); - - } else { // TRAILING EDGE PROCESSING - - // LEADING-TRAILING edges matching - -#ifdef DEBUGPRINT - Double_t timestamp = GetFullTime(tdcId, channel, epoch, coarse, fine) /*+ corr*/; - printf ("Processing trailing edge. tdc 0x00%x ch %d %f\n", tdcId, channel, timestamp); -#endif - - //FIXME -/* - if (tdcId == 0x0110 || tdcId == 0x0111) { - // Create trailing-edge-only digi - new( (*fRichTrbDigi)[fRichTrbDigi->GetEntriesFast()] ) - CbmRichTrbDigi(tdcId, kFALSE, kTRUE, 0xffffffff, channel, 0.0, timestamp); - } -*/ - - UInt_t searchedLchannel = param->GetCorrespondingLeadingEdgeChannel(channel, tdcId); - std::pair<UInt_t, CbmTrbRawMessage> foundLedge = this->FindLeadingEdge(tdcId, searchedLchannel, *curTrbRawHit); - - if (foundLedge.first != 0xffffffff) // corresponding leading edge found - { - - UInt_t lchannel = foundLedge.second.GetChannelID(); - UInt_t lfine = foundLedge.second.GetTDCfine(); - UInt_t lcoarse = foundLedge.second.GetTDCcoarse(); -// Double_t lcorr = foundLedge.second.GetCorr(); - - Double_t tfullTime = GetFullTime(tdcId, channel, epoch, coarse, fine) /*+ corr*/; - Double_t lfullTime = GetFullTime(tdcId, lchannel, foundLedge.first, lcoarse, lfine) /*+ lcorr*/; - - if (fDrawHist) { - fhTtimeMinusLtime[param->TDCidToInteger(tdcId)]->Fill(tfullTime - lfullTime); - if (tdcId == DEBUGTDCID) fhTtimeMinusLtimeCH[(channel/2)-1]->Fill(tfullTime - lfullTime); - } - - if (tfullTime - lfullTime < 0.) { - // negative time-over-threshold in the found pair - } - - // Create both-edges digi - new( (*fRichTrbDigi)[fRichTrbDigi->GetEntriesFast()] ) - CbmRichTrbDigi(tdcId, kTRUE, kTRUE, lchannel, channel, lfullTime, tfullTime); - -#ifdef DEBUGPRINT - printf("PAIR\t\tToT=%f\n", tfullTime - lfullTime); - printf(" --- LEAD - tdc %x ch %d epoch %08x coarse %08x fine %08x\n", tdcId, lchannel, foundLedge.first, lcoarse, lfine); - printf(" --- TRAIL - tdc %x ch %d epoch %08x coarse %08x fine %08x\n", tdcId, channel, epoch, coarse, fine); -#endif - - } else { // corresponding leading edge not found - - fTrBuf.push_back(curTrbRawHit); - - } - - } // TYPE OF THE EDGE - - } // for loop over the input raw hits - - for (auto iter : fTrBuf) { - - UInt_t tdcId = iter->GetSourceAddress(); - UInt_t channel = iter->GetChannelID(); - UInt_t fine = iter->GetTDCfine(); - UInt_t coarse = iter->GetTDCcoarse(); - UInt_t epoch = iter->GetEpochMarker(); - //Double_t corr = iter->GetCorr(); - -// Double_t fullT = GetFullTime(tdcId, channel, epoch, coarse, fine) /*+ corr*/; - - //printf ("POSTPROCESSING EVENT: tdc 0x00%x ch %d time=%f\n", tdcId, channel, fullT); - - // Try to find the leading edge again - now in he buffer, which was formed during the first run - UInt_t searchedLchannel = param->GetCorrespondingLeadingEdgeChannel(channel, tdcId); - std::pair<UInt_t, CbmTrbRawMessage> foundLedge = this->FindLeadingEdge(tdcId, searchedLchannel, *iter); - - if (foundLedge.first != 0xffffffff) // corresponding leading edge found - { - //printf("FOUND!!!\n"); - - UInt_t lchannel = foundLedge.second.GetChannelID(); - UInt_t lfine = foundLedge.second.GetTDCfine(); - UInt_t lcoarse = foundLedge.second.GetTDCcoarse(); -// Double_t lcorr = foundLedge.second.GetCorr(); - - Double_t tfullTime = GetFullTime(tdcId, channel, epoch, coarse, fine) /*+ corr*/; - Double_t lfullTime = GetFullTime(tdcId, lchannel, foundLedge.first, lcoarse, lfine) /*+ lcorr*/; - - if (fDrawHist) { - fhTtimeMinusLtime[param->TDCidToInteger(tdcId)]->Fill(tfullTime - lfullTime); - if (tdcId == DEBUGTDCID) fhTtimeMinusLtimeCH[(channel/2)-1]->Fill(tfullTime - lfullTime); - } - - // Create both-edges digi - new( (*fRichTrbDigi)[fRichTrbDigi->GetEntriesFast()] ) - CbmRichTrbDigi(tdcId, kTRUE, kTRUE, lchannel, channel, lfullTime, tfullTime); - -#ifdef DEBUGPRINT - printf("PAIR\t\tToT=%f\n", tfullTime - lfullTime); - printf(" --- LEAD - tdc %x ch %d epoch %08x coarse %08x fine %08x\n", tdcId, lchannel, foundLedge.first, lcoarse, lfine); - printf(" --- TRAIL - tdc %x ch %d epoch %08x coarse %08x fine %08x\n", tdcId, channel, epoch, coarse, fine); -#endif - - } else { - //printf("EDGE NOT FOUND!!! %x\tch %d\n", tdcId, channel); - - Double_t timestamp = GetFullTime(tdcId, channel, epoch, coarse, fine); //+ corr - - // Create trailing-edge-only digi - new( (*fRichTrbDigi)[fRichTrbDigi->GetEntriesFast()] ) - CbmRichTrbDigi(tdcId, kFALSE, kTRUE, 0xffffffff, channel, 0.0, timestamp); - -#ifdef DEBUGPRINT - printf("TRAILING ONLY\n"); - printf(" --- TRAIL - tdc %x ch %d epoch %08x coarse %08x fine %08x\n", tdcId, channel, epoch, coarse, fine); -#endif - - } - - } - - fTrBuf.clear(); - -} - -void CbmTrbEdgeMatcher::FinishEvent() -{ - fRichTrbDigi->Clear(); -} - -void CbmTrbEdgeMatcher::FinishTask() -{ - LOG(info) << fMultiCounter << " cases with multiple leading edges within time window."; - - UInt_t v_numOfStoredEdges=0; - - for (UInt_t tdcId=0x0010; tdcId<=0x0013; tdcId++) { - - std::map< UInt_t, std::vector< std::pair< UInt_t, CbmTrbRawMessage > >* >::iterator tdcIdToStoredEdgesI; - tdcIdToStoredEdgesI = tdcIdToStoredEdges.find(tdcId); - - if (tdcIdToStoredEdgesI != tdcIdToStoredEdges.end()) { - std::vector< std::pair< UInt_t, CbmTrbRawMessage > >* PerTDCbuffer; - PerTDCbuffer = tdcIdToStoredEdgesI->second; - for (unsigned int v_channel=0; v_channel<=32; v_channel++) { - v_numOfStoredEdges += PerTDCbuffer[v_channel].size(); - } - } - - } - LOG(info) << "Leftovers in the pair-matching buffers: " << v_numOfStoredEdges; - - //fhMultiDist->Draw(); - - this->DrawDebugHistos(); -} - -void CbmTrbEdgeMatcher::AddPossibleLeadingEdge(CbmTrbRawMessage rawMessage) -{ - UInt_t tdcId = rawMessage.GetSourceAddress(); - UInt_t lChannel = rawMessage.GetChannelID(); - UInt_t lEpoch = rawMessage.GetEpochMarker(); - - // Find the buffer for the given channel. - // If no yet - create it. - std::map< UInt_t, std::vector< std::pair< UInt_t, CbmTrbRawMessage > >* >::iterator tdcIdToStoredEdgesI; - tdcIdToStoredEdgesI = tdcIdToStoredEdges.find(tdcId); - if (tdcIdToStoredEdgesI == tdcIdToStoredEdges.end()) - { - tdcIdToStoredEdges.insert( std::pair< UInt_t, std::vector< std::pair< UInt_t, CbmTrbRawMessage > >* >(tdcId, new std::vector< std::pair< UInt_t, CbmTrbRawMessage > >[33]) ); - tdcIdToStoredEdgesI = tdcIdToStoredEdges.find(tdcId); - } - - // Select the sub-buffer corresponding to the channel and add an entry there. - std::vector< std::pair< UInt_t, CbmTrbRawMessage > >* PerTDCbuffer; - PerTDCbuffer = tdcIdToStoredEdgesI->second; - PerTDCbuffer[lChannel].push_back(std::pair<UInt_t, CbmTrbRawMessage>(lEpoch, rawMessage)); - -#ifdef DEBUGPRINT - printf ("Adding leading edge tdc %x ch %d\n", tdcId, lChannel); -#endif -} - -// return found leading edge which corresponds to the given falling edge, the found instance is cleared -std::pair<UInt_t, CbmTrbRawMessage> CbmTrbEdgeMatcher::FindLeadingEdge(UInt_t tdcId, UInt_t lChannel, CbmTrbRawMessage tRawMessage) -{ - std::pair<UInt_t, CbmTrbRawMessage> foundResult; - - UInt_t tChannel = tRawMessage.GetChannelID(); - UInt_t tFine = tRawMessage.GetTDCfine(); - UInt_t tCoarse = tRawMessage.GetTDCcoarse(); - UInt_t tEpoch = tRawMessage.GetEpochMarker(); -// Double_t tCorr = tRawMessage.GetCorr(); - - Double_t tFullTime = GetFullTime(tdcId, tChannel, tEpoch, tCoarse, tFine) /*+ tCorr*/; - - std::map< UInt_t, std::vector< std::pair< UInt_t, CbmTrbRawMessage > >* >::iterator tdcIdToStoredEdgesI; - tdcIdToStoredEdgesI = tdcIdToStoredEdges.find(tdcId); - - // no entries for the given tdc is found - no need to create a 'leading-edge-only' digi. (The trailing-edge-only digi is created outside of this method.) - if (tdcIdToStoredEdgesI == tdcIdToStoredEdges.end()) { - foundResult.first = 0xffffffff; /*foundResult.second = 0xffffffff;*/ - return foundResult; - } else { - - UInt_t foundEpoch = 0xffffffff; - CbmTrbRawMessage foundWord; - - std::vector< std::pair< UInt_t, CbmTrbRawMessage > >* PerTDCbuffer; - PerTDCbuffer = tdcIdToStoredEdgesI->second; - - UInt_t numOfStoredEdges = PerTDCbuffer[lChannel].size(); - - if (numOfStoredEdges == 0) // nothing found for the given channel - no need to create a 'leading-edge-only' digi. (The trailing-edge-only digi is created outside of this method.) - { -#ifdef DEBUGPRINT - printf(" numOfStoredEdges == 0\n"); -#endif - foundResult.first = 0xffffffff; /*foundResult.second = 0xffffffff;*/ - return foundResult; - } - else if (numOfStoredEdges == 1) // only one edge is stored for the given channel. If ToT allowed - return pair, otherwise postpone until the end of the event - { - -#ifdef DEBUGPRINT - printf(" numOfStoredEdges == 1\n"); -#endif - - std::pair< UInt_t, CbmTrbRawMessage > foundPair; - - foundPair = PerTDCbuffer[lChannel].back(); - -/* - //FIXME hardcoded case for the LED - create a pair no matter what TOT is. - if (tdcId == 0x0110 && lChannel == 7) { return foundPair; } - //FIXME hardcoded case for the Laser - create a pair no matter what TOT is. - if (tdcId == 0x0110 && lChannel == 15) { return foundPair; } -*/ - - //FIXME - if (tdcId == 0x0110 || tdcId == 0x0111 || tdcId == 0x0113) { return foundPair; } - - foundEpoch = foundPair.first; - foundWord = foundPair.second; - - UInt_t foundLcoarse = foundWord.GetTDCcoarse(); - UInt_t foundLfine = foundWord.GetTDCfine(); -// Double_t foundCorr = foundWord.GetCorr(); - Double_t lFullTime = GetFullTime(tdcId, lChannel, foundEpoch, foundLcoarse, foundLfine) /*+ foundCorr*/; - - if ((tFullTime - lFullTime) < -NEGATIVEPAIRWINDOW || (tFullTime - lFullTime) > POSITIVEPAIRWINDOW) { -#ifdef DEBUGPRINT - printf("only one edge is stored for the given channel. Restricted ToT. tdc 0x00%x ch %d l=%f t=%f (TOT=%f)\n", tdcId, lChannel, lFullTime, tFullTime, (tFullTime - lFullTime)); -#endif - //// Create a digi with leading edge only (a digi with trailing edge only is created outside of this method). - //this->CreateLeadingEdgeOnlyDigi(foundWord); - foundResult.first = 0xffffffff; /*foundResult.second = 0xffffffff;*/ - return foundResult; - } else { - PerTDCbuffer[lChannel].pop_back(); - return foundPair; - } - - } - else // more than one word found - { - std::vector< std::pair< UInt_t, CbmTrbRawMessage > >::iterator PerTDCbufferI; - std::vector< std::pair< UInt_t, CbmTrbRawMessage > >::iterator foundWordIndex; - -/* - // Flush all the leading edges which were earlier than fallingEdge-NEGATIVEPAIRWINDOW - for (PerTDCbufferI = PerTDCbuffer[lChannel].begin(); PerTDCbufferI != PerTDCbuffer[lChannel].end(); ) { - foundEpoch = PerTDCbufferI->first; - foundWord = PerTDCbufferI->second; - UInt_t foundLcoarse = foundWord.GetTDCcoarse(); - UInt_t foundLfine = foundWord.GetTDCfine(); - Double_t foundLcorr = foundWord.GetCorr(); - Double_t lFullTime = GetFullTime(tdcId, lChannel, foundEpoch, foundLcoarse, foundLfine); //+ foundLcorr; - - if (lFullTime < tFullTime - POSITIVEPAIRWINDOW) { -#ifdef DEBUGPRINT - printf ("Creating leading-edge-only digi lFullTime=%f < tFullTime=%f\n", lFullTime, tFullTime); -#endif - this->CreateLeadingEdgeOnlyDigi(foundWord); - PerTDCbufferI = PerTDCbuffer[lChannel].erase(PerTDCbufferI); - } else { - ++PerTDCbufferI; - } - } -*/ - - UInt_t numWithinWindow = 0; - Double_t storedTOT = 0.; - - // Count how many leading edges in the buffer are in the allowed time window - for (PerTDCbufferI = PerTDCbuffer[lChannel].begin(); PerTDCbufferI != PerTDCbuffer[lChannel].end(); ++PerTDCbufferI) { - foundEpoch = PerTDCbufferI->first; - foundWord = PerTDCbufferI->second; - UInt_t foundLcoarse = foundWord.GetTDCcoarse(); - UInt_t foundLfine = foundWord.GetTDCfine(); -// Double_t foundLcorr = foundWord.GetCorr(); - Double_t lFullTime = GetFullTime(tdcId, lChannel, foundEpoch, foundLcoarse, foundLfine) /*+ foundLcorr*/; - - if ((tFullTime - lFullTime) >= -NEGATIVEPAIRWINDOW && (tFullTime - lFullTime) <= POSITIVEPAIRWINDOW) { - numWithinWindow++; // count - foundWordIndex = PerTDCbufferI; // store - storedTOT = tFullTime - lFullTime; // store - } - - } - -#ifdef DEBUGPRINT - printf(" numWithinWindow == %d\n", numWithinWindow); -#endif - - // If there are no leading edges within allowed time window - ("clear" everything before the current trailing edge) - // Current trailing edge and all leading edges before this trailing edge will be sent to output as separate edges. - if (numWithinWindow == 0) { - foundResult.first = 0xffffffff; /*foundResult.second = 0xffffffff;*/ - return foundResult; - - // Only one leading edge within the allowed time window is found and a) TOT>0 - Perfect case, build a pair. b) TOT<0 - allowed, build a pair - } else if (numWithinWindow == 1) { - - foundEpoch = foundWordIndex->first; - foundWord = foundWordIndex->second; - if (storedTOT >= 0.) { - #ifdef DEBUGPRINT - printf ("One edge in the window. Allowed positive TOT\n"); - #endif - } else { - #ifdef DEBUGPRINT - printf ("One edge in the window. Allowed negative TOT\n"); - #endif - } - PerTDCbuffer[lChannel].erase(foundWordIndex); - // Return epoch and data word (a pair is created outside of this method). - foundResult.first = foundEpoch; foundResult.second = foundWord; - return foundResult; - } else { - -//TODO implement - -//#ifdef DEBUGPRINT - printf ("Multiple edges in the window.\t\tTDC %x\t\tTrailing edge channel=%d\n", tdcId, tChannel); -//#endif - fMultiCounter++; - -/* - for (UInt_t i=0; i<BUFSIZE; i++) { - if (tdcIdToStoredEdgesI->second[lChannel*BUFSIZE*2 + i*2 + 1] != 0xffffffff) { - foundEpoch = tdcIdToStoredEdgesI->second[lChannel*BUFSIZE*2 + i*2 + 0]; // store epoch - foundWord = tdcIdToStoredEdgesI->second[lChannel*BUFSIZE*2 + i*2 + 1]; // store data word - - UInt_t foundLcoarse = foundWord.GetTDCcoarse(); - UInt_t foundLfine = foundWord.GetTDCfine(); - Double_t foundLcorr = foundWord.GetCorr(); - Double_t lFullTime = GetFullTime(tdcId, lChannel, foundEpoch, foundLcoarse, foundLfine) + foundLcorr; - - fhMultiDist->Fill(tFullTime - lFullTime); - - } - } -*/ - foundResult.first = 0xffffffff; //foundResult.second = 0xffffffff; - return foundResult; - } - - } - - } - -} - -void CbmTrbEdgeMatcher::CreateLeadingEdgeOnlyDigi(CbmTrbRawMessage rawMessage) -{ - // Create a digi with leading edge only - - UInt_t tdcId = rawMessage.GetSourceAddress(); - UInt_t lchannel = rawMessage.GetChannelID(); - UInt_t lepoch = rawMessage.GetEpochMarker(); - UInt_t lcoarse = rawMessage.GetTDCcoarse(); - UInt_t lfine = rawMessage.GetTDCfine(); -// Double_t lcorr = rawMessage.GetCorr(); - - Double_t timestamp = GetFullTime(tdcId, lchannel, lepoch, lcoarse, lfine) /*+ lcorr*/; - - new( (*fRichTrbDigi)[fRichTrbDigi->GetEntriesFast()] ) - CbmRichTrbDigi(tdcId, kTRUE, kFALSE, lchannel, 0xffffffff, timestamp, 0.0); - -#ifdef DEBUGPRINT - printf("LEADING ONLY\n"); - printf(" --- LEAD - tdc %x ch %d epoch %08x coarse %08x fine %08x corr %f\n", tdcId, lchannel, lepoch, lcoarse, lfine, lcorr); -#endif -} - -Double_t CbmTrbEdgeMatcher::GetFullTime(UInt_t tdcId, UInt_t channel, UInt_t epoch, UInt_t coarse, UInt_t fine) -{ - return CbmTrbCalibrator::Instance()->GetFullTime(tdcId, channel, epoch, coarse, fine); -} - -void CbmTrbEdgeMatcher::DrawDebugHistos() -{ - if (!fDrawHist) return; - - CbmRichTrbParam* param = CbmRichTrbParam::Instance(); - - TCanvas* c[17]; - for (UInt_t i=1; i<18; i++) { - - TString canvasName; - TString canvasTitle; - canvasName.Form("fhTtimeMinusLtime - TDCs %04x, %04x, %04x, %04x", param->IntegerToTDCid(i*4+0), - param->IntegerToTDCid(i*4+1), - param->IntegerToTDCid(i*4+2), - param->IntegerToTDCid(i*4+3)); - canvasTitle.Form("(Trailing time - Leading time) for TDCs %04x, %04x, %04x, %04x", - param->IntegerToTDCid(i*4+0), - param->IntegerToTDCid(i*4+1), - param->IntegerToTDCid(i*4+2), - param->IntegerToTDCid(i*4+3)); - - c[i-1] = new TCanvas(canvasName, canvasTitle, 800, 800); - c[i-1]->Divide(2, 2); - c[i-1]->cd(1); - c[i-1]->GetPad(1)->SetLogy(1); - fhTtimeMinusLtime[(i-1)*4+0]->Draw(); - c[i-1]->cd(2); - c[i-1]->GetPad(2)->SetLogy(1); - fhTtimeMinusLtime[(i-1)*4+1]->Draw(); - c[i-1]->cd(3); - c[i-1]->GetPad(3)->SetLogy(1); - fhTtimeMinusLtime[(i-1)*4+2]->Draw(); - c[i-1]->cd(4); - c[i-1]->GetPad(4)->SetLogy(1); - fhTtimeMinusLtime[(i-1)*4+3]->Draw(); - } - -/* (FU) not used - TCanvas* c2[16]; - TCanvas* c3; -*/ - - TString canvasName; - TString canvasTitle; - - canvasName.Form("fhTtimeMinusLtime - TDC %04x", DEBUGTDCID); - canvasTitle.Form("(Trailing time - Leading time) for TDC %04x", DEBUGTDCID); - new TCanvas(canvasName, canvasTitle, 800, 800); - gPad->SetLogy(1); - fhTtimeMinusLtime[param->TDCidToInteger(DEBUGTDCID)]->Draw(); - - for (UInt_t i=0; i<16; i++) { - canvasName.Form("fhTtimeMinusLtime - TDC %04x CH%d - CH%d", DEBUGTDCID, i*2+2, i*2+1); - canvasTitle.Form("(Trailing time - Leading time) for TDC %04x CH%d - CH%d", DEBUGTDCID, i*2+2, i*2+1); - - new TCanvas(canvasName, canvasTitle, 800, 800); - gPad->SetLogy(1); - fhTtimeMinusLtimeCH[i]->Draw(); - - } -} - -ClassImp(CbmTrbEdgeMatcher) diff --git a/beamtime/rich/CbmTrbEdgeMatcher.h b/beamtime/rich/CbmTrbEdgeMatcher.h deleted file mode 100644 index 28393d7d4d9f7bb9d292e2b13f62f4f279ea9e8a..0000000000000000000000000000000000000000 --- a/beamtime/rich/CbmTrbEdgeMatcher.h +++ /dev/null @@ -1,87 +0,0 @@ -#ifndef CBMTRBEDGEMATCHER_H -#define CBMTRBEDGEMATCHER_H - -#include <map> -#include <vector> - -#include "FairTask.h" - -#include "CbmTrbRawMessage.h" - -// The TDC channels of which are drawn for debug -#define DEBUGTDCID 0x0081 - -class TH1D; -class TClonesArray; - -class CbmTrbEdgeMatcher : public FairTask -{ -public: // methods - - CbmTrbEdgeMatcher(); - ~CbmTrbEdgeMatcher(); - - virtual InitStatus Init(); - virtual void Exec(Option_t* option); - virtual void FinishEvent(); - virtual void FinishTask(); - - void SetDrawHits(Bool_t toDraw = kTRUE) { fDrawHist = toDraw; } - -private: // methods - - // Add the leading edge into the buffer - void AddPossibleLeadingEdge(CbmTrbRawMessage rawMessage); - - // Return: pair, first - epoch, second - data word (with channel, coarse and fine) - std::pair<UInt_t, CbmTrbRawMessage> FindLeadingEdge(UInt_t tdcId, UInt_t lChannel, CbmTrbRawMessage tRawMessage); - - // Create an output digi with only leading edge - void CreateLeadingEdgeOnlyDigi(CbmTrbRawMessage rawMessage); - - // Interface to the Calibrator::GetFullTime - Double_t GetFullTime(UInt_t tdcId, UInt_t channel, UInt_t epoch, UInt_t coarse, UInt_t fine); - - void DrawDebugHistos(); - -private: // data members - - // Input raw hits from the unpacker - TClonesArray* fTrbRawHits; - - // Output pairs (if possible) of leading and trailing edges - TClonesArray* fRichTrbDigi; // class CbmRichTrbDigi - - std::map< UInt_t, std::vector< std::pair< UInt_t, CbmTrbRawMessage > >* > tdcIdToStoredEdges; - - // For statistics - maximum number of consequent leading edges found in the run - //UInt_t fMaxBufFill; - - - // Buffer for trailing edges - std::vector<CbmTrbRawMessage*> fTrBuf; - - - // For statistics - number of cases when there were several leading edges within time window - UInt_t fMultiCounter; - - // --- Debug histograms - - // If true - draw debug histograms - Bool_t fDrawHist; - - // For each possible TDCid - TH1D* fhTtimeMinusLtime[68]; - - // For all the channels of a single certain TDC with id DEBUGTDCID - TH1D* fhTtimeMinusLtimeCH[16]; - - TH1D* fhMultiDist; - - CbmTrbEdgeMatcher(const CbmTrbEdgeMatcher&); - CbmTrbEdgeMatcher operator=(const CbmTrbEdgeMatcher&); - - ClassDef(CbmTrbEdgeMatcher,1) -}; - -#endif // CBMTRBEDGEMATCHER_H diff --git a/beamtime/rich/CbmTrbIterator.h b/beamtime/rich/CbmTrbIterator.h deleted file mode 100644 index 5dac9d9e779b1bd90b85247c3284227160ee5903..0000000000000000000000000000000000000000 --- a/beamtime/rich/CbmTrbIterator.h +++ /dev/null @@ -1,90 +0,0 @@ -#ifndef CBMTRBITERATOR_H -#define CBMTRBITERATOR_H - -#include "CbmRawEvent.h" -#include "CbmRawSubEvent.h" - -class CbmTrbIterator -{ -private: - void* fData; - size_t fSize; - - CbmRawEvent* fCurrentEvent; - - CbmRawSubEvent* fCurrentSubEvent; - -public: - - CbmTrbIterator(void* data, size_t size): - fData(data), - fSize(size), - fCurrentEvent(NULL), - fCurrentSubEvent(NULL) - { - ; - } - - ~CbmTrbIterator() - { - ; - } - - CbmRawEvent* NextEvent() - { - fCurrentSubEvent= NULL; - if (fCurrentEvent == NULL){ - fCurrentEvent = new CbmRawEvent(fData); - return fCurrentEvent; - } - void* nextEventPointer = (void*)((char*)(fCurrentEvent->fData) + fCurrentEvent->PaddedSize()); - if ( static_cast<size_t>((char*)nextEventPointer - (char*)fData) >= fSize ) return NULL; - - if (fCurrentEvent != NULL) delete fCurrentEvent; - fCurrentEvent = new CbmRawEvent(nextEventPointer); - return fCurrentEvent; - } - - CbmRawEvent* CurrentEvent() const - { - return fCurrentEvent; - } - - CbmRawSubEvent* NextSubEvent() - { - if (fCurrentEvent == NULL) return NULL; - if (fCurrentEvent->Data() == fCurrentEvent->End()){ - return NULL; - } - - if (fCurrentSubEvent == NULL ){ - - fCurrentSubEvent = new CbmRawSubEvent(fCurrentEvent->Data()); - return fCurrentSubEvent; - } - - uint32_t size = fCurrentSubEvent->Size(); - uint32_t alignment = fCurrentEvent->Alignment(); - size_t paddedSize = (size & (alignment - 1)) ? (size & ~(alignment - 1)) + alignment : size; - void* nextSubEventPointer = (void *) ((char *) fCurrentSubEvent->fData + paddedSize); - if (nextSubEventPointer < fCurrentEvent->End()) { - if (fCurrentSubEvent != NULL) delete fCurrentSubEvent; - fCurrentSubEvent = new CbmRawSubEvent(nextSubEventPointer); - return fCurrentSubEvent; - } else { - return NULL; - } - } - - CbmRawSubEvent* currentSubEvent() const - { - return fCurrentSubEvent; - } - - private: - - CbmTrbIterator(const CbmTrbIterator&); - CbmTrbIterator operator=(const CbmTrbIterator&); -}; - -#endif // CBMTRBITERATOR_H diff --git a/beamtime/rich/CbmTrbOutputHit.h b/beamtime/rich/CbmTrbOutputHit.h deleted file mode 100644 index 9459694887d207df8ae0d76e95f959ce668e2e2b..0000000000000000000000000000000000000000 --- a/beamtime/rich/CbmTrbOutputHit.h +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef CBMTRBOUTPUTHIT_H -#define CBMTRBOUTPUTHIT_H - -#include "TObject.h" - -class CbmTrbOutputHit : public TObject -{ -public: - - CbmTrbOutputHit(): - fTdcId(0), - fLeadingChannel(0), - fTrailingChannel(0), - fLeadingFullTime(0.), - fTrailingFullTime(0.) - { - - } - - CbmTrbOutputHit (UShort_t tdc, UShort_t lChannel, Double_t lFullTime, UShort_t tChannel, Double_t tFullTime) : - fTdcId(tdc), - fLeadingChannel(lChannel), - fTrailingChannel(tChannel), - fLeadingFullTime(lFullTime), - fTrailingFullTime(tFullTime) - { - - } - UShort_t GetTdc() const {return fTdcId;} - UShort_t GetLChannel() const {return fLeadingChannel;} - Double_t GetLFullTime () const { return fLeadingFullTime;} - UShort_t GetTChannel() const {return fTrailingChannel;} - Double_t GetTFullTime () const { return fTrailingFullTime;} - Double_t GetDeltaT() const {return fTrailingFullTime - fLeadingFullTime;} - - void SetLeadingFullTime (Double_t fullTime) { fLeadingFullTime = fullTime; } - -private: - - UShort_t fTdcId; - UShort_t fLeadingChannel; - UShort_t fTrailingChannel; - Double_t fLeadingFullTime; // Full time stamp in ns - Double_t fTrailingFullTime; // Full time stamp in ns - -}; - - - -class CbmTrbOutputHitLeadingFullTimeComparatorLess: - public std::binary_function< - const CbmTrbOutputHit*, - const CbmTrbOutputHit*, - bool> -{ - public: - - virtual ~CbmTrbOutputHitLeadingFullTimeComparatorLess(){;} - - bool operator()( - const CbmTrbOutputHit* hit1, - const CbmTrbOutputHit* hit2) const - { - return hit1->GetLFullTime() < hit2->GetLFullTime(); - } -}; - -#endif - diff --git a/beamtime/rich/CbmTrbRawHit.h b/beamtime/rich/CbmTrbRawHit.h deleted file mode 100644 index 5b4b561b4ade98d039488689c1ff31e08eed5f6a..0000000000000000000000000000000000000000 --- a/beamtime/rich/CbmTrbRawHit.h +++ /dev/null @@ -1,78 +0,0 @@ -#ifndef CBMTRBRAWHIT_H -#define CBMTRBRAWHIT_H - -#include "TObject.h" -/* - * TrbRawHit consists of two fronts - leading and trailing. - * Time interval between the leading and the trailing edges indicated the value of the hit. - */ - -class CbmTrbRawHit: public TObject -{ -public: - CbmTrbRawHit () : - fTdcId (0), - fLeadingChannel (0), - fLeadingEpoch(0), - fLeadingCoarseTime(0), - fLeadingFineTime(0), - fLeadingFineTimeCalibCorr(0.), - fTrailingChannel(0), - fTrailingEpoch(0), - fTrailingCoarseTime(0), - fTrailingFineTime(0), - fTrailingFineTimeCalibCorr(0.) - { - } - - CbmTrbRawHit (UShort_t tdc, - UShort_t leadingChannel, UInt_t leadingEpoch, UShort_t leadingCoarseTime, UShort_t leadingFineTime, - UShort_t trailingChannel, UInt_t trailingEpoch, UShort_t trailingCoarseTime, UShort_t trailingFineTime) : - fTdcId (tdc), - fLeadingChannel(leadingChannel), - fLeadingEpoch(leadingEpoch), - fLeadingCoarseTime(leadingCoarseTime), - fLeadingFineTime(leadingFineTime), - fLeadingFineTimeCalibCorr(0.), - fTrailingChannel(trailingChannel), - fTrailingEpoch(trailingEpoch), - fTrailingCoarseTime(trailingCoarseTime), - fTrailingFineTime(trailingFineTime), - fTrailingFineTimeCalibCorr(0.) - { - } - - UShort_t GetTdc() const {return this->fTdcId;} - - UShort_t GetLChannel() const {return this->fLeadingChannel;} - UInt_t GetLEpoch() const {return this->fLeadingEpoch;} - UShort_t GetLCTime() const {return this->fLeadingCoarseTime;} - UShort_t GetLFTime() const {return this->fLeadingFineTime;} - Double_t GetLeadingTimeCorr() const {return this->fLeadingFineTimeCalibCorr;} - - UShort_t GetTChannel() const {return this->fTrailingChannel;} - UInt_t GetTEpoch() const {return this->fTrailingEpoch;} - UShort_t GetTCTime() const {return this->fTrailingCoarseTime;} - UShort_t GetTFTime () const {return this->fTrailingFineTime;} - Double_t GetTrailingTimeCorr () const {return this->fTrailingFineTimeCalibCorr;} - - void SetLeadingTimeCorr (Double_t LFTimeCalibrCorr) {this->fLeadingFineTimeCalibCorr = LFTimeCalibrCorr;} - void SetTrailingTimeCorr (Double_t TFTimeCalibrCorr){this->fTrailingFineTimeCalibCorr = TFTimeCalibrCorr;} - -private: - UShort_t fTdcId; // 16 bit (as max) - - UShort_t fLeadingChannel; - UInt_t fLeadingEpoch; // 28 bit - UShort_t fLeadingCoarseTime; // 11 bit - UShort_t fLeadingFineTime; // 10 bit - Double_t fLeadingFineTimeCalibCorr; - - UShort_t fTrailingChannel; - UInt_t fTrailingEpoch; // 28 bit - UShort_t fTrailingCoarseTime; // 11 bit - UShort_t fTrailingFineTime; // 10 bit - Double_t fTrailingFineTimeCalibCorr; -}; - -#endif // CBMTRBRAWHIT_H diff --git a/beamtime/roclight/CMakeLists.txt b/beamtime/roclight/CMakeLists.txt deleted file mode 100644 index 5e919bb44c7d47b35a305c4204460b9e22c021b6..0000000000000000000000000000000000000000 --- a/beamtime/roclight/CMakeLists.txt +++ /dev/null @@ -1,66 +0,0 @@ -# Create a library called "libCbmFlibReader" which includes the source files given in -# the array . -# The extension is already found. Any number of sources could be listed here. - -Set(INCLUDE_DIRECTORIES - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/mbs - ${CMAKE_CURRENT_SOURCE_DIR}/src_mbs - ${CMAKE_CURRENT_SOURCE_DIR}/roc - ${CMAKE_CURRENT_SOURCE_DIR}/src_roc - ${CMAKE_CURRENT_SOURCE_DIR}/feet -) - -Set(SYSTEM_INCLUDE_DIRECTORIES - ${BASE_INCLUDE_DIRECTORIES} - ${Boost_INCLUDE_DIR} -) - -Include_Directories(${INCLUDE_DIRECTORIES}) -Include_Directories(SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES}) - -Set(LINK_DIRECTORIES - ${ROOT_LIBRARY_DIR} - ${FAIRROOT_LIBRARY_DIR} -) - -Link_Directories( - ${LINK_DIRECTORIES} -) - -Set(SRCS - src_mbs/MbsTypeDefs.cxx - src_mbs/LmdFile.cxx - src_mbs/LmdInput.cxx - src_roc/Message.cxx - src_roc/Board.cxx - src_roc/Iterator.cxx - src_roc/OperList.cxx - src_roc/FileInput.cxx - src_roc/Factory.cxx -) - -Set(HEADERS - mbs/LmdTypeDefs.h - mbs/MbsTypeDefs.h - mbs/LmdFile.h - mbs/LmdInput.h - roc/Message.h - roc/Board.h - roc/Iterator.h - roc/OperList.h - roc/FileInput.h - roc/Factory.h -) - -Set(DEPENDENCIES - Base -) - -If(_UINT8_T_EXIST) - Add_Definitions(-DHAVE_UINT8_T_HEADER_FILE) -EndIf() - -Set(LIBRARY_NAME CbmRocLight) - -GENERATE_LIBRARY() diff --git a/beamtime/roclight/RocLibLinkDef.h b/beamtime/roclight/RocLibLinkDef.h deleted file mode 100644 index c853338b1fad1df53ae26a4573306ce7326c6a7e..0000000000000000000000000000000000000000 --- a/beamtime/roclight/RocLibLinkDef.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifdef __CINT__ - -#pragma link off all globals; -#pragma link off all classes; -#pragma link off all functions; - -#pragma link C++ class mbs::LmdFile -#pragma link C++ class mbs::LmdInput - -#pragma link C++ class roc::Message; -#pragma link C++ class roc::BoardConnector; -#pragma link C++ class roc::Board; -#pragma link C++ class roc::Iterator; -#pragma link C++ class roc::FileInput; -#pragma link C++ class roc::Factory; - -#pragma link C++ enum roc::MessageFormat; -#pragma link C++ enum roc::MessageTypes; -#pragma link C++ enum roc::SysMessageTypes; -#pragma link C++ enum roc::SysMessageUserTypes; -#pragma link C++ enum roc::MessagePrintMask; -#pragma link C++ enum roc::ClientRole; -#pragma link C++ enum roc::ERocMbsTypes; -#pragma link C++ enum roc::ERocBufferTypes; -#pragma link C++ enum roc::ETransportKinds; -#pragma link C++ enum roc::EFrontendKinds; -#pragma link C++ enum roc::EBackendKinds; - -#endif diff --git a/beamtime/roclight/feet/defines_feet.h b/beamtime/roclight/feet/defines_feet.h deleted file mode 100644 index e0f7cc6d3602b4ec95e9e5b056b4650359fc7b65..0000000000000000000000000000000000000000 --- a/beamtime/roclight/feet/defines_feet.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef ROC_DEFINES_FEET_H -#define ROC_DEFINES_FEET_H - -#define ROC_FEET_HWV 0x500000 // r, 32 bit - -#define ROC_FEET_RADTOL 0x500004 // r, 1 bit - -#define ROC_FEET_NR_OF_FEETS 0x500008 // r, 8 bit - -#define ROC_FEET_RESET 0x500010 // w, 0 bit - -#define ROC_FEET_FIFO_RESET 0x500014 // w, 1 bit - -#define ROC_FEET_SAMPLE_FALLING_EDGE 0x500200 // r/w, 1 bit - -#define ROC_FEET_EPOCH250_EN 0x500204 // r/w, 1 bit - -#define ROC_FEET_RECEIVE_MASK 0x501000 // r/w, 32 bit - -#define ROC_FEET_TRANSMIT_MASK 0x501004 // r/w, 32 bit - -#define ROC_FEET_DATAGEN_MASK 0x501008 // r/w, 32 bit - -#define ROC_FEET_DATAGEN_INIT 0x50100C // r/w, 32 bit - -#define ROC_FEET_DATAGEN_EN 0x501010 // w, 1 bit - -#define ROC_FEET_CMD_TO_FEET 0x510000 // w, 8 bit - -#endif diff --git a/beamtime/roclight/mbs/LmdFile.h b/beamtime/roclight/mbs/LmdFile.h deleted file mode 100644 index 4d5124553e300391911490083e7c65d98f78f3d5..0000000000000000000000000000000000000000 --- a/beamtime/roclight/mbs/LmdFile.h +++ /dev/null @@ -1,83 +0,0 @@ -/************************************************************ - * The Data Acquisition Backbone Core (DABC) * - ************************************************************ - * Copyright (C) 2009 - * - * GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * Planckstr. 1, 64291 Darmstadt, Germany * - * Contact: http://dabc.gsi.de * - ************************************************************ - * This software can be used under the GPL license * - * agreements as stated in LICENSE.txt file * - * which is part of the distribution. * - ************************************************************/ - -#ifndef MBS_LmdFile -#define MBS_LmdFile - -#ifndef MBS_LmdTypeDefs -#include "LmdTypeDefs.h" -#endif - -#ifndef MBS_MbsTypeDefs -#include "MbsTypeDefs.h" -#endif - -namespace mbs { - - class LmdFile { - protected: - enum EMode { mNone, mWrite, mRead, mError }; - - EMode fMode; - void *fControl; - uint32_t fLastError; - - public: - LmdFile(); - virtual ~LmdFile(); - - uint32_t LastError() const { return fLastError; } - - /** Open file with specified name for writing */ - bool OpenWrite(const char* fname, uint32_t buffersize = 0x10000); - - /** Opened file for reading. Internal buffer required - * when data read partially and must be kept there. */ - bool OpenRead(const char* fname, uint32_t buffersize = 0x10000); - - bool IsWriteMode() const { return fMode == mWrite; } - bool IsReadMode() const { return fMode == mRead; } - - void Close(); - - /** Write one or several elements into the file. - * Each element must contain mbs::Header with correctly set size - */ - bool WriteElements(mbs::Header* hdr, unsigned num = 1); - - /** Read next element from file. File must be opened by method OpenRead(), - * Data will be copied first in internal buffer and than provided to user. - */ - mbs::Header* ReadElement(); - - /** Read one or several elements to provided user buffer - * When called, bufsize should has available buffer size, - * after call contains actual size read. - * Returns read number of events. */ - unsigned int ReadBuffer(void* buf, uint32_t& bufsize); - - /** Write one or several events to the file. - * Same as WriteElements */ - bool WriteEvents(EventHeader* hdr, unsigned num = 1); - - /** Read next event from file - same as ReadElement. */ - mbs::EventHeader* ReadEvent(); - - private: - LmdFile(const LmdFile&); - LmdFile& operator=(const LmdFile&); - }; - -} // end of namespace - -#endif diff --git a/beamtime/roclight/mbs/LmdInput.h b/beamtime/roclight/mbs/LmdInput.h deleted file mode 100644 index 32aa4a27dc5c379c6b34267a560e4a84b7d870dd..0000000000000000000000000000000000000000 --- a/beamtime/roclight/mbs/LmdInput.h +++ /dev/null @@ -1,77 +0,0 @@ -/************************************************************ - * The Data Acquisition Backbone Core (DABC) * - ************************************************************ - * Copyright (C) 2009 - * - * GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * Planckstr. 1, 64291 Darmstadt, Germany * - * Contact: http://dabc.gsi.de * - ************************************************************ - * This software can be used under the GPL license * - * agreements as stated in LICENSE.txt file * - * which is part of the distribution. * - ************************************************************/ - -#ifndef MBS_LmdInput -#define MBS_LmdInput - -/* *** PAL edit: Avoid using DABC data types, use ROOT ones instead *** -#ifndef DABC_DataIO -#include "dabc/DataIO.h" -#endif - -#ifndef DABC_Object -#include "dabc/Object.h" -#endif - ***************** */ -#include "TList.h" // *** PAL edit, from CbmSourceLmdNew *** -#include "TString.h" // *** PAL edit, from CbmSourceLmdNew *** -#include "TObjString.h" // *** PAL edit, from CbmSourceLmdNew *** - -#ifndef MBS_LmdFile -#include "mbs/LmdFile.h" -#endif - -namespace mbs { - -// class LmdInput : public dabc::DataInput { - class LmdInput { - public: - LmdInput(const char* fname = 0, uint32_t bufsize = 0x10000); - virtual ~LmdInput(); - -/* *** PAL edit: We don't use the xml config in CbmRoot *** - virtual bool Read_Init(const dabc::WorkerRef& wrk, const dabc::Command& cmd); - virtual bool Read_Init(); - ***************** */ - - bool Init(); - - void PrintFileList(); // *** PAL edit, new info method *** - -/* *** PAL edit: Run offline with LMD file and without DABC *** - virtual unsigned Read_Size(); - virtual unsigned Read_Complete(dabc::Buffer& buf); - ***************** */ - - // alternative way to read mbs events from LmdInput - no any dabc buffer are used - mbs::EventHeader* ReadEvent(); - - protected: - bool CloseFile(); - - bool OpenNextFile(); - - std::string fFileName; - uint32_t fBufferSize; - -// dabc::Object* fFilesList; *** PAL edit *** - TList fInputFileList; // *** PAL edit, from CbmSourceLmdNew *** - - mbs::LmdFile fFile; - std::string fCurrentFileName; - uint64_t fCurrentRead; - }; - -} - -#endif diff --git a/beamtime/roclight/mbs/LmdTypeDefs.h b/beamtime/roclight/mbs/LmdTypeDefs.h deleted file mode 100644 index f7798004eab79dff10efb23839322db7fdbb2596..0000000000000000000000000000000000000000 --- a/beamtime/roclight/mbs/LmdTypeDefs.h +++ /dev/null @@ -1,62 +0,0 @@ -/************************************************************ - * The Data Acquisition Backbone Core (DABC) * - ************************************************************ - * Copyright (C) 2009 - * - * GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * Planckstr. 1, 64291 Darmstadt, Germany * - * Contact: http://dabc.gsi.de * - ************************************************************ - * This software can be used under the GPL license * - * agreements as stated in LICENSE.txt file * - * which is part of the distribution. * - ************************************************************/ - -#ifndef MBS_LmdTypeDefs -#define MBS_LmdTypeDefs - -#include <stdint.h> - -#ifdef __APPLE__ -//on MacOS endian.h is in a differnt directory -#include <machine/endian.h> -#else -#include <endian.h> -#endif - -namespace mbs { - -#if BYTE_ORDER == LITTLE_ENDIAN -#define MBS_TYPE(typ, subtyp) ((int32_t) typ | ((int32_t) subtyp) << 16) -#else -#define MBS_TYPE(typ, subtyp) ((int32_t) subtyp | ((int32_t) typ) << 16) -#endif - -#pragma pack(push, 1) - - struct Header { - uint32_t iWords; // data words + 2 - union { - struct { -#if BYTE_ORDER == LITTLE_ENDIAN - uint16_t i_type; - uint16_t i_subtype; -#else - uint16_t i_subtype; - uint16_t i_type; -#endif - }; - uint32_t iType; - }; - - // FullSize - size of data with header (8 bytes) - inline uint32_t FullSize() const { return 8 + iWords*2; } - inline void SetFullSize(uint32_t sz) { iWords = (sz - 8) /2; } - - inline uint32_t Type() const { return iType; } - }; - -#pragma pack(pop) - -} - -#endif diff --git a/beamtime/roclight/mbs/MbsTypeDefs.h b/beamtime/roclight/mbs/MbsTypeDefs.h deleted file mode 100644 index 47c2cc8e8a35bfc20d28dc755804001b0a7ea3a6..0000000000000000000000000000000000000000 --- a/beamtime/roclight/mbs/MbsTypeDefs.h +++ /dev/null @@ -1,232 +0,0 @@ -/************************************************************ - * The Data Acquisition Backbone Core (DABC) * - ************************************************************ - * Copyright (C) 2009 - * - * GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * Planckstr. 1, 64291 Darmstadt, Germany * - * Contact: http://dabc.gsi.de * - ************************************************************ - * This software can be used under the GPL license * - * agreements as stated in LICENSE.txt file * - * which is part of the distribution. * - ************************************************************/ - -#ifndef MBS_MbsTypeDefs -#define MBS_MbsTypeDefs - -#ifndef MBS_LmdTypeDefs -#include "LmdTypeDefs.h" -#endif - -namespace mbs { - - enum EMbsTriggerTypes { - tt_Event = 1, - tt_SpillOn = 12, - tt_SpillOff = 13, - tt_StartAcq = 14, - tt_StopAcq = 15 - }; - -#pragma pack(push, 1) - - - struct SubeventHeader : public Header { - union { - - struct { - -#if BYTE_ORDER == LITTLE_ENDIAN - int16_t iProcId; /* Processor ID [as loaded from VAX] */ - int8_t iSubcrate; /* Subcrate number */ - int8_t iControl; /* Processor type code */ -#else - int8_t iControl; /* Processor type code */ - int8_t iSubcrate; /* Subcrate number */ - int16_t iProcId; /* Processor ID [as loaded from VAX] */ -#endif - }; - - uint32_t fFullId; /** full subevent id */ - }; - - void Init(uint8_t crate = 0, uint16_t procid = 0, uint8_t control = 0) - { - iWords = 0; - iType = MBS_TYPE(10,1); - iProcId = procid; - iSubcrate = crate; - iControl = control; - } - - void *RawData() const { return (char*) this + sizeof(SubeventHeader); } - - // RawDataSize - size of raw data without subevent header - uint32_t RawDataSize() const { return FullSize() - sizeof(SubeventHeader); } - void SetRawDataSize(uint32_t sz) { SetFullSize(sz + sizeof(SubeventHeader)); } - - }; - - typedef uint32_t EventNumType; - - struct EventHeader : public Header { -#if BYTE_ORDER == LITTLE_ENDIAN - int16_t iDummy; /* Not used yet */ - int16_t iTrigger; /* Trigger number */ -#else - int16_t iTrigger; /* Trigger number */ - int16_t iDummy; /* Not used yet */ -#endif - EventNumType iEventNumber; - - void Init(EventNumType evnt = 0) - { - iWords = 0; - iType = MBS_TYPE(10,1); - iDummy = 0; - iTrigger = tt_Event; - iEventNumber = evnt; - } - - void CopyHeader(EventHeader* src) - { - iDummy = src->iDummy; - iTrigger = src->iTrigger; - iEventNumber = src->iEventNumber; - } - - inline EventNumType EventNumber() const { return iEventNumber; } - inline void SetEventNumber(EventNumType ev) { iEventNumber = ev; } - - // SubEventsSize - size of all subevents, not includes events header - inline uint32_t SubEventsSize() const { return FullSize() - sizeof(EventHeader); } - inline void SetSubEventsSize(uint32_t sz) { SetFullSize(sz + sizeof(EventHeader)); } - - SubeventHeader* SubEvents() const - { return (SubeventHeader*) ((char*) this + sizeof(EventHeader)); } - - SubeventHeader* NextSubEvent(SubeventHeader* prev) const - { return prev == 0 ? (FullSize() > sizeof(EventHeader) ? SubEvents() : 0): - (((char*) this + FullSize() > (char*) prev + prev->FullSize() + sizeof(SubeventHeader)) ? - (SubeventHeader*) (((char*) prev) + prev->FullSize()) : 0); } - - unsigned NumSubevents() const; - }; - - - struct BufferHeader : public Header { - union { - struct { -#if BYTE_ORDER == LITTLE_ENDIAN - int16_t i_used; /* Used length of data field in words */ - int8_t h_end; /* Fragment at begin of buffer */ - int8_t h_begin; /* Fragment at end of buffer */ -#else - int8_t h_begin; /* Fragment at end of buffer */ - int8_t h_end; /* Fragment at begin of buffer */ - int16_t i_used; /* Used length of data field in words */ -#endif - }; - int32_t iUsed; // not used for type=100, low 16bits only - }; - - int32_t iBufferId; // consequent buffer id - int32_t iNumEvents; // number of events in buffer - int32_t iTemp; // Used volatile - int32_t iSeconds; - int32_t iNanosec; - int32_t iEndian; // compatible with s_bufhe free[0] - int32_t iLast; // length of last event, free[1] - int32_t iUsedWords; // total words without header to read for type=100, free[2] - int32_t iFree3; // free[3] - - void Init(bool newformat); - - // length of buffer, which will be transported over socket - uint32_t BufferLength() const; - - // UsedBufferSize - size of data after buffer header - uint32_t UsedBufferSize() const; - void SetUsedBufferSize(uint32_t len); - - void SetEndian() { iEndian = 1; } - bool IsCorrectEndian() const { return iEndian == 1; } - }; - - struct TransportInfo { - int32_t iEndian; // byte order. Set to 1 by sender - int32_t iMaxBytes; // maximum buffer size - int32_t iBuffers; // buffers per stream - int32_t iStreams; // number of streams (could be set to -1 to indicate variable length buffers) - }; - - -#pragma pack(pop) - - enum EMbsBufferTypes { - mbt_MbsEvents = 103 // several mbs events without buffer header - }; - - // this is list of server kind, supported up to now by DABC - enum EMbsServerKinds { - NoServer = 0, - TransportServer = 1, - StreamServer = 2, - OldTransportServer = 3, - OldStreamServer = 4 - }; - - extern const char* ServerKindToStr(int kind); - extern int StrToServerKind(const char* str); - extern int DefualtServerPort(int kind); - - extern void SwapData(void* data, unsigned bytessize); - - extern const char* typeLmdInput; - extern const char* typeLmdOutput; - extern const char* typeTextInput; - extern const char* typeServerTransport; - extern const char* typeClientTransport; - - extern const char* protocolLmd; - extern const char* protocolMbs; - extern const char* protocolMbsTransport; - extern const char* protocolMbsStream; - - extern const char* comStartServer; - extern const char* comStopServer; - extern const char* comStartFile; - extern const char* comStopFile; - - extern const char* portOutput; - extern const char* portOutputFmt; - extern const char* portInput; - extern const char* portInputFmt; - extern const char* portFileOutput; - extern const char* portServerOutput; - - extern const char* xmlFileName; - extern const char* xmlSizeLimit; - extern const char* xmlServerName; - extern const char* xmlServerKind; - extern const char* xmlServerPort; - extern const char* xmlServerScale; - - extern const char* xmlTextDataFormat; - extern const char* xmlTextNumData; - extern const char* xmlTextHeaderLines; - extern const char* xmlTextCharBuffer; - - extern const char* xmlNormalOutput; - extern const char* xmlFileOutput; - extern const char* xmlServerOutput; - extern const char* xmlCombineCompleteOnly; - extern const char* xmlCheckSubeventIds; - extern const char* xmlEvidMask; - extern const char* xmlEvidTolerance; - extern const char* xmlSpecialTriggerLimit; - extern const char* xmlCombinerRatesPrefix; - -}; - -#endif diff --git a/beamtime/roclight/roc/Board.h b/beamtime/roclight/roc/Board.h deleted file mode 100644 index 9769ecc12e167e6bfd497bf41d272db6fb2d717e..0000000000000000000000000000000000000000 --- a/beamtime/roclight/roc/Board.h +++ /dev/null @@ -1,498 +0,0 @@ -#ifndef ROC_BOARD_H -#define ROC_BOARD_H - -#ifdef HAVE_UINT8_T_HEADER_FILE -#include <_types/_uint8_t.h> -#include <_types/_uint16_t.h> -#include <_types/_uint32_t.h> -#include <_types/_uint64_t.h> -#else -#include <stdint.h> -#endif - -#include <iostream> -#include <string> -#include <map> -#include <list> - -#include "roc/Message.h" - -#include "roc/OperList.h" - - -namespace roc { - - //! Represents the role the client of a board can have - enum ClientRole { roleNone, //!< no defined role - roleObserver, //!< pure observer, no changes - roleControl, //!< allowed to change state, no DAQ - roleDAQ //!< full control including DAQ - }; - - // FIXME: why is MBS stuff here ??? - // Answer (S.Linev): - just to have in common place constants, which define mbs event types, - // which is than used in DABC and further application, where MBS files should be read - - //! value of iProcId if mbs subevent. - /*! - * Data, taken from ROC by DABC, packed into mbs events and stored in lmd file. - * MBS event consists from one or several subevents. - * Each subevent has three fields - iProcId (16bit), iSubcrate (8bit) and iControl (8bit) - * iProcId used to code data origin - see comment for /ref ERocMbsTypes - * iSubcrate contains roc number (rocid) - * iControl stores data format see /ref MessageFormat - */ - enum ERocMbsTypes { - proc_RocEvent = 1, //!< complete event from one roc board (iSubcrate = rocid) - proc_ErrEvent = 2, //!< one or several events with corrupted data inside (iSubcrate = rocid) - proc_MergedEvent = 3, //!< sorted and synchronized data from several rocs (iSubcrate = upper rocid bits) - proc_RawData = 4, //!< unsorted uncorrelated data from one ROC, no SYNC markers required (mainly for FEET case) - proc_Triglog = 5, //!< subevent produced by MBS directly with sync number and trigger module scalers - proc_TRD_MADC = 6, //!< subevent produced by MBS directly with CERN-Nov10 data - proc_TRD_Spadic = 7, //!< collection of data from susibo board - proc_CERN_Oct11 = 8, //!< id for CERN beamtime in October 11 - proc_SlaveMbs = 9, //!< subevent produce by slave MBS system, which emulates number of triglog module - proc_EPICS = 10, //!< subevent produced by dabc EPICS plugin (ezca) - proc_COSY_Nov11 = 11 //!< id for COSY beamtime in November 11 - }; - - // symbolic names for ROC-related configuration parameters - extern const char* xmlNumRocs; - extern const char* xmlRocPool; - extern const char* xmlTransportWindow; - extern const char* xmlTransportKind; - extern const char* xmlBoardAddr; - extern const char* xmlRole; - extern const char* xmlRocNumber; - extern const char* xmlLowWater; - extern const char* xmlHighWater; - extern const char* xmlMsgFormat; - extern const char* xmlFlushTime; - - extern const char* typeUdpDevice; - extern const char* typeAbbDevice; - - extern const char* roleToString(ClientRole role); - extern ClientRole defineClientRole(const char* name, - ClientRole dflt = roleObserver); - - enum ERocBufferTypes { - rbt_RawRocData = 234 - }; - - enum ETransportKinds { - kind_UDP = 0, - kind_ABB = 1, - kind_File = 2 - }; - - enum EFrontendKinds { - kind_nXYTER = 1, - kind_FEET = 2 - }; - - enum EBackendKinds { - kind_Optic = 1, - kind_FX20 = 2, - kind_FX40 = 3, - kind_FX60 = 4 - }; - - - class BoardConnector; - - class Board { - - friend class BoardConnector; - - private: - // For now disable usage of assignment OP to remove warnings, - // if needed implement it correctly - Board(const roc::Board&); - Board& operator=(const Board&); - - protected: - ClientRole fRole; //!< client role (access rights) - uint32_t fRocNumber; //!< number of connected ROC - double fDefaultTimeout; //!< default timeout - int fVerbosity; //!< Debug verbosity level - int fOperTrace; //!< Oper trace level - BoardConnector* fConnector; - - std::map<std::string,uint32_t> fMapName2Addr; - std::map<uint32_t,std::string> fMapAddr2Name; - typedef std::map<std::string,uint32_t>::iterator mapn2a_iter_t; - typedef std::map<uint32_t,std::string>::iterator mapa2n_iter_t; - - Board(); - virtual ~Board(); - - void setRole(ClientRole r) { fRole = r; } - - void traceOper(OperList* lst, int rc); - - virtual void ShowDebug(int lvl, const char* msg); - - /** reads roc number and displays basic version values - * return ROC hardware version or 0 in case of error */ - uint32_t initBoard(); - - public: - - //! Return codes for get, put and oper calls - /*! - * For a detailed documentation of get/put/oper return code see - * \ref roc_board_opererr. - */ - enum operErr { - kOperSuccess = 0, //!< success - kOperAddrErr = 2, //!< invalid address - kOperValueErr = 3, //!< value not allowed in context - kOperStateErr = 4, //!< operation not allowed in state - kOperNetworkErr = 6, //!< network communication error - kHostError = 8, //!< PC software stack errpr - kOperVerifyErr = 20, //!< readback after write mismatch - kOperBusErr = 21 //!< secondary bus error - }; - - ClientRole getRole() const { return fRole; } - - void Debug(int lvl, const char *fmt, ...); - - bool findRocAddressByName(const char* name, uint32_t& addr); - bool findRocNameByAddress(uint32_t addr, const char*& name); - void printRocAddressMap(std::ostream& os, bool byname=false); - - void addRocAddrMapping(const char* name, uint32_t addr); - - void fillAddrNames(std::list<std::string>& lst); - - //! Set debug output verbosity level. \sa getVerbosity(), Debug() - void setVerbosity(int lvl = 0) - { fVerbosity = lvl; } - //! Returns debug output verbosity level. \sa setVerbosity(), Debug() - int getVerbosity() - { return fVerbosity; } - - //! Set get/put/operGen trace level. - /*! - * Controls whether the full context of get(), put() and operGen() - * requests is printed to stdout. The \a lvl determines whether all, - * none or only failed requests are traced: - * \li 0 no trace at all - * \li 1 trace if network error (default setting) - * \li 2 trace if any error - * \li 3 trace all - * - * The output format is like (-> indicates get, <- indicates put): -\verbatim -get (3,0x00000580 ROC_GPIO_CONFIG ) -> 0x00000000 0 ok -put (3,0x00000580 ROC_GPIO_CONFIG ) <- 0x00000100 256 ok -op[00](3,0x00000514 ROC_SYNC2_BAUD_START ) <- 0x00000002 2 -op[01](3,0x00000518 ROC_SYNC2_BAUD1 ) <- 0x00000004 4 -op[02](3,0x0000051c ROC_SYNC2_BAUD2 ) <- 0x00000004 4 ok -put (3,0x00000500 ROC_SYNC1_M_SCALEDOWN ) <- 0x00000004 4 ok -op[00](3,0x00000504 ROC_SYNC1_BAUD_START ) <- 0x00000002 2 -op[01](3,0x00000508 ROC_SYNC1_BAUD1 ) <- 0x00000004 4 -op[02](3,0x0000050c ROC_SYNC1_BAUD2 ) <- 0x00000004 4 ok -op[00](3,0x00000054 ROC_TESTPULSE_LENGTH ) <- 0x0000c34f 49999 -op[01](3,0x00000058 ROC_TESTPULSE_NUMBER ) <- 0x00000000 0 -op[02](3,0x0000005c ROC_TESTPULSE_START ) <- 0x00000001 1 ok -op[00](3,0x00010100 ROC_I2C1_SWITCH ) <- 0x00000000 0 -op[01](3,0x0001000c ROC_I2C1_SLAVEADDR ) <- 0x00000008 8 -op[02](3,0x00010010 ROC_I2C1_REGISTER ) <- 0x00000015 21 -op[03](3,0x00010000 ROC_I2C1_DATA ) -> 0x0000000f 15 -op[04](3,0x00010020 ROC_I2C1_ERROR ) -> 0x00000000 0 ok -\endverbatim - * \sa getOperTrace() - */ - void setOperTrace(int lvl = 1) - { fOperTrace = lvl; } - //! Returns debug output verbosity level. \sa setOperTrace() - int getOperTrace() - { return fOperTrace; } - - //! Set default get/put/oper timeout. - /*! - * The value set with this method is used whenever no explicit - * timeout is specified in a get(), put() or openGen() call. - * \param tmout network communication timeout in sec. - * \sa getDefaultTimeout() - */ - void setDefaultTimeout(double tmout = 2.) - { fDefaultTimeout = tmout>0 ? tmout : 1.; } - - //! Returns default get/put/oper timeout. \sa setDefaultTimeout() - double getDefaultTimeout() const { return fDefaultTimeout; } - - //! Sets flush timeout of data transport - /*! - * Local transport accumulates data in buffer and until buffer is not filled, - * data is not delivered further. Flush timeout defines time interval, - * when any amount of data will be flushed. - * \param tmout timeout value in sec. - */ - virtual void setFlushTimeout(double /*tmout*/) {} - - //! General operate, arbitrary list of get/put accesses to ROC control space. - /*! - * This function allow to execute a list of gets and puts from and to the - * ROC control address space. It is guaranteed that the execution is an - * atomic action, no control space access from other sources will be - * handled concurrently. - * \param isput array of flags, if \c true a put is done, otherwise a get. - * \param addr array of ROC control space addresses - * \param value array of data values. If the corresponding entry in \a isput - * is true the array element is read and written into the ROC address, - * otherwise the array element is written by data retrieved from the - * ROC address. - * \param num number of operates to do, size of arrays \a isput, \a addr, - * and \a value - * \param tmout maximal network response time - * \returns see \ref roc_board_opererr - * - * \sa operPG(), operPP(), operPPP(), operPPPP() - */ - - virtual int operGen(OperList& lst, double tmout = 0.) = 0; - - virtual int operGen(bool* isput, - uint32_t* addr, - uint32_t* value, - int num, - double tmout = 0.); - - int put(uint32_t addr, uint32_t value, double tmout = 0.); - int get(uint32_t addr, uint32_t& value, double tmout = 0.); - - int operPP(uint32_t addr0, uint32_t val0p, - uint32_t addr1, uint32_t val1p, - double tmout = 0.); - int operPG(uint32_t addr0, uint32_t val0p, - uint32_t addr1, uint32_t& val1g, - double tmout = 0.); - int operPPP(uint32_t addr0, uint32_t val0p, - uint32_t addr1, uint32_t val1p, - uint32_t addr2, uint32_t val2p, - double tmout = 0.); - int operGGG(uint32_t addr0, uint32_t& val0p, - uint32_t addr1, uint32_t& val1p, - uint32_t addr2, uint32_t& val2p, - double tmout = 0.); - int operPPPP(uint32_t addr0, uint32_t val0p, - uint32_t addr1, uint32_t val1p, - uint32_t addr2, uint32_t val2p, - uint32_t addr3, uint32_t val3p, - double tmout = 0.); - - // -------------------------------------------------------------------- - // methods for controlling ROC and components - // -------------------------------------------------------------------- - - static const char* versionToString(uint32_t ver); - - static uint32_t getRoclibVersion(); - uint32_t getRocFpgaType(); - uint32_t getRocSvnRev(); - uint32_t getRocBuildTime(); - - uint32_t getRocHardwareVersion(); - uint32_t getRocHardwareType(); - - //! Return frontend kinds - kind_nXYTER (1) or kind_FEET (2) - uint32_t getRocFrontendKind() { return getRocHardwareType() >> 16; } - - //! Return backend kinds - kind_Optic (1), kind_FX20 (2), kind_FX40 (3) or kind_FX60 (4) - uint32_t getRocBackendKind() { return getRocHardwareType() & 0xffff; } - - //! Returns backend (Optic or UDP) version - virtual uint32_t getRocBackendVersion() { return 0; } - - - //! Returns locally stored ROC number - uint32_t rocNumber() const { return fRocNumber; } - - //! Returns number from ROC directly, store fRocNumber variable - uint32_t getRocNumber(); - void setRocNumber(uint32_t); - - int uploadCommandsList(unsigned num, const OperList& lst, double tmout = 0.); - - int downloadCommandsList(unsigned num, OperList& lst, double tmout = 0.); - - int invokeCommandsList(unsigned num, double tmout = 0.); - - int uploadStartDaqCmdList(bool reset_frontend = false, bool reset_fifo = true); - - int uploadStopDaqCmdList(); - - virtual int invokeDLM(unsigned /*num*/, double /*tmout = 0.*/) { return 0; } - - void clearRocFifo(); - void restartRoc(); - - int getRocThrottleState(uint32_t& val); - - // DAQ functions - - //! Activate DAQ. - /*! - * This method will initialize the data transport chain which brings - * message data from the ROC. The details depend in the underlying - * transport. By the daq starting commands list 0 is always executed. - * This commands list can be initialized by \sa uploadStartDaqCmdList() - * By default configuration (after \sa setToDefault()) frontend is initialized - * (in case of nXYTER, timestamp logic initialization) and message - * FIFO will be cleared. - * - * \sa suspendDaq(), stopDaq(), getNextBuffer() - */ - virtual bool startDaq() = 0; - - //! suspendDaq - /*! - * Sends to ROC ROC_SUSPEND_DAQ command. ROC will produce stop message - * and will deliver it sometime to host PC. User can continue to take data until - * this message. Normally no more messages will be delivered after stop daq message. - */ - virtual bool suspendDaq() = 0; - - //! stopDaq - /*! - * Complimentary function for startDaq. - * Disables any new data requests, all coming data will be discarded - */ - virtual bool stopDaq() = 0; - - //! getNextBuffer - /*! - * Returns pointer on the buffer which contains received messages. - * \param len returns length of buffer in bytes. - * Buffer is allocated by board itself, buffer content remains valid until next - * call of getNextBuffer() or when daq is stopped. - * Format of messages can be defined by \ref getMsgFormat() - * To extract single messages from the buffer, \ref roc::Iterator class should be used - * \sa \ref roc::Iterator getMsgFormat() - */ - virtual bool getNextBuffer(void* &buf, unsigned& len, double tmout = 1.) = 0; - - //! getMsgFormat - /*! - * Returns message format like formatEth2, formatOptic2 and so on - */ - virtual MessageFormat getMsgFormat() const = 0; - - //! getTransportKind - /*! - * Returns kind of transport - roc::kind_UDP or roc::kind_ABB - */ - virtual int getTransportKind() const = 0; - - //! isFile - /*! - * Returns true if board is just envelope around file reading - - * most operation like put/get are nit working and should not be tried - */ - bool isFile() const { return getTransportKind() == roc::kind_File; } - - //! Sets to default values common ROC registers - /*! - * For a moment, initializes start/stop commands lists - */ - virtual int setToDefault(); - - //! enableCalibration - /*! - * Preliminary functionality for nXYTER calibration - * Reconfigures nXYTER in test-trigger mode and fires several test pulses - * \param period can has following values: - * 0 - make calibration once - * >0 - perform calibration periodically - * <0 - disable calibration - */ - virtual bool enableCalibration(double /*period = 10.*/, double /*calibr = 0.1*/, int /*cnt = -1*/) { return false; } - - virtual bool disableCalibration() { return enableCalibration(-1., -1., 0); } - - //! Retrieve error code from get/put/oper return code. - /*! - * Extracts the error code, in general one of the values specified in - * the board::operErr enum, from a return code \a rc of a board access - * method. - * \sa \ref roc_board_opererr. - */ - static int operErrCode(int rc) - { return rc & 0xff; } - //! Retrieve index from get/put/oper return code - /*! - * Extracts the index value from a return code \a rc of a board access. - * method. The index allows to reconstruct at which point of an - * access sequence the error occurred. - * \sa \ref roc_board_opererr. - */ - static int operErrIndex(int rc) - { return (rc>>8) & 0xffffff; } - - //! Build get/put/oper return code from error code and index value. - /*! - * Build a return code for a board access method from an error - * code \a code, in general one of the values specified in the - * board::operErr enum, and an index value \a index. - * \param code error code. Only the lower 8 bits are used, to - * one can use a full return code, the index part will be discarded. - * \param index index or stage number at the point of failure - * \sa \ref roc_board_opererr. - * \sa operErrBuildInc() - */ - static int operErrBuild(int code, int index) - { return (code & 0xff) | ((index & 0xffffff)<<8); } - - //! Add to index value of get/put/oper return code. - /*! - * \param rc return code from board access method - * \param inc value to be added to the index field - * \returns the return code \a rc with the index incremented by \a inc - * \sa \ref roc_board_opererr. - * \sa operErrBuild() - */ - static int operErrBuildInc(int rc, int inc) - { return operErrBuild(rc, operErrIndex(rc) + inc); } - - static std::string operErrToString(int rc); - - static const char* operErrCodeName(int rc); - - static Board* Connect(const char* name, ClientRole role = roleDAQ); - static bool Close(Board* brd); - }; - - - class BoardConnector { - - private: - static BoardConnector* gArr[10]; - - public: - BoardConnector(); - virtual ~BoardConnector(); - - static int NumConn() { return 10; } - static BoardConnector* Conn(int n) { return gArr[n]; } - - //! Checks if name has specified prefix - /*! - * Can be used to resolve address name like udp:\\rocname or file:\\filename. - */ - static const char* CheckNamePrefix(const char* rocname, const char* prefix); - - static const char* CheckOptic(const char* name); - static const char* CheckUdp(const char* name); - static const char* CheckFile(const char* name); - - virtual Board* DoConnect(const char* name, ClientRole role = roleDAQ) = 0; - virtual bool DoClose(Board* brd) = 0; - }; - -} - -#endif diff --git a/beamtime/roclight/roc/Factory.h b/beamtime/roclight/roc/Factory.h deleted file mode 100644 index 9c9fe3b54eb6f6aa530f7a0db4110484760bbb7d..0000000000000000000000000000000000000000 --- a/beamtime/roclight/roc/Factory.h +++ /dev/null @@ -1,68 +0,0 @@ -/******************************************************************** - * The Data Acquisition Backbone Core (DABC) - ******************************************************************** - * Copyright (C) 2009- - * GSI Helmholtzzentrum fuer Schwerionenforschung GmbH - * Planckstr. 1 - * 64291 Darmstadt - * Germany - * Contact: http://dabc.gsi.de - ******************************************************************** - * This software can be used under the GPL license agreements as stated - * in LICENSE.txt file which is part of the distribution. - ********************************************************************/ -#ifndef ROC_FACTORY_H -#define ROC_FACTORY_H - -/* *** PAL edit: Run offline with LMD file and without DABC *** -#ifndef DABC_Factory -#include "dabc/Factory.h" -#endif - -#ifndef DABC_ReferencesVector -#include "dabc/ReferencesVector.h" -#endif - ***************** */ - -#ifndef ROC_Board -#include "roc/Board.h" -#endif - -namespace roc { - -/* *** PAL edit: Run offline with LMD file and without DABC *** - class UdpDevice; - ***************** */ - - class Factory: //public dabc::Factory, - public roc::BoardConnector { - protected: - -/* *** PAL edit: Run offline with LMD file and without DABC *** - dabc::ReferencesVector fDevs;" - ***************** */ - int fFileCount; // number of created files handles - bool fMgrCreated; // true when manager was created automatically - - public: - - Factory(const char* name); - -/* *** PAL edit: Run offline with LMD file and without DABC *** - virtual dabc::Application* CreateApplication(const char* classname, dabc::Command cmd); - - virtual dabc::Module* CreateModule(const char* classname, const char* modulename, dabc::Command cmd); - - virtual dabc::Device* CreateDevice(const char* classname, const char* devname, dabc::Command cmd);" - ***************** */ - - virtual roc::Board* DoConnect(const char* name, roc::ClientRole role = roc::roleDAQ); - - virtual bool DoClose(roc::Board* brd); - - }; - -} - -#endif - diff --git a/beamtime/roclight/roc/FileInput.h b/beamtime/roclight/roc/FileInput.h deleted file mode 100644 index f62271097080bb21cf4c225e4efc1905e1d07963..0000000000000000000000000000000000000000 --- a/beamtime/roclight/roc/FileInput.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef ROC_FILEINPUT_H -#define ROC_FILEINPUT_H - -/* *** PAL edit: Run offline with LMD file and without DABC *** -#include "roc/UdpBoard.h" - ***************** */ -#include "roc/Board.h" - -#ifndef MBS_LmdInput -#include "mbs/LmdInput.h" -#endif - -#ifndef MBS_MbsTypeDefs -#include "mbs/MbsTypeDefs.h" -#endif - -namespace roc { - - class FileInput : public Board { - protected: - mbs::LmdInput* fInput; - - mbs::EventHeader* fHdr; - mbs::SubeventHeader* fSubev; - - int fSelectRoc; - - public: - FileInput(mbs::LmdInput* inp, int selectroc = -1); - - virtual ~FileInput(); - - virtual int getTransportKind() const; - - virtual void setFlushTimeout(double) {} - - virtual int operGen(OperList&, double = 0.) { return 0; } - - // daq interface part of roc::Board - virtual bool startDaq() { return true; } - virtual bool suspendDaq() { return true; } - virtual bool stopDaq() { return true; } - - virtual bool getNextBuffer(void* &buf, unsigned& len, double tmout = 1.); - - virtual MessageFormat getMsgFormat() const; - - private: - FileInput(const FileInput&); - FileInput& operator=(const FileInput&); - }; -} - - -#endif diff --git a/beamtime/roclight/roc/Iterator.h b/beamtime/roclight/roc/Iterator.h deleted file mode 100644 index 1b44362edb96cd99388521573929dadfa1306b09..0000000000000000000000000000000000000000 --- a/beamtime/roclight/roc/Iterator.h +++ /dev/null @@ -1,128 +0,0 @@ -#ifndef ROC_ITERATOR_H -#define ROC_ITERATOR_H - -#include "roc/Message.h" - -#include "roc/Board.h" - -namespace roc { - - class Iterator { - private: - // For now disable usage of assignment OP to remove warnings, - // if needed implement it in the same way as the copy constructor - Iterator& operator=(const Iterator&); - protected: - enum { MaxGet4=16 }; - - MessageFormat fFormat; - void* fBuffer; // assigned buffer - uint32_t fBufferLen; // length of assigned buffer - uint32_t fBufferPos; // current position - uint32_t fMsgSize; // size of single message - Message fMsg; // current read message - uint32_t fEpoch; // current epoch - uint32_t fEpoch2[MaxGet4]; // current epoch2 for each Get4 - Board* fBoard; // board instance, which delivers buffers - bool fOwner; // owner of board instance - - public: - Iterator(MessageFormat fmt = formatNormal); - - Iterator(Board* brd, bool owner = false); - - Iterator(const Iterator& src); - - Iterator(const char* filename); - - virtual ~Iterator(); - - void setFormat(MessageFormat fmt); - MessageFormat getFormat() const { return fFormat; } - - bool isFile() const; - - void setRocNumber(uint16_t rocnum = 0); - - uint32_t getMsgSize() const { return fMsgSize; } - - bool assign(void* buf, uint32_t len); - - bool nextBuffer(Board* brd, double tmout = 1.); - - void resetEpochs(); - - inline bool next(double tmout = 1.) - { - if ((fBuffer==0) || (fBufferPos>=fBufferLen)) - if (!nextBuffer(fBoard, tmout)) return false; - if (fMsg.assign((uint8_t*) fBuffer + fBufferPos, fFormat)) { - fBufferPos += fMsgSize; - switch (fMsg.getMessageType()) { - case MSG_EPOCH: fEpoch = fMsg.getEpochNumber(); break; - case MSG_EPOCH2: - if (fMsg.getEpoch2ChipNumber() < MaxGet4) fEpoch2[fMsg.getEpoch2ChipNumber()] = fMsg.getEpoch2Number(); - break; - } - return true; - } - fBufferPos = fBufferLen; - return false; - } - - // can be used only inside buffer, not with board source - inline bool last() - { - if ((fBuffer==0) || (fBufferLen<fMsgSize)) return false; - - fBufferPos = (fBufferLen - fMsgSize) / fMsgSize * fMsgSize; - - return next(0.); - } - - // can be used only inside buffer, not with board source - inline bool prev() - { - if ((fBuffer==0) || (fBufferPos<fMsgSize*2)) return false; - - fBufferPos -= fMsgSize*2; - - return next(0.); - } - - uint32_t getLastEpoch() const { return fEpoch; } - - uint32_t getLastEpoch2(unsigned n=0) const { return n<MaxGet4 ? fEpoch2[n] : 0; } - - inline Message& msg() { return fMsg; } - - inline uint32_t getMsgEpoch() const - { - switch(fMsg.getMessageType()) { - case MSG_EPOCH2: -// return (fMsg.getEpoch2ChipNumber() < MaxGet4) ? fEpoch2[fMsg.getEpoch2ChipNumber()] : 0; - return fMsg.getEpoch2Number(); - case MSG_GET4: - return (fMsg.getGet4Number() < MaxGet4) ? fEpoch2[fMsg.getGet4Number()] : 0; - } - return fEpoch; - } - - inline uint64_t getMsgFullTime() const - { - return fMsg.getMsgFullTime(getMsgEpoch()); - } - - inline double getMsgFullTimeD() const - { - return fMsg.getMsgFullTimeD(getMsgEpoch()); - } - - void printMessage(unsigned kind = msg_print_Prefix | msg_print_Data); - - void printMessages(unsigned cnt = 100, unsigned kind = msg_print_Prefix | msg_print_Data); - }; -} - - -#endif diff --git a/beamtime/roclight/roc/Message.h b/beamtime/roclight/roc/Message.h deleted file mode 100644 index 4190220aac7fbe4d69affd018c07668da171ddea..0000000000000000000000000000000000000000 --- a/beamtime/roclight/roc/Message.h +++ /dev/null @@ -1,469 +0,0 @@ -#ifndef ROC_MESSAGE_H -#define ROC_MESSAGE_H - -#ifdef HAVE_UINT8_T_HEADER_FILE -#include <_types/_uint8_t.h> -#include <_types/_uint16_t.h> -#include <_types/_uint32_t.h> -#include <_types/_uint64_t.h> -#else -#include <stdint.h> -#endif - -#include <iostream> - -namespace roc { - - - enum MessageFormat { - formatEth1 = 0, // original message format with big-endian coding, 6-byte - formatOptic1 = 1, // original message format with big-endian coding, add 2 byte send/recv info, 8-byte - formatEth2 = 2, // new message format with little-endian coding, 6-byte - formatOptic2 = 3, // new message format with little-endian coding, add 2 byte send/recv info, 8-byte - formatNormal = 4 // new message format with little-endian coding, 16-bit roc number (default) - }; - - enum MessageTypes { - MSG_NOP = 0, - MSG_HIT = 1, - MSG_EPOCH = 2, - MSG_SYNC = 3, - MSG_AUX = 4, - MSG_EPOCH2 = 5, - MSG_GET4 = 6, - MSG_SYS = 7 - }; - - enum SysMessageTypes { - SYSMSG_DAQ_START = 1, // indicates start daq in data stream - SYSMSG_DAQ_FINISH = 2, // stop daq - SYSMSG_NX_PARITY = 3, // nx_parity error - SYSMSG_SYNC_PARITY = 4, // sync parity error - SYSMSG_DAQ_RESUME = 5, // daq resume due to low/high water marker, only in udp case - SYSMSG_FIFO_RESET = 6, // FPGA fifo reset - SYSMSG_USER = 7, // user define message, generated by writing into ROC_ADDSYSMSG register - SYSMSG_PCTIME = 8, // contains value of time() function, indicates when message was created on PC - SYSMSG_ADC = 9, // contains feb1d (1 bit), channel id (7 bit) and adc value (24 bit), measured on PC - SYSMSG_PACKETLOST = 10, // inserted by udp transport when packet was lost at this place - SYSMSG_GET4_EVENT = 11, // GET4 event - SYSMSG_CLOSYSYNC_ERROR = 12, // added to data stream when the closy-sync-strobe does not match the rocs 156MHz timestamp counter - SYSMSG_TS156_SYNC = 13 // added when 156MHz timestamp counter is reset by a DLM - - }; - - enum SysMessageUserTypes { - SYSMSG_USER_CALIBR_ON = 7, - SYSMSG_USER_CALIBR_OFF = 8, - SYSMSG_USER_RECONFIGURE = 9 - }; - - enum MessagePrintMask { - msg_print_Prefix = 1, - msg_print_Data = 2, - msg_print_Hex = 4, - msg_print_Human = 8 - }; - - class Message { - - protected: - uint64_t data; // main and only storage field for the message - - public: - Message() : data(0) {} - - Message(const Message& src) : data(src.data) {} - - void assign(const Message& src) { data = src.data; } - -// void operator=(const Message& src) { assign(src); } - - inline void reset() { data = 0; } - - inline uint32_t getField(uint32_t shift, uint32_t len) const - { return (data >> shift) & ((((uint32_t)1) << len) - 1); } - - inline void setField(uint32_t shift, uint32_t len, uint32_t value) - { data = (data & ~(((((uint64_t) 1) << len) - 1) << shift)) | (((uint64_t) value) << shift); } - - inline uint8_t getBit(uint32_t shift) const - { return (data >> shift) & 1; } - - inline void setBit(uint32_t shift, uint8_t value) - { data = value ? (data | (((uint64_t) 1) << shift)) : (data & ~(((uint64_t) 1) << shift)) ; } - - - // --------------------------- common fields --------------------------------- - - //! Returns the message type. Valid for all message types. 4 bit - inline uint8_t getMessageType() const { return getField(0, 4); } - - //! Returns the number of the sending ROC. Valid for all message types. - /*! - * The field has full 16 bits and allows to aggregate data of up to 64K ROC's - * in one message stream. - */ - inline uint16_t getRocNumber() const { return getField(48, 16); } - - //! Sets the message type field in the current message - inline void setMessageType(uint8_t v) { setField(0, 4, v); } - - //! Sets the ROC number field in the current message - inline void setRocNumber(uint16_t v) { setField(48, 16, v); } - - - // ---------- nXYTER Hit data access methods ---------------- - - //! For Hit data: Returns nXYTER number (2 bit field) - /*! - * A ROC can support up to 2 FEBs with a total of 4 nXYTER chips. - * This field identifies FEB as well as chip. Each supported - * configuration (either 2 x FEB1nx/FEB2nx or a single FEB4nx) - * as a unique nXYTER chip numbering. - */ - inline uint8_t getNxNumber() const { return getField(6, 2); } - - //! For Hit data: Returns 3 most significant bits of ROC LTS (3 bit field) - /*! - * The 3 MSBs of the ROC local time stamp counter at the time of data - * capture are stored in this field. A comparison of this number, - * which reflects the time of readout, and the 3 MSBs of the timestamp - * (returned by getNxLtsMsb() const), which reflects the time of the - * hit, allows to estimate the time the hit stayed in the nXYTER internal - * FIFOs. This in turn gives an indication of the data load in the - * nXYTER. - */ - inline uint8_t getNxLtsMsb() const { return getField(8, 3); } - - //! For Hit data: Returns nXYTER time stamp (14 bit field) - /*! - * Raw timestamp as delivered by the nXYTER. The last-epoch flag - * (returned by getNxLastEpoch() const) determines whether the - * hit belongs to the current or the last epoch. Use the - * getMsgFullTime(uint32_t) const method to determine the - * expanded and adjusted timestamp.inline uint32_t getSysMesData() const { return getField(16, 32); } - */ - inline uint16_t getNxTs() const { return getField(11, 14); } - - //! For Hit data: Returns nXYTER channel number (7 bit field) - inline uint8_t getNxChNum() const { return getField(25, 7); } - - // 1 bit unused - - //! For Hit data: Returns ADC value (12 bit field) - inline uint16_t getNxAdcValue() const { return getField(33, 12); } - - //! For Hit data: Returns nXYTER pileup flag (1 bit field) - /*! - * This flag is set when the nXYTER trigger circuit detected two hits - * during the peak sense time interval of the slow amplitude channel. - * This flag indicates that separation between two hits was smaller than - * what can be handled by the amplitude channel. \sa getNxOverflow() const - */ - inline uint8_t getNxPileup() const { return getBit(45); } - - //! For Hit data: Returns nXYTER overflow flag (1 bit field) - /*! - * This flag is set when a nXYTER channels detects a hit but this hit - * can't be stored because the 4 stage channel FIFO is full. This flag - * indicates that the hit data rate was higher than the chip can handle - * over a longer time. \sa getNxPileup() const - */ - inline uint8_t getNxOverflow() const { return getBit(46); } - - //! For Hit data: Returns nXYTER last-epoch flag (1 bit field) - /*! - * This flag is set when the hit actually belong to the previous epoch. - * Use the getMsgFullTime(uint32_t) const method to determine the - * expanded and adjusted timestamp. - */ - inline uint8_t getNxLastEpoch() const { return getBit(47); } - - - //! For Hit data: Sets nXYTER number (2 bit field) - inline void setNxNumber(uint8_t v) { setField(6, 2, v); } - - //! For Hit data: Sets 3 most significant bits of ROC LTS (3 bit field) - inline void setNxLtsMsb(uint8_t v) { setField(8, 3, v); } - - //! For Hit data: Sets nXYTER time stamp (14 bit field) - inline void setNxTs(uint16_t v) { setField(11, 14, v); } - - //! For Hit data: Sets nXYTER channel number (7 bit field) - inline void setNxChNum(uint8_t v) { setField(25, 7, v); } - - // 1 bit unused - - //! For Hit data: Sets ADC value (12 bit field) - inline void setNxAdcValue(uint16_t v) { setField(33, 12, v); } - - //! For Hit data: Sets nXYTER pileup flag (1 bit field) - inline void setNxPileup(uint8_t v) { setBit(45, v); } - - //! For Hit data: Sets nXYTER overflow flag (1 bit field) - inline void setNxOverflow(uint8_t v) { setBit(46,v ); } - - //! For Hit data: Sets nXYTER last-epoch flag (1 bit field) - inline void setNxLastEpoch(uint8_t v) { setBit(47, v); } - - // ---------- Epoch marker access methods ------------ - - // 2 bit unused - - //! For Epoch data: Returns current epoch number (32 bit field) - // inline uint32_t getEpochNumber() const { return getField(8, 32); } - // on some machines 32-bit field is not working - inline uint32_t getEpochNumber() const { return data >> 8; } - - - //! For Epoch data: Returns number of missed hits (8 bit field) - inline uint8_t getEpochMissed() const { return getField(40, 8); } - - //! For Epoch data: Sets epoch number (32 bit field) - inline void setEpochNumber(uint32_t v) { setField(8, 32, v); } - - //! For Epoch data: Sets missed hits count (8 bit field) - inline void setEpochMissed(uint8_t v) { setField(40, 8, v); } - - - // ---------- Sync marker access methods ------------- - - //! For Sync data: Returns sync channel number (2 bit field) - inline uint8_t getSyncChNum() const { return getField(6, 2); } - - //! For Sync data: Returns sync time stamp (13 bit field, 2 ns bins) - inline uint16_t getSyncTs() const { return getField(8, 13) << 1; } - - //! For Sync data: Returns LSB of true epoch (1 bit field) - inline uint8_t getSyncEpochLSB() const { return getBit(21); } - - //! For Sync data: Returns sync message data (24 bit field) - inline uint32_t getSyncData() const { return getField(22, 24); } - - //! For Sync data: Returns sync status flags (2 bit field) - inline uint8_t getSyncStFlag() const { return getField(46, 2); } - - - //! For Sync data: Set sync channel number (2 bit field) - inline void setSyncChNum(uint8_t v) { setField(6, 2, v); } - - //! For Sync data: Set sync time stamp (13 bit field, 2 ns bins ) - inline void setSyncTs(uint16_t v) { setField(8, 13, v >> 1); } - - //! For Sync data: Set LSB of true epoch (1 bit field) - inline void setSyncEpochLSB(uint8_t v) { setBit(21, v); } - - //! For Sync data: Set sync message data (24 bit field) - inline void setSyncData(uint32_t v) { setField(22, 24, v); } - - //! For Sync data: Set sync status flags (2 bit field) - inline void setSyncStFlag(uint8_t v) { setField(46, 2, v); } - - - // ---------- AUX marker access methods -------------- - - //! For Aux data: Returns aux channel number (7 bit field) - inline uint8_t getAuxChNum() const { return getField(6, 7); } - - //! For Aux data: Returns aux time stamp (13 bit field, 2 ns bins) - inline uint16_t getAuxTs() const { return getField(13, 13) << 1; } - - //! For Aux data: Returns LSB of true epoch (1 bit field) - inline uint8_t getAuxEpochLSB() const { return getBit(26); } - - //! For Aux data: Returns falling edge flag (1 bit flag) - inline uint8_t getAuxFalling() const { return getBit(27); } - - //! For Aux data: Returns overflow flag (1 bit field) - inline uint8_t getAuxOverflow() const { return getBit(28); } - - - //! For Aux data: Set aux channel number (7 bit field) - inline void setAuxChNum(uint8_t v) { setField(6, 7, v); } - - //! For Aux data: Set aux time stamp (13 bit field) - inline void setAuxTs(uint16_t v) { setField(13, 13, v >> 1); } - - //! For Aux data: Set LSB of true epoch (1 bit field) - inline void setAuxEpochLSB(uint8_t v) { setBit(26, v); } - - //! For Aux data: Set falling edge flag (1 bit flag) - inline void setAuxFalling(uint8_t v) { setBit(27, v); } - - //! For Aux data: Set overflow flag (1 bit field) - inline void setAuxOverflow(uint8_t v) { setBit(28, v); } - - // ---------- Epoch2 marker access methods ------------ - - //! For Epoch2 data: Returns epoch-lost flag (1 bit field) - inline uint32_t getEpoch2EpochLost() const { return getBit(5); } - - //! For Epoch2 data: Returns data-lost flag (1 bit field) - inline uint32_t getEpoch2DataLost() const { return getBit(6); } - - //! For Epoch2 data: Returns sync flag (1 bit field) - inline uint32_t getEpoch2Sync() const { return getBit(7); } - - //! For Epoch2 data: Returns the LTS156 bits 11 to 8. This - //! gives information at what time in the Epoche the epoche number - //! was set (4 bit field) - inline uint32_t getEpoch2StampTime() const { return getField(8, 4); } - - //! For Epoch2 data: Returns the epoch number (28 bit field) - // inline uint32_t getEpoch2Number() const { return getField(12, 20); } - // on some machines 32-bit field is not working - // inline uint32_t getEpoch2Number() const { return getField(12, 32); } - inline uint32_t getEpoch2Number() const { return data >> 12; } - - //! For Epoch2 data: Returns the number of the GET4 chip that send - //! the epoche message (8 bit field) - inline uint32_t getEpoch2ChipNumber() const { return getField(44, 4); } - - //! For Epoch2 data: Returns the CRC-8 of the rest of the message - //! (not yet implemented in HW) (8 bit field) - inline uint32_t getEpoch2CRC() const { return getField(40, 8); } - - //! For Epoch2 data: Set epoch-lost flag (1 bit field) - inline void setEpoch2EpochLost(uint32_t v) { setBit(5, v); } - - //! For Epoch2 data: Set data-lost flag (1 bit field) - inline void setEpoch2DataLost(uint32_t v) { setBit(6, v); } - - //! For Epoch2 data: Set sync flag (1 bit field) - inline void setEpoch2Sync(uint32_t v) { setBit(7, v); } - - //! For Epoch2 data: Set the LTS156 bits 11 to 8. This - //! gives information at what time in the Epoche the epoche number - //! was set (4 bit field) - inline void setEpoch2StampTime(uint32_t v) { setField(8, 4, v); } - - //! For Epoch2 data: Set the epoch number (20 bit field) - inline void setEpoch2Number(uint32_t v) { setField(12, 32, v); } - - //! For Epoch2 data: Set the number of the GET4 chip that send - //! the epoche message (8 bit field) - inline void setEpoch2ChipNumber(uint32_t v) { setField(44, 4, v); } - - //! For Epoch2 data: Set the CRC-8 of the rest of the message - //! (not yet implemented in HW) (8 bit field) - inline void setEpoch2CRC(uint32_t v) { setField(40, 8, v); } - - // ---------- Get4 Hit data access methods ---------------- - - //! For Get4 data: Returns Get4 chip number (6 bit field) - inline uint8_t getGet4Number() const { return getField(6, 6); } - - //! For Get4 data: Returns Get4 channel number (2 bit field) - inline uint8_t getGet4ChNum() const { return getField(12, 2); } - - //! For Get4 data: Returns Get4 time stamp, 50 ps binning (19 bit field) - inline uint32_t getGet4Ts() const { return getField(14, 19); } - - //! For Get4 data: Returns Get4 rising or falling edge (1 bit field) - inline uint32_t getGet4Edge() const { return getBit(33); } - - //! For Get4 data: Returns the CRC-8 of the rest of the message. - //! For details check the ROC documentation. (8 bit field) - inline uint32_t getGet4CRC() const { return getField(40, 8); } - - - //! For Get4 data: Sets Get4 chip number (6 bit field) - inline void setGet4Number(uint8_t v) { setField(6, 6, v); } - - //! For Get4 data: Sets Get4 channel number (2 bit field) - inline void setGet4ChNum(uint8_t v) { setField(12, 2, v); } - - //! For Get4 data: Sets Get4 time stamp, 50 ps binning (19 bit field) - inline void setGet4Ts(uint32_t v) { setField(14, 19, v); } - - //! For Get4 data: Sets Get4 rising or falling edge (1 bit field) - inline void setGet4Edge(uint32_t v) { setBit(33, v); } - - //! For Get4 data: Set the CRC-8 of the rest of the message - //! For details check the ROC documentation. (8 bit field) - inline void setGet4CRC(uint32_t v) { setField(40, 8, v); } - - // ---------- System message access methods ---------- - - // 2 bit unused - - //! For SysMes data: Returns system message subtype (8 bit field) - inline uint8_t getSysMesType() const { return getField(8, 8); } - - //! For SysMes data: Returns system message data (32 bit field) - // inline uint32_t getSysMesData() const { return getField(16, 32); } - // on some machine 32-bit field not working - inline uint32_t getSysMesData() const { return data >> 16; } - - //! For SysMes data: Set system message type (8 bit field) - inline void setSysMesType(uint8_t v) { setField(8, 8, v); } - - //! For SysMes data: Set system message data (32 bit field) - inline void setSysMesData(uint32_t v) { setField(16, 32, v); } - - - // ---------- Common functions ----------------------- - - //! Returns \a true is message type is #MSG_NOP (filler message) - inline bool isNopMsg() const { return getMessageType() == MSG_NOP; } - //! Returns \a true is message type is #MSG_HIT (nXYTER hit data) - inline bool isHitMsg() const { return getMessageType() == MSG_HIT; } - //! Returns \a true is message type is #MSG_EPOCH (epoch marker) - inline bool isEpochMsg() const { return getMessageType() == MSG_EPOCH;} - //! Returns \a true is message type is #MSG_SYNC - inline bool isSyncMsg() const { return getMessageType() == MSG_SYNC; } - //! Returns \a true is message type is #MSG_AUX - inline bool isAuxMsg() const { return getMessageType() == MSG_AUX; } - //! Returns \a true is message type is #MSG_EPOCH2 (epoch2 marker) - inline bool isEpoch2Msg() const { return getMessageType() == MSG_EPOCH2;} - //! Returns \a true is message type is #MSG_GET4 (Get4 hit data) - inline bool isGet4Msg() const { return getMessageType() == MSG_GET4; } - //! Returns \a true is message type is #MSG_SYS (system message) - inline bool isSysMsg() const { return getMessageType() == MSG_SYS; } - - //! Returns \a true if system message and subtype #ROC_SYSMSG_DAQ_START - inline bool isStartDaqMsg() const - { return isSysMsg() && (getSysMesType() == SYSMSG_DAQ_START); } - //! Returns \a true if system message and subtype #ROC_SYSMSG_DAQ_FINISH - inline bool isStopDaqMsg() const - { return isSysMsg() && (getSysMesType() == SYSMSG_DAQ_FINISH); } - - - void printData(unsigned kind = msg_print_Prefix | msg_print_Data, uint32_t epoch = 0) const; - - void printData(std::ostream& os, unsigned kind = msg_print_Human, uint32_t epoch = 0) const; - - uint64_t getMsgFullTime(uint32_t epoch) const; - - double getMsgFullTimeD(uint32_t epoch) const; - - //! Expanded timestamp for 250 MHz * 14 bit epochs - inline static uint64_t FullTimeStamp(uint32_t epoch, uint16_t stamp) - { return ((uint64_t) epoch << 14) | (stamp & 0x3fff); } - - //! Expanded timestamp for 250/8*5 MHz * 19 bit epochs - inline static uint64_t FullTimeStamp2(uint32_t epoch, uint32_t stamp) - { return ((uint64_t) epoch << 19) | (stamp & 0x7ffff); } - - - static uint64_t CalcDistance(uint64_t start, uint64_t stop); - - static double CalcDistanceD(double start, double stop); - - // -------------------- methods for working with different formats - - static uint32_t RawSize(MessageFormat fmt); - - bool convertFromOld(void* src); - - bool convertToOld(void* tgt); - - bool assign(void* src, MessageFormat fmt = formatNormal); - - bool copyto(void* tgt, MessageFormat fmt = formatNormal); - }; - -} - - -#endif diff --git a/beamtime/roclight/roc/OperList.h b/beamtime/roclight/roc/OperList.h deleted file mode 100644 index 9e86f0f7e57acce7e9086d6f36107f1c289b817d..0000000000000000000000000000000000000000 --- a/beamtime/roclight/roc/OperList.h +++ /dev/null @@ -1,84 +0,0 @@ -#ifndef ROC_OPERLIST_H -#define ROC_OPERLIST_H - -#include <vector> - -#ifdef HAVE_UINT8_T_HEADER_FILE -#include <_types/_uint8_t.h> -#include <_types/_uint16_t.h> -#include <_types/_uint32_t.h> -#include <_types/_uint64_t.h> -#else -#include <stdint.h> -#endif - -namespace roc { - - struct Oper { - bool isput; - uint32_t addr; - uint32_t value; - - Oper() : isput(false), addr(0), value(0) {} - - Oper(bool _isput, uint32_t _addr, uint32_t _value = 0) : - isput(_isput), - addr(_addr), - value(_value) - { - } - - Oper(const Oper& src) : - isput(src.isput), - addr(src.addr), - value(src.value) - { - } - - }; - - class OperList { - protected: - std::vector<Oper> fList; - - int fErrorOper; // number of operation failed, -1 ok - int fErrorCode; // error code of operation, 0 - ok - - public: - OperList(); - OperList(int noper, bool* isputIn, uint32_t* addr, uint32_t* value); - OperList(const OperList& src); - virtual ~OperList(); - - int number() const { return (int) fList.size(); } - Oper& oper(int n) { return fList[n]; } - const Oper& oper(int n) const { return fList[n]; } - bool isput(int n) const { return oper(n).isput; } - - void clear() { fList.clear(); fErrorOper = -1; fErrorCode = 0; } - - void addOper(const Oper& operIn ) - { fList.push_back(operIn); } - - void addOper(bool isputIn, uint32_t addr, uint32_t value) - { addOper(Oper(isputIn, addr, value)); } - - void addPut(uint32_t addr, uint32_t value) { addOper(true, addr, value); } - - void addGet(uint32_t addr) { addOper(false, addr, 0); } - - void print(); - - int getErrorOper() const { return fErrorOper; } - void setErrorOper(int n) { fErrorOper = n; } - - int getErrorCode() const { return fErrorCode; } - void setErrorCode(int code) { fErrorCode = code; } - }; - -} - - - -#endif - diff --git a/beamtime/roclight/roc/defines_gpio.h b/beamtime/roclight/roc/defines_gpio.h deleted file mode 100644 index 0dbe6450822095800a362405d8ce926d168a1209..0000000000000000000000000000000000000000 --- a/beamtime/roclight/roc/defines_gpio.h +++ /dev/null @@ -1,95 +0,0 @@ -#ifndef ROC_DEFINES_GPIO_H -#define ROC_DEFINES_GPIO_H - - -/*! - * {ROC, read/write, 32 bit} - * Part of \ref roc_iface_syncslave and \ref roc_iface_aux. - */ -#define ROC_GPIO_CONFIG 0x010000 // r/w - -/*! - * {ROC, read/write, 8 bit} This 8 bit register is implemented but has no - * hardware function. It does despite its name <em>not</em> control any - * sync master transmitter timing, since it is only used for recievers. - */ -#define ROC_SYNC1_BAUD_START 0x010100 // r/w -/*! - * {ROC, read/write, 8 bit} Controls for sync master how many 250 MHz clock - * cycles the serial transmitter waits after an odd numbered bit. - * The register contains cycles minus 1, so 4 cycles --> register setting 3 - * - * Part of \ref roc_iface_syncmaster. - */ -#define ROC_SYNC1_BAUD1 0x010104 // r/w -/*! - * {ROC, read/write, 8 bit} Controls for sync master how many 250 MHz clock - * cycles the serial transmitter waits after an even numbered bit. - * The register contains cycles minus 1, so 4 cycles --> register setting 3 - * - * Part of \ref roc_iface_syncmaster. - */ -#define ROC_SYNC1_BAUD2 0x010108 // r/w -/*! - * {ROC, read/write, 8 bit} Determines the rate of sending sync messages out of - * the <em>sync message sender</em> GPIO port. The scale down is settable in - * powers of two, a value of 0 causes a sync message for each epoch, a value - * of 1,2,3,... for each 2nd, 4th, 8th,... epoch. Even though the register - * is 8 bit, only the values 0 to 23 are valid. - * - * Part of \ref roc_iface_syncmaster. - */ -#define ROC_SYNC1_SCALEDOWN 0x01010C // r/w -/*! - * {ROC, read/write, 8 bit} Controls how many 250 MHz clock cycles the serial - * receiver waits after the first falling edge (of the start bit) to sample - * in the middle of the bit cell. Use max(2, 250MHz/(baudrate/2)). - * The register contains cycles minus 1, so 4 cycles --> register setting 3 - * - * Part of \ref roc_iface_syncslave. - */ -#define ROC_SYNC2_BAUD_START 0x010200 // r/w -/*! - * {ROC, read/write, 8 bit} Controls for sync slave channel 0 how many 250 MHz - * clock cycles the serial receiver waits after an odd numbered bit. - * Use 250MHz/baudrate. - * The register contains cycles minus 1, so 4 cycles --> register setting 3 - * - * Part of \ref roc_iface_syncslave. - */ -#define ROC_SYNC2_BAUD1 0x010204 // r/w -/*! - * {ROC, read/write, 8 bit} Controls for sync slave channel 0 how many 250 MHz - * clock cycles the serial receiver waits after an even numbered bit. - * Use 250MHz/baudrate. - * The register contains cycles minus 1, so 4 cycles --> register setting 3 - * - * Part of \ref roc_iface_syncslave. - */ -#define ROC_SYNC2_BAUD2 0x010208 // r/w -/*! - * {ROC, read/write, 8 bit} Like #ROC_SYNC2_BAUD_START for sync slave channel 1. - * Part of \ref roc_iface_syncslave. - */ -#define ROC_SYNC3_BAUD_START 0x010300 // r/w -/*! - * {ROC, read/write, 8 bit} Like #ROC_SYNC2_BAUD1 for sync slave channel 1. - * Part of \ref roc_iface_syncslave. - */ -#define ROC_SYNC3_BAUD1 0x010304 // r/w -/*! - * {ROC, read/write, 8 bit} Like #ROC_SYNC2_BAUD2 for sync slave channel 1. - * Part of \ref roc_iface_syncslave. - */ -#define ROC_SYNC3_BAUD2 0x010308 // r/w - - -#define SYNC_M 1 -#define SYNC_S0 2 -#define SYNC_S1 3 -#define AUX0 4 -#define AUX1 5 -#define AUX2 6 -#define AUX3 7 - -#endif diff --git a/beamtime/roclight/roc/defines_i2c.h b/beamtime/roclight/roc/defines_i2c.h deleted file mode 100644 index 95dc39d2084b61ceb68ec4c06b1f1e828bf8f861..0000000000000000000000000000000000000000 --- a/beamtime/roclight/roc/defines_i2c.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef ROC_DEFINES_I2C_H -#define ROC_DEFINES_I2C_H - -/*! - * {ROC, read/write, 8/16 bit} I2C bus data port. A write into this register - * or a read from this register will initiate a initiate an I2C bus write - * or read cycle, respectively. The addressing is determined by the - * contents of the #ROC_I2C1_SWITCH, #ROC_I2C1_SLAVEADDR, and - * #ROC_I2C1_REGISTER registers. Any error conditions during the - * I2C bus cycle are registered in #ROC_I2C1_ERROR. The setting of - * #ROC_NX_I2C_READ16 determines whether 8 or 16 bit are read. Write - * cycles are always 8 bit. - * - * Part of \ref roc_iface_i2cbus. - */ -#define ROC_NX_I2C_DATA 0x410000 // r/w -/*! - * {ROC, read/write, 7 bit} Holds the I2C slave address for the next - * I2C bus access. - * - * Part of \ref roc_iface_i2cbus. - */ -#define ROC_NX_I2C_SLAVEADDR 0x41000C // r/w -/*! - * {ROC, write-only, 8 bit} Holds the device register address for the - * next I2C bus access. The register is write-only. The address stays - * after an I2C bus cycle, it is <em>not</em> auto-incremented. - * - * Part of \ref roc_iface_i2cbus. - */ -#define ROC_NX_I2C_REGISTER 0x410010 // w -/*! - * {ROC, read-only, 2 bit} Holds error status flags of the last I2C bus access - * \li bit 0 is set when a bus cycle is aborted due to a timeout, e.g. - * because a slave does excessive cycle stretching. Firmware after - * 01070208 has proper pull-ups, so an open I2C bus shouldn't cause - * timeouts anymore. - * \li bit 1 is set when an I2C acknowledge is missing, e.g. because no - * device responds to the slave address. - * - * Part of \ref roc_iface_i2cbus. - */ -#define ROC_NX_I2C_ERROR 0x410020 // r -/*! - * {ROC, write-only, 1 bit} Selects the port to be used for the next I2C - * bus access. - * - * Part of \ref roc_iface_i2cbus. - */ -#define ROC_NX_I2C_SWITCH 0x410100 // w - -/*! - * {ROC, write-only, 1 bit} Determines whether 1 or 2 bytes are read in a - * I2C read cycle. When LSB is 0, the default, only a single byte is read. - * When LSB is 1, the interface expects that 2 bytes are transmitted from - * the device and a total of 16 bit is returned in ROC_NX_I2C_DATA. - * - * Part of \ref roc_iface_i2cbus. - */ -#define ROC_NX_I2C_READ16 0x410104 // w - - -#endif diff --git a/beamtime/roclight/roc/defines_optic.h b/beamtime/roclight/roc/defines_optic.h deleted file mode 100644 index 115c49b38e1e8924c3b7dc6163e1ee1d02edcc54..0000000000000000000000000000000000000000 --- a/beamtime/roclight/roc/defines_optic.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef ROC_DEFINES_OPTIC_H -#define ROC_DEFINES_OPTIC_H - -#define ROC_OPTICS_HWV 0x200000 // r - -// true if there are radiation mitigation techniques in use -#define ROC_OPTICS_RADTOL 0x200004 // r - -// enable/disable data generator -#define ROC_OPTICS_DATAGEN 0x200300 // W - -// start daq, enables sending of data from ROC via optic -#define ROC_OPTICS_START_DAQ 0x200100 // w - -// stop daq, disables sending of data from ROC via optic -#define ROC_OPTICS_STOP_DAQ 0x200104 // w - -#define ROC_OPTICS_DLMGEN 0x201000 // w -#define ROC_OPTICS_DLM_HISTORY 0x201004 // r - - -#endif diff --git a/beamtime/roclight/roc/defines_roc.h b/beamtime/roclight/roc/defines_roc.h deleted file mode 100644 index 93f37ac273a08359e93af3d6a5a2b3015bd909e8..0000000000000000000000000000000000000000 --- a/beamtime/roclight/roc/defines_roc.h +++ /dev/null @@ -1,150 +0,0 @@ -#ifndef ROC_DEFINES_ROC_H -#define ROC_DEFINES_ROC_H - - -#define KNUT_VERSION 0x02000100 // All parts share first 4 digits - -#define ROC_SUCCESS 0 // Success -#define ROC_READBACK_ERROR 1 // Readback failed (different value) -#define ROC_ADDRESS_ERROR 2 // Wrong / unexisting address -#define ROC_VALUE_ERROR 3 // Wrong value -#define ROC_PERMISSION_ERROR 4 // Permission denied (to low level addresses) -#define ROC_ANSWER_DELAYED 5 // The called function needs longer to run. //DEPRECATED -#define ROC_NETWORK_TRANSMISSION_ERROR 6 // Some slow control udp-data packets got lost. -#define ROC_I2C_ERROR 7 // No Response (No Ack) Error on I2C bus. - - -/************************************ - * address space - ***********************************/ - -//myOPB (ROC hardware) -//#define myOPB_LOW 0x00000000 // LOW-Marker of myOPB-Range //DEPRECATED -//#define myOPB_HIGH 0x00ffffff // HIGH-Marker of myOPB-Range //DEPRECATED - - -/*! - * {ROC, read-only} Holds the version number of the front-end and - * back-end type of the ROC - * Frontend: - * 1 - NX - * 2 - FEET - * Backend: - * 1 - Optics - * 2 - Ethernet FX20 - * 3 - Ethernet FX40 - */ -#define ROC_TYPE 0x000000 // r -/*! - * {ROC, read-only} Holds the version number of the FPGA firmware - */ -#define ROC_HWV 0x000004 // r - -/*! - * {ROC, read-only, 8 bit} FPGA type (1: Virtex-4 fx20, 2: Virtex-4 fx40, 3: Virtex-4 fx60, 4: Spartan 6) - */ -#define ROC_FPGA_TYPE 0x000008 // r - -/*! - * {ROC, read-write} Unique ROC id, in Optic it is real register - * in Ethernet - emulated. - */ -#define ROC_ROCID 0x000010 // r/w - -/*! - * {ROC, read-only, 16 bit} subversion revision number of the firmware - */ -#define ROC_SVN_REVISION 0x000014 // r - -/*! - * {ROC, read-only, 32 bit} date and time the firmware was build (no of sec since 1970-01-01 0:00) - */ -#define ROC_BUILD_TIME 0x000018 // r - -/*! - * {ROC, function} A write access will cause the FPGA to reconfigure and, if - * available, the PPC to reboot. This is a cold restart with immediate effect, - * the write into this location will thus not be acknowledged. - */ -#define ROC_SYSTEM_RESET 0x000100 // w - -#define ROC_ETH_HWV 0x100000 // r Hardware-Version -#define ROC_ETH_SWV 0x100004 // r Software-Version - -#define ROC_ADDSYSMSG 0x000200 // w Write Custom System-Message - -#define ROC_CMD_LST_NR 0x020000 // w -#define ROC_CMD_LST_ACTIVE 0x020004 // w -#define ROC_CMD_LST_MEM 0x021000 // w - -// different constants for commands list handling - -#define ROC_CMD_LST_SIZE 0x000800 // size of memory for commands lists -#define ROC_CMD_LST_NUMBER 0x000008 // number of commands lists -#define ROC_CMD_LST_PUT 0x02000000 // PUT command in commands list -#define ROC_CMD_LST_ADDRMASK 0x00ffffff // address mask for operations lists - - -// /*! -// * {ROC, read/write, 3 bit} This register holds the ROC number inserted into -// * all data messages. -// * Part of \ref roc_iface_daq. -// */ -//#define ROC_NUMBER 0x00040 // r/w //DEPRECATED - -/*! - *{ROC, write-only, 1 bit} ACTIVE HIGH since V2.0.0.2! - Resets the nXYTER-TS - * - * Part of \ref roc_iface_nxyter_data. - */ -#define ROC_NX_TS_RESET 0x400010 // w -/*! - * {ROC, function} A write access will clear the message FIFO, thus discard all - * data held in the buffers on the FPGA. It will insert a 'FIFO RESET' system - * message into the data stream. - * Part of \ref roc_iface_daq. -*/ -#define ROC_NX_FIFO_RESET 0x400014 // w -/*! - * {ROC, write-only, 1 bit} ACTIVE HIGH! - Starts nXYTER-Receiver-Init - * - * Part of \ref roc_iface_nxyter_data. - */ -#define ROC_NX_INIT 0x400018 // w - -/*! - * {ROC, read-only, ? bit} - * Part of \ref roc_iface_daq. - */ -#define ROC_NX_BURST1 0x400100 // r -/*! - * {ROC, read-only, ? bit} - * Part of \ref roc_iface_daq. - */ -#define ROC_NX_BURST2 0x400104 // r -/*! - * {ROC, read-only, ? bit} - * Part of \ref roc_iface_daq. - */ -#define ROC_NX_BURST3 0x400108 // r - -/*! - * {ROC, read-only, 2 bit} - * Part of \ref roc_iface_daq. - */ -#define ROC_NX_THROTTLE 0x401200 // r - - -//ROC/FEB Parameters - -/*! - * Symbolic name for \ref glo_roc_port number 0 - */ -#define CON19 0 -/*! - * Symbolic name for \ref glo_roc_port number 1 - */ -#define CON20 1 - -#endif - diff --git a/beamtime/roclight/roc/defines_udp.h b/beamtime/roclight/roc/defines_udp.h deleted file mode 100644 index 476162830c723551be148296356c96d01d44fa42..0000000000000000000000000000000000000000 --- a/beamtime/roclight/roc/defines_udp.h +++ /dev/null @@ -1,197 +0,0 @@ -#ifndef ROC_DEFINES_UDP_H -#define ROC_DEFINES_UDP_H - -#define ROC_PASSWORD 832226211 - -//ROC software -#define ROC_ETH_OCM 0x110090 // r/w activate OPB-2-OCM-Prefetcher - - - -//sdcard -#define ROC_ETH_CFG_READ 0x110060 // w Beim Schreiben einer 1 werden die Konfigurationsdaten (IP, MAC, Delays) von der SD-Karte gelesen -#define ROC_ETH_CFG_WRITE 0x110064 // w Beim Schreiben einer 1 werden die Konfigurationsdaten (IP, MAC, Delays) auf der SD-Karte gespeichert -#define ROC_ETH_OVERWRITE_SD_FILE 0x110068 // w -//network -#define ROC_ETH_SWITCHCONSOLE 0x110100 // r/w -#define ROC_ETH_START_DAQ 0x100100 // w -#define ROC_ETH_STOP_DAQ 0x100104 // w -#define ROC_ETH_SUSPEND_DAQ 0x100108 // w go into suspend state -#define ROC_ETH_IP_ADDRESS 0x110000 // r/w -#define ROC_ETH_NETMASK 0x110004 -#define ROC_ETH_MAC_ADDRESS_UPPER 0x110008 // r/w upper two bytes -#define ROC_ETH_MAC_ADDRESS_LOWER 0x11000C // r/w lower four bytes -#define ROC_ETH_MASTER_LOGIN 0x110010 // r/w -#define ROC_ETH_MASTER_DATAPORT 0x110014 // r/w data port of master node -#define ROC_ETH_MASTER_CTRLPORT 0x110018 // r/w -#define ROC_ETH_BUFFER_FLUSH_TIMER 0x11001C // r/w -#define ROC_ETH_MASTER_LOGOUT 0x110020 // w -#define ROC_ETH_MASTER_IP 0x110024 // r -#define ROC_ETH_RESTART_NETWORK 0x110028 // w -#define ROC_ETH_CONSOLE_OUTPUT 0x11002C // w -#define ROC_ETH_LOST_ETHER_FRAMES 0x110030 // r ethernet frames lost -#define ROC_ETH_UKNOWN_ETHER_FRAMES 0x110034 // r number of ethernet frames with tag other than IP and ARP -#define ROC_ETH_TEMAC_PRINT 0x11003C // w - just print some Temac registers and config -#define ROC_ETH_TEMAC_REG0 0x110040 // r/w - set or read Remac config register -#define ROC_ETH_CTRLPORT 0x110044 // r/w - control port number -#define ROC_ETH_DATAPORT 0x110048 // r/w - data port number -#define ROC_ETH_BURST_LOOPCNT 0x11004C // r/w - number of readout in burst loops -#define ROC_ETH_OCM_LOOPCNT 0x110050 // r/w - number of readout in ocm loops -#define ROC_ETH_CONSOLE_CMD 0x11006C // w - executes provided console command -#define ROC_ETH_STATBLOCK 0x110070 // r - block with sc_statistic -#define ROC_ETH_DEBUGMSG 0x110074 // r - last output of sc_printf command -#define ROC_ETH_HIGHWATER 0x110080 // r/w - value of high water marker (in number of UDP buffers, maximum is about 78000 buffers or 112 MB) -#define ROC_ETH_LOWWATER 0x110084 // r/w - value of low water marker (in number of UDP buffers, default is 10% of highwater) -#define ROC_ETH_NUMBUFALLOC 0x110088 // r - number of allocated UDP buffers - -//Flash -#define ROC_ETH_FLASH_KIBFILE_FROM_DDR 0x120000 // w position value is parsed right now only 0 is supported -#define ROC_ETH_FLASH_ADDR 0x120004 // w - set current FlashFileBuffer-Address Pointer -#define ROC_ETH_FLASH_DATA 0x120008 // r/w - write rawData to FlashFileBuffer and Increment Pointer / read Data from FlashFileBuffer and Pointer++; -#define ROC_ETH_FLASH_CLEAR_FILEBUFFER 0x12000C // w - clears the filebuffer, sets FlashFileBuffer-Address Pointer to 0 -#define ROC_ETH_CHECK_BITFILEBUFFER 0x120010 // r -#define ROC_ETH_CHECK_BITFILEFLASH0 0x120014 // r -#define ROC_ETH_CHECK_BITFILEFLASH1 0x120018 // r -#define ROC_ETH_CHECK_FILEBUFFER 0x120020 // r - -#define ROC_ETH_DLM 0x130000 // w - create a DLM-Message (1=Timestamp-Reset, 4=Custom-Message) - - - -/************************************ - * address space finished - ***********************************/ - - - - - -// default ports number of ROC itself -#define ROC_DEFAULT_CTRLPORT 13132 -#define ROC_DEFAULT_DATAPORT 13131 - -//ROC TAGS -#define ROC_PEEK 111 -#define ROC_POKE 112 -#define ROC_CONSOLE 113 -#define ROC_NOPER 114 - -#define NOPER_PUT 0x80000000 // to write address, one should set high LSB -#define NOPER_GET 0x0 // if address not modified, just do get operation -#define NOPER_OPER_MASK 0x80000000 -#define NOPER_ADDR_MASK 0x7fffffff - - -#define UDP_PAYLOAD_OFFSET 42 -#define MAX_UDP_PAYLOAD 1472 -#define MESSAGES_PER_PACKET 243 - -//4mb buffer as in syscore for file transfer -#define SC_BITFILE_BUFFER_SIZE 4194304 - - -#ifdef HAVE_UINT8_T_HEADER_FILE -#include <_types/_uint8_t.h> -#include <_types/_uint16_t.h> -#include <_types/_uint32_t.h> -#include <_types/_uint64_t.h> -#else -#include <stdint.h> -#endif - -#pragma pack(push, 1) - -namespace roc { - - struct UdpMessage - { - uint8_t tag; - uint8_t pad[3]; - uint32_t password; - uint32_t id; - uint32_t address; - uint32_t value; - - // Add virtual destructor to get rid of warning when using as - // base struct - virtual ~UdpMessage(); - }; - - struct UdpMessageFull : public UdpMessage - { - uint8_t rawdata[MAX_UDP_PAYLOAD - sizeof(UdpMessage)]; - }; - - struct UdpDataRequest - { - uint32_t password; - uint32_t reqpktid; - uint32_t frontpktid; - uint32_t tailpktid; - uint32_t numresend; - - // Add virtual destructor to get rid of warning when using as - // base struct - virtual ~UdpDataRequest(); - }; - - struct UdpDataRequestFull : public UdpDataRequest - { - uint32_t resend[(MAX_UDP_PAYLOAD - sizeof(struct UdpDataRequest)) / 4]; - }; - - struct UdpDataPacket - { - uint32_t pktid; - uint32_t lastreqid; - uint32_t nummsg; - // here all messages should follow - - // Add virtual destructor to get rid of warning when using as - // base struct - virtual ~UdpDataPacket(); - }; - - struct UdpDataPacketFull : public UdpDataPacket - { - uint8_t msgs[MAX_UDP_PAYLOAD - sizeof(struct UdpDataPacket)]; - }; - - struct BoardStatistic { - uint32_t dataRate; // data taking rate in B/s - uint32_t sendRate; // network send rate in B/s - uint32_t recvRate; // network recv rate in B/s - uint32_t nopRate; // double-NOP messages 1/s - uint32_t frameRate; // unrecognized frames 1/s - uint32_t takePerf; // relative use of time for data taking (*100000) - uint32_t dispPerf; // relative use of time for packets dispatching (*100000) - uint32_t sendPerf; // relative use of time for data sending (*100000) - uint32_t daqState; // current daq state - }; - - - /** ISE Binfile header - * A bitfile from Xilinx ISE consists of a binfile and a fileheader. - * We need only a bin file for reprogramming the virtex. So - * we use this header in front of the bin file - * to store it on the Actel Flash. Its size is 512 bytes. - * Behind the Header, the binfile will be written to the flash */ - - union ISEBinfileHeader { - struct { - uint8_t ident[4]; - uint32_t headerSize; - uint32_t binfileSize; - uint8_t XORCheckSum; - uint8_t bitfileName[65]; - uint32_t timestamp; - }; - uint8_t bytes[512]; - }; - -} - -#pragma pack(pop) - - -#endif diff --git a/beamtime/roclight/src_mbs/LmdFile.cxx b/beamtime/roclight/src_mbs/LmdFile.cxx deleted file mode 100644 index fc5219ff84b4d09f8862756ca82e64cb4d0b7d5e..0000000000000000000000000000000000000000 --- a/beamtime/roclight/src_mbs/LmdFile.cxx +++ /dev/null @@ -1,151 +0,0 @@ -/************************************************************ - * The Data Acquisition Backbone Core (DABC) * - ************************************************************ - * Copyright (C) 2009 - * - * GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * Planckstr. 1, 64291 Darmstadt, Germany * - * Contact: http://dabc.gsi.de * - ************************************************************ - * This software can be used under the GPL license * - * agreements as stated in LICENSE.txt file * - * which is part of the distribution. * - ************************************************************/ - -#include "LmdFile.h" - -#include <stdio.h> -#include <stdint.h> -#include <stdlib.h> - -extern "C" { - #include "sMbs.h" - #define FILEONLY // <- Anyway just hack to read old LMD data files - #include "fLmd.h" -} - - -mbs::LmdFile::LmdFile(): - fMode(mNone), - fControl(fLmdAllocateControl()), - fLastError(LMD__SUCCESS) -{ -} - -mbs::LmdFile::~LmdFile() -{ - Close(); - - free((sLmdControl*)fControl); - fControl = 0; - fLastError = LMD__SUCCESS; -} - -bool mbs::LmdFile::OpenWrite(const char* fname, uint32_t buffersize) -{ - Close(); - - fLastError = fLmdPutOpen((sLmdControl*) fControl, - (char*) fname, - LMD__INTERNAL_HEADER, - buffersize, - LMD__OVERWRITE, - LMD__NO_INDEX, - LMD__LARGE_FILE); - - if (fLastError != LMD__SUCCESS) return false; - fMode = mWrite; - return true; -} - -bool mbs::LmdFile::OpenRead(const char* fname, uint32_t buffersize) -{ - Close(); - - if (buffersize < 1024) { - printf("Buffer size %u too small, use 1024\n", buffersize); - buffersize = 1024; - } - - printf("mbs::LmdFile::OpenRead => Buffer size: %u filename: %s\n", buffersize, fname); - fLastError = fLmdGetOpen((sLmdControl*) fControl, - (char*) fname, - LMD__INTERNAL_HEADER, - buffersize, - LMD__NO_INDEX); - - if (fLastError != LMD__SUCCESS) return false; - fMode = mRead; - return true; -} - -void mbs::LmdFile::Close() -{ - if (IsWriteMode()) { - fLastError = fLmdPutClose((sLmdControl*) fControl); - } else - if (IsReadMode()) { - fLastError = fLmdGetClose((sLmdControl*) fControl); - } else - fLastError = LMD__SUCCESS; - - fMode = mNone; -} - -bool mbs::LmdFile::WriteElements(Header* hdr, unsigned num) -{ - if (!IsWriteMode() || (num==0)) { - fLastError = LMD__FAILURE; - return false; - } - - if (num==1) - fLastError = fLmdPutElement((sLmdControl*) fControl, (sMbsHeader*) hdr); - else - fLastError = fLmdPutBuffer((sLmdControl*) fControl, (sMbsHeader*) hdr, num); - - return (fLastError == LMD__SUCCESS); -} - -mbs::Header* mbs::LmdFile::ReadElement() -{ - if (!IsReadMode()) { - fLastError = LMD__FAILURE; - return 0; - } - -// sMbsHeader* hdr = fLmdGetElement((sLmdControl*) fControl, LMD__NO_INDEX); - sMbsHeader* hdr = NULL; - fLmdGetElement((sLmdControl*) fControl, LMD__NO_INDEX, &hdr); - - if (hdr==0) Close(); - - return (mbs::Header*) hdr; -} - -unsigned int mbs::LmdFile::ReadBuffer(void* buf, uint32_t& bufsize) -{ - if (!IsReadMode() || (buf==0) || (bufsize==0)) { - fLastError = LMD__FAILURE; - return 0; - } - - uint32_t numev = 0; - - fLastError = fLmdGetBuffer((sLmdControl*) fControl, - (sMbsHeader*) buf, bufsize, - &numev, &bufsize); - - if (fLastError == GETLMD__EOFILE) Close(); - - return numev; -} - -bool mbs::LmdFile::WriteEvents(EventHeader* hdr, unsigned num) -{ - return WriteElements(hdr, num); -} - -mbs::EventHeader* mbs::LmdFile::ReadEvent() -{ - return (mbs::EventHeader*) ReadElement(); -} diff --git a/beamtime/roclight/src_mbs/LmdInput.cxx b/beamtime/roclight/src_mbs/LmdInput.cxx deleted file mode 100644 index 1eb02f2347f9a5205c309649a7c5dad1e31181a2..0000000000000000000000000000000000000000 --- a/beamtime/roclight/src_mbs/LmdInput.cxx +++ /dev/null @@ -1,272 +0,0 @@ -/************************************************************ - * The Data Acquisition Backbone Core (DABC) * - ************************************************************ - * Copyright (C) 2009 - * - * GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * Planckstr. 1, 64291 Darmstadt, Germany * - * Contact: http://dabc.gsi.de * - * Contact: http://dabc.gsi.de * - ************************************************************ - * This software can be used under the GPL license * - * agreements as stated in LICENSE.txt file * - * which is part of the distribution. * - ************************************************************/ - -#include "mbs/LmdInput.h" - -#include <string.h> -#include <stdlib.h> - -/* *** PAL edit *** -#include "dabc/logging.h" -#include "dabc/Buffer.h" -#include "dabc/FileIO.h" -#include "dabc/Manager.h" -#include "dabc/Port.h" - ***************** */ -#include "FairLogger.h" - -/* *** PAL: for wildcard support *** */ -#include "TRegexp.h" -#include "TSystem.h" -/* ***************** */ - -#include "mbs/MbsTypeDefs.h" - -mbs::LmdInput::LmdInput(const char* fname, uint32_t bufsize) : -// dabc::DataInput(), *** PAL edit *** - fFileName(fname ? fname : ""), - fBufferSize(bufsize), -// fFilesList(0), - fInputFileList(), // *** PAL edit, from CbmSourceLmdNew *** - fFile(), - fCurrentFileName(), - fCurrentRead(0) -{ -} - -mbs::LmdInput::~LmdInput() -{ - // FIXME: cleanup should be done much earlier - CloseFile(); -/* *** PAL edit *** - if (fFilesList) { - dabc::Object::Destroy(fFilesList); - fFilesList = 0; - } - ***************** */ - fInputFileList.Delete(); -} - -/* *** PAL edit: We don't use the xml config in CbmRoot *** -bool mbs::LmdInput::Read_Init(const dabc::WorkerRef& wrk, const dabc::Command& cmd) -{ - fFileName = wrk.Cfg(mbs::xmlFileName, cmd).AsStdStr(fFileName); - fBufferSize = wrk.Cfg(dabc::xmlBufferSize, cmd).AsInt(fBufferSize); - - // DOUT1(("BufferSize = %d", fBufferSize)); - - return Init(); -} - ***************** */ - -bool mbs::LmdInput::Init() -{ -/* *** PAL edit: Avoid using DABC data types, use ROOT ones instead *** - if (fFileName.length()==0) return false; - - if (fFilesList!=0) { - EOUT(("Files list already exists")); - return false; - } - - if (fBufferSize==0) { - EOUT(("Buffer size not specified !!!!")); - return false; - } - - if (strpbrk(fFileName.c_str(),"*?")!=0) - fFilesList = dabc::mgr()->ListMatchFiles("", fFileName.c_str()); - else { - fFilesList = new dabc::Object(0, "FilesList", true); - new dabc::Object(fFilesList, fFileName.c_str()); - } - ***************** */ - -/* *** PAL edit: From root v5.34 method: Int_t TChain::Add(const char* name, Long64_t nentries ) - * *** Attempt to get Wildcard support in a OS independent way - */ - TString basename = fFileName.c_str(); - // case with one single file - if ( kFALSE == basename.MaybeWildcard()) { - fInputFileList.Add(new TObjString(basename)); - } // if ( kFALSE == basename.MaybeWildcard()) - else - { - TString suffix = ""; // PAL => In principle not suffix in our case as we use only local files - - // wildcarding used in name - Int_t slashpos = basename.Last('/'); - TString directory; - if (slashpos>=0) { - directory = basename(0,slashpos); // Copy the directory name - basename.Remove(0,slashpos+1); // and remove it from basename - } else { - directory = gSystem->UnixPathName(gSystem->WorkingDirectory()); // PAL: Convert UNIX path to local path - } - - const char *file; - const char *epath = gSystem->ExpandPathName(directory.Data()); - void *dir = gSystem->OpenDirectory(epath); - delete [] epath; - if (dir) { - //create a TList to store the file names (not yet sorted) - TList l; - TRegexp re(basename,kTRUE); - while ((file = gSystem->GetDirEntry(dir))) { - if (!strcmp(file,".") || !strcmp(file,"..")) continue; - TString s = file; - if ( (basename!=file) && s.Index(re) == kNPOS) continue; - l.Add(new TObjString(file)); - } - gSystem->FreeDirectory(dir); - //sort the files in alphanumeric order - l.Sort(); - TIter next(&l); - TObjString *obj; - while ((obj = (TObjString*)next())) { - file = obj->GetName(); - fInputFileList.Add(new TObjString( TString::Format("%s/%s%s",directory.Data(),file,suffix.Data()) )); - } - l.Delete(); - } - } // else of if ( kFALSE == basename.MaybeWildcard()) -/* - ***************** */ - -// fInputFileList.Add(new TObjString(fFileName.c_str())); // *** PAL edit, from CbmSourceLmdNew, not support for wildcard *** - - PrintFileList(); /* *** PAL edit: Add a bit of info at startup *** */ - - return OpenNextFile(); -} - -void mbs::LmdInput::PrintFileList() -{ - LOG(info) << "mbs::LmdInput::PrintFileList => Following files will be open/read next:"; - - TIter next(&fInputFileList); - TObjString *obj; - while ((obj = (TObjString*)next())) { - LOG(info) << " " - << obj->GetString(); - } // while ((obj = (TObjString*)next())) - LOG(info) << "mbs::LmdInput::PrintFileList => If the order is not what is planned," - << " please do not use wildcards and add files individually"; -} - -bool mbs::LmdInput::OpenNextFile() -{ - CloseFile(); - -/* *** PAL edit: Avoid using DABC data types, use ROOT ones instead *** - if ((fFilesList==0) || (fFilesList->NumChilds()==0)) return false; - - const char* nextfilename = fFilesList->GetChild(0)->GetName(); - - bool res = fFile.OpenRead(nextfilename); - ***************** */ - if ( 0 == fInputFileList.GetSize() ) return false;// *** PAL edit, from CbmSourceLmdNew, - TObjString* tmp = dynamic_cast<TObjString*>(fInputFileList.At(0)); - TString str = tmp->GetString(); - const char* nextfilename = str.Data(); - - LOG(info) << "mbs::LmdInput::OpenNextFile => " - << " -- " << Form("%s", nextfilename); - LOG(debug1) << "mbs::LmdInput::OpenNextFile => " << tmp - << " -- " << tmp->GetString() - << " -- " << nextfilename - << " -- " << Form("%s", str.Data()); - - bool res = fFile.OpenRead( nextfilename ); - - if (!res) - LOG(error) << Form("Cannot open file %s for reading, errcode:%u", nextfilename, fFile.LastError()); - else { - fCurrentFileName = nextfilename; - LOG(debug) << Form("Open lmd file %s for reading", fCurrentFileName.c_str()); - } - -/* *** PAL edit: Avoid using DABC data types, use ROOT ones instead *** - fFilesList->DeleteChild(0); - ***************** */ - fInputFileList.Remove( fInputFileList. First() );// *** PAL edit, from CbmSourceLmdNew amd ROOT Website - - return res; -} - - -bool mbs::LmdInput::CloseFile() -{ - fFile.Close(); - fCurrentFileName = ""; - fCurrentRead = 0; - return true; -} - -/* *** PAL edit: Run offline with LMD file and without DABC *** -unsigned mbs::LmdInput::Read_Size() -{ - // get size of the buffer which should be read from the file - - if (!fFile.IsReadMode()) - if (!OpenNextFile()) return dabc::di_EndOfStream; - - return fBufferSize; -} - ***************** */ - -/* *** PAL edit: Run offline with LMD file and without DABC *** -unsigned mbs::LmdInput::Read_Complete(dabc::Buffer& buf) -{ - unsigned numev = 0; - uint32_t bufsize = 0; - - do { - - if (!fFile.IsReadMode()) return dabc::di_Error; - - // TODO: read into segmented buffer - bufsize = buf.SegmentSize(0); - - numev = fFile.ReadBuffer(buf.SegmentPtr(0), bufsize); - - if (numev==0) { - DOUT3(("File %s return 0 numev for buffer %u - end of file", fCurrentFileName.c_str(), buf.GetTotalSize())); - if (!OpenNextFile()) return dabc::di_EndOfStream; - } - - } while (numev==0); - - fCurrentRead += bufsize; - buf.SetTotalSize(bufsize); - buf.SetTypeId(mbs::mbt_MbsEvents); - - return dabc::di_Ok; -} - ***************** */ - -mbs::EventHeader* mbs::LmdInput::ReadEvent() -{ - while (true) { - if (!fFile.IsReadMode()) return 0; - - mbs::EventHeader* hdr = fFile.ReadEvent(); - if (hdr!=0) return hdr; - - LOG(debug) << Form("File %s return 0 - end of file", fCurrentFileName.c_str()); - if (!OpenNextFile()) return 0; - } - - return 0; -} diff --git a/beamtime/roclight/src_mbs/MbsTypeDefs.cxx b/beamtime/roclight/src_mbs/MbsTypeDefs.cxx deleted file mode 100644 index 71f2a55af70a4f8b47d2057ac62ce2486b71a349..0000000000000000000000000000000000000000 --- a/beamtime/roclight/src_mbs/MbsTypeDefs.cxx +++ /dev/null @@ -1,199 +0,0 @@ -/************************************************************ - * The Data Acquisition Backbone Core (DABC) * - ************************************************************ - * Copyright (C) 2009 - * - * GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * Planckstr. 1, 64291 Darmstadt, Germany * - * Contact: http://dabc.gsi.de * - ************************************************************ - * This software can be used under the GPL license * - * agreements as stated in LICENSE.txt file * - * which is part of the distribution. * - ************************************************************/ - -#ifdef __APPLE__ -// Mac OS X / Darwin features -#include <libkern/OSByteOrder.h> -#define bswap_16(x) OSSwapInt16(x) -#define bswap_32(x) OSSwapInt32(x) -#define bswap_64(x) OSSwapInt64(x) -#else -#include <byteswap.h> -#endif - -#include "MbsTypeDefs.h" - -#include <string.h> - -const char* mbs::typeLmdInput = "mbs::LmdInput"; -const char* mbs::typeLmdOutput = "mbs::LmdOutput"; -const char* mbs::typeTextInput = "mbs::TextInput"; -const char* mbs::typeServerTransport = "mbs::ServerTransport"; -const char* mbs::typeClientTransport = "mbs::ClientTransport"; - - -const char* mbs::protocolLmd = "lmd"; -const char* mbs::protocolMbs = "mbs"; -const char* mbs::protocolMbsTransport = "mbst"; -const char* mbs::protocolMbsStream = "mbss"; - -// Command names used in combiner module: -const char* mbs::comStartServer = "StartServer"; -const char* mbs::comStopServer = "StopServer"; -const char* mbs::comStartFile = "StartFile"; -const char* mbs::comStopFile = "StopFile"; - -// port names and name formats: -const char* mbs::portOutput = "Output"; -const char* mbs::portOutputFmt = "Output%d"; -const char* mbs::portInput = "Input"; -const char* mbs::portInputFmt = "Input%d"; -const char* mbs::portFileOutput = "FileOutput"; -const char* mbs::portServerOutput = "ServerOutput"; - - -// tag names for xml config file: -const char* mbs::xmlFileName = "MbsFileName"; -const char* mbs::xmlSizeLimit = "MbsFileSizeLimit"; -const char* mbs::xmlServerName = "MbsServerName"; -const char* mbs::xmlServerKind = "MbsServerKind"; -const char* mbs::xmlServerPort = "MbsServerPort"; -const char* mbs::xmlServerScale = "MbsServerScale"; -const char* mbs::xmlNormalOutput = "DoOutput"; -const char* mbs::xmlFileOutput = "DoFile"; -const char* mbs::xmlServerOutput = "DoServer"; - -const char* mbs::xmlTextDataFormat = "MbsTextFormat"; -const char* mbs::xmlTextNumData = "MbsTextNumData"; -const char* mbs::xmlTextHeaderLines = "MbsTextHeader"; -const char* mbs::xmlTextCharBuffer = "MbsCharBuffer"; - - -const char* mbs::xmlCombineCompleteOnly = "BuildCompleteEvents"; -const char* mbs::xmlCheckSubeventIds = "CheckSubIds"; -const char* mbs::xmlEvidMask = "EventIdMask"; -const char* mbs::xmlEvidTolerance = "MaxDeltaEventId"; -const char* mbs::xmlSpecialTriggerLimit = "SpecialTriggerLimit"; -const char* mbs::xmlCombinerRatesPrefix = "CombinerRatesPrefix"; - -unsigned mbs::EventHeader::NumSubevents() const -{ - unsigned cnt = 0; - SubeventHeader* sub = 0; - while ((sub = NextSubEvent(sub)) != 0) cnt++; - return cnt; -} - -void mbs::BufferHeader::Init(bool newformat) -{ - iWords = 0; - iType = newformat ? MBS_TYPE(100,1) : MBS_TYPE(10,1); - iBufferId = 0; - iNumEvents = 0; - iTemp = 0; - iSeconds = 0; - iNanosec = 0; - iEndian = 0; - iLast = 0; - iUsedWords = 0; - iFree3 = 0; - SetEndian(); -} - -uint32_t mbs::BufferHeader::BufferLength() const -{ - switch (iType) { - // new buffer type - case MBS_TYPE(100,1): return sizeof(BufferHeader) + iUsedWords * 2; - - // old buffer type - case MBS_TYPE(10,1): return sizeof(BufferHeader) + iWords * 2; - } - - return 0; - -} - -uint32_t mbs::BufferHeader::UsedBufferSize() const -{ - switch (iType) { - // new buffer type - case MBS_TYPE(100,1): return iUsedWords * 2; - - // old buffer type - case MBS_TYPE(10,1): return i_used * 2; - - default: break; - // EOUT(("Uncknown buffer type %d-%d", i_type, i_subtype)); - } - - return 0; -} - -void mbs::BufferHeader::SetUsedBufferSize(uint32_t len) -{ - switch (iType) { - // new buffer type - case MBS_TYPE(100,1): - iUsedWords = len / 2; - if (iWords==0) SetFullSize(len + sizeof(BufferHeader)); - - break; - - // old buffer type - case MBS_TYPE(10,1): - i_used = len / 2; - if (iWords==0) SetFullSize(len + sizeof(BufferHeader)); - break; - - default: - // EOUT(("Uncknown buffer type %d-%d", i_type, i_subtype)); - break; - } -} - -void mbs::SwapData(void* data, unsigned bytessize) -{ - if (data==0) return; - unsigned cnt = bytessize / 4; - uint32_t* d = (uint32_t*) data; - - while (cnt-- != 0) { - *d = bswap_32(*d); - d++; - } -} - -const char* mbs::ServerKindToStr(int kind) -{ - switch (kind) { - case TransportServer: return "Transport"; - case StreamServer: return "Stream"; - case OldTransportServer: return "OldTransport"; - case OldStreamServer: return "OldStream"; - } - return "NoServer"; -} - -int mbs::DefualtServerPort(int kind) -{ - switch (kind) { - case TransportServer: return 6000; - case StreamServer: return 6002; - case OldTransportServer: return 6000; - case OldStreamServer: return 6002; - } - return 0; -} - -int mbs::StrToServerKind(const char* str) -{ - if (str==0) return NoServer; - if (strcmp(str, "Transport") == 0) return TransportServer; - if (strcmp(str, "Stream") == 0) return StreamServer; - if (strcmp(str, "OldTransport") == 0) return OldTransportServer; - if (strcmp(str, "OldStream") == 0) return OldStreamServer; - return NoServer; -} - - diff --git a/beamtime/roclight/src_roc/Board.cxx b/beamtime/roclight/src_roc/Board.cxx deleted file mode 100644 index 1b20d07b32b68b973d2a8eb1037bfe0659068332..0000000000000000000000000000000000000000 --- a/beamtime/roclight/src_roc/Board.cxx +++ /dev/null @@ -1,1087 +0,0 @@ -/******************************************************************** - * The Data Acquisition Backbone Core (DABC) - ******************************************************************** - * Copyright (C) 2009- - * GSI Helmholtzzentrum fuer Schwerionenforschung GmbH - * Planckstr. 1 - * 64291 Darmstadt - * Germany - * Contact: http://dabc.gsi.de - ******************************************************************** - * This software can be used under the GPL license agreements as stated - * in LICENSE.txt file which is part of the distribution. - ********************************************************************/ - -#define USE_NOPER - -#include <string.h> -#include <stdio.h> -#include <stdarg.h> - -#include <iostream> -#include <string> -#include <vector> - -#include "boost/format.hpp" - -#include "roc/Board.h" -#include "roc/defines_roc.h" -#include "roc/defines_optic.h" -#include "roc/defines_udp.h" -#include "feet/defines_feet.h" - - -const char* roc::xmlNumRocs = "NumRocs"; -const char* roc::xmlRocPool = "RocPool"; -const char* roc::xmlTransportWindow = "TransportWindow"; -const char* roc::xmlTransportKind = "TransportKind"; -const char* roc::xmlBoardAddr = "BoardAddr"; -const char* roc::xmlRole = "Role"; -const char* roc::xmlRocNumber = "RocNumber"; -const char* roc::xmlLowWater = "LowWater"; -const char* roc::xmlHighWater = "HighWater"; -const char* roc::xmlMsgFormat = "MsgFormat"; -const char* roc::xmlFlushTime = "FlushTime"; - -const char* roc::typeUdpDevice = "roc::UdpDevice"; -const char* roc::typeAbbDevice = "roc::AbbDevice"; - - -/*! - * \page roc_board_opererr roc::Board get/put/oper return codes - * - * The methods accessing the ROC control space, like - * \li get, put, and oper... in roc::Board - * \li many set and get methods in classes derived from roc::Peripheral - * - * return an \c int return code. It holds 0 in case the operation succeeded - * and is non-zero when it failed. In case of failure - * \li the lower 8 bits contain an error code as defined in - * roc::Board::operErr and is detailed below - * \li the upper 24 bits contain an index or step number. This allows to - * reconstruct the point of failure for list or array operations like - * roc::Board::operGen. - * - * Use the methods - * \li roc::Board::operErrCode() to retrieve the error code - * \li roc::Board::operErrIndex() to retrieve the index value - * \li roc::Board::operErrBuild() to build a return code - * \li roc::Board::operErrBuildInc() to modify index part of a return code - * - * The error codes are - * \li \e kOperSuccess: success - * \li \e kOperAddrErr: invalid address, there is no ROC resource under this - * address. - * \li \e kOperValueErr: invalid value, the value to be written is not allowed - * in the current state of the ROC or ROC peripheral. - * Only returned for write type operations. - * \li \e kOperStateErr: invalid state, the operation is not allowed in the - * current state of the ROC or ROC peripheral. - * \li \e kOperNetworkErr: network communication error. - * \li \e kOperVerifyErr: verify mismatch, a readback after a write operations - * yielded a value different from the written one. - * Only returned by dedicated write type operations, - * the method name often ends in ...Verify. - * \li \e kOperBusErr: secondary bus error. This is returned when a field bus - * operation, like on a I2C bus, failed. - */ - -//---------------------------------------------------------------------------- -//! Convert role state to a string representation - -const char* roc::roleToString(roc::ClientRole role) -{ - switch (role) { - case roleNone: return 0; - case roleObserver: return "Observer"; - case roleControl: return "Control"; - case roleDAQ: return "DAQ"; - } - return 0; -} - -//---------------------------------------------------------------------------- -//! Setup the role of the client application - -roc::ClientRole roc::defineClientRole(const char* name, roc::ClientRole dflt) -{ - if ((name==0) || (strlen(name)==0)) return dflt; - if (strcmp(name,"Observer")==0) return roleObserver; - if (strcmp(name,"Control")==0) return roleControl; - if (strcmp(name,"DAQ")==0) return roleDAQ; - return dflt; -} - -/*! - * \class roc::Board - * \brief This class represents a single ROC. - * - * \todo add class docu - */ - -//---------------------------------------------------------------------------- - -roc::Board::Board() : - fRole(roleNone), - fRocNumber(0), - fDefaultTimeout(2.), - fVerbosity(0), - fOperTrace(1), - fConnector(0), - fMapName2Addr(), - fMapAddr2Name() -{ - - // current ROC address def's from defines.h - - addRocAddrMapping("ROC_TYPE", ROC_TYPE); - addRocAddrMapping("ROC_HWV", ROC_HWV); - addRocAddrMapping("ROC_ROCID", ROC_ROCID); - addRocAddrMapping("ROC_ADDSYSMSG", ROC_ADDSYSMSG); - addRocAddrMapping("ROC_SYSTEM_RESET", ROC_SYSTEM_RESET); -} - -//---------------------------------------------------------------------------- - -roc::Board::~Board() -{ -} - -uint32_t roc::Board::initBoard() -{ - OperList lst; - lst.addGet(ROC_ROCID); - lst.addGet(ROC_HWV); - lst.addGet(ROC_TYPE); - if (operGen(lst)!=0) return 0; - - fRocNumber = lst.oper(0).value; - uint32_t roc_hw_ver = lst.oper(1).value; - uint32_t roc_typ = lst.oper(2).value; - - char sbuf[1000]; - - if(roc_hw_ver < 0x02000000) { - sprintf(sbuf, "The ROC you want to access has hardware version 0x%08x", roc_hw_ver); - ShowDebug(-1, sbuf); - sprintf(sbuf, "Please update your hardware to major version 2.0 == 0x%08x", 0x02000000); - ShowDebug(-1, sbuf); - } - - const char* fe_typ = "<unknown>"; - if ((roc_typ >> 16) == kind_nXYTER) fe_typ = "nXYTER"; - if ((roc_typ >> 16) == kind_FEET) fe_typ = "FEET"; - - const char* be_typ = "<unknown>"; - if ((roc_typ & 0xffff) == kind_Optic) be_typ = "Optic"; - if ((roc_typ & 0xffff) == kind_FX20) be_typ = "Eth-FX20"; - if ((roc_typ & 0xffff) == kind_FX40) be_typ = "Eth-FX40"; - if ((roc_typ & 0xffff) == kind_FX60) be_typ = "Eth-FX60"; - - sprintf(sbuf, "ROC%u ROC HW version: %s; ROC type front:%s back:%s", - fRocNumber, versionToString(roc_hw_ver), fe_typ, be_typ); - ShowDebug(0, sbuf); - - return roc_hw_ver; -} - -//---------------------------------------------------------------------------- -//! Updates ROC number in ROC - -void roc::Board::setRocNumber(uint32_t num) -{ - put(ROC_ROCID, num); -} - -//---------------------------------------------------------------------------- -//! Returns ROC number as stored in ROC - -uint32_t roc::Board::getRocNumber() -{ - uint32_t num = 0; - if (get(ROC_ROCID, num)==0) - fRocNumber = num; - return num; -} - -//---------------------------------------------------------------------------- -//! Returns the FPGA type the firmeware was syntesized for - -uint32_t roc::Board::getRocFpgaType() -{ - uint32_t num = 0; - get(ROC_FPGA_TYPE, num); - return num; -} - -//---------------------------------------------------------------------------- -//! Returns subversion revision number of the ROC firmware source code - -uint32_t roc::Board::getRocSvnRev() -{ - uint32_t num = 0; - get(ROC_SVN_REVISION, num); - return num; -} - -//---------------------------------------------------------------------------- -//! Returns the time the firmware was synthesized. -/*! - * The time is given in numbers of seconds since 1970-01-01 0:00 . - */ - -uint32_t roc::Board::getRocBuildTime() -{ - uint32_t num = 0; - get(ROC_BUILD_TIME, num); - return num; -} - -//---------------------------------------------------------------------------- -//! Add an commands list entry . -/*! - * This method sets commands list, which can be executed by - * command activateCommandsList() or by issuing of DLM - */ - -int roc::Board::uploadCommandsList(unsigned num, const OperList& lst, double tmout) -{ - if (num >= ROC_CMD_LST_NUMBER) { - Debug(-1, "Wrong number %u of commands list", num); - return ROC_ADDRESS_ERROR; - } - - OperList setlst; - - unsigned addr = ROC_CMD_LST_MEM + num * ROC_CMD_LST_SIZE / ROC_CMD_LST_NUMBER; - - for (int n=0;n<lst.number();n++) { - if (!lst.isput(n)) { - Debug(-1, "Only PUT operations are supported by commands list"); - return ROC_VALUE_ERROR; - } - - if (addr >= ROC_CMD_LST_MEM + ROC_CMD_LST_SIZE) { - Debug(-1, "Commands list to long %d for slot %u", lst.number(), num); - return ROC_VALUE_ERROR; - } - - setlst.addPut(addr, ROC_CMD_LST_PUT | (lst.oper(n).addr & ROC_CMD_LST_ADDRMASK)); - addr+=4; - setlst.addPut(addr, lst.oper(n).value); - addr+=4; - } - - // check if last list command not specified, add it - - if ((lst.number()>0) && (lst.oper(lst.number()-1).addr != ROC_CMD_LST_ACTIVE)) { - - if (addr >= ROC_CMD_LST_MEM + ROC_CMD_LST_SIZE) { - Debug(-1, "Commands list to long %d for slot %u", lst.number(), num); - return ROC_VALUE_ERROR; - } - - setlst.addPut(addr, ROC_CMD_LST_PUT | ROC_CMD_LST_ACTIVE); - addr+=4; - setlst.addPut(addr, 0); - addr+=4; - } - - return operGen(setlst, tmout); -} - -//---------------------------------------------------------------------------- -//! Download commands list from the ROC. -/*! - * Method reads specified commands list from the board. - */ - -int roc::Board::downloadCommandsList(unsigned num, OperList& lst, double tmout) -{ - lst.clear(); - - if (num >= ROC_CMD_LST_NUMBER) { - Debug(-1, "Wrong number %u of commands list", num); - return ROC_ADDRESS_ERROR; - } - - OperList getlst; - - unsigned addr = ROC_CMD_LST_MEM + num * ROC_CMD_LST_SIZE / ROC_CMD_LST_NUMBER; - - unsigned lastaddr = addr + ROC_CMD_LST_SIZE / ROC_CMD_LST_NUMBER; - - while (addr<lastaddr) { - getlst.addGet(addr); - addr+=4; - } - - int res = operGen(getlst, tmout); - - if (res!=0) return res; - - for (int n=0;n<getlst.number();n+=2) { - uint32_t addrVal = getlst.oper(n).value; - uint32_t value = getlst.oper(n+1).value; - - if ((addrVal & ROC_CMD_LST_PUT) == 0) { - Debug(-1, "Commands list %u has non-Put operation", num); - return ROC_VALUE_ERROR; - } - - addrVal = addrVal & ROC_CMD_LST_ADDRMASK; - if (addrVal==ROC_CMD_LST_ACTIVE) break; - lst.addPut(addrVal, value); - } - - return 0; -} - - -//---------------------------------------------------------------------------- -//! Produce and upload start daq commands list. -/*! - * This method produces commands list, which is executed - * on the board when startDaq method is called. Actually, it is list number 0 - * \param reset_frontend defines if front-end specific reset commands will - * be put into commands list. For nXYTER frontend, ROC_NX_TS_RESET will be done - * \param reset_fifo defines if message FIFO will be cleared - */ - -int roc::Board::uploadStartDaqCmdList(bool reset_frontend, bool reset_fifo) -{ - OperList lst; - uint32_t hw_kind = getRocFrontendKind(); - - if (hw_kind==kind_nXYTER) { - - if (reset_frontend && (getTransportKind() == kind_UDP)) { - lst.addPut(ROC_NX_TS_RESET, 1); - lst.addPut(ROC_NX_TS_RESET, 0); - } - if (reset_fifo) { - lst.addPut(ROC_NX_FIFO_RESET, 1); - lst.addPut(ROC_NX_FIFO_RESET, 0); - } - - } else - - if (hw_kind==kind_FEET) { - - if (reset_frontend) { - lst.addPut(ROC_FEET_RESET, 1); - } - if (reset_fifo) { - lst.addPut(ROC_FEET_FIFO_RESET, 1); - lst.addPut(ROC_FEET_FIFO_RESET, 0); - } - lst.addPut(ROC_FEET_CMD_TO_FEET, 0x28); - lst.addPut(ROC_FEET_CMD_TO_FEET, 0x2f); - } - - if (getTransportKind() == kind_UDP) - lst.addPut(ROC_ETH_START_DAQ, 1); - else - lst.addPut(ROC_OPTICS_START_DAQ, 1); - - return uploadCommandsList(0, lst, 3.); -} - -//---------------------------------------------------------------------------- -//! Produce and upload stop daq commands list. -/*! - * For a moment, list contains only stopdaq command - */ - -int roc::Board::uploadStopDaqCmdList() -{ - OperList lst; - - if (getTransportKind() == kind_UDP) - lst.addPut(ROC_ETH_STOP_DAQ, 1); - else - lst.addPut(ROC_OPTICS_STOP_DAQ, 1); - - return uploadCommandsList(1, lst, 3.); -} - - -//! Sets to default values common ROC registers -/*! - * For a moment, initializes start/stop commands lists - */ - -int roc::Board::setToDefault() -{ - int res = uploadStartDaqCmdList(); - if (res==0) res = uploadStopDaqCmdList(); - return res; -} - -//---------------------------------------------------------------------------- -//! Invoke command list. -/*! - * Invokes specified commands list and returns immediately. - * Means, commands list may still be executed when new operation is submitted - */ - -int roc::Board::invokeCommandsList(unsigned num, double tmout) -{ - return put(ROC_CMD_LST_NR, num, tmout); -} - -//---------------------------------------------------------------------------- -//! Add an entry to the ROC control space address mapping table. -/*! - * This method is protected and used in the contructors to initialize - * the table. - * \sa findRocNameByAddress(), findRocAddressByName(), printRocAddressMap() - */ - -void roc::Board::addRocAddrMapping(const char* name, uint32_t addr) -{ - std::string sname(name); - fMapName2Addr[sname] = addr; - fMapAddr2Name[addr] = sname; -} - -//---------------------------------------------------------------------------- -//! Retrieve a ROC control space address by its symbolic name. -/*! - * Locates in the ROC control space address mapping table the entry for - * the name \a name and returns the associated address in \a addr. - * \param name name to be looked up - * \param addr address to be returned - * \returns \c true if \a name was found, \c false otherwise - * \sa findRocNameByAddress(), addRocAddrMapping(), printRocAddressMap() - */ - -bool roc::Board::findRocAddressByName(const char* name, uint32_t& addr) -{ - mapn2a_iter_t it = fMapName2Addr.find(std::string(name)); - if (it != fMapName2Addr.end()) { - addr = (*it).second; - return true; - } - return false; -} - - -//---------------------------------------------------------------------------- -//! Retrieve symbolic name of a ROC control space address. -/*! - * Locates in the ROC control space address mapping table the entry for - * the address \a addr and returns the associated sympolic name in \a name. - * \param addr address to be looked up - * \param name name to be returned - * \returns \c true if \a addr was found, \c false otherwise - * \sa findRocAddressByName(), addRocAddrMapping(), printRocAddressMap() - */ - -bool roc::Board::findRocNameByAddress(uint32_t addr, const char*& name) -{ - mapa2n_iter_t it = fMapAddr2Name.find(addr); - if (it != fMapAddr2Name.end()) { - name = (*it).second.c_str(); // ok because entries never deleted - return true; - } - return false; -} - -//---------------------------------------------------------------------------- - -void roc::Board::printRocAddressMap(std::ostream& /*os*/, bool byname) -{ - static boost::format fmt("0x%|08x| : %s"); - if (byname) { - for (mapn2a_iter_t it=fMapName2Addr.begin(); - it!=fMapName2Addr.end(); it++) { - std::cout << fmt % (*it).second % (*it).first << std::endl; - } - - } else { - for (mapa2n_iter_t it=fMapAddr2Name.begin(); - it!=fMapAddr2Name.end(); it++) { - std::cout << fmt % (*it).first % (*it).second << std::endl; - } - } - -} - -//---------------------------------------------------------------------------- -void roc::Board::fillAddrNames(std::list<std::string>& lst) -{ - for (mapn2a_iter_t it=fMapName2Addr.begin(); it!=fMapName2Addr.end(); it++) - lst.push_back(it->first); -} - -//---------------------------------------------------------------------------- - -roc::Board* roc::Board::Connect(const char* name, ClientRole role) -{ - for (int n=0; n<BoardConnector::NumConn(); n++) - if (BoardConnector::Conn(n)) { - roc::Board* brd = BoardConnector::Conn(n)->DoConnect(name, role); - if (brd!=0) { - brd->fConnector = BoardConnector::Conn(n); - return brd; - } - } - - return 0; -} - -//---------------------------------------------------------------------------- - -bool roc::Board::Close(Board* brd) -{ - if (brd==0) return false; - - BoardConnector* conn = brd->fConnector; - - if (conn==0) return false; - - return conn->DoClose(brd); -} - -//---------------------------------------------------------------------------- -//! Print a formatted debug message. -/*! - * If the debug level \a lvl is less or equal to the verbosity level - * setup with setVerbosity() a message will be printed with ShowDebug(). - * The message text is defined by the \c printf style format \a fmt and - * variable length argument list. - * \param lvl debug level - * \param fmt format a la \c printf - * \par Example: - * \code - * Debug(-1, "Error reading Register %d on bus %d", reg, num); - * \endcode - */ - -void roc::Board::Debug(int lvl, const char *fmt, ...) -{ - if (!fmt || (lvl>fVerbosity)) return; - - va_list args; - va_start(args, fmt); - - int result(128), length(128); - char *buffer = 0; - while (result==length) { - if (buffer) delete [] buffer; - length *= 2; - buffer = new char [length + 1]; - memset(buffer, 0, length + 1); - result = vsnprintf(buffer, length, fmt, args); - if (result<0) break; - } - - ShowDebug(lvl, buffer); - delete [] buffer; - va_end(args); -} - -//---------------------------------------------------------------------------- -//! Print a debug message to \c stdout. -/*! - * If the debug level \a lvl is less or equal to the verbosity level - * setup with setVerbosity() the message text \a msg is printed to \c stdout. - * \param lvl debug level - * \param msg text message - * \sa Debug() - */ - -void roc::Board::ShowDebug(int lvl, const char* msg) -{ - if (lvl<=fVerbosity) printf("%s\n", msg); -} - -//---------------------------------------------------------------------------- -//! Generate output for get/put/operGen traces. -/*! - * \param isput 'isput' array - * \param addr 'addr' array (or pointer to address in case of get/put) - * \param value 'value' array (or pointer to value in case of get/put) - * \param num request list length - * \param rc return code - */ - -void roc::Board::traceOper(OperList* lst, int rc) -{ - if (lst==0) return; - if (fOperTrace == 0) return; - if (fOperTrace == 1 && rc != kOperNetworkErr) return; - if (fOperTrace == 2 && rc == 0) return; - - for (int i=0; i<lst->number(); i++) { - const char* aname = "???"; - findRocNameByAddress(lst->oper(i).addr, aname); - - if (lst->number() == 1) { - Debug(0, "%3s (%d,%08x %-27s) %s 0x%08x %10d %s", - (lst->oper(i).isput ? "put" : "get"), - fRocNumber, lst->oper(i).addr, aname, - (lst->oper(i).isput) ? "<-" : "->", - lst->oper(i).value, lst->oper(i).value, - (rc == 0) ? "ok" : "FAIL"); - - } else { - const char* stat = ""; - if (i == lst->number()-1) stat = (rc == 0) ? "ok" : "FAIL"; - Debug(0, "op[%02d](%d,%08x %-27s) %s 0x%08x %10d %s", - i, fRocNumber, lst->oper(i).addr, aname, - (lst->oper(i).isput ? "<-" : "->"), - lst->oper(i).value, lst->oper(i).value, stat); - } - - if (rc != 0) { - std::string str = operErrToString(rc); - Debug(0, " %s", str.c_str()); - } - } -} - -int roc::Board::operGen(bool* isput, - uint32_t* addr, - uint32_t* value, - int num, - double tmout) -{ - OperList lst(num, isput, addr, value); - - int res = operGen(lst, tmout); - - for (int n=0;n<num;n++) - if (!isput[n]) value[n] = lst.oper(n).value; - - return res; -} - - -int roc::Board::put(uint32_t addr, uint32_t value, double tmout) -{ - bool isput = true; - - return operGen(&isput, &addr, &value, 1, tmout); -} - -int roc::Board::get(uint32_t addr, uint32_t& value, double tmout) -{ - bool isput = false; - - return operGen(&isput, &addr, &value, 1, tmout); -} - - -//---------------------------------------------------------------------------- -//! Put-Put accesses sequence to ROC control space. -/*! - * This is a specialization of operGen(), check the documentation of this - * method for details. - * - * \param addr0 address for 1st put - * \param val0p value to write in 1st put - * \param addr1 address for 2nd put - * \param val1p value to write in 2nd put - * \param tmout maximal network response time - * \returns see \ref roc_board_opererr - */ - -int roc::Board::operPP(uint32_t addr0, uint32_t val0p, - uint32_t addr1, uint32_t val1p, - double tmout) -{ - bool isput[2]; - uint32_t addr[2]; - uint32_t data[2]; - - isput[0] = true; addr[0] = addr0; data[0] = val0p; - isput[1] = true; addr[1] = addr1; data[1] = val1p; - - int rc = operGen(isput, addr, data, 2, tmout); - return rc; -} - -//---------------------------------------------------------------------------- -//! Put-Get accesses sequence to ROC control space. -/*! - * This is a specialization of operGen(), check the documentation of this - * method for details. - * - * \param addr0 address for 1st put - * \param val0p value to write in 1st put - * \param addr1 address for 1st get - * \param val1g value returned in 1st get - * \param tmout maximal network response time - * \returns see \ref roc_board_opererr - */ - -int roc::Board::operPG(uint32_t addr0, uint32_t val0p, - uint32_t addr1, uint32_t& val1g, - double tmout) -{ - bool isput[2]; - uint32_t addr[2]; - uint32_t data[2]; - - isput[0] = true; addr[0] = addr0; data[0] = val0p; - isput[1] = false; addr[1] = addr1; - - int rc = operGen(isput, addr, data, 2, tmout); - val1g = data[1]; - return rc; -} - -//---------------------------------------------------------------------------- -//! Put-Put-Put accesses sequence to ROC control space. -/*! - * This is a specialization of operGen(), check the documentation of this - * method for details. - * - * \param addr0 address for 1st put - * \param val0p value to write in 1st put - * \param addr1 address for 2nd put - * \param val1p value to write in 2nd put - * \param addr2 address for 3rd put - * \param val2p value to write in 3rd put - * \param tmout maximal network response time - * \returns see \ref roc_board_opererr - */ - -int roc::Board::operPPP(uint32_t addr0, uint32_t val0p, - uint32_t addr1, uint32_t val1p, - uint32_t addr2, uint32_t val2p, - double tmout) -{ - bool isput[3]; - uint32_t addr[3]; - uint32_t data[3]; - - isput[0] = true; addr[0] = addr0; data[0] = val0p; - isput[1] = true; addr[1] = addr1; data[1] = val1p; - isput[2] = true; addr[2] = addr2; data[2] = val2p; - - int rc = operGen(isput, addr, data, 3, tmout); - return rc; -} - -//---------------------------------------------------------------------------- -//! Get-Get-Get accesses sequence to ROC control space. -/*! - * This is a specialization of operGen(), check the documentation of this - * method for details. - * - * \param addr0 address for 1st get - * \param val0p value to write in 1st get - * \param addr1 address for 2nd get - * \param val1p value to write in 2nd get - * \param addr2 address for 3rd get - * \param val2p value to write in 3rd get - * \param tmout maximal network response time - * \returns see \ref roc_board_opererr - */ - -int roc::Board::operGGG(uint32_t addr0, uint32_t& val0p, - uint32_t addr1, uint32_t& val1p, - uint32_t addr2, uint32_t& val2p, - double tmout) -{ - bool isput[3]; - uint32_t addr[3]; - uint32_t data[3]; - - isput[0] = false; addr[0] = addr0; - isput[1] = false; addr[1] = addr1; - isput[2] = false; addr[2] = addr2; - - int rc = operGen(isput, addr, data, 3, tmout); - - val0p = data[0]; - val1p = data[1]; - val2p = data[2]; - - return rc; -} - -//---------------------------------------------------------------------------- -//! Put-Put-Put-Put accesses sequence to ROC control space. -/*! - * This is a specialization of operGen(), check the documentation of this - * method for details. - * - * \param addr0 address for 1st put - * \param val0p value to write in 1st put - * \param addr1 address for 2nd put - * \param val1p value to write in 2nd put - * \param addr2 address for 3rd put - * \param val2p value to write in 3rd put - * \param addr3 address for 4th put - * \param val3p value to write in 4th put - * \param tmout maximal network response time - * \returns see \ref roc_board_opererr - */ - -int roc::Board::operPPPP(uint32_t addr0, uint32_t val0p, - uint32_t addr1, uint32_t val1p, - uint32_t addr2, uint32_t val2p, - uint32_t addr3, uint32_t val3p, - double tmout) -{ - bool isput[4]; - uint32_t addr[4]; - uint32_t data[4]; - - isput[0] = true; addr[0] = addr0; data[0] = val0p; - isput[1] = true; addr[1] = addr1; data[1] = val1p; - isput[2] = true; addr[2] = addr2; data[2] = val2p; - isput[3] = true; addr[3] = addr3; data[3] = val3p; - - int rc = operGen(isput, addr, data, 4, tmout); - return rc; -} - - -//---------------------------------------------------------------------------- -//! Returns a string representation of a version number - -const char* roc::Board::versionToString(uint32_t ver) -{ - static char sbuf[100]; - snprintf(sbuf, sizeof(sbuf), "%u.%u.%u.%u", - (ver >> 24), - (ver >> 16) & 0xff, - (ver >> 8) & 0xff, - ver & 0xff); - return sbuf; -} - -//---------------------------------------------------------------------------- -//! Returns software version of client software - -uint32_t roc::Board::getRoclibVersion() -{ - return KNUT_VERSION; -} - -//---------------------------------------------------------------------------- -//! Returns hardware version of ROC (FPGA firmware version) - -uint32_t roc::Board::getRocHardwareVersion() -{ - uint32_t val = 0; - get(ROC_HWV, val); - return val; -} - -//---------------------------------------------------------------------------- -//! Returns hardware type (frontend/backend) of ROC (FPGA firmware kind) -/** - * Frontend: - * 1 - NX - * 2 - FEET - * Backend: - * 1 - Optics - * 2 - Ethernet FX20 - * 3 - Ethernet FX40 - */ - -uint32_t roc::Board::getRocHardwareType() -{ - uint32_t val = 0; - get(ROC_TYPE, val); - return val; -} - -//---------------------------------------------------------------------------- -//! Clears the FIFO in ROC (discard all old data) - -void roc::Board::clearRocFifo() -{ -// int rc = operPP(ROC_NX_FIFO_RESET, 1, - operPP(ROC_NX_FIFO_RESET, 1, - ROC_NX_FIFO_RESET, 0); -} - -//---------------------------------------------------------------------------- -//! Full ROC restart (FPGA and PPC, if used) -/*! - * This methods sends a message to the ROC which causes a <b>full reset</b> - * of the ROC board, the FPGA is reconfigured, and if used, the PPC is - * rebooted. Due to this hard reset the connection between the Board object - * and the ROC will abort, the Board object will essentially be a zombie - * after restartRoc() is called. - * - * This method can come in handy when the ROC is in an inaccessible place - * and partially hung. - * - * \post ROC restarting, Board object defunct. - */ - -void roc::Board::restartRoc() -{ - put(ROC_SYSTEM_RESET, 1); -} - -//---------------------------------------------------------------------------- -//! Returns the status of the throttle system. -/*! - * \param val bit mask with throttle system state - * \li bit 0 set indicates that throttling is active, thus data is currently - * been discarded. - * \li bit 1 set indicates that the throttle request flip-flop is set and that - * a throttle request is emitted from GPIO pin 0. - * - * \returns see \ref roc_board_opererr - */ - -int roc::Board::getRocThrottleState(uint32_t& val) -{ - return get(ROC_NX_THROTTLE, val); -} - -//---------------------------------------------------------------------------- -//! Returns descriptive text for a get/put/oper error code. -/*! - * \param rc return code, the index part will be ignored - * \returns pointer to statically allocated string with descriptive text - */ - -const char* roc::Board::operErrCodeName(int rc) -{ - switch(operErrCode(rc)) { - case kOperSuccess: return "success"; - case kOperAddrErr: return "invalid address"; - case kOperValueErr: return "value not allowed"; - case kOperStateErr: return "operation not allowed"; - case kOperNetworkErr: return "communication error"; - case kOperVerifyErr: return "readback verify error"; - case kOperBusErr: return "secondary bus error"; - } - return ""; -} - -//---------------------------------------------------------------------------- -//! Returns a string with a human readable form of a get/put/oper return code. -/*! - * Return codes of many roc or device handling methods return either a - * negative number to indicate an illegal argument combination or state or - * a positive number to indicate a control space access errors (see - * \ref roc_board_opererr). This method converts the return code into a - * human readable form. For negative values it simply returns "rc = nnn", - * while for positive values it extracts the index and error code part of - * the return code \a rc and returns a string of the form -\verbatim -rc = 7,20 -> readback verify error - | | | - | | string representation of error code - | error code - index part -\endverbatim - */ - -std::string roc::Board::operErrToString(int rc) -{ - char buf[32]; - if (rc <0) { - snprintf(buf, sizeof(buf), "rc = %d", rc); - return std::string(buf); - } - - snprintf(buf, sizeof(buf), "rc = %4d,%2d -> ", - operErrIndex(rc), operErrCode(rc)); - std::string str(buf); - return str+operErrCodeName(rc); -} - -//---------------------------------------------------------------------------- - -roc::BoardConnector* roc::BoardConnector::gArr[10] = { 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0 }; - -//---------------------------------------------------------------------------- - -roc::BoardConnector::BoardConnector() -{ - for (int n=0;n<10;n++) - if (gArr[n]==0) { - gArr[n] = this; - break; - } -} - -//---------------------------------------------------------------------------- - -roc::BoardConnector::~BoardConnector() -{ - for (int n=0;n<10;n++) - if (gArr[n]==this) gArr[n] = 0; -} - -//---------------------------------------------------------------------------- - -const char* roc::BoardConnector::CheckNamePrefix(const char* rocname, const char* prefix) -{ - if ((rocname==0) || (prefix==0) || (strlen(rocname)<strlen(prefix))) return 0; - - if (strstr(rocname,"://")==0) return 0; - - if (strncmp(rocname, prefix, strlen(prefix))==0) return rocname+strlen(prefix); - - return 0; -} - -//---------------------------------------------------------------------------- - -//! Check if specified address is address of board, connected via optic -/*! - * First checks that it has preffix optic://, second that name starts from abb - * Also checks, that no udp:// prefix is specified - * Returns connection name without prefix or 0 - */ - -const char* roc::BoardConnector::CheckOptic(const char* name) -{ - if (CheckNamePrefix(name,"udp://")!=0) return 0; - const char* res = CheckNamePrefix(name, "optic://"); - if (res==0) res = name; - if (strlen(res)<3) return 0; - if (strncmp(res,"abb",3)!=0) return 0; - return res; -} - -//---------------------------------------------------------------------------- - -//! Check if specified address is address of board, connected via UDP -/*! - * First checks that it is not optic address - * Also checks, that no udp:// prefix is specified - * Returns connection name without prefix or 0 - */ - -const char* roc::BoardConnector::CheckUdp(const char* name) -{ - if (CheckFile(name)) return 0; - if (CheckOptic(name)) return 0; - const char* res = CheckNamePrefix(name, "udp://"); - if (res) return res; - return (strstr(name,"://")==0) ? name : 0; -} - -//---------------------------------------------------------------------------- - -//! Check if specified address is filename -/*! - * First checks that it is not optic address - * Also checks, that no udp:// prefix is specified - * Returns connection name without prefix or 0 - */ - -const char* roc::BoardConnector::CheckFile(const char* name) -{ - const char* res = CheckNamePrefix(name, "file://"); - if (res!=0) return res; - if (strstr(name, ".lmd")!=0) return name; - return 0; -} - diff --git a/beamtime/roclight/src_roc/Factory.cxx b/beamtime/roclight/src_roc/Factory.cxx deleted file mode 100644 index 4e03747917badd0e59c0fa9a79e030bca8f22b90..0000000000000000000000000000000000000000 --- a/beamtime/roclight/src_roc/Factory.cxx +++ /dev/null @@ -1,235 +0,0 @@ -/******************************************************************** - * The Data Acquisition Backbone Core (DABC) - ******************************************************************** - * Copyright (C) 2009- - * GSI Helmholtzzentrum fuer Schwerionenforschung GmbH - * Planckstr. 1 - * 64291 Darmstadt - * Germany - * Contact: http://dabc.gsi.de - ******************************************************************** - * This software can be used under the GPL license agreements as stated - * in LICENSE.txt file which is part of the distribution. - ********************************************************************/ - -#include "roc/Factory.h" - -/* *** PAL edit: Run offline with LMD file and without DABC *** -#include "roc/CombinerModule.h" -#include "roc/ReadoutModule.h" -#include "roc/ReadoutApplication.h" -#include "roc/UdpDevice.h" -#include "roc/NxCalibrModule.h" - ***************** */ - -/* *** PAL edit: Run offline with LMD file and without DABC *** -#include "dabc/Command.h" -#include "dabc/logging.h" - ***************** */ -#include "FairLogger.h" - -#include "mbs/LmdInput.h" -#include "roc/FileInput.h" - -roc::Factory rocfactory("roc"); - -roc::Factory::Factory(const char* /*name*/) : -// dabc::Factory(name), *** PAL edit: Run offline with LMD file and without DABC *** - roc::BoardConnector(), -// fDevs(), *** PAL edit: Run offline with LMD file and without DABC *** - fFileCount(0), - fMgrCreated(false) -{ -} - -/* *** PAL edit: Run offline with LMD file and without DABC *** -dabc::Application* roc::Factory::CreateApplication(const char* classname, dabc::Command cmd) -{ - if (strcmp(classname, xmlReadoutAppClass)==0) - return new roc::ReadoutApplication(); - - return dabc::Factory::CreateApplication(classname, cmd); -} - ***************** */ - -/* *** PAL edit: Run offline with LMD file and without DABC *** -dabc::Module* roc::Factory::CreateModule(const char* classname, const char* modulename, dabc::Command cmd) -{ - DOUT2(("roc::Factory::CreateModule called for class:%s, module:%s", classname, modulename)); - - if (strcmp(classname, "roc::CombinerModule")==0) { - DOUT2(("roc::Factory::CreateModule - Created roc::CombinerModule %s ", modulename)); - return new roc::CombinerModule(modulename, cmd); - } else - if (strcmp(classname, "roc::ReadoutModule")==0) { - DOUT2(("roc::Factory::CreateModule - Created roc::ReadoutModule module %s ", modulename)); - return new roc::ReadoutModule(modulename, cmd); - } else - if (strcmp(classname, "roc::NxCalibrModule")==0) { - DOUT2(("roc::Factory::CreateModule - Created roc::NxCalibrModule module %s ", modulename)); - return new roc::NxCalibrModule(modulename, cmd); - } - - return 0; -} - ***************** */ - -/* *** PAL edit: Run offline with LMD file and without DABC *** -dabc::Device* roc::Factory::CreateDevice(const char* classname, const char* devname, dabc::Command cmd) -{ - const char* thrdname = cmd.Field("Thread").AsStr(); - - if (strcmp(classname, roc::typeUdpDevice)==0) { - DOUT2(("roc::Factory::CreateDevice - Creating ROC UdpDevice %s ...", devname)); - - roc::UdpDevice* dev = new roc::UdpDevice(devname, thrdname, cmd); - - if (!dev->IsConnected()) { - dabc::Object::Destroy(dev); - return 0; - } - - return dev; - } - - return 0; -} - ***************** */ - -roc::Board* roc::Factory::DoConnect(const char* name, roc::ClientRole /*role*/) -{ -/* *** PAL edit: Run offline with LMD file and without DABC *** - dabc::SetDebugLevel(0); - dabc::lgr()->SetLogLimit(1000000); - dabc::lgr()->SetDebugMask(dabc::lgr()->GetDebugMask() & ~dabc::Logger::lTStamp); - - if (dabc::mgr.null()) { - if (!dabc::Factory::CreateManager("dabc")) return 0; - fMgrCreated = true; - } - ***************** */ - - const char* subname = CheckFile(name); - if (subname!=0) { - - char sbuf[1024]; - strcpy(sbuf, subname); - - int selectroc = -1; - - char* pos = strstr(sbuf,"&roc="); - if (pos!=0) { - selectroc = atoi(pos+5); - *pos = 0; - } - - LOG(debug) << Form("Creating LMD-file input %s selectroc = %d", sbuf, selectroc); - - mbs::LmdInput* inp = new mbs::LmdInput(sbuf, 0x100000); - - if (!inp->Init()) { - LOG(error) << Form("Cannot create LMD input %s", sbuf); - delete inp; - return 0; - } - - fFileCount++; - - return new roc::FileInput(inp, selectroc); - } - else - { - LOG(error) << Form("Filename %s failed the check by CheckFile from roclight/roc/Board.h", name); - return NULL; - } - -/* *** PAL edit: Run offline with LMD file and without DABC *** - subname = CheckUdp(name); - if (subname==0) return 0; - - static int brdcnt = 0; - - std::string devname = dabc::format("/roc/Udp%d", brdcnt++); - if (!dabc::mgr.FindDevice(devname).null()) { - EOUT(("Device with name %s already exists!!!", devname.c_str())); - return 0; - } - - DOUT3(("Create device")); - - dabc::CmdCreateDevice cmd(typeUdpDevice, devname.c_str()); - cmd.SetStr(roc::xmlBoardAddr, subname); - cmd.SetStr(roc::xmlRole, roleToString(role)); - if (!dabc::mgr.Execute(cmd)) return 0; - - UdpDeviceRef dev = dabc::mgr.FindDevice(devname); - - DOUT3(("Create device dev = %p", dev())); - - if (dev.null()) { - EOUT(("UDP Device for board %s cannot be created!!!", subname)); - return 0; - } - - if (!dev()->InitAsBoard()) { - dev.Destroy(); - return 0; - } - - roc::Board* brd = static_cast<roc::Board*> (dev()); - - fDevs.Add(dev); - - return brd; - ***************** */ -} - -bool roc::Factory::DoClose(roc::Board* brd) -{ - roc::FileInput* inp = dynamic_cast<roc::FileInput*> (brd); - if (inp!=0) { - fFileCount--; - delete inp; - -/* *** PAL edit: Run offline with LMD file and without DABC *** - if ((fFileCount==0) && (fDevs.GetSize()==0) && fMgrCreated) { - DOUT3(("Destroying manager from roc::Factory")); - - dabc::mgr()->HaltManager(); - dabc::mgr.Destroy(); - fMgrCreated = false; - } - ***************** */ - - return true; - } - -/* *** PAL edit: Run offline with LMD file and without DABC *** - if (dabc::mgr.null()) return false; - - for (unsigned n=0;n<fDevs.GetSize();n++) { - UdpDevice* dev = (UdpDevice*) fDevs.GetObject(n); - - if (static_cast<roc::Board*>(dev) == brd) { - - dev->CloseAsBoard(); - dev->Execute(dabc::Command(roc::UdpDevice::CmdPutDisconnect()).SetTimeout(4.)); - fDevs.TakeRef(n).Destroy(); - - if ((fFileCount==0) && (fDevs.GetSize()==0) && fMgrCreated) { - DOUT3(("Destroying manager from roc::Factory")); - - dabc::mgr()->HaltManager(); - dabc::mgr.Destroy(); - fMgrCreated = false; - } - - return true; - } - } - ***************** */ - - - LOG(error) << Form("Board::Close FAIL - brd %p not registered. Check if board closed second time", brd); - return false; -} diff --git a/beamtime/roclight/src_roc/FileInput.cxx b/beamtime/roclight/src_roc/FileInput.cxx deleted file mode 100644 index 7c9e239bad90592606e2b4e06aababa6ca31e4cf..0000000000000000000000000000000000000000 --- a/beamtime/roclight/src_roc/FileInput.cxx +++ /dev/null @@ -1,136 +0,0 @@ -#include "roc/FileInput.h" - -/* *** PAL edit: Run offline with LMD file and without DABC *** -#include "dabc/Buffer.h" <- Seems not used, just comment it -#include "dabc/logging.h" - ***************** */ -#include "FairLogger.h" - -#include "roc/Iterator.h" - -/*! - * \class roc::FileInput - * \brief This class provide read access to lmd files via roc::Board interface - * - * No any put/get/startDaq/stopDaq methods are functional. - * Only getNextBuffer() is implemented. Main motivation is to provide access to - * lmd files via roc::Iterator interface in the form: - * - * roc::Iterator iter("file://calibr_*.lmd"); - * - * while (iter.next()) { - * iter.msg().printData(); - * } - * - * Iterator reads data from lmd file for the only roc. By default, first available roc number - * is used. If required, roc id can be selected in the constructor like: - * - * roc::Iterator iter("file://calibr_*.lmd&rocid=3"); - * - * From raw lmd files, produced by DABC, iterator excludes duplicated sync and - * epoch messages from the end. - * - * \todo add class docu - */ - -roc::FileInput::FileInput(mbs::LmdInput* inp, int selectroc) : - roc::Board(), - fInput(inp), - fHdr(0), - fSubev(0), - fSelectRoc(selectroc) -{ - setRole(roc::roleDAQ); -} - -roc::FileInput::~FileInput() -{ - if (fInput) { delete fInput; fInput = 0; } -} - -bool roc::FileInput::getNextBuffer(void* &buf, unsigned& len, double /*tmout*/) -{ - if (fInput==0) return false; - - while (true) { - if (fHdr==0) { - fHdr = fInput->ReadEvent(); - if (fHdr==0) return false; - fSubev = 0; - } - - fSubev = fHdr->NextSubEvent(fSubev); - if (fSubev!=0) { - buf = fSubev->RawData(); - len = fSubev->RawDataSize(); - - if ( (fSubev->iProcId == roc::proc_ErrEvent) || - (fSubev->iProcId==roc::proc_RocEvent) || - (fSubev->iProcId==roc::proc_MergedEvent) || - (fSubev->iProcId==roc::proc_RawData) ) { - - if ((fSelectRoc>=0) && (fSelectRoc != fSubev->iSubcrate)) continue; - - //if (fSelectRoc<0) fSelectRoc = fSubev->iSubcrate; - - // bool calibrated = (fSubev->iProcId == proc_MergedEvent); - - roc::Iterator iter((roc::MessageFormat) fSubev->iControl); - - iter.assign(buf, len); - - if (!iter.last()) { - LOG(error) << Form("Cannot jump to end of raw buffer len = %d", len); - continue; - } - - // exclude last SYNC message - if (!iter.msg().isSyncMsg()) { - LOG(error) << Form("Not an sync message in the end"); - continue; - } - - unsigned msg_size = roc::Message::RawSize(iter.getFormat()); - - len -= msg_size; - - if (!iter.prev()) { - LOG(error) << Form("Cannot roll back one message"); - continue; - } - - // exclude last EPOCH message, belonging to SYNC - if (iter.msg().isEpochMsg()) len -= msg_size; - } else - continue; // do not take non-nXYTER event - - fRocNumber = fSubev->iSubcrate; - - // check if not an empty event - // check in calibration that empty event not produced at all - if (len>0) return true; - } - - fHdr = 0; - } - - return false; -} - -int roc::FileInput::getTransportKind() const -{ - return roc::kind_File; - -/* roc::MessageFormat fmt = getMsgFormat(); - - return ((fmt == formatOptic1) || (fmt==formatOptic2)) ? roc::kind_ABB : roc::kind_UDP; -*/ -} - - -roc::MessageFormat roc::FileInput::getMsgFormat() const -{ - if (fSubev==0) return roc::formatEth1; - - return (roc::MessageFormat) fSubev->iControl; -} diff --git a/beamtime/roclight/src_roc/Iterator.cxx b/beamtime/roclight/src_roc/Iterator.cxx deleted file mode 100644 index d8cbd112514dd1667395a83277b1bc0ff58a833c..0000000000000000000000000000000000000000 --- a/beamtime/roclight/src_roc/Iterator.cxx +++ /dev/null @@ -1,146 +0,0 @@ -#include "roc/Iterator.h" - -roc::Iterator::Iterator(MessageFormat fmt) : - fFormat(fmt), - fBuffer(0), - fBufferLen(0), - fBufferPos(0), - fMsgSize(0), - fMsg(), - fEpoch(0), - fBoard(0), - fOwner(false) -{ - fMsgSize = roc::Message::RawSize(fFormat); - for (unsigned n=0;n<MaxGet4;n++) fEpoch2[n] = 0; -} - -roc::Iterator::Iterator(const Iterator& src) : - fFormat(src.fFormat), - fBuffer(src.fBuffer), - fBufferLen(src.fBufferLen), - fBufferPos(src.fBufferPos), - fMsgSize(src.fMsgSize), - fMsg(src.fMsg), - fEpoch(src.fEpoch), - fBoard(0), - fOwner(false) -{ - for (unsigned n=0;n<MaxGet4;n++) fEpoch2[n] = src.fEpoch2[n]; -} - - -roc::Iterator::Iterator(roc::Board* brd, bool owner) : - fFormat(brd->getMsgFormat()), - fBuffer(0), - fBufferLen(0), - fBufferPos(0), - fMsgSize(0), - fMsg(), - fEpoch(0), - fBoard(brd), - fOwner(owner) -{ - fMsgSize = roc::Message::RawSize(fFormat); - setRocNumber(brd->rocNumber()); - for (unsigned n=0;n<MaxGet4;n++) fEpoch2[n] = 0; -} - -roc::Iterator::Iterator(const char* filename) : - fFormat(roc::formatEth1), - fBuffer(0), - fBufferLen(0), - fBufferPos(0), - fMsgSize(0), - fMsg(), - fEpoch(0), - fBoard(0), - fOwner(false) -{ - for (unsigned n=0;n<MaxGet4;n++) fEpoch2[n] = 0; - roc::Board* brd = roc::Board::Connect(filename); - if (brd!=0) { - fBoard = brd; - fOwner = true; - brd->startDaq(); - - fFormat = brd->getMsgFormat(); - setRocNumber(brd->rocNumber()); - fMsgSize = roc::Message::RawSize(fFormat); - } -} - -roc::Iterator::~Iterator() -{ - if (fOwner) { - roc::Board::Close(fBoard); - fBoard = 0; - fOwner = false; - } -} - -bool roc::Iterator::isFile() const -{ - if (fBoard==0) return false; - - return fBoard->isFile(); -} - - -void roc::Iterator::setFormat(MessageFormat fmt) -{ - fFormat = fmt; - fMsgSize = roc::Message::RawSize(fFormat); -} - - -void roc::Iterator::setRocNumber(uint16_t rocnum) -{ - if (fFormat == formatEth2) - fMsg.setRocNumber(rocnum); -} - -void roc::Iterator::resetEpochs() -{ - fEpoch = 0; - for (unsigned n=0;n<MaxGet4;n++) fEpoch2[n] = 0; -} - -bool roc::Iterator::assign(void* buf, uint32_t len) -{ - fBuffer = buf; - fBufferLen = len; - fBufferPos = 0; - - return len >= fMsgSize; -} - -bool roc::Iterator::nextBuffer(roc::Board* brd, double tmout) -{ - if (brd==0) return false; - - void *buf = 0; - unsigned len = 0; - - if (!brd->getNextBuffer(buf, len, tmout)) return false; - - fFormat = brd->getMsgFormat(); - setRocNumber(brd->rocNumber()); - fMsgSize = roc::Message::RawSize(fFormat); - - return assign(buf, len); -} - -void roc::Iterator::printMessage(unsigned kind) -{ - msg().printData(kind, getMsgEpoch()); -} - - -void roc::Iterator::printMessages(unsigned cnt, unsigned kind) -{ - while (cnt-- > 0) { - if (!next()) return; - msg().printData(kind, getMsgEpoch()); - } -} diff --git a/beamtime/roclight/src_roc/Message.cxx b/beamtime/roclight/src_roc/Message.cxx deleted file mode 100644 index edece27e1b60e558b566b43d7a123a592b080955..0000000000000000000000000000000000000000 --- a/beamtime/roclight/src_roc/Message.cxx +++ /dev/null @@ -1,540 +0,0 @@ -#include "roc/Message.h" - -#include <stdio.h> -#include <string.h> - -bool roc::Message::convertFromOld(void* src) -{ - data = 0; - - uint8_t* arr = (uint8_t*) src; - - setMessageType((arr[0] >> 5) & 0x7); - setRocNumber((arr[0] >> 2) & 0x7); - - switch (getMessageType()) { - case MSG_HIT: - setNxNumber(arr[0] & 0x3); - setNxLtsMsb((arr[1] >> 5) & 0x7); - setNxTs(((arr[1] & 0x1f) << 9) | (arr[2] << 1) | (arr[3] >> 7)); - setNxChNum(arr[3] & 0x7f); - setNxAdcValue(((arr[4] & 0x7f) << 5) | ((arr[5] & 0xf8) >> 3)); - setNxPileup((arr[5] >> 2) & 0x1); - setNxOverflow((arr[5] >> 1) & 0x1); - setNxLastEpoch(arr[5] & 0x1); - break; - - case MSG_EPOCH: - setEpochNumber((arr[1] << 24) | (arr[2] << 16) | (arr[3] << 8) | arr[4]); - setEpochMissed(arr[5]); - break; - - case MSG_SYNC: - setSyncChNum(arr[0] & 0x3); - setSyncEpochLSB(arr[1] >> 7); - setSyncTs(((arr[1] & 0x7f) << 7) | ((arr[2] & 0xfc) >> 1)); - setSyncData(((arr[2] & 0x3) << 22) | (arr[3] << 14) | (arr[4] << 6) | (arr[5] >> 2)); - setSyncStFlag(arr[5] & 0x3); - break; - - case MSG_AUX: - setAuxChNum(((arr[0] & 0x3) << 5) | ((arr[1] & 0xf8) >> 3)); - setAuxEpochLSB((arr[1] & 0x4) >> 2); - setAuxTs(((arr[1] & 0x3) << 12) | (arr[2] << 4) | ((arr[3] & 0xe0) >> 4)); - setAuxFalling((arr[3] >> 4) & 1); - setAuxOverflow((arr[3] >> 3) & 1); - break; - - case MSG_SYS: - setSysMesType(arr[1]); - setSysMesData((arr[2] << 24) | (arr[3] << 16) | (arr[4] << 8) | arr[5]); - break; - - default: - return false; - } - - return true; -} - - -bool roc::Message::convertToOld(void* tgt) -{ - uint8_t* dataPtr = (uint8_t*) tgt; - for (int n=0;n<6;n++) dataPtr[n] = 0; - - dataPtr[0] = ((getMessageType() & 0x7) << 5) | ((getRocNumber() & 0x7) << 2); - - switch (getMessageType()) { - case MSG_HIT: - dataPtr[0] = dataPtr[0] | (getNxNumber() & 0x3); - dataPtr[1] = ((getNxTs() >> 9) & 0x1f) | ((getNxLtsMsb() << 5) & 0xe0); - dataPtr[2] = (getNxTs() >> 1); - dataPtr[3] = ((getNxTs() << 7) & 0x80) | (getNxChNum() & 0x7f); - dataPtr[4] = (getNxAdcValue() >> 5) & 0x7f; - dataPtr[5] = ((getNxAdcValue() << 3) & 0xf8) | - (getNxLastEpoch() & 0x1) | - ((getNxOverflow() & 0x1) << 1) | - ((getNxPileup() & 0x1) << 2); - break; - - case MSG_EPOCH: - dataPtr[1] = (getEpochNumber() >> 24) & 0xff; - dataPtr[2] = (getEpochNumber() >> 16) & 0xff; - dataPtr[3] = (getEpochNumber() >> 8) & 0xff; - dataPtr[4] = getEpochNumber() & 0xff; - dataPtr[5] = getEpochMissed(); - break; - - case MSG_SYNC: - dataPtr[0] = dataPtr[0] | (getSyncChNum() & 0x3); - dataPtr[1] = (getSyncEpochLSB() << 7) | ((getSyncTs() >> 7) & 0x7f); - dataPtr[2] = ((getSyncTs() << 1) & 0xfc) | ((getSyncData() >> 22) & 0x3); - dataPtr[3] = (getSyncData() >> 14) & 0xff; - dataPtr[4] = (getSyncData() >> 6) & 0xff; - dataPtr[5] = ((getSyncData() << 2) & 0xfc) | (getSyncStFlag() & 0x3); - break; - - case MSG_AUX: - dataPtr[0] = dataPtr[0] | ( (getAuxChNum() >> 5) & 0x3 ); - dataPtr[1] = ((getAuxChNum() << 3) & 0xf8) | - ((getAuxEpochLSB() << 2) & 0x4) | - ((getAuxTs() >> 12) & 0x3); - dataPtr[2] = (getAuxTs() >> 4) & 0xff; - dataPtr[3] = ((getAuxTs() << 4) & 0xe0) | - (getAuxFalling() << 4) | - (getAuxOverflow() << 3); - break; - - case MSG_SYS: - dataPtr[1] = getSysMesType(); - dataPtr[2] = (getSysMesData() >> 24) & 0xff; - dataPtr[3] = (getSysMesData() >> 16) & 0xff; - dataPtr[4] = (getSysMesData() >> 8) & 0xff; - dataPtr[5] = getSysMesData() & 0xff; - break; - - default: - return false; - } - - return true; -} - - -//---------------------------------------------------------------------------- -//! Returns expanded and adjusted time of message (in ns) -//! epoch should correspond to the message type - epoch2 for Get4, epoch for all others -//! When converting from GET4 (156Mhz) to SYNC (250 Mhz) clock, one should take into account -//! that initial value of 250 MHz timestamp counter is 0x80 or 512 ns. Therefore such offset -//! should be applied during conversion - -uint64_t roc::Message::getMsgFullTime(uint32_t epoch) const -{ - switch (getMessageType()) { - case MSG_HIT: - return FullTimeStamp(getNxLastEpoch() ? epoch - 1 : epoch, getNxTs()); - case MSG_EPOCH: - return FullTimeStamp(getEpochNumber(), 0); - case MSG_SYNC: - return FullTimeStamp((getSyncEpochLSB() == (epoch & 0x1)) ? epoch : epoch - 1, getSyncTs()); - case MSG_AUX: - return FullTimeStamp((getAuxEpochLSB() == (epoch & 0x1)) ? epoch : epoch - 1, getAuxTs()); - case MSG_EPOCH2: - return FullTimeStamp2(getEpoch2Number(), 0) / 20 + 512; - case MSG_GET4: - return FullTimeStamp2(epoch, getGet4Ts()) / 20 + 512; - case MSG_SYS: - return FullTimeStamp(epoch, 0); - - } - return 0; -} - -//---------------------------------------------------------------------------- -//! Returns expanded and adjusted time of message in double (in ns) -//! epoch should correspond to the message type - epoch2 for Get4, epoch for all others - -double roc::Message::getMsgFullTimeD(uint32_t epoch) const -{ - switch (getMessageType()) { - case MSG_EPOCH2: - return FullTimeStamp2(getEpoch2Number(), 0) / 20. + 512.; - case MSG_GET4: - return FullTimeStamp2(epoch, getGet4Ts()) / 20. + 512.; - } - return getMsgFullTime(epoch); -} - - -//---------------------------------------------------------------------------- -//! Returns the time difference between two expanded time stamps - -uint64_t roc::Message::CalcDistance(uint64_t start, uint64_t stop) -{ - if (start>stop) { - stop += 0x3FFFFFFFFFFFLLU; - if (start>stop) { - printf("Epochs overflow error in CalcDistance\n"); - return 0; - } - } - - return stop - start; -} - - -//---------------------------------------------------------------------------- -//! Returns the time difference between two expanded time stamps - -double roc::Message::CalcDistanceD(double start, double stop) -{ - if (start>stop) { - stop += 0x3FFFFFFFFFFFLLU; - if (start>stop) { - printf("Epochs overflow error in CalcDistanceD\n"); - return 0.; - } - } - - return stop - start; -} - - - -//---------------------------------------------------------------------------- -//! Print message in human readable format to \a cout. -/*! - * Prints a one line representation of the message in to \a cout. - * See printData(std::ostream&, unsigned, uint32_t) const for full - * documentation. - */ - -void roc::Message::printData(unsigned kind, uint32_t epoch) const -{ - printData(std::cout, kind, epoch); -} - -//---------------------------------------------------------------------------- -//! Print message in binary or human readable format to a stream. -/*! - * Prints a one line representation of the message in to stream \a os. - * The parameter \a kind is mask with 4 bits - * \li roc::msg_print_Prefix (1) - ROC number and message type - * \li roc::msg_print_Data (2) - print all message specific data fields - * \li roc::msg_print_Hex (4) - print data as hex dump - * \li roc::msg_print_Human (8) - print in human readable format - * - * If bit msg_print_Human in \a kind is not set, raw format - * output is generated. All data fields are shown in hexadecimal. - * This is the format of choice when chasing hardware problems at the bit level. - * - * If bit msg_print_Human is set, a more human readable output is generated. - * The timestamp is shown as fully extended and adjusted time as - * returned by the getMsgFullTime(uint32_t) const method. - * All data fields are represented in decimal. - * - * \param os output stream - * \param kind mask determing output format - * \param epoch current epoch number (from last epoch message) - * - * Typical message output in human format looks like -\verbatim -Msg:7 Roc:1 SysType: 1 Nx:0 Data: 0 : DAQ started -Msg:7 Roc:1 SysType: 6 Nx:0 Data: 0 : FIFO reset -Msg:2 Roc:1 EPO @ 0.536870912 Epo: 32768 0x00008000 Miss: 0 -Msg:0 Roc:0 NOP (raw 80:40:82:0F:00:00) -Msg:2 Roc:1 EPO @ 0.646627328 Epo: 39467 0x00009a2b Miss: 0 -Msg:1 Roc:1 HIT @ 0.646614333 Nx:2 Chn: 12 Ts: 3389-e( 8) Adc:2726 Pu:0 Of:0 -Msg:1 Roc:1 HIT @ 0.646630717 Nx:2 Chn: 13 Ts: 3389 ( 0) Adc:2745 Pu:0 Of:0 -Msg:2 Roc:1 EPO @ 0.805306368 Epo: 49152 0x0000c000 Miss: 0 -Msg:3 Roc:1 SYN @ 0.805306408 Chn:2 Ts: 40 Data: 49152 0x00c000 Flag:0 -Msg:7 Roc:1 SysType: 2 Nx:0 Data: 0 : DAQ finished -\endverbatim - * - * Typical message output in binary format looks like -\verbatim -Msg:7 Roc:1 SysType: 1 Nx:0 Data: 0 : DAQ started -Msg:7 Roc:1 SysType: 6 Nx:0 Data: 0 : FIFO reset -Msg:2 Roc:1 Epoch:00008000 Missed:00 -Msg:1 Roc:1 Nx:2 Chn:0d Ts:3ec9 Last:1 Msb:7 Adc:a22 Pup:0 Oflw:0 -Msg:1 Roc:1 Nx:2 Chn:0e Ts:3ec9 Last:0 Msb:7 Adc:a18 Pup:0 Oflw:0 -Msg:0 Roc:0 NOP (raw 80:40:82:0F:00:00) -Msg:2 Roc:1 Epoch:00010000 Missed:00 -Msg:3 Roc:1 SyncChn:2 EpochLSB:0 Ts:0028 Data:010000 Flag:0 -Msg:7 Roc:1 SysType: 2 Nx:0 Data: 0 : DAQ finished -\endverbatim - */ - -void roc::Message::printData(std::ostream& os, unsigned kind, uint32_t epoch) const -{ - char buf[256]; - - if (kind & msg_print_Hex) { - uint8_t* arr = (uint8_t*) &data; - snprintf(buf, sizeof(buf), "%02X:%02X:%02X:%02X:%02X:%02X ", - arr[0], arr[1], arr[2], arr[3], arr[4], arr[5]); - os << buf; - } - - if (kind & msg_print_Human) { - double timeInSec = getMsgFullTimeD(epoch)/1.e9; - int fifoFill = 0; - - switch (getMessageType()) { - case MSG_HIT: - fifoFill = getNxLtsMsb() - ((getNxTs()>>11)&0x7); - if (getNxLastEpoch()) fifoFill += 8; - snprintf(buf, sizeof(buf), - "Msg:%u Roc:%u ", getMessageType(), getRocNumber()); - os << buf; - snprintf(buf, sizeof(buf), - "HIT @%15.9f Nx:%d Chn:%3d Ts:%5d%s(%2d) Adc:%4d Pu:%d Of:%d", - timeInSec, getNxNumber(), getNxChNum(), getNxTs(), - (getNxLastEpoch() ? "-e" : " "), - fifoFill, getNxAdcValue(), getNxPileup(), getNxOverflow()); - os << buf << std::endl; - break; - case MSG_EPOCH: - snprintf(buf, sizeof(buf), - "Msg:%u Roc:%u ", getMessageType(), getRocNumber()); - os << buf; - snprintf(buf, sizeof(buf), - "EPO @%15.9f Epo:%10u 0x%08x Miss: %3d%c", - timeInSec, getEpochNumber(), getEpochNumber(), - getEpochMissed(), (getEpochMissed()==0xff) ? '+' : ' '); - os << buf << std::endl; - break; - case MSG_SYNC: - snprintf(buf, sizeof(buf), - "Msg:%u Roc:%u ", getMessageType(), getRocNumber()); - os << buf; - snprintf(buf, sizeof(buf), - "SYN @%15.9f Chn:%d Ts:%5d%s Data:%8d 0x%06x Flag:%d", - timeInSec, getSyncChNum(), getSyncTs(), - ((getSyncEpochLSB() != (epoch&0x1)) ? "-e" : " "), - getSyncData(), getSyncData(), getSyncStFlag()); - os << buf << std::endl; - break; - case MSG_AUX: - snprintf(buf, sizeof(buf), - "Msg:%u Roc:%u ", getMessageType(), getRocNumber()); - os << buf; - snprintf(buf, sizeof(buf), - "AUX @%15.9f Chn:%d Ts:%5d%s Falling:%d Overflow:%d", - timeInSec, getAuxChNum(), getAuxTs(), - ((getAuxEpochLSB() != (epoch&0x1)) ? "-e" : " "), - getAuxFalling(), getAuxOverflow()); - os << buf << std::endl; - break; - case MSG_EPOCH2: - snprintf(buf, sizeof(buf), - "Msg:%u Roc:%u ", getMessageType(), getRocNumber()); - os << buf; - snprintf(buf, sizeof(buf), - "EPO2 @%17.11f Get4:%2d Epoche2:%10u 0x%08x StampTime:%2d Sync:%x Dataloss:%x Epochloss:%x", - timeInSec, getEpoch2ChipNumber(), getEpoch2Number(), getEpoch2Number(), - getEpoch2StampTime(), getEpoch2Sync(), getEpoch2DataLost(), getEpoch2EpochLost()); - os << buf << std::endl; - break; - case MSG_GET4: - snprintf(buf, sizeof(buf), - "Msg:%u Roc:%u ", getMessageType(), getRocNumber()); - os << buf; - snprintf(buf, sizeof(buf), - "Get4 @%17.11f Get4:%2d Chn:%3d Edge:%1d Ts:%7d CRC8:%3d", - timeInSec, getGet4Number(), getGet4ChNum(), getGet4Edge(), getGet4Ts(), getGet4CRC() ); - os << buf << std::endl; - break; - default: - kind = kind & ~msg_print_Human; - if (kind==0) kind = msg_print_Prefix | msg_print_Data; - } - - // return, if message was correctly printed in human-readable form - if (kind & msg_print_Human) return; - } - - if (kind & msg_print_Prefix) { - snprintf(buf, sizeof(buf), "Msg:%u Roc:%u ", getMessageType(), getRocNumber()); - os << buf; - } - - if (kind & msg_print_Data) { - uint8_t* arr = (uint8_t*) &data; - switch (getMessageType()) { - case MSG_NOP: - snprintf(buf, sizeof(buf), "NOP (raw %02X:%02X:%02X:%02X:%02X:%02X)", - arr[0], arr[1], arr[2], arr[3], arr[4], arr[5]); - break; - case MSG_HIT: - snprintf(buf, sizeof(buf), "Nx:%1x Chn:%02x Ts:%04x Last:%1x Msb:%1x Adc:%03x Pup:%1x Oflw:%1x", - getNxNumber(), getNxChNum(), getNxTs(), getNxLastEpoch(), - getNxLtsMsb(), getNxAdcValue(), getNxPileup(), - getNxOverflow()); - break; - case MSG_EPOCH: - snprintf(buf, sizeof(buf), "Epoch:%08x Missed:%02x", - getEpochNumber(), getEpochMissed()); - break; - case MSG_SYNC: - snprintf(buf, sizeof(buf), "SyncChn:%1x EpochLSB:%1x Ts:%04x Data:%06x Flag:%1x", - getSyncChNum(), getSyncEpochLSB(), getSyncTs(), - getSyncData(), getSyncStFlag()); - break; - case MSG_AUX: - snprintf(buf, sizeof(buf), "AuxChn:%02x EpochLSB:%1x Ts:%04x Falling:%1x Overflow:%1x", - getAuxChNum(), getAuxEpochLSB(), getAuxTs(), - getAuxFalling(), getAuxOverflow()); - break; - case MSG_EPOCH2: - snprintf(buf, sizeof(buf), "Get4:0x%02x Epoche2:0x%08x StampTime:0x%x Sync:%x Dataloss:%x Epochloss:%x", - getEpoch2ChipNumber(), getEpoch2Number(), getEpoch2StampTime(), getEpoch2Sync(), getEpoch2DataLost(), getEpoch2EpochLost()); - break; - case MSG_GET4: - snprintf(buf, sizeof(buf), "Get4:0x%02x Chn:%1x Edge:%1x Ts:0x%05x CRC8:0x%02x", - getGet4Number(), getGet4ChNum(), getGet4Edge(), getGet4Ts(), getGet4CRC() ); - break; - case MSG_SYS: { - char sysbuf[256]; - - switch (getSysMesType()) { - case SYSMSG_DAQ_START: - snprintf(sysbuf, sizeof(sysbuf), "DAQ started"); - break; - case SYSMSG_DAQ_FINISH: - snprintf(sysbuf, sizeof(sysbuf), "DAQ finished"); - break; - case SYSMSG_NX_PARITY: { - uint32_t dataMes = getSysMesData(); - uint32_t nxb3_flg = (dataMes>>31) & 0x01; - uint32_t nxb3_val = (dataMes>>24) & 0x7f; - uint32_t nxb2_flg = (dataMes>>23) & 0x01; - uint32_t nxb2_val = (dataMes>>16) & 0x7f; - uint32_t nxb1_flg = (dataMes>>15) & 0x01; - uint32_t nxb1_val = (dataMes>>8 ) & 0x7f; - uint32_t nxb0_flg = (dataMes>>7 ) & 0x01; - uint32_t nxb0_val = (dataMes ) & 0x7f; - snprintf(sysbuf, sizeof(sysbuf),"Nx:%1x %1d%1d%1d%1d:%02x:%02x:%02x:%02x nX parity error", getNxNumber(), - nxb3_flg, nxb2_flg, nxb1_flg, nxb0_flg, - nxb3_val, nxb2_val, nxb1_val, nxb0_val); - } - break; - case SYSMSG_SYNC_PARITY: - snprintf(sysbuf, sizeof(sysbuf), "SYNC parity error "); - break; - case SYSMSG_DAQ_RESUME: - snprintf(sysbuf, sizeof(sysbuf), "DAQ resume after high/low water"); - break; - case SYSMSG_FIFO_RESET: - snprintf(sysbuf, sizeof(sysbuf), "FIFO reset"); - break; - case SYSMSG_USER: { - const char* subtyp = ""; - if (getSysMesData()==SYSMSG_USER_CALIBR_ON) subtyp = "Calibration ON"; else - if (getSysMesData()==SYSMSG_USER_CALIBR_OFF) subtyp = "Calibration OFF"; else - if (getSysMesData()==SYSMSG_USER_RECONFIGURE) subtyp = "Reconfigure"; - snprintf(sysbuf, sizeof(sysbuf), "User message 0x%08x %s", getSysMesData(), subtyp); - break; - } - case SYSMSG_PACKETLOST: - snprintf(sysbuf, sizeof(sysbuf), "Packet lost"); - break; - case SYSMSG_GET4_EVENT: { -// uint32_t dataMes = getSysMesData(); - uint32_t get4_pattern = getField(16, 6); //(dataMes>>16) & 0x3f; - uint32_t get4_eventType = getBit(22); //(dataMes>>7) & 0xfff; - uint32_t get4_TS = getField(23,12); //(dataMes>>6) & 0x1; - uint32_t get4_chip = getField(40, 8); // dataMes & 0xff; - if(get4_eventType==1) - snprintf(sysbuf, sizeof(sysbuf), - "Get4:0x%02x TS:0x%03x Pattern:0x%02x - GET4 External Sync Event", get4_chip, get4_TS, get4_pattern); - else - snprintf(sysbuf, sizeof(sysbuf), - "Get4:0x%02x TS:0x%03x ErrCode:0x%02x - GET4 Error Event", get4_chip, get4_TS, get4_pattern); - break; - } - case SYSMSG_CLOSYSYNC_ERROR: - snprintf(sysbuf, sizeof(sysbuf), "Closy synchronization error"); - break; - case SYSMSG_TS156_SYNC: - snprintf(sysbuf, sizeof(sysbuf), "156.25MHz timestamp reset"); - break; - default: - snprintf(sysbuf, sizeof(sysbuf), "unknown system message type "); - } - - snprintf(buf, sizeof(buf), "SysType:%2x Data:%8x : %s", getSysMesType(), getSysMesData(), sysbuf); - - break; - } - default: - snprintf(buf, sizeof(buf), "Error - unexpected MessageType: %1x", getMessageType()); - } - } - - os << buf << std::endl; -} - -uint32_t roc::Message::RawSize(MessageFormat fmt) -{ - switch (fmt) { - case formatEth1: return 6; - case formatOptic1: return 8; - case formatEth2: return 6; - case formatOptic2: return 8; - case formatNormal: return 8; - } - return 8; -} - -bool roc::Message::assign(void* src, MessageFormat fmt) -{ - switch (fmt) { - case formatEth1: - convertFromOld(src); - return true; - case formatOptic1: - convertFromOld((uint8_t*) src + 2); - setRocNumber((*((uint8_t*) src) << 8) | *((uint8_t*) src + 1) ); - return true; - case formatEth2: - memcpy(&data, src, 6); - return true; - case formatOptic2: - memcpy(&data, (uint8_t*) src + 2, 6); - setRocNumber(*((uint16_t*) src)); - return true; - case formatNormal: - memcpy(&data, src, 8); - return true; - } - - return false; -} - -bool roc::Message::copyto(void* tgt, MessageFormat fmt) -{ - switch (fmt) { - case formatEth1: - convertToOld(tgt); - return true; - case formatOptic1: - convertToOld((uint8_t*) tgt + 2); - *((uint16_t*) tgt) = getRocNumber(); - return true; - case formatEth2: - memcpy(tgt, &data, 6); - return true; - case formatOptic2: - memcpy((uint8_t*) tgt + 2, &data, 6); - *((uint16_t*) tgt) = getRocNumber(); - return true; - case formatNormal: - memcpy(tgt, &data, 8); - return true; - } - - return false; - -} diff --git a/beamtime/roclight/src_roc/OperList.cxx b/beamtime/roclight/src_roc/OperList.cxx deleted file mode 100644 index 3182b4ae58d5533c05dabe9491ab2efefadcd19f..0000000000000000000000000000000000000000 --- a/beamtime/roclight/src_roc/OperList.cxx +++ /dev/null @@ -1,44 +0,0 @@ -#include "roc/OperList.h" - -#include <stdio.h> - -roc::OperList::OperList() : - fList(), - fErrorOper(-1), - fErrorCode(0) -{ - -} - -roc::OperList::OperList(int noper, bool* isputIn, uint32_t* addr, uint32_t* value) : - fList(), - fErrorOper(-1), - fErrorCode(0) -{ - for (int n=0;n<noper;n++) - addOper(isputIn[n], addr[n], value[n]); -} - -roc::OperList::OperList(const OperList& src) : - fList(), - fErrorOper(-1), - fErrorCode(0) -{ - for (int n=0;n<src.number();n++) - addOper(src.oper(n)); -} - -roc::OperList::~OperList() -{ - fList.clear(); - -} - -void roc::OperList::print() -{ - printf("OperList size = %d\n", number()); - for (int n=0;n<number();n++) - printf(" %s %08x %08x\n", (isput(n) ? "Put" : "Get"), oper(n).addr, oper(n).value); - printf(" ErrCode=%d ErrOper=%d\n", fErrorCode, fErrorOper); - -} diff --git a/beamtime/star2017/CMakeLists.txt b/beamtime/star2017/CMakeLists.txt deleted file mode 100644 index 5fa2c6d0bc73a678361b260a9ca5efa16276995a..0000000000000000000000000000000000000000 --- a/beamtime/star2017/CMakeLists.txt +++ /dev/null @@ -1,65 +0,0 @@ -# Create a library called "libCbmFlibReader" which includes the source files given in -# the array . -# The extension is already found. Any number of sources could be listed here. - -Set(INCLUDE_DIRECTORIES - ${CBMBASE_DIR} - - ${CBMDATA_DIR} - ${CBMDATA_DIR}/tof - ${CBMDATA_DIR}/tof/etof # For the star_rhicf.c interface file - - ${CBMROOT_SOURCE_DIR}/beamtime/base - ${CBMROOT_SOURCE_DIR}/beamtime/param - ${CBMROOT_SOURCE_DIR}/beamtime/data/raw - ${CBMROOT_SOURCE_DIR}/beamtime/data - - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/unpacker -) - -Set(SYSTEM_INCLUDE_DIRECTORIES - ${BASE_INCLUDE_DIRECTORIES} - ${Boost_INCLUDE_DIR} - ${ROOT_INCLUDE_DIR} - ${IPC_INCLUDE_DIRECTORY} - ${CBMROOT_SOURCE_DIR}/external/flib_dpb/flib_dpb - ${CMAKE_SOURCE_DIR}/external/cppzmq -) - -Include_Directories(${INCLUDE_DIRECTORIES}) -Include_Directories(SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES}) - - -Set(LINK_DIRECTORIES - ${ROOT_LIBRARY_DIR} - ${FAIRROOT_LIBRARY_DIR} - ${Boost_LIBRARY_DIRS} -) - -Link_Directories( - ${LINK_DIRECTORIES} -) - -Set(SRCS - unpacker/CbmTSMonitorTofStar.cxx - unpacker/CbmTSMonitorTofLab.cxx -) - -If( STAR_SUBEVT_BUILDER ) - ADD_DEFINITIONS(-DSTAR_SUBEVT_BUILDER) - Message(STATUS "Compiling with support for STAR DAQ Event writing") -EndIf() - -If(_UINT8_T_EXIST) - Add_Definitions(-DHAVE_UINT8_T_HEADER_FILE) - Set(DEFINITIONS HAVE_UINT8_T_HEADER_FILE) -EndIf() - -Set(LINKDEF CbmBeamtimeStar2017LinkDef.h ) -Set(LIBRARY_NAME CbmBeamtimeStar2017) -Set(DEPENDENCIES - CbmBase CbmData CbmBeamtimeBase CbmBeamtimeData CbmBeamtimeParam fles_ipc Eve Base -) - -GENERATE_LIBRARY() diff --git a/beamtime/star2017/CbmBeamtimeStar2017LinkDef.h b/beamtime/star2017/CbmBeamtimeStar2017LinkDef.h deleted file mode 100644 index e49f17228cd047824fbbba946c7740770304e337..0000000000000000000000000000000000000000 --- a/beamtime/star2017/CbmBeamtimeStar2017LinkDef.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifdef __CINT__ - -#pragma link off all globals; -#pragma link off all classes; -#pragma link off all functions; - -#pragma link C++ class CbmTSMonitorTofStar; -#pragma link C++ class CbmTSMonitorTofLab; - -#endif diff --git a/beamtime/star2017/unpacker/CbmTSMonitorTofLab.cxx b/beamtime/star2017/unpacker/CbmTSMonitorTofLab.cxx deleted file mode 100644 index 3610755fe31072ab02c6710c73401df60d749b06..0000000000000000000000000000000000000000 --- a/beamtime/star2017/unpacker/CbmTSMonitorTofLab.cxx +++ /dev/null @@ -1,2355 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmTSMonitorTofLab ----- -// ----- Created 15.12.2016 by P.-A. Loizeau ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#include "CbmTSMonitorTofLab.h" -#include "CbmTofUnpackPar.h" - -//#include "CbmFlibCern2016Source.h" -#include "CbmHistManager.h" - -#include "FairLogger.h" -#include "FairRootManager.h" -#include "FairRun.h" -#include "FairRuntimeDb.h" -#include "FairRunOnline.h" - -#include "TClonesArray.h" -#include "TString.h" -#include "THttpServer.h" -#include "Rtypes.h" -#include "TH1.h" -#include "TCanvas.h" -#include "THStack.h" -#include "TROOT.h" -#include "TStyle.h" -#include "TPaveStats.h" -#include "TDatime.h" -#include <TFile.h> - -#include <algorithm> -#include <iostream> -#include <stdint.h> -#include <iomanip> -#include <ctime> - -namespace MonitorTofLab { - static Int_t iMess = 0; -// static Int_t iMessB = 0; - Bool_t bResetTofLabHistos = kFALSE; - Bool_t bTofLabCyclePulserFee = kFALSE; - - // Default value for nb bins in Pulser time difference histos - //const UInt_t kuNbBinsDt = 5000; - const UInt_t kuNbBinsDt = 150; - Double_t dMinDt = -1.*(kuNbBinsDt*get4v1x::kdBinSize/2.) - get4v1x::kdBinSize/2.; - Double_t dMaxDt = 1.*(kuNbBinsDt*get4v1x::kdBinSize/2.) + get4v1x::kdBinSize/2.; - //const UInt_t kuNbBinsDt = 299; - //Double_t dMinDt = -1.*((kuNbBinsDt+1)*get4v1x::kdBinSize/2.); - //Double_t dMaxDt = 1.*((kuNbBinsDt+1)*get4v1x::kdBinSize/2.); - - // Default number of FEET per channels histograms - UInt_t uNbFeetPlot = 2; -} - -using namespace MonitorTofLab; - -CbmTSMonitorTofLab::CbmTSMonitorTofLab() : - CbmTSUnpack(), - fuMsAcceptsPercent(100), - fuOverlapMsNb(0), - fuMinNbGdpb(), - fuCurrNbGdpb(0), - fNrOfGdpbs(0), - fNrOfFebsPerGdpb(0), - fNrOfGet4PerFeb(0), - fNrOfChannelsPerGet4(0), - fNrOfChannelsPerFeet(0), - fNrOfGet4(0), - fNrOfGet4PerGdpb(0), - fiCountsLastTs(0), - fiSpillOnThr(10), - fiSpillOffThr(3), - fiTsUnderOff(0), - fiTsUnderOffThr(10), - fdDetLastTime(-1.), - fdDetTimeLastTs(-1.), - fbSpillOn(kFALSE), - fSpillIdx(0), - fbEpochSuppModeOn(kFALSE), - fvmEpSupprBuffer(), - fvmEpSupprBufferErrors(), - fGdpbId(0), - fGdpbNr(0), - fGet4Id(0), - fGet4Nr(0), - fMsgCounter(11, 0), // length of enum MessageTypes initialized with 0 - fGdpbIdIndexMap(), - fHM(new CbmHistManager()), - fCurrentEpoch(NULL), - fuCurrentEpochCycle(NULL), - fNofEpochs(0), - fCurrentEpochTime(0.), - fdStartTime(-1.), - fdStartTimeMsSz(-1.), - fcMsSizeAll(NULL), - fTsLastHit(), - fEquipmentId(0), - fUnpackPar(NULL), - fTimeLastHistoSave(), - fHistMessType(NULL), - fHistSysMessType(NULL), - fHistGet4MessType(NULL), - fHistGet4ChanErrors(NULL), - fHistGet4EpochFlags(NULL), - fHistSpill(NULL), - fHistSpillLength(NULL), - fHistSpillCount(NULL), - fHistSpillQA(NULL), - fRaw_Tot_gDPB(), - fChCount_gDPB(), - fChannelRate_gDPB(), - fFeetRate_gDPB(), - fFeetErrorRate_gDPB(), - fFeetRateLong_gDPB(), - fFeetErrorRateLong_gDPB(), - fFeetRateDate_gDPB(), - fiRunStartDateTimeSec( -1 ), - fiBinSizeDatePlots( -1 ), - fbEnableCoincMap(kFALSE), - fulLastMsIdx(0), - fbHitsInLastTs(kFALSE), - fvulHitEpochBuffLastTs(), - fvhCoincOffsetEpochGet4(), - fulGdpbTsMsb(0), - fulGdpbTsLsb(0), - fulStarTsMsb(0), - fulStarTsMid(0), - fulGdpbTsFullLast(0), - fulStarTsFullLast(0), - fuStarTokenLast(0), - fuStarDaqCmdLast(0), - fuStarTrigCmdLast(0), - fhTokenMsgType(NULL), - fhTriggerRate(NULL), - fhCmdDaqVsTrig(NULL), - fhStarTokenEvo(NULL), - fbGet4M24b( kFALSE ), - fbGet4v20( kFALSE ), - fbPulserMode( kFALSE ), - fuPulserGdpb(0), - fuPulserFee(0), - fhTimeDiffPulserChosenFee(), - fhTimeDiffPulserChosenChPairs(), - fhTimeRmsPulserChosenFee(NULL), - fhTimeRmsPulserChosenChPairs(NULL), - fdLastRmsUpdateTime(-1), - fhFtDistribPerCh(), - fChCountFall_gDPB(), - fhFtDistribPerChFall(), - fviFtLastRise24b(), - fviFtLastFall24b(), - fvdTimeLastRise24b(), - fvdTimeLastFall24b(), - fuRiseFallChSel(0), - fhFtLastRiseCurrFall(), - fhFtCurrRiseLastFall(), - fhFtLastRiseDistRise(), - fhFtLastRiseDistFall() -{ -} - -CbmTSMonitorTofLab::~CbmTSMonitorTofLab() -{ - delete fHM; //TODO: Who deletes the histograms stored in the CbmHistManager??? - delete[] fCurrentEpoch; - delete[] fuCurrentEpochCycle; -} - -Bool_t CbmTSMonitorTofLab::Init() -{ - LOG(info) << "Initializing Get4 monitor"; - - FairRootManager* ioman = FairRootManager::Instance(); - if (ioman == NULL) { - LOG(fatal) << "No FairRootManager instance"; - } - - return kTRUE; -} - -void CbmTSMonitorTofLab::SetParContainers() -{ - LOG(info) << "Setting parameter containers for " << GetName(); - fUnpackPar = - (CbmTofUnpackPar*) (FairRun::Instance()->GetRuntimeDb()->getContainer( - "CbmTofUnpackPar")); - -} - -Bool_t CbmTSMonitorTofLab::InitContainers() -{ - LOG(info) << "Init parameter containers for " << GetName(); - Bool_t initOK = ReInitContainers(); - - CreateHistograms(); - - fCurrentEpoch = new Long64_t[fNrOfGdpbs * fNrOfGet4PerGdpb]; - fuCurrentEpochCycle = new UInt_t[fNrOfGdpbs * fNrOfGet4PerGdpb]; - for (UInt_t i = 0; i < fNrOfGdpbs; ++i) { - for (UInt_t j = 0; j < fNrOfGet4PerGdpb; ++j) { - fCurrentEpoch[GetArrayIndex(i, j)] = -111; - fuCurrentEpochCycle[GetArrayIndex(i, j)] = 0; - } - } - - return initOK; -} - -Bool_t CbmTSMonitorTofLab::ReInitContainers() -{ - LOG(info) << "ReInit parameter containers for " << GetName(); - - fNrOfGdpbs = fUnpackPar->GetNrOfRocs(); - LOG(info) << "Nr. of Tof GDPBs: " << fNrOfGdpbs; - fuMinNbGdpb = fNrOfGdpbs; - - fNrOfFebsPerGdpb = fUnpackPar->GetNrOfFebsPerGdpb(); - LOG(info) << "Nr. of FEBS per Tof GDPB: " << fNrOfFebsPerGdpb; - - fNrOfGet4PerFeb = fUnpackPar->GetNrOfGet4PerFeb(); - LOG(info) << "Nr. of GET4 per Tof FEB: " << fNrOfGet4PerFeb; - - fNrOfChannelsPerGet4 = fUnpackPar->GetNrOfChannelsPerGet4(); - LOG(info) << "Nr. of channels per GET4: " << fNrOfChannelsPerGet4; - - fNrOfChannelsPerFeet = fNrOfGet4PerFeb * fNrOfChannelsPerGet4; - LOG(info) << "Nr. of channels per FEET: " << fNrOfChannelsPerFeet; - - fNrOfGet4 = fNrOfGdpbs * fNrOfFebsPerGdpb * fNrOfGet4PerFeb; - LOG(info) << "Nr. of GET4s: " << fNrOfGet4; - - fNrOfGet4PerGdpb = fNrOfFebsPerGdpb * fNrOfGet4PerFeb; - LOG(info) << "Nr. of GET4s per GDPB: " << fNrOfGet4PerGdpb; - - fGdpbIdIndexMap.clear(); - for (UInt_t i = 0; i < fNrOfGdpbs; ++i) { - fGdpbIdIndexMap[fUnpackPar->GetRocId(i)] = i; - LOG(info) << "GDPB Id of TOF " << i << " : " << fUnpackPar->GetRocId(i); - } - Int_t NrOfChannels = fUnpackPar->GetNumberOfChannels(); - LOG(info) << "Nr. of mapped Tof channels: " << NrOfChannels; - std::stringstream ss; - for (Int_t i = 0; i< NrOfChannels; ++i) { - if(i%8 == 0) - ss << "\n"; - ss << Form(" 0x%08x",fUnpackPar->GetChannelToDetUIdMap(i)); - } - LOG(info) << ss.str(); - - LOG(info) << "Plot Channel Rate => " - << (fUnpackPar->IsChannelRateEnabled() ? "ON" : "OFF"); - - if( fbEpochSuppModeOn ) - { - fvmEpSupprBuffer.resize( fNrOfGet4 ); - fvmEpSupprBufferErrors.resize( fNrOfGet4 ); - } // if( fbEpochSuppModeOn ) - - return kTRUE; -} - -void CbmTSMonitorTofLab::CreateHistograms() -{ - THttpServer* server = FairRunOnline::Instance()->GetHttpServer(); -// server->SetJSROOT("https://root.cern.ch/js/latest"); - LOG(info) << "Using Http Server " << server - << "with JSROOT = "; - - TString name { "" }; - TString title { "" }; - - name = "hMessageType"; - title = "Nb of message for each type; Type"; - // Test Big Data readout with plotting - TH1I* hMessageType = new TH1I(name, title, 16, 0., 16.); - // TH1I* hMessageType = new TH1I(name, title, 16, -0.5, 15.5); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_NOP, "NOP"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_HIT, "HIT"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_EPOCH, "EPOCH"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_SYNC, "SYNC"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_AUX, "AUX"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_EPOCH2, "EPOCH2"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_GET4, "GET4"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_SYS, "SYS"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_GET4_SLC, - "MSG_GET4_SLC"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_GET4_32B, - "MSG_GET4_32B"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_GET4_SYS, - "MSG_GET4_SYS"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_STAR_TRI, - "MSG_STAR_TRI"); - hMessageType->GetXaxis()->SetBinLabel(1 + 15, "GET4 Hack 32B"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_NOP, "NOP"); - fHM->Add(name.Data(), hMessageType); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - - name = "hSysMessType"; - title = "Nb of system message for each type; System Type"; - TH1I* hSysMessType = new TH1I(name, title, 17, 0., 17.); -// TH1I* hSysMessType = new TH1I(name, title, 17, -0.5, 16.5); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_START, - "DAQ START"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_FINISH, - "DAQ FINISH"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_NX_PARITY, - "NX PARITY"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_SYNC_PARITY, - "SYNC PARITY"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_RESUME, - "DAQ RESUME"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_FIFO_RESET, - "FIFO RESET"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_USER, "USER"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_PCTIME, "PCTIME"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_ADC, "ADC"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_PACKETLOST, - "PACKET LOST"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_GET4_EVENT, - "GET4 ERROR"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_CLOSYSYNC_ERROR, - "CLOSYSYNC ERROR"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_TS156_SYNC, - "TS156 SYNC"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_GDPB_UNKWN, - "UNKW GET4 MSG"); - hSysMessType->GetXaxis()->SetBinLabel(1 + 16, "GET4 Hack 32B"); - fHM->Add(name.Data(), hSysMessType); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - - name = "hGet4MessType"; - title = "Nb of message for each type per GET4; GET4 chip # ; Type"; - TH2I* hGet4MessType = new TH2I(name, title, fNrOfGet4, 0., fNrOfGet4, 5, 0., - 5.); -// TH2I* hGet4MessType = new TH2I(name, title, uNbFeets*feetv1::kuChipPerFeet, -0.5, uNbFeets*feetv1::kuChipPerFeet -0.5, 5, -0.5, 4.5); - hGet4MessType->GetYaxis()->SetBinLabel(1 + ngdpb::GET4_32B_EPOCH, "EPOCH"); - hGet4MessType->GetYaxis()->SetBinLabel(1 + ngdpb::GET4_32B_SLCM, "S.C. M"); - hGet4MessType->GetYaxis()->SetBinLabel(1 + ngdpb::GET4_32B_ERROR, "ERROR"); - hGet4MessType->GetYaxis()->SetBinLabel(1 + ngdpb::GET4_32B_DATA, "DATA 32b"); - hGet4MessType->GetYaxis()->SetBinLabel(1 + ngdpb::GET4_32B_DATA + 1, - "DATA 24b"); - fHM->Add(name.Data(), hGet4MessType); - if (server) - server->Register("/TofRaw", fHM->H2(name.Data())); - - name = "hGet4ChanErrors"; - title = "Error messages per GET4 channel; GET4 channel # ; Error"; - TH2I* hGet4ChanErrors = NULL; - if( kTRUE == fbGet4v20 ) - { - /// Possible errors changed after introduction of Bubbles correction/detection - hGet4ChanErrors = new TH2I(name, title, - fNrOfGet4 * fNrOfChannelsPerGet4, 0., fNrOfGet4 * fNrOfChannelsPerGet4, - 21, 0., 21.); -// 32, 0., 32.); - hGet4ChanErrors->GetYaxis()->SetBinLabel( 1, "0x00: Readout Init "); - hGet4ChanErrors->GetYaxis()->SetBinLabel( 2, "0x01: Sync "); - hGet4ChanErrors->GetYaxis()->SetBinLabel( 3, "0x02: Epoch count sync"); - hGet4ChanErrors->GetYaxis()->SetBinLabel( 4, "0x03: Epoch "); - hGet4ChanErrors->GetYaxis()->SetBinLabel( 5, "0x04: FIFO Write "); - hGet4ChanErrors->GetYaxis()->SetBinLabel( 6, "0x05: Lost event "); - hGet4ChanErrors->GetYaxis()->SetBinLabel( 7, "0x06: Channel state "); - hGet4ChanErrors->GetYaxis()->SetBinLabel( 8, "0x07: Token Ring state"); - hGet4ChanErrors->GetYaxis()->SetBinLabel( 9, "0x08: Token "); - hGet4ChanErrors->GetYaxis()->SetBinLabel(10, "0x09: Error Readout "); - hGet4ChanErrors->GetYaxis()->SetBinLabel(11, "0x0a: SPI "); - hGet4ChanErrors->GetYaxis()->SetBinLabel(12, "0x0b: DLL Lock error "); // <- From GET4 v1.2 - hGet4ChanErrors->GetYaxis()->SetBinLabel(13, "0x0c: DLL Reset invoc."); // <- From GET4 v1.2 - hGet4ChanErrors->GetYaxis()->SetBinLabel(14, "0x11: Overwrite "); - hGet4ChanErrors->GetYaxis()->SetBinLabel(15, "0x12: ToT out of range"); - hGet4ChanErrors->GetYaxis()->SetBinLabel(16, "0x13: Event Discarded "); - hGet4ChanErrors->GetYaxis()->SetBinLabel(17, "0x14: Add. Rising edge"); // <- From GET4 v1.3 - hGet4ChanErrors->GetYaxis()->SetBinLabel(18, "0x15: Unpaired Falling"); // <- From GET4 v1.3 - hGet4ChanErrors->GetYaxis()->SetBinLabel(19, "0x16: Sequence error "); // <- From GET4 v1.3 - hGet4ChanErrors->GetYaxis()->SetBinLabel(20, "0x7f: Unknown "); - hGet4ChanErrors->GetYaxis()->SetBinLabel(21, "Corrupt/unsuprtd error"); - } // if( kTRUE == fbGet4v20 ) - else - { - hGet4ChanErrors = new TH2I(name, title, - fNrOfGet4 * fNrOfChannelsPerGet4, 0., fNrOfGet4 * fNrOfChannelsPerGet4, - 18, 0., 18.); - // 32, 0., 32.); - hGet4ChanErrors->GetYaxis()->SetBinLabel( 1, "0x00: Readout Init "); - hGet4ChanErrors->GetYaxis()->SetBinLabel( 2, "0x01: Sync "); - hGet4ChanErrors->GetYaxis()->SetBinLabel( 3, "0x02: Epoch count sync"); - hGet4ChanErrors->GetYaxis()->SetBinLabel( 4, "0x03: Epoch "); - hGet4ChanErrors->GetYaxis()->SetBinLabel( 5, "0x04: FIFO Write "); - hGet4ChanErrors->GetYaxis()->SetBinLabel( 6, "0x05: Lost event "); - hGet4ChanErrors->GetYaxis()->SetBinLabel( 7, "0x06: Channel state "); - hGet4ChanErrors->GetYaxis()->SetBinLabel( 8, "0x07: Token Ring state"); - hGet4ChanErrors->GetYaxis()->SetBinLabel( 9, "0x08: Token "); - hGet4ChanErrors->GetYaxis()->SetBinLabel(10, "0x09: Error Readout "); - hGet4ChanErrors->GetYaxis()->SetBinLabel(11, "0x0a: SPI "); - hGet4ChanErrors->GetYaxis()->SetBinLabel(12, "0x0b: DLL Lock error "); // <- From GET4 v1.2 - hGet4ChanErrors->GetYaxis()->SetBinLabel(13, "0x0c: DLL Reset invoc."); // <- From GET4 v1.2 - hGet4ChanErrors->GetYaxis()->SetBinLabel(14, "0x11: Overwrite "); - hGet4ChanErrors->GetYaxis()->SetBinLabel(15, "0x12: ToT out of range"); - hGet4ChanErrors->GetYaxis()->SetBinLabel(16, "0x13: Event Discarded "); - hGet4ChanErrors->GetYaxis()->SetBinLabel(17, "0x7f: Unknown "); - } // else of if( kTRUE == fbGet4v20 ) - fHM->Add(name.Data(), hGet4ChanErrors); - if (server) - server->Register("/TofRaw", fHM->H2(name.Data())); - - name = "hGet4EpochFlags"; - title = "Epoch flags per GET4; GET4 chip # ; Type"; - TH2I* hGet4EpochFlags = new TH2I(name, title, fNrOfGet4, 0., fNrOfGet4, 4, 0., - 4.); -// hEpochFlags = new TH2I(name, title, uNbFeets*feetv1::kuChipPerFeet, -0.5, uNbFeets*feetv1::kuChipPerFeet -0.5, 4, -0.5, 3.5); - hGet4EpochFlags->GetYaxis()->SetBinLabel(1, "SYNC"); - hGet4EpochFlags->GetYaxis()->SetBinLabel(2, "Ep LOSS"); - hGet4EpochFlags->GetYaxis()->SetBinLabel(3, "Da LOSS"); - hGet4EpochFlags->GetYaxis()->SetBinLabel(4, "MISSMAT"); - fHM->Add(name.Data(), hGet4EpochFlags); - if (server) - server->Register("/TofRaw", fHM->H2(name.Data())); - - // Prepare storing of hit time info - if( fUnpackPar->IsChannelRateEnabled() || fbPulserMode ) - { - fTsLastHit.resize( fNrOfGdpbs ); - for( UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; uGdpb++) - { - fTsLastHit[ uGdpb ].resize( fNrOfGet4PerGdpb ); - for( UInt_t uGet4 = 0; uGet4 < fNrOfGet4PerGdpb; uGet4++) - { - fTsLastHit[ uGdpb ][ uGet4 ].resize( fNrOfChannelsPerGet4 ); - for( UInt_t uCh = 0; uCh < fNrOfChannelsPerGet4; uCh++) - fTsLastHit[ uGdpb ][ uGet4 ][ uCh ] = -1; - } // for( UInt_t uGet4 = 0; uGet4 < fNrOfGet4PerGdpb; uGet4++) - } // for( UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; uGdpb++) - } // if( fUnpackPar->IsChannelRateEnabled() || fbPulserMode ) - - if (fUnpackPar->IsChannelRateEnabled()) { - for (UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; uGdpb++) { - const Int_t iNbBinsRate = 82; - Double_t dBinsRate[iNbBinsRate] = { 1e0, 2e0, 3e0, 4e0, 5e0, 6e0, 7e0, - 8e0, 9e0, 1e1, 2e1, 3e1, 4e1, 5e1, 6e1, 7e1, 8e1, 9e1, 1e2, 2e2, 3e2, - 4e2, 5e2, 6e2, 7e2, 8e2, 9e2, 1e3, 2e3, 3e3, 4e3, 5e3, 6e3, 7e3, 8e3, - 9e3, 1e4, 2e4, 3e4, 4e4, 5e4, 6e4, 7e4, 8e4, 9e4, 1e5, 2e5, 3e5, 4e5, - 5e5, 6e5, 7e5, 8e5, 9e5, 1e6, 2e6, 3e6, 4e6, 5e6, 6e6, 7e6, 8e6, 9e6, - 1e7, 2e7, 3e7, 4e7, 5e7, 6e7, 7e7, 8e7, 9e7, 1e8, 2e8, 3e8, 4e8, 5e8, - 6e8, 7e8, 8e8, 9e8, 1e9 }; - name = Form("ChannelRate_gDPB_%02u_0", uGdpb); - title = Form("Channel instant rate gDPB %02u; Dist[ns] ; Channel", uGdpb); - fHM->Add(name.Data(), - new TH2F( name.Data(), title.Data(), iNbBinsRate - 1, dBinsRate, - uNbFeetPlot*fNrOfChannelsPerFeet, 0, uNbFeetPlot*fNrOfChannelsPerFeet)); - if (server) - server->Register("/TofRaw", fHM->H2(name.Data())); - if( uNbFeetPlot < fNrOfFebsPerGdpb ) - { - name = Form("ChannelRate_gDPB_%02u_1", uGdpb); - title = Form("Channel instant rate gDPB %02u; Dist[ns] ; Channel", uGdpb); - fHM->Add(name.Data(), - new TH2F( name.Data(), title.Data(), iNbBinsRate - 1, dBinsRate, - uNbFeetPlot*fNrOfChannelsPerFeet, - uNbFeetPlot*fNrOfChannelsPerFeet, - 2*uNbFeetPlot*fNrOfChannelsPerFeet)); - if (server) - server->Register("/TofRaw", fHM->H2(name.Data())); - } // if( uNbFeetPlot < fNrOfFebsPerGdpb ) - if( 2 * uNbFeetPlot < fNrOfFebsPerGdpb ) - { - name = Form("ChannelRate_gDPB_%02u_2", uGdpb); - title = Form("Channel instant rate gDPB %02u; Dist[ns] ; Channel", uGdpb); - fHM->Add(name.Data(), - new TH2F( name.Data(), title.Data(), iNbBinsRate - 1, dBinsRate, - uNbFeetPlot*fNrOfChannelsPerFeet, - 2*uNbFeetPlot*fNrOfChannelsPerFeet, - 3*uNbFeetPlot*fNrOfChannelsPerFeet)); - if (server) - server->Register("/TofRaw", fHM->H2(name.Data())); - } // if( 2 * uNbFeetPlot < fNrOfFebsPerGdpb ) - - LOG(info) << "Adding the rate histos"; - } // for( UInt_t uGdpb = 0; uGdpb < fuMinNbGdpb; uGdpb ++) - } - - if( fbPulserMode ) - { - // Full Fee time difference test - UInt_t uNbBinsDt = kuNbBinsDt + 1; // To account for extra bin due to shift by 1/2 bin of both ranges - for( UInt_t uChanFeeA = 0; uChanFeeA < fNrOfChannelsPerFeet; uChanFeeA++) - { - for( UInt_t uChanFeeB = uChanFeeA + 1; uChanFeeB < fNrOfChannelsPerFeet; uChanFeeB++) - { - fhTimeDiffPulserChosenFee.push_back( - new TH1I( - Form("hTimeDiffPulserChosenFee_%03u_%03u", uChanFeeA, uChanFeeB), - Form("Time difference for channels %03u and %03u in chosen Fee; DeltaT [ps]; Counts", - uChanFeeA, uChanFeeB), - uNbBinsDt, dMinDt, dMaxDt) ); - } // for any unique pair of channel in chosen Fee - } // for( UInt_t uChanFeeA = 0; uChanFeeA < kuNbChanFee; uChanFeeA++) - - // Selected channels test - fhTimeDiffPulserChosenChPairs.resize( kuNbChanTest - 1 ); - for( UInt_t uChan = 0; uChan < kuNbChanTest - 1; uChan++) - { - fhTimeDiffPulserChosenChPairs[uChan] = new TH1I( - Form("hTimeDiffPulserChosenChPairs_%03u_%03u", fuPulserChan[uChan], fuPulserChan[uChan+1]), - Form("Time difference for selected channels %03u and %03u in the first gDPB; DeltaT [ps]; Counts", - fuPulserChan[uChan], fuPulserChan[uChan+1]), - uNbBinsDt, dMinDt, dMaxDt); - if (server) - server->Register("/TofRaw", fhTimeDiffPulserChosenChPairs[uChan] ); - } // for( UInt_t uChan = 0; uChan < kuNbChanTest - 1; uChan++) - - name = "hTimeRmsPulserChosenFee"; - fhTimeRmsPulserChosenFee = new TH2D( name.Data(), - "Time difference RMS for any channels pair in chosen Fee; Ch A; Ch B; RMS [ps]", - fNrOfChannelsPerFeet - 1, -0.5, fNrOfChannelsPerFeet - 1.5, - fNrOfChannelsPerFeet - 1, 0.5, fNrOfChannelsPerFeet - 0.5); - fHM->Add( name.Data(), fhTimeRmsPulserChosenFee); - if (server) - server->Register("/TofRaw", fHM->H2( name.Data() ) ); - - name = "hTimeRmsPulserChosenChPairs"; - fhTimeRmsPulserChosenChPairs = new TH1D( name.Data(), - "Time difference RMS for chosen channels pairs; Pair # ; [ps]", - kuNbChanTest - 1, -0.5, kuNbChanTest - 1.5); - fHM->Add( name.Data(), fhTimeRmsPulserChosenChPairs); - if (server) - server->Register("/TofRaw", fHM->H1( name.Data() ) ); - } // if( fbPulserMode ) - - if( fbGet4M24b ) - { - fviFtLastRise24b.resize( fNrOfGdpbs * fNrOfFebsPerGdpb ); - fviFtLastFall24b.resize( fNrOfGdpbs * fNrOfFebsPerGdpb ); - fvdTimeLastRise24b.resize( fNrOfGdpbs * fNrOfFebsPerGdpb ); - fvdTimeLastFall24b.resize( fNrOfGdpbs * fNrOfFebsPerGdpb ); - } // if( fbGet4M24b ) - - for (UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; uGdpb++) { - name = Form("Raw_Tot_gDPB_%02u_0", uGdpb); - title = Form("Raw TOT gDPB %02u; channel; TOT [bin]", uGdpb); - fHM->Add(name.Data(), - new TH2F(name.Data(), title.Data(), - uNbFeetPlot*fNrOfChannelsPerFeet, 0, uNbFeetPlot*fNrOfChannelsPerFeet, - 256, 0, 256)); - if (server) - server->Register("/TofRaw", fHM->H2(name.Data())); - if( uNbFeetPlot < fNrOfFebsPerGdpb ) - { - name = Form("Raw_Tot_gDPB_%02u_1", uGdpb); - title = Form("Raw TOT gDPB %02u RPC 1; channel; TOT [bin]", uGdpb); - fHM->Add(name.Data(), - new TH2F(name.Data(), title.Data(), - uNbFeetPlot*fNrOfChannelsPerFeet, - uNbFeetPlot*fNrOfChannelsPerFeet, - 2*uNbFeetPlot*fNrOfChannelsPerFeet, - 256, 0, 256)); - if (server) - server->Register("/TofRaw", fHM->H2(name.Data())); - } // if( uNbFeetPlot < fNrOfFebsPerGdpb ) - if( 2 * uNbFeetPlot < fNrOfFebsPerGdpb ) - { - name = Form("Raw_Tot_gDPB_%02u_2", uGdpb); - title = Form("Raw TOT gDPB %02u RPC 2; channel; TOT [bin]", uGdpb); - fHM->Add(name.Data(), - new TH2F(name.Data(), title.Data(), - uNbFeetPlot*fNrOfChannelsPerFeet, - 2*uNbFeetPlot*fNrOfChannelsPerFeet, - 3*uNbFeetPlot*fNrOfChannelsPerFeet, - 256, 0, 256)); - if (server) - server->Register("/TofRaw", fHM->H2(name.Data())); - } // if( 2 * uNbFeetPlot < fNrOfFebsPerGdpb ) - - name = Form("ChCount_gDPB_%02u", uGdpb); - title = Form("Channel counts gDPB %02u; channel; Hits", uGdpb); - fHM->Add(name.Data(), new TH1I(name.Data(), title.Data(), - fNrOfFebsPerGdpb*fNrOfChannelsPerFeet, 0, fNrOfFebsPerGdpb*fNrOfChannelsPerFeet)); - - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - - for (UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; uFeet++) { - name = Form("FeetRate_gDPB_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "Counts per second in Feet %1u of gDPB %02u; Time[s] ; Counts", uFeet, - uGdpb); - fHM->Add(name.Data(), new TH1F(name.Data(), title.Data(), 1800, 0, 1800)); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - - name = Form("FeetErrorRate_gDPB_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "Error Counts per second in Feet %1u of gDPB %02u; Time[s] ; Error Counts", uFeet, - uGdpb); - fHM->Add(name.Data(), new TH1F(name.Data(), title.Data(), 1800, 0, 1800)); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - /// Long duration rate plots: 1 minute binning, 5 days range - name = Form("FeetRateLong_gDPB_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "Counts per minute in Feet %1u of gDPB %02u; Time[min] ; Counts", uFeet, - uGdpb); - fHM->Add(name.Data(), new TH1F(name.Data(), title.Data(), 5*24*60, 0, 5*24*60)); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - - name = Form("FeetErrorRateLong_gDPB_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "Error Counts per minute in Feet %1u of gDPB %02u; Time[min] ; Error Counts", uFeet, - uGdpb); - fHM->Add(name.Data(), new TH1F(name.Data(), title.Data(), 5*24*60, 0, 5*24*60)); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - - if( 0 < fiBinSizeDatePlots && 0 < fiRunStartDateTimeSec ) { - name = Form("FeetRateDate_gDPB_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "Counts per second in Feet %1u of gDPB %02u; Time[s] ; Counts", uFeet, - uGdpb); - fHM->Add(name.Data(), new TH1F(name.Data(), title.Data(), (5400 / fiBinSizeDatePlots), -10, 5400 - 10)); - ( fHM->H1(name.Data()) )->GetXaxis()->SetTimeDisplay(1); - ( fHM->H1(name.Data()) )->GetXaxis()->SetTimeOffset( fiRunStartDateTimeSec ); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - } // if( 0 < fiBinSizeDatePlots && 0 < fiRunStartDateTimeSec ) - - name = Form("FtDistribPerCh_gDPB_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "FT distribution per channel in Feet %1u of gDPB %02u; Channel [] ; FT [bin]; Counts []", uFeet, - uGdpb); - fHM->Add(name.Data(), new TH2I( name.Data(), title.Data(), - fNrOfChannelsPerFeet, 0, fNrOfChannelsPerFeet, - get4v1x::kuFineCounterSize, 0, get4v1x::kuFineCounterSize)); - if (server) - server->Register("/TofRaw", fHM->H2(name.Data())); - - if( fbGet4M24b ) - { - name = Form("ChCountFall_gDPB_%02u", uGdpb); - title = Form("Channel falling edge counts gDPB %02u; channel; Hits", uGdpb); - fHM->Add(name.Data(), new TH1I(name.Data(), title.Data(), - fNrOfFebsPerGdpb*fNrOfChannelsPerFeet, 0, fNrOfFebsPerGdpb*fNrOfChannelsPerFeet)); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - - name = Form("FtDistribPerChFall_gDPB_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "FT distribution per channel, falling edge, in Feet %1u of gDPB %02u; Channel [] ; FT Fall [bin]; Counts []", uFeet, - uGdpb); - fHM->Add(name.Data(), new TH2I( name.Data(), title.Data(), - fNrOfChannelsPerFeet, 0, fNrOfChannelsPerFeet, - get4v1x::kuFineCounterSize, 0, get4v1x::kuFineCounterSize)); - if (server) - server->Register("/TofRaw", fHM->H2(name.Data())); - - fviFtLastRise24b[ uGdpb * fNrOfFebsPerGdpb + uFeet ].resize( fNrOfChannelsPerFeet, -1 ); - fviFtLastFall24b[ uGdpb * fNrOfFebsPerGdpb + uFeet ].resize( fNrOfChannelsPerFeet, -1 ); - fvdTimeLastRise24b[ uGdpb * fNrOfFebsPerGdpb + uFeet ].resize( fNrOfChannelsPerFeet, -1 ); - fvdTimeLastFall24b[ uGdpb * fNrOfFebsPerGdpb + uFeet ].resize( fNrOfChannelsPerFeet, -1 ); - - name = Form("FtLastRiseCurrFall_gDPB_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "FT distribution last rising vs falling edge, in Feet %1u of gDPB %02u; FT last Rise [bin] ; FT Fall [bin]; Counts []", uFeet, - uGdpb); - fHM->Add(name.Data(), new TH2I( name.Data(), title.Data(), - get4v1x::kuFineCounterSize, 0, get4v1x::kuFineCounterSize, - get4v1x::kuFineCounterSize, 0, get4v1x::kuFineCounterSize)); - if (server) - server->Register("/TofRaw", fHM->H2(name.Data())); - - name = Form("FtCurrRiseLastFall_gDPB_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "FT distribution rising vs last falling edge, in Feet %1u of gDPB %02u; FT Rise [bin] ; FT last Fall [bin]; Counts []", uFeet, - uGdpb); - fHM->Add(name.Data(), new TH2I( name.Data(), title.Data(), - get4v1x::kuFineCounterSize, 0, get4v1x::kuFineCounterSize, - get4v1x::kuFineCounterSize, 0, get4v1x::kuFineCounterSize)); - if (server) - server->Register("/TofRaw", fHM->H2(name.Data())); - - name = Form("FtLastRiseDistRise_gDPB_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "Time between rising edges vs rising edge FT, in Feet %1u of gDPB %02u; FT last Rise [] ; Trise - TriseLast[ns]; Counts []", uFeet, - uGdpb); - fHM->Add(name.Data(), new TH2I( name.Data(), title.Data(), - get4v1x::kuFineCounterSize, 0, get4v1x::kuFineCounterSize, - 500, 0.0, 25.0 )); - if (server) - server->Register("/TofRaw", fHM->H2(name.Data())); - - name = Form("FtLastRiseDistFall_gDPB_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "Time between falling edges vs rising edge FT, in Feet %1u of gDPB %02u; FT last Rise [] ; Tfall - TfallLast[ns]; Counts []", uFeet, - uGdpb); - fHM->Add(name.Data(), new TH2I( name.Data(), title.Data(), - get4v1x::kuFineCounterSize, 0, get4v1x::kuFineCounterSize, - 500, 0.0, 25.0 )); - if (server) - server->Register("/TofRaw", fHM->H2(name.Data())); - - } // if( fbGet4M24b ) - } // for( UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; uFeet ++) - } // for( UInt_t uGdpb = 0; uGdpb < fuMinNbGdpb; uGdpb ++) - - ///* ASIC coincidences & offsets mapping */// - if( fbEnableCoincMap ) - { - fvulHitEpochBuffLastTs.resize(fNrOfGet4); //! Dims: [gDPB][hits] - for( UInt_t uAsicA = 0; uAsicA < fNrOfGet4 - 1; uAsicA ++ ) - { - name = Form("fvhCoincOffsetEpochGet4__g%03u", uAsicA); - title = Form( - "Distance in epoch between hits in Get4 %03u and hits in another Get4 ASIC in same TS; GET4 B index [] ; Hit B - Hit A [Epoch]; Counts []", - uAsicA ); - TH2* ph2 = new TH2I( name.Data(), title.Data(), - fNrOfGet4 - uAsicA - 1, uAsicA + 1, fNrOfGet4, - 20000, -10000, 10000 - ); - fvhCoincOffsetEpochGet4.push_back( ph2 ); - - fHM->Add( name.Data(), ph2 ); - if (server) - server->Register("/TofCoinc", fHM->H2(name.Data())); - } // for( UInt_t uAsicA = 0; uAsicA < fNrOfGet4 - 1; uAsicA ++ ) - } // if( fbEnableCoincMap ) - - name = "hSpill"; - title = "Counts per channel in Current Spill; X [Strip]; Y [End]; Counts"; - TH2I* hSpill = new TH2I(name, title, fNrOfChannelsPerFeet, 0., fNrOfChannelsPerFeet, 2, 0., 2.); - fHM->Add(name.Data(), hSpill); - if (server) - server->Register("/TofRaw", fHM->H2(name.Data())); - - name = "hSpillLength"; - title = "Length of spill interval as found from detectors; Length [s]; Counts"; - TH1* hSpillLength = new TH1F(name, title, 3000, 0., 300.); - fHM->Add(name.Data(), hSpillLength); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - - name = "hSpillCount"; - title = "Total counts in detector in each spill; Spill; Counts"; - TH1* hSpillCount = new TH1F(name, title, 300, 0., 300.); - fHM->Add(name.Data(), hSpillCount); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - - name = "hSpillQA"; - title = "Total counts in detector per spill VS Spill length; Length [s]; Counts"; - TH2* hSpillQA = new TH2F(name, title, 120, 0., 120., 150, 0., 150000.); - fHM->Add(name.Data(), hSpillQA); - if (server) - server->Register("/TofRaw", fHM->H2(name.Data())); - - name = "hTokenMsgType"; - title = "STAR trigger Messages type; Type ; Counts"; - fhTokenMsgType = new TH1F(name, title, 4, 0, 4); - fhTokenMsgType->GetXaxis()->SetBinLabel( 1, "A"); // gDPB TS high - fhTokenMsgType->GetXaxis()->SetBinLabel( 2, "B"); // gDPB TS low, STAR TS high - fhTokenMsgType->GetXaxis()->SetBinLabel( 3, "C"); // STAR TS mid - fhTokenMsgType->GetXaxis()->SetBinLabel( 4, "D"); // STAR TS low, token, CMDs - fHM->Add(name.Data(), fhTokenMsgType); - if (server) - server->Register("/StarRaw", fHM->H1(name.Data())); - - name = "hTriggerRate"; - title = "STAR trigger signals per second; Time[s] ; Counts"; - fhTriggerRate = new TH1F(name, title, 1800, 0, 1800); - fHM->Add(name.Data(), fhTriggerRate); - if (server) - server->Register("/StarRaw", fHM->H1(name.Data())); - - name = "hCmdDaqVsTrig"; - title = "STAR daq command VS STAR trigger command; DAQ ; TRIGGER"; - fhCmdDaqVsTrig = new TH2I(name, title, 16, 0, 16, 16, 0, 16 ); - fhCmdDaqVsTrig->GetXaxis()->SetBinLabel( 1, "0x0: no-trig "); // idle link - fhCmdDaqVsTrig->GetXaxis()->SetBinLabel( 2, "0x1: clear "); // clears redundancy counters on the readout boards - fhCmdDaqVsTrig->GetXaxis()->SetBinLabel( 3, "0x2: mast-rst"); // general reset of the whole front-end logic - fhCmdDaqVsTrig->GetXaxis()->SetBinLabel( 4, "0x3: spare "); // reserved - fhCmdDaqVsTrig->GetXaxis()->SetBinLabel( 5, "0x4: trigg. 0"); // Default physics readout, all det support required - fhCmdDaqVsTrig->GetXaxis()->SetBinLabel( 6, "0x5: trigg. 1"); // - fhCmdDaqVsTrig->GetXaxis()->SetBinLabel( 7, "0x6: trigg. 2"); // - fhCmdDaqVsTrig->GetXaxis()->SetBinLabel( 8, "0x7: trigg. 3"); // - fhCmdDaqVsTrig->GetXaxis()->SetBinLabel( 9, "0x8: puls. 0"); // - fhCmdDaqVsTrig->GetXaxis()->SetBinLabel(10, "0x9: puls. 1"); // - fhCmdDaqVsTrig->GetXaxis()->SetBinLabel(11, "0xA: puls. 2"); // - fhCmdDaqVsTrig->GetXaxis()->SetBinLabel(12, "0xB: puls. 3"); // - fhCmdDaqVsTrig->GetXaxis()->SetBinLabel(13, "0xC: config "); // housekeeping trigger: return geographic info of FE - fhCmdDaqVsTrig->GetXaxis()->SetBinLabel(14, "0xD: abort "); // aborts and clears an active event - fhCmdDaqVsTrig->GetXaxis()->SetBinLabel(15, "0xE: L1accept"); // - fhCmdDaqVsTrig->GetXaxis()->SetBinLabel(16, "0xF: L2accept"); // - fhCmdDaqVsTrig->GetYaxis()->SetBinLabel( 1, "0x0: 0"); // To be filled at STAR - fhCmdDaqVsTrig->GetYaxis()->SetBinLabel( 2, "0x1: 1"); // To be filled at STAR - fhCmdDaqVsTrig->GetYaxis()->SetBinLabel( 3, "0x2: 2"); // To be filled at STAR - fhCmdDaqVsTrig->GetYaxis()->SetBinLabel( 4, "0x3: 3"); // To be filled at STAR - fhCmdDaqVsTrig->GetYaxis()->SetBinLabel( 5, "0x4: 4"); // To be filled at STAR - fhCmdDaqVsTrig->GetYaxis()->SetBinLabel( 6, "0x5: 5"); // To be filled at STAR - fhCmdDaqVsTrig->GetYaxis()->SetBinLabel( 7, "0x6: 6"); // To be filled at STAR - fhCmdDaqVsTrig->GetYaxis()->SetBinLabel( 8, "0x7: 7"); // To be filled at STAR - fhCmdDaqVsTrig->GetYaxis()->SetBinLabel( 9, "0x8: 8"); // To be filled at STAR - fhCmdDaqVsTrig->GetYaxis()->SetBinLabel(10, "0x9: 9"); // To be filled at STAR - fhCmdDaqVsTrig->GetYaxis()->SetBinLabel(11, "0xA: 10"); // To be filled at STAR - fhCmdDaqVsTrig->GetYaxis()->SetBinLabel(12, "0xB: 11"); // To be filled at STAR - fhCmdDaqVsTrig->GetYaxis()->SetBinLabel(13, "0xC: 12"); // To be filled at STAR - fhCmdDaqVsTrig->GetYaxis()->SetBinLabel(14, "0xD: 13"); // To be filled at STAR - fhCmdDaqVsTrig->GetYaxis()->SetBinLabel(15, "0xE: 14"); // To be filled at STAR - fhCmdDaqVsTrig->GetYaxis()->SetBinLabel(16, "0xF: 15"); // To be filled at STAR - fHM->Add(name.Data(), fhCmdDaqVsTrig); - if (server) - server->Register("/StarRaw", fHM->H2(name.Data())); - - name = "hStarTokenEvo"; - title = "STAR token value VS time; Time in Run [s] ; STAR Token; Counts"; - fhStarTokenEvo = new TH2I(name, title, 1800, 0, 1800, 410, 0, 4100 ); // 4096 - fHM->Add(name.Data(), fhStarTokenEvo); - if (server) - server->Register("/StarRaw", fHM->H2(name.Data())); - - if (server) - server->RegisterCommand("/Reset_All_TOF", "bResetTofLabHistos=kTRUE"); - if (server) - server->RegisterCommand("/Cycle_Pulser_FEE", "bTofLabCyclePulserFee=kTRUE"); - if (server) - server->Restrict("/Reset_All_TOF", "allow=admin"); - - LOG(info) << "Done with histo creation, now doing canvases"; - - /** Create summary Canvases for STAR 2017 **/ - Double_t w = 10; - Double_t h = 10; - TCanvas* cSummary = new TCanvas("cSummary", "gDPB Monitoring Summary", w, h); - cSummary->Divide(2, 3); - - // 1st Column: Messages types - cSummary->cd(1); - gPad->SetLogy(); - hMessageType->Draw(); - - cSummary->cd(2); - gPad->SetLogy(); - hSysMessType->Draw(); - - cSummary->cd(3); - gPad->SetLogz(); - hGet4MessType->Draw("colz"); - - // 2nd Column: GET4 Errors + Epoch flags + - cSummary->cd(4); - gPad->SetLogz(); - hGet4ChanErrors->Draw("colz"); - - cSummary->cd(5); - gPad->SetLogz(); - hGet4EpochFlags->Draw("colz"); - - cSummary->cd(6); - hSpill->Draw("col text"); - /*****************************/ - - - /** Create FEET rates Canvas for STAR 2017 **/ - TCanvas* cFeeRates = new TCanvas("cFeeRates", "gDPB Monitoring FEET rates", w, h); - cFeeRates->Divide(fNrOfFebsPerGdpb, fNrOfGdpbs ); - - TH1* histPnt = NULL; - for( UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; ++uGdpb ) { - for (UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; ++uFeet ) { - name = Form("FeetRate_gDPB_g%02u_f%1u", uGdpb, uFeet); - histPnt = fHM->H1(name.Data()); - - cFeeRates->cd( 1 + uGdpb * fNrOfFebsPerGdpb + uFeet ); - gPad->SetLogy(); - - histPnt->Draw(); - - name = Form("FeetErrorRate_gDPB_g%02u_f%1u", uGdpb, uFeet); - histPnt = fHM->H1(name.Data()); - histPnt->SetLineColor( kRed ); - histPnt->Draw("same"); - } // for (UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; ++uFeet ) - } // for( UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; ++uGdpb ) - /*****************************/ - - /** Create FEET rates long duration Canvas for STAR 2017 **/ - TCanvas* cFeeRatesLong = new TCanvas("cFeeRatesLong", "gDPB Monitoring FEET rates", w, h); - cFeeRatesLong->Divide(fNrOfFebsPerGdpb, fNrOfGdpbs ); - THStack * stackLong[fNrOfGdpbs][fNrOfFebsPerGdpb]; - for( UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; ++uGdpb ) { - for (UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; ++uFeet ) { - stackLong[uGdpb][uFeet] = new THStack( - Form("hsRateLong_g%02u_f%1u", uGdpb, uFeet), - Form("Rate of hits and errors (red), long duration, for g%02u f%1u", uGdpb, uFeet) ); - - name = Form("FeetRateLong_gDPB_g%02u_f%1u", uGdpb, uFeet); - histPnt = fHM->H1(name.Data()); - - cFeeRatesLong->cd( 1 + uGdpb * fNrOfFebsPerGdpb + uFeet ); - gPad->SetLogy(); - - stackLong[uGdpb][uFeet]->Add(histPnt); - histPnt->Draw(); - - name = Form("FeetErrorRateLong_gDPB_g%02u_f%1u", uGdpb, uFeet); - histPnt = fHM->H1(name.Data()); - histPnt->SetLineColor( kRed ); - histPnt->Draw("same"); - stackLong[uGdpb][uFeet]->Add(histPnt); -// stackLong[uGdpb][uFeet]->Draw("nostack"); - - if (server) - server->Register("/TofStacks", stackLong[uGdpb][uFeet]); - } // for (UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; ++uFeet ) - } // for( UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; ++uGdpb ) - /*****************************/ - - /** Create TOT Canvas(es) for STAR 2017 **/ - TCanvas* cTotPnt = NULL; - for( UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; ++uGdpb ) { - - cTotPnt = new TCanvas( Form("cTotPnt_g%02u", uGdpb), - Form("gDPB %02u TOT distributions", uGdpb), - w, h); - cTotPnt->Divide( fNrOfFebsPerGdpb/uNbFeetPlot ); - TH2* histPntTot = NULL; - for (UInt_t uFeetPlot = 0; uFeetPlot < fNrOfFebsPerGdpb/uNbFeetPlot; ++uFeetPlot ) { - name = Form("Raw_Tot_gDPB_%02u_%1u", uGdpb, uFeetPlot); - histPntTot = fHM->H2(name.Data()); - - cTotPnt->cd( 1 + uFeetPlot ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - - histPntTot->Draw( "colz" ); - } // for (UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; ++uFeet ) - } // for( UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; ++uGdpb ) - /*****************************/ - - /** Create FT Canvas(es) for STAR 2017 **/ - TCanvas* cFtPnt = NULL; - for( UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; ++uGdpb ) { - - cFtPnt = new TCanvas( Form("cFtPnt_g%02u", uGdpb), - Form("gDPB %02u FineTime distributions", uGdpb), - w, h); - cFtPnt->Divide( fNrOfFebsPerGdpb ); - TH2* histPntFt = NULL; - for( UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; uFeet ++) { - name = Form("FtDistribPerCh_gDPB_g%02u_f%1u", uGdpb, uFeet); - histPntFt = fHM->H2(name.Data()); - - cFtPnt->cd( 1 + uFeet ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - - histPntFt->Draw( "colz" ); - } // for (UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; ++uFeet ) - } // for( UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; ++uGdpb ) - /*****************************/ - - - /** Create 24b mode Canvas(es) for STAR 2017 **/ - if( fbGet4M24b ) - { - TCanvas* cFt24b = NULL; - for( UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; ++uGdpb ) { - - cFt24b = new TCanvas( Form("cFt24b_g%02u", uGdpb), - Form("gDPB %02u 24b mode FineTime distributions", uGdpb), - w, h); - cFt24b->Divide( 2, 2 ); - TH2* histPntFt = NULL; - - cFt24b->cd( 1 ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - name = Form("FtDistribPerCh_gDPB_g%02u_f%1u", uGdpb, 0); - histPntFt = fHM->H2(name.Data()); - histPntFt->Draw( "colz" ); - - cFt24b->cd( 2 ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - name = Form("FtDistribPerChFall_gDPB_g%02u_f%1u", uGdpb, 0); - histPntFt = fHM->H2(name.Data()); - histPntFt->Draw( "colz" ); - - cFt24b->cd( 3 ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - name = Form("ChCount_gDPB_%02u", uGdpb); - fHM->H1(name.Data())->Draw(); - - cFt24b->cd( 4 ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - name = Form("ChCountFall_gDPB_%02u", uGdpb); - fHM->H1(name.Data())->Draw(); - } // for( UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; ++uGdpb ) - } // if( fbGet4M24b ) - /*****************************/ - - /** Create Pulser mode Canvas for STAR 2017 **/ - if( fbPulserMode ) - { - TCanvas* cPulserRms = new TCanvas("cPulserRms", "Time difference RMS for chosen FEE and channels in pulser mode", w, h); - cPulserRms->Divide( 2 ); - - cPulserRms->cd(1); - fhTimeRmsPulserChosenFee->Draw( "colz" ); - - cPulserRms->cd(2); - fhTimeRmsPulserChosenChPairs->Draw( "colz" ); - } // if( fbPulserMode ) - /*****************************/ - - /** Create STAR token Canvas for STAR 2017 **/ - TCanvas* cStarToken = new TCanvas("cStarToken", "STAR token detection info", w, h); - cStarToken->Divide( 2, 2 ); - - cStarToken->cd(1); - fhTriggerRate->Draw(); - - cStarToken->cd(2); - fhCmdDaqVsTrig->Draw( "colz" ); - - cStarToken->cd(3); - fhStarTokenEvo->Draw(); - /*****************************/ - - /** Recovers/Create Ms Size Canvas for STAR 2017 **/ - // Try to recover canvas in case it was created already by another monitor - // If not existing, create it - fcMsSizeAll = dynamic_cast<TCanvas *>( gROOT->FindObject( "cMsSizeAll" ) ); - if( NULL == fcMsSizeAll ) - { - fcMsSizeAll = new TCanvas("cMsSizeAll", "Evolution of MS size in last 300 s", w, h); - fcMsSizeAll->Divide( 4, 4 ); - LOG(info) << "Created MS size canvas in TOF monitor"; - } // if( NULL == fcMsSizeAll ) - else LOG(info) << "Recovered MS size canvas in TOF monitor"; - /*****************************/ - - LOG(info) << "Done with canvases creation"; - - /** Store pointers to histograms for STAR 2017 **/ - fHistMessType = fHM->H1("hMessageType"); - fHistSysMessType = fHM->H1("hSysMessType"); - fHistGet4MessType = fHM->H2("hGet4MessType"); - fHistGet4ChanErrors = fHM->H2("hGet4ChanErrors"); - fHistGet4EpochFlags = fHM->H2("hGet4EpochFlags"); - fHistSpill = fHM->H2("hSpill"); - fHistSpillLength = fHM->H1("hSpillLength"); - fHistSpillCount = fHM->H1("hSpillCount"); - fHistSpillQA = fHM->H2("hSpillQA"); - - for (UInt_t i = 0; i < fNrOfGdpbs; ++i) { - name = Form("Raw_Tot_gDPB_%02u_0", i); - fRaw_Tot_gDPB.push_back(fHM->H2(name.Data())); - if( uNbFeetPlot < fNrOfFebsPerGdpb ) - { - name = Form("Raw_Tot_gDPB_%02u_1", i); - fRaw_Tot_gDPB.push_back(fHM->H2(name.Data())); - } // if( uNbFeetPlot < fNrOfFebsPerGdpb ) - if( 2 * uNbFeetPlot < fNrOfFebsPerGdpb ) - { - name = Form("Raw_Tot_gDPB_%02u_2", i); - fRaw_Tot_gDPB.push_back(fHM->H2(name.Data())); - } // if( 2 * uNbFeetPlot < fNrOfFebsPerGdpb ) - - name = Form("ChCount_gDPB_%02u", i); - fChCount_gDPB.push_back(fHM->H1(name.Data())); - - if (fUnpackPar->IsChannelRateEnabled()) { - name = Form("ChannelRate_gDPB_%02u_0", i); - fChannelRate_gDPB.push_back(fHM->H2(name.Data())); - if( uNbFeetPlot < fNrOfFebsPerGdpb ) - { - name = Form("ChannelRate_gDPB_%02u_1", i); - fChannelRate_gDPB.push_back(fHM->H2(name.Data())); - } // if( uNbFeetPlot < fNrOfFebsPerGdpb ) - if( 2 * uNbFeetPlot < fNrOfFebsPerGdpb ) - { - name = Form("ChannelRate_gDPB_%02u_2", i); - fChannelRate_gDPB.push_back(fHM->H2(name.Data())); - } // if( 2 * uNbFeetPlot < fNrOfFebsPerGdpb ) - } // if (fUnpackPar->IsChannelRateEnabled()) - - for (UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; uFeet++) { - name = Form("FeetRate_gDPB_g%02u_f%1u", i, uFeet); - fFeetRate_gDPB.push_back(fHM->H1(name.Data())); - name = Form("FeetErrorRate_gDPB_g%02u_f%1u", i, uFeet); - fFeetErrorRate_gDPB.push_back(fHM->H1(name.Data())); - name = Form("FeetRateLong_gDPB_g%02u_f%1u", i, uFeet); - fFeetRateLong_gDPB.push_back(fHM->H1(name.Data())); - name = Form("FeetErrorRateLong_gDPB_g%02u_f%1u", i, uFeet); - fFeetErrorRateLong_gDPB.push_back(fHM->H1(name.Data())); - if( 0 < fiBinSizeDatePlots && 0 < fiRunStartDateTimeSec ) { - name = Form("FeetRateDate_gDPB_g%02u_f%1u", i, uFeet); - fFeetRateDate_gDPB.push_back(fHM->H1(name.Data())); - } // if( 0 < fiBinSizeDatePlots && 0 < fiRunStartDateTimeSec ) - name = Form("FtDistribPerCh_gDPB_g%02u_f%1u", i, uFeet); - fhFtDistribPerCh.push_back(fHM->H2(name.Data())); - if( fbGet4M24b ) - { - name = Form("ChCountFall_gDPB_%02u", i); - fChCountFall_gDPB.push_back(fHM->H1(name.Data())); - name = Form("FtDistribPerChFall_gDPB_g%02u_f%1u", i, uFeet); - fhFtDistribPerChFall.push_back(fHM->H2(name.Data())); - - name = Form("FtLastRiseCurrFall_gDPB_g%02u_f%1u", i, uFeet); - fhFtLastRiseCurrFall.push_back(fHM->H2(name.Data())); - name = Form("FtCurrRiseLastFall_gDPB_g%02u_f%1u", i, uFeet); - fhFtCurrRiseLastFall.push_back(fHM->H2(name.Data())); - - name = Form("FtLastRiseDistRise_gDPB_g%02u_f%1u", i, uFeet); - fhFtLastRiseDistRise.push_back(fHM->H2(name.Data())); - name = Form("FtLastRiseDistFall_gDPB_g%02u_f%1u", i, uFeet); - fhFtLastRiseDistFall.push_back(fHM->H2(name.Data())); - } // if( fbGet4M24b ) - } // for( UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; uFeet ++) - } - /*****************************/ - - LOG(info) << "Leaving CreateHistograms"; -} - -Bool_t CbmTSMonitorTofLab::DoUnpack(const fles::Timeslice& ts, - size_t component) -{ - THttpServer* server = FairRunOnline::Instance()->GetHttpServer(); - - if (bResetTofLabHistos) { - ResetAllHistos(); - bResetTofLabHistos = kFALSE; - } - if (bTofLabCyclePulserFee) { - CyclePulserFee(); - bTofLabCyclePulserFee = kFALSE; - } - - ///* ASIC coincidences & offsets mapping */// - if( fbEnableCoincMap ) - { - if( 0 == component && fbHitsInLastTs ) - { - for( UInt_t uAsicA = 0; uAsicA < fNrOfGet4 - 1; uAsicA ++ ) - { - for( UInt_t uHitA = 0; uHitA < fvulHitEpochBuffLastTs[uAsicA].size(); uHitA ++ ) - { - for( UInt_t uAsicB = uAsicA; uAsicB < fNrOfGet4; uAsicB ++ ) - { - for( UInt_t uHitB = 0; uHitB < fvulHitEpochBuffLastTs[uAsicB].size(); uHitB ++ ) - { - fvhCoincOffsetEpochGet4[uAsicA]->Fill( uAsicB, - fvulHitEpochBuffLastTs[uAsicB][uHitB] - - fvulHitEpochBuffLastTs[uAsicA][uHitA] ); - } // for( UInt_t uHitB = 0; uHitB < fvulHitEpochBuffLastTs[uAsicB].size(); uHitB ++ ) - } // for( UInt_t uAsicA = 0; uAsicA < fNrOfGet4 - 1; uAsicA ++ ) - } // for( UInt_t uHitA = 0; uHitA < fvulHitEpochBuffLastTs[uAsicA].size(); uHitA ++ ) - fvulHitEpochBuffLastTs[uAsicA].clear(); - } // for( UInt_t uAsicA = 0; uAsicA < fNrOfGet4 - 1; uAsicA ++ ) - fvulHitEpochBuffLastTs[fNrOfGet4 - 1].clear(); - fbHitsInLastTs = kFALSE; - } // if( 0 == component && fbHitsInLastTs ) - } // if( fbEnableCoincMap ) - - // Periodic histo saving & Printout of nb events log - std::chrono::time_point<std::chrono::system_clock> timeCurrent = std::chrono::system_clock::now(); - std::chrono::duration<double> elapsed_seconds = timeCurrent - fTimeLastHistoSave; - if( 0 == fTimeLastHistoSave.time_since_epoch().count() ) - { - fTimeLastHistoSave = timeCurrent; - } // if( 0 == fTimeLastHistoSave.time_since_epoch().count() ) - else if( 300 < elapsed_seconds.count() ) - { - std::time_t cTimeCurrent = std::chrono::system_clock::to_time_t( timeCurrent ); - char tempBuff[80]; - std::strftime( tempBuff, 80, "%F %T", localtime (&cTimeCurrent) ); -// LOG(info) << "CbmTSMonitorTofLab::DoUnpack => " << tempBuff -// << " events in last " << std::setw(4) << elapsed_seconds.count() << " s"; - fTimeLastHistoSave = timeCurrent; - - SaveAllHistos( "data/histos_test.root" ); - } // else if( 300 < elapsed_seconds.count() ) - - LOG(debug1) << "Timeslice contains " << ts.num_microslices(component) - << "microslices."; - - // Getting the pointer to the correct histogram needs a lot more time then - // the actual filling procedure. If one gets the pointer in a loop this kills - // the performance. A test shows that extracting the pointer from the CbmHistManger - // is slower by a factor of 20-100 (depending on the number of histos managed by the - // CbmHistManager) compared to using the pointer directly - // So get the pointer once outside the loop and use it in the loop - - TString sMsSzName = Form("MsSz_link_%02lu", component); - TH1* hMsSz = NULL; - TProfile* hMsSzTime = NULL; - if (fHM->Exists(sMsSzName.Data())) { - hMsSz = fHM->H1(sMsSzName.Data()); - sMsSzName = Form("MsSzTime_link_%02lu", component); - hMsSzTime = fHM->P1(sMsSzName.Data()); - } // if( fHM->Exists(sMsSzName.Data() ) ) - else { - TString sMsSzTitle = Form( - "Size of MS for gDPB of link %02lu; Ms Size [bytes]", component); - fHM->Add(sMsSzName.Data(), - new TH1F(sMsSzName.Data(), sMsSzTitle.Data(), 160000, 0., 20000.)); - hMsSz = fHM->H1(sMsSzName.Data()); - if (server) - server->Register("/FlibRaw", hMsSz); - sMsSzName = Form("MsSzTime_link_%02lu", component); - sMsSzTitle = Form( - "Size of MS vs time for gDPB of link %02lu; Time[s] ; Ms Size [bytes]", - component); - fHM->Add(sMsSzName.Data(), - new TProfile(sMsSzName.Data(), sMsSzTitle.Data(), 180000, 0., 3600.)); - hMsSzTime = fHM->P1(sMsSzName.Data()); - if (server) - server->Register("/FlibRaw", hMsSzTime); - if( NULL != fcMsSizeAll ) - { - fcMsSizeAll->cd( 1 + component ); - gPad->SetLogy(); - hMsSzTime->Draw("hist le0"); - } // if( NULL != fcMsSizeAll ) - LOG(info) << "Added MS size histo for component: " << component << " (gDPB)"; - } // else of if( fHM->Exists(sMsSzName.Data() ) ) - - // Initialize spill detection - fiCountsLastTs = 0; - - Int_t messageType = -111; - Double_t dTsStartTime = -1; - // Loop over microslices - size_t numCompMsInTs = ts.num_microslices(component); - for (size_t m = 0; m < numCompMsInTs; ++m) { - if (fuMsAcceptsPercent < m) - continue; - - constexpr uint32_t kuBytesPerMessage = 8; - - auto msDescriptor = ts.descriptor(component, m); - fEquipmentId = msDescriptor.eq_id; - const uint8_t* msContent = reinterpret_cast<const uint8_t*>(ts.content( - component, m)); - - uint32_t size = msDescriptor.size; - fulLastMsIdx = msDescriptor.idx; - if (size > 0) - LOG(debug) << "Microslice: " << msDescriptor.idx << " has size: " << size; - - if( numCompMsInTs - fuOverlapMsNb <= m ) - { -// LOG(info) << "Ignore overlap Microslice: " << msDescriptor.idx; - continue; - } // if( numCompMsInTs - fuOverlapMsNb <= m ) - - if( 0 == m ) - dTsStartTime = (1e-9) * static_cast<double>(msDescriptor.idx); - - if( fdStartTimeMsSz < 0 ) - fdStartTimeMsSz = (1e-9) * static_cast<double>(msDescriptor.idx); - hMsSz->Fill(size); - hMsSzTime->Fill((1e-9) * static_cast<double>(msDescriptor.idx) - fdStartTimeMsSz, size); - - // If not integer number of message in input buffer, print warning/error - if (0 != (size % kuBytesPerMessage)) - LOG(error) << "The input microslice buffer does NOT " - << "contain only complete nDPB messages!"; - - // Compute the number of complete messages in the input microslice buffer - uint32_t uNbMessages = (size - (size % kuBytesPerMessage)) - / kuBytesPerMessage; - - // Prepare variables for the loop on contents - const uint64_t* pInBuff = reinterpret_cast<const uint64_t*>(msContent); - for (uint32_t uIdx = 0; uIdx < uNbMessages; uIdx++) { - // Fill message - uint64_t ulData = static_cast<uint64_t>(pInBuff[uIdx]); - ngdpb::Message mess(ulData); - - if (gLogger->IsLogNeeded( fair::Severity::debug2 )) - { - mess.printDataCout(); - } // if (gLogger->IsLogNeeded( fair::Severity::debug2 )) - - - // Increment counter for different message types - // and fill the corresponding histogram - messageType = mess.getMessageType(); - fMsgCounter[messageType]++; - fHistMessType->Fill(messageType); - - fGdpbId = mess.getRocNumber(); - fGdpbNr = fGdpbIdIndexMap[fGdpbId]; - - fGet4Id = mess.getGdpbGenChipId(); - fGet4Nr = (fGdpbNr * fNrOfGet4PerGdpb) + fGet4Id; - - switch (messageType) { - case ngdpb::MSG_HIT: - // FillHitInfo(mess); - LOG(error) << "Message type " << messageType - << " not yet included in unpacker."; - break; - case ngdpb::MSG_EPOCH: - // FillEpochInfo(mess); - LOG(error) << "Message type " << messageType - << " not yet included in unpacker."; - break; - case ngdpb::MSG_SYS: - fHistSysMessType->Fill(mess.getSysMesType()); - break; - case ngdpb::MSG_EPOCH2: - fHistGet4MessType->Fill(fGet4Nr, ngdpb::GET4_32B_EPOCH); - FillEpochInfo(mess); - break; - case ngdpb::MSG_GET4: - fHistGet4MessType->Fill(fGet4Nr, ngdpb::GET4_32B_DATA + 1); - if( fbGet4M24b ) - FillHitInfo(mess); - else PrintGenInfo(mess); - break; - case ngdpb::MSG_GET4_32B: - fHistGet4MessType->Fill(fGet4Nr, ngdpb::GET4_32B_DATA); - if( fbEpochSuppModeOn ) - fvmEpSupprBuffer[fGet4Nr].push_back( mess ); - else FillHitInfo(mess); - break; - case ngdpb::MSG_GET4_SLC: - fHistGet4MessType->Fill(fGet4Nr, ngdpb::GET4_32B_SLCM); - PrintSlcInfo(mess); - break; - case ngdpb::MSG_GET4_SYS: - { - fHistSysMessType->Fill(mess.getGdpbSysSubType()); - if (ngdpb::SYSMSG_GET4_EVENT == mess.getGdpbSysSubType()) - { - if( fbEpochSuppModeOn ) - fvmEpSupprBufferErrors[fGet4Nr].push_back( mess ); - else FillGet4ErrorInfo(mess); - } // if (ngdpb::SYSMSG_GET4_EVENT == mess.getGdpbSysSubType()) - - if (100 > iMess) - { - PrintSysInfo(mess); - iMess++; // Separate increment from condition, otherwise increase until wrap to -1664185233 - } // if (100 > iMess) - break; - } - case ngdpb::MSG_STAR_TRI: - fHistGet4MessType->Fill(fGet4Nr, ngdpb::MSG_STAR_TRI); - FillStarTrigInfo(mess); - break; - default: - if (100 > iMess) - { - LOG(error) << "Message (" << iMess << ") type " << std::hex - << std::setw(2) << static_cast<uint16_t>(messageType) - << " not yet included in Get4 unpacker."; - iMess++; // Separate increment from condition, otherwise increase until wrap to -1664185233 - } // if (100 > iMess++) - } // switch( mess.getMessageType() ) - } // for (uint32_t uIdx = 0; uIdx < uNbMessages; uIdx ++) - } // for (size_t m = 0; m < ts.num_microslices(component); ++m) - if (100 == iMess) - { - LOG(error) << "Stop reporting MSG errors... "; - iMess++; // Separate increment from condition, otherwise increase until wrap to -1664185233 - } // if (100 == iMess) - - // Spill detection using Detectors - if( !fbSpillOn && (fiSpillOnThr < fiCountsLastTs) ) - { - fbSpillOn = kTRUE; - fiTsUnderOff = 0; - - if( 0 < fdDetTimeLastTs ) - { - fHistSpillLength->Fill( fdDetLastTime - fdDetTimeLastTs ); - fHistSpillCount->Fill( fSpillIdx, fHistSpill->GetEntries() ); - fHistSpillQA->Fill( fdDetLastTime - fdDetTimeLastTs, - fHistSpill->GetEntries() ); - } // if( 0 < fdTimeLastTs ) - fdDetTimeLastTs = fdDetLastTime; - fSpillIdx++; - fHistSpill->Reset(); - } // if( !fbSpillOn && (fiSpillOnThr < fiCountsLastTs) ) - else if( fbSpillOn ) - { - if( fiCountsLastTs < fiSpillOffThr ) - { - fiTsUnderOff ++; - if( fiTsUnderOffThr < fiTsUnderOff ) - fbSpillOn = kFALSE; - } // if( fiCountsLastTs < fiSpillOffThr ) - else fiTsUnderOff = 0; - } // else if( fbSpillOn ) - - if( kTRUE == fbPulserMode ) - { - // Update RMS plots only every 10s in data - if( 10.0 < dTsStartTime - fdLastRmsUpdateTime ) - { - // Reset summary histograms for safety - fhTimeRmsPulserChosenFee->Reset(); - fhTimeRmsPulserChosenChPairs->Reset(); - - UInt_t uHistoFeeIdx = 0; - for( UInt_t uChanFeeA = 0; uChanFeeA < fNrOfChannelsPerFeet; uChanFeeA++) - { - for( UInt_t uChanFeeB = uChanFeeA + 1; uChanFeeB < fNrOfChannelsPerFeet; uChanFeeB++) - { - fhTimeRmsPulserChosenFee->Fill(uChanFeeA, uChanFeeB, fhTimeDiffPulserChosenFee[uHistoFeeIdx]->GetRMS() ); - uHistoFeeIdx++; - } // for( UInt_t uChanFeeB = uChanFeeA + 1; uChanFeeB < fNrOfChannelsPerFeet; uChanFeeB++) - } // for( UInt_t uChanFeeA = 0; uChanFeeA < fNrOfChannelsPerFeet; uChanFeeA++) - for( UInt_t uChan = 0; uChan < kuNbChanTest - 1; uChan++) - { - fhTimeRmsPulserChosenChPairs->Fill( uChan, fhTimeDiffPulserChosenChPairs[uChan]->GetRMS() ); - } // for( UInt_t uChan = 0; uChan < kuNbChanTest - 1; uChan++) - fdLastRmsUpdateTime = dTsStartTime; - } // if( 10.0 < dTsStartTime - fdLastRmsUpdateTime ) - } // if( kTRUE == fbPulserMode ) - - return kTRUE; -} - -void CbmTSMonitorTofLab::FillHitInfo(ngdpb::Message mess) -{ - Int_t channel = mess.getGdpbHitChanId(); - Int_t tot = mess.getGdpbHit32Tot(); - ULong_t hitTime = mess.getMsgFullTime(0); - - Long64_t curEpochGdpbGet4 = fCurrentEpoch[fGet4Nr]; - - if (curEpochGdpbGet4 != -111) { - UInt_t channelNr = fGet4Id * fNrOfChannelsPerGet4 + channel; - UInt_t uFeetNr = (fGet4Id / fNrOfGet4PerFeb); - - if( !fbGet4M24b ) - { - fRaw_Tot_gDPB[fGdpbNr + uFeetNr/uNbFeetPlot]->Fill(channelNr, tot); - fChCount_gDPB[fGdpbNr]->Fill(channelNr); - - /// Finetime monitoring - fhFtDistribPerCh[(fGdpbNr * fNrOfFebsPerGdpb) + uFeetNr]->Fill( - fGet4Id * fNrOfChannelsPerGet4 + channel, - mess.getGdpbHitFineTs() - ); - } // if( !fbGet4M24b ) - else - { -/* - fGet4Id = mess.getGet4Number(); - channel = mess.getGet4ChNum(); - UInt_t Fts = mess.getGet4FineTs(); - UInt_t edge = mess.getGet4Edge(); -*/ - Int_t Fts = mess.getGdpbHitFineTs(); - Int_t edge = mess.getGdpbHit24Edge(); - - channelNr = fGet4Id * fNrOfChannelsPerGet4 + channel; - uFeetNr = (fGet4Id / fNrOfGet4PerFeb); - Int_t iFullFebIdx = (fGdpbNr * fNrOfFebsPerGdpb) + uFeetNr; - - Double_t dHitTime = mess.getMsgFullTimeD(curEpochGdpbGet4); - - if( edge ) - { - fChCountFall_gDPB[fGdpbNr]->Fill(channelNr); - - - /// Finetime monitoring - fhFtDistribPerChFall[iFullFebIdx]->Fill( channelNr, Fts ); - if( 0 <= fviFtLastRise24b[iFullFebIdx][channelNr] && - fuRiseFallChSel == channelNr) - fhFtLastRiseCurrFall[iFullFebIdx]->Fill( - fviFtLastRise24b[iFullFebIdx][channelNr], - Fts); - if( 0 <= fviFtLastRise24b[iFullFebIdx][channelNr] && - 0 <= fvdTimeLastFall24b[iFullFebIdx][channelNr] && - fuRiseFallChSel == channelNr) - fhFtLastRiseDistFall[iFullFebIdx]->Fill( - fviFtLastRise24b[iFullFebIdx][channelNr], - dHitTime - fvdTimeLastFall24b[iFullFebIdx][channelNr]); - - fviFtLastFall24b[iFullFebIdx][channelNr] = Fts; - fvdTimeLastFall24b[iFullFebIdx][channelNr] = dHitTime; - } // if( edge ) - else - { - fChCount_gDPB[fGdpbNr]->Fill(channelNr); - - /// Finetime monitoring - fhFtDistribPerCh[iFullFebIdx]->Fill( channelNr, Fts ); - if( 0 <= fviFtLastFall24b[iFullFebIdx][channelNr] && - fuRiseFallChSel == channelNr) - fhFtCurrRiseLastFall[iFullFebIdx]->Fill( - Fts, - fviFtLastFall24b[iFullFebIdx][channelNr] ); - if( 0 <= fviFtLastRise24b[iFullFebIdx][channelNr] && - 0 <= fvdTimeLastRise24b[iFullFebIdx][channelNr] && - fuRiseFallChSel == channelNr) - fhFtLastRiseDistRise[iFullFebIdx]->Fill( - fviFtLastRise24b[iFullFebIdx][channelNr], - dHitTime - fvdTimeLastRise24b[iFullFebIdx][channelNr]); - - fviFtLastRise24b[iFullFebIdx][channelNr] = Fts; - fvdTimeLastRise24b[iFullFebIdx][channelNr] = dHitTime; - } // else of if( edge ) - } // else of if( !fbGet4M24b ) - - if (fUnpackPar->IsChannelRateEnabled()) { - // Check if at least one hit before in this channel - if( -1 < fTsLastHit[fGdpbNr][fGet4Id][channel] ) - { - fChannelRate_gDPB[fGdpbNr + uFeetNr/uNbFeetPlot]->Fill( - 1e9 / (mess.getMsgFullTimeD(curEpochGdpbGet4) - - fTsLastHit[fGdpbNr][fGet4Id][channel]), - fGet4Id * fNrOfChannelsPerGet4 + channel); - } // if( -1 < fTsLastHit[fGdpbNr][fGet4Id][channel] ) - } // if( fUnpackPar->IsChannelRateEnabled() ) - - // Save last hist time if channel rate histos or pulser mode enabled - if( fUnpackPar->IsChannelRateEnabled() || fbPulserMode ) - fTsLastHit[fGdpbNr][fGet4Id][channel] = mess.getMsgFullTimeD( - curEpochGdpbGet4); - - // In Run rate evolution - if (fdStartTime < 0) - fdStartTime = mess.getMsgFullTimeD(curEpochGdpbGet4); - - if (0 <= fdStartTime) - { - fFeetRate_gDPB[(fGdpbNr * fNrOfFebsPerGdpb) + uFeetNr]->Fill( - 1e-9 * (mess.getMsgFullTimeD(curEpochGdpbGet4) - fdStartTime)); -// fFeetRateLong_gDPB[(fGdpbNr * fNrOfFebsPerGdpb) + uFeetNr]->Fill( -// 1e-9 * (mess.getMsgFullTimeD(curEpochGdpbGet4) - fdStartTime) / 60 ); - - // General Time (date + time) rate evolution - // Add offset of -1H as the filenames were using some times offset by 1 hour (Summer time?!?) - if( 0 < fiBinSizeDatePlots && 0 < fiRunStartDateTimeSec ) { - fFeetRateDate_gDPB[(fGdpbNr * fNrOfFebsPerGdpb) + uFeetNr]->Fill( - 1e-9 * (mess.getMsgFullTimeD(curEpochGdpbGet4) - fdStartTime) ); - } // if( 0 < fiBinSizeDatePlots && 0 < fiRunStartDateTimeSec ) - } - fFeetRateLong_gDPB[(fGdpbNr * fNrOfFebsPerGdpb) + uFeetNr]->Fill( - 1e-9 * (mess.getMsgFullTimeD(curEpochGdpbGet4) ) / 60.0 - + static_cast< double >( fuCurrentEpochCycle[fGet4Nr] ) * get4v1x::kdEpochCycleInS / 60.0 ); - -/* - Int_t iChanInGdpb = fGet4Id * fNrOfChannelsPerGet4 + channel; - Int_t increment = static_cast<CbmFlibCern2016Source*>(FairRunOnline::Instance()->GetSource())->GetNofTSSinceLastTS(); - // if condition to find the right strip/end index - fHistSpill->Fill(0., 0., increment); -*/ - fiCountsLastTs ++; - fdDetLastTime = 1e-9 * mess.getMsgFullTimeD(curEpochGdpbGet4); - - hitTime = mess.getMsgFullTime(curEpochGdpbGet4); - Int_t Ft = mess.getGdpbHitFineTs(); - - if (100 > iMess) - { - LOG(debug) << "Hit: " << Form("0x%08x ", fGdpbId) << ", " << fGet4Id - << ", " << channel << ", " << tot << ", epoch " - << curEpochGdpbGet4 << ", FullTime " - << hitTime << ", FineTime " << Ft; - iMess++; // Separate increment from condition, otherwise increase until wrap to -1664185233 - } // if (100 > iMess) - - ///* ASIC coincidences & offsets mapping */// - if( fbEnableCoincMap ) - { - fbHitsInLastTs = kTRUE; - fvulHitEpochBuffLastTs[fGet4Nr].push_back( curEpochGdpbGet4 ); - } // if( fbEnableCoincMap ) - } // if( fCurrentEpoch[rocId].end() != fCurrentEpoch[rocId].find( get4Id ) ) - else - LOG(warning) << "Found hit in gdpbId w/o epoch yet: " - << Form("0x%08x g4 %02u", fGdpbId, fGet4Nr); -} - -void CbmTSMonitorTofLab::FillEpochInfo(ngdpb::Message mess) -{ - Long64_t epochNr = mess.getGdpbEpEpochNb(); - - if( fbEpochSuppModeOn ) - { - // If we are exactly on the epoch cycle border - // or if epoch counter made a loop in suppressed epochs (assume at least 1 hit in ~5h!) - if( ( 1 == epochNr && 1 <= fCurrentEpoch[fGet4Nr] ) || - ( epochNr + get4v1x::kuEpochCounterSz/2 < fCurrentEpoch[fGet4Nr] ) - ) - { - fuCurrentEpochCycle[fGet4Nr] ++; - LOG(info) << "Epoch cycle detected for gdpb " - << Form("0x%08x g4 %02u", fGdpbId, fGet4Nr) - << " : prev " << fCurrentEpoch[fGet4Nr] - << " new " << epochNr - << " cycle " << fuCurrentEpochCycle[fGet4Nr]; - } // if epoch cycle happened - - // In Ep. Suppr. Mode, receive following epoch instead of previous - if( 0 < epochNr ) - fCurrentEpoch[fGet4Nr] = epochNr - 1; - else fCurrentEpoch[fGet4Nr] = get4v1x::kuEpochCounterSz; // Catch end of epoch cycle! - } // if( fbEpochSuppModeOn ) - else - { - // If we are exactly on the epoch cycle border - if( 0 == epochNr && 0 < fCurrentEpoch[fGet4Nr] ) - fuCurrentEpochCycle[fGet4Nr] ++; - // if epoch counter made a loop in suppressed epochs (assume at least 1 hit in ~5h!) - else if( epochNr + get4v1x::kuEpochCounterSz/2 < fCurrentEpoch[fGet4Nr] ) - fuCurrentEpochCycle[fGet4Nr] ++; - - fCurrentEpoch[fGet4Nr] = epochNr; - } // else of if( fbEpochSuppModeOn ) - - - if (100 > iMess) - { - LOG(debug) << "Epoch message for get4 " << fGet4Nr << " with epoch number " - << fCurrentEpoch[fGet4Nr]; - iMess++; // Separate increment from condition, otherwise increase until wrap to -1664185233 - } // if (100 > iMess) - - if (1 == mess.getGdpbEpSync()) - fHistGet4EpochFlags->Fill(fGet4Nr, 0); - if (1 == mess.getGdpbEpDataLoss()) - fHistGet4EpochFlags->Fill(fGet4Nr, 1); - if (1 == mess.getGdpbEpEpochLoss()) - fHistGet4EpochFlags->Fill(fGet4Nr, 2); - if (1 == mess.getGdpbEpMissmatch()) - fHistGet4EpochFlags->Fill(fGet4Nr, 3); - - fCurrentEpochTime = mess.getMsgFullTime(epochNr); - fNofEpochs++; - - - if( fbEpochSuppModeOn ) - { - /// Re-align the epoch number of the message in case it will be used later: - /// We received the epoch after the data instead of the one before! - if( 0 < epochNr ) - mess.setEpoch2Number( epochNr - 1 ); - else mess.setEpoch2Number( get4v1x::kuEpochCounterSz ); - - - Int_t iBufferSize = fvmEpSupprBuffer[fGet4Nr].size(); - if( 0 < iBufferSize ) - { - LOG(debug) << "Now processing stored messages for for get4 " << fGet4Nr << " with epoch number " - << (fCurrentEpoch[fGet4Nr] - 1); - - for( Int_t iMsgIdx = 0; iMsgIdx < iBufferSize; iMsgIdx++ ) - { - FillHitInfo( fvmEpSupprBuffer[fGet4Nr][ iMsgIdx ] ); - } // for( Int_t iMsgIdx = 0; iMsgIdx < iBufferSize; iMsgIdx++ ) - - fvmEpSupprBuffer[fGet4Nr].clear(); - } // if( 0 < iBufferSize ) - - iBufferSize = fvmEpSupprBufferErrors[fGet4Nr].size(); - if( 0 < iBufferSize ) - { - LOG(debug) << "Now processing stored error messages for for get4 " << fGet4Nr << " with epoch number " - << (fCurrentEpoch[fGet4Nr] - 1); - - for( Int_t iMsgIdx = 0; iMsgIdx < iBufferSize; iMsgIdx++ ) - { - FillGet4ErrorInfo( fvmEpSupprBufferErrors[fGet4Nr][ iMsgIdx ] ); - } // for( Int_t iMsgIdx = 0; iMsgIdx < iBufferSize; iMsgIdx++ ) - - fvmEpSupprBufferErrors[fGet4Nr].clear(); - } // if( 0 < iBufferSize ) - } // if( fbEpochSuppModeOn ) - - // Fill Pulser test histos if needed - if( fbPulserMode && 0 == (fGet4Id % fNrOfGet4PerFeb) // GET4 index in FEET - && fuPulserFee == (fGet4Nr / fNrOfGet4PerFeb)) // FEET index in full system - { - // Fill the time difference for all channels pairs in - // the chosen Fee - UInt_t uHistoFeeIdx = 0; - - UInt_t uOffsetChip = fuPulserFee * fNrOfGet4PerFeb; - for( UInt_t uChanFeeA = 0; uChanFeeA < fNrOfChannelsPerFeet; uChanFeeA++) - { - UInt_t uChipA = uChanFeeA / fNrOfChannelsPerGet4 + uOffsetChip; - UInt_t uChanA = uChanFeeA % fNrOfChannelsPerGet4; - - for( UInt_t uChanFeeB = uChanFeeA + 1; uChanFeeB < fNrOfChannelsPerFeet; uChanFeeB++) - { - UInt_t uChipB = uChanFeeB / fNrOfChannelsPerGet4 + uOffsetChip; - UInt_t uChanB = uChanFeeB % fNrOfChannelsPerGet4; - - Double_t dTimeDiff = - fTsLastHit[ fuPulserGdpb ][ uChipB ][ uChanB ] - - fTsLastHit[ fuPulserGdpb ][ uChipA ][ uChanA ]; - dTimeDiff *= 1e3; // ns -> ps - if( ( 10.0 * dMinDt < dTimeDiff ) && ( dTimeDiff < 10.0 * dMaxDt ) && - ( 0 < fTsLastHit[ fuPulserGdpb ][ uChipA ][ uChanA ] ) && - ( 0 < fTsLastHit[ fuPulserGdpb ][ uChipB ][ uChanB ] ) ) - { - fhTimeDiffPulserChosenFee[uHistoFeeIdx]->Fill( dTimeDiff ); - } // if both channels have already 1 hit and these are not too far away - - uHistoFeeIdx++; - } // for( UInt_t uChanFeeB = uChanFeeA + 1; uChanFeeB < fNrOfChannelsPerFeet; uChanFeeB++) - } // for( UInt_t uChanFeeA = 0; uChanFeeA < fNrOfChannelsPerFeet; uChanFeeA++) - - // Fill the time difference for the chosen channel pairs - for( UInt_t uChan = 0; uChan < kuNbChanTest - 1; uChan++) - { - UInt_t uChipA = fuPulserChan[ uChan ] / fNrOfChannelsPerGet4; - UInt_t uChanA = fuPulserChan[ uChan ] % fNrOfChannelsPerGet4; - UInt_t uChipB = fuPulserChan[ uChan + 1 ] / fNrOfChannelsPerGet4; - UInt_t uChanB = fuPulserChan[ uChan + 1 ] % fNrOfChannelsPerGet4; - - Double_t dTimeDiff = - fTsLastHit[0][uChipB][ uChanB ] - fTsLastHit[0][uChipA][ uChanA ]; - dTimeDiff *= 1e3; // ns -> ps - if( ( 10.0 * dMinDt < dTimeDiff ) && ( dTimeDiff < 10.0 * dMaxDt ) && - ( 0 < fTsLastHit[0][uChipA][ uChanA ] ) && - ( 0 < fTsLastHit[0][uChipB][ uChanB ] ) ) - { - fhTimeDiffPulserChosenChPairs[uChan]->Fill( dTimeDiff ); - } // if both channels have already 1 hit and these are not too far away - } // for( UInt_t uChan = 0; uChan < kuNbChanTest - 1; uChan++) - } // if( fbPulserMode && First GET4 on chosen FEET ) -} - -void CbmTSMonitorTofLab::FillGet4ErrorInfo(ngdpb::Message mess) -{ - - fHistGet4MessType->Fill(fGet4Nr, ngdpb::GET4_32B_ERROR); - - UInt_t uFeetNr = (fGet4Id / fNrOfGet4PerFeb); - if (0 <= fdStartTime) - { - fFeetErrorRate_gDPB[(fGdpbNr * fNrOfFebsPerGdpb) + uFeetNr]->Fill( - 1e-9 * (mess.getMsgFullTimeD(fCurrentEpoch[fGet4Nr]) - fdStartTime)); -// fFeetErrorRateLong_gDPB[(fGdpbNr * fNrOfFebsPerGdpb) + uFeetNr]->Fill( -// 1e-9 * (mess.getMsgFullTimeD(fCurrentEpoch[fGet4Nr]) - fdStartTime) / 60 ); - } // if (0 <= fdStartTime) - fFeetErrorRateLong_gDPB[(fGdpbNr * fNrOfFebsPerGdpb) + uFeetNr]->Fill( - 1e-9 * (mess.getMsgFullTimeD(fCurrentEpoch[fGet4Nr])) / 60.0 - + static_cast< double >( fuCurrentEpochCycle[fGet4Nr] ) * get4v1x::kdEpochCycleInS / 60.0 ); - - Int_t dFullChId = fGet4Nr * fNrOfChannelsPerGet4 + mess.getGdpbSysErrChanId(); - switch (mess.getGdpbSysErrData()) { - case ngdpb::GET4_V1X_ERR_READ_INIT: - fHistGet4ChanErrors->Fill(dFullChId, 0); - break; - case ngdpb::GET4_V1X_ERR_SYNC: - fHistGet4ChanErrors->Fill(dFullChId, 1); - break; - case ngdpb::GET4_V1X_ERR_EP_CNT_SYNC: - fHistGet4ChanErrors->Fill(dFullChId, 2); - break; - case ngdpb::GET4_V1X_ERR_EP: - fHistGet4ChanErrors->Fill(dFullChId, 3); - break; - case ngdpb::GET4_V1X_ERR_FIFO_WRITE: - fHistGet4ChanErrors->Fill(dFullChId, 4); - break; - case ngdpb::GET4_V1X_ERR_LOST_EVT: - fHistGet4ChanErrors->Fill(dFullChId, 5); - break; - case ngdpb::GET4_V1X_ERR_CHAN_STATE: - fHistGet4ChanErrors->Fill(dFullChId, 6); - break; - case ngdpb::GET4_V1X_ERR_TOK_RING_ST: - fHistGet4ChanErrors->Fill(dFullChId, 7); - break; - case ngdpb::GET4_V1X_ERR_TOKEN: - fHistGet4ChanErrors->Fill(dFullChId, 8); - break; - case ngdpb::GET4_V1X_ERR_READOUT_ERR: - fHistGet4ChanErrors->Fill(dFullChId, 9); - break; - case ngdpb::GET4_V1X_ERR_SPI: - fHistGet4ChanErrors->Fill(dFullChId, 10); - break; - case ngdpb::GET4_V1X_ERR_DLL_LOCK: - fHistGet4ChanErrors->Fill(dFullChId, 11); - break; - case ngdpb::GET4_V1X_ERR_DLL_RESET: - fHistGet4ChanErrors->Fill(dFullChId, 12); - break; - case ngdpb::GET4_V1X_ERR_TOT_OVERWRT: - fHistGet4ChanErrors->Fill(dFullChId, 13); - break; - case ngdpb::GET4_V1X_ERR_TOT_RANGE: - fHistGet4ChanErrors->Fill(dFullChId, 14); - break; - case ngdpb::GET4_V1X_ERR_EVT_DISCARD: - fHistGet4ChanErrors->Fill(dFullChId, 15); - break; - case ngdpb::GET4_V1X_ERR_ADD_RIS_EDG: - if( kTRUE == fbGet4v20 ) - fHistGet4ChanErrors->Fill(dFullChId, 16); - else fHistGet4ChanErrors->Fill(dFullChId, 17); - break; - case ngdpb::GET4_V1X_ERR_UNPAIR_FALL: - if( kTRUE == fbGet4v20 ) - fHistGet4ChanErrors->Fill(dFullChId, 17); - else fHistGet4ChanErrors->Fill(dFullChId, 17); - break; - case ngdpb::GET4_V1X_ERR_SEQUENCE_ER: - if( kTRUE == fbGet4v20 ) - fHistGet4ChanErrors->Fill(dFullChId, 18); - else fHistGet4ChanErrors->Fill(dFullChId, 17); - break; - case ngdpb::GET4_V1X_ERR_UNKNOWN: - if( kTRUE == fbGet4v20 ) - fHistGet4ChanErrors->Fill(dFullChId, 19); - else fHistGet4ChanErrors->Fill(dFullChId, 16); - break; - default: // Corrupt error or not yet supported error - if( kTRUE == fbGet4v20 ) - fHistGet4ChanErrors->Fill(dFullChId, 20); - else fHistGet4ChanErrors->Fill(dFullChId, 17); - break; - } // Switch( mess.getGdpbSysErrData() ) -} - -void CbmTSMonitorTofLab::PrintSlcInfo(ngdpb::Message mess) -{ - if (fGdpbIdIndexMap.end() != fGdpbIdIndexMap.find(fGdpbId)) - LOG(info) << "GET4 Slow Control message, epoch " - << static_cast<Int_t>(fCurrentEpoch[fGet4Nr]) << ", time " << std::setprecision(9) - << std::fixed << Double_t(fCurrentEpochTime) * 1.e-9 << " s " - << " for board ID " << std::hex << std::setw(4) << fGdpbId - << std::dec << "\n" - << " +++++++ > Chip = " - << std::setw(2) << mess.getGdpbGenChipId() << ", Chan = " - << std::setw(1) << mess.getGdpbSlcChan() << ", Edge = " - << std::setw(1) << mess.getGdpbSlcEdge() << ", Type = " - << std::setw(1) << mess.getGdpbSlcType() << ", Data = " - << std::hex << std::setw(6) << mess.getGdpbSlcData() - << std::dec << ", Type = " << mess.getGdpbSlcCrc(); - -} - -void CbmTSMonitorTofLab::PrintGenInfo(ngdpb::Message mess) -{ - Int_t mType = mess.getMessageType(); - Int_t channel = mess.getGdpbHitChanId(); - uint64_t uData = mess.getData(); - - if (100 > iMess) - { - LOG(info) << "Get4 MSG type " << mType << " from gdpbId " << fGdpbId - << ", getId " << fGet4Id << ", (hit channel) " << channel - << " data " << std::hex << uData; - iMess++; // Separate increment from condition, otherwise increase until wrap to -1664185233 - } // if (100 > iMess) -} - -void CbmTSMonitorTofLab::PrintSysInfo(ngdpb::Message mess) -{ - if (fGdpbIdIndexMap.end() != fGdpbIdIndexMap.find(fGdpbId)) - LOG(debug) << "GET4 System message, epoch " - << static_cast<Int_t>(fCurrentEpoch[fGet4Nr]) << ", time " << std::setprecision(9) - << std::fixed << Double_t(fCurrentEpochTime) * 1.e-9 << " s " - << " for board ID " << std::hex << std::setw(4) << fGdpbId - << std::dec; - - switch (mess.getGdpbSysSubType()) { - case ngdpb::SYSMSG_GET4_EVENT: { - uint32_t uData = mess.getGdpbSysErrData(); - if (ngdpb::GET4_V1X_ERR_TOT_OVERWRT == uData - || ngdpb::GET4_V1X_ERR_TOT_RANGE == uData - || ngdpb::GET4_V1X_ERR_EVT_DISCARD == uData - || ngdpb::GET4_V1X_ERR_ADD_RIS_EDG == uData - || ngdpb::GET4_V1X_ERR_UNPAIR_FALL == uData - || ngdpb::GET4_V1X_ERR_SEQUENCE_ER == uData - ) - LOG(debug) << " +++++++ > gDPB: " << std::hex << std::setw(4) << fGdpbId - << std::dec << ", Chip = " << std::setw(2) - << mess.getGdpbGenChipId() << ", Chan = " << std::setw(1) - << mess.getGdpbSysErrChanId() << ", Edge = " - << std::setw(1) << mess.getGdpbSysErrEdge() << ", Empt = " - << std::setw(1) << mess.getGdpbSysErrUnused() - << ", Data = " << std::hex << std::setw(2) << uData - << std::dec << " -- GET4 V1 Error Event"; - else - LOG(info) << " +++++++ >gDPB: " << std::hex << std::setw(4) << fGdpbId - << std::dec << ", Chip = " << std::setw(2) - << mess.getGdpbGenChipId() << ", Chan = " << std::setw(1) - << mess.getGdpbSysErrChanId() << ", Edge = " - << std::setw(1) << mess.getGdpbSysErrEdge() << ", Empt = " - << std::setw(1) << mess.getGdpbSysErrUnused() - << ", Data = " << std::hex << std::setw(2) << uData - << std::dec << " -- GET4 V1 Error Event " << iMess; - break; - } // case ngdpb::SYSMSG_GET4_EVENT - case ngdpb::SYSMSG_CLOSYSYNC_ERROR: - LOG(info) << "Closy synchronization error"; - break; - case ngdpb::SYSMSG_TS156_SYNC: - LOG(debug) << "160.00 MHz timestamp reset"; - break; - case ngdpb::SYSMSG_GDPB_UNKWN: - LOG(info) << "Unknown GET4 message, data: " << std::hex << std::setw(8) - << mess.getGdpbSysUnkwData() << std::dec - <<" Full message: " << std::hex << std::setw(16) - << mess.getData() << std::dec; - break; - } // switch( getGdpbSysSubType() ) -} - -void CbmTSMonitorTofLab::FillStarTrigInfo(ngdpb::Message mess) -{ - Int_t iMsgIndex = mess.getStarTrigMsgIndex(); - -// mess.printDataCout(); - - switch( iMsgIndex ) - { - case 0: - fhTokenMsgType->Fill(0); - fulGdpbTsMsb = mess.getGdpbTsMsbStarA(); - break; - case 1: - fhTokenMsgType->Fill(1); - fulGdpbTsLsb = mess.getGdpbTsLsbStarB(); - fulStarTsMsb = mess.getStarTsMsbStarB(); - break; - case 2: - fhTokenMsgType->Fill(2); - fulStarTsMid = mess.getStarTsMidStarC(); - break; - case 3: - { - fhTokenMsgType->Fill(3); - ULong64_t ulNewGdpbTsFull = ( fulGdpbTsMsb << 24 ) - + ( fulGdpbTsLsb ); - ULong64_t ulNewStarTsFull = ( fulStarTsMsb << 48 ) - + ( fulStarTsMid << 8 ) - + mess.getStarTsLsbStarD(); - UInt_t uNewToken = mess.getStarTokenStarD(); - UInt_t uNewDaqCmd = mess.getStarDaqCmdStarD(); - UInt_t uNewTrigCmd = mess.getStarTrigCmdStarD(); - - if( ( uNewToken == fuStarTokenLast ) && ( ulNewGdpbTsFull == fulGdpbTsFullLast ) && - ( ulNewStarTsFull == fulStarTsFullLast ) && ( uNewDaqCmd == fuStarDaqCmdLast ) && - ( uNewTrigCmd == fuStarTrigCmdLast ) ) - { - LOG(debug) << "Possible error: identical STAR tokens found twice in a row => ignore 2nd! " - << Form("token = %5u ", fuStarTokenLast ) - << Form("gDPB ts = %12llu ", fulGdpbTsFullLast ) - << Form("STAR ts = %12llu ", fulStarTsFullLast ) - << Form("DAQ cmd = %2u ", fuStarDaqCmdLast ) - << Form("TRG cmd = %2u ", fuStarTrigCmdLast ); - return; - } // if exactly same message repeated - - // STAR TS counter reset detection - if( ulNewStarTsFull < fulStarTsFullLast ) - LOG(debug) << "Probable reset of the STAR TS: old = " << Form("%16llu", fulStarTsFullLast) - << " new = " << Form("%16llu", ulNewStarTsFull) - << " Diff = -" << Form("%8llu", fulStarTsFullLast - ulNewStarTsFull); - -// ULong64_t ulGdpbTsDiff = ulNewGdpbTsFull - fulGdpbTsFullLast; - fulGdpbTsFullLast = ulNewGdpbTsFull; - fulStarTsFullLast = ulNewStarTsFull; - fuStarTokenLast = uNewToken; - fuStarDaqCmdLast = uNewDaqCmd; - fuStarTrigCmdLast = uNewTrigCmd; - - if( 0 <= fdStartTime ) - { - fhTriggerRate->Fill( - 1e-9 * ( fulGdpbTsFullLast * 6.25 - fdStartTime ) ); - fhStarTokenEvo->Fill( - 1e-9 * ( fulGdpbTsFullLast * 6.25 - fdStartTime ), - fuStarTokenLast ); - } // if( 0 < fdStartTime ) - else fdStartTime = fulGdpbTsFullLast * 6.25; - fhCmdDaqVsTrig->Fill( fuStarDaqCmdLast, fuStarTrigCmdLast ); - - break; - } // case 3 - default: - LOG(fatal) << "Unknown Star Trigger messageindex: " << iMsgIndex; - } // switch( iMsgIndex ) -} -void CbmTSMonitorTofLab::FillTrigEpochInfo(ngdpb::Message mess) -{ - Int_t epochNr = mess.getGdpbEpEpochNb(); - fGet4Id = mess.getGdpbGenChipId(); - fGet4Nr = (fGdpbNr * fNrOfGet4PerGdpb) + fGet4Id; - - if (100 > iMess) - { - LOG(debug) << "Epoch message for get4 " << fGet4Id - << " in gDPB " << fGdpbNr - <<" with epoch number " << epochNr; - iMess++; // Separate increment from condition, otherwise increase until wrap to -1664185233 - } // if (100 > iMess) - - fCurrentEpochTime = mess.getMsgFullTime(epochNr); - fNofEpochs++; - - if( fbEpochSuppModeOn ) - { - /// Re-align the epoch number of the message in case it will be used later: - /// We received the epoch after the data instead of the one before! - //// The epoch index from the token message should not need to be re-aligned - //// ====> to be checked with pulser or data-trigger correlation -// if( 0 < epochNr ) -// mess.setEpoch2Number( epochNr - 1 ); - - } // if( fbEpochSuppModeOn ) -} - -void CbmTSMonitorTofLab::Reset() -{ -} - -void CbmTSMonitorTofLab::Finish() -{ - // Printout some stats on what was unpacked - TString message_type; - for (unsigned int i = 0; i < fMsgCounter.size(); ++i) { - switch (i) { - case 0: - message_type = "NOP"; - break; - case 1: - message_type = "HIT"; - break; - case 2: - message_type = "EPOCH"; - break; - case 3: - message_type = "SYNC"; - break; - case 4: - message_type = "AUX"; - break; - case 5: - message_type = "EPOCH2"; - break; - case 6: - message_type = "GET4"; - break; - case 7: - message_type = "SYS"; - break; - case 8: - message_type = "GET4_SLC"; - break; - case 9: - message_type = "GET4_32B"; - break; - case 10: - message_type = "GET4_SYS"; - break; - default: - message_type = "UNKNOWN"; - break; - } // switch(i) - LOG(info) << message_type << " messages: " << fMsgCounter[i]; - } // for (unsigned int i=0; i< fMsgCounter.size(); ++i) - - LOG(info) << "-------------------------------------"; - for (UInt_t i = 0; i < fNrOfGdpbs; ++i) { - for (UInt_t j = 0; j < fNrOfGet4PerGdpb; ++j) { - LOG(info) << "Last epoch for gDPB: " << std::hex << std::setw(4) << i - << std::dec << " , GET4 " << std::setw(4) << j << " => " - << fCurrentEpoch[GetArrayIndex(i, j)] - << " Cycle " << fuCurrentEpochCycle[GetArrayIndex(i, j)]; - } - } - LOG(info) << "-------------------------------------"; - - SaveAllHistos(); -} - -void CbmTSMonitorTofLab::FillOutput(boost::any) -{ -} - -void CbmTSMonitorTofLab::SaveAllHistos( TString sFileName ) -{ - TDirectory * oldDir = NULL; - TFile * histoFile = NULL; - if( "" != sFileName ) - { - // Store current directory position to allow restore later - oldDir = gDirectory; - // open separate histo file in recreate mode - histoFile = new TFile( sFileName , "RECREATE"); - histoFile->cd(); - } // if( "" != sFileName ) - - gDirectory->mkdir("Tof_Raw_gDPB"); - gDirectory->cd("Tof_Raw_gDPB"); - for (UInt_t uGdpb = 0; uGdpb < fuMinNbGdpb; uGdpb++) { - - for (UInt_t uFeetPlot = 0; uFeetPlot < fNrOfFebsPerGdpb/uNbFeetPlot; ++uFeetPlot ) - fHM->H2(Form("Raw_Tot_gDPB_%02u_%1u", uGdpb, uFeetPlot))->Write(); - - fHM->H1(Form("ChCount_gDPB_%02u", uGdpb))->Write(); - if( fbGet4M24b ) - fHM->H1(Form("ChCountFall_gDPB_%02u", uGdpb))->Write(); - -// if (fUnpackPar->IsChannelRateEnabled()) -// fHM->H2(Form("ChannelRate_gDPB_%02u", uGdpb))->Write(); - for (UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; uFeet++) { - fHM->H1(Form("FeetRate_gDPB_g%02u_f%1u", uGdpb, uFeet))->Write(); - fHM->H1(Form("FeetErrorRate_gDPB_g%02u_f%1u", uGdpb, uFeet))->Write(); - fHM->H1(Form("FeetRateLong_gDPB_g%02u_f%1u", uGdpb, uFeet))->Write(); - fHM->H1(Form("FeetErrorRateLong_gDPB_g%02u_f%1u", uGdpb, uFeet))->Write(); - if( 0 < fiBinSizeDatePlots && 0 < fiRunStartDateTimeSec ) { - fHM->H1(Form("FeetRateDate_gDPB_g%02u_f%1u", uGdpb, uFeet))->Write(); - } - fHM->H2(Form("FtDistribPerCh_gDPB_g%02u_f%1u", uGdpb, uFeet))->Write(); - if( fbGet4M24b ) - fHM->H2(Form("FtDistribPerChFall_gDPB_g%02u_f%1u", uGdpb, uFeet))->Write(); - } - } // for( UInt_t uGdpb = 0; uGdpb < fuMinNbGdpb; uGdpb ++) - fHM->H1("hMessageType")->Write(); - fHM->H1("hSysMessType")->Write(); - fHM->H2("hGet4MessType")->Write(); - fHM->H2("hGet4ChanErrors")->Write(); - fHM->H2("hGet4EpochFlags")->Write(); - fHM->H1("hSpillLength")->Write(); - fHM->H1("hSpillCount")->Write(); - fHM->H1("hSpillQA")->Write(); - - gDirectory->cd(".."); - - ///* ASIC coincidences & offsets mapping */// - if( fbEnableCoincMap ) - { - gDirectory->mkdir("TofCoinc"); - gDirectory->cd("TofCoinc"); - for( UInt_t uAsicA = 0; uAsicA < fvhCoincOffsetEpochGet4.size(); uAsicA ++ ) - fvhCoincOffsetEpochGet4[uAsicA]->Write(); - gDirectory->cd(".."); - } // if( fbEnableCoincMap ) - - ///* STAR event building/cutting */// - gDirectory->mkdir("Star_Raw"); - gDirectory->cd("Star_Raw"); - fhTokenMsgType->Write(); - fHM->H1("hTriggerRate")->Write(); - fHM->H1("hCmdDaqVsTrig")->Write(); - fHM->H1("hStarTokenEvo")->Write(); - gDirectory->cd(".."); - - gDirectory->mkdir("Flib_Raw"); - gDirectory->cd("Flib_Raw"); - for (UInt_t uLinks = 0; uLinks < 16; uLinks++) { - TString sMsSzName = Form("MsSz_link_%02u", uLinks); - if (fHM->Exists(sMsSzName.Data())) - fHM->H1(sMsSzName.Data())->Write(); - - sMsSzName = Form("MsSzTime_link_%02u", uLinks); - if (fHM->Exists(sMsSzName.Data())) - fHM->P1(sMsSzName.Data())->Write(); - } // for( UInt_t uLinks = 0; uLinks < 16; uLinks ++) - gDirectory->cd(".."); - - if( "" != sFileName ) - { - // Restore original directory position - histoFile->Close(); - oldDir->cd(); - } // if( "" != sFileName ) - -} - -void CbmTSMonitorTofLab::ResetAllHistos() -{ - LOG(info) << "Reseting all TOF histograms."; - fHM->H1("hMessageType")->Reset(); - fHM->H1("hSysMessType")->Reset(); - fHM->H2("hGet4MessType")->Reset(); - fHM->H2("hGet4ChanErrors")->Reset(); - fHM->H2("hGet4EpochFlags")->Reset(); - fHM->H1("hSpillLength")->Reset(); - fHM->H1("hSpillCount")->Reset(); - fHM->H2("hSpillQA")->Reset(); - fSpillIdx = 0; - - for (UInt_t uGdpb = 0; uGdpb < fuMinNbGdpb; uGdpb++) { - fHM->H1(Form("ChCount_gDPB_%02u", uGdpb))->Reset(); - if( fbGet4M24b ) - fHM->H1(Form("ChCountFall_gDPB_%02u", uGdpb))->Reset(); - - for (UInt_t uFeetPlot = 0; uFeetPlot < fNrOfFebsPerGdpb/uNbFeetPlot; ++uFeetPlot ) - fHM->H2(Form("Raw_Tot_gDPB_%02u_%1u", uGdpb, uFeetPlot))->Reset(); - -// if (fUnpackPar->IsChannelRateEnabled()) -// fHM->H2(Form("ChannelRate_gDPB_%02u", uGdpb))->Reset(); - for (UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; uFeet++) { - fHM->H1(Form("FeetRate_gDPB_g%02u_f%1u", uGdpb, uFeet))->Reset(); - fHM->H1(Form("FeetErrorRate_gDPB_g%02u_f%1u", uGdpb, uFeet))->Reset(); - fHM->H1(Form("FeetRateLong_gDPB_g%02u_f%1u", uGdpb, uFeet))->Reset(); - fHM->H1(Form("FeetErrorRateLong_gDPB_g%02u_f%1u", uGdpb, uFeet))->Reset(); - fHM->H2(Form("FtDistribPerCh_gDPB_g%02u_f%1u", uGdpb, uFeet))->Reset(); - if( fbGet4M24b ) - { - fHM->H2(Form("FtDistribPerChFall_gDPB_g%02u_f%1u", uGdpb, uFeet))->Reset(); - fHM->H2(Form("FtLastRiseCurrFall_gDPB_g%02u_f%1u", uGdpb, uFeet))->Reset(); - fHM->H2(Form("FtCurrRiseLastFall_gDPB_g%02u_f%1u", uGdpb, uFeet))->Reset(); - fHM->H2(Form("FtLastRiseDistRise_gDPB_g%02u_f%1u", uGdpb, uFeet))->Reset(); - fHM->H2(Form("FtLastRiseDistFall_gDPB_g%02u_f%1u", uGdpb, uFeet))->Reset(); - } // if( fbGet4M24b ) - } // for( UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; uFeet ++) - } // for( UInt_t uGdpb = 0; uGdpb < fuMinNbGdpb; uGdpb ++) - - for (UInt_t uLinks = 0; uLinks < 16; uLinks++) { - TString sMsSzName = Form("MsSz_link_%02u", uLinks); - if (fHM->Exists(sMsSzName.Data())) - fHM->H1(sMsSzName.Data())->Reset(); - - sMsSzName = Form("MsSzTime_link_%02u", uLinks); - if (fHM->Exists(sMsSzName.Data())) - fHM->P1(sMsSzName.Data())->Reset(); - } // for( UInt_t uLinks = 0; uLinks < 16; uLinks ++) - - if( fbPulserMode ) - { - fHM->H2("hTimeRmsPulserChosenFee")->Reset(); - fHM->H1("hTimeRmsPulserChosenChPairs")->Reset(); - fdLastRmsUpdateTime = -1; - - // Full Fee time difference test - UInt_t uHistoFeeIdx = 0; - for( UInt_t uChanFeeA = 0; uChanFeeA < fNrOfChannelsPerFeet; uChanFeeA++) - { - for( UInt_t uChanFeeB = uChanFeeA + 1; uChanFeeB < fNrOfChannelsPerFeet; uChanFeeB++) - { - fhTimeDiffPulserChosenFee[uHistoFeeIdx]->Reset(); - uHistoFeeIdx++; - } // for any unique pair of channel in chosen Fee - } // for( UInt_t uChanFeeA = 0; uChanFeeA < kuNbChanFee; uChanFeeA++) - - // Selected channels test - for( UInt_t uChan = 0; uChan < kuNbChanTest - 1; uChan++) - fhTimeDiffPulserChosenChPairs[uChan]->Reset(); - } // if( fbPulserMode ) - - ///* STAR event building/cutting */// - fhTokenMsgType->Reset(); - fHM->H1("hTriggerRate")->Reset(); - fHM->H1("hCmdDaqVsTrig")->Reset(); - fHM->H1("hStarTokenEvo")->Reset(); - - fdStartTime = -1; - fdStartTimeMsSz = -1; -} -void CbmTSMonitorTofLab::CyclePulserFee() -{ - if( fbPulserMode ) - { - fHM->H2("hTimeRmsPulserChosenFee")->Reset(); - fdLastRmsUpdateTime = -1; - - // Full Fee time difference test - UInt_t uHistoFeeIdx = 0; - for( UInt_t uChanFeeA = 0; uChanFeeA < fNrOfChannelsPerFeet; uChanFeeA++) - { - for( UInt_t uChanFeeB = uChanFeeA + 1; uChanFeeB < fNrOfChannelsPerFeet; uChanFeeB++) - { - fhTimeDiffPulserChosenFee[uHistoFeeIdx]->Reset(); - uHistoFeeIdx++; - } // for any unique pair of channel in chosen Fee - } // for( UInt_t uChanFeeA = 0; uChanFeeA < kuNbChanFee; uChanFeeA++) - - // Cycle the chosen FEE index within the current chosen gDPB - fuPulserFee = (fuPulserFee + 1)%fNrOfFebsPerGdpb; - - LOG(info) << "FEE index for pulser RMS histo changed to : " << fuPulserFee; - } // if( fbPulserMode ) - - if( fbGet4M24b ) - { - // Full Fee time difference test - UInt_t uHistoFeeIdx = 0; - for (UInt_t uGdpb = 0; uGdpb < fuMinNbGdpb; uGdpb++) - { - for (UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; uFeet++) - { - fhFtLastRiseCurrFall[uHistoFeeIdx]->Reset(); - fhFtCurrRiseLastFall[uHistoFeeIdx]->Reset(); - fhFtLastRiseDistRise[uHistoFeeIdx]->Reset(); - fhFtLastRiseDistFall[uHistoFeeIdx]->Reset(); - uHistoFeeIdx++; - } // for (UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; uFeet++) - } // for (UInt_t uGdpb = 0; uGdpb < fuMinNbGdpb; uGdpb++) - - // Cycle the chosen FEE index within the current chosen gDPB - fuRiseFallChSel = (fuRiseFallChSel + 1)%fNrOfChannelsPerFeet; - - LOG(info) << "Channel index for 24b FT Rise vs FT Fall histo changed to : " << fuRiseFallChSel; - } // - -} - - -void CbmTSMonitorTofLab::SetRunStart( Int_t dateIn, Int_t timeIn, Int_t iBinSize ) -{ - TDatime * fRunStartDateTime = new TDatime( dateIn, timeIn); - fiRunStartDateTimeSec = fRunStartDateTime->Convert(); - fiBinSizeDatePlots = iBinSize; - - LOG(info) << "Assigned new TOF Run Start Date-Time: " << fRunStartDateTime->AsString(); -} - -void CbmTSMonitorTofLab::SetPulserChans( - UInt_t inPulserChanA, UInt_t inPulserChanB, UInt_t inPulserChanC, UInt_t inPulserChanD, - UInt_t inPulserChanE, UInt_t inPulserChanF, UInt_t inPulserChanG, UInt_t inPulserChanH, - UInt_t inPulserChanI, UInt_t inPulserChanJ, UInt_t inPulserChanK, UInt_t inPulserChanL, - UInt_t inPulserChanM, UInt_t inPulserChanN, UInt_t inPulserChanO, UInt_t inPulserChanP ) -{ - fuPulserChan[ 0] = inPulserChanA; - fuPulserChan[ 1] = inPulserChanB; - fuPulserChan[ 2] = inPulserChanC; - fuPulserChan[ 3] = inPulserChanD; - fuPulserChan[ 4] = inPulserChanE; - fuPulserChan[ 5] = inPulserChanF; - fuPulserChan[ 6] = inPulserChanG; - fuPulserChan[ 7] = inPulserChanH; - fuPulserChan[ 8] = inPulserChanI; - fuPulserChan[ 9] = inPulserChanJ; - fuPulserChan[10] = inPulserChanK; - fuPulserChan[11] = inPulserChanL; - fuPulserChan[12] = inPulserChanM; - fuPulserChan[13] = inPulserChanN; - fuPulserChan[14] = inPulserChanO; - fuPulserChan[15] = inPulserChanP; -} - -ClassImp(CbmTSMonitorTofLab) diff --git a/beamtime/star2017/unpacker/CbmTSMonitorTofLab.h b/beamtime/star2017/unpacker/CbmTSMonitorTofLab.h deleted file mode 100644 index a39958c8c6dd617a99ab30166f185aefc66ea68f..0000000000000000000000000000000000000000 --- a/beamtime/star2017/unpacker/CbmTSMonitorTofLab.h +++ /dev/null @@ -1,245 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmTSMonitorTofLab ----- -// ----- Created 22.05.2017 by P.-A. Loizeau ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CbmTSMonitorTofLab_H -#define CbmTSMonitorTofLab_H - -#include "Timeslice.hpp" -#include "rocMess_wGet4v1.h" -#include "CbmTofStarData.h" - -#include "CbmTSUnpack.h" -#include "CbmHistManager.h" - -#include "TClonesArray.h" -#include "Rtypes.h" - -#include <vector> -#include <map> -#include <chrono> - -class CbmTofUnpackPar; - -class CbmTSMonitorTofLab: public CbmTSUnpack { - public: - - CbmTSMonitorTofLab(); - virtual ~CbmTSMonitorTofLab(); - - virtual Bool_t Init(); - - virtual Bool_t DoUnpack(const fles::Timeslice& ts, size_t component); - - virtual void Reset(); - - virtual void Finish(); - - void SetParContainers(); - - Bool_t InitContainers(); - - Bool_t ReInitContainers(); - - void FillOutput(boost::any); - - void SetMsLimitLevel(size_t uAcceptBoundaryPct = 100) { - fuMsAcceptsPercent = uAcceptBoundaryPct; - } - size_t GetMsLimitLevel() { - return fuMsAcceptsPercent; - } - - void SetMsOverlap(size_t uOverlapMsNb = 1) { - fuOverlapMsNb = uOverlapMsNb; - } - size_t GetMsOverlap() { - return fuOverlapMsNb; - } - - void SetPerTsSpillOnThr( Int_t iThrIn = 10 ) { fiSpillOnThr = iThrIn; } - void SetPerTsSpillOffThr( Int_t iThrIn = 3 ) { fiSpillOffThr = iThrIn; } - void SetTsNbSpillOffThr( Int_t iThrIn = 10 ) { fiTsUnderOffThr = iThrIn; } - - void SetEpochSuppressedMode( Bool_t bEnable = kTRUE ) { fbEpochSuppModeOn = bEnable; } - - void SetRunStart( Int_t dateIn, Int_t timeIn, Int_t iBinSize = 5 ); - - void SetCoincidenceMapOn( Bool_t bEnable = kTRUE ) { fbEnableCoincMap = bEnable; } - - inline void SetGet4Mode24b( Bool_t inGet4Mode24b = kTRUE ) { fbGet4M24b = inGet4Mode24b; } - inline void SetGet4v20Mode( Bool_t inGet4v20Mode = kTRUE ) { fbGet4v20 = inGet4v20Mode; } - inline void SetPulserMode( Bool_t inPulserMode = kTRUE ) { fbPulserMode = inPulserMode; SetPulserChans(); } - inline void SetPulserFee( UInt_t inPulserGdpb, UInt_t inPulserFee ) { fuPulserGdpb = inPulserGdpb; fuPulserFee = inPulserFee; } - void SetPulserChans( UInt_t inPulserChanA = 0, UInt_t inPulserChanB = 1, UInt_t inPulserChanC = 2, - UInt_t inPulserChanD = 3, UInt_t inPulserChanE = 4, UInt_t inPulserChanF = 5, - UInt_t inPulserChanG = 6, UInt_t inPulserChanH = 7, UInt_t inPulserChanI = 8, - UInt_t inPulserChanJ = 9, UInt_t inPulserChanK = 10, UInt_t inPulserChanL = 11, - UInt_t inPulserChanM = 12, UInt_t inPulserChanN = 13, UInt_t inPulserChanO = 14, - UInt_t inPulserChanP = 15 ); - - void SaveAllHistos( TString sFileName = "" ); - void ResetAllHistos(); - void CyclePulserFee(); - - private: - - size_t fuMsAcceptsPercent; /** Reject Ms with index inside TS above this, assumes 100 MS per TS **/ - size_t fuOverlapMsNb; /** Ignore Overlap Ms: all fuOverlapMsNb MS at the end of timeslice **/ - UInt_t fuMinNbGdpb; - UInt_t fuCurrNbGdpb; - - UInt_t fNrOfGdpbs; // Total number of GDPBs in the system - UInt_t fNrOfFebsPerGdpb; // Number of FEBs per GDPB - UInt_t fNrOfGet4PerFeb; // Number of GET4s per FEB - UInt_t fNrOfChannelsPerGet4; // Number of channels in each GET4 - - UInt_t fNrOfChannelsPerFeet; // Number of channels in each FEET - UInt_t fNrOfGet4; // Total number of Get4 chips in the system - UInt_t fNrOfGet4PerGdpb; // Number of GET4s per GDPB - - Int_t fiCountsLastTs; - Int_t fiSpillOnThr; - Int_t fiSpillOffThr; - Int_t fiTsUnderOff; - Int_t fiTsUnderOffThr; - Double_t fdDetLastTime; - Double_t fdDetTimeLastTs; - Bool_t fbSpillOn; - UInt_t fSpillIdx; - - Bool_t fbEpochSuppModeOn; - std::vector< std::vector < ngdpb::Message > > fvmEpSupprBuffer; - std::vector< std::vector < ngdpb::Message > > fvmEpSupprBufferErrors; - - Int_t fGdpbId; // Id (hex number)of the GDPB which is read from the message - Int_t fGdpbNr; // running number (0 to fNrOfGdpbs) of the GDPB in the - Int_t fGet4Id; // running number (0 to fNrOfGet4PerGdpb) of the Get4 chip of a unique GDPB - Int_t fGet4Nr; // running number (0 to fNrOfGet4) of the Get4 chip in the system - - std::vector<int> fMsgCounter; - - std::map<UInt_t, UInt_t> fGdpbIdIndexMap; - - CbmHistManager* fHM; ///< Histogram manager - - /** Current epoch marker for each GDPB and GET4 - * (first epoch in the stream initializes the map item) - * pointer points to an array of size fNrOfGdpbs * fNrOfGet4PerGdpb - * The correct array index is calculated using the function - * GetArrayIndex(gdpbId, get4Id) - **/ - Long64_t* fCurrentEpoch; //! - UInt_t* fuCurrentEpochCycle; //! - - Int_t fNofEpochs; /** Current epoch marker for each ROC **/ - ULong_t fCurrentEpochTime; /** Time stamp of current epoch **/ - Double_t fdStartTime; /** Time of first valid hit (epoch available), used as reference for evolution plots**/ - Double_t fdStartTimeMsSz; /** Time of first microslice, used as reference for evolution plots**/ - TCanvas* fcMsSizeAll; - - /** Used only if the channel rate or pulse hit difference plots are enabled **/ - /** Last Hit time for each gDPB/GET4/Channel **/ - std::vector< std::vector< std::vector< Double_t > > > fTsLastHit; // * 6.25 ns - - Int_t fEquipmentId; - - CbmTofUnpackPar* fUnpackPar; //! - - std::chrono::time_point<std::chrono::system_clock> fTimeLastHistoSave; - - TH1* fHistMessType; - TH1* fHistSysMessType; - TH2* fHistGet4MessType; - TH2* fHistGet4ChanErrors; - TH2* fHistGet4EpochFlags; - TH2* fHistSpill; - TH1* fHistSpillLength; - TH1* fHistSpillCount; - TH2* fHistSpillQA; - - std::vector<TH2*> fRaw_Tot_gDPB; - std::vector<TH1*> fChCount_gDPB; - std::vector<TH2*> fChannelRate_gDPB; - std::vector<TH1*> fFeetRate_gDPB; - std::vector<TH1*> fFeetErrorRate_gDPB; - std::vector<TH1*> fFeetRateLong_gDPB; - std::vector<TH1*> fFeetErrorRateLong_gDPB; - - std::vector<TH1*> fFeetRateDate_gDPB; - Int_t fiRunStartDateTimeSec; - Int_t fiBinSizeDatePlots; - - ///* ASIC coincidences & offsets mapping */// - Bool_t fbEnableCoincMap; - ULong64_t fulLastMsIdx; - Bool_t fbHitsInLastTs; - std::vector< std::vector< Long64_t > > fvulHitEpochBuffLastTs; //! Dims: [gDPB][hits] - std::vector< TH2 * > fvhCoincOffsetEpochGet4; //! Dims: [gDPB - 1] - - ///* STAR TRIGGER detection */// - ULong64_t fulGdpbTsMsb; - ULong64_t fulGdpbTsLsb; - ULong64_t fulStarTsMsb; - ULong64_t fulStarTsMid; - ULong64_t fulGdpbTsFullLast; - ULong64_t fulStarTsFullLast; - UInt_t fuStarTokenLast; - UInt_t fuStarDaqCmdLast; - UInt_t fuStarTrigCmdLast; - TH1 * fhTokenMsgType; - TH1 * fhTriggerRate; - TH2 * fhCmdDaqVsTrig; - TH2 * fhStarTokenEvo; - - ///* STAR and pulser monitoring */// - static const UInt_t kuNbChanTest = 16; - Bool_t fbGet4M24b; - Bool_t fbGet4v20; - Bool_t fbPulserMode; - UInt_t fuPulserGdpb; - UInt_t fuPulserFee; - UInt_t fuPulserChan[kuNbChanTest]; //! Always in first gDPB !!! - std::vector<TH1 *> fhTimeDiffPulserChosenFee; - std::vector<TH1 *> fhTimeDiffPulserChosenChPairs; - TH2 * fhTimeRmsPulserChosenFee; - TH1 * fhTimeRmsPulserChosenChPairs; - Double_t fdLastRmsUpdateTime; - std::vector<TH2 *> fhFtDistribPerCh; - std::vector<TH1*> fChCountFall_gDPB; - std::vector<TH2 *> fhFtDistribPerChFall; - std::vector< std::vector<Int_t> > fviFtLastRise24b; - std::vector< std::vector<Int_t> > fviFtLastFall24b; - std::vector< std::vector<Double_t> > fvdTimeLastRise24b; - std::vector< std::vector<Double_t> > fvdTimeLastFall24b; - UInt_t fuRiseFallChSel; - std::vector<TH2 *> fhFtLastRiseCurrFall; - std::vector<TH2 *> fhFtCurrRiseLastFall; - std::vector<TH2 *> fhFtLastRiseDistRise; - std::vector<TH2 *> fhFtLastRiseDistFall; - - void CreateHistograms(); - - void FillHitInfo(ngdpb::Message); - void FillEpochInfo(ngdpb::Message); - void FillGet4ErrorInfo(ngdpb::Message); - void PrintSlcInfo(ngdpb::Message); - void PrintSysInfo(ngdpb::Message); - void PrintGenInfo(ngdpb::Message); - void FillStarTrigInfo(ngdpb::Message); - void FillTrigEpochInfo(ngdpb::Message); - - inline Int_t GetArrayIndex(Int_t gdpbId, Int_t get4Id) { - return gdpbId * fNrOfGet4PerGdpb + get4Id; - } - - CbmTSMonitorTofLab(const CbmTSMonitorTofLab&); - CbmTSMonitorTofLab operator=(const CbmTSMonitorTofLab&); - - ClassDef(CbmTSMonitorTofLab, 1) -}; - -#endif diff --git a/beamtime/star2017/unpacker/CbmTSMonitorTofStar.cxx b/beamtime/star2017/unpacker/CbmTSMonitorTofStar.cxx deleted file mode 100644 index 36ea814afe10fb819f50612aeb1131b36de019bc..0000000000000000000000000000000000000000 --- a/beamtime/star2017/unpacker/CbmTSMonitorTofStar.cxx +++ /dev/null @@ -1,4357 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmTSMonitorTofStar ----- -// ----- Created 15.12.2016 by P.-A. Loizeau ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#include "CbmTSMonitorTofStar.h" -#include "CbmTofUnpackPar.h" - -//#include "CbmFlibCern2016Source.h" -#include "CbmHistManager.h" - -#include "FairLogger.h" -#include "FairRootManager.h" -#include "FairRun.h" -#include "FairRuntimeDb.h" -#include "FairRunOnline.h" - -#include "TClonesArray.h" -#include "TString.h" -#include "THttpServer.h" -#include "Rtypes.h" -#include "TH1.h" -#include "TF1.h" -#include "TCanvas.h" -#include "THStack.h" -#include "TROOT.h" -#include "TStyle.h" -#include "TPaveStats.h" -#include "TDatime.h" -#include "TMath.h" -#include <TFile.h> - -#include <algorithm> -#include <iostream> -#include <stdint.h> -#include <iomanip> -#include <ctime> - -static Int_t iMess = 0; -//static Int_t iMessB = 0; -Bool_t bResetTofStarHistos = kFALSE; -Bool_t bSaveTofStarHistos = kFALSE; -Bool_t bTofCyclePulserFee = kFALSE; -Bool_t bTofUpdateNormedFt = kFALSE; -Bool_t bTofUpdateZoomedFit = kFALSE; - -// Default value for nb bins in Pulser time difference histos -//const UInt_t kuNbBinsDt = 5000; -const UInt_t kuNbBinsDt = 300; -Double_t dMinDt = -1.*(kuNbBinsDt*get4v1x::kdBinSize/2.) - get4v1x::kdBinSize/2.; -Double_t dMaxDt = 1.*(kuNbBinsDt*get4v1x::kdBinSize/2.) + get4v1x::kdBinSize/2.; -//const UInt_t kuNbBinsDt = 299; -//Double_t dMinDt = -1.*((kuNbBinsDt+1)*get4v1x::kdBinSize/2.); -//Double_t dMaxDt = 1.*((kuNbBinsDt+1)*get4v1x::kdBinSize/2.); - -// Default number of FEET per channels histograms -UInt_t uNbFeetPlot = 2; -UInt_t uNbFeetPlotsPerGdpb = 0; - -CbmTSMonitorTofStar::CbmTSMonitorTofStar() : - CbmTSUnpack(), - fuMsAcceptsPercent(100), - fuOverlapMsNb(0), - fuMinNbGdpb(), - fuCurrNbGdpb(0), - fNrOfGdpbs(0), - fNrOfFebsPerGdpb(0), - fNrOfGet4PerFeb(0), - fNrOfChannelsPerGet4(0), - fNrOfChannelsPerFeet(0), - fNrOfGet4(0), - fNrOfGet4PerGdpb(0), - fuNbChannelsPerGdpb( 0 ), - fiCountsLastTs(0), - fiSpillOnThr(10), - fiSpillOffThr(3), - fiTsUnderOff(0), - fiTsUnderOffThr(10), - fdDetLastTime(-1.), - fdDetTimeLastTs(-1.), - fbSpillOn(kFALSE), - fSpillIdx(0), - fbEpochSuppModeOn(kFALSE), - fvmEpSupprBuffer(), - fGdpbId(0), - fGdpbNr(0), - fGet4Id(0), - fGet4Nr(0), - fMsgCounter(11, 0), // length of enum MessageTypes initialized with 0 - fGdpbIdIndexMap(), - fHM(new CbmHistManager()), - fCurrentEpoch(NULL), - fNofEpochs(0), - fCurrentEpochTime(0.), - fdStartTime(-1.), - fdStartTimeLong(-1.), - fdStartTimeMsSz(-1.), - fcMsSizeAll(NULL), - fTsLastHit(), - fEquipmentId(0), - fdMsIndex(0.0), - fUnpackPar(NULL), - fHistMessType(NULL), - fHistSysMessType(NULL), - fHistGet4MessType(NULL), - fHistGet4ChanScm(NULL), - fHistGet4ChanErrors(NULL), - fHistGet4EpochFlags(NULL), - fHistSpill(NULL), - fHistSpillLength(NULL), - fHistSpillCount(NULL), - fHistSpillQA(NULL), - fhScmScalerCounters(NULL), - fhScmDeadtimeCounters(NULL), - fhScmSeuCounters(NULL), - fhScmSeuCountersEvo(NULL), - fdTimeLastStartMessage(0.), - fhScmStartMessDist(NULL), - fhScmStartMessEvo(NULL), - fRaw_Tot_gDPB(), - fChCount_gDPB(), - fChannelRate_gDPB(), - fFeetRate_gDPB(), - fFeetErrorRate_gDPB(), - fuHistoryHistoSize( 1800 ), - fFeetRateLong_gDPB(), - fFeetErrorRateLong_gDPB(), - fuHistoryHistoSizeLong( 600 ), - fFeetRateDate_gDPB(), - fiRunStartDateTimeSec( -1 ), - fiBinSizeDatePlots( -1 ), - fdFirstMsIndex( -1 ), - fbFirstEpochInMsFound(), - fRealMsFineQa_gDPB(), - fRealMsMidQa_gDPB(), - fRealMsCoarseQa_gDPB(), -/* - fulLastMsIdx(0), - fbHitsInLastTs(kFALSE), - fvulHitEpochBuffLastTs(), - fvhCoincOffsetEpochGet4(), -*/ - fulGdpbTsMsb(0), - fulGdpbTsLsb(0), - fulStarTsMsb(0), - fulStarTsMid(0), - fulGdpbTsFullLast(0), - fulStarTsFullLast(0), - fuStarTokenLast(0), - fuStarDaqCmdLast(0), - fuStarTrigCmdLast(0), - fhTokenMsgType(NULL), - fhTriggerRate(NULL), - fhCmdDaqVsTrig(NULL), - fhStarTokenEvo(NULL), - fbGet4M24b( kFALSE ), - fbGet4v20( kFALSE ), - fbMergedEpochsOn( kFALSE ), - fbPulserMode( kFALSE ), - fuPulserGdpb(0), - fuPulserFee(0), - fhTimeDiffPulserChosenFee(), - fhTimeDiffPulserChosenChPairs(), - fhTimeRmsPulserChosenFee(NULL), - fhTimeRmsPulserChosenChPairs(NULL), - fdLastRmsUpdateTime(-1), - fdFitZoomWidthPs(0.0), - fhTimeRmsZoomPulsChosenFee(NULL), - fhTimeRmsZoomFitPulsChosenChPairs(NULL), - fhTimeResFitPulsChosenFee(NULL), - fhTimeResFitPulsChosenChPairs(NULL), - fhFtDistribPerCh(), - fChCountFall_gDPB(), - fhFtDistribPerChFall(), - fSelChFtNormDnlRise(), - fSelChFtNormDnlFall(), - fFtNormDnlMinRise(), - fFtNormDnlMaxRise(), - fFtNormDnlMinFall(), - fFtNormDnlMaxFall(), - fhTempHistInlRise(NULL), - fhTempHistInlFall(NULL), - fSelChFtNormInlRise(), - fSelChFtNormInlFall(), - fFtNormInlMinRise(), - fFtNormInlMaxRise(), - fFtNormInlMinFall(), - fFtNormInlMaxFall(), - fviFtLastRise24b(), - fviFtLastFall24b(), - fvdTimeLastRise24b(), - fvdTimeLastFall24b(), - fuRiseFallChSel(0), - fhFtLastRiseCurrFall(), - fhFtCurrRiseLastFall(), - fhFtLastRiseDistRise(), - fhFtLastRiseDistFall(), - fbStarSortAndCutMode(kFALSE), - fuStarActiveAsicMask(), - fdStarTriggerDelay(), - fdStarTriggerWinSize(), - fuCurrentEpGdpb(), - fuStarCurrentEpFound(), - fuStarNextBufferUse(), - fdStarLastTrigTimeG(), - fiStarBuffIdxPrev(), - fiStarBuffIdxCurr(), - fiStarBuffIdxNext(), - fuLastTriggerFullTs(), - fvGdpbEpMsgBuffer(), - fvGdpbEpHitBuffer(), - fvGdpbEpTrgBuffer(), - fStarSubEvent(), - fhStarEpToTrig_gDPB(), - fhStarHitToTrigAll_gDPB(), - fhStarHitToTrigWin_gDPB(), - fhStarEventSize_gDPB(), - fhStarEventSizeTime_gDPB(), - fulNbStarEvent(0), - fulNbStarEventLastPrintout(0), - fTimeLastPrintoutNbStarEvent() -{ -} - -CbmTSMonitorTofStar::~CbmTSMonitorTofStar() -{ - delete fHM; //TODO: Who deletes the histograms stored in the CbmHistManager??? - delete[] fCurrentEpoch; -} - -Bool_t CbmTSMonitorTofStar::Init() -{ - LOG(info) << "Initializing Get4 monitor"; - - FairRootManager* ioman = FairRootManager::Instance(); - if (ioman == NULL) { - LOG(fatal) << "No FairRootManager instance"; - } - - return kTRUE; -} - -void CbmTSMonitorTofStar::SetParContainers() -{ - LOG(info) << "Setting parameter containers for " << GetName(); - fUnpackPar = - (CbmTofUnpackPar*) (FairRun::Instance()->GetRuntimeDb()->getContainer( - "CbmTofUnpackPar")); - -} - -Bool_t CbmTSMonitorTofStar::InitContainers() -{ - LOG(info) << "Init parameter containers for " << GetName(); - Bool_t initOK = ReInitContainers(); - - CreateHistograms(); - - fCurrentEpoch = new Long64_t[fNrOfGdpbs * fNrOfGet4PerGdpb]; - for (UInt_t i = 0; i < fNrOfGdpbs; ++i) { - for (UInt_t j = 0; j < fNrOfGet4PerGdpb; ++j) { - fCurrentEpoch[GetArrayIndex(i, j)] = -111; - } - } - - return initOK; -} - -Bool_t CbmTSMonitorTofStar::ReInitContainers() -{ - LOG(info) << "ReInit parameter containers for " << GetName(); - - fNrOfGdpbs = fUnpackPar->GetNrOfRocs(); - LOG(info) << "Nr. of Tof GDPBs: " << fNrOfGdpbs; - fuMinNbGdpb = fNrOfGdpbs; - - fNrOfFebsPerGdpb = fUnpackPar->GetNrOfFebsPerGdpb(); - LOG(info) << "Nr. of FEBS per Tof GDPB: " << fNrOfFebsPerGdpb; - - fNrOfGet4PerFeb = fUnpackPar->GetNrOfGet4PerFeb(); - LOG(info) << "Nr. of GET4 per Tof FEB: " << fNrOfGet4PerFeb; - - fNrOfChannelsPerGet4 = fUnpackPar->GetNrOfChannelsPerGet4(); - LOG(info) << "Nr. of channels per GET4: " << fNrOfChannelsPerGet4; - - fNrOfChannelsPerFeet = fNrOfGet4PerFeb * fNrOfChannelsPerGet4; - LOG(info) << "Nr. of channels per FEET: " << fNrOfChannelsPerFeet; - - fNrOfGet4 = fNrOfGdpbs * fNrOfFebsPerGdpb * fNrOfGet4PerFeb; - LOG(info) << "Nr. of GET4s: " << fNrOfGet4; - - fNrOfGet4PerGdpb = fNrOfFebsPerGdpb * fNrOfGet4PerFeb; - LOG(info) << "Nr. of GET4s per GDPB: " << fNrOfGet4PerGdpb; - - fuNbChannelsPerGdpb = fNrOfFebsPerGdpb * fNrOfGet4PerFeb * fNrOfChannelsPerGet4; - LOG(info) << "Nr. of channels per GDPB: " << fuNbChannelsPerGdpb; - - fGdpbIdIndexMap.clear(); - for (UInt_t i = 0; i < fNrOfGdpbs; ++i) { - fGdpbIdIndexMap[fUnpackPar->GetRocId(i)] = i; - LOG(info) << "GDPB Id of TOF " << i << " : " << fUnpackPar->GetRocId(i); - } - UInt_t NrOfChannels = fUnpackPar->GetNumberOfChannels(); - LOG(info) << "Nr. of mapped Tof channels: " << NrOfChannels; - std::stringstream ss; - for (UInt_t i = 0; i< NrOfChannels; ++i) { - if(i%8 == 0) - ss << "\n"; - ss << Form(" 0x%08x",fUnpackPar->GetChannelToDetUIdMap(i)); - } - LOG(info) << ss.str(); - - LOG(info) << "Plot Channel Rate => " - << (fUnpackPar->IsChannelRateEnabled() ? "ON" : "OFF"); - - if( fbEpochSuppModeOn ) - fvmEpSupprBuffer.resize( fNrOfGet4 ); - - if( fbStarSortAndCutMode ) - { - fuCurrentEpGdpb.resize( fNrOfGdpbs ); - fuStarActiveAsicMask.resize( fNrOfGdpbs ); - fuStarCurrentEpFound.resize( fNrOfGdpbs ); - fuStarNextBufferUse.resize( fNrOfGdpbs ); - fdStarTriggerDelay.resize( fNrOfGdpbs ); - fdStarTriggerWinSize.resize( fNrOfGdpbs ); - fdStarLastTrigTimeG.resize( fNrOfGdpbs ); - fiStarBuffIdxPrev.resize( fNrOfGdpbs ); - fiStarBuffIdxCurr.resize( fNrOfGdpbs ); - fiStarBuffIdxNext.resize( fNrOfGdpbs ); - fuLastTriggerFullTs.resize( fNrOfGdpbs ); - fvGdpbEpMsgBuffer.resize( fNrOfGdpbs ); - fvGdpbEpHitBuffer.resize( fNrOfGdpbs ); - fvGdpbEpTrgBuffer.resize( fNrOfGdpbs ); - for (UInt_t iGdpb = 0; iGdpb < fNrOfGdpbs; ++iGdpb) - { - fuCurrentEpGdpb[ iGdpb ] = 0; - fuStarActiveAsicMask[ iGdpb ] = fUnpackPar->GetStarActiveMask( iGdpb ); - fuStarCurrentEpFound[ iGdpb ] = 0; - fuStarNextBufferUse[ iGdpb ] = 0; - fdStarTriggerDelay[ iGdpb ] = fUnpackPar->GetStarTriggDelay( iGdpb ); - fdStarTriggerWinSize[ iGdpb ] = fUnpackPar->GetStarTriggWinSize( iGdpb ); - fdStarLastTrigTimeG[ iGdpb ] = -1.0; - fiStarBuffIdxPrev[ iGdpb ] = -1; - fiStarBuffIdxCurr[ iGdpb ] = 0; - fiStarBuffIdxNext[ iGdpb ] = 1; - fvGdpbEpMsgBuffer[ iGdpb ].resize( 3 ); // 1 buff. for Prev, Curr and Next - fvGdpbEpHitBuffer[ iGdpb ].resize( 3 ); // 1 buff. for Prev, Curr and Next - fvGdpbEpTrgBuffer[ iGdpb ].resize( 3 ); // 1 buff. for Prev, Curr and Next - - LOG(info) << "STAR trigger par of gDPB " << iGdpb << " are: mask " << fuStarActiveAsicMask[ iGdpb ] - << " Delay " << fdStarTriggerDelay[ iGdpb ] - << " and WinSz " << fdStarTriggerWinSize[ iGdpb ]; - if( fdStarTriggerDelay[ iGdpb ] < fdStarTriggerWinSize[ iGdpb ] ) - LOG(fatal) << "STAR trigger window should end at latest on token itself!" - << " => Delay has to be greater or equal with window size!"; - } // for (Int_t iGdpb = 0; iGdpb < fNrOfGdpbs; ++iGdpb) - } // if( fbStarSortAndCutMode ) - - return kTRUE; -} - -void CbmTSMonitorTofStar::CreateHistograms() -{ - THttpServer* server = FairRunOnline::Instance()->GetHttpServer(); -// server->SetJSROOT("https://root.cern.ch/js/latest"); - - TString name { "" }; - TString title { "" }; - - name = "hMessageType"; - title = "Nb of message for each type; Type"; - // Test Big Data readout with plotting - TH1I* hMessageType = new TH1I(name, title, 16, 0., 16.); - // TH1I* hMessageType = new TH1I(name, title, 16, -0.5, 15.5); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_NOP, "NOP"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_HIT, "HIT"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_EPOCH, "EPOCH"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_SYNC, "SYNC"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_AUX, "AUX"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_EPOCH2, "EPOCH2"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_GET4, "GET4"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_SYS, "SYS"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_GET4_SLC, - "MSG_GET4_SLC"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_GET4_32B, - "MSG_GET4_32B"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_GET4_SYS, - "MSG_GET4_SYS"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_STAR_TRI, - "MSG_STAR_TRI"); - hMessageType->GetXaxis()->SetBinLabel(1 + 15, "GET4 Hack 32B"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_NOP, "NOP"); - fHM->Add(name.Data(), hMessageType); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - - name = "hSysMessType"; - title = "Nb of system message for each type; System Type"; - TH1I* hSysMessType = new TH1I(name, title, 17, 0., 17.); -// TH1I* hSysMessType = new TH1I(name, title, 17, -0.5, 16.5); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_START, - "DAQ START"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_FINISH, - "DAQ FINISH"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_NX_PARITY, - "NX PARITY"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_SYNC_PARITY, - "SYNC PARITY"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_RESUME, - "DAQ RESUME"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_FIFO_RESET, - "FIFO RESET"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_USER, "USER"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_PCTIME, "PCTIME"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_ADC, "ADC"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_PACKETLOST, - "PACKET LOST"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_GET4_EVENT, - "GET4 ERROR"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_CLOSYSYNC_ERROR, - "CLOSYSYNC ERROR"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_TS156_SYNC, - "TS156 SYNC"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_GDPB_UNKWN, - "UNKW GET4 MSG"); - hSysMessType->GetXaxis()->SetBinLabel(1 + 16, "GET4 Hack 32B"); - fHM->Add(name.Data(), hSysMessType); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - - name = "hGet4MessType"; - title = "Nb of message for each type per GET4; GET4 chip # ; Type"; - TH2I* hGet4MessType = new TH2I(name, title, fNrOfGet4, 0., fNrOfGet4, 5, 0., - 5.); -// TH2I* hGet4MessType = new TH2I(name, title, uNbFeets*feetv1::kuChipPerFeet, -0.5, uNbFeets*feetv1::kuChipPerFeet -0.5, 5, -0.5, 4.5); - hGet4MessType->GetYaxis()->SetBinLabel(1 + ngdpb::GET4_32B_EPOCH, "EPOCH"); - hGet4MessType->GetYaxis()->SetBinLabel(1 + ngdpb::GET4_32B_SLCM, "S.C. M"); - hGet4MessType->GetYaxis()->SetBinLabel(1 + ngdpb::GET4_32B_ERROR, "ERROR"); - hGet4MessType->GetYaxis()->SetBinLabel(1 + ngdpb::GET4_32B_DATA, "DATA 32b"); - hGet4MessType->GetYaxis()->SetBinLabel(1 + ngdpb::GET4_32B_DATA + 1, - "DATA 24b"); - fHM->Add(name.Data(), hGet4MessType); - if (server) - server->Register("/TofRaw", fHM->H2(name.Data())); - - name = "hGet4ChanScm"; - title = "SC messages per GET4 channel; GET4 channel # ; SC type"; - TH2I* hGet4ChanScm = new TH2I(name, title, - 2 * fNrOfGet4 * fNrOfChannelsPerGet4, 0., fNrOfGet4 * fNrOfChannelsPerGet4, - 4, 0., 4.); - fHM->Add(name.Data(), hGet4ChanScm); - if (server) - server->Register("/TofRaw", fHM->H2(name.Data())); - - name = "hGet4ChanErrors"; - title = "Error messages per GET4 channel; GET4 channel # ; Error"; - TH2I* hGet4ChanErrors = NULL; - if( kTRUE == fbGet4v20 ) - { - /// Possible errors changed after introduction of Bubbles correction/detection - hGet4ChanErrors = new TH2I(name, title, - fNrOfGet4 * fNrOfChannelsPerGet4, 0., fNrOfGet4 * fNrOfChannelsPerGet4, - 21, 0., 21.); -// 32, 0., 32.); - hGet4ChanErrors->GetYaxis()->SetBinLabel( 1, "0x00: Readout Init "); - hGet4ChanErrors->GetYaxis()->SetBinLabel( 2, "0x01: Sync "); - hGet4ChanErrors->GetYaxis()->SetBinLabel( 3, "0x02: Epoch count sync"); - hGet4ChanErrors->GetYaxis()->SetBinLabel( 4, "0x03: Epoch "); - hGet4ChanErrors->GetYaxis()->SetBinLabel( 5, "0x04: FIFO Write "); - hGet4ChanErrors->GetYaxis()->SetBinLabel( 6, "0x05: Lost event "); - hGet4ChanErrors->GetYaxis()->SetBinLabel( 7, "0x06: Channel state "); - hGet4ChanErrors->GetYaxis()->SetBinLabel( 8, "0x07: Token Ring state"); - hGet4ChanErrors->GetYaxis()->SetBinLabel( 9, "0x08: Token "); - hGet4ChanErrors->GetYaxis()->SetBinLabel(10, "0x09: Error Readout "); - hGet4ChanErrors->GetYaxis()->SetBinLabel(11, "0x0a: SPI "); - hGet4ChanErrors->GetYaxis()->SetBinLabel(12, "0x0b: DLL Lock error "); // <- From GET4 v1.2 - hGet4ChanErrors->GetYaxis()->SetBinLabel(13, "0x0c: DLL Reset invoc."); // <- From GET4 v1.2 - hGet4ChanErrors->GetYaxis()->SetBinLabel(14, "0x11: Overwrite "); - hGet4ChanErrors->GetYaxis()->SetBinLabel(15, "0x12: ToT out of range"); - hGet4ChanErrors->GetYaxis()->SetBinLabel(16, "0x13: Event Discarded "); - hGet4ChanErrors->GetYaxis()->SetBinLabel(17, "0x14: Add. Rising edge"); // <- From GET4 v1.3 - hGet4ChanErrors->GetYaxis()->SetBinLabel(18, "0x15: Unpaired Falling"); // <- From GET4 v1.3 - hGet4ChanErrors->GetYaxis()->SetBinLabel(19, "0x16: Sequence error "); // <- From GET4 v1.3 - hGet4ChanErrors->GetYaxis()->SetBinLabel(20, "0x7f: Unknown "); - hGet4ChanErrors->GetYaxis()->SetBinLabel(21, "Corrupt/unsuprtd error"); - } // if( kTRUE == fbGet4v20 ) - else - { - hGet4ChanErrors = new TH2I(name, title, - fNrOfGet4 * fNrOfChannelsPerGet4, 0., fNrOfGet4 * fNrOfChannelsPerGet4, - 18, 0., 18.); - // 32, 0., 32.); - hGet4ChanErrors->GetYaxis()->SetBinLabel( 1, "0x00: Readout Init "); - hGet4ChanErrors->GetYaxis()->SetBinLabel( 2, "0x01: Sync "); - hGet4ChanErrors->GetYaxis()->SetBinLabel( 3, "0x02: Epoch count sync"); - hGet4ChanErrors->GetYaxis()->SetBinLabel( 4, "0x03: Epoch "); - hGet4ChanErrors->GetYaxis()->SetBinLabel( 5, "0x04: FIFO Write "); - hGet4ChanErrors->GetYaxis()->SetBinLabel( 6, "0x05: Lost event "); - hGet4ChanErrors->GetYaxis()->SetBinLabel( 7, "0x06: Channel state "); - hGet4ChanErrors->GetYaxis()->SetBinLabel( 8, "0x07: Token Ring state"); - hGet4ChanErrors->GetYaxis()->SetBinLabel( 9, "0x08: Token "); - hGet4ChanErrors->GetYaxis()->SetBinLabel(10, "0x09: Error Readout "); - hGet4ChanErrors->GetYaxis()->SetBinLabel(11, "0x0a: SPI "); - hGet4ChanErrors->GetYaxis()->SetBinLabel(12, "0x0b: DLL Lock error "); // <- From GET4 v1.2 - hGet4ChanErrors->GetYaxis()->SetBinLabel(13, "0x0c: DLL Reset invoc."); // <- From GET4 v1.2 - hGet4ChanErrors->GetYaxis()->SetBinLabel(14, "0x11: Overwrite "); - hGet4ChanErrors->GetYaxis()->SetBinLabel(15, "0x12: ToT out of range"); - hGet4ChanErrors->GetYaxis()->SetBinLabel(16, "0x13: Event Discarded "); - hGet4ChanErrors->GetYaxis()->SetBinLabel(17, "0x7f: Unknown "); - } // else of if( kTRUE == fbGet4v20 ) - fHM->Add(name.Data(), hGet4ChanErrors); - if (server) - server->Register("/TofRaw", fHM->H2(name.Data())); - - name = "hGet4EpochFlags"; - title = "Epoch flags per GET4; GET4 chip # ; Type"; - TH2I* hGet4EpochFlags = new TH2I(name, title, fNrOfGet4, 0., fNrOfGet4, 4, 0., - 4.); -// hEpochFlags = new TH2I(name, title, uNbFeets*feetv1::kuChipPerFeet, -0.5, uNbFeets*feetv1::kuChipPerFeet -0.5, 4, -0.5, 3.5); - hGet4EpochFlags->GetYaxis()->SetBinLabel(1, "SYNC"); - hGet4EpochFlags->GetYaxis()->SetBinLabel(2, "Ep LOSS"); - hGet4EpochFlags->GetYaxis()->SetBinLabel(3, "Da LOSS"); - hGet4EpochFlags->GetYaxis()->SetBinLabel(4, "MISSMAT"); - fHM->Add(name.Data(), hGet4EpochFlags); - if (server) - server->Register("/TofRaw", fHM->H2(name.Data())); - - // Slow control messages analysis - name = "hScmScalerCounters"; - title = "Content of Scaler counter SC messages; Scaler counter [hit]; Channel []"; - fhScmScalerCounters = new TH2I(name, title, fNrOfGet4 * fNrOfChannelsPerGet4 * 2, 0., fNrOfGet4 * fNrOfChannelsPerGet4, - 8192, 0., 8192.); - fHM->Add(name.Data(), fhScmScalerCounters); - if (server) - server->Register("/TofRaw", fhScmScalerCounters ); - - name = "hScmDeadtimeCounters"; - title = "Content of Deadtime counter SC messages; Deadtime [Clk Cycles]; Channel []"; - fhScmDeadtimeCounters = new TH2I(name, title, fNrOfGet4 * fNrOfChannelsPerGet4 * 2, 0., fNrOfGet4 * fNrOfChannelsPerGet4, - 8192, 0., 8192.); - fHM->Add(name.Data(), fhScmDeadtimeCounters); - if (server) - server->Register("/TofRaw", fhScmDeadtimeCounters ); - - name = "hScmSeuCounters"; - title = "Content of SEU counter SC messages; SEU []; Channel []"; - fhScmSeuCounters = new TH2I(name, title, fNrOfGet4 * fNrOfChannelsPerGet4 * 2, 0., fNrOfGet4 * fNrOfChannelsPerGet4, - 8192, 0., 8192.); - fHM->Add(name.Data(), fhScmSeuCounters); - if (server) - server->Register("/TofRaw", fhScmSeuCounters ); - - name = "hScmSeuCountersEvo"; - title = "SEU counter rate from SC messages; Time in Run [s]; Channel []; SEU []"; - fhScmSeuCountersEvo = new TH2I(name, title, fNrOfGet4 * fNrOfChannelsPerGet4 * 2, 0., fNrOfGet4 * fNrOfChannelsPerGet4, - fuHistoryHistoSize, 0., fuHistoryHistoSize); - fHM->Add(name.Data(), fhScmSeuCountersEvo); - if (server) - server->Register("/TofRaw", fhScmSeuCountersEvo ); - - name = "hScmStartMessDist"; - title = "Start message time interval distribution for GET4 #0; Time interval [s]; Counts []"; - fhScmStartMessDist = new TH1I(name, title, 10000, 0., 10.); - fHM->Add(name.Data(), fhScmStartMessDist); - if (server) - server->Register("/TofRaw", fhScmStartMessDist ); - - name = "hScmStartMessEvo"; - title = "Start message rate for GET4 #0; Time in Run [s]; Start Mess []"; - fhScmStartMessEvo = new TH1I(name, title, fuHistoryHistoSize, 0., fuHistoryHistoSize); - fHM->Add(name.Data(), fhScmStartMessEvo); - if (server) - server->Register("/TofRaw", fhScmStartMessEvo ); - - // Prepare storing of hit time info - if( fUnpackPar->IsChannelRateEnabled() || fbPulserMode ) - { - fTsLastHit.resize( fNrOfGdpbs ); - for( UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; uGdpb++) - { - fTsLastHit[ uGdpb ].resize( fNrOfGet4PerGdpb ); - for( UInt_t uGet4 = 0; uGet4 < fNrOfGet4PerGdpb; uGet4++) - { - fTsLastHit[ uGdpb ][ uGet4 ].resize( fNrOfChannelsPerGet4 ); - for( UInt_t uCh = 0; uCh < fNrOfChannelsPerGet4; uCh++) - fTsLastHit[ uGdpb ][ uGet4 ][ uCh ] = -1; - } // for( UInt_t uGet4 = 0; uGet4 < fNrOfGet4PerGdpb; uGet4++) - } // for( UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; uGdpb++) - } // if( fUnpackPar->IsChannelRateEnabled() || fbPulserMode ) - - if (fUnpackPar->IsChannelRateEnabled()) { - for (UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; uGdpb++) { - const Int_t iNbBinsRate = 82; - Double_t dBinsRate[iNbBinsRate] = { 1e0, 2e0, 3e0, 4e0, 5e0, 6e0, 7e0, - 8e0, 9e0, 1e1, 2e1, 3e1, 4e1, 5e1, 6e1, 7e1, 8e1, 9e1, 1e2, 2e2, 3e2, - 4e2, 5e2, 6e2, 7e2, 8e2, 9e2, 1e3, 2e3, 3e3, 4e3, 5e3, 6e3, 7e3, 8e3, - 9e3, 1e4, 2e4, 3e4, 4e4, 5e4, 6e4, 7e4, 8e4, 9e4, 1e5, 2e5, 3e5, 4e5, - 5e5, 6e5, 7e5, 8e5, 9e5, 1e6, 2e6, 3e6, 4e6, 5e6, 6e6, 7e6, 8e6, 9e6, - 1e7, 2e7, 3e7, 4e7, 5e7, 6e7, 7e7, 8e7, 9e7, 1e8, 2e8, 3e8, 4e8, 5e8, - 6e8, 7e8, 8e8, 9e8, 1e9 }; - name = Form("ChannelRate_gDPB_%02u_0", uGdpb); - title = Form("Channel instant rate gDPB %02u; Dist[ns] ; Channel", uGdpb); - fHM->Add(name.Data(), - new TH2F( name.Data(), title.Data(), iNbBinsRate - 1, dBinsRate, - uNbFeetPlot*fNrOfChannelsPerFeet, 0, uNbFeetPlot*fNrOfChannelsPerFeet)); - if (server) - server->Register("/TofRaw", fHM->H2(name.Data())); - if( uNbFeetPlot < fNrOfFebsPerGdpb ) - { - name = Form("ChannelRate_gDPB_%02u_1", uGdpb); - title = Form("Channel instant rate gDPB %02u; Dist[ns] ; Channel", uGdpb); - fHM->Add(name.Data(), - new TH2F( name.Data(), title.Data(), iNbBinsRate - 1, dBinsRate, - uNbFeetPlot*fNrOfChannelsPerFeet, - uNbFeetPlot*fNrOfChannelsPerFeet, - 2*uNbFeetPlot*fNrOfChannelsPerFeet)); - if (server) - server->Register("/TofRaw", fHM->H2(name.Data())); - } // if( uNbFeetPlot < fNrOfFebsPerGdpb ) - if( 2 * uNbFeetPlot < fNrOfFebsPerGdpb ) - { - name = Form("ChannelRate_gDPB_%02u_2", uGdpb); - title = Form("Channel instant rate gDPB %02u; Dist[ns] ; Channel", uGdpb); - fHM->Add(name.Data(), - new TH2F( name.Data(), title.Data(), iNbBinsRate - 1, dBinsRate, - uNbFeetPlot*fNrOfChannelsPerFeet, - 2*uNbFeetPlot*fNrOfChannelsPerFeet, - 3*uNbFeetPlot*fNrOfChannelsPerFeet)); - if (server) - server->Register("/TofRaw", fHM->H2(name.Data())); - } // if( 2 * uNbFeetPlot < fNrOfFebsPerGdpb ) - - LOG(info) << "Adding the rate histos"; - } // for( UInt_t uGdpb = 0; uGdpb < fuMinNbGdpb; uGdpb ++) - } - - if( fbPulserMode ) - { - // Full Fee time difference test - UInt_t uNbBinsDt = kuNbBinsDt + 1; // To account for extra bin due to shift by 1/2 bin of both ranges - - if( fbGet4v20 && !fbGet4M24b ) - { - Double_t dBinSzG4v2 = (6250. / 112.); - dMinDt = -1.*(kuNbBinsDt*dBinSzG4v2/2.) - dBinSzG4v2/2.; - dMaxDt = 1.*(kuNbBinsDt*dBinSzG4v2/2.) + dBinSzG4v2/2.; - } // if( fbGet4v20 && fbGet4M24b ) - - for( UInt_t uChanFeeA = 0; uChanFeeA < fNrOfChannelsPerFeet; uChanFeeA++) - { - for( UInt_t uChanFeeB = uChanFeeA + 1; uChanFeeB < fNrOfChannelsPerFeet; uChanFeeB++) - { - fhTimeDiffPulserChosenFee.push_back( - new TH1I( - Form("hTimeDiffPulserChosenFee_%03u_%03u", uChanFeeA, uChanFeeB), - Form("Time difference for channels %03u and %03u in chosen Fee; DeltaT [ps]; Counts", - uChanFeeA, uChanFeeB), - uNbBinsDt, dMinDt, dMaxDt) ); - if (server) - server->Register("/TofFt", fhTimeDiffPulserChosenFee[ fhTimeDiffPulserChosenFee.size() - 1] ); - } // for any unique pair of channel in chosen Fee - } // for( UInt_t uChanFeeA = 0; uChanFeeA < kuNbChanFee; uChanFeeA++) - - // Selected channels test - fhTimeDiffPulserChosenChPairs.resize( kuNbChanTest - 1 ); - for( UInt_t uChan = 0; uChan < kuNbChanTest - 1; uChan++) - { - fhTimeDiffPulserChosenChPairs[uChan] = new TH1I( - Form("hTimeDiffPulserChosenChPairs_%03u_%03u", fuPulserChan[uChan], fuPulserChan[uChan+1]), - Form("Time difference for selected channels %03u and %03u in the first gDPB; DeltaT [ps]; Counts", - fuPulserChan[uChan], fuPulserChan[uChan+1]), - uNbBinsDt, dMinDt, dMaxDt); - if (server) - server->Register("/TofRaw", fhTimeDiffPulserChosenChPairs[uChan] ); - } // for( UInt_t uChan = 0; uChan < kuNbChanTest - 1; uChan++) - - name = "hTimeRmsPulserChosenFee"; - fhTimeRmsPulserChosenFee = new TH2D( name.Data(), - "Time difference RMS for any channels pair in chosen Fee; Ch A; Ch B; RMS [ps]", - fNrOfChannelsPerFeet - 1, -0.5, fNrOfChannelsPerFeet - 1.5, - fNrOfChannelsPerFeet - 1, 0.5, fNrOfChannelsPerFeet - 0.5); - fHM->Add( name.Data(), fhTimeRmsPulserChosenFee); - if (server) - server->Register("/TofRaw", fHM->H2( name.Data() ) ); - - name = "hTimeRmsPulserChosenChPairs"; - fhTimeRmsPulserChosenChPairs = new TH1D( name.Data(), - "Time difference RMS for chosen channels pairs; Pair # ; [ps]", - kuNbChanTest - 1, -0.5, kuNbChanTest - 1.5); - fHM->Add( name.Data(), fhTimeRmsPulserChosenChPairs); - if (server) - server->Register("/TofRaw", fHM->H1( name.Data() ) ); - - name = "hTimeRmsZoomPulsChosenFee"; - fhTimeRmsZoomPulsChosenFee = new TH2D( name.Data(), - "Time difference RMS after zoom for any channels pair in chosen Fee; Ch A; Ch B; RMS [ps]", - fNrOfChannelsPerFeet - 1, -0.5, fNrOfChannelsPerFeet - 1.5, - fNrOfChannelsPerFeet - 1, 0.5, fNrOfChannelsPerFeet - 0.5); - fHM->Add( name.Data(), fhTimeRmsZoomPulsChosenFee); - if (server) - server->Register("/TofRaw", fHM->H2( name.Data() ) ); - - name = "hTimeRmsZoomFitPulsChosenChPairs"; - fhTimeRmsZoomFitPulsChosenChPairs = new TH1D( name.Data(), - "Time difference RMS after zoom for chosen channels pairs; Pair # ; RMS [ps]", - kuNbChanTest - 1, -0.5, kuNbChanTest - 1.5); - fHM->Add( name.Data(), fhTimeRmsZoomFitPulsChosenChPairs); - if (server) - server->Register("/TofRaw", fHM->H1( name.Data() ) ); - - name = "hTimeResFitPulsChosenFee"; - fhTimeResFitPulsChosenFee = new TH2D( name.Data(), - "Time difference Res from fit for any channels pair in chosen Fee; Ch A; Ch B; Sigma [ps]", - fNrOfChannelsPerFeet - 1, -0.5, fNrOfChannelsPerFeet - 1.5, - fNrOfChannelsPerFeet - 1, 0.5, fNrOfChannelsPerFeet - 0.5); - fHM->Add( name.Data(), fhTimeResFitPulsChosenFee); - if (server) - server->Register("/TofRaw", fHM->H2( name.Data() ) ); - - name = "hTimeResFitPulsChosenChPairs"; - fhTimeResFitPulsChosenChPairs = new TH1D( name.Data(), - "Time difference Res from fit for chosen channels pairs; Pair # ; Sigma [ps]", - kuNbChanTest - 1, -0.5, kuNbChanTest - 1.5); - fHM->Add( name.Data(), fhTimeResFitPulsChosenChPairs); - if (server) - server->Register("/TofRaw", fHM->H1( name.Data() ) ); - } // if( fbPulserMode ) - - if( fbGet4M24b ) - { - fviFtLastRise24b.resize( fNrOfGdpbs * fNrOfFebsPerGdpb ); - fviFtLastFall24b.resize( fNrOfGdpbs * fNrOfFebsPerGdpb ); - fvdTimeLastRise24b.resize( fNrOfGdpbs * fNrOfFebsPerGdpb ); - fvdTimeLastFall24b.resize( fNrOfGdpbs * fNrOfFebsPerGdpb ); - } // if( fbGet4M24b ) - - for (UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; uGdpb++) { - name = Form("Raw_Tot_gDPB_%02u_0", uGdpb); - title = Form("Raw TOT gDPB %02u; channel; TOT [bin]", uGdpb); - fHM->Add(name.Data(), - new TH2F(name.Data(), title.Data(), - uNbFeetPlot*fNrOfChannelsPerFeet, 0, uNbFeetPlot*fNrOfChannelsPerFeet, - 256, 0, 256)); - if (server) - server->Register("/TofRaw", fHM->H2(name.Data())); - if( uNbFeetPlot < fNrOfFebsPerGdpb ) - { - name = Form("Raw_Tot_gDPB_%02u_1", uGdpb); - title = Form("Raw TOT gDPB %02u RPC 1; channel; TOT [bin]", uGdpb); - fHM->Add(name.Data(), - new TH2F(name.Data(), title.Data(), - uNbFeetPlot*fNrOfChannelsPerFeet, - uNbFeetPlot*fNrOfChannelsPerFeet, - 2*uNbFeetPlot*fNrOfChannelsPerFeet, - 256, 0, 256)); - if (server) - server->Register("/TofRaw", fHM->H2(name.Data())); - } // if( uNbFeetPlot < fNrOfFebsPerGdpb ) - if( 2 * uNbFeetPlot < fNrOfFebsPerGdpb ) - { - name = Form("Raw_Tot_gDPB_%02u_2", uGdpb); - title = Form("Raw TOT gDPB %02u RPC 2; channel; TOT [bin]", uGdpb); - fHM->Add(name.Data(), - new TH2F(name.Data(), title.Data(), - uNbFeetPlot*fNrOfChannelsPerFeet, - 2*uNbFeetPlot*fNrOfChannelsPerFeet, - 3*uNbFeetPlot*fNrOfChannelsPerFeet, - 256, 0, 256)); - if (server) - server->Register("/TofRaw", fHM->H2(name.Data())); - } // if( 2 * uNbFeetPlot < fNrOfFebsPerGdpb ) - - name = Form("ChCount_gDPB_%02u", uGdpb); - title = Form("Channel counts gDPB %02u; channel; Hits", uGdpb); - fHM->Add(name.Data(), new TH1I(name.Data(), title.Data(), - fNrOfFebsPerGdpb*fNrOfChannelsPerFeet, 0, fNrOfFebsPerGdpb*fNrOfChannelsPerFeet)); - - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - - if( fbGet4M24b ) - { - name = Form("ChCountFall_gDPB_%02u", uGdpb); - title = Form("Channel falling edge counts gDPB %02u; channel; Hits", uGdpb); - fHM->Add(name.Data(), new TH1I(name.Data(), title.Data(), - fNrOfFebsPerGdpb*fNrOfChannelsPerFeet, 0, fNrOfFebsPerGdpb*fNrOfChannelsPerFeet)); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - } // if( fbGet4M24b ) - - for (UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; uFeet++) { - name = Form("FeetRate_gDPB_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "Counts per second in Feet %1u of gDPB %02u; Time[s] ; Counts", uFeet, - uGdpb); - fHM->Add(name.Data(), new TH1F(name.Data(), title.Data(), fuHistoryHistoSize, 0, fuHistoryHistoSize)); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - - name = Form("FeetErrorRate_gDPB_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "Error Counts per second in Feet %1u of gDPB %02u; Time[s] ; Error Counts", uFeet, - uGdpb); - fHM->Add(name.Data(), new TH1F(name.Data(), title.Data(), fuHistoryHistoSize, 0, fuHistoryHistoSize)); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - - name = Form("FeetRateLong_gDPB_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "Counts per minutes in Feet %1u of gDPB %02u; Time[min] ; Counts", uFeet, - uGdpb); - fHM->Add(name.Data(), new TH1F(name.Data(), title.Data(), fuHistoryHistoSizeLong, 0, fuHistoryHistoSizeLong)); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - - name = Form("FeetErrorRateLong_gDPB_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "Error Counts per minutes in Feet %1u of gDPB %02u; Time[min] ; Error Counts", uFeet, - uGdpb); - fHM->Add(name.Data(), new TH1F(name.Data(), title.Data(), fuHistoryHistoSizeLong, 0, fuHistoryHistoSizeLong)); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - - if( 0 < fiBinSizeDatePlots && 0 < fiRunStartDateTimeSec ) { - name = Form("FeetRateDate_gDPB_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "Counts per second in Feet %1u of gDPB %02u; Time[s] ; Counts", uFeet, - uGdpb); - fHM->Add(name.Data(), new TH1F(name.Data(), title.Data(), (5400 / fiBinSizeDatePlots), -10, 5400 - 10)); - ( fHM->H1(name.Data()) )->GetXaxis()->SetTimeDisplay(1); - ( fHM->H1(name.Data()) )->GetXaxis()->SetTimeOffset( fiRunStartDateTimeSec ); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - } // if( 0 < fiBinSizeDatePlots && 0 < fiRunStartDateTimeSec ) - - name = Form("FtDistribPerCh_gDPB_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "FT distribution per channel in Feet %1u of gDPB %02u; Channel [] ; FT [bin]; Counts []", uFeet, - uGdpb); - fHM->Add(name.Data(), new TH2I( name.Data(), title.Data(), - fNrOfChannelsPerFeet, 0, fNrOfChannelsPerFeet, - get4v1x::kuFineCounterSize, 0, get4v1x::kuFineCounterSize)); - if (server) - server->Register("/TofRaw", fHM->H2(name.Data())); - - - name = Form("SelChFtNormDnlRise_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "normalized FT distribution for selected channel, rising edge, in Feet %1u of gDPB %02u; FT Rise [bin]; DNL []", uFeet, - uGdpb); - fHM->Add(name.Data(), new TH1D( name.Data(), title.Data(), - get4v1x::kuFineCounterSize, 0, get4v1x::kuFineCounterSize)); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - - name = Form("FtNormDnlMinRise_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "Minimum of normalized FT distribution per channel, rising edge, in Feet %1u of gDPB %02u; channel []; DNL Min []", uFeet, - uGdpb); - fHM->Add(name.Data(), new TH1D( name.Data(), title.Data(), - fNrOfChannelsPerFeet, 0, fNrOfChannelsPerFeet )); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - - name = Form("FtNormDnlMaxRise_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "maximum of normalized FT distribution per channel, rising edge, in Feet %1u of gDPB %02u; channel []; DNL Max []", uFeet, - uGdpb); - fHM->Add(name.Data(), new TH1D( name.Data(), title.Data(), - fNrOfChannelsPerFeet, 0, fNrOfChannelsPerFeet )); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - -/// ----------------------> INL plots - name = Form("SelChFtNormInlRise_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "INL distribution for selected channel, rising edge, in Feet %1u of gDPB %02u; FT Rise [bin]; INL []", uFeet, - uGdpb); - fHM->Add(name.Data(), new TH1D( name.Data(), title.Data(), - get4v1x::kuFineCounterSize, 0, get4v1x::kuFineCounterSize)); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - - name = Form("FtNormInlMinRise_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "Minimum of INL distribution per channel, rising edge, in Feet %1u of gDPB %02u; channel []; INL Min []", uFeet, - uGdpb); - fHM->Add(name.Data(), new TH1D( name.Data(), title.Data(), - fNrOfChannelsPerFeet, 0, fNrOfChannelsPerFeet )); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - - name = Form("FtNormInlMaxRise_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "maximum of INL distribution per channel, rising edge, in Feet %1u of gDPB %02u; channel []; INL Max []", uFeet, - uGdpb); - fHM->Add(name.Data(), new TH1D( name.Data(), title.Data(), - fNrOfChannelsPerFeet, 0, fNrOfChannelsPerFeet )); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); -/// <-------------------------------- - - if( fbGet4M24b ) - { - name = Form("FtDistribPerChFall_gDPB_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "FT distribution per channel, falling edge, in Feet %1u of gDPB %02u; Channel [] ; FT Fall [bin]; Counts []", uFeet, - uGdpb); - fHM->Add(name.Data(), new TH2I( name.Data(), title.Data(), - fNrOfChannelsPerFeet, 0, fNrOfChannelsPerFeet, - get4v1x::kuFineCounterSize, 0, get4v1x::kuFineCounterSize)); - if (server) - server->Register("/TofRaw", fHM->H2(name.Data())); - - name = Form("SelChFtNormDnlFall_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "normalized FT distribution for selected channel, falling edge, in Feet %1u of gDPB %02u; FT Fall [bin]; DNL []", uFeet, - uGdpb); - fHM->Add(name.Data(), new TH1D( name.Data(), title.Data(), - get4v1x::kuFineCounterSize, 0, get4v1x::kuFineCounterSize)); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - - name = Form("FtNormDnlMinFall_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "Minimum of normalized FT distribution per channel, falling edge, in Feet %1u of gDPB %02u; channel []; DNL Min []", uFeet, - uGdpb); - fHM->Add(name.Data(), new TH1D( name.Data(), title.Data(), - fNrOfChannelsPerFeet, 0, fNrOfChannelsPerFeet )); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - - name = Form("FtNormDnlMaxFall_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "maximum of normalized FT distribution per channel, falling edge, in Feet %1u of gDPB %02u; channel []; DNL Max []", uFeet, - uGdpb); - fHM->Add(name.Data(), new TH1D( name.Data(), title.Data(), - fNrOfChannelsPerFeet, 0, fNrOfChannelsPerFeet )); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - -/// ----------------------> INL plots - name = Form("SelChFtNormInlFall_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "INL distribution for selected channel, falling edge, in Feet %1u of gDPB %02u; FT Fall [bin]; INL []", uFeet, - uGdpb); - fHM->Add(name.Data(), new TH1D( name.Data(), title.Data(), - get4v1x::kuFineCounterSize, 0, get4v1x::kuFineCounterSize)); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - - name = Form("FtNormInlMinFall_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "Minimum of INL distribution per channel, falling edge, in Feet %1u of gDPB %02u; channel []; INL Min []", uFeet, - uGdpb); - fHM->Add(name.Data(), new TH1D( name.Data(), title.Data(), - fNrOfChannelsPerFeet, 0, fNrOfChannelsPerFeet )); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - - name = Form("FtNormInlMaxFall_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "maximum of INL distribution per channel, falling edge, in Feet %1u of gDPB %02u; channel []; INL Max []", uFeet, - uGdpb); - fHM->Add(name.Data(), new TH1D( name.Data(), title.Data(), - fNrOfChannelsPerFeet, 0, fNrOfChannelsPerFeet )); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); -/// <-------------------------------- - - fviFtLastRise24b[ uGdpb * fNrOfFebsPerGdpb + uFeet ].resize( fNrOfChannelsPerFeet, -1 ); - fviFtLastFall24b[ uGdpb * fNrOfFebsPerGdpb + uFeet ].resize( fNrOfChannelsPerFeet, -1 ); - fvdTimeLastRise24b[ uGdpb * fNrOfFebsPerGdpb + uFeet ].resize( fNrOfChannelsPerFeet, -1 ); - fvdTimeLastFall24b[ uGdpb * fNrOfFebsPerGdpb + uFeet ].resize( fNrOfChannelsPerFeet, -1 ); - - name = Form("FtLastRiseCurrFall_gDPB_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "FT distribution last rising vs falling edge, in Feet %1u of gDPB %02u; FT last Rise [bin] ; FT Fall [bin]; Counts []", uFeet, - uGdpb); - fHM->Add(name.Data(), new TH2I( name.Data(), title.Data(), - get4v1x::kuFineCounterSize, 0, get4v1x::kuFineCounterSize, - get4v1x::kuFineCounterSize, 0, get4v1x::kuFineCounterSize)); - if (server) - server->Register("/TofRaw", fHM->H2(name.Data())); - - name = Form("FtCurrRiseLastFall_gDPB_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "FT distribution rising vs last falling edge, in Feet %1u of gDPB %02u; FT Rise [bin] ; FT last Fall [bin]; Counts []", uFeet, - uGdpb); - fHM->Add(name.Data(), new TH2I( name.Data(), title.Data(), - get4v1x::kuFineCounterSize, 0, get4v1x::kuFineCounterSize, - get4v1x::kuFineCounterSize, 0, get4v1x::kuFineCounterSize)); - if (server) - server->Register("/TofRaw", fHM->H2(name.Data())); - - name = Form("FtLastRiseDistRise_gDPB_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "Time between rising edges vs rising edge FT, in Feet %1u of gDPB %02u; FT last Rise [] ; Trise - TriseLast[ns]; Counts []", uFeet, - uGdpb); - fHM->Add(name.Data(), new TH2I( name.Data(), title.Data(), - get4v1x::kuFineCounterSize, 0, get4v1x::kuFineCounterSize, - 500, 0.0, 25.0 )); - if (server) - server->Register("/TofRaw", fHM->H2(name.Data())); - - name = Form("FtLastRiseDistFall_gDPB_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "Time between falling edges vs rising edge FT, in Feet %1u of gDPB %02u; FT last Rise [] ; Tfall - TfallLast[ns]; Counts []", uFeet, - uGdpb); - fHM->Add(name.Data(), new TH2I( name.Data(), title.Data(), - get4v1x::kuFineCounterSize, 0, get4v1x::kuFineCounterSize, - 500, 0.0, 25.0 )); - if (server) - server->Register("/TofRaw", fHM->H2(name.Data())); - - } // if( fbGet4M24b ) - } // for( UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; uFeet ++) - - /** Real MS QA **/ - fbFirstEpochInMsFound.push_back( kFALSE ); - - name = Form("fRealMsFineQa_gDPB_%02u", uGdpb); - title = Form("QA check of epoch index in Real MS for gDPB %02u; Ms Idx []; 1st Ep Idx / MS Idx []", uGdpb); - fRealMsFineQa_gDPB.push_back( new TH1D(name.Data(), title.Data(), 10000, -0.5, 10000.0 - 0.5 ) ); - fHM->Add(name.Data(), fRealMsFineQa_gDPB[uGdpb] ); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - - name = Form("fRealMsMidQa_gDPB_%02u", uGdpb); - title = Form("QA check of epoch index in Real MS for gDPB %02u, Mid range; Ms Idx []; 1st Ep Idx / MS Idx []", uGdpb); - fRealMsMidQa_gDPB.push_back( new TProfile(name.Data(), title.Data(), 10000, -0.5, 1e6 - 0.5 ) ); - fHM->Add(name.Data(), fRealMsMidQa_gDPB[uGdpb] ); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - - name = Form("fRealMsCoarseQa_gDPB_%02u", uGdpb); - title = Form("QA check of epoch index in Real MS for gDPB %02u, Coarse range; Ms Idx []; 1st Ep Idx / MS Idx []", uGdpb); - fRealMsCoarseQa_gDPB.push_back( new TProfile(name.Data(), title.Data(), 10000, -0.5, 1e9 - 0.5 ) ); - fHM->Add(name.Data(), fRealMsCoarseQa_gDPB[uGdpb] ); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - } // for( UInt_t uGdpb = 0; uGdpb < fuMinNbGdpb; uGdpb ++) - fhTempHistInlRise = new TH1D( "TempHistInlRise", - "Temp holder for INL distribution in current channel, rising edge; FT Rise [bin]; INL []", - get4v1x::kuFineCounterSize, 0, get4v1x::kuFineCounterSize); - if( fbGet4M24b ) - fhTempHistInlFall = new TH1D( "TempHistInlFall", - "Temp holder for INL distribution in current channel, falling edge; FT Fall [bin]; INL []", - get4v1x::kuFineCounterSize, 0, get4v1x::kuFineCounterSize); - - ///* ASIC coincidences & offsets mapping */// -/* - fvulHitEpochBuffLastTs.resize(fNrOfGet4); //! Dims: [gDPB][hits] - for( UInt_t uAsicA = 0; uAsicA < fNrOfGet4 - 1; uAsicA ++ ) - { - name = Form("fvhCoincOffsetEpochGet4__g%03u", uAsicA); - title = Form( - "Distance in epoch between hits in Get4 %03u and hits in another Get4 ASIC in same TS; GET4 B index [] ; Hit B - Hit A [Epoch]; Counts []", - uAsicA ); - TH2* ph2 = new TH2I( name.Data(), title.Data(), - fNrOfGet4 - uAsicA - 1, uAsicA + 1, fNrOfGet4, - 20000, -10000, 10000 - ); - fvhCoincOffsetEpochGet4.push_back( ph2 ); - - fHM->Add( name.Data(), ph2 ); - if (server) - server->Register("/TofCoinc", fHM->H2(name.Data())); - } // for( UInt_t uAsicA = 0; uAsicA < fNrOfGet4 - 1; uAsicA ++ ) -*/ - - name = "hSpill"; - title = "Counts per channel in Current Spill; X [Strip]; Y [End]; Counts"; - TH2I* hSpill = new TH2I(name, title, fNrOfChannelsPerFeet, 0., fNrOfChannelsPerFeet, 2, 0., 2.); - fHM->Add(name.Data(), hSpill); - if (server) - server->Register("/TofRaw", fHM->H2(name.Data())); - - name = "hSpillLength"; - title = "Length of spill interval as found from detectors; Length [s]; Counts"; - TH1* hSpillLength = new TH1F(name, title, 3000, 0., 300.); - fHM->Add(name.Data(), hSpillLength); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - - name = "hSpillCount"; - title = "Total counts in detector in each spill; Spill; Counts"; - TH1* hSpillCount = new TH1F(name, title, 300, 0., 300.); - fHM->Add(name.Data(), hSpillCount); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - - name = "hSpillQA"; - title = "Total counts in detector per spill VS Spill length; Length [s]; Counts"; - TH2* hSpillQA = new TH2F(name, title, 120, 0., 120., 150, 0., 150000.); - fHM->Add(name.Data(), hSpillQA); - if (server) - server->Register("/TofRaw", fHM->H2(name.Data())); - - name = "hTokenMsgType"; - title = "STAR trigger Messages type; Type ; Counts"; - fhTokenMsgType = new TH1F(name, title, 4, 0, 4); - fhTokenMsgType->GetXaxis()->SetBinLabel( 1, "A"); // gDPB TS high - fhTokenMsgType->GetXaxis()->SetBinLabel( 2, "B"); // gDPB TS low, STAR TS high - fhTokenMsgType->GetXaxis()->SetBinLabel( 3, "C"); // STAR TS mid - fhTokenMsgType->GetXaxis()->SetBinLabel( 4, "D"); // STAR TS low, token, CMDs - fHM->Add(name.Data(), fhTokenMsgType); - if (server) - server->Register("/StarRaw", fHM->H1(name.Data())); - - name = "hTriggerRate"; - title = "STAR trigger signals per second; Time[s] ; Counts"; - fhTriggerRate = new TH1F(name, title, fuHistoryHistoSize, 0, fuHistoryHistoSize); - fHM->Add(name.Data(), fhTriggerRate); - if (server) - server->Register("/StarRaw", fHM->H1(name.Data())); - - name = "hCmdDaqVsTrig"; - title = "STAR daq command VS STAR trigger command; DAQ ; TRIGGER"; - fhCmdDaqVsTrig = new TH2I(name, title, 16, 0, 16, 16, 0, 16 ); - fhCmdDaqVsTrig->GetXaxis()->SetBinLabel( 1, "0x0: no-trig "); // idle link - fhCmdDaqVsTrig->GetXaxis()->SetBinLabel( 2, "0x1: clear "); // clears redundancy counters on the readout boards - fhCmdDaqVsTrig->GetXaxis()->SetBinLabel( 3, "0x2: mast-rst"); // general reset of the whole front-end logic - fhCmdDaqVsTrig->GetXaxis()->SetBinLabel( 4, "0x3: spare "); // reserved - fhCmdDaqVsTrig->GetXaxis()->SetBinLabel( 5, "0x4: trigg. 0"); // Default physics readout, all det support required - fhCmdDaqVsTrig->GetXaxis()->SetBinLabel( 6, "0x5: trigg. 1"); // - fhCmdDaqVsTrig->GetXaxis()->SetBinLabel( 7, "0x6: trigg. 2"); // - fhCmdDaqVsTrig->GetXaxis()->SetBinLabel( 8, "0x7: trigg. 3"); // - fhCmdDaqVsTrig->GetXaxis()->SetBinLabel( 9, "0x8: puls. 0"); // - fhCmdDaqVsTrig->GetXaxis()->SetBinLabel(10, "0x9: puls. 1"); // - fhCmdDaqVsTrig->GetXaxis()->SetBinLabel(11, "0xA: puls. 2"); // - fhCmdDaqVsTrig->GetXaxis()->SetBinLabel(12, "0xB: puls. 3"); // - fhCmdDaqVsTrig->GetXaxis()->SetBinLabel(13, "0xC: config "); // housekeeping trigger: return geographic info of FE - fhCmdDaqVsTrig->GetXaxis()->SetBinLabel(14, "0xD: abort "); // aborts and clears an active event - fhCmdDaqVsTrig->GetXaxis()->SetBinLabel(15, "0xE: L1accept"); // - fhCmdDaqVsTrig->GetXaxis()->SetBinLabel(16, "0xF: L2accept"); // - fhCmdDaqVsTrig->GetYaxis()->SetBinLabel( 1, "0x0: 0"); // To be filled at STAR - fhCmdDaqVsTrig->GetYaxis()->SetBinLabel( 2, "0x1: 1"); // To be filled at STAR - fhCmdDaqVsTrig->GetYaxis()->SetBinLabel( 3, "0x2: 2"); // To be filled at STAR - fhCmdDaqVsTrig->GetYaxis()->SetBinLabel( 4, "0x3: 3"); // To be filled at STAR - fhCmdDaqVsTrig->GetYaxis()->SetBinLabel( 5, "0x4: 4"); // To be filled at STAR - fhCmdDaqVsTrig->GetYaxis()->SetBinLabel( 6, "0x5: 5"); // To be filled at STAR - fhCmdDaqVsTrig->GetYaxis()->SetBinLabel( 7, "0x6: 6"); // To be filled at STAR - fhCmdDaqVsTrig->GetYaxis()->SetBinLabel( 8, "0x7: 7"); // To be filled at STAR - fhCmdDaqVsTrig->GetYaxis()->SetBinLabel( 9, "0x8: 8"); // To be filled at STAR - fhCmdDaqVsTrig->GetYaxis()->SetBinLabel(10, "0x9: 9"); // To be filled at STAR - fhCmdDaqVsTrig->GetYaxis()->SetBinLabel(11, "0xA: 10"); // To be filled at STAR - fhCmdDaqVsTrig->GetYaxis()->SetBinLabel(12, "0xB: 11"); // To be filled at STAR - fhCmdDaqVsTrig->GetYaxis()->SetBinLabel(13, "0xC: 12"); // To be filled at STAR - fhCmdDaqVsTrig->GetYaxis()->SetBinLabel(14, "0xD: 13"); // To be filled at STAR - fhCmdDaqVsTrig->GetYaxis()->SetBinLabel(15, "0xE: 14"); // To be filled at STAR - fhCmdDaqVsTrig->GetYaxis()->SetBinLabel(16, "0xF: 15"); // To be filled at STAR - fHM->Add(name.Data(), fhCmdDaqVsTrig); - if (server) - server->Register("/StarRaw", fHM->H2(name.Data())); - - name = "hStarTokenEvo"; - title = "STAR token value VS time; Time in Run [s] ; STAR Token; Counts"; - fhStarTokenEvo = new TH2I(name, title, fuHistoryHistoSize, 0, fuHistoryHistoSize, 410, 0, 4100 ); // 4096 - fHM->Add(name.Data(), fhStarTokenEvo); - if (server) - server->Register("/StarRaw", fHM->H2(name.Data())); - - if( fbStarSortAndCutMode ) - for( UInt_t uGdpb = 0; uGdpb < fuMinNbGdpb; uGdpb ++) - { - name = Form("StarEpToTrig_gDPB%02u", uGdpb); - title = Form("Time to trigger for all hits gDPB %02u; Epoch nb; t(Hit) - t(Trigg) [ns]", uGdpb); - fHM->Add(name.Data(), - new TH2I(name.Data(), title.Data(), - 100, 2662000, 2663000, - 500, -10000000.0, 0.0) ); // TODO make offset parameter - if (server) - server->Register("/StarRaw", fHM->H2(name.Data())); - // TODO: move to proper place!!! - fhStarEpToTrig_gDPB.push_back( fHM->H2(name.Data()) ); - - - name = Form("StarHitToTrigAll_gDPB_%02u", uGdpb); - title = Form("Time to trigger for all hits gDPB %02u; t(Hit) - t(Trigg) [ns]", uGdpb); - fHM->Add(name.Data(), - new TH1I(name.Data(), title.Data(), - 5000, -100000.0, 50000.0) ); // TODO make offset parameter -// 4000, -800000.0, 0.0) ); // TODO make offset parameter - if (server) - server->Register("/StarRaw", fHM->H1(name.Data())); - // TODO: move to proper place!!! - fhStarHitToTrigAll_gDPB.push_back( fHM->H1(name.Data()) ); - - name = Form("StarHitToTrigWin_gDPB_%02u", uGdpb); - title = Form("Time to trigger for hits in trigger window gDPB %02u; t(Hit) - t(Trigg) [ns]", uGdpb); - UInt_t uNbBins = static_cast< UInt_t >( fdStarTriggerWinSize[uGdpb] / 10.0 ); - Double_t dLowBin = -fdStarTriggerDelay[uGdpb]; - Double_t dHighBin = -fdStarTriggerDelay[uGdpb] + fdStarTriggerWinSize[uGdpb]; - fHM->Add(name.Data(), - new TH1I(name.Data(), title.Data(), - uNbBins, dLowBin, dHighBin) ); // TODO make size parameter - if (server) - server->Register("/StarRaw", fHM->H1(name.Data())); - // TODO: move to proper place!!! - fhStarHitToTrigWin_gDPB.push_back( fHM->H1(name.Data()) ); - - name = Form("StarEventSize_gDPB_%02u", uGdpb); - title = Form("STAR SubEvent size gDPB %02u; SubEvent size [bytes]", uGdpb); - uNbBins = static_cast< UInt_t >( CbmTofStarSubevent::GetMaxOutputSize() / 8 ); // 1 bin = 1 long 64b uint - fHM->Add(name.Data(), - new TH1I(name.Data(), title.Data(), - uNbBins, 0.0, CbmTofStarSubevent::GetMaxOutputSize() ) ); // TODO make size parameter - if (server) - server->Register("/StarRaw", fHM->H1(name.Data())); - // TODO: move to proper place!!! - fhStarEventSize_gDPB.push_back( fHM->H1(name.Data()) ); - - name = Form("StarEventSizeTime_gDPB_%02u", uGdpb); - title = Form("STAR SubEvent size gDPB %02u; run time [s]; SubEvent size [bytes]", uGdpb); - uNbBins = static_cast< UInt_t >( CbmTofStarSubevent::GetMaxOutputSize() - / (sizeof( ngdpb::Message )) ); - fHM->Add(name.Data(), - new TH2I(name.Data(), title.Data(), - 360, 0.0, 3600.0, - uNbBins, 0.0, CbmTofStarSubevent::GetMaxOutputSize() ) ); // TODO make size parameter - if (server) - server->Register("/StarRaw", fHM->H1(name.Data())); - // TODO: move to proper place!!! - fhStarEventSizeTime_gDPB.push_back( fHM->H2(name.Data()) ); - } // for( UInt_t uGdpb = 0; uGdpb < fuMinNbGdpb; uGdpb ++) - - if (server) - { - server->RegisterCommand("/Reset_All_TOF", "bResetTofStarHistos=kTRUE"); - server->RegisterCommand("/Save_All_Tof", "bSaveTofStarHistos=kTRUE"); - - server->RegisterCommand("/Cycle_Pulser_FEE", "bTofCyclePulserFee=kTRUE"); - server->RegisterCommand("/Update_Norm_FT", "bTofUpdateNormedFt=kTRUE"); - - if( fbPulserMode ) - server->RegisterCommand("/Update_Zoom_Fit", "bTofUpdateZoomedFit=kTRUE"); - - - server->Restrict("/Reset_All_TOF", "allow=admin"); - server->Restrict("/Save_All_Tof", "allow=admin"); - } // if (server) - - LOG(info) << "Done with histo creation, now doing canvases"; - - /** Create summary Canvases for STAR 2017 **/ - Double_t w = 10; - Double_t h = 10; - TCanvas* cSummary = new TCanvas("cSummary", "gDPB Monitoring Summary", w, h); - cSummary->Divide(2, 3); - - // 1st Column: Messages types - cSummary->cd(1); - gPad->SetLogy(); - hMessageType->Draw(); - - cSummary->cd(2); - gPad->SetLogy(); - hSysMessType->Draw(); - - cSummary->cd(3); - gPad->SetLogz(); - hGet4MessType->Draw("colz"); - - // 2nd Column: GET4 Errors + Epoch flags + - cSummary->cd(4); - gPad->SetLogz(); - hGet4ChanErrors->Draw("colz"); - - cSummary->cd(5); - gPad->SetLogz(); - hGet4EpochFlags->Draw("colz"); - - cSummary->cd(6); - hSpill->Draw("col text"); - /*****************************/ - - - /** Create FEET rates Canvas for STAR 2017 **/ - TCanvas* cFeeRates = new TCanvas("cFeeRates", "gDPB Monitoring FEET rates", w, h); - cFeeRates->Divide(fNrOfFebsPerGdpb, fNrOfGdpbs ); - - TH1* histPnt = NULL; - for( UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; ++uGdpb ) { - for (UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; ++uFeet ) { - name = Form("FeetRate_gDPB_g%02u_f%1u", uGdpb, uFeet); - histPnt = fHM->H1(name.Data()); - - cFeeRates->cd( 1 + uGdpb * fNrOfFebsPerGdpb + uFeet ); - gPad->SetLogy(); - - histPnt->Draw(); - - name = Form("FeetErrorRate_gDPB_g%02u_f%1u", uGdpb, uFeet); - histPnt = fHM->H1(name.Data()); - histPnt->SetLineColor( kRed ); - histPnt->Draw("same"); - } // for (UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; ++uFeet ) - } // for( UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; ++uGdpb ) - /*****************************/ - - - /** Create FEET rates long Canvas for STAR 2017 **/ - TCanvas* cFeeRatesLong = new TCanvas("cFeeRatesLong", "gDPB Monitoring FEET rates", w, h); - cFeeRatesLong->Divide(fNrOfFebsPerGdpb, fNrOfGdpbs ); - - histPnt = NULL; - for( UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; ++uGdpb ) { - for (UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; ++uFeet ) { - name = Form("FeetRateLong_gDPB_g%02u_f%1u", uGdpb, uFeet); - histPnt = fHM->H1(name.Data()); - - cFeeRatesLong->cd( 1 + uGdpb * fNrOfFebsPerGdpb + uFeet ); - gPad->SetLogy(); - - histPnt->Draw(); - - name = Form("FeetErrorRateLong_gDPB_g%02u_f%1u", uGdpb, uFeet); - histPnt = fHM->H1(name.Data()); - histPnt->SetLineColor( kRed ); - histPnt->Draw("same"); - } // for (UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; ++uFeet ) - } // for( UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; ++uGdpb ) - /*****************************/ - - /** Create TOT Canvas(es) for STAR 2017 **/ - TCanvas* cTotPnt = NULL; - uNbFeetPlotsPerGdpb = fNrOfFebsPerGdpb/uNbFeetPlot + ( 0 != fNrOfFebsPerGdpb%uNbFeetPlot ? 1 : 0 ); - for( UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; ++uGdpb ) { - - cTotPnt = new TCanvas( Form("cTotPnt_g%02u", uGdpb), - Form("gDPB %02u TOT distributions", uGdpb), - w, h); - cTotPnt->Divide( uNbFeetPlotsPerGdpb ); - TH2* histPntTot = NULL; - for (UInt_t uFeetPlot = 0; - uFeetPlot < uNbFeetPlotsPerGdpb; - ++uFeetPlot ) { - name = Form("Raw_Tot_gDPB_%02u_%1u", uGdpb, uFeetPlot); - histPntTot = fHM->H2(name.Data()); - - cTotPnt->cd( 1 + uFeetPlot ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - - histPntTot->Draw( "colz" ); - } // for (UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; ++uFeet ) - } // for( UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; ++uGdpb ) - /*****************************/ - - /** Create FT Canvas(es) for STAR 2017 **/ - TCanvas* cFtPnt = NULL; - for( UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; ++uGdpb ) { - - cFtPnt = new TCanvas( Form("cFtPnt_g%02u", uGdpb), - Form("gDPB %02u FineTime distributions", uGdpb), - w, h); - cFtPnt->Divide( fNrOfFebsPerGdpb ); - TH2* histPntFt = NULL; - for( UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; uFeet ++) { - name = Form("FtDistribPerCh_gDPB_g%02u_f%1u", uGdpb, uFeet); - histPntFt = fHM->H2(name.Data()); - - cFtPnt->cd( 1 + uFeet ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - - histPntFt->Draw( "colz" ); - } // for (UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; ++uFeet ) - } // for( UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; ++uGdpb ) - /*****************************/ - - - /** Create 24b mode Canvas(es) for STAR 2017 **/ - if( fbGet4M24b ) - { - TCanvas* cFt24b = NULL; - TCanvas* cFt24b_Dnl = NULL; - TCanvas* cFt24b_Inl = NULL; - for( UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; ++uGdpb ) { - - cFt24b = new TCanvas( Form("cFt24b_g%02u_f0", uGdpb), - Form("gDPB %02u Feet 0 24b mode FineTime distributions", uGdpb), - w, h); - cFt24b->Divide( 2, 4 ); - - cFt24b->cd( 1 ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - name = Form("FtDistribPerCh_gDPB_g%02u_f%1u", uGdpb, 0); - fHM->H2(name.Data())->Draw( "colz" ); - - cFt24b->cd( 2 ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - name = Form("FtDistribPerChFall_gDPB_g%02u_f%1u", uGdpb, 0); - fHM->H2(name.Data())->Draw( "colz" ); - - cFt24b->cd( 3 ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); -// name = Form("ChCount_gDPB_%02u", uGdpb); - name = Form("SelChFtNormDnlRise_g%02u_f%1u", uGdpb, 0); - fHM->H1(name.Data())->Draw(); - - cFt24b->cd( 4 ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); -// name = Form("ChCountFall_gDPB_%02u", uGdpb); - name = Form("SelChFtNormDnlFall_g%02u_f%1u", uGdpb, 0); - fHM->H1(name.Data())->Draw(); - - cFt24b->cd( 5 ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - name = Form("FtLastRiseCurrFall_gDPB_g%02u_f%1u", uGdpb, 0); - fHM->H2(name.Data())->Draw( "colz" ); - - cFt24b->cd( 6 ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - name = Form("FtCurrRiseLastFall_gDPB_g%02u_f%1u", uGdpb, 0); - fHM->H2(name.Data())->Draw( "colz" ); - - cFt24b->cd( 7 ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - name = Form("FtLastRiseDistRise_gDPB_g%02u_f%1u", uGdpb, 0); - fHM->H2(name.Data())->Draw( "colz" ); - - cFt24b->cd( 8 ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - name = Form("FtLastRiseDistFall_gDPB_g%02u_f%1u", uGdpb, 0); - fHM->H2(name.Data())->Draw( "colz" ); - - - cFt24b_Dnl = new TCanvas( Form("cFt24bDnl_g%02u_f0", uGdpb), - Form("gDPB %02u Feet 0 24b mode FineTime DNL min/max distributions", uGdpb), - w, h); - cFt24b_Dnl->Divide( 2, 2 ); - - cFt24b_Dnl->cd( 1 ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - name = Form("FtNormDnlMinRise_g%02u_f%1u", uGdpb, 0); - fHM->H1(name.Data())->Draw(); - - cFt24b_Dnl->cd( 2 ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - name = Form("FtNormDnlMaxRise_g%02u_f%1u", uGdpb, 0); - fHM->H1(name.Data())->Draw(); - - cFt24b_Dnl->cd( 3 ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - name = Form("FtNormDnlMinFall_g%02u_f%1u", uGdpb, 0); - fHM->H1(name.Data())->Draw(); - - cFt24b_Dnl->cd( 4 ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - name = Form("FtNormDnlMaxFall_g%02u_f%1u", uGdpb, 0); - fHM->H1(name.Data())->Draw(); - - cFt24b_Inl = new TCanvas( Form("cFt24bInl_g%02u_f0", uGdpb), - Form("gDPB %02u Feet 0 24b mode FineTime INL min/max distributions", uGdpb), - w, h); - cFt24b_Inl->Divide( 2, 2 ); - - cFt24b_Inl->cd( 1 ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - name = Form("FtNormInlMinRise_g%02u_f%1u", uGdpb, 0); - fHM->H1(name.Data())->Draw(); - - cFt24b_Inl->cd( 2 ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - name = Form("FtNormInlMaxRise_g%02u_f%1u", uGdpb, 0); - fHM->H1(name.Data())->Draw(); - - cFt24b_Inl->cd( 3 ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - name = Form("FtNormInlMinFall_g%02u_f%1u", uGdpb, 0); - fHM->H1(name.Data())->Draw(); - - cFt24b_Inl->cd( 4 ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - name = Form("FtNormInlMaxFall_g%02u_f%1u", uGdpb, 0); - fHM->H1(name.Data())->Draw(); - } // for( UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; ++uGdpb ) - } // if( fbGet4M24b ) - /*****************************/ - - /** Create 32b mode Canvas(es) for STAR 2017 **/ - else - { - TCanvas* cFt32b = NULL; - for( UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; ++uGdpb ) { - - cFt32b = new TCanvas( Form("cFt32b_g%02u_f0", uGdpb), - Form("gDPB %02u Feet 0 32b mode FineTime, DNL & INL distributions", uGdpb), - w, h); - cFt32b->Divide( 2, 3 ); - - cFt32b->cd( 1 ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - name = Form("SelChFtNormDnlRise_g%02u_f%1u", uGdpb, 0); - fHM->H1(name.Data())->Draw("hist"); - - cFt32b->cd( 2 ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - name = Form("SelChFtNormInlRise_g%02u_f%1u", uGdpb, 0); - fHM->H1(name.Data())->Draw("hist"); - - cFt32b->cd( 3 ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - name = Form("FtNormDnlMinRise_g%02u_f%1u", uGdpb, 0); - fHM->H1(name.Data())->Draw("hist"); - - cFt32b->cd( 4 ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - name = Form("FtNormDnlMaxRise_g%02u_f%1u", uGdpb, 0); - fHM->H1(name.Data())->Draw("hist"); - - cFt32b->cd( 5 ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - name = Form("FtNormInlMinRise_g%02u_f%1u", uGdpb, 0); - fHM->H1(name.Data())->Draw("hist"); - - cFt32b->cd( 6 ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - name = Form("FtNormInlMaxRise_g%02u_f%1u", uGdpb, 0); - fHM->H1(name.Data())->Draw("hist"); - } // for( UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; ++uGdpb ) - } // else of if( fbGet4M24b ) - /*****************************/ - - /** Create Pulser mode Canvas for STAR 2017 **/ - if( fbPulserMode ) - { - TCanvas* cPulserRms = new TCanvas("cPulserRms", "Time difference RMS for chosen FEE and channels in pulser mode", w, h); - cPulserRms->Divide( 2 ); - - cPulserRms->cd(1); - fhTimeRmsPulserChosenFee->Draw( "colz" ); - - cPulserRms->cd(2); - fhTimeRmsPulserChosenChPairs->Draw( "hist" ); - - TCanvas* cPulserFit = new TCanvas("cPulserFit", "Time difference Res from fit for chosen FEE and channels in pulser mode", w, h); - cPulserFit->Divide( 2, 2 ); - - cPulserFit->cd(1); - fhTimeRmsZoomPulsChosenFee->Draw( "colz" ); - - cPulserFit->cd(2); - fhTimeRmsZoomFitPulsChosenChPairs->Draw( "hist" ); - - cPulserFit->cd(3); - fhTimeResFitPulsChosenFee->Draw( "colz" ); - - cPulserFit->cd(4); - fhTimeResFitPulsChosenChPairs->Draw( "hist" ); - } // if( fbPulserMode ) - /*****************************/ - - /** Create STAR token Canvas for STAR 2017 **/ - TCanvas* cStarToken = new TCanvas("cStarToken", "STAR token detection info", w, h); - cStarToken->Divide( 2, 2 ); - - cStarToken->cd(1); - fhTriggerRate->Draw(); - - cStarToken->cd(2); - fhCmdDaqVsTrig->Draw( "colz" ); - - cStarToken->cd(3); - fhStarTokenEvo->Draw(); - /*****************************/ - - /** Create Event building mode Canvas(es) for STAR 2017 **/ - if( fbStarSortAndCutMode ) - { - for( UInt_t uGdpb = 0; uGdpb < fuMinNbGdpb; uGdpb ++) - { - TCanvas* cStarEvtBuild = new TCanvas( Form("cStarEvt_g%02u", uGdpb), - Form("STAR SubEvent Building for gDPB %02u", uGdpb), - w, h); - cStarEvtBuild->Divide( 2, 2 ); - - cStarEvtBuild->cd(1); - fhStarHitToTrigAll_gDPB[uGdpb]->Draw(); - - cStarEvtBuild->cd(2); - fhStarHitToTrigWin_gDPB[uGdpb]->Draw(); - - cStarEvtBuild->cd(3); - fhStarEventSize_gDPB[uGdpb]->Draw(); - - cStarEvtBuild->cd(4); - fhStarEventSizeTime_gDPB[uGdpb]->Draw( "colz" ); - } // for( UInt_t uGdpb = 0; uGdpb < fuMinNbGdpb; uGdpb ++) - } // if( fbPulserMode ) - /*****************************/ - - - /** Recovers/Create Ms Size Canvas for STAR 2017 **/ - // Try to recover canvas in case it was created already by another monitor - // If not existing, create it - fcMsSizeAll = dynamic_cast<TCanvas *>( gROOT->FindObject( "cMsSizeAll" ) ); - if( NULL == fcMsSizeAll ) - { - fcMsSizeAll = new TCanvas("cMsSizeAll", "Evolution of MS size in last 300 s", w, h); - fcMsSizeAll->Divide( 4, 4 ); - LOG(info) << "Created MS size canvas in TOF monitor"; - } // if( NULL == fcMsSizeAll ) - else LOG(info) << "Recovered MS size canvas in TOF monitor"; - /*****************************/ - - LOG(info) << "Done with canvases creation"; - - /** Store pointers to histograms for STAR 2017 **/ - fHistMessType = fHM->H1("hMessageType"); - fHistSysMessType = fHM->H1("hSysMessType"); - fHistGet4MessType = fHM->H2("hGet4MessType"); - fHistGet4ChanScm = fHM->H2("hGet4ChanScm"); - fHistGet4ChanErrors = fHM->H2("hGet4ChanErrors"); - fHistGet4EpochFlags = fHM->H2("hGet4EpochFlags"); - fHistSpill = fHM->H2("hSpill"); - fHistSpillLength = fHM->H1("hSpillLength"); - fHistSpillCount = fHM->H1("hSpillCount"); - fHistSpillQA = fHM->H2("hSpillQA"); - - for (UInt_t i = 0; i < fNrOfGdpbs; ++i) { - name = Form("Raw_Tot_gDPB_%02u_0", i); - fRaw_Tot_gDPB.push_back(fHM->H2(name.Data())); - if( uNbFeetPlot < fNrOfFebsPerGdpb ) - { - name = Form("Raw_Tot_gDPB_%02u_1", i); - fRaw_Tot_gDPB.push_back(fHM->H2(name.Data())); - } // if( uNbFeetPlot < fNrOfFebsPerGdpb ) - if( 2 * uNbFeetPlot < fNrOfFebsPerGdpb ) - { - name = Form("Raw_Tot_gDPB_%02u_2", i); - fRaw_Tot_gDPB.push_back(fHM->H2(name.Data())); - } // if( 2 * uNbFeetPlot < fNrOfFebsPerGdpb ) - - name = Form("ChCount_gDPB_%02u", i); - fChCount_gDPB.push_back(fHM->H1(name.Data())); - - if( fbGet4M24b ) - { - name = Form("ChCountFall_gDPB_%02u", i); - fChCountFall_gDPB.push_back(fHM->H1(name.Data())); - } // if( fbGet4M24b ) - - if (fUnpackPar->IsChannelRateEnabled()) { - name = Form("ChannelRate_gDPB_%02u_0", i); - fChannelRate_gDPB.push_back(fHM->H2(name.Data())); - if( uNbFeetPlot < fNrOfFebsPerGdpb ) - { - name = Form("ChannelRate_gDPB_%02u_1", i); - fChannelRate_gDPB.push_back(fHM->H2(name.Data())); - } // if( uNbFeetPlot < fNrOfFebsPerGdpb ) - if( 2 * uNbFeetPlot < fNrOfFebsPerGdpb ) - { - name = Form("ChannelRate_gDPB_%02u_2", i); - fChannelRate_gDPB.push_back(fHM->H2(name.Data())); - } // if( 2 * uNbFeetPlot < fNrOfFebsPerGdpb ) - } // if (fUnpackPar->IsChannelRateEnabled()) - - for (UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; uFeet++) { - name = Form("FeetRate_gDPB_g%02u_f%1u", i, uFeet); - fFeetRate_gDPB.push_back(fHM->H1(name.Data())); - name = Form("FeetErrorRate_gDPB_g%02u_f%1u", i, uFeet); - fFeetErrorRate_gDPB.push_back(fHM->H1(name.Data())); - name = Form("FeetRateLong_gDPB_g%02u_f%1u", i, uFeet); - fFeetRateLong_gDPB.push_back(fHM->H1(name.Data())); - name = Form("FeetErrorRateLong_gDPB_g%02u_f%1u", i, uFeet); - fFeetErrorRateLong_gDPB.push_back(fHM->H1(name.Data())); - if( 0 < fiBinSizeDatePlots && 0 < fiRunStartDateTimeSec ) { - name = Form("FeetRateDate_gDPB_g%02u_f%1u", i, uFeet); - fFeetRateDate_gDPB.push_back(fHM->H1(name.Data())); - } // if( 0 < fiBinSizeDatePlots && 0 < fiRunStartDateTimeSec ) - name = Form("FtDistribPerCh_gDPB_g%02u_f%1u", i, uFeet); - fhFtDistribPerCh.push_back(fHM->H2(name.Data())); - name = Form("SelChFtNormDnlRise_g%02u_f%1u", i, uFeet); - fSelChFtNormDnlRise.push_back(fHM->H1(name.Data())); - name = Form("FtNormDnlMinRise_g%02u_f%1u", i, uFeet); - fFtNormDnlMinRise.push_back(fHM->H1(name.Data())); - name = Form("FtNormDnlMaxRise_g%02u_f%1u", i, uFeet); - fFtNormDnlMaxRise.push_back(fHM->H1(name.Data())); - name = Form("SelChFtNormInlRise_g%02u_f%1u", i, uFeet); - fSelChFtNormInlRise.push_back(fHM->H1(name.Data())); - name = Form("FtNormInlMinRise_g%02u_f%1u", i, uFeet); - fFtNormInlMinRise.push_back(fHM->H1(name.Data())); - name = Form("FtNormInlMaxRise_g%02u_f%1u", i, uFeet); - fFtNormInlMaxRise.push_back(fHM->H1(name.Data())); - - if( fbGet4M24b ) - { - name = Form("FtDistribPerChFall_gDPB_g%02u_f%1u", i, uFeet); - fhFtDistribPerChFall.push_back(fHM->H2(name.Data())); - - name = Form("SelChFtNormDnlFall_g%02u_f%1u", i, uFeet); - fSelChFtNormDnlFall.push_back(fHM->H1(name.Data())); - name = Form("FtNormDnlMinFall_g%02u_f%1u", i, uFeet); - fFtNormDnlMinFall.push_back(fHM->H1(name.Data())); - name = Form("FtNormDnlMaxFall_g%02u_f%1u", i, uFeet); - fFtNormDnlMaxFall.push_back(fHM->H1(name.Data())); - name = Form("SelChFtNormInlFall_g%02u_f%1u", i, uFeet); - fSelChFtNormInlFall.push_back(fHM->H1(name.Data())); - name = Form("FtNormInlMinFall_g%02u_f%1u", i, uFeet); - fFtNormInlMinFall.push_back(fHM->H1(name.Data())); - name = Form("FtNormInlMaxFall_g%02u_f%1u", i, uFeet); - fFtNormInlMaxFall.push_back(fHM->H1(name.Data())); - - name = Form("FtLastRiseCurrFall_gDPB_g%02u_f%1u", i, uFeet); - fhFtLastRiseCurrFall.push_back(fHM->H2(name.Data())); - name = Form("FtCurrRiseLastFall_gDPB_g%02u_f%1u", i, uFeet); - fhFtCurrRiseLastFall.push_back(fHM->H2(name.Data())); - - name = Form("FtLastRiseDistRise_gDPB_g%02u_f%1u", i, uFeet); - fhFtLastRiseDistRise.push_back(fHM->H2(name.Data())); - name = Form("FtLastRiseDistFall_gDPB_g%02u_f%1u", i, uFeet); - fhFtLastRiseDistFall.push_back(fHM->H2(name.Data())); - } // if( fbGet4M24b ) - } // for( UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; uFeet ++) - } - /*****************************/ - - LOG(info) << "Leaving CreateHistograms"; -} - -Bool_t CbmTSMonitorTofStar::DoUnpack(const fles::Timeslice& ts, - size_t component) -{ - THttpServer* server = FairRunOnline::Instance()->GetHttpServer(); - - if (bResetTofStarHistos) { - LOG(info) << "Reset TOF STAR histos "; - ResetAllHistos(); - bResetTofStarHistos = kFALSE; - } - if( bSaveTofStarHistos ) - { - LOG(info) << "Start saving TOF STAR histos "; - SaveAllHistos( "data/histos_StarTof.root" ); - bSaveTofStarHistos = kFALSE; - } // if( bSaveStsHistos ) - if (bTofCyclePulserFee) { - CyclePulserFee(); - bTofCyclePulserFee = kFALSE; - } // if (bTofCyclePulserFee) - if (bTofUpdateNormedFt) { - UpdateNormedFt(); - bTofUpdateNormedFt = kFALSE; - } // if (bTofUpdateNormedFt) - if (bTofUpdateZoomedFit) { - UpdateZoomedFit(); - bTofUpdateZoomedFit = kFALSE; - } // if (bTofUpdateZoomedFit) - - ///* ASIC coincidences & offsets mapping */// -/* - if( 0 == component && fbHitsInLastTs ) - { - for( UInt_t uAsicA = 0; uAsicA < fNrOfGet4 - 1; uAsicA ++ ) - { - for( UInt_t uHitA = 0; uHitA < fvulHitEpochBuffLastTs[uAsicA].size(); uHitA ++ ) - { - for( UInt_t uAsicB = uAsicA; uAsicB < fNrOfGet4; uAsicB ++ ) - { - for( UInt_t uHitB = 0; uHitB < fvulHitEpochBuffLastTs[uAsicB].size(); uHitB ++ ) - { - fvhCoincOffsetEpochGet4[uAsicA]->Fill( uAsicB, - fvulHitEpochBuffLastTs[uAsicB][uHitB] - - fvulHitEpochBuffLastTs[uAsicA][uHitA] ); - } // for( UInt_t uHitB = 0; uHitB < fvulHitEpochBuffLastTs[uAsicB].size(); uHitB ++ ) - } // for( UInt_t uAsicA = 0; uAsicA < fNrOfGet4 - 1; uAsicA ++ ) - } // for( UInt_t uHitA = 0; uHitA < fvulHitEpochBuffLastTs[uAsicA].size(); uHitA ++ ) - fvulHitEpochBuffLastTs[uAsicA].clear(); - } // for( UInt_t uAsicA = 0; uAsicA < fNrOfGet4 - 1; uAsicA ++ ) - fvulHitEpochBuffLastTs[fNrOfGet4 - 1].clear(); - fbHitsInLastTs = kFALSE; - } // if( 0 == component && fbHitsInLastTs ) -*/ - - // Printout of nb star events log - std::chrono::time_point<std::chrono::system_clock> timeCurrent = std::chrono::system_clock::now(); - std::chrono::duration<double> elapsed_seconds = timeCurrent - fTimeLastPrintoutNbStarEvent; - if( 0 == fTimeLastPrintoutNbStarEvent.time_since_epoch().count() ) - { - fTimeLastPrintoutNbStarEvent = timeCurrent; - fulNbStarEventLastPrintout = fulNbStarEvent; - } // if( 0 == fTimeLastPrintoutNbStarEvent.time_since_epoch().count() ) - else if( 300 < elapsed_seconds.count() ) - { - std::time_t cTimeCurrent = std::chrono::system_clock::to_time_t( timeCurrent ); - char tempBuff[80]; - std::strftime( tempBuff, 80, "%F %T", localtime (&cTimeCurrent) ); - LOG(info) << "CbmTSMonitorTofStar::DoUnpack => " << tempBuff - << " Total number of STAR events: " << std::setw(9) << fulNbStarEvent - << ", " << std::setw(9) << (fulNbStarEvent - fulNbStarEventLastPrintout) - << " events in last " << std::setw(4) << elapsed_seconds.count() << " s"; - fTimeLastPrintoutNbStarEvent = timeCurrent; - fulNbStarEventLastPrintout = fulNbStarEvent; - - SaveAllHistos( "data/histos_test.root" ); - } // else if( 300 < elapsed_seconds.count() ) - - LOG(debug1) << "Timeslice contains " << ts.num_microslices(component) - << "microslices."; - - // Getting the pointer to the correct histogram needs a lot more time then - // the actual filling procedure. If one gets the pointer in a loop this kills - // the performance. A test shows that extracting the pointer from the CbmHistManger - // is slower by a factor of 20-100 (depending on the number of histos managed by the - // CbmHistManager) compared to using the pointer directly - // So get the pointer once outside the loop and use it in the loop - - TString sMsSzName = Form("MsSz_link_%02lu", component); - TH1* hMsSz = NULL; - TProfile* hMsSzTime = NULL; - if (fHM->Exists(sMsSzName.Data())) { - hMsSz = fHM->H1(sMsSzName.Data()); - sMsSzName = Form("MsSzTime_link_%02lu", component); - hMsSzTime = fHM->P1(sMsSzName.Data()); - } // if( fHM->Exists(sMsSzName.Data() ) ) - else { - TString sMsSzTitle = Form( - "Size of MS for gDPB of link %02lu; Ms Size [bytes]", component); - fHM->Add(sMsSzName.Data(), - new TH1F(sMsSzName.Data(), sMsSzTitle.Data(), 160000, 0., 20000.)); - hMsSz = fHM->H1(sMsSzName.Data()); - if (server) - server->Register("/FlibRaw", hMsSz); - sMsSzName = Form("MsSzTime_link_%02lu", component); - sMsSzTitle = Form( - "Size of MS vs time for gDPB of link %02lu; Time[s] ; Ms Size [bytes]", - component); - fHM->Add(sMsSzName.Data(), - new TProfile( sMsSzName.Data(), sMsSzTitle.Data(), - 100 * fuHistoryHistoSize, 0., 2 * fuHistoryHistoSize ) ); - hMsSzTime = fHM->P1(sMsSzName.Data()); - if (server) - server->Register("/FlibRaw", hMsSzTime); - if( NULL != fcMsSizeAll ) - { - fcMsSizeAll->cd( 1 + component ); - gPad->SetLogy(); - hMsSzTime->Draw("hist le0"); - } // if( NULL != fcMsSizeAll ) - LOG(info) << "Added MS size histo for component: " << component << " (gDPB)"; - } // else of if( fHM->Exists(sMsSzName.Data() ) ) - - // Initialize spill detection - fiCountsLastTs = 0; - - Int_t messageType = -111; - Double_t dTsStartTime = -1; - // Loop over microslices - size_t numCompMsInTs = ts.num_microslices(component); - for (size_t m = 0; m < numCompMsInTs; ++m) { - if (fuMsAcceptsPercent < m) - continue; - - constexpr uint32_t kuBytesPerMessage = 8; - - auto msDescriptor = ts.descriptor(component, m); - fEquipmentId = msDescriptor.eq_id; - fdMsIndex = static_cast<double>(msDescriptor.idx); - const uint8_t* msContent = reinterpret_cast<const uint8_t*>(ts.content( - component, m)); - - uint32_t size = msDescriptor.size; -// fulLastMsIdx = msDescriptor.idx; - if (size > 0) - LOG(debug) << "Microslice: " << msDescriptor.idx << " has size: " << size; - - if( numCompMsInTs - fuOverlapMsNb <= m ) - { -// LOG(info) << "Ignore overlap Microslice: " << msDescriptor.idx; - continue; - } // if( numCompMsInTs - fuOverlapMsNb <= m ) - - if( 0 == m ) - dTsStartTime = (1e-9) * fdMsIndex; - - if( fdStartTimeMsSz < 0 ) - fdStartTimeMsSz = (1e-9) * fdMsIndex; - hMsSz->Fill(size); - if( 2 * fuHistoryHistoSize < (1e-9) * fdMsIndex - fdStartTimeMsSz ) - { - // Reset the evolution Histogram and the start time when we reach the end of the range - hMsSzTime->Reset(); - fdStartTimeMsSz = (1e-9) * fdMsIndex; - } // if( 2 * fuHistoryHistoSize < (1e-9) * fdMsIndex - fdStartTimeMsSz ) - hMsSzTime->Fill((1e-9) * fdMsIndex - fdStartTimeMsSz, size); - - // If not integer number of message in input buffer, print warning/error - if (0 != (size % kuBytesPerMessage)) - LOG(error) << "The input microslice buffer does NOT " - << "contain only complete nDPB messages!"; - - // Compute the number of complete messages in the input microslice buffer - uint32_t uNbMessages = (size - (size % kuBytesPerMessage)) - / kuBytesPerMessage; - - /** Real MS QA **/ - if( -1 == fdFirstMsIndex ) - fdFirstMsIndex = fdMsIndex; - for( UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; uGdpb ++) - fbFirstEpochInMsFound[uGdpb] = kFALSE; - - // Prepare variables for the loop on contents - const uint64_t* pInBuff = reinterpret_cast<const uint64_t*>(msContent); - for (uint32_t uIdx = 0; uIdx < uNbMessages; uIdx++) { - // Fill message - uint64_t ulData = static_cast<uint64_t>(pInBuff[uIdx]); - ngdpb::Message mess(ulData); - - if (gLogger->IsLogNeeded( fair::Severity::debug2 )) - { - mess.printDataCout(); - } // if (gLogger->IsLogNeeded( fair::Severity::debug2 )) - - - // Increment counter for different message types - // and fill the corresponding histogram - messageType = mess.getMessageType(); - fMsgCounter[messageType]++; - fHistMessType->Fill(messageType); - - fGdpbId = mess.getRocNumber(); - fGdpbNr = fGdpbIdIndexMap[fGdpbId]; - - fGet4Id = mess.getGdpbGenChipId(); - fGet4Nr = (fGdpbNr * fNrOfGet4PerGdpb) + fGet4Id; - - if( fNrOfGet4PerGdpb <= fGet4Id && - ngdpb::MSG_STAR_TRI != messageType && - ( get4v1x::kuChipIdMergedEpoch != fGet4Id || - kFALSE == fbMergedEpochsOn ) ) - LOG(warning) << "Message with Get4 ID too high: " << fGet4Id - << " VS " << fNrOfGet4PerGdpb << " set in parameters."; - - switch (messageType) { - case ngdpb::MSG_HIT: - // FillHitInfo(mess); - LOG(error) << "Message type " << messageType - << " not yet included in unpacker."; - break; - case ngdpb::MSG_EPOCH: - // FillEpochInfo(mess); - LOG(error) << "Message type " << messageType - << " not yet included in unpacker."; - break; - case ngdpb::MSG_SYS: - fHistSysMessType->Fill(mess.getSysMesType()); - break; - case ngdpb::MSG_EPOCH2: - { - if( get4v1x::kuChipIdMergedEpoch == fGet4Id && - kTRUE == fbMergedEpochsOn ) - { - for( uint32_t uGet4Index = 0; uGet4Index < fNrOfGet4PerGdpb; uGet4Index ++ ) - { - fGet4Id = uGet4Index; - fGet4Nr = (fGdpbNr * fNrOfGet4PerGdpb) + fGet4Id; - ngdpb::Message tmpMess(mess); - tmpMess.setGdpbGenChipId( uGet4Index ); - - fHistGet4MessType->Fill(fGet4Nr, ngdpb::GET4_32B_EPOCH); - FillEpochInfo(tmpMess); - } // for( uint32_t uGet4Index = 0; uGet4Index < fNrOfGet4PerGdpb; uGetIndex ++ ) - } // if this epoch message is a merged one valiud for all chips - else - { - fHistGet4MessType->Fill(fGet4Nr, ngdpb::GET4_32B_EPOCH); - FillEpochInfo(mess); - } // if single chip epoch message - break; - } - case ngdpb::MSG_GET4: - fHistGet4MessType->Fill(fGet4Nr, ngdpb::GET4_32B_DATA + 1); - if( fbGet4M24b ) - FillHitInfo(mess); - else PrintGenInfo(mess); - break; - case ngdpb::MSG_GET4_32B: - fHistGet4MessType->Fill(fGet4Nr, ngdpb::GET4_32B_DATA); - if( fbEpochSuppModeOn ) - fvmEpSupprBuffer[fGet4Nr].push_back( mess ); - else FillHitInfo(mess); - break; - case ngdpb::MSG_GET4_SLC: - fHistGet4MessType->Fill(fGet4Nr, ngdpb::GET4_32B_SLCM); - PrintSlcInfo(mess); - break; - case ngdpb::MSG_GET4_SYS: { - fHistSysMessType->Fill(mess.getGdpbSysSubType()); - if (ngdpb::SYSMSG_GET4_EVENT == mess.getGdpbSysSubType()) { - fHistGet4MessType->Fill(fGet4Nr, ngdpb::GET4_32B_ERROR); - - UInt_t uFeetNr = (fGet4Id / fNrOfGet4PerFeb); - if (0 <= fdStartTime) - { - fFeetErrorRate_gDPB[(fGdpbNr * fNrOfFebsPerGdpb) + uFeetNr]->Fill( - 1e-9 * (mess.getMsgFullTimeD(fCurrentEpoch[fGet4Nr]) - fdStartTime)); - } // if (0 <= fdStartTime) - if (0 <= fdStartTimeLong) - { - fFeetErrorRateLong_gDPB[(fGdpbNr * fNrOfFebsPerGdpb) + uFeetNr]->Fill( - 1e-9 / 60.0 * (mess.getMsgFullTimeD(fCurrentEpoch[fGet4Nr]) - fdStartTimeLong), 1 / 60.0); - } // if (0 <= fdStartTime) - - Int_t dFullChId = fGet4Nr * fNrOfChannelsPerGet4 + mess.getGdpbSysErrChanId(); - switch (mess.getGdpbSysErrData()) { - case ngdpb::GET4_V1X_ERR_READ_INIT: - fHistGet4ChanErrors->Fill(dFullChId, 0); - break; - case ngdpb::GET4_V1X_ERR_SYNC: - fHistGet4ChanErrors->Fill(dFullChId, 1); - break; - case ngdpb::GET4_V1X_ERR_EP_CNT_SYNC: - fHistGet4ChanErrors->Fill(dFullChId, 2); - break; - case ngdpb::GET4_V1X_ERR_EP: - fHistGet4ChanErrors->Fill(dFullChId, 3); - break; - case ngdpb::GET4_V1X_ERR_FIFO_WRITE: - fHistGet4ChanErrors->Fill(dFullChId, 4); - break; - case ngdpb::GET4_V1X_ERR_LOST_EVT: - fHistGet4ChanErrors->Fill(dFullChId, 5); - break; - case ngdpb::GET4_V1X_ERR_CHAN_STATE: - fHistGet4ChanErrors->Fill(dFullChId, 6); - break; - case ngdpb::GET4_V1X_ERR_TOK_RING_ST: - fHistGet4ChanErrors->Fill(dFullChId, 7); - break; - case ngdpb::GET4_V1X_ERR_TOKEN: - fHistGet4ChanErrors->Fill(dFullChId, 8); - break; - case ngdpb::GET4_V1X_ERR_READOUT_ERR: - fHistGet4ChanErrors->Fill(dFullChId, 9); - break; - case ngdpb::GET4_V1X_ERR_SPI: - fHistGet4ChanErrors->Fill(dFullChId, 10); - break; - case ngdpb::GET4_V1X_ERR_DLL_LOCK: - fHistGet4ChanErrors->Fill(dFullChId, 11); - break; - case ngdpb::GET4_V1X_ERR_DLL_RESET: - fHistGet4ChanErrors->Fill(dFullChId, 12); - break; - case ngdpb::GET4_V1X_ERR_TOT_OVERWRT: - fHistGet4ChanErrors->Fill(dFullChId, 13); - break; - case ngdpb::GET4_V1X_ERR_TOT_RANGE: - fHistGet4ChanErrors->Fill(dFullChId, 14); - break; - case ngdpb::GET4_V1X_ERR_EVT_DISCARD: - fHistGet4ChanErrors->Fill(dFullChId, 15); - break; - case ngdpb::GET4_V1X_ERR_ADD_RIS_EDG: - if( kTRUE == fbGet4v20 ) - fHistGet4ChanErrors->Fill(dFullChId, 16); - else fHistGet4ChanErrors->Fill(dFullChId, 17); - break; - case ngdpb::GET4_V1X_ERR_UNPAIR_FALL: - if( kTRUE == fbGet4v20 ) - fHistGet4ChanErrors->Fill(dFullChId, 17); - else fHistGet4ChanErrors->Fill(dFullChId, 17); - break; - case ngdpb::GET4_V1X_ERR_SEQUENCE_ER: - if( kTRUE == fbGet4v20 ) - fHistGet4ChanErrors->Fill(dFullChId, 18); - else fHistGet4ChanErrors->Fill(dFullChId, 17); - break; - case ngdpb::GET4_V1X_ERR_UNKNOWN: - if( kTRUE == fbGet4v20 ) - fHistGet4ChanErrors->Fill(dFullChId, 19); - else fHistGet4ChanErrors->Fill(dFullChId, 16); - break; - default: // Corrupt error or not yet supported error - if( kTRUE == fbGet4v20 ) - fHistGet4ChanErrors->Fill(dFullChId, 20); - else fHistGet4ChanErrors->Fill(dFullChId, 17); - break; - } // Switch( mess.getGdpbSysErrData() ) - - } - if (100 > iMess) - { - PrintSysInfo(mess); - iMess++; // Separate increment from condition, otherwise increase until wrap to -1664185233 - } // if (100 > iMess) - break; - } - case ngdpb::MSG_STAR_TRI: - fHistGet4MessType->Fill(fGet4Nr, ngdpb::MSG_STAR_TRI); - FillStarTrigInfo(mess); - break; - default: - if (100 > iMess) - { - LOG(error) << "Message (" << iMess << ") type " << std::hex - << std::setw(2) << static_cast<uint16_t>(messageType) - << " not yet included in Get4 unpacker."; - iMess++; // Separate increment from condition, otherwise increase until wrap to -1664185233 - } // if (100 > iMess++) - } // switch( mess.getMessageType() ) - } // for (uint32_t uIdx = 0; uIdx < uNbMessages; uIdx ++) - } // for (size_t m = 0; m < ts.num_microslices(component); ++m) - if (100 == iMess) - { - LOG(error) << "Stop reporting MSG errors... "; - iMess++; // Separate increment from condition, otherwise increase until wrap to -1664185233 - } // if (100 == iMess) - - // Spill detection using Detectors - if( !fbSpillOn && (fiSpillOnThr < fiCountsLastTs) ) - { - fbSpillOn = kTRUE; - fiTsUnderOff = 0; - - if( 0 < fdDetTimeLastTs ) - { - fHistSpillLength->Fill( fdDetLastTime - fdDetTimeLastTs ); - fHistSpillCount->Fill( fSpillIdx, fHistSpill->GetEntries() ); - fHistSpillQA->Fill( fdDetLastTime - fdDetTimeLastTs, - fHistSpill->GetEntries() ); - } // if( 0 < fdTimeLastTs ) - fdDetTimeLastTs = fdDetLastTime; - fSpillIdx++; - fHistSpill->Reset(); - } // if( !fbSpillOn && (fiSpillOnThr < fiCountsLastTs) ) - else if( fbSpillOn ) - { - if( fiCountsLastTs < fiSpillOffThr ) - { - fiTsUnderOff ++; - if( fiTsUnderOffThr < fiTsUnderOff ) - fbSpillOn = kFALSE; - } // if( fiCountsLastTs < fiSpillOffThr ) - else fiTsUnderOff = 0; - } // else if( fbSpillOn ) - - if( kTRUE == fbPulserMode ) - { - // Update RMS plots only every 10s in data - if( 10.0 < dTsStartTime - fdLastRmsUpdateTime ) - { - // Reset summary histograms for safety - fhTimeRmsPulserChosenFee->Reset(); - fhTimeRmsPulserChosenChPairs->Reset(); - - UInt_t uHistoFeeIdx = 0; - for( UInt_t uChanFeeA = 0; uChanFeeA < fNrOfChannelsPerFeet; uChanFeeA++) - { - for( UInt_t uChanFeeB = uChanFeeA + 1; uChanFeeB < fNrOfChannelsPerFeet; uChanFeeB++) - { - fhTimeRmsPulserChosenFee->Fill(uChanFeeA, uChanFeeB, fhTimeDiffPulserChosenFee[uHistoFeeIdx]->GetRMS() ); - uHistoFeeIdx++; - } // for( UInt_t uChanFeeB = uChanFeeA + 1; uChanFeeB < fNrOfChannelsPerFeet; uChanFeeB++) - } // for( UInt_t uChanFeeA = 0; uChanFeeA < fNrOfChannelsPerFeet; uChanFeeA++) - for( UInt_t uChan = 0; uChan < kuNbChanTest - 1; uChan++) - { - fhTimeRmsPulserChosenChPairs->Fill( uChan, fhTimeDiffPulserChosenChPairs[uChan]->GetRMS() ); - } // for( UInt_t uChan = 0; uChan < kuNbChanTest - 1; uChan++) - fdLastRmsUpdateTime = dTsStartTime; - } // if( 10.0 < dTsStartTime - fdLastRmsUpdateTime ) - } // if( kTRUE == fbPulserMode ) - - return kTRUE; -} - -void CbmTSMonitorTofStar::FillHitInfo(ngdpb::Message mess) -{ - Int_t channel = mess.getGdpbHitChanId(); - Int_t tot = mess.getGdpbHit32Tot(); - Int_t Fts = mess.getGdpbHitFineTs(); - - Long64_t curEpochGdpbGet4 = fCurrentEpoch[fGet4Nr]; - - if (curEpochGdpbGet4 != -111) { - - if( fbEpochSuppModeOn ) - { - // In Ep. Suppr. Mode, receive following epoch instead of previous - if( 0 < curEpochGdpbGet4 ) - curEpochGdpbGet4 --; - else curEpochGdpbGet4 = get4v1x::kuEpochCounterSz; // Catch epoch cycle! - } // if( fbEpochSuppModeOn ) - - UInt_t channelNr = fGet4Id * fNrOfChannelsPerGet4 + channel; - UInt_t channelNrInFeet = (fGet4Id % fNrOfGet4PerFeb) * fNrOfChannelsPerGet4 + channel; - UInt_t uFeetNr = (fGet4Id / fNrOfGet4PerFeb); - - ULong_t hitTime; - Double_t dHitTime; - - if( fbGet4v20 ) - { - hitTime = mess.getMsgG4v2FullTime(curEpochGdpbGet4); - dHitTime = mess.getMsgG4v2FullTimeD(curEpochGdpbGet4); - - // In 32b mode the coarse counter is already computed back to 112 FTS bins - // => need to hide its contribution from the Finetime - // => FTS = Fullt TS modulo 112 - if( !fbGet4M24b ) - Fts = mess.getGdpbHitFullTs() % 112; - } // if( fbGet4v20 ) - else - { - hitTime = mess.getMsgFullTime(curEpochGdpbGet4); - dHitTime = mess.getMsgFullTimeD(curEpochGdpbGet4); - } // else of if( fbGet4v20 ) - - if( !fbGet4M24b ) - { - fChCount_gDPB[fGdpbNr]->Fill(channelNr); - if( fRaw_Tot_gDPB.size() <= (fGdpbNr * uNbFeetPlotsPerGdpb + uFeetNr/uNbFeetPlot) ) - { - LOG(warning) << "Index error: " - << Form("%03lu vs %03u (%03u, %03d, %03u)", fRaw_Tot_gDPB.size(), - (fGdpbNr * uNbFeetPlotsPerGdpb + uFeetNr/uNbFeetPlot), - fGdpbNr, uFeetNr, uNbFeetPlot ) - << "\n" - << Form("(%03u, %03d)", fGet4Id, channel ); - mess.printDataCout(); - } - if( NULL == fRaw_Tot_gDPB[fGdpbNr * uNbFeetPlotsPerGdpb + uFeetNr/uNbFeetPlot ] ) - LOG(warning) << "Histo pointer is NULL: " - << Form("%03lu vs %03u (%03u, %03d, %03u)", fRaw_Tot_gDPB.size(), - (fGdpbNr * uNbFeetPlotsPerGdpb + uFeetNr/uNbFeetPlot), - fGdpbNr, uFeetNr, uNbFeetPlot ); - - fRaw_Tot_gDPB[ fGdpbNr * uNbFeetPlotsPerGdpb + uFeetNr/uNbFeetPlot ]->Fill(channelNr, tot); - - /// Finetime monitoring - fhFtDistribPerCh[(fGdpbNr * fNrOfFebsPerGdpb) + uFeetNr]->Fill( - channelNrInFeet, Fts ); - } // if( !fbGet4M24b ) - else - { -/* - fGet4Id = mess.getGet4Number(); - channel = mess.getGet4ChNum(); - UInt_t Fts = mess.getGet4FineTs(); - UInt_t edge = mess.getGet4Edge(); -*/ - Int_t edge = mess.getGdpbHit24Edge(); - - channelNr = fGet4Id * fNrOfChannelsPerGet4 + channel; - uFeetNr = (fGet4Id / fNrOfGet4PerFeb); - UInt_t uFullFebIdx = (fGdpbNr * fNrOfFebsPerGdpb) + uFeetNr; - - if( edge ) - { - fChCountFall_gDPB[fGdpbNr]->Fill(channelNr); - - - /// Finetime monitoring - fhFtDistribPerChFall[uFullFebIdx]->Fill( channelNrInFeet, Fts ); - if( 0 <= fviFtLastRise24b[uFullFebIdx][channelNr] && - fuRiseFallChSel == channelNr) - fhFtLastRiseCurrFall[uFullFebIdx]->Fill( - fviFtLastRise24b[uFullFebIdx][channelNr], - Fts); - if( 0 <= fviFtLastRise24b[uFullFebIdx][channelNr] && - 0 <= fvdTimeLastFall24b[uFullFebIdx][channelNr] && - fuRiseFallChSel == channelNr) - fhFtLastRiseDistFall[uFullFebIdx]->Fill( - fviFtLastRise24b[uFullFebIdx][channelNr], - dHitTime - fvdTimeLastFall24b[uFullFebIdx][channelNr]); - - fviFtLastFall24b[uFullFebIdx][channelNr] = Fts; - fvdTimeLastFall24b[uFullFebIdx][channelNr] = dHitTime; - } // if( edge ) - else - { - fChCount_gDPB[fGdpbNr]->Fill(channelNr); - - /// Finetime monitoring - fhFtDistribPerCh[uFullFebIdx]->Fill( channelNr, Fts ); - if( 0 <= fviFtLastFall24b[uFullFebIdx][channelNr] && - fuRiseFallChSel == channelNr) - fhFtCurrRiseLastFall[uFullFebIdx]->Fill( - Fts, - fviFtLastFall24b[uFullFebIdx][channelNr] ); - if( 0 <= fviFtLastRise24b[uFullFebIdx][channelNr] && - 0 <= fvdTimeLastRise24b[uFullFebIdx][channelNr] && - fuRiseFallChSel == channelNr ) - fhFtLastRiseDistRise[uFullFebIdx]->Fill( - fviFtLastRise24b[uFullFebIdx][channelNr], - dHitTime - fvdTimeLastRise24b[uFullFebIdx][channelNr]); - - fviFtLastRise24b[uFullFebIdx][channelNr] = Fts; - fvdTimeLastRise24b[uFullFebIdx][channelNr] = dHitTime; - } // else of if( edge ) - } // else of if( !fbGet4M24b ) - - if (fUnpackPar->IsChannelRateEnabled() && - ( !fbGet4M24b || !(mess.getGdpbHit24Edge()) )) { - // Check if at least one hit before in this channel - if( -1 < fTsLastHit[fGdpbNr][fGet4Id][channel] ) - { - fChannelRate_gDPB[fGdpbNr + uFeetNr/uNbFeetPlot]->Fill( -// 1e9 / (dHitTime - fTsLastHit[fGdpbNr][fGet4Id][channel]), - (dHitTime - fTsLastHit[fGdpbNr][fGet4Id][channel]), - fGet4Id * fNrOfChannelsPerGet4 + channel); - } // if( -1 < fTsLastHit[fGdpbNr][fGet4Id][channel] ) - } // if( fUnpackPar->IsChannelRateEnabled() ) - - // Save last hist time if channel rate histos or pulser mode enabled - if( fUnpackPar->IsChannelRateEnabled() || fbPulserMode ) - { - if( !fbGet4M24b || !(mess.getGdpbHit24Edge()) ) - fTsLastHit[fGdpbNr][fGet4Id][channel] = dHitTime; - } // if( fUnpackPar->IsChannelRateEnabled() || fbPulserMode ) - - // In Run rate evolution - if (fdStartTime < 0) - fdStartTime = dHitTime; - - // Reset the evolution Histogram and the start time when we reach the end of the range - if( fuHistoryHistoSize < 1e-9 * (dHitTime - fdStartTime) ) - { - for (UInt_t uGdpbLoop = 0; uGdpbLoop < fNrOfGdpbs; uGdpbLoop++) - { - for (UInt_t uFeetLoop = 0; uFeetLoop < fNrOfFebsPerGdpb; uFeetLoop++) - { - fFeetRate_gDPB[(uGdpbLoop * fNrOfFebsPerGdpb) + uFeetLoop]->Reset(); - fFeetErrorRate_gDPB[(uGdpbLoop * fNrOfFebsPerGdpb) + uFeetLoop]->Reset(); - } // for (UInt_t uFeetLoop = 0; uFeetLoop < fNrOfFebsPerGdpb; uFeetLoop++) - } // for (UInt_t uFeetLoop = 0; uFeetLoop < fNrOfFebsPerGdpb; uFeetLoop++) - fhTriggerRate->Reset(); - fhStarTokenEvo->Reset(); - - fdStartTime = dHitTime; - } // if( fuHistoryHistoSize < 1e-9 * (dHitTime - fdStartTime) ) - - // In Run rate evolution - if (fdStartTimeLong < 0) - fdStartTimeLong = dHitTime; - - // Reset the evolution Histogram and the start time when we reach the end of the range - if( fuHistoryHistoSizeLong < 1e-9 * (dHitTime - fdStartTimeLong) / 60.0 ) - { - for (UInt_t uGdpbLoop = 0; uGdpbLoop < fNrOfGdpbs; uGdpbLoop++) - { - for (UInt_t uFeetLoop = 0; uFeetLoop < fNrOfFebsPerGdpb; uFeetLoop++) - { - fFeetRateLong_gDPB[(uGdpbLoop * fNrOfFebsPerGdpb) + uFeetLoop]->Reset(); - fFeetErrorRateLong_gDPB[(uGdpbLoop * fNrOfFebsPerGdpb) + uFeetLoop]->Reset(); - } // for (UInt_t uFeetLoop = 0; uFeetLoop < fNrOfFebsPerGdpb; uFeetLoop++) - } // for (UInt_t uFeetLoop = 0; uFeetLoop < fNrOfFebsPerGdpb; uFeetLoop++) - - fdStartTimeLong = dHitTime; - } // if( fuHistoryHistoSize < 1e-9 * (dHitTime - fdStartTime) / 60.0 ) - - if (0 <= fdStartTime) - { - fFeetRate_gDPB[(fGdpbNr * fNrOfFebsPerGdpb) + uFeetNr]->Fill( - 1e-9 * (dHitTime - fdStartTime)); - - // General Time (date + time) rate evolution - // Add offset of -1H as the filenames were using some times offset by 1 hour (Summer time?!?) - if( 0 < fiBinSizeDatePlots && 0 < fiRunStartDateTimeSec ) { - fFeetRateDate_gDPB[(fGdpbNr * fNrOfFebsPerGdpb) + uFeetNr]->Fill( - 1e-9 * (dHitTime - fdStartTime) ); - } // if( 0 < fiBinSizeDatePlots && 0 < fiRunStartDateTimeSec ) - } - - if (0 <= fdStartTimeLong) - { - fFeetRateLong_gDPB[(fGdpbNr * fNrOfFebsPerGdpb) + uFeetNr]->Fill( - 1e-9 / 60.0 * (dHitTime - fdStartTimeLong), 1 / 60.0); - } // if (0 <= fdStartTimeLong) - -// Int_t iChanInGdpb = fGet4Id * fNrOfChannelsPerGet4 + channel; -// Int_t increment = static_cast<CbmFlibCern2016Source*>(FairRunOnline::Instance()->GetSource())->GetNofTSSinceLastTS(); -/* - // if condition to find the right strip/end index - fHistSpill->Fill(0., 0., increment); -*/ - fiCountsLastTs ++; - fdDetLastTime = 1e-9 * dHitTime; - - ///* STAR event building/cutting */// - if( fbStarSortAndCutMode ) - { - if( fbEpochSuppModeOn ) - { - /// In epoch suppressed mode, assume the epoch message come always in - /// increasing epoch number - /// => never Epoch n from chip A efter Epoch n+1 from chip B - /// => no need to use fuStarActiveAsicMask or fuStarNextBufferUse - fvGdpbEpHitBuffer[ fGdpbNr ][ fiStarBuffIdxCurr[ fGdpbNr ] ].push_back( mess ); - } // if( fbEpochSuppModeOn ) - else - { - /// Only use GET4s declared as active - if( fuStarActiveAsicMask[ fGdpbNr ] & (0x1 << fGet4Id) ) - { - /// If chip is already ready for current epoch, save the message in the buffer for the next epoch - if( 0x1 & ( fuStarNextBufferUse[ fGdpbNr ] >> fGet4Id ) ) - fvGdpbEpHitBuffer[ fGdpbNr ][ fiStarBuffIdxNext[ fGdpbNr ] ].push_back( mess ); - else fvGdpbEpHitBuffer[ fGdpbNr ][ fiStarBuffIdxCurr[ fGdpbNr ] ].push_back( mess ); - } // if( fuStarActiveAsicMask[ fGdpbNr ] & (0x1 << fGet4Id) ) - } // else of if( fbEpochSuppModeOn ) - } // if( fbStarSortAndCutMode ) - - if (100 > iMess) - { - LOG(debug) << "Hit: " << Form("0x%08x ", fGdpbId) << ", " << fGet4Id - << ", " << channel << ", " << tot << ", epoch " - << curEpochGdpbGet4 << ", FullTime " - << hitTime << ", FineTime " << Fts; - iMess++; // Separate increment from condition, otherwise increase until wrap to -1664185233 - } // if (100 > iMess) - - ///* ASIC coincidences & offsets mapping */// -/* - fbHitsInLastTs = kTRUE; - fvulHitEpochBuffLastTs[fGet4Nr].push_back( curEpochGdpbGet4 ); -*/ - } // if( fCurrentEpoch[rocId].end() != fCurrentEpoch[rocId].find( get4Id ) ) - //} // if( fCurrentEpoch.end() != fCurrentEpoch.find( rocId ) ) - //} // if( fGdpbIdIndexMap.end() != fGdpbIdIndexMap.find( rocId ) ) - else - LOG(warning) << "Found hit in gdpbId w/o epoch yet: " - << Form("0x%08x g4 %02u", fGdpbId, fGet4Nr); -} - -void CbmTSMonitorTofStar::FillEpochInfo(ngdpb::Message mess) -{ - ULong64_t ulEpochNr = mess.getGdpbEpEpochNb(); -/* - if( ulEpochNr < fCurrentEpoch[fGet4Nr] ) - LOG(warning) << "Epoch message for get4 " << Form("%3u", fGet4Nr ) - << " with epoch number " << Form("%9u", ulEpochNr ) - << " smaller than previous epoch number for same chip: " - << Form("%9u", fCurrentEpoch[fGet4Nr] ); - if( ulEpochNr == fCurrentEpoch[fGet4Nr] ) - LOG(warning) << "Epoch message for get4 " << Form("%3u", fGet4Nr ) - << " with epoch number " << Form("%9u", ulEpochNr ) - << " same as previous epoch number for same chip: " - << Form("%9u", fCurrentEpoch[fGet4Nr] ); -*/ - - /** Real MS QA **/ - if( kFALSE == fbFirstEpochInMsFound[fGdpbNr] ) - { - Double_t dMsIndexCnt = fdMsIndex / 102400; // ~10 kHz MS => 1e5 ns increase of index per MS - Double_t dMsIndexFromStart = (fdMsIndex - fdFirstMsIndex)/ 102400; // ~10 kHz MS => 1e5 ns increase of index per MS - Double_t dEpIdxMsIdxRatio = static_cast< Double_t >( ulEpochNr ) / dMsIndexCnt; - fRealMsFineQa_gDPB[fGdpbNr]->Fill( dMsIndexFromStart, dEpIdxMsIdxRatio ); - fRealMsMidQa_gDPB[fGdpbNr]->Fill( dMsIndexFromStart, dEpIdxMsIdxRatio ); - fRealMsCoarseQa_gDPB[fGdpbNr]->Fill( dMsIndexFromStart, dEpIdxMsIdxRatio ); - fbFirstEpochInMsFound[fGdpbNr] = kTRUE; - } // if( kFALSE == fbFirstEpochInMsFound[uGdpb] ) - - - fCurrentEpoch[fGet4Nr] = ulEpochNr; - - if (100 > iMess) - { - LOG(debug) << "Epoch message for get4 " << fGet4Nr << " with epoch number " - << fCurrentEpoch[fGet4Nr]; - iMess++; // Separate increment from condition, otherwise increase until wrap to -1664185233 - } // if (100 > iMess) -/* - if (1000 > iMessB ) - { -// if( 0 <= fGet4Nr && fGet4Nr <= 15 ) - if( ( 16 <= fGet4Nr && fGet4Nr <= 23 ) || ( 40 <= fGet4Nr && fGet4Nr <= 47 )) -// if( 24 <= fGet4Nr && fGet4Nr <= 39 ) -// if( 48 <= fGet4Nr && fGet4Nr <= 63 ) -// if( ( 64 <= fGet4Nr && fGet4Nr <= 71 ) || ( 88 <= fGet4Nr && fGet4Nr <= 95 )) -// if( 72 <= fGet4Nr && fGet4Nr <= 87 ) - { - LOG(info) << "Epoch message for get4 " << Form( "%02u", fGet4Nr) << " with epoch number " - << Form( "%09llu", fCurrentEpoch[fGet4Nr]) - << " in ms " << Form("%12llu", fulLastMsIdx); - iMessB++; - } // if get4 chip in range - } // if (10000 > iMessB ) -*/ - - if (1 == mess.getGdpbEpSync()) - fHistGet4EpochFlags->Fill(fGet4Nr, 0); - if (1 == mess.getGdpbEpDataLoss()) - fHistGet4EpochFlags->Fill(fGet4Nr, 1); - if (1 == mess.getGdpbEpEpochLoss()) - fHistGet4EpochFlags->Fill(fGet4Nr, 2); - if (1 == mess.getGdpbEpMissmatch()) - fHistGet4EpochFlags->Fill(fGet4Nr, 3); - - fCurrentEpochTime = mess.getMsgFullTime(ulEpochNr); - fNofEpochs++; - - - if( fbEpochSuppModeOn ) - { - /// Re-align the epoch number of the message in case it will be used later: - /// We received the epoch after the data instead of the one before! - if( 0 < ulEpochNr ) - mess.setEpoch2Number( ulEpochNr - 1 ); - else mess.setEpoch2Number( get4v1x::kuEpochCounterSz ); - - ///* STAR event building/cutting */// - /// In epoch suppressed mode, assume the epoch message come always in - /// increasing epoch number - /// => never Epoch n from chip A efter Epoch n+1 from chip B - /// => no need to use fuStarActiveAsicMask - if( fbStarSortAndCutMode ) - { - Bool_t bEpochOk = kTRUE; - if( 0 == fuCurrentEpGdpb[fGdpbNr] ) - { - /// First epoch for this gDPB board => initialize everything - fuCurrentEpGdpb[ fGdpbNr ] = ulEpochNr; - fuStarCurrentEpFound[ fGdpbNr ] = 0; - fuStarNextBufferUse[ fGdpbNr ] = 0; - fiStarBuffIdxPrev[ fGdpbNr ] = 0; - fiStarBuffIdxCurr[ fGdpbNr ] = 1; - fiStarBuffIdxNext[ fGdpbNr ] = 2; - - UInt_t uNbInitialStarTokens = 0; - /// Previous epoch buffer - UInt_t uNbEpochTrgs = fvGdpbEpTrgBuffer[ fGdpbNr ][ fiStarBuffIdxPrev[ fGdpbNr ] ].size(); - for( UInt_t uTrigIdx = 0; uTrigIdx < uNbEpochTrgs; uTrigIdx ++) - { - StarGenEmptyEvt( fGdpbNr, - fvGdpbEpTrgBuffer[ fGdpbNr ] - [ fiStarBuffIdxPrev[ fGdpbNr ] ] - [ uTrigIdx ] ); - uNbInitialStarTokens++; - } // for( UInt_t uTrigIdx = 0; uTrigIdx < uNbEpochTrgs; uTrigIdx ++) - - LOG(info) << "Generated empty STAR events for the " << uNbInitialStarTokens - << " first tokens which arrived before the first epoch"; - - /// Clear data from before as we are not sure they belong to the epoch before - fvGdpbEpHitBuffer[ fGdpbNr ][ fiStarBuffIdxPrev[fGdpbNr] ].clear(); - fvGdpbEpTrgBuffer[ fGdpbNr ][ fiStarBuffIdxPrev[fGdpbNr] ].clear(); - } - else if( ulEpochNr == fuCurrentEpGdpb[ fGdpbNr ] ) - { - /// Epoch currently waiting for all GET4s to be ready - /// => This one is ready and starts "storing" its data in Next buffer - //// (no real effect as in this mode we dalay processing of hits) - fuStarCurrentEpFound[ fGdpbNr ] |= 0x1 << fGet4Id; // !!! This implies a limit to 32 GET4 per gDPB !!! - fuStarNextBufferUse[ fGdpbNr ] |= 0x1 << fGet4Id; // !!! This implies a limit to 32 GET4 per gDPB !!! - } // else if( ulEpochNr == fuCurrentEpGdpb[ fGdpbNr ] ) - else if( ulEpochNr == (fuCurrentEpGdpb[ fGdpbNr ] + 1) ) - { - /// => In both cases, for processing of current epoch buffer + go to next - StarSort( fGdpbNr ); - StarSelect( fGdpbNr); - - /// Then update flags and indices to be ready for next epoch - fuCurrentEpGdpb[ fGdpbNr ] = ulEpochNr; - fuStarCurrentEpFound[ fGdpbNr ] = 0; - fuStarNextBufferUse[ fGdpbNr ] = 0; - fiStarBuffIdxPrev[ fGdpbNr ] = (fiStarBuffIdxPrev[ fGdpbNr ] + 1)%3; - fiStarBuffIdxCurr[ fGdpbNr ] = (fiStarBuffIdxCurr[ fGdpbNr ] + 1)%3; - fiStarBuffIdxNext[ fGdpbNr ] = (fiStarBuffIdxNext[ fGdpbNr ] + 1)%3; - } // else if( ulEpochNr == (fuCurrentEpGdpb[ fGdpbNr ] + 1) ) - else if( ( ulEpochNr > (fuCurrentEpGdpb[ fGdpbNr ] + 1) ) || - ( ( ulEpochNr < fuCurrentEpGdpb[ fGdpbNr ] ) && - ( get4v1x::kuEpochCounterSz / 2 < fuCurrentEpGdpb[ fGdpbNr ] - ulEpochNr ) - ) // Epoch counter cycle!!!! - ) - { - /// => Do processing of current epoch buffer + go to next - StarSort( fGdpbNr ); - StarSelect( fGdpbNr); - - /// Then update flags and indices to be ready for next epoch - fuCurrentEpGdpb[ fGdpbNr ] = ulEpochNr; - fuStarCurrentEpFound[ fGdpbNr ] = 0; - fuStarNextBufferUse[ fGdpbNr ] = 0; - fiStarBuffIdxPrev[ fGdpbNr ] = (fiStarBuffIdxPrev[ fGdpbNr ] + 1)%3; - fiStarBuffIdxCurr[ fGdpbNr ] = (fiStarBuffIdxCurr[ fGdpbNr ] + 1)%3; - fiStarBuffIdxNext[ fGdpbNr ] = (fiStarBuffIdxNext[ fGdpbNr ] + 1)%3; - } // else if( ulEpochNr > (fuCurrentEpGdpb[ fGdpbNr ] + 1) ) - else - { - LOG(error) << "In STAR sort and cut mode, gDPB " << Form("0x%08x,", fGdpbId) - << " found epoch " << Form( "%12llu", ulEpochNr) - << " for get4 "<< Form( "%2u", fGet4Id) - << " while waiting for epoch " - << Form( "%12u", fuCurrentEpGdpb[ fGdpbNr ]) - << std::endl - << " -----> GET4 active mask is 0x" << std::hex - << fuStarActiveAsicMask[ fGdpbNr ] << " and GET4 ready flags is " - << fuStarCurrentEpFound[ fGdpbNr ] - << std::dec - << std::endl - << " => corrupted epoch number ordering, exiting now!"; - bEpochOk = kFALSE; - } // else of many ifs => Correspond to ulEpochNr < fuCurrentEpGdpb[ fGdpbNr ] - - if( bEpochOk ) - { - /// Save the epoch message corresponding to the current buffer: - fvGdpbEpMsgBuffer[ fGdpbNr ][ fiStarBuffIdxCurr[ fGdpbNr ] ].push_back( mess ); - - /// Save content of current GET4 hit buffer in Current buffer! - Int_t iBufferSize = fvmEpSupprBuffer[fGet4Nr].size(); - if( 0 < iBufferSize ) - { - for( Int_t iMsgIdx = 0; iMsgIdx < iBufferSize; iMsgIdx++ ) - { - FillHitInfo( fvmEpSupprBuffer[fGet4Nr][ iMsgIdx ] ); - } // for( Int_t iMsgIdx = 0; iMsgIdx < iBufferSize; iMsgIdx++ ) - - fvmEpSupprBuffer[fGet4Nr].clear(); - } // if( 0 < iBufferSize ) - - - /// Epoch currently waiting for all GET4s to be ready - /// => This one is ready and starts "storing" its data in Next buffer - //// (no real effect as in this mode we dalay processing of hits) - fuStarCurrentEpFound[ fGdpbNr ] |= 0x1 << fGet4Id; // !!! This implies a limit to 32 GET4 per gDPB !!! - fuStarNextBufferUse[ fGdpbNr ] |= 0x1 << fGet4Id; // !!! This implies a limit to 32 GET4 per gDPB !!! - } // if( bEpochOk ) - else - { - /// Bad epoch for whatever reason: just jump it and do nothing with it - fvmEpSupprBuffer[fGet4Nr].clear(); - } // else of if( bEpochOk ) - } // if( fbStarSortAndCutMode ) - else - { - Int_t iBufferSize = fvmEpSupprBuffer[fGet4Nr].size(); - if( 0 < iBufferSize ) - { - LOG(debug) << "Now processing stored messages for for get4 " << fGet4Nr << " with epoch number " - << (fCurrentEpoch[fGet4Nr] - 1); - - for( Int_t iMsgIdx = 0; iMsgIdx < iBufferSize; iMsgIdx++ ) - { - FillHitInfo( fvmEpSupprBuffer[fGet4Nr][ iMsgIdx ] ); - } // for( Int_t iMsgIdx = 0; iMsgIdx < iBufferSize; iMsgIdx++ ) - - fvmEpSupprBuffer[fGet4Nr].clear(); - } // if( 0 < fvmEpSupprBuffer[fGet4Nr] ) - } // else of if( fbStarSortAndCutMode ) - - } // if( fbEpochSuppModeOn ) - else if( fbStarSortAndCutMode ) - { - ///* STAR event building/cutting without EP suppr. */// - /// Only use GET4s declared as active - if( fuStarActiveAsicMask[ fGdpbNr ] & (0x1 << fGet4Id) ) - { - LOG(fatal) << "In STAR sort and cut mode, full epoch mode not supported yet!"; - } // if( fuStarActiveAsicMask[ fGdpbNr ] & (0x1 << fGet4Id) ) - } // else if( fbStarSortAndCutMode ) of if( fbEpochSuppModeOn ) - - // Fill Pulser test histos if needed - if( fbPulserMode && 0 == (fGet4Id % fNrOfGet4PerFeb) // GET4 index in FEET - && fuPulserFee == (fGet4Nr / fNrOfGet4PerFeb)) // FEET index in full system - { - // Fill the time difference for all channels pairs in - // the chosen Fee - UInt_t uHistoFeeIdx = 0; - - UInt_t uOffsetChip = fuPulserFee * fNrOfGet4PerFeb; - for( UInt_t uChanFeeA = 0; uChanFeeA < fNrOfChannelsPerFeet; uChanFeeA++) - { - UInt_t uChipA = uChanFeeA / fNrOfChannelsPerGet4 + uOffsetChip; - UInt_t uChanA = uChanFeeA % fNrOfChannelsPerGet4; - - for( UInt_t uChanFeeB = uChanFeeA + 1; uChanFeeB < fNrOfChannelsPerFeet; uChanFeeB++) - { - UInt_t uChipB = uChanFeeB / fNrOfChannelsPerGet4 + uOffsetChip; - UInt_t uChanB = uChanFeeB % fNrOfChannelsPerGet4; - - Double_t dTimeDiff = - fTsLastHit[ fuPulserGdpb ][ uChipB ][ uChanB ] - - fTsLastHit[ fuPulserGdpb ][ uChipA ][ uChanA ]; - dTimeDiff *= 1e3; // ns -> ps - if( ( 10.0 * dMinDt < dTimeDiff ) && ( dTimeDiff < 10.0 * dMaxDt ) && - ( 0 < fTsLastHit[ fuPulserGdpb ][ uChipA ][ uChanA ] ) && - ( 0 < fTsLastHit[ fuPulserGdpb ][ uChipB ][ uChanB ] ) ) - { - fhTimeDiffPulserChosenFee[uHistoFeeIdx]->Fill( dTimeDiff ); - } // if both channels have already 1 hit and these are not too far away - - uHistoFeeIdx++; - } // for( UInt_t uChanFeeB = uChanFeeA + 1; uChanFeeB < fNrOfChannelsPerFeet; uChanFeeB++) - } // for( UInt_t uChanFeeA = 0; uChanFeeA < fNrOfChannelsPerFeet; uChanFeeA++) - - // Fill the time difference for the chosen channel pairs - for( UInt_t uChan = 0; uChan < kuNbChanTest - 1; uChan++) - { - UInt_t uGdpbA = fuPulserChan[ uChan ] / fuNbChannelsPerGdpb; - UInt_t uChipA = ( fuPulserChan[ uChan ] % fuNbChannelsPerGdpb ) / fNrOfChannelsPerGet4; - UInt_t uChanA = fuPulserChan[ uChan ] % fNrOfChannelsPerGet4; - UInt_t uGdpbB = fuPulserChan[ uChan + 1 ] / fuNbChannelsPerGdpb; - UInt_t uChipB = ( fuPulserChan[ uChan + 1 ] % fuNbChannelsPerGdpb ) / fNrOfChannelsPerGet4; - UInt_t uChanB = fuPulserChan[ uChan + 1 ] % fNrOfChannelsPerGet4; - - Double_t dTimeDiff = - fTsLastHit[uGdpbB][uChipB][ uChanB ] - fTsLastHit[uGdpbA][uChipA][ uChanA ]; - dTimeDiff *= 1e3; // ns -> ps - if( ( 10.0 * dMinDt < dTimeDiff ) && ( dTimeDiff < 10.0 * dMaxDt ) && - ( 0 < fTsLastHit[uGdpbA][uChipA][ uChanA ] ) && - ( 0 < fTsLastHit[uGdpbB][uChipB][ uChanB ] ) ) - { - fhTimeDiffPulserChosenChPairs[uChan]->Fill( dTimeDiff ); - } // if both channels have already 1 hit and these are not too far away - } // for( UInt_t uChan = 0; uChan < kuNbChanTest - 1; uChan++) - } // if( fbPulserMode && First GET4 on chosen FEET ) - - /* - LOG(debug) << "Epoch message " - << fNofEpochs << ", epoch " << static_cast<Int_t>(fCurrentEpoch[gdpbId][get4Id]) - << ", time " << std::setprecision(9) << std::fixed - << Double_t(fCurrentEpochTime) * 1.e-9 << " s " - << " for board ID " << std::hex << std::setw(4) << gdpbId << std::dec - << " and chip " << mess.getEpoch2ChipNumber(); - */ -} - -void CbmTSMonitorTofStar::PrintSlcInfo(ngdpb::Message mess) -{ - if (fGdpbIdIndexMap.end() != fGdpbIdIndexMap.find(fGdpbId)) - { - UInt_t uChip = mess.getGdpbGenChipId(); - UInt_t uChan = mess.getGdpbSlcChan(); - UInt_t uEdge = mess.getGdpbSlcEdge(); - UInt_t uData = mess.getGdpbSlcData(); - UInt_t uCRC = mess.getGdpbSlcCrc(); - Double_t dFullChId = fGet4Nr * fNrOfChannelsPerGet4 + mess.getGdpbSlcChan() + 0.5 * mess.getGdpbSlcEdge(); - Double_t dMessTime = static_cast< Double_t>( fCurrentEpochTime ) * 1.e-9; - - switch( mess.getGdpbSlcType() ) - { - case 0: // Scaler counter - { - fhScmScalerCounters->Fill( uData, dFullChId); - break; - } - case 1: // Deadtime counter - { - fhScmDeadtimeCounters->Fill( uData, dFullChId); - break; - } - case 2: // SPI message - { - LOG(info) << "GET4 Slow Control message, epoch " - << static_cast<Int_t>(fCurrentEpoch[fGet4Nr]) << ", time " << std::setprecision(9) - << std::fixed << dMessTime << " s " - << " for board ID " << std::hex << std::setw(4) << fGdpbId - << std::dec << "\n" - << " +++++++ > Chip = " - << std::setw(2) << uChip << ", Chan = " - << std::setw(1) << uChan << ", Edge = " - << std::setw(1) << uEdge << ", Type = " - << std::setw(1) << mess.getGdpbSlcType() << ", Data = 0x" -// << std::hex << std::setw(6) << mess.getGdpbSlcData() - << Form( "%06x", uData ) - << std::dec << ", CRC = " << uCRC; - break; - } - case 3: // Start message or SEU counter - { - if( 0 == mess.getGdpbSlcChan() && 0 == mess.getGdpbSlcEdge() ) // START message - { - // Print or fill histo - if( 0 == fGet4Nr && 0x474554 == mess.getGdpbSlcData() ) // START message block 1/6 - { - if( 0 < fdTimeLastStartMessage ) - fhScmStartMessDist->Fill( dMessTime - fdTimeLastStartMessage ); - fhScmStartMessEvo->Fill( dMessTime - fdStartTime * 1.e-9 ); - fdTimeLastStartMessage = dMessTime; - } // if( 0 == fGet4Nr && 0x474554 == mess.getGdpbSlcData() ) -/* - LOG(info) << std::setprecision(9) - << std::fixed << dMessTime << " s "; - LOG(info) << "GET4 Slow Control message, epoch " - << static_cast<Int_t>(fCurrentEpoch[fGet4Nr]) << ", time " << std::setprecision(9) - << std::fixed << dMessTime << " s " - << " for board ID " << std::hex << std::setw(4) << fGdpbId - << std::dec << "\n" - << " +++++++ > Chip = " - << std::setw(2) << mess.getGdpbGenChipId() << ", Chan = " - << std::setw(1) << mess.getGdpbSlcChan() << ", Edge = " - << std::setw(1) << mess.getGdpbSlcEdge() << ", Type = " - << std::setw(1) << mess.getGdpbSlcType() << ", Data = 0x" - // << std::hex << std::setw(6) << mess.getGdpbSlcData() - << Form( "%06x", mess.getGdpbSlcData() ) - << std::dec << ", CRC = " << mess.getGdpbSlcCrc(); -*/ - } // if( 0 == mess.getGdpbSlcChan() && 0 == mess.getGdpbSlcEdge() ) - else if( 0 == mess.getGdpbSlcChan() && 1 == mess.getGdpbSlcEdge() ) // SEU counter message - { -/* - LOG(info) << "GET4 Slow Control message, epoch " - << static_cast<Int_t>(fCurrentEpoch[fGet4Nr]) << ", time " << std::setprecision(9) - << std::fixed << dMessTime << " s " - << " for board ID " << std::hex << std::setw(4) << fGdpbId - << std::dec << "\n" - << " +++++++ > Chip = " - << std::setw(2) << mess.getGdpbGenChipId() << ", Chan = " - << std::setw(1) << mess.getGdpbSlcChan() << ", Edge = " - << std::setw(1) << mess.getGdpbSlcEdge() << ", Type = " - << std::setw(1) << mess.getGdpbSlcType() << ", Data = 0x" -// << std::hex << std::setw(6) << mess.getGdpbSlcData() - << Form( "%06x", mess.getGdpbSlcData() ) - << std::dec << ", CRC = " << mess.getGdpbSlcCrc(); -*/ - fhScmSeuCounters->Fill( uData, dFullChId); - fhScmSeuCountersEvo->Fill( dMessTime - fdStartTime* 1.e-9, uData, dFullChId); - } // else if( 0 == mess.getGdpbSlcChan() && 1 == mess.getGdpbSlcEdge() ) - break; - } - default: // Should never happen - break; - } // switch( mess.getGdpbSlcType() ) - fHistGet4ChanScm->Fill(dFullChId, mess.getGdpbSlcType()); - } - - -} - -void CbmTSMonitorTofStar::PrintGenInfo(ngdpb::Message mess) -{ - Int_t mType = mess.getMessageType(); - Int_t channel = mess.getGdpbHitChanId(); - uint64_t uData = mess.getData(); - - if (100 > iMess) - { - LOG(info) << "Get4 MSG type " << mType << " from gdpbId " << fGdpbId - << ", getId " << fGet4Id << ", (hit channel) " << channel - << " data " << std::hex << uData; - iMess++; // Separate increment from condition, otherwise increase until wrap to -1664185233 - } // if (100 > iMess) -} - -void CbmTSMonitorTofStar::PrintSysInfo(ngdpb::Message mess) -{ - if (fGdpbIdIndexMap.end() != fGdpbIdIndexMap.find(fGdpbId)) - LOG(debug) << "GET4 System message, epoch " - << static_cast<Int_t>(fCurrentEpoch[fGet4Nr]) << ", time " << std::setprecision(9) - << std::fixed << Double_t(fCurrentEpochTime) * 1.e-9 << " s " - << " for board ID " << std::hex << std::setw(4) << fGdpbId - << std::dec; - - switch (mess.getGdpbSysSubType()) { - case ngdpb::SYSMSG_GET4_EVENT: { - uint32_t uData = mess.getGdpbSysErrData(); - if (ngdpb::GET4_V1X_ERR_TOT_OVERWRT == uData - || ngdpb::GET4_V1X_ERR_TOT_RANGE == uData - || ngdpb::GET4_V1X_ERR_EVT_DISCARD == uData - || ngdpb::GET4_V1X_ERR_ADD_RIS_EDG == uData - || ngdpb::GET4_V1X_ERR_UNPAIR_FALL == uData - || ngdpb::GET4_V1X_ERR_SEQUENCE_ER == uData - ) - LOG(debug) << " +++++++ > gDPB: " << std::hex << std::setw(4) << fGdpbId - << std::dec << ", Chip = " << std::setw(2) - << mess.getGdpbGenChipId() << ", Chan = " << std::setw(1) - << mess.getGdpbSysErrChanId() << ", Edge = " - << std::setw(1) << mess.getGdpbSysErrEdge() << ", Empt = " - << std::setw(1) << mess.getGdpbSysErrUnused() - << ", Data = " << std::hex << std::setw(2) << uData - << std::dec << " -- GET4 V1 Error Event"; - else - LOG(info) << " +++++++ >gDPB: " << std::hex << std::setw(4) << fGdpbId - << std::dec << ", Chip = " << std::setw(2) - << mess.getGdpbGenChipId() << ", Chan = " << std::setw(1) - << mess.getGdpbSysErrChanId() << ", Edge = " - << std::setw(1) << mess.getGdpbSysErrEdge() << ", Empt = " - << std::setw(1) << mess.getGdpbSysErrUnused() - << ", Data = " << std::hex << std::setw(2) << uData - << std::dec << " -- GET4 V1 Error Event " << iMess; - break; - } // case ngdpb::SYSMSG_GET4_EVENT - case ngdpb::SYSMSG_CLOSYSYNC_ERROR: - LOG(info) << "Closy synchronization error"; - break; - case ngdpb::SYSMSG_TS156_SYNC: - LOG(debug) << "160.00 MHz timestamp reset"; - break; - case ngdpb::SYSMSG_GDPB_UNKWN: - LOG(info) << "Unknown GET4 message, data: " << std::hex << std::setw(8) - << mess.getGdpbSysUnkwData() << std::dec - <<" Full message: " << std::hex << std::setw(16) - << mess.getData() << std::dec; - break; - } // switch( getGdpbSysSubType() ) -} - -void CbmTSMonitorTofStar::FillStarTrigInfo(ngdpb::Message mess) -{ - Int_t iMsgIndex = mess.getStarTrigMsgIndex(); - -// mess.printDataCout(); - - switch( iMsgIndex ) - { - case 0: - fhTokenMsgType->Fill(0); - fulGdpbTsMsb = mess.getGdpbTsMsbStarA(); - break; - case 1: - fhTokenMsgType->Fill(1); - fulGdpbTsLsb = mess.getGdpbTsLsbStarB(); - fulStarTsMsb = mess.getStarTsMsbStarB(); - break; - case 2: - fhTokenMsgType->Fill(2); - fulStarTsMid = mess.getStarTsMidStarC(); - break; - case 3: - { - fhTokenMsgType->Fill(3); - ULong64_t ulNewGdpbTsFull = ( fulGdpbTsMsb << 24 ) - + ( fulGdpbTsLsb ); - ULong64_t ulNewStarTsFull = ( fulStarTsMsb << 48 ) - + ( fulStarTsMid << 8 ) - + mess.getStarTsLsbStarD(); - UInt_t uNewToken = mess.getStarTokenStarD(); - UInt_t uNewDaqCmd = mess.getStarDaqCmdStarD(); - UInt_t uNewTrigCmd = mess.getStarTrigCmdStarD(); - - if( ( uNewToken == fuStarTokenLast ) && ( ulNewGdpbTsFull == fulGdpbTsFullLast ) && - ( ulNewStarTsFull == fulStarTsFullLast ) && ( uNewDaqCmd == fuStarDaqCmdLast ) && - ( uNewTrigCmd == fuStarTrigCmdLast ) ) - { - LOG(debug) << "Possible error: identical STAR tokens found twice in a row => ignore 2nd! " - << Form("token = %5u ", fuStarTokenLast ) - << Form("gDPB ts = %12llu ", fulGdpbTsFullLast ) - << Form("STAR ts = %12llu ", fulStarTsFullLast ) - << Form("DAQ cmd = %2u ", fuStarDaqCmdLast ) - << Form("TRG cmd = %2u ", fuStarTrigCmdLast ); - return; - } // if exactly same message repeated -/* - if( (uNewToken != fuStarTokenLast + 1) && - 0 < fulGdpbTsFullLast && 0 < fulStarTsFullLast && - ( 4095 != fuStarTokenLast || 1 != uNewToken) ) - LOG(warning) << "Possible error: STAR token did not increase by exactly 1! " - << Form("old = %5u vs new = %5u ", fuStarTokenLast, uNewToken) - << Form("old = %12llu vs new = %12llu ", fulGdpbTsFullLast, ulNewGdpbTsFull) - << Form("old = %12llu vs new = %12llu ", fulStarTsFullLast, ulNewStarTsFull) - << Form("old = %2u vs new = %2u ", fuStarDaqCmdLast, uNewDaqCmd) - << Form("old = %2u vs new = %2u ", fuStarTrigCmdLast, uNewTrigCmd); -*/ - // STAR TS counter reset detection - if( ulNewStarTsFull < fulStarTsFullLast ) - LOG(debug) << "Probable reset of the STAR TS: old = " << Form("%16llu", fulStarTsFullLast) - << " new = " << Form("%16llu", ulNewStarTsFull) - << " Diff = -" << Form("%8llu", fulStarTsFullLast - ulNewStarTsFull); - -// ULong64_t ulGdpbTsDiff = ulNewGdpbTsFull - fulGdpbTsFullLast; - fulGdpbTsFullLast = ulNewGdpbTsFull; - fulStarTsFullLast = ulNewStarTsFull; - fuStarTokenLast = uNewToken; - fuStarDaqCmdLast = uNewDaqCmd; - fuStarTrigCmdLast = uNewTrigCmd; - - ///* STAR event building/cutting */// - if( fbStarSortAndCutMode ) - { - CbmTofStarTrigger newTrig( fulGdpbTsFullLast, fulStarTsFullLast, fuStarTokenLast, - fuStarDaqCmdLast, fuStarTrigCmdLast ); - - /// Check the epoch number contained in the token and generate a fake "gDPB" epoch - /// from it if it is more than 2 epochs away from the current epoch -/* - if( fuCurrentEpGdpb[ fGdpbNr ] + 3 < newTrig.GetFullGdpbEpoch() ) - { - ngdpb::Message messEpoch(0); - messEpoch.setRocNumber( mess.getRocNumber() ); - messEpoch.setMessageType( ngdpb::MSG_EPOCH2 ); - messEpoch.setEpoch2ChipNumber( 62 ); // Use a ChipID out of physical connection possibility - messEpoch.setEpoch2Number( newTrig.GetFullGdpbEpoch() ); - FillTrigEpochInfo( messEpoch ); - } // if( fuCurrentEpGdpb[ fGdpbNr ] + 1 < newTrig.GetTrigger() ) -*/ - - /// Store the token - fvGdpbEpTrgBuffer[ fGdpbNr ][ fiStarBuffIdxCurr[fGdpbNr] ].push_back( newTrig ); - } // if( fbStarSortAndCutMode ) - - if( 0 <= fdStartTime ) - { - // Reset the evolution Histogram and the start time when we reach the end of the range - if( fuHistoryHistoSize < 1e-9 * (fulGdpbTsFullLast * 6.25 - fdStartTime) ) - { - for (UInt_t uGdpbLoop = 0; uGdpbLoop < fNrOfGdpbs; uGdpbLoop++) - { - for (UInt_t uFeetLoop = 0; uFeetLoop < fNrOfFebsPerGdpb; uFeetLoop++) - { - fFeetRate_gDPB[(uGdpbLoop * fNrOfFebsPerGdpb) + uFeetLoop]->Reset(); - fFeetErrorRate_gDPB[(uGdpbLoop * fNrOfFebsPerGdpb) + uFeetLoop]->Reset(); - } // for (UInt_t uFeetLoop = 0; uFeetLoop < fNrOfFebsPerGdpb; uFeetLoop++) - } // for (UInt_t uFeetLoop = 0; uFeetLoop < fNrOfFebsPerGdpb; uFeetLoop++) - fhTriggerRate->Reset(); - fhStarTokenEvo->Reset(); - - fdStartTime = fulGdpbTsFullLast * 6.25; - } // if( fuHistoryHistoSize < 1e-9 * (fulGdpbTsFullLast * 6.25 - fdStartTime) ) - - fhTriggerRate->Fill( - 1e-9 * ( fulGdpbTsFullLast * 6.25 - fdStartTime ) ); - fhStarTokenEvo->Fill( - 1e-9 * ( fulGdpbTsFullLast * 6.25 - fdStartTime ), - fuStarTokenLast ); - } // if( 0 < fdStartTime ) - else fdStartTime = fulGdpbTsFullLast * 6.25; - fhCmdDaqVsTrig->Fill( fuStarDaqCmdLast, fuStarTrigCmdLast ); - -/* - LOG(info) << "Found full Star Trigger with gDPB TS " << Form("%16llu", fulGdpbTsFullLast) - << " STAR TS " << Form("%16llu", fulStarTsFullLast) - << " token " << Form("%8u", fuStarTokenLast) - << " DAQ CMD " << Form("%1X", fuStarDaqCmdLast) - << " TRIG CMD " << Form("%1X", fuStarTrigCmdLast) -// << " Filler " << Form("%2X", mess.getStarFillerD()) - << "GDPB DIFF " << Form("%8llu", ulGdpbTsDiff); -*/ - break; - } // case 3 - default: - LOG(error) << "Unknown Star Trigger messageindex: " << iMsgIndex; - } // switch( iMsgIndex ) -} -void CbmTSMonitorTofStar::FillTrigEpochInfo(ngdpb::Message mess) -{ - UInt_t uEpochNr = mess.getGdpbEpEpochNb(); - fGet4Id = mess.getGdpbGenChipId(); - fGet4Nr = (fGdpbNr * fNrOfGet4PerGdpb) + fGet4Id; - - if (100 > iMess) - { - LOG(debug) << "Epoch message for get4 " << fGet4Id - << " in gDPB " << fGdpbNr - <<" with epoch number " << uEpochNr; - iMess++; // Separate increment from condition, otherwise increase until wrap to -1664185233 - } // if (100 > iMess) - - fCurrentEpochTime = mess.getMsgFullTime(uEpochNr); - fNofEpochs++; - - if( fbEpochSuppModeOn ) - { - /// Re-align the epoch number of the message in case it will be used later: - /// We received the epoch after the data instead of the one before! - //// The epoch index from the token message should not need to be re-aligned - //// ====> to be checked with pulser or data-trigger correlation -// if( 0 < uEpochNr ) -// mess.setEpoch2Number( uEpochNr - 1 ); - - ///* STAR event building/cutting */// - /// In epoch suppressed mode, assume the epoch message come always in - /// increasing epoch number - /// => never Epoch n from chip A efter Epoch n+1 from chip B - /// => no need to use fuStarActiveAsicMask - if( fbStarSortAndCutMode ) - { - Bool_t bEpochOk = kTRUE; - if( 0 == fuCurrentEpGdpb[fGdpbNr] ) - { - /// First epoch for this gDPB board => initialize everything - fuCurrentEpGdpb[ fGdpbNr ] = uEpochNr; - fuStarCurrentEpFound[ fGdpbNr ] = 0; - fuStarNextBufferUse[ fGdpbNr ] = 0; - fiStarBuffIdxPrev[ fGdpbNr ] = 0; - fiStarBuffIdxCurr[ fGdpbNr ] = 1; - fiStarBuffIdxNext[ fGdpbNr ] = 2; - - UInt_t uNbInitialStarTokens = 0; - /// Previous epoch buffer - UInt_t uNbEpochTrgs = fvGdpbEpTrgBuffer[ fGdpbNr ][ fiStarBuffIdxPrev[ fGdpbNr ] ].size(); - for( UInt_t uTrigIdx = 0; uTrigIdx < uNbEpochTrgs; uTrigIdx ++) - { - StarGenEmptyEvt( fGdpbNr, - fvGdpbEpTrgBuffer[ fGdpbNr ] - [ fiStarBuffIdxPrev[ fGdpbNr ] ] - [ uTrigIdx ] ); - uNbInitialStarTokens++; - } // for( UInt_t uTrigIdx = 0; uTrigIdx < uNbEpochTrgs; uTrigIdx ++) - - LOG(info) << "Generated empty STAR events for the " << uNbInitialStarTokens - << " first tokens which arrived before the first epoch"; - - /// Clear data from before as we are not sure they belong to the epoch before - fvGdpbEpHitBuffer[ fGdpbNr ][ fiStarBuffIdxPrev[fGdpbNr] ].clear(); - fvGdpbEpTrgBuffer[ fGdpbNr ][ fiStarBuffIdxPrev[fGdpbNr] ].clear(); - } - else if( uEpochNr == fuCurrentEpGdpb[ fGdpbNr ] ) - { - /// Epoch currently waiting for all GET4s to be ready - /// => This one is ready and starts "storing" its data in Next buffer - //// (no real effect as in this mode we dalay processing of hits) - //// ====> Not for epoch from token message - } // else if( uEpochNr == fuCurrentEpGdpb[ fGdpbNr ] ) - else if( uEpochNr == (fuCurrentEpGdpb[ fGdpbNr ] + 1) ) - { - /// => In both cases, for processing of current epoch buffer + go to next - StarSort( fGdpbNr ); - StarSelect( fGdpbNr); - - /// Then update flags and indices to be ready for next epoch - fuCurrentEpGdpb[ fGdpbNr ] = uEpochNr; - fuStarCurrentEpFound[ fGdpbNr ] = 0; - fuStarNextBufferUse[ fGdpbNr ] = 0; - fiStarBuffIdxPrev[ fGdpbNr ] = (fiStarBuffIdxPrev[ fGdpbNr ] + 1)%3; - fiStarBuffIdxCurr[ fGdpbNr ] = (fiStarBuffIdxCurr[ fGdpbNr ] + 1)%3; - fiStarBuffIdxNext[ fGdpbNr ] = (fiStarBuffIdxNext[ fGdpbNr ] + 1)%3; - } // else if( uEpochNr == (fuCurrentEpGdpb[ fGdpbNr ] + 1) ) - else if( uEpochNr > (fuCurrentEpGdpb[ fGdpbNr ] + 1) ) - { - /// => Do processing of current epoch buffer + go to next - StarSort( fGdpbNr ); - StarSelect( fGdpbNr); - - /// Then update flags and indices to be ready for next epoch - fuCurrentEpGdpb[ fGdpbNr ] = uEpochNr; - fuStarCurrentEpFound[ fGdpbNr ] = 0; - fuStarNextBufferUse[ fGdpbNr ] = 0; - fiStarBuffIdxPrev[ fGdpbNr ] = (fiStarBuffIdxPrev[ fGdpbNr ] + 1)%3; - fiStarBuffIdxCurr[ fGdpbNr ] = (fiStarBuffIdxCurr[ fGdpbNr ] + 1)%3; - fiStarBuffIdxNext[ fGdpbNr ] = (fiStarBuffIdxNext[ fGdpbNr ] + 1)%3; - } // else if( uEpochNr > (fuCurrentEpGdpb[ fGdpbNr ] + 1) ) - else - { - LOG(error) << "In STAR sort and cut mode, gDPB " << Form("0x%08x,", fGdpbId) - << " found epoch " << Form( "%12u", uEpochNr) - << " for get4 "<< Form( "%2u", fGet4Id) - << " while waiting for epoch " - << Form( "%12u", fuCurrentEpGdpb[ fGdpbNr ]) - << std::endl - << " -----> GET4 active mask is 0x" << std::hex - << fuStarActiveAsicMask[ fGdpbNr ] << " and GET4 ready flags is " - << fuStarCurrentEpFound[ fGdpbNr ] - << std::dec - << std::endl - << " => corrupted epoch number ordering, exiting now!"; - bEpochOk = kFALSE; - } // else of many ifs => Correspond to uEpochNr < fuCurrentEpGdpb[ fGdpbNr ] - - if( bEpochOk ) - { - /// Save the epoch message corresponding to the current buffer: - fvGdpbEpMsgBuffer[ fGdpbNr ][ fiStarBuffIdxCurr[ fGdpbNr ] ].push_back( mess ); - - /// Save content of current GET4 hit buffer in Current buffer! - //// ====> Not for epoch from token message - - - /// Epoch currently waiting for all GET4s to be ready - /// => This one is ready and starts "storing" its data in Next buffer - //// (no real effect as in this mode we dalay processing of hits) - //// ====> Not for epoch from token message - } // if( bEpochOk ) - } // if( fbStarSortAndCutMode ) - - } // if( fbEpochSuppModeOn ) - else if( fbStarSortAndCutMode ) - { - ///* STAR event building/cutting without EP suppr. */// - /// Only use GET4s declared as active - //// ====> Not for epoch from token message - LOG(fatal) << "In STAR sort and cut mode, full epoch mode not supported yet!"; - } // else if( fbStarSortAndCutMode ) of if( fbEpochSuppModeOn ) -} - -void CbmTSMonitorTofStar::Reset() -{ -} - -void CbmTSMonitorTofStar::Finish() -{ - /// Generate empty events for each remaining trigger in the buffers - if( fbEpochSuppModeOn && 0 < fiStarBuffIdxPrev.size() ) - { - UInt_t uNbFinalStarTokens = 0; - /** TODO: clarify how we deal with multiple sub-events (eg one for each gDPB) **/ - for( UInt_t uGdpbIdx = 0; uGdpbIdx < fNrOfGdpbs; ++uGdpbIdx ) - if( 0 < fiStarBuffIdxPrev[ uGdpbIdx ] ) - { - /// Previous epoch buffer - UInt_t uNbEpochTrgs = fvGdpbEpTrgBuffer[ uGdpbIdx ][ fiStarBuffIdxPrev[ uGdpbIdx ] ].size(); - for( UInt_t uTrigIdx = 0; uTrigIdx < uNbEpochTrgs; uTrigIdx ++) - { - StarGenEmptyEvt( uGdpbIdx, - fvGdpbEpTrgBuffer[ uGdpbIdx ] - [ fiStarBuffIdxPrev[ uGdpbIdx ] ] - [ uTrigIdx ] ); - uNbFinalStarTokens++; - } // for( UInt_t uTrigIdx = 0; uTrigIdx < uNbEpochTrgs; uTrigIdx ++) - - /// Current epoch buffer - uNbEpochTrgs = fvGdpbEpTrgBuffer[ uGdpbIdx ][ fiStarBuffIdxCurr[ uGdpbIdx ] ].size(); - for( UInt_t uTrigIdx = 0; uTrigIdx < uNbEpochTrgs; uTrigIdx ++) - { - StarGenEmptyEvt( uGdpbIdx, - fvGdpbEpTrgBuffer[ uGdpbIdx ] - [ fiStarBuffIdxCurr[ uGdpbIdx ] ] - [ uTrigIdx ] ); - uNbFinalStarTokens++; - } // for( UInt_t uTrigIdx = 0; uTrigIdx < uNbEpochTrgs; uTrigIdx ++) - - /// Next epoch buffer - uNbEpochTrgs = fvGdpbEpTrgBuffer[ uGdpbIdx ][ fiStarBuffIdxNext[ uGdpbIdx ] ].size(); - for( UInt_t uTrigIdx = 0; uTrigIdx < uNbEpochTrgs; uTrigIdx ++) - { - StarGenEmptyEvt( uGdpbIdx, - fvGdpbEpTrgBuffer[ uGdpbIdx ] - [ fiStarBuffIdxNext[ uGdpbIdx ] ] - [ uTrigIdx ] ); - uNbFinalStarTokens++; - } // for( UInt_t uTrigIdx = 0; uTrigIdx < uNbEpochTrgs; uTrigIdx ++) - } // for( UInt_t uGdpbIdx = 0; uGdpbIdx < fNrOfGdpbs; ++uGdpbIdx ) - LOG(info) << "Generated empty STAR events for the " << uNbFinalStarTokens - << " Last tokens without data in epoch"; - } // if( fbEpochSuppModeOn ) - - // Printout some stats on what was unpacked - TString message_type; - for (unsigned int i = 0; i < fMsgCounter.size(); ++i) { - switch (i) { - case 0: - message_type = "NOP"; - break; - case 1: - message_type = "HIT"; - break; - case 2: - message_type = "EPOCH"; - break; - case 3: - message_type = "SYNC"; - break; - case 4: - message_type = "AUX"; - break; - case 5: - message_type = "EPOCH2"; - break; - case 6: - message_type = "GET4"; - break; - case 7: - message_type = "SYS"; - break; - case 8: - message_type = "GET4_SLC"; - break; - case 9: - message_type = "GET4_32B"; - break; - case 10: - message_type = "GET4_SYS"; - break; - default: - message_type = "UNKNOWN"; - break; - } // switch(i) - LOG(info) << message_type << " messages: " << fMsgCounter[i]; - } // for (unsigned int i=0; i< fMsgCounter.size(); ++i) - - LOG(info) << "-------------------------------------"; - for (UInt_t i = 0; i < fNrOfGdpbs; ++i) { - for (UInt_t j = 0; j < fNrOfGet4PerGdpb; ++j) { - LOG(info) << "Last epoch for gDPB: " << std::hex << std::setw(4) << i - << std::dec << " , GET4 " << std::setw(4) << j << " => " - << fCurrentEpoch[GetArrayIndex(i, j)]; - } - } - LOG(info) << "-------------------------------------"; - - SaveAllHistos(); -} - -void CbmTSMonitorTofStar::FillOutput(boost::any) -{ -} - -void CbmTSMonitorTofStar::SaveAllHistos( TString sFileName ) -{ - TDirectory * oldDir = NULL; - TFile * histoFile = NULL; - if( "" != sFileName ) - { - // Store current directory position to allow restore later - oldDir = gDirectory; - // open separate histo file in recreate mode - histoFile = new TFile( sFileName , "RECREATE"); - histoFile->cd(); - } // if( "" != sFileName ) - - // Update the FT slected channel distribution if needed - if( fbGet4M24b ) - UpdateNormedFt(); - - gDirectory->mkdir("Tof_Raw_gDPB"); - gDirectory->cd("Tof_Raw_gDPB"); - for (UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; uGdpb++) { - - for (UInt_t uFeetPlot = 0; uFeetPlot < fNrOfFebsPerGdpb/uNbFeetPlot; ++uFeetPlot ) - fHM->H2(Form("Raw_Tot_gDPB_%02u_%1u", uGdpb, uFeetPlot))->Write(); - - fHM->H1(Form("ChCount_gDPB_%02u", uGdpb))->Write(); - if( fbGet4M24b ) - fHM->H1(Form("ChCountFall_gDPB_%02u", uGdpb))->Write(); - -// if (fUnpackPar->IsChannelRateEnabled()) -// fHM->H2(Form("ChannelRate_gDPB_%02u", uGdpb))->Write(); - for (UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; uFeet++) { - fHM->H1(Form("FeetRate_gDPB_g%02u_f%1u", uGdpb, uFeet))->Write(); - fHM->H1(Form("FeetErrorRate_gDPB_g%02u_f%1u", uGdpb, uFeet))->Write(); - fHM->H1(Form("FeetRateLong_gDPB_g%02u_f%1u", uGdpb, uFeet))->Write(); - fHM->H1(Form("FeetErrorRateLong_gDPB_g%02u_f%1u", uGdpb, uFeet))->Write(); - if( 0 < fiBinSizeDatePlots && 0 < fiRunStartDateTimeSec ) { - fHM->H1(Form("FeetRateDate_gDPB_g%02u_f%1u", uGdpb, uFeet))->Write(); - } // if( 0 < fiBinSizeDatePlots && 0 < fiRunStartDateTimeSec ) - fHM->H2(Form("FtDistribPerCh_gDPB_g%02u_f%1u", uGdpb, uFeet))->Write(); - fHM->H1(Form("SelChFtNormDnlRise_g%02u_f%1u", uGdpb, uFeet))->Write(); - fHM->H1(Form("FtNormDnlMinRise_g%02u_f%1u", uGdpb, uFeet))->Write(); - fHM->H1(Form("FtNormDnlMaxRise_g%02u_f%1u", uGdpb, uFeet))->Write(); - if( fbGet4M24b ) - { - fHM->H2(Form("FtDistribPerChFall_gDPB_g%02u_f%1u", uGdpb, uFeet))->Write(); - fHM->H1(Form("SelChFtNormDnlFall_g%02u_f%1u", uGdpb, uFeet))->Write(); - fHM->H1(Form("FtNormDnlMinFall_g%02u_f%1u", uGdpb, uFeet))->Write(); - fHM->H1(Form("FtNormDnlMaxFall_g%02u_f%1u", uGdpb, uFeet))->Write(); - fHM->H2(Form("FtLastRiseCurrFall_gDPB_g%02u_f%1u", uGdpb, uFeet))->Write(); - fHM->H2(Form("FtCurrRiseLastFall_gDPB_g%02u_f%1u", uGdpb, uFeet))->Write(); - fHM->H2(Form("FtLastRiseDistRise_gDPB_g%02u_f%1u", uGdpb, uFeet))->Write(); - fHM->H2(Form("FtLastRiseDistFall_gDPB_g%02u_f%1u", uGdpb, uFeet))->Write(); - } // if( fbGet4M24b ) - } // for (UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; uFeet++) - fRealMsFineQa_gDPB[uGdpb]->Write(); - fRealMsMidQa_gDPB[uGdpb]->Write(); - fRealMsCoarseQa_gDPB[uGdpb]->Write(); - } // for( UInt_t uGdpb = 0; uGdpb < fuMinNbGdpb; uGdpb ++) - fHM->H1("hMessageType")->Write(); - fHM->H1("hSysMessType")->Write(); - fHM->H2("hGet4MessType")->Write(); - fHM->H2("hGet4ChanScm")->Write(); - fHM->H2("hGet4ChanErrors")->Write(); - fHM->H2("hGet4EpochFlags")->Write(); - fHM->H1("hSpillLength")->Write(); - fHM->H1("hSpillCount")->Write(); - fHM->H1("hSpillQA")->Write(); - - gDirectory->cd(".."); - - ///* ASIC coincidences & offsets mapping */// -/* - gDirectory->mkdir("TofCoinc"); - gDirectory->cd("TofCoinc"); - for( UInt_t uAsicA = 0; uAsicA < fvhCoincOffsetEpochGet4.size(); uAsicA ++ ) - fvhCoincOffsetEpochGet4[uAsicA]->Write(); - gDirectory->cd(".."); -*/ - - ///* STAR event building/cutting */// - gDirectory->mkdir("Star_Raw"); - gDirectory->cd("Star_Raw"); - fhTokenMsgType->Write(); - fHM->H1("hTriggerRate")->Write(); - fHM->H1("hCmdDaqVsTrig")->Write(); - fHM->H1("hStarTokenEvo")->Write(); - if( fbStarSortAndCutMode ) - { - for (UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; uGdpb++) - { - fhStarHitToTrigAll_gDPB[ uGdpb ]->Write(); - fhStarHitToTrigWin_gDPB[ uGdpb ]->Write(); - fhStarEventSize_gDPB[ uGdpb ]->Write(); - fhStarEventSizeTime_gDPB[ uGdpb ]->Write(); - } // for (UInt_t uGdpb = 0; uGdpb < fuMinNbGdpb; uGdpb++) - } // if( fbStarSortAndCutMode ) - gDirectory->cd(".."); - - gDirectory->mkdir("Flib_Raw"); - gDirectory->cd("Flib_Raw"); - for (UInt_t uLinks = 0; uLinks < 16; uLinks++) { - TString sMsSzName = Form("MsSz_link_%02u", uLinks); - if (fHM->Exists(sMsSzName.Data())) - fHM->H1(sMsSzName.Data())->Write(); - - sMsSzName = Form("MsSzTime_link_%02u", uLinks); - if (fHM->Exists(sMsSzName.Data())) - fHM->P1(sMsSzName.Data())->Write(); - } // for( UInt_t uLinks = 0; uLinks < 16; uLinks ++) - gDirectory->cd(".."); - - if( "" != sFileName ) - { - // Restore original directory position - histoFile->Close(); - oldDir->cd(); - } // if( "" != sFileName ) - if( "" != sFileName ) - { - // Restore original directory position - histoFile->Close(); - oldDir->cd(); - } // if( "" != sFileName ) - -} - -void CbmTSMonitorTofStar::ResetAllHistos() -{ - LOG(info) << "Reseting all TOF histograms."; - fHM->H1("hMessageType")->Reset(); - fHM->H1("hSysMessType")->Reset(); - fHM->H2("hGet4MessType")->Reset(); - fHM->H2("hGet4ChanScm")->Reset(); - fHM->H2("hGet4ChanErrors")->Reset(); - fHM->H2("hGet4EpochFlags")->Reset(); - fHM->H1("hSpillLength")->Reset(); - fHM->H1("hSpillCount")->Reset(); - fHM->H2("hSpillQA")->Reset(); - fSpillIdx = 0; - - for (UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; uGdpb++) { - fHM->H1(Form("ChCount_gDPB_%02u", uGdpb))->Reset(); - if( fbGet4M24b ) - fHM->H1(Form("ChCountFall_gDPB_%02u", uGdpb))->Reset(); - - for (UInt_t uFeetPlot = 0; uFeetPlot < fNrOfFebsPerGdpb/uNbFeetPlot; ++uFeetPlot ) - fHM->H2(Form("Raw_Tot_gDPB_%02u_%1u", uGdpb, uFeetPlot))->Reset(); - -// if (fUnpackPar->IsChannelRateEnabled()) -// fHM->H2(Form("ChannelRate_gDPB_%02u", uGdpb))->Reset(); - for (UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; uFeet++) { - fHM->H1(Form("FeetRate_gDPB_g%02u_f%1u", uGdpb, uFeet))->Reset(); - fHM->H1(Form("FeetErrorRate_gDPB_g%02u_f%1u", uGdpb, uFeet))->Reset(); - fHM->H1(Form("FeetRateLong_gDPB_g%02u_f%1u", uGdpb, uFeet))->Reset(); - fHM->H1(Form("FeetErrorRateLong_gDPB_g%02u_f%1u", uGdpb, uFeet))->Reset(); - fHM->H2(Form("FtDistribPerCh_gDPB_g%02u_f%1u", uGdpb, uFeet))->Reset(); - fHM->H1(Form("SelChFtNormDnlRise_g%02u_f%1u", uGdpb, uFeet))->Reset(); - fHM->H1(Form("FtNormDnlMinRise_g%02u_f%1u", uGdpb, uFeet))->Reset(); - fHM->H1(Form("FtNormDnlMaxRise_g%02u_f%1u", uGdpb, uFeet))->Reset(); - - if( fbGet4M24b ) - { - fHM->H2(Form("FtDistribPerChFall_gDPB_g%02u_f%1u", uGdpb, uFeet))->Reset(); - fHM->H1(Form("SelChFtNormDnlFall_g%02u_f%1u", uGdpb, uFeet))->Reset(); - fHM->H1(Form("FtNormDnlMinFall_g%02u_f%1u", uGdpb, uFeet))->Reset(); - fHM->H1(Form("FtNormDnlMaxFall_g%02u_f%1u", uGdpb, uFeet))->Reset(); - fHM->H2(Form("FtLastRiseCurrFall_gDPB_g%02u_f%1u", uGdpb, uFeet))->Reset(); - fHM->H2(Form("FtCurrRiseLastFall_gDPB_g%02u_f%1u", uGdpb, uFeet))->Reset(); - fHM->H2(Form("FtLastRiseDistRise_gDPB_g%02u_f%1u", uGdpb, uFeet))->Reset(); - fHM->H2(Form("FtLastRiseDistFall_gDPB_g%02u_f%1u", uGdpb, uFeet))->Reset(); - } // if( fbGet4M24b ) - } // for( UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; uFeet ++) - fRealMsFineQa_gDPB[uGdpb]->Reset(); - fRealMsMidQa_gDPB[uGdpb]->Reset(); - fRealMsCoarseQa_gDPB[uGdpb]->Reset(); - fdFirstMsIndex = -1; - } // for( UInt_t uGdpb = 0; uGdpb < fuMinNbGdpb; uGdpb ++) - - for (UInt_t uLinks = 0; uLinks < 16; uLinks++) { - TString sMsSzName = Form("MsSz_link_%02u", uLinks); - if (fHM->Exists(sMsSzName.Data())) - fHM->H1(sMsSzName.Data())->Reset(); - - sMsSzName = Form("MsSzTime_link_%02u", uLinks); - if (fHM->Exists(sMsSzName.Data())) - fHM->P1(sMsSzName.Data())->Reset(); - } // for( UInt_t uLinks = 0; uLinks < 16; uLinks ++) - - if( fbPulserMode ) - { - fHM->H2("hTimeRmsPulserChosenFee")->Reset(); - fHM->H1("hTimeRmsPulserChosenChPairs")->Reset(); - fdLastRmsUpdateTime = -1; - - // Full Fee time difference test - UInt_t uHistoFeeIdx = 0; - for( UInt_t uChanFeeA = 0; uChanFeeA < fNrOfChannelsPerFeet; uChanFeeA++) - { - for( UInt_t uChanFeeB = uChanFeeA + 1; uChanFeeB < fNrOfChannelsPerFeet; uChanFeeB++) - { - fhTimeDiffPulserChosenFee[uHistoFeeIdx]->Reset(); - uHistoFeeIdx++; - } // for any unique pair of channel in chosen Fee - } // for( UInt_t uChanFeeA = 0; uChanFeeA < kuNbChanFee; uChanFeeA++) - - // Selected channels test - for( UInt_t uChan = 0; uChan < kuNbChanTest - 1; uChan++) - fhTimeDiffPulserChosenChPairs[uChan]->Reset(); - } // if( fbPulserMode ) - - ///* STAR event building/cutting */// - fhTokenMsgType->Reset(); - fHM->H1("hTriggerRate")->Reset(); - fHM->H1("hCmdDaqVsTrig")->Reset(); - fHM->H1("hStarTokenEvo")->Reset(); - if( fbStarSortAndCutMode ) - { - for (UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; uGdpb++) - { - fhStarHitToTrigAll_gDPB[ uGdpb ]->Reset(); - fhStarHitToTrigWin_gDPB[ uGdpb ]->Reset(); - fhStarEventSize_gDPB[ uGdpb ]->Reset(); - fhStarEventSizeTime_gDPB[ uGdpb ]->Reset(); - } // for (UInt_t uGdpb = 0; uGdpb < fuMinNbGdpb; uGdpb++) - } // if( fbStarSortAndCutMode ) - - fdStartTime = -1; - fdStartTimeLong = -1; - fdStartTimeMsSz = -1; -} -void CbmTSMonitorTofStar::CyclePulserFee() -{ - if( fbPulserMode ) - { - fHM->H2("hTimeRmsPulserChosenFee")->Reset(); - fdLastRmsUpdateTime = -1; - - // Full Fee time difference test - UInt_t uHistoFeeIdx = 0; - for( UInt_t uChanFeeA = 0; uChanFeeA < fNrOfChannelsPerFeet; uChanFeeA++) - { - for( UInt_t uChanFeeB = uChanFeeA + 1; uChanFeeB < fNrOfChannelsPerFeet; uChanFeeB++) - { - fhTimeDiffPulserChosenFee[uHistoFeeIdx]->Reset(); - uHistoFeeIdx++; - } // for any unique pair of channel in chosen Fee - } // for( UInt_t uChanFeeA = 0; uChanFeeA < kuNbChanFee; uChanFeeA++) - - // Cycle the chosen FEE index within the current chosen gDPB - fuPulserFee = (fuPulserFee + 1)%fNrOfFebsPerGdpb; - - LOG(info) << "FEE index for pulser RMS histo changed to : " << fuPulserFee; - } // if( fbPulserMode ) - - if( fbGet4M24b ) - { - // Full Fee time difference test - UInt_t uHistoFeeIdx = 0; - for (UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; uGdpb++) - { - for (UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; uFeet++) - { - fSelChFtNormDnlRise[uHistoFeeIdx]->Reset(); - fSelChFtNormDnlFall[uHistoFeeIdx]->Reset(); - fhFtLastRiseCurrFall[uHistoFeeIdx]->Reset(); - fhFtCurrRiseLastFall[uHistoFeeIdx]->Reset(); - fhFtLastRiseDistRise[uHistoFeeIdx]->Reset(); - fhFtLastRiseDistFall[uHistoFeeIdx]->Reset(); - - fSelChFtNormInlRise[uHistoFeeIdx]->Reset(); - fSelChFtNormInlFall[uHistoFeeIdx]->Reset(); - fhFtLastRiseCurrFall[uHistoFeeIdx]->Reset(); - fhFtCurrRiseLastFall[uHistoFeeIdx]->Reset(); - fhFtLastRiseDistRise[uHistoFeeIdx]->Reset(); - fhFtLastRiseDistFall[uHistoFeeIdx]->Reset(); - - uHistoFeeIdx++; - } // for (UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; uFeet++) - } // for (UInt_t uGdpb = 0; uGdpb < fuMinNbGdpb; uGdpb++) - - // Cycle the chosen FEE index within the current chosen gDPB - fuRiseFallChSel = (fuRiseFallChSel + 1)%fNrOfChannelsPerFeet; - - LOG(info) << "Channel index for 24b FT Rise vs FT Fall histo changed to : " << fuRiseFallChSel; - } // if( fbGet4M24b ) - -} -void CbmTSMonitorTofStar::UpdateNormedFt() -{ - TDirectory * oldDir = gDirectory; - - gROOT->cd(); - UInt_t uHistoFeeIdx = 0; - TF1 *constantVal = new TF1("constant","1", 0, get4v1x::kuFineCounterSize); - for (UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; uGdpb++) - { - for (UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; uFeet++) - { - fFtNormDnlMinRise[uHistoFeeIdx]->Reset(); - fFtNormDnlMaxRise[uHistoFeeIdx]->Reset(); - fFtNormInlMinRise[uHistoFeeIdx]->Reset(); - fFtNormInlMaxRise[uHistoFeeIdx]->Reset(); - if( fbGet4M24b ) - { - fFtNormDnlMinFall[uHistoFeeIdx]->Reset(); - fFtNormDnlMaxFall[uHistoFeeIdx]->Reset(); - fFtNormInlMinFall[uHistoFeeIdx]->Reset(); - fFtNormInlMaxFall[uHistoFeeIdx]->Reset(); - } // if( fbGet4M24b ) - - for (UInt_t uChannel = 0; uChannel < fNrOfChannelsPerFeet; uChannel++) - { - // Rising edge - TH1 * pFtSelChSliceRise = fhFtDistribPerCh[uHistoFeeIdx]->ProjectionY( "temp_pFtSelChSliceRise", - 1 + uChannel, 1 + uChannel); - if( 0 < pFtSelChSliceRise->GetEntries() ) - { - Double_t dNormFactRise = pFtSelChSliceRise->GetEntries() - / (fbGet4v20 ? 112. : get4v1x::kuFineCounterSize); - pFtSelChSliceRise->Scale( 1.0 / dNormFactRise ); - pFtSelChSliceRise->Add( constantVal, -1.); - } // if( 0 < pFtSelChSliceRise->GetEntries() ) - - // Falling edge - TH1 * pFtSelChSliceFall = NULL; - if( fbGet4M24b ) - { - pFtSelChSliceFall = fhFtDistribPerChFall[uHistoFeeIdx]->ProjectionY( "temp_pFtSelChSliceFall", - 1 + uChannel, 1 + uChannel); - if( 0 < pFtSelChSliceFall->GetEntries() ) - { - Double_t dNormFactFall = pFtSelChSliceFall->GetEntries() - / (fbGet4v20 ? 112. : get4v1x::kuFineCounterSize); - pFtSelChSliceFall->Scale( 1.0 / dNormFactFall ); - pFtSelChSliceFall->Add( constantVal, -1.); - } // if( 0 < pFtSelChSliceFall->GetEntries() ) - - if( fbGet4v20 ) - { - pFtSelChSliceRise->SetAxisRange( 8, 119 ); - pFtSelChSliceFall->SetAxisRange( 8, 119 ); - } // if( fbGet4v20 ) - } // if( fbGet4M24b ) - else if( fbGet4v20 ) - { - pFtSelChSliceRise->SetAxisRange( 0, 111 ); - } // if !fbGet4M24b and fbGet4v20 - - // INLs - fhTempHistInlRise->Reset(); - if( fbGet4M24b ) - fhTempHistInlFall->Reset(); - Double_t dInlRise = 0.0; - Double_t dInlFall = 0.0; - for( UInt_t uFtBin = 0; uFtBin < get4v1x::kuFineCounterSize; uFtBin++) - { - dInlRise += pFtSelChSliceRise->GetBinContent( 1 + uFtBin ); - fhTempHistInlRise->Fill( uFtBin, dInlRise ); - - if( fbGet4M24b ) - { - dInlFall += pFtSelChSliceFall->GetBinContent( 1 + uFtBin ); - fhTempHistInlFall->Fill( uFtBin, dInlFall ); - } // if( fbGet4M24b ) - } // for( UInt_t uFtBin = 0; uFtBin < get4v1x::kuFineCounterSize; uFtBin++) - if( fbGet4v20 ) - { - if( fbGet4M24b ) - { - fhTempHistInlRise->SetAxisRange( 8, 119 ); - fhTempHistInlFall->SetAxisRange( 8, 119 ); - } // if( fbGet4M24b ) - else fhTempHistInlRise->SetAxisRange( 0, 111 ); - } // if( fbGet4v20 ) - - // Fill min/max histos - fFtNormDnlMinRise[uHistoFeeIdx]->Fill( uChannel, pFtSelChSliceRise->GetMinimum() ); - fFtNormDnlMaxRise[uHistoFeeIdx]->Fill( uChannel, pFtSelChSliceRise->GetMaximum() ); - fFtNormInlMinRise[uHistoFeeIdx]->Fill( uChannel, fhTempHistInlRise->GetMinimum() ); - fFtNormInlMaxRise[uHistoFeeIdx]->Fill( uChannel, fhTempHistInlRise->GetMaximum() ); - if( fbGet4M24b ) - { - fFtNormDnlMinFall[uHistoFeeIdx]->Fill( uChannel, pFtSelChSliceFall->GetMinimum() ); - fFtNormDnlMaxFall[uHistoFeeIdx]->Fill( uChannel, pFtSelChSliceFall->GetMaximum() ); - fFtNormInlMinFall[uHistoFeeIdx]->Fill( uChannel, fhTempHistInlFall->GetMinimum() ); - fFtNormInlMaxFall[uHistoFeeIdx]->Fill( uChannel, fhTempHistInlFall->GetMaximum() ); - } // if( fbGet4M24b ) - - if( uChannel == fuRiseFallChSel ) - { - fSelChFtNormDnlRise[uHistoFeeIdx]->Reset(); - fSelChFtNormDnlRise[uHistoFeeIdx]->Add( pFtSelChSliceRise ); - - fSelChFtNormInlRise[uHistoFeeIdx]->Reset(); - fSelChFtNormInlRise[uHistoFeeIdx]->Add( fhTempHistInlRise ); - - if( fbGet4M24b ) - { - fSelChFtNormDnlFall[uHistoFeeIdx]->Reset(); - fSelChFtNormDnlFall[uHistoFeeIdx]->Add( pFtSelChSliceFall ); - - fSelChFtNormInlFall[uHistoFeeIdx]->Reset(); - fSelChFtNormInlFall[uHistoFeeIdx]->Add( fhTempHistInlFall ); - - if( fbGet4v20 ) - { - fSelChFtNormDnlRise[uHistoFeeIdx]->SetAxisRange( 8, 119 ); - fSelChFtNormDnlFall[uHistoFeeIdx]->SetAxisRange( 8, 119 ); - - fSelChFtNormInlRise[uHistoFeeIdx]->SetAxisRange( 8, 119 ); - fSelChFtNormInlFall[uHistoFeeIdx]->SetAxisRange( 8, 119 ); - } // if( fbGet4v20 ) - } // if( fbGet4M24b ) - else if( fbGet4v20 ) - { - fSelChFtNormDnlRise[uHistoFeeIdx]->SetAxisRange( 0, 111 ); - fSelChFtNormInlRise[uHistoFeeIdx]->SetAxisRange( 0, 111 ); - } // if !fbGet4M24b and fbGet4v20 - - LOG(info) << "Gdpb " << uGdpb << " Feet " << uFeet - << " Leading DNL min " << fSelChFtNormDnlRise[uHistoFeeIdx]->GetMinimum() - << " max " << fSelChFtNormDnlRise[uHistoFeeIdx]->GetMaximum(); - if( fbGet4M24b ) - LOG(info) << "Gdpb " << uGdpb << " Feet " << uFeet - << " Trailing DNL min " << fSelChFtNormDnlFall[uHistoFeeIdx]->GetMinimum() - << " max " << fSelChFtNormDnlFall[uHistoFeeIdx]->GetMaximum(); - } // if( uChannel == fuRiseFallChSel ) - - delete pFtSelChSliceRise; - if( fbGet4M24b ) - delete pFtSelChSliceFall; - } // for (UInt_t uChannel = 0; uChannel < fNrOfChannelsPerFeet; uChannel++) - - // Update histo index - uHistoFeeIdx++; - } // for (UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; uFeet++) - } // for (UInt_t uGdpb = 0; uGdpb < fuMinNbGdpb; uGdpb++) - delete constantVal; - - oldDir->cd(); -} -void CbmTSMonitorTofStar::UpdateZoomedFit() -{ - // Do something only if we are in pulser mode - if( kFALSE == fbPulserMode ) - return; - - // Only do something is the user defined the width a want for the zoom - if( 0.0 < fdFitZoomWidthPs ) - { - // Reset summary histograms for safety - fhTimeRmsZoomPulsChosenFee->Reset(); - fhTimeRmsZoomFitPulsChosenChPairs->Reset(); - fhTimeResFitPulsChosenFee->Reset(); - fhTimeResFitPulsChosenChPairs->Reset(); - - UInt_t uHistoFeeIdx = 0; - Double_t dRes = 0; - TF1 *fitFuncFee[ fNrOfChannelsPerFeet * fNrOfChannelsPerFeet ]; // bigger than needed but OK - for( UInt_t uChanFeeA = 0; uChanFeeA < fNrOfChannelsPerFeet; uChanFeeA++) - { - for( UInt_t uChanFeeB = uChanFeeA + 1; uChanFeeB < fNrOfChannelsPerFeet; uChanFeeB++) - { - // Check that we have at least 1 entry - if( 0 == fhTimeDiffPulserChosenFee[uHistoFeeIdx]->GetEntries() ) - { - fhTimeRmsZoomPulsChosenFee->Fill( uChanFeeA, uChanFeeB, 0.0 ); - fhTimeResFitPulsChosenFee->Fill( uChanFeeA, uChanFeeB, 0.0 ); - LOG(info) << "CbmTSMonitorTofStar::UpdateZoomedFit => Empty input " - << "for channels " << uChanFeeA << " and " << uChanFeeB << " !!!"; - continue; - } // if( 0 == fhTimeDiffPulserChosenFee[uHistoFeeIdx]->GetEntries() ) - - // Read the peak position (bin with max counts) + total nb of entries - Int_t iBinWithMax = fhTimeDiffPulserChosenFee[uHistoFeeIdx]->GetMaximumBin(); - Double_t dNbCounts = fhTimeDiffPulserChosenFee[uHistoFeeIdx]->Integral(); - - // Zoom the X axis to +/- ZoomWidth around the peak position - Double_t dPeakPos = fhTimeDiffPulserChosenFee[uHistoFeeIdx]->GetXaxis()->GetBinCenter( iBinWithMax ); - fhTimeDiffPulserChosenFee[uHistoFeeIdx]->GetXaxis()->SetRangeUser( dPeakPos - fdFitZoomWidthPs, - dPeakPos + fdFitZoomWidthPs ); - - // Read integral and check how much we lost due to the zoom (% loss allowed) - Double_t dZoomCounts = fhTimeDiffPulserChosenFee[uHistoFeeIdx]->Integral(); - if( ( dZoomCounts / dNbCounts ) < 0.99 ) - { - fhTimeRmsZoomPulsChosenFee->Fill( uChanFeeA, uChanFeeB, 0.0 ); - fhTimeResFitPulsChosenFee->Fill( uChanFeeA, uChanFeeB, 0.0 ); - LOG(warning) << "CbmTSMonitorTofStar::UpdateZoomedFit => Zoom too strong, " - << "more than 1% loss for channels " << uChanFeeA << " and " - << uChanFeeB << " !!!"; - continue; - } // if( ( dZoomCounts / dNbCounts ) < 0.99 ) - - // Fill new RMS after zoom into summary histo - fhTimeRmsZoomPulsChosenFee->Fill( uChanFeeA, uChanFeeB, fhTimeDiffPulserChosenFee[uHistoFeeIdx]->GetRMS() ); - - // Fit using zoomed boundaries + starting gaussian width, store into summary histo - dRes = 0; - fitFuncFee[uHistoFeeIdx] = new TF1( Form("fFee_%02d", uHistoFeeIdx ), "gaus", - dPeakPos - fdFitZoomWidthPs , - dPeakPos + fdFitZoomWidthPs); - // Fix the Mean fit value around the Histogram Mean - fitFuncFee[uHistoFeeIdx]->SetParameter( 0, dZoomCounts ); - fitFuncFee[uHistoFeeIdx]->SetParameter( 1, dPeakPos ); - fitFuncFee[uHistoFeeIdx]->SetParameter( 2, 200.0 ); // Hardcode start with ~4*BinWidth, do better later - // Using integral instead of bin center seems to lead to unrealistic values => no "I" - fhTimeDiffPulserChosenFee[uHistoFeeIdx]->Fit( Form("fFee_%02d", uHistoFeeIdx ), "QRM0"); - // Get Sigma - dRes = fitFuncFee[uHistoFeeIdx]->GetParameter(2); - // Cleanup memory - delete fitFuncFee[uHistoFeeIdx]; - // Fill summary - fhTimeResFitPulsChosenFee->Fill( uChanFeeA, uChanFeeB, dRes / TMath::Sqrt2() ); - - // Restore original axis state? - fhTimeDiffPulserChosenFee[uHistoFeeIdx]->GetXaxis()->UnZoom(); - - uHistoFeeIdx++; - } // for( UInt_t uChanFeeB = uChanFeeA + 1; uChanFeeB < fNrOfChannelsPerFeet; uChanFeeB++) - } // for( UInt_t uChanFeeA = 0; uChanFeeA < fNrOfChannelsPerFeet; uChanFeeA++) - - TF1 *fitFuncPairs[ kuNbChanTest - 1 ]; - for( UInt_t uChan = 0; uChan < kuNbChanTest - 1; uChan++) - { - // Check that we have at least 1 entry - if( 0 == fhTimeDiffPulserChosenChPairs[uChan]->GetEntries() ) - { - fhTimeRmsZoomFitPulsChosenChPairs->Fill( uChan, 0.0 ); - fhTimeResFitPulsChosenChPairs->Fill( uChan, 0.0 ); - LOG(info) << "CbmTSMonitorTofStar::UpdateZoomedFit => Empty input " - << "for channels pair " << uChan << " !!! "; - continue; - } // if( 0 == fhTimeDiffPulserChosenChPairs[uChan]>GetEntries() ) - - // Read the peak position (bin with max counts) + total nb of entries - Int_t iBinWithMax = fhTimeDiffPulserChosenChPairs[uChan]->GetMaximumBin(); - Double_t dNbCounts = fhTimeDiffPulserChosenChPairs[uChan]->Integral(); - - // Zoom the X axis to +/- ZoomWidth around the peak position - Double_t dPeakPos = fhTimeDiffPulserChosenChPairs[uChan]->GetXaxis()->GetBinCenter( iBinWithMax ); - fhTimeDiffPulserChosenChPairs[uChan]->GetXaxis()->SetRangeUser( dPeakPos - fdFitZoomWidthPs, - dPeakPos + fdFitZoomWidthPs ); - - // Read integral and check how much we lost due to the zoom (% loss allowed) - Double_t dZoomCounts = fhTimeDiffPulserChosenChPairs[uChan]->Integral(); - if( ( dZoomCounts / dNbCounts ) < 0.99 ) - { - fhTimeRmsZoomFitPulsChosenChPairs->Fill( uChan, 0.0 ); - fhTimeResFitPulsChosenChPairs->Fill( uChan, 0.0 ); - LOG(warning) << "CbmTSMonitorTofStar::UpdateZoomedFit => Zoom too strong, " - << "more than 1% loss for channels pair " << uChan << " !!!"; - continue; - } // if( ( dZoomCounts / dNbCounts ) < 0.99 ) - - // Fill new RMS after zoom into summary histo - fhTimeRmsZoomFitPulsChosenChPairs->Fill( uChan, fhTimeDiffPulserChosenChPairs[uChan]->GetRMS() ); - - - // Fit using zoomed boundaries + starting gaussian width, store into summary histo - dRes = 0; - fitFuncPairs[uChan] = new TF1( Form("fPair_%02d", uChan ), "gaus", - dPeakPos - fdFitZoomWidthPs , - dPeakPos + fdFitZoomWidthPs); - // Fix the Mean fit value around the Histogram Mean - fitFuncPairs[uChan]->SetParameter( 0, dZoomCounts ); - fitFuncPairs[uChan]->SetParameter( 1, dPeakPos ); - fitFuncPairs[uChan]->SetParameter( 2, 200.0 ); // Hardcode start with ~4*BinWidth, do better later - // Using integral instead of bin center seems to lead to unrealistic values => no "I" - fhTimeDiffPulserChosenChPairs[uChan]->Fit( Form("fPair_%02d", uChan ), "QRM0"); - // Get Sigma - dRes = fitFuncPairs[uChan]->GetParameter(2); - // Cleanup memory - delete fitFuncPairs[uChan]; - // Fill summary - fhTimeResFitPulsChosenChPairs->Fill( uChan, dRes / TMath::Sqrt2() ); - - // Restore original axis state? - fhTimeDiffPulserChosenChPairs[uChan]->GetXaxis()->UnZoom(); - } // for( UInt_t uChan = 0; uChan < kuNbChanTest - 1; uChan++) - } // if( 0.0 < fdFitZoomWidthPs ) - else - { - LOG(error) << "CbmTSMonitorTofStar::UpdateZoomedFit => Zoom width not defined, " - << "please use SetFitZoomWidthPs, e.g. in macro, before trying this update !!!"; - } // else of if( 0.0 < fdFitZoomWidthPs ) -/* - { - // Update RMS plots only every 10s in data - if( 10.0 < dTsStartTime - fdLastRmsUpdateTime ) - { - - } // if( 10.0 < dTsStartTime - fdLastRmsUpdateTime ) - } // if( kTRUE == fbPulserMode ) - */ -} - -void CbmTSMonitorTofStar::SetRunStart( Int_t dateIn, Int_t timeIn, Int_t iBinSize ) -{ - TDatime * fRunStartDateTime = new TDatime( dateIn, timeIn); - fiRunStartDateTimeSec = fRunStartDateTime->Convert(); - fiBinSizeDatePlots = iBinSize; - - LOG(info) << "Assigned new TOF Run Start Date-Time: " << fRunStartDateTime->AsString(); -} - -void CbmTSMonitorTofStar::SetPulserChans( - UInt_t inPulserChanA, UInt_t inPulserChanB, UInt_t inPulserChanC, UInt_t inPulserChanD, - UInt_t inPulserChanE, UInt_t inPulserChanF, UInt_t inPulserChanG, UInt_t inPulserChanH, - UInt_t inPulserChanI, UInt_t inPulserChanJ, UInt_t inPulserChanK, UInt_t inPulserChanL, - UInt_t inPulserChanM, UInt_t inPulserChanN, UInt_t inPulserChanO, UInt_t inPulserChanP, - UInt_t inPulserChanQ, UInt_t inPulserChanR ) -{ - fuPulserChan[ 0] = inPulserChanA; - fuPulserChan[ 1] = inPulserChanB; - fuPulserChan[ 2] = inPulserChanC; - fuPulserChan[ 3] = inPulserChanD; - fuPulserChan[ 4] = inPulserChanE; - fuPulserChan[ 5] = inPulserChanF; - fuPulserChan[ 6] = inPulserChanG; - fuPulserChan[ 7] = inPulserChanH; - fuPulserChan[ 8] = inPulserChanI; - fuPulserChan[ 9] = inPulserChanJ; - fuPulserChan[10] = inPulserChanK; - fuPulserChan[11] = inPulserChanL; - fuPulserChan[12] = inPulserChanM; - fuPulserChan[13] = inPulserChanN; - fuPulserChan[14] = inPulserChanO; - fuPulserChan[15] = inPulserChanP; - fuPulserChan[16] = inPulserChanQ; - fuPulserChan[17] = inPulserChanR; -} - - ///* STAR event building/cutting */// -Bool_t CbmTSMonitorTofStar::StarSort( Int_t iGdpbIdx ) -{ - // Sort the messages in current buffer relative to time - std::stable_sort( fvGdpbEpHitBuffer[ iGdpbIdx ][ fiStarBuffIdxCurr[ iGdpbIdx ] ].begin(), - fvGdpbEpHitBuffer[ iGdpbIdx ][ fiStarBuffIdxCurr[ iGdpbIdx ] ].end() ); - - // Sort the triggers in current buffer relative to time - std::stable_sort( fvGdpbEpTrgBuffer[ iGdpbIdx ][ fiStarBuffIdxCurr[ iGdpbIdx ] ].begin(), - fvGdpbEpTrgBuffer[ iGdpbIdx ][ fiStarBuffIdxCurr[ iGdpbIdx ] ].end() ); - - return kTRUE; -} -Bool_t CbmTSMonitorTofStar::StarSelect( Int_t iGdpbIdx ) -{ - /** Read the triggers one by one and for each scan the messages until one outside of the - ** event window is found - **/ - - /// Reload the value of the End of the trigger window from last trigger - Double_t dLastTriggerWinEnd = get4v1x::kdClockCycleSizeNs * fuLastTriggerFullTs[ iGdpbIdx ] - - fdStarTriggerDelay[ iGdpbIdx ] - + fdStarTriggerWinSize[ iGdpbIdx ]; - - /**** Process all triggers in the current buffer (ones that could have data in current) - **** This includes for the first ones looking if they do not need data from the previous buffer ****/ - UInt_t uNbPrevEpochMsgs = fvGdpbEpMsgBuffer[ iGdpbIdx ][ fiStarBuffIdxPrev[ iGdpbIdx ] ].size(); - UInt_t uNbPrevEpochHits = fvGdpbEpHitBuffer[ iGdpbIdx ][ fiStarBuffIdxPrev[ iGdpbIdx ] ].size(); -// UInt_t uNbPrevEpochTrgs = fvGdpbEpTrgBuffer[ iGdpbIdx ][ fiStarBuffIdxPrev[ iGdpbIdx ] ].size(); - UInt_t uNbEpochMsgs = fvGdpbEpMsgBuffer[ iGdpbIdx ][ fiStarBuffIdxCurr[ iGdpbIdx ] ].size(); - UInt_t uNbEpochHits = fvGdpbEpHitBuffer[ iGdpbIdx ][ fiStarBuffIdxCurr[ iGdpbIdx ] ].size(); - UInt_t uNbEpochTrgs = fvGdpbEpTrgBuffer[ iGdpbIdx ][ fiStarBuffIdxCurr[ iGdpbIdx ] ].size(); - Bool_t bFirstHitFound = kFALSE; - UInt_t uFirstHitIdxPrevTrgPrevBuf = 0; - UInt_t uFirstHitIdxPrevTrigg = 0; - for( UInt_t uTrigIdx = 0; uTrigIdx < uNbEpochTrgs; uTrigIdx ++) - { - Bool_t bFullPrevEvent = kFALSE; // default is event with hits in this buffer - - /// In any case, associate this trigger to its subevent - fStarSubEvent.SetTrigger( fvGdpbEpTrgBuffer[ iGdpbIdx ][ fiStarBuffIdxCurr[ iGdpbIdx ] ][uTrigIdx] ); - - if( 0 == uNbEpochMsgs && 0 < uNbEpochHits ) - LOG(fatal) << "In star Sort and cut, some hit messages were found without corresponding epoch message(s)" - << std::endl - << "====> This sould NEVER happen, code broken or corrupt data!!!"; - - /// Ignore Trigger stored but not corresponding to this epoch and the previous one - /// Triggers with higher epoch numbers are shifted to next buffer! - /// This should happen only on epoch suppressed mode - Double_t dTriggerTime = get4v1x::kdClockCycleSizeNs * - ( fvGdpbEpTrgBuffer[ iGdpbIdx ] - [ fiStarBuffIdxCurr[ iGdpbIdx ] ] - [ uTrigIdx ].GetFullGdpbTs() ); - UInt_t uTriggerEpIdx = fvGdpbEpTrgBuffer[ iGdpbIdx ] - [ fiStarBuffIdxCurr[ iGdpbIdx ] ] - [ uTrigIdx ].GetFullGdpbEpoch(); - Double_t dTriggerWinStart = dTriggerTime - fdStarTriggerDelay[ iGdpbIdx ]; - Double_t dTriggerWinStop = dTriggerTime - fdStarTriggerDelay[ iGdpbIdx ] - + fdStarTriggerWinSize[ iGdpbIdx ]; - Double_t dEpochTime = fvGdpbEpMsgBuffer[ iGdpbIdx ] - [ fiStarBuffIdxCurr[ iGdpbIdx ] ] - [ 0 ].getMsgFullTimeD( 0 ); - UInt_t uEpochIdx = fvGdpbEpMsgBuffer[ iGdpbIdx ] - [ fiStarBuffIdxCurr[ iGdpbIdx ] ] - [ 0 ].getGdpbEpEpochNb(); - - fhStarEpToTrig_gDPB[ iGdpbIdx ]->Fill( uEpochIdx, dEpochTime - dTriggerTime ); - - /// Trigger windows overlap is not allowed!!! - /// Any trigger with a window overlaping the previous one is sent to STAR as empty event - /// with the overlap event flag - if( dTriggerWinStart < dLastTriggerWinEnd ) - { - fStarSubEvent.SetBadEventFlag(); - fStarSubEvent.SetOverlapEventFlag(); - - /** TODO: clarify how we deal with multiple sub-events (eg one for each gDPB) **/ - Int_t iBuffSzByte = 0; - void * pDataBuff = fStarSubEvent.BuildOutput( iBuffSzByte ); - if( NULL != pDataBuff ) - { - /// Valid output, do stuff with it! -#ifdef STAR_SUBEVT_BUILDER - /* - ** Function to send sub-event block to the STAR DAQ system - * trg_word received is packed as: - * - * trg_cmd|daq_cmd|tkn_hi|tkn_mid|tkn_lo - */ - star_rhicf_write( fStarSubEvent.GetTrigger().GetStarTrigerWord(), - pDataBuff, iBuffSzByte ); - fulNbStarEvent++; -/* - LOG(info) << "Sent STAR event with size " << iBuffSzByte << " Bytes" - << " and token " << fStarSubEvent.GetTrigger().GetStarToken(); -*/ -#endif // STAR_SUBEVT_BUILDER - } // if( NULL != pDataBuff ) - else LOG(error) << "Invalid STAR SubEvent Output, can only happen if trigger " - << " object was not set => Do Nothing more with it!!! "; - - /// Fill plot of event size - fhStarEventSize_gDPB[ iGdpbIdx ]->Fill( iBuffSzByte ); - /// Fill plot of event size as function of trigger time - if( 0 < fdStartTime ) - fhStarEventSizeTime_gDPB[ iGdpbIdx ]->Fill( 1e-9 *(dTriggerTime - fdStartTime), iBuffSzByte ); - - /// Now clear the sub-event - fStarSubEvent.ClearSubEvent(); - continue; - } // if( dTriggerWinStart < dLastTriggerWinEnd ) - - /// Triggers from old epochs ending up here are just ignored and sent to STAR as empty events - /// Triggers from next epochs are shifted to the next buffer for later processing - if( uTriggerEpIdx < uEpochIdx ) - { - /** TODO: clarify how we deal with multiple sub-events (eg one for each gDPB) **/ - Int_t iBuffSzByte = 0; - void * pDataBuff = fStarSubEvent.BuildOutput( iBuffSzByte ); - if( NULL != pDataBuff ) - { - /// Valid output, do stuff with it! -#ifdef STAR_SUBEVT_BUILDER - /* - ** Function to send sub-event block to the STAR DAQ system - * trg_word received is packed as: - * - * trg_cmd|daq_cmd|tkn_hi|tkn_mid|tkn_lo - */ - star_rhicf_write( fStarSubEvent.GetTrigger().GetStarTrigerWord(), - pDataBuff, iBuffSzByte ); - fulNbStarEvent++; -/* - LOG(info) << "Sent STAR event with size " << iBuffSzByte << " Bytes" - << " and token " << fStarSubEvent.GetTrigger().GetStarToken(); -*/ -#endif // STAR_SUBEVT_BUILDER - } // if( NULL != pDataBuff ) - else LOG(error) << "Invalid STAR SubEvent Output, can only happen if trigger " - << " object was not set => Do Nothing more with it!!! "; - - /// Fill plot of event size - fhStarEventSize_gDPB[ iGdpbIdx ]->Fill( iBuffSzByte ); - /// Fill plot of event size as function of trigger time - if( 0 < fdStartTime ) - fhStarEventSizeTime_gDPB[ iGdpbIdx ]->Fill( 1e-9 *(dTriggerTime - fdStartTime), iBuffSzByte ); - - /// Now clear the sub-event - fStarSubEvent.ClearSubEvent(); - continue; - } // if( uTriggerEpIdx < uEpochIdx ) - else if( uTriggerEpIdx > uEpochIdx ) - { - /// shift to next buffer then continue - fvGdpbEpTrgBuffer[ iGdpbIdx ][ fiStarBuffIdxNext[ iGdpbIdx ] ].push_back( - fvGdpbEpTrgBuffer[ iGdpbIdx ][ fiStarBuffIdxCurr[ iGdpbIdx ] ][uTrigIdx] ); - continue; - } // else if( uTriggerEpIdx > uEpochIdx ) - - /// This trigger matches the epoch in this buffer - - /// First check if it may include hits from the previous epoch buffer - if( dTriggerWinStart < dEpochTime ) - { - /// Check if the previous buffer end time fits with the window start - /// (Equivalent to checking that previous buffer contains the previous epoch) - Double_t dPrevBufferEndTime = get4v1x::kdEpochInNs + - fvGdpbEpMsgBuffer[ iGdpbIdx ][ fiStarBuffIdxPrev[ iGdpbIdx ] ][ 0 ].getMsgFullTimeD( 0 ); - if( dTriggerWinStart < dPrevBufferEndTime ) - { - /// Then add all the epoch messages from the previous buffer to this SubEvent - for( UInt_t uEpochMsg = 0; uEpochMsg < uNbPrevEpochMsgs; uEpochMsg++ ) - fStarSubEvent.AddMsg( fvGdpbEpMsgBuffer[ iGdpbIdx ][ fiStarBuffIdxPrev[ iGdpbIdx ] ][ uEpochMsg ] ); - - /// Then scan to find the hit messages in prev buff fitting the event window of this trigger - bFirstHitFound = kFALSE; -// Double_t dTimeFirstHit = -1; - UInt_t uEpochHit; - for( uEpochHit = uFirstHitIdxPrevTrgPrevBuf; uEpochHit < uNbPrevEpochHits; uEpochHit++ ) - { - Double_t dHitTime = fvGdpbEpHitBuffer[ iGdpbIdx ] - [ fiStarBuffIdxPrev[ iGdpbIdx ] ] - [ uEpochHit ]. getMsgFullTimeD( uEpochIdx ); - - /// Fill plot of Hit time - Trigger time for all hits - fhStarHitToTrigAll_gDPB[ iGdpbIdx ]->Fill( dHitTime - dTriggerTime ); - - /// Check trigger window - if( dTriggerWinStart < dHitTime ) - { - /// Hit Time after beginning of trigger window - if( dHitTime < dTriggerWinStop ) - { - /// First hit for next trigger cannot be before first hit for this trigger - /// as they are time sorted - if( !bFirstHitFound ) - { - uFirstHitIdxPrevTrgPrevBuf = uEpochHit; - } // if( !bFirstHitFound ) - - /// Fill plot for Hit time - Trigger time for hits within trigger window - fhStarHitToTrigWin_gDPB[ iGdpbIdx ]->Fill( dHitTime - dTriggerTime ); - - /// Add hit message to SubEvent - fStarSubEvent.AddMsg( fvGdpbEpHitBuffer[ iGdpbIdx ][ fiStarBuffIdxPrev[ iGdpbIdx ] ][ uEpochHit ] ); - } // if( dHitTime < dTriggerWinStop ) - else break; - } // if( dTriggerWinStart < dHitTime ) -/* - if( 0 == uTrigIdx ) - { - if( dTimeFirstHit < 0 ) - dTimeFirstHit = dHitTime; - else fhStarHitToTrigAll_gDPB[ iGdpbIdx ]->Fill( dTimeFirstHit - dHitTime ); - } -*/ - } // for( UInt_t uEpochHit = 0; uEpochHit < uNbEpochHits; uEpochHit++ ) - - /// If hits after end of window found, we don't need to go to the following buffer - if( uEpochHit < uNbPrevEpochHits ) - bFullPrevEvent = kTRUE; - } // if( dTriggerWinStart < dPrevBufferEndTime ) - } // if( dTriggerWinStart < dEpochTime ) - - if( kFALSE == bFullPrevEvent ) - { - /// Then add all the epoch messages for this block to this SubEvent - for( UInt_t uEpochMsg = 0; uEpochMsg < uNbEpochMsgs; uEpochMsg++ ) - fStarSubEvent.AddMsg( fvGdpbEpMsgBuffer[ iGdpbIdx ][ fiStarBuffIdxCurr[ iGdpbIdx ] ][ uEpochMsg ] ); - - /// Then scan to find the hit messages fitting the event window of this trigger - bFirstHitFound = kFALSE; -// Double_t dTimeFirstHit = -1; - for( UInt_t uEpochHit = uFirstHitIdxPrevTrigg; uEpochHit < uNbEpochHits; uEpochHit++ ) - { - Double_t dHitTime = fvGdpbEpHitBuffer[ iGdpbIdx ] - [ fiStarBuffIdxCurr[ iGdpbIdx ] ] - [ uEpochHit ]. getMsgFullTimeD( uEpochIdx ); - - /// Fill plot of Hit time - Trigger time for all hits - fhStarHitToTrigAll_gDPB[ iGdpbIdx ]->Fill( dHitTime - dTriggerTime ); - - /// Check trigger window - if( dTriggerWinStart < dHitTime ) - { - /// Hit Time after beginning of trigger window - if( dHitTime < dTriggerWinStop ) - { - /// First hit for next trigger cannot be before first hit for this trigger - /// as they are time sorted - if( !bFirstHitFound ) - { - uFirstHitIdxPrevTrigg = uEpochHit; - } // if( !bFirstHitFound ) - - /// Fill plot for Hit time - Trigger time for hits within trigger window - fhStarHitToTrigWin_gDPB[ iGdpbIdx ]->Fill( dHitTime - dTriggerTime ); - - /// Add hit message to SubEvent - fStarSubEvent.AddMsg( fvGdpbEpHitBuffer[ iGdpbIdx ][ fiStarBuffIdxCurr[ iGdpbIdx ] ][ uEpochHit ] ); - } // if( dHitTime < dTriggerWinStop ) - else break; - } // if( dTriggerWinStart < dHitTime ) -/* - if( 0 == uTrigIdx ) - { - if( dTimeFirstHit < 0 ) - dTimeFirstHit = dHitTime; - else fhStarHitToTrigAll_gDPB[ iGdpbIdx ]->Fill( dTimeFirstHit - dHitTime ); - } -*/ - } // for( UInt_t uEpochHit = 0; uEpochHit < uNbEpochHits; uEpochHit++ ) - } // if( kFALSE == bFullPrevEvent ) - - /** TODO: clarify how we deal with multiple sub-events (eg one for each gDPB) **/ - Int_t iBuffSzByte = 0; - void * pDataBuff = fStarSubEvent.BuildOutput( iBuffSzByte ); - if( NULL != pDataBuff ) - { - /// Valid output, do stuff with it! -#ifdef STAR_SUBEVT_BUILDER - /* - ** Function to send sub-event block to the STAR DAQ system - * trg_word received is packed as: - * - * trg_cmd|daq_cmd|tkn_hi|tkn_mid|tkn_lo - */ - star_rhicf_write( fStarSubEvent.GetTrigger().GetStarTrigerWord(), - pDataBuff, iBuffSzByte ); - fulNbStarEvent++; -/* - LOG(info) << "Sent STAR event with size " << iBuffSzByte << " Bytes" - << " and token " << fStarSubEvent.GetTrigger().GetStarToken(); -*/ -#endif // STAR_SUBEVT_BUILDER - } // if( NULL != pDataBuff ) - else LOG(error) << "Invalid STAR SubEvent Output, can only happen if trigger " - << " object was not set => Do Nothing more with it!!! "; - - /// Fill plot of event size - fhStarEventSize_gDPB[ iGdpbIdx ]->Fill( iBuffSzByte ); - /// Fill plot of event size as function of trigger time - if( 0 < fdStartTime ) - fhStarEventSizeTime_gDPB[ iGdpbIdx ]->Fill( 1e-9 *(dTriggerTime - fdStartTime), iBuffSzByte ); - - /// Now clear the sub-event - fStarSubEvent.ClearSubEvent(); - } // Loop on triggers in current buffer - - /// Clears hits which cannot make it into a trigger window of tokens in the next epoch - //// Next two lines will always work as we checked with a FATAL before that we have at least - //// 1 epoch message - Double_t dNextEpochTime = get4v1x::kdEpochInNs + - fvGdpbEpMsgBuffer[ iGdpbIdx ][ fiStarBuffIdxCurr[ iGdpbIdx ] ][ 0 ].getMsgFullTimeD( 0 ); - - UInt_t uEpochIdx = fvGdpbEpMsgBuffer[ iGdpbIdx ][ fiStarBuffIdxCurr[ iGdpbIdx ] ][ 0 ].getGdpbEpEpochNb(); - - Double_t dEarliestNextWinStart = dNextEpochTime - fdStarTriggerDelay[ iGdpbIdx ]; - - UInt_t uFirstHitToKeep = 0; - for( UInt_t uEpochHit = 0; uEpochHit < uNbEpochHits; uEpochHit++ ) - { - Double_t dHitTime = fvGdpbEpHitBuffer[ iGdpbIdx ] - [ fiStarBuffIdxCurr[ iGdpbIdx ] ] - [ uEpochHit ]. getMsgFullTimeD( uEpochIdx ); - if( dHitTime < dEarliestNextWinStart ) - uFirstHitToKeep = uEpochHit + 1; - } // for( UInt_t uEpochHit = 0; uEpochHit < uNbEpochHits; uEpochHit++ ) - - if( uFirstHitToKeep == uNbEpochHits ) - fvGdpbEpHitBuffer[ iGdpbIdx ][ fiStarBuffIdxCurr[ iGdpbIdx ] ].clear(); - else fvGdpbEpHitBuffer[ iGdpbIdx ][ fiStarBuffIdxCurr[ iGdpbIdx ] ].erase( - fvGdpbEpHitBuffer[ iGdpbIdx ][ fiStarBuffIdxCurr[ iGdpbIdx ] ].begin(), - fvGdpbEpHitBuffer[ iGdpbIdx ][ fiStarBuffIdxCurr[ iGdpbIdx ] ].begin() + uFirstHitToKeep ); - - /// No need to store extra triggers as windows extending after trigger itself are forbidden - fvGdpbEpTrgBuffer[ iGdpbIdx ][ fiStarBuffIdxCurr[ iGdpbIdx ] ].clear(); - - /// Data from the Prev buffer needed only for triggers in beginning of Current - /// Triggers from the Prev buffer needed only until Current buffer is ready - /// => Both ok, clear the Prev buffer so that it can be re-used of Next buffer later - fvGdpbEpMsgBuffer[ iGdpbIdx ][ fiStarBuffIdxPrev[ iGdpbIdx ] ].clear(); - fvGdpbEpHitBuffer[ iGdpbIdx ][ fiStarBuffIdxPrev[ iGdpbIdx ] ].clear(); - fvGdpbEpTrgBuffer[ iGdpbIdx ][ fiStarBuffIdxPrev[ iGdpbIdx ] ].clear(); - - return kTRUE; -} -Bool_t CbmTSMonitorTofStar::StarGenEmptyEvt( Int_t iGdpbIdx, CbmTofStarTrigger triggerIn ) -{ - /// In any case, associate this trigger to its subevent - fStarSubEvent.SetTrigger( triggerIn ); - fStarSubEvent.SetEmptyEventFlag( ); - - Double_t dTriggerTime = get4v1x::kdClockCycleSizeNs * ( triggerIn.GetFullGdpbTs() ); - - /** TODO: clarify how we deal with multiple sub-events (eg one for each gDPB) **/ - Int_t iBuffSzByte = 0; - void * pDataBuff = fStarSubEvent.BuildOutput( iBuffSzByte ); - if( NULL != pDataBuff ) - { - /// Valid output, do stuff with it! -#ifdef STAR_SUBEVT_BUILDER - /* - ** Function to send sub-event block to the STAR DAQ system - * trg_word received is packed as: - * - * trg_cmd|daq_cmd|tkn_hi|tkn_mid|tkn_lo - */ - star_rhicf_write( fStarSubEvent.GetTrigger().GetStarTrigerWord(), - pDataBuff, iBuffSzByte ); - fulNbStarEvent++; -/* - LOG(info) << "Sent STAR event with size " << iBuffSzByte << " Bytes" - << " and token " << fStarSubEvent.GetTrigger().GetStarToken(); -*/ -#endif // STAR_SUBEVT_BUILDER - } // if( NULL != pDataBuff ) - else LOG(error) << "Invalid STAR SubEvent Output, can only happen if trigger " - << " object was not set => Do Nothing more with it!!! "; - - /// Fill plot of event size - fhStarEventSize_gDPB[ iGdpbIdx ]->Fill( iBuffSzByte ); - /// Fill plot of event size as function of trigger time - if( 0 < fdStartTime ) - fhStarEventSizeTime_gDPB[ iGdpbIdx ]->Fill( 1e-9 *(dTriggerTime - fdStartTime), iBuffSzByte ); - - /// Now clear the sub-event - fStarSubEvent.ClearSubEvent(); - - return kTRUE; -} - -ClassImp(CbmTSMonitorTofStar) diff --git a/beamtime/star2017/unpacker/CbmTSMonitorTofStar.h b/beamtime/star2017/unpacker/CbmTSMonitorTofStar.h deleted file mode 100644 index e4d9162384f30152ec55686d129f07d70e25c50e..0000000000000000000000000000000000000000 --- a/beamtime/star2017/unpacker/CbmTSMonitorTofStar.h +++ /dev/null @@ -1,328 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmTSMonitorTofStar ----- -// ----- Created 15.12.2016 by P.-A. Loizeau ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CbmTSMonitorTofStar_H -#define CbmTSMonitorTofStar_H - -#include "Timeslice.hpp" -#include "rocMess_wGet4v1.h" -#include "CbmTofStarData.h" - -#include "CbmTSUnpack.h" -#include "CbmHistManager.h" - -#include "TClonesArray.h" -#include "Rtypes.h" - -#include <vector> -#include <map> -#include <chrono> - -class CbmTofUnpackPar; - -#ifdef STAR_SUBEVT_BUILDER - /* - ** Function to send sub-event block to the STAR DAQ system - * trg_word received is packed as: - * - * trg_cmd|daq_cmd|tkn_hi|tkn_mid|tkn_lo - */ - extern "C" int star_rhicf_write(unsigned int trg_word, void *dta, int bytes); -#endif // STAR_SUBEVT_BUILDER - -class CbmTSMonitorTofStar: public CbmTSUnpack { - public: - - CbmTSMonitorTofStar(); - virtual ~CbmTSMonitorTofStar(); - - virtual Bool_t Init(); - - virtual Bool_t DoUnpack(const fles::Timeslice& ts, size_t component); - - virtual void Reset(); - - virtual void Finish(); - - void SetParContainers(); - - Bool_t InitContainers(); - - Bool_t ReInitContainers(); - - void FillOutput(boost::any); - - void SetMsLimitLevel(size_t uAcceptBoundaryPct = 100) { - fuMsAcceptsPercent = uAcceptBoundaryPct; - } - size_t GetMsLimitLevel() { - return fuMsAcceptsPercent; - } - - void SetMsOverlap(size_t uOverlapMsNb = 1) { - fuOverlapMsNb = uOverlapMsNb; - } - size_t GetMsOverlap() { - return fuOverlapMsNb; - } - - void SetPerTsSpillOnThr( Int_t iThrIn = 10 ) { fiSpillOnThr = iThrIn; } - void SetPerTsSpillOffThr( Int_t iThrIn = 3 ) { fiSpillOffThr = iThrIn; } - void SetTsNbSpillOffThr( Int_t iThrIn = 10 ) { fiTsUnderOffThr = iThrIn; } - - void SetEpochSuppressedMode( Bool_t bEnable = kTRUE ) { fbEpochSuppModeOn = bEnable; } - void SetStarSortAndCutMode( Bool_t bEnable = kTRUE ) { fbStarSortAndCutMode = bEnable; } - - void SetRunStart( Int_t dateIn, Int_t timeIn, Int_t iBinSize = 5 ); - - inline void SetGet4Mode24b( Bool_t inGet4Mode24b = kTRUE ) { fbGet4M24b = inGet4Mode24b; } - inline void SetGet4v20Mode( Bool_t inGet4v20Mode = kTRUE ) { fbGet4v20 = inGet4v20Mode; } - inline void SetMergedEpochs( Bool_t inMergedEpochs = kTRUE ) { fbMergedEpochsOn = inMergedEpochs; } - inline void SetPulserMode( Bool_t inPulserMode = kTRUE ) { fbPulserMode = inPulserMode; SetPulserChans(); } - inline void SetPulserFee( UInt_t inPulserGdpb, UInt_t inPulserFee ) { fuPulserGdpb = inPulserGdpb; fuPulserFee = inPulserFee; } - void SetPulserChans( UInt_t inPulserChanA = 0, UInt_t inPulserChanB = 1, UInt_t inPulserChanC = 2, - UInt_t inPulserChanD = 3, UInt_t inPulserChanE = 4, UInt_t inPulserChanF = 5, - UInt_t inPulserChanG = 6, UInt_t inPulserChanH = 7, UInt_t inPulserChanI = 8, - UInt_t inPulserChanJ = 9, UInt_t inPulserChanK = 10, UInt_t inPulserChanL = 11, - UInt_t inPulserChanM = 12, UInt_t inPulserChanN = 13, UInt_t inPulserChanO = 14, - UInt_t inPulserChanP = 15, UInt_t inPulserChanQ = 16, UInt_t inPulserChanR = 17 ); - inline void SetFitZoomWidthPs( Double_t inZoomWidth = 1000.0 ) { fdFitZoomWidthPs = inZoomWidth; } - inline void SetHistoryHistoSize( UInt_t inHistorySizeSec = 1800 ) { fuHistoryHistoSize = inHistorySizeSec; } - inline void SetHistoryHistoSizeLong( UInt_t inHistorySizeMin = 1800 ) { fuHistoryHistoSizeLong = inHistorySizeMin; } - - void SaveAllHistos( TString sFileName = "" ); - void ResetAllHistos(); - void CyclePulserFee(); - void UpdateNormedFt(); - void UpdateZoomedFit(); - - private: - - size_t fuMsAcceptsPercent; /** Reject Ms with index inside TS above this, assumes 100 MS per TS **/ - size_t fuOverlapMsNb; /** Ignore Overlap Ms: all fuOverlapMsNb MS at the end of timeslice **/ - UInt_t fuMinNbGdpb; - UInt_t fuCurrNbGdpb; - - UInt_t fNrOfGdpbs; // Total number of GDPBs in the system - UInt_t fNrOfFebsPerGdpb; // Number of FEBs per GDPB - UInt_t fNrOfGet4PerFeb; // Number of GET4s per FEB - UInt_t fNrOfChannelsPerGet4; // Number of channels in each GET4 - - UInt_t fNrOfChannelsPerFeet; // Number of channels in each FEET - UInt_t fNrOfGet4; // Total number of Get4 chips in the system - UInt_t fNrOfGet4PerGdpb; // Number of GET4s per GDPB - UInt_t fuNbChannelsPerGdpb; // Number of channels in each gDPB - - Int_t fiCountsLastTs; - Int_t fiSpillOnThr; - Int_t fiSpillOffThr; - Int_t fiTsUnderOff; - Int_t fiTsUnderOffThr; - Double_t fdDetLastTime; - Double_t fdDetTimeLastTs; - Bool_t fbSpillOn; - UInt_t fSpillIdx; - - Bool_t fbEpochSuppModeOn; - std::vector< std::vector < ngdpb::Message > > fvmEpSupprBuffer; - - UInt_t fGdpbId; // Id (hex number)of the GDPB which is read from the message - UInt_t fGdpbNr; // running number (0 to fNrOfGdpbs) of the GDPB in the - UInt_t fGet4Id; // running number (0 to fNrOfGet4PerGdpb) of the Get4 chip of a unique GDPB - UInt_t fGet4Nr; // running number (0 to fNrOfGet4) of the Get4 chip in the system - - std::vector<int> fMsgCounter; - - std::map<UInt_t, UInt_t> fGdpbIdIndexMap; - - CbmHistManager* fHM; ///< Histogram manager - - /** Current epoch marker for each GDPB and GET4 - * (first epoch in the stream initializes the map item) - * pointer points to an array of size fNrOfGdpbs * fNrOfGet4PerGdpb - * The correct array index is calculated using the function - * GetArrayIndex(gdpbId, get4Id) - **/ - Long64_t* fCurrentEpoch; //! - - Int_t fNofEpochs; /** Current epoch marker for each ROC **/ - ULong_t fCurrentEpochTime; /** Time stamp of current epoch **/ - Double_t fdStartTime; /** Time of first valid hit (epoch available), used as reference for evolution plots**/ - Double_t fdStartTimeLong; /** Time of first valid hit (epoch available), used as reference for evolution plots**/ - Double_t fdStartTimeMsSz; /** Time of first microslice, used as reference for evolution plots**/ - TCanvas* fcMsSizeAll; - - /** Used only if the channel rate or pulse hit difference plots are enabled **/ - /** Last Hit time for each gDPB/GET4/Channel **/ - std::vector< std::vector< std::vector< Double_t > > > fTsLastHit; // * 6.25 ns - - Int_t fEquipmentId; - Double_t fdMsIndex; - - CbmTofUnpackPar* fUnpackPar; //! - - TH1* fHistMessType; - TH1* fHistSysMessType; - TH2* fHistGet4MessType; - TH2* fHistGet4ChanScm; - TH2* fHistGet4ChanErrors; - TH2* fHistGet4EpochFlags; - TH2* fHistSpill; - TH1* fHistSpillLength; - TH1* fHistSpillCount; - TH2* fHistSpillQA; - - TH2* fhScmScalerCounters; - TH2* fhScmDeadtimeCounters; - TH2* fhScmSeuCounters; - TH2* fhScmSeuCountersEvo; - - Double_t fdTimeLastStartMessage; - TH1* fhScmStartMessDist; - TH1* fhScmStartMessEvo; - - std::vector<TH2*> fRaw_Tot_gDPB; - std::vector<TH1*> fChCount_gDPB; - std::vector<TH2*> fChannelRate_gDPB; - std::vector<TH1*> fFeetRate_gDPB; - std::vector<TH1*> fFeetErrorRate_gDPB; - UInt_t fuHistoryHistoSize; - - std::vector<TH1*> fFeetRateLong_gDPB; - std::vector<TH1*> fFeetErrorRateLong_gDPB; - UInt_t fuHistoryHistoSizeLong; - - std::vector<TH1*> fFeetRateDate_gDPB; - Int_t fiRunStartDateTimeSec; - Int_t fiBinSizeDatePlots; - - Double_t fdFirstMsIndex; - std::vector<Bool_t> fbFirstEpochInMsFound; - std::vector<TH1*> fRealMsFineQa_gDPB; - std::vector<TProfile*> fRealMsMidQa_gDPB; - std::vector<TProfile*> fRealMsCoarseQa_gDPB; - - ///* ASIC coincidences & offsets mapping */// -/* - ULong64_t fulLastMsIdx; - Bool_t fbHitsInLastTs; - std::vector< std::vector< Long64_t > > fvulHitEpochBuffLastTs; //! Dims: [gDPB][hits] - std::vector< TH2 * > fvhCoincOffsetEpochGet4; //! Dims: [gDPB - 1] -*/ - - ///* STAR TRIGGER detection */// - ULong64_t fulGdpbTsMsb; - ULong64_t fulGdpbTsLsb; - ULong64_t fulStarTsMsb; - ULong64_t fulStarTsMid; - ULong64_t fulGdpbTsFullLast; - ULong64_t fulStarTsFullLast; - UInt_t fuStarTokenLast; - UInt_t fuStarDaqCmdLast; - UInt_t fuStarTrigCmdLast; - TH1 * fhTokenMsgType; - TH1 * fhTriggerRate; - TH2 * fhCmdDaqVsTrig; - TH2 * fhStarTokenEvo; - - ///* STAR and pulser monitoring */// - static const UInt_t kuNbChanTest = 18; - Bool_t fbGet4M24b; - Bool_t fbGet4v20; - Bool_t fbMergedEpochsOn; - Bool_t fbPulserMode; - UInt_t fuPulserGdpb; - UInt_t fuPulserFee; - UInt_t fuPulserChan[kuNbChanTest]; //! Always in first gDPB !!! - std::vector<TH1 *> fhTimeDiffPulserChosenFee; - std::vector<TH1 *> fhTimeDiffPulserChosenChPairs; - TH2 * fhTimeRmsPulserChosenFee; - TH1 * fhTimeRmsPulserChosenChPairs; - Double_t fdLastRmsUpdateTime; - Double_t fdFitZoomWidthPs; - TH2 * fhTimeRmsZoomPulsChosenFee; - TH1 * fhTimeRmsZoomFitPulsChosenChPairs; - TH2 * fhTimeResFitPulsChosenFee; - TH1 * fhTimeResFitPulsChosenChPairs; - std::vector<TH2 *> fhFtDistribPerCh; - std::vector<TH1*> fChCountFall_gDPB; - std::vector<TH2 *> fhFtDistribPerChFall; - std::vector<TH1*> fSelChFtNormDnlRise; - std::vector<TH1*> fSelChFtNormDnlFall; - std::vector<TH1*> fFtNormDnlMinRise; - std::vector<TH1*> fFtNormDnlMaxRise; - std::vector<TH1*> fFtNormDnlMinFall; - std::vector<TH1*> fFtNormDnlMaxFall; - TH1 * fhTempHistInlRise; - TH1 * fhTempHistInlFall; - std::vector<TH1*> fSelChFtNormInlRise; - std::vector<TH1*> fSelChFtNormInlFall; - std::vector<TH1*> fFtNormInlMinRise; - std::vector<TH1*> fFtNormInlMaxRise; - std::vector<TH1*> fFtNormInlMinFall; - std::vector<TH1*> fFtNormInlMaxFall; - std::vector< std::vector<Int_t> > fviFtLastRise24b; - std::vector< std::vector<Int_t> > fviFtLastFall24b; - std::vector< std::vector<Double_t> > fvdTimeLastRise24b; - std::vector< std::vector<Double_t> > fvdTimeLastFall24b; - UInt_t fuRiseFallChSel; - std::vector<TH2 *> fhFtLastRiseCurrFall; - std::vector<TH2 *> fhFtCurrRiseLastFall; - std::vector<TH2 *> fhFtLastRiseDistRise; - std::vector<TH2 *> fhFtLastRiseDistFall; - - ///* STAR event building/cutting */// - Bool_t fbStarSortAndCutMode; - std::vector< UInt_t > fuStarActiveAsicMask; - std::vector< Double_t > fdStarTriggerDelay; - std::vector< Double_t > fdStarTriggerWinSize; - std::vector< UInt_t > fuCurrentEpGdpb; - std::vector< UInt_t > fuStarCurrentEpFound; - std::vector< UInt_t > fuStarNextBufferUse; - std::vector< Double_t > fdStarLastTrigTimeG; - std::vector< Int_t > fiStarBuffIdxPrev; - std::vector< Int_t > fiStarBuffIdxCurr; - std::vector< Int_t > fiStarBuffIdxNext; - std::vector< ULong64_t > fuLastTriggerFullTs; - std::vector< std::vector< std::vector < ngdpb::Message > > > fvGdpbEpMsgBuffer; //! Dims: [gDPB][buffer][msgs], 1 buff. for Prev, Curr and Next - std::vector< std::vector< std::vector < ngdpb::Message > > > fvGdpbEpHitBuffer; //! Dims: [gDPB][buffer][msgs], 1 buff. for Prev, Curr and Next - std::vector< std::vector< std::vector < CbmTofStarTrigger > > > fvGdpbEpTrgBuffer; //! Dims: [gDPB][buffer][trig], 1 buff. for Prev, Curr and Next - CbmTofStarSubevent fStarSubEvent; - std::vector<TH2*> fhStarEpToTrig_gDPB; - std::vector<TH1*> fhStarHitToTrigAll_gDPB; - std::vector<TH1*> fhStarHitToTrigWin_gDPB; - std::vector<TH1*> fhStarEventSize_gDPB; - std::vector<TH2*> fhStarEventSizeTime_gDPB; - - void CreateHistograms(); - - void FillHitInfo(ngdpb::Message); - void FillEpochInfo(ngdpb::Message); - void PrintSlcInfo(ngdpb::Message); - void PrintSysInfo(ngdpb::Message); - void PrintGenInfo(ngdpb::Message); - void FillStarTrigInfo(ngdpb::Message); - void FillTrigEpochInfo(ngdpb::Message); - - Bool_t StarSort( Int_t iGdpbIdx ); - Bool_t StarSelect( Int_t iGdpbIdx ); - Bool_t StarGenEmptyEvt( Int_t iGdpbIdx, CbmTofStarTrigger triggerIn ); - ULong64_t fulNbStarEvent; - ULong64_t fulNbStarEventLastPrintout; - std::chrono::time_point<std::chrono::system_clock> fTimeLastPrintoutNbStarEvent; - - inline Int_t GetArrayIndex(Int_t gdpbId, Int_t get4Id) { - return gdpbId * fNrOfGet4PerGdpb + get4Id; - } - - CbmTSMonitorTofStar(const CbmTSMonitorTofStar&); - CbmTSMonitorTofStar operator=(const CbmTSMonitorTofStar&); - - ClassDef(CbmTSMonitorTofStar, 1) -}; - -#endif diff --git a/beamtime/star2018/CMakeLists.txt b/beamtime/star2018/CMakeLists.txt deleted file mode 100644 index 6d01ff0a65117b6587015e03a683d7c96e54a070..0000000000000000000000000000000000000000 --- a/beamtime/star2018/CMakeLists.txt +++ /dev/null @@ -1,72 +0,0 @@ -# Create a library called "libCbmFlibReader" which includes the source files given in -# the array . -# The extension is already found. Any number of sources could be listed here. - -Set(INCLUDE_DIRECTORIES - ${CBMBASE_DIR} - - ${CBMDATA_DIR} - ${CBMDATA_DIR}/tof - ${CBMDATA_DIR}/tof/etof # For the star_rhicf.c interface file - - ${CBMROOT_SOURCE_DIR}/beamtime/base - ${CBMROOT_SOURCE_DIR}/beamtime/param - ${CBMROOT_SOURCE_DIR}/beamtime/data/raw - ${CBMROOT_SOURCE_DIR}/beamtime/data - - ${CBMROOT_SOURCE_DIR}/fles/flestools - - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/unpacker - ${CMAKE_CURRENT_SOURCE_DIR}/param -) - -Set(SYSTEM_INCLUDE_DIRECTORIES - ${BASE_INCLUDE_DIRECTORIES} - ${Boost_INCLUDE_DIR} - ${ROOT_INCLUDE_DIR} - ${IPC_INCLUDE_DIRECTORY} - ${CBMROOT_SOURCE_DIR}/external/flib_dpb/flib_dpb - ${CMAKE_SOURCE_DIR}/external/cppzmq -) - -Include_Directories(${INCLUDE_DIRECTORIES}) -Include_Directories(SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES}) - - -Set(LINK_DIRECTORIES - ${ROOT_LIBRARY_DIR} - ${FAIRROOT_LIBRARY_DIR} - ${Boost_LIBRARY_DIRS} -) - -Link_Directories( - ${LINK_DIRECTORIES} -) - -Set(SRCS - CbmTofStar2018Source.cxx - - param/CbmTofStar2018Par.cxx - param/CbmTofStar2018ContFact.cxx - - unpacker/rocMess_wGet4v2.cxx - unpacker/CbmTofStarData2018.cxx - unpacker/CbmTofStarMonitor2018.cxx - unpacker/CbmTofStarMonitorShift2018.cxx - unpacker/CbmTofStarEventBuilder2018.cxx -# unpacker/CbmUnpackTofStar2018.cxx -) - -If(_UINT8_T_EXIST) - Add_Definitions(-DHAVE_UINT8_T_HEADER_FILE) - Set(DEFINITIONS HAVE_UINT8_T_HEADER_FILE) -EndIf() - -Set(LINKDEF CbmBeamtimeStar2018LinkDef.h ) -Set(LIBRARY_NAME CbmBeamtimeStar2018) -Set(DEPENDENCIES - CbmBase CbmBeamtimeBase CbmBeamtimeData fles_ipc Eve Base -) - -GENERATE_LIBRARY() diff --git a/beamtime/star2018/CbmBeamtimeStar2018LinkDef.h b/beamtime/star2018/CbmBeamtimeStar2018LinkDef.h deleted file mode 100644 index 16744f395ecc2516b71056dc4d3ac64823255e4a..0000000000000000000000000000000000000000 --- a/beamtime/star2018/CbmBeamtimeStar2018LinkDef.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifdef __CINT__ - -#pragma link off all globals; -#pragma link off all classes; -#pragma link off all functions; - -#pragma link C++ class CbmTofStar2018Source; - -#pragma link C++ class CbmTofStar2018Par; -#pragma link C++ class CbmTofStar2018ContFact; - -#pragma link C++ class CbmTofStarSubevent2018; -#pragma link C++ class CbmTofStarMonitor2018; -#pragma link C++ class CbmTofStarMonitorShift2018; -#pragma link C++ class CbmTofStarEventBuilder2018; -// #pragma link C++ class CbmUnpackTofStar2018; - -#endif diff --git a/beamtime/star2018/CbmTofStar2018Source.cxx b/beamtime/star2018/CbmTofStar2018Source.cxx deleted file mode 100644 index f6f78ee348cd3162df1e8b113e4a7e9b54051cb6..0000000000000000000000000000000000000000 --- a/beamtime/star2018/CbmTofStar2018Source.cxx +++ /dev/null @@ -1,350 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmTofStar2018Source ----- -// ----- Created 19.01.2018 by P.-A. Loizeau ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#include "CbmTofStar2018Source.h" - -//#include "CbmTbDaqBuffer.h" - -#include "TimesliceInputArchive.hpp" -#include "Timeslice.hpp" -#include "TimesliceSubscriber.hpp" -#include "MicrosliceContents.hpp" - -#include "FairLogger.h" -#include "FairRunOnline.h" - -#include "TH1.h" -#include "THttpServer.h" -#include "TProfile.h" - -#include <iostream> -#include <fstream> -#include <iomanip> - -CbmTofStar2018Source::CbmTofStar2018Source() - : FairSource(), - fFileName(""), - fInputFileList(new TObjString()), - fFileCounter(0), - fHost("localhost"), - fPort(5556), - fUnpackers(), - fDetectorSystemMap(), -// fBuffer(CbmTbDaqBuffer::Instance()), - fTSNumber(0), - fTSCounter(0), - fTimer(), - fBufferFillNeeded(kTRUE), - fHistoMissedTS(NULL), - fHistoMissedTSEvo(NULL), - fNofTSSinceLastTS(0), - fuTsReduction(1), - fSource(NULL) -{ -} - -CbmTofStar2018Source::CbmTofStar2018Source(const CbmTofStar2018Source& source) - : FairSource(source), - fFileName(""), - fInputFileList(), - fFileCounter(0), - fHost("localhost"), - fPort(5556), - fUnpackers(), - fDetectorSystemMap(), -// fBuffer(CbmTbDaqBuffer::Instance()), - fTSNumber(0), - fTSCounter(0), - fTimer(), - fBufferFillNeeded(kTRUE), - fHistoMissedTS(NULL), - fHistoMissedTSEvo(NULL), - fNofTSSinceLastTS(0), - fuTsReduction(1), - fSource(NULL) -{ -} - -CbmTofStar2018Source::~CbmTofStar2018Source() -{ -} - -Bool_t CbmTofStar2018Source::Init() -{ - if ( 0 == fFileName.Length() && 0 == fInputFileList.GetSize()) { - TString connector = Form("tcp://%s:%i", fHost.Data(), fPort); - LOG(info) << "Open TSPublisher at " << connector; - fInputFileList.Add(new TObjString(connector)); - fSource = new fles::TimesliceSubscriber(connector.Data()); - if ( !fSource) { - LOG(fatal) << "Could not connect to publisher."; - } - } else { - - if( kFALSE == OpenNextFile() ) - { - LOG(error) << "Could not open the first file in the list, Doing nothing!"; - return kFALSE; - } // if( kFALSE == OpenNextFile() ) - } - - for (auto it=fUnpackers.begin(); it!=fUnpackers.end(); ++it) { - LOG(info) << "Initialize " << it->second->GetName() << - " for systemID 0x" << std::hex << it->first << std::dec; - it->second->Init(); - // it->second->Register(); - } - - THttpServer* server = FairRunOnline::Instance()->GetHttpServer(); - - fHistoMissedTS = new TH1I("Missed_TS", "Missed TS", 2, 0., 2.); - fHistoMissedTSEvo = new TProfile("Missed_TS_Evo", "Missed TS evolution; TS Idx []", 100000, 0., 10000000.); - - if (server) - { - server->Register("/TofRaw", fHistoMissedTS); - server->Register("/TofRaw", fHistoMissedTSEvo); - } // if (server) - - - return kTRUE; -} - -void CbmTofStar2018Source::SetParUnpackers() -{ - for (auto it=fUnpackers.begin(); it!=fUnpackers.end(); ++it) { - LOG(info) << "Set parameter container " << it->second->GetName() << - " for systemID 0x" << std::hex << it->first << std::dec; - it->second->SetParContainers(); - } - -} - -Bool_t CbmTofStar2018Source::InitUnpackers() -{ - Bool_t result = kTRUE; - for (auto it=fUnpackers.begin(); it!=fUnpackers.end(); ++it) { - LOG(info) << "Initialize parameter container " << it->second->GetName() << - " for systemID 0x" << std::hex << it->first << std::dec; - result = result && it->second->InitContainers(); - } - return result; -} - -Bool_t CbmTofStar2018Source::ReInitUnpackers() -{ - Bool_t result = kTRUE; - for (auto it=fUnpackers.begin(); it!=fUnpackers.end(); ++it) { - LOG(info) << "Initialize parameter container " << it->second->GetName() << - " for systemID 0x" << std::hex << it->first << std::dec; - result = result && it->second->ReInitContainers(); - } - return result; -} - -Int_t CbmTofStar2018Source::ReadEvent(UInt_t) -{ -// LOG(info) << "Before FillBuffer"; -// Int_t retVal = -1; - if (fBufferFillNeeded) { - FillBuffer(); - } -// LOG(info) << "After FillBuffer"; - -// retVal = GetNextEvent(); -// LOG(debug) << "After GetNextEvent: " << retVal; - - Int_t bla = 0; - // If no more data and file mode, try to read next file in List - if( fSource->eos() && 0 < fFileName.Length() ) - { - fFileCounter ++; // Increment file counter to go to next item in List - bla = ( kFALSE == OpenNextFile() ? 1 : 0 ); - } // if( fSource->eos() && 0 < fFileName.Length() ) - -// Int_t bla = fSource->eos(); // no more data; trigger end of run -// LOG(info) << "After fSource->eos: " << bla; - return bla; // no more data; trigger end of run -} - -void CbmTofStar2018Source::PrintMicroSliceDescriptor(const fles::MicrosliceDescriptor& mdsc) -{ - LOG(info) << "Header ID: Ox" << std::hex << static_cast<int>(mdsc.hdr_id) - << std::dec; - LOG(info) << "Header version: Ox" << std::hex << static_cast<int>(mdsc.hdr_ver) - << std::dec; - LOG(info) << "Equipement ID: " << mdsc.eq_id; - LOG(info) << "Flags: " << mdsc.flags; - LOG(info) << "Sys ID: Ox" << std::hex << static_cast<int>(mdsc.sys_id) - << std::dec; - LOG(info) << "Sys version: Ox" << std::hex << static_cast<int>(mdsc.sys_ver) - << std::dec; - LOG(info) << "Microslice Idx: " << mdsc.idx; - LOG(info) << "Checksum: " << mdsc.crc; - LOG(info) << "Size: " << mdsc.size; - LOG(info) << "Offset: " << mdsc.offset; -} - -Bool_t CbmTofStar2018Source::CheckTimeslice(const fles::Timeslice& ts) -{ - if ( 0 == ts.num_components() ) { - LOG(error) << "No Component in TS " << ts.index(); - return 1; - } - LOG(info) << "Found " << ts.num_components() - << " different components in timeslice"; - return kTRUE; -} - -void CbmTofStar2018Source::Close() -{ - for (auto it=fUnpackers.begin(); it!=fUnpackers.end(); ++it) { - LOG(info) << "Finish " << it->second->GetName() << " for systemID 0x" - << std::hex << it->first << std::dec; - it->second->Finish(); - } - fHistoMissedTS->Write(); - fHistoMissedTSEvo->Write(); -} - -void CbmTofStar2018Source::Reset() -{ - for (auto it=fUnpackers.begin(); it!=fUnpackers.end(); ++it) { - it->second->Reset(); - } -} - -Int_t CbmTofStar2018Source::FillBuffer() -{ - - while (auto timeslice = fSource->get()) { - fTSCounter++; - if ( 0 == fTSCounter%10000 ) { - LOG(info) << "Analyse Event " << fTSCounter; - } - - const fles::Timeslice& ts = *timeslice; - auto tsIndex = ts.index(); - if( (tsIndex != (fTSNumber+1)) &&( fTSNumber != 0) ) { - LOG(debug) << "Missed Timeslices. Old TS Number was " << fTSNumber - << " New TS Number is " << tsIndex; - fHistoMissedTS->Fill(1, tsIndex-fTSNumber); - fHistoMissedTSEvo->Fill( tsIndex, 1, tsIndex-fTSNumber); - fNofTSSinceLastTS=tsIndex-fTSNumber; - } else { - fHistoMissedTS->Fill(0); - fHistoMissedTSEvo->Fill( tsIndex, 0, 1); - fNofTSSinceLastTS=1; - } - fTSNumber=tsIndex; - - if ( 0 ==fTSNumber%1000 ) { - LOG(info) << "Reading Timeslice " << fTSNumber; - } - - for (size_t c {0}; c < ts.num_components(); c++) { - auto systemID = static_cast<int>(ts.descriptor(c, 0).sys_id); - - LOG(debug) << "Found systemID: " << std::hex - << systemID << std::dec; -/* - if(gLogger->IsLogNeeded( fair::Severity::debug1 )) { - PrintMicroSliceDescriptor(ts.descriptor(c, 0)); - } -*/ - auto it=fUnpackers.find(systemID); - if (it == fUnpackers.end()) { - LOG(debug) << "Could not find unpacker for system id 0x" - << std::hex << systemID << std::dec; - } else { - if( 0 == tsIndex%fuTsReduction || systemID != 0x10 ) - it->second->DoUnpack(ts, c); - } - } - return 0; - } - - return 1; -} - -Int_t CbmTofStar2018Source::GetNextEvent() -{ -/* - Double_t fTimeBufferOut = fBuffer->GetTimeLast(); - LOG(debug) << "Timeslice contains data from " - << std::setprecision(9) << std::fixed - << static_cast<Double_t>(fBuffer->GetTimeFirst()) * 1.e-9 << " to " - << std::setprecision(9) << std::fixed - << static_cast<Double_t>(fBuffer->GetTimeLast()) * 1.e-9 << " s"; - - LOG(debug) << "Buffer has " << fBuffer->GetSize() << " entries."; - - - CbmDigi* digi = fBuffer->GetNextData(fTimeBufferOut); - -// LOG(info) << "Before if"; - if (NULL == digi) return 1; -// LOG(info) << "After if"; - - while(digi) { - Int_t detId = digi->GetSystemId(); - Int_t flibId = fDetectorSystemMap[detId]; - LOG(debug) << "Digi has system ID " << detId - << " which maps to FlibId "<< flibId; - std::map<Int_t, CbmTSUnpack*>::iterator it=fUnpackers.find(flibId); - if (it == fUnpackers.end()) { - LOG(error) << "Skipping digi with unknown id " - << detId; - continue; - } else { - it->second->FillOutput(digi); - } - digi = fBuffer->GetNextData(fTimeBufferOut); - }; -*/ - return 0; -} - -Bool_t CbmTofStar2018Source::OpenNextFile() -{ - // First Close and delete existing source - if( NULL != fSource ) - delete fSource; - - if( fFileCounter < fInputFileList.GetSize() ) - { - // --- Open current input file - TObjString* tmp = - dynamic_cast<TObjString*>(fInputFileList.At(fFileCounter)); - fFileName = tmp->GetString(); - - LOG(info) << "Open the Flib input file " << fFileName; - // Check if the input file exist - FILE* inputFile = fopen(fFileName.Data(), "r"); - if ( ! inputFile ) { - LOG(error) << "Input file " << fFileName << " doesn't exist."; - return kFALSE; - } - fclose(inputFile); - fSource = new fles::TimesliceInputArchive(fFileName.Data()); - if ( !fSource) { - LOG(error) << "Could not open input file."; - return kFALSE; - } - } // if( fFileCounter < fInputFileList.GetSize() ) - else - { - LOG(info) << "End of files list reached: file counter is " << fFileCounter - << " for " << fInputFileList.GetSize() << " entries in the file list."; - return kFALSE; - } // else of if( fFileCounter < fInputFileList.GetSize() ) - - return kTRUE; -} - - -ClassImp(CbmTofStar2018Source) diff --git a/beamtime/star2018/CbmTofStar2018Source.h b/beamtime/star2018/CbmTofStar2018Source.h deleted file mode 100644 index ae44a7da055997f86e659a791aa6dbc3188cb033..0000000000000000000000000000000000000000 --- a/beamtime/star2018/CbmTofStar2018Source.h +++ /dev/null @@ -1,110 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmTofStar2018Source ----- -// ----- Created 19.01.2018 by P.-A. Loizeau ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CBMTOFSTAR2018SOURCE_H -#define CBMTOFSTAR2018SOURCE_H - -#include "TimesliceSource.hpp" -#include "Timeslice.hpp" -#include "MicrosliceDescriptor.hpp" - -#include "FairSource.h" -#include "CbmTSUnpack.h" -//#include "CbmTbDaqBuffer.h" - -#include "TString.h" -#include "TClonesArray.h" -#include "TList.h" -#include "TObjString.h" -#include "TStopwatch.h" - -#include <memory> -#include <map> - -class TH1I; -class TProfile; - -class CbmTofStar2018Source : public FairSource -{ - public: - CbmTofStar2018Source(); - CbmTofStar2018Source(const CbmTofStar2018Source& source); - virtual ~CbmTofStar2018Source(); - - Bool_t Init(); - Int_t ReadEvent(UInt_t); - - Source_Type GetSourceType() {return kONLINE;} - - virtual void SetParUnpackers(); - - virtual Bool_t InitUnpackers(); - - virtual Bool_t ReInitUnpackers(); - - void Close(); - void Reset(); - - void SetFileName(TString name) { fFileName = name; fInputFileList.Add(new TObjString(name));} - void SetHostName(TString name) { fHost = name; } - void SetPortNumber(Int_t port) { fPort = port; } - - void AddUnpacker(CbmTSUnpack* unpacker, Int_t flibId, Int_t detId) - { - fUnpackers.insert ( std::pair<Int_t,CbmTSUnpack*>(flibId,unpacker) ); - fDetectorSystemMap.insert ( std::pair<Int_t,Int_t>(detId,flibId) ); - } - - void AddFile(const char * name) { - fInputFileList.Add(new TObjString(name)); - } - - UInt_t GetTsCount() { return fTSCounter; } - UInt_t GetNofTSSinceLastTS() { return fNofTSSinceLastTS; } - - void SetDataReductionMuch( UInt_t uTsReduction = 15 ) { fuTsReduction = uTsReduction; } - - private: - - TString fFileName; - TList fInputFileList; ///< List of input files - Int_t fFileCounter; - TString fHost; - Int_t fPort; - - std::map<Int_t, CbmTSUnpack*> fUnpackers; - std::map<Int_t, Int_t> fDetectorSystemMap; //! Map detector system id to flib system id - -// CbmTbDaqBuffer* fBuffer; - - UInt_t fTSNumber; - UInt_t fTSCounter; - TStopwatch fTimer; - - Bool_t fBufferFillNeeded; /** True if the input buffer has to be filled again **/ - - TH1I* fHistoMissedTS; - TProfile* fHistoMissedTSEvo; - Int_t fNofTSSinceLastTS; - - UInt_t fuTsReduction; - - fles::TimesliceSource* fSource; //! - Bool_t CheckTimeslice(const fles::Timeslice& ts); - void PrintMicroSliceDescriptor(const fles::MicrosliceDescriptor& mdsc); - - Int_t FillBuffer(); - Int_t GetNextEvent(); - Bool_t OpenNextFile(); - - CbmTofStar2018Source operator=(const CbmTofStar2018Source&); - - ClassDef(CbmTofStar2018Source, 1) -}; - - -#endif diff --git a/beamtime/star2018/param/CbmTofStar2018ContFact.cxx b/beamtime/star2018/param/CbmTofStar2018ContFact.cxx deleted file mode 100644 index 5289246004fb8bc8515fb569d4b18695e9cfe7c6..0000000000000000000000000000000000000000 --- a/beamtime/star2018/param/CbmTofStar2018ContFact.cxx +++ /dev/null @@ -1,50 +0,0 @@ -///////////////////////////////////////////////////////////// -// -// CbmTofStar2018ContFact -// -// Factory for the parameter containers in libFlesTest -// -///////////////////////////////////////////////////////////// - -#include "CbmTofStar2018ContFact.h" - -#include "CbmTofStar2018Par.h" - -#include "FairRuntimeDb.h" - -ClassImp(CbmTofStar2018ContFact) - -static CbmTofStar2018ContFact gCbmTofStar2018ContFact; - -CbmTofStar2018ContFact::CbmTofStar2018ContFact() { - // Constructor (called when the library is loaded) - fName="CbmTofStar2018ContFact"; - fTitle="Factory for parameter containers for fles test library"; - setAllContainers(); - FairRuntimeDb::instance()->addContFactory(this); -} - -void CbmTofStar2018ContFact::setAllContainers() { - /** Creates the Container objects with all accepted contexts and adds them to - * the list of containers for the fles test library.*/ - - FairContainer* p= new FairContainer("CbmTofStar2018Par", - "TOF at STAR 2018 Unpack Parameters", - "TestDefaultContext"); - p->addContext("TestNonDefaultContext"); - - containers->Add(p); -} - -FairParSet* CbmTofStar2018ContFact::createContainer(FairContainer* c) { - /** Calls the constructor of the corresponding parameter container. - * For an actual context, which is not an empty string and not the default context - * of this container, the name is concatinated with the context. */ - const char* name=c->GetName(); - FairParSet* p=0; - if (strcmp(name,"CbmTofStar2018Par")==0) { - p = new CbmTofStar2018Par(c->getConcatName().Data(),c->GetTitle(),c->getContext()); - } - return p; -} - diff --git a/beamtime/star2018/param/CbmTofStar2018ContFact.h b/beamtime/star2018/param/CbmTofStar2018ContFact.h deleted file mode 100644 index 81996a7c6e4e675c160ba0463c92822ce6f9b93c..0000000000000000000000000000000000000000 --- a/beamtime/star2018/param/CbmTofStar2018ContFact.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef CBMTOFSTAR2018CONTFACT_H -#define CBMTOFSTAR2018CONTFACT_H - -#include "FairContFact.h" - -class FairContainer; -class FairParSet; - -class CbmTofStar2018ContFact : public FairContFact { -private: - void setAllContainers(); - CbmTofStar2018ContFact(const CbmTofStar2018ContFact&); - CbmTofStar2018ContFact& operator=(const CbmTofStar2018ContFact&); -public: - CbmTofStar2018ContFact(); - ~CbmTofStar2018ContFact() {} - FairParSet* createContainer(FairContainer*); - ClassDef(CbmTofStar2018ContFact,0) // Factory for all TRD parameter containers -}; - -#endif /* !CBMTOFSTAR2018CONTFACT_H */ diff --git a/beamtime/star2018/param/CbmTofStar2018Par.cxx b/beamtime/star2018/param/CbmTofStar2018Par.cxx deleted file mode 100644 index b083ee4f6cc99764244f2756dc40e0a9b7c4b1e5..0000000000000000000000000000000000000000 --- a/beamtime/star2018/param/CbmTofStar2018Par.cxx +++ /dev/null @@ -1,114 +0,0 @@ -// ------------------------------------------------------------------------- -// ----- CbmTofStar2018Par source file ----- -// ----- Created 18/01/17 by P.-A. Loizeau ----- -// ------------------------------------------------------------------------- - -#include "CbmTofStar2018Par.h" - -#include "FairParamList.h" -#include "FairDetParIo.h" -#include "FairParIo.h" -#include "FairLogger.h" - -#include "TString.h" - -// ----- Standard constructor ------------------------------------------ -CbmTofStar2018Par::CbmTofStar2018Par(const char* name, - const char* title, - const char* context) - : FairParGenericSet(name, title, context), - fiNrOfGdpb(-1), - fiGdpbIdArray(), - fiNrOfFebsPerGdpb(-1), - fiNrOfGet4PerFeb(-1), - fiNrOfChannelsPerGet4(-1), - fiNrOfChannels(-1), - fiChannelToDetUIdMap(), - fiNbMsTot(0), - fiNbMsOverlap(0), - fdSizeMsInNs(0.0), - fdStarTriggerDeadtime(), - fdStarTriggerDelay(), - fdStarTriggerWinSize(), - fdTsDeadtimePeriod(0.0) -{ - detName="Tof"; -} -// ------------------------------------------------------------------------- - - - -// ----- Destructor ---------------------------------------------------- -CbmTofStar2018Par::~CbmTofStar2018Par() -{ -} -// ------------------------------------------------------------------------- - - -// ----- Public method clear ------------------------------------------- -void CbmTofStar2018Par::clear() -{ - status = kFALSE; - resetInputVersions(); -} -// ------------------------------------------------------------------------- - -// ------------------------------------------------------------------------- - -void CbmTofStar2018Par::putParams(FairParamList* l) -{ - if (!l) return; - l->add("NrOfRocs", fiNrOfGdpb); - l->add("RocIdArray", fiGdpbIdArray); - l->add("NrOfFebsPerGdpb", fiNrOfFebsPerGdpb); - l->add("NrOfGet4PerFeb", fiNrOfGet4PerFeb); - l->add("NrOfChannelsPerGet4", fiNrOfChannelsPerGet4); - l->add("NrOfChannels", fiNrOfChannels); - l->add("ChannelToDetUIdMap", fiChannelToDetUIdMap); - l->add("NbMsTot", fiNbMsTot); - l->add("NbMsOverlap", fiNbMsOverlap); - l->add("SizeMsInNs", fdSizeMsInNs); - l->add("StarTriggerDeadtime", fdStarTriggerDeadtime); - l->add("StarTriggerDelay", fdStarTriggerDelay); - l->add("StarTriggerWinSize", fdStarTriggerWinSize); - l->add("TsDeadtimePeriod", fdTsDeadtimePeriod); -} - -//------------------------------------------------------ - -Bool_t CbmTofStar2018Par::getParams(FairParamList* l) { - - if (!l) return kFALSE; - - if ( ! l->fill("NrOfRocs", &fiNrOfGdpb) ) return kFALSE; - - fiGdpbIdArray.Set(fiNrOfGdpb); - if ( ! l->fill("RocIdArray", &fiGdpbIdArray) ) return kFALSE; - - if ( ! l->fill("NrOfFebsPerGdpb", &fiNrOfFebsPerGdpb) ) return kFALSE; - if ( ! l->fill("NrOfGet4PerFeb", &fiNrOfGet4PerFeb) ) return kFALSE; - if ( ! l->fill("NrOfChannelsPerGet4", &fiNrOfChannelsPerGet4) ) return kFALSE; - - if ( ! l->fill("NrOfChannels", &fiNrOfChannels) ) return kFALSE; - - fiChannelToDetUIdMap.Set(fiNrOfChannels); - - if ( ! l->fill("ChannelToDetUIdMap", &fiChannelToDetUIdMap) ) return kFALSE; - - if ( ! l->fill("NbMsTot", &fiNbMsTot) ) return kFALSE; - if ( ! l->fill("NbMsOverlap", &fiNbMsOverlap) ) return kFALSE; - if ( ! l->fill("SizeMsInNs", &fdSizeMsInNs) ) return kFALSE; - - fdStarTriggerDeadtime.Set(fiNrOfGdpb); - fdStarTriggerDelay.Set(fiNrOfGdpb); - fdStarTriggerWinSize.Set(fiNrOfGdpb); - if ( ! l->fill("StarTriggerDeadtime", &fdStarTriggerDeadtime) ) return kFALSE; - if ( ! l->fill("StarTriggerDelay", &fdStarTriggerDelay) ) return kFALSE; - if ( ! l->fill("StarTriggerWinSize", &fdStarTriggerWinSize) ) return kFALSE; - if ( ! l->fill("TsDeadtimePeriod", &fdTsDeadtimePeriod) ) return kFALSE; - - return kTRUE; -} - - -ClassImp(CbmTofStar2018Par) diff --git a/beamtime/star2018/param/CbmTofStar2018Par.h b/beamtime/star2018/param/CbmTofStar2018Par.h deleted file mode 100644 index 40cac6392bbbcf2a80d7969b70a59c09422e2dfb..0000000000000000000000000000000000000000 --- a/beamtime/star2018/param/CbmTofStar2018Par.h +++ /dev/null @@ -1,78 +0,0 @@ -// ------------------------------------------------------------------------- -// ----- CbmTofStar2018Par header file ----- -// ----- Created 18/01/17 by P.-A. Loizeau ----- -// ------------------------------------------------------------------------- - -#ifndef CBMTOFSTAR2018PAR_H -#define CBMTOFSTAR2018PAR_H - -#include "FairParGenericSet.h" - -#include "TArrayI.h" -#include "TArrayD.h" - -class FairParIo; -class FairParamList; - - -class CbmTofStar2018Par : public FairParGenericSet -{ - - public: - - /** Standard constructor **/ - CbmTofStar2018Par(const char* name = "CbmTofStar2018Par", - const char* title = "Tof unpacker parameters", - const char* context = "Default"); - - - /** Destructor **/ - virtual ~CbmTofStar2018Par(); - - /** Reset all parameters **/ - virtual void clear(); - - void putParams(FairParamList*); - Bool_t getParams(FairParamList*); - - inline Int_t GetNrOfRocs() { return fiNrOfGdpb; } - inline Int_t GetRocId(Int_t i) { return fiGdpbIdArray[i]; } - inline Int_t GetNrOfFebsPerGdpb() { return fiNrOfFebsPerGdpb; } - inline Int_t GetNrOfGet4PerFeb() {return fiNrOfGet4PerFeb;} - inline Int_t GetNrOfChannelsPerGet4() {return fiNrOfChannelsPerGet4;} - inline Int_t GetNumberOfChannels() {return fiNrOfChannels;} - inline Int_t GetChannelToDetUIdMap(Int_t channel) {return fiChannelToDetUIdMap[channel];} - - inline Int_t GetNbMsTot() { return fiNbMsTot;} - inline Int_t GetNbMsOverlap() { return fiNbMsOverlap;} - inline Double_t GetSizeMsInNs() { return fdSizeMsInNs;} - - inline Double_t GetStarTriggDeadtime(Int_t gdpb) { return fdStarTriggerDeadtime[gdpb];} - inline Double_t GetStarTriggDelay(Int_t gdpb) { return fdStarTriggerDelay[gdpb];} - inline Double_t GetStarTriggWinSize(Int_t gdpb) { return fdStarTriggerWinSize[gdpb];} - inline Double_t GetTsDeadtimePeriod() { return fdTsDeadtimePeriod;} - - private: - - Int_t fiNrOfGdpb; // Total number of GDPBs - TArrayI fiGdpbIdArray; // Array to hold the unique IDs for all Tof GDPBs - - Int_t fiNrOfFebsPerGdpb; // Number of FEBs which are connected to one GDPB - Int_t fiNrOfGet4PerFeb; // Number of GET4 chips which are connected to one FEB - Int_t fiNrOfChannelsPerGet4; // Number of channels per GET4 - - Int_t fiNrOfChannels; // Total number of Channels - TArrayI fiChannelToDetUIdMap;// Array which stores the corresponding UIDs for each channel - - Int_t fiNbMsTot; // Total number of MS per link in TS - Int_t fiNbMsOverlap; // Number of overlap MS per TS - Double_t fdSizeMsInNs; // Size of the MS in ns, needed for MS border detection - - TArrayD fdStarTriggerDeadtime; // STAR: Array to hold for each gDPB the deadtime between triggers in ns - TArrayD fdStarTriggerDelay; // STAR: Array to hold for each gDPB the Delay in ns to subtract when looking for beginning of coincidence of data with trigger window - TArrayD fdStarTriggerWinSize; // STAR: Array to hold for each gDPB the Size of the trigger window in ns - Double_t fdTsDeadtimePeriod; // Period (ns) in the first MS of each TS where events with missing triggers should be built using the overlap MS of previous TS (overlap events) - - ClassDef(CbmTofStar2018Par,1); -}; -#endif diff --git a/beamtime/star2018/unpacker/CbmTofStarData2018.cxx b/beamtime/star2018/unpacker/CbmTofStarData2018.cxx deleted file mode 100644 index 656c9992d6774a6108e8589ca271433d566a338e..0000000000000000000000000000000000000000 --- a/beamtime/star2018/unpacker/CbmTofStarData2018.cxx +++ /dev/null @@ -1,219 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmTofStarData2018 ----- -// ----- Created 13.01.2017 by P.-A. Loizeau ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#include "CbmTofStarData2018.h" - -#include <algorithm> - -#include <iostream> -#include <iomanip> - -/********************** CbmTofStarTrigger2018 *************************/ -CbmTofStarTrigger2018::CbmTofStarTrigger2018( ULong64_t ulGdpbTsFullIn, ULong64_t ulStarTsFullIn, - UInt_t uStarTokenIn, UInt_t uStarDaqCmdIn, - UInt_t uStarTrigCmdIn ) : - CbmTofStarTrigger( ulGdpbTsFullIn, ulStarTsFullIn, - uStarTokenIn, uStarDaqCmdIn, - uStarTrigCmdIn ) -{ -} -//! strict weak ordering operator, assumes same TS cycle for both triggers -bool CbmTofStarTrigger2018::operator<(const CbmTofStarTrigger2018& other) const -{ - ULong64_t uThisTs = this->GetFullGdpbTs(); - ULong64_t uOtherTs = other.GetFullGdpbTs(); - - return uThisTs < uOtherTs; -} -std::vector< gdpb::FullMessage > CbmTofStarTrigger2018::GetGdpbMessages( UShort_t usGdpbId ) const -{ - gdpb::Message mCommonData( ( static_cast< ULong64_t >( usGdpbId ) << 48 ) // GdpbId - + gdpb::MSG_STAR_TRI // Message type - ); - std::vector< gdpb::FullMessage > vMsgs( 4, mCommonData ); - - /// Subtype 0 - vMsgs[ 0 ].setStarTrigMsgIndex( 0 ); // Message Subtype - vMsgs[ 0 ].setGdpbTsMsbStarA( GetFullGdpbTs() ); // 40b MSB of GDPB TS b[ 24, 63 ] - /// Subtype 1 - vMsgs[ 1 ].setStarTrigMsgIndex( 1 ); // Message Subtype - vMsgs[ 1 ].setGdpbTsLsbStarB( GetFullGdpbTs() ); // 24b LSB of GDPB TS b[ 0, 23 ] - vMsgs[ 1 ].setStarTsMsbStarB( GetFullStarTs() ); // 16b MSB of STAR TS b[ 48, 63 ] - /// Subtype 2 - vMsgs[ 2 ].setStarTrigMsgIndex( 2 ); // Message Subtype - vMsgs[ 2 ].setStarTsMidStarC( GetFullStarTs() ); // 40b mid bits of STAR TS b[ 8, 47 ] - /// Subtype 3 - vMsgs[ 3 ].setStarTrigMsgIndex( 3 ); // Message Subtype - vMsgs[ 3 ].setStarTsLsbStarD( GetFullStarTs() ); // 8b LSB of STAR TS b[ 0, 7] - vMsgs[ 3 ].setStarFillerD(); // 12 bits in between are set to 0 - vMsgs[ 3 ].setStarTokenStarD( GetStarToken() ); // 12b STAR Token - vMsgs[ 3 ].setStarDaqCmdStarD( GetStarDaqCmd() ); // 4b STAR DAQ CMD - vMsgs[ 3 ].setStarTrigCmdStarD( GetStarTrigCmd() ); // 4b STAR TRIG CMD - - return vMsgs; -} -//ClassImp(CbmTofStarTrigger2018) -/**********************************************************************/ -/********************** CbmTofStarSubevent2018 ************************/ -CbmTofStarSubevent2018::CbmTofStarSubevent2018() : - fbTriggerSet( kFALSE ), - fTrigger( CbmTofStarTrigger( 0, 0, 0, 0, 0) ), - fusSourceId( 0 ), - fulEventStatusFlags( 0 ), - fuEventSizeBytes( 0 ), - fvMsgBuffer() -{ -} -CbmTofStarSubevent2018::CbmTofStarSubevent2018( CbmTofStarTrigger triggerIn, UShort_t sourceIdIn ) : - fbTriggerSet( kTRUE ), - fTrigger( triggerIn ), - fusSourceId( sourceIdIn ), - fulEventStatusFlags( 0 ), - fuEventSizeBytes( 0 ), - fvMsgBuffer() -{ - SetSource( sourceIdIn ); -} -CbmTofStarSubevent2018::~CbmTofStarSubevent2018() -{ - ClearSubEvent(); -} -void CbmTofStarSubevent2018::ClearSubEvent() -{ - fbTriggerSet = kFALSE; - fulEventStatusFlags = 0; - fvMsgBuffer.clear(); -} -void CbmTofStarSubevent2018::SortMessages() -{ - std::sort( fvMsgBuffer.begin(), fvMsgBuffer.end() ); -} -void * CbmTofStarSubevent2018::BuildOutput( Int_t & iOutputSizeBytes ) -{ - // If trigger not set, something is wrong, we just pass - if( kFALSE == fbTriggerSet ) - { - iOutputSizeBytes = 0; - return NULL; - } // if( kFALSE == fbTriggerSet ) - - iOutputSizeBytes = 0; - - // Size of output is - // 3 * Long64 for Header Star Token Info - // 1 * Long64 for Header Event Status Flags (version, bad/good, ...) & source ID - // 2 * n * Long64 for the n messages in Buffer: 1 extended Epoch + message data - iOutputSizeBytes = 4 + 2 * fvMsgBuffer.size(); - iOutputSizeBytes *= sizeof( ULong64_t ); - UInt_t uMsgsToRead = fvMsgBuffer.size(); - - // Check if max size passed - // If it is the case, limit the number of data read + set Bad Event flag - if( kuMaxOutputSize < static_cast<uint32_t>(iOutputSizeBytes) ) - { - iOutputSizeBytes = kuMaxOutputSize; - uMsgsToRead = kuMaxNbMsgs; - fulEventStatusFlags |= kulFlagBadEvt; - } // if( kuMaxOutputSize < iOutputSizeBytes ) - - /// Store the event size in the free part of the status member for consistency checks - fuEventSizeBytes = iOutputSizeBytes & kulEventSizeMask; - fulEventStatusFlags = (fulEventStatusFlags & !( kulEventSizeMask << kulEventSizeOffset ) ) - | ( static_cast< ULong64_t >( fuEventSizeBytes ) << kulEventSizeOffset ); - - // Fills header info - fpulBuff[0] = fTrigger.GetFullGdpbTs(); - fpulBuff[1] = fTrigger.GetFullStarTs(); - fpulBuff[2] = (static_cast< ULong64_t >( fTrigger.GetStarToken() ) << 32) - + (static_cast< ULong64_t >( fTrigger.GetStarDaqCmd() ) << 16) - + (static_cast< ULong64_t >( fTrigger.GetStarTrigCmd() ) ); - fpulBuff[3] = fulEventStatusFlags; - - // does not work due to "error: cannot convert ‘gdpb::Message’ to ‘long unsigned int’ in assignment" -// std::copy( fvMsgBuffer.begin(), fvMsgBuffer.begin() + uMsgsToRead, pulBuff + 4 ); - - // Unoptimized replacement: item by item copy - for( UInt_t uMsgIdx = 0; uMsgIdx < uMsgsToRead; uMsgIdx++) - { - fpulBuff[4 + 2 * uMsgIdx ] = fvMsgBuffer[uMsgIdx].getData(); - fpulBuff[4 + 2 * uMsgIdx + 1] = fvMsgBuffer[uMsgIdx].getExtendedEpoch(); - } // for( UInt_t uMsgIdx = 0; uMsgIdx < uMsgsToRead; uMsgIdx++) - - return static_cast< void * >( fpulBuff ); -} -Bool_t CbmTofStarSubevent2018::LoadInput( void * pBuff, Int_t iInputSizeBytes ) -{ - // Check input variables are properly defined - if( NULL == pBuff || 0 == iInputSizeBytes) - return kFALSE; - - Int_t iRestBytes = iInputSizeBytes % sizeof( ULong64_t ); - Int_t iInputSzLg = iInputSizeBytes / sizeof( ULong64_t ); - - - // Check event header is complete and buffer is multiple of 64b - if( iInputSzLg < 4 || 0 < iRestBytes ) - return kFALSE; - - // First clear subEvent content - ClearSubEvent(); - - // Read the header to the SubEvent members - ULong64_t * pulLongBuff = static_cast< ULong64_t * >(pBuff); - ULong64_t ulTrgGdpbFullTs = pulLongBuff[0]; - ULong64_t ulTrgStarFullTs = pulLongBuff[1]; - UInt_t uStarToken = (pulLongBuff[2] >> 32) & 0xFFF; - UInt_t uStarDaqCmdIn = (pulLongBuff[2] >> 16) & 0x00F; - UInt_t uStarTrigCmdIn = (pulLongBuff[2] ) & 0x00F; - fulEventStatusFlags = pulLongBuff[3]; - - fusSourceId = (fulEventStatusFlags >> kulSourceIdOffset ) & kulSourceIdMask; - - fuEventSizeBytes = (fulEventStatusFlags >> kulEventSizeOffset ) & kulEventSizeMask; - - fTrigger.SetFullGdpbTs( ulTrgGdpbFullTs ); - fTrigger.SetFullStarTs( ulTrgStarFullTs ); - fTrigger.SetStarToken( uStarToken ); - fTrigger.SetStarDaqCmd( uStarDaqCmdIn ); - fTrigger.SetStarTRigCmd(uStarTrigCmdIn ); - - // Read as many messages as left in the buffer and store them in the vector - UInt_t uMsgsToRead = (iInputSzLg - 4)/2; - for( UInt_t uMsgIdx = 0; uMsgIdx < uMsgsToRead; uMsgIdx++) - { - gdpb::FullMessage mess( pulLongBuff[4 + 2 * uMsgIdx], pulLongBuff[4 + 2 * uMsgIdx + 1] ); - fvMsgBuffer.push_back( mess ); - } // for( UInt_t uMsgIdx = 0; uMsgIdx < uMsgsToRead; uMsgIdx++) - - return kTRUE; -} -void CbmTofStarSubevent2018::PrintSubEvent() -{ - std::cout << "-------------------------------------------------------" << std::endl; - std::cout << "Printing CbmTofStarSubevent2018 dump" << std::endl; - // Print the header - std::cout << "Trigger info: gDPB TS = " << fTrigger.GetFullGdpbTs() - << " STAR TS = " << fTrigger.GetFullStarTs() - << " Token = " << fTrigger.GetStarToken() - << " DAQ CMD = " << fTrigger.GetStarDaqCmd() - << " TRIG CMD = " << fTrigger.GetStarTrigCmd() - << std::endl; - std::cout << "Status flags = " - << std::hex << std::setw(16) << fulEventStatusFlags - << std::dec << std::endl; - - // Print the messages in the buffer - - for( UInt_t uMsgIdx = 0; uMsgIdx < fvMsgBuffer.size(); uMsgIdx++) - { - fvMsgBuffer[uMsgIdx].PrintMessage( gdpb::msg_print_Prefix | gdpb::msg_print_Data ); - } // for( UInt_t uMsgIdx = 0; uMsgIdx < uMsgsToRead; uMsgIdx++) - - std::cout << "-------------------------------------------------------" << std::endl; -} -//ClassImp(CbmTofStarTrigger) -/**********************************************************************/ diff --git a/beamtime/star2018/unpacker/CbmTofStarData2018.h b/beamtime/star2018/unpacker/CbmTofStarData2018.h deleted file mode 100644 index fe3f1c991214adda2e9d57a64a7bb542631c3730..0000000000000000000000000000000000000000 --- a/beamtime/star2018/unpacker/CbmTofStarData2018.h +++ /dev/null @@ -1,137 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmTofStarData2018 ----- -// ----- Created 13.01.2017 by P.-A. Loizeau ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CbmTofStarData2018_H -#define CbmTofStarData2018_H - -#include "rocMess_wGet4v2.h" -#include "CbmTofStarData.h" - -#include "Rtypes.h" - -#include <vector> - - -class CbmTofStarTrigger2018 : public CbmTofStarTrigger -{ - // Methods implementation can be found at the end of CbmTsMonitorTofStar.cxx! - public: - // Constructors - CbmTofStarTrigger2018( ULong64_t ulGdpbTsFullIn, ULong64_t ulStarTsFullIn, - UInt_t uStarTokenIn, UInt_t uStarDaqCmdIn, - UInt_t uStarTrigCmdIn ); - - // Destructor - ~CbmTofStarTrigger2018() {}; - - // Setters => Provided by CbmTofStarTrigger - - // Accessors => Mostly provided by CbmTofStarTrigger - std::vector< gdpb::FullMessage > GetGdpbMessages( UShort_t usGdpbId ) const; - - // Operators - bool operator<(const CbmTofStarTrigger2018& other) const; - - private: - -// CbmTofStarTrigger2018(const CbmTofStarTrigger2018&); -// CbmTofStarTrigger2018 operator=(const CbmTofStarTrigger2018&); - -// ClassDef(CbmTofStarTrigger2018, 1) -}; - -class CbmTofStarSubevent2018 -{ - // Methods implementation can be found at the end of CbmTsMonitorTofStar.cxx! - public: - // Constructors - CbmTofStarSubevent2018(); - CbmTofStarSubevent2018( CbmTofStarTrigger triggerIn, UShort_t sourceIdIn ); - - // Destructor - ~CbmTofStarSubevent2018(); - - // Setters - inline void SetTrigger( CbmTofStarTrigger triggerIn ){ fTrigger = triggerIn; fbTriggerSet = kTRUE; } - inline void SetSource( UShort_t sourceIdIn ){ fusSourceId = sourceIdIn; - fulEventStatusFlags = (fulEventStatusFlags & !( kulSourceIdMask << kulSourceIdOffset ) ) - | ( ( sourceIdIn & kulSourceIdMask ) << kulSourceIdOffset ); - } - inline void SetBadEventFlag( Bool_t bFlagState = kTRUE ){ - bFlagState ? (fulEventStatusFlags |= kulFlagBadEvt) : - (fulEventStatusFlags &= ~(kulFlagBadEvt) ); } - inline void SetOverlapEventFlag( Bool_t bFlagState = kTRUE ){ - bFlagState ? (fulEventStatusFlags |= kulFlagOverlapEvt) : - (fulEventStatusFlags &= ~(kulFlagOverlapEvt) ); } - inline void SetEmptyEventFlag( Bool_t bFlagState = kTRUE ){ - bFlagState ? (fulEventStatusFlags |= kulFlagEmptyEvt) : - (fulEventStatusFlags &= ~(kulFlagEmptyEvt) ); } - inline void SetStartBorderEventFlag( Bool_t bFlagState = kTRUE ){ - bFlagState ? (fulEventStatusFlags |= kulFlagStartBorderEvt) : - (fulEventStatusFlags &= ~(kulFlagStartBorderEvt) ); } - inline void SetEndBorderEventFlag( Bool_t bFlagState = kTRUE ){ - bFlagState ? (fulEventStatusFlags |= kulFlagEndBorderEvt) : - (fulEventStatusFlags &= ~(kulFlagEndBorderEvt) ); } - inline void AddMsg( gdpb::FullMessage & msgIn){ fvMsgBuffer.push_back( msgIn ); } - - // Accessors - inline CbmTofStarTrigger GetTrigger() const { return fTrigger;} - inline UShort_t GetSource() const { return fusSourceId; } - inline Bool_t GetBadEventFlag() const { return 0 < (fulEventStatusFlags & kulFlagBadEvt); } - inline Bool_t GetOverlapEventFlag() const { return 0 < (fulEventStatusFlags & kulFlagOverlapEvt); } - inline Bool_t GetEmptyEventFlag() const { return 0 < (fulEventStatusFlags & kulFlagEmptyEvt); } - inline Bool_t GetStartBorderEventFlag() const { return 0 < (fulEventStatusFlags & kulFlagStartBorderEvt); } - inline Bool_t GetEndBorderEventFlag() const { return 0 < (fulEventStatusFlags & kulFlagEndBorderEvt); } - inline Int_t GetEventSize() const { return fuEventSizeBytes; } - inline gdpb::Message GetMsg( UInt_t uMsgIdx ) const; - inline UInt_t GetMsgBuffSize() const { return fvMsgBuffer.size();} - inline static uint32_t GetMaxOutputSize() { return kuMaxOutputSize;} - - // Content clearing - void ClearSubEvent(); - - // Sort content of output buffer - void SortMessages(); - - // Sub-event output - void * BuildOutput( Int_t & iOutputSizeBytes ); - - // Sub-event input - Bool_t LoadInput( void * pBuff, Int_t iInputSizeBytes ); - - // Print the heade and the messages in the buffer - void PrintSubEvent(); - - private: - static const uint32_t kuMaxOutputSize = 131072; // 2^17 - static const uint32_t kuMaxNbMsgs = 8190; // 4 * 64b in header => floor( (2^17 / 8 ) - 4) / 2 - static const uint64_t kulFlagBadEvt = 0x1 << 0; - static const uint64_t kulFlagOverlapEvt = 0x1 << 1; - static const uint64_t kulFlagEmptyEvt = 0x1 << 2; - static const uint64_t kulFlagStartBorderEvt = 0x1 << 3; - static const uint64_t kulFlagEndBorderEvt = 0x1 << 4; - static const uint64_t kulSourceIdOffset = 16; - static const uint64_t kulSourceIdMask = 0xFFFF; - static const uint64_t kulEventSizeOffset = 32; - static const uint64_t kulEventSizeMask = 0xFFFFFFFF; - - Bool_t fbTriggerSet; - CbmTofStarTrigger fTrigger; - UShort_t fusSourceId; - ULong64_t fulEventStatusFlags; - UInt_t fuEventSizeBytes; - std::vector< gdpb::FullMessage > fvMsgBuffer; - ULong64_t fpulBuff[kuMaxOutputSize]; - - - CbmTofStarSubevent2018(const CbmTofStarSubevent2018&); - CbmTofStarSubevent2018 operator=(const CbmTofStarSubevent2018&); - -// ClassDef(CbmTofStarSubevent2018, 1) -}; - -#endif diff --git a/beamtime/star2018/unpacker/CbmTofStarEventBuilder2018.cxx b/beamtime/star2018/unpacker/CbmTofStarEventBuilder2018.cxx deleted file mode 100644 index b47f7c465448810ca6c546321219e8426c99ed3c..0000000000000000000000000000000000000000 --- a/beamtime/star2018/unpacker/CbmTofStarEventBuilder2018.cxx +++ /dev/null @@ -1,2406 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmTofStarEventBuilder2018 ----- -// ----- Created 08.12.2017 by P.-A. Loizeau ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#include "CbmTofStarEventBuilder2018.h" -#include "CbmTofStar2018Par.h" -//#include "CbmTbEvent.h" - -#include "CbmFormatDecHexPrintout.h" - -#include "CbmTbDaqBuffer.h" - -#include "CbmHistManager.h" - -#include "FairLogger.h" -#include "FairRootManager.h" -#include "FairRun.h" -#include "FairRuntimeDb.h" -#include "FairRunOnline.h" - -#include "TROOT.h" -#include "TClonesArray.h" -#include "TString.h" -#include "THttpServer.h" -#include "TProfile.h" -#include <TFile.h> - -#include <iostream> -#include <stdint.h> -#include <iomanip> -#include <fstream> - -static Int_t iMess=0; -// const Int_t DetMask = 0x0001FFFF; (VF) unused - - -CbmTofStarEventBuilder2018::CbmTofStarEventBuilder2018( UInt_t uNbGdpb ) - : CbmTSUnpack(), - fuMsAcceptsPercent(100), - fuTotalMsNb(0), - fuOverlapMsNb(0), - fuCoreMs(0), - fdMsSizeInNs(0.0), - fdTsCoreSizeInNs(0.0), - fuMinNbGdpb( uNbGdpb ), - fuCurrNbGdpb( 0 ), - fuNrOfGdpbs(0), - fuNrOfFebsPerGdpb(0), - fuNrOfGet4PerFeb(0), - fuNrOfChannelsPerGet4(0), - fuNrOfChannelsPerFeet(0), - fuNrOfGet4(0), - fuNrOfGet4PerGdpb(0), - fuNrOfChannelsPerGdpb(0), - fMsgCounter(11,0), // length of enum MessageTypes initialized with 0 - fGdpbIdIndexMap(), - fdStarTriggerDeadtime(), - fdStarTriggerDelay(), - fdStarTriggerWinSize(), - fdTsDeadtimePeriod(0.0), - fulCurrentTsIndex(0), - fuCurrentMs(0), - fuGdpbId(0), - fuGdpbNr(0), - fuGet4Id(0), - fuGet4Nr(0), - fvulCurrentEpoch(), - fvbFirstEpochSeen(), - fNofEpochs(0), - fulCurrentEpochTime(0.), - fdStartTime(-1.), - fdStartTimeLong(-1.), - fdStartTimeMsSz(-1.), - fcMsSizeAll(NULL), - fEquipmentId(0), - fdMsIndex(0.), - fUnpackPar(NULL), - fuHistoryHistoSize( 1800 ), - fuHistoryHistoSizeLong( 600 ), - fdMoniOutIntervalSec( 30.0 ), - fuPrintToSaveRatio( 4 ), - fuPrintToSaveCount( 0 ), - fulGdpbTsMsb(), - fulGdpbTsLsb(), - fulStarTsMsb(), - fulStarTsMid(), - fulGdpbTsFullLast(), - fulStarTsFullLast(), - fuStarTokenLast(), - fuStarDaqCmdLast(), - fuStarTrigCmdLast(), - fulGdpbTsFullLastCore(), - fulStarTsFullLastCore(), - fuStarTokenLastCore(), - fuStarDaqCmdLastCore(), - fuStarTrigCmdLastCore(), - fhTokenMsgType(), - fhTriggerRate(), - fhTriggerRateLong(), - fhCmdDaqVsTrig(), - fhStarTokenEvo(), - fhStarTrigGdpbTsEvo(), - fhStarTrigStarTsEvo(), - fbEventBuilding( kFALSE ), - fbTimeSortOutput( kFALSE ), - fStarSubEvent(), - fulNbBuiltSubEvent( 0 ), - fulNbStarSubEvent( 0 ), - fulNbBuiltSubEventLastPrintout( 0 ), - fulNbStarSubEventLastPrintout( 0 ), - fTimeLastPrintoutNbStarEvent(), - fdCurrentMsStartTime( 0.0 ), - fdCurrentMsEndTime( 0.0 ), - fvmCurrentLinkBuffer(), - fvtCurrentLinkBuffer(), - fdCurrentTsStartTime( 0.0 ), - fdCurrentTsCoreEndTime( 0.0 ), - fvmTsLinksBuffer(), - fvtTsLinksBuffer(), - fvmTsOverLinksBuffer(), - fvtTsOverLinksBuffer(), - fhStarHitToTrigAll_gDPB(), - fhStarHitToTrigWin_gDPB(), - fhStarHitToTrigAllTime_gDPB(), - fhStarHitToTrigWinTime_gDPB(), - fhStarHitToTrigAllTimeLong_gDPB(), - fhStarHitToTrigWinTimeLong_gDPB(), - fhStarEventSize_gDPB(), - fhStarEventSizeTime_gDPB(), - fhStarEventSizeTimeLong_gDPB(), - fhStarTrigTimeToMeanTrig_gDPB(), - fhStarEventSize( NULL ), - fhStarEventSizeTime( NULL ), - fhStarEventSizeTimeLong( NULL ), - fStartTimeProcessingLastTs(), - fhStarTsProcessTime( NULL ), - fhStarTsProcessTimeShort( NULL ), - fhStarTsInterprocessTime( NULL ), - fvmEpSupprBuffer(), - fbEventDumpEna( kFALSE ), - fpBinDumpFile( NULL ) -{ -} - -CbmTofStarEventBuilder2018::~CbmTofStarEventBuilder2018() -{ -} - -Bool_t CbmTofStarEventBuilder2018::Init() -{ - LOG(info) << "CbmTofStarEventBuilder2018::Init => modif of 2018/02/14 18:52 CET"; - LOG(info) << "Initializing STAR eTOF 2018 Event Builder"; - - FairRootManager* ioman = FairRootManager::Instance(); - if( NULL == ioman ) - { - LOG(fatal) << "No FairRootManager instance"; - } - - fUnpackPar = (CbmTofStar2018Par*)(FairRun::Instance()); - - return kTRUE; -} - -void CbmTofStarEventBuilder2018::SetParContainers() -{ - LOG(info) << "Setting parameter containers for " << GetName(); - fUnpackPar = (CbmTofStar2018Par*)(FairRun::Instance()->GetRuntimeDb()->getContainer("CbmTofStar2018Par")); - -} - -Bool_t CbmTofStarEventBuilder2018::InitContainers() -{ - LOG(info) << "Init parameter containers for " << GetName(); - Bool_t initOK = ReInitContainers(); - - CreateHistograms(); - - fvulCurrentEpoch.resize( fuNrOfGdpbs * fuNrOfGet4PerGdpb ); - fvbFirstEpochSeen.resize( fuNrOfGdpbs * fuNrOfGet4PerGdpb ); - for( UInt_t i = 0; i < fuNrOfGdpbs; ++i ) - { - for( UInt_t j = 0; j < fuNrOfGet4PerGdpb; ++j ) - { - fvulCurrentEpoch[GetArrayIndex(i, j)] = 0; - } // for( UInt_t j = 0; j < fuNrOfGet4PerGdpb; ++j ) - } // for( UInt_t i = 0; i < fuNrOfGdpbs; ++i ) - - return initOK; -} - -Bool_t CbmTofStarEventBuilder2018::ReInitContainers() -{ - LOG(info) << "ReInit parameter containers for " << GetName(); - - fuNrOfGdpbs = fUnpackPar->GetNrOfRocs(); - LOG(info) << "Nr. of Tof GDPBs: " << fuNrOfGdpbs; - fuMinNbGdpb = fuNrOfGdpbs; - - fuNrOfFebsPerGdpb = fUnpackPar->GetNrOfFebsPerGdpb(); - LOG(info) << "Nr. of FEBS per Tof GDPB: " << fuNrOfFebsPerGdpb; - - fuNrOfGet4PerFeb = fUnpackPar->GetNrOfGet4PerFeb(); - LOG(info) << "Nr. of GET4 per Tof FEB: " << fuNrOfGet4PerFeb; - - fuNrOfChannelsPerGet4 = fUnpackPar->GetNrOfChannelsPerGet4(); - LOG(info) << "Nr. of channels per GET4: " << fuNrOfChannelsPerGet4; - - fuNrOfChannelsPerFeet = fuNrOfGet4PerFeb * fuNrOfChannelsPerGet4; - LOG(info) << "Nr. of channels per FEET: " << fuNrOfChannelsPerFeet; - - fuNrOfGet4 = fuNrOfGdpbs * fuNrOfFebsPerGdpb * fuNrOfGet4PerFeb; - LOG(info) << "Nr. of GET4s: " << fuNrOfGet4; - - fuNrOfGet4PerGdpb = fuNrOfFebsPerGdpb * fuNrOfGet4PerFeb; - LOG(info) << "Nr. of GET4s per GDPB: " << fuNrOfGet4PerGdpb; - - fuNrOfChannelsPerGdpb = fuNrOfGet4PerGdpb * fuNrOfChannelsPerGet4; - LOG(info) << "Nr. of channels per GDPB: " << fuNrOfChannelsPerGdpb; - - fGdpbIdIndexMap.clear(); - for( UInt_t i = 0; i < fuNrOfGdpbs; ++i ) - { - fGdpbIdIndexMap[fUnpackPar->GetRocId(i)] = i; - LOG(info) << "GDPB Id of TOF " << i << " : " << std::hex << fUnpackPar->GetRocId(i) - << std::dec; - } // for( UInt_t i = 0; i < fuNrOfGdpbs; ++i ) - UInt_t uNrOfChannels = fUnpackPar->GetNumberOfChannels(); - LOG(info) << "Nr. of mapped Tof channels: " << uNrOfChannels; - std::stringstream ss; - for( UInt_t i = 0; i < uNrOfChannels; ++i) - { - if(i%8 == 0) - ss << "\n"; - ss << Form(" 0x%08x",fUnpackPar->GetChannelToDetUIdMap(i)); - } // for( UInt_t i = 0; i < uNrOfChannels; ++i) - LOG(info) << ss.str(); - - fuTotalMsNb = fUnpackPar->GetNbMsTot(); - fuOverlapMsNb = fUnpackPar->GetNbMsOverlap(); - fuCoreMs = fuTotalMsNb - fuOverlapMsNb; - fdMsSizeInNs = fUnpackPar->GetSizeMsInNs(); - fdTsCoreSizeInNs = fdMsSizeInNs * fuCoreMs; - LOG(info) << "Timeslice parameters: " - << fuTotalMsNb << " MS per link, of which " - << fuOverlapMsNb << " overlap MS, each MS is " - << fdMsSizeInNs << " ns, gives TS of " - << fdTsCoreSizeInNs << " ns"; - - fdStarTriggerDeadtime.resize( fuNrOfGdpbs ); - fdStarTriggerDelay.resize( fuNrOfGdpbs ); - fdStarTriggerWinSize.resize( fuNrOfGdpbs ); - for (UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb) - { - fdStarTriggerDeadtime[ uGdpb ] = fUnpackPar->GetStarTriggDeadtime( uGdpb ); - fdStarTriggerDelay[ uGdpb ] = fUnpackPar->GetStarTriggDelay( uGdpb ); - fdStarTriggerWinSize[ uGdpb ] = fUnpackPar->GetStarTriggWinSize( uGdpb ); - LOG(info) << "STAR trigger par of gDPB " << uGdpb << " are: " - << " Deadtime " << fdStarTriggerDeadtime[ uGdpb ] - << " Delay " << -fdStarTriggerDelay[ uGdpb ] - << " and WinSz " << fdStarTriggerWinSize[ uGdpb ]; - if( fdStarTriggerDelay[ uGdpb ] < fdStarTriggerWinSize[ uGdpb ] ) - LOG(fatal) << "STAR trigger window should end at latest on token itself!" - << " => Delay has to be greater or equal with window size!"; - } // for (Int_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb) - fdTsDeadtimePeriod = fUnpackPar->GetTsDeadtimePeriod(); - LOG(info) << "Timeslice deadtime period at beginning: " - << fdTsDeadtimePeriod << "(dealt with using the overlap MS)"; - - /// STAR Trigger decoding and monitoring - fulGdpbTsMsb.resize( fuNrOfGdpbs ); - fulGdpbTsLsb.resize( fuNrOfGdpbs ); - fulStarTsMsb.resize( fuNrOfGdpbs ); - fulStarTsMid.resize( fuNrOfGdpbs ); - fulGdpbTsFullLast.resize( fuNrOfGdpbs ); - fulStarTsFullLast.resize( fuNrOfGdpbs ); - fuStarTokenLast.resize( fuNrOfGdpbs ); - fuStarDaqCmdLast.resize( fuNrOfGdpbs ); - fuStarTrigCmdLast.resize( fuNrOfGdpbs ); - fulGdpbTsFullLastCore.resize( fuNrOfGdpbs ); - fulStarTsFullLastCore.resize( fuNrOfGdpbs ); - fuStarTokenLastCore.resize( fuNrOfGdpbs ); - fuStarDaqCmdLastCore.resize( fuNrOfGdpbs ); - fuStarTrigCmdLastCore.resize( fuNrOfGdpbs ); - fhTokenMsgType.resize( fuNrOfGdpbs ); - fhTriggerRate.resize( fuNrOfGdpbs ); - fhTriggerRateLong.resize( fuNrOfGdpbs ); - fhCmdDaqVsTrig.resize( fuNrOfGdpbs ); - fhStarTokenEvo.resize( fuNrOfGdpbs ); - fhStarTrigGdpbTsEvo.resize( fuNrOfGdpbs ); - fhStarTrigStarTsEvo.resize( fuNrOfGdpbs ); - for (UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb) - { - fulGdpbTsMsb[ uGdpb ] = 0; - fulGdpbTsLsb[ uGdpb ] = 0; - fulStarTsMsb[ uGdpb ] = 0; - fulStarTsMid[ uGdpb ] = 0; - fulGdpbTsFullLast[ uGdpb ] = 0; - fulStarTsFullLast[ uGdpb ] = 0; - fuStarTokenLast[ uGdpb ] = 0; - fuStarDaqCmdLast[ uGdpb ] = 0; - fuStarTrigCmdLast[ uGdpb ] = 0; - fulGdpbTsFullLastCore[ uGdpb ] = 0; - fulStarTsFullLastCore[ uGdpb ] = 0; - fuStarTokenLastCore[ uGdpb ] = 0; - fuStarDaqCmdLastCore[ uGdpb ] = 0; - fuStarTrigCmdLastCore[ uGdpb ] = 0; - fhTokenMsgType[ uGdpb ] = NULL; - fhTriggerRate[ uGdpb ] = NULL; - fhTriggerRateLong[ uGdpb ] = NULL; - fhCmdDaqVsTrig[ uGdpb ] = NULL; - fhStarTokenEvo[ uGdpb ] = NULL; - fhStarTrigGdpbTsEvo[ uGdpb ] = NULL; - fhStarTrigStarTsEvo[ uGdpb ] = NULL; - } // for (Int_t iGdpb = 0; iGdpb < fuNrOfGdpbs; ++iGdpb) - - /// STAR subevent building - if( kTRUE == fbEventBuilding ) - { - fvmTsLinksBuffer.resize( fuNrOfGdpbs ); - fvtTsLinksBuffer.resize( fuNrOfGdpbs ); - fvmTsOverLinksBuffer.resize( fuNrOfGdpbs ); - fvtTsOverLinksBuffer.resize( fuNrOfGdpbs ); - } // if( kTRUE == fbEventBuilding ) - - fvmEpSupprBuffer.resize( fuNrOfGet4 ); - - return kTRUE; -} - -void CbmTofStarEventBuilder2018::SetEventBuildingMode( Bool_t bEventBuildingMode ) -{ - fbEventBuilding = bEventBuildingMode; - if( !fbEventBuilding ) - LOG(info) << "Event building mode = single link per subevent: " << "\n" - << "test mode in 2018 S1, sector mode in 2018 S2"; - else LOG(info) << "Event building mode = all links in same subevent: " << "\n" - << "Sector mode in 2018 S1, Full eTOF mode in 2018 S2"; -} -void CbmTofStarEventBuilder2018::SetTimeSortOutput( Bool_t bTimeSort ) -{ - fbTimeSortOutput = bTimeSort; - if( fbTimeSortOutput ) - LOG(info) << "Output buffer will be time sorted before being sent to STAR DAQ " << "\n" - << "=> This will have an effect (build time) only in event building mode with all links in one subevent " - << " as data for single links are already time sorted"; - else LOG(info) << "Output buffer will NOT be time sorted before being sent to STAR DAQ " << "\n" - << "=> This will have an effect (build time) only in event building mode with all links in one subevent " - << " as data for single links are already time sorted"; -} -void CbmTofStarEventBuilder2018::SetEventDumpEnable( Bool_t bDumpEna ) -{ - if( fbEventDumpEna != bDumpEna ) - { - if( bDumpEna ) - { - LOG(info) << "Enabling event dump to binary file which was disabled. File will be opened."; - - std::time_t cTimeCurrent = std::chrono::system_clock::to_time_t( std::chrono::system_clock::now() ); - char tempBuff[80]; - std::strftime( tempBuff, 80, "%Y_%m_%d_%H_%M_%S", localtime (&cTimeCurrent) ); - TString sFileName = Form("event_dump_%s.bin", tempBuff); - fpBinDumpFile = new std::fstream( sFileName, std::ios::out | std::ios::binary); - - if( NULL == fpBinDumpFile ) - { - LOG(fatal) << "Failed to open new binary file for event dump at " - << sFileName; - } // if( NULL == fpBinDumpFile ) - else LOG(info) << "Opened binary dump file at " - << sFileName; - - } // if( bDumpEna ) - else - { - LOG(info) << "Disabling event dump to binary file which was enabled. File will be closed."; - - if( NULL != fpBinDumpFile ) - fpBinDumpFile->close(); - } // else of if( bDumpEna ) - } // if( fbEventDumpEna != bDumpEna ) - - fbEventDumpEna = bDumpEna; - if( fbEventDumpEna ) - LOG(info) << "Event dump to binary file is now ENABLED"; - else LOG(info) << "Event dump to binary file is now DISABLED"; -} - -void CbmTofStarEventBuilder2018::CbmTofStarEventBuilder2018::CreateHistograms() -{ - LOG(info) << "create Histos for " << fuNrOfGdpbs <<" gDPBs "; - - THttpServer* server = FairRunOnline::Instance()->GetHttpServer(); - - TString name { "" }; - TString title { "" }; - - for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; uGdpb ++) - { - /// Event building - name = Form("StarHitToTrigAll_gDPB_%02u", uGdpb); - title = Form("Time to trigger for all hits gDPB %02u; t(Hit) - t(Trigg) [ns]", uGdpb); - fhStarHitToTrigAll_gDPB.push_back( - new TH1I( name.Data(), title.Data(), - 5000, -100000.0, 50000.0) ); // TODO make offset parameter -// 4000, -800000.0, 0.0) ); // TODO make offset parameter - if (server) - server->Register("/StarRaw", fhStarHitToTrigAll_gDPB[ uGdpb ] ); - - name = Form("StarHitToTrigWin_gDPB_%02u", uGdpb); - title = Form("Time to trigger for hits in trigger window gDPB %02u; t(Hit) - t(Trigg) [ns]", uGdpb); - UInt_t uNbBins = static_cast< UInt_t >( fdStarTriggerWinSize[uGdpb] / 10.0 ); - Double_t dLowBin = -fdStarTriggerDelay[uGdpb]; - Double_t dHighBin = -fdStarTriggerDelay[uGdpb] + fdStarTriggerWinSize[uGdpb]; - fhStarHitToTrigWin_gDPB.push_back( - new TH1I( name.Data(), title.Data(), - uNbBins, dLowBin, dHighBin) ); // TODO make size parameter - if (server) - server->Register("/StarRaw", fhStarHitToTrigWin_gDPB[ uGdpb ] ); - - name = Form("StarHitToTrigAllTime_gDPB_%02u", uGdpb); - title = Form("Time to trigger for all hits gDPB %02u; Time in run [s]; t(Hit) - t(Trigg) [ns]", uGdpb); - fhStarHitToTrigAllTime_gDPB.push_back( - new TH2I( name.Data(), title.Data(), - fuHistoryHistoSize, 0, fuHistoryHistoSize, - 1500, -100000.0, 50000.0) ); // TODO make offset parameter - - name = Form("StarHitToTrigWinTime_gDPB_%02u", uGdpb); - title = Form("Time to trigger for hits in trigger window gDPB %02u; Time in run [s]; t(Hit) - t(Trigg) [ns]", uGdpb); - fhStarHitToTrigWinTime_gDPB.push_back( - new TH2I( name.Data(), title.Data(), - fuHistoryHistoSize, 0, fuHistoryHistoSize, - uNbBins/10.0, dLowBin, dHighBin) ); // TODO make size parameter - - name = Form("StarHitToTrigAllTimeLong_gDPB_%02u", uGdpb); - title = Form("Time to trigger for all hits gDPB %02u; Time in run [s]; t(Hit) - t(Trigg) [ns]", uGdpb); - fhStarHitToTrigAllTimeLong_gDPB.push_back( - new TH2I( name.Data(), title.Data(), - fuHistoryHistoSizeLong, 0, fuHistoryHistoSizeLong, - 1500, -100000.0, 50000.0) ); // TODO make offset parameter - - name = Form("StarHitToTrigWinTimeLong_gDPB_%02u", uGdpb); - title = Form("Time to trigger for hits in trigger window gDPB %02u; Time in run [s]; t(Hit) - t(Trigg) [ns]", uGdpb); - fhStarHitToTrigWinTimeLong_gDPB.push_back( - new TH2I( name.Data(), title.Data(), - fuHistoryHistoSizeLong, 0, fuHistoryHistoSizeLong, - uNbBins/10.0, dLowBin, dHighBin) ); // TODO make size parameter - - if( server ) - { - server->Register("/StarRaw", fhStarHitToTrigAllTime_gDPB[ uGdpb ] ); - server->Register("/StarRaw", fhStarHitToTrigWinTime_gDPB[ uGdpb ] ); - server->Register("/StarRaw", fhStarHitToTrigAllTimeLong_gDPB[ uGdpb ] ); - server->Register("/StarRaw", fhStarHitToTrigWinTimeLong_gDPB[ uGdpb ] ); - } // - - /// STAR Trigger decoding and monitoring - name = Form( "hTokenMsgType_gDPB_%02u", uGdpb); - title = Form( "STAR trigger Messages type gDPB %02u; Type ; Counts", uGdpb); - fhTokenMsgType[ uGdpb ] = new TH1F(name, title, 4, 0, 4); - fhTokenMsgType[ uGdpb ]->GetXaxis()->SetBinLabel( 1, "A"); // gDPB TS high - fhTokenMsgType[ uGdpb ]->GetXaxis()->SetBinLabel( 2, "B"); // gDPB TS low, STAR TS high - fhTokenMsgType[ uGdpb ]->GetXaxis()->SetBinLabel( 3, "C"); // STAR TS mid - fhTokenMsgType[ uGdpb ]->GetXaxis()->SetBinLabel( 4, "D"); // STAR TS low, token, CMDs - if (server) - server->Register("/StarRaw", fhTokenMsgType[ uGdpb ] ); - - name = Form( "hTriggerRate_gDPB_%02u", uGdpb); - title = Form( "STAR trigger signals per second gDPB %02u; Time[s] ; Counts", uGdpb); - fhTriggerRate[ uGdpb ] = new TH1F(name, title, fuHistoryHistoSize, 0, fuHistoryHistoSize); - if (server) - server->Register("/StarRaw", fhTriggerRate[ uGdpb ] ); - - name = Form( "hTriggerRateLong_gDPB_%02u", uGdpb); - title = Form( "STAR trigger signals per minute gDPB %02u; Time[min] ; Counts", uGdpb); - fhTriggerRateLong[ uGdpb ] = new TH1F(name, title, fuHistoryHistoSizeLong, 0, fuHistoryHistoSizeLong); - if (server) - server->Register("/StarRaw", fhTriggerRateLong[ uGdpb ] ); - - name = Form( "hCmdDaqVsTrig_gDPB_%02u", uGdpb); - title = Form( "STAR daq command VS STAR trigger command gDPB %02u; DAQ ; TRIGGER", uGdpb); - fhCmdDaqVsTrig[ uGdpb ] = new TH2I(name, title, 16, 0, 16, 16, 0, 16 ); - fhCmdDaqVsTrig[ uGdpb ]->GetXaxis()->SetBinLabel( 1, "0x0: no-trig "); // idle link - fhCmdDaqVsTrig[ uGdpb ]->GetXaxis()->SetBinLabel( 2, "0x1: clear "); // clears redundancy counters on the readout boards - fhCmdDaqVsTrig[ uGdpb ]->GetXaxis()->SetBinLabel( 3, "0x2: mast-rst"); // general reset of the whole front-end logic - fhCmdDaqVsTrig[ uGdpb ]->GetXaxis()->SetBinLabel( 4, "0x3: spare "); // reserved - fhCmdDaqVsTrig[ uGdpb ]->GetXaxis()->SetBinLabel( 5, "0x4: trigg. 0"); // Default physics readout, all det support required - fhCmdDaqVsTrig[ uGdpb ]->GetXaxis()->SetBinLabel( 6, "0x5: trigg. 1"); // - fhCmdDaqVsTrig[ uGdpb ]->GetXaxis()->SetBinLabel( 7, "0x6: trigg. 2"); // - fhCmdDaqVsTrig[ uGdpb ]->GetXaxis()->SetBinLabel( 8, "0x7: trigg. 3"); // - fhCmdDaqVsTrig[ uGdpb ]->GetXaxis()->SetBinLabel( 9, "0x8: puls. 0"); // - fhCmdDaqVsTrig[ uGdpb ]->GetXaxis()->SetBinLabel(10, "0x9: puls. 1"); // - fhCmdDaqVsTrig[ uGdpb ]->GetXaxis()->SetBinLabel(11, "0xA: puls. 2"); // - fhCmdDaqVsTrig[ uGdpb ]->GetXaxis()->SetBinLabel(12, "0xB: puls. 3"); // - fhCmdDaqVsTrig[ uGdpb ]->GetXaxis()->SetBinLabel(13, "0xC: config "); // housekeeping trigger: return geographic info of FE - fhCmdDaqVsTrig[ uGdpb ]->GetXaxis()->SetBinLabel(14, "0xD: abort "); // aborts and clears an active event - fhCmdDaqVsTrig[ uGdpb ]->GetXaxis()->SetBinLabel(15, "0xE: L1accept"); // - fhCmdDaqVsTrig[ uGdpb ]->GetXaxis()->SetBinLabel(16, "0xF: L2accept"); // - fhCmdDaqVsTrig[ uGdpb ]->GetYaxis()->SetBinLabel( 1, "0x0: 0"); // To be filled at STAR - fhCmdDaqVsTrig[ uGdpb ]->GetYaxis()->SetBinLabel( 2, "0x1: 1"); // To be filled at STAR - fhCmdDaqVsTrig[ uGdpb ]->GetYaxis()->SetBinLabel( 3, "0x2: 2"); // To be filled at STAR - fhCmdDaqVsTrig[ uGdpb ]->GetYaxis()->SetBinLabel( 4, "0x3: 3"); // To be filled at STAR - fhCmdDaqVsTrig[ uGdpb ]->GetYaxis()->SetBinLabel( 5, "0x4: 4"); // To be filled at STAR - fhCmdDaqVsTrig[ uGdpb ]->GetYaxis()->SetBinLabel( 6, "0x5: 5"); // To be filled at STAR - fhCmdDaqVsTrig[ uGdpb ]->GetYaxis()->SetBinLabel( 7, "0x6: 6"); // To be filled at STAR - fhCmdDaqVsTrig[ uGdpb ]->GetYaxis()->SetBinLabel( 8, "0x7: 7"); // To be filled at STAR - fhCmdDaqVsTrig[ uGdpb ]->GetYaxis()->SetBinLabel( 9, "0x8: 8"); // To be filled at STAR - fhCmdDaqVsTrig[ uGdpb ]->GetYaxis()->SetBinLabel(10, "0x9: 9"); // To be filled at STAR - fhCmdDaqVsTrig[ uGdpb ]->GetYaxis()->SetBinLabel(11, "0xA: 10"); // To be filled at STAR - fhCmdDaqVsTrig[ uGdpb ]->GetYaxis()->SetBinLabel(12, "0xB: 11"); // To be filled at STAR - fhCmdDaqVsTrig[ uGdpb ]->GetYaxis()->SetBinLabel(13, "0xC: 12"); // To be filled at STAR - fhCmdDaqVsTrig[ uGdpb ]->GetYaxis()->SetBinLabel(14, "0xD: 13"); // To be filled at STAR - fhCmdDaqVsTrig[ uGdpb ]->GetYaxis()->SetBinLabel(15, "0xE: 14"); // To be filled at STAR - fhCmdDaqVsTrig[ uGdpb ]->GetYaxis()->SetBinLabel(16, "0xF: 15"); // To be filled at STAR - if (server) - server->Register("/StarRaw", fhCmdDaqVsTrig[ uGdpb ] ); - - name = Form( "hStarTokenEvo_gDPB_%02u", uGdpb); - title = Form( "STAR token value VS time gDPB %02u; Time in Run [s] ; STAR Token; Counts", uGdpb); - fhStarTokenEvo[ uGdpb ] = new TH2I(name, title, fuHistoryHistoSize, 0, fuHistoryHistoSize, 410, 0, 4100 ); // 4096 - if (server) - server->Register("/StarRaw", fhStarTokenEvo[ uGdpb ] ); - - name = Form( "hStarTrigGdpbTsEvo_gDPB_%02u", uGdpb); - title = Form( "gDPB TS in STAR triger tokens for gDPB %02u; Time in Run [s] ; gDPB TS;", uGdpb); - fhStarTrigGdpbTsEvo[ uGdpb ] = new TProfile(name, title, fuHistoryHistoSize, 0, fuHistoryHistoSize ); - if (server) - server->Register("/StarRaw", fhStarTrigGdpbTsEvo[ uGdpb ] ); - - name = Form( "hStarTrigStarTsEvo_gDPB_%02u", uGdpb); - title = Form( "STAR TS in STAR triger tokens for gDPB %02u; Time in Run [s] ; STAR TS;", uGdpb); - fhStarTrigStarTsEvo[ uGdpb ] = new TProfile(name, title, fuHistoryHistoSize, 0, fuHistoryHistoSize ); - if (server) - server->Register("/StarRaw", fhStarTrigStarTsEvo[ uGdpb ] ); - - /// Check if we are in "single link per sub-event" building mode - if( kFALSE == fbEventBuilding ) - { - name = Form("StarEventSize_gDPB_%02u", uGdpb); - title = Form("STAR SubEvent size gDPB %02u; SubEvent size [bytes]", uGdpb); - uNbBins = static_cast< UInt_t >( CbmTofStarSubevent::GetMaxOutputSize() / 8 ); // 1 bin = 1 long 64b uint - fhStarEventSize_gDPB.push_back( - new TH1I( name.Data(), title.Data(), - uNbBins, 0.0, CbmTofStarSubevent::GetMaxOutputSize() ) ); - if (server) - server->Register("/StarRaw", fhStarEventSize_gDPB[ uGdpb ] ); - - name = Form("StarEventSizeTime_gDPB_%02u", uGdpb); - title = Form("STAR SubEvent size gDPB %02u; run time [s]; SubEvent size [bytes]", uGdpb); - uNbBins = static_cast< UInt_t >( CbmTofStarSubevent::GetMaxOutputSize() - / (sizeof( ngdpb::Message )) ); - fhStarEventSizeTime_gDPB.push_back( - new TH2I( name.Data(), title.Data(), - fuHistoryHistoSize, 0.0, fuHistoryHistoSize, - uNbBins, 0.0, CbmTofStarSubevent::GetMaxOutputSize() ) ); - if (server) - server->Register("/StarRaw", fhStarEventSizeTime_gDPB[ uGdpb ] ); - - name = Form("StarEventSizeTimeLong_gDPB_%02u", uGdpb); - title = Form("STAR SubEvent size gDPB %02u; run time [min]; SubEvent size [bytes]", uGdpb); - uNbBins = static_cast< UInt_t >( CbmTofStarSubevent::GetMaxOutputSize() - / (sizeof( ngdpb::Message )) ); - fhStarEventSizeTimeLong_gDPB.push_back( - new TH2I( name.Data(), title.Data(), - fuHistoryHistoSizeLong, 0.0, fuHistoryHistoSizeLong, - uNbBins, 0.0, CbmTofStarSubevent::GetMaxOutputSize() ) ); - if (server) - server->Register("/StarRaw", fhStarEventSizeTimeLong_gDPB[ uGdpb ] ); - } // if( kFALSE == fbEventBuilding ) - else - { - - name = Form("StarTrigTimeToMeanTrig_gDPB_%02u", uGdpb); - title = Form("Time difference between gDPB %02u trigger and mean trigger; dT [ns]; counts []", uGdpb); - uNbBins = static_cast< UInt_t >( CbmTofStarSubevent::GetMaxOutputSize() - / (sizeof( ngdpb::Message )) ); - fhStarTrigTimeToMeanTrig_gDPB.push_back( - new TH1I( name.Data(), title.Data(), - 625, -312.5, 312.5 ) ); - if (server) - server->Register("/StarRaw", fhStarTrigTimeToMeanTrig_gDPB[ uGdpb ] ); - } // else of if( kFALSE == fbEventBuilding ) - } // for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; uGdpb ++) - - /// Check if we are in "single sub-event for all links" building mode - if( kTRUE == fbEventBuilding ) - { - name = "StarEventSize_gDPB"; - title = "STAR SubEvent size for all gDPBs; SubEvent size [bytes]"; - UInt_t uNbBins = static_cast< UInt_t >( CbmTofStarSubevent::GetMaxOutputSize() / 8 ); // 1 bin = 1 long 64b uint - fhStarEventSize = new TH1I( name.Data(), title.Data(), uNbBins, 0.0, CbmTofStarSubevent::GetMaxOutputSize() ); - if (server) - server->Register("/StarRaw", fhStarEventSize ); - - name = "StarEventSizeTime"; - title = "STAR SubEvent size for all gDPBS; run time [s]; SubEvent size [bytes]"; - uNbBins = static_cast< UInt_t >( CbmTofStarSubevent::GetMaxOutputSize() - / (sizeof( gdpb::FullMessage )) ); - fhStarEventSizeTime = new TH2I( name.Data(), title.Data(), - fuHistoryHistoSize, 0.0, fuHistoryHistoSize, - uNbBins, 0.0, CbmTofStarSubevent::GetMaxOutputSize() ); - if (server) - server->Register("/StarRaw", fhStarEventSizeTime ); - - name = "StarEventSizeTimeLong"; - title = "STAR SubEvent size for all gDPB; run time [min]; SubEvent size [bytes]"; - uNbBins = static_cast< UInt_t >( CbmTofStarSubevent::GetMaxOutputSize() - / (sizeof( gdpb::FullMessage )) ); - fhStarEventSizeTimeLong = new TH2I( name.Data(), title.Data(), - fuHistoryHistoSizeLong, 0.0, fuHistoryHistoSizeLong, - uNbBins, 0.0, CbmTofStarSubevent::GetMaxOutputSize() ); - if (server) - server->Register("/StarRaw", fhStarEventSizeTimeLong ); - } // if( kFALSE == fbEventBuilding ) - - /// Monitoring of the processing time - name = "fhStarTsProcessTime"; - title = "Ratio of processing time per TS to TS size VS TS index; TS index []; Ratio []"; - Double_t dTsEvoLongMax = fuHistoryHistoSizeLong * 60.0 / (fdTsCoreSizeInNs * 1e-9); - fhStarTsProcessTime = new TH2I( name.Data(), title.Data(), - fuHistoryHistoSizeLong, 0.0, dTsEvoLongMax, - 250, 0.0, 5.0 ); - if (server) - server->Register("/StarRaw", fhStarTsProcessTime ); - name = "fhStarTsProcessTimeShort"; - title = "Ratio of processing time per TS to TS size VS TS index; TS index []; Ratio []"; - Double_t dTsEvoShortMax = 500 / (fdTsCoreSizeInNs * 1e-9); - fhStarTsProcessTimeShort = new TH2I( name.Data(), title.Data(), - 500, 0.0, dTsEvoShortMax, - 250, 0.0, 5.0 ); - if (server) - server->Register("/StarRaw", fhStarTsProcessTimeShort ); - name = "fhStarTsInterprocessTime"; - title = "Ratio of time between TS processing to TS size VS TS index; Ratio tInterprocess / tTS []"; - fhStarTsInterprocessTime = new TH1D( name.Data(), title.Data(), - 2000, 0.0, 200.0 ); - if (server) - server->Register("/StarRaw", fhStarTsInterprocessTime ); - - /** Create summary Canvases for STAR 2017 **/ - Double_t w = 10; - Double_t h = 10; - /*****************************/ - - - /** Create STAR token Canvas for STAR 2017 **/ - for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; uGdpb ++) - { - TCanvas* cStarToken = new TCanvas( Form("cStarToken_g%02u", uGdpb), - Form("STAR token detection info for gDPB %02u", uGdpb), - w, h); - cStarToken->Divide( 2, 2 ); - - cStarToken->cd(1); - fhTriggerRate[uGdpb]->Draw(); - - cStarToken->cd(2); - fhCmdDaqVsTrig[uGdpb]->Draw( "colz" ); - - cStarToken->cd(3); - fhStarTokenEvo[uGdpb]->Draw(); - - cStarToken->cd(4); - fhStarTrigStarTsEvo[uGdpb]->Draw( "hist" ); - } // for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; uGdpb ++) - /*****************************/ - - /** Create Event building mode Canvas(es) for STAR 2017 **/ - if( kTRUE == fbEventBuilding ) - { - TCanvas* cStarEvtBuild = new TCanvas( "cStarEvtAll", - "STAR SubEvent Building for all gDPBs", - w, h); - cStarEvtBuild->Divide( 2, 2 ); - - cStarEvtBuild->cd(1); - gPad->SetLogx(); - gPad->SetLogy(); - fhStarEventSize->Draw(); - - cStarEvtBuild->cd(2); - gPad->SetLogy(); - gPad->SetLogz(); - fhStarEventSizeTime->Draw( "colz" ); - - cStarEvtBuild->cd(3); - gPad->SetLogy(); - gPad->SetLogz(); - fhStarEventSizeTimeLong->Draw( "colz" ); - } // if( kTRUE == fbEventBuilding ) - - for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; uGdpb ++) - { - TCanvas* cStarEvtBuild = new TCanvas( Form("cStarEvt_g%02u", uGdpb), - Form("STAR SubEvent Building for gDPB %02u", uGdpb), - w, h); - if( kTRUE == fbEventBuilding ) - cStarEvtBuild->Divide( 1, 3 ); - else cStarEvtBuild->Divide( 2, 2 ); - - cStarEvtBuild->cd(1); - fhStarHitToTrigAll_gDPB[uGdpb]->Draw(); - - cStarEvtBuild->cd(2); - fhStarHitToTrigWin_gDPB[uGdpb]->Draw(); - - if( kFALSE == fbEventBuilding ) - { - cStarEvtBuild->cd(3); - gPad->SetLogx(); - gPad->SetLogy(); - fhStarEventSize_gDPB[uGdpb]->Draw(); - - cStarEvtBuild->cd(4); - gPad->SetLogy(); - gPad->SetLogz(); - fhStarEventSizeTime_gDPB[uGdpb]->Draw( "colz" ); - } // if( kFALSE == fbEventBuilding ) - else - { - cStarEvtBuild->cd(3); - gPad->SetLogy(); - fhStarTrigTimeToMeanTrig_gDPB[uGdpb]->Draw(); - } // else of if( kFALSE == fbEventBuilding ) - } // for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; uGdpb ++) - /*****************************/ - -} - -Bool_t CbmTofStarEventBuilder2018::DoUnpack(const fles::Timeslice& ts, size_t component) -{ - uint64_t ulTsIndex = ts.index(); - if( fulCurrentTsIndex < ulTsIndex ) - { - /// Check if we are in "single sub-event for all links" building mode - if( kTRUE == fbEventBuilding ) - { - BuildStarEventsAllLinks(); - } // if( kTRUE == fbEventBuilding ) - - std::chrono::time_point<std::chrono::system_clock> timeCurrent = std::chrono::system_clock::now(); - if( 0 != fStartTimeProcessingLastTs.time_since_epoch().count() && - 0 < fulCurrentTsIndex ) - { - std::chrono::duration<double> elapsed_seconds = timeCurrent - fStartTimeProcessingLastTs; - Double_t dTimeRatio = elapsed_seconds.count() / (fdTsCoreSizeInNs * 1e-9); - fhStarTsInterprocessTime->Fill( dTimeRatio ); - } // if( 0 != fStartTimeProcessingLastTs.time_since_epoch().count() && 0 < fulCurrentTsIndex ) - fStartTimeProcessingLastTs = timeCurrent; - } // if( fCurrentTsIndex < ts.index() ) - else if( ulTsIndex < fulCurrentTsIndex ) - { - /// Either TS index made a loop or the timestamps were reinitialised - /// Check if we are in "single sub-event for all links" building mode - if( kTRUE == fbEventBuilding ) - { - /// Clear buffers, eventual border crossing should be taken care thanks to the overlap MS - for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; uGdpb ++) - { - fvtTsLinksBuffer[uGdpb].clear(); - fvmTsLinksBuffer[uGdpb].clear(); - fvmTsOverLinksBuffer[uGdpb].clear(); - fvtTsOverLinksBuffer[uGdpb].clear(); - } // for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; uGdpb ++) - } // if( kTRUE == fbEventBuilding ) - } // if( tsIndex < fulCurrentTsIndex ) - fulCurrentTsIndex = ulTsIndex; - - LOG(debug) << "Timeslice contains " << ts.num_microslices(component) - << " microslices of component " << component; - - /// Printout of nb star events log - std::chrono::time_point<std::chrono::system_clock> timeCurrent = std::chrono::system_clock::now(); - std::chrono::duration<double> elapsed_seconds = timeCurrent - fTimeLastPrintoutNbStarEvent; - if( 0 == fTimeLastPrintoutNbStarEvent.time_since_epoch().count() ) - { - fTimeLastPrintoutNbStarEvent = timeCurrent; - fulNbBuiltSubEventLastPrintout = fulNbBuiltSubEvent; - fulNbStarSubEventLastPrintout = fulNbStarSubEvent; - } // if( 0 == fTimeLastPrintoutNbStarEvent.time_since_epoch().count() ) - else if( fdMoniOutIntervalSec < elapsed_seconds.count() ) - { - std::time_t cTimeCurrent = std::chrono::system_clock::to_time_t( timeCurrent ); - char tempBuff[80]; - std::strftime( tempBuff, 80, "%F %T", localtime (&cTimeCurrent) ); - - LOG(info) << "CbmTofStarEventBuilder2018::DoUnpack => " << tempBuff - << " Total number of Built events: " << std::setw(9) << fulNbBuiltSubEvent - << ", " << std::setw(9) << (fulNbBuiltSubEvent - fulNbBuiltSubEventLastPrintout) - << " events in last " << std::setw(4) << elapsed_seconds.count() << " s"; - fTimeLastPrintoutNbStarEvent = timeCurrent; - fulNbBuiltSubEventLastPrintout = fulNbBuiltSubEvent; - - LOG(info) << "CbmTofStarEventBuilder2018::DoUnpack => " << tempBuff - << " Total number of events sent to STAR: " << std::setw(9) << fulNbStarSubEvent - << ", " << std::setw(9) << (fulNbStarSubEvent - fulNbStarSubEventLastPrintout) - << " events in last " << std::setw(4) << elapsed_seconds.count() << " s"; - fTimeLastPrintoutNbStarEvent = timeCurrent; - fulNbStarSubEventLastPrintout = fulNbStarSubEvent; - - if( kTRUE == fbEventBuilding ) - { - } // if( kTRUE == fbEventBuilding ) - else LOG(info) << "CbmTofStarEventBuilder2018::DoUnpack => " << tempBuff - << " Buffers size: messages " << std::setw(9) << fvmCurrentLinkBuffer.size() - << " triggers " << std::setw(9) << fvtCurrentLinkBuffer.size(); - - fuPrintToSaveCount ++; - if( fuPrintToSaveCount == fuPrintToSaveRatio ) - { - SaveAllHistos( "data/histos_event_build.root" ); - fuPrintToSaveCount = 0; - } // if( fuPrintToSaveCount == fuPrintToSaveRatio ) - } // else if( 300 < elapsed_seconds.count() ) - - // Loop over microslices - Int_t iMessageType = -111; - size_t numCompMsInTs = ts.num_microslices(component); - for( fuCurrentMs = 0; fuCurrentMs < numCompMsInTs; ++fuCurrentMs ) - { - // Jump some microslices if needed -// if( fuMsAcceptsPercent < m) -// continue; - - // Ignore overlap ms if number defined by user - // => Should be dealt with in the methods for each message type -// if( numCompMsInTs - fuOverlapMsNb <= fuCurrentMs ) -// continue; - - constexpr uint32_t kuBytesPerMessage = 8; - - auto msDescriptor = ts.descriptor(component, fuCurrentMs); - fEquipmentId = msDescriptor.eq_id; - fdMsIndex = static_cast<double>(msDescriptor.idx); - const uint8_t* msContent = reinterpret_cast< const uint8_t* >( ts.content(component, fuCurrentMs) ); - - uint32_t size = msDescriptor.size; - if( 0 < size ) - LOG(debug1) << "Microslice "<< fuCurrentMs <<": " << fdMsIndex - << " has size: " << size; - - if( fdStartTimeMsSz < 0 ) - fdStartTimeMsSz = (1e-9) * fdMsIndex; - - /// Save the starting time of the TS or of the MS - if( kTRUE == fbEventBuilding ) - { - if( 0 == fuCurrentMs ) - { - fdCurrentTsStartTime = fdMsIndex; - fdCurrentTsCoreEndTime = fdCurrentTsStartTime + fdTsCoreSizeInNs; - } // if( 0 == fuCurrentMs ) - } // if( kTRUE == fbEventBuilding ) - else - { - fdCurrentMsStartTime = fdMsIndex; - fdCurrentMsEndTime = fdCurrentMsStartTime + fdMsSizeInNs; - } // else of if( kTRUE == fbEventBuilding ) - - // If not integer number of message in input buffer, print warning/error - if( 0 != (size % kuBytesPerMessage) ) - LOG(error) << "The input microslice buffer does NOT " - << "contain only complete nDPB messages!"; - - // If not integer number of message in input buffer, print warning/error - if( 0 != (size % kuBytesPerMessage) ) - LOG(error) << "The input microslice buffer does NOT " - << "contain only complete nDPB messages!"; - - // Compute the number of complete messages in the input microslice buffer - uint32_t uNbMessages = (size - (size % kuBytesPerMessage) ) - / kuBytesPerMessage; - - // Prepare variables for the loop on contents - const uint64_t* pInBuff = reinterpret_cast<const uint64_t*>( msContent ); - for (uint32_t uIdx = 0; uIdx < uNbMessages; uIdx ++) - { - // Fill message - uint64_t ulData = static_cast<uint64_t>( pInBuff[uIdx] ); - gdpb::Message mess( ulData ); - - if( gLogger->IsLogNeeded( fair::Severity::debug2 ) ) - { - mess.printDataCout(); - } // if( gLogger->IsLogNeeded( fair::Severity::debug2 ) ) - - // Increment counter for different message types - iMessageType = mess.getMessageType(); - fMsgCounter[ iMessageType ]++; - - if( 0 == uIdx ) - { - fuGdpbId = mess.getRocNumber(); - - /// if unmapped gDPB, just ignore this block - if( fGdpbIdIndexMap.end() == fGdpbIdIndexMap.find( fuGdpbId ) ) - break; - - fuGdpbNr = fGdpbIdIndexMap[ fuGdpbId ]; - - /// Store the last STAR trigger values for the core MS when reaching the first overlap MS - if( fuCoreMs == fuCurrentMs ) - { - fulGdpbTsFullLastCore[ fuGdpbNr ] = fulGdpbTsFullLast[ fuGdpbNr ]; - fulStarTsFullLastCore[ fuGdpbNr ] = fulStarTsFullLast[ fuGdpbNr ]; - fuStarTokenLastCore[ fuGdpbNr ] = fuStarTokenLast[ fuGdpbNr ]; - fuStarDaqCmdLastCore[ fuGdpbNr ] = fuStarDaqCmdLast[ fuGdpbNr ]; - fuStarTrigCmdLastCore[ fuGdpbNr ] = fuStarTrigCmdLast[ fuGdpbNr ]; - } // if( fuCoreMs == fuCurrentMs ) - - /// Restore the last STAR trigger values for the core MS when reaching the first core MS - if( 0 == fuCurrentMs ) - { - fulGdpbTsFullLast[ fuGdpbNr ] = fulGdpbTsFullLastCore[ fuGdpbNr ]; - fulStarTsFullLast[ fuGdpbNr ] = fulStarTsFullLastCore[ fuGdpbNr ]; - fuStarTokenLast[ fuGdpbNr ] = fuStarTokenLastCore[ fuGdpbNr ]; - fuStarDaqCmdLast[ fuGdpbNr ] = fuStarDaqCmdLastCore[ fuGdpbNr ]; - fuStarTrigCmdLast[ fuGdpbNr ] = fuStarTrigCmdLastCore[ fuGdpbNr ]; - } // if( 0 == fuCurrentMs ) - } // if( 0 = uIdx ) - - fuGet4Id = mess.getGdpbGenChipId(); - fuGet4Nr = (fuGdpbNr * fuNrOfGet4PerGdpb) + fuGet4Id; - - if( fuNrOfGet4PerGdpb <= fuGet4Id && - gdpb::MSG_STAR_TRI != iMessageType && - get4v2x::kuChipIdMergedEpoch != fuGet4Id ) - LOG(warning) << "Message with Get4 ID too high: " << fuGet4Id - << " VS " << fuNrOfGet4PerGdpb << " set in parameters."; - - /// First message in MS should ALWAYS be a merged epoch -/* - if( 0 == uIdx ) - { - if( gdpb::MSG_EPOCH2 != iMessageType || get4v2x::kuChipIdMergedEpoch != fuGet4Id ) - LOG(warning) << "First message in MS is not a merged epoch!!!!!" - << " TS = " << fulCurrentTsIndex << " MS = " << fuCurrentMs - << " Type = " << iMessageType << " Get4Id = " << fuGet4Id - << " Is epoch? " << (gdpb::MSG_EPOCH2 == iMessageType); - } // if( 0 == uIdx ) - if( uNbMessages - 1 == uIdx ) - { - if( gdpb::MSG_EPOCH2 != iMessageType || get4v2x::kuChipIdMergedEpoch != fuGet4Id ) - LOG(warning) << "Last message in MS is not a merged epoch!!!!!" - << " TS = " << fulCurrentTsIndex << " MS = " << fuCurrentMs - << " Type = " << iMessageType << " Get4Id = " << fuGet4Id - << " Is epoch? " << (gdpb::MSG_EPOCH2 == iMessageType); - } // if( uNbMessages - 1 == uIdx ) -*/ - switch( iMessageType ) - { - case gdpb::MSG_GET4: - { - // FillEpochInfo(mess); - LOG(error) << "Message type " << iMessageType - << " not included in unpacker."; - break; - } // case old non tof messages - case gdpb::MSG_EPOCH2: - { - if( get4v2x::kuChipIdMergedEpoch == fuGet4Id ) - { - /// Propagate for all ASICs corresponding to this merged epoch - for( uint32_t uGet4Index = 0; uGet4Index < fuNrOfGet4PerGdpb; uGet4Index ++ ) - { - gdpb::Message tmpMess( mess ); - tmpMess.setGdpbGenChipId( uGet4Index ); - fuGet4Nr = (fuGdpbNr * fuNrOfGet4PerGdpb) + uGet4Index; - - FillEpochInfo( tmpMess ); - } // for( uint32_t uGet4Index = 0; uGet4Index < fuNrOfGet4PerGdpb; uGetIndex ++ ) - - /// Keep track of extended epoch index for each gDPB - // TO BE DONE - } // if this epoch message is a merged one valiud for all chips - else - { -// fHistGet4MessType->Fill( fuGet4Nr, gdpb::GET4_32B_EPOCH ); - LOG(warning) << "Extra non merged epoch for GDPB#" << Form("%2u", fuGdpbNr) - << " G4 #" << Form("%2u", fuGet4Id) - << " => ASIC " << Form("%3u", fuGet4Nr); - FillEpochInfo(mess); - } // if single chip epoch message - - /// Out of FillEpochInfo so that we do not expand the Merged epoch!! - gdpb::FullMessage fullMess( mess, mess.getGdpbEpEpochNb() ); - if( kTRUE == fbEventBuilding ) - { - if( fuCurrentMs < fuCoreMs ) - fvmTsLinksBuffer[fuGdpbNr].push_back( fullMess ); - else fvmTsOverLinksBuffer[fuGdpbNr].push_back( fullMess ); - } // if( kTRUE == fbEventBuilding ) - else - fvmCurrentLinkBuffer.push_back( fullMess ); - - break; - } // case gdpb::MSG_EPOCH2: - case gdpb::MSG_GET4_32B: - { - FillHitInfo( mess ); -// fvmEpSupprBuffer[ fuGet4Nr ].push_back( mess ); - break; - } // case gdpb::MSG_GET4_32B: - case gdpb::MSG_GET4_SLC: - { - PrintSlcInfo(mess); - break; - } // case gdpb::MSG_GET4_SLC: - case gdpb::MSG_GET4_SYS: - { - PrintSysInfo(mess); - break; - } // case gdpb::MSG_GET4_SYS: - case gdpb::MSG_STAR_TRI: - { - FillStarTrigInfo(mess); - break; - } // case gdpb::MSG_STAR_TRI: - default: - { - if(100 > iMess++) - LOG(error) << "Message ("<<iMess<<") type " << std::hex << std::setw(2) - << static_cast< uint16_t >( iMessageType ) - << " not included in Get4 unpacker."; - if(100 == iMess) - LOG(error) << "Stop reporting MSG errors... "; - } // default: - } // switch( iMessageType ) - - } // for (uint32_t uIdx = 0; uIdx < uNbMessages; uIdx ++) - - /// Check if we are in "single link per sub-event" building mode - if( kFALSE == fbEventBuilding ) - { - /// Make sure that the current MS is not one of the overlap ones - /// and build sub-events in it if that is the case - if( fuCurrentMs < fuCoreMs ) - BuildStarEventsSingleLink(); - else - { - /// clear message buffer - fvmCurrentLinkBuffer.clear(); - - /// Clear trigger buffer - fvtCurrentLinkBuffer.clear(); - } // else of if( fuCurrentMs < fuCoreMs ) - } // if( kFALSE == fbEventBuilding ) - - } // for( fuCurrentMs = 0; fuCurrentMs < numCompMsInTs; ++fuCurrentMs ) - - /// Plot processing time - timeCurrent = std::chrono::system_clock::now(); - if( 0 != fStartTimeProcessingLastTs.time_since_epoch().count() && - 0 < fulCurrentTsIndex ) - { - elapsed_seconds = timeCurrent - fStartTimeProcessingLastTs; - Double_t dTimeRatio = elapsed_seconds.count() / (fdTsCoreSizeInNs * 1e-9); - if( dTimeRatio < 5 ) - { - fhStarTsProcessTime->Fill(fulCurrentTsIndex, dTimeRatio ); - fhStarTsProcessTimeShort->Fill(fulCurrentTsIndex, dTimeRatio ); - } // if( dTimeRatio < 5 ) - else - { - fhStarTsProcessTime->Fill(fulCurrentTsIndex, 4.999 ); - fhStarTsProcessTimeShort->Fill(fulCurrentTsIndex, 4.999 ); - } // else of if( dTimeRatio < 5 ) - } // if( 0 != fStartTimeProcessingLastTs.time_since_epoch().count() && 0 < fulCurrentTsIndex ) - fStartTimeProcessingLastTs = timeCurrent; - - return kTRUE; -} - -void CbmTofStarEventBuilder2018::FillHitInfo( gdpb::Message mess ) -{ - // --- Get absolute time, GET4 ID and channel number - UInt_t uGet4Id = mess.getGdpbGenChipId(); - UInt_t uChannel = mess.getGdpbHitChanId(); -// UInt_t uTot = mess.getGdpbHit32Tot(); - // In 32b mode the coarse counter is already computed back to 112 FTS bins - // => need to hide its contribution from the Finetime - // => FTS = Fullt TS modulo 112 -// UInt_t uFts = mess.getGdpbHitFullTs() % 112; - - ULong64_t ulCurEpochGdpbGet4 = fvulCurrentEpoch[ fuGet4Nr ]; - - if( kTRUE == fvbFirstEpochSeen[ fuGet4Nr ] ) - { - -/// TODO clean epoch suppression in STAR 2018! -/* - // In Ep. Suppr. Mode, receive following epoch instead of previous - if( 0 < ulCurEpochGdpbGet4 ) - ulCurEpochGdpbGet4 --; - else ulCurEpochGdpbGet4 = get4v2x::kuEpochCounterSz; // Catch epoch cycle! -*/ -// ULong_t ulhitTime = mess.getMsgFullTime( ulCurEpochGdpbGet4 ); - Double_t dHitTime = mess.getMsgFullTimeD( ulCurEpochGdpbGet4 ); -// Double_t dHitTot = uTot; // in bins - - -// UInt_t uFebIdx = (uGet4Id / fuNrOfGet4PerFeb); -// UInt_t uFullFebIdx = (fuGdpbNr * fuNrOfFebsPerGdpb) + uFebIdx; - - UInt_t uChanInGdpb = uGet4Id * fuNrOfChannelsPerGet4 + uChannel; - UInt_t uChanInSyst = fuGdpbNr * fuNrOfChannelsPerGdpb + uChanInGdpb; - if( fUnpackPar->GetNumberOfChannels() < 1 || - static_cast< UInt_t>( fUnpackPar->GetNumberOfChannels() ) < uChanInSyst ) - { - LOG(error) << "Invalid mapping index " << uChanInSyst - << " VS " << fUnpackPar->GetNumberOfChannels() - <<", from " << fuGdpbNr - <<", " << uGet4Id - <<", " << uChannel; - return; - } // if( fUnpackPar->GetNumberOfChannels() < uChanUId ) - - /// Histograms filling - /// In Run rate evolution - if (fdStartTime < 0) - fdStartTime = dHitTime; - if (fdStartTimeLong < 0) - fdStartTimeLong = dHitTime; - /// Reset the evolution Histogram and the start time when we reach the end of the range - if( fuHistoryHistoSize < 1e-9 * (dHitTime - fdStartTime) ) - { - ResetEvolutionHistograms(); - fdStartTime = dHitTime; - } // if( fuHistoryHistoSize < 1e-9 * (dHitTime - fdStartTime) ) - /// Reset the long evolution Histogram and the start time when we reach the end of the range - if( fuHistoryHistoSizeLong < 1e-9 * (dHitTime - fdStartTimeLong) / 60.0 ) - { - ResetLongEvolutionHistograms(); - fdStartTimeLong = dHitTime; - } // if( fuHistoryHistoSizeLong < 1e-9 * (dHitTime - fdStartTimeLong) / 60.0 ) - - gdpb::FullMessage fullMess( mess, ulCurEpochGdpbGet4 ); - if( kTRUE == fbEventBuilding ) - { - if( fuCurrentMs < fuCoreMs ) - fvmTsLinksBuffer[fuGdpbNr].push_back( fullMess ); - else fvmTsOverLinksBuffer[fuGdpbNr].push_back( fullMess ); - } // if( kTRUE == fbEventBuilding ) - else - fvmCurrentLinkBuffer.push_back( fullMess ); - - } // if( kTRUE == fvbFirstEpochSeen[ fuGet4Nr ] ) -} - -void CbmTofStarEventBuilder2018::FillEpochInfo( gdpb::Message mess ) -{ - ULong64_t ulEpochNr = mess.getGdpbEpEpochNb(); - - fvulCurrentEpoch[ fuGet4Nr ] = ulEpochNr; -/* - if (1 == mess.getGdpbEpDataLoss()) - LOG(info) << "Data loss flag set GDPB #" << Form( "%2u", fuGdpbNr) << " G4 #" << Form( "%3u", fuGet4Nr); - if (1 == mess.getGdpbEpEpochLoss()) - LOG(info) << "Epoch loss flag set GDPB #" << Form( "%2u", fuGdpbNr) << " G4 #" << Form( "%3u", fuGet4Nr); -// if (1 == mess.getGdpbEpMissmatch()) -// LOG(info) << "Epoch missmatch flag set GDPB #" << Form( "%2u", fuGdpbNr) << " G4 #" << Form( "%3u", fuGet4Nr); -*/ - - if( kFALSE == fvbFirstEpochSeen[ fuGet4Nr ] ) - fvbFirstEpochSeen[ fuGet4Nr ] = kTRUE; - - fulCurrentEpochTime = mess.getMsgFullTime(ulEpochNr); - fNofEpochs++; -/* - /// In Ep. Suppr. Mode, receive following epoch instead of previous - /// Re-align the epoch number of the message in case it will be used later: - /// We received the epoch after the data instead of the one before! - /// TODO FIXME: commented out for the time being so that the order in the STAR - /// date is the same as in the CBM data - if( 0 < ulEpochNr ) - mess.setEpoch2Number( ulEpochNr - 1 ); - else mess.setEpoch2Number( get4v2x::kuEpochCounterSz ); - - Int_t iBufferSize = fvmEpSupprBuffer[ fuGet4Nr ].size(); - if( 0 < iBufferSize ) - { - LOG(debug) << "Now processing stored messages for for get4 " << fuGet4Nr << " with epoch number " - << (fvulCurrentEpoch[ fuGet4Nr ] - 1); - - /// Data are sorted between epochs, not inside => Epoch level ordering - /// Sorting at lower bin precision level - std::stable_sort( fvmEpSupprBuffer[fuGet4Nr].begin(), fvmEpSupprBuffer[fuGet4Nr].begin() ); - - for( Int_t iMsgIdx = 0; iMsgIdx < iBufferSize; iMsgIdx++ ) - { - FillHitInfo( fvmEpSupprBuffer[ fuGet4Nr ][ iMsgIdx ] ); - } // for( Int_t iMsgIdx = 0; iMsgIdx < iBufferSize; iMsgIdx++ ) - - fvmEpSupprBuffer[fuGet4Nr].clear(); - } // if( 0 < fvmEpSupprBuffer[fGet4Nr] ) -*/ -} - -void CbmTofStarEventBuilder2018::PrintSlcInfo(gdpb::Message mess) -{ - /// Nothing to do, maybe later use it to trakc parameter changes like treshold? -/* - if( fGdpbIdIndexMap.end() != fGdpbIdIndexMap.find( rocId ) ) - LOG(info) << "GET4 Slow Control message, epoch " << static_cast<Int_t>(fCurrentEpoch[rocId][get4Id]) - << ", time " << std::setprecision(9) << std::fixed - << Double_t(fulCurrentEpochTime) * 1.e-9 << " s " - << " for board ID " << std::hex << std::setw(4) << rocId << std::dec - << "\n" - << " +++++++ > Chip = " << std::setw(2) << mess.getGdpbGenChipId() - << ", Chan = " << std::setw(1) << mess.getGdpbSlcChan() - << ", Edge = " << std::setw(1) << mess.getGdpbSlcEdge() - << ", Type = " << std::setw(1) << mess.getGdpbSlcType() - << ", Data = " << std::hex << std::setw(6) << mess.getGdpbSlcData() << std::dec - << ", Type = " << mess.getGdpbSlcCrc(); -*/ - gdpb::FullMessage fullMess( mess, fvulCurrentEpoch[ fuGet4Nr ] ); - if( kTRUE == fbEventBuilding ) - { - if( fuCurrentMs < fuCoreMs ) - fvmTsLinksBuffer[fuGdpbNr].push_back( fullMess ); - else fvmTsOverLinksBuffer[fuGdpbNr].push_back( fullMess ); - } // if( kTRUE == fbEventBuilding ) - else - fvmCurrentLinkBuffer.push_back( fullMess ); - - /// TODO FIXME: Add the error messages to the buffer for inclusion in the STAR event - /// NEEDS the proper "<" operator in FullMessage or Message to allow time sorting -} - -void CbmTofStarEventBuilder2018::PrintGenInfo(gdpb::Message mess) -{ - Int_t mType = mess.getMessageType(); - Int_t rocId = mess.getRocNumber(); - Int_t get4Id = mess.getGdpbGenChipId(); - Int_t channel = mess.getGdpbHitChanId(); - uint64_t uData = mess.getData(); - if(100 > iMess++) - LOG(info) << "Get4 MSG type "<<mType<<" from rocId "<<rocId<<", getId "<<get4Id - << ", (hit channel) "<<channel -// <<Form(" hex data %0llx ",uData); - << " hex data " << FormatHexPrintout( uData, 0, '0' ); -} - -void CbmTofStarEventBuilder2018::PrintSysInfo(gdpb::Message mess) -{ -/* - LOG(info) << "GET4 System message, epoch " << (fvulCurrentEpoch[ fuGet4Nr]) - << ", time " << std::setprecision(9) << std::fixed - << Double_t(fulCurrentEpochTime) * 1.e-9 << " s " - << " for board ID " << std::hex << std::setw(4) << fuGdpbId << std::dec; -*/ - - switch( mess.getGdpbSysSubType() ) - { - case gdpb::SYSMSG_GET4_EVENT: - { -/* - LOG(info) << " +++++++ > Chip = " << std::setw(2) << mess.getGdpbGenChipId() - << ", Chan = " << std::setw(1) << mess.getGdpbSysErrChanId() - << ", Edge = " << std::setw(1) << mess.getGdpbSysErrEdge() - << ", Empt = " << std::setw(1) << mess.getGdpbSysErrUnused() - << ", Data = " << std::hex << std::setw(2) << mess.getGdpbSysErrData() << std::dec - << " -- GET4 V1 Error Event"; -*/ - /// TODO FIXME: Add the error messages to the buffer for inclusion in the STAR event - /// NEEDS the proper "<" operator in FullMessage or Message to allow time sorting - gdpb::FullMessage fullMess( mess, fvulCurrentEpoch[ fuGet4Nr ] ); - if( kTRUE == fbEventBuilding ) - { - if( fuCurrentMs < fuCoreMs ) - fvmTsLinksBuffer[fuGdpbNr].push_back( fullMess ); - else fvmTsOverLinksBuffer[fuGdpbNr].push_back( fullMess ); - } // if( kTRUE == fbEventBuilding ) - else - fvmCurrentLinkBuffer.push_back( fullMess ); - break; - } // - case gdpb::SYSMSG_CLOSYSYNC_ERROR: - if(100 > iMess++) - LOG(info) << "Closy synchronization error"; - break; - case gdpb::SYSMSG_TS156_SYNC: - if(100 > iMess++) - LOG(info) << "156.25MHz timestamp reset"; - break; - case gdpb::SYSMSG_GDPB_UNKWN: - if(100 > iMess++) - LOG(info) << "Unknown GET4 message, data: " << std::hex << std::setw(8) - << mess.getGdpbSysUnkwData() << std::dec; - break; - } // switch( getGdpbSysSubType() ) -} - -void CbmTofStarEventBuilder2018::FillStarTrigInfo(gdpb::Message mess) -{ - Int_t iMsgIndex = mess.getStarTrigMsgIndex(); - - switch( iMsgIndex ) - { - case 0: - fhTokenMsgType[fuGdpbNr]->Fill(0); - fulGdpbTsMsb[fuGdpbNr] = mess.getGdpbTsMsbStarA(); - break; - case 1: - fhTokenMsgType[fuGdpbNr]->Fill(1); - fulGdpbTsLsb[fuGdpbNr] = mess.getGdpbTsLsbStarB(); - fulStarTsMsb[fuGdpbNr] = mess.getStarTsMsbStarB(); - break; - case 2: - fhTokenMsgType[fuGdpbNr]->Fill(2); - fulStarTsMid[fuGdpbNr] = mess.getStarTsMidStarC(); - break; - case 3: - { - fhTokenMsgType[fuGdpbNr]->Fill(3); - - ULong64_t ulNewGdpbTsFull = ( fulGdpbTsMsb[fuGdpbNr] << 24 ) - + ( fulGdpbTsLsb[fuGdpbNr] ); - ULong64_t ulNewStarTsFull = ( fulStarTsMsb[fuGdpbNr] << 48 ) - + ( fulStarTsMid[fuGdpbNr] << 8 ) - + mess.getStarTsLsbStarD(); - UInt_t uNewToken = mess.getStarTokenStarD(); - UInt_t uNewDaqCmd = mess.getStarDaqCmdStarD(); - UInt_t uNewTrigCmd = mess.getStarTrigCmdStarD(); - -/* - UInt_t uNewTrigWord = ( (uNewTrigCmd & 0x00F) << 16 ) - + ( (uNewDaqCmd & 0x00F) << 12 ) - + ( (uNewToken & 0xFFF) ); - LOG(info) << "New STAR trigger " - << " TS " << fulCurrentTsIndex - << " gDBB #" << fuGdpbNr << " " - << Form("token = %5u ", uNewToken ) - << Form("gDPB ts = %12llu ", ulNewGdpbTsFull ) - << Form("STAR ts = %12llu ", ulNewStarTsFull ) - << Form("DAQ cmd = %2u ", uNewDaqCmd ) - << Form("TRG cmd = %2u ", uNewTrigCmd ) - << Form("TRG Wrd = %5x ", uNewTrigWord ); -*/ - - if( ( uNewToken == fuStarTokenLast[fuGdpbNr] ) && ( ulNewGdpbTsFull == fulGdpbTsFullLast[fuGdpbNr] ) && - ( ulNewStarTsFull == fulStarTsFullLast[fuGdpbNr] ) && ( uNewDaqCmd == fuStarDaqCmdLast[fuGdpbNr] ) && - ( uNewTrigCmd == fuStarTrigCmdLast[fuGdpbNr] ) ) - { - UInt_t uTrigWord = ( (fuStarTrigCmdLast[fuGdpbNr] & 0x00F) << 16 ) - + ( (fuStarDaqCmdLast[fuGdpbNr] & 0x00F) << 12 ) - + ( (fuStarTokenLast[fuGdpbNr] & 0xFFF) ); - LOG(warning) << "Possible error: identical STAR tokens found twice in a row => ignore 2nd! " - << " TS " << fulCurrentTsIndex - << " gDBB #" << fuGdpbNr << " " - << Form("token = %5u ", fuStarTokenLast[fuGdpbNr] ) - << Form("gDPB ts = %12llu ", fulGdpbTsFullLast[fuGdpbNr] ) - << Form("STAR ts = %12llu ", fulStarTsFullLast[fuGdpbNr] ) - << Form("DAQ cmd = %2u ", fuStarDaqCmdLast[fuGdpbNr] ) - << Form("TRG cmd = %2u ", fuStarTrigCmdLast[fuGdpbNr] ) - << Form("TRG Wrd = %5x ", uTrigWord ); - return; - } // if exactly same message repeated -/* - if( (uNewToken != fuStarTokenLast[fuGdpbNr] + 1) && - 0 < fulGdpbTsFullLast[fuGdpbNr] && 0 < fulStarTsFullLast[fuGdpbNr] && - ( 4095 != fuStarTokenLast[fuGdpbNr] || 1 != uNewToken) ) - LOG(warning) << "Possible error: STAR token did not increase by exactly 1! " - << " gDBB #" << fuGdpbNr << " " - << Form("old = %5u vs new = %5u ", fuStarTokenLast[fuGdpbNr], uNewToken) - << Form("old = %12llu vs new = %12llu ", fulGdpbTsFullLast[fuGdpbNr], ulNewGdpbTsFull) - << Form("old = %12llu vs new = %12llu ", fulStarTsFullLast[fuGdpbNr], ulNewStarTsFull) - << Form("old = %2u vs new = %2u ", fuStarDaqCmdLast[fuGdpbNr], uNewDaqCmd) - << Form("old = %2u vs new = %2u ", fuStarTrigCmdLast[fuGdpbNr], uNewTrigCmd); -*/ - // GDPB TS counter reset detection - if( ulNewGdpbTsFull < fulGdpbTsFullLast[fuGdpbNr] ) - LOG(debug) << "Probable reset of the GDPB TS: old = " << Form("%16llu", fulGdpbTsFullLast[fuGdpbNr]) - << " new = " << Form("%16llu", ulNewGdpbTsFull) - << " Diff = -" << Form("%8llu", fulGdpbTsFullLast[fuGdpbNr] - ulNewGdpbTsFull) - << " GDPB #" << Form( "%2u", fuGdpbNr); - - // STAR TS counter reset detection - if( ulNewStarTsFull < fulStarTsFullLast[fuGdpbNr] ) - LOG(debug) << "Probable reset of the STAR TS: old = " << Form("%16llu", fulStarTsFullLast[fuGdpbNr]) - << " new = " << Form("%16llu", ulNewStarTsFull) - << " Diff = -" << Form("%8llu", fulStarTsFullLast[fuGdpbNr] - ulNewStarTsFull) - << " GDPB #" << Form( "%2u", fuGdpbNr); - -/* - LOG(info) << "Updating trigger token for " << fuGdpbNr - << " " << fuStarTokenLast[fuGdpbNr] << " " << uNewToken; -*/ -// ULong64_t ulGdpbTsDiff = ulNewGdpbTsFull - fulGdpbTsFullLast[fuGdpbNr]; - fulGdpbTsFullLast[fuGdpbNr] = ulNewGdpbTsFull; - fulStarTsFullLast[fuGdpbNr] = ulNewStarTsFull; - fuStarTokenLast[fuGdpbNr] = uNewToken; - fuStarDaqCmdLast[fuGdpbNr] = uNewDaqCmd; - fuStarTrigCmdLast[fuGdpbNr] = uNewTrigCmd; - - /// Histograms filling only in core MS - if( fuCurrentMs < fuCoreMs ) - { - /// In Run rate evolution - if( 0 <= fdStartTime ) - { - /// Reset the evolution Histogram and the start time when we reach the end of the range - if( fuHistoryHistoSize < 1e-9 * (fulGdpbTsFullLast[fuGdpbNr] * get4v2x::kdClockCycleSizeNs - fdStartTime) ) - { - ResetEvolutionHistograms(); - fdStartTime = fulGdpbTsFullLast[fuGdpbNr] * get4v2x::kdClockCycleSizeNs; - } // if( fuHistoryHistoSize < 1e-9 * (fulGdpbTsFullLast * get4v2x::kdClockCycleSizeNs - fdStartTime) ) - - fhTriggerRate[fuGdpbNr]->Fill( 1e-9 * ( fulGdpbTsFullLast[fuGdpbNr] * get4v2x::kdClockCycleSizeNs - fdStartTime ) ); - fhStarTokenEvo[fuGdpbNr]->Fill( 1e-9 * ( fulGdpbTsFullLast[fuGdpbNr] * get4v2x::kdClockCycleSizeNs - fdStartTime ), - fuStarTokenLast[fuGdpbNr] ); - fhStarTrigGdpbTsEvo[fuGdpbNr]->Fill( 1e-9 * ( fulGdpbTsFullLast[fuGdpbNr] * get4v2x::kdClockCycleSizeNs - fdStartTime ), - fulGdpbTsFullLast[fuGdpbNr] ); - fhStarTrigStarTsEvo[fuGdpbNr]->Fill( 1e-9 * ( fulGdpbTsFullLast[fuGdpbNr] * get4v2x::kdClockCycleSizeNs - fdStartTime ), - fulStarTsFullLast[fuGdpbNr] ); - } // if( 0 < fdStartTime ) - else fdStartTime = fulGdpbTsFullLast[fuGdpbNr] * get4v2x::kdClockCycleSizeNs; - - /// In Run rate long evolution - if( 0 <= fdStartTimeLong ) - { - /// Reset the evolution Histogram and the start time when we reach the end of the range - if( fuHistoryHistoSize < 1e-9 * (fulGdpbTsFullLast[fuGdpbNr] * get4v2x::kdClockCycleSizeNs - fdStartTime) / 60.0 ) - { - ResetLongEvolutionHistograms(); - fdStartTimeLong = fulGdpbTsFullLast[fuGdpbNr] * get4v2x::kdClockCycleSizeNs; - } // if( fuHistoryHistoSize < 1e-9 * (fulGdpbTsFullLast * get4v2x::kdClockCycleSizeNs - fdStartTime) / 60.0 ) - fhTriggerRateLong[fuGdpbNr]->Fill( 1e-9 * ( fulGdpbTsFullLast[fuGdpbNr] * get4v2x::kdClockCycleSizeNs - fdStartTimeLong ) / 60.0, - 1 / 60.0 ); - } // if( 0 < fdStartTimeLong ) - else fdStartTimeLong = fulGdpbTsFullLast[fuGdpbNr] * get4v2x::kdClockCycleSizeNs; - - fhCmdDaqVsTrig[fuGdpbNr]->Fill( fuStarDaqCmdLast[fuGdpbNr], fuStarTrigCmdLast[fuGdpbNr] ); - } // if( fuCurrentMs < fuCoreMs ) - - /// Generate Trigger object and store it for event building /// - CbmTofStarTrigger2018 newTrig( fulGdpbTsFullLast[fuGdpbNr], fulStarTsFullLast[fuGdpbNr], fuStarTokenLast[fuGdpbNr], - fuStarDaqCmdLast[fuGdpbNr], fuStarTrigCmdLast[fuGdpbNr] ); - if( kTRUE == fbEventBuilding ) - { - if( fuCurrentMs < fuCoreMs ) - fvtTsLinksBuffer[fuGdpbNr].push_back( newTrig ); - else fvtTsOverLinksBuffer[fuGdpbNr].push_back( newTrig ); - } // if( kTRUE == fbEventBuilding ) - else - fvtCurrentLinkBuffer.push_back( newTrig ); - ///---------------------------------------------------------/// - break; - } // case 3 - default: - LOG(error) << "Unknown Star Trigger messageindex: " << iMsgIndex; - } // switch( iMsgIndex ) -} - -void CbmTofStarEventBuilder2018::Reset() -{ -} - -void CbmTofStarEventBuilder2018::FillOutput(boost::any) -{ -} - -void CbmTofStarEventBuilder2018::Finish() -{ - TString message_type; - - for( UInt_t uType = 0; uType < fMsgCounter.size(); ++uType) - { - switch(uType) - { - case 0: message_type ="NOP"; break; - case 1: message_type ="HIT"; break; - case 2: message_type ="EPOCH"; break; - case 3: message_type ="SYNC"; break; - case 4: message_type ="AUX"; break; - case 5: message_type ="EPOCH2"; break; - case 6: message_type ="GET4"; break; - case 7: message_type ="SYS"; break; - case 8: message_type ="GET4_SLC"; break; - case 9: message_type ="GET4_32B"; break; - case 10: message_type ="GET4_SYS"; break; - default: message_type ="UNKNOWN"; break; - } // switch(uType) - LOG(info) << message_type << " messages: " - << fMsgCounter[uType]; - } // for( UInt_t uType = 0; uType < fMsgCounter.size(); ++uType) - - LOG(info) << "-------------------------------------"; - for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb ) - for( UInt_t uGet4 = 0; uGet4 < fuNrOfGet4PerGdpb; ++uGet4 ) - LOG(info) << "Last epoch for gDPB: "<< std::setw(4) << uGdpb - << " , GET4 " << std::setw(4) << uGet4 - << " => " << fvulCurrentEpoch[GetArrayIndex(uGdpb, uGet4)]; - LOG(info) << "-------------------------------------"; - - if( NULL != fpBinDumpFile ) - { - LOG(info) << "Closing binary file used for event dump."; - fpBinDumpFile->close(); - } // if( NULL != fpBinDumpFile ) - - SaveAllHistos(); - -} - -void CbmTofStarEventBuilder2018::SaveAllHistos( TString sFileName ) -{ - TDirectory * oldDir = NULL; - TFile * histoFile = NULL; - if( "" != sFileName ) - { - // Store current directory position to allow restore later - oldDir = gDirectory; - // open separate histo file in recreate mode - histoFile = new TFile( sFileName , "RECREATE"); - histoFile->cd(); - } // if( "" != sFileName ) - - gDirectory->mkdir("Tof_Raw_gDPB"); - gDirectory->cd("Tof_Raw_gDPB"); - for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; uGdpb ++) - { - /// Token detection - fhTokenMsgType[ uGdpb ]->Write(); - fhTriggerRate[ uGdpb ]->Write(); - fhTriggerRateLong[ uGdpb ]->Write(); - fhCmdDaqVsTrig[ uGdpb ]->Write(); - fhStarTokenEvo[ uGdpb ]->Write(); - fhStarTrigGdpbTsEvo[ uGdpb ]->Write(); - fhStarTrigStarTsEvo[ uGdpb ]->Write(); - - /// Event building - fhStarHitToTrigAll_gDPB[ uGdpb ]->Write(); - fhStarHitToTrigWin_gDPB[ uGdpb ]->Write(); - fhStarHitToTrigAllTime_gDPB[ uGdpb ]->Write(); - fhStarHitToTrigWinTime_gDPB[ uGdpb ]->Write(); - fhStarHitToTrigAllTimeLong_gDPB[ uGdpb ]->Write(); - fhStarHitToTrigWinTimeLong_gDPB[ uGdpb ]->Write(); - - if( kFALSE == fbEventBuilding ) - { - fhStarEventSize_gDPB[ uGdpb ]->Write(); - fhStarEventSizeTime_gDPB[ uGdpb ]->Write(); - fhStarEventSizeTimeLong_gDPB[ uGdpb ]->Write(); - } // if( kFALSE == fbEventBuilding ) - else fhStarTrigTimeToMeanTrig_gDPB[ uGdpb ]->Write(); - } // for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; uGdpb ++) - - if( kTRUE == fbEventBuilding ) - { - fhStarEventSize->Write(); - fhStarEventSizeTime->Write(); - fhStarEventSizeTimeLong->Write(); - } // if( kTRUE == fbEventBuilding ) - - fhStarTsProcessTime->Write(); - fhStarTsProcessTimeShort->Write(); - fhStarTsInterprocessTime->Write(); - gDirectory->cd(".."); - - // Plots monitoring the TS losses - gDirectory->mkdir("Flib_Raw"); - gDirectory->cd("Flib_Raw"); - TH1 * pMissedTsH1 = dynamic_cast< TH1 * >( gROOT->FindObjectAny( "Missed_TS" ) ); - if( NULL != pMissedTsH1 ) - pMissedTsH1->Write(); - - TProfile * pMissedTsEvoP = dynamic_cast< TProfile * >( gROOT->FindObjectAny( "Missed_TS_Evo" ) ); - if( NULL != pMissedTsEvoP ) - pMissedTsEvoP->Write(); - gDirectory->cd(".."); - - if( "" != sFileName ) - { - // Restore original directory position - histoFile->Close(); - oldDir->cd(); - } // if( "" != sFileName ) - if( "" != sFileName ) - { - // Restore original directory position - histoFile->Close(); - oldDir->cd(); - } // if( "" != sFileName ) - -} - -void CbmTofStarEventBuilder2018::ResetAllHistos() -{ - LOG(info) << "Reseting all Event building histograms."; - - for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; uGdpb ++) - { - /// Token detection - fhTokenMsgType[ uGdpb ]->Reset(); - fhTriggerRate[ uGdpb ]->Reset(); - fhTriggerRateLong[ uGdpb ]->Reset(); - fhCmdDaqVsTrig[ uGdpb ]->Reset(); - fhStarTokenEvo[ uGdpb ]->Reset(); - fhStarTrigGdpbTsEvo[ uGdpb ]->Reset(); - fhStarTrigStarTsEvo[ uGdpb ]->Reset(); - - /// Event building - fhStarHitToTrigAll_gDPB[ uGdpb ]->Reset(); - fhStarHitToTrigWin_gDPB[ uGdpb ]->Reset(); - fhStarHitToTrigAllTime_gDPB[ uGdpb ]->Reset(); - fhStarHitToTrigWinTime_gDPB[ uGdpb ]->Reset(); - fhStarHitToTrigAllTimeLong_gDPB[ uGdpb ]->Reset(); - fhStarHitToTrigWinTimeLong_gDPB[ uGdpb ]->Reset(); - - if( kFALSE == fbEventBuilding ) - { - fhStarEventSize_gDPB[ uGdpb ]->Reset(); - fhStarEventSizeTime_gDPB[ uGdpb ]->Reset(); - fhStarEventSizeTimeLong_gDPB[ uGdpb ]->Reset(); - } // if( kFALSE == fbEventBuilding ) - else fhStarTrigTimeToMeanTrig_gDPB[ uGdpb ]->Reset(); - } // for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; uGdpb ++) - - if( kTRUE == fbEventBuilding ) - { - fhStarEventSize->Reset(); - fhStarEventSizeTime->Reset(); - fhStarEventSizeTimeLong->Reset(); - } // if( kTRUE == fbEventBuilding ) - fhStarTsProcessTime->Reset(); - fhStarTsProcessTimeShort->Reset(); - fhStarTsInterprocessTime->Reset(); - - fdStartTime = -1; - fdStartTimeLong = -1; - fdStartTimeMsSz = -1; -} -void CbmTofStarEventBuilder2018::ResetEvolutionHistograms() -{ - for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb ) - { - fhTriggerRate[ uGdpb ]->Reset(); - fhStarTokenEvo[ uGdpb ]->Reset(); - fhStarTrigGdpbTsEvo[ uGdpb ]->Reset(); - fhStarTrigStarTsEvo[ uGdpb ]->Reset(); - - /// Event building - fhStarHitToTrigAllTime_gDPB[ uGdpb ]->Reset(); - fhStarHitToTrigWinTime_gDPB[ uGdpb ]->Reset(); - - if( kFALSE == fbEventBuilding ) - { - fhStarEventSizeTime_gDPB[ uGdpb ]->Reset(); - } // if( kFALSE == fbEventBuilding ) - } // for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb ) - - if( kTRUE == fbEventBuilding ) - { - fhStarEventSizeTime->Reset(); - } // if( kTRUE == fbEventBuilding ) - - fdStartTime = -1; -} -void CbmTofStarEventBuilder2018::ResetLongEvolutionHistograms() -{ - for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb ) - { - fhTriggerRate[ uGdpb ]->Reset(); - - /// Event building - fhStarHitToTrigAllTimeLong_gDPB[ uGdpb ]->Reset(); - fhStarHitToTrigWinTimeLong_gDPB[ uGdpb ]->Reset(); - } // for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb ) - - if( kFALSE == fbEventBuilding ) - { - for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; uGdpb ++) - { - fhStarEventSizeTimeLong_gDPB[ uGdpb ]->Reset(); - } // for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; uGdpb ++) - } // if( kFALSE == fbEventBuilding ) - else - { - fhStarEventSizeTimeLong->Reset(); - } // else of if( kFALSE == fbEventBuilding ) - fdStartTimeLong = -1; -} - -void CbmTofStarEventBuilder2018::BuildStarEventsSingleLink() -{ - /// Time sort the message buffer - /// TODO: Check if using an epoch buffer per gDPB similar to the epoch suppression one does not make - /// a more efficient sorting (max disorder is within the epoch!) - /// Data are sorted between epochs, not inside => Epoch level ordering - /// Sorting at lower bin precision level - std::stable_sort( fvmCurrentLinkBuffer.begin(), fvmCurrentLinkBuffer.begin() ); - - std::vector< gdpb::FullMessage >::iterator itFirstMessageNextEvent = fvmCurrentLinkBuffer.begin(); - Double_t dPrevEventEnd = 0.0; - - for( UInt_t uTriggIdx = 0; uTriggIdx < fvtCurrentLinkBuffer.size(); uTriggIdx++ ) - { - Double_t dTriggerTime = get4v2x::kdClockCycleSizeNs * fvtCurrentLinkBuffer[uTriggIdx].GetFullGdpbTs(); - Double_t dTriggerWinBeg = dTriggerTime - fdStarTriggerDelay[ fuGdpbNr ]; - Double_t dTriggerWinEnd = dTriggerTime - fdStarTriggerDelay[ fuGdpbNr ] + fdStarTriggerWinSize[ fuGdpbNr ]; - Double_t dClosestTriggerWinStart = dTriggerTime - fdStarTriggerDelay[ fuGdpbNr ] + fdStarTriggerDeadtime[ fuGdpbNr ]; - Bool_t bFirstMessClosestEventFound = kFALSE; - - /// Associate this trigger to its subevent - fStarSubEvent.SetTrigger( fvtCurrentLinkBuffer[uTriggIdx] ); - /// Set the source index of the subevent - fStarSubEvent.SetSource( fuGdpbNr ); - - /// Check if this trigger may correspond to an event with data in previous MS - if( dTriggerWinBeg < fdCurrentMsStartTime ) - fStarSubEvent.SetStartBorderEventFlag(); - - /// Check if this trigger may correspond to an event with data in next MS - if( fdCurrentMsEndTime < dTriggerWinEnd ) - fStarSubEvent.SetEndBorderEventFlag(); - - /// Check if this trigger leads to an event overlapping with the previous one - if( 0 < dPrevEventEnd && dTriggerWinBeg < dPrevEventEnd ) - fStarSubEvent.SetOverlapEventFlag(); - - for( std::vector< gdpb::FullMessage >::iterator itMess = itFirstMessageNextEvent; - itMess != fvmCurrentLinkBuffer.end(); - ++ itMess ) - { - Double_t dMessageFullTime = (*itMess).GetFullTimeNs(); - if( kFALSE == bFirstMessClosestEventFound && - dClosestTriggerWinStart < dMessageFullTime ) - { - itFirstMessageNextEvent = itMess; - bFirstMessClosestEventFound = kTRUE; - } // If first possible hit of closest event not found and current hit fits - - /// Plotting of time to trigger for all hits - Double_t dTimeToTrigg = dMessageFullTime - dTriggerTime; - fhStarHitToTrigAll_gDPB[ fuGdpbNr ]->Fill( dTimeToTrigg ); - fhStarHitToTrigAllTime_gDPB[ fuGdpbNr ]->Fill( 1e-9 *(dTriggerTime - fdStartTime), dTimeToTrigg ); - fhStarHitToTrigAllTimeLong_gDPB[ fuGdpbNr ]->Fill( 1e-9 *(dTriggerTime - fdStartTimeLong) / 60.0, dTimeToTrigg ); - - if( dTriggerWinBeg <= dMessageFullTime && dMessageFullTime <= dTriggerWinEnd ) - { - /// Message belongs to this event - fStarSubEvent.AddMsg( (*itMess) ); - - /// Plotting of time to trigger for hits within the event window - fhStarHitToTrigWin_gDPB[ fuGdpbNr ]->Fill( dTimeToTrigg ); - fhStarHitToTrigWinTime_gDPB[ fuGdpbNr ]->Fill( 1e-9 *(dTriggerTime - fdStartTime), dTimeToTrigg ); - fhStarHitToTrigWinTimeLong_gDPB[ fuGdpbNr ]->Fill( 1e-9 *(dTriggerTime - fdStartTimeLong) / 60.0, dTimeToTrigg ); - } // if( dTriggerWinBeg <= dMessageFullTime && dMessageFullTime <= dTriggerWinEnd ) - else if( dTriggerWinEnd < dMessageFullTime ) - /// First Message out of the window for this event => Stop there and go to the next - break; - } // Loop on message from first allowed by last event + deadtime to end - - /** TODO: clarify how we deal with multiple sub-events (eg one for each gDPB) **/ - /// Send the sub-event to the STAR systems - Int_t iBuffSzByte = 0; - void * pDataBuff = fStarSubEvent.BuildOutput( iBuffSzByte ); - if( NULL != pDataBuff ) - { - /// Valid output, do stuff with it! - fulNbBuiltSubEvent++; - -#ifdef STAR_SUBEVT_BUILDER - /* - ** Function to send sub-event block to the STAR DAQ system - * trg_word received is packed as: - * - * trg_cmd|daq_cmd|tkn_hi|tkn_mid|tkn_lo - */ - star_rhicf_write( fStarSubEvent.GetTrigger().GetStarTrigerWord(), - pDataBuff, iBuffSzByte ); - fulNbStarSubEvent++; -/* - LOG(info) << "Sent STAR event with size " << iBuffSzByte << " Bytes" - << " and token " << fStarSubEvent.GetTrigger().GetStarToken(); -*/ -#endif // STAR_SUBEVT_BUILDER - - if( kTRUE == fbEventDumpEna ) - { - fpBinDumpFile->write( reinterpret_cast< const char * >( &kuBinDumpBegWord ), sizeof( UInt_t ) ); - fpBinDumpFile->write( reinterpret_cast< const char * >( &iBuffSzByte ), sizeof( Int_t ) ); - fpBinDumpFile->write( reinterpret_cast< const char * >( pDataBuff ), iBuffSzByte ); - fpBinDumpFile->write( reinterpret_cast< const char * >( &kuBinDumpEndWord ), sizeof( UInt_t ) ); - } // if( kTRUE == fbEventDumpEna ) - } // if( NULL != pDataBuff ) - else LOG(error) << "Invalid STAR SubEvent Output, can only happen if trigger " - << " object was not set => Do Nothing more with it!!! "; - - /// Fill plot of event size - fhStarEventSize_gDPB[ fuGdpbNr ]->Fill( iBuffSzByte ); - /// Fill plot of event size as function of trigger time - if( 0 < fdStartTime ) - fhStarEventSizeTime_gDPB[ fuGdpbNr ]->Fill( 1e-9 *(dTriggerTime - fdStartTime), iBuffSzByte ); - if( 0 < fdStartTimeLong ) - fhStarEventSizeTimeLong_gDPB[ fuGdpbNr ]->Fill( 1e-9 *(dTriggerTime - fdStartTimeLong) / 60.0, iBuffSzByte ); - - /// Now clear the sub-event - fStarSubEvent.ClearSubEvent(); - } // for( UInt_t uTriggIdx = 0; uTriggIdx < fvtCurrentLinkBuffer.size(); uTriggIdx++ ) - - /// catch case of MS without triggers - if( 0 == fvtCurrentLinkBuffer.size() ) - itFirstMessageNextEvent = fvmCurrentLinkBuffer.end(); - - /// Remove message until the first which could fit in an event in next MS - fvmCurrentLinkBuffer.erase( fvmCurrentLinkBuffer.begin(), itFirstMessageNextEvent); - - /// Clear trigger buffer - fvtCurrentLinkBuffer.clear(); - -} -void CbmTofStarEventBuilder2018::BuildStarEventsAllLinks() -{ - /// TODO: - /// 1) use overlap MS to fill events where the event window would go over the lower edge of the TS - - /// First check if any trigger was present in this TS - Bool_t bEmptyTs = kTRUE; - for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; uGdpb ++) - if( 0 < fvtTsLinksBuffer[uGdpb].size() ) - { - bEmptyTs = kFALSE; - break; - } // if( 0 < fvtTsLinksBuffer[0].size() ) - if( kTRUE == bEmptyTs ) - { - for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; uGdpb ++) - { - fvmTsLinksBuffer[uGdpb].clear(); - fvmTsOverLinksBuffer[uGdpb].clear(); - fvtTsOverLinksBuffer[uGdpb].clear(); - } // for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; uGdpb ++) - return; - } // if( kTRUE == bEmptyTS ) -/* - LOG(info) << "--------------------------------"; - LOG(info) << " TS " << fulCurrentTsIndex; - - for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; uGdpb ++) - { - for( UInt_t uTrig = 0; uTrig < fvtTsLinksBuffer[uGdpb].size(); uTrig ++) - LOG(info) << "board " << uGdpb << " Trig " << std::setw(2) << uTrig - << " TS g " << std::setw(15) << fvtTsLinksBuffer[uGdpb][uTrig].GetFullGdpbTs() - << " TS s " << std::setw(15) << fvtTsLinksBuffer[uGdpb][uTrig].GetFullStarTs() - << " Trigger " << std::hex << std::setw(5) << fvtTsLinksBuffer[uGdpb][uTrig].GetStarTrigerWord() - << std::dec; - } // for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; uGdpb ++) -*/ - - /// Time sort the message buffers - /// TODO: Check if using an epoch buffer per gDPB similar to the epoch suppression one does not make - /// a more efficient sorting (max disorder is within the epoch!) - for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; uGdpb ++) - { - /// Data are sorted between epochs, not inside => Epoch level ordering - /// Sorting at lower bin precision level - std::stable_sort( fvmTsLinksBuffer[uGdpb].begin(), fvmTsLinksBuffer[uGdpb].begin() ); - std::stable_sort( fvmTsOverLinksBuffer[uGdpb].begin(), fvmTsOverLinksBuffer[uGdpb].begin() ); - } // for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; uGdpb ++) - - /// Initialize the iterator for first possible message in event to beginning of buffer - std::vector< std::vector< gdpb::FullMessage >::iterator > itFirstMessageNextEvent( fuNrOfGdpbs ); - for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; uGdpb ++) - itFirstMessageNextEvent[ uGdpb ] = fvmTsLinksBuffer[ uGdpb ].begin(); - - /// Initialize the time of previous event end to 0 - std::vector< Double_t > dPrevEventEnd( fuNrOfGdpbs, 0.0 ); - - /// Checking whether all Trigger buffers start with the same trigger - Bool_t bFirstTriggerMatch = kTRUE; - std::vector< UInt_t > vuIndexMatchingTrigger(fuNrOfGdpbs); - if( 0 < fvtTsLinksBuffer[0].size() ) - { - vuIndexMatchingTrigger[0] = 0; -// ULong64_t ulFirstBoardFirstTriggerTime = fvtTsLinksBuffer[0][0].GetFullGdpbTs(); - UInt_t uFirstBoardFirstTriggerWord = fvtTsLinksBuffer[0][0].GetStarTrigerWord(); - - for( UInt_t uGdpb = 1; uGdpb < fuNrOfGdpbs; uGdpb ++) - { - if( 0 < fvtTsLinksBuffer[uGdpb].size() ) - { - vuIndexMatchingTrigger[uGdpb] = 0; - if( fvtTsLinksBuffer[uGdpb][0].GetStarTrigerWord() != uFirstBoardFirstTriggerWord ) - { -// LOG(warning) << "Trigger word not matching for board " << uGdpb << ": " -// << fvtTsLinksBuffer[uGdpb][0].GetStarTrigerWord() << " VS " -// << uFirstBoardFirstTriggerWord; - bFirstTriggerMatch = kFALSE; - break; - } // if( fvtTsLinksBuffer[uGdpb][0].GetStarTrigerWord() != uFirstBoardFirstTriggerWord ) - } // if( 0 < fvtTsLinksBuffer[0].size() ) - else - { -// LOG(warning) << "No trigger in board " << uGdpb; - bFirstTriggerMatch = kFALSE; - } - } // for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; uGdpb ++) - } // if( 0 < fvtTsLinksBuffer[0].size() ) - else - { -// LOG(warning) << "No trigger in first board!"; - bFirstTriggerMatch = kFALSE; - } // else of if( 0 < fvtTsLinksBuffer[0].size() ) - - if( kFALSE == bFirstTriggerMatch ) - { -// LOG(error) << "First trigger in TS not the same for all boards!"; - for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; uGdpb ++) - { -// LOG(error) << "Board: " << uGdpb -// << " has " << fvtTsLinksBuffer[uGdpb].size() -// << " triggers"; - fvtTsLinksBuffer[uGdpb].clear(); - fvmTsLinksBuffer[uGdpb].clear(); - fvmTsOverLinksBuffer[uGdpb].clear(); - fvtTsOverLinksBuffer[uGdpb].clear(); - } // for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; uGdpb ++) - return; - } // if( kFALSE == bFirstTriggerMatch ) - - /// We now have a matching trigger for starting - Bool_t bMatchingTriggerFound = kTRUE; - while( kTRUE == bMatchingTriggerFound ) - { - Double_t dMeanTriggerGdpbTs = 0; - Double_t dMeanTriggerStarTs = 0; - for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; uGdpb ++) - { - dMeanTriggerGdpbTs += get4v2x::kdClockCycleSizeNs * fvtTsLinksBuffer[uGdpb][ vuIndexMatchingTrigger[uGdpb] ].GetFullGdpbTs(); - dMeanTriggerStarTs += get4v2x::kdClockCycleSizeNs * fvtTsLinksBuffer[uGdpb][ vuIndexMatchingTrigger[uGdpb] ].GetFullStarTs(); - - /// Recreate the corresponding messages and insert them into the event bufffer - std::vector< gdpb::FullMessage > vTrigMess = fvtTsLinksBuffer[uGdpb][ vuIndexMatchingTrigger[uGdpb] ].GetGdpbMessages( fUnpackPar->GetRocId( uGdpb ) ); - for( std::vector< gdpb::FullMessage >::iterator itMess = vTrigMess.begin(); itMess != vTrigMess.end(); ++ itMess ) - { - fStarSubEvent.AddMsg( (*itMess) ); -// std::cout << Form( "Event %6llu Trigger message for gDPB %02u is %016lx ", fulNbBuiltSubEvent, uGdpb, (*itMess).getData() ) << std::endl; - } // for( std::vector< gdpb::FullMessage >::iterator itMess = vTrigMess.begin(); itMess != vTrigMess.end(); ++ itMess ) -/* - ULong64_t testulGdpbTsMsb = vTrigMess[0].getGdpbTsMsbStarA(); - ULong64_t testulGdpbTsLsb = vTrigMess[1].getGdpbTsLsbStarB(); - ULong64_t testulStarTsMsb = vTrigMess[1].getStarTsMsbStarB(); - ULong64_t testulStarTsMid = vTrigMess[2].getStarTsMidStarC(); - ULong64_t ulNewGdpbTsFull = ( testulGdpbTsMsb << 24 ) - + ( testulGdpbTsLsb ); - ULong64_t ulNewStarTsFull = ( testulStarTsMsb << 48 ) - + ( testulStarTsMid << 8 ) - + vTrigMess[3].getStarTsLsbStarD(); - UInt_t uNewToken = vTrigMess[3].getStarTokenStarD(); - UInt_t uNewDaqCmd = vTrigMess[3].getStarDaqCmdStarD(); - UInt_t uNewTrigCmd = vTrigMess[3].getStarTrigCmdStarD(); - - std::cout << Form( "Event %6llu Trigger message for gDPB %02u check: %1u %1u %1u %1u %1u ", fulNbBuiltSubEvent, uGdpb, - ulNewGdpbTsFull == fvtTsLinksBuffer[uGdpb][ vuIndexMatchingTrigger[uGdpb] ].GetFullGdpbTs(), - ulNewStarTsFull == fvtTsLinksBuffer[uGdpb][ vuIndexMatchingTrigger[uGdpb] ].GetFullStarTs(), - uNewToken == fvtTsLinksBuffer[uGdpb][ vuIndexMatchingTrigger[uGdpb] ].GetStarToken(), - uNewDaqCmd == fvtTsLinksBuffer[uGdpb][ vuIndexMatchingTrigger[uGdpb] ].GetStarDaqCmd(), - uNewTrigCmd == fvtTsLinksBuffer[uGdpb][ vuIndexMatchingTrigger[uGdpb] ].GetStarTrigCmd() ) - << std::endl; -*/ - } // for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; uGdpb ++) - dMeanTriggerGdpbTs /= fuNrOfGdpbs; - dMeanTriggerStarTs /= fuNrOfGdpbs; - Double_t dMeanTriggTimeToStartSec = 1e-9 *(dMeanTriggerGdpbTs - fdStartTime); - Double_t dMeanTriggTimeToStartLongSec = 1e-9 *(dMeanTriggerGdpbTs - fdStartTimeLong) / 60.0; - - for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; uGdpb ++) - fhStarTrigTimeToMeanTrig_gDPB[ uGdpb ]->Fill( - get4v2x::kdClockCycleSizeNs * fvtTsLinksBuffer[uGdpb][ vuIndexMatchingTrigger[uGdpb] ].GetFullGdpbTs() - - dMeanTriggerGdpbTs ); - - CbmTofStarTrigger2018 meanTrigger( static_cast< ULong64_t >( dMeanTriggerGdpbTs ), static_cast< ULong64_t >( dMeanTriggerStarTs ), - fvtTsLinksBuffer[0][ vuIndexMatchingTrigger[0] ].GetStarToken(), - fvtTsLinksBuffer[0][ vuIndexMatchingTrigger[0] ].GetStarDaqCmd(), - fvtTsLinksBuffer[0][ vuIndexMatchingTrigger[0] ].GetStarTrigCmd() ); - - /// Associate this trigger to its subevent - fStarSubEvent.SetTrigger( meanTrigger ); - /// Set the source index of the subevent - fStarSubEvent.SetSource( 16 ); - - for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; uGdpb ++) - { - - Double_t dTriggerTime = get4v2x::kdClockCycleSizeNs * fvtTsLinksBuffer[uGdpb][ vuIndexMatchingTrigger[uGdpb] ].GetFullGdpbTs(); - Double_t dTriggerWinBeg = dTriggerTime - fdStarTriggerDelay[ uGdpb ]; - Double_t dTriggerWinEnd = dTriggerTime - fdStarTriggerDelay[ uGdpb ] + fdStarTriggerWinSize[ uGdpb ]; - Double_t dClosestTriggerWinStart = dTriggerTime - fdStarTriggerDelay[ uGdpb ] + fdStarTriggerDeadtime[ uGdpb ]; - Bool_t bFirstMessClosestEventFound = kFALSE; - - /// Check if this trigger may correspond to an event with data in previous TS - if( dTriggerWinBeg < fdCurrentTsStartTime ) - fStarSubEvent.SetStartBorderEventFlag(); - - /// Check if this trigger may correspond to an event with data in next TS - if( fdCurrentTsCoreEndTime < dTriggerWinEnd ) - fStarSubEvent.SetEndBorderEventFlag(); - - /// Check if this trigger leads to an event overlapping with the previous one - if( 0 < dPrevEventEnd[ uGdpb ] && dTriggerWinBeg < dPrevEventEnd[ uGdpb ] ) - fStarSubEvent.SetOverlapEventFlag(); - - for( std::vector< gdpb::FullMessage >::iterator itMess = itFirstMessageNextEvent[ uGdpb ]; - itMess != fvmTsLinksBuffer[ uGdpb ].end(); - ++ itMess ) - { - Double_t dMessageFullTime = (*itMess).GetFullTimeNs(); - if( kFALSE == bFirstMessClosestEventFound && - dClosestTriggerWinStart < dMessageFullTime ) - { - itFirstMessageNextEvent[ uGdpb ] = itMess; - bFirstMessClosestEventFound = kTRUE; - } // If first possible hit of closest event not found and current hit fits - - /// Plotting of time to trigger for all hits - Double_t dTimeToTrigg = dMessageFullTime - dTriggerTime; - fhStarHitToTrigAll_gDPB[ uGdpb ]->Fill( dTimeToTrigg ); - fhStarHitToTrigAllTime_gDPB[ uGdpb ]->Fill( dMeanTriggTimeToStartSec, dTimeToTrigg ); - fhStarHitToTrigAllTimeLong_gDPB[ uGdpb ]->Fill( dMeanTriggTimeToStartLongSec, dTimeToTrigg ); - - if( dTriggerWinBeg <= dMessageFullTime && dMessageFullTime <= dTriggerWinEnd ) - { - /// Message belongs to this event - fStarSubEvent.AddMsg( (*itMess) ); - - /// Plotting of time to trigger for hits within the event window - fhStarHitToTrigWin_gDPB[ uGdpb ]->Fill( dTimeToTrigg ); - fhStarHitToTrigWinTime_gDPB[ uGdpb ]->Fill( dMeanTriggTimeToStartSec, dTimeToTrigg ); - fhStarHitToTrigWinTimeLong_gDPB[ uGdpb ]->Fill( dMeanTriggTimeToStartLongSec, dTimeToTrigg ); - } // if( dTriggerWinBeg <= dMessageFullTime && dMessageFullTime <= dTriggerWinEnd ) - else if( dTriggerWinEnd < dMessageFullTime ) - /// First Message out of the window for this event => Stop there and go to the next - break; - } // Loop on message from first allowed by last event + deadtime to end - } // for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; uGdpb ++) - - /// Time sort the sub-event if required by the user - if( kTRUE == fbTimeSortOutput ) - fStarSubEvent.SortMessages( ); - - /// Send the sub-event to the STAR systems - Int_t iBuffSzByte = 0; - void * pDataBuff = fStarSubEvent.BuildOutput( iBuffSzByte ); - if( NULL != pDataBuff ) - { - /// Valid output, do stuff with it! - fulNbBuiltSubEvent++; - -#ifdef STAR_SUBEVT_BUILDER - /* - ** Function to send sub-event block to the STAR DAQ system - * trg_word received is packed as: - * - * trg_cmd|daq_cmd|tkn_hi|tkn_mid|tkn_lo - */ - star_rhicf_write( fStarSubEvent.GetTrigger().GetStarTrigerWord(), - pDataBuff, iBuffSzByte ); - fulNbStarSubEvent++; -/* - LOG(info) << "Sent STAR event with size " << iBuffSzByte << " Bytes" - << " and token " << fStarSubEvent.GetTrigger().GetStarToken(); -*/ -#endif // STAR_SUBEVT_BUILDER - - if( kTRUE == fbEventDumpEna ) - { - fpBinDumpFile->write( reinterpret_cast< const char * >( &kuBinDumpBegWord ), sizeof( UInt_t ) ); - fpBinDumpFile->write( reinterpret_cast< const char * >( &iBuffSzByte ), sizeof( Int_t ) ); - fpBinDumpFile->write( reinterpret_cast< const char * >( pDataBuff ), iBuffSzByte ); - fpBinDumpFile->write( reinterpret_cast< const char * >( &kuBinDumpEndWord ), sizeof( UInt_t ) ); - } // if( kTRUE == fbEventDumpEna ) - } // if( NULL != pDataBuff ) - else LOG(error) << "Invalid STAR SubEvent Output, can only happen if trigger " - << " object was not set => Do Nothing more with it!!! "; -/* - if( 1000 < iBuffSzByte ) - fStarSubEvent.PrintSubEvent(); -*/ - /// Fill plot of event size - fhStarEventSize->Fill( iBuffSzByte ); - /// Fill plot of event size as function of trigger time - if( 0 < fdStartTime ) - fhStarEventSizeTime->Fill( dMeanTriggTimeToStartSec, iBuffSzByte ); - if( 0 < fdStartTimeLong ) - fhStarEventSizeTimeLong->Fill( dMeanTriggTimeToStartLongSec, iBuffSzByte ); - - /// Now clear the sub-event - fStarSubEvent.ClearSubEvent(); - - /// Check if we still can find a Matching trigger - vuIndexMatchingTrigger[0] ++; - bMatchingTriggerFound = kTRUE; - if( vuIndexMatchingTrigger[0] < fvtTsLinksBuffer[0].size() ) - { -// ULong64_t ulFirstBoardNextTriggerTime = fvtTsLinksBuffer[0][ vuIndexMatchingTrigger[0] ].GetFullGdpbTs(); - UInt_t uFirstBoardNextTriggerWord = fvtTsLinksBuffer[0][ vuIndexMatchingTrigger[0] ].GetStarTrigerWord(); - for( UInt_t uGdpb = 1; uGdpb < fuNrOfGdpbs; uGdpb ++) - { - vuIndexMatchingTrigger[uGdpb] ++; - if( vuIndexMatchingTrigger[uGdpb] < fvtTsLinksBuffer[uGdpb].size() ) - { - if( fvtTsLinksBuffer[uGdpb][ vuIndexMatchingTrigger[uGdpb] ].GetStarTrigerWord() != uFirstBoardNextTriggerWord ) - { - bMatchingTriggerFound = kFALSE; - break; - } // if( fvtTsLinksBuffer[uGdpb][ vuIndexMatchingTrigger[uGdpb] ].GetStarTrigerWord() != uFirstBoardNextTriggerWord ) - } // if( vuIndexMatchingTrigger[uGdpb] < fvtTsLinksBuffer[uGdpb].size() ) - else bMatchingTriggerFound = kFALSE; - } // for( UInt_t uGdpb = 1; uGdpb < fuNrOfGdpbs; uGdpb ++) - } // if( vuIndexMatchingTrigger[0] < fvtTsLinksBuffer[0].size() ) - else - { - bMatchingTriggerFound = kFALSE; - } // else of if( 0 < fvtTsLinksBuffer[0].size() ) - - /// If no matching trigger, check if matching trigger building not possible - /// using the deadtime period of the overlap MS - if( kFALSE == bMatchingTriggerFound ) - { - /// First find out for which gDPBs the trigger is potentially in the overlap MS - std::vector< Bool_t > bTriggerInOverMs( fuNrOfGdpbs, kFALSE ); - for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; uGdpb ++) - if( fvtTsLinksBuffer[uGdpb].size() < vuIndexMatchingTrigger[uGdpb] && - 0 < fvtTsOverLinksBuffer[uGdpb].size() ) - bTriggerInOverMs[uGdpb] = kTRUE; - -// ULong64_t ulFirstBoardNextTriggerTime = 0; - UInt_t uFirstBoardNextTriggerWord = 0; - bFirstTriggerMatch = kTRUE; - if( vuIndexMatchingTrigger[0] < fvtTsLinksBuffer[0].size() ) - { -// ulFirstBoardNextTriggerTime = fvtTsLinksBuffer[0][ vuIndexMatchingTrigger[0] ].GetFullGdpbTs(); - uFirstBoardNextTriggerWord = fvtTsLinksBuffer[0][ vuIndexMatchingTrigger[0] ].GetStarTrigerWord(); - } // if( vuIndexMatchingTrigger[0] < fvtTsLinksBuffer[0].size() ) - else if( bTriggerInOverMs[0] ) - { -// ulFirstBoardNextTriggerTime = fvtTsOverLinksBuffer[0][ 0 ].GetFullGdpbTs(); - uFirstBoardNextTriggerWord = fvtTsOverLinksBuffer[0][ 0 ].GetStarTrigerWord(); - } // else if( bTriggerInOverMs[0] ) of if( vuIndexMatchingTrigger[0] < fvtTsLinksBuffer[0].size() ) - else bFirstTriggerMatch = kFALSE; - - for( UInt_t uGdpb = 1; uGdpb < fuNrOfGdpbs; uGdpb ++) - { - if( vuIndexMatchingTrigger[uGdpb] < fvtTsLinksBuffer[uGdpb].size() ) - { - /// Check if triggger words are matching - if( fvtTsLinksBuffer[uGdpb][ vuIndexMatchingTrigger[uGdpb] ].GetStarTrigerWord() != uFirstBoardNextTriggerWord ) - { - bFirstTriggerMatch = kFALSE; - break; - } // if( fvtTsLinksBuffer[uGdpb][ vuIndexMatchingTrigger[uGdpb] ].GetStarTrigerWord() != uFirstBoardNextTriggerWord ) - } // if( vuIndexMatchingTrigger[uGdpb] < fvtTsLinksBuffer[uGdpb].size() ) - else if( bTriggerInOverMs[uGdpb] ) - { - /// Check if triggger words are matching - if( fvtTsOverLinksBuffer[uGdpb][ 0 ].GetStarTrigerWord() != uFirstBoardNextTriggerWord ) - { - bFirstTriggerMatch = kFALSE; - break; - } // if( fvtTsOverLinksBuffer[uGdpb][ 0 ].GetStarTrigerWord() != uFirstBoardNextTriggerWord ) - /// Check if this trigger is still without the period declared as TS deadtime - if( fdCurrentTsCoreEndTime + fdTsDeadtimePeriod < fvtTsOverLinksBuffer[uGdpb][ 0 ].GetFullGdpbTs() ) - { - bFirstTriggerMatch = kFALSE; - break; - } // if( fdCurrentTsCoreEndTime + fdTsDeadtimePeriod < fvtTsOverLinksBuffer[uGdpb][ 0 ].GetFullGdpbTs() ) - } // else if( bTriggerInOverMs[uGdpb] ) of if( vuIndexMatchingTrigger[uGdpb] < fvtTsLinksBuffer[uGdpb].size() ) - else bFirstTriggerMatch = kFALSE; - } // for( UInt_t uGdpb = 1; uGdpb < fuNrOfGdpbs; uGdpb ++) - - if( bFirstTriggerMatch ) - { - Double_t dMeanTriggerGdpbTsOver = 0; - Double_t dMeanTriggerStarTsOver = 0; - for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; uGdpb ++) - { - if( bTriggerInOverMs[uGdpb] ) - { - dMeanTriggerGdpbTsOver += get4v2x::kdClockCycleSizeNs * fvtTsOverLinksBuffer[uGdpb][ 0 ].GetFullGdpbTs(); - dMeanTriggerStarTsOver += get4v2x::kdClockCycleSizeNs * fvtTsOverLinksBuffer[uGdpb][ 0 ].GetFullStarTs(); - - /// Recreate the corresponding messages and insert them into the event bufffer - std::vector< gdpb::FullMessage > vTrigMess = fvtTsLinksBuffer[uGdpb][ 0 ].GetGdpbMessages( fUnpackPar->GetRocId( uGdpb ) ); - for( std::vector< gdpb::FullMessage >::iterator itMess = vTrigMess.begin(); itMess != vTrigMess.end(); ++ itMess ) - { - fStarSubEvent.AddMsg( (*itMess) ); -// std::cout << Form( "Event %6llu Trigger message in Overlap for gDPB %02u is %016lx ", fulNbBuiltSubEvent, uGdpb, (*itMess).getData() ) << std::endl; - } // for( std::vector< gdpb::FullMessage >::iterator itMess = vTrigMess.begin(); itMess != vTrigMess.end(); ++ itMess ) - } // if( bTriggerInOverMs[uGdpb] ) - else - { - dMeanTriggerGdpbTsOver += get4v2x::kdClockCycleSizeNs * fvtTsLinksBuffer[uGdpb][ vuIndexMatchingTrigger[uGdpb] ].GetFullGdpbTs(); - dMeanTriggerStarTsOver += get4v2x::kdClockCycleSizeNs * fvtTsLinksBuffer[uGdpb][ vuIndexMatchingTrigger[uGdpb] ].GetFullStarTs(); - - /// Recreate the corresponding messages and insert them into the event bufffer - std::vector< gdpb::FullMessage > vTrigMess = fvtTsLinksBuffer[uGdpb][ vuIndexMatchingTrigger[uGdpb] ].GetGdpbMessages( fUnpackPar->GetRocId( uGdpb ) ); - for( std::vector< gdpb::FullMessage >::iterator itMess = vTrigMess.begin(); itMess != vTrigMess.end(); ++ itMess ) - { - fStarSubEvent.AddMsg( (*itMess) ); -// std::cout << Form( "Event %6llu Trigger message in Overlap for gDPB %02u is %016lx ", fulNbBuiltSubEvent, uGdpb, (*itMess).getData() ) << std::endl; - } // for( std::vector< gdpb::FullMessage >::iterator itMess = vTrigMess.begin(); itMess != vTrigMess.end(); ++ itMess ) - } // else of if( bTriggerInOverMs[uGdpb] ) - } // for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; uGdpb ++) - dMeanTriggerGdpbTsOver /= fuNrOfGdpbs; - dMeanTriggerStarTsOver /= fuNrOfGdpbs; - dMeanTriggTimeToStartSec = 1e-9 *(dMeanTriggerGdpbTs - fdStartTime); - dMeanTriggTimeToStartLongSec = 1e-9 *(dMeanTriggerGdpbTs - fdStartTimeLong) / 60.0; - - if( bTriggerInOverMs[0] ) - { - CbmTofStarTrigger2018 meanTriggerOver( static_cast< ULong64_t >( dMeanTriggerGdpbTsOver ), static_cast< ULong64_t >( dMeanTriggerStarTsOver ), - fvtTsOverLinksBuffer[0][ 0 ].GetStarToken(), - fvtTsOverLinksBuffer[0][ 0 ].GetStarDaqCmd(), - fvtTsOverLinksBuffer[0][ 0 ].GetStarTrigCmd() ); - - /// Associate this trigger to its subevent - fStarSubEvent.SetTrigger( meanTriggerOver ); - } // if( bTriggerInOverMs[0] ) - else - { - CbmTofStarTrigger2018 meanTriggerOver( static_cast< ULong64_t >( dMeanTriggerGdpbTsOver ), static_cast< ULong64_t >( dMeanTriggerStarTsOver ), - fvtTsLinksBuffer[0][ vuIndexMatchingTrigger[0] ].GetStarToken(), - fvtTsLinksBuffer[0][ vuIndexMatchingTrigger[0] ].GetStarDaqCmd(), - fvtTsLinksBuffer[0][ vuIndexMatchingTrigger[0] ].GetStarTrigCmd() ); - - /// Associate this trigger to its subevent - fStarSubEvent.SetTrigger( meanTriggerOver ); - } // else of if( bTriggerInOverMs[0] ) - /// Set the source index of the subevent - fStarSubEvent.SetSource( 16 ); - - for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; uGdpb ++) - if( bTriggerInOverMs[uGdpb] ) - fhStarTrigTimeToMeanTrig_gDPB[ uGdpb ]->Fill( - get4v2x::kdClockCycleSizeNs * fvtTsOverLinksBuffer[uGdpb][ 0 ].GetFullGdpbTs() - - dMeanTriggerGdpbTs ); - else fhStarTrigTimeToMeanTrig_gDPB[ uGdpb ]->Fill( - get4v2x::kdClockCycleSizeNs * fvtTsLinksBuffer[uGdpb][ vuIndexMatchingTrigger[uGdpb] ].GetFullGdpbTs() - - dMeanTriggerGdpbTs ); - - for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; uGdpb ++) - { - Double_t dTriggerTime = 0.0; - if( bTriggerInOverMs[uGdpb] ) - dTriggerTime = get4v2x::kdClockCycleSizeNs * fvtTsOverLinksBuffer[uGdpb][ 0 ].GetFullGdpbTs(); - else dTriggerTime = get4v2x::kdClockCycleSizeNs * fvtTsLinksBuffer[uGdpb][ vuIndexMatchingTrigger[uGdpb] ].GetFullGdpbTs(); - Double_t dTriggerWinBeg = dTriggerTime - fdStarTriggerDelay[ uGdpb ]; - Double_t dTriggerWinEnd = dTriggerTime - fdStarTriggerDelay[ uGdpb ] + fdStarTriggerWinSize[ uGdpb ]; - Double_t dClosestTriggerWinStart = dTriggerTime - fdStarTriggerDelay[ uGdpb ] + fdStarTriggerDeadtime[ uGdpb ]; - Bool_t bFirstMessClosestEventFound = kFALSE; - Bool_t bEventWindowInOverlap = ( fdCurrentTsCoreEndTime < dTriggerWinEnd ? kTRUE : kFALSE ); - - /// Check if this trigger may correspond to an event with data in next TS - if( kTRUE == bEventWindowInOverlap ) - fStarSubEvent.SetEndBorderEventFlag(); - - /// Check if this trigger leads to an event overlapping with the previous one - if( 0 < dPrevEventEnd[ uGdpb ] && dTriggerWinBeg < dPrevEventEnd[ uGdpb ] ) - fStarSubEvent.SetOverlapEventFlag(); - - for( std::vector< gdpb::FullMessage >::iterator itMess = itFirstMessageNextEvent[ uGdpb ]; - itMess != fvmTsLinksBuffer[ uGdpb ].end(); - ++ itMess ) - { - Double_t dMessageFullTime = (*itMess).GetFullTimeNs(); - if( kFALSE == bFirstMessClosestEventFound && - dClosestTriggerWinStart < dMessageFullTime ) - { - itFirstMessageNextEvent[ uGdpb ] = itMess; - bFirstMessClosestEventFound = kTRUE; - } // If first possible hit of closest event not found and current hit fits - - /// Plotting of time to trigger for all hits - Double_t dTimeToTrigg = dMessageFullTime - dTriggerTime; - fhStarHitToTrigAll_gDPB[ uGdpb ]->Fill( dTimeToTrigg ); - fhStarHitToTrigAllTime_gDPB[ uGdpb ]->Fill( dMeanTriggTimeToStartSec, dTimeToTrigg ); - fhStarHitToTrigAllTimeLong_gDPB[ uGdpb ]->Fill( dMeanTriggTimeToStartLongSec, dTimeToTrigg ); - - if( dTriggerWinBeg <= dMessageFullTime && dMessageFullTime <= dTriggerWinEnd ) - { - /// Message belongs to this event - fStarSubEvent.AddMsg( (*itMess) ); - - /// Plotting of time to trigger for hits within the event window - fhStarHitToTrigWin_gDPB[ uGdpb ]->Fill( dTimeToTrigg ); - fhStarHitToTrigWinTime_gDPB[ uGdpb ]->Fill( dMeanTriggTimeToStartSec, dTimeToTrigg ); - fhStarHitToTrigWinTimeLong_gDPB[ uGdpb ]->Fill( dMeanTriggTimeToStartLongSec, dTimeToTrigg ); - } // if( dTriggerWinBeg <= dMessageFullTime && dMessageFullTime <= dTriggerWinEnd ) - else if( dTriggerWinEnd < dMessageFullTime ) - /// First Message out of the window for this event => Stop there and go to the next - break; - } // Loop on message from first allowed by last event + deadtime to end - - /// If event window is going in overlap MS, check also these messages - if( kTRUE == bEventWindowInOverlap ) - { - for( std::vector< gdpb::FullMessage >::iterator itMess = fvmTsOverLinksBuffer[ uGdpb ].begin(); - itMess != fvmTsOverLinksBuffer[ uGdpb ].end(); - ++ itMess ) - { - Double_t dMessageFullTime = (*itMess).GetFullTimeNs(); - if( kFALSE == bFirstMessClosestEventFound && - dClosestTriggerWinStart < dMessageFullTime ) - { - itFirstMessageNextEvent[ uGdpb ] = itMess; - bFirstMessClosestEventFound = kTRUE; - } // If first possible hit of closest event not found and current hit fits - - /// Plotting of time to trigger for all hits - Double_t dTimeToTrigg = dMessageFullTime - dTriggerTime; - fhStarHitToTrigAll_gDPB[ uGdpb ]->Fill( dTimeToTrigg ); - fhStarHitToTrigAllTime_gDPB[ uGdpb ]->Fill( dMeanTriggTimeToStartSec, dTimeToTrigg ); - fhStarHitToTrigAllTimeLong_gDPB[ uGdpb ]->Fill( dMeanTriggTimeToStartLongSec, dTimeToTrigg ); - - if( dTriggerWinBeg <= dMessageFullTime && dMessageFullTime <= dTriggerWinEnd ) - { - /// Message belongs to this event - fStarSubEvent.AddMsg( (*itMess) ); - - /// Plotting of time to trigger for hits within the event window - fhStarHitToTrigWin_gDPB[ uGdpb ]->Fill( dTimeToTrigg ); - fhStarHitToTrigWinTime_gDPB[ uGdpb ]->Fill( dMeanTriggTimeToStartSec, dTimeToTrigg ); - fhStarHitToTrigWinTimeLong_gDPB[ uGdpb ]->Fill( dMeanTriggTimeToStartLongSec, dTimeToTrigg ); - } // if( dTriggerWinBeg <= dMessageFullTime && dMessageFullTime <= dTriggerWinEnd ) - else if( dTriggerWinEnd < dMessageFullTime ) - /// First Message out of the window for this event => Stop there and go to the next - break; - } // Loop on message from beginning to end - } // if( kTRUE == bEventWindowInOverlap ) - } // for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; uGdpb ++) - - /// Time sort the sub-event if required by the user - if( kTRUE == fbTimeSortOutput ) - fStarSubEvent.SortMessages( ); - - /// Send the sub-event to the STAR systems - iBuffSzByte = 0; - pDataBuff = fStarSubEvent.BuildOutput( iBuffSzByte ); - if( NULL != pDataBuff ) - { - /// Valid output, do stuff with it! - fulNbBuiltSubEvent++; - -#ifdef STAR_SUBEVT_BUILDER - /* - ** Function to send sub-event block to the STAR DAQ system - * trg_word received is packed as: - * - * trg_cmd|daq_cmd|tkn_hi|tkn_mid|tkn_lo - */ - star_rhicf_write( fStarSubEvent.GetTrigger().GetStarTrigerWord(), - pDataBuff, iBuffSzByte ); - fulNbStarSubEvent++; -/* - LOG(info) << "Sent STAR event with size " << iBuffSzByte << " Bytes" - << " and token " << fStarSubEvent.GetTrigger().GetStarToken(); -*/ -#endif // STAR_SUBEVT_BUILDER - - if( kTRUE == fbEventDumpEna ) - { - fpBinDumpFile->write( reinterpret_cast< const char * >( &kuBinDumpBegWord ), sizeof( UInt_t ) ); - fpBinDumpFile->write( reinterpret_cast< const char * >( &iBuffSzByte ), sizeof( Int_t ) ); - fpBinDumpFile->write( reinterpret_cast< const char * >( pDataBuff ), iBuffSzByte ); - fpBinDumpFile->write( reinterpret_cast< const char * >( &kuBinDumpEndWord ), sizeof( UInt_t ) ); - } // if( kTRUE == fbEventDumpEna ) - } // if( NULL != pDataBuff ) - else LOG(error) << "Invalid STAR SubEvent Output, can only happen if trigger " - << " object was not set => Do Nothing more with it!!! "; -/* - if( 1000 < iBuffSzByte ) - { - std::cout << "Big subevent in overlap" << std::endl; - fStarSubEvent.PrintSubEvent(); - } // if( 100 < iBuffSzByte ) -*/ - /// Fill plot of event size - fhStarEventSize->Fill( iBuffSzByte ); - /// Fill plot of event size as function of trigger time - if( 0 < fdStartTime ) - fhStarEventSizeTime->Fill( 1e-9 *(dMeanTriggerGdpbTsOver - fdStartTime), iBuffSzByte ); - if( 0 < fdStartTimeLong ) - fhStarEventSizeTimeLong->Fill( 1e-9 *(dMeanTriggerGdpbTsOver - fdStartTimeLong) / 60.0, iBuffSzByte ); - - /// Now clear the sub-event - fStarSubEvent.ClearSubEvent(); - } // if( bFirstTriggerMatch ) - } // if( kFALSE == bMatchingTriggerFound ) - } // while( kTRUE == bMatchingTriggerFound ) - - /// Clear buffers, eventual border crossing should be taken care thanks to the overlap MS - for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; uGdpb ++) - { - fvtTsLinksBuffer[uGdpb].clear(); - fvmTsLinksBuffer[uGdpb].clear(); - fvmTsOverLinksBuffer[uGdpb].clear(); - fvtTsOverLinksBuffer[uGdpb].clear(); - } // for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; uGdpb ++) -} - -ClassImp(CbmTofStarEventBuilder2018) diff --git a/beamtime/star2018/unpacker/CbmTofStarEventBuilder2018.h b/beamtime/star2018/unpacker/CbmTofStarEventBuilder2018.h deleted file mode 100644 index 782cca1b32004c987e3531f8204e403243e930d0..0000000000000000000000000000000000000000 --- a/beamtime/star2018/unpacker/CbmTofStarEventBuilder2018.h +++ /dev/null @@ -1,244 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmTofStarEventBuilder2018 ----- -// ----- Created 08.12.2017 by P.-A. Loizeau ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CbmTofStarEventBuilder2018_H -#define CbmTofStarEventBuilder2018_H - -#include "Timeslice.hpp" -#include "rocMess_wGet4v2.h" -#include "CbmTofStarData.h" -#include "CbmTofStarData2018.h" - -#include "CbmTSUnpack.h" -#include "CbmTbDaqBuffer.h" - -#include "TClonesArray.h" - -#include <vector> -#include <map> -#include <chrono> - -class CbmTofStar2018Par; - -class TCanvas; -class TH1; -class TH2; -class TProfile; - -#ifdef STAR_SUBEVT_BUILDER - /* - ** Function to send sub-event block to the STAR DAQ system - * trg_word received is packed as: - * - * trg_cmd|daq_cmd|tkn_hi|tkn_mid|tkn_lo - */ - extern "C" int star_rhicf_write(unsigned int trg_word, void *dta, int bytes); -#endif // STAR_SUBEVT_BUILDER - -class CbmTofStarEventBuilder2018 : public CbmTSUnpack -{ -public: - - CbmTofStarEventBuilder2018( UInt_t uNbGdpb = 1 ); - virtual ~CbmTofStarEventBuilder2018(); - - virtual Bool_t Init(); - virtual Bool_t DoUnpack(const fles::Timeslice& ts, size_t component); - virtual void Reset(); - - virtual void Finish(); - - void SetParContainers(); - - Bool_t InitContainers(); - - Bool_t ReInitContainers(); - - void FillOutput(boost::any); - - // Setting change methods - void SetMsLimitLevel( size_t uAcceptBoundaryPct = 100 ) { fuMsAcceptsPercent = uAcceptBoundaryPct; } - size_t GetMsLimitLevel( ) { return fuMsAcceptsPercent; } - - void SetEventBuildingMode( Bool_t bEventBuildingMode = kFALSE ); - void SetTimeSortOutput( Bool_t bTimeSort = kTRUE ); - void SetEventDumpEnable( Bool_t bDumpEna = kTRUE ); - - inline void SetHistoryHistoSize( UInt_t inHistorySizeSec = 1800 ) { fuHistoryHistoSize = inHistorySizeSec; } - inline void SetHistoryHistoSizeLong( UInt_t inHistorySizeMin = 1800 ) { fuHistoryHistoSizeLong = inHistorySizeMin; } - inline void SetPrintoutInterval( Double_t inIntervalInSec = 30.0 ) { fdMoniOutIntervalSec = inIntervalInSec; } - inline void SetHistSaveToPrintRatio( UInt_t inSavePrintRatio = 4 ) { fuPrintToSaveRatio = inSavePrintRatio; } - - - // Output control methods - void SaveAllHistos( TString sFileName = "" ); - void ResetAllHistos(); - void ResetEvolutionHistograms(); - void ResetLongEvolutionHistograms(); - -private: - - size_t fuMsAcceptsPercent; /** Reject Ms with index inside TS above this, assumes 100 MS per TS **/ - size_t fuTotalMsNb; /** Total nb of MS per link in timeslice **/ - size_t fuOverlapMsNb; /** Overlap Ms: all fuOverlapMsNb MS at the end of timeslice **/ - size_t fuCoreMs; /** Number of non overlap MS at beginning of TS **/ - Double_t fdMsSizeInNs; - Double_t fdTsCoreSizeInNs; - UInt_t fuMinNbGdpb; - UInt_t fuCurrNbGdpb; - - /** Settings from parameter file **/ - UInt_t fuNrOfGdpbs; // Total number of GDPBs in the system - UInt_t fuNrOfFebsPerGdpb; // Number of FEBs per GDPB - UInt_t fuNrOfGet4PerFeb; // Number of GET4s per FEB - UInt_t fuNrOfChannelsPerGet4; // Number of channels in each GET4 - - UInt_t fuNrOfChannelsPerFeet; // Number of channels in each FEET - UInt_t fuNrOfGet4; // Total number of Get4 chips in the system - UInt_t fuNrOfGet4PerGdpb; // Number of GET4s per GDPB - UInt_t fuNrOfChannelsPerGdpb; // Number of channels per GDPB - - std::vector<int> fMsgCounter; - std::map<UInt_t, UInt_t> fGdpbIdIndexMap; - - std::vector< Double_t > fdStarTriggerDeadtime; - std::vector< Double_t > fdStarTriggerDelay; - std::vector< Double_t > fdStarTriggerWinSize; - Double_t fdTsDeadtimePeriod; - - /** Running indices **/ - uint64_t fulCurrentTsIndex; // Idx of the current TS - size_t fuCurrentMs; // Idx of the current MS in TS (0 to fuTotalMsNb) - UInt_t fuGdpbId; // Id (hex number) of the GDPB for current message - UInt_t fuGdpbNr; // running number (0 to fNrOfGdpbs) of the GDPB for current message - UInt_t fuGet4Id; // running number (0 to fNrOfGet4PerGdpb) of the Get4 chip of a unique GDPB for current message - UInt_t fuGet4Nr; // running number (0 to fNrOfGet4) of the Get4 chip in the system for current message - - /** Current epoch marker for each GDPB and GET4 - * (first epoch in the stream initializes the map item) - * pointer points to an array of size fNrOfGdpbs * fNrOfGet4PerGdpb - * The correct array index is calculated using the function - * GetArrayIndex(gdpbId, get4Id) - **/ - std::vector< ULong64_t > fvulCurrentEpoch; //! - std::vector< Bool_t > fvbFirstEpochSeen; //! - - Int_t fNofEpochs; /** Current epoch marker for each ROC **/ - ULong64_t fulCurrentEpochTime; /** Time stamp of current epoch **/ - Double_t fdStartTime; /** Time of first valid hit (epoch available), used as reference for evolution plots**/ - Double_t fdStartTimeLong; /** Time of first valid hit (epoch available), used as reference for evolution plots**/ - Double_t fdStartTimeMsSz; /** Time of first microslice, used as reference for evolution plots**/ - TCanvas* fcMsSizeAll; - - Int_t fEquipmentId; - Double_t fdMsIndex; - - CbmTofStar2018Par* fUnpackPar; //! - - void CreateHistograms(); - - /// Variables used for histo filling - UInt_t fuHistoryHistoSize; - UInt_t fuHistoryHistoSizeLong; - - /// Variables used for monitoring output control - Double_t fdMoniOutIntervalSec; - UInt_t fuPrintToSaveRatio; - UInt_t fuPrintToSaveCount; - - ///* STAR TRIGGER detection */// - std::vector< ULong64_t > fulGdpbTsMsb; - std::vector< ULong64_t > fulGdpbTsLsb; - std::vector< ULong64_t > fulStarTsMsb; - std::vector< ULong64_t > fulStarTsMid; - std::vector< ULong64_t > fulGdpbTsFullLast; - std::vector< ULong64_t > fulStarTsFullLast; - std::vector< UInt_t > fuStarTokenLast; - std::vector< UInt_t > fuStarDaqCmdLast; - std::vector< UInt_t > fuStarTrigCmdLast; - std::vector< ULong64_t > fulGdpbTsFullLastCore; - std::vector< ULong64_t > fulStarTsFullLastCore; - std::vector< UInt_t > fuStarTokenLastCore; - std::vector< UInt_t > fuStarDaqCmdLastCore; - std::vector< UInt_t > fuStarTrigCmdLastCore; - std::vector< TH1 * > fhTokenMsgType; - std::vector< TH1 * > fhTriggerRate; - std::vector< TH1 * > fhTriggerRateLong; - std::vector< TH2 * > fhCmdDaqVsTrig; - std::vector< TH2 * > fhStarTokenEvo; - std::vector< TProfile * > fhStarTrigGdpbTsEvo; - std::vector< TProfile * > fhStarTrigStarTsEvo; - - ///* STAR event building */// - Bool_t fbEventBuilding; //! If false => build subevents in each MS => M1, if true => store data for full TS, then build subevents in TS => M2 - Bool_t fbTimeSortOutput; - CbmTofStarSubevent2018 fStarSubEvent; - ULong64_t fulNbBuiltSubEvent; - ULong64_t fulNbStarSubEvent; - ULong64_t fulNbBuiltSubEventLastPrintout; - ULong64_t fulNbStarSubEventLastPrintout; - std::chrono::time_point<std::chrono::system_clock> fTimeLastPrintoutNbStarEvent; - Double_t fdCurrentMsStartTime; //! M1, Used in case of single link per subevent: test mode in 2018 S1, sector mode in 2018 S2 - Double_t fdCurrentMsEndTime; //! M1, Used in case of single link per subevent: test mode in 2018 S1, sector mode in 2018 S2 - std::vector< gdpb::FullMessage > fvmCurrentLinkBuffer; //! M1, Used in case of single link per subevent: test mode in 2018 S1, sector mode in 2018 S2 - std::vector< CbmTofStarTrigger2018 > fvtCurrentLinkBuffer; //! M1, Used in case of single link per subevent: test mode in 2018 S1, sector mode in 2018 S2 - Double_t fdCurrentTsStartTime; //! M2, Used in case of all links in same subevent: Sector mode in 2018 S1, Full eTOF mode in 2018 S2 - Double_t fdCurrentTsCoreEndTime; //! M2, Used in case of all links in same subevent: Sector mode in 2018 S1, Full eTOF mode in 2018 S2 - std::vector< std::vector < gdpb::FullMessage > > fvmTsLinksBuffer; //! M2, Used in case of all links in same subevent: Sector mode in 2018 S1, Full eTOF mode in 2018 S2 - std::vector< std::vector < CbmTofStarTrigger2018 > > fvtTsLinksBuffer; //! M2, Used in case of all links in same subevent: Sector mode in 2018 S1, Full eTOF mode in 2018 S2 - std::vector< std::vector < gdpb::FullMessage > > fvmTsOverLinksBuffer; //! M2, Used in case of all links in same subevent: Sector mode in 2018 S1, Full eTOF mode in 2018 S2 - std::vector< std::vector < CbmTofStarTrigger2018 > > fvtTsOverLinksBuffer; //! M2, Used in case of all links in same subevent: Sector mode in 2018 S1, Full eTOF mode in 2018 S2 - std::vector<TH1*> fhStarHitToTrigAll_gDPB; - std::vector<TH1*> fhStarHitToTrigWin_gDPB; - std::vector<TH2*> fhStarHitToTrigAllTime_gDPB; - std::vector<TH2*> fhStarHitToTrigWinTime_gDPB; - std::vector<TH2*> fhStarHitToTrigAllTimeLong_gDPB; - std::vector<TH2*> fhStarHitToTrigWinTimeLong_gDPB; - std::vector<TH1*> fhStarEventSize_gDPB; - std::vector<TH2*> fhStarEventSizeTime_gDPB; - std::vector<TH2*> fhStarEventSizeTimeLong_gDPB; - std::vector<TH1*> fhStarTrigTimeToMeanTrig_gDPB; - TH1 * fhStarEventSize; - TH2 * fhStarEventSizeTime; - TH2 * fhStarEventSizeTimeLong; - - std::chrono::time_point<std::chrono::system_clock> fStartTimeProcessingLastTs; - TH2 * fhStarTsProcessTime; - TH2 * fhStarTsProcessTimeShort; - TH1 * fhStarTsInterprocessTime; - - std::vector< std::vector < gdpb::Message > > fvmEpSupprBuffer; - - ///* Event dump to binary file */// - Bool_t fbEventDumpEna; - std::fstream * fpBinDumpFile; - const UInt_t kuBinDumpBegWord = 0xFEEDBEAF; - const UInt_t kuBinDumpEndWord = 0xFAEBDEEF; - - void FillHitInfo(gdpb::Message); - void FillStarTrigInfo(gdpb::Message); - void FillEpochInfo(gdpb::Message); - void PrintSlcInfo(gdpb::Message); - void PrintSysInfo(gdpb::Message); - void PrintGenInfo(gdpb::Message); - - - inline Int_t GetArrayIndex(Int_t gdpbId, Int_t get4Id) - { - return gdpbId * fuNrOfGet4PerGdpb + get4Id; - } - - void BuildStarEventsSingleLink(); - void BuildStarEventsAllLinks(); - - CbmTofStarEventBuilder2018(const CbmTofStarEventBuilder2018&); - CbmTofStarEventBuilder2018 operator=(const CbmTofStarEventBuilder2018&); - - ClassDef(CbmTofStarEventBuilder2018, 1) -}; - -#endif diff --git a/beamtime/star2018/unpacker/CbmTofStarMonitor2018.cxx b/beamtime/star2018/unpacker/CbmTofStarMonitor2018.cxx deleted file mode 100644 index a0c6f8611041ba07974522c3a944605eb3eccfe4..0000000000000000000000000000000000000000 --- a/beamtime/star2018/unpacker/CbmTofStarMonitor2018.cxx +++ /dev/null @@ -1,3411 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmTofStarMonitor2018 ----- -// ----- Created 19.01.2018 by P.-A. Loizeau ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#include "CbmTofStarMonitor2018.h" -#include "CbmTofUnpackPar.h" - -//#include "CbmFlibCern2016Source.h" -#include "CbmHistManager.h" - -#include "FairLogger.h" -#include "FairRootManager.h" -#include "FairRun.h" -#include "FairRuntimeDb.h" -#include "FairRunOnline.h" - -#include "TClonesArray.h" -#include "TString.h" -#include "THttpServer.h" -#include "Rtypes.h" -#include "TH1.h" -#include "TF1.h" -#include "TCanvas.h" -#include "THStack.h" -#include "TROOT.h" -#include "TStyle.h" -#include "TPaveStats.h" -#include "TDatime.h" -#include "TMath.h" -#include <TFile.h> - -#include <algorithm> -#include <iostream> -#include <stdint.h> -#include <iomanip> -#include <ctime> - -Bool_t bResetTofStarMoniHistos = kFALSE; -Bool_t bSaveTofStarMoniHistos = kFALSE; -Bool_t bTofUpdateNormedFtMoni = kFALSE; -Bool_t bTofUpdateZoomedFitMoni = kFALSE; - -CbmTofStarMonitor2018::CbmTofStarMonitor2018() : - CbmTSUnpack(), - fuMsAcceptsPercent(100), - fuOverlapMsNb(0), - fuMinNbGdpb(), - fuCurrNbGdpb(0), - fNrOfGdpbs(0), - fNrOfFebsPerGdpb(0), - fNrOfGet4PerFeb(0), - fNrOfChannelsPerGet4(0), - fNrOfChannelsPerFeet(0), - fNrOfGet4(0), - fNrOfGet4PerGdpb(0), - fuNbChannelsPerGdpb( 0 ), - fiCountsLastTs(0), - fiSpillOnThr(10), - fiSpillOffThr(3), - fiTsUnderOff(0), - fiTsUnderOffThr(10), - fdDetLastTime(-1.), - fdDetTimeLastTs(-1.), - fbSpillOn(kFALSE), - fSpillIdx(0), - fbEpochSuppModeOn(kFALSE), - fvmEpSupprBuffer(), - fGdpbId(0), - fGdpbNr(0), - fGet4Id(0), - fGet4Nr(0), - fMsgCounter(11, 0), // length of enum MessageTypes initialized with 0 - fGdpbIdIndexMap(), - fHM(new CbmHistManager()), - fCurrentEpoch(NULL), - fNofEpochs(0), - fCurrentEpochTime(0.), - fdStartTime(-1.), - fdStartTimeLong(-1.), - fdStartTimeMsSz(-1.), - fcMsSizeAll(NULL), - fTsLastHit(), - fEquipmentId(0), - fdMsIndex(0.0), - fUnpackPar(NULL), - fHistMessType(NULL), - fHistSysMessType(NULL), - fHistGet4MessType(NULL), - fHistGet4ChanScm(NULL), - fHistGet4ChanErrors(NULL), - fHistGet4EpochFlags(NULL), - fHistSpill(NULL), - fHistSpillLength(NULL), - fHistSpillCount(NULL), - fHistSpillQA(NULL), - fhScmScalerCounters(NULL), - fhScmDeadtimeCounters(NULL), - fhScmSeuCounters(NULL), - fhScmSeuCountersEvo(NULL), - fdTimeLastStartMessage(0.), - fhScmStartMessDist(NULL), - fhScmStartMessEvo(NULL), - fRaw_Tot_gDPB(), - fChCount_gDPB(), - fChannelRate_gDPB(), - fFeetRate_gDPB(), - fFeetErrorRate_gDPB(), - fuHistoryHistoSize( 1800 ), - fFeetRateLong_gDPB(), - fFeetErrorRateLong_gDPB(), - fuHistoryHistoSizeLong( 600 ), - fFeetRateDate_gDPB(), - fiRunStartDateTimeSec( -1 ), - fiBinSizeDatePlots( -1 ), - fdFirstMsIndex( -1 ), - fbFirstEpochInMsFound(), - fRealMsFineQa_gDPB(), - fRealMsMidQa_gDPB(), - fRealMsCoarseQa_gDPB(), -/* - fulLastMsIdx(0), - fbHitsInLastTs(kFALSE), - fvulHitEpochBuffLastTs(), - fvhCoincOffsetEpochGet4(), -*/ - fulGdpbTsMsb(0), - fulGdpbTsLsb(0), - fulStarTsMsb(0), - fulStarTsMid(0), - fulGdpbTsFullLast(0), - fulStarTsFullLast(0), - fuStarTokenLast(0), - fuStarDaqCmdLast(0), - fuStarTrigCmdLast(0), - fhTokenMsgType(NULL), - fhTriggerRate(NULL), - fhCmdDaqVsTrig(NULL), - fhStarTokenEvo(NULL), - fbGet4M24b( kFALSE ), - fbGet4v20( kFALSE ), - fbMergedEpochsOn( kFALSE ), - fbPulserMode( kFALSE ), - fuPulserGdpb(0), - fuPulserFee(0), - fhTimeDiffPulserChosenFee(), - fhTimeDiffPulserChosenChPairs(), - fhTimeRmsPulserChosenFee(NULL), - fhTimeRmsPulserChosenChPairs(NULL), - fdLastRmsUpdateTime(-1), - fdFitZoomWidthPs(0.0), - fhTimeRmsZoomPulsChosenFee(NULL), - fhTimeRmsZoomFitPulsChosenChPairs(NULL), - fhTimeResFitPulsChosenFee(NULL), - fhTimeResFitPulsChosenChPairs(NULL), - fhFtDistribPerCh(), - fChCountFall_gDPB(), - fhFtDistribPerChFall(), - fSelChFtNormDnlRise(), - fSelChFtNormDnlFall(), - fFtNormDnlMinRise(), - fFtNormDnlMaxRise(), - fFtNormDnlMinFall(), - fFtNormDnlMaxFall(), - fhTempHistInlRise(NULL), - fhTempHistInlFall(NULL), - fSelChFtNormInlRise(), - fSelChFtNormInlFall(), - fFtNormInlMinRise(), - fFtNormInlMaxRise(), - fFtNormInlMinFall(), - fFtNormInlMaxFall(), - fviFtLastRise24b(), - fviFtLastFall24b(), - fvdTimeLastRise24b(), - fvdTimeLastFall24b(), - fuRiseFallChSel(0), - fhFtLastRiseCurrFall(), - fhFtCurrRiseLastFall(), - fhFtLastRiseDistRise(), - fhFtLastRiseDistFall(), - iMess(0), - iMessB(0), - dMinDt(-1.*(kuNbBinsDt*get4v1x::kdBinSize/2.) - get4v1x::kdBinSize/2.), - dMaxDt(1.*(kuNbBinsDt*get4v1x::kdBinSize/2.) + get4v1x::kdBinSize/2.), - uNbFeetPlot(2), - uNbFeetPlotsPerGdpb(0) -{ -} - -CbmTofStarMonitor2018::~CbmTofStarMonitor2018() -{ - delete fHM; //TODO: Who deletes the histograms stored in the CbmHistManager??? - delete[] fCurrentEpoch; -} - -Bool_t CbmTofStarMonitor2018::Init() -{ - LOG(info) << "Initializing Get4 monitor"; - - FairRootManager* ioman = FairRootManager::Instance(); - if (ioman == NULL) { - LOG(fatal) << "No FairRootManager instance"; - } - - return kTRUE; -} - -void CbmTofStarMonitor2018::SetParContainers() -{ - LOG(info) << "Setting parameter containers for " << GetName(); - fUnpackPar = - (CbmTofUnpackPar*) (FairRun::Instance()->GetRuntimeDb()->getContainer( - "CbmTofUnpackPar")); - -} - -Bool_t CbmTofStarMonitor2018::InitContainers() -{ - LOG(info) << "Init parameter containers for " << GetName(); - Bool_t initOK = ReInitContainers(); - - CreateHistograms(); - - fCurrentEpoch = new Long64_t[fNrOfGdpbs * fNrOfGet4PerGdpb]; - for (UInt_t i = 0; i < fNrOfGdpbs; ++i) { - for (UInt_t j = 0; j < fNrOfGet4PerGdpb; ++j) { - fCurrentEpoch[GetArrayIndex(i, j)] = -111; - } - } - - return initOK; -} - -Bool_t CbmTofStarMonitor2018::ReInitContainers() -{ - LOG(info) << "ReInit parameter containers for " << GetName(); - - fNrOfGdpbs = fUnpackPar->GetNrOfRocs(); - LOG(info) << "Nr. of Tof GDPBs: " << fNrOfGdpbs; - fuMinNbGdpb = fNrOfGdpbs; - - fNrOfFebsPerGdpb = fUnpackPar->GetNrOfFebsPerGdpb(); - LOG(info) << "Nr. of FEBS per Tof GDPB: " << fNrOfFebsPerGdpb; - - fNrOfGet4PerFeb = fUnpackPar->GetNrOfGet4PerFeb(); - LOG(info) << "Nr. of GET4 per Tof FEB: " << fNrOfGet4PerFeb; - - fNrOfChannelsPerGet4 = fUnpackPar->GetNrOfChannelsPerGet4(); - LOG(info) << "Nr. of channels per GET4: " << fNrOfChannelsPerGet4; - - fNrOfChannelsPerFeet = fNrOfGet4PerFeb * fNrOfChannelsPerGet4; - LOG(info) << "Nr. of channels per FEET: " << fNrOfChannelsPerFeet; - - fNrOfGet4 = fNrOfGdpbs * fNrOfFebsPerGdpb * fNrOfGet4PerFeb; - LOG(info) << "Nr. of GET4s: " << fNrOfGet4; - - fNrOfGet4PerGdpb = fNrOfFebsPerGdpb * fNrOfGet4PerFeb; - LOG(info) << "Nr. of GET4s per GDPB: " << fNrOfGet4PerGdpb; - - fuNbChannelsPerGdpb = fNrOfFebsPerGdpb * fNrOfGet4PerFeb * fNrOfChannelsPerGet4; - LOG(info) << "Nr. of channels per GDPB: " << fuNbChannelsPerGdpb; - - fGdpbIdIndexMap.clear(); - for (UInt_t i = 0; i < fNrOfGdpbs; ++i) { - fGdpbIdIndexMap[fUnpackPar->GetRocId(i)] = i; - LOG(info) << "GDPB Id of TOF " << i << " : " << fUnpackPar->GetRocId(i); - } - UInt_t NrOfChannels = fUnpackPar->GetNumberOfChannels(); - LOG(info) << "Nr. of mapped Tof channels: " << NrOfChannels; - std::stringstream ss; - for( UInt_t i = 0; i < NrOfChannels; ++i) - { - if(i%8 == 0) - ss << "\n"; - ss << Form(" 0x%08x",fUnpackPar->GetChannelToDetUIdMap(i)); - } // for( UInt_t i = 0; i < NrOfChannels; ++i) - LOG(info) << ss.str(); - - LOG(info) << "Plot Channel Rate => " - << (fUnpackPar->IsChannelRateEnabled() ? "ON" : "OFF"); - - if( fbEpochSuppModeOn ) - fvmEpSupprBuffer.resize( fNrOfGet4 ); - - return kTRUE; -} - -void CbmTofStarMonitor2018::CreateHistograms() -{ - THttpServer* server = FairRunOnline::Instance()->GetHttpServer(); -// server->SetJSROOT("https://root.cern.ch/js/latest"); - - TString name { "" }; - TString title { "" }; - - name = "hMessageType"; - title = "Nb of message for each type; Type"; - // Test Big Data readout with plotting - TH1I* hMessageType = new TH1I(name, title, 16, 0., 16.); - // TH1I* hMessageType = new TH1I(name, title, 16, -0.5, 15.5); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_NOP, "NOP"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_HIT, "HIT"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_EPOCH, "EPOCH"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_SYNC, "SYNC"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_AUX, "AUX"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_EPOCH2, "EPOCH2"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_GET4, "GET4"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_SYS, "SYS"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_GET4_SLC, - "MSG_GET4_SLC"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_GET4_32B, - "MSG_GET4_32B"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_GET4_SYS, - "MSG_GET4_SYS"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_STAR_TRI, - "MSG_STAR_TRI"); - hMessageType->GetXaxis()->SetBinLabel(1 + 15, "GET4 Hack 32B"); - hMessageType->GetXaxis()->SetBinLabel(1 + ngdpb::MSG_NOP, "NOP"); - fHM->Add(name.Data(), hMessageType); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - - name = "hSysMessType"; - title = "Nb of system message for each type; System Type"; - TH1I* hSysMessType = new TH1I(name, title, 17, 0., 17.); -// TH1I* hSysMessType = new TH1I(name, title, 17, -0.5, 16.5); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_START, - "DAQ START"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_FINISH, - "DAQ FINISH"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_NX_PARITY, - "NX PARITY"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_SYNC_PARITY, - "SYNC PARITY"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_DAQ_RESUME, - "DAQ RESUME"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_FIFO_RESET, - "FIFO RESET"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_USER, "USER"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_PCTIME, "PCTIME"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_ADC, "ADC"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_PACKETLOST, - "PACKET LOST"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_GET4_EVENT, - "GET4 ERROR"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_CLOSYSYNC_ERROR, - "CLOSYSYNC ERROR"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_TS156_SYNC, - "TS156 SYNC"); - hSysMessType->GetXaxis()->SetBinLabel(1 + ngdpb::SYSMSG_GDPB_UNKWN, - "UNKW GET4 MSG"); - hSysMessType->GetXaxis()->SetBinLabel(1 + 16, "GET4 Hack 32B"); - fHM->Add(name.Data(), hSysMessType); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - - name = "hGet4MessType"; - title = "Nb of message for each type per GET4; GET4 chip # ; Type"; - TH2I* hGet4MessType = new TH2I(name, title, fNrOfGet4, 0., fNrOfGet4, 5, 0., - 5.); -// TH2I* hGet4MessType = new TH2I(name, title, uNbFeets*feetv1::kuChipPerFeet, -0.5, uNbFeets*feetv1::kuChipPerFeet -0.5, 5, -0.5, 4.5); - hGet4MessType->GetYaxis()->SetBinLabel(1 + ngdpb::GET4_32B_EPOCH, "EPOCH"); - hGet4MessType->GetYaxis()->SetBinLabel(1 + ngdpb::GET4_32B_SLCM, "S.C. M"); - hGet4MessType->GetYaxis()->SetBinLabel(1 + ngdpb::GET4_32B_ERROR, "ERROR"); - hGet4MessType->GetYaxis()->SetBinLabel(1 + ngdpb::GET4_32B_DATA, "DATA 32b"); - hGet4MessType->GetYaxis()->SetBinLabel(1 + ngdpb::GET4_32B_DATA + 1, - "DATA 24b"); - fHM->Add(name.Data(), hGet4MessType); - if (server) - server->Register("/TofRaw", fHM->H2(name.Data())); - - name = "hGet4ChanScm"; - title = "SC messages per GET4 channel; GET4 channel # ; SC type"; - TH2I* hGet4ChanScm = new TH2I(name, title, - 2 * fNrOfGet4 * fNrOfChannelsPerGet4, 0., fNrOfGet4 * fNrOfChannelsPerGet4, - 4, 0., 4.); - fHM->Add(name.Data(), hGet4ChanScm); - if (server) - server->Register("/TofRaw", fHM->H2(name.Data())); - - name = "hGet4ChanErrors"; - title = "Error messages per GET4 channel; GET4 channel # ; Error"; - TH2I* hGet4ChanErrors = NULL; - if( kTRUE == fbGet4v20 ) - { - /// Possible errors changed after introduction of Bubbles correction/detection - hGet4ChanErrors = new TH2I(name, title, - fNrOfGet4 * fNrOfChannelsPerGet4, 0., fNrOfGet4 * fNrOfChannelsPerGet4, - 21, 0., 21.); -// 32, 0., 32.); - hGet4ChanErrors->GetYaxis()->SetBinLabel( 1, "0x00: Readout Init "); - hGet4ChanErrors->GetYaxis()->SetBinLabel( 2, "0x01: Sync "); - hGet4ChanErrors->GetYaxis()->SetBinLabel( 3, "0x02: Epoch count sync"); - hGet4ChanErrors->GetYaxis()->SetBinLabel( 4, "0x03: Epoch "); - hGet4ChanErrors->GetYaxis()->SetBinLabel( 5, "0x04: FIFO Write "); - hGet4ChanErrors->GetYaxis()->SetBinLabel( 6, "0x05: Lost event "); - hGet4ChanErrors->GetYaxis()->SetBinLabel( 7, "0x06: Channel state "); - hGet4ChanErrors->GetYaxis()->SetBinLabel( 8, "0x07: Token Ring state"); - hGet4ChanErrors->GetYaxis()->SetBinLabel( 9, "0x08: Token "); - hGet4ChanErrors->GetYaxis()->SetBinLabel(10, "0x09: Error Readout "); - hGet4ChanErrors->GetYaxis()->SetBinLabel(11, "0x0a: SPI "); - hGet4ChanErrors->GetYaxis()->SetBinLabel(12, "0x0b: DLL Lock error "); // <- From GET4 v1.2 - hGet4ChanErrors->GetYaxis()->SetBinLabel(13, "0x0c: DLL Reset invoc."); // <- From GET4 v1.2 - hGet4ChanErrors->GetYaxis()->SetBinLabel(14, "0x11: Overwrite "); - hGet4ChanErrors->GetYaxis()->SetBinLabel(15, "0x12: ToT out of range"); - hGet4ChanErrors->GetYaxis()->SetBinLabel(16, "0x13: Event Discarded "); - hGet4ChanErrors->GetYaxis()->SetBinLabel(17, "0x14: Add. Rising edge"); // <- From GET4 v1.3 - hGet4ChanErrors->GetYaxis()->SetBinLabel(18, "0x15: Unpaired Falling"); // <- From GET4 v1.3 - hGet4ChanErrors->GetYaxis()->SetBinLabel(19, "0x16: Sequence error "); // <- From GET4 v1.3 - hGet4ChanErrors->GetYaxis()->SetBinLabel(20, "0x7f: Unknown "); - hGet4ChanErrors->GetYaxis()->SetBinLabel(21, "Corrupt/unsuprtd error"); - } // if( kTRUE == fbGet4v20 ) - else - { - hGet4ChanErrors = new TH2I(name, title, - fNrOfGet4 * fNrOfChannelsPerGet4, 0., fNrOfGet4 * fNrOfChannelsPerGet4, - 18, 0., 18.); - // 32, 0., 32.); - hGet4ChanErrors->GetYaxis()->SetBinLabel( 1, "0x00: Readout Init "); - hGet4ChanErrors->GetYaxis()->SetBinLabel( 2, "0x01: Sync "); - hGet4ChanErrors->GetYaxis()->SetBinLabel( 3, "0x02: Epoch count sync"); - hGet4ChanErrors->GetYaxis()->SetBinLabel( 4, "0x03: Epoch "); - hGet4ChanErrors->GetYaxis()->SetBinLabel( 5, "0x04: FIFO Write "); - hGet4ChanErrors->GetYaxis()->SetBinLabel( 6, "0x05: Lost event "); - hGet4ChanErrors->GetYaxis()->SetBinLabel( 7, "0x06: Channel state "); - hGet4ChanErrors->GetYaxis()->SetBinLabel( 8, "0x07: Token Ring state"); - hGet4ChanErrors->GetYaxis()->SetBinLabel( 9, "0x08: Token "); - hGet4ChanErrors->GetYaxis()->SetBinLabel(10, "0x09: Error Readout "); - hGet4ChanErrors->GetYaxis()->SetBinLabel(11, "0x0a: SPI "); - hGet4ChanErrors->GetYaxis()->SetBinLabel(12, "0x0b: DLL Lock error "); // <- From GET4 v1.2 - hGet4ChanErrors->GetYaxis()->SetBinLabel(13, "0x0c: DLL Reset invoc."); // <- From GET4 v1.2 - hGet4ChanErrors->GetYaxis()->SetBinLabel(14, "0x11: Overwrite "); - hGet4ChanErrors->GetYaxis()->SetBinLabel(15, "0x12: ToT out of range"); - hGet4ChanErrors->GetYaxis()->SetBinLabel(16, "0x13: Event Discarded "); - hGet4ChanErrors->GetYaxis()->SetBinLabel(17, "0x7f: Unknown "); - } // else of if( kTRUE == fbGet4v20 ) - fHM->Add(name.Data(), hGet4ChanErrors); - if (server) - server->Register("/TofRaw", fHM->H2(name.Data())); - - name = "hGet4EpochFlags"; - title = "Epoch flags per GET4; GET4 chip # ; Type"; - TH2I* hGet4EpochFlags = new TH2I(name, title, fNrOfGet4, 0., fNrOfGet4, 4, 0., - 4.); -// hEpochFlags = new TH2I(name, title, uNbFeets*feetv1::kuChipPerFeet, -0.5, uNbFeets*feetv1::kuChipPerFeet -0.5, 4, -0.5, 3.5); - hGet4EpochFlags->GetYaxis()->SetBinLabel(1, "SYNC"); - hGet4EpochFlags->GetYaxis()->SetBinLabel(2, "Ep LOSS"); - hGet4EpochFlags->GetYaxis()->SetBinLabel(3, "Da LOSS"); - hGet4EpochFlags->GetYaxis()->SetBinLabel(4, "MISSMAT"); - fHM->Add(name.Data(), hGet4EpochFlags); - if (server) - server->Register("/TofRaw", fHM->H2(name.Data())); - - // Slow control messages analysis - name = "hScmScalerCounters"; - title = "Content of Scaler counter SC messages; Scaler counter [hit]; Channel []"; - fhScmScalerCounters = new TH2I(name, title, fNrOfGet4 * fNrOfChannelsPerGet4 * 2, 0., fNrOfGet4 * fNrOfChannelsPerGet4, - 8192, 0., 8192.); - fHM->Add(name.Data(), fhScmScalerCounters); - if (server) - server->Register("/TofRaw", fhScmScalerCounters ); - - name = "hScmDeadtimeCounters"; - title = "Content of Deadtime counter SC messages; Deadtime [Clk Cycles]; Channel []"; - fhScmDeadtimeCounters = new TH2I(name, title, fNrOfGet4 * fNrOfChannelsPerGet4 * 2, 0., fNrOfGet4 * fNrOfChannelsPerGet4, - 8192, 0., 8192.); - fHM->Add(name.Data(), fhScmDeadtimeCounters); - if (server) - server->Register("/TofRaw", fhScmDeadtimeCounters ); - - name = "hScmSeuCounters"; - title = "Content of SEU counter SC messages; SEU []; Channel []"; - fhScmSeuCounters = new TH2I(name, title, fNrOfGet4 * fNrOfChannelsPerGet4 * 2, 0., fNrOfGet4 * fNrOfChannelsPerGet4, - 8192, 0., 8192.); - fHM->Add(name.Data(), fhScmSeuCounters); - if (server) - server->Register("/TofRaw", fhScmSeuCounters ); - - name = "hScmSeuCountersEvo"; - title = "SEU counter rate from SC messages; Time in Run [s]; Channel []; SEU []"; - fhScmSeuCountersEvo = new TH2I(name, title, fNrOfGet4 * fNrOfChannelsPerGet4 * 2, 0., fNrOfGet4 * fNrOfChannelsPerGet4, - fuHistoryHistoSize, 0., fuHistoryHistoSize); - fHM->Add(name.Data(), fhScmSeuCountersEvo); - if (server) - server->Register("/TofRaw", fhScmSeuCountersEvo ); - - name = "hScmStartMessDist"; - title = "Start message time interval distribution for GET4 #0; Time interval [s]; Counts []"; - fhScmStartMessDist = new TH1I(name, title, 10000, 0., 10.); - fHM->Add(name.Data(), fhScmStartMessDist); - if (server) - server->Register("/TofRaw", fhScmStartMessDist ); - - name = "hScmStartMessEvo"; - title = "Start message rate for GET4 #0; Time in Run [s]; Start Mess []"; - fhScmStartMessEvo = new TH1I(name, title, fuHistoryHistoSize, 0., fuHistoryHistoSize); - fHM->Add(name.Data(), fhScmStartMessEvo); - if (server) - server->Register("/TofRaw", fhScmStartMessEvo ); - - // Prepare storing of hit time info - if( fUnpackPar->IsChannelRateEnabled() || fbPulserMode ) - { - fTsLastHit.resize( fNrOfGdpbs ); - for( UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; uGdpb++) - { - fTsLastHit[ uGdpb ].resize( fNrOfGet4PerGdpb ); - for( UInt_t uGet4 = 0; uGet4 < fNrOfGet4PerGdpb; uGet4++) - { - fTsLastHit[ uGdpb ][ uGet4 ].resize( fNrOfChannelsPerGet4 ); - for( UInt_t uCh = 0; uCh < fNrOfChannelsPerGet4; uCh++) - fTsLastHit[ uGdpb ][ uGet4 ][ uCh ] = -1; - } // for( UInt_t uGet4 = 0; uGet4 < fNrOfGet4PerGdpb; uGet4++) - } // for( UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; uGdpb++) - } // if( fUnpackPar->IsChannelRateEnabled() || fbPulserMode ) - - if (fUnpackPar->IsChannelRateEnabled()) { - for (UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; uGdpb++) { - const Int_t iNbBinsRate = 82; - Double_t dBinsRate[iNbBinsRate] = { 1e0, 2e0, 3e0, 4e0, 5e0, 6e0, 7e0, - 8e0, 9e0, 1e1, 2e1, 3e1, 4e1, 5e1, 6e1, 7e1, 8e1, 9e1, 1e2, 2e2, 3e2, - 4e2, 5e2, 6e2, 7e2, 8e2, 9e2, 1e3, 2e3, 3e3, 4e3, 5e3, 6e3, 7e3, 8e3, - 9e3, 1e4, 2e4, 3e4, 4e4, 5e4, 6e4, 7e4, 8e4, 9e4, 1e5, 2e5, 3e5, 4e5, - 5e5, 6e5, 7e5, 8e5, 9e5, 1e6, 2e6, 3e6, 4e6, 5e6, 6e6, 7e6, 8e6, 9e6, - 1e7, 2e7, 3e7, 4e7, 5e7, 6e7, 7e7, 8e7, 9e7, 1e8, 2e8, 3e8, 4e8, 5e8, - 6e8, 7e8, 8e8, 9e8, 1e9 }; - name = Form("ChannelRate_gDPB_%02u_0", uGdpb); - title = Form("Channel instant rate gDPB %02u; Dist[ns] ; Channel", uGdpb); - fHM->Add(name.Data(), - new TH2F( name.Data(), title.Data(), iNbBinsRate - 1, dBinsRate, - uNbFeetPlot*fNrOfChannelsPerFeet, 0, uNbFeetPlot*fNrOfChannelsPerFeet)); - if (server) - server->Register("/TofRaw", fHM->H2(name.Data())); - if( uNbFeetPlot < fNrOfFebsPerGdpb ) - { - name = Form("ChannelRate_gDPB_%02u_1", uGdpb); - title = Form("Channel instant rate gDPB %02u; Dist[ns] ; Channel", uGdpb); - fHM->Add(name.Data(), - new TH2F( name.Data(), title.Data(), iNbBinsRate - 1, dBinsRate, - uNbFeetPlot*fNrOfChannelsPerFeet, - uNbFeetPlot*fNrOfChannelsPerFeet, - 2*uNbFeetPlot*fNrOfChannelsPerFeet)); - if (server) - server->Register("/TofRaw", fHM->H2(name.Data())); - } // if( uNbFeetPlot < fNrOfFebsPerGdpb ) - if( 2 * uNbFeetPlot < fNrOfFebsPerGdpb ) - { - name = Form("ChannelRate_gDPB_%02u_2", uGdpb); - title = Form("Channel instant rate gDPB %02u; Dist[ns] ; Channel", uGdpb); - fHM->Add(name.Data(), - new TH2F( name.Data(), title.Data(), iNbBinsRate - 1, dBinsRate, - uNbFeetPlot*fNrOfChannelsPerFeet, - 2*uNbFeetPlot*fNrOfChannelsPerFeet, - 3*uNbFeetPlot*fNrOfChannelsPerFeet)); - if (server) - server->Register("/TofRaw", fHM->H2(name.Data())); - } // if( 2 * uNbFeetPlot < fNrOfFebsPerGdpb ) - - LOG(info) << "Adding the rate histos"; - } // for( UInt_t uGdpb = 0; uGdpb < fuMinNbGdpb; uGdpb ++) - } - - if( fbPulserMode ) - { - // Full Fee time difference test - UInt_t uNbBinsDt = kuNbBinsDt + 1; // To account for extra bin due to shift by 1/2 bin of both ranges - - if( fbGet4v20 && !fbGet4M24b ) - { - Double_t dBinSzG4v2 = (6250. / 112.); - dMinDt = -1.*(kuNbBinsDt*dBinSzG4v2/2.) - dBinSzG4v2/2.; - dMaxDt = 1.*(kuNbBinsDt*dBinSzG4v2/2.) + dBinSzG4v2/2.; - } // if( fbGet4v20 && fbGet4M24b ) - - for( UInt_t uChanFeeA = 0; uChanFeeA < fNrOfChannelsPerFeet; uChanFeeA++) - { - for( UInt_t uChanFeeB = uChanFeeA + 1; uChanFeeB < fNrOfChannelsPerFeet; uChanFeeB++) - { - fhTimeDiffPulserChosenFee.push_back( - new TH1I( - Form("hTimeDiffPulserChosenFee_%03u_%03u", uChanFeeA, uChanFeeB), - Form("Time difference for channels %03u and %03u in chosen Fee; DeltaT [ps]; Counts", - uChanFeeA, uChanFeeB), - uNbBinsDt, dMinDt, dMaxDt) ); - if (server) - server->Register("/TofFt", fhTimeDiffPulserChosenFee[ fhTimeDiffPulserChosenFee.size() - 1] ); - } // for any unique pair of channel in chosen Fee - } // for( UInt_t uChanFeeA = 0; uChanFeeA < kuNbChanFee; uChanFeeA++) - - // Selected channels test - fhTimeDiffPulserChosenChPairs.resize( kuNbChanTest - 1 ); - for( UInt_t uChan = 0; uChan < kuNbChanTest - 1; uChan++) - { - fhTimeDiffPulserChosenChPairs[uChan] = new TH1I( - Form("hTimeDiffPulserChosenChPairs_%03u_%03u", fuPulserChan[uChan], fuPulserChan[uChan+1]), - Form("Time difference for selected channels %03u and %03u in the first gDPB; DeltaT [ps]; Counts", - fuPulserChan[uChan], fuPulserChan[uChan+1]), - uNbBinsDt, dMinDt, dMaxDt); - if (server) - server->Register("/TofRaw", fhTimeDiffPulserChosenChPairs[uChan] ); - } // for( UInt_t uChan = 0; uChan < kuNbChanTest - 1; uChan++) - - name = "hTimeRmsPulserChosenFee"; - fhTimeRmsPulserChosenFee = new TH2D( name.Data(), - "Time difference RMS for any channels pair in chosen Fee; Ch A; Ch B; RMS [ps]", - fNrOfChannelsPerFeet - 1, -0.5, fNrOfChannelsPerFeet - 1.5, - fNrOfChannelsPerFeet - 1, 0.5, fNrOfChannelsPerFeet - 0.5); - fHM->Add( name.Data(), fhTimeRmsPulserChosenFee); - if (server) - server->Register("/TofRaw", fHM->H2( name.Data() ) ); - - name = "hTimeRmsPulserChosenChPairs"; - fhTimeRmsPulserChosenChPairs = new TH1D( name.Data(), - "Time difference RMS for chosen channels pairs; Pair # ; [ps]", - kuNbChanTest - 1, -0.5, kuNbChanTest - 1.5); - fHM->Add( name.Data(), fhTimeRmsPulserChosenChPairs); - if (server) - server->Register("/TofRaw", fHM->H1( name.Data() ) ); - - name = "hTimeRmsZoomPulsChosenFee"; - fhTimeRmsZoomPulsChosenFee = new TH2D( name.Data(), - "Time difference RMS after zoom for any channels pair in chosen Fee; Ch A; Ch B; RMS [ps]", - fNrOfChannelsPerFeet - 1, -0.5, fNrOfChannelsPerFeet - 1.5, - fNrOfChannelsPerFeet - 1, 0.5, fNrOfChannelsPerFeet - 0.5); - fHM->Add( name.Data(), fhTimeRmsZoomPulsChosenFee); - if (server) - server->Register("/TofRaw", fHM->H2( name.Data() ) ); - - name = "hTimeRmsZoomFitPulsChosenChPairs"; - fhTimeRmsZoomFitPulsChosenChPairs = new TH1D( name.Data(), - "Time difference RMS after zoom for chosen channels pairs; Pair # ; RMS [ps]", - kuNbChanTest - 1, -0.5, kuNbChanTest - 1.5); - fHM->Add( name.Data(), fhTimeRmsZoomFitPulsChosenChPairs); - if (server) - server->Register("/TofRaw", fHM->H1( name.Data() ) ); - - name = "hTimeResFitPulsChosenFee"; - fhTimeResFitPulsChosenFee = new TH2D( name.Data(), - "Time difference Res from fit for any channels pair in chosen Fee; Ch A; Ch B; Sigma [ps]", - fNrOfChannelsPerFeet - 1, -0.5, fNrOfChannelsPerFeet - 1.5, - fNrOfChannelsPerFeet - 1, 0.5, fNrOfChannelsPerFeet - 0.5); - fHM->Add( name.Data(), fhTimeResFitPulsChosenFee); - if (server) - server->Register("/TofRaw", fHM->H2( name.Data() ) ); - - name = "hTimeResFitPulsChosenChPairs"; - fhTimeResFitPulsChosenChPairs = new TH1D( name.Data(), - "Time difference Res from fit for chosen channels pairs; Pair # ; Sigma [ps]", - kuNbChanTest - 1, -0.5, kuNbChanTest - 1.5); - fHM->Add( name.Data(), fhTimeResFitPulsChosenChPairs); - if (server) - server->Register("/TofRaw", fHM->H1( name.Data() ) ); - } // if( fbPulserMode ) - - if( fbGet4M24b ) - { - fviFtLastRise24b.resize( fNrOfGdpbs * fNrOfFebsPerGdpb ); - fviFtLastFall24b.resize( fNrOfGdpbs * fNrOfFebsPerGdpb ); - fvdTimeLastRise24b.resize( fNrOfGdpbs * fNrOfFebsPerGdpb ); - fvdTimeLastFall24b.resize( fNrOfGdpbs * fNrOfFebsPerGdpb ); - } // if( fbGet4M24b ) - - for (UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; uGdpb++) { - name = Form("Raw_Tot_gDPB_%02u_0", uGdpb); - title = Form("Raw TOT gDPB %02u RPC 0; channel; TOT [bin]", uGdpb); - fHM->Add(name.Data(), - new TH2F(name.Data(), title.Data(), - uNbFeetPlot*fNrOfChannelsPerFeet, - 0*uNbFeetPlot*fNrOfChannelsPerFeet, - 1*uNbFeetPlot*fNrOfChannelsPerFeet, - 256, 0, 256)); - if (server) - server->Register("/TofRaw", fHM->H2(name.Data())); - - if( uNbFeetPlot < fNrOfFebsPerGdpb ) - { - name = Form("Raw_Tot_gDPB_%02u_1", uGdpb); - title = Form("Raw TOT gDPB %02u RPC 1; channel; TOT [bin]", uGdpb); - fHM->Add(name.Data(), - new TH2F(name.Data(), title.Data(), - uNbFeetPlot*fNrOfChannelsPerFeet, - 1*uNbFeetPlot*fNrOfChannelsPerFeet, - 2*uNbFeetPlot*fNrOfChannelsPerFeet, - 256, 0, 256)); - if (server) - server->Register("/TofRaw", fHM->H2(name.Data())); - } // if( uNbFeetPlot < fNrOfFebsPerGdpb ) - - if( 2 * uNbFeetPlot < fNrOfFebsPerGdpb ) - { - name = Form("Raw_Tot_gDPB_%02u_2", uGdpb); - title = Form("Raw TOT gDPB %02u RPC 2; channel; TOT [bin]", uGdpb); - fHM->Add(name.Data(), - new TH2F(name.Data(), title.Data(), - uNbFeetPlot*fNrOfChannelsPerFeet, - 2*uNbFeetPlot*fNrOfChannelsPerFeet, - 3*uNbFeetPlot*fNrOfChannelsPerFeet, - 256, 0, 256)); - if (server) - server->Register("/TofRaw", fHM->H2(name.Data())); - } // if( 2 * uNbFeetPlot < fNrOfFebsPerGdpb ) - - name = Form("ChCount_gDPB_%02u", uGdpb); - title = Form("Channel counts gDPB %02u; channel; Hits", uGdpb); - fHM->Add(name.Data(), new TH1I(name.Data(), title.Data(), - fNrOfFebsPerGdpb*fNrOfChannelsPerFeet, 0, fNrOfFebsPerGdpb*fNrOfChannelsPerFeet)); - - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - - if( fbGet4M24b ) - { - name = Form("ChCountFall_gDPB_%02u", uGdpb); - title = Form("Channel falling edge counts gDPB %02u; channel; Hits", uGdpb); - fHM->Add(name.Data(), new TH1I(name.Data(), title.Data(), - fNrOfFebsPerGdpb*fNrOfChannelsPerFeet, 0, fNrOfFebsPerGdpb*fNrOfChannelsPerFeet)); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - } // if( fbGet4M24b ) - - for (UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; uFeet++) { - name = Form("FeetRate_gDPB_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "Counts per second in Feet %1u of gDPB %02u; Time[s] ; Counts", uFeet, - uGdpb); - fHM->Add(name.Data(), new TH1F(name.Data(), title.Data(), fuHistoryHistoSize, 0, fuHistoryHistoSize)); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - - name = Form("FeetErrorRate_gDPB_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "Error Counts per second in Feet %1u of gDPB %02u; Time[s] ; Error Counts", uFeet, - uGdpb); - fHM->Add(name.Data(), new TH1F(name.Data(), title.Data(), fuHistoryHistoSize, 0, fuHistoryHistoSize)); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - - name = Form("FeetRateLong_gDPB_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "Counts per minutes in Feet %1u of gDPB %02u; Time[min] ; Counts", uFeet, - uGdpb); - fHM->Add(name.Data(), new TH1F(name.Data(), title.Data(), fuHistoryHistoSizeLong, 0, fuHistoryHistoSizeLong)); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - - name = Form("FeetErrorRateLong_gDPB_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "Error Counts per minutes in Feet %1u of gDPB %02u; Time[min] ; Error Counts", uFeet, - uGdpb); - fHM->Add(name.Data(), new TH1F(name.Data(), title.Data(), fuHistoryHistoSizeLong, 0, fuHistoryHistoSizeLong)); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - - if( 0 < fiBinSizeDatePlots && 0 < fiRunStartDateTimeSec ) { - name = Form("FeetRateDate_gDPB_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "Counts per second in Feet %1u of gDPB %02u; Time[s] ; Counts", uFeet, - uGdpb); - fHM->Add(name.Data(), new TH1F(name.Data(), title.Data(), (5400 / fiBinSizeDatePlots), -10, 5400 - 10)); - ( fHM->H1(name.Data()) )->GetXaxis()->SetTimeDisplay(1); - ( fHM->H1(name.Data()) )->GetXaxis()->SetTimeOffset( fiRunStartDateTimeSec ); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - } // if( 0 < fiBinSizeDatePlots && 0 < fiRunStartDateTimeSec ) - - name = Form("FtDistribPerCh_gDPB_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "FT distribution per channel in Feet %1u of gDPB %02u; Channel [] ; FT [bin]; Counts []", uFeet, - uGdpb); - fHM->Add(name.Data(), new TH2I( name.Data(), title.Data(), - fNrOfChannelsPerFeet, 0, fNrOfChannelsPerFeet, - get4v1x::kuFineCounterSize, 0, get4v1x::kuFineCounterSize)); - if (server) - server->Register("/TofRaw", fHM->H2(name.Data())); - - - name = Form("SelChFtNormDnlRise_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "normalized FT distribution for selected channel, rising edge, in Feet %1u of gDPB %02u; FT Rise [bin]; DNL []", uFeet, - uGdpb); - fHM->Add(name.Data(), new TH1D( name.Data(), title.Data(), - get4v1x::kuFineCounterSize, 0, get4v1x::kuFineCounterSize)); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - - name = Form("FtNormDnlMinRise_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "Minimum of normalized FT distribution per channel, rising edge, in Feet %1u of gDPB %02u; channel []; DNL Min []", uFeet, - uGdpb); - fHM->Add(name.Data(), new TH1D( name.Data(), title.Data(), - fNrOfChannelsPerFeet, 0, fNrOfChannelsPerFeet )); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - - name = Form("FtNormDnlMaxRise_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "maximum of normalized FT distribution per channel, rising edge, in Feet %1u of gDPB %02u; channel []; DNL Max []", uFeet, - uGdpb); - fHM->Add(name.Data(), new TH1D( name.Data(), title.Data(), - fNrOfChannelsPerFeet, 0, fNrOfChannelsPerFeet )); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - -/// ----------------------> INL plots - name = Form("SelChFtNormInlRise_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "INL distribution for selected channel, rising edge, in Feet %1u of gDPB %02u; FT Rise [bin]; INL []", uFeet, - uGdpb); - fHM->Add(name.Data(), new TH1D( name.Data(), title.Data(), - get4v1x::kuFineCounterSize, 0, get4v1x::kuFineCounterSize)); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - - name = Form("FtNormInlMinRise_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "Minimum of INL distribution per channel, rising edge, in Feet %1u of gDPB %02u; channel []; INL Min []", uFeet, - uGdpb); - fHM->Add(name.Data(), new TH1D( name.Data(), title.Data(), - fNrOfChannelsPerFeet, 0, fNrOfChannelsPerFeet )); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - - name = Form("FtNormInlMaxRise_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "maximum of INL distribution per channel, rising edge, in Feet %1u of gDPB %02u; channel []; INL Max []", uFeet, - uGdpb); - fHM->Add(name.Data(), new TH1D( name.Data(), title.Data(), - fNrOfChannelsPerFeet, 0, fNrOfChannelsPerFeet )); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); -/// <-------------------------------- - - if( fbGet4M24b ) - { - name = Form("FtDistribPerChFall_gDPB_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "FT distribution per channel, falling edge, in Feet %1u of gDPB %02u; Channel [] ; FT Fall [bin]; Counts []", uFeet, - uGdpb); - fHM->Add(name.Data(), new TH2I( name.Data(), title.Data(), - fNrOfChannelsPerFeet, 0, fNrOfChannelsPerFeet, - get4v1x::kuFineCounterSize, 0, get4v1x::kuFineCounterSize)); - if (server) - server->Register("/TofRaw", fHM->H2(name.Data())); - - name = Form("SelChFtNormDnlFall_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "normalized FT distribution for selected channel, falling edge, in Feet %1u of gDPB %02u; FT Fall [bin]; DNL []", uFeet, - uGdpb); - fHM->Add(name.Data(), new TH1D( name.Data(), title.Data(), - get4v1x::kuFineCounterSize, 0, get4v1x::kuFineCounterSize)); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - - name = Form("FtNormDnlMinFall_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "Minimum of normalized FT distribution per channel, falling edge, in Feet %1u of gDPB %02u; channel []; DNL Min []", uFeet, - uGdpb); - fHM->Add(name.Data(), new TH1D( name.Data(), title.Data(), - fNrOfChannelsPerFeet, 0, fNrOfChannelsPerFeet )); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - - name = Form("FtNormDnlMaxFall_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "maximum of normalized FT distribution per channel, falling edge, in Feet %1u of gDPB %02u; channel []; DNL Max []", uFeet, - uGdpb); - fHM->Add(name.Data(), new TH1D( name.Data(), title.Data(), - fNrOfChannelsPerFeet, 0, fNrOfChannelsPerFeet )); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - -/// ----------------------> INL plots - name = Form("SelChFtNormInlFall_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "INL distribution for selected channel, falling edge, in Feet %1u of gDPB %02u; FT Fall [bin]; INL []", uFeet, - uGdpb); - fHM->Add(name.Data(), new TH1D( name.Data(), title.Data(), - get4v1x::kuFineCounterSize, 0, get4v1x::kuFineCounterSize)); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - - name = Form("FtNormInlMinFall_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "Minimum of INL distribution per channel, falling edge, in Feet %1u of gDPB %02u; channel []; INL Min []", uFeet, - uGdpb); - fHM->Add(name.Data(), new TH1D( name.Data(), title.Data(), - fNrOfChannelsPerFeet, 0, fNrOfChannelsPerFeet )); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - - name = Form("FtNormInlMaxFall_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "maximum of INL distribution per channel, falling edge, in Feet %1u of gDPB %02u; channel []; INL Max []", uFeet, - uGdpb); - fHM->Add(name.Data(), new TH1D( name.Data(), title.Data(), - fNrOfChannelsPerFeet, 0, fNrOfChannelsPerFeet )); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); -/// <-------------------------------- - - fviFtLastRise24b[ uGdpb * fNrOfFebsPerGdpb + uFeet ].resize( fNrOfChannelsPerFeet, -1 ); - fviFtLastFall24b[ uGdpb * fNrOfFebsPerGdpb + uFeet ].resize( fNrOfChannelsPerFeet, -1 ); - fvdTimeLastRise24b[ uGdpb * fNrOfFebsPerGdpb + uFeet ].resize( fNrOfChannelsPerFeet, -1 ); - fvdTimeLastFall24b[ uGdpb * fNrOfFebsPerGdpb + uFeet ].resize( fNrOfChannelsPerFeet, -1 ); - - name = Form("FtLastRiseCurrFall_gDPB_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "FT distribution last rising vs falling edge, in Feet %1u of gDPB %02u; FT last Rise [bin] ; FT Fall [bin]; Counts []", uFeet, - uGdpb); - fHM->Add(name.Data(), new TH2I( name.Data(), title.Data(), - get4v1x::kuFineCounterSize, 0, get4v1x::kuFineCounterSize, - get4v1x::kuFineCounterSize, 0, get4v1x::kuFineCounterSize)); - if (server) - server->Register("/TofRaw", fHM->H2(name.Data())); - - name = Form("FtCurrRiseLastFall_gDPB_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "FT distribution rising vs last falling edge, in Feet %1u of gDPB %02u; FT Rise [bin] ; FT last Fall [bin]; Counts []", uFeet, - uGdpb); - fHM->Add(name.Data(), new TH2I( name.Data(), title.Data(), - get4v1x::kuFineCounterSize, 0, get4v1x::kuFineCounterSize, - get4v1x::kuFineCounterSize, 0, get4v1x::kuFineCounterSize)); - if (server) - server->Register("/TofRaw", fHM->H2(name.Data())); - - name = Form("FtLastRiseDistRise_gDPB_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "Time between rising edges vs rising edge FT, in Feet %1u of gDPB %02u; FT last Rise [] ; Trise - TriseLast[ns]; Counts []", uFeet, - uGdpb); - fHM->Add(name.Data(), new TH2I( name.Data(), title.Data(), - get4v1x::kuFineCounterSize, 0, get4v1x::kuFineCounterSize, - 500, 0.0, 25.0 )); - if (server) - server->Register("/TofRaw", fHM->H2(name.Data())); - - name = Form("FtLastRiseDistFall_gDPB_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "Time between falling edges vs rising edge FT, in Feet %1u of gDPB %02u; FT last Rise [] ; Tfall - TfallLast[ns]; Counts []", uFeet, - uGdpb); - fHM->Add(name.Data(), new TH2I( name.Data(), title.Data(), - get4v1x::kuFineCounterSize, 0, get4v1x::kuFineCounterSize, - 500, 0.0, 25.0 )); - if (server) - server->Register("/TofRaw", fHM->H2(name.Data())); - - } // if( fbGet4M24b ) - } // for( UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; uFeet ++) - - /** Real MS QA **/ - fbFirstEpochInMsFound.push_back( kFALSE ); - - name = Form("fRealMsFineQa_gDPB_%02u", uGdpb); - title = Form("QA check of epoch index in Real MS for gDPB %02u; Ms Idx []; 1st Ep Idx / MS Idx []", uGdpb); - fRealMsFineQa_gDPB.push_back( new TH1D(name.Data(), title.Data(), 10000, -0.5, 10000.0 - 0.5 ) ); - fHM->Add(name.Data(), fRealMsFineQa_gDPB[uGdpb] ); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - - name = Form("fRealMsMidQa_gDPB_%02u", uGdpb); - title = Form("QA check of epoch index in Real MS for gDPB %02u, Mid range; Ms Idx []; 1st Ep Idx / MS Idx []", uGdpb); - fRealMsMidQa_gDPB.push_back( new TProfile(name.Data(), title.Data(), 10000, -0.5, 1e6 - 0.5 ) ); - fHM->Add(name.Data(), fRealMsMidQa_gDPB[uGdpb] ); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - - name = Form("fRealMsCoarseQa_gDPB_%02u", uGdpb); - title = Form("QA check of epoch index in Real MS for gDPB %02u, Coarse range; Ms Idx []; 1st Ep Idx / MS Idx []", uGdpb); - fRealMsCoarseQa_gDPB.push_back( new TProfile(name.Data(), title.Data(), 10000, -0.5, 1e9 - 0.5 ) ); - fHM->Add(name.Data(), fRealMsCoarseQa_gDPB[uGdpb] ); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - } // for( UInt_t uGdpb = 0; uGdpb < fuMinNbGdpb; uGdpb ++) - fhTempHistInlRise = new TH1D( "TempHistInlRise", - "Temp holder for INL distribution in current channel, rising edge; FT Rise [bin]; INL []", - get4v1x::kuFineCounterSize, 0, get4v1x::kuFineCounterSize); - if( fbGet4M24b ) - fhTempHistInlFall = new TH1D( "TempHistInlFall", - "Temp holder for INL distribution in current channel, falling edge; FT Fall [bin]; INL []", - get4v1x::kuFineCounterSize, 0, get4v1x::kuFineCounterSize); - - ///* ASIC coincidences & offsets mapping */// -/* - fvulHitEpochBuffLastTs.resize(fNrOfGet4); //! Dims: [gDPB][hits] - for( UInt_t uAsicA = 0; uAsicA < fNrOfGet4 - 1; uAsicA ++ ) - { - name = Form("fvhCoincOffsetEpochGet4__g%03u", uAsicA); - title = Form( - "Distance in epoch between hits in Get4 %03u and hits in another Get4 ASIC in same TS; GET4 B index [] ; Hit B - Hit A [Epoch]; Counts []", - uAsicA ); - TH2* ph2 = new TH2I( name.Data(), title.Data(), - fNrOfGet4 - uAsicA - 1, uAsicA + 1, fNrOfGet4, - 20000, -10000, 10000 - ); - fvhCoincOffsetEpochGet4.push_back( ph2 ); - - fHM->Add( name.Data(), ph2 ); - if (server) - server->Register("/TofCoinc", fHM->H2(name.Data())); - } // for( UInt_t uAsicA = 0; uAsicA < fNrOfGet4 - 1; uAsicA ++ ) -*/ - - name = "hSpill"; - title = "Counts per channel in Current Spill; X [Strip]; Y [End]; Counts"; - TH2I* hSpill = new TH2I(name, title, fNrOfChannelsPerFeet, 0., fNrOfChannelsPerFeet, 2, 0., 2.); - fHM->Add(name.Data(), hSpill); - if (server) - server->Register("/TofRaw", fHM->H2(name.Data())); - - name = "hSpillLength"; - title = "Length of spill interval as found from detectors; Length [s]; Counts"; - TH1* hSpillLength = new TH1F(name, title, 3000, 0., 300.); - fHM->Add(name.Data(), hSpillLength); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - - name = "hSpillCount"; - title = "Total counts in detector in each spill; Spill; Counts"; - TH1* hSpillCount = new TH1F(name, title, 300, 0., 300.); - fHM->Add(name.Data(), hSpillCount); - if (server) - server->Register("/TofRaw", fHM->H1(name.Data())); - - name = "hSpillQA"; - title = "Total counts in detector per spill VS Spill length; Length [s]; Counts"; - TH2* hSpillQA = new TH2F(name, title, 120, 0., 120., 150, 0., 150000.); - fHM->Add(name.Data(), hSpillQA); - if (server) - server->Register("/TofRaw", fHM->H2(name.Data())); - - name = "hTokenMsgType"; - title = "STAR trigger Messages type; Type ; Counts"; - fhTokenMsgType = new TH1F(name, title, 4, 0, 4); - fhTokenMsgType->GetXaxis()->SetBinLabel( 1, "A"); // gDPB TS high - fhTokenMsgType->GetXaxis()->SetBinLabel( 2, "B"); // gDPB TS low, STAR TS high - fhTokenMsgType->GetXaxis()->SetBinLabel( 3, "C"); // STAR TS mid - fhTokenMsgType->GetXaxis()->SetBinLabel( 4, "D"); // STAR TS low, token, CMDs - fHM->Add(name.Data(), fhTokenMsgType); - if (server) - server->Register("/StarRaw", fHM->H1(name.Data())); - - name = "hTriggerRate"; - title = "STAR trigger signals per second; Time[s] ; Counts"; - fhTriggerRate = new TH1F(name, title, fuHistoryHistoSize, 0, fuHistoryHistoSize); - fHM->Add(name.Data(), fhTriggerRate); - if (server) - server->Register("/StarRaw", fHM->H1(name.Data())); - - name = "hCmdDaqVsTrig"; - title = "STAR daq command VS STAR trigger command; DAQ ; TRIGGER"; - fhCmdDaqVsTrig = new TH2I(name, title, 16, 0, 16, 16, 0, 16 ); - fhCmdDaqVsTrig->GetXaxis()->SetBinLabel( 1, "0x0: no-trig "); // idle link - fhCmdDaqVsTrig->GetXaxis()->SetBinLabel( 2, "0x1: clear "); // clears redundancy counters on the readout boards - fhCmdDaqVsTrig->GetXaxis()->SetBinLabel( 3, "0x2: mast-rst"); // general reset of the whole front-end logic - fhCmdDaqVsTrig->GetXaxis()->SetBinLabel( 4, "0x3: spare "); // reserved - fhCmdDaqVsTrig->GetXaxis()->SetBinLabel( 5, "0x4: trigg. 0"); // Default physics readout, all det support required - fhCmdDaqVsTrig->GetXaxis()->SetBinLabel( 6, "0x5: trigg. 1"); // - fhCmdDaqVsTrig->GetXaxis()->SetBinLabel( 7, "0x6: trigg. 2"); // - fhCmdDaqVsTrig->GetXaxis()->SetBinLabel( 8, "0x7: trigg. 3"); // - fhCmdDaqVsTrig->GetXaxis()->SetBinLabel( 9, "0x8: puls. 0"); // - fhCmdDaqVsTrig->GetXaxis()->SetBinLabel(10, "0x9: puls. 1"); // - fhCmdDaqVsTrig->GetXaxis()->SetBinLabel(11, "0xA: puls. 2"); // - fhCmdDaqVsTrig->GetXaxis()->SetBinLabel(12, "0xB: puls. 3"); // - fhCmdDaqVsTrig->GetXaxis()->SetBinLabel(13, "0xC: config "); // housekeeping trigger: return geographic info of FE - fhCmdDaqVsTrig->GetXaxis()->SetBinLabel(14, "0xD: abort "); // aborts and clears an active event - fhCmdDaqVsTrig->GetXaxis()->SetBinLabel(15, "0xE: L1accept"); // - fhCmdDaqVsTrig->GetXaxis()->SetBinLabel(16, "0xF: L2accept"); // - fhCmdDaqVsTrig->GetYaxis()->SetBinLabel( 1, "0x0: 0"); // To be filled at STAR - fhCmdDaqVsTrig->GetYaxis()->SetBinLabel( 2, "0x1: 1"); // To be filled at STAR - fhCmdDaqVsTrig->GetYaxis()->SetBinLabel( 3, "0x2: 2"); // To be filled at STAR - fhCmdDaqVsTrig->GetYaxis()->SetBinLabel( 4, "0x3: 3"); // To be filled at STAR - fhCmdDaqVsTrig->GetYaxis()->SetBinLabel( 5, "0x4: 4"); // To be filled at STAR - fhCmdDaqVsTrig->GetYaxis()->SetBinLabel( 6, "0x5: 5"); // To be filled at STAR - fhCmdDaqVsTrig->GetYaxis()->SetBinLabel( 7, "0x6: 6"); // To be filled at STAR - fhCmdDaqVsTrig->GetYaxis()->SetBinLabel( 8, "0x7: 7"); // To be filled at STAR - fhCmdDaqVsTrig->GetYaxis()->SetBinLabel( 9, "0x8: 8"); // To be filled at STAR - fhCmdDaqVsTrig->GetYaxis()->SetBinLabel(10, "0x9: 9"); // To be filled at STAR - fhCmdDaqVsTrig->GetYaxis()->SetBinLabel(11, "0xA: 10"); // To be filled at STAR - fhCmdDaqVsTrig->GetYaxis()->SetBinLabel(12, "0xB: 11"); // To be filled at STAR - fhCmdDaqVsTrig->GetYaxis()->SetBinLabel(13, "0xC: 12"); // To be filled at STAR - fhCmdDaqVsTrig->GetYaxis()->SetBinLabel(14, "0xD: 13"); // To be filled at STAR - fhCmdDaqVsTrig->GetYaxis()->SetBinLabel(15, "0xE: 14"); // To be filled at STAR - fhCmdDaqVsTrig->GetYaxis()->SetBinLabel(16, "0xF: 15"); // To be filled at STAR - fHM->Add(name.Data(), fhCmdDaqVsTrig); - if (server) - server->Register("/StarRaw", fHM->H2(name.Data())); - - name = "hStarTokenEvo"; - title = "STAR token value VS time; Time in Run [s] ; STAR Token; Counts"; - fhStarTokenEvo = new TH2I(name, title, fuHistoryHistoSize, 0, fuHistoryHistoSize, 410, 0, 4100 ); // 4096 - fHM->Add(name.Data(), fhStarTokenEvo); - if (server) - server->Register("/StarRaw", fHM->H2(name.Data())); - - if (server) - { - server->RegisterCommand("/Reset_All_TOF", "bResetTofStarMoniHistos=kTRUE"); - server->RegisterCommand("/Save_All_Tof", "bSaveTofStarMoniHistos=kTRUE"); - - server->RegisterCommand("/Update_Norm_FT", "bTofUpdateNormedFtMoni=kTRUE"); - - if( fbPulserMode ) - server->RegisterCommand("/Update_Zoom_Fit", "bTofUpdateZoomedFitMoni=kTRUE"); - - - server->Restrict("/Reset_All_TOF", "allow=admin"); - server->Restrict("/Save_All_Tof", "allow=admin"); - } // if (server) - - LOG(info) << "Done with histo creation, now doing canvases"; - - /** Create summary Canvases for STAR 2017 **/ - Double_t w = 10; - Double_t h = 10; - TCanvas* cSummary = new TCanvas("cSummary", "gDPB Monitoring Summary", w, h); - cSummary->Divide(2, 3); - - // 1st Column: Messages types - cSummary->cd(1); - gPad->SetLogy(); - hMessageType->Draw(); - - cSummary->cd(2); - gPad->SetLogy(); - hSysMessType->Draw(); - - cSummary->cd(3); - gPad->SetLogz(); - hGet4MessType->Draw("colz"); - - // 2nd Column: GET4 Errors + Epoch flags + - cSummary->cd(4); - gPad->SetLogz(); - hGet4ChanErrors->Draw("colz"); - - cSummary->cd(5); - gPad->SetLogz(); - hGet4EpochFlags->Draw("colz"); - - cSummary->cd(6); - hSpill->Draw("col text"); - /*****************************/ - - - /** Create FEET rates Canvas for STAR 2017 **/ - TCanvas* cFeeRates = new TCanvas("cFeeRates", "gDPB Monitoring FEET rates", w, h); - cFeeRates->Divide(fNrOfFebsPerGdpb, fNrOfGdpbs ); - - TH1* histPnt = NULL; - for( UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; ++uGdpb ) { - for (UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; ++uFeet ) { - name = Form("FeetRate_gDPB_g%02u_f%1u", uGdpb, uFeet); - histPnt = fHM->H1(name.Data()); - - cFeeRates->cd( 1 + uGdpb * fNrOfFebsPerGdpb + uFeet ); - gPad->SetLogy(); - - histPnt->Draw(); - - name = Form("FeetErrorRate_gDPB_g%02u_f%1u", uGdpb, uFeet); - histPnt = fHM->H1(name.Data()); - histPnt->SetLineColor( kRed ); - histPnt->Draw("same"); - } // for (UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; ++uFeet ) - } // for( UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; ++uGdpb ) - /*****************************/ - - - /** Create FEET rates long Canvas for STAR 2017 **/ - TCanvas* cFeeRatesLong = new TCanvas("cFeeRatesLong", "gDPB Monitoring FEET rates", w, h); - cFeeRatesLong->Divide(fNrOfFebsPerGdpb, fNrOfGdpbs ); - - histPnt = NULL; - for( UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; ++uGdpb ) { - for (UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; ++uFeet ) { - name = Form("FeetRateLong_gDPB_g%02u_f%1u", uGdpb, uFeet); - histPnt = fHM->H1(name.Data()); - - cFeeRatesLong->cd( 1 + uGdpb * fNrOfFebsPerGdpb + uFeet ); - gPad->SetLogy(); - - histPnt->Draw(); - - name = Form("FeetErrorRateLong_gDPB_g%02u_f%1u", uGdpb, uFeet); - histPnt = fHM->H1(name.Data()); - histPnt->SetLineColor( kRed ); - histPnt->Draw("same"); - } // for (UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; ++uFeet ) - } // for( UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; ++uGdpb ) - /*****************************/ - - /** Create TOT Canvas(es) for STAR 2017 **/ - TCanvas* cTotPnt = NULL; - uNbFeetPlotsPerGdpb = fNrOfFebsPerGdpb/uNbFeetPlot + ( 0 != fNrOfFebsPerGdpb%uNbFeetPlot ? 1 : 0 ); - for( UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; ++uGdpb ) { - - cTotPnt = new TCanvas( Form("cTotPnt_g%02u", uGdpb), - Form("gDPB %02u TOT distributions", uGdpb), - w, h); - cTotPnt->Divide( uNbFeetPlotsPerGdpb ); - TH2* histPntTot = NULL; - for (UInt_t uFeetPlot = 0; - uFeetPlot < uNbFeetPlotsPerGdpb; - ++uFeetPlot ) { - name = Form("Raw_Tot_gDPB_%02u_%1u", uGdpb, uFeetPlot); - histPntTot = fHM->H2(name.Data()); - - cTotPnt->cd( 1 + uFeetPlot ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - - histPntTot->Draw( "colz" ); - } // for (UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; ++uFeet ) - } // for( UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; ++uGdpb ) - /*****************************/ - - /** Create FT Canvas(es) for STAR 2017 **/ - TCanvas* cFtPnt = NULL; - for( UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; ++uGdpb ) { - - cFtPnt = new TCanvas( Form("cFtPnt_g%02u", uGdpb), - Form("gDPB %02u FineTime distributions", uGdpb), - w, h); - cFtPnt->Divide( fNrOfFebsPerGdpb ); - TH2* histPntFt = NULL; - for( UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; uFeet ++) { - name = Form("FtDistribPerCh_gDPB_g%02u_f%1u", uGdpb, uFeet); - histPntFt = fHM->H2(name.Data()); - - cFtPnt->cd( 1 + uFeet ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - - histPntFt->Draw( "colz" ); - } // for (UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; ++uFeet ) - } // for( UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; ++uGdpb ) - /*****************************/ - - - /** Create 24b mode Canvas(es) for STAR 2017 **/ - if( fbGet4M24b ) - { - TCanvas* cFt24b = NULL; - TCanvas* cFt24b_Dnl = NULL; - TCanvas* cFt24b_Inl = NULL; - for( UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; ++uGdpb ) { - - cFt24b = new TCanvas( Form("cFt24b_g%02u_f0", uGdpb), - Form("gDPB %02u Feet 0 24b mode FineTime distributions", uGdpb), - w, h); - cFt24b->Divide( 2, 4 ); - - cFt24b->cd( 1 ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - name = Form("FtDistribPerCh_gDPB_g%02u_f%1u", uGdpb, 0); - fHM->H2(name.Data())->Draw( "colz" ); - - cFt24b->cd( 2 ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - name = Form("FtDistribPerChFall_gDPB_g%02u_f%1u", uGdpb, 0); - fHM->H2(name.Data())->Draw( "colz" ); - - cFt24b->cd( 3 ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); -// name = Form("ChCount_gDPB_%02u", uGdpb); - name = Form("SelChFtNormDnlRise_g%02u_f%1u", uGdpb, 0); - fHM->H1(name.Data())->Draw(); - - cFt24b->cd( 4 ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); -// name = Form("ChCountFall_gDPB_%02u", uGdpb); - name = Form("SelChFtNormDnlFall_g%02u_f%1u", uGdpb, 0); - fHM->H1(name.Data())->Draw(); - - cFt24b->cd( 5 ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - name = Form("FtLastRiseCurrFall_gDPB_g%02u_f%1u", uGdpb, 0); - fHM->H2(name.Data())->Draw( "colz" ); - - cFt24b->cd( 6 ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - name = Form("FtCurrRiseLastFall_gDPB_g%02u_f%1u", uGdpb, 0); - fHM->H2(name.Data())->Draw( "colz" ); - - cFt24b->cd( 7 ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - name = Form("FtLastRiseDistRise_gDPB_g%02u_f%1u", uGdpb, 0); - fHM->H2(name.Data())->Draw( "colz" ); - - cFt24b->cd( 8 ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - name = Form("FtLastRiseDistFall_gDPB_g%02u_f%1u", uGdpb, 0); - fHM->H2(name.Data())->Draw( "colz" ); - - - cFt24b_Dnl = new TCanvas( Form("cFt24bDnl_g%02u_f0", uGdpb), - Form("gDPB %02u Feet 0 24b mode FineTime DNL min/max distributions", uGdpb), - w, h); - cFt24b_Dnl->Divide( 2, 2 ); - - cFt24b_Dnl->cd( 1 ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - name = Form("FtNormDnlMinRise_g%02u_f%1u", uGdpb, 0); - fHM->H1(name.Data())->Draw(); - - cFt24b_Dnl->cd( 2 ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - name = Form("FtNormDnlMaxRise_g%02u_f%1u", uGdpb, 0); - fHM->H1(name.Data())->Draw(); - - cFt24b_Dnl->cd( 3 ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - name = Form("FtNormDnlMinFall_g%02u_f%1u", uGdpb, 0); - fHM->H1(name.Data())->Draw(); - - cFt24b_Dnl->cd( 4 ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - name = Form("FtNormDnlMaxFall_g%02u_f%1u", uGdpb, 0); - fHM->H1(name.Data())->Draw(); - - cFt24b_Inl = new TCanvas( Form("cFt24bInl_g%02u_f0", uGdpb), - Form("gDPB %02u Feet 0 24b mode FineTime INL min/max distributions", uGdpb), - w, h); - cFt24b_Inl->Divide( 2, 2 ); - - cFt24b_Inl->cd( 1 ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - name = Form("FtNormInlMinRise_g%02u_f%1u", uGdpb, 0); - fHM->H1(name.Data())->Draw(); - - cFt24b_Inl->cd( 2 ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - name = Form("FtNormInlMaxRise_g%02u_f%1u", uGdpb, 0); - fHM->H1(name.Data())->Draw(); - - cFt24b_Inl->cd( 3 ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - name = Form("FtNormInlMinFall_g%02u_f%1u", uGdpb, 0); - fHM->H1(name.Data())->Draw(); - - cFt24b_Inl->cd( 4 ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - name = Form("FtNormInlMaxFall_g%02u_f%1u", uGdpb, 0); - fHM->H1(name.Data())->Draw(); - } // for( UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; ++uGdpb ) - } // if( fbGet4M24b ) - /*****************************/ - - /** Create 32b mode Canvas(es) for STAR 2017 **/ - else - { - TCanvas* cFt32b = NULL; - for( UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; ++uGdpb ) { - - cFt32b = new TCanvas( Form("cFt32b_g%02u_f0", uGdpb), - Form("gDPB %02u Feet 0 32b mode FineTime, DNL & INL distributions", uGdpb), - w, h); - cFt32b->Divide( 2, 3 ); - - cFt32b->cd( 1 ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - name = Form("SelChFtNormDnlRise_g%02u_f%1u", uGdpb, 0); - fHM->H1(name.Data())->Draw("hist"); - - cFt32b->cd( 2 ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - name = Form("SelChFtNormInlRise_g%02u_f%1u", uGdpb, 0); - fHM->H1(name.Data())->Draw("hist"); - - cFt32b->cd( 3 ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - name = Form("FtNormDnlMinRise_g%02u_f%1u", uGdpb, 0); - fHM->H1(name.Data())->Draw("hist"); - - cFt32b->cd( 4 ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - name = Form("FtNormDnlMaxRise_g%02u_f%1u", uGdpb, 0); - fHM->H1(name.Data())->Draw("hist"); - - cFt32b->cd( 5 ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - name = Form("FtNormInlMinRise_g%02u_f%1u", uGdpb, 0); - fHM->H1(name.Data())->Draw("hist"); - - cFt32b->cd( 6 ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - name = Form("FtNormInlMaxRise_g%02u_f%1u", uGdpb, 0); - fHM->H1(name.Data())->Draw("hist"); - } // for( UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; ++uGdpb ) - } // else of if( fbGet4M24b ) - /*****************************/ - - /** Create Pulser mode Canvas for STAR 2017 **/ - if( fbPulserMode ) - { - TCanvas* cPulserRms = new TCanvas("cPulserRms", "Time difference RMS for chosen FEE and channels in pulser mode", w, h); - cPulserRms->Divide( 2 ); - - cPulserRms->cd(1); - fhTimeRmsPulserChosenFee->Draw( "colz" ); - - cPulserRms->cd(2); - fhTimeRmsPulserChosenChPairs->Draw( "hist" ); - - TCanvas* cPulserFit = new TCanvas("cPulserFit", "Time difference Res from fit for chosen FEE and channels in pulser mode", w, h); - cPulserFit->Divide( 2, 2 ); - - cPulserFit->cd(1); - fhTimeRmsZoomPulsChosenFee->Draw( "colz" ); - - cPulserFit->cd(2); - fhTimeRmsZoomFitPulsChosenChPairs->Draw( "hist" ); - - cPulserFit->cd(3); - fhTimeResFitPulsChosenFee->Draw( "colz" ); - - cPulserFit->cd(4); - fhTimeResFitPulsChosenChPairs->Draw( "hist" ); - } // if( fbPulserMode ) - /*****************************/ - - /** Create STAR token Canvas for STAR 2017 **/ - TCanvas* cStarToken = new TCanvas("cStarToken", "STAR token detection info", w, h); - cStarToken->Divide( 2, 2 ); - - cStarToken->cd(1); - fhTriggerRate->Draw(); - - cStarToken->cd(2); - fhCmdDaqVsTrig->Draw( "colz" ); - - cStarToken->cd(3); - fhStarTokenEvo->Draw(); - /*****************************/ - - - /** Recovers/Create Ms Size Canvas for STAR 2017 **/ - // Try to recover canvas in case it was created already by another monitor - // If not existing, create it - fcMsSizeAll = dynamic_cast<TCanvas *>( gROOT->FindObject( "cMsSizeAll" ) ); - if( NULL == fcMsSizeAll ) - { - fcMsSizeAll = new TCanvas("cMsSizeAll", "Evolution of MS size in last 300 s", w, h); - fcMsSizeAll->Divide( 4, 4 ); - LOG(info) << "Created MS size canvas in TOF monitor"; - } // if( NULL == fcMsSizeAll ) - else LOG(info) << "Recovered MS size canvas in TOF monitor"; - /*****************************/ - - LOG(info) << "Done with canvases creation"; - - /** Store pointers to histograms for STAR 2017 **/ - fHistMessType = fHM->H1("hMessageType"); - fHistSysMessType = fHM->H1("hSysMessType"); - fHistGet4MessType = fHM->H2("hGet4MessType"); - fHistGet4ChanScm = fHM->H2("hGet4ChanScm"); - fHistGet4ChanErrors = fHM->H2("hGet4ChanErrors"); - fHistGet4EpochFlags = fHM->H2("hGet4EpochFlags"); - fHistSpill = fHM->H2("hSpill"); - fHistSpillLength = fHM->H1("hSpillLength"); - fHistSpillCount = fHM->H1("hSpillCount"); - fHistSpillQA = fHM->H2("hSpillQA"); - - for (UInt_t i = 0; i < fNrOfGdpbs; ++i) { - name = Form("Raw_Tot_gDPB_%02u_0", i); - fRaw_Tot_gDPB.push_back(fHM->H2(name.Data())); - if( uNbFeetPlot < fNrOfFebsPerGdpb ) - { - name = Form("Raw_Tot_gDPB_%02u_1", i); - fRaw_Tot_gDPB.push_back(fHM->H2(name.Data())); - } // if( uNbFeetPlot < fNrOfFebsPerGdpb ) - if( 2 * uNbFeetPlot < fNrOfFebsPerGdpb ) - { - name = Form("Raw_Tot_gDPB_%02u_2", i); - fRaw_Tot_gDPB.push_back(fHM->H2(name.Data())); - } // if( 2 * uNbFeetPlot < fNrOfFebsPerGdpb ) - - name = Form("ChCount_gDPB_%02u", i); - fChCount_gDPB.push_back(fHM->H1(name.Data())); - - if( fbGet4M24b ) - { - name = Form("ChCountFall_gDPB_%02u", i); - fChCountFall_gDPB.push_back(fHM->H1(name.Data())); - } // if( fbGet4M24b ) - - if (fUnpackPar->IsChannelRateEnabled()) { - name = Form("ChannelRate_gDPB_%02u_0", i); - fChannelRate_gDPB.push_back(fHM->H2(name.Data())); - if( uNbFeetPlot < fNrOfFebsPerGdpb ) - { - name = Form("ChannelRate_gDPB_%02u_1", i); - fChannelRate_gDPB.push_back(fHM->H2(name.Data())); - } // if( uNbFeetPlot < fNrOfFebsPerGdpb ) - if( 2 * uNbFeetPlot < fNrOfFebsPerGdpb ) - { - name = Form("ChannelRate_gDPB_%02u_2", i); - fChannelRate_gDPB.push_back(fHM->H2(name.Data())); - } // if( 2 * uNbFeetPlot < fNrOfFebsPerGdpb ) - } // if (fUnpackPar->IsChannelRateEnabled()) - - for (UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; uFeet++) { - name = Form("FeetRate_gDPB_g%02u_f%1u", i, uFeet); - fFeetRate_gDPB.push_back(fHM->H1(name.Data())); - name = Form("FeetErrorRate_gDPB_g%02u_f%1u", i, uFeet); - fFeetErrorRate_gDPB.push_back(fHM->H1(name.Data())); - name = Form("FeetRateLong_gDPB_g%02u_f%1u", i, uFeet); - fFeetRateLong_gDPB.push_back(fHM->H1(name.Data())); - name = Form("FeetErrorRateLong_gDPB_g%02u_f%1u", i, uFeet); - fFeetErrorRateLong_gDPB.push_back(fHM->H1(name.Data())); - if( 0 < fiBinSizeDatePlots && 0 < fiRunStartDateTimeSec ) { - name = Form("FeetRateDate_gDPB_g%02u_f%1u", i, uFeet); - fFeetRateDate_gDPB.push_back(fHM->H1(name.Data())); - } // if( 0 < fiBinSizeDatePlots && 0 < fiRunStartDateTimeSec ) - name = Form("FtDistribPerCh_gDPB_g%02u_f%1u", i, uFeet); - fhFtDistribPerCh.push_back(fHM->H2(name.Data())); - name = Form("SelChFtNormDnlRise_g%02u_f%1u", i, uFeet); - fSelChFtNormDnlRise.push_back(fHM->H1(name.Data())); - name = Form("FtNormDnlMinRise_g%02u_f%1u", i, uFeet); - fFtNormDnlMinRise.push_back(fHM->H1(name.Data())); - name = Form("FtNormDnlMaxRise_g%02u_f%1u", i, uFeet); - fFtNormDnlMaxRise.push_back(fHM->H1(name.Data())); - name = Form("SelChFtNormInlRise_g%02u_f%1u", i, uFeet); - fSelChFtNormInlRise.push_back(fHM->H1(name.Data())); - name = Form("FtNormInlMinRise_g%02u_f%1u", i, uFeet); - fFtNormInlMinRise.push_back(fHM->H1(name.Data())); - name = Form("FtNormInlMaxRise_g%02u_f%1u", i, uFeet); - fFtNormInlMaxRise.push_back(fHM->H1(name.Data())); - - if( fbGet4M24b ) - { - name = Form("FtDistribPerChFall_gDPB_g%02u_f%1u", i, uFeet); - fhFtDistribPerChFall.push_back(fHM->H2(name.Data())); - - name = Form("SelChFtNormDnlFall_g%02u_f%1u", i, uFeet); - fSelChFtNormDnlFall.push_back(fHM->H1(name.Data())); - name = Form("FtNormDnlMinFall_g%02u_f%1u", i, uFeet); - fFtNormDnlMinFall.push_back(fHM->H1(name.Data())); - name = Form("FtNormDnlMaxFall_g%02u_f%1u", i, uFeet); - fFtNormDnlMaxFall.push_back(fHM->H1(name.Data())); - name = Form("SelChFtNormInlFall_g%02u_f%1u", i, uFeet); - fSelChFtNormInlFall.push_back(fHM->H1(name.Data())); - name = Form("FtNormInlMinFall_g%02u_f%1u", i, uFeet); - fFtNormInlMinFall.push_back(fHM->H1(name.Data())); - name = Form("FtNormInlMaxFall_g%02u_f%1u", i, uFeet); - fFtNormInlMaxFall.push_back(fHM->H1(name.Data())); - - name = Form("FtLastRiseCurrFall_gDPB_g%02u_f%1u", i, uFeet); - fhFtLastRiseCurrFall.push_back(fHM->H2(name.Data())); - name = Form("FtCurrRiseLastFall_gDPB_g%02u_f%1u", i, uFeet); - fhFtCurrRiseLastFall.push_back(fHM->H2(name.Data())); - - name = Form("FtLastRiseDistRise_gDPB_g%02u_f%1u", i, uFeet); - fhFtLastRiseDistRise.push_back(fHM->H2(name.Data())); - name = Form("FtLastRiseDistFall_gDPB_g%02u_f%1u", i, uFeet); - fhFtLastRiseDistFall.push_back(fHM->H2(name.Data())); - } // if( fbGet4M24b ) - } // for( UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; uFeet ++) - } - /*****************************/ - - LOG(info) << "Leaving CreateHistograms"; -} - -Bool_t CbmTofStarMonitor2018::DoUnpack(const fles::Timeslice& ts, - size_t component) -{ - THttpServer* server = FairRunOnline::Instance()->GetHttpServer(); - - if (bResetTofStarMoniHistos) { - LOG(info) << "Reset TOF STAR histos "; - ResetAllHistos(); - bResetTofStarMoniHistos = kFALSE; - } - if( bSaveTofStarMoniHistos ) - { - LOG(info) << "Start saving TOF STAR histos "; - SaveAllHistos( "data/histos_StarTof.root" ); - bSaveTofStarMoniHistos = kFALSE; - } // if( bSaveStsHistos ) - if (bTofUpdateNormedFtMoni) { - UpdateNormedFt(); - bTofUpdateNormedFtMoni = kFALSE; - } // if (bTofUpdateNormedFtMoni) - if (bTofUpdateZoomedFitMoni) { - UpdateZoomedFit(); - bTofUpdateZoomedFitMoni = kFALSE; - } // if (bTofUpdateZoomedFitMoni) - - ///* ASIC coincidences & offsets mapping */// -/* - if( 0 == component && fbHitsInLastTs ) - { - for( UInt_t uAsicA = 0; uAsicA < fNrOfGet4 - 1; uAsicA ++ ) - { - for( UInt_t uHitA = 0; uHitA < fvulHitEpochBuffLastTs[uAsicA].size(); uHitA ++ ) - { - for( UInt_t uAsicB = uAsicA; uAsicB < fNrOfGet4; uAsicB ++ ) - { - for( UInt_t uHitB = 0; uHitB < fvulHitEpochBuffLastTs[uAsicB].size(); uHitB ++ ) - { - fvhCoincOffsetEpochGet4[uAsicA]->Fill( uAsicB, - fvulHitEpochBuffLastTs[uAsicB][uHitB] - - fvulHitEpochBuffLastTs[uAsicA][uHitA] ); - } // for( UInt_t uHitB = 0; uHitB < fvulHitEpochBuffLastTs[uAsicB].size(); uHitB ++ ) - } // for( UInt_t uAsicA = 0; uAsicA < fNrOfGet4 - 1; uAsicA ++ ) - } // for( UInt_t uHitA = 0; uHitA < fvulHitEpochBuffLastTs[uAsicA].size(); uHitA ++ ) - fvulHitEpochBuffLastTs[uAsicA].clear(); - } // for( UInt_t uAsicA = 0; uAsicA < fNrOfGet4 - 1; uAsicA ++ ) - fvulHitEpochBuffLastTs[fNrOfGet4 - 1].clear(); - fbHitsInLastTs = kFALSE; - } // if( 0 == component && fbHitsInLastTs ) -*/ - - LOG(debug1) << "Timeslice contains " << ts.num_microslices(component) - << "microslices."; - - // Getting the pointer to the correct histogram needs a lot more time then - // the actual filling procedure. If one gets the pointer in a loop this kills - // the performance. A test shows that extracting the pointer from the CbmHistManger - // is slower by a factor of 20-100 (depending on the number of histos managed by the - // CbmHistManager) compared to using the pointer directly - // So get the pointer once outside the loop and use it in the loop - - TString sMsSzName = Form("MsSz_link_%02lu", component); - TH1* hMsSz = NULL; - TProfile* hMsSzTime = NULL; - if (fHM->Exists(sMsSzName.Data())) { - hMsSz = fHM->H1(sMsSzName.Data()); - sMsSzName = Form("MsSzTime_link_%02lu", component); - hMsSzTime = fHM->P1(sMsSzName.Data()); - } // if( fHM->Exists(sMsSzName.Data() ) ) - else { - TString sMsSzTitle = Form( - "Size of MS for gDPB of link %02lu; Ms Size [bytes]", component); - fHM->Add(sMsSzName.Data(), - new TH1F(sMsSzName.Data(), sMsSzTitle.Data(), 160000, 0., 20000.)); - hMsSz = fHM->H1(sMsSzName.Data()); - if (server) - server->Register("/FlibRaw", hMsSz); - sMsSzName = Form("MsSzTime_link_%02lu", component); - sMsSzTitle = Form( - "Size of MS vs time for gDPB of link %02lu; Time[s] ; Ms Size [bytes]", - component); - fHM->Add(sMsSzName.Data(), - new TProfile( sMsSzName.Data(), sMsSzTitle.Data(), - 100 * fuHistoryHistoSize, 0., 2 * fuHistoryHistoSize ) ); - hMsSzTime = fHM->P1(sMsSzName.Data()); - if (server) - server->Register("/FlibRaw", hMsSzTime); - if( NULL != fcMsSizeAll ) - { - fcMsSizeAll->cd( 1 + component ); - gPad->SetLogy(); - hMsSzTime->Draw("hist le0"); - } // if( NULL != fcMsSizeAll ) - LOG(info) << "Added MS size histo for component: " << component << " (gDPB)"; - } // else of if( fHM->Exists(sMsSzName.Data() ) ) - - // Initialize spill detection - fiCountsLastTs = 0; - - Int_t messageType = -111; - Double_t dTsStartTime = -1; - // Loop over microslices - size_t numCompMsInTs = ts.num_microslices(component); - for (size_t m = 0; m < numCompMsInTs; ++m) { - if (fuMsAcceptsPercent < m) - continue; - - constexpr uint32_t kuBytesPerMessage = 8; - - auto msDescriptor = ts.descriptor(component, m); - fEquipmentId = msDescriptor.eq_id; - fdMsIndex = static_cast<double>(msDescriptor.idx); - const uint8_t* msContent = reinterpret_cast<const uint8_t*>(ts.content( - component, m)); - - uint32_t size = msDescriptor.size; -// fulLastMsIdx = msDescriptor.idx; - if (size > 0) - LOG(debug) << "Microslice: " << msDescriptor.idx << " has size: " << size; - - if( numCompMsInTs - fuOverlapMsNb <= m ) - { -// LOG(info) << "Ignore overlap Microslice: " << msDescriptor.idx; - continue; - } // if( numCompMsInTs - fuOverlapMsNb <= m ) - - if( 0 == m ) - dTsStartTime = (1e-9) * fdMsIndex; - - if( fdStartTimeMsSz < 0 ) - fdStartTimeMsSz = (1e-9) * fdMsIndex; - hMsSz->Fill(size); - if( 2 * fuHistoryHistoSize < (1e-9) * fdMsIndex - fdStartTimeMsSz ) - { - // Reset the evolution Histogram and the start time when we reach the end of the range - hMsSzTime->Reset(); - fdStartTimeMsSz = (1e-9) * fdMsIndex; - } // if( 2 * fuHistoryHistoSize < (1e-9) * fdMsIndex - fdStartTimeMsSz ) - hMsSzTime->Fill((1e-9) * fdMsIndex - fdStartTimeMsSz, size); - - // If not integer number of message in input buffer, print warning/error - if (0 != (size % kuBytesPerMessage)) - LOG(error) << "The input microslice buffer does NOT " - << "contain only complete nDPB messages!"; - - // Compute the number of complete messages in the input microslice buffer - uint32_t uNbMessages = (size - (size % kuBytesPerMessage)) - / kuBytesPerMessage; - - /** Real MS QA **/ - if( -1 == fdFirstMsIndex ) - fdFirstMsIndex = fdMsIndex; - for( UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; uGdpb ++) - fbFirstEpochInMsFound[uGdpb] = kFALSE; - - // Prepare variables for the loop on contents - const uint64_t* pInBuff = reinterpret_cast<const uint64_t*>(msContent); - for (uint32_t uIdx = 0; uIdx < uNbMessages; uIdx++) { - // Fill message - uint64_t ulData = static_cast<uint64_t>(pInBuff[uIdx]); - ngdpb::Message mess(ulData); - - if (gLogger->IsLogNeeded( fair::Severity::debug2 )) - { - mess.printDataCout(); - } // if (gLogger->IsLogNeeded( fair::Severity::debug2 )) - - - // Increment counter for different message types - // and fill the corresponding histogram - messageType = mess.getMessageType(); - fMsgCounter[messageType]++; - fHistMessType->Fill(messageType); - - fGdpbId = mess.getRocNumber(); - fGdpbNr = fGdpbIdIndexMap[fGdpbId]; - - fGet4Id = mess.getGdpbGenChipId(); - fGet4Nr = (fGdpbNr * fNrOfGet4PerGdpb) + fGet4Id; - - if( fNrOfGet4PerGdpb <= fGet4Id && - ngdpb::MSG_STAR_TRI != messageType && - ( get4v1x::kuChipIdMergedEpoch != fGet4Id || - kFALSE == fbMergedEpochsOn ) ) - LOG(warning) << "Message with Get4 ID too high: " << fGet4Id - << " VS " << fNrOfGet4PerGdpb << " set in parameters."; - - switch (messageType) { - case ngdpb::MSG_HIT: - // FillHitInfo(mess); - LOG(error) << "Message type " << messageType - << " not yet included in unpacker."; - break; - case ngdpb::MSG_EPOCH: - // FillEpochInfo(mess); - LOG(error) << "Message type " << messageType - << " not yet included in unpacker."; - break; - case ngdpb::MSG_SYS: - fHistSysMessType->Fill(mess.getSysMesType()); - break; - case ngdpb::MSG_EPOCH2: - { - if( get4v1x::kuChipIdMergedEpoch == fGet4Id && - kTRUE == fbMergedEpochsOn ) - { - for( uint32_t uGet4Index = 0; uGet4Index < fNrOfGet4PerGdpb; uGet4Index ++ ) - { - fGet4Id = uGet4Index; - fGet4Nr = (fGdpbNr * fNrOfGet4PerGdpb) + fGet4Id; - ngdpb::Message tmpMess(mess); - tmpMess.setGdpbGenChipId( uGet4Index ); - - fHistGet4MessType->Fill(fGet4Nr, ngdpb::GET4_32B_EPOCH); - FillEpochInfo(tmpMess); - } // for( uint32_t uGet4Index = 0; uGet4Index < fNrOfGet4PerGdpb; uGetIndex ++ ) - } // if this epoch message is a merged one valiud for all chips - else - { - fHistGet4MessType->Fill(fGet4Nr, ngdpb::GET4_32B_EPOCH); - FillEpochInfo(mess); - } // if single chip epoch message - break; - } - case ngdpb::MSG_GET4: - fHistGet4MessType->Fill(fGet4Nr, ngdpb::GET4_32B_DATA + 1); - if( fbGet4M24b ) - FillHitInfo(mess); - else PrintGenInfo(mess); - break; - case ngdpb::MSG_GET4_32B: - fHistGet4MessType->Fill(fGet4Nr, ngdpb::GET4_32B_DATA); - if( fbEpochSuppModeOn ) - fvmEpSupprBuffer[fGet4Nr].push_back( mess ); - else FillHitInfo(mess); - break; - case ngdpb::MSG_GET4_SLC: - fHistGet4MessType->Fill(fGet4Nr, ngdpb::GET4_32B_SLCM); - PrintSlcInfo(mess); - break; - case ngdpb::MSG_GET4_SYS: { - fHistSysMessType->Fill(mess.getGdpbSysSubType()); - if (ngdpb::SYSMSG_GET4_EVENT == mess.getGdpbSysSubType()) { - fHistGet4MessType->Fill(fGet4Nr, ngdpb::GET4_32B_ERROR); - - UInt_t uFeetNr = (fGet4Id / fNrOfGet4PerFeb); - if (0 <= fdStartTime) - { - fFeetErrorRate_gDPB[(fGdpbNr * fNrOfFebsPerGdpb) + uFeetNr]->Fill( - 1e-9 * (mess.getMsgFullTimeD(fCurrentEpoch[fGet4Nr]) - fdStartTime)); - } // if (0 <= fdStartTime) - if (0 <= fdStartTimeLong) - { - fFeetErrorRateLong_gDPB[(fGdpbNr * fNrOfFebsPerGdpb) + uFeetNr]->Fill( - 1e-9 / 60.0 * (mess.getMsgFullTimeD(fCurrentEpoch[fGet4Nr]) - fdStartTimeLong), 1 / 60.0); - } // if (0 <= fdStartTime) - - Int_t dFullChId = fGet4Nr * fNrOfChannelsPerGet4 + mess.getGdpbSysErrChanId(); - switch (mess.getGdpbSysErrData()) { - case ngdpb::GET4_V1X_ERR_READ_INIT: - fHistGet4ChanErrors->Fill(dFullChId, 0); - break; - case ngdpb::GET4_V1X_ERR_SYNC: - fHistGet4ChanErrors->Fill(dFullChId, 1); - break; - case ngdpb::GET4_V1X_ERR_EP_CNT_SYNC: - fHistGet4ChanErrors->Fill(dFullChId, 2); - break; - case ngdpb::GET4_V1X_ERR_EP: - fHistGet4ChanErrors->Fill(dFullChId, 3); - break; - case ngdpb::GET4_V1X_ERR_FIFO_WRITE: - fHistGet4ChanErrors->Fill(dFullChId, 4); - break; - case ngdpb::GET4_V1X_ERR_LOST_EVT: - fHistGet4ChanErrors->Fill(dFullChId, 5); - break; - case ngdpb::GET4_V1X_ERR_CHAN_STATE: - fHistGet4ChanErrors->Fill(dFullChId, 6); - break; - case ngdpb::GET4_V1X_ERR_TOK_RING_ST: - fHistGet4ChanErrors->Fill(dFullChId, 7); - break; - case ngdpb::GET4_V1X_ERR_TOKEN: - fHistGet4ChanErrors->Fill(dFullChId, 8); - break; - case ngdpb::GET4_V1X_ERR_READOUT_ERR: - fHistGet4ChanErrors->Fill(dFullChId, 9); - break; - case ngdpb::GET4_V1X_ERR_SPI: - fHistGet4ChanErrors->Fill(dFullChId, 10); - break; - case ngdpb::GET4_V1X_ERR_DLL_LOCK: - fHistGet4ChanErrors->Fill(dFullChId, 11); - break; - case ngdpb::GET4_V1X_ERR_DLL_RESET: - fHistGet4ChanErrors->Fill(dFullChId, 12); - break; - case ngdpb::GET4_V1X_ERR_TOT_OVERWRT: - fHistGet4ChanErrors->Fill(dFullChId, 13); - break; - case ngdpb::GET4_V1X_ERR_TOT_RANGE: - fHistGet4ChanErrors->Fill(dFullChId, 14); - break; - case ngdpb::GET4_V1X_ERR_EVT_DISCARD: - fHistGet4ChanErrors->Fill(dFullChId, 15); - break; - case ngdpb::GET4_V1X_ERR_ADD_RIS_EDG: - if( kTRUE == fbGet4v20 ) - fHistGet4ChanErrors->Fill(dFullChId, 16); - else fHistGet4ChanErrors->Fill(dFullChId, 17); - break; - case ngdpb::GET4_V1X_ERR_UNPAIR_FALL: - if( kTRUE == fbGet4v20 ) - fHistGet4ChanErrors->Fill(dFullChId, 17); - else fHistGet4ChanErrors->Fill(dFullChId, 17); - break; - case ngdpb::GET4_V1X_ERR_SEQUENCE_ER: - if( kTRUE == fbGet4v20 ) - fHistGet4ChanErrors->Fill(dFullChId, 18); - else fHistGet4ChanErrors->Fill(dFullChId, 17); - break; - case ngdpb::GET4_V1X_ERR_UNKNOWN: - if( kTRUE == fbGet4v20 ) - fHistGet4ChanErrors->Fill(dFullChId, 19); - else fHistGet4ChanErrors->Fill(dFullChId, 16); - break; - default: // Corrupt error or not yet supported error - if( kTRUE == fbGet4v20 ) - fHistGet4ChanErrors->Fill(dFullChId, 20); - else fHistGet4ChanErrors->Fill(dFullChId, 17); - break; - } // Switch( mess.getGdpbSysErrData() ) - - } - if (100 > iMess) - { - PrintSysInfo(mess); - iMess++; // Separate increment from condition, otherwise increase until wrap to -1664185233 - } // if (100 > iMess) - break; - } - case ngdpb::MSG_STAR_TRI: - fHistGet4MessType->Fill(fGet4Nr, ngdpb::MSG_STAR_TRI); - FillStarTrigInfo(mess); - break; - default: - if (100 > iMess) - { - LOG(error) << "Message (" << iMess << ") type " << std::hex - << std::setw(2) << static_cast<uint16_t>(messageType) - << " not yet included in Get4 unpacker."; - iMess++; // Separate increment from condition, otherwise increase until wrap to -1664185233 - } // if (100 > iMess++) - } // switch( mess.getMessageType() ) - } // for (uint32_t uIdx = 0; uIdx < uNbMessages; uIdx ++) - } // for (size_t m = 0; m < ts.num_microslices(component); ++m) - if (100 == iMess) - { - LOG(error) << "Stop reporting MSG errors... "; - iMess++; // Separate increment from condition, otherwise increase until wrap to -1664185233 - } // if (100 == iMess) - - // Spill detection using Detectors - if( !fbSpillOn && (fiSpillOnThr < fiCountsLastTs) ) - { - fbSpillOn = kTRUE; - fiTsUnderOff = 0; - - if( 0 < fdDetTimeLastTs ) - { - fHistSpillLength->Fill( fdDetLastTime - fdDetTimeLastTs ); - fHistSpillCount->Fill( fSpillIdx, fHistSpill->GetEntries() ); - fHistSpillQA->Fill( fdDetLastTime - fdDetTimeLastTs, - fHistSpill->GetEntries() ); - } // if( 0 < fdTimeLastTs ) - fdDetTimeLastTs = fdDetLastTime; - fSpillIdx++; - fHistSpill->Reset(); - } // if( !fbSpillOn && (fiSpillOnThr < fiCountsLastTs) ) - else if( fbSpillOn ) - { - if( fiCountsLastTs < fiSpillOffThr ) - { - fiTsUnderOff ++; - if( fiTsUnderOffThr < fiTsUnderOff ) - fbSpillOn = kFALSE; - } // if( fiCountsLastTs < fiSpillOffThr ) - else fiTsUnderOff = 0; - } // else if( fbSpillOn ) - - if( kTRUE == fbPulserMode ) - { - // Update RMS plots only every 10s in data - if( 10.0 < dTsStartTime - fdLastRmsUpdateTime ) - { - // Reset summary histograms for safety - fhTimeRmsPulserChosenFee->Reset(); - fhTimeRmsPulserChosenChPairs->Reset(); - - UInt_t uHistoFeeIdx = 0; - for( UInt_t uChanFeeA = 0; uChanFeeA < fNrOfChannelsPerFeet; uChanFeeA++) - { - for( UInt_t uChanFeeB = uChanFeeA + 1; uChanFeeB < fNrOfChannelsPerFeet; uChanFeeB++) - { - fhTimeRmsPulserChosenFee->Fill(uChanFeeA, uChanFeeB, fhTimeDiffPulserChosenFee[uHistoFeeIdx]->GetRMS() ); - uHistoFeeIdx++; - } // for( UInt_t uChanFeeB = uChanFeeA + 1; uChanFeeB < fNrOfChannelsPerFeet; uChanFeeB++) - } // for( UInt_t uChanFeeA = 0; uChanFeeA < fNrOfChannelsPerFeet; uChanFeeA++) - for( UInt_t uChan = 0; uChan < kuNbChanTest - 1; uChan++) - { - fhTimeRmsPulserChosenChPairs->Fill( uChan, fhTimeDiffPulserChosenChPairs[uChan]->GetRMS() ); - } // for( UInt_t uChan = 0; uChan < kuNbChanTest - 1; uChan++) - fdLastRmsUpdateTime = dTsStartTime; - } // if( 10.0 < dTsStartTime - fdLastRmsUpdateTime ) - } // if( kTRUE == fbPulserMode ) - - return kTRUE; -} - -void CbmTofStarMonitor2018::FillHitInfo(ngdpb::Message mess) -{ - // DE - Int_t paditoget4[64] = { 4, 3, 2, 1, // provided by Jochen - 24, 23, 22, 21, - 8, 7, 6, 5, - 28, 27, 26, 25, - 12, 11, 10, 9, - 32, 31, 30, 29, - 16, 15, 14, 13, - 20, 19, 18, 17, - - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0 }; - - Int_t get4topadi[64] = { 4, 3, 2, 1, // provided by Jochen - 12, 11, 10, 9, - 20, 19, 18, 17, - 28, 27, 26, 25, - - 32, 31, 30, 29, - 8, 7, 6, 5, - 16, 15, 14, 13, - 24, 23, 22, 21, - - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0 }; - - for (Int_t i = 0; i < 32; i++) - { - paditoget4[i+32] = paditoget4[i]+32; // compute 2nd half of mapping matrix - get4topadi[i+32] = get4topadi[i]+32; // compute 2nd half of mapping matrix - } - - Int_t channel_us = mess.getGdpbHitChanId(); // unsorted - Int_t channel = paditoget4[channel_us]; // resorted - // DE Int_t channel = get4topadi[channel_us]; // resorted - - Int_t tot = mess.getGdpbHit32Tot(); - Int_t Fts = mess.getGdpbHitFineTs(); - - Long64_t curEpochGdpbGet4 = fCurrentEpoch[fGet4Nr]; - - if (curEpochGdpbGet4 != -111) { - - if( fbEpochSuppModeOn ) - { - // In Ep. Suppr. Mode, receive following epoch instead of previous - if( 0 < curEpochGdpbGet4 ) - curEpochGdpbGet4 --; - else curEpochGdpbGet4 = get4v1x::kuEpochCounterSz; // Catch epoch cycle! - } // if( fbEpochSuppModeOn ) - - UInt_t channelNr = fGet4Id * fNrOfChannelsPerGet4 + channel; - UInt_t channelNrInFeet = (fGet4Id % fNrOfGet4PerFeb) * fNrOfChannelsPerGet4 + channel; - UInt_t uFeetNr = (fGet4Id / fNrOfGet4PerFeb); - - ULong_t hitTime; - Double_t dHitTime; - - if( fbGet4v20 ) - { - hitTime = mess.getMsgG4v2FullTime(curEpochGdpbGet4); - dHitTime = mess.getMsgG4v2FullTimeD(curEpochGdpbGet4); - - // In 32b mode the coarse counter is already computed back to 112 FTS bins - // => need to hide its contribution from the Finetime - // => FTS = Fullt TS modulo 112 - if( !fbGet4M24b ) - Fts = mess.getGdpbHitFullTs() % 112; - } // if( fbGet4v20 ) - else - { - hitTime = mess.getMsgFullTime(curEpochGdpbGet4); - dHitTime = mess.getMsgFullTimeD(curEpochGdpbGet4); - } // else of if( fbGet4v20 ) - - if( !fbGet4M24b ) - { - fChCount_gDPB[fGdpbNr]->Fill(channelNr); - if( fRaw_Tot_gDPB.size() <= (fGdpbNr * uNbFeetPlotsPerGdpb + uFeetNr/uNbFeetPlot) ) - { - LOG(warning) << "Index error: " - << Form("%03lu vs %03u (%03u, %03d, %03u)", fRaw_Tot_gDPB.size(), - (fGdpbNr * uNbFeetPlotsPerGdpb + uFeetNr/uNbFeetPlot), - fGdpbNr, uFeetNr, uNbFeetPlot ) - << "\n" - << Form("(%03u, %03d)", fGet4Id, channel ); - mess.printDataCout(); - } - if( NULL == fRaw_Tot_gDPB[fGdpbNr * uNbFeetPlotsPerGdpb + uFeetNr/uNbFeetPlot ] ) - LOG(warning) << "Histo pointer is NULL: " - << Form("%03lu vs %03u (%03u, %03d, %03u)", fRaw_Tot_gDPB.size(), - (fGdpbNr * uNbFeetPlotsPerGdpb + uFeetNr/uNbFeetPlot), - fGdpbNr, uFeetNr, uNbFeetPlot ); - - fRaw_Tot_gDPB[ fGdpbNr * uNbFeetPlotsPerGdpb + uFeetNr/uNbFeetPlot ]->Fill(channelNr, tot); - - /// Finetime monitoring - fhFtDistribPerCh[(fGdpbNr * fNrOfFebsPerGdpb) + uFeetNr]->Fill( - channelNrInFeet, Fts ); - } // if( !fbGet4M24b ) - else - { -/* - fGet4Id = mess.getGet4Number(); - channel = mess.getGet4ChNum(); - UInt_t Fts = mess.getGet4FineTs(); - UInt_t edge = mess.getGet4Edge(); -*/ - Int_t edge = mess.getGdpbHit24Edge(); - - channelNr = fGet4Id * fNrOfChannelsPerGet4 + channel; - uFeetNr = (fGet4Id / fNrOfGet4PerFeb); - UInt_t uFullFebIdx = (fGdpbNr * fNrOfFebsPerGdpb) + uFeetNr; - - if( edge ) - { - fChCountFall_gDPB[fGdpbNr]->Fill(channelNr); - - - /// Finetime monitoring - fhFtDistribPerChFall[uFullFebIdx]->Fill( channelNrInFeet, Fts ); - if( 0 <= fviFtLastRise24b[uFullFebIdx][channelNr] && - fuRiseFallChSel == channelNr) - fhFtLastRiseCurrFall[uFullFebIdx]->Fill( - fviFtLastRise24b[uFullFebIdx][channelNr], - Fts); - if( 0 <= fviFtLastRise24b[uFullFebIdx][channelNr] && - 0 <= fvdTimeLastFall24b[uFullFebIdx][channelNr] && - fuRiseFallChSel == channelNr) - fhFtLastRiseDistFall[uFullFebIdx]->Fill( - fviFtLastRise24b[uFullFebIdx][channelNr], - dHitTime - fvdTimeLastFall24b[uFullFebIdx][channelNr]); - - fviFtLastFall24b[uFullFebIdx][channelNr] = Fts; - fvdTimeLastFall24b[uFullFebIdx][channelNr] = dHitTime; - } // if( edge ) - else - { - fChCount_gDPB[fGdpbNr]->Fill(channelNr); - - /// Finetime monitoring - fhFtDistribPerCh[uFullFebIdx]->Fill( channelNr, Fts ); - if( 0 <= fviFtLastFall24b[uFullFebIdx][channelNr] && - fuRiseFallChSel == channelNr) - fhFtCurrRiseLastFall[uFullFebIdx]->Fill( - Fts, - fviFtLastFall24b[uFullFebIdx][channelNr] ); - if( 0 <= fviFtLastRise24b[uFullFebIdx][channelNr] && - 0 <= fvdTimeLastRise24b[uFullFebIdx][channelNr] && - fuRiseFallChSel == channelNr) - fhFtLastRiseDistRise[uFullFebIdx]->Fill( - fviFtLastRise24b[uFullFebIdx][channelNr], - dHitTime - fvdTimeLastRise24b[uFullFebIdx][channelNr]); - - fviFtLastRise24b[uFullFebIdx][channelNr] = Fts; - fvdTimeLastRise24b[uFullFebIdx][channelNr] = dHitTime; - } // else of if( edge ) - } // else of if( !fbGet4M24b ) - - if (fUnpackPar->IsChannelRateEnabled() && - ( !fbGet4M24b || !(mess.getGdpbHit24Edge()) )) { - // Check if at least one hit before in this channel - if( -1 < fTsLastHit[fGdpbNr][fGet4Id][channel] ) - { - fChannelRate_gDPB[fGdpbNr + uFeetNr/uNbFeetPlot]->Fill( -// 1e9 / (dHitTime - fTsLastHit[fGdpbNr][fGet4Id][channel]), - (dHitTime - fTsLastHit[fGdpbNr][fGet4Id][channel]), - fGet4Id * fNrOfChannelsPerGet4 + channel); - } // if( -1 < fTsLastHit[fGdpbNr][fGet4Id][channel] ) - } // if( fUnpackPar->IsChannelRateEnabled() ) - - // Save last hist time if channel rate histos or pulser mode enabled - if( fUnpackPar->IsChannelRateEnabled() || fbPulserMode ) - { - if( !fbGet4M24b || !(mess.getGdpbHit24Edge()) ) - fTsLastHit[fGdpbNr][fGet4Id][channel] = dHitTime; - } // if( fUnpackPar->IsChannelRateEnabled() || fbPulserMode ) - - // In Run rate evolution - if (fdStartTime < 0) - fdStartTime = dHitTime; - - // Reset the evolution Histogram and the start time when we reach the end of the range - if( fuHistoryHistoSize < 1e-9 * (dHitTime - fdStartTime) ) - { - for (UInt_t uGdpbLoop = 0; uGdpbLoop < fNrOfGdpbs; uGdpbLoop++) - { - for (UInt_t uFeetLoop = 0; uFeetLoop < fNrOfFebsPerGdpb; uFeetLoop++) - { - fFeetRate_gDPB[(uGdpbLoop * fNrOfFebsPerGdpb) + uFeetLoop]->Reset(); - fFeetErrorRate_gDPB[(uGdpbLoop * fNrOfFebsPerGdpb) + uFeetLoop]->Reset(); - } // for (UInt_t uFeetLoop = 0; uFeetLoop < fNrOfFebsPerGdpb; uFeetLoop++) - } // for (UInt_t uFeetLoop = 0; uFeetLoop < fNrOfFebsPerGdpb; uFeetLoop++) - fhTriggerRate->Reset(); - fhStarTokenEvo->Reset(); - - fdStartTime = dHitTime; - } // if( fuHistoryHistoSize < 1e-9 * (dHitTime - fdStartTime) ) - - // In Run rate evolution - if (fdStartTimeLong < 0) - fdStartTimeLong = dHitTime; - - // Reset the evolution Histogram and the start time when we reach the end of the range - if( fuHistoryHistoSizeLong < 1e-9 * (dHitTime - fdStartTimeLong) ) - { - for (UInt_t uGdpbLoop = 0; uGdpbLoop < fNrOfGdpbs; uGdpbLoop++) - { - for (UInt_t uFeetLoop = 0; uFeetLoop < fNrOfFebsPerGdpb; uFeetLoop++) - { - fFeetRateLong_gDPB[(uGdpbLoop * fNrOfFebsPerGdpb) + uFeetLoop]->Reset(); - fFeetErrorRateLong_gDPB[(uGdpbLoop * fNrOfFebsPerGdpb) + uFeetLoop]->Reset(); - } // for (UInt_t uFeetLoop = 0; uFeetLoop < fNrOfFebsPerGdpb; uFeetLoop++) - } // for (UInt_t uFeetLoop = 0; uFeetLoop < fNrOfFebsPerGdpb; uFeetLoop++) - - fdStartTimeLong = dHitTime; - } // if( fuHistoryHistoSize < 1e-9 * (dHitTime - fdStartTime) ) - - if (0 <= fdStartTime) - { - fFeetRate_gDPB[(fGdpbNr * fNrOfFebsPerGdpb) + uFeetNr]->Fill( - 1e-9 * (dHitTime - fdStartTime)); - - // General Time (date + time) rate evolution - // Add offset of -1H as the filenames were using some times offset by 1 hour (Summer time?!?) - if( 0 < fiBinSizeDatePlots && 0 < fiRunStartDateTimeSec ) { - fFeetRateDate_gDPB[(fGdpbNr * fNrOfFebsPerGdpb) + uFeetNr]->Fill( - 1e-9 * (dHitTime - fdStartTime) ); - } // if( 0 < fiBinSizeDatePlots && 0 < fiRunStartDateTimeSec ) - } - - if (0 <= fdStartTimeLong) - { - fFeetRateLong_gDPB[(fGdpbNr * fNrOfFebsPerGdpb) + uFeetNr]->Fill( - 1e-9 / 60.0 * (dHitTime - fdStartTimeLong), 1 / 60.0); - } // if (0 <= fdStartTimeLong) - -// Int_t iChanInGdpb = fGet4Id * fNrOfChannelsPerGet4 + channel; -// Int_t increment = static_cast<CbmFlibCern2016Source*>(FairRunOnline::Instance()->GetSource())->GetNofTSSinceLastTS(); -/* - // if condition to find the right strip/end index - fHistSpill->Fill(0., 0., increment); -*/ - fiCountsLastTs ++; - fdDetLastTime = 1e-9 * dHitTime; - - if (100 > iMess) - { - LOG(debug) << "Hit: " << Form("0x%08x ", fGdpbId) << ", " << fGet4Id - << ", " << channel << ", " << tot << ", epoch " - << curEpochGdpbGet4 << ", FullTime " - << hitTime << ", FineTime " << Fts; - iMess++; // Separate increment from condition, otherwise increase until wrap to -1664185233 - } // if (100 > iMess) - - ///* ASIC coincidences & offsets mapping */// -/* - fbHitsInLastTs = kTRUE; - fvulHitEpochBuffLastTs[fGet4Nr].push_back( curEpochGdpbGet4 ); -*/ - } // if( fCurrentEpoch[rocId].end() != fCurrentEpoch[rocId].find( get4Id ) ) - //} // if( fCurrentEpoch.end() != fCurrentEpoch.find( rocId ) ) - //} // if( fGdpbIdIndexMap.end() != fGdpbIdIndexMap.find( rocId ) ) - else - LOG(warning) << "Found hit in gdpbId w/o epoch yet: " - << Form("0x%08x g4 %02u", fGdpbId, fGet4Nr); -} - -void CbmTofStarMonitor2018::FillEpochInfo(ngdpb::Message mess) -{ - ULong64_t ulEpochNr = mess.getGdpbEpEpochNb(); -/* - if( ulEpochNr < fCurrentEpoch[fGet4Nr] ) - LOG(warning) << "Epoch message for get4 " << Form("%3u", fGet4Nr ) - << " with epoch number " << Form("%9u", ulEpochNr ) - << " smaller than previous epoch number for same chip: " - << Form("%9u", fCurrentEpoch[fGet4Nr] ); - if( ulEpochNr == fCurrentEpoch[fGet4Nr] ) - LOG(warning) << "Epoch message for get4 " << Form("%3u", fGet4Nr ) - << " with epoch number " << Form("%9u", ulEpochNr ) - << " same as previous epoch number for same chip: " - << Form("%9u", fCurrentEpoch[fGet4Nr] ); -*/ - - /** Real MS QA **/ - if( kFALSE == fbFirstEpochInMsFound[fGdpbNr] ) - { - Double_t dMsIndexCnt = fdMsIndex / 102400; // ~10 kHz MS => 1e5 ns increase of index per MS - Double_t dMsIndexFromStart = (fdMsIndex - fdFirstMsIndex)/ 102400; // ~10 kHz MS => 1e5 ns increase of index per MS - Double_t dEpIdxMsIdxRatio = static_cast< Double_t >( ulEpochNr ) / dMsIndexCnt; - fRealMsFineQa_gDPB[fGdpbNr]->Fill( dMsIndexFromStart, dEpIdxMsIdxRatio ); - fRealMsMidQa_gDPB[fGdpbNr]->Fill( dMsIndexFromStart, dEpIdxMsIdxRatio ); - fRealMsCoarseQa_gDPB[fGdpbNr]->Fill( dMsIndexFromStart, dEpIdxMsIdxRatio ); - fbFirstEpochInMsFound[fGdpbNr] = kTRUE; - } // if( kFALSE == fbFirstEpochInMsFound[uGdpb] ) - - - fCurrentEpoch[fGet4Nr] = ulEpochNr; - - if (100 > iMess) - { - LOG(debug) << "Epoch message for get4 " << fGet4Nr << " with epoch number " - << fCurrentEpoch[fGet4Nr]; - iMess++; // Separate increment from condition, otherwise increase until wrap to -1664185233 - } // if (100 > iMess) -/* - if (1000 > iMessB ) - { -// if( 0 <= fGet4Nr && fGet4Nr <= 15 ) - if( ( 16 <= fGet4Nr && fGet4Nr <= 23 ) || ( 40 <= fGet4Nr && fGet4Nr <= 47 )) -// if( 24 <= fGet4Nr && fGet4Nr <= 39 ) -// if( 48 <= fGet4Nr && fGet4Nr <= 63 ) -// if( ( 64 <= fGet4Nr && fGet4Nr <= 71 ) || ( 88 <= fGet4Nr && fGet4Nr <= 95 )) -// if( 72 <= fGet4Nr && fGet4Nr <= 87 ) - { - LOG(info) << "Epoch message for get4 " << Form( "%02u", fGet4Nr) << " with epoch number " - << Form( "%09llu", fCurrentEpoch[fGet4Nr]) - << " in ms " << Form("%12llu", fulLastMsIdx); - iMessB++; - } // if get4 chip in range - } // if (10000 > iMessB ) -*/ - - if (1 == mess.getGdpbEpSync()) - fHistGet4EpochFlags->Fill(fGet4Nr, 0); - if (1 == mess.getGdpbEpDataLoss()) - fHistGet4EpochFlags->Fill(fGet4Nr, 1); - if (1 == mess.getGdpbEpEpochLoss()) - fHistGet4EpochFlags->Fill(fGet4Nr, 2); - if (1 == mess.getGdpbEpMissmatch()) - fHistGet4EpochFlags->Fill(fGet4Nr, 3); - - fCurrentEpochTime = mess.getMsgFullTime(ulEpochNr); - fNofEpochs++; - - - if( fbEpochSuppModeOn ) - { - /// Re-align the epoch number of the message in case it will be used later: - /// We received the epoch after the data instead of the one before! - if( 0 < ulEpochNr ) - mess.setEpoch2Number( ulEpochNr - 1 ); - else mess.setEpoch2Number( get4v1x::kuEpochCounterSz ); - - Int_t iBufferSize = fvmEpSupprBuffer[fGet4Nr].size(); - if( 0 < iBufferSize ) - { - LOG(debug) << "Now processing stored messages for for get4 " << fGet4Nr << " with epoch number " - << (fCurrentEpoch[fGet4Nr] - 1); - - /// Data are sorted between epochs, not inside => Epoch level ordering - /// Sorting at lower bin precision level - std::stable_sort( fvmEpSupprBuffer[fGet4Nr].begin(), fvmEpSupprBuffer[fGet4Nr].begin() ); - - for( Int_t iMsgIdx = 0; iMsgIdx < iBufferSize; iMsgIdx++ ) - { - FillHitInfo( fvmEpSupprBuffer[fGet4Nr][ iMsgIdx ] ); - } // for( Int_t iMsgIdx = 0; iMsgIdx < iBufferSize; iMsgIdx++ ) - - fvmEpSupprBuffer[fGet4Nr].clear(); - } // if( 0 < fvmEpSupprBuffer[fGet4Nr] ) - - } // if( fbEpochSuppModeOn ) - - // Fill Pulser test histos if needed - if( fbPulserMode && 0 == (fGet4Id % fNrOfGet4PerFeb) // GET4 index in FEET - && fuPulserFee == (fGet4Nr / fNrOfGet4PerFeb)) // FEET index in full system - { - // Fill the time difference for all channels pairs in - // the chosen Fee - UInt_t uHistoFeeIdx = 0; - - UInt_t uOffsetChip = fuPulserFee * fNrOfGet4PerFeb; - for( UInt_t uChanFeeA = 0; uChanFeeA < fNrOfChannelsPerFeet; uChanFeeA++) - { - UInt_t uChipA = uChanFeeA / fNrOfChannelsPerGet4 + uOffsetChip; - UInt_t uChanA = uChanFeeA % fNrOfChannelsPerGet4; - - for( UInt_t uChanFeeB = uChanFeeA + 1; uChanFeeB < fNrOfChannelsPerFeet; uChanFeeB++) - { - UInt_t uChipB = uChanFeeB / fNrOfChannelsPerGet4 + uOffsetChip; - UInt_t uChanB = uChanFeeB % fNrOfChannelsPerGet4; - - Double_t dTimeDiff = - fTsLastHit[ fuPulserGdpb ][ uChipB ][ uChanB ] - - fTsLastHit[ fuPulserGdpb ][ uChipA ][ uChanA ]; - dTimeDiff *= 1e3; // ns -> ps - if( ( 10.0 * dMinDt < dTimeDiff ) && ( dTimeDiff < 10.0 * dMaxDt ) && - ( 0 < fTsLastHit[ fuPulserGdpb ][ uChipA ][ uChanA ] ) && - ( 0 < fTsLastHit[ fuPulserGdpb ][ uChipB ][ uChanB ] ) ) - { - fhTimeDiffPulserChosenFee[uHistoFeeIdx]->Fill( dTimeDiff ); - } // if both channels have already 1 hit and these are not too far away - - uHistoFeeIdx++; - } // for( UInt_t uChanFeeB = uChanFeeA + 1; uChanFeeB < fNrOfChannelsPerFeet; uChanFeeB++) - } // for( UInt_t uChanFeeA = 0; uChanFeeA < fNrOfChannelsPerFeet; uChanFeeA++) - - // Fill the time difference for the chosen channel pairs - for( UInt_t uChan = 0; uChan < kuNbChanTest - 1; uChan++) - { - UInt_t uGdpbA = fuPulserChan[ uChan ] / fuNbChannelsPerGdpb; - UInt_t uChipA = ( fuPulserChan[ uChan ] % fuNbChannelsPerGdpb ) / fNrOfChannelsPerGet4; - UInt_t uChanA = fuPulserChan[ uChan ] % fNrOfChannelsPerGet4; - UInt_t uGdpbB = fuPulserChan[ uChan + 1 ] / fuNbChannelsPerGdpb; - UInt_t uChipB = ( fuPulserChan[ uChan + 1 ] % fuNbChannelsPerGdpb ) / fNrOfChannelsPerGet4; - UInt_t uChanB = fuPulserChan[ uChan + 1 ] % fNrOfChannelsPerGet4; - - Double_t dTimeDiff = - fTsLastHit[uGdpbB][uChipB][ uChanB ] - fTsLastHit[uGdpbA][uChipA][ uChanA ]; - dTimeDiff *= 1e3; // ns -> ps - if( ( 10.0 * dMinDt < dTimeDiff ) && ( dTimeDiff < 10.0 * dMaxDt ) && - ( 0 < fTsLastHit[uGdpbA][uChipA][ uChanA ] ) && - ( 0 < fTsLastHit[uGdpbB][uChipB][ uChanB ] ) ) - { - fhTimeDiffPulserChosenChPairs[uChan]->Fill( dTimeDiff ); - } // if both channels have already 1 hit and these are not too far away - } // for( UInt_t uChan = 0; uChan < kuNbChanTest - 1; uChan++) - } // if( fbPulserMode && First GET4 on chosen FEET ) - - /* - LOG(debug) << "Epoch message " - << fNofEpochs << ", epoch " << static_cast<Int_t>(fCurrentEpoch[gdpbId][get4Id]) - << ", time " << std::setprecision(9) << std::fixed - << Double_t(fCurrentEpochTime) * 1.e-9 << " s " - << " for board ID " << std::hex << std::setw(4) << gdpbId << std::dec - << " and chip " << mess.getEpoch2ChipNumber(); - */ -} - -void CbmTofStarMonitor2018::PrintSlcInfo(ngdpb::Message mess) -{ - if (fGdpbIdIndexMap.end() != fGdpbIdIndexMap.find(fGdpbId)) - { - UInt_t uChip = mess.getGdpbGenChipId(); - UInt_t uChan = mess.getGdpbSlcChan(); - UInt_t uEdge = mess.getGdpbSlcEdge(); - UInt_t uData = mess.getGdpbSlcData(); - UInt_t uCRC = mess.getGdpbSlcCrc(); - Double_t dFullChId = fGet4Nr * fNrOfChannelsPerGet4 + mess.getGdpbSlcChan() + 0.5 * mess.getGdpbSlcEdge(); - Double_t dMessTime = static_cast< Double_t>( fCurrentEpochTime ) * 1.e-9; - - switch( mess.getGdpbSlcType() ) - { - case 0: // Scaler counter - { - fhScmScalerCounters->Fill( uData, dFullChId); - break; - } - case 1: // Deadtime counter - { - fhScmDeadtimeCounters->Fill( uData, dFullChId); - break; - } - case 2: // SPI message - { - LOG(info) << "GET4 Slow Control message, epoch " - << static_cast<Int_t>(fCurrentEpoch[fGet4Nr]) << ", time " << std::setprecision(9) - << std::fixed << dMessTime << " s " - << " for board ID " << std::hex << std::setw(4) << fGdpbId - << std::dec << "\n" - << " +++++++ > Chip = " - << std::setw(2) << uChip << ", Chan = " - << std::setw(1) << uChan << ", Edge = " - << std::setw(1) << uEdge << ", Type = " - << std::setw(1) << mess.getGdpbSlcType() << ", Data = 0x" -// << std::hex << std::setw(6) << mess.getGdpbSlcData() - << Form( "%06x", uData ) - << std::dec << ", CRC = " << uCRC; - break; - } - case 3: // Start message or SEU counter - { - if( 0 == mess.getGdpbSlcChan() && 0 == mess.getGdpbSlcEdge() ) // START message - { - // Print or fill histo - if( 0 == fGet4Nr && 0x474554 == mess.getGdpbSlcData() ) // START message block 1/6 - { - if( 0 < fdTimeLastStartMessage ) - fhScmStartMessDist->Fill( dMessTime - fdTimeLastStartMessage ); - fhScmStartMessEvo->Fill( dMessTime - fdStartTime * 1.e-9 ); - fdTimeLastStartMessage = dMessTime; - } // if( 0 == fGet4Nr && 0x474554 == mess.getGdpbSlcData() ) -/* - LOG(info) << std::setprecision(9) - << std::fixed << dMessTime << " s "; - LOG(info) << "GET4 Slow Control message, epoch " - << static_cast<Int_t>(fCurrentEpoch[fGet4Nr]) << ", time " << std::setprecision(9) - << std::fixed << dMessTime << " s " - << " for board ID " << std::hex << std::setw(4) << fGdpbId - << std::dec << "\n" - << " +++++++ > Chip = " - << std::setw(2) << mess.getGdpbGenChipId() << ", Chan = " - << std::setw(1) << mess.getGdpbSlcChan() << ", Edge = " - << std::setw(1) << mess.getGdpbSlcEdge() << ", Type = " - << std::setw(1) << mess.getGdpbSlcType() << ", Data = 0x" - // << std::hex << std::setw(6) << mess.getGdpbSlcData() - << Form( "%06x", mess.getGdpbSlcData() ) - << std::dec << ", CRC = " << mess.getGdpbSlcCrc(); -*/ - } // if( 0 == mess.getGdpbSlcChan() && 0 == mess.getGdpbSlcEdge() ) - else if( 0 == mess.getGdpbSlcChan() && 1 == mess.getGdpbSlcEdge() ) // SEU counter message - { -/* - LOG(info) << "GET4 Slow Control message, epoch " - << static_cast<Int_t>(fCurrentEpoch[fGet4Nr]) << ", time " << std::setprecision(9) - << std::fixed << dMessTime << " s " - << " for board ID " << std::hex << std::setw(4) << fGdpbId - << std::dec << "\n" - << " +++++++ > Chip = " - << std::setw(2) << mess.getGdpbGenChipId() << ", Chan = " - << std::setw(1) << mess.getGdpbSlcChan() << ", Edge = " - << std::setw(1) << mess.getGdpbSlcEdge() << ", Type = " - << std::setw(1) << mess.getGdpbSlcType() << ", Data = 0x" -// << std::hex << std::setw(6) << mess.getGdpbSlcData() - << Form( "%06x", mess.getGdpbSlcData() ) - << std::dec << ", CRC = " << mess.getGdpbSlcCrc(); -*/ - fhScmSeuCounters->Fill( uData, dFullChId); - fhScmSeuCountersEvo->Fill( dMessTime - fdStartTime* 1.e-9, uData, dFullChId); - } // else if( 0 == mess.getGdpbSlcChan() && 1 == mess.getGdpbSlcEdge() ) - break; - } - default: // Should never happen - break; - } // switch( mess.getGdpbSlcType() ) - fHistGet4ChanScm->Fill(dFullChId, mess.getGdpbSlcType()); - } - - -} - -void CbmTofStarMonitor2018::PrintGenInfo(ngdpb::Message mess) -{ - Int_t mType = mess.getMessageType(); - Int_t channel = mess.getGdpbHitChanId(); - uint64_t uData = mess.getData(); - - if (100 > iMess) - { - LOG(info) << "Get4 MSG type " << mType << " from gdpbId " << fGdpbId - << ", getId " << fGet4Id << ", (hit channel) " << channel - << " data " << std::hex << uData; - iMess++; // Separate increment from condition, otherwise increase until wrap to -1664185233 - } // if (100 > iMess) -} - -void CbmTofStarMonitor2018::PrintSysInfo(ngdpb::Message mess) -{ - if (fGdpbIdIndexMap.end() != fGdpbIdIndexMap.find(fGdpbId)) - LOG(debug) << "GET4 System message, epoch " - << static_cast<Int_t>(fCurrentEpoch[fGet4Nr]) << ", time " << std::setprecision(9) - << std::fixed << Double_t(fCurrentEpochTime) * 1.e-9 << " s " - << " for board ID " << std::hex << std::setw(4) << fGdpbId - << std::dec; - - switch (mess.getGdpbSysSubType()) { - case ngdpb::SYSMSG_GET4_EVENT: { - uint32_t uData = mess.getGdpbSysErrData(); - if (ngdpb::GET4_V1X_ERR_TOT_OVERWRT == uData - || ngdpb::GET4_V1X_ERR_TOT_RANGE == uData - || ngdpb::GET4_V1X_ERR_EVT_DISCARD == uData - || ngdpb::GET4_V1X_ERR_ADD_RIS_EDG == uData - || ngdpb::GET4_V1X_ERR_UNPAIR_FALL == uData - || ngdpb::GET4_V1X_ERR_SEQUENCE_ER == uData - ) - LOG(debug) << " +++++++ > gDPB: " << std::hex << std::setw(4) << fGdpbId - << std::dec << ", Chip = " << std::setw(2) - << mess.getGdpbGenChipId() << ", Chan = " << std::setw(1) - << mess.getGdpbSysErrChanId() << ", Edge = " - << std::setw(1) << mess.getGdpbSysErrEdge() << ", Empt = " - << std::setw(1) << mess.getGdpbSysErrUnused() - << ", Data = " << std::hex << std::setw(2) << uData - << std::dec << " -- GET4 V1 Error Event"; - else - LOG(info) << " +++++++ >gDPB: " << std::hex << std::setw(4) << fGdpbId - << std::dec << ", Chip = " << std::setw(2) - << mess.getGdpbGenChipId() << ", Chan = " << std::setw(1) - << mess.getGdpbSysErrChanId() << ", Edge = " - << std::setw(1) << mess.getGdpbSysErrEdge() << ", Empt = " - << std::setw(1) << mess.getGdpbSysErrUnused() - << ", Data = " << std::hex << std::setw(2) << uData - << std::dec << " -- GET4 V1 Error Event " << iMess; - break; - } // case ngdpb::SYSMSG_GET4_EVENT - case ngdpb::SYSMSG_CLOSYSYNC_ERROR: - LOG(info) << "Closy synchronization error"; - break; - case ngdpb::SYSMSG_TS156_SYNC: - LOG(debug) << "160.00 MHz timestamp reset"; - break; - case ngdpb::SYSMSG_GDPB_UNKWN: - LOG(info) << "Unknown GET4 message, data: " << std::hex << std::setw(8) - << mess.getGdpbSysUnkwData() << std::dec - <<" Full message: " << std::hex << std::setw(16) - << mess.getData() << std::dec; - break; - } // switch( getGdpbSysSubType() ) -} - -void CbmTofStarMonitor2018::FillStarTrigInfo(ngdpb::Message mess) -{ - Int_t iMsgIndex = mess.getStarTrigMsgIndex(); - -// mess.printDataCout(); - - switch( iMsgIndex ) - { - case 0: - fhTokenMsgType->Fill(0); - fulGdpbTsMsb = mess.getGdpbTsMsbStarA(); - break; - case 1: - fhTokenMsgType->Fill(1); - fulGdpbTsLsb = mess.getGdpbTsLsbStarB(); - fulStarTsMsb = mess.getStarTsMsbStarB(); - break; - case 2: - fhTokenMsgType->Fill(2); - fulStarTsMid = mess.getStarTsMidStarC(); - break; - case 3: - { - fhTokenMsgType->Fill(3); - ULong64_t ulNewGdpbTsFull = ( fulGdpbTsMsb << 24 ) - + ( fulGdpbTsLsb ); - ULong64_t ulNewStarTsFull = ( fulStarTsMsb << 48 ) - + ( fulStarTsMid << 8 ) - + mess.getStarTsLsbStarD(); - UInt_t uNewToken = mess.getStarTokenStarD(); - UInt_t uNewDaqCmd = mess.getStarDaqCmdStarD(); - UInt_t uNewTrigCmd = mess.getStarTrigCmdStarD(); - - if( ( uNewToken == fuStarTokenLast ) && ( ulNewGdpbTsFull == fulGdpbTsFullLast ) && - ( ulNewStarTsFull == fulStarTsFullLast ) && ( uNewDaqCmd == fuStarDaqCmdLast ) && - ( uNewTrigCmd == fuStarTrigCmdLast ) ) - { - LOG(debug) << "Possible error: identical STAR tokens found twice in a row => ignore 2nd! " - << Form("token = %5u ", fuStarTokenLast ) - << Form("gDPB ts = %12llu ", fulGdpbTsFullLast ) - << Form("STAR ts = %12llu ", fulStarTsFullLast ) - << Form("DAQ cmd = %2u ", fuStarDaqCmdLast ) - << Form("TRG cmd = %2u ", fuStarTrigCmdLast ); - return; - } // if exactly same message repeated -/* - if( (uNewToken != fuStarTokenLast + 1) && - 0 < fulGdpbTsFullLast && 0 < fulStarTsFullLast && - ( 4095 != fuStarTokenLast || 1 != uNewToken) ) - LOG(warning) << "Possible error: STAR token did not increase by exactly 1! " - << Form("old = %5u vs new = %5u ", fuStarTokenLast, uNewToken) - << Form("old = %12llu vs new = %12llu ", fulGdpbTsFullLast, ulNewGdpbTsFull) - << Form("old = %12llu vs new = %12llu ", fulStarTsFullLast, ulNewStarTsFull) - << Form("old = %2u vs new = %2u ", fuStarDaqCmdLast, uNewDaqCmd) - << Form("old = %2u vs new = %2u ", fuStarTrigCmdLast, uNewTrigCmd); -*/ - // STAR TS counter reset detection - if( ulNewStarTsFull < fulStarTsFullLast ) - LOG(debug) << "Probable reset of the STAR TS: old = " << Form("%16llu", fulStarTsFullLast) - << " new = " << Form("%16llu", ulNewStarTsFull) - << " Diff = -" << Form("%8llu", fulStarTsFullLast - ulNewStarTsFull); - -// ULong64_t ulGdpbTsDiff = ulNewGdpbTsFull - fulGdpbTsFullLast; - fulGdpbTsFullLast = ulNewGdpbTsFull; - fulStarTsFullLast = ulNewStarTsFull; - fuStarTokenLast = uNewToken; - fuStarDaqCmdLast = uNewDaqCmd; - fuStarTrigCmdLast = uNewTrigCmd; - - if( 0 <= fdStartTime ) - { - // Reset the evolution Histogram and the start time when we reach the end of the range - if( fuHistoryHistoSize < 1e-9 * (fulGdpbTsFullLast * 6.25 - fdStartTime) ) - { - for (UInt_t uGdpbLoop = 0; uGdpbLoop < fNrOfGdpbs; uGdpbLoop++) - { - for (UInt_t uFeetLoop = 0; uFeetLoop < fNrOfFebsPerGdpb; uFeetLoop++) - { - fFeetRate_gDPB[(uGdpbLoop * fNrOfFebsPerGdpb) + uFeetLoop]->Reset(); - fFeetErrorRate_gDPB[(uGdpbLoop * fNrOfFebsPerGdpb) + uFeetLoop]->Reset(); - } // for (UInt_t uFeetLoop = 0; uFeetLoop < fNrOfFebsPerGdpb; uFeetLoop++) - } // for (UInt_t uFeetLoop = 0; uFeetLoop < fNrOfFebsPerGdpb; uFeetLoop++) - fhTriggerRate->Reset(); - fhStarTokenEvo->Reset(); - - fdStartTime = fulGdpbTsFullLast * 6.25; - } // if( fuHistoryHistoSize < 1e-9 * (fulGdpbTsFullLast * 6.25 - fdStartTime) ) - - fhTriggerRate->Fill( - 1e-9 * ( fulGdpbTsFullLast * 6.25 - fdStartTime ) ); - fhStarTokenEvo->Fill( - 1e-9 * ( fulGdpbTsFullLast * 6.25 - fdStartTime ), - fuStarTokenLast ); - } // if( 0 < fdStartTime ) - else fdStartTime = fulGdpbTsFullLast * 6.25; - fhCmdDaqVsTrig->Fill( fuStarDaqCmdLast, fuStarTrigCmdLast ); - -/* - LOG(info) << "Found full Star Trigger with gDPB TS " << Form("%16llu", fulGdpbTsFullLast) - << " STAR TS " << Form("%16llu", fulStarTsFullLast) - << " token " << Form("%8u", fuStarTokenLast) - << " DAQ CMD " << Form("%1X", fuStarDaqCmdLast) - << " TRIG CMD " << Form("%1X", fuStarTrigCmdLast) -// << " Filler " << Form("%2X", mess.getStarFillerD()) - << "GDPB DIFF " << Form("%8llu", ulGdpbTsDiff); -*/ - break; - } // case 3 - default: - LOG(error) << "Unknown Star Trigger messageindex: " << iMsgIndex; - } // switch( iMsgIndex ) -} -void CbmTofStarMonitor2018::FillTrigEpochInfo(ngdpb::Message mess) -{ - UInt_t uEpochNr = mess.getGdpbEpEpochNb(); - fGet4Id = mess.getGdpbGenChipId(); - fGet4Nr = (fGdpbNr * fNrOfGet4PerGdpb) + fGet4Id; - - if (100 > iMess) - { - LOG(debug) << "Epoch message for get4 " << fGet4Id - << " in gDPB " << fGdpbNr - <<" with epoch number " << uEpochNr; - iMess++; // Separate increment from condition, otherwise increase until wrap to -1664185233 - } // if (100 > iMess) - - fCurrentEpochTime = mess.getMsgFullTime(uEpochNr); - fNofEpochs++; - - if( fbEpochSuppModeOn ) - { - /// Re-align the epoch number of the message in case it will be used later: - /// We received the epoch after the data instead of the one before! - //// The epoch index from the token message should not need to be re-aligned - //// ====> to be checked with pulser or data-trigger correlation -// if( 0 < uEpochNr ) -// mess.setEpoch2Number( uEpochNr - 1 ); - } // if( fbEpochSuppModeOn ) -} - -void CbmTofStarMonitor2018::Reset() -{ -} - -void CbmTofStarMonitor2018::Finish() -{ - // Printout some stats on what was unpacked - TString message_type; - for (unsigned int i = 0; i < fMsgCounter.size(); ++i) { - switch (i) { - case 0: - message_type = "NOP"; - break; - case 1: - message_type = "HIT"; - break; - case 2: - message_type = "EPOCH"; - break; - case 3: - message_type = "SYNC"; - break; - case 4: - message_type = "AUX"; - break; - case 5: - message_type = "EPOCH2"; - break; - case 6: - message_type = "GET4"; - break; - case 7: - message_type = "SYS"; - break; - case 8: - message_type = "GET4_SLC"; - break; - case 9: - message_type = "GET4_32B"; - break; - case 10: - message_type = "GET4_SYS"; - break; - default: - message_type = "UNKNOWN"; - break; - } // switch(i) - LOG(info) << message_type << " messages: " << fMsgCounter[i]; - } // for (unsigned int i=0; i< fMsgCounter.size(); ++i) - - LOG(info) << "-------------------------------------"; - for (UInt_t i = 0; i < fNrOfGdpbs; ++i) { - for (UInt_t j = 0; j < fNrOfGet4PerGdpb; ++j) { - LOG(info) << "Last epoch for gDPB: " << std::hex << std::setw(4) << i - << std::dec << " , GET4 " << std::setw(4) << j << " => " - << fCurrentEpoch[GetArrayIndex(i, j)]; - } - } - LOG(info) << "-------------------------------------"; - - SaveAllHistos(); -} - -void CbmTofStarMonitor2018::FillOutput(boost::any) -{ -} - -void CbmTofStarMonitor2018::SaveAllHistos( TString sFileName ) -{ - TDirectory * oldDir = NULL; - TFile * histoFile = NULL; - if( "" != sFileName ) - { - // Store current directory position to allow restore later - oldDir = gDirectory; - // open separate histo file in recreate mode - histoFile = new TFile( sFileName , "RECREATE"); - histoFile->cd(); - } // if( "" != sFileName ) - - // Update the FT slected channel distribution if needed - if( fbGet4M24b ) - UpdateNormedFt(); - - gDirectory->mkdir("Tof_Raw_gDPB"); - gDirectory->cd("Tof_Raw_gDPB"); - for (UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; uGdpb++) { - - for (UInt_t uFeetPlot = 0; uFeetPlot < fNrOfFebsPerGdpb/uNbFeetPlot; ++uFeetPlot ) - fHM->H2(Form("Raw_Tot_gDPB_%02u_%1u", uGdpb, uFeetPlot))->Write(); - - fHM->H1(Form("ChCount_gDPB_%02u", uGdpb))->Write(); - if( fbGet4M24b ) - fHM->H1(Form("ChCountFall_gDPB_%02u", uGdpb))->Write(); - -// if (fUnpackPar->IsChannelRateEnabled()) -// fHM->H2(Form("ChannelRate_gDPB_%02u", uGdpb))->Write(); - for (UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; uFeet++) { - fHM->H1(Form("FeetRate_gDPB_g%02u_f%1u", uGdpb, uFeet))->Write(); - fHM->H1(Form("FeetErrorRate_gDPB_g%02u_f%1u", uGdpb, uFeet))->Write(); - fHM->H1(Form("FeetRateLong_gDPB_g%02u_f%1u", uGdpb, uFeet))->Write(); - fHM->H1(Form("FeetErrorRateLong_gDPB_g%02u_f%1u", uGdpb, uFeet))->Write(); - if( 0 < fiBinSizeDatePlots && 0 < fiRunStartDateTimeSec ) { - fHM->H1(Form("FeetRateDate_gDPB_g%02u_f%1u", uGdpb, uFeet))->Write(); - } // if( 0 < fiBinSizeDatePlots && 0 < fiRunStartDateTimeSec ) - fHM->H2(Form("FtDistribPerCh_gDPB_g%02u_f%1u", uGdpb, uFeet))->Write(); - fHM->H1(Form("SelChFtNormDnlRise_g%02u_f%1u", uGdpb, uFeet))->Write(); - fHM->H1(Form("FtNormDnlMinRise_g%02u_f%1u", uGdpb, uFeet))->Write(); - fHM->H1(Form("FtNormDnlMaxRise_g%02u_f%1u", uGdpb, uFeet))->Write(); - if( fbGet4M24b ) - { - fHM->H2(Form("FtDistribPerChFall_gDPB_g%02u_f%1u", uGdpb, uFeet))->Write(); - fHM->H1(Form("SelChFtNormDnlFall_g%02u_f%1u", uGdpb, uFeet))->Write(); - fHM->H1(Form("FtNormDnlMinFall_g%02u_f%1u", uGdpb, uFeet))->Write(); - fHM->H1(Form("FtNormDnlMaxFall_g%02u_f%1u", uGdpb, uFeet))->Write(); - fHM->H2(Form("FtLastRiseCurrFall_gDPB_g%02u_f%1u", uGdpb, uFeet))->Write(); - fHM->H2(Form("FtCurrRiseLastFall_gDPB_g%02u_f%1u", uGdpb, uFeet))->Write(); - fHM->H2(Form("FtLastRiseDistRise_gDPB_g%02u_f%1u", uGdpb, uFeet))->Write(); - fHM->H2(Form("FtLastRiseDistFall_gDPB_g%02u_f%1u", uGdpb, uFeet))->Write(); - } // if( fbGet4M24b ) - } // for (UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; uFeet++) - fRealMsFineQa_gDPB[uGdpb]->Write(); - fRealMsMidQa_gDPB[uGdpb]->Write(); - fRealMsCoarseQa_gDPB[uGdpb]->Write(); - } // for( UInt_t uGdpb = 0; uGdpb < fuMinNbGdpb; uGdpb ++) - fHM->H1("hMessageType")->Write(); - fHM->H1("hSysMessType")->Write(); - fHM->H2("hGet4MessType")->Write(); - fHM->H2("hGet4ChanScm")->Write(); - fHM->H2("hGet4ChanErrors")->Write(); - fHM->H2("hGet4EpochFlags")->Write(); - fHM->H1("hSpillLength")->Write(); - fHM->H1("hSpillCount")->Write(); - fHM->H1("hSpillQA")->Write(); - - gDirectory->cd(".."); - - ///* ASIC coincidences & offsets mapping */// -/* - gDirectory->mkdir("TofCoinc"); - gDirectory->cd("TofCoinc"); - for( UInt_t uAsicA = 0; uAsicA < fvhCoincOffsetEpochGet4.size(); uAsicA ++ ) - fvhCoincOffsetEpochGet4[uAsicA]->Write(); - gDirectory->cd(".."); -*/ - - ///* STAR event building/cutting */// - gDirectory->mkdir("Star_Raw"); - gDirectory->cd("Star_Raw"); - fhTokenMsgType->Write(); - fHM->H1("hTriggerRate")->Write(); - fHM->H1("hCmdDaqVsTrig")->Write(); - fHM->H1("hStarTokenEvo")->Write(); - gDirectory->cd(".."); - - gDirectory->mkdir("Flib_Raw"); - gDirectory->cd("Flib_Raw"); - for (UInt_t uLinks = 0; uLinks < 16; uLinks++) { - TString sMsSzName = Form("MsSz_link_%02u", uLinks); - if (fHM->Exists(sMsSzName.Data())) - fHM->H1(sMsSzName.Data())->Write(); - - sMsSzName = Form("MsSzTime_link_%02u", uLinks); - if (fHM->Exists(sMsSzName.Data())) - fHM->P1(sMsSzName.Data())->Write(); - } // for( UInt_t uLinks = 0; uLinks < 16; uLinks ++) - gDirectory->cd(".."); - - if( "" != sFileName ) - { - // Restore original directory position - histoFile->Close(); - oldDir->cd(); - } // if( "" != sFileName ) - if( "" != sFileName ) - { - // Restore original directory position - histoFile->Close(); - oldDir->cd(); - } // if( "" != sFileName ) - -} - -void CbmTofStarMonitor2018::ResetAllHistos() -{ - LOG(info) << "Reseting all TOF histograms."; - fHM->H1("hMessageType")->Reset(); - fHM->H1("hSysMessType")->Reset(); - fHM->H2("hGet4MessType")->Reset(); - fHM->H2("hGet4ChanScm")->Reset(); - fHM->H2("hGet4ChanErrors")->Reset(); - fHM->H2("hGet4EpochFlags")->Reset(); - fHM->H1("hSpillLength")->Reset(); - fHM->H1("hSpillCount")->Reset(); - fHM->H2("hSpillQA")->Reset(); - fSpillIdx = 0; - - for (UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; uGdpb++) { - fHM->H1(Form("ChCount_gDPB_%02u", uGdpb))->Reset(); - if( fbGet4M24b ) - fHM->H1(Form("ChCountFall_gDPB_%02u", uGdpb))->Reset(); - - for (UInt_t uFeetPlot = 0; uFeetPlot < fNrOfFebsPerGdpb/uNbFeetPlot; ++uFeetPlot ) - fHM->H2(Form("Raw_Tot_gDPB_%02u_%1u", uGdpb, uFeetPlot))->Reset(); - -// if (fUnpackPar->IsChannelRateEnabled()) -// fHM->H2(Form("ChannelRate_gDPB_%02u", uGdpb))->Reset(); - for (UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; uFeet++) { - fHM->H1(Form("FeetRate_gDPB_g%02u_f%1u", uGdpb, uFeet))->Reset(); - fHM->H1(Form("FeetErrorRate_gDPB_g%02u_f%1u", uGdpb, uFeet))->Reset(); - fHM->H1(Form("FeetRateLong_gDPB_g%02u_f%1u", uGdpb, uFeet))->Reset(); - fHM->H1(Form("FeetErrorRateLong_gDPB_g%02u_f%1u", uGdpb, uFeet))->Reset(); - fHM->H2(Form("FtDistribPerCh_gDPB_g%02u_f%1u", uGdpb, uFeet))->Reset(); - fHM->H1(Form("SelChFtNormDnlRise_g%02u_f%1u", uGdpb, uFeet))->Reset(); - fHM->H1(Form("FtNormDnlMinRise_g%02u_f%1u", uGdpb, uFeet))->Reset(); - fHM->H1(Form("FtNormDnlMaxRise_g%02u_f%1u", uGdpb, uFeet))->Reset(); - - if( fbGet4M24b ) - { - fHM->H2(Form("FtDistribPerChFall_gDPB_g%02u_f%1u", uGdpb, uFeet))->Reset(); - fHM->H1(Form("SelChFtNormDnlFall_g%02u_f%1u", uGdpb, uFeet))->Reset(); - fHM->H1(Form("FtNormDnlMinFall_g%02u_f%1u", uGdpb, uFeet))->Reset(); - fHM->H1(Form("FtNormDnlMaxFall_g%02u_f%1u", uGdpb, uFeet))->Reset(); - fHM->H2(Form("FtLastRiseCurrFall_gDPB_g%02u_f%1u", uGdpb, uFeet))->Reset(); - fHM->H2(Form("FtCurrRiseLastFall_gDPB_g%02u_f%1u", uGdpb, uFeet))->Reset(); - fHM->H2(Form("FtLastRiseDistRise_gDPB_g%02u_f%1u", uGdpb, uFeet))->Reset(); - fHM->H2(Form("FtLastRiseDistFall_gDPB_g%02u_f%1u", uGdpb, uFeet))->Reset(); - } // if( fbGet4M24b ) - } // for( UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; uFeet ++) - fRealMsFineQa_gDPB[uGdpb]->Reset(); - fRealMsMidQa_gDPB[uGdpb]->Reset(); - fRealMsCoarseQa_gDPB[uGdpb]->Reset(); - fdFirstMsIndex = -1; - } // for( UInt_t uGdpb = 0; uGdpb < fuMinNbGdpb; uGdpb ++) - - for (UInt_t uLinks = 0; uLinks < 16; uLinks++) { - TString sMsSzName = Form("MsSz_link_%02u", uLinks); - if (fHM->Exists(sMsSzName.Data())) - fHM->H1(sMsSzName.Data())->Reset(); - - sMsSzName = Form("MsSzTime_link_%02u", uLinks); - if (fHM->Exists(sMsSzName.Data())) - fHM->P1(sMsSzName.Data())->Reset(); - } // for( UInt_t uLinks = 0; uLinks < 16; uLinks ++) - - if( fbPulserMode ) - { - fHM->H2("hTimeRmsPulserChosenFee")->Reset(); - fHM->H1("hTimeRmsPulserChosenChPairs")->Reset(); - fdLastRmsUpdateTime = -1; - - // Full Fee time difference test - UInt_t uHistoFeeIdx = 0; - for( UInt_t uChanFeeA = 0; uChanFeeA < fNrOfChannelsPerFeet; uChanFeeA++) - { - for( UInt_t uChanFeeB = uChanFeeA + 1; uChanFeeB < fNrOfChannelsPerFeet; uChanFeeB++) - { - fhTimeDiffPulserChosenFee[uHistoFeeIdx]->Reset(); - uHistoFeeIdx++; - } // for any unique pair of channel in chosen Fee - } // for( UInt_t uChanFeeA = 0; uChanFeeA < kuNbChanFee; uChanFeeA++) - - // Selected channels test - for( UInt_t uChan = 0; uChan < kuNbChanTest - 1; uChan++) - fhTimeDiffPulserChosenChPairs[uChan]->Reset(); - } // if( fbPulserMode ) - - ///* STAR event building/cutting */// - fhTokenMsgType->Reset(); - fHM->H1("hTriggerRate")->Reset(); - fHM->H1("hCmdDaqVsTrig")->Reset(); - fHM->H1("hStarTokenEvo")->Reset(); - - fdStartTime = -1; - fdStartTimeLong = -1; - fdStartTimeMsSz = -1; -} -void CbmTofStarMonitor2018::UpdateNormedFt() -{ - TDirectory * oldDir = gDirectory; - - gROOT->cd(); - UInt_t uHistoFeeIdx = 0; - TF1 *constantVal = new TF1("constant","1", 0, get4v1x::kuFineCounterSize); - for (UInt_t uGdpb = 0; uGdpb < fNrOfGdpbs; uGdpb++) - { - for (UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; uFeet++) - { - fFtNormDnlMinRise[uHistoFeeIdx]->Reset(); - fFtNormDnlMaxRise[uHistoFeeIdx]->Reset(); - fFtNormInlMinRise[uHistoFeeIdx]->Reset(); - fFtNormInlMaxRise[uHistoFeeIdx]->Reset(); - if( fbGet4M24b ) - { - fFtNormDnlMinFall[uHistoFeeIdx]->Reset(); - fFtNormDnlMaxFall[uHistoFeeIdx]->Reset(); - fFtNormInlMinFall[uHistoFeeIdx]->Reset(); - fFtNormInlMaxFall[uHistoFeeIdx]->Reset(); - } // if( fbGet4M24b ) - - for (UInt_t uChannel = 0; uChannel < fNrOfChannelsPerFeet; uChannel++) - { - // Rising edge - TH1 * pFtSelChSliceRise = fhFtDistribPerCh[uHistoFeeIdx]->ProjectionY( "temp_pFtSelChSliceRise", - 1 + uChannel, 1 + uChannel); - if( 0 < pFtSelChSliceRise->GetEntries() ) - { - Double_t dNormFactRise = pFtSelChSliceRise->GetEntries() - / (fbGet4v20 ? 112. : get4v1x::kuFineCounterSize); - pFtSelChSliceRise->Scale( 1.0 / dNormFactRise ); - pFtSelChSliceRise->Add( constantVal, -1.); - } // if( 0 < pFtSelChSliceRise->GetEntries() ) - - // Falling edge - TH1 * pFtSelChSliceFall = NULL; - if( fbGet4M24b ) - { - pFtSelChSliceFall = fhFtDistribPerChFall[uHistoFeeIdx]->ProjectionY( "temp_pFtSelChSliceFall", - 1 + uChannel, 1 + uChannel); - if( 0 < pFtSelChSliceFall->GetEntries() ) - { - Double_t dNormFactFall = pFtSelChSliceFall->GetEntries() - / (fbGet4v20 ? 112. : get4v1x::kuFineCounterSize); - pFtSelChSliceFall->Scale( 1.0 / dNormFactFall ); - pFtSelChSliceFall->Add( constantVal, -1.); - } // if( 0 < pFtSelChSliceFall->GetEntries() ) - - if( fbGet4v20 ) - { - pFtSelChSliceRise->SetAxisRange( 8, 119 ); - pFtSelChSliceFall->SetAxisRange( 8, 119 ); - } // if( fbGet4v20 ) - } // if( fbGet4M24b ) - else if( fbGet4v20 ) - { - pFtSelChSliceRise->SetAxisRange( 0, 111 ); - } // if !fbGet4M24b and fbGet4v20 - - // INLs - fhTempHistInlRise->Reset(); - if( fbGet4M24b ) - fhTempHistInlFall->Reset(); - Double_t dInlRise = 0.0; - Double_t dInlFall = 0.0; - for( UInt_t uFtBin = 0; uFtBin < get4v1x::kuFineCounterSize; uFtBin++) - { - dInlRise += pFtSelChSliceRise->GetBinContent( 1 + uFtBin ); - fhTempHistInlRise->Fill( uFtBin, dInlRise ); - - if( fbGet4M24b ) - { - dInlFall += pFtSelChSliceFall->GetBinContent( 1 + uFtBin ); - fhTempHistInlFall->Fill( uFtBin, dInlFall ); - } // if( fbGet4M24b ) - } // for( UInt_t uFtBin = 0; uFtBin < get4v1x::kuFineCounterSize; uFtBin++) - if( fbGet4v20 ) - { - if( fbGet4M24b ) - { - fhTempHistInlRise->SetAxisRange( 8, 119 ); - fhTempHistInlFall->SetAxisRange( 8, 119 ); - } // if( fbGet4M24b ) - else fhTempHistInlRise->SetAxisRange( 0, 111 ); - } // if( fbGet4v20 ) - - // Fill min/max histos - fFtNormDnlMinRise[uHistoFeeIdx]->Fill( uChannel, pFtSelChSliceRise->GetMinimum() ); - fFtNormDnlMaxRise[uHistoFeeIdx]->Fill( uChannel, pFtSelChSliceRise->GetMaximum() ); - fFtNormInlMinRise[uHistoFeeIdx]->Fill( uChannel, fhTempHistInlRise->GetMinimum() ); - fFtNormInlMaxRise[uHistoFeeIdx]->Fill( uChannel, fhTempHistInlRise->GetMaximum() ); - if( fbGet4M24b ) - { - fFtNormDnlMinFall[uHistoFeeIdx]->Fill( uChannel, pFtSelChSliceFall->GetMinimum() ); - fFtNormDnlMaxFall[uHistoFeeIdx]->Fill( uChannel, pFtSelChSliceFall->GetMaximum() ); - fFtNormInlMinFall[uHistoFeeIdx]->Fill( uChannel, fhTempHistInlFall->GetMinimum() ); - fFtNormInlMaxFall[uHistoFeeIdx]->Fill( uChannel, fhTempHistInlFall->GetMaximum() ); - } // if( fbGet4M24b ) - - if( uChannel == fuRiseFallChSel ) - { - fSelChFtNormDnlRise[uHistoFeeIdx]->Reset(); - fSelChFtNormDnlRise[uHistoFeeIdx]->Add( pFtSelChSliceRise ); - - fSelChFtNormInlRise[uHistoFeeIdx]->Reset(); - fSelChFtNormInlRise[uHistoFeeIdx]->Add( fhTempHistInlRise ); - - if( fbGet4M24b ) - { - fSelChFtNormDnlFall[uHistoFeeIdx]->Reset(); - fSelChFtNormDnlFall[uHistoFeeIdx]->Add( pFtSelChSliceFall ); - - fSelChFtNormInlFall[uHistoFeeIdx]->Reset(); - fSelChFtNormInlFall[uHistoFeeIdx]->Add( fhTempHistInlFall ); - - if( fbGet4v20 ) - { - fSelChFtNormDnlRise[uHistoFeeIdx]->SetAxisRange( 8, 119 ); - fSelChFtNormDnlFall[uHistoFeeIdx]->SetAxisRange( 8, 119 ); - - fSelChFtNormInlRise[uHistoFeeIdx]->SetAxisRange( 8, 119 ); - fSelChFtNormInlFall[uHistoFeeIdx]->SetAxisRange( 8, 119 ); - } // if( fbGet4v20 ) - } // if( fbGet4M24b ) - else if( fbGet4v20 ) - { - fSelChFtNormDnlRise[uHistoFeeIdx]->SetAxisRange( 0, 111 ); - fSelChFtNormInlRise[uHistoFeeIdx]->SetAxisRange( 0, 111 ); - } // if !fbGet4M24b and fbGet4v20 - - LOG(info) << "Gdpb " << uGdpb << " Feet " << uFeet - << " Leading DNL min " << fSelChFtNormDnlRise[uHistoFeeIdx]->GetMinimum() - << " max " << fSelChFtNormDnlRise[uHistoFeeIdx]->GetMaximum(); - if( fbGet4M24b ) - LOG(info) << "Gdpb " << uGdpb << " Feet " << uFeet - << " Trailing DNL min " << fSelChFtNormDnlFall[uHistoFeeIdx]->GetMinimum() - << " max " << fSelChFtNormDnlFall[uHistoFeeIdx]->GetMaximum(); - } // if( uChannel == fuRiseFallChSel ) - - delete pFtSelChSliceRise; - if( fbGet4M24b ) - delete pFtSelChSliceFall; - } // for (UInt_t uChannel = 0; uChannel < fNrOfChannelsPerFeet; uChannel++) - - // Update histo index - uHistoFeeIdx++; - } // for (UInt_t uFeet = 0; uFeet < fNrOfFebsPerGdpb; uFeet++) - } // for (UInt_t uGdpb = 0; uGdpb < fuMinNbGdpb; uGdpb++) - delete constantVal; - - oldDir->cd(); -} -void CbmTofStarMonitor2018::UpdateZoomedFit() -{ - // Do something only if we are in pulser mode - if( kFALSE == fbPulserMode ) - return; - - // Only do something is the user defined the width a want for the zoom - if( 0.0 < fdFitZoomWidthPs ) - { - // Reset summary histograms for safety - fhTimeRmsZoomPulsChosenFee->Reset(); - fhTimeRmsZoomFitPulsChosenChPairs->Reset(); - fhTimeResFitPulsChosenFee->Reset(); - fhTimeResFitPulsChosenChPairs->Reset(); - - UInt_t uHistoFeeIdx = 0; - Double_t dRes = 0; - TF1 *fitFuncFee[ fNrOfChannelsPerFeet * fNrOfChannelsPerFeet ]; // bigger than needed but OK - for( UInt_t uChanFeeA = 0; uChanFeeA < fNrOfChannelsPerFeet; uChanFeeA++) - { - for( UInt_t uChanFeeB = uChanFeeA + 1; uChanFeeB < fNrOfChannelsPerFeet; uChanFeeB++) - { - // Check that we have at least 1 entry - if( 0 == fhTimeDiffPulserChosenFee[uHistoFeeIdx]->GetEntries() ) - { - fhTimeRmsZoomPulsChosenFee->Fill( uChanFeeA, uChanFeeB, 0.0 ); - fhTimeResFitPulsChosenFee->Fill( uChanFeeA, uChanFeeB, 0.0 ); - LOG(info) << "CbmTofStarMonitor2018::UpdateZoomedFit => Empty input " - << "for channels " << uChanFeeA << " and " << uChanFeeB << " !!!"; - continue; - } // if( 0 == fhTimeDiffPulserChosenFee[uHistoFeeIdx]->GetEntries() ) - - // Read the peak position (bin with max counts) + total nb of entries - Int_t iBinWithMax = fhTimeDiffPulserChosenFee[uHistoFeeIdx]->GetMaximumBin(); - Double_t dNbCounts = fhTimeDiffPulserChosenFee[uHistoFeeIdx]->Integral(); - - // Zoom the X axis to +/- ZoomWidth around the peak position - Double_t dPeakPos = fhTimeDiffPulserChosenFee[uHistoFeeIdx]->GetXaxis()->GetBinCenter( iBinWithMax ); - fhTimeDiffPulserChosenFee[uHistoFeeIdx]->GetXaxis()->SetRangeUser( dPeakPos - fdFitZoomWidthPs, - dPeakPos + fdFitZoomWidthPs ); - - // Read integral and check how much we lost due to the zoom (% loss allowed) - Double_t dZoomCounts = fhTimeDiffPulserChosenFee[uHistoFeeIdx]->Integral(); - if( ( dZoomCounts / dNbCounts ) < 0.99 ) - { - fhTimeRmsZoomPulsChosenFee->Fill( uChanFeeA, uChanFeeB, 0.0 ); - fhTimeResFitPulsChosenFee->Fill( uChanFeeA, uChanFeeB, 0.0 ); - LOG(warning) << "CbmTofStarMonitor2018::UpdateZoomedFit => Zoom too strong, " - << "more than 1% loss for channels " << uChanFeeA << " and " - << uChanFeeB << " !!!"; - continue; - } // if( ( dZoomCounts / dNbCounts ) < 0.99 ) - - // Fill new RMS after zoom into summary histo - fhTimeRmsZoomPulsChosenFee->Fill( uChanFeeA, uChanFeeB, fhTimeDiffPulserChosenFee[uHistoFeeIdx]->GetRMS() ); - - // Fit using zoomed boundaries + starting gaussian width, store into summary histo - dRes = 0; - fitFuncFee[uHistoFeeIdx] = new TF1( Form("fFee_%02d", uHistoFeeIdx ), "gaus", - dPeakPos - fdFitZoomWidthPs , - dPeakPos + fdFitZoomWidthPs); - // Fix the Mean fit value around the Histogram Mean - fitFuncFee[uHistoFeeIdx]->SetParameter( 0, dZoomCounts ); - fitFuncFee[uHistoFeeIdx]->SetParameter( 1, dPeakPos ); - fitFuncFee[uHistoFeeIdx]->SetParameter( 2, 200.0 ); // Hardcode start with ~4*BinWidth, do better later - // Using integral instead of bin center seems to lead to unrealistic values => no "I" - fhTimeDiffPulserChosenFee[uHistoFeeIdx]->Fit( Form("fFee_%02d", uHistoFeeIdx ), "QRM0"); - // Get Sigma - dRes = fitFuncFee[uHistoFeeIdx]->GetParameter(2); - // Cleanup memory - delete fitFuncFee[uHistoFeeIdx]; - // Fill summary - fhTimeResFitPulsChosenFee->Fill( uChanFeeA, uChanFeeB, dRes / TMath::Sqrt2() ); - - // Restore original axis state? - fhTimeDiffPulserChosenFee[uHistoFeeIdx]->GetXaxis()->UnZoom(); - - uHistoFeeIdx++; - } // for( UInt_t uChanFeeB = uChanFeeA + 1; uChanFeeB < fNrOfChannelsPerFeet; uChanFeeB++) - } // for( UInt_t uChanFeeA = 0; uChanFeeA < fNrOfChannelsPerFeet; uChanFeeA++) - - TF1 *fitFuncPairs[ kuNbChanTest - 1 ]; - for( UInt_t uChan = 0; uChan < kuNbChanTest - 1; uChan++) - { - // Check that we have at least 1 entry - if( 0 == fhTimeDiffPulserChosenChPairs[uChan]->GetEntries() ) - { - fhTimeRmsZoomFitPulsChosenChPairs->Fill( uChan, 0.0 ); - fhTimeResFitPulsChosenChPairs->Fill( uChan, 0.0 ); - LOG(info) << "CbmTofStarMonitor2018::UpdateZoomedFit => Empty input " - << "for channels pair " << uChan << " !!! "; - continue; - } // if( 0 == fhTimeDiffPulserChosenChPairs[uChan]>GetEntries() ) - - // Read the peak position (bin with max counts) + total nb of entries - Int_t iBinWithMax = fhTimeDiffPulserChosenChPairs[uChan]->GetMaximumBin(); - Double_t dNbCounts = fhTimeDiffPulserChosenChPairs[uChan]->Integral(); - - // Zoom the X axis to +/- ZoomWidth around the peak position - Double_t dPeakPos = fhTimeDiffPulserChosenChPairs[uChan]->GetXaxis()->GetBinCenter( iBinWithMax ); - fhTimeDiffPulserChosenChPairs[uChan]->GetXaxis()->SetRangeUser( dPeakPos - fdFitZoomWidthPs, - dPeakPos + fdFitZoomWidthPs ); - - // Read integral and check how much we lost due to the zoom (% loss allowed) - Double_t dZoomCounts = fhTimeDiffPulserChosenChPairs[uChan]->Integral(); - if( ( dZoomCounts / dNbCounts ) < 0.99 ) - { - fhTimeRmsZoomFitPulsChosenChPairs->Fill( uChan, 0.0 ); - fhTimeResFitPulsChosenChPairs->Fill( uChan, 0.0 ); - LOG(warning) << "CbmTofStarMonitor2018::UpdateZoomedFit => Zoom too strong, " - << "more than 1% loss for channels pair " << uChan << " !!!"; - continue; - } // if( ( dZoomCounts / dNbCounts ) < 0.99 ) - - // Fill new RMS after zoom into summary histo - fhTimeRmsZoomFitPulsChosenChPairs->Fill( uChan, fhTimeDiffPulserChosenChPairs[uChan]->GetRMS() ); - - - // Fit using zoomed boundaries + starting gaussian width, store into summary histo - dRes = 0; - fitFuncPairs[uChan] = new TF1( Form("fPair_%02d", uChan ), "gaus", - dPeakPos - fdFitZoomWidthPs , - dPeakPos + fdFitZoomWidthPs); - // Fix the Mean fit value around the Histogram Mean - fitFuncPairs[uChan]->SetParameter( 0, dZoomCounts ); - fitFuncPairs[uChan]->SetParameter( 1, dPeakPos ); - fitFuncPairs[uChan]->SetParameter( 2, 200.0 ); // Hardcode start with ~4*BinWidth, do better later - // Using integral instead of bin center seems to lead to unrealistic values => no "I" - fhTimeDiffPulserChosenChPairs[uChan]->Fit( Form("fPair_%02d", uChan ), "QRM0"); - // Get Sigma - dRes = fitFuncPairs[uChan]->GetParameter(2); - // Cleanup memory - delete fitFuncPairs[uChan]; - // Fill summary - fhTimeResFitPulsChosenChPairs->Fill( uChan, dRes / TMath::Sqrt2() ); - - // Restore original axis state? - fhTimeDiffPulserChosenChPairs[uChan]->GetXaxis()->UnZoom(); - } // for( UInt_t uChan = 0; uChan < kuNbChanTest - 1; uChan++) - } // if( 0.0 < fdFitZoomWidthPs ) - else - { - LOG(error) << "CbmTofStarMonitor2018::UpdateZoomedFit => Zoom width not defined, " - << "please use SetFitZoomWidthPs, e.g. in macro, before trying this update !!!"; - } // else of if( 0.0 < fdFitZoomWidthPs ) -/* - { - // Update RMS plots only every 10s in data - if( 10.0 < dTsStartTime - fdLastRmsUpdateTime ) - { - - } // if( 10.0 < dTsStartTime - fdLastRmsUpdateTime ) - } // if( kTRUE == fbPulserMode ) - */ -} - -void CbmTofStarMonitor2018::SetRunStart( Int_t dateIn, Int_t timeIn, Int_t iBinSize ) -{ - TDatime * fRunStartDateTime = new TDatime( dateIn, timeIn); - fiRunStartDateTimeSec = fRunStartDateTime->Convert(); - fiBinSizeDatePlots = iBinSize; - - LOG(info) << "Assigned new TOF Run Start Date-Time: " << fRunStartDateTime->AsString(); -} - -void CbmTofStarMonitor2018::SetPulserChans( - UInt_t inPulserChanA, UInt_t inPulserChanB, UInt_t inPulserChanC, UInt_t inPulserChanD, - UInt_t inPulserChanE, UInt_t inPulserChanF, UInt_t inPulserChanG, UInt_t inPulserChanH, - UInt_t inPulserChanI, UInt_t inPulserChanJ, UInt_t inPulserChanK, UInt_t inPulserChanL, - UInt_t inPulserChanM, UInt_t inPulserChanN, UInt_t inPulserChanO, UInt_t inPulserChanP, - UInt_t inPulserChanQ, UInt_t inPulserChanR ) -{ - fuPulserChan[ 0] = inPulserChanA; - fuPulserChan[ 1] = inPulserChanB; - fuPulserChan[ 2] = inPulserChanC; - fuPulserChan[ 3] = inPulserChanD; - fuPulserChan[ 4] = inPulserChanE; - fuPulserChan[ 5] = inPulserChanF; - fuPulserChan[ 6] = inPulserChanG; - fuPulserChan[ 7] = inPulserChanH; - fuPulserChan[ 8] = inPulserChanI; - fuPulserChan[ 9] = inPulserChanJ; - fuPulserChan[10] = inPulserChanK; - fuPulserChan[11] = inPulserChanL; - fuPulserChan[12] = inPulserChanM; - fuPulserChan[13] = inPulserChanN; - fuPulserChan[14] = inPulserChanO; - fuPulserChan[15] = inPulserChanP; - fuPulserChan[16] = inPulserChanQ; - fuPulserChan[17] = inPulserChanR; -} - -ClassImp(CbmTofStarMonitor2018) diff --git a/beamtime/star2018/unpacker/CbmTofStarMonitor2018.h b/beamtime/star2018/unpacker/CbmTofStarMonitor2018.h deleted file mode 100644 index 84bdd085c14543586ba6731303ae2fb1834e7195..0000000000000000000000000000000000000000 --- a/beamtime/star2018/unpacker/CbmTofStarMonitor2018.h +++ /dev/null @@ -1,298 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmTofStarMonitor2018 ----- -// ----- Created 19.01.2018 by P.-A. Loizeau ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CbmTofStarMonitor2018_H -#define CbmTofStarMonitor2018_H - -#include "Timeslice.hpp" -#include "rocMess_wGet4v1.h" -#include "CbmTofStarData.h" - -#include "CbmTSUnpack.h" -#include "CbmHistManager.h" - -#include "TClonesArray.h" -#include "Rtypes.h" - -#include <vector> -#include <map> -#include <chrono> - -class CbmTofUnpackPar; - -class CbmTofStarMonitor2018: public CbmTSUnpack { - public: - - CbmTofStarMonitor2018(); - virtual ~CbmTofStarMonitor2018(); - - virtual Bool_t Init(); - - virtual Bool_t DoUnpack(const fles::Timeslice& ts, size_t component); - - virtual void Reset(); - - virtual void Finish(); - - void SetParContainers(); - - Bool_t InitContainers(); - - Bool_t ReInitContainers(); - - void FillOutput(boost::any); - - void SetMsLimitLevel(size_t uAcceptBoundaryPct = 100) { - fuMsAcceptsPercent = uAcceptBoundaryPct; - } - size_t GetMsLimitLevel() { - return fuMsAcceptsPercent; - } - - void SetMsOverlap(size_t uOverlapMsNb = 1) { - fuOverlapMsNb = uOverlapMsNb; - } - size_t GetMsOverlap() { - return fuOverlapMsNb; - } - - void SetPerTsSpillOnThr( Int_t iThrIn = 10 ) { fiSpillOnThr = iThrIn; } - void SetPerTsSpillOffThr( Int_t iThrIn = 3 ) { fiSpillOffThr = iThrIn; } - void SetTsNbSpillOffThr( Int_t iThrIn = 10 ) { fiTsUnderOffThr = iThrIn; } - - void SetEpochSuppressedMode( Bool_t bEnable = kTRUE ) { fbEpochSuppModeOn = bEnable; } - - void SetRunStart( Int_t dateIn, Int_t timeIn, Int_t iBinSize = 5 ); - - inline void SetGet4Mode24b( Bool_t inGet4Mode24b = kTRUE ) { fbGet4M24b = inGet4Mode24b; } - inline void SetGet4v20Mode( Bool_t inGet4v20Mode = kTRUE ) { fbGet4v20 = inGet4v20Mode; } - inline void SetMergedEpochs( Bool_t inMergedEpochs = kTRUE ) { fbMergedEpochsOn = inMergedEpochs; } - inline void SetPulserMode( Bool_t inPulserMode = kTRUE ) { fbPulserMode = inPulserMode; SetPulserChans(); } - inline void SetPulserFee( UInt_t inPulserGdpb, UInt_t inPulserFee ) { fuPulserGdpb = inPulserGdpb; fuPulserFee = inPulserFee; } - void SetPulserChans( UInt_t inPulserChanA = 0, UInt_t inPulserChanB = 1, UInt_t inPulserChanC = 2, - UInt_t inPulserChanD = 3, UInt_t inPulserChanE = 4, UInt_t inPulserChanF = 5, - UInt_t inPulserChanG = 6, UInt_t inPulserChanH = 7, UInt_t inPulserChanI = 8, - UInt_t inPulserChanJ = 9, UInt_t inPulserChanK = 10, UInt_t inPulserChanL = 11, - UInt_t inPulserChanM = 12, UInt_t inPulserChanN = 13, UInt_t inPulserChanO = 14, - UInt_t inPulserChanP = 15, UInt_t inPulserChanQ = 16, UInt_t inPulserChanR = 17 ); - inline void SetFitZoomWidthPs( Double_t inZoomWidth = 1000.0 ) { fdFitZoomWidthPs = inZoomWidth; } - inline void SetHistoryHistoSize( UInt_t inHistorySizeSec = 1800 ) { fuHistoryHistoSize = inHistorySizeSec; } - inline void SetHistoryHistoSizeLong( UInt_t inHistorySizeMin = 1800 ) { fuHistoryHistoSizeLong = inHistorySizeMin; } - - void SaveAllHistos( TString sFileName = "" ); - void ResetAllHistos(); - void UpdateNormedFt(); - void UpdateZoomedFit(); - - private: - - size_t fuMsAcceptsPercent; /** Reject Ms with index inside TS above this, assumes 100 MS per TS **/ - size_t fuOverlapMsNb; /** Ignore Overlap Ms: all fuOverlapMsNb MS at the end of timeslice **/ - UInt_t fuMinNbGdpb; - UInt_t fuCurrNbGdpb; - - UInt_t fNrOfGdpbs; // Total number of GDPBs in the system - UInt_t fNrOfFebsPerGdpb; // Number of FEBs per GDPB - UInt_t fNrOfGet4PerFeb; // Number of GET4s per FEB - UInt_t fNrOfChannelsPerGet4; // Number of channels in each GET4 - - UInt_t fNrOfChannelsPerFeet; // Number of channels in each FEET - UInt_t fNrOfGet4; // Total number of Get4 chips in the system - UInt_t fNrOfGet4PerGdpb; // Number of GET4s per GDPB - UInt_t fuNbChannelsPerGdpb; // Number of channels in each gDPB - - Int_t fiCountsLastTs; - Int_t fiSpillOnThr; - Int_t fiSpillOffThr; - Int_t fiTsUnderOff; - Int_t fiTsUnderOffThr; - Double_t fdDetLastTime; - Double_t fdDetTimeLastTs; - Bool_t fbSpillOn; - UInt_t fSpillIdx; - - Bool_t fbEpochSuppModeOn; - std::vector< std::vector < ngdpb::Message > > fvmEpSupprBuffer; - - UInt_t fGdpbId; // Id (hex number)of the GDPB which is read from the message - UInt_t fGdpbNr; // running number (0 to fNrOfGdpbs) of the GDPB in the - UInt_t fGet4Id; // running number (0 to fNrOfGet4PerGdpb) of the Get4 chip of a unique GDPB - UInt_t fGet4Nr; // running number (0 to fNrOfGet4) of the Get4 chip in the system - - std::vector<int> fMsgCounter; - - std::map<UInt_t, UInt_t> fGdpbIdIndexMap; - - CbmHistManager* fHM; ///< Histogram manager - - /** Current epoch marker for each GDPB and GET4 - * (first epoch in the stream initializes the map item) - * pointer points to an array of size fNrOfGdpbs * fNrOfGet4PerGdpb - * The correct array index is calculated using the function - * GetArrayIndex(gdpbId, get4Id) - **/ - Long64_t* fCurrentEpoch; //! - - Int_t fNofEpochs; /** Current epoch marker for each ROC **/ - ULong_t fCurrentEpochTime; /** Time stamp of current epoch **/ - Double_t fdStartTime; /** Time of first valid hit (epoch available), used as reference for evolution plots**/ - Double_t fdStartTimeLong; /** Time of first valid hit (epoch available), used as reference for evolution plots**/ - Double_t fdStartTimeMsSz; /** Time of first microslice, used as reference for evolution plots**/ - TCanvas* fcMsSizeAll; - - /** Used only if the channel rate or pulse hit difference plots are enabled **/ - /** Last Hit time for each gDPB/GET4/Channel **/ - std::vector< std::vector< std::vector< Double_t > > > fTsLastHit; // * 6.25 ns - - Int_t fEquipmentId; - Double_t fdMsIndex; - - CbmTofUnpackPar* fUnpackPar; //! - - TH1* fHistMessType; - TH1* fHistSysMessType; - TH2* fHistGet4MessType; - TH2* fHistGet4ChanScm; - TH2* fHistGet4ChanErrors; - TH2* fHistGet4EpochFlags; - TH2* fHistSpill; - TH1* fHistSpillLength; - TH1* fHistSpillCount; - TH2* fHistSpillQA; - - TH2* fhScmScalerCounters; - TH2* fhScmDeadtimeCounters; - TH2* fhScmSeuCounters; - TH2* fhScmSeuCountersEvo; - - Double_t fdTimeLastStartMessage; - TH1* fhScmStartMessDist; - TH1* fhScmStartMessEvo; - - std::vector<TH2*> fRaw_Tot_gDPB; - std::vector<TH1*> fChCount_gDPB; - std::vector<TH2*> fChannelRate_gDPB; - std::vector<TH1*> fFeetRate_gDPB; - std::vector<TH1*> fFeetErrorRate_gDPB; - UInt_t fuHistoryHistoSize; - - std::vector<TH1*> fFeetRateLong_gDPB; - std::vector<TH1*> fFeetErrorRateLong_gDPB; - UInt_t fuHistoryHistoSizeLong; - - std::vector<TH1*> fFeetRateDate_gDPB; - Int_t fiRunStartDateTimeSec; - Int_t fiBinSizeDatePlots; - - Double_t fdFirstMsIndex; - std::vector<Bool_t> fbFirstEpochInMsFound; - std::vector<TH1*> fRealMsFineQa_gDPB; - std::vector<TProfile*> fRealMsMidQa_gDPB; - std::vector<TProfile*> fRealMsCoarseQa_gDPB; - - ///* ASIC coincidences & offsets mapping */// -/* - ULong64_t fulLastMsIdx; - Bool_t fbHitsInLastTs; - std::vector< std::vector< Long64_t > > fvulHitEpochBuffLastTs; //! Dims: [gDPB][hits] - std::vector< TH2 * > fvhCoincOffsetEpochGet4; //! Dims: [gDPB - 1] -*/ - - ///* STAR TRIGGER detection */// - ULong64_t fulGdpbTsMsb; - ULong64_t fulGdpbTsLsb; - ULong64_t fulStarTsMsb; - ULong64_t fulStarTsMid; - ULong64_t fulGdpbTsFullLast; - ULong64_t fulStarTsFullLast; - UInt_t fuStarTokenLast; - UInt_t fuStarDaqCmdLast; - UInt_t fuStarTrigCmdLast; - TH1 * fhTokenMsgType; - TH1 * fhTriggerRate; - TH2 * fhCmdDaqVsTrig; - TH2 * fhStarTokenEvo; - - ///* STAR and pulser monitoring */// - static const UInt_t kuNbChanTest = 18; - Bool_t fbGet4M24b; - Bool_t fbGet4v20; - Bool_t fbMergedEpochsOn; - Bool_t fbPulserMode; - UInt_t fuPulserGdpb; - UInt_t fuPulserFee; - UInt_t fuPulserChan[kuNbChanTest]; //! Always in first gDPB !!! - std::vector<TH1 *> fhTimeDiffPulserChosenFee; - std::vector<TH1 *> fhTimeDiffPulserChosenChPairs; - TH2 * fhTimeRmsPulserChosenFee; - TH1 * fhTimeRmsPulserChosenChPairs; - Double_t fdLastRmsUpdateTime; - Double_t fdFitZoomWidthPs; - TH2 * fhTimeRmsZoomPulsChosenFee; - TH1 * fhTimeRmsZoomFitPulsChosenChPairs; - TH2 * fhTimeResFitPulsChosenFee; - TH1 * fhTimeResFitPulsChosenChPairs; - std::vector<TH2 *> fhFtDistribPerCh; - std::vector<TH1*> fChCountFall_gDPB; - std::vector<TH2 *> fhFtDistribPerChFall; - std::vector<TH1*> fSelChFtNormDnlRise; - std::vector<TH1*> fSelChFtNormDnlFall; - std::vector<TH1*> fFtNormDnlMinRise; - std::vector<TH1*> fFtNormDnlMaxRise; - std::vector<TH1*> fFtNormDnlMinFall; - std::vector<TH1*> fFtNormDnlMaxFall; - TH1 * fhTempHistInlRise; - TH1 * fhTempHistInlFall; - std::vector<TH1*> fSelChFtNormInlRise; - std::vector<TH1*> fSelChFtNormInlFall; - std::vector<TH1*> fFtNormInlMinRise; - std::vector<TH1*> fFtNormInlMaxRise; - std::vector<TH1*> fFtNormInlMinFall; - std::vector<TH1*> fFtNormInlMaxFall; - std::vector< std::vector<Int_t> > fviFtLastRise24b; - std::vector< std::vector<Int_t> > fviFtLastFall24b; - std::vector< std::vector<Double_t> > fvdTimeLastRise24b; - std::vector< std::vector<Double_t> > fvdTimeLastFall24b; - UInt_t fuRiseFallChSel; - std::vector<TH2 *> fhFtLastRiseCurrFall; - std::vector<TH2 *> fhFtCurrRiseLastFall; - std::vector<TH2 *> fhFtLastRiseDistRise; - std::vector<TH2 *> fhFtLastRiseDistFall; - - void CreateHistograms(); - - void FillHitInfo(ngdpb::Message); - void FillEpochInfo(ngdpb::Message); - void PrintSlcInfo(ngdpb::Message); - void PrintSysInfo(ngdpb::Message); - void PrintGenInfo(ngdpb::Message); - void FillStarTrigInfo(ngdpb::Message); - void FillTrigEpochInfo(ngdpb::Message); - - inline Int_t GetArrayIndex(Int_t gdpbId, Int_t get4Id) { - return gdpbId * fNrOfGet4PerGdpb + get4Id; - } - - /// Histo and printout control - Int_t iMess; - Int_t iMessB; - // Default value for nb bins in Pulser time difference histos - //const UInt_t kuNbBinsDt = 5000; - const UInt_t kuNbBinsDt = 300; - Double_t dMinDt; - Double_t dMaxDt; - // Default number of FEET per channels histograms - UInt_t uNbFeetPlot; - UInt_t uNbFeetPlotsPerGdpb; - - CbmTofStarMonitor2018(const CbmTofStarMonitor2018&); - CbmTofStarMonitor2018 operator=(const CbmTofStarMonitor2018&); - - ClassDef(CbmTofStarMonitor2018, 1) -}; - -#endif diff --git a/beamtime/star2018/unpacker/CbmTofStarMonitorShift2018.cxx b/beamtime/star2018/unpacker/CbmTofStarMonitorShift2018.cxx deleted file mode 100644 index 2c01017a69674fe24d36606fba98f61f0a225bbe..0000000000000000000000000000000000000000 --- a/beamtime/star2018/unpacker/CbmTofStarMonitorShift2018.cxx +++ /dev/null @@ -1,2148 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmTofStarMonitorShift2018 ----- -// ----- Created 19.01.2018 by P.-A. Loizeau ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#include "CbmTofStarMonitorShift2018.h" -#include "CbmTofStar2018Par.h" - -//#include "CbmFlibCern2016Source.h" -#include "CbmHistManager.h" - -#include "FairLogger.h" -#include "FairRootManager.h" -#include "FairRun.h" -#include "FairRuntimeDb.h" -#include "FairRunOnline.h" - -#include "TROOT.h" -#include "TClonesArray.h" -#include "TString.h" -#include "THttpServer.h" -#include "Rtypes.h" -#include "TProfile.h" -#include "TH2.h" -#include "TH1.h" -#include "TF1.h" -#include "TCanvas.h" -#include "THStack.h" -#include "TROOT.h" -#include "TStyle.h" -#include "TPaveStats.h" -#include "TMath.h" -#include <TFile.h> - -#include <algorithm> -#include <iostream> -#include <stdint.h> -#include <iomanip> -#include <ctime> - -Bool_t bResetTofStarMoniShiftHistos = kFALSE; -Bool_t bSaveTofStarMoniShiftHistos = kFALSE; -Bool_t bTofUpdateZoomedFitMoniShift = kFALSE; - -CbmTofStarMonitorShift2018::CbmTofStarMonitorShift2018() : - CbmTSUnpack(), - fuMsAcceptsPercent(100), - fuTotalMsNb(0), - fuOverlapMsNb(0), - fuCoreMs(0), - fdMsSizeInNs(0.0), - fdTsCoreSizeInNs(0.0), - fuMinNbGdpb( 0 ), - fuCurrNbGdpb( 0 ), - fUnpackPar(), - fuNrOfGdpbs(0), - fuNrOfFeetPerGdpb(0), - fuNrOfGet4PerFeb(0), - fuNrOfChannelsPerGet4(0), - fuNrOfChannelsPerFeet(0), - fuNrOfGet4(0), - fuNrOfGet4PerGdpb(0), - fuNrOfChannelsPerGdpb(0), - fulCurrentTsIndex(0), - fuCurrentMs(0), - fdMsIndex(0), - fuGdpbId(0), - fuGdpbNr(0), - fuGet4Id(0), - fuGet4Nr(0), - fiEquipmentId(0), - fviMsgCounter(11, 0), // length of enum MessageTypes initialized with 0 - fvulGdpbTsMsb(), - fvulGdpbTsLsb(), - fvulStarTsMsb(), - fvulStarTsMid(), - fvulGdpbTsFullLast(), - fvulStarTsFullLast(), - fvuStarTokenLast(), - fvuStarDaqCmdLast(), - fvuStarTrigCmdLast(), - fvulCurrentEpoch(), - fvbFirstEpochSeen(), - fulCurrentEpochTime(0), - fGdpbIdIndexMap(), - fvmEpSupprBuffer(), - fdTsLastPulserHit(), - dMinDt(-1.*(kuNbBinsDt*get4v2x::kdBinSize/2.) - get4v2x::kdBinSize/2.), - dMaxDt(1.*(kuNbBinsDt*get4v2x::kdBinSize/2.) + get4v2x::kdBinSize/2.), - fuNbFeetPlot(2), - fuNbFeetPlotsPerGdpb(0), - fdStartTime(-1.), - fdStartTimeLong(-1.), - fdStartTimeMsSz(-1.), - fuHistoryHistoSize( 1800 ), - fuHistoryHistoSizeLong( 600 ), - fdLastRmsUpdateTime(0.0), - fdFitZoomWidthPs(0.0), - fcMsSizeAll(NULL), - fvhMsSzPerLink(12, NULL), - fvhMsSzTimePerLink(12, NULL), - fhMessType(NULL), - fhSysMessType(NULL), - fhGet4MessType(NULL), - fhGet4ChanScm(NULL), - fhGet4ChanErrors(NULL), - fhGet4EpochFlags(NULL), - fhScmScalerCounters(NULL), - fhScmDeadtimeCounters(NULL), - fhScmSeuCounters(NULL), - fhScmSeuCountersEvo(NULL), - fvhRawFt_gDPB(), - fvhRawTot_gDPB(), - fvhChCount_gDPB(), - fvhChannelRate_gDPB(), - fvhRemapTot_gDPB(), - fvhRemapChCount_gDPB(), - fvhRemapChRate_gDPB(), - fvhFeetRate_gDPB(), - fvhFeetErrorRate_gDPB(), - fvhFeetErrorRatio_gDPB(), - fvhFeetRateLong_gDPB(), - fvhFeetErrorRateLong_gDPB(), - fvhFeetErrorRatioLong_gDPB(), - fvhTokenMsgType(), - fvhTriggerRate(), - fvhCmdDaqVsTrig(), - fvhStarTokenEvo(), - fvhStarTrigGdpbTsEvo(), - fvhStarTrigStarTsEvo(), - fvhTimeDiffPulser(), - fhTimeRmsPulser(NULL), - fhTimeRmsZoomFitPuls(NULL), - fhTimeResFitPuls(NULL), - fvuPadiToGet4(), - fvuGet4ToPadi(), - fTimeLastHistoSaving() -{ -} - -CbmTofStarMonitorShift2018::~CbmTofStarMonitorShift2018() -{ -} - -Bool_t CbmTofStarMonitorShift2018::Init() -{ - LOG(info) << "Initializing Get4 monitor"; - - FairRootManager* ioman = FairRootManager::Instance(); - if( ioman == NULL ) - { - LOG(fatal) << "No FairRootManager instance"; - } // if( ioman == NULL ) - - return kTRUE; -} - -void CbmTofStarMonitorShift2018::SetParContainers() -{ - LOG(info) << "Setting parameter containers for " << GetName(); - fUnpackPar = (CbmTofStar2018Par*) (FairRun::Instance()->GetRuntimeDb()->getContainer( - "CbmTofStar2018Par") ); - -} - -Bool_t CbmTofStarMonitorShift2018::InitContainers() -{ - LOG(info) << "Init parameter containers for " << GetName(); - Bool_t initOK = ReInitContainers(); - - CreateHistograms(); - - fvulCurrentEpoch.resize( fuNrOfGdpbs * fuNrOfGet4PerGdpb ); - fvbFirstEpochSeen.resize( fuNrOfGdpbs * fuNrOfGet4PerGdpb ); - for( UInt_t i = 0; i < fuNrOfGdpbs; ++i ) - { - for( UInt_t j = 0; j < fuNrOfGet4PerGdpb; ++j ) - { - fvulCurrentEpoch[GetArrayIndex(i, j)] = 0; - } // for( UInt_t j = 0; j < fuNrOfGet4PerGdpb; ++j ) - } // for( UInt_t i = 0; i < fuNrOfGdpbs; ++i ) - - return initOK; -} - -Bool_t CbmTofStarMonitorShift2018::ReInitContainers() -{ - LOG(info) << "ReInit parameter containers for " << GetName(); - - fuNrOfGdpbs = fUnpackPar->GetNrOfRocs(); - LOG(info) << "Nr. of Tof GDPBs: " << fuNrOfGdpbs; - fuMinNbGdpb = fuNrOfGdpbs; - - fuNrOfFeetPerGdpb = fUnpackPar->GetNrOfFebsPerGdpb(); - LOG(info) << "Nr. of FEBS per Tof GDPB: " << fuNrOfFeetPerGdpb; - - fuNrOfGet4PerFeb = fUnpackPar->GetNrOfGet4PerFeb(); - LOG(info) << "Nr. of GET4 per Tof FEB: " << fuNrOfGet4PerFeb; - - fuNrOfChannelsPerGet4 = fUnpackPar->GetNrOfChannelsPerGet4(); - LOG(info) << "Nr. of channels per GET4: " << fuNrOfChannelsPerGet4; - - fuNrOfChannelsPerFeet = fuNrOfGet4PerFeb * fuNrOfChannelsPerGet4; - LOG(info) << "Nr. of channels per FEET: " << fuNrOfChannelsPerFeet; - - fuNrOfGet4 = fuNrOfGdpbs * fuNrOfFeetPerGdpb * fuNrOfGet4PerFeb; - LOG(info) << "Nr. of GET4s: " << fuNrOfGet4; - - fuNrOfGet4PerGdpb = fuNrOfFeetPerGdpb * fuNrOfGet4PerFeb; - LOG(info) << "Nr. of GET4s per GDPB: " << fuNrOfGet4PerGdpb; - - fuNrOfChannelsPerGdpb = fuNrOfGet4PerGdpb * fuNrOfChannelsPerGet4; - LOG(info) << "Nr. of channels per GDPB: " << fuNrOfChannelsPerGdpb; - - fGdpbIdIndexMap.clear(); - for( UInt_t i = 0; i < fuNrOfGdpbs; ++i ) - { - fGdpbIdIndexMap[fUnpackPar->GetRocId(i)] = i; - LOG(info) << "GDPB Id of TOF " << i << " : " << std::hex << fUnpackPar->GetRocId(i) - << std::dec; - } // for( UInt_t i = 0; i < fuNrOfGdpbs; ++i ) - UInt_t uNrOfChannels = fUnpackPar->GetNumberOfChannels(); - LOG(info) << "Nr. of mapped Tof channels: " << uNrOfChannels; - std::stringstream ss; - for( UInt_t i = 0; i < uNrOfChannels; ++i) - { - if(i%8 == 0) - ss << "\n"; - ss << Form(" 0x%08x",fUnpackPar->GetChannelToDetUIdMap(i)); - } // for( UInt_t i = 0; i < uNrOfChannels; ++i) - LOG(info) << ss.str(); - - fuTotalMsNb = fUnpackPar->GetNbMsTot(); - fuOverlapMsNb = fUnpackPar->GetNbMsOverlap(); - fuCoreMs = fuTotalMsNb - fuOverlapMsNb; - fdMsSizeInNs = fUnpackPar->GetSizeMsInNs(); - fdTsCoreSizeInNs = fdMsSizeInNs * fuCoreMs; - LOG(info) << "Timeslice parameters: " - << fuTotalMsNb << " MS per link, of which " - << fuOverlapMsNb << " overlap MS, each MS is " - << fdMsSizeInNs << " ns"; - - /// STAR Trigger decoding and monitoring - fvulGdpbTsMsb.resize( fuNrOfGdpbs ); - fvulGdpbTsLsb.resize( fuNrOfGdpbs ); - fvulStarTsMsb.resize( fuNrOfGdpbs ); - fvulStarTsMid.resize( fuNrOfGdpbs ); - fvulGdpbTsFullLast.resize( fuNrOfGdpbs ); - fvulStarTsFullLast.resize( fuNrOfGdpbs ); - fvuStarTokenLast.resize( fuNrOfGdpbs ); - fvuStarDaqCmdLast.resize( fuNrOfGdpbs ); - fvuStarTrigCmdLast.resize( fuNrOfGdpbs ); - for (UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb) - { - fvulGdpbTsMsb[ uGdpb ] = 0; - fvulGdpbTsLsb[ uGdpb ] = 0; - fvulStarTsMsb[ uGdpb ] = 0; - fvulStarTsMid[ uGdpb ] = 0; - fvulGdpbTsFullLast[ uGdpb ] = 0; - fvulStarTsFullLast[ uGdpb ] = 0; - fvuStarTokenLast[ uGdpb ] = 0; - fvuStarDaqCmdLast[ uGdpb ] = 0; - fvuStarTrigCmdLast[ uGdpb ] = 0; - } // for (Int_t iGdpb = 0; iGdpb < fuNrOfGdpbs; ++iGdpb) - - fvmEpSupprBuffer.resize( fuNrOfGet4 ); - - ///* Pulser monitoring */// - fdTsLastPulserHit.resize( fuNrOfFeetPerGdpb * fuNrOfGdpbs, 0.0 ); - -/// TODO: move these constants somewhere shared, e.g the parameter file - fvuPadiToGet4.resize( fuNrOfChannelsPerFeet ); - fvuGet4ToPadi.resize( fuNrOfChannelsPerFeet ); - UInt_t uGet4topadi[32] = { - 4, 3, 2, 1, // provided by Jochen - 24, 23, 22, 21, - 8, 7, 6, 5, - 28, 27, 26, 25, - 12, 11, 10, 9, - 32, 31, 30, 29, - 16, 15, 14, 13, - 20, 19, 18, 17 }; - - UInt_t uPaditoget4[32] = { - 4, 3, 2, 1, // provided by Jochen - 12, 11, 10, 9, - 20, 19, 18, 17, - 28, 27, 26, 25, - 32, 31, 30, 29, - 8, 7, 6, 5, - 16, 15, 14, 13, - 24, 23, 22, 21 }; - - for( UInt_t uChan = 0; uChan < fuNrOfChannelsPerFeet; ++uChan ) - { - fvuPadiToGet4[ uChan ] = uPaditoget4[ uChan ] - 1; - fvuGet4ToPadi[ uChan ] = uGet4topadi[ uChan ] - 1; - } // for( UInt_t uChan = 0; uChan < fuNrOfChannelsPerFeet; ++uChan ) - - return kTRUE; -} - -void CbmTofStarMonitorShift2018::CreateHistograms() -{ - LOG(info) << "create Histos for " << fuNrOfGdpbs <<" gDPBs "; - - THttpServer* server = FairRunOnline::Instance()->GetHttpServer(); - - TString name { "" }; - TString title { "" }; - - // Full Fee time difference test - UInt_t uNbBinsDt = kuNbBinsDt + 1; // To account for extra bin due to shift by 1/2 bin of both ranges - - fuNbFeetPlotsPerGdpb = fuNrOfFeetPerGdpb/fuNbFeetPlot + ( 0 != fuNrOfFeetPerGdpb%fuNbFeetPlot ? 1 : 0 ); - Double_t dBinSzG4v2 = (6250. / 112.); - dMinDt = -1.*(kuNbBinsDt*dBinSzG4v2/2.) - dBinSzG4v2/2.; - dMaxDt = 1.*(kuNbBinsDt*dBinSzG4v2/2.) + dBinSzG4v2/2.; - - /*******************************************************************/ - name = "hMessageType"; - title = "Nb of message for each type; Type"; - // Test Big Data readout with plotting - fhMessType = new TH1I(name, title, 16, 0., 16.); - fhMessType->GetXaxis()->SetBinLabel(1 + gdpb::MSG_NOP, "NOP"); - fhMessType->GetXaxis()->SetBinLabel(1 + gdpb::MSG_HIT, "HIT"); - fhMessType->GetXaxis()->SetBinLabel(1 + gdpb::MSG_EPOCH, "EPOCH"); - fhMessType->GetXaxis()->SetBinLabel(1 + gdpb::MSG_SYNC, "SYNC"); - fhMessType->GetXaxis()->SetBinLabel(1 + gdpb::MSG_AUX, "AUX"); - fhMessType->GetXaxis()->SetBinLabel(1 + gdpb::MSG_EPOCH2, "EPOCH2"); - fhMessType->GetXaxis()->SetBinLabel(1 + gdpb::MSG_GET4, "GET4"); - fhMessType->GetXaxis()->SetBinLabel(1 + gdpb::MSG_SYS, "SYS"); - fhMessType->GetXaxis()->SetBinLabel(1 + gdpb::MSG_GET4_SLC, "MSG_GET4_SLC"); - fhMessType->GetXaxis()->SetBinLabel(1 + gdpb::MSG_GET4_32B, "MSG_GET4_32B"); - fhMessType->GetXaxis()->SetBinLabel(1 + gdpb::MSG_GET4_SYS, "MSG_GET4_SYS"); - fhMessType->GetXaxis()->SetBinLabel(1 + gdpb::MSG_STAR_TRI, "MSG_STAR_TRI"); - fhMessType->GetXaxis()->SetBinLabel(1 + 15, "GET4 Hack 32B"); - fhMessType->GetXaxis()->SetBinLabel(1 + gdpb::MSG_NOP, "NOP"); - - /*******************************************************************/ - name = "hSysMessType"; - title = "Nb of system message for each type; System Type"; - fhSysMessType = new TH1I(name, title, 17, 0., 17.); - fhSysMessType->GetXaxis()->SetBinLabel(1 + gdpb::SYSMSG_DAQ_START, "DAQ START"); - fhSysMessType->GetXaxis()->SetBinLabel(1 + gdpb::SYSMSG_DAQ_FINISH, "DAQ FINISH"); - fhSysMessType->GetXaxis()->SetBinLabel(1 + gdpb::SYSMSG_NX_PARITY, "NX PARITY"); - fhSysMessType->GetXaxis()->SetBinLabel(1 + gdpb::SYSMSG_SYNC_PARITY, "SYNC PARITY"); - fhSysMessType->GetXaxis()->SetBinLabel(1 + gdpb::SYSMSG_DAQ_RESUME, "DAQ RESUME"); - fhSysMessType->GetXaxis()->SetBinLabel(1 + gdpb::SYSMSG_FIFO_RESET, "FIFO RESET"); - fhSysMessType->GetXaxis()->SetBinLabel(1 + gdpb::SYSMSG_USER, "USER"); - fhSysMessType->GetXaxis()->SetBinLabel(1 + gdpb::SYSMSG_PCTIME, "PCTIME"); - fhSysMessType->GetXaxis()->SetBinLabel(1 + gdpb::SYSMSG_ADC, "ADC"); - fhSysMessType->GetXaxis()->SetBinLabel(1 + gdpb::SYSMSG_PACKETLOST, "PACKET LOST"); - fhSysMessType->GetXaxis()->SetBinLabel(1 + gdpb::SYSMSG_GET4_EVENT, "GET4 ERROR"); - fhSysMessType->GetXaxis()->SetBinLabel(1 + gdpb::SYSMSG_CLOSYSYNC_ERROR, "CLOSYSYNC ERROR"); - fhSysMessType->GetXaxis()->SetBinLabel(1 + gdpb::SYSMSG_TS156_SYNC, "TS156 SYNC"); - fhSysMessType->GetXaxis()->SetBinLabel(1 + gdpb::SYSMSG_GDPB_UNKWN, "UNKW GET4 MSG"); - fhSysMessType->GetXaxis()->SetBinLabel(1 + 16, "GET4 Hack 32B"); - - /*******************************************************************/ - name = "hGet4MessType"; - title = "Nb of message for each type per GET4; GET4 chip # ; Type"; - fhGet4MessType = new TH2I(name, title, fuNrOfGet4, 0., fuNrOfGet4, 5, 0., 5.); - fhGet4MessType->GetYaxis()->SetBinLabel(1 + gdpb::GET4_32B_EPOCH, "EPOCH"); - fhGet4MessType->GetYaxis()->SetBinLabel(1 + gdpb::GET4_32B_SLCM, "S.C. M"); - fhGet4MessType->GetYaxis()->SetBinLabel(1 + gdpb::GET4_32B_ERROR, "ERROR"); - fhGet4MessType->GetYaxis()->SetBinLabel(1 + gdpb::GET4_32B_DATA, "DATA 32b"); - fhGet4MessType->GetYaxis()->SetBinLabel(1 + gdpb::GET4_32B_DATA + 1, "DATA 24b"); - - /*******************************************************************/ - name = "hGet4ChanScm"; - title = "SC messages per GET4 channel; GET4 channel # ; SC type"; - fhGet4ChanScm = new TH2I(name, title, - 2 * fuNrOfGet4 * fuNrOfChannelsPerGet4, 0., fuNrOfGet4 * fuNrOfChannelsPerGet4, - 5, 0., 5.); - fhGet4ChanScm->GetYaxis()->SetBinLabel( 1, "Hit Scal" ); - fhGet4ChanScm->GetYaxis()->SetBinLabel( 2, "Deadtime" ); - fhGet4ChanScm->GetYaxis()->SetBinLabel( 3, "SPI" ); - fhGet4ChanScm->GetYaxis()->SetBinLabel( 4, "SEU Scal" ); - fhGet4ChanScm->GetYaxis()->SetBinLabel( 5, "START" ); - - /*******************************************************************/ - name = "hGet4ChanErrors"; - title = "Error messages per GET4 channel; GET4 channel # ; Error"; - fhGet4ChanErrors = new TH2I(name, title, - fuNrOfGet4 * fuNrOfChannelsPerGet4, 0., fuNrOfGet4 * fuNrOfChannelsPerGet4, - 21, 0., 21.); - fhGet4ChanErrors->GetYaxis()->SetBinLabel( 1, "0x00: Readout Init "); - fhGet4ChanErrors->GetYaxis()->SetBinLabel( 2, "0x01: Sync "); - fhGet4ChanErrors->GetYaxis()->SetBinLabel( 3, "0x02: Epoch count sync"); - fhGet4ChanErrors->GetYaxis()->SetBinLabel( 4, "0x03: Epoch "); - fhGet4ChanErrors->GetYaxis()->SetBinLabel( 5, "0x04: FIFO Write "); - fhGet4ChanErrors->GetYaxis()->SetBinLabel( 6, "0x05: Lost event "); - fhGet4ChanErrors->GetYaxis()->SetBinLabel( 7, "0x06: Channel state "); - fhGet4ChanErrors->GetYaxis()->SetBinLabel( 8, "0x07: Token Ring state"); - fhGet4ChanErrors->GetYaxis()->SetBinLabel( 9, "0x08: Token "); - fhGet4ChanErrors->GetYaxis()->SetBinLabel(10, "0x09: Error Readout "); - fhGet4ChanErrors->GetYaxis()->SetBinLabel(11, "0x0a: SPI "); - fhGet4ChanErrors->GetYaxis()->SetBinLabel(12, "0x0b: DLL Lock error "); // <- From GET4 v1.2 - fhGet4ChanErrors->GetYaxis()->SetBinLabel(13, "0x0c: DLL Reset invoc."); // <- From GET4 v1.2 - fhGet4ChanErrors->GetYaxis()->SetBinLabel(14, "0x11: Overwrite "); - fhGet4ChanErrors->GetYaxis()->SetBinLabel(15, "0x12: ToT out of range"); - fhGet4ChanErrors->GetYaxis()->SetBinLabel(16, "0x13: Event Discarded "); - fhGet4ChanErrors->GetYaxis()->SetBinLabel(17, "0x14: Add. Rising edge"); // <- From GET4 v1.3 - fhGet4ChanErrors->GetYaxis()->SetBinLabel(18, "0x15: Unpaired Falling"); // <- From GET4 v1.3 - fhGet4ChanErrors->GetYaxis()->SetBinLabel(19, "0x16: Sequence error "); // <- From GET4 v1.3 - fhGet4ChanErrors->GetYaxis()->SetBinLabel(20, "0x7f: Unknown "); - fhGet4ChanErrors->GetYaxis()->SetBinLabel(21, "Corrupt/unsuprtd error"); - - /*******************************************************************/ - name = "hGet4EpochFlags"; - title = "Epoch flags per GET4; GET4 chip # ; Type"; - fhGet4EpochFlags = new TH2I(name, title, fuNrOfGet4, 0., fuNrOfGet4, 4, 0., 4.); - fhGet4EpochFlags->GetYaxis()->SetBinLabel(1, "SYNC"); - fhGet4EpochFlags->GetYaxis()->SetBinLabel(2, "Ep LOSS"); - fhGet4EpochFlags->GetYaxis()->SetBinLabel(3, "Da LOSS"); - fhGet4EpochFlags->GetYaxis()->SetBinLabel(4, "MISSMAT"); - - /*******************************************************************/ - // Slow control messages analysis - name = "hScmScalerCounters"; - title = "Content of Scaler counter SC messages; Scaler counter [hit]; Channel []"; - fhScmScalerCounters = new TH2I(name, title, fuNrOfGet4 * fuNrOfChannelsPerGet4 * 2, 0., fuNrOfGet4 * fuNrOfChannelsPerGet4, - 8192, 0., 8192.); - - name = "hScmDeadtimeCounters"; - title = "Content of Deadtime counter SC messages; Deadtime [Clk Cycles]; Channel []"; - fhScmDeadtimeCounters = new TH2I(name, title, fuNrOfGet4 * fuNrOfChannelsPerGet4 * 2, 0., fuNrOfGet4 * fuNrOfChannelsPerGet4, - 8192, 0., 8192.); - - name = "hScmSeuCounters"; - title = "Content of SEU counter SC messages; SEU []; Channel []"; - fhScmSeuCounters = new TH2I(name, title, fuNrOfGet4 * fuNrOfChannelsPerGet4 * 2, 0., fuNrOfGet4 * fuNrOfChannelsPerGet4, - 8192, 0., 8192.); - - name = "hScmSeuCountersEvo"; - title = "SEU counter rate from SC messages; Time in Run [s]; Channel []; SEU []"; - fhScmSeuCountersEvo = new TH2I(name, title, fuNrOfGet4 * fuNrOfChannelsPerGet4 * 2, 0., fuNrOfGet4 * fuNrOfChannelsPerGet4, - fuHistoryHistoSize, 0., fuHistoryHistoSize); - - /*******************************************************************/ - for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb ) - { - /**++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++**/ - name = Form("RawFt_gDPB_%02u", uGdpb); - title = Form("Raw FineTime gDPB %02u Plot 0; channel; FineTime [bin]", uGdpb); - fvhRawFt_gDPB.push_back( - new TH2F(name.Data(), title.Data(), - fuNrOfChannelsPerGdpb, 0, fuNrOfChannelsPerGdpb, - 128, 0, 128 ) ); - - /**++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++**/ - name = Form("RawTot_gDPB_%02u_0", uGdpb); - title = Form("Raw TOT gDPB %02u Plot 0; channel; TOT [bin]", uGdpb); - fvhRawTot_gDPB.push_back( - new TH2F(name.Data(), title.Data(), - fuNbFeetPlot*fuNrOfChannelsPerFeet, 0*fuNbFeetPlot*fuNrOfChannelsPerFeet, 1*fuNbFeetPlot*fuNrOfChannelsPerFeet, - 256, 0, 256 ) ); - - if( fuNbFeetPlot < fuNrOfFeetPerGdpb ) - { - name = Form("RawTot_gDPB_%02u_1", uGdpb); - title = Form("Raw TOT gDPB %02u Plot 1; channel; TOT [bin]", uGdpb); - fvhRawTot_gDPB.push_back( - new TH2F(name.Data(), title.Data(), - fuNbFeetPlot*fuNrOfChannelsPerFeet, 1*fuNbFeetPlot*fuNrOfChannelsPerFeet, 2*fuNbFeetPlot*fuNrOfChannelsPerFeet, - 256, 0, 256)); - } // if( fuNbFeetPlot < fuNrOfFeetPerGdpb ) - if( 2 * fuNbFeetPlot < fuNrOfFeetPerGdpb ) - { - name = Form("RawTot_gDPB_%02u_2", uGdpb); - title = Form("Raw TOT gDPB %02u Plot 2; channel; TOT [bin]", uGdpb); - fvhRawTot_gDPB.push_back( - new TH2F(name.Data(), title.Data(), - fuNbFeetPlot*fuNrOfChannelsPerFeet, 2*fuNbFeetPlot*fuNrOfChannelsPerFeet, 3*fuNbFeetPlot*fuNrOfChannelsPerFeet, - 256, 0, 256)); - } // if( 2 * fuNbFeetPlot < fuNrOfFeetPerGdpb ) - - /**++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++**/ - name = Form("ChCount_gDPB_%02u", uGdpb); - title = Form("Channel counts gDPB %02u; channel; Hits", uGdpb); - fvhChCount_gDPB.push_back( new TH1I(name.Data(), title.Data(), - fuNrOfFeetPerGdpb * fuNrOfChannelsPerFeet, 0, fuNrOfFeetPerGdpb * fuNrOfChannelsPerFeet) ); - - /**++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++**/ - name = Form("ChRate_gDPB_%02u", uGdpb); - title = Form("Channel rate gDPB %02u; Time in run [s]; channel; Rate [1/s]", uGdpb); - fvhChannelRate_gDPB.push_back( new TH2D(name.Data(), title.Data(), - fuHistoryHistoSize, 0, fuHistoryHistoSize, - fuNrOfFeetPerGdpb * fuNrOfChannelsPerFeet, 0, fuNrOfFeetPerGdpb * fuNrOfChannelsPerFeet ) ); - - /**++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++**/ - name = Form("RemapTot_gDPB_%02u_0", uGdpb); - title = Form("Raw TOT gDPB %02u remapped Plot 0; PADI channel; TOT [bin]", uGdpb); - fvhRemapTot_gDPB.push_back( - new TH2F(name.Data(), title.Data(), - fuNbFeetPlot*fuNrOfChannelsPerFeet, 0*fuNbFeetPlot*fuNrOfChannelsPerFeet, 1*fuNbFeetPlot*fuNrOfChannelsPerFeet, - 256, 0, 256 ) ); - - if( fuNbFeetPlot < fuNrOfFeetPerGdpb ) - { - name = Form("RemapTot_gDPB_%02u_1", uGdpb); - title = Form("Raw TOT gDPB %02u remapped Plot 1; PADI channel; TOT [bin]", uGdpb); - fvhRemapTot_gDPB.push_back( - new TH2F(name.Data(), title.Data(), - fuNbFeetPlot*fuNrOfChannelsPerFeet, 1*fuNbFeetPlot*fuNrOfChannelsPerFeet, 2*fuNbFeetPlot*fuNrOfChannelsPerFeet, - 256, 0, 256)); - } // if( fuNbFeetPlot < fuNrOfFeetPerGdpb ) - if( 2 * fuNbFeetPlot < fuNrOfFeetPerGdpb ) - { - name = Form("RemapTot_gDPB_%02u_2", uGdpb); - title = Form("Raw TOT gDPB %02u remapped Plot 2; PADI channel; TOT [bin]", uGdpb); - fvhRemapTot_gDPB.push_back( - new TH2F(name.Data(), title.Data(), - fuNbFeetPlot*fuNrOfChannelsPerFeet, 2*fuNbFeetPlot*fuNrOfChannelsPerFeet, 3*fuNbFeetPlot*fuNrOfChannelsPerFeet, - 256, 0, 256)); - } // if( 2 * fuNbFeetPlot < fuNrOfFeetPerGdpb ) - - /**++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++**/ - name = Form("RemapChCount_gDPB_%02u", uGdpb); - title = Form("Channel counts gDPB %02u remapped; PADI channel; Hits", uGdpb); - fvhRemapChCount_gDPB.push_back( new TH1I(name.Data(), title.Data(), - fuNrOfFeetPerGdpb * fuNrOfChannelsPerFeet, 0, fuNrOfFeetPerGdpb * fuNrOfChannelsPerFeet) ); - - /**++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++**/ - name = Form("RemapChRate_gDPB_%02u", uGdpb); - title = Form("PADI channel rate gDPB %02u; Time in run [s]; PADI channel; Rate [1/s]", uGdpb); - fvhRemapChRate_gDPB.push_back( new TH2D(name.Data(), title.Data(), - fuHistoryHistoSize, 0, fuHistoryHistoSize, - fuNrOfFeetPerGdpb * fuNrOfChannelsPerFeet, 0, fuNrOfFeetPerGdpb * fuNrOfChannelsPerFeet ) ); - - /**++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++**/ - for (UInt_t uFeet = 0; uFeet < fuNrOfFeetPerGdpb; ++ uFeet) - { - name = Form("FeetRate_gDPB_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "Counts per second in Feet %1u of gDPB %02u; Time[s] ; Counts", uFeet, - uGdpb); - fvhFeetRate_gDPB.push_back( new TH1D(name.Data(), title.Data(), fuHistoryHistoSize, 0, fuHistoryHistoSize) ); - - name = Form("FeetErrorRate_gDPB_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "Error Counts per second in Feet %1u of gDPB %02u; Time[s] ; Error Counts", uFeet, - uGdpb); - fvhFeetErrorRate_gDPB.push_back( new TH1D(name.Data(), title.Data(), fuHistoryHistoSize, 0, fuHistoryHistoSize) ); - - name = Form("FeetErrorRatio_gDPB_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "Error to data ratio per second in Feet %1u of gDPB %02u; Time[s] ; Error ratio[]", uFeet, - uGdpb); - fvhFeetErrorRatio_gDPB.push_back( new TProfile(name.Data(), title.Data(), fuHistoryHistoSize, 0, fuHistoryHistoSize) ); - - name = Form("FeetRateLong_gDPB_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "Counts per minutes in Feet %1u of gDPB %02u; Time[min] ; Counts", uFeet, - uGdpb); - fvhFeetRateLong_gDPB.push_back( new TH1D(name.Data(), title.Data(), fuHistoryHistoSizeLong, 0, fuHistoryHistoSizeLong) ); - - name = Form("FeetErrorRateLong_gDPB_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "Error Counts per minutes in Feet %1u of gDPB %02u; Time[min] ; Error Counts", uFeet, - uGdpb); - fvhFeetErrorRateLong_gDPB.push_back( new TH1D(name.Data(), title.Data(), fuHistoryHistoSizeLong, 0, fuHistoryHistoSizeLong) ); - - name = Form("FeetErrorRatioLong_gDPB_g%02u_f%1u", uGdpb, uFeet); - title = Form( - "Error to data ratio per minutes in Feet %1u of gDPB %02u; Time[min] ; Error ratio[]", uFeet, - uGdpb); - fvhFeetErrorRatioLong_gDPB.push_back( new TProfile(name.Data(), title.Data(), fuHistoryHistoSizeLong, 0, fuHistoryHistoSizeLong) ); - } // for (UInt_t uFeet = 0; uFeet < fuNrOfFeetPerGdpb; uFeet++) - - /**++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++**/ - /// STAR Trigger decoding and monitoring - name = Form( "hTokenMsgType_gDPB_%02u", uGdpb); - title = Form( "STAR trigger Messages type gDPB %02u; Type ; Counts", uGdpb); - fvhTokenMsgType.push_back( new TH1F(name, title, 4, 0, 4) ); - fvhTokenMsgType[ uGdpb ]->GetXaxis()->SetBinLabel( 1, "A"); // gDPB TS high - fvhTokenMsgType[ uGdpb ]->GetXaxis()->SetBinLabel( 2, "B"); // gDPB TS low, STAR TS high - fvhTokenMsgType[ uGdpb ]->GetXaxis()->SetBinLabel( 3, "C"); // STAR TS mid - fvhTokenMsgType[ uGdpb ]->GetXaxis()->SetBinLabel( 4, "D"); // STAR TS low, token, CMDs - if (server) - server->Register("/StarRaw", fvhTokenMsgType[ uGdpb ] ); - - name = Form( "hTriggerRate_gDPB_%02u", uGdpb); - title = Form( "STAR trigger signals per second gDPB %02u; Time[s] ; Counts", uGdpb); - fvhTriggerRate.push_back( new TH1F(name, title, fuHistoryHistoSize, 0, fuHistoryHistoSize) ); - if (server) - server->Register("/StarRaw", fvhTriggerRate[ uGdpb ] ); - - name = Form( "hCmdDaqVsTrig_gDPB_%02u", uGdpb); - title = Form( "STAR daq command VS STAR trigger command gDPB %02u; DAQ ; TRIGGER", uGdpb); - fvhCmdDaqVsTrig.push_back( new TH2I(name, title, 16, 0, 16, 16, 0, 16 ) ); - fvhCmdDaqVsTrig[ uGdpb ]->GetXaxis()->SetBinLabel( 1, "0x0: no-trig "); // idle link - fvhCmdDaqVsTrig[ uGdpb ]->GetXaxis()->SetBinLabel( 2, "0x1: clear "); // clears redundancy counters on the readout boards - fvhCmdDaqVsTrig[ uGdpb ]->GetXaxis()->SetBinLabel( 3, "0x2: mast-rst"); // general reset of the whole front-end logic - fvhCmdDaqVsTrig[ uGdpb ]->GetXaxis()->SetBinLabel( 4, "0x3: spare "); // reserved - fvhCmdDaqVsTrig[ uGdpb ]->GetXaxis()->SetBinLabel( 5, "0x4: trigg. 0"); // Default physics readout, all det support required - fvhCmdDaqVsTrig[ uGdpb ]->GetXaxis()->SetBinLabel( 6, "0x5: trigg. 1"); // - fvhCmdDaqVsTrig[ uGdpb ]->GetXaxis()->SetBinLabel( 7, "0x6: trigg. 2"); // - fvhCmdDaqVsTrig[ uGdpb ]->GetXaxis()->SetBinLabel( 8, "0x7: trigg. 3"); // - fvhCmdDaqVsTrig[ uGdpb ]->GetXaxis()->SetBinLabel( 9, "0x8: puls. 0"); // - fvhCmdDaqVsTrig[ uGdpb ]->GetXaxis()->SetBinLabel(10, "0x9: puls. 1"); // - fvhCmdDaqVsTrig[ uGdpb ]->GetXaxis()->SetBinLabel(11, "0xA: puls. 2"); // - fvhCmdDaqVsTrig[ uGdpb ]->GetXaxis()->SetBinLabel(12, "0xB: puls. 3"); // - fvhCmdDaqVsTrig[ uGdpb ]->GetXaxis()->SetBinLabel(13, "0xC: config "); // housekeeping trigger: return geographic info of FE - fvhCmdDaqVsTrig[ uGdpb ]->GetXaxis()->SetBinLabel(14, "0xD: abort "); // aborts and clears an active event - fvhCmdDaqVsTrig[ uGdpb ]->GetXaxis()->SetBinLabel(15, "0xE: L1accept"); // - fvhCmdDaqVsTrig[ uGdpb ]->GetXaxis()->SetBinLabel(16, "0xF: L2accept"); // - fvhCmdDaqVsTrig[ uGdpb ]->GetYaxis()->SetBinLabel( 1, "0x0: 0"); // To be filled at STAR - fvhCmdDaqVsTrig[ uGdpb ]->GetYaxis()->SetBinLabel( 2, "0x1: 1"); // To be filled at STAR - fvhCmdDaqVsTrig[ uGdpb ]->GetYaxis()->SetBinLabel( 3, "0x2: 2"); // To be filled at STAR - fvhCmdDaqVsTrig[ uGdpb ]->GetYaxis()->SetBinLabel( 4, "0x3: 3"); // To be filled at STAR - fvhCmdDaqVsTrig[ uGdpb ]->GetYaxis()->SetBinLabel( 5, "0x4: 4"); // To be filled at STAR - fvhCmdDaqVsTrig[ uGdpb ]->GetYaxis()->SetBinLabel( 6, "0x5: 5"); // To be filled at STAR - fvhCmdDaqVsTrig[ uGdpb ]->GetYaxis()->SetBinLabel( 7, "0x6: 6"); // To be filled at STAR - fvhCmdDaqVsTrig[ uGdpb ]->GetYaxis()->SetBinLabel( 8, "0x7: 7"); // To be filled at STAR - fvhCmdDaqVsTrig[ uGdpb ]->GetYaxis()->SetBinLabel( 9, "0x8: 8"); // To be filled at STAR - fvhCmdDaqVsTrig[ uGdpb ]->GetYaxis()->SetBinLabel(10, "0x9: 9"); // To be filled at STAR - fvhCmdDaqVsTrig[ uGdpb ]->GetYaxis()->SetBinLabel(11, "0xA: 10"); // To be filled at STAR - fvhCmdDaqVsTrig[ uGdpb ]->GetYaxis()->SetBinLabel(12, "0xB: 11"); // To be filled at STAR - fvhCmdDaqVsTrig[ uGdpb ]->GetYaxis()->SetBinLabel(13, "0xC: 12"); // To be filled at STAR - fvhCmdDaqVsTrig[ uGdpb ]->GetYaxis()->SetBinLabel(14, "0xD: 13"); // To be filled at STAR - fvhCmdDaqVsTrig[ uGdpb ]->GetYaxis()->SetBinLabel(15, "0xE: 14"); // To be filled at STAR - fvhCmdDaqVsTrig[ uGdpb ]->GetYaxis()->SetBinLabel(16, "0xF: 15"); // To be filled at STAR - if (server) - server->Register("/StarRaw", fvhCmdDaqVsTrig[ uGdpb ] ); - - name = Form( "hStarTokenEvo_gDPB_%02u", uGdpb); - title = Form( "STAR token value VS time gDPB %02u; Time in Run [s] ; STAR Token; Counts", uGdpb); - fvhStarTokenEvo.push_back( new TH2I(name, title, fuHistoryHistoSize, 0, fuHistoryHistoSize, 410, 0, 4100 ) ); - - - name = Form( "hStarTrigGdpbTsEvo_gDPB_%02u", uGdpb); - title = Form( "gDPB TS in STAR triger tokens for gDPB %02u; Time in Run [s] ; gDPB TS;", uGdpb); - fvhStarTrigGdpbTsEvo.push_back( new TProfile(name, title, fuHistoryHistoSize, 0, fuHistoryHistoSize ) ); - - name = Form( "hStarTrigStarTsEvo_gDPB_%02u", uGdpb); - title = Form( "STAR TS in STAR triger tokens for gDPB %02u; Time in Run [s] ; STAR TS;", uGdpb); - fvhStarTrigStarTsEvo.push_back( new TProfile(name, title, fuHistoryHistoSize, 0, fuHistoryHistoSize ) ); - } // for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb ) - - /*******************************************************************/ - /// FEET pulser test channels - fvhTimeDiffPulser.resize( fuNrOfFeetPerGdpb * fuNrOfGdpbs ); - for( UInt_t uFeeA = 0; uFeeA < fuNrOfFeetPerGdpb * fuNrOfGdpbs; uFeeA++) - { - fvhTimeDiffPulser[uFeeA].resize( fuNrOfFeetPerGdpb * fuNrOfGdpbs ); - for( UInt_t uFeeB = 0; uFeeB < fuNrOfFeetPerGdpb * fuNrOfGdpbs; uFeeB++) - { - if( uFeeA < uFeeB ) - { - UInt_t uGdpbA = uFeeA / ( fuNrOfFeetPerGdpb ); - UInt_t uFeetA = uFeeA - ( fuNrOfFeetPerGdpb * uGdpbA ); - UInt_t uGdpbB = uFeeB / ( fuNrOfFeetPerGdpb ); - UInt_t uFeetB = uFeeB - ( fuNrOfFeetPerGdpb * uGdpbB ); - fvhTimeDiffPulser[uFeeA][uFeeB] = new TH1I( - Form("hTimeDiffPulser_g%02u_f%1u_g%02u_f%1u", uGdpbA, uFeetA, uGdpbB, uFeetB), - Form("Time difference for pulser on gDPB %02u FEE %1u and gDPB %02u FEE %1u; DeltaT [ps]; Counts", - uGdpbA, uFeetA, uGdpbB, uFeetB ), - uNbBinsDt, dMinDt, dMaxDt); - } // if( uFeeA < uFeeB ) - else fvhTimeDiffPulser[uFeeA][uFeeB] = NULL; - } // for( UInt_t uFeeB = uFeeA; uFeeB < fuNrOfFeetPerGdpb * fuNrOfGdpbs - 1; uFeeB++) - } // for( UInt_t uFeeA = 0; uFeeA < kuNbChanTest - 1; uFeeA++) - - name = "hTimeRmsPulser"; - fhTimeRmsPulser = new TH2D( name.Data(), - "Time difference RMS for each FEE pairs; FEE A; FEE B ; [ps]", - fuNrOfFeetPerGdpb * fuNrOfGdpbs - 1, -0.5, fuNrOfFeetPerGdpb * fuNrOfGdpbs - 1.5, - fuNrOfFeetPerGdpb * fuNrOfGdpbs - 1, 0.5, fuNrOfFeetPerGdpb * fuNrOfGdpbs - 0.5 ); - - name = "hTimeRmsZoomFitPuls"; - fhTimeRmsZoomFitPuls = new TH2D( name.Data(), - "Time difference RMS after zoom for each FEE pairs; FEE A; FEE B ; RMS [ps]", - fuNrOfFeetPerGdpb * fuNrOfGdpbs - 1, -0.5, fuNrOfFeetPerGdpb * fuNrOfGdpbs - 1.5, - fuNrOfFeetPerGdpb * fuNrOfGdpbs - 1, 0.5, fuNrOfFeetPerGdpb * fuNrOfGdpbs - 0.5 ); - - name = "hTimeResFitPuls"; - fhTimeResFitPuls = new TH2D( name.Data(), - "Time difference Res from fit for each FEE pairs; FEE A; FEE B ; Sigma [ps]", - fuNrOfFeetPerGdpb * fuNrOfGdpbs - 1, -0.5, fuNrOfFeetPerGdpb * fuNrOfGdpbs - 1.5, - fuNrOfFeetPerGdpb * fuNrOfGdpbs - 1, 0.5, fuNrOfFeetPerGdpb * fuNrOfGdpbs - 0.5 ); - - if( server ) - { - server->Register("/TofRaw", fhMessType ); - server->Register("/TofRaw", fhSysMessType ); - server->Register("/TofRaw", fhGet4MessType ); - server->Register("/TofRaw", fhGet4ChanScm ); - server->Register("/TofRaw", fhGet4ChanErrors ); - server->Register("/TofRaw", fhGet4EpochFlags ); - server->Register("/TofRaw", fhScmScalerCounters ); - server->Register("/TofRaw", fhScmDeadtimeCounters ); - server->Register("/TofRaw", fhScmSeuCounters ); - server->Register("/TofRaw", fhScmSeuCountersEvo ); - - for( UInt_t uTotPlot = 0; uTotPlot < fvhRawTot_gDPB.size(); ++uTotPlot ) - server->Register("/TofRaw", fvhRawTot_gDPB[ uTotPlot ] ); - - for( UInt_t uTotPlot = 0; uTotPlot < fvhRemapTot_gDPB.size(); ++uTotPlot ) - server->Register("/TofRaw", fvhRemapTot_gDPB[ uTotPlot ] ); - - for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb ) - { - server->Register("/TofRaw", fvhRawFt_gDPB[ uGdpb ] ); - server->Register("/TofRaw", fvhChCount_gDPB[ uGdpb ] ); - server->Register("/TofRates", fvhChannelRate_gDPB[ uGdpb ] ); - server->Register("/TofRaw", fvhRemapChCount_gDPB[ uGdpb ] ); - server->Register("/TofRates", fvhRemapChRate_gDPB[ uGdpb ] ); - - for (UInt_t uFeet = 0; uFeet < fuNrOfFeetPerGdpb; ++ uFeet) - { - server->Register("/TofRates", fvhFeetRate_gDPB[ uGdpb * fuNrOfFeetPerGdpb + uFeet ] ); - server->Register("/TofRates", fvhFeetErrorRate_gDPB[ uGdpb * fuNrOfFeetPerGdpb + uFeet ] ); - server->Register("/TofRates", fvhFeetErrorRatio_gDPB[ uGdpb * fuNrOfFeetPerGdpb + uFeet ] ); - server->Register("/TofRates", fvhFeetRateLong_gDPB[ uGdpb * fuNrOfFeetPerGdpb + uFeet ] ); - server->Register("/TofRates", fvhFeetErrorRateLong_gDPB[ uGdpb * fuNrOfFeetPerGdpb + uFeet ] ); - server->Register("/TofRates", fvhFeetErrorRatioLong_gDPB[ uGdpb * fuNrOfFeetPerGdpb + uFeet ] ); - } // for (UInt_t uFeet = 0; uFeet < fuNrOfFeetPerGdpb; ++ uFeet) - - server->Register("/StarRaw", fvhTokenMsgType[ uGdpb ] ); - server->Register("/StarRaw", fvhTriggerRate[ uGdpb ] ); - server->Register("/StarRaw", fvhCmdDaqVsTrig[ uGdpb ] ); - server->Register("/StarRaw", fvhStarTokenEvo[ uGdpb ] ); - server->Register("/StarRaw", fvhStarTrigGdpbTsEvo[ uGdpb ] ); - server->Register("/StarRaw", fvhStarTrigStarTsEvo[ uGdpb ] ); - } // for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb ) - - for( UInt_t uFeeA = 0; uFeeA < fuNrOfFeetPerGdpb * fuNrOfGdpbs; uFeeA++) - for( UInt_t uFeeB = 0; uFeeB < fuNrOfFeetPerGdpb * fuNrOfGdpbs; uFeeB++) - if( NULL != fvhTimeDiffPulser[uFeeA][uFeeB] ) - server->Register("/TofDt", fvhTimeDiffPulser[uFeeA][uFeeB] ); - - server->Register("/TofRaw", fhTimeRmsPulser ); - server->Register("/TofRaw", fhTimeRmsZoomFitPuls ); - server->Register("/TofRaw", fhTimeResFitPuls ); - - - server->RegisterCommand("/Reset_All_eTOF", "bResetTofStarMoniShiftHistos=kTRUE"); - server->RegisterCommand("/Save_All_eTof", "bSaveTofStarMoniShiftHistos=kTRUE"); - server->RegisterCommand("/Update_PulsFit", "bTofUpdateZoomedFitMoniShift=kTRUE"); - - server->Restrict("/Reset_All_eTof", "allow=admin"); - server->Restrict("/Save_All_eTof", "allow=admin"); - server->Restrict("/Update_PulsFit", "allow=admin"); - } // if( server ) - - /** Create summary Canvases for STAR 2018 **/ - Double_t w = 10; - Double_t h = 10; - TCanvas* cSummary = new TCanvas("cSummary", "gDPB Monitoring Summary", w, h); - cSummary->Divide(2, 3); - - // 1st Column: Messages types - cSummary->cd(1); - gPad->SetLogy(); - fhMessType->Draw(); - - cSummary->cd(2); - gPad->SetLogy(); - fhSysMessType->Draw(); - - cSummary->cd(3); - gPad->SetLogz(); - fhGet4MessType->Draw("colz"); - - // 2nd Column: GET4 Errors + Epoch flags + SCm - cSummary->cd(4); - gPad->SetLogz(); - fhGet4ChanErrors->Draw("colz"); - - cSummary->cd(5); - gPad->SetLogz(); - fhGet4EpochFlags->Draw("colz"); - - cSummary->cd(6); - fhGet4ChanScm->Draw("colz"); - /*****************************/ - - /** Create FEET rates Canvas for STAR 2018 **/ - TCanvas* cFeeRates = new TCanvas("cFeeRates", "gDPB Monitoring FEET rates", w, h); - cFeeRates->Divide(fuNrOfFeetPerGdpb, fuNrOfGdpbs ); - for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb ) - { - for (UInt_t uFeet = 0; uFeet < fuNrOfFeetPerGdpb; ++uFeet ) - { - cFeeRates->cd( 1 + uGdpb * fuNrOfFeetPerGdpb + uFeet ); - gPad->SetLogy(); - fvhFeetRate_gDPB[uGdpb * fuNrOfFeetPerGdpb + uFeet]->Draw("hist"); - - fvhFeetErrorRate_gDPB[uGdpb * fuNrOfFeetPerGdpb + uFeet]->SetLineColor( kRed ); - fvhFeetErrorRate_gDPB[uGdpb * fuNrOfFeetPerGdpb + uFeet]->Draw("same hist"); - } // for (UInt_t uFeet = 0; uFeet < fuNrOfFeetPerGdpb; ++uFeet ) - } // for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb ) - /*****************************/ - - /** Create FEET error ratio Canvas for STAR 2018 **/ - TCanvas* cFeeErrRatio = new TCanvas("cFeeErrRatio", "gDPB Monitoring FEET error ratios", w, h); - cFeeErrRatio->Divide(fuNrOfFeetPerGdpb, fuNrOfGdpbs ); - for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb ) - { - for (UInt_t uFeet = 0; uFeet < fuNrOfFeetPerGdpb; ++uFeet ) - { - cFeeErrRatio->cd( 1 + uGdpb * fuNrOfFeetPerGdpb + uFeet ); - gPad->SetLogy(); - fvhFeetErrorRatio_gDPB[uGdpb * fuNrOfFeetPerGdpb + uFeet]->Draw( "hist le0"); - } // for (UInt_t uFeet = 0; uFeet < fuNrOfFeetPerGdpb; ++uFeet ) - } // for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb ) - /*****************************/ - - - /** Create FEET rates long Canvas for STAR 2018 **/ - TCanvas* cFeeRatesLong = new TCanvas("cFeeRatesLong", "gDPB Monitoring FEET rates", w, h); - cFeeRatesLong->Divide(fuNrOfFeetPerGdpb, fuNrOfGdpbs ); - for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb ) - { - for (UInt_t uFeet = 0; uFeet < fuNrOfFeetPerGdpb; ++uFeet ) - { - cFeeRatesLong->cd( 1 + uGdpb * fuNrOfFeetPerGdpb + uFeet ); - gPad->SetLogy(); - fvhFeetRateLong_gDPB[uGdpb]->Draw( "hist" ); - - fvhFeetErrorRateLong_gDPB[uGdpb * fuNrOfFeetPerGdpb + uFeet]->SetLineColor( kRed ); - fvhFeetErrorRateLong_gDPB[uGdpb * fuNrOfFeetPerGdpb + uFeet]->Draw("same hist"); - } // for (UInt_t uFeet = 0; uFeet < fuNrOfFeetPerGdpb; ++uFeet ) - } // for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb ) - /*****************************/ - - /** Create FEET error ratio long Canvas for STAR 2018 **/ - TCanvas* cFeeErrRatioLong = new TCanvas("cFeeErrRatioLong", "gDPB Monitoring FEET error ratios", w, h); - cFeeErrRatioLong->Divide(fuNrOfFeetPerGdpb, fuNrOfGdpbs ); - for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb ) - { - for (UInt_t uFeet = 0; uFeet < fuNrOfFeetPerGdpb; ++uFeet ) - { - cFeeErrRatioLong->cd( 1 + uGdpb * fuNrOfFeetPerGdpb + uFeet ); - gPad->SetLogy(); - fvhFeetErrorRatioLong_gDPB[uGdpb * fuNrOfFeetPerGdpb + uFeet]->Draw( "hist le0"); - } // for (UInt_t uFeet = 0; uFeet < fuNrOfFeetPerGdpb; ++uFeet ) - } // for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb ) - /*****************************/ - - /** Create channel count Canvas for STAR 2018 **/ - TCanvas* cGdpbChannelCount = new TCanvas("cGdpbChannelCount", "Integrated Get4 channel counts per gDPB", w, h); - cGdpbChannelCount->Divide( 1, fuNrOfGdpbs ); - for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb ) - { - cGdpbChannelCount->cd( 1 + uGdpb ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogy(); - fvhChCount_gDPB[ uGdpb ]->Draw(); - } // for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb ) - /*****************************/ - - /** Create remapped channel count Canvas for STAR 2018 **/ - TCanvas* cGdpbRemapChCount = new TCanvas("cGdpbRemapChCount", "Integrated PADI channel counts per gDPB", w, h); - cGdpbRemapChCount->Divide( 1, fuNrOfGdpbs ); - for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb ) - { - cGdpbRemapChCount->cd( 1 + uGdpb ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogy(); - fvhRemapChCount_gDPB[ uGdpb ]->Draw(); - } // for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb ) - /*****************************/ - - /** Create channel rate Canvas for STAR 2018 **/ - TCanvas* cGdpbChannelRate = new TCanvas("cGdpbChannelRate", "Get4 channel rate per gDPB", w, h); - cGdpbChannelRate->Divide( 1, fuNrOfGdpbs ); - for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb ) - { - cGdpbChannelRate->cd( 1 + uGdpb ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fvhChannelRate_gDPB[ uGdpb ]->Draw( "colz" ); - } // for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb ) - /*****************************/ - - /** Create remapped rate count Canvas for STAR 2018 **/ - TCanvas* cGdpbRemapChRate = new TCanvas("cGdpbRemapChRate", "PADI channel rate per gDPB", w, h); - cGdpbRemapChRate->Divide( 1, fuNrOfGdpbs ); - for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb ) - { - cGdpbRemapChRate->cd( 1 + uGdpb ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - fvhRemapChRate_gDPB[ uGdpb ]->Draw( "colz" ); - } // for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb ) - /*****************************/ - - /** Create TOT Canvas(es) for STAR 2018 **/ - TCanvas* cTotPnt = NULL; - for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb ) - { - cTotPnt = new TCanvas( Form("cTot_g%02u", uGdpb), - Form("gDPB %02u TOT distributions", uGdpb), - w, h); - cTotPnt->Divide( fuNbFeetPlotsPerGdpb ); - - for( UInt_t uFeetPlot = 0; uFeetPlot < fuNbFeetPlotsPerGdpb; ++uFeetPlot ) - { - cTotPnt->cd( 1 + uFeetPlot ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - - fvhRawTot_gDPB[ uGdpb * fuNbFeetPlotsPerGdpb + uFeetPlot ]->Draw( "colz" ); - } // for (UInt_t uFeet = 0; uFeet < fuNbFeetPlotsPerGdpb; ++uFeet ) - } // for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb ) - cTotPnt = new TCanvas( "cTot_all", "TOT distributions", w, h); - cTotPnt->Divide( fuNrOfGdpbs, fuNbFeetPlotsPerGdpb ); - for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb ) - for( UInt_t uFeetPlot = 0; uFeetPlot < fuNbFeetPlotsPerGdpb; ++uFeetPlot ) - { - cTotPnt->cd( 1 + uGdpb + fuNrOfGdpbs * uFeetPlot ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - - fvhRawTot_gDPB[ uGdpb * fuNbFeetPlotsPerGdpb + uFeetPlot]->Draw( "colz" ); - } // for (UInt_t uFeet = 0; uFeet < fuNbFeetPlotsPerGdpb; ++uFeet ) - /**************************************************/ - - /** Create PADI TOT Canvas(es) for STAR 2018 **/ - cTotPnt = NULL; - for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb ) - { - cTotPnt = new TCanvas( Form("cTotRemap_g%02u", uGdpb), - Form("PADI ch gDPB %02u TOT distributions", uGdpb), - w, h); - cTotPnt->Divide( fuNbFeetPlotsPerGdpb ); - - for( UInt_t uFeetPlot = 0; uFeetPlot < fuNbFeetPlotsPerGdpb; ++uFeetPlot ) - { - cTotPnt->cd( 1 + uFeetPlot ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - - fvhRemapTot_gDPB[ uGdpb * fuNbFeetPlotsPerGdpb + uFeetPlot ]->Draw( "colz" ); - } // for (UInt_t uFeet = 0; uFeet < fuNbFeetPlotsPerGdpb; ++uFeet ) - } // for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb ) - cTotPnt = new TCanvas( "cTotRemap_all", "TOT distributions", w, h); - cTotPnt->Divide( fuNrOfGdpbs, fuNbFeetPlotsPerGdpb ); - for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb ) - for( UInt_t uFeetPlot = 0; uFeetPlot < fuNbFeetPlotsPerGdpb; ++uFeetPlot ) - { - cTotPnt->cd( 1 + uGdpb + fuNrOfGdpbs * uFeetPlot ); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->SetLogz(); - - fvhRemapTot_gDPB[ uGdpb * fuNbFeetPlotsPerGdpb + uFeetPlot]->Draw( "colz" ); - } // for (UInt_t uFeet = 0; uFeet < fuNbFeetPlotsPerGdpb; ++uFeet ) - /**************************************************/ - - /** Create STAR token Canvas for STAR 2018 **/ - for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; uGdpb ++) - { - TCanvas* cStarToken = new TCanvas( Form("cStarToken_g%02u", uGdpb), - Form("STAR token detection info for gDPB %02u", uGdpb), - w, h); - cStarToken->Divide( 2, 2 ); - - cStarToken->cd(1); - fvhTriggerRate[uGdpb]->Draw(); - - cStarToken->cd(2); - fvhCmdDaqVsTrig[uGdpb]->Draw( "colz" ); - - cStarToken->cd(3); - fvhStarTokenEvo[uGdpb]->Draw(); - - cStarToken->cd(4); - fvhStarTrigGdpbTsEvo[uGdpb]->Draw( "hist le0" ); - fvhStarTrigStarTsEvo[uGdpb]->SetLineColor( kRed ); - fvhStarTrigStarTsEvo[uGdpb]->Draw( "same hist le0" ); - } // for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; uGdpb ++) - /*****************************/ - - /** Create Pulser check Canvas for STAR 2018 **/ - TCanvas* cPulser = new TCanvas("cPulser", "Time difference RMS for pulser channels when FEE pulser mode is ON", w, h); - cPulser->Divide( 3 ); - - cPulser->cd(1); - gPad->SetGridx(); - gPad->SetGridy(); - fhTimeRmsPulser->Draw( "colz" ); - - cPulser->cd(2); - gPad->SetGridx(); - gPad->SetGridy(); - fhTimeRmsZoomFitPuls->Draw( "colz" ); - - cPulser->cd(3); - gPad->SetGridx(); - gPad->SetGridy(); - fhTimeResFitPuls->Draw( "colz" ); - /*****************************/ - - /** Recovers/Create Ms Size Canvas for STAR 2018 **/ - // Try to recover canvas in case it was created already by another monitor - // If not existing, create it - fcMsSizeAll = dynamic_cast<TCanvas *>( gROOT->FindObject( "cMsSizeAll" ) ); - if( NULL == fcMsSizeAll ) - { - fcMsSizeAll = new TCanvas("cMsSizeAll", "Evolution of MS size in last 300 s", w, h); - fcMsSizeAll->Divide( 4, 3 ); - LOG(info) << "Created MS size canvas in TOF monitor"; - } // if( NULL == fcMsSizeAll ) - else LOG(info) << "Recovered MS size canvas in TOF monitor"; - - LOG(info) << "Leaving CreateHistograms"; -} - -Bool_t CbmTofStarMonitorShift2018::DoUnpack(const fles::Timeslice& ts, - size_t component) -{ - if( bResetTofStarMoniShiftHistos ) - { - LOG(info) << "Reset eTOF STAR histos "; - ResetAllHistos(); - bResetTofStarMoniShiftHistos = kFALSE; - } // if( bResetTofStarMoniShiftHistos ) - if( bSaveTofStarMoniShiftHistos ) - { - LOG(info) << "Start saving eTOF STAR histos "; - SaveAllHistos( "data/histos_Shift_StarTof.root" ); - bSaveTofStarMoniShiftHistos = kFALSE; - } // if( bSaveStsHistos ) - if( bTofUpdateZoomedFitMoniShift ) - { - UpdateZoomedFit(); - bTofUpdateZoomedFitMoniShift = kFALSE; - } // if (bTofUpdateZoomedFitMoniShift) - - LOG(debug1) << "Timeslice contains " << ts.num_microslices(component) - << "microslices."; - - // MS size monitoring - if( NULL == fvhMsSzPerLink[ component ] ) - { - TString sMsSzName = Form( "MsSz_link_%02lu", component ); - TString sMsSzTitle = Form( "Size of MS from link %02lu; Ms Size [bytes]", component ); - fvhMsSzPerLink[ component ] = new TH1F(sMsSzName.Data(), sMsSzTitle.Data(), 160000, 0., 20000. ); - - sMsSzName = Form("MsSzTime_link_%02lu", component); - sMsSzTitle = Form( "Size of MS vs time for gDPB of link %02lu; Time[s] ; Ms Size [bytes]", component); - fvhMsSzTimePerLink[ component ] = new TProfile( sMsSzName.Data(), sMsSzTitle.Data(), - 100 * fuHistoryHistoSize, 0., 2 * fuHistoryHistoSize ); - THttpServer* server = FairRunOnline::Instance()->GetHttpServer(); - if( server ) - { - server->Register("/FlibRaw", fvhMsSzPerLink[ component ]); - server->Register("/FlibRaw", fvhMsSzTimePerLink[ component ]); - } // if( server ) - if( NULL != fcMsSizeAll ) - { - fcMsSizeAll->cd( 1 + component ); - gPad->SetLogy(); - fvhMsSzTimePerLink[ component ]->Draw("hist le0"); - } // if( NULL != fcMsSizeAll ) - LOG(info) << "Added MS size histo for component (link): " << component; - } // if( NULL == fvhMsSzPerLink[ component ] ) - - /// Periodically save the histograms - std::chrono::time_point<std::chrono::system_clock> timeCurrent = std::chrono::system_clock::now(); - std::chrono::duration<double> elapsed_seconds = timeCurrent - fTimeLastHistoSaving; - if( 0 == fTimeLastHistoSaving.time_since_epoch().count() ) - { - fTimeLastHistoSaving = timeCurrent; -// fulNbBuiltSubEventLastPrintout = fulNbBuiltSubEvent; -// fulNbStarSubEventLastPrintout = fulNbStarSubEvent; - } // if( 0 == fTimeLastHistoSaving.time_since_epoch().count() ) - else if( 300 < elapsed_seconds.count() ) - { - std::time_t cTimeCurrent = std::chrono::system_clock::to_time_t( timeCurrent ); - char tempBuff[80]; - std::strftime( tempBuff, 80, "%F %T", localtime (&cTimeCurrent) ); -/* - LOG(info) << "CbmTofStarEventBuilder2018::DoUnpack => " << tempBuff - << " Total number of Built events: " << std::setw(9) << fulNbBuiltSubEvent - << ", " << std::setw(9) << (fulNbBuiltSubEvent - fulNbBuiltSubEventLastPrintout) - << " events in last " << std::setw(4) << elapsed_seconds.count() << " s"; - fTimeLastPrintoutNbStarEvent = timeCurrent; - fulNbBuiltSubEventLastPrintout = fulNbBuiltSubEvent; -*/ - fTimeLastHistoSaving = timeCurrent; - SaveAllHistos( "data/histos_shift.root" ); - } // else if( 300 < elapsed_seconds.count() ) - - Int_t messageType = -111; - Double_t dTsStartTime = -1; - // Loop over microslices - size_t numCompMsInTs = ts.num_microslices(component); - for( size_t m = 0; m < numCompMsInTs; ++m ) - { - if (fuMsAcceptsPercent < m) - continue; - - constexpr uint32_t kuBytesPerMessage = 8; - - auto msDescriptor = ts.descriptor(component, m); - fiEquipmentId = msDescriptor.eq_id; - fdMsIndex = static_cast<double>(msDescriptor.idx); - const uint8_t* msContent = reinterpret_cast<const uint8_t*>( ts.content( component, m) ); - - uint32_t size = msDescriptor.size; -// fulLastMsIdx = msDescriptor.idx; - if (size > 0) - LOG(debug) << "Microslice: " << msDescriptor.idx << " has size: " << size; - - if( numCompMsInTs - fuOverlapMsNb <= m ) - { -// LOG(info) << "Ignore overlap Microslice: " << msDescriptor.idx; - continue; - } // if( numCompMsInTs - fuOverlapMsNb <= m ) - - if( 0 == m ) - dTsStartTime = (1e-9) * fdMsIndex; - - if( fdStartTimeMsSz < 0 ) - fdStartTimeMsSz = (1e-9) * fdMsIndex; - fvhMsSzPerLink[ component ]->Fill(size); - if( 2 * fuHistoryHistoSize < (1e-9) * fdMsIndex - fdStartTimeMsSz ) - { - // Reset the evolution Histogram and the start time when we reach the end of the range - fvhMsSzTimePerLink[ component ]->Reset(); - fdStartTimeMsSz = (1e-9) * fdMsIndex; - } // if( 2 * fuHistoryHistoSize < (1e-9) * fdMsIndex - fdStartTimeMsSz ) - fvhMsSzTimePerLink[ component ]->Fill((1e-9) * fdMsIndex - fdStartTimeMsSz, size); - - // If not integer number of message in input buffer, print warning/error - if (0 != (size % kuBytesPerMessage)) - LOG(error) << "The input microslice buffer does NOT " - << "contain only complete nDPB messages!"; - - // Compute the number of complete messages in the input microslice buffer - uint32_t uNbMessages = (size - (size % kuBytesPerMessage)) / kuBytesPerMessage; - - // Prepare variables for the loop on contents - const uint64_t* pInBuff = reinterpret_cast<const uint64_t*>(msContent); - for( uint32_t uIdx = 0; uIdx < uNbMessages; uIdx++ ) - { - // Fill message - uint64_t ulData = static_cast<uint64_t>(pInBuff[uIdx]); - gdpb::Message mess(ulData); - - if (gLogger->IsLogNeeded( fair::Severity::debug2 )) - { - mess.printDataCout(); - } // if (gLogger->IsLogNeeded( fair::Severity::debug2 )) - - - // Increment counter for different message types - // and fill the corresponding histogram - messageType = mess.getMessageType(); - fviMsgCounter[messageType]++; - fhMessType->Fill(messageType); - - fuGdpbId = mess.getRocNumber(); - fuGdpbNr = fGdpbIdIndexMap[fuGdpbId]; - - fuGet4Id = mess.getGdpbGenChipId(); - fuGet4Nr = (fuGdpbNr * fuNrOfGet4PerGdpb) + fuGet4Id; - - if( fuNrOfGet4PerGdpb <= fuGet4Id && - gdpb::MSG_STAR_TRI != messageType && - ( get4v2x::kuChipIdMergedEpoch != fuGet4Id ) ) - LOG(warning) << "Message with Get4 ID too high: " << fuGet4Id - << " VS " << fuNrOfGet4PerGdpb << " set in parameters."; - - switch (messageType) - { - case gdpb::MSG_HIT: - case gdpb::MSG_EPOCH: - LOG(error) << "Message type " << messageType - << " not included in unpacker."; - break; - case gdpb::MSG_SYS: - fhSysMessType->Fill(mess.getSysMesType()); - break; - case gdpb::MSG_EPOCH2: - { - if( get4v2x::kuChipIdMergedEpoch == fuGet4Id ) - { - for( uint32_t uGet4Index = 0; uGet4Index < fuNrOfGet4PerGdpb; uGet4Index ++ ) - { - fuGet4Id = uGet4Index; - fuGet4Nr = (fuGdpbNr * fuNrOfGet4PerGdpb) + fuGet4Id; - gdpb::Message tmpMess(mess); - tmpMess.setGdpbGenChipId( uGet4Index ); - - fhGet4MessType->Fill(fuGet4Nr, gdpb::GET4_32B_EPOCH); - FillEpochInfo(tmpMess); - } // for( uint32_t uGet4Index = 0; uGet4Index < fuNrOfGet4PerGdpb; uGetIndex ++ ) - } // if this epoch message is a merged one valiud for all chips - else - { - fhGet4MessType->Fill(fuGet4Nr, gdpb::GET4_32B_EPOCH); - FillEpochInfo(mess); - } // if single chip epoch message - break; - } - case gdpb::MSG_GET4: - fhGet4MessType->Fill(fuGet4Nr, gdpb::GET4_32B_DATA + 1); - PrintGenInfo(mess); - break; - case gdpb::MSG_GET4_32B: - fhGet4MessType->Fill(fuGet4Nr, gdpb::GET4_32B_DATA); - fvmEpSupprBuffer[fuGet4Nr].push_back( mess ); - break; - case gdpb::MSG_GET4_SLC: - fhGet4MessType->Fill(fuGet4Nr, gdpb::GET4_32B_SLCM); - PrintSlcInfo(mess); - break; - case gdpb::MSG_GET4_SYS: - { - fhSysMessType->Fill(mess.getGdpbSysSubType()); - if( gdpb::SYSMSG_GET4_EVENT == mess.getGdpbSysSubType() ) - { - fhGet4MessType->Fill(fuGet4Nr, gdpb::GET4_32B_ERROR); - - UInt_t uFeetNr = (fuGet4Id / fuNrOfGet4PerFeb); - if (0 <= fdStartTime) - { - fvhFeetErrorRate_gDPB[(fuGdpbNr * fuNrOfFeetPerGdpb) + uFeetNr]->Fill( - 1e-9 * (mess.getMsgFullTimeD(fvulCurrentEpoch[fuGet4Nr]) - fdStartTime)); - fvhFeetErrorRatio_gDPB[(fuGdpbNr * fuNrOfFeetPerGdpb) + uFeetNr]->Fill( - 1e-9 * (mess.getMsgFullTimeD(fvulCurrentEpoch[fuGet4Nr]) - fdStartTime), 1, 1 ); - } // if (0 <= fdStartTime) - if (0 <= fdStartTimeLong) - { - fvhFeetErrorRateLong_gDPB[(fuGdpbNr * fuNrOfFeetPerGdpb) + uFeetNr]->Fill( - 1e-9 / 60.0 * (mess.getMsgFullTimeD(fvulCurrentEpoch[fuGet4Nr]) - fdStartTimeLong), 1 / 60.0); - fvhFeetErrorRatioLong_gDPB[(fuGdpbNr * fuNrOfFeetPerGdpb) + uFeetNr]->Fill( - 1e-9 / 60.0 * (mess.getMsgFullTimeD(fvulCurrentEpoch[fuGet4Nr]) - fdStartTimeLong), 1, 1 / 60.0); - } // if (0 <= fdStartTime) - - Int_t dFullChId = fuGet4Nr * fuNrOfChannelsPerGet4 + mess.getGdpbSysErrChanId(); - switch( mess.getGdpbSysErrData() ) - { - case gdpb::GET4_V2X_ERR_READ_INIT: - fhGet4ChanErrors->Fill(dFullChId, 0); - break; - case gdpb::GET4_V2X_ERR_SYNC: - fhGet4ChanErrors->Fill(dFullChId, 1); - break; - case gdpb::GET4_V2X_ERR_EP_CNT_SYNC: - fhGet4ChanErrors->Fill(dFullChId, 2); - break; - case gdpb::GET4_V2X_ERR_EP: - fhGet4ChanErrors->Fill(dFullChId, 3); - break; - case gdpb::GET4_V2X_ERR_FIFO_WRITE: - fhGet4ChanErrors->Fill(dFullChId, 4); - break; - case gdpb::GET4_V2X_ERR_LOST_EVT: - fhGet4ChanErrors->Fill(dFullChId, 5); - break; - case gdpb::GET4_V2X_ERR_CHAN_STATE: - fhGet4ChanErrors->Fill(dFullChId, 6); - break; - case gdpb::GET4_V2X_ERR_TOK_RING_ST: - fhGet4ChanErrors->Fill(dFullChId, 7); - break; - case gdpb::GET4_V2X_ERR_TOKEN: - fhGet4ChanErrors->Fill(dFullChId, 8); - break; - case gdpb::GET4_V2X_ERR_READOUT_ERR: - fhGet4ChanErrors->Fill(dFullChId, 9); - break; - case gdpb::GET4_V2X_ERR_SPI: - fhGet4ChanErrors->Fill(dFullChId, 10); - break; - case gdpb::GET4_V2X_ERR_DLL_LOCK: - fhGet4ChanErrors->Fill(dFullChId, 11); - break; - case gdpb::GET4_V2X_ERR_DLL_RESET: - fhGet4ChanErrors->Fill(dFullChId, 12); - break; - case gdpb::GET4_V2X_ERR_TOT_OVERWRT: - fhGet4ChanErrors->Fill(dFullChId, 13); - break; - case gdpb::GET4_V2X_ERR_TOT_RANGE: - fhGet4ChanErrors->Fill(dFullChId, 14); - break; - case gdpb::GET4_V2X_ERR_EVT_DISCARD: - fhGet4ChanErrors->Fill(dFullChId, 15); - break; - case gdpb::GET4_V2X_ERR_ADD_RIS_EDG: - fhGet4ChanErrors->Fill(dFullChId, 16); - break; - case gdpb::GET4_V2X_ERR_UNPAIR_FALL: - fhGet4ChanErrors->Fill(dFullChId, 17); - break; - case gdpb::GET4_V2X_ERR_SEQUENCE_ER: - fhGet4ChanErrors->Fill(dFullChId, 18); - break; - case gdpb::GET4_V2X_ERR_UNKNOWN: - fhGet4ChanErrors->Fill(dFullChId, 19); - break; - default: // Corrupt error or not yet supported error - fhGet4ChanErrors->Fill(dFullChId, 20); - break; - } // Switch( mess.getGdpbSysErrData() ) - } // if( gdpb::SYSMSG_GET4_EVENT == mess.getGdpbSysSubType() ) - PrintSysInfo(mess); - break; - } // case gdpb::MSG_GET4_SYS: - case gdpb::MSG_STAR_TRI: - fhGet4MessType->Fill(fuGet4Nr, gdpb::MSG_STAR_TRI); - FillStarTrigInfo(mess); - break; - default: - LOG(error) << "Message type " << std::hex - << std::setw(2) << static_cast<uint16_t>(messageType) - << " not included in Get4 unpacker."; - } // switch( mess.getMessageType() ) - } // for (uint32_t uIdx = 0; uIdx < uNbMessages; uIdx ++) - } // for (size_t m = 0; m < ts.num_microslices(component); ++m) - - // Update RMS plots only every 10s in data - if( 10.0 < dTsStartTime - fdLastRmsUpdateTime ) - { - // Reset summary histograms for safety - fhTimeRmsPulser->Reset(); - - for( UInt_t uFeeA = 0; uFeeA < fuNrOfFeetPerGdpb * fuNrOfGdpbs; uFeeA++) - for( UInt_t uFeeB = 0; uFeeB < fuNrOfFeetPerGdpb * fuNrOfGdpbs; uFeeB++) - if( NULL != fvhTimeDiffPulser[uFeeA][uFeeB] ) - { - fhTimeRmsPulser->Fill( uFeeA, uFeeB, fvhTimeDiffPulser[uFeeA][uFeeB]->GetRMS() ); - } // for( UInt_t uChan = 0; uChan < kuNbChanTest - 1; uChan++) - fdLastRmsUpdateTime = dTsStartTime; - } // if( 10.0 < dTsStartTime - fdLastRmsUpdateTime ) - - return kTRUE; -} - -void CbmTofStarMonitorShift2018::FillHitInfo(gdpb::Message mess) -{ - UInt_t uChannel = mess.getGdpbHitChanId(); - UInt_t uTot = mess.getGdpbHit32Tot(); - UInt_t uFts = mess.getGdpbHitFineTs(); - - ULong64_t ulCurEpochGdpbGet4 = fvulCurrentEpoch[ fuGet4Nr ]; - - // In Ep. Suppr. Mode, receive following epoch instead of previous - if( 0 < ulCurEpochGdpbGet4 ) - ulCurEpochGdpbGet4 --; - else ulCurEpochGdpbGet4 = get4v2x::kuEpochCounterSz; // Catch epoch cycle! - - UInt_t uChannelNr = fuGet4Id * fuNrOfChannelsPerGet4 + uChannel; - UInt_t uChannelNrInFeet = (fuGet4Id % fuNrOfGet4PerFeb) * fuNrOfChannelsPerGet4 + uChannel; - UInt_t uFeetNr = (fuGet4Id / fuNrOfGet4PerFeb); - UInt_t uFeetNrInSys = fuGdpbNr * fuNrOfFeetPerGdpb + uFeetNr; - UInt_t uRemappedChannelNr = uFeetNr * fuNrOfChannelsPerFeet + fvuGet4ToPadi[ uChannelNrInFeet ]; - -// ULong_t ulHitTime = mess.getMsgFullTime(ulCurEpochGdpbGet4); - Double_t dHitTime = mess.getMsgFullTimeD(ulCurEpochGdpbGet4); - - // In 32b mode the coarse counter is already computed back to 112 FTS bins - // => need to hide its contribution from the Finetime - // => FTS = Fullt TS modulo 112 - uFts = mess.getGdpbHitFullTs() % 112; - - fvhChCount_gDPB[fuGdpbNr]->Fill(uChannelNr); - fvhRawFt_gDPB[fuGdpbNr]->Fill(uChannelNr, uFts); - fvhRawTot_gDPB[ fuGdpbNr * fuNbFeetPlotsPerGdpb + uFeetNr/fuNbFeetPlot ]->Fill(uChannelNr, uTot); - - /// Remapped for PADI to GET4 - fvhRemapChCount_gDPB[fuGdpbNr]->Fill( uRemappedChannelNr ); - fvhRemapTot_gDPB[ fuGdpbNr * fuNbFeetPlotsPerGdpb + uFeetNr/fuNbFeetPlot ]->Fill( uRemappedChannelNr , uTot); - - ///* Pulser monitoring */// - /// Save last hist time if pulser channel - /// Fill the corresponding histos if the time difference is reasonnable - if( get4v2x::kuFeePulserChannel == uChannelNrInFeet ) - { - fdTsLastPulserHit[ uFeetNrInSys ] = dHitTime; - - /// Update the difference to all other FEE with lower indices - for( UInt_t uFeeB = 0; uFeeB < uFeetNrInSys; uFeeB++) - if( NULL != fvhTimeDiffPulser[uFeeB][uFeetNrInSys] ) - { - Double_t dTimeDiff = 1e3 * ( fdTsLastPulserHit[ uFeetNrInSys ] - fdTsLastPulserHit[ uFeeB ] ); - if( TMath::Abs( dTimeDiff ) < kdMaxDtPulserPs ) - fvhTimeDiffPulser[uFeeB][uFeetNrInSys]->Fill( dTimeDiff ); - } // if( NULL != fvhTimeDiffPulser[uFeeB][uFeeB] ) - - /// Update the difference to all other FEE with higher indices - for( UInt_t uFeeB = uFeetNrInSys + 1; uFeeB < fuNrOfFeetPerGdpb * fuNrOfGdpbs; uFeeB++) - if( NULL != fvhTimeDiffPulser[uFeetNrInSys][uFeeB] ) - { - Double_t dTimeDiff = 1e3 * ( fdTsLastPulserHit[ uFeeB ] - fdTsLastPulserHit[ uFeetNrInSys ] ); - if( TMath::Abs( dTimeDiff ) < kdMaxDtPulserPs ) - fvhTimeDiffPulser[uFeetNrInSys][uFeeB]->Fill( dTimeDiff ); - } // if( NULL != fvhTimeDiffPulser[uFeetNrInSys][uFeeB] ) - } // if( get4v2x::kuFeePulserChannel == uChannelNrInFeet ) - - // In Run rate evolution - if (fdStartTime < 0) - fdStartTime = dHitTime; - - // Reset the evolution Histogram and the start time when we reach the end of the range - if( fuHistoryHistoSize < 1e-9 * (dHitTime - fdStartTime) ) - { - ResetEvolutionHistograms(); - fdStartTime = dHitTime; - } // if( fuHistoryHistoSize < 1e-9 * (dHitTime - fdStartTime) ) - - // In Run rate evolution - if (fdStartTimeLong < 0) - fdStartTimeLong = dHitTime; - - // Reset the evolution Histogram and the start time when we reach the end of the range - if( fuHistoryHistoSizeLong < 1e-9 * (dHitTime - fdStartTimeLong) / 60.0 ) - { - ResetLongEvolutionHistograms(); - fdStartTimeLong = dHitTime; - } // if( fuHistoryHistoSize < 1e-9 * (dHitTime - fdStartTime) / 60.0 ) - - if (0 <= fdStartTime) - { - fvhChannelRate_gDPB[ fuGdpbNr ]->Fill( 1e-9 * (dHitTime - fdStartTime), uChannelNr ); - fvhRemapChRate_gDPB[ fuGdpbNr ]->Fill( 1e-9 * (dHitTime - fdStartTime), uRemappedChannelNr ); - fvhFeetRate_gDPB[(fuGdpbNr * fuNrOfFeetPerGdpb) + uFeetNr]->Fill( 1e-9 * (dHitTime - fdStartTime)); - fvhFeetErrorRatio_gDPB[(fuGdpbNr * fuNrOfFeetPerGdpb) + uFeetNr]->Fill( 1e-9 * (dHitTime - fdStartTime), 0, 1); - } // if (0 <= fdStartTime) - - if (0 <= fdStartTimeLong) - { - fvhFeetRateLong_gDPB[(fuGdpbNr * fuNrOfFeetPerGdpb) + uFeetNr]->Fill( - 1e-9 / 60.0 * (dHitTime - fdStartTimeLong), 1 / 60.0 ); - fvhFeetErrorRatioLong_gDPB[(fuGdpbNr * fuNrOfFeetPerGdpb) + uFeetNr]->Fill( - 1e-9 / 60.0 * (dHitTime - fdStartTimeLong), 0, 1 / 60.0 ); - } // if (0 <= fdStartTimeLong) -} - -void CbmTofStarMonitorShift2018::FillEpochInfo(gdpb::Message mess) -{ - ULong64_t ulEpochNr = mess.getGdpbEpEpochNb(); - - fvulCurrentEpoch[fuGet4Nr] = ulEpochNr; - - if (1 == mess.getGdpbEpSync()) - fhGet4EpochFlags->Fill(fuGet4Nr, 0); - if (1 == mess.getGdpbEpDataLoss()) - fhGet4EpochFlags->Fill(fuGet4Nr, 1); - if (1 == mess.getGdpbEpEpochLoss()) - fhGet4EpochFlags->Fill(fuGet4Nr, 2); - if (1 == mess.getGdpbEpMissmatch()) - fhGet4EpochFlags->Fill(fuGet4Nr, 3); - - fulCurrentEpochTime = mess.getMsgFullTime(ulEpochNr); - - /// Re-align the epoch number of the message in case it will be used later: - /// We received the epoch after the data instead of the one before! - if( 0 < ulEpochNr ) - mess.setEpoch2Number( ulEpochNr - 1 ); - else mess.setEpoch2Number( get4v2x::kuEpochCounterSz ); - - Int_t iBufferSize = fvmEpSupprBuffer[fuGet4Nr].size(); - if( 0 < iBufferSize ) - { - LOG(debug) << "Now processing stored messages for for get4 " << fuGet4Nr << " with epoch number " - << (fvulCurrentEpoch[fuGet4Nr] - 1); - - /// Data are sorted between epochs, not inside => Epoch level ordering - /// Sorting at lower bin precision level - std::stable_sort( fvmEpSupprBuffer[fuGet4Nr].begin(), fvmEpSupprBuffer[fuGet4Nr].begin() ); - - for( Int_t iMsgIdx = 0; iMsgIdx < iBufferSize; iMsgIdx++ ) - { - FillHitInfo( fvmEpSupprBuffer[fuGet4Nr][ iMsgIdx ] ); - } // for( Int_t iMsgIdx = 0; iMsgIdx < iBufferSize; iMsgIdx++ ) - - fvmEpSupprBuffer[fuGet4Nr].clear(); - } // if( 0 < fvmEpSupprBuffer[fuGet4Nr] ) -} - -void CbmTofStarMonitorShift2018::PrintSlcInfo(gdpb::Message mess) -{ - if (fGdpbIdIndexMap.end() != fGdpbIdIndexMap.find(fuGdpbId)) - { -// UInt_t uChip = mess.getGdpbGenChipId(); -// UInt_t uChan = mess.getGdpbSlcChan(); -// UInt_t uEdge = mess.getGdpbSlcEdge(); - UInt_t uData = mess.getGdpbSlcData(); -// UInt_t uCRC = mess.getGdpbSlcCrc(); - UInt_t uType = mess.getGdpbSlcType(); - Double_t dFullChId = fuGet4Nr * fuNrOfChannelsPerGet4 + mess.getGdpbSlcChan() + 0.5 * mess.getGdpbSlcEdge(); - Double_t dMessTime = static_cast< Double_t>( fulCurrentEpochTime ) * 1.e-9; - - switch( uType ) - { - case 0: // Scaler counter - { - fhGet4ChanScm->Fill(dFullChId, uType ); - fhScmScalerCounters->Fill( uData, dFullChId); - break; - } - case 1: // Deadtime counter - { - fhGet4ChanScm->Fill(dFullChId, uType ); - fhScmDeadtimeCounters->Fill( uData, dFullChId); - break; - } - case 2: // SPI message - { -/* - LOG(info) << "GET4 Slow Control message, epoch " - << static_cast<Int_t>(fvulCurrentEpoch[fuGet4Nr]) << ", time " << std::setprecision(9) - << std::fixed << dMessTime << " s " - << " for board ID " << std::hex << std::setw(4) << fuGdpbId - << std::dec << "\n" - << " +++++++ > Chip = " - << std::setw(2) << uChip << ", Chan = " - << std::setw(1) << uChan << ", Edge = " - << std::setw(1) << uEdge << ", Type = " - << std::setw(1) << mess.getGdpbSlcType() << ", Data = 0x" -// << std::hex << std::setw(6) << mess.getGdpbSlcData() - << Form( "%06x", uData ) - << std::dec << ", CRC = " << uCRC -// << " RAW: " << Form( "%08x", mess.getGdpbSlcMess() ); -*/ - fhGet4ChanScm->Fill(dFullChId, uType ); - break; - } - case 3: // Start message or SEU counter - { - if( 0 == mess.getGdpbSlcChan() && 0 == mess.getGdpbSlcEdge() ) // START message - { -/* - LOG(info) << std::setprecision(9) - << std::fixed << dMessTime << " s "; - LOG(info) << "GET4 Slow Control message, epoch " - << static_cast<Int_t>(fvulCurrentEpoch[fuGet4Nr]) << ", time " << std::setprecision(9) - << std::fixed << dMessTime << " s " - << " for board ID " << std::hex << std::setw(4) << fuGdpbId - << std::dec << "\n" - << " +++++++ > Chip = " - << std::setw(2) << mess.getGdpbGenChipId() << ", Chan = " - << std::setw(1) << mess.getGdpbSlcChan() << ", Edge = " - << std::setw(1) << mess.getGdpbSlcEdge() << ", Type = " - << std::setw(1) << mess.getGdpbSlcType() << ", Data = 0x" - // << std::hex << std::setw(6) << mess.getGdpbSlcData() - << Form( "%06x", mess.getGdpbSlcData() ) - << std::dec << ", CRC = " << mess.getGdpbSlcCrc(); -*/ - fhGet4ChanScm->Fill(dFullChId, uType + 1); - } // if( 0 == mess.getGdpbSlcChan() && 0 == mess.getGdpbSlcEdge() ) - else if( 0 == mess.getGdpbSlcChan() && 1 == mess.getGdpbSlcEdge() ) // SEU counter message - { -/* - LOG(info) << "GET4 Slow Control message, epoch " - << static_cast<Int_t>(fvulCurrentEpoch[fuGet4Nr]) << ", time " << std::setprecision(9) - << std::fixed << dMessTime << " s " - << " for board ID " << std::hex << std::setw(4) << fuGdpbId - << std::dec << "\n" - << " +++++++ > Chip = " - << std::setw(2) << mess.getGdpbGenChipId() << ", Chan = " - << std::setw(1) << mess.getGdpbSlcChan() << ", Edge = " - << std::setw(1) << mess.getGdpbSlcEdge() << ", Type = " - << std::setw(1) << mess.getGdpbSlcType() << ", Data = 0x" -// << std::hex << std::setw(6) << mess.getGdpbSlcData() - << Form( "%06x", mess.getGdpbSlcData() ) - << std::dec << ", CRC = " << mess.getGdpbSlcCrc(); -*/ - fhGet4ChanScm->Fill(dFullChId, uType ); - fhScmSeuCounters->Fill( uData, dFullChId); - fhScmSeuCountersEvo->Fill( dMessTime - fdStartTime* 1.e-9, uData, dFullChId); - } // else if( 0 == mess.getGdpbSlcChan() && 1 == mess.getGdpbSlcEdge() ) - break; - } - default: // Should never happen - break; - } // switch( mess.getGdpbSlcType() ) - } -} - -void CbmTofStarMonitorShift2018::PrintGenInfo(gdpb::Message mess) -{ - Int_t mType = mess.getMessageType(); - Int_t channel = mess.getGdpbHitChanId(); - uint64_t uData = mess.getData(); - - LOG(debug) << "Get4 MSG type " << mType << " from gdpbId " << fuGdpbId - << ", getId " << fuGet4Id << ", (hit channel) " << channel - << " data " << std::hex << uData; -} - -void CbmTofStarMonitorShift2018::PrintSysInfo(gdpb::Message mess) -{ - if (fGdpbIdIndexMap.end() != fGdpbIdIndexMap.find(fuGdpbId)) - LOG(debug) << "GET4 System message, epoch " - << static_cast<Int_t>(fvulCurrentEpoch[fuGet4Nr]) << ", time " << std::setprecision(9) - << std::fixed << Double_t(fulCurrentEpochTime) * 1.e-9 << " s " - << " for board ID " << std::hex << std::setw(4) << fuGdpbId - << std::dec; - - switch( mess.getGdpbSysSubType() ) - { - case gdpb::SYSMSG_GET4_EVENT: - { - uint32_t uData = mess.getGdpbSysErrData(); - if( gdpb::GET4_V2X_ERR_TOT_OVERWRT == uData - || gdpb::GET4_V2X_ERR_TOT_RANGE == uData - || gdpb::GET4_V2X_ERR_EVT_DISCARD == uData - || gdpb::GET4_V2X_ERR_ADD_RIS_EDG == uData - || gdpb::GET4_V2X_ERR_UNPAIR_FALL == uData - || gdpb::GET4_V2X_ERR_SEQUENCE_ER == uData - ) - LOG(debug) << " +++++++ > gDPB: " << std::hex << std::setw(4) << fuGdpbId - << std::dec << ", Chip = " << std::setw(2) - << mess.getGdpbGenChipId() << ", Chan = " << std::setw(1) - << mess.getGdpbSysErrChanId() << ", Edge = " - << std::setw(1) << mess.getGdpbSysErrEdge() << ", Empt = " - << std::setw(1) << mess.getGdpbSysErrUnused() - << ", Data = " << std::hex << std::setw(2) << uData - << std::dec << " -- GET4 V1 Error Event"; - else LOG(debug) << " +++++++ >gDPB: " << std::hex << std::setw(4) << fuGdpbId - << std::dec << ", Chip = " << std::setw(2) - << mess.getGdpbGenChipId() << ", Chan = " << std::setw(1) - << mess.getGdpbSysErrChanId() << ", Edge = " - << std::setw(1) << mess.getGdpbSysErrEdge() << ", Empt = " - << std::setw(1) << mess.getGdpbSysErrUnused() - << ", Data = " << std::hex << std::setw(2) << uData - << std::dec << " -- GET4 V1 Error Event "; - break; - } // case gdpb::SYSMSG_GET4_EVENT - case gdpb::SYSMSG_CLOSYSYNC_ERROR: - LOG(debug) << "Closy synchronization error"; - break; - case gdpb::SYSMSG_TS156_SYNC: - LOG(debug) << "160.00 MHz timestamp reset"; - break; - case gdpb::SYSMSG_GDPB_UNKWN: - LOG(debug) << "Unknown GET4 message, data: " << std::hex << std::setw(8) - << mess.getGdpbSysUnkwData() << std::dec - <<" Full message: " << std::hex << std::setw(16) - << mess.getData() << std::dec; - break; - } // switch( getGdpbSysSubType() ) -} - -void CbmTofStarMonitorShift2018::FillStarTrigInfo(gdpb::Message mess) -{ - Int_t iMsgIndex = mess.getStarTrigMsgIndex(); - - switch( iMsgIndex ) - { - case 0: - fvhTokenMsgType[fuGdpbNr]->Fill(0); - fvulGdpbTsMsb[fuGdpbNr] = mess.getGdpbTsMsbStarA(); - break; - case 1: - fvhTokenMsgType[fuGdpbNr]->Fill(1); - fvulGdpbTsLsb[fuGdpbNr] = mess.getGdpbTsLsbStarB(); - fvulStarTsMsb[fuGdpbNr] = mess.getStarTsMsbStarB(); - break; - case 2: - fvhTokenMsgType[fuGdpbNr]->Fill(2); - fvulStarTsMid[fuGdpbNr] = mess.getStarTsMidStarC(); - break; - case 3: - { - fvhTokenMsgType[fuGdpbNr]->Fill(3); - - ULong64_t ulNewGdpbTsFull = ( fvulGdpbTsMsb[fuGdpbNr] << 24 ) - + ( fvulGdpbTsLsb[fuGdpbNr] ); - ULong64_t ulNewStarTsFull = ( fvulStarTsMsb[fuGdpbNr] << 48 ) - + ( fvulStarTsMid[fuGdpbNr] << 8 ) - + mess.getStarTsLsbStarD(); - UInt_t uNewToken = mess.getStarTokenStarD(); - UInt_t uNewDaqCmd = mess.getStarDaqCmdStarD(); - UInt_t uNewTrigCmd = mess.getStarTrigCmdStarD(); - - if( ( uNewToken == fvuStarTokenLast[fuGdpbNr] ) && ( ulNewGdpbTsFull == fvulGdpbTsFullLast[fuGdpbNr] ) && - ( ulNewStarTsFull == fvulStarTsFullLast[fuGdpbNr] ) && ( uNewDaqCmd == fvuStarDaqCmdLast[fuGdpbNr] ) && - ( uNewTrigCmd == fvuStarTrigCmdLast[fuGdpbNr] ) ) - { - UInt_t uTrigWord = ( (fvuStarTrigCmdLast[fuGdpbNr] & 0x00F) << 16 ) - + ( (fvuStarDaqCmdLast[fuGdpbNr] & 0x00F) << 12 ) - + ( (fvuStarTokenLast[fuGdpbNr] & 0xFFF) ); - LOG(warning) << "Possible error: identical STAR tokens found twice in a row => ignore 2nd! " - << " TS " << fulCurrentTsIndex - << " gDBB #" << fuGdpbNr << " " - << Form("token = %5u ", fvuStarTokenLast[fuGdpbNr] ) - << Form("gDPB ts = %12llu ", fvulGdpbTsFullLast[fuGdpbNr] ) - << Form("STAR ts = %12llu ", fvulStarTsFullLast[fuGdpbNr] ) - << Form("DAQ cmd = %2u ", fvuStarDaqCmdLast[fuGdpbNr] ) - << Form("TRG cmd = %2u ", fvuStarTrigCmdLast[fuGdpbNr] ) - << Form("TRG Wrd = %5x ", uTrigWord ); - return; - } // if exactly same message repeated -/* - if( (uNewToken != fuStarTokenLast[fuGdpbNr] + 1) && - 0 < fvulGdpbTsFullLast[fuGdpbNr] && 0 < fvulStarTsFullLast[fuGdpbNr] && - ( 4095 != fvuStarTokenLast[fuGdpbNr] || 1 != uNewToken) ) - LOG(warning) << "Possible error: STAR token did not increase by exactly 1! " - << " gDBB #" << fuGdpbNr << " " - << Form("old = %5u vs new = %5u ", fvuStarTokenLast[fuGdpbNr], uNewToken) - << Form("old = %12llu vs new = %12llu ", fvulGdpbTsFullLast[fuGdpbNr], ulNewGdpbTsFull) - << Form("old = %12llu vs new = %12llu ", fvulStarTsFullLast[fuGdpbNr], ulNewStarTsFull) - << Form("old = %2u vs new = %2u ", fvuStarDaqCmdLast[fuGdpbNr], uNewDaqCmd) - << Form("old = %2u vs new = %2u ", fvuStarTrigCmdLast[fuGdpbNr], uNewTrigCmd); -*/ - // STAR TS counter reset detection - if( ulNewStarTsFull < fvulStarTsFullLast[fuGdpbNr] ) - LOG(debug) << "Probable reset of the STAR TS: old = " << Form("%16llu", fvulStarTsFullLast[fuGdpbNr]) - << " new = " << Form("%16llu", ulNewStarTsFull) - << " Diff = -" << Form("%8llu", fvulStarTsFullLast[fuGdpbNr] - ulNewStarTsFull); - -/* - LOG(info) << "Updating trigger token for " << fuGdpbNr - << " " << fuStarTokenLast[fuGdpbNr] << " " << uNewToken; -*/ -// ULong64_t ulGdpbTsDiff = ulNewGdpbTsFull - fvulGdpbTsFullLast[fuGdpbNr]; - fvulGdpbTsFullLast[fuGdpbNr] = ulNewGdpbTsFull; - fvulStarTsFullLast[fuGdpbNr] = ulNewStarTsFull; - fvuStarTokenLast[fuGdpbNr] = uNewToken; - fvuStarDaqCmdLast[fuGdpbNr] = uNewDaqCmd; - fvuStarTrigCmdLast[fuGdpbNr] = uNewTrigCmd; - - /// Histograms filling only in core MS - if( fuCurrentMs < fuCoreMs ) - { - /// In Run rate evolution - if( 0 <= fdStartTime ) - { - /// Reset the evolution Histogram and the start time when we reach the end of the range - if( fuHistoryHistoSize < 1e-9 * (fvulGdpbTsFullLast[fuGdpbNr] * get4v2x::kdClockCycleSizeNs - fdStartTime) ) - { - ResetEvolutionHistograms(); - fdStartTime = fvulGdpbTsFullLast[fuGdpbNr] * get4v2x::kdClockCycleSizeNs; - } // if( fuHistoryHistoSize < 1e-9 * (fulGdpbTsFullLast * get4v2x::kdClockCycleSizeNs - fdStartTime) ) - - fvhTriggerRate[fuGdpbNr]->Fill( 1e-9 * ( fvulGdpbTsFullLast[fuGdpbNr] * get4v2x::kdClockCycleSizeNs - fdStartTime ) ); - fvhStarTokenEvo[fuGdpbNr]->Fill( 1e-9 * ( fvulGdpbTsFullLast[fuGdpbNr] * get4v2x::kdClockCycleSizeNs - fdStartTime ), - fvuStarTokenLast[fuGdpbNr] ); - fvhStarTrigGdpbTsEvo[fuGdpbNr]->Fill( 1e-9 * ( fvulGdpbTsFullLast[fuGdpbNr] * get4v2x::kdClockCycleSizeNs - fdStartTime ), - fvulGdpbTsFullLast[fuGdpbNr] ); - fvhStarTrigStarTsEvo[fuGdpbNr]->Fill( 1e-9 * ( fvulGdpbTsFullLast[fuGdpbNr] * get4v2x::kdClockCycleSizeNs - fdStartTime ), - fvulStarTsFullLast[fuGdpbNr] ); - } // if( 0 < fdStartTime ) - else fdStartTime = fvulGdpbTsFullLast[fuGdpbNr] * get4v2x::kdClockCycleSizeNs; - fvhCmdDaqVsTrig[fuGdpbNr]->Fill( fvuStarDaqCmdLast[fuGdpbNr], fvuStarTrigCmdLast[fuGdpbNr] ); - } // if( fuCurrentMs < fuCoreMs ) - - break; - } // case 3 - default: - LOG(error) << "Unknown Star Trigger messageindex: " << iMsgIndex; - } // switch( iMsgIndex ) -} - -void CbmTofStarMonitorShift2018::Reset() -{ -} - -void CbmTofStarMonitorShift2018::Finish() -{ - // Printout some stats on what was unpacked - TString message_type; - for( unsigned int i = 0; i < fviMsgCounter.size(); ++i) - { - switch (i) - { - case 0: - message_type = "NOP"; - break; - case 1: - message_type = "HIT"; - break; - case 2: - message_type = "EPOCH"; - break; - case 3: - message_type = "SYNC"; - break; - case 4: - message_type = "AUX"; - break; - case 5: - message_type = "EPOCH2"; - break; - case 6: - message_type = "GET4"; - break; - case 7: - message_type = "SYS"; - break; - case 8: - message_type = "GET4_SLC"; - break; - case 9: - message_type = "GET4_32B"; - break; - case 10: - message_type = "GET4_SYS"; - break; - default: - message_type = "UNKNOWN"; - break; - } // switch(i) - LOG(info) << message_type << " messages: " << fviMsgCounter[i]; - } // for (unsigned int i=0; i< fviMsgCounter.size(); ++i) - - LOG(info) << "-------------------------------------"; - for (UInt_t i = 0; i < fuNrOfGdpbs; ++i) - { - for (UInt_t j = 0; j < fuNrOfGet4PerGdpb; ++j) - { - LOG(info) << "Last epoch for gDPB: " << std::hex << std::setw(4) << i - << std::dec << " , GET4 " << std::setw(4) << j << " => " - << fvulCurrentEpoch[GetArrayIndex(i, j)]; - } // for (UInt_t j = 0; j < fuNrOfGet4PerGdpb; ++j) - } // for (UInt_t i = 0; i < fuNrOfGdpbs; ++i) - LOG(info) << "-------------------------------------"; - - SaveAllHistos(); -} - -void CbmTofStarMonitorShift2018::FillOutput(boost::any) -{ -} - -void CbmTofStarMonitorShift2018::SaveAllHistos( TString sFileName ) -{ - TDirectory * oldDir = NULL; - TFile * histoFile = NULL; - if( "" != sFileName ) - { - // Store current directory position to allow restore later - oldDir = gDirectory; - // open separate histo file in recreate mode - histoFile = new TFile( sFileName , "RECREATE"); - histoFile->cd(); - } // if( "" != sFileName ) - - gDirectory->mkdir("Tof_Raw_gDPB"); - gDirectory->cd("Tof_Raw_gDPB"); - - fhMessType->Write(); - fhSysMessType->Write(); - fhGet4MessType->Write(); - fhGet4ChanScm->Write(); - fhGet4ChanErrors->Write(); - fhGet4EpochFlags->Write(); - fhScmScalerCounters->Write(); - fhScmDeadtimeCounters->Write(); - fhScmSeuCounters->Write(); - fhScmSeuCountersEvo->Write(); - - for( UInt_t uTotPlot = 0; uTotPlot < fvhRawTot_gDPB.size(); ++uTotPlot ) - fvhRawTot_gDPB[ uTotPlot ]->Write(); - - for( UInt_t uTotPlot = 0; uTotPlot < fvhRemapTot_gDPB.size(); ++uTotPlot ) - fvhRemapTot_gDPB[ uTotPlot ]->Write(); - - for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb ) - { - fvhRawFt_gDPB[ uGdpb ]->Write(); - fvhChCount_gDPB[ uGdpb ]->Write(); - fvhChannelRate_gDPB[ uGdpb ]->Write(); - fvhRemapChCount_gDPB[ uGdpb ]->Write(); - fvhRemapChRate_gDPB[ uGdpb ]->Write(); - - for (UInt_t uFeet = 0; uFeet < fuNrOfFeetPerGdpb; ++ uFeet) - { - fvhFeetRate_gDPB[ uGdpb * fuNrOfFeetPerGdpb + uFeet ]->Write(); - fvhFeetErrorRate_gDPB[ uGdpb * fuNrOfFeetPerGdpb + uFeet ]->Write(); - fvhFeetErrorRatio_gDPB[ uGdpb * fuNrOfFeetPerGdpb + uFeet ]->Write(); - fvhFeetRateLong_gDPB[ uGdpb * fuNrOfFeetPerGdpb + uFeet ]->Write(); - fvhFeetErrorRateLong_gDPB[ uGdpb * fuNrOfFeetPerGdpb + uFeet ]->Write(); - fvhFeetErrorRatioLong_gDPB[ uGdpb * fuNrOfFeetPerGdpb + uFeet ]->Write(); - } // for (UInt_t uFeet = 0; uFeet < fuNrOfFeetPerGdpb; ++ uFeet) - - } // for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb ) - fhTimeRmsPulser->Write(); - fhTimeRmsZoomFitPuls->Write(); - fhTimeResFitPuls->Write(); - gDirectory->cd(".."); - - ///* STAR event building/cutting */// - gDirectory->mkdir("Star_Raw"); - gDirectory->cd("Star_Raw"); - for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb ) - { - fvhTokenMsgType[ uGdpb ]->Write(); - fvhTriggerRate[ uGdpb ]->Write(); - fvhCmdDaqVsTrig[ uGdpb ]->Write(); - fvhStarTokenEvo[ uGdpb ]->Write(); - fvhStarTrigGdpbTsEvo[ uGdpb ]->Write(); - fvhStarTrigStarTsEvo[ uGdpb ]->Write(); - } // for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb ) - gDirectory->cd(".."); - - ///* Pulser monitoring */// - gDirectory->mkdir("TofDt"); - gDirectory->cd("TofDt"); - for( UInt_t uFeeA = 0; uFeeA < fuNrOfFeetPerGdpb * fuNrOfGdpbs; uFeeA++) - for( UInt_t uFeeB = 0; uFeeB < fuNrOfFeetPerGdpb * fuNrOfGdpbs; uFeeB++) - if( NULL != fvhTimeDiffPulser[uFeeA][uFeeB] ) - fvhTimeDiffPulser[uFeeA][uFeeB]->Write(); - gDirectory->cd(".."); - - - gDirectory->mkdir("Flib_Raw"); - gDirectory->cd("Flib_Raw"); - for( UInt_t uLinks = 0; uLinks < fvhMsSzPerLink.size(); uLinks++ ) - { - if( NULL == fvhMsSzPerLink[ uLinks ] ) - continue; - - fvhMsSzPerLink[ uLinks ]->Write(); - fvhMsSzTimePerLink[ uLinks ]->Write(); - } // for( UInt_t uLinks = 0; uLinks < fvhMsSzPerLink.size(); uLinks++ ) - - TH1 * pMissedTsH1 = dynamic_cast< TH1 * >( gROOT->FindObjectAny( "Missed_TS" ) ); - if( NULL != pMissedTsH1 ) - pMissedTsH1->Write(); - - TProfile * pMissedTsEvoP = dynamic_cast< TProfile * >( gROOT->FindObjectAny( "Missed_TS_Evo" ) ); - if( NULL != pMissedTsEvoP ) - pMissedTsEvoP->Write(); - - gDirectory->cd(".."); - - - if( "" != sFileName ) - { - // Restore original directory position - histoFile->Close(); - oldDir->cd(); - } // if( "" != sFileName ) - if( "" != sFileName ) - { - // Restore original directory position - histoFile->Close(); - oldDir->cd(); - } // if( "" != sFileName ) - -} - -void CbmTofStarMonitorShift2018::ResetAllHistos() -{ - LOG(info) << "Reseting all TOF histograms."; - - fhMessType->Reset(); - fhSysMessType->Reset(); - fhGet4MessType->Reset(); - fhGet4ChanScm->Reset(); - fhGet4ChanErrors->Reset(); - fhGet4EpochFlags->Reset(); - fhScmScalerCounters->Reset(); - fhScmDeadtimeCounters->Reset(); - fhScmSeuCounters->Reset(); - fhScmSeuCountersEvo->Reset(); - - for( UInt_t uTotPlot = 0; uTotPlot < fvhRawTot_gDPB.size(); ++uTotPlot ) - fvhRawTot_gDPB[ uTotPlot ]->Reset(); - - for( UInt_t uTotPlot = 0; uTotPlot < fvhRemapTot_gDPB.size(); ++uTotPlot ) - fvhRemapTot_gDPB[ uTotPlot ]->Reset(); - - for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb ) - { - fvhRawFt_gDPB[ uGdpb ]->Reset(); - fvhChCount_gDPB[ uGdpb ]->Reset(); - fvhChannelRate_gDPB[ uGdpb ]->Reset(); - fvhRemapChCount_gDPB[ uGdpb ]->Reset(); - fvhRemapChRate_gDPB[ uGdpb ]->Reset(); - - for (UInt_t uFeet = 0; uFeet < fuNrOfFeetPerGdpb; ++ uFeet) - { - fvhFeetRate_gDPB[ uGdpb * fuNrOfFeetPerGdpb + uFeet ]->Reset(); - fvhFeetErrorRate_gDPB[ uGdpb * fuNrOfFeetPerGdpb + uFeet ]->Reset(); - fvhFeetErrorRatio_gDPB[ uGdpb * fuNrOfFeetPerGdpb + uFeet ]->Reset(); - fvhFeetRateLong_gDPB[ uGdpb * fuNrOfFeetPerGdpb + uFeet ]->Reset(); - fvhFeetErrorRateLong_gDPB[ uGdpb * fuNrOfFeetPerGdpb + uFeet ]->Reset(); - fvhFeetErrorRatioLong_gDPB[ uGdpb * fuNrOfFeetPerGdpb + uFeet ]->Reset(); - } // for (UInt_t uFeet = 0; uFeet < fuNrOfFeetPerGdpb; ++ uFeet) - - } // for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb ) - fhTimeRmsPulser->Reset(); - fhTimeRmsZoomFitPuls->Reset(); - fhTimeResFitPuls->Reset(); - - ///* STAR event building/cutting */// - for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb ) - { - fvhTokenMsgType[ uGdpb ]->Reset(); - fvhTriggerRate[ uGdpb ]->Reset(); - fvhCmdDaqVsTrig[ uGdpb ]->Reset(); - fvhStarTokenEvo[ uGdpb ]->Reset(); - fvhStarTrigGdpbTsEvo[ uGdpb ]->Reset(); - fvhStarTrigStarTsEvo[ uGdpb ]->Reset(); - } // for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb ) - - ///* Pulser monitoring */// - for( UInt_t uFeeA = 0; uFeeA < fuNrOfFeetPerGdpb * fuNrOfGdpbs; uFeeA++) - for( UInt_t uFeeB = 0; uFeeB < fuNrOfFeetPerGdpb * fuNrOfGdpbs; uFeeB++) - if( NULL != fvhTimeDiffPulser[uFeeA][uFeeB] ) - fvhTimeDiffPulser[uFeeA][uFeeB]->Reset(); - - for( UInt_t uLinks = 0; uLinks < fvhMsSzPerLink.size(); uLinks++ ) - { - if( NULL == fvhMsSzPerLink[ uLinks ] ) - continue; - - fvhMsSzPerLink[ uLinks ]->Reset(); - fvhMsSzTimePerLink[ uLinks ]->Reset(); - } // for( UInt_t uLinks = 0; uLinks < fvhMsSzPerLink.size(); uLinks++ ) - - fdStartTime = -1; - fdStartTimeLong = -1; - fdStartTimeMsSz = -1; -} -void CbmTofStarMonitorShift2018::ResetEvolutionHistograms() -{ - for( UInt_t uGdpbLoop = 0; uGdpbLoop < fuNrOfGdpbs; ++uGdpbLoop ) - { - fvhChannelRate_gDPB[ uGdpbLoop ]->Reset(); - fvhRemapChRate_gDPB[ uGdpbLoop ]->Reset(); - for( UInt_t uFeetLoop = 0; uFeetLoop < fuNrOfFeetPerGdpb; ++uFeetLoop ) - { - fvhFeetRate_gDPB[(uGdpbLoop * fuNrOfFeetPerGdpb) + uFeetLoop]->Reset(); - fvhFeetErrorRate_gDPB[(uGdpbLoop * fuNrOfFeetPerGdpb) + uFeetLoop]->Reset(); - fvhFeetErrorRatio_gDPB[(uGdpbLoop * fuNrOfFeetPerGdpb) + uFeetLoop]->Reset(); - } // for( UInt_t uFeetLoop = 0; uFeetLoop < fuNrOfFeetPerGdpb; ++uFeetLoop ) - fvhTriggerRate[ uGdpbLoop ]->Reset(); - fvhStarTokenEvo[ uGdpbLoop ]->Reset(); - fvhStarTrigGdpbTsEvo[ uGdpbLoop ]->Reset(); - fvhStarTrigStarTsEvo[ uGdpbLoop ]->Reset(); - } // for( UInt_t uGdpbLoop = 0; uGdpbLoop < fuNrOfGdpbs; ++uGdpbLoop ) - - fdStartTime = -1; -} -void CbmTofStarMonitorShift2018::ResetLongEvolutionHistograms() -{ - for (UInt_t uGdpbLoop = 0; uGdpbLoop < fuNrOfGdpbs; uGdpbLoop++) - { - for (UInt_t uFeetLoop = 0; uFeetLoop < fuNrOfFeetPerGdpb; uFeetLoop++) - { - fvhFeetRateLong_gDPB[(uGdpbLoop * fuNrOfFeetPerGdpb) + uFeetLoop]->Reset(); - fvhFeetErrorRateLong_gDPB[(uGdpbLoop * fuNrOfFeetPerGdpb) + uFeetLoop]->Reset(); - fvhFeetErrorRatioLong_gDPB[(uGdpbLoop * fuNrOfFeetPerGdpb) + uFeetLoop]->Reset(); - } // for (UInt_t uFeetLoop = 0; uFeetLoop < fuNrOfFeetPerGdpb; uFeetLoop++) - } // for (UInt_t uFeetLoop = 0; uFeetLoop < fuNrOfFeetPerGdpb; uFeetLoop++) - - fdStartTimeLong = -1; -} - -void CbmTofStarMonitorShift2018::UpdateZoomedFit() -{ - // Only do something is the user defined the width he want for the zoom - if( 0.0 < fdFitZoomWidthPs ) - { - // Reset summary histograms for safety - fhTimeRmsZoomFitPuls->Reset(); - fhTimeResFitPuls->Reset(); - - Double_t dRes = 0; - TF1 *fitFuncPairs[ fuNrOfFeetPerGdpb * fuNrOfGdpbs ][ fuNrOfFeetPerGdpb * fuNrOfGdpbs ]; - - for( UInt_t uFeeA = 0; uFeeA < fuNrOfFeetPerGdpb * fuNrOfGdpbs; uFeeA++) - for( UInt_t uFeeB = 0; uFeeB < fuNrOfFeetPerGdpb * fuNrOfGdpbs; uFeeB++) - if( NULL != fvhTimeDiffPulser[uFeeA][uFeeB] ) - { - // Check that we have at least 1 entry - if( 0 == fvhTimeDiffPulser[uFeeA][uFeeB]->GetEntries() ) - { - fhTimeRmsZoomFitPuls->Fill( uFeeA, uFeeB, 0.0 ); - fhTimeResFitPuls->Fill( uFeeA, uFeeB, 0.0 ); - LOG(info) << "CbmTofStarMonitorShift2018::UpdateZoomedFit => Empty input " - << "for FEE pair " << uFeeA << " and " << uFeeB << " !!! "; - continue; - } // if( 0 == fvhTimeDiffPulser[uFeeA][uFeeB]->GetEntries() ) - - // Read the peak position (bin with max counts) + total nb of entries - Int_t iBinWithMax = fvhTimeDiffPulser[uFeeA][uFeeB]->GetMaximumBin(); - Double_t dNbCounts = fvhTimeDiffPulser[uFeeA][uFeeB]->Integral(); - - // Zoom the X axis to +/- ZoomWidth around the peak position - Double_t dPeakPos = fvhTimeDiffPulser[uFeeA][uFeeB]->GetXaxis()->GetBinCenter( iBinWithMax ); - fvhTimeDiffPulser[uFeeA][uFeeB]->GetXaxis()->SetRangeUser( dPeakPos - fdFitZoomWidthPs, - dPeakPos + fdFitZoomWidthPs ); - - // Read integral and check how much we lost due to the zoom (% loss allowed) - Double_t dZoomCounts = fvhTimeDiffPulser[uFeeA][uFeeB]->Integral(); - if( ( dZoomCounts / dNbCounts ) < 0.99 ) - { - fhTimeRmsZoomFitPuls->Fill( uFeeA, uFeeB, 0.0 ); - fhTimeResFitPuls->Fill( uFeeA, uFeeB, 0.0 ); - LOG(warning) << "CbmTofStarMonitorShift2018::UpdateZoomedFit => Zoom too strong, " - << "more than 1% loss for FEE pair " << uFeeA << " and " << uFeeB << " !!! "; - continue; - } // if( ( dZoomCounts / dNbCounts ) < 0.99 ) - - // Fill new RMS after zoom into summary histo - fhTimeRmsZoomFitPuls->Fill( uFeeA, uFeeB, fvhTimeDiffPulser[uFeeA][uFeeB]->GetRMS() ); - - - // Fit using zoomed boundaries + starting gaussian width, store into summary histo - dRes = 0; - fitFuncPairs[uFeeA][uFeeB] = new TF1( Form("fPair_%02d_%02d", uFeeA, uFeeB ), "gaus", - dPeakPos - fdFitZoomWidthPs , - dPeakPos + fdFitZoomWidthPs); - // Fix the Mean fit value around the Histogram Mean - fitFuncPairs[uFeeA][uFeeB]->SetParameter( 0, dZoomCounts ); - fitFuncPairs[uFeeA][uFeeB]->SetParameter( 1, dPeakPos ); - fitFuncPairs[uFeeA][uFeeB]->SetParameter( 2, 200.0 ); // Hardcode start with ~4*BinWidth, do better later - // Using integral instead of bin center seems to lead to unrealistic values => no "I" - fvhTimeDiffPulser[uFeeA][uFeeB]->Fit( Form("fPair_%02d_%02d", uFeeA, uFeeB ), "QRM0"); - // Get Sigma - dRes = fitFuncPairs[uFeeA][uFeeB]->GetParameter(2); - // Cleanup memory - delete fitFuncPairs[uFeeA][uFeeB]; - // Fill summary - fhTimeResFitPuls->Fill( uFeeA, uFeeB, dRes / TMath::Sqrt2() ); - - - LOG(info) << "CbmTofStarMonitorShift2018::UpdateZoomedFit => " - << "For FEE pair " << uFeeA << " and " << uFeeB - << " we have zoomed RMS = " << fvhTimeDiffPulser[uFeeA][uFeeB]->GetRMS() - << " and a resolution of " << dRes / TMath::Sqrt2(); - - // Restore original axis state? - fvhTimeDiffPulser[uFeeA][uFeeB]->GetXaxis()->UnZoom(); - } // loop on uFeeA and uFeeB + check if corresponding fvhTimeDiffPulser exists - } // if( 0.0 < fdFitZoomWidthPs ) - else - { - LOG(error) << "CbmTofStarMonitorShift2018::UpdateZoomedFit => Zoom width not defined, " - << "please use SetFitZoomWidthPs, e.g. in macro, before trying this update !!!"; - } // else of if( 0.0 < fdFitZoomWidthPs ) -} - -ClassImp(CbmTofStarMonitorShift2018) diff --git a/beamtime/star2018/unpacker/CbmTofStarMonitorShift2018.h b/beamtime/star2018/unpacker/CbmTofStarMonitorShift2018.h deleted file mode 100644 index 207d763692fecc6dc89caa41787bdbfbd07986af..0000000000000000000000000000000000000000 --- a/beamtime/star2018/unpacker/CbmTofStarMonitorShift2018.h +++ /dev/null @@ -1,228 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmTofStarMonitorShift2018 ----- -// ----- Created 19.01.2018 by P.-A. Loizeau ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CbmTofStarMonitorShift2018_H -#define CbmTofStarMonitorShift2018_H - -#include "Timeslice.hpp" -#include "rocMess_wGet4v2.h" -#include "CbmTofStarData.h" -#include "CbmTofStarData2018.h" - -#include "CbmTSUnpack.h" - -#include "TClonesArray.h" -#include "Rtypes.h" - -#include <vector> -#include <map> -#include <chrono> - -class CbmTofStar2018Par; - -class TCanvas; -class TH1; -class TH2; -class TProfile; - -class CbmTofStarMonitorShift2018: public CbmTSUnpack { - public: - - CbmTofStarMonitorShift2018(); - virtual ~CbmTofStarMonitorShift2018(); - - virtual Bool_t Init(); - - virtual Bool_t DoUnpack(const fles::Timeslice& ts, size_t component); - - virtual void Reset(); - - virtual void Finish(); - - void SetParContainers(); - - Bool_t InitContainers(); - - Bool_t ReInitContainers(); - - void FillOutput(boost::any); - - void SetMsLimitLevel(size_t uAcceptBoundaryPct = 100) { fuMsAcceptsPercent = uAcceptBoundaryPct; } - size_t GetMsLimitLevel() { return fuMsAcceptsPercent; } - - void SetMsOverlap(size_t uOverlapMsNb = 1) { fuOverlapMsNb = uOverlapMsNb; } - size_t GetMsOverlap() { return fuOverlapMsNb; } - - inline void SetFitZoomWidthPs( Double_t inZoomWidth = 1000.0 ) { fdFitZoomWidthPs = inZoomWidth; } - inline void SetHistoryHistoSize( UInt_t inHistorySizeSec = 1800 ) { fuHistoryHistoSize = inHistorySizeSec; } - inline void SetHistoryHistoSizeLong( UInt_t inHistorySizeMin = 1800 ) { fuHistoryHistoSizeLong = inHistorySizeMin; } - - void SaveAllHistos( TString sFileName = "" ); - void ResetAllHistos(); - void ResetEvolutionHistograms(); - void ResetLongEvolutionHistograms(); - void UpdateNormedFt(); - void UpdateZoomedFit(); - - private: - - size_t fuMsAcceptsPercent; /** Reject Ms with index inside TS above this, assumes 100 MS per TS **/ - size_t fuTotalMsNb; /** Total nb of MS per link in timeslice **/ - size_t fuOverlapMsNb; /** Overlap Ms: all fuOverlapMsNb MS at the end of timeslice **/ - size_t fuCoreMs; /** Number of non overlap MS at beginning of TS **/ - Double_t fdMsSizeInNs; - Double_t fdTsCoreSizeInNs; - UInt_t fuMinNbGdpb; - UInt_t fuCurrNbGdpb; - - /** Settings from parameter file **/ - CbmTofStar2018Par* fUnpackPar; //! - UInt_t fuNrOfGdpbs; // Total number of GDPBs in the system - UInt_t fuNrOfFeetPerGdpb; // Number of FEBs per GDPB - UInt_t fuNrOfGet4PerFeb; // Number of GET4s per FEB - UInt_t fuNrOfChannelsPerGet4; // Number of channels in each GET4 - - UInt_t fuNrOfChannelsPerFeet; // Number of channels in each FEET - UInt_t fuNrOfGet4; // Total number of Get4 chips in the system - UInt_t fuNrOfGet4PerGdpb; // Number of GET4s per GDPB - UInt_t fuNrOfChannelsPerGdpb; // Number of channels per GDPB - - - /** Running indices **/ - uint64_t fulCurrentTsIndex; // Idx of the current TS - size_t fuCurrentMs; // Idx of the current MS in TS (0 to fuTotalMsNb) - Double_t fdMsIndex; // Time in ns of current MS from its index - UInt_t fuGdpbId; // Id (hex number) of the GDPB for current message - UInt_t fuGdpbNr; // running number (0 to fuNrOfGdpbs) of the GDPB for current message - UInt_t fuGet4Id; // running number (0 to fuNrOfGet4PerGdpb) of the Get4 chip of a unique GDPB for current message - UInt_t fuGet4Nr; // running number (0 to fuNrOfGet4) of the Get4 chip in the system for current message - Int_t fiEquipmentId; - std::vector<int> fviMsgCounter; - - ///* STAR TRIGGER detection */// - std::vector< ULong64_t > fvulGdpbTsMsb; - std::vector< ULong64_t > fvulGdpbTsLsb; - std::vector< ULong64_t > fvulStarTsMsb; - std::vector< ULong64_t > fvulStarTsMid; - std::vector< ULong64_t > fvulGdpbTsFullLast; - std::vector< ULong64_t > fvulStarTsFullLast; - std::vector< UInt_t > fvuStarTokenLast; - std::vector< UInt_t > fvuStarDaqCmdLast; - std::vector< UInt_t > fvuStarTrigCmdLast; - - /** Current epoch marker for each GDPB and GET4 - * (first epoch in the stream initializes the map item) - * pointer points to an array of size fuNrOfGdpbs * fuNrOfGet4PerGdpb - * The correct array index is calculated using the function - * GetArrayIndex(gdpbId, get4Id) - **/ - std::vector< ULong64_t > fvulCurrentEpoch; //! - std::vector< Bool_t > fvbFirstEpochSeen; //! - - ULong64_t fulCurrentEpochTime; /** Time stamp of current epoch **/ - - /// Map of ID to index for the gDPBs - std::map<UInt_t, UInt_t> fGdpbIdIndexMap; - - /// Buffer for suppressed epoch processing - std::vector< std::vector < gdpb::Message > > fvmEpSupprBuffer; - - /// Buffer for pulser channels - std::vector< Double_t > fdTsLastPulserHit; // [ fuFeetNr ] - - /// Histograms and histogram control variables - // Default value for nb bins in Pulser time difference histos - const UInt_t kuNbBinsDt = 300; - Double_t dMinDt; - Double_t dMaxDt; - // Default number of FEET per channels histograms - UInt_t fuNbFeetPlot; - UInt_t fuNbFeetPlotsPerGdpb; - // Evolution plots control - Double_t fdStartTime; /** Time of first valid hit (epoch available), used as reference for evolution plots**/ - Double_t fdStartTimeLong; /** Time of first valid hit (epoch available), used as reference for evolution plots**/ - Double_t fdStartTimeMsSz; /** Time of first microslice, used as reference for evolution plots**/ - UInt_t fuHistoryHistoSize; /** Size in seconds of the evolution histograms **/ - UInt_t fuHistoryHistoSizeLong; /** Size in minutes of the long evolution histograms **/ - // Pulser plots - Double_t fdLastRmsUpdateTime; - Double_t fdFitZoomWidthPs; - // Flesnet - TCanvas* fcMsSizeAll; - std::vector< TH1 * > fvhMsSzPerLink; - std::vector< TProfile * > fvhMsSzTimePerLink; - // Messages types and flags - TH1* fhMessType; - TH1* fhSysMessType; - TH2* fhGet4MessType; - TH2* fhGet4ChanScm; - TH2* fhGet4ChanErrors; - TH2* fhGet4EpochFlags; - // Slow control messages - TH2* fhScmScalerCounters; - TH2* fhScmDeadtimeCounters; - TH2* fhScmSeuCounters; - TH2* fhScmSeuCountersEvo; - // Hit messages - /// TODO: Channel rate plots! - std::vector< TH2 * > fvhRawFt_gDPB; - std::vector< TH2 * > fvhRawTot_gDPB; - std::vector< TH1 * > fvhChCount_gDPB; - std::vector< TH2 * > fvhChannelRate_gDPB; - std::vector< TH2 * > fvhRemapTot_gDPB; - std::vector< TH1 * > fvhRemapChCount_gDPB; - std::vector< TH2 * > fvhRemapChRate_gDPB; - std::vector< TH1 * > fvhFeetRate_gDPB; - std::vector< TH1 * > fvhFeetErrorRate_gDPB; - std::vector< TProfile * > fvhFeetErrorRatio_gDPB; - std::vector< TH1 * > fvhFeetRateLong_gDPB; - std::vector< TH1 * > fvhFeetErrorRateLong_gDPB; - std::vector< TProfile * > fvhFeetErrorRatioLong_gDPB; - - ///* STAR TRIGGER detection */// - std::vector< TH1 * > fvhTokenMsgType; - std::vector< TH1 * > fvhTriggerRate; - std::vector< TH2 * > fvhCmdDaqVsTrig; - std::vector< TH2 * > fvhStarTokenEvo; - std::vector< TProfile * > fvhStarTrigGdpbTsEvo; - std::vector< TProfile * > fvhStarTrigStarTsEvo; - - ///* Pulser monitoring */// - const Double_t kdMaxDtPulserPs = 100e3; - std::vector< std::vector< TH1 * > > fvhTimeDiffPulser; - TH2 * fhTimeRmsPulser; - TH2 * fhTimeRmsZoomFitPuls; - TH2 * fhTimeResFitPuls; - - void CreateHistograms(); - - void FillHitInfo( gdpb::Message ); - void FillEpochInfo( gdpb::Message ); - void PrintSlcInfo( gdpb::Message ); - void PrintSysInfo( gdpb::Message ); - void PrintGenInfo( gdpb::Message ); - void FillStarTrigInfo( gdpb::Message ); - - inline Int_t GetArrayIndex(Int_t gdpbId, Int_t get4Id) - { - return gdpbId * fuNrOfGet4PerGdpb + get4Id; - } - - ///* PADI channel to GET4 channel mapping and reverse */// - std::vector< UInt_t > fvuPadiToGet4; - std::vector< UInt_t > fvuGet4ToPadi; - - ///* Periodic histos saving */// - std::chrono::time_point<std::chrono::system_clock> fTimeLastHistoSaving; - - CbmTofStarMonitorShift2018(const CbmTofStarMonitorShift2018&); - CbmTofStarMonitorShift2018 operator=(const CbmTofStarMonitorShift2018&); - - ClassDef(CbmTofStarMonitorShift2018, 1) -}; - -#endif diff --git a/beamtime/star2018/unpacker/CbmUnpackTofStar2018.cxx b/beamtime/star2018/unpacker/CbmUnpackTofStar2018.cxx deleted file mode 100644 index 15c680a0a526d0fb680688da41d0ec7bd22433dc..0000000000000000000000000000000000000000 --- a/beamtime/star2018/unpacker/CbmUnpackTofStar2018.cxx +++ /dev/null @@ -1,838 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmUnpackTofStar2018 ----- -// ----- Created 08.12.2017 by P.-A. Loizeau ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#include "CbmUnpackTofStar2018.h" -#include "CbmTofUnpackPar.h" -#include "CbmTofDigi.h" -//#include "CbmTbEvent.h" - -#include "CbmFormatDecHexPrintout.h" - -#include "CbmTbDaqBuffer.h" - -//#include "CbmFiberHodoAddress.h" -#include "CbmHistManager.h" - -#include "FairLogger.h" -#include "FairRootManager.h" -#include "FairRun.h" -#include "FairRuntimeDb.h" - -#include "TClonesArray.h" -#include "TString.h" - -#include <iostream> -#include <stdint.h> -#include <iomanip> - -static Int_t iMess=0; -const Int_t DetMask = 0x0001FFFF; - - -CbmUnpackTofStar2018::CbmUnpackTofStar2018( UInt_t uNbGdpb ) - : CbmTSUnpack(), - fuMsAcceptsPercent(100), - fuOverlapMsNb(0), - fuMinNbGdpb( uNbGdpb ), - fuCurrNbGdpb( 0 ), - fuNrOfGdpbs(0), - fuNrOfFebsPerGdpb(0), - fuNrOfGet4PerFeb(0), - fuNrOfChannelsPerGet4(0), - fuNrOfChannelsPerFeet(0), - fuNrOfGet4(0), - fuNrOfGet4PerGdpb(0), - fuNrOfChannelsPerGdpb(0), - fMsgCounter(11,0), // length of enum MessageTypes initialized with 0 - fGdpbIdIndexMap(), - fuGdpbId(0), - fuGdpbNr(0), - fuGet4Id(0), - fuGet4Nr(0), - fHM(new CbmHistManager()), - fvulCurrentEpoch(), - fvbFirstEpochSeen(), - fNofEpochs(0), - fulCurrentEpochTime(0.), - fEquipmentId(0), - fdMsIndex(0.), - fdTShiftRef(0.), - fTofDigi(), - fDigi(NULL), - fBuffer(CbmTbDaqBuffer::Instance()), - fUnpackPar(NULL), - fdRefTime(0.), - fdLastDigiTime(0.), - fdFirstDigiTimeDif(0.), - fdEvTime0(0.), - fhRawTDigEvT0( NULL ), - fhRawTDigRef0( NULL ), - fhRawTDigRef( NULL ), - fhRawTRefDig0( NULL ), - fhRawTRefDig1( NULL ), - fhRawDigiLastDigi( NULL ), - fhRawTotCh(), - fhChCount(), - fvbChanThere(), - fhChanCoinc(), - fhDetChanCoinc(nullptr), - fvmEpSupprBuffer() -{ -} - -CbmUnpackTofStar2018::~CbmUnpackTofStar2018() -{ -} - -Bool_t CbmUnpackTofStar2018::Init() -{ - LOG(info) << "Initializing flib Get4 unpacker"; - - FairRootManager* ioman = FairRootManager::Instance(); - if( NULL == ioman ) - { - LOG(fatal) << "No FairRootManager instance"; - } - - fTofDigi= new TClonesArray("CbmTofDigi", 10); - if( NULL == fTofDigi ) - { - LOG(fatal) << "No Digi TClonesarray "; - } - ioman->Register("CbmTofDigi", "Tof raw Digi", fTofDigi, kTRUE); - -/* - CbmTbEvent * fEventHeader = (CbmTbEvent *)ioman->GetObject("EventHeader."); - if( NULL == fEventHeade r) - { - LOG(fatal) << "No EventHeader TClonesarray "; - } -*/ - - fUnpackPar = (CbmTofUnpackPar*)(FairRun::Instance()); - - return kTRUE; -} - -void CbmUnpackTofStar2018::SetParContainers() -{ - LOG(info) << "Setting parameter containers for " << GetName(); - fUnpackPar = (CbmTofUnpackPar*)(FairRun::Instance()->GetRuntimeDb()->getContainer("CbmTofUnpackPar")); - -} - -Bool_t CbmUnpackTofStar2018::InitContainers() -{ - LOG(info) << "Init parameter containers for " << GetName(); - Bool_t initOK = ReInitContainers(); - - CreateHistograms(); - - fvulCurrentEpoch.resize( fuNrOfGdpbs * fuNrOfGet4PerGdpb ); - fvbFirstEpochSeen.resize( fuNrOfGdpbs * fuNrOfGet4PerGdpb ); - fvbChanThere.resize( fUnpackPar->GetNumberOfChannels(), kFALSE ); - for( UInt_t i = 0; i < fuNrOfGdpbs; ++i ) - { - for( UInt_t j = 0; j < fuNrOfGet4PerGdpb; ++j ) - { - fvulCurrentEpoch[GetArrayIndex(i, j)] = 0; - fvbFirstEpochSeen[GetArrayIndex(i, j)] = kFALSE; - } // for( UInt_t j = 0; j < fuNrOfGet4PerGdpb; ++j ) - } // for( UInt_t i = 0; i < fuNrOfGdpbs; ++i ) - - return initOK; -} - -Bool_t CbmUnpackTofStar2018::ReInitContainers() -{ - LOG(info) << "ReInit parameter containers for " << GetName(); - - fuNrOfGdpbs = fUnpackPar->GetNrOfRocs(); - LOG(info) << "Nr. of Tof GDPBs: " << fuNrOfGdpbs; - fuMinNbGdpb = fuNrOfGdpbs; - - fuNrOfFebsPerGdpb = fUnpackPar->GetNrOfFebsPerGdpb(); - LOG(info) << "Nr. of FEBS per Tof GDPB: " << fuNrOfFebsPerGdpb; - - fuNrOfGet4PerFeb = fUnpackPar->GetNrOfGet4PerFeb(); - LOG(info) << "Nr. of GET4 per Tof FEB: " << fuNrOfGet4PerFeb; - - fuNrOfChannelsPerGet4 = fUnpackPar->GetNrOfChannelsPerGet4(); - LOG(info) << "Nr. of channels per GET4: " << fuNrOfChannelsPerGet4; - - fuNrOfChannelsPerFeet = fuNrOfGet4PerFeb * fuNrOfChannelsPerGet4; - LOG(info) << "Nr. of channels per FEET: " << fuNrOfChannelsPerFeet; - - fuNrOfGet4 = fuNrOfGdpbs * fuNrOfFebsPerGdpb * fuNrOfGet4PerFeb; - LOG(info) << "Nr. of GET4s: " << fuNrOfGet4; - - fuNrOfGet4PerGdpb = fuNrOfFebsPerGdpb * fuNrOfGet4PerFeb; - LOG(info) << "Nr. of GET4s per GDPB: " << fuNrOfGet4PerGdpb; - - fuNrOfChannelsPerGdpb = fuNrOfGet4PerGdpb * fuNrOfChannelsPerGet4; - LOG(info) << "Nr. of channels per GDPB: " << fuNrOfChannelsPerGdpb; - - fGdpbIdIndexMap.clear(); - for( UInt_t i = 0; i < fuNrOfGdpbs; ++i ) - { - fGdpbIdIndexMap[fUnpackPar->GetRocId(i)] = i; - LOG(info) << "GDPB Id of TOF " << i << " : " << std::hex << fUnpackPar->GetRocId(i) - << std::dec; - } // for( UInt_t i = 0; i < fuNrOfGdpbs; ++i ) - UInt_t uNrOfChannels = fUnpackPar->GetNumberOfChannels(); - LOG(info) << "Nr. of mapped Tof channels: " << uNrOfChannels; - std::stringstream ss; - for( UInt_t i = 0; i < uNrOfChannels; ++i) - { - if(i%8 == 0) - ss << "\n"; - ss << Form(" 0x%08x",fUnpackPar->GetChannelToDetUIdMap(i)); - } // for( UInt_t i = 0; i < uNrOfChannels; ++i) - LOG(info) << ss.str(); - - LOG(info) << "Plot Channel Rate => " - << (fUnpackPar->IsChannelRateEnabled() ? "ON" : "OFF"); - - fvmEpSupprBuffer.resize( fuNrOfGet4 ); - - return kTRUE; -} - -void CbmUnpackTofStar2018::CreateHistograms() -{ - LOG(info) << "create Histos for " << fuNrOfGdpbs <<" gDPBs "; - - fhRawTDigEvT0 = new TH1F( Form("Raw_TDig-EvT0"), - Form("Raw digi time difference to 1st digi ; time [ns]; cts"), - 100, 0, 50.); - fHM->Add( Form("Raw_TDig-EvT0"), fhRawTDigEvT0); - - fhRawTDigRef0 = new TH1F( Form("Raw_TDig-Ref0"), - Form("Raw digi time difference to Ref ; time [ns]; cts"), - 5000, 0, 500000); - fHM->Add( Form("Raw_TDig-Ref0"), fhRawTDigRef0); - - fhRawTDigRef = new TH1F( Form("Raw_TDig-Ref"), - Form("Raw digi time difference to Ref ; time [ns]; cts"), - 5000, 0, 50000); - fHM->Add( Form("Raw_TDig-Ref"), fhRawTDigRef); - - fhRawTRefDig0 = new TH1F( Form("Raw_TRef-Dig0"), - Form("Raw Ref time difference to last digi ; time [ns]; cts"), - 9999, -500000000, 500000000); - fHM->Add( Form("Raw_TRef-Dig0"), fhRawTRefDig0); - - fhRawTRefDig1 = new TH1F( Form("Raw_TRef-Dig1"), - Form("Raw Ref time difference to last digi ; time [ns]; cts"), - 9999, -5000000, 5000000); - fHM->Add( Form("Raw_TRef-Dig1"), fhRawTRefDig1); - - fhRawDigiLastDigi = new TH1F( Form("Raw_Digi-LastDigi"), - Form("Raw Digi time difference to last digi ; time [ns]; cts"), - 9999, -5000000, 5000000); - fHM->Add( Form("Raw_Digi-LastDigi"), fhRawDigiLastDigi); - - fhRawTotCh.resize( fuNrOfGdpbs ); - fhChCount.resize( fuNrOfGdpbs ); - fhChanCoinc.resize( fuNrOfGdpbs * fuNrOfFebsPerGdpb / 2 ); - for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; uGdpb ++) - { - fhRawTotCh[ uGdpb ] = new TH2F( Form("Raw_Tot_gDPB_%02u", uGdpb), - Form("Raw TOT gDPB %02u; channel; TOT [bin]", uGdpb), - fuNrOfChannelsPerGdpb, 0., fuNrOfChannelsPerGdpb, - 256, 0., 256. ); - fHM->Add( Form("Raw_Tot_gDPB_%02u", uGdpb), fhRawTotCh[ uGdpb ]); - - fhChCount[ uGdpb ] = new TH1I( Form("ChCount_gDPB_%02u", uGdpb), - Form("Channel counts gDPB %02u; channel; Hits", uGdpb), - fuNrOfChannelsPerGdpb, 0., fuNrOfChannelsPerGdpb ); - fHM->Add( Form("ChCount_gDPB_%02u", uGdpb), fhChCount[ uGdpb ]); -/* - for( UInt_t uLeftFeb = uGdpb*fuNrOfFebsPerGdpb / 2; - uLeftFeb < (uGdpb + 1 )*fuNrOfFebsPerGdpb / 2; - ++uLeftFeb ) - { - fhChanCoinc[ uLeftFeb ] = new TH2F( Form("fhChanCoinc_%02u", uLeftFeb), - Form("Channels Coincidence %02; Left; Right", uLeftFeb), - fuNrOfChannelsPerFeet, 0., fuNrOfChannelsPerFeet, - fuNrOfChannelsPerFeet, 0., fuNrOfChannelsPerFeet ); - } // for( UInt_t uLeftFeb = 0; uLeftFeb < fuNrOfFebsPerGdpb / 2; uLeftFeb ++ ) -*/ - fhChanCoinc[ uGdpb ] = new TH2F( Form("fhChanCoinc_%02u", uGdpb), - Form("Channels Coincidence %02u; Left; Right", uGdpb), - fuNrOfChannelsPerGdpb, 0., fuNrOfChannelsPerGdpb, - fuNrOfChannelsPerGdpb, 0., fuNrOfChannelsPerGdpb ); - } // for( UInt_t uGdpb = 0; uGdpb < fuMinNbGdpb; uGdpb ++) - fhDetChanCoinc = new TH2F( "fhDetChanCoinc", - "Det Channels Coincidence; Left; Right", - 32, 0., 32, - 32, 0., 32 ); -} - -Bool_t CbmUnpackTofStar2018::DoUnpack(const fles::Timeslice& ts, size_t component) -{ - LOG(debug) << "Timeslice contains " << ts.num_microslices(component) - << " microslices of component " << component; - - // Loop over microslices - Int_t iMessageType = -111; - size_t numCompMsInTs = ts.num_microslices(component); - for (size_t m = 0; m < numCompMsInTs; ++m) - { - // Jump some microslices if needed -// if( fuMsAcceptsPercent < m) -// continue; - - // Ignore overlap ms if number defined by user - if( numCompMsInTs - fuOverlapMsNb <= m ) - continue; - - constexpr uint32_t kuBytesPerMessage = 8; - - auto msDescriptor = ts.descriptor(component, m); - fEquipmentId = msDescriptor.eq_id; - fdMsIndex = static_cast<double>(msDescriptor.idx); - const uint8_t* msContent = reinterpret_cast< const uint8_t* >( ts.content(component, m) ); - - uint32_t size = msDescriptor.size; - if( 0 < size ) - LOG(debug1) << "Microslice "<< m <<": " << fdMsIndex - << " has size: " << size; - - // If not integer number of message in input buffer, print warning/error - if( 0 != (size % kuBytesPerMessage) ) - LOG(error) << "The input microslice buffer does NOT " - << "contain only complete nDPB messages!"; - - // If not integer number of message in input buffer, print warning/error - if( 0 != (size % kuBytesPerMessage) ) - LOG(error) << "The input microslice buffer does NOT " - << "contain only complete nDPB messages!"; - - // Compute the number of complete messages in the input microslice buffer - uint32_t uNbMessages = (size - (size % kuBytesPerMessage) ) - / kuBytesPerMessage; - - // Prepare variables for the loop on contents - const uint64_t* pInBuff = reinterpret_cast<const uint64_t*>( msContent ); - for (uint32_t uIdx = 0; uIdx < uNbMessages; uIdx ++) - { - // Fill message - uint64_t ulData = static_cast<uint64_t>( pInBuff[uIdx] ); - ngdpb::Message mess( ulData ); - - if( gLogger->IsLogNeeded( fair::Severity::debug2 ) ) - { - mess.printDataCout(); - } // if( gLogger->IsLogNeeded( fair::Severity::debug2 ) ) - - // Increment counter for different message types - iMessageType = mess.getMessageType(); - fMsgCounter[ iMessageType ]++; - - fuGdpbId = mess.getRocNumber(); - fuGdpbNr = fGdpbIdIndexMap[ fuGdpbId ]; - - fuGet4Id = mess.getGdpbGenChipId(); - fuGet4Nr = (fuGdpbNr * fuNrOfGet4PerGdpb) + fuGet4Id; - - if( fuNrOfGet4PerGdpb <= fuGet4Id && - ngdpb::MSG_STAR_TRI != iMessageType && - get4v1x::kuChipIdMergedEpoch != fuGet4Id ) - LOG(warning) << "Message with Get4 ID too high: " << fuGet4Id - << " VS " << fuNrOfGet4PerGdpb << " set in parameters."; - - switch( mess.getMessageType() ) - { - case ngdpb::MSG_HIT: - case ngdpb::MSG_EPOCH: - case ngdpb::MSG_GET4: - { - // FillEpochInfo(mess); - LOG(error) << "Message type " << mess.getMessageType() - << " not included in unpacker."; - break; - } // case old non tof messages - case ngdpb::MSG_EPOCH2: - { - if( get4v1x::kuChipIdMergedEpoch == fuGet4Id ) - { - - for( UInt_t uChan = fuGdpbNr * fuNrOfChannelsPerGdpb; - uChan < (fuGdpbNr + 1 ) * fuNrOfChannelsPerGdpb; - ++uChan ) - fvbChanThere[ uChan ] = kFALSE; - - if( 0 == fuGdpbNr ) - for( UInt_t uDetChan = 0; uDetChan < 64; uDetChan ++) - fbDetChanThere[uDetChan] = kFALSE; - - for( uint32_t uGet4Index = 0; uGet4Index < fuNrOfGet4PerGdpb; uGet4Index ++ ) - { - ngdpb::Message tmpMess( mess ); - tmpMess.setGdpbGenChipId( uGet4Index ); - fuGet4Nr = (fuGdpbNr * fuNrOfGet4PerGdpb) + uGet4Index; - -// fHistGet4MessType->Fill(uGet4Index, ngdpb::GET4_32B_EPOCH); - FillEpochInfo( tmpMess ); - } // for( uint32_t uGet4Index = 0; uGet4Index < fuNrOfGet4PerGdpb; uGetIndex ++ ) - - for( UInt_t uChanA = fuGdpbNr * fuNrOfChannelsPerGdpb; - uChanA < (fuGdpbNr + 1 ) * fuNrOfChannelsPerGdpb; - ++uChanA ) - { - if( kTRUE == fvbChanThere[ uChanA ] ) - { - for( UInt_t uChanB = fuGdpbNr * fuNrOfChannelsPerGdpb; - uChanB < (fuGdpbNr + 1 ) * fuNrOfChannelsPerGdpb; - ++uChanB ) - { - if( kTRUE == fvbChanThere[ uChanB ] ) - { - fhChanCoinc[ fuGdpbNr ]->Fill( uChanA - fuGdpbNr * fuNrOfChannelsPerGdpb, - uChanB - fuGdpbNr * fuNrOfChannelsPerGdpb ); - } // if uChanB - } // for uChanB - } // if uChanA - } // for uChanA - - if( 0 == fuGdpbNr ) - { - for( UInt_t uDetChanLeft = 0; uDetChanLeft < 32; uDetChanLeft ++) - if( kTRUE == fbDetChanThere[ uDetChanLeft ] ) - for( UInt_t uDetChanRight = 0; uDetChanRight < 32; uDetChanRight ++) - if( kTRUE == fbDetChanThere[ 32 + uDetChanRight ] ) - fhDetChanCoinc->Fill( uDetChanLeft, uDetChanRight ); - } // if( 0 == fuGdpbNr ) - } // if this epoch message is a merged one valiud for all chips - else - { -// fHistGet4MessType->Fill( fuGet4Nr, ngdpb::GET4_32B_EPOCH ); - FillEpochInfo(mess); - } // if single chip epoch message - break; - } // case ngdpb::MSG_EPOCH2: - case ngdpb::MSG_GET4_32B: - { - fvmEpSupprBuffer[ fuGet4Nr ].push_back( mess ); - break; - } // case ngdpb::MSG_GET4_32B: - case ngdpb::MSG_GET4_SLC: - { - PrintSlcInfo(mess); - break; - } // case ngdpb::MSG_GET4_SLC: - case ngdpb::MSG_GET4_SYS: - { - if(100 > iMess++) - PrintSysInfo(mess); - break; - } // case ngdpb::MSG_GET4_SYS: - case ngdpb::MSG_STAR_TRI: - { - FillStarTrigInfo(mess); - break; - } // case ngdpb::MSG_STAR_TRI: - default: - { - if(100 > iMess++) - LOG(error) << "Message ("<<iMess<<") type " << std::hex << std::setw(2) - << static_cast< uint16_t >( mess.getMessageType() ) - << " not included in Get4 unpacker."; - if(100 == iMess) - LOG(error) << "Stop reporting MSG errors... "; - } // default: - } // switch( mess.getMessageType() ) - - } // for (uint32_t uIdx = 0; uIdx < uNbMessages; uIdx ++) - - } // for (size_t m = 0; m < numCompMsInTs; ++m) - - - return kTRUE; -} - -void CbmUnpackTofStar2018::FillHitInfo( ngdpb::Message mess ) -{ - // --- Get absolute time, GET4 ID and channel number - UInt_t uGet4Id = mess.getGdpbGenChipId(); - UInt_t uChannel = mess.getGdpbHitChanId(); - UInt_t uTot = mess.getGdpbHit32Tot(); - // In 32b mode the coarse counter is already computed back to 112 FTS bins - // => need to hide its contribution from the Finetime - // => FTS = Fullt TS modulo 112 -// UInt_t uFts = mess.getGdpbHitFullTs() % 112; - - ULong_t ulCurEpochGdpbGet4 = fvulCurrentEpoch[ fuGet4Nr ]; - - if( kTRUE == fvbFirstEpochSeen[ fuGet4Nr ] ) - { - // In Ep. Suppr. Mode, receive following epoch instead of previous - if( 0 < ulCurEpochGdpbGet4 ) - ulCurEpochGdpbGet4 --; - else ulCurEpochGdpbGet4 = get4v1x::kuEpochCounterSz; // Catch epoch cycle! - -// ULong_t ulhitTime = mess.getMsgG4v2FullTime( ulCurEpochGdpbGet4 ); - Double_t dHitTime = mess.getMsgG4v2FullTimeD( ulCurEpochGdpbGet4 ); - Double_t dHitTot = uTot; // in bins - - -// UInt_t uFebIdx = (uGet4Id / fuNrOfGet4PerFeb); -// UInt_t uFullFebIdx = (fuGdpbNr * fuNrOfFebsPerGdpb) + uFebIdx; - - UInt_t uChanInGdpb = uGet4Id * fuNrOfChannelsPerGet4 + uChannel; - UInt_t uChanInSyst = fuGdpbNr * fuNrOfChannelsPerGdpb + uChanInGdpb; - if( fUnpackPar->GetNumberOfChannels() < 1 || - static_cast< UInt_t >( fUnpackPar->GetNumberOfChannels() ) < uChanInSyst ) - { - LOG(error) << "Invalid mapping index " << uChanInSyst - << " VS " << fUnpackPar->GetNumberOfChannels() - <<", from " << fuGdpbNr - <<", " << uGet4Id - <<", " << uChannel; - return; - } // if( fUnpackPar->GetNumberOfChannels() < uChanUId ) - - fvbChanThere[ uChanInSyst ] = kTRUE; - - UInt_t uChanUId = fUnpackPar->GetChannelToDetUIdMap( uChanInSyst ); - if( 0 == uChanUId ) - return; // Hit not mapped to digi - - if( (uChanUId & DetMask) == 0x00001006 ) - { - UInt_t uDetChan = (uChanUId & 0xFF000000) >> 24; - if( (uChanUId & 0x00800000) == 0x00800000 ) - uDetChan += 32; - - fbDetChanThere[ uDetChan ] = kTRUE; - } // if( (uChanUId & DetMask) == 0x00001006 ) - - fhRawDigiLastDigi->Fill( dHitTime - fdLastDigiTime ); - fdLastDigiTime = dHitTime; - - if( (uChanUId & DetMask) == 0x00001006 ) - dHitTime += fdTShiftRef; - - LOG(debug) << Form("Insert 0x%08x digi with time ", uChanUId ) << dHitTime << Form(", Tot %4.0f",dHitTot) - << " into buffer with " << fBuffer->GetSize() << " data from " - << Form("%11.1f to %11.1f ", fBuffer->GetTimeFirst(), fBuffer->GetTimeLast()) - << " at epoch " << ulCurEpochGdpbGet4; - fDigi = new CbmTofDigi(uChanUId, dHitTime, dHitTot); - - fBuffer->InsertData<CbmTofDigi>(fDigi); - - // Histograms filling - fhRawTotCh[ fuGdpbNr ]->Fill( uChanInGdpb, dHitTot); - fhChCount[ fuGdpbNr ] ->Fill( uChanInGdpb ); - - } // if( kTRUE == fvbFirstEpochSeen[ fuGet4Nr ] ) -} - -void CbmUnpackTofStar2018::FillEpochInfo( ngdpb::Message mess ) -{ - ULong64_t ulEpochNr = mess.getGdpbEpEpochNb(); - - fvulCurrentEpoch[ fuGet4Nr ] = ulEpochNr; - - if( kFALSE == fvbFirstEpochSeen[ fuGet4Nr ] ) - fvbFirstEpochSeen[ fuGet4Nr ] = kTRUE; - - fulCurrentEpochTime = mess.getMsgFullTime(ulEpochNr); - fNofEpochs++; - - /// In Ep. Suppr. Mode, receive following epoch instead of previous - /// Re-align the epoch number of the message in case it will be used later: - /// We received the epoch after the data instead of the one before! - if( 0 < ulEpochNr ) - mess.setEpoch2Number( ulEpochNr - 1 ); - else mess.setEpoch2Number( get4v1x::kuEpochCounterSz ); - - Int_t iBufferSize = fvmEpSupprBuffer[ fuGet4Nr ].size(); - if( 0 < iBufferSize ) - { - LOG(debug) << "Now processing stored messages for for get4 " << fuGet4Nr << " with epoch number " - << (fvulCurrentEpoch[ fuGet4Nr ] - 1); - - for( Int_t iMsgIdx = 0; iMsgIdx < iBufferSize; iMsgIdx++ ) - { - FillHitInfo( fvmEpSupprBuffer[ fuGet4Nr ][ iMsgIdx ] ); - } // for( Int_t iMsgIdx = 0; iMsgIdx < iBufferSize; iMsgIdx++ ) -/* - for( UInt_t uLeftFeb = fuGdpbNr * fuNrOfFebsPerGdpb / 2; - uLeftFeb < (fuGdpbNr + 1) * fuNrOfFebsPerGdpb / 2; - ++uLeftFeb ) - { - for( UInt_t uChanA = 2*uLeftFeb * fuNrOfChannelsPerFeet; - uChanA < (2*uLeftFeb + 1) * fuNrOfChannelsPerFeet; - ++uChanA ) - { - if( kTRUE == fvbChanThere[ uChanA ] ) - { - for( UInt_t uChanB = (2*uLeftFeb + 1) * fuNrOfChannelsPerFeet; - uChanB < (2*uLeftFeb + 2) * fuNrOfChannelsPerFeet; - ++uChanB ) - { - if( kTRUE == fvbChanThere[ uChanB ] ) - { - fhChanCoinc[ uLeftFeb ]->Fill( uChanA, uChanB ); - } - } - } - } - } // for( UInt_t uLeftFeb = 0; uLeftFeb < fuNrOfFebsPerGdpb / 2; ++uLeftFeb ) -*/ - fvmEpSupprBuffer[fuGet4Nr].clear(); - } // if( 0 < fvmEpSupprBuffer[fGet4Nr] ) -} - -void CbmUnpackTofStar2018::PrintSlcInfo(ngdpb::Message /*mess*/) -{ - /// Nothing to do, maybe later use it to trakc parameter changes like treshold? -/* - if( fGdpbIdIndexMap.end() != fGdpbIdIndexMap.find( rocId ) ) - LOG(info) << "GET4 Slow Control message, epoch " << static_cast<Int_t>(fCurrentEpoch[rocId][get4Id]) - << ", time " << std::setprecision(9) << std::fixed - << Double_t(fulCurrentEpochTime) * 1.e-9 << " s " - << " for board ID " << std::hex << std::setw(4) << rocId << std::dec - << "\n" - << " +++++++ > Chip = " << std::setw(2) << mess.getGdpbGenChipId() - << ", Chan = " << std::setw(1) << mess.getGdpbSlcChan() - << ", Edge = " << std::setw(1) << mess.getGdpbSlcEdge() - << ", Type = " << std::setw(1) << mess.getGdpbSlcType() - << ", Data = " << std::hex << std::setw(6) << mess.getGdpbSlcData() << std::dec - << ", Type = " << mess.getGdpbSlcCrc(); -*/ -} - -void CbmUnpackTofStar2018::PrintGenInfo(ngdpb::Message mess) -{ - Int_t mType = mess.getMessageType(); - Int_t rocId = mess.getRocNumber(); - Int_t get4Id = mess.getGdpbGenChipId(); - Int_t channel = mess.getGdpbHitChanId(); - uint64_t uData = mess.getData(); - if(100 > iMess++) - LOG(info) << "Get4 MSG type "<<mType<<" from rocId "<<rocId<<", getId "<<get4Id - << ", (hit channel) "<<channel -// <<Form(" hex data %0llx ",uData); - << " hex data " << FormatHexPrintout( uData, 0, '0' ); -} - -void CbmUnpackTofStar2018::PrintSysInfo(ngdpb::Message mess) -{ - LOG(info) << "GET4 System message, epoch " << (fvulCurrentEpoch[ fuGet4Nr]) - << ", time " << std::setprecision(9) << std::fixed - << Double_t(fulCurrentEpochTime) * 1.e-9 << " s " - << " for board ID " << std::hex << std::setw(4) << fuGdpbId << std::dec; - - switch( mess.getGdpbSysSubType() ) - { - case ngdpb::SYSMSG_GET4_EVENT: - { - LOG(info) << " +++++++ > Chip = " << std::setw(2) << mess.getGdpbGenChipId() - << ", Chan = " << std::setw(1) << mess.getGdpbSysErrChanId() - << ", Edge = " << std::setw(1) << mess.getGdpbSysErrEdge() - << ", Empt = " << std::setw(1) << mess.getGdpbSysErrUnused() - << ", Data = " << std::hex << std::setw(2) << mess.getGdpbSysErrData() << std::dec - << " -- GET4 V1 Error Event"; - break; - } // - case ngdpb::SYSMSG_CLOSYSYNC_ERROR: - LOG(info) << "Closy synchronization error"; - break; - case ngdpb::SYSMSG_TS156_SYNC: - LOG(info) << "156.25MHz timestamp reset"; - break; - case ngdpb::SYSMSG_GDPB_UNKWN: - LOG(info) << "Unknown GET4 message, data: " << std::hex << std::setw(8) - << mess.getGdpbSysUnkwData() << std::dec; - break; - } // switch( getGdpbSysSubType() ) -} - -void CbmUnpackTofStar2018::Reset() -{ - // fFiberHodoRaw->Clear(); - fTofDigi->Clear(); -} - -void CbmUnpackTofStar2018::Finish() -{ - TString message_type; - - for( UInt_t uType = 0; uType < fMsgCounter.size(); ++uType) - { - switch(uType) - { - case 0: message_type ="NOP"; break; - case 1: message_type ="HIT"; break; - case 2: message_type ="EPOCH"; break; - case 3: message_type ="SYNC"; break; - case 4: message_type ="AUX"; break; - case 5: message_type ="EPOCH2"; break; - case 6: message_type ="GET4"; break; - case 7: message_type ="SYS"; break; - case 8: message_type ="GET4_SLC"; break; - case 9: message_type ="GET4_32B"; break; - case 10: message_type ="GET4_SYS"; break; - default: message_type ="UNKNOWN"; break; - } // switch(uType) - LOG(info) << message_type << " messages: " - << fMsgCounter[uType]; - } // for( UInt_t uType = 0; uType < fMsgCounter.size(); ++uType) - - LOG(info) << "-------------------------------------"; - for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; ++uGdpb ) - for( UInt_t uGet4 = 0; uGet4 < fuNrOfGet4PerGdpb; ++uGet4 ) - LOG(info) << "Last epoch for gDPB: "<< std::setw(4) << uGdpb - << " , GET4 " << std::setw(4) << uGet4 - << " => " << fvulCurrentEpoch[GetArrayIndex(uGdpb, uGet4)]; - LOG(info) << "-------------------------------------"; - - - gDirectory->mkdir("Tof_Raw_gDPB"); - gDirectory->cd("Tof_Raw_gDPB"); - fHM->H1( Form("Raw_TDig-Ref0") )->Write(); - fHM->H1( Form("Raw_TDig-Ref") )->Write(); - fHM->H1( Form("Raw_TRef-Dig0") )->Write(); - fHM->H1( Form("Raw_TRef-Dig1") )->Write(); - fHM->H1( Form("Raw_Digi-LastDigi") )->Write(); - for( UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; uGdpb ++) - { - fHM->H2( Form("Raw_Tot_gDPB_%02u", uGdpb) )->Write(); - fHM->H1( Form("ChCount_gDPB_%02u", uGdpb) )->Write(); -/* - for( UInt_t uLeftFeb = uGdpb*fuNrOfFebsPerGdpb / 2; - uLeftFeb < (uGdpb + 1 )*fuNrOfFebsPerGdpb / 2; - ++uLeftFeb ) - fhChanCoinc[ uLeftFeb ]->Write(); -*/ - fhChanCoinc[ uGdpb ]->Write(); - } // for( UInt_t uGdpb = 0; uGdpb < fuMinNbGdpb; uGdpb ++) - fhDetChanCoinc->Write(); - gDirectory->cd(".."); - -} - - -void CbmUnpackTofStar2018::FillOutput(CbmDigi* digi) -{ - if( 100 > iMess++ ) - LOG(debug) << "Fill digi TClonesarray with " - << Form("0x%08x", digi->GetAddress()) - << " at " << static_cast<Int_t>( fTofDigi->GetEntriesFast() ); - - - new( (*fTofDigi)[ fTofDigi->GetEntriesFast() ] ) - CbmTofDigi( *( dynamic_cast<CbmTofDigi*>(digi) ) ); - //CbmTofDigi((CbmTofDigi *)digi); - - if( 0 == fTofDigi->GetEntriesFast()) - fdEvTime0=digi->GetTime(); - else fhRawTDigEvT0->Fill( digi->GetTime() - fdEvTime0 ); - - if( (digi->GetAddress() & DetMask) != 0x00001006 ) - { - fhRawTDigRef0->Fill( digi->GetTime() - fdRefTime); - fhRawTDigRef->Fill( digi->GetTime() - fdRefTime); - } // if( (digi->GetAddress() & DetMask) != 0x00001006 ) - else fdRefTime = digi->GetTime(); - - digi->Delete(); -} - -static ULong64_t fulGdpbTsMsb; -static ULong64_t fulGdpbTsLsb; -static ULong64_t fulStarTsMsb; -static ULong64_t fulStarTsMid; -static ULong64_t fulGdpbTsFullLast; -static ULong64_t fulStarTsFullLast; -static UInt_t fuStarTokenLast; -static UInt_t fuStarDaqCmdLast; -static UInt_t fuStarTrigCmdLast; - -void CbmUnpackTofStar2018::FillStarTrigInfo(ngdpb::Message mess) -{ - Int_t iMsgIndex = mess.getStarTrigMsgIndex(); - - switch( iMsgIndex ) - { - case 0: - fulGdpbTsMsb = mess.getGdpbTsMsbStarA(); - break; - case 1: - fulGdpbTsLsb = mess.getGdpbTsLsbStarB(); - fulStarTsMsb = mess.getStarTsMsbStarB(); - break; - case 2: - fulStarTsMid = mess.getStarTsMidStarC(); - break; - case 3: - { - ULong64_t ulNewGdpbTsFull = ( fulGdpbTsMsb << 24 ) - + ( fulGdpbTsLsb ); - ULong64_t ulNewStarTsFull = ( fulStarTsMsb << 48 ) - + ( fulStarTsMid << 8 ) - + mess.getStarTsLsbStarD(); - UInt_t uNewToken = mess.getStarTokenStarD(); - UInt_t uNewDaqCmd = mess.getStarDaqCmdStarD(); - UInt_t uNewTrigCmd = mess.getStarTrigCmdStarD(); - if( ( uNewToken == fuStarTokenLast ) && ( ulNewGdpbTsFull == fulGdpbTsFullLast ) && - ( ulNewStarTsFull == fulStarTsFullLast ) && ( uNewDaqCmd == fuStarDaqCmdLast ) && - ( uNewTrigCmd == fuStarTrigCmdLast ) ) - { - LOG(debug) << "Possible error: identical STAR tokens found twice in a row => ignore 2nd! " - << Form("token = %5u ", fuStarTokenLast ) - << Form("gDPB ts = %12llu ", fulGdpbTsFullLast ) - << Form("STAR ts = %12llu ", fulStarTsFullLast ) - << Form("DAQ cmd = %2u ", fuStarDaqCmdLast ) - << Form("TRG cmd = %2u ", fuStarTrigCmdLast ); - return; - } // if exactly same message repeated -/* - if( (uNewToken != fuStarTokenLast + 1) && - 0 < fulGdpbTsFullLast && 0 < fulStarTsFullLast && - ( 4095 != fuStarTokenLast || 1 != uNewToken) ) - LOG(warning) << "Possible error: STAR token did not increase by exactly 1! " - << Form("old = %5u vs new = %5u ", fuStarTokenLast, uNewToken) - << Form("old = %12llu vs new = %12llu ", fulGdpbTsFullLast, ulNewGdpbTsFull) - << Form("old = %12llu vs new = %12llu ", fulStarTsFullLast, ulNewStarTsFull) - << Form("old = %2u vs new = %2u ", fuStarDaqCmdLast, uNewDaqCmd) - << Form("old = %2u vs new = %2u ", fuStarTrigCmdLast, uNewTrigCmd); -*/ - fulGdpbTsFullLast = ulNewGdpbTsFull; - fulStarTsFullLast = ulNewStarTsFull; - fuStarTokenLast = uNewToken; - fuStarDaqCmdLast = uNewDaqCmd; - fuStarTrigCmdLast = uNewTrigCmd; - - Double_t dTot = 1.; - Double_t dTime = fulGdpbTsFullLast * 6.25; - if( 0. == fdFirstDigiTimeDif && 0. != fdLastDigiTime ) - { - fdFirstDigiTimeDif = dTime - fdLastDigiTime; - LOG(info) << "Default fake digi time shift initialized to " << fdFirstDigiTimeDif; - } // if( 0. == fdFirstDigiTimeDif && 0. != fdLastDigiTime ) - - dTime -= fdFirstDigiTimeDif; - dTime += fdTShiftRef; - - LOG(debug) << "Insert fake digi with time " << dTime << ", Tot " << dTot; - fhRawTRefDig0->Fill( dTime - fdLastDigiTime); - fhRawTRefDig1->Fill( dTime - fdLastDigiTime); - - fDigi = new CbmTofDigi(0x00005006, dTime, dTot); // fake start counter signal - fBuffer->InsertData<CbmTofDigi>(fDigi); - break; - } // case 3 - default: - LOG(fatal) << "Unknown Star Trigger messageindex: " << iMsgIndex; - } // switch( iMsgIndex ) -} - -ClassImp(CbmUnpackTofStar2018) diff --git a/beamtime/star2018/unpacker/CbmUnpackTofStar2018.h b/beamtime/star2018/unpacker/CbmUnpackTofStar2018.h deleted file mode 100644 index d14e3e5f768d31a707f95581e7ae4d1e42025d5f..0000000000000000000000000000000000000000 --- a/beamtime/star2018/unpacker/CbmUnpackTofStar2018.h +++ /dev/null @@ -1,148 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- ----- -// ----- CbmUnpackTofStar2018 ----- -// ----- Created 08.12.2017 by P.-A. Loizeau ----- -// ----- ----- -// ----------------------------------------------------------------------------- - -#ifndef CbmUnpackTofStar2018_H -#define CbmUnpackTofStar2018_H - -#include "Timeslice.hpp" -#include "rocMess_wGet4v1.h" - -#include "CbmTSUnpack.h" -#include "CbmHistManager.h" -#include "CbmTofDigi.h" -#include "CbmTbDaqBuffer.h" - -#include "TClonesArray.h" - -#include <vector> -#include <map> - -class CbmTofUnpackPar; - -class CbmUnpackTofStar2018 : public CbmTSUnpack -{ -public: - - CbmUnpackTofStar2018( UInt_t uNbGdpb = 1 ); - virtual ~CbmUnpackTofStar2018(); - - virtual Bool_t Init(); - - virtual Bool_t DoUnpack(const fles::Timeslice& ts, size_t component); - - virtual void Reset(); - - virtual void Finish(); - - void SetParContainers(); - - Bool_t InitContainers(); - - Bool_t ReInitContainers(); - - - void FillOutput(CbmDigi* digi); - - void SetMsLimitLevel( size_t uAcceptBoundaryPct = 100 ) { fuMsAcceptsPercent = uAcceptBoundaryPct; } - size_t GetMsLimitLevel( ) { return fuMsAcceptsPercent; } - - void SetMsOverlap(size_t uOverlapMsNb = 1) { fuOverlapMsNb = uOverlapMsNb; } - size_t GetMsOverlap() { return fuOverlapMsNb; } - - inline void SetTShiftRef(Double_t val) {fdTShiftRef = val;} - -private: - - size_t fuMsAcceptsPercent; /** Reject Ms with index inside TS above this, assumes 100 MS per TS **/ - size_t fuOverlapMsNb; /** Ignore Overlap Ms: all fuOverlapMsNb MS at the end of timeslice **/ - UInt_t fuMinNbGdpb; - UInt_t fuCurrNbGdpb; - - UInt_t fuNrOfGdpbs; // Total number of GDPBs in the system - UInt_t fuNrOfFebsPerGdpb; // Number of FEBs per GDPB - UInt_t fuNrOfGet4PerFeb; // Number of GET4s per FEB - UInt_t fuNrOfChannelsPerGet4; // Number of channels in each GET4 - - UInt_t fuNrOfChannelsPerFeet; // Number of channels in each FEET - UInt_t fuNrOfGet4; // Total number of Get4 chips in the system - UInt_t fuNrOfGet4PerGdpb; // Number of GET4s per GDPB - UInt_t fuNrOfChannelsPerGdpb; // Number of channels per GDPB - - std::vector<int> fMsgCounter; - std::map<UInt_t, UInt_t> fGdpbIdIndexMap; - - UInt_t fuGdpbId; // Id (hex number) of the GDPB for current message - UInt_t fuGdpbNr; // running number (0 to fNrOfGdpbs) of the GDPB for current message - UInt_t fuGet4Id; // running number (0 to fNrOfGet4PerGdpb) of the Get4 chip of a unique GDPB for current message - UInt_t fuGet4Nr; // running number (0 to fNrOfGet4) of the Get4 chip in the system for current message - - CbmHistManager* fHM; ///< Histogram manager - - /** Current epoch marker for each GDPB and GET4 - * (first epoch in the stream initializes the map item) - * pointer points to an array of size fNrOfGdpbs * fNrOfGet4PerGdpb - * The correct array index is calculated using the function - * GetArrayIndex(gdpbId, get4Id) - **/ - std::vector< ULong64_t > fvulCurrentEpoch; //! - std::vector< Bool_t > fvbFirstEpochSeen; //! - - Int_t fNofEpochs; /** Current epoch marker for each ROC **/ - ULong64_t fulCurrentEpochTime; /** Time stamp of current epoch **/ - - Int_t fEquipmentId; - Double_t fdMsIndex; - Double_t fdTShiftRef; - - TClonesArray* fTofDigi; - CbmTofDigi* fDigi; - - CbmTbDaqBuffer* fBuffer; - - CbmTofUnpackPar* fUnpackPar; //! - - void CreateHistograms(); - - // Variables used for histo filling - Double_t fdRefTime; - Double_t fdLastDigiTime; - Double_t fdFirstDigiTimeDif; - Double_t fdEvTime0; - TH1* fhRawTDigEvT0; - TH1* fhRawTDigRef0; - TH1* fhRawTDigRef; - TH1* fhRawTRefDig0; - TH1* fhRawTRefDig1; - TH1* fhRawDigiLastDigi; - std::vector< TH2* > fhRawTotCh; - std::vector< TH1* > fhChCount; - std::vector< Bool_t > fvbChanThere; - std::vector< TH2* > fhChanCoinc; - Bool_t fbDetChanThere[64]; - TH2* fhDetChanCoinc; - - std::vector< std::vector < ngdpb::Message > > fvmEpSupprBuffer; - - void FillHitInfo(ngdpb::Message); - void FillStarTrigInfo(ngdpb::Message); - void FillEpochInfo(ngdpb::Message); - void PrintSlcInfo(ngdpb::Message); - void PrintSysInfo(ngdpb::Message); - void PrintGenInfo(ngdpb::Message); - - inline Int_t GetArrayIndex(Int_t gdpbId, Int_t get4Id) - { - return gdpbId * fuNrOfGet4PerGdpb + get4Id; - } - - CbmUnpackTofStar2018(const CbmUnpackTofStar2018&); - CbmUnpackTofStar2018 operator=(const CbmUnpackTofStar2018&); - - ClassDef(CbmUnpackTofStar2018, 1) -}; - -#endif diff --git a/beamtime/star2018/unpacker/rocMess_wGet4v2.cxx b/beamtime/star2018/unpacker/rocMess_wGet4v2.cxx deleted file mode 100644 index b08e3d43550f09dcc0ff1ac10efffdbe01b5e959..0000000000000000000000000000000000000000 --- a/beamtime/star2018/unpacker/rocMess_wGet4v2.cxx +++ /dev/null @@ -1,590 +0,0 @@ -#include "rocMess_wGet4v2.h" - -// Specific headers -#include "CbmFormatDecHexPrintout.h" - -// C++11 headers -#include <cmath> - -// std C++ lib headers -#include <stdio.h> -#include <string.h> - -//#include <iostream> -#include <iomanip> - -//---------------------------------------------------------------------------- -//! strict weak ordering operator, assumes same epoch for both messages -bool gdpb::Message::operator<(const gdpb::Message& other) const -{ - uint64_t uThisTs = 0; - uint64_t uOtherTs = 0; - - uint32_t uThisType = this->getMessageType(); - uint32_t uOtherType = other.getMessageType(); - - // if both GET4 hit messages, use the full timestamp info - if( (MSG_GET4_32B == uThisType || MSG_GET4 == uThisType )&& - (MSG_GET4_32B == uOtherType || MSG_GET4 == uOtherType ) ) - { - uThisTs = this->getGdpbHitFullTs(); - uOtherTs = other.getGdpbHitFullTs(); - return uThisTs < uOtherTs; - } // both GET4 hit (32b or 24b) - - // First find the timestamp of the current message - if( MSG_GET4_32B == uThisType || MSG_GET4 == uThisType ) - { - uThisTs = ( this->getGdpbHitFullTs() ) / 20 + 512; - } // if Hit GET4 message (24 or 32b) - else if( MSG_GET4_SLC == uThisType || MSG_GET4_SYS == uThisType ) - { - uThisTs = 0; - } // if SLC or SYS GET4 message - else uThisTs = this->getMsgFullTime( 0 ); - - // Then find the timestamp of the current message - if( MSG_GET4_32B == uOtherType || MSG_GET4 == uOtherType ) - { - uOtherTs = ( this->getGdpbHitFullTs() ) / 20 + 512; - } // if Hit GET4 message (24 or 32b) - else if( MSG_GET4_SLC == uOtherType || MSG_GET4_SYS == uOtherType ) - { - uOtherTs = 0; - } // if SLC or SYS GET4 message - else uOtherTs = other.getMsgFullTime( 0 ); - - return uThisTs < uOtherTs; -} -//---------------------------------------------------------------------------- -//! Returns expanded and adjusted time of message (in ns) -//! epoch should correspond to the message type - epoch2 for Get4, epoch for all others -//! With the DPBs, both GET4 and nXYTER systems operate at the same frequency of 160MHz. -//! When converting from GET4 to nXYTER clocks, one should take into account -//! that initial value of nDPB timestamp counter is 0x80 or 512 ns. Therefore such offset -//! should be applied during conversion => Is it really true? nXYTER or nDPB effect? -//! =====> see '///' lines -uint64_t gdpb::Message::getMsgFullTime(uint64_t epoch) const -{ - return std::round( getMsgFullTimeD( epoch ) ); -} -//---------------------------------------------------------------------------- -//! Returns expanded and adjusted time of message in double (in ns) -//! epoch should correspond to the message type - epoch2 for Get4, epoch for all others -//! Harcoded constants should be implemented better as soon as their value is fixed -double gdpb::Message::getMsgFullTimeD(uint64_t epoch) const -{ - switch( getMessageType() ) - { - case MSG_EPOCH2: - return get4v2x::kdEpochInNs * static_cast<double_t>( getEpoch2Number() ); - case MSG_GET4: - return ( static_cast<double_t>(FullTimeStamp2(epoch, (getGdpbHitCoarse() << 7))) + ( static_cast<double_t>(getGdpbHitFineTs() - 8. ) * 128. /112.) ) - * (6.25 / 128.); /// TODO: hardcoded -> constant values!! - case MSG_SYS: -// if( SYSMSG_GET4_EVENT == getGdpbSysSubType() ) - return get4v2x::kdEpochInNs * static_cast<double_t>( epoch ); // Use epoch period of TOF!! - case MSG_GET4_32B: - return ( get4v2x::kdEpochInNs * static_cast<double_t>( epoch ) + static_cast<double_t>( getGdpbHitFullTs() ) * get4v2x::kdClockCycleSizeNs / 112. ); - case MSG_GET4_SLC: - case MSG_GET4_SYS: - return FullTimeStamp2(epoch, 0) * (6.25 / 128.); - default: - return 0.0; - } // switch( getMessageType() ) - - // If not already dealt with => unknown type - return 0.0; -} -//---------------------------------------------------------------------------- -//---------------------------------------------------------------------------- -//! Returns the time difference between two expanded time stamps - -uint64_t gdpb::Message::CalcDistance(uint64_t start, uint64_t stop) -{ - if (start>stop) { - stop += 0x3FFFFFFFFFFFLLU; - if (start>stop) { - printf("Epochs overflow error in CalcDistance\n"); - return 0; - } - } - - return stop - start; -} - - -//---------------------------------------------------------------------------- -//! Returns the time difference between two expanded time stamps - -double gdpb::Message::CalcDistanceD(double start, double stop) -{ - if (start>stop) { - stop += 0x3FFFFFFFFFFFLLU; - if (start>stop) { - printf("Epochs overflow error in CalcDistanceD\n"); - return 0.; - } - } - - return stop - start; -} - - - -//---------------------------------------------------------------------------- -//! Print message in human readable format to \a cout. -/*! - * Prints a one line representation of the message in to \a cout. - * See printData(std::ostream&, unsigned, uint32_t) const for full - * documentation. - */ - -void gdpb::Message::printDataCout(unsigned kind, uint32_t epoch) const -{ - printData(msg_print_Cout, kind, epoch); -} - -//---------------------------------------------------------------------------- -//! Print message in human readable format to the Fairroot logger. -/*! - * Prints a one line representation of the message in to the Fairroot logger. - * TODO: Add coloring of possible - * See printData(std::ostream&, unsigned, uint32_t) const for full - * documentation. - */ - -void gdpb::Message::printDataLog(unsigned kind, uint32_t epoch) const -{ - printData(msg_print_FairLog, kind, epoch); -} - -//---------------------------------------------------------------------------- -//! Print message in binary or human readable format to a stream. -/*! - * Prints a one line representation of the message in to a stream, selected by \a outType. - * The stream is \a cout if \a outType is kFALSE and \a FairLogger if \a outType is kTRUE. - * The parameter \a kind is mask with 4 bits - * \li gdpb::msg_print_Prefix (1) - ROC number and message type - * \li gdpb::msg_print_Data (2) - print all message specific data fields - * \li gdpb::msg_print_Hex (4) - print data as hex dump - * \li gdpb::msg_print_Human (8) - print in human readable format - * - * If bit msg_print_Human in \a kind is not set, raw format - * output is generated. All data fields are shown in hexadecimal. - * This is the format of choice when chasing hardware problems at the bit level. - * - * If bit msg_print_Human is set, a more human readable output is generated. - * The timestamp is shown as fully extended and adjusted time as - * returned by the getMsgFullTime(uint32_t) const method. - * All data fields are represented in decimal. - * - * \param os output stream - * \param kind mask determing output format - * \param epoch current epoch number (from last epoch message) - * - * Typical message output in human format looks like -\verbatim -Msg:7 Roc:1 SysType: 1 Nx:0 Data: 0 : DAQ started -Msg:7 Roc:1 SysType: 6 Nx:0 Data: 0 : FIFO reset -Msg:2 Roc:1 EPO @ 0.536870912 Epo: 32768 0x00008000 Miss: 0 -Msg:0 Roc:0 NOP (raw 80:40:82:0F:00:00) -Msg:2 Roc:1 EPO @ 0.646627328 Epo: 39467 0x00009a2b Miss: 0 -Msg:1 Roc:1 HIT @ 0.646614333 Nx:2 Chn: 12 Ts: 3389-e( 8) Adc:2726 Pu:0 Of:0 -Msg:1 Roc:1 HIT @ 0.646630717 Nx:2 Chn: 13 Ts: 3389 ( 0) Adc:2745 Pu:0 Of:0 -Msg:2 Roc:1 EPO @ 0.805306368 Epo: 49152 0x0000c000 Miss: 0 -Msg:3 Roc:1 SYN @ 0.805306408 Chn:2 Ts: 40 Data: 49152 0x00c000 Flag:0 -Msg:7 Roc:1 SysType: 2 Nx:0 Data: 0 : DAQ finished -\endverbatim - * - * Typical message output in binary format looks like -\verbatim -Msg:7 Roc:1 SysType: 1 Nx:0 Data: 0 : DAQ started -Msg:7 Roc:1 SysType: 6 Nx:0 Data: 0 : FIFO reset -Msg:2 Roc:1 Epoch:00008000 Missed:00 -Msg:1 Roc:1 Nx:2 Chn:0d Ts:3ec9 Last:1 Msb:7 Adc:a22 Pup:0 Oflw:0 -Msg:1 Roc:1 Nx:2 Chn:0e Ts:3ec9 Last:0 Msb:7 Adc:a18 Pup:0 Oflw:0 -Msg:0 Roc:0 NOP (raw 80:40:82:0F:00:00) -Msg:2 Roc:1 Epoch:00010000 Missed:00 -Msg:3 Roc:1 SyncChn:2 EpochLSB:0 Ts:0028 Data:010000 Flag:0 -Msg:7 Roc:1 SysType: 2 Nx:0 Data: 0 : DAQ finished -\endverbatim - */ - -//void gdpb::Message::printData(std::ostream& os, unsigned kind, uint32_t epoch) const -void gdpb::Message::printData(unsigned outType, unsigned kind, uint32_t epoch, std::ostream& os) const -{ - char buf[256]; - if (kind & msg_print_Hex) { - const uint8_t* arr = reinterpret_cast<const uint8_t*> ( &data ); - snprintf(buf, sizeof(buf), "BE= %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X LE= %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X ", - arr[0], arr[1], arr[2], arr[3], arr[4], arr[5], arr[6], arr[7], - arr[7], arr[6], arr[5], arr[4], arr[3], arr[2], arr[1], arr[0] ); -// os << buf; - if( msg_print_Cout == outType) - std::cout << buf; - else if( msg_print_File == outType ) - os << buf; - - snprintf(buf, sizeof(buf), " "); - } - - if (kind & msg_print_Human) { - double timeInSec = getMsgFullTimeD(epoch)/1.e9; -// int fifoFill = 0; - - switch (getMessageType()) { - case MSG_EPOCH2: - snprintf(buf, sizeof(buf), - "Msg:%u Roc:%04x ", getMessageType(), getRocNumber()); -// os << buf; - if( msg_print_Cout == outType) - std::cout << buf; - else if( msg_print_File == outType ) - os << buf; - - snprintf(buf, sizeof(buf), - "EPO2 @%17.11f Get4:%2d Epoche2:%10u 0x%08x StampTime:%2d Sync:%x Dataloss:%x Epochloss:%x Epochmissmatch:%x", - timeInSec, getEpoch2ChipNumber(), getEpoch2Number(), getEpoch2Number(), - getEpoch2StampTime(), getEpoch2Sync(), getEpoch2DataLost(), getEpoch2EpochLost(), getEpoch2EpochMissmatch()); -// os << buf << std::endl; - if( msg_print_Cout == outType) - std::cout << buf << std::endl; - else if( msg_print_File == outType ) - os << buf << std::endl; - break; - case MSG_GET4: - snprintf(buf, sizeof(buf), - "Msg:%u Roc:%04x ", getMessageType(), getRocNumber()); -// os << buf; - if( msg_print_Cout == outType) - std::cout << buf; - else if( msg_print_File == outType ) - os << buf; - - snprintf(buf, sizeof(buf), - "Get4 @%17.11f Get4:%2d Chn:%3d Edge:%1d Ts:%7d CRC8:%3d", - timeInSec, getGet4Number(), getGet4ChNum(), getGet4Edge(), getGet4Ts(), getGet4CRC() ); -// os << buf << std::endl; - if( msg_print_Cout == outType) - std::cout << buf << std::endl; - else if( msg_print_File == outType ) - os << buf << std::endl; - break; - default: - kind = kind & ~msg_print_Human; - if (kind==0) kind = msg_print_Prefix | msg_print_Data; - } - - // return, if message was correctly printed in human-readable form - if (kind & msg_print_Human) return; - } - - if (kind & msg_print_Prefix) { - snprintf(buf, sizeof(buf), "Msg:%2u Roc:%04x ", getMessageType(), getRocNumber()); -// os << buf; - if( msg_print_Cout == outType) - std::cout << buf; - else if( msg_print_File == outType ) - os << buf; - } - - if (kind & msg_print_Data) { - const uint8_t* arr = reinterpret_cast<const uint8_t*> ( &data ); - switch (getMessageType()) { - case MSG_NOP: - snprintf(buf, sizeof(buf), "NOP (raw %02X:%02X:%02X:%02X:%02X:%02X)", - arr[0], arr[1], arr[2], arr[3], arr[4], arr[5]); - break; - case MSG_EPOCH2: - snprintf(buf, sizeof(buf), "Get4:0x%02x Link: %1u Epoche2:0x%08x StampTime:0x%x Sync:%x Dataloss:%x Epochloss:%x Epochmissmatch:%x", - getGdpbGenChipId(), getGdpbEpLinkId(), getGdpbEpEpochNb(), getGdpbEpStampTs(), getGdpbEpSync(), - getGdpbEpDataLoss(), getGdpbEpEpochLoss(), getGdpbEpMissmatch()); - break; - case MSG_GET4: - snprintf(buf, sizeof(buf), "Get4:0x%02x Chn:%1x Edge:%1x Ts:0x%05x CRC8:0x%02x", - getGdpbGenChipId(), getGdpbHitChanId(), getGdpbHit24Edge(), getGdpbHitFullTs(), getGdpbHitCrc() ); - break; - case MSG_SYS: { - char sysbuf[256]; - - switch (getSysMesType()) { - case SYSMSG_DAQ_START: - snprintf(sysbuf, sizeof(sysbuf), "DAQ started"); - break; - case SYSMSG_DAQ_FINISH: - snprintf(sysbuf, sizeof(sysbuf), "DAQ finished"); - break; - case SYSMSG_SYNC_PARITY: - snprintf(sysbuf, sizeof(sysbuf), "SYNC parity error "); - break; - case SYSMSG_DAQ_RESUME: - snprintf(sysbuf, sizeof(sysbuf), "DAQ resume after high/low water"); - break; - case SYSMSG_FIFO_RESET: - snprintf(sysbuf, sizeof(sysbuf), "FIFO reset"); - break; - case SYSMSG_USER: { - const char* subtyp = ""; - if (getSysMesData()==SYSMSG_USER_CALIBR_ON) subtyp = "Calibration ON"; else - if (getSysMesData()==SYSMSG_USER_CALIBR_OFF) subtyp = "Calibration OFF"; else - if (getSysMesData()==SYSMSG_USER_RECONFIGURE) subtyp = "Reconfigure"; - snprintf(sysbuf, sizeof(sysbuf), "User message 0x%08x %s", getSysMesData(), subtyp); - break; - } - case SYSMSG_PACKETLOST: - snprintf(sysbuf, sizeof(sysbuf), "Packet lost"); - break; - case SYSMSG_GET4_EVENT: - { - break; - } // - case SYSMSG_CLOSYSYNC_ERROR: - snprintf(sysbuf, sizeof(sysbuf), "Closy synchronization error"); - break; - case SYSMSG_TS156_SYNC: - snprintf(sysbuf, sizeof(sysbuf), "156.25MHz timestamp reset"); - break; - case SYSMSG_GET4V1_32BIT_0: - case SYSMSG_GET4V1_32BIT_1: - case SYSMSG_GET4V1_32BIT_2: - case SYSMSG_GET4V1_32BIT_3: - case SYSMSG_GET4V1_32BIT_4: - case SYSMSG_GET4V1_32BIT_5: - case SYSMSG_GET4V1_32BIT_6: - case SYSMSG_GET4V1_32BIT_7: - case SYSMSG_GET4V1_32BIT_8: - case SYSMSG_GET4V1_32BIT_9: - case SYSMSG_GET4V1_32BIT_10: - case SYSMSG_GET4V1_32BIT_11: - case SYSMSG_GET4V1_32BIT_12: - case SYSMSG_GET4V1_32BIT_13: - case SYSMSG_GET4V1_32BIT_14: - case SYSMSG_GET4V1_32BIT_15: - { - break; - } // case SYSMSG_GET4V1_32BIT + channel! - default: - snprintf(sysbuf, sizeof(sysbuf), "unknown system message type "); - } // switch (getSysMesType()) - - snprintf(buf, sizeof(buf), "SysType:%2x Data:%8x : %s", getSysMesType(), getSysMesData(), sysbuf); - - break; - } // case MSG_SYS: - case MSG_GET4_SLC: - { - // GET4 slow control message, new "true" ROC support - snprintf(buf, sizeof(buf), - "Get4 Slow control, chip %02d => Chan:%01d Edge:%01d Type:%01x Data:0x%06x CRC:0x%02x", - getGdpbGenChipId(), 0x0, 0x0, 0x0, getGdpbSlcData(), getGdpbSlcCrc() ); - break; - } // case MSG_GET4_SLC: - case MSG_GET4_32B: - { - // 32b GET4 data event, new "true" ROC support - snprintf(buf, sizeof(buf), - "Get4 32 bits, Chip:0x%02x Dll %1d Channel %1d Ts:0x%03x Ft:0x%02x Tot:0x%02x", - getGdpbGenChipId(), getGdpbHit32DllLck(), getGdpbHitChanId(), - getGdpbHitCoarse(), getGdpbHitFineTs(), getGdpbHit32Tot() ); - - break; - } // case MSG_GET4_32B: - case MSG_GET4_SYS: - { - // GET4 system message, new "true" ROC support - char sysbuf[256]; - - switch( getGdpbSysSubType() ) - { - case SYSMSG_GET4_EVENT: - { - snprintf(sysbuf, sizeof(sysbuf), - "Get4:0x%02x Ch:0x%01x Edge:%01x Unused:%06x ErrCode:0x%02x - GET4 V1 Error Event", - getGdpbGenChipId(), getGdpbSysErrChanId(), getGdpbSysErrEdge(), getGdpbSysErrUnused(), getGdpbSysErrData()); - break; - } // - case SYSMSG_CLOSYSYNC_ERROR: - snprintf(sysbuf, sizeof(sysbuf), "Closy synchronization error"); - break; - case SYSMSG_TS156_SYNC: - snprintf(sysbuf, sizeof(sysbuf), "156.25MHz timestamp reset"); - break; - case SYSMSG_GDPB_UNKWN: - snprintf(sysbuf, sizeof(sysbuf), "Unknown GET4 message, data: 0x%08x", getGdpbSysUnkwData()); - break; - default: - snprintf(sysbuf, sizeof(sysbuf), "unknown system message type %u", getGdpbSysSubType()); - } // switch( getGdpbSysSubType() ) - snprintf(buf, sizeof(buf), "%s", sysbuf); - - break; - } // case MSG_GET4_SYS: - case MSG_STAR_TRI: - { - // STAR trigger token, spread over 4 messages - switch( getStarTrigMsgIndex() ) - { - case 0: - { - snprintf(buf, sizeof(buf), -// "STAR token A, gDPB TS MSB bits: 0x%010llx000000", -// getGdpbTsMsbStarA() ); - "STAR token A, gDPB TS MSB bits: 0x%s000000", - FormatHexPrintout( getGdpbTsMsbStarA(), 10, '0').c_str() ); - break; - } // case 1st message: - case 1: - { - snprintf(buf, sizeof(buf), -// "STAR token B, gDPB TS LSB bits: 0x0000000000%06llx, STAR TS MSB bits: 0x%04llx000000000000", -// getGdpbTsLsbStarB(), getStarTsMsbStarB() ); - "STAR token B, gDPB TS LSB bits: 0x0000000000%s, STAR TS MSB bits: 0x%s000000000000", - FormatHexPrintout( getGdpbTsLsbStarB(), 6, '0').c_str(), FormatHexPrintout( getStarTsMsbStarB(), 4, '0').c_str() ); - break; - } // case 2nd message: - case 2: - { - snprintf(buf, sizeof(buf), -// "STAR token C, , STAR TS Mid bits: 0x0000%010llx00", -// getStarTsMidStarC() ); - "STAR token C, , STAR TS Mid bits: 0x0000%s00", - FormatHexPrintout( getStarTsMidStarC(), 10, '0').c_str() ); - break; - } // case 3rd message: - case 3: - { - snprintf(buf, sizeof(buf), -// "STAR token D, , STAR TS LSB bits: 0x00000000000000%02llx" - "STAR token D, , STAR TS LSB bits: 0x00000000000000%s" - ", Token: %03x, DAQ: %1x; TRG:%1x", -// getStarTsLsbStarD(), - FormatHexPrintout( getStarTsLsbStarD(), 2, '0').c_str(), - getStarTokenStarD(), getStarDaqCmdStarD(), getStarTrigCmdStarD() ); - break; - } // case 4th message: - } // switch( getStarTrigMsgIndex() ) - - break; - } // case MSG_STAR_TRI: - default: - snprintf(buf, sizeof(buf), "Error - unexpected MessageType: %1x, full data %08X::%08X", - getMessageType(), getField(32, 32), getField(0, 32) ); - } - } - -// os << buf << std::endl; - if( msg_print_Cout == outType) - std::cout << buf << std::endl; - else if( msg_print_File == outType ) - os << buf << std::endl; -// else os << sLogBuff << buf << std::endl; -} - -uint32_t gdpb::Message::RawSize(int fmt) -{ - switch (fmt) { - case formatNormal: return 8; - default: - std::cerr << "gdpb::Message::RawSize => " - << " Deprecated format, nothing done!!" - << std::endl; - return 0; - } - return 8; -} - -bool gdpb::Message::assign(void* src, int fmt) -{ - switch (fmt) { - case formatNormal: - memcpy(&data, src, 8); - return true; - default: - std::cerr << "gdpb::Message::assign => " - << " Deprecated format, nothing done!!" - << std::endl; - return false; - } - - return false; -} - -bool gdpb::Message::copyto(void* tgt, int fmt) -{ - switch (fmt) { - case formatNormal: - memcpy(tgt, &data, 8); - return true; - default: - std::cerr << "gdpb::Message::assign => " - << " Deprecated format, nothing done!!" - << std::endl; - return false; - } - - return false; - -} - -/* -double gdpb::Message::CalcGet4V10R24HitTimeDiff( - uint32_t epochA, uint32_t epochB, Message& messB) -{ - Double_t dTimeDiff = 0.0; - // if conditions needed to deal with unsigned int at full resolution - if( epochA < epochB) - dTimeDiff -= - ( epochB - epochA )*get4v2x::kdEpochInPs; - else dTimeDiff += - ( epochA - epochB )*get4v2x::kdEpochInPs; - // if conditions needed to deal with unsigned int at full resolution - if( this->getGet4Ts() < messB.getGet4Ts() ) - dTimeDiff -= - ( messB.getGet4Ts() - this->getGet4Ts() - )*get4v2x::kdBinSize; - else dTimeDiff += - ( this->getGet4Ts() - messB.getGet4Ts() - )*get4v2x::kdBinSize; - - return dTimeDiff; -} - -double gdpb::Message::CalcGet4V10R32HitTimeDiff( - uint32_t epochA, uint32_t epochB, Message& messB) -{ - Double_t dTimeDiff = 0.0; - // if conditions needed to deal with unsigned int at full resolution - if( epochA < epochB) - dTimeDiff -= - ( epochB - epochA )*get4v2x::kdEpochInPs; - else dTimeDiff += - ( epochA - epochB )*get4v2x::kdEpochInPs; - // if conditions needed to deal with unsigned int at full resolution - if( this->getGet4V10R32HitTimeBin() < messB.getGet4V10R32HitTimeBin() ) - dTimeDiff -= - ( messB.getGet4V10R32HitTimeBin() - this->getGet4V10R32HitTimeBin() - )*get4v2x::kdBinSize; - else dTimeDiff += - ( this->getGet4V10R32HitTimeBin() - messB.getGet4V10R32HitTimeBin() - )*get4v2x::kdBinSize; - - return dTimeDiff; -} -*/ -//---------------------------------------------------------------------------- -//! strict weak ordering operator, including epoch for both messages -bool gdpb::FullMessage::operator<(const FullMessage& other) const -{ - if( other.fulExtendedEpoch == this->fulExtendedEpoch ) - // Same epoch => use Message (base) class ordering operator - return this->Message::operator<( other ); - else return this->fulExtendedEpoch < other.fulExtendedEpoch; - -} -//---------------------------------------------------------------------------- -void gdpb::FullMessage::PrintMessage( unsigned outType, unsigned kind) const -{ - std::cout << "Full epoch = " << std::setw(9) << fulExtendedEpoch << " "; - printDataCout( outType, kind ); -} diff --git a/beamtime/star2018/unpacker/rocMess_wGet4v2.h b/beamtime/star2018/unpacker/rocMess_wGet4v2.h deleted file mode 100644 index 397c84063244993d2155dd29cda6b3e2a46469d4..0000000000000000000000000000000000000000 --- a/beamtime/star2018/unpacker/rocMess_wGet4v2.h +++ /dev/null @@ -1,521 +0,0 @@ -#ifndef ROC_MESS_WGET4V2X_DEF_H -#define ROC_MESS_WGET4V2X_DEF_H - -#include <stdint.h> -#include <iostream> - -namespace get4v2x { - // Size of one clock cycle (=1 coarse bin) - const double kdClockCycleSize = 6250.0; //[ps] - const double kdClockCycleSizeNs = kdClockCycleSize / 1000.0; //[ns] - // TODO:For now make 100ps default, maybe need later an option for it - const double kdTotBinSize = 50.0; //ps - - const uint32_t kuFineTime = 0x0000007F; // Fine Counter value - const uint32_t kuFtShift = 0; // Fine Counter offset - const uint32_t kuCoarseTime = 0x0007FF80; // Coarse Counter value - const uint32_t kuCtShift = 7; // Coarse Counter offset - const uint32_t kuCtSize = 12; // Coarse Counter size in bits - - const uint32_t kuFineCounterSize = ( (kuFineTime>>kuFtShift)+1 ); - const uint32_t kuCoarseCounterSize = ( (kuCoarseTime>>kuCtShift)+1 ); - const uint32_t kuCoarseOverflowTest = kuCoarseCounterSize / 2 ; // Limit for overflow check - const uint32_t kuTotCounterSize = 256; - - // Nominal bin size of NL are neglected - const double kdBinSize = kdClockCycleSize / static_cast<double>(kuFineCounterSize); - // Epoch Size in bins - const uint32_t kuEpochInBins = kuFineTime + kuCoarseTime + 1; - // Epoch Size in ps - // alternatively: (kiCoarseTime>>kiCtShift + 1)*kdClockCycleSize - const double kdEpochInPs = static_cast<double>(kuEpochInBins)*kdBinSize; - const double kdEpochInNs = kdEpochInPs / 1000.0; - - // Epoch counter size in epoch - const uint32_t kuEpochCounterSz = 0x7FFFFFFF; - const double kdEpochCycleInS = static_cast<double>(kuEpochCounterSz) * (kdEpochInNs/1e9); - - const uint32_t kuChipIdMergedEpoch = 63; // 0x3F - - const uint32_t kuFeePulserChannel = 3; // Channel where a pulser can be set ON at 20 ns 500 Hz -} - -namespace gdpb { - - - enum MessageFormat { - formatNormal = 4 // new message format with little-endian coding, 16-bit roc number (default) - }; - - enum MessageTypes { - MSG_NOP = 0, - MSG_HIT = 1, - MSG_EPOCH = 2, - MSG_SYNC = 3, - MSG_AUX = 4, - MSG_EPOCH2 = 5, - MSG_GET4 = 6, - MSG_SYS = 7, - MSG_GET4_SLC = 8, - MSG_GET4_32B = 9, - MSG_GET4_SYS = 10, - MSG_STAR_TRI = 0xD - }; - - enum SysMessageTypes { - SYSMSG_DAQ_START = 1, // indicates start daq in data stream - SYSMSG_DAQ_FINISH = 2, // stop daq - SYSMSG_NX_PARITY = 3, // nx_parity error - SYSMSG_SYNC_PARITY = 4, // sync parity error - SYSMSG_DAQ_RESUME = 5, // daq resume due to low/high water marker, only in udp case - SYSMSG_FIFO_RESET = 6, // FPGA fifo reset - SYSMSG_USER = 7, // user define message, generated by writing into ROC_ADDSYSMSG register - SYSMSG_PCTIME = 8, // contains value of time() function, indicates when message was created on PC - SYSMSG_ADC = 9, // contains feb1d (1 bit), channel id (7 bit) and adc value (24 bit), measured on PC - SYSMSG_PACKETLOST = 10, // inserted by udp transport when packet was lost at this place - SYSMSG_GET4_EVENT = 11, // GET4 event - SYSMSG_CLOSYSYNC_ERROR = 12, // added to data stream when the closy-sync-strobe does not match the rocs 156MHz timestamp counter - SYSMSG_TS156_SYNC = 13, // added when 156MHz timestamp counter is reset by a DLM - SYSMSG_GDPB_UNKWN = 15, // Raw data from gDPB in case of unknown message type from GET4 - SYSMSG_GET4V1_32BIT_0 = 240, // Get4 V1.0, 32bit mode, Raw messages - SYSMSG_GET4V1_32BIT_1 = 241, // Get4 V1.0, 32bit mode, Raw messages - SYSMSG_GET4V1_32BIT_2 = 242, // Get4 V1.0, 32bit mode, Raw messages - SYSMSG_GET4V1_32BIT_3 = 243, // Get4 V1.0, 32bit mode, Raw messages - SYSMSG_GET4V1_32BIT_4 = 244, // Get4 V1.0, 32bit mode, Raw messages - SYSMSG_GET4V1_32BIT_5 = 245, // Get4 V1.0, 32bit mode, Raw messages - SYSMSG_GET4V1_32BIT_6 = 246, // Get4 V1.0, 32bit mode, Raw messages - SYSMSG_GET4V1_32BIT_7 = 247, // Get4 V1.0, 32bit mode, Raw messages - SYSMSG_GET4V1_32BIT_8 = 248, // Get4 V1.0, 32bit mode, Raw messages - SYSMSG_GET4V1_32BIT_9 = 249, // Get4 V1.0, 32bit mode, Raw messages - SYSMSG_GET4V1_32BIT_10 = 250, // Get4 V1.0, 32bit mode, Raw messages - SYSMSG_GET4V1_32BIT_11 = 251, // Get4 V1.0, 32bit mode, Raw messages - SYSMSG_GET4V1_32BIT_12 = 252, // Get4 V1.0, 32bit mode, Raw messages - SYSMSG_GET4V1_32BIT_13 = 253, // Get4 V1.0, 32bit mode, Raw messages - SYSMSG_GET4V1_32BIT_14 = 254, // Get4 V1.0, 32bit mode, Raw messages - SYSMSG_GET4V1_32BIT_15 = 255, // Get4 V1.0, 32bit mode, Raw messages - }; - - enum SysMessageUserTypes { - SYSMSG_USER_CALIBR_ON = 7, - SYSMSG_USER_CALIBR_OFF = 8, - SYSMSG_USER_RECONFIGURE = 9, - SYSMSG_USER_ROCFEET_SYNC = 16 - }; - - enum MessagePrintMask { - msg_print_Prefix = 1, - msg_print_Data = 2, - msg_print_Hex = 4, - msg_print_Human = 8 - }; - - enum MessagePrintType { - msg_print_Cout = 1, - msg_print_FairLog = 2, - msg_print_File = 3 - }; - - enum Get4Message32bTypes { - GET4_32B_EPOCH = 0, - GET4_32B_SLCM = 1, - GET4_32B_ERROR = 2, - GET4_32B_DATA = 3 - }; - - enum Get4Message32bSlC { - GET4_32B_SLC_SCALER = 0, - GET4_32B_SLC_DEADT = 1, - GET4_32B_SLC_SPIREAD = 2, - GET4_32B_SLC_START_SEU = 3 - }; - - enum Get4Message32bErrors { - GET4_V2X_ERR_READ_INIT = 0x00, - GET4_V2X_ERR_SYNC = 0x01, - GET4_V2X_ERR_EP_CNT_SYNC = 0x02, - GET4_V2X_ERR_EP = 0x03, - GET4_V2X_ERR_FIFO_WRITE = 0x04, - GET4_V2X_ERR_LOST_EVT = 0x05, - GET4_V2X_ERR_CHAN_STATE = 0x06, - GET4_V2X_ERR_TOK_RING_ST = 0x07, - GET4_V2X_ERR_TOKEN = 0x08, - GET4_V2X_ERR_READOUT_ERR = 0x09, - GET4_V2X_ERR_SPI = 0x0A, - GET4_V2X_ERR_DLL_LOCK = 0x0B, - GET4_V2X_ERR_DLL_RESET = 0x0C, - GET4_V2X_ERR_TOT_OVERWRT = 0x11, - GET4_V2X_ERR_TOT_RANGE = 0x12, - GET4_V2X_ERR_EVT_DISCARD = 0x13, - GET4_V2X_ERR_ADD_RIS_EDG = 0x14, - GET4_V2X_ERR_UNPAIR_FALL = 0x15, - GET4_V2X_ERR_SEQUENCE_ER = 0x16, - GET4_V2X_ERR_UNKNOWN = 0x7F - }; - - // Max nb of each external trigger signal type - const uint32_t kuMaxSync = 2; // <- MAX_SYNC - const uint32_t kuMaxAux = 4; // <- MAX_AUX - - class Message { - - protected: - uint64_t data; // main and only storage field for the message - - public: - Message() : data(0) {} - - Message(const Message& src) : data(src.data) {} - - Message( uint64_t dataIn ) : data(dataIn) {} - - virtual ~Message() {}; - - void assign(const Message& src) { data = src.data; } - - Message& operator=(const Message& src) { assign(src); return *this; } - - inline void reset() { data = 0; } - - inline uint64_t getData() const { return data; } - inline void setData( uint64_t value) { data = value; } - - inline uint64_t getFieldLong(uint32_t shift, uint32_t len) const - { return (data >> shift) & (((static_cast<uint64_t>(1)) << len) - 1); } - - inline uint32_t getField(uint32_t shift, uint32_t len) const - { return (data >> shift) & (((static_cast<uint32_t>(1)) << len) - 1); } - - inline void setField(uint32_t shift, uint32_t len, uint32_t value) - { uint64_t mask = (((static_cast<uint64_t>(1)) << len) - 1); - data = (data & ~(mask << shift)) | ((static_cast<uint64_t>(value) & mask) << shift); } - - inline void setFieldLong(uint32_t shift, uint32_t len, uint64_t value) - { uint64_t mask = (((static_cast<uint64_t>(1)) << len) - 1); - data = (data & ~(mask << shift)) | ((value & mask ) << shift); } - - inline uint8_t getBit(uint32_t shift) const - { return (data >> shift) & 1; } - - inline void setBit(uint32_t shift, uint8_t value) - { data = value ? (data | ((static_cast<uint64_t>(1)) << shift)) : (data & ~((static_cast<uint64_t>(1)) << shift)) ; } - - - inline uint32_t getFieldBE(uint32_t shift, uint32_t len) const - { return (dataBE() >> shift) & (((static_cast<uint32_t>(1)) << len) - 1); } - inline uint8_t getBitBE(uint32_t shift) const - { return (dataBE() >> shift) & 1; } - inline uint64_t dataBE() const - { return ((data&0x00000000000000FF)<<56)+ - ((data&0x000000000000FF00)<<40)+ - ((data&0x0000000000FF0000)<<24)+ - ((data&0x00000000FF000000)<< 8)+ - ((data>> 8)&0x00000000FF000000)+ - ((data>>24)&0x0000000000FF0000)+ - ((data>>40)&0x000000000000FF00)+ - ((data>>56)&0x00000000000000FF); - } - - // --------------------------- common fields --------------------------------- - - //! Returns the message type. Valid for all message types. 4 bit - inline uint8_t getMessageType() const { return getField(0, 4); } - - //! Returns the number of the sending ROC. Valid for all message types. - /*! - * The field has full 16 bits and allows to aggregate data of up to 64K ROC's - * in one message stream. - */ - inline uint16_t getRocNumber() const { return getField(48, 16); } - - //! Sets the message type field in the current message - inline void setMessageType(uint8_t v) { setField(0, 4, v); } - - //! Sets the ROC number field in the current message - inline void setRocNumber(uint16_t v) { setField(48, 16, v); } - - // ---------- Epoch2 marker access methods ------------ - - //! For Epoch2 data: Returns epoch missmatch flag (set in ROC when - //! ROC timestamp and timestamp send by GET4 did not match) (1 bit field) - inline uint32_t getEpoch2EpochMissmatch() const { return getBit(4); } - - //! For Epoch2 data: Returns epoch-lost flag (1 bit field) - inline uint32_t getEpoch2EpochLost() const { return getBit(5); } - - //! For Epoch2 data: Returns data-lost flag (1 bit field) - inline uint32_t getEpoch2DataLost() const { return getBit(6); } - - //! For Epoch2 data: Returns sync flag (1 bit field) - inline uint32_t getEpoch2Sync() const { return getBit(7); } - - //! For Epoch2 data: Returns the LTS156 bits 11 to 8. This - //! gives information at what time in the Epoche the epoche number - //! was set (2 bit field) - inline uint32_t getEpoch2StampTime() const { return getField(8, 2); } - - //! For Epoch2 data: Returns the epoch number (32 bit field) - // on some machines 32-bit field is not working - inline uint32_t getEpoch2Number() const { return (data >> 10) & 0xFFFFFFFF; } - - //! For Epoch2 data: Returns the number of the GET4 chip that send - //! the epoche message (6 bit field) - inline uint32_t getEpoch2ChipNumber() const { return getField(42, 6); } - - //! For Epoch2 data: Set epoch missmatch flag (1 bit field) - inline void setEpoch2EpochMissmatch(uint32_t v) { setBit(4, v); } - - //! For Epoch2 data: Set epoch-lost flag (1 bit field) - inline void setEpoch2EpochLost(uint32_t v) { setBit(5, v); } - - //! For Epoch2 data: Set data-lost flag (1 bit field) - inline void setEpoch2DataLost(uint32_t v) { setBit(6, v); } - - //! For Epoch2 data: Set sync flag (1 bit field) - inline void setEpoch2Sync(uint32_t v) { setBit(7, v); } - - //! For Epoch2 data: Set the LTS156 bits 11 to 8. This - //! gives information at what time in the Epoche the epoche number - //! was set (2 bit field) - inline void setEpoch2StampTime(uint32_t v) { setField(8, 2, v); } - - //! For Epoch2 data: Set the epoch number (32 bit field) - inline void setEpoch2Number(uint32_t v) { setField(10, 32, v); } - - //! For Epoch2 data: Set the number of the GET4 chip that send - //! the epoche message (6 bit field) - inline void setEpoch2ChipNumber(uint32_t v) { setField(42, 6, v); } - - // ---------- Get4 24b Hit data access methods ---------------- - - //! For Get4 data: Returns Get4 chip number (6 bit field) - inline uint8_t getGet4Number() const { return getField(38, 6); } - - //! For Get4 data: Returns Get4 channel number (2 bit field) - inline uint8_t getGet4ChNum() const { return getField(36, 2); } - - //! For Get4 data: Returns Get4 time stamp, 50 ps binning (19 bit field) - inline uint32_t getGet4Ts() const { return getField(17, 19); } - - //! For Get4 data: Returns Get4 fine time stamp, 50 ps binning (7 bit field) - inline uint32_t getGet4FineTs() const { return getField(17, 7); } - - //! For Get4 data: Returns Get4 coarse time stamp, 6.4 ns binning (12 bit field) - inline uint32_t getGet4CoarseTs() const { return getField(24, 12); } - - //! For Get4 data: Returns Get4 rising or falling edge (1 bit field) - inline uint32_t getGet4Edge() const { return getBit(16); } - - //! For Get4 data: Returns the CRC-8 of the rest of the message. - //! For details check the ROC documentation. (8 bit field) - inline uint32_t getGet4CRC() const { return getField(0, 8); } - - - //! For Get4 data: Sets Get4 chip number (6 bit field) - inline void setGet4Number(uint8_t v) { setField(38, 6, v); } - - //! For Get4 data: Sets Get4 channel number (2 bit field) - inline void setGet4ChNum(uint8_t v) { setField(36, 2, v); } - - //! For Get4 data: Sets Get4 time stamp, 50 ps binning (19 bit field) - inline void setGet4Ts(uint32_t v) { setField(17, 19, v); } - - //! For Get4 data: Sets Get4 rising or falling edge (1 bit field) - inline void setGet4Edge(uint32_t v) { setBit(16, v); } - - //! For Get4 data: Set the CRC-8 of the rest of the message - //! For details check the ROC documentation. (8 bit field) - inline void setGet4CRC(uint32_t v) { setField(0, 8, v); } - - // ---------- System message access methods ---------- - - // 2 bit unused - - //! For SysMes data: Returns system message subtype (8 bit field) - inline uint8_t getSysMesType() const { return getField(8, 8); } - - //! For SysMes data: Returns system message data (32 bit field) - // inline uint32_t getSysMesData() const { return getField(16, 32); } - // on some machine 32-bit field not working - inline uint32_t getSysMesData() const { return data >> 16; } - - //! For SysMes data: Set system message type (8 bit field) - inline void setSysMesType(uint8_t v) { setField(8, 8, v); } - - //! For SysMes data: Set system message data (32 bit field) - inline void setSysMesData(uint32_t v) { setField(16, 32, v); } - - // ---------- Get4 gDPB 24b/32b ALL access methods ------------------------ - inline uint16_t getGdpbGenChipId() const { return getField( 42, 6); } - inline void setGdpbGenChipId(uint32_t v) { setField(42, 6, v); } - - // ---------- Get4 gDPB 24b/32b Hit access methods ------------------------ -// inline uint16_t getGdpbHitChipId() const { return getField( 42, 6); } - inline uint16_t getGdpbHitChanId() const { return getField( 40, 2); } - inline uint32_t getGdpbHitFullTs() const { return getField( 21, 19); } - inline uint16_t getGdpbHitCrc() const { return getField( 4, 8); } - inline uint16_t getGdpbHitCoarse() const { return getField( 28, 12); } - inline uint16_t getGdpbHitFineTs() const { return getField( 21, 7); } - // ---------- Get4 gDPB 24b Hit access methods ---------------------------- - inline bool getGdpbHit24Edge() const { return getBit( 20 ); } - // ---------- Get4 gDPB 32b Hit access methods ---------------------------- - inline bool getGdpbHit32DllLck() const { return getBit( 20 ); } - inline uint16_t getGdpbHit32Tot() const { return getField( 12, 8); } - - // ---------- Get4 gDPB 24b/32b Epoch access methods ---------------------- -// inline uint16_t getGdpbEpChipId() const { return getField( 42, 6); } - inline bool getGdpbEpLinkId() const { return getBit( 41 ); } - inline uint32_t getGdpbEpEpochNb() const { return getField( 10, 31); } - inline uint16_t getGdpbEpStampTs() const { return getField( 8, 2); } - inline bool getGdpbEpSync() const { return getBit( 7 ); } - inline bool getGdpbEpDataLoss() const { return getBit( 6 ); } - inline bool getGdpbEpEpochLoss() const { return getBit( 5 ); } - inline bool getGdpbEpMissmatch() const { return getBit( 4 ); } - - // ---------- Get4 gDPB 24b/32b Slow cont. access methods ----------------- -// inline uint16_t getGdpbSlcChipId() const { return getField( 42, 6); } - inline uint32_t getGdpbSlcMess() const { return getField( 12, 29); } - inline uint32_t getGdpbSlcData() const { return getField( 12, 24); } - inline uint32_t getGdpbSlcType() const { return getField( 36, 2); } - inline uint32_t getGdpbSlcEdge() const { return getBit( 38 ); } - inline uint32_t getGdpbSlcChan() const { return getField( 39, 2); } - inline uint16_t getGdpbSlcCrc() const { return getField( 4, 8); } - - // ---------- Get4 gDPB System Msg access methods ------------------------- -// inline uint16_t getGdpbSysChipId() const { return getField( 42, 6); } - inline bool getGdpbSysLinkId() const { return getBit( 41 ); } - inline uint16_t getGdpbSysSubType() const { return getField( 37, 4); } - // ---------- Get4 gDPB 24b/32b Errors access methods --------------------- - inline bool getGdpbSysErrRoType() const { return getBit( 36 ); } - inline uint16_t getGdpbSysErrUnused() const { return getField( 14, 22); } - inline uint16_t getGdpbSysErrChanId() const { return getField( 12, 2); } - inline bool getGdpbSysErrEdge() const { return getBit( 11 ); } - inline uint16_t getGdpbSysErrData() const { return getField( 4, 7); } - // ---------- Get4 gDPB unknown msg type access methods ------------------- - inline uint32_t getGdpbSysUnkwData() const { return getField( 4, 32); } - - // ---------- STAR Trigger messages access methods ------------------------ - inline uint16_t getStarTrigMsgIndex() const { return getField( 4, 4 ); } - //++++// - inline uint64_t getGdpbTsMsbStarA() const { return getFieldLong( 8, 40 ); } - //++++// - inline uint64_t getGdpbTsLsbStarB() const { return getFieldLong( 24, 24 ); } - inline uint64_t getStarTsMsbStarB() const { return getFieldLong( 8, 16 ); } - //++++// - inline uint64_t getStarTsMidStarC() const { return getFieldLong( 8, 40 ); } - //++++// - inline uint64_t getStarTsLsbStarD() const { return getFieldLong( 40, 8 ); } - /// 12 bits in between are set to 0 - inline uint32_t getStarFillerD() const { return getField( 28, 12 ); } // Should be always 0 - inline uint32_t getStarTokenStarD() const { return getField( 8, 12 ); } - inline uint32_t getStarDaqCmdStarD() const { return getField( 20, 4 ); } - inline uint32_t getStarTrigCmdStarD() const { return getField( 24, 4 ); } - - // ---------- STAR Trigger messages setter methods ------------------------ - inline void setStarTrigMsgIndex( uint8_t v ) { setField( 4, 4, v ); } - //++++// - inline void setGdpbTsMsbStarA( uint64_t fullGdpbTs ) { setFieldLong( 8, 40, ( fullGdpbTs >> 24 ) ); } - //++++// - inline void setGdpbTsLsbStarB( uint64_t fullGdpbTs ) { setFieldLong( 24, 24, ( fullGdpbTs ) ); } - inline void setStarTsMsbStarB( uint64_t fullStarTs ) { setFieldLong( 8, 16, ( fullStarTs >> 48 ) ); } - //++++// - inline void setStarTsMidStarC( uint64_t fullStarTs ) { setFieldLong( 8, 40, ( fullStarTs >> 8 ) ); } - //++++// - inline void setStarTsLsbStarD( uint64_t fullStarTs ) { setFieldLong( 40, 8, ( fullStarTs ) ); } - /// 12 bits in between are set to 0 - inline void setStarFillerD() { setField( 28, 12, 0 ); } // Should be always 0 - inline void setStarTokenStarD( uint16_t v ) { setField( 8, 12, v ); } - inline void setStarDaqCmdStarD( uint8_t v ) { setField( 20, 4, v ); } - inline void setStarTrigCmdStarD( uint8_t v ) { setField( 24, 4, v ); } - - // ---------- Common functions ----------------------- - - //! Returns \a true is message type is #MSG_NOP (filler message) - inline bool isNopMsg() const { return getMessageType() == MSG_NOP; } - //! Returns \a true is message type is #MSG_EPOCH2 (epoch2 marker) - inline bool isEpoch2Msg() const { return getMessageType() == MSG_EPOCH2;} - //! Returns \a true is message type is #MSG_GET4 (Get4 hit data) - inline bool isGet4Msg() const { return getMessageType() == MSG_GET4; } - //! Returns \a true is message type is #MSG_SYS (system message) - inline bool isSysMsg() const { return getMessageType() == MSG_SYS; } - //! Returns \a true is message type is #MSG_GET4_SLC (GET4 Slow Control) - inline bool isGet4SlCtrMsg() const { return getMessageType() == MSG_GET4_SLC; } - //! Returns \a true is message type is #MSG_GET4_32B (GET4 Hit Data in 32b mode) - inline bool isGet4Hit32Msg() const { return getMessageType() == MSG_GET4_32B; } - //! Returns \a true is message type is #MSG_GET4_SYS (GET4 system message) - inline bool isGet4SysMsg() const { return getMessageType() == MSG_GET4_SYS; } - //! Returns \a true is message type is #MSG_STAR_TRI (STAR Trigger message) - inline bool isStarTrigger() const { return getMessageType() == MSG_STAR_TRI;} - //! Returns \a true is message type is #MSG_SYS (system message) and subtype is 32bHack - inline bool isGet4Hack32Msg() const { return - ( (getMessageType() == MSG_SYS) && - (SYSMSG_GET4V1_32BIT_0 <= getSysMesType()) ); } - - //! Returns \a true if system message and subtype #ROC_SYSMSG_DAQ_START - inline bool isStartDaqMsg() const - { return isSysMsg() && (getSysMesType() == SYSMSG_DAQ_START); } - //! Returns \a true if system message and subtype #ROC_SYSMSG_DAQ_FINISH - inline bool isStopDaqMsg() const - { return isSysMsg() && (getSysMesType() == SYSMSG_DAQ_FINISH); } - - - void printDataCout(unsigned kind = msg_print_Prefix | msg_print_Data, uint32_t epoch = 0) const; - void printDataLog(unsigned kind = msg_print_Prefix | msg_print_Data, uint32_t epoch = 0) const; - - void printData(unsigned outType = msg_print_Cout, unsigned kind = msg_print_Human, - uint32_t epoch = 0, std::ostream& os = std::cout ) const; - - uint64_t getMsgFullTime(uint64_t epoch) const; - - double getMsgFullTimeD(uint64_t epoch) const; - - //! Expanded timestamp for 160 MHz * 19 bit (12 + 7) epochs - inline static uint64_t FullTimeStamp2(uint64_t epoch, uint32_t stamp) - { return ( epoch << 19) | (stamp & 0x7ffff); } - - - static uint64_t CalcDistance(uint64_t start, uint64_t stop); - - static double CalcDistanceD(double start, double stop); - - bool operator<(const gdpb::Message& other) const; - - // -------------------- methods for working with different formats - - static uint32_t RawSize(int fmt); - - bool assign(void* src, int fmt = formatNormal); - - bool copyto(void* tgt, int fmt = formatNormal); - }; - - class FullMessage : public Message { - protected: - uint64_t fulExtendedEpoch; // Epoch of the message, extended with 32b epoch cycle counter - - public: - FullMessage() : Message(), fulExtendedEpoch(0) {} - - FullMessage(const Message& src, uint64_t uEpIn = 0) : Message(src), fulExtendedEpoch(uEpIn) {} - - FullMessage(const FullMessage& src) : Message(src), fulExtendedEpoch(src.fulExtendedEpoch) {} - - void assign(const FullMessage& src) { Message::assign(src); fulExtendedEpoch = src.fulExtendedEpoch; } - - FullMessage& operator=(const FullMessage& src) { assign(src); return *this; } - - bool operator<(const FullMessage& other) const; - - inline void reset() { Message::reset(); fulExtendedEpoch = 0; } - - inline uint64_t getExtendedEpoch() const {return fulExtendedEpoch; } - - // Works only for GET4 v2.XXX !!!!!! - inline double GetFullTimeNs() { return getMsgFullTimeD( fulExtendedEpoch ); } - - void PrintMessage( unsigned outType = msg_print_Cout, unsigned kind = msg_print_Human ) const; - }; - -} // gdpb - - -#endif // ROC_MESS_WGET4V2X_H diff --git a/beamtime/tof/CMakeLists.txt b/beamtime/tof/CMakeLists.txt deleted file mode 100644 index f70c221f8faa8f10459357c71d054dc19b43ad66..0000000000000000000000000000000000000000 --- a/beamtime/tof/CMakeLists.txt +++ /dev/null @@ -1,188 +0,0 @@ -# Create a library called "libTofUnpack" which includes the source files given in -# the array . -# The extension is already found. Any number of sources could be listed here. - -set(INCLUDE_DIRECTORIES - ${CBMROOT_SOURCE_DIR}/beamtime/roclight - - ${CBMDATA_DIR} - ${CBMDATA_DIR}/tof - - ${CBMBASE_DIR} - - ${CBMDETECTORBASE_DIR}/tof - ${CBMROOT_SOURCE_DIR}/beamtime/tof - ${CBMROOT_SOURCE_DIR}/beamtime/tof/hadaq - ${CBMROOT_SOURCE_DIR}/beamtime/tof/tdc - ${CBMROOT_SOURCE_DIR}/beamtime/tof/tdc/v1290 - ${CBMROOT_SOURCE_DIR}/beamtime/tof/tdc/vftx - ${CBMROOT_SOURCE_DIR}/beamtime/tof/tdc/trb - ${CBMROOT_SOURCE_DIR}/beamtime/tof/tdc/get4 - ${CBMROOT_SOURCE_DIR}/beamtime/tof/scalers - ${CBMROOT_SOURCE_DIR}/beamtime/tof/scalers/triglog - ${CBMROOT_SOURCE_DIR}/beamtime/tof/scalers/scalormu - ${CBMROOT_SOURCE_DIR}/beamtime/tof/scalers/scal2014 - ${CBMROOT_SOURCE_DIR}/beamtime/tof/scalers/orgen - ${CBMROOT_SOURCE_DIR}/beamtime/tof/unpMoni - ${CBMROOT_SOURCE_DIR}/beamtime/tof/calib - ${CBMROOT_SOURCE_DIR}/beamtime/tof/calib/tdc - ${CBMROOT_SOURCE_DIR}/beamtime/tof/calib/scaler - ${CBMROOT_SOURCE_DIR}/beamtime/tof/mapping - ${CBMROOT_SOURCE_DIR}/beamtime/tof/output - ${CBMROOT_SOURCE_DIR}/beamtime/tof/display -) - -Set(SYSTEM_INCLUDE_DIRECTORIES - ${BASE_INCLUDE_DIRECTORIES} - ${Boost_INCLUDE_DIR} -) - -Include_Directories( - ${INCLUDE_DIRECTORIES} -) - -Include_Directories( - SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES} -) - -Set(LINK_DIRECTORIES - ${ROOT_LIBRARY_DIR} - ${Boost_LIBRARY_DIRS} - ${FAIRROOT_LIBRARY_DIR} -) - -Link_Directories( - ${LINK_DIRECTORIES} -) - - -set(SRCS - TMbsUnpackTof.cxx - TTriglogUnpackTof.cxx - TGet4UnpackTof.cxx - hadaq/HadaqDefines.cxx - hadaq/HadaqTrbIterator.cxx - hadaq/HadaqTdcMessage.cxx - hadaq/CbmHldSource.cxx - TTrbUnpackTof.cxx - TMbsUnpackTofPar.cxx - TMbsUnpackTofContFact.cxx - scalers/TTofScalerBoard.cxx - scalers/triglog/TTofTriglogBoard.cxx - scalers/triglog/TTofTriglogUnpacker.cxx - scalers/triglog/TTofTriglogScalUnpacker.cxx - scalers/scalormu/TTofScomUnpacker.cxx - scalers/scal2014/TTofScal2014Unpacker.cxx - scalers/orgen/TTofOrGenUnpacker.cxx - tdc/TTofTdcData.cxx - tdc/TTofTdcBoard.cxx - tdc/vftx/TTofVftxData.cxx - tdc/vftx/TTofVftxBoard.cxx - tdc/vftx/TTofVftxUnpacker.cxx - tdc/trb/TTofTrbTdcData.cxx - tdc/trb/TTofTrbTdcBoard.cxx - tdc/trb/TTofTrbTdcUnpacker.cxx - tdc/trb/TTofTrbTdcCalib.cxx - tdc/get4/TGet4v1Event.cxx - tdc/get4/TTofGet4Data.cxx - tdc/get4/TTofGet4Board.cxx - tdc/get4/TGet4v1Rec.cxx - tdc/get4/TGet4v1Param.cxx - tdc/get4/TTofGet4Unpacker.cxx - unpMoni/TMbsUnpTofMonitor.cxx - calib/tdc/TTofCalibData.cxx - calib/tdc/TMbsCalibTdcTof.cxx - calib/scaler/TTofCalibScaler.cxx - calib/scaler/TMbsCalibScalTof.cxx - calib/TMbsCalibTof.cxx - calib/TMbsCalibTofPar.cxx - mapping/TMbsMappingTof.cxx - mapping/TMbsMappingTofPar.cxx - output/Plastics_Event.cxx - output/Rpc_Event.cxx - output/Scalers_Event.cxx - output/TVftxBoardData.cxx - output/TMbsConvTof.cxx - output/TMbsConvTofPar.cxx - display/CbmTofOnlineDisplay.cxx -) - -Set(HEADERS - TofDef.h - TMbsUnpackTof.h - TTriglogUnpackTof.h - TGet4UnpackTof.h - hadaq/HadaqDefines.h - hadaq/HadaqTrbIterator.h - hadaq/HadaqTimeStamp.h - hadaq/HadaqTdcMessage.h - hadaq/HadaqTdcIterator.h - hadaq/CbmHldSource.h - TTrbUnpackTof.h - TMbsUnpackTofPar.h - TMbsUnpackTofContFact.h - scalers/TofScalerDef.h - scalers/TTofScalerBoard.h - scalers/triglog/TofTriglogDef.h - scalers/triglog/TTofTriglogBoard.h - scalers/triglog/TTofTriglogUnpacker.h - scalers/triglog/TTofTriglogScalUnpacker.h - scalers/scal2014/TofScal2014Def.h - scalers/scalormu/TofScomDef.h - scalers/scalormu/TTofScomUnpacker.h - scalers/scal2014/TTofScal2014Unpacker.h - scalers/orgen/TTofOrGenUnpacker.h - tdc/TofTdcDef.h - tdc/TTofTdcData.h - tdc/TTofTdcBoard.h - tdc/v1290/TofCaenDef.h - tdc/vftx/TofVftxDef.h - tdc/vftx/TTofVftxData.h - tdc/vftx/TTofVftxBoard.h - tdc/vftx/TTofVftxUnpacker.h - tdc/trb/TofTrbTdcDef.h - tdc/trb/TTofTrbTdcData.h - tdc/trb/TTofTrbTdcBoard.h - tdc/trb/TTofTrbTdcUnpacker.h - tdc/trb/TTofTrbTdcCalib.h - tdc/get4/TofGet4Def.h - tdc/get4/TGet4v1Event.h - tdc/get4/TTofGet4Data.h - tdc/get4/TTofGet4Board.h - tdc/get4/TGet4v1Rec.h - tdc/get4/TGet4v1Param.h - tdc/get4/TTofGet4Unpacker.h - unpMoni/TMbsUnpTofMonitor.h - calib/tdc/TTofCalibData.h - calib/tdc/TMbsCalibTdcTof.h - calib/scaler/TTofCalibScaler.h - calib/scaler/TMbsCalibScalTof.h - calib/TMbsCalibTof.h - calib/TMbsCalibTofPar.h - mapping/TMbsMappingTof.h - mapping/TMbsMappingTofPar.h - output/MbsCrateDefines.h - output/Plastics_Event.h - output/Rpc_Event.h - output/Scalers_Event.h - output/TVftxBoardData.h - output/TMbsConvTof.h - output/TMbsConvTofPar.h - display/CbmTofOnlineDisplay.h -) - -If(_UINT8_T_EXIST) - Add_Definitions(-DHAVE_UINT8_T_HEADER_FILE) - Set(DEFINITIONS HAVE_UINT8_T_HEADER_FILE) -EndIf() - -Set(LINKDEF CbmTofUnpackLinkDef.h) -Set(LIBRARY_NAME CbmTofUnpack) -Set(DEPENDENCIES - Base ParBase - CbmData CbmBase - CbmTofBase - CbmRocLight -) - -GENERATE_LIBRARY() diff --git a/beamtime/tof/CbmTofUnpackLinkDef.h b/beamtime/tof/CbmTofUnpackLinkDef.h deleted file mode 100644 index f1ba512f03aa5c86874af9db1b104541d4a5c2dc..0000000000000000000000000000000000000000 --- a/beamtime/tof/CbmTofUnpackLinkDef.h +++ /dev/null @@ -1,86 +0,0 @@ -#ifdef __CINT__ - -#pragma link off all globals; -#pragma link off all classes; -#pragma link off all functions; - -#pragma link C++ struct hadaq::HadTu+; -#pragma link C++ struct hadaq::HadTuId+; -#pragma link C++ struct hadaq::RawEvent+; -#pragma link C++ struct hadaq::RawSubevent+; -#pragma link C++ class hadaq::TrbIterator+; -#pragma link C++ class hadaq::LocalStampConverter+; -#pragma link C++ class hadaq::TdcIterator+; -#pragma link C++ struct hadaq::TdcMessage+; -//#ifdef BUILD_TOF_BEAMTIME - #pragma link C++ class CbmHldSource+; -//#endif // NOT BUILD_BEAMTIME - -#pragma link C++ class TMbsUnpackTofPar+; -#pragma link C++ class TMbsUnpackTofContFact+; -#pragma link C++ class TMbsUnpackTof+; -#pragma link C++ class TTriglogUnpackTof+; -#pragma link C++ class TGet4UnpackTof+; -#pragma link C++ class TTrbUnpackTof+; - -#pragma link C++ class TTofTriglogBoard+; -#pragma link C++ class TTofScalerBoard+; -#pragma link C++ class TTofTriglogUnpacker+; -#pragma link C++ class TTofTriglogScalUnpacker+; -#pragma link C++ class TTofScomUnpacker+; -#pragma link C++ class TTofScal2014Unpacker+; -#pragma link C++ class TTofTrbTdcUnpacker+; -#pragma link C++ class TTofOrGenUnpacker+; - -#pragma link C++ class TTofTdcData+; -#pragma link C++ class std::vector<TTofTdcData>+; -#pragma link C++ class TTofTdcBoard+; -#pragma link C++ class std::vector<TTofVftxData>+; -#pragma link C++ class TTofVftxData+; -#pragma link C++ class TTofVftxBoard+; -#pragma link C++ class TTofVftxUnpacker+; -#pragma link C++ class std::vector<TTofTrbTdcData>+; -#pragma link C++ class TTofTrbTdcData+; -#pragma link C++ class TTofTrbTdcBoard+; -#pragma link C++ class TTofTrbTdcUnpacker+; -#pragma link C++ class TTofTrbTdcCalib+; - -#pragma link C++ class TGet4v1MessageExtended+; -#pragma link C++ class Get4v1Hit+; -#pragma link C++ class Get4v1Tdc+; -#pragma link C++ class Get4v1Event+; -#pragma link C++ class TTofGet4Data+; -#pragma link C++ class TTofGet4Board+; -#pragma link C++ class TimeWindowCond+; -#pragma link C++ struct TGet4v1Rec+; -#pragma link C++ class TGet4v1Param+; -#pragma link C++ class TTofGet4Unpacker+; - -#pragma link C++ class TMbsUnpTofMonitor+; - -#pragma link C++ class TMbsCalibTofPar+; -#pragma link C++ class TMbsCalibTof+; - -#pragma link C++ class TMbsCalibTdcTof+; -#pragma link C++ class TTofCalibData+; - -#pragma link C++ class TMbsCalibScalTof+; -#pragma link C++ class TTofCalibScaler+; - -#pragma link C++ class TMbsMappingTofPar+; -#pragma link C++ class TMbsMappingTof+; - -#pragma link C++ class Plastics_Hit+; -#pragma link C++ class Plastics_Event+; -#pragma link C++ class Rpc_Hit+; -#pragma link C++ class Rpc_Cluster+; -#pragma link C++ class Rpc_Event+; -#pragma link C++ class Scalers_Event+; -#pragma link C++ class TVftxBoardData+; -#pragma link C++ class TMbsConvTof+; -#pragma link C++ class TMbsConvTofPar+; - -#pragma link C++ class CbmTofOnlineDisplay; - -#endif - diff --git a/beamtime/tof/README.txt b/beamtime/tof/README.txt deleted file mode 100644 index 3cdd066b5567d286e4bc40ca75853f47d84760c8..0000000000000000000000000000000000000000 --- a/beamtime/tof/README.txt +++ /dev/null @@ -1,304 +0,0 @@ --------------------------------------------------------------- - Readme file for the ToF MBS event unpacker in CBMRoot --------------------------------------------------------------- -09/07/2013: PAL, First version --------------------------------------------------------------- -Supported hardware: - * TRIGLOG = trigger logic VME board implemented in a GSI - VULOM board, J. Fruehauf - * SCALORMU = Scaler-Or-Multiplicty VMEboard implemented in a - GSI VULOM board, also called SCOM in some place - of code, J. Fruehauf 2012 - * VFTX = 10ps 32ch Tot TDC VME board implemented in a GSI - VFTX board, E. Bayer/J. Fruehauf 2011/2012 - -Planned supported hardware (empty classes, calls missing, ...: - * v1290 = CAEN V1290A and V1290N TDC VME board, based on - CERN HPTDC chips - * GET4 = 4 channel self-triggered TDC chip developed at - GSI, v1.0 (2012) and higher - * TRB3 = 4*32ch Tot TDC implemented in a HADES TRB3 board, - 2012/2013 - * FPGA-TDC = 32ch TOT TDC implemented in a dedicated FPGA board, - specifically developped for CBM TOF wall - J. Fruehauf and GSI E.E. 2013/2014 --------------------------------------------------------------- - - I. Classes/headers Description, by call/step order - 1. Custom MBS event source (adapted from Go4) - In ./unpack/mbs -* TGo4GSIEventHeader - See Go4 Online class description -* TGo4SubEventHeader10 - See Go4 Online class description -* TGo4EventHeader10 - See Go4 Online class description -* TMbsSubEvent - See Go4 Online class description -* TMbsEvent - See Go4 Online class description -* TGo4MbsSourcePrintPar - See Go4 Online class description -* TMbsSourceParameter - Inherits from FairParGenericSet. - Parameter class for all Go4 like MBS event sources -* TMbsFileParameter - Inherits from TMbsSourceParameter. - Parameter class for the LMD file as Go4 like MBS event source. -* TMbsContFact - See Go4 Online class description -* TGo4Exception - See Go4 Online class description -* TGo4RuntimeException - See Go4 Online class description -* TGo4EventSourceException - See Go4 Online class description -* TGo4EventEndException - See Go4 Online class description -* TGo4EventErrorException - See Go4 Online class description -* TGo4EventTimeoutException - See Go4 Online class description -* TMbsSource - See Go4 Online class description -* TMbsClient - See Go4 Online class description -* TMbsFile - See Go4 Online class description - - 2. Unpacking - In ./unpack/tof -* TMbsUnpackTofContFact: - Container for all parameter classes that could be used in the each step of - unpacking: - TMbsUnpackTofPar, TMbsCalibTofPar, TMbsMappingTofPar & TMbsConvTofPar -* TMbsUnpackTofPar: - Main Parameter class for the pure unpacking step: file -> Raw -* TMbsUnpackTofCustom: - Unpacker using the Go4 like custom MBS source as event source. - Instanciate TTofTriglogUnpacker, TTofScomUnpacker and TTofVftxUnpacker objects - depending on options. - Read a full MBS event and then its SubEvents to assign the proper block of data - to each unpackers - Output object collections: - - TofTriglog (TTofTriglogBoard) - - TofRawScalers (TTofScalerBoard) - - TofVftxTdc (TTofVftxBoard) -* TMbsUnpackTof: - Inherits from FairUnpack => meant to be used with FairSource and its childs. - Unpacker for the roc3587::proc_COSY_Nov11 type of MBS subevent, which hold the data - from the detector acquisition boards (TDC, QDC, scalers, ...). - Instanciate TTofScomUnpacker and TTofVftxUnpacker objects depending on options. - Read the data block corresponding to this subevent and then split it to assign - the proper block of data to each unpackers - Output object collections: - - TofRawScalers (TTofScalerBoard) - - TofVftxTdc (TTofVftxBoard) -* TTriglogUnpackTof: - Inherits from FairUnpack => meant to be used with FairSource and its childs. - Unpacker for the roc3587::proc_triglog type of MBS subevent, which hold the trigger - board data. - Instanciate a TTofTriglogUnpacker objects depending on options and feed it with - the data blocks it receives when all options are OK. - Output object collections: - - TofRawScalers (TTofScalerBoard) - - TofTriglog (TTofTriglogBoard) -* scalers/ TTofScalerBoard: - Class storing data from a bard with scalers. These data are made of the counts - value for each scaler and the count value for a reference internal clock if it - is present. -* scalers/triglog/ TTofTriglogUnpacker: - Implement the unpacking of data coming from a TRIGLOG board and the storing of - resulting data in a TTofTriglogBoard objects for event time, clock and trigger - related data and in a TTofScalerBoard for the 3 stages of trigger scalers data - and for the clock data. (Clock data saved twice on purpose). -* scalers/triglog/ TTofTriglogBoard: - Class storing the part of the unpacked data from a TRIGLOG board which are - directly related to trigger and event timing (MBS time) -* scalers/scalormu/ TTofScomUnpacker: - Implement the unpacking of data coming from a SCALER-OR-MULTIPLICITY board and - the storing of resulting data in a TTofScalerBoard ( scalers & internal clock - data). -* tdc/ TTofTdcData: - "Standard" class for storing a single raw data point from a TDC. Made of a chan. - number, a fine time value, a coarse time value, a edge/sign flag and an optional - Time Over Threshold value. All output objets for TDC unpackers should be daughter - class of this one for the calibration step to work. For proper operation daughter - should reimplement the comparison functions/operators if needed to allow a rough - time ordering -* tdc/ TTofTdcBoard: - "Standard" class for storing the raw data from a TDC board. Holds a collection of - TTofTdcData, a TDC type, the number of channel of this board and an optional - trigger time. All output containers for TDC unpackers should be daughter class of - this one for the calibration step to work. For proper operation daughter should - reimplement the data collection related functions if a specific dat object class - is made -* tdc/vftx TTofVftxUnpacker: - Implement the unpacking of data coming from a VFTX FPGA TDC board and the - storing of resulting data TTofVftxData objects stored in the collection of a - TTofVftxBoard. -* tdc/vftx TTofVftxData: - Daughter class of TTofTdcData, adds an optional future bit flag and reimplement - the comparison function & operator to match VFTX properties. -* tdc/vftx TTofVftxBoard: - Daughter class of TTofTdcBoard, adds an optional flag for trigger type and - reimplement the data collection related functions to use TTofVftxData instead of - TTofTdcData -* TofVmeDef: - Defines namespace tofVme, which holds general constants definition for the TOF - MBS unpacking. -* commons: - Taken from last RocLib rev. 4862. Defines namespace roc, which holds the ProcId - value for the MBS sub-event taken with CBM MBS until mid-2013. -* scalers/ TofScalerDef: - Defines namespace tofscaler, which holds general constants definition for the - scalers unpacking. -* scalers/scalormu TofScomDef: - Defines namespaces scalormu and scalormubig, which hold constants definition for - the scalers properties of both ScalOrMu version. -* scalers/triglog TofTriglogDef: - Defines namespace triglog, which holds constants definition for the properties - of TRIGLOG scalers. -* tdc/ TofTdcDef: - Defines namespace toftdc, which holds general constants definition for the - tdc boards unpacking. -* tdc/vftx/ TofVftxDef: - Defines namespace vftxtdc, which holds constants definition for the unpacking - of VFTX data (nb Chans, masks, offsets, ...). -* tdc/v1290/ TofCaenDef: - Defines namespace caentdc, which holds constants definition for the unpacking - of CAEN V1290X data (nb Chans, masks, offsets, ...). -* tdc/get4/ TofGet4Def: - Defines namespace get4tdc, which holds constants definition for the unpacking - of GET4 v1.X data (nb Chans, masks, offsets, ...). -* tdc/trb/ TofTrbTdcDef: - Defines namespace trbtdc, which holds constants definition for the unpacking - of TRB3 based FPGA TDC data (nb Chans, masks, offsets, ...). - - 3. Calibration - In ./unpack/tof/calib -* TMbsCalibTof: - Calibration control class. - Instanciate TMbsCalibScalTof and TMbsCalibTdcTof objects depending on options. - Calls the TMbsCalibScalTof and TMbsCalibTdcTof calibration functions in a - controlled way. -* TMbsCalibTofPar: - Main Parameter class for the calibration step: Raw -> Calib electronics data. - Holds calibration parameters for TMbsCalibScalTof & TMbsCalibTdcTof. - Different settings for each type of TDC. -* scaler/ TMbsCalibScalTof: - Calibrator for scaler data. - Performs the conversion of the reference clock counts to an absolute time of - few us precision. If the TRIGLOG data are present, this reference clock is - histogrammmed against the MBS time (precision ~1ms) to allow for a - calibration of the clock frequency. If the clock is absent and the TRIGLOG - data re present, hte internal clock from TRIGLOG will be used instead to - obtain the absolute time. - Once the absolute time is obtained, it is used to calculate the time since - the first event and the time since the last event. Form the time since the - last event, it calculates the instantaneous rate since last event for each - channel in each scaler of the board. - Input object collections: - - TofRawScalers (TTofScalerBoard) - - TofTriglog (TTofTriglogBoard) if available - Output object collections: - - TofCalibScaler (TTofCalibScaler) -* scaler/ TTofCalibScaler: - Class to store the calibrated rate of all scaler channels from a single - scaler board. Holds also the scaler board type, the scaler number and the - channel number. When a reference internal clock is present, it is stored as - an absolute time, as well as the time since the first event and the last - event obtained from it. -* tdc/ TMbsCalibTdcTof: - Calibrator for TDC data of all types. Perform bin->time calibration for each - timing channel, Edges association (ToT building) and generation/loading of - bin-> calibration histograms files. Options allow to invert time and tot - edges, select the ToT building method, apply board specific offset, etc... - 5 ToT building methods are available: - - None => just store both rising and falling edges as calibrated times - - Time and ToT in same raw data object (message) => trivial, just need the - bin->tot conversion constantm which should be defined for each type of - board supporting this readout mode - - Time and ToT measured in same channel but stored in different data - objects (messages) => need time ordering after calibrating each data - message in an event. Building once the full board is ordered. - - Time and Tot measured in adjacent channel in the same board (e.g. 2 TDC - channels for a single input channel) => Similar to previous one. Number - of channels divided by two after calibration. - - Time and Tot measured in same channel in two adjacent boards => need - time ordering after calibrating each data message in an event. Building - only once both full boards are calibrated and ordered. - Two calibration histograms saving method are available: - - A single root file for all channels and boards present (non zero number - of counts) - - A root file for each channel/board pair placed in the calib subfolder. - Input object collections: - - TofVftxTdc (TTofVftxBoard) - - TofTriglog (TTofTriglogBoard) if available - Output object collections: - - TofCalibData (TTofCalibData) -* tdc/ TTofCalibData: - Class for storing a single calibrated time data point from a TDC. Made of a tdc - type, a board number, a channel number, an edge index (0 = rising, 1 = falling, - 2 = full hit), a calibrated time in ps and am optional ToT in ps. Function and - operator for time ordering are provided. - - 4. Mapping - In ./unpack/tof/mapping -* TMbsMappingTof - The mapping step goal is to tranform the electronics related calibrated into - detector related data: - (board, channel) -> (System, Sm, Module, Channel, Side) - The TDC data are transformed into CbmTofDigi/CbmTofDigiExp depending on the - options. The mapping is done by providing in the parameter file a detector - Unique ID (UID) following the CbmTofAddress format - Is is planned but not implemented yet to also have a mapping for the scalers: - Rate(Board,scaler,channel)[1/s] -> Flux( Detector )[1/(s*cm^2)] - Input object collections: - - TofCalibData (TTofCalibData) - Output object collections: - - CbmTofDigi (CbmTofDigi or CbmTofDigiExp) -* TMbsMappingTofPar.h - Main Parameter class for the mapping step: Calib electronics data -> Digis. - Holds calibration parameters for TMbsMappingTof. - - 5. Conversion to a ROOT TTree file in old Go4 unpacker format - In ./unpack/tof/output -* MbsCrateDefines - Definitions file from the old Go4 unpacker, used in its output classes - cf Go4 unpacker in RocLib->beamtime->tof-tdctest formore info. -* TVftxBoardData - Calibrated VFTX data holder from the old Go4 unpacker - cf Go4 unpacker in RocLib->beamtime->tof-tdctest formore info. -* Scalers_Event - Calibrated scaler data holder from the old Go4 unpacker - cf Go4 unpacker in RocLib->beamtime->tof-tdctest formore info. -* Rpc_Event - Rpc Hits and clusters holder from the old Go4 unpacker - cf Go4 unpacker in RocLib->beamtime->tof-tdctest formore info. -* Plastics_Event - Plastic Hits holder from the old Go4 unpacker - cf Go4 unpacker in RocLib->beamtime->tof-tdctest formore info -* TMbsConvTof - This step is filling a ROOT TTree following the old Go4 unpacker format. - It uses as output classes the ones from the Go4 unpacker. - Input object collections: - - TofTriglog (TTofTriglogBoard) if available - - TofVftxTdc (TTofVftxBoard) - - TofCalibData (TTofCalibData) - - TofCalibScaler (TTofCalibScaler) - - CbmTofDigi (CbmTofDigi or CbmTofDigiExp) -* TMbsConvTofPar - Main Parameter class for the conversion step: any input -> Go4/Roclic - classes. - Allows to control what is added to the Tree and how it is remapped. - -++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - II. Macro description and use - -++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -III. Option files description and use - -++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ diff --git a/beamtime/tof/TGet4UnpackTof.cxx b/beamtime/tof/TGet4UnpackTof.cxx deleted file mode 100644 index 10adb0c152fd63eeaec887ca07ab39b99d95a948..0000000000000000000000000000000000000000 --- a/beamtime/tof/TGet4UnpackTof.cxx +++ /dev/null @@ -1,228 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TGet4UnpackTof ----- -// ----- Created 24/07/2013 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ -#include "TGet4UnpackTof.h" - -// General MBS headers -#include "TofDef.h" -#include "TMbsUnpackTofPar.h" - -// ToF specific headers -#include "TTofGet4Unpacker.h" -#include "TTofGet4Board.h" -#include "TTofGet4Data.h" - -// ROOT headers -#include "TClonesArray.h" -#include "TFile.h" -#include "TROOT.h" -#include "TDirectory.h" - -// FAIR headers -#include "FairLogger.h" -//#include "FairRootManager.h" -#include "FairRunAna.h" -#include "FairRuntimeDb.h" - -TGet4UnpackTof::TGet4UnpackTof() : - FairUnpack( 10, 1, roc3587::proc_RocEvent, 0, roc::formatOptic2 ), - fiVerbosity(0), - fMbsUnpackPar(0), - fiNbEvents(0), - fiFirstEventNumber(0), - fiLastEventNumber(0), - fGet4Unp(NULL), - fGet4BoardCollection(NULL) -{ -} - -TGet4UnpackTof::TGet4UnpackTof( Int_t verbose ) : - FairUnpack( 10, 1, roc3587::proc_RocEvent, 0, roc::formatOptic2 ), - fiVerbosity(verbose), - fMbsUnpackPar(0), - fiNbEvents(0), - fiFirstEventNumber(0), - fiLastEventNumber(0), - fGet4Unp(NULL), - fGet4BoardCollection(NULL) -{ -} - -TGet4UnpackTof::TGet4UnpackTof( Int_t type, Int_t subType, Short_t sRocId, Int_t verbose, - Short_t procId, Short_t control ) : - FairUnpack( type, subType, procId, sRocId, control ), - fiVerbosity(verbose), - fMbsUnpackPar(0), - fiNbEvents(0), - fiFirstEventNumber(0), - fiLastEventNumber(0), - fGet4Unp(NULL), - fGet4BoardCollection(NULL) -{ -} - -TGet4UnpackTof::~TGet4UnpackTof() -{ - LOG(info)<<"**** TGet4UnpackTof: Delete instance "; - - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::get4 ) ) - delete fGet4Unp; -} - -// -------------------------------------------------- -// FairUnpack specific functions -Bool_t TGet4UnpackTof::Init() -{ - LOG(info)<<"**** TGet4UnpackTof: Init Params "; - if( kFALSE == InitParameters() ) - return kFALSE; - LOG(info)<<"**** TGet4UnpackTof: Params Initialized "; - - // Create the proper Unpackers and number of output objects for each boards type -// if( kFALSE == RegisterOutput() ) -// return kFALSE; - Register(); // FairUnpack Style, I feel unsafe as no check on output Array validity! - if( kFALSE == CreateUnpackers() ) - return kFALSE; - - return kTRUE; -} -Bool_t TGet4UnpackTof::DoUnpack(Int_t* data, Int_t size) -{ -/* Int_t * pData = data;*/ - - LOG(debug)<<"TGet4UnpackTof::ProcessSubevent => Found ROC subevent! LEN" - <<size; - - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::get4 ) ) - fGet4Unp->ProcessGet4( (UInt_t*)data , size ); - - FillHistograms(); - - fiNbEvents++; - LOG(debug)<<"GET4 unpacked!"; - - return kTRUE; -} -void TGet4UnpackTof::Reset() -{ - ClearOutput(); -} -void TGet4UnpackTof::Register() -{ - RegisterOutput(); -} -Bool_t TGet4UnpackTof::Finish() -{ - WriteHistogramms(); - return kTRUE; -} - -// ------------------------------------------------------------------ -Bool_t TGet4UnpackTof::InitParameters() -{ - // Get Base Container - FairRun* ana = FairRun::Instance(); - FairRuntimeDb* rtdb=ana->GetRuntimeDb(); - - // Unpacker parameter - fMbsUnpackPar = (TMbsUnpackTofPar*) (rtdb->getContainer("TMbsUnpackTofPar")); - if( 0 == fMbsUnpackPar ) - return kFALSE; - - // PAL: Added to recover loading of parameters before initialization -// rtdb->initContainers( ana->GetRunId() ); - - fMbsUnpackPar->printParams(); - - return kTRUE; -} -// ------------------------------------------------------------------ -Bool_t TGet4UnpackTof::CreateHistogramms() -{ - TDirectory * oldir = gDirectory; // <= To prevent histos from being sucked in by the param file of the TRootManager! - gROOT->cd(); // <= To prevent histos from being sucked in by the param file of the TRootManager! - - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::get4 ) ) - fGet4Unp->CreateHistos(); - - gDirectory->cd( oldir->GetPath() ); // <= To prevent histos from being sucked in by the param file of the TRootManager! - - return kTRUE; -} -Bool_t TGet4UnpackTof::FillHistograms() -{ - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::get4 ) ) - fGet4Unp->FillHistos(); - - return kTRUE; -} -void TGet4UnpackTof::WriteHistogramms() -{ - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::get4 ) ) - { - TDirectory * oldir = gDirectory; - TFile *fHist = new TFile("./tofRocUnp.hst.root","RECREATE"); - - fGet4Unp->WriteHistos( fHist ); - - gDirectory->cd( oldir->GetPath() ); - fHist->Close(); - } // if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::get4 ) ) -} -void TGet4UnpackTof::DeleteHistograms() -{ - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::get4 ) ) - fGet4Unp->DeleteHistos(); -} -// ------------------------------------------------------------------ -Bool_t TGet4UnpackTof::CreateUnpackers() -{ - if( 0 == fMbsUnpackPar->GetNbActiveBoards() ) - { - LOG(error)<<"TGet4UnpackTof::CreateUnpackers => No active boards => No unpacker !?!?! "; - return kFALSE; - } - - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::get4 ) ) - { - fGet4Unp = new TTofGet4Unpacker( fMbsUnpackPar ); - fGet4Unp->Init(); - } - - return kTRUE; -} -Bool_t TGet4UnpackTof::RegisterOutput() -{ - if( 0 == fMbsUnpackPar->GetNbActiveBoards() ) - { - LOG(error)<<"TGet4UnpackTof::RegisterOutput => No active boards => No output objects !?!?! "; - return kFALSE; - } - // Not sure here what is the best way to group the TDC objects...... - // The vector of data in the board objects kill probably the TClonesArray purpose? - // Maybe better to have big fixed size array and TTofVftxData::Clear calls in TTofVftxBoard combined - // with ConstructedAt access in TTofVftxUnpacker - FairRootManager *fManager = FairRootManager::Instance(); - // TDC - // GET4 - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::get4 ) ) - { - fGet4BoardCollection = new TClonesArray( "TTofGet4Board", - fMbsUnpackPar->GetNbActiveBoards( tofMbs::get4 )); -// fManager->Register("TofGet4Tdc","TofUnpack",fGet4BoardCollection, kTRUE); - fManager->Register( "TofGet4Tdc","TofUnpack",fGet4BoardCollection, - fMbsUnpackPar->WriteDataInCbmOut()); - } // if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::get4 ) ) - - return kTRUE; -} -Bool_t TGet4UnpackTof::ClearOutput() -{ - LOG(debug)<<"Clear GET4"; - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::get4 ) ) - fGet4BoardCollection->Clear("C"); - return kTRUE; -} -// ------------------------------------------------------------------ diff --git a/beamtime/tof/TGet4UnpackTof.h b/beamtime/tof/TGet4UnpackTof.h deleted file mode 100644 index 4345a91067e6acf939da9a658d41bcd6ff360ffd..0000000000000000000000000000000000000000 --- a/beamtime/tof/TGet4UnpackTof.h +++ /dev/null @@ -1,84 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TGet4UnpackTof ----- -// ----- Created 24/07/2013 by P.-A. Loizeau ----- -// ----- Get4 Data unpacker using the fairroot MBS classes ----- -// ------------------------------------------------------------------ -#ifndef _TGET4UNPACKTOF_H_ -#define _TGET4UNPACKTOF_H_ - -// General Fairroot unpack of GSI/MBS event -#include "FairUnpack.h" - -// Old Go4 includes - // ROC -#include "roc/Message.h" -#include "roc/Board.h" -#include "roc/Iterator.h" - -// SubEvent ProcId from ROC library -#include "commons.h" - -// FAIR headers -#include "FairRootManager.h" - -// Parameters -class TMbsUnpackTofPar; - -// Unpackers -class TTofGet4Unpacker; - -// ROOT -class TClonesArray; -class TH1; -class TH2; -class TString; - -class TGet4UnpackTof : public FairUnpack { - public: - TGet4UnpackTof(); - TGet4UnpackTof( Int_t verbose ); - TGet4UnpackTof( Int_t type, Int_t subType, Short_t sRocId = 0, Int_t verbose = 1, - Short_t procId = roc3587::proc_RocEvent, Short_t control = -roc::formatOptic2); - virtual ~TGet4UnpackTof(); - - // FairUnpack specific functions - virtual Bool_t Init(); - virtual Bool_t DoUnpack(Int_t* data, Int_t size); - virtual void Reset(); - virtual Bool_t Finish(); - - void WriteHistogramms(); - - protected: - virtual void Register(); - - private: - TGet4UnpackTof(const TGet4UnpackTof&); - TGet4UnpackTof operator=(const TGet4UnpackTof&); - - // Parameters - Int_t fiVerbosity; - Bool_t InitParameters(); - TMbsUnpackTofPar *fMbsUnpackPar; - - Bool_t CreateHistogramms(); - Bool_t FillHistograms(); - void DeleteHistograms(); - - Bool_t RegisterOutput(); - Bool_t CreateUnpackers(); - Bool_t ClearOutput(); - - Int_t fiNbEvents; - Int_t fiFirstEventNumber; - Int_t fiLastEventNumber; - - // Unpackers - TTofGet4Unpacker * fGet4Unp; - // Output objects - TClonesArray * fGet4BoardCollection; - - ClassDef(TGet4UnpackTof, 1); -}; -#endif // _TGET4UNPACKTOF_H_ diff --git a/beamtime/tof/TMbsUnpackTof.cxx b/beamtime/tof/TMbsUnpackTof.cxx deleted file mode 100644 index 3d35f47db81b3cb5271b179ea3bec502342e543c..0000000000000000000000000000000000000000 --- a/beamtime/tof/TMbsUnpackTof.cxx +++ /dev/null @@ -1,505 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TMbsUnpackTof ----- -// ----- Created 05/07/2013 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ -#include "TMbsUnpackTof.h" - -// SubEvent ProcId from ROC library -#include "commons.h" - -// General MBS headers -#include "TofDef.h" -#include "TMbsUnpackTofPar.h" - -// ToF specific headers -#include "TTofOrGenUnpacker.h" -#include "TTofScal2014Unpacker.h" -#include "TTofScomUnpacker.h" -#include "TTofTriglogScalUnpacker.h" -#include "TTofScalerBoard.h" -#include "TTofVftxUnpacker.h" -#include "TTofVftxBoard.h" -#include "TTofTdcBoard.h" - -// ROOT headers -#include "TClonesArray.h" -#include "TFile.h" -#include "TDatime.h" -#include "TROOT.h" -#include "TDirectory.h" - -// FAIR headers -#include "FairLogger.h" -//#include "FairRootManager.h" -#include "FairRunAna.h" -#include "FairRuntimeDb.h" - -TMbsUnpackTof::TMbsUnpackTof() : - FairUnpack( 10, 1, roc3587::proc_COSY_Nov11, 1, 9 ), - fiVerbosity(0), - fMbsUnpackPar(0), - fiNbEvents(0), - fiFirstEventNumber(0), - fiLastEventNumber(0), - fLastCheck(), - fCheck(), - fOrGenUnp(NULL), - fScal2014Unp(NULL), - fScomUnp(NULL), - fVftxUnp(NULL), - fTrloScalUnp(NULL), - fScalerBoardCollection(NULL), - fVftxBoardCollection(NULL), - fbSaveScalers(kFALSE), - fbSaveRawVftx(kFALSE) -{ -} - -TMbsUnpackTof::TMbsUnpackTof( Int_t verbose ) : - FairUnpack( 10, 1, roc3587::proc_COSY_Nov11, 1, 9 ), - fiVerbosity(verbose), - fMbsUnpackPar(0), - fiNbEvents(0), - fiFirstEventNumber(0), - fiLastEventNumber(0), - fLastCheck(), - fCheck(), - fOrGenUnp(NULL), - fScal2014Unp(NULL), - fScomUnp(NULL), - fVftxUnp(NULL), - fTrloScalUnp(NULL), - fScalerBoardCollection(NULL), - fVftxBoardCollection(NULL), - fbSaveScalers(kFALSE), - fbSaveRawVftx(kFALSE) -{ -} - -TMbsUnpackTof::TMbsUnpackTof( Int_t type, Int_t subType, Short_t procId, Int_t verbose, - Short_t subCrate, Short_t control) : - FairUnpack( type, subType, procId, subCrate, control ), - fiVerbosity(verbose), - fMbsUnpackPar(0), - fiNbEvents(0), - fiFirstEventNumber(0), - fiLastEventNumber(0), - fLastCheck(), - fCheck(), - fOrGenUnp(NULL), - fScal2014Unp(NULL), - fScomUnp(NULL), - fVftxUnp(NULL), - fTrloScalUnp(NULL), - fScalerBoardCollection(NULL), - fVftxBoardCollection(NULL), - fbSaveScalers(kFALSE), - fbSaveRawVftx(kFALSE) -{ -} - -TMbsUnpackTof::~TMbsUnpackTof() -{ - LOG(info)<<"**** TMbsUnpackTof: Delete instance "; - - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::orgen ) ) - delete fOrGenUnp; - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::scaler2014 ) ) - delete fScal2014Unp; - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::scalormu ) ) - delete fScomUnp; - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::triglogscal ) ) - delete fTrloScalUnp; - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::vftx ) ) - delete fVftxUnp; - LOG(info)<<"**** TMbsUnpackTof: instance deleted "; -} - -// -------------------------------------------------- -// FairUnpack specific functions -Bool_t TMbsUnpackTof::Init() -{ - LOG(info)<<"**** TMbsUnpackTof: Init Params "; - if( kFALSE == InitParameters() ) - LOG(error)<<"**** TMbsUnpackTof: Failed to Initialize params"; -// return kFALSE; - LOG(info)<<"**** TMbsUnpackTof: Params Initialized "; - - // Create the proper Unpackers and number of output objects for each boards type -// if( kFALSE == RegisterOutput() ) -// return kFALSE; - Register(); // FairUnpack Style, I feel unsafe as no check on output Array validity! - if( kFALSE == CreateUnpackers() ) - LOG(error)<<"**** TMbsUnpackTof: Failed to create unpackers "; -// return kFALSE; - - return kTRUE; -} -Bool_t TMbsUnpackTof::DoUnpack(Int_t* data, Int_t size) -{ - Int_t * pData = data; -// UInt_t uNbWords = size/2 - 1; // <= Somehow FAIRROOT transfers the size in words from the subevt header and not the size in longwords reads by the f_evt_get_subevent function -// Changed in git commit 0c0bd037c201d3496f9d5d7c133874382e885677 to fairroot LMD source -// TODO: Make sure the same change is applied to FairMbsStreamSource !!!! => For now patch in autoinstall procedure - UInt_t uNbWords = size; - - LOG(debug)<<"TMbsUnpackTof::DoUnpack => Found DATA subevent! LEN" - <<uNbWords; - - if( 3 < fiVerbosity ) - { - TString sPrintEvent = ""; - LOG(debug)<<"----------------------------------------------------------------"; - LOG(debug)<<"Size: "<<uNbWords; - for( UInt_t uWdInd = 0; uWdInd < uNbWords; uWdInd++ ) - { - if( 0 < uWdInd && 0 == uWdInd%8 ) - { - LOG(debug)<<sPrintEvent; - sPrintEvent = ""; - } // if( 0 < uWdInd && 0 == uWdInd%8 ) - sPrintEvent += Form("%08x ", pData[uWdInd]); - } // for( UInt_t uWdInd = 0; uWdInd < uNbWords; uWdInd++ ) - LOG(debug)<<sPrintEvent; - LOG(debug)<<"----------------------------------------------------------------"; - } // if( 3 < fiVerbosity ) - - Int_t* iTagPos[ fMbsUnpackPar->GetBoardsNumber() ]; - Int_t iTagLen[ fMbsUnpackPar->GetBoardsNumber() ]; - - for(UInt_t uBoard = 0; uBoard < fMbsUnpackPar->GetBoardsNumber(); uBoard++) - { - iTagPos[uBoard] = NULL; - iTagLen[uBoard] = 0; - } // for(UInt_t uBoard = 0; uBoard < fMbsUnpackPar->GetBoardsNumber(); uBoard++) - - Int_t iLastTag = -1; - -// if( 400 < fiNbEvents ) -// LOG(error)<<"TMbsUnpackTof::ProcessSubevent => Event "<<fiNbEvents<< "size "<<size<<" nbWords "<<uNbWords; - for (UInt_t uCurrWord = 0; uCurrWord < uNbWords; ++uCurrWord) - { - ULong64_t* plTag = (ULong64_t*) pData; - Bool_t bFound = kFALSE; - - // loop over boards until finding a matching one0 - for( UInt_t uBoard=0;uBoard< fMbsUnpackPar->GetBoardsNumber(); uBoard++ ) - if( kTRUE == fMbsUnpackPar->IsActive( uBoard ) ) - if ((*plTag == fMbsUnpackPar->GetBoardTag( uBoard )) && (fMbsUnpackPar->GetBoardTag( uBoard )!=0)) - { - if (iLastTag>=0) - { - // If a tag was already found: - // length of corresponding data is nb words since it was found - iTagLen[iLastTag] = pData - iTagPos[iLastTag]; - iLastTag = -1; - } // if (iLastTag>=0) - - if (iTagPos[uBoard]==0) - { -// if( 411 == fiNbEvents ) -// cout<<"Found board "<<uBoard<<" Tag " -// <<Form("%08llX %08llX", fMbsUnpackPar->GetBoardTag( uBoard )>>32, (fMbsUnpackPar->GetBoardTag( uBoard )&0xFFFFFFFF) )<<" at word "<<uCurrWord<<endl; - // if Tag of this board was never found - pData+=2; - uCurrWord+=1; - iTagPos[uBoard] = pData; - iLastTag = uBoard; - } // if (iTagPos[uBoard]==0) - else - { - LOG(error)<<"----------------------------------------------------------------"; - LOG(error)<<"TMbsUnpackTof::ProcessSubevent => size "<<size<<" nbWords "<<uNbWords; - LOG(error)<<"TMbsUnpackTof::ProcessSubevent => FORMAT ERROR found tag " - <<Form("%08llX %08llX", fMbsUnpackPar->GetBoardTag( uBoard )>>32, - fMbsUnpackPar->GetBoardTag( uBoard ) ) - <<" twice in event "<<fiNbEvents; - LOG(error)<<" First: "<<iTagPos[uBoard]<<" Second "<<pData<<" Origin "<<data - <<" Last Board "<<iLastTag<<" This Board "<<uBoard; - LOG(error)<<" Current word: "<<uCurrWord; - LOG(error)<<" Buffer: "<<Form("%08llX %08llX", (*plTag)>>32, (*plTag)&0xFFFFFFFF ); - // Display full sub-event for debug - TString sPrintEvent = ""; - for( UInt_t uWdInd = 0; uWdInd < uNbWords; uWdInd++ ) - { - if( 0 < uWdInd && 0 == uWdInd%8 ) - { - LOG(error)<<sPrintEvent; - sPrintEvent = ""; - } // if( 0 < uWdInd && 0 == uWdInd%8 ) - sPrintEvent += Form("%08x ", data[uWdInd]); - } // for( UInt_t uWdInd = 0; uWdInd < uNbWords; uWdInd++ ) - LOG(error)<<sPrintEvent; - LOG(error)<<"----------------------------------------------------------------"; - // jump this tag - pData+=2; - uCurrWord+=1; - } // else of if (iTagPos[uBoard]==0) - - bFound = kTRUE; - break; - } // if ((*plTag == fMbsUnpackPar->GetBoardTag( uBoard )) && (fMbsUnpackPar->GetBoardTag( uBoard )!=0)) - - if( kFALSE == bFound ) - pData++; - } // for (UInt_t uCurrWord = 0; uCurrWord < uNbWords; ++uCurrWord) - - // if t east one TAG found: end of corresponding data is end of subevent - if (iLastTag>=0) - iTagLen[iLastTag] = pData - iTagPos[iLastTag]; - - // Actually process data in different Unpackers: - - for( UInt_t uBoard=0; uBoard < fMbsUnpackPar->GetBoardsNumber(); uBoard++ ) - if( NULL != iTagPos[uBoard] ) - { - LOG(debug)<<"TMbsUnpackTof::ProcessSubevent => TAG "<<uBoard - <<" POS "<<iTagPos[uBoard] - data - <<" LEN "<<iTagLen[uBoard] - <<" TYP "<<fMbsUnpackPar->GetBoardType( uBoard ); - if( 0 < iTagLen[uBoard]) - switch( fMbsUnpackPar->GetBoardType( uBoard ) ) - { - case tofMbs::caenV1290: - break; - case tofMbs::vftx: - fVftxUnp->ProcessVFTX( fMbsUnpackPar->GetGlobalToActiveInd( uBoard ), - (UInt_t*) iTagPos[uBoard], iTagLen[uBoard]); - break; - case tofMbs::get4: - break; - case tofMbs::triglog: - break; - case tofMbs::scalormu: - fScomUnp->ProcessScom( fMbsUnpackPar->GetGlobalToActiveInd( uBoard ), - (UInt_t*) iTagPos[uBoard], iTagLen[uBoard]); // Scaler Or Multiplicity - break; - case tofMbs::scaler2014: - fScal2014Unp->ProcessScal2014( fMbsUnpackPar->GetGlobalToActiveInd( uBoard ), - (UInt_t*) iTagPos[uBoard], iTagLen[uBoard]); // Scalers 2014 - break; - case tofMbs::triglogscal: - fTrloScalUnp->ProcessTriglogScal( fMbsUnpackPar->GetGlobalToActiveInd( uBoard ), - (UInt_t*) iTagPos[uBoard], iTagLen[uBoard]); // Triglog used as scalers - break; - case tofMbs::orgen: - fOrGenUnp->ProcessOrGen( fMbsUnpackPar->GetGlobalToActiveInd( uBoard ), - (UInt_t*) iTagPos[uBoard], iTagLen[uBoard]); // OrGen 2015 - break; - case tofMbs::undef: - default: - LOG(warn)<<"TMbsUnpackTof::ProcessSubevent => Unknown board type " - <<fMbsUnpackPar->GetBoardType( uBoard ) - <<"!!!!" ; - } // switch( fMbsUnpackPar->GetBoardType( uBoard ) ) - } // if( NULL != iTagPos[uBoard] ) -/* - if (iTagPos[VME__ID_1182] && iTagLen[VME__ID_1182]) - Process1182(0, iTagPos[VME__ID_1182], iTagLen[VME__ID_1182]); // 1182 - if (iTagPos[VME__ID_1183] && iTagLen[VME__ID_1183]) - Process1182(1, iTagPos[VME__ID_1183], iTagLen[VME__ID_1183]); // 1183 - for (int tdc=VME__ID_TDC1;tdc<=VME__ID_TDC8;tdc++) - if (iTagPos[tdc] && iTagLen[tdc]) - Process1290(tdc-VME__ID_TDC1, iTagPos[tdc], iTagLen[tdc]); // all TDCs - for (int qdc=VME__ID_QDC1;qdc<=VME__ID_QDC2;qdc++) - if (iTagPos[qdc] && iTagLen[qdc]) - Process965(qdc-VME__ID_QDC1, iTagPos[qdc], iTagLen[qdc]); // all QDCs - if (iTagPos[VME__ID_QFW] && iTagLen[VME__ID_QFW]) - ProcessQFW((uint32_t*)iTagPos[VME__ID_QFW], iTagLen[VME__ID_QFW]); // QFW -*/ - fiNbEvents++; - LOG(debug)<<"MBS unpacked!"; - return kTRUE; -} -void TMbsUnpackTof::Reset() -{ - ClearOutput(); -} -void TMbsUnpackTof::Register() -{ - RegisterOutput(); -} -Bool_t TMbsUnpackTof::Finish() -{ -// fScomUnp->FinishScom(); - return kTRUE; -} - -// ------------------------------------------------------------------ -Bool_t TMbsUnpackTof::InitParameters() -{ - // Get Base Container - FairRun* ana = FairRun::Instance(); - FairRuntimeDb* rtdb=ana->GetRuntimeDb(); - - // Unpacker parameter - fMbsUnpackPar = (TMbsUnpackTofPar*) (rtdb->getContainer("TMbsUnpackTofPar")); - if( 0 == fMbsUnpackPar ) - return kFALSE; - -// rtdb->initContainers( ana->GetRunId() ); - fMbsUnpackPar->printParams(); - - return kTRUE; -} -// ------------------------------------------------------------------ -Bool_t TMbsUnpackTof::CreateHistogramms() -{ - TDirectory * oldir = gDirectory; // <= To prevent histos from being sucked in by the param file of the TRootManager! - gROOT->cd(); // <= To prevent histos from being sucked in by the param file of the TRootManager! - - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::scaler2014 ) ) - fScal2014Unp->CreateHistos(); - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::scalormu ) ) - fScomUnp->CreateHistos(); - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::triglogscal ) ) - fTrloScalUnp->CreateHistos(); - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::orgen ) ) - fOrGenUnp->CreateHistos(); - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::vftx ) ) - fVftxUnp->CreateHistos(); - - gDirectory->cd( oldir->GetPath() ); // <= To prevent histos from being sucked in by the param file of the TRootManager! - - return kTRUE; -} -Bool_t TMbsUnpackTof::FillHistograms() -{ - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::scaler2014 ) ) - fScal2014Unp->FillHistos(); - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::scalormu ) ) - fScomUnp->FillHistos(); - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::triglogscal ) ) - fTrloScalUnp->FillHistos(); - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::orgen ) ) - fOrGenUnp->FillHistos(); - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::vftx ) ) - fVftxUnp->FillHistos(); - - return kTRUE; -} -void TMbsUnpackTof::WriteHistogramms() -{ - TDirectory * oldir = gDirectory; - TFile *fHist; - - if( 1 == fMbsUnpackPar->GetNbActiveBoards( tofMbs::triglog ) ) - fHist = new TFile("./tofMbsUnp.hst.root","UPDATE"); - else fHist = new TFile("./tofMbsUnp.hst.root","RECREATE"); - - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::scaler2014 ) ) - fScal2014Unp->WriteHistos( fHist ); - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::scalormu ) ) - fScomUnp->WriteHistos( fHist ); - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::triglogscal ) ) - fTrloScalUnp->WriteHistos( fHist ); - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::orgen ) ) - fOrGenUnp->WriteHistos( fHist ); - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::vftx ) ) - fVftxUnp->WriteHistos( fHist ); - - gDirectory->cd( oldir->GetPath() ); - fHist->Close(); -} -void TMbsUnpackTof::DeleteHistograms() -{ - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::scaler2014 ) ) - fScal2014Unp->DeleteHistos(); - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::scalormu ) ) - fScomUnp->DeleteHistos(); - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::triglogscal ) ) - fTrloScalUnp->DeleteHistos(); - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::orgen ) ) - fOrGenUnp->DeleteHistos(); - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::vftx ) ) - fVftxUnp->DeleteHistos(); -} -// ------------------------------------------------------------------ -Bool_t TMbsUnpackTof::CreateUnpackers() -{ - if( 0 == fMbsUnpackPar->GetNbActiveBoards() ) - { - LOG(error)<<"TMbsUnpackTof::CreateUnpackers => No active boards => No unpacker !?!?! "; - return kFALSE; - } - - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::scaler2014 ) ) - fScal2014Unp = new TTofScal2014Unpacker( fMbsUnpackPar ); - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::scalormu ) ) - fScomUnp = new TTofScomUnpacker( fMbsUnpackPar ); - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::triglogscal ) ) - fTrloScalUnp = new TTofTriglogScalUnpacker( fMbsUnpackPar ); - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::orgen ) ) - fOrGenUnp = new TTofOrGenUnpacker( fMbsUnpackPar ); -/* - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::caenV1290 ) ) - fV1290Unp = new TTofV1290Unpacker( fMbsUnpackPar ); -*/ - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::vftx ) ) - fVftxUnp = new TTofVftxUnpacker( fMbsUnpackPar ); -/* - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::get4 ) ) - fGet4Unp = new TTofGet4Unpacker( fMbsUnpackPar ); -*/ - return kTRUE; -} -Bool_t TMbsUnpackTof::RegisterOutput() -{ - if( 0 == fMbsUnpackPar->GetNbActiveBoards() ) - { - LOG(error)<<"TMbsUnpackTof::RegisterOutput => No active boards => No output objects !?!?! "; - return kFALSE; - } - // Not sure here what is the best way to group the TDC objects...... - // The vector of data in the board objects kill probably the TClonesArray purpose? - // Maybe better to have big fixed size array and TTofVftxData::Clear calls in TTofVftxBoard combined - // with ConstructedAt access in TTofVftxUnpacker - FairRootManager *fManager = FairRootManager::Instance(); - // Scalers - // TRIGLOG + Scalormu + Scaler2014 + OrGen - if( 0 < fMbsUnpackPar->GetNbActiveScalersB() && 1 != fMbsUnpackPar->GetNbActiveBoards( tofMbs::triglog ) ) - { - fScalerBoardCollection = new TClonesArray( "TTofScalerBoard", - fMbsUnpackPar->GetNbActiveScalersB()); -// fManager->Register("TofRawScalers","TofUnpack",fScalerBoardCollection, kTRUE); - fManager->Register( "TofRawScalers","TofUnpack",fScalerBoardCollection, - fMbsUnpackPar->WriteDataInCbmOut() || fbSaveScalers ); - } // if( 0 < fMbsUnpackPar->GetNbActiveScalersB() ) - //TDC - // VFTX - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::vftx ) ) - { - fVftxBoardCollection = new TClonesArray( "TTofVftxBoard", - fMbsUnpackPar->GetNbActiveBoards( tofMbs::vftx )); -// fManager->Register("TofVftxTdc","TofUnpack",fVftxBoardCollection, kTRUE); - fManager->Register( "TofVftxTdc","TofUnpack",fVftxBoardCollection, - fMbsUnpackPar->WriteDataInCbmOut() || fbSaveRawVftx ); - } // if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::vftx ) ) - // Caen v1290 TDC - // VFTX - // TRB3 - - return kTRUE; -} -Bool_t TMbsUnpackTof::ClearOutput() -{ - LOG(debug)<<"Clear MBS"; - if( 0 < fMbsUnpackPar->GetNbActiveScalersB() && 1 != fMbsUnpackPar->GetNbActiveBoards( tofMbs::triglog ) ) - fScalerBoardCollection->Clear("C"); - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::vftx ) ) - fVftxBoardCollection->Clear("C"); - return kTRUE; -} -void TMbsUnpackTof::SetSaveScalers( Bool_t bSaveScal ) -{ - fbSaveScalers = bSaveScal; - LOG(info)<<"TMbsUnpackTof => Enable the saving of raw scaler data in analysis output file"; - -} -void TMbsUnpackTof::SetSaveRawVftx( Bool_t bSaveVftx ) -{ - fbSaveRawVftx = bSaveVftx; - LOG(info)<<"TMbsUnpackTof => Enable the saving of raw VFTX data in analysis output file"; - -} -// ------------------------------------------------------------------ diff --git a/beamtime/tof/TMbsUnpackTof.h b/beamtime/tof/TMbsUnpackTof.h deleted file mode 100644 index 5719dbfa4f8952fc7efbb4ee8bf5933ea83f0607..0000000000000000000000000000000000000000 --- a/beamtime/tof/TMbsUnpackTof.h +++ /dev/null @@ -1,92 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TMbsUnpackTof ----- -// ----- Created 05/07/2013 by P.-A. Loizeau ----- -// ----- Mbs Data unpacker using the fairroot MBS classes ----- -// ------------------------------------------------------------------ -#ifndef _TMBSUNPACKTOF_H_ -#define _TMBSUNPACKTOF_H_ - -// General Fairroot unpack of GSI/MBS event -#include "FairUnpack.h" - -// FAIR headers -//#include "FairLogger.h" // error: field ‘fLastCheck’ has incomplete type otherwise ?!?!? -#include "FairRootManager.h" // error: field ‘fLastCheck’ has incomplete type otherwise ?!?!? - -// Parameters -class TMbsUnpackTofPar; - -// Unpackers -class TTofOrGenUnpacker; -class TTofScal2014Unpacker; -class TTofScomUnpacker; -class TTofVftxUnpacker; -class TTofTriglogScalUnpacker; - -// ROOT -class TClonesArray; -class TH1; -class TH2; -class TString; -class TDatime; - -class TMbsUnpackTof : public FairUnpack { - public: - TMbsUnpackTof(); - TMbsUnpackTof( Int_t verbose ); - TMbsUnpackTof( Int_t type, Int_t subType, Short_t procId, Int_t verbose = 1, - Short_t subCrate = 1, Short_t control = 9 ); - virtual ~TMbsUnpackTof(); - - // FairUnpack specific functions - virtual Bool_t Init(); - virtual Bool_t DoUnpack(Int_t* data, Int_t size); - virtual void Reset(); - virtual Bool_t Finish(); - - void WriteHistogramms(); - - void SetSaveScalers( Bool_t bSaveScal=kTRUE ); - void SetSaveRawVftx( Bool_t bSaveVftx=kTRUE ); - protected: - virtual void Register(); - - private: - TMbsUnpackTof(const TMbsUnpackTof&); - TMbsUnpackTof operator=(const TMbsUnpackTof&); - - // Parameters - Int_t fiVerbosity; - Bool_t InitParameters(); - TMbsUnpackTofPar *fMbsUnpackPar; - - Bool_t CreateHistogramms(); - Bool_t FillHistograms(); - void DeleteHistograms(); - - Bool_t RegisterOutput(); - Bool_t CreateUnpackers(); - Bool_t ClearOutput(); - - Int_t fiNbEvents; - Int_t fiFirstEventNumber; - Int_t fiLastEventNumber; - TDatime fLastCheck; - TDatime fCheck; - - // Unpackers - TTofOrGenUnpacker * fOrGenUnp; - TTofScal2014Unpacker * fScal2014Unp; - TTofScomUnpacker * fScomUnp; - TTofVftxUnpacker * fVftxUnp; - TTofTriglogScalUnpacker * fTrloScalUnp; - // Output objects - TClonesArray * fScalerBoardCollection; - TClonesArray * fVftxBoardCollection; - - Bool_t fbSaveScalers; - Bool_t fbSaveRawVftx; - - ClassDef(TMbsUnpackTof, 1); -}; -#endif // _TMBSUNPACKTOF_H_ diff --git a/beamtime/tof/TMbsUnpackTofContFact.cxx b/beamtime/tof/TMbsUnpackTofContFact.cxx deleted file mode 100644 index 2e0758c6f48263ba7af9f265f5c299ba71012cf8..0000000000000000000000000000000000000000 --- a/beamtime/tof/TMbsUnpackTofContFact.cxx +++ /dev/null @@ -1,91 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TMbsUnpackTofPar ----- -// ----- Created 08/05/2013 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ - -#include "TMbsUnpackTofContFact.h" - -#include "TMbsUnpackTofPar.h" - -#include "TMbsCalibTofPar.h" - -#include "TMbsMappingTofPar.h" - -#include "TMbsConvTofPar.h" - -#include "FairRuntimeDb.h" - -#include <iostream> - -using std::cout; -using std::endl; - -ClassImp(TMbsUnpackTofContFact) - -static TMbsUnpackTofContFact gTMbsUnpackTofContFact; - -TMbsUnpackTofContFact::TMbsUnpackTofContFact() { - // Constructor (called when the library is loaded) - fName="TMbsUnpackTofContFact"; - fTitle="Factory for parameter containers in libTofUnpack"; - setAllContainers(); - FairRuntimeDb::instance()->addContFactory(this); -} - -void TMbsUnpackTofContFact::setAllContainers() { - /** Creates the Container objects with all accepted contexts and adds them to - * the list of containers for the Tof library.*/ - - FairContainer* p= new FairContainer("TMbsUnpackTofPar", - "Tof MBS Unpack Parameters", - "TestDefaultContext"); - p->addContext("TestNonDefaultContext"); - - containers->Add(p); - - FairContainer* p2= new FairContainer("TMbsCalibTofPar", - "Tof MBS Calibration Parameters", - "TestDefaultContext"); - p2->addContext("TestNonDefaultContext"); - - containers->Add(p2); - - FairContainer* p3= new FairContainer("TMbsMappingTofPar", - "Tof MBS Mapping Parameters", - "TestDefaultContext"); - p3->addContext("TestNonDefaultContext"); - - containers->Add(p3); - - FairContainer* p4= new FairContainer("TMbsConvTofPar", - "Tof MBS Conversion Parameters", - "TestDefaultContext"); - p4->addContext("TestNonDefaultContext"); - - containers->Add(p4); -} - -FairParSet* TMbsUnpackTofContFact::createContainer(FairContainer* c) { - /** Calls the constructor of the corresponding parameter container. - * For an actual context, which is not an empty string and not the default context - * of this container, the name is concatinated with the context. */ - const char* name=c->GetName(); - cout << " -I container name " << name << endl; - - FairParSet* p=NULL; - if (strcmp(name,"TMbsUnpackTofPar")==0) { - p=new TMbsUnpackTofPar(c->getConcatName().Data(), c->GetTitle(),c->getContext()); - } - else if (strcmp(name,"TMbsCalibTofPar")==0) { - p=new TMbsCalibTofPar(c->getConcatName().Data(), c->GetTitle(),c->getContext()); - } - else if (strcmp(name,"TMbsMappingTofPar")==0) { - p=new TMbsMappingTofPar(c->getConcatName().Data(), c->GetTitle(),c->getContext()); - } - else if (strcmp(name,"TMbsConvTofPar")==0) { - p=new TMbsConvTofPar(c->getConcatName().Data(), c->GetTitle(),c->getContext()); - } - - return p; -} - diff --git a/beamtime/tof/TMbsUnpackTofContFact.h b/beamtime/tof/TMbsUnpackTofContFact.h deleted file mode 100644 index 0c38df21db32014b393dc1adaf1cdaadfb1f00d2..0000000000000000000000000000000000000000 --- a/beamtime/tof/TMbsUnpackTofContFact.h +++ /dev/null @@ -1,24 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TMbsUnpackTofPar ----- -// ----- Created 08/05/2013 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ -#ifndef MBSUNPACKTOFCONTFACT_H -#define MBSUNPACKTOFCONTFACT_H - -#include "FairContFact.h" - -class FairContainer; - -class TMbsUnpackTofContFact : public FairContFact { -private: - void setAllContainers(); - TMbsUnpackTofContFact(const TMbsUnpackTofContFact&); - TMbsUnpackTofContFact& operator=(const TMbsUnpackTofContFact&); -public: - TMbsUnpackTofContFact(); - ~TMbsUnpackTofContFact() {} - FairParSet* createContainer(FairContainer*); - ClassDef( TMbsUnpackTofContFact,0) // Factory for all TOF unpack parameter containers -}; - -#endif /* !MBSUNPACKTOFCONTFACT_H */ diff --git a/beamtime/tof/TMbsUnpackTofPar.cxx b/beamtime/tof/TMbsUnpackTofPar.cxx deleted file mode 100644 index 19d30991fb1262b08ff247659381a286d756ea37..0000000000000000000000000000000000000000 --- a/beamtime/tof/TMbsUnpackTofPar.cxx +++ /dev/null @@ -1,1156 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- TMbsUnpackTofPar source file ----- -// ----- ----- -// ----- created by C. Simon on 2014-03-18 ----- -// ----- ----- -// ----- based on TMbsUnpackTofPar by P.-A. Loizeau ----- -// ----- https://subversion.gsi.de/fairroot/cbmroot/development/ploizeau/ ----- -// ----- main/unpack/tof/TMbsUnpackTofPar.cxx ----- -// ----- revision 21645, 2013-09-06 ----- -// ----------------------------------------------------------------------------- - -#include "TMbsUnpackTofPar.h" - -// TOF headers -#include "TofDef.h" - -// FAIR headers -#include "FairLogger.h" -#include "FairParamList.h" - -// ROOT headers - -ClassImp(TMbsUnpackTofPar) - -TMbsUnpackTofPar::TMbsUnpackTofPar() : - FairParGenericSet("TMbsUnpackTofPar","Mbs Unpack parameters for the ToF","TestDefaultContext"), - fiMbsSourceMode(0), - fuCbmOutOn(0), - fuVftxDebug(0), - fuNbVmeBoards(0), - fiMbsVmeMapping(), - fuNbNonVmeBoards(0), - fiNonVmeMapping(), - fuNbScalerB(0), - fuNbScalerActiveB(0), - fuNbTriglog(0), - fuNbTriglogActive(0), - fuNbScalOrMu(0), - fuNbScalOrMuActive(0), - fuNbTdc(0), - fuNbTdcActive(0), - fuNbV1290(0), - fuNbVftx(0), - fuNbGet4(0), - fuTrbSebNb(0), - fuTrbTdcNb(0), - fuTrbHubNb(0), - fMapFpgaAddrToInDataFlag(), - fMapFpgaAddrToTrbSebAddr(), - fMapTrbSebAddrToFpgaNb(), - fMapTrbSebAddrToFpgaInDataNb(), - fMapTrbSebAddrToUnpackTdcNb(), - fMapTrbSebAddrToTrbSebIndex(), - fMapTrbSebIndexToTrbSebAddr(), - fMapFpgaAddrToActiveTdcIndex(), - fMapActiveTdcIndexToFpgaAddr(), - fActiveTrbTdcAddrToUnpackFlag(), - fActiveTrbTdcIndexToUnpackFlag(), - fiTriggerRejection(0), - fuNbCtsTrigChs(0), - fiCtsTriggerMap(), - fiTrbTdcBitMode(0) -{ -} - -TMbsUnpackTofPar::TMbsUnpackTofPar(const char* name, - const char* title, - const char* context, - Int_t iMode ) : - FairParGenericSet(name,title,context), - fiMbsSourceMode(iMode), - fuCbmOutOn(0), - fuVftxDebug(0), - fuNbVmeBoards(0), - fiMbsVmeMapping(), - fuNbNonVmeBoards(0), - fiNonVmeMapping(), - fuNbScalerB(0), - fuNbScalerActiveB(0), - fuNbTriglog(0), - fuNbTriglogActive(0), - fuNbScalOrMu(0), - fuNbScalOrMuActive(0), - fuNbTdc(0), - fuNbTdcActive(0), - fuNbV1290(0), - fuNbVftx(0), - fuNbGet4(0), - fuTrbSebNb(0), - fuTrbTdcNb(0), - fuTrbHubNb(0), - fMapFpgaAddrToInDataFlag(), - fMapFpgaAddrToTrbSebAddr(), - fMapTrbSebAddrToFpgaNb(), - fMapTrbSebAddrToFpgaInDataNb(), - fMapTrbSebAddrToUnpackTdcNb(), - fMapTrbSebAddrToTrbSebIndex(), - fMapTrbSebIndexToTrbSebAddr(), - fMapFpgaAddrToActiveTdcIndex(), - fMapActiveTdcIndexToFpgaAddr(), - fActiveTrbTdcAddrToUnpackFlag(), - fActiveTrbTdcIndexToUnpackFlag(), - fiTriggerRejection(0), - fuNbCtsTrigChs(0), - fiCtsTriggerMap(), - fiTrbTdcBitMode(0) -{ -} - - -TMbsUnpackTofPar::~TMbsUnpackTofPar() -{ -} - -void TMbsUnpackTofPar::clear(void) -{ - status = kFALSE; - resetInputVersions(); - - fiMbsSourceMode = 0; - fuCbmOutOn = 0; - fuVftxDebug = 0; - fuNbVmeBoards = 0; - fuNbNonVmeBoards = 0; - fuNbScalerB = 0; - fuNbScalerActiveB = 0; - fuNbTriglog = 0; - fuNbTriglogActive = 0; - fuNbScalOrMu = 0; - fuNbScalOrMuActive = 0; - fuNbTdc = 0; - fuNbTdcActive = 0; - fuNbV1290 = 0; - fuNbVftx = 0; - fuNbGet4 = 0; - fuTrbSebNb = 0; - fuTrbTdcNb = 0; - fuTrbHubNb = 0; - fuNbCtsTrigChs = 0; - fiTrbTdcBitMode = 0; - - fMapFpgaAddrToInDataFlag.clear(); - fMapFpgaAddrToTrbSebAddr.clear(); - - fMapTrbSebAddrToFpgaNb.clear(); - fMapTrbSebAddrToFpgaInDataNb.clear(); - fMapTrbSebAddrToUnpackTdcNb.clear(); - - fMapTrbSebAddrToTrbSebIndex.clear(); - fMapTrbSebIndexToTrbSebAddr.clear(); - - fMapFpgaAddrToActiveTdcIndex.clear(); - fMapActiveTdcIndexToFpgaAddr.clear(); - -} - -void TMbsUnpackTofPar::putParams(FairParamList* l) -{ - if (!l) { return; } - - l->add("MbsSourceMode", fiMbsSourceMode); - l->add("WriteDataInCbmOut", (Int_t)fuCbmOutOn); - l->add("VftxDebug", (Int_t)fuVftxDebug); - l->add("MbsNbVmeBoards", (Int_t)fuNbVmeBoards); - l->add("MbsVmeMapping", fiMbsVmeMapping); - l->add("NbNonVmeBoards", (Int_t)fuNbNonVmeBoards); - l->add("NonVmeMapping", fiNonVmeMapping); - l->add("TriggerRejection", fiTriggerRejection); - l->add("NbCtsTrigChs", (Int_t)fuNbCtsTrigChs); - l->add("CtsTriggerMap", fiCtsTriggerMap); - l->add("TrbTdcBitMode", fiTrbTdcBitMode); -} - -Bool_t TMbsUnpackTofPar::getParams(FairParamList* l) -{ - if (!l) { return kFALSE; } - - clear(); - - LOG(debug2)<<"Get the MBS unpack parameters."; - - if ( ! l->fill("MbsSourceMode", &fiMbsSourceMode) ) return kFALSE; - - Int_t iTempCaster = 0; - if ( ! l->fill("WriteDataInCbmOut", &iTempCaster) ) return kFALSE; - fuCbmOutOn = (UInt_t)iTempCaster; - - iTempCaster = 0; - if ( ! l->fill("VftxDebug", &iTempCaster) ) return kFALSE; - fuVftxDebug = (UInt_t)iTempCaster; - - iTempCaster = 0; - if ( ! l->fill("MbsNbVmeBoards", &iTempCaster) ) return kFALSE; - fuNbVmeBoards = (UInt_t)iTempCaster; - - if( 0 < fuNbVmeBoards ) - { - fiMbsVmeMapping.Set( fuNbVmeBoards * tofMbs::kuNbFieldsMapping ); - if ( ! l->fill("MbsVmeMapping", &fiMbsVmeMapping) ) return kFALSE; - } - - iTempCaster = 0; - if ( ! l->fill("NbNonVmeBoards", &iTempCaster) ) return kFALSE; - fuNbNonVmeBoards = (UInt_t)iTempCaster; - - if( 0 < fuNbNonVmeBoards ) - { - fiNonVmeMapping.Set( fuNbNonVmeBoards * tofMbs::kuNbFieldsMapping ); - if ( ! l->fill("NonVmeMapping", &fiNonVmeMapping) ) return kFALSE; - } // if( 0 < fuNbNonVmeBoards ) - - if ( ! l->fill("TriggerRejection", &fiTriggerRejection) ) return kFALSE; - - iTempCaster = 0; - if ( ! l->fill("NbCtsTrigChs", &iTempCaster) ) - { - LOG(warn)<<"Field 'NbCtsTrigChs' not existing in the unpack parameter file!"; - LOG(warn)<<"Ignore this message if you analyze beamtime data prior to CERN February 2015."; - } - fuNbCtsTrigChs = (UInt_t)iTempCaster; - - if( 0 < fuNbCtsTrigChs ) - { - fiCtsTriggerMap.Set( fuNbCtsTrigChs * tofMbs::kuNbFieldsCtsMapping ); - if ( ! l->fill("CtsTriggerMap", &fiCtsTriggerMap) ) - { - LOG(warn)<<"Field 'CtsTriggerMap' not existing in the unpack parameter file!"; - LOG(warn)<<"Ignore this message if you analyze beamtime data prior to CERN February 2015."; - } - } - - if ( ! l->fill("TrbTdcBitMode", &fiTrbTdcBitMode) ) - { - LOG(warn)<<"Field 'TrbTdcBitMode' not existing in the unpack parameter file!"; - LOG(warn)<<"Ignore this message if you analyze beamtime data prior to CERN February 2015."; - } - - FillBoardsNbPerType(); - FillActiveBoardsNbPerType(); - - FillTrbMaps(); - -// printParams(); - - return kTRUE; -} - -void TMbsUnpackTofPar::printParams() -{ - LOG(info)<<"Parameter values in TMbsUnpackTofPar: "; - LOG(info)<<" Mbs Source Mode: \t\t"<<GetMode(); - if( kTRUE == WriteDataInCbmOut() ) - LOG(info)<<" Data writen in cbmroot out: \t\tON"; - else LOG(info)<<" Data writen in cbmroot out: \t\tOFF"; - if( kTRUE == IsDebug() ) - LOG(info)<<" VFTX Unp debug: \t\tON"; - else LOG(info)<<" VFTX Unp debug: \t\tOFF"; - LOG(info)<<" Mbs Nb Boards: \t\t"<<GetBoardsNumber(); - LOG(info)<<" Mbs Vme Mapping: \t\t BoardIndex Active Address AddMod TokenA TokenB Type"; - TString sTemp = ""; - for( UInt_t uBoard = 0; uBoard < fuNbVmeBoards; uBoard++ ) - { - sTemp = Form(" \t\t %10d %6d 0x%08X %6x 0x%08X 0x%08X %4d", - GetMappingField( uBoard, tofMbs::BoardIndex), - GetMappingField( uBoard, tofMbs::Active), - GetMappingField( uBoard, tofMbs::Address), - GetMappingField( uBoard, tofMbs::AddMod), - GetMappingField( uBoard, tofMbs::TokenA), - GetMappingField( uBoard, tofMbs::TokenB), - GetMappingField( uBoard, tofMbs::Type) ); - LOG(info)<<sTemp; - } // for( UInt_t uBoard = 0; uBoard < fuNbVmeBoards; uBoard++ ) - - LOG(info)<<" Nb Non VME Boards:\t\t"<<GetNotVmeBoardsNumber(); - if( 0 < GetNotVmeBoardsNumber() ) - { - LOG(info)<<" Not-Vme Mapping: \t\t BoardIndex Active RocIndx AddMod TokenA TokenB Type"; - sTemp = ""; - for( UInt_t uBoard = 0; uBoard < GetNotVmeBoardsNumber(); uBoard++ ) - { - sTemp = Form(" \t\t %10d %6d 0x%08X %6x 0x%08X 0x%08X %4d", - GetNotVmeMappingField( uBoard, tofMbs::BoardIndex), - GetNotVmeMappingField( uBoard, tofMbs::Active), - GetNotVmeMappingField( uBoard, tofMbs::Address), - GetNotVmeMappingField( uBoard, tofMbs::AddMod), - GetNotVmeMappingField( uBoard, tofMbs::TokenA), - GetNotVmeMappingField( uBoard, tofMbs::TokenB), - GetNotVmeMappingField( uBoard, tofMbs::Type) ); - LOG(info)<<sTemp; - } // for( UInt_t uBoard = 0; uBoard < GetNotVmeBoardsNumber(); uBoard++ ) - } // if( 0 < GetNotVmeBoardsNumber() ) - - if( -1 < GetTriggerToReject() ) - LOG(info)<<" Trigger to reject:\t\t"<<GetTriggerToReject(); - else LOG(info)<<" Trigger rejection:\t\tOFF"; - - LOG(info)<<" Nb CTS trigger ch:\t\t"<<fuNbCtsTrigChs; - if( 0 < fuNbCtsTrigChs ) - { - LOG(info)<<" CTS trigger map: \t\t TriggerChannel TriggerType TriggerReadout"; - sTemp = ""; - for( UInt_t uChannel = 0; uChannel < fuNbCtsTrigChs; uChannel++ ) - { - sTemp = Form(" \t\t %*d 0x%1X %*d", - 14, GetCtsTrigMappingField( uChannel, tofMbs::TriggerChannel), - GetCtsTrigMappingField( uChannel, tofMbs::TriggerType), - 14, GetCtsTrigMappingField( uChannel, tofMbs::TriggerUnpack) - ); - LOG(info)<<sTemp; - } - } - - if( IsTrbTdcJointEdgesChannel() ) - { - LOG(info)<<" TRB-TDC 96-bit mode: joint edge detection in the same TDC channel"; - } - else - { - LOG(info)<<" TRB-TDC 128-bit mode: separate edge detection in different TDC channels"; - } - - return; -} - -//*************** VME boards ****************************************************/ -Int_t TMbsUnpackTofPar::GetActiveBoardsNumber() -{ - UInt_t uNbActive = 0; - // Count all active VME boards of all types - for( UInt_t uBoard = 0; uBoard < fuNbVmeBoards; uBoard++ ) - if( kTRUE == IsActive( uBoard ) ) - uNbActive++; - return uNbActive; -} -Int_t TMbsUnpackTofPar::GetMappingField( UInt_t uBoard, UInt_t uField) -{ - LOG(debug3)<<"TMbsUnpackTofPar::GetMappingField: Trying to get combination (" - <<uBoard<<"/"<<uField<<") => Index "<<uBoard*tofMbs::kuNbFieldsMapping + uField; - if( static_cast<Int_t>(fuNbVmeBoards*tofMbs::kuNbFieldsMapping) == fiMbsVmeMapping.GetSize() ) - { - if( uBoard < fuNbVmeBoards && uField < tofMbs::kuNbFieldsMapping ) - return fiMbsVmeMapping[ uBoard*tofMbs::kuNbFieldsMapping + uField ]; - else - { - LOG(warn)<<"TMbsUnpackTofPar::GetMappingField: wrong Board/field combination (" - <<uBoard<<"/"<<uField<<")"; - return -1; - } // else of if( uBoard < fuNbVmeBoards && uField < tofMbs::kuNbFieldsMapping ) - } // if( fuNbVmeBoards*tofMbs::kuNbFieldsMapping == fiMbsVmeMapping.GetSize() ) - else - { - LOG(error)<<"TMbsUnpackTofPar::GetMappingField: wrong fiMbsVmeMapping size (" - <<fiMbsVmeMapping.GetSize()<<" instead of " - <<fuNbVmeBoards*tofMbs::kuNbFieldsMapping<<"), maybe not initialized!"; - return -1; - } // else of if( fuNbVmeBoards*tofMbs::kuNbFieldsMapping == fiMbsVmeMapping.GetSize() ) -} -ULong64_t TMbsUnpackTofPar::GetBoardTag( UInt_t uBoard) -{ - if( static_cast<Int_t>(fuNbVmeBoards*tofMbs::kuNbFieldsMapping) == fiMbsVmeMapping.GetSize() ) - { - if( uBoard < fuNbVmeBoards ) - { - ULong64_t uFullTag = ( ( (ULong64_t)GetMappingField( uBoard, tofMbs::TokenB ) )<< 32 ) | - (ULong64_t)GetMappingField( uBoard, tofMbs::TokenA ); -// LOG(info)<<Form(" %016llX %08llX %08llX", uFullTag, (uFullTag&0xFFFFFFFF00000000)>>32, (uFullTag&0xFFFFFFFF) ); - return uFullTag; - } // if( uBoard < fuNbVmeBoards ) - else - { - LOG(warn)<<"TMbsUnpackTofPar::GetBoardTag: wrong Board (" - <<uBoard<<")"; - return 0; - } // else of if( uBoard < fuNbVmeBoards && uField < tofMbs::kuNbFieldsMapping ) - } // if( fuNbVmeBoards*tofMbs::kuNbFieldsMapping == fiMbsVmeMapping.GetSize() ) - else - { - LOG(error)<<"TMbsUnpackTofPar::GetBoardTag: wrong fiMbsVmeMapping size (" - <<fiMbsVmeMapping.GetSize()<<" instead of " - <<fuNbVmeBoards*tofMbs::kuNbFieldsMapping<<"), maybe not initialized!"; - return 0; - } // else of if( fuNbVmeBoards*tofMbs::kuNbFieldsMapping == fiMbsVmeMapping.GetSize() ) -} -Bool_t TMbsUnpackTofPar::IsActive( UInt_t uBoard) -{ - if( static_cast<Int_t>(fuNbVmeBoards*tofMbs::kuNbFieldsMapping) == fiMbsVmeMapping.GetSize() ) - { - if( uBoard < fuNbVmeBoards ) - return (1 == GetMappingField( uBoard, tofMbs::Active ) )? kTRUE: kFALSE; - else - { - LOG(warn)<<"TMbsUnpackTofPar::IsActive: wrong Board (" - <<uBoard<<")"; - return kFALSE; - } // else of if( uBoard < fuNbVmeBoards && uField < tofMbs::kuNbFieldsMapping ) - } // if( fuNbVmeBoards*tofMbs::kuNbFieldsMapping == fiMbsVmeMapping.GetSize() ) - else - { - LOG(error)<<"TMbsUnpackTofPar::IsActive: wrong fiMbsVmeMapping size (" - <<fiMbsVmeMapping.GetSize()<<" instead of " - <<fuNbVmeBoards*tofMbs::kuNbFieldsMapping<<"), maybe not initialized!"; - return kFALSE; - } // else of if( fuNbVmeBoards*tofMbs::kuNbFieldsMapping == fiMbsVmeMapping.GetSize() ) -} -Int_t TMbsUnpackTofPar::GetBoardType( UInt_t uBoard) -{ - return GetMappingField( uBoard, tofMbs::Type); -}; -UInt_t TMbsUnpackTofPar::GetGlobalToTypeInd( UInt_t uBoardToFind ) -{ - UInt_t uIndBoardSameType = 0; - for( UInt_t uBoard = 0; uBoard < fuNbVmeBoards; uBoard++) - { - // When find target return its index among boards - // of same type - if( uBoardToFind == uBoard ) - return uIndBoardSameType; - // Count active boards of same type as target - if( GetBoardType( uBoardToFind ) == GetBoardType( uBoard ) ) - uIndBoardSameType++; - } // for( UInt_t uBoard = 0; uBoard < fuNbVmeBoards; uBoard++) - // If the board was not found: - // return total number of boards as it will be rejected by other functions! - return fuNbVmeBoards; -} -UInt_t TMbsUnpackTofPar::GetGlobalToActiveInd( UInt_t uBoardToFind ) -{ - UInt_t uIndActiveSameBoard = 0; - for( UInt_t uBoard = 0; uBoard < fuNbVmeBoards; uBoard++) - { - // When find target return its index among active boards - // of same type - if( uBoardToFind == uBoard ) - return uIndActiveSameBoard; - // Count active boards of same type as target - if( GetBoardType( uBoardToFind ) == GetBoardType( uBoard ) && - kTRUE == IsActive( uBoard ) ) - uIndActiveSameBoard++; - } // for( UInt_t uBoard = 0; uBoard < fuNbVmeBoards; uBoard++) - // If the board was not found: - // return total number of boards as it will be rejected by other functions! - return fuNbVmeBoards; -} -UInt_t TMbsUnpackTofPar::GetActiveToAllTypeInd( UInt_t uBoardToFind, UInt_t uType ) -{ - UInt_t uIndBoardSameType = 0; - UInt_t uIndActiveSameBoard = 0; - for( UInt_t uBoard = 0; uBoard < fuNbVmeBoards; uBoard++) - { - // When find target return its index among boards - // of same type - if( uBoardToFind == uIndActiveSameBoard && - kTRUE == IsActive( uBoard )) - return uIndBoardSameType; - // Count all boards of same type as target - if( static_cast<Int_t>(uType) == GetBoardType( uBoard ) ) - { - uIndBoardSameType++; - // Count active boards of same type as target - if( kTRUE == IsActive( uBoard ) ) - uIndActiveSameBoard++; - } - } // for( UInt_t uBoard = 0; uBoard < fuNbVmeBoards; uBoard++) - // If the boad was not found: - // return total number of boards as it will be rejected by other functions! - return fuNbVmeBoards; -} -//*******************************************************************************/ -//*********** Not VME boards ****************************************************/ -Int_t TMbsUnpackTofPar::GetActiveNotVmeBoardsNumber() -{ - UInt_t uNbActive = 0; - // Count all active Non-VME boards of all types - for( UInt_t uBoard = 0; uBoard < fuNbNonVmeBoards; uBoard++ ) - if( kTRUE == IsActiveNotVme( uBoard ) ) - uNbActive++; - return uNbActive; -} -Int_t TMbsUnpackTofPar::GetNotVmeMappingField( UInt_t uBoard, UInt_t uField) -{ - LOG(debug3)<<"TMbsUnpackTofPar::GetNotVmeMappingField: Trying to get combination (" - <<uBoard<<"/"<<uField<<") => Index "<<uBoard*tofMbs::kuNbFieldsMapping + uField; - if( static_cast<Int_t>(fuNbNonVmeBoards*tofMbs::kuNbFieldsMapping) == fiNonVmeMapping.GetSize() ) - { - if( uBoard < fuNbNonVmeBoards && uField < tofMbs::kuNbFieldsMapping ) - return fiNonVmeMapping[ uBoard*tofMbs::kuNbFieldsMapping + uField ]; - else - { - LOG(warn)<<"TMbsUnpackTofPar::GetNotVmeMappingField: wrong Board/field combination (" - <<uBoard<<"/"<<uField<<")"; - return -1; - } // else of if( uBoard < fuNbNonVmeBoards && uField < tofMbs::kuNbFieldsMapping ) - } // if( fuNbNonVmeBoards*tofMbs::kuNbFieldsMapping == fiMbsVmeMapping.GetSize() ) - else - { - LOG(error)<<"TMbsUnpackTofPar::GetNotVmeMappingField: wrong fiNonVmeMapping size (" - <<fiNonVmeMapping.GetSize()<<" instead of " - <<fuNbNonVmeBoards*tofMbs::kuNbFieldsMapping<<"), maybe not initialized!"; - return -1; - } // else of if( fuNbNonVmeBoards*tofMbs::kuNbFieldsMapping == fiNonVmeMapping.GetSize() ) -} -ULong64_t TMbsUnpackTofPar::GetNotVmeBoardTag( UInt_t uBoard) -{ - if( static_cast<Int_t>(fuNbNonVmeBoards*tofMbs::kuNbFieldsMapping) == fiNonVmeMapping.GetSize() ) - { - if( uBoard < fuNbNonVmeBoards ) - { - ULong64_t uFullTag = ( ( (ULong64_t)GetNotVmeMappingField( uBoard, tofMbs::TokenB ) )<< 32 ) | - (ULong64_t)GetNotVmeMappingField( uBoard, tofMbs::TokenA ); - return uFullTag; - } // if( uBoard < fuNbVmeBoards ) - else - { - LOG(warn)<<"TMbsUnpackTofPar::GetNotVmeBoardTag: wrong Board (" - <<uBoard<<")"; - return 0; - } // else of if( uBoard < fuNbNonVmeBoards && uField < tofMbs::kuNbFieldsMapping ) - } // if( fuNbNonVmeBoards*tofMbs::kuNbFieldsMapping == fiNonVmeMapping.GetSize() ) - else - { - LOG(error)<<"TMbsUnpackTofPar::GetNotVmeBoardTag: wrong fiNonVmeMapping size (" - <<fiNonVmeMapping.GetSize()<<" instead of " - <<fuNbNonVmeBoards*tofMbs::kuNbFieldsMapping<<"), maybe not initialized!"; - return 0; - } // else of if( fuNbNonVmeBoards*tofMbs::kuNbFieldsMapping == fiNonVmeMapping.GetSize() ) -} -Bool_t TMbsUnpackTofPar::IsActiveNotVme( UInt_t uBoard) -{ - if( static_cast<Int_t>(fuNbNonVmeBoards*tofMbs::kuNbFieldsMapping) == fiNonVmeMapping.GetSize() ) - { - if( uBoard < fuNbNonVmeBoards ) - return (1 == GetNotVmeMappingField( uBoard, tofMbs::Active ) )? kTRUE: kFALSE; - else - { - LOG(warn)<<"TMbsUnpackTofPar::IsActiveNotVme: wrong Board (" - <<uBoard<<")"; - return kFALSE; - } // else of if( uBoard < fuNbNonVmeBoards && uField < tofMbs::kuNbFieldsMapping ) - } // if( fuNbNonVmeBoards*tofMbs::kuNbFieldsMapping == fiNonVmeMapping.GetSize() ) - else - { - LOG(error)<<"TMbsUnpackTofPar::IsActiveNotVme: wrong fiNonVmeMapping size (" - <<fiNonVmeMapping.GetSize()<<" instead of " - <<fuNbNonVmeBoards*tofMbs::kuNbFieldsMapping<<"), maybe not initialized!"; - return kFALSE; - } // else of if( fuNbNonVmeBoards*tofMbs::kuNbFieldsMapping == fiNonVmeMapping.GetSize() ) -} -Int_t TMbsUnpackTofPar::GetNotVmeBoardType( UInt_t uBoard) -{ - return GetNotVmeMappingField( uBoard, tofMbs::Type); -}; -UInt_t TMbsUnpackTofPar::GetGlobToTypeIndNoVme( UInt_t uBoardToFind ) -{ - UInt_t uIndBoardSameType = 0; - for( UInt_t uBoard = 0; uBoard < fuNbNonVmeBoards; uBoard++) - { - // When find target return its index among boards - // of same type - if( uBoardToFind == uBoard ) - return uIndBoardSameType; - // Count active boards of same type as target - if( GetNotVmeBoardType( uBoardToFind ) == GetNotVmeBoardType( uBoard ) ) - uIndBoardSameType++; - } // for( UInt_t uBoard = 0; uBoard < fuNbNonVmeBoards; uBoard++) - // If the board was not found: - // return total number of boards as it will be rejected by other functions! - return fuNbNonVmeBoards; -} -UInt_t TMbsUnpackTofPar::GetGlobToActiveIndNoVme( UInt_t uBoardToFind ) -{ - UInt_t uIndActiveSameBoard = 0; - for( UInt_t uBoard = 0; uBoard < fuNbNonVmeBoards; uBoard++) - { - // When find target return its index among active boards - // of same type - if( uBoardToFind == uBoard ) - return uIndActiveSameBoard; - // Count active boards of same type as target - if( GetNotVmeBoardType( uBoardToFind ) == GetNotVmeBoardType( uBoard ) && - kTRUE == IsActiveNotVme( uBoard ) ) - uIndActiveSameBoard++; - } // for( UInt_t uBoard = 0; uBoard < fuNbNonVmeBoards; uBoard++) - // If the board was not found: - // return total number of boards as it will be rejected by other functions! - return fuNbNonVmeBoards; -} -UInt_t TMbsUnpackTofPar::GetActivToAllTypeIndNoVme( UInt_t uBoardToFind, UInt_t uType ) -{ - UInt_t uIndBoardSameType = 0; - UInt_t uIndActiveSameBoard = 0; - for( UInt_t uBoard = 0; uBoard < fuNbNonVmeBoards; uBoard++) - { - // When find target return its index among boards - // of same type - if( uBoardToFind == uIndActiveSameBoard && - kTRUE == IsActiveNotVme( uBoard )) - return uIndBoardSameType; - // Count all boards of same type as target - if( static_cast<Int_t>(uType) == GetNotVmeBoardType( uBoard ) ) - { - uIndBoardSameType++; - // Count active boards of same type as target - if( kTRUE == IsActiveNotVme( uBoard ) ) - uIndActiveSameBoard++; - } - } // for( UInt_t uBoard = 0; uBoard < fuNbNonVmeBoards; uBoard++) - // If the boad was not found: - // return total number of boards as it will be rejected by other functions! - return fuNbNonVmeBoards; -} -//*******************************************************************************/ -//*************** All boards ****************************************************/ -UInt_t TMbsUnpackTofPar::GetNbActiveBoards() -{ - UInt_t uNbActiveBoards = 0; - - uNbActiveBoards += GetActiveBoardsNumber(); - uNbActiveBoards += GetActiveNotVmeBoardsNumber(); - - return uNbActiveBoards; -} -UInt_t TMbsUnpackTofPar::GetNbActiveBoards( UInt_t uType ) -{ - UInt_t uNbActiveSameBoard = 0; - - if( tofMbs::trb == uType) - uType = tofMbs::trbtdc; - - // Count active boards of asked type - for( UInt_t uBoard = 0; uBoard < fuNbVmeBoards; uBoard++) - if( static_cast<Int_t>(uType) == GetBoardType( uBoard ) && - kTRUE == IsActive( uBoard ) ) - uNbActiveSameBoard++; - - // Count active boards of asked type - for( UInt_t uBoard = 0; uBoard < fuNbNonVmeBoards; uBoard++) - if( static_cast<Int_t>(uType) == GetNotVmeBoardType( uBoard ) && - kTRUE == IsActiveNotVme( uBoard ) ) - uNbActiveSameBoard++; - - return uNbActiveSameBoard; -} -UInt_t TMbsUnpackTofPar::GetNbTdcs( ) -{ - // If 0 recheck if it was simply not filled from params - if( 0 == fuNbTdc ) - FillBoardsNbPerType(); - - return fuNbTdc; -} -UInt_t TMbsUnpackTofPar::GetNbActiveTdcs( ) -{ - // If 0 recheck if it was simply not filled from params - if( 0 == fuNbTdcActive ) - FillActiveBoardsNbPerType(); - - return fuNbTdcActive; -} -UInt_t TMbsUnpackTofPar::GetNbScalersB( ) -{ - // If 0 recheck if it was simply not filled from params - if( 0 == fuNbScalerB ) - FillBoardsNbPerType(); - - return fuNbScalerB; -} -UInt_t TMbsUnpackTofPar::GetNbActiveScalersB( ) -{ - // If 0 recheck if it was simply not filled from params - if( 0 == fuNbScalerActiveB ) - FillActiveBoardsNbPerType(); - - return fuNbScalerActiveB; -} -Bool_t TMbsUnpackTofPar::WithActiveTriglog( ) -{ - if( 0 == fuNbTriglogActive ) - FillActiveBoardsNbPerType(); - - if( 0 == fuNbTriglogActive ) - return kFALSE; - else return kTRUE; -} - -void TMbsUnpackTofPar::FillBoardsNbPerType() -{ - // Scaler boards - fuNbScalerB = 0; - fuNbTriglog = 0; - fuNbScalOrMu = 0; - // TDC boards - fuNbTdc = 0; - fuNbV1290 = 0; - fuNbVftx = 0; - fuTrbTdcNb = 0; - fuNbGet4 = 0; - for( UInt_t uBoard = 0; uBoard < fuNbVmeBoards; uBoard++) - switch( GetBoardType( uBoard ) ) - { - case tofMbs::caenV1290: - fuNbTdc++; - fuNbV1290++; - break; - case tofMbs::vftx: - fuNbTdc++; - fuNbVftx++; - break; - case tofMbs::get4: - fuNbTdc++; - fuNbGet4++; - break; - case tofMbs::triglog: - fuNbScalerB++; - fuNbTriglog++; - break; - case tofMbs::scalormu: - fuNbScalerB++; - fuNbScalOrMu++; - break; - case tofMbs::scaler2014: - fuNbScalerB++; - break; - case tofMbs::orgen: - fuNbScalerB++; - break; - case tofMbs::triglogscal: - fuNbScalerB++; - break; - case tofMbs::caenv965: - case tofMbs::lecroy1182: - case tofMbs::vulqfwread: - break; - case tofMbs::undef: - default: - LOG(warn)<<"TMbsUnpackTofPar::FillBoardsNbPerType => Unknown board type " - <<GetBoardType( uBoard ) - <<"!!!!" ; - } // switch( GetBoardType( uBoard ) ) - for( UInt_t uBoard = 0; uBoard < GetNotVmeBoardsNumber(); uBoard++) - switch( GetNotVmeBoardType( uBoard ) ) - { - case tofMbs::caenV1290: - fuNbTdc++; - fuNbV1290++; - break; - case tofMbs::vftx: - fuNbTdc++; - fuNbVftx++; - break; - case tofMbs::trbseb: - fuTrbSebNb++; - break; - case tofMbs::trbtdc: - fuNbTdc++; - fuTrbTdcNb++; - break; - case tofMbs::trbhub: - fuTrbHubNb++; - break; - case tofMbs::get4: - fuNbTdc++; - fuNbGet4++; - break; - case tofMbs::triglog: - fuNbScalerB++; - fuNbTriglog++; - break; - case tofMbs::scalormu: - fuNbScalerB++; - fuNbScalOrMu++; - break; - case tofMbs::scaler2014: - fuNbScalerB++; - break; - case tofMbs::orgen: - fuNbScalerB++; - break; - case tofMbs::triglogscal: - fuNbScalerB++; - break; - case tofMbs::caenv965: - case tofMbs::lecroy1182: - case tofMbs::vulqfwread: - break; - case tofMbs::undef: - default: - LOG(warn)<<"TMbsUnpackTofPar::FillBoardsNbPerType => Unknown board type " - <<GetNotVmeBoardType( uBoard ) - <<"!!!!" ; - } // switch( GetNotVmeBoardType( uBoard ) ) -} -void TMbsUnpackTofPar::FillActiveBoardsNbPerType() -{ - // Scaler boards - fuNbScalerActiveB = 0; - fuNbTriglogActive = 0; - fuNbScalOrMuActive = 0; - // TDC boards - fuNbTdcActive = 0; - for( UInt_t uBoard = 0; uBoard < fuNbVmeBoards; uBoard++) - if( kTRUE == IsActive( uBoard ) ) - switch( GetBoardType( uBoard ) ) - { - case tofMbs::caenV1290: - case tofMbs::vftx: - case tofMbs::get4: - fuNbTdcActive++; - break; - case tofMbs::triglog: - fuNbTriglogActive++; - fuNbScalerActiveB++; - break; - case tofMbs::scalormu: - fuNbScalOrMuActive++; - fuNbScalerActiveB++; - break; - case tofMbs::scaler2014: - fuNbScalerActiveB++; - break; - case tofMbs::orgen: - fuNbScalerActiveB++; - break; - case tofMbs::triglogscal: - fuNbScalerActiveB++; - break; - case tofMbs::caenv965: - case tofMbs::lecroy1182: - case tofMbs::vulqfwread: - break; - case tofMbs::undef: - default: - LOG(warn)<<"TMbsUnpackTofPar::FillBoardsNbPerType => Unknown board type " - <<GetBoardType( uBoard ) - <<"!!!!" ; - } // switch( GetBoardType( uBoard ) ) - for( UInt_t uBoard = 0; uBoard < GetNotVmeBoardsNumber(); uBoard++) - if( kTRUE == IsActiveNotVme( uBoard ) ) - switch( GetNotVmeBoardType( uBoard ) ) - { - case tofMbs::caenV1290: - case tofMbs::vftx: - case tofMbs::trbtdc: - case tofMbs::get4: - fuNbTdcActive++; - break; - case tofMbs::triglog: - fuNbTriglogActive++; - fuNbScalerActiveB++; - break; - case tofMbs::scalormu: - fuNbScalOrMuActive++; - fuNbScalerActiveB++; - break; - case tofMbs::scaler2014: - fuNbScalerActiveB++; - break; - case tofMbs::orgen: - fuNbScalerActiveB++; - break; - case tofMbs::triglogscal: - fuNbScalerActiveB++; - break; - case tofMbs::caenv965: - case tofMbs::lecroy1182: - case tofMbs::vulqfwread: - case tofMbs::trbseb: - case tofMbs::trbhub: - break; - case tofMbs::undef: - default: - LOG(warn)<<"TMbsUnpackTofPar::FillBoardsNbPerType => Unknown board type " - <<GetNotVmeBoardType( uBoard ) - <<"!!!!" ; - } // switch( GetNotVmeBoardType( uBoard ) ) -} - - -Bool_t TMbsUnpackTofPar::OnlyOneTriglog() -{ - return ( 1 == GetNbActiveBoards( tofMbs::triglog ) ? kTRUE: kFALSE); -} - -UInt_t TMbsUnpackTofPar::GetTrbSebAddrForFpga( UInt_t uTrbNetAddress ) -{ - UInt_t uSebAddr = 0xffff; - - if( fMapFpgaAddrToTrbSebAddr.count(uTrbNetAddress) ) - { - uSebAddr = fMapFpgaAddrToTrbSebAddr[uTrbNetAddress]; - return uSebAddr; - } - else - { - return uSebAddr; - } -} - -UInt_t TMbsUnpackTofPar::GetFpgaNbPerTrbSeb( UInt_t uTrbNetAddress ) -{ - UInt_t uFpgaNb = 0; - - if( fMapTrbSebAddrToFpgaNb.count(uTrbNetAddress) ) - { - uFpgaNb = fMapTrbSebAddrToFpgaNb[uTrbNetAddress]; - return uFpgaNb; - } - else - { - return uFpgaNb; - } -} - -UInt_t TMbsUnpackTofPar::GetInDataFpgaNbPerTrbSeb( UInt_t uTrbNetAddress ) -{ - UInt_t uInDataFpgaNb = 0; - - if( fMapTrbSebAddrToFpgaInDataNb.count(uTrbNetAddress) ) - { - uInDataFpgaNb = fMapTrbSebAddrToFpgaInDataNb[uTrbNetAddress]; - return uInDataFpgaNb; - } - else - { - return uInDataFpgaNb; - } -} - -UInt_t TMbsUnpackTofPar::GetUnpackTdcNbPerTrbSeb( UInt_t uTrbNetAddress ) -{ - UInt_t uActiveTdcNb = 0; - - if( fMapTrbSebAddrToUnpackTdcNb.count(uTrbNetAddress) ) - { - uActiveTdcNb = fMapTrbSebAddrToUnpackTdcNb[uTrbNetAddress]; - return uActiveTdcNb; - } - else - { - return uActiveTdcNb; - } -} - -Int_t TMbsUnpackTofPar::GetTrbSebIndex( UInt_t uTrbNetAddress ) -{ - Int_t iIndex = -1; - - if( fMapTrbSebAddrToTrbSebIndex.count(uTrbNetAddress) ) - { - iIndex = fMapTrbSebAddrToTrbSebIndex[uTrbNetAddress]; - return iIndex; - } - else - { - return iIndex; - } - -} - -UInt_t TMbsUnpackTofPar::GetTrbSebAddr( Int_t iTrbSebIndex ) -{ - UInt_t uSebAddr = 0xffff; - - if( fMapTrbSebIndexToTrbSebAddr.count(iTrbSebIndex) ) - { - uSebAddr = fMapTrbSebIndexToTrbSebAddr[iTrbSebIndex]; - return uSebAddr; - } - else - { - return uSebAddr; - } - -} - -Int_t TMbsUnpackTofPar::GetActiveTrbTdcIndex( UInt_t uTrbNetAddress ) -{ - Int_t iIndex = -1; - - if( fMapFpgaAddrToActiveTdcIndex.count(uTrbNetAddress) ) - { - iIndex = fMapFpgaAddrToActiveTdcIndex[uTrbNetAddress]; - return iIndex; - } - else - { - return iIndex; - } -} - -UInt_t TMbsUnpackTofPar::GetActiveTrbTdcAddr( Int_t iActiveTrbTdcIndex ) -{ - UInt_t uFpgaAddr = 0xffff; - - if( fMapActiveTdcIndexToFpgaAddr.count(iActiveTrbTdcIndex) ) - { - uFpgaAddr = fMapActiveTdcIndexToFpgaAddr[iActiveTrbTdcIndex]; - return uFpgaAddr; - } - else - { - return uFpgaAddr; - } - -} - -void TMbsUnpackTofPar::FillTrbMaps() -{ - LOG(debug2)<<"**** TMbsUnpackTofPar: Call FillTrbMaps()..."; - - if( static_cast<Int_t>(fuNbNonVmeBoards*tofMbs::kuNbFieldsMapping) == fiNonVmeMapping.GetSize() ) - { - - Int_t iActiveTrbTdcIndex = 0; - Int_t iTrbSebIndex = 0; - - for( UInt_t uBoard = 0; uBoard < fuNbNonVmeBoards; uBoard++ ) - { - Int_t iBoardType = fiNonVmeMapping[ uBoard*tofMbs::kuNbFieldsMapping + tofMbs::Type ]; - - if( tofMbs::trb == iBoardType/10 ) - { - Bool_t bFpgaInData = (Bool_t)fiNonVmeMapping[ uBoard*tofMbs::kuNbFieldsMapping + tofMbs::Active ]; - UInt_t uFpgaAddr = (UInt_t)fiNonVmeMapping[ uBoard*tofMbs::kuNbFieldsMapping + tofMbs::Address ]; - UInt_t uSebAddr = (UInt_t)fiNonVmeMapping[ uBoard*tofMbs::kuNbFieldsMapping + tofMbs::TokenA ]; - Bool_t bUnpackTdc = (Bool_t)fiNonVmeMapping[ uBoard*tofMbs::kuNbFieldsMapping + tofMbs::TokenB ]; - - if( 0 < fMapFpgaAddrToInDataFlag.count(uFpgaAddr) ) - { - LOG(fatal)<<Form("FPGA address 0x%.4x appears more than once in the NonVmeMapping list. Abort program execution!", uFpgaAddr); - } - - fMapFpgaAddrToInDataFlag[uFpgaAddr] = bFpgaInData; - fMapFpgaAddrToTrbSebAddr[uFpgaAddr] = uSebAddr; - - if( bFpgaInData ) - { - if( 0 == fMapTrbSebAddrToFpgaInDataNb.count(uSebAddr) ) - { - fMapTrbSebAddrToFpgaInDataNb[uSebAddr] = 0; - } - if( 0 < fMapTrbSebAddrToFpgaInDataNb.count(uSebAddr) ) - { - fMapTrbSebAddrToFpgaInDataNb[uSebAddr]++; - } - - if( tofMbs::trbseb == iBoardType ) - { - fMapTrbSebAddrToTrbSebIndex[uFpgaAddr] = iTrbSebIndex; - fMapTrbSebIndexToTrbSebAddr[iTrbSebIndex] = uFpgaAddr; - iTrbSebIndex++; - } - - if( tofMbs::trbtdc == iBoardType ) - { - if(bUnpackTdc) - { - if( 0 == fMapTrbSebAddrToUnpackTdcNb.count(uSebAddr) ) - { - fMapTrbSebAddrToUnpackTdcNb[uSebAddr] = 0; - } - if( 0 < fMapTrbSebAddrToUnpackTdcNb.count(uSebAddr) ) - { - fMapTrbSebAddrToUnpackTdcNb[uSebAddr]++; - } - - fActiveTrbTdcAddrToUnpackFlag[uFpgaAddr] = bUnpackTdc; - fActiveTrbTdcIndexToUnpackFlag[iActiveTrbTdcIndex] = bUnpackTdc; - } - - fMapFpgaAddrToActiveTdcIndex[uFpgaAddr] = iActiveTrbTdcIndex; - fMapActiveTdcIndexToFpgaAddr[iActiveTrbTdcIndex] = uFpgaAddr; - iActiveTrbTdcIndex++; - } - - } - else - { - if( 0 == fMapTrbSebAddrToFpgaNb.count(uSebAddr) ) - { - fMapTrbSebAddrToFpgaNb[uSebAddr] = 0; - } - if( 0 < fMapTrbSebAddrToFpgaNb.count(uSebAddr) ) - { - fMapTrbSebAddrToFpgaNb[uSebAddr]++; - } - } - - } - } - - } - - else - { - LOG(error)<<"TMbsUnpackTofPar::FillTrbMaps: wrong fiNonVmeMapping size (" - <<fiNonVmeMapping.GetSize()<<" instead of " - <<fuNbNonVmeBoards*tofMbs::kuNbFieldsMapping<<"), maybe not initialized!"; - } -} - -Int_t TMbsUnpackTofPar::GetCtsTrigMappingField( UInt_t uChannel, UInt_t uField) -{ - LOG(debug3)<<"TMbsUnpackTofPar::GetCtsTrigMappingField: Trying to get combination (" - <<uChannel<<"/"<<uField<<") => Index "<<uChannel*tofMbs::kuNbFieldsCtsMapping + uField; - if( static_cast<Int_t>(fuNbCtsTrigChs*tofMbs::kuNbFieldsCtsMapping) == fiCtsTriggerMap.GetSize() ) - { - if( uChannel < fuNbCtsTrigChs && uField < tofMbs::kuNbFieldsCtsMapping ) - return fiCtsTriggerMap[ uChannel*tofMbs::kuNbFieldsCtsMapping + uField ]; - else - { - LOG(warn)<<"TMbsUnpackTofPar::GetCtsTrigMappingField: wrong channel/field combination (" - <<uChannel<<"/"<<uField<<")"; - return -1; - } - } - else - { - LOG(error)<<"TMbsUnpackTofPar::GetCtsTrigMappingField: wrong fiCtsTriggerMap size (" - <<fiCtsTriggerMap.GetSize()<<" instead of " - <<fuNbCtsTrigChs*tofMbs::kuNbFieldsCtsMapping<<"), maybe not initialized!"; - return -1; - } -} - -Bool_t TMbsUnpackTofPar::IsTrbEventUnpacked(UInt_t uTriggerPattern) -{ - Bool_t bUnpack = kTRUE; - - for( UInt_t uChannel = 0; uChannel < fuNbCtsTrigChs; uChannel++) - { - if( 1 == GetCtsTrigMappingField(uChannel,tofMbs::TriggerUnpack) ) - { - bUnpack = bUnpack && ((uTriggerPattern >> uChannel) & 0x1); - } - } - - return bUnpack; -} - -UInt_t TMbsUnpackTofPar::GetFirstTrbTrigger(UChar_t cTriggerType, UInt_t uTriggerPattern) -{ - UInt_t uFirstPattern = uTriggerPattern; - - for( UInt_t uChannel = 0; uChannel < fuNbCtsTrigChs; uChannel++) - { - if( (uFirstPattern >> uChannel) & 0x1 ) - { - if( (UChar_t)GetCtsTrigMappingField(uChannel,tofMbs::TriggerType) != cTriggerType) - { - uFirstPattern = uFirstPattern ^ (0x1 << uChannel); - } - } - } - - return uFirstPattern; -} diff --git a/beamtime/tof/TMbsUnpackTofPar.h b/beamtime/tof/TMbsUnpackTofPar.h deleted file mode 100644 index 7c417a895b807f0f13a36eb7bc24e323d47c33b3..0000000000000000000000000000000000000000 --- a/beamtime/tof/TMbsUnpackTofPar.h +++ /dev/null @@ -1,192 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- TMbsUnpackTofPar header file ----- -// ----- ----- -// ----- created by C. Simon on 2014-03-18 ----- -// ----- ----- -// ----- based on TMbsUnpackTofPar by P.-A. Loizeau ----- -// ----- https://subversion.gsi.de/fairroot/cbmroot/development/ploizeau/ ----- -// ----- main/unpack/tof/TMbsUnpackTofPar.h ----- -// ----- revision 21006, 2013-08-08 ----- -// ----------------------------------------------------------------------------- - -#ifndef _TMBSUNPACKTOFPAR_H_ -#define _TMBSUNPACKTOFPAR_H_ - -#include <map> - -#include "FairParGenericSet.h" -#include "TArrayI.h" - -class TMbsUnpackTofPar : public FairParGenericSet -{ - public: - TMbsUnpackTofPar() ; - - TMbsUnpackTofPar( const char* name, - const char* title="Mbs Unpack parameters for the ToF", - const char* context="TestDefaultContext", - Int_t iMode = 0 ); // <- no input as default !!! - - virtual ~TMbsUnpackTofPar(); - - /** Type of MBS source: file, transport client, ... */ - void SetMode(Int_t iMode) { fiMbsSourceMode = iMode; }; - Int_t GetMode() const { return fiMbsSourceMode; }; - - Bool_t WriteDataInCbmOut() const { return (1 == fuCbmOutOn)? kTRUE: kFALSE; }; - - Bool_t IsDebug() const { return (1 == fuVftxDebug)? kTRUE: kFALSE; }; - - void SetBoardsNumber( UInt_t uNbBoards ){ fuNbVmeBoards = uNbBoards; }; - UInt_t GetBoardsNumber() { return fuNbVmeBoards; }; - Int_t GetActiveBoardsNumber(); - Int_t GetMappingField( UInt_t uBoard, UInt_t uField); - ULong64_t GetBoardTag( UInt_t uBoard); - Bool_t IsActive( UInt_t uBoard); - Int_t GetBoardType( UInt_t uBoard); - // Get the index among all boards of same type from global index - UInt_t GetGlobalToTypeInd( UInt_t uBoardToFind ); - // Get the index among active boards of same type from global index - UInt_t GetGlobalToActiveInd( UInt_t uBoardToFind ); - // Get the index of an active board among all boards of same type from global index - UInt_t GetActiveToAllTypeInd( UInt_t uBoardToFind, UInt_t uType ); - - void SetNotVmeBoardsNumber( UInt_t uNbBoards ){ fuNbNonVmeBoards = uNbBoards; }; - UInt_t GetNotVmeBoardsNumber() { return fuNbNonVmeBoards; }; - Int_t GetActiveNotVmeBoardsNumber(); - Int_t GetNotVmeMappingField( UInt_t uBoard, UInt_t uField); - ULong64_t GetNotVmeBoardTag( UInt_t uBoard); - Bool_t IsActiveNotVme( UInt_t uBoard); - Int_t GetNotVmeBoardType( UInt_t uBoard); - // Get the index among all boards of same type from global index, for non-VME boards - UInt_t GetGlobToTypeIndNoVme( UInt_t uBoardToFind ); - // Get the index among active boards of same type from global index, for non-VME boards - UInt_t GetGlobToActiveIndNoVme( UInt_t uBoardToFind ); - // Get the index of an active board among all boards of same type from global index, for non-VME boards - UInt_t GetActivToAllTypeIndNoVme( UInt_t uBoardToFind, UInt_t uType ); - - // Get Total number of identified active boards - UInt_t GetNbActiveBoards(); - // Get number of active boards of asked type - UInt_t GetNbActiveBoards( UInt_t uType ); - // Get Total number of identified Tdc boards - UInt_t GetNbTdcs(); - // Get Total number of identified active Tdc boards - UInt_t GetNbActiveTdcs(); - // Get Total number of identified Scaler boards - UInt_t GetNbScalersB(); - // Get Total number of identified active Scalerboards - UInt_t GetNbActiveScalersB(); - Bool_t WithActiveTriglog(); - - UInt_t GetActiveTrbSebNb() { return fMapTrbSebAddrToTrbSebIndex.size(); }; - - Bool_t IsTrbFpgaInData( UInt_t uTrbNetAddress ) { return fMapFpgaAddrToInDataFlag[ uTrbNetAddress ]; }; - UInt_t GetTrbSebAddrForFpga( UInt_t uTrbNetAddress ); - - UInt_t GetFpgaNbPerTrbSeb( UInt_t uTrbNetAddress ); - UInt_t GetInDataFpgaNbPerTrbSeb( UInt_t uTrbNetAddress ); - UInt_t GetUnpackTdcNbPerTrbSeb( UInt_t uTrbNetAddress ); - - Int_t GetTrbSebIndex( UInt_t uTrbNetAddress ); - UInt_t GetTrbSebAddr( Int_t iTrbSebIndex ); - - Int_t GetActiveTrbTdcIndex( UInt_t uTrbNetAddress ); - UInt_t GetActiveTrbTdcAddr( Int_t iActiveTrbTdcIndex ); - - Bool_t UnpackTrbTdcAddress( UInt_t uTrbNetAddress ) { return fActiveTrbTdcAddrToUnpackFlag[ uTrbNetAddress ]; }; - Bool_t UnpackTrbTdcIndex( Int_t iActiveTrbTdcIndex ) { return fActiveTrbTdcIndexToUnpackFlag[ iActiveTrbTdcIndex ]; }; - - Int_t GetTriggerToReject() { return fiTriggerRejection; }; - Bool_t OnlyOneTriglog(); - - Int_t GetCtsTrigMappingField( UInt_t uChannel, UInt_t uField); - - Bool_t IsTrbEventUnpacked(UInt_t uTriggerPattern); - UInt_t GetFirstTrbTrigger(UChar_t cTriggerType, UInt_t uTriggerPattern); - - Bool_t IsTrbTdcJointEdgesChannel() const { return (1 == fiTrbTdcBitMode)? kTRUE: kFALSE; }; - - // Example taken from CbmTofDigiPar - void clear(void); - void putParams(FairParamList*); - Bool_t getParams(FairParamList*); - virtual void printParams(); - - private: - - /** Type of MBS source: file, transport client, ... */ - Int_t fiMbsSourceMode; - - /** CBMroot steering related parameters */ - UInt_t fuCbmOutOn; // Switch ON/OFF the writing of data in the output root file of cbmroot analysis - - /** VFTX related parameters */ - UInt_t fuVftxDebug; // Switch ON/OFF debug tests in VFTX unpacker - - // Mapping of all possible VME boards in our setup - // { BoardIndex, Active, Address, AddMod, TokenA, TokenB, Type } - UInt_t fuNbVmeBoards; - TArrayI fiMbsVmeMapping; - // Mapping of all possible Non-VME boards in our setup - // { BoardIndex, Active, Address(ROC), AddMod, TokenA, TokenB, Type } - UInt_t fuNbNonVmeBoards; - TArrayI fiNonVmeMapping; - - // Scaler boards. This numbers are not saved to file - // as can be recovered from mapping - UInt_t fuNbScalerB; - UInt_t fuNbScalerActiveB; - UInt_t fuNbTriglog; - UInt_t fuNbTriglogActive; - UInt_t fuNbScalOrMu; - UInt_t fuNbScalOrMuActive; - // TDC boards. This numbers are not saved to file - // as can be recovered from mapping - UInt_t fuNbTdc; - UInt_t fuNbTdcActive; - UInt_t fuNbV1290; - UInt_t fuNbVftx; - UInt_t fuNbGet4; - - // TRB components - UInt_t fuTrbSebNb; - UInt_t fuTrbTdcNb; - UInt_t fuTrbHubNb; - - std::map<UInt_t,Bool_t> fMapFpgaAddrToInDataFlag; - std::map<UInt_t,UInt_t> fMapFpgaAddrToTrbSebAddr; - - std::map<UInt_t,UInt_t> fMapTrbSebAddrToFpgaNb; - std::map<UInt_t,UInt_t> fMapTrbSebAddrToFpgaInDataNb; - std::map<UInt_t,UInt_t> fMapTrbSebAddrToUnpackTdcNb; - - std::map<UInt_t,Int_t> fMapTrbSebAddrToTrbSebIndex; - std::map<Int_t,UInt_t> fMapTrbSebIndexToTrbSebAddr; - - std::map<UInt_t,Int_t> fMapFpgaAddrToActiveTdcIndex; - std::map<Int_t,UInt_t> fMapActiveTdcIndexToFpgaAddr; - - std::map<UInt_t, Bool_t> fActiveTrbTdcAddrToUnpackFlag; - std::map<Int_t, Bool_t> fActiveTrbTdcIndexToUnpackFlag; - - // Trigger Rejection - Int_t fiTriggerRejection; - - // TRB-CTS trigger mapping - UInt_t fuNbCtsTrigChs; - TArrayI fiCtsTriggerMap; - - // TRB-TDC bit mode - Int_t fiTrbTdcBitMode; - - TMbsUnpackTofPar(const TMbsUnpackTofPar&); - TMbsUnpackTofPar& operator=(const TMbsUnpackTofPar&); - void FillBoardsNbPerType(); - void FillActiveBoardsNbPerType(); - void FillTrbMaps(); - - ClassDef(TMbsUnpackTofPar, 1) -}; - -#endif //TMBSUNPACKTOFPAR_H diff --git a/beamtime/tof/TTrbUnpackTof.cxx b/beamtime/tof/TTrbUnpackTof.cxx deleted file mode 100644 index 0bcc51757a757667fc309bedf0a8dd16f66a5e9f..0000000000000000000000000000000000000000 --- a/beamtime/tof/TTrbUnpackTof.cxx +++ /dev/null @@ -1,1538 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- TTrbUnpackTof source file ----- -// ----- ----- -// ----- created by C. Simon on 2014-03-08 ----- -// ----- ----- -// ----- based on TMbsUnpackTof by P.-A. Loizeau ----- -// ----- https://subversion.gsi.de/fairroot/cbmroot/development/ploizeau/ ----- -// ----- main/unpack/tof/TMbsUnpackTof.cxx ----- -// ----- revision 21787, 2013-09-20 ----- -// ----------------------------------------------------------------------------- - -#include "TTrbUnpackTof.h" - -// Parameter header -#include "TMbsUnpackTofPar.h" -#include "TofDef.h" -#include "TofTrbTdcDef.h" -#include "TTrbHeader.h" - -// Iterator -#include "HadaqTrbIterator.h" - -// Subunpacker header -#include "TTofTrbTdcUnpacker.h" - -// Output object -#include "TTofTrbTdcBoard.h" - -// ROOT headers -#include "TClonesArray.h" -#include "TROOT.h" -#include "TH1.h" -#include "TH2.h" -#include "TMath.h" -#include <TFile.h> - -// FairRoot headers -#include "FairRunOnline.h" -#include "FairLogger.h" -#include "FairRuntimeDb.h" - -ClassImp(TTrbUnpackTof) - -TTrbUnpackTof::TTrbUnpackTof( Short_t type, Short_t subType, Short_t procId, Short_t subCrate, Short_t control) : - FairUnpack( type, subType, procId, subCrate, control), - fMbsUnpackPar(0), - fMbsCalibPar(0), - fiNbEvents(0), - fiCurrentEventNumber(0), - fiPreviousEventNumber(0), - fiFirstEventNumber(0), - fiEventNumberOverflows(0), - fbFineSpillTiming(kTRUE), - fbInspection(kFALSE), - fTrbIterator(NULL), - fTrbTdcUnpacker(NULL), - fTrbTdcBoardCollection(NULL), - fbSaveRawTdcBoards(kFALSE), - fTdcUnpackMap(), - fuInDataTrbSebNb(0), - fuActiveTrbTdcNb(0), - fTrbTriggerPattern(NULL), - fTrbTriggerType(NULL), - fCtsBusyTime(NULL), - fCtsIdleTime(NULL), - fCtsIdleTimeSpill(NULL), - fCtsSpillLength(NULL), - fCtsTriggerDistance(NULL), - fItcAssertions(NULL), - fItcEvents(NULL), - fHadaqEventTime(NULL), - fTrbEventNumberJump(NULL), - fCtsTriggerCycles(NULL), - fCtsTriggerAccepted(NULL), - fHadaqEventsRecorded(NULL), - fHadaqTimeInSpill(NULL), - fCtsTimeInSpill(NULL), - fEventSkipsInSpill(NULL), - fTrbHeader(NULL), - fTrbSubeventSize(), - fTrbSubeventStatus(), - fTrbTdcWords(), - fTrbTdcProcessStatus(), - fTrbSubeventSizeRunTime(), - fuTrigChanEdgeCounter(new UInt_t[16]), - fuTrigChanClockCounter(new UInt_t[16]), - fuTrigInputEdgeCounter(new UInt_t[16]), - fuTrigInputClockCounter(new UInt_t[16]), - fiAllPossibleTriggers(0), - fiAcceptedTriggers(0), - fliAllPossibleTriggersOverflows(0), - fliAcceptedTriggersOverflows(0), - fiHadaqLastEventTime(0), - fiHadaqFirstEventTime(0), - fiHadaqSpillStartTime(0), - fiHadaqCoarseSpillStartTime(0), - fiCtsLastEventTime(0), - fiCtsFirstEventTime(0), - fbNextSpillToStart(kFALSE), - fbHadaqBufferDelay(kFALSE), - fbCtsAvailable(kFALSE), - fbGoodEventInBuffer(kFALSE), - fuSubeventSizes() -{ - LOG(info)<<"**** TTrbUnpackTof: Call TTrbUnpackTof()..."; -} - -TTrbUnpackTof::~TTrbUnpackTof() -{ - LOG(info)<<"**** TTrbUnpackTof: Call ~TTrbUnpackTof()..."; - - LOG(info)<<"**** TTrbUnpackTof: Delete subunpacker objects..."; - - if( 0 < fuActiveTrbTdcNb ) - delete fTrbTdcUnpacker; - - fTdcUnpackMap.clear(); - - delete[] fuTrigChanEdgeCounter; - delete[] fuTrigChanClockCounter; - delete[] fuTrigInputEdgeCounter; - delete[] fuTrigInputClockCounter; - -// DeleteHistograms(); -} - -Bool_t TTrbUnpackTof::Init() -{ - LOG(info)<<"**** TTrbUnpackTof: Call Init()..."; - - if( kFALSE == InitParameters() ) - { - LOG(error)<<"**** TTrbUnpackTof: Failed to initialize parameters!"; - return kFALSE; - } - LOG(info)<<"**** TTrbUnpackTof: Succeeded to initialize parameters."; - - if( kFALSE == RegisterOutput() ) - { - LOG(error)<<"**** TTrbUnpackTof: Failed to register output objects with FairRootManager!"; - return kFALSE; - } - LOG(info)<<"**** TTrbUnpackTof: Succeeded to register output objects with FairRootManager."; - - if( kFALSE == CreateSubunpackers() ) - { - LOG(error)<<"**** TTrbUnpackTof: Failed to create subunpacker objects!"; - return kFALSE; - } - LOG(info)<<"**** TTrbUnpackTof: Succeeded to create subunpacker objects."; - - CreateHistograms(); - - fuSubeventSizes.resize(fuInDataTrbSebNb); - - return kTRUE; -} - -Bool_t TTrbUnpackTof::DoUnpack(Int_t* data, Int_t size) -{ - LOG(debug)<<"**** TTrbUnpackTof: Call DoUnpack()... "; - - Int_t * pData = data; -// UInt_t uNb4ByteWords = size/2 - 1; -// Changed in git commit 0c0bd037c201d3496f9d5d7c133874382e885677 to fairroot LMD source -// TODO: Make sure the same change is applied to FairMbsStreamSource !!!! - UInt_t uNb4ByteWords = size; - UInt_t uNb1ByteWords = uNb4ByteWords*4; - - LOG(debug); - LOG(debug)<<"Unpacking TRB-type MBS subevent..."; - LOG(debug); - LOG(debug)<<"====================================="; - LOG(debug)<<"= MBS subevent ="; - LOG(debug)<<"====================================="; - LOG(debug)<<"size: "<<uNb1ByteWords<<" B"; - LOG(debug)<<"type: "<<GetType(); - LOG(debug)<<"subtype: "<<GetSubType(); - LOG(debug)<<"procid: "<<GetProcId(); - LOG(debug)<<"subcrate: "<<GetSubCrate(); - LOG(debug)<<"control: "<<GetControl(); - LOG(debug)<<"====================================="; - LOG(debug); - - FairRun::Instance()->MarkFill(kFALSE); - fbCtsAvailable = kFALSE; - fTdcUnpackMap.clear(); - std::fill(fuSubeventSizes.begin(), fuSubeventSizes.end(), 0); - - - - fTrbIterator = new hadaq::TrbIterator(pData, uNb1ByteWords); - - LOG(debug)<<"Getting single HADAQ raw event in MBS subevent..."; - hadaq::RawEvent* tCurrentEvent = fTrbIterator->nextEvent(); - - LOG(debug2)<<"First word in memory: "<<Form("0x%.8x",*((Int_t*)tCurrentEvent)); - LOG(debug2)<<"Second word in memory: "<<Form("0x%.8x",*((Int_t*)tCurrentEvent+1)); - LOG(debug2)<<"Third word in memory: "<<Form("0x%.8x",*((Int_t*)tCurrentEvent+2)); - LOG(debug2)<<"Fourth word in memory: "<<Form("0x%.8x",*((Int_t*)tCurrentEvent+3)); - LOG(debug2)<<"Fifth word in memory: "<<Form("0x%.8x",*((Int_t*)tCurrentEvent+4)); - LOG(debug2)<<"Sixth word in memory: "<<Form("0x%.8x",*((Int_t*)tCurrentEvent+5)); - LOG(debug2)<<"Seventh word in memory: "<<Form("0x%.8x",*((Int_t*)tCurrentEvent+6)); - LOG(debug2)<<"Eighth word in memory: "<<Form("0x%.8x",*((Int_t*)tCurrentEvent+7)); - - LOG(debug2)<<"First word in HADAQ event: "<<Form("0x%.8x",tCurrentEvent->tuSize); - LOG(debug2)<<"Second word in HADAQ event: "<<Form("0x%.8x",tCurrentEvent->tuDecoding); - LOG(debug2)<<"Third word in HADAQ event: "<<Form("0x%.8x",tCurrentEvent->tuId); - LOG(debug2)<<"Fourth word in HADAQ event: "<<Form("0x%.8x",tCurrentEvent->evtSeqNr); - LOG(debug2)<<"Fifth word in HADAQ event: "<<Form("0x%.8x",tCurrentEvent->evtDate); - LOG(debug2)<<"Sixth word in HADAQ event: "<<Form("0x%.8x",tCurrentEvent->evtTime); - LOG(debug2)<<"Seventh word in HADAQ event: "<<Form("0x%.8x",tCurrentEvent->evtRunNr); - LOG(debug2)<<"Eighth word in HADAQ event: "<<Form("0x%.8x",tCurrentEvent->evtPad); - - if( 0 == tCurrentEvent ) - { - LOG(error)<<"Bad HADAQ raw event. Skip whole MBS subevent."; - CheckEventBuffer(); - return kFALSE; - } - - if( 32 == uNb1ByteWords ) - { - LOG(error)<<"Empty HADAQ raw event. Skip it."; - LOG(error)<<"event number: "<<tCurrentEvent->GetSeqNr(); - CheckEventBuffer(); - return kFALSE; - } - - if( tCurrentEvent->GetDataError() ) - { - LOG(warn)<<"Error bit set in at least one HADAQ raw subevent!"; - } - - UInt_t uTriggerPattern = 0; - UInt_t uTriggerType = tCurrentEvent->GetTrigType(); - - if( !fTrbTdcUnpacker ) - { - LOG(error)<<"TTrbUnpackTof not properly initialized! Cannot unpack any events."; - CheckEventBuffer(); - return kFALSE; - } - fTrbTdcUnpacker->SetCalibTrigger(uTriggerType); - - LOG(debug); - LOG(debug)<<"====================================="; - LOG(debug)<<"= HADAQ raw event ="; - LOG(debug)<<"====================================="; - LOG(debug)<<"size: "<<tCurrentEvent->GetSize()<<" B"; - LOG(debug)<<"decoding: "<<Form("0x%.8x",tCurrentEvent->GetDecoding()); - LOG(debug)<<"id: "<<Form("0x%.8x",tCurrentEvent->GetId()); - LOG(debug)<<"event number: "<<tCurrentEvent->GetSeqNr(); - LOG(debug)<<"trigger type: "<<Form("0x%.1x",uTriggerType); - LOG(debug)<<"date: "<<Form("%.4u-%.2u-%.2u (yyyy-mm-dd)",1900+(tCurrentEvent->GetDate()>>16), - 1+((tCurrentEvent->GetDate()&0xff00)>>8), - ((tCurrentEvent->GetDate()&0xff))); - LOG(debug)<<"time: "<<Form("%.2u:%.2u:%.2u UTC (hh:mm:ss)",(tCurrentEvent->GetTime()>>16), - ((tCurrentEvent->GetTime()&0xff00)>>8), - ((tCurrentEvent->GetTime()&0xff))); - LOG(debug)<<"file number: "<<tCurrentEvent->GetRunNr(); - LOG(debug)<<"padding: "<<tCurrentEvent->GetPaddedSize()-tCurrentEvent->GetSize()<<" B"; - LOG(debug)<<"====================================="; - LOG(debug); - - if( uNb1ByteWords != tCurrentEvent->GetPaddedSize() ) - { -// LOG(warn)<<Form("HADAQ raw event of padded size %u does not fully occupy MBS Subevent data field of size %u!", - LOG(warn)<<Form("HADAQ raw event of padded size %u does not fully occupy MBS Subevent data field of size %u! Ratio: %f, size %d", - tCurrentEvent->GetPaddedSize(), uNb1ByteWords, - (Float_t)(tCurrentEvent->GetPaddedSize())/(Float_t)uNb1ByteWords, size ); - } - - - hadaq::RawSubevent* tCurrentSubevent; - UInt_t uNbSubevents = 0; - UInt_t uNbGoodSubevents = 0; - - while( 0 != fTrbIterator->nextSubevent() ) - { - LOG(debug)<<"Getting HADAQ raw subevent in HADAQ raw event..."; - - tCurrentSubevent = fTrbIterator->currSubevent(); - UInt_t uSubeventId = tCurrentSubevent->GetId() & 0xffff; - - uNbSubevents++; - - Bool_t bKnownSubevent = ( -1 < fMbsUnpackPar->GetTrbSebIndex( uSubeventId ) ); - UInt_t uNbRegisteredFpgas = 0; - UInt_t uNbActiveFpgas = 0; - - if( bKnownSubevent ) - { - uNbRegisteredFpgas = fMbsUnpackPar->GetInDataFpgaNbPerTrbSeb( uSubeventId ); - uNbActiveFpgas = fMbsUnpackPar->GetUnpackTdcNbPerTrbSeb( uSubeventId ); - - fTrbSubeventSize[ fMbsUnpackPar->GetTrbSebIndex( uSubeventId ) ]->Fill( tCurrentSubevent->GetSize()/1000 ); - - fuSubeventSizes.at(fMbsUnpackPar->GetTrbSebIndex( uSubeventId )) = tCurrentSubevent->GetSize(); - } - - DataErrorHandling(uSubeventId, tCurrentSubevent->GetErrBits()); - - if( tCurrentSubevent->GetDataError() || (tCurrentSubevent->GetErrBits() != 0x00000001) ) - { - LOG(error)<<Form("HADAQ raw subevent from source 0x%.4x contains broken data.", uSubeventId); - CheckEventBuffer(); - return kFALSE; - } - - uNbGoodSubevents++; - - - LOG(debug); - LOG(debug)<<"====================================="; - if( bKnownSubevent ) - { - LOG(debug)<<Form("= HADAQ raw subevent 0x%.4x =",uSubeventId); - } - else - { - LOG(debug)<<Form("= Unknown subevent 0x%.4x =",uSubeventId); - } - LOG(debug)<<"====================================="; - LOG(debug)<<"size: "<<tCurrentSubevent->GetSize()<<" B"; - LOG(debug)<<"decoding: "<<Form("0x%.8x",tCurrentSubevent->GetDecoding()); - LOG(debug)<<"CTS trigger counter: "<<Form("0x%.6x",tCurrentSubevent->GetTrigNr()>>8); - LOG(debug)<<"trigger type: "<<Form("0x%.2x",tCurrentSubevent->GetTrigType()); - LOG(debug)<<"next trigger tag: "<<Form("0x%.2x",tCurrentSubevent->GetTrigNr()&0xff); - LOG(debug)<<"padding: "<<tCurrentSubevent->GetPaddedSize()-tCurrentSubevent->GetSize()<<" B"; - LOG(debug)<<"====================================="; - if( bKnownSubevent ) - { - LOG(debug)<<Form("FPGAs registered: %u", uNbRegisteredFpgas); - LOG(debug)<<Form("TDCs read out : %u", uNbActiveFpgas); - LOG(debug)<<"====================================="; - } - LOG(debug); - - LOG(debug)<<"Getting HADAQ raw subsubevents in HADAQ raw subevent..."; - - UInt_t uNbSubsubevents = 0; - - UInt_t uNbSubsubeventDataWords = tCurrentSubevent->GetNrOfDataWords(); - - if( 0 == uNbSubsubeventDataWords ) - { - LOG(warn)<<Form("No data in HADAQ raw subevent 0x%.4x.. Skip!", uSubeventId); - continue; - } - - UInt_t uSubsubeventDataIndex = 0; - UInt_t uSubsubeventData = 0; - UInt_t uSubsubeventSource = 0xffff; - - while ( uSubsubeventSource != 0x5555 ) - { - uSubsubeventData = tCurrentSubevent->Data(uSubsubeventDataIndex); - uSubsubeventSource = uSubsubeventData & 0xffff; - - UInt_t uSubsubeventLength = (uSubsubeventData >> 16) & 0xffff; - Bool_t bKnownSubsubevent = fMbsUnpackPar->IsTrbFpgaInData(uSubsubeventSource); - - UInt_t uMotherBoardId = 0xffff; - - if( bKnownSubsubevent ) - { - uMotherBoardId = fMbsUnpackPar->GetTrbSebAddrForFpga(uSubsubeventSource); - } - - LOG(debug); - - if( 0x0 == (uSubsubeventSource>>12) ) - { - uNbSubsubevents++; - - LOG(debug)<<"====================================="; - LOG(debug)<<Form("= HADAQ raw TDC subsubevent 0x%.4x =",uSubsubeventSource); - LOG(debug)<<"====================================="; - LOG(debug)<<"size: "<<Form("%u B",(uSubsubeventLength+1)*4); - LOG(debug)<<"data words: "<<Form("%u",uSubsubeventLength); - LOG(debug)<<"trigger tag: "<<Form("0x%.2x",(tCurrentSubevent->Data(uSubsubeventDataIndex+1)>>16)&0xff); - LOG(debug)<<"====================================="; - if( bKnownSubsubevent && bKnownSubevent) - { - LOG(debug)<<Form("registered FPGA on TRB 0x%.4x", uMotherBoardId); - LOG(debug)<<"====================================="; - LOG(debug); - - if(gLogger->IsLogNeeded(fair::Severity::debug2) ) - { - for(UInt_t uWord = uSubsubeventDataIndex; uWord <= uSubsubeventDataIndex+uSubsubeventLength; uWord++) - { - LOG(debug2)<<Form("0x%.8x",tCurrentSubevent->Data(uWord)); - } - - LOG(debug2); - } - - if( uSubeventId != uMotherBoardId ) - { - LOG(fatal)<<Form("Severe error in parameter file. FPGA 0x%.4x is the data transmitter of FPGA 0x%.4x, not FPGA 0x%.4x. Abort program execution!", - uSubeventId, uSubsubeventSource, uMotherBoardId); - } - - Int_t iActiveTdcIndex = fMbsUnpackPar->GetActiveTrbTdcIndex( uSubsubeventSource ); - fTdcUnpackMap[iActiveTdcIndex] = std::pair<hadaq::RawSubevent*,UInt_t>(tCurrentSubevent, uSubsubeventDataIndex); - fTrbTdcWords[iActiveTdcIndex]->Fill(uSubsubeventLength); - -// fTrbTdcProcessStatus[ iActiveTdcIndex ]->Fill( fTrbTdcUnpacker->ProcessData( tCurrentSubevent, uSubsubeventDataIndex ) ); - - } - else - { - LOG(debug)<<Form("unregistered FPGA"); - LOG(debug)<<"====================================="; - LOG(debug); - - if(gLogger->IsLogNeeded(fair::Severity::debug2) ) - { - for(UInt_t uWord = uSubsubeventDataIndex; uWord <= uSubsubeventDataIndex+uSubsubeventLength; uWord++) - { - LOG(debug2)<<Form("0x%.8x",tCurrentSubevent->Data(uWord)); - } - - LOG(debug2); - } - - } - } - - else if( 0xb == (uSubsubeventSource>>12) ) - { - uNbSubsubevents++; - - LOG(debug)<<"====================================="; - LOG(debug)<<Form("= HADAQ raw Hub subsubevent 0x%.4x =",uSubsubeventSource); - LOG(debug)<<"====================================="; - LOG(debug)<<"size: "<<Form("%u B",(uSubsubeventLength+1)*4); - LOG(debug)<<"data words: "<<Form("%u",uSubsubeventLength); - LOG(debug)<<"====================================="; - if( bKnownSubsubevent && bKnownSubevent) - { - LOG(debug)<<Form("registered FPGA on TRB 0x%.4x", uMotherBoardId); - LOG(debug)<<"====================================="; - LOG(debug); - if( uSubeventId != uMotherBoardId ) - { - LOG(fatal)<<Form("Severe error in parameter file. FPGA 0x%.4x is the data transmitter of FPGA 0x%.4x, not FPGA 0x%.4x. Abort program execution!", - uSubeventId, uSubsubeventSource, uMotherBoardId); - } - } - else - { - LOG(debug)<<Form("unregistered FPGA"); - LOG(debug)<<"====================================="; - LOG(debug); - } - - LOG(debug2)<<Form("0x%.8x",tCurrentSubevent->Data(uSubsubeventDataIndex)); - - UInt_t uHubSubeventDataIndex = uSubsubeventDataIndex+1; - UInt_t uHubEventLength = uSubsubeventLength; - - while ( uHubEventLength ) - { - UInt_t uHubSubeventData = tCurrentSubevent->Data(uHubSubeventDataIndex); - UInt_t uHubSubeventSource = uHubSubeventData & 0xffff; - UInt_t uHubSubeventLength = (uHubSubeventData >> 16) & 0xffff; - - Bool_t bKnownHubSubevent = fMbsUnpackPar->IsTrbFpgaInData(uHubSubeventSource); - - if( bKnownHubSubevent && bKnownSubsubevent ) - { - uMotherBoardId = fMbsUnpackPar->GetTrbSebAddrForFpga(uHubSubeventSource); - } - - LOG(debug); - - if( 0x0 == (uHubSubeventSource>>12) ) - { - uNbSubsubevents++; - - LOG(debug)<<"====================================="; - LOG(debug)<<Form("= HADAQ raw TDC hubsubevent 0x%.4x =",uHubSubeventSource); - LOG(debug)<<"====================================="; - LOG(debug)<<"size: "<<Form("%u B",(uHubSubeventLength+1)*4); - LOG(debug)<<"data words: "<<Form("%u",uHubSubeventLength); - LOG(debug)<<"trigger tag: "<<Form("0x%.2x",(tCurrentSubevent->Data(uHubSubeventDataIndex+1)>>16)&0xff); - LOG(debug)<<"====================================="; - if( bKnownHubSubevent && bKnownSubsubevent ) - { - LOG(debug)<<Form("registered FPGA on TRB 0x%.4x", uMotherBoardId); - LOG(debug)<<"====================================="; - LOG(debug); - - if(gLogger->IsLogNeeded(fair::Severity::debug2) ) - { - for(UInt_t uWord = uHubSubeventDataIndex; uWord <= uHubSubeventDataIndex+uHubSubeventLength; uWord++) - { - LOG(debug2)<<Form("0x%.8x",tCurrentSubevent->Data(uWord)); - } - - LOG(debug2); - } - - if( uSubeventId != uMotherBoardId ) - { - LOG(fatal)<<Form("Severe error in parameter file. FPGA 0x%.4x is the data transmitter of FPGA 0x%.4x, not FPGA 0x%.4x. Abort program execution!", - uSubeventId, uHubSubeventSource, uMotherBoardId); - } - - Int_t iActiveTdcIndex = fMbsUnpackPar->GetActiveTrbTdcIndex( uHubSubeventSource ); - fTdcUnpackMap[iActiveTdcIndex] = std::pair<hadaq::RawSubevent*,UInt_t>(tCurrentSubevent, uHubSubeventDataIndex); - fTrbTdcWords[iActiveTdcIndex]->Fill(uHubSubeventLength); - -// fTrbTdcProcessStatus[ iActiveTdcIndex ]->Fill( fTrbTdcUnpacker->ProcessData( tCurrentSubevent, uHubSubeventDataIndex ) ); - - } - else - { - LOG(debug)<<Form("unregistered FPGA"); - LOG(debug)<<"====================================="; - LOG(debug); - - if(gLogger->IsLogNeeded(fair::Severity::debug2) ) - { - for(UInt_t uWord = uHubSubeventDataIndex; uWord <= uHubSubeventDataIndex+uHubSubeventLength; uWord++) - { - LOG(debug2)<<Form("0x%.8x",tCurrentSubevent->Data(uWord)); - } - - LOG(debug2); - } - - } - - } - else if( 0x8 == (uHubSubeventSource>>12) ) - { - uNbSubsubevents++; - - LOG(debug)<<"====================================="; - LOG(debug)<<Form("= HADAQ raw Hub hubsubevent 0x%.4x =",uHubSubeventSource); - LOG(debug)<<"====================================="; - LOG(debug)<<"size: "<<Form("%u B",(uHubSubeventLength+1)*4); - LOG(debug)<<"data words: "<<Form("%u",uHubSubeventLength); - LOG(debug)<<"====================================="; - if( bKnownHubSubevent && bKnownSubsubevent ) - { - LOG(debug)<<Form("registered central hub on slave TRB"); - LOG(debug)<<"====================================="; - LOG(debug); - - if(gLogger->IsLogNeeded(fair::Severity::debug2) ) - { - for(UInt_t uWord = uHubSubeventDataIndex; uWord <= uHubSubeventDataIndex+uHubSubeventLength; uWord++) - { - LOG(debug2)<<Form("0x%.8x",tCurrentSubevent->Data(uWord)); - } - } - - if( uSubeventId != uMotherBoardId ) - { - LOG(fatal)<<Form("Severe error in parameter file. FPGA 0x%.4x is the data transmitter of FPGA 0x%.4x, not FPGA 0x%.4x. Abort program execution!", - uSubeventId, uHubSubeventSource, uMotherBoardId); - } - } - else - { - LOG(debug)<<Form("unregistered central hub on slave TRB"); - LOG(debug)<<"====================================="; - LOG(debug); - - if(gLogger->IsLogNeeded(fair::Severity::debug2) ) - { - for(UInt_t uWord = uHubSubeventDataIndex; uWord <= uHubSubeventDataIndex+uHubSubeventLength; uWord++) - { - LOG(debug2)<<Form("0x%.8x",tCurrentSubevent->Data(uWord)); - } - } - } - - } - else - { - uNbSubsubevents++; - - LOG(warn)<<"====================================="; - LOG(warn)<<Form("= Unknown hubsubevent type 0x%.4x =",uHubSubeventSource); - LOG(warn)<<"====================================="; - LOG(debug)<<"size: "<<Form("%u B",(uHubSubeventLength+1)*4); - LOG(debug)<<"data words: "<<Form("%u",uHubSubeventLength); - LOG(debug)<<"====================================="; - - if(gLogger->IsLogNeeded(fair::Severity::debug2) ) - { - for(UInt_t uWord = uHubSubeventDataIndex; uWord <= uHubSubeventDataIndex+uHubSubeventLength; uWord++) - { - LOG(debug2)<<Form("0x%.8x",tCurrentSubevent->Data(uWord)); - } - } - - } - - uHubSubeventDataIndex += uHubSubeventLength+1; - uHubEventLength -= uHubSubeventLength+1; - - } - } - - else if( 0xc == (uSubsubeventSource>>12) ) - { - uNbSubsubevents++; - - fbCtsAvailable = kTRUE; - - UInt_t uNbInputCh = (tCurrentSubevent->Data(uSubsubeventDataIndex+1) >> 16) & 0xf; - UInt_t uNbTrigCh = (tCurrentSubevent->Data(uSubsubeventDataIndex+1) >> 20) & 0x1f; - Bool_t bIncludeLastIdle = (tCurrentSubevent->Data(uSubsubeventDataIndex+1) >> 25) & 0x1; - Bool_t bIncludeCounters = (tCurrentSubevent->Data(uSubsubeventDataIndex+1) >> 26) & 0x1; - Bool_t bIncludeTimestamp = (tCurrentSubevent->Data(uSubsubeventDataIndex+1) >> 27) & 0x1; - UInt_t uExtTrigFlag = (tCurrentSubevent->Data(uSubsubeventDataIndex+1) >> 28) & 0x3; - - Bool_t bIncludeMbsSync = kFALSE; - UInt_t uMbsSync = 0xffffff; - Bool_t bMbsSyncError = kFALSE; - - UInt_t uNbCtsWords = uNbInputCh*2 - +uNbTrigCh*2 - +bIncludeLastIdle*2 - +bIncludeCounters*3 - +bIncludeTimestamp*1; - - UInt_t uBusyIdleOffset = uSubsubeventDataIndex + 2 + uNbInputCh*2 + uNbTrigCh*2; - UInt_t uStatsOffset = uBusyIdleOffset + bIncludeLastIdle*2; - UInt_t uTimeStampOffset = uStatsOffset + bIncludeCounters*3; - - - // Moving all the HADAQ time calculations here to make sure that only - // good events with a CTS subsubevent are considered. - Int_t iHadaqCurrentEventTime = (tCurrentEvent->GetTime()&0xff) - +60*((tCurrentEvent->GetTime()&0xff00)>>8) - +3600*(tCurrentEvent->GetTime()>>16); - - // time offset of the first valid event in a run - if( 0 == fiNbEvents ) - { - fiHadaqFirstEventTime = iHadaqCurrentEventTime; - } - - // allow for unambiguous, consecutive time stamping of events for between 24h and 48h of data taking per run - // (1 overflow from 23:59:59 to 00:00:00 can be taken into account without duplicating time stamps when - // not keeping track of the number of overflows) - if( 0 > (iHadaqCurrentEventTime - fiHadaqLastEventTime) ) - { - iHadaqCurrentEventTime += 86400; - } - - fHadaqEventTime->Fill(iHadaqCurrentEventTime - fiHadaqFirstEventTime); - - // start of a new HADAQ spill: at least 2 seconds time difference to the preceding event - if( 1 < (iHadaqCurrentEventTime - fiHadaqLastEventTime) ) - { - fiHadaqCoarseSpillStartTime = iHadaqCurrentEventTime; - fHadaqTimeInSpill->Reset("ICE"); - } - - fiCurrentEventNumber = static_cast<Int_t>(((tCurrentSubevent->GetTrigNr()) >> 8) & 0xFFFF) - fiFirstEventNumber + fiEventNumberOverflows*65536; - if( 0 < fiNbEvents ) - { - // FIXME: trigger number wrapping in Nov15 - if( 0 > (fiCurrentEventNumber - fiPreviousEventNumber) ) - { - LOG(error)<<Form("previous: 0x%.6x",fiPreviousEventNumber); - LOG(error)<<Form("current : 0x%.6x",fiCurrentEventNumber); - - fiCurrentEventNumber += 65536; - fiEventNumberOverflows++; - } - - fTrbEventNumberJump->Fill(fiCurrentEventNumber - fiPreviousEventNumber); - } - else - { - fiFirstEventNumber = fiCurrentEventNumber; - fiCurrentEventNumber = 0; - } - - - if( bIncludeLastIdle ) - { - UInt_t uBusyTime = tCurrentSubevent->Data(uBusyIdleOffset+1); - - // time [us] to complete the TrbNet trigger process in the last event - fCtsBusyTime->Fill( uBusyTime/100. ); - - UInt_t uIdleTime = tCurrentSubevent->Data(uBusyIdleOffset); - - // time [us] passed since the last trigger procession - fCtsIdleTime->Fill( uIdleTime/100. ); - - // CTS idle for less than 1 second - if( 1. > uIdleTime/100000000. ) - { - fCtsTriggerDistance->Fill( (uBusyTime+uIdleTime)/100.); - } - - if(1 == (fiCurrentEventNumber - fiPreviousEventNumber)) - { - fTrbHeader->SetCTSBusyTime(uBusyTime/100.); - fTrbHeader->SetCTSIdleTime(uIdleTime/100.); - } - } - - // fill previous event data into the output tree before TrbHeader information is overwritten - CheckEventBuffer(); - - fTrbHeader->SetEventDAQDate(tCurrentEvent->GetDate()); - fTrbHeader->SetEventDAQTime(tCurrentEvent->GetTime()); - fTrbHeader->SetTriggerIndex(fiCurrentEventNumber); - - fTrbHeader->SetTimeInSpill(static_cast<Double_t>(iHadaqCurrentEventTime-fiHadaqCoarseSpillStartTime)); - - fHadaqTimeInSpill->Fill(fTrbHeader->GetTimeInSpill()); - - - UInt_t uTrigStatus = tCurrentSubevent->Data(uSubsubeventDataIndex+1) & 0xffff; - uTriggerPattern = uTrigStatus; - - for(UInt_t uChannel = 0; uChannel < 16; uChannel++) - { - if( uTriggerPattern & (0x1 << uChannel) ) - { - fTrbTriggerPattern->Fill(TMath::Log2( uTriggerPattern & (0x1 << uChannel) )); - } - } - - fTrbTriggerType->Fill(uTriggerType); - - fTrbHeader->SetTriggerPattern(uTriggerPattern); - fTrbHeader->SetTriggerType(uTriggerType); - - - Long64_t iAllTriggersDiff(0); - Long64_t iAllEventsDiff(0); - - if( bIncludeCounters ) - { - Long64_t iAllTriggersCounter = (Long64_t)tCurrentSubevent->Data(uStatsOffset+1) + fliAllPossibleTriggersOverflows*4294967296; - Long64_t iAllEventsCounter = (Long64_t)tCurrentSubevent->Data(uStatsOffset+2) + fliAcceptedTriggersOverflows*4294967296; - - iAllTriggersDiff = iAllTriggersCounter - fiAllPossibleTriggers; - if( 0 > iAllTriggersDiff ) - { - iAllTriggersDiff += 4294967296; - fliAllPossibleTriggersOverflows++; - } - - iAllEventsDiff = iAllEventsCounter - fiAcceptedTriggers; - if( 0 > iAllEventsDiff ) - { - iAllEventsDiff += 4294967296; - fliAcceptedTriggersOverflows++; - } - - LOG(debug)<<Form("In total, %lld trigger opportunities (10 ns sampling) have been counted since the last event.", iAllTriggersDiff); - LOG(debug)<<Form("In total, %lld events have been triggered since the last event.", iAllEventsDiff); - LOG(debug); - - if( 0 < fiNbEvents ) - { - fItcAssertions->Fill(iAllTriggersDiff); - fItcEvents->Fill(iAllEventsDiff); - } - - fiAllPossibleTriggers = (Long64_t)tCurrentSubevent->Data(uStatsOffset+1) + fliAllPossibleTriggersOverflows*4294967296; - fiAcceptedTriggers = (Long64_t)tCurrentSubevent->Data(uStatsOffset+2) + fliAcceptedTriggersOverflows*4294967296; - } - - if( bIncludeTimestamp ) - { - Long64_t iCurrentTimeStamp = (Long64_t)tCurrentSubevent->Data(uTimeStampOffset); - -/* ############################################################################# -// works reliably only for nov15 data -// more robust than the version covering both feb15 and nov15 - - if( fbNextSpillToStart || (0 == fiNbEvents) ) - { - fiCtsFirstEventTime = iCurrentTimeStamp; - fiCtsLastEventTime = 0; - fiHadaqSpillStartTime = iHadaqCurrentEventTime - fiHadaqFirstEventTime; - iAllTriggersDiff = 0; - iAllEventsDiff = 0; - - fbNextSpillToStart = kFALSE; - } - - if( 10 < (iHadaqCurrentEventTime - fiHadaqLastEventTime) ) - { - fbNextSpillToStart = kTRUE; - } - ########################################################################### */ -// seems to work for both feb15 and nov15 data -// more assumptions necessary, less robust - - if( 0 == fiNbEvents ) - { - fiCtsFirstEventTime = iCurrentTimeStamp; - fiCtsLastEventTime = 0; - fiHadaqSpillStartTime = iHadaqCurrentEventTime - fiHadaqFirstEventTime; - iAllTriggersDiff = 0; - iAllEventsDiff = 0; - - // seemingly a HADAQ buffer delay can already exist at the beginning of a run! - fbHadaqBufferDelay = kTRUE; - } - else - { - // start of a new HADAQ spill: at least 2 seconds time difference to the preceding one - if( 1 < (iHadaqCurrentEventTime - fiHadaqLastEventTime) ) - { - // no HADAQ buffer delay has been observed - if( !fbHadaqBufferDelay ) - { - // compare the current CTS time to the value in the previous event - Long64_t iTimeInSpill = iCurrentTimeStamp - fiCtsFirstEventTime; - - if( 0 > iTimeInSpill ) - { - iTimeInSpill += 4294967296; - } - - // event most probably belongs to the preceding spill - if( 1000*100000 > (iTimeInSpill-fiCtsLastEventTime) ) - { - fbHadaqBufferDelay = kTRUE; - } - // event most probably starts a new spill - else - { - fiCtsFirstEventTime = iCurrentTimeStamp; - fiCtsLastEventTime = 0; - fiHadaqSpillStartTime = iHadaqCurrentEventTime - fiHadaqFirstEventTime; - iAllTriggersDiff = 0; - iAllEventsDiff = 0; - - fCtsTimeInSpill->Reset("ICE"); - } - } - // a HADAQ buffer delay is propagating - else - { - fiCtsFirstEventTime = iCurrentTimeStamp; - fiCtsLastEventTime = 0; - fiHadaqSpillStartTime = fiHadaqLastEventTime - fiHadaqFirstEventTime; - iAllTriggersDiff = 0; - iAllEventsDiff = 0; - - fCtsTimeInSpill->Reset("ICE"); - } - } - // somewhere inside a HADAQ spill - else - { - // first event following a series of delayed HADAQ buffers - if( fbHadaqBufferDelay ) - { - fiCtsFirstEventTime = iCurrentTimeStamp; - fiCtsLastEventTime = 0; - // correct spill start time w.r.t. the HADAQ buffer delay - fiHadaqSpillStartTime = fiHadaqLastEventTime - fiHadaqFirstEventTime; - iAllTriggersDiff = 0; - iAllEventsDiff = 0; - - fCtsTimeInSpill->Reset("ICE"); - - // HADAQ buffer delay propagation should stop here - fbHadaqBufferDelay = kFALSE; - } - } - } -// ############################################################################# - - Long64_t iTimeInSpill = iCurrentTimeStamp - fiCtsFirstEventTime; - - if( 0 > iTimeInSpill ) - { - iTimeInSpill += 4294967296; - } - - if( bIncludeCounters ) - { - if( 0 == fiCtsLastEventTime ) - { - LOG(debug)<<Form("time to origin: %f. event: %u",fiHadaqSpillStartTime*1. + (Double_t)(fiCtsLastEventTime + iTimeInSpill)/2./100000000.,fiNbEvents); - LOG(debug)<<Form("timestamp value: %lld",iCurrentTimeStamp); - LOG(debug)<<Form("idle time: %u",tCurrentSubevent->Data(uBusyIdleOffset)); - } - - fCtsTriggerCycles->Fill(fiHadaqSpillStartTime*1. + (Double_t)(fiCtsLastEventTime + iTimeInSpill)/2./100000000., iAllTriggersDiff); - fCtsTriggerAccepted->Fill(fiHadaqSpillStartTime*1. + (Double_t)(fiCtsLastEventTime + iTimeInSpill)/2./100000000., iAllEventsDiff); - fHadaqEventsRecorded->Fill(fiHadaqSpillStartTime*1. + (Double_t)(fiCtsLastEventTime + iTimeInSpill)/2./100000000., 1); - } - - if(fbFineSpillTiming) - { - fTrbHeader->SetTimeInSpill(static_cast<Double_t>(iTimeInSpill)/100000000.); - } - - fCtsTimeInSpill->Fill((Double_t)iTimeInSpill/100000.); - fEventSkipsInSpill->Fill((Double_t)iTimeInSpill/100000000., fiCurrentEventNumber - fiPreviousEventNumber - 1); - - fiCtsLastEventTime = iTimeInSpill; - } - - - /* Uncomment the following block of code to display [DEBUG2] the difference of assertion cycle and rising edge - counters of the trigger input modules (IM) and the iternal trigger channels (ITC) compared to the previous event. - As of 2016-01-22, most counter values written into the CTS subsubevent are not meaningful due to a firmware bug. - In the CTS GUI, the counter values are correct (polled via the slow-control channel of TrbNet). - */ - -/* - UInt_t uTrigInpOffset = uSubsubeventDataIndex + 2; - UInt_t uTrigCntOffset = uTrigInpOffset + uNbInputCh*2; - - UInt_t uTrigInpEdgeDiffsSum(0); - UInt_t uTrigInpClockDiffsSum(0); - - for( UInt_t uInput = 0; uInput < uNbInputCh; uInput++ ) - { - - UInt_t uTrigInpClockDiff = tCurrentSubevent->Data( uTrigInpOffset + 2*uInput ) - fuTrigInputClockCounter[uInput]; - uTrigInpClockDiffsSum += uTrigInpClockDiff; - fuTrigInputClockCounter[uInput] = tCurrentSubevent->Data( uTrigInpOffset + 2*uInput ); - - LOG(debug2)<<Form("Input Module %u: %u clock cycles since the last event.",uInput,uTrigInpClockDiff); - - } - - for( UInt_t uInput = 0; uInput < uNbInputCh; uInput++ ) - { - UInt_t uTrigInpEdgeDiff = tCurrentSubevent->Data( uTrigInpOffset + 1 + 2*uInput ) - fuTrigInputEdgeCounter[uInput]; - uTrigInpEdgeDiffsSum += uTrigInpEdgeDiff; - fuTrigInputEdgeCounter[uInput] = tCurrentSubevent->Data( uTrigInpOffset + 1 + 2*uInput ); - - LOG(debug2)<<Form("Input Module %u: %u rising edges since the last event.",uInput,uTrigInpEdgeDiff); - - } - - UInt_t uTrigChanEdgeDiffsSum(0); - UInt_t uTrigChanClockDiffsSum(0); - - for( UInt_t uChannel = 0; uChannel < uNbTrigCh; uChannel++ ) - { - - UInt_t uTrigChanClockDiff = tCurrentSubevent->Data( uTrigCntOffset + 2*uChannel ) - fuTrigChanClockCounter[uChannel]; - uTrigChanClockDiffsSum += uTrigChanClockDiff; - fuTrigChanClockCounter[uChannel] = tCurrentSubevent->Data( uTrigCntOffset + 2*uChannel ); - - LOG(debug2)<<Form("ITC %u: %u clock cycles since the last event.",uChannel,uTrigChanClockDiff); - - } - - for( UInt_t uChannel = 0; uChannel < uNbTrigCh; uChannel++ ) - { - UInt_t uTrigChanEdgeDiff = tCurrentSubevent->Data( uTrigCntOffset + 1 + 2*uChannel ) - fuTrigChanEdgeCounter[uChannel]; - uTrigChanEdgeDiffsSum += uTrigChanEdgeDiff; - fuTrigChanEdgeCounter[uChannel] = tCurrentSubevent->Data( uTrigCntOffset + 1 + 2*uChannel ); - - LOG(debug2)<<Form("ITC %u: %u rising edges since the last event.",uChannel,uTrigChanEdgeDiff); - - } - -*/ - - if( 0x1 == uExtTrigFlag ) - { - bIncludeMbsSync = kTRUE; - uMbsSync = tCurrentSubevent->Data(uSubsubeventDataIndex+2+uNbCtsWords) & 0xffffff; - bMbsSyncError = tCurrentSubevent->Data(uSubsubeventDataIndex+2+uNbCtsWords) & 0x80000000; - } - - LOG(debug)<<"====================================="; - LOG(debug)<<Form("= HADAQ raw CTS subsubevent 0x%.4x =",uSubsubeventSource); - LOG(debug)<<"====================================="; - LOG(debug)<<"size: "<<Form("%u B",(uSubsubeventLength+1)*4); - LOG(debug)<<"data words: "<<Form("%u",uSubsubeventLength); - LOG(debug)<<"ITC status: "<<Form("%.4x",uTrigStatus); - LOG(debug)<<"input channels: "<<Form("%u",uNbInputCh); - LOG(debug)<<"ITC counters: "<<Form("%u",uNbTrigCh); - if( bIncludeMbsSync ) - { - LOG(debug)<<"CBM/MBS sync: "<<Form("%.6x",uMbsSync); - if( bMbsSyncError ) - { - LOG(debug)<<"sync error!!! "; - } - } - LOG(debug)<<"====================================="; - if( bKnownSubsubevent && bKnownSubevent ) - { - LOG(debug)<<Form("registered FPGA on TRB 0x%.4x", uMotherBoardId); - LOG(debug)<<"====================================="; - LOG(debug); - - if(gLogger->IsLogNeeded(fair::Severity::debug2) ) - { - for(UInt_t uWord = uSubsubeventDataIndex; uWord <= uSubsubeventDataIndex+uSubsubeventLength; uWord++) - { - LOG(debug2)<<Form("0x%.8x",tCurrentSubevent->Data(uWord)); - } - } - - if( uSubeventId != uMotherBoardId ) - { - LOG(fatal)<<Form("Severe error in parameter file. FPGA 0x%.4x is the data transmitter of FPGA 0x%.4x, not FPGA 0x%.4x. Abort program execution!", - uSubeventId, uSubsubeventSource, uMotherBoardId); - } - } - else - { - LOG(debug)<<Form("unregistered FPGA"); - LOG(debug)<<"====================================="; - LOG(debug); - - if(gLogger->IsLogNeeded(fair::Severity::debug2) ) - { - for(UInt_t uWord = uSubsubeventDataIndex; uWord <= uSubsubeventDataIndex+uSubsubeventLength; uWord++) - { - LOG(debug2)<<Form("0x%.8x",tCurrentSubevent->Data(uWord)); - } - } - - } - - // Regardless of the trigger evaluation result this event contains valid CTS information that can be - // used for time-in-spill calculations etc. - fiNbEvents++; - - fiPreviousEventNumber = fiCurrentEventNumber; - - fiHadaqLastEventTime = iHadaqCurrentEventTime; - - // Trigger pattern evaluation - if( !fMbsUnpackPar->IsTrbEventUnpacked(uTriggerPattern) ) - { - LOG(info)<<"HADAQ raw event does not meet the trigger selection criteria. Skip it."; - CheckEventBuffer(); - return kFALSE; - } - - } - - else if(0x5555 == uSubsubeventSource) - { - LOG(debug)<<"====================================="; - LOG(debug)<<Form("= HADAQ raw END subsubevent 0x%.4x =",uSubsubeventSource); - LOG(debug)<<"====================================="; - LOG(debug)<<"size: "<<Form("%u B",(uSubsubeventLength+1)*4); - LOG(debug)<<"data words: "<<Form("%u",uSubsubeventLength); - LOG(debug)<<"====================================="; - } - - else - { - uNbSubsubevents++; - - LOG(debug)<<"====================================="; - LOG(debug)<<Form("= Unknown subsubevent type 0x%.4x =",uSubsubeventSource); - LOG(debug)<<"====================================="; - LOG(debug)<<"size: "<<Form("%u B",(uSubsubeventLength+1)*4); - LOG(debug)<<"data words: "<<Form("%u",uSubsubeventLength); - LOG(debug)<<"====================================="; - - if(gLogger->IsLogNeeded(fair::Severity::debug2) ) - { - for(UInt_t uWord = uSubsubeventDataIndex; uWord <= uSubsubeventDataIndex+uSubsubeventLength; uWord++) - { - LOG(debug2)<<Form("0x%.8x",tCurrentSubevent->Data(uWord)); - } - } - - } - - uSubsubeventDataIndex += uSubsubeventLength+1; - uNbSubsubeventDataWords -= uSubsubeventLength+1; - } - - LOG(debug); - LOG(debug)<<Form("%u subsubevents identified in subevent 0x%.4x.", uNbSubsubevents, uSubeventId); - if( bKnownSubevent ) - { - LOG(debug)<<Form("%u subsubevents expected according to the parameter file.", uNbRegisteredFpgas); - } - - LOG(debug); - - } - - if( !fbCtsAvailable ) - { - LOG(error)<<"No CTS subsubevent available. Skip the full HADAQ raw event."; - CheckEventBuffer(); - return kFALSE; - } - - Bool_t bSkipHadaqEvent = kFALSE; - - // TDC data unpacking only in case of a positive trigger pattern evaluation - for ( std::map<Int_t,std::pair<hadaq::RawSubevent*,UInt_t> >::iterator it = fTdcUnpackMap.begin(); - it != fTdcUnpackMap.end(); - ++it) - { - Int_t iTdcUnpackStatus = fTrbTdcUnpacker->ProcessData( (it->second).first, (it->second).second ); - fTrbTdcProcessStatus[ it->first ]->Fill( iTdcUnpackStatus ); - - if( (trbtdc::process_Success != iTdcUnpackStatus) && (trbtdc::process_BadFineTime != iTdcUnpackStatus) ) - { - bSkipHadaqEvent = kTRUE; - } - } - - if( bSkipHadaqEvent ) - { - LOG(info)<<"TDC raw data integrity not guaranteed. Skip the full HADAQ raw event."; - CheckEventBuffer(); - return kFALSE; - } - - LOG(debug); - - LOG(debug)<<Form("Total number of subevents in HADAQ raw event: %u", uNbSubevents); - LOG(debug)<<Form("The parameter file specifies %u active TRB subevent builders.", fMbsUnpackPar->GetActiveTrbSebNb()); - LOG(debug); - LOG(debug); - - delete fTrbIterator; - - fTrbHeader->SetSubeventSizes(fuSubeventSizes); - - fbGoodEventInBuffer = kTRUE; - // The following method call does unexpectedly not trigger the output tree - // to be filled with good buffered event data once again in - // 'FairRunOnline::Finish' as calling 'FairRootManager::StoreAllWriteoutBufferData' - // at the end of 'FairRunOnline::Run' invalidates 'FairRootManager::fFillLastData'. - // Instead, this needs to be taken care of in the steering run macro. - FairRootManager::Instance()->SetLastFill(kTRUE); - - return kTRUE; -} - -void TTrbUnpackTof::Reset() -{ - LOG(debug)<<"**** TTrbUnpackTof: Call Reset()... "; - -// ClearOutput(); -} - -void TTrbUnpackTof::Register() -{ - LOG(info)<<"**** TTrbUnpackTof: Call Register()..."; -} - -Bool_t TTrbUnpackTof::InitParameters() -{ - LOG(info)<<"**** TTrbUnpackTof: Call InitParameters()..."; - - FairRun * ana = FairRun::Instance(); - FairRuntimeDb * rtdb = ana->GetRuntimeDb(); - - ana->MarkFill(kFALSE); - - fMbsUnpackPar = (TMbsUnpackTofPar *) (rtdb->getContainer("TMbsUnpackTofPar")); - - if( fbInspection ) - { - fMbsCalibPar = (TMbsCalibTofPar *) (rtdb->getContainer("TMbsCalibTofPar")); - } - - if( 0 == fMbsUnpackPar || ( fbInspection && !fMbsCalibPar ) ) - return kFALSE; - - fMbsUnpackPar->printParams(); - - fuInDataTrbSebNb = fMbsUnpackPar->GetActiveTrbSebNb(); - fuActiveTrbTdcNb = fMbsUnpackPar->GetNbActiveBoards( tofMbs::trbtdc ); - - return kTRUE; -} - -Bool_t TTrbUnpackTof::CreateSubunpackers() -{ - LOG(info)<<"**** TTrbUnpackTof: Call CreateSubunpackers()..."; - - if( 0 == fuActiveTrbTdcNb ) - { - LOG(error)<<"**** TTrbUnpackTof: No active FPGA-TDCs!"; - return kFALSE; - } - else - { - fTrbTdcUnpacker = new TTofTrbTdcUnpacker( fMbsUnpackPar, fMbsCalibPar ); - fTrbTdcUnpacker->SetInspection(fbInspection); - } - - return kTRUE; -} - -Bool_t TTrbUnpackTof::RegisterOutput() -{ - LOG(info)<<"**** TTrbUnpackTof: Call RegisterOutput()..."; - - if( 0 == fuActiveTrbTdcNb ) - { - LOG(error)<<"**** TTrbUnpackTof: No active FPGA-TDCs!"; - return kFALSE; - } - - FairRootManager * manager = FairRootManager::Instance(); - manager->SetLastFill(kFALSE); - - fTrbTdcBoardCollection = new TClonesArray( "TTofTrbTdcBoard", fuActiveTrbTdcNb ); - manager->Register( "TofTrbTdc","TofUnpack", fTrbTdcBoardCollection, - fMbsUnpackPar->WriteDataInCbmOut() || fbSaveRawTdcBoards ); - - fTrbHeader = new TTrbHeader(); - manager->Register( "TofTrbHeader.","TofUnpack", fTrbHeader, kTRUE ); - - return kTRUE; -} -void TTrbUnpackTof::SetSaveRawData( Bool_t bSaveRaw ) -{ - fbSaveRawTdcBoards = bSaveRaw; - LOG(info)<<"TTrbUnpackTof => Enable the saving of raw trb data in analysis output file"; -} - -Bool_t TTrbUnpackTof::ClearOutput() -{ - LOG(debug)<<"**** TTrbUnpackTof: Call ClearOutput()..."; - - fTrbHeader->Clear(); - - if( 0 < fuActiveTrbTdcNb ) - fTrbTdcBoardCollection->Clear("C"); - -// fTdcUnpackMap.clear(); - - return kTRUE; -} - -void TTrbUnpackTof::CreateHistograms() -{ - LOG(debug)<<"**** TTrbUnpackTof: Call CreateHistograms()..."; - - TDirectory* oldir = gDirectory; - gROOT->cd(); - - fTrbTriggerPattern = new TH1I("tof_trb_trigger_pattern", "CTS trigger pattern", 16, 0, 16); - fTrbTriggerPattern->GetXaxis()->SetTitle("trigger pattern []"); - fTrbTriggerType = new TH1I("tof_trb_trigger_types", "CTS trigger types", 16, 0, 16); - fTrbTriggerType->GetXaxis()->SetTitle("trigger type []"); - fTrbEventNumberJump = new TH1I("tof_trb_event_jump", "CTS event number jumps", 100, 0, 100); - fTrbEventNumberJump->GetXaxis()->SetTitle("event counter increment []"); - fCtsBusyTime = new TH1I("tof_trb_cts_busy", "CTS busy time", 100, 0, 100); - fCtsBusyTime->GetXaxis()->SetTitle("busy time [#mus]"); - fCtsIdleTime = new TH1I("tof_trb_cts_idle", "CTS idle time", 200, 0, 200); - fCtsIdleTime->GetXaxis()->SetTitle("idle time [#mus]"); - fCtsIdleTimeSpill = new TH1I("tof_trb_cts_idle_spill", "TDC spill-break length", 100, 0, 100); - fCtsIdleTimeSpill->GetXaxis()->SetTitle("spill break [s]"); - fCtsSpillLength = new TH1I("tof_trb_cts_spill_length", "TDC spill length", 20, 0, 20); - fCtsSpillLength->GetXaxis()->SetTitle("spill length [s]"); - fCtsTriggerDistance = new TH1I("tof_trb_cts_cycle", "CTS trigger distance", 500, 0, 500); - fCtsTriggerDistance->GetXaxis()->SetTitle("trigger distance [#mus]"); - fItcAssertions = new TH1I("tof_trb_itc_assert", "All trigger cycles since last event", 200, 0, 200); - fItcAssertions->GetXaxis()->SetTitle("detected triggers []"); - fItcEvents = new TH1I("tof_trb_cts_events", "Accepted cycles since last event", 100, 0, 100); - fItcEvents->GetXaxis()->SetTitle("accepted triggers []"); - - // binning and range increased to cover run times of up to 6 hours - fHadaqEventTime = new TH1I("tof_trb_hadaq_time", "HADAQ event time", 20000, 0, 20000); - fHadaqEventTime->GetXaxis()->SetTitle("HADAQ event time [s]"); - - fCtsTriggerCycles = new TH1I("tof_trb_trigger_rate", "CTS trigger/event rate", 20000, 0, 20000); - fCtsTriggerCycles->GetXaxis()->SetTitle("CTS event time [s]"); - fCtsTriggerCycles->SetMarkerStyle(34); - fCtsTriggerCycles->SetMarkerColor(kRed); - fCtsTriggerCycles->SetLineColor(kRed); - - fCtsTriggerAccepted = new TH1I("tof_trb_event_rate", "CTS trigger/event rate", 20000, 0, 20000); - fCtsTriggerAccepted->GetXaxis()->SetTitle("CTS event time [s]"); - fCtsTriggerAccepted->SetMarkerStyle(34); - fCtsTriggerAccepted->SetMarkerColor(kGreen); - fCtsTriggerAccepted->SetLineColor(kGreen); - - fHadaqEventsRecorded = new TH1I("tof_trb_hadaq_rate", "CTS/HADAQ event rate", 20000, 0, 20000); - fHadaqEventsRecorded->GetXaxis()->SetTitle("CTS event time [s]"); - fHadaqEventsRecorded->SetMarkerStyle(34); - fHadaqEventsRecorded->SetMarkerColor(kBlue); - fHadaqEventsRecorded->SetLineColor(kBlue); - - fHadaqTimeInSpill = new TH1I("tof_hadaq_time_spill", "HADAQ coarse time in spill", 20, 0, 20); - fHadaqTimeInSpill->GetXaxis()->SetTitle("HADAQ time in spill [s]"); - - fCtsTimeInSpill = new TH1I("tof_cts_time_spill", "CTS fine time in spill", 20000, 0, 20000); - fCtsTimeInSpill->GetXaxis()->SetTitle("CTS time in spill [ms]"); - - fEventSkipsInSpill = new TH2I("tof_trb_skips_spill", "CTS events skipped in spill", 20, 0, 20, 100, 0, 100); - fEventSkipsInSpill->GetXaxis()->SetTitle("CTS event time in spill [s]"); - fEventSkipsInSpill->GetYaxis()->SetTitle("CTS events skipped"); - - TH1* hTemp = 0; - TH2* hTemp2 = 0; - - for( UInt_t uTrbSeb = 0; uTrbSeb < fuInDataTrbSebNb; uTrbSeb++ ) - { - UInt_t uTrbNetAddress = fMbsUnpackPar->GetTrbSebAddr(uTrbSeb); - - hTemp = new TH1I( Form("tof_trb_size_subevent_%03u", uTrbSeb), - Form("data sent by TRB-SEB 0x%04x", uTrbNetAddress), - 65, 0, 65); - hTemp->GetXaxis()->SetTitle("subevent size [kB]"); - - fTrbSubeventSize.push_back( hTemp ); - - hTemp = new TH1I( Form("tof_trb_status_subevent_%03u", uTrbSeb), - Form("status bits of TRB-SEB 0x%04x", uTrbNetAddress), - 32, 0, 32); - hTemp->GetXaxis()->SetTitle("TrbNet status bits []"); - - fTrbSubeventStatus.push_back( hTemp ); - - hTemp2 = new TH2F( Form("tof_trb_rate_subevent_%03u", uTrbSeb), - Form("data rate from TRB-SEB 0x%04x", uTrbNetAddress), - 100, 0., 100., 65, 0, 65); - - fTrbSubeventSizeRunTime.push_back( hTemp2 ); - } - - for( UInt_t uTrbTdc = 0; uTrbTdc < fuActiveTrbTdcNb; uTrbTdc++) - { - UInt_t uTrbNetAddress = fMbsUnpackPar->GetActiveTrbTdcAddr(uTrbTdc); - - hTemp = new TH1I( Form("tof_trb_words_tdc_%03u", uTrbTdc), - Form("words sent by TRB-TDC 0x%04x", uTrbNetAddress), - 4100, 0, 4100); - hTemp->GetXaxis()->SetTitle("subsubevent words [4 B]"); - - fTrbTdcWords.push_back( hTemp ); - - hTemp = new TH1I( Form("tof_trb_process_status_tdc_%03u", uTrbTdc), - Form("data processing status of TRB-TDC 0x%04x", uTrbNetAddress), - trbtdc::process_StatusMessages, 0, trbtdc::process_StatusMessages); - hTemp->GetXaxis()->SetTitle("TDC unpacking status []"); - - fTrbTdcProcessStatus.push_back( hTemp ); - } - - gDirectory->cd( oldir->GetPath() ); -} - -void TTrbUnpackTof::WriteHistograms() -{ - LOG(debug)<<"**** TTrbUnpackTof: Call WriteHistograms()..."; - - TDirectory* oldir = gDirectory; - - TFile* tHist = new TFile("./tofTrbUnp.hst.root","RECREATE"); - - fTrbTriggerPattern->Write(); - fTrbTriggerType->Write(); - fTrbEventNumberJump->Write(); - fCtsBusyTime->Write(); - fCtsIdleTime->Write(); - fCtsIdleTimeSpill->Write(); - fCtsSpillLength->Write(); - fCtsTriggerDistance->Write(); - fItcAssertions->Write(); - fItcEvents->Write(); - fHadaqEventTime->Write(); - fCtsTriggerCycles->Write(); - fCtsTriggerAccepted->Write(); - fHadaqEventsRecorded->Write(); - fHadaqTimeInSpill->Write(); - fCtsTimeInSpill->Write(); - fEventSkipsInSpill->Write(); - - for( UInt_t uTrbSeb = 0; uTrbSeb < fuInDataTrbSebNb; uTrbSeb++ ) - { - fTrbSubeventSize[uTrbSeb]->Write(); - fTrbSubeventStatus[uTrbSeb]->Write(); - fTrbSubeventSizeRunTime[uTrbSeb]->Write(); - } - - for( UInt_t uTrbTdc = 0; uTrbTdc < fuActiveTrbTdcNb; uTrbTdc++) - { - fTrbTdcWords[uTrbTdc]->Write(); - fTrbTdcProcessStatus[uTrbTdc]->Write(); - } - - gDirectory->cd( oldir->GetPath() ); - tHist->Close(); - delete tHist; -} - -void TTrbUnpackTof::DataErrorHandling(UInt_t uSubeventId, UInt_t uErrorPattern) -{ - // TrbNet network error and status bits - if (tofTrb::status_network_0 & uErrorPattern) - { - LOG(debug)<<Form("TrbNet network status: node replied to network request (%d) ",tofTrb::status_network_0); - fTrbSubeventStatus[ fMbsUnpackPar->GetTrbSebIndex( uSubeventId ) ]->Fill(TMath::Log2(tofTrb::status_network_0)); - } - if (tofTrb::status_network_1 & uErrorPattern) - { - LOG(error)<<"TrbNet network status: endpoint data collision"; - fTrbSubeventStatus[ fMbsUnpackPar->GetTrbSebIndex( uSubeventId ) ]->Fill(TMath::Log2(tofTrb::status_network_1)); - } - if (tofTrb::status_network_2 & uErrorPattern) - { - LOG(error)<<"TrbNet network status: incomplete data transfer between nodes"; - fTrbSubeventStatus[ fMbsUnpackPar->GetTrbSebIndex( uSubeventId ) ]->Fill(TMath::Log2(tofTrb::status_network_2)); - } - if (tofTrb::status_network_3 & uErrorPattern) - { - LOG(error)<<"TrbNet network status: check-sum mismatch on point-to-point link"; - fTrbSubeventStatus[ fMbsUnpackPar->GetTrbSebIndex( uSubeventId ) ]->Fill(TMath::Log2(tofTrb::status_network_3)); - } - if (tofTrb::status_network_4 & uErrorPattern) - { - LOG(error)<<"TrbNet network status: network request not understood by node"; - fTrbSubeventStatus[ fMbsUnpackPar->GetTrbSebIndex( uSubeventId ) ]->Fill(TMath::Log2(tofTrb::status_network_4)); - } - if (tofTrb::status_network_5 & uErrorPattern) - { - LOG(error)<<"TrbNet network status: I/O buffer packet count mismatch"; - fTrbSubeventStatus[ fMbsUnpackPar->GetTrbSebIndex( uSubeventId ) ]->Fill(TMath::Log2(tofTrb::status_network_5)); - } - if (tofTrb::status_network_6 & uErrorPattern) - { - LOG(error)<<"TrbNet network status: network transaction timeout"; - fTrbSubeventStatus[ fMbsUnpackPar->GetTrbSebIndex( uSubeventId ) ]->Fill(TMath::Log2(tofTrb::status_network_6)); - } - - // TrbNet readout error and status bits - if (tofTrb::status_readout_16 & uErrorPattern) - { - LOG(error)<<"TrbNet readout status: trigger number mismatch"; - fTrbSubeventStatus[ fMbsUnpackPar->GetTrbSebIndex( uSubeventId ) ]->Fill(TMath::Log2(tofTrb::status_readout_16)); - } - if (tofTrb::status_readout_17 & uErrorPattern) - { - LOG(error)<<"TrbNet readout status: trigger code mismatch"; - fTrbSubeventStatus[ fMbsUnpackPar->GetTrbSebIndex( uSubeventId ) ]->Fill(TMath::Log2(tofTrb::status_readout_17)); - } - if (tofTrb::status_readout_18 & uErrorPattern) - { - LOG(error)<<"TrbNet readout status: wrong data stream length"; - fTrbSubeventStatus[ fMbsUnpackPar->GetTrbSebIndex( uSubeventId ) ]->Fill(TMath::Log2(tofTrb::status_readout_18)); - } - if (tofTrb::status_readout_19 & uErrorPattern) - { - LOG(error)<<"TrbNet readout status: front-end failed to deliver any data"; - fTrbSubeventStatus[ fMbsUnpackPar->GetTrbSebIndex( uSubeventId ) ]->Fill(TMath::Log2(tofTrb::status_readout_19)); - } - if (tofTrb::status_readout_20 & uErrorPattern) - { - LOG(error)<<"TrbNet readout status: requested CTS trigger number not in front-end event data buffer"; - fTrbSubeventStatus[ fMbsUnpackPar->GetTrbSebIndex( uSubeventId ) ]->Fill(TMath::Log2(tofTrb::status_readout_20)); - } - if (tofTrb::status_readout_21 & uErrorPattern) - { - LOG(error)<<"TrbNet readout status: front-end data only partially sent"; - fTrbSubeventStatus[ fMbsUnpackPar->GetTrbSebIndex( uSubeventId ) ]->Fill(TMath::Log2(tofTrb::status_readout_21)); - } - if (tofTrb::status_readout_22 & uErrorPattern) - { - LOG(error)<<"TrbNet readout status: severe readout problem (TrbNet reset required)"; - fTrbSubeventStatus[ fMbsUnpackPar->GetTrbSebIndex( uSubeventId ) ]->Fill(TMath::Log2(tofTrb::status_readout_22)); - } - if (tofTrb::status_readout_23 & uErrorPattern) - { - LOG(error)<<"TrbNet readout status: single broken event"; - fTrbSubeventStatus[ fMbsUnpackPar->GetTrbSebIndex( uSubeventId ) ]->Fill(TMath::Log2(tofTrb::status_readout_23)); - } - if (tofTrb::status_readout_24 & uErrorPattern) - { - LOG(error)<<"TrbNet readout status: GbE link down"; - fTrbSubeventStatus[ fMbsUnpackPar->GetTrbSebIndex( uSubeventId ) ]->Fill(TMath::Log2(tofTrb::status_readout_24)); - } - if (tofTrb::status_readout_25 & uErrorPattern) - { - LOG(error)<<"TrbNet readout status: subevent buffer almost full"; - fTrbSubeventStatus[ fMbsUnpackPar->GetTrbSebIndex( uSubeventId ) ]->Fill(TMath::Log2(tofTrb::status_readout_25)); - } - if (tofTrb::status_readout_26 & uErrorPattern) - { - LOG(error)<<"TrbNet readout status: corrupted data detected by the subevent builder"; - fTrbSubeventStatus[ fMbsUnpackPar->GetTrbSebIndex( uSubeventId ) ]->Fill(TMath::Log2(tofTrb::status_readout_26)); - } - if (tofTrb::status_readout_27 & uErrorPattern) - { - LOG(error)<<"TrbNet readout status: reference time problem"; - fTrbSubeventStatus[ fMbsUnpackPar->GetTrbSebIndex( uSubeventId ) ]->Fill(TMath::Log2(tofTrb::status_readout_27)); - } - - return; -} - -void TTrbUnpackTof::CheckEventBuffer() -{ - // At all possible exit points of 'TTrbUnpackTof::DoUnpack' we need to check if a good event is available in - // the output tree buffers. If so, fill the event in the output tree. If not so, discard whatever data are in - // the buffers. - if(fbGoodEventInBuffer) - { - FillRunTimeHistograms(); - - FairRootManager::Instance()->Fill(); - FairRootManager::Instance()->SetLastFill(kFALSE); - - fbGoodEventInBuffer = kFALSE; - } - - ClearOutput(); - - return; -} - -void TTrbUnpackTof::FillRunTimeHistograms() -{ - for( Int_t uTrbSeb = 0; uTrbSeb < fTrbHeader->GetNSubevents(); uTrbSeb++ ) - { - fTrbSubeventSizeRunTime[uTrbSeb]->Fill(fTrbHeader->GetTimeInRun(), fTrbHeader->GetSubeventSize(uTrbSeb)/1000 ); - } -} diff --git a/beamtime/tof/TTrbUnpackTof.h b/beamtime/tof/TTrbUnpackTof.h deleted file mode 100644 index e49d6a42d543a68535e2271de52c8010668560af..0000000000000000000000000000000000000000 --- a/beamtime/tof/TTrbUnpackTof.h +++ /dev/null @@ -1,174 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- TTrbUnpackTof header file ----- -// ----- ----- -// ----- created by C. Simon on 2014-03-08 ----- -// ----- ----- -// ----- based on TTrbUnpackTof by P.-A. Loizeau ----- -// ----- https://subversion.gsi.de/fairroot/cbmroot/development/ploizeau/ ----- -// ----- main/unpack/tof/TTrbUnpackTof.h ----- -// ----- revision 21379, 2013-08-24 ----- -// ----------------------------------------------------------------------------- - -#ifndef TTRBUNPACKTOF_H -#define TTRBUNPACKTOF_H - -// STL -#include <map> -#include <utility> - -// General FairRoot unpacker of GSI/MBS events -#include "FairUnpack.h" -#include "TTrbHeader.h" - -// Parameters -class TMbsUnpackTofPar; -class TMbsCalibTofPar; - -// Iterator -namespace hadaq -{ - class TrbIterator; - struct RawSubevent; -} - -// Subunpacker -class TTofTrbTdcUnpacker; - -// ROOT -class TClonesArray; -class TH1; -class TH2; - -class TTrbUnpackTof : public FairUnpack -{ - public: - TTrbUnpackTof( Short_t type, Short_t subType, Short_t procId, Short_t subCrate, Short_t control); - virtual ~TTrbUnpackTof(); - - // FairUnpack pure virtual methods - virtual Bool_t Init(); - virtual Bool_t DoUnpack(Int_t* data, Int_t size); - virtual void Reset(); - - void WriteHistograms(); - - void SetFineSpillTiming(Bool_t bFineTiming = kTRUE) {fbFineSpillTiming = bFineTiming;} - void SetInspection(Bool_t bInspection = kTRUE) {fbInspection = bInspection;} - - void SetSaveRawData( Bool_t bSaveRaw=kTRUE ); - - Bool_t IsGoodEventInBuffer() {return fbGoodEventInBuffer;} - - protected: - // FairUnpack pure virtual method - // neither called by a FairSource daughter class nor by FairRunOnline - // why made pure virtual in FairUnpack? - virtual void Register(); - - private: - TTrbUnpackTof(const TTrbUnpackTof&); - TTrbUnpackTof operator=(const TTrbUnpackTof&); - - // Methods - Bool_t InitParameters(); - Bool_t CreateSubunpackers(); - Bool_t RegisterOutput(); - Bool_t ClearOutput(); - - void DataErrorHandling(UInt_t uSubeventId, UInt_t uErrorPattern); - - // Parameters - TMbsUnpackTofPar * fMbsUnpackPar; - TMbsCalibTofPar * fMbsCalibPar; - - Int_t fiNbEvents; - Int_t fiCurrentEventNumber; - Int_t fiPreviousEventNumber; - Int_t fiFirstEventNumber; - Int_t fiEventNumberOverflows; - - Bool_t fbFineSpillTiming; - Bool_t fbInspection; - - // Iterator - hadaq::TrbIterator * fTrbIterator; - - // Subunpacker - TTofTrbTdcUnpacker * fTrbTdcUnpacker; - - // Output objects - TClonesArray * fTrbTdcBoardCollection; - Bool_t fbSaveRawTdcBoards; - - // Map to delay TDC data unpacking until a decision is made based on the CTS trigger pattern - // key: active TDC index - // value: pair of hadaq rawsubevent pointer and subsubevent data index - // (input to TTofTrbTdcUnpacker::ProcessData) - std::map<Int_t,std::pair<hadaq::RawSubevent*,UInt_t> > fTdcUnpackMap; - - void CreateHistograms(); -// void DeleteHistograms(); - void FillRunTimeHistograms(); - - void CheckEventBuffer(); - - UInt_t fuInDataTrbSebNb; - UInt_t fuActiveTrbTdcNb; - - // Histograms - TH1* fTrbTriggerPattern; - TH1* fTrbTriggerType; - TH1* fCtsBusyTime; - TH1* fCtsIdleTime; - TH1* fCtsIdleTimeSpill; - TH1* fCtsSpillLength; - TH1* fCtsTriggerDistance; - TH1* fItcAssertions; - TH1* fItcEvents; - TH1* fHadaqEventTime; - TH1* fTrbEventNumberJump; - TH1* fCtsTriggerCycles; - TH1* fCtsTriggerAccepted; - TH1* fHadaqEventsRecorded; - TH1* fHadaqTimeInSpill; - TH1* fCtsTimeInSpill; - TH2* fEventSkipsInSpill; - TTrbHeader* fTrbHeader; - std::vector<TH1*> fTrbSubeventSize; - std::vector<TH1*> fTrbSubeventStatus; - std::vector<TH1*> fTrbTdcWords; - std::vector<TH1*> fTrbTdcProcessStatus; - - std::vector<TH2*> fTrbSubeventSizeRunTime; - - // CTS counters - UInt_t* fuTrigChanEdgeCounter; - UInt_t* fuTrigChanClockCounter; - UInt_t* fuTrigInputEdgeCounter; - UInt_t* fuTrigInputClockCounter; - Long64_t fiAllPossibleTriggers; - Long64_t fiAcceptedTriggers; - Long64_t fliAllPossibleTriggersOverflows; - Long64_t fliAcceptedTriggersOverflows; - - // HADAQ event timestamp - Int_t fiHadaqLastEventTime; - Int_t fiHadaqFirstEventTime; - Int_t fiHadaqSpillStartTime; - Int_t fiHadaqCoarseSpillStartTime; - - // CTS trigger timestamp - Long64_t fiCtsLastEventTime; - Long64_t fiCtsFirstEventTime; - Bool_t fbNextSpillToStart; - Bool_t fbHadaqBufferDelay; - - Bool_t fbCtsAvailable; - Bool_t fbGoodEventInBuffer; - - std::vector<UShort_t> fuSubeventSizes; - - ClassDef(TTrbUnpackTof,1) -}; - -#endif diff --git a/beamtime/tof/TTriglogUnpackTof.cxx b/beamtime/tof/TTriglogUnpackTof.cxx deleted file mode 100644 index a3b761b26807f8d842ee994382a5f22872563240..0000000000000000000000000000000000000000 --- a/beamtime/tof/TTriglogUnpackTof.cxx +++ /dev/null @@ -1,298 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TTriglogUnpackTof ----- -// ----- Created 07/07/2013 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ -#include "TTriglogUnpackTof.h" - -// SubEvent ProcId from ROC library -#include "commons.h" - -// General MBS headers -#include "TofDef.h" -#include "TMbsUnpackTofPar.h" - -// ToF specific headers -#include "TTofTriglogUnpacker.h" -#include "TTofTriglogBoard.h" -#include "TTofScalerBoard.h" - -// ROOT headers -#include "TClonesArray.h" -#include "TFile.h" -#include "TDatime.h" -#include "TROOT.h" -#include "TDirectory.h" - -// FAIR headers -#include "FairLogger.h" -//#include "FairRootManager.h" -#include "FairRunAna.h" -#include "FairRuntimeDb.h" - -TTriglogUnpackTof::TTriglogUnpackTof() : - FairUnpack( 10, 1, roc3587::proc_Triglog, 0, 9 ), - fiVerbosity(0), - fMbsUnpackPar(0), - fiNbEvents(0), - fiFirstEventNumber(0), - fiLastEventNumber(0), - fLastCheck(), - fCheck(), - fTriglogUnp(NULL), - fTriglogBoardCollection(NULL), - fScalerBoardCollection(NULL), - fbSaveTriglogBoard(kFALSE), - fbSaveScalerBoards(kFALSE) -{ -} - -TTriglogUnpackTof::TTriglogUnpackTof( Int_t verbose ) : - FairUnpack( 10, 1, roc3587::proc_Triglog, 0, 9 ), - fiVerbosity(verbose), - fMbsUnpackPar(0), - fiNbEvents(0), - fiFirstEventNumber(0), - fiLastEventNumber(0), - fLastCheck(), - fCheck(), - fTriglogUnp(NULL), - fTriglogBoardCollection(NULL), - fScalerBoardCollection(NULL), - fbSaveTriglogBoard(kFALSE), - fbSaveScalerBoards(kFALSE) -{ -} - -TTriglogUnpackTof::TTriglogUnpackTof( Int_t type, Int_t subType, Short_t procId, Int_t verbose, - Short_t subCrate, Short_t control) : - FairUnpack( type, subType, procId, subCrate, control ), - fiVerbosity(verbose), - fMbsUnpackPar(0), - fiNbEvents(0), - fiFirstEventNumber(0), - fiLastEventNumber(0), - fLastCheck(), - fCheck(), - fTriglogUnp(NULL), - fTriglogBoardCollection(NULL), - fScalerBoardCollection(NULL), - fbSaveTriglogBoard(kFALSE), - fbSaveScalerBoards(kFALSE) -{ -} - -TTriglogUnpackTof::~TTriglogUnpackTof() -{ - LOG(info)<<"**** TTriglogUnpackTof: Delete instance "; - - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::triglog ) ) - delete fTriglogUnp; -} - -// -------------------------------------------------- -// FairUnpack specific functions -Bool_t TTriglogUnpackTof::Init() -{ - LOG(info)<<"**** TTriglogUnpackTof: Init Params "; - if( kFALSE == InitParameters() ) - LOG(error)<<"**** TTriglogUnpackTof: Failed to Initialize params"; -// return kFALSE; - LOG(info)<<"**** TTriglogUnpackTof: Params Initialized "; - - // Create the proper Unpackers and number of output objects for each boards type -// if( kFALSE == RegisterOutput() ) -// return kFALSE; - Register(); // FairUnpack Style, I feel unsafe as no check on output Array validity! - if( kFALSE == CreateUnpackers() ) - LOG(error)<<"**** TTriglogUnpackTof: Failed to create unpackers "; -// return kFALSE; - - return kTRUE; -} -Bool_t TTriglogUnpackTof::DoUnpack(Int_t* data, Int_t size) -{ - Int_t * pData = data; -// UInt_t uNbWords = size/2 - 1; // <= Somehow FAIRROOT transfers the size in words from the subevt header and not the size in longwords reads by the f_evt_get_subevent function -// Changed in git commit 0c0bd037c201d3496f9d5d7c133874382e885677 to fairroot LMD source -// TODO: Make sure the same change is applied to FairMbsStreamSource !!!! - UInt_t uNbWords = size; - - - LOG(debug)<<"TTriglogUnpackTof::DoUnpack => Found TRIGLOG subevent! LEN" - <<uNbWords; - - if( 3 < fiVerbosity ) - { - TString sPrintEvent = ""; - LOG(debug)<<"----------------------------------------------------------------"; - LOG(debug)<<"Size: "<<uNbWords; - for( UInt_t uWdInd = 0; uWdInd < uNbWords; uWdInd++ ) - { - if( 0 < uWdInd && 0 == uWdInd%8 ) - { - LOG(debug)<<sPrintEvent; - sPrintEvent = ""; - } // if( 0 < uWdInd && 0 == uWdInd%8 ) - sPrintEvent += Form("%08x ", pData[uWdInd]); - } // for( UInt_t uWdInd = 0; uWdInd < uNbWords; uWdInd++ ) - LOG(debug)<<sPrintEvent; - LOG(debug)<<"----------------------------------------------------------------"; - } // if( 3 < fiVerbosity ) - - - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::triglog ) ) - fTriglogUnp->ProcessTriglog( (UInt_t*)data , uNbWords ); - - fiNbEvents++; - LOG(debug)<<"TRIGLOG unpacked!"; - return kTRUE; -} -void TTriglogUnpackTof::Reset() -{ - ClearOutput(); -} -void TTriglogUnpackTof::Register() -{ - if( kFALSE == RegisterOutput() ) - LOG(error)<<"**** TTriglogUnpackTof: Failed to create outputs "; -} -Bool_t TTriglogUnpackTof::Finish() -{ - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::triglog ) ) - fTriglogUnp->FinishTriglog(); - else LOG(info)<<"No Triglog summary as 0 Triglog board active"; - - return kTRUE; -} - -// ------------------------------------------------------------------ -Bool_t TTriglogUnpackTof::InitParameters() -{ - // Get Base Container - FairRun* ana = FairRun::Instance(); - FairRuntimeDb* rtdb=ana->GetRuntimeDb(); - - // Unpacker parameter - fMbsUnpackPar = (TMbsUnpackTofPar*) (rtdb->getContainer("TMbsUnpackTofPar")); - if( 0 == fMbsUnpackPar ) - return kFALSE; - - // PAL: Added to recover loading of parameters before initialization -// rtdb->initContainers( ana->GetRunId() ); - - fMbsUnpackPar->printParams(); - - return kTRUE; -} -// ------------------------------------------------------------------ -Bool_t TTriglogUnpackTof::CreateHistogramms() -{ - TDirectory * oldir = gDirectory; // <= To prevent histos from being sucked in by the param file of the TRootManager! - gROOT->cd(); // <= To prevent histos from being sucked in by the param file of the TRootManager! - - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::triglog ) ) - fTriglogUnp->CreateHistos(); - - gDirectory->cd( oldir->GetPath() ); // <= To prevent histos from being sucked in by the param file of the TRootManager! - - return kTRUE; -} -Bool_t TTriglogUnpackTof::FillHistograms() -{ - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::triglog ) ) - fTriglogUnp->FillHistos(); - - return kTRUE; -} -void TTriglogUnpackTof::WriteHistogramms() -{ - // There should always be only 1 active TRIGLOG board at a time - if( 1 == fMbsUnpackPar->GetNbActiveBoards( tofMbs::triglog ) ) - { - TDirectory * oldir = gDirectory; - TFile *fHist = new TFile("./tofMbsUnp.hst.root","RECREATE"); - - if( 1 == fMbsUnpackPar->GetNbActiveBoards( tofMbs::triglog ) ) - fTriglogUnp->WriteHistos( fHist ); - - gDirectory->cd( oldir->GetPath() ); - fHist->Close(); - } // if( 1 == fMbsUnpackPar->GetNbActiveBoards( tofMbs::triglog ) ) -} -void TTriglogUnpackTof::DeleteHistograms() -{ - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::triglog ) ) - fTriglogUnp->DeleteHistos(); -} -// ------------------------------------------------------------------ -Bool_t TTriglogUnpackTof::CreateUnpackers() -{ - if( 0 == fMbsUnpackPar->GetNbActiveBoards() ) - { - LOG(error)<<"TTriglogUnpackTof::CreateUnpackers => No active boards => No unpacker !?!?! "; - return kFALSE; - } - - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::triglog ) ) - fTriglogUnp = new TTofTriglogUnpacker( fMbsUnpackPar ); - - return kTRUE; -} -Bool_t TTriglogUnpackTof::RegisterOutput() -{ - if( 0 == fMbsUnpackPar->GetNbActiveBoards() ) - { - LOG(error)<<"TTriglogUnpackTof::RegisterOutput => No active boards => No output objects !?!?! "; - return kFALSE; - } - // Not sure here what is the best way to group the TDC objects...... - // The vector of data in the board objects kill probably the TClonesArray purpose? - // Maybe better to have big fixed size array and TTofVftxData::Clear calls in TTofVftxBoard combined - // with ConstructedAt access in TTofVftxUnpacker - FairRootManager *fManager = FairRootManager::Instance(); - // Scalers - // TRIGLOG - if( 1 == fMbsUnpackPar->GetNbActiveBoards( tofMbs::triglog ) ) - { - // There should always be maximum one trigger board active at a time!!! - fTriglogBoardCollection = new TClonesArray( "TTofTriglogBoard", 1 ); -// fManager->Register("TofTriglog","TofUnpack",fTriglogBoardCollection, kTRUE); - fManager->Register( "TofTriglog","TofUnpack",fTriglogBoardCollection, - fMbsUnpackPar->WriteDataInCbmOut() || fbSaveTriglogBoard); - - fScalerBoardCollection = new TClonesArray( "TTofScalerBoard", - fMbsUnpackPar->GetNbActiveScalersB()); -// fManager->Register("TofRawScalers","TofUnpack",fScalerBoardCollection, kTRUE); - fManager->Register( "TofRawScalers","TofUnpack",fScalerBoardCollection, - fMbsUnpackPar->WriteDataInCbmOut() || fbSaveScalerBoards); - } // if( 1 == fMbsUnpackPar->GetNbActiveBoards( tofMbs::triglog ) ) - else if( 1 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::triglog ) ) - { - LOG(error)<<"TMbsUnpackTofCustom::RegisterOutput => More than 1 TRIGLOG board active!!!!! recheck your VME address matrix "; - return kFALSE; - } // else if( 1 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::triglog ) ) - - return kTRUE; -} -Bool_t TTriglogUnpackTof::ClearOutput() -{ - LOG(debug)<<"Clear TRIGLOG"; - if( 1 == fMbsUnpackPar->GetNbActiveBoards( tofMbs::triglog ) ) - fTriglogBoardCollection->Clear("C"); - if( 0 < fMbsUnpackPar->GetNbActiveScalersB() ) - fScalerBoardCollection->Clear("C"); - return kTRUE; -} -void TTriglogUnpackTof::SetSaveTriglog( Bool_t bSaveTrlo ) -{ - fbSaveTriglogBoard = bSaveTrlo; - LOG(info)<<"TTriglogUnpackTof => Enable the saving of raw triglog data in analysis output file"; - -} -void TTriglogUnpackTof::SetSaveScalers( Bool_t bSaveScal ) -{ - fbSaveScalerBoards = bSaveScal; - LOG(info)<<"TTriglogUnpackTof => Enable the saving of raw scaler data in analysis output file"; - -} -// ------------------------------------------------------------------ diff --git a/beamtime/tof/TTriglogUnpackTof.h b/beamtime/tof/TTriglogUnpackTof.h deleted file mode 100644 index ccaa356b4fc86b318110f427f114b0aafce58ddd..0000000000000000000000000000000000000000 --- a/beamtime/tof/TTriglogUnpackTof.h +++ /dev/null @@ -1,83 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TTriglogUnpackTof ----- -// ----- Created 07/07/2013 by P.-A. Loizeau ----- -// ----- Triglog Data unpacker using the fairroot MBS classes ----- -// ------------------------------------------------------------------ -#ifndef _TTRIGLOGUNPACKTOF_H_ -#define _TTRIGLOGUNPACKTOF_H_ - -// General Fairroot unpack of GSI/MBS event -#include "FairUnpack.h" - -// FAIR headers -//#include "FairLogger.h" // error: field ‘fLastCheck’ has incomplete type otherwise ?!?!? -#include "FairRootManager.h" // error: field ‘fLastCheck’ has incomplete type otherwise ?!?!? - -// Parameters -class TMbsUnpackTofPar; - -// Unpackers -class TTofTriglogUnpacker; - -// ROOT -class TClonesArray; -class TH1; -class TH2; -class TString; -class TDatime; - -class TTriglogUnpackTof : public FairUnpack { - public: - TTriglogUnpackTof(); - TTriglogUnpackTof( Int_t verbose ); - TTriglogUnpackTof( Int_t type, Int_t subType, Short_t procId, Int_t verbose = 1, - Short_t subCrate = 1, Short_t control = 9 ); - virtual ~TTriglogUnpackTof(); - - // FairUnpack specific functions - virtual Bool_t Init(); - virtual Bool_t DoUnpack(Int_t* data, Int_t size); - virtual void Reset(); - virtual Bool_t Finish(); - - void WriteHistogramms(); - - void SetSaveTriglog( Bool_t bSaveTrlo=kTRUE ); - void SetSaveScalers( Bool_t bSaveScal=kTRUE ); - protected: - virtual void Register(); - - private: - TTriglogUnpackTof(const TTriglogUnpackTof&); - TTriglogUnpackTof operator=(const TTriglogUnpackTof&); - - // Parameters - Int_t fiVerbosity; - Bool_t InitParameters(); - TMbsUnpackTofPar *fMbsUnpackPar; - - Bool_t CreateHistogramms(); - Bool_t FillHistograms(); - void DeleteHistograms(); - - Bool_t RegisterOutput(); - Bool_t CreateUnpackers(); - Bool_t ClearOutput(); - - Int_t fiNbEvents; - Int_t fiFirstEventNumber; - Int_t fiLastEventNumber; - TDatime fLastCheck; - TDatime fCheck; - - // Unpackers - TTofTriglogUnpacker * fTriglogUnp; - // Output objects - TClonesArray * fTriglogBoardCollection; - TClonesArray * fScalerBoardCollection; - Bool_t fbSaveTriglogBoard; - Bool_t fbSaveScalerBoards; - - ClassDef(TTriglogUnpackTof, 2); -}; -#endif // _TTRIGLOGUNPACKTOF_H_ diff --git a/beamtime/tof/TofDef.h b/beamtime/tof/TofDef.h deleted file mode 100644 index 8bebab5fceff8e3785ef31511af1c9795a1cf7e4..0000000000000000000000000000000000000000 --- a/beamtime/tof/TofDef.h +++ /dev/null @@ -1,99 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- TofDef header file ----- -// ----- ----- -// ----- created by C. Simon on 2014-03-18 ----- -// ----- ----- -// ----- based on TofVmeDef by P.-A. Loizeau ----- -// ----- https://subversion.gsi.de/fairroot/cbmroot/development/ploizeau/ ----- -// ----- main/unpack/tof/TofVmeDef.h ----- -// ----- revision 20754, 2013-07-17 ----- -// ----------------------------------------------------------------------------- - -#ifndef TOFDEF_H_ -#define TOFDEF_H_ - -#include "TString.h" - -namespace tofMbs -{ - enum BoardTypes { - undef = 0, // unknown type, default value - caenV1290 = 1, // CAEN v1290A and CAEN v1290N VME boards based on HPTDC chips - vftx = 2, // FPGA TDC of the VFTX family (E. Bayer dev.) - trb = 3, // FPGA TDC of the HADES TRB3 family (alias of trbtdc) - get4 = 4, // GET4 chips - triglog = 10, // VULOM TRIGLOG board - scalormu = 11, // VULOM Scaler Or Multiplicity board - scalormubig= 12, // VULOM Scaler Or Multiplicity board 32 channel version ? not used for now - scaler2014 = 13, // VULOM Scaler Or/And board used in the GSI April 2014 TOF beamtime - triglogscal= 14, // VULOM TRIGLOG board used as additional scaler board - orgen = 15, // VULOM Or Generation board (nov 2015) with more scalers than scaler2014 - caenv965 = 20, // CAEN v965A and CAEN v965N VME QDC boards - lecroy1182 = 21, // LECROY 1182 VME QDC/ADC board - vulqfwread = 22, // VULOM QFW board (Charge to Frequency Converter Readout) - trbseb = 30, // Subevent builder on central TRB-FPGA - trbtdc = 31, // TDC on peripheral TRB-FPGA or FEE-TDC - trbhub = 32 // Hub on peripheral TRB-FPGA - - }; - enum MappingFields { - BoardIndex = 0, // General board Index in the mapping array/MBS - Active = 1, // Active flag, 1 = board present - Address = 2, // VME base address of the board (used only in MBS) - AddMod = 3, // VME Address modifier (used only in MBS) - TokenA = 4, // Token inserted at the beginning of data for this board - TokenB = 5, // Token inserted at the beginning of data for this board - Type = 6 // Board Type - }; - const UInt_t kuNbFieldsMapping = 7; - const UInt_t kuNbFieldsCtsMapping = 3; - - enum CtsMappingFields { - TriggerChannel = 0, - TriggerType = 1, - TriggerUnpack = 2 - }; - - const TString ksTriglogHistName = "triglog"; - const TString ksScomHistName = "scom"; - const TString ksScalHistName = "scal"; - const TString ksOrGenHistName = "orgen"; - const TString ksV965HistName = "v965"; - const TString ks1182HistName = "1182"; - const TString ksQfwHistName = "qfw"; - - /* - const TString ksTriglogParName = "Triglog"; - const TString ksScomParName = "Scom"; - const TString ksV965ParName = "V965"; - const TString ks1182ParName = "1182"; - const TString ksQfwParName = "Qfw"; - */ -} - -namespace tofTrb -{ - enum TrbNetStatusBits { - status_network_0 = 0x00000001, - status_network_1 = 0x00000002, - status_network_2 = 0x00000004, - status_network_3 = 0x00000008, - status_network_4 = 0x00000010, - status_network_5 = 0x00000020, - status_network_6 = 0x00000040, - status_readout_16 = 0x00010000, - status_readout_17 = 0x00020000, - status_readout_18 = 0x00040000, - status_readout_19 = 0x00080000, - status_readout_20 = 0x00100000, - status_readout_21 = 0x00200000, - status_readout_22 = 0x00400000, - status_readout_23 = 0x00800000, - status_readout_24 = 0x01000000, - status_readout_25 = 0x02000000, - status_readout_26 = 0x04000000, - status_readout_27 = 0x08000000 - }; -} - -#endif // TOFDEF_H_ diff --git a/beamtime/tof/calib/TMbsCalibTof.cxx b/beamtime/tof/calib/TMbsCalibTof.cxx deleted file mode 100644 index 29c982c1390fa6f38818c0b3d1de87bcd729d584..0000000000000000000000000000000000000000 --- a/beamtime/tof/calib/TMbsCalibTof.cxx +++ /dev/null @@ -1,333 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TMbsCalibTof ----- -// ----- Created 19/05/2013 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ -#include "TMbsCalibTof.h" - -// General Unpack headers -#include "TMbsUnpackTofPar.h" - -// ToF specific headers -#include "TMbsCalibTdcTof.h" -#include "TMbsCalibTofPar.h" -#include "TofTdcDef.h" -#include "TofCaenDef.h" -#include "TofVftxDef.h" -#include "TofTrbTdcDef.h" -#include "TofGet4Def.h" -#include "TTofTdcBoard.h" -#include "TTofTdcData.h" -#include "TTofCalibData.h" -#include "TTofCalibScaler.h" -#include "TMbsCalibScalTof.h" -#include "TTofTriglogBoard.h" - -// FAIR headers -#include "FairLogger.h" -#include "FairRunAna.h" -#include "FairRuntimeDb.h" -#include "FairRootManager.h" - -// ROOT headers -#include "Riostream.h" // for cout, endl, etc... -#include "TClonesArray.h" -#include "TH2.h" -#include "TH1.h" -#include "TTimeStamp.h" -#include <TFile.h> - -TMbsCalibTof::TMbsCalibTof() : - FairTask("MbsCalibTof"), - fMbsUnpackPar(NULL), - fMbsCalibPar(NULL), - fTdcCalibrator(NULL), - fScalerCalibrator(NULL), - fTriglogBoardCollection(NULL), - fbSaveCalibScalers(kFALSE), - fdScalersEvoRangeUser(-1), - fdScalersEvoBinSzUser(-1), - fbSaveCalibTdcs(kFALSE), - fsTdcCalibOutFoldername("./"), - fsTdcCalibFilename(""), - fbTdcCalibGsiSep14Fix(kFALSE), - fbTdcRefMoniMode(kFALSE) -{ -} - -TMbsCalibTof::TMbsCalibTof(const char* name, Int_t /*mode*/, Int_t verbose) : - FairTask(name, verbose), - fMbsUnpackPar(0), - fMbsCalibPar(NULL), - fTdcCalibrator(NULL), - fScalerCalibrator(NULL), - fTriglogBoardCollection(NULL), - fbSaveCalibScalers(kFALSE), - fdScalersEvoRangeUser(-1), - fdScalersEvoBinSzUser(-1), - fbSaveCalibTdcs(kFALSE), - fsTdcCalibOutFoldername("./"), - fsTdcCalibFilename(""), - fbTdcCalibGsiSep14Fix(kFALSE), - fbTdcRefMoniMode(kFALSE) -{ -} - -TMbsCalibTof::~TMbsCalibTof() -{ - DeleteHistograms(); - LOG(info)<<"**** TMbsCalibTof: Delete instance "; -} - -// -------------------------------------------------- -// Fairtask specific functions -void TMbsCalibTof::SetParContainers() -{ - InitParameters(); -} -InitStatus TMbsCalibTof::ReInit() -{ - LOG(info)<<"**** TMbsCalibTof: Reinitialize the unpack parameters for tof "; - if( kFALSE == InitParameters() ) - return kFATAL; - fMbsCalibPar->printParams(); - - return kSUCCESS; -} - -InitStatus TMbsCalibTof::Init() -{ - if( kFALSE == InitParameters() ) - return kFATAL; - fMbsCalibPar->printParams(); - - // Create the proper Calibrators and number of output objects for each boards type - if( kFALSE == InitCalibrators() ) - return kFATAL; - - return kSUCCESS; -} -void TMbsCalibTof::Exec(Option_t* /*option*/) -{ - // Run processing functions of all enables calibrators - ExecCalibrators(); -} -void TMbsCalibTof::Finish() -{ - CloseCalibrators(); - - WriteHistogramms(); -} - -// ------------------------------------------------------------------ -Bool_t TMbsCalibTof::InitParameters() -{ - // Get Base Container - FairRun* ana = FairRun::Instance(); - FairRuntimeDb* rtdb=ana->GetRuntimeDb(); - - // Unpack parameter - fMbsUnpackPar = (TMbsUnpackTofPar*) (rtdb->getContainer("TMbsUnpackTofPar")); - if( 0 == fMbsUnpackPar ) - { - LOG(error)<<"TMbsCalibTof::InitParameters => Could not obtain the TMbsUnpackTofPar "; - return kFALSE; - } - - // Calibration parameter - fMbsCalibPar = (TMbsCalibTofPar*) (rtdb->getContainer("TMbsCalibTofPar")); - if( 0 == fMbsCalibPar ) - { - LOG(error)<<"TMbsCalibTof::InitParameters => Could not obtain the TMbsCalibTofPar "; - return kFALSE; - } - - // PAL: Added to recover loading of parameters before initialization -// rtdb->initContainers( ana->GetRunId() ); - - return kTRUE; -} -Bool_t TMbsCalibTof::InitCalibrators() -{ - // Scalers - if( 0 < fMbsUnpackPar->GetNbActiveScalersB() ) - { - fScalerCalibrator = new TMbsCalibScalTof( fMbsUnpackPar, fMbsCalibPar ); - fScalerCalibrator->RegisterInput(); - fScalerCalibrator->SetSaveScalers( fbSaveCalibScalers ); - fScalerCalibrator->SetHistoUserAxis( fdScalersEvoRangeUser, fdScalersEvoBinSzUser ); - fScalerCalibrator->RegisterOutput(); - fScalerCalibrator->CreateHistogramms(); - if( kFALSE == fScalerCalibrator->InitScalersCalib() ) - return kFALSE; - } // if( 0 < fMbsUnpackPar->GetNbActiveScalersB() ) - - // TDCs - if( 0 < fMbsUnpackPar->GetNbActiveTdcs() ) - { - fTdcCalibrator = new TMbsCalibTdcTof( fMbsUnpackPar, fMbsCalibPar ); - fTdcCalibrator->RegisterInput(); - fTdcCalibrator->SetSaveTdcs( fbSaveCalibTdcs ); - fTdcCalibrator->SetCalibFilename(fsTdcCalibFilename); - fTdcCalibrator->SetCalibOutFolder(fsTdcCalibOutFoldername); - fTdcCalibrator->SetSep14Fix(fbTdcCalibGsiSep14Fix); - fTdcCalibrator->EnaTdcRefMoniMode(fbTdcRefMoniMode); - fTdcCalibrator->RegisterOutput(); - fTdcCalibrator->CreateHistogramms(); - if( kFALSE == fTdcCalibrator->InitiTdcCalib() ) - return kFALSE; - } // if( 0 < fMbsUnpackPar->GetNbActiveTdcs() ) - - // Event rejection - // E.g.: pulser event used to Empty the VFTX buffers - if( 1 == fMbsUnpackPar->OnlyOneTriglog() && - -1 < fMbsUnpackPar->GetTriggerToReject() ) - { - LOG(info)<<"TMbsCalibTof::RegisterInput => Load the TofTriglog TClonesArray for trigger rejection!!!"; - FairRootManager* rootMgr = FairRootManager::Instance(); - fTriglogBoardCollection = (TClonesArray*) rootMgr->GetObject("TofTriglog"); - if( NULL == fTriglogBoardCollection) - { - LOG(error)<<"TMbsCalibTof::RegisterInput => Could not get the TofTriglog TClonesArray!!!"; - return kFALSE; - } // if( NULL == fTriglogBoardCollection) - } // if trigger rejection enabled and trigger board enabled - - return kTRUE; -} -Bool_t TMbsCalibTof::ExecCalibrators() -{ - // Scalers - if( 0 < fMbsUnpackPar->GetNbActiveScalersB() ) - fScalerCalibrator->ClearCalib(); - // TDCs - if( 0 < fMbsUnpackPar->GetNbActiveTdcs() ) - fTdcCalibrator->ClearCalib(); - - // Event rejection - // E.g.: pulser event used to Empty the VFTX buffers - if( 1 == fMbsUnpackPar->OnlyOneTriglog() && - -1 < fMbsUnpackPar->GetTriggerToReject() ) - { -// if( NULL == fTriglogBoardCollection ) -// return kFALSE; - - TTofTriglogBoard * xTriglogBoard = (TTofTriglogBoard*) fTriglogBoardCollection->At(0); // Always only 1 TRIGLOG board! - -// if( NULL == xTriglogBoard ) -// return kFALSE; -// if( 1 == ( 0x1 & ( (xTriglogBoard->GetTriggPatt()) >> (fMbsUnpackPar->GetTriggerToReject()) ) ) ) - // Reject selected trigger only when alone (accept when both not rejected trigger and rejected trigger are present) - if( (xTriglogBoard->GetTriggPatt()) == ( 1ul << (fMbsUnpackPar->GetTriggerToReject()) ) ) - // Jump this event ! - return kTRUE; - } // if trigger rejection enabled and trigger board enabled - - // Scalers - if( 0 < fMbsUnpackPar->GetNbActiveScalersB() ) - { -// fScalerCalibrator->ClearCalib(); - fScalerCalibrator->CalibScalers(); - fScalerCalibrator->FillHistograms(); - } // if( 0 < fMbsUnpackPar->GetNbActiveScalersB() ) - - // TDCs - if( 0 < fMbsUnpackPar->GetNbActiveTdcs() ) - { -// fTdcCalibrator->ClearCalib(); - fTdcCalibrator->CalibTdc(); - fTdcCalibrator->FillHistograms(); - } // if( 0 < fMbsUnpackPar->GetNbActiveTdcs() ) - - return kTRUE; -} -Bool_t TMbsCalibTof::CloseCalibrators() -{ - // Scalers - if( 0 < fMbsUnpackPar->GetNbActiveScalersB() ) - fScalerCalibrator->CloseScalersCalib(); - - // TDCs - if( 0 < fMbsUnpackPar->GetNbActiveTdcs() ) - fTdcCalibrator->CloseTdcCalib(); - - return kTRUE; -} -// ------------------------------------------------------------------ -Bool_t TMbsCalibTof::CreateHistogramms() -{ - // Calibrator initalisation functions should take care of creating their own - // => for the task own histos - return kTRUE; -} -Bool_t TMbsCalibTof::FillHistograms() -{ - // Calibrator filling functions should take care of creating their own - // => for the task own histos - return kTRUE; -} -void TMbsCalibTof::WriteHistogramms() -{ - TDirectory * oldir = gDirectory; - TFile *fHist = new TFile("./tofMbsCal.hst.root","RECREATE"); - - // Scalers - if( 0 < fMbsUnpackPar->GetNbActiveScalersB() ) - fScalerCalibrator->WriteHistogramms( fHist ); - - // TDCs - if( 0 < fMbsUnpackPar->GetNbActiveTdcs() ) - fTdcCalibrator->WriteHistogramms( fHist ); - - // Task own histos - // TODO if necessary - - gDirectory->cd( oldir->GetPath() ); - - fHist->Close(); -} -void TMbsCalibTof::DeleteHistograms() -{ - // Calibrator destructors should take care of destroying their own - // => for the task own histos -} -// ------------------------------------------------------------------ -Bool_t TMbsCalibTof::RegisterInput() -{ - // Scalers - if( 0 < fMbsUnpackPar->GetNbActiveScalersB() ) - if( kFALSE == fScalerCalibrator->RegisterInput() ) - return kFALSE; - - // TDCs - if( 0 < fMbsUnpackPar->GetNbActiveTdcs() ) - if( kFALSE == fTdcCalibrator->RegisterInput() ) - return kFALSE; - - return kTRUE; -} -Bool_t TMbsCalibTof::RegisterOutput() -{ - // Scalers - if( 0 < fMbsUnpackPar->GetNbActiveScalersB() ) - { - fScalerCalibrator->SetSaveScalers( fbSaveCalibScalers ); - fScalerCalibrator->SetHistoUserAxis( fdScalersEvoRangeUser, fdScalersEvoBinSzUser ); - fScalerCalibrator->RegisterOutput(); - } // if( 0 < fMbsUnpackPar->GetNbActiveScalersB() ) - - // TDCs - if( 0 < fMbsUnpackPar->GetNbActiveTdcs() ) - { - fTdcCalibrator->SetSaveTdcs( fbSaveCalibTdcs ); - fTdcCalibrator->SetCalibFilename(fsTdcCalibFilename); - fTdcCalibrator->SetCalibOutFolder(fsTdcCalibOutFoldername); - fTdcCalibrator->RegisterOutput(); - } // if( 0 < fMbsUnpackPar->GetNbActiveScalersB() ) - - return kTRUE; -} -Bool_t TMbsCalibTof::ClearOutput() -{ - return kTRUE; -} -// ------------------------------------------------------------------ diff --git a/beamtime/tof/calib/TMbsCalibTof.h b/beamtime/tof/calib/TMbsCalibTof.h deleted file mode 100644 index 6fec6b41ca21c6d56929a1a22ef821864605990c..0000000000000000000000000000000000000000 --- a/beamtime/tof/calib/TMbsCalibTof.h +++ /dev/null @@ -1,107 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TMbsCalibTof ----- -// ----- Created 21/05/2013 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ -#ifndef _TMBSCALIBTOF_H_ -#define _TMBSCALIBTOF_H_ - -#include "FairTask.h" - -#include <vector> - -#include "TofTdcDef.h" - -class TMbsUnpackTofPar; -class TMbsCalibTofPar; - -class TMbsCalibTdcTof; -class TTofCalibData; - -class TMbsCalibScalTof; -class TTofCalibScaler; - -class TFile; -class TDirectory; -class TClonesArray; -class TH1; -class TH2; -class TString; - -class TMbsCalibTof : public FairTask { - public: - TMbsCalibTof(); - TMbsCalibTof(const char* name, Int_t mode = 1, Int_t verbose = 1); - virtual ~TMbsCalibTof(); - - // Fairtask specific functions - virtual void SetParContainers(); - virtual InitStatus Init(); - virtual InitStatus ReInit(); - virtual void Exec(Option_t* option); - virtual void Finish(); - - void SetSaveScalers( Bool_t bSaveScal=kTRUE ) {fbSaveCalibScalers = bSaveScal; }; - void SetScalHistoUserAxis( Double_t dRangeIn, Double_t dBinSzIn ) - { fdScalersEvoRangeUser = dRangeIn; fdScalersEvoBinSzUser = dBinSzIn; }; - - void SetSaveTdcs( Bool_t bSaveTdcs=kTRUE ) {fbSaveCalibTdcs = bSaveTdcs; }; - void SetTdcCalibFilename( TString sFilenameIn="" ) {fsTdcCalibFilename = sFilenameIn; }; - void SetTdcCalibOutFoldername( TString sFoldernameIn="" ) {fsTdcCalibOutFoldername = sFoldernameIn; }; - - // Fix for big trigger time deviation in GSI Sep14 data - void SetTdcCalibSep14Fix( Bool_t inGsiSep14Fix = kTRUE) { fbTdcCalibGsiSep14Fix = inGsiSep14Fix; }; - - // Calibration mode where only the reference channels are processed (Calib and histo filling) - void EnaTdcRefMoniMode( Bool_t inTdcRefMoni = kTRUE) { fbTdcRefMoniMode = inTdcRefMoni; }; - - private: - TMbsCalibTof(const TMbsCalibTof&); - TMbsCalibTof operator=(const TMbsCalibTof&); - - // Parameters - Bool_t InitParameters(); - TMbsUnpackTofPar *fMbsUnpackPar; - TMbsCalibTofPar *fMbsCalibPar; - - // Calibration Processors - Bool_t CreateCalibrators(); - Bool_t InitCalibrators(); - Bool_t ClearCalibrators(); - Bool_t ExecCalibrators(); - Bool_t CloseCalibrators(); - TMbsCalibTdcTof *fTdcCalibrator; - TMbsCalibScalTof *fScalerCalibrator; - - // Histograms, including Task own histos - Bool_t CreateHistogramms(); - Bool_t FillHistograms(); - void WriteHistogramms(); - void DeleteHistograms(); - - // Input - Bool_t RegisterInput(); - - // Output - Bool_t RegisterOutput(); - Bool_t ClearOutput(); - - // For trigger rejection - TClonesArray * fTriglogBoardCollection; - - Bool_t fbSaveCalibScalers; - Double_t fdScalersEvoRangeUser; - Double_t fdScalersEvoBinSzUser; - - Bool_t fbSaveCalibTdcs; - TString fsTdcCalibOutFoldername; - TString fsTdcCalibFilename; - - // Fix for big trigger time deviation in GSI Sep14 data - Bool_t fbTdcCalibGsiSep14Fix; - - // Calibration mode where only the reference channels are processed (Calib and histo filling) - Bool_t fbTdcRefMoniMode; - - ClassDef(TMbsCalibTof, 1); -}; -#endif // _TMBSCALIBTOF_H_ diff --git a/beamtime/tof/calib/TMbsCalibTofPar.cxx b/beamtime/tof/calib/TMbsCalibTofPar.cxx deleted file mode 100644 index 335447046c6c263362f108b71b3fe72b0b912e12..0000000000000000000000000000000000000000 --- a/beamtime/tof/calib/TMbsCalibTofPar.cxx +++ /dev/null @@ -1,1695 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TMbsCalibTofPar ----- -// ----- Created 08/05/2013 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ -#include "TMbsCalibTofPar.h" - -// TOF headers -#include "TofTdcDef.h" -#include "TofCaenDef.h" -#include "TofVftxDef.h" -#include "TofTrbTdcDef.h" -#include "TofGet4Def.h" - -// FAIR headers -#include "FairLogger.h" -#include "FairParamList.h" - -// ROOT headers -#include "TString.h" - -ClassImp(TMbsCalibTofPar) - -TMbsCalibTofPar::TMbsCalibTofPar() : - FairParGenericSet("TMbsCalibTofPar","Tof MBS Calibration Parameters","TestDefaultContext"), - fuCalibDebug(0), - fuCalibScalRefClk(0), - fiMinNbHitsCalib(0), - fiFactMinNbHitsOnlyNewCalib(0), - fsInitialCalibrationFilename(""), - fiNbVftxCalib(0), - fiNbCaenCalib(0), - fiNbTrb3Calib(0), - fiNbGet4Calib(0), - fiInitialCalIndexVftx(), - fiInitialCalIndexCaen(), - fiInitialCalIndexTrb3(), - fiInitialCalIndexGet4(), - fuEnableCalibOutput(0), - fuSingleChannelCalibFilesEnable(0), - fuSingleChannelCalibFilesOutput(0), - fuUseCoarseCorrectedTime(0), - fiNbVftxOffset(0), - fiNbCaenOffset(0), - fiNbTrb3Offset(0), - fiNbGet4Offset(0), - fiBoardIndexVftx(), - fiBoardIndexCaen(), - fiBoardIndexTrb3(), - fiBoardIndexGet4(), - fuEnableTimeOffsetCalibration(0), - fdTimeOffsetVftx(), - fdTimeOffsetCaen(), - fdTimeOffsetTrb3(), - fdTimeOffsetGet4(), - fdMeanTimeOffsetVftx(), - fdMeanTimeOffsetCaen(), - fdMeanTimeOffsetTrb3(), - fdMeanTimeOffsetGet4(), - fuEnableTotCalibration(0), - fdTotOffsetVftx(), - fdTotOffsetCaen(), - fdTotOffsetTrb3(), - fdTotOffsetGet4(), - fdMeanTotOffsetVftx(), - fdMeanTotOffsetCaen(), - fdMeanTotOffsetTrb3(), - fdMeanTotOffsetGet4(), - fuManualTdcOffsetEnable(0), - fiTdcToTdcOffsetVftx(), - fiTdcToTdcOffsetCaen(), - fiTdcToTdcOffsetTrb3(), - fiTdcToTdcOffsetGet4(), - fuAutomaticOffsetEnable(0), - fiMainReferenceTdcVftx(-1), - fiMainReferenceTdcCaen(-1), - fiMainReferenceTdcTrb3(-1), - fiMainReferenceTdcGet4(-1), - fiTotModeVftx(0), - fiTotModeCaen(0), - fiTotModeTrb3(0), - fiTotModeGet4(0), - fiNbVftxTotInvFlag(0), - fiNbCaenTotInvFlag(0), - fiNbTrb3TotInvFlag(0), - fiNbGet4TotInvFlag(0), - fiTotInversionFlagVftx(), - fiTotInversionFlagCaen(), - fiTotInversionFlagTrb3(), - fiTotInversionFlagGet4(), - fuTimeHistEnable(0), - fuTimeHistSinglesEnable(0), - fuTotHistoEnable(0), - fuMultiHitsDistanceHistoEnable(0), - fuTdcOffsetEnable(0), - fiTdcOffsetEnaFlagVftx(), - fiTdcOffsetEnaFlagCaen(), - fiTdcOffsetEnaFlagTrb3(), - fiTdcOffsetEnaFlagGet4(), - fuTdcOffsetMainTdc(0), - fuTrbOffsetLinearEnable(0), - fiChannelResolutionTest(0) -{ -} - -TMbsCalibTofPar::TMbsCalibTofPar(const char* name, - const char* title, - const char* context ) : - FairParGenericSet(name,title,context), - fuCalibDebug(0), - fuCalibScalRefClk(0), - fiMinNbHitsCalib(0), - fiFactMinNbHitsOnlyNewCalib(0), - fsInitialCalibrationFilename(""), - fiNbVftxCalib(0), - fiNbCaenCalib(0), - fiNbTrb3Calib(0), - fiNbGet4Calib(0), - fiInitialCalIndexVftx(), - fiInitialCalIndexCaen(), - fiInitialCalIndexTrb3(), - fiInitialCalIndexGet4(), - fuEnableCalibOutput(0), - fuSingleChannelCalibFilesEnable(0), - fuSingleChannelCalibFilesOutput(0), - fuUseCoarseCorrectedTime(0), - fiNbVftxOffset(0), - fiNbCaenOffset(0), - fiNbTrb3Offset(0), - fiNbGet4Offset(0), - fiBoardIndexVftx(), - fiBoardIndexCaen(), - fiBoardIndexTrb3(), - fiBoardIndexGet4(), - fuEnableTimeOffsetCalibration(0), - fdTimeOffsetVftx(), - fdTimeOffsetCaen(), - fdTimeOffsetTrb3(), - fdTimeOffsetGet4(), - fdMeanTimeOffsetVftx(), - fdMeanTimeOffsetCaen(), - fdMeanTimeOffsetTrb3(), - fdMeanTimeOffsetGet4(), - fuEnableTotCalibration(0), - fdTotOffsetVftx(), - fdTotOffsetCaen(), - fdTotOffsetTrb3(), - fdTotOffsetGet4(), - fdMeanTotOffsetVftx(), - fdMeanTotOffsetCaen(), - fdMeanTotOffsetTrb3(), - fdMeanTotOffsetGet4(), - fuManualTdcOffsetEnable(0), - fiTdcToTdcOffsetVftx(), - fiTdcToTdcOffsetCaen(), - fiTdcToTdcOffsetTrb3(), - fiTdcToTdcOffsetGet4(), - fuAutomaticOffsetEnable(0), - fiMainReferenceTdcVftx(-1), - fiMainReferenceTdcCaen(-1), - fiMainReferenceTdcTrb3(-1), - fiMainReferenceTdcGet4(-1), - fiTotModeVftx(0), - fiTotModeCaen(0), - fiTotModeTrb3(0), - fiTotModeGet4(0), - fiNbVftxTotInvFlag(0), - fiNbCaenTotInvFlag(0), - fiNbTrb3TotInvFlag(0), - fiNbGet4TotInvFlag(0), - fiTotInversionFlagVftx(), - fiTotInversionFlagCaen(), - fiTotInversionFlagTrb3(), - fiTotInversionFlagGet4(), - fuTimeHistEnable(0), - fuTimeHistSinglesEnable(0), - fuTotHistoEnable(0), - fuMultiHitsDistanceHistoEnable(0), - fuTdcOffsetEnable(0), - fiTdcOffsetEnaFlagVftx(), - fiTdcOffsetEnaFlagCaen(), - fiTdcOffsetEnaFlagTrb3(), - fiTdcOffsetEnaFlagGet4(), - fuTdcOffsetMainTdc(0), - fuTrbOffsetLinearEnable(0), - fiChannelResolutionTest(0) -{ -} - - -TMbsCalibTofPar::~TMbsCalibTofPar() -{ -} - -void TMbsCalibTofPar::clear(void) -{ - status = kFALSE; - resetInputVersions(); -} - -void TMbsCalibTofPar::putParams(FairParamList* l) -{ - if (!l) { return; } - - l->add("CalibDebug", (Int_t)fuCalibDebug); - l->add("CalibScalRefClk", (Int_t)fuCalibScalRefClk); - l->add("MinNbHitsCalib", fiMinNbHitsCalib); - l->add("FactMinNbOnlyNewCalib", fiFactMinNbHitsOnlyNewCalib); - l->add("InitialCalibFilename", fsInitialCalibrationFilename); - l->add("NbVftxCalib", fiNbVftxCalib); - l->add("NbCaenCalib", fiNbCaenCalib); - l->add("NbTrb3Calib", fiNbTrb3Calib); - l->add("NbGet4Calib", fiNbGet4Calib); - l->add("InitialCalIndexVftx", fiInitialCalIndexVftx); - l->add("InitialCalIndexCaen", fiInitialCalIndexCaen); - l->add("InitialCalIndexTrb3", fiInitialCalIndexTrb3); - l->add("InitialCalIndexGet4", fiInitialCalIndexGet4); - l->add("EnableCalibOutput", (Int_t)fuEnableCalibOutput); - l->add("SingleChCalibFilesEna", (Int_t)fuSingleChannelCalibFilesEnable); - l->add("SingleChCalibFilesOut", (Int_t)fuSingleChannelCalibFilesOutput); - l->add("UseCoarseCorrTime", (Int_t)fuUseCoarseCorrectedTime); - l->add("NbVftxOffset", fiNbVftxOffset); - l->add("NbCaenOffset", fiNbCaenOffset); - l->add("NbTrb3Offset", fiNbTrb3Offset); - l->add("NbGet4Offset", fiNbGet4Offset); - l->add("BoardIndexVftx", fiBoardIndexVftx); - l->add("BoardIndexCaen", fiBoardIndexCaen); - l->add("BoardIndexTrb3", fiBoardIndexTrb3); - l->add("BoardIndexGet4", fiBoardIndexGet4); - l->add("EnableTimeOffCalib", (Int_t)fuEnableTimeOffsetCalibration); - l->add("TimeOffsetCaen", fdTimeOffsetCaen); - l->add("TimeOffsetVftx", fdTimeOffsetVftx); - l->add("TimeOffsetTrb3", fdTimeOffsetTrb3); - l->add("TimeOffsetGet4", fdTimeOffsetGet4); - l->add("MeanTimeOffsetCaen", fdMeanTimeOffsetCaen); - l->add("MeanTimeOffsetVftx", fdMeanTimeOffsetVftx); - l->add("MeanTimeOffsetTrb3", fdMeanTimeOffsetTrb3); - l->add("MeanTimeOffsetGet4", fdMeanTimeOffsetGet4); - l->add("EnableTotCalibration", (Int_t)fuEnableTotCalibration); - l->add("TotOffsetVftx", fdTotOffsetVftx); - l->add("TotOffsetCaen", fdTotOffsetCaen); - l->add("TotOffsetTrb3", fdTotOffsetTrb3); - l->add("TotOffsetGet4", fdTotOffsetGet4); - l->add("MeanTotOffsetVftx", fdMeanTotOffsetVftx); - l->add("MeanTotOffsetCaen", fdMeanTotOffsetCaen); - l->add("MeanTotOffsetTrb3", fdMeanTotOffsetTrb3); - l->add("MeanTotOffsetGet4", fdMeanTotOffsetGet4); - l->add("ManualTdcOffsetEnable", (Int_t)fuManualTdcOffsetEnable); - l->add("AutomaticOffsetEnable", (Int_t)fuAutomaticOffsetEnable); - l->add("MainReferenceTdcVftx", fiMainReferenceTdcVftx); - l->add("MainReferenceTdcCaen", fiMainReferenceTdcCaen); - l->add("MainReferenceTdcTrb3", fiMainReferenceTdcTrb3); - l->add("MainReferenceTdcGet4", fiMainReferenceTdcGet4); - l->add("TdcToTdcOffsetVftx", fiTdcToTdcOffsetVftx); - l->add("TdcToTdcOffsetCaen", fiTdcToTdcOffsetCaen); - l->add("TdcToTdcOffsetTrb3", fiTdcToTdcOffsetTrb3); - l->add("TdcToTdcOffsetGet4", fiTdcToTdcOffsetGet4); - l->add("TotModeVftx", fiTotModeVftx); - l->add("TotModeCaen", fiTotModeCaen); - l->add("TotModeTrb3", fiTotModeTrb3); - l->add("TotModeGet4", fiTotModeGet4); - l->add("NbVftxTotInvFlag", fiNbVftxTotInvFlag); - l->add("NbCaenTotInvFlag", fiNbCaenTotInvFlag); - l->add("NbTrb3TotInvFlag", fiNbTrb3TotInvFlag); - l->add("NbGet4TotInvFlag", fiNbGet4TotInvFlag); - l->add("TotInversionFlagVftx", fiTotInversionFlagVftx); - l->add("TotInversionFlagCaen", fiTotInversionFlagCaen); - l->add("TotInversionFlagTrb3", fiTotInversionFlagTrb3); - l->add("TotInversionFlagGet4", fiTotInversionFlagGet4); - l->add("TimeHistEnable", (Int_t)fuTimeHistEnable); - l->add("TimeHistSinglesEnable", (Int_t)fuTimeHistSinglesEnable); - l->add("TotHistoEnable", (Int_t)fuTotHistoEnable); - l->add("MultiHitsDistHistoEna", (Int_t)fuMultiHitsDistanceHistoEnable); - l->add("TdcOffsetEnable", (Int_t)fuTdcOffsetEnable); - l->add("TdcOffsetMainTdc", (Int_t)fuTdcOffsetMainTdc); - l->add("TdcOffsetEnaFlagVftx", fiTdcOffsetEnaFlagVftx); - l->add("TdcOffsetEnaFlagCaen", fiTdcOffsetEnaFlagCaen); - l->add("TdcOffsetEnaFlagTrb3", fiTdcOffsetEnaFlagTrb3); - l->add("TdcOffsetEnaFlagGet4", fiTdcOffsetEnaFlagGet4); - l->add("TrbOffsetLinearEnable", (Int_t)fuTrbOffsetLinearEnable); - l->add("ChannelResolutionTest", fiChannelResolutionTest); -} - -Bool_t TMbsCalibTofPar::getParams(FairParamList* l) -{ - if (!l) { return kFALSE; } - - /* - * TODO PAL: Thing I am not sure is whether order in readout has to - * match order in the ascii file => to check - */ - - LOG(debug2)<<"Get the Tof MBS calib parameters."; - - Int_t iTempCaster = 0; - if ( ! l->fill("CalibDebug", &iTempCaster) ) return kFALSE; - fuCalibDebug = (UInt_t)iTempCaster; - - iTempCaster = 0; - if ( ! l->fill("CalibScalRefClk", &iTempCaster) ) return kFALSE; - fuCalibScalRefClk = (UInt_t)iTempCaster; - - if ( ! l->fill("MinNbHitsCalib", &fiMinNbHitsCalib) ) return kFALSE; - if ( ! l->fill("FactMinNbOnlyNewCalib", &fiFactMinNbHitsOnlyNewCalib) ) return kFALSE; - - Int_t iMaxSizeFilename = 5000; - Text_t *sTempText; - sTempText = new Text_t[iMaxSizeFilename]; - if ( ! l->fill("InitialCalibFilename", sTempText, iMaxSizeFilename ) ) return kFALSE; - fsInitialCalibrationFilename = sTempText; - - if ( ! l->fill("NbVftxCalib", &fiNbVftxCalib) ) return kFALSE; - if( 0<fiNbVftxCalib ) - { - fiInitialCalIndexVftx.Set( fiNbVftxCalib ); - if ( ! l->fill("InitialCalIndexVftx", &fiInitialCalIndexVftx) ) return kFALSE; - } // if( 0<fiNbVftxCalib ) - - if ( ! l->fill("NbCaenCalib", &fiNbCaenCalib) ) return kFALSE; - if( 0<fiNbCaenCalib ) - { - fiInitialCalIndexCaen.Set( fiNbCaenCalib ); - if ( ! l->fill("InitialCalIndexCaen", &fiInitialCalIndexCaen) ) return kFALSE; - } // if( 0<fiNbCaenCalib ) - - if ( ! l->fill("NbTrb3Calib", &fiNbTrb3Calib) ) return kFALSE; - if( 0<fiNbTrb3Calib ) - { - fiInitialCalIndexTrb3.Set( fiNbTrb3Calib ); - if ( ! l->fill("InitialCalIndexTrb3", &fiInitialCalIndexTrb3) ) return kFALSE; - } // if( 0<fiNbTrb3Calib ) - - if ( ! l->fill("NbGet4Calib", &fiNbGet4Calib) ) return kFALSE; - if( 0<fiNbGet4Calib ) - { - fiInitialCalIndexGet4.Set( fiNbGet4Calib ); - if ( ! l->fill("InitialCalIndexGet4", &fiInitialCalIndexGet4) ) return kFALSE; - } // if( 0<fiNbGet4Calib ) - - iTempCaster = 0; - if ( ! l->fill("EnableCalibOutput", &iTempCaster) ) return kFALSE; - fuEnableCalibOutput = (UInt_t)iTempCaster; - - if ( ! l->fill("SingleChCalibFilesEna", &iTempCaster) ) return kFALSE; - fuSingleChannelCalibFilesEnable = (UInt_t)iTempCaster; - - if ( ! l->fill("SingleChCalibFilesOut", &iTempCaster) ) return kFALSE; - fuSingleChannelCalibFilesOutput = (UInt_t)iTempCaster; - - if ( ! l->fill("UseCoarseCorrTime", &iTempCaster) ) return kFALSE; - fuUseCoarseCorrectedTime = (UInt_t)iTempCaster; - - iTempCaster = 0; - if ( ! l->fill("EnableTimeOffCalib", &iTempCaster) ) return kFALSE; - fuEnableTimeOffsetCalibration = (UInt_t)iTempCaster; - - iTempCaster = 0; - if ( ! l->fill("EnableTotCalibration", &iTempCaster) ) return kFALSE; - fuEnableTotCalibration = (UInt_t)iTempCaster; - - // Vtfx -----------------------------------------------------------// - if ( ! l->fill("NbVftxOffset", &fiNbVftxOffset) ) return kFALSE; - if( 0 < fiNbVftxOffset ) - { - fiBoardIndexVftx.Set( fiNbVftxOffset ); - if ( ! l->fill("BoardIndexVftx", &fiBoardIndexVftx) ) return kFALSE; - - fdTimeOffsetVftx.Set( fiNbVftxOffset * vftxtdc::kuNbChan/2 ); - if ( ! l->fill("TimeOffsetVftx", &fdTimeOffsetVftx) ) return kFALSE; - } // if( 0 < fiNbVftxOffset ) - - fdMeanTimeOffsetVftx.Set( vftxtdc::kuNbChan/2 ); - if ( ! l->fill("MeanTimeOffsetVftx", &fdMeanTimeOffsetVftx) ) return kFALSE; - - if( 0 < fiNbVftxOffset ) - { - fdTotOffsetVftx.Set( fiNbVftxOffset * vftxtdc::kuNbChan/2 ); - if ( ! l->fill("TotOffsetVftx", &fdTotOffsetVftx) ) return kFALSE; - } // if( 0 < fiNbVftxOffset ) - - fdMeanTotOffsetVftx.Set( vftxtdc::kuNbChan/2 ); - if ( ! l->fill("MeanTotOffsetVftx", &fdMeanTotOffsetVftx) ) return kFALSE; - // ----------------------------------------------------------------// - - // Caen -----------------------------------------------------------// - if ( ! l->fill("NbCaenOffset", &fiNbCaenOffset) ) return kFALSE; - if( 0 < fiNbCaenOffset ) - { - fiBoardIndexCaen.Set( fiNbCaenOffset ); - if ( ! l->fill("BoardIndexCaen", &fiBoardIndexCaen) ) return kFALSE; - - fdTimeOffsetCaen.Set( fiNbCaenOffset * caentdc::kuNbChan ); - if ( ! l->fill("TimeOffsetCaen", &fdTimeOffsetCaen) ) return kFALSE; - } // if( 0 < fiNbCaenOffset ) - - fdMeanTimeOffsetCaen.Set( caentdc::kuNbChan ); - if ( ! l->fill("MeanTimeOffsetCaen", &fdMeanTimeOffsetCaen) ) return kFALSE; - - if( 0 < fiNbCaenOffset ) - { - fdTotOffsetCaen.Set( fiNbCaenOffset * caentdc::kuNbChan ); - if ( ! l->fill("TotOffsetCaen", &fdTotOffsetCaen) ) return kFALSE; - } // if( 0 < fiNbCaenOffset ) - - fdMeanTotOffsetCaen.Set( caentdc::kuNbChan ); - if ( ! l->fill("MeanTotOffsetCaen", &fdMeanTotOffsetCaen) ) return kFALSE; - // ----------------------------------------------------------------// - - // Trb3 -----------------------------------------------------------// - if ( ! l->fill("NbTrb3Offset", &fiNbTrb3Offset) ) return kFALSE; - if( 0 < fiNbTrb3Offset ) - { - fiBoardIndexTrb3.Set( fiNbTrb3Offset ); - if ( ! l->fill("BoardIndexTrb3", &fiBoardIndexTrb3) ) return kFALSE; - - fdTimeOffsetTrb3.Set( fiNbTrb3Offset * trbtdc::kuNbChan/2 ); - if ( ! l->fill("TimeOffsetTrb3", &fdTimeOffsetTrb3) ) return kFALSE; - } // if( 0 < fiNbTrb3Offset ) - - fdMeanTimeOffsetTrb3.Set( trbtdc::kuNbChan/2 ); - if ( ! l->fill("MeanTimeOffsetTrb3", &fdMeanTimeOffsetTrb3) ) return kFALSE; - - if( 0 < fiNbTrb3Offset ) - { - fdTotOffsetTrb3.Set( fiNbTrb3Offset * trbtdc::kuNbChan/2 ); - if ( ! l->fill("TotOffsetTrb3", &fdTotOffsetTrb3) ) return kFALSE; - } // if( 0 < fiNbTrb3Offset ) - - fdMeanTotOffsetTrb3.Set( trbtdc::kuNbChan/2 ); - if ( ! l->fill("MeanTotOffsetTrb3", &fdMeanTotOffsetTrb3) ) return kFALSE; - // ----------------------------------------------------------------// - - // GET4 -----------------------------------------------------------// - if ( ! l->fill("NbGet4Offset", &fiNbGet4Offset) ) return kFALSE; - if( 0 < fiNbGet4Offset ) - { - fiBoardIndexGet4.Set( fiNbGet4Offset ); - if ( ! l->fill("BoardIndexGet4", &fiBoardIndexGet4) ) return kFALSE; - - fdTimeOffsetGet4.Set( fiNbGet4Offset * get4tdc::kuNbChan/2 ); - if ( ! l->fill("TimeOffsetGet4", &fdTimeOffsetGet4) ) return kFALSE; - } // if( 0 < fiNbGet4Offset ) - - fdMeanTimeOffsetGet4.Set( get4tdc::kuNbChan/2 ); - if ( ! l->fill("MeanTimeOffsetGet4", &fdMeanTimeOffsetGet4) ) return kFALSE; - - if( 0 < fiNbGet4Offset ) - { - fdTotOffsetGet4.Set( fiNbGet4Offset * get4tdc::kuNbChan/2 ); - if ( ! l->fill("TotOffsetGet4", &fdTotOffsetGet4) ) return kFALSE; - } // if( 0 < fiNbGet4Offset ) - - fdMeanTotOffsetGet4.Set( get4tdc::kuNbChan/2 ); - if ( ! l->fill("MeanTotOffsetGet4", &fdMeanTotOffsetGet4) ) return kFALSE; - // ----------------------------------------------------------------// - - iTempCaster = 0; - if ( ! l->fill("ManualTdcOffsetEnable", &iTempCaster) ) return kFALSE; - fuManualTdcOffsetEnable = (UInt_t)iTempCaster; - - iTempCaster = 0; - if ( ! l->fill("AutomaticOffsetEnable", &iTempCaster) ) return kFALSE; - fuAutomaticOffsetEnable = (UInt_t)iTempCaster; - - if ( ! l->fill("MainReferenceTdcVftx", &fiMainReferenceTdcVftx) ) return kFALSE; - if ( ! l->fill("MainReferenceTdcCaen", &fiMainReferenceTdcCaen) ) return kFALSE; - if ( ! l->fill("MainReferenceTdcTrb3", &fiMainReferenceTdcTrb3) ) return kFALSE; - if ( ! l->fill("MainReferenceTdcGet4", &fiMainReferenceTdcGet4) ) return kFALSE; - - if( 0 < fiNbVftxCalib ) - { - fiTdcToTdcOffsetVftx.Set( fiNbVftxCalib ); - if ( ! l->fill("TdcToTdcOffsetVftx", &fiTdcToTdcOffsetVftx) ) return kFALSE; - } // if( 0 < fiNbVftxCalib ) - if( 0 < fiNbCaenCalib ) - { - fiTdcToTdcOffsetCaen.Set( fiNbCaenCalib ); - if ( ! l->fill("TdcToTdcOffsetCaen", &fiTdcToTdcOffsetCaen) ) return kFALSE; - } // if( 0 < fiNbCaenCalib ) - if( 0 < fiNbTrb3Calib ) - { - fiTdcToTdcOffsetTrb3.Set( fiNbTrb3Calib ); - if ( ! l->fill("TdcToTdcOffsetTrb3", &fiTdcToTdcOffsetTrb3) ) return kFALSE; - } // if( 0 < fiNbTrb3Calib ) - if( 0 < fiNbGet4Calib ) - { - fiTdcToTdcOffsetGet4.Set( fiNbGet4Calib ); - if ( ! l->fill("TdcToTdcOffsetGet4", &fiTdcToTdcOffsetGet4) ) return kFALSE; - } // if( 0 < fiNbGet4Calib ) - - if ( ! l->fill("TotModeVftx", &fiTotModeVftx) ) return kFALSE; - if ( ! l->fill("TotModeCaen", &fiTotModeCaen) ) return kFALSE; - if ( ! l->fill("TotModeTrb3", &fiTotModeTrb3) ) return kFALSE; - if ( ! l->fill("TotModeGet4", &fiTotModeGet4) ) return kFALSE; - - if ( ! l->fill("NbVftxTotInvFlag", &fiNbVftxTotInvFlag) ) return kFALSE; - if ( ! l->fill("NbCaenTotInvFlag", &fiNbCaenTotInvFlag) ) return kFALSE; - if ( ! l->fill("NbTrb3TotInvFlag", &fiNbTrb3TotInvFlag) ) return kFALSE; - if ( ! l->fill("NbGet4TotInvFlag", &fiNbGet4TotInvFlag) ) return kFALSE; - - if( 0 < fiNbVftxTotInvFlag ) - { - fiTotInversionFlagVftx.Set( fiNbVftxTotInvFlag * vftxtdc::kuNbChan/2 ); - if ( ! l->fill("TotInversionFlagVftx", &fiTotInversionFlagVftx) ) return kFALSE; - } // if( 0 < fiNbVftxTotInvFlag ) - - if( 0 < fiNbCaenTotInvFlag ) - { - fiTotInversionFlagCaen.Set( fiNbCaenTotInvFlag * caentdc::kuNbChan ); - if ( ! l->fill("TotInversionFlagCaen", &fiTotInversionFlagCaen) ) return kFALSE; - } // if( 0 < fiNbCaenTotInvFlag ) - if( 0 < fiNbTrb3TotInvFlag ) - { - fiTotInversionFlagTrb3.Set( fiNbTrb3TotInvFlag * trbtdc::kuNbChan/2 ); - if ( ! l->fill("TotInversionFlagTrb3", &fiTotInversionFlagTrb3) ) return kFALSE; - } // if( 0 < fiNbTrb3TotInvFlag ) - if( 0 < fiNbGet4TotInvFlag ) - { - fiTotInversionFlagGet4.Set( fiNbGet4TotInvFlag * get4tdc::kuNbChan/2 ); - if ( ! l->fill("TotInversionFlagGet4", &fiTotInversionFlagGet4) ) return kFALSE; - } // if( 0 < fiNbGet4TotInvFlag ) - - - iTempCaster = 0; - if ( ! l->fill("TimeHistEnable", &iTempCaster) ) return kFALSE; - fuTimeHistEnable = (UInt_t)iTempCaster; - - iTempCaster = 0; - if ( ! l->fill("TimeHistSinglesEnable", &iTempCaster) ) return kFALSE; - fuTimeHistSinglesEnable = (UInt_t)iTempCaster; - - iTempCaster = 0; - if ( ! l->fill("TotHistoEnable", &iTempCaster) ) return kFALSE; - fuTotHistoEnable = (UInt_t)iTempCaster; - - iTempCaster = 0; - if ( ! l->fill("MultiHitsDistHistoEna", &iTempCaster) ) return kFALSE; - fuMultiHitsDistanceHistoEnable = (UInt_t)iTempCaster; - - - iTempCaster = 0; - if ( ! l->fill("TdcOffsetEnable", &iTempCaster) ) return kFALSE; - fuTdcOffsetEnable = (UInt_t)iTempCaster; - - // The parameter to enable the TDC offset on a single TDC basis is - // used only if the offset is NOT enabled for all TDCs - if( 0 == fuTdcOffsetEnable ) - { - if( 0 < fiNbVftxCalib ) - { - fiTdcOffsetEnaFlagVftx.Set( fiNbVftxCalib ); - if ( ! l->fill("TdcOffsetEnaFlagVftx", &fiTdcOffsetEnaFlagVftx) ) return kFALSE; - } // if( 0 < fiNbVftxCalib ) - if( 0 < fiNbCaenCalib ) - { - fiTdcOffsetEnaFlagCaen.Set( fiNbCaenCalib ); - if ( ! l->fill("TdcOffsetEnaFlagCaen", &fiTdcOffsetEnaFlagCaen) ) return kFALSE; - } // if( 0 < fiNbCaenCalib ) - if( 0 < fiNbTrb3Calib ) - { - fiTdcOffsetEnaFlagTrb3.Set( fiNbTrb3Calib ); - if ( ! l->fill("TdcOffsetEnaFlagTrb3", &fiTdcOffsetEnaFlagTrb3) ) return kFALSE; - } // if( 0 < fiNbTrb3Calib ) - if( 0 < fiNbGet4Calib ) - { - fiTdcOffsetEnaFlagGet4.Set( fiNbGet4Calib ); - if ( ! l->fill("TdcOffsetEnaFlagGet4", &fiTdcOffsetEnaFlagGet4) ) return kFALSE; - } // if( 0 < fiNbGet4Calib ) - } // if( 0 == fuTdcOffsetEnable ) - - iTempCaster = 0; - if ( ! l->fill("TdcOffsetMainTdc", &iTempCaster) ) fuTdcOffsetMainTdc = 0; - else fuTdcOffsetMainTdc = (UInt_t)iTempCaster; - - iTempCaster = 0; - if ( ! l->fill("TrbOffsetLinearEnable", &iTempCaster) ) return kFALSE; - fuTrbOffsetLinearEnable = (UInt_t)iTempCaster; - - if ( ! l->fill("ChannelResolutionTest", &fiChannelResolutionTest) ) return kFALSE; - -// printParams(); - - return kTRUE; -} - -void TMbsCalibTofPar::printParams() -{ - LOG(info)<<"Parameter values in TMbsCalibTofPar: "; - - if(1 == fuCalibDebug) - LOG(info)<<" Calibration Debug ON!!!!!!"; - else LOG(info)<<" Calibration Debug OFF"; - - // Scaler boards reference clock frequency calibration - if(1 == fuCalibScalRefClk) - LOG(info)<<" Scaler boards ref. clk freq. cal.: ON"; - else LOG(info)<<" Scaler boards ref. clk freq. cal.: OFF"; - - // Channel Bin to Time calibration - if( 0 < fiMinNbHitsCalib ) - { - LOG(info)<<" Min nb hits for calib update : "<<fiMinNbHitsCalib; - if( 0 < fiFactMinNbHitsOnlyNewCalib ) - LOG(info)<<" Calib update : Use Initial + New until " - <<fiMinNbHitsCalib*fiFactMinNbHitsOnlyNewCalib - <<" then only New data"; - else LOG(info)<<" Calib update : Always use Initial + New when available"; - } // if( -1 != fiMinNbHitsCalib ) - else LOG(info)<<" Calib update : Use Only Initial"; - - if( kTRUE != fsInitialCalibrationFilename.EqualTo("") && kTRUE != fsInitialCalibrationFilename.EqualTo("-") ) - { - LOG(info)<<" Filename for initial calib hist: "<<fsInitialCalibrationFilename; - if( 0 < fiNbVftxCalib ) - { - TString sTemp = " VFTX FPGA TDC index: |- "; - for( Int_t iIndexVftx = 0; iIndexVftx < fiNbVftxCalib; iIndexVftx++) - sTemp += Form("%3d ", iIndexVftx); - LOG(info)<<sTemp; - - sTemp = " Tdc initial calib. index: |-> "; - for( Int_t iIndexVftx = 0; iIndexVftx < fiNbVftxCalib; iIndexVftx++) - sTemp += Form("%3d ", fiInitialCalIndexVftx[iIndexVftx] ); - LOG(info)<<sTemp; - } - - if( 0 < fiNbCaenCalib ) - { - TString sTemp = " CAEN V1290 TDC index: |- "; - for( Int_t iIndexCaen = 0; iIndexCaen < fiNbCaenCalib; iIndexCaen++) - sTemp += Form("%3d ", iIndexCaen); - LOG(info)<<sTemp; - - sTemp = " Tdc initial calib. index: |-> "; - for( Int_t iIndexCaen = 0; iIndexCaen < fiNbCaenCalib; iIndexCaen++) - sTemp += Form("%3d ", fiInitialCalIndexCaen[iIndexCaen] ); - LOG(info)<<sTemp; - } - if( 0 < fiNbTrb3Calib ) - { - TString sTemp = " TRB3 FPGA TDC index: |- "; - for( Int_t iIndexTrb3 = 0; iIndexTrb3 < fiNbTrb3Calib; iIndexTrb3++) - sTemp += Form("%3d ", iIndexTrb3); - LOG(info)<<sTemp; - - sTemp = " Tdc initial calib. index: |-> "; - for( Int_t iIndexTrb3 = 0; iIndexTrb3 < fiNbTrb3Calib; iIndexTrb3++) - sTemp += Form("%3d ", fiInitialCalIndexTrb3[iIndexTrb3] ); - LOG(info)<<sTemp; - } - if( 0 < fiNbGet4Calib ) - { - TString sTemp = " GET4 TDC index: |- "; - for( Int_t iIndexGet4 = 0; iIndexGet4 < fiNbGet4Calib; iIndexGet4++) - sTemp += Form("%3d ", iIndexGet4); - LOG(info)<<sTemp; - - sTemp = " Tdc initial calib. index: |-> "; - for( Int_t iIndexGet4 = 0; iIndexGet4 < fiNbGet4Calib; iIndexGet4++) - sTemp += Form("%3d ", fiInitialCalIndexGet4[iIndexGet4] ); - LOG(info)<<sTemp; - } - - } // if( filename not empty ) - - if(1 == fuEnableCalibOutput) - LOG(info)<<" Calibration saved in root file: ON"; - else LOG(info)<<" Calibration saved in root file: OFF"; - if(1 == fuSingleChannelCalibFilesEnable) - LOG(info)<<" Use single channel calib files: ON"; - else LOG(info)<<" Use single channel calib files: OFF"; - switch( fuSingleChannelCalibFilesOutput ) - { - case 0: - LOG(info)<<" Single channel calib files output: OFF"; - break; - case 1: - LOG(info)<<" Single channel calib files output: New files from data"; - break; - case 2: - LOG(info)<<" Single channel calib files output: Update files with data"; - break; - default: - break; - } // switch( fuSingleChannelCalibFilesOutput ) - - // Coarse overflow correction? - if( 1 == fuUseCoarseCorrectedTime ) - LOG(info)<<" Coarse time cycle correc.: ON"; - else LOG(info)<<" Coarse time cycle correc.: OFF"; - - // Board related stuff - if( 1 == fuEnableTimeOffsetCalibration || - 1 == fuEnableTotCalibration ) - { - if( 0 < fiNbVftxOffset ) - { - TString sTemp = " VFTX FPGA TDC slot index: |- "; - for( Int_t iIndexVftx = 0; iIndexVftx < fiNbVftxOffset; iIndexVftx++) - sTemp += Form("%3d ", iIndexVftx); - LOG(info)<<sTemp; - - sTemp = " VFTX FPGA TDC board index: |-> "; - for( Int_t iIndexVftx = 0; iIndexVftx < fiNbVftxOffset; iIndexVftx++) - sTemp += Form("%3d ", fiBoardIndexVftx[iIndexVftx]); - LOG(info)<<sTemp; - } // if( 0 < fiNbVftxOffset ) - - if( 0 < fiNbCaenOffset ) - { - TString sTemp = "CAEN 1290 TDC slot index: |- "; - for( Int_t iIndexCaen = 0; iIndexCaen < fiNbCaenOffset; iIndexCaen++) - sTemp += Form("%3d ", iIndexCaen); - LOG(info)<<sTemp; - - sTemp = "CAEN 1290 TDC board index: |-> "; - for( Int_t iIndexCaen = 0; iIndexCaen < fiNbCaenOffset; iIndexCaen++) - sTemp += Form("%3d ", fiBoardIndexCaen[iIndexCaen]); - LOG(info)<<sTemp; - } // if( 0 < fiNbCaenOffset ) - - if( 0 < fiNbTrb3Offset ) - { - TString sTemp = "TRB3 TDC slot index: |- "; - for( Int_t iIndexTrb3 = 0; iIndexTrb3 < fiNbTrb3Offset; iIndexTrb3++) - sTemp += Form("%3d ", iIndexTrb3); - LOG(info)<<sTemp; - - sTemp = "TRB3 TDC board index: |-> "; - for( Int_t iIndexTrb3 = 0; iIndexTrb3 < fiNbTrb3Offset; iIndexTrb3++) - sTemp += Form("%3d ", fiBoardIndexTrb3[iIndexTrb3]); - LOG(info)<<sTemp; - } // if( 0 < fiNbTrb3Offset ) - - if( 0 < fiNbGet4Offset ) - { - TString sTemp = "GET4 TDC slot index: |- "; - for( Int_t iIndexGet4 = 0; iIndexGet4 < fiNbGet4Offset; iIndexGet4++) - sTemp += Form("%3d ", iIndexGet4); - LOG(info)<<sTemp; - - sTemp = "GET4 TDC chip index: |-> "; - for( Int_t iIndexGet4 = 0; iIndexGet4 < fiNbGet4Offset; iIndexGet4++) - sTemp += Form("%3d ", fiBoardIndexGet4[iIndexGet4]); - LOG(info)<<sTemp; - } // if( 0 < fiNbGet4Offset ) - - } // if( 1 == fuEnableTimeOffsetCalibration || 1 == fuEnableTotCalibration ) - - if( 1 == fuEnableTimeOffsetCalibration ) - { - LOG(info)<<" Time offset calibration: ON";; - if( 0 < fiNbVftxOffset ) - { - LOG(info)<<" ------- VFTX TDC ------- ";; - LOG(info)<<" Channel: |- "; - TString sTemp=""; - for( UInt_t uIndexChannel = 0; uIndexChannel < vftxtdc::kuNbChan/2; uIndexChannel++) - sTemp += Form("%5u ", uIndexChannel); - LOG(info)<<sTemp; - - for( Int_t iIndexVftx = 0; iIndexVftx < fiNbVftxOffset; iIndexVftx++) - if( -1 < fiBoardIndexVftx[iIndexVftx] && fiBoardIndexVftx[iIndexVftx] < fiNbVftxOffset ) - { - sTemp = Form(" Slot %02d Board #%02d Time offset: |-> ", iIndexVftx, fiBoardIndexVftx[iIndexVftx]); - for( UInt_t uIndexChannel = 0; uIndexChannel < vftxtdc::kuNbChan/2; uIndexChannel++) - sTemp += Form("%5.0f ", fdTimeOffsetVftx[ vftxtdc::kuNbChan/2 * fiBoardIndexVftx[iIndexVftx] + uIndexChannel]); - LOG(info)<<sTemp; - } // if( -1 < fiBoardIndexVftx[iIndexVftx] ) - else - { - sTemp = Form(" Slot %02d def. mean Time offset: |-> ", iIndexVftx ); - for( UInt_t uIndexChannel = 0; uIndexChannel < vftxtdc::kuNbChan/2; uIndexChannel++) - sTemp += Form("%5.0f ", fdMeanTimeOffsetVftx[uIndexChannel] ); - LOG(info)<<sTemp; - } // else of if( -1 < fiBoardIndexVftx[iIndexVftx] ) - LOG(info); - } // if( 0 < fiNbVftxOffset ) - - if( 0 < fiNbCaenOffset ) - { - LOG(info)<<" ------- CAEN V1290 TDC ------- ";; - LOG(info)<<" Channel: |- "; - TString sTemp=""; - for( UInt_t uIndexChannel = 0; uIndexChannel < caentdc::kuNbChan; uIndexChannel++) - sTemp += Form("%5u ", uIndexChannel); - LOG(info)<<sTemp; - - for( Int_t iIndexCaen = 0; iIndexCaen < fiNbCaenOffset; iIndexCaen++) - if( -1 < fiBoardIndexCaen[iIndexCaen] && fiBoardIndexCaen[iIndexCaen] < fiNbCaenOffset ) - { - sTemp = Form(" Slot %02d Board #%02d Time offset: |-> ", iIndexCaen, fiBoardIndexCaen[iIndexCaen]); - for( UInt_t uIndexChannel = 0; uIndexChannel < caentdc::kuNbChan; uIndexChannel++) - sTemp += Form("%5.0f ", fdTimeOffsetCaen[ caentdc::kuNbChan * fiBoardIndexCaen[iIndexCaen] + uIndexChannel]); - LOG(info)<<sTemp; - } // if( -1 < fiBoardIndexCaen[iIndexCaen] ) - else - { - sTemp = Form(" Slot %02d def. mean Time offset: |-> ", iIndexCaen ); - for( UInt_t uIndexChannel = 0; uIndexChannel < caentdc::kuNbChan/2; uIndexChannel++) - sTemp += Form("%5.0f ", fdMeanTimeOffsetCaen[uIndexChannel] ); - LOG(info)<<sTemp; - } // else of if( -1 < fiBoardIndexCaen[iIndexCaen] ) - LOG(info); - } // if( 0 < fiNbCaenOffset ) - if( 0 < fiNbTrb3Offset ) - { - LOG(info)<<" ------- TRB3 TDC ------- ";; - LOG(info)<<" Channel: |- "; - TString sTemp=""; - for( UInt_t uIndexChannel = 0; uIndexChannel < trbtdc::kuNbChan/2; uIndexChannel++) - sTemp += Form("%5u ", uIndexChannel); - LOG(info)<<sTemp; - - for( Int_t iIndexTrb3 = 0; iIndexTrb3 < fiNbTrb3Offset; iIndexTrb3++) - if( -1 < fiBoardIndexTrb3[iIndexTrb3] && fiBoardIndexTrb3[iIndexTrb3] < fiNbTrb3Offset ) - { - sTemp = Form(" Slot %02d Board #%02d Time offset: |-> ", iIndexTrb3, fiBoardIndexTrb3[iIndexTrb3]); - for( UInt_t uIndexChannel = 0; uIndexChannel < trbtdc::kuNbChan/2; uIndexChannel++) - sTemp += Form("%5.0f ", fdTimeOffsetTrb3[ trbtdc::kuNbChan/2 * fiBoardIndexTrb3[iIndexTrb3] + uIndexChannel]); - LOG(info)<<sTemp; - } // if( -1 < fiBoardIndexTrb3[iIndexTrb3] ) - else - { - sTemp = Form(" Slot %02d def. mean Time offset: |-> ", iIndexTrb3 ); - for( UInt_t uIndexChannel = 0; uIndexChannel < trbtdc::kuNbChan/2; uIndexChannel++) - sTemp += Form("%5.0f ", fdMeanTimeOffsetTrb3[uIndexChannel] ); - LOG(info)<<sTemp; - } // else of if( -1 < fiBoardIndexTrb3[iIndexTrb3] ) - LOG(info); - } // if( 0 < fiNbTrb3Offset ) - if( 0 < fiNbGet4Offset ) - { - LOG(info)<<" ------- GET4 TDC ------- ";; - LOG(info)<<" Channel: |- "; - TString sTemp=""; - for( UInt_t uIndexChannel = 0; uIndexChannel < get4tdc::kuNbChan/2; uIndexChannel++) - sTemp += Form("%5u ", uIndexChannel); - LOG(info)<<sTemp; - - for( Int_t iIndexGet4 = 0; iIndexGet4 < fiNbGet4Offset; iIndexGet4++) - if( -1 < fiBoardIndexGet4[iIndexGet4] && fiBoardIndexGet4[iIndexGet4] < fiNbGet4Offset ) - { - sTemp = Form(" Slot %02d Board #%02d Time offset: |-> ", iIndexGet4, fiBoardIndexGet4[iIndexGet4]); - for( UInt_t uIndexChannel = 0; uIndexChannel < get4tdc::kuNbChan/2; uIndexChannel++) - sTemp += Form("%5.0f ", fdTimeOffsetGet4[ get4tdc::kuNbChan/2 * fiBoardIndexGet4[iIndexGet4] + uIndexChannel]); - LOG(info)<<sTemp; - } // if( -1 < fiBoardIndexGet4[iIndexGet4] ) - else - { - sTemp = Form(" Slot %02d def. mean Time offset: |-> ", iIndexGet4 ); - for( UInt_t uIndexChannel = 0; uIndexChannel < get4tdc::kuNbChan/2; uIndexChannel++) - sTemp += Form("%5.0f ", fdMeanTimeOffsetGet4[uIndexChannel] ); - LOG(info)<<sTemp; - } // else of if( -1 < fiBoardIndexGet4[iIndexGet4] ) - LOG(info); - } // if( 0 < fiNbGet4Offset ) - - } // if( 1 == uEnableTimeOffsetCalibration ) - else LOG(info)<<" Time offset calibration: OFF";; - - if( 1 == fuEnableTotCalibration) - { - LOG(info)<<" Tot offset calibration: ON"; - if( 0 < fiNbVftxOffset ) - { - LOG(info)<<" ------- VFTX TDC ------- ";; - LOG(info)<<" Channel: |- "; - TString sTemp=""; - for( UInt_t uIndexChannel = 0; uIndexChannel < vftxtdc::kuNbChan/2; uIndexChannel++) - sTemp += Form("%5u ", uIndexChannel); - LOG(info)<<sTemp; - - for( Int_t iIndexVftx = 0; iIndexVftx < fiNbVftxOffset; iIndexVftx++) - if( -1 < fiBoardIndexVftx[iIndexVftx] && fiBoardIndexVftx[iIndexVftx] < fiNbVftxOffset ) - { - sTemp = Form(" Slot %02d Board #%02d Tot offset: |-> ", iIndexVftx, fiBoardIndexVftx[iIndexVftx]); - for( UInt_t uIndexChannel = 0; uIndexChannel < vftxtdc::kuNbChan/2; uIndexChannel++) - sTemp += Form("%5.0f ", fdTotOffsetVftx[ vftxtdc::kuNbChan/2 * fiBoardIndexVftx[iIndexVftx] + uIndexChannel]); - LOG(info)<<sTemp; - } // if( -1 < fiBoardIndexVftx[iIndexVftx] ) - else - { - sTemp = Form(" Slot %02d def. mean Tot offset: |-> ", iIndexVftx ); - for( UInt_t uIndexChannel = 0; uIndexChannel < vftxtdc::kuNbChan/2; uIndexChannel++) - sTemp += Form("%5.0f ", fdMeanTotOffsetVftx[uIndexChannel] ); - LOG(info)<<sTemp; - } // else of if( -1 < fiBoardIndexVftx[iIndexVftx] ) - LOG(info); - } // if( 0 < fiNbVftxOffset ) - - if( 0 < fiNbCaenOffset ) - { - LOG(info)<<" ------- CAEN V1290 TDC ------- ";; - LOG(info)<<" Channel: |- "; - TString sTemp=""; - for( UInt_t uIndexChannel = 0; uIndexChannel < caentdc::kuNbChan; uIndexChannel++) - sTemp += Form("%5u ", uIndexChannel); - LOG(info)<<sTemp; - - for( Int_t iIndexCaen = 0; iIndexCaen < fiNbCaenOffset; iIndexCaen++) - if( -1 < fiBoardIndexCaen[iIndexCaen] && fiBoardIndexCaen[iIndexCaen] < fiNbCaenOffset ) - { - sTemp = Form(" Slot %02d Board #%02d Tot offset: |-> ", iIndexCaen, fiBoardIndexCaen[iIndexCaen]); - for( UInt_t uIndexChannel = 0; uIndexChannel < caentdc::kuNbChan; uIndexChannel++) - sTemp += Form("%5.0f ", fdTotOffsetCaen[ caentdc::kuNbChan * fiBoardIndexCaen[iIndexCaen] + uIndexChannel]); - LOG(info)<<sTemp; - } // if( -1 < fiBoardIndexCaen[iIndexCaen] ) - else - { - sTemp = Form(" Slot %02d def. mean Tot offset: |-> ", iIndexCaen ); - for( UInt_t uIndexChannel = 0; uIndexChannel < caentdc::kuNbChan/2; uIndexChannel++) - sTemp += Form("%5.0f ", fdMeanTotOffsetCaen[uIndexChannel] ); - LOG(info)<<sTemp; - } // else of if( -1 < fiBoardIndexCaen[iIndexCaen] ) - LOG(info); - } // if( 0 < fiNbCaenOffset ) - if( 0 < fiNbTrb3Offset ) - { - LOG(info)<<" ------- TRB3 TDC ------- ";; - LOG(info)<<" Channel: |- "; - TString sTemp=""; - for( UInt_t uIndexChannel = 0; uIndexChannel < trbtdc::kuNbChan/2; uIndexChannel++) - sTemp += Form("%5u ", uIndexChannel); - LOG(info)<<sTemp; - - for( Int_t iIndexTrb3 = 0; iIndexTrb3 < fiNbTrb3Offset; iIndexTrb3++) - if( -1 < fiBoardIndexTrb3[iIndexTrb3] && fiBoardIndexTrb3[iIndexTrb3] < fiNbTrb3Offset ) - { - sTemp = Form(" Slot %02d Board #%02d Tot offset: |-> ", iIndexTrb3, fiBoardIndexTrb3[iIndexTrb3]); - for( UInt_t uIndexChannel = 0; uIndexChannel < trbtdc::kuNbChan/2; uIndexChannel++) - sTemp += Form("%5.0f ", fdTotOffsetTrb3[ trbtdc::kuNbChan/2 * fiBoardIndexTrb3[iIndexTrb3] + uIndexChannel]); - LOG(info)<<sTemp; - } // if( -1 < fiBoardIndexTrb3[iIndexTrb3] ) - else - { - sTemp = Form(" Slot %02d def. mean Tot offset: |-> ", iIndexTrb3 ); - for( UInt_t uIndexChannel = 0; uIndexChannel < trbtdc::kuNbChan/2; uIndexChannel++) - sTemp += Form("%5.0f ", fdMeanTotOffsetTrb3[uIndexChannel] ); - LOG(info)<<sTemp; - } // else of if( -1 < fiBoardIndexTrb3[iIndexTrb3] ) - LOG(info); - } // if( 0 < fiNbTrb3Offset ) - if( 0 < fiNbGet4Offset ) - { - LOG(info)<<" ------- GET4 TDC ------- ";; - LOG(info)<<" Channel: |- "; - TString sTemp=""; - for( UInt_t uIndexChannel = 0; uIndexChannel < 4 * get4tdc::kuNbChan/2; uIndexChannel++) - sTemp += Form("%5u ", uIndexChannel); - LOG(info)<<sTemp; - - for( Int_t iIndexGet4 = 0; iIndexGet4 < fiNbGet4Offset; iIndexGet4++) - if( -1 < fiBoardIndexGet4[iIndexGet4] && fiBoardIndexGet4[iIndexGet4] < fiNbGet4Offset ) - { - sTemp = Form(" Slot %02d Board #%02d Tot offset: |-> ", iIndexGet4, fiBoardIndexGet4[iIndexGet4]); - for( UInt_t uIndexChannel = 0; uIndexChannel < get4tdc::kuNbChan/2; uIndexChannel++) - sTemp += Form("%5f ", fdTotOffsetGet4[ get4tdc::kuNbChan/2 * fiBoardIndexGet4[iIndexGet4] + uIndexChannel]); - LOG(info)<<sTemp; - } // if( -1 < fiBoardIndexGet4[iIndexGet4] ) - else - { - sTemp = Form(" Slot %02d def. mean Tot offset: |-> ", iIndexGet4 ); - for( UInt_t uIndexChannel = 0; uIndexChannel < get4tdc::kuNbChan/2; uIndexChannel++) - sTemp += Form("%5f ", fdMeanTotOffsetGet4[uIndexChannel] ); - LOG(info)<<sTemp; - } // else of if( -1 < fiBoardIndexGet4[iIndexGet4] ) - LOG(info); - } // if( 0 < fiNbGet4Offset ) - - } // if( 1 == uEnableTotCalibration) - else LOG(info)<<" Tot offset calibration: OFF"; - - // TDC to TDC offsets - if(1 == fuManualTdcOffsetEnable) - { - LOG(info)<<" Manual tdc to tdc offset: ON"; - if( 0 < fiNbVftxCalib ) - { - TString sTemp = " VFTX FPGA TDC index: |- "; - for( Int_t iIndexVftx = 0; iIndexVftx < fiNbVftxCalib; iIndexVftx++) - sTemp += Form("%3d ", iIndexVftx); - LOG(info)<<sTemp; - - sTemp = " Manual offset val., clock: |-> "; - for( Int_t iIndexVftx = 0; iIndexVftx < fiNbVftxCalib; iIndexVftx++) - sTemp += Form("%3d ", fiTdcToTdcOffsetVftx[iIndexVftx]); - LOG(info)<<sTemp; - } // if( 0 < fiNbVftxCalib ) - - if( 0 < fiNbCaenCalib ) - { - TString sTemp = " VFTX FPGA TDC index: |- "; - for( Int_t iIndexCaen = 0; iIndexCaen < fiNbCaenCalib; iIndexCaen++) - sTemp += Form("%3d ", iIndexCaen); - LOG(info)<<sTemp; - - sTemp = " Manual offset val., clock: |-> "; - for( Int_t iIndexCaen = 0; iIndexCaen < fiNbCaenCalib; iIndexCaen++) - sTemp += Form("%3d ", fiTdcToTdcOffsetCaen[iIndexCaen]); - LOG(info)<<sTemp; - } // if( 0 < fiNbCaenCalib ) - if( 0 < fiNbTrb3Calib ) - { - TString sTemp = " VFTX FPGA TDC index: |- "; - for( Int_t iIndexTrb3 = 0; iIndexTrb3 < fiNbTrb3Calib; iIndexTrb3++) - sTemp += Form("%3d ", iIndexTrb3); - LOG(info)<<sTemp; - - sTemp = " Manual offset val., clock: |-> "; - for( Int_t iIndexTrb3 = 0; iIndexTrb3 < fiNbTrb3Calib; iIndexTrb3++) - sTemp += Form("%3d ", fiTdcToTdcOffsetTrb3[iIndexTrb3]); - LOG(info)<<sTemp; - } // if( 0 < fiNbTrb3Calib ) - if( 0 < fiNbGet4Calib ) - { - TString sTemp = " VFTX FPGA TDC index: |- "; - for( Int_t iIndexGet4 = 0; iIndexGet4 < fiNbGet4Calib; iIndexGet4++) - sTemp += Form("%3d ", iIndexGet4); - LOG(info)<<sTemp; - - sTemp = " Manual offset val., clock: |-> "; - for( Int_t iIndexGet4 = 0; iIndexGet4 < fiNbGet4Calib; iIndexGet4++) - sTemp += Form("%3d ", fiTdcToTdcOffsetGet4[iIndexGet4]); - LOG(info)<<sTemp; - } // if( 0 < fiNbGet4Calib ) - - } - else LOG(info)<<" Manual tdc offset detection: OFF"; - if(1 == fuAutomaticOffsetEnable) - { - LOG(info)<<" Automatic tdc offset detection: ON"; - LOG(info)<<" Auto tdc offset det. main VFTX TDC: "<<fiMainReferenceTdcVftx; - LOG(info)<<" Auto tdc offset det. main CAEN TDC: "<<fiMainReferenceTdcCaen; - LOG(info)<<" Auto tdc offset det. main TRB3 TDC: "<<fiMainReferenceTdcTrb3; - LOG(info)<<" Auto tdc offset det. main GET4 TDC: "<<fiMainReferenceTdcGet4; - } - else LOG(info)<<" Automatic tdc offset detection: OFF"; - - /** Tot calculation **/ - switch( fiTotModeVftx ) - { - case 0: - LOG(info)<<" VFTX TOT calculation mode: None"; - break; - case 2: - LOG(info)<<" VFTX TOT calculation mode: 2 TDC channels per input channel (even = Falling, odd = Rising)"; - break; - default: - LOG(info)<<" VFTX TOT calculation mode: Wrong one => none"; - break; - } // switch( fiTotModeVftx ) - switch( fiTotModeCaen ) - { - case 0: - LOG(info)<<" CAEN TOT calculation mode: None"; - break; - case 1: - LOG(info)<<" CAEN TOT calculation mode: Same TDC channel, diff data (Use edge flag)"; - break; - case 2: - LOG(info)<<" CAEN TOT calculation mode: 2 input channels per front end channel (even = Falling, odd = Rising)"; - break; - case 3: - LOG(info)<<" CAEN TOT calculation mode: Same input channels in 2 consecutive boards (even = Rising, odd = Falling)"; - break; - default: - LOG(info)<<" CAEN TOT calculation mode: Wrong one => none"; - break; - } // switch( fiTotModeCaen ) - switch( fiTotModeTrb3 ) - { - case 0: - LOG(info)<<" TRB3 TOT calculation mode: None"; - break; - case 2: - LOG(info)<<" TRB3 TOT calculation mode: 2 TDC channels per input channel (even = Falling, odd = Rising)"; - break; - default: - LOG(info)<<" TRB3 TOT calculation mode: Wrong one => none"; - break; - } // switch( fiTotModeTrb3 ) - switch( fiTotModeGet4 ) - { - case 0: - LOG(info)<<" GET4 TOT calculation mode: None"; - break; - case 1: - LOG(info)<<" GET4 TOT calculation mode: Same TDC channel, diff data (Use edge flag)"; - break; - case 2: - LOG(info)<<" GET4 TOT calculation mode: 2 TDC channels per front end channel (even = Falling, odd = Rising)"; - break; - case 4: - LOG(info)<<" GET4 TOT calculation mode: Same TDC channel, same data"; - break; - default: - LOG(info)<<" GET4 TOT calculation mode: Wrong one => none"; - break; - } // switch( fiTotModeVftx ) - if( 0 < fiTotModeVftx && 0 < fiNbVftxTotInvFlag ) - { - LOG(info)<<" VFTX TOT Inversion flags:"; - LOG(info)<<" Channel: |- "; - TString sTemp=""; - for( UInt_t uIndexChannel = 0; uIndexChannel < vftxtdc::kuNbChan/2; uIndexChannel++) - sTemp += Form("%3u ", uIndexChannel); - LOG(info)<<sTemp; - - for( Int_t iIndexTdc = 0; iIndexTdc < fiNbVftxTotInvFlag; iIndexTdc++) - { - sTemp = Form(" Slot %02d Tot Inversion flags: |-> ", iIndexTdc); - for( UInt_t uIndexChannel = 0; uIndexChannel < vftxtdc::kuNbChan/2; uIndexChannel++) - sTemp += Form("%3d ", fiTotInversionFlagVftx[ vftxtdc::kuNbChan/2 * iIndexTdc + uIndexChannel]); - LOG(info)<<sTemp; - } // for( Int_t iIndexTdc = 0; iIndexTdc < fiNbVftxTotInvFlag; iIndexTdc++) - LOG(info); - } // if( 0 < fiTotModeVftx && 0 < fiNbVftxTotInvFlag ) - - if( 0 < fiTotModeCaen && 0 < fiNbCaenTotInvFlag ) - { - LOG(info)<<" CAEN TOT Inversion flags:"; - LOG(info)<<" Channel: |- "; - TString sTemp=""; - for( UInt_t uIndexChannel = 0; uIndexChannel < caentdc::kuNbChan; uIndexChannel++) - sTemp += Form("%3u ", uIndexChannel); - LOG(info)<<sTemp; - - for( Int_t iIndexTdc = 0; iIndexTdc < fiNbCaenTotInvFlag; iIndexTdc++) - { - sTemp = Form(" Slot %02d Tot Inversion flags: |-> ", iIndexTdc); - for( UInt_t uIndexChannel = 0; uIndexChannel < caentdc::kuNbChan; uIndexChannel++) - sTemp += Form("%3d ", fiTotInversionFlagCaen[ caentdc::kuNbChan * iIndexTdc + uIndexChannel]); - LOG(info)<<sTemp; - } // for( Int_t iIndexTdc = 0; iIndexTdc < fiNbCaenTotInvFlag; iIndexTdc++) - LOG(info); - } // if( 0 < fiTotModeCaen && 0 < fiNbCaenTotInvFlag ) - if( 0 < fiTotModeTrb3 && 0 < fiNbTrb3TotInvFlag ) - { - LOG(info)<<" TRB3 TOT Inversion flags:"; - LOG(info)<<" Channel: |- "; - TString sTemp=""; - for( UInt_t uIndexChannel = 0; uIndexChannel < trbtdc::kuNbChan/2; uIndexChannel++) - sTemp += Form("%3u ", uIndexChannel); - LOG(info)<<sTemp; - - for( Int_t iIndexTdc = 0; iIndexTdc < fiNbTrb3TotInvFlag; iIndexTdc++) - { - sTemp = Form(" Slot %02d Tot Inversion flags: |-> ", iIndexTdc); - for( UInt_t uIndexChannel = 0; uIndexChannel < trbtdc::kuNbChan/2; uIndexChannel++) - sTemp += Form("%3d ", fiTotInversionFlagTrb3[ trbtdc::kuNbChan/2 * iIndexTdc + uIndexChannel]); - LOG(info)<<sTemp; - } // for( Int_t iIndexTdc = 0; iIndexTdc < fiNbTrb3TotInvFlag; iIndexTdc++) - LOG(info); - } // if( 0 < fiTotModeTrb3 && 0 < fiNbTrb3TotInvFlag ) - if( 0 < fiTotModeGet4 && 0 < fiNbGet4TotInvFlag ) - { - LOG(info)<<" GET4 TOT Inversion flags:"; - LOG(info)<<" Channel: |- "; - TString sTemp=""; - for( UInt_t uIndexChannel = 0; uIndexChannel < get4tdc::kuNbChan/2; uIndexChannel++) - sTemp += Form("%3u ", uIndexChannel); - LOG(info)<<sTemp; - - for( Int_t iIndexTdc = 0; iIndexTdc < fiNbGet4TotInvFlag; iIndexTdc++) - { - sTemp = Form(" Slot %02d Tot Inversion flags: |-> ", iIndexTdc); - for( UInt_t uIndexChannel = 0; uIndexChannel < get4tdc::kuNbChan/2; uIndexChannel++) - sTemp += Form("%3d ", fiTotInversionFlagGet4[ get4tdc::kuNbChan/2 * iIndexTdc + uIndexChannel]); - LOG(info)<<sTemp; - } // for( Int_t iIndexTdc = 0; iIndexTdc < fiNbGet4TotInvFlag; iIndexTdc++) - LOG(info); - } // if( 0 < fiTotModeGet4 && 0 < fiNbGet4TotInvFlag ) - - - // Histograms - if( 1 == fuTimeHistEnable ) - LOG(info)<<" Trigger - Calib. Time Histograms: ON"; - else LOG(info)<<" Trigger - Calib. Time Histograms: OFF"; - if( 1 == fuTimeHistSinglesEnable ) - LOG(info)<<" Trig. - Calib. Time Histo, Multi 1: ON"; - else LOG(info)<<" Trig. - Calib. Time Histo, Multi 1: OFF"; - if( 1 == fuTotHistoEnable ) - LOG(info)<<" Tot Histograms : ON"; - else LOG(info)<<" Tot Histograms : OFF"; - if( 1 == fuMultiHitsDistanceHistoEnable ) - LOG(info)<<" Histograms Distance Multi Hits: ON"; - else LOG(info)<<" Histograms Distance Multi Hits: OFF"; - LOG(info); - - // TDC offsets - if( 1 == fuTdcOffsetEnable ) - { - LOG(info)<<" TDC to TDC offset event wise, all: ON"; - } - else - { - LOG(info)<<" TDC to TDC offset event wise, all: OFF"; - LOG(info)<<"++TDC to TDC offset event wise, per TDC:"; - if( 0 < fiNbVftxCalib ) - { - TString sTemp = " VFTX FPGA TDC index: |- "; - for( Int_t iIndexVftx = 0; iIndexVftx < fiNbVftxCalib; iIndexVftx++) - sTemp += Form("%3d ", iIndexVftx); - LOG(info)<<sTemp; - - sTemp = " TDC w/ offset enabled: |-> "; - for( Int_t iIndexVftx = 0; iIndexVftx < fiNbVftxCalib; iIndexVftx++) - sTemp += Form("%3d ", fiTdcOffsetEnaFlagVftx[iIndexVftx]); - LOG(info)<<sTemp; - } // if( 0 < fiNbVftxCalib ) - - if( 0 < fiNbCaenCalib ) - { - TString sTemp = " VFTX FPGA TDC index: |- "; - for( Int_t iIndexCaen = 0; iIndexCaen < fiNbCaenCalib; iIndexCaen++) - sTemp += Form("%3d ", iIndexCaen); - LOG(info)<<sTemp; - - sTemp = " TDC w/ offset enabled: |-> "; - for( Int_t iIndexCaen = 0; iIndexCaen < fiNbCaenCalib; iIndexCaen++) - sTemp += Form("%3d ", fiTdcOffsetEnaFlagCaen[iIndexCaen]); - LOG(info)<<sTemp; - } // if( 0 < fiNbCaenCalib ) - if( 0 < fiNbTrb3Calib ) - { - TString sTemp = " VFTX FPGA TDC index: |- "; - for( Int_t iIndexTrb3 = 0; iIndexTrb3 < fiNbTrb3Calib; iIndexTrb3++) - sTemp += Form("%3d ", iIndexTrb3); - LOG(info)<<sTemp; - - sTemp = " TDC w/ offset enabled: |-> "; - for( Int_t iIndexTrb3 = 0; iIndexTrb3 < fiNbTrb3Calib; iIndexTrb3++) - sTemp += Form("%3d ", fiTdcOffsetEnaFlagTrb3[iIndexTrb3]); - LOG(info)<<sTemp; - } // if( 0 < fiNbTrb3Calib ) - if( 0 < fiNbGet4Calib ) - { - TString sTemp = " VFTX FPGA TDC index: |- "; - for( Int_t iIndexGet4 = 0; iIndexGet4 < fiNbGet4Calib; iIndexGet4++) - sTemp += Form("%3d ", iIndexGet4); - LOG(info)<<sTemp; - - sTemp = " TDC w/ offset enabled: |-> "; - for( Int_t iIndexGet4 = 0; iIndexGet4 < fiNbGet4Calib; iIndexGet4++) - sTemp += Form("%3d ", fiTdcOffsetEnaFlagGet4[iIndexGet4]); - LOG(info)<<sTemp; - } // if( 0 < fiNbGet4Calib ) - } // else of if( 1 == fuTdcOffsetEnable ) - - LOG(info)<<" Main TDC for TDC offset w/ ref. ch: "<<fuTdcOffsetMainTdc; - - if( 1 == fuTrbOffsetLinearEnable ) - LOG(info)<<" Linear calib. for TRB-TDC offsets: Allowed"; - else LOG(info)<<" Trigger - Calib. Time Histograms: OFF"; - - if( -1 < fiChannelResolutionTest ) - LOG(info)<<" Channel for TDC to TDC reso. check: "<<fiChannelResolutionTest; - else LOG(info)<<" TDC to TDC resolution check: OFF"; - LOG(info); - - return; -} -// ----------------------------------------------------------------// -// Accessors -Int_t TMbsCalibTofPar::GetNbCalibBoards( UInt_t uType) const -{ - switch( uType ) - { - case toftdc::caenV1290: - return fiNbCaenCalib; - break; - case toftdc::vftx: - return fiNbVftxCalib; - break; - case toftdc::trb: - return fiNbTrb3Calib; - break; - case toftdc::get4: - return fiNbGet4Calib; - break; - case toftdc::undef: - default: - return 0; - break; - } // switch( uType ) -} -Int_t TMbsCalibTofPar::GetInitialCalInd( UInt_t uType, UInt_t uBoard ) const -{ - switch( uType ) - { - case toftdc::caenV1290: - if( static_cast<Int_t>(uBoard) < fiNbCaenCalib && 0 < fiInitialCalIndexCaen.GetSize() ) - return fiInitialCalIndexCaen[uBoard]; - else return -1; - break; - case toftdc::vftx: - if( static_cast<Int_t>(uBoard) < fiNbVftxCalib && 0 < fiInitialCalIndexVftx.GetSize() ) - return fiInitialCalIndexVftx[uBoard]; - else return -1; - break; - case toftdc::trb: - if( static_cast<Int_t>(uBoard) < fiNbTrb3Calib && 0 < fiInitialCalIndexTrb3.GetSize() ) - return fiInitialCalIndexTrb3[uBoard]; - else return -1; - break; - case toftdc::get4: - if( static_cast<Int_t>(uBoard) < fiNbGet4Calib && 0 < fiInitialCalIndexGet4.GetSize() ) - return fiInitialCalIndexGet4[uBoard]; - else return -1; - break; - case toftdc::undef: - default: - return -1; - break; - } // switch( uType ) -} -Int_t TMbsCalibTofPar::GetNbOffsetBoard( UInt_t uType) const -{ - switch( uType ) - { - case toftdc::caenV1290: - return fiNbCaenOffset; - break; - case toftdc::vftx: - return fiNbVftxOffset; - break; - case toftdc::trb: - return fiNbTrb3Offset; - break; - case toftdc::get4: - return fiNbGet4Offset; - break; - case toftdc::undef: - default: - return 0; - break; - } // switch( uType ) -} -Int_t TMbsCalibTofPar::GetOffsetBoardInd( UInt_t uType, UInt_t uSlot ) const -{ - switch( uType ) - { - case toftdc::caenV1290: - if( static_cast<Int_t>(uSlot) < fiNbCaenOffset && 0 < fiBoardIndexCaen.GetSize() ) - return fiBoardIndexCaen[uSlot]; - else return -1; - break; - case toftdc::vftx: - if( static_cast<Int_t>(uSlot) < fiNbVftxOffset && 0 < fiBoardIndexVftx.GetSize() ) - return fiBoardIndexVftx[uSlot]; - else return -1; - break; - case toftdc::trb: - if( static_cast<Int_t>(uSlot) < fiNbTrb3Offset && 0 < fiBoardIndexTrb3.GetSize() ) - return fiBoardIndexTrb3[uSlot]; - else return -1; - break; - case toftdc::get4: - if( static_cast<Int_t>(uSlot) < fiNbGet4Offset && 0 < fiBoardIndexGet4.GetSize() ) - return fiBoardIndexGet4[uSlot]; - else return -1; - break; - case toftdc::undef: - default: - return -1; - break; - } // switch( uType ) -} -Int_t TMbsCalibTofPar::GetTimeOffsetVal( UInt_t uType, UInt_t uSlot, UInt_t uChan ) const -{ - Int_t iBoardIndex = GetOffsetBoardInd( uType, uSlot); - if( 0 <= iBoardIndex ) - { - switch( uType ) - { - case toftdc::caenV1290: - if( 0 < fdMeanTimeOffsetCaen.GetSize() && - uChan < caentdc::kuNbChan ) - return fdTimeOffsetCaen[ iBoardIndex * caentdc::kuNbChan + uChan]; - else return 0; - break; - case toftdc::vftx: - if( 0 < fdMeanTimeOffsetVftx.GetSize() && - uChan < vftxtdc::kuNbChan/2 ) - return fdTimeOffsetVftx[iBoardIndex * vftxtdc::kuNbChan/2 + uChan]; - else return 0; - break; - case toftdc::trb: - if( 0 < fdMeanTimeOffsetTrb3.GetSize() && - uChan < trbtdc::kuNbChan/2 ) - return fdTimeOffsetTrb3[iBoardIndex * trbtdc::kuNbChan/2 + uChan]; - else return 0; - break; - case toftdc::get4: - if( 0 < fdMeanTimeOffsetGet4.GetSize() && - uChan < get4tdc::kuNbChan/2 ) - return fdTimeOffsetGet4[iBoardIndex * get4tdc::kuNbChan/2 + uChan]; - else return 0; - break; - case toftdc::undef: - default: - return 0; - break; - } // switch( uType ) - } // if( 0 <= iBoardIndex ) - else switch( uType ) - { - case toftdc::caenV1290: - if( static_cast<Int_t>(caentdc::kuNbChan) == fdMeanTimeOffsetCaen.GetSize() && - uChan < caentdc::kuNbChan ) - return fdMeanTimeOffsetCaen[uChan]; - else return 0; - break; - case toftdc::vftx: - if( static_cast<Int_t>(vftxtdc::kuNbChan/2) == fdMeanTimeOffsetVftx.GetSize() && - uChan < vftxtdc::kuNbChan/2 ) - return fdMeanTimeOffsetVftx[uChan]; - else return 0; - break; - case toftdc::trb: - if( static_cast<Int_t>(trbtdc::kuNbChan/2) == fdMeanTimeOffsetTrb3.GetSize() && - uChan < trbtdc::kuNbChan/2 ) - return fdMeanTimeOffsetTrb3[uChan]; - else return 0; - break; - case toftdc::get4: - if( static_cast<Int_t>(get4tdc::kuNbChan) == fdMeanTimeOffsetGet4.GetSize() && - uChan < get4tdc::kuNbChan/2 ) - return fdMeanTimeOffsetGet4[uChan]; - else return 0; - break; - case toftdc::undef: - default: - return 0; - break; - } // else switch( uType ) of if( 0 <= iBoardIndex ) -} -Int_t TMbsCalibTofPar::GetTotOffsetVal( UInt_t uType, UInt_t uSlot, UInt_t uChan ) const -{ - Int_t iBoardIndex = GetOffsetBoardInd( uType, uSlot); - if( 0 <= iBoardIndex ) - { - switch( uType ) - { - case toftdc::caenV1290: - if( 0 < fdTotOffsetCaen.GetSize() && - uChan < caentdc::kuNbChan ) - return fdTotOffsetCaen[ iBoardIndex * caentdc::kuNbChan + uChan]; - else return 0; - break; - case toftdc::vftx: - if( 0 < fdTotOffsetVftx.GetSize() && - uChan < vftxtdc::kuNbChan/2 ) - return fdTotOffsetVftx[iBoardIndex * vftxtdc::kuNbChan/2 + uChan]; - else return 0; - break; - case toftdc::trb: - if( 0 < fdTotOffsetTrb3.GetSize() && - uChan < trbtdc::kuNbChan/2 ) - return fdTotOffsetTrb3[iBoardIndex * trbtdc::kuNbChan/2 + uChan]; - else return 0; - break; - case toftdc::get4: - if( 0 < fdTotOffsetGet4.GetSize() && - uChan < get4tdc::kuNbChan/2 ) - return fdTotOffsetGet4[iBoardIndex * get4tdc::kuNbChan/2 + uChan]; - else return 0; - break; - case toftdc::undef: - default: - return 0; - break; - } // switch( uType ) - } // if( 0 <= iBoardIndex ) - else switch( uType ) - { - case toftdc::caenV1290: - if( static_cast<Int_t>(caentdc::kuNbChan) == fdMeanTotOffsetCaen.GetSize() && - uChan < caentdc::kuNbChan ) - return fdMeanTotOffsetCaen[uChan]; - else return 0; - break; - case toftdc::vftx: - if( static_cast<Int_t>(vftxtdc::kuNbChan/2) == fdMeanTotOffsetVftx.GetSize() && - uChan < vftxtdc::kuNbChan/2 ) - return fdMeanTotOffsetVftx[uChan]; - else return 0; - break; - case toftdc::trb: - if( static_cast<Int_t>(trbtdc::kuNbChan/2) == fdMeanTotOffsetTrb3.GetSize() && - uChan < trbtdc::kuNbChan/2 ) - return fdMeanTotOffsetTrb3[uChan]; - else return 0; - break; - case toftdc::get4: - if( static_cast<Int_t>(get4tdc::kuNbChan) == fdMeanTotOffsetGet4.GetSize() && - uChan < get4tdc::kuNbChan/2 ) - return fdMeanTotOffsetGet4[uChan]; - else return 0; - break; - case toftdc::undef: - default: - return 0; - break; - } // else switch( uType ) of if( 0 <= iBoardIndex ) -} -Int_t TMbsCalibTofPar::GetTdcTdcOffset( UInt_t uType, UInt_t uBoard ) const -{ - switch( uType ) - { - case toftdc::caenV1290: - if( static_cast<Int_t>(uBoard) < fiNbCaenCalib && 0 < fiTdcToTdcOffsetCaen.GetSize() ) - return fiTdcToTdcOffsetCaen[uBoard]; - else return 0; - break; - case toftdc::vftx: - if( static_cast<Int_t>(uBoard) < fiNbVftxCalib && 0 < fiTdcToTdcOffsetVftx.GetSize() ) - return fiTdcToTdcOffsetVftx[uBoard]; - else return 0; - break; - case toftdc::trb: - if( static_cast<Int_t>(uBoard) < fiNbTrb3Calib && 0 < fiTdcToTdcOffsetTrb3.GetSize() ) - return fiTdcToTdcOffsetTrb3[uBoard]; - else return 0; - break; - case toftdc::get4: - if( static_cast<Int_t>(uBoard) < fiNbGet4Calib && 0 < fiTdcToTdcOffsetGet4.GetSize() ) - return fiTdcToTdcOffsetGet4[uBoard]; - else return 0; - break; - case toftdc::undef: - default: - return 0; - break; - } // switch( uType ) -} -Int_t TMbsCalibTofPar::GetMainTdcTdcOffset( UInt_t uType ) const -{ - switch( uType ) - { - case toftdc::caenV1290: - return fiMainReferenceTdcCaen; - break; - case toftdc::vftx: - return fiMainReferenceTdcVftx; - break; - case toftdc::trb: - return fiMainReferenceTdcTrb3; - break; - case toftdc::get4: - return fiMainReferenceTdcGet4; - break; - case toftdc::undef: - default: - return 0; - break; - } // switch( uType ) -} -Int_t TMbsCalibTofPar::GetTotMode( UInt_t uType ) const -{ - switch( uType ) - { - case toftdc::caenV1290: - return fiTotModeCaen; - break; - case toftdc::vftx: - return fiTotModeVftx; - break; - case toftdc::trb: - return fiTotModeTrb3; - break; - case toftdc::get4: - return fiTotModeGet4; - break; - case toftdc::undef: - default: - return 0; - break; - } // switch( uType ) -} - -Bool_t TMbsCalibTofPar::CheckTotInvFlag( UInt_t uType, UInt_t uSlot ) const -{ - switch( uType ) - { - case toftdc::caenV1290: - if( static_cast<Int_t>(uSlot) < fiNbCaenTotInvFlag && - 0 < fiTotInversionFlagCaen.GetSize() ) - return kTRUE; - else return kFALSE; - break; - case toftdc::vftx: - if( static_cast<Int_t>(uSlot) < fiNbVftxTotInvFlag && - 0 < fiTotInversionFlagVftx.GetSize() ) - return kTRUE; - else return kFALSE; - break; - case toftdc::trb: - if( static_cast<Int_t>(uSlot) < fiNbTrb3TotInvFlag && - 0 < fiTotInversionFlagTrb3.GetSize() ) - return kTRUE; - else - { - LOG(error)<<Form("Only %d inversion flags available.",fiNbTrb3TotInvFlag); - return kFALSE; - } - break; - case toftdc::get4: - if( static_cast<Int_t>(uSlot) < fiNbGet4TotInvFlag && - 0 < fiTotInversionFlagGet4.GetSize() ) - return kTRUE; - else return kFALSE; - break; - case toftdc::undef: - default: - return kFALSE; - break; - } // switch( uType ) -} - -Int_t TMbsCalibTofPar::GetTotInvFlag( UInt_t uType, UInt_t uSlot, UInt_t uChan ) const -{ - switch( uType ) - { - case toftdc::caenV1290: - if( static_cast<Int_t>(uSlot) < fiNbCaenTotInvFlag && - 0 < fiTotInversionFlagCaen.GetSize() && - uChan < caentdc::kuNbChan ) - return fiTotInversionFlagCaen[uSlot * caentdc::kuNbChan + uChan]; - else return 0; - break; - case toftdc::vftx: - if( static_cast<Int_t>(uSlot) < fiNbVftxTotInvFlag && - 0 < fiTotInversionFlagVftx.GetSize() && - uChan < vftxtdc::kuNbChan/2 ) - return fiTotInversionFlagVftx[uSlot * vftxtdc::kuNbChan/2 + uChan]; - else return 0; - break; - case toftdc::trb: - if( static_cast<Int_t>(uSlot) < fiNbTrb3TotInvFlag && - 0 < fiTotInversionFlagTrb3.GetSize() && - uChan < trbtdc::kuNbChan/2 ) - return fiTotInversionFlagTrb3[uSlot * trbtdc::kuNbChan/2 + uChan]; - else return 0; - break; - case toftdc::get4: - if( static_cast<Int_t>(uSlot) < fiNbGet4TotInvFlag && - 0 < fiTotInversionFlagGet4.GetSize() && - uChan < get4tdc::kuNbChan/2 ) - return fiTotInversionFlagGet4[uSlot * get4tdc::kuNbChan/2 + uChan]; - else return 0; - break; - case toftdc::undef: - default: - return 0; - break; - } // switch( uType ) -} - -Bool_t TMbsCalibTofPar::GetTdcOffEnaFlag( UInt_t uType, UInt_t uBoard ) const -{ - // The parameter to enable the TDC offset on a single TDC basis is - // used only if the offset is NOT enabled for all TDCs - if( kFALSE == IsTdcOffsetEna() ) - { - switch( uType ) - { - case toftdc::caenV1290: - if( static_cast<Int_t>(uBoard) < fiNbCaenCalib && 0 < fiTdcOffsetEnaFlagVftx.GetSize() ) - return (1 == fiTdcOffsetEnaFlagVftx[uBoard])? kTRUE: kFALSE; - else return kFALSE; - break; - case toftdc::vftx: - if( static_cast<Int_t>(uBoard) < fiNbVftxCalib && 0 < fiTdcOffsetEnaFlagCaen.GetSize() ) - return (1 == fiTdcOffsetEnaFlagCaen[uBoard])? kTRUE: kFALSE; - else return kFALSE; - break; - case toftdc::trb: - if( static_cast<Int_t>(uBoard) < fiNbTrb3Calib && 0 < fiTdcOffsetEnaFlagTrb3.GetSize() ) - return (1 == fiTdcOffsetEnaFlagTrb3[uBoard])? kTRUE: kFALSE; - else return kFALSE; - break; - case toftdc::get4: - if( static_cast<Int_t>(uBoard) < fiNbGet4Calib && 0 < fiTdcOffsetEnaFlagGet4.GetSize() ) - return (1 == fiTdcOffsetEnaFlagGet4[uBoard])? kTRUE: kFALSE; - else return kFALSE; - break; - case toftdc::undef: - default: - return kFALSE; - break; - } // switch( uType ) - } - else return IsTdcOffsetEna(); -} diff --git a/beamtime/tof/calib/TMbsCalibTofPar.h b/beamtime/tof/calib/TMbsCalibTofPar.h deleted file mode 100644 index 43dd1e025f2bbb218795868d5d435a5fa28b1144..0000000000000000000000000000000000000000 --- a/beamtime/tof/calib/TMbsCalibTofPar.h +++ /dev/null @@ -1,244 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TMbsCalibTofPar ----- -// ----- Created 08/05/2013 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ -#ifndef _TMBSCALIBTOFPAR_H_ -#define _TMBSCALIBTOFPAR_H_ - -#include "TofTdcDef.h" - -#include "FairParGenericSet.h" -#include "TArrayI.h" -#include "TArrayD.h" - -class TMbsCalibTofPar : public FairParGenericSet -{ - public: - TMbsCalibTofPar() ; - - TMbsCalibTofPar( const char* name, - const char* title="Mbs Calib parameters for the ToF", - const char* context="TestDefaultContext" ); - - virtual ~TMbsCalibTofPar(); - - // Accessors - Bool_t IsDebug() const { return (1 == fuCalibDebug)? kTRUE: kFALSE; }; - - Bool_t CalibRefClocks() const {return (1 == fuCalibScalRefClk)? kTRUE: kFALSE; }; - - Int_t GetMinHitCalib() const { return fiMinNbHitsCalib; }; - Int_t GetMinHitCalibNewOnly() const { return fiFactMinNbHitsOnlyNewCalib*fiMinNbHitsCalib; }; - TString GetInitCalFilename() const {return fsInitialCalibrationFilename; }; - Int_t GetNbCalibBoards( UInt_t uType) const; - Int_t GetInitialCalInd( UInt_t uType, UInt_t uBoard ) const; - Bool_t EnaCalibOutput() const - { return (1 == fuEnableCalibOutput)? kTRUE: kFALSE; }; - Bool_t EnaSingleCalib() const - { return (1 == fuSingleChannelCalibFilesEnable)? kTRUE: kFALSE; }; - Bool_t EnaSingleCalibOutput() const - { return (0 < fuSingleChannelCalibFilesOutput)? kTRUE: kFALSE; }; - Int_t GetSingleCalOutMode() const { return fuSingleChannelCalibFilesOutput; }; - - Bool_t UseCoarse() const - { return (1 == fuUseCoarseCorrectedTime)? kTRUE: kFALSE; }; - - Int_t GetNbOffsetBoard( UInt_t uType) const; - Int_t GetOffsetBoardInd( UInt_t uType, UInt_t uSlot ) const; - Bool_t EnaTimeOffset() const - { return (1 == fuEnableTimeOffsetCalibration)? kTRUE: kFALSE; }; - Int_t GetTimeOffsetVal( UInt_t uType, UInt_t uSlot, UInt_t uChan ) const; - Bool_t EnaTotOffset() const - { return (1 == fuEnableTotCalibration)? kTRUE: kFALSE; }; - Int_t GetTotOffsetVal( UInt_t uType, UInt_t uSlot, UInt_t uChan ) const; - - Bool_t EnaManuTdcTdcOffset() const - { return (1 == fuManualTdcOffsetEnable)? kTRUE: kFALSE; }; - Int_t GetTdcTdcOffset( UInt_t uType, UInt_t uBoard ) const; - Bool_t EnaAutoTdcTdcOffset() const - { return (1 == fuAutomaticOffsetEnable)? kTRUE: kFALSE; }; - Int_t GetMainTdcTdcOffset( UInt_t uType ) const; - - Int_t GetTotMode( UInt_t uType ) const; - Bool_t CheckTotInvFlag( UInt_t uType, UInt_t uSlot ) const; - Int_t GetTotInvFlag( UInt_t uType, UInt_t uSlot, UInt_t uChan ) const; - - Bool_t IsTimeHistEna() const - { return (1 == fuTimeHistEnable)? kTRUE: kFALSE; }; - Bool_t IsSingleTimeHistEna() const - { return (1 == fuTimeHistSinglesEnable)? kTRUE: kFALSE; }; - Bool_t IsTotHistEna() const - { return (1 == fuTotHistoEnable)? kTRUE: kFALSE; }; - Bool_t IsMultiDistHistEna() const - { return (1 == fuMultiHitsDistanceHistoEnable)? kTRUE: kFALSE; }; - - Bool_t IsTdcOffsetEna() const - { return (1 == fuTdcOffsetEnable)? kTRUE: kFALSE; }; - Bool_t GetTdcOffEnaFlag( UInt_t uType, UInt_t uBoard ) const; - UInt_t GetTdcOffsetMainTdc() const - { return fuTdcOffsetMainTdc; }; - Bool_t IsTrbLinCalEna() const - { return (1 == fuTrbOffsetLinearEnable)? kTRUE: kFALSE; }; - Int_t GetChanResTest() const { return fiChannelResolutionTest;}; - - // Example taken from CbmTofDigiPar - void clear(void); - void putParams(FairParamList*); - Bool_t getParams(FairParamList*); - virtual void printParams(); - - private: - /** DEBUG */ - // Switch ON/OFF debug tests, output & histos in calibration - UInt_t fuCalibDebug; - - /** Scalers Calib params **/ - // If 1, the calibrator will try to update the reference clock frequency using the reference counts - // and the MBS LINUX clock saved in the TRIGLOG event. As this clock as only a bining of 1ms, the rate is - // calculated at time intervals of 50ms to 500ms - UInt_t fuCalibScalRefClk; - /** TDC Calib params **/ - // Minimal number of hits in the finetime histogram before we start applying corrections based on New data - // Corrections are updated on multiples of this value - Int_t fiMinNbHitsCalib; - // Number of time the minimal number of hits after which corrections use only new data - // 0 desactivate and when initial calibration is available use always its addition with new data - Int_t fiFactMinNbHitsOnlyNewCalib; - - // Calibration loading - // If not empty or -, use the bin to ns calibration histograms from this file as initial calibration - TString fsInitialCalibrationFilename; - // Nb of boards for which the calibration where measured - Int_t fiNbVftxCalib; - Int_t fiNbCaenCalib; - Int_t fiNbTrb3Calib; - Int_t fiNbGet4Calib; - // Tdc index of the initial calibration histograms for individual VFTX - // (should allow board slot change if calibration stable over time) - TArrayI fiInitialCalIndexVftx; - TArrayI fiInitialCalIndexCaen; - TArrayI fiInitialCalIndexTrb3; - TArrayI fiInitialCalIndexGet4; - // Save all bin to ns calibration histos to a root file with date/time as name - UInt_t fuEnableCalibOutput; - // Enable use a one calibration file per channel in ./Calib/ folder - // Name is built using tdc type + curr. board index + channel index - UInt_t fuSingleChannelCalibFilesEnable; - // 0 = Not output of single channel calib file, 1 = single channel calib file with new data, 2 = Old + new - UInt_t fuSingleChannelCalibFilesOutput; - - // Switch between calibrated time and calibrated time with correction for coarse counter cycle (relative to trigger) - UInt_t fuUseCoarseCorrectedTime; - - // Board/chip dependent offsets (constant over time!!!) - // Nb of board for which the offset where measured - Int_t fiNbVftxOffset; - Int_t fiNbCaenOffset; - Int_t fiNbTrb3Offset; - Int_t fiNbGet4Offset; - // Tdc hardware board #X in slot/data #Y - // (should allow board slot change) - TArrayI fiBoardIndexVftx; - TArrayI fiBoardIndexCaen; - TArrayI fiBoardIndexTrb3; - TArrayI fiBoardIndexGet4; - // Time offset calibration - // Enable/disable time offset calibration - UInt_t fuEnableTimeOffsetCalibration; - // Time offset per channel, depends on TDC board, not TDC slot!!!!! - TArrayD fdTimeOffsetVftx; - TArrayD fdTimeOffsetCaen; - TArrayD fdTimeOffsetTrb3; - TArrayD fdTimeOffsetGet4; - // Time offset per channel, independent of TDC board, this is a mean value for each TDC type!!!!! - TArrayD fdMeanTimeOffsetVftx; - TArrayD fdMeanTimeOffsetCaen; - TArrayD fdMeanTimeOffsetTrb3; - TArrayD fdMeanTimeOffsetGet4; - - // ToT offset calibration - // Enable/disable tot offset calibration - UInt_t fuEnableTotCalibration; - // ToT offset per channel, depends on TDC board, not TDC slot!!!!! - TArrayD fdTotOffsetVftx; - TArrayD fdTotOffsetCaen; - TArrayD fdTotOffsetTrb3; - TArrayD fdTotOffsetGet4; - // ToT offset per channel, independent of TDC board, this is a mean value for each TDC type!!!!! - TArrayD fdMeanTotOffsetVftx; - TArrayD fdMeanTotOffsetCaen; - TArrayD fdMeanTotOffsetTrb3; - TArrayD fdMeanTotOffsetGet4; - - // TDC to TDC offsets, e.g. due to diff. clock cycle locking on reset - // Enable a manual X clock TDC offset use - UInt_t fuManualTdcOffsetEnable; - // Offset to main TDC, in clock period - TArrayI fiTdcToTdcOffsetVftx; - TArrayI fiTdcToTdcOffsetCaen; - TArrayI fiTdcToTdcOffsetTrb3; - TArrayI fiTdcToTdcOffsetGet4; - // Enable an automatic X clock TDC offset detection - UInt_t fuAutomaticOffsetEnable; - // TDC to be used for the automatic offset detection - Int_t fiMainReferenceTdcVftx; - Int_t fiMainReferenceTdcCaen; - Int_t fiMainReferenceTdcTrb3; - Int_t fiMainReferenceTdcGet4; - - /** Tot calculation **/ - // Tot calculation mode - // 0 = None - // 1 = Same TDC channel, diff data - // 2 = 2 TDC channels per input channel or 2 input channels per front end channel (even = Falling, odd = Rising) - // 3 = Same input channels in 2 consecutive boards (even = Rising, odd = Falling) - // 4 = Same TDC channel, same data - Int_t fiTotModeVftx; - Int_t fiTotModeCaen; - Int_t fiTotModeTrb3; - Int_t fiTotModeGet4; - // Nb of board for which inversion flags are provided - Int_t fiNbVftxTotInvFlag; - Int_t fiNbCaenTotInvFlag; - Int_t fiNbTrb3TotInvFlag; - Int_t fiNbGet4TotInvFlag; - // Tot inversion flags ( default is signal not inverted) - TArrayI fiTotInversionFlagVftx; - TArrayI fiTotInversionFlagCaen; - TArrayI fiTotInversionFlagTrb3; - TArrayI fiTotInversionFlagGet4; - - /** Histos control **/ - // Trigger time - calibrated time Histograms for every TDC channel - UInt_t fuTimeHistEnable; - // Trigger time - calibrated time Histograms for every TDC channel with only 1 hit in event - UInt_t fuTimeHistSinglesEnable; - // Tot Histograms for every input channel if possible/available (depends on TDC type) - UInt_t fuTotHistoEnable; - // Time distance between consecutive multiple hits on same channel - UInt_t fuMultiHitsDistanceHistoEnable; - - /** TDC offsets **/ - // Enable the use of TDC to TDC offsets for each event using reference channel - UInt_t fuTdcOffsetEnable; - // If the use of TDC to TDC offsets from ref ch is not enabled globally, enable it on a TDC basis - TArrayI fiTdcOffsetEnaFlagVftx; - TArrayI fiTdcOffsetEnaFlagCaen; - TArrayI fiTdcOffsetEnaFlagTrb3; - TArrayI fiTdcOffsetEnaFlagGet4; - // Index of the TDC to be used as main reference for the TDC to TDC offset using reference channel - UInt_t fuTdcOffsetMainTdc; - // Enable the use of linear calibration for the TRB3-TDC reference channel time calculation - UInt_t fuTrbOffsetLinearEnable; - // DEBUG: Channel to be used in all TDCs to build a TDC to TDC resolution check, -1 is disable!!!! - Int_t fiChannelResolutionTest; - - TMbsCalibTofPar(const TMbsCalibTofPar&); - TMbsCalibTofPar& operator=(const TMbsCalibTofPar&); - void FillBoardsNbPerType(); - - ClassDef(TMbsCalibTofPar, 2) -}; - -#endif //TMBSCALIBTOFPAR_H - diff --git a/beamtime/tof/calib/scaler/TMbsCalibScalTof.cxx b/beamtime/tof/calib/scaler/TMbsCalibScalTof.cxx deleted file mode 100644 index 3eea7f799f27ab8186eda02fd5eea7c912397ec9..0000000000000000000000000000000000000000 --- a/beamtime/tof/calib/scaler/TMbsCalibScalTof.cxx +++ /dev/null @@ -1,1008 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TMbsCalibScalTof ----- -// ----- Created 08/07/2013 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ -#include "TMbsCalibScalTof.h" - -// General Unpack headers -#include "TMbsUnpackTofPar.h" - -// ToF specific headers -#include "TMbsCalibTofPar.h" -#include "TofDef.h" -#include "TofScalerDef.h" -#include "TofScomDef.h" -#include "TofScal2014Def.h" -#include "TofTriglogDef.h" -#include "TofOrGenDef.h" -#include "TTofScalerBoard.h" -#include "TTofTriglogBoard.h" -#include "TTofCalibScaler.h" - -// FAIR headers -#include "FairLogger.h" -#include "FairRunAna.h" -#include "FairRuntimeDb.h" -#include "FairRootManager.h" - -// ROOT headers -#include "TClonesArray.h" -#include "TH2.h" -#include "TH1.h" -#include "TProfile.h" -#include "TROOT.h" -#include "TTimeStamp.h" - -TMbsCalibScalTof::TMbsCalibScalTof() : - fMbsUnpackPar(NULL), - fMbsCalibPar(NULL), - fhRefClkRate(), - fhRefClkRateEvo(), - fhRefMbsTimeComp(), - fhScalersRate(), - fhScalersRateEvo(), - fdEvoRangeUser(-1), - fdEvoBinSzUser(-1), - fScalerBoardCollection(NULL), - fTriglogBoardCollection(NULL), - fbSaveCalibScalers(kFALSE), - fCalibScalCollection(NULL), - bFirstEvent(kTRUE), - bFirstEvent2014(kTRUE), - fvuFirstRefClk(), - fvuRefClkCycle(), - fvuLastRefClk(), - fvuLastScalers(), - fdFirstMbsTime(0.0), - fdPrevMbsTime(0.0), - fvdPrevMbsTimeBd(), - fvuLastRefClkCal(), - fvdMeanRefClkFreq() -{ - // Get Base Container - FairRunAna* ana = FairRunAna::Instance(); - FairRuntimeDb* rtdb=ana->GetRuntimeDb(); - - // Unpack parameter - fMbsUnpackPar = (TMbsUnpackTofPar*) (rtdb->getContainer("TMbsUnpackTofPar")); - if( 0 == fMbsUnpackPar ) - LOG(error)<<"TMbsCalibScalTof::TMbsCalibScalTof => Could not obtain the TMbsUnpackTofPar "; - - // Calibration parameter - fMbsCalibPar = (TMbsCalibTofPar*) (rtdb->getContainer("TMbsCalibTofPar")); - if( 0 == fMbsCalibPar ) - LOG(error)<<"TMbsCalibScalTof::TMbsCalibScalTof => Could not obtain the TMbsCalibTofPar "; - else fMbsCalibPar->printParams(); -} - -TMbsCalibScalTof::TMbsCalibScalTof(TMbsUnpackTofPar * parIn, TMbsCalibTofPar *parCalIn) : - fMbsUnpackPar(parIn), - fMbsCalibPar(parCalIn), - fhRefClkRate(), - fhRefClkRateEvo(), - fhRefMbsTimeComp(), - fhScalersRate(), - fhScalersRateEvo(), - fdEvoRangeUser(-1), - fdEvoBinSzUser(-1), - fScalerBoardCollection(NULL), - fTriglogBoardCollection(NULL), - fbSaveCalibScalers(kFALSE), - fCalibScalCollection(NULL), - bFirstEvent(kTRUE), - bFirstEvent2014(kTRUE), - fvuFirstRefClk(), - fvuRefClkCycle(), - fvuLastRefClk(), - fvuLastScalers(), - fdFirstMbsTime(0.0), - fdPrevMbsTime(0.0), - fvdPrevMbsTimeBd(), - fvuLastRefClkCal(), - fvdMeanRefClkFreq() -{ -} - -TMbsCalibScalTof::~TMbsCalibScalTof() -{ - DeleteHistograms(); - LOG(info)<<"**** TMbsCalibScalTof: Delete instance "; -} - -void TMbsCalibScalTof::Clear(Option_t * /*option*/) -{ - fMbsUnpackPar = NULL; - fMbsCalibPar = NULL; - fScalerBoardCollection = NULL; - fTriglogBoardCollection = NULL; - fbSaveCalibScalers = kFALSE; - fCalibScalCollection = NULL; -} - -// Calibration Functions -Bool_t TMbsCalibScalTof::InitScalersCalib() -{ -/* - if( kFALSE == RegisterInput() ) - return kFALSE; - - if( kFALSE == RegisterOutput() ) - return kFALSE; - - if( kFALSE == CreateHistogramms() ) - return kFALSE; -*/ - if( kFALSE == InitCalibration() ) - return kFALSE; - - return kTRUE; -} -Bool_t TMbsCalibScalTof::ClearCalib() -{ - ClearOutput(); - return kTRUE; -} -Bool_t TMbsCalibScalTof::CalibScalers() -{ - UInt_t uNbScalBd = fMbsUnpackPar->GetNbActiveScalersB(); - // Loop over all scaler boards - for( UInt_t uScalBdIndx = 0; uScalBdIndx < uNbScalBd; uScalBdIndx++ ) - Calibration( uScalBdIndx ); - - // Update the MBS time info used by all boards from the single TRIGLOG unpack event - if( 1 == fMbsUnpackPar->GetNbActiveBoards( tofMbs::triglog ) ) - { - if( NULL == fTriglogBoardCollection ) - return kFALSE; - - TTofTriglogBoard * xTriglogBoard = (TTofTriglogBoard*) fTriglogBoardCollection->At(0); // Always only 1 TRIGLOG board! - - if( NULL == xTriglogBoard ) - return kFALSE; - - Double_t dMbsTime = xTriglogBoard->GetMbsTimeSec() + xTriglogBoard->GetMbsTimeMilliSec()*1e-3; - if( ( 0 == fdPrevMbsTime ) || ( fdPrevMbsTime + 0.05 < dMbsTime ) ) - fdPrevMbsTime = dMbsTime; - - if( kTRUE == bFirstEvent ) - fdFirstMbsTime = dMbsTime; - } // if( 1 == fMbsUnpackPar->GetNbActiveBoards( tofMbs::triglog ) ) - - if( kTRUE == bFirstEvent ) - bFirstEvent = kFALSE; - - return kTRUE; -} -Bool_t TMbsCalibScalTof::CloseScalersCalib() -{ - if( kFALSE == CloseCalibration() ) - return kFALSE; - -// if( kFALSE == DeleteHistograms() ) -// return kFALSE; - - return kTRUE; -} -Bool_t TMbsCalibScalTof::InitParameters() -{ - return kTRUE; -} -// ------------------------------------------------------------------ -Bool_t TMbsCalibScalTof::RegisterInput() -{ - FairRootManager* rootMgr = FairRootManager::Instance(); - - // There should always be only 1 Trigger board active, if not => problem - if( 1 == fMbsUnpackPar->GetNbActiveBoards( tofMbs::triglog ) ) - { - fTriglogBoardCollection = (TClonesArray*) rootMgr->GetObject("TofTriglog"); - if( NULL == fTriglogBoardCollection) - { - LOG(error)<<"TMbsCalibScalTof::RegisterInput => Could not get the TofTriglog TClonesArray!!!"; - return kFALSE; - } // if( NULL == fTriglogBoardCollection) - } // if( 1 == fParUnpack->GetNbActiveBoards( tofMbs::triglog ) ) - - // Each scaler board has its scaler unpack object, same type for TRIGLOG, ScalOrMu, etc... - if( 0 < fMbsUnpackPar->GetNbActiveScalersB() ) - { - fScalerBoardCollection = (TClonesArray*) rootMgr->GetObject("TofRawScalers"); - if( NULL == fScalerBoardCollection) - { - LOG(error)<<"TMbsCalibScalTof::RegisterInput => Could not get the TofRawScalers TClonesArray!!!"; - return kFALSE; - } // if( NULL == fScalerBoardCollection) - } // if( 0 < fMbsUnpackPar->GetNbActiveScalersB() ) - - return kTRUE; -} -Bool_t TMbsCalibScalTof::RegisterOutput() -{ - FairRootManager* rootMgr = FairRootManager::Instance(); - fCalibScalCollection = new TClonesArray("TTofCalibScaler"); - - rootMgr->Register( "TofCalibScaler","Tof",fCalibScalCollection, - fMbsUnpackPar->WriteDataInCbmOut() || fbSaveCalibScalers); - - return kTRUE; -} -Bool_t TMbsCalibScalTof::ClearOutput() -{ - fCalibScalCollection->Clear("C"); - return kTRUE; -} -void TMbsCalibScalTof::SetSaveScalers( Bool_t bSaveScal ) -{ - fbSaveCalibScalers = bSaveScal; - if( kTRUE == bSaveScal ) { - LOG(info)<<"TMbsCalibScalTof => Enable the saving of calibrated scaler data in analysis output file"; - } else { - LOG(info)<<"TMbsCalibScalTof => Disable the saving of calibrated scaler data in analysis output file"; - } -} -// ------------------------------------------------------------------ -Bool_t TMbsCalibScalTof::CreateHistogramms() -{ - UInt_t uNbScalBd = fMbsUnpackPar->GetNbActiveScalersB(); - // Resize vectors with a "board" dimension - if( 0 < uNbScalBd ) - { - fhScalersRate.resize( uNbScalBd ); - fhScalersRateEvo.resize( uNbScalBd ); -// fhRefClkRateEstA.resize( uNbScalBd ); -// fhRefClkRateEstB.resize( uNbScalBd ); - if( 1 == fMbsUnpackPar->GetNbActiveBoards( tofMbs::triglog ) ) - { - fhRefClkRateEvo.resize( uNbScalBd ); - fhRefMbsTimeComp.resize( uNbScalBd ); - fhRefClkRate.resize( uNbScalBd ); - } // if( 1 == fMbsUnpackPar->GetNbActiveBoards( tofMbs::triglog ) ) - } // if( 0 < fMbsUnpackPar->GetNbActiveScalersB() ) - - // Loop over all scalers - for( UInt_t uScalBdIndx = 0; uScalBdIndx < uNbScalBd; uScalBdIndx++ ) - { - TTofScalerBoard * xScalerBoard = (TTofScalerBoard*) fScalerBoardCollection->At(uScalBdIndx); - UInt_t uType = xScalerBoard->GetScalerType(); - Double_t dRefClkFreq; - UInt_t uNbScalers; - UInt_t uNbChan; - Double_t dEvoRange; - Double_t dEvoBinNb; - switch( uType ) - { - case tofscaler::triglog : - case tofscaler::triglogscal : - dRefClkFreq = triglog::kdRefClkFreq; - uNbScalers = triglog::kuNbScalers; - uNbChan = triglog::kuNbChan; - dEvoRange = triglog::kdEvoRange; - dEvoBinNb = triglog::kdEvoRange / triglog::kdEvoBin; - break; - case tofscaler::scalormu : - dRefClkFreq = scalormu::kdRefClkFreq; - uNbScalers = scalormu::kuNbScalers; - uNbChan = scalormu::kuNbChan; - dEvoRange = scalormu::kdEvoRange; - dEvoBinNb = scalormu::kdEvoRange / scalormu::kdEvoBin; - break; - case tofscaler::scalormubig : - dRefClkFreq = scalormuBig::kdRefClkFreq; - uNbScalers = scalormuBig::kuNbScalers; - uNbChan = scalormuBig::kuNbChan; - dEvoRange = scalormuBig::kdEvoRange; - dEvoBinNb = scalormuBig::kdEvoRange / scalormuBig::kdEvoBin; - break; - case tofscaler::scaler2014 : - dRefClkFreq = scaler2014::kdRefClkFreq; - uNbScalers = scaler2014::kuNbScalers; - uNbChan = scaler2014::kuNbChan; - dEvoRange = scaler2014::kdEvoRange; - dEvoBinNb = scaler2014::kdEvoRange / scaler2014::kdEvoBin; - break; - case tofscaler::orgen : - dRefClkFreq = orgen::kdRefClkFreq; - uNbScalers = orgen::kuNbScalers; - uNbChan = orgen::kuNbChan; - dEvoRange = orgen::kdEvoRange; - dEvoBinNb = orgen::kdEvoRange / orgen::kdEvoBin; - break; - case tofscaler::undef : - default: - dRefClkFreq = -1.0; - uNbScalers = 0; - uNbChan = 0; - dEvoRange = 0; - dEvoBinNb = 0; - // Here we go to next board for all undefined/invalid types - continue; - break; - } // switch( xScalerBoard->GetScalerType() ) - - if( 0 < fdEvoRangeUser && 0 < fdEvoBinSzUser && fdEvoBinSzUser < fdEvoRangeUser ) - { - dEvoRange = fdEvoRangeUser; - dEvoBinNb = static_cast<Int_t>(fdEvoRangeUser) / static_cast<Int_t>(fdEvoBinSzUser); - } // if( 0 < fdEvoRangeUser && 0 < fdEvoBinSzUser && fdEvoBinSzUser < fdEvoRangeUser ) - - // Resize vectors with a "Scalers" dimension - fhScalersRate[uScalBdIndx].resize( uNbScalers ); - fhScalersRateEvo[uScalBdIndx].resize( uNbScalers ); - for( UInt_t uScaler = 0; uScaler < uNbScalers; uScaler++) - { - // resize vectors with a "channel" dimension - fhScalersRate[uScalBdIndx][uScaler].resize(uNbChan); - fhScalersRateEvo[uScalBdIndx][uScaler].resize(uNbChan); - for( UInt_t uCh = 0; uCh < uNbChan; uCh++) - { - fhScalersRate[uScalBdIndx][uScaler][uCh] = - new TH1I( Form("tof_cal_%s_%02d_scal_%02d_%02d", - tofscaler::ksTdcHistName[ uType ].Data(), uScalBdIndx, uScaler, uCh ), - Form("Rate of the channel %02d in scaler %02d; Freq. [Hz]", uCh, uScaler), - (Int_t)(dRefClkFreq/2000), 0.0 , dRefClkFreq/2 ); -// fhScalersRateEvo[uScalBdIndx][uScaler][uCh] = -// new TH1I( Form("tof_cal_%s_scal_evo_%02d_%02d", tofscaler::ksTdcHistName[ uType ].Data(), uScaler, uCh ), -// Form("Channel %02d in scaler %02d counts per second; Time [s]; Counts []", uCh, uScaler), -// 3600, 0.0, dEvoRange ); - fhScalersRateEvo[uScalBdIndx][uScaler][uCh] = - new TProfile( Form("tof_cal_%s_%02d_scal_evo_%02d_%02d", - tofscaler::ksTdcHistName[ uType ].Data(), uScalBdIndx, uScaler, uCh ), - Form("Channel %02d in scaler %02d Mean rate per second; Time [s]; Rate [1/s]", uCh, uScaler), - static_cast<Int_t>(dEvoBinNb), 0.0, dEvoRange ); - } // for( UInt_t uCh = 0; uCh < triglog::kuNbChan; uCh++) - } // for( UInt_t uScaler = 0; uScaler <triglog::kuNbScalers; uScaler++) - - // There should always be only 1 Trigger board active, if not => problem - if( 1 == fMbsUnpackPar->GetNbActiveBoards( tofMbs::triglog ) ) - { - fhRefClkRate[uScalBdIndx] = new TH1I( Form("tof_cal_%s_%02d_refclk", - tofscaler::ksTdcHistName[ uType ].Data(), uScalBdIndx ), - "Rate of the reference clock; Freq. [Hz]", - (Int_t)(2*dRefClkFreq/1000), 0.0 , 2*dRefClkFreq ); -// fhRefClkRateEvo[uScalBdIndx] = new TH1I( Form("tof_cal_%s_%02d_refclk_evo", -// tofscaler::ksTdcHistName[ uType ].Data(), uScalBdIndx ), -// "Reference clock counts per second; Time [s]; Counts []", dEvoBinNb, 0.0, dEvoRange ); - fhRefClkRateEvo[uScalBdIndx] = new TProfile( Form("tof_cal_%s_%02d_refclk_evo", - tofscaler::ksTdcHistName[ uType ].Data(), uScalBdIndx ), - "Reference clock counts per second; Time [s]; Counts []", - (Int_t)dEvoRange, 0.0, (Int_t)dEvoRange ); - -// fhRefClkRateEstA[uScalBdIndx] = new TH2I( Form("tof_cal_%s_%02d_refclk_estA", -// tofscaler::ksTdcHistName[ uType ].Data(), uScalBdIndx ), -// "Reference clock counts per second; Time [s]; Counts []", -// (Int_t)dEvoRange, 0.0, (Int_t)dEvoRange, -// 500, 750*1e3, 850*1e3 ); -// fhRefClkRateEstB[uScalBdIndx] = new TH2I( Form("tof_cal_%s_%02d_refclk_estB", -// tofscaler::ksTdcHistName[ uType ].Data(), uScalBdIndx ), -// "Reference clock counts per second; Time [s]; Counts []", -// (Int_t)dEvoRange, 0.0, (Int_t)dEvoRange, -// 500, 750*1e3, 850*1e3 ); - - fhRefMbsTimeComp[uScalBdIndx] = new TH2I( Form("tof_cal_%s_%02d_refmbs_comp", - tofscaler::ksTdcHistName[ uType ].Data(), uScalBdIndx ), - "Comparison of clk VS Mbs time since first event; Mbs Time [s]; Mbs Time - Ref Clk Time [s]", - dEvoBinNb/10, 0.0, dEvoRange, 200, -0.1, 0.1 ); - } // if( 1 == fMbsUnpackPar->GetNbActiveBoards( tofMbs::triglog ) ) - } // for( UInt_t uScalBdIndx = 0; uScalBdIndx < uNbScalBd; uScalBdIndx++ ) - - return kTRUE; -} -Bool_t TMbsCalibScalTof::FillHistograms() -{ - UInt_t uNbScalBd = fMbsUnpackPar->GetNbActiveScalersB(); - - TTofTriglogBoard * xTriglogBoard; - Double_t dMbsTime = 0; - if( 1 == fMbsUnpackPar->GetNbActiveBoards( tofMbs::triglog ) ) - { - if( NULL == fTriglogBoardCollection ) - return kFALSE; - - xTriglogBoard = (TTofTriglogBoard*) fTriglogBoardCollection->At(0); // Always only 1 TRIGLOG board! - - if( NULL == xTriglogBoard ) - return kFALSE; - - // In GSI April 2014 beamtime some event are used to empty TRB buffers - // and therefore do not contain the MBS event - if( kFALSE == xTriglogBoard->IsUpdated() ) - { - LOG(error)<<"TMbsCalibScalTof::FillHistograms => No TRIGLOG sub-event in this event," - <<" OK for GSI April 2014 beamtime"; - return kFALSE; - } // if( kFALSE == fTriglogBoard->IsUpdated() && kFALSE == fScalerBoard->IsUpdated() ) - - dMbsTime = xTriglogBoard->GetMbsTimeSec() + xTriglogBoard->GetMbsTimeMilliSec()*1e-3; - } // if( 1 == fMbsUnpackPar->GetNbActiveBoards( tofMbs::triglog ) ) - - // Loop over all scalers - for( UInt_t uScalBdIndx = 0; uScalBdIndx < uNbScalBd; uScalBdIndx++ ) - { - TTofCalibScaler * xCalibScaler = (TTofCalibScaler*) fCalibScalCollection->ConstructedAt(uScalBdIndx); - UInt_t uType = xCalibScaler->GetScalerType(); -// Double_t dRefClkFreq; // -> Comment to remove warning because set but never used - UInt_t uNbScalers; - UInt_t uNbChan; - switch( uType ) - { - case tofscaler::triglog : - case tofscaler::triglogscal : -// dRefClkFreq = triglog::kdRefClkFreq; // -> Comment to remove warning because set but never used - uNbScalers = triglog::kuNbScalers; - uNbChan = triglog::kuNbChan; - break; - case tofscaler::scalormu : -// dRefClkFreq = scalormu::kdRefClkFreq; // -> Comment to remove warning because set but never used - uNbScalers = scalormu::kuNbScalers; - uNbChan = scalormu::kuNbChan; - break; - case tofscaler::scalormubig : -// dRefClkFreq = scalormuBig::kdRefClkFreq; // -> Comment to remove warning because set but never used - uNbScalers = scalormuBig::kuNbScalers; - uNbChan = scalormuBig::kuNbChan; - break; - case tofscaler::scaler2014 : -// dRefClkFreq = scaler2014::kdRefClkFreq; // -> Comment to remove warning because set but never used - uNbScalers = scaler2014::kuNbScalers; - uNbChan = scaler2014::kuNbChan; - break; - case tofscaler::orgen : -// dRefClkFreq = orgen::kdRefClkFreq; // -> Comment to remove warning because set but never used - uNbScalers = orgen::kuNbScalers; - uNbChan = orgen::kuNbChan; - break; - case tofscaler::undef : - default: -// dRefClkFreq = -1.0; // -> Comment to remove warning because set but never used - uNbScalers = 0; - uNbChan = 0; - // Here we go to next board for all undefined/invalid types - continue; - break; - } // switch( xScalerBoard->GetScalerType() ) - - if( ( kFALSE == xCalibScaler->IsUpdated() || kTRUE == bFirstEvent2014 ) - && uType == tofscaler::scaler2014 ) - // This event did not contain 2014 scalers data - continue; - - // Comparison between the time since first event stored by MBS in the TRIGLOG event and the one - // obtained using the reference clock counts and frequency - if( 1 == fMbsUnpackPar->GetNbActiveBoards( tofMbs::triglog ) && kFALSE == bFirstEvent - && kTRUE == xCalibScaler->IsUpdated() ) - { - Double_t dMbsTimeSinceFirst = dMbsTime - fdFirstMbsTime; - fhRefMbsTimeComp[uScalBdIndx]->Fill( dMbsTimeSinceFirst, dMbsTimeSinceFirst - xCalibScaler->GetTimeToFirst() ); - - // Instantaneous rate of individual channels - for( UInt_t uScaler = 0; uScaler < uNbScalers; uScaler++) - { - for( UInt_t uCh = 0; uCh < uNbChan; uCh++) - { - if( 0 < xCalibScaler->GetTimeToLast() ) - { - fhScalersRate[uScalBdIndx][uScaler][uCh]->Fill( xCalibScaler->GetScalerValue( uCh, uScaler) ); - fhScalersRateEvo[uScalBdIndx][uScaler][uCh]->Fill( dMbsTimeSinceFirst, - xCalibScaler->GetScalerValue( uCh, uScaler) ); - } // if( 0 < xCalibScaler->GetTimeToLast() ) - } // for( UInt_t uCh = 0; uCh < uNbChan; uCh++) - } // for( UInt_t uScaler = 0; uScaler < uNbScalers; uScaler++) - } // if( 1 == fMbsUnpackPar->GetNbActiveBoards( tofMbs::triglog ) && kFALSE == bFirstEvent ) - else - { - // Instantaneous rate of individual channels - for( UInt_t uScaler = 0; uScaler < uNbScalers; uScaler++) - { - for( UInt_t uCh = 0; uCh < uNbChan; uCh++) - { - if( 0 < xCalibScaler->GetTimeToLast() ) - { - fhScalersRate[uScalBdIndx][uScaler][uCh]->Fill( xCalibScaler->GetScalerValue( uCh, uScaler) ); - fhScalersRateEvo[uScalBdIndx][uScaler][uCh]->Fill( xCalibScaler->GetTimeToFirst(), - xCalibScaler->GetScalerValue( uCh, uScaler) ); - } // if( 0 < xCalibScaler->GetTimeToLast() ) - } // for( UInt_t uCh = 0; uCh < uNbChan; uCh++) - } // for( UInt_t uScaler = 0; uScaler < uNbScalers; uScaler++) - } // else of if( 1 == fMbsUnpackPar->GetNbActiveBoards( tofMbs::triglog ) && kFALSE == bFirstEvent ) - } // for( UInt_t uScalBdIndx = 0; uScalBdIndx < uNbScalBd; uScalBdIndx++ ) - -// if( 1 == fMbsUnpackPar->GetNbActiveBoards( tofMbs::triglog ) ) - - if( kTRUE == bFirstEvent2014 ) - // Loop over all scalers to find 2014 ones - for( UInt_t uScalBdIndx = 0; uScalBdIndx < uNbScalBd; uScalBdIndx++ ) - { - TTofCalibScaler * xCalibScaler = (TTofCalibScaler*) fCalibScalCollection->ConstructedAt(uScalBdIndx); - UInt_t uType = xCalibScaler->GetScalerType(); - if( uType == tofscaler::scaler2014 && - kTRUE == xCalibScaler->IsUpdated() ) - { - // This event was the first to contain 2014 scalers data - bFirstEvent2014 = kFALSE; - break; - } - } // for( UInt_t uScalBdIndx = 0; uScalBdIndx < uNbScalBd; uScalBdIndx++ ) - - return kTRUE; -} -Bool_t TMbsCalibScalTof::WriteHistogramms( TDirectory* inDir) -{ - TDirectory * oldir = gDirectory; - - LOG(info)<<"TMbsCalibScalTof::WriteHistogramms => Start writing histos!!!"; - - UInt_t uNbScalBd = fMbsUnpackPar->GetNbActiveScalersB(); - // Loop over all scalers - for( UInt_t uScalBdIndx = 0; uScalBdIndx < uNbScalBd; uScalBdIndx++ ) - { - TTofCalibScaler * xCalibScaler = (TTofCalibScaler*) fCalibScalCollection->ConstructedAt(uScalBdIndx); - UInt_t uType = xCalibScaler->GetScalerType(); - UInt_t uNbScalers; - UInt_t uNbChan; - switch( uType ) - { - case tofscaler::triglog : - case tofscaler::triglogscal : - uNbScalers = triglog::kuNbScalers; - uNbChan = triglog::kuNbChan; - break; - case tofscaler::scalormu : - uNbScalers = scalormu::kuNbScalers; - uNbChan = scalormu::kuNbChan; - break; - case tofscaler::scalormubig : - uNbScalers = scalormuBig::kuNbScalers; - uNbChan = scalormuBig::kuNbChan; - break; - case tofscaler::scaler2014 : - uNbScalers = scaler2014::kuNbScalers; - uNbChan = scaler2014::kuNbChan; - break; - case tofscaler::orgen : - uNbScalers = orgen::kuNbScalers; - uNbChan = orgen::kuNbChan; - break; - case tofscaler::undef : - default: - // Here we go to next board for all undefined/invalid types - continue; - break; - } // switch( xScalerBoard->GetScalerType() ) - - // create a subdirectory "Cal_type" in this file - TDirectory *cdCal = inDir->mkdir( Form( "Cal_%s_%02d", tofscaler::ksTdcHistName[ uType ].Data(), uScalBdIndx ) ); - cdCal->cd(); // make the "Cal_type" directory the current directory - TDirectory *cdCalScal[ uNbScalers ]; - - if( 1 == fMbsUnpackPar->GetNbActiveBoards( tofMbs::triglog ) ) - { - fhRefClkRate[uScalBdIndx]->Write(); - fhRefClkRateEvo[uScalBdIndx]->Write(); -// fhRefClkRateEstA[uScalBdIndx]->Write(); -// fhRefClkRateEstB[uScalBdIndx]->Write(); - fhRefMbsTimeComp[uScalBdIndx]->Write(); - } - - for( UInt_t uScaler = 0; uScaler < uNbScalers; uScaler++) - { - // Create a sub folder for each scaler - cdCalScal[uScaler] = cdCal->mkdir( Form( "cScal%03d", uScaler) ); - cdCalScal[uScaler]->cd(); - - for( UInt_t uCh = 0; uCh < uNbChan; uCh++) - { - fhScalersRate[uScalBdIndx][uScaler][uCh]->Write(); - fhScalersRateEvo[uScalBdIndx][uScaler][uCh]->Write(); - } - } // for( UInt_t uScaler = 0; uScaler < uNbScalers; uScaler++) - } // for( UInt_t uScalBdIndx = 0; uScalBdIndx < uNbScalBd; uScalBdIndx++ ) - - gDirectory->cd( oldir->GetPath() ); - return kTRUE; -} -Bool_t TMbsCalibScalTof::DeleteHistograms() -{ - UInt_t uNbScalBd = fMbsUnpackPar->GetNbActiveScalersB(); - // Loop over all scalers - for( UInt_t uScalBdIndx = 0; uScalBdIndx < uNbScalBd; uScalBdIndx++ ) - { - TTofScalerBoard * xScalerBoard = (TTofScalerBoard*) fScalerBoardCollection->At(uScalBdIndx); - UInt_t uType = xScalerBoard->GetScalerType(); - - UInt_t uNbScalers; - switch( uType ) - { - case tofscaler::triglog : - case tofscaler::triglogscal : - uNbScalers = triglog::kuNbScalers; - break; - case tofscaler::scalormu : - uNbScalers = scalormu::kuNbScalers; - break; - case tofscaler::scalormubig : - uNbScalers = scalormuBig::kuNbScalers; - break; - case tofscaler::scaler2014 : - uNbScalers = scaler2014::kuNbScalers; - break; - case tofscaler::orgen : - uNbScalers = orgen::kuNbScalers; - break; - case tofscaler::undef : - default: - // Here we go to next board for all undefined/invalid types - continue; - break; - } // switch( xScalerBoard->GetScalerType() ) - - for( UInt_t uScaler = 0; uScaler < uNbScalers; uScaler++) - { - fhScalersRate[uScalBdIndx][uScaler].clear(); - fhScalersRateEvo[uScalBdIndx][uScaler].clear(); - } // for( UInt_t uScaler = 0; uScaler < uNbScalers; uScaler++) - fhScalersRate[uScalBdIndx].clear(); - fhScalersRateEvo[uScalBdIndx].clear(); - } // for( UInt_t uScalBdIndx = 0; uScalBdIndx < uNbScalBd; uScalBdIndx++ ) - - if( 0 < uNbScalBd ) - { - fhScalersRate.clear(); - fhScalersRateEvo.clear(); - if( 1 == fMbsUnpackPar->GetNbActiveBoards( tofMbs::triglog ) ) - { - fhRefClkRateEvo.clear(); - fhRefMbsTimeComp.clear(); - fhRefClkRate.clear(); - } // if( 1 == fMbsUnpackPar->GetNbActiveBoards( tofMbs::triglog ) ) - } // if( 0 < fMbsUnpackPar->GetNbActiveScalersB() ) - - return kTRUE; -} -// ------------------------------------------------------------------ -Bool_t TMbsCalibScalTof::InitCalibration() -{ - UInt_t uNbScalBd = fMbsUnpackPar->GetNbActiveScalersB(); - if( 0 < uNbScalBd ) - { - fvuLastScalers.resize( uNbScalBd ); - fvuFirstRefClk.resize( uNbScalBd ); - fvuRefClkCycle.resize( uNbScalBd ); - fvuLastRefClk.resize( uNbScalBd ); - fvdPrevMbsTimeBd.resize( uNbScalBd ); - fvuLastRefClkCal.resize( uNbScalBd ); - fvdMeanRefClkFreq.resize( uNbScalBd ); - } - - // Loop over all scalers - for( UInt_t uScalBdIndx = 0; uScalBdIndx < uNbScalBd; uScalBdIndx++ ) - { - TTofScalerBoard * xScalerBoard = (TTofScalerBoard*) fScalerBoardCollection->At(uScalBdIndx); - TTofCalibScaler * xCalibScaler = (TTofCalibScaler*) fCalibScalCollection->ConstructedAt(uScalBdIndx); - UInt_t uType = xScalerBoard->GetScalerType(); - - if( tofscaler::undef == xCalibScaler->GetScalerType() ) - xCalibScaler->SetType( uType ); - -// Double_t dRefClkFreq; // -> Comment to remove warning because set but never used - UInt_t uNbScalers; - UInt_t uNbChan; - switch( uType ) - { - case tofscaler::triglog : - case tofscaler::triglogscal : -// dRefClkFreq = triglog::kdRefClkFreq; // -> Comment to remove warning because set but never used - uNbScalers = triglog::kuNbScalers; - uNbChan = triglog::kuNbChan; - break; - case tofscaler::scalormu : -// dRefClkFreq = scalormu::kdRefClkFreq; // -> Comment to remove warning because set but never used - uNbScalers = scalormu::kuNbScalers; - uNbChan = scalormu::kuNbChan; - break; - case tofscaler::scalormubig : -// dRefClkFreq = scalormuBig::kdRefClkFreq; // -> Comment to remove warning because set but never used - uNbScalers = scalormuBig::kuNbScalers; - uNbChan = scalormuBig::kuNbChan; - break; - case tofscaler::scaler2014 : -// dRefClkFreq = scaler2014::kdRefClkFreq; // -> Comment to remove warning because set but never used - uNbScalers = scaler2014::kuNbScalers; - uNbChan = scaler2014::kuNbChan; - break; - case tofscaler::orgen : -// dRefClkFreq = orgen::kdRefClkFreq; // -> Comment to remove warning because set but never used - uNbScalers = orgen::kuNbScalers; - uNbChan = orgen::kuNbChan; - break; - case tofscaler::undef : - default: -// dRefClkFreq = -1.0; // -> Comment to remove warning because set but never used - uNbScalers = 0; - uNbChan = 0; - // Here we go to next board for all undefined/invalid types - continue; - break; - } // switch( xScalerBoard->GetScalerType() ) - - fvuLastScalers[uScalBdIndx].resize(uNbScalers); - for( UInt_t uScaler = 0; uScaler < uNbScalers; uScaler++) - { - fvuLastScalers[uScalBdIndx][uScaler].resize(uNbChan); - for( UInt_t uCh = 0; uCh < uNbChan; uCh++) - { - fvuLastScalers[uScalBdIndx][uScaler][uCh] = 0; - } // for( UInt_t uCh = 0; uCh < uNbChan; uCh++) - } // for( UInt_t uScaler = 0; uScaler < uNbScalers; uScaler++) - - fvuFirstRefClk[uScalBdIndx] = 0; - fvuRefClkCycle[uScalBdIndx] = 0; - fvuLastRefClk[uScalBdIndx] = 0; - fvdPrevMbsTimeBd[uScalBdIndx] = 0; - fvuLastRefClkCal[uScalBdIndx] = 0; - fvdMeanRefClkFreq[uScalBdIndx] = -1.0; - } // for( UInt_t uScalBdIndx = 0; uScalBdIndx < uNbScalBd; uScalBdIndx++ ) - - fdFirstMbsTime = 0; - fdPrevMbsTime = 0; - - bFirstEvent = kTRUE; - bFirstEvent2014 = kTRUE; - - return kTRUE; -} -Bool_t TMbsCalibScalTof::Calibration( UInt_t uBoard) -{ - if( fMbsUnpackPar->GetNbActiveScalersB() <= uBoard) - return kFALSE; - - if( NULL == fScalerBoardCollection || - NULL == fCalibScalCollection ) - return kFALSE; - - TTofScalerBoard * xScalerBoard = (TTofScalerBoard*) fScalerBoardCollection->At(uBoard); - TTofCalibScaler * xCalibScaler = (TTofCalibScaler*) fCalibScalCollection->ConstructedAt(uBoard); - - if( NULL == xScalerBoard || NULL == xCalibScaler ) - return kFALSE; - - UInt_t uType = xScalerBoard->GetScalerType(); - - if( tofscaler::undef == xCalibScaler->GetScalerType() ) - xCalibScaler->SetType( uType ); - - if( kFALSE == xScalerBoard->IsUpdated() ) - { - // This event did not contain scalers data - xCalibScaler->SetPresentFlag( kFALSE ); - return kFALSE; - } // if( kFALSE == xScalerBoard->IsUpdated() ) - else xCalibScaler->SetPresentFlag( kTRUE ); - - Double_t dRefClkFreq; - UInt_t uNbScalers; - UInt_t uNbChan; - switch( uType ) - { - case tofscaler::triglog : - case tofscaler::triglogscal : - dRefClkFreq = triglog::kdRefClkFreq; - uNbScalers = triglog::kuNbScalers; - uNbChan = triglog::kuNbChan; - break; - case tofscaler::scalormu : - dRefClkFreq = scalormu::kdRefClkFreq; - uNbScalers = scalormu::kuNbScalers; - uNbChan = scalormu::kuNbChan; - break; - case tofscaler::scalormubig : - dRefClkFreq = scalormuBig::kdRefClkFreq; - uNbScalers = scalormuBig::kuNbScalers; - uNbChan = scalormuBig::kuNbChan; - break; - case tofscaler::scaler2014 : - dRefClkFreq = scaler2014::kdRefClkFreq; - uNbScalers = scaler2014::kuNbScalers; - uNbChan = scaler2014::kuNbChan; - break; - case tofscaler::orgen : - dRefClkFreq = orgen::kdRefClkFreq; - uNbScalers = orgen::kuNbScalers; - uNbChan = orgen::kuNbChan; - break; - case tofscaler::undef : - default: - dRefClkFreq = -1.0; - uNbScalers = 0; - uNbChan = 0; - // Here we go to next board for all undefined/invalid types - return kFALSE; - break; - } // switch( xScalerBoard->GetScalerType() ) - - // Detection of reference clock counter cycles - if( xScalerBoard->GetRefClk() < fvuLastRefClk[uBoard] ) - fvuRefClkCycle[uBoard] ++; - - // There should always be only 1 Trigger board active, if not => problem - if( 1 == fMbsUnpackPar->GetNbActiveBoards( tofMbs::triglog ) ) - { - TTofTriglogBoard * xTriglogBoard = (TTofTriglogBoard*) fTriglogBoardCollection->At(0); // Always only 1 TRIGLOG board! - - // In GSI April 2014 beamtime some event are used to empty TRB buffers - // and therefore do not contain the MBS event - if( kFALSE == xTriglogBoard->IsUpdated() ) - { - LOG(error)<<"TMbsCalibScalTof::Calibration => No TRIGLOG sub-event in this event," - <<" OK for GSI April 2014 beamtime"; - return kFALSE; - } // if( kFALSE == fTriglogBoard->IsUpdated() && kFALSE == fScalerBoard->IsUpdated() ) - - if( NULL == xTriglogBoard ) - { - LOG(error)<<"TMbsCalibScalTof::Calibration => TRIGLOG board object not existing!!!!"; - LOG(error)<<"TMbsCalibScalTof::Calibration => TTofTriglogBoard = "<<xTriglogBoard; - LOG(error)<<"TMbsCalibScalTof::Calibration => Probably the TRIGLOG sub-event is not there in this event!"; - return kFALSE; - } // if( NULL == xTriglogBoard ) - - Double_t dMbsTime = xTriglogBoard->GetMbsTimeSec() + xTriglogBoard->GetMbsTimeMilliSec()*1e-3; - if( 0 < fdPrevMbsTime ) - // MBS time is time in s since LINUX epoch (circa 1970) => never 0 except on first event! - { - // Update only when at least 50ms passed since last update due to ms precision of the MBS time - if( (fdPrevMbsTime + 0.05 < dMbsTime && kFALSE == bFirstEvent && uType != tofscaler::scaler2014) || - (fvdPrevMbsTimeBd[uBoard] + 0.05 < dMbsTime && kFALSE == bFirstEvent && uType == tofscaler::triglogscal) || - (fvdPrevMbsTimeBd[uBoard] + 0.05 < dMbsTime && kFALSE == bFirstEvent2014 - && uType == tofscaler::scaler2014) ) - { - Double_t dTimeDiff = dMbsTime - fdPrevMbsTime; - if( uType == tofscaler::scaler2014 || uType == tofscaler::triglogscal) - dTimeDiff = dMbsTime - fvdPrevMbsTimeBd[uBoard]; - // Update only if less than 500ms passed since last update to avoid problems with spill breaks - if( dTimeDiff < 0.5 && uType != tofscaler::scaler2014 ) - { - // Monitoring the rate of the reference clock - fhRefClkRate[uBoard]->Fill( (Double_t)((Double_t)(xScalerBoard->GetRefClk()) - (Double_t)(fvuLastRefClkCal[uBoard]) ) / - dTimeDiff ); - fhRefClkRateEvo[uBoard]->Fill(dMbsTime - fdFirstMbsTime, - (Double_t)((Double_t)(xScalerBoard->GetRefClk()) - (Double_t)(fvuLastRefClkCal[uBoard]))/dTimeDiff ); - - // Try to update the clock frequency only if there are enough points in the monitoring histo, - // the distribution spread is reasonnable and the option is ON - if( 2000 < fhRefClkRate[uBoard]->GetEntries() && - 10000 < fhRefClkRate[uBoard]->GetRMS() && kTRUE == fMbsCalibPar->CalibRefClocks() - ) - fvdMeanRefClkFreq[uBoard] = fhRefClkRate[uBoard]->GetMean(); - -// fhRefClkRateEstA[uBoard]->Fill( dMbsTime - fdFirstMbsTime, fhRefClkRate[uBoard]->GetMean() ); -// fhRefClkRateEstB[uBoard]->Fill( dMbsTime - fdFirstMbsTime, fhRefClkRateEvo[uBoard]->GetMean(2) ); - } // if( 0 < fdPrevMbsTime ) - // in case of 2014 GSI April beamtime this happens quite often for scalers => use time dist! - // Same at cern Feb15 - else if( dTimeDiff < 5 && (uType == tofscaler::scaler2014 || uType == tofscaler::triglogscal) ) //&& - // fvuLastRefClkCal[uBoard] < xScalerBoard->GetRefClk()) - { - // Monitoring the rate of the reference clock - fhRefClkRate[uBoard]->Fill( (Double_t)((Double_t)(xScalerBoard->GetRefClk()) - (Double_t)(fvuLastRefClkCal[uBoard]) ) / - dTimeDiff ); - fhRefClkRateEvo[uBoard]->Fill(dMbsTime - fdFirstMbsTime, - (Double_t)((Double_t)(xScalerBoard->GetRefClk()) - (Double_t)(fvuLastRefClkCal[uBoard]) )/ - dTimeDiff ); - -// LOG(info)<<"TMbsCalibScalTof::Calibration => => Scaler 2014 #" -// <<uBoard -// <<" "<<xScalerBoard->GetRefClk()<<" "<<fvuLastRefClkCal[uBoard] -// <<" "<<(Double_t)(xScalerBoard->GetRefClk() - fvuLastRefClkCal[uBoard] ) -// <<" "<<dTimeDiff -// <<" "<<(Double_t)(xScalerBoard->GetRefClk() - fvuLastRefClkCal[uBoard] )/dTimeDiff -// ; - // Try to update the clock frequency only if there are enough points in the monitoring histo, - // the distribution spread is reasonable and the option is ON - if( 2000 < fhRefClkRate[uBoard]->GetEntries() && - 10000 < fhRefClkRate[uBoard]->GetRMS() && kTRUE == fMbsCalibPar->CalibRefClocks() - ) - fvdMeanRefClkFreq[uBoard] = fhRefClkRate[uBoard]->GetMean(); - -// fhRefClkRateEstA[uBoard]->Fill( dMbsTime - fdFirstMbsTime, fhRefClkRate[uBoard]->GetMean() ); -// fhRefClkRateEstB[uBoard]->Fill( dMbsTime - fdFirstMbsTime, fhRefClkRateEvo[uBoard]->GetMean(2) ); - } // if( 0 < fdPrevMbsTime ) - if( ( 0 == fvdPrevMbsTimeBd[uBoard] ) || ( fvdPrevMbsTimeBd[uBoard] + 0.05 < dMbsTime ) ) - fvdPrevMbsTimeBd[uBoard] = dMbsTime; - - // Save value of the reference clock in last rate update -// fvuLastRefClkCal[uBoard] = xScalerBoard->GetRefClk(); - } // if( ( 0 == fdPrevMbsTime ) || ( fdPrevMbsTime + 0.05 < dMbsTime ) ) - - if( 0 < fvdMeanRefClkFreq[uBoard] && kTRUE == fMbsCalibPar->CalibRefClocks() ) - dRefClkFreq = fvdMeanRefClkFreq[uBoard]; - } // if( 0 < fdPrevMbsTime ) - } // if( 1 == fMbsUnpackPar->GetNbActiveBoards( tofMbs::triglog ) ) - - if( ( kFALSE == bFirstEvent && uType != tofscaler::scaler2014) || - ( kFALSE == bFirstEvent2014 && uType == tofscaler::scaler2014) ) - { - // If not first event, calculate the time since first and last event using the reference clock of the board - Double_t dRefTime = (Double_t)( (Double_t)(xScalerBoard->GetRefClk()) - (Double_t)(fvuFirstRefClk[uBoard]) - + (Double_t)(fvuRefClkCycle[uBoard])*4294967296. )/dRefClkFreq; - - Double_t dRefTimeToLast = (Double_t)( (Double_t)(xScalerBoard->GetRefClk()) - (Double_t)(fvuLastRefClk[uBoard]) )/dRefClkFreq; - if( xScalerBoard->GetRefClk() < fvuLastRefClk[uBoard] ) - dRefTimeToLast = (Double_t)( (Double_t)(xScalerBoard->GetRefClk()) + 1 + (Double_t)(0xFFFFFFFF - fvuLastRefClk[uBoard]) )/dRefClkFreq; - - xCalibScaler->SetRefClk( (Double_t)( xScalerBoard->GetRefClk() )/dRefClkFreq ); - xCalibScaler->SetTimeToFirst( dRefTime ); - xCalibScaler->SetTimeToLast( dRefTimeToLast ); - - if( 1e-6 < dRefTimeToLast ) - { - for( UInt_t uScaler = 0; uScaler < uNbScalers; uScaler++) - { - for( UInt_t uCh = 0; uCh < uNbChan; uCh++) - { - // for each board/scaler/channel, calculate the instantaneous rate between last event and this one - // using the scaler count difference and the time since last event obtained with the reference clock - UInt_t uCurrVal = xScalerBoard->GetScalerValue( uCh, uScaler); - Double_t dRate = (Double_t)( (Double_t)(uCurrVal) - (Double_t)(fvuLastScalers[uBoard][uScaler][uCh]) ) / dRefTimeToLast; - if( uCurrVal < fvuLastScalers[uBoard][uScaler][uCh] ) - dRate = (Double_t)( (Double_t)(uCurrVal) + 1 + (Double_t)(0xFFFFFFFF - fvuLastScalers[uBoard][uScaler][uCh]) ) - / dRefTimeToLast; - xCalibScaler->SetScalerValue( uCh, dRate, uScaler); -// fhScalersRateEvo[uBoard][uScaler][uCh]->Fill( dRefTime, uCurrVal - fvuLastScalers[uBoard][uScaler][uCh] ); - fvuLastScalers[uBoard][uScaler][uCh] = uCurrVal; - } // for( UInt_t uCh = 0; uCh < uNbChan; uCh++) - } // for( UInt_t uScaler = 0; uScaler < uNbScalers; uScaler++) - } // if( 0 < dRefTimeToLast ) - else - { - for( UInt_t uScaler = 0; uScaler < uNbScalers; uScaler++) - { - for( UInt_t uCh = 0; uCh < uNbChan; uCh++) - { - // for each board/scaler/channel, calculate the instantaneous rate between last event and this one - // using the scaler count difference and the time since last event obtained with the reference clock - UInt_t uCurrVal = xScalerBoard->GetScalerValue( uCh, uScaler); - Double_t dRate = 0.0; - xCalibScaler->SetScalerValue( uCh, dRate, uScaler); - fvuLastScalers[uBoard][uScaler][uCh] = uCurrVal; - } // for( UInt_t uCh = 0; uCh < uNbChan; uCh++) - } // for( UInt_t uScaler = 0; uScaler < uNbScalers; uScaler++) - } // else of if( 0 < dRefTimeToLast ) - } // if( kFALSE == bFirstEvent ) - - fvuLastRefClk[uBoard] = xScalerBoard->GetRefClk(); - - if( ( kTRUE == bFirstEvent && uType != tofscaler::scaler2014) || - ( kTRUE == bFirstEvent2014 && uType == tofscaler::scaler2014) ) - { - fvuFirstRefClk[uBoard] = fvuLastRefClk[uBoard]; - fvuLastRefClkCal[uBoard] = fvuLastRefClk[uBoard]; - - for( UInt_t uScaler = 0; uScaler < uNbScalers; uScaler++) - for( UInt_t uCh = 0; uCh < uNbChan; uCh++) - fvuLastScalers[uBoard][uScaler][uCh] = xScalerBoard->GetScalerValue( uCh, uScaler); - } // if( kTRUE == bFirstEvent ) - - return kTRUE; -} - -Bool_t TMbsCalibScalTof::CloseCalibration() -{ - // Loop over all scalers - for( UInt_t uScalBdIndx = 0; uScalBdIndx < fvuLastScalers.size(); uScalBdIndx++ ) - { - for( UInt_t uScaler = 0; uScaler < fvuLastScalers[uScalBdIndx].size(); uScaler++) - fvuLastScalers[uScalBdIndx][uScaler].clear(); - fvuLastScalers[uScalBdIndx].clear(); - } // for( UInt_t uScalBdIndx = 0; uScalBdIndx < uNbScalBd; uScalBdIndx++ ) - - if( 0 < fvuLastScalers.size() ) - { - fvuLastScalers.clear(); - fvuFirstRefClk.clear(); - fvuLastRefClk.clear(); - fvdMeanRefClkFreq.clear(); - } - return kTRUE; -} -// ------------------------------------------------------------------ - diff --git a/beamtime/tof/calib/scaler/TMbsCalibScalTof.h b/beamtime/tof/calib/scaler/TMbsCalibScalTof.h deleted file mode 100644 index b549924d62497b9a873dd39cf3272e8227c1b3d6..0000000000000000000000000000000000000000 --- a/beamtime/tof/calib/scaler/TMbsCalibScalTof.h +++ /dev/null @@ -1,122 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TMbsCalibScalTof.h ----- -// ----- Created 08/07/2013 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ - -#ifndef TMBSCALIBSCALTOF_H_ -#define TMBSCALIBSCALTOF_H_ - -// TOF headers -#include "TofScalerDef.h" - -// ROOT headers -#include "TObject.h" - -// C/C++ headers -#include <vector> - -class TMbsUnpackTofPar; -class TMbsCalibTofPar; - -class TFile; -class TDirectory; -class TClonesArray; -class TH1; -class TH2; -class TProfile; -class TString; - -class TMbsCalibScalTof : public TObject -{ - public: - TMbsCalibScalTof(); - TMbsCalibScalTof( TMbsUnpackTofPar * parIn, TMbsCalibTofPar *parCalIn = NULL ); - ~TMbsCalibScalTof(); - - virtual void Clear(Option_t *option); - - Bool_t RegisterInput(); - Bool_t RegisterOutput(); - void SetSaveScalers( Bool_t bSaveScal=kTRUE ); - void SetHistoUserAxis( Double_t dRangeIn, Double_t dBinSzIn ) - { fdEvoRangeUser = dRangeIn; fdEvoBinSzUser = dBinSzIn; }; - - Bool_t InitScalersCalib(); - Bool_t CalibScalers(); - Bool_t ClearCalib(); - Bool_t CloseScalersCalib(); - - - // Histograms - Bool_t CreateHistogramms(); - Bool_t FillHistograms(); - Bool_t WriteHistogramms( TDirectory* inDir); - Bool_t DeleteHistograms(); - - private: - // no default Copy constructor and = OP as class not meant to be copied - TMbsCalibScalTof(const TMbsCalibScalTof&); - TMbsCalibScalTof& operator=(const TMbsCalibScalTof&); - - Bool_t InitParameters(); - TMbsUnpackTofPar *fMbsUnpackPar; - TMbsCalibTofPar *fMbsCalibPar; - - // Histograms - - // Histograms objects - std::vector< TH1* > fhRefClkRate; // Only if Triglog present - std::vector< TProfile* > fhRefClkRateEvo; // Only if Triglog present -// std::vector< TH2* > fhRefClkRateEstA; // Only if Triglog present -// std::vector< TH2* > fhRefClkRateEstB; // Only if Triglog present -// std::vector< TProfile* > fhRefClkRateEvo; // Only if Triglog present - std::vector< TH2* > fhRefMbsTimeComp; // Only if Triglog present - std::vector< std::vector< std::vector< TH1* > > > fhScalersRate; // [NbBoards][NbScalers][NbChan] -// std::vector< std::vector< std::vector< TH1* > > > fhScalersRateEvo; // [NbBoards][NbScalers][NbChan] - std::vector< std::vector< std::vector< TProfile* > > > fhScalersRateEvo; // [NbBoards][NbScalers][NbChan] - - // Histograms tuning - Double_t fdEvoRangeUser; - Double_t fdEvoBinSzUser; - - // Input - - // Input objects - TClonesArray * fScalerBoardCollection; - TClonesArray * fTriglogBoardCollection; - - // Output - Bool_t ClearOutput(); - - // Output objects - Bool_t fbSaveCalibScalers; - TClonesArray * fCalibScalCollection; - - // Calibration - Bool_t InitCalibration(); - Bool_t Calibration( UInt_t uBoard); - Bool_t CloseCalibration(); - - // Calibration objects - Bool_t bFirstEvent; - Bool_t bFirstEvent2014; - // First reference clock number [NbBoards] - std::vector< UInt_t > fvuFirstRefClk; - // Number of times the reference clock scaler made a cycle [NbBoards] - std::vector< UInt_t > fvuRefClkCycle; - // last reference clock number [NbBoards] - std::vector< UInt_t > fvuLastRefClk; - // First value of each scaler <= integrated counts [NbBoards][NbScalers][NbChan] - std::vector< std::vector< std::vector< UInt_t > > > fvuLastScalers; - - // Clock Calibration objects, used only if TRIGLOG board is present - Double_t fdFirstMbsTime; // First point for rate measurement - Double_t fdPrevMbsTime; // previous point for rate measurement - std::vector< Double_t > fvdPrevMbsTimeBd; // previous point for ref clockrate measurement - std::vector< UInt_t > fvuLastRefClkCal; // last reference clock number used in frequency calibration [NbBoards] - std::vector< Double_t > fvdMeanRefClkFreq; // Only if Triglog present - - ClassDef(TMbsCalibScalTof, 1) -}; - -#endif // TMBSCALIBSCALTOF_H_ diff --git a/beamtime/tof/calib/scaler/TTofCalibScaler.cxx b/beamtime/tof/calib/scaler/TTofCalibScaler.cxx deleted file mode 100644 index 4c9a46ec30729aad727e24452ad642a74d853684..0000000000000000000000000000000000000000 --- a/beamtime/tof/calib/scaler/TTofCalibScaler.cxx +++ /dev/null @@ -1,230 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TTofCalibScaler ----- -// ----- Created 08/07/2013 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ - -#include "TTofCalibScaler.h" - -// TOF headers -#include "TofScalerDef.h" -#include "TofTriglogDef.h" -#include "TofScomDef.h" -#include "TofScal2014Def.h" -#include "TofOrGenDef.h" - -// FAIR headers -#include "FairLogger.h" - -// ROOT headers - -// C/C++ headers - -/************************** TTofCalibScaler ****************************/ -TTofCalibScaler::TTofCalibScaler(): - fbScalerFoundInEvent(kFALSE), - fuScalerType(0), - fuScalerNumber(0), - fuChannelNumber(0), - fdReferenceClock(0), - fdTimeSinceFirst(0), - fdTimeSinceLast(0), - fvdDataCollection() -{ - fvdDataCollection.clear(); -} -TTofCalibScaler::TTofCalibScaler( UInt_t uType ) : - fbScalerFoundInEvent(kFALSE), - fuScalerType(uType), - fuScalerNumber(0), - fuChannelNumber(0), - fdReferenceClock(0), - fdTimeSinceFirst(0), - fdTimeSinceLast(0) , - fvdDataCollection() -{ - switch( fuScalerType ) - { - case tofscaler::undef : - fuScalerNumber = 0; - fuChannelNumber = 0; - fvdDataCollection.clear(); - break; - case tofscaler::triglog : - case tofscaler::triglogscal : - fuScalerNumber = triglog::kuNbScalers; - fuChannelNumber = triglog::kuNbChan; - fvdDataCollection.resize( fuScalerNumber ); - for( UInt_t uScaler = 0; uScaler < fuScalerNumber; uScaler ++) - fvdDataCollection[uScaler].resize( fuChannelNumber ); - break; - case tofscaler::scalormu : - fuScalerNumber = scalormu::kuNbScalers; - fuChannelNumber = scalormu::kuNbChan; - fvdDataCollection.resize( fuScalerNumber ); - for( UInt_t uScaler = 0; uScaler < fuScalerNumber; uScaler ++) - fvdDataCollection[uScaler].resize( fuChannelNumber ); - break; - case tofscaler::scalormubig : - fuScalerNumber = scalormuBig::kuNbScalers; - fuChannelNumber = scalormuBig::kuNbChan; - fvdDataCollection.resize( fuScalerNumber ); - for( UInt_t uScaler = 0; uScaler < fuScalerNumber; uScaler ++) - fvdDataCollection[uScaler].resize( fuChannelNumber ); - break; - case tofscaler::scaler2014 : - fuScalerNumber = scaler2014::kuNbScalers; - fuChannelNumber = scaler2014::kuNbChan; - fvdDataCollection.resize( fuScalerNumber ); - for( UInt_t uScaler = 0; uScaler < fuScalerNumber; uScaler ++) - fvdDataCollection[uScaler].resize( fuChannelNumber ); - break; - case tofscaler::orgen : - fuScalerNumber = orgen::kuNbScalers; - fuChannelNumber = orgen::kuNbChan; - fvdDataCollection.resize( fuScalerNumber ); - for( UInt_t uScaler = 0; uScaler < fuScalerNumber; uScaler ++) - fvdDataCollection[uScaler].resize( fuChannelNumber ); - break; - default: - fuScalerNumber = 0; - fuChannelNumber = 0; - fvdDataCollection.clear(); - break; - } // switch( fuScalerType ) -} -TTofCalibScaler::TTofCalibScaler( UInt_t uType, UInt_t uScalNb, UInt_t uChNb ) : - fbScalerFoundInEvent(kFALSE), - fuScalerType(uType), - fuScalerNumber(uScalNb), - fuChannelNumber(uChNb), - fdReferenceClock(0), - fdTimeSinceFirst(0), - fdTimeSinceLast(0), - fvdDataCollection() -{ - if( 0 < fuScalerNumber && 0 < fuChannelNumber ) - { - fvdDataCollection.resize( fuScalerNumber ); - for( UInt_t uScaler = 0; uScaler < fuScalerNumber; uScaler ++) - fvdDataCollection[uScaler].resize( fuChannelNumber ); - } // if( 0 < fuScalerNumber && 0 < fuChannelNumber ) -} -TTofCalibScaler::~TTofCalibScaler() -{ - for( UInt_t uScaler = 0; uScaler < fuScalerNumber; uScaler ++) - fvdDataCollection[uScaler].clear(); - - fvdDataCollection.clear(); -} - -void TTofCalibScaler::Clear(Option_t *option) -{ - TObject::Clear( option ); - fbScalerFoundInEvent = kFALSE; - fdReferenceClock = 0; - fdTimeSinceFirst = 0; - fdTimeSinceLast = 0; - for( UInt_t uScaler = 0; uScaler < fuScalerNumber; uScaler ++) - for( UInt_t uCh = 0; uCh < fuChannelNumber; uCh ++) - fvdDataCollection[uScaler][uCh] = 0; -} - // Set the scaler type from list defined in TofScalerDef.h, then the scaler size from other Def headers -void TTofCalibScaler::SetType( UInt_t uType ) -{ - fuScalerType = uType; - switch( fuScalerType ) - { - case tofscaler::undef : - fuScalerNumber = 0; - fuChannelNumber = 0; - fvdDataCollection.clear(); - break; - case tofscaler::triglog : - case tofscaler::triglogscal : - fuScalerNumber = triglog::kuNbScalers; - fuChannelNumber = triglog::kuNbChan; - fvdDataCollection.resize( fuScalerNumber ); - for( UInt_t uScaler = 0; uScaler < fuScalerNumber; uScaler ++) - fvdDataCollection[uScaler].resize( fuChannelNumber ); - break; - case tofscaler::scalormu : - fuScalerNumber = scalormu::kuNbScalers; - fuChannelNumber = scalormu::kuNbChan; - fvdDataCollection.resize( fuScalerNumber ); - for( UInt_t uScaler = 0; uScaler < fuScalerNumber; uScaler ++) - fvdDataCollection[uScaler].resize( fuChannelNumber ); - break; - case tofscaler::scalormubig : - fuScalerNumber = scalormuBig::kuNbScalers; - fuChannelNumber = scalormuBig::kuNbChan; - fvdDataCollection.resize( fuScalerNumber ); - for( UInt_t uScaler = 0; uScaler < fuScalerNumber; uScaler ++) - fvdDataCollection[uScaler].resize( fuChannelNumber ); - break; - case tofscaler::scaler2014 : - fuScalerNumber = scaler2014::kuNbScalers; - fuChannelNumber = scaler2014::kuNbChan; - fvdDataCollection.resize( fuScalerNumber ); - for( UInt_t uScaler = 0; uScaler < fuScalerNumber; uScaler ++) - fvdDataCollection[uScaler].resize( fuChannelNumber ); - break; - case tofscaler::orgen : - fuScalerNumber = orgen::kuNbScalers; - fuChannelNumber = orgen::kuNbChan; - fvdDataCollection.resize( fuScalerNumber ); - for( UInt_t uScaler = 0; uScaler < fuScalerNumber; uScaler ++) - fvdDataCollection[uScaler].resize( fuChannelNumber ); - break; - default: - fuScalerNumber = 0; - fuChannelNumber = 0; - fvdDataCollection.clear(); - break; - } // switch( fuScalerType ) -} -// if 0 < fuChannelNumber, update fvdDataCollection size or create it -void TTofCalibScaler::SetScalerNumber( UInt_t uScalNb ) -{ - fuScalerNumber = uScalNb; - if( 0 < fuScalerNumber && 0 < fuChannelNumber ) - { - fvdDataCollection.resize( fuScalerNumber ); - for( UInt_t uScaler = 0; uScaler < fuScalerNumber; uScaler ++) - fvdDataCollection[uScaler].resize( fuChannelNumber ); - } // if( 0 < fuScalerNumber && 0 < fuChannelNumber ) -} -// if 0 < fuScalerNumber, update fvdDataCollection size or create it -void TTofCalibScaler::SetChannelNumber( UInt_t uChNb ) -{ - fuChannelNumber = uChNb; - if( 0 < fuScalerNumber && 0 < fuChannelNumber ) - { - fvdDataCollection.resize( fuScalerNumber ); - for( UInt_t uScaler = 0; uScaler < fuScalerNumber; uScaler ++) - fvdDataCollection[uScaler].resize( fuChannelNumber ); - } // if( 0 < fuScalerNumber && 0 < fuChannelNumber ) -} -// update fvdDataCollection size or create it -void TTofCalibScaler::SetBoardCharac( UInt_t uScalNb, UInt_t uChNb) -{ - fuScalerNumber = uScalNb; - fuChannelNumber = uChNb; - if( 0 < fuScalerNumber && 0 < fuChannelNumber ) - { - fvdDataCollection.resize( fuScalerNumber ); - for( UInt_t uScaler = 0; uScaler < fuScalerNumber; uScaler ++) - fvdDataCollection[uScaler].resize( fuChannelNumber ); - } // if( 0 < fuScalerNumber && 0 < fuChannelNumber ) -} -void TTofCalibScaler::SetScalerValue( UInt_t uChan, Double_t dVal, UInt_t uScaler) -{ - if( uScaler < fuScalerNumber && uChan < fuChannelNumber ) - fvdDataCollection[uScaler][uChan] = dVal; -} - -Double_t TTofCalibScaler::GetScalerValue( UInt_t uChannel, UInt_t uScaler) const -{ - if( uScaler < fuScalerNumber && uChannel < fuChannelNumber ) - return fvdDataCollection[uScaler][uChannel]; - else return 0.0; -} diff --git a/beamtime/tof/calib/scaler/TTofCalibScaler.h b/beamtime/tof/calib/scaler/TTofCalibScaler.h deleted file mode 100644 index 9402962f4e615723d41b90a5785c4e9b1eb7b9b1..0000000000000000000000000000000000000000 --- a/beamtime/tof/calib/scaler/TTofCalibScaler.h +++ /dev/null @@ -1,63 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TTofCalibScaler ----- -// ----- Created 08/07/2013 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ - -#ifndef TTOFCALIBSSCALER_H_ -#define TTOFCALIBSSCALER_H_ - -// ROOT headers -#include "TObject.h" - -// C/C++ headers -#include <vector> - -class TTofCalibScaler : public TObject -{ - public: - TTofCalibScaler(); - TTofCalibScaler( UInt_t uType ); - TTofCalibScaler( UInt_t uType, UInt_t uScalNb, UInt_t uChNb ); - ~TTofCalibScaler(); - - virtual void Clear(Option_t *option = ""); - - void SetPresentFlag( Bool_t bDataThere ) { fbScalerFoundInEvent = bDataThere; }; - void SetType( UInt_t uType ); // Set the scaler type from list defined in TofScalerDef.h, then the scaler size from other Def headers - void SetScalerNumber( UInt_t uScalNb ); // if 0 < fuChannelNumber, update fvuDataCollection size or create it - void SetChannelNumber( UInt_t uChNb ); // if 0 < fuScalerNumber, update fvuDataCollection size or create it - void SetBoardCharac( UInt_t uScalNb, UInt_t uChNb); // update fvuDataCollection size or create it - void SetScalerValue( UInt_t uChan, Double_t dVal, UInt_t uScaler = 0 ); - void SetRefClk( Double_t dRefClk ) { fdReferenceClock = dRefClk; }; - void SetTimeToFirst( Double_t dTimeFirst ) { fdTimeSinceFirst = dTimeFirst; }; - void SetTimeToLast( Double_t dTimeLast ) { fdTimeSinceLast = dTimeLast; }; - - Bool_t IsUpdated() const { return fbScalerFoundInEvent; }; - UInt_t GetScalerType() const { return fuScalerType; }; - UInt_t GetScalerNumber() const { return fuScalerNumber; }; - UInt_t GetChannelNumber() const { return fuChannelNumber; }; - Double_t GetRefClk() const { return fdReferenceClock; }; - Double_t GetTimeToFirst() const { return fdTimeSinceFirst; }; - Double_t GetTimeToLast() const { return fdTimeSinceLast; }; - Double_t GetScalerValue( UInt_t uChannel, UInt_t uScaler = 0 ) const; - - private: - Bool_t fbScalerFoundInEvent; - UInt_t fuScalerType; - UInt_t fuScalerNumber; - UInt_t fuChannelNumber; - - /* Internal 781250 Hz reference clock for rates calculation */ - Double_t fdReferenceClock; - - /* Time since the first event, calculated using the reference clock values and frequency */ - Double_t fdTimeSinceFirst; - /* Time since the last event, calculated using the reference clock values and frequency */ - Double_t fdTimeSinceLast; - - std::vector< std::vector< Double_t > > fvdDataCollection; - - ClassDef(TTofCalibScaler, 1) -}; - -#endif // TTOFCALIBSSCALER_H_ diff --git a/beamtime/tof/calib/tdc/TMbsCalibTdcTof.cxx b/beamtime/tof/calib/tdc/TMbsCalibTdcTof.cxx deleted file mode 100644 index e900af9dfc8e34f6e8bb215b85a18abdb6d9c1d4..0000000000000000000000000000000000000000 --- a/beamtime/tof/calib/tdc/TMbsCalibTdcTof.cxx +++ /dev/null @@ -1,3759 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TMbsCalibTdcTof ----- -// ----- Created 20/06/2013 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ -#include "TMbsCalibTdcTof.h" - -// General Unpack headers -#include "TMbsUnpackTofPar.h" - -// ToF specific headers -#include "TMbsCalibTofPar.h" -#include "TofTdcDef.h" -#include "TofCaenDef.h" -#include "TofVftxDef.h" -#include "TofTrbTdcDef.h" -#include "TofGet4Def.h" -#include "TTofTdcBoard.h" -#include "TTofTdcData.h" -#include "TTofCalibData.h" -// TRB-TDC specific headers -#include "TTofTrbTdcBoard.h" -#include "TTofTrbTdcData.h" - -// FAIR headers -#include "FairLogger.h" -#include "FairRunAna.h" -#include "FairRuntimeDb.h" -#include "FairRootManager.h" - -// ROOT headers -#include "TClonesArray.h" -#include "TH2.h" -#include "TH1.h" -#include "TProfile.h" -#include "TROOT.h" -#include "TTimeStamp.h" -#include <TFile.h> - -TMbsCalibTdcTof::TMbsCalibTdcTof() : - TObject(), - fMbsUnpackPar(NULL), - fMbsCalibPar(NULL), - fbGsiSep14Fix(kFALSE), - fiOffsetGsiSep14Fix(-1), - fbTdcRefMoniMode(kFALSE), - fCaenBoardCollection(NULL), - fVftxBoardCollection(NULL), - fTrb3BoardCollection(NULL), - fGet4BoardCollection(NULL), - fbSaveCalibTdcs(kFALSE), - fCalibDataCollection(NULL), - fileCalibrationIn(NULL), - oldDir(NULL), - fsCalibOutFoldername("./"), - fsCalibFilename("") -{ - // Get Base Container - FairRunAna* ana = FairRunAna::Instance(); - FairRuntimeDb* rtdb=ana->GetRuntimeDb(); - - // Unpack parameter - fMbsUnpackPar = (TMbsUnpackTofPar*) (rtdb->getContainer("TMbsUnpackTofPar")); - if( 0 == fMbsUnpackPar ) - - // Calibration parameter - fMbsCalibPar = (TMbsCalibTofPar*) (rtdb->getContainer("TMbsCalibTofPar")); - if( 0 == fMbsCalibPar ) - LOG(error)<<"TMbsCalibTdcTof::TMbsCalibTdcTof => Could not obtain the TMbsCalibTofPar "; - else fMbsCalibPar->printParams(); -} - -TMbsCalibTdcTof::TMbsCalibTdcTof(TMbsUnpackTofPar * parIn, TMbsCalibTofPar *parCalIn) : - TObject(), - fMbsUnpackPar(parIn), - fMbsCalibPar(parCalIn), - fbGsiSep14Fix(kFALSE), - fiOffsetGsiSep14Fix(-1), - fbTdcRefMoniMode(kFALSE), - fCaenBoardCollection(NULL), - fVftxBoardCollection(NULL), - fTrb3BoardCollection(NULL), - fGet4BoardCollection(NULL), - fbSaveCalibTdcs(kFALSE), - fCalibDataCollection(NULL), - fileCalibrationIn(NULL), - oldDir(NULL), - fsCalibOutFoldername("./"), - fsCalibFilename("") -{ -} - -TMbsCalibTdcTof::~TMbsCalibTdcTof() -{ - DeleteHistograms(); - DeleteTotVariables(); - LOG(info)<<"**** TMbsCalibTdcTof: Delete instance "; -} - -void TMbsCalibTdcTof::Clear(Option_t */*option*/) -{ - fMbsUnpackPar = NULL; - fMbsCalibPar = NULL; - fCaenBoardCollection = NULL; - fVftxBoardCollection = NULL; - fTrb3BoardCollection = NULL; - fGet4BoardCollection = NULL; - fCalibDataCollection = NULL; - fbSaveCalibTdcs = kFALSE; - fsCalibOutFoldername = "./", - fsCalibFilename = ""; -} - -// Calibration Functions -Bool_t TMbsCalibTdcTof::InitiTdcCalib() -{ - if( kFALSE == InitCalibration() ) - return kFALSE; - - if( kFALSE == CreateTotVariables() ) - return kFALSE; - - if( kFALSE == GetHistosFromUnpack() ) - return kFALSE; - -// if( kTRUE == fMbsCalibPar->IsTdcOffsetEna() ) -// { - if( kFALSE == GetRefHistosFromUnpack() ) - return kFALSE; -// } // if( kTRUE == fMbsCalibPar->IsTdcOffsetEna() ) - - return kTRUE; -} -Bool_t TMbsCalibTdcTof::ClearCalib() -{ - ClearOutput(); - ClearTotVariables(); - return kTRUE; -} -Bool_t TMbsCalibTdcTof::CalibTdc() -{ - // Clean event start - ClearTdcReference(); - // Use only events with no corrupt data - if( kFALSE == CheckAllTdcValid() ) - return kFALSE; - - // Loop over all defined TDC types - for( UInt_t uType = toftdc::caenV1290; uType < toftdc::NbTdcTypes; uType++ ) - { - // Calibrate first the reference channel of the main TDC for TDC-TDc offset calc. - if( fMbsCalibPar->GetTdcOffsetMainTdc() < fMbsUnpackPar->GetNbActiveBoards( uType ) ) - CalibrateReference( uType, fMbsCalibPar->GetTdcOffsetMainTdc()); - - // loop over all active TDCs - for( UInt_t uTdc = 0; uTdc < fMbsUnpackPar->GetNbActiveBoards( uType ); uTdc ++) - { - // Make Main TDC reference is not calibrated twice (would spoil the calibration stats) - if( uTdc != fMbsCalibPar->GetTdcOffsetMainTdc() ) - CalibrateReference( uType, uTdc); - - if( kTRUE == fMbsCalibPar->GetTdcOffEnaFlag(uType, uTdc) ) - { - TdcOffsetCalc( uType, uTdc); - } // if( kTRUE == fMbsCalibPar->GetTdcOffEnaFlag(uType, uTdc) ) - - // If TDC Ref channel monitoring mode, calibrate and - // fill histos only for reference channel - if( kTRUE == fbTdcRefMoniMode ) - continue; - - Calibration( uType, uTdc); - } - - // If TDC Ref channel monitoring mode, calibrate and - // fill histos only for reference channel - if( kTRUE == fbTdcRefMoniMode ) - continue; - - // TOT mode 1 and 4 are already done. - // TOT mode 2 time orders and builds TOT for each TDC inside the Calibration function - if( 3 == fMbsCalibPar->GetTotMode( uType ) ) - // In the case where 1 input channel correspond to a TDC channel in 2 consecutive boards, - // we can time order the hits now that we have all boards calibrated - // and then we will be able to associate the hits in full calibrated TDC data! - BuildTotSplitBoards( uType ); - } - return kTRUE; -} -Bool_t TMbsCalibTdcTof::CloseTdcCalib() -{ - if( kTRUE == fMbsCalibPar->EnaCalibOutput() ) - WriteCalibrationFile(); - if( kTRUE == fMbsCalibPar->EnaSingleCalibOutput() ) - WriteSingleCalibrations(); - - return kTRUE; -} -void TMbsCalibTdcTof::SetCalibFilename( TString sFilenameIn ) -{ - fsCalibFilename = sFilenameIn; - if( "" == fsCalibFilename ) { - LOG(info)<<"TMbsCalibTdcTof => Use default name generation from current time for the TDC calibration file output"; - } else { - LOG(info)<<"TMbsCalibTdcTof => New name for the TDC calibration file output: " - << Form("%sTofTdcCalibHistos_%s.root", fsCalibOutFoldername.Data(), fsCalibFilename.Data() ); - } -} -void TMbsCalibTdcTof::SetCalibOutFolder( TString sFoldernameIn ) -{ - fsCalibOutFoldername = sFoldernameIn; - if( "./" == fsCalibOutFoldername ) { - LOG(info)<<"TMbsCalibTdcTof => Use current folder for the TDC calibration file output"; - } else { - LOG(info)<<"TMbsCalibTdcTof => New folder for the TDC calibration file output: " - << Form("%sTofTdcCalibHistos_%s.root", fsCalibOutFoldername.Data(), fsCalibFilename.Data() ); - } -} -Bool_t TMbsCalibTdcTof::InitParameters() -{ - return kTRUE; -} -// ------------------------------------------------------------------ -Bool_t TMbsCalibTdcTof::RegisterInput() -{ - FairRootManager* rootMgr = FairRootManager::Instance(); - - if( 0 < fMbsUnpackPar->GetNbActiveBoards( toftdc::caenV1290 ) ) - { - fCaenBoardCollection = (TClonesArray*) rootMgr->GetObject("TofCaenTdc"); - if( NULL == fCaenBoardCollection) - { - LOG(error)<<"TMbsCalibTdcTof::RegisterInput => Could not get the TofCaenTdc TClonesArray!!!"; - return kFALSE; - } // if( NULL == fCaenBoardCollection) - } // if( 0 < fMbsUnpackPar->GetNbActiveBoards( uType ) ) - - if( 0 < fMbsUnpackPar->GetNbActiveBoards( toftdc::vftx ) ) - { - fVftxBoardCollection = (TClonesArray*) rootMgr->GetObject("TofVftxTdc"); - if( NULL == fVftxBoardCollection) - { - LOG(error)<<"TMbsCalibTdcTof::RegisterInput => Could not get the TofVftxTdc TClonesArray!!!"; - return kFALSE; - } // if( NULL == fVftxBoardCollection) - } // if( 0 < fMbsUnpackPar->GetNbActiveBoards( uType ) ) - - if( 0 < fMbsUnpackPar->GetNbActiveBoards( toftdc::trb ) ) - { - fTrb3BoardCollection = (TClonesArray*) rootMgr->GetObject("TofTrbTdc"); - if( NULL == fTrb3BoardCollection) - { - LOG(error)<<"TMbsCalibTdcTof::RegisterInput => Could not get the TofTrb3Tdc TClonesArray!!!"; - return kFALSE; - } // if( NULL == fTrb3BoardCollection) - } // if( 0 < fMbsUnpackPar->GetNbActiveBoards( uType ) ) - - if( 0 < fMbsUnpackPar->GetNbActiveBoards( toftdc::get4 ) ) - { - fGet4BoardCollection = (TClonesArray*) rootMgr->GetObject("TofGet4Tdc"); - if( NULL == fGet4BoardCollection) - { - LOG(error)<<"TMbsCalibTdcTof::RegisterInput => Could not get the TofGet4Tdc TClonesArray!!!"; - return kFALSE; - } // if( NULL == fGet4BoardCollection) - } // if( 0 < fMbsUnpackPar->GetNbActiveBoards( uType ) ) - - return kTRUE; -} -Bool_t TMbsCalibTdcTof::RegisterOutput() -{ - FairRootManager* rootMgr = FairRootManager::Instance(); - fCalibDataCollection = new TClonesArray("TTofCalibData"); - - rootMgr->Register( "TofCalibData","Tof",fCalibDataCollection, - fMbsUnpackPar->WriteDataInCbmOut() || fbSaveCalibTdcs); - /* - fCalibTdcTrigCollection = new TClonesArray("Double_t"); - rootMgr->Register("TofCalibTdcTrigg","Tof",fCalibTdcTrigCollection, kTRUE); - */ - - // Prepare the saving of the reference channel time (trigger) - for( UInt_t uType = toftdc::caenV1290; uType < toftdc::NbTdcTypes; uType++ ) - { - // TODO: for now only TRB has reference channel methods implemented - if( toftdc::caenV1290 == uType || - toftdc::vftx == uType || - toftdc::get4 == uType || - toftdc::undef == uType ) - continue; - - if( 0 < fMbsUnpackPar->GetNbActiveBoards( uType ) ) - { - fCalibRefCollection[uType] = new TClonesArray( "TTofCalibData", fMbsUnpackPar->GetNbActiveBoards( uType ) ); - rootMgr->Register( Form("TofCalibRef%s",toftdc::ksTdcParName[ uType ].Data() ), - "TofCalib", fCalibRefCollection[uType], - fMbsUnpackPar->WriteDataInCbmOut() || fbSaveCalibTdcs ); - } // if( 0 < fMbsUnpackPar->GetNbActiveBoards( uType ) ) - } // for( UInt_t uType = toftdc::caenV1290; uType < toftdc::NbTdcTypes; uType++ ) - - return kTRUE; -} -Bool_t TMbsCalibTdcTof::CheckAllTdcValid() -{ - // Loop over all TDC types - for( UInt_t uType = toftdc::caenV1290; uType < toftdc::NbTdcTypes; uType++ ) - { - for( UInt_t uTdc = 0; uTdc < fMbsUnpackPar->GetNbActiveBoards( uType ); uTdc ++) - { - // TDC type specific values - TClonesArray * xUnpDataArray = NULL; - switch( uType ) - { - case toftdc::caenV1290: - xUnpDataArray = fCaenBoardCollection; - break; - case toftdc::vftx: - xUnpDataArray = fVftxBoardCollection; - break; - case toftdc::trb: - xUnpDataArray = fTrb3BoardCollection; - break; - case toftdc::get4: - xUnpDataArray = fGet4BoardCollection; - break; - default: - break; - } // switch( uType ) - - if( NULL == xUnpDataArray ) - { - LOG(error)<<"TMbsCalibTdcTof::CheckAllTdcValid => Data pt failed Type "<<uType - <<" Active bd "<<fMbsUnpackPar->GetNbActiveBoards( uType ) - <<" Board "<<uTdc<<" Unp array "<<xUnpDataArray; - return kFALSE; - } - - // Board raw data recovery - TTofTdcBoard * xBoardUnpData = (TTofTdcBoard*) xUnpDataArray->At(uTdc); - - if( NULL == xBoardUnpData ) - { - fdBoardTriggerTime[uType][uTdc] = 0.0; - LOG(error)<<"TMbsCalibTdcTof::CheckAllTdcValid => Bd pt failed Type "<<uType - <<" Active bd "<<fMbsUnpackPar->GetNbActiveBoards( uType ) - <<" Board "<<uTdc; - return kFALSE; - } // if( NULL == xBoardUnpData ) - - if( kFALSE == xBoardUnpData->IsValid() ) - { - fdBoardTriggerTime[uType][uTdc] = 0.0; - LOG(debug)<<"TMbsCalibTdcTof::CheckAllTdcValid => Bd data invalid Type "<<uType - <<" Active bds "<<fMbsUnpackPar->GetNbActiveBoards( uType ) - <<" Board "<<uTdc; - return kFALSE; - } // if( kFALSE == xBoardUnpData->IsValid() ) - } // for( UInt_t uTdc = 0; uTdc < fMbsUnpackPar->GetNbActiveBoards( uType ); uTdc ++) - } // for( UInt_t uType = toftdc::caenV1290; uType < toftdc::NbTdcTypes; uType++ ) - return kTRUE; -} -Bool_t TMbsCalibTdcTof::ClearOutput() -{ - fCalibDataCollection->Clear("C"); - - for( UInt_t uType = toftdc::caenV1290; uType < toftdc::NbTdcTypes; uType++ ) - { - // TODO: for now only TRB has reference channel methods implemented - if( toftdc::caenV1290 == uType || - toftdc::vftx == uType || - toftdc::get4 == uType || - toftdc::undef == uType ) - continue; - - if( 0 < fMbsUnpackPar->GetNbActiveBoards( uType ) ) - fCalibRefCollection[uType]->Clear("C"); - } // for( UInt_t uType = toftdc::caenV1290; uType < toftdc::NbTdcTypes; uType++ ) - - return kTRUE; -} -void TMbsCalibTdcTof::SetSaveTdcs( Bool_t bSaveTdcs ) -{ - fbSaveCalibTdcs = bSaveTdcs; - if( kTRUE == bSaveTdcs ) { - LOG(info)<<"TMbsCalibTdcTof => Enable the saving of calibrated tdc data in analysis output file"; - } else { - LOG(info)<<"TMbsCalibTdcTof => Disable the saving of calibrated tdc data in analysis output file"; - } -} -// ------------------------------------------------------------------ -Bool_t TMbsCalibTdcTof::CreateHistogramms() -{ - TDirectory * oldir = gDirectory; // <= To prevent histos from being sucked in by the param file of the TRootManager! - gROOT->cd(); // <= To prevent histos from being sucked in by the param file of the TRootManager ! - - // Loop over all TDC types - for( UInt_t uType = toftdc::caenV1290; uType < toftdc::NbTdcTypes; uType++ ) - { - if( 0 < fMbsUnpackPar->GetNbActiveBoards( uType ) ) - { - UInt_t uNbChan = 0; - Double_t dClockCycle = 0.0; - UInt_t uFtBinNb = 0; - UInt_t uMaxMul = 0; - - switch( uType ) - { - case toftdc::caenV1290: - uNbChan = caentdc::kuNbChan; - dClockCycle = caentdc::kdClockCycleSize; - uFtBinNb = caentdc::kiFineTime + 1; - uMaxMul = toftdc::kuDefNbMulti; // TODO: add proper value for this type - break; - case toftdc::vftx: - uNbChan = vftxtdc::kuNbChan; - dClockCycle = vftxtdc::kdClockCycleSize; - uFtBinNb = vftxtdc::kiFifoFineTime + 1; - uMaxMul = vftxtdc::kuNbMulti; - break; - case toftdc::trb: - uNbChan = trbtdc::kuNbChan; - dClockCycle = trbtdc::kdClockCycleSize; - uFtBinNb = trbtdc::kiFineCounterSize; - uMaxMul = toftdc::kuDefNbMulti; // TODO: add proper value for this type - break; - case toftdc::get4: - uNbChan = get4tdc::kuNbChan; - dClockCycle = get4tdc::kdClockCycleSize; - uFtBinNb = get4tdc::kiFineTime + 1; - uMaxMul = toftdc::kuDefNbMulti; // TODO: add proper value for this type - if( 4 == fMbsCalibPar->GetTotMode( uType ) ) - uNbChan = get4v10::kuNbChan; - break; - default: - break; - } // switch( uType ) - - // Calibration variable initialization - fhDnlChan[uType].resize( fMbsUnpackPar->GetNbActiveBoards( uType ) * uNbChan, NULL ); - fhDnlSum[uType].resize( fMbsUnpackPar->GetNbActiveBoards( uType ) * uNbChan, NULL ); - fhBinSizeChan[uType].resize( fMbsUnpackPar->GetNbActiveBoards( uType ) * uNbChan, NULL ); - for( UInt_t uTdc = 0; uTdc < fMbsUnpackPar->GetNbActiveBoards( uType ); uTdc ++) - for( UInt_t uChanInd = 0; uChanInd< uNbChan; uChanInd++) - { - Int_t iHistoIndex = uTdc*uNbChan + uChanInd; - - // Current Dnl correction per bin - fhDnlChan[uType][iHistoIndex] = new TH1D( - Form("tof_%s_dnlch_b%03u_ch%03u", toftdc::ksTdcHistName[ uType ].Data(), - uTdc, uChanInd), - Form("Current Dnl factor for channel %3u in %s TDC #%03u", uChanInd, - toftdc::ksTdcHistName[ uType ].Data(), uTdc), - uFtBinNb, -0.5, uFtBinNb-0.5 ); - - // Current Dnl Sum per bin - fhDnlSum[uType][iHistoIndex] = new TH1D( - Form("tof_%s_dnlsum_b%03u_ch%03u", toftdc::ksTdcHistName[ uType ].Data(), - uTdc, uChanInd), - Form("Current Dnl Sum for channel %3u in %s TDC #%03u; Bin[]; ", uChanInd, - toftdc::ksTdcHistName[ uType ].Data(), uTdc), - uFtBinNb, -0.5, uFtBinNb-0.5 ); - - // Current Bin sizes from Dnl correction - fhBinSizeChan[uType][iHistoIndex] = new TH1D( - Form("tof_%s_binszch_b%03u_ch%03u", toftdc::ksTdcHistName[ uType ].Data(), - uTdc, uChanInd), - Form("Current Bin size from Dnl factor for channel %3u in %s TDC #%03u; Bin size [ps]; Bins []", - uChanInd, toftdc::ksTdcHistName[ uType ].Data(), uTdc), - (Int_t)(20*dClockCycle/uFtBinNb), -0.5, 20*dClockCycle/uFtBinNb -0.5 ); - } // for( UInt_t uChanInd = 0; uChanInd< uNbChan; uChanInd++) - - // Monitoring histograms - UInt_t uNbDataChan = uNbChan; - // If we are using the 1 input chan = 2 tdc chan tot mode, the number of channels in - // calibrated data is halved! - if( 2 == fMbsCalibPar->GetTotMode(uType) ) - uNbDataChan /= 2; - - if( kTRUE == fMbsCalibPar->IsTimeHistEna() ) - fhTimeToTrigg[uType].resize( fMbsUnpackPar->GetNbActiveBoards( uType ) * uNbDataChan, NULL ); - if( kTRUE == fMbsCalibPar->IsSingleTimeHistEna() ) - fhTimeToTriggSingles[uType].resize( fMbsUnpackPar->GetNbActiveBoards( uType ) * uNbDataChan, NULL ); - if( kTRUE == fMbsCalibPar->IsTotHistEna() && 0 < fMbsCalibPar->GetTotMode(uType) ) - fhToT[uType].resize( fMbsUnpackPar->GetNbActiveBoards( uType ) * uNbDataChan, NULL ); - if( kTRUE == fMbsCalibPar->IsMultiDistHistEna() ) - fhMultiDist[uType].resize( fMbsUnpackPar->GetNbActiveBoards( uType ) * uNbDataChan, NULL ); - - fhMultiplicity[uType].resize( fMbsUnpackPar->GetNbActiveBoards( uType ), NULL ); - - for( UInt_t uTdc = 0; uTdc < fMbsUnpackPar->GetNbActiveBoards( uType ); uTdc ++) - { - for( UInt_t uChanInd = 0; uChanInd< uNbDataChan; uChanInd++) - { - Int_t iHistoIndex = uTdc*uNbDataChan + uChanInd; - - // Time to board trigger in ps - if( kTRUE == fMbsCalibPar->IsTimeHistEna() ) - fhTimeToTrigg[uType][iHistoIndex] = new TH1I( - Form("tof_%s_t2trig_b%03u_ch%03u", toftdc::ksTdcHistName[ uType ].Data(), - uTdc, uChanInd), - Form("Time to board trigger for channel %3u in %s TDC #%03u; Trigger time - Calibrated Time [ps]", - uChanInd, toftdc::ksTdcHistName[ uType ].Data(), uTdc), - 11000, -2000000.0, 200000.0 ); -// 8000, -700000.0, 100000.0 ); - // Time to board trigger in ps for events with a single hit in the channel - if( kTRUE == fMbsCalibPar->IsSingleTimeHistEna() ) - fhTimeToTriggSingles[uType][iHistoIndex] = new TH1I( - Form("tof_%s_t2trig_sing_b%03u_ch%03u", toftdc::ksTdcHistName[ uType ].Data(), - uTdc, uChanInd), - Form("Time to board trigger for events with a single hit for channel %3u in %s TDC #%03u; Trigger time - Calibrated Time [ps]", - uChanInd, toftdc::ksTdcHistName[ uType ].Data(), uTdc), - 8000, -700000.0, 100000.0 ); - // Tot in ps - if( kTRUE == fMbsCalibPar->IsTotHistEna() && 0 < fMbsCalibPar->GetTotMode(uType) ) - fhToT[uType][iHistoIndex] = new TH1I( - Form("tof_%s_tot_b%03u_ch%03u", toftdc::ksTdcHistName[ uType ].Data(), - uTdc, uChanInd), - Form("Time over threshold for channel %3d in %s TDC #%03u; ToT [ps]", - uChanInd, toftdc::ksTdcHistName[ uType ].Data(), uTdc), - 30000, -150000, 150000 ); - - // Distance between consecutive multiple hits on same channel in ps - if( kTRUE == fMbsCalibPar->IsMultiDistHistEna() ) - fhMultiDist[uType][iHistoIndex] = new TH2I( - Form("tof_%s_muldist_b%03u_ch%03u", toftdc::ksTdcHistName[ uType ].Data(), - uTdc, uChanInd), - Form("Time to previous hit for multiple hits for channel %3u in %s TDC #%03u; T(n) - T(n-1) [ps]; n (Multiple hits index) []", - uChanInd, toftdc::ksTdcHistName[ uType ].Data(), uTdc), - 7500, -50000, 100000, - vftxtdc::kuNbMulti, 1, vftxtdc::kuNbMulti + 1 ); - // TODO: why VFTX values here? - } // for( UInt_t uChanInd = 0; uChanInd< uNbChan; uChanInd++) - - //Multiplicity - fhMultiplicity[uType][uTdc] = new TH2I( - Form("tof_%s_mul_b%03u", toftdc::ksTdcHistName[ uType ].Data(), uTdc), - Form("Data multiplicty per channel in %s TDC #%03u; Channel []; Multiplicity []", - toftdc::ksTdcHistName[ uType ].Data(), uTdc), - uNbDataChan, 0.0, uNbDataChan, - uMaxMul + 1, 0, uMaxMul + 1 ); - } // for( UInt_t uTdc = 0; uTdc < fMbsUnpackPar->GetNbActiveBoards( uType ); uTdc ++) - } // if( 0 < fMbsUnpackPar->GetNbActiveBoards( uType ) ) - } // for( UInt_t uType = toftdc::caenV1290; uType < toftdc::NbTdcTypes; uType++ ) - -// if( kTRUE == fMbsCalibPar->IsTdcOffsetEna() ) -// { - if( kFALSE == CreateReferenceHistogramms() ) - { - gDirectory->cd( oldir->GetPath() ); // <= To prevent histos from being sucked in by the param file of the TRootManager! - return kFALSE; - } -// } // if( kTRUE == fMbsCalibPar->IsTdcOffsetEna() ) - - gDirectory->cd( oldir->GetPath() ); // <= To prevent histos from being sucked in by the param file of the TRootManager! - - return kTRUE; -} -Bool_t TMbsCalibTdcTof::FillHistograms() -{ - TTofCalibData * fCalibData; - - // Use only events with no corrupt data - if( kFALSE == CheckAllTdcValid() ) - return kFALSE; - - LOG(debug)<<"TMbsCalibTdcTof::FillHistograms => "<<fCalibDataCollection->GetEntriesFast() - <<" data unpacked & calibrated successfully in this event!"; - - if( kTRUE == fbTdcRefMoniMode ) - { - // If TDC Ref channel monitoring mode, calibrate and - // fill histos only for reference channel - if( kFALSE == FillReferenceHistograms() ) - return kFALSE; - else return kTRUE; - } // if( kTRUE == fbTdcRefMoniMode ) - - UInt_t uNbChan[ toftdc::NbTdcTypes]; - uNbChan[ toftdc::undef ] = 0; - uNbChan[ toftdc::caenV1290 ] = caentdc::kuNbChan; - uNbChan[ toftdc::vftx ] = vftxtdc::kuNbChan; - uNbChan[ toftdc::trb ] = trbtdc::kuNbChan; - uNbChan[ toftdc::get4 ] = get4tdc::kuNbChan; - if( 4 == fMbsCalibPar->GetTotMode( toftdc::get4 ) ) - uNbChan[ toftdc::get4 ] = get4v10::kuNbChan; - - std::vector< UInt_t > uMul[ toftdc::NbTdcTypes ]; - std::vector< Double_t > dLastTime[ toftdc::NbTdcTypes ]; - - // If we are using the 1 input chan = 2 tdc chan tot mode, the number of channels in - // calibrated data is halved! - for( UInt_t uType = toftdc::caenV1290; uType < toftdc::NbTdcTypes; uType++ ) - { - if( 2 == fMbsCalibPar->GetTotMode(uType) ) - uNbChan[ uType ] /= 2; - uMul[ uType ].resize( fMbsUnpackPar->GetNbActiveBoards( uType ) * uNbChan[uType] ); - dLastTime[ uType ].resize( fMbsUnpackPar->GetNbActiveBoards( uType ) * uNbChan[uType] ); - } - - // loop over Calibrated Data - for( Int_t iDataIndex = 0; iDataIndex < fCalibDataCollection->GetEntriesFast() ; iDataIndex++ ) - { - fCalibData = (TTofCalibData *)fCalibDataCollection->At( iDataIndex ); - - // Monitoring histograms - UInt_t uType = fCalibData->GetType(); - UInt_t uTdc = fCalibData->GetBoard(); - UInt_t uChan = fCalibData->GetChannel(); - Double_t dTime = fCalibData->GetTime(); - Double_t dTot = fCalibData->GetTot(); - - Int_t iHistoIndex = uTdc*uNbChan[uType] + uChan; - - // Time to board trigger in ps - if( kTRUE == fMbsCalibPar->IsTimeHistEna() ) - fhTimeToTrigg[uType][iHistoIndex]->Fill( dTime - fdBoardTriggerTime[uType][uTdc] ); - // Tot in ps - if( kTRUE == fMbsCalibPar->IsTotHistEna() ) - fhToT[uType][iHistoIndex]->Fill( dTot ); - // Distance between consecutive multiple hits on same channel in ps - if( kTRUE == fMbsCalibPar->IsMultiDistHistEna() && 0 < uMul[ uType ][ iHistoIndex ] ) - fhMultiDist[uType][iHistoIndex]->Fill( dTime - dLastTime[ uType ][ iHistoIndex ], uMul[ uType ][ iHistoIndex ] ); - - // Multi hits data - uMul[ uType ][ iHistoIndex ]++; - dLastTime[ uType ][ iHistoIndex ] = dTime; - - TString sTemp = Form( "TMbsCalibTdcTof::FillHistos: Data #%04d Type %s Board #%03d Chan %3d Time %7.0f Tot %7.0f Edge %1d", - iDataIndex, - toftdc::ksTdcHistName[ fCalibData->GetType() ].Data(), -// "Missing", - fCalibData->GetBoard(), fCalibData->GetChannel(), fCalibData->GetTime(), - fCalibData->GetTot(), fCalibData->GetEdge() ); - LOG(debug)<<sTemp; - } // for( Int_t iDataIndex = 0; iDataIndex < fVftxBoard[iBoardIndex]->GetDataNb() ; iDataIndex++ ) - - // Time to board trigger in ps for events with a single hit in the channel - for( UInt_t uType = toftdc::caenV1290; uType < toftdc::NbTdcTypes; uType++ ) - for( UInt_t uTdc = 0; uTdc < fMbsUnpackPar->GetNbActiveBoards( uType ); uTdc ++) - { - TString sTemp = Form( "TMbsCalibTdcTof::FillHistos: %s Board #%03u Trigger Time %7.0f ", - toftdc::ksTdcHistName[ uType ].Data(), uTdc, fdBoardTriggerTime[uType][uTdc] ); - LOG(debug)<<sTemp; - for( UInt_t uChanInd = 0; uChanInd< uNbChan[uType]; uChanInd++) - { - fhMultiplicity[uType][uTdc]->Fill(uChanInd, uMul[uType][ uTdc*uNbChan[uType] + uChanInd ] ); - if( 1 == uMul[uType][ uTdc*uNbChan[uType] + uChanInd ] && - kTRUE == fMbsCalibPar->IsSingleTimeHistEna() ) - { - Int_t iHistoIndex = uTdc*uNbChan[uType] + uChanInd; - fhTimeToTriggSingles[uType][iHistoIndex]->Fill( dLastTime[uType][iHistoIndex] - - fdBoardTriggerTime[uType][uTdc] ); - } // if( 1 == uMul[uType][ uTdc*uNbChan[uType] + uChanInd ] ) - } // for( UInt_t uChanInd = 0; uChanInd< uNbChan[uType]; uChanInd++) - } // for( UInt_t uTdc = 0; uTdc < fMbsUnpackPar->GetNbActiveBoards( uType ); uTdc ++) - - -// if( kTRUE == fMbsCalibPar->IsTdcOffsetEna() ) -// { - if( kFALSE == FillReferenceHistograms() ) - return kFALSE; -// } // if( kTRUE == fMbsCalibPar->IsTdcOffsetEna() ) - - return kTRUE; -} -Bool_t TMbsCalibTdcTof::WriteHistogramms( TDirectory* inDir) -{ - TDirectory * oldir = gDirectory; - - for( UInt_t uType = toftdc::caenV1290; uType < toftdc::NbTdcTypes; uType++ ) - if( 0 < fMbsUnpackPar->GetNbActiveBoards( uType ) ) - { - UInt_t uNbChan = 0; - - switch( uType ) - { - case toftdc::caenV1290: - uNbChan = caentdc::kuNbChan; - break; - case toftdc::vftx: - uNbChan = vftxtdc::kuNbChan; - break; - case toftdc::trb: - uNbChan = trbtdc::kuNbChan; - break; - case toftdc::get4: - uNbChan = get4tdc::kuNbChan; - if( 4 == fMbsCalibPar->GetTotMode( uType ) ) - uNbChan = get4v10::kuNbChan; - break; - default: - break; - } // switch( uType ) - - // create a subdirectory "Cal_type" in this file - TDirectory *cdCal = inDir->mkdir( Form( "Cal_%s", toftdc::ksTdcHistName[ uType ].Data() ) ); - cdCal->cd(); // make the "Cal_type" directory the current directory - TDirectory *cdCalTdc[ fMbsUnpackPar->GetNbActiveBoards( uType ) ]; - TDirectory *cdCalTdcHist[ fMbsUnpackPar->GetNbActiveBoards( uType ) ][3]; - - // loop over active TDCs - for( UInt_t uTdc = 0; uTdc < fMbsUnpackPar->GetNbActiveBoards( uType ); uTdc ++) - { - // Create a sub folder for each TDC - cdCalTdc[uTdc] = cdCal->mkdir( Form( "cTdc%03u", uTdc) ); - cdCalTdc[uTdc]->cd(); - - // Create a sub folder for each histogram type - cdCalTdcHist[uTdc][0] = cdCalTdc[uTdc]->mkdir( Form( "dnl%03u", uTdc) ); - cdCalTdcHist[uTdc][1] = cdCalTdc[uTdc]->mkdir( Form( "dnlSum%03u", uTdc) ); - cdCalTdcHist[uTdc][2] = cdCalTdc[uTdc]->mkdir( Form( "binSz%03u", uTdc) ); - - // Loop over all TDC channels - for( UInt_t uChanInd = 0; uChanInd< uNbChan; uChanInd++) - { - Int_t iHistoIndex = uTdc*uNbChan + uChanInd; - - // Current Dnl correction per bin - cdCalTdcHist[uTdc][0]->cd(); - fhDnlChan[uType][iHistoIndex]->Write(); - - // Current Dnl Sum per bin - cdCalTdcHist[uTdc][1]->cd(); - fhDnlSum[uType][iHistoIndex]->Write(); - - // Current Bin sizes from Dnl correction - cdCalTdcHist[uTdc][2]->cd(); - fhBinSizeChan[uType][iHistoIndex]->Write(); - } // for( UInt_t uChanInd = 0; uChanInd< uNbChan; uChanInd++) - } // for( UInt_t uTdc = 0; uTdc < fMbsUnpackPar->GetNbActiveBoards( uType ); uTdc ++) - - // Monitoring histograms - UInt_t uNbDataChan = uNbChan; - // If we are using the 1 input chan = 2 tdc chan tot mode, the number of channels in - // calibrated data is halved! - if( 2 == fMbsCalibPar->GetTotMode(uType) ) - uNbDataChan /= 2; - - // create a subdirectory "Mon_Type" in this file - TDirectory *cdMon = inDir->mkdir( Form( "Mon_%s", toftdc::ksTdcHistName[ uType ].Data() ) ); - cdMon->cd(); // make the "Mon_type" directory the current directory - TDirectory *cdMonTdc[ fMbsUnpackPar->GetNbActiveBoards( uType ) ]; - TDirectory *cdMonTdcHist[ fMbsUnpackPar->GetNbActiveBoards( uType ) ][4]; - - // loop over active TDCs - for( UInt_t uTdc = 0; uTdc < fMbsUnpackPar->GetNbActiveBoards( uType ); uTdc ++) - { - // Create a sub folder for each TDC - cdMonTdc[uTdc] = cdMon->mkdir( Form( "mTdc%03u", uTdc) ); - cdMonTdc[uTdc]->cd(); - - fhMultiplicity[uType][uTdc]->Write(); - - // Create a sub folder for each histogram type - if( kTRUE == fMbsCalibPar->IsTimeHistEna() ) - cdMonTdcHist[uTdc][0] = cdMonTdc[uTdc]->mkdir( Form( "t2trig%03u", uTdc) ); - if( kTRUE == fMbsCalibPar->IsSingleTimeHistEna() ) - cdMonTdcHist[uTdc][1] = cdMonTdc[uTdc]->mkdir( Form( "t2trig_sing%03u", uTdc) ); - if( kTRUE == fMbsCalibPar->IsTotHistEna() ) - cdMonTdcHist[uTdc][2] = cdMonTdc[uTdc]->mkdir( Form( "tot%03u", uTdc) ); - if( kTRUE == fMbsCalibPar->IsMultiDistHistEna() ) - cdMonTdcHist[uTdc][3] = cdMonTdc[uTdc]->mkdir( Form( "mulDist%03u", uTdc) ); - - // Loop over all input channels - for( UInt_t uChanInd = 0; uChanInd< uNbDataChan; uChanInd++) - { - Int_t iHistoIndex = uTdc*uNbDataChan + uChanInd; - - if( kTRUE == fMbsCalibPar->IsTimeHistEna() ) - { - cdMonTdcHist[uTdc][0]->cd(); - fhTimeToTrigg[uType][iHistoIndex]->Write(); - } // if( kTRUE == fMbsCalibPar->IsTimeHistEna() ) - - if( kTRUE == fMbsCalibPar->IsSingleTimeHistEna() ) - { - cdMonTdcHist[uTdc][1]->cd(); - fhTimeToTriggSingles[uType][iHistoIndex]->Write(); - } // if( kTRUE == fMbsCalibPar->IsSingleTimeHistEna() ) - - if( kTRUE == fMbsCalibPar->IsTotHistEna() ) - { - cdMonTdcHist[uTdc][2]->cd(); - fhToT[uType][iHistoIndex]->Write(); - } // if( kTRUE == fMbsCalibPar->IsTotHistEna() ) - - if( kTRUE == fMbsCalibPar->IsMultiDistHistEna() ) - { - cdMonTdcHist[uTdc][3]->cd(); - fhMultiDist[uType][iHistoIndex]->Write(); - } // if( kTRUE == fMbsCalibPar->IsMultiDistHistEna() ) - } // for( UInt_t uChanInd = 0; uChanInd< uNbDataChan[uType]; uChanInd++) - } // for( UInt_t uTdc = 0; uTdc < fMbsUnpackPar->GetNbActiveBoards( uType ); uTdc ++) - } // if( 0 < fMbsUnpackPar->GetNbActiveBoards( uType ) ) - - // if( kTRUE == fMbsCalibPar->IsTdcOffsetEna() ) - // { - if( kFALSE == WriteReferenceHistogramms( inDir ) ) - return kFALSE; -// } // if( kTRUE == fMbsCalibPar->IsTdcOffsetEna() ) - - gDirectory->cd( oldir->GetPath() ); - - return kTRUE; -} -Bool_t TMbsCalibTdcTof::DeleteHistograms() -{ -// if( kTRUE == fMbsCalibPar->IsTdcOffsetEna() ) -// { - if( kFALSE == DeleteReferenceHistograms( ) ) - return kFALSE; -// } // if( kTRUE == fMbsCalibPar->IsTdcOffsetEna() ) - - return kTRUE; -} -// ------------------------------------------------------------------ -Bool_t TMbsCalibTdcTof::InitCalibration() -{ - // Loop over all TDC types - for( UInt_t uType = toftdc::caenV1290; uType < toftdc::NbTdcTypes; uType++ ) - { - if( 0 < fMbsUnpackPar->GetNbActiveBoards( uType ) ) - { - UInt_t uNbChan = 0; - UInt_t uFtBinNb = 0; - Int_t iFtLinCalMin = 0; - Int_t iFtLinCalMax = 0; - - switch( uType ) - { - case toftdc::caenV1290: - uNbChan = caentdc::kuNbChan; - uFtBinNb = caentdc::kiFineTime + 1; - break; - case toftdc::vftx: - uNbChan = vftxtdc::kuNbChan; - uFtBinNb = vftxtdc::kiFifoFineTime + 1; - break; - case toftdc::trb: - uNbChan = trbtdc::kuNbChan; - uFtBinNb = trbtdc::kiFineCounterSize; - iFtLinCalMin = trbtdc::kuSimpleFineTimeMinValue; - iFtLinCalMax = trbtdc::kuSimpleFineTimeMinValue; - break; - case toftdc::get4: - uNbChan = get4tdc::kuNbChan; - uFtBinNb = get4tdc::kiFineTime + 1; - if( 4 == fMbsCalibPar->GetTotMode( uType ) ) - uNbChan = get4v10::kuNbChan; - break; - default: - break; - } // switch( uType ) - - // Calibration variable initialization - fiNbHitsForCalib[uType].resize( fMbsUnpackPar->GetNbActiveBoards( uType ) * uNbChan, 0 ); - fbCalibAvailable[uType].resize( fMbsUnpackPar->GetNbActiveBoards( uType ) * uNbChan, kFALSE ); - fdCorr[uType].resize( fMbsUnpackPar->GetNbActiveBoards( uType ) * uNbChan ); - fdBoardTriggerTime[uType].resize( fMbsUnpackPar->GetNbActiveBoards( uType ), 0.0 ); - - // TDC offsets variables calibration - fhInitialCalibHistoRef[uType].resize( fMbsUnpackPar->GetNbActiveBoards( uType ), 0 ); - fiLinCalRefMinBin[uType].resize( fMbsUnpackPar->GetNbActiveBoards( uType ), iFtLinCalMin ); - fiLinCalRefMaxBin[uType].resize( fMbsUnpackPar->GetNbActiveBoards( uType ), iFtLinCalMax ); - fdCorrRef[uType].resize( fMbsUnpackPar->GetNbActiveBoards( uType ) ); - fdTdcReference[uType].resize( fMbsUnpackPar->GetNbActiveBoards( uType ), 0.0 ); - fdTdcOffsets[uType].resize( fMbsUnpackPar->GetNbActiveBoards( uType ), 0.0 ); - - fbFirstEventPassedRef[uType] = kFALSE; - fdTdcReferenceFirstEvent[uType].resize( fMbsUnpackPar->GetNbActiveBoards( uType ), 0.0 ); - - // loop over all active TDC & all channels - for( UInt_t uTdc = 0; uTdc < fMbsUnpackPar->GetNbActiveBoards( uType ); uTdc ++) - { - for( UInt_t uChanInd = 0; uChanInd< uNbChan; uChanInd++) - { - Int_t iHistoIndex = uTdc*uNbChan + uChanInd; - fdCorr[uType][iHistoIndex].resize(uFtBinNb, 0.0); - } // for( UInt_t uChanInd = 0; uChanInd< uNbChan; uChanInd++) - - fdCorrRef[uType][uTdc].resize( uFtBinNb, 0.0 ); - } // for( UInt_t uTdc = 0; uTdc < fMbsUnpackPar->GetNbActiveBoards( uType ); uTdc ++) - } // if( 0 < fMbsUnpackPar->GetNbActiveBoards( uType ) ) - } // for( UInt_t uType = toftdc::caenV1290; uType < toftdc::NbTdcTypes; uType++ ) - - if( kTRUE == fMbsCalibPar->EnaSingleCalib() ) - LoadSingleCalibrations(); - else LoadCalibrationFile(); - - return kTRUE; -} -Bool_t TMbsCalibTdcTof::GetHistosFromUnpack() -{ - TDirectory * oldir = gDirectory; // <= To prevent histos from being sucked in by the param file of the TRootManager! - gROOT->cd(); // <= To prevent histos from being sucked in by the param file of the TRootManager ! - - // Loop over all TDC types - for( UInt_t uType = toftdc::caenV1290; uType < toftdc::NbTdcTypes; uType++ ) - { - if( 0 < fMbsUnpackPar->GetNbActiveBoards( uType ) ) - { - UInt_t uNbChan = 0; - - switch( uType ) - { - case toftdc::caenV1290: - uNbChan = caentdc::kuNbChan; - break; - case toftdc::vftx: - uNbChan = vftxtdc::kuNbChan; - break; - case toftdc::trb: - uNbChan = trbtdc::kuNbChan; - break; - case toftdc::get4: - uNbChan = get4tdc::kuNbChan; - if( 4 == fMbsCalibPar->GetTotMode( uType ) ) - uNbChan = get4v10::kuNbChan; - break; - default: - break; - } // switch( uType ) - - fhFineTime[uType].resize( fMbsUnpackPar->GetNbActiveBoards( uType ) * uNbChan ); - - TString sInfoLoading = "Got FineTime histograms from unpack step for following "+ - toftdc::ksTdcHistName[ uType ] + " TDC channels:"; - LOG(info)<<sInfoLoading; - - sInfoLoading = " "; - for( UInt_t uChanInd = 0; uChanInd< uNbChan; uChanInd++) - sInfoLoading += Form("%3u ", uChanInd); - LOG(info)<<sInfoLoading; - - // Loop over all active TDCs and all channels - for( UInt_t uTdc = 0; uTdc < fMbsUnpackPar->GetNbActiveBoards( uType ); uTdc ++) - { - sInfoLoading = Form("tdc #%3u: ",uTdc ); - for( UInt_t uChanInd = 0; uChanInd< uNbChan; uChanInd++) - { - Int_t iHistoIndex = uTdc*uNbChan + uChanInd; -// gDirectory->GetObject( Form("tof_%s_ft_b%03d_ch%03d", toftdc::ksTdcHistName[ uType ].Data(), -// uTdc, uChanInd), -// fhFineTime[uType][iHistoIndex]); - - if( 0 == fMbsCalibPar->GetMinHitCalib() ) - if( NULL != fhInitialCalibHisto[uType][iHistoIndex] ) - { - // Only initial calibration should be used and the calibration histogram was found - // => no need to access unpack histogram! - fhFineTime[uType][iHistoIndex] = NULL; - sInfoLoading += " - "; - continue; - } // if( NULL != fhInitialCalibHisto[uType][iHistoIndex] ) - - fhFineTime[uType][iHistoIndex] = (TH1*) gDirectory->FindObject( Form("tof_%s_ft_b%03u_ch%03u", toftdc::ksTdcHistName[ uType ].Data(), - uTdc, uChanInd)); - if( NULL == fhFineTime[uType][iHistoIndex] ) - { - LOG(error)<<" TMbsCalibTdcTof::GetHistosFromUnpack => Could not get FT histo for " - <<toftdc::ksTdcHistName[ uType ]<<" #" - <<uTdc<<" ch "<<uChanInd<<" from the unpack step"; - sInfoLoading += " 0 "; - LOG(info)<<sInfoLoading; - - gDirectory->cd( oldir->GetPath() ); // <= To prevent histos from being sucked in by the param file of the TRootManager! - return kFALSE; - } // if( NULL == fhFineTime[uType][iHistoIndex] ) - else LOG(debug)<<" TMbsCalibTdcTof::GetHistosFromUnpack =>Got FT histo for " - <<toftdc::ksTdcHistName[ uType ]<<" #" - <<uTdc<<" ch "<<uChanInd<<" from the unpack step: 0x" - <<fhFineTime[uType][iHistoIndex]<<" " - <<fhFineTime[uType][iHistoIndex]->GetEntries(); - sInfoLoading += " 1 "; - } // for( UInt_t uChanInd = 0; uChanInd< uNbChan; uChanInd++) - LOG(info)<<sInfoLoading; - } // for( UInt_t uTdc = 0; uTdc < fMbsUnpackPar->GetNbActiveBoards( uType ); uTdc ++) - } // if( 0 < fMbsUnpackPar->GetNbActiveBoards( uType ) ) - else LOG(info)<<" TMbsCalibTdcTof::GetHistosFromUnpack => no boards for "<<toftdc::ksTdcHistName[ uType ]; - } // for( UInt_t uType = toftdc::caenV1290; uType < toftdc::NbTdcTypes; uType++ ) - - gDirectory->cd( oldir->GetPath() ); // <= To prevent histos from being sucked in by the param file of the TRootManager! - - return kTRUE; -} -Bool_t TMbsCalibTdcTof::LoadCalibrationFile() -{ - // First check if the inital calibration file name is properly defined - if( kTRUE != fMbsCalibPar->GetInitCalFilename().EqualTo("") && - kTRUE != fMbsCalibPar->GetInitCalFilename().EqualTo("-") ) - { - // Save online ROOT directory as the File opening auto change current Dir - oldDir = gDirectory; - - TString sInitialCalibHistoName = ""; - fileCalibrationIn = new TFile( fMbsCalibPar->GetInitCalFilename(), "READ"); - - if( kTRUE == fileCalibrationIn->IsOpen() ) - { - // Loop over all TDC types - for( UInt_t uType = toftdc::caenV1290; uType < toftdc::NbTdcTypes; uType++ ) - { - if( 0 == fMbsCalibPar->GetNbCalibBoards( uType ) || - 0 == fMbsUnpackPar->GetNbActiveBoards( uType ) ) - continue; - - UInt_t uNbChan = 0; - UInt_t uFtBinNb = 0; - - switch( uType ) - { - case toftdc::caenV1290: - uNbChan = caentdc::kuNbChan; - uFtBinNb = caentdc::kiFineTime + 1; - break; - case toftdc::vftx: - uNbChan = vftxtdc::kuNbChan; - uFtBinNb = vftxtdc::kiFifoFineTime + 1; - break; - case toftdc::trb: - uNbChan = trbtdc::kuNbChan; - uFtBinNb = trbtdc::kiFineCounterSize; - break; - case toftdc::get4: - uNbChan = get4tdc::kuNbChan; - uFtBinNb = get4tdc::kiFineTime + 1; - if( 4 == fMbsCalibPar->GetTotMode( uType ) ) - uNbChan = get4v10::kuNbChan; - break; - default: - break; - } // switch( uType ) - if( 0 == uNbChan || 1 == uFtBinNb ) - { - LOG(info)<<"TMbsCalibTdcTof::LoadCalibrationFile Undefined tdc parameters for type " - <<toftdc::ksTdcHistName[ uType ]; - LOG(info)<<" => No initial calib loading!"; - continue; - } - // TODO: Does not handle the TRB case! - // One could replace trbtdc::kiFineCounterSize everywhere by trbtdc::time_FineTimeBitMask + 1 - // to handle this case like every other TDC - - TString sInfoLoading = "Loaded initial calibration histograms for following "+ - toftdc::ksTdcHistName[ uType ] + " TDC channels:"; - LOG(info)<<sInfoLoading; - - sInfoLoading = " "; - for( UInt_t uChanInd = 0; uChanInd< uNbChan; uChanInd++) - sInfoLoading += Form("%3u ", uChanInd); - LOG(info)<<sInfoLoading; - - //define correction variables - fhInitialCalibHisto[ uType ].resize( fMbsCalibPar->GetNbCalibBoards( uType ) * - uNbChan, NULL ); -/* Bool_t bincontrol[uFtBinNb];*/ // Commented out to remove warning bec. unused -/* Int_t iSum[fMbsCalibPar->GetNbCalibBoards( uType )][uNbChan];*/ // Commented out to remove warning bec. unused - - // Temp variable to store pointer on calib histo in File - TH1* fInitialCalibHistoFromFile = 0; - - for( UInt_t uTdc = 0; uTdc < fMbsUnpackPar->GetNbActiveBoards( uType ); uTdc ++) - { - if( -1 < fMbsCalibPar->GetInitialCalInd( uType, uTdc ) ) - { - sInfoLoading = Form("tdc #%3u: ",uTdc ); - for( UInt_t uChanInd = 0; uChanInd< uNbChan; uChanInd++) - { - Int_t iHistoIndex = uTdc*uNbChan + uChanInd; - - // Initialize pointer to NULL - fInitialCalibHistoFromFile = NULL; - - // Find histogram in file and store its pointer in a temp variable - sInitialCalibHistoName = Form("tof_%s_ft_b%03u_ch%03u", toftdc::ksTdcHistName[ uType ].Data(), - fMbsCalibPar->GetInitialCalInd( uType, uTdc ), uChanInd ); - - fileCalibrationIn->GetObject( sInitialCalibHistoName, fInitialCalibHistoFromFile); - - if( NULL == fInitialCalibHistoFromFile ) - sInfoLoading += " 0 "; - else - { - sInfoLoading += " 1 "; - // Clone the found histo and move it to online ROOT directory instead of File - fhInitialCalibHisto[ uType ][ iHistoIndex ] = (TH1*)fInitialCalibHistoFromFile->Clone( - Form("%s_CalibFile", sInitialCalibHistoName.Data() ) ); - fhInitialCalibHisto[ uType ][ iHistoIndex ]->SetDirectory( oldDir ); - } // else of if( 0 == fInitialCalibHistoFromFile ) - - // Extract calibration factors from initialization histo - CalibFactorsInit( uType, uTdc, uChanInd ); - } // for( UInt_t uChanInd = 0; uChanInd< uNbChan; uChanInd++) - LOG(info)<<sInfoLoading; - } // if( -1 < fMbsCalibPar->GetInitialCalInd( uType, uTdc ) ) - } // for( UInt_t uTdc = 0; uTdc < fMbsUnpackPar->GetNbActiveBoards( uType ); uTdc ++) - } // for( UInt_t uType = toftdc::caenV1290; uType < toftdc::NbTdcTypes; uType++ ) - - // File closing and going back to online ROOT folder - fileCalibrationIn->Close(); - gDirectory->Cd(oldDir->GetPath()); - } // if( kTRUE == fileCalibrationIn->IsOpen() ) - else - { - LOG(info)<<"Could not open "<<fMbsCalibPar->GetInitCalFilename() - <<" to load initial TDC calibration, please check setting in Calibration option file"; - for( UInt_t uType = toftdc::caenV1290; uType < toftdc::NbTdcTypes; uType++ ) - if( 0 == fMbsCalibPar->GetNbCalibBoards( uType ) || - 0 == fMbsUnpackPar->GetNbActiveBoards( uType ) ) - continue; - else - { - UInt_t uNbChan = 0; - - switch( uType ) - { - case toftdc::caenV1290: - uNbChan = caentdc::kuNbChan; - break; - case toftdc::vftx: - uNbChan = vftxtdc::kuNbChan; - break; - case toftdc::trb: - uNbChan = trbtdc::kuNbChan; - break; - case toftdc::get4: - uNbChan = get4tdc::kuNbChan; - break; - default: - break; - } // switch( uType ) - if( 0 == uNbChan ) - { - LOG(info)<<"TMbsCalibTdcTof::LoadCalibrationFile Undefined tdc parameters for type " - <<toftdc::ksTdcHistName[ uType ]; - LOG(info)<<" => No initial calib loading!"; - continue; - } - fhInitialCalibHisto[ uType ].resize( fMbsCalibPar->GetNbCalibBoards( uType ) * - uNbChan, NULL ); - } - return kFALSE; - } // else of if( kTRUE == fileCalibrationIn->IsOpen() ) - } // if( sInitialCalibrationFilename OK and 1 == fMbsCalibPar->uEnableCalib) - - -// if( kTRUE == fMbsCalibPar->IsTdcOffsetEna() ) -// { - if( kFALSE == LoadCalibrationFileRef( ) ) - return kFALSE; -// } // if( kTRUE == fMbsCalibPar->IsTdcOffsetEna() ) - - return kTRUE; -} -Bool_t TMbsCalibTdcTof::LoadSingleCalibrations() -{ - for( UInt_t uType = toftdc::caenV1290; uType < toftdc::NbTdcTypes; uType++ ) - { - if( 0 == fMbsCalibPar->GetNbCalibBoards( uType ) || - 0 == fMbsUnpackPar->GetNbActiveBoards( uType ) ) - continue; - - UInt_t uNbChan = 0; - UInt_t uFtBinNb = 0; - - switch( uType ) - { - case toftdc::caenV1290: - uNbChan = caentdc::kuNbChan; - uFtBinNb = caentdc::kiFineTime + 1; - break; - case toftdc::vftx: - uNbChan = vftxtdc::kuNbChan; - uFtBinNb = vftxtdc::kiFifoFineTime + 1; - break; - case toftdc::trb: - uNbChan = trbtdc::kuNbChan; - uFtBinNb = trbtdc::kiFineCounterSize; - break; - case toftdc::get4: - uNbChan = get4tdc::kuNbChan; - uFtBinNb = get4tdc::kiFineTime + 1; - if( 4 == fMbsCalibPar->GetTotMode( uType ) ) - uNbChan = get4v10::kuNbChan; - break; - default: - break; - } // switch( uType ) - if( 0 == uNbChan || 1 == uFtBinNb ) - { - LOG(info)<<"TMbsCalibTdcTof::LoadSingleCalibrations Undefined tdc parameters for type " - <<toftdc::ksTdcHistName[ uType ];; - LOG(info)<<" => No initial calib loading!"; - continue; - } - // TODO: Does not handle the TRB case! - // One could replace trbtdc::kiFineCounterSize everywhere by trbtdc::time_FineTimeBitMask + 1 - // to handle this case like every other TDC - - TString sInfoLoading = "Loaded initial calibration histograms for following "+ - toftdc::ksTdcHistName[ uType ] + " TDC channels:"; - LOG(info)<<sInfoLoading; - - sInfoLoading = " "; - for( UInt_t uChanInd = 0; uChanInd< uNbChan; uChanInd++) - sInfoLoading += Form("%3u ", uChanInd); - LOG(info)<<sInfoLoading; - - //define correction variables - fhInitialCalibHisto[ uType ].resize( fMbsCalibPar->GetNbCalibBoards( uType ) * - uNbChan, NULL ); -/* Bool_t bincontrol[uFtBinNb];*/ // Commented out to remove warning bec. unused -/* Int_t iSum[fMbsCalibPar->GetNbCalibBoards( uType )][uNbChan];*/ // Commented out to remove warning bec. unused - - // Save online ROOT directory as the File opening auto change current Dir - oldDir = gDirectory; - - for( UInt_t uTdc = 0; uTdc < fMbsUnpackPar->GetNbActiveBoards( uType ); uTdc ++) - if( -1 < fMbsCalibPar->GetInitialCalInd( uType, uTdc ) ) - { - sInfoLoading = Form("tdc #%3u: ",uTdc ); - for( UInt_t uChanInd = 0; uChanInd< uNbChan; uChanInd++) - { - TString sInitialCalibFileName = Form("./calib/%s_Tdc%03dChan%03u.root ", toftdc::ksTdcHistName[ uType ].Data(), - fMbsCalibPar->GetInitialCalInd( uType, uTdc ), uChanInd); - TString sInitialCalibHistoName = ""; - fileCalibrationIn = new TFile( sInitialCalibFileName, "READ"); - if( kTRUE == fileCalibrationIn->IsOpen() ) - { - // Initialize pointer to NULL - TH1* fInitialCalibHistoFromFile = NULL; - sInitialCalibHistoName = Form("tof_%s_ft_b%03d_ch%03u", toftdc::ksTdcHistName[ uType ].Data(), - fMbsCalibPar->GetInitialCalInd( uType, uTdc ), uChanInd ); - - fileCalibrationIn->GetObject( sInitialCalibHistoName, fInitialCalibHistoFromFile); - - Int_t iHistoIndex = uTdc*uNbChan + uChanInd; - - if( NULL == fInitialCalibHistoFromFile ) - sInfoLoading += " 0 "; - else - { - sInfoLoading += " 1 "; - fhInitialCalibHisto[ uType ][ iHistoIndex ] = (TH1*)fInitialCalibHistoFromFile->Clone( - Form("%s_CalibFile", sInitialCalibHistoName.Data() ) ); - fhInitialCalibHisto[ uType ][ iHistoIndex ]->SetDirectory( oldDir ); - - // Extract calibration factors from initialization histo - CalibFactorsInit( uType, uTdc, uChanInd ); - } // else of if( NULL == fInitialCalibHistoFromFile ) - fileCalibrationIn->Close(); - } // if( kTRUE == fileCalibrationIn->IsOpen() ) - else sInfoLoading += " 0 "; - } // for( UInt_t uChanInd = 0; uChanInd< uNbChan; uChanInd++) - LOG(info)<<sInfoLoading; - } // if( -1 < fMbsCalibPar->GetInitialCalInd( uType, uTdc ) ) - } // for( UInt_t uType = toftdc::caenV1290; uType < toftdc::NbTdcTypes; uType++ ) - -// if( kTRUE == fMbsCalibPar->IsTdcOffsetEna() ) -// { - if( kFALSE == LoadSingleCalibrationsRef( ) ) - return kFALSE; -// } // if( kTRUE == fMbsCalibPar->IsTdcOffsetEna() ) - - return kTRUE; -} -Bool_t TMbsCalibTdcTof::CalibFactorsInit( UInt_t uType, UInt_t uBoard, UInt_t uChan ) -{ - UInt_t uNbChan = 0; - Double_t dClockCycle = 0.0; - UInt_t uFtBinNb = 0; - - switch( uType ) - { - case toftdc::caenV1290: - uNbChan = caentdc::kuNbChan; - dClockCycle = caentdc::kdClockCycleSize; - uFtBinNb = caentdc::kiFineTime + 1; - break; - case toftdc::vftx: - uNbChan = vftxtdc::kuNbChan; - dClockCycle = vftxtdc::kdClockCycleSize; - uFtBinNb = vftxtdc::kiFifoFineTime + 1; - break; - case toftdc::trb: - uNbChan = trbtdc::kuNbChan; - dClockCycle = trbtdc::kdClockCycleSize; - uFtBinNb = trbtdc::kiFineCounterSize; - break; - case toftdc::get4: - uNbChan = get4tdc::kuNbChan; - dClockCycle = get4tdc::kdClockCycleSize; - uFtBinNb = get4tdc::kiFineTime + 1; - if( 4 == fMbsCalibPar->GetTotMode( uType ) ) - uNbChan = get4v10::kuNbChan; - break; - default: - break; - } // switch( uType ) - - Int_t iHistoIndex = uBoard*uNbChan + uChan; - - if( NULL != fhInitialCalibHisto[ uType ][ iHistoIndex ]) - { - // Reset Histos with DNL ploting - fhDnlChan[uType][iHistoIndex]->Reset(); - fhDnlSum[uType][iHistoIndex]->Reset(); - fhBinSizeChan[uType][iHistoIndex]->Reset(); - - //set the sum to zero before summing over all bins in one channel - Bool_t bincontrol[uFtBinNb]; - Int_t iSum = 0; - - Double_t dTotalEntriesInHisto = (Double_t)(fhInitialCalibHisto[ uType ][ iHistoIndex ]->GetEntries() ); - - for(Int_t iBin = 0; iBin < (Int_t)uFtBinNb; iBin++) - { - Int_t iBinContent = (Int_t)(fhInitialCalibHisto[ uType ][ iHistoIndex ]->GetBinContent(iBin+1)); - //Looking for the used bins - if( iBinContent <= 0) - bincontrol[iBin] = kFALSE; - else if( iBinContent > 0) - bincontrol[iBin] = kTRUE; - - // build the sum of all bin content - if(bincontrol[iBin]) - { - iSum = iSum + iBinContent; - fdCorr[uType][iHistoIndex][iBin] = (Double_t)iSum / dTotalEntriesInHisto; - fhDnlChan[uType][iHistoIndex]->Fill(iBin, (Double_t)iBinContent/dTotalEntriesInHisto ); - fhBinSizeChan[uType][iHistoIndex]->Fill( dClockCycle*(Double_t)iBinContent/dTotalEntriesInHisto ); - } // if(bincontrol[iBin]) - else - { - if( 0 < iBin) - fdCorr[uType][iHistoIndex][iBin] = fdCorr[uType][iHistoIndex][iBin-1]; - else fdCorr[uType][iHistoIndex][iBin] = 0.0; - } // else of if(bincontrol[iBin]) - fhDnlSum[uType][iHistoIndex]->Fill(iBin, fdCorr[uType][iHistoIndex][iBin] ); - } // for(Int_t iBin=0; iBin < (Int_t)uFtBinNb; iBin++) - fbCalibAvailable[uType][iHistoIndex] = kTRUE; - } // if( NULL != fInitialCalibHisto[uTdc][uChanInd]) - else return kFALSE; - - return kTRUE; -} -Bool_t TMbsCalibTdcTof::Calibration( UInt_t uType, UInt_t uBoard) -{ - LOG(debug)<<"TMbsCalibTdcTof::Calibration => Type "<<uType - <<" Active bd "<<fMbsUnpackPar->GetNbActiveBoards( uType ) - <<" Board "<<uBoard; - if( uBoard < fMbsUnpackPar->GetNbActiveBoards( uType ) ) - { - // TDC type specific values - UInt_t uNbChan = 0; - TClonesArray * xUnpDataArray = NULL; - Double_t dClockCycle = 0.0; - Bool_t bInvertFt = kFALSE; - Double_t dTotBinToPs = 0.0; - Int_t iCoarseSize = 0; - Int_t iCoarseOfLim = 0; - switch( uType ) - { - case toftdc::caenV1290: - uNbChan = caentdc::kuNbChan; - xUnpDataArray = fCaenBoardCollection; - dClockCycle = caentdc::kdClockCycleSize; - bInvertFt = caentdc::kbInvertFt; - iCoarseSize = caentdc::kiCoarseCounterSize; - iCoarseOfLim = caentdc::kuCoarseOverflowTest; - break; - case toftdc::vftx: - uNbChan = vftxtdc::kuNbChan; - xUnpDataArray = fVftxBoardCollection; - dClockCycle = vftxtdc::kdClockCycleSize; - bInvertFt = vftxtdc::kbInvertFt; - iCoarseSize = vftxtdc::kiCoarseCounterSize; - iCoarseOfLim = vftxtdc::kuCoarseOverflowTest; - break; - case toftdc::trb: - uNbChan = trbtdc::kuNbChan; - xUnpDataArray = fTrb3BoardCollection; - dClockCycle = trbtdc::kdClockCycleSize; - bInvertFt = trbtdc::kbInvertFt; - iCoarseSize = trbtdc::kiCoarseCounterSize; - iCoarseOfLim = trbtdc::kuCoarseOverflowTest; - break; - case toftdc::get4: - uNbChan = get4tdc::kuNbChan; - xUnpDataArray = fGet4BoardCollection; - dClockCycle = get4tdc::kdClockCycleSize; - bInvertFt = get4tdc::kbInvertFt; - dTotBinToPs = get4tdc::kdTotBinSize; - iCoarseSize = get4tdc::kiCoarseCounterSize; - iCoarseOfLim = get4tdc::kuCoarseOverflowTest; - if( 4 == fMbsCalibPar->GetTotMode( uType ) ) - uNbChan = get4v10::kuNbChan; - break; - default: - break; - } // switch( uType ) - - if( NULL == xUnpDataArray || NULL == fCalibDataCollection ) - { - LOG(error)<<"TMbsCalibTdcTof::Calibration => Data pt failed Type "<<uType - <<" Active bd "<<fMbsUnpackPar->GetNbActiveBoards( uType ) - <<" Board "<<uBoard<<" Unp array "<<xUnpDataArray<<" CalibDataColl "<<fCalibDataCollection; - return kFALSE; - } - - // Board raw data recovery - TTofTdcBoard * xBoardUnpData = (TTofTdcBoard*) xUnpDataArray->At(uBoard); - - if( NULL == xBoardUnpData ) - { - fdBoardTriggerTime[uType][uBoard] = 0.0; - LOG(error)<<"TMbsCalibTdcTof::Calibration => Bd pt failed Type "<<uType - <<" Active bd "<<fMbsUnpackPar->GetNbActiveBoards( uType ) - <<" Board "<<uBoard; - return kFALSE; - } // if( NULL == xBoardUnpData ) - - if( kFALSE == xBoardUnpData->IsValid() ) - { - fdBoardTriggerTime[uType][uBoard] = 0.0; - LOG(debug)<<"TMbsCalibTdcTof::Calibration => Bd data invalid Type "<<uType - <<" Active bds "<<fMbsUnpackPar->GetNbActiveBoards( uType ) - <<" Board "<<uBoard; - return kFALSE; - } // if( kFALSE == xBoardUnpData->IsValid() ) - - // TOT variables preparation - // TOT mode 1 and 4 don't need intermediate storage for time ordering - // TOT mode 3 needs all boards to have been processed before time ordering of calibrated data and - // Tot building. - // Only TOT mode 2 needs time ordering of a single board data - if( 2 == fMbsCalibPar->GetTotMode( uType ) ) - xTempCalibData[uType]->Clear("C"); - - // Trigger time - Int_t iTriggerCoarseTime = xBoardUnpData->GetTriggerTime(); -// fdBoardTriggerTime[uType][uBoard] = iTriggerCoarseTime * dClockCycle; - // TODO: board time corrections => board to board offset, Offsets between different tdc types, etc... - // Partially done for TRB by using channel 0. - Int_t iMainTriggerCoarseTime = 0; - if( NULL != (TTofTdcBoard*) xUnpDataArray->At(fMbsCalibPar->GetTdcOffsetMainTdc()) ) - if( kTRUE == ( (TTofTdcBoard*) xUnpDataArray->At(fMbsCalibPar->GetTdcOffsetMainTdc()) )->IsValid() ) - { - iMainTriggerCoarseTime = ((TTofTdcBoard*) xUnpDataArray->At( - fMbsCalibPar->GetTdcOffsetMainTdc() ))->GetTriggerTime(); - - // Fix for big trigger time deviation in GSI Sep14 data - // The TDCs in the TRB3 boards had a big deviation in time counter origin relative - // to the FPGA TDC small boards. - // Here we try to add to the offset and additional offset for the boards - // which are too far away from the main TDC time origin. - // For this we use the trigger time of the first board in this case and in the first event. - // Hopefully this is enough to avoid introducing different offsets for different boards/events. - // Problem: the boards are jumping around - if( kTRUE == fbGsiSep14Fix && toftdc::trb == uType && 0 < iTriggerCoarseTime ) - if( ( iTriggerCoarseTime - iMainTriggerCoarseTime > 1000000 ) || - ( iTriggerCoarseTime - iMainTriggerCoarseTime < -1000000 ) ) // deviation > ~5ms - { - std::stringstream ss; - ss <<"TMbsCalibTdcTof::Calibration Type "<<uType<<" Board "<<uBoard - <<" Instead of Main Trigger coarse time "<<iMainTriggerCoarseTime; - - if( fiOffsetGsiSep14Fix < 0 ) - fiOffsetGsiSep14Fix = iTriggerCoarseTime - iMainTriggerCoarseTime; - - Int_t iFurtherOffset = fiOffsetGsiSep14Fix + iMainTriggerCoarseTime; - - ss <<" Use Main Trigger coarse time "<<iFurtherOffset - <<" ("<< ((iFurtherOffset& 0x7FFFFE00) - (iMainTriggerCoarseTime& 0x7FFFFE00))<<")"; - LOG(debug) << ss.str(); - - iMainTriggerCoarseTime += fiOffsetGsiSep14Fix; - - if( ( (iMainTriggerCoarseTime - iTriggerCoarseTime) > 1000000) || - ( (iMainTriggerCoarseTime - iTriggerCoarseTime) < -1000000) ) - { - LOG(info)<<"TMbsCalibTdcTof::Calibration Type "<<uType<<" Board "<<uBoard - <<" Trigger time used for offset may have jumped "<<iMainTriggerCoarseTime - iTriggerCoarseTime - <<" in event "; - // Try to update the common offset => may lead to multiple peaks in time difference - iMainTriggerCoarseTime -= fiOffsetGsiSep14Fix; // Remove the offset we just added - fiOffsetGsiSep14Fix = iTriggerCoarseTime - iMainTriggerCoarseTime; // compute new offset - iMainTriggerCoarseTime += fiOffsetGsiSep14Fix; // apply this offset - } - - } // if( iTriggerCoarseTime - iMainTriggerCoarseTime > 100000 ) // deviation > ~500us - - } // if( kTRUE == ( (TTofTdcBoard*) xUnpDataArray->At(fMbsCalibPar->GetTdcOffsetMainTdc()) )->IsValid() ) - // In order to avoid big numbers after conversion to double float - // (precision loss), we subtract part of the main board trigger time counter from calib hits - // Use for now 128 clock cycle (~600ns for trb) - // Therefore we need to do the same to "calib" trigger time for plotting - if( kTRUE == fMbsCalibPar->UseCoarse() ) -// fdBoardTriggerTime[uType][uBoard] = ( iTriggerCoarseTime - (iMainTriggerCoarseTime & 0x7FFFFF80) ) - fdBoardTriggerTime[uType][uBoard] = ( iTriggerCoarseTime - (iMainTriggerCoarseTime & 0x7FFFFFFF) ) - * dClockCycle; - else fdBoardTriggerTime[uType][uBoard] = iTriggerCoarseTime * dClockCycle; - - LOG(debug)<<"TMbsCalibTdcTof::Calibration Type "<<uType<<" Board "<<uBoard - <<" Main Trigger coarse time "<<iMainTriggerCoarseTime; - - // Data calibration - Int_t iNbUnpData = xBoardUnpData->GetDataNb(); - TTofTdcData * xUnpDataPtr; -/* TTofCalibData * xCalData;*/ // Commented out to remove warning bec. unused - - LOG(debug)<<"TMbsCalibTdcTof::Calibration Type "<<uType<<" Board "<<uBoard<<" N Data "<<iNbUnpData; - // Loop over unpacked data - for( Int_t iUnpDataInd = 0; iUnpDataInd < iNbUnpData; iUnpDataInd++ ) - { -// xCalData.Clear(); - xUnpDataPtr = xBoardUnpData->GetDataPtr(iUnpDataInd); - - Int_t iHistoIndex = uBoard*uNbChan + xUnpDataPtr->GetChannel(); - - // Check if the calibration factors are available (either initial or new data) - if( kFALSE == fbCalibAvailable[uType][iHistoIndex] ) - continue; - - Int_t iCoarseTime = xUnpDataPtr->GetCoarseTime(); - if( kTRUE == fMbsCalibPar->UseCoarse() ) - { - // Test Coarse counter Overflow - if( iCoarseOfLim < iCoarseTime - iTriggerCoarseTime ) - // trigger -- OverflowLimit --> hit - //=> if right order probably: hit ... Overflow ... trigger - iCoarseTime -= iCoarseSize; - else if( iCoarseOfLim < iTriggerCoarseTime - iCoarseTime ) - // hit -- OverflowLimit --> trigger - //=> if right order probably: trigger ... Overflow ... hit - iCoarseTime += iCoarseSize; - - // In order to avoid big numbers after conversion to double float - // (precision loss), subtract part of the main board trigger time counter - // Use for now 128 clock cycle (~600ns for trb) -// iCoarseTime -= iMainTriggerCoarseTime & 0x7FFFFF80; - iCoarseTime -= iMainTriggerCoarseTime & 0x7FFFFFFF; - - if( iCoarseTime < -1000000 || 1000000 < iCoarseTime ) { - std::stringstream ss; - ss <<"TMbsCalibTdcTof::Calibration Type "<<uType<<" Board "<<uBoard<<" Chan "<< xUnpDataPtr->GetChannel() - <<" Trigger time used for offset may have jumped "<<iTriggerCoarseTime - <<" "<<iMainTriggerCoarseTime<<" "<<fiOffsetGsiSep14Fix - <<" "<<iMainTriggerCoarseTime - iTriggerCoarseTime - << "\n" - <<" data coarse "<< iCoarseTime; - LOG(debug) << ss.str(); - } - } // if( kTRUE == fMbsCalibPar->UseCoarse() - - Double_t dCalibTime = dClockCycle * iCoarseTime; - if( kTRUE == bInvertFt ) - dCalibTime += dClockCycle *( 1 - fdCorr[uType][iHistoIndex][xUnpDataPtr->GetFineTime()] ); - else dCalibTime += dClockCycle * fdCorr[uType][iHistoIndex][xUnpDataPtr->GetFineTime()]; - - - // ToT calculation - // TODO: multiple consecutive Rising edges - // TODO: Time difference with coarse counter overflow check/safety for Tot - Double_t dTot = 0.0; - UInt_t uEdge = 0; - switch( fMbsCalibPar->GetTotMode( uType ) ) - { - case 1: - { - Int_t iDataIndex = uBoard*uNbChan + xUnpDataPtr->GetChannel(); - UInt_t uChan = xUnpDataPtr->GetChannel(); - if( fMbsCalibPar->GetTotInvFlag( uType, uBoard, uChan ) == static_cast<Int_t>(xUnpDataPtr->GetEdge()) ) - { - if( NULL != xTofTdcDataPrevArray[uType]->At( iDataIndex ) ) - ((TTofCalibData*)(xTofTdcDataPrevArray[uType]->At( iDataIndex )))->Clear(); - // rising edge - new((*xTofTdcDataPrevArray[uType])[ iDataIndex ]) - TTofCalibData( uType, uBoard, uChan, dCalibTime , dTot, uEdge ); - } // if( 0 == xUnpDataPtr->GetEdge() ) - else if( NULL != xTofTdcDataPrevArray[uType]->At( iDataIndex ) ) - { - TTofCalibData* dataRisingEdge = (TTofCalibData*)(xTofTdcDataPrevArray[uType]->At( iDataIndex ) ); - if( kTRUE == dataRisingEdge->IsFilled() ) - { - Double_t dDataTime = dataRisingEdge->GetTime(); - - // falling edge & rising edge present & filled - dTot = dataRisingEdge->GetTimeDifference( dCalibTime ); - - // Time offset - if( kTRUE == fMbsCalibPar->EnaTimeOffset() ) - dDataTime -= fMbsCalibPar->GetTimeOffsetVal( uType, uBoard, uChan ); - - // TDC to TDC offset -// if( kTRUE == fMbsCalibPar->IsTdcOffsetEna() ) - if( kTRUE == fMbsCalibPar->GetTdcOffEnaFlag(uType, uBoard) ) - dDataTime -= fdTdcOffsets[uType][uBoard]; - - // Tot offset - // Tot offset signe inverted if rising and falling inverted - if( kTRUE == fMbsCalibPar->EnaTimeOffset() ) - dTot -= fMbsCalibPar->GetTotOffsetVal( uType, uBoard, uChan ) * - ( 1 == fMbsCalibPar->GetTotInvFlag( uType, uBoard, uChan ) ? -1 : 1 ); - - // Use time from rising edge and newly calculated tot to create the hit - new((*fCalibDataCollection)[ fCalibDataCollection->GetEntriesFast() ]) - TTofCalibData( uType, uBoard, uChan, - dDataTime, - dTot, 2 ); - } // if( kTRUE == (xTofTdcDataPrevArray[uType]->At( iDataIndex ) )->IsFilled() ) - } // else if( NULL != xTofTdcDataPrevArray[uType]->At( iDataIndex ) ) - break; - } // encapsulation needed because of iDataIndex presence/initialization in multiple cases - case 2: - { - UInt_t uInputChan = ( xUnpDataPtr->GetChannel() - xUnpDataPtr->GetChannel()%2 ) / 2; - - // Save data for later time ordering - Int_t iDataIndex = xTempCalibData[uType]->GetEntriesFast(); - uEdge = ( xUnpDataPtr->GetChannel()%2 + 1 + fMbsCalibPar->GetTotInvFlag( uType, uBoard, uInputChan ) )%2; - - // Tot offset signe inverted if rising and falling inverted - if( 1 == uEdge && kTRUE == fMbsCalibPar->EnaTotOffset() ) - // TODO: For now use the value of TOT offsets as just a way to make sure the TOT is positive, - // to change once the real offset are measured with pulser - dCalibTime -= fMbsCalibPar->GetTotOffsetVal( uType, uBoard, uInputChan ); - // TODO: Change to enable the use of measured TOT offset -// dCalibTime -= fMbsCalibPar->GetTotOffsetVal( uType, uBoard, uInputChan ) * -// ( 1 == fMbsCalibPar->GetTotInvFlag( uType, uBoard, uInputChan ) ? -1 : 1 ); - - new((*xTempCalibData[uType])[ iDataIndex ]) - TTofCalibData( uType, uBoard, uInputChan, dCalibTime , 0.0, - uEdge ); - break; - } // encapsulation needed because of iDataIndex presence/initialization in multiple cases - case 3: - { - // TODO: make it independent of board order! - // (time ordering is done in unpacker only inside a board => fail with inverted board order) - // TODO: board to board offset - UInt_t uChan = xUnpDataPtr->GetChannel(); - - // Save data for later time ordering - Int_t iDataIndex = xTempCalibData[uType]->GetEntriesFast(); - uEdge = ( uBoard%2 + fMbsCalibPar->GetTotInvFlag( uType, uBoard, uChan ) )%2; - new((*xTempCalibData[uType])[ iDataIndex ]) - TTofCalibData( uType, uBoard%2, uChan, dCalibTime , 0.0, - uEdge ); - break; - } // encapsulation needed because of iDataIndex presence/initialization in multiple cases - case 4: - dTot = xUnpDataPtr->GetTot() * dTotBinToPs; - // Offset of input channel time - if( kTRUE == fMbsCalibPar->EnaTimeOffset() ) - dCalibTime -= fMbsCalibPar->GetTimeOffsetVal( uType, uBoard, xUnpDataPtr->GetChannel() ); - - // TDC to TDC offset - if( kTRUE == fMbsCalibPar->GetTdcOffEnaFlag(uType, uBoard) ) -// if( kTRUE == fMbsCalibPar->IsTdcOffsetEna() ) - dCalibTime -= fdTdcOffsets[uType][uBoard]; - - // Offset between rising and falling edge => Tot offset - if( kTRUE == fMbsCalibPar->EnaTotOffset() ) - dTot -= fMbsCalibPar->GetTotOffsetVal( uType, uBoard, xUnpDataPtr->GetChannel() ); - - new((*fCalibDataCollection)[ fCalibDataCollection->GetEntriesFast() ]) - TTofCalibData( uType, uBoard, xUnpDataPtr->GetChannel(), dCalibTime , dTot, 2 ); - break; - case 0: - default : - { - uEdge = xUnpDataPtr->GetEdge(); - - if( kTRUE == fMbsCalibPar->EnaTimeOffset() ) - { - // Time offset applies to input channel, not TDC channel! - UInt_t uInputChan; - switch( uType ) - { - case toftdc::vftx: - case toftdc::trb: - // 2 TDC channel per input channel - uInputChan = ( xUnpDataPtr->GetChannel() - xUnpDataPtr->GetChannel()%2 ) / 2; - break; - case toftdc::caenV1290: - case toftdc::get4: - default: - // 1 TDC channel per input channel - uInputChan = xUnpDataPtr->GetChannel(); - break; - } // switch( uType ) - dCalibTime -= fMbsCalibPar->GetTimeOffsetVal( uType, uBoard, uInputChan ); - } // if( kTRUE == fMbsCalibPar->EnaTimeOffset() ) - - // TDC to TDC offset - if( kTRUE == fMbsCalibPar->GetTdcOffEnaFlag(uType, uBoard) ) -// if( kTRUE == fMbsCalibPar->IsTdcOffsetEna() ) - dCalibTime -= fdTdcOffsets[uType][uBoard]; - - // Not Tot => no Tot offset!! - - // For now always save - new((*fCalibDataCollection)[ fCalibDataCollection->GetEntriesFast() ]) - TTofCalibData( uType, uBoard, xUnpDataPtr->GetChannel(), dCalibTime , dTot, uEdge ); - break; - } // encapsulation needed because of uInputChan presence/initialization in multiple cases - } // switch( fMbsCalibPar->GetTotMode() ) - } // for( Int_t iUnpDataInd = 0; iUnpDataInd < iNbUnpData; iUnpDataInd++ ) - - // TOT mode 1 and 4 are already done. - // TOT mode 3 needs all boards to have been processed before time ordering of calibrated data and - // Tot building. - if( 2 == fMbsCalibPar->GetTotMode( uType ) ) - { - // In the case where 1 input channel correspond to 2 TDC channels, - // we can time order the hits now that we have all of them calibrated - // and then we will be able to associate them in full calibrated TDC data! - BuildTotSplitChannels( uType, uBoard ); - } // if( 2 == fMbsCalibPar->GetTotMode( uType ) ) - - // Recalibration if necessary/possible - // Check if initial histos array was created - Bool_t bBoardInitialThere = kFALSE; - if( fhInitialCalibHisto[ uType ].size() == fMbsUnpackPar->GetNbActiveBoards( uType )*uNbChan ) - bBoardInitialThere = kTRUE; - - // loop over channels - for( UInt_t uChanInd = 0; uChanInd< uNbChan; uChanInd++) - { - Int_t iHistoIndex = uBoard*uNbChan + uChanInd; - - if( 0 < fMbsCalibPar->GetMinHitCalib() ) - { - Int_t iNbHitsThisCh = fhFineTime[uType][iHistoIndex]->GetEntries(); - - // Check if initial calibration histograms are available - Bool_t bInitialThere = kFALSE; - if( kTRUE == bBoardInitialThere ) - if( NULL != fhInitialCalibHisto[ uType ][ iHistoIndex ] ) - bInitialThere = kTRUE; - - // Check whether we should use the initial calibration on top of the new data - Bool_t bUseInitial = bInitialThere; - if( 0 < fMbsCalibPar->GetMinHitCalibNewOnly() && - fMbsCalibPar->GetMinHitCalibNewOnly() <= iNbHitsThisCh ) - bUseInitial = kFALSE; - - if( 0 < iNbHitsThisCh && - 0 == iNbHitsThisCh % fMbsCalibPar->GetMinHitCalib() ) - CalibFactorsCalc( uType, uBoard, uChanInd, bUseInitial); - } // if( 0 < fMbsCalibPar->GetMinHitCalib() ) - } // for( UInt_t uChanInd = 0; uChanInd< uNbChan; uChanInd++) - } // if( 0 < fMbsUnpackPar->GetNbActiveBoards( uType ) ) - else return kFALSE; - - return kTRUE; -} -Bool_t TMbsCalibTdcTof::CalibFactorsCalc( UInt_t uType, UInt_t uBoard, UInt_t uChan, Bool_t bWithInitial ) -{ - UInt_t uNbChan = 0; - Double_t dClockCycle = 0.0; - UInt_t uFtBinNb = 0; - - switch( uType ) - { - case toftdc::caenV1290: - uNbChan = caentdc::kuNbChan; - dClockCycle = caentdc::kdClockCycleSize; - uFtBinNb = caentdc::kiFineTime + 1; - break; - case toftdc::vftx: - uNbChan = vftxtdc::kuNbChan; - dClockCycle = vftxtdc::kdClockCycleSize; - uFtBinNb = vftxtdc::kiFifoFineTime + 1; - break; - case toftdc::trb: - uNbChan = trbtdc::kuNbChan; - dClockCycle = trbtdc::kdClockCycleSize; - uFtBinNb = trbtdc::kiFineCounterSize; - break; - case toftdc::get4: - uNbChan = get4tdc::kuNbChan; - dClockCycle = get4tdc::kdClockCycleSize; - uFtBinNb = get4tdc::kiFineTime + 1; - if( 4 == fMbsCalibPar->GetTotMode( uType ) ) - uNbChan = get4v10::kuNbChan; - break; - default: - break; - } // switch( uType ) - Int_t iHistoIndex = uBoard*uNbChan + uChan; - - // define correction variables - // & set the sum to zero before summing over all bins in one channel - Bool_t bincontrol[uFtBinNb]; - Int_t iSum = 0; - - if( kTRUE == bWithInitial ) - { - // Use both initial calibration histograms and new data - // To extract the correction factors - if( NULL != fhInitialCalibHisto[ uType ][ iHistoIndex ]) - { - // Reset Histos with DNL ploting - fhDnlChan[uType][iHistoIndex]->Reset(); - fhDnlSum[uType][iHistoIndex]->Reset(); - fhBinSizeChan[uType][iHistoIndex]->Reset(); - - Double_t dTotalEntriesInHisto = (Double_t)(fhFineTime[ uType ][ iHistoIndex ]->GetEntries() ) + - (Double_t)(fhInitialCalibHisto[ uType ][ iHistoIndex ]->GetEntries() ); - - for(Int_t iBin = 0; iBin < (Int_t)uFtBinNb; iBin++) - { - Int_t iBinContent = (Int_t)(fhFineTime[ uType ][ iHistoIndex ]->GetBinContent(iBin+1)) + - (Int_t)(fhInitialCalibHisto[ uType ][ iHistoIndex ]->GetBinContent(iBin+1)); - //Looking for the used bins - if( iBinContent <= 0) - bincontrol[iBin] = kFALSE; - else if( iBinContent > 0) - bincontrol[iBin] = kTRUE; - - // build the sum of all bin content - if(bincontrol[iBin]) - { - iSum = iSum + iBinContent; - fdCorr[uType][iHistoIndex][iBin] = (Double_t)iSum / dTotalEntriesInHisto; - fhDnlChan[uType][iHistoIndex]->Fill(iBin, (Double_t)iBinContent/dTotalEntriesInHisto ); - fhBinSizeChan[uType][iHistoIndex]->Fill( dClockCycle*(Double_t)iBinContent/dTotalEntriesInHisto ); - } // if(bincontrol[iBin]) - else - { - if( 0 < iBin) - fdCorr[uType][iHistoIndex][iBin] = fdCorr[uType][iHistoIndex][iBin-1]; - else fdCorr[uType][iHistoIndex][iBin] = 0.0; - } // else of if(bincontrol[iBin]) - fhDnlSum[uType][iHistoIndex]->Fill(iBin, fdCorr[uType][iHistoIndex][iBin] ); - } // for(Int_t iBin=0; iBin < (Int_t)uFtBinNb; iBin++) - fbCalibAvailable[uType][iHistoIndex] = kTRUE; - return kTRUE; - } // if( NULL != fhInitialCalibHisto[ uType ][ iHistoIndex ]) - } // if( kTRUE == bWithInitial ) - - // If either choice to use only new data or initial histo missing - // => Use only new data to extract the correction factors - - // Reset Histos with DNL ploting - fhDnlChan[uType][iHistoIndex]->Reset(); - fhDnlSum[uType][iHistoIndex]->Reset(); - fhBinSizeChan[uType][iHistoIndex]->Reset(); - - Double_t dTotalEntriesInHisto = (Double_t)(fhFineTime[ uType ][ iHistoIndex ]->GetEntries() ); - - for(Int_t iBin = 0; iBin < (Int_t)uFtBinNb; iBin++) - { - Int_t iBinContent = (Int_t)(fhFineTime[ uType ][ iHistoIndex ]->GetBinContent(iBin+1)); - //Looking for the used bins - if( iBinContent <= 0) - bincontrol[iBin] = kFALSE; - else if( iBinContent > 0) - bincontrol[iBin] = kTRUE; - - // build the sum of all bin content - if(bincontrol[iBin]) - { - iSum = iSum + iBinContent; - fdCorr[uType][iHistoIndex][iBin] = (Double_t)iSum / dTotalEntriesInHisto; - fhDnlChan[uType][iHistoIndex]->Fill(iBin, (Double_t)iBinContent/dTotalEntriesInHisto ); - fhBinSizeChan[uType][iHistoIndex]->Fill( dClockCycle*(Double_t)iBinContent/dTotalEntriesInHisto ); - } // if(bincontrol[iBin]) - else - { - if( 0 < iBin) - fdCorr[uType][iHistoIndex][iBin] = fdCorr[uType][iHistoIndex][iBin-1]; - else fdCorr[uType][iHistoIndex][iBin] = 0.0; - } // else of if(bincontrol[iBin]) - fhDnlSum[uType][iHistoIndex]->Fill(iBin, fdCorr[uType][iHistoIndex][iBin] ); - fbCalibAvailable[uType][iHistoIndex] = kTRUE; - } // for(Int_t iBin=0; iBin < (Int_t)uFtBinNb; iBin++) - return kTRUE; -} - - -Bool_t TMbsCalibTdcTof::WriteCalibrationFile() -{ - TTimeStamp timeCurrent; - oldDir = gDirectory; - TString sCalibOutFilename; - if( "" == fsCalibFilename ) - sCalibOutFilename = Form("%sTofTdcCalibHistos_%u_%u.root", fsCalibOutFoldername.Data(), timeCurrent.GetDate( kFALSE), timeCurrent.GetTime( kFALSE) ); - else sCalibOutFilename = Form("%sTofTdcCalibHistos_%s.root", fsCalibOutFoldername.Data(), fsCalibFilename.Data() ); - TFile* fileCalibrationOut = new TFile( sCalibOutFilename, "RECREATE", - Form("Calibration Data for ToF TDCs, saved from analysis on %s", timeCurrent.AsString("lc") ), - 9); - if( kTRUE == fileCalibrationOut->IsOpen() ) - { - sCalibOutFilename += ":/"; - gDirectory->Cd(sCalibOutFilename); - - for( UInt_t uType = toftdc::caenV1290; uType < toftdc::NbTdcTypes; uType++ ) - if( 0 < fMbsUnpackPar->GetNbActiveBoards( uType ) ) - { - UInt_t uNbChan = 0; - - switch( uType ) - { - case toftdc::caenV1290: - uNbChan = caentdc::kuNbChan; - break; - case toftdc::vftx: - uNbChan = vftxtdc::kuNbChan; - break; - case toftdc::trb: - uNbChan = trbtdc::kuNbChan; - break; - case toftdc::get4: - uNbChan = get4tdc::kuNbChan; - if( 4 == fMbsCalibPar->GetTotMode( uType ) ) - uNbChan = get4v10::kuNbChan; - break; - default: - break; - } // switch( uType ) - if( 0 == uNbChan ) - { - LOG(info)<<"TMbsCalibTdcTof::WriteSingleCalibrations Undefined tdc parameters for type " - <<toftdc::ksTdcHistName[ uType ]; - LOG(info)<<" => No calib histo saving!"; - continue; - } - - TString sInfoSaving = "Saved initial calibration histograms for following " - + toftdc::ksTdcHistName[ uType ] +" channels:"; - LOG(info)<<sInfoSaving; - - sInfoSaving = " "; - for( UInt_t uChanInd = 0; uChanInd< uNbChan; uChanInd++) - sInfoSaving += Form("%3u ", uChanInd); - LOG(info)<<sInfoSaving; - - for( UInt_t uTdc = 0; uTdc < fMbsUnpackPar->GetNbActiveBoards( uType ); uTdc ++) - { - sInfoSaving = Form("tdc #%3u: ",uTdc ); - for( UInt_t uChanInd = 0; uChanInd< uNbChan; uChanInd++) - { - TString sCalibHistoOutputName = Form("tof_%s_ft_b%03u_ch%03u", toftdc::ksTdcHistName[ uType ].Data(), - uTdc, uChanInd ); - Int_t iHistoIndex = uTdc*uNbChan + uChanInd; - - // If only initial calib was used and the histogram is not there try again to get it as it was not accessed before - if( 0 == fMbsCalibPar->GetMinHitCalib() && NULL == fhFineTime[uType][iHistoIndex] ) - fhFineTime[uType][iHistoIndex] = (TH1*) gROOT->FindObjectAny( Form("tof_%s_ft_b%03u_ch%03u", toftdc::ksTdcHistName[ uType ].Data(), - uTdc, uChanInd)); - if( NULL == fhFineTime[uType][iHistoIndex] ) - LOG(info)<<uType<<" "<<iHistoIndex<<" "<<uTdc<<" "<<uChanInd; - - // New Calibration histo using only new data - if( 0 < (fhFineTime[ uType ][ iHistoIndex ]->GetEntries() ) ) - { - fhFineTime[ uType ][ iHistoIndex ]->Write( sCalibHistoOutputName, TObject::kOverwrite); - sInfoSaving += " 1 "; - } // if( 0 < (fhFineTime[ uType ][ iHistoIndex ]->GetEntries() ) ) - else sInfoSaving += " 0 "; - } // for( UInt_t uChanInd = 0; uChanInd< uNbChan; uChanInd++) - LOG(info)<<sInfoSaving; - } // for( UInt_t uTdc = 0; uTdc < fMbsCalibPar->GetNbCalibBoards( uType ); uTdc ++) - } // if( 0 < fMbsUnpackPar->GetNbActiveBoards( uType ) ) - -// if( kTRUE == fMbsCalibPar->IsTdcOffsetEna() ) -// { - if( kFALSE == WriteCalibrationFileRef( sCalibOutFilename ) ) - return kFALSE; -// } // if( kTRUE == fMbsCalibPar->IsTdcOffsetEna() ) - - //fileCalibrationOut->Write("",TObject::kOverwrite); - fileCalibrationOut->Close(); - LOG(info)<<"Calibration data saved in "<<sCalibOutFilename; - LOG(info)<<"Parameter line: InitialCalibFilename: Text_t " - <<(TString)( sCalibOutFilename(0, sCalibOutFilename.Length() -2 ) ); - } // if( kTRUE == fileCalibrationOut->IsOpen() ) - else LOG(warn)<<"TMbsCalibTdcTof::WriteCalibrationFile => Unable to open root file " - <<sCalibOutFilename - <<" to save calibration data, please check settings"; - gDirectory->Cd(oldDir->GetPath()); - - return kTRUE; -} -Bool_t TMbsCalibTdcTof::WriteSingleCalibrations() -{ - for( UInt_t uType = toftdc::caenV1290; uType < toftdc::NbTdcTypes; uType++ ) - if( 0 < fMbsUnpackPar->GetNbActiveBoards( uType ) ) - { - UInt_t uNbChan = 0; - - switch( uType ) - { - case toftdc::caenV1290: - uNbChan = caentdc::kuNbChan; - break; - case toftdc::vftx: - uNbChan = vftxtdc::kuNbChan; - break; - case toftdc::trb: - uNbChan = trbtdc::kuNbChan; - break; - case toftdc::get4: - uNbChan = get4tdc::kuNbChan; - if( 4 == fMbsCalibPar->GetTotMode( uType ) ) - uNbChan = get4v10::kuNbChan; - break; - default: - break; - } // switch( uType ) - if( 0 == uNbChan ) - { - LOG(info)<<"TMbsCalibTdcTof::WriteSingleCalibrations Undefined tdc parameters for type " - <<toftdc::ksTdcHistName[ uType ]; - LOG(info)<<" => No calib histo saving!"; - continue; - } - - TString sInfoSaving = "Saved initial calibration histograms for following " - + toftdc::ksTdcHistName[ uType ] +" channels:"; - LOG(info)<<sInfoSaving; - - sInfoSaving = " "; - for( UInt_t uChanInd = 0; uChanInd< uNbChan; uChanInd++) - sInfoSaving += Form("%3u ", uChanInd); - LOG(info)<<sInfoSaving; - - // Save current directory as TFile opening change it! - oldDir = gDirectory; - - // Check if initial histos arrays was created - Bool_t bBoardInitialThere = kFALSE; - if( fhInitialCalibHisto[ uType ].size() == fMbsUnpackPar->GetNbActiveBoards( uType )*uNbChan ) - bBoardInitialThere = kTRUE; - - for( UInt_t uTdc = 0; uTdc < fMbsUnpackPar->GetNbActiveBoards( uType ); uTdc ++) - { - sInfoSaving = Form("tdc #%3u: ",uTdc ); - - for( UInt_t uChanInd = 0; uChanInd< uNbChan; uChanInd++) - { - Bool_t bDataToSave = kFALSE; - Bool_t bInitialThere = kFALSE; - Int_t iHistoIndex = uTdc*uNbChan + uChanInd; - - if( kTRUE == bBoardInitialThere ) - if( NULL != fhInitialCalibHisto[ uType ][ iHistoIndex ] ) - bInitialThere = kTRUE; - - if( 0 < (fhFineTime[ uType ][ iHistoIndex ]->GetEntries() ) ) - bDataToSave = kTRUE; - - if( 1 == fMbsCalibPar->GetSingleCalOutMode() || kFALSE == bInitialThere ) - { - if( kTRUE == bDataToSave ) - { - TString sCalibOutFilename = Form("./calib/%s_Tdc%03uChan%03u.root", - toftdc::ksTdcHistName[ uType ].Data(), - uTdc, uChanInd); - TFile* fileCalibrationOut = new TFile( sCalibOutFilename, "RECREATE", - Form("Calibration Data for %s TDC %03u channel %03u", - toftdc::ksTdcHistName[ uType ].Data(), - uTdc, uChanInd ), - 9); - if( kTRUE == fileCalibrationOut->IsOpen() ) - { - sCalibOutFilename += ":/"; - gDirectory->Cd(sCalibOutFilename); - TString sCalibHistoOutputName = Form("tof_%s_ft_b%03u_ch%03u", toftdc::ksTdcHistName[ uType ].Data(), - uTdc, uChanInd ); - fhFineTime[ uType ][ iHistoIndex ]->Write( sCalibHistoOutputName, TObject::kOverwrite); - sInfoSaving += " 1 "; - - //fileCalibrationOut->Write("",TObject::kOverwrite); - fileCalibrationOut->Close(); - gDirectory->Cd(oldDir->GetPath()); - } // if( kTRUE == fileCalibrationOut->IsOpen() ) - else sInfoSaving += " 0 "; - } // if( kTRUE == bDataToSave ) - else sInfoSaving += " 0 "; - } // if( 1 == fMbsCalibPar->GetSingleCalOutMode() || kFALSE == bInitialThere ) - else if( kTRUE == bDataToSave ) - { - // Update old calibration histo with new data - TString sCalibOutFilename = Form("./calib/%s_Tdc%03uChan%03u.root ", - toftdc::ksTdcHistName[ uType ].Data(), - uTdc, uChanInd); - TFile* fileCalibrationOut = new TFile( sCalibOutFilename, "RECREATE", - Form("Calibration Data for %s TDC %03u channel %03u", - toftdc::ksTdcHistName[ uType ].Data(), - uTdc, uChanInd ), - 9); - if( kTRUE == fileCalibrationOut->IsOpen() ) - { - sCalibOutFilename += ":/"; - gDirectory->Cd(sCalibOutFilename); - TString sCalibHistoOutputName = Form("tof_%s_ft_b%03d_ch%03u", toftdc::ksTdcHistName[ uType ].Data(), - fMbsCalibPar->GetInitialCalInd( uType, uTdc ), uChanInd ); - // Try to update old calibration histo with new data - fhInitialCalibHisto[ uType ][ iHistoIndex ]->Add( fhFineTime[ uType ][ iHistoIndex ] ); - fhInitialCalibHisto[ uType ][ iHistoIndex ]->Write( sCalibHistoOutputName, TObject::kOverwrite); - sInfoSaving += " 1 "; - - //fileCalibrationOut->Write("",TObject::kOverwrite); - fileCalibrationOut->Close(); - gDirectory->Cd(oldDir->GetPath()); - } // if( kTRUE == fileCalibrationOut->IsOpen() ) - else sInfoSaving += " 0 "; - } // else of if( 1 == fMbsCalibPar->uSingleChannelCalibFilesOutput ) - // No new Data => no need to update calibration!!! - else sInfoSaving += " 0 "; - } // for( UInt_t uChanInd = 0; uChanInd< uNbChan; uChanInd++) - LOG(info)<<sInfoSaving; - } // for( UInt_t uTdc = 0; uTdc < fMbsCalibPar->GetNbCalibBoards( uType ); uTdc ++) - - // Go back to original directory - gDirectory->Cd(oldDir->GetPath()); - } // if( 0 < fMbsUnpackPar->GetNbActiveBoards( uType ) ) - -// if( kTRUE == fMbsCalibPar->IsTdcOffsetEna() ) -// { - if( kFALSE == WriteSingleCalibrationsRef( ) ) - return kFALSE; -// } // if( kTRUE == fMbsCalibPar->IsTdcOffsetEna() ) - - return kTRUE; -} -// ------------------------------------------------------------------ -Bool_t TMbsCalibTdcTof::CreateTotVariables() -{ - for( UInt_t uType = toftdc::caenV1290; uType < toftdc::NbTdcTypes; uType++ ) - if( 0 < fMbsUnpackPar->GetNbActiveBoards( uType ) ) - { - UInt_t uNbChan = 0; - UInt_t uMaxMult = 0; - - switch( uType ) - { - case toftdc::caenV1290: - uNbChan = caentdc::kuNbChan; - uMaxMult = toftdc::kuDefNbMulti; - break; - case toftdc::vftx: - uNbChan = vftxtdc::kuNbChan; - uMaxMult = vftxtdc::kuNbMulti; - break; - case toftdc::trb: - uNbChan = trbtdc::kuNbChan; - uMaxMult = toftdc::kuDefNbMulti; - break; - case toftdc::get4: - uNbChan = get4tdc::kuNbChan; - uMaxMult = toftdc::kuDefNbMulti; - if( 4 == fMbsCalibPar->GetTotMode( uType ) ) - uNbChan = get4v10::kuNbChan; - break; - default: - break; - } // switch( uType ) - - // TODO: test for flag for TOT inside a single data - switch( fMbsCalibPar->GetTotMode( uType ) ) - { - case 1: - xTofTdcDataPrevArray[uType] = new TClonesArray("TTofCalibData", - uNbChan * fMbsUnpackPar->GetNbActiveBoards( uType )); - // no need of a temporary vector to hold not associated edges and time order them - // as the hits are either already ordered - break; - case 2: - xTofTdcDataPrevArray[uType] = new TClonesArray("TTofCalibData", - uNbChan/2 * fMbsUnpackPar->GetNbActiveBoards( uType )); - - // Use a temporary vector to hold not associated edges and time order them - // 1 input channel -> 2 TDC channels => all boards used - xTempCalibData[uType] = new TClonesArray("TTofCalibData", - uMaxMult * uNbChan/2 * fMbsUnpackPar->GetNbActiveBoards( uType )); - break; - case 3: - if( 1 == fMbsUnpackPar->GetNbActiveBoards( uType )%2 ) - return kFALSE; - - xTofTdcDataPrevArray[uType] = new TClonesArray("TTofCalibData", - uNbChan * fMbsUnpackPar->GetNbActiveBoards( uType )); - - // Use a temporary vector to hold not associated edges and time order them - // 1 FEE channel -> 2 input channels in each board => 1/2 boards used - xTempCalibData[uType] = new TClonesArray("TTofCalibData", - uMaxMult * uNbChan * fMbsUnpackPar->GetNbActiveBoards( uType ) /2); - break; - case 0: - case 4: - // no need of a temporary vector to hold not associated edges and time order them - // as the hits are either already associated - default : - xTofTdcDataPrevArray[uType] = NULL; - break; - } // switch( fMbsCalibPar->GetTotMode() ) - } // if( 0 < fMbsUnpackPar->GetNbActiveBoards( uType ) ) - else xTofTdcDataPrevArray[uType] = NULL; - return kTRUE; -} -Bool_t TMbsCalibTdcTof::ClearTotVariables() -{ - for( UInt_t uType = toftdc::caenV1290; uType < toftdc::NbTdcTypes; uType++ ) - if( 0 < fMbsUnpackPar->GetNbActiveBoards( uType ) ) - { - - // TODO: test for flag for TOT inside a single data - switch( fMbsCalibPar->GetTotMode( uType ) ) - { - case 1: - xTofTdcDataPrevArray[uType]->Clear("C"); - // no need of a temporary vector to hold not associated edges and time order them - // as the hits are either already ordered - break; - case 2: - xTofTdcDataPrevArray[uType]->Clear("C"); - - // Use a temporary vector to hold not associated edges and time order them - // 1 input channel -> 2 TDC channels => all boards used - xTempCalibData[uType]->Clear("C"); - break; - case 3: - if( 1 == fMbsUnpackPar->GetNbActiveBoards( uType )%2 ) - return kFALSE; - - xTofTdcDataPrevArray[uType]->Clear("C"); - - // Use a temporary vector to hold not associated edges and time order them - // 1 FEE channel -> 2 input channels in each board => 1/2 boards used - xTempCalibData[uType]->Clear("C"); - break; - case 0: - case 4: - // no need of a temporary vector to hold not associated edges and time order them - // as the hits are either already associated - default : - break; - } // switch( fMbsCalibPar->GetTotMode() ) - } // if( 0 < fMbsUnpackPar->GetNbActiveBoards( uType ) ) - return kTRUE; -} -Bool_t TMbsCalibTdcTof::DeleteTotVariables() -{ - for( UInt_t uType = toftdc::caenV1290; uType < toftdc::NbTdcTypes; uType++ ) - if( 0 < fMbsUnpackPar->GetNbActiveBoards( uType ) ) - { - - // TODO: test for flag for TOT inside a single data - switch( fMbsCalibPar->GetTotMode( uType ) ) - { - case 1: - delete xTofTdcDataPrevArray[uType]; - // no need of a temporary vector to hold not associated edges and time order them - // as the hits are either already ordered - break; - case 2: - delete xTofTdcDataPrevArray[uType]; - - // Use a temporary vector to hold not associated edges and time order them - // 1 input channel -> 2 TDC channels => all boards used - delete xTempCalibData[uType]; - break; - case 3: - if( 1 == fMbsUnpackPar->GetNbActiveBoards( uType )%2 ) - return kFALSE; - - delete xTofTdcDataPrevArray[uType]; - - // Use a temporary vector to hold not associated edges and time order them - // 1 FEE channel -> 2 input channels in each board => 1/2 boards used - delete xTempCalibData[uType]; - break; - case 0: - case 4: - // no need of a temporary vector to hold not associated edges and time order them - // as the hits are either already associated - default : - break; - } // switch( fMbsCalibPar->GetTotMode() ) - } // if( 0 < fMbsUnpackPar->GetNbActiveBoards( uType ) ) - return kTRUE; -} -Bool_t TMbsCalibTdcTof::BuildTotSplitChannels( UInt_t uType, UInt_t uBoard ) -{ - UInt_t uNbChan = 0; - switch( uType ) - { - case toftdc::caenV1290: - uNbChan = caentdc::kuNbChan; - break; - case toftdc::vftx: - uNbChan = vftxtdc::kuNbChan; - break; - case toftdc::trb: - uNbChan = trbtdc::kuNbChan; - break; - case toftdc::get4: - uNbChan = get4tdc::kuNbChan; - if( 4 == fMbsCalibPar->GetTotMode( uType ) ) - uNbChan = get4v10::kuNbChan; - break; - default: - break; - } // switch( uType ) - - // In the case where 1 input channel correspond to 2 TDC channels, - // we can time order the hits now that we have all of them calibrated - // and then we will be able to associate them in full calibrated TDC data! - xTempCalibData[uType]->Sort(); - - // now build TOT - Int_t iNbCalData = xTempCalibData[uType]->GetEntriesFast(); - LOG(debug)<<"TMbsCalibTdcTof::BuildTotSplitChannels Type "<<uType<<" Board "<<uBoard<<" N Data "<<iNbCalData; - for( Int_t iCalDataInd = 0; iCalDataInd < iNbCalData; iCalDataInd++ ) - { - TTofCalibData * xCalibData = (TTofCalibData*) xTempCalibData[uType]->At(iCalDataInd); - - UInt_t uInputChan = xCalibData->GetChannel(); - Int_t iDataIndex = uBoard*uNbChan/2 + uInputChan; - UInt_t uEdge = xCalibData->GetEdge(); - Double_t dCalibTime = xCalibData->GetTime(); -/* - LOG(info)<<"TMbsCalibTdcTof::BuildTotSplitChannels Type "<<uType<<" Board "<<uBoard<<" Data "<<iCalDataInd; - LOG(info)<<" Chan "<<uInputChan<<" Edge "<<uEdge; - LOG(info)<<" Time "<<dCalibTime; -*/ - if( 0 == uEdge ) - { - if( NULL != xTofTdcDataPrevArray[uType]->At( iDataIndex ) ) - ((TTofCalibData*)(xTofTdcDataPrevArray[uType]->At( iDataIndex )))->Clear(); - // rising edge channel - new((*xTofTdcDataPrevArray[uType])[ iDataIndex ]) - TTofCalibData( *xCalibData ); - } // if( 1 == xUnpDataPtr->GetChannel()%2 ) - else if( NULL != xTofTdcDataPrevArray[uType]->At( iDataIndex ) ) - { - TTofCalibData* dataRisingEdge = (TTofCalibData*)(xTofTdcDataPrevArray[uType]->At( iDataIndex ) ); - if( kTRUE == dataRisingEdge->IsFilled() ) - { - Double_t dDataTime = dataRisingEdge->GetTime(); - // falling edge & rising edge present & filled - Double_t dTot = dataRisingEdge->GetTimeDifference( dCalibTime ); - - // Time offset applies to input channel, not TDC channel! - if( kTRUE == fMbsCalibPar->EnaTimeOffset() ) - dDataTime -= fMbsCalibPar->GetTimeOffsetVal( uType, uBoard, uInputChan ); - - // TDC to TDC offset - if( kTRUE == fMbsCalibPar->GetTdcOffEnaFlag(uType, uBoard) ) -// if( kTRUE == fMbsCalibPar->IsTdcOffsetEna() ) - dDataTime -= fdTdcOffsets[uType][uBoard]; - - // Tot offset applies to input channel, not TDC channel! - // Tot offset signe inverted if rising and falling inverted -// if( kTRUE == fMbsCalibPar->EnaTotOffset() ) -// dTot -= fMbsCalibPar->GetTotOffsetVal( uType, uBoard, uInputChan ) * -// ( 1 == fMbsCalibPar->GetTotInvFlag( uType, uBoard, uInputChan ) ? -1 : 1 ); - - // Use time from rising edge and newly calculated tot to create the hit - new((*fCalibDataCollection)[ fCalibDataCollection->GetEntriesFast() ]) - TTofCalibData( uType, uBoard, uInputChan, - dDataTime, - dTot, 2 ); - } // if( kTRUE == (xTofTdcDataPrevArray[uType]->At( iDataIndex ) )->IsFilled() ) - else - { - LOG(debug)<<"Cannot build ToT falling before rising. Please cross-check your cabling!"; - } - } // else if( NULL != xTofTdcDataPrevArray[uType]->At( iDataIndex ) ) - else - { - LOG(debug)<<"Cannot build ToT falling before any rising. Please cross-check your cabling!"; - } - } // for( Int_t iUnpDataInd = 0; iUnpDataInd < iNbUnpData; iUnpDataInd++ ) -// LOG(info)<<"TMbsCalibTdcTof::BuildTotSplitChannels Type "<<uType<<" Board "<<uBoard<<" N Data End "<<fCalibDataCollection->GetEntriesFast(); - - return kTRUE; -} -Bool_t TMbsCalibTdcTof::BuildTotSplitBoards( UInt_t uType ) -{ - UInt_t uNbChan = 0; - switch( uType ) - { - case toftdc::caenV1290: - uNbChan = caentdc::kuNbChan; - break; - case toftdc::vftx: - uNbChan = vftxtdc::kuNbChan; - break; - case toftdc::trb: - uNbChan = trbtdc::kuNbChan; - break; - case toftdc::get4: - uNbChan = get4tdc::kuNbChan; - if( 4 == fMbsCalibPar->GetTotMode( uType ) ) - uNbChan = get4v10::kuNbChan; - break; - default: - break; - } // switch( uType ) - - // In the case where 1 input channel correspond to a TDC channel in 2 consecutive boards, - // we can time order the hits now that we have all boards calibrated - // and then we will be able to associate the hits in full calibrated TDC data! - xTempCalibData[uType]->Sort(); - - // now build TOT - Int_t iNbCalData = xTempCalibData[uType]->GetEntriesFast(); - for( Int_t iCalDataInd = 0; iCalDataInd < iNbCalData; iCalDataInd++ ) - { - TTofCalibData * xCalibData = (TTofCalibData*) xTempCalibData[uType]->At(iCalDataInd); - - UInt_t uBoard = xCalibData->GetBoard(); - UInt_t uInputChan = xCalibData->GetChannel(); - Int_t iDataIndex = uBoard*uNbChan + uInputChan; - UInt_t uEdge = xCalibData->GetEdge(); - Double_t dCalibTime = xCalibData->GetTime(); - - if( 0 == uEdge ) - { - if( NULL != xTofTdcDataPrevArray[uType]->At( iDataIndex ) ) - ((TTofCalibData*)(xTofTdcDataPrevArray[uType]->At( iDataIndex )))->Clear(); - // rising edge channel - new((*xTofTdcDataPrevArray[uType])[ iDataIndex ]) - TTofCalibData( *xCalibData ); - } // if( 1 == xUnpDataPtr->GetChannel()%2 ) - else if( NULL != xTofTdcDataPrevArray[uType]->At( iDataIndex ) ) - { - TTofCalibData* dataRisingEdge = (TTofCalibData*)(xTofTdcDataPrevArray[uType]->At( iDataIndex ) ); - if( kTRUE == dataRisingEdge->IsFilled() ) - { - Double_t dDataTime = dataRisingEdge->GetTime(); - // falling edge & rising edge present & filled - Double_t dTot = dataRisingEdge->GetTimeDifference( dCalibTime ); - - // Time offset applies to input channel, not TDC channel! - if( kTRUE == fMbsCalibPar->EnaTimeOffset() ) - dDataTime -= fMbsCalibPar->GetTimeOffsetVal( uType, uBoard, uInputChan ); - - // TDC to TDC offset - if( kTRUE == fMbsCalibPar->GetTdcOffEnaFlag(uType, uBoard) ) -// if( kTRUE == fMbsCalibPar->IsTdcOffsetEna() ) - dDataTime -= fdTdcOffsets[uType][uBoard]; - - // Tot offset applies to input channel, not TDC channel! - // Tot offset signe inverted if rising and falling inverted - if( kTRUE == fMbsCalibPar->EnaTimeOffset() ) - dTot -= fMbsCalibPar->GetTotOffsetVal( uType, uBoard, uInputChan ) * - ( 1 == fMbsCalibPar->GetTotInvFlag( uType, uBoard, uInputChan ) ? -1 : 1 ); - - // Use time from rising edge and newly calculated tot to create the hit - new((*fCalibDataCollection)[ fCalibDataCollection->GetEntriesFast() ]) - TTofCalibData( uType, uBoard, uInputChan, - dDataTime, - dTot, 2 ); - } // if( kTRUE == (xTofTdcDataPrevArray[uType]->At( iDataIndex ) )->IsFilled() ) - } // else if( NULL != xTofTdcDataPrevArray[uType]->At( iDataIndex ) ) - } // for( Int_t iUnpDataInd = 0; iUnpDataInd < iNbUnpData; iUnpDataInd++ ) - - return kTRUE; -} - -// ------------------------------------------------------------------ -Bool_t TMbsCalibTdcTof::GetRefHistosFromUnpack() -{ - TDirectory * oldir = gDirectory; // <= To prevent histos from being sucked in by the param file of the TRootManager! - gROOT->cd(); // <= To prevent histos from being sucked in by the param file of the TRootManager ! - - // Loop over all TDC types - for( UInt_t uType = toftdc::caenV1290; uType < toftdc::NbTdcTypes; uType++ ) - { - // TODO: for now only TRB has reference channel methods implemented - if( toftdc::caenV1290 == uType || - toftdc::vftx == uType || - toftdc::get4 == uType ) - continue; - - if( 0 < fMbsUnpackPar->GetNbActiveBoards( uType ) ) - { - fhFineTimeRef[uType].resize( fMbsUnpackPar->GetNbActiveBoards( uType ) ); - - TString sInfoLoading = "Got FineTime histograms from unpack step for following "+ - toftdc::ksTdcHistName[ uType ] + " TDC reference channels:"; - LOG(info)<<sInfoLoading; - - sInfoLoading = " "; - LOG(info)<<sInfoLoading; - - // Loop over all active TDCs and all channels - for( UInt_t uTdc = 0; uTdc < fMbsUnpackPar->GetNbActiveBoards( uType ); uTdc ++) - { - sInfoLoading = Form("tdc #%3u: ",uTdc ); - - fhFineTimeRef[uType][uTdc] = (TH1*) gDirectory->FindObject( Form("tof_%s_ft_b%03u_ref", toftdc::ksTdcHistName[ uType ].Data(), - uTdc)); - if( NULL == fhFineTimeRef[uType][uTdc] ) - { - LOG(error)<<" TMbsCalibTdcTof::GetRefHistosFromUnpack => Could not get FT histo for " - <<toftdc::ksTdcHistName[ uType ]<<" #" - <<uTdc<<" reference channel from the unpack step"; - sInfoLoading += " 0 "; - gDirectory->cd( oldir->GetPath() ); // <= To prevent histos from being sucked in by the param file of the TRootManager! - return kFALSE; - } // if( NULL == fhFineTime[uType][iHistoIndex] ) - else LOG(debug)<<" TMbsCalibTdcTof::GetHistosFromUnpack =>Got FT histo for " - <<toftdc::ksTdcHistName[ uType ]<<" #" - <<uTdc<<" reference channel from the unpack step: 0x" - <<fhFineTimeRef[uType][uTdc]<<" " - <<fhFineTimeRef[uType][uTdc]->GetEntries(); - - sInfoLoading += " 1 "; - LOG(info)<<sInfoLoading; - } // for( UInt_t uTdc = 0; uTdc < fMbsUnpackPar->GetNbActiveBoards( uType ); uTdc ++) - } // if( 0 < fMbsUnpackPar->GetNbActiveBoards( uType ) ) - else LOG(info)<<" TMbsCalibTdcTof::GetRefHistosFromUnpack => no boards for "<<toftdc::ksTdcHistName[ uType ]<<" "<<uType; - } // for( UInt_t uType = toftdc::caenV1290; uType < toftdc::NbTdcTypes; uType++ ) - - gDirectory->cd( oldir->GetPath() ); // <= To prevent histos from being sucked in by the param file of the TRootManager! - - return kTRUE; -} -Bool_t TMbsCalibTdcTof::LoadCalibrationFileRef() -{ - // First check if the inital calibration file name is properly defined - if( kTRUE != fMbsCalibPar->GetInitCalFilename().EqualTo("") && - kTRUE != fMbsCalibPar->GetInitCalFilename().EqualTo("-") ) - { - // Save online ROOT directory as the File opening auto change current Dir - oldDir = gDirectory; - - TString sInitialCalibHistoName = ""; - fileCalibrationIn = new TFile( fMbsCalibPar->GetInitCalFilename(), "READ"); - - if( kTRUE == fileCalibrationIn->IsOpen() ) - { - // Loop over all TDC types - for( UInt_t uType = toftdc::caenV1290; uType < toftdc::NbTdcTypes; uType++ ) - { - // TODO: for now only TRB has reference channel methods implemented - if( toftdc::caenV1290 == uType || - toftdc::vftx == uType || - toftdc::get4 == uType ) - continue; - - if( 0 == fMbsCalibPar->GetNbCalibBoards( uType ) || - 0 == fMbsUnpackPar->GetNbActiveBoards( uType ) ) - continue; - - UInt_t uFtBinNb = 0; - - switch( uType ) - { - case toftdc::caenV1290: - uFtBinNb = caentdc::kiFineTime + 1; - break; - case toftdc::vftx: - uFtBinNb = vftxtdc::kiFifoFineTime + 1; - break; - case toftdc::trb: - uFtBinNb = trbtdc::kiFineCounterSize; - break; - case toftdc::get4: - uFtBinNb = get4tdc::kiFineTime + 1; - break; - default: - break; - } // switch( uType ) - if( 1 == uFtBinNb ) - { - LOG(info)<<"TMbsCalibTdcTof::LoadCalibrationFileRef Undefined tdc parameters for type " - <<toftdc::ksTdcHistName[ uType ]; - LOG(info)<<" => No initial calib loading!"; - continue; - } - // TODO: Does not handle the TRB case! - // One could replace trbtdc::kiFineCounterSize everywhere by trbtdc::time_FineTimeBitMask + 1 - // to handle this case like every other TDC - - TString sInfoLoading = "Loaded initial calibration histograms for following "+ - toftdc::ksTdcHistName[ uType ] + " TDC reference channel:"; - LOG(info)<<sInfoLoading; - - //define correction variables - fhInitialCalibHistoRef[ uType ].resize( fMbsCalibPar->GetNbCalibBoards( uType ), NULL ); -/* Bool_t bincontrol[uFtBinNb];*/ // Commented out to remove warning bec. unused -// Int_t iSum[fMbsCalibPar->GetNbCalibBoards( uType )][uNbChan]; - - // Temp variable to store pointer on calib histo in File - TH1* fInitialCalibHistoFromFile = 0; - - for( UInt_t uTdc = 0; uTdc < fMbsUnpackPar->GetNbActiveBoards( uType ); uTdc ++) - { - if( -1 < fMbsCalibPar->GetInitialCalInd( uType, uTdc ) ) - { - sInfoLoading = Form("tdc #%3u: ",uTdc ); - - // Initialize pointer to NULL - fInitialCalibHistoFromFile = NULL; - - // Find histogram in file and store its pointer in a temp variable - sInitialCalibHistoName = Form("tof_%s_ft_b%03d_ref", toftdc::ksTdcHistName[ uType ].Data(), - fMbsCalibPar->GetInitialCalInd( uType, uTdc ) ); - - fileCalibrationIn->GetObject( sInitialCalibHistoName, fInitialCalibHistoFromFile); - - if( NULL == fInitialCalibHistoFromFile ) - sInfoLoading += " 0 "; - else - { - sInfoLoading += " 1 "; - // Clone the found histo and move it to online ROOT directory instead of File - fhInitialCalibHistoRef[ uType ][ uTdc ] = (TH1*)fInitialCalibHistoFromFile->Clone( - Form("%s_CalibFile", sInitialCalibHistoName.Data() ) ); - fhInitialCalibHistoRef[ uType ][ uTdc ]->SetDirectory( oldDir ); - } // else of if( 0 == fInitialCalibHistoFromFile ) - - // Extract calibration factors from initialization histo - CalibFactorsInitReference( uType, uTdc ); - - LOG(info)<<sInfoLoading; - } // if( -1 < fMbsCalibPar->GetInitialCalInd( uType, uTdc ) ) - } // for( UInt_t uTdc = 0; uTdc < fMbsUnpackPar->GetNbActiveBoards( uType ); uTdc ++) - } // for( UInt_t uType = toftdc::caenV1290; uType < toftdc::NbTdcTypes; uType++ ) - - // File closing and going back to online ROOT folder - fileCalibrationIn->Close(); - gDirectory->Cd(oldDir->GetPath()); - } // if( kTRUE == fileCalibrationIn->IsOpen() ) - else - { - LOG(info)<<"Could not open "<<fMbsCalibPar->GetInitCalFilename() - <<" to load initial TDC calibration for reference channel, please check setting in Calibration option file"; - for( UInt_t uType = toftdc::caenV1290; uType < toftdc::NbTdcTypes; uType++ ) - if( 0 == fMbsCalibPar->GetNbCalibBoards( uType ) || - 0 == fMbsUnpackPar->GetNbActiveBoards( uType ) ) - continue; - else - { - // resize array and assign NULL to all pointers to avoid segmentation faults - fhInitialCalibHistoRef[ uType ].resize( fMbsCalibPar->GetNbCalibBoards( uType ), NULL ); - } - return kFALSE; - } // else of if( kTRUE == fileCalibrationIn->IsOpen() ) - } // if( sInitialCalibrationFilename OK and 1 == fMbsCalibPar->uEnableCalib) - - return kTRUE; -} -Bool_t TMbsCalibTdcTof::LoadSingleCalibrationsRef() -{ - for( UInt_t uType = toftdc::caenV1290; uType < toftdc::NbTdcTypes; uType++ ) - { - // TODO: for now only TRB has reference channel methods implemented - if( toftdc::caenV1290 == uType || - toftdc::vftx == uType || - toftdc::get4 == uType ) - continue; - - if( 0 == fMbsCalibPar->GetNbCalibBoards( uType ) || - 0 == fMbsUnpackPar->GetNbActiveBoards( uType ) ) - continue; - - UInt_t uFtBinNb = 0; - - switch( uType ) - { - case toftdc::caenV1290: - uFtBinNb = caentdc::kiFineTime + 1; - break; - case toftdc::vftx: - uFtBinNb = vftxtdc::kiFifoFineTime + 1; - break; - case toftdc::trb: - uFtBinNb = trbtdc::kiFineCounterSize; - break; - case toftdc::get4: - uFtBinNb = get4tdc::kiFineTime + 1; - break; - default: - break; - } // switch( uType ) - if( 1 == uFtBinNb ) - { - LOG(info)<<"TMbsCalibTdcTof::LoadSingleCalibrationsRef Undefined tdc parameters for type " - <<toftdc::ksTdcHistName[ uType ];; - LOG(info)<<" => No initial calib loading!"; - continue; - } - // TODO: Does not handle the TRB case! - // One could replace trbtdc::kiFineCounterSize everywhere by trbtdc::time_FineTimeBitMask + 1 - // to handle this case like every other TDC - - TString sInfoLoading = "Loaded initial calibration histograms for following "+ - toftdc::ksTdcHistName[ uType ] + " TDC reference channel:"; - LOG(info)<<sInfoLoading; - - //define correction variables - fhInitialCalibHistoRef[ uType ].resize( fMbsCalibPar->GetNbCalibBoards( uType ), NULL ); -/* Bool_t bincontrol[uFtBinNb];*/ // Commented out to remove warning bec. unused - - // Save online ROOT directory as the File opening auto change current Dir - oldDir = gDirectory; - - for( UInt_t uTdc = 0; uTdc < fMbsUnpackPar->GetNbActiveBoards( uType ); uTdc ++) - if( -1 < fMbsCalibPar->GetInitialCalInd( uType, uTdc ) ) - { - sInfoLoading = Form("tdc #%3u: ",uTdc ); - - TString sInitialCalibFileName = Form("./calib/%s_Tdc%03dRefChan.root ", toftdc::ksTdcHistName[ uType ].Data(), - fMbsCalibPar->GetInitialCalInd( uType, uTdc ) ); - TString sInitialCalibHistoName = ""; - fileCalibrationIn = new TFile( sInitialCalibFileName, "READ"); - if( kTRUE == fileCalibrationIn->IsOpen() ) - { - // Initialize pointer to NULL - TH1* fInitialCalibHistoFromFile = NULL; - sInitialCalibHistoName = Form("tof_%s_ft_b%03d_ref", toftdc::ksTdcHistName[ uType ].Data(), - fMbsCalibPar->GetInitialCalInd( uType, uTdc ) ); - - fileCalibrationIn->GetObject( sInitialCalibHistoName, fInitialCalibHistoFromFile); - - if( NULL == fInitialCalibHistoFromFile ) - sInfoLoading += " 0 "; - else - { - sInfoLoading += " 1 "; - fhInitialCalibHistoRef[ uType ][ uTdc ] = (TH1*)fInitialCalibHistoFromFile->Clone( - Form("%s_CalibFile", sInitialCalibHistoName.Data() ) ); - fhInitialCalibHistoRef[ uType ][ uTdc ]->SetDirectory( oldDir ); - - // Extract calibration factors from initialization histo - CalibFactorsInitReference( uType, uTdc ); - } // else of if( NULL == fInitialCalibHistoFromFile ) - fileCalibrationIn->Close(); - } // if( kTRUE == fileCalibrationIn->IsOpen() ) - else sInfoLoading += " 0 "; - - LOG(info)<<sInfoLoading; - } // if( -1 < fMbsCalibPar->GetInitialCalInd( uType, uTdc ) ) - } // for( UInt_t uType = toftdc::caenV1290; uType < toftdc::NbTdcTypes; uType++ ) - - return kTRUE; -} -Bool_t TMbsCalibTdcTof::CalibFactorsInitReference( UInt_t uType, UInt_t uBoard) -{ -// Double_t dClockCycle = 0.0; // -> Comment to remove warning because set but never used - UInt_t uFtBinNb = 0; - - switch( uType ) - { - case toftdc::caenV1290: -// dClockCycle = caentdc::kdClockCycleSize; // -> Comment to remove warning because set but never used - uFtBinNb = caentdc::kiFineTime + 1; - break; - case toftdc::vftx: -// dClockCycle = vftxtdc::kdClockCycleSize; // -> Comment to remove warning because set but never used - uFtBinNb = vftxtdc::kiFifoFineTime + 1; - break; - case toftdc::trb: -// dClockCycle = trbtdc::kdClockCycleSize; // -> Comment to remove warning because set but never used - uFtBinNb = trbtdc::kiFineCounterSize; - break; - case toftdc::get4: -// dClockCycle = get4tdc::kdClockCycleSize; // -> Comment to remove warning because set but never used - uFtBinNb = get4tdc::kiFineTime + 1; - break; - default: - break; - } // switch( uType ) - - if( NULL != fhInitialCalibHistoRef[ uType ][ uBoard ]) - { - // Reset Histos with DNL ploting -// fhDnlChan[uType][uBoard]->Reset(); -// fhDnlSum[uType][uBoard]->Reset(); -// fhBinSizeChan[uType][uBoard]->Reset(); - - //set the sum to zero before summing over all bins in one channel - Bool_t bincontrol[uFtBinNb]; - Int_t iSum = 0; - - Double_t dTotalEntriesInHisto = (Double_t)(fhInitialCalibHistoRef[ uType ][ uBoard ]->GetEntries() ); - - for(Int_t iBin = 0; iBin < (Int_t)uFtBinNb; iBin++) - { - Int_t iBinContent = (Int_t)(fhInitialCalibHistoRef[ uType ][ uBoard ]->GetBinContent(iBin+1)); - //Looking for the used bins - if( iBinContent <= 0) - bincontrol[iBin] = kFALSE; - else if( iBinContent > 0) - bincontrol[iBin] = kTRUE; - - // build the sum of all bin content - if(bincontrol[iBin]) - { - iSum = iSum + iBinContent; - fdCorrRef[uType][uBoard][iBin] = (Double_t)iSum / dTotalEntriesInHisto; -// fhDnlChan[uType][uBoard]->Fill(iBin, (Double_t)iBinContent/dTotalEntriesInHisto ); -// fhBinSizeChan[uType][uBoard]->Fill( dClockCycle*(Double_t)iBinContent/dTotalEntriesInHisto ); - } // if(bincontrol[iBin]) - else - { - if( 0 < iBin) - fdCorrRef[uType][uBoard][iBin] = fdCorrRef[uType][uBoard][iBin-1]; - else fdCorrRef[uType][uBoard][iBin] = 0.0; - } // else of if(bincontrol[iBin]) -// fhDnlSum[uType][uBoard]->Fill(iBin, fdCorrRef[uType][uBoard][iBin] ); - } // for(Int_t iBin=0; iBin < (Int_t)uFtBinNb; iBin++) - } // if( NULL != fhInitialCalibHistoRef[uTdc][uBoard]) - else return kFALSE; - - return kTRUE; -} -Bool_t TMbsCalibTdcTof::CalibFactorsCalcReference( UInt_t uType, UInt_t uBoard, Bool_t bWithInitial ) -{ -// Double_t dClockCycle = 0.0; - UInt_t uFtBinNb = 0; - - switch( uType ) - { - case toftdc::caenV1290: -// dClockCycle = caentdc::kdClockCycleSize; // -> Comment to remove warning because set but never used - uFtBinNb = caentdc::kiFineTime + 1; - break; - case toftdc::vftx: -// dClockCycle = vftxtdc::kdClockCycleSize; // -> Comment to remove warning because set but never used - uFtBinNb = vftxtdc::kiFifoFineTime + 1; - break; - case toftdc::trb: -// dClockCycle = trbtdc::kdClockCycleSize; // -> Comment to remove warning because set but never used - uFtBinNb = trbtdc::kiFineCounterSize; - break; - case toftdc::get4: -// dClockCycle = get4tdc::kdClockCycleSize; // -> Comment to remove warning because set but never used - uFtBinNb = get4tdc::kiFineTime + 1; - break; - default: - break; - } // switch( uType ) - - // define correction variables - // & set the sum to zero before summing over all bins in one channel - Bool_t bincontrol[uFtBinNb]; - Int_t iSum = 0; - - if( kTRUE == bWithInitial ) - { - // Use both initial calibration histograms and new data - // To extract the correction factors - if( NULL != fhInitialCalibHistoRef[ uType ][ uBoard ]) - { - // Reset Histos with DNL ploting -// fhDnlChan[uType][uBoard]->Reset(); -// fhDnlSum[uType][uBoard]->Reset(); -// fhBinSizeChan[uType][uBoard]->Reset(); - - Double_t dTotalEntriesInHisto = (Double_t)(fhFineTimeRef[ uType ][ uBoard ]->GetEntries() ) + - (Double_t)(fhInitialCalibHistoRef[ uType ][ uBoard ]->GetEntries() ); - - for(Int_t iBin = 0; iBin < (Int_t)uFtBinNb; iBin++) - { - Int_t iBinContent = (Int_t)(fhFineTimeRef[ uType ][ uBoard ]->GetBinContent(iBin+1)) + - (Int_t)(fhInitialCalibHistoRef[ uType ][ uBoard ]->GetBinContent(iBin+1)); - //Looking for the used bins - if( iBinContent <= 0) - bincontrol[iBin] = kFALSE; - else if( iBinContent > 0) - bincontrol[iBin] = kTRUE; - - // build the sum of all bin content - if(bincontrol[iBin]) - { - iSum = iSum + iBinContent; - fdCorr[uType][uBoard][iBin] = (Double_t)iSum / dTotalEntriesInHisto; - //TODO-CHS: must be fdCorrRef!!! - -// fhDnlChan[uType][iHistoIndex]->Fill(iBin, (Double_t)iBinContent/dTotalEntriesInHisto ); -// fhBinSizeChan[uType][iHistoIndex]->Fill( dClockCycle*(Double_t)iBinContent/dTotalEntriesInHisto ); - } // if(bincontrol[iBin]) - else - { - if( 0 < iBin) - fdCorrRef[uType][uBoard][iBin] = fdCorrRef[uType][uBoard][iBin-1]; - else fdCorrRef[uType][uBoard][iBin] = 0.0; - } // else of if(bincontrol[iBin]) -// fhDnlSum[uType][iHistoIndex]->Fill(iBin, fdCorrRef[uType][iHistoIndex][iBin] ); - } // for(Int_t iBin=0; iBin < (Int_t)uFtBinNb; iBin++) - return kTRUE; - } // if( NULL != fhInitialCalibHistoRef[ uType ][ uBoard ]) - } // if( kTRUE == bWithInitial ) - - // If either choice to use only new data or initial histo missing - // => Use only new data to extract the correction factors - - // Reset Histos with DNL ploting -// fhDnlChan[uType][uBoard]->Reset(); -// fhDnlSum[uType][uBoard]->Reset(); -// fhBinSizeChan[uType][uBoard]->Reset(); - - Double_t dTotalEntriesInHisto = (Double_t)(fhFineTimeRef[ uType ][ uBoard ]->GetEntries() ); - - for(Int_t iBin = 0; iBin < (Int_t)uFtBinNb; iBin++) - { - Int_t iBinContent = (Int_t)(fhFineTimeRef[ uType ][ uBoard ]->GetBinContent(iBin+1)); - //Looking for the used bins - if( iBinContent <= 0) - bincontrol[iBin] = kFALSE; - else if( iBinContent > 0) - bincontrol[iBin] = kTRUE; - - // build the sum of all bin content - if(bincontrol[iBin]) - { - iSum = iSum + iBinContent; - fdCorr[uType][uBoard][iBin] = (Double_t)iSum / dTotalEntriesInHisto; - //TODO-CHS: must be fdCorrRef!!! - -// fhDnlChan[uType][uBoard]->Fill(iBin, (Double_t)iBinContent/dTotalEntriesInHisto ); -// fhBinSizeChan[uType][uBoard]->Fill( dClockCycle*(Double_t)iBinContent/dTotalEntriesInHisto ); - } // if(bincontrol[iBin]) - else - { - if( 0 < iBin) - fdCorrRef[uType][uBoard][iBin] = fdCorrRef[uType][uBoard][iBin-1]; - else fdCorrRef[uType][uBoard][iBin] = 0.0; - } // else of if(bincontrol[iBin]) -// fhDnlSum[uType][uBoard]->Fill(iBin, fdCorrRef[uType][uBoard][iBin] ); - } // for(Int_t iBin=0; iBin < (Int_t)uFtBinNb; iBin++) - return kTRUE; -} -Bool_t TMbsCalibTdcTof::WriteCalibrationFileRef( TString outDir ) -{ - gDirectory->Cd( outDir ); - for( UInt_t uType = toftdc::caenV1290; uType < toftdc::NbTdcTypes; uType++ ) - { - // TODO: for now only TRB has reference channel methods implemented - if( toftdc::caenV1290 == uType || - toftdc::vftx == uType || - toftdc::get4 == uType ) - continue; - - if( 0 < fMbsUnpackPar->GetNbActiveBoards( uType ) ) - { - UInt_t uNbChan = 0; - - switch( uType ) - { - case toftdc::caenV1290: - uNbChan = caentdc::kuNbChan; - break; - case toftdc::vftx: - uNbChan = vftxtdc::kuNbChan; - break; - case toftdc::trb: - uNbChan = trbtdc::kuNbChan; - break; - case toftdc::get4: - uNbChan = get4tdc::kuNbChan; - if( 4 == fMbsCalibPar->GetTotMode( uType ) ) - uNbChan = get4v10::kuNbChan; - break; - default: - break; - } // switch( uType ) - if( 0 == uNbChan ) - { - LOG(info)<<"TMbsCalibTdcTof::WriteCalibrationFileRef Undefined tdc parameters for type " - <<toftdc::ksTdcHistName[ uType ]; - LOG(info)<<" => No calib histo saving!"; - continue; - } - - TString sInfoSaving = "Saved initial calibration histograms for following " - + toftdc::ksTdcHistName[ uType ] +" reference channel:"; - LOG(info)<<sInfoSaving; - - for( UInt_t uTdc = 0; uTdc < fMbsUnpackPar->GetNbActiveBoards( uType ); uTdc ++) - { - sInfoSaving = Form("tdc #%3u: ",uTdc ); - TString sCalibHistoOutputName = Form("tof_%s_ft_b%03u_ref", toftdc::ksTdcHistName[ uType ].Data(), - uTdc ); - - // New Calibration histo using only new data - if( 0 < (fhFineTimeRef[ uType ][ uTdc ]->GetEntries() ) ) - { - fhFineTimeRef[ uType ][ uTdc ]->Write( sCalibHistoOutputName, TObject::kOverwrite); - sInfoSaving += " 1 "; - } // if( 0 < (fhFineTime[ uType ][ uTdc ]->GetEntries() ) ) - else sInfoSaving += " 0 "; - LOG(info)<<sInfoSaving; - } // for( UInt_t uTdc = 0; uTdc < fMbsCalibPar->GetNbCalibBoards( uType ); uTdc ++) - } // if( 0 < fMbsUnpackPar->GetNbActiveBoards( uType ) ) - } // for( UInt_t uType = toftdc::caenV1290; uType < toftdc::NbTdcTypes; uType++ ) - return kTRUE; -} -Bool_t TMbsCalibTdcTof::WriteSingleCalibrationsRef() -{ - for( UInt_t uType = toftdc::caenV1290; uType < toftdc::NbTdcTypes; uType++ ) - { - // TODO: for now only TRB has reference channel methods implemented - if( toftdc::caenV1290 == uType || - toftdc::vftx == uType || - toftdc::get4 == uType ) - continue; - - if( 0 < fMbsUnpackPar->GetNbActiveBoards( uType ) ) - { - UInt_t uNbChan = 0; - - switch( uType ) - { - case toftdc::caenV1290: - uNbChan = caentdc::kuNbChan; - break; - case toftdc::vftx: - uNbChan = vftxtdc::kuNbChan; - break; - case toftdc::trb: - uNbChan = trbtdc::kuNbChan; - break; - case toftdc::get4: - uNbChan = get4tdc::kuNbChan; - if( 4 == fMbsCalibPar->GetTotMode( uType ) ) - uNbChan = get4v10::kuNbChan; - break; - default: - break; - } // switch( uType ) - if( 0 == uNbChan ) - { - LOG(info)<<"TMbsCalibTdcTof::WriteSingleCalibrationsRef Undefined tdc parameters for type " - <<toftdc::ksTdcHistName[ uType ]; - LOG(info)<<" => No calib histo saving!"; - continue; - } - - TString sInfoSaving = "Saved initial calibration histograms for following " - + toftdc::ksTdcHistName[ uType ] +" reference channel:"; - LOG(info)<<sInfoSaving; - - // Save current directory as TFile opening change it! - oldDir = gDirectory; - - // Check if initial histos arrays was created - Bool_t bBoardInitialThere = kFALSE; - if( fhInitialCalibHisto[ uType ].size() == fMbsUnpackPar->GetNbActiveBoards( uType )*uNbChan ) - bBoardInitialThere = kTRUE; - - for( UInt_t uTdc = 0; uTdc < fMbsUnpackPar->GetNbActiveBoards( uType ); uTdc ++) - { - sInfoSaving = Form("tdc #%3u: ",uTdc ); - - Bool_t bDataToSave = kFALSE; - Bool_t bInitialThere = kFALSE; - - if( kTRUE == bBoardInitialThere ) - if( NULL != fhInitialCalibHistoRef[ uType ][ uTdc ] ) - bInitialThere = kTRUE; - - if( 0 < (fhFineTimeRef[ uType ][ uTdc ]->GetEntries() ) ) - bDataToSave = kTRUE; - - if( 1 == fMbsCalibPar->GetSingleCalOutMode() || kFALSE == bInitialThere ) - { - if( kTRUE == bDataToSave ) - { - TString sCalibOutFilename = Form("./calib/%s_Tdc%03uRefChan.root", - toftdc::ksTdcHistName[ uType ].Data(), - uTdc); - TFile* fileCalibrationOut = new TFile( sCalibOutFilename, "RECREATE", - Form("Calibration Data for %s TDC %03d Reference channel ", - toftdc::ksTdcHistName[ uType ].Data(), - uTdc ), - 9); - if( kTRUE == fileCalibrationOut->IsOpen() ) - { - sCalibOutFilename += ":/"; - gDirectory->Cd(sCalibOutFilename); - TString sCalibHistoOutputName = Form("tof_%s_ft_b%03u_ref", toftdc::ksTdcHistName[ uType ].Data(), - uTdc ); - fhFineTimeRef[ uType ][ uTdc ]->Write( sCalibHistoOutputName, TObject::kOverwrite); - sInfoSaving += " 1 "; - - //fileCalibrationOut->Write("",TObject::kOverwrite); - fileCalibrationOut->Close(); - gDirectory->Cd(oldDir->GetPath()); - } // if( kTRUE == fileCalibrationOut->IsOpen() ) - else sInfoSaving += " 0 "; - } // if( kTRUE == bDataToSave ) - else sInfoSaving += " 0 "; - } // if( 1 == fMbsCalibPar->GetSingleCalOutMode() || kFALSE == bInitialThere ) - else if( kTRUE == bDataToSave ) - { - // Update old calibration histo with new data - TString sCalibOutFilename = Form("./calib/%s_Tdc%03uRefChan.root ", - toftdc::ksTdcHistName[ uType ].Data(), - uTdc ); - TFile* fileCalibrationOut = new TFile( sCalibOutFilename, "RECREATE", - Form("Calibration Data for %s TDC %03u Reference", - toftdc::ksTdcHistName[ uType ].Data(), - uTdc ), - 9); - if( kTRUE == fileCalibrationOut->IsOpen() ) - { - sCalibOutFilename += ":/"; - gDirectory->Cd(sCalibOutFilename); - TString sCalibHistoOutputName = Form("tof_%s_ft_b%03d_ref", toftdc::ksTdcHistName[ uType ].Data(), - fMbsCalibPar->GetInitialCalInd( uType, uTdc ) ); - // Try to update old calibration histo with new data - fhInitialCalibHistoRef[ uType ][ uTdc ]->Add( fhFineTimeRef[ uType ][ uTdc ] ); - fhInitialCalibHistoRef[ uType ][ uTdc ]->Write( sCalibHistoOutputName, TObject::kOverwrite); - sInfoSaving += " 1 "; - - //fileCalibrationOut->Write("",TObject::kOverwrite); - fileCalibrationOut->Close(); - gDirectory->Cd(oldDir->GetPath()); - } // if( kTRUE == fileCalibrationOut->IsOpen() ) - else sInfoSaving += " 0 "; - } // else of if( 1 == fMbsCalibPar->uSingleChannelCalibFilesOutput ) - // No new Data => no need to update calibration!!! - else sInfoSaving += " 0 "; - - LOG(info)<<sInfoSaving; - } // for( UInt_t uTdc = 0; uTdc < fMbsCalibPar->GetNbCalibBoards( uType ); uTdc ++) - - // Go back to original directory - gDirectory->Cd(oldDir->GetPath()); - } // if( 0 < fMbsUnpackPar->GetNbActiveBoards( uType ) ) - } // for( UInt_t uType = toftdc::caenV1290; uType < toftdc::NbTdcTypes; uType++ ) - - return kTRUE; -} -Bool_t TMbsCalibTdcTof::CalibrateReference(UInt_t uType, UInt_t uBoard) -{ - // TODO: Make it TRB specific: use TRB board and TRB data and reject all othe TDC types - LOG(debug)<<"TMbsCalibTdcTof::CalibrateReference => Type "<<uType - <<" Active bd "<<fMbsUnpackPar->GetNbActiveBoards( uType ) - <<" Board "<<uBoard; - if( uBoard < fMbsUnpackPar->GetNbActiveBoards( uType ) ) - { - // TDC type specific values -// UInt_t uNbChan = 0; // -> Comment to remove warning because set but never used - TClonesArray * xUnpDataArray = NULL; - Double_t dClockCycle = 0.0; - Bool_t bInvertFt = kFALSE; -/* Double_t dTotBinToPs = 0.0;*/ // Commented out to remove warning bec. unused -// Int_t iCoarseSize = 0; // -> Comment to remove warning because set but never used -// Int_t iCoarseOfLim = 0; // -> Comment to remove warning because set but never used - switch( uType ) - { - case toftdc::caenV1290: -/* - uNbChan = caentdc::kuNbChan; - xUnpDataArray = fCaenBoardCollection; - dClockCycle = caentdc::kdClockCycleSize; - bInvertFt = caentdc::kbInvertFt; - iCoarseSize = caentdc::kiCoarseCounterSize; - iCoarseOfLim = caentdc::kuCoarseOverflowTest; -*/ - return kFALSE; - break; - case toftdc::vftx: -/* - uNbChan = vftxtdc::kuNbChan; - xUnpDataArray = fVftxBoardCollection; - dClockCycle = vftxtdc::kdClockCycleSize; - bInvertFt = vftxtdc::kbInvertFt; - iCoarseSize = vftxtdc::kiCoarseCounterSize; - iCoarseOfLim = vftxtdc::kuCoarseOverflowTest; -*/ - return kFALSE; - break; - case toftdc::trb: -// uNbChan = trbtdc::kuNbChan; // -> Comment to remove warning because set but never used - xUnpDataArray = fTrb3BoardCollection; - dClockCycle = trbtdc::kdClockCycleSize; - bInvertFt = trbtdc::kbInvertFt; -// iCoarseSize = trbtdc::kiCoarseCounterSize; // -> Comment to remove warning because set but never used -// iCoarseOfLim = trbtdc::kuCoarseOverflowTest; // -> Comment to remove warning because set but never used - break; - case toftdc::get4: -/* - uNbChan = get4tdc::kuNbChan; - xUnpDataArray = fGet4BoardCollection; - dClockCycle = get4tdc::kdClockCycleSize; - bInvertFt = get4tdc::kbInvertFt; - dTotBinToPs = get4tdc::kdTotBinSize; - iCoarseSize = get4tdc::kiCoarseCounterSize; - iCoarseOfLim = get4tdc::kuCoarseOverflowTest; - if( 4 == fMbsCalibPar->GetTotMode( uType ) ) - uNbChan = get4v10::kuNbChan; -*/ - return kFALSE; - break; - default: - return kFALSE; - break; - } // switch( uType ) - - // Getting access to the Board object and to the output object - TTofCalibData * pCalibRef = (TTofCalibData*) fCalibRefCollection[uType]->ConstructedAt(uBoard); - if( NULL == xUnpDataArray || - NULL == fCalibRefCollection[uType] || - 0 == pCalibRef ) - { - LOG(error)<<"TMbsCalibTdcTof::Calibration => Data pt failed Type "<<uType - <<" Active bd "<<fMbsUnpackPar->GetNbActiveBoards( uType ) - <<" Board "<<uBoard<<" Unp array "<<xUnpDataArray<<" CalibRefCollection "<<(fCalibRefCollection[uType]) - <<" CalibRef object "<<pCalibRef; - return kFALSE; - } - - // Board raw data recovery - TTofTrbTdcBoard * xBoardUnpData = (TTofTrbTdcBoard*) xUnpDataArray->At(uBoard); - - if( NULL == xBoardUnpData ) - { - fdTdcReference[uType][uBoard] = -1.0; - LOG(error)<<"TMbsCalibTdcTof::Calibration => Bd pt failed Type "<<uType - <<" Active bd "<<fMbsUnpackPar->GetNbActiveBoards( uType ) - <<" Board "<<uBoard; - return kFALSE; - } // if( NULL == xBoardUnpData ) - - if( kFALSE == xBoardUnpData->IsValid() ) - { - fdTdcReference[uType][uBoard] = -1.0; - LOG(debug)<<"TMbsCalibTdcTof::Calibration => Bd data invalid Type "<<uType - <<" Active bds "<<fMbsUnpackPar->GetNbActiveBoards( uType ) - <<" Board "<<uBoard; - return kFALSE; - } // if( kFALSE == xBoardUnpData->IsValid() ) - - TTofTrbTdcData& xUnpDataRef = xBoardUnpData->GetRefChannelData(); // - - // In order to avoid big numbers after conversion to double float - // (precision loss), subtract part of the main board trigger time counter - Int_t iMainTriggerCoarseTime = 0; - if( NULL != (TTofTdcBoard*) xUnpDataArray->At(fMbsCalibPar->GetTdcOffsetMainTdc()) ) - if( kTRUE == ( (TTofTdcBoard*) xUnpDataArray->At(fMbsCalibPar->GetTdcOffsetMainTdc()) )->IsValid() ) - if( toftdc::trb == uType ) - { - TTofTrbTdcData& xUnpDataRefMain = ((TTofTrbTdcBoard*) xUnpDataArray->At( - fMbsCalibPar->GetTdcOffsetMainTdc() ))->GetRefChannelData(); - iMainTriggerCoarseTime = xUnpDataRefMain.GetCoarseTime(); - } - - Int_t iCoarseTime = xUnpDataRef.GetCoarseTime(); - if( kTRUE == fMbsCalibPar->UseCoarse() ) - { - // In order to avoid big numbers after conversion to double float - // (precision loss), subtract part of the main board trigger time counter - // Use for now 128 clock cycle (~600ns for trb) -// iCoarseTime -= iMainTriggerCoarseTime & 0x7FFFFF80; - iCoarseTime -= iMainTriggerCoarseTime & 0x7FFFFFFF; - } // if( kTRUE == fMbsCalibPar->UseCoarse() - fdTdcReference[uType][uBoard] = dClockCycle * iCoarseTime; - //TODO: The total coarse time range (including the epoch counter) spans - // values between [0, 2^39-1] or [0, 5.5e11]. The double floating - // point precision is 1,1e-16. The coarse counter granularity is 5 ns. - // The maximum time measurable by a TRB-TDC, 5.5e11*5 ns = 2.7e12 ns, - // would have a maximum absolute error of 0.3 ps if stored in a - // double floating point variable which is sufficient for our calculations. - - Int_t iNbEntriesFtHist = fhFineTimeRef[uType][uBoard]->GetEntries(); - if( NULL != fhInitialCalibHistoRef[uType][uBoard]) - iNbEntriesFtHist += fhInitialCalibHistoRef[uType][uBoard]->GetEntries(); - Int_t iNbHitsThisCh = fhFineTimeRef[uType][uBoard]->GetEntries(); - - // FIXME: for TRB TDC, first try to prevent invalid FT from being processed - if( toftdc::trb != uType || 0x3ff != xUnpDataRef.GetFineTime() ) - { - if( 0 < fMbsCalibPar->GetMinHitCalib() && - iNbEntriesFtHist < fMbsCalibPar->GetMinHitCalib() ) - { - // Use initial calibration values or linear calibration with data limits for TRB-TDC - if( toftdc::trb == uType && kTRUE == fMbsCalibPar->IsTrbLinCalEna() ) - { - if( kTRUE == bInvertFt ) - fdTdcReference[uType][uBoard] += dClockCycle - * ( 1 - (Double_t)(xUnpDataRef.GetFineTime() - fiLinCalRefMinBin[uType][uBoard]) - / (Double_t)(fiLinCalRefMaxBin[uType][uBoard] - fiLinCalRefMinBin[uType][uBoard]) ); - else fdTdcReference[uType][uBoard] += dClockCycle - * (Double_t)(xUnpDataRef.GetFineTime() - fiLinCalRefMinBin[uType][uBoard]) - / (Double_t)(fiLinCalRefMaxBin[uType][uBoard] - fiLinCalRefMinBin[uType][uBoard]); - } // if( toftdc::trb == uType && kTRUE == fMbsCalibPar->IsTrbLinCalEna()) - } // else if( iNbEntriesFtHist < fMbsCalibPar->GetMinHitCalib() ) - else - { - // Use standard calibration method - if( kTRUE == bInvertFt ) - fdTdcReference[uType][uBoard] += dClockCycle *( 1 - fdCorrRef[uType][uBoard][xUnpDataRef.GetFineTime()] ); - else fdTdcReference[uType][uBoard] += dClockCycle * fdCorrRef[uType][uBoard][xUnpDataRef.GetFineTime()]; - } // else of if( iNbEntriesFtHist < fMbsCalibPar->GetMinHitCalibNewOnly() ) - - pCalibRef->SetType( uType ); // For consistency cross check - pCalibRef->SetBoard( uBoard ); // For consistency cross check - pCalibRef->SetChannel( 0xFFFFFFFF ); // Fixed value for consistency cross check - pCalibRef->SetEdge( 3 ); // For consistency cross check (0 = Rising, 1 = Falling, 2 = Full Chan ) - pCalibRef->SetTime( fdTdcReference[uType][uBoard] ); // Reference time - pCalibRef->SetTot( -1.0 ); // Fixed value for cross check - pCalibRef->SetFilled(); - } // if( toftdc::trb != uType || 0x3ff != xUnpDataRef.GetFineTime() ) - - if( 0 < fMbsCalibPar->GetMinHitCalib() ) - { - // Check if initial calibration histograms are available - Bool_t bInitialThere = kFALSE; - if( kTRUE == bInitialThere ) - if( NULL != fhFineTimeRef[ uType ][ uBoard ] ) - bInitialThere = kTRUE; - //TODO: The above piece of code is never executed!!! - - // Check whether we should use the initial calibration on top of the new data - Bool_t bUseInitial = bInitialThere; - if( 0 < fMbsCalibPar->GetMinHitCalibNewOnly() && - fMbsCalibPar->GetMinHitCalibNewOnly() <= iNbHitsThisCh ) - bUseInitial = kFALSE; - - if( 0 < iNbHitsThisCh && - 0 == iNbHitsThisCh % fMbsCalibPar->GetMinHitCalib() ) - CalibFactorsCalcReference( uType, uBoard, bUseInitial); - } // if( 0 < fMbsCalibPar->GetMinHitCalib() ) - - // Update limits with real counts for linear calibration - if( 1000 < iNbHitsThisCh && - iNbHitsThisCh < fMbsCalibPar->GetMinHitCalib() ) // <= To use for limits updates - { - Int_t iBin = 0; - Int_t iNbCounts = 0; - - while( 0 == fhFineTimeRef[uType][uBoard]->GetBinContent(iBin) ) - iBin++; - fiLinCalRefMinBin[uType][uBoard] = iBin; - - iNbCounts = fhFineTimeRef[uType][uBoard]->GetBinContent(iBin); - while( fhFineTimeRef[uType][uBoard]->GetEntries() > iNbCounts ) - { - iBin++; - iNbCounts += fhFineTimeRef[uType][uBoard]->GetBinContent(iBin); - } // while( fhFineTimeRef[uType][uBoard]->GetEntries() > iNbCounts ) - fiLinCalRefMaxBin[uType][uBoard] = iBin; - } // if( 1000 < iNbEntriesFtHist) // <= To use for limits updates - - } // if( 0 < fMbsUnpackPar->GetNbActiveBoards( uType ) ) - else return kFALSE; - - return kTRUE; -} -Bool_t TMbsCalibTdcTof::ClearTdcReference() -{ - // Loop over all TDC types - for( UInt_t uType = toftdc::caenV1290; uType < toftdc::NbTdcTypes; uType++ ) - { - for( UInt_t uTdc = 0; uTdc < fMbsUnpackPar->GetNbActiveBoards( uType ); uTdc ++) - { - fdTdcOffsets[ uType ][ uTdc ] = 0.0; - fdTdcReference[uType][uTdc] = -1; - } // for( UInt_t uTdc = 0; uTdc < fMbsUnpackPar->GetNbActiveBoards( uType ); uTdc ++) - } // for( UInt_t uType = toftdc::caenV1290; uType < toftdc::NbTdcTypes; uType++ ) - return kTRUE; -} -Bool_t TMbsCalibTdcTof::TdcOffsetCalc(UInt_t uType, UInt_t uBoard) -{ - LOG(debug)<<"TMbsCalibTdcTof::TdcOffsetCalc => Type "<<uType - <<" Active bd "<<fMbsUnpackPar->GetNbActiveBoards( uType ) - <<" Board "<<uBoard; - if( uBoard < fMbsUnpackPar->GetNbActiveBoards( uType ) ) - { - if( -1 != fdTdcReference[uType][uBoard] && - -1 != fdTdcReference[ uType ][ fMbsCalibPar->GetTdcOffsetMainTdc() ] ) - { - // TDC type specific values - Double_t dClockCycle = 0.0; - switch( uType ) - { - case toftdc::caenV1290: - return kFALSE; - break; - case toftdc::vftx: - return kFALSE; - break; - case toftdc::trb: - dClockCycle = trbtdc::kdClockCycleSize; - break; - case toftdc::get4: - return kFALSE; - break; - default: - return kFALSE; - break; - } // switch( uType ) -/* - fdTdcOffsets[ uType ][ uBoard ] = fdTdcReference[ uType ][ uBoard ] - - fdTdcReference[ uType ][ fMbsCalibPar->GetTdcOffsetMainTdc() ]; -*/ - // New method to detect only offset modulo the clock cycle - fdTdcOffsets[ uType ][ uBoard ] = dClockCycle * (Int_t)( - ( fdTdcReference[ uType ][ uBoard ] - - fdTdcReference[ uType ][ fMbsCalibPar->GetTdcOffsetMainTdc() ] - + dClockCycle/2 - )/(dClockCycle) - + (fdTdcReference[ uType ][ uBoard ] - < fdTdcReference[ uType ][ fMbsCalibPar->GetTdcOffsetMainTdc()]? -1 : 0) ); - LOG(debug)<<"TMbsCalibTdcTof::TdcOffsetCalc => Type "<<uType - <<" Ref " <<fdTdcReference[ uType ][ uBoard ] - <<" Main Ref "<<fdTdcReference[ uType ][ fMbsCalibPar->GetTdcOffsetMainTdc() ] - <<" Offset " <<fdTdcOffsets[ uType ][ uBoard ]; - } // if both values OK - } // if( 0 < fMbsUnpackPar->GetNbActiveBoards( uType ) ) - else - { - fdTdcOffsets[ uType ][ uBoard ] = 0.0; - return kFALSE; - } // else of if( 0 < fMbsUnpackPar->GetNbActiveBoards( uType ) ) - - return kTRUE; -} -Bool_t TMbsCalibTdcTof::CreateReferenceHistogramms() -{ - // Loop over all TDC types - for( UInt_t uType = toftdc::caenV1290; uType < toftdc::NbTdcTypes; uType++ ) - { - // TODO: for now only TRB has reference channel methods implemented - if( toftdc::caenV1290 == uType || - toftdc::vftx == uType || - toftdc::get4 == uType ) -{ - LOG(info)<<"TMbsCalibTdcTof::CreateReferenceHistogramms => Type "<<uType - <<" not allowed "; - continue; -} - - if( 0 < fMbsUnpackPar->GetNbActiveBoards( uType ) ) - { -/* // -> Comment to remove warning because set but never used - UInt_t uNbChan = 0; - Double_t dClockCycle = 0.0; - UInt_t uFtBinNb = 0; - UInt_t uMaxMul = 0; - - switch( uType ) - { - case toftdc::caenV1290: - uNbChan = caentdc::kuNbChan; - dClockCycle = caentdc::kdClockCycleSize; - uFtBinNb = caentdc::kiFineTime + 1; - uMaxMul = toftdc::kuDefNbMulti; // TODO: add proper value for this type - break; - case toftdc::vftx: - uNbChan = vftxtdc::kuNbChan; - dClockCycle = vftxtdc::kdClockCycleSize; - uFtBinNb = vftxtdc::kiFifoFineTime + 1; - uMaxMul = vftxtdc::kuNbMulti; - break; - case toftdc::trb: - uNbChan = trbtdc::kuNbChan; - dClockCycle = trbtdc::kdClockCycleSize; - uFtBinNb = trbtdc::kiFineCounterSize; - uMaxMul = toftdc::kuDefNbMulti; // TODO: add proper value for this type - break; - case toftdc::get4: - uNbChan = get4tdc::kuNbChan; - dClockCycle = get4tdc::kdClockCycleSize; - uFtBinNb = get4tdc::kiFineTime + 1; - uMaxMul = toftdc::kuDefNbMulti; // TODO: add proper value for this type - if( 4 == fMbsCalibPar->GetTotMode( uType ) ) - uNbChan = get4v10::kuNbChan; - break; - default: - break; - } // switch( uType ) -*/ - LOG(info)<<"TMbsCalibTdcTof::CreateReferenceHistogramms => Create Histo for Type "<<uType - <<" Nb active boards: " << fMbsUnpackPar->GetNbActiveBoards( uType ) - <<" Name pattern: " << toftdc::ksTdcHistName[ uType ].Data(); - - // Reference histograms initialization - Int_t iNbBoards = fMbsUnpackPar->GetNbActiveBoards( uType ); - fhTdcReferenceComp[uType].resize( iNbBoards - 1, NULL ); - if( -1 < fMbsCalibPar->GetChanResTest() ) - { - fhTdcResolutionTest[uType].resize( iNbBoards - 1, NULL ); - fhTdcTestToRef[uType].resize( iNbBoards, NULL ); - } // if( -1 < fMbsCalibPar->GetChanResTest() ) - for( Int_t iTdc = 0; iTdc < iNbBoards - 1; iTdc ++) - { - if( -1 < fMbsCalibPar->GetChanResTest() ) - fhTdcReferenceComp[uType][iTdc] = new TH2I( - Form("tof_%s_RefChComp_b%03d", toftdc::ksTdcHistName[ uType ].Data(), iTdc), - Form("Comparison of the reference channels of %s TDC #%03d to all other TDC of same type; TDC#n []; Ref(TDC#n) -Ref(TDC #%03d)", - toftdc::ksTdcHistName[ uType ].Data(), iTdc, iTdc), - iNbBoards -1 -iTdc, iTdc +1 -0.5, iNbBoards -0.5, - 10000, -50000, 50000 ); - else fhTdcReferenceComp[uType][iTdc] = new TH2I( - Form("tof_%s_RefChComp_b%03d", toftdc::ksTdcHistName[ uType ].Data(), iTdc), - Form("Comparison of the reference channels of %s TDC #%03d to all other TDC of same type; TDC#n []; Ref(TDC#n) -Ref(TDC #%03d)", - toftdc::ksTdcHistName[ uType ].Data(), iTdc, iTdc), - iNbBoards -1 -iTdc, iTdc +1 -0.5, iNbBoards -0.5, - 80000, -800000, 800000 ); - if( -1 < fMbsCalibPar->GetChanResTest() ) - fhTdcResolutionTest[uType][iTdc] = new TH2I( - Form("tof_%s_ResoTest_b%03d", toftdc::ksTdcHistName[ uType ].Data(), iTdc), - Form("Comparison of the channel %03d of %s TDC #%03d to all other TDC of same type; TDC#n []; t(TDC#n) -t(TDC #%03d)", - fMbsCalibPar->GetChanResTest(), toftdc::ksTdcHistName[ uType ].Data(), iTdc, iTdc), - iNbBoards -1 -iTdc, iTdc +1 -0.5, iNbBoards -0.5, - 10000, -50000, 50000 ); - LOG(debug2)<<"TMbsCalibTdcTof::CreateReferenceHistogramms => Create Histo " - <<Form("tof_%s_RefChComp_b%03d", toftdc::ksTdcHistName[ uType ].Data(), iTdc) - <<" at " << fhTdcReferenceComp[uType][iTdc] - <<" found at "<< (TH2 *)(gROOT->FindObjectAny(Form("tof_trb_RefChComp_b%03d", iTdc))); - } // for( Int_t iTdc = 0; iTdc < fMbsUnpackPar->GetNbActiveBoards( uType ) - 1; iTdc ++) - - fhTdcOffsetFirstEvent[uType] = new TProfile( - Form("tof_%s_OffsetFirstEvent", toftdc::ksTdcHistName[ uType ].Data()), - Form("Comparison of the reference channels of %s TDC #001 to all other TDC of same type in first event; TDC#n []; Ref(TDC#n) -Ref(TDC #001)", - toftdc::ksTdcHistName[ uType ].Data() ), - iNbBoards , -0.5, iNbBoards -0.5); - - if( -1 < fMbsCalibPar->GetChanResTest() ) - for( Int_t iTdc = 0; iTdc < iNbBoards; iTdc ++) - { - fhTdcTestToRef[uType][iTdc] = new TH1I( - Form("tof_%s_TestToRef_b%03d", toftdc::ksTdcHistName[ uType ].Data(), iTdc), - Form("Comparison of the channel %03d of %s TDC #%03d to reference channel of the same board; TDC#n []; t(ch %03d) -t(ref)", - fMbsCalibPar->GetChanResTest(), toftdc::ksTdcHistName[ uType ].Data(), iTdc, fMbsCalibPar->GetChanResTest()), - 2000, -400000, 400000 ); - } // for( Int_t iTdc = 0; iTdc < iNbBoards; iTdc ++) - } // if( 0 < fMbsUnpackPar->GetNbActiveBoards( uType ) ) - else LOG(info)<<"TMbsCalibTdcTof::CreateReferenceHistogramms => Type "<<uType - <<" no active boards: " << fMbsUnpackPar->GetNbActiveBoards( uType ); - } // for( UInt_t uType = toftdc::caenV1290; uType < toftdc::NbTdcTypes; uType++ ) - return kTRUE; -} -Bool_t TMbsCalibTdcTof::FillReferenceHistograms() -{ - // Loop over all TDC types - for( UInt_t uType = toftdc::caenV1290; uType < toftdc::NbTdcTypes; uType++ ) - { - // TODO: for now only TRB has reference channel methods implemented - if( toftdc::caenV1290 == uType || - toftdc::vftx == uType || - toftdc::get4 == uType ) - continue; - - if( 0 < fMbsUnpackPar->GetNbActiveBoards( uType ) ) - { -/* // -> Comment to remove warning because set but never used - UInt_t uNbChan = 0; - Double_t dClockCycle = 0.0; - UInt_t uFtBinNb = 0; - UInt_t uMaxMul = 0; - - switch( uType ) - { - case toftdc::caenV1290: - uNbChan = caentdc::kuNbChan; - dClockCycle = caentdc::kdClockCycleSize; - uFtBinNb = caentdc::kiFineTime + 1; - uMaxMul = toftdc::kuDefNbMulti; // TODO: add proper value for this type - break; - case toftdc::vftx: - uNbChan = vftxtdc::kuNbChan; - dClockCycle = vftxtdc::kdClockCycleSize; - uFtBinNb = vftxtdc::kiFifoFineTime + 1; - uMaxMul = vftxtdc::kuNbMulti; - break; - case toftdc::trb: - uNbChan = trbtdc::kuNbChan; - dClockCycle = trbtdc::kdClockCycleSize; - uFtBinNb = trbtdc::kiFineCounterSize; - uMaxMul = toftdc::kuDefNbMulti; // TODO: add proper value for this type - break; - case toftdc::get4: - uNbChan = get4tdc::kuNbChan; - dClockCycle = get4tdc::kdClockCycleSize; - uFtBinNb = get4tdc::kiFineTime + 1; - uMaxMul = toftdc::kuDefNbMulti; // TODO: add proper value for this type - if( 4 == fMbsCalibPar->GetTotMode( uType ) ) - uNbChan = get4v10::kuNbChan; - break; - default: - break; - } // switch( uType ) -*/ - - // Reference histograms initialization - Int_t iNbBoards = fMbsUnpackPar->GetNbActiveBoards( uType ); - - // Try to compensate fixed offsets between boards - if( kTRUE == fbFirstEventPassedRef[uType]) - { - for( Int_t iTdcA = 0; iTdcA < iNbBoards - 1; iTdcA ++) - if( -1 != fdTdcReference[uType][iTdcA] ) - { - for( Int_t iTdcB = iTdcA + 1; iTdcB < iNbBoards; iTdcB ++) - if( -1 != fdTdcReference[uType][iTdcB] ) - { - fhTdcReferenceComp[uType][iTdcA]->Fill( iTdcB, - (fdTdcReference[uType][iTdcB] - fdTdcReference[uType][iTdcA]) - - ( kTRUE == fMbsCalibPar->GetTdcOffEnaFlag(uType, iTdcB) && kTRUE == fMbsCalibPar->GetTdcOffEnaFlag(uType, iTdcA) ? - (fdTdcOffsets[ uType ][ iTdcB ] - fdTdcOffsets[ uType ][ iTdcA ] ) : - 0.0 ) - ); -// - (fdTdcReferenceFirstEvent[uType][iTdcB] - fdTdcReferenceFirstEvent[uType][iTdcA]) ); - - LOG(debug)<<"TMbsCalibTdcTof::FillReferenceHistograms => Type "<<uType - <<" Board A "<<iTdcA<<" Board B "<<iTdcB - <<" T A "<<fdTdcReference[uType][iTdcA]<<" T B "<<fdTdcReference[uType][iTdcB] - <<" Off A "<<fdTdcOffsets[ uType ][ iTdcA ]<<" Off B "<<fdTdcOffsets[ uType ][ iTdcB ] - <<" First A "<<fdTdcReferenceFirstEvent[ uType ][ iTdcA ]<<" First B "<<fdTdcReferenceFirstEvent[ uType ][ iTdcB ]; - } - } // for( Int_t iTdcA = 0; iTdcA < fMbsUnpackPar->GetNbActiveBoards( uType ) - 1; iTdcA ++) - - /* - if( 0 < fdTdcReference[uType][14] ) - for( Int_t iTdcA = 0; iTdcA < iNbBoards; iTdcA ++) - if( 0 < fdTdcReference[uType][iTdcA] ) - fhTdcOffsetFirstEvent[uType]->Fill(iTdcA, - fdTdcReference[uType][iTdcA] - fdTdcReference[uType][14]); - */ - } // if( kTRUE == fbFirstEventPassedRef[uType]) - else - { - for( Int_t iTdcA = 0; iTdcA < iNbBoards; iTdcA ++) - if( -1 != fdTdcReference[uType][iTdcA] ) - fdTdcReferenceFirstEvent[uType][iTdcA] = fdTdcReference[uType][iTdcA]; - - if( -1 != fdTdcReference[uType][fMbsCalibPar->GetTdcOffsetMainTdc()] ) - for( Int_t iTdcA = 0; iTdcA < iNbBoards; iTdcA ++) - if( -1 != fdTdcReference[uType][iTdcA] ) - fhTdcOffsetFirstEvent[uType]->Fill(iTdcA, - fdTdcReference[uType][iTdcA] - - fdTdcReference[uType][fMbsCalibPar->GetTdcOffsetMainTdc()]); - - fbFirstEventPassedRef[uType] = kTRUE; - } // else of if( kTRUE == fbFirstEventPassedRef[uType]) - - if( -1 < fMbsCalibPar->GetChanResTest() ) - { - Bool_t bChannelFound[iNbBoards]; - Double_t dTimeDebugCheck[iNbBoards]; - for( Int_t iTdcA = 0; iTdcA < iNbBoards - 1; iTdcA ++) - { - bChannelFound[iTdcA] = kFALSE; - dTimeDebugCheck[iTdcA] = 0.0; - } // for( Int_t iTdcA = 0; iTdcA < fMbsUnpackPar->GetNbActiveBoards( uType ) - 1; iTdcA ++) - for( Int_t iDataIndex = 0; iDataIndex < fCalibDataCollection->GetEntriesFast() ; iDataIndex++ ) - { - TTofCalibData * fCalibData; - fCalibData = (TTofCalibData *)fCalibDataCollection->At( iDataIndex ); - - UInt_t uTypeData = fCalibData->GetType(); - UInt_t uChan = fCalibData->GetChannel(); - - if( fMbsCalibPar->GetChanResTest() != (Int_t)uChan || - uType != uTypeData ) - continue; - - UInt_t uTdc = fCalibData->GetBoard(); - - if( kTRUE == bChannelFound[uTdc] ) - continue; - - Double_t dTime = fCalibData->GetTime(); -/* Double_t dTot = fCalibData->GetTot(); */ // Commented out to remove warning bec. unused - - bChannelFound[uTdc] = kTRUE; - dTimeDebugCheck[uTdc] = dTime; - - } // for( Int_t iDataIndex = 0; iDataIndex < fCalibDataCollection->GetEntriesFast() ; iDataIndex++ ) - for( Int_t iTdcA = 0; iTdcA < iNbBoards - 1; iTdcA ++) - { - for( Int_t iTdcB = iTdcA + 1; iTdcB < iNbBoards; iTdcB ++) - if( kTRUE == bChannelFound[iTdcA] && kTRUE == bChannelFound[iTdcB] ) - { - fhTdcResolutionTest[uType][iTdcA]->Fill( iTdcB, dTimeDebugCheck[iTdcB] - dTimeDebugCheck[iTdcA]); - } // if( kTRUE == bChannelFound[iTdcA] && kTRUE == bChannelFound[iTdcB] ) - } // for( Int_t iTdcA = 0; iTdcA < fMbsUnpackPar->GetNbActiveBoards( uType ) - 1; iTdcA ++) - for( Int_t iTdc = 0; iTdc < iNbBoards; iTdc ++) - if( -1 != fdTdcReference[uType][iTdc] ) - fhTdcTestToRef[uType][iTdc]->Fill( dTimeDebugCheck[iTdc] - fdTdcReference[uType][iTdc]); - } // if( -1 < fMbsCalibPar->GetChanResTest() ) - - } // if( 0 < fMbsUnpackPar->GetNbActiveBoards( uType ) ) - } // for( UInt_t uType = toftdc::caenV1290; uType < toftdc::NbTdcTypes; uType++ ) - - return kTRUE; -} -Bool_t TMbsCalibTdcTof::WriteReferenceHistogramms( TDirectory* inDir) -{ - TDirectory * oldir = gDirectory; - - for( UInt_t uType = toftdc::caenV1290; uType < toftdc::NbTdcTypes; uType++ ) - { - // TODO: for now only TRB has reference channel methods implemented - if( toftdc::caenV1290 == uType || - toftdc::vftx == uType || - toftdc::get4 == uType ) - continue; - - if( 0 < fMbsUnpackPar->GetNbActiveBoards( uType ) ) - { -/* // -> Comment to remove warning because set but never used - UInt_t uNbChan = 0; - - switch( uType ) - { - case toftdc::caenV1290: - uNbChan = caentdc::kuNbChan; - break; - case toftdc::vftx: - uNbChan = vftxtdc::kuNbChan; - break; - case toftdc::trb: - uNbChan = trbtdc::kuNbChan; - break; - case toftdc::get4: - uNbChan = get4tdc::kuNbChan; - if( 4 == fMbsCalibPar->GetTotMode( uType ) ) - uNbChan = get4v10::kuNbChan; - break; - default: - break; - } // switch( uType ) -*/ - - // create a subdirectory "Cal_type" in this file - TDirectory *cdRef = inDir->mkdir( Form( "Ref_%s", toftdc::ksTdcHistName[ uType ].Data() ) ); - cdRef->cd(); // make the "Cal_type" directory the current directory - - // loop over active TDCs - Int_t iNbBoards = fMbsUnpackPar->GetNbActiveBoards( uType ); - for( Int_t iTdcA = 0; iTdcA < iNbBoards - 1; iTdcA ++) - { - fhTdcReferenceComp[uType][iTdcA]->Write(); - - if( -1 < fMbsCalibPar->GetChanResTest() ) - fhTdcResolutionTest[uType][iTdcA]->Write(); - } // for( Int_t iTdcA = 0; iTdcA < iNbBoards - 1; iTdcA ++) - fhTdcOffsetFirstEvent[uType]->Write(); - - if( -1 < fMbsCalibPar->GetChanResTest() ) - for( Int_t iTdc = 0; iTdc < iNbBoards; iTdc ++) - fhTdcTestToRef[uType][iTdc]->Write(); - } // if( 0 < fMbsUnpackPar->GetNbActiveBoards( uType ) ) - } // for( UInt_t uType = toftdc::caenV1290; uType < toftdc::NbTdcTypes; uType++ ) - - LOG(info)<<"TMbsCalibTdcTof::WriteReferenceHistogramms Done!"; - gDirectory->cd( oldir->GetPath() ); - return kTRUE; -} -Bool_t TMbsCalibTdcTof::DeleteReferenceHistograms() -{ - return kTRUE; -} diff --git a/beamtime/tof/calib/tdc/TMbsCalibTdcTof.h b/beamtime/tof/calib/tdc/TMbsCalibTdcTof.h deleted file mode 100644 index d04405ee3eaac66fa0e2df8c0a0c21e63fff308c..0000000000000000000000000000000000000000 --- a/beamtime/tof/calib/tdc/TMbsCalibTdcTof.h +++ /dev/null @@ -1,171 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TMbsCalibTdcTof.h ----- -// ----- Created 20/06/2013 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ - -#ifndef TMBSCALIBTDCTOF_H_ -#define TMBSCALIBTDCTOF_H_ - -#include "TObject.h" - -#include <vector> - -#include "TofTdcDef.h" - -class TMbsUnpackTofPar; -class TMbsCalibTofPar; - -class TTofCalibData; - -class TFile; -class TDirectory; -class TClonesArray; -class TH1; -class TH2; -class TString; -class TProfile; - -class TMbsCalibTdcTof : public TObject -{ - public: - TMbsCalibTdcTof(); - TMbsCalibTdcTof( TMbsUnpackTofPar * parIn, TMbsCalibTofPar *parCalIn = NULL ); - ~TMbsCalibTdcTof(); - - virtual void Clear(Option_t *option); - - Bool_t RegisterInput(); - Bool_t RegisterOutput(); - void SetSaveTdcs( Bool_t bSaveTdcs=kTRUE ); - Bool_t InitiTdcCalib(); - Bool_t CalibTdc(); - Bool_t ClearCalib(); - Bool_t CloseTdcCalib(); - void SetCalibFilename( TString sFilenameIn = "" ); - void SetCalibOutFolder( TString sFoldernameIn = "" ); - - // Fix for big trigger time deviation in GSI Sep14 data - void SetSep14Fix( Bool_t inGsiSep14Fix = kTRUE) { fbGsiSep14Fix = inGsiSep14Fix; }; - - // Calibration mode where only the reference channels are processed (Calib and histo filling) - void EnaTdcRefMoniMode( Bool_t inTdcRefMoni = kTRUE) { fbTdcRefMoniMode = inTdcRefMoni; }; - - // Histograms - Bool_t CreateHistogramms(); - Bool_t FillHistograms(); - Bool_t WriteHistogramms( TDirectory* inDir); - Bool_t DeleteHistograms(); - - private: - // no default Copy constructor and = OP as class not meant to be copied - TMbsCalibTdcTof(const TMbsCalibTdcTof&); - TMbsCalibTdcTof& operator=(const TMbsCalibTdcTof&); - - Bool_t InitParameters(); - TMbsUnpackTofPar *fMbsUnpackPar; - TMbsCalibTofPar *fMbsCalibPar; - - // Fix for big trigger time deviation in GSI Sep14 data - Bool_t fbGsiSep14Fix; - Int_t fiOffsetGsiSep14Fix; // common offset for all crazy boards - - // Calibration mode where only the reference channels are processed (Calib and histo filling) - Bool_t fbTdcRefMoniMode; - - // Histograms - - // Histograms objects - std::vector< TH1* > fhDnlChan[ toftdc::NbTdcTypes ]; - std::vector< TH1* > fhDnlSum[ toftdc::NbTdcTypes ]; - std::vector< TH1* > fhBinSizeChan[ toftdc::NbTdcTypes ]; - std::vector< TH1* > fhTimeToTrigg[ toftdc::NbTdcTypes ]; - std::vector< TH1* > fhTimeToTriggSingles[ toftdc::NbTdcTypes ]; - std::vector< TH1* > fhToT[ toftdc::NbTdcTypes ]; - std::vector< TH2* > fhMultiDist[ toftdc::NbTdcTypes ]; - std::vector< TH2* > fhMultiplicity[ toftdc::NbTdcTypes ]; - // For reference channels comparison - std::vector< TH2* > fhTdcReferenceComp[ toftdc::NbTdcTypes ]; - std::vector< TH2* > fhTdcResolutionTest[ toftdc::NbTdcTypes ]; - std::vector< TH1* > fhTdcTestToRef[ toftdc::NbTdcTypes ]; - - // Input - Bool_t CheckAllTdcValid(); - - // Input objects - TClonesArray * fCaenBoardCollection; - TClonesArray * fVftxBoardCollection; - TClonesArray * fTrb3BoardCollection; - TClonesArray * fGet4BoardCollection; - - // Output - Bool_t ClearOutput(); - - // Output objects - Bool_t fbSaveCalibTdcs; - TClonesArray * fCalibDataCollection; - TClonesArray * fCalibRefCollection[ toftdc::NbTdcTypes ]; - - // Calibration - Bool_t InitCalibration(); - Bool_t GetHistosFromUnpack(); - Bool_t LoadCalibrationFile(); - Bool_t LoadSingleCalibrations(); - Bool_t CalibFactorsInit( UInt_t uType, UInt_t uBoard, UInt_t uChan ); - Bool_t Calibration( UInt_t uType, UInt_t uBoard); - Bool_t CalibFactorsCalc( UInt_t uType, UInt_t uBoard, UInt_t uChan, Bool_t bWithInitial ); - Bool_t WriteCalibrationFile(); - Bool_t WriteSingleCalibrations(); - - // Calibration objects - TFile* fileCalibrationIn; - TDirectory* oldDir; - TString fsCalibOutFoldername; - TString fsCalibFilename; - std::vector< TH1* > fhInitialCalibHisto[ toftdc::NbTdcTypes ]; - std::vector< TH1* > fhFineTime[ toftdc::NbTdcTypes ]; - std::vector< Int_t > fiNbHitsForCalib[ toftdc::NbTdcTypes ]; - std::vector< Bool_t > fbCalibAvailable[ toftdc::NbTdcTypes ]; - std::vector< std::vector< Double_t > > fdCorr[ toftdc::NbTdcTypes ]; - std::vector< Double_t > fdBoardTriggerTime[ toftdc::NbTdcTypes ]; - - // Tot calculation - Bool_t CreateTotVariables(); - Bool_t ClearTotVariables(); - Bool_t DeleteTotVariables(); - Bool_t BuildTotSplitChannels( UInt_t uType, UInt_t uBoard ); - Bool_t BuildTotSplitBoards( UInt_t uType ); - // Tot objects - TClonesArray * xTofTdcDataPrevArray[ toftdc::NbTdcTypes ]; - TClonesArray * xTempCalibData[ toftdc::NbTdcTypes ]; - - // TDC to TDC offset objects - Bool_t GetRefHistosFromUnpack(); - Bool_t LoadCalibrationFileRef(); // TODO in a smarter way ??? - Bool_t LoadSingleCalibrationsRef(); - Bool_t CalibFactorsInitReference( UInt_t uType, UInt_t uBoard); - Bool_t CalibFactorsCalcReference( UInt_t uType, UInt_t uBoard, Bool_t bWithInitial ); - Bool_t WriteCalibrationFileRef( TString outDir ); // TODO in a smart way ??? - Bool_t WriteSingleCalibrationsRef(); - Bool_t CalibrateReference(UInt_t uType, UInt_t uBoard); - Bool_t ClearTdcReference(); - Bool_t TdcOffsetCalc(UInt_t uType, UInt_t uBoard); - Bool_t CreateReferenceHistogramms(); - Bool_t FillReferenceHistograms(); - Bool_t WriteReferenceHistogramms( TDirectory* inDir); - Bool_t DeleteReferenceHistograms(); - - std::vector< TH1* > fhInitialCalibHistoRef[ toftdc::NbTdcTypes ]; - std::vector< TH1* > fhFineTimeRef[ toftdc::NbTdcTypes ]; - std::vector< Int_t > fiLinCalRefMinBin[ toftdc::NbTdcTypes ]; - std::vector< Int_t > fiLinCalRefMaxBin[ toftdc::NbTdcTypes ]; - std::vector< std::vector< Double_t > > fdCorrRef[ toftdc::NbTdcTypes ]; - std::vector< Double_t > fdTdcReference[ toftdc::NbTdcTypes ]; - std::vector< Double_t > fdTdcOffsets[ toftdc::NbTdcTypes ]; - Bool_t fbFirstEventPassedRef[ toftdc::NbTdcTypes ]; - std::vector< Double_t > fdTdcReferenceFirstEvent[ toftdc::NbTdcTypes ]; - TProfile* fhTdcOffsetFirstEvent[ toftdc::NbTdcTypes ]; - - ClassDef(TMbsCalibTdcTof, 1) -}; - -#endif // TMBSCALIBTDCTOF_H_ diff --git a/beamtime/tof/calib/tdc/TTofCalibData.cxx b/beamtime/tof/calib/tdc/TTofCalibData.cxx deleted file mode 100644 index b0f505db0c60fedfed56ce572a836d81107a4946..0000000000000000000000000000000000000000 --- a/beamtime/tof/calib/tdc/TTofCalibData.cxx +++ /dev/null @@ -1,85 +0,0 @@ - // ------------------------------------------------------------------ -// ----- TTofCalibData ----- -// ----- Created 17/05/2013 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ - -#include "TTofCalibData.h" - -/************************** TTofCalibData ****************************/ -TTofCalibData::TTofCalibData() : - TObject(), - fbFilled(kTRUE), - fuTdcType(0), - fuTdcBoard(0), - fuTdcChannel(0), - fuEdge(0), - fdCalibTime(0), - fdTimeOverThreshold(0) -{ - -} -TTofCalibData::TTofCalibData( UInt_t uType, UInt_t uBoard, UInt_t uChan, - Double_t dCalibT, Double_t dTot, UInt_t uEdge ): - TObject(), - fbFilled(kTRUE), - fuTdcType(uType), - fuTdcBoard(uBoard), - fuTdcChannel(uChan), - fuEdge(uEdge), - fdCalibTime(dCalibT), - fdTimeOverThreshold(dTot) -{ -} - -TTofCalibData::~TTofCalibData() -{ -} - -void TTofCalibData::Clear(Option_t *option) -{ - TObject::Clear( option ); - SetData( 0, 0, 0, 0.0, 0.0); - ClearFilled(); -} - -void TTofCalibData::SetData( UInt_t uType, UInt_t uBoard, UInt_t uChan, - Double_t dCalibT, Double_t dTot, - UInt_t uEdge ) -{ - SetType( uType ); - SetBoard( uBoard ); - SetChannel( uChan ); - SetEdge( uEdge ); - SetTime( dCalibT ); - SetTot( dTot ); - SetFilled(); -} -Int_t TTofCalibData::Compare( const TObject* obj) const -{ - return Compare( (TTofCalibData*) obj); -} -Int_t TTofCalibData::Compare( const TTofCalibData* obj) const -{ - // Class using only Time! - if( this->GetTime() < obj->GetTime() ) - // hit ... rhs - return -1; - else if( this->GetTime() > obj->GetTime() ) - // rhs ... hit - return 1; - // rhs = hit - else if( this->GetEdge() < obj->GetEdge() ) - // rhs is Falling edge while hit is Rising edge - return -1; - else return 0; -} - -Double_t TTofCalibData::GetTimeDifference( const Double_t & dTimeIn ) -{ - return dTimeIn - this->GetTime(); -} -Double_t TTofCalibData::GetTimeDifference( const TTofCalibData & dataIn ) -{ - return dataIn.GetTime() - this->GetTime(); -} - diff --git a/beamtime/tof/calib/tdc/TTofCalibData.h b/beamtime/tof/calib/tdc/TTofCalibData.h deleted file mode 100644 index d1dd7bd1083564b53f24b3e13f5587941ad08d71..0000000000000000000000000000000000000000 --- a/beamtime/tof/calib/tdc/TTofCalibData.h +++ /dev/null @@ -1,73 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TTofCalibData ----- -// ----- Created 17/05/2013 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ - -#ifndef TTOFCALIBDATA_H_ -#define TTOFCALIBDATA_H_ - -#include "TObject.h" - -class TTofCalibData : public TObject -{ - public: - TTofCalibData(); - TTofCalibData( UInt_t uType, UInt_t uBoard, UInt_t uChan, - Double_t dCalibT, Double_t dTot = 0, - UInt_t uEdge = 0 ); - ~TTofCalibData(); - - virtual void Clear(Option_t *option = ""); - - // copy constructor, used by vector to copy content - TTofCalibData(const TTofCalibData& src) : - TObject(src), - fbFilled(src.fbFilled), - fuTdcType(src.fuTdcType), - fuTdcBoard(src.fuTdcBoard), - fuTdcChannel(src.fuTdcChannel), - fuEdge(src.fuEdge), - fdCalibTime(src.fdCalibTime), - fdTimeOverThreshold(src.fdTimeOverThreshold) {}; - // Comparison operator, needed for time sorting -// virtual Bool_t operator <( const TTofCalibData& rhs) const; - virtual Int_t Compare( const TObject* obj) const; - virtual Int_t Compare( const TTofCalibData* obj) const; - virtual Bool_t IsSortable() const { return kTRUE; }; - - void SetData( UInt_t uType, UInt_t uBoard, UInt_t uChan, - Double_t dCalibT, Double_t dTot = 0, - UInt_t uEdge = 0 ); - void SetFilled(){ fbFilled = kTRUE; }; - void ClearFilled(){ fbFilled = kFALSE; }; - void SetType( UInt_t uType ){ fuTdcType = uType; }; - void SetBoard( UInt_t uBoard ){ fuTdcBoard = uBoard; }; - void SetChannel( UInt_t uChan ){ fuTdcChannel = uChan; }; - void SetEdge( UInt_t uEdge ){ fuEdge = uEdge; }; - void SetTime( Double_t dCalibT ){ fdCalibTime = dCalibT; }; - void SetTot( Double_t dTot ){ fdTimeOverThreshold = dTot; }; - - Bool_t IsFilled() const { return fbFilled; }; - UInt_t GetType() const { return fuTdcType; }; - UInt_t GetBoard() const { return fuTdcBoard; }; - UInt_t GetChannel() const { return fuTdcChannel; }; - UInt_t GetEdge() const { return fuEdge; }; // 0 = Rising, 1 = Falling, 2 = Full, 3 = Ref ch - Double_t GetTime() const { return fdCalibTime; }; - Double_t GetTot() const { return fdTimeOverThreshold; }; - - Double_t GetTimeDifference( const Double_t & dTimeIn ); - Double_t GetTimeDifference( const TTofCalibData & dataIn ); - - private: - Bool_t fbFilled; - UInt_t fuTdcType; - UInt_t fuTdcBoard; - UInt_t fuTdcChannel; - UInt_t fuEdge; // 0 = Rising, 1 = Falling, 2 = Full hit, 3 = Ref ch - Double_t fdCalibTime; // [ps] - Double_t fdTimeOverThreshold; // [ps] - - ClassDef(TTofCalibData, 1) -}; - -#endif // TTOFCALIBDATA_H_ diff --git a/beamtime/tof/commons.h b/beamtime/tof/commons.h deleted file mode 100644 index 5dee888e281118c57e643d0e121f9d9ccf645dc4..0000000000000000000000000000000000000000 --- a/beamtime/tof/commons.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef BASE_COMMONS_H -#define BASE_COMMONS_H - -/** This is a place for common constants, types - * One should try to keep file generic and small - not everything should go here, - * while later it will be difficult to avoid them */ - -namespace roc3587 { - //! value of iProcId if mbs subevent. - /*! - * Data, taken from ROC by DABC, packed into mbs events and stored in lmd file. - * MBS event consists from one or several subevents. - * Each subevent has three fields - iProcId (16bit), iSubcrate (8bit) and iControl (8bit) - * iProcId used to code data origin - see comment for /ref ERocMbsTypes - * iSubcrate contains roc number (rocid) - * iControl stores data format see /ref MessageFormat - */ - enum ERocMbsTypes { - proc_RocEvent = 1, //!< complete event from one roc board (iSubcrate = rocid) - proc_ErrEvent = 2, //!< one or several events with corrupted data inside (iSubcrate = rocid) - proc_MergedEvent = 3, //!< sorted and synchronized data from several rocs (iSubcrate = upper rocid bits) - proc_RawData = 4, //!< unsorted uncorrelated data from one ROC, no SYNC markers required (mainly for FEET case) - proc_Triglog = 5, //!< subevent produced by MBS directly with sync number and trigger module scalers - proc_TRD_MADC = 6, //!< subevent produced by MBS directly with CERN-Nov10 data - proc_TRD_Spadic = 7, //!< collection of data from susibo board (spadic 0.3) - proc_CERN_Oct11 = 8, //!< id for CERN beamtime in October 11 - proc_SlaveMbs = 9, //!< subevent produce by slave MBS system, which emulates number of triglog module - proc_EPICS = 10, //!< subevent produced by dabc EPICS plugin (ezca) - proc_COSY_Nov11 = 11, //!< id for COSY beamtime in November 11 - proc_SpadicV10Raw = 12, //!< raw data from single spadic V1.0 chip - proc_SpadicV10Event = 13, //!< dabc-packed data for spadic V1.0 from SP605 - proc_CERN_Oct12 = 14, //!< id for CERN beamtime in October 12 - proc_FASP = 15, //!< id for the FASP data - proc_TRBEvent = 31 //!< container for TRB frontend data - }; -} - -#endif diff --git a/beamtime/tof/display/CbmTofOnlineDisplay.cxx b/beamtime/tof/display/CbmTofOnlineDisplay.cxx deleted file mode 100644 index a2763c62610714a981de166d4d10f45dc5bfd9c7..0000000000000000000000000000000000000000 --- a/beamtime/tof/display/CbmTofOnlineDisplay.cxx +++ /dev/null @@ -1,1456 +0,0 @@ -#include "CbmTofOnlineDisplay.h" - -#include "FairLogger.h" - -#include "TCanvas.h" -#include "TPad.h" -#include "TStyle.h" -#include "TH1.h" -#include "TH2.h" -#include "TProfile.h" -#include "TF1.h" -#include "THStack.h" -#include "TLegend.h" -#include "TString.h" -#include "TROOT.h" -#include "TPaveStats.h" -#include "TGraph.h" -#include <TLegendEntry.h> - -#include "TofDef.h" -#include "TMbsUnpackTofPar.h" -#include "TMbsCalibTofPar.h" - -#include "FairRun.h" -#include "FairRuntimeDb.h" - -// ---- Default constructor ------------------------------------------- -CbmTofOnlineDisplay::CbmTofOnlineDisplay() - :FairTask("CbmTofOnlineDisplay"), - fMbsUnpackPar(NULL), - fMbsCalibPar(NULL), - fbMonitorTdcOcc(kTRUE), - fTdcChannelOccupancy(NULL), - fNumberOfTDC(30), - fNumberOfSEB(8), - fUpdateInterval(100), - fEventCounter(0), - fbMonitorCts(kFALSE), - fCtsTriggerMonitor(NULL), - fbMonitorSebStatus(kFALSE), - fSebSizeMonitor(NULL), - fSebStatusMonitor(NULL), - fSebDataRateMonitor(NULL), - fbMonitorTdcStatus(kFALSE), - fTdcSizeMonitor(NULL), - fTdcStatusMonitor(NULL), - fbMonitorFSMockup(kFALSE), - fFSMockupMonitor(NULL), - fbMonitorRes(kFALSE), - fOverviewRes(NULL), - fhResolutionSummary(NULL), - fhResolutionRmsSummary(NULL), - fbMonitorDigiStatus(kFALSE), - fDigiSizeMonitor(NULL), - fDigiStatusMonitor(NULL), - fbMonitorRates(kFALSE), - fCanvRatesMonitor(NULL), - fStackMbsTrloA(NULL), - fStackMbsTrloB(NULL), - fStackFreeTrloA(NULL), - fStackFreeTrloB(NULL), - fStackFreeTrloOutA(NULL), - fStackFreeTrloOutB(NULL), - fLegStackMbsTrloA(NULL), - fLegStackMbsTrloB(NULL), - fLegStackFreeTrloA(NULL), - fLegStackFreeTrloB(NULL), - fLegStackFreeTrloOutA(NULL), - fLegStackFreeTrloOutB(NULL), - fbRatesSlidingScale(kFALSE), - fbMonitorInspection(kFALSE), - fLeadingEdgeOnly(NULL), - fTrailingEdgeOnly(NULL), - fUnequalEdgeCounts(NULL), - fTimeOverThreshold(NULL), - fLeadingPosition(NULL), - fTrailingPosition(NULL), - fBoardFineTime(NULL), - fRefChFineTime(NULL), - fbMonitorCalibration(kFALSE), - fBoardOffsetGraphs(NULL), - fBoardOffsetLinear(NULL), - fBoardOffsetBinCenter(NULL), - fBoardOffsetBinEdge(NULL) - -{ - LOG(debug) << "Default Constructor of CbmTofOnlineDisplay"; - for( Int_t iCh = 0; iCh < 16; iCh++) - fsFreeTrloNames[iCh] = Form("Ch %02d", iCh); -} - -// ---- Destructor ---------------------------------------------------- -CbmTofOnlineDisplay::~CbmTofOnlineDisplay() -{ - LOG(debug) << "Destructor of CbmTofOnlineDisplay"; -} - -// ---- Initialisation ---------------------------------------------- -void CbmTofOnlineDisplay::SetParContainers() -{ - LOG(debug) << "SetParContainers of CbmTofOnlineDisplay"; - - InitParameters(); -} - -void CbmTofOnlineDisplay::SetFreeTrloNames( - TString sChA, TString sChB, TString sChC, TString sChD, - TString sChE, TString sChF, TString sChG, TString sChH, - TString sChI, TString sChJ, TString sChK, TString sChL, - TString sChM, TString sChN, TString sChO, TString sChP ) -{ - fsFreeTrloNames[ 0] = sChA; - fsFreeTrloNames[ 1] = sChB; - fsFreeTrloNames[ 2] = sChC; - fsFreeTrloNames[ 3] = sChD; - fsFreeTrloNames[ 4] = sChE; - fsFreeTrloNames[ 5] = sChF; - fsFreeTrloNames[ 6] = sChG; - fsFreeTrloNames[ 7] = sChH; - fsFreeTrloNames[ 8] = sChI; - fsFreeTrloNames[ 9] = sChJ; - fsFreeTrloNames[10] = sChK; - fsFreeTrloNames[11] = sChL; - fsFreeTrloNames[12] = sChM; - fsFreeTrloNames[13] = sChN; - fsFreeTrloNames[14] = sChO; - fsFreeTrloNames[15] = sChP; -} - -// ---- Init ---------------------------------------------------------- -InitStatus CbmTofOnlineDisplay::Init() -{ - LOG(debug) << "Initilization of CbmTofOnlineDisplay"; - - fNumberOfTDC = fMbsUnpackPar->GetNbActiveBoards( tofMbs::trbtdc ); - fNumberOfSEB = fMbsUnpackPar->GetActiveTrbSebNb(); - - TH1 *h1; - TH2 *h2; - Float_t lsize=0.07; - - if( fbMonitorTdcOcc ) - { - fTdcChannelOccupancy = new TCanvas("tCanvasOccupancy","TRB TDC channel occupancy",8,6,900,600); - fTdcChannelOccupancy->Divide(8,(fNumberOfTDC % 8 ? fNumberOfTDC/8+1 : fNumberOfTDC/8)); - - for(Int_t iCh=0; iCh<fNumberOfTDC; iCh++){ - fTdcChannelOccupancy->cd(iCh+1); - gROOT->cd(); - TString hname=Form("tof_trb_ch_occ_%03d",iCh); - h1=(TH1 *)gROOT->FindObjectAny(hname); - if (h1!=NULL) { - h1->Draw(""); - gPad->SetFillColor(0); - gStyle->SetPalette(1); - gStyle->SetLabelSize(lsize); - gPad->SetLogy(); - } else { - LOG(info)<<"Histogram "<<hname<<" not existing. "; - } - } - } - - if( fbMonitorCalibration ) - { - fBoardOffsetGraphs = new TCanvas("tBoardOffsetGraphs",Form("Reference hit run time difference precision with respect to reference TDC"),0,0,700,700); - fBoardOffsetGraphs->Divide(2,2); - - fBoardOffsetLinear = new TCanvas("tBoardOffsetLinear",Form("Reference hit run time differences (calibrated linearly) with respect to reference TDC"),0,0,700,700); - fBoardOffsetLinear->Divide(8,(fNumberOfTDC % 8 ? fNumberOfTDC/8+1 : fNumberOfTDC/8)); - - fBoardOffsetBinCenter = new TCanvas("tBoardOffsetBinCenter",Form("Reference hit run time differences (calibrated bin-by-bin center) with respect to reference TDC"),0,0,700,700); - fBoardOffsetBinCenter->Divide(8,(fNumberOfTDC % 8 ? fNumberOfTDC/8+1 : fNumberOfTDC/8)); - - fBoardOffsetBinEdge = new TCanvas("tBoardOffsetBinEdge",Form("Reference hit run time differences (calibrated bin-by-bin edge) with respect to reference TDC"),0,0,700,700); - fBoardOffsetBinEdge->Divide(8,(fNumberOfTDC % 8 ? fNumberOfTDC/8+1 : fNumberOfTDC/8)); - - } - - if( fbMonitorInspection ) - { - fLeadingEdgeOnly = new TCanvas("tCanvasLeadingEdgeOnly","Shares of leading edge only TDC channel buffers",8,6,900,600); - fLeadingEdgeOnly->Divide(8,(fNumberOfTDC % 8 ? fNumberOfTDC/8+1 : fNumberOfTDC/8)); - - for(Int_t iCh=0; iCh<fNumberOfTDC; iCh++) - { - fLeadingEdgeOnly->cd(iCh+1); - gROOT->cd(); - TString hname=Form("tof_trb_ch_leadonly_%03d",iCh); - h1=(TH1 *)gROOT->FindObjectAny(hname); - if (h1!=NULL) - { - h1->Draw(""); - gPad->SetFillColor(0); - gStyle->SetPalette(1); - gStyle->SetLabelSize(lsize); - } - else - { - LOG(info)<<"Histogram "<<hname<<" not existing. "; - } - } - - fTrailingEdgeOnly = new TCanvas("tCanvasTrailingEdgeOnly","Shares of trailing edge only TDC channel buffers",8,6,900,600); - fTrailingEdgeOnly->Divide(8,(fNumberOfTDC % 8 ? fNumberOfTDC/8+1 : fNumberOfTDC/8)); - - for(Int_t iCh=0; iCh<fNumberOfTDC; iCh++) - { - fTrailingEdgeOnly->cd(iCh+1); - gROOT->cd(); - TString hname=Form("tof_trb_ch_trailonly_%03d",iCh); - h1=(TH1 *)gROOT->FindObjectAny(hname); - if (h1!=NULL) - { - h1->Draw(""); - gPad->SetFillColor(0); - gStyle->SetPalette(1); - gStyle->SetLabelSize(lsize); - } - else - { - LOG(info)<<"Histogram "<<hname<<" not existing. "; - } - } - - fUnequalEdgeCounts = new TCanvas("tCanvasUnequalEdgeCounts","Shares of unequal edge TDC channel buffers",8,6,900,600); - fUnequalEdgeCounts->Divide(8,(fNumberOfTDC % 8 ? fNumberOfTDC/8+1 : fNumberOfTDC/8)); - - for(Int_t iCh=0; iCh<fNumberOfTDC; iCh++) - { - fUnequalEdgeCounts->cd(iCh+1); - gROOT->cd(); - TString hname=Form("tof_trb_ch_unequal_%03d",iCh); - h1=(TH1 *)gROOT->FindObjectAny(hname); - if (h1!=NULL) - { - h1->Draw(""); - gPad->SetFillColor(0); - gStyle->SetPalette(1); - gStyle->SetLabelSize(lsize); - } - else - { - LOG(info)<<"Histogram "<<hname<<" not existing. "; - } - } - - fTimeOverThreshold = new TCanvas("tCanvasTimeOverThreshold","RAW(!!!) Time over threshold - If negative, change the inversion flag!",8,6,900,600); - fTimeOverThreshold->Divide(8,(fNumberOfTDC % 8 ? fNumberOfTDC/8+1 : fNumberOfTDC/8)); - - for(Int_t iCh=0; iCh<fNumberOfTDC; iCh++) - { - fTimeOverThreshold->cd(iCh+1); - gROOT->cd(); - TString hname=Form("tof_trb_board_tot_%03d",iCh); - h2=(TH2 *)gROOT->FindObjectAny(hname); - if (h2!=NULL) - { - gPad->SetFillColor(0); - gStyle->SetPalette(1); - gStyle->SetLabelSize(lsize); - gPad->SetLogz(); - h2->Draw("colz"); - - } - else - { - LOG(info)<<"Histogram "<<hname<<" not existing. "; - } - } - - fLeadingPosition = new TCanvas("tCanvasLeadingPosition","Leading edge time to trigger",8,6,900,600); - fLeadingPosition->Divide(8,(fNumberOfTDC % 8 ? fNumberOfTDC/8+1 : fNumberOfTDC/8)); - - for(Int_t iCh=0; iCh<fNumberOfTDC; iCh++) - { - fLeadingPosition->cd(iCh+1); - gROOT->cd(); - TString hname=Form("tof_trb_board_lead_pos_%03d",iCh); - h2=(TH2 *)gROOT->FindObjectAny(hname); - if (h2!=NULL) - { - gPad->SetFillColor(0); - gStyle->SetPalette(1); - gStyle->SetLabelSize(lsize); - gPad->SetLogz(); - h2->Draw("colz"); - } - else - { - LOG(info)<<"Histogram "<<hname<<" not existing. "; - } - } - - fTrailingPosition = new TCanvas("tCanvasTrailingPosition","Trailing edge time to trigger",8,6,900,600); - fTrailingPosition->Divide(8,(fNumberOfTDC % 8 ? fNumberOfTDC/8+1 : fNumberOfTDC/8)); - - for(Int_t iCh=0; iCh<fNumberOfTDC; iCh++) - { - fTrailingPosition->cd(iCh+1); - gROOT->cd(); - TString hname=Form("tof_trb_board_trail_pos_%03d",iCh); - h2=(TH2 *)gROOT->FindObjectAny(hname); - if (h2!=NULL) - { - gPad->SetFillColor(0); - gStyle->SetPalette(1); - gStyle->SetLabelSize(lsize); - gPad->SetLogz(); - h2->Draw("colz"); - } - else - { - LOG(info)<<"Histogram "<<hname<<" not existing. "; - } - } - - fBoardFineTime = new TCanvas("tCanvasBoardFineTime","TDC channel fine times",8,6,900,600); - fBoardFineTime->Divide(8,(fNumberOfTDC % 8 ? fNumberOfTDC/8+1 : fNumberOfTDC/8)); - - for(Int_t iCh=0; iCh<fNumberOfTDC; iCh++) - { - fBoardFineTime->cd(iCh+1); - gROOT->cd(); - TString hname=Form("tof_trb_board_ft_%03d",iCh); - h2=(TH2 *)gROOT->FindObjectAny(hname); - if (h2!=NULL) - { - gPad->SetFillColor(0); - gStyle->SetPalette(1); - gStyle->SetLabelSize(lsize); - gPad->SetLogz(); - h2->Draw("colz"); - } - else - { - LOG(info)<<"Histogram "<<hname<<" not existing. "; - } - } - - fRefChFineTime = new TCanvas("tCanvasRefChFineTime","TDC reference channel fine times",8,6,400,300); - - gROOT->cd(); - TString hname=Form("tof_trb_all_ref_ft"); - h2=(TH2 *)gROOT->FindObjectAny(hname); - if (h2!=NULL) - { - gPad->SetFillColor(0); - gStyle->SetPalette(1); - gStyle->SetLabelSize(lsize); - gPad->SetLogz(); - h2->Draw("colz"); - } - else - { - LOG(info)<<"Histogram "<<hname<<" not existing. "; - } - - } - - - if( fbMonitorCts ) - { - fCtsTriggerMonitor = new TCanvas("tCanvasTrigger","TRB CTS trigger monitor",1080,0,1000,750); - fCtsTriggerMonitor->Divide(4,3); - - fCtsTriggerMonitor->cd(1); - gROOT->cd(); - gPad->SetFillColor(0); - gStyle->SetPalette(1); - gStyle->SetLabelSize(lsize); - gPad->SetLogy(); - h1 = ((TH1 *)gROOT->FindObjectAny("tof_trb_trigger_pattern")); - if( h1 ) - { - h1->Draw(""); - } - - fCtsTriggerMonitor->cd(2); - gROOT->cd(); - gPad->SetFillColor(0); - gStyle->SetPalette(1); - gStyle->SetLabelSize(lsize); - gPad->SetLogy(); - h1 = ((TH1 *)gROOT->FindObjectAny("tof_trb_trigger_types")); - if( h1 ) - { - h1->Draw(""); - } - - fCtsTriggerMonitor->cd(3); - gROOT->cd(); - gPad->SetFillColor(0); - gStyle->SetPalette(1); - gStyle->SetLabelSize(lsize); - gPad->SetLogy(); - h1 = ((TH1 *)gROOT->FindObjectAny("tof_trb_cts_busy")); - if( h1 ) - { - h1->Draw(""); - } - - fCtsTriggerMonitor->cd(4); - gROOT->cd(); - gPad->SetFillColor(0); - gStyle->SetPalette(1); - gStyle->SetLabelSize(lsize); - gPad->SetLogy(); - h1 = ((TH1 *)gROOT->FindObjectAny("tof_trb_cts_idle")); - if( h1 ) - { - h1->Draw(""); - } - - fCtsTriggerMonitor->cd(5); - gROOT->cd(); - gPad->SetFillColor(0); - gStyle->SetPalette(1); - gStyle->SetLabelSize(lsize); - gPad->SetLogy(); - h1 = ((TH1 *)gROOT->FindObjectAny("tof_cts_time_spill")); - if( h1 ) - { - h1->Draw(""); - } - - fCtsTriggerMonitor->cd(6); - gROOT->cd(); - gPad->SetFillColor(0); - gStyle->SetPalette(1); - gStyle->SetLabelSize(lsize); - gPad->SetLogy(); - h1 = ((TH1 *)gROOT->FindObjectAny("tof_trb_itc_assert")); - if( h1 ) - { - h1->Draw(""); - } - - fCtsTriggerMonitor->cd(7); - gROOT->cd(); - gPad->SetFillColor(0); - gStyle->SetPalette(1); - gStyle->SetLabelSize(lsize); - gPad->SetLogy(); - h1 = ((TH1 *)gROOT->FindObjectAny("tof_trb_cts_events")); - if( h1 ) - { - h1->Draw(""); - } - - fCtsTriggerMonitor->cd(8); - gROOT->cd(); - gPad->SetFillColor(0); - gStyle->SetPalette(1); - gStyle->SetLabelSize(lsize); - gPad->SetLogy(); - h1 = ((TH1 *)gROOT->FindObjectAny("tof_trb_cts_cycle")); - if( h1 ) - { - h1->Draw(""); - } - - fCtsTriggerMonitor->cd(9); - gROOT->cd(); - gPad->SetFillColor(0); - gStyle->SetPalette(1); - gStyle->SetLabelSize(lsize); - gPad->SetLogy(); - h1 = ((TH1 *)gROOT->FindObjectAny("tof_trb_trigger_rate")); - if( h1 ) - { - h1->Draw("LP"); - } - h1 = ((TH1 *)gROOT->FindObjectAny("tof_trb_event_rate")); - if( h1 ) - { - h1->Draw("LPSAME"); - } - - fCtsTriggerMonitor->cd(10); - gROOT->cd(); - gPad->SetFillColor(0); - gStyle->SetPalette(1); - gStyle->SetLabelSize(lsize); - gPad->SetLogy(); - h1 = ((TH1 *)gROOT->FindObjectAny("tof_trb_hadaq_rate")); - if( h1 ) - { - h1->Draw("LP"); - } - h1 = ((TH1 *)gROOT->FindObjectAny("tof_trb_event_rate")); - if( h1 ) - { - h1->Draw("LPSAME"); - } - - fCtsTriggerMonitor->cd(11); - gROOT->cd(); - gPad->SetFillColor(0); - gStyle->SetPalette(1); - gStyle->SetLabelSize(lsize); - gPad->SetLogy(); - h1 = ((TH1 *)gROOT->FindObjectAny("tof_trb_cts_idle_spill")); - if( h1 ) - { - h1->Draw(""); - } - - fCtsTriggerMonitor->cd(12); - gROOT->cd(); - gPad->SetFillColor(0); - gStyle->SetPalette(1); - gStyle->SetLabelSize(lsize); - gPad->SetLogy(); - h1 = ((TH1 *)gROOT->FindObjectAny("tof_trb_cts_spill_length")); - if( h1 ) - { - h1->Draw(""); - } - - } - - if( fbMonitorSebStatus ) - { - fSebSizeMonitor = new TCanvas("tCanvasSebSize","TRB subevent sizes",1080,36,500,100); - fSebSizeMonitor->Divide(8,(fNumberOfSEB % 8 ? fNumberOfSEB/8+1 : fNumberOfSEB/8)); - - for(Int_t iCh=0; iCh<fNumberOfSEB; iCh++){ - fSebSizeMonitor->cd(iCh+1); - gROOT->cd(); - TString hname=Form("tof_trb_size_subevent_%03d",iCh); - h1=(TH1 *)gROOT->FindObjectAny(hname); - if (h1!=NULL) { - h1->Draw(""); - gPad->SetFillColor(0); - gStyle->SetPalette(1); - gStyle->SetLabelSize(lsize); - gPad->SetLogy(); - } else { - LOG(info)<<"Histogram "<<hname<<" not existing. "; - } - } - - fSebStatusMonitor = new TCanvas("tCanvasSebStatus","TrbNet subevent status bits",1080,56,500,100); - fSebStatusMonitor->Divide(8,(fNumberOfSEB % 8 ? fNumberOfSEB/8+1 : fNumberOfSEB/8)); - - for(Int_t iCh=0; iCh<fNumberOfSEB; iCh++){ - fSebStatusMonitor->cd(iCh+1); - gROOT->cd(); - TString hname=Form("tof_trb_status_subevent_%03d",iCh); - h1=(TH1 *)gROOT->FindObjectAny(hname); - if (h1!=NULL) { - h1->Draw(""); - gPad->SetFillColor(0); - gStyle->SetPalette(1); - gStyle->SetLabelSize(lsize); - gPad->SetLogy(); - } else { - LOG(info)<<"Histogram "<<hname<<" not existing. "; - } - } - - fSebDataRateMonitor = new TCanvas("tCanvasSebDataRate","TRB subevent data rate",1080,36,500,100); - fSebDataRateMonitor->Divide(8,(fNumberOfSEB % 8 ? fNumberOfSEB/8+1 : fNumberOfSEB/8)); - - for(Int_t iCh=0; iCh<fNumberOfSEB; iCh++){ - fSebDataRateMonitor->cd(iCh+1); - gROOT->cd(); - TString hname=Form("tof_trb_rate_subevent_%03d",iCh); - h2=(TH2 *)gROOT->FindObjectAny(hname); - if (h2!=NULL) { - TProfile* tProfile = h2->ProfileX(); - tProfile->Draw(""); - gPad->SetFillColor(0); - gStyle->SetLabelSize(lsize); - } else { - LOG(info)<<"Histogram "<<hname<<" not existing. "; - } - } - } - - if( fbMonitorTdcStatus ) - { - fTdcSizeMonitor = new TCanvas("tCanvasTdcSize","TDC data payload",980,76,500,300); - fTdcSizeMonitor->Divide(8,(fNumberOfTDC % 8 ? fNumberOfTDC/8+1 : fNumberOfTDC/8)); - - for(Int_t iCh=0; iCh<fNumberOfTDC; iCh++){ - fTdcSizeMonitor->cd(iCh+1); - gROOT->cd(); - TString hname=Form("tof_trb_words_tdc_%03d",iCh); - h1=(TH1 *)gROOT->FindObjectAny(hname); - if (h1!=NULL) { - h1->Draw(""); - gPad->SetFillColor(0); - gStyle->SetPalette(1); - gStyle->SetLabelSize(lsize); - gPad->SetLogy(); - } else { - LOG(info)<<"Histogram "<<hname<<" not existing. "; - } - } - - fTdcStatusMonitor = new TCanvas("tCanvasTdcStatus","TDC processing status",48,56,1000,700); - fTdcStatusMonitor->Divide(8,(fNumberOfTDC % 8 ? fNumberOfTDC/8+1 : fNumberOfTDC/8)); - - for(Int_t iCh=0; iCh<fNumberOfTDC; iCh++){ - fTdcStatusMonitor->cd(iCh+1); - gROOT->cd(); - TString hname=Form("tof_trb_process_status_tdc_%03d",iCh); - h1=(TH1 *)gROOT->FindObjectAny(hname); - if (h1!=NULL) { - h1->Draw(""); - gPad->SetFillColor(0); - gStyle->SetPalette(1); - gStyle->SetLabelSize(lsize); - gPad->SetLogy(); - } else { - LOG(info)<<"Histogram "<<hname<<" not existing. "; - } - } - } - - if( fbMonitorFSMockup ) - { - fFSMockupMonitor = new TCanvas("tCanvasMockup","TRB free-running mock-up monitor",1080,0,500,400); - fFSMockupMonitor->Divide(2,2); - - fFSMockupMonitor->cd(1); - gROOT->cd(); - gPad->SetFillColor(0); - gStyle->SetPalette(1); - gStyle->SetLabelSize(lsize); - gPad->SetLogy(); - h1 = ((TH1 *)gROOT->FindObjectAny("tof_trb_event_jump")); - if( h1 ) - { - h1->Draw(""); - gPad->Update(); - TPaveStats* tStats = (TPaveStats*)h1->FindObject("stats"); - tStats->SetOptStat(111111); - gPad->Update(); - } - - fFSMockupMonitor->cd(2); - gROOT->cd(); - gPad->SetFillColor(0); - gStyle->SetPalette(1); - gStyle->SetLabelSize(lsize); - gPad->SetLogy(); - h1 = ((TH1 *)gROOT->FindObjectAny("tof_trb_buffer_overflow")); - if( h1 ) - { - h1->Draw(""); - } - - fFSMockupMonitor->cd(3); - gROOT->cd(); - gPad->SetFillColor(0); - gStyle->SetPalette(1); - gStyle->SetLabelSize(lsize); - h1 = ((TH2 *)gROOT->FindObjectAny("tof_trb_skips_spill")); - if( h1 ) - { - h1->Draw("colz"); - } - - } - -// fbMonitorDigiStatus=kTRUE; - if( fbMonitorDigiStatus ) - { - fDigiStatusMonitor = new TCanvas("tCanvasDigiSize","Digi status",1000,500,700,700); - fDigiStatusMonitor->Divide(4,5); - Int_t iType[9]={1,3,4,6,7,9,2,5,8}; - Int_t iNumSm[9]={1,1,1,1,1,1,4,3,1}; - Int_t iNumRpc[9]={1,1,1,1,1,1,1,1,6}; - Int_t iCanv=0; - Int_t iNDet=9; - for(Int_t iCh=0; iCh<iNDet; iCh++){ - for(Int_t iSm=0; iSm<iNumSm[iCh];iSm++){ - for(Int_t iRpc=0; iRpc<iNumRpc[iCh];iRpc++){ - fDigiStatusMonitor->cd(iCanv+1); iCanv++; - gROOT->cd(); - TString hname=Form("cl_SmT%01d_sm%03d_rpc%03d_DigiCor",iType[iCh],iSm,iRpc); - h2=(TH2 *)gROOT->FindObjectAny(hname); - if (h2!=NULL) { - h2->Draw("colz"); - //gPad->SetLogz(); - } else { - LOG(info)<<"Histogram "<<hname<<" not existing. "; - fbMonitorDigiStatus=kFALSE; - } - } - } - } - } - - if( kTRUE == fbMonitorRes ) - { - fOverviewRes = new TCanvas("OverviewRes","Overview TDC Resolution (RMS and Fit)",48,56,1000,700); - fOverviewRes->Divide(2); - fhResolutionSummary = new TH2D("fhResolutionSummary", "TDC Resolution summary (Fit); TDC #1 []; TDC #2 [] ", - fNumberOfTDC - 1, 0, fNumberOfTDC - 1, - fNumberOfTDC - 1, 1, fNumberOfTDC ); - fhResolutionSummary->SetStats(kFALSE); - - fhResolutionRmsSummary = new TH2D("fhResolutionRmsSummary", "TDC Resolution summary (RMS); TDC #1 []; TDC #2 [] ", - fNumberOfTDC - 1, 0, fNumberOfTDC - 1, - fNumberOfTDC - 1, 1, fNumberOfTDC ); - fhResolutionRmsSummary->SetStats(kFALSE); - } // if( kTRUE == fbMonitorRes ) - - if( kTRUE == fbMonitorRates ) - { - fCanvRatesMonitor = new TCanvas("OverviewRates","Overview TrigLog scaler rates (MBS and free)",48,56,1000,700); - fCanvRatesMonitor->Divide(3, 2); - fStackMbsTrloA = new THStack("fStackMbsTrloA", - "Evolution of MBS scalers 1- 8 rates; Time since start [s]; Rate [Hz] "); - fStackMbsTrloB = new THStack("fStackMbsTrloB", - "Evolution of MBS scalers 9-16 rates; Time since start [s]; Rate [Hz] "); - fStackFreeTrloA = new THStack("fStackFreeTrloA", - "Evolution of Free scalers 1- 8 rates; Time since start [s]; Rate [Hz] "); - fStackFreeTrloB = new THStack("fStackFreeTrloB", - "Evolution of Free scalers 9-16 rates; Time since start [s]; Rate [Hz] "); - fStackFreeTrloOutA = new THStack("fStackFreeTrloOutA", - "Evolution of Free output scalers 1- 8 counts; Time since start [s]; Counts [] "); - fStackFreeTrloOutB = new THStack("fStackFreeTrloOutB", - "Evolution of Free output scalers 9-16 counts; Time since start [s]; Counts [] "); - fLegStackMbsTrloA = new TLegend(0.80,0.5,0.99,0.9); - fLegStackMbsTrloB = new TLegend(0.80,0.5,0.99,0.9); - fLegStackFreeTrloA = new TLegend(0.80,0.5,0.99,0.9); - fLegStackFreeTrloB = new TLegend(0.80,0.5,0.99,0.9); - fLegStackFreeTrloOutA = new TLegend(0.80,0.5,0.99,0.9); - fLegStackFreeTrloOutB = new TLegend(0.80,0.5,0.99,0.9); - - TProfile * pTemp = NULL; - Int_t iColorsArr[8] = { kRed, kBlue, kGreen+3, kOrange+1, - kMagenta+1, kBlack, kViolet-6, kCyan+2}; - gROOT->cd(); - for( Int_t iCh = 0; iCh < 16; iCh++) - { - TString hname; - if( iCh < 8 ) - { - hname=Form("tof_cal_triglog_00_scal_evo_00_%02d",iCh); - pTemp=(TProfile *)gROOT->FindObjectAny(hname); - if( NULL != pTemp) - { - pTemp->SetLineColor( iColorsArr[iCh] ); - fStackMbsTrloA->Add(pTemp); - fLegStackMbsTrloA->AddEntry(pTemp,Form("Ch %02d", iCh),"l"); - } // if( NULL != pTemp) - - hname=Form("tof_cal_trigscal_07_scal_evo_00_%02d",iCh); - pTemp=(TProfile *)gROOT->FindObjectAny(hname); - if( NULL != pTemp) - { - pTemp->SetLineColor( iColorsArr[iCh] ); - fStackFreeTrloA->Add(pTemp); -// fLegStackFreeTrloA->AddEntry(pTemp,Form("Ch %02d", iCh),"l"); - fLegStackFreeTrloA->AddEntry(pTemp,fsFreeTrloNames[iCh],"l"); - } // if( NULL != pTemp) - - hname=Form("tof_trigscal_00_scalers_evo_01_%02d",iCh); - h1=(TH1 *)gROOT->FindObjectAny(hname); - if( NULL != h1) - { - h1->SetLineColor( iColorsArr[iCh] ); - fStackFreeTrloOutA->Add(h1); - fLegStackFreeTrloOutA->AddEntry(h1,Form("LmuO %01d", iCh),"l"); -// fLegStackFreeTrloOutA->AddEntry(pTemp,fsFreeTrloNames[iCh],"l"); - } // if( NULL != pTemp) - } // if( iCh < 8 ) - else - { - hname=Form("tof_cal_triglog_00_scal_evo_00_%02d",iCh); - pTemp=(TProfile *)gROOT->FindObjectAny(hname); - if( NULL != pTemp) - { - pTemp->SetLineColor( iColorsArr[iCh - 8] ); - fStackMbsTrloB->Add(pTemp); - fLegStackMbsTrloB->AddEntry(pTemp,Form("Ch %02d", iCh),"l"); - } // if( NULL != pTemp) - - hname=Form("tof_cal_trigscal_07_scal_evo_00_%02d",iCh); - pTemp=(TProfile *)gROOT->FindObjectAny(hname); - if( NULL != pTemp) - { - pTemp->SetLineColor( iColorsArr[iCh - 8] ); - fStackFreeTrloB->Add(pTemp); -// fLegStackFreeTrloB->AddEntry(pTemp,Form("Ch %02d", iCh),"l"); - fLegStackFreeTrloB->AddEntry(pTemp,fsFreeTrloNames[iCh],"l"); - } // if( NULL != pTemp) - - hname=Form("tof_trigscal_00_scalers_evo_01_%02d",iCh); - h1=(TH1 *)gROOT->FindObjectAny(hname); - if( NULL != h1) - { - h1->SetLineColor( iColorsArr[iCh - 8] ); - fStackFreeTrloOutB->Add(h1); - fLegStackFreeTrloOutB->AddEntry(h1,Form("LmuO %02d", iCh),"l"); -// fLegStackFreeTrloOutB->AddEntry(pTemp,fsFreeTrloNames[iCh],"l"); - } // if( NULL != pTemp) - - } // else of if( iCh < 8 ) - } // for( Int_t iCh = 0; iCh < 16; iCh++) - - fCanvRatesMonitor->cd(1); - fStackMbsTrloA->Draw("nostack"); - fLegStackMbsTrloA->Draw(); - - fCanvRatesMonitor->cd(2); - fStackFreeTrloA->Draw("nostack"); - fLegStackFreeTrloA->Draw(); - - fCanvRatesMonitor->cd(3); - fStackFreeTrloOutA->Draw("nostack"); - fLegStackFreeTrloOutB->Draw(); - - fCanvRatesMonitor->cd(4); - fStackMbsTrloB->Draw("nostack"); - fLegStackMbsTrloB->Draw(); - - fCanvRatesMonitor->cd(5); - fStackFreeTrloB->Draw("nostack"); - fLegStackFreeTrloB->Draw(); - - fCanvRatesMonitor->cd(6); - fStackFreeTrloOutB->Draw("nostack"); - fLegStackFreeTrloOutB->Draw(); - } // if( kTRUE == fbMonitorRes ) - - - return kSUCCESS; - -} - -// ---- ReInit ------------------------------------------------------- -InitStatus CbmTofOnlineDisplay::ReInit() -{ - LOG(debug) << "Initilization of CbmTofOnlineDisplay"; - return kSUCCESS; -} - -// ---- Exec ---------------------------------------------------------- -void CbmTofOnlineDisplay::Exec(Option_t* /*option*/) -{ - - fEventCounter++; - - if ( 0 == fEventCounter%fUpdateInterval ) { - LOG(debug)<<"Update Canvas for Event "<< fEventCounter; - - if( fbMonitorTdcOcc ) - { - for(Int_t iCh=0; iCh<fNumberOfTDC; iCh++){ - fTdcChannelOccupancy->cd(iCh+1); - gPad->Modified(); - gPad->Update(); - } - fTdcChannelOccupancy->Modified(); - fTdcChannelOccupancy->Update(); - } - - if( fbMonitorInspection ) - { - for(Int_t iCh=0; iCh<fNumberOfTDC; iCh++){ - fLeadingEdgeOnly->cd(iCh+1); - gPad->Modified(); - gPad->Update(); - } - - fLeadingEdgeOnly->Modified(); - fLeadingEdgeOnly->Update(); - - for(Int_t iCh=0; iCh<fNumberOfTDC; iCh++){ - fTrailingEdgeOnly->cd(iCh+1); - gPad->Modified(); - gPad->Update(); - } - - fTrailingEdgeOnly->Modified(); - fTrailingEdgeOnly->Update(); - - for(Int_t iCh=0; iCh<fNumberOfTDC; iCh++){ - fUnequalEdgeCounts->cd(iCh+1); - gPad->Modified(); - gPad->Update(); - } - - fUnequalEdgeCounts->Modified(); - fUnequalEdgeCounts->Update(); - - for(Int_t iCh=0; iCh<fNumberOfTDC; iCh++){ - fTimeOverThreshold->cd(iCh+1); - gPad->Modified(); - gPad->Update(); - } - - fTimeOverThreshold->Modified(); - fTimeOverThreshold->Update(); - - for(Int_t iCh=0; iCh<fNumberOfTDC; iCh++){ - fLeadingPosition->cd(iCh+1); - gPad->Modified(); - gPad->Update(); - } - - fLeadingPosition->Modified(); - fLeadingPosition->Update(); - - for(Int_t iCh=0; iCh<fNumberOfTDC; iCh++){ - fTrailingPosition->cd(iCh+1); - gPad->Modified(); - gPad->Update(); - } - - fTrailingPosition->Modified(); - fTrailingPosition->Update(); - - for(Int_t iCh=0; iCh<fNumberOfTDC; iCh++){ - fBoardFineTime->cd(iCh+1); - gPad->Modified(); - gPad->Update(); - } - - fBoardFineTime->Modified(); - fBoardFineTime->Update(); - - fRefChFineTime->Modified(); - fRefChFineTime->Update(); - - } - - if( fbMonitorCts ) - { - fCtsTriggerMonitor->cd(1); - gPad->Modified(); - gPad->Update(); - - fCtsTriggerMonitor->cd(2); - gPad->Modified(); - gPad->Update(); - - fCtsTriggerMonitor->cd(3); - gPad->Modified(); - gPad->Update(); - - fCtsTriggerMonitor->cd(4); - gPad->Modified(); - gPad->Update(); - - fCtsTriggerMonitor->cd(5); - gPad->Modified(); - gPad->Update(); - - fCtsTriggerMonitor->cd(6); - gPad->Modified(); - gPad->Update(); - - fCtsTriggerMonitor->cd(7); - gPad->Modified(); - gPad->Update(); - - fCtsTriggerMonitor->cd(8); - gPad->Modified(); - gPad->Update(); - - fCtsTriggerMonitor->cd(9); - gPad->Modified(); - gPad->Update(); - - fCtsTriggerMonitor->cd(10); - gPad->Modified(); - gPad->Update(); - - fCtsTriggerMonitor->cd(11); - gPad->Modified(); - gPad->Update(); - - fCtsTriggerMonitor->cd(12); - gPad->Modified(); - gPad->Update(); - - fCtsTriggerMonitor->Modified(); - fCtsTriggerMonitor->Update(); - } - - if( fbMonitorSebStatus ) - { - for(Int_t iCh=0; iCh<fNumberOfSEB; iCh++){ - fSebSizeMonitor->cd(iCh+1); - gPad->Modified(); - gPad->Update(); - } - - fSebSizeMonitor->Modified(); - fSebSizeMonitor->Update(); - - for(Int_t iCh=0; iCh<fNumberOfSEB; iCh++){ - fSebStatusMonitor->cd(iCh+1); - gPad->Modified(); - gPad->Update(); - } - - fSebStatusMonitor->Modified(); - fSebStatusMonitor->Update(); - - for(Int_t iCh=0; iCh<fNumberOfSEB; iCh++){ - fSebDataRateMonitor->cd(iCh+1); - gPad->Modified(); - gPad->Update(); - } - - fSebDataRateMonitor->Modified(); - fSebDataRateMonitor->Update(); - } - - if( fbMonitorTdcStatus ) - { - for(Int_t iCh=0; iCh<fNumberOfTDC; iCh++){ - fTdcSizeMonitor->cd(iCh+1); - gPad->Modified(); - gPad->Update(); - } - - fTdcSizeMonitor->Modified(); - fTdcSizeMonitor->Update(); - - for(Int_t iCh=0; iCh<fNumberOfTDC; iCh++){ - fTdcStatusMonitor->cd(iCh+1); - gPad->Modified(); - gPad->Update(); - } - - fTdcStatusMonitor->Modified(); - fTdcStatusMonitor->Update(); - } - - if( fbMonitorFSMockup ) - { - fFSMockupMonitor->cd(1); - gPad->Modified(); - gPad->Update(); - - fFSMockupMonitor->cd(2); - gPad->Modified(); - gPad->Update(); - - fFSMockupMonitor->cd(3); - gPad->Modified(); - gPad->Update(); - - fFSMockupMonitor->Modified(); - fFSMockupMonitor->Update(); - } - - if( kTRUE == fbMonitorRes ) - { - fhResolutionSummary->Reset(); - fhResolutionRmsSummary->Reset(); - - TH2 *h2; -// TProfile *pTemp; - TH1 *hTemp; - TF1 *fitFunc; - for(Int_t iTdc1 = 0; iTdc1 < fNumberOfTDC - 1; iTdc1++) - { - // First get the reference comp histogram - TString hname=Form("tof_trb_RefChComp_b%03d", iTdc1); - h2=(TH2 *)gROOT->FindObjectAny(hname); - if (h2!=NULL) - { - if( 0 < h2->GetEntries() ) - { - for(Int_t iTdc2 = iTdc1 + 1; iTdc2 < fNumberOfTDC; iTdc2++) - { - hTemp = h2->ProjectionY("hTemp", iTdc2 - iTdc1, iTdc2 - iTdc1 ); // s to get RMS instead of standard error - - if( 0 < hTemp->GetEntries() && 0 < hTemp->Integral() ) - { - // Fill the RMS plot - fhResolutionRmsSummary->Fill(iTdc1, iTdc2, hTemp->GetRMS() ); - - // Fit and fill the Sigma plot - Int_t iBinPeak = hTemp->GetMaximumBin(); - fitFunc = new TF1( Form("fitFunc_%03d_%03d",iTdc1, iTdc2), "gaus", - hTemp->GetBinCenter(iBinPeak) - 1000 , - hTemp->GetBinCenter(iBinPeak) + 1000); - hTemp->Fit( Form("fitFunc_%03d_%03d",iTdc1, iTdc2), "QRM0"); - fhResolutionSummary->Fill(iTdc1, iTdc2, fitFunc->GetParameter(2) ); - - delete hTemp; - if( NULL != gROOT->FindObjectAny( Form("fitFunc_%03d_%03d",iTdc1, iTdc2) ) ) - delete gROOT->FindObjectAny( Form("fitFunc_%03d_%03d",iTdc1, iTdc2) ) ; - } // if( 0 < hTemp->GetEntries() ) - } // for(Int_t iTdc2 = iTdc1 + 1; iTdc2 < fNumberOfTDC; iTdc2++) - } // if( 0 < h2->GetEntries() ) - } // if (h2!=NULL) - else LOG(info)<<"Histogram "<<hname<<" not existing. "; - } // for(Int_t iCh=0; iCh<fNumberOfTDC; iCh++) - fOverviewRes->cd(1); - fhResolutionRmsSummary->Draw("colz"); - ( fhResolutionRmsSummary->GetZaxis() )->SetRangeUser(10.0, 50.0); - - fOverviewRes->cd(2); - fhResolutionSummary->Draw("colz"); - ( fhResolutionSummary->GetZaxis() )->SetRangeUser(10.0, 50.0); - - fOverviewRes->Modified(); - fOverviewRes->Update(); - } // if( kTRUE == fbMonitorRes ) - - if( fbMonitorDigiStatus ) - { - for(Int_t iCh=0; iCh<20; iCh++){ - fDigiStatusMonitor->cd(iCh+1); - gPad->Modified(); - gPad->Update(); - } - } - if( kTRUE == fbMonitorRates ) - { - if( kTRUE == fbRatesSlidingScale ) - { - TProfile *pTemp = (TProfile *)gROOT->FindObjectAny("tof_cal_triglog_00_scal_evo_00_15"); - Double_t dTimeEnd = pTemp->GetBinCenter( pTemp->FindLastBinAbove( 0.0 ) ); - if( 100.0 < dTimeEnd ) - { - (fStackMbsTrloA->GetXaxis() )->SetRangeUser( dTimeEnd - 100.0, dTimeEnd + 10 ); - (fStackMbsTrloB->GetXaxis() )->SetRangeUser( dTimeEnd - 100.0, dTimeEnd + 10 ); - (fStackFreeTrloA->GetXaxis() )->SetRangeUser( dTimeEnd - 100.0, dTimeEnd + 10 ); - (fStackFreeTrloB->GetXaxis() )->SetRangeUser( dTimeEnd - 100.0, dTimeEnd + 10 ); - (fStackFreeTrloOutA->GetXaxis() )->SetRangeUser( dTimeEnd - 100.0, dTimeEnd + 10 ); - (fStackFreeTrloOutB->GetXaxis() )->SetRangeUser( dTimeEnd - 100.0, dTimeEnd + 10 ); - } // if( 100.0 < dTimeEnd ) - else - { - (fStackMbsTrloA->GetXaxis() )->SetRangeUser( 0.0, dTimeEnd + 10 ); - (fStackMbsTrloB->GetXaxis() )->SetRangeUser( 0.0, dTimeEnd + 10 ); - (fStackFreeTrloA->GetXaxis() )->SetRangeUser( 0.0, dTimeEnd + 10 ); - (fStackFreeTrloB->GetXaxis() )->SetRangeUser( 0.0, dTimeEnd + 10 ); - (fStackFreeTrloOutA->GetXaxis() )->SetRangeUser( 0.0, dTimeEnd + 10 ); - (fStackFreeTrloOutB->GetXaxis() )->SetRangeUser( 0.0, dTimeEnd + 10 ); - } // else of if( 100.0 < dTimeEnd ) - } // if( kTRUE == fbRatesSlidingScale ) - - fCanvRatesMonitor->cd(1); - gPad->SetLogy(); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->Modified(); - gPad->Update(); - - fCanvRatesMonitor->cd(2); - gPad->SetLogy(); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->Modified(); - gPad->Update(); - - fCanvRatesMonitor->cd(3); - gPad->SetLogy(); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->Modified(); - gPad->Update(); - - fCanvRatesMonitor->cd(4); - gPad->SetLogy(); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->Modified(); - gPad->Update(); - - fCanvRatesMonitor->cd(5); - gPad->SetLogy(); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->Modified(); - gPad->Update(); - - fCanvRatesMonitor->cd(6); -// gPad->SetLogy(); - gPad->SetGridx(); - gPad->SetGridy(); - gPad->Modified(); - gPad->Update(); - - } // if( kTRUE == fbMonitorRes ) - } -} - -// ---- Finish -------------------------------------------------------- -void CbmTofOnlineDisplay::Finish() -{ - LOG(info)<<"Finish of CbmTofOnlineDisplay"; - - if( fbMonitorTdcOcc ) - fTdcChannelOccupancy->Update(); - - if( fbMonitorCalibration ) - { - TLegendEntry* tEntry; - - TGraph* tGraphRmsLinear = dynamic_cast<TGraph*>(gROOT->FindObjectAny("tGraphRmsLinear")); - TGraph* tGraphSigmaLinear = dynamic_cast<TGraph*>(gROOT->FindObjectAny("tGraphSigmaLinear")); - TGraph* tGraphRmsBinCenter = dynamic_cast<TGraph*>(gROOT->FindObjectAny("tGraphRmsBinCenter")); - TGraph* tGraphSigmaBinCenter = dynamic_cast<TGraph*>(gROOT->FindObjectAny("tGraphSigmaBinCenter")); - TGraph* tGraphRmsBinEdge = dynamic_cast<TGraph*>(gROOT->FindObjectAny("tGraphRmsBinEdge")); - TGraph* tGraphSigmaBinEdge = dynamic_cast<TGraph*>(gROOT->FindObjectAny("tGraphSigmaBinEdge")); - - TGraph* tGraphHistoMeanLinear = dynamic_cast<TGraph*>(gROOT->FindObjectAny("tGraphHistoMeanLinear")); - TGraph* tGraphGausMeanLinear = dynamic_cast<TGraph*>(gROOT->FindObjectAny("tGraphGausMeanLinear")); - TGraph* tGraphHistoMeanBinCenter = dynamic_cast<TGraph*>(gROOT->FindObjectAny("tGraphHistoMeanBinCenter")); - TGraph* tGraphGausMeanBinCenter = dynamic_cast<TGraph*>(gROOT->FindObjectAny("tGraphGausMeanBinCenter")); - TGraph* tGraphHistoMeanBinEdge = dynamic_cast<TGraph*>(gROOT->FindObjectAny("tGraphHistoMeanBinEdge")); - TGraph* tGraphGausMeanBinEdge = dynamic_cast<TGraph*>(gROOT->FindObjectAny("tGraphGausMeanBinEdge")); - - // Workaround to prevent (not understood) warning messages like - // Warning in <TROOT::Append>: Replacing existing TH1: tGraphRmsBinCenter (Potential memory leak). - // from popping up when multiple named TGraph objects added to the list of gROOT memory objects are drawn - // onto the same pad. - // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - gROOT->GetList()->Remove(tGraphRmsLinear); - gROOT->GetList()->Remove(tGraphSigmaLinear); - gROOT->GetList()->Remove(tGraphRmsBinCenter); - gROOT->GetList()->Remove(tGraphSigmaBinCenter); - gROOT->GetList()->Remove(tGraphRmsBinEdge); - gROOT->GetList()->Remove(tGraphSigmaBinEdge); - - gROOT->GetList()->Remove(tGraphHistoMeanLinear); - gROOT->GetList()->Remove(tGraphGausMeanLinear); - gROOT->GetList()->Remove(tGraphHistoMeanBinCenter); - gROOT->GetList()->Remove(tGraphGausMeanBinCenter); - gROOT->GetList()->Remove(tGraphHistoMeanBinEdge); - gROOT->GetList()->Remove(tGraphGausMeanBinEdge); - // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - if(tGraphRmsLinear && tGraphRmsBinCenter && tGraphRmsBinEdge) - { - fBoardOffsetGraphs->cd(1); - gPad->SetGridx(); - gPad->SetGridy(); - tGraphRmsLinear->SetMarkerColor(1); - tGraphRmsBinCenter->SetMarkerColor(4); - tGraphRmsBinEdge->SetMarkerColor(2); - tGraphRmsLinear->SetMarkerStyle(20); - tGraphRmsBinCenter->SetMarkerStyle(21); - tGraphRmsBinEdge->SetMarkerStyle(22); - tGraphRmsLinear->GetXaxis()->SetTitle("TDC index []"); - tGraphRmsLinear->GetYaxis()->SetTitle("RMS [ps]"); - tGraphRmsLinear->Draw("AP"); - tGraphRmsBinCenter->Draw("P"); - tGraphRmsBinEdge->Draw("P"); - - TLegend* tLegend41 = new TLegend(gPad->GetLeftMargin()+0.05,gPad->GetBottomMargin()+0.05,1.-gPad->GetRightMargin()-0.05,0.5); - tLegend41->SetName("tLegendRms"); - tLegend41->SetHeader(Form("%d events",fEventCounter)); - tEntry = tLegend41->AddEntry("tGraphRmsLinear","linear calibration","P"); - tEntry->SetMarkerSize(1.5); - tEntry = tLegend41->AddEntry("tGraphRmsBinEdge","bin-by-bin edge","P"); - tEntry->SetMarkerSize(1.5); - tEntry = tLegend41->AddEntry("tGraphRmsBinCenter","bin-by-bin center","P"); - tEntry->SetMarkerSize(1.5); - tLegend41->Draw(); - - } - - if(tGraphSigmaLinear && tGraphSigmaBinCenter && tGraphSigmaBinEdge) - { - fBoardOffsetGraphs->cd(2); - gPad->SetGridx(); - gPad->SetGridy(); - tGraphSigmaLinear->SetMarkerColor(1); - tGraphSigmaBinCenter->SetMarkerColor(4); - tGraphSigmaBinEdge->SetMarkerColor(2); - tGraphSigmaLinear->SetMarkerStyle(20); - tGraphSigmaBinCenter->SetMarkerStyle(21); - tGraphSigmaBinEdge->SetMarkerStyle(22); - tGraphSigmaLinear->GetXaxis()->SetTitle("TDC index []"); - tGraphSigmaLinear->GetYaxis()->SetTitle("Sigma [ps]"); - tGraphSigmaLinear->Draw("AP"); - tGraphSigmaBinCenter->Draw("P"); - tGraphSigmaBinEdge->Draw("P"); - - TLegend* tLegend42 = new TLegend(gPad->GetLeftMargin()+0.05,gPad->GetBottomMargin()+0.05,1.-gPad->GetRightMargin()-0.05,0.5); - tLegend42->SetName("tLegendSigma"); - tLegend42->SetHeader(Form("%d events",fEventCounter)); - tEntry = tLegend42->AddEntry("tGraphSigmaLinear","linear calibration","P"); - tEntry->SetMarkerSize(1.5); - tEntry = tLegend42->AddEntry("tGraphSigmaBinEdge","bin-by-bin edge","P"); - tEntry->SetMarkerSize(1.5); - tEntry = tLegend42->AddEntry("tGraphSigmaBinCenter","bin-by-bin center","P"); - tEntry->SetMarkerSize(1.5); - tLegend42->Draw(); - - } - - if(tGraphHistoMeanLinear && tGraphHistoMeanBinCenter && tGraphHistoMeanBinEdge) - { - fBoardOffsetGraphs->cd(3); - gPad->SetLogy(); - gPad->SetGridx(); - gPad->SetGridy(); - tGraphHistoMeanLinear->SetMarkerColor(1); - tGraphHistoMeanBinCenter->SetMarkerColor(4); - tGraphHistoMeanBinEdge->SetMarkerColor(2); - tGraphHistoMeanLinear->SetMarkerStyle(20); - tGraphHistoMeanBinCenter->SetMarkerStyle(21); - tGraphHistoMeanBinEdge->SetMarkerStyle(22); - tGraphHistoMeanLinear->GetXaxis()->SetTitle("TDC index []"); - tGraphHistoMeanLinear->GetYaxis()->SetTitle("h-Mean [clock cycles]"); - tGraphHistoMeanLinear->Draw("AP"); - tGraphHistoMeanBinCenter->Draw("P"); - tGraphHistoMeanBinEdge->Draw("P"); - tGraphHistoMeanLinear->GetYaxis()->SetRangeUser(1.,1000000000000.); - - } - - if(tGraphGausMeanLinear && tGraphGausMeanBinCenter && tGraphGausMeanBinEdge) - { - fBoardOffsetGraphs->cd(4); - gPad->SetLogy(); - gPad->SetGridx(); - gPad->SetGridy(); - tGraphGausMeanLinear->SetMarkerColor(1); - tGraphGausMeanBinCenter->SetMarkerColor(4); - tGraphGausMeanBinEdge->SetMarkerColor(2); - tGraphGausMeanLinear->SetMarkerStyle(20); - tGraphGausMeanBinCenter->SetMarkerStyle(21); - tGraphGausMeanBinEdge->SetMarkerStyle(22); - tGraphGausMeanLinear->GetXaxis()->SetTitle("TDC index []"); - tGraphGausMeanLinear->GetYaxis()->SetTitle("g-Mean [clock cycles]"); - tGraphGausMeanLinear->Draw("AP"); - tGraphGausMeanBinCenter->Draw("P"); - tGraphGausMeanBinEdge->Draw("P"); - tGraphGausMeanLinear->GetYaxis()->SetRangeUser(1.,1000000000000.); - - } - - - for(Int_t iBoardIndex = 0; iBoardIndex < fNumberOfTDC; iBoardIndex++) - { - TH1D* tOffsetsLinear = dynamic_cast<TH1D*>(gROOT->FindObjectAny(Form("tOffsetsLinear%d",iBoardIndex))); - TH1D* tOffsetsBinCenter = dynamic_cast<TH1D*>(gROOT->FindObjectAny(Form("tOffsetsBinCenter%d",iBoardIndex))); - TH1D* tOffsetsBinEdge = dynamic_cast<TH1D*>(gROOT->FindObjectAny(Form("tOffsetsBinEdge%d",iBoardIndex))); - - if( tOffsetsLinear ) - { - fBoardOffsetLinear->cd(iBoardIndex+1); - gPad->SetLogy(); - tOffsetsLinear->GetXaxis()->SetRangeUser(tOffsetsLinear->GetMean()-0.3,tOffsetsLinear->GetMean()+0.3); - tOffsetsLinear->Draw(); - gPad->Update(); - (tOffsetsLinear->GetFunction("gaus"))->SetLineWidth(3); - (tOffsetsLinear->GetFunction("gaus"))->Draw("same"); - gPad->Update(); - gPad->Modified(); - } - - if( tOffsetsBinCenter ) - { - fBoardOffsetBinCenter->cd(iBoardIndex+1); - gPad->SetLogy(); - tOffsetsBinCenter->GetXaxis()->SetRangeUser(tOffsetsBinCenter->GetMean()-0.3,tOffsetsBinCenter->GetMean()+0.3); - tOffsetsBinCenter->Draw(); - gPad->Update(); - (tOffsetsBinCenter->GetFunction("gaus"))->SetLineWidth(3); - (tOffsetsBinCenter->GetFunction("gaus"))->Draw("same"); - gPad->Update(); - gPad->Modified(); - } - - if( tOffsetsBinEdge ) - { - fBoardOffsetBinEdge->cd(iBoardIndex+1); - gPad->SetLogy(); - tOffsetsBinEdge->GetXaxis()->SetRangeUser(tOffsetsBinEdge->GetMean()-0.3,tOffsetsBinEdge->GetMean()+0.3); - tOffsetsBinEdge->Draw(); - gPad->Update(); - (tOffsetsBinEdge->GetFunction("gaus"))->SetLineWidth(3); - (tOffsetsBinEdge->GetFunction("gaus"))->Draw("same"); - gPad->Update(); - gPad->Modified(); - } - } - - } - - if( fbMonitorInspection ) - { - fLeadingEdgeOnly->Update(); - fTrailingEdgeOnly->Update(); - fUnequalEdgeCounts->Update(); - fTimeOverThreshold->Update(); - fLeadingPosition->Update(); - fTrailingPosition->Update(); - fBoardFineTime->Update(); - fRefChFineTime->Update(); - } - - if( fbMonitorCts ) - { - fCtsTriggerMonitor->Update(); - } - if( fbMonitorSebStatus ) - { - fSebSizeMonitor->Update(); - fSebStatusMonitor->Update(); - fSebDataRateMonitor->Update(); - } - if( fbMonitorTdcStatus ) - { - fTdcSizeMonitor->Update(); - fTdcStatusMonitor->Update(); - } - if( fbMonitorFSMockup ) - { - fFSMockupMonitor->Update(); - } - if( kTRUE == fbMonitorRes ) - fOverviewRes->Update(); - - if( fbMonitorDigiStatus ) - { - fDigiStatusMonitor->Update(); - } - -} - -Bool_t CbmTofOnlineDisplay::InitParameters() -{ - // Get Base Container - FairRun* ana = FairRun::Instance(); - if( 0 == ana ) - return kFALSE; - FairRuntimeDb* rtdb=ana->GetRuntimeDb(); - if( 0 == rtdb ) - return kFALSE; - - // Unpacker parameter - fMbsUnpackPar = (TMbsUnpackTofPar*) (rtdb->getContainer("TMbsUnpackTofPar")); - if( 0 == fMbsUnpackPar ) - return kFALSE; - - // Call needed here to make available calibration parameters - // in the TRB unpack stage - fMbsCalibPar = (TMbsCalibTofPar*) (rtdb->getContainer("TMbsCalibTofPar")); - if( 0 == fMbsCalibPar ) - return kFALSE; - - return kTRUE; -} - -ClassImp(CbmTofOnlineDisplay) diff --git a/beamtime/tof/display/CbmTofOnlineDisplay.h b/beamtime/tof/display/CbmTofOnlineDisplay.h deleted file mode 100644 index e412817afbf07e1732bcdc1a645fd8a0c9f9ed38..0000000000000000000000000000000000000000 --- a/beamtime/tof/display/CbmTofOnlineDisplay.h +++ /dev/null @@ -1,157 +0,0 @@ -#ifndef CBMTOFONLINEDISPLAY_H -#define CBMTOFONLINEDISPLAY_H - -#include "FairTask.h" - -#include <vector> - -// Parameters -class TMbsUnpackTofPar; -class TMbsCalibTofPar; - -class TClonesArray; -class TCanvas; -class TH2; -class THStack; -class TLegend; - -class CbmTofOnlineDisplay : public FairTask -{ - public: - - /** Default constructor **/ - CbmTofOnlineDisplay(); - - /** Constructor with parameters (Optional) **/ - // CbmTofOnlineDisplay(Int_t verbose); - - - /** Destructor **/ - ~CbmTofOnlineDisplay(); - - - /** Initiliazation of task at the beginning of a run **/ - virtual InitStatus Init(); - - /** ReInitiliazation of task when the runID changes **/ - virtual InitStatus ReInit(); - - - /** Executed for each event. **/ - virtual void Exec(Option_t* opt); - - /** Load the parameter container from the runtime database **/ - virtual void SetParContainers(); - - /** Finish task called at the end of the run **/ - virtual void Finish(); - - void SetNumberOfTDC(Int_t val) { fNumberOfTDC = val; } - void SetUpdateInterval(Int_t val) { fUpdateInterval = val; } - - void SetResMonitorEna( Bool_t bInEna = kTRUE ){ fbMonitorRes = bInEna; }; - - void MonitorTdcOccupancy( Bool_t bMonitor = kTRUE){ fbMonitorTdcOcc = bMonitor; }; - void MonitorCts( Bool_t bMonitor = kTRUE){ fbMonitorCts = bMonitor; }; - void MonitorSebStatus( Bool_t bMonitor = kTRUE){ fbMonitorSebStatus = bMonitor; }; - void MonitorTdcStatus( Bool_t bMonitor = kTRUE){ fbMonitorTdcStatus = bMonitor; }; - void MonitorFSMockup( Bool_t bMonitor = kTRUE){ fbMonitorFSMockup = bMonitor; }; - void MonitorDigiStatus( Bool_t bMonitor = kTRUE){ fbMonitorDigiStatus = bMonitor; }; - void MonitorInspection( Bool_t bMonitor = kTRUE){ fbMonitorInspection = bMonitor; }; - void MonitorCalibration( Bool_t bMonitor = kTRUE){ fbMonitorCalibration = bMonitor; }; - - void SetNumberOfSEB(Int_t val) { fNumberOfSEB = val; } - - void SetRateMonitorEna( Bool_t bInEna = kTRUE ){ fbMonitorRates = bInEna; }; - void SetFreeTrloNames( TString sChA, TString sChB, TString sChC, TString sChD, - TString sChE, TString sChF, TString sChG, TString sChH, - TString sChI, TString sChJ, TString sChK, TString sChL, - TString sChM, TString sChN, TString sChO, TString sChP ); - void RatesSlidingScaleEna( Bool_t bInEna = kTRUE ){ fbRatesSlidingScale = bInEna; }; - - private: - - /** Input array from previous already existing data level **/ - // TClonesArray* <InputDataLevel>; - - /** Output array to new data level**/ - // TClonesArray* <OutputDataLevel>; - - Bool_t InitParameters(); - TMbsUnpackTofPar *fMbsUnpackPar; - TMbsCalibTofPar *fMbsCalibPar; - - Bool_t fbMonitorTdcOcc; - TCanvas* fTdcChannelOccupancy; //! - - Int_t fNumberOfTDC; - Int_t fNumberOfSEB; - Int_t fUpdateInterval; - Int_t fEventCounter; - - Bool_t fbMonitorCts; - TCanvas* fCtsTriggerMonitor; //! - - Bool_t fbMonitorSebStatus; - TCanvas* fSebSizeMonitor; //! - TCanvas* fSebStatusMonitor; //! - TCanvas* fSebDataRateMonitor; //! - - Bool_t fbMonitorTdcStatus; - TCanvas* fTdcSizeMonitor; //! - TCanvas* fTdcStatusMonitor; //! - - Bool_t fbMonitorFSMockup; - TCanvas* fFSMockupMonitor; //! - - // Monitoring of the TDC resolution stability using reference channel - Bool_t fbMonitorRes; - TCanvas* fOverviewRes; //! - TH2* fhResolutionSummary; //! - TH2* fhResolutionRmsSummary; //! - - Bool_t fbMonitorDigiStatus; - TCanvas* fDigiSizeMonitor; //! - TCanvas* fDigiStatusMonitor; //! - - // Monitoring of the rates from Triglog and/or scalers - Bool_t fbMonitorRates; - TString fsFreeTrloNames[16]; - TCanvas* fCanvRatesMonitor; //! - THStack* fStackMbsTrloA; //! - THStack* fStackMbsTrloB; //! - THStack* fStackFreeTrloA; //! - THStack* fStackFreeTrloB; //! - THStack* fStackFreeTrloOutA; //! - THStack* fStackFreeTrloOutB; //! - TLegend* fLegStackMbsTrloA; //! - TLegend* fLegStackMbsTrloB; //! - TLegend* fLegStackFreeTrloA; //! - TLegend* fLegStackFreeTrloB; //! - TLegend* fLegStackFreeTrloOutA; //! - TLegend* fLegStackFreeTrloOutB; //! - Bool_t fbRatesSlidingScale; //! - - Bool_t fbMonitorInspection; - TCanvas* fLeadingEdgeOnly; //! - TCanvas* fTrailingEdgeOnly; //! - TCanvas* fUnequalEdgeCounts; //! - TCanvas* fTimeOverThreshold; //! - TCanvas* fLeadingPosition; //! - TCanvas* fTrailingPosition; //! - TCanvas* fBoardFineTime; //! - TCanvas* fRefChFineTime; //! - - Bool_t fbMonitorCalibration; - TCanvas* fBoardOffsetGraphs; //! - TCanvas* fBoardOffsetLinear; //! - TCanvas* fBoardOffsetBinCenter; //! - TCanvas* fBoardOffsetBinEdge; //! - - CbmTofOnlineDisplay(const CbmTofOnlineDisplay&); - CbmTofOnlineDisplay operator=(const CbmTofOnlineDisplay&); - - ClassDef(CbmTofOnlineDisplay,1); -}; - -#endif diff --git a/beamtime/tof/hadaq/CbmHldSource.cxx b/beamtime/tof/hadaq/CbmHldSource.cxx deleted file mode 100644 index 2cd4ce0f8b2c1fff8a3d9154ca49d82bb4d1f836..0000000000000000000000000000000000000000 --- a/beamtime/tof/hadaq/CbmHldSource.cxx +++ /dev/null @@ -1,520 +0,0 @@ -/** @file CbmHldSource.cxx - ** @author Christian Simon <csimon@physi.uni-heidelberg.de> - ** @date 2015-11-25 - **/ - -#include "CbmHldSource.h" - -#include "HadaqDefines.h" - -#include "FairLogger.h" - -#include "TSystem.h" -#include "TList.h" -#include "TObjString.h" -#include "TRegexp.h" -#include "TSystemDirectory.h" - -// ===== default constructor =============================================== -CbmHldSource::CbmHldSource() - : FairMbsSource(), - fFileNames(new TList()), - fNFiles(0), - fCurrentFile(0), - fCurrentFileName(""), - fNEvents(0), - fCurrentEvent(0), - fFileStream(new std::ifstream()), - fDataBuffer(new Char_t[hadaq::HADTU_PAYLOAD_MAX]), - fNoMoreEvents(kFALSE) -{ -} -// ============================================================================= - -// ============================================================================= -CbmHldSource::~CbmHldSource() -{ - fFileNames->Delete(); //TODO: does it delete the TObjString instances? - delete fFileNames; - - delete fFileStream; - - delete[] fDataBuffer; -} -// ============================================================================= - -// ============================================================================= -Bool_t CbmHldSource::Init() -{ - fNFiles = fFileNames->GetEntries(); - - if(!fNFiles) - { - LOG(error) << - TString::Format("\nNo input data file given to the data " - "source. Please add at least one input data " - "file by calling CbmHldSource::AddFile " - "prior to calling FairRunOnline::Init." - ).Data(); - - return kFALSE; - } - - for(Int_t i = 0; i < fNFiles; i++) - { - TString tFileName = ((TObjString*)fFileNames->At(i))->GetString(); - - if(!tFileName.EndsWith(".hld")) - { - LOG(error) << - TString::Format("\nFile extension of input data file %s " - "is not compatible with CbmHldSource.", - tFileName.Data() - ).Data(); - - return kFALSE; - } - } - - if(!OpenNextFile()) - { - return kFALSE; - } - - fNEvents = 0; - - return kTRUE; -} -// ============================================================================= - -// ============================================================================= -Int_t CbmHldSource::ReadEvent(UInt_t) -{ - // return values: 0 -- all fine - // 1 -- source could not read event from file (stop event loop) - // 2 -- unpacker could not handle event (skip it) - - if(fNoMoreEvents) - { - LOG(info) << - TString::Format("\nNo more events to be offered by this " - "FairSource instance.\nIn total, %10d events " - "were successfully unpacked for analysis.", - fNEvents - ).Data(); - - return 1; - - } - - Int_t iEvHeaderSize = sizeof(hadaq::RawEvent)*sizeof(Char_t); - std::streampos headerPos = fFileStream->tellg(); - fFileStream->read(fDataBuffer, iEvHeaderSize); - - hadaq::RawEvent* tRawEventHeader = (hadaq::RawEvent*)fDataBuffer; - - switch(tRawEventHeader->GetId()) - { - case hadaq::EvtId_runStop: - { - if(static_cast<UInt_t>(iEvHeaderSize) - != tRawEventHeader->GetPaddedSize() - ) - { - - LOG(warn) << - TString::Format("\nInput data file %s does not " - "contain a valid stop event. Possible " - "data corruption. ", - fCurrentFileName.Data() - ).Data(); - } - - LOG(info) << - TString::Format("\nFound a valid stop event in input data " - "file %s.\nIn total, %10d events were " - "extracted.\nThe file will be closed.", - fCurrentFileName.Data(), - fCurrentEvent - ).Data(); - - // reading the last (unknown) character and a hypothetical additional one - // from file to force the EOF bit of ifstream to be set - fFileStream->read(fDataBuffer,2); - - if(!fFileStream->eof()) - { - LOG(warn) << - TString::Format("\nEnd of input data file %s has not " - "been reached although a valid stop " - "event was found. The additional file " - "content will be discarded.", - fCurrentFileName.Data() - ).Data(); - } - - CloseFile(); - - if(fCurrentFile != fNFiles) - { - if(OpenNextFile()) - { - return ReadEvent(); - } - else - { - LOG(error) << - TString::Format("\nAborting event loop as the next " - "input file could not be opened." - ).Data(); - } - } - else - { - LOG(info) << - TString::Format("\nAll events in all input data files " - "added to the source have been read.\n" - "In total, %10d events were " - "extracted.", - fNEvents - ).Data(); - } - - fNoMoreEvents = kTRUE; - return 1; - - break; - } - - case hadaq::EvtId_DABC_TrbNet_Type_0: - case hadaq::EvtId_DABC_TrbNet_Type_1: - case hadaq::EvtId_DABC_TrbNet_Type_2: - case hadaq::EvtId_DABC_TrbNet_Type_3: - case hadaq::EvtId_DABC_TrbNet_Type_4: - case hadaq::EvtId_DABC_TrbNet_Type_5: - case hadaq::EvtId_DABC_TrbNet_Type_6: - case hadaq::EvtId_DABC_TrbNet_Type_7: - { - fFileStream->seekg(headerPos); - Int_t* iEvtStart = (Int_t*)fDataBuffer; - Int_t iEvtSize = tRawEventHeader->GetPaddedSize(); - - fFileStream->read(fDataBuffer, iEvtSize); - - if(fFileStream->eof()) - { - LOG(error) << - TString::Format("\nEnd of input data file %s reached " - "after reading regular event %u. We " - "close this file and try to open the " - "next input data file if there is any.", - fCurrentFileName.Data(), - fCurrentEvent - ).Data(); - CloseFile(); - - if(fCurrentFile != fNFiles) - { - if(OpenNextFile()) - { - return ReadEvent(); - } - else - { - LOG(error) << - TString::Format("\nAborting event loop as the next " - "input file could not be opened." - ).Data(); - } - } - else - { - LOG(info) << - TString::Format("\nAll events in all input data files " - "added to the source have been read.\n" - "In total, %10d events were " - "extracted.", - fNEvents - ).Data(); - } - - fNoMoreEvents = kTRUE; - return 1; - } - - LOG(debug1) << - TString::Format("\nSuccessfully read event %u from input " - "data file %s. The raw data is forwarded " - "to the FairUnpack instances registered " - "with the source.", - fCurrentEvent, - fCurrentFileName.Data() - ).Data(); - - for (Int_t i = 0; i < fUnpackers->GetEntriesFast(); i++) - { - FairUnpack* tUnpacker = (FairUnpack*)fUnpackers->At(i); - - // giving 4-byte words as second function argument for compatibility - // with FairRoot MBS sources - if(!tUnpacker->DoUnpack(iEvtStart, iEvtSize/4)) - { - LOG(info) << - TString::Format("\nFairUnpack instance indexed %u " - "of type %s did not unpack HADAQ raw " - "event %u (see log message above). " - "Fully ignore this event.", - i, - tUnpacker->ClassName(), - tRawEventHeader->GetSeqNr() - ).Data(); - return 2; - } - } - - fNEvents++; - fCurrentEvent++; - return 0; - - break; - } - - case hadaq::EvtId_DABC_TrbNet_Type_8: - case hadaq::EvtId_DABC_TrbNet_Type_9: - case hadaq::EvtId_DABC_TrbNet_Type_A: - case hadaq::EvtId_DABC_TrbNet_Type_B: - case hadaq::EvtId_DABC_TrbNet_Type_C: - case hadaq::EvtId_DABC_TrbNet_Type_D: - case hadaq::EvtId_DABC_TrbNet_Type_E: - case hadaq::EvtId_DABC_TrbNet_Type_F: - { - LOG(warn) << - TString::Format("\nThe HadTuId 0x%.8x indicates event " - "%u in input data file %s being " - "triggered by a calibration trigger of " - "type 0x%.1x. Skip unpacking and " - "FairTask execution for this event. If " - "the problem persists, check the TrbNet " - "trigger map in the CTS monitor!", - tRawEventHeader->GetId(), - fCurrentEvent, - fCurrentFileName.Data(), - tRawEventHeader->GetTrigType() - ).Data(); - - headerPos += static_cast<Int_t>(tRawEventHeader->GetPaddedSize()); - fFileStream->seekg(headerPos); - - fCurrentEvent++; - - // The framework will call FairSource::ReadEvent repeatedly until it - // receives return value 0 (event unpacked) or 1 (abort event loop). - return 2; - - break; - } - - default: - LOG(error) << - TString::Format("\nUnknown HadTuId 0x%.8x found in event " - "%u in input data file %s. We stop " - "reading events from this file and try to " - "open the next input data file if there " - "is any.", - tRawEventHeader->GetId(), - fCurrentEvent, - fCurrentFileName.Data() - ).Data(); - - CloseFile(); - - if(fCurrentFile != fNFiles) - { - if(OpenNextFile()) - { - return ReadEvent(); - } - else - { - LOG(error) << - TString::Format("\nAborting event loop as the next " - "input file could not be opened." - ).Data(); - } - } - else - { - LOG(info) << - TString::Format("\nAll events in all input data files " - "added to the source have been read.\n" - "In total, %10d events were " - "extracted.", - fNEvents - ).Data(); - } - - fNoMoreEvents = kTRUE; - return 1; - - break; - } - -} -// ============================================================================= - -// ============================================================================= -void CbmHldSource::Close() -{ -} -// ============================================================================= - -// ============================================================================= -Bool_t CbmHldSource::OpenNextFile() -{ - fCurrentFileName = ((TObjString*)fFileNames->At(fCurrentFile))->GetString(); - - fFileStream->open(fCurrentFileName, std::ifstream::binary | - std::ifstream::ate - ); - - if(!fFileStream->is_open()) - { - LOG(error) << - TString::Format("\nCould not open input data file %s.", - fCurrentFileName.Data() - ).Data(); - - return kFALSE; - } - - Int_t tFileSize = fFileStream->tellg(); - fFileStream->seekg(0, std::ios::beg); - - LOG(info) << - TString::Format("\nSuccessfully opened input data file %s.\n" - "Size: %4d MiB.", - fCurrentFileName.Data(), - tFileSize/1048576 - ).Data(); - - //TODO: HADES file name decoding (optional) - - if(fFileStream->eof()) - { - LOG(error) << - TString::Format("\nInput data file %s seems to be empty.", - fCurrentFileName.Data() - ).Data(); - - CloseFile(); - - return kFALSE; - } - - Int_t iEvHeaderSize = sizeof(hadaq::RawEvent)*sizeof(Char_t); - - fFileStream->read(fDataBuffer, iEvHeaderSize); - - hadaq::RawEvent* tRawEventHeader = (hadaq::RawEvent*)fDataBuffer; - - if((static_cast<UInt_t>(iEvHeaderSize) != tRawEventHeader->GetPaddedSize()) - || (hadaq::EvtId_runStart != tRawEventHeader->GetId()) - ) - { - LOG(error) << - TString::Format("\nInput data file %s does not contain a " - "valid start event. Possible data " - "corruption. ", - fCurrentFileName.Data() - ).Data(); - - CloseFile(); - - return kFALSE; - } - - fCurrentFile++; - fCurrentEvent = 0; - - return kTRUE; - -} -// ============================================================================= - -// ============================================================================= -void CbmHldSource::CloseFile() -{ - fFileStream->close(); -} -// ============================================================================= - -// ============================================================================= -void CbmHldSource::AddFile(const TString& tFileName) -{ - FileStat_t tFileStat; - - if(gSystem->GetPathInfo(tFileName.Data(), tFileStat)) - { - LOG(fatal) << - TString::Format("\nInput data file %s does not exist.", - tFileName.Data() - ).Data(); - } - - TObjString* tObjString = new TObjString(tFileName); - fFileNames->Add(tObjString); -} -// ============================================================================= - -// ============================================================================= -void CbmHldSource::AddPath(const TString& tFileDirectory, - const TString& tFileNameWildCard) -{ - - FileStat_t tFileStat; - if(1 == gSystem->GetPathInfo(tFileDirectory.Data(), tFileStat)) - { - LOG(fatal) << - TString::Format("\nInput data file directory %s does not " - "exist.", - tFileDirectory.Data() - ).Data(); - } - - TRegexp* tRegexp = new TRegexp(tFileNameWildCard.Data(), kTRUE); - - TSystemDirectory* tSystemDirectory = - new TSystemDirectory("dir", tFileDirectory.Data()); - - TString tDirectoryName(tFileDirectory); - - if(!tDirectoryName.EndsWith("/")) - { - tDirectoryName += "/"; - } - - TList* tList = tSystemDirectory->GetListOfFiles(); - tList->Sort(); - - TIterator* tIter = tList->MakeIterator(); - TSystemFile* tSystemFile; - - TString tFileName; - - while(NULL != (tSystemFile = (TSystemFile*)tIter->Next())) - { - tFileName = tSystemFile->GetName(); - - if(tFileName.Contains(*tRegexp)) - { - tFileName = tDirectoryName + tFileName; - - AddFile(tFileName); - } - } - - tList->Delete(); -} -// ============================================================================= - -ClassImp(CbmHldSource) diff --git a/beamtime/tof/hadaq/CbmHldSource.h b/beamtime/tof/hadaq/CbmHldSource.h deleted file mode 100644 index c2d76702fedf0a59f1fe52de7fa279072e6e86ac..0000000000000000000000000000000000000000 --- a/beamtime/tof/hadaq/CbmHldSource.h +++ /dev/null @@ -1,78 +0,0 @@ -/** @file CbmHldSource.h - ** @author Christian Simon <csimon@physi.uni-heidelberg.de> - ** @date 2015-11-25 - **/ - -#ifndef CBMHLDSOURCE_H -#define CBMHLDSOURCE_H 1 - -#include "FairMbsSource.h" - -//#include "TObjArray.h" // already included in "FairMbsSource.h" -#include "TString.h" - -namespace hadaq -{ - struct RawEvent; -} - -class TList; - - -/** @class CbmHldSource - ** @brief ... - ** @author C. Simon <csimon@physi.uni-heidelberg.de> - ** @version 1.0 - ** - ** ... - ** - **/ -class CbmHldSource : public FairMbsSource -{ - public: - - /** default constructor **/ - CbmHldSource(); - - /** default destructor **/ - ~CbmHldSource(); - - /** inherited pure virtual methods from FairSource **/ - Bool_t Init(); - Int_t ReadEvent(UInt_t = 0); - void Close(); - - void AddFile(const TString& tFileName); - void AddPath(const TString& tFileDirectory, - const TString& tFileNameWildCard); - - protected: - - private: - /**private methods*/ - - /** copy constructor **/ - CbmHldSource(const CbmHldSource&); - - /** assignment operator **/ - CbmHldSource& operator=(const CbmHldSource&); - - Bool_t OpenNextFile(); - void CloseFile(); - - /**private members*/ - - TList* fFileNames; - Int_t fNFiles; - Int_t fCurrentFile; - TString fCurrentFileName; - Int_t fNEvents; - Int_t fCurrentEvent; - std::ifstream* fFileStream; - Char_t* fDataBuffer; - Bool_t fNoMoreEvents; - - ClassDef(CbmHldSource,2) -}; - -#endif diff --git a/beamtime/tof/hadaq/HadaqDefines.cxx b/beamtime/tof/hadaq/HadaqDefines.cxx deleted file mode 100644 index 489031f2ab7ec92ece887d62ae87d52bfffd1318..0000000000000000000000000000000000000000 --- a/beamtime/tof/hadaq/HadaqDefines.cxx +++ /dev/null @@ -1,86 +0,0 @@ -// --------------------------------------------------------------------------------- -// ----- HadaqDefines source file ----- -// ----- ----- -// ----- created by C. Simon on 2014-03-06 ----- -// ----- ----- -// ----- based on stream by S. Linev ----- -// ----- https://subversion.gsi.de/go4/app/stream/framework/hadaq/defines.cxx ----- -// ----- revision 1156, 2014-02-14 ----- -// --------------------------------------------------------------------------------- - -#include "HadaqDefines.h" - -#include "TString.h" - -#include "FairLogger.h" -#include <sys/time.h> // for function gettimeofday, and struct timeval (!!Unix!!) -#include <time.h> // for type time_t, functions time and gmtime, and struct tm - -void hadaq::RawEvent::Dump() -{ - LOG(info)<<Form("*** Event #0x%06x fullid=0x%04x size %u ***", - (UInt_t) GetSeqNr(), - (UInt_t) GetId(), - (UInt_t) GetSize() - ); -} - -void hadaq::RawEvent::InitHeader(UInt_t id) -{ - tuDecoding = EvtDecoding_64bitAligned; - SetId(id); - SetSize(sizeof(hadaq::RawEvent)); - // timestamp at creation of structure: - time_t tempo = time(NULL); - struct tm* gmTime = gmtime(&tempo); - UInt_t date = 0, clock = 0; - date |= gmTime->tm_year << 16; - date |= gmTime->tm_mon << 8; - date |= gmTime->tm_mday; - SetDate(date); - clock |= gmTime->tm_hour << 16; - clock |= gmTime->tm_min << 8; - clock |= gmTime->tm_sec; - SetTime(clock); -} - -UInt_t hadaq::RawEvent::CreateRunId() -{ - struct timeval tv; - gettimeofday(&tv, NULL); - return tv.tv_sec - hadaq::HADAQ_TIMEOFFSET; -} - -// =========================================================== - -void hadaq::RawSubevent::Dump(Bool_t print_raw_data) -{ - LOG(info)<<Form(" *** Subevent size %u decoding 0x%06x id 0x%04x trig 0x%08x %s align %u ***", - (UInt_t) GetSize(), - (UInt_t) GetDecoding(), - (UInt_t) GetId(), - (UInt_t) GetTrigNr(), - IsSwapped() ? "swapped" : "not swapped", - (UInt_t) Alignment() - ); - - if (!print_raw_data) return; - - Bool_t newline = true; - - UInt_t size = ((GetSize() - sizeof(RawSubevent)) / Alignment()); - UInt_t width = 2; - if (size>=100) width = 3; - if (size>=1000) width = 4; - - for (UInt_t ix=0; ix < size; ix++) - { - if (ix % 8 == 0) LOG(info)<<Form(" "); newline = false; - - LOG(info)<<Form(" [%*u] %08x", width, ix, (UInt_t) Data(ix)); - - if (((ix + 1) % 8) == 0) { LOG(info); newline = true; } - } - - if (!newline) LOG(info); -} diff --git a/beamtime/tof/hadaq/HadaqDefines.h b/beamtime/tof/hadaq/HadaqDefines.h deleted file mode 100644 index 4a96248c100fb9f4af378fa757e6352383004444..0000000000000000000000000000000000000000 --- a/beamtime/tof/hadaq/HadaqDefines.h +++ /dev/null @@ -1,411 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- HadaqDefines header file ----- -// ----- ----- -// ----- created by C. Simon on 2014-03-06 ----- -// ----- ----- -// ----- based on stream by S. Linev ----- -// ----- https://subversion.gsi.de/go4/app/stream/include/hadaq/defines.h ----- -// ----- revision 967, 2013-05-13 ----- -// ----------------------------------------------------------------------------- - -#ifndef HADAQ_DEFINES_H -#define HADAQ_DEFINES_H - -#include "Rtypes.h" - -#pragma pack(push, 1) - -namespace hadaq { - - enum { - HADAQ_TIMEOFFSET = 1200000000 /* needed to reconstruct time from runId */ - }; - - enum EvtId { - EvtId_data = 0x00000001, - EvtId_DABC = 0x00002001, // hades DAQVERSION=2 (same as evtbuild.c uses DAQVERSION=2) - EvtId_runStart = 0x00010002, - EvtId_runStop = 0x00010003, - EvtId_DABC_TrbNet_Type_0 = 0x00002000, - EvtId_DABC_TrbNet_Type_1 = 0x00002001, - EvtId_DABC_TrbNet_Type_2 = 0x00002002, - EvtId_DABC_TrbNet_Type_3 = 0x00002003, - EvtId_DABC_TrbNet_Type_4 = 0x00002004, - EvtId_DABC_TrbNet_Type_5 = 0x00002005, - EvtId_DABC_TrbNet_Type_6 = 0x00002006, - EvtId_DABC_TrbNet_Type_7 = 0x00002007, - EvtId_DABC_TrbNet_Type_8 = 0x00002008, - EvtId_DABC_TrbNet_Type_9 = 0x00002009, - EvtId_DABC_TrbNet_Type_A = 0x0000200A, - EvtId_DABC_TrbNet_Type_B = 0x0000200B, - EvtId_DABC_TrbNet_Type_C = 0x0000200C, - EvtId_DABC_TrbNet_Type_D = 0x0000200D, - EvtId_DABC_TrbNet_Type_E = 0x0000200E, - EvtId_DABC_TrbNet_Type_F = 0x0000200F - }; - - enum EvtDecoding { - EvtDecoding_default = 1, - EvtDecoding_64bitAligned = (0x03 << 16) | 0x0001 - }; - - enum { - HADTU_PAYLOAD_MAX = 65535 - }; - - /* - * HADES transport unit header - * used as base for event and subevent - * also common envelope for trd network data packets - */ - - struct HadTu { -// protected: - UInt_t tuSize; - UInt_t tuDecoding; - - public: - - HadTu() : - tuSize(0), - tuDecoding(0) - {} - - // Makes destructor virtual to get rid of warning when using as - // base struct - ~HadTu() {} - - /** msb of decode word is always non zero...? */ - inline Bool_t IsSwapped() const { return tuDecoding > 0xffffff; } - - inline UInt_t Value(const UInt_t *member) const - { - return IsSwapped() ? ((((UChar_t *) member)[0] << 24) | - (((UChar_t *) member)[1] << 16) | - (((UChar_t *) member)[2] << 8) | - (((UChar_t *) member)[3])) : *member; - } - - /** swapsave method to set value stolen from hadtu.h */ - inline void SetValue(UInt_t *member, UInt_t val) - { - *member = IsSwapped() ? - ((((UChar_t *) &val)[0] << 24) | - (((UChar_t *) &val)[1] << 16) | - (((UChar_t *) &val)[2] << 8) | - (((UChar_t *) &val)[3])) : val; - } - - - UInt_t GetDecoding() const { return Value(&tuDecoding); } - inline UInt_t GetSize() const { return Value(&tuSize); } - - inline UInt_t GetPaddedSize() const - { - UInt_t hedsize = GetSize(); - UInt_t rest = hedsize % 8; - return (rest==0) ? hedsize : (hedsize + 8 - rest); - } - - void SetSize(UInt_t bytes) { SetValue(&tuSize, bytes); } - }; - - // ====================================================================== - - /* - * Intermediate hierarchy class as common base for event and subevent - */ - struct HadTuId : public HadTu { -// protected: - UInt_t tuId; - - public: - - HadTuId() : tuId(0) {} - // Makes destructor virtual to get rid of warning when using as - // base struct - ~HadTuId() {} - - inline UInt_t GetId() const { return Value(&tuId); } - void SetId(UInt_t id) { SetValue(&tuId, id); } - - inline Bool_t GetDataError() const { return (GetId() & 0x80000000) != 0; } - - void SetDataError(Bool_t on) - { - if(on) - SetId(GetId() | 0x80000000); - else - SetId(GetId() & ~0x80000000); - } - }; - - // ================================================================================= - - //Description of the Event Structure - // - //An event consists of an event header and of varying number of subevents, each with a subevent header. The size of the event header is fixed to 0x20 bytes - // - //Event header - //evtHeader - //evtSize evtDecoding evtId evtSeqNr evtDate evtTime runNr expId - // - // * evtSize - total size of the event including the event header, it is measured in bytes. - // * evtDecoding - event decoding type: Tells the analysis the binary format of the event data, so that it can be handed to a corresponding routine for unpacking into a software usable data structure. For easier decoding of this word, the meaning of some bits is already predefined: - // evtDecoding - // msB --- --- lsB - // 0 alignment decoding type nonzero - // o The first (most significant) byte is always zero. - // o The second byte contains the alignment of the subevents in the event. 0 = byte, 1 = 16 bit word, 2 = 32 bit word... - // o The remaining two bytes form the actual decoding type, e.g. fixed length, zero suppressed etc. - // o The last byte must not be zero, so the whole evtDecoding can be used to check for correct or swapped byte order. - // - //It is stated again, that the whole evtDecoding is one 32bit word. The above bit assignments are merely a rule how to select this 32bit numbers. - // - // * evtId - event identifier: Tells the analysis the semantics of the event data, e.g. if this is a run start event, data event, simulated event, slow control data, end file event, etc.. - // evtId - // 31 30 - 16 15 - 12 11 - 8 5 - 7 4 3- 0 - // error bit reserved version reserved MU decision DS flag ID - // o error bit - set if one of the subsystems has set the error bit - // o version - 0 meaning of event ID before SEP03; 1 event ID after SEP03 - // o MU decision - 0 = negative LVL2 decision; >0 positive LVL2 decision - // MU trigger algo result - // 1 negative decision - // 2 positive decision - // 3 positive decision due to too many leptons or dileptons - // 4 reserved - // 5 reserved - // o DS flag - LVL1 downscaling flag; 1 = this event is written to the tape independent on the LVL2 trigger decision - // o ID - defines the trigger code - // ID before SEP03 description - // 0 simulation - // 1 real - // 2,3,4,5,6,7,8,9 calibration - // 13 beginrun - // 14 endrun - // - // ID after SEP03 description - // 0 simulation - // 1,2,3,4,5 real - // 7,9 calibration - // 1 real1 - // 2 real2 - // 3 real3 - // 4 real4 - // 5 real5 - // 6 special1 - // 7 offspill - // 8 special3 - // 9 MDCcalibration - // 10 special5 - // 13 beginrun - // 14 endrun - // * evtSeqNr - event number: This is the sequence number of the event in the file. The pair evtFileNr/evtSeqNr - // - //is unique throughout all events ever acquired by the system. - // - // * evtDate - date of event assembly (filled by the event builder, rough precision): - // evtDate ISO-C date format - // msB --- --- lsB - // 0 year month day - // - // 1. The first (most significant) byte is zero - // 2. The second byte contains the years since 1900 - // 3. The third the months since January [0-11] - // 4. The last the day of the month [1-31] - // - // * evtTime - time of assembly (filled by the event builder, rough precision): - // evtTime ISO-C time format - // msB --- --- lsB - // 0 hour minute second - // - // 1. The first (most significant) byte is zero - // 2. The second byte contains the hours since midnight [0-23] - // 3. The third the minutes after the hour [0-59] - // 4. The last the seconds after the minute [0-60] - // - // * runNr - file number: A unique number assigned to the file. The runNr is used as key for the RTDB. - // * evtPad - padding: Makes the event header a multiple of 64 bits long. - - - struct RawEvent : public HadTuId { - -// protected: - UInt_t evtSeqNr; - UInt_t evtDate; - UInt_t evtTime; - UInt_t evtRunNr; - UInt_t evtPad; - - /** Method to set initial header value like decoding and date/time */ - void InitHeader(UInt_t evid); - - - public: - - RawEvent() : - evtSeqNr(0), - evtDate(0), - evtTime(0), - evtRunNr(0), - evtPad(0) - {} - ~RawEvent() {} - - UInt_t GetSeqNr() const { return Value(&evtSeqNr); } - void SetSeqNr(UInt_t n) { SetValue(&evtSeqNr, n); } - - Int_t GetRunNr() const { return Value(&evtRunNr); } - void SetRunNr(UInt_t n) { SetValue(&evtRunNr, n); } - - Int_t GetDate() const { return Value(&evtDate); } - void SetDate(UInt_t d) { SetValue(&evtDate, d); } - - Int_t GetTime() const { return Value(&evtTime); } - void SetTime(UInt_t t) { SetValue(&evtTime, t); } - - UChar_t GetTrigType () const { return (GetId() & 0xf); } - - void Init(UInt_t evnt, UInt_t run=0, UInt_t id=EvtId_DABC) - { - InitHeader(id); - SetSeqNr(evnt); - SetRunNr(run); - evtPad = 0; - } - - void Dump(); - - static UInt_t CreateRunId(); - }; - -/* -//Subevent -// -//Every event contains zero to unspecified many subevents. As an empty event is allowed, data outside of any subevent are not allowed. A subevents consists out of a fixed size subevent header and a varying number of data words. -// -// * The subevent header -// subEvtHeader -// subEvtSize subEvtDecoding subEvtId subEvtTrigNr -// o subEvtSize - size of the subevent: This includes the the subevent header, it is measured in bytes. -// o subEvtDecoding - subevent decoding type: Tells the analysis the binary format of the subevent data, so that it can be handed to a corresponding routine for unpacking into a software usable data structure. For easier decoding of this word, the meaning of some bits is already predefined: -// subEvtDecoding -// msB --- --- lsB -// 0 data type decoding type nonzero -// + The first (most significant) byte is always zero -// + The second byte contains the word length of the subevent data. 0 = byte, 1 = 16 bit word, 2 = 32 bit word... -// + The remaining two bytes form the actual decoding type, e.g. fixed length, zero suppressed etc. -// + The last byte must not be zero, so the whole subEvtDecoding can be used to check for correct or swapped byte order. It is stated again, that the whole subEvtDecoding is one 32bit word. The above bit assignments are merely a rule how to select this 32bit numbers. -// o subEvtId - subevent identifier: Tells the analysis the semantics of the subevent data, e.g. every subevent builder may get its own subEvtId. So the data structure can be analyzed by the corresponding routine after unpacking. -// 1-99 DAQ -// 100-199 RICH -// 200-299 MDC -// 300-399 SHOWER -// 400-499 TOF -// 500-599 TRIG -// 600-699 SLOW -// 700-799 TRB_RPC common TRB, but contents is RPC -// 800-899 TRB_HOD pion-hodoscope -// 900-999 TRB_FW forward wall -// 1000-1099 TRB_START start detector -// 1100-1199 TRB_TOF TOF detector -// 1200-1299 TRB RICH RICH detector -// -//Additionally, all subEvtIds may have the MSB set. This indicates a sub event of the corresponding id that contains broken data (e.g. parity check failed, sub event was too long etc.). -// -// * -// o subEvtTrigNr - subevent Trigger Number: This is the event tag that is produced by the trigger system and is used for checking the correct assembly of several sub entities. In general, this number is not counting sequentially. The lowest significant byte represents the trigger tag generated by the CTU and has to be same for all detector subsystems in one event. The rest is filled by the EB. -// * The data words: The format of the data words (word length, compression algorithm, sub-sub-event format) is defined by the subEvtDecoding and apart from this it is completely free. The meaning of the data words (detector, geographical position, error information) is defined by the subEvtId and apart from this it is completely unknown to the data acquisition system. -*/ - - struct RawSubevent : public HadTuId { - -// protected: - - UInt_t subEvtTrigNr; - - public: - - RawSubevent() : subEvtTrigNr(0) {} - ~RawSubevent() {} - - UInt_t Alignment() const { return 1 << ( GetDecoding() >> 16 & 0xff); } - - UInt_t GetTrigNr() const { return Value(&subEvtTrigNr); } - void SetTrigNr(UInt_t trigger) { SetValue(&subEvtTrigNr, trigger); } - - UChar_t GetTrigType () const { return (GetDecoding() & 0xf0) >> 4; } - - void Init(UInt_t trigger = 0) - { - SetTrigNr(trigger); - } - - - /** Return pointer on data by index - user should care itself about swapping */ - UInt_t* GetDataPtr(UInt_t indx) const - { - return (UInt_t*) (this) + sizeof(RawSubevent)/sizeof(UInt_t) + indx; - } - - - /* returns number of payload data words, not maximum index!*/ - UInt_t GetNrOfDataWords() const - { - UInt_t datasize = GetSize() - sizeof(hadaq::RawSubevent); - switch (Alignment()) { - case 4: return datasize / sizeof(UInt_t); - case 2: return datasize / sizeof(UShort_t); - default: return datasize / sizeof(UChar_t); - } - return datasize; - } - - /** swap-save access to any data. stolen from hadtu.h */ - UInt_t Data(UInt_t idx) const - { - const void* my = (char*) (this) + sizeof(RawSubevent); - - switch (Alignment()) { - case 4: - return Value((UInt_t *) my + idx); - - case 2: { - UShort_t tmp = ((UShort_t *) my)[idx]; - - if (IsSwapped()) tmp = ((tmp >> 8) & 0xff) | ((tmp << 8) & 0xff00); - - return tmp; - } - } - - return ((UChar_t*) my)[idx]; - } - - UInt_t GetErrBits() - { - return Data(GetNrOfDataWords()-1); - } - - void CopyDataTo(void* buf, UInt_t indx, UInt_t datalen) - { - if (buf==0) return; - while (datalen-- > 0) { - *((UInt_t*) buf) = Data(indx++); - buf = ((UInt_t*) buf) + 1; - } - } - - /** Return pointer where raw data should starts */ - void* RawData() const { return (char*) (this) + sizeof(hadaq::RawSubevent); } - - - void Dump(Bool_t print_raw_data = false); - }; - - -} - -#pragma pack(pop) - -#endif diff --git a/beamtime/tof/hadaq/HadaqTdcIterator.h b/beamtime/tof/hadaq/HadaqTdcIterator.h deleted file mode 100644 index 0bc64bfa66c7d5affa6720eaf54d6c85e0de1f8c..0000000000000000000000000000000000000000 --- a/beamtime/tof/hadaq/HadaqTdcIterator.h +++ /dev/null @@ -1,130 +0,0 @@ -// -------------------------------------------------------------------------------- -// ----- HadaqTdcIterator header file ----- -// ----- ----- -// ----- created by C. Simon on 2014-04-02 ----- -// ----- ----- -// ----- based on stream by S. Linev ----- -// ----- https://subversion.gsi.de/go4/app/stream/include/hadaq/TdcIterator.h ----- -// ----- revision 1111, 2014-01-15 ----- -// -------------------------------------------------------------------------------- - -#ifndef HADAQ_TDCITERATOR_H -#define HADAQ_TDCITERATOR_H - -#include "HadaqDefines.h" -#include "HadaqTdcMessage.h" -#include "HadaqTimeStamp.h" - -namespace hadaq { - - class TdcIterator { - protected: - - enum { DummyEpoch = 0xffffffff }; - - UInt_t* fBuf; //! pointer on raw data - UInt_t fBuflen; //! length of raw data - Bool_t fSwapped; //! true if raw data are swapped - - hadaq::TdcMessage fMsg; //! current message - UInt_t fCurEpoch; //! current epoch - - hadaq::LocalStampConverter fConv; //! use to covert time stamps in seconds - - public: - - TdcIterator() : - fBuf(0), - fBuflen(0), - fSwapped(kFALSE), - fMsg(), - fCurEpoch(DummyEpoch), - fConv() - { - // 1st argument: wrap bits = epoch counter size + coarse time counter size - // 2nd argument: conversion factor from coarse time unit to seconds - fConv.SetTimeSystem(trbtdc::size_EpochCounter + trbtdc::size_CoarseTimeCounter, hadaq::TdcMessage::CoarseUnit()); - } - - void assign(UInt_t* buf, UInt_t len, Bool_t swapped = kTRUE) - { - fBuf = buf; - fBuflen = len; - fSwapped = swapped; - fMsg.assign(0); - - if (fBuflen == 0) fBuf = 0; - fCurEpoch = DummyEpoch; - } - - void assign(hadaq::RawSubevent* subev, UInt_t indx, UInt_t datalen) - { - if (subev!=0) - assign(subev->GetDataPtr(indx), datalen, subev->IsSwapped()); - } - - /** One should call method to set current reference epoch */ - void setRefEpoch(UInt_t epoch) - { - fConv.MoveRef(((ULong64_t) epoch) << trbtdc::size_CoarseTimeCounter); - } - - Bool_t next() - { - if (fBuf==0) return false; - - if (fSwapped) - fMsg.assign((((UChar_t *) fBuf)[0] << 24) | (((UChar_t *) fBuf)[1] << 16) | (((UChar_t *) fBuf)[2] << 8) | (((UChar_t *) fBuf)[3])); - else - fMsg.assign(*fBuf); - - if (fMsg.isEpochMsg()) fCurEpoch = fMsg.getEpochValue(); - - fBuf++; - if (--fBuflen == 0) fBuf = 0; - - return true; - } - - /** Returns message stamp which combines epoch and coarse time counter */ - ULong64_t getMsgStamp() const - { return (isCurEpoch() ? ((ULong64_t) fCurEpoch) << trbtdc::size_CoarseTimeCounter : 0) | (fMsg.isTimeMsg() ? fMsg.getTimeTmCoarse() : 0); } - - /** Returns epoch + coarse time converted to seconds */ - inline Double_t getMsgTimeCoarse() const - { return fConv.ToSeconds(getMsgStamp()); } - - /** Returns fine time converted to seconds */ - inline Double_t getMsgTimeFine() const - { return fMsg.isTimeMsg() ? hadaq::TdcMessage::SimpleFineCalibr(fMsg.getTimeTmFine()) : 0.; } - - hadaq::TdcMessage& msg() { return fMsg; } - - /** Returns true, if current epoch was assigned */ - Bool_t isCurEpoch() const { return fCurEpoch != DummyEpoch; } - - /** Clear current epoch value */ - void clearCurEpoch() { fCurEpoch = DummyEpoch; } - - /** Set value of current epoch */ - void setCurEpoch(UInt_t val) { fCurEpoch = val; } - - /** Return value of current epoch */ - UInt_t getCurEpoch() const { return fCurEpoch; } - - void printmsg() - { - Double_t tm = -1.; - if (msg().isTimeMsg() || msg().isEpochMsg()) - tm = getMsgTimeCoarse() - getMsgTimeFine(); - msg().print(tm); - } - - private: - // no default Copy constructor and = OP as class not meant to be copied - TdcIterator(const TdcIterator&); - TdcIterator& operator=(const TdcIterator&); - }; -} - -#endif diff --git a/beamtime/tof/hadaq/HadaqTdcMessage.cxx b/beamtime/tof/hadaq/HadaqTdcMessage.cxx deleted file mode 100644 index 2988a5391003274e0c4e12aadb2e820a54e703cd..0000000000000000000000000000000000000000 --- a/beamtime/tof/hadaq/HadaqTdcMessage.cxx +++ /dev/null @@ -1,52 +0,0 @@ -// ----------------------------------------------------------------------------------- -// ----- HadaqTdcMessage source file ----- -// ----- ----- -// ----- created by C. Simon on 2014-04-02 ----- -// ----- ----- -// ----- based on stream by S. Linev ----- -// ----- https://subversion.gsi.de/go4/app/stream/framework/hadaq/TdcMessage.cxx ----- -// ----- revision 1046, 2013-11-20 ----- -// ----------------------------------------------------------------------------------- - -#include "HadaqTdcMessage.h" - -#include "TString.h" - -#include "FairLogger.h" - -UInt_t hadaq::TdcMessage::gFineMinValue = trbtdc::kuSimpleFineTimeMinValue; -UInt_t hadaq::TdcMessage::gFineMaxValue = trbtdc::kuSimpleFineTimeMaxValue; - -void hadaq::TdcMessage::print(Double_t tm) -{ - switch (getKind()) { - case trbtdc::message_Reserved: - LOG(debug)<<Form(" tdc reserv 0x%08x", (UInt_t) fData); - break; - - case trbtdc::message_Header: - LOG(debug)<<Form(" tdc head 0x%08x", (UInt_t) fData); - break; - case trbtdc::message_Debug: - LOG(debug)<<Form(" tdc debug 0x%08x", (UInt_t) fData); - break; - case trbtdc::message_Epoch: - LOG(debug)<<Form(" tdc epoch 0x%08x", (UInt_t) fData); - if (tm>=0) LOG(debug)<<Form(" tm:%9.2f", tm*1e9); - LOG(debug)<<Form(" epoch 0x%x", (UInt_t) getEpochValue()); - break; - case trbtdc::message_Time: - case trbtdc::message_Time1: - case trbtdc::message_Time2: - case trbtdc::message_Time3: - LOG(debug)<<Form(" tdc hit 0x%08x", (UInt_t) fData); - if (tm>=0) LOG(debug)<<Form(" tm:%9.2f", tm*1e9); - LOG(debug)<<Form(" ch %3u isrising:%u tc 0x%03x tf 0x%03x", - (UInt_t) getTimeChannel(), (UInt_t)getTimeEdge(), - (UInt_t)getTimeTmCoarse(), (UInt_t)getTimeTmFine()); - break; - default: - LOG(debug)<<Form(" tdc unkn 0x%08x kind %u", (UInt_t) fData, (UInt_t) getKind()); - break; - } -} diff --git a/beamtime/tof/hadaq/HadaqTdcMessage.h b/beamtime/tof/hadaq/HadaqTdcMessage.h deleted file mode 100644 index 61484885c8be08ebbf1de56939a163992c29e5d1..0000000000000000000000000000000000000000 --- a/beamtime/tof/hadaq/HadaqTdcMessage.h +++ /dev/null @@ -1,129 +0,0 @@ -// ------------------------------------------------------------------------------- -// ----- HadaqTdcMessage header file ----- -// ----- ----- -// ----- created by C. Simon on 2014-04-02 ----- -// ----- ----- -// ----- based on stream by S. Linev ----- -// ----- https://subversion.gsi.de/go4/app/stream/include/hadaq/TdcMessage.h ----- -// ----- revision 1060, 2013-11-28 ----- -// ------------------------------------------------------------------------------- - -#ifndef HADAQ_TDCMESSAGE_H -#define HADAQ_TDCMESSAGE_H - -#include "Rtypes.h" - -#include "TofTrbTdcDef.h" - -namespace hadaq { - - /** TdcMessage is wrapper for data, produced by FPGA-TDC - * struct is used to avoid any potential overhead */ - - struct TdcMessage { - protected: - UInt_t fData; - - static UInt_t gFineMinValue; - static UInt_t gFineMaxValue; - - public: - - TdcMessage() : fData(0) {} - - TdcMessage(UInt_t d) : fData(d) {} - - void assign(UInt_t d) { fData=d; } - - // methods for message type determination - - /** Returns kind of the message (upper 3 bits of the TDC header word) */ - UInt_t getKind() const { return fData & trbtdc::message_Mask; } - - /** If used for the time message (MSb set), four different values can be returned */ - Bool_t isTimeMsg() const { return fData & trbtdc::message_Time; } - - Bool_t isEpochMsg() const { return getKind() == trbtdc::message_Epoch; } - Bool_t isDebugMsg() const { return getKind() == trbtdc::message_Debug; } - Bool_t isHeaderMsg() const { return getKind() == trbtdc::message_Header; } - Bool_t isReservedMsg() const { return getKind() == trbtdc::message_Reserved; } - - // methods for HEADER word - - /** Return error bits of header message */ - UInt_t getHeaderErr() const { return (fData >> trbtdc::header_ErrorBitShift) & trbtdc::header_ErrorBitMask; } - - /** Return trigger code bits of header message */ - UInt_t getHeaderTrig() const { return (fData >> trbtdc::header_TriggerCodeBitShift) & trbtdc::header_TriggerCodeBitMask; } - - /** Return reserved bits of header message */ - UInt_t getHeaderRes() const { return (fData >> trbtdc::header_ReservedBitShift) & trbtdc::header_ReservedBitMask; } - - // methods for TIME word - - /** Returns time word coarse time counter */ - UInt_t getTimeTmCoarse() const { return (fData >> trbtdc::time_CoarseTimeBitShift) & trbtdc::time_CoarseTimeBitMask; } - - /** Returns time word edge */ - UInt_t getTimeEdge() const { return (fData >> trbtdc::time_EdgeBitShift) & trbtdc::time_EdgeBitMask; } - - /** Returns time word fine time counter */ - UInt_t getTimeTmFine() const { return (fData >> trbtdc::time_FineTimeBitShift) & trbtdc::time_FineTimeBitMask; } - - /** Returns time word channel ID */ - UInt_t getTimeChannel() const { return (fData >> trbtdc::time_ChannelBitShift) & trbtdc::time_ChannelBitMask; } - - /** Returns time word reserved value */ - UInt_t getTimeReserved() const { return (fData >> trbtdc::time_ReservedBitShift) & trbtdc::time_ReservedBitMask; } - - /** Returns time stamp, which is simple combination coarse and fine counter */ - UInt_t getTimeTmStamp() const { return (getTimeTmCoarse() << trbtdc::size_FineTimeCounter) | getTimeTmFine(); } - - Bool_t isHitRisingEdge() const { return getTimeEdge() == trbtdc::edge_Rising; } - Bool_t isHitFallingEdge() const { return getTimeEdge() == trbtdc::edge_Falling; } - - // methods for EPOCH word - - /** Return Epoch for epoch marker */ - UInt_t getEpochValue() const { return (fData >> trbtdc::epoch_EpochBitShift) & trbtdc::epoch_EpochBitMask; } - /** Get reserved bit for epoch */ - UInt_t getEpochRes() const { return (fData >> trbtdc::epoch_ReservedBitShift) & trbtdc::epoch_ReservedBitMask; } - - void print(Double_t tm = -1.); - - static Double_t CoarseUnit() { return trbtdc::kdClockCycleSizeSec; } - - static Double_t SimpleFineCalibr(UInt_t fine) - { - if (fine < gFineMinValue) return 0.; - if (fine > gFineMaxValue) return 1.; - return (1.*(fine - (gFineMinValue - 1) - 0.5)/(gFineMaxValue - gFineMinValue + 1)); - } - - /** Method set static limits, which are used for simple interpolation of time for fine counter */ - static void SetFineLimits(UInt_t min, UInt_t max) - { - gFineMinValue = min; - gFineMaxValue = max; - } - - static void CoarseOverflow(Long64_t& liEdgeCoarseTime, const Long64_t& liRefCoarseTime) - { - // hit arrived prior to reference hit but the full coarse counter overflowed in between - // time difference will yield a huge positive number - if(liEdgeCoarseTime - liRefCoarseTime > trbtdc::kliFullCoarseSize/2) - { - liEdgeCoarseTime -= trbtdc::kliFullCoarseSize; - } - // hit arrived posterior to reference hit but the full coarse counter overflowed in between - // time difference will yield a huge negative number - else if(liEdgeCoarseTime - liRefCoarseTime < -trbtdc::kliFullCoarseSize/2) - { - liEdgeCoarseTime += trbtdc::kliFullCoarseSize; - } - } - - }; -} - -#endif diff --git a/beamtime/tof/hadaq/HadaqTimeStamp.h b/beamtime/tof/hadaq/HadaqTimeStamp.h deleted file mode 100644 index ac4bdda48ef59107de248354b1b25249cf507037..0000000000000000000000000000000000000000 --- a/beamtime/tof/hadaq/HadaqTimeStamp.h +++ /dev/null @@ -1,137 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- HadaqTimeStamp header file ----- -// ----- ----- -// ----- created by C. Simon on 2014-04-02 ----- -// ----- ----- -// ----- based on stream by S. Linev ----- -// ----- https://subversion.gsi.de/go4/app/stream/include/base/TimeStamp.h ----- -// ----- revision 924, 2012-12-21 ----- -// ----------------------------------------------------------------------------- - -#ifndef HADAQ_TIMESTAMP_H -#define HADAQ_TIMESTAMP_H - -#include "Rtypes.h" - -namespace hadaq { - - /** Current time model - * There are three different time representations: - * local stamp - 64-bit unsigned integer (LocalStamp_t), can be analyzed only locally - * local time - double in seconds (GlobalTime_t), adjust all local differences, should be without wrap - * global time - double in seconds (GlobalTime_t), universal time used for global actions like RoI declaration - * In case when stream does not required time synchronization local time automatically used as global - */ - - /** type for generic representation of local stamp - * if necessary, can be made more complex, - * for a moment arbitrary 64-bit value */ - typedef ULong64_t LocalStamp_t; - - - /** type for global time stamp, valid for all subsystems - * should be reasonable values in nanoseconds - * for a moment double precision should be enough */ - typedef Double_t GlobalTime_t; - - - /** LocalStampConverter class should perform - * conversion of time stamps to time in seconds. - * Main problem to solve - handle correctly time stamp wraps. - */ - - class LocalStampConverter { - protected: - Long64_t fT0; //! time stamp, used as t0 for time production - ULong64_t fWrapSize; //! value of time stamp which wraps - MUST be power of 2 - ULong64_t fHalfWrapSize; //! fWrapSize/2 - used very often in calculations - ULong64_t fValueMask; //! mask to extract bits related to stamp - - ULong64_t fCurrentWrap; //! summed wraps since begin - LocalStamp_t fRef; //! reference time, used to detect wraps of timestamp - Long64_t fConvRef; //! value used for time conversion - - Double_t fCoef; // time coefficient to convert to seconds - - public: - - LocalStampConverter() : - fT0(0), - fWrapSize(2), - fHalfWrapSize(1), - fValueMask(1), - fCurrentWrap(0), - fRef(0), - fConvRef(0), - fCoef(1.) - { - } - - ~LocalStampConverter() {} - - void SetT0(Long64_t t0) { fT0 = t0; } - - /** Set major timing parameters - wrap value and coefficient */ - void SetTimeSystem(UInt_t wrapbits, Double_t coef) - { - fWrapSize = ((ULong64_t) 1) << wrapbits; - fHalfWrapSize = fWrapSize/2; - fValueMask = fWrapSize - 1; - fCoef = coef; - - // TODO: should it be done here??? - MoveRef(0); - } - - /** Method calculates distance between two stamps - * In simplest case just should return t2-t1 */ - Long64_t distance(LocalStamp_t t1, LocalStamp_t t2) const - { - ULong64_t diff = (t2 - t1) & fValueMask; - return diff < fWrapSize/2 ? (Long64_t) diff : (Long64_t)diff - fWrapSize; - } - - /** Method returns abs(t1-t2) */ - ULong64_t abs_distance(LocalStamp_t t1, LocalStamp_t t2) - { - ULong64_t diff = (t2 - t1) & fValueMask; - return diff < fWrapSize/2 ? diff : fWrapSize - diff; - } - - /** Method convert time stamp to seconds, - * taking into account probable wrap relative to fRef value */ - Double_t ToSeconds(LocalStamp_t stamp) const - { - // simplest way just return stamp*fCoef, - // but one should account all possible wraps - - // first estimate distance to the reference - // stamp could be left or right - Long64_t dist = distance(fRef, stamp); - - // one we found distance, we could calculate full stamp as - // return (fCurrentWrap + fRef + dist - fT0) * fCoef; - return (fConvRef + dist) * fCoef; - } - - /** Move reference to the new position */ - void MoveRef(LocalStamp_t newref) - { - // when new reference smaller than previous - // one should check if distance small that we could believe it is normal - if (newref < fRef) { - Long64_t shift = distance(fRef, newref); - if ((shift>0) && (shift < (Long64_t) fWrapSize/2)) - fCurrentWrap+=fWrapSize; - } - - fRef = newref; - - // precalculate value, which will be used for conversion - fConvRef = Long64_t(fCurrentWrap + fRef) - fT0; - } - }; - -} - -#endif diff --git a/beamtime/tof/hadaq/HadaqTrbIterator.cxx b/beamtime/tof/hadaq/HadaqTrbIterator.cxx deleted file mode 100644 index c2793c78b487f0c241aeb1a827739629609b3703..0000000000000000000000000000000000000000 --- a/beamtime/tof/hadaq/HadaqTrbIterator.cxx +++ /dev/null @@ -1,124 +0,0 @@ -// ------------------------------------------------------------------------------------- -// ----- HadaqTrbIterator source file ----- -// ----- ----- -// ----- created by C. Simon on 2014-03-07 ----- -// ----- ----- -// ----- based on stream by S. Linev ----- -// ----- https://subversion.gsi.de/go4/app/stream/framework/hadaq/TrbIterator.cxx ----- -// ----- revision 1046, 2013-11-20 ----- -// ------------------------------------------------------------------------------------- - -#include "HadaqTrbIterator.h" - -#include "TString.h" - -#include "FairLogger.h" - -hadaq::TrbIterator::TrbIterator(void* data, UInt_t datalen) : - fData(data), - fDatalen(datalen), - fEvCursor(0), - fEvLen(0), - fSubCursor(0), - fSubLen(0), - fSubsubCursor(0), - fSubsubLen(0) -{ -} - -hadaq::RawEvent* hadaq::TrbIterator::nextEvent() -{ - if (fEvCursor == 0) { - - fEvCursor = fData; - fEvLen = fDatalen; - - } else { - hadaq::RawEvent* prev = (hadaq::RawEvent*) fEvCursor; - - UInt_t fulllen = prev->GetPaddedSize(); - - LOG(debug3)<<Form("nextEvent fEvLen = %u evlen = %u", fEvLen, fulllen); - - if (fulllen >= fEvLen) { - if (fulllen > fEvLen) - { - LOG(error)<<Form("hadaq::RawEvent length mismatch %u %u", fulllen, fEvLen); - } - fEvCursor = 0; - fEvLen = 0; - } else { - fEvCursor = ((UChar_t*) fEvCursor) + fulllen; - fEvLen -= fulllen; - } - } - - if ((fEvCursor!=0) && (fEvLen!=0) && (fEvLen < sizeof(hadaq::RawEvent))) { - LOG(error)<<Form("Strange hadaq::RawEvent length %u minumum %u", (UInt_t) fEvLen, (UInt_t) sizeof(hadaq::RawEvent)); - fEvCursor = 0; - fEvLen = 0; - } - - fSubCursor = 0; - fSubLen = 0; - - return (hadaq::RawEvent*) fEvCursor; -} - -hadaq::RawSubevent* hadaq::TrbIterator::nextSubevent() -{ - RawEvent* ev = currEvent(); - - if (ev==0) return 0; - - if (fSubCursor == 0) { - fSubCursor = ((UChar_t*) ev) + sizeof(hadaq::RawEvent); - - fSubLen = ev->GetPaddedSize(); - - if (fSubLen >= sizeof(hadaq::RawEvent)) { - fSubLen -= sizeof(hadaq::RawEvent); - } else { - LOG(error)<<Form("Wrong hadaq::RawEvent length %u header size %u", (UInt_t) ev->GetSize(), (UInt_t) sizeof(hadaq::RawEvent)); - fSubLen = 0; - } - } else { - - hadaq::RawSubevent* sub = (hadaq::RawSubevent*) fSubCursor; - - UInt_t fulllen = sub->GetPaddedSize(); - - LOG(debug3)<<Form("Shift to next subevent size %u fulllen %u", fulllen, fSubLen); - - if (fulllen >= fSubLen) { - if (fulllen > fSubLen) - { - LOG(error)<<Form("Mismatch in subevent length %u %u", fulllen, fSubLen); - } - fSubLen = 0; - } else { - fSubCursor = ((UChar_t*) fSubCursor) + fulllen; - fSubLen -= fulllen; - - if (fSubLen < sizeof(hadaq::RawSubevent)) { - fSubLen = 0; - } else { - - UInt_t align = ((UChar_t*) fSubCursor - (UChar_t*) fEvCursor) % 8; - - if (align != 0) { - LOG(error)<<Form("Align problem %u != 0 of subevent relative to buffer begin", align); - } - } - } - } - - if ((fSubLen==0) || ((fSubLen!=0) && (fSubLen < sizeof(hadaq::RawSubevent)))) { -// LOG(error)<<Form("Strange hadaq::Subevent length %u", fSubLen); - fSubCursor = 0; - fSubLen = 0; - } - - return (hadaq::RawSubevent*) fSubCursor; -} - diff --git a/beamtime/tof/hadaq/HadaqTrbIterator.h b/beamtime/tof/hadaq/HadaqTrbIterator.h deleted file mode 100644 index 6af4598a88725524f99243131d1052219fb4517d..0000000000000000000000000000000000000000 --- a/beamtime/tof/hadaq/HadaqTrbIterator.h +++ /dev/null @@ -1,58 +0,0 @@ -// --------------------------------------------------------------------------------- -// ----- HadaqTrbIterator header file ----- -// ----- ----- -// ----- created by C. Simon on 2014-03-07 ----- -// ----- ----- -// ----- based on stream by S. Linev ----- -// ----- https://subversion.gsi.de/go4/app/stream/include/hadaq/TrbIterator.h ----- -// ----- revision 909, 2012-12-17 ----- -// --------------------------------------------------------------------------------- - -#ifndef HADAQ_TRBITERATOR_H -#define HADAQ_TRBITERATOR_H - -#include "HadaqDefines.h" - -#include "Rtypes.h" - -namespace hadaq { - - class TrbIterator { - protected: - void* fData; - UInt_t fDatalen; - - void* fEvCursor; - UInt_t fEvLen; - - void* fSubCursor; - UInt_t fSubLen; - - void* fSubsubCursor; - UInt_t fSubsubLen; - - public: - - TrbIterator(void* data, UInt_t datalen); - ~TrbIterator() {} - - RawEvent* nextEvent(); - - RawEvent* currEvent() const { return (RawEvent*) fEvCursor; } - - RawSubevent* nextSubevent(); - - RawSubevent* currSubevent() const { return (RawSubevent*) fSubCursor; } - - private: - // no default Copy constructor and = OP as class not meant to be copied - TrbIterator(const TrbIterator&); - TrbIterator& operator=(const TrbIterator&); - - }; - - -} - - -#endif diff --git a/beamtime/tof/mapping/TMbsMappingTof.cxx b/beamtime/tof/mapping/TMbsMappingTof.cxx deleted file mode 100644 index 10f5ba45782a7d807a6968ccb75e8ccefe07725b..0000000000000000000000000000000000000000 --- a/beamtime/tof/mapping/TMbsMappingTof.cxx +++ /dev/null @@ -1,697 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TMbsMappingTof ----- -// ----- Created 09/06/2013 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ -#include "TMbsMappingTof.h" - -// General Unpack headers -#include "TMbsUnpackTofPar.h" - -// ToF specific headers -#include "TMbsMappingTofPar.h" -#include "TMbsCalibTofPar.h" -#include "TofTdcDef.h" -#include "TofCaenDef.h" -#include "TofVftxDef.h" -#include "TofTrbTdcDef.h" -#include "TofGet4Def.h" -#include "TTofTdcBoard.h" -#include "TTofTdcData.h" -#include "TTofCalibData.h" -#include "CbmTofAddress.h" -#include "CbmTofDigi.h" -#include "TTofTriglogBoard.h" - -// FAIR headers -#include "FairLogger.h" -#include "FairRunAna.h" -#include "FairRuntimeDb.h" -#include "FairRootManager.h" - -// ROOT headers -#include "TClonesArray.h" -#include "TH2.h" -#include "TH1.h" -#include "TROOT.h" -#include "TTimeStamp.h" -#include <TFile.h> - -// C++ headers -#include <algorithm> - -TMbsMappingTof::TMbsMappingTof() : - FairTask("MbsCalibTof"), - fMbsUnpackPar(NULL), - fMbsCalibPar(NULL), - fMbsMappingPar(NULL), - fviNbHitInThisEvent(), - fhDetChEvtMul(), - fhDetChTotMul(), - fhDetChHitsPerEvt(), - fhDetChCoincSides(), - fhDetChCoincLeft(), - fhDetChCoincRight(), - fCalibDataCollection(NULL), - fTriglogBoardCollection(NULL), - fbSaveMappedDigis(kFALSE), - fbFillHistos(kFALSE), - fbDuplicatePadDigis(kTRUE), - fCbmTofDigiCollection(NULL) -{ -} - -TMbsMappingTof::TMbsMappingTof(const char* name, Int_t /*mode*/, Int_t verbose) : - FairTask(name, verbose), - fMbsUnpackPar(0), - fMbsCalibPar(NULL), - fMbsMappingPar(NULL), - fviNbHitInThisEvent(), - fhDetChEvtMul(), - fhDetChTotMul(), - fhDetChHitsPerEvt(), - fhDetChCoincSides(), - fhDetChCoincLeft(), - fhDetChCoincRight(), - fCalibDataCollection(NULL), - fTriglogBoardCollection(NULL), - fbSaveMappedDigis(kFALSE), - fbFillHistos(kFALSE), - fbDuplicatePadDigis(kTRUE), - fCbmTofDigiCollection(NULL) -{ -} - -TMbsMappingTof::~TMbsMappingTof() -{ - DeleteHistograms(); - LOG(info)<<"**** TMbsMappingTof: Delete instance "; -} - -// -------------------------------------------------- -// Fairtask specific functions -void TMbsMappingTof::SetParContainers() -{ - InitParameters(); -} -InitStatus TMbsMappingTof::ReInit() -{ - LOG(info)<<"**** TMbsMappingTof: Reinitialize the mapping parameters for tof "; - if( kFALSE == InitParameters() ) - return kFATAL; - fMbsMappingPar->printParams(); - - return kSUCCESS; -} - -InitStatus TMbsMappingTof::Init() -{ - if( kFALSE == InitParameters() ) - return kFATAL; - fMbsMappingPar->printParams(); - if( kFALSE == CreateHistogramms() ) - return kFATAL; - - if( kFALSE == RegisterInput() ) - return kFATAL; - - // Create the proper output objects for each detector - if( kFALSE == RegisterOutput() ) - return kFATAL; - - return kSUCCESS; -} -void TMbsMappingTof::Exec(Option_t* /*option*/) -{ - ClearOutput(); - - // Event rejection - // E.g.: pulser event used to Empty the VFTX buffers - if( 1 == fMbsUnpackPar->OnlyOneTriglog() && - -1 < fMbsUnpackPar->GetTriggerToReject() ) - { -// if( NULL == fTriglogBoardCollection ) -// return kFALSE; - - TTofTriglogBoard * xTriglogBoard = (TTofTriglogBoard*) fTriglogBoardCollection->At(0); // Always only 1 TRIGLOG board! - -// if( NULL == xTriglogBoard ) -// return kFALSE; -// if( 1 == ( 0x1 & ( (xTriglogBoard->GetTriggPatt()) >> (fMbsUnpackPar->GetTriggerToReject()) ) ) ) - // Reject selected trigger only when alone (accept when both not rejected trigger and rejected trigger are present) - if( (xTriglogBoard->GetTriggPatt()) == ( 1ul << (fMbsUnpackPar->GetTriggerToReject()) ) ) - // Jump this event ! - return; - } // if trigger rejection enabled and trigger board enabled - - MapTdcDataToDet(); - - if( fbFillHistos ) - { - FillHistograms(); - } -} -void TMbsMappingTof::Finish() -{ - WriteHistogramms(); -} - -// ------------------------------------------------------------------ -Bool_t TMbsMappingTof::InitParameters() -{ - // Get Base Container - FairRun* ana = FairRun::Instance(); - FairRuntimeDb* rtdb=ana->GetRuntimeDb(); - - // Unpack parameter - fMbsUnpackPar = (TMbsUnpackTofPar*) (rtdb->getContainer("TMbsUnpackTofPar")); - if( 0 == fMbsUnpackPar ) - { - LOG(error)<<"TMbsMappingTof::InitParameters => Could not obtain the TMbsUnpackTofPar "; - return kFALSE; - } - - // Calibration parameter - fMbsCalibPar = (TMbsCalibTofPar*) (rtdb->getContainer("TMbsCalibTofPar")); - if( 0 == fMbsCalibPar ) - { - LOG(error)<<"TMbsMappingTof::InitParameters => Could not obtain the TMbsCalibTofPar "; - return kFALSE; - } - - // Calibration parameter - fMbsMappingPar = (TMbsMappingTofPar*) (rtdb->getContainer("TMbsMappingTofPar")); - if( 0 == fMbsMappingPar ) - { - LOG(error)<<"TMbsMappingTof::InitParameters => Could not obtain the TMbsMappingTofPar "; - return kFALSE; - } - - // PAL: Added to recover loading of parameters before initialization -// rtdb->initContainers( ana->GetRunId() ); - - return kTRUE; -} -// ------------------------------------------------------------------ -Bool_t TMbsMappingTof::CreateHistogramms() -{ - TDirectory * oldir = gDirectory; // <= To prevent histos from being sucked in by the param file of the TRootManager! - gROOT->cd(); // <= To prevent histos from being sucked in by the param file of the TRootManager ! - - if( 0 < fMbsMappingPar->GetNbMappedDet() ) - { - fhDetChEvtMul.resize( fMbsMappingPar->GetNbMappedDet() ); - fhDetChTotMul.resize( fMbsMappingPar->GetNbMappedDet() ); - fhDetChHitsPerEvt.resize( 2*fMbsMappingPar->GetNbMappedDet() ); - fhDetChCoincSides.resize( fMbsMappingPar->GetNbMappedDet() ); - fhDetChCoincLeft.resize( fMbsMappingPar->GetNbMappedDet() ); - fhDetChCoincRight.resize( fMbsMappingPar->GetNbMappedDet() ); - - fviNbHitInThisEvent.resize( fMbsMappingPar->GetNbMappedDet() ); - for( Int_t iDetIndx = 0; iDetIndx < fMbsMappingPar->GetNbMappedDet(); iDetIndx++ ) - { - Int_t iUniqueId = fMbsMappingPar->GetMappedDetUId( iDetIndx ); - Int_t iSmType = CbmTofAddress::GetSmType( iUniqueId ); - Int_t iSmId = CbmTofAddress::GetSmId( iUniqueId ); - Int_t iRpcId = CbmTofAddress::GetRpcId( iUniqueId ); - fhDetChEvtMul.at(iDetIndx) = new TH2I( - Form("tof_ty%01d_sm%03d_rpc%03d_ch_evt_mul", iSmType, iSmId, iRpcId ), - Form("Number of events with hits for each channel of Rpc #%03d in Sm %03d of type %d; Channel []; Side []; Events with hits[]", - iRpcId, iSmId, iSmType ), - fMbsMappingPar->GetSmTypeNbCh(iSmType), 0, fMbsMappingPar->GetSmTypeNbCh(iSmType), - 2, 0, 2 ); - fhDetChTotMul.at(iDetIndx) = new TH2I( - Form("tof_ty%01d_sm%03d_rpc%03d_ch_tot_mul", iSmType, iSmId, iRpcId ), - Form("Number of hits for each channel of Rpc #%03d in Sm %03d of type %d; Channel []; Side []; Hits []", - iRpcId, iSmId, iSmType ), - fMbsMappingPar->GetSmTypeNbCh(iSmType), 0, fMbsMappingPar->GetSmTypeNbCh(iSmType), - 2, 0, 2 ); - fhDetChHitsPerEvt.at(2*iDetIndx) = new TH2I( - Form("tof_ty%01d_sm%03d_rpc%03d_ch_left_hitsperevt", iSmType, iSmId, iRpcId ), - Form("Number of hits per event for the left side each channel of Rpc #%03d in Sm %03d of type %d; Channel []; Nb hits per event []; Events []", - iRpcId, iSmId, iSmType ), - fMbsMappingPar->GetSmTypeNbCh(iSmType), 0, fMbsMappingPar->GetSmTypeNbCh(iSmType), - 10, 0, 10 ); - fhDetChHitsPerEvt.at(2*iDetIndx + 1) = new TH2I( - Form("tof_ty%01d_sm%03d_rpc%03d_ch_right_hitsperevt", iSmType, iSmId, iRpcId ), - Form("Number of hits per event for the right side each channel of Rpc #%03d in Sm %03d of type %d; Channel []; Nb hits per event []; Events []", - iRpcId, iSmId, iSmType ), - fMbsMappingPar->GetSmTypeNbCh(iSmType), 0, fMbsMappingPar->GetSmTypeNbCh(iSmType), - 10, 0, 10 ); - - fhDetChCoincSides.at(iDetIndx) = new TH2I( - Form("tof_ty%01d_sm%03d_rpc%03d_coinc_sides", iSmType, iSmId, iRpcId ), - Form("Number of events with hits for both channels of Rpc #%03d in Sm %03d of type %d; Channel left []; Channel right []; Events with hits in both[]", - iRpcId, iSmId, iSmType ), - fMbsMappingPar->GetSmTypeNbCh(iSmType), 0, fMbsMappingPar->GetSmTypeNbCh(iSmType), - fMbsMappingPar->GetSmTypeNbCh(iSmType), 0, fMbsMappingPar->GetSmTypeNbCh(iSmType)); - fhDetChCoincLeft.at(iDetIndx) = new TH2I( - Form("tof_ty%01d_sm%03d_rpc%03d_coinc_left", iSmType, iSmId, iRpcId ), - Form("Number of events with hits for both channels of Rpc #%03d in Sm %03d of type %d; Channel left 1 []; Channel left 2 []; Events with hits in both[]", - iRpcId, iSmId, iSmType ), - fMbsMappingPar->GetSmTypeNbCh(iSmType), 0, fMbsMappingPar->GetSmTypeNbCh(iSmType), - fMbsMappingPar->GetSmTypeNbCh(iSmType), 0, fMbsMappingPar->GetSmTypeNbCh(iSmType)); - fhDetChCoincRight.at(iDetIndx) = new TH2I( - Form("tof_ty%01d_sm%03d_rpc%03d_coinc_right", iSmType, iSmId, iRpcId ), - Form("Number of events with hits for both channels of Rpc #%03d in Sm %03d of type %d; Channel right 1 []; Channel right 2 []; Events with hits in both[]", - iRpcId, iSmId, iSmType ), - fMbsMappingPar->GetSmTypeNbCh(iSmType), 0, fMbsMappingPar->GetSmTypeNbCh(iSmType), - fMbsMappingPar->GetSmTypeNbCh(iSmType), 0, fMbsMappingPar->GetSmTypeNbCh(iSmType)); - - (fviNbHitInThisEvent.at(iDetIndx)).resize( 2*fMbsMappingPar->GetSmTypeNbCh(iSmType), 0 ); - } // for( Int_t iDetIndx = 0; iDetIndx < fMbsMappingPar->GetNbMappedDet(); iDetIndx++ ) - } // if( 0 < fMbsMappingPar->GetNbMappedDet() ) - - if( kTRUE == fMbsMappingPar->IsDebug() ) - { - for( UInt_t uType = toftdc::caenV1290; uType < toftdc::NbTdcTypes; uType++ ) - { - if( 0 < fMbsUnpackPar->GetNbActiveBoards( uType ) ) - { - UInt_t uNbChan = 0; - - switch( uType ) - { - case toftdc::caenV1290: - uNbChan = caentdc::kuNbChan; - break; - case toftdc::vftx: - uNbChan = vftxtdc::kuNbChan / 2; - break; - case toftdc::trb: - uNbChan = trbtdc::kuNbChan / 2; -// uNbChan /= 2; // FIXME: used to reduce channel number (half empty) for GSI Sep 14!!! - break; - case toftdc::get4: - uNbChan = get4tdc::kuNbChan; - break; - default: - break; - } // switch( uType ) - - // Calibration variable initialization - Int_t iHistoIndex = 0; - for( UInt_t uTdc1 = 0; uTdc1 < fMbsUnpackPar->GetNbActiveBoards( uType ); uTdc1 ++) - for( UInt_t uTdc2 = uTdc1; uTdc2 < fMbsUnpackPar->GetNbActiveBoards( uType ); uTdc2 ++) - iHistoIndex ++; - fhDebTdcChEvtCoinc[uType].resize( iHistoIndex, NULL ); - iHistoIndex = 0; -// fhDebTdcChEvtCoinc[uType].resize( fMbsUnpackPar->GetNbActiveBoards( uType ) -1 ); - fbDebTdcChEvtThere[uType].resize( fMbsUnpackPar->GetNbActiveBoards( uType ) ); - for( UInt_t uTdc1 = 0; uTdc1 < fMbsUnpackPar->GetNbActiveBoards( uType ); uTdc1 ++) - { -// fhDebTdcChEvtCoinc[uType][uTdc1].resize( fMbsUnpackPar->GetNbActiveBoards( uType ) - uTdc1 -1, NULL ); - ((fbDebTdcChEvtThere[uType]).at(uTdc1)).resize( uNbChan, kFALSE ); - for( UInt_t uTdc2 = uTdc1; uTdc2 < fMbsUnpackPar->GetNbActiveBoards( uType ); uTdc2 ++) - { -// LOG(info)<<"TMbsMappingTof::CreateHistogramms => "<< uType << " " << uTdc1 << " " << uTdc2; - (fhDebTdcChEvtCoinc[uType]).at(iHistoIndex) = new TH2I( - Form("tof_map_deb_ty%01u_tdc%03u_tdc%03u", uType, uTdc1, uTdc2 ), - Form("Number of events with hits for in both channels for TDC #%03u and %03u of type %d; Channel TDC #%03u []; Channel TDC #%03u []; Events with hits in both[]", - uTdc1, uTdc2, uType, uTdc1, uTdc2 ), - uNbChan, 0, uNbChan, - uNbChan, 0, uNbChan ); -// LOG(info)<<" => OK "; - iHistoIndex++; - } // for( UInt_t uTdc2 = uTdc1 + 1; uTdc2 < fMbsUnpackPar->GetNbActiveBoards( uType ); uTdc2 ++) - } // for( UInt_t uTdc1 = 0; uTdc1 < fMbsUnpackPar->GetNbActiveBoards( uType ); uTdc1 ++) - } // if( 0 < fMbsUnpackPar->GetNbActiveBoards( uType ) ) - } // for( UInt_t uType = toftdc::caenV1290; uType < toftdc::NbTdcTypes; uType++ ) - } // if( kTRUE == fMbsMappingPar->IsDebug() ) - - gDirectory->cd( oldir->GetPath() ); // <= To prevent histos from being sucked in by the param file of the TRootManager! - - return kTRUE; -} -Bool_t TMbsMappingTof::FillHistograms() -{ - if( 0 != FairRunAna::Instance() ) - { - // Get Base Container <- Needed because currently RunOnLmd runs 1 more time after setting end of file flag!!!!! - // Should not be a problem when using the FAIRROOT way of reading MBS event instead of the custom "Go4 like" way - FairRunAna* ana = FairRunAna::Instance(); // <- Needed because currently RunOnLmd runs 1 more time after setting end of file flag!!!!!! - // Needed because currently RunOnLmd runs 1 more time after setting end of file flag!!!!!! - if( kTRUE == ana->GetLMDProcessingStatus() ) - return kFALSE; - } // if( 0 != FairRunAna::Instance() ) - - if( 0 < fMbsMappingPar->GetNbMappedDet() ) - { - for( Int_t iDetIndx = 0; iDetIndx < fMbsMappingPar->GetNbMappedDet(); iDetIndx++ ) - std::fill( (fviNbHitInThisEvent.at(iDetIndx)).begin(), (fviNbHitInThisEvent.at(iDetIndx)).end(), 0 ); - - Int_t iAddress = 0xFFFFFFFF; - Int_t iMappedDet = -1; - Int_t iSmType = -1; - Int_t iChan = -1; - Int_t iSide = -1; - // loop over Mapped Data - for( Int_t iDigiIndex = 0; iDigiIndex < fCbmTofDigiCollection->GetEntriesFast() ; iDigiIndex++ ) - { - if( kTRUE == fMbsMappingPar->UseDigiExp() ) - { - CbmTofDigi * xDigiPtr = (CbmTofDigi *)fCbmTofDigiCollection->At( iDigiIndex ); - - iAddress = xDigiPtr->GetAddress(); - iMappedDet = fMbsMappingPar->GetMappedDetInd( iAddress ); - if( -1 < iMappedDet ) - { - iSmType = xDigiPtr->GetType(); - iChan = xDigiPtr->GetChannel(); - iSide = xDigiPtr->GetSide(); - (fviNbHitInThisEvent.at(iMappedDet)).at( iSide*fMbsMappingPar->GetSmTypeNbCh(iSmType) + iChan) ++; - - (fhDetChTotMul.at(iMappedDet))->Fill( iChan, iSide); - } // if( -1 < iMappedDet ) - } // if( kTRUE == fMbsMappingPar->UseDigiExp() ) - } // for( Int_t iDigiIndex = 0; iDigiIndex < fCbmTofDigiCollection->GetEntriesFast() ; iDigiIndex++ ) - for( Int_t iDetIndx = 0; iDetIndx < fMbsMappingPar->GetNbMappedDet(); iDetIndx++ ) - { - Int_t iUniqueId = fMbsMappingPar->GetMappedDetUId( iDetIndx ); - iSmType = CbmTofAddress::GetSmType( iUniqueId ); - for( Int_t iChIndx = 0; iChIndx < fMbsMappingPar->GetSmTypeNbCh(iSmType); iChIndx++) - { - // Hits per events - (fhDetChHitsPerEvt.at(2*iDetIndx))->Fill( iChIndx, - (fviNbHitInThisEvent.at(iDetIndx)).at( iChIndx )); - (fhDetChHitsPerEvt.at(2*iDetIndx+1))->Fill( iChIndx, - (fviNbHitInThisEvent.at(iDetIndx)).at( fMbsMappingPar->GetSmTypeNbCh(iSmType) +iChIndx )); - - // Events with at least one hit - if( 0 < (fviNbHitInThisEvent.at(iDetIndx)).at( iChIndx ) ) - (fhDetChEvtMul.at(iDetIndx))->Fill( iChIndx, 0); - if( 0 < (fviNbHitInThisEvent.at(iDetIndx)).at( fMbsMappingPar->GetSmTypeNbCh(iSmType) + iChIndx ) ) - (fhDetChEvtMul.at(iDetIndx))->Fill( iChIndx, 1); - - // Events with at least one hit in both channels = coincidences - for( Int_t iChIndx2 = 0 ; iChIndx2 < fMbsMappingPar->GetSmTypeNbCh(iSmType); iChIndx2++) - { - if( 0 < (fviNbHitInThisEvent.at(iDetIndx)).at( iChIndx ) && - 0 < (fviNbHitInThisEvent.at(iDetIndx)).at( fMbsMappingPar->GetSmTypeNbCh(iSmType) + iChIndx2 )) - (fhDetChCoincSides.at(iDetIndx))->Fill( iChIndx, iChIndx2 ); - if( iChIndx < iChIndx2 && - 0 < (fviNbHitInThisEvent.at(iDetIndx)).at( iChIndx ) && - 0 < (fviNbHitInThisEvent.at(iDetIndx)).at( iChIndx2 )) - (fhDetChCoincLeft.at(iDetIndx))->Fill( iChIndx, iChIndx2 ); - - if( iChIndx < iChIndx2 && - 0 < (fviNbHitInThisEvent.at(iDetIndx)).at( fMbsMappingPar->GetSmTypeNbCh(iSmType) + iChIndx ) && - 0 < (fviNbHitInThisEvent.at(iDetIndx)).at( fMbsMappingPar->GetSmTypeNbCh(iSmType) + iChIndx2 )) - (fhDetChCoincRight.at(iDetIndx))->Fill( iChIndx, iChIndx2 ); - } // for( Int_t iChIndx2 = iChIndx ; iChIndx2 < fMbsMappingPar->GetSmTypeNbCh(iSmType); iChIndx2++) - } // for all Det/Ch pairs - } // for( Int_t iDetIndx = 0; iDetIndx < fMbsMappingPar->GetNbMappedDet(); iDetIndx++ ) - } // if( 0 < fMbsMappingPar->GetNbMappedDet() ) - - if( kTRUE == fMbsMappingPar->IsDebug() ) - { - TTofCalibData * fCalibData; - // loop over Calibrated Data - for( Int_t iDataIndex = 0; iDataIndex < fCalibDataCollection->GetEntriesFast() ; iDataIndex++ ) - { - fCalibData = (TTofCalibData *)fCalibDataCollection->At( iDataIndex ); - - // Monitoring histograms - UInt_t uType = fCalibData->GetType(); - UInt_t uTdc = fCalibData->GetBoard(); - UInt_t uChan = fCalibData->GetChannel(); - Double_t dTime = fCalibData->GetTime(); - Double_t dTot = fCalibData->GetTot(); - - if( 0 < dTime && 0 < dTot ) - ((fbDebTdcChEvtThere[uType]).at(uTdc)).at(uChan) = kTRUE; - } // for( Int_t iDataIndex = 0; iDataIndex < fCalibDataCollection->GetEntriesFast() ; iDataIndex++ ) - - for( UInt_t uType = toftdc::caenV1290; uType < toftdc::NbTdcTypes; uType++ ) - { - if( 0 < fMbsUnpackPar->GetNbActiveBoards( uType ) ) - { - UInt_t uNbChan = 0; - - switch( uType ) - { - case toftdc::caenV1290: - uNbChan = caentdc::kuNbChan; - break; - case toftdc::vftx: - uNbChan = vftxtdc::kuNbChan / 2; - break; - case toftdc::trb: - uNbChan = trbtdc::kuNbChan / 2; -// uNbChan /= 2; // FIXME: used to reduce channel number (half empty) for GSI Sep 14!!! - break; - case toftdc::get4: - uNbChan = get4tdc::kuNbChan; - break; - default: - break; - } // switch( uType ) - - // Debug Fill and clear - Int_t iHistoIndex = 0; - for( UInt_t uTdc1 = 0; uTdc1 < fMbsUnpackPar->GetNbActiveBoards( uType ); uTdc1 ++) - { - for( UInt_t uTdc2 = uTdc1; uTdc2 < fMbsUnpackPar->GetNbActiveBoards( uType ); uTdc2 ++) - { - for( UInt_t uChIndx1 = 0 ; uChIndx1 < uNbChan; uChIndx1++) - for( UInt_t uChIndx2 = 0 ; uChIndx2 < uNbChan; uChIndx2++) - if( kTRUE == ((fbDebTdcChEvtThere[uType]).at(uTdc1)).at(uChIndx1) && - kTRUE == ((fbDebTdcChEvtThere[uType]).at(uTdc2)).at(uChIndx2) ) - ((fhDebTdcChEvtCoinc[uType]).at(iHistoIndex))->Fill(uChIndx1, uChIndx2); - iHistoIndex++; - } // for( UInt_t uTdc2 = uTdc1 + 1; uTdc2 < fMbsUnpackPar->GetNbActiveBoards( uType ); uTdc2 ++) - - for( UInt_t uChIndx1 = 0 ; uChIndx1 < uNbChan; uChIndx1++) - ((fbDebTdcChEvtThere[uType]).at(uTdc1)).at(uChIndx1) = kFALSE; - } // for( UInt_t uTdc1 = 0; uTdc1 < fMbsUnpackPar->GetNbActiveBoards( uType ); uTdc1 ++) - } // if( 0 < fMbsUnpackPar->GetNbActiveBoards( uType ) ) - } // for( UInt_t uType = toftdc::caenV1290; uType < toftdc::NbTdcTypes; uType++ ) - } // if( kTRUE == fMbsMappingPar->IsDebug() ) - return kTRUE; -} -void TMbsMappingTof::WriteHistogramms() -{ - TDirectory * oldir = gDirectory; - TFile *fHist = new TFile("./tofMbsMap.hst.root","RECREATE"); - -// TDirectory* inDir = (TDirectory *)fHist; - if( 0 < fMbsMappingPar->GetNbMappedDet() ) - { - - // create a subdirectory for each histogram type in this file - TDirectory *cdMapEvt = fHist->mkdir( "Map_Evt" ); - TDirectory *cdMapTot = fHist->mkdir( "Map_Total" ); - TDirectory *cdMapHitsPerEvt = fHist->mkdir( "Map_HitsPerEvt" ); - TDirectory *cdMapCoincSides = fHist->mkdir( "Map_coincSide" ); - TDirectory *cdMapCoincLeft = fHist->mkdir( "Map_coincLeft" ); - TDirectory *cdMapCoincRight = fHist->mkdir( "Map_coincRight" ); - - // loop over all mapped Detectors - for( Int_t iDetIndx = 0; iDetIndx < fMbsMappingPar->GetNbMappedDet(); iDetIndx++ ) - { - // Nb Events with hits - cdMapEvt->cd(); - (fhDetChEvtMul.at(iDetIndx))->Write(); - - // Total Nb hits per channel/side - cdMapTot->cd(); - (fhDetChTotMul.at(iDetIndx))->Write(); - - // Hits per events - cdMapHitsPerEvt->cd(); - (fhDetChHitsPerEvt.at(2*iDetIndx))->Write(); - (fhDetChHitsPerEvt.at(2*iDetIndx+1))->Write(); - - cdMapCoincSides->cd(); - (fhDetChCoincSides.at(iDetIndx))->Write(); - cdMapCoincLeft->cd(); - (fhDetChCoincLeft.at(iDetIndx))->Write(); - cdMapCoincRight->cd(); - (fhDetChCoincRight.at(iDetIndx))->Write(); - } // for( Int_t iDetIndx = 0; iDetIndx < fMbsMappingPar->GetNbMappedDet(); iDetIndx++ ) - } // if( 0 < fMbsMappingPar->GetNbMappedDet() ) - - if( kTRUE == fMbsMappingPar->IsDebug() ) - { - TDirectory *cdDebugMapTdc = fHist->mkdir( "Map_DebugTdc" ); - cdDebugMapTdc->cd(); - for( UInt_t uType = toftdc::caenV1290; uType < toftdc::NbTdcTypes; uType++ ) - { - if( 0 < fMbsUnpackPar->GetNbActiveBoards( uType ) ) - { - TDirectory *cdDebugMapTdcFirst[fMbsUnpackPar->GetNbActiveBoards( uType )]; // TODO: safe? - // Debug Write - Int_t iHistoIndex = 0; - for( UInt_t uTdc1 = 0; uTdc1 < fMbsUnpackPar->GetNbActiveBoards( uType ); uTdc1 ++) - { - cdDebugMapTdcFirst[uTdc1] = cdDebugMapTdc->mkdir( Form("%s%03u_Map", - toftdc::ksTdcHistName[ uType ].Data(), uTdc1 ) ); - cdDebugMapTdcFirst[uTdc1]->cd(); - for( UInt_t uTdc2 = uTdc1; uTdc2 < fMbsUnpackPar->GetNbActiveBoards( uType ); uTdc2 ++) - { - ((fhDebTdcChEvtCoinc[uType]).at(iHistoIndex))->Write(); - iHistoIndex++; - } // for( UInt_t uTdc2 = uTdc1 + 1; uTdc2 < fMbsUnpackPar->GetNbActiveBoards( uType ); uTdc2 ++) - } // for( UInt_t uTdc1 = 0; uTdc1 < fMbsUnpackPar->GetNbActiveBoards( uType ); uTdc1 ++) - } // if( 0 < fMbsUnpackPar->GetNbActiveBoards( uType ) ) - } // for( UInt_t uType = toftdc::caenV1290; uType < toftdc::NbTdcTypes; uType++ ) - } // if( kTRUE == fMbsMappingPar->IsDebug() ) - - gDirectory->cd( oldir->GetPath() ); - - fHist->Close(); -} -void TMbsMappingTof::DeleteHistograms() -{ -} -// ------------------------------------------------------------------ -Bool_t TMbsMappingTof::RegisterInput() -{ - FairRootManager* rootMgr = FairRootManager::Instance(); - - if( 0 < fMbsUnpackPar->GetNbActiveBoards() ) - { - fCalibDataCollection = (TClonesArray*) rootMgr->GetObject("TofCalibData"); - if( NULL == fCalibDataCollection) - { - LOG(error)<<"TMbsMappingTof::RegisterInput => Could not get the TofCalibData TClonesArray!!!"; - return kFALSE; - } // if( NULL == fCalibDataCollection) - } // if( 0 < fMbsUnpackPar->GetNbActiveBoards() ) - - // Event rejection - // E.g.: pulser event used to Empty the VFTX buffers - if( 1 == fMbsUnpackPar->OnlyOneTriglog() && - -1 < fMbsUnpackPar->GetTriggerToReject() ) - { - LOG(info)<<"TMbsMappingTof::RegisterInput => Load the TofTriglog TClonesArray for trigger rejection!!!"; - fTriglogBoardCollection = (TClonesArray*) rootMgr->GetObject("TofTriglog"); - if( NULL == fTriglogBoardCollection) - { - LOG(error)<<"TMbsMappingTof::RegisterInput => Could not get the TofTriglog TClonesArray!!!"; - return kFALSE; - } // if( NULL == fTriglogBoardCollection) - } // if trigger rejection enabled and trigger board enabled - - return kTRUE; -} -Bool_t TMbsMappingTof::RegisterOutput() -{ - FairRootManager* rootMgr = FairRootManager::Instance(); - - if( kTRUE == fMbsMappingPar->UseDigiExp() ) - fCbmTofDigiCollection = new TClonesArray("CbmTofDigiExp"); - else fCbmTofDigiCollection = new TClonesArray("CbmTofDigi"); -// rootMgr->Register("CbmTofDigi","Tof",fCbmTofDigiCollection, IsOutputBranchPersistent("CbmTofDigi")); - rootMgr->Register( "CbmTofDigi","Tof",fCbmTofDigiCollection, - fMbsUnpackPar->WriteDataInCbmOut() || fbSaveMappedDigis ); - - return kTRUE; -} -Bool_t TMbsMappingTof::ClearOutput() -{ - // Actually, neither CbmDigi nor CbmTofDigi nor CbmTofDigiExp reimplement - // TObject::Clear(). This does, however, not matter here because each event's - // digi objects are reconstructed in the dedicated TClonesArray by a - // placement new operation instead of calling TClonesArray::ConstructedAt(). - fCbmTofDigiCollection->Clear("C"); - return kTRUE; -} - -void TMbsMappingTof::SetSaveDigis( Bool_t bSaveDigis ) -{ - fbSaveMappedDigis = bSaveDigis; - LOG(info)<<"TMbsMappingTof => Enable the saving of mapped digis in analysis output file"; -} -// ------------------------------------------------------------------ -// Mapping - // ----- Bit masks ----------------------------------------------------------- -const Int_t TMbsMappingTof::fgklTypeMask = ( 1 << TMbsMappingTof::fgkiTypeSize) - 1; -const Int_t TMbsMappingTof::fgklBoardMask = ( 1 << TMbsMappingTof::fgkiBoardSize) - 1; -const Int_t TMbsMappingTof::fgklChannelMask = ( 1 << TMbsMappingTof::fgkiChannelSize) - 1; -const Int_t TMbsMappingTof::fgklEdgeMask = ( 1 << TMbsMappingTof::fgkEdgeSize) - 1; - // ----------------------------------------------------------------------------- - // ----- Bit shifts -------------------------------------------------------- -const Int_t TMbsMappingTof::fgkiTypeOffs = 0; -const Int_t TMbsMappingTof::fgkiBoardOffs = TMbsMappingTof::fgkiTypeOffs + TMbsMappingTof::fgkiTypeSize; -const Int_t TMbsMappingTof::fgkiChannelOffs = TMbsMappingTof::fgkiBoardOffs + TMbsMappingTof::fgkiBoardSize; -const Int_t TMbsMappingTof::fgkiEdgeOffs = TMbsMappingTof::fgkiChannelOffs + TMbsMappingTof::fgkiChannelSize; - // ----------------------------------------------------------------------------- -Int_t TMbsMappingTof::GetTdcUniqueId( UInt_t uType, UInt_t uBoard, UInt_t uChannel, UInt_t uEdge ) -{ - Int_t iUniqueId = ( ( uType & fgklTypeMask ) << fgkiTypeOffs ) + - ( ( uBoard & fgklBoardMask ) << fgkiBoardOffs ) + - ( ( uChannel & fgklChannelMask ) << fgkiChannelOffs ) + - ( ( uEdge & fgklEdgeMask ) << fgkiEdgeOffs ); - return iUniqueId; -} -Bool_t TMbsMappingTof::MapTdcDataToDet() -{ - if( NULL == fCalibDataCollection || NULL == fCbmTofDigiCollection ) - return kFALSE; - - TTofCalibData * fCalibData; - LOG(debug)<<"TMbsCalibTof::MapTdcDataToDet => "<<fCalibDataCollection->GetEntriesFast() - <<" data calibrated to be mapped in this event!"; - - // loop over Calibrated Data - for( Int_t iDataIndex = 0; iDataIndex < fCalibDataCollection->GetEntriesFast() ; iDataIndex++ ) - { - fCalibData = (TTofCalibData *)fCalibDataCollection->At( iDataIndex ); - - UInt_t uType = fCalibData->GetType(); - UInt_t uTdc = fCalibData->GetBoard(); - UInt_t uChan = fCalibData->GetChannel(); - Double_t dTime = fCalibData->GetTime(); - Double_t dTot = fCalibData->GetTot(); - UInt_t uEdge = fCalibData->GetEdge(); - - Int_t iTdcUId = GetTdcUniqueId( uType, uTdc ); - Int_t iMappedTdcInd = fMbsMappingPar->GetMappedTdcInd( iTdcUId ); - - // First Check if this TDC is in the mapping and if the calibrated hit is complete - if( -1 < iMappedTdcInd && 2 == uEdge ) - { - Int_t iChanUId = fMbsMappingPar->GetMapping( iMappedTdcInd, uChan ); - if( 0xFFFFFFFF != static_cast<UInt_t>(iChanUId) ) - { - // Create Digi and store it - if( kTRUE == fMbsMappingPar->UseDigiExp() ) - new((*fCbmTofDigiCollection)[ fCbmTofDigiCollection->GetEntriesFast() ]) - CbmTofDigi( iChanUId, dTime, dTot ); - - - if(fbDuplicatePadDigis) - { - if ( ((iChanUId & 0x0000F00F) == 0x00005006) // duplicate diamond, pad entry - ||((iChanUId & 0x0000F00F) == 0x00002006) // duplicate ceramics entry/interference wih Pla!? - ||((iChanUId & 0x0000F00F) == 0x00008006)) { // duplicate Pad entry // FIXME - iChanUId |= 0x00800000; - Int_t Nent = fCbmTofDigiCollection->GetEntriesFast(); - new((*fCbmTofDigiCollection)[ fCbmTofDigiCollection->GetEntriesFast() ]) - CbmTofDigi( iChanUId, dTime, dTot ); - LOG(debug)<<Form("TMbsMappingTof: Pad entry duplicated 0x%08x at Nent",iChanUId); - CbmTofDigi *pDigi2=(CbmTofDigi*) fCbmTofDigiCollection->At(Nent); - CbmTofDigi *pDigi1=(CbmTofDigi*) fCbmTofDigiCollection->At(Nent-1); - if(pDigi1->GetTime() !=pDigi2->GetTime()){ - LOG(error) << "TMbsMappingTof: Digi duplication error "; - LOG(error) << " " <<pDigi1->ToString(); - LOG(error) << " " <<pDigi2->ToString(); - } - } - } - - } // if( 0xFFFFFFFF != fMbsMappingPar->GetMapping( iMappedTdcInd, uChan ) ) - else { - LOG(debug)<<Form("TMbsMappingTof:: <W> Digi in unmapped TDC %d channel %d", iMappedTdcInd, uChan); - } - } // if( -1 < iMappedTdcInd && 2 == uEdge ) - else if( uEdge < 2) - LOG(warn)<<"TMbsCalibTof::MapTdcDataToDet => Incomplete calibrated data found" - <<" => Maybe you are using the wrong Tot building mode? fuEdge = "<<uEdge; - } // for( Int_t iDataIndex = 0; iDataIndex < fCalibDataCollection->GetEntriesFast() ; iDataIndex++ ) - - // Time sort digis - fCbmTofDigiCollection->Sort(); - - return kTRUE; -} diff --git a/beamtime/tof/mapping/TMbsMappingTof.h b/beamtime/tof/mapping/TMbsMappingTof.h deleted file mode 100644 index 9f78c298c487d21cbfc32244aeca1521baf3e47f..0000000000000000000000000000000000000000 --- a/beamtime/tof/mapping/TMbsMappingTof.h +++ /dev/null @@ -1,119 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TMbsMappingTof ----- -// ----- Created 09/06/2013 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ -#ifndef _TMBSMAPPINGTOF_H_ -#define _TMBSMAPPINGTOF_H_ - -#include "FairTask.h" - -#include <vector> - -#include "TofTdcDef.h" - -// Parameters -class TMbsUnpackTofPar; -class TMbsCalibTofPar; -class TMbsMappingTofPar; - -// Output Data -class TTofCalibData; - -// ROOT -class TFile; -class TDirectory; -class TClonesArray; -class TH1; -class TH2; -class TString; - -class TMbsMappingTof : public FairTask { - public: - TMbsMappingTof(); - TMbsMappingTof(const char* name, Int_t mode = 1, Int_t verbose = 1); - virtual ~TMbsMappingTof(); - - // Fairtask specific functions - virtual void SetParContainers(); - virtual InitStatus Init(); - virtual InitStatus ReInit(); - virtual void Exec(Option_t* option); - virtual void Finish(); - - // Histograms - void WriteHistogramms(); - void SetFillHistogramms( Bool_t bFillHistos = kTRUE ) { fbFillHistos = bFillHistos; } - void SetDuplicatePadDigis( Bool_t bDuplicate = kTRUE ) { fbDuplicatePadDigis = bDuplicate; } - - void SetSaveDigis( Bool_t bSaveDigis = kTRUE ); - private: - TMbsMappingTof(const TMbsMappingTof&); - TMbsMappingTof operator=(const TMbsMappingTof&); - - // Parameters - Bool_t InitParameters(); - TMbsUnpackTofPar *fMbsUnpackPar; - TMbsCalibTofPar *fMbsCalibPar; - TMbsMappingTofPar *fMbsMappingPar; - - // Histograms - Bool_t CreateHistogramms(); - Bool_t FillHistograms(); - void DeleteHistograms(); // TODO - - // Histograms objects - std::vector< std::vector< Int_t > > fviNbHitInThisEvent; - std::vector< TH2* > fhDetChEvtMul; - std::vector< TH2* > fhDetChTotMul; - std::vector< TH2* > fhDetChHitsPerEvt; - std::vector< TH2* > fhDetChCoincSides; - std::vector< TH2* > fhDetChCoincLeft; - std::vector< TH2* > fhDetChCoincRight; - // DEBUG - std::vector< std::vector< Bool_t > > fbDebTdcChEvtThere[ toftdc::NbTdcTypes ]; - std::vector< TH2 * > fhDebTdcChEvtCoinc[ toftdc::NbTdcTypes ]; - - // Input - Bool_t RegisterInput(); - - // Input objects - TClonesArray * fCalibDataCollection; - - // For trigger rejection - TClonesArray * fTriglogBoardCollection; - - // Output - Bool_t RegisterOutput(); - Bool_t ClearOutput(); - - // Output objects - Bool_t fbSaveMappedDigis; - Bool_t fbFillHistos; - Bool_t fbDuplicatePadDigis; - TClonesArray * fCbmTofDigiCollection; - - // Mapping - Int_t GetTdcUniqueId( UInt_t uType, UInt_t uBoard, UInt_t uChannel = 0, UInt_t uEdge = 0 ); - // ----- Bit fields sizes -------------------------------------------------- - static const Int_t fgkiTypeSize = 4; - static const Int_t fgkiBoardSize = 12; - static const Int_t fgkiChannelSize = 12; - static const Int_t fgkEdgeSize = 1; - // ----------------------------------------------------------------------------- - // ----- Bit masks ----------------------------------------------------------- - static const Int_t fgklTypeMask; - static const Int_t fgklBoardMask; - static const Int_t fgklChannelMask; - static const Int_t fgklEdgeMask; - // ----------------------------------------------------------------------------- - // ----- Bit shifts -------------------------------------------------------- - static const Int_t fgkiTypeOffs; - static const Int_t fgkiBoardOffs; - static const Int_t fgkiChannelOffs; - static const Int_t fgkiEdgeOffs; - // ----------------------------------------------------------------------------- - Bool_t MapTdcDataToDet(); - - ClassDef(TMbsMappingTof, 1); -}; -#endif // _TMBSMAPPINGTOF_H_ diff --git a/beamtime/tof/mapping/TMbsMappingTofPar.cxx b/beamtime/tof/mapping/TMbsMappingTofPar.cxx deleted file mode 100644 index d3be872ab4ef7df06c1fd556e31897d35e8c624b..0000000000000000000000000000000000000000 --- a/beamtime/tof/mapping/TMbsMappingTofPar.cxx +++ /dev/null @@ -1,266 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TMbsMappingTofPar ----- -// ----- Created 09/06/2013 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ -#include "TMbsMappingTofPar.h" - -// TOF headers -#include "TofTdcDef.h" -#include "TofCaenDef.h" -#include "TofVftxDef.h" -#include "TofTrbTdcDef.h" -#include "TofGet4Def.h" -#include "CbmTofAddress.h" - -// FAIR headers -#include "FairLogger.h" -#include "FairParamList.h" - -// ROOT headers -#include "TString.h" - -ClassImp(TMbsMappingTofPar) - -// TODO: To be defined somewhere else later!! FIXME -// HD BUC PLA CRPC Ref BHD newBUC -//const Int_t TMbsMappingTofPar::fgkiNbChDetType[7] = { 32, 72, 1, 8, 10, 56, 8 }; -Int_t TMbsMappingTofPar::fgkiNbChDetType[fgkiNbDetType] = -// Feb2015 P3 Ref PLA P2 P5 Dia 2013 USTC PAD ThuStr 2012 -// | | | | | | | | | | | -// { 56, 72, 1, 32, 16, 16, 64, 16, 8, 24, 8 }; -// Nov2015 P3 Ref PLA P2 P5 Dia 2015 2012 PAD Star ThuStr -// | | | | | | | | | | | -// { 1, 72, 1, 32, 16, 16, 40, 40, 8, 32, 24 }; - { 1, 72, 1, 32, 16, 16, 64, 40, 8, 32, 24 }; -// This information should be collected from the DigiPar file (nh, Nov. 2015) - -TMbsMappingTofPar::TMbsMappingTofPar() : - FairParGenericSet("TMbsMappingTofPar","Tof MBS Mapping Parameters","TestDefaultContext"), - fuMappingDebug(0), - fiNbMappedTdc(0), - fiNbChTdc(), - fiTdcUniqueId(), - fiMapping(), - fiUseExtendedDigi(0), - fiNbMappedDet(0), - fiDetUniqueId() -{ -} - -TMbsMappingTofPar::TMbsMappingTofPar(const char* name, - const char* title, - const char* context ) : - FairParGenericSet(name,title,context), - fuMappingDebug(0), - fiNbMappedTdc(0), - fiNbChTdc(), - fiTdcUniqueId(), - fiMapping(), - fiUseExtendedDigi(0), - fiNbMappedDet(0), - fiDetUniqueId() -{ -} - -TMbsMappingTofPar::~TMbsMappingTofPar() -{ -} - -void TMbsMappingTofPar::clear(void) -{ - status = kFALSE; - resetInputVersions(); -} - -void TMbsMappingTofPar::putParams(FairParamList* l) -{ - if (!l) { return; } - - l->add("MappingDebug", (Int_t)fuMappingDebug); - l->add("NbMappedTdc", fiNbMappedTdc); - l->add("NbChTdc", fiNbChTdc); - l->add("TdcUniqueId", fiTdcUniqueId); - l->add("Mapping", fiMapping); - l->add("UseExtDigi", fiUseExtendedDigi); - l->add("NbMappedDet", fiNbMappedDet); - l->add("DetUniqueId", fiDetUniqueId); -} - -Bool_t TMbsMappingTofPar::getParams(FairParamList* l) -{ - if (!l) { return kFALSE; } - - /* - * TODO PAL: Thing I am not sure is whether order in readout has to - * match order in the ascii file => to check - */ - - LOG(debug2)<<"Get the Tof MBS mapping parameters."; - - Int_t iTempCaster = 0; - if ( ! l->fill("MappingDebug", &iTempCaster) ) return kFALSE; - fuMappingDebug = (UInt_t)iTempCaster; - - if ( ! l->fill("NbMappedTdc", &fiNbMappedTdc) ) return kFALSE; - - if( 0 < fiNbMappedTdc ) - { - fiNbChTdc.Set( fiNbMappedTdc ); - if ( ! l->fill("NbChanTdc", &fiNbChTdc) ) return kFALSE; - - fiTdcUniqueId.Set( fiNbMappedTdc ); - if ( ! l->fill("TdcUniqueId", &fiTdcUniqueId) ) return kFALSE; - - Int_t iTotalNbChMapped = 0; - for( Int_t iMappTdcIndex = 0; iMappTdcIndex < fiNbMappedTdc; iMappTdcIndex++) - iTotalNbChMapped += fiNbChTdc[iMappTdcIndex]; - if( 0 < iTotalNbChMapped ) - { - fiMapping.Set( iTotalNbChMapped ); - if ( ! l->fill("Mapping", &fiMapping) ) return kFALSE; - } // if( 0 < iTotalNbChMapped ) - } // if( 0 < fiNbMappedTdc ) - if ( ! l->fill("UseExtDigi", &fiUseExtendedDigi) ) return kFALSE; - - if ( ! l->fill("NbMappedDet", &fiNbMappedDet) ) return kFALSE; - if( 0 < fiNbMappedDet ) - { - fiDetUniqueId.Set( fiNbMappedDet ); - if ( ! l->fill("DetUniqueId", &fiDetUniqueId) ) return kFALSE; - } // if( 0 < fiNbMappedDet ) - - return kTRUE; -} - -void TMbsMappingTofPar::printParams() -{ - LOG(info)<<"Parameter values in TMbsMappingTofPar: "; - - if(1 == fuMappingDebug) - LOG(info)<<" Mapping Debug ON!!!!!!"; - else LOG(info)<<" Mapping Debug OFF"; - - LOG(info)<<" Nb of TDC mapped to detectors: "<<fiNbMappedTdc; - - if( 0 < fiNbMappedTdc ) - { - TString sTdcInd = "Tdc #: --- "; - TString sNbChTdc = "Nb ch per Mapped TDC: |-> "; - TString sUnIdTdc = "TDC Unique Id: |-> "; - - TString sChanInd = "Channel Index: --- "; - TString* sMapping = new TString[fiNbMappedTdc]; - - Int_t iMappingIndex = 0; - Int_t iMaxChannels = fiNbChTdc[0]; - for( Int_t iMappTdcIndex = 0; iMappTdcIndex < fiNbMappedTdc; iMappTdcIndex++) - { - sTdcInd += Form(" %8d ", iMappTdcIndex); - sNbChTdc += Form(" %8d ", fiNbChTdc[iMappTdcIndex]); - sUnIdTdc += Form("0x%08X ", fiTdcUniqueId[iMappTdcIndex]); - - sMapping[iMappTdcIndex] = Form("Tdc #%03d, mapped to Det UId: |-> ", iMappTdcIndex); - if( iMaxChannels < fiNbChTdc[iMappTdcIndex] ) - sChanInd = "Channel Index: ---"; - for( Int_t iChanInd = 0; iChanInd < fiNbChTdc[iMappTdcIndex]; iChanInd++) - { - if( 0xFFFFFFFF == static_cast<UInt_t>(fiMapping[ iMappingIndex + iChanInd ]) ) - sMapping[iMappTdcIndex] += "0xFFFFFFFF "; - else sMapping[iMappTdcIndex] += Form("0x%08X ", fiMapping[ iMappingIndex + iChanInd ]); - if( 0 == iMappTdcIndex ) - sChanInd += Form(" %8d ", iChanInd); - else if( iMaxChannels < fiNbChTdc[iMappTdcIndex] ) - sChanInd += Form(" %8d ", iChanInd); - } // for( Int_t iChanInd = 0; iChanInd < fiNbChTdc[iMappTdcIndex]; iChanInd++) - if( iMaxChannels < fiNbChTdc[iMappTdcIndex] ) - iMaxChannels = fiNbChTdc[iMappTdcIndex]; - - iMappingIndex += fiNbChTdc[iMappTdcIndex]; - } // for( Int_t iMappTdcIndex = 0; iMappTdcIndex < fiNbMappedTdc; iMappTdcIndex++) - LOG(info)<<sTdcInd; - LOG(info)<<sNbChTdc; - LOG(info)<<sUnIdTdc; - LOG(info)<<sChanInd; - for( Int_t iMappTdcIndex = 0; iMappTdcIndex < fiNbMappedTdc; iMappTdcIndex++) - LOG(info)<<sMapping[iMappTdcIndex]; - - delete [] sMapping; - } // if( 0 < fiNbMappedTdc ) - - - if(1 == fiUseExtendedDigi) - LOG(info)<<" Type of Digis used: Extended"; - else LOG(info)<<" Type of Digis used: Compressed"; - - LOG(info)<<" Nb of detectors in mapping: "<<fiNbMappedDet; - if( 0 < fiNbMappedDet ) - { - TString sDetInd = "Det #: --- "; - TString sUnIdDet = "Det Unique Id: |-> "; - for( Int_t iMappDetIndex = 0; iMappDetIndex < fiNbMappedDet; iMappDetIndex++) - { - sDetInd += Form(" %8d ", iMappDetIndex); - sUnIdDet += Form("0x%08X ", fiDetUniqueId[iMappDetIndex]); - } // for( Int_t iMappDetIndex = 0; iMappDetIndex < fiNbMappedDet; iMappDetIndex++) - LOG(info)<<sDetInd; - LOG(info)<<sUnIdDet; - } // if( 0 < fiNbMappedDet ) - return; -} -// ------------------------------------------------------------------ -Int_t TMbsMappingTofPar::GetMappedTdcUId( Int_t iMappedTdcInd ) const -{ - if( iMappedTdcInd < fiNbMappedTdc ) - return fiTdcUniqueId[iMappedTdcInd]; - else return -1; // Equal to 0xFFFFFFFF => inactive -} -Int_t TMbsMappingTofPar::GetMappedTdcInd( Int_t iTdcUId ) const -{ - for( Int_t iMappedTdcInd = 0; iMappedTdcInd < GetNbMappedTdc(); iMappedTdcInd++) - if( iTdcUId == GetMappedTdcUId( iMappedTdcInd ) ) - return iMappedTdcInd; - - // If none of the TDC matches => return -1, calling function/method has to catch it - // and ignore the corresponding data object - return -1; -} -Int_t TMbsMappingTofPar::GetMapping( Int_t iMappedTdcInd, Int_t iMappedChan ) const -{ - if( iMappedTdcInd < fiNbMappedTdc ) - { - if( iMappedChan < fiNbChTdc[iMappedTdcInd] ) - { - Int_t iMappingIndex = 0; - for( Int_t iPrevTdcIndx = 0; iPrevTdcIndx < iMappedTdcInd; iPrevTdcIndx++) - iMappingIndex += fiNbChTdc[iPrevTdcIndx]; - return fiMapping[ iMappingIndex + iMappedChan ]; - } // if( iMappedChan < fiNbChTdc[iMappedTdcInd] ) - else return -1; // Equal to 0xFFFFFFFF => inactive - } // if( iMappedTdcInd < fiNbMappedTdc ) - else return -1; // Equal to 0xFFFFFFFF => inactive -} -Int_t TMbsMappingTofPar::GetMappedDetUId( Int_t iMappedDetInd ) const -{ - if( iMappedDetInd < fiNbMappedDet ) - return fiDetUniqueId[iMappedDetInd]; - else return -1; // Equal to 0xFFFFFFFF => inactive -} -Int_t TMbsMappingTofPar::GetMappedDetInd( Int_t iMappedDetUId ) const -{ - if( 0xFFFFFFFF == static_cast<UInt_t>(iMappedDetUId) ) - return -1; // Equal to 0xFFFFFFFF => inactive - - for( Int_t iDetIndx = 0; iDetIndx < fiNbMappedDet; iDetIndx++) - if( kTRUE == CbmTofAddress::SameModule( iMappedDetUId, fiDetUniqueId[iDetIndx] ) ) - return iDetIndx; - - // If not matching any detector => - return -1; // Equal to 0xFFFFFFFF => inactive -} -// ------------------------------------------------------------------ -Int_t TMbsMappingTofPar::GetSmTypeNbCh( Int_t iSmType ) const -{ - if( -1 < iSmType && iSmType < fgkiNbDetType ) - return fgkiNbChDetType[iSmType]; - else return 0; -} diff --git a/beamtime/tof/mapping/TMbsMappingTofPar.h b/beamtime/tof/mapping/TMbsMappingTofPar.h deleted file mode 100644 index 728d033b4925a458b30dc56062c45af7a3700e60..0000000000000000000000000000000000000000 --- a/beamtime/tof/mapping/TMbsMappingTofPar.h +++ /dev/null @@ -1,75 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TMbsMappingTofPar ----- -// ----- Created 09/06/2013 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ -#ifndef _TMBSMAPPINGTOFPAR_H_ -#define _TMBSMAPPINGTOFPAR_H_ - -#include "TofTdcDef.h" - -#include "FairParGenericSet.h" -#include "TArrayI.h" -#include "TArrayD.h" - -class TMbsMappingTofPar : public FairParGenericSet -{ - public: - TMbsMappingTofPar() ; - - TMbsMappingTofPar( const char* name, - const char* title="Mbs Mapping parameters for the ToF", - const char* context="TestDefaultContext" ); - - virtual ~TMbsMappingTofPar(); - - // Accessors - Bool_t IsDebug() const { return (1 == fuMappingDebug)? kTRUE: kFALSE; }; - Bool_t UseDigiExp() const { return (1 == fiUseExtendedDigi)? kTRUE: kFALSE; }; - Int_t GetNbMappedTdc() const { return fiNbMappedTdc; }; - Int_t GetMappedTdcUId( Int_t iMappedTdcInd ) const; - Int_t GetMappedTdcInd( Int_t iTdcUId ) const; - Int_t GetMapping( Int_t iMappedTdcInd, Int_t iMappedChan ) const; - Int_t GetNbMappedDet() const { return fiNbMappedDet; }; - Int_t GetMappedDetUId( Int_t iMappedDetInd ) const; - Int_t GetMappedDetInd( Int_t iMappedDetUId ) const; - Int_t GetSmTypeNbCh( Int_t iSmType ) const; - - // Example taken from CbmTofDigiPar - void clear(void); - void putParams(FairParamList*); - Bool_t getParams(FairParamList*); - virtual void printParams(); - - private: - /** DEBUG */ - // Switch ON/OFF debug tests, output & histos in calibration - UInt_t fuMappingDebug; - - /** Mapping **/ - // Nb of TDC mapped (1) - Int_t fiNbMappedTdc; - // Nb of channels per TDC (2) - TArrayI fiNbChTdc; - // TDC Unique ID (aka 1st channel rising edge ID) - TArrayI fiTdcUniqueId; - // TDC to Detector Mapping: for each tdc channel provides the Detector Unique ID to use - TArrayI fiMapping; - // Use extended Digis: Time and Tot stored as double - // while "normal" digis rebin both to make them fit together in a single 32b integer - Int_t fiUseExtendedDigi; - // Nb of Detectors mapped (3) - Int_t fiNbMappedDet; - // Det Unique ID (aka 1st channel left side ID) - TArrayI fiDetUniqueId; - - // TODO: To be defined somewhere else later!! - static const Int_t fgkiNbDetType = 11; - static Int_t fgkiNbChDetType[fgkiNbDetType]; - - TMbsMappingTofPar(const TMbsMappingTofPar&); - TMbsMappingTofPar& operator=(const TMbsMappingTofPar&); - - ClassDef(TMbsMappingTofPar, 1) -}; - -#endif //TMBSMAPPINGTOFPAR_H diff --git a/beamtime/tof/output/MbsCrateDefines.h b/beamtime/tof/output/MbsCrateDefines.h deleted file mode 100644 index e388303c8e9385c1215db28e7579e9ca5bec51f0..0000000000000000000000000000000000000000 --- a/beamtime/tof/output/MbsCrateDefines.h +++ /dev/null @@ -1,133 +0,0 @@ -#ifndef MBSCRATEDEFINES_H -#define MBSCRATEDEFINES_H - -// TRIGLOG INFO -#ifndef WITHGO4ROC - #define NUM_SCALERS 3 - #define N_SCALERS_CH 16 -#endif // WITHGO4ROC - -// number of LeCroy 1182 modules -#define MAX_1182 2 -// number of channels in LeCroy 1182 modules -#define NUM_1182_CH 8 - -// number of 1290 TDC modules -#define MAX_1290 8 - -// V1290 bin size -//#define CAENBINSIZE 25.0/1024.0 - -// number of 965 QDC Modules -#define MAX_965 3 - -// number of FPGA TDC modules -#define MAX_FPGA_TDC 11 - -//#define OLD_VERSION_VULOM // <- Pre-COSY nov11 HD vulom FPGA code -//#define VERSION_VFTX // <- June 2012 version based on VFTX board (32 chan, 16 true chan+tot) -#define VERSION_VFTX_28 // <- August 2012 version based on VFTX board (56 chan, 28 true chan+tot) - -// number of channels in FPGA TDC modules -//#ifdef VERSION_VFTX -// #define FPGA_TDC_NBCHAN 32 -//#elif defined VERSION_VFTX_28 - #define FPGA_TDC_NBCHAN 56 -//#else -// #define FPGA_TDC_NBCHAN 8 -//#endif - -/******************** FPGA TDC data unpacking definitions *************/ -#define TDC_EVT_HEADER_KEY_MASK 0xFFFF0000 -#define TDC_EVT_HEADER_KEY_SHIFT 16 -#define TDC_EVT_HEADER_KEYWORD 0xABCD -#define TDC_EVT_HEADER_MOD_MASK 0x0000FF00 -#define TDC_EVT_HEADER_MOD_SHIFT 8 -#define TDC_EVT_HEADER_NB_MASK 0x000000FF - - -#ifdef OLD_VERSION_VULOM - #define TDC_FIFO_FINE_CT 0x000003FF - #define TDC_FIFO_COARSE_CT 0x01FFFC00 // Coarse counter value - #define TDC_FIFO_COARSE_CT_SHIFT 10 - #define TDC_FIFO_COARSE_FT_SHIFT 0 - #define TDC_FIFO_FUTURE_BIT 0x02000000 // Flag for hits after trigger - #define TDC_FIFO_FUTURE_BIT_SHIFT 25 - #define TDC_FIFO_DATA_CHAN 0x7C000000 - #define TDC_FIFO_DATA_CHAN_SHIFT 26 -#elif defined VERSION_VFTX - #define TDC_FIFO_FINE_CT 0x000007FF - #define TDC_FIFO_COARSE_CT 0x01FFF800 // Coarse counter value - #define TDC_FIFO_COARSE_CT_SHIFT 11 - #define TDC_FIFO_COARSE_FT_SHIFT 0 - #define TDC_FIFO_FUTURE_BIT 0x02000000 // Flag for hits after trigger - #define TDC_FIFO_FUTURE_BIT_SHIFT 25 - #define TDC_FIFO_DATA_CHAN 0x7C000000 // Channel number - #define TDC_FIFO_DATA_CHAN_SHIFT 26 -#elif defined VERSION_VFTX_28 - #define TDC_FIFO_FINE_CT 0x000007FF - #define TDC_FIFO_COARSE_CT 0x00FFF800 // Coarse counter value - #define TDC_FIFO_COARSE_CT_SHIFT 11 - #define TDC_FIFO_COARSE_FT_SHIFT 0 - #define TDC_FIFO_FUTURE_BIT 0x01000000 // Flag for hits after trigger - #define TDC_FIFO_FUTURE_BIT_SHIFT 24 - #define TDC_FIFO_DATA_CHAN 0x7E000000 // Channel number - #define TDC_FIFO_DATA_CHAN_SHIFT 25 -#else - #define TDC_FIFO_FINE_CT 0x000007FF - #define TDC_FIFO_COARSE_CT 0x03FFF800 // Coarse counter value - #define TDC_FIFO_COARSE_CT_SHIFT 11 - #define TDC_FIFO_COARSE_FT_SHIFT 0 - #define TDC_FIFO_FUTURE_BIT 0x04000000 // Flag for hits after trigger - #define TDC_FIFO_FUTURE_BIT_SHIFT 26 - #define TDC_FIFO_DATA_CHAN 0x78000000 - #define TDC_FIFO_DATA_CHAN_SHIFT 27 -#endif - -#ifdef OLD_VERSION_VULOM - #define TDC_FIFO_HEADER_DATA_CNT 0x000000FF // Data count - #define TDC_FIFO_HEADER_TRIG_TIME 0x01FFFC00 // Coarse counter value - #define TDC_FIFO_HEADER_TRIG_TIME_SHIFT 10 - #define TDC_FIFO_HEADER_TRIG_TYPE 0x60000000 // Trigger Type - #define TDC_FIFO_HEADER_TRIG_TYPE_SHIFT 29 - #define TDC_FIFO_MESSAGE_TYPE 0x80000000 // Message Type - #define TDC_FIFO_MESSAGE_TYPE_SHIFT 31 // (1 = header, 0 = data) -#elif defined VERSION_VFTX - #define TDC_FIFO_HEADER_DATA_CNT 0x000000FF // Data count - #define TDC_FIFO_HEADER_TRIG_TIME 0x01FFF800 // Coarse counter value - #define TDC_FIFO_HEADER_TRIG_TIME_SHIFT 11 - #define TDC_FIFO_HEADER_TRIG_TYPE 0x60000000 // Trigger Type - #define TDC_FIFO_HEADER_TRIG_TYPE_SHIFT 29 - #define TDC_FIFO_MESSAGE_TYPE 0x80000000 // Message Type - #define TDC_FIFO_MESSAGE_TYPE_SHIFT 31 // (1 = header, 0 = data) -#elif defined VERSION_VFTX_28 - #define TDC_FIFO_HEADER_DATA_CNT 0x000000FF // Data count - #define TDC_FIFO_HEADER_TRIG_TIME 0x00FFF800 // Coarse counter value - #define TDC_FIFO_HEADER_TRIG_TIME_SHIFT 11 - #define TDC_FIFO_HEADER_TRIG_TYPE 0x60000000 // Trigger Type - #define TDC_FIFO_HEADER_TRIG_TYPE_SHIFT 29 - #define TDC_FIFO_MESSAGE_TYPE 0x80000000 // Message Type - #define TDC_FIFO_MESSAGE_TYPE_SHIFT 31 // (1 = header, 0 = data) -#else - #define TDC_FIFO_HEADER_DATA_CNT 0x000000FF // Data count - #define TDC_FIFO_HEADER_TRIG_TIME 0x03FFF800 // Coarse counter value - #define TDC_FIFO_HEADER_TRIG_TIME_SHIFT 11 - #define TDC_FIFO_HEADER_TRIG_TYPE 0x60000000 // Trigger Type - #define TDC_FIFO_HEADER_TRIG_TYPE_SHIFT 29 - #define TDC_FIFO_MESSAGE_TYPE 0x80000000 // Message Type - #define TDC_FIFO_MESSAGE_TYPE_SHIFT 31 // (1 = header, 0 = data) -#endif - -//TODO: Switch to vftx_def.h -//#define VFTX_COARSE_SIZE (TDC_FIFO_COARSE_CT>>TDC_FIFO_COARSE_CT_SHIFT)+1 -#define VFTX_COARSE_OVERFLW_CHK 1 - -/**************** End FPGA TDC data unpacking definitions *************/ - -// Number of scalers in ScalOrMu - // Oct12 -//#define SCALORMU_NB_SCAL 16 - // Nov 12 -#define SCALORMU_NB_SCAL 32 - -#endif // MBSCRATEDEFINES_H diff --git a/beamtime/tof/output/Plastics_Event.cxx b/beamtime/tof/output/Plastics_Event.cxx deleted file mode 100644 index 0f8b4ce4d9664e86bf01a3e5ab2152769f937d70..0000000000000000000000000000000000000000 --- a/beamtime/tof/output/Plastics_Event.cxx +++ /dev/null @@ -1,28 +0,0 @@ - -#include "Plastics_Event.h" - -#ifdef WITHGO4ROC - #include "TGo4Version.h" - #if __GO4BUILDVERSION__ > 40502 - #include "go4iostream.h" - #else - #include "Riostream.h" - #endif -#endif // WITHGO4ROC - -void Plastics_Hit::Clear(Option_t * /*t*/) -{ - dTimeLeft = -1 ; - dTotLeft = -1 ; - dTimeRight = -1 ; - dTotRight = -1 ; - fbMultiEdge = kFALSE; -} - -void Plastics_Event::Clear(Option_t * /*t*/) -{ - // all members should be cleared. - for(Int_t iPlastic = 0; iPlastic<NB_PLASTICS_MAX; iPlastic++) - fHits[iPlastic].clear(); - fbMultiEdgesPresent = kFALSE; -} diff --git a/beamtime/tof/output/Plastics_Event.h b/beamtime/tof/output/Plastics_Event.h deleted file mode 100644 index 7e8cd73c4ce4ed46d6e23c0e7cdda4f2611453d7..0000000000000000000000000000000000000000 --- a/beamtime/tof/output/Plastics_Event.h +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef PLASTICS_EVENT_H -#define PLASTICS_EVENT_H - -#ifdef WITHGO4ROC - #include "TGo4EventElement.h" -#else - #include "Riostream.h" - #include "TObject.h" - #include <vector> -#endif // WITHGO4ROC - -#define NB_PLASTICS_MAX 4 // Maximal Nb of plastics which can be defined - -class Plastics_Hit: public TObject { - public: - Double_t dTimeLeft; // in ps - Double_t dTotLeft; // in ps - Double_t dTimeRight; // in ps - Double_t dTotRight; // in ps - Bool_t fbMultiEdge; - - Plastics_Hit() : - TObject(), - dTimeLeft(0.0), - dTotLeft(0.0), - dTimeRight(0.0), - dTotRight(0.0), - fbMultiEdge(kFALSE) - { Clear(); }; - virtual ~Plastics_Hit(){ Clear(); }; - - virtual void Clear(Option_t *t=""); - - Bool_t IsMultiEdge() const { return fbMultiEdge; }; - - /* - // copy constructor, used by vector to copy content for sorting - Plastics_Hit(const Plastics_Hit& src) : - iStrip(src.iStrip), - dTimeLeft(src.dTimeLeft), dTotLeft(src.dTotLeft), - dTimeRight(src.dTimeRight), dTotRight(src.dTotRight) {} - */ - - ClassDef(Plastics_Hit, 2) -}; - -class Plastics_Event : public TObject { - public: - - - Plastics_Event(): - TObject(), - fuEventNumber(0), - fbMultiEdgesPresent(kFALSE) - { Clear(); }; - virtual ~Plastics_Event(){ Clear(); }; - - /** Method called by the framework to clear the event element. */ - virtual void Clear(Option_t *t=""); - Bool_t IsMultiEdge() const { return fbMultiEdgesPresent; }; - - // Maybe to be transformed into a TObjArray or TCloneArray - std::vector<Plastics_Hit> fHits[NB_PLASTICS_MAX]; - UInt_t fuEventNumber; - Bool_t fbMultiEdgesPresent; - - ClassDef(Plastics_Event,2) -}; - -#endif //PLASTICS_EVENT_H diff --git a/beamtime/tof/output/Rpc_Event.cxx b/beamtime/tof/output/Rpc_Event.cxx deleted file mode 100644 index 7fa88e670b442bd4b8eae0589fdd1cd36a704a10..0000000000000000000000000000000000000000 --- a/beamtime/tof/output/Rpc_Event.cxx +++ /dev/null @@ -1,100 +0,0 @@ - -#include "Rpc_Event.h" - -#ifdef WITHGO4ROC - #include "TGo4Version.h" - #if __GO4BUILDVERSION__ > 40502 - #include "go4iostream.h" - #else - #include "Riostream.h" - #endif -#endif // WITHGO4ROC - - -void Rpc_Hit::Clear(Option_t*) -{ - iStrip = -1 ; - dTimeLeft = -1 ; - dTotLeft = -1 ; - dTimeRight = -1 ; - dTotRight = -1 ; - fbMultiEdge = kFALSE; -} -Double_t Rpc_Hit::PositionCalculation( Double_t dTimeConv ) -{ - return (dTimeRight - dTimeLeft)*dTimeConv/1000.0; -} - -void Rpc_Cluster::Clear(Option_t*) -{ - fHits.clear(); - dX = 0.0; - dY = 0.0; - dMeanTime = 0.0; -} -void Rpc_Cluster::PositionCalculation( - Double_t dMiddleStrip, UInt_t uOrientation, - Double_t dStripWidth, Double_t dTimeConv, - UInt_t uUseGravityCenter ) -{ - Double_t dTotSum = 0.0; - Double_t dMeanTot = 0.0; - if( 0 == fHits.size() ) - return; - - if( 1 == uOrientation ) - { - dX = 0.0; - dY = 0.0; - dMeanTime = 0; - dMeanStrip= 0; - for( UInt_t uHit = 0; uHit < fHits.size(); uHit++) - { - if( 1 == uUseGravityCenter ) - dMeanTot = (fHits[uHit].dTotLeft ) + (fHits[uHit].dTotRight ); // Weighted - else dMeanTot = 1; // Not Weighted - // Along strips axis: Strip Index + 0.5 to sit in the middle of the strip! - dX += (Double_t)(fHits[uHit].iStrip + 0.5)*dMeanTot; - dY += ( (fHits[uHit].dTimeRight) - (fHits[uHit].dTimeLeft) )*dMeanTot; - dMeanTime += ( (fHits[uHit].dTimeRight) + (fHits[uHit].dTimeLeft) )*dMeanTot/2.0; - dTotSum += dMeanTot; - dMeanStrip += (Double_t)(fHits[uHit].iStrip)*dMeanTot; - } // for( UInt_t uHit = 0; uHit < fHits.size(); uHit++) - dX = (dX/dTotSum)*dStripWidth -dMiddleStrip; - dY *= dTimeConv/(1000.0*dTotSum); - dMeanTime /= dTotSum; - dMeanStrip /= dTotSum; - } // if( 1 == uOrientation ) - else - { - dX = 0.0; - dY = 0.0; - dMeanTime = 0; - dMeanStrip= 0; - for( UInt_t uHit = 0; uHit < fHits.size(); uHit++) - { - if( 1 == uUseGravityCenter ) - dMeanTot = (fHits[uHit].dTotLeft ) + (fHits[uHit].dTotRight ); // Weighted - else dMeanTot = 1; // Not Weighted - dX += ( (fHits[uHit].dTimeRight) - (fHits[uHit].dTimeLeft) )*dMeanTot; - // Along strips axis: Strip Index + 0.5 to sit in the middle of the strip! - dY += (Double_t)(fHits[uHit].iStrip + 0.5)*dMeanTot; - dMeanTime += ( (fHits[uHit].dTimeRight) + (fHits[uHit].dTimeLeft) )*dMeanTot/2.0; - dTotSum += dMeanTot; - dMeanStrip += (Double_t)(fHits[uHit].iStrip)*dMeanTot; - } // for( UInt_t uHit = 0; uHit < fHits.size(); uHit++) - dX *= dTimeConv/(1000.0*dTotSum); - dY = (dY/dTotSum)*dStripWidth -dMiddleStrip; - dMeanTime /= dTotSum; - dMeanStrip /= dTotSum; - } // else of if( 1 == uOrientation ) -} - -/* Real Event */ -void Rpc_Event::Clear(Option_t*) -{ - // all members should be cleared. - fClusters.clear(); - fuEventNumber = 0; - fbMultiEdgesPresent = kFALSE; -} diff --git a/beamtime/tof/output/Rpc_Event.h b/beamtime/tof/output/Rpc_Event.h deleted file mode 100644 index 33d9ac3f71d034d22f063735425995bc933bf737..0000000000000000000000000000000000000000 --- a/beamtime/tof/output/Rpc_Event.h +++ /dev/null @@ -1,95 +0,0 @@ -#ifndef RPC_EVENT_H -#define RPC_EVENT_H - -#ifdef WITHGO4ROC - #include "TGo4EventElement.h" -#else - #include "Riostream.h" - #include "TObject.h" - #include <vector> -#endif // WITHGO4ROC - -class Rpc_Hit: public TObject { - public: - Int_t iStrip; - Double_t dTimeLeft; // in ps - Double_t dTotLeft; // in ps - Double_t dTimeRight; // in ps - Double_t dTotRight; // in ps - Bool_t fbMultiEdge; - - Rpc_Hit() : - TObject(), - iStrip(-1), - dTimeLeft(0.0), - dTotLeft(0.0), - dTimeRight(0.0), - dTotRight(0.0), - fbMultiEdge(kFALSE) - { Clear(); }; - - void Clear(Option_t* =""); - - Double_t PositionCalculation( Double_t dTimeConv ); - Bool_t IsMultiEdge() const { return fbMultiEdge; }; - - /* - // copy constructor, used by vector to copy content for sorting - Rpc_Hit(const Rpc_Hit& src) : - iStrip(src.iStrip), - dTimeLeft(src.dTimeLeft), dTotLeft(src.dTotLeft), - dTimeRight(src.dTimeRight), dTotRight(src.dTotRight) {} - */ - - ClassDef(Rpc_Hit, 2) -}; - -class Rpc_Cluster: public TObject { - public: - std::vector<Rpc_Hit> fHits; - Double_t dX; - Double_t dY; - Double_t dMeanTime; - Double_t dMeanStrip; - - Rpc_Cluster() : - TObject(), - fHits(), - dX(0.0), - dY(0.0), - dMeanTime(0.0), - dMeanStrip(0.0) - { Clear(); }; - - void Clear(Option_t* =""); - - void PositionCalculation( Double_t dMiddleStrip, UInt_t uOrientation, - Double_t dStripWidth, Double_t dTimeConv, - UInt_t uUseGravityCenter = 0); - - - ClassDef(Rpc_Cluster, 1) -}; - -class Rpc_Event: public TObject { - public: - - // Maybe to be transformed into a TObjArray or TCloneArray - std::vector<Rpc_Cluster> fClusters; - UInt_t fuEventNumber; - Bool_t fbMultiEdgesPresent; - - Rpc_Event() : - TObject(), - fClusters(), - fuEventNumber(0), - fbMultiEdgesPresent(kFALSE) - { Clear(); }; - ~Rpc_Event(){ Clear(); }; - - void Clear(Option_t* =""); - Bool_t IsMultiEdge() const { return fbMultiEdgesPresent; }; - - ClassDef(Rpc_Event, 2) - }; -#endif //RPC_EVENT_H diff --git a/beamtime/tof/output/Scalers_Event.cxx b/beamtime/tof/output/Scalers_Event.cxx deleted file mode 100644 index 78b3fcd52c5497db56c42d2d03dffb1c77d4c51a..0000000000000000000000000000000000000000 --- a/beamtime/tof/output/Scalers_Event.cxx +++ /dev/null @@ -1,28 +0,0 @@ -/* Generated by Together */ - -#include "Scalers_Event.h" - -void Scalers_Event::Clear(Option_t*) -{ - TObject::Clear(); - // all members should be cleared. - - // Oct 12 - fDTimeSinceFirstEventSecondsTriglog = 0.0; - fDTimeSinceLastEventSecondsTriglog = 0.0; - - // Starting Nov 12 - fDTimeSinceFirstEventSecondsScalOrMu = 0.0; - fDTimeSinceLastEventSecondsScalOrMu = 0.0; - - for( Int_t iScalOrMuIndex = 0; iScalOrMuIndex < SCALORMU_NB_SCAL; iScalOrMuIndex++) - { - fDScalOrMuRate[iScalOrMuIndex] = 0.0; - fDDetectorRate[iScalOrMuIndex] = 0.0; - } - - for( Int_t iTriglogScaler = 0; iTriglogScaler < NUM_SCALERS; iTriglogScaler++) - for( Int_t iTriglogChannel = 0; iTriglogChannel < N_SCALERS_CH; iTriglogChannel++) - fDTriglogRate[iTriglogScaler][iTriglogChannel] = 0.0; -} - diff --git a/beamtime/tof/output/Scalers_Event.h b/beamtime/tof/output/Scalers_Event.h deleted file mode 100644 index 9ff03568ff99ed7d7481f12e6df38bc82b6a96a5..0000000000000000000000000000000000000000 --- a/beamtime/tof/output/Scalers_Event.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef SCALERS_EVENT_H -#define SCALERS_EVENT_H - - -/* - * Put all definitions here and use them in processor, - * since they are necessary for data structure of event - */ - -#include "MbsCrateDefines.h" -#ifdef WITHGO4ROC - #include "TGo4Version.h" - #if __GO4BUILDVERSION__ > 40502 - #include "go4iostream.h" - #endif - #include "TTriglogEvent.h" -#else - #include <vector> - #include "Riostream.h" -#endif // WITHGO4ROC -#include "TObject.h" - -class Scalers_Event : public TObject { - public: - Scalers_Event() : - TObject(), - fDTimeSinceFirstEventSecondsTriglog(0.0), - fDTimeSinceLastEventSecondsTriglog(0.0), - fDTimeSinceFirstEventSecondsScalOrMu(0.0), - fDTimeSinceLastEventSecondsScalOrMu(0.0) - { Clear(); }; - ~Scalers_Event(){ Clear(); }; - - /** Method called by the framework to clear the event element. */ - void Clear(Option_t* =""); - - // Oct 12 - Double_t fDTimeSinceFirstEventSecondsTriglog; - Double_t fDTimeSinceLastEventSecondsTriglog; - - // Starting Nov 12 - Double_t fDTimeSinceFirstEventSecondsScalOrMu; - Double_t fDTimeSinceLastEventSecondsScalOrMu; - - Double_t fDTriglogRate[NUM_SCALERS][N_SCALERS_CH]; - Double_t fDScalOrMuRate[SCALORMU_NB_SCAL]; - - Double_t fDDetectorRate[SCALORMU_NB_SCAL]; - - ClassDef(Scalers_Event,1) -}; -#endif //SCALERS_EVENT_H - - - diff --git a/beamtime/tof/output/TMbsConvTof.cxx b/beamtime/tof/output/TMbsConvTof.cxx deleted file mode 100644 index bc2b904c6bdeed9de2c1505fc036b6b101a91131..0000000000000000000000000000000000000000 --- a/beamtime/tof/output/TMbsConvTof.cxx +++ /dev/null @@ -1,1042 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TMbsConvTof ----- -// ----- Created 11/06/2013 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ -#include "TMbsConvTof.h" - -// General Unpack headers -#include "TMbsUnpackTofPar.h" - -// GO4 unpacker headers -#include "TVftxBoardData.h" -#include "Plastics_Event.h" -#include "Rpc_Event.h" -#include "Scalers_Event.h" - -// ToF specific headers -#include "TMbsConvTofPar.h" -#include "TMbsMappingTofPar.h" -#include "TMbsCalibTofPar.h" - //General -#include "TofDef.h" - // Scalers -#include "TofScalerDef.h" -#include "TTofScalerBoard.h" -#include "TTofTriglogBoard.h" -#include "TTofCalibScaler.h" - // TDCs -#include "TofTdcDef.h" -#include "TofCaenDef.h" -#include "TofVftxDef.h" -#include "TofTrbTdcDef.h" -#include "TofGet4Def.h" -#include "TTofTdcBoard.h" -#include "TTofTdcData.h" -#include "TTofCalibData.h" - // Digis -#include "CbmTofAddress.h" - -// FAIR headers -#include "FairLogger.h" -#include "FairRunAna.h" -#include "FairRuntimeDb.h" -#include "FairRootManager.h" - -// ROOT headers -#include "TClonesArray.h" -#include "TH2.h" -#include "TH1.h" -#include "TROOT.h" -#include "TTimeStamp.h" -#include "TFile.h" - -// C++ headers -#include <algorithm> - -TMbsConvTof::TMbsConvTof() : - FairTask("MbsConvTof"), - fMbsUnpackPar(NULL), - fMbsCalibPar(NULL), - fMbsMappingPar(NULL), - fMbsConvPar(NULL), - fhRpcHitPosition(), - fhRpcTotComp(), - fhPlasticHitPosition(), - fhPlasticTotComp(), - fTriglogBoardCollection(NULL), - fScalerBoardCollection(NULL), - fCaenBoardCollection(NULL), - fVftxBoardCollection(NULL), - fGet4BoardCollection(NULL), - fCalibDataCollection(NULL), - fCalibScalCollection(NULL), - fCbmTofDigiCollection(NULL), - fRateDataCollection(NULL), - sOutputFilename(""), - fOutputFile(NULL), - fOutputTree(NULL), - uTriglogSyncNb(0), - uTriglogPattern(0), - uTriglogInputPattern(0), - uTriglogTimeSec(0), - TriglogTimeMilsec(0), - fvVftxCalibBoards(), - fvScalerEvents(), - fvbMappedDet(), - fviNbChannels(), - fvClassedDigis(), - fvPlasticHits(), - fvRpcHits(), - fvVftxBoards(), - fiNbEvents(0) -{ -} - -TMbsConvTof::TMbsConvTof(const char* name, Int_t /*mode*/, Int_t verbose) : - FairTask(name, verbose), - fMbsUnpackPar(0), - fMbsCalibPar(NULL), - fMbsMappingPar(NULL), - fMbsConvPar(NULL), - fhRpcHitPosition(), - fhRpcTotComp(), - fhPlasticHitPosition(), - fhPlasticTotComp(), - fTriglogBoardCollection(NULL), - fScalerBoardCollection(NULL), - fCaenBoardCollection(NULL), - fVftxBoardCollection(NULL), - fGet4BoardCollection(NULL), - fCalibDataCollection(NULL), - fCalibScalCollection(NULL), - fCbmTofDigiCollection(NULL), - fRateDataCollection(NULL), - sOutputFilename(""), - fOutputFile(NULL), - fOutputTree(NULL), - uTriglogSyncNb(0), - uTriglogPattern(0), - uTriglogInputPattern(0), - uTriglogTimeSec(0), - TriglogTimeMilsec(0), - fvVftxCalibBoards(), - fvScalerEvents(), - fvbMappedDet(), - fviNbChannels(), - fvClassedDigis(), - fvPlasticHits(), - fvRpcHits(), - fvVftxBoards(), - fiNbEvents(0) -{ -} - -TMbsConvTof::~TMbsConvTof() -{ - DeleteHistograms(); - LOG(info)<<"**** TMbsConvTof: Delete instance "; -} - -// -------------------------------------------------- -// Fairtask specific functions -void TMbsConvTof::SetParContainers() -{ - InitParameters(); -} - -InitStatus TMbsConvTof::ReInit() -{ - LOG(info)<<"**** TMbsConvTof: Reinitialize the conversion parameters for tof "; - if( kFALSE == InitParameters() ) - return kFATAL; - fMbsConvPar->printParams(); - - return kSUCCESS; -} - -InitStatus TMbsConvTof::Init() -{ - if( kFALSE == InitParameters() ) - return kFATAL; - fMbsConvPar->printParams(); - if( kFALSE == CreateHistogramms() ) - return kFATAL; - - if( kFALSE == RegisterInput() ) - return kFATAL; - - if( kFALSE == InitTempDigiStorage() ) - return kFATAL; - - // Create the proper output objects for each detector - if( kFALSE == RegisterOutput() ) - return kFATAL; - - fiNbEvents = 0; - - return kSUCCESS; -} -void TMbsConvTof::Exec(Option_t* /*option*/) -{ - ClearOutput(); - ClearTriglogData(); - ClearVftxBoards(); - ClearScalerEvent(); - ClearTempDigiStorage(); - - // Event rejection - // E.g.: pulser event used to Empty the VFTX buffers - if( 1 == fMbsUnpackPar->OnlyOneTriglog() && - -1 < fMbsUnpackPar->GetTriggerToReject() ) - { -// if( NULL == fTriglogBoardCollection ) -// return kFALSE; - - TTofTriglogBoard * xTriglogBoard = (TTofTriglogBoard*) fTriglogBoardCollection->At(0); // Always only 1 TRIGLOG board! - -// if( NULL == xTriglogBoard ) -// return kFALSE; -// if( 1 == ( 0x1 & ( (xTriglogBoard->GetTriggPatt()) >> (fMbsUnpackPar->GetTriggerToReject()) ) ) ) - // Reject selected trigger only when alone (accept when both not rejected trigger and rejected trigger are present) - if( (xTriglogBoard->GetTriggPatt()) == ( 1ul << (fMbsUnpackPar->GetTriggerToReject()) ) ) - // Jump this event ! - return; - } // if trigger rejection enabled and trigger board enabled - - FillTriglogData(); - FillVftxBoards(); - - FillCalibScaler(); - FillMappedScaler(); - - FillTempDigiStorage(); - BuildFiredChannels(); - - FillOutput(); - - FillHistograms(); - fiNbEvents++; -} -void TMbsConvTof::Finish() -{ - WriteHistogramms(); - - DeleteTempDigiStorage(); - - DeleteOutput(); -} - -// ------------------------------------------------------------------ -Bool_t TMbsConvTof::InitParameters() -{ - // Get Base Container - FairRun* ana = FairRun::Instance(); - FairRuntimeDb* rtdb=ana->GetRuntimeDb(); - - // Unpack parameter - fMbsUnpackPar = (TMbsUnpackTofPar*) (rtdb->getContainer("TMbsUnpackTofPar")); - if( 0 == fMbsUnpackPar ) - { - LOG(error)<<"TMbsConvTof::InitParameters => Could not obtain the TMbsUnpackTofPar "; - return kFALSE; - } - - // Calibration parameter - fMbsCalibPar = (TMbsCalibTofPar*) (rtdb->getContainer("TMbsCalibTofPar")); - if( 0 == fMbsCalibPar ) - { - LOG(error)<<"TMbsConvTof::InitParameters => Could not obtain the TMbsCalibTofPar "; - return kFALSE; - } - - // Calibration parameter - fMbsMappingPar = (TMbsMappingTofPar*) (rtdb->getContainer("TMbsMappingTofPar")); - if( 0 == fMbsMappingPar ) - { - LOG(error)<<"TMbsConvTof::InitParameters => Could not obtain the TMbsMappingTofPar "; - return kFALSE; - } - - // Conversion parameter - fMbsConvPar = (TMbsConvTofPar*) (rtdb->getContainer("TMbsConvTofPar")); - if( 0 == fMbsConvPar ) - { - LOG(error)<<"TMbsConvTof::InitParameters => Could not obtain the TMbsConvTofPar "; - return kFALSE; - } - - // PAL: Added to recover loading of parameters before initialization -// rtdb->initContainers( ana->GetRunId() ); - - return kTRUE; -} -// ------------------------------------------------------------------ -Bool_t TMbsConvTof::CreateHistogramms() -{ - TDirectory * oldir = gDirectory; // <= To prevent histos from being sucked in by the param file of the TRootManager! - gROOT->cd(); // <= To prevent histos from being sucked in by the param file of the TRootManager ! - - if( 0 < fMbsConvPar->GetNbRpc() ) - { - fhRpcHitPosition.resize( fMbsConvPar->GetNbRpc() ); - fhRpcTotComp.resize( fMbsConvPar->GetNbRpc() ); - for( Int_t iRpcIndx = 0; iRpcIndx < fMbsConvPar->GetNbRpc(); iRpcIndx++ ) - { - switch( fMbsConvPar->GetRpcChType( iRpcIndx ) ) - { - case 1: // PADs - { - Int_t iUniqueId = fMbsConvPar->GetRpcUid( iRpcIndx ); - Int_t iSmType = CbmTofAddress::GetSmType( iUniqueId ); - Int_t iSmId = CbmTofAddress::GetSmId( iUniqueId ); - Int_t iRpcId = CbmTofAddress::GetRpcId( iUniqueId ); - fhRpcHitPosition[iRpcIndx] = new TH2I( - Form("tof_ty%01d_sm%03d_rpc%03d_hits_map", iSmType, iSmId, iRpcId ), - Form("Hit distribution on Rpc #%03d in Sm %03d of type %d; Column []; Row []", - iRpcId, iSmId, iSmType ), - fMbsMappingPar->GetSmTypeNbCh(iSmType), 0, fMbsMappingPar->GetSmTypeNbCh(iSmType), - 2, 0, 2 ); - break; - } - case 2: // STRIPs - { - Int_t iUniqueId = fMbsConvPar->GetRpcUid( iRpcIndx ); - Int_t iSmType = CbmTofAddress::GetSmType( iUniqueId ); - Int_t iSmId = CbmTofAddress::GetSmId( iUniqueId ); - Int_t iRpcId = CbmTofAddress::GetRpcId( iUniqueId ); - fhRpcHitPosition[iRpcIndx] = new TH2I( - Form("tof_ty%01d_sm%03d_rpc%03d_hits_map", iSmType, iSmId, iRpcId ), - Form("Hit distribution on Rpc #%03d in Sm %03d of type %d; Channel []; Time difference [ps]", - iRpcId, iSmId, iSmType ), - fMbsMappingPar->GetSmTypeNbCh(iSmType), 0, fMbsMappingPar->GetSmTypeNbCh(iSmType), - 2000, -10000, 10000 ); - fhRpcTotComp[iRpcIndx] = new TH2I( - Form("tof_ty%01d_sm%03d_rpc%03d_tot_comp", iSmType, iSmId, iRpcId ), - Form("Comparison of TOT on each channel end on Rpc #%03d in Sm %03d of type %d; Tot left side []; Tot right side [ps]", - iRpcId, iSmId, iSmType ), - 550, -5000.0, 50000.0, - 550, -5000.0, 50000.0 ); - break; - } - default: - break; - } // switch( fMbsConvPar->GetRpcChType(iRpcIndx) ) - } // for( Int_t iRpcIndx = 0; iRpcIndx < fMbsConvPar->GetNbRpc(); iRpcIndx++ ) - } // if( 0 < fMbsConvPar->GetNbRpc() ) - if( 0 < fMbsConvPar->GetNbPlastic() ) - { - fhPlasticHitPosition.resize( fMbsConvPar->GetNbPlastic() ); - fhPlasticTotComp.resize( fMbsConvPar->GetNbPlastic() ); - for( Int_t iPlastIndx = 0; iPlastIndx < fMbsConvPar->GetNbPlastic(); iPlastIndx++ ) - { - switch( fMbsConvPar->GetPlasticEndNb( iPlastIndx ) ) - { - case 2: // Both ends - { - Int_t iUniqueId = fMbsConvPar->GetPlasticUid( iPlastIndx ); - Int_t iSmType = CbmTofAddress::GetSmType( iUniqueId ); - Int_t iSmId = CbmTofAddress::GetSmId( iUniqueId ); - Int_t iPlaId = CbmTofAddress::GetRpcId( iUniqueId ); - fhPlasticHitPosition[iPlastIndx] = new TH1I( - Form("tof_ty%01d_sm%03d_pla%03d_hits_map", iSmType, iSmId, iPlaId ), - Form("Hit distribution on Plastic #%03d in Sm %03d of type %d; Time difference [ps]", - iPlaId, iSmId, iSmType ), - 2000, -10000, 10000 ); - fhPlasticTotComp[iPlastIndx] = new TH2I( - Form("tof_ty%01d_sm%03d_pla%03d_tot_comp", iSmType, iSmId, iPlaId ), - Form("Comparison of TOT on each channel end on Plastic #%03d in Sm %03d of type %d; Tot left side []; Tot right side [ps]", - iPlaId, iSmId, iSmType ), - 550, -5000.0, 50000.0, - 550, -5000.0, 50000.0 ); - break; - } - case 1: // Single ended - default: - break; - } // switch( fMbsConvPar->GetPlasticEndNb(iPlastIndx) ) - } // for( Int_t iPlastIndx = 0; iPlastIndx < fMbsConvPar->GetNbPlastic(); iPlastIndx++ ) - } // if( 0 < fMbsConvPar->GetNbPlastic() ) - - gDirectory->cd( oldir->GetPath() ); // <= To prevent histos from being sucked in by the param file of the TRootManager! - - return kTRUE; -} -Bool_t TMbsConvTof::FillHistograms() -{ - if( 0 != FairRunAna::Instance() ) - { - // Get Base Container <- Needed because currently RunOnLmd runs 1 more time after setting end of file flag!!!!! - // Should not be a problem when using the FAIRROOT way of reading MBS event instead of the custom "Go4 like" way - FairRunAna* ana = FairRunAna::Instance(); // <- Needed because currently RunOnLmd runs 1 more time after setting end of file flag!!!!!! - // Needed because currently RunOnLmd runs 1 more time after setting end of file flag!!!!!! - if( kTRUE == ana->GetLMDProcessingStatus() ) - return kFALSE; - } // if( 0 != FairRunAna::Instance() ) - - for( Int_t iRpcIndx = 0; iRpcIndx < fMbsConvPar->GetNbRpc(); iRpcIndx++ ) - { - switch( fMbsConvPar->GetRpcChType( iRpcIndx ) ) - { - case 1: // PADs - { - Int_t iUniqueId = fMbsConvPar->GetRpcUid( iRpcIndx ); - Int_t iSmType = CbmTofAddress::GetSmType( iUniqueId ); - for( UInt_t uHitInd = 0; uHitInd < fvRpcHits[iRpcIndx].size(); uHitInd ++) - fhRpcHitPosition[iRpcIndx]->Fill( fvRpcHits[iRpcIndx][uHitInd].iStrip % fMbsMappingPar->GetSmTypeNbCh(iSmType), // Column - fvRpcHits[iRpcIndx][uHitInd].iStrip / fMbsMappingPar->GetSmTypeNbCh(iSmType) );// Row - break; - } - case 2: // STRIPs - { - for( UInt_t uHitInd = 0; uHitInd < fvRpcHits[iRpcIndx].size(); uHitInd ++) - { - fhRpcHitPosition[iRpcIndx]->Fill( fvRpcHits[iRpcIndx][uHitInd].iStrip, - fvRpcHits[iRpcIndx][uHitInd].dTimeRight - - fvRpcHits[iRpcIndx][uHitInd].dTimeLeft ); - fhRpcTotComp[iRpcIndx]->Fill( fvRpcHits[iRpcIndx][uHitInd].dTotLeft, - fvRpcHits[iRpcIndx][uHitInd].dTotRight ); - } // for( UInt_t uHitInd = 0; uHitInd < fvRpcHits[iRpcIndx].size(); uHitInd ++) - break; - } - default: - break; - } // switch( fMbsConvPar->GetRpcChType( iRpcIndx ) ) - } // for( Int_t iRpcIndx = 0; iRpcIndx < fMbsConvPar->GetNbRpc(); iRpcIndx++ ) - for( Int_t iPlastIndx = 0; iPlastIndx < fMbsConvPar->GetNbPlastic(); iPlastIndx++ ) - { - switch( fMbsConvPar->GetPlasticEndNb( iPlastIndx ) ) - { - case 2: // Both ends - { - for( UInt_t uHitInd = 0; uHitInd < fvPlasticHits[iPlastIndx].size(); uHitInd ++) - { - fhPlasticHitPosition[iPlastIndx]->Fill( fvPlasticHits[iPlastIndx][uHitInd].dTimeRight - - fvPlasticHits[iPlastIndx][uHitInd].dTimeLeft ); - fhPlasticTotComp[iPlastIndx]->Fill( fvPlasticHits[iPlastIndx][uHitInd].dTotLeft, - fvPlasticHits[iPlastIndx][uHitInd].dTotRight ); - } // for( UInt_t uHitInd = 0; uHitInd < fvPlasticHits[iPlastIndx].size(); uHitInd ++) - break; - } - case 1: // Single ended - default: - break; - } // switch( fMbsConvPar->GetRpcChType( iRpcIndx ) ) - } // for( Int_t iPlastIndx = 0; iPlastIndx < fMbsConvPar->GetNbPlastic(); iPlastIndx++ ) - return kTRUE; -} -void TMbsConvTof::WriteHistogramms() -{ - TDirectory * oldir = gDirectory; - TFile *fHist = new TFile("./tofMbsConv.hst.root","RECREATE"); - - if( 0 < fMbsConvPar->GetNbRpc() ) - { - // create a subdirectory for each histogram type in this file - TDirectory *cdConvRpc = fHist->mkdir( "Rpc" ); - cdConvRpc->cd(); - for( Int_t iRpcIndx = 0; iRpcIndx < fMbsConvPar->GetNbRpc(); iRpcIndx++ ) - { - fhRpcHitPosition[iRpcIndx]->Write(); - if( 2 == fMbsConvPar->GetRpcChType( iRpcIndx ) ) - fhRpcTotComp[iRpcIndx]->Write(); - } // for( Int_t iRpcIndx = 0; iRpcIndx < fMbsConvPar->GetNbRpc(); iRpcIndx++ ) - } // if( 0 < fMbsConvPar->GetNbRpc() ) - - if( 0 < fMbsConvPar->GetNbPlastic() ) - { - // create a subdirectory for each histogram type in this file - TDirectory *cdConvPla = fHist->mkdir( "Plastics" ); - cdConvPla->cd(); - for( Int_t iPlastIndx = 0; iPlastIndx < fMbsConvPar->GetNbPlastic(); iPlastIndx++ ) - { - if( 2 == fMbsConvPar->GetPlasticEndNb( iPlastIndx ) ) - { - fhPlasticHitPosition[iPlastIndx]->Write(); - fhPlasticTotComp[iPlastIndx]->Write(); - } - } // for( Int_t iPlastIndx = 0; iPlastIndx < fMbsConvPar->GetNbPlastic(); iPlastIndx++ ) - } // if( 0 < fMbsConvPar->GetNbPlastic() ) - - gDirectory->cd( oldir->GetPath() ); - - fHist->Close(); -} -void TMbsConvTof::DeleteHistograms() -{ -} -// ------------------------------------------------------------------ -Bool_t TMbsConvTof::RegisterInput() -{ - FairRootManager* rootMgr = FairRootManager::Instance(); - - // Obtain Triglog board object - if( 1 == fMbsUnpackPar->GetNbActiveBoards( tofMbs::triglog ) && - ( kTRUE == fMbsConvPar->TriglogEnabled() || -1 < fMbsUnpackPar->GetTriggerToReject() ) ) - { - fTriglogBoardCollection = (TClonesArray*) rootMgr->GetObject("TofTriglog"); - if( NULL == fTriglogBoardCollection) - { - LOG(error)<<"TMbsConvTof::RegisterInput => Could not get the TofTriglog TClonesArray!!!"; - return kFALSE; - } // if( NULL == fTriglogBoardCollection) - } // if( 1 == fMbsUnpackPar->GetNbActiveBoards( toftdc::triglog ) && kTRUE == fMbsConvPar->TriglogEnabled() ) - - // Obtain VFTX boards and calibrated TDC objects - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::vftx ) && 0 < fMbsConvPar->GetNbOutVftx() ) - { - fVftxBoardCollection = (TClonesArray*) rootMgr->GetObject("TofVftxTdc"); - if( NULL == fVftxBoardCollection) - { - LOG(error)<<"TMbsConvTof::RegisterInput => Could not get the TofVftxTdc TClonesArray!!!"; - return kFALSE; - } // if( NULL == fVftxBoardCollection) - fCalibDataCollection = (TClonesArray*) rootMgr->GetObject("TofCalibData"); - if( NULL == fCalibDataCollection) - { - LOG(error)<<"TMbsConvTof::RegisterInput => Could not get the TofCalibData TClonesArray!!!"; - return kFALSE; - } // if( NULL == fCalibDataCollection) - } // if( 0 < fMbsUnpackPar->GetNbActiveBoards() ) - - // Obtain Calibrated scalers objects - if( 0 < fMbsUnpackPar->GetNbActiveScalersB() && 0 < fMbsConvPar->GetNbOutScal() ) - { - fCalibScalCollection = (TClonesArray*) rootMgr->GetObject("TofCalibScaler"); - if( NULL == fCalibScalCollection) - { - LOG(error)<<"TMbsConvTof::RegisterInput => Could not get the TofCalibScaler TClonesArray!!!"; - return kFALSE; - } // if( NULL == fCalibScalCollection) - } // if( 0 < fMbsUnpackPar->GetNbActiveScalersB() && 0 < fMbsConvPar->GetNbOutScal() ) - - // Obtain Digi collection object - if( 0 < fMbsConvPar->GetNbRpc() || 0 < fMbsConvPar->GetNbPlastic() ) - { - fCbmTofDigiCollection = (TClonesArray*) rootMgr->GetObject("CbmTofDigi"); - if( NULL == fCbmTofDigiCollection) - { - LOG(error)<<"TMbsConvTof::RegisterInput => Could not get the CbmTofDigi TClonesArray!!!"; - return kFALSE; - } // if( NULL == fCbmTofDigiCollection) - } - - return kTRUE; -} -Bool_t TMbsConvTof::RegisterOutput() -{ - TDirectory* oldDir; - - oldDir = gDirectory; - - sOutputFilename = fMbsConvPar->GetOutFilename(); - fOutputFile = new TFile(sOutputFilename, "RECREATE", "TTree file in format similar to GO4 unpacker", 9); - sOutputFilename += ":/"; - if( fOutputFile->IsZombie() ) - { - LOG(error)<<"TMbsConvTof::RegisterOutput => Error opening file for TTree output!!!"; - return kFALSE; - } // if (fOutputFile->IsZombie()) - - gDirectory->Cd(sOutputFilename); - - fOutputTree = new TTree("GsiNov12", "GSI November 2012 data format"); - LOG(info)<<"TMbsConvTof::RegisterOutput => Output Tree created in "<<gDirectory->GetPath(); - - // TODO: Triglog, scalers - // TRIGLOG - if( 1 == fMbsUnpackPar->GetNbActiveBoards( tofMbs::triglog ) && kTRUE == fMbsConvPar->TriglogEnabled() ) - { - fOutputTree->Branch("TriglogSyncNb", &uTriglogSyncNb, "TriglogSyncNb/i" ); - fOutputTree->Branch("TriglogPattern", &uTriglogPattern, "TriglogPattern/i" ); - fOutputTree->Branch("TriglogInputPattern", &uTriglogInputPattern, "TriglogInputPattern/i" ); - fOutputTree->Branch("TriglogTimeSec", &uTriglogTimeSec, "TriglogTimeSec/i" ); - fOutputTree->Branch("TriglogTimeMilsec", &TriglogTimeMilsec, "TriglogTimeMilsec/i" ); - } // if( kTRUE == fMbsConvPar->TriglogEnabled() ) - - // VFTX - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::vftx ) && 0 < fMbsConvPar->GetNbOutVftx() ) - { - Int_t iNbVftx = fMbsUnpackPar->GetNbActiveBoards( toftdc::vftx ); - fvVftxCalibBoards.resize( iNbVftx ); - - for( Int_t iVftxIndex = 0; iVftxIndex < fMbsConvPar->GetNbOutVftx(); iVftxIndex ++) - if( fMbsConvPar->GetVftxInd( iVftxIndex ) < iNbVftx ) - { - fOutputTree->Branch( Form("Vftx%02dData.", iVftxIndex), "TVftxBoardData", - &(fvVftxCalibBoards[ fMbsConvPar->GetVftxInd( iVftxIndex ) ]) ); - } - } - - // SCALERS - if( 0 < fMbsUnpackPar->GetNbActiveScalersB() && 0 < fMbsConvPar->GetNbOutScal() ) - { - fvScalerEvents.resize( fMbsConvPar->GetNbOutScal() ); - - for( Int_t iScalEvtIdx = 0; iScalEvtIdx < fMbsConvPar->GetNbOutScal(); iScalEvtIdx ++) - { -/* Scalers_Event * test = &(fvScalerEvents[iScalEvtIdx]);*/ - fOutputTree->Branch( Form("CalScal%02d.", iScalEvtIdx), "Scalers_Event", - &( fvScalerEvents[iScalEvtIdx] ) ); - } - } // if( 0 < fMbsUnpackPar->GetNbActiveScalersB() && 0 < fMbsConvPar->GetNbOutScal() ) - - // RPC, PLASTICS - if( 0 < fMbsConvPar->GetNbDetectors() ) - { - if( 0 < fMbsConvPar->GetNbPlastic() ) - fvPlasticHits.resize( fMbsConvPar->GetNbPlastic() ); - if( 0 < fMbsConvPar->GetNbRpc() ) - fvRpcHits.resize( fMbsConvPar->GetNbRpc() ); - - for( Int_t iRpcIndex = 0; iRpcIndex < fMbsConvPar->GetNbRpc(); iRpcIndex ++) - fOutputTree->Branch( Form("Rpc%02dHits", iRpcIndex), &( fvRpcHits[iRpcIndex] ) ); - - for( Int_t iPlasticIndex = 0; iPlasticIndex < fMbsConvPar->GetNbPlastic(); iPlasticIndex ++) - fOutputTree->Branch( Form("Plastics%02dHits", iPlasticIndex), &( fvPlasticHits[iPlasticIndex] ) ); - } // if( 0 < fMbsConvPar->GetNbDetectors() ) - - fOutputTree->SetDirectory(gDirectory); - - gDirectory->cd( oldDir->GetPath() ); - - return kTRUE; -} -Bool_t TMbsConvTof::FillOutput() -{ - fOutputTree->Fill(); - return kTRUE; -} -Bool_t TMbsConvTof::ClearOutput() -{ - // Clear the output vectors - if( 0 < fMbsConvPar->GetNbDetectors() ) - { - for( Int_t iRpcIndx = 0; iRpcIndx < fMbsConvPar->GetNbRpc(); iRpcIndx++ ) - fvRpcHits[iRpcIndx].clear(); - for( Int_t iPlastIndx = 0; iPlastIndx < fMbsConvPar->GetNbPlastic(); iPlastIndx++ ) - fvPlasticHits[iPlastIndx].clear(); - } // if( 0 < fMbsConvPar->GetNbDetectors() ) - - return kTRUE; -} -Bool_t TMbsConvTof::DeleteOutput() -{ - TDirectory* oldDir; - oldDir = gDirectory; - gDirectory->Cd(sOutputFilename); - fOutputTree->SetDirectory(gDirectory); - - fOutputFile->Write("",TObject::kOverwrite); - - gDirectory->cd( oldDir->GetPath() ); - fOutputTree->SetDirectory(gDirectory); - fOutputFile->Close(); - delete fOutputTree; - - if( 0 < fMbsUnpackPar->GetNbActiveBoards( toftdc::vftx ) && 0 < fMbsConvPar->GetNbOutVftx() ) - fvVftxCalibBoards.clear(); - - if( 0 < fMbsUnpackPar->GetNbActiveScalersB() && 0 < fMbsConvPar->GetNbOutScal() ) - fvScalerEvents.clear(); - - // Clear the output vectors - if( 0 < fMbsConvPar->GetNbDetectors() ) - { - for( Int_t iRpcIndx = 0; iRpcIndx < fMbsConvPar->GetNbRpc(); iRpcIndx++ ) - fvRpcHits[iRpcIndx].clear(); - fvRpcHits.clear(); - - for( Int_t iPlastIndx = 0; iPlastIndx < fMbsConvPar->GetNbPlastic(); iPlastIndx++ ) - fvPlasticHits[iPlastIndx].clear(); - fvPlasticHits.clear(); - } // if( 0 < fMbsConvPar->GetNbDetectors() ) - - return kTRUE; -} -// ------------------------------------------------------------------ -// Just filling temporary holders for TRIGlOG data -Bool_t TMbsConvTof::FillTriglogData() -{ - if( 1 == fMbsUnpackPar->GetNbActiveBoards( tofMbs::triglog ) && kTRUE == fMbsConvPar->TriglogEnabled() ) - { - if( NULL == fTriglogBoardCollection ) - return kFALSE; - - TTofTriglogBoard * xTriglogBoard = (TTofTriglogBoard*) fTriglogBoardCollection->At(0); // Always only 1 TRIGLOG board! - - if( NULL == xTriglogBoard ) - return kFALSE; - - uTriglogSyncNb = xTriglogBoard->GetSyncNb(); - uTriglogPattern = xTriglogBoard->GetTriggPatt(); - uTriglogInputPattern = xTriglogBoard->GetInpPatt(); - uTriglogTimeSec = xTriglogBoard->GetMbsTimeSec(); - TriglogTimeMilsec = xTriglogBoard->GetMbsTimeMilliSec(); - } // if( 1 == fMbsUnpackPar->GetNbActiveBoards( toftdc::triglog ) && kTRUE == fMbsConvPar->TriglogEnabled() ) - - return kTRUE; -} -Bool_t TMbsConvTof::ClearTriglogData() -{ - uTriglogSyncNb = 0; - uTriglogPattern = 0; - uTriglogInputPattern = 0; - uTriglogTimeSec = 0; - TriglogTimeMilsec = 0; - - return kTRUE; -} -// ------------------------------------------------------------------ -// VFTX calibrated TDC boards conversion -Bool_t TMbsConvTof::FillVftxBoards() -{ - if( 0 != FairRunAna::Instance() ) - { - // Get Base Container <- Needed because currently RunOnLmd runs 1 more time after setting end of file flag!!!!! - // Should not be a problem when using the FAIRROOT way of reading MBS event instead of the custom "Go4 like" way - FairRunAna* ana = FairRunAna::Instance(); // <- Needed because currently RunOnLmd runs 1 more time after setting end of file flag!!!!!! - // Needed because currently RunOnLmd runs 1 more time after setting end of file flag!!!!!! - if( kTRUE == ana->GetLMDProcessingStatus() ) - return kFALSE; - } // if( 0 != FairRunAna::Instance() ) - - // Board data - for( Int_t iVftxIndex = 0; iVftxIndex < fMbsConvPar->GetNbOutVftx(); iVftxIndex ++) - if( static_cast<UInt_t>(fMbsConvPar->GetVftxInd( iVftxIndex )) < fMbsUnpackPar->GetNbActiveBoards( toftdc::vftx ) ) - { - Int_t iInputVftxInd = fMbsConvPar->GetVftxInd( iVftxIndex ); - TTofTdcBoard * vftxPtr = ( TTofTdcBoard * )fVftxBoardCollection->At( iInputVftxInd ); - fvVftxCalibBoards[ iInputVftxInd ].iTriggerTime = vftxPtr->GetTriggerTime(); - } // if( fMbsConvPar->GetVftxInd( iVftxIndex ) < fMbsUnpackPar->GetNbActiveBoards( toftdc::vftx ) ) - - // Channels data - for( Int_t iCalibDatInd = 0; iCalibDatInd < fCalibDataCollection->GetEntriesFast(); iCalibDatInd++ ) - { - TTofCalibData * calibPtr = ( TTofCalibData * )fCalibDataCollection->At( iCalibDatInd ); - UInt_t uBoard = calibPtr->GetBoard(); - if( toftdc::vftx == calibPtr->GetType() && -1 < fMbsConvPar->GetVftxOutInd( uBoard ) ) - { - UInt_t uCh = calibPtr->GetChannel(); - switch( calibPtr->GetEdge() ) - { - case 0: // 0 = Rising - if( fvVftxCalibBoards[uBoard].iMultiplicity[uCh] < TVftxBoardData::MaxMult ) - { - fvVftxCalibBoards[uBoard].iMultiplicity[uCh] ++; - fvVftxCalibBoards[uBoard].dTimeCorr[uCh] - [ fvVftxCalibBoards[uBoard].iMultiplicity[uCh] ] = - calibPtr->GetTime(); - } // if( fvVftxCalibBoards[uBoard].iMultiplicity[uCh] < TVftxBoardData::MaxMult ) - break; - case 1: // 1 = Falling - if( fvVftxCalibBoards[uBoard].iMultiplicity[uCh] < TVftxBoardData::MaxMult ) - { - fvVftxCalibBoards[uBoard].iMultiplicity[uCh] ++; - fvVftxCalibBoards[uBoard].dTimeCorr[uCh] - [ fvVftxCalibBoards[uBoard].iMultiplicity[uCh] ] = - calibPtr->GetTime(); - } // if( fvVftxCalibBoards[uBoard].iMultiplicity[uCh] < TVftxBoardData::MaxMult ) - break; - case 2: // 2 = Full - if( fvVftxCalibBoards[uBoard].iMultiplicity[2*uCh] < TVftxBoardData::MaxMult && - fvVftxCalibBoards[uBoard].iMultiplicity[2*uCh + 1] < TVftxBoardData::MaxMult ) - { - fvVftxCalibBoards[uBoard].iMultiplicity[2*uCh] ++; - fvVftxCalibBoards[uBoard].iMultiplicity[2*uCh + 1] ++; - fvVftxCalibBoards[uBoard].dTimeCorr[2*uCh] - [ fvVftxCalibBoards[uBoard].iMultiplicity[2*uCh] ] = - calibPtr->GetTime() + calibPtr->GetTot(); - fvVftxCalibBoards[uBoard].dTimeCorr[2*uCh + 1] - [ fvVftxCalibBoards[uBoard].iMultiplicity[2*uCh + 1] ] = - calibPtr->GetTime(); - } // if( both edges multiplicity < TVftxBoardData::MaxMult ) - break; - default: - break; - } // switch( calibPtr->GetEdge() ) - } // if( toftdc::vftx == calibPtr->GetType() ) - } // for( Int_t iCalibDatInd = 0; iCalibDatInd < fCalibDataCollection->GetEntriesFast(); iCalibDatInd++ ) - return kTRUE; -} -Bool_t TMbsConvTof::ClearVftxBoards() -{ - for( Int_t iVftxIndex = 0; iVftxIndex < fMbsConvPar->GetNbOutVftx(); iVftxIndex ++) - if( static_cast<UInt_t>(fMbsConvPar->GetVftxInd( iVftxIndex )) < fMbsUnpackPar->GetNbActiveBoards( toftdc::vftx ) ) - { - fvVftxCalibBoards[ fMbsConvPar->GetVftxInd( iVftxIndex ) ].Clear(); - } // if( fMbsConvPar->GetVftxInd( iVftxIndex ) < fMbsUnpackPar->GetNbActiveBoards( toftdc::vftx ) ) - - return kFALSE; -} -// ------------------------------------------------------------------ -// Fired Channel building & Conversion -Bool_t TMbsConvTof::FillCalibScaler() -{ - UInt_t uNbScalBd = fMbsUnpackPar->GetNbActiveScalersB(); - - for( Int_t iScalBdIndx = 0; iScalBdIndx < fMbsConvPar->GetNbOutScal(); iScalBdIndx++ ) - if( -1 < fMbsConvPar->GetScalerInd( iScalBdIndx ) && - static_cast<UInt_t>(fMbsConvPar->GetScalerInd( iScalBdIndx ))< uNbScalBd ) - { - if( NULL == fCalibScalCollection ) - return kFALSE; - - TTofCalibScaler * xCalibScaler = (TTofCalibScaler*) fCalibScalCollection->At(fMbsConvPar->GetScalerInd( iScalBdIndx ) ); - - if( NULL == xCalibScaler ) - return kFALSE; - - switch( xCalibScaler->GetScalerType() ) - { - case tofscaler::triglog: - { - // Filling event times from internal reference clock - fvScalerEvents[iScalBdIndx].fDTimeSinceFirstEventSecondsTriglog = xCalibScaler->GetTimeToFirst(); - fvScalerEvents[iScalBdIndx].fDTimeSinceLastEventSecondsTriglog = xCalibScaler->GetTimeToLast(); - - // Filling scaler rates since last event - for( UInt_t uScalIndx = 0; uScalIndx < xCalibScaler->GetScalerNumber(); uScalIndx++) - for( UInt_t uCh = 0; uCh < xCalibScaler->GetChannelNumber(); uCh++) - fvScalerEvents[iScalBdIndx].fDTriglogRate[uScalIndx][uCh] = xCalibScaler->GetScalerValue( uCh, uScalIndx); - break; - } - case tofscaler::scalormu: - { - // Filling event times from internal reference clock - fvScalerEvents[iScalBdIndx].fDTimeSinceFirstEventSecondsScalOrMu = xCalibScaler->GetTimeToFirst(); - fvScalerEvents[iScalBdIndx].fDTimeSinceLastEventSecondsScalOrMu = xCalibScaler->GetTimeToLast(); - - // Filling scaler rates since last event - for( UInt_t uCh = 0; uCh < xCalibScaler->GetChannelNumber(); uCh++) - fvScalerEvents[iScalBdIndx].fDScalOrMuRate[uCh] = xCalibScaler->GetScalerValue( uCh ); - break; - } - case tofscaler::scalormubig: - { - // Filling event times from internal reference clock - fvScalerEvents[iScalBdIndx].fDTimeSinceFirstEventSecondsScalOrMu = xCalibScaler->GetTimeToFirst(); - fvScalerEvents[iScalBdIndx].fDTimeSinceLastEventSecondsScalOrMu = xCalibScaler->GetTimeToLast(); - - // Filling scaler rates since last event - for( UInt_t uCh = 0; uCh < xCalibScaler->GetChannelNumber(); uCh++) - fvScalerEvents[iScalBdIndx].fDScalOrMuRate[uCh] = xCalibScaler->GetScalerValue( uCh ); - break; - } - case tofscaler::undef: - default: - break; - } // switch( xCalibScaler->GetScalerType() ) - } // if( fMbsConvPar->GetScalerInd( iScalBdIndx ) < uNbScalBd ) - - return kTRUE; -} -Bool_t TMbsConvTof::FillMappedScaler() -{ - // TODO: if mapped scaler rate to detector rate available - // fvScalerEvents[uScalBdIndx].fDDetectorRate - return kTRUE; -} -Bool_t TMbsConvTof::ClearScalerEvent() -{ - // Clear all Scalers_Event objects - for( UInt_t uScalerEvt = 0; uScalerEvt < fvScalerEvents.size(); uScalerEvt++) - fvScalerEvents[uScalerEvt].Clear(); - - return kTRUE; -} -// ------------------------------------------------------------------ -// Fired Channel building & Conversion -Bool_t TMbsConvTof::InitTempDigiStorage() -{ - if( 0 < fMbsConvPar->GetNbDetectors() ) - { - fvbMappedDet.resize( fMbsConvPar->GetNbDetectors() ); - fviNbChannels.resize( fMbsConvPar->GetNbDetectors() ); - if( kTRUE == fMbsMappingPar->UseDigiExp() ) - { - fvClassedDigis = new std::vector< CbmTofDigi > *[ fMbsConvPar->GetNbDetectors() ]; - for( Int_t iDetInd = 0; iDetInd < fMbsConvPar->GetNbDetectors(); iDetInd ++ ) - { - Int_t iUniqueId = fMbsConvPar->GetDetectorUid( iDetInd ); - if( -1 < fMbsMappingPar->GetMappedDetInd( iUniqueId ) ) - { - fvbMappedDet[iDetInd] = kTRUE; - Int_t iSmType = CbmTofAddress::GetSmType( iUniqueId ); - fviNbChannels[iDetInd] = fMbsMappingPar->GetSmTypeNbCh(iSmType); - fvClassedDigis[iDetInd] = new std::vector< CbmTofDigi >[ - fMbsConvPar->GetDetChTyp(iDetInd) * fviNbChannels[iDetInd] ]; - } // if( -1 < fMbsMappingPar->GetMappedDetInd( iUniqueId ) ) - else fvbMappedDet[iDetInd] = kFALSE; - } // for( Int_t iDetInd = 0; iDetInd < fMbsMappingPar->GetNbMappedDet(); iDetInd ++ ) - } // if( kTRUE == fMbsMappingPar->UseDigiExp() ) - - return kTRUE; - } // if( 0 < fMbsMappingPar->GetNbMappedDet() ) - else - { - LOG(error)<<"TMbsConvTof::InitTempDigiStorage => 0 detectors defined in fMbsMappingPar !!!"; - return kFALSE; - } // else of if( 0 < fMbsMappingPar->GetNbMappedDet() ) -} -Bool_t TMbsConvTof::FillTempDigiStorage() -{ - // Saves digis in separate vectors for each Detector/channel pair => allow time oredring for left-right building - if( kTRUE == fMbsMappingPar->UseDigiExp() ) - { - for( Int_t iDigiInd = 0; iDigiInd < fCbmTofDigiCollection->GetEntriesFast(); iDigiInd++ ) - { - CbmTofDigi * digiPtr = ( CbmTofDigi * )fCbmTofDigiCollection->At( iDigiInd ); - Int_t iAddress = digiPtr->GetAddress(); - Int_t iDetInd = fMbsConvPar->GetDetectorInd( iAddress ); - if( -1 == iDetInd ) - continue; - if( kTRUE == fvbMappedDet[iDetInd] ) - { - Int_t iChan = digiPtr->GetChannel(); - Int_t iSide = digiPtr->GetSide(); - switch( fMbsConvPar->GetDetChTyp(iDetInd) ) - { - case 1: - // For pads, number left channels as even and right channels as odd - fvClassedDigis[iDetInd][ 2*iChan + iSide ].push_back( *digiPtr ); - break; - case 2: - // First left end of all channels, then right end - fvClassedDigis[iDetInd][ iChan + iSide * fviNbChannels[iDetInd] ].push_back( *digiPtr ); - break; - default: - break; - } // switch( fMbsConvPar->GetDetChTyp(iDetInd) ) - } // if( kTRUE == fvbMappedDet[iDetInd] ) - } // for( Int_t iDigiInd = 0; iDigiInd < fCbmTofDigiCollection->GetEntriesFast(); iDigiInd++ ) - } // if( kTRUE == fMbsMappingPar->UseDigiExp() ) - return kTRUE; -} -Bool_t TMbsConvTof::BuildFiredChannels() -{ - if( kTRUE == fMbsMappingPar->UseDigiExp() ) - { - for( Int_t iDetInd = 0; iDetInd < fMbsConvPar->GetNbDetectors(); iDetInd ++ ) - if( kTRUE == fvbMappedDet[iDetInd] ) - switch( fMbsConvPar->GetDetChTyp(iDetInd) ) - { - case 1: - { - for( Int_t iChanInd = 0; iChanInd < fviNbChannels[iDetInd]; iChanInd ++) - if( 0 < fvClassedDigis[iDetInd][iChanInd].size() ) - { - if( iDetInd < fMbsConvPar->GetNbRpc() ) - { - Rpc_Hit hit; - hit.iStrip = iChanInd; - hit.dTimeLeft = fvClassedDigis[iDetInd][iChanInd][0].GetTime(); // in ps - hit.dTotLeft = fvClassedDigis[iDetInd][iChanInd][0].GetTot(); // in ps - hit.fbMultiEdge = 1 < fvClassedDigis[iDetInd][iChanInd].size() ? kTRUE : kFALSE; - fvRpcHits[iDetInd].push_back( hit ); - } // if( iDetInd < fMbsConvPar->GetNbRpc() ) - else for( UInt_t uHit = 0; - uHit < fvClassedDigis[iDetInd][iChanInd].size(); - uHit++) - { - Plastics_Hit hit; - hit.dTimeLeft = fvClassedDigis[iDetInd][iChanInd][uHit].GetTime(); // in ps - hit.dTotLeft = fvClassedDigis[iDetInd][iChanInd][uHit].GetTot(); // in ps - hit.fbMultiEdge = 1 < fvClassedDigis[iDetInd][iChanInd].size() ? kTRUE : kFALSE; - fvPlasticHits[iDetInd - fMbsConvPar->GetNbRpc() ].push_back( hit ); - } // else of if( iDetInd < fMbsConvPar->GetNbRpc() ) - } // for( Int_t iChanInd = 0; iChanInd < fviNbChannels[iDetInd]; iChanInd ++) - break; - } - case 2: - { - for( Int_t iChanInd = 0; iChanInd < fviNbChannels[iDetInd]; iChanInd ++) - if( 0 < fvClassedDigis[iDetInd][iChanInd].size() && - 0 < fvClassedDigis[iDetInd][iChanInd + fviNbChannels[iDetInd] ].size() ) - { - if( iDetInd < fMbsConvPar->GetNbRpc() ) - { - Rpc_Hit hit; - hit.iStrip = iChanInd; - hit.dTimeLeft = fvClassedDigis[iDetInd][iChanInd][0].GetTime(); // in ps - hit.dTotLeft = fvClassedDigis[iDetInd][iChanInd][0].GetTot(); // in ps - hit.dTimeRight = fvClassedDigis[iDetInd] - [iChanInd+ fviNbChannels[iDetInd] ] - [0].GetTime(); // in ps - hit.dTotRight = fvClassedDigis[iDetInd] - [iChanInd + fviNbChannels[iDetInd] ] - [0].GetTot(); // in ps - hit.fbMultiEdge = ( 1 < fvClassedDigis[iDetInd][iChanInd].size() || - 1 < fvClassedDigis[iDetInd] - [iChanInd + fviNbChannels[iDetInd] ].size() ) ? - kTRUE : kFALSE; - fvRpcHits[iDetInd].push_back( hit ); - } // if( iDetInd < fMbsConvPar->GetNbRpc() ) - else for( UInt_t uHit = 0; - uHit < fvClassedDigis[iDetInd][iChanInd].size() && - uHit < fvClassedDigis[iDetInd][iChanInd + fviNbChannels[iDetInd] ].size(); - uHit++) - { - Plastics_Hit hit; - hit.dTimeLeft = fvClassedDigis[iDetInd][iChanInd][uHit].GetTime(); // in ps - hit.dTotLeft = fvClassedDigis[iDetInd][iChanInd][uHit].GetTot(); // in ps - hit.dTimeRight = fvClassedDigis[iDetInd] - [iChanInd+ fviNbChannels[iDetInd] ] - [uHit].GetTime(); // in ps - hit.dTotRight = fvClassedDigis[iDetInd] - [iChanInd + fviNbChannels[iDetInd] ] - [uHit].GetTot(); // in ps - hit.fbMultiEdge = ( 1 < fvClassedDigis[iDetInd][iChanInd].size() || - 1 < fvClassedDigis[iDetInd] - [iChanInd + fviNbChannels[iDetInd] ].size() ) ? - kTRUE : kFALSE; - fvPlasticHits[iDetInd - fMbsConvPar->GetNbRpc() ].push_back( hit ); - } // else of if( iDetInd < fMbsConvPar->GetNbRpc() ) - } // for( Int_t iChanInd = 0; iChanInd < fviNbChannels[iDetInd]; iChanInd ++) - } - break; - default: - break; - } // switch( fMbsConvPar->GetDetChTyp(iDetInd) ) - } // if( kTRUE == fMbsMappingPar->UseDigiExp() ) - return kTRUE; -} -Bool_t TMbsConvTof::ClearTempDigiStorage() -{ - if( 0 < fMbsMappingPar->GetNbMappedDet() ) - { - if( kTRUE == fMbsMappingPar->UseDigiExp() ) - { - for( Int_t iDetInd = 0; iDetInd < fMbsConvPar->GetNbDetectors(); iDetInd ++ ) - if( kTRUE == fvbMappedDet[iDetInd] ) - for( Int_t iChanInd = 0; - iChanInd < fMbsConvPar->GetDetChTyp(iDetInd) * fviNbChannels[iDetInd]; - iChanInd ++) - fvClassedDigis[iDetInd][iChanInd].clear(); - } // if( kTRUE == fMbsMappingPar->UseDigiExp() ) - } // if( 0 < fMbsMappingPar->GetNbMappedDet() ) - - return kTRUE; -} -Bool_t TMbsConvTof::DeleteTempDigiStorage() -{ - if( 0 < fMbsMappingPar->GetNbMappedDet() ) - { - if( kTRUE == fMbsMappingPar->UseDigiExp() ) - { - for( Int_t iDetInd = 0; iDetInd < fMbsConvPar->GetNbDetectors(); iDetInd ++ ) - if( kTRUE == fvbMappedDet[iDetInd] ) - { - for( Int_t iChanInd = 0; - iChanInd < fMbsConvPar->GetDetChTyp(iDetInd) * fviNbChannels[iDetInd]; - iChanInd ++) - fvClassedDigis[iDetInd][iChanInd].clear(); - delete [] fvClassedDigis[iDetInd]; - } // for( Int_t iDetInd = 0; iDetInd < fMbsMappingPar->GetNbMappedDet(); iDetInd ++ ) - delete fvClassedDigis; - } // if( kTRUE == fMbsMappingPar->UseDigiExp() ) - fviNbChannels.clear(); - } // if( 0 < fMbsMappingPar->GetNbMappedDet() ) - - return kTRUE; -} - diff --git a/beamtime/tof/output/TMbsConvTof.h b/beamtime/tof/output/TMbsConvTof.h deleted file mode 100644 index 209f775891e6bdacc4abf103a74302c4100aacf0..0000000000000000000000000000000000000000 --- a/beamtime/tof/output/TMbsConvTof.h +++ /dev/null @@ -1,144 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TMbsConvTof ----- -// ----- Created 11/06/2013 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ -#ifndef _TMBSCONVTOF_H_ -#define _TMBSCONVTOF_H_ - -#include "FairTask.h" - -#include <vector> - -#include "TofTdcDef.h" - - -// Parameters -class TMbsUnpackTofPar; -class TMbsCalibTofPar; -class TMbsMappingTofPar; -class TMbsConvTofPar; - -// Input Data -class TTofCalibData; -/* -class CbmTofDigiExp; -class CbmTofDigi; -*/ -#include "CbmTofDigi.h" - -// Output Data -class Plastics_Hit; -class Rpc_Hit; -class Scalers_Event; -class TVftxBoardData; - -// ROOT -class TFile; -class TDirectory; -class TClonesArray; -class TH1; -class TH2; -class TString; - -class TMbsConvTof : public FairTask { - public: - TMbsConvTof(); - TMbsConvTof(const char* name, Int_t mode = 1, Int_t verbose = 1); - virtual ~TMbsConvTof(); - - // Fairtask specific functions - virtual void SetParContainers(); - virtual InitStatus Init(); - virtual InitStatus ReInit(); - virtual void Exec(Option_t* option); - virtual void Finish(); - - // Histograms - void WriteHistogramms(); - - private: - TMbsConvTof(const TMbsConvTof&); - TMbsConvTof operator=(const TMbsConvTof&); - - // Parameters - Bool_t InitParameters(); - TMbsUnpackTofPar *fMbsUnpackPar; - TMbsCalibTofPar *fMbsCalibPar; - TMbsMappingTofPar *fMbsMappingPar; - TMbsConvTofPar *fMbsConvPar; - - // Histograms - Bool_t CreateHistogramms(); - Bool_t FillHistograms(); - void DeleteHistograms(); // TODO - - // Histograms objects - std::vector< TH2* > fhRpcHitPosition; - std::vector< TH2* > fhRpcTotComp; - std::vector< TH1* > fhPlasticHitPosition; - std::vector< TH2* > fhPlasticTotComp; - - // Input - Bool_t RegisterInput(); - - // Input objects - TClonesArray * fTriglogBoardCollection; - TClonesArray * fScalerBoardCollection; - TClonesArray * fCaenBoardCollection; - TClonesArray * fVftxBoardCollection; - TClonesArray * fGet4BoardCollection; - TClonesArray * fCalibDataCollection; - TClonesArray * fCalibScalCollection; - TClonesArray * fCbmTofDigiCollection; - TClonesArray * fRateDataCollection; - - // Output to ROOT file - Bool_t RegisterOutput(); - Bool_t FillOutput(); - Bool_t ClearOutput(); - Bool_t DeleteOutput(); - - // Output objects - TString sOutputFilename; - TFile * fOutputFile; - TTree * fOutputTree; - - // Triglog - UInt_t uTriglogSyncNb; - UInt_t uTriglogPattern; - UInt_t uTriglogInputPattern; - UInt_t uTriglogTimeSec; - UInt_t TriglogTimeMilsec; - Bool_t FillTriglogData(); - Bool_t ClearTriglogData(); - - // VFTX calibrated TDC boards conversion - std::vector< TVftxBoardData > fvVftxCalibBoards; - Bool_t FillVftxBoards(); - Bool_t ClearVftxBoards(); - - // Calibrated scalers: Rates, clock time, ... - // + Mapped Rates when available - std::vector< Scalers_Event > fvScalerEvents; // Dim 1 = Scaler Board, 1st for (TRIGLOG + 1 ScalOrMu + Detectors) - Bool_t FillCalibScaler(); - Bool_t FillMappedScaler(); - Bool_t ClearScalerEvent(); - - // Fired Channel building & Conversion - std::vector< Bool_t > fvbMappedDet; - std::vector< Int_t > fviNbChannels; - std::vector< CbmTofDigi > ** fvClassedDigis; // Dim 1 = Detector, Dim 2 = Channel * Side, Dim 3 = Digi Ind - std::vector< std::vector< Plastics_Hit > > fvPlasticHits; // Dim 1 = Plastic, Dim 2 = Hit Ind - std::vector< std::vector< Rpc_Hit > > fvRpcHits; // Dim 1 = RPC, Dim 2 = Hit Ind - std::vector< TVftxBoardData > fvVftxBoards; // Dim 1 = VFTX board - Bool_t InitTempDigiStorage(); - Bool_t FillTempDigiStorage(); - Bool_t BuildFiredChannels(); - Bool_t ClearTempDigiStorage(); - Bool_t DeleteTempDigiStorage(); - - Int_t fiNbEvents; - - ClassDef(TMbsConvTof, 1); -}; -#endif // _TMBSCONVTOF_H_ diff --git a/beamtime/tof/output/TMbsConvTofPar.cxx b/beamtime/tof/output/TMbsConvTofPar.cxx deleted file mode 100644 index 00712d77d1c2a60502e43ba23e59ce4ea2299bb8..0000000000000000000000000000000000000000 --- a/beamtime/tof/output/TMbsConvTofPar.cxx +++ /dev/null @@ -1,346 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TMbsConvTofPar ----- -// ----- Created 09/06/2013 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ -#include "TMbsConvTofPar.h" - -// TOF headers -#include "CbmTofAddress.h" - -// FAIR headers -#include "FairLogger.h" -#include "FairParamList.h" - -// ROOT headers -#include "TString.h" - -ClassImp(TMbsConvTofPar) - -TMbsConvTofPar::TMbsConvTofPar() : - FairParGenericSet("TMbsConvTofPar","Tof MBS Conversion Parameters","TestDefaultContext"), - fuConvDebug(0), - fsFilenameOut(""), - fiEnableTriglog(0), - fiNbOutScalers(0), - fiScalersIndex(), - fiNbOutVftx(0), - fiVftxIndex(), - fiNbRpc(0), - fiRpcUniqueAddress(), - fiRpcChType(), - fiNbPlastics(0), - fiPlasticUniqueAddress(), - fiPlasticEndsNb() -{ -} - -TMbsConvTofPar::TMbsConvTofPar(const char* name, - const char* title, - const char* context ) : - FairParGenericSet(name,title,context), - fuConvDebug(0), - fsFilenameOut(""), - fiEnableTriglog(0), - fiNbOutScalers(0), - fiScalersIndex(), - fiNbOutVftx(0), - fiVftxIndex(), - fiNbRpc(0), - fiRpcUniqueAddress(), - fiRpcChType(), - fiNbPlastics(0), - fiPlasticUniqueAddress(), - fiPlasticEndsNb() -{ -} - -TMbsConvTofPar::~TMbsConvTofPar() -{ -} - -void TMbsConvTofPar::clear(void) -{ - status = kFALSE; - resetInputVersions(); -} - -void TMbsConvTofPar::putParams(FairParamList* l) -{ - if (!l) { return; } - - l->add("ConvDebug", (Int_t)fuConvDebug); - - l->add("EnableTriglog", fiEnableTriglog); - l->add("FilenameOut", fsFilenameOut); - l->add("NbOutScalers", fiNbOutScalers); - l->add("ScalersIndex", fiScalersIndex); - l->add("NbOutVftx", fiNbOutVftx); - l->add("VftxIndex", fiVftxIndex); - l->add("NbRpc", fiNbRpc); - l->add("RpcUniqueAdd", fiPlasticUniqueAddress); - l->add("RpcChType", fiRpcChType); - l->add("NbPlastics", fiNbPlastics); - l->add("PlaUniqueAdd", fiPlasticUniqueAddress); - l->add("PlaEndsNb", fiPlasticEndsNb); -} - -Bool_t TMbsConvTofPar::getParams(FairParamList* l) -{ - if (!l) { return kFALSE; } - - /* - * TODO PAL: Thing I am not sure is whether order in readout has to - * match order in the ascii file => to check - */ - - LOG(debug2)<<"Get the Tof MBS Conversion parameters."; - - Int_t iTempCaster = 0; - if ( ! l->fill("ConvDebug", &iTempCaster) ) return kFALSE; - fuConvDebug = (UInt_t)iTempCaster; - - Int_t iMaxSizeFilename = 5000; - Text_t *sTempText; - sTempText = new Text_t[iMaxSizeFilename]; - if ( ! l->fill("FilenameOut", sTempText, iMaxSizeFilename ) ) return kFALSE; - fsFilenameOut = sTempText; - - if ( ! l->fill("EnableTriglog", &fiEnableTriglog) ) return kFALSE; - - if ( ! l->fill("NbOutScalers", &fiNbOutScalers) ) return kFALSE; - if( 0 < fiNbOutScalers ) - { - fiScalersIndex.Set( fiNbOutScalers ); - if ( ! l->fill("ScalersIndex", &fiScalersIndex) ) return kFALSE; - } // if( 0 < fiNbOutScalers ) - - if ( ! l->fill("NbOutVftx", &fiNbOutVftx) ) return kFALSE; - if( 0 < fiNbOutVftx ) - { - fiVftxIndex.Set( fiNbOutVftx ); - if ( ! l->fill("VftxIndex", &fiVftxIndex) ) return kFALSE; - } // if( 0 < fiNbOutVftx ) - - if ( ! l->fill("NbRpc", &fiNbRpc) ) return kFALSE; - if( 0 < fiNbRpc ) - { - fiRpcUniqueAddress.Set( fiNbRpc ); - if ( ! l->fill("RpcUniqueAdd", &fiRpcUniqueAddress) ) return kFALSE; - - fiRpcChType.Set( fiNbRpc ); - if ( ! l->fill("RpcChType", &fiRpcChType) ) return kFALSE; - } // if( 0 < fiNbRpc ) - - if ( ! l->fill("NbPlastics", &fiNbPlastics) ) return kFALSE; - if( 0 < fiNbPlastics ) - { - fiPlasticUniqueAddress.Set( fiNbPlastics ); - if ( ! l->fill("PlaUniqueAdd", &fiPlasticUniqueAddress) ) return kFALSE; - - fiPlasticEndsNb.Set( fiNbPlastics ); - if ( ! l->fill("PlaEndsNb", &fiPlasticEndsNb) ) return kFALSE; - } // if( 0 < fiNbPlastics ) - - return kTRUE; -} - -void TMbsConvTofPar::printParams() -{ - LOG(info)<<"Parameter values in TMbsConvTofPar: "; - - if(1 == fuConvDebug) - LOG(info)<<" Conversion Debug ON!!!!!!"; - else LOG(info)<<" Conversion Debug OFF"; - - // Output Filename - LOG(info)<<" ROOT output filename "<<fsFilenameOut; - - // TRIGLOG - if( 1 == fiEnableTriglog ) - LOG(info)<<" TRIGLOG data in output: ON"; - else LOG(info)<<" TRIGLOG data in output: OFF"; - - // SCALERS - if( 0 < fiNbOutScalers ) - { - LOG(info)<<" Nb Scalers output: "<<fiNbOutScalers; - - TString sOutScal = "Output scaler Index: --- "; - TString sCalScal = "Calib. scaler Index: |-> "; - for( Int_t iOutScalIndx = 0; iOutScalIndx < fiNbOutScalers; iOutScalIndx++ ) - { - sOutScal += Form( "%03d ", iOutScalIndx); - sCalScal += Form( "%03d ", fiScalersIndex[iOutScalIndx]); - } // for( Int_t iOutScalIndx = 0; iOutScalIndx < fiNbOutScalers; iOutScalIndx++ ) - LOG(info)<<sOutScal; - LOG(info)<<sCalScal; - } // if( 0 < fiNbOutScalers ) - else LOG(info)<<" Nb Scalers output: NONE"; - - // VFTX - if( 0 < fiNbOutVftx ) - { - LOG(info)<<" Nb VFTX in output: "<<fiNbOutVftx; - - TString sOutVftx = "Output VFTX Index: --- "; - TString sCalVftx = "Calib. VFTX Index: |-> "; - for( Int_t iOutVftxIndx = 0; iOutVftxIndx < fiNbOutVftx; iOutVftxIndx++ ) - { - sOutVftx += Form( "%03d ", iOutVftxIndx); - sCalVftx += Form( "%03d ", fiVftxIndex[iOutVftxIndx]); - } // for( Int_t iOutVftxIndx = 0; iOutVftxIndx < fiNbOutVftx; iOutVftxIndx++ ) - LOG(info)<<sOutVftx; - LOG(info)<<sCalVftx; - } // if( 0 < fiNbOutVftx ) - else LOG(info)<<" Nb VFTX in output: NONE"; - - // RPC - if( 0 < fiNbRpc ) - { - LOG(info)<<" Nb RPC in output: "<<fiNbRpc; - - TString sOutRpc = "Output RPC Index: --- "; - TString sRpcUId = "RPC unique ID: |-> "; - TString sRpcChType = "RPC Channel Type |-> "; - for( Int_t iRpcIndx = 0; iRpcIndx < fiNbRpc; iRpcIndx++ ) - { - sOutRpc += Form( "%10d ", iRpcIndx); - sRpcUId += Form( "0x%08x ", (UInt_t)(fiRpcUniqueAddress[iRpcIndx]) ); - if( 1 == fiRpcChType[iRpcIndx] ) - sRpcChType += " PADS "; - else if( 2 == fiRpcChType[iRpcIndx] ) - sRpcChType += " STRIPS "; - else sRpcChType += " UNDEF "; - } // for( Int_t iOutVftxIndx = 0; iOutVftxIndx < fiNbOutVftx; iOutVftxIndx++ ) - LOG(info)<<sOutRpc; - LOG(info)<<sRpcUId; - LOG(info)<<sRpcChType; - } // if( 0 < fiNbRpc ) - else LOG(info)<<" Nb RPC in output: NONE"; - - // Plastics - if( 0 < fiNbPlastics ) - { - LOG(info)<<" Nb Plastics in output: "<<fiNbPlastics; - - TString sOutPla = "Output Plastic Index: --- "; - TString sPlaUId = "Plastic unique ID: |-> "; - TString sPlaEndNb = "Plastic Ends Nb: |-> "; - for( Int_t iPlasticIndx = 0; iPlasticIndx < fiNbPlastics; iPlasticIndx++ ) - { - sOutPla += Form( "%10d ", iPlasticIndx); - sPlaUId += Form( "0x%08x ", (UInt_t)fiPlasticUniqueAddress[iPlasticIndx]); - if( 1 == fiPlasticEndsNb[iPlasticIndx] ) - sPlaEndNb += " Single "; - else if( 2 == fiPlasticEndsNb[iPlasticIndx] ) - sPlaEndNb += " Double "; - else sPlaEndNb += " UNDEF "; - } // for( Int_t iOutVftxIndx = 0; iOutVftxIndx < fiNbOutVftx; iOutVftxIndx++ ) - LOG(info)<<sOutPla; - LOG(info)<<sPlaUId; - LOG(info)<<sPlaEndNb; - } // if( 0 < fiNbPlastics ) - else LOG(info)<<" Nb Plastics in output: NONE"; - - return; -} -// ------------------------------------------------------------------ -Int_t TMbsConvTofPar::GetScalerInd( Int_t outScalerInd ) const -{ - if( outScalerInd < fiNbOutScalers && 0 < fiScalersIndex.GetSize() ) - return fiScalersIndex[outScalerInd]; - else return -1; -} -Int_t TMbsConvTofPar::GetVftxInd( Int_t outBoardInd ) const -{ - if( outBoardInd < fiNbOutVftx && 0 < fiVftxIndex.GetSize() ) - return fiVftxIndex[outBoardInd]; - else return -1; -} -Int_t TMbsConvTofPar::GetVftxOutInd( Int_t inputBoardInd ) const -{ - for( Int_t iOutInd = 0; iOutInd < fiNbOutVftx; iOutInd++) - if( inputBoardInd == fiVftxIndex[iOutInd] ) - return iOutInd; - - return -1; -} -Int_t TMbsConvTofPar::GetDetectorUid( Int_t detInd ) const -{ - if( detInd < fiNbRpc && 0 < fiRpcUniqueAddress.GetSize() ) - return fiRpcUniqueAddress[detInd]; - else if( detInd - fiNbRpc < fiNbPlastics && 0 < fiPlasticUniqueAddress.GetSize() ) - return fiPlasticUniqueAddress[detInd - fiNbRpc]; - else return -1; -} -Int_t TMbsConvTofPar::GetDetectorInd( Int_t channelAddress ) const -{ - Int_t iDetectorIndex = 0; - // loop over all defined output rpc to find if the address matches one of them - for( Int_t iRpcIndx = 0; iRpcIndx < fiNbRpc; iRpcIndx++ ) - if( kTRUE == CbmTofAddress::SameModule( channelAddress, fiRpcUniqueAddress[iRpcIndx] ) ) - return iDetectorIndex; - else iDetectorIndex++; - - // loop over all defined output plastics to find if the address matches one of them - for( Int_t iPlasticIndx = 0; iPlasticIndx < fiNbPlastics; iPlasticIndx++ ) - if( kTRUE == CbmTofAddress::SameModule( channelAddress, fiPlasticUniqueAddress[iPlasticIndx] ) ) - return iDetectorIndex; - else iDetectorIndex++; - - // If none matching - return -1; -} -Int_t TMbsConvTofPar::GetDetChTyp( Int_t detInd ) const -{ - if( detInd < fiNbRpc && 0 < fiRpcUniqueAddress.GetSize() ) - return GetRpcChType(detInd); - else if( detInd - fiNbRpc < fiNbPlastics && 0 < fiPlasticUniqueAddress.GetSize() ) - return GetPlasticEndNb(detInd - fiNbRpc); - else return -1; -} -Int_t TMbsConvTofPar::GetRpcUid( Int_t rpcInd ) const -{ - if( rpcInd < fiNbRpc && 0 < fiRpcUniqueAddress.GetSize() ) - return fiRpcUniqueAddress[rpcInd]; - else return -1; -} -Int_t TMbsConvTofPar::GetRpcInd( Int_t channelAddress ) const -{ - // loop over all defined output rpc to find if the address matches one of them - for( Int_t iRpcIndx = 0; iRpcIndx < fiNbRpc; iRpcIndx++ ) - if( kTRUE == CbmTofAddress::SameModule( channelAddress, fiRpcUniqueAddress[iRpcIndx] ) ) - return iRpcIndx; - - // If none matching - return -1; -} -Int_t TMbsConvTofPar::GetRpcChType( Int_t rpcInd ) const -{ - if( rpcInd < fiNbRpc && 0 < fiRpcChType.GetSize() ) - return fiRpcChType[rpcInd]; - else return -1; -} -Int_t TMbsConvTofPar::GetPlasticUid( Int_t plasticInd ) const -{ - if( plasticInd < fiNbPlastics && 0 < fiPlasticUniqueAddress.GetSize() ) - return fiPlasticUniqueAddress[plasticInd]; - else return -1; -} -Int_t TMbsConvTofPar::GetPlasticInd( Int_t channelAddress ) const -{ - // loop over all defined output plastics to find if the address matches one of them - for( Int_t iPlasticIndx = 0; iPlasticIndx < fiNbPlastics; iPlasticIndx++ ) - if( kTRUE == CbmTofAddress::SameModule( channelAddress, fiPlasticUniqueAddress[iPlasticIndx] ) ) - return iPlasticIndx; - - // If none matching - return -1; -} -Int_t TMbsConvTofPar::GetPlasticEndNb( Int_t plasticInd ) const -{ - if( plasticInd < fiNbPlastics && 0 < fiPlasticEndsNb.GetSize() ) - return fiPlasticEndsNb[plasticInd]; - else return -1; -} - diff --git a/beamtime/tof/output/TMbsConvTofPar.h b/beamtime/tof/output/TMbsConvTofPar.h deleted file mode 100644 index 2692875b666805faa409ea2733ef62f2a907d0a1..0000000000000000000000000000000000000000 --- a/beamtime/tof/output/TMbsConvTofPar.h +++ /dev/null @@ -1,96 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TMbsConvTofPar ----- -// ----- Created 11/06/2013 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ -#ifndef _TMBSCONVTOFPAR_H_ -#define _TMBSCONVTOFPAR_H_ - -#include "FairParGenericSet.h" -#include "TArrayI.h" -#include "TArrayD.h" - -class TMbsConvTofPar : public FairParGenericSet -{ - public: - TMbsConvTofPar() ; - - TMbsConvTofPar( const char* name, - const char* title="Mbs Mapping parameters for the ToF", - const char* context="TestDefaultContext" ); - - virtual ~TMbsConvTofPar(); - - // Accessors - Bool_t IsDebug() const { return (1 == fuConvDebug)? kTRUE: kFALSE; }; - TString GetOutFilename() const { return fsFilenameOut; }; - - Bool_t TriglogEnabled() const { return (1 == fiEnableTriglog)? kTRUE: kFALSE; }; - Int_t GetNbOutScal() const { return fiNbOutScalers; }; - Int_t GetScalerInd( Int_t outScalerInd ) const; - Int_t GetNbOutVftx() const { return fiNbOutVftx; }; - Int_t GetVftxInd( Int_t outBoardInd ) const; - Int_t GetVftxOutInd( Int_t inputBoardInd ) const; - // General - Int_t GetNbDetectors() const { return fiNbRpc + fiNbPlastics; }; - Int_t GetDetectorUid( Int_t detInd ) const; - Int_t GetDetectorInd( Int_t channelAddress ) const; - Int_t GetDetChTyp( Int_t detInd ) const; - // RPC - Int_t GetNbRpc() const { return fiNbRpc; }; - Int_t GetRpcUid( Int_t rpcInd ) const; - Int_t GetRpcInd( Int_t channelAddress ) const; - Int_t GetRpcChType( Int_t rpcInd ) const; - // PLASTIC - Int_t GetNbPlastic() const { return fiNbPlastics; }; - Int_t GetPlasticUid( Int_t plasticInd ) const; - Int_t GetPlasticInd( Int_t channelAddress ) const; - Int_t GetPlasticEndNb( Int_t plasticInd ) const; - - // Example taken from CbmTofDigiPar - void clear(void); - void putParams(FairParamList*); - Bool_t getParams(FairParamList*); - virtual void printParams(); - - private: - /** DEBUG */ - // Switch ON/OFF debug tests, output & histos in calibration - UInt_t fuConvDebug; - - /** Conversion **/ - // Name and path of the ROOT file in which the tree will be save - TString fsFilenameOut; - // Enable/Disable the Triglog data in the output tree - Int_t fiEnableTriglog; - // Nb of scaler boards saved in the TTree - Int_t fiNbOutScalers; - // Index of the scaler boards to be save under specified output scaler index - TArrayI fiScalersIndex; - // Number of scalers groups for each of the output scalers (maybe in scaler unpacker parameter) -// TArrayI fiScalersNb; - // Number of channels per scaler group for each of the output scalers (maybe in scaler unpacker parameter) -// TArrayI fiScalersChNb; - // Number of VFTX boards saved in output TTree - Int_t fiNbOutVftx; - // Index of the VFTX boards to be save under specified output VFTX index - TArrayI fiVftxIndex; - // Number of RPCs to be saved in output TTree - Int_t fiNbRpc; - // Unique address of the RPC to be saved under specified output RPC index - TArrayI fiRpcUniqueAddress; - // Channel type ( 1 = pad, 2 = strip, ...) for specified output RPC index - TArrayI fiRpcChType; - // Number of Plastics to be saved in output TTree - Int_t fiNbPlastics; - // Unique address of the Plastics (mapped as a 1 channel RPC) to be saved under specified output plastic index - TArrayI fiPlasticUniqueAddress; - // Ends readout type ( 1 = single end, 2 = both ends, ...) for specified output plastic index - TArrayI fiPlasticEndsNb; - - TMbsConvTofPar(const TMbsConvTofPar&); - TMbsConvTofPar& operator=(const TMbsConvTofPar&); - - ClassDef(TMbsConvTofPar, 1) -}; - -#endif //TMBSCONVTOFPAR_H diff --git a/beamtime/tof/output/TVftxBoardData.cxx b/beamtime/tof/output/TVftxBoardData.cxx deleted file mode 100644 index 059d697cf1ee998d9bb81243ab957b79414eeeaa..0000000000000000000000000000000000000000 --- a/beamtime/tof/output/TVftxBoardData.cxx +++ /dev/null @@ -1,49 +0,0 @@ - -#include "TVftxBoardData.h" - -#ifndef WITHGO4ROC - #define NB_BIN_FTS 1024 - #define CLOCK_TIME 5000 //ps -#endif // WITHGO4ROC - -void TVftxBoardData::Clear(Option_t*) -{ - iTriggerTime = 0; - for( Int_t iChan = 0; iChan < FPGA_TDC_NBCHAN; iChan++) - { - iMultiplicity[iChan] = 0; - for( Int_t iHit = 0; iHit < MaxMult; iHit++) - { - iFineTime[iChan][iHit] = -1; - iCoarseTime[iChan][iHit] = -1; - uFutureBit[iChan][iHit] = 0; - dTimeCorr[iChan][iHit] = -1; - dFineTimeCorr[iChan][iHit] = -1; - } - } -} -Double_t TVftxBoardData::GetCalibratedTime( UInt_t uChan, UInt_t uMult) -{ - // Return either the calibrated time - // when possible, otherwise 0 - if( uChan < FPGA_TDC_NBCHAN && uMult < MaxMult ) - return dTimeCorr[uChan][uMult]; - else return 0.0; -} -Double_t TVftxBoardData::GetCoarseCorrectedTime( UInt_t uChan, UInt_t uMult) -{ - // Return the calibrated time with a correction for coarse counter overflow relative to trigger - // when possible, otherwise 0 - if( uChan < FPGA_TDC_NBCHAN && uMult < MaxMult ) - { - Double_t dCoarseCorrectedTime = dTimeCorr[uChan][uMult]; - - if( VFTX_COARSE_OVERFLW_CHK < iCoarseTime[ uChan ][ uMult ] - iTriggerTime ) - dCoarseCorrectedTime -= ((TDC_FIFO_COARSE_CT>>TDC_FIFO_COARSE_CT_SHIFT)+1)*(Double_t)CLOCK_TIME; - if( iCoarseTime[ uChan ][ uMult ] - iTriggerTime < -1*VFTX_COARSE_OVERFLW_CHK ) - dCoarseCorrectedTime += ((TDC_FIFO_COARSE_CT>>TDC_FIFO_COARSE_CT_SHIFT)+1)*(Double_t)CLOCK_TIME; - - return dCoarseCorrectedTime; - } - else return 0.0; -} diff --git a/beamtime/tof/output/TVftxBoardData.h b/beamtime/tof/output/TVftxBoardData.h deleted file mode 100644 index 1a6949a5a45efd3b2f20d312187b5b9eeedbe6ad..0000000000000000000000000000000000000000 --- a/beamtime/tof/output/TVftxBoardData.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef TVFTXBOARDDATA_H -#define TVFTXBOARDDATA_H - -#include "MbsCrateDefines.h" - -#ifdef WITHGO4ROC - #include "TGo4Version.h" - #if __GO4BUILDVERSION__ > 40502 - #include "go4iostream.h" - #endif - #define NB_BIN_FTS 1024 - #define CLOCK_TIME 5000 //ps -#else - #include "Riostream.h" -#endif // WITHGO4ROC - -#include "TObject.h" - - -class TVftxBoardData : public TObject { - public: - enum { MaxMult = 8 }; - - Int_t iTriggerTime; - Int_t iMultiplicity[FPGA_TDC_NBCHAN]; // how many hits par channel - Int_t iFineTime[FPGA_TDC_NBCHAN][MaxMult]; - Int_t iCoarseTime[FPGA_TDC_NBCHAN][MaxMult]; - UInt_t uFutureBit[FPGA_TDC_NBCHAN][MaxMult]; - Double_t dTimeCorr[FPGA_TDC_NBCHAN][MaxMult]; - Double_t dFineTimeCorr[FPGA_TDC_NBCHAN][MaxMult]; - - TVftxBoardData() : - TObject(), - iTriggerTime(0) - { Clear(); } - void Clear(Option_t* =""); - Bool_t IsHitThere( UInt_t uChan, Int_t iMult ){ - return iMult < iMultiplicity[ uChan ]? kTRUE : kFALSE; }; - Double_t GetCalibratedTime( UInt_t uChan, UInt_t uMult); - Double_t GetCoarseCorrectedTime( UInt_t uChan, UInt_t uMult); - - ClassDef(TVftxBoardData,1) -}; -#endif //TVFTXBOARDDATA_H diff --git a/beamtime/tof/scalers/TTofScalerBoard.cxx b/beamtime/tof/scalers/TTofScalerBoard.cxx deleted file mode 100644 index 9d7737cdd8c2035e9ae2c6170eef719a74dcab69..0000000000000000000000000000000000000000 --- a/beamtime/tof/scalers/TTofScalerBoard.cxx +++ /dev/null @@ -1,222 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TTofScalerBoard ----- -// ----- Created 21/06/2013 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ - -#include "TTofScalerBoard.h" - -// TOF headers -#include "TofScalerDef.h" -#include "TofTriglogDef.h" -#include "TofScomDef.h" -#include "TofScal2014Def.h" -#include "TofOrGenDef.h" - -// FAIR headers -#include "FairLogger.h" - -// ROOT headers - -// C/C++ headers - -/************************** TTofScalerBoard ****************************/ -TTofScalerBoard::TTofScalerBoard(): - fbScalerFoundInEvent(kFALSE), - fuScalerType(0), - fuScalerNumber(0), - fuChannelNumber(0), - fuReferenceClock(0), - fvuDataCollection() -{ - fvuDataCollection.clear(); -} -TTofScalerBoard::TTofScalerBoard( UInt_t uType ) : - fbScalerFoundInEvent(kFALSE), - fuScalerType(uType), - fuScalerNumber(0), - fuChannelNumber(0), - fuReferenceClock(0), - fvuDataCollection() -{ - switch( fuScalerType ) - { - case tofscaler::undef : - fuScalerNumber = 0; - fuChannelNumber = 0; - fvuDataCollection.clear(); - break; - case tofscaler::triglog : - case tofscaler::triglogscal : - fuScalerNumber = triglog::kuNbScalers; - fuChannelNumber = triglog::kuNbChan; - fvuDataCollection.resize( fuScalerNumber ); - for( UInt_t uScaler = 0; uScaler < fuScalerNumber; uScaler ++) - fvuDataCollection[uScaler].resize( fuChannelNumber ); - break; - case tofscaler::scalormu : - fuScalerNumber = scalormu::kuNbScalers; - fuChannelNumber = scalormu::kuNbChan; - fvuDataCollection.resize( fuScalerNumber ); - for( UInt_t uScaler = 0; uScaler < fuScalerNumber; uScaler ++) - fvuDataCollection[uScaler].resize( fuChannelNumber ); - break; - case tofscaler::scalormubig : - fuScalerNumber = scalormuBig::kuNbScalers; - fuChannelNumber = scalormuBig::kuNbChan; - fvuDataCollection.resize( fuScalerNumber ); - for( UInt_t uScaler = 0; uScaler < fuScalerNumber; uScaler ++) - fvuDataCollection[uScaler].resize( fuChannelNumber ); - break; - case tofscaler::scaler2014 : - fuScalerNumber = scaler2014::kuNbScalers; - fuChannelNumber = scaler2014::kuNbChan; - fvuDataCollection.resize( fuScalerNumber ); - for( UInt_t uScaler = 0; uScaler < fuScalerNumber; uScaler ++) - fvuDataCollection[uScaler].resize( fuChannelNumber ); - break; - case tofscaler::orgen : - fuScalerNumber = orgen::kuNbScalers; - fuChannelNumber = orgen::kuNbChan; - fvuDataCollection.resize( fuScalerNumber ); - for( UInt_t uScaler = 0; uScaler < fuScalerNumber; uScaler ++) - fvuDataCollection[uScaler].resize( fuChannelNumber ); - break; - default: - fuScalerNumber = 0; - fuChannelNumber = 0; - fvuDataCollection.clear(); - break; - } // switch( fuScalerType ) -} -TTofScalerBoard::TTofScalerBoard( UInt_t uType, UInt_t uScalNb, UInt_t uChNb ) : - fbScalerFoundInEvent(kFALSE), - fuScalerType(uType), - fuScalerNumber(uScalNb), - fuChannelNumber(uChNb), - fuReferenceClock(0), - fvuDataCollection() -{ - if( 0 < fuScalerNumber && 0 < fuChannelNumber ) - { - fvuDataCollection.resize( fuScalerNumber ); - for( UInt_t uScaler = 0; uScaler < fuScalerNumber; uScaler ++) - fvuDataCollection[uScaler].resize( fuChannelNumber ); - } // if( 0 < fuScalerNumber && 0 < fuChannelNumber ) -} -TTofScalerBoard::~TTofScalerBoard() -{ - for( UInt_t uScaler = 0; uScaler < fuScalerNumber; uScaler ++) - fvuDataCollection[uScaler].clear(); - - fvuDataCollection.clear(); -} - -void TTofScalerBoard::Clear(Option_t *option) -{ - TObject::Clear( option ); - fbScalerFoundInEvent = kFALSE; - fuReferenceClock = 0; - for( UInt_t uScaler = 0; uScaler < fuScalerNumber; uScaler ++) - for( UInt_t uCh = 0; uCh < fuChannelNumber; uCh ++) - fvuDataCollection[uScaler][uCh] = 0; -} - // Set the scaler type from list defined in TofScalerDef.h, then the scaler size from other Def headers -void TTofScalerBoard::SetType( UInt_t uType ) -{ - fuScalerType = uType; - switch( fuScalerType ) - { - case tofscaler::undef : - fuScalerNumber = 0; - fuChannelNumber = 0; - fvuDataCollection.clear(); - break; - case tofscaler::triglog : - case tofscaler::triglogscal : - fuScalerNumber = triglog::kuNbScalers; - fuChannelNumber = triglog::kuNbChan; - fvuDataCollection.resize( fuScalerNumber ); - for( UInt_t uScaler = 0; uScaler < fuScalerNumber; uScaler ++) - fvuDataCollection[uScaler].resize( fuChannelNumber ); - break; - case tofscaler::scalormu : - fuScalerNumber = scalormu::kuNbScalers; - fuChannelNumber = scalormu::kuNbChan; - fvuDataCollection.resize( fuScalerNumber ); - for( UInt_t uScaler = 0; uScaler < fuScalerNumber; uScaler ++) - fvuDataCollection[uScaler].resize( fuChannelNumber ); - break; - case tofscaler::scalormubig : - fuScalerNumber = scalormuBig::kuNbScalers; - fuChannelNumber = scalormuBig::kuNbChan; - fvuDataCollection.resize( fuScalerNumber ); - for( UInt_t uScaler = 0; uScaler < fuScalerNumber; uScaler ++) - fvuDataCollection[uScaler].resize( fuChannelNumber ); - break; - case tofscaler::scaler2014 : - fuScalerNumber = scaler2014::kuNbScalers; - fuChannelNumber = scaler2014::kuNbChan; - fvuDataCollection.resize( fuScalerNumber ); - for( UInt_t uScaler = 0; uScaler < fuScalerNumber; uScaler ++) - fvuDataCollection[uScaler].resize( fuChannelNumber ); - break; - case tofscaler::orgen : - fuScalerNumber = orgen::kuNbScalers; - fuChannelNumber = orgen::kuNbChan; - fvuDataCollection.resize( fuScalerNumber ); - for( UInt_t uScaler = 0; uScaler < fuScalerNumber; uScaler ++) - fvuDataCollection[uScaler].resize( fuChannelNumber ); - break; - default: - fuScalerNumber = 0; - fuChannelNumber = 0; - fvuDataCollection.clear(); - break; - } // switch( fuScalerType ) -} -// if 0 < fuChannelNumber, update fvuDataCollection size or create it -void TTofScalerBoard::SetScalerNumber( UInt_t uScalNb ) -{ - fuScalerNumber = uScalNb; - if( 0 < fuScalerNumber && 0 < fuChannelNumber ) - { - fvuDataCollection.resize( fuScalerNumber ); - for( UInt_t uScaler = 0; uScaler < fuScalerNumber; uScaler ++) - fvuDataCollection[uScaler].resize( fuChannelNumber ); - } // if( 0 < fuScalerNumber && 0 < fuChannelNumber ) -} -// if 0 < fuScalerNumber, update fvuDataCollection size or create it -void TTofScalerBoard::SetChannelNumber( UInt_t uChNb ) -{ - fuChannelNumber = uChNb; - if( 0 < fuScalerNumber && 0 < fuChannelNumber ) - { - fvuDataCollection.resize( fuScalerNumber ); - for( UInt_t uScaler = 0; uScaler < fuScalerNumber; uScaler ++) - fvuDataCollection[uScaler].resize( fuChannelNumber ); - } // if( 0 < fuScalerNumber && 0 < fuChannelNumber ) -} -// update fvuDataCollection size or create it -void TTofScalerBoard::SetBoardCharac( UInt_t uScalNb, UInt_t uChNb) -{ - fuScalerNumber = uScalNb; - fuChannelNumber = uChNb; - if( 0 < fuScalerNumber && 0 < fuChannelNumber ) - { - fvuDataCollection.resize( fuScalerNumber ); - for( UInt_t uScaler = 0; uScaler < fuScalerNumber; uScaler ++) - fvuDataCollection[uScaler].resize( fuChannelNumber ); - } // if( 0 < fuScalerNumber && 0 < fuChannelNumber ) -} -void TTofScalerBoard::SetScalerValue( UInt_t uChan, UInt_t uVal, UInt_t uScaler) -{ - if( uScaler < fuScalerNumber && uChan < fuChannelNumber ) - fvuDataCollection[uScaler][uChan] = uVal; -} - -UInt_t TTofScalerBoard::GetScalerValue( UInt_t uChannel, UInt_t uScaler) const -{ - if( uScaler < fuScalerNumber && uChannel < fuChannelNumber ) - return fvuDataCollection[uScaler][uChannel]; - else return 0; -} diff --git a/beamtime/tof/scalers/TTofScalerBoard.h b/beamtime/tof/scalers/TTofScalerBoard.h deleted file mode 100644 index f18af40949fd4a713e4fedd6b1761a526233ecee..0000000000000000000000000000000000000000 --- a/beamtime/tof/scalers/TTofScalerBoard.h +++ /dev/null @@ -1,56 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TTofScalerBoard ----- -// ----- Created 21/06/2013 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ - -#ifndef TTOFSCALERBOARD_H_ -#define TTOFSCALERBOARD_H_ - -// ROOT headers -#include "TObject.h" - -// C/C++ headers -#include <vector> - -class TTofScalerBoard : public TObject -{ - public: - TTofScalerBoard(); - TTofScalerBoard( UInt_t uType ); - TTofScalerBoard( UInt_t uType, UInt_t uScalNb, UInt_t uChNb ); - ~TTofScalerBoard(); - - virtual void Clear(Option_t *option = ""); - - void SetPresentFlag( Bool_t bDataThere ) { fbScalerFoundInEvent = bDataThere; }; - void SetType( UInt_t uType ); // Set the scaler type from list defined in TofScalerDef.h, then the scaler size from other Def headers - void SetScalerNumber( UInt_t uScalNb ); // if 0 < fuChannelNumber, update fvuDataCollection size or create it - void SetChannelNumber( UInt_t uChNb ); // if 0 < fuScalerNumber, update fvuDataCollection size or create it - void SetBoardCharac( UInt_t uScalNb, UInt_t uChNb); // update fvuDataCollection size or create it - void SetScalerValue( UInt_t uChan, UInt_t uVal, UInt_t uScaler = 0 ); - void SetRefClk( UInt_t uRefClk ) { fuReferenceClock = uRefClk; }; - - Bool_t IsUpdated() const { return fbScalerFoundInEvent; }; - UInt_t GetScalerType() const { return fuScalerType; }; - UInt_t GetScalerNumber() const { return fuScalerNumber; }; - UInt_t GetChannelNumber() const { return fuChannelNumber; }; - UInt_t GetRefClk() const { return fuReferenceClock; }; - UInt_t GetScalerValue( UInt_t uChannel, UInt_t uScaler = 0 ) const; - - protected: - - private: - Bool_t fbScalerFoundInEvent; - UInt_t fuScalerType; - UInt_t fuScalerNumber; - UInt_t fuChannelNumber; - - /* Internal 781250 Hz reference clock for rates calculation */ - UInt_t fuReferenceClock; - - std::vector< std::vector< UInt_t > > fvuDataCollection; - - ClassDef(TTofScalerBoard, 1) -}; - -#endif // TTOFSCALERBOARD_H_ diff --git a/beamtime/tof/scalers/TofScalerDef.h b/beamtime/tof/scalers/TofScalerDef.h deleted file mode 100644 index ba3472930a13b849e44e4881b52d6be6ff4acde6..0000000000000000000000000000000000000000 --- a/beamtime/tof/scalers/TofScalerDef.h +++ /dev/null @@ -1,33 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TofScalerDef ----- -// ----- Created 21/06/2013 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ - -#ifndef TOFSCALERDEF_H_ -#define TOFSCALERDEF_H_ - -#include "TString.h" - -namespace tofscaler -{ - enum ScalerTypes { - undef = 0, // unknown TDC type, default value - triglog = 1, // TRIGger LOGic on boards of the VULOM family (J. Fruehauf dev.) - scalormu = 2, // Scaler Or Multiplicty on boards of the VULOM family (J. Fruehauf dev.) - scalormubig = 3, // Scaler Or Multiplicty on boards of the VULOM family (J. Fruehauf dev.) with more channels - scaler2014 = 4, // Scalers on boards of the VULOM family (J. Fruehauf dev.) with 32 input channels and 16 And scaler - triglogscal = 5, // TRIGLOG used as Scalers on boards of the VULOM family (J. Fruehauf dev.) with 16 IN, 16 LMU and 16 OUT scalers - orgen = 6, // VULOM Or Generation board (nov 2015) with 32 input channels, 16 ECl output scalers and 1-2 LEM output scalers - NbScalerTypes // Nb of Scaler types, require indices to be consecutive (no gap) - }; - - // Names for Histos - // !! Has to be adapted to match in initializer size the number of entries in TdcTypes!!! - const TString ksTdcHistName[NbScalerTypes] = { "default", "triglog", "scalormu", "scalormubig", "scaler2014", "trigscal", "orgen"}; - - // Names for parameters - // !! Has to be adapted to match in initializer size the number of entries in TdcTypes!!! - const TString ksTdcParName[NbScalerTypes] = { "Def", "Triglog", "Scalormu", "ScalormuBig", "Scaler2014", "TrigScal", "OrGen"}; -} - -#endif // TOFSCALERDEF_H_ diff --git a/beamtime/tof/scalers/orgen/TTofOrGenUnpacker.cxx b/beamtime/tof/scalers/orgen/TTofOrGenUnpacker.cxx deleted file mode 100644 index ce3a1136c13eb074eb89d742e321eb6e061642ae..0000000000000000000000000000000000000000 --- a/beamtime/tof/scalers/orgen/TTofOrGenUnpacker.cxx +++ /dev/null @@ -1,294 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TTofOrGenUnpacker ----- -// ----- Created 22/11/2015 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ - -#include "TTofOrGenUnpacker.h" - -// TOF headers -#include "TofDef.h" -#include "TMbsUnpackTofPar.h" -#include "TofOrGenDef.h" -#include "TofScalerDef.h" -#include "TTofScalerBoard.h" - -// FAIR headers -#include "FairRootManager.h" -#include "FairLogger.h" -#include "TString.h" - -// ROOT headers -#include "TClonesArray.h" -#include "TH1.h" -#include "TROOT.h" -#include "TDirectory.h" - -TTofOrGenUnpacker::TTofOrGenUnpacker(): - fParUnpack(0), - fuNbOrGen(0), - fScalerBoardCollection(NULL), - fhScalers(), - fhScalersEclo(), - fhScalersLemo(), - bFirstEvent(kTRUE), - fvuFirstScalers(), - fvuFirstScalersEclo(), - fvuFirstScalersLemo() -{ -} -TTofOrGenUnpacker::TTofOrGenUnpacker( TMbsUnpackTofPar * parIn ): - fParUnpack( parIn ), - fuNbOrGen( parIn->GetNbActiveBoards( tofMbs::orgen ) ), - fScalerBoardCollection(NULL), - fhScalers(), - fhScalersEclo(), - fhScalersLemo(), - bFirstEvent(kTRUE), - fvuFirstScalers(), - fvuFirstScalersEclo(), - fvuFirstScalersLemo() -{ - // Recover first the ScalerBoard objects created in general unpacker class - FairRootManager* rootMgr = FairRootManager::Instance(); - - fScalerBoardCollection = (TClonesArray*) rootMgr->GetObject("TofRawScalers"); - if(NULL == fScalerBoardCollection) - { - LOG(warn)<<"TTofOrGenUnpacker::TTofOrGenUnpacker : no Raw Scalers array! "; - fuNbOrGen = 0; - } // if(NULL == fScalerBoardCollection) - else - { - // Initialize the ScalerBoard object with each OrGen characteristics - TTofScalerBoard * fScalerBoard = NULL; - - // TRIGLOG is always considered as first scaler board! - UInt_t uTrigOff = 0; - if( kTRUE == fParUnpack->WithActiveTriglog() ) - uTrigOff = 1; - - LOG(debug)<<"TTofOrGenUnpacker::TTofOrGenUnpacker : Initialize objects for " - <<fuNbOrGen<<" boards "; - - for( UInt_t uScalIndex = 0; uScalIndex < fuNbOrGen; uScalIndex++) - { - // TRIGLOG always first scaler board! - fScalerBoard = (TTofScalerBoard*) fScalerBoardCollection->ConstructedAt( uScalIndex + uTrigOff); - if( tofscaler::undef == fScalerBoard->GetScalerType() ) - fScalerBoard->SetType( tofscaler::orgen ); - } // for( UInt_t uScalIndex = 0; uScalIndex < fuNbOrGen; uScalIndex++) - } // else of if(NULL == fScalerBoardCollection) - bFirstEvent = kTRUE; -} -TTofOrGenUnpacker::~TTofOrGenUnpacker() -{ -// DeleteHistos(); -} - -void TTofOrGenUnpacker::Clear(Option_t */*option*/) -{ - fParUnpack = NULL; - fuNbOrGen = 0; - fScalerBoardCollection = NULL; -} - -void TTofOrGenUnpacker::ProcessOrGen( Int_t iScalIndex, UInt_t* pMbsData, UInt_t uLength ) -{ - if( (iScalIndex<0) || (fuNbOrGen <= static_cast<UInt_t>(iScalIndex) ) ) - { - LOG(error)<<"Error Or Gen number "<<iScalIndex<<" out of bound (max "<<fuNbOrGen<<") "; - return; - } - - // TRIGLOG is always considered as first scaler board! - TTofScalerBoard * fScalerBoard = NULL; - if( kTRUE == fParUnpack->WithActiveTriglog() ) - { - // First check if ScalerBoard object for Triglog was created already - if( 2 + iScalIndex <= fScalerBoardCollection->GetEntriesFast() ) - fScalerBoard = (TTofScalerBoard*) fScalerBoardCollection->ConstructedAt( 1 + iScalIndex, "C"); - else for( Int_t iScalBd = fScalerBoardCollection->GetEntriesFast(); iScalBd <= 1 + iScalIndex; iScalBd++ ) - fScalerBoard = (TTofScalerBoard*) fScalerBoardCollection->ConstructedAt( iScalBd); - } // if( kTRUE == fParUnpack->WithActiveTriglog() ) - else fScalerBoard = (TTofScalerBoard*) fScalerBoardCollection->ConstructedAt( iScalIndex, "C"); - - UInt_t uIndx = 0; - -/* UInt_t uNbScalCh = orgen::kuNbChan;*/ - - if( tofscaler::undef == fScalerBoard->GetScalerType() ) - fScalerBoard->SetType( tofscaler::orgen ); - - // First readout scalers for the input channels - for( UInt_t uScalerInd=0; uScalerInd < orgen::kuNbChanIn; uScalerInd++) - { - UInt_t uValue = (UInt_t)( uIndx < uLength ? pMbsData[uIndx] : 0 ); - uIndx++; - fScalerBoard->SetScalerValue(uScalerInd, uValue); - } // for( UInt_t uScalerInd=0; uScalerInd < orgen::kuNbChanIn; uScalerInd++) - - // Then readout the reference clock scaler - fScalerBoard->SetRefClk( pMbsData[uIndx] ); - uIndx++; - - // Then readout the scalers for the ECL output signal pairs - for( UInt_t uScalerInd=0; uScalerInd < orgen::kuNbChanEclo; uScalerInd++) - { - UInt_t uValue = (UInt_t)( uIndx < uLength ? pMbsData[uIndx] : 0 ); - uIndx++; - fScalerBoard->SetScalerValue( orgen::kuNbChanIn + uScalerInd, uValue); - } // for( UInt_t uScalerInd=0; uScalerInd < orgen::kuNbChanEclo; uScalerInd++) - - // Finally readout the scalers for the LEM output signal (NIM) - for( UInt_t uScalerInd=0; uScalerInd < orgen::kuNbChanLemo; uScalerInd++) - { - UInt_t uValue = (UInt_t)( uIndx < uLength ? pMbsData[uIndx] : 0 ); - uIndx++; - fScalerBoard->SetScalerValue( orgen::kuNbChanIn + orgen::kuNbChanEclo + uScalerInd, uValue); - } // for( UInt_t uScalerInd=0; uScalerInd < orgen::kuNbChanEclo; uScalerInd++) - - if( uLength != uIndx ) - LOG(error)<<" TTofOrGenUnpacker::ProcessOrGen => Or Gen #" - <<fParUnpack->GetActiveToAllTypeInd(iScalIndex, tofMbs::orgen) - <<" unpacking length missmatch: length " - <<uLength<<" VS index "<<uIndx; - - fScalerBoard->SetPresentFlag( kTRUE ); - - LOG(debug2)<<" Or Gen #"<<fParUnpack->GetActiveToAllTypeInd(iScalIndex, tofMbs::orgen) - <<" finished"; - return; -} - -// Histogram management -// TODO: maybe add some options to control which histograms are -// created and filed (memory management) -void TTofOrGenUnpacker::CreateHistos() -{ - LOG(debug)<<"TTofOrGenUnpacker::CreateHistos : Create histos for " - <<fuNbOrGen<<" boards "; - - TDirectory * oldir = gDirectory; // <= To prevent histos from being sucked in by the param file of the TRootManager! - gROOT->cd(); // <= To prevent histos from being su - - fhScalers.resize(fuNbOrGen, NULL); - fvuFirstScalers.resize(fuNbOrGen); - - fhScalersEclo.resize(fuNbOrGen, NULL); - fhScalersLemo.resize(fuNbOrGen, NULL); - fvuFirstScalersEclo.resize(fuNbOrGen); - fvuFirstScalersLemo.resize(fuNbOrGen); - - for( UInt_t uScalIndex = 0; uScalIndex < fuNbOrGen; uScalIndex++) - { - fhScalers[uScalIndex] = new TH1I( - Form("tof_%s_%02u_scalersIn", tofscaler::ksTdcHistName[ tofscaler::orgen ].Data(), uScalIndex ), - "Counts per scaler channel; Channel []; Total counts []", orgen::kuNbChanIn, 0., orgen::kuNbChanIn); - - fvuFirstScalers[uScalIndex].resize( orgen::kuNbChanIn ); - for( UInt_t uScalerInd=0; uScalerInd < orgen::kuNbChanIn; uScalerInd++) - fvuFirstScalers[uScalIndex][uScalerInd] = 0; - - fhScalersEclo[uScalIndex] = new TH1I( - Form("tof_%s_%02u_scalersEclo", tofscaler::ksTdcHistName[ tofscaler::orgen ].Data(), uScalIndex ), - "Counts per scaler channel; Channel []; Total counts []", orgen::kuNbChanEclo, 0., orgen::kuNbChanEclo); - fhScalersLemo[uScalIndex] = new TH1I( - Form("tof_%s_%02u_scalerslemo", tofscaler::ksTdcHistName[ tofscaler::orgen ].Data(), uScalIndex ), - "Counts per scaler channel; Channel []; Total counts []", orgen::kuNbChanLemo, 0., orgen::kuNbChanLemo); - - fvuFirstScalersEclo[uScalIndex].resize( orgen::kuNbChanEclo ); - for( UInt_t uScalerInd=0; uScalerInd < orgen::kuNbChanEclo; uScalerInd++) - fvuFirstScalersEclo[uScalIndex][uScalerInd] = 0; - fvuFirstScalersLemo[uScalIndex].resize( orgen::kuNbChanLemo ); - for( UInt_t uScalerInd=0; uScalerInd < orgen::kuNbChanLemo; uScalerInd++) - fvuFirstScalersLemo[uScalIndex][uScalerInd] = 0; - - } // for( UInt_t uScalIndex = 0; uScalIndex < fuNbOrGen; uScalIndex++) - - gDirectory->cd( oldir->GetPath() ); // <= To prevent histos from being sucked in by the param file of the TRootManager! - - LOG(debug)<<"TTofOrGenUnpacker::CreateHistos : Created histos for " - <<fuNbOrGen<<" boards "; -} -void TTofOrGenUnpacker::FillHistos() -{ - LOG(debug)<<"TTofOrGenUnpacker::FillHistos : Fill histos for " - <<fuNbOrGen<<" boards "; - - for( UInt_t uScalIndex = 0; uScalIndex < fuNbOrGen; uScalIndex++) - { - - // TRIGLOG is always considered as first scaler board! - TTofScalerBoard * fScalerBoard; - if( kTRUE == fParUnpack->WithActiveTriglog() ) - fScalerBoard = (TTofScalerBoard*) fScalerBoardCollection->ConstructedAt( 1 + uScalIndex ); - else fScalerBoard = (TTofScalerBoard*) fScalerBoardCollection->ConstructedAt( 0 + uScalIndex ); - - if( kFALSE == fScalerBoard->IsUpdated() ) - continue; - - for( UInt_t uScalerInd=0; uScalerInd < orgen::kuNbChanIn; uScalerInd++) - { - if( kTRUE == bFirstEvent ) - fvuFirstScalers[uScalIndex][uScalerInd] = fScalerBoard->GetScalerValue( uScalerInd ); - else fhScalers[uScalIndex]->SetBinContent( 1 + uScalerInd, fScalerBoard->GetScalerValue( uScalerInd ) - - fvuFirstScalers[uScalIndex][uScalerInd] ); - } // for( UInt_t uScalerInd=0; uScalerInd < orgen::kuNbChanIn; uScalerInd++) - for( UInt_t uScalerInd=0; uScalerInd < orgen::kuNbChanEclo; uScalerInd++) - { - if( kTRUE == bFirstEvent ) - fvuFirstScalersEclo[uScalIndex][uScalerInd] = fScalerBoard->GetScalerValue( - orgen::kuNbChanIn + uScalerInd ); - else fhScalersEclo[uScalIndex]->SetBinContent( 1 + uScalerInd, - fScalerBoard->GetScalerValue( orgen::kuNbChanIn +uScalerInd ) - - fvuFirstScalersEclo[uScalIndex][uScalerInd] ); - } // for( UInt_t uScalerInd=0; uScalerInd < orgen::kuNbChanEclo; uScalerInd++) - for( UInt_t uScalerInd=0; uScalerInd < orgen::kuNbChanLemo; uScalerInd++) - { - if( kTRUE == bFirstEvent ) - fvuFirstScalersLemo[uScalIndex][uScalerInd] = fScalerBoard->GetScalerValue( - orgen::kuNbChanIn + orgen::kuNbChanEclo + uScalerInd ); - else fhScalersLemo[uScalIndex]->SetBinContent( 1 + uScalerInd, - fScalerBoard->GetScalerValue( orgen::kuNbChanIn + orgen::kuNbChanEclo + uScalerInd ) - - fvuFirstScalersLemo[uScalIndex][uScalerInd] ); - } // for( UInt_t uScalerInd=0; uScalerInd < orgen::kuNbChanLemo; uScalerInd++) - } // for( UInt_t uScalIndex = 0; uScalIndex < fuNbOrGen; uScalIndex++) - if( kTRUE == bFirstEvent ) - bFirstEvent = kFALSE; - - LOG(debug)<<"TTofOrGenUnpacker::FillHistos : Filled histos for " - <<fuNbOrGen<<" boards "; -} -void TTofOrGenUnpacker::WriteHistos( TDirectory* inDir) -{ - TDirectory * oldir = gDirectory; - - LOG(debug)<<"TTofOrGenUnpacker::WriteHistos : Write histos for " - <<fuNbOrGen<<" boards "; - for( UInt_t uScalIndex = 0; uScalIndex < fuNbOrGen; uScalIndex++) - { - TDirectory *cdOrGen = inDir->mkdir( - Form( "Unp_%s_%02u", tofscaler::ksTdcHistName[ tofscaler::orgen ].Data(), uScalIndex ) ); - cdOrGen->cd(); // make the "Unp_OrGen" directory the current directory - fhScalers[uScalIndex]->Write(); - fhScalersEclo[uScalIndex]->Write(); - fhScalersLemo[uScalIndex]->Write(); - } // for( UInt_t uScalIndex = 0; uScalIndex < fuNbOrGen; uScalIndex++) - - gDirectory->cd( oldir->GetPath() ); -} -void TTofOrGenUnpacker::DeleteHistos() -{ - // not sure if it will not make problems for seeing them - // => for now just delete histograming variables - - for( UInt_t uScalIndex = 0; uScalIndex < fuNbOrGen; uScalIndex++) - { - fvuFirstScalers[uScalIndex].clear(); - fvuFirstScalersEclo[uScalIndex].clear(); - fvuFirstScalersLemo[uScalIndex].clear(); - } // for( UInt_t uScalIndex = 0; uScalIndex < fuNbOrGen; uScalIndex++) - fvuFirstScalers.clear(); - fvuFirstScalersEclo.clear(); - fvuFirstScalersLemo.clear(); -} diff --git a/beamtime/tof/scalers/orgen/TTofOrGenUnpacker.h b/beamtime/tof/scalers/orgen/TTofOrGenUnpacker.h deleted file mode 100644 index 247891786131c65a8269beff7363ad7c1da2b58a..0000000000000000000000000000000000000000 --- a/beamtime/tof/scalers/orgen/TTofOrGenUnpacker.h +++ /dev/null @@ -1,58 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TTofOrGenUnpacker ----- -// ----- Created 22/11/2015 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ - -#ifndef TTOFORGENUNPACKER_H_ -#define TTOFORGENUNPACKER_H_ - -#include "TObject.h" - -#include <vector> - -class TMbsUnpackTofPar; - -class TClonesArray; -class TH1; -class TH2; -class TDirectory; - -class TTofOrGenUnpacker : public TObject -{ - public: - TTofOrGenUnpacker(); - TTofOrGenUnpacker( TMbsUnpackTofPar * parIn ); - ~TTofOrGenUnpacker(); - - virtual void Clear(Option_t *option); - - void ProcessOrGen( Int_t iScalIndex, UInt_t* pMbsData, UInt_t uLength ); - - void CreateHistos(); - void FillHistos(); - void WriteHistos( TDirectory* inDir); - void DeleteHistos(); - - private: - // no default Copy constructor and = OP as class not meant to be copied - TTofOrGenUnpacker(const TTofOrGenUnpacker&); - TTofOrGenUnpacker& operator=(const TTofOrGenUnpacker&); - - TMbsUnpackTofPar * fParUnpack; - UInt_t fuNbOrGen; - TClonesArray * fScalerBoardCollection; - - // Histograms - std::vector<TH1 *> fhScalers; //! last value of each scaler = integrated counts - std::vector<TH1 *> fhScalersEclo; //! last value of each Eclo scaler = integrated counts - std::vector<TH1 *> fhScalersLemo; //! last value of each Lemo scaler = integrated counts - - Bool_t bFirstEvent; - std::vector< std::vector< UInt_t > > fvuFirstScalers; //! First value of each scaler <= integrated counts - std::vector< std::vector< UInt_t > > fvuFirstScalersEclo; //! First value of each Eclo scaler <= integrated counts - std::vector< std::vector< UInt_t > > fvuFirstScalersLemo; //! First value of each Lemo scaler <= integrated counts - - ClassDef(TTofOrGenUnpacker, 1) -}; - -#endif // TTOFORGENUNPACKER_H_ diff --git a/beamtime/tof/scalers/orgen/TofOrGenDef.h b/beamtime/tof/scalers/orgen/TofOrGenDef.h deleted file mode 100644 index 3bab8ae2cff7f960e72a6572c41f1a028d7e2d0c..0000000000000000000000000000000000000000 --- a/beamtime/tof/scalers/orgen/TofOrGenDef.h +++ /dev/null @@ -1,25 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TofOrGenDef ----- -// ----- Created 22/11/2015 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ - -#ifndef TOFORGENDEF_H_ -#define TOFORGENDEF_H_ - -#include "TString.h" - -/******** VULOM3/4:OrGen CERN November 2015 data unpacking definitions *********/ - -namespace orgen -{ - const UInt_t kuNbScalers = 1; - const UInt_t kuNbChanIn = 32; - const UInt_t kuNbChanEclo = 16; - const UInt_t kuNbChanLemo = 1; - const UInt_t kuNbChan = kuNbChanIn + kuNbChanEclo + kuNbChanLemo; - const Double_t kdRefClkFreq = 781250.0; - const Double_t kdEvoRange = 3*3600; // s - const Double_t kdEvoBin = 1; // s -} - -#endif // TOFORGENDEFDEF_H_ diff --git a/beamtime/tof/scalers/scal2014/TTofScal2014Unpacker.cxx b/beamtime/tof/scalers/scal2014/TTofScal2014Unpacker.cxx deleted file mode 100644 index a6e7943037bcb20a5bfd38146bc0892ffe70c30d..0000000000000000000000000000000000000000 --- a/beamtime/tof/scalers/scal2014/TTofScal2014Unpacker.cxx +++ /dev/null @@ -1,262 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TTofScal2014Unpacker ----- -// ----- Created 19/04/2014 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ - -#include "TTofScal2014Unpacker.h" - -// TOF headers -#include "TofDef.h" -#include "TMbsUnpackTofPar.h" -#include "TofScal2014Def.h" -#include "TofScalerDef.h" -#include "TTofScalerBoard.h" - -// FAIR headers -#include "FairRootManager.h" -#include "FairLogger.h" -#include "TString.h" - -// ROOT headers -#include "TClonesArray.h" -#include "TH1.h" -#include "TROOT.h" -#include "TDirectory.h" - -TTofScal2014Unpacker::TTofScal2014Unpacker(): - fParUnpack(0), - fuNbScal2014(0), - fScalerBoardCollection(NULL), - fhScalers(), - fhScalersAnd(), - bFirstEvent(kTRUE), - fvuFirstScalers(), - fvuFirstScalersAnd() -{ -} -TTofScal2014Unpacker::TTofScal2014Unpacker( TMbsUnpackTofPar * parIn ): - fParUnpack( parIn ), - fuNbScal2014( parIn->GetNbActiveBoards( tofMbs::scaler2014 ) ), - fScalerBoardCollection(NULL), - fhScalers(), - fhScalersAnd(), - bFirstEvent(kTRUE), - fvuFirstScalers(), - fvuFirstScalersAnd() -{ - // Recover first the ScalerBoard objects created in general unpacker class - FairRootManager* rootMgr = FairRootManager::Instance(); - - fScalerBoardCollection = (TClonesArray*) rootMgr->GetObject("TofRawScalers"); - if(NULL == fScalerBoardCollection) - { - LOG(warn)<<"TTofScal2014Unpacker::TTofScal2014Unpacker : no Raw Scalers array! "; - fuNbScal2014 = 0; - } // if(NULL == fScalerBoardCollection) - else - { - // Initialize the ScalerBoard object with each Scal2014 characteristics - TTofScalerBoard * fScalerBoard = NULL; - - // TRIGLOG is always considered as first scaler board! - UInt_t uTrigOff = 0; - if( kTRUE == fParUnpack->WithActiveTriglog() ) - uTrigOff = 1; - - LOG(debug)<<"TTofScal2014Unpacker::TTofScal2014Unpacker : Initialize objects for " - <<fuNbScal2014<<" boards "; - - for( UInt_t uScalIndex = 0; uScalIndex < fuNbScal2014; uScalIndex++) - { - // TRIGLOG always first scaler board! - fScalerBoard = (TTofScalerBoard*) fScalerBoardCollection->ConstructedAt( uScalIndex + uTrigOff); - if( tofscaler::undef == fScalerBoard->GetScalerType() ) - fScalerBoard->SetType( tofscaler::scaler2014 ); - } // for( UInt_t uScalIndex = 0; uScalIndex < fuNbScal2014; uScalIndex++) - } // else of if(NULL == fScalerBoardCollection) - bFirstEvent = kTRUE; -} -TTofScal2014Unpacker::~TTofScal2014Unpacker() -{ -// DeleteHistos(); -} - -void TTofScal2014Unpacker::Clear(Option_t */*option*/) -{ - fParUnpack = NULL; - fuNbScal2014 = 0; - fScalerBoardCollection = NULL; -} - -void TTofScal2014Unpacker::ProcessScal2014( Int_t iScalIndex, UInt_t* pMbsData, UInt_t uLength ) -{ - if( (iScalIndex<0) || (fuNbScal2014 <= static_cast<UInt_t>(iScalIndex) ) ) - { - LOG(error)<<"Error Scaler2014 number "<<iScalIndex<<" out of bound (max "<<fuNbScal2014<<") "; - return; - } - - // TRIGLOG is always considered as first scaler board! - TTofScalerBoard * fScalerBoard = NULL; - if( kTRUE == fParUnpack->WithActiveTriglog() ) - { - // First check if ScalerBoard object for Triglog was created already - if( 2 + iScalIndex <= fScalerBoardCollection->GetEntriesFast() ) - fScalerBoard = (TTofScalerBoard*) fScalerBoardCollection->ConstructedAt( 1 + iScalIndex, "C"); - else for( Int_t iScalBd = fScalerBoardCollection->GetEntriesFast(); iScalBd <= 1 + iScalIndex; iScalBd++ ) - fScalerBoard = (TTofScalerBoard*) fScalerBoardCollection->ConstructedAt( iScalBd); - } // if( kTRUE == fParUnpack->WithActiveTriglog() ) - else fScalerBoard = (TTofScalerBoard*) fScalerBoardCollection->ConstructedAt( iScalIndex, "C"); - - UInt_t uIndx = 0; - -/* UInt_t uNbScalCh = scaler2014::kuNbChan;*/ - - if( tofscaler::undef == fScalerBoard->GetScalerType() ) - fScalerBoard->SetType( tofscaler::scaler2014 ); - - // First readout scalers for the input channels - for( UInt_t uScalerInd=0; uScalerInd < scaler2014::kuNbChanIn; uScalerInd++) - { - UInt_t uValue = (UInt_t)( uIndx < uLength ? pMbsData[uIndx] : 0 ); - uIndx++; - fScalerBoard->SetScalerValue(uScalerInd, uValue); - } // for( UInt_t uScalerInd=0; uScalerInd < scaler2014::kuNbChanIn; uScalerInd++) - - // Then readout the reference clock scaler - fScalerBoard->SetRefClk( pMbsData[uIndx] ); - uIndx++; - - // Finally readout the scalers for the AND of the input signal pairs - for( UInt_t uScalerInd=0; uScalerInd < scaler2014::kuNbChanAnd; uScalerInd++) - { - UInt_t uValue = (UInt_t)( uIndx < uLength ? pMbsData[uIndx] : 0 ); - uIndx++; - fScalerBoard->SetScalerValue( scaler2014::kuNbChanIn + uScalerInd, uValue); - } // for( UInt_t uScalerInd=0; uScalerInd < scaler2014::kuNbChanAnd; uScalerInd++) - - if( uLength != uIndx ) - LOG(error)<<" TTofScal2014Unpacker::ProcessScal2014 => Scaler 2014 #" - <<fParUnpack->GetActiveToAllTypeInd(iScalIndex, tofMbs::scaler2014) - <<" unpacking length missmatch: length " - <<uLength<<" VS index "<<uIndx; - - fScalerBoard->SetPresentFlag( kTRUE ); - - LOG(debug2)<<" Scaler 2014 #"<<fParUnpack->GetActiveToAllTypeInd(iScalIndex, tofMbs::scaler2014) - <<" finished"; - return; -} - -// Histogram management -// TODO: maybe add some options to control which histograms are -// created and filed (memory management) -void TTofScal2014Unpacker::CreateHistos() -{ - LOG(debug)<<"TTofScal2014Unpacker::CreateHistos : Create histos for " - <<fuNbScal2014<<" boards "; - - TDirectory * oldir = gDirectory; // <= To prevent histos from being sucked in by the param file of the TRootManager! - gROOT->cd(); // <= To prevent histos from being su - - fhScalers.resize(fuNbScal2014, NULL); - fvuFirstScalers.resize(fuNbScal2014); - - fhScalersAnd.resize(fuNbScal2014, NULL); - fvuFirstScalersAnd.resize(fuNbScal2014); - - for( UInt_t uScalIndex = 0; uScalIndex < fuNbScal2014; uScalIndex++) - { - fhScalers[uScalIndex] = new TH1I( - Form("tof_%s_%02u_scalersIn", tofscaler::ksTdcHistName[ tofscaler::scaler2014 ].Data(), uScalIndex ), - "Counts per scaler channel; Channel []; Total counts []", scaler2014::kuNbChanIn, 0., scaler2014::kuNbChanIn); - - fvuFirstScalers[uScalIndex].resize( scaler2014::kuNbChanIn ); - for( UInt_t uScalerInd=0; uScalerInd < scaler2014::kuNbChanIn; uScalerInd++) - fvuFirstScalers[uScalIndex][uScalerInd] = 0; - - fhScalersAnd[uScalIndex] = new TH1I( - Form("tof_%s_%02u_scalersAnd", tofscaler::ksTdcHistName[ tofscaler::scaler2014 ].Data(), uScalIndex ), - "Counts per scaler channel; Channel []; Total counts []", scaler2014::kuNbChanAnd, 0., scaler2014::kuNbChanAnd); - - fvuFirstScalersAnd[uScalIndex].resize( scaler2014::kuNbChanAnd ); - for( UInt_t uScalerInd=0; uScalerInd < scaler2014::kuNbChanAnd; uScalerInd++) - fvuFirstScalersAnd[uScalIndex][uScalerInd] = 0; - - } // for( UInt_t uScalIndex = 0; uScalIndex < fuNbScal2014; uScalIndex++) - - gDirectory->cd( oldir->GetPath() ); // <= To prevent histos from being sucked in by the param file of the TRootManager! - - LOG(debug)<<"TTofScal2014Unpacker::CreateHistos : Created histos for " - <<fuNbScal2014<<" boards "; -} -void TTofScal2014Unpacker::FillHistos() -{ - LOG(debug)<<"TTofScal2014Unpacker::FillHistos : Fill histos for " - <<fuNbScal2014<<" boards "; - - for( UInt_t uScalIndex = 0; uScalIndex < fuNbScal2014; uScalIndex++) - { - - // TRIGLOG is always considered as first scaler board! - TTofScalerBoard * fScalerBoard; - if( kTRUE == fParUnpack->WithActiveTriglog() ) - fScalerBoard = (TTofScalerBoard*) fScalerBoardCollection->ConstructedAt( 1 + uScalIndex ); - else fScalerBoard = (TTofScalerBoard*) fScalerBoardCollection->ConstructedAt( 0 + uScalIndex ); - - if( kFALSE == fScalerBoard->IsUpdated() ) - continue; - - for( UInt_t uScalerInd=0; uScalerInd < scaler2014::kuNbChanIn; uScalerInd++) - { - if( kTRUE == bFirstEvent ) - fvuFirstScalers[uScalIndex][uScalerInd] = fScalerBoard->GetScalerValue( uScalerInd ); - else fhScalers[uScalIndex]->SetBinContent( 1 + uScalerInd, fScalerBoard->GetScalerValue( uScalerInd ) - - fvuFirstScalers[uScalIndex][uScalerInd] ); - } // for( UInt_t uScalerInd=0; uScalerInd < scaler2014::kuNbChanIn; uScalerInd++) - for( UInt_t uScalerInd=0; uScalerInd < scaler2014::kuNbChanAnd; uScalerInd++) - { - if( kTRUE == bFirstEvent ) - fvuFirstScalersAnd[uScalIndex][uScalerInd] = fScalerBoard->GetScalerValue( - scaler2014::kuNbChanIn + uScalerInd ); - else fhScalersAnd[uScalIndex]->SetBinContent( 1 + uScalerInd, - fScalerBoard->GetScalerValue( scaler2014::kuNbChanIn +uScalerInd ) - - fvuFirstScalersAnd[uScalIndex][uScalerInd] ); - } // for( UInt_t uScalerInd=0; uScalerInd < scaler2014::kuNbChanAnd; uScalerInd++) - } // for( UInt_t uScalIndex = 0; uScalIndex < fuNbScal2014; uScalIndex++) - if( kTRUE == bFirstEvent ) - bFirstEvent = kFALSE; - - LOG(debug)<<"TTofScal2014Unpacker::FillHistos : Filled histos for " - <<fuNbScal2014<<" boards "; -} -void TTofScal2014Unpacker::WriteHistos( TDirectory* inDir) -{ - TDirectory * oldir = gDirectory; - - LOG(debug)<<"TTofScal2014Unpacker::WriteHistos : Write histos for " - <<fuNbScal2014<<" boards "; - for( UInt_t uScalIndex = 0; uScalIndex < fuNbScal2014; uScalIndex++) - { - TDirectory *cdScal2014 = inDir->mkdir( - Form( "Unp_%s_%02u", tofscaler::ksTdcHistName[ tofscaler::scaler2014 ].Data(), uScalIndex ) ); - cdScal2014->cd(); // make the "Unp_Scal2014" directory the current directory - fhScalers[uScalIndex]->Write(); - fhScalersAnd[uScalIndex]->Write(); - } // for( UInt_t uScalIndex = 0; uScalIndex < fuNbScal2014; uScalIndex++) - - gDirectory->cd( oldir->GetPath() ); -} -void TTofScal2014Unpacker::DeleteHistos() -{ - // not sure if it will not make problems for seeing them - // => for now just delete histograming variables - - for( UInt_t uScalIndex = 0; uScalIndex < fuNbScal2014; uScalIndex++) - { - fvuFirstScalers[uScalIndex].clear(); - fvuFirstScalersAnd[uScalIndex].clear(); - } // for( UInt_t uScalIndex = 0; uScalIndex < fuNbScal2014; uScalIndex++) - fvuFirstScalers.clear(); - fvuFirstScalersAnd.clear(); -} diff --git a/beamtime/tof/scalers/scal2014/TTofScal2014Unpacker.h b/beamtime/tof/scalers/scal2014/TTofScal2014Unpacker.h deleted file mode 100644 index 2c2f3f1916e2a9f7065362d6c08c7a89b0115967..0000000000000000000000000000000000000000 --- a/beamtime/tof/scalers/scal2014/TTofScal2014Unpacker.h +++ /dev/null @@ -1,56 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TTofScal2014Unpacker ----- -// ----- Created 19/04/2014 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ - -#ifndef TTOFSCAL2014UNPACKER_H_ -#define TTOFSCAL2014UNPACKER_H_ - -#include "TObject.h" - -#include <vector> - -class TMbsUnpackTofPar; - -class TClonesArray; -class TH1; -class TH2; -class TDirectory; - -class TTofScal2014Unpacker : public TObject -{ - public: - TTofScal2014Unpacker(); - TTofScal2014Unpacker( TMbsUnpackTofPar * parIn ); - ~TTofScal2014Unpacker(); - - virtual void Clear(Option_t *option); - - void ProcessScal2014( Int_t iScalIndex, UInt_t* pMbsData, UInt_t uLength ); - - void CreateHistos(); - void FillHistos(); - void WriteHistos( TDirectory* inDir); - void DeleteHistos(); - - private: - // no default Copy constructor and = OP as class not meant to be copied - TTofScal2014Unpacker(const TTofScal2014Unpacker&); - TTofScal2014Unpacker& operator=(const TTofScal2014Unpacker&); - - TMbsUnpackTofPar * fParUnpack; - UInt_t fuNbScal2014; - TClonesArray * fScalerBoardCollection; - - // Histograms - std::vector<TH1 *> fhScalers; //! last value of each scaler = integrated counts - std::vector<TH1 *> fhScalersAnd; //! last value of each AND scaler = integrated counts - - Bool_t bFirstEvent; - std::vector< std::vector< UInt_t > > fvuFirstScalers; //! First value of each scaler <= integrated counts - std::vector< std::vector< UInt_t > > fvuFirstScalersAnd; //! First value of each AND scaler <= integrated counts - - ClassDef(TTofScal2014Unpacker, 1) -}; - -#endif // TTOFSCAL2014UNPACKER_H_ diff --git a/beamtime/tof/scalers/scal2014/TofScal2014Def.h b/beamtime/tof/scalers/scal2014/TofScal2014Def.h deleted file mode 100644 index fb903d30914e2f22b835e97d81e7263f4b14f2f2..0000000000000000000000000000000000000000 --- a/beamtime/tof/scalers/scal2014/TofScal2014Def.h +++ /dev/null @@ -1,24 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TofScal2014Def ----- -// ----- Created 19/04/2014 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ - -#ifndef TOFSCAL2014DEF_H_ -#define TOFSCAL2014DEF_H_ - -#include "TString.h" - -/******** VULOM3:ScalOrAnd Gsi April 2014 data unpacking definitions *********/ - -namespace scaler2014 -{ - const UInt_t kuNbScalers = 1; - const UInt_t kuNbChanIn = 32; - const UInt_t kuNbChanAnd = 16; - const UInt_t kuNbChan = kuNbChanIn + kuNbChanAnd; - const Double_t kdRefClkFreq = 781250.0; - const Double_t kdEvoRange = 3*3600; // s - const Double_t kdEvoBin = 1; // s -} - -#endif // TOFSCAL2014DEF_H_ diff --git a/beamtime/tof/scalers/scalormu/TTofScomUnpacker.cxx b/beamtime/tof/scalers/scalormu/TTofScomUnpacker.cxx deleted file mode 100644 index c03d1c786ec64e263ff83072218e31d8fc8ad48b..0000000000000000000000000000000000000000 --- a/beamtime/tof/scalers/scalormu/TTofScomUnpacker.cxx +++ /dev/null @@ -1,247 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TTofScomUnpacker ----- -// ----- Created 03/07/2013 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ - -#include "TTofScomUnpacker.h" - -// TOF headers -#include "TofDef.h" -#include "TMbsUnpackTofPar.h" -#include "TofScomDef.h" -#include "TofScalerDef.h" -#include "TTofScalerBoard.h" - -// FAIR headers -#include "FairRootManager.h" -#include "FairLogger.h" -#include "TString.h" - -// ROOT headers -#include "TClonesArray.h" -#include "TH1.h" -#include "TROOT.h" -#include "TDirectory.h" - -TTofScomUnpacker::TTofScomUnpacker(): - fParUnpack(0), - fuNbScom(0), - fScalerBoardCollection(NULL), - fhScalers(), - bFirstEvent(kTRUE), - fvuFirstScalers() -{ -} -TTofScomUnpacker::TTofScomUnpacker( TMbsUnpackTofPar * parIn ): - fParUnpack( parIn ), - fuNbScom( parIn->GetNbActiveBoards( tofMbs::scalormu ) ), - fScalerBoardCollection(NULL), - fhScalers(), - bFirstEvent(kTRUE), - fvuFirstScalers() -{ - // Recover first the ScalerBoard objects created in general unpacker class - FairRootManager* rootMgr = FairRootManager::Instance(); - - fScalerBoardCollection = (TClonesArray*) rootMgr->GetObject("TofRawScalers"); - if(NULL == fScalerBoardCollection) - { - LOG(warn)<<"TTofScomUnpacker::TTofScomUnpacker : no Raw Scalers array! "; - fuNbScom = 0; - } // if(NULL == fScalerBoardCollection) - else - { - // Intialize the ScalerBoard object with each SCOM characteristics - // TODO: use VME matrix instead of fixed Scalormu types! - TTofScalerBoard * fScalerBoard = NULL; - - // TRIGLOG is always considered as first scaler board! - UInt_t uTrigOff = 0; - if( kTRUE == fParUnpack->WithActiveTriglog() ) - uTrigOff = 1; - - if( 0 < fuNbScom ) - { - fScalerBoard = (TTofScalerBoard*) fScalerBoardCollection->ConstructedAt(0 + uTrigOff); // TRIGLOG always first scaler board! - if( tofscaler::undef == fScalerBoard->GetScalerType() ) - fScalerBoard->SetType( tofscaler::scalormu ); - } // if( 0 < fuNbScom ) - if( 1 < fuNbScom ) - { - fScalerBoard = (TTofScalerBoard*) fScalerBoardCollection->ConstructedAt(1 + uTrigOff); // TRIGLOG always first scaler board! - if( tofscaler::undef == fScalerBoard->GetScalerType() ) - fScalerBoard->SetType( tofscaler::scalormubig ); - } // if( 1 < fuNbScom ) - } // else of if(NULL == fScalerBoardCollection) - bFirstEvent = kTRUE; -} -TTofScomUnpacker::~TTofScomUnpacker() -{ - DeleteHistos(); -} - -void TTofScomUnpacker::Clear(Option_t */*option*/) -{ - fParUnpack = NULL; - fuNbScom = 0; - fScalerBoardCollection = NULL; -} - -void TTofScomUnpacker::ProcessScom( Int_t iScomIndex, UInt_t* pMbsData, UInt_t uLength ) -{ - if( (iScomIndex<0) || (fuNbScom <= static_cast<UInt_t>(iScomIndex) ) ) - { - LOG(error)<<"Error ScalOrMu number "<<iScomIndex<<" out of bound (max "<<fuNbScom<<") "; - return; - } - - // TRIGLOG is always considered as first scaler board! - TTofScalerBoard * fScalerBoard = NULL; - if( kTRUE == fParUnpack->WithActiveTriglog() ) - { - // First check if ScalerBoard object for Triglog was created already - if( 2+iScomIndex <= fScalerBoardCollection->GetEntriesFast() ) - fScalerBoard = (TTofScalerBoard*) fScalerBoardCollection->ConstructedAt( 1 + iScomIndex, "C"); - else for( Int_t iScalBd = fScalerBoardCollection->GetEntriesFast(); iScalBd <= 1 + iScomIndex; iScalBd++ ) - fScalerBoard = (TTofScalerBoard*) fScalerBoardCollection->ConstructedAt( iScalBd); - } // if( kTRUE == fParUnpack->WithActiveTriglog() ) - else fScalerBoard = (TTofScalerBoard*) fScalerBoardCollection->ConstructedAt( iScomIndex, "C"); - - UInt_t uIndx = 0; - - UInt_t uNbScalCh = 0; - if( 0 == iScomIndex ) - { - if( tofscaler::undef == fScalerBoard->GetScalerType() ) - fScalerBoard->SetType( tofscaler::scalormu ); - uNbScalCh = scalormu::kuNbChan; - } - else if( 1 == iScomIndex ) - { - if( tofscaler::undef == fScalerBoard->GetScalerType() ) - fScalerBoard->SetType( tofscaler::scalormubig ); - uNbScalCh = scalormuBig::kuNbChan; - } - else uNbScalCh = 0; - - for( UInt_t uScalerInd=0; uScalerInd < uNbScalCh; uScalerInd++) - { - // Check is needed to analyse old data with the early version used for tests - // October 2012: Only 1 version of the board, 16 channels, testing concept, need clock from TRIGLOG for ref. - // November 2012: 24 channel version for BUC + small HD (#0), 32 channel version for big HD (#2), both include reference clock - UInt_t uValue = (UInt_t)( uIndx < uLength ? pMbsData[uIndx] : 0 ); - uIndx++; - fScalerBoard->SetScalerValue(uScalerInd, uValue); - } // for( UInt_t uScalerInd=0; uScalerInd < uNbScalCh; uScalerInd++) - if( uIndx < uLength) - { - // Reference clock is inside Tof MBS event only since November 2012 - fScalerBoard->SetRefClk( pMbsData[uIndx] ); - uIndx++; - } // if( uIndx < uLength) - - fScalerBoard->SetPresentFlag( kTRUE ); - - LOG(debug2)<<" ScalOrMu #"<<fParUnpack->GetActiveToAllTypeInd(iScomIndex, tofMbs::scalormu)<<" finished"; - return; -} - -// Histogram management -// TODO: maybe add some options to control which histograms are -// created and filed (memory management) -void TTofScomUnpacker::CreateHistos() -{ - TDirectory * oldir = gDirectory; // <= To prevent histos from being sucked in by the param file of the TRootManager! - gROOT->cd(); // <= To prevent histos from being sucked in by the param file of the TRootManager! - - if( 0 < fuNbScom ) - { - fhScalers.resize(fuNbScom); - fvuFirstScalers.resize(fuNbScom); - - fhScalers[0] = new TH1I( Form("tof_%s_scalers", tofscaler::ksTdcHistName[ tofscaler::scalormu ].Data() ), - "Counts per scaler channel; Channel []; Total counts []", scalormu::kuNbChan, 0, scalormu::kuNbChan); - fvuFirstScalers[0].resize( scalormu::kuNbChan ); - for( UInt_t uScalerInd=0; uScalerInd < scalormu::kuNbChan; uScalerInd++) - fvuFirstScalers[0][uScalerInd] = 0; - - if( 1 < fuNbScom ) - { - fhScalers[1] = new TH1I( Form("tof_%s_scalers", tofscaler::ksTdcHistName[ tofscaler::scalormubig ].Data() ), - "Counts per scaler channel; Channel []; Total counts []", scalormuBig::kuNbChan, 0, scalormuBig::kuNbChan); - fvuFirstScalers[1].resize( scalormu::kuNbChan ); - for( UInt_t uScalerInd=0; uScalerInd < scalormuBig::kuNbChan; uScalerInd++) - fvuFirstScalers[1][uScalerInd] = 0; - } - } // if( 0 < fuNbScom ) - - gDirectory->cd( oldir->GetPath() ); // <= To prevent histos from being sucked in by the param file of the TRootManager! -} -void TTofScomUnpacker::FillHistos() -{ - if( 0 < fuNbScom ) - { - // TRIGLOG is always considered as first scaler board! - TTofScalerBoard * fScalerBoard; - if( kTRUE == fParUnpack->WithActiveTriglog() ) - fScalerBoard = (TTofScalerBoard*) fScalerBoardCollection->ConstructedAt( 1 ); - else fScalerBoard = (TTofScalerBoard*) fScalerBoardCollection->ConstructedAt( 0 ); - - for( UInt_t uScalerInd=0; uScalerInd < scalormu::kuNbChan; uScalerInd++) - { - if( kTRUE == bFirstEvent ) - fvuFirstScalers[0][uScalerInd] = fScalerBoard->GetScalerValue( uScalerInd ); - else fhScalers[0]->SetBinContent( 1 + uScalerInd, fScalerBoard->GetScalerValue( uScalerInd ) - - fvuFirstScalers[0][uScalerInd] ); - } // for( UInt_t uScalerInd=0; uScalerInd < scalormu::kuNbChan; uScalerInd++) - - if( 1 < fuNbScom ) - { - if( kTRUE == fParUnpack->WithActiveTriglog() ) - fScalerBoard = (TTofScalerBoard*) fScalerBoardCollection->ConstructedAt( 2 ); - else fScalerBoard = (TTofScalerBoard*) fScalerBoardCollection->ConstructedAt( 1 ); - - for( UInt_t uScalerInd=0; uScalerInd < scalormu::kuNbChan; uScalerInd++) - { - if( kTRUE == bFirstEvent ) - fvuFirstScalers[1][uScalerInd] = fScalerBoard->GetScalerValue( uScalerInd ); - else fhScalers[1]->SetBinContent( 1 + uScalerInd, fScalerBoard->GetScalerValue( uScalerInd ) - - fvuFirstScalers[1][uScalerInd] ); - } // for( UInt_t uScalerInd=0; uScalerInd < scalormu::kuNbChan; uScalerInd++) - } // if( 1 < fuNbScom ) - - if( kTRUE == bFirstEvent ) - bFirstEvent = kFALSE; - } // if( 0 < fuNbScom ) -} -void TTofScomUnpacker::WriteHistos( TDirectory* inDir) -{ - TDirectory * oldir = gDirectory; - - if( 0 < fuNbScom ) - { - TDirectory *cdScom = inDir->mkdir( Form( "Unp_%s", tofscaler::ksTdcHistName[ tofscaler::scalormu ].Data() ) ); - cdScom->cd(); // make the "Unp_scom" directory the current directory - fhScalers[0]->Write(); - - if( 1 < fuNbScom ) - { - TDirectory *cdScomBig = inDir->mkdir( Form( "Unp_%s", tofscaler::ksTdcHistName[ tofscaler::scalormubig ].Data() ) ); - cdScomBig->cd(); // make the "Unp_scombig" directory the current directory - fhScalers[1]->Write(); - } // if( 1 < fuNbScom ) - } // if( 0 < fuNbScom ) - gDirectory->cd( oldir->GetPath() ); -} -void TTofScomUnpacker::DeleteHistos() -{ - // not sure if it will not make problems for seeing them - // => for now just delete histograming variables - if( 0 < fuNbScom ) - { - fvuFirstScalers[0].clear(); - if( 1 < fuNbScom ) - fvuFirstScalers[1].clear(); - } // if( 0 < fuNbScom ) - fvuFirstScalers.clear(); -} diff --git a/beamtime/tof/scalers/scalormu/TTofScomUnpacker.h b/beamtime/tof/scalers/scalormu/TTofScomUnpacker.h deleted file mode 100644 index e48c71a585e427985dacb41b2c43639cccbf66c3..0000000000000000000000000000000000000000 --- a/beamtime/tof/scalers/scalormu/TTofScomUnpacker.h +++ /dev/null @@ -1,54 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TTofScomUnpacker ----- -// ----- Created 03/07/2013 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ - -#ifndef TTOFSCOMUNPACKER_H_ -#define TTOFSCOMUNPACKER_H_ - -#include "TObject.h" - -#include <vector> - -class TMbsUnpackTofPar; - -class TClonesArray; -class TH1; -class TH2; -class TDirectory; - -class TTofScomUnpacker : public TObject -{ - public: - TTofScomUnpacker(); - TTofScomUnpacker( TMbsUnpackTofPar * parIn ); - ~TTofScomUnpacker(); - - virtual void Clear(Option_t *option); - - void ProcessScom( Int_t iScomIndex, UInt_t* pMbsData, UInt_t uLength ); - - void CreateHistos(); - void FillHistos(); - void WriteHistos( TDirectory* inDir); - void DeleteHistos(); - - private: - // no default Copy constructor and = OP as class not meant to be copied - TTofScomUnpacker(const TTofScomUnpacker&); - TTofScomUnpacker& operator=(const TTofScomUnpacker&); - - TMbsUnpackTofPar * fParUnpack; - UInt_t fuNbScom; - TClonesArray * fScalerBoardCollection; - - // Histograms - std::vector<TH1 *> fhScalers; //! last value of each scaler = integrated counts - - Bool_t bFirstEvent; - std::vector< std::vector< UInt_t > > fvuFirstScalers; //! First value of each scaler <= integrated counts - - ClassDef(TTofScomUnpacker, 1) -}; - -#endif // TTOFSCOMUNPACKER_H_ diff --git a/beamtime/tof/scalers/scalormu/TofScomDef.h b/beamtime/tof/scalers/scalormu/TofScomDef.h deleted file mode 100644 index 2c1488daf8c0ccdd9965cee75deef1f4f3293a8d..0000000000000000000000000000000000000000 --- a/beamtime/tof/scalers/scalormu/TofScomDef.h +++ /dev/null @@ -1,29 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TofScomDef ----- -// ----- Created 21/06/2013 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ - -#ifndef TOFSCOMDEF_H_ -#define TOFSCOMDEF_H_ - -#include "TString.h" - -/******************** VULOM3:ScalOrMu data unpacking definitions *************/ -namespace scalormu -{ - const UInt_t kuNbScalers = 1; - const UInt_t kuNbChan = 24; - const Double_t kdRefClkFreq = 781250.0; - const Double_t kdEvoRange = 3600; // s - const Double_t kdEvoBin = 0.1; // s -} -namespace scalormuBig -{ - const UInt_t kuNbScalers = 1; - const UInt_t kuNbChan = 32; - const Double_t kdRefClkFreq = 781250.0; - const Double_t kdEvoRange = 3600; // s - const Double_t kdEvoBin = 0.1; // s -} - -#endif // TOFSCOMDEF_H_ diff --git a/beamtime/tof/scalers/triglog/TTofTriglogBoard.cxx b/beamtime/tof/scalers/triglog/TTofTriglogBoard.cxx deleted file mode 100644 index 31c28afaa5a6cdd119d898b7b026ca76c81159b0..0000000000000000000000000000000000000000 --- a/beamtime/tof/scalers/triglog/TTofTriglogBoard.cxx +++ /dev/null @@ -1,51 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TTofTriglogBoard ----- -// ----- Created 21/06/2013 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ - -#include "TTofTriglogBoard.h" - -// FAIR headers -#include "FairLogger.h" - -// ROOT headers - -// C/C++ headers - -/************************** TTofTriglogBoard ****************************/ -TTofTriglogBoard::TTofTriglogBoard(): - fbTriglogFoundInEvent(kFALSE), - fMbsTimeSecs(0), - fMbsTimeMillisec(0), - fVulomSyncNumber(0), - fVulomTriggerPattern(0), - fTriglogInputPattern(0), - fTriglogReferenceClock(0) -{ -} -TTofTriglogBoard::TTofTriglogBoard( UInt_t uSec, UInt_t uMilSec, UInt_t uSyncNb, - UInt_t uTrigPat, UInt_t uInpPat, UInt_t uRefClk ): - fbTriglogFoundInEvent(kFALSE), - fMbsTimeSecs(uSec), - fMbsTimeMillisec(uMilSec), - fVulomSyncNumber(uSyncNb), - fVulomTriggerPattern(uTrigPat), - fTriglogInputPattern(uInpPat), - fTriglogReferenceClock(uRefClk) -{ -} -TTofTriglogBoard::~TTofTriglogBoard() -{ -} - -void TTofTriglogBoard::Clear(Option_t *option) -{ - TObject::Clear( option ); - fbTriglogFoundInEvent = kFALSE; - fMbsTimeSecs = 0; - fMbsTimeMillisec = 0; - fVulomSyncNumber = 0; - fVulomTriggerPattern = 0; - fTriglogInputPattern = 0; - fTriglogReferenceClock = 0; -} diff --git a/beamtime/tof/scalers/triglog/TTofTriglogBoard.h b/beamtime/tof/scalers/triglog/TTofTriglogBoard.h deleted file mode 100644 index 596652bfeb28da8654c23a58af222763b5394c27..0000000000000000000000000000000000000000 --- a/beamtime/tof/scalers/triglog/TTofTriglogBoard.h +++ /dev/null @@ -1,62 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TTofTriglogBoard ----- -// ----- Created 21/06/2013 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ - -#ifndef TTOFTRIGLOGBOARD_H_ -#define TTOFTRIGLOGBOARD_H_ - -#include <vector> - -#include "TObject.h" - -class TTofTriglogBoard : public TObject -{ - public: - TTofTriglogBoard(); - TTofTriglogBoard( UInt_t uSec, UInt_t uMilSec, UInt_t uSyncNb, - UInt_t uTrigPat, UInt_t uInpPat = 0, UInt_t uRefClk = 0 ); - ~TTofTriglogBoard(); - - virtual void Clear(Option_t *option = ""); - - void SetPresentFlag( Bool_t bDataThere ) { fbTriglogFoundInEvent = bDataThere; }; - void SetMbsTimeSec( UInt_t uSec ) { fMbsTimeSecs = uSec; }; - void SetMbsTimeMilliSec( UInt_t uMilSec ) { fMbsTimeMillisec = uMilSec; }; - void SetSyncNb( UInt_t uSyncNb ) { fVulomSyncNumber = uSyncNb; }; - void SetTriggPatt( UInt_t uTrigPat ) { fVulomTriggerPattern = uTrigPat; }; - void SetInpPatt( UInt_t uInpPat ) { fTriglogInputPattern = uInpPat; }; - void SetRefClk( UInt_t uRefClk ) { fTriglogReferenceClock = uRefClk; }; - - Bool_t IsUpdated() const { return fbTriglogFoundInEvent; }; - UInt_t GetMbsTimeSec() const { return fMbsTimeSecs; }; - UInt_t GetMbsTimeMilliSec() const { return fMbsTimeMillisec; }; - UInt_t GetSyncNb() const { return fVulomSyncNumber; }; - UInt_t GetTriggPatt() const { return fVulomTriggerPattern; }; - UInt_t GetInpPatt() const { return fTriglogInputPattern; }; - UInt_t GetRefClk() const { return fTriglogReferenceClock; }; - - protected: - - private: - /* In GSI April 2014 beamtime some events mayb not contains any TRIGLOG data - * (TRB buffer flushing trigger) - */ - Bool_t fbTriglogFoundInEvent; - /* system time from mbs, seconds since 1970*/ - UInt_t fMbsTimeSecs; - /* system time from mbs, microseconds since fMbsTimeSecs*/ - UInt_t fMbsTimeMillisec; - /* vulom trigger sync number*/ - UInt_t fVulomSyncNumber; - /* vulom trigger pattern*/ - UInt_t fVulomTriggerPattern; - /* Triglog input pattern*/ - UInt_t fTriglogInputPattern; - /* Internal 781250 Hz reference clock for rates calculation */ - UInt_t fTriglogReferenceClock; - - ClassDef(TTofTriglogBoard, 1) -}; - -#endif // TTOFTRIGLOGBOARD_H_ diff --git a/beamtime/tof/scalers/triglog/TTofTriglogScalUnpacker.cxx b/beamtime/tof/scalers/triglog/TTofTriglogScalUnpacker.cxx deleted file mode 100644 index de1797683b1496a3bb1101f652acbb3d4436959d..0000000000000000000000000000000000000000 --- a/beamtime/tof/scalers/triglog/TTofTriglogScalUnpacker.cxx +++ /dev/null @@ -1,495 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TTofTriglogScalUnpacker ----- -// ----- Created 03/07/2013 by P.-A. Loizeau ----- -// ----- Adapted from TTriglogProc.cxx by S. Linev ----- -// ----- and TMbsCrateProc.cxx by P.-A. Loizeau ---- -// ------------------------------------------------------------------ - -#include "TTofTriglogScalUnpacker.h" - -// TOF headers -#include "TofDef.h" -#include "TMbsUnpackTofPar.h" -#include "TofTriglogDef.h" -#include "TofScalerDef.h" -#include "TTofTriglogBoard.h" -#include "TTofScalerBoard.h" - -// FAIR headers -#include "FairRootManager.h" -#include "FairLogger.h" -#include "TString.h" - -// ROOT headers -#include "TClonesArray.h" -#include "TH1.h" -#include "TROOT.h" -#include "TDirectory.h" -#include "TString.h" - -TTofTriglogScalUnpacker::TTofTriglogScalUnpacker(): - fParUnpack(0), - fScalerBoardCollection(NULL), - fuNbTriglogScal( 0 ), - fuTrigOff( 0 ), - fuTotalTriggerCount(), - fuFirstMbsTime(), - fuLastMbsTime(), - fuFirstScaler(), - fuLastScaler(), - fhScalers(), - fvuFirstScalers(), - fdFirstMbsTime(), - fdPrevMbsTime(), - fdCurrMbsTime(), - fuLastRefClk(), - fhRefClkRate(), - fhRefClkRateEvo(), - fTriglogBoardCollection(NULL), - fdEvoRangeUser(-1), - fdEvoBinSzUser(-1), - fhScalersCountsEvo() -{ -} -TTofTriglogScalUnpacker::TTofTriglogScalUnpacker( TMbsUnpackTofPar * parIn ): - fParUnpack( parIn ), - fScalerBoardCollection(NULL), - fuNbTriglogScal( parIn->GetNbActiveBoards( tofMbs::triglogscal ) ), - fuTrigOff( 0 ), - fuTotalTriggerCount(), - fuFirstMbsTime(), - fuLastMbsTime(), - fuFirstScaler(), - fuLastScaler(), - fhScalers(), - fvuFirstScalers(), - fdFirstMbsTime(), - fdPrevMbsTime(), - fdCurrMbsTime(), - fuLastRefClk(), - fhRefClkRate(), - fhRefClkRateEvo(), - fTriglogBoardCollection(NULL), - fdEvoRangeUser(-1), - fdEvoBinSzUser(-1), - fhScalersCountsEvo() -{ - // Some triglog board can be used as scaler board instead of trigger source - if( 0 < fuNbTriglogScal ) - { - // Recover first the TRIGLOG and SCALER board objects created in general unpacker class - FairRootManager* rootMgr = FairRootManager::Instance(); - - fScalerBoardCollection = (TClonesArray*) rootMgr->GetObject("TofRawScalers"); - if(NULL == fScalerBoardCollection) - { - LOG(warn)<<"TTofTriglogScalUnpacker::TTofTriglogScalUnpacker : no Raw Scalers array! "; - } // if(NULL == fScalerBoardCollection) - else - { - // Initialize the ScalerBoard object with TRIGLOG characteristics - TTofScalerBoard * fScalerBoard = NULL; - - // TRIGLOG is always considered as first scaler board! - fuTrigOff = 0; - if( kTRUE == fParUnpack->WithActiveTriglog() ) - { - fuTrigOff = 1; - fTriglogBoardCollection = (TClonesArray*) rootMgr->GetObject("TofTriglog"); - } // if( kTRUE == fParUnpack->WithActiveTriglog() ) - // There may be some simple scaler boards - fuTrigOff += parIn->GetNbActiveBoards( tofMbs::scaler2014 ); - fuTrigOff += parIn->GetNbActiveBoards( tofMbs::orgen ); - - LOG(debug)<<"TTofTriglogScalUnpacker::TTofTriglogScalUnpacker : Initialize objects for " - << fuNbTriglogScal << " Triglog boards used as scaler "; - - for( UInt_t uScalIndex = 0; uScalIndex < fuNbTriglogScal; uScalIndex++) - { - // TRIGLOG always first scaler board! - // SCALORMU are always next, followed by Triglog used as scalers! - fScalerBoard = (TTofScalerBoard*) fScalerBoardCollection->ConstructedAt( uScalIndex + fuTrigOff); - if( tofscaler::undef == fScalerBoard->GetScalerType() ) - fScalerBoard->SetType( tofscaler::triglogscal ); - } // for( UInt_t uScalIndex = 0; uScalIndex < fuNbTriglogScal; uScalIndex++) - } // else of if(NULL == fScalerBoardCollection) - - fuTotalTriggerCount.resize(fuNbTriglogScal); - fuFirstMbsTime.resize(fuNbTriglogScal); - fuLastMbsTime.resize(fuNbTriglogScal); - fuFirstScaler.resize(fuNbTriglogScal); - fuLastScaler.resize(fuNbTriglogScal); - fdFirstMbsTime.resize(fuNbTriglogScal); - fdPrevMbsTime.resize(fuNbTriglogScal); - fdCurrMbsTime.resize(fuNbTriglogScal); - fuLastRefClk.resize(fuNbTriglogScal); - for( UInt_t uScalIndex = 0; uScalIndex < fuNbTriglogScal; uScalIndex++) - { - // Initialize variable used in filling - fdFirstMbsTime[uScalIndex] = 0; - fdPrevMbsTime[uScalIndex] = -1; - fdCurrMbsTime[uScalIndex] = -1; - fuLastRefClk[uScalIndex] = 0; - fuTotalTriggerCount[uScalIndex] = 0; - fuFirstMbsTime[uScalIndex] = 0; - fuLastMbsTime[uScalIndex] = 0; - - fuFirstScaler[uScalIndex].resize(triglog::kuNbScalers); - fuLastScaler[uScalIndex].resize(triglog::kuNbScalers); - for( UInt_t uScaler = 0; uScaler < triglog::kuNbScalers; uScaler++) - { - fuFirstScaler[uScalIndex][uScaler].resize(triglog::kuNbChan); - fuLastScaler[uScalIndex][uScaler].resize(triglog::kuNbChan); - } // for( UInt_t uScaler = 0; uScaler <triglog::kuNbScalers; uScaler++) - } // for( UInt_t uScalIndex = 0; uScalIndex < fuNbTriglogScal; uScalIndex++) - } // if( 0 < fuNbTriglogScal ) - else LOG(error)<<"TTofTriglogScalUnpacker::TTofTriglogScalUnpacker => No TRIGLOG board active as scaler!!!!!" - <<" recheck your VME address matrix "; -} -TTofTriglogScalUnpacker::~TTofTriglogScalUnpacker() -{ - // Some triglog board can be used as scaler board instead of trigger source - if( 0 < fuNbTriglogScal ) - { - for( UInt_t uScalIndex = 0; uScalIndex < fuNbTriglogScal; uScalIndex++) - { - for( UInt_t uScaler = 0; uScaler <triglog::kuNbScalers; uScaler++) - { - fuFirstScaler[uScalIndex][uScaler].clear(); - fuLastScaler[uScalIndex][uScaler].clear(); - } // for( UInt_t uScaler = 0; uScaler <triglog::kuNbScalers; uScaler++) - fuFirstScaler[uScalIndex].clear(); - fuLastScaler[uScalIndex].clear(); - } // for( UInt_t uScalIndex = 0; uScalIndex < fuNbTriglogScal; uScalIndex++) - fuTotalTriggerCount.clear(); - fuFirstMbsTime.clear(); - fuLastMbsTime.clear(); - fuFirstScaler.clear(); - fuLastScaler.clear(); - } // if( 0 < fuNbTriglogScal ) - else LOG(error)<<"TTofTriglogScalUnpacker::~TTofTriglogScalUnpacker => No TRIGLOG board active as scaler!!!!!" - <<" recheck your VME address matrix "; - -// DeleteHistos(); -} - -void TTofTriglogScalUnpacker::Clear(Option_t */*option*/) -{ - fParUnpack = NULL; - fuNbTriglogScal = 0; - fScalerBoardCollection = NULL; -} - -void TTofTriglogScalUnpacker::ProcessTriglogScal( Int_t iTrigScalIndex, UInt_t* pMbsData, UInt_t uLength ) -{ - if( (iTrigScalIndex<0) || (fuNbTriglogScal <= static_cast<UInt_t>(iTrigScalIndex)) ) - { - LOG(error)<<"Error TriglogScal number "<<iTrigScalIndex<<" out of bound (max "<<fuNbTriglogScal<<") "; - return; - } - - // Getting output objects - // TRIGLOG always first scaler board! - TTofScalerBoard * fScalerBoard = NULL; - if( kTRUE == fParUnpack->WithActiveTriglog() ) - { - // First check if ScalerBoard object for Triglog was created already - // and check if ScalerBoard object for ScalOrMu14 were created already - if( 1 + static_cast<Int_t>(fuTrigOff) + iTrigScalIndex <= fScalerBoardCollection->GetEntriesFast() ) - fScalerBoard = (TTofScalerBoard*) fScalerBoardCollection->ConstructedAt( fuTrigOff + iTrigScalIndex, "C"); - else for( Int_t iScalBd = fScalerBoardCollection->GetEntriesFast(); iScalBd <= static_cast<Int_t>(fuTrigOff) + iTrigScalIndex; iScalBd++ ) - fScalerBoard = (TTofScalerBoard*) fScalerBoardCollection->ConstructedAt( iScalBd); - } // if( kTRUE == fParUnpack->WithActiveTriglog() ) - else fScalerBoard = (TTofScalerBoard*) fScalerBoardCollection->ConstructedAt( fuTrigOff + iTrigScalIndex, "C"); - - if( tofscaler::undef == fScalerBoard->GetScalerType() ) - fScalerBoard->SetType( tofscaler::triglogscal ); - - UInt_t uIndx = 0; - - // Jump TRIGLOG not scaler data - Int_t sync_num = pMbsData[uIndx]; -// fTriglogBoard->SetSyncNb( sync_num ); - uIndx++; - LOG(debug2)<<" ===================== TRIGLOG SCAL EVENT ============ " << sync_num % 0x1000000 ; -// fTriglogBoard->SetTriggPatt( (UInt_t) pMbsData[uIndx] ); - uIndx++; -// fTriglogBoard->SetMbsTimeSec( (UInt_t) pMbsData[uIndx] ); - UInt_t uMbsTime = (UInt_t) pMbsData[uIndx]; - uIndx++; - LOG(debug2)<<" TRIGLOG SCAL UNPACK test 0 "<< iTrigScalIndex ; -// fTriglogBoard->SetMbsTimeMilliSec( (UInt_t) pMbsData[uIndx] ); - UInt_t uMbsTimeMs = (UInt_t) pMbsData[uIndx]; - LOG(debug2)<<" TRIGLOG SCAL UNPACK test 0a "<< iTrigScalIndex ; - fdCurrMbsTime[iTrigScalIndex] = uMbsTime + uMbsTimeMs*1e-3; // BROKEN: Will not work as histo filling in different instance - uIndx++; - LOG(debug2)<<" TRIGLOG SCAL UNPACK test 1"; - - for( UInt_t uScaler = 0; uScaler < triglog::kuNbScalers; uScaler++) - { - // SL 20.10.11 MBS readout was changed and two more scalers were included - // to be able process old files, add this break condition; - - for( UInt_t uCh = 0; uCh < triglog::kuNbChan; uCh++) - { - // SL: put protection against different length of this subevent - // also trigger-pattern was not correctly counted - UInt_t uValue = (UInt_t)(uIndx < uLength ? pMbsData[uIndx] : 0); - uIndx++; - fScalerBoard->SetScalerValue( uCh, uValue, uScaler ); - } // for( UInt uCh = 0; uCh < triglog::kuNbChan; uCh++) { - } // for( UInt uScaler = 0; uScaler < triglog::kuNbScalers; uScaler++) - - LOG(debug2)<<" TRIGLOG SCAL UNPACK test 2"; - if( uIndx < uLength) - { - // Jump TRIGLOG not scaler data - // Input pattern is inside Tof MBS event only since August 2012 -// fTriglogBoard->SetInpPatt( pMbsData[uIndx] ); - uIndx++; - } // if( uIndx < uLength) - if( uIndx < uLength) - { - // Reference clock is inside Tof MBS event only since October 2012 - fScalerBoard->SetRefClk( pMbsData[uIndx] ); - uIndx++; - } // if( uIndx < uLength) - LOG(debug2)<<" TRIGLOG SCAL UNPACK finished"; - - fScalerBoard->SetPresentFlag( kTRUE ); - - UpdateStats( iTrigScalIndex, uMbsTime ); - - return; -} -void TTofTriglogScalUnpacker::UpdateStats( Int_t iTrigScalIndex, UInt_t uMbsTime ) -{ - if( (iTrigScalIndex<0) || (fuNbTriglogScal <= static_cast<UInt_t>(iTrigScalIndex)) ) - { - LOG(error)<<"Error TriglogScal number "<<iTrigScalIndex<<" out of bound (max "<<fuNbTriglogScal<<") "; - return; - } - // Some triglog board can be used as scaler board instead of trigger source - if( 0 < fuNbTriglogScal ) - { - // Getting output objects - // TRIGLOG always first scaler board! then ScalOrMu/Scal2014 - TTofScalerBoard * fScalerBoard = (TTofScalerBoard*) fScalerBoardCollection->At(fuTrigOff + iTrigScalIndex); - if( NULL == fScalerBoard ) - { - LOG(error)<<"TTofTriglogScalUnpacker::UpdateStats => Board objects not existing!!!!"; - LOG(error)<<"TTofTriglogScalUnpacker::UpdateStats => TTofScalerBoard = "<<fScalerBoard; - LOG(error)<<"TTofTriglogScalUnpacker::UpdateStats => Probably the TRIGLOG SCALER sub-event is not there in this event!"; - return; - } // if( | NULL == fScalerBoard ) - - // Preparing output at the end: - // MBS time is time in s since LINUX epoch (circa 1970) => never 0 except on first event! - for( UInt_t uScaler = 0; uScaler <triglog::kuNbScalers; uScaler++) - for( UInt_t uCh = 0; uCh < triglog::kuNbChan; uCh++) - { - fuLastScaler[iTrigScalIndex][uScaler][uCh] = fScalerBoard->GetScalerValue( uCh, uScaler); - if( fuFirstMbsTime[iTrigScalIndex] == 0 ) - fuFirstScaler[iTrigScalIndex][uScaler][uCh] = fuLastScaler[iTrigScalIndex][uScaler][uCh]; - } // for( UInt_t uCh = 0; uCh < triglog::kuNbChan; uCh++) - fuLastMbsTime[iTrigScalIndex] = uMbsTime; - if( 0 == fuFirstMbsTime[iTrigScalIndex] ) - fuFirstMbsTime[iTrigScalIndex] = fuLastMbsTime[iTrigScalIndex]; - } // if( 0 < fuNbTriglogScal ) - else LOG(error)<<"TTofTriglogScalUnpacker::UpdateStats => No TRIGLOG board active as scaler!!!!!" - <<" recheck your VME address matrix "; -} - -void TTofTriglogScalUnpacker::FinishTriglog( ) -{ - // Some triglog board can be used as scaler board instead of trigger source - if( 0 < fuNbTriglogScal ) - { - for( UInt_t uScalIndex = 0; uScalIndex < fuNbTriglogScal; uScalIndex++) - { - LOG(info)<<Form("-------- Triglog Scaler board %02u ----", uScalIndex); - Double_t dRuntime = fuLastMbsTime[uScalIndex] - fuFirstMbsTime[uScalIndex]; - LOG(info)<<Form("Total MBS run time %6.0f sec.", dRuntime); - - if( 0 < dRuntime ) - { - TString sLine = ""; - for( UInt_t uCh = 0; uCh < triglog::kuNbChan; uCh++) - { - sLine = Form(" Ch %2d", uCh ); - for( UInt_t uScaler = 0; uScaler <triglog::kuNbScalers; uScaler++) - sLine += Form(" %9u", fuLastScaler[uScalIndex][uScaler][uCh] - fuFirstScaler[uScalIndex][uScaler][uCh]); - LOG(info)<<sLine; - } // for( UInt_t uCh = 0; uCh < triglog::kuNbChan; uCh++) - - LOG(info)<<Form("---------------------------------------"); - - for( UInt_t uCh = 0; uCh < triglog::kuNbChan; uCh++) - { - sLine = Form(" Ch %2d", uCh ); - for( UInt_t uScaler = 0; uScaler <triglog::kuNbScalers; uScaler++) - sLine += Form(" %9.2f", (fuLastScaler[uScalIndex][uScaler][uCh] - fuFirstScaler[uScalIndex][uScaler][uCh])/dRuntime); - LOG(info)<<sLine; - } // for( UInt_t uCh = 0; uCh < triglog::kuNbChan; uCh++) - } // if( 0 < dRuntime ) - LOG(info)<<Form("---------------------------------------"); - } // for( UInt_t uScalIndex = 0; uScalIndex < fuNbTriglogScal; uScalIndex++) - } // if( 0 < fuNbTriglogScal ) - else LOG(error)<<"TTofTriglogScalUnpacker::FinishTriglog => No TRIGLOG board active as scaler!!!!!" - <<" recheck your VME address matrix "; -} - -// Histogram management -// TODO: maybe add some options to control which histograms are -// created and filed (memory management) -void TTofTriglogScalUnpacker::CreateHistos() -{ - // Some triglog board can be used as scaler board instead of trigger source - if( 0 < fuNbTriglogScal ) - { - TDirectory * oldir = gDirectory; // <= To prevent histos from being sucked in by the param file of the TRootManager! - gROOT->cd(); // <= To prevent histos from being sucked in by the param file of the TRootManager ! - - Double_t dEvoRange = triglog::kdEvoRange; - Double_t dEvoBinNb = triglog::kdEvoRange / triglog::kdEvoBin; - if( 0 < fdEvoRangeUser && 0 < fdEvoBinSzUser && fdEvoBinSzUser < fdEvoRangeUser ) - { - dEvoRange = fdEvoRangeUser; - dEvoBinNb = static_cast<Int_t>(fdEvoRangeUser) / static_cast<Int_t>(fdEvoBinSzUser); - LOG(info)<<"TTofTriglogScalUnpacker::CreateHistos => Set the scaler evolution plot with user range: " - << dEvoRange << " s/range " << fdEvoBinSzUser << " s/bin " << dEvoBinNb << " bins "; - } // if( 0 < fdEvoRangeUser && 0 < fdEvoBinSzUser && fdEvoBinSzUser < fdEvoRangeUser ) - - - fhRefClkRate.resize(fuNbTriglogScal); - fhRefClkRateEvo.resize(fuNbTriglogScal); - fhScalers.resize(fuNbTriglogScal); - fhScalersCountsEvo.resize(fuNbTriglogScal); - for( UInt_t uScalIndex = 0; uScalIndex < fuNbTriglogScal; uScalIndex++) - { - fhRefClkRate[uScalIndex] = new TH1I( Form("tof_%s_%02u_refclk", tofscaler::ksTdcHistName[ tofscaler::triglogscal ].Data(), - uScalIndex ), - "Rate of the reference clock; Freq. [Hz]", - (Int_t)(2*triglog::kdRefClkFreq/1000), 0.0 , 2*triglog::kdRefClkFreq ); - fhRefClkRateEvo[uScalIndex] = new TH1I( Form("tof_%s_%02u_refclk_evo", tofscaler::ksTdcHistName[ tofscaler::triglogscal ].Data(), - uScalIndex ), - "Reference clock counts per second; Time [s]; Counts []", 3600, 0.0, 3600 ); - - fhScalers[uScalIndex].resize(triglog::kuNbScalers); - fhScalersCountsEvo[uScalIndex].resize(triglog::kuNbScalers); - for( UInt_t uScaler = 0; uScaler <triglog::kuNbScalers; uScaler++) - { - fhScalers[uScalIndex][uScaler] = new TH1I( Form("tof_%s_%02u_scalers%02u", tofscaler::ksTdcHistName[ tofscaler::triglogscal ].Data(), - uScalIndex, uScaler ), - Form("Counts per scaler channel in scaler %02u; Channel []; Total counts []", uScaler), - triglog::kuNbChan, 0, triglog::kuNbChan); - fhScalersCountsEvo[uScalIndex][uScaler].resize(triglog::kuNbChan); - for( UInt_t uCh = 0; uCh < triglog::kuNbChan; uCh++) - fhScalersCountsEvo[uScalIndex][uScaler][uCh] = new TH1I( Form("tof_%s_%02u_scalers_evo_%02u_%02u", - tofscaler::ksTdcHistName[ tofscaler::triglogscal ].Data(), - uScalIndex, uScaler, uCh ), - Form("Channel %02d in scaler %02d counts evolution; Time [s]; Counts []", uCh, uScaler), - static_cast<Int_t>(dEvoBinNb), 0.0, dEvoRange ); - - } // for( UInt_t uScaler = 0; uScaler <triglog::kuNbScalers; uScaler++) - } // for( UInt_t uScalIndex = 0; uScalIndex < fuNbTriglogScal; uScalIndex++) - - gDirectory->cd( oldir->GetPath() ); // <= To prevent histos from being sucked in by the param file of the TRootManager! - } // if( 0 < fuNbTriglogScal ) - else LOG(error)<<"TTofTriglogScalUnpacker::CreateHistos => No TRIGLOG board active as scaler!!!!!" - <<" recheck your VME address matrix "; -} -void TTofTriglogScalUnpacker::FillHistos() -{ - // Some triglog board can be used as scaler board instead of trigger source - for( UInt_t uScalIndex = 0; uScalIndex < fuNbTriglogScal; uScalIndex++) - { - // Getting output objects - // TRIGLOG always first scaler board! then ScalOrMu/Scal2014 - TTofScalerBoard * fScalerBoard = (TTofScalerBoard*) fScalerBoardCollection->At(fuTrigOff + uScalIndex); - - if( NULL == fScalerBoard ) - { - LOG(error)<<"TTofTriglogScalUnpacker::FillHistos => Board objects not existing!!!!"; - LOG(error)<<"TTofTriglogScalUnpacker::FillHistos => TTofScalerBoard = "<<fScalerBoard; - LOG(error)<<"TTofTriglogScalUnpacker::FillHistos => Probably the TRIGLOG SCALER sub-event is not there in this event!"; - return; - } // if( NULL == fScalerBoard ) - - LOG(debug3)<<(fScalerBoardCollection->GetEntries()); - - // BROKEN: Will not work as data filling in different instance -/* - if( 0 == fdFirstMbsTime[uScalIndex] ) - // MBS time is time in s since LINUX epoch (circa 1970) => never 0 except on first event! - fdFirstMbsTime[uScalIndex] = fdCurrMbsTime[uScalIndex]; -*/ - // Fix attempt - if( kTRUE == fParUnpack->WithActiveTriglog() ) - { - TTofTriglogBoard * fTriglogBoard = (TTofTriglogBoard*) fTriglogBoardCollection->At(0); // Always only 1 TRIGLOG board! - - fdCurrMbsTime[uScalIndex] = fTriglogBoard->GetMbsTimeSec(); - if( 0 == fdFirstMbsTime[uScalIndex] ) - // MBS time is time in s since LINUX epoch (circa 1970) => never 0 except on first event! - fdFirstMbsTime[uScalIndex] = fdCurrMbsTime[uScalIndex]; - } - - if( ( 0 == fdPrevMbsTime[uScalIndex] ) || ( fdPrevMbsTime[uScalIndex] + 0.05 < fdCurrMbsTime[uScalIndex] ) ) - { - Double_t dTimeDiff = fdCurrMbsTime[uScalIndex] - fdPrevMbsTime[uScalIndex]; - if( 0 < fdPrevMbsTime[uScalIndex] && dTimeDiff < 0.3 ) - { - fhRefClkRate[uScalIndex]->Fill( (Double_t)(fScalerBoard->GetRefClk() - fuLastRefClk[uScalIndex] ) / - dTimeDiff ); - fhRefClkRateEvo[uScalIndex]->Fill(fdCurrMbsTime[uScalIndex] - fdFirstMbsTime[uScalIndex], - fScalerBoard->GetRefClk() - fuLastRefClk[uScalIndex]); - } // if( 0 < fdPrevMbsTime ) - - fdPrevMbsTime[uScalIndex] = fdCurrMbsTime[uScalIndex]; - fuLastRefClk[uScalIndex] = fScalerBoard->GetRefClk(); - } // if( ( 0 == fdPrevMbsTime ) || ( dMbsTime > fdPrevMbsTime + 0.1 ) ) - - for( UInt_t uScaler = 0; uScaler <triglog::kuNbScalers; uScaler++) - for( UInt_t uCh = 0; uCh < triglog::kuNbChan; uCh++) - { - fhScalers[uScalIndex][uScaler]->SetBinContent( 1 + uCh, fScalerBoard->GetScalerValue( uCh, uScaler) - - fuFirstScaler[uScalIndex][uScaler][uCh] ); - fhScalersCountsEvo[uScalIndex][uScaler][uCh]->SetBinContent( fdCurrMbsTime[uScalIndex] - fdFirstMbsTime[uScalIndex], - fScalerBoard->GetScalerValue( uCh, uScaler) ); - } // for( UInt_t uCh = 0; uCh < triglog::kuNbChan; uCh++) - } // for( UInt_t uScalIndex = 0; uScalIndex < fuNbTriglogScal; uScalIndex++) -} -void TTofTriglogScalUnpacker::WriteHistos( TDirectory* inDir) -{ - // Some triglog board can be used as scaler board instead of trigger source - for( UInt_t uScalIndex = 0; uScalIndex < fuNbTriglogScal; uScalIndex++) - { - TDirectory * oldir = gDirectory; - - TDirectory *cdTriglog = inDir->mkdir( Form( "Unp_%s_%02u", tofscaler::ksTdcHistName[ tofscaler::triglogscal ].Data(), uScalIndex ) ); - cdTriglog->cd(); // make the "Unp_triglog" directory the current directory - - fhRefClkRate[uScalIndex]->Write(); - fhRefClkRateEvo[uScalIndex]->Write(); - for( UInt_t uScaler = 0; uScaler <triglog::kuNbScalers; uScaler++) - { - fhScalers[uScalIndex][uScaler]->Write(); - for( UInt_t uCh = 0; uCh < triglog::kuNbChan; uCh++) - fhScalersCountsEvo[uScalIndex][uScaler][uCh]->Write(); - } // for( UInt_t uScaler = 0; uScaler <triglog::kuNbScalers; uScaler++) - - gDirectory->cd( oldir->GetPath() ); - } // for( UInt_t uScalIndex = 0; uScalIndex < fuNbTriglogScal; uScalIndex++) -} -void TTofTriglogScalUnpacker::DeleteHistos() -{ -/* - // Some triglog board can be used as scaler board instead of trigger source - if( 0 < fuNbTriglogScal ) - { - } // if( 0 < fuNbTriglogScal ) - else LOG(error)<<"TTofTriglogScalUnpacker::DeleteHistos => No TRIGLOG board active as scaler!!!!!" - <<" recheck your VME address matrix "; -*/ -} diff --git a/beamtime/tof/scalers/triglog/TTofTriglogScalUnpacker.h b/beamtime/tof/scalers/triglog/TTofTriglogScalUnpacker.h deleted file mode 100644 index cee6b0ffaa5ec5a80795dcf5a88a08f7cca86de1..0000000000000000000000000000000000000000 --- a/beamtime/tof/scalers/triglog/TTofTriglogScalUnpacker.h +++ /dev/null @@ -1,79 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TTofTriglogScalUnpacker ----- -// ----- Created 20/03/2015 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ - -#ifndef TTOFTRIGLOGSCALUNPACKER_H_ -#define TTOFTRIGLOGSCALUNPACKER_H_ - -#include "TObject.h" - -#include <vector> - -class TMbsUnpackTofPar; - -class TClonesArray; -class TH1; -class TH2; -class TDirectory; - -class TTofTriglogScalUnpacker : public TObject -{ - public: - TTofTriglogScalUnpacker(); - TTofTriglogScalUnpacker( TMbsUnpackTofPar * parIn ); - ~TTofTriglogScalUnpacker(); - - virtual void Clear(Option_t *option); - - void ProcessTriglogScal( Int_t iTrigScalIndex, UInt_t* pMbsData, UInt_t uLength ); - void UpdateStats( Int_t iTrigScalIndex, UInt_t uMbsTime ); - void FinishTriglog( ); - - void CreateHistos(); - void FillHistos(); - void WriteHistos( TDirectory* inDir); - void DeleteHistos(); - - void SetHistoUserAxis( Double_t dRangeIn, Double_t dBinSzIn ) - { fdEvoRangeUser = dRangeIn; fdEvoBinSzUser = dBinSzIn; }; - - private: - // no default Copy constructor and = OP as class not meant to be copied - TTofTriglogScalUnpacker(const TTofTriglogScalUnpacker&); - TTofTriglogScalUnpacker& operator=(const TTofTriglogScalUnpacker&); - - TMbsUnpackTofPar * fParUnpack; - TClonesArray * fScalerBoardCollection; - - UInt_t fuNbTriglogScal; - UInt_t fuTrigOff; - - // Final output - std::vector< UInt_t > fuTotalTriggerCount; //! - std::vector< UInt_t > fuFirstMbsTime; //! first mbs time - std::vector< UInt_t > fuLastMbsTime; //! last mbs time - std::vector< std::vector< std::vector< UInt_t > > > fuFirstScaler; //! TRIGLOG scaler contents - std::vector< std::vector< std::vector< UInt_t > > > fuLastScaler; //! TRIGLOG scaler contents - - // Histograms - std::vector< std::vector< TH1* > > fhScalers; //! last value of each scaler = integrated counts - - std::vector< std::vector< std::vector< UInt_t > > > fvuFirstScalers; //! First value of each scaler <= integrated counts - - std::vector< Double_t > fdFirstMbsTime; // First point for rate measurement - std::vector< Double_t > fdPrevMbsTime; // previous point for rate measurement - std::vector< Double_t > fdCurrMbsTime; // current point for rate measurement - std::vector< UInt_t > fuLastRefClk; //! last reference clock number - std::vector< TH1* > fhRefClkRate; - std::vector< TH1* > fhRefClkRateEvo; - - TClonesArray * fTriglogBoardCollection; - Double_t fdEvoRangeUser; - Double_t fdEvoBinSzUser; - std::vector< std::vector< std::vector< TH1* > > > fhScalersCountsEvo; // [NbBoards][NbScalers][NbChan] - - ClassDef(TTofTriglogScalUnpacker, 1) -}; - -#endif // TTOFTRIGLOGSCALUNPACKER_H_ diff --git a/beamtime/tof/scalers/triglog/TTofTriglogUnpacker.cxx b/beamtime/tof/scalers/triglog/TTofTriglogUnpacker.cxx deleted file mode 100644 index 4b1c966650d6945b5ba322002927be35b2b8934f..0000000000000000000000000000000000000000 --- a/beamtime/tof/scalers/triglog/TTofTriglogUnpacker.cxx +++ /dev/null @@ -1,450 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TTofTriglogUnpacker ----- -// ----- Created 03/07/2013 by P.-A. Loizeau ----- -// ----- Adapted from TTriglogProc.cxx by S. Linev ----- -// ----- and TMbsCrateProc.cxx by P.-A. Loizeau ---- -// ------------------------------------------------------------------ - -#include "TTofTriglogUnpacker.h" - -// TOF headers -#include "TofDef.h" -#include "TMbsUnpackTofPar.h" -#include "TofTriglogDef.h" -#include "TofScalerDef.h" -#include "TTofTriglogBoard.h" -#include "TTofScalerBoard.h" - -// FAIR headers -#include "FairRootManager.h" -#include "FairLogger.h" -#include "TString.h" - -// ROOT headers -#include "TClonesArray.h" -#include "TH1.h" -#include "TROOT.h" -#include "TDirectory.h" -#include "TString.h" - -TTofTriglogUnpacker::TTofTriglogUnpacker(): - fParUnpack(0), - fTriglogBoardCollection(NULL), - fScalerBoardCollection(NULL), - fuTotalTriggerCount(0), - fuFirstMbsTime(0), - fuLastMbsTime(0), - fuFirstScaler(NULL), - fuLastScaler(NULL), - fhTriglogSyncs(NULL), - fuLastSync(0), - fhSpillRate(NULL), - fTriggerPattern(NULL), - fInputPattern(NULL), - fhScalers(), - fvuFirstScalers(), - fdFirstMbsTime(0.), - fdPrevMbsTime(0.), - fuLastRefClk(0), - fhRefClkRate(NULL), - fhRefClkRateEvo(NULL) -{ -} -TTofTriglogUnpacker::TTofTriglogUnpacker( TMbsUnpackTofPar * parIn ): - fParUnpack( parIn ), - fTriglogBoardCollection(NULL), - fScalerBoardCollection(NULL), - fuTotalTriggerCount(0), - fuFirstMbsTime(0), - fuLastMbsTime(0), - fuFirstScaler(NULL), - fuLastScaler(NULL), - fhTriglogSyncs(NULL), - fuLastSync(0), - fhSpillRate(NULL), - fTriggerPattern(NULL), - fInputPattern(NULL), - fhScalers(), - fvuFirstScalers(), - fdFirstMbsTime(0.), - fdPrevMbsTime(0.), - fuLastRefClk(0), - fhRefClkRate(NULL), - fhRefClkRateEvo(NULL) -{ - // There should always be only 1 Trigger board active, if not => problem - if( 1 == fParUnpack->GetNbActiveBoards( tofMbs::triglog ) ) - { - // Recover first the TRIGLOG and SCALER board objects created in general unpacker class - FairRootManager* rootMgr = FairRootManager::Instance(); - - fTriglogBoardCollection = (TClonesArray*) rootMgr->GetObject("TofTriglog"); - if(NULL == fTriglogBoardCollection) - { - LOG(warn)<<"TTofTriglogUnpacker::TTofTriglogUnpacker : no TRIGLOG object in manager! "; - } // if(NULL == fTriglogBoardCollection) - - fScalerBoardCollection = (TClonesArray*) rootMgr->GetObject("TofRawScalers"); - if(NULL == fScalerBoardCollection) - { - LOG(warn)<<"TTofTriglogUnpacker::TTofTriglogUnpacker : no Raw Scalers array! "; - } // if(NULL == fScalerBoardCollection) - else - { - // Intialize the ScalerBoard object with TRIGLOG characteristics - TTofScalerBoard * fScalerBoard = (TTofScalerBoard*) fScalerBoardCollection->ConstructedAt(0); // TRIGLOG always first scaler board! - if( tofscaler::undef == fScalerBoard->GetScalerType() ) - fScalerBoard->SetType( tofscaler::triglog ); - } // else of if(NULL == fScalerBoardCollection) - - fuTotalTriggerCount = 0; - fuFirstMbsTime = 0; - fuLastMbsTime = 0; - fuFirstScaler = new UInt_t*[triglog::kuNbScalers]; - fuLastScaler = new UInt_t*[triglog::kuNbScalers]; - for( UInt_t uScaler = 0; uScaler <triglog::kuNbScalers; uScaler++) - { - fuFirstScaler[uScaler] = new UInt_t[triglog::kuNbChan]; - fuLastScaler[uScaler] = new UInt_t[triglog::kuNbChan]; - } // for( UInt_t uScaler = 0; uScaler <triglog::kuNbScalers; uScaler++) - } // if( 1 == fParUnpack->GetNbActiveBoards( tofMbs::triglog ) ) - else if( 1 < fParUnpack->GetNbActiveBoards( tofMbs::triglog ) ) - LOG(error)<<"TTofTriglogUnpacker::TTofTriglogUnpacker => More than 1 TRIGLOG board active!!!!!" - <<" recheck your VME address matrix "; -} -TTofTriglogUnpacker::~TTofTriglogUnpacker() -{ - // There should always be only 1 Trigger board active, if not => problem - if( 1 == fParUnpack->GetNbActiveBoards( tofMbs::triglog ) ) - { - for( UInt_t uScaler = 0; uScaler <triglog::kuNbScalers; uScaler++) - { - delete[] fuFirstScaler[uScaler]; - delete[] fuLastScaler[uScaler]; - } // for( UInt_t uScaler = 0; uScaler <triglog::kuNbScalers; uScaler++) - delete[] fuFirstScaler; - delete[] fuLastScaler; - } // if( 1 == fParUnpack->GetNbActiveBoards( tofMbs::triglog ) ) - else if( 1 < fParUnpack->GetNbActiveBoards( tofMbs::triglog ) ) - LOG(error)<<"TTofTriglogUnpacker::~TTofTriglogUnpacker => More than 1 TRIGLOG board active!!!!!" - <<" recheck your VME address matrix "; - -// DeleteHistos(); -} - -void TTofTriglogUnpacker::Clear(Option_t */*option*/) -{ - fParUnpack = NULL; - fTriglogBoardCollection = NULL; - fScalerBoardCollection = NULL; -} - -void TTofTriglogUnpacker::ProcessTriglog( UInt_t* pMbsData, UInt_t uLength ) -{ - // There should always be only 1 Trigger board active, if not => problem - if( 1 == fParUnpack->GetNbActiveBoards( tofMbs::triglog ) ) - { - // Getting output objects - TTofTriglogBoard * fTriglogBoard = (TTofTriglogBoard*) fTriglogBoardCollection->ConstructedAt(0); // Always only 1 TRIGLOG board! - TTofScalerBoard * fScalerBoard = (TTofScalerBoard*) fScalerBoardCollection->ConstructedAt(0); // TRIGLOG always first scaler board! - - if( tofscaler::undef == fScalerBoard->GetScalerType() ) - fScalerBoard->SetType( tofscaler::triglog ); - - UInt_t uIndx = 0; - Int_t sync_num = pMbsData[uIndx]; - fTriglogBoard->SetSyncNb( sync_num ); - uIndx++; - - LOG(debug2)<<" ===================== TRIGLOG EVENT ================= " << sync_num % 0x1000000 ; - - fTriglogBoard->SetTriggPatt( (UInt_t) pMbsData[uIndx] ); - uIndx++; - - fTriglogBoard->SetMbsTimeSec( (UInt_t) pMbsData[uIndx] ); - uIndx++; - fTriglogBoard->SetMbsTimeMilliSec( (UInt_t) pMbsData[uIndx] ); - uIndx++; - - for( UInt_t uScaler = 0; uScaler < triglog::kuNbScalers; uScaler++) - { - // SL 20.10.11 MBS readout was changed and two more scalers were included - // to be able process old files, add this break condition; - - for( UInt_t uCh = 0; uCh < triglog::kuNbChan; uCh++) - { - // SL: put protection against different length of this subevent - // also trigger-pattern was not correctly counted - UInt_t uValue = (UInt_t)(uIndx < uLength ? pMbsData[uIndx] : 0); - uIndx++; - fScalerBoard->SetScalerValue( uCh, uValue, uScaler ); - } // for( UInt uCh = 0; uCh < triglog::kuNbChan; uCh++) { - } // for( UInt uScaler = 0; uScaler < triglog::kuNbScalers; uScaler++) - - if( uIndx < uLength) - { - // Input pattern is inside Tof MBS event only since August 2012 - fTriglogBoard->SetInpPatt( pMbsData[uIndx] ); - uIndx++; - } // if( uIndx < uLength) - if( uIndx < uLength) - { - // Reference clock is inside Tof MBS event only since October 2012 - fTriglogBoard->SetRefClk( pMbsData[uIndx] ); - fScalerBoard->SetRefClk( pMbsData[uIndx] ); - uIndx++; - } // if( uIndx < uLength) - LOG(debug2)<<" TRIGLOG UNPACK finished"; - - fTriglogBoard->SetPresentFlag( kTRUE ); - fScalerBoard->SetPresentFlag( kTRUE ); - - UpdateStats(); - } // if( 1 == fParUnpack->GetNbActiveBoards( tofMbs::triglog ) ) - else if( 1 < fParUnpack->GetNbActiveBoards( tofMbs::triglog ) ) - LOG(error)<<"TTofTriglogUnpacker::ProcessTriglog => More than 1 TRIGLOG board active!!!!!" - <<" recheck your VME address matrix "; - - return; -} -void TTofTriglogUnpacker::UpdateStats() -{ - // There should always be only 1 Trigger board active, if not => problem - if( 1 == fParUnpack->GetNbActiveBoards( tofMbs::triglog ) ) - { - // Getting output objects - TTofTriglogBoard * fTriglogBoard = (TTofTriglogBoard*) fTriglogBoardCollection->At(0); // Always only 1 TRIGLOG board! - TTofScalerBoard * fScalerBoard = (TTofScalerBoard*) fScalerBoardCollection->At(0); // TRIGLOG always first scaler board! - - if( NULL == fTriglogBoard || NULL == fScalerBoard ) - { - LOG(error)<<"TTofTriglogUnpacker::UpdateStats => Board objects not existing!!!!"; - LOG(error)<<"TTofTriglogUnpacker::UpdateStats => TTofTriglogBoard = "<<fTriglogBoard - <<" TTofTriglogBoard = "<<fScalerBoard; - LOG(error)<<"TTofTriglogUnpacker::UpdateStats => Probably the TRIGLOG sub-event is not there in this event!"; - return; - } // if( NULL == fTriglogBoard || NULL == fScalerBoard ) - - // In GSI April 2014 beamtime some event are used to empty TRB buffers - // and therefore do not contain the MBS event - if( kFALSE == fTriglogBoard->IsUpdated() && kFALSE == fScalerBoard->IsUpdated() ) - { - LOG(error)<<"TTofTriglogUnpacker::UpdateStats => No TRIGLOG sub-event in this event," - <<" OK for GSI April 2014 beamtime"; - return; - } // if( kFALSE == fTriglogBoard->IsUpdated() && kFALSE == fScalerBoard->IsUpdated() ) - - // Preparing output at the end: - // MBS time is time in s since LINUX epoch (circa 1970) => never 0 except on first event! - fuTotalTriggerCount++; - for( UInt_t uScaler = 0; uScaler <triglog::kuNbScalers; uScaler++) - for( UInt_t uCh = 0; uCh < triglog::kuNbChan; uCh++) - { - fuLastScaler[uScaler][uCh] = fScalerBoard->GetScalerValue( uCh, uScaler); - if( fuFirstMbsTime == 0 ) fuFirstScaler[uScaler][uCh] = fuLastScaler[uScaler][uCh]; - } // for( UInt_t uCh = 0; uCh < triglog::kuNbChan; uCh++) - fuLastMbsTime = fTriglogBoard->GetMbsTimeSec(); - if( 0 == fuFirstMbsTime ) - fuFirstMbsTime = fuLastMbsTime; - } // if( 1 == fParUnpack->GetNbActiveBoards( tofMbs::triglog ) ) - else if( 1 < fParUnpack->GetNbActiveBoards( tofMbs::triglog ) ) - LOG(error)<<"TTofTriglogUnpacker::ProcessTriglog => More than 1 TRIGLOG board active!!!!!" - <<" recheck your VME address matrix "; -} - -void TTofTriglogUnpacker::FinishTriglog( ) -{ - // There should always be only 1 Trigger board active, if not => problem - if( 1 == fParUnpack->GetNbActiveBoards( tofMbs::triglog ) ) - { - Double_t dRuntime = fuLastMbsTime - fuFirstMbsTime; - LOG(info)<<Form("Total MBS run time %6.0f sec.", dRuntime); - - if( 0 < dRuntime ) - { - LOG(info)<<Form("-------- Total number of triggers %d --------", fuTotalTriggerCount); - - TString sLine = ""; - for( UInt_t uCh = 0; uCh < triglog::kuNbChan; uCh++) - { - sLine = Form(" Ch %2d", uCh ); - for( UInt_t uScaler = 0; uScaler <triglog::kuNbScalers; uScaler++) - sLine += Form(" %9u", fuLastScaler[uScaler][uCh] - fuFirstScaler[uScaler][uCh]); - LOG(info)<<sLine; - } // for( UInt_t uCh = 0; uCh < triglog::kuNbChan; uCh++) - - LOG(info)<<Form("------- Trigger rate %8.3f Hz ---------", fuTotalTriggerCount/dRuntime); - - for( UInt_t uCh = 0; uCh < triglog::kuNbChan; uCh++) - { - sLine = Form(" Ch %2d", uCh ); - for( UInt_t uScaler = 0; uScaler <triglog::kuNbScalers; uScaler++) - sLine += Form(" %9.2f", (fuLastScaler[uScaler][uCh] - fuFirstScaler[uScaler][uCh])/dRuntime); - LOG(info)<<sLine; - } // for( UInt_t uCh = 0; uCh < triglog::kuNbChan; uCh++) - } // if( 0 < dRuntime ) - } // if( 1 == fParUnpack->GetNbActiveBoards( tofMbs::triglog ) ) - else if( 1 < fParUnpack->GetNbActiveBoards( tofMbs::triglog ) ) - LOG(error)<<"TTofTriglogUnpacker::FinishTriglog => More than 1 TRIGLOG board active!!!!!" - <<" recheck your VME address matrix "; -} - -// Histogram management -// TODO: maybe add some options to control which histograms are -// created and filed (memory management) -void TTofTriglogUnpacker::CreateHistos() -{ - // There should always be only 1 Trigger board active, if not => problem - if( 1 == fParUnpack->GetNbActiveBoards( tofMbs::triglog ) ) - { - TDirectory * oldir = gDirectory; // <= To prevent histos from being sucked in by the param file of the TRootManager! - gROOT->cd(); // <= To prevent histos from being sucked in by the param file of the TRootManager ! - - fhTriglogSyncs = new TH1I( Form("tof_%s_syncs", tofscaler::ksTdcHistName[ tofscaler::triglog ].Data() ), - "Number of sync messages from VULOM", 65536, 0, 65536.); - fhSpillRate = new TH1I( Form("tof_%s_trig_rate", tofscaler::ksTdcHistName[ tofscaler::triglog ].Data() ), - "Number of triggers per second; Time [s]", 3600, 0.0, 3600 ); - fhRefClkRate = new TH1I( Form("tof_%s_refclk", tofscaler::ksTdcHistName[ tofscaler::triglog ].Data() ), - "Rate of the reference clock; Freq. [Hz]", - (Int_t)(2*triglog::kdRefClkFreq/1000), 0.0 , 2*triglog::kdRefClkFreq ); - fhRefClkRateEvo = new TH1I( Form("tof_%s_refclk_evo", tofscaler::ksTdcHistName[ tofscaler::triglog ].Data() ), - "Reference clock counts per second; Time [s]; Counts []", 3600, 0.0, 3600 ); - - fTriggerPattern = new TH1I( Form("tof_%s_trig_patt", tofscaler::ksTdcHistName[ tofscaler::triglog ].Data() ), - "Trigger Pattern ; Trigger []; Counts []", 16, -0.5, 15.5 ); - fInputPattern = new TH1I( Form("tof_%s_inp_patt", tofscaler::ksTdcHistName[ tofscaler::triglog ].Data() ), - "Input Pattern ; Input []; Counts []", 16, -0.5, 15.5 ); - - fhScalers.resize(triglog::kuNbScalers); - for( UInt_t uScaler = 0; uScaler <triglog::kuNbScalers; uScaler++) - fhScalers[uScaler] = new TH1I( Form("tof_%s_scalers%02d", tofscaler::ksTdcHistName[ tofscaler::triglog ].Data(), uScaler ), - Form("Counts per scaler channel in scaler %02d; Channel []; Total counts []", uScaler), - triglog::kuNbChan, 0, triglog::kuNbChan); - - gDirectory->cd( oldir->GetPath() ); // <= To prevent histos from being sucked in by the param file of the TRootManager! - - // Initialize variable used in filling - fuLastSync = 0; - fdFirstMbsTime = 0; - fdPrevMbsTime = -1; - fuLastRefClk = 0; - } // if( 1 == fParUnpack->GetNbActiveBoards( tofMbs::triglog ) ) - else if( 1 < fParUnpack->GetNbActiveBoards( tofMbs::triglog ) ) - LOG(error)<<"TTofTriglogUnpacker::CreateHistos => More than 1 TRIGLOG board active!!!!!" - <<" recheck your VME address matrix "; -} -void TTofTriglogUnpacker::FillHistos() -{ - // There should always be only 1 Trigger board active, if not => problem - if( 1 == fParUnpack->GetNbActiveBoards( tofMbs::triglog ) ) - { - // Getting output objects - TTofTriglogBoard * fTriglogBoard = (TTofTriglogBoard*) fTriglogBoardCollection->At(0); // Always only 1 TRIGLOG board! - TTofScalerBoard * fScalerBoard = (TTofScalerBoard*) fScalerBoardCollection->At(0); // TRIGLOG always first scaler board! - - if( NULL == fTriglogBoard || NULL == fScalerBoard ) - { - LOG(error)<<"TTofTriglogUnpacker::FillHistos => Board objects not existing!!!!"; - LOG(error)<<"TTofTriglogUnpacker::FillHistos => TTofTriglogBoard = "<<fTriglogBoard - <<" TTofScalerBoard = "<<fScalerBoard; - LOG(error)<<"TTofTriglogUnpacker::FillHistos => Probably the TRIGLOG sub-event is not there in this event!"; - return; - } // if( NULL == fTriglogBoard || NULL == fScalerBoard ) - - // In GSI April 2014 beamtime some event are used to empty TRB buffers - // and therefore do not contain the MBS event - if( kFALSE == fTriglogBoard->IsUpdated() && kFALSE == fScalerBoard->IsUpdated() ) - { - LOG(error)<<"TTofTriglogUnpacker::FillHistos => No TRIGLOG sub-event in this event," - <<" OK for GSI April 2014 beamtime"; - return; - } // if( kFALSE == fTriglogBoard->IsUpdated() && kFALSE == fScalerBoard->IsUpdated() ) - - LOG(debug3)<<(fTriglogBoardCollection->GetEntries())<<" "<<(fScalerBoardCollection->GetEntries()); - - Double_t dMbsTime = fTriglogBoard->GetMbsTimeSec() + fTriglogBoard->GetMbsTimeMilliSec()*1e-3; - if( 0 == fdFirstMbsTime ) - // MBS time is time in s since LINUX epoch (circa 1970) => never 0 except on first event! - fdFirstMbsTime = dMbsTime; - - // just to see that sync number is changing - UInt_t uSyncValue = fTriglogBoard->GetSyncNb(); - fhTriglogSyncs->Fill(uSyncValue % 65536); - if( (fuLastSync!=0) && (uSyncValue > fuLastSync) ) - fhSpillRate->Fill( fuLastMbsTime - fuFirstMbsTime, uSyncValue - fuLastSync); - fuLastSync = uSyncValue; - - for( UInt_t uBit=0; uBit < 16; uBit++) - { - if( ( (UInt_t) fTriglogBoard->GetTriggPatt() >>uBit )&0x00000001 ) - { - fTriggerPattern->Fill(uBit); - } // if( ( (UInt_t) fTriglogBoard->GetTriggPatt() >>uBit )&0x00000001 ) - if( ( (UInt_t) fTriglogBoard->GetInpPatt() >>uBit )&0x00000001 ) - { - fInputPattern->Fill(uBit); - } // if( ( (UInt_t) fTriglogBoard->GetTriggPatt() >>uBit )&0x00000001 ) - } // for( UInt_t uBit=0; uBit < 16; uBit++) - - if( ( 0 == fdPrevMbsTime ) || ( fdPrevMbsTime + 0.05 < dMbsTime ) ) - { - Double_t dTimeDiff = dMbsTime - fdPrevMbsTime; - if( 0 < fdPrevMbsTime && dTimeDiff < 0.3 ) - { - fhRefClkRate->Fill( (Double_t)(fScalerBoard->GetRefClk() - fuLastRefClk ) / - dTimeDiff ); - fhRefClkRateEvo->Fill(dMbsTime - fdFirstMbsTime, fScalerBoard->GetRefClk() - fuLastRefClk); - } // if( 0 < fdPrevMbsTime ) - - fdPrevMbsTime = dMbsTime; - fuLastRefClk = fScalerBoard->GetRefClk(); - } // if( ( 0 == fdPrevMbsTime ) || ( dMbsTime > fdPrevMbsTime + 0.1 ) ) - - for( UInt_t uScaler = 0; uScaler <triglog::kuNbScalers; uScaler++) - for( UInt_t uCh = 0; uCh < triglog::kuNbChan; uCh++) - fhScalers[uScaler]->SetBinContent( 1 + uCh, fScalerBoard->GetScalerValue( uCh, uScaler) - - fuFirstScaler[uScaler][uCh] ); - - } // if( 1 == fParUnpack->GetNbActiveBoards( tofMbs::triglog ) ) - else if( 1 < fParUnpack->GetNbActiveBoards( tofMbs::triglog ) ) - LOG(error)<<"TTofTriglogUnpacker::FillHistos => More than 1 TRIGLOG board active!!!!!" - <<" recheck your VME address matrix "; - -} -void TTofTriglogUnpacker::WriteHistos( TDirectory* inDir) -{ - // There should always be only 1 Trigger board active, if not => problem - if( 1 == fParUnpack->GetNbActiveBoards( tofMbs::triglog ) ) - { - TDirectory * oldir = gDirectory; - - TDirectory *cdTriglog = inDir->mkdir( Form( "Unp_%s", tofscaler::ksTdcHistName[ tofscaler::triglog ].Data() ) ); - cdTriglog->cd(); // make the "Unp_triglog" directory the current directory - - fhTriglogSyncs->Write(); - fhSpillRate->Write(); - fhRefClkRate->Write(); - fhRefClkRateEvo->Write(); - fTriggerPattern->Write(); - fInputPattern->Write(); - for( UInt_t uScaler = 0; uScaler <triglog::kuNbScalers; uScaler++) - fhScalers[uScaler]->Write(); - - gDirectory->cd( oldir->GetPath() ); - } // if( 1 == fParUnpack->GetNbActiveBoards( tofMbs::triglog ) ) - else if( 1 < fParUnpack->GetNbActiveBoards( tofMbs::triglog ) ) - LOG(error)<<"TTofTriglogUnpacker::WriteHistos => More than 1 TRIGLOG board active!!!!!" - <<" recheck your VME address matrix "; -} -void TTofTriglogUnpacker::DeleteHistos() -{ -/* - // There should always be only 1 Trigger board active, if not => problem - if( 1 == fParUnpack->GetNbActiveBoards( tofMbs::triglog ) ) - { - } // if( 1 == fParUnpack->GetNbActiveBoards( tofMbs::triglog ) ) - else if( 1 < fParUnpack->GetNbActiveBoards( tofMbs::triglog ) ) - LOG(error)<<"TTofTriglogUnpacker::DeleteHistos => More than 1 TRIGLOG board active!!!!!" - <<" recheck your VME address matrix "; -*/ -} diff --git a/beamtime/tof/scalers/triglog/TTofTriglogUnpacker.h b/beamtime/tof/scalers/triglog/TTofTriglogUnpacker.h deleted file mode 100644 index 1001fd7b4c4949b4271a5257ccf8091ca07bda3d..0000000000000000000000000000000000000000 --- a/beamtime/tof/scalers/triglog/TTofTriglogUnpacker.h +++ /dev/null @@ -1,73 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TTofTriglogUnpacker ----- -// ----- Created 03/07/2013 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ - -#ifndef TTOFTRIGLOGUNPACKER_H_ -#define TTOFTRIGLOGUNPACKER_H_ - -#include "TObject.h" - -#include <vector> - -class TMbsUnpackTofPar; - -class TClonesArray; -class TH1; -class TH2; -class TDirectory; - -class TTofTriglogUnpacker : public TObject -{ - public: - TTofTriglogUnpacker(); - TTofTriglogUnpacker( TMbsUnpackTofPar * parIn ); - ~TTofTriglogUnpacker(); - - virtual void Clear(Option_t *option); - - void ProcessTriglog( UInt_t* pMbsData, UInt_t uLength ); - void UpdateStats(); - void FinishTriglog( ); - - void CreateHistos(); - void FillHistos(); - void WriteHistos( TDirectory* inDir); - void DeleteHistos(); - - private: - // no default Copy constructor and = OP as class not meant to be copied - TTofTriglogUnpacker(const TTofTriglogUnpacker&); - TTofTriglogUnpacker& operator=(const TTofTriglogUnpacker&); - - TMbsUnpackTofPar * fParUnpack; - TClonesArray * fTriglogBoardCollection; - TClonesArray * fScalerBoardCollection; - - // Final output - UInt_t fuTotalTriggerCount; //! - UInt_t fuFirstMbsTime; //! first mbs time - UInt_t fuLastMbsTime; //! last mbs time - UInt_t **fuFirstScaler; //! TRIGLOG scaler contents - UInt_t **fuLastScaler; //! TRIGLOG scaler contents - - // Histograms - TH1 * fhTriglogSyncs; - UInt_t fuLastSync; //! last sync number - TH1 * fhSpillRate; //! events per second - TH1 * fTriggerPattern; - TH1 * fInputPattern; - std::vector< TH1* > fhScalers; //! last value of each scaler = integrated counts - - std::vector< std::vector< UInt_t > > fvuFirstScalers; //! First value of each scaler <= integrated counts - - Double_t fdFirstMbsTime; // First point for rate measurement - Double_t fdPrevMbsTime; // previous point for rate measurement - UInt_t fuLastRefClk; //! last reference clock number - TH1 * fhRefClkRate; - TH1 * fhRefClkRateEvo; - - ClassDef(TTofTriglogUnpacker, 1) -}; - -#endif // TTOFTRIGLOGUNPACKER_H_ diff --git a/beamtime/tof/scalers/triglog/TofTriglogDef.h b/beamtime/tof/scalers/triglog/TofTriglogDef.h deleted file mode 100644 index c2b48464d6097ea93e765f0f531e2a38f60a2339..0000000000000000000000000000000000000000 --- a/beamtime/tof/scalers/triglog/TofTriglogDef.h +++ /dev/null @@ -1,21 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TofTriglogDef ----- -// ----- Created 21/06/2013 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ - -#ifndef TOFTRIGLOGDEF_H_ -#define TOFTRIGLOGDEF_H_ - -#include "TString.h" - -/******************** VULOM3:TRIGLOG data unpacking definitions *************/ -namespace triglog -{ - const UInt_t kuNbScalers = 3; - const UInt_t kuNbChan = 16; - const Double_t kdRefClkFreq = 781250.0; - const Double_t kdEvoRange = 3*3600; // s - const Double_t kdEvoBin = 1; // s -} - -#endif // TOFTRIGLOGDEF_H_ diff --git a/beamtime/tof/tdc/TTofTdcBoard.cxx b/beamtime/tof/tdc/TTofTdcBoard.cxx deleted file mode 100644 index 2b0c347977f16522970e8d6e764248da791b20c8..0000000000000000000000000000000000000000 --- a/beamtime/tof/tdc/TTofTdcBoard.cxx +++ /dev/null @@ -1,115 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TTofTdcBoard ----- -// ----- Created 12/05/2013 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ - -#include "TTofTdcBoard.h" - -// TOF headers -#include "TTofTdcData.h" -#include "TofTdcDef.h" - -// FAIR headers -#include "FairLogger.h" - -// ROOT headers -#include "TClonesArray.h" - -// C/C++ headers - -/************************** TTofTdcBoard ****************************/ -TTofTdcBoard::TTofTdcBoard(): - fDataCollection(NULL), - fbValidData(kTRUE), - fuTdcType(0), - fuChannelNumber(0), - fuTriggerTime(0) -{ -} -TTofTdcBoard::TTofTdcBoard( UInt_t uType, UInt_t uChNb ) : - fDataCollection(NULL), - fbValidData(kTRUE), - fuTdcType(uType), - fuChannelNumber(uChNb), - fuTriggerTime(0) -{ -} -TTofTdcBoard::~TTofTdcBoard() -{ - if( 0 < fuChannelNumber && NULL != fDataCollection ) - fDataCollection->Delete(); -} - -void TTofTdcBoard::Clear(Option_t *option) -{ - fbValidData = kTRUE; // Default, unpacker has to take care of invalidating stuff - TObject::Clear( option ); - fuTriggerTime = 0; - if( NULL != fDataCollection ) - fDataCollection->Clear("C"); -} - -void TTofTdcBoard::SetChannelNb( UInt_t uChNb ) -{ - fuChannelNumber = uChNb; - ResizeArray(); -} - -Bool_t TTofTdcBoard::CreateDataArray() -{ - LOG(debug)<<" TTofTdcBoard::CreateDataArray "; - if( 0 < fuChannelNumber && NULL == fDataCollection ) - fDataCollection = new TClonesArray( "TTofTdcData", toftdc::kuDefNbMulti * fuChannelNumber ); - else return kFALSE; - - return kTRUE; -} -Bool_t TTofTdcBoard::ResizeArray() -{ - if( 0 < fuChannelNumber && NULL != fDataCollection ) - { - fDataCollection->Expand( toftdc::kuDefNbMulti*fuChannelNumber ); - return kTRUE; - } // if( 0 < fuChannelNumber && NULL != fDataCollection ) - else return kFALSE; -} - -UInt_t TTofTdcBoard::AddData( TTofTdcData & dataIn ) -{ - if( NULL != fDataCollection ) - { - Int_t iNextIndex = fDataCollection->GetEntriesFast(); - if( iNextIndex < static_cast<Int_t>(toftdc::kuDefNbMulti * fuChannelNumber) ) - { - TTofTdcData * dataSlot = (TTofTdcData *)fDataCollection->ConstructedAt( iNextIndex ); - *dataSlot = dataIn; - } // if( iNextIndex < toftdc::kuDefNbMulti * fuChannelNumber ) - return fDataCollection->GetEntriesFast(); - } // if( NULL != fDataCollection ) - else return 0; -} -TTofTdcData * TTofTdcBoard::GetDataPtr( UInt_t uDataIndex ) -{ - if( NULL != fDataCollection ) - { - if( static_cast<Int_t>(uDataIndex) < fDataCollection->GetEntriesFast() ) - return (TTofTdcData *)fDataCollection->At( uDataIndex ); - else return NULL; - } // if( NULL != fDataCollection ) - else return NULL; -} -const TTofTdcData & TTofTdcBoard::GetData( UInt_t uDataIndex ) const -{ - return *( (TTofTdcData *)fDataCollection->At( uDataIndex ) ); -} -UInt_t TTofTdcBoard::GetDataNb() const -{ - if( NULL != fDataCollection ) - return fDataCollection->GetEntriesFast(); - else return 0; -} -void TTofTdcBoard::SortData() -{ - if( NULL != fDataCollection ) - fDataCollection->Sort(); -} diff --git a/beamtime/tof/tdc/TTofTdcBoard.h b/beamtime/tof/tdc/TTofTdcBoard.h deleted file mode 100644 index b7d4ef68e65511dcc468cdc4eb58e4d408adc11b..0000000000000000000000000000000000000000 --- a/beamtime/tof/tdc/TTofTdcBoard.h +++ /dev/null @@ -1,65 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TTofTdcBoard ----- -// ----- Created 12/05/2013 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ - -#ifndef TTOFTDCBOARD_H_ -#define TTOFTDCBOARD_H_ - -#include <vector> - -#include "TObject.h" - -class TTofTdcData; -class TClonesArray; - -class TTofTdcBoard : public TObject -{ - public: - TTofTdcBoard(); - TTofTdcBoard( UInt_t uType, UInt_t uChNb ); - ~TTofTdcBoard(); - - virtual void Clear(Option_t *option = ""); - - void SetTdcType( UInt_t uType ) { fuTdcType = uType; }; - void SetChannelNb( UInt_t uChNb ); // Maybe call Delete/CreateArray in here to refresh the TClonesArray? - void SetTriggerTime( UInt_t uTriggerTimeIn){ fuTriggerTime = uTriggerTimeIn; }; - void SetInvalid() { fbValidData = kFALSE; }; - void SetValid() { fbValidData = kTRUE; }; - - UInt_t GetTdcType() const { return fuTdcType; }; - UInt_t GetChannelNb() const { return fuChannelNumber; }; - UInt_t GetTriggerTime() const { return fuTriggerTime; }; - Bool_t IsValid() const { return fbValidData; }; - - // All these functions have to be implemented in the derived classes - // With the proper Data objects - virtual Bool_t CreateDataArray(); // To be called in derived classes constructors - virtual Bool_t ResizeArray(); - UInt_t AddData( TTofTdcData & dataIn ); - TTofTdcData * GetDataPtr( UInt_t uDataIndex ); - // ! no check on valid index in this one, Probably stupid method - const TTofTdcData & GetData( UInt_t uDataIndex ) const; - - // These ones should be ok even for child class (generic TClonesArray methods) - UInt_t GetDataNb() const; - virtual void SortData(); - - protected: - TClonesArray * fDataCollection; - - private: - // no default Copy constructor and = OP as class not meant to be copied - TTofTdcBoard(const TTofTdcBoard&); - TTofTdcBoard& operator=(const TTofTdcBoard&); - - Bool_t fbValidData; - UInt_t fuTdcType; - UInt_t fuChannelNumber; - UInt_t fuTriggerTime; // [Clock Cycles] - - ClassDef(TTofTdcBoard, 1) -}; - -#endif // TTOFTDCBOARD_H_ diff --git a/beamtime/tof/tdc/TTofTdcData.cxx b/beamtime/tof/tdc/TTofTdcData.cxx deleted file mode 100644 index 2f1060f99a3b5a64409e85e8f4ccbfa883144bc3..0000000000000000000000000000000000000000 --- a/beamtime/tof/tdc/TTofTdcData.cxx +++ /dev/null @@ -1,71 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TTofTdcData ----- -// ----- Created 17/05/2013 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ - -#include "TTofTdcData.h" - -/************************** TTofTdcData ****************************/ -TTofTdcData::TTofTdcData() : - fuTdcChannel(0), - fuEdge(0), - fuFineTime(0), - fuCoarseTime(0), - fuTimeOverThreshold(0) -{ -} -TTofTdcData::TTofTdcData( UInt_t uChan, UInt_t uFt, - UInt_t uCoarseT, UInt_t uTot, UInt_t uEdge ) : - fuTdcChannel(uChan), - fuEdge(uEdge), - fuFineTime(uFt), - fuCoarseTime(uCoarseT), - fuTimeOverThreshold(uTot) -{ -} - -TTofTdcData::~TTofTdcData() -{ -} - -void TTofTdcData::Clear(Option_t *option) -{ - TObject::Clear( option ); - SetData( 0, 0, 0, 0); -} -void TTofTdcData::SetData( UInt_t uChan, UInt_t uFt, - UInt_t uCoarseT, UInt_t uTot, - UInt_t uEdge ) -{ - SetChannel( uChan ); - SetEdge( uEdge ); - SetFineTime( uFt ); - SetCoarseTime( uCoarseT ); - SetTot( uTot ); -} -Int_t TTofTdcData::Compare( const TObject* obj) const -{ - return Compare( (TTofTdcData*) obj); -} -Int_t TTofTdcData::Compare( const TTofTdcData* obj) const -{ - // No Check on CT overflow as this is determined by TDC type - // => Need to be overriden in Child classes!!!! - if( this->GetCoarseTime() < obj->GetCoarseTime() ) - // CT hit ... rhs - return -1; - else if( this->GetCoarseTime() > obj->GetCoarseTime() ) - // CT rhs ... hit - return 1; - else if( this->GetFineTime() < obj->GetFineTime()) - // CT rhs = hit - // FT hit ... rhs - return -1; - else if( this->GetFineTime() > obj->GetFineTime()) - // CT rhs = hit - // FT rhs ... hit - return 1; - // CT rhs = hit - // FT rhs = hit - else return 0; -} diff --git a/beamtime/tof/tdc/TTofTdcData.h b/beamtime/tof/tdc/TTofTdcData.h deleted file mode 100644 index 819d795d4bb11e31a2e36cb663a7c5d93efa0427..0000000000000000000000000000000000000000 --- a/beamtime/tof/tdc/TTofTdcData.h +++ /dev/null @@ -1,62 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TTofTdcData ----- -// ----- Created 17/05/2013 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ - -#ifndef TTOFTDCDATA_H_ -#define TTOFTDCDATA_H_ - -#include "TObject.h" - -class TTofTdcData : public TObject -{ - public: - TTofTdcData(); - TTofTdcData( UInt_t uChan, UInt_t uFt, - UInt_t uCoarseT, UInt_t uTot = 0, - UInt_t uEdge = 0 ); - ~TTofTdcData(); - - virtual void Clear(Option_t *option = ""); - - // copy constructor, used by vector to copy content - TTofTdcData(const TTofTdcData& src) : - TObject(), - fuTdcChannel(src.fuTdcChannel), - fuEdge(src.fuEdge), - fuFineTime(src.fuFineTime), - fuCoarseTime(src.fuCoarseTime), - fuTimeOverThreshold(src.fuTimeOverThreshold) {}; - // Comparison operator, needed for time sorting - // To be implemeted for each TDC type as need coarse counter size -// virtual Bool_t operator <( const TTofTdcData& rhs) const; - virtual Int_t Compare( const TObject* obj) const; - virtual Int_t Compare( const TTofTdcData* obj) const; - virtual Bool_t IsSortable() const { return kTRUE; }; - - void SetData( UInt_t uChan, UInt_t uFt, - UInt_t uCoarseT, UInt_t uTot = 0, - UInt_t uEdge = 0 ); - void SetChannel( UInt_t uChan ){ fuTdcChannel = uChan; }; - void SetEdge( UInt_t uEdge ){ fuEdge = uEdge; }; - void SetFineTime( UInt_t uFt ){ fuFineTime = uFt; }; - void SetCoarseTime( UInt_t uCoarseT ){ fuCoarseTime = uCoarseT; }; - void SetTot( UInt_t uTot ){ fuTimeOverThreshold = uTot; }; - - UInt_t GetChannel() const { return fuTdcChannel; }; - UInt_t GetEdge() const { return fuEdge; }; - UInt_t GetFineTime() const { return fuFineTime; }; - UInt_t GetCoarseTime() const { return fuCoarseTime; }; - UInt_t GetTot() const { return fuTimeOverThreshold; }; - - private: - UInt_t fuTdcChannel; - UInt_t fuEdge; - UInt_t fuFineTime; // [Time bins] - UInt_t fuCoarseTime; // [Clock Cycles] - UInt_t fuTimeOverThreshold; // [ToT bins] - - ClassDef(TTofTdcData, 1) -}; - -#endif // TTOFTDCDATA_H_ diff --git a/beamtime/tof/tdc/TofTdcDef.h b/beamtime/tof/tdc/TofTdcDef.h deleted file mode 100644 index 468591d3d4c8e809d88f98942c70ba9e48292557..0000000000000000000000000000000000000000 --- a/beamtime/tof/tdc/TofTdcDef.h +++ /dev/null @@ -1,34 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TofTdcDef ----- -// ----- Created 22/05/2013 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ - -#ifndef TOFTDCDEF_H_ -#define TOFTDCDEF_H_ - -#include "TString.h" - -namespace toftdc -{ - enum TdcTypes { - undef = 0, // unknown TDC type, default value - caenV1290 = 1, // CAEN v1290A and CAEN v1290N VME boards based on HPTDC chips - vftx = 2, // FPGA TDC of the VFTX family (E. Bayer dev.) - trb = 3, // FPGA TDC of the HADES TRB3 family - get4 = 4, // GET4 chips - NbTdcTypes // Nb of Tdc types, require indices to be consecutive (no gap) - }; - - // Default Maximal number of hits per channel per event stored - const UInt_t kuDefNbMulti = 8; - - // Names for Histos - // !! Has to be adapted to match in initializer size the number of entries in TdcTypes!!! - const TString ksTdcHistName[NbTdcTypes] = { "default", "v1290", "vftx", "trb", "get4"}; - - // Names for parameters - // !! Has to be adapted to match in initializer size the number of entries in TdcTypes!!! - const TString ksTdcParName[NbTdcTypes] = { "Def", "Caen", "Vftx", "Trb", "Get4"}; -} - -#endif // TOFTDCDEF_H_ diff --git a/beamtime/tof/tdc/get4/TGet4v1Event.cxx b/beamtime/tof/tdc/get4/TGet4v1Event.cxx deleted file mode 100755 index 5f00bfa45f4e2a1780dba3f09979672a801dc578..0000000000000000000000000000000000000000 --- a/beamtime/tof/tdc/get4/TGet4v1Event.cxx +++ /dev/null @@ -1,436 +0,0 @@ -/* Generated by Together */ - -#include "TGet4v1Event.h" - -// ROOT headers -#include "Riostream.h" -#include "TString.h" - -#include <iostream> - -using std::cout; -using std::endl; - -/* - * Conversion of definitions to constants: - * -MAX_ROC get4v10::kiMaxRoc -MAX_GET4 get4v10::kuMaxGet4 -MAX_GET4_PER_ROC get4v10::kiMaxGet4Roc -MAX_AUX get4v10::kiMaxAux -MAX_SYNC get4v10::kiMaxSync -GET4_PRINT get4v10::kiGet4MessPr -GET4_EPOCH_CYCLE_SIZE get4v10::kulGet4EpochCycleSz -MAIN_EPOCH_CYCLE_SIZE get4v10::kulMainEpochCycleSz -MAIN_CLK_SYNC_SIZE get4v10::kiSyncCycleSzMain -GET4_SYNC_CYCLE_SIZE get4v10::kiSyncCycleSzGet4 -MAX_DATA_TRIGG get4v10::kiMaxNbDataTriggs -MAX_SEC_TRIG get4v10::kiMaxNbSecTriggCh - -NB_BIN_GET4_FTS get4tdc::kiFineTime -GET4_BIN_SIZE_IN_PS get4tdc::kdBinSize -GET4_EPOCH_IN_BINS get4tdc::kiEpochInBins -GET4_EPOCH_IN_PS get4tdc::kdEpochInPs - -psubevt->GetSubcrate() fcSubCrate -psubevt->GetControl() fcControl -psubevt->GetDlen() uLength ??? -psubevt->GetDataField() pMbsData - -GetTriggerNumber() Not available (TCBMBeamtimeProc method) -GetEventNumber() Not available (TCBMBeamtimeProc method) -*/ - -Bool_t TGet4v1MessageExtended::RocOrder( const TGet4v1MessageExtended &messageToCompare) const -{ - /* - * TODO: update with 32bit - */ - if( uRocEpochCycle < messageToCompare.GetRocCycle() ) // messageToCompare in next Cycle - return kTRUE; - else if( uRocEpochCycle > messageToCompare.GetRocCycle() ) // messageToCompare in prev Cycle - return kFALSE; - else if( uRocEpoch < messageToCompare.GetRocEpoch() ) // messageToCompare in next Epoch - return kTRUE; - else if( uRocEpoch > messageToCompare.GetRocEpoch() ) // messageToCompare in prev Epoch - return kFALSE; - else // Same cycle and same epoch! - { - UInt_t typ1 = fxMessage.getMessageType(); - UInt_t typ2 = (messageToCompare.GetRocMessage()).getMessageType(); - if( typ1 == roc::MSG_SYS && typ2 == roc::MSG_SYS) // Both External synch messages - { - if( fxMessage.getField(23,12) <= (messageToCompare.GetRocMessage()).getField(23,12) ) - return kTRUE; - else return kFALSE; - } - else if( typ1 == roc::MSG_SYS ) // Only this message is Ext Synch - { - if( ((fxMessage.getField(23,12))<<7) <= (messageToCompare.GetRocMessage()).getGet4Ts() ) - return kTRUE; - else return kFALSE; - } - else if( typ2 == roc::MSG_SYS) // Only messageToCompare is Ext Synch - { - if( fxMessage.getGet4Ts() <= (((messageToCompare.GetRocMessage()).getField(23,12))<<7) ) - return kTRUE; - else return kFALSE; - } - else // Both are data messages - { - if( fxMessage.getGet4Ts() <= (messageToCompare.GetRocMessage()).getGet4Ts() ) - return kTRUE; - else return kFALSE; - } - } -} - -Double_t TGet4v1MessageExtended::RocSpacing( const TGet4v1MessageExtended &messageToCompare) const -{ - /* - * TODO: update with 32bit - */ - UInt_t typ1 = fxMessage.getMessageType(); - UInt_t typ2 = (messageToCompare.GetRocMessage()).getMessageType(); - if( roc::MSG_GET4 != typ1 || roc::MSG_GET4 != typ2 ) // not a hit info - return -1; - // distance between two messages in bin multiplied by 0.05 ns. - double dSpacing = get4tdc::kdBinSize * (double) ( (double) (messageToCompare.GetRocMessage()).getGet4Ts() - - (double)fxMessage.getGet4Ts() ); - // When messages are not in the same epoch - // the time has to be corrected - if ( uRocEpoch != messageToCompare.GetRocEpoch() ) - { - if( uRocEpochCycle != messageToCompare.GetRocCycle() ) - { - dSpacing += get4tdc::kdEpochInPs * (double) ( (double)messageToCompare.GetRocEpoch() - - (double)uRocEpoch + - (double)get4v10::kulGet4EpochCycleSz * (double) ( (double)messageToCompare.GetRocCycle() - - (double)uRocEpochCycle ) ); - } - else - { - dSpacing += get4tdc::kdEpochInPs * (double) ( (double)messageToCompare.GetRocEpoch() - - (double)uRocEpoch ); - } - } - // returns time in ps. - return dSpacing; -} - -void TGet4v1MessageExtended::Print( unsigned kind ) const -{ - if( roc::MSG_SYS == fxMessage.getMessageType() ) - { - UShort_t ucSysMesType = fxMessage.getSysMesType(); // change type to avoid warning if last Chip id reach char type size - if( get4v10::SYSMSG_GET4V1_32BIT_0 <= ucSysMesType && - ucSysMesType <= get4v10::SYSMSG_GET4V1_32BIT_15 ) - { - Print32Bit( kind ); - } // case SYSMSG_GET4V1_32BIT + channel! - else fxMessage.printData( kind, uRocEpoch + get4v10::kulGet4EpochCycleSz*uRocEpochCycle ); - } - else fxMessage.printData( kind, uRocEpoch + get4v10::kulGet4EpochCycleSz*uRocEpochCycle ); - -} -void TGet4v1MessageExtended::Print32Bit( unsigned kind ) const -{ - - TString sPrintout =""; - ULong64_t data = ((ULong64_t)fxMessage.getField( 48, 16 ) )<<48 | - ((ULong64_t)fxMessage.getField( 32, 16 ) )<<32 | - ((ULong64_t)fxMessage.getField( 16, 16 ) )<<16 | - ((ULong64_t)fxMessage.getField( 0, 16 ) ); - - if( kind & roc::msg_print_Hex ) - { - UChar_t* arr = (uint8_t*) &data; - sPrintout += Form("%02X:%02X:%02X:%02X:%02X:%02X ", - arr[0], arr[1], arr[2], arr[3], arr[4], arr[5]); - } // if( kind & msg_print_Hex ) - - if( kind & roc::msg_print_Prefix ) - { - sPrintout += Form( "Msg:%u Roc:%u ", fxMessage.getMessageType(), fxMessage.getRocNumber()); - } // if( kind & msg_print_Prefix) - if (kind & roc::msg_print_Human) - { - Double_t timeInSec = fxMessage.getMsgFullTimeD(fuFulltime >> 14)/1.e9; // <--- to be change !!!!! - sPrintout += Form( "SysType:%2x Data:%8x @%17.11f : ", fxMessage.getSysMesType(), fxMessage.getSysMesData(), timeInSec); - } // if( kind & msg_print_Human ) - else sPrintout += Form( "SysType:%2x Data:%8x : ", fxMessage.getSysMesType(), fxMessage.getSysMesData()); - - UInt_t get4_32b_type = getFieldBE(fxMessage, 46, 2); //(dataBE>>46) & 0x3; - switch(get4_32b_type) - { - case 0: // epoch message - { - UInt_t get4_32b_ep_epoch = getFieldBE(fxMessage, 17,24); //(dataBE>>17) & 0xFFFFFF; - UInt_t get4_32b_ep_sync = getBitBE(fxMessage, 16); //(dataBE>>16) & 0x000001; - sPrintout += Form( "Get4 V1 32 bits, type:0x%02x => Epoch %08d Sync: %1d", - get4_32b_type, get4_32b_ep_epoch, get4_32b_ep_sync ); - break; - } - case 1: // slow control message - { - UInt_t get4_32b_sl_data = getFieldBE(fxMessage, 16, 24); //(dataBE>>16) & 0xFFFFFF; - UInt_t get4_32b_sl_type = getFieldBE(fxMessage, 40, 2); //(dataBE>>40) & 0x3; - UInt_t get4_32b_sl_edge = getBitBE(fxMessage, 42); //(dataBE>>42) & 0x1; - UInt_t get4_32b_sl_chan = getFieldBE(fxMessage, 43, 2); //(dataBE>>43) & 0x3; - sPrintout += Form("Get4 V1 32 bits, type:0x%02x => Slow control Chan:%01d Edge:%01d Type:%01x Data:0x%06x", - get4_32b_type, get4_32b_sl_chan, get4_32b_sl_edge, get4_32b_sl_type, get4_32b_sl_data ); - break; - } - case 2: // error event - { - UInt_t get4_32b_er_code = getFieldBE(fxMessage, 16,7); //(dataBE>>16) & 0x7f; - UInt_t get4_32b_er_chan = getFieldBE(fxMessage, 42,2); //(dataBE>>42) & 0x3; - UInt_t get4_32b_er_edge = getBitBE(fxMessage, 44); //(dataBE>>44) & 0x1; - sPrintout += Form("Get4 V1 32 bits, type:0x%02x => Error 0x%02x Channel %1d Edge %1d", - get4_32b_type, get4_32b_er_code, get4_32b_er_chan, get4_32b_er_edge ); - break; - } - case 3: // data event - { - UInt_t get4_32b_dat_tot = getFieldBE(fxMessage, 16, 8); //(dataBE>>16) & 0xff; - UInt_t get4_32b_dat_ft = getFieldBE(fxMessage, 24, 7); //(dataBE>>24) & 0x7f; - UInt_t get4_32b_dat_ts = getFieldBE(fxMessage, 31,12); //(dataBE>>31) & 0xfff; - UInt_t get4_32b_dat_chan = getFieldBE(fxMessage, 43, 2); //(dataBE>>43) & 0x3; - UInt_t get4_32b_dat_dll = getBitBE(fxMessage, 45); //(dataBE>>45) & 0x1; - sPrintout += Form("Get4 V1 32 bits, type:0x%02x => Data Dll %1d Channel %1d Ts:0x%04d Ft:0x%03d Tot:0x%03d", - get4_32b_type, get4_32b_dat_dll, get4_32b_dat_chan, get4_32b_dat_ts, - get4_32b_dat_ft, get4_32b_dat_tot); - break; - } - default: - sPrintout += Form("Get4 V1 32 bits, type:0x%02x ", get4_32b_type ); - break; - } // switch(get4_32b_type) - cout<<sPrintout<<endl; -} - -/*****************************************************************************/ -/* Get4 v1.0 hit */ -Get4v1Hit::Get4v1Hit() : - TObject(), - fbIs32Bit(kFALSE), - fTimeMessage(), - fbTimeSet(kFALSE), - fTotMessage(), - fbTotSet(kFALSE), - fdTot(0.) -{ - Clear(); -} -void Get4v1Hit::Clear( Option_t * /*t*/ ) -{ - fbTimeSet = kFALSE; - fbTotSet = kFALSE; - fdTot = 0.0; - fbIs32Bit = kFALSE; -} -void Get4v1Hit::SetFullHit24Bits( TGet4v1MessageExtended& mesTime, TGet4v1MessageExtended& mesTot) -{ - if( kFALSE == mesTime.Is32Bit() && kFALSE == mesTot.Is32Bit() ) - { - /* TODO - * Check on compatibility Time with Tot - */ - fTimeMessage = mesTime; - fTotMessage = mesTot; - fbTimeSet = kTRUE; - fbTotSet = kTRUE; - fbIs32Bit = kFALSE; - CalculateTot(); - } // if( kFALSE == mesTime.Is32Bit() && kFALSE == mesTot.Is32Bit() ) -} -void Get4v1Hit::SetFullHit32Bits( TGet4v1MessageExtended& mesHit, Double_t d32bTotRange ) -{ - if( kTRUE == mesHit.Is32Bit() ) - { - fTimeMessage = mesHit; - fbTimeSet = kTRUE; - fbTotSet = kTRUE; - fbIs32Bit = kTRUE; - CalculateTot( d32bTotRange ); - } // if( mesHit.Is32Bit() ) -} -void Get4v1Hit::SetTime24Bits( TGet4v1MessageExtended& mesTime ) -{ - if( kFALSE == mesTime.Is32Bit() ) - { - fTimeMessage = mesTime; - fbTimeSet = kTRUE; - fbIs32Bit = kFALSE; - /* TODO - * Check on compatibility Time with Tot - */ - if( kTRUE == IsComplete() ) - CalculateTot(); - } // if( kFALSE == mesTime.Is32Bit() && kFALSE == mesTot.Is32Bit() ) -} -void Get4v1Hit::SetTot24Bits( TGet4v1MessageExtended& mesTot ) -{ - if( kFALSE == mesTot.Is32Bit() ) - { - fTotMessage = mesTot; - fbTotSet = kTRUE; - fbIs32Bit = kFALSE; - /* TODO - * Check on compatibility Time with Tot - */ - if( kTRUE == IsComplete() ) - CalculateTot(); - } // if( kFALSE == mesTot.Is32Bit() ) -} -void Get4v1Hit::CalculateTot( Double_t d32bTotRange ) -{ - if( kTRUE == fbIs32Bit ) - fdTot = ((Double_t)fTimeMessage.getGet4V10R32HitTot() ) * (d32bTotRange/255.0); - else fdTot = fTimeMessage.RocSpacing( fTotMessage); -} -Double_t Get4v1Hit::GetHitTime() -{ - /* - * TODO: Epoch borders!!! - */ - if( kTRUE == fbIs32Bit ) - return get4tdc::kdBinSize * fTimeMessage.getGet4V10R32HitTimeBin(); - else return get4tdc::kdBinSize * (fTimeMessage.GetRocMessage()).getGet4Ts(); -} -Int_t Get4v1Hit::GetHitLeadingFTS() -{ - if( kTRUE == fbIs32Bit ) - return (Int_t)(fTimeMessage.getGet4V10R32HitFt()); - else return (Int_t)( ( (fTimeMessage.GetRocMessage()).getGet4Ts() )%get4tdc::kiFineTime ); -} -Int_t Get4v1Hit::GetHitTrailingFTS() -{ - if( kTRUE == fbIs32Bit ) - return 0; - else return (Int_t)( ( (fTotMessage.GetRocMessage()).getGet4Ts() )%get4tdc::kiFineTime ); -} -Double_t Get4v1Hit::GetTimeDiff( Get4v1Hit& hitToCompare ) -{ - if( kTRUE == fbIs32Bit && - kTRUE == hitToCompare.Is32Bit() ) - { - // Both 32 bits - /* - * TODO: update RocSpacing, this is just a temp solution, not sure of resolution!!! - * or use GetHitTime with epoch border check!!!! - */ - return (hitToCompare.GetHitFullTimeD() - GetHitFullTimeD())*1000.0; - } - else if( kTRUE == fbIs32Bit ) - return -1000000.0; // Not both the same => crazy ?!? - else if( kTRUE == hitToCompare.Is32Bit() ) - return 1000000.0; // Not both the same => crazy ?!? - else // Both 24 bits - return fTimeMessage.RocSpacing( (hitToCompare.GetTimeMessage()) ); -} -/*****************************************************************************/ -/* Get4 v1.0 TDC */ -Get4v1Tdc::~Get4v1Tdc() -{ - Clear(); -} -/* -Get4v1Tdc::Get4v1Tdc(const Get4v1Tdc& src) : TObject() -{ - for( Int_t iChan = 0; iChan < get4v10::kuNbChan; iChan++) - fHits[iChan] = src.fHits[iChan]; -} -Get4v1Tdc & Get4v1Tdc::operator=(const Get4v1Tdc& src) -{ - // TObject copy attempt.... - TObject* ptrObj1 = this; - TObject* ptrObj2 = &src; - *ptrObj1 = *ptrObj2; - - for( Int_t iChan = 0; iChan < get4v10::kuNbChan; iChan++) - this.fHits[iChan] = src.fHits[iChan]; - return *this; -} -*/ -void Get4v1Tdc::Clear(Option_t * /*t*/ ) -{ - for(UInt_t uChannelIndex = 0; uChannelIndex < get4v10::kuNbChan; uChannelIndex++) - { - for(UInt_t uHitIndex = 0; uHitIndex < fHits[uChannelIndex].size(); uHitIndex++) - fHits[uChannelIndex][uHitIndex].Clear(); - fHits[uChannelIndex].clear(); - } -} -UInt_t Get4v1Tdc::Size() -{ - UInt_t uSize = 0; - for(UInt_t uChannelIndex = 0; uChannelIndex < get4v10::kuNbChan; uChannelIndex++) - uSize += fHits[uChannelIndex].size(); - return uSize; -} - -/*****************************************************************************/ -/* Real Event */ -Get4v1Event::Get4v1Event() : - TObject(), - fuMbsEventNumber(0), - fuEventNbInsideMbsEvt(0), - fuGlobalEventNumber(0), - fbMbsSyncedEvent(kFALSE), - fuSyncEventNumber(0), - fbDataTriggered(kFALSE), - fuTriggerIndex(0) -{ - Clear(); -} -Get4v1Event::~Get4v1Event() -{ - Clear(); -} -void Get4v1Event::Clear( Option_t * /*t*/ ) -{ - // all members should be cleared. - for(UInt_t uGet4Index = 0; uGet4Index < get4v10::kuMaxGet4; uGet4Index++) - fGet4Boards[uGet4Index].Clear( ); - - for(UInt_t uRocIndex = 0; uRocIndex < get4v10::kuMaxRoc; uRocIndex++) - { - fPureRocMessages[uRocIndex].clear(); - fdTriggerFullTime[uRocIndex] = 0.0; - } // for(UInt_t uRocIndex = 0; uRocIndex < get4v10::kuMaxGet4; uRocIndex++) - - fuMbsEventNumber = 0; - fuEventNbInsideMbsEvt = 0; - fuGlobalEventNumber = 0; - fbMbsSyncedEvent = kFALSE; - fuSyncEventNumber = 0; -} -UInt_t Get4v1Event::Size() -{ - UInt_t uSize = 0; - for(UInt_t uGet4Index = 0; uGet4Index < get4v10::kuMaxGet4; uGet4Index++) - uSize += fGet4Boards[uGet4Index].Size( ); - return uSize; -} -Bool_t Get4v1Event::IsEmpty() -{ - Bool_t bEmpty = kTRUE; - for(UInt_t uGet4Index = 0; uGet4Index < get4v10::kuMaxGet4; uGet4Index++) - bEmpty &= ( 0 == fGet4Boards[uGet4Index].Size( ) ); - return bEmpty; -} -Bool_t Get4v1Event::HasTrigger() -{ - Bool_t bTrigger = kFALSE; - for(UInt_t uRocIndex = 0; uRocIndex < get4v10::kuMaxRoc; uRocIndex++) - if( 0 < fdTriggerFullTime[uRocIndex] ) - { - bTrigger = kTRUE; - break; - } - return bTrigger; -} - -/////////////////////////////// - diff --git a/beamtime/tof/tdc/get4/TGet4v1Event.h b/beamtime/tof/tdc/get4/TGet4v1Event.h deleted file mode 100755 index f23bb371067c1b1c9beb6caaf92e9201239580d2..0000000000000000000000000000000000000000 --- a/beamtime/tof/tdc/get4/TGet4v1Event.h +++ /dev/null @@ -1,430 +0,0 @@ -#ifndef TGET4EVENT_H -#define TGET4EVENT_H - -#include <vector> - -/* - * Put all definitions here and use them in processor, - * since they are necessary for data structure of event - */ - -#include "TObject.h" - -#include "roc/Message.h" -//#include "Message.h" - -#include "TofGet4Def.h" -/* - * Conversion of definitions to constants: - * -MAX_ROC get4v10::kuMaxRoc -MAX_GET4 get4v10::kuMaxGet4 -MAX_GET4_PER_ROC get4v10::kiMaxGet4Roc -MAX_AUX get4v10::kiMaxAux -MAX_SYNC get4v10::kiMaxSync -GET4_PRINT get4v10::kiGet4MessPr -GET4_EPOCH_CYCLE_SIZE get4v10::kulGet4EpochCycleSz -MAIN_EPOCH_CYCLE_SIZE get4v10::kulMainEpochCycleSz -MAIN_CLK_SYNC_SIZE get4v10::kiSyncCycleSzMain -GET4_SYNC_CYCLE_SIZE get4v10::kiSyncCycleSzGet4 -MAX_DATA_TRIGG get4v10::kiMaxNbDataTriggs -MAX_SEC_TRIG get4v10::kiMaxNbSecTriggCh - -NB_BIN_GET4_FTS get4tdc::kiFineTime -GET4_BIN_SIZE_IN_PS get4tdc::kdBinSize -GET4_EPOCH_IN_BINS get4tdc::kiEpochInBins -GET4_EPOCH_IN_PS get4tdc::kdEpochInPs -GET4_CYCLE_IN_EPOCHS get4v10::kulGet4EpochCycleSz - -NB_CHAN_GET4 get4v10::kuNbChan instead of get4tdc::kuNbChan to accomodate 2tdc ch per input ch - -psubevt->GetSubcrate() fcSubCrate -psubevt->GetControl() fcControl -psubevt->GetDlen() uLength ??? -psubevt->GetDataField() pMbsData - -GetTriggerNumber() Not available (TCBMBeamtimeProc method) -GetEventNumber() Not available (TCBMBeamtimeProc method) -*/ - -#ifdef HAVE_UINT8_T_HEADER_FILE -#include <_types/_uint8_t.h> -#include <_types/_uint16_t.h> -#include <_types/_uint32_t.h> -#include <_types/_uint64_t.h> -#else -#include <stdint.h> -#endif - -/* - * Extended message container. Keeps original ROC message, but adds full timestamp and - * optionally corrected adc valules. - * Note that extended messages inside the vector will be sorted after full timestamp - * by the TRocProc::FinalizeEvent - * - * TODO: Recalculation of full time when setting RocEpoch and/or RocCycle !!! - */ -class TGet4v1MessageExtended : public TObject -{ - public: - - TGet4v1MessageExtended(const roc::Message& msg, ULong64_t fulltime=0 ) : - TObject(), - fxMessage(msg), - fuFulltime(fulltime), - fdFullTime((Double_t)fulltime), - ffTriggerDeltaT(0), - fbIs32Bit(kFALSE), - uRocEpoch( 0 ), - uRocEpochCycle( 0 ), - fbIsEmpty(kFALSE) - { - } - - TGet4v1MessageExtended() : - TObject(), - fxMessage(), - fuFulltime(0), - fdFullTime(0), - ffTriggerDeltaT(0), - fbIs32Bit(kFALSE), - uRocEpoch( 0 ), - uRocEpochCycle( 0 ), - fbIsEmpty(kFALSE) - { - } - - virtual ~TGet4v1MessageExtended(){} - - // copy constructor, used by vector to copy content - TGet4v1MessageExtended(const TGet4v1MessageExtended& src) : TObject(), - fxMessage(src.fxMessage), fuFulltime(src.fuFulltime), fdFullTime(src.fdFullTime), - ffTriggerDeltaT(src.ffTriggerDeltaT), fbIs32Bit(src.fbIs32Bit), - uRocEpoch(src.uRocEpoch), uRocEpochCycle(src.uRocEpochCycle), - fbIsEmpty(src.fbIsEmpty){} - - /* this is used for timesorting the messages in the filled vectors */ - /* - bool operator<(const TGet4v1MessageExtended &rhs) const - { return (fuFulltime < rhs.fuFulltime); } - */ - /* Move to double version to insure GET4 messages ordering */ - bool operator<(const TGet4v1MessageExtended &rhs) const - { return (fdFullTime < rhs.fdFullTime); } - - void Clear(Option_t* ="") - { - fxMessage = roc::Message(); - fuFulltime = 0; - fdFullTime = 0; - ffTriggerDeltaT = 0; - fbIs32Bit = kFALSE; - uRocEpoch = 0; - uRocEpochCycle = 0; - SetEmptyFlag(); - } - - void SetRocMessage(const roc::Message & source) - { - fxMessage=source; - } - - const roc::Message& GetRocMessage() const - { - return fxMessage; - } - - UChar_t GetMessageType() const - { - return fxMessage.getMessageType(); - } - UChar_t GetSysMesType() const - { - return fxMessage.getSysMesType(); - } - - void SetFullTime(ULong64_t ts) - { - fuFulltime=ts; - fdFullTime = (Double_t) ts; - } - void SetFullTimeD(Double_t ts) - { - fdFullTime = ts; - fuFulltime = (ULong64_t)ts; - } - ULong64_t GetFullTime() const - { - return fuFulltime; - } - Double_t GetFullTimeD() const - { - return fdFullTime; - } - - uint16_t GetRocNumber() const - { - return fxMessage.getRocNumber(); - } - - uint8_t GetGet4Number() const - { - return fxMessage.getGet4Number(); - } - - uint8_t GetGet4ChNum() const - { - return fxMessage.getGet4ChNum(); - } - - uint32_t GetGet4Ts() const - { - return fxMessage.getGet4Ts(); - } - - Bool_t IsRisingGet4Edge() const - { - return fxMessage.getGet4Edge(); - } - - void SetTriggerDeltaT(float dt) - { - ffTriggerDeltaT=dt; - } - - float GetTriggerDeltaT() const - { - return ffTriggerDeltaT; - } - - Bool_t SetGet4MessageFull( const roc::Message & DataMessIn, UInt_t rocEpochIn, - UInt_t rocCycleIn) - { - fxMessage = DataMessIn; - uRocEpoch = rocEpochIn; - uRocEpochCycle = rocCycleIn; -/* - if( roc::MSG_GET4 == fxMessage.getMessageType() ) - fuFulltime = fxMessage.getMsgFullTime( uRocEpoch ); - else if(roc::MSG_SYS == fxMessage.getMessageType() && - roc::SYSMSG_GET4_EVENT == fxMessage.getSysMesType() ) - fuFulltime = fxMessage.FullTimeStamp2(uRocEpoch, (fxMessage.getField(23,12)<<7) ) - / 20 + 512; -*/ - return kTRUE; - } - - Bool_t SetRocEpoch( UInt_t rocEpochIn) - { - uRocEpoch = rocEpochIn; - /* - if( roc::MSG_GET4 == fxMessage.getMessageType() ) - fuFulltime = fxMessage.getMsgFullTime( uRocEpoch ); - else if(roc::MSG_SYS == fxMessage.getMessageType() && - roc::SYSMSG_GET4_EVENT == fxMessage.getSysMesType() ) - fuFulltime = fxMessage.FullTimeStamp2(uRocEpoch, (fxMessage.getField(23,12)<<7) ) - / 20 + 512; - */ - return kTRUE; - } - Bool_t SetRocCycle( UInt_t rocCycleIn) - { - uRocEpochCycle = rocCycleIn; - return kTRUE; - } - - UInt_t GetRocEpoch() const - { - return uRocEpoch; - } - UInt_t GetRocCycle() const - { - return uRocEpochCycle; - } - - Bool_t RocOrder( const TGet4v1MessageExtended &messageToCompare )const; - Double_t RocSpacing( const TGet4v1MessageExtended &messageToCompare) const; - - void Print( unsigned kind = roc::msg_print_Human ) const; - void Print32Bit( unsigned kind = roc::msg_print_Human ) const; - - // Implement to remove warning - void Print(Option_t*) const {;} - - // All Get4 v1.0 24 bit messages - inline void SetGet4Number( UChar_t ucGet4Index) { fxMessage.setGet4Number(ucGet4Index); } - inline void SetEpoch2ChipNumber(UChar_t ucGet4Index) { fxMessage.setEpoch2ChipNumber(ucGet4Index); } - - // Get4 v1,0 32bits message function (later general?) - inline UInt_t getFieldBE(roc::Message rawMessage, UInt_t shift, UInt_t len) const - { return (dataBE(rawMessage) >> shift) & ((((UInt_t)1) << len) - 1); } - inline UChar_t getBitBE(roc::Message rawMessage, UInt_t shift) const - { return (dataBE(rawMessage) >> shift) & 1; } - inline ULong64_t dataBE( roc::Message rawMessage) const - { return (((ULong64_t)rawMessage.getField(0, 8) &0x00000000000000FF)<<56)+ - ( ((ULong64_t)rawMessage.getField(0, 16) &0x000000000000FF00)<<40)+ - ( ((ULong64_t)rawMessage.getField(0, 24) &0x0000000000FF0000)<<24)+ - ( ( ((ULong64_t)rawMessage.getField( 8, 24) <<8 ) &0x00000000FF000000)<< 8)+ - ( ( ((ULong64_t)rawMessage.getField(16, 24)) << 8)&0x00000000FF000000)+ - ( ((ULong64_t)rawMessage.getField(24, 24) )&0x0000000000FF0000)+ - ( ((ULong64_t)rawMessage.getField(40, 16) )&0x000000000000FF00)+ - ( ((ULong64_t)rawMessage.getField(56, 8) )&0x00000000000000FF); - } - - inline UChar_t getGet4V10R32ChipId() const { return ( (fxMessage.getSysMesType() )&0xF ); } - inline UChar_t getGet4V10R32MessageType() const { return getFieldBE(fxMessage, 46, 2); } - // type 0 => Epoch message - inline UInt_t getGet4V10R32EpochNumber() const { return getFieldBE(fxMessage, 17,24); } - inline Bool_t getGet4V10R32SyncFlag() const { return getBitBE(fxMessage, 16); } - // type 1 => Slow control - inline UInt_t getGet4V10R32SlData() const { return getFieldBE(fxMessage, 16,24); } - inline UChar_t getGet4V10R32SlType() const { return getFieldBE(fxMessage, 40, 2); } - inline Bool_t getGet4V10R32SlEdge() const { return getBitBE(fxMessage, 42); } - inline UChar_t getGet4V10R32SlChan() const { return getFieldBE(fxMessage, 43, 2); } - // type 2 => Error message - inline UChar_t getGet4V10R32ErrorData() const { return getFieldBE(fxMessage, 16, 7); } - inline UChar_t getGet4V10R32ErrorChan() const { return getFieldBE(fxMessage, 42, 2); } - inline Bool_t getGet4V10R32ErrorEdge() const { return getBitBE(fxMessage, 44); } - // type 3 => Hit Data - inline UChar_t getGet4V10R32HitTot() const { return getFieldBE(fxMessage, 16, 8); } - inline UChar_t getGet4V10R32HitFt() const { return getFieldBE(fxMessage, 24, 7); } - inline UInt_t getGet4V10R32HitTs() const { return getFieldBE(fxMessage, 31,12); } - inline UInt_t getGet4V10R32HitTimeBin()const { return getFieldBE(fxMessage, 24,19); } - inline UChar_t getGet4V10R32HitChan() const { return getFieldBE(fxMessage, 43, 2); } - inline Bool_t getGet4V10R32HitDllFlag() const { return getBitBE(fxMessage, 45); } - - void Set32BitFlag(){ fbIs32Bit = kTRUE; }; - Bool_t Is32Bit(){ return fbIs32Bit; }; - void SetEmptyFlag(){ fbIsEmpty = kTRUE; }; - Bool_t IsEmpty(){ return fbIsEmpty; }; - protected: - - /* original roc message*/ - roc::Message fxMessage; - - /* full time stamp without correction*/ - ULong64_t fuFulltime; - Double_t fdFullTime; - - /* corrected time difference to trigger time of master ROC - * float range should be sufficient here*/ - float ffTriggerDeltaT; - - Bool_t fbIs32Bit; - UInt_t uRocEpoch; - UInt_t uRocEpochCycle; - - Bool_t fbIsEmpty; - - ClassDef(TGet4v1MessageExtended,1) -}; - -class Get4v1Hit : public TObject { - public: - Get4v1Hit(); - void Clear(Option_t *t=""); - void SetFullHit24Bits( TGet4v1MessageExtended& mesTime, TGet4v1MessageExtended& mesTot); - void SetFullHit32Bits( TGet4v1MessageExtended& mesHit, Double_t d32bTotRange = 25500.0 ); - void SetTime24Bits( TGet4v1MessageExtended& mesTime ); - void SetTot24Bits( TGet4v1MessageExtended& mesTot ); - - TGet4v1MessageExtended GetTimeMessage() { return fTimeMessage; }; - TGet4v1MessageExtended GetTotMessage() { return fTotMessage; }; - - UChar_t GetChan(){ return (kTRUE == fbIs32Bit? fTimeMessage.getGet4V10R32HitChan() : fTimeMessage.GetGet4ChNum()); }; - ULong_t GetHitFullTime(){ return fTimeMessage.GetFullTime(); }; - Double_t GetHitFullTimeD(){ return fTimeMessage.GetFullTimeD();}; - UInt_t GetHitEpoch(){ return fTimeMessage.GetRocEpoch(); }; - UInt_t GetHitCycle(){ return fTimeMessage.GetRocCycle(); }; - - Double_t GetHitTime(); - Double_t GetTot(){ return fdTot; }; - Int_t GetHitLeadingFTS(); - Int_t GetHitTrailingFTS(); - Double_t GetTimeDiff( Get4v1Hit& hitToCompare ); - - Bool_t IsTimeSet(){ return fbTimeSet;}; - Bool_t IsTotSet(){ return fbTotSet;}; - Bool_t IsComplete(){ return fbTimeSet && fbTotSet;}; - Bool_t Is32Bit(){ return fbIs32Bit; }; - - /* - // copy constructor, used by vector to copy content for sorting - Get4v1Hit(const Get4v1Hit& src) : - fTimeMessage(src.fTimeMessage), fbTimeSet(src.fbTimeSet), - fTotMessage(src.fTotMessage), fbTotSet(src.fbTotSet), - fdTot(src.fdTot) {}; - */ - - protected: - Bool_t fbIs32Bit; - void CalculateTot( Double_t d32bTotRange = 25500.0 ); - - TGet4v1MessageExtended fTimeMessage; - Bool_t fbTimeSet; - TGet4v1MessageExtended fTotMessage; - Bool_t fbTotSet; - Double_t fdTot; - - ClassDef(Get4v1Hit,1) -}; - -class Get4v1Tdc : public TObject { - public: - Get4v1Tdc() : TObject() { Clear(); } - ~Get4v1Tdc(); - void Clear(Option_t *t=""); - UInt_t Size(); - - std::vector<Get4v1Hit> fHits[get4v10::kuNbChan]; -/* - // copy constructor - Get4v1Tdc(const Get4v1Tdc& src); - // Assignment operator - Get4v1Tdc & operator=(const Get4v1Tdc& src); -*/ - ClassDef(Get4v1Tdc,1) -}; - -class Get4v1Event : public TObject { - public: - Get4v1Event(); - ~Get4v1Event(); - void Clear(Option_t *t=""); - UInt_t Size(); - Bool_t IsEmpty(); - Bool_t HasTrigger(); - Bool_t IsMbsSynced(){ return fbMbsSyncedEvent;}; - /*************************************/ - Get4v1Tdc fGet4Boards[get4v10::kuMaxGet4]; - - std::vector<TGet4v1MessageExtended> fPureRocMessages[get4v10::kuMaxRoc]; - - /* last time of trigger signal (defined by parameter) - * can be sync or aux message, depending on TGet4Parameter::triggerSignal setup*/ - Double_t fdTriggerFullTime[get4v10::kuMaxRoc]; - - // Event number of the corresponding MBS event - UInt_t fuMbsEventNumber; - // Index of the real event inside MBS event - UInt_t fuEventNbInsideMbsEvt; - // Total event number - UInt_t fuGlobalEventNumber; - - // Flag indicating that this real event is the one synchronized to MBS - Bool_t fbMbsSyncedEvent; - // Event Nmber from the sync message - UInt_t fuSyncEventNumber; - - // Flag indicating that this real event was made after finding coincidence in data - Bool_t fbDataTriggered; - // Index of the Data trigger making this event - UInt_t fuTriggerIndex; - - ClassDef(Get4v1Event,1) -}; - -#endif //TGET4V1EVENT_H - - - diff --git a/beamtime/tof/tdc/get4/TGet4v1Param.cxx b/beamtime/tof/tdc/get4/TGet4v1Param.cxx deleted file mode 100755 index 7a6df540f4ff3ea4ef2b32d5b54206c33ab700ef..0000000000000000000000000000000000000000 --- a/beamtime/tof/tdc/get4/TGet4v1Param.cxx +++ /dev/null @@ -1,531 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TGet4v1Rec.h ----- -// ----- Created 22/07/2013 by P.-A. Loizeau ----- -// ----- Adapted from TGet4v1Rec.h ----- -// ----- in RocLib/beamtime/tof-tdctest rev.4862 ----- -// ------------------------------------------------------------------ -#include "TGet4v1Param.h" - -#include "Riostream.h" - -#include <iostream> - -using std::cout; -using std::endl; - -TGet4v1Param::TGet4v1Param(): - TNamed("", "TGet4v1Param"), - numRocs (0), - noTrigger (kTRUE), - triggerSignal (0), - globalTrigger (kFALSE), - masterRoc (77777), - maxBufferTriggers (10), - maxBufferLoops (10), - doSorting (kFALSE), - bGet4Debug (kFALSE), - bTriggerAfterData (kFALSE), - iEventNbGap (-1), - uEventNbCycle (0), - uSyncCycleSize (0), - bSuppressedEpochs (kFALSE), - bLongTimeHistos (kFALSE), - uRocCycleSize (0), - uMainSyncCycleSize (0), - uNbRocsGet4 (0), - uNbGet4 (0), - uSilentMode (0), - uDebugHistoOn (0), - uDebugPrintOn (0), - uGet4Print (0), - uNbTriggerChan (0), - uCoincidenceWinSize(0), - b32bReadoutModeGet4v1 (kFALSE), - dMaxTot (300000.0), - bTotHistoEnable (kFALSE), - bDebugHistoEnable (kFALSE), - uNbEventsDnlUpdate (1000), - uGet4TimeDiffChip1 (0), - uGet4TimeDiffChip2 (0), - bChannelRateHistoEnable (kFALSE), - bChipRateHistoEnable (kFALSE), - bRawDataMode (kFALSE), - bFreeStreaming (kFALSE), - uNbTriggers (0), - dDeadTime (0.0), - bAllowEventMixing (kFALSE), - iMainReferenceTdc (-1), - iReference1Channel (-1), - iReference2Channel (-1) -{ -// numRocs = 0; - for (UInt_t roc=0;roc<get4v10::kuMaxRoc;roc++) { - activeRoc[roc] = kFALSE; - timeScale[roc] = 1.0; - timeShift[roc] = 0; - uGet4RocsMapping[roc] = 0; - } -/* - noTrigger = kTRUE; // ignore trigger window and take all messages with initial event division - triggerSignal = 0; // 0 .. 3 is AUXs, 10-11 is SYNCs - globalTrigger = kFALSE; // true for selecting messages under global corrected time window, false for using separate windows for each roc - masterRoc = 77777; // id number of ROC which is time/trigger reference, big number is disable master roc - maxBufferTriggers=10; - maxBufferLoops=10; - doSorting = kFALSE; // perform time sorting of messages - bGet4Debug = kFALSE; - - bTriggerAfterData = kFALSE; -*/ - /** GET4 unpacking & pre-processing **/ -/* - iEventNbGap = -1; // -1 = check Off, Gap in event nember between get4 events - uEventNbCycle = 0; // No Online Change - Size of the event nember cycle - uSyncCycleSize = 0; // No Online Change - Size of the synchronization cycle in epochs - bSuppressedEpochs = kFALSE;// No Online Change - kFALSE = Normal epoch operation, kTRUE = 24b readout suppressed epoch mode, epoch only just after data - bLongTimeHistos = kFALSE; // Enable some Long duration counts monitoring histos (10 days) - uRocCycleSize = 0; // No Online Change - Size of roc epoch counter cycle in epochs - uMainSyncCycleSize = 0; // No Online Change - Size of the synchronization cycle in Main clock (250MHz) epochs - uNbRocsGet4 = 0; // No Online Change - Nb of Rocs "GET4" in setup - uNbGet4 = 0; // No Online Change - Total Nb of active FEET boards in setup - uSilentMode = 0; // Remove all printouts => Blind mode! - uDebugHistoOn = 0; // No Online Change - Enable/Disable general debug histograms - uDebugPrintOn = 0; // Number of data messages to be printed on screen for debug - uGet4Print = 0; // Number of data messages to be printed on screen for debug -*/ - /************* GET4 v1.x debug *******/ -/* - dMaxTot = 300000.0; // Maximal allowed Tot for 24 bits hit building, in ps - bTotHistoEnable = kFALSE; // Enable Tot histograms - bDebugHistoEnable = kFALSE; // Enable the time difference, finetime and DNL histograms - uNbEventsDnlUpdate = 1000; // Nb of events between 2 updates of the DNL histograms - uGet4TimeDiffChip1 = 0; // Index of first chip to be used for time difference histos - uGet4TimeDiffChip2 = 0; // Index of first chip to be used for time difference histos - bChannelRateHistoEnable = kFALSE; // Enable Rate histograms for each channel - bChipRateHistoEnable = kFALSE; // Enable Rate histograms for each chip -*/ - /*************************************/ - /*********** free-streaming **********/ -/* - bRawDataMode = kFALSE; // kFALSE = DABC data format, 1 SYNC/Event, kTRUE = RAW DATA format, all messages - bFreeStreaming = kFALSE; // kFALSE = Sync trigger/no trigger, kTRUE= online detection/selection from data -*/ - /*************************************/ - - for (UInt_t n=0;n<get4v10::kuMaxGet4;n++) { - uGet4Mapping[n] = 0; // No Online Change - Get4 Mapping: there should be always at least 2*nbfeets entries here - uGet4Active[n] = 0; // Activated Get4 chips (indexes after remapping => not hardware map !) - uGet4EdgeInversion[n] = 0; // Edges inversion: affect all channels of a GET4 chip - } -/* - iMainReferenceTdc = -1; // No Online Change - TDC used for the reference signals profiles in Detector classes, -1 disable it - iReference1Channel = -1; // No Online Change - Channel used for the 1st reference histogram in Detector classes, -1 disable it - iReference2Channel = -1; // No Online Change - Channel used for the 2nd reference histogram in Detector classes, -1 disable it -*/ -} - - - -TGet4v1Param::TGet4v1Param(const char* name): - TNamed(name, "TGet4v1Param"), - numRocs (0), - noTrigger (kTRUE), - triggerSignal (0), - globalTrigger (kFALSE), - masterRoc (77777), - maxBufferTriggers (10), - maxBufferLoops (10), - doSorting (kFALSE), - bGet4Debug (kFALSE), - bTriggerAfterData (kFALSE), - iEventNbGap (-1), - uEventNbCycle (0), - uSyncCycleSize (0), - bSuppressedEpochs (kFALSE), - bLongTimeHistos (kFALSE), - uRocCycleSize (0), - uMainSyncCycleSize (0), - uNbRocsGet4 (0), - uNbGet4 (0), - uSilentMode (0), - uDebugHistoOn (0), - uDebugPrintOn (0), - uGet4Print (0), - uNbTriggerChan (0), - uCoincidenceWinSize(0), - b32bReadoutModeGet4v1 (kFALSE), - dMaxTot (300000.0), - bTotHistoEnable (kFALSE), - bDebugHistoEnable (kFALSE), - uNbEventsDnlUpdate (1000), - uGet4TimeDiffChip1 (0), - uGet4TimeDiffChip2 (0), - bChannelRateHistoEnable (kFALSE), - bChipRateHistoEnable (kFALSE), - bRawDataMode (kFALSE), - bFreeStreaming (kFALSE), - uNbTriggers (0), - dDeadTime (0.0), - bAllowEventMixing (kFALSE), - iMainReferenceTdc (-1), - iReference1Channel (-1), - iReference2Channel (-1) -{ -// numRocs = 4; - for (UInt_t rocid=0;rocid<get4v10::kuMaxRoc; rocid++) { - if(rocid<numRocs) - activeRoc[rocid]=kTRUE; - else - activeRoc[rocid]=kFALSE; - - timeScale[rocid]=1.0; - timeShift[rocid]=0; - } -/* - globalTrigger = true; - - // use AUX2 as default trigger signal, while it is external trigger input for ROC - triggerSignal = 2; - noTrigger = kFALSE; - masterRoc = 0; - maxBufferTriggers=10; - maxBufferLoops=10; - doSorting = kTRUE; - bGet4Debug = kFALSE; - - bTriggerAfterData = kFALSE; -*/ - /** GET4 unpacking & pre-processing **/ -/* - iEventNbGap = -1; // -1 = check Off, Gap in event nember between get4 events - uSyncCycleSize = 0; // No Online Change - Size of the synchronization cycle in epochs - bSuppressedEpochs = kFALSE;// No Online Change - kFALSE = Normal epoch operation, kTRUE = 24b readout suppressed epoch mode, epoch only just after data - bLongTimeHistos = kFALSE; // Enable some Long duration counts monitoring histos (10 days) - uRocCycleSize = 0; // No Online Change - Size of roc epoch counter cycle in epochs - uMainSyncCycleSize = 0; // No Online Change - Size of the synchronization cycle in Main clock (250MHz) epochs - uNbRocsGet4 = 0; // No Online Change - Nb of Rocs "GET4" in setup - uNbGet4 = 0; // No Online Change - Total Nb of active FEET boards in setup - uSilentMode = 0; // Remove all printouts => Blind mode! - uDebugHistoOn = 0; // No Online Change - Enable/Disable general debug histograms - uDebugPrintOn = 0; // Number of data messages to be printed on screen for debug - uGet4Print = 0; // Number of data messages to be printed on screen for debug -*/ - /************* GET4 v1.x debug *******/ -/* - dMaxTot = 300000.0; // Maximal allowed Tot for 24 bits hit building, in ps - bTotHistoEnable = kFALSE; // Enable Tot histograms - bDebugHistoEnable = kFALSE; // Enable the time difference, finetime and DNL histograms - uNbEventsDnlUpdate = 1000; // Nb of events between 2 updates of the DNL histograms - uGet4TimeDiffChip1 = 0; // Index of first chip to be used for time difference histos - uGet4TimeDiffChip2 = 0; // Index of first chip to be used for time difference histos - bChannelRateHistoEnable = kFALSE; // Enable Rate histograms for each channel - bChipRateHistoEnable = kFALSE; // Enable Rate histograms for each chip -*/ - /*************************************/ - /*********** free-streaming **********/ -/* - bRawDataMode = kFALSE; // kFALSE = DABC data format, 1 SYNC/Event, kTRUE = RAW DATA format, all messages - bFreeStreaming = kFALSE; // kFALSE = Sync trigger/no trigger, kTRUE= online detection/selection from data -*/ - /*************************************/ - - for (UInt_t n=0;n<get4v10::kuMaxGet4;n++) { - uGet4Mapping[n] = 0; // No Online Change - Get4 Mapping: there should be always at least 2*nbfeets entries here - uGet4Active[n] = 0; // Activated Get4 chips (indexes after remapping => not hardware map !) - uGet4EdgeInversion[n] = 0; // Edges inversion: affect all channels of a GET4 chip - } -/* - iMainReferenceTdc = -1; // No Online Change - TDC used for the reference signals profiles in Detector classes, -1 disable it - iReference1Channel = -1; // No Online Change - Channel used for the 1st reference histogram in Detector classes, -1 disable it - iReference2Channel = -1; // No Online Change - Channel used for the 2nd reference histogram in Detector classes, -1 disable it -*/ -} - -TGet4v1Param::~TGet4v1Param() -{ - SetNbRocsGet4(0); - - SetNbGet4(0); -} - -// Roc functions -Bool_t TGet4v1Param::SetConfigRocs() -{ - /* - for (UInt_t rocid=0;rocid<get4v10::kuMaxRoc; rocid++) - { - TGet4v1Event::ConfigRocs[rocid] = rocid < numRocs ? (UInt_t) activeRoc[rocid] : 0; - cout <<"TGet4v1Param::SetConfigRocs sets rocid " << rocid << " to active:" << TGet4v1Event::ConfigRocs[rocid] << endl; - } - */ - return kTRUE; -} - -// Get4 functions -void TGet4v1Param::SetNbRocsGet4(UInt_t num) -{ - uNbRocsGet4 = num; - - if (uNbRocsGet4 > get4v10::kuMaxRoc) uNbRocsGet4 = get4v10::kuMaxRoc; - - if (uNbRocsGet4==0) return; - for (unsigned n=0;n<uNbRocsGet4;n++) - uGet4RocsMapping[n] = n; -} - -Int_t TGet4v1Param::FindGet4RocId(UInt_t rocid) const -{ - for(Int_t iGet4Roc=0; iGet4Roc < (Int_t)uNbRocsGet4; iGet4Roc++) - if(rocid == uGet4RocsMapping[iGet4Roc]) return iGet4Roc; - - return -1; -} - -UInt_t TGet4v1Param::DefineGet4IndexOffset(UInt_t rocid) const -{ - Int_t id = FindGet4RocId(rocid); - return id>=0 ? id*get4v10::kuMaxGet4Roc : 0; -} - -void TGet4v1Param::SetNbGet4(UInt_t num) -{ - - uNbGet4 = num; - if (uNbGet4>get4v10::kuMaxGet4) uNbGet4 = get4v10::kuMaxGet4; - - if (uNbGet4==0) return; - - for(UInt_t uGet4Index = 0; uGet4Index < uNbGet4; uGet4Index++) { - // No Online Change - Get4 Mapping: there should be always at least 2*nbfeets entries here - uGet4Mapping[uGet4Index] = uGet4Index; - // Activated Get4 chips (indexes after remapping => not hardware map !) - uGet4Active[uGet4Index] = 0; - // Edges inversion: affect all channels of a GET4 chip - uGet4EdgeInversion[uGet4Index] = 0; - } -} - -UInt_t TGet4v1Param::RemapGet4Chip(UInt_t uChip) const -{ - for(UInt_t temp_index = 0; temp_index < uNbGet4; temp_index++) - if( uChip == uGet4Mapping[temp_index]) return temp_index; - return uNbGet4; -} -UInt_t TGet4v1Param::RemapGet4Chip(UInt_t roc, UInt_t uChip) const -{ - for(UInt_t temp_index = 0; temp_index < uNbGet4; temp_index++) - if( DefineGet4IndexOffset(roc)+uChip == uGet4Mapping[temp_index]) return temp_index; - return uNbGet4; -} - -// Data Triggering -/** Return -1 if not a main channel for any trigger, trigger number otherwise */ -Int_t TGet4v1Param::IsTriggerMainChannel( UInt_t tdc, UInt_t channel ) -{ - for( UInt_t uTrigger = 0; uTrigger < uNbTriggers; uTrigger++) - { - if( tdc == uMainSelectionTdc[uTrigger] && - channel == uMainSelectionChannel[uTrigger]) - return uTrigger; - } // for( UInt_t uTrigger = 0; uTrigger < uNbTriggers; uTrigger++) - return -1; -} -/** Return -1 if not a secondary channel for any trigger, trigger number otherwise */ -Int_t TGet4v1Param::IsTriggerSecChannel( UInt_t tdc, UInt_t channel ) -{ - for( UInt_t uTrigger = 0; uTrigger < uNbTriggers; uTrigger++) - { - if( 0 < uNbSecondarySelectionCh[uTrigger]) - { - for(UInt_t uSecondary = 0; uSecondary < uNbSecondarySelectionCh[uTrigger]; uSecondary++) - if( tdc == uSecondarySelectionTdc[uTrigger][uSecondary] && - channel == uSecondarySelectionChannel[uTrigger][uSecondary] ) - return uTrigger; - } // if( 0 < uNbSecondarySelectionCh[iTrigger]) - } // for( UInt_t uTrigger = 0; uTrigger < uNbTriggers; uTrigger++) - return -1; -} -/** Return secondary channel index if the group (trigger, tdc, channel) match, -1 otherwise */ -Int_t TGet4v1Param::GetSecChannelIndex( UInt_t uTrigger, UInt_t tdc, UInt_t channel ) -{ - if( 0 < uNbSecondarySelectionCh[uTrigger]) - { - for(UInt_t iSecondary = 0; iSecondary < uNbSecondarySelectionCh[uTrigger]; iSecondary++) - if( tdc == uSecondarySelectionTdc[uTrigger][iSecondary] && - channel == uSecondarySelectionChannel[uTrigger][iSecondary] ) - return iSecondary; - } // if( 0 < uNbSecondarySelectionCh[uTrigger]) - return -1; -} -Bool_t TGet4v1Param::IsMainOfThisTrigger( UInt_t uTrigger, UInt_t tdc, UInt_t channel ) -{ - if( tdc == uMainSelectionTdc[uTrigger] && - channel == uMainSelectionChannel[uTrigger]) - return kTRUE; - else return kFALSE; -} -Bool_t TGet4v1Param::IsSecOfThisTrigger( UInt_t uTrigger, UInt_t tdc, UInt_t channel ) -{ - for(UInt_t iSecondary = 0; iSecondary < uNbSecondarySelectionCh[uTrigger]; iSecondary++) - if( tdc == uSecondarySelectionTdc[uTrigger][iSecondary] && - channel == uSecondarySelectionChannel[uTrigger][iSecondary] ) - return kTRUE; - return kFALSE; -} - - -Bool_t TGet4v1Param::PrintGet4Options() -{ - cout<<"*************************************************"<<endl; - cout<<" Option values"<<endl; - cout<<"Trigger after data: "<<bTriggerAfterData<<endl; - cout<<"Event index gap: "<<iEventNbGap<<endl; - cout<<"Sync cycle size: "<<uSyncCycleSize<<" Epochs (1 synch + "<<(uSyncCycleSize-1)<<" Unsynched)"<<endl; - cout<<"Sync cycle size (Main): "<<uMainSyncCycleSize<<" Epochs (1 synch + "<<(uMainSyncCycleSize-1)<<" Unsynched)"<<endl; - cout<<"Nb ROC-GET4 : "<<uNbRocsGet4<<endl; - cout<<"Rocs Mapping : |- "; - for(UInt_t temp_index = 0; temp_index < uNbRocsGet4; temp_index++) - { - cout.width(2); - cout<<uGet4RocsMapping[temp_index]<<" "; - } - cout<<endl<<" |-> "; - for(UInt_t temp_index = 0; temp_index < uNbRocsGet4; temp_index++) - { - cout.width(2); - cout<<temp_index<<" "; - } - cout<<endl; - cout<<"Nb GET4 chips: "<<uNbGet4<<endl; - cout<<"Get4 Mapping : |- "; - for(UInt_t temp_index = 0; temp_index < uNbGet4; temp_index++) - { - cout.width(2); - cout<<uGet4Mapping[temp_index]<<" "; - } - cout<<endl<<" |-> "; - for(UInt_t temp_index = 0; temp_index < uNbGet4; temp_index++) - { - cout.width(2); - cout<<temp_index<<" "; - } - cout<<endl; - cout<<"Get4 Activated: |- "; - for(UInt_t temp_index = 0; temp_index < uNbGet4; temp_index++) - { - cout.width(2); - cout<<temp_index<<" "; - } - cout<<endl<<" |-> "; - for(UInt_t temp_index = 0; temp_index < uNbGet4; temp_index++) - { - cout.width(2); - cout<<uGet4Active[temp_index]<<" "; - } - cout<<endl; - cout<<"Get4 Inversion: |- "; - for(UInt_t temp_index = 0; temp_index < uNbGet4; temp_index++) - { - cout.width(2); - cout<<temp_index<<" "; - } - cout<<endl<<" |-> "; - for(UInt_t temp_index = 0; temp_index < uNbGet4; temp_index++) - { - cout.width(2); - cout<<uGet4EdgeInversion[temp_index]<<" "; - } - cout<<endl; - cout<<"Nb Get4 message printed: "<<uGet4Print<<endl; - if( 1 == uSilentMode ) - cout<<"Silent Mode : ON "<<endl; - else cout<<"Silent Mode : OFF"<<endl; - if( 1 == uDebugHistoOn ) - cout<<"Debug Histograms: ON "<<endl; - else cout<<"Debug Histograms: OFF"<<endl; - if( 1 == uDebugPrintOn ) - cout<<"Debug Printout: ON "<<endl; - else cout<<"Debug Printout: OFF"<<endl; - cout<<"Chips used for time diff: "<<uGet4TimeDiffChip1<<" and "<<uGet4TimeDiffChip2<<endl; - cout<<"Nb Get4 message printed: "<<uGet4Print<<endl; - cout<<"*************************************************"<<endl; - - /************* GET4 v1.0 *************/ - cout<<" Get4 v1.0 Option values"<<endl; - if( kTRUE == b32bReadoutModeGet4v1 ) - cout<<"Readout Mode: 32 bits "<<endl; - else - { - cout<<"Readout Mode: 24 bit"<<endl; - if( kTRUE == bSuppressedEpochs ) - cout<<"Suppressed epoch mode: ON "<<endl; - else cout<<"Suppressed epoch mode: OFF"<<endl; - } // else of if( kTRUE == b32bReadoutModeGet4v1 ) - if( kTRUE == bLongTimeHistos ) - cout<<"Long duration counts mon. hist.: ON "<<endl; - else cout<<"Long duration counts mon. hist.: OFF"<<endl; - cout<<"*************************************************"<<endl; - /*************************************/ - - /*********** free-streaming **********/ - if( kTRUE == bFreeStreaming ) - { - cout<<" Free-streaming Option values"<<endl; - for( UInt_t uTrigger = 0; uTrigger < uNbTriggers; uTrigger++) - { - cout<<"Tdc main trigger chan: "<<uMainSelectionTdc[uTrigger]<<endl; - cout<<"Channel main trigger: "<<uMainSelectionChannel[uTrigger]<<endl; - if( 0 < uNbSecondarySelectionCh[uTrigger]) - { - cout<<"Sec. trigger chans: |- "; - for(UInt_t temp_index = 0; temp_index < uNbSecondarySelectionCh[uTrigger]; temp_index++) - { - cout.width(3); - cout<<temp_index<<" "; - } - cout<<endl<<" TDC |-> "; - for(UInt_t temp_index = 0; temp_index < uNbSecondarySelectionCh[uTrigger]; temp_index++) - { - cout.width(3); - cout<<uSecondarySelectionTdc[uTrigger][temp_index]<<" "; - } - cout<<endl<<" Channel |-> "; - for(UInt_t temp_index = 0; temp_index < uNbSecondarySelectionCh[uTrigger]; temp_index++) - { - cout.width(3); - cout<<uSecondarySelectionChannel[uTrigger][temp_index]<<" "; - } - cout<<endl; - } - cout<<"Channel main trigger: "<<uMainSelectionChannel[uTrigger]<<endl; - cout<<"Coincidenc Window start: "<<dCoincidenceWindowStart[uTrigger]<<" ns relative to main channel hits"<<endl; - cout<<"Coincidenc Window stop: "<<dCoincidenceWindowStop[uTrigger]<<" ns relative to main channel hits"<<endl; - } // for( UInt_t uTrigger = 0; uTrigger < uNbTriggers; uTrigger++) - cout<<"Deadtime: "<<dDeadTime<<" ns"<<endl; - if( kTRUE == bAllowEventMixing ) - cout<<"Event mixing/superpos.: ON"<<endl; - else cout<<"Event mixing/superpos.: OFF"<<endl; - } // if( kTRUE == bFreeStreaming )// if( kTRUE == bFreeStreaming ) - else if( 9 < triggerSignal ) - cout<<" Use SYNC "<<(triggerSignal- 10)<<" as trigger"<<endl; - else cout<<" Use AUX "<<triggerSignal<<" as trigger"<<endl; - cout<<"*************************************************"<<endl; - /*************************************/ - /************** Detectors ************/ - if(-1 < iMainReferenceTdc ) - { - cout<<" Detectors Option values"<<endl; - cout<<"Tdc reference signals: "<<iMainReferenceTdc<<endl; - if( -1 < iReference1Channel ) - cout<<"Channel reference 1: "<<iReference1Channel<<endl; - else cout<<"Reference 1: OFF"<<endl; - if( -1 < iReference2Channel ) - cout<<"Channel reference 2: "<<iReference2Channel<<endl; - else cout<<"Reference 2: OFF"<<endl; - } // if(-1 < iMainReferenceTdc ) - else cout<<"Reference hist. in det.: OFF"<<endl; - cout<<"*************************************************"<<endl; - /*************************************/ - - return kTRUE; -} diff --git a/beamtime/tof/tdc/get4/TGet4v1Param.h b/beamtime/tof/tdc/get4/TGet4v1Param.h deleted file mode 100755 index 1d5d7506d29cab269a3894451fc738cd3e9a14fc..0000000000000000000000000000000000000000 --- a/beamtime/tof/tdc/get4/TGet4v1Param.h +++ /dev/null @@ -1,163 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TGet4v1Rec.h ----- -// ----- Created 22/07/2013 by P.-A. Loizeau ----- -// ----- Adapted from TGet4v1Rec.h ----- -// ----- in RocLib/beamtime/tof-tdctest rev.4862 ----- -// ------------------------------------------------------------------ - -#ifndef TGET4V1PARAM_H -#define TGET4V1PARAM_H - -#include "TofGet4Def.h" -#include "TNamed.h" - -class TGet4v1Param : public TNamed -{ - public: - - // default constructor - important for streamer - TGet4v1Param(); - - TGet4v1Param(const char* name); - - virtual ~TGet4v1Param(); - - /* implemented to copy setup of active roc to roc event */ -// virtual Bool_t UpdateFrom(TGo4Parameter* rhs); - - /* Actual set roc event configuration. To be used from setup macro*/ - Bool_t SetConfigRocs(); - - UInt_t numRocs; // maximum roc id in use +1 - - Bool_t activeRoc[get4v10::kuMaxRoc]; //enable roc of id - - Bool_t noTrigger; // ignore trigger window and take all messages with initial event division - - Int_t triggerSignal; // 0 .. 3 is AUXs, 10-11 is SYNCs - - Bool_t globalTrigger; // true for selecting messages under global corrected time window, false for using separate windows for each roc - - UInt_t masterRoc; // id number of ROC which is time/trigger reference for global roc - - UInt_t maxBufferTriggers; // maximum number of triggers in same mbs input buffer until retrieving next - UInt_t maxBufferLoops; // maximum number of loops over same mbs input buffer until retrieving next - - Double_t timeScale[get4v10::kuMaxRoc]; // scaling factor for time correction - - Int_t timeShift[get4v10::kuMaxRoc]; // instrumental time shift between triggers of each ROC - - Bool_t doSorting; // perform time sorting of messages - - Bool_t bGet4Debug; // provide debug information about Get4 errors - - Bool_t bTriggerAfterData; // kFALSE = SYNC arriving before the event data, kTRUE = after - - /** GET4 unpacking & pre-processing **/ - Int_t iEventNbGap; // -1 = check Off, Gap in event nember between get4 events - Int_t uEventNbCycle; // No Online Change - Size of the event nember cycle - UInt_t uSyncCycleSize; // No Online Change - Size of the synchronization cycle in epochs - // No Online Change - kFALSE = Normal epoch operation, - // kTRUE = 24b readout suppressed epoch mode, epoch only just after data - Bool_t bSuppressedEpochs; // No Online Change - For suppressed epoch mode in 24b readout - Bool_t bLongTimeHistos; // Enable some Long duration counts monitoring histos (10 days) - ULong64_t uRocCycleSize; // No Online Change - Size of roc epoch counter cycle in epochs - UInt_t uMainSyncCycleSize; // No Online Change - Size of the synchronization cycle in Main clock (250MHz) epochs - UInt_t uNbRocsGet4; // No Online Change - Nb of Rocs "GET4" in setup - UInt_t uGet4RocsMapping[get4v10::kuMaxRoc]; // No Online Change - Roc-GET4 id among indexes of all rocs - UInt_t uNbGet4; // No Online Change - Total Nb of active FEET boards in setup - UInt_t uGet4Mapping[get4v10::kuMaxGet4]; // No Online Change - Get4 Mapping: there should be always at least 2*nbfeets entries here - UInt_t uGet4Active[get4v10::kuMaxGet4]; // Activated Get4 chips (indexes after remapping => not hardware map !) - UInt_t uGet4EdgeInversion[get4v10::kuMaxGet4]; // Edges inversion: affect all channels of a GET4 chip - UInt_t uSilentMode; // Remove all printouts => Blind mode! - UInt_t uDebugHistoOn; // No Online Change - Enable/Disable general debug histograms - UInt_t uDebugPrintOn; // Number of data messages to be printed on screen for debug - UInt_t uGet4Print; // Number of data messages to be printed on screen for debug - - UInt_t uNbTriggerChan; // Number of Get4 channels to use for the coincidence trigger, max 8 - UInt_t uCoincidenceWinSize; // Size of the coincidence window for trigger building - UInt_t uTriggerChannels[8]; // Channels to be used for building a coincidence trigger - /*************************************/ - - /************* GET4 v1.0 *************/ - Bool_t b32bReadoutModeGet4v1; // Get4 v1.0 readout mode: kFALSE = 24 bits, kTRUE = 32 bits - /*************************************/ - /************* GET4 v1.x debug *******/ - Double_t dMaxTot; // Maximal allowed Tot for 24 bits hit building, in ps - Bool_t bTotHistoEnable; // Enable Tot histograms - Bool_t bDebugHistoEnable; // Enable the time difference, finetime and DNL histograms - UInt_t uNbEventsDnlUpdate; // Nb of events between 2 updates of the DNL histograms - UInt_t uGet4TimeDiffChip1; // Index of first chip to be used for time difference histos - UInt_t uGet4TimeDiffChip2; // Index of first chip to be used for time difference histos - Bool_t bChannelRateHistoEnable; // Enable Rate histograms for each channel - Bool_t bChipRateHistoEnable; // Enable Rate histograms for each chip - /*************************************/ - /*********** free-streaming **********/ - Bool_t bRawDataMode; // kFALSE = DABC data format, 1 SYNC/Event, kTRUE = RAW DATA format, all messages - Bool_t bFreeStreaming; // kFALSE = Sync trigger/no trigger, kTRUE= online detection/selection from data - UInt_t uNbTriggers; // Number of user defined data triggers - UInt_t uNbSecondarySelectionCh[get4v10::kiMaxNbDataTriggs]; // Nb of secondary channels to use for event detection/selection - UInt_t uMainSelectionTdc[get4v10::kiMaxNbDataTriggs]; // TDC index of the main signal for online selection. Selection window is relative to this - UInt_t uMainSelectionChannel[get4v10::kiMaxNbDataTriggs]; // Channel of the main signal for online selection. Selection window is relative to this - UInt_t uSecondarySelectionTdc[get4v10::kiMaxNbDataTriggs][get4v10::kiMaxNbSecTriggCh]; // TDC index of the secondary signals for online selection. - UInt_t uSecondarySelectionChannel[get4v10::kiMaxNbDataTriggs][get4v10::kiMaxNbSecTriggCh]; // Channel of the secondary signals for online selection. - Double_t dCoincidenceWindowStart[get4v10::kiMaxNbDataTriggs]; // Beginning of time window in which secondary channels have to be present, relative to main channel - Double_t dCoincidenceWindowStop[get4v10::kiMaxNbDataTriggs]; // End of time window in which secondary channels have to be present, relative to main channel - Double_t dDeadTime; // Minimal time between the main channel of two identical triggers in ns - - // kFALSE = 1 hit => max 1 event of same trigger, 2nd event ignored ( ~Deadtime ) - // kTRUE = 1 hit => all events matching trigger window inside MBS event as long as same trigger - Bool_t bAllowEventMixing; // kFALSE = 1 hit => max 1 event, kTRUE = 1 hit => all trigger window matching events inside MBS event - /*************************************/ - - /************** Detectors ************/ - Int_t iMainReferenceTdc; // No Online Change - TDC used for the reference signals profiles in Detector classes, -1 disable it - Int_t iReference1Channel; // No Online Change - Channel used for the 1st reference histogram in Detector classes, -1 disable it - Int_t iReference2Channel; // No Online Change - Channel used for the 2nd reference histogram in Detector classes, -1 disable it - /*************************************/ - - /** Set number of ROCs for Get4 readout, automatically sets default uFeetRocsMapping */ - void SetNbRocsGet4(UInt_t num); - - /** Find feet rocid, using uFeetRocsMapping. Return -1 if not exists in the map */ - Int_t FindGet4RocId(UInt_t rocid) const; - - /** Calculate offset for Get4 chip using rocid */ - UInt_t DefineGet4IndexOffset(UInt_t rocid) const; - - /** Change uNbGet4, automatically sets defaults for Get4Mapping, Get4Active and Get4EdgeInversion */ - void SetNbGet4(UInt_t num); - - /** Find Get4 chip in current map, returns uNbGet4 if not found */ - UInt_t RemapGet4Chip(UInt_t chip) const; - UInt_t RemapGet4Chip(UInt_t roc, UInt_t chip) const; - - /** Returns true if Roc id is inside mapping index */ - Bool_t IsValidRoc(UInt_t board) const { return board < numRocs; } - - /** Returns true if chip id is inside mapping index */ - Bool_t IsValidGet4Chip(UInt_t chip) const { return chip < uNbGet4; } - - /** Returns true if Roc id is activated */ - Bool_t IsActiveRoc(UInt_t board) const { return (board < numRocs)? (kTRUE == activeRoc[board]): kFALSE ; } - - /** Returns true if chip id is activated */ - Bool_t IsActiveGet4Chip(UInt_t chip) const { return (chip < uNbGet4)? (1 == uGet4Active[chip]): kFALSE; } - - /** Return -1 if not a main channel for any trigger, trigger number otherwise */ - Int_t IsTriggerMainChannel( UInt_t tdc, UInt_t channel ); - /** Return -1 if not a secondary channel for any trigger, trigger number otherwise */ - Int_t IsTriggerSecChannel( UInt_t tdc, UInt_t channel ); - /** Return secondary channel index if the group (trigger, tdc, channel) match, -1 otherwise */ - Int_t GetSecChannelIndex( UInt_t uTrigger, UInt_t tdc, UInt_t channel ); - - Bool_t IsMainOfThisTrigger( UInt_t uTrigger, UInt_t tdc, UInt_t channel ); - Bool_t IsSecOfThisTrigger( UInt_t uTrigger, UInt_t tdc, UInt_t channel ); - - Bool_t PrintGet4Options(); - - - ClassDef(TGet4v1Param, 1) -}; - -#endif // TGET4V1PARAM_H diff --git a/beamtime/tof/tdc/get4/TGet4v1Rec.cxx b/beamtime/tof/tdc/get4/TGet4v1Rec.cxx deleted file mode 100755 index 1bdc71ec2eed5375e93065a10407da56c03a9290..0000000000000000000000000000000000000000 --- a/beamtime/tof/tdc/get4/TGet4v1Rec.cxx +++ /dev/null @@ -1,498 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TGet4v1Rec.cxx ----- -// ----- Created 22/07/2013 by P.-A. Loizeau ----- -// ----- Adapted from TGet4v1Rec.cxx ----- -// ----- in RocLib/beamtime/tof-tdctest rev.4862 ----- -// ------------------------------------------------------------------ - -#include "TGet4v1Rec.h" - -TimeWindowCond::TimeWindowCond(): - TNamed("", "Time Window Condition"), - fdLowT (0.0), - fdHighT(0.0) -{ -} -TimeWindowCond::TimeWindowCond( const char* name, Double_t tLow, Double_t tHigh ): - TNamed( name, "Time Window Condition" ), - fdLowT (tLow), - fdHighT(tHigh) -{ -} - -void TimeWindowCond::SetValues( Double_t tLow, Double_t tHigh ) -{ - fdLowT = tLow; - fdHighT = tHigh; -} -void TimeWindowCond::Clear(Option_t *t) -{ - TNamed::Clear( t ); - fdLowT = 0.0; - fdHighT = 0.0; -} - -Bool_t TimeWindowCond::Test( Double_t dValToTest) -{ - if( fdLowT <= dValToTest && dValToTest <= fdHighT) - return kTRUE; - else return kFALSE; -} - -TGet4v1Rec::TGet4v1Rec() : - fRocId (0), - fIter(), - fMsgTypes (NULL), - fSysTypes (NULL), - fSysUserTypes (NULL), - fAUXch (NULL), - fTrigger_All (NULL), - fTrigger_AUX (NULL), - fTrigger_All_100 (NULL), - fTrigger_All_us (NULL), - fTrigger_All_ms (NULL), - fTrigger_All_s (NULL), - fTriggerWind (), - fAUXWind (), - fSelfTrigWind (), - fEvntMultipl (NULL), - fALLt (NULL), - fDATAt (NULL), - fERRORt (NULL), - fSLOWCt (NULL), - fSelfTriggT (NULL), - fEPOCHt (NULL), - fAllSelectedT (NULL), - fAllLongT (NULL), - fDataLongT (NULL), - fErrorLongT (NULL), - fSlowCLongT (NULL), - fSelfTriggLongT (NULL), - fEpochLongT (NULL), - fAllEpoch2LongT (NULL), - fAllSelLongT (NULL), - fLastTm (0), - fLastTriggerTm (0), - fStartSyncTm (0), - fStopSyncTm (0), - fUnprocessedMsg (), - fDabcSeparator (-1), - bIgnoreData (kFALSE), - fIgnoreCnt (0), - fIgnoreTime (0), - fCollectTime (0), - fuCurrEpoch (0), - fuEpochCycle (0), - fDistribEpochs (NULL), - fDistribEpochs2 (NULL), - fEpochShiftsPerChip (NULL), - fEpochShiftsDurationPerChip (NULL), - fbBufferWithLastFullEpoch (kFALSE), - fbEpochSinceTrigger (kFALSE), - fbSelectionRocDone (kTRUE), - fDataSelfTriggerPerEvent (NULL), - fDataSelfTrigDistanceNs (NULL), - fDataSelfTrigDistanceUs (NULL), - fDataSelfTrigDistanceMs (NULL), - fDataSelfTrigDistanceS (NULL), - fNbEventsPerMbsEvent (NULL), - fNbNotEmptyEventsPerMbsEvent (NULL), - fChannelsMapping (NULL), - fChannelInputMessCount (NULL), - fChannelMultiplicity (NULL), - fdRateEvolutionBinSize (0.0), - fb24bitsReadoutDetected (kFALSE), - fb32bitsReadoutDetected (kFALSE), - fGet4V1SlowControlType(NULL), - fGet4V1SlowControlScaler(NULL), - fGet4V1SlowControlDeadTime(NULL), - fGet4V1SlowControlHamming(NULL), - fGet4V1SlowControlSeuEvo(NULL), - fGet4ErrorChip(NULL), - fGet4ErrorChan(NULL), - fGet4ErrorPatt(NULL), - fGet4V1DllLockBit(NULL) -{ -/* - fRocId = 0; - - fAUXch = 0; - fMsgTypes = 0; - fSysTypes = 0; - fSysUserTypes = 0; - fTrigger_All = 0; - fTrigger_All_100 = 0; - fTrigger_All_us = 0; - fTrigger_All_ms = 0; - fTrigger_All_s = 0; - fTriggerWind = 0; // time window to assign hits to event - fAUXWind = 0; // time window to assign AUX to event - fEvntMultipl = 0; // event multiplicity in time window after trigger signal - - fLastTm = 0; // - fLastTriggerTm = 0; -*/ - for (unsigned n=0;n<get4v10::kuMaxAux;n++) fLastAuxTm[n] = 0; - for (unsigned n=0;n<get4v10::kuMaxSync;n++) { - fLastSyncTm[n] = 0; - fLastSyncId[n] = 0; - } -/* - fStartSyncTm = 0; - fStopSyncTm = 0; -*/ - for (unsigned aux=0;aux<get4v10::kuMaxAux;aux++) - fAUXt[aux] = 0; // time distribution of aux signals - for (unsigned n=0;n<get4v10::kuMaxSync;n++) - { - fSYNCt[n] = 0; // time distribution of sync signals - fSyncLongT[n] = 0; // time distribution of sync signals - } -/* - fALLt = 0; - fDATAt = 0; - fERRORt = 0; - fSLOWCt = 0; - fSelfTriggT = 0; - fEPOCHt = 0; - fAllSelectedT = 0; - - // Long duration time distribution (1 min. bin, 10 days length) - fAllLongT = 0; - fDataLongT = 0; - fErrorLongT = 0; - fSlowCLongT = 0; - fSelfTriggLongT = 0; - fEpochLongT = 0; - fAllEpoch2LongT = 0; - fAllSelLongT = 0; -*/ - fUnprocessedMsg.clear(); -/* - fDabcSeparator=-1; - - bIgnoreData = kFALSE; - fIgnoreCnt = 0; - fIgnoreTime = 0; // time when ignore message was generated - fCollectTime = 0; // time when collect message was generated -*/ - /** GET4 unpacking & pre-processing **/ - /*************************************/ - - /* Modified part */ - - // Epochs -/* - fuCurrEpoch = 0; // current epoch on the roc - fuEpochCycle = 0; // Number of time the epoch counter cycled -*/ - for( UInt_t uGet4 = 0; uGet4 < get4v10::kuMaxGet4Roc; uGet4++) - { - fEPOCH2t[uGet4] = 0; - fuCurrEpoch2[uGet4] = 0; // current epoch2 for each get4 chip - fuEpoch2Cycle[uGet4] = 0; // Number of time the epoch2 counter cycled - fiEpochShift[uGet4] = 0; - fuNbShiftedEpochs[uGet4] = 0; - fEpochShiftsDuration[uGet4] = 0; - fuEpochWithData[uGet4] = 0; // Data flag for suppressed epoch mode - fEpSuppBuffer[uGet4].clear(); // temp buffer in supp epoch mode to wait for epoch message - } -/* - fDistribEpochs = 0; - fDistribEpochs2 = 0; - fEpochShiftsPerChip = 0; - fEpochShiftsDurationPerChip = 0; - - // Buffers - fbBufferWithLastFullEpoch = kFALSE; -*/ - fPrevEpochsBuffer[0].clear(); // buffer of all ROC messages in current epoch and previous one - fPrevEpochsBuffer[1].clear(); // buffer of all ROC messages in current epoch and previous one -// fbEpochSinceTrigger = kFALSE; - for( UInt_t uGet4 = 0; uGet4 < get4v10::kuMaxGet4Roc; uGet4++) - { - fbBufferWithLastFullEpoch2[uGet4] = kFALSE; - fPrevEpochs2Buffer[uGet4][0].clear(); // buffer of all get4 messages in current epoch and previous one - fPrevEpochs2Buffer[uGet4][1].clear(); // buffer of all get4 messages in current epoch and previous one - bLookInPreviousEpoch[uGet4] = kFALSE; - bLookInNextEpoch[uGet4] = kFALSE; - fbEpoch2SinceTrigger[uGet4]= kFALSE; - - for( UInt_t uGet4Chan = 0; uGet4Chan < get4v10::kuNbChan; uGet4Chan++) - { - fSelectedT[uGet4][uGet4Chan] = 0; - fTrigger_Get4Channel[uGet4][uGet4Chan] = 0; - fTriggerMs_Get4Channel[uGet4][uGet4Chan] = 0; - fTriggerS_Get4Channel[uGet4][uGet4Chan] = 0; - fbDllFlag[uGet4][uGet4Chan] = kFALSE; - - fbDataTimeOut[uGet4][uGet4Chan] = kFALSE; - fbDataFallingOut[uGet4][uGet4Chan] = kFALSE; - - fLastExtMess[uGet4][uGet4Chan].Clear(); - } // for( UInt_t uGet4Chan = 0; uGet4Chan < get4v10::kuNbChan; uGet4Chan++) - fGet4V1HitsDistanceNs[uGet4] = 0; - fGet4V1HitsDistanceUs[uGet4] = 0; - fGet4V1HitsDistanceMs[uGet4] = 0; - fGet4V1HitsDistanceS[uGet4] = 0; - } // for( UInt_t uGet4 = 0; uGet4 < get4v10::kuMaxGet4Roc; uGet4++) -/* - fb24bitsReadoutDetected = kFALSE; - fb32bitsReadoutDetected = kFALSE; - - // HitsSelection - fbSelectionRocDone = kTRUE; -*/ - for( UInt_t uGet4 = 0; uGet4 < get4v10::kuMaxGet4Roc; uGet4++) - { - fbSelectionDone[uGet4] = kTRUE; - } - - // Triggering on data themselves -/* - fDataSelfTriggerPerEvent = 0; - fDataSelfTrigDistanceNs = 0; - fDataSelfTrigDistanceUs = 0; - fDataSelfTrigDistanceMs = 0; - fDataSelfTrigDistanceS = 0; -*/ - for( Int_t iTrigger = 0; iTrigger < get4v10::kiMaxNbDataTriggs; iTrigger++) - { - fuDataSelfTriggerCount[iTrigger] = 0; - fdLastFullTimeSelfTrigger[iTrigger] = 0; - fextMessLastMainChannel[iTrigger].Clear(); - fdLastFullTimeMainChannelTot[iTrigger] = 0; - for( Int_t iSecTriggerChan = 0; iSecTriggerChan < get4v10::kiMaxNbSecTriggCh; iSecTriggerChan++) - { - fdLastFullTimeSecChannel[iTrigger][iSecTriggerChan] = 0; - fdLastFullTimeSecChannelTot[iTrigger][iSecTriggerChan] = 0; - } - } - - // Event statistics -/* - fNbEventsPerMbsEvent = 0; - fNbNotEmptyEventsPerMbsEvent = 0; - fChannelsMapping = 0; - fChannelInputMessCount = 0; - fChannelMultiplicity = 0; - fdRateEvolutionBinSize = 0; -*/ - for( UInt_t uGet4 = 0; uGet4 < get4v10::kuMaxGet4Roc; uGet4++) - { - fuNbHitsChipEpoch[uGet4] = 0; - fChipRateEvolution[uGet4] = 0; - for( UInt_t uGet4Chan = 0; uGet4Chan < get4v10::kuNbChan; uGet4Chan++) - { - fChannelRateEvolution[uGet4][uGet4Chan] = 0; - } // for( UInt_t uGet4Chan = 0; uGet4Chan < get4v10::kuNbChan; uGet4Chan++) - } // for( UInt_t uGet4 = 0; uGet4 < get4v10::kuMaxGet4Roc; uGet4++) - -} -TGet4v1Rec::TGet4v1Rec(const TGet4v1Rec& src): - fRocId (src.fRocId), - fIter (src.fIter), - fMsgTypes (src.fMsgTypes), - fSysTypes (src.fSysTypes), - fSysUserTypes (src.fSysUserTypes), - fAUXch (src.fAUXch), - fTrigger_All (src.fTrigger_All), - fTrigger_AUX (src.fTrigger_AUX), - fTrigger_All_100 (src.fTrigger_All_100), - fTrigger_All_us (src.fTrigger_All_us), - fTrigger_All_ms (src.fTrigger_All_ms), - fTrigger_All_s (src.fTrigger_All_s), - fTriggerWind (src.fTriggerWind), - fAUXWind (src.fAUXWind), - fSelfTrigWind (src.fSelfTrigWind), - fEvntMultipl (src.fEvntMultipl), - fALLt (src.fALLt), - fDATAt (src.fDATAt), - fERRORt (src.fERRORt), - fSLOWCt (src.fSLOWCt), - fSelfTriggT (src.fSelfTriggT), - fEPOCHt (src.fEPOCHt), - fAllSelectedT (src.fAllSelectedT), - fAllLongT (src.fAllLongT), - fDataLongT (src.fDataLongT), - fErrorLongT (src.fErrorLongT), - fSlowCLongT (src.fSlowCLongT), - fSelfTriggLongT (src.fSelfTriggLongT), - fEpochLongT (src.fEpochLongT), - fAllEpoch2LongT (src.fAllEpoch2LongT), - fAllSelLongT (src.fAllSelLongT), - fLastTm (src.fLastTm), - fLastTriggerTm (src.fLastTriggerTm), - fStartSyncTm (src.fStartSyncTm), - fStopSyncTm (src.fStopSyncTm), - fUnprocessedMsg (src.fUnprocessedMsg), - fDabcSeparator (src.fDabcSeparator), - bIgnoreData (src.bIgnoreData), - fIgnoreCnt (src.fIgnoreCnt), - fIgnoreTime (src.fIgnoreTime), - fCollectTime (src.fCollectTime), - fuCurrEpoch (src.fuCurrEpoch), - fuEpochCycle (src.fuEpochCycle), - fDistribEpochs (src.fDistribEpochs), - fDistribEpochs2 (src.fDistribEpochs2), - fEpochShiftsPerChip (src.fEpochShiftsPerChip), - fEpochShiftsDurationPerChip (src.fEpochShiftsDurationPerChip), - fbBufferWithLastFullEpoch (src.fbBufferWithLastFullEpoch), - fbEpochSinceTrigger (src.fbEpochSinceTrigger), - fbSelectionRocDone (src.fbSelectionRocDone), - fDataSelfTriggerPerEvent (src.fDataSelfTriggerPerEvent), - fDataSelfTrigDistanceNs (src.fDataSelfTrigDistanceNs), - fDataSelfTrigDistanceUs (src.fDataSelfTrigDistanceUs), - fDataSelfTrigDistanceMs (src.fDataSelfTrigDistanceMs), - fDataSelfTrigDistanceS (src.fDataSelfTrigDistanceS), - fNbEventsPerMbsEvent (src.fNbEventsPerMbsEvent), - fNbNotEmptyEventsPerMbsEvent (src.fNbNotEmptyEventsPerMbsEvent), - fChannelsMapping (src.fChannelsMapping), - fChannelInputMessCount (src.fChannelInputMessCount), - fChannelMultiplicity (src.fChannelMultiplicity), - fdRateEvolutionBinSize (src.fdRateEvolutionBinSize), - fb24bitsReadoutDetected (src.fb24bitsReadoutDetected), - fb32bitsReadoutDetected (src.fb32bitsReadoutDetected), - fGet4V1SlowControlType (src.fGet4V1SlowControlType), - fGet4V1SlowControlScaler (src.fGet4V1SlowControlScaler), - fGet4V1SlowControlDeadTime(src.fGet4V1SlowControlDeadTime), - fGet4V1SlowControlHamming (src.fGet4V1SlowControlHamming), - fGet4V1SlowControlSeuEvo (src.fGet4V1SlowControlSeuEvo), - fGet4ErrorChip (src.fGet4ErrorChip), - fGet4ErrorChan (src.fGet4ErrorChan), - fGet4ErrorPatt (src.fGet4ErrorPatt), - fGet4V1DllLockBit (src.fGet4V1DllLockBit) -{ - - for (unsigned n=0;n<get4v10::kuMaxAux;n++) - fLastAuxTm[n] = src.fLastAuxTm[n] ; - for (unsigned n=0;n<get4v10::kuMaxSync;n++) { - fLastSyncTm[n] = src.fLastSyncTm[n]; - fLastSyncId[n] = src.fLastSyncId[n]; - } // for (unsigned n=0;n<get4v10::kuMaxSync;n++) - - for (unsigned aux=0;aux<get4v10::kuMaxAux;aux++) - fAUXt[aux] = src.fAUXt[aux]; - for (unsigned n=0;n<get4v10::kuMaxSync;n++) - { - fSYNCt[n] = src.fSYNCt[n] ; - fSyncLongT[n] = src.fSyncLongT[n]; - } // for (int n=0;n<get4v10::kuMaxSync;n++) - - /** GET4 unpacking & pre-processing **/ - /*************************************/ - - for( UInt_t uGet4 = 0; uGet4 < get4v10::kuMaxGet4Roc; uGet4++) - { - fEPOCH2t[uGet4] = src.fEPOCH2t[uGet4]; - fuCurrEpoch2[uGet4] = src.fuCurrEpoch2[uGet4]; - fuEpoch2Cycle[uGet4] = src.fuEpoch2Cycle[uGet4]; - fiEpochShift[uGet4] = src.fiEpochShift[uGet4]; - fuNbShiftedEpochs[uGet4] = src.fuNbShiftedEpochs[uGet4]; - fEpochShiftsDuration[uGet4] = src.fEpochShiftsDuration[uGet4]; - fuEpochWithData[uGet4] = src.fuEpochWithData[uGet4]; - fEpSuppBuffer[uGet4] = src.fEpSuppBuffer[uGet4]; - } // for( UInt_t uGet4 = 0; uGet4 < get4v10::kuMaxGet4Roc; uGet4++) - - fPrevEpochsBuffer[0] = src.fPrevEpochsBuffer[0]; - fPrevEpochsBuffer[1] = src.fPrevEpochsBuffer[1]; - for( UInt_t uGet4 = 0; uGet4 < get4v10::kuMaxGet4Roc; uGet4++) - { - fbBufferWithLastFullEpoch2[uGet4] = src.fbBufferWithLastFullEpoch2[uGet4]; - fPrevEpochs2Buffer[uGet4][0] = src.fPrevEpochs2Buffer[uGet4][0]; - fPrevEpochs2Buffer[uGet4][1] = src.fPrevEpochs2Buffer[uGet4][1]; - bLookInPreviousEpoch[uGet4] = src.bLookInPreviousEpoch[uGet4]; - bLookInNextEpoch[uGet4] = src.bLookInNextEpoch[uGet4]; - fbEpoch2SinceTrigger[uGet4] = src.fbEpoch2SinceTrigger[uGet4]; - - for( UInt_t uGet4Chan = 0; uGet4Chan < get4v10::kuNbChan; uGet4Chan++) - { - fSelectedT[uGet4][uGet4Chan] = src.fSelectedT[uGet4][uGet4Chan]; - fTrigger_Get4Channel[uGet4][uGet4Chan] = src.fTrigger_Get4Channel[uGet4][uGet4Chan]; - fTriggerMs_Get4Channel[uGet4][uGet4Chan] = src.fTriggerMs_Get4Channel[uGet4][uGet4Chan]; - fTriggerS_Get4Channel[uGet4][uGet4Chan] = src.fTriggerS_Get4Channel[uGet4][uGet4Chan]; - fbDllFlag[uGet4][uGet4Chan] = src.fbDllFlag[uGet4][uGet4Chan]; - - fbDataTimeOut[uGet4][uGet4Chan] = src.fbDataTimeOut[uGet4][uGet4Chan]; - fbDataFallingOut[uGet4][uGet4Chan] = src.fbDataFallingOut[uGet4][uGet4Chan]; - - fLastExtMess[uGet4][uGet4Chan] = src.fLastExtMess[uGet4][uGet4Chan]; - } // for( UInt_t uGet4Chan = 0; uGet4Chan < get4v10::kuNbChan; uGet4Chan++) - fGet4V1HitsDistanceNs[uGet4] = src.fGet4V1HitsDistanceNs[uGet4]; - fGet4V1HitsDistanceUs[uGet4] = src.fGet4V1HitsDistanceUs[uGet4]; - fGet4V1HitsDistanceMs[uGet4] = src.fGet4V1HitsDistanceMs[uGet4]; - fGet4V1HitsDistanceS[uGet4] = src.fGet4V1HitsDistanceS[uGet4]; - } // for( UInt_t uGet4 = 0; uGet4 < get4v10::kuMaxGet4Roc; uGet4++) - - for( UInt_t uGet4 = 0; uGet4 < get4v10::kuMaxGet4Roc; uGet4++) - { - fbSelectionDone[uGet4] = src.fbSelectionDone[uGet4]; - } // for( UInt_t uGet4 = 0; uGet4 < get4v10::kuMaxGet4Roc; uGet4++) - - for( Int_t iTrigger = 0; iTrigger < get4v10::kiMaxNbDataTriggs; iTrigger++) - { - fuDataSelfTriggerCount[iTrigger] = src.fuDataSelfTriggerCount[iTrigger]; - fdLastFullTimeSelfTrigger[iTrigger] = src.fdLastFullTimeSelfTrigger[iTrigger]; - fextMessLastMainChannel[iTrigger] = src.fextMessLastMainChannel[iTrigger]; - fdLastFullTimeMainChannelTot[iTrigger] = src.fdLastFullTimeMainChannelTot[iTrigger]; - for( Int_t iSecTriggerChan = 0; iSecTriggerChan < get4v10::kiMaxNbSecTriggCh; iSecTriggerChan++) - { - fdLastFullTimeSecChannel[iTrigger][iSecTriggerChan] = src.fdLastFullTimeSecChannel[iTrigger][iSecTriggerChan]; - fdLastFullTimeSecChannelTot[iTrigger][iSecTriggerChan] = src.fdLastFullTimeSecChannelTot[iTrigger][iSecTriggerChan]; - } // for( Int_t iSecTriggerChan = 0; iSecTriggerChan < get4v10::kiMaxNbSecTriggCh; iSecTriggerChan++) - } // for( Int_t iTrigger = 0; iTrigger < get4v10::kiMaxNbDataTriggs; iTrigger++) - - for( UInt_t uGet4 = 0; uGet4 < get4v10::kuMaxGet4Roc; uGet4++) - { - fuNbHitsChipEpoch[uGet4] = src.fuNbHitsChipEpoch[uGet4]; - fChipRateEvolution[uGet4] = src.fChipRateEvolution[uGet4]; - for( UInt_t uGet4Chan = 0; uGet4Chan < get4v10::kuNbChan; uGet4Chan++) - { - fChannelRateEvolution[uGet4][uGet4Chan] = src.fChannelRateEvolution[uGet4][uGet4Chan]; - } // for( UInt_t uGet4Chan = 0; uGet4Chan < get4v10::kuNbChan; uGet4Chan++) - } // for( UInt_t uGet4 = 0; uGet4 < get4v10::kuMaxGet4Roc; uGet4++) -} - -ULong64_t TGet4v1Rec::GetFullEpochNumber() -{ - return (ULong64_t)(fuCurrEpoch) + - ( (ULong64_t)(get4v10::kulMainEpochCycleSz) +1)*(ULong64_t)(fuEpochCycle); -} -ULong64_t TGet4v1Rec::GetFullEpoch2Number( UInt_t uGet4Id) -{ - return (ULong64_t)(fuCurrEpoch2[uGet4Id]) + - ( (ULong64_t)(get4v10::kulGet4EpochCycleSz) +1)*(ULong64_t)(fuEpoch2Cycle[uGet4Id]); -} - -// Functions to overcome the 32 bit limit in epoch number as input to -// GetMessageFullTime function - -ULong64_t TGet4v1Rec::GetSuperCycleEpOffset( ) -{ - // Nb of epoch lost by MessageTime function due to 32b limit -// ULong64_t ulNb32bCycles = GetFullEpochNumber() / ( 0x100000000ULL ); - ULong64_t ulNb32bCycles = GetFullEpochNumber() >> 32; - if( 0 < ulNb32bCycles) - return (ULong64_t)( ulNb32bCycles * ( 0x100000000ULL ) )<<14; // epoch nb lost due to 32 bit limit, shifted in ns - else return 0; -} -ULong64_t TGet4v1Rec::GetSuperCycleEp2Offset( UInt_t uGet4Id) -{ - // Nb of epoch lost by MessageTime function due to 32b limit -// ULong64_t ulNb32bCycles = GetFullEpoch2Number( uGet4Id) / ( 0x100000000ULL ); - ULong64_t ulNb32bCycles = GetFullEpoch2Number( uGet4Id) >> 32; - if( 0 < ulNb32bCycles) - return (ULong64_t)( ulNb32bCycles * ( 0x100000000ULL ) )* // epoch nb lost due to 32 bit limit - (ULong64_t)( get4tdc::kdEpochInPs / 1000 ); // Get4 epoch in ns - return 0; -} -Double_t TGet4v1Rec::GetSuperCycleEp2OffsetD( UInt_t uGet4Id) -{ - // Nb of epoch lost by MessageTime function due to 32b limit -// ULong64_t ulNb32bCycles = GetFullEpoch2Number( uGet4Id) / ( 0x100000000ULL ); - ULong64_t ulNb32bCycles = GetFullEpoch2Number( uGet4Id) >> 32; - if( 0 < ulNb32bCycles) - return (Double_t)( ulNb32bCycles * ( 0x100000000ULL ) )* // epoch nb lost due to 32 bit limit - (Double_t)( get4tdc::kdEpochInPs) / 1000.0 ; // Get4 epoch in ns - return 0.0; -} diff --git a/beamtime/tof/tdc/get4/TGet4v1Rec.h b/beamtime/tof/tdc/get4/TGet4v1Rec.h deleted file mode 100755 index 73c63bc20e6d3aea1917a323c81e4a22a267bac6..0000000000000000000000000000000000000000 --- a/beamtime/tof/tdc/get4/TGet4v1Rec.h +++ /dev/null @@ -1,254 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TGet4v1Rec.h ----- -// ----- Created 22/07/2013 by P.-A. Loizeau ----- -// ----- Adapted from TGet4v1Rec.h ----- -// ----- in RocLib/beamtime/tof-tdctest rev.4862 ----- -// ------------------------------------------------------------------ -#ifndef TGET4V1REC_H -#define TGET4V1REC_H - -// GET4 Headers -#include "TofGet4Def.h" -#include "TGet4v1Event.h" - -// ROClib headers -#include "roc/Iterator.h" -#include "roc/Message.h" -#include "roc/Board.h" - -//class TGo4WinCond; - -// ROOT headers -#include "TNamed.h" -#include "TH1.h" -#include "TH2.h" - -// C++ headers -#include <vector> - -#ifdef HAVE_UINT8_T_HEADER_FILE -#include <_types/_uint8_t.h> -#include <_types/_uint16_t.h> -#include <_types/_uint32_t.h> -#include <_types/_uint64_t.h> -#else -#include <stdint.h> -#endif - -class TimeWindowCond : public TNamed -{ - public: - TimeWindowCond(); - TimeWindowCond( const char* name, Double_t tLow, Double_t tHigh ); - ~TimeWindowCond(){}; - void Clear(Option_t *t=""); - - void SetValues( Double_t tLow, Double_t tHigh ); - - Bool_t Test( Double_t dValToTest); - private: - Double_t fdLowT; - Double_t fdHighT; - - ClassDef(TimeWindowCond, 1) -}; - -struct TGet4v1Rec { - - Int_t fRocId; - roc::Iterator fIter; // iterator of current roc input buffer - - TH1* fMsgTypes; // messages types - TH1* fSysTypes; // system messages types - TH1* fSysUserTypes; // user system messages - TH1* fAUXch; // filling of AUX channels - - TH1* fTrigger_All; // time shift between last trigger and hit - TH1* fTrigger_AUX; // time shift between last trigger and all AUX - TH1* fTrigger_All_100; // time shift between last trigger and hit (100ns bin) - TH1* fTrigger_All_us; // time shift between last trigger and hit (1 us bin) - TH1* fTrigger_All_ms; // time shift between last trigger and hit (1 ms bin) - TH1* fTrigger_All_s; // time shift between last trigger and hit (1 s bin) -// TGo4WinCond* fTriggerWind; // time window to assign hits to event (relative to last trigger) -// TGo4WinCond* fAUXWind; // time window to assign AUX to event (relative to last trigger, differs from NX messages) -// TGo4WinCond* fSelfTrigWind; // time window to detect trigger inside data themselves - TimeWindowCond* fTriggerWind; // time window to assign hits to event (relative to last trigger) - TimeWindowCond* fAUXWind; // time window to assign AUX to event (relative to last trigger, differs from NX messages) - TimeWindowCond* fSelfTrigWind; // time window to detect trigger inside data themselves - TH1* fEvntMultipl; // event multiplicity (how many messages selected) - - TH1* fALLt; // time distribution of all signals - TH1* fDATAt; // time distribution of data signals - TH1* fERRORt; // time distribution of error signals - TH1* fSLOWCt; // time distribution of slow control signals - TH1* fSelfTriggT; // time distribution of triggers from data - TH1* fAUXt[get4v10::kuMaxAux]; // time distribution of aux signals - TH1* fSYNCt[get4v10::kuMaxSync]; // time distribution of sync signals - TH1* fEPOCHt; // time distribution of epoch signals - TH1* fEPOCH2t[get4v10::kuMaxGet4Roc]; // time distribution of epoch signals - TH1* fAllSelectedT; // time distribution of all selected hits in an event - TH1* fSelectedT[get4v10::kuMaxGet4Roc][get4v10::kuNbChan]; // time distribution of hits selected in an event - - // Long duration time distribution (1 min. bin, 10 days length) - TH1* fAllLongT; // Long time distribution of all signals - TH1* fDataLongT; // Long time distribution of data signals - TH1* fErrorLongT; // Long time distribution of error signals - TH1* fSlowCLongT; // Long time distribution of slow control signals - TH1* fSelfTriggLongT; // Long time distribution of triggers from data - TH1* fSyncLongT[get4v10::kuMaxSync]; // Long time distribution of sync signals - TH1* fEpochLongT; // Long time distribution of epoch signals - TH1* fAllEpoch2LongT; // Long time distribution of all epoch2 signals - TH1* fAllSelLongT; // Long time distribution of all selected hits in an event - - uint64_t fLastTm; // - uint64_t fLastTriggerTm; // last time of trigger signal (defined by parameter) - uint64_t fLastAuxTm[get4v10::kuMaxAux]; // last time of rising edge of AUX signals - uint64_t fLastSyncTm[get4v10::kuMaxSync]; // last time of SYNC signals - uint32_t fLastSyncId[get4v10::kuMaxSync]; // last ID of SYNC signals - uint64_t fStartSyncTm; // time of SYNC signal in the beginning of subevent - uint64_t fStopSyncTm; // time of SYNC signal at the end of subevent - - std::vector<TGet4v1MessageExtended> fUnprocessedMsg; // buffer of not accounted hit messages of previous mbs evnts - - Int_t fDabcSeparator; // sync id of the dabc event separator. For event finalizing condition - - Bool_t bIgnoreData; // true when data should be ignored during reconfiguration - Int_t fIgnoreCnt; // counter used to process data when ignored, reset when ignore activated - uint64_t fIgnoreTime; // time when ignore message was generated - uint64_t fCollectTime; // time when collect message was generated - - /* Modified part */ - - // Epochs - UInt_t fuCurrEpoch; // current epoch on the roc - UInt_t fuEpochCycle; // Number of time the epoch counter cycled - UInt_t fuCurrEpoch2[get4v10::kuMaxGet4Roc]; // current epoch2 for each get4 chip - UInt_t fuEpoch2Cycle[get4v10::kuMaxGet4Roc]; // Number of time the epoch2 counter cycled - TH1 *fDistribEpochs; - TH2 *fDistribEpochs2; - TH2 *fEpochShiftsPerChip; - TH2 *fEpochShiftsDurationPerChip; - Int_t fiEpochShift[get4v10::kuMaxGet4Roc]; - UInt_t fuNbShiftedEpochs[get4v10::kuMaxGet4Roc]; - TH2 *fEpochShiftsDuration[get4v10::kuMaxGet4Roc]; - - // Buffers - // ROC - Bool_t fbBufferWithLastFullEpoch; - std::vector<TGet4v1MessageExtended> fPrevEpochsBuffer[2]; // buffer of all ROC messages in current epoch and previous one - Bool_t fbEpochSinceTrigger; - // GET4s - Bool_t fbBufferWithLastFullEpoch2[get4v10::kuMaxGet4Roc]; - std::vector<TGet4v1MessageExtended> fPrevEpochs2Buffer[get4v10::kuMaxGet4Roc][2]; // buffer of all get4 messages in current epoch and previous one - Bool_t bLookInPreviousEpoch[get4v10::kuMaxGet4Roc]; - Bool_t bLookInNextEpoch[get4v10::kuMaxGet4Roc]; - Bool_t fbEpoch2SinceTrigger[get4v10::kuMaxGet4Roc]; - - // HitsSelection - Bool_t fbSelectionRocDone; - Bool_t fbSelectionDone[get4v10::kuMaxGet4Roc]; - Bool_t fbDataTimeOut[get4v10::kuMaxGet4Roc][get4v10::kuNbChan]; - Bool_t fbDataFallingOut[get4v10::kuMaxGet4Roc][get4v10::kuNbChan]; - TH1* fTrigger_Get4Channel[get4v10::kuMaxGet4Roc][get4v10::kuNbChan]; // time shift between last trigger and hit in this Get4 channel - TH1* fTriggerMs_Get4Channel[get4v10::kuMaxGet4Roc][get4v10::kuNbChan]; // time shift between last trigger and hit in this Get4 channel - TH1* fTriggerS_Get4Channel[get4v10::kuMaxGet4Roc][get4v10::kuNbChan]; // time shift between last trigger and hit in this Get4 channel - - // Triggering on data themselves - TH2* fDataSelfTriggerPerEvent; - TH2* fDataSelfTrigDistanceNs; - TH2* fDataSelfTrigDistanceUs; - TH2* fDataSelfTrigDistanceMs; - TH2* fDataSelfTrigDistanceS; - - UInt_t fuDataSelfTriggerCount[get4v10::kiMaxNbDataTriggs]; - Double_t fdLastFullTimeSelfTrigger[get4v10::kiMaxNbDataTriggs]; - TGet4v1MessageExtended fextMessLastMainChannel[get4v10::kiMaxNbDataTriggs]; - Double_t fdLastFullTimeMainChannelTot[get4v10::kiMaxNbDataTriggs]; - Double_t fdLastFullTimeSecChannel[get4v10::kiMaxNbDataTriggs][get4v10::kiMaxNbSecTriggCh]; - Double_t fdLastFullTimeSecChannelTot[get4v10::kiMaxNbDataTriggs][get4v10::kiMaxNbSecTriggCh]; - - // Event statistics - TH1* fNbEventsPerMbsEvent; - TH1* fNbNotEmptyEventsPerMbsEvent; - TH2 *fChannelsMapping; - TH1 *fChannelInputMessCount; - TH2 *fChannelMultiplicity; - TH1 *fChipRateEvolution[get4v10::kuMaxGet4Roc]; - TH1 *fChannelRateEvolution[get4v10::kuMaxGet4Roc][get4v10::kuNbChan]; - Double_t fdRateEvolutionBinSize; - UInt_t fuNbHitsChipEpoch[get4v10::kuMaxGet4Roc]; - - - /* - * 24 & 32 bits variables & histograms - */ - TH1 *fRawTot[get4v10::kuMaxGet4Roc][get4v10::kuNbChan]; - TH1 *fTot[get4v10::kuMaxGet4Roc][get4v10::kuNbChan]; - - /* - * 24 bits specific variables & histograms - */ - Bool_t fb24bitsReadoutDetected; - Get4v1Hit fHitTemp24[get4v10::kuMaxGet4Roc][get4v10::kuNbChan]; - UInt_t fuEpochWithData[get4v10::kuMaxGet4Roc]; // Data flag for suppressed epoch mode - std::vector<TGet4v1MessageExtended> fEpSuppBuffer[get4v10::kuMaxGet4Roc]; // temp buffer in supp epoch mode to wait for epoch message - - /* - * 32 bits specific variables & histograms - */ - Bool_t fb32bitsReadoutDetected; - TH2 *fGet4V1SlowControlType; - TH2 *fGet4V1SlowControlScaler; - TH2 *fGet4V1SlowControlDeadTime; - TH2 *fGet4V1SlowControlHamming; - TH2 *fGet4V1SlowControlSeuEvo; - TH1 *fGet4ErrorChip; // Get4 System Error chip - TH2 *fGet4ErrorChan; // Get4 System Error channel/edge - TH2 *fGet4ErrorPatt; // Get4 System Error pattern - Bool_t fbDllFlag[get4v10::kuMaxGet4Roc][get4v10::kuNbChan]; - TH2 *fGet4V1DllLockBit; - - TGet4v1MessageExtended fLastExtMess[get4v10::kuMaxGet4Roc][get4v10::kuNbChan]; - TH2 *fGet4V1HitsDistanceNs[get4v10::kuMaxGet4Roc]; - TH2 *fGet4V1HitsDistanceUs[get4v10::kuMaxGet4Roc]; - TH2 *fGet4V1HitsDistanceMs[get4v10::kuMaxGet4Roc]; - TH2 *fGet4V1HitsDistanceS[get4v10::kuMaxGet4Roc]; - - /* - * Debug Histograms for GET4 v1.x - */ - TH1 *fLeadingFTS[get4v10::kuMaxGet4Roc][get4v10::kuNbChan]; - TH1 *fTrailingFTS[get4v10::kuMaxGet4Roc][get4v10::kuNbChan]; - TH1 *fLeadingDnl[get4v10::kuMaxGet4Roc][get4v10::kuNbChan]; - TH1 *fLeadingDnlSum[get4v10::kuMaxGet4Roc][get4v10::kuNbChan]; - TH1 *fTrailingDnl[get4v10::kuMaxGet4Roc][get4v10::kuNbChan]; - TH1 *fTrailingDnlSum[get4v10::kuMaxGet4Roc][get4v10::kuNbChan]; - - TH1 *fTimeDiffInsideChip[2][get4v10::kuNbChan*(get4v10::kuNbChan-1)/2]; - TH1 *fTimeDiffBetweenChips[get4v10::kuNbChan*get4v10::kuNbChan]; - - TH1 *fFTCorrel[2][get4v10::kuNbChan*(get4v10::kuNbChan-1)/2]; - TH2 *fFTCorrel2D[2][get4v10::kuNbChan*(get4v10::kuNbChan-1)/2]; - TH1 *fFTCorrelChipToChip[get4v10::kuNbChan*get4v10::kuNbChan]; - - TGet4v1Rec(); - // no copy constructor required to add object in std::vector - TGet4v1Rec(const TGet4v1Rec&); - - ULong64_t GetFullEpochNumber(); - ULong64_t GetFullEpoch2Number( UInt_t uGet4Id); - // Functions to overcome the 32 bit limit in epoch number as input to - // GetMessageFullTime function - ULong64_t GetSuperCycleEpOffset( ); - ULong64_t GetSuperCycleEp2Offset( UInt_t uGet4Id); - Double_t GetSuperCycleEp2OffsetD( UInt_t uGet4Id); - - private: - // no default = OP as object not meant to be copied - TGet4v1Rec& operator=(const TGet4v1Rec&); -}; - - -#endif - - diff --git a/beamtime/tof/tdc/get4/TTofGet4Board.cxx b/beamtime/tof/tdc/get4/TTofGet4Board.cxx deleted file mode 100644 index 31c5634a83af14974a0b82c016be52c7a5618d11..0000000000000000000000000000000000000000 --- a/beamtime/tof/tdc/get4/TTofGet4Board.cxx +++ /dev/null @@ -1,93 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TTofGet4Board ----- -// ----- Created 22/07/2013 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ - -#include "TTofGet4Board.h" - -// TOF headers -#include "TofTdcDef.h" -#include "TofGet4Def.h" -#include "TTofGet4Data.h" - -// FAIR headers -#include "FairLogger.h" - -// ROOT headers -#include "TClonesArray.h" - -// C/C++ headers - -/************************** TTofTdcBoard ****************************/ -TTofGet4Board::TTofGet4Board(): - TTofTdcBoard( toftdc::get4, get4tdc::kuNbChan ), - fdTriggerFullTime(0.0), - fbMbsSyncedEvent(kTRUE), - fuSyncEventNumber(0), - fbDataTriggered(kTRUE), - fuTriggerIndex(0) -{ - CreateDataArray(); -} -TTofGet4Board::~TTofGet4Board() -{ -} - -void TTofGet4Board::Clear( Option_t *option ) -{ - TTofTdcBoard::Clear( option ); - fdTriggerFullTime = 0.0; - fbMbsSyncedEvent = kTRUE; - fuSyncEventNumber = 0; - fbDataTriggered = kTRUE; - fuTriggerIndex = 0; -} - -// TClonesArray versions -Bool_t TTofGet4Board::CreateDataArray() -{ - LOG(debug)<<" TTofGet4Board::CreateDataArray "; - if( 0 < GetChannelNb() && NULL == fDataCollection ) - fDataCollection = new TClonesArray( "TTofGet4Data", get4tdc::kuNbMulti * GetChannelNb() ); - else return kFALSE; - - return kTRUE; -} -Bool_t TTofGet4Board::ResizeArray() -{ - if( 0 < GetChannelNb() && NULL != fDataCollection ) - { - fDataCollection->Expand( get4tdc::kuNbMulti*GetChannelNb() ); - return kTRUE; - } // if( 0 < GetChannelNb() && NULL != fDataCollection ) - else return kFALSE; -} -UInt_t TTofGet4Board::AddData( TTofGet4Data & dataIn ) -{ - if( NULL != fDataCollection ) - { - Int_t iNextIndex = fDataCollection->GetEntriesFast(); - if( iNextIndex < static_cast<Int_t>(get4tdc::kuNbMulti * GetChannelNb()) ) - { - TTofGet4Data * dataSlot = (TTofGet4Data *)fDataCollection->ConstructedAt( iNextIndex ); - *dataSlot = dataIn; - } // if( iNextIndex < toftdc::kuDefNbMulti * GetChannelNb() ) - return fDataCollection->GetEntriesFast(); - } // if( NULL != fDataCollection ) - else return 0; -} -TTofGet4Data * TTofGet4Board::GetDataPtr( UInt_t uDataIndex ) -{ - if( NULL != fDataCollection ) - { - if( static_cast<Int_t>(uDataIndex) < fDataCollection->GetEntriesFast() ) - return (TTofGet4Data *)fDataCollection->At( uDataIndex ); - else return NULL; - } // if( NULL != fDataCollection ) - else return NULL; -} -// ! no check on valid index in this one, Probably stupid method -const TTofGet4Data & TTofGet4Board::GetData( UInt_t uDataIndex ) const -{ - return *( (TTofGet4Data *)fDataCollection->At( uDataIndex ) ); -} diff --git a/beamtime/tof/tdc/get4/TTofGet4Board.h b/beamtime/tof/tdc/get4/TTofGet4Board.h deleted file mode 100644 index 8afcbfad6519e1fad203ffff86ae492ea5c80d64..0000000000000000000000000000000000000000 --- a/beamtime/tof/tdc/get4/TTofGet4Board.h +++ /dev/null @@ -1,75 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TTofGet4Board ----- -// ----- Created 22/07/2013 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ - -#ifndef TTOFGET4BOARD_H_ -#define TTOFGET4BOARD_H_ - -#include "TTofTdcBoard.h" - -class TTofGet4Board; -class TTofGet4Data; - -class TTofGet4Board : public TTofTdcBoard -{ - public: - TTofGet4Board(); - ~TTofGet4Board(); - - virtual void Clear(Option_t *option = ""); - - void SetTriggerFullTime( Double_t dTriggerTimeIn){ fdTriggerFullTime = dTriggerTimeIn; }; - void SetSyncEventFlag( Bool_t bSyncEvent = kTRUE){ fbMbsSyncedEvent = bSyncEvent; }; - void SetSyncEvtNb( UInt_t uSyncEvtNbIn ){ fuSyncEventNumber = uSyncEvtNbIn; }; - void SetDataEventFlag( Bool_t bDataEvent = kTRUE ){ fbDataTriggered = bDataEvent; }; - void SetTriggIndx( UInt_t uTrigIndx ){ fuTriggerIndex = uTrigIndx; }; - - Double_t GetTriggerFullTime() const { return fdTriggerFullTime; }; - Bool_t IsSyncTriggered() const { return fbMbsSyncedEvent; }; - UInt_t GetSyncEvtNb() const { return fuSyncEventNumber; }; - Bool_t IsDataTriggered() const { return fbDataTriggered; }; - UInt_t GetTriggIndx() const { return fuTriggerIndex; }; - - // TClones array version - // All these functions have to be implemented in the derived classes - // With the proper Data objects - virtual Bool_t CreateDataArray(); - virtual Bool_t ResizeArray(); - UInt_t AddData( TTofGet4Data & dataIn ); - TTofGet4Data * GetDataPtr( UInt_t uDataIndex ); - // ! no check on valid index in this one, Probably stupid method - const TTofGet4Data & GetData( UInt_t uDataIndex ) const; - - private: - - /** Last time of trigger signal (defined by parameter) - ** Can be sync or aux message, depending on TGet4Parameter::triggerSignal setup if pseudo-trigger mode - ** Time of the main trigger channel if self-trigger mode - ** Should be the same time for all Boards of a same ROC!!!! - **/ - Double_t fdTriggerFullTime; - - /* - // Event number of the corresponding MBS event - UInt_t fuMbsEventNumber; - // Index of the real event inside MBS event - UInt_t fuEventNbInsideMbsEvt; - // Total event number - UInt_t fuGlobalEventNumber; - */ - - // Flag indicating that this real event is the one synchronized to MBS - Bool_t fbMbsSyncedEvent; - // Event Number from the sync message - UInt_t fuSyncEventNumber; - - // Flag indicating that this real event was made after finding coincidence in data - Bool_t fbDataTriggered; - // Index of the Data trigger making this event - UInt_t fuTriggerIndex; - - ClassDef(TTofGet4Board, 1) -}; - -#endif // TTOFGET4BOARD_H_ diff --git a/beamtime/tof/tdc/get4/TTofGet4Data.cxx b/beamtime/tof/tdc/get4/TTofGet4Data.cxx deleted file mode 100644 index 01fcfc532461da6242a1e3d8f67ae36ebc63979d..0000000000000000000000000000000000000000 --- a/beamtime/tof/tdc/get4/TTofGet4Data.cxx +++ /dev/null @@ -1,200 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TTofGet4Data ----- -// ----- Created 22/07/2013 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ - -#include "TTofGet4Data.h" - -// Tof headers -#include "TofGet4Def.h" - -/************************** TTofTdcBoard ****************************/ -TTofGet4Data::TTofGet4Data() : - TTofTdcData(), - fuFulltime(0), - fdFullTime(0), - fuGet4Epoch(0), - fuGet4EpochCycle(0), - fbIs32Bit(kFALSE) -{ -} -TTofGet4Data::TTofGet4Data( UInt_t uChan, UInt_t uFt, - UInt_t uCoarseT, - ULong64_t uFulltime, Double_t dFullTime, - UInt_t uGet4Epoch, UInt_t uGet4EpCycle, - UInt_t uTot, Bool_t bIs32Bit) : - TTofTdcData(uChan, uFt, uCoarseT, uTot), - fuFulltime(uFulltime), - fdFullTime(dFullTime), - fuGet4Epoch(uGet4Epoch), - fuGet4EpochCycle(uGet4EpCycle), - fbIs32Bit(bIs32Bit) -{ -} - -TTofGet4Data::~TTofGet4Data() -{ -} - -void TTofGet4Data::Clear(Option_t *option) -{ - TTofTdcData::Clear(option); - fuFulltime = 0; - fdFullTime = 0; - fuGet4Epoch = 0; - fuGet4EpochCycle = 0; - fbIs32Bit = kFALSE; -} - -// Define < operator for vector sorting -Bool_t TTofGet4Data::operator <( const TTofGet4Data& rhs) const -{ - if( 0.0 < rhs.GetFullTimeD() && 0.0 < this->GetFullTimeD() ) - { - // Full time was assigned in both data! - if( this->GetFullTimeD() < rhs.GetFullTimeD() ) - // hit ... rhs - return kTRUE; - else - // rhs ... hit or rhs == hit - return kFALSE; - } // if( 0.0 < rhs.GetFullTimeD && 0.0 < this->GetFullTimeD() ) - else - { - // At least one of the Full time is not available - if( rhs.GetCoarseTime() < get4tdc::kuCoarseOverflowTest && - this->GetCoarseTime() >= rhs.GetCoarseTime() + get4tdc::kuCoarseOverflowTest ) - // Corse counter overflow between this hit and checked one - // hit ... Ovflw ... rhs - return kTRUE; - else if( this->GetCoarseTime() < get4tdc::kuCoarseOverflowTest && - this->GetCoarseTime() + get4tdc::kuCoarseOverflowTest <= rhs.GetCoarseTime() ) - // Corse counter overflow between checked hit and this one - // rhs ... Ovflw ... hit - return kFALSE; - else if( this->GetCoarseTime() < rhs.GetCoarseTime() ) - // CT hit ... rhs - return kTRUE; - else if( this->GetCoarseTime() > rhs.GetCoarseTime() ) - // CT rhs ... hit - return kFALSE; - else if( this->GetFineTime() < rhs.GetFineTime()) - // CT rhs = hit - // FT hit ... rhs - return kTRUE; - // CT rhs = hit - // FT rhs ... hit or rhs = hit - else return kFALSE; - } // else of if( 0.0 < rhs.GetFullTimeD && 0.0 < this->GetFullTimeD() ) -} - -Bool_t TTofGet4Data::operator <( const TTofTdcData& rhs) const -{ - // TTofTdcData does not have full time => rely on generic method - if( rhs.GetCoarseTime() < get4tdc::kuCoarseOverflowTest && - this->GetCoarseTime() >= rhs.GetCoarseTime() + get4tdc::kuCoarseOverflowTest ) - // Corse counter overflow between this hit and checked one - // hit ... Ovflw ... rhs - return kTRUE; - else if( this->GetCoarseTime() < get4tdc::kuCoarseOverflowTest && - this->GetCoarseTime() + get4tdc::kuCoarseOverflowTest <= rhs.GetCoarseTime() ) - // Corse counter overflow between checked hit and this one - // rhs ... Ovflw ... hit - return kFALSE; - else if( this->GetCoarseTime() < rhs.GetCoarseTime() ) - // CT hit ... rhs - return kTRUE; - else if( this->GetCoarseTime() > rhs.GetCoarseTime() ) - // CT rhs ... hit - return kFALSE; - else if( this->GetFineTime() < rhs.GetFineTime() ) - // CT rhs = hit - // FT hit ... rhs - return kTRUE; - // CT rhs = hit - // FT rhs ... hit or rhs = hit - else return kFALSE; -} -Int_t TTofGet4Data::Compare( const TObject* obj) const -{ - return Compare( (TTofGet4Data*) obj); -} -Int_t TTofGet4Data::Compare( const TTofGet4Data* obj) const -{ - if( 0.0 < obj->GetFullTimeD() && 0.0 < this->GetFullTimeD() ) - { - // Full time was assigned in both data! - if( this->GetFullTimeD() < obj->GetFullTimeD() ) - // hit ... rhs - return -1; - else if( this->GetFullTimeD() > obj->GetFullTimeD() ) - // rhs ... hit or rhs == hit - return 1; - else - // rhs == hit - return 0; - } // if( 0.0 < rhs.GetFullTimeD && 0.0 < this->GetFullTimeD() ) - else - { - // At least one of the Full time is not available - if( obj->GetCoarseTime() < get4tdc::kuCoarseOverflowTest && - this->GetCoarseTime() >= obj->GetCoarseTime() + get4tdc::kuCoarseOverflowTest ) - // Corse counter overflow between this hit and checked one - // hit ... Ovflw ... rhs - return -1; - else if( this->GetCoarseTime() < get4tdc::kuCoarseOverflowTest && - this->GetCoarseTime() + get4tdc::kuCoarseOverflowTest <= obj->GetCoarseTime() ) - // Corse counter overflow between checked hit and this one - // rhs ... Ovflw ... hit - return 1; - else if( this->GetCoarseTime() < obj->GetCoarseTime() ) - // CT hit ... rhs - return -1; - else if( this->GetCoarseTime() > obj->GetCoarseTime() ) - // CT rhs ... hit - return 1; - else if( this->GetFineTime() < obj->GetFineTime()) - // CT rhs = hit - // FT hit ... rhs - return -1; - else if( this->GetFineTime() > obj->GetFineTime()) - // CT rhs = hit - // FT rhs ... hit - return 1; - // CT rhs = hit - // FT rhs = hit - else return 0; - } // else of if( 0.0 < rhs.GetFullTimeD && 0.0 < this->GetFullTimeD() ) -} -Int_t TTofGet4Data::Compare( const TTofTdcData* obj) const -{ - // TTofTdcData does not have full time => rely on generic method - - if( obj->GetCoarseTime() < get4tdc::kuCoarseOverflowTest && - this->GetCoarseTime() >= obj->GetCoarseTime() + get4tdc::kuCoarseOverflowTest ) - // Corse counter overflow between this hit and checked one - // hit ... Ovflw ... rhs - return -1; - else if( this->GetCoarseTime() < get4tdc::kuCoarseOverflowTest && - this->GetCoarseTime() + get4tdc::kuCoarseOverflowTest <= obj->GetCoarseTime() ) - // Corse counter overflow between checked hit and this one - // rhs ... Ovflw ... hit - return 1; - else if( this->GetCoarseTime() < obj->GetCoarseTime() ) - // CT hit ... rhs - return -1; - else if( this->GetCoarseTime() > obj->GetCoarseTime() ) - // CT rhs ... hit - return 1; - else if( this->GetFineTime() < obj->GetFineTime()) - // CT rhs = hit - // FT hit ... rhs - return -1; - else if( this->GetFineTime() > obj->GetFineTime()) - // CT rhs = hit - // FT rhs ... hit - return 1; - // CT rhs = hit - // FT rhs = hit - else return 0; -} diff --git a/beamtime/tof/tdc/get4/TTofGet4Data.h b/beamtime/tof/tdc/get4/TTofGet4Data.h deleted file mode 100644 index 769b9d9c60c441b31ac8ad9a71bebf7cd216d8a0..0000000000000000000000000000000000000000 --- a/beamtime/tof/tdc/get4/TTofGet4Data.h +++ /dev/null @@ -1,80 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TTofGet4Data ----- -// ----- Created 22/07/2013 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ - -#ifndef TTOFGET4DATA_H_ -#define TTOFGET4DATA_H_ - -#include "TTofTdcData.h" - -class TTofGet4Data : public TTofTdcData -{ - public: - TTofGet4Data(); - TTofGet4Data( UInt_t uChan, UInt_t uFt, - UInt_t uCoarseT, - ULong64_t uFulltime = 0, Double_t dFullTime = 0.0, - UInt_t uGet4Epoch = 0, UInt_t uGet4EpCycle = 0, - UInt_t uTot = 0, Bool_t bIs32Bit = kFALSE ); - ~TTofGet4Data(); - - virtual void Clear(Option_t *option = ""); - - // copy constructor, used by vector to copy content - TTofGet4Data(const TTofGet4Data& src) : - TTofTdcData(src), - fuFulltime(src.fuFulltime), - fdFullTime(src.fdFullTime), - fuGet4Epoch(src.fuGet4Epoch), - fuGet4EpochCycle(src.fuGet4EpochCycle), - fbIs32Bit(src.fbIs32Bit) {}; - // Comparison operator, needed for time sorting - // To be implemeted for each TDC type as need coarse counter size - virtual Bool_t operator <( const TTofGet4Data& rhs) const; - virtual Bool_t operator <( const TTofTdcData& rhs) const; - - virtual Int_t Compare( const TObject* obj) const; - virtual Int_t Compare( const TTofGet4Data* obj) const; - virtual Int_t Compare( const TTofTdcData* obj) const; - virtual Bool_t IsSortable() const { return kTRUE; }; - - void SetFullTime( ULong64_t ts) - { - fuFulltime=ts; - fdFullTime = (Double_t) ts; - }; - void SetFullTimeD( Double_t ts) - { - fdFullTime = ts; - fuFulltime = (ULong64_t)ts; - }; - void SetEpoch( UInt_t uGet4Epoch) { fuGet4Epoch = uGet4Epoch; }; - void SetEpochCycle( UInt_t uGet4EpCycle) { fuGet4EpochCycle = uGet4EpCycle; }; - void Set32bFlag( UInt_t u32Bit){ fbIs32Bit = (1 == u32Bit) ? kTRUE: kFALSE; }; - void Set32bFlag( Bool_t b32Bit = kTRUE){ fbIs32Bit = b32Bit; }; - - ULong64_t GetFullTime() const { return fuFulltime; }; - Double_t GetFullTimeD() const { return fdFullTime; }; - UInt_t GetEpoch() const { return fuGet4Epoch; }; - UInt_t GetEpochCycle() const { return fuGet4EpochCycle; }; - Bool_t Is32Bit( ) const { return fbIs32Bit; }; - - private: - // Full time stamp without correction, usefull for time ordering and data selection - ULong64_t fuFulltime; - Double_t fdFullTime; - - // Get4 epoch2 counter and cycles of this counter - UInt_t fuGet4Epoch; - UInt_t fuGet4EpochCycle; - - /* - * Flag indicating that this data point was from a GET4 readout in 32b mode - * => Tot calculated on chip and included in data! - */ - Bool_t fbIs32Bit; - ClassDef(TTofGet4Data, 1) -}; - -#endif // TTOFGET4DATA_H_ diff --git a/beamtime/tof/tdc/get4/TTofGet4Unpacker.cxx b/beamtime/tof/tdc/get4/TTofGet4Unpacker.cxx deleted file mode 100644 index 5fb2f66d14e1ac0bd640403116307c277385f4fb..0000000000000000000000000000000000000000 --- a/beamtime/tof/tdc/get4/TTofGet4Unpacker.cxx +++ /dev/null @@ -1,4446 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TTofGet4Unpacker ----- -// ----- Created 22/07/2013 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ - -/* - * Conversion of definitions to constants: - * -MAX_ROC get4v10::kuMaxRoc -MAX_GET4 get4v10::kuMaxGet4 -MAX_GET4_PER_ROC get4v10::kuMaxGet4Roc -MAX_AUX get4v10::kuMaxAux -MAX_SYNC get4v10::kuMaxSync -GET4_PRINT get4v10::kiGet4MessPr -GET4_EPOCH_CYCLE_SIZE get4v10::kulGet4EpochCycleSz -MAIN_EPOCH_CYCLE_SIZE get4v10::kulMainEpochCycleSz -MAIN_CLK_SYNC_SIZE get4v10::kiSyncCycleSzMain -GET4_SYNC_CYCLE_SIZE get4v10::kiSyncCycleSzGet4 -MAX_DATA_TRIGG get4v10::kiMaxNbDataTriggs -MAX_SEC_TRIG get4v10::kiMaxNbSecTriggCh - -NB_BIN_GET4_FTS get4tdc::kiFineTime -GET4_BIN_SIZE_IN_PS get4tdc::kdBinSize -GET4_EPOCH_IN_BINS get4tdc::kiEpochInBins -GET4_EPOCH_IN_PS get4tdc::kdEpochInPs - -NB_CHAN_GET4 get4v10::kuNbChan instead of get4tdc::kuNbChan to accomodate 2tdc ch per input ch - -psubevt->GetSubcrate() fcSubCrate -psubevt->GetControl() fcControl -psubevt->GetDlen() uLength ??? -psubevt->GetDataField() pMbsData - -GetTriggerNumber() Not available (TCBMBeamtimeProc method) -GetEventNumber() Not available (TCBMBeamtimeProc method) -*/ - -#include "TTofGet4Unpacker.h" - -// TOF headers -#include "TofDef.h" -#include "TMbsUnpackTofPar.h" -#include "TofTdcDef.h" -#include "TofGet4Def.h" -#include "TTofGet4Data.h" -#include "TTofGet4Board.h" - -// FAIR headers -#include "FairRootManager.h" -#include "FairLogger.h" -#include "TString.h" - -// ROOT headers -#include "TClonesArray.h" -#include "TH1.h" -#include "TROOT.h" -#include "TDirectory.h" - -// Includes from old GO4 unpacker - // ROOT -#include "Riostream.h" -#include "TH1.h" -#include "TH2.h" -#include "TTimeStamp.h" -#include "TROOT.h" -#include "TSystem.h" -#include "TLatex.h" - // GO4 -//#include "TGo4MbsEvent.h" -//#include "TGo4WinCond.h" -//#include "TGo4Log.h" -//#include "TGo4Version.h" - // GET4 -#include "TGet4v1Param.h" - // ROC -#include "roc/Message.h" -#include "roc/Board.h" - // C++ -#include <algorithm> -#include <iostream> - -using std::cout; -using std::endl; - -TTofGet4Unpacker::TTofGet4Unpacker(): - fParUnpack(0), - fiProcId( roc3587::proc_RocEvent ), - fcSubCrate( 0 ), - fcControl( roc::formatOptic2 ), - fuNbTdc(0), - fGet4BoardCollection(NULL), - fbDataSavedForThisEvent(kFALSE), - fb24bitsReadoutDetected(kFALSE), - fb32bitsReadoutDetected(kFALSE), - fParam(NULL), - fCurrentGet4Event (), - fIsTimeSorted(kFALSE), - fEvntSize(NULL), - fEvtPerProc(NULL), - fEvtIndexRoc(NULL), - fEvtIndexTrig(NULL), - fEvtIndexVme(NULL), - uInitialEvent(0), - uEventCountsRoc(0), - uEventCountsTrig(0), - uEventCountsVme(0), - fTriggerNumber(NULL), - fMsgsPerRoc(NULL), - fTriggerPerRoc(NULL), - fDeltaTriggerTime(NULL), - fGlobalTriggerWind(NULL), - fGlobalAUXWind(NULL), - fGlobalSelfTriggWind(NULL), - fTotaldatasize(0), - fCurrEvntTm(0), - fLastRateTm(0.), - fRate(0.), - ROC(), - fFirstSubEvent(kFALSE), - fHasNewGlobalTrigger(kFALSE), - fTriggerCounter(0), - printData(0), - fHitTemp() -{ -} -TTofGet4Unpacker::TTofGet4Unpacker( TMbsUnpackTofPar * parIn, Short_t sProcId, Short_t sSubCrate, Short_t sControl ): - fParUnpack( parIn ), - fiProcId( sProcId ), - fcSubCrate( sSubCrate ), - fcControl( sControl ), - fuNbTdc( parIn->GetNbActiveBoards( tofMbs::get4 ) ), - fGet4BoardCollection(NULL), - fbDataSavedForThisEvent(kFALSE), - fb24bitsReadoutDetected(kFALSE), - fb32bitsReadoutDetected(kFALSE), - fParam(NULL), - fCurrentGet4Event (), - fIsTimeSorted(kFALSE), - fEvntSize(NULL), - fEvtPerProc(NULL), - fEvtIndexRoc(NULL), - fEvtIndexTrig(NULL), - fEvtIndexVme(NULL), - uInitialEvent(0), - uEventCountsRoc(0), - uEventCountsTrig(0), - uEventCountsVme(0), - fTriggerNumber(NULL), - fMsgsPerRoc(NULL), - fTriggerPerRoc(NULL), - fDeltaTriggerTime(NULL), - fGlobalTriggerWind(NULL), - fGlobalAUXWind(NULL), - fGlobalSelfTriggWind(NULL), - fTotaldatasize(0), - fCurrEvntTm(0), - fLastRateTm(0.), - fRate(0.), - ROC(), - fFirstSubEvent(kFALSE), - fHasNewGlobalTrigger(kFALSE), - fTriggerCounter(0), - printData(0), - fHitTemp() -{ -} -TTofGet4Unpacker::~TTofGet4Unpacker() -{ - // TODO: Histos file -// WriteHistos(); - - // not sure if it will not make problems for seeing them -// DeleteHistos(); - ROC.clear(); -} - -void TTofGet4Unpacker::Clear(Option_t * /*option*/) -{ - fParUnpack = NULL; - fuNbTdc = 0; - fGet4BoardCollection = NULL; -} -void TTofGet4Unpacker::ProcessGet4( UInt_t* pMbsData, UInt_t uLength, Char_t cSubCrate, Char_t cControl ) -{ - fcSubCrate = cSubCrate; - fcControl = cControl; - ProcessGet4( pMbsData, uLength ); -} - - -void TTofGet4Unpacker::ProcessGet4( UInt_t* pMbsData, UInt_t uLength ) -{ -// if( (iTdcIndex<0) || (fuNbTdc <= iTdcIndex) || -// (fGet4BoardCollection->GetEntriesFast() <= iTdcIndex )) - - // Use a flag to insure only the first detected event is saved in each MBS event - fbDataSavedForThisEvent = kFALSE; - -/* uint32_t g4id(0);*/ // Commented out as unused to remove warning - uint32_t auxid(0); -/* uint32_t syncid(0);*/ // Commented out as unused to remove warning - uint64_t fulltm(0); - uint32_t typ(0), rocid(0); -/* uint32_t lastevrocid(0);*/ // Commented out as unused to remove warning -/* static int cnt=0;*/ // Commented out as unused to remove warning - unsigned msgcount=0; - - - // TODO: Replace it with a parameter option - // => cannot be detected in FAIRROOT scheme, so it is responsability - // of the user to insure the proper sub-event type is provided to the unpacker - bool is_dabc_evt = (fiProcId == roc3587::proc_RocEvent) || - (fiProcId == roc3587::proc_ErrEvent) || - (fiProcId == roc3587::proc_MergedEvent); - bool is_raw_evt = (fiProcId == roc3587::proc_RawData); - if( 1 == is_raw_evt && kFALSE == fParam->bRawDataMode ) - { - fParam->bRawDataMode = kTRUE; - cout<<" Found a RAW DATA event => switch RAW DATA mode ON"<<endl; - } - - unsigned rid = fcSubCrate; - -// BEGIN INITIAL EVENT PART - int datasize = (uLength - 2) * 2; -// int datasize = uLength * 2; -// int msg_fmt = fcControl; - roc::MessageFormat msg_fmt = ConvertToMsgFormat(fcControl); - ROC[rid].fIter.setFormat(msg_fmt); - ROC[rid].fIter.setRocNumber(rid); - - /** GET4 unpacking & pre-processing **/ - if( -1 != fParam->FindGet4RocId( fcSubCrate ) ) - { - Int_t iFeetRocIndex = fParam->FindGet4RocId( fcSubCrate ); - if(uNbEvents[iFeetRocIndex] == 0) { -// uFirstEventIndex[iFeetRocIndex] = GetEventNumber(); - TString sTemp = Form("***** First event on Get4 roc %d: %d ", iFeetRocIndex, uFirstEventIndex[iFeetRocIndex]); - LOG(info)<<sTemp; - } // if(uNbEvents[iFeetRocIndex] == 0) - /* - else { - if( 0 < fParam->iEventNbGap && - (Int_t)uPrevEventIndex[iFeetRocIndex] + fParam->iEventNbGap != GetEventNumber() && - ( uPrevEventIndex[iFeetRocIndex] != fParam->uEventNbCycle || 0 != GetEventNumber() ) ) { - TString sTemp = Form("***** Missing event in file for Get4 roc %d: Event %d, Previous event index %d, Current event Index %d, expected %d", - iFeetRocIndex, uNbEvents[iFeetRocIndex], uPrevEventIndex[iFeetRocIndex], GetEventNumber(), - (Int_t)uPrevEventIndex[iFeetRocIndex] + fParam->iEventNbGap); - LOG(error)<<sTemp; - } // if not matching expected event gap - } // else of if(uNbEvents[iFeetRocIndex] == 0) - uPrevEventIndex[iFeetRocIndex] = GetEventNumber(); - */ - uNbEvents[iFeetRocIndex]++; - } // if( -1 != fParam->FindGet4RocId( fcSubCrate ) ) - /*************************************/ - - // we can exclude messages (SYNC and may be EPOCH) which are added by DABC at the end of subevent - if (is_dabc_evt) - { - // ignore all irrelevant events - /* - if (GetTriggerNumber()>11) - { - cout<<"OUPS, trigger too high: "<<GetTriggerNumber()<<endl; - return; - } - */ - - roc::Message msg1, msg2; - roc::Message msgA, msgB; - - char* ptr = (char*) pMbsData; - int msglen = roc::Message::RawSize(msg_fmt); - - if (ROC[rid].fIter.assign(ptr + datasize - msglen, msglen)) { - if (ROC[rid].fIter.next()) msg1.assign(ROC[rid].fIter.msg()); - } - - if (!msg1.isSyncMsg()) { - LOG(error)<<"Non-SYNC message at the end of DABC-produced subevent"; - } else { - rocid = msg1.getRocNumber(); - /* - * TODO: Option to choose between removing final epoch+SYNC or initial epoch+SYNC - */ -/* UInt_t uSyncId = msg1.getSyncChNum();*/ // Commented out as unused to remove warning -/* UInt_t uSyncTs = msg1.getSyncTs();*/ // Commented out as unused to remove warning -/* UInt_t uSyncEpLsb = msg1.getSyncEpochLSB();*/ // Commented out as unused to remove warning -/* UInt_t uSyncData = msg1.getSyncData();*/ // Commented out as unused to remove warning -/* UInt_t uSyncFlag = msg1.getSyncStFlag();*/ // Commented out as unused to remove warning - ULong64_t ulFulltime = msg1.getMsgFullTime( ROC[rocid].GetFullEpochNumber( ) ); - ulFulltime += ROC[rocid].GetSuperCycleEpOffset(); -/* - cout<<"End Event "<<GetEventNumber()<<" Sync Id "<<uSyncId<<" Ts "<<uSyncTs; - cout<<" EpLsb "<<uSyncEpLsb<<" Data "<<uSyncData<<" Flag "<<uSyncFlag; - cout<<" FullT "<<ulFulltime<<endl; - */ - /* - * - */ - - // kFALSE = SYNC arriving before the event data, kTRUE = after - // => if kTRUE, keep last 2 message and throw 2 first! - if( kFALSE == fParam->bTriggerAfterData ) - datasize -= msglen; - int shift = msglen; - while (shift<=datasize) { - - if (ROC[rid].fIter.assign(ptr + datasize - shift, msglen)) { - if (ROC[rid].fIter.next()) - msg2.assign(ROC[rid].fIter.msg()); - else - break; - - if (msg2.isEpochMsg()) - { - /* - cout<<"End Event "<<GetEventNumber()<<" Epoch "<<msg2.getEpochNumber()<<endl; - */ - break; - } - } - shift+=msglen; - } - // exclude special epoch message for sync only - // kFALSE = SYNC arriving before the event data, kTRUE = after - // => if kTRUE, keep last 2 message and throw 2 first! - if( kFALSE == fParam->bTriggerAfterData ) - if ((shift==msglen) && msg2.isEpochMsg()) datasize -= msglen; - } // else of if (!msg1.isSyncMsg()) - } // if (is_dabc_evt) - - fTotaldatasize += datasize; - - if (!ROC[rid].fIter.assign(pMbsData, datasize)) - { - cout<<"OUPS, probblem: "<<pMbsData<<" "<<datasize<<endl; - return; - } // if (!ROC[rid].fIter.assign(pMbsData, datasize)) - - fEvntSize->Fill(datasize); - - //cout << "AnlProc: found subevent subcrate="<<(int) fcSubCrate<<", procid="; - //cout<<(int)psubevt->GetProcid()<<", control="<<(int) psubevt->GetControl()<< endl; -// END INITIAL EVENT PART - - /* TODO FILL ME - * Buffer processing - */ - - roc::Message* data = & ROC[rid].fIter.msg(); - while (ROC[rid].fIter.next()) { - msgcount++; - - rocid = data->getRocNumber(); - fMsgsPerRoc->Fill(rocid); - - // Process data only from active ROCs - if( kFALSE == fParam->IsActiveRoc(rocid) ) - continue; - - typ = data->getMessageType(); - if(typ==roc::MSG_GET4) - { - fulltm = data->getMsgFullTime( - ROC[rocid].GetFullEpoch2Number( - fParam->RemapGet4Chip( data->getGet4Number() ) )); - fulltm += ROC[rocid].GetSuperCycleEp2Offset( - fParam->RemapGet4Chip( data->getGet4Number() ) ); - } - else - { - fulltm = data->getMsgFullTime( - ROC[rocid].GetFullEpochNumber() ); - fulltm += ROC[rocid].GetSuperCycleEpOffset( ); - - } - - ROC[rocid].fMsgTypes->Fill(typ); - - ULong64_t ulMsgTm = fulltm / 100000000L; - ROC[rocid].fALLt->Fill( (ulMsgTm % 36000) * 0.1 ); - - // Long duration time distribution (1 min. bin, 10 days length) - if( kTRUE == fParam->bLongTimeHistos ) - ROC[rocid].fAllLongT->Fill( ( ulMsgTm * 0.1 ) /3600); - - TGet4v1MessageExtended exmess(*data,fulltm); - - switch (typ) - { - case roc::MSG_NOP: - { - break; - } // case roc::MSG_NOP: - case roc::MSG_HIT: - { - break; - } // case roc::MSG_HIT: - case roc::MSG_GET4: - { - Double_t dFullTimeD = data->getMsgFullTimeD( - ROC[rocid].GetFullEpoch2Number( - fParam->RemapGet4Chip( data->getGet4Number() ) ) ); - dFullTimeD += ROC[rocid].GetSuperCycleEp2OffsetD( fParam->RemapGet4Chip( data->getGet4Number() ) ); - exmess.SetFullTimeD( dFullTimeD ); - // In case of suppressed epochs, we will have no epoch2 message for all empty epochs - // However, when a chip has data, its next epoch message should be present!!! - // => Specific function to wait for next epoch2 - if( kTRUE == fParam->bSuppressedEpochs) - ProcessGet4SuppDataMessage(rocid, exmess); - else if( kTRUE == ProcessGet4DataMessage(rocid, exmess) ) - ProcessExtendedMessage(rocid, exmess); - break; - } // case roc::MSG_GET4: - case roc::MSG_EPOCH: - { - /* - if((msgcount<3) && !is_raw_evt) - { - cout<<"Beg Event "<<GetEventNumber()<<" Epoch "<<data->getEpochNumber()<<endl; - } - */ - if( !is_dabc_evt || kFALSE == fParam->bTriggerAfterData || - 2 < msgcount) - ProcessRocEpochMessage(rocid, exmess); - break; - } // case roc::MSG_EPOCH: - case roc::MSG_EPOCH2: - { - if( kTRUE == fParam->bSuppressedEpochs) - ProcessGet4SuppEpochMessage(rocid, exmess); - else ProcessGet4EpochMessage(rocid, exmess); - break; - } // case roc::MSG_EPOCH2: - case roc::MSG_SYNC: - { -/* UInt_t uSyncId = data->getSyncChNum();*/ // Commented out as unused to remove warning -/* UInt_t uSyncTs = data->getSyncTs();*/ // Commented out as unused to remove warning -/* UInt_t uSyncEpLsb = data->getSyncEpochLSB();*/ // Commented out as unused to remove warning -/* UInt_t uSyncData = data->getSyncData();*/ // Commented out as unused to remove warning -/* UInt_t uSyncFlag = data->getSyncStFlag();*/ // Commented out as unused to remove warning - ULong64_t ulFulltime = data->getMsgFullTime( ROC[rocid].GetFullEpochNumber( ) ); - ulFulltime += ROC[rocid].GetSuperCycleEpOffset(); - - if( kFALSE == fParam->bTriggerAfterData ) - { - if((msgcount<3) && !is_raw_evt) - { - ROC[rocid].fDabcSeparator = data->getSyncChNum()+10; - } - ProcessRocSyncMessage(rocid, exmess); - } // if( kFALSE == fParam->bTriggerAfterData ) - else if( (2 < msgcount ) || !is_dabc_evt) - { - if( ( (datasize - 3 ) < (Int_t)msgcount) && !is_raw_evt) - { - ROC[rocid].fDabcSeparator = data->getSyncChNum()+10; - } - ProcessRocSyncMessage(rocid, exmess); - } // else if( (2 < msgcount ) || !is_dabc_evt) of if( kFALSE == fParam->bTriggerAfterData ) - break; - } // case roc::MSG_SYNC: - case roc::MSG_AUX: - { - auxid = data->getAuxChNum(); - ROC[rocid].fAUXch->Fill(auxid); - if (auxid < get4v10::kuMaxAux) - { - ROC[rocid].fLastAuxTm[auxid] = fulltm; - - // Recalculate the full Time to take into account also the epoch cycles - ULong64_t ulFulltime ; - ulFulltime = (exmess.GetRocMessage()).getMsgFullTime( - ROC[rocid].GetFullEpochNumber( )); - ulFulltime += ROC[rocid].GetSuperCycleEpOffset(); - exmess.SetFullTime(ulFulltime); - - ULong64_t auxtm = fulltm / 100000000L; - ROC[rocid].fAUXt[auxid]->Fill((auxtm % 10000) * 0.1); - - if( kFALSE == fParam->bFreeStreaming || 0 == fParam->uNbTriggers ) - if (fParam->triggerSignal == (Int_t) auxid) - { - ProcessTriggerMessage(rocid, exmess); - } - } // if (auxid < get4v10::kuMaxAux) - - break; - } // case roc::MSG_AUX: - case roc::MSG_SYS: - { - ROC[rocid].fSysTypes->Fill(data->getSysMesType()); - - UShort_t ucSysMesType = data->getSysMesType(); // change type to avoid warning if last Chip id reach char type size - - if (data->getSysMesType() == roc::SYSMSG_USER) - { - ROC[rocid].fSysUserTypes->Fill(data->getSysMesData()); - - switch (data->getSysMesData()) - { - case roc::SYSMSG_USER_CALIBR_ON: - ROC[rocid].bIgnoreData = kFALSE; - break; - case roc::SYSMSG_USER_CALIBR_OFF: - ROC[rocid].bIgnoreData = kFALSE; - break; - case roc::SYSMSG_USER_RECONFIGURE: - ROC[rocid].bIgnoreData = kTRUE; - ROC[rocid].fIgnoreCnt = 0; - ROC[rocid].fIgnoreTime = fulltm; - break; - default: - break; - } // switch (data->getSysMesData()) - } // if (data->getSysMesType() == roc::SYSMSG_USER) - else if( data->getSysMesType() == roc::SYSMSG_GET4_EVENT ) - { -/* UInt_t uGet4SysMessType = (data->getSysMesData()>>6) & 0x1;*/ // Commented out as unused to remove warning - - // Get4 system message types histogram - /* - if (ROC[rocid].fGet4SysTypes) - ROC[rocid].fGet4SysTypes->Fill(uGet4SysMessType); - */ - - UInt_t uGet4IndexOffset = fParam->DefineGet4IndexOffset(rocid); - // Remap the Get4 chip index - UInt_t uChip = data->getField(40, 8) + uGet4IndexOffset; - uChip = fParam->RemapGet4Chip(uChip); - // Set Remapped Get4 index - data->setField(40, 8, uChip); - - // Get4 system message type = Error - if (!fParam->IsValidGet4Chip(uChip)) { - cout << "Error: Bad chip nb in Error message = " << uChip << endl; - cout << " => This message will be skipped!!!! "<<endl; - continue; - } -/* - fGet4ErrorChip->Fill( uChip ); - fGet4ErrorPatt->Fill( uChip, (data->getSysMesData()) & 0x7f); - if( 3 < ( (data->getSysMesData()) & 0x7f ) && ( (data->getSysMesData()) & 0x7f ) < 7 ) - fGet4ErrorChan->Fill( (((data->getSysMesData()) & 0x300)>>16) + 0.5*(((data->getSysMesData()) & 0x80)>>15), - ((data->getSysMesData()) & 0x7f )>>2 ); -*/ - UInt_t get4_24b_er_code = exmess.getGet4V10R32ErrorData(); - UInt_t get4_24b_er_chan = exmess.getGet4V10R32ErrorChan(); - UInt_t get4_24b_er_edge = exmess.getGet4V10R32ErrorEdge(); - - ROC[rocid].fGet4ErrorChip->Fill( uChip ); - ROC[rocid].fGet4ErrorPatt->Fill( uChip, get4_24b_er_code); - if( (0x03 < get4_24b_er_code && get4_24b_er_code < 0x07) ) - ROC[rocid].fGet4ErrorChan->Fill( - get4v10::kuNbChan*uChip + get4_24b_er_chan + 0.5*get4_24b_er_edge, - get4_24b_er_code - 0x04 ); - - ULong64_t uFullTimeBins = ((ULong64_t) ROC[rocid].GetFullEpoch2Number( uChip )) << 19; - uFullTimeBins /= 20; // now in ns - uFullTimeBins += 512; // 250MHz offset - uFullTimeBins /= 100000000L; - ROC[rocid].fERRORt->Fill( (uFullTimeBins % 36000) * 0.1 ); - - // Long duration time distribution (1 min. bin, 10 days length) - if( kTRUE == fParam->bLongTimeHistos ) - ROC[rocid].fErrorLongT->Fill( (uFullTimeBins * 0.1 ) / 3600 ); - - } // if( data->getSysMesType() == roc::SYSMSG_GET4_EVENT ) - else if( get4v10::SYSMSG_GET4V1_32BIT_0 <= data->getSysMesType() && - ucSysMesType <= get4v10::SYSMSG_GET4V1_32BIT_15 ) - { - if( 3 == Process32BitGet4Message(rocid, exmess) ) - ProcessExtendedMessage(rocid, exmess); - } // if GET4 32 bits message - break; - } // case roc::MSG_SYS: - default: - break; - } // switch (typ) - - if(printData<fParam->uGet4Print ) - { - exmess.Print(roc::msg_print_Human); - printData++; - } - } // while (ROC[rid].fIter.next()) { - /* - * Buffer processing End - */ - - fFirstSubEvent = kFALSE; - - if( kFALSE == fbDataSavedForThisEvent ) - { - // First event found in this MBS event - for( UInt_t uGet4 = 0; uGet4 < get4v10::kuMaxGet4; uGet4++) - { - TTofGet4Board * fGet4Board = (TTofGet4Board*) fGet4BoardCollection->ConstructedAt(uGet4); - - // Check if there is an unfinished event and save its data if it is the case - if( kFALSE == fCurrentGet4Event.IsEmpty() ) - { - if( 0 < (fCurrentGet4Event.fGet4Boards[uGet4]).Size() ) - { - fGet4Board->SetTriggerFullTime( fCurrentGet4Event.fdTriggerFullTime[0] ); // Use only first ROC!!!! - fGet4Board->SetSyncEventFlag( fCurrentGet4Event.fbMbsSyncedEvent ); - fGet4Board->SetSyncEvtNb( fCurrentGet4Event.fuSyncEventNumber ); - fGet4Board->SetDataEventFlag( fCurrentGet4Event.fbDataTriggered ); - fGet4Board->SetTriggIndx( fCurrentGet4Event.fuTriggerIndex ); - - // Some Data found for this TDC Chip - for( UInt_t uCh = 0; uCh < get4v10::kuNbChan; uCh++ ) - for( UInt_t uHit = 0; - uHit < ((fCurrentGet4Event.fGet4Boards[uGet4]).fHits[uCh]).size(); - uHit++ ) - { - TGet4v1MessageExtended extTime = ((fCurrentGet4Event.fGet4Boards[uGet4]).fHits[uCh])[uHit].GetTimeMessage(); - TGet4v1MessageExtended extTot = ((fCurrentGet4Event.fGet4Boards[uGet4]).fHits[uCh])[uHit].GetTotMessage(); - - if( kFALSE == extTime.IsEmpty() ) - { - TTofGet4Data dataTime; - dataTime.SetEdge( 0 ); - if( kTRUE == extTime.Is32Bit() ) - { - dataTime.SetChannel( uCh ); - dataTime.SetFineTime( extTime.getGet4V10R32HitFt() ); - dataTime.SetCoarseTime( extTime.getGet4V10R32HitTs() ); - dataTime.SetTot( extTime.getGet4V10R32HitTot() ); - } // if( kTRUE == extTime.Is32Bit() ) - else - { - // Time saved in "odd channels" as example of VFTX - dataTime.SetChannel( 2*uCh + 1 ); - dataTime.SetFineTime( extTime.GetGet4Ts() & get4tdc::kiFineTime ); - dataTime.SetCoarseTime( (extTime.GetGet4Ts() & get4tdc::kiCoarseTime )>>get4tdc::kiCtShift ); - } // else of if( kTRUE == extTime.Is32Bit() ) - dataTime.SetEpoch( extTime.GetRocEpoch() ); - dataTime.SetEpochCycle( extTime.GetRocCycle() ); - dataTime.SetFullTimeD( extTime.GetFullTimeD() ); - dataTime.Set32bFlag( extTime.Is32Bit() ); - fGet4Board->AddData( dataTime ); - } // if( kFALSE == extTime.IsEmpty() ) - - if( kFALSE == extTot.IsEmpty() ) - { - // Will appear only in case of 24bit mode !!! - TTofGet4Data dataTot; - // Tot saved in "even channels" as example of VFTX - dataTot.SetChannel( 2*uCh ); - dataTot.SetEdge( 1 ); - dataTot.SetFineTime( extTot.GetGet4Ts() & get4tdc::kiFineTime ); - dataTot.SetCoarseTime( (extTot.GetGet4Ts() & get4tdc::kiCoarseTime )>>get4tdc::kiCtShift ); - dataTot.SetEpoch( extTot.GetRocEpoch() ); - dataTot.SetEpochCycle( extTot.GetRocCycle() ); - dataTot.SetFullTimeD( extTot.GetFullTimeD() ); - dataTot.Set32bFlag( extTot.Is32Bit() ); - fGet4Board->AddData( dataTot ); - } // if( kFALSE == extTot.IsEmpty() ) - } // scan over all hits in this board object - - } // if( 0 < (fCurrentGet4Event.fGet4Boards[uGet4]).Size() ) - } // if( kFALSE == fCurrentGet4Event.IsEmpty() ) - } // for( UInt_t uGet4 = 0; uGet4 < get4v10::kuMaxGet4; uGet4++) - fbDataSavedForThisEvent = kTRUE; - } // if( kFALSE == fbDataSavedForThisEvent ) - return; -} - -Bool_t TTofGet4Unpacker::Init( ) -{ - if( kFALSE == InitParameters() ) - return kFALSE; - if( kFALSE == InitOutput() ) - return kFALSE; - if( kFALSE == CreateHistos() ) - return kFALSE; - if( kFALSE == InitConditions() ) - return kFALSE; - - return kTRUE; -} -Bool_t TTofGet4Unpacker::InitParameters( ) -{ - -// fParam = (TGet4v1Param *) MakeParameter("Get4v1Par", "TGet4v1Param" /*, "set_RocPar.C" */); - fParam = new TGet4v1Param("Get4v1Par"); - gROOT->GetListOfSpecials()->Add(fParam); // Register param so it can be retrieved by gROOT->FindObject - - - fLastRateTm = TTimeStamp().AsDouble(); - fTotaldatasize = 0; - fRate = 0.; - - // here we optionally override parameter values with setup macro, if existing: - TString setupmacro = "set_Get4v1Par.C"; - if (!gSystem->AccessPathName(setupmacro.Data())) { - TString sTemp = Form("Executing ROC parameter setup script %s", setupmacro.Data()); - LOG(info)<<sTemp; - gROOT->ProcessLine(Form(".x %s( )", setupmacro.Data())); - // need to copy parameter setup to static event array, - // when restored from Autosave file, executed in UpdateFrom method - fParam->SetConfigRocs(); - } else { - TString sTemp = Form("NO ROC parameter setup script %s. Use previous values!", setupmacro.Data()); - LOG(info)<<sTemp; - } - - fParam->PrintGet4Options(); - if (fParam->numRocs > get4v10::kuMaxRoc) fParam->numRocs = get4v10::kuMaxRoc; - if (fParam->uNbGet4 > get4v10::kuMaxGet4) fParam->uNbGet4 = get4v10::kuMaxGet4; - - printData = 0; - - - ResetEndOfBuffer(); - fCurrentGet4Event.Clear(); - - uInitialEvent = 0; - uEventCountsRoc = 0; - uEventCountsTrig = 0; - uEventCountsVme = 0; - - return kTRUE; -} -Bool_t TTofGet4Unpacker::InitConditions() -{ -// fGlobalTriggerWind = MakeWinCond("TriggerWindow", -100, 2000., fDeltaTriggerTime->GetName()); -// fGlobalAUXWind = MakeWinCond("AUXWindow", -100, 100., fDeltaTriggerTime->GetName()); - fGlobalTriggerWind = new TimeWindowCond( "TriggerWindow", -100., 2000.); - gROOT->GetListOfSpecials()->Add(fGlobalTriggerWind); // Register Condition so it can be retrieved by gROOT->FindObject - fGlobalAUXWind = new TimeWindowCond( "AUXWindow", -100., 100.); - gROOT->GetListOfSpecials()->Add(fGlobalAUXWind); // Register Condition so it can be retrieved by gROOT->FindObject - - TString setupmacro = "set_Get4v1Cond.C"; - if (!gSystem->AccessPathName(setupmacro.Data())) { - TString sTemp = Form("Executing ROC condition setup script %s", setupmacro.Data()); - LOG(info)<<sTemp; - gROOT->ProcessLine(Form(".x %s()", setupmacro.Data() ) ); // -// gROOT->ProcessLine(Form(".x %s( %p, %p, %p, %p )", setupmacro.Data(), -// fGlobalTriggerWind, fGlobalAUXWind, ROC[0].fTriggerWind, ROC[0].fAUXWind)); // Only ROC00!! - } else { - TString sTemp = Form("NO ROC condition setup script %s. Use previous values!", setupmacro.Data()); - LOG(info)<<sTemp; - } - - return kTRUE; -} - -Bool_t TTofGet4Unpacker::InitOutput() -{ - // Recover first the GET4 board objects created in general unpacker class - FairRootManager* rootMgr = FairRootManager::Instance(); - - fGet4BoardCollection = (TClonesArray*) rootMgr->GetObject("TofGet4Tdc"); - if(NULL == fGet4BoardCollection) - { - LOG(warn)<<"TTofGet4Unpacker::TTofGet4Unpacker : no TOF GET4 TDC array! "; - fuNbTdc = 0; - return kFALSE; - } // if(NULL == fGet4BoardCollection) - return kTRUE; -} - -// Histogram management -Bool_t TTofGet4Unpacker::CreateHistos() -{ - LOG(debug)<<" TTofGet4Unpacker::CreateHistos Nb boards: "<<fuNbTdc<<" Directory "; - - TDirectory * oldir = gDirectory; // <= To prevent histos from being sucked in by the param file of the TRootManager! - gROOT->cd(); // <= To prevent histos from being sucked in by the param file of the TRootManager ! - - for (unsigned n=0; n < fParam->numRocs;n++) { - ROC.push_back(TGet4v1Rec()); - ROC[n].fRocId = n; - } - - fEvntSize = new TH1I("EvntSize", "Number of messages in event", - 250, 1., 2000.); - - fEvtPerProc= new TH1I("SubEventsPerProc", "Number of subevents per Proc index", - 64, 0., 64); - - fMsgsPerRoc = new TH1I("MsgsPerRoc", "Number of messages per ROC", - fParam->numRocs, 0., fParam->numRocs); - - fTriggerPerRoc = new TH1I("TriggersPerRoc", "Number of Trigger messages per ROC", - fParam->numRocs, 0., fParam->numRocs); - - fDeltaTriggerTime = new TH1I("TriggerDeltaTime", "Corrected hits time difference of all ROCs; Delta t", - 5000, -5000., 5000.); - - for( UInt_t uRoc =0; uRoc<fParam->numRocs; uRoc++ ) - { - // do not build histograms for non-used ROC - if (!fParam->IsActiveRoc(uRoc)) continue; - - char folder[30]; - sprintf(folder,"ROC%u/",uRoc); - - ROC[uRoc].fMsgTypes = new TH1I( Form("MsgTypes%u", uRoc), - Form("ROC%u Distribution of messages types", uRoc), - 8, 0., 8.); - -// if (IsObjMade()) - { - ROC[uRoc].fMsgTypes->GetXaxis()->SetBinLabel(1 + roc::MSG_NOP, "NOP"); - ROC[uRoc].fMsgTypes->GetXaxis()->SetBinLabel(1 + roc::MSG_HIT, "HIT"); - ROC[uRoc].fMsgTypes->GetXaxis()->SetBinLabel(1 + roc::MSG_EPOCH, "EPOCH"); - ROC[uRoc].fMsgTypes->GetXaxis()->SetBinLabel(1 + roc::MSG_SYNC, "SYNC"); - ROC[uRoc].fMsgTypes->GetXaxis()->SetBinLabel(1 + roc::MSG_AUX, "AUX"); - ROC[uRoc].fMsgTypes->GetXaxis()->SetBinLabel(1 + roc::MSG_EPOCH2, "EPOCH2"); - ROC[uRoc].fMsgTypes->GetXaxis()->SetBinLabel(1 + roc::MSG_GET4, "GET4"); - ROC[uRoc].fMsgTypes->GetXaxis()->SetBinLabel(1 + roc::MSG_SYS, "SYS"); - } - - ROC[uRoc].fSysTypes = new TH1I( Form("SysTypes%u", uRoc), - Form("ROC%u Distribution of system messages", uRoc), - roc::SYSMSG_GET4_EVENT+1, 0., roc::SYSMSG_GET4_EVENT+1); - -// if (IsObjMade()) - { - ROC[uRoc].fSysTypes->GetXaxis()->SetBinLabel(1 + roc::SYSMSG_DAQ_START, "DAQ_START"); - ROC[uRoc].fSysTypes->GetXaxis()->SetBinLabel(1 + roc::SYSMSG_DAQ_FINISH, "DAQ_FINISH"); - ROC[uRoc].fSysTypes->GetXaxis()->SetBinLabel(1 + roc::SYSMSG_NX_PARITY, "NX_PARITY"); - ROC[uRoc].fSysTypes->GetXaxis()->SetBinLabel(1 + roc::SYSMSG_SYNC_PARITY,"SYNC_PARITY"); - ROC[uRoc].fSysTypes->GetXaxis()->SetBinLabel(1 + roc::SYSMSG_DAQ_RESUME, "DAQ_RESUME"); - ROC[uRoc].fSysTypes->GetXaxis()->SetBinLabel(1 + roc::SYSMSG_FIFO_RESET, "FIFO_RESET"); - ROC[uRoc].fSysTypes->GetXaxis()->SetBinLabel(1 + roc::SYSMSG_USER, "USER_MSG"); - ROC[uRoc].fSysTypes->GetXaxis()->SetBinLabel(1 + roc::SYSMSG_PCTIME, "PCTIME"); - ROC[uRoc].fSysTypes->GetXaxis()->SetBinLabel(1 + roc::SYSMSG_ADC, "ADC"); - ROC[uRoc].fSysTypes->GetXaxis()->SetBinLabel(1 + roc::SYSMSG_PACKETLOST, "PACKETLOST"); - ROC[uRoc].fSysTypes->GetXaxis()->SetBinLabel(1 + roc::SYSMSG_GET4_EVENT, "GET4_EVENT"); - } - - ROC[uRoc].fSysUserTypes = new TH1I( Form("SysUserTypes%u", uRoc), - Form("ROC%u Distribution of user messages", uRoc), - 8, 7., 15.); -// if (IsObjMade()) - { - ROC[uRoc].fSysUserTypes->GetXaxis()->SetBinLabel(roc::SYSMSG_USER_CALIBR_ON - 6, "CALIBR_ON"); - ROC[uRoc].fSysUserTypes->GetXaxis()->SetBinLabel(roc::SYSMSG_USER_CALIBR_OFF - 6, "CALIBR_OFF"); - ROC[uRoc].fSysUserTypes->GetXaxis()->SetBinLabel(roc::SYSMSG_USER_RECONFIGURE - 6, "RECONFIGURE"); - } - - ROC[uRoc].fAUXch = new TH1I( Form("Roc%u_aux_chs", uRoc), - "Number events per aux channel", - 8, 0., 8.); - - ROC[uRoc].fTrigger_All = new TH1I( Form("Roc%u_Trigger", uRoc), - Form("Time difference between all hits and last trigger signal on ROC%u", uRoc), - 5000, -1000., 4000.); - ROC[uRoc].fTrigger_All_100 = new TH1I( Form("Roc%u_Trigger_100", uRoc), - Form("Time difference between all hits and last trigger signal on ROC%u", uRoc), - 50005, -100000., 1e6); - ROC[uRoc].fTrigger_All_us = new TH1I( Form("Roc%u_Trigger_us", uRoc), - Form("Time difference between all hits and last trigger signal on ROC%u", uRoc), - 1000, -1000., 999.*1e3); - ROC[uRoc].fTrigger_All_ms = new TH1I( Form("Roc%u_Trigger_ms", uRoc), - Form("Time difference between all hits and last trigger signal on ROC%u", uRoc), - 1000, -1e6, 999*1e6); - ROC[uRoc].fTrigger_All_s = new TH1I( Form("Roc%u_Trigger_s", uRoc), - Form("Time difference between all hits and last trigger signal on ROC%u", uRoc), - 1000, -1e9, 999*1e9); - - ROC[uRoc].fTrigger_AUX = new TH1I( Form("Roc%u_Trigger_AUX", uRoc), - Form("Time difference between all AUXs and last trigger signal on ROC%u", uRoc), - 5000, -5000., 5000.); - - ROC[uRoc].fEvntMultipl = new TH1I( Form("Roc%u_Multiplicity", uRoc), - Form("Event multiplicity for ROC%u in time window", uRoc), - 16, 0., 16.); - - ROC[uRoc].fALLt = new TH1I( Form("Roc%u_ALL_t",uRoc), Form("Time distribution of ALL signals on ROC%u; s", uRoc), - 36000, 0., 3600.); - - ROC[uRoc].fDATAt = new TH1I( Form("Roc%u_DATA_t",uRoc), Form("Time distribution of DATA hits on ROC%u; s", uRoc), - 36000, 0., 3600.); - - ROC[uRoc].fERRORt = new TH1I( Form("Roc%u_ERROR_t",uRoc), Form("Time distribution of ERROR signals on ROC%u; s", uRoc), - 36000, 0., 3600.); - - ROC[uRoc].fSLOWCt = new TH1I( Form("Roc%u_SLOWC_t",uRoc), Form("Time distribution of SLOW CONTROL signals on ROC%u; s", uRoc), - 36000, 0., 3600.); - - ROC[uRoc].fSelfTriggT = new TH1I( Form("Roc%u_SelfTrigg_t",uRoc), Form("Time distribution of self triggers on ROC%u; s", uRoc), - 36000, 0., 3600.); - - ROC[uRoc].fEPOCHt = new TH1I( Form("Roc%u_EPOCH_t",uRoc), Form("Time distribution of Epochs on ROC%u; s", uRoc), - 36000, 0., 3600.); - - ROC[uRoc].fAllSelectedT = new TH1I( Form("Roc%u_AllSel_t",uRoc), Form("Time distribution of all selected hits on ROC%u; s", uRoc), - 36000, 0., 3600.); - - for (unsigned nsync=0; nsync<get4v10::kuMaxSync; nsync++) - ROC[uRoc].fSYNCt[nsync] = new TH1I( Form("Roc%u_Sync%u_t", uRoc, nsync), - Form("Time distribution of SYNC%u signal on ROC%u; s", nsync, uRoc), - 36000, 0., 3600.); - - for (unsigned naux=0; naux<get4v10::kuMaxAux; naux++) - ROC[uRoc].fAUXt[naux] = new TH1I( Form("Roc%u_Aux%u_t", uRoc, naux), - Form("Time distribution of AUX%u signal on ROC%u; s", naux, uRoc), - 36000, 0., 3600.); - - // Long duration time distribution (1 min. bin, 10 days length) - if( kTRUE == fParam->bLongTimeHistos ) - { - ROC[uRoc].fAllLongT = new TH1I( Form("Roc%u_All_lt",uRoc), Form("Time distribution of ALL signals on ROC%u; t [h]", uRoc), - 18720, 0., 312.); - - ROC[uRoc].fDataLongT = new TH1I( Form("Roc%u_Data_lt",uRoc), Form("Time distribution of DATA hits on ROC%u; t [h]", uRoc), - 18720, 0., 312.); - - ROC[uRoc].fErrorLongT = new TH1I( Form("Roc%u_Error_lt",uRoc), Form("Time distribution of ERROR signals on ROC%u; t [h]", uRoc), - 18720, 0., 312.); - - ROC[uRoc].fSlowCLongT = new TH1I( Form("Roc%u_Slowc_lt",uRoc), Form("Time distribution of SLOW CONTROL signals on ROC%u; t [h]", uRoc), - 18720, 0., 312.); - - ROC[uRoc].fSelfTriggLongT = new TH1I( Form("Roc%u_SelfTrigg_lt",uRoc), Form("Time distribution of self triggers on ROC%u; t [h]", uRoc), - 18720, 0., 312.); - - ROC[uRoc].fEpochLongT = new TH1I( Form("Roc%u_Epoch_lt",uRoc), Form("Time distribution of Epochs on ROC%u; t [h]", uRoc), - 18720, 0., 312.); - - ROC[uRoc].fAllEpoch2LongT = new TH1I( Form("Roc%u_AllEp2_lt",uRoc), Form("Time distribution of all epoch2 on ROC%u; t [h]", uRoc), - 18720, 0., 312.); - - ROC[uRoc].fAllSelLongT = new TH1I( Form("Roc%u_AllSel_lt",uRoc), Form("Time distribution of all selected hits on ROC%u; t [h]", uRoc), - 18720, 0., 312.); - - for (unsigned nsync=0; nsync<get4v10::kuMaxSync; nsync++) - ROC[uRoc].fSyncLongT[nsync] = new TH1I( Form("Roc%u_Sync%u_lt", uRoc, nsync), - Form("Time distribution of SYNC%u signal on ROC%u; t [h]", nsync, uRoc), - 18720, 0., 312.); - } // if( kTRUE == fParam->bLongTimeHistos ) - - /** GET4 unpacking & pre-processing **/ - uNbEvents[uRoc] = 0; - uFirstEventIndex[uRoc] = 0; - uPrevEventIndex[uRoc] = 0; - - // Real events counters - uEventInsideMbsEvtCount[uRoc] = 0; - uRealEventsCount[uRoc] = 0; - uNotEmptyEventInsideMbsEvtCount[uRoc] = 0; - uNotEmptyRealEventsCount[uRoc] = 0; - -// ROC[uRoc].fTriggerWind = MakeWinCond(Form("Roc%u_EventWindow",uRoc), -// 485., 885., ROC[uRoc].fTrigger_All->GetName()); -// ROC[uRoc].fAUXWind = MakeWinCond(Form("Roc%u_AUXWindow",uRoc), -// -100., 100., ROC[uRoc].fTrigger_AUX->GetName()); - - ROC[uRoc].fTriggerWind = new TimeWindowCond( Form("Roc%u_EventWindow",uRoc), 485., 885. ); - gROOT->GetListOfSpecials()->Add(ROC[uRoc].fTriggerWind); // Register Condition so it can be retrieved by gROOT->FindObject - ROC[uRoc].fAUXWind = new TimeWindowCond( Form("Roc%u_AUXWindow",uRoc), -100., 100. ); - gROOT->GetListOfSpecials()->Add(ROC[uRoc].fAUXWind); // Register Condition so it can be retrieved by gROOT->FindObject - - for( UInt_t uGet4 = 0; uGet4 < get4v10::kuMaxGet4Roc; uGet4++) - { - char folderGet4[30]; - sprintf(folderGet4,"%sGet4_%u/",folder, uGet4); - UInt_t uRemappedGet4Index = fParam->RemapGet4Chip(uRoc, uGet4); - if( kTRUE == fParam->IsValidGet4Chip(uRemappedGet4Index) && - kTRUE == fParam->IsActiveGet4Chip(uRemappedGet4Index) ) - { - ROC[uRoc].fEPOCH2t[uGet4] = new TH1I( Form("Roc%u_EPOCH2_t_%u",uRoc, uGet4), - Form("Time distribution of GET4 Epochs on ROC%u Get4 %u; s", uRoc, uGet4), - 36000, 0., 3600.); - for( UInt_t uGet4Chan = 0; uGet4Chan < get4v10::kuNbChan; uGet4Chan++) - { - ROC[uRoc].fSelectedT[uGet4][uGet4Chan] = new TH1I( Form("Roc%u_Selected_t_%u_Ch%u",uRoc, uGet4, uGet4Chan), - Form("Time distribution of selected hits on ROC%u Get4 %u Channel %u; s", uRoc, uGet4, uGet4Chan), - 36000, 0., 3600.); - - ROC[uRoc].fTrigger_Get4Channel[uGet4][uGet4Chan] = - new TH1I( Form("Roc%u_Get%u_Ch%u_Trigger", - uRoc, uGet4, uGet4Chan), - Form("Time difference between all hits on GET4 %u Channel %u and last trigger signal on ROC%u; [ns]", - uGet4, uGet4Chan, uRoc), - 10000, -5000., 5000.); - ROC[uRoc].fTriggerMs_Get4Channel[uGet4][uGet4Chan] = - new TH1I( Form("Roc%u_Get%u_Ch%u_TriggerMs", - uRoc, uGet4, uGet4Chan), - Form("Time difference between all hits on GET4 %u Channel %u and last trigger signal on ROC%u; [ns]", - uGet4, uGet4Chan, uRoc), - 20000, -100*1e3, 100*1e3); - ROC[uRoc].fTriggerS_Get4Channel[uGet4][uGet4Chan] = - new TH1I( Form("Roc%u_Get%u_Ch%u_TriggerS", - uRoc, uGet4, uGet4Chan), - Form("Time difference between all hits on GET4 %u Channel %u and last trigger signal on ROC%u; [ns]", - uGet4, uGet4Chan, uRoc), - 20000, -100*1e9, 1900*1e9); - - /* - * Debug Histograms for GET4 v1.x - */ - if( 1 == fParam->bTotHistoEnable ) - ROC[uRoc].fTot[uGet4][uGet4Chan] = - new TH1I( Form("Roc%u_Get%u_Ch%u_Tot", - uRoc, uGet4, uGet4Chan), - Form("Tot for channel %u in chip %u on ROC %u;Tot [ps];Counts [1]", uGet4Chan, uGet4, uRoc), - 1200, -25, 59975 ); - if( 1 == fParam->bDebugHistoEnable ) - { - // Change Name to make it compatible with calibration step - ROC[uRoc].fLeadingFTS[uGet4][uGet4Chan] = -// new TH1I( Form("Roc%u_Get%d_Ch%d_FTS_Leading", -// uRoc, uGet4, uGet4Chan), - new TH1I( Form("tof_%s_ft_b%03u_ch%03u", - toftdc::ksTdcHistName[ toftdc::get4 ].Data(), - uGet4, 2*uGet4Chan + 1), - Form("FTS of Leading edge of channel %u in chip %u on ROC %u", - uGet4Chan, uGet4, uRoc), - get4tdc::kiFineTime, 0., get4tdc::kiFineTime); - // Change Name to make it compatible with calibration step - ROC[uRoc].fTrailingFTS[uGet4][uGet4Chan] = -// new TH1I( Form("Roc%u_Get%d_Ch%d_FTS_Trailing", -// uRoc, uGet4, uGet4Chan), - new TH1I( Form("tof_%s_ft_b%03u_ch%03u", - toftdc::ksTdcHistName[ toftdc::get4 ].Data(), - uGet4, 2*uGet4Chan), - Form("FTS of Trailing edge of channel %u in chip %u on ROC %u", - uGet4Chan, uGet4, uRoc), - get4tdc::kiFineTime, 0., get4tdc::kiFineTime); - ROC[uRoc].fLeadingDnl[uGet4][uGet4Chan] = - new TH1D( Form("Roc%u_Get%u_Ch%u_Dnl_Leading", - uRoc, uGet4, uGet4Chan), - Form("DNL of Leading edge of channel %u in chip %u on ROC %u", - uGet4Chan, uGet4, uRoc), - get4tdc::kiFineTime, -0.5, get4tdc::kiFineTime-0.5); - ROC[uRoc].fLeadingDnlSum[uGet4][uGet4Chan] = - new TH1D( Form("Roc%u_Get%u_Ch%u_DnlSum_Leading", - uRoc, uGet4, uGet4Chan), - Form("DNL Integral of Leading edge of channel %u in chip %u on ROC %u", - uGet4Chan, uGet4, uRoc), - get4tdc::kiFineTime, -0.5, get4tdc::kiFineTime-0.5); - ROC[uRoc].fTrailingDnl[uGet4][uGet4Chan] = - new TH1D( Form("Roc%u_Get%u_Ch%u_Dnl_Trailing", - uRoc, uGet4, uGet4Chan), - Form("DNL of Trailing edge of channel %u in chip %u on ROC %u", - uGet4Chan, uGet4, uRoc), - get4tdc::kiFineTime, -0.5, get4tdc::kiFineTime-0.5); - ROC[uRoc].fTrailingDnlSum[uGet4][uGet4Chan] = - new TH1D( Form("Roc%u_Get%u_Ch%u_DnlSum_Trailing", - uRoc, uGet4, uGet4Chan), - Form("DNL Integral of Trailing edge of channel %u in chip %u on ROC %u", - uGet4Chan, uGet4, uRoc), - get4tdc::kiFineTime, -0.5, get4tdc::kiFineTime-0.5); - } // if( 1 == fParam->bDebugHistoEnable ) - - // Event statistics - if( kTRUE == fParam->bChannelRateHistoEnable ) - ROC[uRoc].fChannelRateEvolution[uGet4][uGet4Chan] = new TH1I( - Form("Roc%u_Get%u_Ch%u_RateEvolution", - uRoc, uGet4, uGet4Chan), - Form("Time distribution of hits of channel %u in chip %u on ROC %u; Time [s]; (Nb hits)/(bin size in s) []", - uGet4Chan, uGet4, uRoc), - 36000, 0., 7200.); - - } // for( UInt_t uGet4Chan = 0; uGet4Chan < get4v10::kuNbChan; uGet4Chan++) - - // Event statistics - if( kTRUE == fParam->bChipRateHistoEnable ) - { - ROC[uRoc].fChipRateEvolution[uGet4] = new TH1I( - Form("Roc%u_Get%u_RateEvolution", - uRoc, uGet4 ), - Form("Time distribution of hits for all channels of chip %u on ROC %u; Time [s]; (Nb hits)/(bin size in s) []", - uGet4, uRoc), - 36000, 0., 7200.); - ROC[uRoc].fdRateEvolutionBinSize = ROC[uRoc].fChipRateEvolution[uGet4]->GetBinWidth( 1 ); - } // if( kTRUE == fParam->bChipRateHistoEnable ) - ROC[uRoc].fuNbHitsChipEpoch[uGet4] = 0; - - // Epochs - ROC[uRoc].fEpochShiftsDuration[uGet4] = new TH2I( Form("Roc%u_Get%u_EpochShiftsDuration", - uRoc, uGet4 ), - Form("Time distribution of hits for all channels of chip %u on ROC %u; Shift [GET4 epochs]; Duration [GET4 epochs]", - uGet4, uRoc), - 52, -26., 26., - 5000, 0., 5000.); - } // if remapped chip is valid and active - } // for( UInt_t uGet4 = 0; uGet4 < get4v10::kuMaxGet4Roc; uGet4++) - ROC[uRoc].fDistribEpochs = new TH1I( Form("Roc%u_DistribEpochs", uRoc), - "Distribution of epoch counter value for 250MHz epoch messages; Value of Local Epoch Cnt []; Counts []", - get4v10::kulMainEpochCycleSz/100000, 0, get4v10::kulMainEpochCycleSz ); - ROC[uRoc].fDistribEpochs2 = new TH2I( Form("Roc%u_DistribEpochs2", uRoc), - "Distribution of epoch counter value for Roc epoch messages; chip []; Value of Roc Epoch Cnt []; Counts []", - get4v10::kuMaxGet4Roc, -0.5, get4v10::kuMaxGet4Roc -0.5, - get4v10::kulGet4EpochCycleSz/100000, 0, get4v10::kulGet4EpochCycleSz ); - ROC[uRoc].fEpochShiftsPerChip = new TH2I( Form("Roc%u_EpochShiftsPerChip", uRoc), - "Value of shift in Epochs when non consecutive epoch index are detected, per chip; chip []; Epoch indec Shift in GET4 epochs []; Counts []", - get4v10::kuMaxGet4Roc, -0.5, get4v10::kuMaxGet4Roc -0.5, - 512, -256, 256 ); - ROC[uRoc].fEpochShiftsDurationPerChip = new TH2I( Form("Roc%u_EpochShiftsDurationPerChip", uRoc ), - Form("Duration of epoch shifts for all chips on ROC %d; chip []; Duration [GET4 epochs]", uRoc), - get4v10::kuMaxGet4Roc, -0.5, get4v10::kuMaxGet4Roc -0.5, - 5000, 0., 5000.); - - ROC[uRoc].fNbEventsPerMbsEvent = new TH1I( Form("Roc%u_EventsCount", uRoc), - "Nb of detected events per Mbs event; # Events []; Counts []", - 50, 0, 50 ); - ROC[uRoc].fNbNotEmptyEventsPerMbsEvent = new TH1I( Form("Roc%u_NotEmptyEvtCount", uRoc), - "Nb of detected events per Mbs event; # Events []; Counts []", - 50, 0, 50 ); - ROC[uRoc].fChannelsMapping = new TH2I( Form("Roc%u_ChanMap", uRoc), - "Events with both channels present; 1st channel []; 2nd channel []; Counts []", - get4v10::kuNbChan*get4v10::kuMaxGet4Roc, 0, get4v10::kuMaxGet4Roc , - get4v10::kuNbChan*get4v10::kuMaxGet4Roc, 0, get4v10::kuMaxGet4Roc ); - ROC[uRoc].fChannelMultiplicity = new TH2I( Form("Roc%u_ChanMul", uRoc), - "Channel multiplicity per event; Channel []; # Hits []; events []", - get4v10::kuNbChan*get4v10::kuMaxGet4Roc, 0, get4v10::kuMaxGet4Roc , - 20, 0, 20 ); - - if( kTRUE == fParam->bFreeStreaming && 0 < fParam->uNbTriggers ) - { - ROC[uRoc].fDataSelfTriggerPerEvent = new TH2I( Form("Roc%u_DataSelfTrigg", uRoc), - "Channel multiplicity per event; # Triggers/event []; Trigger index[]; events []", - 50, 0, 50 , - fParam->uNbTriggers, 0, fParam->uNbTriggers ); - - ROC[uRoc].fDataSelfTrigDistanceNs = new TH2I( Form("Roc%u_DataTrigDistanceNs", uRoc), - "Time difference since last trigger from data ROC; [ns]; Trigger index[]; events []", - 1002, -2., 1000., - fParam->uNbTriggers, 0, fParam->uNbTriggers ); - ROC[uRoc].fDataSelfTrigDistanceUs = new TH2I( Form("Roc%u_DataTrigDistanceUs", uRoc), - "Time difference since last trigger from data ROC; [us]; Trigger index[]; events []", - 999, 1., 1000., - fParam->uNbTriggers, 0, fParam->uNbTriggers ); - ROC[uRoc].fDataSelfTrigDistanceMs = new TH2I( Form("Roc%u_DataTrigDistanceMs", uRoc), - "Time difference since last trigger from data ROC; [ms]; Trigger index[]; events []", - 999, 1., 1000., - fParam->uNbTriggers, 0, fParam->uNbTriggers ); - ROC[uRoc].fDataSelfTrigDistanceS = new TH2I( Form("sRoc%u_DataTrigDistanceS", uRoc), - "Time difference since last trigger from data ROC; [s]; Trigger index[]; events []", - 999, 1., 1000., - fParam->uNbTriggers, 0, fParam->uNbTriggers); - } - - // Error messages - ROC[uRoc].fGet4ErrorChip = new TH1I( Form("Roc%u_Get4ErrorChip", uRoc), - "Get4 chip sending Error message; Error Chip; Entries [1]", - fParam->uNbGet4, -0.5, fParam->uNbGet4 -0.5); - ROC[uRoc].fGet4ErrorChan = new TH2I( Form("Roc%u_Get4ErrorChan", uRoc), - "Get4 channel/edge sending Error message; Error chan;;Entries [1]", - 2*(fParam->uNbGet4)*get4v10::kuNbChan, 0., (fParam->uNbGet4)*get4v10::kuNbChan, - 6, 0, 6 ); - - ROC[uRoc].fGet4ErrorChan->GetYaxis()->SetBinLabel(1, "0x04: FIFO Write "); - ROC[uRoc].fGet4ErrorChan->GetYaxis()->SetBinLabel(2, "0x05: Lost event "); - ROC[uRoc].fGet4ErrorChan->GetYaxis()->SetBinLabel(3, "0x06: Channel state "); - ROC[uRoc].fGet4ErrorChan->GetYaxis()->SetBinLabel(4, "0x11: Overwrite "); - ROC[uRoc].fGet4ErrorChan->GetYaxis()->SetBinLabel(5, "0x12: ToT out of range"); - - ROC[uRoc].fGet4ErrorPatt = new TH2I( Form("Roc%u_Get4ErrorPatt", uRoc), - "Pattern of Get4 Error message;Error chip;;Entries [1]", - fParam->uNbGet4, -0.5, fParam->uNbGet4 -0.5, 128, 0., 128); - ROC[uRoc].fGet4ErrorPatt->GetYaxis()->SetBinLabel(1, "0x00: Readout Init "); - ROC[uRoc].fGet4ErrorPatt->GetYaxis()->SetBinLabel(2, "0x01: Sync "); - ROC[uRoc].fGet4ErrorPatt->GetYaxis()->SetBinLabel(3, "0x02: Epoch count sync"); - ROC[uRoc].fGet4ErrorPatt->GetYaxis()->SetBinLabel(4, "0x03: Epoch "); - ROC[uRoc].fGet4ErrorPatt->GetYaxis()->SetBinLabel(5, "0x04: FIFO Write "); - ROC[uRoc].fGet4ErrorPatt->GetYaxis()->SetBinLabel(6, "0x05: Lost event "); - ROC[uRoc].fGet4ErrorPatt->GetYaxis()->SetBinLabel(7, "0x06: Channel state "); - ROC[uRoc].fGet4ErrorPatt->GetYaxis()->SetBinLabel(8, "0x07: Token Ring state"); - ROC[uRoc].fGet4ErrorPatt->GetYaxis()->SetBinLabel(9, "0x08: Token "); - ROC[uRoc].fGet4ErrorPatt->GetYaxis()->SetBinLabel(10, "0x09: Error Readout "); - ROC[uRoc].fGet4ErrorPatt->GetYaxis()->SetBinLabel(11, "0x0a: SPI "); - ROC[uRoc].fGet4ErrorPatt->GetYaxis()->SetBinLabel(12, "0x0b: DLL Lock error "); // <- From GET4 v1.2 - ROC[uRoc].fGet4ErrorPatt->GetYaxis()->SetBinLabel(13, "0x0c: DLL Reset invok."); // <- From GET4 v1.2 -// ROC[uRoc].fGet4ErrorPatt->GetYaxis()->SetBinLabel(14, "0x0d: "); -// ROC[uRoc].fGet4ErrorPatt->GetYaxis()->SetBinLabel(15, "0x0e: "); -// ROC[uRoc].fGet4ErrorPatt->GetYaxis()->SetBinLabel(16, "0x0f: "); -// ROC[uRoc].fGet4ErrorPatt->GetYaxis()->SetBinLabel(17, "0x10: "); - ROC[uRoc].fGet4ErrorPatt->GetYaxis()->SetBinLabel(18, "0x11: Overwrite "); - ROC[uRoc].fGet4ErrorPatt->GetYaxis()->SetBinLabel(19, "0x12: ToT out of range"); - ROC[uRoc].fGet4ErrorPatt->GetYaxis()->SetBinLabel(20, "0x13: Event Discarded "); - ROC[uRoc].fGet4ErrorPatt->GetYaxis()->SetBinLabel(128, "0x7f: Unknown "); - - /* - * Debug Histograms for GET4 v1.x - */ - if( 1 == fParam->bDebugHistoEnable ) - { - UInt_t uHistosIndexSingleChip = 0; - UInt_t uHistosIndexChipVsChip = 0; - for(UInt_t uFirstGet4Channel = 0; uFirstGet4Channel < get4v10::kuNbChan; uFirstGet4Channel++) - { - for(UInt_t uSecondGet4Channel = 0; uSecondGet4Channel < get4v10::kuNbChan; uSecondGet4Channel++) - { - if( uFirstGet4Channel < uSecondGet4Channel ) - { - ROC[uRoc].fTimeDiffInsideChip[0][uHistosIndexSingleChip] = - new TH1I( Form("Roc%d_TimeDiff1_%d_%d", - uRoc, uFirstGet4Channel, uSecondGet4Channel), - Form("Time difference between channel %d and %d in chip %d ROC %d; dT [ps]; Counts [1]", - uFirstGet4Channel, uSecondGet4Channel, fParam->uGet4TimeDiffChip1, uRoc), - 601, -15025, 15025 ); - ROC[uRoc].fTimeDiffInsideChip[1][uHistosIndexSingleChip] = - new TH1I( Form("Roc%d_TimeDiff2_%d_%d", - uRoc, uFirstGet4Channel, uSecondGet4Channel), - Form("Time difference between channel %d and %d in chip %d ROC %d; dT [ps]; Counts [1]", - uFirstGet4Channel, uSecondGet4Channel, fParam->uGet4TimeDiffChip2, uRoc), - 601, -15025, 15025 ); - - // 1D FineTime correlation - ROC[uRoc].fFTCorrel[0][uHistosIndexSingleChip] = - new TH1I( Form("Roc%d_FTCorrel1_%d_%d", - uRoc, uFirstGet4Channel, uSecondGet4Channel), - Form("FTS Correlation between channels %d and %d in chip %d ROC %d", - uFirstGet4Channel, uSecondGet4Channel, fParam->uGet4TimeDiffChip1, uRoc), - 2*get4tdc::kiFineTime + 1, -get4tdc::kiFineTime-0.5, get4tdc::kiFineTime+0.5); - ROC[uRoc].fFTCorrel[1][uHistosIndexSingleChip] = - new TH1I( Form("Roc%d_FTCorrel2_%d_%d", - uRoc, uFirstGet4Channel, uSecondGet4Channel), - Form("FTS Correlation between channels %d and %d in chip %d ROC %d", - uFirstGet4Channel, uSecondGet4Channel, fParam->uGet4TimeDiffChip2, uRoc), - 2*get4tdc::kiFineTime + 1, -get4tdc::kiFineTime-0.5, get4tdc::kiFineTime+0.5); - - // 2D FineTime correlation - ROC[uRoc].fFTCorrel2D[0][uHistosIndexSingleChip] = - new TH2I( Form("Roc%d_2dFTCorr1_%d_%d", - uRoc, uFirstGet4Channel, uSecondGet4Channel), - Form("FTS Correlation between channels %d and %d in chip %d ROC %d", - uFirstGet4Channel, uSecondGet4Channel, fParam->uGet4TimeDiffChip1, uRoc), - get4tdc::kiFineTime, -0.5, get4tdc::kiFineTime-0.5, - get4tdc::kiFineTime, -0.5, get4tdc::kiFineTime-0.5); - ROC[uRoc].fFTCorrel2D[1][uHistosIndexSingleChip] = - new TH2I( Form("Roc%d_2dFTCorr2_%d_%d", - uRoc, uFirstGet4Channel, uSecondGet4Channel), - Form("FTS Correlation between channels %d and %d in chip %d ROC %d", - uFirstGet4Channel, uSecondGet4Channel, fParam->uGet4TimeDiffChip2, uRoc), - get4tdc::kiFineTime, -0.5, get4tdc::kiFineTime-0.5, - get4tdc::kiFineTime, -0.5, get4tdc::kiFineTime-0.5); - - uHistosIndexSingleChip++; - } // if( uFirstGet4Channel < uSecondGet4Channel ) - ROC[uRoc].fTimeDiffBetweenChips[uHistosIndexChipVsChip] = - new TH1I( Form("Roc%d_dT_%d_%d_Vs_%d_%d", - uRoc, - fParam->uGet4TimeDiffChip1, uFirstGet4Channel, - fParam->uGet4TimeDiffChip2, uSecondGet4Channel), - Form("Time difference between channel %d in chip %d and channel %d in chip %d; dT [ps]; Counts [1]", - uFirstGet4Channel, fParam->uGet4TimeDiffChip1, uSecondGet4Channel, fParam->uGet4TimeDiffChip2), - 961, -24025, 24025 ); - ROC[uRoc].fFTCorrelChipToChip[uHistosIndexChipVsChip] = - new TH1I( Form("Roc%d_FTCorrel_%d_%d_Vs_%d_%d", - uRoc, - fParam->uGet4TimeDiffChip1, uFirstGet4Channel, - fParam->uGet4TimeDiffChip2, uSecondGet4Channel), - Form("FTS Correlation between channel %d in chip %d and channel %d in chip %d", - uFirstGet4Channel, fParam->uGet4TimeDiffChip1, uSecondGet4Channel, fParam->uGet4TimeDiffChip2), - 2*get4tdc::kiFineTime + 1, -get4tdc::kiFineTime-0.5, get4tdc::kiFineTime+0.5); - uHistosIndexChipVsChip++; - } // for(UInt_t uSecondGet4Channel = 0; uSecondGet4Channel < MAX_GET4_CH; uSecondGet4Channel++) - } // for(UInt_t uFirstGet4Channel = 0; uFirstGet4Channel < MAX_GET4_CH; uFirstGet4Channel++) - } // if( 1 == fParam->bDebugHistoEnable ) - } // for( UInt_t uRoc =0; uRoc<fParam->numRocs; uRoc++ ) - - gDirectory->cd( oldir->GetPath() ); // <= To prevent histos from being sucked in by the param file of the TRootManager! - - return kTRUE; -} -void TTofGet4Unpacker::FillHistos() -{ - // Most Histos are filled inside processing functions - - // Fill histos which were normally filled in Finish function - for( UInt_t uRocTempId =0; uRocTempId < fParam->numRocs; uRocTempId++ ) - { - ROC[uRocTempId].fNbEventsPerMbsEvent->Fill(uEventInsideMbsEvtCount[uRocTempId]); - ROC[uRocTempId].fNbNotEmptyEventsPerMbsEvent->Fill(uNotEmptyEventInsideMbsEvtCount[uRocTempId]); - uEventInsideMbsEvtCount[uRocTempId] = 0; - uNotEmptyEventInsideMbsEvtCount[uRocTempId] = 0; - - if( kTRUE == fParam->bFreeStreaming && 0 < fParam->uNbTriggers ) - for( UInt_t uTrigger = 0; uTrigger < fParam->uNbTriggers; uTrigger++) - { - ROC[uRocTempId].fDataSelfTriggerPerEvent->Fill( ROC[uRocTempId].fuDataSelfTriggerCount[uTrigger], - uTrigger ); - ROC[uRocTempId].fuDataSelfTriggerCount[uTrigger] = 0; - } // for( UInt_t uTrigger = 0; uTrigger < fParam->uNbTriggers; uTrigger++) - } // for( UInt_t uRocTempId =0; uRocTempId < fParam->numRocs; uRocTempId++ ) -} -void TTofGet4Unpacker::WriteHistos( TDirectory* inDir) -{ - TDirectory * oldir = gDirectory; - - // ROCS and base Dir - TDirectory *cdAllRocs; - TDirectory *cdRoc[fParam->numRocs]; - TDirectory *cdRocLong[fParam->numRocs]; - - // GET4 - TDirectory *cdRocGet4[fParam->numRocs][get4v10::kuMaxGet4Roc]; - TDirectory *cdRocGet4FtL[fParam->numRocs][get4v10::kuMaxGet4Roc]; - TDirectory *cdRocGet4FtT[fParam->numRocs][get4v10::kuMaxGet4Roc]; - TDirectory *cdRocGet4Rate[fParam->numRocs][get4v10::kuMaxGet4Roc]; - - // DEBUG - TDirectory *cdRocDebug[fParam->numRocs]; - TDirectory *cdRocDebugChip1[fParam->numRocs]; - TDirectory *cdRocDebugChip2[fParam->numRocs]; - TDirectory *cdRocDebugCvsC[fParam->numRocs]; - - // All Sub-Events histo - fEvtPerProc->Write(); - - // All ROCs histos - cdAllRocs = inDir->mkdir( "ROCs" ); - cdAllRocs->cd(); // make the "ROCs" directory the current directory - - fEvntSize->Write(); - fMsgsPerRoc->Write(); - fTriggerPerRoc->Write(); - fDeltaTriggerTime->Write(); - - // ROC Specific histos - for( UInt_t uRoc =0; uRoc<fParam->numRocs; uRoc++ ) - { - cdRoc[uRoc] = inDir->mkdir( Form("ROC%02u",uRoc) ); - cdRoc[uRoc]->cd(); // make the "ROCXX" directory the current directory - - ROC[uRoc].fMsgTypes->Write(); - ROC[uRoc].fSysTypes->Write(); - ROC[uRoc].fSysUserTypes->Write(); - ROC[uRoc].fAUXch->Write(); - - ROC[uRoc].fTrigger_All->Write(); - ROC[uRoc].fTrigger_All_100->Write(); - ROC[uRoc].fTrigger_All_us->Write(); - ROC[uRoc].fTrigger_All_ms->Write(); - ROC[uRoc].fTrigger_All_s->Write(); - - ROC[uRoc].fTrigger_AUX->Write(); - - ROC[uRoc].fEvntMultipl->Write(); - - ROC[uRoc].fALLt->Write(); - ROC[uRoc].fDATAt->Write(); - ROC[uRoc].fERRORt->Write(); - ROC[uRoc].fSLOWCt->Write(); - ROC[uRoc].fSelfTriggT->Write(); - ROC[uRoc].fEPOCHt->Write(); - ROC[uRoc].fAllSelectedT->Write(); - - for (unsigned nsync=0; nsync<get4v10::kuMaxSync; nsync++) - ROC[uRoc].fSYNCt[nsync]->Write(); - - for (unsigned naux=0; naux<get4v10::kuMaxAux; naux++) - ROC[uRoc].fAUXt[naux]->Write(); - - // Long duration time distribution (1 min. bin, 10 days length) - if( kTRUE == fParam->bLongTimeHistos ) - { - cdRocLong[uRoc] = cdRoc[uRoc]->mkdir( "Long" ); - cdRocLong[uRoc]->cd(); // make the "ROCXX/Long" directory the current directory - - ROC[uRoc].fAllLongT->Write(); - ROC[uRoc].fDataLongT->Write(); - ROC[uRoc].fErrorLongT->Write(); - ROC[uRoc].fSlowCLongT->Write(); - ROC[uRoc].fSelfTriggLongT->Write(); - ROC[uRoc].fEpochLongT->Write(); - ROC[uRoc].fAllEpoch2LongT->Write(); - ROC[uRoc].fAllSelLongT->Write(); - - for (unsigned nsync=0; nsync<get4v10::kuMaxSync; nsync++) - ROC[uRoc].fSyncLongT[nsync]->Write(); - } // if( kTRUE == fParam->bLongTimeHistos ) - - for( UInt_t uGet4 = 0; uGet4 < get4v10::kuMaxGet4Roc; uGet4++) - { - UInt_t uRemappedGet4Index = fParam->RemapGet4Chip(uRoc, uGet4); - - if( kTRUE == fParam->IsValidGet4Chip(uRemappedGet4Index) && - kTRUE == fParam->IsActiveGet4Chip(uRemappedGet4Index) ) - { - cdRocGet4[uRoc][uGet4] = cdRoc[uRoc]->mkdir( Form("Get4_%u", uGet4) ); - cdRocGet4[uRoc][uGet4]->cd(); // make the "ROCXX/Get4_YY" directory the current directory - if( 1 == fParam->bDebugHistoEnable ) - { - cdRocGet4FtL[uRoc][uGet4] = cdRocGet4[uRoc][uGet4]->mkdir( "FTS_L" ); - cdRocGet4FtT[uRoc][uGet4] = cdRocGet4[uRoc][uGet4]->mkdir( "FTS_T" ); - } // if( 1 == fParam->bDebugHistoEnable ) - if( kTRUE == fParam->bChannelRateHistoEnable ) - cdRocGet4Rate[uRoc][uGet4] = cdRocGet4[uRoc][uGet4]->mkdir( "RateCh" ); - - ROC[uRoc].fEPOCH2t[uGet4]->Write(); - for( UInt_t uGet4Chan = 0; uGet4Chan < get4v10::kuNbChan; uGet4Chan++) - { - ROC[uRoc].fSelectedT[uGet4][uGet4Chan]->Write(); - - ROC[uRoc].fTrigger_Get4Channel[uGet4][uGet4Chan]->Write(); - ROC[uRoc].fTriggerMs_Get4Channel[uGet4][uGet4Chan]->Write(); - ROC[uRoc].fTriggerS_Get4Channel[uGet4][uGet4Chan]->Write(); - - /* - * Debug Histograms for GET4 v1.x - */ - if( 1 == fParam->bTotHistoEnable ) - ROC[uRoc].fTot[uGet4][uGet4Chan]->Write(); - if( 1 == fParam->bDebugHistoEnable ) - { - cdRocGet4FtL[uRoc][uGet4]->cd(); // make the "ROCXX/Get4_YY/FTS_L" directory the current directory - - ROC[uRoc].fLeadingFTS[uGet4][uGet4Chan]->Write(); - ROC[uRoc].fLeadingDnl[uGet4][uGet4Chan]->Write(); - ROC[uRoc].fLeadingDnlSum[uGet4][uGet4Chan]->Write(); - - cdRocGet4FtT[uRoc][uGet4]->cd(); // make the "ROCXX/Get4_YY/FTS_T" directory the current directory - - ROC[uRoc].fTrailingFTS[uGet4][uGet4Chan]->Write(); - ROC[uRoc].fTrailingDnl[uGet4][uGet4Chan]->Write(); - ROC[uRoc].fTrailingDnlSum[uGet4][uGet4Chan]->Write(); - } // if( 1 == fParam->bDebugHistoEnable ) - - // Event statistics - if( kTRUE == fParam->bChannelRateHistoEnable ) - { - cdRocGet4Rate[uRoc][uGet4]->cd(); // make the "ROCXX/Get4_YY/RateCh" directory the current directory - ROC[uRoc].fChannelRateEvolution[uGet4][uGet4Chan]->Write(); - } // if( kTRUE == fParam->bChannelRateHistoEnable ) - - } // for( UInt_t uGet4Chan = 0; uGet4Chan < get4v10::kuNbChan; uGet4Chan++) - - cdRocGet4[uRoc][uGet4]->cd(); // make the "ROCXX/Get4_YY" directory the current directory - // Event statistics - if( kTRUE == fParam->bChipRateHistoEnable ) - ROC[uRoc].fChipRateEvolution[uGet4]->Write(); - - // Epochs - ROC[uRoc].fEpochShiftsDuration[uGet4]->Write(); - } // if remapped chip is valid and active - } // for( UInt_t uGet4 = 0; uGet4 < get4v10::kuMaxGet4Roc; uGet4++) - - cdRoc[uRoc]->cd(); // make the "ROCXX" directory the current directory - ROC[uRoc].fDistribEpochs->Write(); - ROC[uRoc].fDistribEpochs2->Write(); - ROC[uRoc].fEpochShiftsPerChip->Write(); - ROC[uRoc].fEpochShiftsDurationPerChip->Write(); - - ROC[uRoc].fNbEventsPerMbsEvent->Write(); - ROC[uRoc].fNbNotEmptyEventsPerMbsEvent->Write(); - ROC[uRoc].fChannelsMapping->Write(); - ROC[uRoc].fChannelMultiplicity->Write(); - - if( kTRUE == fParam->bFreeStreaming && 0 < fParam->uNbTriggers ) - { - ROC[uRoc].fDataSelfTriggerPerEvent->Write(); - - ROC[uRoc].fDataSelfTrigDistanceNs->Write(); - ROC[uRoc].fDataSelfTrigDistanceUs->Write(); - ROC[uRoc].fDataSelfTrigDistanceMs->Write(); - ROC[uRoc].fDataSelfTrigDistanceS->Write(); - } - - // Error messages - ROC[uRoc].fGet4ErrorChip->Write(); - ROC[uRoc].fGet4ErrorChan->Write(); - - ROC[uRoc].fGet4ErrorPatt->Write(); - - /* - * Debug Histograms for GET4 v1.x - */ - if( 1 == fParam->bDebugHistoEnable ) - { - cdRocDebug[uRoc] = cdRoc[uRoc]->mkdir( "Debug" ); - cdRocDebug[uRoc]->cd(); // make the "ROCXX/Debug" directory the current directory - cdRocDebugChip1[uRoc] = cdRocDebug[uRoc]->mkdir( "Chip1" ); - cdRocDebugChip2[uRoc] = cdRocDebug[uRoc]->mkdir( "Chip2" ); - cdRocDebugCvsC[uRoc] = cdRocDebug[uRoc]->mkdir( "ChipVsChip" ); - - UInt_t uHistosIndexSingleChip = 0; - UInt_t uHistosIndexChipVsChip = 0; - for(UInt_t uFirstGet4Channel = 0; uFirstGet4Channel < get4v10::kuNbChan; uFirstGet4Channel++) - { - for(UInt_t uSecondGet4Channel = 0; uSecondGet4Channel < get4v10::kuNbChan; uSecondGet4Channel++) - { - if( uFirstGet4Channel < uSecondGet4Channel ) - { - cdRocDebugChip1[uRoc]->cd(); // make the "ROCXX/Debug/Chip1" directory the current directory - ROC[uRoc].fTimeDiffInsideChip[0][uHistosIndexSingleChip]->Write(); - // 1D FineTime correlation - ROC[uRoc].fFTCorrel[0][uHistosIndexSingleChip]->Write(); - // 2D FineTime correlation - ROC[uRoc].fFTCorrel2D[0][uHistosIndexSingleChip]->Write(); - - cdRocDebugChip2[uRoc]->cd(); // make the "ROCXX/Debug/Chip2" directory the current directory - ROC[uRoc].fTimeDiffInsideChip[1][uHistosIndexSingleChip]->Write(); - // 1D FineTime correlation - ROC[uRoc].fFTCorrel[1][uHistosIndexSingleChip]->Write(); - // 2D FineTime correlation - ROC[uRoc].fFTCorrel2D[1][uHistosIndexSingleChip]->Write(); - - uHistosIndexSingleChip++; - } // if( uFirstGet4Channel < uSecondGet4Channel ) - - cdRocDebugCvsC[uRoc]->cd(); // make the "ROCXX/Debug/ChipVsChip" directory the current directory - ROC[uRoc].fTimeDiffBetweenChips[uHistosIndexChipVsChip]->Write(); - ROC[uRoc].fFTCorrelChipToChip[uHistosIndexChipVsChip]->Write(); - - uHistosIndexChipVsChip++; - } // for(UInt_t uSecondGet4Channel = 0; uSecondGet4Channel < get4v10::kuNbChan; uSecondGet4Channel++) - } // for(UInt_t uFirstGet4Channel = 0; uFirstGet4Channel < get4v10::kuNbChan; uFirstGet4Channel++) - } // if( 1 == fParam->bDebugHistoEnable ) - } // for( UInt_t uRoc =0; uRoc<fParam->numRocs; uRoc++ ) - - oldir->cd(); -} -void TTofGet4Unpacker::DeleteHistos() -{ - /* - fh1VftxRawChMap.clear(); - for( Int_t iBoardIndex = 0; iBoardIndex < fuNbTdc; iBoardIndex++) - (fh1VftxChFt[iBoardIndex]).clear(); - fh1VftxChFt.clear(); - */ -} - -/*********************************************************************************/ -/****************** Internal Functions *******************************************/ - -void TTofGet4Unpacker::ProcessTriggerMessage(UInt_t uRocId, TGet4v1MessageExtended& extMess, - Int_t iTriggerIndex) -{ - /* TODO FILL ME - * Trigger processing - */ - - /* - * Check if current event already got a trigger - */ - if( kTRUE == fCurrentGet4Event.HasTrigger() ) - { - Double_t dLastTriggerDistance = - extMess.GetFullTimeD() - - fCurrentGet4Event.fdTriggerFullTime[uRocId] ; - - /* - * If incoming trigger has lower priority than current trigger or if - * current trigger was a SYNC trigger and a data trigger comes - * And it is inside the deatime window - * => Ignore incoming trigger - */ - if( dLastTriggerDistance <= fParam->dDeadTime && - iTriggerIndex < (Int_t)(fCurrentGet4Event.fuTriggerIndex) ) - return; - /* - * If incoming trigger has higher priority than current trigger or if - * current trigger was a SYNC trigger and a data trigger comes - * And it is inside the deatime window - * => erase current event, start new event using incoming trigger - */ - else if( dLastTriggerDistance <= fParam->dDeadTime && - iTriggerIndex > (Int_t)(fCurrentGet4Event.fuTriggerIndex) ) - { - fCurrentGet4Event.Clear(); - - } // else if( iTriggerIndex > (Int_t)(fCurrentGet4Event.fuTriggerIndex) ) - /* - * If incoming trigger has same priority than current trigger or if - * current trigger was a SYNC trigger and a SYNC trigger comes - * => depend on bAllowEventMixing flag and distance - * kTRUE = save the partially filled old one, start the new one => TODO MIXING!!! - * kFALSE = ignore incoming trigger - * Distance between them bigger than trigger window size => save the partially filled old one, start the new one - */ - else - { - if( fParam->dDeadTime < dLastTriggerDistance || kTRUE == fParam->bAllowEventMixing) - { - /* - * TODO real event mixing or parallel buffers - */ - - // Check flag indicating the extra epoch after trigger is passed - for( UInt_t uRocTempId =0; uRocTempId<fParam->numRocs; uRocTempId++ ) - { - // do not check for non-used ROC - if (!fParam->IsActiveRoc(uRocTempId)) continue; - - for( UInt_t uGet4 = 0; uGet4 < get4v10::kuMaxGet4Roc; uGet4++) - { - UInt_t uRemappedGet4Index = fParam->RemapGet4Chip(uRocTempId, uGet4); - if( kFALSE == fParam->IsValidGet4Chip(uRemappedGet4Index) || - kFALSE == fParam->IsActiveGet4Chip(uRemappedGet4Index) ) - continue; - - // Finish previous event -// BuildHitsAfterTrigg( uRocTempId, uRemappedGet4Index); - - // If chip not finished to process this event, build hits from current - // buffer (safe as we anyway build hits on epoch end when necessary) - if( kFALSE == ROC[uRocTempId].fbSelectionDone[uRemappedGet4Index] ) - { - // If This is the first epoch after the trigger and - // we did not process the epoch before the one where the - // trigger came, we need to initialize the 24 bit temp hits - if( kFALSE == ROC[uRocId].fbEpoch2SinceTrigger[uRemappedGet4Index] && - kFALSE == ROC[uRocId].bLookInPreviousEpoch[uRemappedGet4Index] ) - for( UInt_t uChan = 0; uChan < get4v10::kuNbChan; uChan++) - (ROC[uRocId].fHitTemp24[uRemappedGet4Index][uChan]).Clear(); - - BuildHits(uRocTempId, uRemappedGet4Index, ROC[uRocTempId].fbBufferWithLastFullEpoch2[uRemappedGet4Index]); - ROC[uRocTempId].fbSelectionDone[uRemappedGet4Index] = kTRUE; - } - } // for( UInt_t uGet4 = 0; uGet4 < get4v10::kuMaxGet4Roc; uGet4++) - } // for( UInt_t uRocId =0; uRocId<fParam->numRocs; uRocId++ ) - - // Save previous event if not empty - if( kFALSE == fCurrentGet4Event.IsEmpty() ) - { - AnalyzeAllGet4Channels( fCurrentGet4Event ); - - // Replaced with cbmroot output format - // Only 1 event used per MBS event!! -// (fOutputEvent->fEvents).push_back( fCurrentGet4Event ); - if( kFALSE == fbDataSavedForThisEvent ) - { - // First event found in this MBS event - for( UInt_t uGet4 = 0; uGet4 < get4v10::kuMaxGet4; uGet4++) - { - TTofGet4Board * fGet4Board = (TTofGet4Board*) fGet4BoardCollection->ConstructedAt(uGet4); - if( 0 < (fCurrentGet4Event.fGet4Boards[uGet4]).Size() ) - { - fGet4Board->SetTriggerFullTime( fCurrentGet4Event.fdTriggerFullTime[0] ); // Use only first ROC!!!! - fGet4Board->SetSyncEventFlag( fCurrentGet4Event.fbMbsSyncedEvent ); - fGet4Board->SetSyncEvtNb( fCurrentGet4Event.fuSyncEventNumber ); - fGet4Board->SetDataEventFlag( fCurrentGet4Event.fbDataTriggered ); - fGet4Board->SetTriggIndx( fCurrentGet4Event.fuTriggerIndex ); - - // Some Data found for this TDC Chip - for( UInt_t uCh = 0; uCh < get4v10::kuNbChan; uCh++ ) - for( UInt_t uHit = 0; - uHit < ((fCurrentGet4Event.fGet4Boards[uGet4]).fHits[uCh]).size(); - uHit++ ) - { - TGet4v1MessageExtended extTime = ((fCurrentGet4Event.fGet4Boards[uGet4]).fHits[uCh])[uHit].GetTimeMessage(); - TGet4v1MessageExtended extTot = ((fCurrentGet4Event.fGet4Boards[uGet4]).fHits[uCh])[uHit].GetTotMessage(); - - if( kFALSE == extTime.IsEmpty() ) - { - TTofGet4Data dataTime; - dataTime.Set32bFlag( extTime.Is32Bit() ); - - dataTime.SetEdge( 0 ); - if( kTRUE == extTime.Is32Bit() ) - { - dataTime.SetChannel( uCh ); - dataTime.SetFineTime( extTime.getGet4V10R32HitFt() ); - dataTime.SetCoarseTime( extTime.getGet4V10R32HitTs() ); - dataTime.SetTot( extTime.getGet4V10R32HitTot() ); - } // if( kTRUE == extTime.Is32Bit() ) - else - { - // Time saved in "odd channels" as example of VFTX - dataTime.SetChannel( 2*uCh + 1 ); - dataTime.SetFineTime( extTime.GetGet4Ts() & get4tdc::kiFineTime ); - dataTime.SetCoarseTime( (extTime.GetGet4Ts() & get4tdc::kiCoarseTime )>>get4tdc::kiCtShift ); - } // else of if( kTRUE == extTime.Is32Bit() ) - dataTime.SetEpoch( extTime.GetRocEpoch() ); - dataTime.SetEpochCycle( extTime.GetRocCycle() ); - dataTime.SetFullTimeD( extTime.GetFullTimeD() ); - fGet4Board->AddData( dataTime ); - } // if( kFALSE == extTime.IsEmpty() ) - - if( kFALSE == extTot.IsEmpty() ) - { - // Will appear only in case of 24bit mode !!! - TTofGet4Data dataTot; - // Tot saved in "even channels" as example of VFTX - dataTot.SetChannel( 2*uCh ); - dataTot.SetEdge( 1 ); - dataTot.SetFineTime( extTot.GetGet4Ts() & get4tdc::kiFineTime ); - dataTot.SetCoarseTime( (extTot.GetGet4Ts() & get4tdc::kiCoarseTime )>>get4tdc::kiCtShift ); - dataTot.SetEpoch( extTot.GetRocEpoch() ); - dataTot.SetEpochCycle( extTot.GetRocCycle() ); - dataTot.SetFullTimeD( extTot.GetFullTimeD() ); - dataTot.Set32bFlag( extTot.Is32Bit() ); - fGet4Board->AddData( dataTot ); - } // if( kFALSE == extTot.IsEmpty() ) - } // scan over all hits in this board object - - } // if( 0 < (fCurrentGet4Event.fGet4Boards[uGet4]).Size() ) - } // for( UInt_t uGet4 = 0; uGet4 < get4v10::kuMaxGet4; uGet4++) - fbDataSavedForThisEvent = kTRUE; - } // if( kFALSE == fbDataSavedForThisEvent ) - /////////////////////////////////////////////// - - for( UInt_t uRocTempId =0; uRocTempId<fParam->numRocs; uRocTempId++ ) - { - // do not check for non-used ROC - if (!fParam->IsActiveRoc(uRocTempId)) continue; - - uNotEmptyEventInsideMbsEvtCount[uRocTempId]++; - uNotEmptyRealEventsCount[uRocTempId]++; - } // for( UInt_t uRocTempId =0; uRocTempId<fParam->numRocs; uRocTempId++ ) - } // if( kFALSE == fCurrentGet4Event.IsEmpty() ) - } // if( kTRUE == fParam->bAllowEventMixing) - else return; - } // else of else if( trigger > currentTrig) of if( trigger < currentTrig) - } // if( kTRUE == fCurrentGet4Event.HasTrigger() ) - - // anyway clear again for safety - fCurrentGet4Event.Clear(); - - // Assign new trigger time to current event holder - fCurrentGet4Event.fdTriggerFullTime[uRocId] = extMess.GetFullTimeD(); - if( fCurrentGet4Event.fdTriggerFullTime[uRocId] <= 0.0) - { - TString sTemp = Form("Assigning 0 time as trigger time? event %d time %f", uNbEvents[uRocId], extMess.GetFullTimeD()); - LOG(error)<<sTemp; - } // if( fCurrentGet4Event.fdTriggerFullTime[uRocId] <= 0.0) - - // Event number of the corresponding MBS event -// fCurrentGet4Event.fuMbsEventNumber = GetEventNumber(); - // Index of the real event inside MBS event - fCurrentGet4Event.fuEventNbInsideMbsEvt = uEventInsideMbsEvtCount[uRocId]; - // Total event number - fCurrentGet4Event.fuGlobalEventNumber = uRealEventsCount[uRocId]; - if( roc::MSG_SYNC == extMess.GetMessageType() ) - { - // Flag indicating that this real event is the one synchronized to MBS - fCurrentGet4Event.fbMbsSyncedEvent = kTRUE; - // Event Nmber from the sync message - fCurrentGet4Event.fuSyncEventNumber = (extMess.GetRocMessage()).getSyncData(); - } // if( roc::MSG_SYNC == extMess.GetMessageType() ) - else if( -1 < iTriggerIndex ) - { - // Flag indicating that this real event was made after finding coincidence in data - fCurrentGet4Event.fbDataTriggered = kTRUE; - // Index of the Data trigger making this event - fCurrentGet4Event.fuTriggerIndex = (UInt_t)iTriggerIndex; - } // else if( -1 < iTriggerIndex ) of if( roc::MSG_SYNC == extMess.GetMessageType() ) - uEventInsideMbsEvtCount[uRocId]++; - uRealEventsCount[uRocId]++; - - /* - * TODO: ROC self (NX/SYNC/AUX) messages bulding/checking - */ - ROC[uRocId].fbSelectionRocDone = kFALSE; - ROC[uRocId].fbEpochSinceTrigger = kFALSE; - - // Good solution is following: - // When trigger: Process PrevBuffer Epoch -1 and remove older data if no event mixing - // When current epoch finishes or when new trigger out of deadtime => process current epoch and remove older data if no event mixing - // When future epoch finishes or when new trigger out of deadtime => process future epoch (which is stored in current buffer) - for( UInt_t uGet4Index = 0; uGet4Index < fParam->uNbGet4; uGet4Index++) - if( fParam->IsActiveGet4Chip( uGet4Index ) ) - { - // Check if necessary to build hits from buffer of previous epoch - // Is the case if the trigger window begins before beginning of current epoch - Double_t dFullTimeCurrentEpoch = (((ULong64_t)ROC[uRocId].GetFullEpoch2Number(uGet4Index)) << 19); - dFullTimeCurrentEpoch = dFullTimeCurrentEpoch / 20. + 512.; - - if( extMess.GetFullTimeD() + fParam->dCoincidenceWindowStart[iTriggerIndex] < dFullTimeCurrentEpoch) - { - ROC[uRocId].bLookInPreviousEpoch[uGet4Index] = kTRUE; - for( UInt_t uChan = 0; uChan < get4v10::kuNbChan; uChan++) - (ROC[uRocId].fHitTemp24[uGet4Index][uChan]).Clear(); - Bool_t bOlderBuffer = ( kTRUE == ROC[uRocId].fbBufferWithLastFullEpoch2[uGet4Index] ? 0 : 1 ); - BuildHits(uRocId, uGet4Index, bOlderBuffer); - } // if( extMess.GetFullTimeD() + fParam->dCoincidenceWindowStart[iTriggerIndex] < dFullTimeCurrentEpoch) - else ROC[uRocId].bLookInPreviousEpoch[uGet4Index] = kFALSE; - - // Check if necessary to build hits from buffer of epoch after current one - // Is the case if the trigger window ends after the end of current epoch -// Double_t dFullTimeNextEpoch = (Double_t)get4tdc::kdEpochInPs*(Double_t)( 1.0 + ROC[uRocId].GetFullEpoch2Number(uGet4Index) )/ 1000.0; - Double_t dFullTimeNextEpoch = 1.0 + (((ULong64_t)ROC[uRocId].GetFullEpoch2Number(uGet4Index)) << 19); - dFullTimeNextEpoch = dFullTimeCurrentEpoch / 20. + 512.; - if( dFullTimeNextEpoch < extMess.GetFullTimeD() + fParam->dCoincidenceWindowStop[iTriggerIndex] ) - ROC[uRocId].bLookInNextEpoch[uGet4Index] = kTRUE; - else ROC[uRocId].bLookInNextEpoch[uGet4Index] = kFALSE; - - // Initialize the flag indicating how many epoch2 finished since this trigger came - ROC[uRocId].fbEpoch2SinceTrigger[uGet4Index] = kFALSE; - ROC[uRocId].fbSelectionDone[uGet4Index] = kFALSE; - - for(UInt_t uChanTest = 0; uChanTest < get4v10::kuNbChan; uChanTest ++) - { - ROC[uRocId].fbDataTimeOut[uGet4Index][uChanTest] = kFALSE; - ROC[uRocId].fbDataFallingOut[uGet4Index][uChanTest] = kFALSE; - } - } - return; -} - -void TTofGet4Unpacker::ProcessExtendedMessage(UInt_t uRocId, TGet4v1MessageExtended& extMess) -{ - /* TODO FILL ME - * Generic Extended message processing - * If Previous trigger done => just put in buffer - * If not done => put in buffer, build hit if possible and - * check if it does not match current trigger - */ - UInt_t uType = extMess.GetMessageType(); - - // 24 Bits data message => need to be built - if( roc::MSG_GET4 == uType ) - { - UInt_t uGet4Id = extMess.GetGet4Number() ; - - // Check if chip is activated - if( fParam->IsActiveGet4Chip(uGet4Id) ) - { - // Save message anyway in previous epochs buffer in case two triggers come close - ROC[uRocId].fPrevEpochs2Buffer[uGet4Id][ - ROC[uRocId].fbBufferWithLastFullEpoch2[uGet4Id]].push_back(extMess); - } // if( fParam->IsActiveGet4Chip(uChip) ) - } - // 32 Bits data message => already contains a full hit! - else if( roc::MSG_SYS == uType ) - { - UShort_t ucSysMesType = extMess.GetSysMesType(); // change type to avoid warning if last Chip id reach char type size - if( get4v10::SYSMSG_GET4V1_32BIT_0 <= ucSysMesType && - ucSysMesType <= get4v10::SYSMSG_GET4V1_32BIT_15 ) - { - UInt_t uGet4Id = extMess.getGet4V10R32ChipId() ; - uGet4Id = fParam->RemapGet4Chip( uRocId, uGet4Id); - - // Check if chip is activated - if( fParam->IsActiveGet4Chip(uGet4Id) ) - { - // Save message anyway in previous epochs buffer in case two triggers come close - ROC[uRocId].fPrevEpochs2Buffer[uGet4Id][ - ROC[uRocId].fbBufferWithLastFullEpoch2[uGet4Id]].push_back(extMess); - } // if( fParam->IsActiveGet4Chip(uChip) ) - } - else - { - cout<<"Rejected message because type not recognised in ProcessExtendedMessage"<<endl; - }// else of else if( Get4 32 bits) of if( Get4 24 bits ) - } // else if( Get4 32 bits) of if( Get4 24 bits ) - // Other ROC data messages => Saved in their own vector for each event if needed - else - { - cout<<"Rejected message because type not recognised in ProcessExtendedMessage"<<endl; - }// else of else if( Get4 32 bits) of if( Get4 24 bits ) -} -/**********************************************************************/ -Bool_t TTofGet4Unpacker::BuildHits(UInt_t uRocId, UInt_t uGet4Id, Bool_t bBufferToBuild) -{ - /* - * 32 bit hit building from all raw message => easy => done - * 24bit hit building from all raw edges messages - * -> Check edges order? => ordering messages should solve - * -> Check multiple rising edges case => Histos? - * -> Check multiple falling edges case => Histos? - */ - UInt_t uLastAcceptedMessageIndex = 0; - - std::sort( ROC[uRocId].fPrevEpochs2Buffer[uGet4Id][bBufferToBuild].begin(), - ROC[uRocId].fPrevEpochs2Buffer[uGet4Id][bBufferToBuild].end() ); - for( UInt_t uMessageIndex = 0; - uMessageIndex < ROC[uRocId].fPrevEpochs2Buffer[uGet4Id][bBufferToBuild].size(); - uMessageIndex ++) - { - if( kTRUE == (ROC[uRocId].fPrevEpochs2Buffer[uGet4Id][bBufferToBuild])[uMessageIndex].Is32Bit() ) - { - // 32 Bits data message => already contains a full hit! - fHitTemp.Clear(); - fHitTemp.SetFullHit32Bits( (ROC[uRocId].fPrevEpochs2Buffer[uGet4Id][bBufferToBuild])[uMessageIndex] ); - if( kTRUE == CheckHit( uRocId, uGet4Id, fHitTemp ) ) - uLastAcceptedMessageIndex = uMessageIndex; - - } // if( kTRUE == (ROC[uRocId].fPrevEpochs2Buffer[uGet4Id][bBufferToBuild])[uMessageIndex].Is32Bit() ) - else - { - UChar_t ucChan = (ROC[uRocId].fPrevEpochs2Buffer[uGet4Id][bBufferToBuild])[uMessageIndex].GetGet4ChNum(); - - // 24 Bits data message => Rising and falling edge need to be associated to get a hit - if( 1 == (ROC[uRocId].fPrevEpochs2Buffer[uGet4Id][bBufferToBuild])[uMessageIndex].IsRisingGet4Edge() ) - { - // Trailing Edge - // If no leading edge there, as messages are time ordered, means that - // the leading edge of this hit is missing => no need to save it - if( kTRUE == (ROC[uRocId].fHitTemp24[uGet4Id][ucChan]).IsTimeSet() ) - { - (ROC[uRocId].fHitTemp24[uGet4Id][ucChan]).SetTot24Bits( - (ROC[uRocId].fPrevEpochs2Buffer[uGet4Id][bBufferToBuild])[uMessageIndex] ); - - // Check if hit is not too big - // If it is we can clear this one as anyway messages are time ordered! - if( (ROC[uRocId].fHitTemp24[uGet4Id][ucChan]).GetTot() < 0) - { - cout<<"Negative 24b ToT in Build Older: Mess "<<uMessageIndex; - cout<<" Tot "<<(ROC[uRocId].fHitTemp24[uGet4Id][ucChan]).GetTot(); - cout<<" Test "<<( ((ROC[uRocId].fHitTemp24[uGet4Id][ucChan]).GetTimeMessage()) < ((ROC[uRocId].fHitTemp24[uGet4Id][ucChan]).GetTotMessage()) )<<endl; - ((ROC[uRocId].fHitTemp24[uGet4Id][ucChan]).GetTimeMessage()).Print(roc::msg_print_Human); - ((ROC[uRocId].fHitTemp24[uGet4Id][ucChan]).GetTotMessage()).Print(roc::msg_print_Human); - cout<<endl; - if( kTRUE == CheckHit( uRocId, uGet4Id, (ROC[uRocId].fHitTemp24[uGet4Id][ucChan]) ) ) - uLastAcceptedMessageIndex = uMessageIndex; - } - else if( (ROC[uRocId].fHitTemp24[uGet4Id][ucChan]).GetTot() < fParam->dMaxTot ) - { - if( kTRUE == CheckHit( uRocId, uGet4Id, (ROC[uRocId].fHitTemp24[uGet4Id][ucChan]) ) ) - uLastAcceptedMessageIndex = uMessageIndex; - } - else (ROC[uRocId].fHitTemp24[uGet4Id][ucChan]).Clear(); - } // if( kTRUE == fHitTemp.IsTimeSet() ) - } - else - { - // Leading edge - // clear anyway as time ordered, worst case there was another leading edge - // whose trailing edge is missing - (ROC[uRocId].fHitTemp24[uGet4Id][ucChan]).Clear(); - (ROC[uRocId].fHitTemp24[uGet4Id][ucChan]).SetTime24Bits( - (ROC[uRocId].fPrevEpochs2Buffer[uGet4Id][bBufferToBuild])[uMessageIndex] ); - } - } // else of if( kTRUE == (ROC[uRocId].fPrevEpochs2Buffer[uGet4Id][bOlderBuffer])[uMessageIndex].Is32Bit() ) - } // for loop over older buffer = full epoch one - - // Erase all messages until last accepted one - // This can be done only if we don't mix event (always strictly consecutive events) - - if( kFALSE == fParam->bAllowEventMixing) - (ROC[uRocId].fPrevEpochs2Buffer[uGet4Id][bBufferToBuild]).erase( - (ROC[uRocId].fPrevEpochs2Buffer[uGet4Id][bBufferToBuild]).begin(), - (ROC[uRocId].fPrevEpochs2Buffer[uGet4Id][bBufferToBuild]).begin() + uLastAcceptedMessageIndex ); - - /* - cout<<"Building hits, size old = "<<(ROC[uRocId].fPrevEpochs2Buffer[uGet4Id][bBufferToBuild]).size()<<" (buffer "<<bBufferToBuild<<" )"; - cout<<" size new = "<<(ROC[uRocId].fPrevEpochs2Buffer[uGet4Id][bCurrentBuffer]).size()<<" (buffer "<<bCurrentBuffer<<" )"<<endl; - */ - - return kTRUE; -} - - -Bool_t TTofGet4Unpacker::CheckHit(UInt_t uRocId, UInt_t uGet4Id, Get4v1Hit& hit) -{ - /* TODO FILL ME - * Check if Get4 Hit matches the current trigger and - * if yes save it in output event - */ - Double_t dTimeToTrigger = 0.0; - Bool_t bSelectedHit = kFALSE; - - if ( 0.0 < fCurrentGet4Event.fdTriggerFullTime[uRocId] ) - { - dTimeToTrigger = hit.GetHitFullTimeD() - fCurrentGet4Event.fdTriggerFullTime[uRocId]; - - fDeltaTriggerTime->Fill( dTimeToTrigger ); - ROC[uRocId].fTrigger_All->Fill( dTimeToTrigger ); - ROC[uRocId].fTrigger_All_100->Fill( dTimeToTrigger ); - ROC[uRocId].fTrigger_All_us->Fill( dTimeToTrigger ); - ROC[uRocId].fTrigger_All_ms->Fill( dTimeToTrigger ); - ROC[uRocId].fTrigger_All_s->Fill( dTimeToTrigger ); - - UChar_t uGet4Chan = hit.GetChan(); - ROC[uRocId].fTrigger_Get4Channel[uGet4Id][uGet4Chan]->Fill( dTimeToTrigger ); - ROC[uRocId].fTriggerMs_Get4Channel[uGet4Id][uGet4Chan]->Fill( dTimeToTrigger ); - ROC[uRocId].fTriggerS_Get4Channel[uGet4Id][uGet4Chan]->Fill( dTimeToTrigger ); - - - if( kTRUE == ROC[uRocId].fTriggerWind->Test( dTimeToTrigger) ) - { - bSelectedHit =kTRUE; - // Hit is in trigger selection window => add it to the event - ( ( fCurrentGet4Event.fGet4Boards[uGet4Id] ).fHits[ hit.GetChan() ]).push_back( hit ); - - // Count per global time unit in s - Double_t dSyncTm = hit.GetHitFullTimeD() / 100000000.0; - ROC[uRocId].fSelectedT[uGet4Id][uGet4Chan]->Fill(( dSyncTm ) * 0.1); - - ROC[uRocId].fAllSelectedT->Fill(( dSyncTm ) * 0.1 ); - // Long duration time distribution (1 min. bin, 10 days length) - if( kTRUE == fParam->bLongTimeHistos ) - ROC[uRocId].fAllSelLongT->Fill( (dSyncTm * 0.1 ) / 3600 ); - - // Filling histos: - if( 1 == fParam->bTotHistoEnable ) - { - ROC[uRocId].fTot[uGet4Id][hit.GetChan()]->Fill( hit.GetTot() ); - if( hit.GetTot() < 0) - { - cout<<"Negative 24b ToT in Check: "<<hit.GetTot()<<endl; - (hit.GetTimeMessage()).Print(roc::msg_print_Human); - (hit.GetTotMessage()).Print(roc::msg_print_Human); - cout<<endl; - } - } - if( 1 == fParam->bDebugHistoEnable ) - { - ROC[uRocId].fLeadingFTS[uGet4Id][hit.GetChan()]->Fill( hit.GetHitLeadingFTS() ); - if( kFALSE == hit.Is32Bit() ) - ROC[uRocId].fTrailingFTS[uGet4Id][hit.GetChan()]->Fill( hit.GetHitTrailingFTS() ); - } // if( 1 == fParam->bDebugHistoEnable ) - } - } // if ( 0.0 < fCurrentGet4Event.fdTriggerFullTime[uRocId]) - else LOG(error)<<"Trying to check a hit validity while no trigger found for current event"; - - return bSelectedHit; -} -void TTofGet4Unpacker::CheckEventClosure() -{ - /* TODO FILL ME - * Checking if event finiched for all ROCs/GET4s - * saving it - */ - - // If not trigger yet => no need to check! - if( kFALSE == fCurrentGet4Event.HasTrigger() ) - return; - - Bool_t bAllFutureEpochsFinished = kTRUE; - // Check flag indicating the extra epoch after trigger is passed - for( UInt_t uRocId =0; uRocId<fParam->numRocs; uRocId++ ) - { - // do not check for non-used ROC - if (!fParam->IsActiveRoc(uRocId)) continue; - - if( kFALSE == ROC[uRocId].fbSelectionRocDone ) - bAllFutureEpochsFinished = kFALSE; - - for( UInt_t uGet4 = 0; uGet4 < get4v10::kuMaxGet4Roc; uGet4++) - { - UInt_t uRemappedGet4Index = fParam->RemapGet4Chip(uRocId, uGet4); - if( kTRUE == fParam->IsValidGet4Chip(uRemappedGet4Index) && - kTRUE == fParam->IsActiveGet4Chip(uRemappedGet4Index) ) - if( kFALSE == ROC[uRocId].fbSelectionDone[uGet4] ) - bAllFutureEpochsFinished = kFALSE; - } - } - - // extra epoch passed for all => save event - if( kTRUE == bAllFutureEpochsFinished ) - { - if( kFALSE == fCurrentGet4Event.IsEmpty() ) - { - AnalyzeAllGet4Channels( fCurrentGet4Event ); - /////////////////////////////////////////////// - // Replaced with cbmroot output format - // Only 1 event used per MBS event! -// (fOutputEvent->fEvents).push_back( fCurrentGet4Event ); - if( kFALSE == fbDataSavedForThisEvent ) - { - // First event found in this MBS event - for( UInt_t uGet4 = 0; uGet4 < get4v10::kuMaxGet4; uGet4++) - { - TTofGet4Board * fGet4Board = (TTofGet4Board*) fGet4BoardCollection->ConstructedAt(uGet4); - if( 0 < (fCurrentGet4Event.fGet4Boards[uGet4]).Size() ) - { - fGet4Board->SetTriggerFullTime( fCurrentGet4Event.fdTriggerFullTime[0] ); // Use only first ROC!!!! - fGet4Board->SetSyncEventFlag( fCurrentGet4Event.fbMbsSyncedEvent ); - fGet4Board->SetSyncEvtNb( fCurrentGet4Event.fuSyncEventNumber ); - fGet4Board->SetDataEventFlag( fCurrentGet4Event.fbDataTriggered ); - fGet4Board->SetTriggIndx( fCurrentGet4Event.fuTriggerIndex ); - - // Some Data found for this TDC Chip - for( UInt_t uCh = 0; uCh < get4v10::kuNbChan; uCh++ ) - for( UInt_t uHit = 0; - uHit < ((fCurrentGet4Event.fGet4Boards[uGet4]).fHits[uCh]).size(); - uHit++ ) - { - TGet4v1MessageExtended extTime = ((fCurrentGet4Event.fGet4Boards[uGet4]).fHits[uCh])[uHit].GetTimeMessage(); - TGet4v1MessageExtended extTot = ((fCurrentGet4Event.fGet4Boards[uGet4]).fHits[uCh])[uHit].GetTotMessage(); - - if( kFALSE == extTime.IsEmpty() ) - { - TTofGet4Data dataTime; - dataTime.SetEdge( 0 ); - if( kTRUE == extTime.Is32Bit() ) - { - dataTime.SetChannel( uCh ); - dataTime.SetFineTime( extTime.getGet4V10R32HitFt() ); - dataTime.SetCoarseTime( extTime.getGet4V10R32HitTs() ); - dataTime.SetTot( extTime.getGet4V10R32HitTot() ); - } // if( kTRUE == extTime.Is32Bit() ) - else - { - // Time saved in "odd channels" as example of VFTX - dataTime.SetChannel( 2*uCh + 1 ); - dataTime.SetFineTime( extTime.GetGet4Ts() & get4tdc::kiFineTime ); - dataTime.SetCoarseTime( (extTime.GetGet4Ts() & get4tdc::kiCoarseTime )>>get4tdc::kiCtShift ); - } // else of if( kTRUE == extTime.Is32Bit() ) - dataTime.SetEpoch( extTime.GetRocEpoch() ); - dataTime.SetEpochCycle( extTime.GetRocCycle() ); - dataTime.SetFullTimeD( extTime.GetFullTimeD() ); - dataTime.Set32bFlag( extTime.Is32Bit() ); - fGet4Board->AddData( dataTime ); - } // if( kFALSE == extTime.IsEmpty() ) - - if( kFALSE == extTot.IsEmpty() ) - { - // Will appear only in case of 24bit mode !!! - TTofGet4Data dataTot; - // Tot saved in "even channels" as example of VFTX - dataTot.SetChannel( 2*uCh ); - dataTot.SetEdge( 1 ); - dataTot.SetFineTime( extTot.GetGet4Ts() & get4tdc::kiFineTime ); - dataTot.SetCoarseTime( (extTot.GetGet4Ts() & get4tdc::kiCoarseTime )>>get4tdc::kiCtShift ); - dataTot.SetEpoch( extTot.GetRocEpoch() ); - dataTot.SetEpochCycle( extTot.GetRocCycle() ); - dataTot.SetFullTimeD( extTot.GetFullTimeD() ); - dataTot.Set32bFlag( extTot.Is32Bit() ); - fGet4Board->AddData( dataTot ); - } // if( kFALSE == extTot.IsEmpty() ) - } // scan over all hits in this board object - - } // if( 0 < (fCurrentGet4Event.fGet4Boards[uGet4]).Size() ) - } // for( UInt_t uGet4 = 0; uGet4 < get4v10::kuMaxGet4; uGet4++) - fbDataSavedForThisEvent = kTRUE; - } // if( kFALSE == fbDataSavedForThisEvent ) - /////////////////////////////////////////////// - - for( UInt_t uRocId =0; uRocId<fParam->numRocs; uRocId++ ) - { - uNotEmptyEventInsideMbsEvtCount[uRocId]++; - uNotEmptyRealEventsCount[uRocId]++; - } - } // if( kFALSE == fCurrentGet4Event.IsEmpty() ) - - fCurrentGet4Event.Clear(); - } // if( kTRUE == bAllFutureEpochsFinished ) -} - -void TTofGet4Unpacker::ResetTrigger() -{ - /* TODO FILL ME - * Trigger resetting => Needed? - */ -} - - -void TTofGet4Unpacker::ResetEndOfBuffer() -{ - /* TODO FILL ME - * Buffer resetting => Needed? - */ -} - -/**********************************************************************/ -/* - * This function process the data message when it is a ROC Sync message - */ -Bool_t TTofGet4Unpacker::ProcessRocSyncMessage( UInt_t uRocId, TGet4v1MessageExtended& extMess ) -{ - /* - * ROC Sync message specific processing - * TODO: Check on Sync number from current event to avoid - * multiple events created for same sync when using more than 1 ROC - */ - UInt_t uSyncId = (extMess.GetRocMessage()).getSyncChNum(); - ULong64_t ulFulltime = extMess.GetFullTime(); - - // Recalculate the full Time to take into account also the epoch cycles - ulFulltime = (extMess.GetRocMessage()).getMsgFullTime( - ROC[uRocId].GetFullEpochNumber( )); - ulFulltime += ROC[uRocId].GetSuperCycleEpOffset(); - extMess.SetFullTime(ulFulltime); - - if( uSyncId < get4v10::kuMaxSync ) - { - ROC[uRocId].fLastSyncTm[uSyncId] = ulFulltime; - ROC[uRocId].fLastSyncId[uSyncId] = (extMess.GetRocMessage()).getSyncData(); - /* TODO ? - if (rocevent) - rocevent->fLastSyncTm[uSyncId] = ulFulltime; - */ - - // Count per global time unit in s - ULong64_t ulSyncTm = ulFulltime / 100000000L; - ROC[uRocId].fSYNCt[uSyncId]->Fill((ulSyncTm % 36000) * 0.1); - - // Long duration time distribution (1 min. bin, 10 days length) - if( kTRUE == fParam->bLongTimeHistos ) - ROC[uRocId].fSyncLongT[uSyncId]->Fill( (ulSyncTm * 0.1 ) / 3600 ); - - if( kFALSE == fParam->bFreeStreaming || 0 == fParam->uNbTriggers ) - if( fParam->triggerSignal == (Int_t) (uSyncId + 10) ) // then may use it for new trigger - ProcessTriggerMessage( uRocId, extMess ); - } // if( uSyncId < get4v10::kuMaxSync ) - return kTRUE; -} -/**********************************************************************/ -/* - * This function process the data message when it is a ROC epoch message - */ -Bool_t TTofGet4Unpacker::ProcessRocEpochMessage( UInt_t uRocId, TGet4v1MessageExtended& extMess ) -{ - /* - * Roc epoch message specific processing - */ - if( ROC[uRocId].fuCurrEpoch > (extMess.GetRocMessage()).getEpochNumber() ) - { - ROC[uRocId].fuEpochCycle++; - TString sTemp = Form("Roc Epoch cycle change: %u", ROC[uRocId].fuEpochCycle); - LOG(info)<<sTemp; - } - ROC[uRocId].fuCurrEpoch = (extMess.GetRocMessage()).getEpochNumber(); - - // Recalculate the full Time to take into account also the epoch cycles - ULong64_t ulFulltime = ((ULong64_t) ROC[uRocId].GetFullEpochNumber() ) << 14; - extMess.SetFullTime(ulFulltime); - - // Count per global time unit in s - ULong64_t ulEpochTm = ulFulltime / 100000000L; - ROC[uRocId].fEPOCHt->Fill((ulEpochTm % 36000) * 0.1); - - // Long duration time distribution (1 min. bin, 10 days length) - if( kTRUE == fParam->bLongTimeHistos ) - ROC[uRocId].fEpochLongT->Fill( (ulEpochTm * 0.1 ) / 3600 ); - - ROC[uRocId].fDistribEpochs->Fill( ROC[uRocId].fuCurrEpoch ); - - if( kTRUE == fCurrentGet4Event.HasTrigger() && - kFALSE == ROC[uRocId].fbSelectionRocDone ) - { - Double_t dTimeToTrigger = 0.0; - dTimeToTrigger = extMess.GetFullTimeD() - fCurrentGet4Event.fdTriggerFullTime[uRocId]; - // If flag is kTRUE: we are at the second epoch since trigger - // => rest of trigger epoch + 1 full epoch elapsed, enough for ordering issues - // => close hit selection checks for ROC self message - // If Epoch is out of the trigger window started on trigger - // => all hits always contained inside epoch even if not time ordered - // => No need to look at the next epoch!!! - if( kTRUE == ROC[uRocId].fbEpochSinceTrigger || - kFALSE == ROC[uRocId].fTriggerWind->Test( dTimeToTrigger) ) - { - ROC[uRocId].fbSelectionRocDone = kTRUE; - ROC[uRocId].fbEpochSinceTrigger = kFALSE; - CheckEventClosure(); - } - else ROC[uRocId].fbEpochSinceTrigger = kTRUE; - } // If selection of hits after trigger detection not over -/* - // TODO: Maybe necessary? - // As no empty epoch there after data anymore, try to use ROC epoch as - // empty epochs... unsafe because of ordering, but epochs with data - // should anyway have the flag ON and an epoch2 message coming after, - // thus keeping the ordering containment - if( kTRUE == fParam->bSuppressedEpochs && kTRUE == fCurrentGet4Event.HasTrigger()) - for( UInt_t uGet4Id = 0; uGet4Id < get4v10::kuMaxGet4Roc; uGet4Id ++) - if( kTRUE == fParam->IsActiveGet4Chip(uGet4Id) && - 0 == ROC[uRocId].fuEpochWithData[uGet4Id] && - kFALSE == ROC[uRocId].fbSelectionDone[uGet4Id] ) - { - // A trigger is ongoing on this chip! - if( kFALSE == ROC[uRocId].fbEpoch2SinceTrigger[uGet4Id] ) - { - // This is the first epoch after the trigger - // => time to look for the data in the epoch which was - // ongoing when the trigger was found - - // If we did not process the epoch before the one where the - // trigger came, we need to initialize the 24 bit temp hits - if( kFALSE == ROC[uRocId].bLookInPreviousEpoch[uGet4Id] ) - for( UInt_t uChan = 0; uChan < get4v10::kuNbChan; uChan++) - (ROC[uRocId].fHitTemp24[uGet4Id][uChan]).Clear(); - - BuildHits(uRocId, uGet4Id, ROC[uRocId].fbBufferWithLastFullEpoch2[uGet4Id]); - if( kFALSE == ROC[uRocId].bLookInNextEpoch[uGet4Id] ) - { - ROC[uRocId].fbSelectionDone[uGet4Id] = kTRUE; - CheckEventClosure(); - } - ROC[uRocId].fbEpoch2SinceTrigger[uGet4Id] = kTRUE; - } // if( kFALSE == ROC[uRocId].fbEpoch2SinceTrigger[uGet4Id] ) - else if( kTRUE == ROC[uRocId].fbEpoch2SinceTrigger[uGet4Id] && - kTRUE == ROC[uRocId].bLookInNextEpoch[uGet4Id]) - { - // This is the second epoch after the trigger and we detected on trigger - // that the trigger window extend in epoch after the one where trigger - // was found => time to look for the data in the epoch which just finished - // and was the one just after the trigger epoch - BuildHits(uRocId, uGet4Id, ROC[uRocId].fbBufferWithLastFullEpoch2[uGet4Id]); - ROC[uRocId].fbSelectionDone[uGet4Id] = kTRUE; - CheckEventClosure(); - } // else if( kTRUE == ROC[uRocId].fbEpoch2SinceTrigger[uGet4Id] && kFALSE == ROC[uRocId].bLookInNextEpoch[uGet4Id]) - } // if chip active and not over -*/ - // Swap the flag indicating which buffer contains currently happening epoch - ROC[uRocId].fbBufferWithLastFullEpoch = ( kTRUE == ROC[uRocId].fbBufferWithLastFullEpoch ? kFALSE: kTRUE ); - // Clear this buffer (Data more than 1 full epoch old => either already selected or junk) - ROC[uRocId].fPrevEpochsBuffer[ ROC[uRocId].fbBufferWithLastFullEpoch ].clear(); - - return kTRUE; -} -/**********************************************************************/ -/* - * This function process the data message when it is a GET4 epoch message - */ -Bool_t TTofGet4Unpacker::ProcessGet4EpochMessage( UInt_t uRocId, TGet4v1MessageExtended& extMess ) -{ - /* - * 24bit Get4 epoch message specific processing - */ - - UInt_t uGet4Id(0); - - // Remap the Get4 chip index => Go in Get4 indexing common to all ROCs - uGet4Id = (extMess.GetRocMessage()).getEpoch2ChipNumber(); - uGet4Id = fParam->RemapGet4Chip( fParam->DefineGet4IndexOffset(uRocId) + uGet4Id); - extMess.SetEpoch2ChipNumber(uGet4Id); - - // Check if active chip - if( kFALSE == fParam->IsValidGet4Chip(uGet4Id) ) - { - cout << "Error: Bad chip nb in Epoch message = " << uGet4Id << endl; - cout << " => This message will be skipped!!!! "<<endl; - return kFALSE; - } - if( kFALSE == fParam->IsActiveGet4Chip(uGet4Id) ) - { - // Masked chip, hopefully on purpose, don't complain & return - return kFALSE; - } - - if( kTRUE == fCurrentGet4Event.HasTrigger() && kFALSE == ROC[uRocId].fbSelectionDone[uGet4Id] ) - { - // A trigger is ongoing on this chip! - if( kFALSE == ROC[uRocId].fbEpoch2SinceTrigger[uGet4Id] ) - { - // This is the first epoch after the trigger - // => time to look for the data in the epoch which was - // ongoing when the trigger was found - - // If we did not process the epoch before the one where the - // trigger came, we need to initialize the 24 bit temp hits - if( kFALSE == ROC[uRocId].bLookInPreviousEpoch[uGet4Id] ) - for( UInt_t uChan = 0; uChan < get4v10::kuNbChan; uChan++) - (ROC[uRocId].fHitTemp24[uGet4Id][uChan]).Clear(); - - BuildHits(uRocId, uGet4Id, ROC[uRocId].fbBufferWithLastFullEpoch2[uGet4Id]); - if( kFALSE == ROC[uRocId].bLookInNextEpoch[uGet4Id] ) - { - ROC[uRocId].fbSelectionDone[uGet4Id] = kTRUE; - CheckEventClosure(); - } - ROC[uRocId].fbEpoch2SinceTrigger[uGet4Id] = kTRUE; - } // if( kFALSE == ROC[uRocId].fbEpoch2SinceTrigger[uGet4Id] ) - else if( kTRUE == ROC[uRocId].fbEpoch2SinceTrigger[uGet4Id] && - kTRUE == ROC[uRocId].bLookInNextEpoch[uGet4Id]) - { - // This is the second epoch after the trigger and we detected on trigger - // that the trigger window extend in epoch after the one where trigger - // was found => time to look for the data in the epoch which just finished - // and was the one just after the trigger epoch - BuildHits(uRocId, uGet4Id, ROC[uRocId].fbBufferWithLastFullEpoch2[uGet4Id]); - ROC[uRocId].fbSelectionDone[uGet4Id] = kTRUE; - CheckEventClosure(); - } // else if( kTRUE == ROC[uRocId].fbEpoch2SinceTrigger[uGet4Id] && kFALSE == ROC[uRocId].bLookInNextEpoch[uGet4Id]) - } // if( kTRUE == fCurrentGet4Event.HasTrigger() && kFALSE == ROC[uRocId].fbSelectionDone[uGet4Id] ) - - UInt_t get4_24b_ep_epoch = (extMess.GetRocMessage()).getEpoch2Number(); - if( ROC[uRocId].fuCurrEpoch2[uGet4Id] + 1 != get4_24b_ep_epoch && - ( 0 < ROC[uRocId].fuCurrEpoch2[uGet4Id] || 0 < ROC[uRocId].fuEpoch2Cycle[uGet4Id] ) && - !( get4v10::kulGet4EpochCycleSz == ROC[uRocId].fuCurrEpoch2[uGet4Id] && 0 == get4_24b_ep_epoch ) ) - { - LOG(info)<<"Roc Get4 Epoch2 error in 24b mode"; - ROC[uRocId].fEpochShiftsPerChip->Fill( uGet4Id, (Int_t)get4_24b_ep_epoch - (Int_t)(ROC[uRocId].fuCurrEpoch2[uGet4Id]+1) ); - - // Correction attempt: just calculating, not using it - if( (Int_t)get4_24b_ep_epoch - (Int_t)(ROC[uRocId].fuCurrEpoch2[uGet4Id]+1) < 10 ) - { - // close epochs ( < 250us) => probable not a full event missing - if( 0 != ROC[uRocId].fiEpochShift[uGet4Id]) - ROC[uRocId].fEpochShiftsDuration[uGet4Id]->Fill(ROC[uRocId].fiEpochShift[uGet4Id], - ROC[uRocId].fuNbShiftedEpochs[uGet4Id] ); - ROC[uRocId].fiEpochShift[uGet4Id] += (Int_t)get4_24b_ep_epoch - (Int_t)(ROC[uRocId].fuCurrEpoch2[uGet4Id]+1) ; - ROC[uRocId].fuNbShiftedEpochs[uGet4Id] = 0; - } - else - { - // far epochs ( > 250us) => probable a full event is missing - if( 0 != ROC[uRocId].fiEpochShift[uGet4Id]) - ROC[uRocId].fEpochShiftsDuration[uGet4Id]->Fill(ROC[uRocId].fiEpochShift[uGet4Id], - ROC[uRocId].fuNbShiftedEpochs[uGet4Id] ); - ROC[uRocId].fiEpochShift[uGet4Id] = 0 ; - ROC[uRocId].fuNbShiftedEpochs[uGet4Id] = 0; - } - } // if non consecutive epoch indexes - else - { - if( 0 != ROC[uRocId].fiEpochShift[uGet4Id] ) - ROC[uRocId].fuNbShiftedEpochs[uGet4Id]++; - } // else of if non consecutive epoch indexes - - // Event statistics - ROC[uRocId].fuNbHitsChipEpoch[uGet4Id] = 0; - - if( ROC[uRocId].fuCurrEpoch2[uGet4Id] > get4_24b_ep_epoch ) - { - TString sTemp = Form("Roc Epoch2 cycle (24b mode) change: %u", ROC[uRocId].fuEpoch2Cycle[uGet4Id]); - LOG(info)<<sTemp; - ROC[uRocId].fuEpoch2Cycle[uGet4Id]++; - } - ROC[uRocId].fuCurrEpoch2[uGet4Id] = get4_24b_ep_epoch; - - // In case of suppressed epochs, we will have only chip 0 epochs for all empty epochs - // We then use these epochs for all other active chips - // However, when a chip has data, its next epoch message should be present!!! - if( kTRUE == fParam->bSuppressedEpochs ) - { - // Assume Chip 0 are always there, even if disabled - // TODO: test this and at some other behavior if needed - if( 0 == uGet4Id ) - for( UInt_t uGet4IdBis = uGet4Id + 1; uGet4IdBis < get4v10::kuMaxGet4Roc; uGet4IdBis ++) - if( kTRUE == fParam->IsActiveGet4Chip(uGet4IdBis) ) - { - // In case no data was found in previous epoch for this chip, we use the epoch info - // from chip 0 - if( 0 == ROC[uRocId].fuEpochWithData[uGet4IdBis]) - { - if( ROC[uRocId].fuCurrEpoch2[uGet4IdBis] + 1 != get4_24b_ep_epoch && - ( 0 < ROC[uRocId].fuCurrEpoch2[uGet4IdBis] || 0 < ROC[uRocId].fuEpoch2Cycle[uGet4IdBis] ) && - !( get4v10::kulGet4EpochCycleSz == ROC[uRocId].fuCurrEpoch2[uGet4IdBis] && 0 == get4_24b_ep_epoch ) ) - { - LOG(info)<<"Roc Get4 Epoch2 error in 24b mode"; - ROC[uRocId].fEpochShiftsPerChip->Fill( uGet4IdBis, (Int_t)get4_24b_ep_epoch - (Int_t)(ROC[uRocId].fuCurrEpoch2[uGet4IdBis]+1) ); - - // Correction attempt: just calculating, not using it - if( (Int_t)get4_24b_ep_epoch - (Int_t)(ROC[uRocId].fuCurrEpoch2[uGet4IdBis]+1) < 10 ) - { - // close epochs ( < 250us) => probable not a full event missing - if( 0 != ROC[uRocId].fiEpochShift[uGet4IdBis]) - ROC[uRocId].fEpochShiftsDuration[uGet4IdBis]->Fill(ROC[uRocId].fiEpochShift[uGet4IdBis], - ROC[uRocId].fuNbShiftedEpochs[uGet4IdBis] ); - ROC[uRocId].fiEpochShift[uGet4IdBis] += (Int_t)get4_24b_ep_epoch - (Int_t)(ROC[uRocId].fuCurrEpoch2[uGet4IdBis]+1) ; - ROC[uRocId].fuNbShiftedEpochs[uGet4IdBis] = 0; - } - else - { - // far epochs ( > 250us) => probable a full event is missing - if( 0 != ROC[uRocId].fiEpochShift[uGet4IdBis]) - ROC[uRocId].fEpochShiftsDuration[uGet4IdBis]->Fill(ROC[uRocId].fiEpochShift[uGet4IdBis], - ROC[uRocId].fuNbShiftedEpochs[uGet4IdBis] ); - ROC[uRocId].fiEpochShift[uGet4IdBis] = 0 ; - ROC[uRocId].fuNbShiftedEpochs[uGet4IdBis] = 0; - } - } // if non consecutive epoch indexes - else - { - if( 0 != ROC[uRocId].fiEpochShift[uGet4IdBis] ) - ROC[uRocId].fuNbShiftedEpochs[uGet4IdBis]++; - } // else of if non consecutive epoch indexes - - // Event statistics - ROC[uRocId].fuNbHitsChipEpoch[uGet4IdBis] = 0; - - if( ROC[uRocId].fuCurrEpoch2[uGet4IdBis] > get4_24b_ep_epoch ) - { - TString sTemp = Form("Roc Epoch2 cycle (24b mode) change: %u", ROC[uRocId].fuEpoch2Cycle[uGet4Id]); - LOG(info)<<sTemp; - ROC[uRocId].fuEpoch2Cycle[uGet4IdBis]++; - } - ROC[uRocId].fuCurrEpoch2[uGet4IdBis] = get4_24b_ep_epoch; - } // if( 0 == ROC[uRocId].fuEpochWithData[uGet4IdBis]) - // If data just increase the flag, should not hurt, - // just in case the epoch messages are not always coming ordered the way I expect - else ROC[uRocId].fuEpochWithData[uGet4IdBis]++; - } // if( kTRUE == fParam->IsActiveGet4Chip(uGet4IdBis) ) - - ROC[uRocId].fuEpochWithData[uGet4Id] = 0; - } // if( kTRUE == fParam->bSuppressedEpochs) - - // Recalculate the full Time to take into account also the epoch2 cycles - ULong64_t uFullTimeBins = ((ULong64_t) ROC[uRocId].GetFullEpoch2Number( uGet4Id )) << 19; - ULong64_t uFullTime = uFullTimeBins/ 20 + 512; - Double_t dFullTime = uFullTimeBins / 20. + 512.; - extMess.SetFullTime( uFullTime ); - extMess.SetFullTimeD( dFullTime ); - - // Set The ROC epoch2 counter and cycle counter - extMess.SetRocEpoch( ROC[uRocId].fuCurrEpoch2[uGet4Id] ); - extMess.SetRocCycle( ROC[uRocId].fuEpoch2Cycle[uGet4Id] ); - - // Count per global time unit in s - ULong64_t ulEpochTm = uFullTime / 100000000L; - ROC[uRocId].fEPOCH2t[uGet4Id]->Fill((ulEpochTm % 36000) * 0.1); - - // Long duration time distribution (1 min. bin, 10 days length) - if( kTRUE == fParam->bLongTimeHistos ) - ROC[uRocId].fAllEpoch2LongT->Fill( (ulEpochTm * 0.1 ) / 3600 ); - - ROC[uRocId].fDistribEpochs2->Fill(uGet4Id, ROC[uRocId].fuCurrEpoch2[uGet4Id]); - - // Swap the flag indicating which buffer contains currently happening epoch - ROC[uRocId].fbBufferWithLastFullEpoch2[uGet4Id] = ( kTRUE == ROC[uRocId].fbBufferWithLastFullEpoch2[uGet4Id] ? kFALSE: kTRUE ); - // Clear this buffer (Data more than 1 full epoch old => either already selected or junk) - ROC[uRocId].fPrevEpochs2Buffer[uGet4Id][ ROC[uRocId].fbBufferWithLastFullEpoch2[uGet4Id] ].clear(); - - return kTRUE; -} -/**********************************************************************/ -/* - * This function process the data message when it is a GET4 data message - */ -Bool_t TTofGet4Unpacker::ProcessGet4DataMessage( UInt_t uRocId, TGet4v1MessageExtended& extMess ) -{ - /* - * 24bit Get4 hit message specific processing - * - * TODO - * Make the get4_index consistent everywhere between global get4 index and inside roc get4 index - */ - - if (ROC[uRocId].bIgnoreData) return kFALSE; - - if( kFALSE == ROC[uRocId].fb24bitsReadoutDetected ) - { - ROC[uRocId].fb24bitsReadoutDetected = kTRUE; - fb24bitsReadoutDetected = kTRUE; - // As it is first 24bit message, let's create - // 24bit specific histograms - char folder[30]; - sprintf(folder,"ROC%u/",uRocId); - - /* - * 24 bits specific histograms - */ - ROC[uRocId].fChannelInputMessCount = new TH1I( Form("Roc%u_ChanCounts", uRocId), - "Channel multiplicity per event; Channel []; # Mess []" , - 2*get4v10::kuNbChan*get4v10::kuMaxGet4Roc, 0, get4v10::kuMaxGet4Roc); - ROC[uRocId].fb24bitsReadoutDetected = kTRUE; - } // if( kFALSE == ROC[uRocId].fb24bitsReadoutDetected ) - - UInt_t uGet4Id(0), uGet4Ch(0), uGet4Edge(0); - uGet4Id = (extMess.GetRocMessage()).getGet4Number(); - uGet4Ch = (extMess.GetRocMessage()).getGet4ChNum(); - uGet4Edge = (extMess.GetRocMessage()).getGet4Edge(); - - // Remap the Get4 chip index - uGet4Id = (extMess.GetRocMessage()).getGet4Number(); - uGet4Id = fParam->RemapGet4Chip( fParam->DefineGet4IndexOffset(uRocId) + uGet4Id); - extMess.SetGet4Number(uGet4Id); - - // Check if valid chip - if( kFALSE == fParam->IsValidGet4Chip(uGet4Id) ) - { - cout << "Error: Bad chip nb in Data message = " << uGet4Id << endl; - cout << " => This message will be skipped!!!! "<<endl; - return kFALSE; - } - if( kFALSE == fParam->IsActiveGet4Chip(uGet4Id) ) - { - // Masked chip, hopefully on purpose, don't complain & return - return kFALSE; - } - - // Recalculate the full Time to take into account also the epoch2 cycles - ULong64_t uFullTimeBins = ((ULong64_t) ROC[uRocId].GetFullEpoch2Number( uGet4Id ) << 19) | - (ULong64_t)extMess.GetGet4Ts(); - ULong64_t uFullTime = uFullTimeBins/ 20 + 512; - Double_t dFullTime = ((Double_t)uFullTimeBins)*0.05 + 512.; - extMess.SetFullTime( uFullTime ); - extMess.SetFullTimeD( dFullTime ); - - // Set The ROC epoch2 counter and cycle counter - extMess.SetRocEpoch( ROC[uRocId].fuCurrEpoch2[uGet4Id] ); - extMess.SetRocCycle( ROC[uRocId].fuEpoch2Cycle[uGet4Id] ); - - - // Count per global time unit in s - ULong64_t ulDataTm = uFullTime / 100000000L; - ROC[uRocId].fDATAt->Fill((ulDataTm % 36000) * 0.1); - - // Long duration time distribution (1 min. bin, 10 days length) - if( kTRUE == fParam->bLongTimeHistos ) - ROC[uRocId].fDataLongT->Fill( (ulDataTm * 0.1 ) / 3600 ); - - // Event statistics - ROC[uRocId].fChannelInputMessCount->Fill( uGet4Id + (Double_t)uGet4Ch/(Double_t)get4v10::kuNbChan - + (Double_t)uGet4Edge/(Double_t)(2*get4v10::kuNbChan) ); - if( kTRUE == fParam->bChipRateHistoEnable ) - ROC[uRocId].fChipRateEvolution[uGet4Id]->Fill( - (uFullTimeBins ) * 0.1, 1.0/ROC[uRocId].fdRateEvolutionBinSize ); - if( kTRUE == fParam->bChannelRateHistoEnable ) - ROC[uRocId].fChannelRateEvolution[uGet4Id][uGet4Ch]->Fill( - (uFullTimeBins ) * 0.1, 1.0/ROC[uRocId].fdRateEvolutionBinSize ); - ROC[uRocId].fuNbHitsChipEpoch[uGet4Id] ++; - - // Early event closure check - if( kTRUE == fCurrentGet4Event.HasTrigger() && - kFALSE == ROC[uRocId].fbSelectionDone[uGet4Id] ) - { - Double_t dTimeToTrigger = 0.0; - dTimeToTrigger = extMess.GetFullTimeD() - fCurrentGet4Event.fdTriggerFullTime[uRocId]; - if( kFALSE == ROC[uRocId].fTriggerWind->Test( dTimeToTrigger) ) - { - // Message after the end of trigger window!! - Bool_t bAllChanInChipOver = kTRUE; - - // If there was already a message from the same channel & edge out of the trigger - // window, then the token ring made at least one full turn => ok for all - // Otherwise: need to check other channels/edge status - if( (kFALSE == ROC[uRocId].fbDataTimeOut[uGet4Id][uGet4Ch] && 0 == uGet4Edge ) || - (kFALSE == ROC[uRocId].fbDataFallingOut[uGet4Id][uGet4Ch] && 1 == uGet4Edge ) ) - { - // 24b = always a edge not a hit => need to check both ! - if( 0 == uGet4Edge ) - ROC[uRocId].fbDataTimeOut[uGet4Id][uGet4Ch] = kTRUE; - else ROC[uRocId].fbDataFallingOut[uGet4Id][uGet4Ch] = kTRUE; - // Check if chip fully finished - for(UInt_t uChanTest = 0; uChanTest < get4v10::kuNbChan; uChanTest ++) - { - if( kFALSE == ROC[uRocId].fbDataTimeOut[uGet4Id][uChanTest] ) - bAllChanInChipOver = kFALSE; - if( kFALSE == ROC[uRocId].fbDataFallingOut[uGet4Id][uChanTest] ) - bAllChanInChipOver = kFALSE; - } - } // if same edge not already out of trigger once - - // If chip fully finished: don't wait for the next epoch to close future buffer - // of current event for this chip - if( kTRUE == bAllChanInChipOver) - { - // If This is the first epoch after the trigger and - // we did not process the epoch before the one where the - // trigger came, we need to initialize the 24 bit temp hits - if( kFALSE == ROC[uRocId].fbEpoch2SinceTrigger[uGet4Id] && - kFALSE == ROC[uRocId].bLookInPreviousEpoch[uGet4Id] ) - for( UInt_t uChan = 0; uChan < get4v10::kuNbChan; uChan++) - (ROC[uRocId].fHitTemp24[uGet4Id][uChan]).Clear(); - - BuildHits(uRocId, uGet4Id, ROC[uRocId].fbBufferWithLastFullEpoch2[uGet4Id]); - ROC[uRocId].fbSelectionDone[uGet4Id] = kTRUE; - CheckEventClosure(); - - for(UInt_t uChanTest = 0; uChanTest < get4v10::kuNbChan; uChanTest ++) - { - ROC[uRocId].fbDataTimeOut[uGet4Id][uChanTest] = kFALSE; - ROC[uRocId].fbDataFallingOut[uGet4Id][uChanTest] = kFALSE; - } - } // if( kTRUE == bAllChanInChipOver) - } // if( kFALSE == ROC[uRocId].fTriggerWind->Test( dTimeToTrigger) ) - } // Event ongoing with a detected trigger and chip did not finished all its buffers - - /** Triggering on Data **/ - if( kTRUE == fParam->bFreeStreaming && 0 < fParam->uNbTriggers ) - { - /** Rising edge: Triggering on Data **/ - if( 0 == uGet4Edge ) - { - for( Int_t iMainTriggerIndex = 0; iMainTriggerIndex < (Int_t)(fParam->uNbTriggers); iMainTriggerIndex++ ) - if( kTRUE == fParam->IsMainOfThisTrigger( iMainTriggerIndex, uGet4Id, uGet4Ch ) ) - { - ROC[uRocId].fextMessLastMainChannel[iMainTriggerIndex] = extMess; - /* - * TODO: call to ProcessTrigger - * TEMP: histo Filling + counting - */ - Bool_t bAllInCoinc = kTRUE; - for( UInt_t uSecChannel = 0; uSecChannel < fParam->uNbSecondarySelectionCh[iMainTriggerIndex]; uSecChannel++) - { - Double_t dDistanceToMain = ROC[uRocId].fdLastFullTimeSecChannel[iMainTriggerIndex][uSecChannel] - - extMess.GetFullTimeD(); - if( dDistanceToMain < fParam->dCoincidenceWindowStart[iMainTriggerIndex] || - fParam->dCoincidenceWindowStop[iMainTriggerIndex] < dDistanceToMain ) - { - bAllInCoinc = kFALSE; - break; - } // if out of coincidence window - Double_t dTotDistanceToMain = ROC[uRocId].fdLastFullTimeSecChannelTot[iMainTriggerIndex][uSecChannel] - - extMess.GetFullTimeD(); - if( dTotDistanceToMain < fParam->dCoincidenceWindowStart[iMainTriggerIndex] || - fParam->dCoincidenceWindowStop[iMainTriggerIndex] < dTotDistanceToMain ) - { - bAllInCoinc = kFALSE; - break; - } // if out of coincidence window - } // for( UInt_t uSecChannel = 0; uSecChannel < fParam->uNbSecondarySelectionCh[iMainTriggerIndex]; uSecChannel++) - - // Check if tot edge of the main channel is in trigger window - Double_t dTotMainDistanceToMain = ROC[uRocId].fdLastFullTimeMainChannelTot[iMainTriggerIndex] - - ROC[uRocId].fextMessLastMainChannel[iMainTriggerIndex].GetFullTimeD(); - if( dTotMainDistanceToMain < fParam->dCoincidenceWindowStart[iMainTriggerIndex] || - fParam->dCoincidenceWindowStop[iMainTriggerIndex] < dTotMainDistanceToMain ) - { - bAllInCoinc = kFALSE; - } // if out of coincidence window - - if( kTRUE == bAllInCoinc ) - { - Double_t dSameTriggerDistance = - ROC[uRocId].fextMessLastMainChannel[iMainTriggerIndex].GetFullTimeD() - - ROC[uRocId].fdLastFullTimeSelfTrigger[iMainTriggerIndex] ; - - ROC[uRocId].fDataSelfTrigDistanceNs->Fill( dSameTriggerDistance, iMainTriggerIndex ); - ROC[uRocId].fDataSelfTrigDistanceUs->Fill( dSameTriggerDistance/1e3, iMainTriggerIndex ); - ROC[uRocId].fDataSelfTrigDistanceMs->Fill( dSameTriggerDistance/1e6, iMainTriggerIndex ); - ROC[uRocId].fDataSelfTrigDistanceS->Fill( dSameTriggerDistance/1e9, iMainTriggerIndex ); - - if( fParam->dDeadTime <= dSameTriggerDistance ) - { - // Here we have a DATA self-trigger!!!!!! - ROC[uRocId].fuDataSelfTriggerCount[iMainTriggerIndex] ++; - - ROC[uRocId].fdLastFullTimeSelfTrigger[iMainTriggerIndex] = - ROC[uRocId].fextMessLastMainChannel[iMainTriggerIndex].GetFullTimeD(); - - ULong64_t uFullTimeSelfTrigBins = ROC[uRocId].fextMessLastMainChannel[iMainTriggerIndex].GetFullTime(); - uFullTimeSelfTrigBins /= 100000000L; - ROC[uRocId].fSelfTriggT->Fill( (uFullTimeSelfTrigBins % 36000) * 0.1 ); - - // Long duration time distribution (1 min. bin, 10 days length) - if( kTRUE == fParam->bLongTimeHistos ) - ROC[uRocId].fSelfTriggLongT->Fill( (uFullTimeSelfTrigBins * 0.1 ) / 3600 ); - - ProcessTriggerMessage(uRocId, ROC[uRocId].fextMessLastMainChannel[iMainTriggerIndex], iMainTriggerIndex); - } // if( fParam->dDeadTime <= dSameTriggerDistance ) - } // if( kTRUE == bAllInCoinc ) - } // if( -1 < iMainTriggerIndex ) - - for( Int_t iSecTriggerIndex = 0; iSecTriggerIndex < (Int_t)(fParam->uNbTriggers); iSecTriggerIndex++ ) - { - if( kTRUE == fParam->IsSecOfThisTrigger( iSecTriggerIndex, uGet4Id, uGet4Ch ) ) - { - Int_t iSecondaryIndex = fParam->GetSecChannelIndex(iSecTriggerIndex, uGet4Id, uGet4Ch); - if( -1 < iSecondaryIndex ) - { - ROC[uRocId].fdLastFullTimeSecChannel[iSecTriggerIndex][iSecondaryIndex] = extMess.GetFullTimeD(); - - /* - * TODO: call to ProcessTrigger - * TEMP: histo Filling + counting - */ - Bool_t bAllInCoinc = kTRUE; - for( UInt_t uSecChannel = 0; uSecChannel < fParam->uNbSecondarySelectionCh[iSecTriggerIndex]; uSecChannel++) - { - Double_t dDistanceToMain = ROC[uRocId].fdLastFullTimeSecChannel[iSecTriggerIndex][uSecChannel] - - ROC[uRocId].fextMessLastMainChannel[iSecTriggerIndex].GetFullTimeD(); - if( dDistanceToMain < fParam->dCoincidenceWindowStart[iSecTriggerIndex] || - fParam->dCoincidenceWindowStop[iSecTriggerIndex] < dDistanceToMain ) - { - bAllInCoinc = kFALSE; - break; - } // if out of coincidence window - - // Check if tot edge is in trigger window, only needed in 24b mode - Double_t dTotDistanceToMain = ROC[uRocId].fdLastFullTimeSecChannelTot[iSecTriggerIndex][uSecChannel] - - ROC[uRocId].fextMessLastMainChannel[iSecTriggerIndex].GetFullTimeD(); - if( dTotDistanceToMain < fParam->dCoincidenceWindowStart[iSecTriggerIndex] || - fParam->dCoincidenceWindowStop[iSecTriggerIndex] < dTotDistanceToMain ) - { - bAllInCoinc = kFALSE; - break; - } // if out of coincidence window - } // for( UInt_t uSecChannel = 0; uSecChannel < fParam->uNbSecondarySelectionCh[iSecTriggerIndex]; uSecChannel++) - - // Check if tot edge of the main channel is in trigger window, only needed in 24b mode - Double_t dTotMainDistanceToMain = ROC[uRocId].fdLastFullTimeMainChannelTot[iSecTriggerIndex] - - ROC[uRocId].fextMessLastMainChannel[iSecTriggerIndex].GetFullTimeD(); - if( dTotMainDistanceToMain < fParam->dCoincidenceWindowStart[iSecTriggerIndex] || - fParam->dCoincidenceWindowStop[iSecTriggerIndex] < dTotMainDistanceToMain ) - { - bAllInCoinc = kFALSE; - } // if out of coincidence window - - if( kTRUE == bAllInCoinc ) - { - Double_t dSameTriggerDistance = - ROC[uRocId].fextMessLastMainChannel[iSecTriggerIndex].GetFullTimeD() - - ROC[uRocId].fdLastFullTimeSelfTrigger[iSecTriggerIndex] ; - - ROC[uRocId].fDataSelfTrigDistanceNs->Fill( dSameTriggerDistance, iSecTriggerIndex ); - ROC[uRocId].fDataSelfTrigDistanceUs->Fill( dSameTriggerDistance/1e3, iSecTriggerIndex ); - ROC[uRocId].fDataSelfTrigDistanceMs->Fill( dSameTriggerDistance/1e6, iSecTriggerIndex ); - ROC[uRocId].fDataSelfTrigDistanceS->Fill( dSameTriggerDistance/1e9, iSecTriggerIndex ); - - if( fParam->dDeadTime <= dSameTriggerDistance ) - { - // Here we have a DATA self-trigger!!!!!! - ROC[uRocId].fuDataSelfTriggerCount[iSecTriggerIndex] ++; - - ROC[uRocId].fdLastFullTimeSelfTrigger[iSecTriggerIndex] = - ROC[uRocId].fextMessLastMainChannel[iSecTriggerIndex].GetFullTimeD(); - - ULong64_t uFullTimeSelfTrigBins = ROC[uRocId].fextMessLastMainChannel[iSecTriggerIndex].GetFullTime(); - uFullTimeSelfTrigBins /= 100000000L; - ROC[uRocId].fSelfTriggT->Fill( (uFullTimeSelfTrigBins % 36000) * 0.1 ); - - // Long duration time distribution (1 min. bin, 10 days length) - if( kTRUE == fParam->bLongTimeHistos ) - ROC[uRocId].fSelfTriggLongT->Fill( (uFullTimeSelfTrigBins * 0.1 ) / 3600 ); - - ProcessTriggerMessage(uRocId, ROC[uRocId].fextMessLastMainChannel[iSecTriggerIndex], iSecTriggerIndex); - } // if( fParam->dDeadTime <= dSameTriggerDistance ) - } // if( kTRUE == bAllInCoinc ) - } // if( -1 < iSecondaryIndex ) - } // if( -1 < iSecTriggerIndex ) - } // for( Int_t iSecTriggerIndex = 0; iSecTriggerIndex < (Int_t)(fParam->uNbTriggers); iSecTriggerIndex++ ) - }// if( 0 == uGet4Edge ) - /** Falling edge: Triggering on Data, only needed in 24b mode **/ - else - { - // Falling edge - for( Int_t iMainTriggerIndex = 0; iMainTriggerIndex < (Int_t)(fParam->uNbTriggers); iMainTriggerIndex++ ) - if( kTRUE == fParam->IsMainOfThisTrigger( iMainTriggerIndex, uGet4Id, uGet4Ch ) ) - { - ROC[uRocId].fdLastFullTimeMainChannelTot[iMainTriggerIndex] = extMess.GetFullTimeD(); - - Bool_t bAllInCoinc = kTRUE; - for( UInt_t uSecChannel = 0; uSecChannel < fParam->uNbSecondarySelectionCh[iMainTriggerIndex]; uSecChannel++) - { - // Check if time edge is in trigger window - Double_t dDistanceToMain = ROC[uRocId].fdLastFullTimeSecChannel[iMainTriggerIndex][uSecChannel] - - ROC[uRocId].fextMessLastMainChannel[iMainTriggerIndex].GetFullTimeD(); - if( dDistanceToMain < fParam->dCoincidenceWindowStart[iMainTriggerIndex] || - fParam->dCoincidenceWindowStop[iMainTriggerIndex] < dDistanceToMain ) - { - bAllInCoinc = kFALSE; - break; - } // if out of coincidence window - - // Check if tot edge is in trigger window, only needed in 24b mode - Double_t dTotDistanceToMain = ROC[uRocId].fdLastFullTimeSecChannelTot[iMainTriggerIndex][uSecChannel] - - ROC[uRocId].fextMessLastMainChannel[iMainTriggerIndex].GetFullTimeD(); - if( dTotDistanceToMain < fParam->dCoincidenceWindowStart[iMainTriggerIndex] || - fParam->dCoincidenceWindowStop[iMainTriggerIndex] < dTotDistanceToMain ) - { - bAllInCoinc = kFALSE; - break; - } // if out of coincidence window - } // for( UInt_t uSecChannel = 0; uSecChannel < fParam->uNbSecondarySelectionCh[iMainTriggerIndex]; uSecChannel++) - - // Check if tot edge of the main channel is in trigger window, only needed in 24b mode - Double_t dTotMainDistanceToMain = ROC[uRocId].fdLastFullTimeMainChannelTot[iMainTriggerIndex] - - ROC[uRocId].fextMessLastMainChannel[iMainTriggerIndex].GetFullTimeD(); - if( dTotMainDistanceToMain < fParam->dCoincidenceWindowStart[iMainTriggerIndex] || - fParam->dCoincidenceWindowStop[iMainTriggerIndex] < dTotMainDistanceToMain ) - { - bAllInCoinc = kFALSE; - } // if out of coincidence window - - if( kTRUE == bAllInCoinc ) - { - Double_t dSameTriggerDistance = - ROC[uRocId].fextMessLastMainChannel[iMainTriggerIndex].GetFullTimeD() - - ROC[uRocId].fdLastFullTimeSelfTrigger[iMainTriggerIndex] ; - - ROC[uRocId].fDataSelfTrigDistanceNs->Fill( dSameTriggerDistance, iMainTriggerIndex ); - ROC[uRocId].fDataSelfTrigDistanceUs->Fill( dSameTriggerDistance/1e3, iMainTriggerIndex ); - ROC[uRocId].fDataSelfTrigDistanceMs->Fill( dSameTriggerDistance/1e6, iMainTriggerIndex ); - ROC[uRocId].fDataSelfTrigDistanceS->Fill( dSameTriggerDistance/1e9, iMainTriggerIndex ); - - if( fParam->dDeadTime <= dSameTriggerDistance ) - { - // Here we have a DATA self-trigger!!!!!! - ROC[uRocId].fuDataSelfTriggerCount[iMainTriggerIndex] ++; - - ROC[uRocId].fdLastFullTimeSelfTrigger[iMainTriggerIndex] = - ROC[uRocId].fextMessLastMainChannel[iMainTriggerIndex].GetFullTimeD(); - - ULong64_t uFullTimeSelfTrigBins = ROC[uRocId].fextMessLastMainChannel[iMainTriggerIndex].GetFullTime(); - uFullTimeSelfTrigBins /= 100000000L; - ROC[uRocId].fSelfTriggT->Fill( (uFullTimeSelfTrigBins % 36000) * 0.1 ); - - // Long duration time distribution (1 min. bin, 10 days length) - if( kTRUE == fParam->bLongTimeHistos ) - ROC[uRocId].fSelfTriggLongT->Fill( (uFullTimeSelfTrigBins * 0.1 ) / 3600 ); - - ProcessTriggerMessage(uRocId, ROC[uRocId].fextMessLastMainChannel[iMainTriggerIndex], iMainTriggerIndex); - } // if( fParam->dDeadTime <= dSameTriggerDistance ) - } // if( kTRUE == bAllInCoinc ) - } // if( kTRUE == fParam->IsMainOfThisTrigger( iMainTriggerIndex, uGet4Id, uGet4Ch ) ) - - for( Int_t iSecTriggerIndex = 0; iSecTriggerIndex < (Int_t)(fParam->uNbTriggers); iSecTriggerIndex++ ) - { - if( kTRUE == fParam->IsSecOfThisTrigger( iSecTriggerIndex, uGet4Id, uGet4Ch ) ) - { - Int_t iSecondaryIndex = fParam->GetSecChannelIndex(iSecTriggerIndex, uGet4Id, uGet4Ch); - if( -1 < iSecondaryIndex ) - { - ROC[uRocId].fdLastFullTimeSecChannelTot[iSecTriggerIndex][iSecondaryIndex] = extMess.GetFullTimeD(); - - Bool_t bAllInCoinc = kTRUE; - for( UInt_t uSecChannel = 0; uSecChannel < fParam->uNbSecondarySelectionCh[iSecTriggerIndex]; uSecChannel++) - { - // Check if time edge is in trigger window - Double_t dDistanceToMain = ROC[uRocId].fdLastFullTimeSecChannel[iSecTriggerIndex][uSecChannel] - - ROC[uRocId].fextMessLastMainChannel[iSecTriggerIndex].GetFullTimeD(); - if( dDistanceToMain < fParam->dCoincidenceWindowStart[iSecTriggerIndex] || - fParam->dCoincidenceWindowStop[iSecTriggerIndex] < dDistanceToMain ) - { - bAllInCoinc = kFALSE; - break; - } // if out of coincidence window - - // Check if tot edge is in trigger window - Double_t dTotDistanceToMain = ROC[uRocId].fdLastFullTimeSecChannelTot[iSecTriggerIndex][uSecChannel] - - ROC[uRocId].fextMessLastMainChannel[iSecTriggerIndex].GetFullTimeD(); - if( dTotDistanceToMain < fParam->dCoincidenceWindowStart[iSecTriggerIndex] || - fParam->dCoincidenceWindowStop[iSecTriggerIndex] < dTotDistanceToMain ) - { - bAllInCoinc = kFALSE; - break; - } // if out of coincidence window - } // for( UInt_t uSecChannel = 0; uSecChannel < fParam->uNbSecondarySelectionCh[iSecTriggerIndex]; uSecChannel++) - - // Check if tot edge of the main channel is in trigger window - Double_t dTotMainDistanceToMain = ROC[uRocId].fdLastFullTimeMainChannelTot[iSecTriggerIndex] - - ROC[uRocId].fextMessLastMainChannel[iSecTriggerIndex].GetFullTimeD(); - if( dTotMainDistanceToMain < fParam->dCoincidenceWindowStart[iSecTriggerIndex] || - fParam->dCoincidenceWindowStop[iSecTriggerIndex] < dTotMainDistanceToMain ) - { - bAllInCoinc = kFALSE; - } // if out of coincidence window - - if( kTRUE == bAllInCoinc ) - { - Double_t dSameTriggerDistance = - ROC[uRocId].fextMessLastMainChannel[iSecTriggerIndex].GetFullTimeD() - - ROC[uRocId].fdLastFullTimeSelfTrigger[iSecTriggerIndex] ; - - ROC[uRocId].fDataSelfTrigDistanceNs->Fill( dSameTriggerDistance, iSecTriggerIndex ); - ROC[uRocId].fDataSelfTrigDistanceUs->Fill( dSameTriggerDistance/1e3, iSecTriggerIndex ); - ROC[uRocId].fDataSelfTrigDistanceMs->Fill( dSameTriggerDistance/1e6, iSecTriggerIndex ); - ROC[uRocId].fDataSelfTrigDistanceS->Fill( dSameTriggerDistance/1e9, iSecTriggerIndex ); - - if( fParam->dDeadTime <= dSameTriggerDistance ) - { - // Here we have a DATA self-trigger!!!!!! - ROC[uRocId].fuDataSelfTriggerCount[iSecTriggerIndex] ++; - - ROC[uRocId].fdLastFullTimeSelfTrigger[iSecTriggerIndex] = - ROC[uRocId].fextMessLastMainChannel[iSecTriggerIndex].GetFullTimeD(); - - ULong64_t uFullTimeSelfTrigBins = ROC[uRocId].fextMessLastMainChannel[iSecTriggerIndex].GetFullTime(); - uFullTimeSelfTrigBins /= 100000000L; - ROC[uRocId].fSelfTriggT->Fill( (uFullTimeSelfTrigBins % 36000) * 0.1 ); - - // Long duration time distribution (1 min. bin, 10 days length) - if( kTRUE == fParam->bLongTimeHistos ) - ROC[uRocId].fSelfTriggLongT->Fill( (uFullTimeSelfTrigBins * 0.1 ) / 3600 ); - - ProcessTriggerMessage(uRocId, ROC[uRocId].fextMessLastMainChannel[iSecTriggerIndex], iSecTriggerIndex); - } // if( fParam->dDeadTime <= dSameTriggerDistance ) - } // if( kTRUE == bAllInCoinc ) - } // if( -1 < iSecondaryIndex ) - } // if( kTRUE == fParam->IsSecOfThisTrigger( iSecTriggerIndex, uGet4Id, uGet4Ch ) ) - } // for( Int_t iSecTriggerIndex = 0; iSecTriggerIndex < (Int_t)(fParam->uNbTriggers); iSecTriggerIndex++ ) - } // else if( 0 == uGet4Edge ) - } // if( kTRUE == fParam->bFreeStreaming && 0 < fParam->uNbTriggers && 0 == uGet4Edge ) - - return kTRUE; -} -/**********************************************************************/ -/* - * This function process the data message when it is a GET4 External Synch - */ -Bool_t TTofGet4Unpacker::ProcessGet4ExtSyncMessage( UInt_t /*uRocId*/, TGet4v1MessageExtended& /*extMess*/ ) -{ - /* TODO FILL ME - * 24bit Get4 external sync message specific processing - */ - return kTRUE; -} -/**********************************************************************/ -/* - * This function process the data message when it is a GET4 epoch message - * In suppressed empty epochs 2 mode - */ -Bool_t TTofGet4Unpacker::ProcessGet4SuppEpochMessage( UInt_t uRocId, TGet4v1MessageExtended& extMess ) -{ - /* - * 24bit Get4 epoch message specific processing - */ - - UInt_t uGet4Id(0); - - // Remap the Get4 chip index => Go in Get4 indexing common to all ROCs - uGet4Id = (extMess.GetRocMessage()).getEpoch2ChipNumber(); - uGet4Id = fParam->RemapGet4Chip( fParam->DefineGet4IndexOffset(uRocId) + uGet4Id); - extMess.SetEpoch2ChipNumber(uGet4Id); - - // Check if active chip - if( kFALSE == fParam->IsValidGet4Chip(uGet4Id) ) - { - cout << "Error: Bad chip nb in Epoch message = " << uGet4Id << endl; - cout << " => This message will be skipped!!!! "<<endl; - return kFALSE; - } - if( kFALSE == fParam->IsActiveGet4Chip(uGet4Id) ) - { - // Masked chip, hopefully on purpose, don't complain & return - return kFALSE; - } - - UInt_t get4_24b_ep_epoch = (extMess.GetRocMessage()).getEpoch2Number(); - // No "non-consecutive epoch check" as in this mode they are by definition non consecutive - - // Event statistics - ROC[uRocId].fuNbHitsChipEpoch[uGet4Id] = 0; - - if( ROC[uRocId].fuCurrEpoch2[uGet4Id] > get4_24b_ep_epoch ) - { - TString sTemp = Form("Roc Epoch2 cycle (24b mode) change: %u", ROC[uRocId].fuEpoch2Cycle[uGet4Id]); - LOG(info)<<sTemp; - ROC[uRocId].fuEpoch2Cycle[uGet4Id]++; - } - ROC[uRocId].fuCurrEpoch2[uGet4Id] = get4_24b_ep_epoch; - - // Reprocess all data messages which where waiting for their epoch - if( 1 == ROC[uRocId].fuEpochWithData[uGet4Id] ) - { - ProcessGet4ReprocessSuppData( uRocId, uGet4Id ); - ROC[uRocId].fuEpochWithData[uGet4Id] = 0; - } - - // Self triggering - if( kTRUE == fCurrentGet4Event.HasTrigger() && kFALSE == ROC[uRocId].fbSelectionDone[uGet4Id] ) - { - // A trigger is ongoing on this chip! - if( kFALSE == ROC[uRocId].fbEpoch2SinceTrigger[uGet4Id] ) - { - // This is the first epoch after the trigger - // => time to look for the data in the epoch which was - // ongoing when the trigger was found - - // If we did not process the epoch before the one where the - // trigger came, we need to initialize the 24 bit temp hits - if( kFALSE == ROC[uRocId].bLookInPreviousEpoch[uGet4Id] ) - for( UInt_t uChan = 0; uChan < get4v10::kuNbChan; uChan++) - (ROC[uRocId].fHitTemp24[uGet4Id][uChan]).Clear(); - - BuildHits(uRocId, uGet4Id, ROC[uRocId].fbBufferWithLastFullEpoch2[uGet4Id]); - if( kFALSE == ROC[uRocId].bLookInNextEpoch[uGet4Id] ) - { - ROC[uRocId].fbSelectionDone[uGet4Id] = kTRUE; - CheckEventClosure(); - } - ROC[uRocId].fbEpoch2SinceTrigger[uGet4Id] = kTRUE; - } // if( kFALSE == ROC[uRocId].fbEpoch2SinceTrigger[uGet4Id] ) - else if( kTRUE == ROC[uRocId].fbEpoch2SinceTrigger[uGet4Id] && - kTRUE == ROC[uRocId].bLookInNextEpoch[uGet4Id]) - { - // This is the second epoch after the trigger and we detected on trigger - // that the trigger window extend in epoch after the one where trigger - // was found => time to look for the data in the epoch which just finished - // and was the one just after the trigger epoch - BuildHits(uRocId, uGet4Id, ROC[uRocId].fbBufferWithLastFullEpoch2[uGet4Id]); - ROC[uRocId].fbSelectionDone[uGet4Id] = kTRUE; - CheckEventClosure(); - } // else if( kTRUE == ROC[uRocId].fbEpoch2SinceTrigger[uGet4Id] && kFALSE == ROC[uRocId].bLookInNextEpoch[uGet4Id]) - } // if( kTRUE == fCurrentGet4Event.HasTrigger() && kFALSE == ROC[uRocId].fbSelectionDone[uGet4Id] ) - - // Recalculate the full Time to take into account also the epoch2 cycles - ULong64_t uFullTimeBins = ((ULong64_t) ROC[uRocId].GetFullEpoch2Number( uGet4Id )) << 19; - ULong64_t uFullTime = uFullTimeBins/ 20 + 512; - Double_t dFullTime = uFullTimeBins / 20. + 512.; - extMess.SetFullTime( uFullTime ); - extMess.SetFullTimeD( dFullTime ); - - // Set The ROC epoch2 counter and cycle counter - extMess.SetRocEpoch( ROC[uRocId].fuCurrEpoch2[uGet4Id] ); - extMess.SetRocCycle( ROC[uRocId].fuEpoch2Cycle[uGet4Id] ); - - // Count per global time unit in s - ULong64_t ulEpochTm = uFullTime / 100000000L; - ROC[uRocId].fEPOCH2t[uGet4Id]->Fill((ulEpochTm % 36000) * 0.1); - - // Long duration time distribution (1 min. bin, 10 days length) - if( kTRUE == fParam->bLongTimeHistos ) - ROC[uRocId].fAllEpoch2LongT->Fill( (ulEpochTm * 0.1 ) / 3600 ); - - ROC[uRocId].fDistribEpochs2->Fill(uGet4Id, ROC[uRocId].fuCurrEpoch2[uGet4Id]); - - // Swap the flag indicating which buffer contains currently happening epoch - ROC[uRocId].fbBufferWithLastFullEpoch2[uGet4Id] = ( kTRUE == ROC[uRocId].fbBufferWithLastFullEpoch2[uGet4Id] ? kFALSE: kTRUE ); - // Clear this buffer (Data more than 1 full epoch old => either already selected or junk) - ROC[uRocId].fPrevEpochs2Buffer[uGet4Id][ ROC[uRocId].fbBufferWithLastFullEpoch2[uGet4Id] ].clear(); - - return kTRUE; -} -/**********************************************************************/ -/* - * This function process the data message when it is a GET4 data message - */ -Bool_t TTofGet4Unpacker::ProcessGet4SuppDataMessage( UInt_t uRocId, TGet4v1MessageExtended& extMess ) -{ - /* - * 24bit Get4 hit message specific processing - * In case of suppressed epochs, we will have no epoch2 message for all empty epochs - * However, when a chip has data, its next epoch message should be present!!! - * => need a flag to use the proper epoch message when its the case - * - * TODO - * Make the get4_index consistent everywhere between global get4 index and inside roc get4 index - */ - - if (ROC[uRocId].bIgnoreData) return kFALSE; - - if( kFALSE == ROC[uRocId].fb24bitsReadoutDetected ) - { - ROC[uRocId].fb24bitsReadoutDetected = kTRUE; - fb24bitsReadoutDetected = kTRUE; - // As it is first 24bit message, let's create - // 24bit specific histograms - char folder[30]; - sprintf(folder,"ROC%u/",uRocId); - - /* - * 24 bits specific histograms - */ - ROC[uRocId].fChannelInputMessCount = new TH1I( Form("Roc%u_ChanCounts", uRocId), - "Channel multiplicity per event; Channel []; # Mess []", - 2*get4v10::kuNbChan*get4v10::kuMaxGet4Roc, 0, get4v10::kuMaxGet4Roc ); - ROC[uRocId].fb24bitsReadoutDetected = kTRUE; - } // if( kFALSE == ROC[uRocId].fb24bitsReadoutDetected ) - - UInt_t uGet4Id(0); -// UInt_t uGet4Ch(0); // -> Comment to remove warning because set but never used -// UInt_t uGet4Edge(0); // -> Comment to remove warning because set but never used - uGet4Id = (extMess.GetRocMessage()).getGet4Number(); -// uGet4Ch = (extMess.GetRocMessage()).getGet4ChNum(); // -> Comment to remove warning because set but never used -// uGet4Edge = (extMess.GetRocMessage()).getGet4Edge(); // -> Comment to remove warning because set but never used - - // Remap the Get4 chip index - uGet4Id = (extMess.GetRocMessage()).getGet4Number(); - uGet4Id = fParam->RemapGet4Chip( fParam->DefineGet4IndexOffset(uRocId) + uGet4Id); - extMess.SetGet4Number(uGet4Id); - - // Check if valid chip - if( kFALSE == fParam->IsValidGet4Chip(uGet4Id) ) - { - cout << "Error: Bad chip nb in Data message = " << uGet4Id << endl; - cout << " => This message will be skipped!!!! "<<endl; - return kFALSE; - } - if( kFALSE == fParam->IsActiveGet4Chip(uGet4Id) ) - { - // Masked chip, hopefully on purpose, don't complain & return - return kFALSE; - } - - // => need a flag to use the proper epoch message when its the case - ROC[uRocId].fuEpochWithData[uGet4Id] = 1; - - // Store data message in temporary buffer to wait for the next epoch message - ROC[uRocId].fEpSuppBuffer[uGet4Id].push_back( extMess ); - - return kTRUE; -} - -/**********************************************************************/ -/* - * This function reprocess the data message from a GET4 in empty epoch suppression - * mode once its next epoch message is found - */ -Bool_t TTofGet4Unpacker::ProcessGet4ReprocessSuppData( UInt_t uRocId, UInt_t uGet4Id ) -{ - /* - * 24bit Get4 hit message specific processing - * In case of suppressed epochs, we will have no epoch2 message for all empty epochs - * However, when a chip has data, its next epoch message should be present just after all data!!! - * => there should not be more than 1 epoch waiting time before reprocessing - * - * TODO - * Make the get4_index consistent everywhere between global get4 index and inside roc get4 index - */ - // Loop over the temporary buffer - for( UInt_t uDataIndex = 0; uDataIndex < ROC[uRocId].fEpSuppBuffer[uGet4Id].size(); uDataIndex++ ) - { - TGet4v1MessageExtended extMess = ROC[uRocId].fEpSuppBuffer[uGet4Id][uDataIndex]; - UInt_t uGet4Ch(0), uGet4Edge(0); - uGet4Ch = (extMess.GetRocMessage()).getGet4ChNum(); - uGet4Edge = (extMess.GetRocMessage()).getGet4Edge(); - - // Recalculate the full Time to take into account also the epoch2 cycles - ULong64_t uFullTimeBins = ((ULong64_t) ( ROC[uRocId].GetFullEpoch2Number( uGet4Id ) - 1 ) << 19) | - (ULong64_t)extMess.GetGet4Ts(); - ULong64_t uFullTime = uFullTimeBins/ 20 + 512; - Double_t dFullTime = ((Double_t)uFullTimeBins)*0.05 + 512.; - extMess.SetFullTime( uFullTime ); - extMess.SetFullTimeD( dFullTime ); - - // Set The ROC epoch2 counter and cycle counter - extMess.SetRocEpoch( ROC[uRocId].fuCurrEpoch2[uGet4Id] ); - extMess.SetRocCycle( ROC[uRocId].fuEpoch2Cycle[uGet4Id] ); - - - // Count per global time unit in s - ULong64_t ulDataTm = uFullTime / 100000000L; - ROC[uRocId].fDATAt->Fill((ulDataTm % 36000) * 0.1); - - // Long duration time distribution (1 min. bin, 10 days length) - if( kTRUE == fParam->bLongTimeHistos ) - ROC[uRocId].fDataLongT->Fill( (ulDataTm * 0.1 ) / 3600 ); - - // Event statistics - ROC[uRocId].fChannelInputMessCount->Fill( uGet4Id + (Double_t)uGet4Ch/(Double_t)get4v10::kuNbChan - + (Double_t)uGet4Edge/(Double_t)(2*get4v10::kuNbChan) ); - if( kTRUE == fParam->bChipRateHistoEnable ) - ROC[uRocId].fChipRateEvolution[uGet4Id]->Fill( - (uFullTimeBins ) * 0.1, 1.0/ROC[uRocId].fdRateEvolutionBinSize ); - if( kTRUE == fParam->bChannelRateHistoEnable ) - ROC[uRocId].fChannelRateEvolution[uGet4Id][uGet4Ch]->Fill( - (uFullTimeBins ) * 0.1, 1.0/ROC[uRocId].fdRateEvolutionBinSize ); - ROC[uRocId].fuNbHitsChipEpoch[uGet4Id] ++; - - // Early event closure check - if( kTRUE == fCurrentGet4Event.HasTrigger() && - kFALSE == ROC[uRocId].fbSelectionDone[uGet4Id] ) - { - Double_t dTimeToTrigger = 0.0; - dTimeToTrigger = extMess.GetFullTimeD() - fCurrentGet4Event.fdTriggerFullTime[uRocId]; - if( kFALSE == ROC[uRocId].fTriggerWind->Test( dTimeToTrigger) ) - { - // Message after the end of trigger window!! - Bool_t bAllChanInChipOver = kTRUE; - - // If there was already a message from the same channel & edge out of the trigger - // window, then the token ring made at least one full turn => ok for all - // Otherwise: need to check other channels/edge status - if( (kFALSE == ROC[uRocId].fbDataTimeOut[uGet4Id][uGet4Ch] && 0 == uGet4Edge ) || - (kFALSE == ROC[uRocId].fbDataFallingOut[uGet4Id][uGet4Ch] && 1 == uGet4Edge ) ) - { - // 24b = always a edge not a hit => need to check both ! - if( 0 == uGet4Edge ) - ROC[uRocId].fbDataTimeOut[uGet4Id][uGet4Ch] = kTRUE; - else ROC[uRocId].fbDataFallingOut[uGet4Id][uGet4Ch] = kTRUE; - // Check if chip fully finished - for(UInt_t uChanTest = 0; uChanTest < get4v10::kuNbChan; uChanTest ++) - { - if( kFALSE == ROC[uRocId].fbDataTimeOut[uGet4Id][uChanTest] ) - bAllChanInChipOver = kFALSE; - if( kFALSE == ROC[uRocId].fbDataFallingOut[uGet4Id][uChanTest] ) - bAllChanInChipOver = kFALSE; - } - } // if same edge not already out of trigger once - - // If chip fully finished: don't wait for the next epoch to close future buffer - // of current event for this chip - if( kTRUE == bAllChanInChipOver) - { - // If This is the first epoch after the trigger and - // we did not process the epoch before the one where the - // trigger came, we need to initialize the 24 bit temp hits - if( kFALSE == ROC[uRocId].fbEpoch2SinceTrigger[uGet4Id] && - kFALSE == ROC[uRocId].bLookInPreviousEpoch[uGet4Id] ) - for( UInt_t uChan = 0; uChan < get4v10::kuNbChan; uChan++) - (ROC[uRocId].fHitTemp24[uGet4Id][uChan]).Clear(); - - BuildHits(uRocId, uGet4Id, ROC[uRocId].fbBufferWithLastFullEpoch2[uGet4Id]); - ROC[uRocId].fbSelectionDone[uGet4Id] = kTRUE; - CheckEventClosure(); - - for(UInt_t uChanTest = 0; uChanTest < get4v10::kuNbChan; uChanTest ++) - { - ROC[uRocId].fbDataTimeOut[uGet4Id][uChanTest] = kFALSE; - ROC[uRocId].fbDataFallingOut[uGet4Id][uChanTest] = kFALSE; - } - } // if( kTRUE == bAllChanInChipOver) - } // if( kFALSE == ROC[uRocId].fTriggerWind->Test( dTimeToTrigger) ) - } // Event ongoing with a detected trigger and chip did not finished all its buffers - - /** Triggering on Data **/ - if( kTRUE == fParam->bFreeStreaming && 0 < fParam->uNbTriggers ) - { - /** Rising edge: Triggering on Data **/ - if( 0 == uGet4Edge ) - { - for( Int_t iMainTriggerIndex = 0; iMainTriggerIndex < (Int_t)(fParam->uNbTriggers); iMainTriggerIndex++ ) - if( kTRUE == fParam->IsMainOfThisTrigger( iMainTriggerIndex, uGet4Id, uGet4Ch ) ) - { - ROC[uRocId].fextMessLastMainChannel[iMainTriggerIndex] = extMess; - /* - * TODO: call to ProcessTrigger - * TEMP: histo Filling + counting - */ - Bool_t bAllInCoinc = kTRUE; - for( UInt_t uSecChannel = 0; uSecChannel < fParam->uNbSecondarySelectionCh[iMainTriggerIndex]; uSecChannel++) - { - Double_t dDistanceToMain = ROC[uRocId].fdLastFullTimeSecChannel[iMainTriggerIndex][uSecChannel] - - extMess.GetFullTimeD(); - if( dDistanceToMain < fParam->dCoincidenceWindowStart[iMainTriggerIndex] || - fParam->dCoincidenceWindowStop[iMainTriggerIndex] < dDistanceToMain ) - { - bAllInCoinc = kFALSE; - break; - } // if out of coincidence window - Double_t dTotDistanceToMain = ROC[uRocId].fdLastFullTimeSecChannelTot[iMainTriggerIndex][uSecChannel] - - extMess.GetFullTimeD(); - if( dTotDistanceToMain < fParam->dCoincidenceWindowStart[iMainTriggerIndex] || - fParam->dCoincidenceWindowStop[iMainTriggerIndex] < dTotDistanceToMain ) - { - bAllInCoinc = kFALSE; - break; - } // if out of coincidence window - } // for( UInt_t uSecChannel = 0; uSecChannel < fParam->uNbSecondarySelectionCh[iMainTriggerIndex]; uSecChannel++) - - // Check if tot edge of the main channel is in trigger window - Double_t dTotMainDistanceToMain = ROC[uRocId].fdLastFullTimeMainChannelTot[iMainTriggerIndex] - - ROC[uRocId].fextMessLastMainChannel[iMainTriggerIndex].GetFullTimeD(); - if( dTotMainDistanceToMain < fParam->dCoincidenceWindowStart[iMainTriggerIndex] || - fParam->dCoincidenceWindowStop[iMainTriggerIndex] < dTotMainDistanceToMain ) - { - bAllInCoinc = kFALSE; - } // if out of coincidence window - - if( kTRUE == bAllInCoinc ) - { - Double_t dSameTriggerDistance = - ROC[uRocId].fextMessLastMainChannel[iMainTriggerIndex].GetFullTimeD() - - ROC[uRocId].fdLastFullTimeSelfTrigger[iMainTriggerIndex] ; - - ROC[uRocId].fDataSelfTrigDistanceNs->Fill( dSameTriggerDistance, iMainTriggerIndex ); - ROC[uRocId].fDataSelfTrigDistanceUs->Fill( dSameTriggerDistance/1e3, iMainTriggerIndex ); - ROC[uRocId].fDataSelfTrigDistanceMs->Fill( dSameTriggerDistance/1e6, iMainTriggerIndex ); - ROC[uRocId].fDataSelfTrigDistanceS->Fill( dSameTriggerDistance/1e9, iMainTriggerIndex ); - - if( fParam->dDeadTime <= dSameTriggerDistance ) - { - // Here we have a DATA self-trigger!!!!!! - ROC[uRocId].fuDataSelfTriggerCount[iMainTriggerIndex] ++; - - ROC[uRocId].fdLastFullTimeSelfTrigger[iMainTriggerIndex] = - ROC[uRocId].fextMessLastMainChannel[iMainTriggerIndex].GetFullTimeD(); - - ULong64_t uFullTimeSelfTrigBins = ROC[uRocId].fextMessLastMainChannel[iMainTriggerIndex].GetFullTime(); - uFullTimeSelfTrigBins /= 100000000L; - ROC[uRocId].fSelfTriggT->Fill( (uFullTimeSelfTrigBins % 36000) * 0.1 ); - - // Long duration time distribution (1 min. bin, 10 days length) - if( kTRUE == fParam->bLongTimeHistos ) - ROC[uRocId].fSelfTriggLongT->Fill( (uFullTimeSelfTrigBins * 0.1 ) / 3600 ); - - ProcessTriggerMessage(uRocId, ROC[uRocId].fextMessLastMainChannel[iMainTriggerIndex], iMainTriggerIndex); - } // if( fParam->dDeadTime <= dSameTriggerDistance ) - } // if( kTRUE == bAllInCoinc ) - } // if( -1 < iMainTriggerIndex ) - - for( Int_t iSecTriggerIndex = 0; iSecTriggerIndex < (Int_t)(fParam->uNbTriggers); iSecTriggerIndex++ ) - { - if( kTRUE == fParam->IsSecOfThisTrigger( iSecTriggerIndex, uGet4Id, uGet4Ch ) ) - { - Int_t iSecondaryIndex = fParam->GetSecChannelIndex(iSecTriggerIndex, uGet4Id, uGet4Ch); - if( -1 < iSecondaryIndex ) - { - ROC[uRocId].fdLastFullTimeSecChannel[iSecTriggerIndex][iSecondaryIndex] = extMess.GetFullTimeD(); - - /* - * TODO: call to ProcessTrigger - * TEMP: histo Filling + counting - */ - Bool_t bAllInCoinc = kTRUE; - for( UInt_t uSecChannel = 0; uSecChannel < fParam->uNbSecondarySelectionCh[iSecTriggerIndex]; uSecChannel++) - { - Double_t dDistanceToMain = ROC[uRocId].fdLastFullTimeSecChannel[iSecTriggerIndex][uSecChannel] - - ROC[uRocId].fextMessLastMainChannel[iSecTriggerIndex].GetFullTimeD(); - if( dDistanceToMain < fParam->dCoincidenceWindowStart[iSecTriggerIndex] || - fParam->dCoincidenceWindowStop[iSecTriggerIndex] < dDistanceToMain ) - { - bAllInCoinc = kFALSE; - break; - } // if out of coincidence window - - // Check if tot edge is in trigger window, only needed in 24b mode - Double_t dTotDistanceToMain = ROC[uRocId].fdLastFullTimeSecChannelTot[iSecTriggerIndex][uSecChannel] - - ROC[uRocId].fextMessLastMainChannel[iSecTriggerIndex].GetFullTimeD(); - if( dTotDistanceToMain < fParam->dCoincidenceWindowStart[iSecTriggerIndex] || - fParam->dCoincidenceWindowStop[iSecTriggerIndex] < dTotDistanceToMain ) - { - bAllInCoinc = kFALSE; - break; - } // if out of coincidence window - } // for( UInt_t uSecChannel = 0; uSecChannel < fParam->uNbSecondarySelectionCh[iSecTriggerIndex]; uSecChannel++) - - // Check if tot edge of the main channel is in trigger window, only needed in 24b mode - Double_t dTotMainDistanceToMain = ROC[uRocId].fdLastFullTimeMainChannelTot[iSecTriggerIndex] - - ROC[uRocId].fextMessLastMainChannel[iSecTriggerIndex].GetFullTimeD(); - if( dTotMainDistanceToMain < fParam->dCoincidenceWindowStart[iSecTriggerIndex] || - fParam->dCoincidenceWindowStop[iSecTriggerIndex] < dTotMainDistanceToMain ) - { - bAllInCoinc = kFALSE; - } // if out of coincidence window - - if( kTRUE == bAllInCoinc ) - { - Double_t dSameTriggerDistance = - ROC[uRocId].fextMessLastMainChannel[iSecTriggerIndex].GetFullTimeD() - - ROC[uRocId].fdLastFullTimeSelfTrigger[iSecTriggerIndex] ; - - ROC[uRocId].fDataSelfTrigDistanceNs->Fill( dSameTriggerDistance, iSecTriggerIndex ); - ROC[uRocId].fDataSelfTrigDistanceUs->Fill( dSameTriggerDistance/1e3, iSecTriggerIndex ); - ROC[uRocId].fDataSelfTrigDistanceMs->Fill( dSameTriggerDistance/1e6, iSecTriggerIndex ); - ROC[uRocId].fDataSelfTrigDistanceS->Fill( dSameTriggerDistance/1e9, iSecTriggerIndex ); - - if( fParam->dDeadTime <= dSameTriggerDistance ) - { - // Here we have a DATA self-trigger!!!!!! - ROC[uRocId].fuDataSelfTriggerCount[iSecTriggerIndex] ++; - - ROC[uRocId].fdLastFullTimeSelfTrigger[iSecTriggerIndex] = - ROC[uRocId].fextMessLastMainChannel[iSecTriggerIndex].GetFullTimeD(); - - ULong64_t uFullTimeSelfTrigBins = ROC[uRocId].fextMessLastMainChannel[iSecTriggerIndex].GetFullTime(); - uFullTimeSelfTrigBins /= 100000000L; - ROC[uRocId].fSelfTriggT->Fill( (uFullTimeSelfTrigBins % 36000) * 0.1 ); - - // Long duration time distribution (1 min. bin, 10 days length) - if( kTRUE == fParam->bLongTimeHistos ) - ROC[uRocId].fSelfTriggLongT->Fill( (uFullTimeSelfTrigBins * 0.1 ) / 3600 ); - - ProcessTriggerMessage(uRocId, ROC[uRocId].fextMessLastMainChannel[iSecTriggerIndex], iSecTriggerIndex); - } // if( fParam->dDeadTime <= dSameTriggerDistance ) - } // if( kTRUE == bAllInCoinc ) - } // if( -1 < iSecondaryIndex ) - } // if( -1 < iSecTriggerIndex ) - } // for( Int_t iSecTriggerIndex = 0; iSecTriggerIndex < (Int_t)(fParam->uNbTriggers); iSecTriggerIndex++ ) - }// if( 0 == uGet4Edge ) - /** Falling edge: Triggering on Data, only needed in 24b mode **/ - else - { - // Falling edge - for( Int_t iMainTriggerIndex = 0; iMainTriggerIndex < (Int_t)(fParam->uNbTriggers); iMainTriggerIndex++ ) - if( kTRUE == fParam->IsMainOfThisTrigger( iMainTriggerIndex, uGet4Id, uGet4Ch ) ) - { - ROC[uRocId].fdLastFullTimeMainChannelTot[iMainTriggerIndex] = extMess.GetFullTimeD(); - - Bool_t bAllInCoinc = kTRUE; - for( UInt_t uSecChannel = 0; uSecChannel < fParam->uNbSecondarySelectionCh[iMainTriggerIndex]; uSecChannel++) - { - // Check if time edge is in trigger window - Double_t dDistanceToMain = ROC[uRocId].fdLastFullTimeSecChannel[iMainTriggerIndex][uSecChannel] - - ROC[uRocId].fextMessLastMainChannel[iMainTriggerIndex].GetFullTimeD(); - if( dDistanceToMain < fParam->dCoincidenceWindowStart[iMainTriggerIndex] || - fParam->dCoincidenceWindowStop[iMainTriggerIndex] < dDistanceToMain ) - { - bAllInCoinc = kFALSE; - break; - } // if out of coincidence window - - // Check if tot edge is in trigger window, only needed in 24b mode - Double_t dTotDistanceToMain = ROC[uRocId].fdLastFullTimeSecChannelTot[iMainTriggerIndex][uSecChannel] - - ROC[uRocId].fextMessLastMainChannel[iMainTriggerIndex].GetFullTimeD(); - if( dTotDistanceToMain < fParam->dCoincidenceWindowStart[iMainTriggerIndex] || - fParam->dCoincidenceWindowStop[iMainTriggerIndex] < dTotDistanceToMain ) - { - bAllInCoinc = kFALSE; - break; - } // if out of coincidence window - } // for( UInt_t uSecChannel = 0; uSecChannel < fParam->uNbSecondarySelectionCh[iMainTriggerIndex]; uSecChannel++) - - // Check if tot edge of the main channel is in trigger window, only needed in 24b mode - Double_t dTotMainDistanceToMain = ROC[uRocId].fdLastFullTimeMainChannelTot[iMainTriggerIndex] - - ROC[uRocId].fextMessLastMainChannel[iMainTriggerIndex].GetFullTimeD(); - if( dTotMainDistanceToMain < fParam->dCoincidenceWindowStart[iMainTriggerIndex] || - fParam->dCoincidenceWindowStop[iMainTriggerIndex] < dTotMainDistanceToMain ) - { - bAllInCoinc = kFALSE; - } // if out of coincidence window - - if( kTRUE == bAllInCoinc ) - { - Double_t dSameTriggerDistance = - ROC[uRocId].fextMessLastMainChannel[iMainTriggerIndex].GetFullTimeD() - - ROC[uRocId].fdLastFullTimeSelfTrigger[iMainTriggerIndex] ; - - ROC[uRocId].fDataSelfTrigDistanceNs->Fill( dSameTriggerDistance, iMainTriggerIndex ); - ROC[uRocId].fDataSelfTrigDistanceUs->Fill( dSameTriggerDistance/1e3, iMainTriggerIndex ); - ROC[uRocId].fDataSelfTrigDistanceMs->Fill( dSameTriggerDistance/1e6, iMainTriggerIndex ); - ROC[uRocId].fDataSelfTrigDistanceS->Fill( dSameTriggerDistance/1e9, iMainTriggerIndex ); - - if( fParam->dDeadTime <= dSameTriggerDistance ) - { - // Here we have a DATA self-trigger!!!!!! - ROC[uRocId].fuDataSelfTriggerCount[iMainTriggerIndex] ++; - - ROC[uRocId].fdLastFullTimeSelfTrigger[iMainTriggerIndex] = - ROC[uRocId].fextMessLastMainChannel[iMainTriggerIndex].GetFullTimeD(); - - ULong64_t uFullTimeSelfTrigBins = ROC[uRocId].fextMessLastMainChannel[iMainTriggerIndex].GetFullTime(); - uFullTimeSelfTrigBins /= 100000000L; - ROC[uRocId].fSelfTriggT->Fill( (uFullTimeSelfTrigBins % 36000) * 0.1 ); - - // Long duration time distribution (1 min. bin, 10 days length) - if( kTRUE == fParam->bLongTimeHistos ) - ROC[uRocId].fSelfTriggLongT->Fill( (uFullTimeSelfTrigBins * 0.1 ) / 3600 ); - - ProcessTriggerMessage(uRocId, ROC[uRocId].fextMessLastMainChannel[iMainTriggerIndex], iMainTriggerIndex); - } // if( fParam->dDeadTime <= dSameTriggerDistance ) - } // if( kTRUE == bAllInCoinc ) - } // if( kTRUE == fParam->IsMainOfThisTrigger( iMainTriggerIndex, uGet4Id, uGet4Ch ) ) - - for( Int_t iSecTriggerIndex = 0; iSecTriggerIndex < (Int_t)(fParam->uNbTriggers); iSecTriggerIndex++ ) - { - if( kTRUE == fParam->IsSecOfThisTrigger( iSecTriggerIndex, uGet4Id, uGet4Ch ) ) - { - Int_t iSecondaryIndex = fParam->GetSecChannelIndex(iSecTriggerIndex, uGet4Id, uGet4Ch); - if( -1 < iSecondaryIndex ) - { - ROC[uRocId].fdLastFullTimeSecChannelTot[iSecTriggerIndex][iSecondaryIndex] = extMess.GetFullTimeD(); - - Bool_t bAllInCoinc = kTRUE; - for( UInt_t uSecChannel = 0; uSecChannel < fParam->uNbSecondarySelectionCh[iSecTriggerIndex]; uSecChannel++) - { - // Check if time edge is in trigger window - Double_t dDistanceToMain = ROC[uRocId].fdLastFullTimeSecChannel[iSecTriggerIndex][uSecChannel] - - ROC[uRocId].fextMessLastMainChannel[iSecTriggerIndex].GetFullTimeD(); - if( dDistanceToMain < fParam->dCoincidenceWindowStart[iSecTriggerIndex] || - fParam->dCoincidenceWindowStop[iSecTriggerIndex] < dDistanceToMain ) - { - bAllInCoinc = kFALSE; - break; - } // if out of coincidence window - - // Check if tot edge is in trigger window - Double_t dTotDistanceToMain = ROC[uRocId].fdLastFullTimeSecChannelTot[iSecTriggerIndex][uSecChannel] - - ROC[uRocId].fextMessLastMainChannel[iSecTriggerIndex].GetFullTimeD(); - if( dTotDistanceToMain < fParam->dCoincidenceWindowStart[iSecTriggerIndex] || - fParam->dCoincidenceWindowStop[iSecTriggerIndex] < dTotDistanceToMain ) - { - bAllInCoinc = kFALSE; - break; - } // if out of coincidence window - } // for( UInt_t uSecChannel = 0; uSecChannel < fParam->uNbSecondarySelectionCh[iSecTriggerIndex]; uSecChannel++) - - // Check if tot edge of the main channel is in trigger window - Double_t dTotMainDistanceToMain = ROC[uRocId].fdLastFullTimeMainChannelTot[iSecTriggerIndex] - - ROC[uRocId].fextMessLastMainChannel[iSecTriggerIndex].GetFullTimeD(); - if( dTotMainDistanceToMain < fParam->dCoincidenceWindowStart[iSecTriggerIndex] || - fParam->dCoincidenceWindowStop[iSecTriggerIndex] < dTotMainDistanceToMain ) - { - bAllInCoinc = kFALSE; - } // if out of coincidence window - - if( kTRUE == bAllInCoinc ) - { - Double_t dSameTriggerDistance = - ROC[uRocId].fextMessLastMainChannel[iSecTriggerIndex].GetFullTimeD() - - ROC[uRocId].fdLastFullTimeSelfTrigger[iSecTriggerIndex] ; - - ROC[uRocId].fDataSelfTrigDistanceNs->Fill( dSameTriggerDistance, iSecTriggerIndex ); - ROC[uRocId].fDataSelfTrigDistanceUs->Fill( dSameTriggerDistance/1e3, iSecTriggerIndex ); - ROC[uRocId].fDataSelfTrigDistanceMs->Fill( dSameTriggerDistance/1e6, iSecTriggerIndex ); - ROC[uRocId].fDataSelfTrigDistanceS->Fill( dSameTriggerDistance/1e9, iSecTriggerIndex ); - - if( fParam->dDeadTime <= dSameTriggerDistance ) - { - // Here we have a DATA self-trigger!!!!!! - ROC[uRocId].fuDataSelfTriggerCount[iSecTriggerIndex] ++; - - ROC[uRocId].fdLastFullTimeSelfTrigger[iSecTriggerIndex] = - ROC[uRocId].fextMessLastMainChannel[iSecTriggerIndex].GetFullTimeD(); - - ULong64_t uFullTimeSelfTrigBins = ROC[uRocId].fextMessLastMainChannel[iSecTriggerIndex].GetFullTime(); - uFullTimeSelfTrigBins /= 100000000L; - ROC[uRocId].fSelfTriggT->Fill( (uFullTimeSelfTrigBins % 36000) * 0.1 ); - - // Long duration time distribution (1 min. bin, 10 days length) - if( kTRUE == fParam->bLongTimeHistos ) - ROC[uRocId].fSelfTriggLongT->Fill( (uFullTimeSelfTrigBins * 0.1 ) / 3600 ); - - ProcessTriggerMessage(uRocId, ROC[uRocId].fextMessLastMainChannel[iSecTriggerIndex], iSecTriggerIndex); - } // if( fParam->dDeadTime <= dSameTriggerDistance ) - } // if( kTRUE == bAllInCoinc ) - } // if( -1 < iSecondaryIndex ) - } // if( kTRUE == fParam->IsSecOfThisTrigger( iSecTriggerIndex, uGet4Id, uGet4Ch ) ) - } // for( Int_t iSecTriggerIndex = 0; iSecTriggerIndex < (Int_t)(fParam->uNbTriggers); iSecTriggerIndex++ ) - } // else if( 0 == uGet4Edge ) - } // if( kTRUE == fParam->bFreeStreaming && 0 < fParam->uNbTriggers && 0 == uGet4Edge ) - - ProcessExtendedMessage(uRocId, extMess); - } // for( UInt_t uDataIndex = 0; uDataIndex < ROC[uRocId].fEpSuppBuffer[uGet4Id].size(); uDataIndex++ ) - ROC[uRocId].fEpSuppBuffer[uGet4Id].clear(); - - return kTRUE; -} -/**********************************************************************/ -Int_t TTofGet4Unpacker::Process32BitGet4Message( UInt_t uRocId, TGet4v1MessageExtended& extMess ) -{ - /* - * 32bit Get4 hit message specific processing - * TODO FILL ME - * Make the get4_index consistent everywhere between global get4 index and inside roc get4 index - */ - - UInt_t get4_index = extMess.getGet4V10R32ChipId() ; - get4_index = fParam->RemapGet4Chip(get4_index); - - // Check if valid chip - if( kFALSE == fParam->IsValidGet4Chip(get4_index) ) - { - cout << "Error: Bad chip nb in 32b Data message = " << get4_index <<" < "<<fParam->uNbGet4<< endl; - cout << " => This message will be skipped!!!! "<<endl; - return -1; - } - if( kFALSE == fParam->IsActiveGet4Chip(get4_index) ) - { - // Masked chip, hopefully on purpose, don't complain & return - return -1; - } - - // If 1 message is 32bits, all are! - if( kFALSE == ROC[uRocId].fb32bitsReadoutDetected ) - { - ROC[uRocId].fb32bitsReadoutDetected = kTRUE; - fb32bitsReadoutDetected = kTRUE; - // As it is first 32bit message, let's create - // 32bit specific histograms - char folder[30]; - sprintf(folder,"ROC%u/",uRocId); - - /* - * 32 bits specific histograms - */ - ROC[uRocId].fChannelInputMessCount = new TH1I( Form("Roc%u_ChanCounts", uRocId), - "Channel multiplicity per event; Channel []; # Mess []", - get4v10::kuNbChan*get4v10::kuMaxGet4Roc, 0, get4v10::kuMaxGet4Roc ); - - // Slow control messages - ROC[uRocId].fGet4V1SlowControlType = new TH2I( Form("Roc%u_Get4SlowControl", uRocId), - "SlowControl message type per Get4; Chip; ; Entries [1]", - fParam->uNbGet4, -0.5, fParam->uNbGet4 -0.5, 5, 0., 5); - ROC[uRocId].fGet4V1SlowControlType->GetYaxis()->SetBinLabel(1, "Scaler"); - ROC[uRocId].fGet4V1SlowControlType->GetYaxis()->SetBinLabel(2, "Dead time"); - ROC[uRocId].fGet4V1SlowControlType->GetYaxis()->SetBinLabel(3, "SPI"); - ROC[uRocId].fGet4V1SlowControlType->GetYaxis()->SetBinLabel(4, "Start"); - ROC[uRocId].fGet4V1SlowControlType->GetYaxis()->SetBinLabel(5, "Hamming"); - ROC[uRocId].fGet4V1SlowControlScaler = new TH2I( Form("Roc%u_Get4SlScaler", uRocId), - "Scaler in Get4 slow control message; Channel; Scaler [hits]; Entries [1]", - 2*(fParam->uNbGet4)*get4v10::kuNbChan, 0., (fParam->uNbGet4)*get4v10::kuNbChan, 820, 0, 8200); - ROC[uRocId].fGet4V1SlowControlDeadTime = new TH2I( Form("Roc%u_Get4SlDeadTime", uRocId), - "Dead time in Get4 slow control message; Channel; Dead Time [Clk cycle]; Entries [1]", - 2*(fParam->uNbGet4)*get4v10::kuNbChan, 0., (fParam->uNbGet4)*get4v10::kuNbChan, 410, 0, 4100); - ROC[uRocId].fGet4V1SlowControlHamming = new TH2I( Form("Roc%u_Get4SlSeu", uRocId), - "Hamming error counter for SEU in Get4 slow control message; Chip; Scaler [hits]; Entries [1]", - fParam->uNbGet4, 0., fParam->uNbGet4, 512, 0, 512); - ROC[uRocId].fGet4V1SlowControlSeuEvo = new TH2I( Form("Roc%u_Get4SlSeuEvo", uRocId), - "Hamming error counter for SEU in Get4 slow control message; Time [s]; Chip; Scaler [hits]", - 3600, 0, 3600, fParam->uNbGet4, 0., fParam->uNbGet4); - // Data messages - ROC[uRocId].fGet4V1DllLockBit = - new TH2I( Form("Roc%u_Get4V1DllLockBit", uRocId), - "Dll lock bit status per channel; Channel []; Dll lock bit []; Counts [1]", - fParam->uNbGet4*get4v10::kuNbChan, -0.5 , fParam->uNbGet4*get4v10::kuNbChan -0.5, - 2, -0.5, 1.5 ); - - for( UInt_t uGet4 = 0; uGet4 < get4v10::kuMaxGet4Roc; uGet4++) - { - char folderGet4[30]; - sprintf(folderGet4,"%sGet4_%u/",folder, uGet4); - UInt_t uRemappedGet4Index = fParam->RemapGet4Chip(uRocId, uGet4); - if( kTRUE == fParam->IsValidGet4Chip(uRemappedGet4Index) && - kTRUE == fParam->IsActiveGet4Chip(uRemappedGet4Index) ) - { - ROC[uRocId].fGet4V1HitsDistanceNs[uGet4] = - new TH2I( Form("Roc%u_Get%u_HitDistNs", - uRocId, uGet4), - Form("Time difference since last hit on same channel in GET4 %u Channels on ROC%u; [ns]", - uGet4, uRocId), - 1002, -2., 1000., - get4v10::kuNbChan, 0, get4v10::kuNbChan ); - ROC[uRocId].fGet4V1HitsDistanceUs[uGet4] = - new TH2I( Form("Roc%u_Get%u_HitDistUs", - uRocId, uGet4), - Form("Time difference since last hit on same channel in GET4 %u Channels on ROC%u; [us]", - uGet4, uRocId), - 999, 1., 1000., - get4v10::kuNbChan, 0, get4v10::kuNbChan ); - ROC[uRocId].fGet4V1HitsDistanceMs[uGet4] = - new TH2I( Form("Roc%u_Get%u_HitDistMs", - uRocId, uGet4), - Form("Time difference since last hit on same channel in GET4 %u Channels on ROC%u; [ms]", - uGet4, uRocId), - 999, 1., 1000., - get4v10::kuNbChan, 0, get4v10::kuNbChan ); - ROC[uRocId].fGet4V1HitsDistanceS[uGet4] = - new TH2I( Form("Roc%u_Get%u_HitDistS", - uRocId, uGet4), - Form("Time difference since last hit on same channel in GET4 %u Channels on ROC%u; [s]", - uGet4, uRocId), - 999, 1., 1000., - get4v10::kuNbChan, 0, get4v10::kuNbChan ); - - if( 1 == fParam->bTotHistoEnable ) - for( UInt_t uGet4Chan = 0; uGet4Chan < get4v10::kuNbChan; uGet4Chan++) - ROC[uRocId].fRawTot[uGet4][uGet4Chan] = - new TH1I( Form("RawTot_Ch%u_Get%u_Roc%u", - uGet4Chan, uGet4, uRocId ), - Form("Tot for channel %u in chip %u on ROC %u; Tot [ps]; Counts [1]", uGet4Chan, uGet4, uRocId), - 1200, -25, 59975 ); - } - } // for( UInt_t uGet4 = 0; uGet4 < get4v10::kuMaxGet4Roc; uGet4++) - } // if( kFALSE == fb32bitsReadoutDetected ) - extMess.Set32BitFlag(); - - UInt_t get4_32b_type = extMess.getGet4V10R32MessageType(); - switch(get4_32b_type) - { - case 0: // epoch message - { - UInt_t get4_32b_ep_epoch = extMess.getGet4V10R32EpochNumber(); -/* UInt_t get4_32b_ep_sync = extMess.getGet4V10R32SyncFlag();*/ // Commented out as unused to remove warning - - if( kTRUE == fCurrentGet4Event.HasTrigger() && kFALSE == ROC[uRocId].fbSelectionDone[get4_index] ) - { - // A trigger is ongoing on this chip! - if( kFALSE == ROC[uRocId].fbEpoch2SinceTrigger[get4_index] ) - { - // This is the first epoch after the trigger - // => time to look for the data in the epoch which was - // ongoing when the trigger was found - - // If we did not process the epoch before the one where the - // trigger came, we need to initialize the 24 bit temp hits - if( kFALSE == ROC[uRocId].bLookInPreviousEpoch[get4_index] ) - for( UInt_t uChan = 0; uChan < get4v10::kuNbChan; uChan++) - (ROC[uRocId].fHitTemp24[get4_index][uChan]).Clear(); - - BuildHits(uRocId, get4_index, ROC[uRocId].fbBufferWithLastFullEpoch2[get4_index]); - if( kFALSE == ROC[uRocId].bLookInNextEpoch[get4_index] ) - { - ROC[uRocId].fbSelectionDone[get4_index] = kTRUE; - CheckEventClosure(); - } - } // if( kFALSE == ROC[uRocId].fbEpoch2SinceTrigger[get4_index] ) - else if( kTRUE == ROC[uRocId].fbEpoch2SinceTrigger[get4_index] && - kTRUE == ROC[uRocId].bLookInNextEpoch[get4_index]) - { - // This is the second epoch after the trigger and we detected on trigger - // that the trigger window extend in epoch after the one where trigger - // was found => time to look for the data in the epoch which just finished - // and was the one just after the trigger epoch - BuildHits(uRocId, get4_index, ROC[uRocId].fbBufferWithLastFullEpoch2[get4_index]); - ROC[uRocId].fbSelectionDone[get4_index] = kTRUE; - CheckEventClosure(); - } // else if( kTRUE == ROC[uRocId].fbEpoch2SinceTrigger[get4_index] && kFALSE == ROC[uRocId].bLookInNextEpoch[get4_index]) - } // if( kTRUE == fCurrentGet4Event.HasTrigger() && kFALSE == ROC[uRocId].fbSelectionDone[get4_index] ) - - if( ROC[uRocId].fuCurrEpoch2[get4_index] + 1 != get4_32b_ep_epoch && - ( 0 < ROC[uRocId].fuCurrEpoch2[get4_index] || 0 < ROC[uRocId].fuEpoch2Cycle[get4_index] ) && - !( get4v10::kulGet4EpochCycleSz == ROC[uRocId].fuCurrEpoch2[get4_index] && 0 == get4_32b_ep_epoch ) ) - { - - // Count per global time unit in s for previous epoch as should not be too far away - // anyway this is just for selection, not actual display - ULong64_t ulPrevEpochTm = ((ULong64_t) ROC[uRocId].GetFullEpoch2Number( get4_index )) << 19; - ulPrevEpochTm = ulPrevEpochTm/ 20 + 512; - ulPrevEpochTm = ulPrevEpochTm / 100000000L; - - if( 311 < (ulPrevEpochTm % 36000) * 0.1 && - (ulPrevEpochTm % 36000) * 0.1 < 312 ) - { - cout<<(ulPrevEpochTm % 36000) * 0.1<<" Non consecutive epoch message for chip "<<get4_index<<" Roc Epoch "<<ROC[uRocId].fuCurrEpoch<<" : "; - cout<<ROC[uRocId].fuCurrEpoch2[get4_index]<<" "<<get4_32b_ep_epoch<<" "; - cout<<(Int_t)get4_32b_ep_epoch - (Int_t)(ROC[uRocId].fuCurrEpoch2[get4_index]+1) <<" "; - cout<<ROC[uRocId].fiEpochShift[get4_index]<<" "; - cout<<ROC[uRocId].fuNbShiftedEpochs[get4_index]<<endl; - } - - ROC[uRocId].fEpochShiftsPerChip->Fill( get4_index, (Int_t)get4_32b_ep_epoch - (Int_t)(ROC[uRocId].fuCurrEpoch2[get4_index]+1) ); - - if( ROC[uRocId].fuCurrEpoch2[get4_index] > get4_32b_ep_epoch && - get4v10::kulGet4EpochCycleSz < ROC[uRocId].fuCurrEpoch2[get4_index] + 100ul && - 100 < get4_32b_ep_epoch ) - // Epoch close to a cycle change on both sides - ROC[uRocId].fuEpoch2Cycle[get4_index]++; - - // Correction attempt: - if( (Int_t)get4_32b_ep_epoch - (Int_t)(ROC[uRocId].fuCurrEpoch2[get4_index]+1) < 10 ) - { - // close epochs ( < 250us) => probable not a full event missing - if( 0 != ROC[uRocId].fiEpochShift[get4_index]) - { - ROC[uRocId].fEpochShiftsDuration[get4_index]->Fill(ROC[uRocId].fiEpochShift[get4_index], - ROC[uRocId].fuNbShiftedEpochs[get4_index] ); - ROC[uRocId].fEpochShiftsDurationPerChip->Fill( get4_index, - ROC[uRocId].fuNbShiftedEpochs[get4_index] ); - } - ROC[uRocId].fiEpochShift[get4_index] += (Int_t)get4_32b_ep_epoch - (Int_t)(ROC[uRocId].fuCurrEpoch2[get4_index]+1) ; - ROC[uRocId].fuNbShiftedEpochs[get4_index] = 0; - } - else - { - // far epochs ( > 250us) => probable a full event is missing - if( 0 != ROC[uRocId].fiEpochShift[get4_index]) - { - ROC[uRocId].fEpochShiftsDuration[get4_index]->Fill(ROC[uRocId].fiEpochShift[get4_index], - ROC[uRocId].fuNbShiftedEpochs[get4_index] ); - ROC[uRocId].fEpochShiftsDurationPerChip->Fill( get4_index, - ROC[uRocId].fuNbShiftedEpochs[get4_index] ); - } - ROC[uRocId].fiEpochShift[get4_index] = 0 ; - ROC[uRocId].fuNbShiftedEpochs[get4_index] = 0; - } - - ROC[uRocId].fuCurrEpoch2[get4_index] = get4_32b_ep_epoch; - } // if non consecutive epoch indexes - else - { - if( ROC[uRocId].fuCurrEpoch2[get4_index] > get4_32b_ep_epoch ) - ROC[uRocId].fuEpoch2Cycle[get4_index]++; - ROC[uRocId].fuCurrEpoch2[get4_index] = get4_32b_ep_epoch; - - if( 0 != ROC[uRocId].fiEpochShift[get4_index] ) - ROC[uRocId].fuNbShiftedEpochs[get4_index]++; - } // else of if non consecutive epoch indexes - - // Event statistics - ROC[uRocId].fuNbHitsChipEpoch[get4_index] = 0; - - /* - * Temp fix for nov 2012 epoch problem - */ -/* - if( 0 == get4_index) - { - if( ROC[uRocId].fuCurrEpoch2[get4_index] > get4_32b_ep_epoch ) - { - ROC[uRocId].fuEpoch2Cycle[1]++; - ROC[uRocId].fuEpoch2Cycle[5]++; - } - ROC[uRocId].fuCurrEpoch2[1] = get4_32b_ep_epoch; - ROC[uRocId].fuCurrEpoch2[5] = get4_32b_ep_epoch; - } - if( 1 != get4_index && 5 != get4_index) - { - if( ROC[uRocId].fuCurrEpoch2[get4_index] > get4_32b_ep_epoch ) - ROC[uRocId].fuEpoch2Cycle[get4_index]++; - ROC[uRocId].fuCurrEpoch2[get4_index] = get4_32b_ep_epoch; - } -*/ - - ROC[uRocId].fDistribEpochs2->Fill(get4_index, ROC[uRocId].fuCurrEpoch2[get4_index]); - - ULong64_t uFullTimeBins = ((ULong64_t) ROC[uRocId].GetFullEpoch2Number( get4_index )) << 19; - ULong64_t uFullTime = uFullTimeBins/ 20 + 512; - Double_t dFullTime = uFullTimeBins / 20. + 512.; - extMess.SetFullTime( uFullTime ); - extMess.SetFullTimeD( dFullTime ); - - // Count per global time unit in s - ULong64_t ulEpochTm = uFullTime / 100000000L; - ROC[uRocId].fEPOCH2t[get4_index]->Fill((ulEpochTm % 36000) * 0.1); - - // Long duration time distribution (1 min. bin, 10 days length) - if( kTRUE == fParam->bLongTimeHistos ) - ROC[uRocId].fAllEpoch2LongT->Fill( (ulEpochTm * 0.1 ) / 3600 ); - - // Swap the flag indicating which buffer contains currently happening epoch - ROC[uRocId].fbBufferWithLastFullEpoch2[get4_index] = ( kTRUE == ROC[uRocId].fbBufferWithLastFullEpoch2[get4_index] ? kFALSE: kTRUE ); - // Clear this buffer (Data more than 1 full epoch old => either already selected or junk) - ROC[uRocId].fPrevEpochs2Buffer[get4_index][ ROC[uRocId].fbBufferWithLastFullEpoch2[get4_index] ].clear(); - - break; - } - case 1: // slow control message - { - UInt_t get4_32b_sl_data = extMess.getGet4V10R32SlData(); - UInt_t get4_32b_sl_type = extMess.getGet4V10R32SlType(); - UInt_t get4_32b_sl_edge = extMess.getGet4V10R32SlEdge(); - UInt_t get4_32b_sl_chan = extMess.getGet4V10R32SlChan(); - - if( get4_32b_sl_type < 3) - ROC[uRocId].fGet4V1SlowControlType->Fill(get4_index, get4_32b_sl_type); - - ULong64_t uFullTimeBins = ((ULong64_t) ROC[uRocId].GetFullEpoch2Number( get4_index )) << 19; - ULong64_t uFullTime = uFullTimeBins/ 20 + 512; - Double_t dFullTime = uFullTimeBins / 20. + 512.; - extMess.SetFullTime( uFullTime ); - extMess.SetFullTimeD( dFullTime ); - - uFullTimeBins /= 20; - uFullTimeBins += 512; - uFullTimeBins /= 100000000L; - ROC[uRocId].fSLOWCt->Fill( (uFullTimeBins % 36000) * 0.1 ); - - // Long duration time distribution (1 min. bin, 10 days length) - if( kTRUE == fParam->bLongTimeHistos ) - ROC[uRocId].fSlowCLongT->Fill( (uFullTimeBins * 0.1 ) / 3600 ); - - switch(get4_32b_sl_type) - { - case 0: - ROC[uRocId].fGet4V1SlowControlScaler->Fill( - get4v10::kuNbChan*get4_index + get4_32b_sl_chan + 0.5*get4_32b_sl_edge, get4_32b_sl_data ); - break; - case 1: - ROC[uRocId].fGet4V1SlowControlDeadTime->Fill( - get4v10::kuNbChan*get4_index + get4_32b_sl_chan + 0.5*get4_32b_sl_edge, get4_32b_sl_data ); - break; - case 2: - { - TString sTemp = Form("Get4 V1.0 32bit, chip %02d, SPI message: %06x", get4_index, get4_32b_sl_data); - LOG(info)<<sTemp; - break; - } - case 3: - { - if( 0 == get4_32b_sl_chan && 1 == get4_32b_sl_edge ) - { - ROC[uRocId].fGet4V1SlowControlType->Fill(get4_index, 4); - ROC[uRocId].fGet4V1SlowControlHamming->Fill( get4_index, get4_32b_sl_data ); - ROC[uRocId].fGet4V1SlowControlSeuEvo->Fill( - ( ROC[uRocId].GetFullEpoch2Number(get4_index) * get4tdc::kdEpochInPs ) / 1e12, - get4_index, get4_32b_sl_data ); - } - else - { - ROC[uRocId].fGet4V1SlowControlType->Fill(get4_index, get4_32b_sl_type); - TString sTemp = Form("Get4 V1.0 32bit, chip %02d, Start message: %c%c%c (%6X)", - get4_index, - (get4_32b_sl_data>>16)&0xFF, (get4_32b_sl_data>>8)&0xFF, - get4_32b_sl_data&0xFF, get4_32b_sl_data); - LOG(info)<<sTemp; - } - - break; - } - default: - break; - } - - break; - } - case 2: // error event - { - UInt_t get4_32b_er_code = extMess.getGet4V10R32ErrorData(); - UInt_t get4_32b_er_chan = extMess.getGet4V10R32ErrorChan(); - UInt_t get4_32b_er_edge = extMess.getGet4V10R32ErrorEdge(); - - ULong64_t uFullTimeBins = ((ULong64_t) ROC[uRocId].GetFullEpoch2Number( get4_index )) << 19; - ULong64_t uFullTime = uFullTimeBins/ 20 + 512; - Double_t dFullTime = uFullTimeBins / 20. + 512.; - extMess.SetFullTime( uFullTime ); - extMess.SetFullTimeD( dFullTime ); - - uFullTimeBins /= 20; - uFullTimeBins += 512; - uFullTimeBins /= 100000000L; - ROC[uRocId].fERRORt->Fill( (uFullTimeBins % 36000) * 0.1 ); - - // Long duration time distribution (1 min. bin, 10 days length) - if( kTRUE == fParam->bLongTimeHistos ) - ROC[uRocId].fErrorLongT->Fill( (uFullTimeBins * 0.1 ) / 3600 ); - - ROC[uRocId].fGet4ErrorChip->Fill( get4_index ); - ROC[uRocId].fGet4ErrorPatt->Fill( get4_index, get4_32b_er_code); - if( (0x03 < get4_32b_er_code && get4_32b_er_code < 0x07) ) - ROC[uRocId].fGet4ErrorChan->Fill( - get4v10::kuNbChan*get4_index + get4_32b_er_chan + 0.5*get4_32b_er_edge, - get4_32b_er_code - 0x04 ); - else if( 0x11 == get4_32b_er_code || - 0x12 == get4_32b_er_code ) - ROC[uRocId].fGet4ErrorChan->Fill( - get4v10::kuNbChan*get4_index + get4_32b_er_chan + 0.5*get4_32b_er_edge, - get4_32b_er_code - 0x0e ); - - break; - } - case 3: // data event - { - UInt_t get4_32b_dat_tot = extMess.getGet4V10R32HitTot(); -/* UInt_t get4_32b_dat_ft = extMess.getGet4V10R32HitFt();*/ // Commented out as unused to remove warning -/* UInt_t get4_32b_dat_ts = extMess.getGet4V10R32HitTs();*/ // Commented out as unused to remove warning - UInt_t get4_32b_dat_chan = extMess.getGet4V10R32HitChan(); - UInt_t get4_32b_dat_dll = extMess.getGet4V10R32HitDllFlag(); - if( get4v10::kuNbChan <= get4_32b_dat_chan ) - return -1; - - ULong64_t uFullTimeBins = ((ULong64_t) ROC[uRocId].GetFullEpoch2Number( get4_index ) << 19) | - (ULong64_t)extMess.getGet4V10R32HitTimeBin(); - ULong64_t uFullTime = uFullTimeBins/ 20 + 512; - Double_t dFullTime = ((Double_t)uFullTimeBins)*0.05 + 512.; - extMess.SetFullTime( uFullTime ); - extMess.SetFullTimeD( dFullTime ); - - uFullTimeBins /= 20; - uFullTimeBins += 512; - uFullTimeBins /= 100000000L; - ROC[uRocId].fDATAt->Fill( (uFullTimeBins % 36000) * 0.1 ); - - // Long duration time distribution (1 min. bin, 10 days length) - if( kTRUE == fParam->bLongTimeHistos ) - ROC[uRocId].fDataLongT->Fill( (uFullTimeBins * 0.1 ) / 3600 ); - - if( 0 < ROC[uRocId].fLastExtMess[get4_index][get4_32b_dat_chan].GetFullTimeD() ) - { - ROC[uRocId].fGet4V1HitsDistanceNs[get4_index]->Fill( extMess.GetFullTimeD() - - ROC[uRocId].fLastExtMess[get4_index][get4_32b_dat_chan].GetFullTimeD(), - get4_32b_dat_chan); - ROC[uRocId].fGet4V1HitsDistanceUs[get4_index]->Fill( ( extMess.GetFullTimeD() - - ROC[uRocId].fLastExtMess[get4_index][get4_32b_dat_chan].GetFullTimeD() )/1e3, - get4_32b_dat_chan); - ROC[uRocId].fGet4V1HitsDistanceMs[get4_index]->Fill( ( extMess.GetFullTimeD() - - ROC[uRocId].fLastExtMess[get4_index][get4_32b_dat_chan].GetFullTimeD() )/1e6, - get4_32b_dat_chan); - ROC[uRocId].fGet4V1HitsDistanceS[get4_index]->Fill( ( extMess.GetFullTimeD() - - ROC[uRocId].fLastExtMess[get4_index][get4_32b_dat_chan].GetFullTimeD() )/1e9, - get4_32b_dat_chan); - } - - // Event statistics - ROC[uRocId].fLastExtMess[get4_index][get4_32b_dat_chan] = extMess; - ROC[uRocId].fChannelInputMessCount->Fill( get4_index + (Double_t)get4_32b_dat_chan/(Double_t)get4v10::kuNbChan ); - if( kTRUE == fParam->bChipRateHistoEnable ) - ROC[uRocId].fChipRateEvolution[get4_index]->Fill( - (uFullTimeBins ) * 0.1, 1.0/ROC[uRocId].fdRateEvolutionBinSize ); - if( kTRUE == fParam->bChannelRateHistoEnable ) - ROC[uRocId].fChannelRateEvolution[get4_index][get4_32b_dat_chan]->Fill( - (uFullTimeBins ) * 0.1, 1.0/ROC[uRocId].fdRateEvolutionBinSize ); - ROC[uRocId].fuNbHitsChipEpoch[get4_index] ++; - - // TODO: bin size for Tot as option!!! - if( 1 == fParam->bTotHistoEnable ) - ROC[uRocId].fRawTot[get4_index][get4_32b_dat_chan]->Fill( get4_32b_dat_tot*25500.0/255.0 ); - - ROC[uRocId].fGet4V1DllLockBit->Fill( get4v10::kuNbChan*get4_index + get4_32b_dat_chan, - get4_32b_dat_dll); - if( kTRUE == ROC[uRocId].fbDllFlag[get4_index][get4_32b_dat_chan] && 1 == get4_32b_dat_dll) - { - ROC[uRocId].fbDllFlag[get4_index][get4_32b_dat_chan] = kFALSE; - cout<<"DLL lock recovery, chip "<<get4_index<<" chan "<<get4_32b_dat_chan<<" at "<<(Double_t)uFullTimeBins*0.1<<" s"<<endl; - } - if( kFALSE == ROC[uRocId].fbDllFlag[get4_index][get4_32b_dat_chan] && 0 == get4_32b_dat_dll) - { - ROC[uRocId].fbDllFlag[get4_index][get4_32b_dat_chan] = kTRUE; - cout<<"DLL lock loss, chip "<<get4_index<<" chan "<<get4_32b_dat_chan<<" at "<<(Double_t)uFullTimeBins*0.1<<" s"<<endl; - } - - // Early event closure check - if( kTRUE == fCurrentGet4Event.HasTrigger() && - kFALSE == ROC[uRocId].fbSelectionDone[get4_index] ) - { - Double_t dTimeToTrigger = 0.0; - dTimeToTrigger = extMess.GetFullTimeD() - fCurrentGet4Event.fdTriggerFullTime[uRocId]; - if( kFALSE == ROC[uRocId].fTriggerWind->Test( dTimeToTrigger) ) - { - // Message after the end of trigger window!! - Bool_t bAllChanInChipOver = kTRUE; - - // If there was already a message from the same channel out of the trigger - // window, then the token ring made at least one full turn => ok for all - // Otherwise: need to check other channels status - if( kFALSE == ROC[uRocId].fbDataTimeOut[get4_index][get4_32b_dat_chan] ) - { - // 32b = always a hit, not just edge ! - ROC[uRocId].fbDataTimeOut[get4_index][get4_32b_dat_chan] = kTRUE; - // Check if chip fully finished - for(UInt_t uChanTest = 0; uChanTest < get4v10::kuNbChan; uChanTest ++) - if( kFALSE == ROC[uRocId].fbDataTimeOut[get4_index][uChanTest] ) - bAllChanInChipOver = kFALSE; - } - // If chip fully finished: don't wait for the next epoch to close future buffer - // of current event for this chip - if( kTRUE == bAllChanInChipOver) - { - // If This is the first epoch after the trigger and - // we did not process the epoch before the one where the - // trigger came, we need to initialize the 24 bit temp hits - if( kFALSE == ROC[uRocId].fbEpoch2SinceTrigger[get4_index] && - kFALSE == ROC[uRocId].bLookInPreviousEpoch[get4_index] ) - for( UInt_t uChan = 0; uChan < get4v10::kuNbChan; uChan++) - (ROC[uRocId].fHitTemp24[get4_index][uChan]).Clear(); - - BuildHits(uRocId, get4_index, ROC[uRocId].fbBufferWithLastFullEpoch2[get4_index]); - ROC[uRocId].fbSelectionDone[get4_index] = kTRUE; - CheckEventClosure(); - - for(UInt_t uChanTest = 0; uChanTest < get4v10::kuNbChan; uChanTest ++) - ROC[uRocId].fbDataTimeOut[get4_index][uChanTest] = kFALSE; - } // if( kTRUE == bAllChanInChipOver) - } // if( kFALSE == ROC[uRocId].fTriggerWind->Test( dTimeToTrigger) ) - } // Event ongoing with a detected trigger and future buffer not closed - - /** Triggering on Data **/ - if( kTRUE == fParam->bFreeStreaming && 0 < fParam->uNbTriggers ) - { - for( Int_t iMainTriggerIndex = 0; iMainTriggerIndex < (Int_t)(fParam->uNbTriggers); iMainTriggerIndex++ ) - if( kTRUE == fParam->IsMainOfThisTrigger( iMainTriggerIndex, get4_index, get4_32b_dat_chan ) ) - { - ROC[uRocId].fextMessLastMainChannel[iMainTriggerIndex] = extMess; - /* - * TODO: call to ProcessTrigger - * TEMP: histo Filling + counting - */ - Bool_t bAllInCoinc = kTRUE; - for( UInt_t uSecChannel = 0; uSecChannel < fParam->uNbSecondarySelectionCh[iMainTriggerIndex]; uSecChannel++) - { - Double_t dDistanceToMain = ROC[uRocId].fdLastFullTimeSecChannel[iMainTriggerIndex][uSecChannel] - - extMess.GetFullTimeD(); - if( dDistanceToMain < fParam->dCoincidenceWindowStart[iMainTriggerIndex] || - fParam->dCoincidenceWindowStop[iMainTriggerIndex] < dDistanceToMain ) - { - bAllInCoinc = kFALSE; - break; - } // if out of coincidence window - } // for( UInt_t uSecChannel = 0; uSecChannel < fParam->uNbSecondarySelectionCh[iMainTriggerIndex]; uSecChannel++) - if( kTRUE == bAllInCoinc ) - { - Double_t dSameTriggerDistance = - ROC[uRocId].fextMessLastMainChannel[iMainTriggerIndex].GetFullTimeD() - - ROC[uRocId].fdLastFullTimeSelfTrigger[iMainTriggerIndex] ; - - ROC[uRocId].fDataSelfTrigDistanceNs->Fill( dSameTriggerDistance, iMainTriggerIndex ); - ROC[uRocId].fDataSelfTrigDistanceUs->Fill( dSameTriggerDistance/1e3, iMainTriggerIndex ); - ROC[uRocId].fDataSelfTrigDistanceMs->Fill( dSameTriggerDistance/1e6, iMainTriggerIndex ); - ROC[uRocId].fDataSelfTrigDistanceS->Fill( dSameTriggerDistance/1e9, iMainTriggerIndex ); - - if( fParam->dDeadTime <= dSameTriggerDistance ) - { - // Here we have a DATA self-trigger!!!!!! - ROC[uRocId].fuDataSelfTriggerCount[iMainTriggerIndex] ++; - - ROC[uRocId].fdLastFullTimeSelfTrigger[iMainTriggerIndex] = - ROC[uRocId].fextMessLastMainChannel[iMainTriggerIndex].GetFullTimeD(); - - ULong64_t uFullTimeSelfTrigBins = ROC[uRocId].fextMessLastMainChannel[iMainTriggerIndex].GetFullTime(); - uFullTimeSelfTrigBins /= 100000000L; - ROC[uRocId].fSelfTriggT->Fill( (uFullTimeSelfTrigBins % 36000) * 0.1 ); - - // Long duration time distribution (1 min. bin, 10 days length) - if( kTRUE == fParam->bLongTimeHistos ) - ROC[uRocId].fSelfTriggLongT->Fill( (uFullTimeSelfTrigBins * 0.1 ) / 3600 ); - - ProcessTriggerMessage(uRocId, ROC[uRocId].fextMessLastMainChannel[iMainTriggerIndex], iMainTriggerIndex); - } // if( fParam->dDeadTime <= dSameTriggerDistance ) - } // if( kTRUE == bAllInCoinc ) - } // if( -1 < iMainTriggerIndex ) - for( Int_t iSecTriggerIndex = 0; iSecTriggerIndex < (Int_t)(fParam->uNbTriggers); iSecTriggerIndex++ ) - { - if( kTRUE == fParam->IsSecOfThisTrigger( iSecTriggerIndex, get4_index, get4_32b_dat_chan ) ) - { - Int_t iSecondaryIndex = fParam->GetSecChannelIndex(iSecTriggerIndex, get4_index, get4_32b_dat_chan); - if( -1 < iSecondaryIndex ) - { - ROC[uRocId].fdLastFullTimeSecChannel[iSecTriggerIndex][iSecondaryIndex] = extMess.GetFullTimeD(); - - /* - * TODO: call to ProcessTrigger - * TEMP: histo Filling + counting - */ - Bool_t bAllInCoinc = kTRUE; - for( UInt_t uSecChannel = 0; uSecChannel < fParam->uNbSecondarySelectionCh[iSecTriggerIndex]; uSecChannel++) - { - Double_t dDistanceToMain = ROC[uRocId].fdLastFullTimeSecChannel[iSecTriggerIndex][uSecChannel] - - ROC[uRocId].fextMessLastMainChannel[iSecTriggerIndex].GetFullTimeD(); - if( dDistanceToMain < fParam->dCoincidenceWindowStart[iSecTriggerIndex] || - fParam->dCoincidenceWindowStop[iSecTriggerIndex] < dDistanceToMain ) - { - bAllInCoinc = kFALSE; - break; - } // if out of coincidence window - } // for( UInt_t uSecChannel = 0; uSecChannel < fParam->uNbSecondarySelectionCh[iSecTriggerIndex]; uSecChannel++) - if( kTRUE == bAllInCoinc ) - { - Double_t dSameTriggerDistance = - ROC[uRocId].fextMessLastMainChannel[iSecTriggerIndex].GetFullTimeD() - - ROC[uRocId].fdLastFullTimeSelfTrigger[iSecTriggerIndex] ; - - ROC[uRocId].fDataSelfTrigDistanceNs->Fill( dSameTriggerDistance, iSecTriggerIndex ); - ROC[uRocId].fDataSelfTrigDistanceUs->Fill( dSameTriggerDistance/1e3, iSecTriggerIndex ); - ROC[uRocId].fDataSelfTrigDistanceMs->Fill( dSameTriggerDistance/1e6, iSecTriggerIndex ); - ROC[uRocId].fDataSelfTrigDistanceS->Fill( dSameTriggerDistance/1e9, iSecTriggerIndex ); - - if( fParam->dDeadTime <= dSameTriggerDistance ) - { - // Here we have a DATA self-trigger!!!!!! - ROC[uRocId].fuDataSelfTriggerCount[iSecTriggerIndex] ++; - - ROC[uRocId].fdLastFullTimeSelfTrigger[iSecTriggerIndex] = - ROC[uRocId].fextMessLastMainChannel[iSecTriggerIndex].GetFullTimeD(); - - ULong64_t uFullTimeSelfTrigBins = ROC[uRocId].fextMessLastMainChannel[iSecTriggerIndex].GetFullTime(); - uFullTimeSelfTrigBins /= 100000000L; - ROC[uRocId].fSelfTriggT->Fill( (uFullTimeSelfTrigBins % 36000) * 0.1 ); - - // Long duration time distribution (1 min. bin, 10 days length) - if( kTRUE == fParam->bLongTimeHistos ) - ROC[uRocId].fSelfTriggLongT->Fill( (uFullTimeSelfTrigBins * 0.1 ) / 3600 ); - - ProcessTriggerMessage(uRocId, ROC[uRocId].fextMessLastMainChannel[iSecTriggerIndex], iSecTriggerIndex); - } // if( fParam->dDeadTime <= dSameTriggerDistance ) - } // if( kTRUE == bAllInCoinc ) - } // if( -1 < iSecondaryIndex ) - } // if( -1 < iSecTriggerIndex ) - } // else of if( -1 < iMainTriggerIndex ) - } // if( kTRUE == fParam->bFreeStreaming && 0 < fParam->uNbTriggers ) - - break; - } - default: - break; - } // switch(get4_32b_type) - - return get4_32b_type; -} -/**********************************************************************/ - -Bool_t TTofGet4Unpacker::AnalyzeAllGet4Channels( Get4v1Event &eventFull ) -{ - - /* TODO FILL ME - * both readout mode histo filling - */ - for( UInt_t uRocId =0; uRocId<fParam->numRocs; uRocId++ ) - { - if( !fParam->IsActiveRoc(uRocId) ) continue; - - for( UInt_t uGet4 = 0; uGet4 < get4v10::kuMaxGet4Roc; uGet4++) - for( UInt_t uGet4Chan = 0; uGet4Chan < get4v10::kuNbChan; uGet4Chan++) - { - if( 0 < ( (eventFull.fGet4Boards[uGet4]).fHits[uGet4Chan]).size() ) - { - for( UInt_t uGet4Chan_2 = uGet4Chan+1; uGet4Chan_2 < get4v10::kuNbChan; uGet4Chan_2++) - if( 0 < ( (eventFull.fGet4Boards[uGet4]).fHits[uGet4Chan_2]).size() ) - ROC[uRocId].fChannelsMapping->Fill( uGet4 + (Double_t)uGet4Chan/(Double_t)get4v10::kuNbChan, - uGet4 + (Double_t)uGet4Chan_2/(Double_t)get4v10::kuNbChan ); - - for( UInt_t uGet4_2 = uGet4+1; uGet4_2 < get4v10::kuMaxGet4Roc; uGet4_2++) - for( UInt_t uGet4Chan_2 = 0; uGet4Chan_2 < get4v10::kuNbChan; uGet4Chan_2++) - if( 0 < ( (eventFull.fGet4Boards[uGet4_2]).fHits[uGet4Chan_2]).size() ) - ROC[uRocId].fChannelsMapping->Fill( uGet4 + (Double_t)uGet4Chan/(Double_t)get4v10::kuNbChan, - uGet4_2 + (Double_t)uGet4Chan_2/(Double_t)get4v10::kuNbChan ); - } - - ROC[uRocId].fChannelMultiplicity->Fill( uGet4 + (Double_t)uGet4Chan/(Double_t)get4v10::kuNbChan, - ( (eventFull.fGet4Boards[uGet4]).fHits[uGet4Chan]).size()); - } - - if( 1 == fParam->bDebugHistoEnable ) - { - UInt_t uHistosIndexSingleChip = 0; - UInt_t uHistosIndexChipVsChip = 0; - for(UInt_t uFirstGet4Channel = 0; uFirstGet4Channel < get4v10::kuNbChan; uFirstGet4Channel++) - { - for(UInt_t uSecondGet4Channel = 0; uSecondGet4Channel < get4v10::kuNbChan; uSecondGet4Channel++) - { - if( uFirstGet4Channel < uSecondGet4Channel ) - { - if( 1 == ( (eventFull.fGet4Boards[fParam->uGet4TimeDiffChip1]).fHits[uFirstGet4Channel]).size() && - 1 == ( (eventFull.fGet4Boards[fParam->uGet4TimeDiffChip1]).fHits[uSecondGet4Channel]).size() ) - { - ROC[uRocId].fTimeDiffInsideChip[0][uHistosIndexSingleChip]->Fill( - ( (eventFull.fGet4Boards[fParam->uGet4TimeDiffChip1]).fHits[uFirstGet4Channel])[0].GetTimeDiff( - ( (eventFull.fGet4Boards[fParam->uGet4TimeDiffChip1]).fHits[uSecondGet4Channel])[0]) ); - // 1D FineTime correlation - ROC[uRocId].fFTCorrel[0][uHistosIndexSingleChip]->Fill( - ( (eventFull.fGet4Boards[fParam->uGet4TimeDiffChip1]).fHits[uSecondGet4Channel])[0].GetHitLeadingFTS() - -( (eventFull.fGet4Boards[fParam->uGet4TimeDiffChip1]).fHits[uFirstGet4Channel])[0].GetHitLeadingFTS() ); - // 2D FineTime correlation - ROC[uRocId].fFTCorrel2D[0][uHistosIndexSingleChip]->Fill( - ( (eventFull.fGet4Boards[fParam->uGet4TimeDiffChip1]).fHits[uFirstGet4Channel])[0].GetHitLeadingFTS(), - ( (eventFull.fGet4Boards[fParam->uGet4TimeDiffChip1]).fHits[uSecondGet4Channel])[0].GetHitLeadingFTS() ); - } - if( 1 == ( (eventFull.fGet4Boards[fParam->uGet4TimeDiffChip2]).fHits[uFirstGet4Channel]).size() && - 1 == ( (eventFull.fGet4Boards[fParam->uGet4TimeDiffChip2]).fHits[uSecondGet4Channel]).size() ) - { - ROC[uRocId].fTimeDiffInsideChip[1][uHistosIndexSingleChip]->Fill( - ( (eventFull.fGet4Boards[fParam->uGet4TimeDiffChip2]).fHits[uFirstGet4Channel])[0].GetTimeDiff( - ( (eventFull.fGet4Boards[fParam->uGet4TimeDiffChip2]).fHits[uSecondGet4Channel])[0]) ); - // 1D FineTime correlation - ROC[uRocId].fFTCorrel[1][uHistosIndexSingleChip]->Fill( - ( (eventFull.fGet4Boards[fParam->uGet4TimeDiffChip2]).fHits[uSecondGet4Channel])[0].GetHitLeadingFTS() - -( (eventFull.fGet4Boards[fParam->uGet4TimeDiffChip2]).fHits[uFirstGet4Channel])[0].GetHitLeadingFTS() ); - // 2D FineTime correlation - ROC[uRocId].fFTCorrel2D[1][uHistosIndexSingleChip]->Fill( - ( (eventFull.fGet4Boards[fParam->uGet4TimeDiffChip2]).fHits[uFirstGet4Channel])[0].GetHitLeadingFTS(), - ( (eventFull.fGet4Boards[fParam->uGet4TimeDiffChip2]).fHits[uSecondGet4Channel])[0].GetHitLeadingFTS() ); - } - uHistosIndexSingleChip++; - } // if( uFirstGet4Channel < uSecondGet4Channel ) - if( 1 == ( (eventFull.fGet4Boards[fParam->uGet4TimeDiffChip1]).fHits[uFirstGet4Channel]).size() && - 1 == ( (eventFull.fGet4Boards[fParam->uGet4TimeDiffChip2]).fHits[uSecondGet4Channel]).size() ) - { - ROC[uRocId].fTimeDiffBetweenChips[uHistosIndexChipVsChip]->Fill( - ( (eventFull.fGet4Boards[fParam->uGet4TimeDiffChip1]).fHits[uFirstGet4Channel])[0].GetTimeDiff( - ( (eventFull.fGet4Boards[fParam->uGet4TimeDiffChip2]).fHits[uSecondGet4Channel])[0]) ); - ROC[uRocId].fFTCorrelChipToChip[uHistosIndexChipVsChip]->Fill( - ( (eventFull.fGet4Boards[fParam->uGet4TimeDiffChip2]).fHits[uSecondGet4Channel])[0].GetHitLeadingFTS() - -( (eventFull.fGet4Boards[fParam->uGet4TimeDiffChip1]).fHits[uFirstGet4Channel])[0].GetHitLeadingFTS() ); - } - uHistosIndexChipVsChip++; - } // for(UInt_t uSecondGet4Channel = 0; uSecondGet4Channel < MAX_GET4_CH; uSecondGet4Channel++) - } // for(UInt_t uFirstGet4Channel = 0; uFirstGet4Channel < MAX_GET4_CH; uFirstGet4Channel++) - } // if( 1 == fParam->bDebugHistoEnable ) - } // for( UInt_t uRocId =0; uRocId<fParam->numRocs; uRocId++ ) - - if( kTRUE == fb32bitsReadoutDetected ) - AnalyzeAllGet4Channels32Bits( fCurrentGet4Event ); - else AnalyzeAllGet4Channels24Bits( fCurrentGet4Event ); - - return kTRUE; -} -Bool_t TTofGet4Unpacker::AnalyzeAllGet4Channels24Bits( Get4v1Event &eventFull ) -{ - - /* TODO FILL ME - * 24 bit mode histo filling - */ - - if( 1 == fParam->bDebugHistoEnable ) - for( UInt_t uRoc =0; uRoc<fParam->numRocs; uRoc++ ) - if( fParam->IsActiveRoc(uRoc) ) - if( 0 == uNbEvents[uRoc]%fParam->uNbEventsDnlUpdate ) - { - UpdateLeadingDnlHistograms( eventFull, uRoc ); - UpdateTrailingDnlHistograms( eventFull, uRoc ); - } - - return kTRUE; -} -Bool_t TTofGet4Unpacker::AnalyzeAllGet4Channels32Bits( Get4v1Event &eventFull ) -{ - - /* TODO FILL ME - * 32 bit mode histo filling - */ - - if( 1 == fParam->bDebugHistoEnable ) - for( UInt_t uRoc =0; uRoc<fParam->numRocs; uRoc++ ) - if( fParam->IsActiveRoc(uRoc) ) - if( 0 == uNbEvents[uRoc]%fParam->uNbEventsDnlUpdate ) - UpdateLeadingDnlHistograms( eventFull, uRoc ); - - return kTRUE; -} -/**********************************************************************/ - -/* -Bool_t TTofGet4Unpacker::PrintRocEpochIndexes(UInt_t uRocId, Int_t uMessagePriority ) -{ - TString sOutput = ""; - - for( UInt_t uGet4 = 0; uGet4 < fParam->uNbGet4; uGet4++) - { - sOutput += Form(" %7d", ROC[uRocId].fuCurrEpoch2[uGet4]); - } - LOG((FairLogLevel)uMessagePriority)<<"Current ROC epoch indexes: "<<sOutput.Data(); - - return kTRUE; -} -Bool_t TTofGet4Unpacker::PrintRocEpochCycles(UInt_t uRocId, Int_t uMessagePriority ) -{ - TString sOutput = ""; - - for( UInt_t uGet4 = 0; uGet4 < fParam->uNbGet4; uGet4++) - { - sOutput += Form(" %6d", ROC[uRocId].fuEpoch2Cycle[uGet4]); - } - LOG((FairLogLevel)uMessagePriority)<<"Current ROC cycle indexes: "<<sOutput.Data(); - - return kTRUE; -} -*/ -/**********************************************************************/ -void TTofGet4Unpacker::UpdateLeadingDnlHistograms( Get4v1Event & /*eventFull*/, UInt_t uRocId ) -{ - for( UInt_t uGet4 = 0; uGet4 < get4v10::kuMaxGet4Roc; uGet4++) - for( UInt_t uGet4Chan = 0; uGet4Chan < get4v10::kuNbChan; uGet4Chan++) - { - UInt_t uRemappedGet4Index = fParam->RemapGet4Chip(uRocId, uGet4); - if( kTRUE == fParam->IsValidGet4Chip(uRemappedGet4Index) && - kTRUE == fParam->IsActiveGet4Chip(uRemappedGet4Index) ) - { - Double_t dDnlLeading = 0; - Double_t dSumLeading = 0; - - // First Resets everything - ROC[uRocId].fLeadingDnl[uGet4][uGet4Chan]->Reset(); - ROC[uRocId].fLeadingDnlSum[uGet4][uGet4Chan]->Reset(); - - // First bin - dDnlLeading = ( ROC[uRocId].fLeadingFTS[uGet4][uGet4Chan]->GetBinContent(1) - - (ROC[uRocId].fLeadingFTS[uGet4][uGet4Chan]->GetEntries()/(Double_t)get4tdc::kiFineTime) ) / - (ROC[uRocId].fLeadingFTS[uGet4][uGet4Chan]->GetEntries()/(Double_t)get4tdc::kiFineTime); - ROC[uRocId].fLeadingDnl[uGet4][uGet4Chan]->Fill( 0.0, dDnlLeading); - dSumLeading += dDnlLeading; - ROC[uRocId].fLeadingDnlSum[uGet4][uGet4Chan]->Fill( 0.0, dSumLeading ); - - for( int j = 2; j <= get4tdc::kiFineTime; j++) - { - dDnlLeading = ( ROC[uRocId].fLeadingFTS[uGet4][uGet4Chan]->GetBinContent(j) - - (ROC[uRocId].fLeadingFTS[uGet4][uGet4Chan]->GetEntries()/(Double_t)get4tdc::kiFineTime) ) / - (ROC[uRocId].fLeadingFTS[uGet4][uGet4Chan]->GetEntries()/(Double_t)get4tdc::kiFineTime); - ROC[uRocId].fLeadingDnl[uGet4][uGet4Chan]->Fill( (Double_t)(j-1), dDnlLeading ); - dSumLeading += dDnlLeading; - ROC[uRocId].fLeadingDnlSum[uGet4][uGet4Chan]->Fill( (Double_t)j-1, dSumLeading ); - } - } - } // For get4 in ROC, for channel in GET4 -} -void TTofGet4Unpacker::UpdateTrailingDnlHistograms( Get4v1Event & /*eventFull*/, UInt_t uRocId ) -{ - for( UInt_t uGet4 = 0; uGet4 < get4v10::kuMaxGet4Roc; uGet4++) - for( UInt_t uGet4Chan = 0; uGet4Chan < get4v10::kuNbChan; uGet4Chan++) - { - UInt_t uRemappedGet4Index = fParam->RemapGet4Chip(uRocId, uGet4); - if( kTRUE == fParam->IsValidGet4Chip(uRemappedGet4Index) && - kTRUE == fParam->IsActiveGet4Chip(uRemappedGet4Index) ) - { - Double_t dDnlTrailing = 0; - Double_t dSumTrailing = 0; - - // First Resets everything - ROC[uRocId].fTrailingDnl[uGet4][uGet4Chan]->Reset(); - ROC[uRocId].fTrailingDnlSum[uGet4][uGet4Chan]->Reset(); - - // First bin - dDnlTrailing = ( ROC[uRocId].fTrailingFTS[uGet4][uGet4Chan]->GetBinContent(1) - - (ROC[uRocId].fTrailingFTS[uGet4][uGet4Chan]->GetEntries()/(Double_t)get4tdc::kiFineTime) ) / - (ROC[uRocId].fTrailingFTS[uGet4][uGet4Chan]->GetEntries()/(Double_t)get4tdc::kiFineTime); - ROC[uRocId].fTrailingDnl[uGet4][uGet4Chan]->Fill( 0.0, dDnlTrailing ); - dSumTrailing += dDnlTrailing; - ROC[uRocId].fTrailingDnlSum[uGet4][uGet4Chan]->Fill( 0.0, dSumTrailing ); - - for( int j = 2; j <= get4tdc::kiFineTime; j++) - { - dDnlTrailing = ( ROC[uRocId].fTrailingFTS[uGet4][uGet4Chan]->GetBinContent(j) - - (ROC[uRocId].fTrailingFTS[uGet4][uGet4Chan]->GetEntries()/(Double_t)get4tdc::kiFineTime) ) / - (ROC[uRocId].fTrailingFTS[uGet4][uGet4Chan]->GetEntries()/(Double_t)get4tdc::kiFineTime); - ROC[uRocId].fTrailingDnl[uGet4][uGet4Chan]->Fill( (Double_t)(j-1), dDnlTrailing ); - dSumTrailing += dDnlTrailing; - ROC[uRocId].fTrailingDnlSum[uGet4][uGet4Chan]->Fill( (Double_t)(j-1), dSumTrailing ); - } - } - } // For get4 in ROC, for channel in GET4 -} - -roc::MessageFormat TTofGet4Unpacker::ConvertToMsgFormat(const Char_t& cNumFormat) -{ - roc::MessageFormat tmp_fmt; - - switch(cNumFormat) - { - case 0: - tmp_fmt = roc::formatEth1; - break; - case 1: - tmp_fmt = roc::formatOptic1; - break; - case 2: - tmp_fmt = roc::formatEth2; - break; - case 3: - tmp_fmt = roc::formatOptic2; - break; - case 4: - default: - tmp_fmt = roc::formatNormal; - break; - } - - return tmp_fmt; -} diff --git a/beamtime/tof/tdc/get4/TTofGet4Unpacker.h b/beamtime/tof/tdc/get4/TTofGet4Unpacker.h deleted file mode 100644 index 2e36a5baf8eefe1e7cc68c00958b95a5e898b131..0000000000000000000000000000000000000000 --- a/beamtime/tof/tdc/get4/TTofGet4Unpacker.h +++ /dev/null @@ -1,208 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TTofGet4Unpacker ----- -// ----- Created 22/07/2013 by P.-A. Loizeau ----- -// ----- Adapted from TGet4v1Proc.h ----- -// ----- in RocLib/beamtime/tof-tdctest rev.4862 ----- -// ----- Known limitations: ----- -// ----- * Restricted to single ROC runs by the way FAIRROOT ----- -// ----- deals with MBS Sub-evt to unpacker association ----- -// ----- Default = RocEvent type, ROC0, formatOptic2 ----- -// ----- And also by the way chosen for FT histos names calib----- -// ----- * 32 bit mode histograms are not save in WriteHisto ----- -// ----- function ----- -// ----- * User has to take care of synchronizing options in ----- -// ----- TGet4v1Param and TMbsUnpackTofPar (active chips, ----- -// ----- nb chips, etc...) ----- -// ------------------------------------------------------------------ - -#ifndef TTOFGET4UNPACKER_H_ -#define TTOFGET4UNPACKER_H_ - -#include "TObject.h" - -#include <vector> - -class TMbsUnpackTofPar; - -class TClonesArray; -class TDirectory; - -// Old Go4 includes - // ROC -#include "roc/Message.h" -#include "roc/Board.h" -#include "roc/Iterator.h" - -// SubEvent ProcId from ROC library -#include "commons.h" - - // C++ -#include <vector> - -#ifdef HAVE_UINT8_T_HEADER_FILE -#include <_types/_uint8_t.h> -#include <_types/_uint16_t.h> -#include <_types/_uint32_t.h> -#include <_types/_uint64_t.h> -#else -#include <stdint.h> -#endif - - // GET4 -class TGet4v1Param; -#include "TGet4v1Event.h" -#include "TGet4v1Rec.h" - -class TH1; -class TH2; - -class TTofGet4Unpacker : public TObject -{ - public: - TTofGet4Unpacker(); - TTofGet4Unpacker( TMbsUnpackTofPar * parIn, Short_t sProcId = roc3587::proc_RocEvent, - Short_t sSubCrate = 0, Short_t sControl = roc::formatOptic2 ); - ~TTofGet4Unpacker(); - - virtual void Clear(Option_t *option); - - Bool_t Init(); - Bool_t InitParameters(); - Bool_t InitOutput(); - Bool_t InitConditions(); - - void ProcessGet4( UInt_t* pMbsData, UInt_t uLength ); - void ProcessGet4( UInt_t* pMbsData, UInt_t uLength, Char_t cSubCrate, Char_t cControl ); - - Bool_t CreateHistos(); - void FillHistos(); - void WriteHistos( TDirectory* inDir); - void DeleteHistos(); - - private: - // no default Copy constructor and = OP as class not meant to be copied - TTofGet4Unpacker(const TTofGet4Unpacker&); - TTofGet4Unpacker& operator=(const TTofGet4Unpacker&); - - TMbsUnpackTofPar * fParUnpack; - Int_t fiProcId; - Char_t fcSubCrate; - Char_t fcControl; - UInt_t fuNbTdc; - TClonesArray * fGet4BoardCollection; - Bool_t fbDataSavedForThisEvent; - - roc::MessageFormat ConvertToMsgFormat(const Char_t& cNumFormat); - - /** Method should add message to proper epoch buffer and check if necessary if it fits last trigger */ - void ProcessExtendedMessage(UInt_t uRocId, TGet4v1MessageExtended& extMess); // <- Done - void ProcessTriggerMessage(UInt_t uRocId, TGet4v1MessageExtended& extMess, - Int_t iTriggerIndex = -1); // <- Done - /** Method should check if message fits last trigger */ - Bool_t BuildHits(UInt_t uRocId, UInt_t uGet4Id, Bool_t bBufferToBuild); // <- Done - Bool_t CheckHit(UInt_t uRocId, UInt_t uGet4Id, Get4v1Hit& hit); // <- Done - - void CheckEventClosure(); // <- Done - - /** GET4 unpacking & pre-processing **/ - Bool_t ProcessRocSyncMessage( UInt_t uRocId, TGet4v1MessageExtended& extMess); // <- Done - Bool_t ProcessRocEpochMessage( UInt_t uRocId, TGet4v1MessageExtended& extMess); // <- Done - Bool_t ProcessGet4EpochMessage( UInt_t uRocId, TGet4v1MessageExtended& extMess); // <- Done - Bool_t ProcessGet4DataMessage( UInt_t uRocId, TGet4v1MessageExtended& extMess); // <- Done - Bool_t ProcessGet4ExtSyncMessage(UInt_t uRocId, TGet4v1MessageExtended& extMess); // <- NOT Done - Bool_t ProcessGet4SuppEpochMessage( UInt_t uRocId, TGet4v1MessageExtended& extMess); // <- Done - Bool_t ProcessGet4SuppDataMessage( UInt_t uRocId, TGet4v1MessageExtended& extMess); // <- Done - Bool_t ProcessGet4ReprocessSuppData( UInt_t uRocId, UInt_t uGet4Id ); // <- Done - - Int_t Process32BitGet4Message(UInt_t uRocId, TGet4v1MessageExtended& extMess); // <- Done - - Bool_t fb24bitsReadoutDetected; - Bool_t fb32bitsReadoutDetected; - Bool_t AnalyzeAllGet4Channels( Get4v1Event &eventFull ); // <- Done - Bool_t AnalyzeAllGet4Channels24Bits( Get4v1Event &eventFull ); // <- Done - Bool_t AnalyzeAllGet4Channels32Bits( Get4v1Event &eventFull ); // <- Done - -// Bool_t PrintRocEpochIndexes(UInt_t uRocId, Int_t uMessagePriority = 0); // <- Done -// Bool_t PrintRocEpochCycles(UInt_t uRocId, Int_t uMessagePriority = 0); // <- Done - - /* after event completion reset until next triggers are found*/ - void ResetTrigger(); - - /* after all input buffers are done, we reset end of buffer flag*/ - void ResetEndOfBuffer(); - - /* For Debug histograms*/ - void UpdateLeadingDnlHistograms( Get4v1Event &eventFull, UInt_t uRocId = 0 ); - void UpdateTrailingDnlHistograms( Get4v1Event &eventFull, UInt_t uRocId = 0 ); - - TGet4v1Param *fParam; -// TGet4v1Event *fOutputEvent; //! shortcut to output event - Get4v1Event fCurrentGet4Event; - - Bool_t fIsTimeSorted; // true if messages within mbs container are strictly time sorted - - TH1 *fEvntSize; - TH1 *fEvtPerProc; - TH1 *fEvtIndexRoc; - TH1 *fEvtIndexTrig; - TH1 *fEvtIndexVme; - UInt_t uInitialEvent; - UInt_t uEventCountsRoc; - UInt_t uEventCountsTrig; - UInt_t uEventCountsVme; - TH1 *fTriggerNumber; - - TH1 *fMsgsPerRoc; - TH1 *fTriggerPerRoc; - - TH1* fDeltaTriggerTime; // absolute time difference of all hits with respect to global trigger -// TGo4WinCond* fGlobalTriggerWind; // time window to assign hits to output event (relative to last global trigger) -// TGo4WinCond* fGlobalAUXWind; // time window to assign AUX to output event (relative to last global trigger) -// TGo4WinCond* fGlobalSelfTriggWind; // time window to detect coincidence of channel in self triggering case - TimeWindowCond* fGlobalTriggerWind; // time window to assign hits to output event (relative to last global trigger) - TimeWindowCond* fGlobalAUXWind; // time window to assign AUX to output event (relative to last global trigger) - TimeWindowCond* fGlobalSelfTriggWind; // time window to detect coincidence of channel in self triggering case - - ULong_t fTotaldatasize; - - UInt_t fCurrEvntTm; - - Double_t fLastRateTm; // last time of rate measurement - Double_t fRate; // currently calculated rate - - std::vector<TGet4v1Rec> ROC; //! array of all rocs and get4v1 histograms - Bool_t fFirstSubEvent; //! indicate if first subevent is processing - - Bool_t fHasNewGlobalTrigger; //! true if new global trigger was found - unsigned fTriggerCounter; //! count all trigger messages received - - - /** GET4 unpacking & pre-processing **/ - - // General counters (allow for example event jumps by stream server) - UInt_t printData; - UInt_t uNbEvents[get4v10::kuMaxRoc]; - UInt_t uFirstEventIndex[get4v10::kuMaxRoc]; - UInt_t uPrevEventIndex[get4v10::kuMaxRoc]; - - // Real events counters - UInt_t uEventInsideMbsEvtCount[get4v10::kuMaxRoc]; - UInt_t uRealEventsCount[get4v10::kuMaxRoc]; - UInt_t uNotEmptyEventInsideMbsEvtCount[get4v10::kuMaxRoc]; - UInt_t uNotEmptyRealEventsCount[get4v10::kuMaxRoc]; - - // Variables - Get4v1Hit fHitTemp; - // Histograms - - - // Get4 v1.0 - - // 24 bits - - // 32 bits - - ClassDef(TTofGet4Unpacker, 1) -}; - -#endif // TTOFGET4UNPACKER_H_ diff --git a/beamtime/tof/tdc/get4/TofGet4Def.h b/beamtime/tof/tdc/get4/TofGet4Def.h deleted file mode 100644 index d6564a01b29ad3430145c48600c3f8194994334e..0000000000000000000000000000000000000000 --- a/beamtime/tof/tdc/get4/TofGet4Def.h +++ /dev/null @@ -1,87 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TofGet4Def ----- -// ----- Created 22/05/2013 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ - -#ifndef TOFGET4DEF_H_ -#define TOFGET4DEF_H_ - -#include "Rtypes.h" - -// "//<- XXXX" shows to which preproc definition in original GO4 unpacker the constant correspond -namespace get4tdc -{ - const UInt_t kuNbChan = 8; // <- NB_CHAN_GET4 - // Size of one clock cycle (=1 coarse bin) - const Double_t kdClockCycleSize = 6400.0; //[ps] - // TODO:For now make 100ps default, maybe need later an option for it - const Double_t kdTotBinSize = 100.0; //ps - - // Maximal number of hits per channel per event stored - // More than for VFTX as free streaming can induce maby extra data points - const UInt_t kuNbMulti = 16; - - // Finetime need to be inverted after calibration as it count from next clock cycle - const Bool_t kbInvertFt = kFALSE; - - const Int_t kiFineTime = 0x0000007F; // Fine Counter value <- NB_BIN_GET4_FTS - const Int_t kiFtShift = 0; // Fine Counter offset - const Int_t kiCoarseTime = 0x0007FF80; // Coarse Counter value - const Int_t kiCtShift = 7; // Coarse Counter offset - - const Int_t kiCoarseCounterSize = ( (kiCoarseTime>>kiCtShift)+1 ); - const UInt_t kuCoarseOverflowTest = kiCoarseCounterSize / 2 ; // Limit for overflow check - - const Double_t kdBinSize = kdClockCycleSize / Double_t(kiFineTime + 1); // <- GET4_BIN_SIZE_IN_PS - const Int_t kiEpochInBins = kiFineTime + kiCoarseTime + 1; // <- GET4_EPOCH_IN_BINS - const Double_t kdEpochInPs = kiEpochInBins*kdBinSize; // alternatively: (kiCoarseTime>>kiCtShift + 1)*kdClockCycleSize // <- GET4_EPOCH_IN_PS -} - -namespace get4v10 { - const UInt_t kuNbChan = get4tdc::kuNbChan/2; // <- NB_CHAN_GET4 - - enum SysMessageTypes { - SYSMSG_GET4V1_32BIT_0 = 240, // Get4 V1.0, 32bit mode, Raw messages chip 0 link 1 - SYSMSG_GET4V1_32BIT_1 = 241, // Get4 V1.0, 32bit mode, Raw messages chip 1 link 1 - SYSMSG_GET4V1_32BIT_2 = 242, // Get4 V1.0, 32bit mode, Raw messages chip 2 link 1 - SYSMSG_GET4V1_32BIT_3 = 243, // Get4 V1.0, 32bit mode, Raw messages chip 3 link 1 - SYSMSG_GET4V1_32BIT_4 = 244, // Get4 V1.0, 32bit mode, Raw messages chip 4 link 1 - SYSMSG_GET4V1_32BIT_5 = 245, // Get4 V1.0, 32bit mode, Raw messages chip 5 link 1 - SYSMSG_GET4V1_32BIT_6 = 246, // Get4 V1.0, 32bit mode, Raw messages chip 6 link 1 - SYSMSG_GET4V1_32BIT_7 = 247, // Get4 V1.0, 32bit mode, Raw messages chip 7 link 1 - SYSMSG_GET4V1_32BIT_8 = 248, // Get4 V1.0, 32bit mode, Raw messages chip 0 link 2 - SYSMSG_GET4V1_32BIT_9 = 249, // Get4 V1.0, 32bit mode, Raw messages chip 1 link 2 - SYSMSG_GET4V1_32BIT_10 = 250, // Get4 V1.0, 32bit mode, Raw messages chip 2 link 2 - SYSMSG_GET4V1_32BIT_11 = 251, // Get4 V1.0, 32bit mode, Raw messages chip 3 link 2 - SYSMSG_GET4V1_32BIT_12 = 252, // Get4 V1.0, 32bit mode, Raw messages chip 4 link 2 - SYSMSG_GET4V1_32BIT_13 = 253, // Get4 V1.0, 32bit mode, Raw messages chip 5 link 2 - SYSMSG_GET4V1_32BIT_14 = 254, // Get4 V1.0, 32bit mode, Raw messages chip 6 link 2 - SYSMSG_GET4V1_32BIT_15 = 255, // Get4 V1.0, 32bit mode, Raw messages chip 7 link 2 - }; - - // Hardware max Number - const UInt_t kuMaxRoc = 15; // <- MAX_ROC - const UInt_t kuMaxGet4 = 32; // <- MAX_GET4 - const UInt_t kuMaxGet4Roc = 16; // <- MAX_GET4_PER_ROC - - // Max nb of each external trigger signal type - const UInt_t kuMaxAux = 4; // <- MAX_AUX - const UInt_t kuMaxSync = 2; // <- MAX_SYNC - - // Nb of ROC message to be printed? - const Int_t kiGet4MessPr = 6; // <- GET4_PRINT - - // Size of the epoch counters in ROC messages - const ULong64_t kulMainEpochCycleSz = 0xFFFFFFFFuLL; // <- GET4_EPOCH_CYCLE_SIZE - const ULong64_t kulGet4EpochCycleSz = 0xFFFFFFFFuLL; // <- MAIN_EPOCH_CYCLE_SIZE - - // Size of the SYNC cycles (aka nb of epoch between 2 epochs with SYNC flag) - const Int_t kiSyncCycleSzMain = 40; // <- MAIN_CLK_SYNC_SIZE - const Int_t kiSyncCycleSzGet4 = 25; // <- GET4_SYNC_CYCLE_SIZE - - // Self triggering - const Int_t kiMaxNbDataTriggs = 24; // <- MAX_DATA_TRIGG - const Int_t kiMaxNbSecTriggCh = 8; // <- MAX_SEC_TRIG -} - -#endif // TOFGET4DEF_H_ diff --git a/beamtime/tof/tdc/trb/TTofTrbTdcBoard.cxx b/beamtime/tof/tdc/trb/TTofTrbTdcBoard.cxx deleted file mode 100644 index 06154a530df3151a1c2846ca1c3629152bd80541..0000000000000000000000000000000000000000 --- a/beamtime/tof/tdc/trb/TTofTrbTdcBoard.cxx +++ /dev/null @@ -1,102 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- TTofTrbTdcBoard source file ----- -// ----- ----- -// ----- created by C. Simon on 2014-04-06 ----- -// ----- ----- -// ----- based on TTofVftxBoard by P.-A. Loizeau ----- -// ----- https://subversion.gsi.de/fairroot/cbmroot/development/ploizeau/ ----- -// ----- main/unpack/tof/tdc/vftx/TTofVftxBoard.cxx ----- -// ----- revision 20754, 2013-07-17 ----- -// ----------------------------------------------------------------------------- - -#include "TTofTrbTdcBoard.h" - -// TOF headers -#include "TofTdcDef.h" -#include "TofTrbTdcDef.h" -#include "TTofTrbTdcData.h" - -// FAIR headers -#include "FairLogger.h" - -// ROOT headers -#include "TClonesArray.h" - -TTofTrbTdcBoard::TTofTrbTdcBoard(): - TTofTdcBoard( toftdc::trb, trbtdc::kuNbChan ), - fRefChannelData(TTofTrbTdcData()), - fbIsCalibData(kFALSE), - fbIsChannelBufferIssue(kFALSE) -{ - CreateDataArray(); -} - -TTofTrbTdcBoard::~TTofTrbTdcBoard() -{ -} - -void TTofTrbTdcBoard::Clear( Option_t *option ) -{ - TTofTdcBoard::Clear( option ); - fRefChannelData.Clear( option ); - fbIsCalibData = kFALSE; - fbIsChannelBufferIssue = kFALSE; -} - -// TClonesArray versions -Bool_t TTofTrbTdcBoard::CreateDataArray() -{ - LOG(debug)<<" TTofTrbTdcBoard::CreateDataArray "; - if( 0 < GetChannelNb() && NULL == fDataCollection ) - fDataCollection = new TClonesArray( "TTofTrbTdcData", trbtdc::kuNbMulti * GetChannelNb() ); - else return kFALSE; - - return kTRUE; -} -Bool_t TTofTrbTdcBoard::ResizeArray() -{ - if( 0 < GetChannelNb() && NULL != fDataCollection ) - { - fDataCollection->Expand( trbtdc::kuNbMulti*GetChannelNb() ); - return kTRUE; - } // if( 0 < GetChannelNb() && NULL != fDataCollection ) - else return kFALSE; -} -UInt_t TTofTrbTdcBoard::AddData( TTofTrbTdcData & dataIn ) -{ - if( NULL != fDataCollection ) - { - Int_t iNextIndex = fDataCollection->GetEntriesFast(); - // Limiting the TClonesArray to trbtdc::kuNbMulti*trbtdc::kuNbChan entries - // might lead to unwanted data discard if the system is readout periodically - // without a trigger window enabled. The TClonesArray automatically expands - // if the original number of entries is exceeded by an out-of-range call - // of TClonesArray::ConstructedAt(). Due to the initial reservation of - // memory for trbtdc::kuNbMulti*trbtdc::kuNbChan hits per TDC per event - // we will most likely not face any performance penalty due to array - // expansion in triggered readout mode. -// if( iNextIndex < static_cast<Int_t>(trbtdc::kuNbMulti * GetChannelNb()) ) -// { - TTofTrbTdcData * dataSlot = (TTofTrbTdcData *)fDataCollection->ConstructedAt( iNextIndex ); - // (implicit) copy assignment operator - *dataSlot = dataIn; -// } // if( iNextIndex < toftdc::kuDefNbMulti * GetChannelNb() ) - return fDataCollection->GetEntriesFast(); - } // if( NULL != fDataCollection ) - else return 0; -} -TTofTrbTdcData * TTofTrbTdcBoard::GetDataPtr( UInt_t uDataIndex ) -{ - if( NULL != fDataCollection ) - { - if( static_cast<Int_t>(uDataIndex) < fDataCollection->GetEntriesFast() ) - return (TTofTrbTdcData *)fDataCollection->At( uDataIndex ); - else return NULL; - } // if( NULL != fDataCollection ) - else return NULL; -} -// ! no check on valid index in this one, Probably stupid method -const TTofTrbTdcData & TTofTrbTdcBoard::GetData( UInt_t uDataIndex ) const -{ - return *( (TTofTrbTdcData *)fDataCollection->At( uDataIndex ) ); -} diff --git a/beamtime/tof/tdc/trb/TTofTrbTdcBoard.h b/beamtime/tof/tdc/trb/TTofTrbTdcBoard.h deleted file mode 100644 index 98f0b466d9e5c12e0373f023628fe459d1d33cb3..0000000000000000000000000000000000000000 --- a/beamtime/tof/tdc/trb/TTofTrbTdcBoard.h +++ /dev/null @@ -1,54 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- TTofTrbTdcBoard header file ----- -// ----- ----- -// ----- created by C. Simon on 2014-04-05 ----- -// ----- ----- -// ----- based on TTofVftxBoard by P.-A. Loizeau ----- -// ----- https://subversion.gsi.de/fairroot/cbmroot/development/ploizeau/ ----- -// ----- main/unpack/tof/tdc/vftx/TTofVftxBoard.h ----- -// ----- revision 20754, 2013-07-17 ----- -// ----------------------------------------------------------------------------- - -#ifndef TTOFTRBTDCBOARD_H_ -#define TTOFTRBTDCBOARD_H_ - -#include "TTofTdcBoard.h" - -//class TTofTrbTdcData; -#include "TTofTrbTdcData.h" - -class TTofTrbTdcBoard : public TTofTdcBoard -{ - public: - TTofTrbTdcBoard(); - ~TTofTrbTdcBoard(); - - virtual void Clear(Option_t *option = ""); - - TTofTrbTdcData& GetRefChannelData() { return fRefChannelData; }; - - void SetCalibData( Bool_t bIsCalibTrigger ) { fbIsCalibData = bIsCalibTrigger; }; - Bool_t IsCalibData() { return fbIsCalibData; }; - - void SetChannelBufferIssue() { fbIsChannelBufferIssue = kTRUE; }; - Bool_t GetChannelBufferIssue() { return fbIsChannelBufferIssue; }; - - // TClones array version - // All these functions have to be implemented in the derived classes - // With the proper Data objects - virtual Bool_t CreateDataArray(); - virtual Bool_t ResizeArray(); - UInt_t AddData( TTofTrbTdcData & dataIn ); - TTofTrbTdcData * GetDataPtr( UInt_t uDataIndex ); - // ! no check on valid index in this one, Probably stupid method - const TTofTrbTdcData & GetData( UInt_t uDataIndex ) const; - - private: - TTofTrbTdcData fRefChannelData; - Bool_t fbIsCalibData; - Bool_t fbIsChannelBufferIssue; - - ClassDef(TTofTrbTdcBoard, 1) -}; - -#endif // TTOFTRBTDCBOARD_H_ diff --git a/beamtime/tof/tdc/trb/TTofTrbTdcCalib.cxx b/beamtime/tof/tdc/trb/TTofTrbTdcCalib.cxx deleted file mode 100644 index c7a40e5278d670d52ba23de95342b7d3cebb41f1..0000000000000000000000000000000000000000 --- a/beamtime/tof/tdc/trb/TTofTrbTdcCalib.cxx +++ /dev/null @@ -1,1736 +0,0 @@ -/** @file TTofTrbTdcCalib.cxx - ** @author Christian Simon <csimon@physi.uni-heidelberg.de> - ** @date 2016-04-18 - **/ -#include "TTofTrbTdcCalib.h" - -#include "TMbsUnpackTofPar.h" -#include "TMbsCalibTofPar.h" - -#include "TofDef.h" -#include "TTofTrbTdcBoard.h" -#include "TTofTrbTdcData.h" -#include "TTofCalibData.h" -#include "HadaqTdcMessage.h" -#include "TTrbHeader.h" - -#include "FairRun.h" -#include "FairRuntimeDb.h" -#include "FairRootManager.h" -#include "FairLogger.h" - -#include "TROOT.h" -#include "TFile.h" -#include "TTree.h" -#include "TH1.h" -#include "TF1.h" -#include "TGraph.h" -#include "TClonesArray.h" - -#include <map> - -using namespace std; - -// ============================================================================= -TTofTrbTdcCalib::TTofTrbTdcCalib() : - FairTask("TTofTrbTdcCalib", 0), - fMbsUnpackPar(NULL), - fMbsCalibPar(NULL), - fbCreateCalib(kFALSE), - fbSaveOutput(kFALSE), - fTrbTdcBoardCollection(NULL), - fTrbHeader(NULL), - fTrbTdcCalibCollection(NULL), - fiFineTimeMethod(0), - fiToTMethod(0), - fiMinEntriesBinByBin(100000), - fiMinEntriesLocalLimits(10000), - fbTimeContinuum(kTRUE), - fiTrailingOffset(0), - fuLowerLinearFineLimit(trbtdc::kuSimpleFineTimeMinValue), - fuUpperLinearFineLimit(trbtdc::kuSimpleFineTimeMaxValue), - fiReferenceBoard(0), - fbDisableBoard(NULL), - fdFinalOffset(NULL), - fdRefFineTime(), - fdFineTime(), - fliFullCoarseOverflows(0), - fdPreviousRefCoarseTime(0.), - fdInitialRefOffset(0.), - fbFirstEvent(kTRUE), - fdToTSingleLeading(-100.), - fBufferFile(NULL), - fBufferTree(NULL), - fiPreviousSpillIndex(-1), - fdPreviousEventTime(0.), - fdSpillStartTime(0.), - fCtsIdleTimeSpill(NULL), - fCtsSpillLength(NULL) -{ -} - -// ============================================================================= -void TTofTrbTdcCalib::Exec(Option_t */*option*/) -{ - const Int_t kiTdcChNb = static_cast<Int_t>(trbtdc::kuNbChan); - const Int_t kiNbActiveBoards = static_cast<Int_t>(fMbsUnpackPar->GetNbActiveBoards(tofMbs::trbtdc)); - - - if( fbCreateCalib ) - { - fBufferTree->Fill(); - } - else - { - // from TClonesArray.cxx: - // TClonesArray allows you to "reuse" the same portion of memory for new/delete avoiding memory - // fragmentation and memory growth and improving the performance by orders of magnitude. - // Every time the memory of the TClonesArray has to be reused, the Clear() method is used. - // To provide its benefits, each TClonesArray must be allocated once per process and disposed - // of (deleted) only when not needed any more. - fTrbTdcCalibCollection->Clear("C"); - - Int_t iArrayEntries = fTrbTdcBoardCollection->GetEntriesFast(); - - if(iArrayEntries != kiNbActiveBoards) - { - LOG(fatal)<<"A different number of TTofTrbTdcBoard objects found in the tree than given in the parameter file."; - return; - } - - TTofTrbTdcBoard* tTrbTdcBoard(0); - - if(fiReferenceBoard < iArrayEntries) - { - tTrbTdcBoard = dynamic_cast<TTofTrbTdcBoard*>(fTrbTdcBoardCollection->At(fiReferenceBoard)); - } - - if(!tTrbTdcBoard) - { - LOG(fatal)<<Form("Reference TTofTrbTdcBoard object indexed %d not found.",fiReferenceBoard); - return; - } - - // Vector holding for each event the time correction offsets for all TDCs - vector<Double_t> dBoardOffsets( iArrayEntries, 0. ); - - const TTofTrbTdcData& tRefTdcRefTime = tTrbTdcBoard->GetRefChannelData(); - - Double_t dRefCoarseTime = static_cast<Double_t>(tRefTdcRefTime.GetFullCoarseTime()); - - // The full coarse counter of the reference TDC overflowed between - // this event and the previous one. To keep the time axis continuous, - // keep track of such overflows and take them into account. - if(dRefCoarseTime - fdPreviousRefCoarseTime < -static_cast<Double_t>(trbtdc::kliFullCoarseSize)/2.) - { - fliFullCoarseOverflows++; - } - - fdPreviousRefCoarseTime = dRefCoarseTime; - - Double_t dReferenceOffset = dRefCoarseTime - (fdRefFineTime.at(fiReferenceBoard)).at(static_cast<Int_t>(tRefTdcRefTime.GetFineTime())); - - if( fbFirstEvent ) - { - fdInitialRefOffset = dReferenceOffset; - fbFirstEvent = kFALSE; - - // The pre-trigger window can extend up to 1 epoch into - // the past. By subtracting the initial reference offset - // excluding the maximum pre-trigger window range we can - // avoid handling any negative numbers in the analysis. - // This does, however, not work for the free-streaming - // system mockup which does not know about the trigger - // window. - fdInitialRefOffset -= static_cast<Double_t>(trbtdc::kliEpochSize); - } - - if( fbTimeContinuum ) - { - // Calculate the board offset for each channel of the reference board - dBoardOffsets.at(fiReferenceBoard) = fdInitialRefOffset; - - // continuous time axis - dBoardOffsets.at(fiReferenceBoard) -= static_cast<Double_t>(fliFullCoarseOverflows*trbtdc::kliFullCoarseSize); - - Double_t fdCurrentEventTime = (dReferenceOffset-dBoardOffsets.at(fiReferenceBoard))*trbtdc::kdClockCycleSizeSec; - - // Store the event time in the run (reference channel of the reference TDC) - fTrbHeader->SetTimeInRun(fdCurrentEventTime); - - if( 0 > fiPreviousSpillIndex ) - { - fiPreviousSpillIndex = 0; - - fdSpillStartTime = fdCurrentEventTime; - } - // no event for at least 2 seconds: most probably a new spill started - // (criterion does not work if the spill breaks are not trigger free) - else if((fdCurrentEventTime-fdPreviousEventTime) > 2.) - { - fiPreviousSpillIndex++; - - fCtsSpillLength->Fill(fdPreviousEventTime-fdSpillStartTime); - - fdSpillStartTime = fdCurrentEventTime; - - // time since the last trigger procession in spill breaks - fCtsIdleTimeSpill->Fill(fdCurrentEventTime-fdPreviousEventTime); - } - - // Index all spills in a run consecutively - fTrbHeader->SetSpillIndex(fiPreviousSpillIndex); - - fTrbHeader->SetTimeInSpill(fdCurrentEventTime-fdSpillStartTime); - - fdPreviousEventTime = fdCurrentEventTime; - } - - - // TODO: The loop to determine the board offsets could as well be merged with the - // main loop over boards and channels. For now, we keep it separate in case a - // mechanism to handle clock counter jumps needs to be implemented in the future. - for(Int_t iBoardIndex = 0; iBoardIndex < iArrayEntries; iBoardIndex++) - { - if( (fiReferenceBoard != iBoardIndex) && !fbDisableBoard->at(iBoardIndex) ) - { - tTrbTdcBoard = dynamic_cast<TTofTrbTdcBoard*>(fTrbTdcBoardCollection->At(iBoardIndex)); - - const TTofTrbTdcData& tTdcRefTime = tTrbTdcBoard->GetRefChannelData(); - - Double_t dCoarseTime = static_cast<Double_t>(tTdcRefTime.GetFullCoarseTime()); - - Double_t dTimeOffset = dCoarseTime - (fdRefFineTime.at(iBoardIndex)).at(static_cast<Int_t>(tTdcRefTime.GetFineTime())) - dReferenceOffset; - - // Ensure equal offsets throughout the data sample, i.e. correct for - // overflows of the TDCs' full coarse counters w.r.t. the reference TDC's - // full coarse counter. - if( (dTimeOffset - fdFinalOffset->at(iBoardIndex)) > static_cast<Double_t>(trbtdc::kliFullCoarseSize)/4. ) - { - dBoardOffsets.at(iBoardIndex) += static_cast<Double_t>(trbtdc::kliFullCoarseSize); - } - else if( (dTimeOffset - fdFinalOffset->at(iBoardIndex)) < -static_cast<Double_t>(trbtdc::kliFullCoarseSize)/4. ) - { - dBoardOffsets.at(iBoardIndex) -= static_cast<Double_t>(trbtdc::kliFullCoarseSize); - } - - // Annihilate these offsets (constrained by differences in the LVDS trigger - // signal run times that cannot be corrected for on the raw-data level). - dBoardOffsets.at(iBoardIndex) += fdFinalOffset->at(iBoardIndex); - - if( fbTimeContinuum ) - { - // Let the common time axis of all TDCs start at 0 (with some negative - // values from the content of the first event's pre-trigger buffer). - dBoardOffsets.at(iBoardIndex) += fdInitialRefOffset; - - // For time axis continuity, correct for full coarse counter overflows - // in the reference TDC. - dBoardOffsets.at(iBoardIndex) -= static_cast<Double_t>(fliFullCoarseOverflows*trbtdc::kliFullCoarseSize); - } - } - } - - // Now all TDC offsets are available in the vector dBoardOffsets. - // We can again loop over all boards and consider the regular TDC - // channels this time. - for(Int_t iBoardIndex = 0; iBoardIndex < iArrayEntries; iBoardIndex++) - { - if( !fbDisableBoard->at(iBoardIndex) || (fiReferenceBoard == iBoardIndex) ) - { - tTrbTdcBoard = dynamic_cast<TTofTrbTdcBoard*>(fTrbTdcBoardCollection->At(iBoardIndex)); - - // Information needed to board-internally correct for full coarse counter - // overflows w.r.t. the respective reference channel - const TTofTrbTdcData& tTdcRefTime = tTrbTdcBoard->GetRefChannelData(); - Long64_t liRefCoarseTime = static_cast<Long64_t>(tTdcRefTime.GetFullCoarseTime()); - - vector< vector<const TTofTrbTdcData*> > tToTEvenEdgeBuffers( kiTdcChNb/2, vector<const TTofTrbTdcData*>() ); - vector< vector<const TTofTrbTdcData*> > tToTOddEdgeBuffers( kiTdcChNb/2, vector<const TTofTrbTdcData*>() ); - vector< vector<const TTofTrbTdcData*> > tToTBuildingBuffers( kiTdcChNb/2, vector<const TTofTrbTdcData*>() ); - - // Reserve memory for the vectors. Elements will be inserted into the - // container using the push_back method. When the next element to be - // appended to the vector would exceed the container's capacity, - // push_back allocates a new buffer for the vector elements which capacity - // geometrically progresses (new capacity will be k*old_size with k > 1). - // So there is actually no need to care about managing vector capacities - // once some (reasonably large) initial memory has been reserved for the container. - for( Int_t iChannelIndex = 0; iChannelIndex < kiTdcChNb/2; iChannelIndex++ ) - { - (tToTEvenEdgeBuffers.at(iChannelIndex)).reserve(static_cast<Int_t>(trbtdc::kuNbMulti)); - (tToTOddEdgeBuffers.at(iChannelIndex)).reserve(static_cast<Int_t>(trbtdc::kuNbMulti)); - (tToTBuildingBuffers.at(iChannelIndex)).reserve(2*static_cast<Int_t>(trbtdc::kuNbMulti)); - } - - // Loop over all channel hits in the TDC to build a hit index map and - // fill the ToT building buffers - for( Int_t iDataIndex = 0; iDataIndex < static_cast<Int_t>(tTrbTdcBoard->GetDataNb()); iDataIndex++ ) - { - const TTofTrbTdcData* data = tTrbTdcBoard->GetDataPtr( static_cast<UInt_t>(iDataIndex) ); - - Int_t iCurrentChannel(static_cast<Int_t>(data->GetChannel())); - - if( 0 == iCurrentChannel % 2) - { - (tToTEvenEdgeBuffers.at(iCurrentChannel/2)).push_back(data); - } - else - { - (tToTOddEdgeBuffers.at(iCurrentChannel/2)).push_back(data); - } - - (tToTBuildingBuffers.at(iCurrentChannel/2)).push_back(data); - } - - // ToT building function - for( Int_t iChannelIndex = 0; iChannelIndex < kiTdcChNb/2; iChannelIndex++ ) - { - UInt_t uLeadingModulo; - UInt_t uTrailingModulo; - - UInt_t uLeadingMultiplicity; - UInt_t uTrailingMultiplicity; - - // positive LVDS input signal - // leading edge in even channel - // trailing edge in odd channel - if( fMbsCalibPar->GetTotInvFlag( toftdc::trb, iBoardIndex, iChannelIndex ) ) - { - uLeadingModulo = 0; - uTrailingModulo = 1; - - uLeadingMultiplicity = (tToTEvenEdgeBuffers.at(iChannelIndex)).size(); - uTrailingMultiplicity = (tToTOddEdgeBuffers.at(iChannelIndex)).size(); - } - // negative LVDS input signal - // trailing edge in even channel - // leading edge in odd channel - else - { - uTrailingModulo = 0; - uLeadingModulo = 1; - - uTrailingMultiplicity = (tToTEvenEdgeBuffers.at(iChannelIndex)).size(); - uLeadingMultiplicity = (tToTOddEdgeBuffers.at(iChannelIndex)).size(); - } - - // advanced ToT building - if( 0 == fiToTMethod ) - { - map<Double_t,UInt_t> tToTEdgeMatching; - - for( Int_t iSignalEdge = 0; iSignalEdge < static_cast<Int_t>((tToTBuildingBuffers.at(iChannelIndex)).size()); iSignalEdge++ ) - { - const TTofTrbTdcData* tEdgeData = (tToTBuildingBuffers.at(iChannelIndex)).at(iSignalEdge); - - Long64_t liEdgeCoarseTime = static_cast<Long64_t>(tEdgeData->GetFullCoarseTime()); - hadaq::TdcMessage::CoarseOverflow(liEdgeCoarseTime,liRefCoarseTime); - - Double_t dEdgeTimeStamp = static_cast<Double_t>(liEdgeCoarseTime); - - dEdgeTimeStamp -= ((fdFineTime.at(iBoardIndex)).at(static_cast<Int_t>(tEdgeData->GetChannel()))).at(static_cast<Int_t>(tEdgeData->GetFineTime())); - - // Artificially stretching the time over threshold by offsetting the - // trailing edge time to account for situations where the leading edge - // run time on the chip is longer (up to a few ns) than the trailing - // edge run time. - if( uTrailingModulo == tEdgeData->GetChannel() % 2 ) - { - dEdgeTimeStamp += static_cast<Double_t>(fiTrailingOffset); - } - - tToTEdgeMatching.insert( std::make_pair(dEdgeTimeStamp,tEdgeData->GetChannel() % 2) ); - } - - // Now all leading and trailing edges have been corrected (except for the board offset) - // and are sorted by digitization time (map key) in increasing order. We iterate over - // the map tToTEdgeMatching and try to combine edges. - // features: several consecutive leading edges -> assign all but the last one a fixed ToT - // several consecutive trailing edges -> ignore all but the first one - - Bool_t bValidLeadingEdge(kFALSE); - Double_t dLastLeadingTime; - - for( map<Double_t,UInt_t>::iterator it = tToTEdgeMatching.begin(); it != tToTEdgeMatching.end(); ++it ) - { - // leading edge - if( it->second == uLeadingModulo ) - { - // For several leading edges in a row, assign a fixed ToT value to those which are not followed - // by a trailing edge - if( bValidLeadingEdge ) - { - // ToT in ps - Double_t dTimeOverThreshold = fdToTSingleLeading; - - // Calibrated hit time in ps - Double_t dCalibHitTime = (dLastLeadingTime - dBoardOffsets.at(iBoardIndex))*trbtdc::kdClockCycleSize; - - // Here, we use TClonesArray::ConstructedAt() instead of TObject's placement new operator to save - // a constructor call if a TTofCalibData object has been constructed (and cleared at the beginning - // of the Exec method) at the respective array index before. Member variables are changed by mutator methods. - TTofCalibData* tNewHit = dynamic_cast<TTofCalibData*>(fTrbTdcCalibCollection->ConstructedAt(fTrbTdcCalibCollection->GetEntriesFast())); - - tNewHit->SetData( toftdc::trb, static_cast<UInt_t>(iBoardIndex), static_cast<UInt_t>(iChannelIndex), - dCalibHitTime, dTimeOverThreshold, 2 ); - } - - bValidLeadingEdge = kTRUE; - dLastLeadingTime = it->first; - } - // trailing edge - else - { - if( bValidLeadingEdge ) - { - // ToT in ps - Double_t dTimeOverThreshold = (it->first - dLastLeadingTime)*trbtdc::kdClockCycleSize; - - // Calibrated hit time in ps - Double_t dCalibHitTime = (dLastLeadingTime - dBoardOffsets.at(iBoardIndex))*trbtdc::kdClockCycleSize; - - // Here, we use TClonesArray::ConstructedAt() instead of TObject's placement new operator to save - // a constructor call if a TTofCalibData object has been constructed (and cleared at the beginning - // of the Exec method) at the respective array index before. Member variables are changed by mutator methods. - TTofCalibData* tNewHit = dynamic_cast<TTofCalibData*>(fTrbTdcCalibCollection->ConstructedAt(fTrbTdcCalibCollection->GetEntriesFast())); - - tNewHit->SetData( toftdc::trb, static_cast<UInt_t>(iBoardIndex), static_cast<UInt_t>(iChannelIndex), - dCalibHitTime, dTimeOverThreshold, 2 ); - } - - bValidLeadingEdge = kFALSE; - - } - } - - } - // pair-wise ToT building - else - { - if( uLeadingMultiplicity == uTrailingMultiplicity ) - { - for( Int_t iEvenIndex = 0; iEvenIndex < static_cast<Int_t>((tToTEvenEdgeBuffers.at(iChannelIndex)).size()); iEvenIndex++ ) - { - const TTofTrbTdcData* leadingData; - const TTofTrbTdcData* trailingData; - - if( 0x0 == uLeadingModulo ) - { - leadingData = (tToTEvenEdgeBuffers.at(iChannelIndex)).at(iEvenIndex); - trailingData = (tToTOddEdgeBuffers.at(iChannelIndex)).at(iEvenIndex); - } - else - { - leadingData = (tToTOddEdgeBuffers.at(iChannelIndex)).at(iEvenIndex); - trailingData = (tToTEvenEdgeBuffers.at(iChannelIndex)).at(iEvenIndex); - } - - Long64_t liLeadingCoarseTime = static_cast<Long64_t>(leadingData->GetFullCoarseTime()); - Long64_t liTrailingCoarseTime = static_cast<Long64_t>(trailingData->GetFullCoarseTime()); - - // Correcting for TDC internal coarse counter overflows w.r.t. - // the reference channel - hadaq::TdcMessage::CoarseOverflow(liLeadingCoarseTime,liRefCoarseTime); - hadaq::TdcMessage::CoarseOverflow(liTrailingCoarseTime,liRefCoarseTime); - - Double_t dLeadingTimeStamp = static_cast<Double_t>(liLeadingCoarseTime); - Double_t dTrailingTimeStamp = static_cast<Double_t>(liTrailingCoarseTime); - - dLeadingTimeStamp -= ((fdFineTime.at(iBoardIndex)).at(static_cast<Int_t>(leadingData->GetChannel()))).at(static_cast<Int_t>(leadingData->GetFineTime())); - dTrailingTimeStamp -= ((fdFineTime.at(iBoardIndex)).at(static_cast<Int_t>(trailingData->GetChannel()))).at(static_cast<Int_t>(trailingData->GetFineTime())); - - // Artificially stretching the time over threshold by offsetting the - // trailing edge time to account for situations where the leading edge - // run time on the chip is longer (up to 3 ns) than the trailing - // edge run time. - dTrailingTimeStamp += static_cast<Double_t>(fiTrailingOffset); - - // ToT in ps - Double_t dTimeOverThreshold = (dTrailingTimeStamp - dLeadingTimeStamp)*trbtdc::kdClockCycleSize; - - // Calibrated hit time - Double_t dCalibHitTime = (dLeadingTimeStamp - dBoardOffsets.at(iBoardIndex))*trbtdc::kdClockCycleSize; - - // Here, we use TClonesArray::ConstructedAt() instead of TObject's placement new operator to save - // a constructor call if a TTofCalibData object has been constructed (and cleared at the beginning - // of the Exec method) at the respective array index before. Member variables are changed by mutator methods. - TTofCalibData* tNewHit = dynamic_cast<TTofCalibData*>(fTrbTdcCalibCollection->ConstructedAt(fTrbTdcCalibCollection->GetEntriesFast())); - - tNewHit->SetData( toftdc::trb, static_cast<UInt_t>(iBoardIndex), static_cast<UInt_t>(iChannelIndex), - dCalibHitTime, dTimeOverThreshold, 2 ); - } - } - } - } - } - - } - } -} - -// ============================================================================= -InitStatus TTofTrbTdcCalib::Init() -{ - if( !fMbsUnpackPar || !fMbsCalibPar ) - { - LOG(error)<<"Parameter containers not initialized."; - return kFATAL; - } - - const Int_t kiTdcChNb = static_cast<Int_t>(trbtdc::kuNbChan); - - const Int_t kiNbActiveBoards = static_cast<Int_t>(fMbsUnpackPar->GetNbActiveBoards(tofMbs::trbtdc)); - if( fiReferenceBoard >= kiNbActiveBoards ) - { - LOG(error)<<"Reference TDC index out of range."; - return kFATAL; - } - - if( fiFineTimeMethod < 0 || fiFineTimeMethod > 2 ) - { - LOG(error)<<"Invalid fine time interpolation method."; - LOG(error)<<"Use 0 for bin-by-bin center interpolation."; - LOG(error)<<"Use 1 for bin-by-bin edge interpolation."; - LOG(error)<<"Use 2 for linear interpolation."; - return kFATAL; - } - - if( fiToTMethod < 0 || fiToTMethod > 1 ) - { - LOG(error)<<"Invalid ToT building method."; - LOG(error)<<"Use 0 for advanced ToT building."; - LOG(error)<<"Use 1 for pair-wise ToT edge matching (requires same numbers of leading and trailing edges for the channel)."; - return kFATAL; - } - - FairRootManager* tRootManager = FairRootManager::Instance(); - - // Get access to the output-tree branch holding TTofTrbTdcBoard objects - fTrbTdcBoardCollection = dynamic_cast<TClonesArray*>(tRootManager->GetObject("TofTrbTdc")); - if( !fTrbTdcBoardCollection ) - { - LOG(error)<<"Could not retrieve branch 'TofTrbTdc' from FairRootManager."; - return kFATAL; - } - - if( fbCreateCalib ) - { - // Generating TDC to TDC offset calibration requires the full raw data branch - // of the event tree to be accessible in Finish(). We could achieve this by - // making the branch 'TofTrbTdc' permanent in FairRootManager's output tree. - // Depending on the calibration statistics this might lead to very big file - // sizes although we only need the calibration histograms and values in the - // real data processing run. This gave rise to the idea of creating our own - // tree file for making the TTofTrbTdcBoard objects available independently - // of the memory persistency of 'TofTrbTdc'. Once the calibration run has - // finished this file can be discarded. - // Also, we cannot risk working with a pure memory tree as we might run out - // of memory and crash accordingly at high calibration statistics. - - TDirectory* tOldDirectory = gDirectory; - - TFile* tOutputFile = tRootManager->GetOutFile(); - - TString tBufferFileName(tOutputFile->GetName()); - tBufferFileName.Replace(tBufferFileName.Length()-10,10,"buffer.root"); - - fBufferFile = new TFile(tBufferFileName.Data(),"RECREATE"); - - fBufferTree = new TTree("trbtree","My TRB tree"); - - fBufferTree->Branch("TofTrbTdc",&fTrbTdcBoardCollection); - - tOldDirectory->cd(); - } - else - { - fTrbHeader = dynamic_cast<TTrbHeader*>(tRootManager->GetObject("TofTrbHeader.")); - if( !fTrbHeader ) - { - LOG(error)<<"Could not retrieve branch 'TofTrbHeader' from FairRootManager."; - return kFATAL; - } - - fCtsIdleTimeSpill = dynamic_cast<TH1I*>(gROOT->FindObjectAny("tof_trb_cts_idle_spill")); - if( !fCtsIdleTimeSpill ) - { - LOG(error)<<"Could not retrieve histogram 'tof_trb_cts_idle_spill' from TROOT instance."; - return kFATAL; - } - - fCtsSpillLength = dynamic_cast<TH1I*>(gROOT->FindObjectAny("tof_trb_cts_spill_length")); - if( !fCtsSpillLength ) - { - LOG(error)<<"Could not retrieve histogram 'tof_trb_cts_spill_length' from TROOT instance."; - return kFATAL; - } - - // By default, after construction TObject** TClonesArray::fCont points to 1000 pointers - // to objects that are supposed to be stored in the array. If the total number of TDC hits per - // event exceeded this limit, the TClonesArray would be automatically expanded. To prevent - // such an expansion from happening, at least with an asynchronous readout trigger and the - // trigger window feature enabled, we ask for the following number of pointers: - fTrbTdcCalibCollection = new TClonesArray("TTofCalibData",kiNbActiveBoards*kiTdcChNb/2*trbtdc::kuNbMulti); - - // We apply the calibration to the raw data and create TTofCalibData objects - // as a result. When creating the calibration files, we do not further process - // the data. - tRootManager->Register("TofCalibData","TofCalib",static_cast<TCollection*>(fTrbTdcCalibCollection),fbSaveOutput); - - TFile* tOutputFile = tRootManager->GetOutFile(); - - TString tCalibFileName(tOutputFile->GetName()); - tCalibFileName.Replace(tCalibFileName.Length()-8,8,"calib.root"); - - TFile* tCalibFile = new TFile(tCalibFileName.Data(),"READ"); - // gDirectory points to the calibration file - if( tCalibFile->IsZombie() ) - { - tCalibFile->Close(); - delete tCalibFile; - - LOG(error)<<"Could not open calibration file."; - return kFATAL; - } - - if( !tCalibFile->cd("TofTrbCalib") ) - { - LOG(error)<<"Could not find directory 'TofTrbCalib' in calibration file."; - return kFATAL; - } - - TDirectory* tCalibParent = gDirectory; - - vector<Int_t>* iReferenceBoard = NULL; - - gDirectory->GetObject("iReferenceBoard",iReferenceBoard); - if( !iReferenceBoard ) - { - LOG(error)<<"Could not retrieve 'iReferenceBoard' from the calibration file."; - return kFATAL; - } - - if( iReferenceBoard->at(0) != fiReferenceBoard ) - { - LOG(warn)<<Form("TDC to TDC offsets were calibrated w.r.t. TDC %d, not the currently selected TDC %d.",iReferenceBoard->at(0),fiReferenceBoard); - LOG(warn)<<"The current setting will be ignored."; - - fiReferenceBoard = iReferenceBoard->at(0); - } - - vector<UInt_t>* uGlobalFineTimeLimits = NULL; - - gDirectory->GetObject("uGlobalFineTimeLimits",uGlobalFineTimeLimits); - if( !uGlobalFineTimeLimits ) - { - LOG(error)<<"Could not retrieve 'uGlobalFineTimeLimits' from the calibration file."; - return kFATAL; - } - - if( uGlobalFineTimeLimits->at(0) != fuLowerLinearFineLimit || uGlobalFineTimeLimits->at(1) != fuUpperLinearFineLimit ) - { - LOG(warn)<<"The global linear fine time interpolation limits do not match the ones used for TDC offset calibration."; - LOG(warn)<<"The current settings will be ignored."; - - fuLowerLinearFineLimit = uGlobalFineTimeLimits->at(0); - fuUpperLinearFineLimit = uGlobalFineTimeLimits->at(1); - } - - gDirectory->GetObject("bDisableBoard",fbDisableBoard); - if( !fbDisableBoard ) - { - LOG(error)<<"Could not retrieve 'bDisableBoard' from the calibration file."; - return kFATAL; - } - - gDirectory->GetObject("dFinalOffset",fdFinalOffset); - if( !fdFinalOffset ) - { - LOG(error)<<"Could not retrieve 'dFinalOffset' from the calibration file."; - return kFATAL; - } - - - fdRefFineTime.resize( kiNbActiveBoards, vector<Double_t>( trbtdc::kiFineCounterSize, 0. ) ); - fdFineTime.resize( kiNbActiveBoards, vector< vector<Double_t> >( kiTdcChNb, vector<Double_t>( trbtdc::kiFineCounterSize, 0. ) ) ); - - vector<TH1I*> tRefFineTimeHistos( kiNbActiveBoards, NULL ); - vector< vector<TH1I*> > tFineTimeHistos( kiNbActiveBoards, vector<TH1I*>( kiTdcChNb, NULL ) ); - - vector< vector<UInt_t> > uRefFineTimeLimits( kiNbActiveBoards, vector<UInt_t>( 2, 0 ) ); - vector< vector< vector<UInt_t> > > uFineTimeLimits( kiNbActiveBoards, vector< vector<UInt_t> >( kiTdcChNb, vector<UInt_t>( 2, 0 ) ) ); - - for(Int_t iBoardIndex = 0; iBoardIndex < kiNbActiveBoards; iBoardIndex++) - { - if(!fMbsCalibPar->CheckTotInvFlag( toftdc::trb, static_cast<UInt_t>(iBoardIndex) )) - { - LOG(error)<<Form("Check your parCalib* file! No ToT inversion flags provided for TDCs indexed %2d and above.",iBoardIndex); - return kFATAL; - } - - if( !tCalibParent->cd(Form("tdc_b%03d",iBoardIndex)) ) - { - LOG(error)<<Form("Could not find directory 'tdc_b%03d' in calibration file.",iBoardIndex); - return kFATAL; - } - - gDirectory->GetObject(Form("calib_trb_ft_b%03d_ref",iBoardIndex),tRefFineTimeHistos.at(iBoardIndex)); - - if( tRefFineTimeHistos.at(iBoardIndex) ) - { - tRefFineTimeHistos.at(iBoardIndex)->SetDirectory(gROOT); - - (uRefFineTimeLimits.at(iBoardIndex)).at(0) = static_cast<UInt_t>(tRefFineTimeHistos.at(iBoardIndex)->FindFirstBinAbove(0.)); - (uRefFineTimeLimits.at(iBoardIndex)).at(1) = static_cast<UInt_t>(tRefFineTimeHistos.at(iBoardIndex)->FindLastBinAbove(0.)); - - // Insufficient number of entries in the fine time histogram - // OR unreasonably narrow fine time distribution. - // Switch to linear interpolation based on globally defined limits. - if( (fiMinEntriesLocalLimits > tRefFineTimeHistos.at(iBoardIndex)->GetEntries()) || - (trbtdc::kuMinimumFineTimeRange > ((uRefFineTimeLimits.at(iBoardIndex)).at(1) - (uRefFineTimeLimits.at(iBoardIndex)).at(0))) ) - { - hadaq::TdcMessage::SetFineLimits(fuLowerLinearFineLimit,fuUpperLinearFineLimit); - } - else - { - hadaq::TdcMessage::SetFineLimits((uRefFineTimeLimits.at(iBoardIndex)).at(0),(uRefFineTimeLimits.at(iBoardIndex)).at(1)); - } - - // Insufficient number of entries in the fine time histogram - // OR unreasonably narrow fine time distribution. - // Applying the bin-by-bin interpolation method is not reasonable. - // Regardless of the chosen global interpolation method data from - // this TDC channel will be interpolated linearly within the globally - // defined limits. - if( (fiMinEntriesBinByBin > tRefFineTimeHistos.at(iBoardIndex)->GetEntries()) || - (trbtdc::kuMinimumFineTimeRange > ((uRefFineTimeLimits.at(iBoardIndex)).at(1) - (uRefFineTimeLimits.at(iBoardIndex)).at(0))) ) - { - // fine time range [0,1023] - // histogram bin range: [1,1024] - // mapping: ft(0) -> bin(1) - // ft(1023) -> bin(1024) - for(Int_t iBin = 1; iBin <= tRefFineTimeHistos.at(iBoardIndex)->GetNbinsX(); iBin++) - { - (fdRefFineTime.at(iBoardIndex)).at(iBin-1) = hadaq::TdcMessage::SimpleFineCalibr(static_cast<UInt_t>(iBin)-1); - } - } - else - { - if( trbtdc::finetime_bincenter == fiFineTimeMethod ) - { - for(Int_t iBin = 1; iBin <= tRefFineTimeHistos.at(iBoardIndex)->GetNbinsX(); iBin++) - { - (fdRefFineTime.at(iBoardIndex)).at(iBin-1) = (tRefFineTimeHistos.at(iBoardIndex)->Integral(1,iBin) - 0.5*tRefFineTimeHistos.at(iBoardIndex)->GetBinContent(iBin)) - /tRefFineTimeHistos.at(iBoardIndex)->Integral(1,tRefFineTimeHistos.at(iBoardIndex)->GetNbinsX()); - } - } - else if( trbtdc::finetime_binedge == fiFineTimeMethod ) - { - for(Int_t iBin = 1; iBin <= tRefFineTimeHistos.at(iBoardIndex)->GetNbinsX(); iBin++) - { - (fdRefFineTime.at(iBoardIndex)).at(iBin-1) = tRefFineTimeHistos.at(iBoardIndex)->Integral(1,iBin) - /tRefFineTimeHistos.at(iBoardIndex)->Integral(1,tRefFineTimeHistos.at(iBoardIndex)->GetNbinsX()); - } - } - else - { - for(Int_t iBin = 1; iBin <= tRefFineTimeHistos.at(iBoardIndex)->GetNbinsX(); iBin++) - { - (fdRefFineTime.at(iBoardIndex)).at(iBin-1) = hadaq::TdcMessage::SimpleFineCalibr(static_cast<UInt_t>(iBin)-1); - } - } - } - - } - else - { - LOG(error)<<Form("Could not retrieve the reference fine time histogram of TDC %d.",iBoardIndex); - return kFATAL; - } - - for(Int_t iChannelIndex = 0; iChannelIndex < kiTdcChNb; iChannelIndex++) - { - gDirectory->GetObject(Form("calib_trb_ft_b%03d_ch%03d",iBoardIndex,iChannelIndex),(tFineTimeHistos.at(iBoardIndex)).at(iChannelIndex)); - - if( (tFineTimeHistos.at(iBoardIndex)).at(iChannelIndex) ) - { - (tFineTimeHistos.at(iBoardIndex)).at(iChannelIndex)->SetDirectory(gROOT); - - ((uFineTimeLimits.at(iBoardIndex)).at(iChannelIndex)).at(0) = static_cast<UInt_t>((tFineTimeHistos.at(iBoardIndex)).at(iChannelIndex)->FindFirstBinAbove(0.)); - ((uFineTimeLimits.at(iBoardIndex)).at(iChannelIndex)).at(1) = static_cast<UInt_t>((tFineTimeHistos.at(iBoardIndex)).at(iChannelIndex)->FindLastBinAbove(0.)); - - // Insufficient number of entries in the fine time histogram - // OR unreasonably narrow fine time distribution. - // Switch to linear interpolation based on globally defined limits. - if( (fiMinEntriesLocalLimits > (tFineTimeHistos.at(iBoardIndex)).at(iChannelIndex)->GetEntries()) || - (trbtdc::kuMinimumFineTimeRange > (((uFineTimeLimits.at(iBoardIndex)).at(iChannelIndex)).at(1) - ((uFineTimeLimits.at(iBoardIndex)).at(iChannelIndex)).at(0))) ) - { - hadaq::TdcMessage::SetFineLimits(fuLowerLinearFineLimit,fuUpperLinearFineLimit); - } - else - { - hadaq::TdcMessage::SetFineLimits(((uFineTimeLimits.at(iBoardIndex)).at(iChannelIndex)).at(0),((uFineTimeLimits.at(iBoardIndex)).at(iChannelIndex)).at(1)); - } - - // Insufficient number of entries in the fine time histogram - // OR unreasonably narrow fine time distribution. - // Applying the bin-by-bin interpolation method is not reasonable. - // Regardless of the chosen global interpolation method data from - // this TDC channel will be interpolated linearly within the globally - // defined limits. - if( (fiMinEntriesBinByBin > (tFineTimeHistos.at(iBoardIndex)).at(iChannelIndex)->GetEntries()) || - (trbtdc::kuMinimumFineTimeRange > (((uFineTimeLimits.at(iBoardIndex)).at(iChannelIndex)).at(1) - ((uFineTimeLimits.at(iBoardIndex)).at(iChannelIndex)).at(0))) ) - { - // fine time range [0,1023] - // histogram bin range: [1,1024] - // mapping: ft(0) -> bin(1) - // ft(1023) -> bin(1024) - for(Int_t iBin = 1; iBin <= (tFineTimeHistos.at(iBoardIndex)).at(iChannelIndex)->GetNbinsX(); iBin++) - { - ((fdFineTime.at(iBoardIndex)).at(iChannelIndex)).at(iBin-1) = hadaq::TdcMessage::SimpleFineCalibr(static_cast<UInt_t>(iBin)-1); - } - } - else - { - if( trbtdc::finetime_bincenter == fiFineTimeMethod ) - { - for(Int_t iBin = 1; iBin <= (tFineTimeHistos.at(iBoardIndex)).at(iChannelIndex)->GetNbinsX(); iBin++) - { - ((fdFineTime.at(iBoardIndex)).at(iChannelIndex)).at(iBin-1) = ( (tFineTimeHistos.at(iBoardIndex)).at(iChannelIndex)->Integral(1,iBin) - - 0.5*(tFineTimeHistos.at(iBoardIndex)).at(iChannelIndex)->GetBinContent(iBin) ) - /(tFineTimeHistos.at(iBoardIndex)).at(iChannelIndex)->Integral(1,(tFineTimeHistos.at(iBoardIndex)).at(iChannelIndex)->GetNbinsX()); - } - } - else if( trbtdc::finetime_binedge == fiFineTimeMethod ) - { - for(Int_t iBin = 1; iBin <= (tFineTimeHistos.at(iBoardIndex)).at(iChannelIndex)->GetNbinsX(); iBin++) - { - ((fdFineTime.at(iBoardIndex)).at(iChannelIndex)).at(iBin-1) = (tFineTimeHistos.at(iBoardIndex)).at(iChannelIndex)->Integral(1,iBin) - /(tFineTimeHistos.at(iBoardIndex)).at(iChannelIndex)->Integral(1,(tFineTimeHistos.at(iBoardIndex)).at(iChannelIndex)->GetNbinsX()); - } - } - else - { - for(Int_t iBin = 1; iBin <= (tFineTimeHistos.at(iBoardIndex)).at(iChannelIndex)->GetNbinsX(); iBin++) - { - ((fdFineTime.at(iBoardIndex)).at(iChannelIndex)).at(iBin-1) = hadaq::TdcMessage::SimpleFineCalibr(static_cast<UInt_t>(iBin)-1); - } - } - } - - } - else - { - LOG(error)<<Form("Could not retrieve the fine time histogram of channel %2d of TDC %2d.",iBoardIndex,iChannelIndex); - return kFATAL; - } - } - } - - tCalibFile->Close(); - // gDirectory points to whatever it pointed to before the calibration file was opened - delete tCalibFile; - - } - - return kSUCCESS; -} - -// ============================================================================= -void TTofTrbTdcCalib::SetParContainers() -{ - FairRun* tRun = FairRun::Instance(); - if( !tRun ) - { - LOG(fatal)<<Form("FairRun instance not found."); - } - - FairRuntimeDb* tDataBase = tRun->GetRuntimeDb(); - if( !tDataBase ) - { - LOG(fatal)<<Form("FairRuntimeDb instance not found."); - } - - // request initialization of parameter containers - // The actual parameter container initializiation happens only upon calling - // FairRuntimeDb::initContainers in the FairRun instance - fMbsUnpackPar = dynamic_cast<TMbsUnpackTofPar*>(tDataBase->getContainer("TMbsUnpackTofPar")); - fMbsCalibPar = dynamic_cast<TMbsCalibTofPar*>(tDataBase->getContainer("TMbsCalibTofPar")); -} - -// ============================================================================= -void TTofTrbTdcCalib::Finish() -{ - const Int_t kiTdcChNb = static_cast<Int_t>(trbtdc::kuNbChan); - const Int_t kiNbActiveBoards = static_cast<Int_t>(fMbsUnpackPar->GetNbActiveBoards(tofMbs::trbtdc)); - - if( fbCreateCalib ) - { - - FairRootManager* tRootManager = FairRootManager::Instance(); - - TFile* tOutputFile = tRootManager->GetOutFile(); - if( !tOutputFile ) - { - LOG(fatal)<<"Output file could not be retrieved from FairRootManager."; - return; - } - - tOutputFile->mkdir("TofTrbCalib"); - - TBranch* tBranch = fBufferTree->GetBranch("TofTrbTdc"); - if( !tBranch ) - { - LOG(fatal)<<"Branch 'TofTrbTdc' not found in calib buffer tree."; - return; - } - - Long64_t lBranchEntries = tBranch->GetEntries(); - - Long64_t lInitialLoopPasses = 0; - - if( 100 > lBranchEntries ) - { - lInitialLoopPasses = lBranchEntries; - } - else - { - lInitialLoopPasses = 100; - } - - void* vOldAddress = tBranch->GetAddress(); - - TDirectory* tOldDirectory = gDirectory; - gROOT->cd(); - // gDirectory points to Rint - - TClonesArray* tArray = new TClonesArray("TTofTrbTdcBoard"); - tBranch->SetAddress(&tArray); - - // The vector of vectors approach is necessary because kiNbActiveBoards is only - // known at run time, not at compile time. We would need a run-time sized - // container here which size is fixed. - // A more elegant solution requires ROOT to be compiled with c++11 support. - // vector< array<UInt_t,2> > uRefFineTimeLimits(kiNbActiveBoards); - - - vector< vector<UInt_t> > uRefFineTimeLimits( kiNbActiveBoards, vector<UInt_t>( 2, 0 ) ); - vector<TH1I*> tRefFineTimeHistos( kiNbActiveBoards, NULL ); - vector< vector<Double_t> > dRefFineTimeLinear( kiNbActiveBoards, vector<Double_t>( trbtdc::kiFineCounterSize, 0. ) ); - vector< vector<Double_t> > dRefFineTimeBinCenter( kiNbActiveBoards, vector<Double_t>( trbtdc::kiFineCounterSize, 0. ) ); - vector< vector<Double_t> > dRefFineTimeBinEdge( kiNbActiveBoards, vector<Double_t>( trbtdc::kiFineCounterSize, 0. ) ); - - vector< vector<TH1I*> > tFineTimeHistos( kiNbActiveBoards, vector<TH1I*>( kiTdcChNb, NULL ) ); - - for(Int_t iBoardIndex = 0; iBoardIndex < kiNbActiveBoards; iBoardIndex++) - { - if(!fMbsCalibPar->CheckTotInvFlag( toftdc::trb, static_cast<UInt_t>(iBoardIndex) )) - { - LOG(fatal)<<Form("Check your parCalib* file! No ToT inversion flags provided for TDCs indexed %2d and above.",iBoardIndex); - return; - } - - tRefFineTimeHistos.at(iBoardIndex) = dynamic_cast<TH1I*>(gROOT->FindObjectAny(Form("tof_trb_ft_b%03d_ref",iBoardIndex))); - // Renaming the calibration histogram at this point to avoid name conflicts in the actual calibration event loop - tRefFineTimeHistos.at(iBoardIndex)->SetName(Form("calib_trb_ft_b%03d_ref",iBoardIndex)); - - if(tRefFineTimeHistos.at(iBoardIndex)) - { - // Writing the reference channel fine time distributions to file - tOutputFile->cd("TofTrbCalib"); - TDirectory* tBoardDirectory = gDirectory->mkdir(Form("tdc_b%03d",iBoardIndex)); - tBoardDirectory->cd(); - tRefFineTimeHistos.at(iBoardIndex)->Write(); - - (uRefFineTimeLimits.at(iBoardIndex)).at(0) = static_cast<UInt_t>(tRefFineTimeHistos.at(iBoardIndex)->FindFirstBinAbove(0.)); - (uRefFineTimeLimits.at(iBoardIndex)).at(1) = static_cast<UInt_t>(tRefFineTimeHistos.at(iBoardIndex)->FindLastBinAbove(0.)); - - // Insufficient number of entries in the fine time histogram - // OR unreasonably narrow fine time distribution. - // Switch to linear interpolation based on globally defined limits. - if( (fiMinEntriesLocalLimits > tRefFineTimeHistos.at(iBoardIndex)->GetEntries()) || - (trbtdc::kuMinimumFineTimeRange > ((uRefFineTimeLimits.at(iBoardIndex)).at(1) - (uRefFineTimeLimits.at(iBoardIndex)).at(0))) ) - { - hadaq::TdcMessage::SetFineLimits(fuLowerLinearFineLimit,fuUpperLinearFineLimit); - } - else - { - hadaq::TdcMessage::SetFineLimits((uRefFineTimeLimits.at(iBoardIndex)).at(0),(uRefFineTimeLimits.at(iBoardIndex)).at(1)); - } - - // Insufficient number of entries in the fine time histogram - // OR unreasonably narrow fine time distribution. - // Applying the bin-by-bin interpolation method is not reasonable. - // Regardless of the chosen global interpolation method data from - // this TDC channel will be interpolated linearly within the globally - // defined limits. - if( (fiMinEntriesBinByBin > tRefFineTimeHistos.at(iBoardIndex)->GetEntries()) || - (trbtdc::kuMinimumFineTimeRange > ((uRefFineTimeLimits.at(iBoardIndex)).at(1) - (uRefFineTimeLimits.at(iBoardIndex)).at(0))) ) - { - // fine time range [0,1023] - // histogram bin range: [1,1024] - // mapping: ft(0) -> bin(1) - // ft(1023) -> bin(1024) - for(Int_t iBin = 1; iBin <= tRefFineTimeHistos.at(iBoardIndex)->GetNbinsX(); iBin++) - { - (dRefFineTimeBinCenter.at(iBoardIndex)).at(iBin-1) = hadaq::TdcMessage::SimpleFineCalibr(static_cast<UInt_t>(iBin)-1); - (dRefFineTimeBinEdge.at(iBoardIndex)).at(iBin-1) = hadaq::TdcMessage::SimpleFineCalibr(static_cast<UInt_t>(iBin)-1); - (dRefFineTimeLinear.at(iBoardIndex)).at(iBin-1) = hadaq::TdcMessage::SimpleFineCalibr(static_cast<UInt_t>(iBin)-1); - } - } - else - { - for(Int_t iBin = 1; iBin <= tRefFineTimeHistos.at(iBoardIndex)->GetNbinsX(); iBin++) - { - (dRefFineTimeBinCenter.at(iBoardIndex)).at(iBin-1) = (tRefFineTimeHistos.at(iBoardIndex)->Integral(1,iBin) - 0.5*tRefFineTimeHistos.at(iBoardIndex)->GetBinContent(iBin)) - /tRefFineTimeHistos.at(iBoardIndex)->Integral(1,tRefFineTimeHistos.at(iBoardIndex)->GetNbinsX()); - - (dRefFineTimeBinEdge.at(iBoardIndex)).at(iBin-1) = tRefFineTimeHistos.at(iBoardIndex)->Integral(1,iBin) - /tRefFineTimeHistos.at(iBoardIndex)->Integral(1,tRefFineTimeHistos.at(iBoardIndex)->GetNbinsX()); - - (dRefFineTimeLinear.at(iBoardIndex)).at(iBin-1) = hadaq::TdcMessage::SimpleFineCalibr(static_cast<UInt_t>(iBin)-1); - } - } - } - else - { - LOG(fatal)<<Form("No fine time histogram available for reference channel of TDC %d.",iBoardIndex); - return; - } - - for(Int_t iChannelIndex = 0; iChannelIndex < kiTdcChNb; iChannelIndex++) - { - (tFineTimeHistos.at(iBoardIndex)).at(iChannelIndex) = dynamic_cast<TH1I*>(gROOT->FindObjectAny(Form("tof_trb_ft_b%03d_ch%03d",iBoardIndex,iChannelIndex))); - // Renaming the calibration histogram at this point to avoid name conflicts in the actual calibration event loop - (tFineTimeHistos.at(iBoardIndex)).at(iChannelIndex)->SetName(Form("calib_trb_ft_b%03d_ch%03d",iBoardIndex,iChannelIndex)); - - if((tFineTimeHistos.at(iBoardIndex)).at(iChannelIndex)) - { - (tFineTimeHistos.at(iBoardIndex)).at(iChannelIndex)->Write(); - } - else - { - LOG(fatal)<<Form("No fine time histogram available for channel %2d of TDC %2d.",iBoardIndex,iChannelIndex); - return; - } - } - - } - - gROOT->cd(); - // gDirectory points to Rint - - - // In 3 histogram iterations, we determine time offsets between TDCs w.r.t a reference TDC board. - - // +++++++ 1st iteration +++++++++++++++++++++++++++++++++++++++++++++++++++ - // Divide the full coarse time axis into 4 sectors with granularities of 2.6 ms - // - // kliFullCoarseSize = 549,755,813,888 (in units of 5 ns) - // 1 Bin = 524,288 coarse time units = 2.6 ms - // 524,288 bins each (2^38 -> 2^19 -> 2^19) - - vector< vector<TH1D*> > tFirstOffsetSearch( kiNbActiveBoards, vector<TH1D*>( 4, NULL)); - - for(Int_t iBoardIndex = 0; iBoardIndex < kiNbActiveBoards; iBoardIndex++) - { - (tFirstOffsetSearch.at(iBoardIndex)).at(0) = new TH1D(Form("tFirstOffsetSearch%d_0",iBoardIndex),Form("TDC %d, ref-TDC %d",iBoardIndex,fiReferenceBoard), - 524288,static_cast<Double_t>(-trbtdc::kliFullCoarseSize),static_cast<Double_t>(-trbtdc::kliFullCoarseSize/2)); - - (tFirstOffsetSearch.at(iBoardIndex)).at(1) = new TH1D(Form("tFirstOffsetSearch%d_1",iBoardIndex),Form("TDC %d, ref-TDC %d",iBoardIndex,fiReferenceBoard), - 524288,static_cast<Double_t>(-trbtdc::kliFullCoarseSize/2),0.); - - (tFirstOffsetSearch.at(iBoardIndex)).at(2) = new TH1D(Form("tFirstOffsetSearch%d_2",iBoardIndex),Form("TDC %d, ref-TDC %d",iBoardIndex,fiReferenceBoard), - 524288,0.,static_cast<Double_t>(trbtdc::kliFullCoarseSize/2)); - - (tFirstOffsetSearch.at(iBoardIndex)).at(3) = new TH1D(Form("tFirstOffsetSearch%d_3",iBoardIndex),Form("TDC %d, ref-TDC %d",iBoardIndex,fiReferenceBoard), - 524288,static_cast<Double_t>(trbtdc::kliFullCoarseSize/2),static_cast<Double_t>(trbtdc::kliFullCoarseSize)); - } - - // +++++++ partial event loop ++++++++++++++++++++++++++++++++++++++++++++++ - for(Long64_t lBranchEntry = 0; lBranchEntry < lInitialLoopPasses; lBranchEntry++) - { - tArray->Clear("C"); - - tBranch->GetEntry(lBranchEntry); - - Int_t iArrayEntries = tArray->GetEntriesFast(); - - if(iArrayEntries != kiNbActiveBoards) - { - LOG(fatal)<<"A different number of TTofTrbTdcBoard objects found in the tree than given in the parameter file."; - return; - } - - TTofTrbTdcBoard* tTrbTdcBoard(0); - - vector<Double_t> dTimeOffset(iArrayEntries, 0.); - Double_t dReferenceOffset(0.); - - if(fiReferenceBoard < iArrayEntries) - { - tTrbTdcBoard = dynamic_cast<TTofTrbTdcBoard*>(tArray->At(fiReferenceBoard)); - } - - if(!tTrbTdcBoard) - { - LOG(fatal)<<Form("Reference TTofTrbTdcBoard object indexed %d not found.",fiReferenceBoard); - continue; - } - - const TTofTrbTdcData& tRefTdcRefTime = tTrbTdcBoard->GetRefChannelData(); - - dReferenceOffset = static_cast<Double_t>(tRefTdcRefTime.GetFullCoarseTime()); - - - for(Int_t iBoardIndex = 0; iBoardIndex < iArrayEntries; iBoardIndex++) - { - if(fiReferenceBoard != iBoardIndex) - { - tTrbTdcBoard = dynamic_cast<TTofTrbTdcBoard*>(tArray->At(iBoardIndex)); - - const TTofTrbTdcData& tTdcRefTime = tTrbTdcBoard->GetRefChannelData(); - - dTimeOffset.at(iBoardIndex) = static_cast<Double_t>(tTdcRefTime.GetFullCoarseTime()) - dReferenceOffset; - - (tFirstOffsetSearch.at(iBoardIndex)).at(0)->Fill(dTimeOffset.at(iBoardIndex)); - (tFirstOffsetSearch.at(iBoardIndex)).at(1)->Fill(dTimeOffset.at(iBoardIndex)); - (tFirstOffsetSearch.at(iBoardIndex)).at(2)->Fill(dTimeOffset.at(iBoardIndex)); - (tFirstOffsetSearch.at(iBoardIndex)).at(3)->Fill(dTimeOffset.at(iBoardIndex)); - } - } - - } - // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - - // +++++++ 2nd iteration +++++++++++++++++++++++++++++++++++++++++++++++++++ - // Scan each sector histogram of iteration 1 for a single occupied bin. If - // several bins are occupied in a single histogram, exempt the TDC board - // from calibration (probably no clock signal applied). If the last bin - // of one sector histogram and the first bin of the neighboring sector - // histogram are occupied, the offset distribution crosses sector borders. - // Create a joint 2nd level histogram in this case. - // - // 1 Bin = 2.6 ms/524,288 = 5 ns - // 1,048,576 bins each (range of 5.2 ms) - - vector< vector<TH1D*> > tSecondOffsetSearch( kiNbActiveBoards, vector<TH1D*>() ); - - vector<Bool_t> bDisableBoard( kiNbActiveBoards, kFALSE ); - - for(Int_t iBoardIndex = 0; iBoardIndex < kiNbActiveBoards; iBoardIndex++) - { - Int_t iFirstOccupiedBin[4] = {-1}; - Int_t iLastOccupiedBin[4] = {-1}; - Bool_t bOffsetFound[4]; - - for(Int_t iSector = 0; iSector < 4; iSector++) - { - bOffsetFound[iSector] = kFALSE; - - iFirstOccupiedBin[iSector] = ((tFirstOffsetSearch.at(iBoardIndex)).at(iSector))->FindFirstBinAbove(0.); - iLastOccupiedBin[iSector] = ((tFirstOffsetSearch.at(iBoardIndex)).at(iSector))->FindLastBinAbove(0.); - - if( (iFirstOccupiedBin[iSector] > -1) && (iLastOccupiedBin[iSector] > -1) ) - { - // Given a bin width of 2^19 clock cycles (2.6 ms) the coarse counter offset distribution - // should not span more than two neighboring bins. If one observes a different behavior, - // most likely the TDC did not receive any clock signal. In this case, the respective coarse counter - // would not be incremented at all and arbitrarily jump w.r.t. the reference TDC. Owing to bad - // grounding between the clock signal generator and a TDC, there might be a chance that a TDC - // does from time to time jump a clock edge. If such a hypothetical jump by one edge does not - // occur within the first 100 events of the sample, it is not taken into account here. - if( 1 >= TMath::Abs(iFirstOccupiedBin[iSector] - iLastOccupiedBin[iSector]) ) - { - Double_t dLowerRangeLimit = ((tFirstOffsetSearch.at(iBoardIndex)).at(iSector))->GetBinLowEdge(iFirstOccupiedBin[iSector]); - Double_t dUpperRangeLimit = dLowerRangeLimit + 2.*((tFirstOffsetSearch.at(iBoardIndex)).at(iSector))->GetBinWidth(1); - - (tSecondOffsetSearch.at(iBoardIndex)).push_back( new TH1D(Form("tSecondOffsetSearch%d_%lu",iBoardIndex,(tSecondOffsetSearch.at(iBoardIndex)).size()),Form("TDC %d, ref-TDC %d",iBoardIndex,fiReferenceBoard), - 1048576,dLowerRangeLimit,dUpperRangeLimit) ); - - bOffsetFound[iSector] = kTRUE; - - // Check for offset distributions crossing sector borders - // 0/1, 1/2, 2/3 - if( 0 != iSector ) - { - if( bOffsetFound[iSector-1] ) - { - if( ( ((tFirstOffsetSearch.at(iBoardIndex)).at(iSector-1))->GetNbinsX() == iLastOccupiedBin[iSector-1] ) && - ( 1 == iFirstOccupiedBin[iSector] ) ) - { - // The vector at this point contains two single histograms for a single distribution - // that crosses sector borders. Remove these two and replace them by an inclusive one. - delete (tSecondOffsetSearch.at(iBoardIndex)).back(); - (tSecondOffsetSearch.at(iBoardIndex)).pop_back(); - delete (tSecondOffsetSearch.at(iBoardIndex)).back(); - (tSecondOffsetSearch.at(iBoardIndex)).pop_back(); - - dLowerRangeLimit = ((tFirstOffsetSearch.at(iBoardIndex)).at(iSector-1))->GetBinLowEdge(iLastOccupiedBin[iSector-1]); - dUpperRangeLimit = dLowerRangeLimit + 2.*((tFirstOffsetSearch.at(iBoardIndex)).at(iSector))->GetBinWidth(1); - - (tSecondOffsetSearch.at(iBoardIndex)).push_back( new TH1D(Form("tSecondOffsetSearch%d_%lu",iBoardIndex,(tSecondOffsetSearch.at(iBoardIndex)).size()),Form("TDC %d, ref-TDC %d",iBoardIndex,fiReferenceBoard), - 1048576,dLowerRangeLimit,dUpperRangeLimit) ); - } - } - } - } - } - } - - // Disable TDCs for which no (valid) offset distributions were found - for(Int_t iSector = 0; iSector < 4; iSector++) - { - if( bOffsetFound[iSector] ) - { - break; - } - - if(3 == iSector) - { - bDisableBoard.at(iBoardIndex) = kTRUE; - } - } - - } - - // Deallocating some memory - for(Int_t iBoardIndex = 0; iBoardIndex < kiNbActiveBoards; iBoardIndex++) - { - for(Int_t iSector = 0; iSector < 4; iSector++) - { - delete ((tFirstOffsetSearch.at(iBoardIndex)).at(iSector)); - } - } - - // +++++++ partial event loop ++++++++++++++++++++++++++++++++++++++++++++++ - for(Long64_t lBranchEntry = 0; lBranchEntry < lInitialLoopPasses; lBranchEntry++) - { - tArray->Clear("C"); - - tBranch->GetEntry(lBranchEntry); - - Int_t iArrayEntries = tArray->GetEntriesFast(); - - TTofTrbTdcBoard* tTrbTdcBoard(0); - - vector<Double_t> dTimeOffset(iArrayEntries, 0.); - Double_t dReferenceOffset(0.); - - if(fiReferenceBoard < iArrayEntries) - { - tTrbTdcBoard = dynamic_cast<TTofTrbTdcBoard*>(tArray->At(fiReferenceBoard)); - } - - const TTofTrbTdcData& tRefTdcRefTime = tTrbTdcBoard->GetRefChannelData(); - - dReferenceOffset = static_cast<Double_t>(tRefTdcRefTime.GetFullCoarseTime()); - - - for(Int_t iBoardIndex = 0; iBoardIndex < iArrayEntries; iBoardIndex++) - { - if(fiReferenceBoard != iBoardIndex) - { - tTrbTdcBoard = dynamic_cast<TTofTrbTdcBoard*>(tArray->At(iBoardIndex)); - - const TTofTrbTdcData& tTdcRefTime = tTrbTdcBoard->GetRefChannelData(); - - dTimeOffset.at(iBoardIndex) = static_cast<Double_t>(tTdcRefTime.GetFullCoarseTime()) - dReferenceOffset; - - for(Int_t iRange = 0; iRange < static_cast<Int_t>((tSecondOffsetSearch.at(iBoardIndex)).size()); iRange++) - { - ((tSecondOffsetSearch.at(iBoardIndex)).at(iRange))->Fill(dTimeOffset.at(iBoardIndex)); - } - - } - } - } - // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - // +++++++ 3rd iteration +++++++++++++++++++++++++++++++++++++++++++++++++++ - // Create from each 2nd level histogram a new histogram with final binning. - // Create in addition the complementary partner histogram (shifted by +/- - // the full coarse counter range) to determine among the 3rd level histograms - // a reference range (closest to 0) for correcting and offset fitting. - // 1 Bin = 5ns/500 = 10 ps - // 1500 bins each (range of 15 ns) - - vector< vector<TH1D*> > tThirdOffsetSearch( kiNbActiveBoards, vector<TH1D*>() ); - - vector<Int_t> iMainOffsetHisto( kiNbActiveBoards, -1 ); - vector<Double_t> dPreliminaryOffset( kiNbActiveBoards, 0. ); - - for(Int_t iBoardIndex = 0; iBoardIndex < kiNbActiveBoards; iBoardIndex++) - { - if( (tSecondOffsetSearch.at(iBoardIndex)).size() ) - { - vector<Int_t> iFirstOccupiedBin( static_cast<Int_t>((tSecondOffsetSearch.at(iBoardIndex)).size()) ); - vector<Int_t> iLastOccupiedBin( static_cast<Int_t>((tSecondOffsetSearch.at(iBoardIndex)).size()) ); - - for(Int_t iRange = 0; iRange < static_cast<Int_t>((tSecondOffsetSearch.at(iBoardIndex)).size()); iRange++) - { - iFirstOccupiedBin.at(iRange) = ((tSecondOffsetSearch.at(iBoardIndex)).at(iRange))->FindFirstBinAbove(0.); - iLastOccupiedBin.at(iRange) = ((tSecondOffsetSearch.at(iBoardIndex)).at(iRange))->FindLastBinAbove(0.); - - // Given a bin width of 1 clock cycle (5 ns) the coarse counter offset distribution - // should not span more than two neighboring bins. - // Also, we need to take into account that the fine counter offset distribution may - // extend to neighboring bins. - - // Assume the coarse counter offset distribution (100 events) spans one bin only. - // The actual offset distribution might, however, cross the border to the left or - // right bin neighbor, respectively. Create 3rd level histograms with - // three 2nd level bins. - if( (0 == TMath::Abs(iFirstOccupiedBin.at(iRange) - iLastOccupiedBin.at(iRange))) || (1 == TMath::Abs(iFirstOccupiedBin.at(iRange) - iLastOccupiedBin.at(iRange))) ) - { - Double_t dLowerRangeLimit = ((tSecondOffsetSearch.at(iBoardIndex)).at(iRange))->GetBinLowEdge(iFirstOccupiedBin.at(iRange)-1); - Double_t dUpperRangeLimit = dLowerRangeLimit + 3.*((tSecondOffsetSearch.at(iBoardIndex)).at(iRange))->GetBinWidth(1); - - (tThirdOffsetSearch.at(iBoardIndex)).push_back( new TH1D(Form("tThirdOffsetSearch%d_%lu",iBoardIndex,(tThirdOffsetSearch.at(iBoardIndex)).size()),Form("TDC %d, ref-TDC %d",iBoardIndex,fiReferenceBoard), - 1500,dLowerRangeLimit,dUpperRangeLimit) ); - } - else - { - bDisableBoard.at(iBoardIndex) = kTRUE; - } - } - - // The complementary offset distribution was not found. Nevertheless, - // we create a corresponding histogram in case offsets change sign in - // the course of the calibration loop. - if( 1 == (tThirdOffsetSearch.at(iBoardIndex)).size() ) - { - Double_t dLowerRangeLimit = ((tThirdOffsetSearch.at(iBoardIndex)).at(0))->GetBinLowEdge(1); - Double_t dUpperRangeLimit = ((tThirdOffsetSearch.at(iBoardIndex)).at(0))->GetBinLowEdge( ((tThirdOffsetSearch.at(iBoardIndex)).at(0))->GetNbinsX()+1 ); - - // Found an offset distribution in the positive sectors. - // Create the complementary distribution in the negative sectors. - if( 0. <= dLowerRangeLimit && 0. < dUpperRangeLimit ) - { - dLowerRangeLimit -= static_cast<Double_t>(trbtdc::kliFullCoarseSize); - dUpperRangeLimit -= static_cast<Double_t>(trbtdc::kliFullCoarseSize); - - (tThirdOffsetSearch.at(iBoardIndex)).push_back( new TH1D(Form("tThirdOffsetSearch%d_%lu",iBoardIndex,(tThirdOffsetSearch.at(iBoardIndex)).size()),Form("TDC %d, ref-TDC %d",iBoardIndex,fiReferenceBoard), - 1500,dLowerRangeLimit,dUpperRangeLimit) ); - } - // Found an offset distribution in the negative sectors. - // Create the complementary distribution in the positive sectors. - else if( 0. > dLowerRangeLimit && 0. >= dUpperRangeLimit) - { - dLowerRangeLimit += static_cast<Double_t>(trbtdc::kliFullCoarseSize); - dUpperRangeLimit += static_cast<Double_t>(trbtdc::kliFullCoarseSize); - - (tThirdOffsetSearch.at(iBoardIndex)).push_back( new TH1D(Form("tThirdOffsetSearch%d_%lu",iBoardIndex,(tThirdOffsetSearch.at(iBoardIndex)).size()),Form("TDC %d, ref-TDC %d",iBoardIndex,fiReferenceBoard), - 1500,dLowerRangeLimit,dUpperRangeLimit) ); - } - // The offset distribution has a negative and a positive contribution. - // Create a negative and a positive complement (3 histograms in total). - else - { - (tThirdOffsetSearch.at(iBoardIndex)).push_back( new TH1D(Form("tThirdOffsetSearch%d_%lu",iBoardIndex,(tThirdOffsetSearch.at(iBoardIndex)).size()),Form("TDC %d, ref-TDC %d",iBoardIndex,fiReferenceBoard), - 1500,dLowerRangeLimit-static_cast<Double_t>(trbtdc::kliFullCoarseSize),dUpperRangeLimit-static_cast<Double_t>(trbtdc::kliFullCoarseSize)) ); - - (tThirdOffsetSearch.at(iBoardIndex)).push_back( new TH1D(Form("tThirdOffsetSearch%d_%lu",iBoardIndex,(tThirdOffsetSearch.at(iBoardIndex)).size()),Form("TDC %d, ref-TDC %d",iBoardIndex,fiReferenceBoard), - 1500,dLowerRangeLimit+static_cast<Double_t>(trbtdc::kliFullCoarseSize),dUpperRangeLimit+static_cast<Double_t>(trbtdc::kliFullCoarseSize)) ); - } - } - - // Determine the element in tThirdOffsetSearch which axis range is - // closest to 0. Entries in the complementary histograms should be - // corrected (+/- coarse counter range) w.r.t. the offset obtained - // from this histogram. In case of two histograms centered about - // +/- half the coarse counter range choose anyone. - - Double_t dTempOffset = 2.*static_cast<Double_t>(trbtdc::kliFullCoarseSize); - - for(Int_t iElement = 0; iElement < static_cast<Int_t>((tThirdOffsetSearch.at(iBoardIndex)).size()); iElement++) - { - Double_t dLowerRangeLimit = ((tThirdOffsetSearch.at(iBoardIndex)).at(iElement))->GetBinLowEdge(1); - Double_t dUpperRangeLimit = ((tThirdOffsetSearch.at(iBoardIndex)).at(iElement))->GetBinLowEdge( ((tThirdOffsetSearch.at(iBoardIndex)).at(iElement))->GetNbinsX()+1 ); - - Double_t dMeanRange = (dLowerRangeLimit + dUpperRangeLimit)/2.; - - if( TMath::Abs(dTempOffset) > TMath::Abs(dMeanRange) ) - { - iMainOffsetHisto.at(iBoardIndex) = iElement; - dPreliminaryOffset.at(iBoardIndex) = dMeanRange; - - dTempOffset = dMeanRange; - } - } - - } - } - - // Deallocating some memory - for(Int_t iBoardIndex = 0; iBoardIndex < kiNbActiveBoards; iBoardIndex++) - { - for(Int_t iRange = 0; iRange < static_cast<Int_t>((tSecondOffsetSearch.at(iBoardIndex)).size()); iRange++) - { - delete ((tSecondOffsetSearch.at(iBoardIndex)).at(iRange)); - } - } - // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - // Offset fitting histograms - vector<TH1D*> tOffsetsLinear( kiNbActiveBoards ); - vector<TH1D*> tOffsetsBinCenter( kiNbActiveBoards ); - vector<TH1D*> tOffsetsBinEdge( kiNbActiveBoards ); - - for(Int_t iBoardIndex = 0; iBoardIndex < kiNbActiveBoards; iBoardIndex++) - { - if( !bDisableBoard.at(iBoardIndex) ) - { - Double_t dLowerRangeLimit = ((tThirdOffsetSearch.at(iBoardIndex)).at(iMainOffsetHisto.at(iBoardIndex)))->GetBinLowEdge(1); - dLowerRangeLimit -= dPreliminaryOffset.at(iBoardIndex); - Double_t dUpperRangeLimit = ((tThirdOffsetSearch.at(iBoardIndex)).at(iMainOffsetHisto.at(iBoardIndex)))->GetBinLowEdge( ((tThirdOffsetSearch.at(iBoardIndex)).at(iMainOffsetHisto.at(iBoardIndex)))->GetNbinsX()+1 ); - dUpperRangeLimit -= dPreliminaryOffset.at(iBoardIndex); - - tOffsetsLinear.at(iBoardIndex) = new TH1D(Form("tOffsetsLinear%d",iBoardIndex),Form("TDC %d, ref-TDC %d",iBoardIndex,fiReferenceBoard), - 1500,dLowerRangeLimit,dUpperRangeLimit); - tOffsetsLinear.at(iBoardIndex)->GetXaxis()->SetTitle("linear ref diff [ps]"); - - tOffsetsBinCenter.at(iBoardIndex) = new TH1D(Form("tOffsetsBinCenter%d",iBoardIndex),Form("TDC %d, ref-TDC %d",iBoardIndex,fiReferenceBoard), - 1500,dLowerRangeLimit,dUpperRangeLimit); - tOffsetsBinCenter.at(iBoardIndex)->GetXaxis()->SetTitle("bin center ref diff [5 ns]"); - - tOffsetsBinEdge.at(iBoardIndex) = new TH1D(Form("tOffsetsBinEdge%d",iBoardIndex),Form("TDC %d, ref-TDC %d",iBoardIndex,fiReferenceBoard), - 1500,dLowerRangeLimit,dUpperRangeLimit); - tOffsetsBinEdge.at(iBoardIndex)->GetXaxis()->SetTitle("bin edge ref diff [5 ns]"); - } - } - - - LOG(info)<<"Calibrating the TDC to TDC offsets..."; - - // Loop to fill the offset fitting histograms - for(Long64_t lBranchEntry = 0; lBranchEntry < lBranchEntries; lBranchEntry++) - { - if(0 == lBranchEntry % 10000) - { - LOG(info)<<Form("event: %8lld of %8lld",lBranchEntry,lBranchEntries); - } - - tArray->Clear("C"); - - tBranch->GetEntry(lBranchEntry); - - Int_t iArrayEntries = tArray->GetEntriesFast(); - - TTofTrbTdcBoard* tTrbTdcBoard(0); - - Double_t dReferenceOffsetLinear(0.); - Double_t dReferenceOffsetBinCenter(0.); - Double_t dReferenceOffsetBinEdge(0.); - - if(fiReferenceBoard < iArrayEntries) - { - tTrbTdcBoard = dynamic_cast<TTofTrbTdcBoard*>(tArray->At(fiReferenceBoard)); - } - - const TTofTrbTdcData& tRefTdcRefTime = tTrbTdcBoard->GetRefChannelData(); - - Double_t dRefCoarseTime = static_cast<Double_t>(tRefTdcRefTime.GetFullCoarseTime()); - - if(0 == lBranchEntry) - { - LOG(info)<<Form("reference TDC %d first time: %.2f s",fiReferenceBoard,static_cast<Double_t>(tRefTdcRefTime.GetFullCoarseTime())*trbtdc::kdClockCycleSizeSec); - } - else if(lBranchEntries-1 == lBranchEntry) - { - LOG(info)<<Form("reference TDC %d last time: %.2f s",fiReferenceBoard,static_cast<Double_t>(tRefTdcRefTime.GetFullCoarseTime())*trbtdc::kdClockCycleSizeSec); - } - else if(0 == lBranchEntry % 10000) - { - LOG(info)<<Form(" TDC %d reference time: %.2f s",fiReferenceBoard,static_cast<Double_t>(tRefTdcRefTime.GetFullCoarseTime())*trbtdc::kdClockCycleSizeSec); - } - - dReferenceOffsetLinear = dRefCoarseTime - (dRefFineTimeLinear.at(fiReferenceBoard)).at(static_cast<Int_t>(tRefTdcRefTime.GetFineTime())); - dReferenceOffsetBinCenter = dRefCoarseTime - (dRefFineTimeBinCenter.at(fiReferenceBoard)).at(static_cast<Int_t>(tRefTdcRefTime.GetFineTime())); - dReferenceOffsetBinEdge = dRefCoarseTime - (dRefFineTimeBinEdge.at(fiReferenceBoard)).at(static_cast<Int_t>(tRefTdcRefTime.GetFineTime())); - - for(Int_t iBoardIndex = 0; iBoardIndex < iArrayEntries; iBoardIndex++) - { - if( (fiReferenceBoard != iBoardIndex) && !bDisableBoard.at(iBoardIndex) ) - { - tTrbTdcBoard = dynamic_cast<TTofTrbTdcBoard*>(tArray->At(iBoardIndex)); - - const TTofTrbTdcData& tTdcRefTime = tTrbTdcBoard->GetRefChannelData(); - - Double_t dCoarseTime = static_cast<Double_t>(tTdcRefTime.GetFullCoarseTime()); - - Double_t dTimeOffsetLinear = dCoarseTime - (dRefFineTimeLinear.at(iBoardIndex)).at(static_cast<Int_t>(tTdcRefTime.GetFineTime())) - dReferenceOffsetLinear; - Double_t dTimeOffsetBinCenter = dCoarseTime - (dRefFineTimeBinCenter.at(iBoardIndex)).at(static_cast<Int_t>(tTdcRefTime.GetFineTime())) - dReferenceOffsetBinCenter; - Double_t dTimeOffsetBinEdge = dCoarseTime - (dRefFineTimeBinEdge.at(iBoardIndex)).at(static_cast<Int_t>(tTdcRefTime.GetFineTime())) - dReferenceOffsetBinEdge; - - - Double_t dTimeOffset(0.); - - if( trbtdc::finetime_bincenter == fiFineTimeMethod ) - { - dTimeOffset = dTimeOffsetBinCenter; - } - else if( trbtdc::finetime_binedge == fiFineTimeMethod ) - { - dTimeOffset = dTimeOffsetBinEdge; - } - else - { - dTimeOffset = dTimeOffsetLinear; - } - - for(Int_t iRange = 0; iRange < static_cast<Int_t>((tThirdOffsetSearch.at(iBoardIndex)).size()); iRange++) - { - ((tThirdOffsetSearch.at(iBoardIndex)).at(iRange))->Fill(dTimeOffset); - } - - - if( (dTimeOffsetLinear - dPreliminaryOffset.at(iBoardIndex)) > static_cast<Double_t>(trbtdc::kliFullCoarseSize)/4. ) - { - dTimeOffsetLinear -= static_cast<Double_t>(trbtdc::kliFullCoarseSize); - } - else if( (dTimeOffsetLinear - dPreliminaryOffset.at(iBoardIndex)) < -static_cast<Double_t>(trbtdc::kliFullCoarseSize)/4. ) - { - dTimeOffsetLinear += static_cast<Double_t>(trbtdc::kliFullCoarseSize); - } - - if( (dTimeOffsetBinCenter - dPreliminaryOffset.at(iBoardIndex)) > static_cast<Double_t>(trbtdc::kliFullCoarseSize)/4. ) - { - dTimeOffsetBinCenter -= static_cast<Double_t>(trbtdc::kliFullCoarseSize); - } - else if( (dTimeOffsetBinCenter - dPreliminaryOffset.at(iBoardIndex)) < -static_cast<Double_t>(trbtdc::kliFullCoarseSize)/4. ) - { - dTimeOffsetBinCenter += static_cast<Double_t>(trbtdc::kliFullCoarseSize); - } - - if( (dTimeOffsetBinEdge - dPreliminaryOffset.at(iBoardIndex)) > static_cast<Double_t>(trbtdc::kliFullCoarseSize)/4. ) - { - dTimeOffsetBinEdge -= static_cast<Double_t>(trbtdc::kliFullCoarseSize); - } - else if( (dTimeOffsetBinEdge - dPreliminaryOffset.at(iBoardIndex)) < -static_cast<Double_t>(trbtdc::kliFullCoarseSize)/4. ) - { - dTimeOffsetBinEdge += static_cast<Double_t>(trbtdc::kliFullCoarseSize); - } - - tOffsetsLinear.at(iBoardIndex)->Fill(dTimeOffsetLinear - dPreliminaryOffset.at(iBoardIndex)); - tOffsetsBinCenter.at(iBoardIndex)->Fill(dTimeOffsetBinCenter - dPreliminaryOffset.at(iBoardIndex)); - tOffsetsBinEdge.at(iBoardIndex)->Fill(dTimeOffsetBinEdge - dPreliminaryOffset.at(iBoardIndex)); - - } - } - - } - - vector<Double_t> dFinalOffset( kiNbActiveBoards, 0. ); - - vector<Double_t> dRmsLinear( kiNbActiveBoards, 0. ); - vector<Double_t> dSigmaLinear( kiNbActiveBoards, 0. ); - vector<Double_t> dRmsBinCenter( kiNbActiveBoards, 0. ); - vector<Double_t> dSigmaBinCenter( kiNbActiveBoards, 0. ); - vector<Double_t> dRmsBinEdge( kiNbActiveBoards, 0. ); - vector<Double_t> dSigmaBinEdge( kiNbActiveBoards, 0. ); - - vector<Double_t> dHistoMeanLinear( kiNbActiveBoards, 0. ); - vector<Double_t> dGausMeanLinear( kiNbActiveBoards, 0. ); - vector<Double_t> dHistoMeanBinCenter( kiNbActiveBoards, 0. ); - vector<Double_t> dGausMeanBinCenter( kiNbActiveBoards, 0. ); - vector<Double_t> dHistoMeanBinEdge( kiNbActiveBoards, 0. ); - vector<Double_t> dGausMeanBinEdge( kiNbActiveBoards, 0. ); - - vector<Double_t> dHistoIndizes( kiNbActiveBoards, 0. ); - - for(Int_t iBoardIndex = 0; iBoardIndex < kiNbActiveBoards; iBoardIndex++) - { - if( !bDisableBoard.at(iBoardIndex) ) - { - tOffsetsLinear.at(iBoardIndex)->GetXaxis()->SetRangeUser(tOffsetsLinear.at(iBoardIndex)->GetMean()-0.3,tOffsetsLinear.at(iBoardIndex)->GetMean()+0.3); - dRmsLinear.at(iBoardIndex) = trbtdc::kdClockCycleSize*tOffsetsLinear.at(iBoardIndex)->GetRMS(); - dHistoMeanLinear.at(iBoardIndex) = TMath::Abs(tOffsetsLinear.at(iBoardIndex)->GetMean() + dPreliminaryOffset.at(iBoardIndex))+1.; - - if( trbtdc::finetime_linear == fiFineTimeMethod ) - { - dFinalOffset.at(iBoardIndex) = tOffsetsLinear.at(iBoardIndex)->GetMean() + dPreliminaryOffset.at(iBoardIndex); - } - - // from TH1.cxx: - // "Q" Quiet mode (minimum printing) - // "0" Do not plot the result of the fit. By default the fitted function is drawn unless the option"N" above is specified. - if(static_cast<Int_t>(tOffsetsLinear.at(iBoardIndex)->Fit("gaus","Q0"))) - { - LOG(error)<<Form("Linear FT interpolation: Gaussian fit failed for TDC %d.",iBoardIndex); - } - else - { - dSigmaLinear.at(iBoardIndex) = trbtdc::kdClockCycleSize*(tOffsetsLinear.at(iBoardIndex)->GetFunction("gaus"))->GetParameter("Sigma"); - dGausMeanLinear.at(iBoardIndex) = TMath::Abs((tOffsetsLinear.at(iBoardIndex)->GetFunction("gaus"))->GetParameter("Mean") + dPreliminaryOffset.at(iBoardIndex))+1.; - - if( trbtdc::finetime_linear == fiFineTimeMethod ) - { - dFinalOffset.at(iBoardIndex) = (tOffsetsLinear.at(iBoardIndex)->GetFunction("gaus"))->GetParameter("Mean") + dPreliminaryOffset.at(iBoardIndex); - } - } - - tOffsetsBinCenter.at(iBoardIndex)->GetXaxis()->SetRangeUser(tOffsetsBinCenter.at(iBoardIndex)->GetMean()-0.3,tOffsetsBinCenter.at(iBoardIndex)->GetMean()+0.3); - dRmsBinCenter.at(iBoardIndex) = trbtdc::kdClockCycleSize*tOffsetsBinCenter.at(iBoardIndex)->GetRMS(); - dHistoMeanBinCenter.at(iBoardIndex) = TMath::Abs(tOffsetsBinCenter.at(iBoardIndex)->GetMean() + dPreliminaryOffset.at(iBoardIndex))+1.; - - if( trbtdc::finetime_bincenter == fiFineTimeMethod ) - { - dFinalOffset.at(iBoardIndex) = tOffsetsBinCenter.at(iBoardIndex)->GetMean() + dPreliminaryOffset.at(iBoardIndex); - } - - if(static_cast<Int_t>(tOffsetsBinCenter.at(iBoardIndex)->Fit("gaus","Q0"))) - { - LOG(error)<<Form("Bin center FT interpolation: Gaussian fit failed for TDC %d.",iBoardIndex); - } - else - { - dSigmaBinCenter.at(iBoardIndex) = trbtdc::kdClockCycleSize*(tOffsetsBinCenter.at(iBoardIndex)->GetFunction("gaus"))->GetParameter("Sigma"); - dGausMeanBinCenter.at(iBoardIndex) = TMath::Abs((tOffsetsBinCenter.at(iBoardIndex)->GetFunction("gaus"))->GetParameter("Mean") + dPreliminaryOffset.at(iBoardIndex))+1.; - - if( trbtdc::finetime_bincenter == fiFineTimeMethod ) - { - dFinalOffset.at(iBoardIndex) = (tOffsetsBinCenter.at(iBoardIndex)->GetFunction("gaus"))->GetParameter("Mean") + dPreliminaryOffset.at(iBoardIndex); - } - - } - - tOffsetsBinEdge.at(iBoardIndex)->GetXaxis()->SetRangeUser(tOffsetsBinEdge.at(iBoardIndex)->GetMean()-0.3,tOffsetsBinEdge.at(iBoardIndex)->GetMean()+0.3); - dRmsBinEdge.at(iBoardIndex) = trbtdc::kdClockCycleSize*tOffsetsBinEdge.at(iBoardIndex)->GetRMS(); - dHistoMeanBinEdge.at(iBoardIndex) = TMath::Abs(tOffsetsBinEdge.at(iBoardIndex)->GetMean() + dPreliminaryOffset.at(iBoardIndex))+1.; - - if( trbtdc::finetime_binedge == fiFineTimeMethod ) - { - dFinalOffset.at(iBoardIndex) = tOffsetsBinEdge.at(iBoardIndex)->GetMean() + dPreliminaryOffset.at(iBoardIndex); - } - - if(static_cast<Int_t>(tOffsetsBinEdge.at(iBoardIndex)->Fit("gaus","Q0"))) - { - LOG(error)<<Form("Bin edge FT interpolation: Gaussian fit failed for TDC %d.",iBoardIndex); - } - else - { - dSigmaBinEdge.at(iBoardIndex) = trbtdc::kdClockCycleSize*(tOffsetsBinEdge.at(iBoardIndex)->GetFunction("gaus"))->GetParameter("Sigma"); - dGausMeanBinEdge.at(iBoardIndex) = TMath::Abs((tOffsetsBinEdge.at(iBoardIndex)->GetFunction("gaus"))->GetParameter("Mean") + dPreliminaryOffset.at(iBoardIndex))+1.; - - if( trbtdc::finetime_binedge == fiFineTimeMethod ) - { - dFinalOffset.at(iBoardIndex) = (tOffsetsBinEdge.at(iBoardIndex)->GetFunction("gaus"))->GetParameter("Mean") + dPreliminaryOffset.at(iBoardIndex); - } - - } - - dHistoIndizes.at(iBoardIndex) = static_cast<Double_t>(iBoardIndex); - - } - - } - - // The TGraph constructor requires a pointer of type Double_t to the C arrays - // to plot. The vector content can be addressed in an array-style fashion by a - // Double_t pointer because vectors store their elements contiguously. - - TGraph* tGraphRmsLinear = new TGraph(kiNbActiveBoards,static_cast<Double_t*>(&dHistoIndizes.at(0)),static_cast<Double_t*>(&dRmsLinear.at(0))); - TGraph* tGraphSigmaLinear = new TGraph(kiNbActiveBoards,static_cast<Double_t*>(&dHistoIndizes.at(0)),static_cast<Double_t*>(&dSigmaLinear.at(0))); - TGraph* tGraphRmsBinCenter = new TGraph(kiNbActiveBoards,static_cast<Double_t*>(&dHistoIndizes.at(0)),static_cast<Double_t*>(&dRmsBinCenter.at(0))); - TGraph* tGraphSigmaBinCenter = new TGraph(kiNbActiveBoards,static_cast<Double_t*>(&dHistoIndizes.at(0)),static_cast<Double_t*>(&dSigmaBinCenter.at(0))); - TGraph* tGraphRmsBinEdge = new TGraph(kiNbActiveBoards,static_cast<Double_t*>(&dHistoIndizes.at(0)),static_cast<Double_t*>(&dRmsBinEdge.at(0))); - TGraph* tGraphSigmaBinEdge = new TGraph(kiNbActiveBoards,static_cast<Double_t*>(&dHistoIndizes.at(0)),static_cast<Double_t*>(&dSigmaBinEdge.at(0))); - - tGraphRmsLinear->SetName("tGraphRmsLinear"); - tGraphSigmaLinear->SetName("tGraphSigmaLinear"); - tGraphRmsBinCenter->SetName("tGraphRmsBinCenter"); - tGraphSigmaBinCenter->SetName("tGraphSigmaBinCenter"); - tGraphRmsBinEdge->SetName("tGraphRmsBinEdge"); - tGraphSigmaBinEdge->SetName("tGraphSigmaBinEdge"); - - tGraphRmsLinear->SetTitle(Form("Reference time differences RMS to TDC %d",fiReferenceBoard)); - tGraphSigmaLinear->SetTitle(Form("Reference time differences Sigma to TDC %d",fiReferenceBoard)); - tGraphRmsBinCenter->SetTitle(Form("Reference time differences RMS to TDC %d",fiReferenceBoard)); - tGraphSigmaBinCenter->SetTitle(Form("Reference time differences Sigma to TDC %d",fiReferenceBoard)); - tGraphRmsBinEdge->SetTitle(Form("Reference time differences RMS to TDC %d",fiReferenceBoard)); - tGraphSigmaBinEdge->SetTitle(Form("Reference time differences Sigma to TDC %d",fiReferenceBoard)); - - - gDirectory->GetList()->Add(tGraphRmsLinear); - gDirectory->GetList()->Add(tGraphSigmaLinear); - gDirectory->GetList()->Add(tGraphRmsBinCenter); - gDirectory->GetList()->Add(tGraphSigmaBinCenter); - gDirectory->GetList()->Add(tGraphRmsBinEdge); - gDirectory->GetList()->Add(tGraphSigmaBinEdge); - - - TGraph* tGraphHistoMeanLinear = new TGraph(kiNbActiveBoards,static_cast<Double_t*>(&dHistoIndizes.at(0)),static_cast<Double_t*>(&dHistoMeanLinear.at(0))); - TGraph* tGraphGausMeanLinear = new TGraph(kiNbActiveBoards,static_cast<Double_t*>(&dHistoIndizes.at(0)),static_cast<Double_t*>(&dGausMeanLinear.at(0))); - TGraph* tGraphHistoMeanBinCenter = new TGraph(kiNbActiveBoards,static_cast<Double_t*>(&dHistoIndizes.at(0)),static_cast<Double_t*>(&dHistoMeanBinCenter.at(0))); - TGraph* tGraphGausMeanBinCenter = new TGraph(kiNbActiveBoards,static_cast<Double_t*>(&dHistoIndizes.at(0)),static_cast<Double_t*>(&dGausMeanBinCenter.at(0))); - TGraph* tGraphHistoMeanBinEdge = new TGraph(kiNbActiveBoards,static_cast<Double_t*>(&dHistoIndizes.at(0)),static_cast<Double_t*>(&dHistoMeanBinEdge.at(0))); - TGraph* tGraphGausMeanBinEdge = new TGraph(kiNbActiveBoards,static_cast<Double_t*>(&dHistoIndizes.at(0)),static_cast<Double_t*>(&dGausMeanBinEdge.at(0))); - - tGraphHistoMeanLinear->SetName("tGraphHistoMeanLinear"); - tGraphGausMeanLinear->SetName("tGraphGausMeanLinear"); - tGraphHistoMeanBinCenter->SetName("tGraphHistoMeanBinCenter"); - tGraphGausMeanBinCenter->SetName("tGraphGausMeanBinCenter"); - tGraphHistoMeanBinEdge->SetName("tGraphHistoMeanBinEdge"); - tGraphGausMeanBinEdge->SetName("tGraphGausMeanBinEdge"); - - tGraphHistoMeanLinear->SetTitle(Form("Reference time differences h-Mean to TDC %d",fiReferenceBoard)); - tGraphGausMeanLinear->SetTitle(Form("Reference time differences g-Mean to TDC %d",fiReferenceBoard)); - tGraphHistoMeanBinCenter->SetTitle(Form("Reference time differences h-Mean to TDC %d",fiReferenceBoard)); - tGraphGausMeanBinCenter->SetTitle(Form("Reference time differences g-Mean to TDC %d",fiReferenceBoard)); - tGraphHistoMeanBinEdge->SetTitle(Form("Reference time differences h-Mean to TDC %d",fiReferenceBoard)); - tGraphGausMeanBinEdge->SetTitle(Form("Reference time differences g-Mean to TDC %d",fiReferenceBoard)); - - gDirectory->GetList()->Add(tGraphHistoMeanLinear); - gDirectory->GetList()->Add(tGraphGausMeanLinear); - gDirectory->GetList()->Add(tGraphHistoMeanBinCenter); - gDirectory->GetList()->Add(tGraphGausMeanBinCenter); - gDirectory->GetList()->Add(tGraphHistoMeanBinEdge); - gDirectory->GetList()->Add(tGraphGausMeanBinEdge); - - tBranch->SetAddress(vOldAddress); - - tArray->Clear("C"); - tArray = NULL; - - tOutputFile->cd("TofTrbCalib"); - - // Save information about the selected reference board, disabled boards - // and the board offsets w.r.t. the reference board in the output file - // of FairRootManager. - // Instead of dumping these "parameters" to the output ROOT file one could - // also utilize FairRuntimeDb by extending TMbsCalibTofPar by corresponding - // attributes, generating an updated parameter ROOT file when the calibration - // parameters have been created and delivering this file as "second input" - // to the digi production run. At this moment, I am not willing to invest - // this amount of effort, though. - vector<Int_t> iReferenceBoard(1,fiReferenceBoard); - vector<UInt_t> uGlobalFineTimeLimits(2,0); - uGlobalFineTimeLimits.at(0) = fuLowerLinearFineLimit; - uGlobalFineTimeLimits.at(1) = fuUpperLinearFineLimit; - - gDirectory->WriteObjectAny(&iReferenceBoard,"vector<Int_t>","iReferenceBoard"); - gDirectory->WriteObjectAny(&uGlobalFineTimeLimits,"vector<UInt_t>","uGlobalFineTimeLimits"); - gDirectory->WriteObjectAny(&bDisableBoard,"vector<Bool_t>","bDisableBoard"); - gDirectory->WriteObjectAny(&dFinalOffset,"vector<Double_t>","dFinalOffset"); - -/* - TVectorD* tDisableBoard = new TVectorD(bDisableBoard.size(),static_cast<Double_t*>(&bDisableBoard.at(0))); - TVectorD* tFinalOffset = new TVectorD(dFinalOffset.size(),static_cast<Double_t*>(&dFinalOffset.at(0))); - - tOutputTree->GetUserInfo()->Add(tDisableBoard); - tOutputTree->GetUserInfo()->Add(tFinalOffset); -*/ - - tOldDirectory->cd(); - - fBufferFile->Write(); - fBufferFile->Close(); - delete fBufferFile; - - } -} - -ClassImp(TTofTrbTdcCalib) diff --git a/beamtime/tof/tdc/trb/TTofTrbTdcCalib.h b/beamtime/tof/tdc/trb/TTofTrbTdcCalib.h deleted file mode 100644 index bc2439fdd7e10173528de1f7d8a7803a569ea369..0000000000000000000000000000000000000000 --- a/beamtime/tof/tdc/trb/TTofTrbTdcCalib.h +++ /dev/null @@ -1,126 +0,0 @@ -/** @file TTofTrbTdcCalib.h - ** @author Christian Simon <csimon@physi.uni-heidelberg.de> - ** @date 2016-04-18 - **/ - -#ifndef TTOFTRBTDCCALIB_H -#define TTOFTRBTDCCALIB_H 1 - -#include "FairTask.h" - -#include <vector> - -class TMbsUnpackTofPar; -class TMbsCalibTofPar; -class TClonesArray; -class TTree; -class TFile; -class TTrbHeader; -class TH1; - -/** @class TTofTrbTdcCalib - ** @brief ... - ** @author C. Simon <csimon@physi.uni-heidelberg.de> - ** @version 1.0 - ** - ** ... - ** - **/ -class TTofTrbTdcCalib : public FairTask -{ - public: - - /** default constructor **/ - TTofTrbTdcCalib(); - - /** default destructor **/ - ~TTofTrbTdcCalib() {}; - - virtual void Exec(Option_t *option); - - void CreateCalibration(Bool_t bCalibration = kTRUE) {fbCreateCalib = bCalibration;} - void SaveCalibData(Bool_t bSaveData = kTRUE) {fbSaveOutput = bSaveData;} - void SetFineTimeMethod(Int_t iMethod = 0) {fiFineTimeMethod = iMethod;} - void SetToTMethod(Int_t iMethod = 0) {fiToTMethod = iMethod;} - void SetMinEntriesBinByBin(Int_t iEntries = 100000) {fiMinEntriesBinByBin = iEntries;} - void SetMinEntriesLocalFineLimits(Int_t iEntries = 10000) {fiMinEntriesLocalLimits = iEntries;} - void SetTimeContinuum(Bool_t bContinuum = kTRUE) {fbTimeContinuum = bContinuum;} - void SetTrailingOffsetCycles(Int_t iCycles = 2) {fiTrailingOffset = iCycles;} - void SetLowerLinearFineLimit(UInt_t uLowerLimit) {fuLowerLinearFineLimit = uLowerLimit;} - void SetUpperLinearFineLimit(UInt_t uUpperLimit) {fuUpperLinearFineLimit = uUpperLimit;} - void SetReferenceBoard(Int_t iBoard = 0) {fiReferenceBoard = iBoard;} - void SetToTSingleLeading(Double_t dToT = -100.) {fdToTSingleLeading = dToT;} - - protected: - - /** Intialisation at begin of run. To be implemented in the derived class. - * If return value not kSUCCESS, task will be set inactive. - **/ - virtual InitStatus Init(); - - /** Intialise parameter containers. - * To be implemented in the derived class. - **/ - virtual void SetParContainers(); - - /** Action after each event. To be implemented in the derived class **/ - virtual void Finish(); - - private: - /** private methods **/ - - /** copy constructor **/ - TTofTrbTdcCalib(const TTofTrbTdcCalib&); - - /** assignment operator **/ - TTofTrbTdcCalib& operator=(const TTofTrbTdcCalib&); - - /** private members **/ - - TMbsUnpackTofPar* fMbsUnpackPar; - TMbsCalibTofPar* fMbsCalibPar; - - Bool_t fbCreateCalib; - Bool_t fbSaveOutput; - - TClonesArray* fTrbTdcBoardCollection; - TTrbHeader* fTrbHeader; - TClonesArray* fTrbTdcCalibCollection; - - Int_t fiFineTimeMethod; - Int_t fiToTMethod; - Int_t fiMinEntriesBinByBin; - Int_t fiMinEntriesLocalLimits; - Bool_t fbTimeContinuum; - Int_t fiTrailingOffset; - UInt_t fuLowerLinearFineLimit; - UInt_t fuUpperLinearFineLimit; - Int_t fiReferenceBoard; - - std::vector<Bool_t>* fbDisableBoard; - std::vector<Double_t>* fdFinalOffset; - - std::vector< std::vector<Double_t> > fdRefFineTime; - std::vector< std::vector< std::vector<Double_t> > > fdFineTime; - - Long64_t fliFullCoarseOverflows; - Double_t fdPreviousRefCoarseTime; - Double_t fdInitialRefOffset; - Bool_t fbFirstEvent; - - Double_t fdToTSingleLeading; - - TFile* fBufferFile; - TTree* fBufferTree; - - Int_t fiPreviousSpillIndex; - Double_t fdPreviousEventTime; - Double_t fdSpillStartTime; - - TH1* fCtsIdleTimeSpill; - TH1* fCtsSpillLength; - - ClassDef(TTofTrbTdcCalib,1) -}; - -#endif diff --git a/beamtime/tof/tdc/trb/TTofTrbTdcData.cxx b/beamtime/tof/tdc/trb/TTofTrbTdcData.cxx deleted file mode 100644 index 51260beae18ca89e059b47157559ef870972153d..0000000000000000000000000000000000000000 --- a/beamtime/tof/tdc/trb/TTofTrbTdcData.cxx +++ /dev/null @@ -1,175 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- TTofTrbTdcData source file ----- -// ----- ----- -// ----- created by C. Simon on 2014-04-05 ----- -// ----- ----- -// ----- based on TTofVftxData by P.-A. Loizeau ----- -// ----- https://subversion.gsi.de/fairroot/cbmroot/development/ploizeau/ ----- -// ----- main/unpack/tof/tdc/vftx/TTofVftxData.cxx ----- -// ----- revision 20754, 2013-07-17 ----- -// ----------------------------------------------------------------------------- - -#include "TTofTrbTdcData.h" - -// Defines -#include "TofTrbTdcDef.h" - -ClassImp(TTofTrbTdcData) - -TTofTrbTdcData::TTofTrbTdcData() : - TTofTdcData(), - fuEpoch(0), - fuFullCoarseTime(0) -{ -} - -TTofTrbTdcData::TTofTrbTdcData( UInt_t uChan, UInt_t uFt, - UInt_t uCoarseT, UInt_t uTot, UInt_t uEdge, - UInt_t uEpoch, ULong64_t uFullCoarseTime ) : - TTofTdcData(uChan, uFt, uCoarseT, uTot, uEdge), - fuEpoch(uEpoch), - fuFullCoarseTime(uFullCoarseTime) -{ -} - -TTofTrbTdcData::~TTofTrbTdcData() -{ -} - -void TTofTrbTdcData::Clear(Option_t *option) -{ - TTofTdcData::Clear(option); - fuEpoch = 0; - fuFullCoarseTime = 0; -} - -// Define < operator for vector sorting -Bool_t TTofTrbTdcData::operator <( const TTofTrbTdcData& rhs) const -{ - if( rhs.GetCoarseTime() < trbtdc::kuCoarseOverflowTest && - this->GetCoarseTime() >= rhs.GetCoarseTime() + trbtdc::kuCoarseOverflowTest ) - // Corse counter overflow between this hit and checked one - // hit ... Ovflw ... rhs - return kTRUE; - else if( this->GetCoarseTime() < trbtdc::kuCoarseOverflowTest && - this->GetCoarseTime() + trbtdc::kuCoarseOverflowTest <= rhs.GetCoarseTime() ) - // Corse counter overflow between checked hit and this one - // rhs ... Ovflw ... hit - return kFALSE; - else if( this->GetCoarseTime() < rhs.GetCoarseTime() ) - // CT hit ... rhs - return kTRUE; - else if( this->GetCoarseTime() > rhs.GetCoarseTime() ) - // CT rhs ... hit - return kFALSE; - else if( this->GetFineTime() > rhs.GetFineTime()) - // Comparator inverted as FineTime is counting - // Backward from next epoch!!!!! - // CT rhs = hit - // FT hit ... rhs - return kTRUE; - // CT rhs = hit - // FT rhs ... hit or rhs = hit - else return kFALSE; -} - -Bool_t TTofTrbTdcData::operator <( const TTofTdcData& rhs) const -{ - if( rhs.GetCoarseTime() < trbtdc::kuCoarseOverflowTest && - this->GetCoarseTime() >= rhs.GetCoarseTime() + trbtdc::kuCoarseOverflowTest ) - // Corse counter overflow between this hit and checked one - // hit ... Ovflw ... rhs - return kTRUE; - else if( this->GetCoarseTime() < trbtdc::kuCoarseOverflowTest && - this->GetCoarseTime() + trbtdc::kuCoarseOverflowTest <= rhs.GetCoarseTime() ) - // Corse counter overflow between checked hit and this one - // rhs ... Ovflw ... hit - return kFALSE; - else if( this->GetCoarseTime() < rhs.GetCoarseTime() ) - // CT hit ... rhs - return kTRUE; - else if( this->GetCoarseTime() > rhs.GetCoarseTime() ) - // CT rhs ... hit - return kFALSE; - else if( this->GetFineTime() > rhs.GetFineTime()) - // Comparator inverted as FineTime is counting - // Backward from next epoch!!!!! - // CT rhs = hit - // FT hit ... rhs - return kTRUE; - // CT rhs = hit - // FT rhs ... hit or rhs = hit - else return kFALSE; -} -Int_t TTofTrbTdcData::Compare( const TObject* obj) const -{ - return Compare( (TTofTrbTdcData*) obj); -} -Int_t TTofTrbTdcData::Compare( const TTofTrbTdcData* obj) const -{ - if( obj->GetCoarseTime() < trbtdc::kuCoarseOverflowTest && - this->GetCoarseTime() >= obj->GetCoarseTime() + trbtdc::kuCoarseOverflowTest ) - // Corse counter overflow between this hit and checked one - // hit ... Ovflw ... rhs - return -1; - else if( this->GetCoarseTime() < trbtdc::kuCoarseOverflowTest && - this->GetCoarseTime() + trbtdc::kuCoarseOverflowTest <= obj->GetCoarseTime() ) - // Corse counter overflow between checked hit and this one - // rhs ... Ovflw ... hit - return 1; - else if( this->GetCoarseTime() < obj->GetCoarseTime() ) - // CT hit ... rhs - return -1; - else if( this->GetCoarseTime() > obj->GetCoarseTime() ) - // CT rhs ... hit - return 1; - else if( this->GetFineTime() > obj->GetFineTime()) - // Comparator inverted as FineTime is counting - // Backward from next epoch!!!!! - // CT rhs = hit - // FT hit ... rhs - return -1; - else if( this->GetFineTime() < obj->GetFineTime()) - // Comparator inverted as FineTime is counting - // Backward from next epoch!!!!! - // CT rhs = hit - // FT rhs ... hit - return 1; - // CT rhs = hit - // FT rhs = hit - else return 0; -} -Int_t TTofTrbTdcData::Compare( const TTofTdcData* obj) const -{ - if( obj->GetCoarseTime() < trbtdc::kuCoarseOverflowTest && - this->GetCoarseTime() >= obj->GetCoarseTime() + trbtdc::kuCoarseOverflowTest ) - // Corse counter overflow between this hit and checked one - // hit ... Ovflw ... rhs - return -1; - else if( this->GetCoarseTime() < trbtdc::kuCoarseOverflowTest && - this->GetCoarseTime() + trbtdc::kuCoarseOverflowTest <= obj->GetCoarseTime() ) - // Corse counter overflow between checked hit and this one - // rhs ... Ovflw ... hit - return 1; - else if( this->GetCoarseTime() < obj->GetCoarseTime() ) - // CT hit ... rhs - return -1; - else if( this->GetCoarseTime() > obj->GetCoarseTime() ) - // CT rhs ... hit - return 1; - else if( this->GetFineTime() > obj->GetFineTime()) - // Comparator inverted as FineTime is counting - // Backward from next epoch!!!!! - // CT rhs = hit - // FT hit ... rhs - return -1; - else if( this->GetFineTime() < obj->GetFineTime()) - // Comparator inverted as FineTime is counting - // Backward from next epoch!!!!! - // CT rhs = hit - // FT rhs ... hit - return 1; - // CT rhs = hit - // FT rhs = hit - else return 0; -} diff --git a/beamtime/tof/tdc/trb/TTofTrbTdcData.h b/beamtime/tof/tdc/trb/TTofTrbTdcData.h deleted file mode 100644 index cdf39df76bf3a3e1079aa3b46862b48075bc9199..0000000000000000000000000000000000000000 --- a/beamtime/tof/tdc/trb/TTofTrbTdcData.h +++ /dev/null @@ -1,59 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- TTofTrbTdcData header file ----- -// ----- ----- -// ----- created by C. Simon on 2014-04-05 ----- -// ----- ----- -// ----- based on TTofVftxData by P.-A. Loizeau ----- -// ----- https://subversion.gsi.de/fairroot/cbmroot/development/ploizeau/ ----- -// ----- main/unpack/tof/tdc/vftx/TTofVftxData.h ----- -// ----- revision 20754, 2013-07-17 ----- -// ----------------------------------------------------------------------------- - -#ifndef TTOFTRBTDCDATA_H_ -#define TTOFTRBTDCDATA_H_ - -#include "TTofTdcData.h" - -class TTofTrbTdcData : public TTofTdcData -{ - public: - TTofTrbTdcData(); - TTofTrbTdcData( UInt_t uChan, UInt_t uFt, - UInt_t uCoarseT, UInt_t uTot, UInt_t uEdge, - UInt_t uEpoch, ULong64_t uFullCoarseTime ); - ~TTofTrbTdcData(); - - virtual void Clear(Option_t *option = ""); - - // copy constructor, used by vector to copy content - TTofTrbTdcData(const TTofTrbTdcData& src) : - TTofTdcData(src), - fuEpoch(src.fuEpoch), - fuFullCoarseTime(src.fuFullCoarseTime) {}; - - // Comparison operator, needed for time sorting - // To be implemeted for each TDC type as need coarse counter size - virtual Bool_t operator <( const TTofTrbTdcData& rhs) const; - virtual Bool_t operator <( const TTofTdcData& rhs) const; - - virtual Int_t Compare( const TObject* obj) const; - virtual Int_t Compare( const TTofTrbTdcData* obj) const; - virtual Int_t Compare( const TTofTdcData* obj) const; - - virtual Bool_t IsSortable() const { return kTRUE; }; - - void SetEpoch( UInt_t uEpoch ) { fuEpoch = uEpoch; }; - UInt_t GetEpoch() const { return fuEpoch; }; - - void SetFullCoarseTime( ULong64_t uFullCoarseTime ) { fuFullCoarseTime = uFullCoarseTime; }; - ULong64_t GetFullCoarseTime() const { return fuFullCoarseTime; }; - - private: - UInt_t fuEpoch; - ULong64_t fuFullCoarseTime; - - - ClassDef(TTofTrbTdcData, 1) -}; - -#endif diff --git a/beamtime/tof/tdc/trb/TTofTrbTdcUnpacker.cxx b/beamtime/tof/tdc/trb/TTofTrbTdcUnpacker.cxx deleted file mode 100644 index e015ce23dec93b7237c4da6fbbd55a2fb9d51eee..0000000000000000000000000000000000000000 --- a/beamtime/tof/tdc/trb/TTofTrbTdcUnpacker.cxx +++ /dev/null @@ -1,956 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- TTofTrbTdcUnpacker source file ----- -// ----- ----- -// ----- created by C. Simon on 2014-04-03 ----- -// ----- ----- -// ----- based on TTofVftxUnpacker by P.-A. Loizeau ----- -// ----- https://subversion.gsi.de/fairroot/cbmroot/development/ploizeau/ ----- -// ----- main/unpack/tof/tdc/vftx/TTofVftxUnpacker.cxx ----- -// ----- revision 20754, 2013-07-17 ----- -// ----------------------------------------------------------------------------- - -#include "TTofTrbTdcUnpacker.h" - -// Parameter header -#include "TMbsUnpackTofPar.h" -#include "TMbsCalibTofPar.h" - -// Output data objects -#include "TTofTrbTdcBoard.h" - -// Defines -#include "TofDef.h" -#include "TofTdcDef.h" - -// TDC iterator -#include "HadaqTdcIterator.h" - -// ROOT -#include "TClonesArray.h" -#include "TH1.h" -#include "TH2.h" -#include "TROOT.h" -#include "TTree.h" -#include "TBranch.h" - -// FairRoot -#include "FairRootManager.h" -#include "FairLogger.h" -#include "FairRuntimeDb.h" -#include "FairRun.h" - -ClassImp(TTofTrbTdcUnpacker) - -std::map<Int_t,Bool_t> TTofTrbTdcUnpacker::fmRingBufferOverflow; -Int_t TTofTrbTdcUnpacker::fiAcceptedHits(0); -Int_t TTofTrbTdcUnpacker::fiAvailableHits(0); -Bool_t TTofTrbTdcUnpacker::fbInspection(kFALSE); - -TTofTrbTdcUnpacker::TTofTrbTdcUnpacker( TMbsUnpackTofPar * parUnpackIn, TMbsCalibTofPar * parCalibIn ): - fParUnpack( parUnpackIn ), - fParCalib( parCalibIn ), - fuNbActiveTrbTdc( parUnpackIn->GetNbActiveBoards( tofMbs::trbtdc ) ), - fbCalibTrigger(kFALSE), - fbJointEdgesChannel( parUnpackIn->IsTrbTdcJointEdgesChannel() ), - fTrbTdcBoardCollection(0), - fTrbTdcRingBufferOverflow(NULL), - fLeadingOnlyShares(), - fTrailingOnlyShares(), - fUnequalEdgesShares(), - fiLeadingOnlyBuffers(), - fiTrailingOnlyBuffers(), - fiUnequalEdgesBuffers(), - fiAllNonEmptyBuffers(), - fTrbTdcBoardTot(), - fTrbTdcLeadingPosition(), - fTrbTdcTrailingPosition(), - fTrbTdcRefChannelFineTime(NULL), - fTrbTdcBoardFineTime(), - fTrbTdcChannelOccupancy(), -// fTrbTdcChannelFineTimeOvershoot(), -// fTrbTdcChannelUnprocessedHits(), - fTrbTdcChannelFineTime(), -// fTrbTdcChannelCoarseTime(), - fTrbTdcChannelToT(), - fuEventIndex(0) -{ - LOG(info)<<"**** TTofTrbTdcUnpacker: Call TTofTrbTdcUnpacker()..."; - - // Recover first the TRB-TDC board objects created in TTrbUnpackTof - FairRootManager* rootMgr = FairRootManager::Instance(); - - fTrbTdcBoardCollection = (TClonesArray*) rootMgr->GetObject("TofTrbTdc"); - if(0 == fTrbTdcBoardCollection) - { - LOG(warn)<<"TTofTrbTdcUnpacker::TTofTrbTdcUnpacker : no TOF TRB-TDC array! "; - fuNbActiveTrbTdc = 0; - } - - if( fbInspection ) - { - for(UInt_t uBoardIndex = 0; uBoardIndex < fuNbActiveTrbTdc; uBoardIndex++) - { - if( !fParCalib->CheckTotInvFlag( toftdc::trb, uBoardIndex ) ) - { - LOG(fatal)<<Form("Check your parCalib* file! No ToT inversion flags provided for TDCs indexed %2u and above!!!",uBoardIndex); - } - } - } - -} - -TTofTrbTdcUnpacker::~TTofTrbTdcUnpacker() -{ - LOG(info)<<"**** TTofTrbTdcUnpacker: Call ~TTofTrbTdcUnpacker()..."; - // Creation and clean-up of member histogram vectors done by TMbsUnpTofMonitor -} - -void TTofTrbTdcUnpacker::Clear(Option_t */*option*/) -{ - LOG(info)<<"**** TTofTrbTdcUnpacker: Call Clear()..."; - -// fParUnpack = 0; -// fuNbActiveTrbTdc = 0; -// fTrbTdcBoardCollection = 0; -} - -Int_t TTofTrbTdcUnpacker::ProcessData( hadaq::RawSubevent* tSubevent, UInt_t uStartIndex ) -{ -/* unclear points: - - EPOCH reset compensation in stream - - 2016-04-07 - Unclear point understood and appropriately treated in the new calibration class -*/ - LOG(debug)<<"**** TTofTrbTdcUnpacker: Call ProcessData()..."; - - UInt_t uTdcDataIndex = uStartIndex; - - UInt_t uTdcData = tSubevent->Data(uTdcDataIndex); - UInt_t uTdcAddress = uTdcData & 0xffff; - UInt_t uNbTdcDataWords = (uTdcData >> 16) & 0xffff; - Int_t iTdcBoardIndex = fParUnpack->GetActiveTrbTdcIndex( uTdcAddress ); - Bool_t bUnpackData = fParUnpack->UnpackTrbTdcAddress(uTdcAddress); - - TTofTrbTdcBoard* tTrbTdcBoard = (TTofTrbTdcBoard*) fTrbTdcBoardCollection->ConstructedAt( iTdcBoardIndex ); - tTrbTdcBoard->SetInvalid(); - UInt_t uTdcWordCount = 0; - - // PAL 23/07/2015: Use direct constructor call instead of copy constructor -// hadaq::TdcIterator tTrbTdcIterator = hadaq::TdcIterator(); - hadaq::TdcIterator tTrbTdcIterator; - tTrbTdcIterator.assign(tSubevent, uTdcDataIndex+1, uNbTdcDataWords); - - hadaq::TdcMessage& tTrbTdcMessage = tTrbTdcIterator.msg(); - - Bool_t bPreviousIsEpoch = kFALSE; - UInt_t uPreviousChannel = 0; - UInt_t uPreviousCoarseTime = 0; - UInt_t uPreviousTimeWord = 0; - - Int_t iStatusMessage = trbtdc::process_Success; - - while ( tTrbTdcIterator.next() ) - { - uTdcWordCount++; - - if( 1 == uTdcWordCount ) - { - if ( tTrbTdcMessage.isHeaderMsg() ) - { - if( tTrbTdcMessage.getHeaderErr() & 0x1 ) - { - tTrbTdcBoard->SetChannelBufferIssue(); - fmRingBufferOverflow[iTdcBoardIndex] = kTRUE; - -// LOG(error)<<Form("TDC 0x%.4x: At least one channel ring buffer has been overwritten.",uTdcAddress); -// LOG(error)<<Form("TDC 0x%.4x: At least one channel ring buffer has been overwritten. Skip this TDC subsubevent!",uTdcAddress); -// return trbtdc::process_RingBufferOverwrite; - } - } - else - { - LOG(error)<<Form("TDC 0x%.4x: First data word is not a TDC HEADER word.",uTdcAddress); - return trbtdc::process_FirstNoHeader; - } - - continue; - } - - if( 2 == uTdcWordCount ) - { - if ( tTrbTdcMessage.isEpochMsg() ) - { - tTrbTdcIterator.setRefEpoch( tTrbTdcIterator.getCurEpoch() ); - } - else - { - LOG(error)<<Form("TDC 0x%.4x: Second data word is not a TDC EPOCH word.",uTdcAddress); - return trbtdc::process_SecondNoEpoch; - } - - continue; - } - - if( 3 == uTdcWordCount ) - { - if ( tTrbTdcMessage.isTimeMsg() ) - { - if( tTrbTdcMessage.getTimeChannel() == 0 ) - { - if( trbtdc::kuHighestReasonableFineTimeBin >= tTrbTdcMessage.getTimeTmFine() ) - { - ( tTrbTdcBoard->GetRefChannelData() ).SetData( - tTrbTdcMessage.getTimeChannel(), - tTrbTdcMessage.getTimeTmFine(), - ( UInt_t )( tTrbTdcIterator.getMsgStamp() & ( trbtdc::kiCoarseCounterSize-1 ) ), - 0, - tTrbTdcMessage.getTimeEdge() ); - ( tTrbTdcBoard->GetRefChannelData() ).SetEpoch( tTrbTdcIterator.getCurEpoch() ); - ( tTrbTdcBoard->GetRefChannelData() ).SetFullCoarseTime( tTrbTdcIterator.getMsgStamp() ); - - tTrbTdcBoard->SetTriggerTime( ( tTrbTdcBoard->GetRefChannelData() ).GetCoarseTime() ); - - } - else - { - LOG(info)<<Form("TDC 0x%.4x: Third data word is a TDC TIME word from channel 0 but with an unreasonable fine time of 0x%.3x.", - uTdcAddress,tTrbTdcMessage.getTimeTmFine()); - return trbtdc::process_ThirdBadRefTime; - } - } - else - { - LOG(error)<<Form("TDC 0x%.4x: Third data word is a TDC TIME word but not from channel 0.",uTdcAddress); - return trbtdc::process_ThirdNoRefTime; - } - } - else - { - LOG(error)<<Form("TDC 0x%.4x: Third data word is not a TDC TIME word.",uTdcAddress); - return trbtdc::process_ThirdNoTime; - } - - continue; - } - - if( 4 == uTdcWordCount ) - { - if ( !tTrbTdcMessage.isEpochMsg() && !fbCalibTrigger ) - { - LOG(error)<<Form("TDC 0x%.4x: Fourth data word is not a TDC EPOCH word.",uTdcAddress); - return trbtdc::process_FourthNoEpoch; - } - - bPreviousIsEpoch = kTRUE; - continue; - } - - if( kTRUE == bPreviousIsEpoch ) - { - switch ( tTrbTdcMessage.getKind() ) - { - case trbtdc::message_Time: - case trbtdc::message_Time1: - case trbtdc::message_Time2: - case trbtdc::message_Time3: - { - bPreviousIsEpoch = kFALSE; - - UInt_t uChNumber = tTrbTdcMessage.getTimeChannel(); - UInt_t uChFineTime = tTrbTdcMessage.getTimeTmFine(); - UInt_t uChCoarseTime = ( UInt_t )( tTrbTdcIterator.getMsgStamp() & ( trbtdc::kiCoarseCounterSize-1 ) ); - UInt_t uChEdge = tTrbTdcMessage.getTimeEdge(); - UInt_t uChEpoch = tTrbTdcIterator.getCurEpoch(); - ULong64_t uChFullCoarseTime = tTrbTdcIterator.getMsgStamp(); - - uPreviousChannel = uChNumber; - - if ( ( 0 == uChNumber && !fbCalibTrigger ) || ( tTrbTdcBoard->GetChannelNb() < uChNumber ) ) - { - LOG(error)<<Form("TDC 0x%.4x: Invalid channel number %u in TDC TIME word.",uTdcAddress,uChNumber); - return trbtdc::process_BadChannelNumber; - } - - uPreviousCoarseTime = tTrbTdcMessage.getTimeTmCoarse(); - uPreviousTimeWord = tSubevent->Data(uStartIndex+uTdcWordCount); - - fiAvailableHits++; - - if ( trbtdc::time_FineTimeBitMask == uChFineTime ) - { - LOG(debug)<<Form("TDC 0x%.4x: Hit detected in channel %u but not properly processed. Skip it.", uTdcAddress, uChNumber); - iStatusMessage = trbtdc::process_BadFineTime; - continue; - } - - if ( 0 == uChNumber ) - { - LOG(debug2)<<Form("TDC 0x%.4x: Additional calibration hit detected in channel %u. Ignore it.", uTdcAddress, uChNumber); - continue; - } - - LOG(debug2)<<Form("TDC 0x%.4x: Hit in channel %u properly processed. Store it.", uTdcAddress, uChNumber); - - // Remove reference channel index (i.e. ch1->ch0, ch2->ch1 etc.) - // default: positive LVDS input signals - // leading edge in TDC channel with even index - // (after compensating for the reference channel index 0) - // trailing edge in TDC channel with odd index - // (after compensating for the reference channel index 0) - UInt_t uFinalChNumber = uChNumber - 1; - - if( fbJointEdgesChannel ) - { - uFinalChNumber = 2*uFinalChNumber + ( trbtdc::edge_Rising == uChEdge ? 0 : 1 ); - } - - if(bUnpackData) - { - TTofTrbTdcData tValidHit( uFinalChNumber, uChFineTime, uChCoarseTime, 0, uChEdge, uChEpoch, uChFullCoarseTime ); - tTrbTdcBoard->AddData( tValidHit ); - } - fiAcceptedHits++; - continue; - - break; - } - case trbtdc::message_Epoch: - { - LOG(error)<<Form("TDC 0x%.4x: Two consecutive TDC EPOCH words.", uTdcAddress); - return trbtdc::process_TwoConsecutiveEpochs; - - break; - } - default: - { - continue; - - break; - } - } - - } - else - { - switch ( tTrbTdcMessage.getKind() ) - { - case trbtdc::message_Time: - case trbtdc::message_Time1: - case trbtdc::message_Time2: - case trbtdc::message_Time3: - { - UInt_t uChNumber = tTrbTdcMessage.getTimeChannel(); - UInt_t uChFineTime = tTrbTdcMessage.getTimeTmFine(); - UInt_t uChCoarseTime = ( UInt_t )( tTrbTdcIterator.getMsgStamp() & ( trbtdc::kiCoarseCounterSize-1 ) ); - UInt_t uChEdge = tTrbTdcMessage.getTimeEdge(); - UInt_t uChEpoch = tTrbTdcIterator.getCurEpoch(); - ULong64_t uChFullCoarseTime = tTrbTdcIterator.getMsgStamp(); - - if( ( 0 == uChNumber && !fbCalibTrigger ) || ( tTrbTdcBoard->GetChannelNb() < uChNumber ) ) - { - LOG(error)<<Form("TDC 0x%.4x: Invalid channel number %u in TDC TIME word.", uTdcAddress, uChNumber); - return trbtdc::process_BadChannelNumber; - } - - if( uPreviousChannel != uChNumber ) - { - LOG(error)<<Form("TDC 0x%.4x: Change in hit channel number from %u to %u without a TDC EPOCH word in between.", uTdcAddress, uPreviousChannel, uChNumber); - return trbtdc::process_ChannelButNoEpochChange; - } - - UInt_t uBackupCoarseTime = uPreviousCoarseTime; - UInt_t uBackupTimeWord = uPreviousTimeWord; - - uPreviousCoarseTime = tTrbTdcMessage.getTimeTmCoarse(); - uPreviousTimeWord = tSubevent->Data(uStartIndex+uTdcWordCount); - - fiAvailableHits++; - - if( trbtdc::time_FineTimeBitMask == uChFineTime ) - { - LOG(debug)<<Form("TDC 0x%.4x: Hit detected in channel %u but not properly processed. Skip it.", uTdcAddress, uChNumber); - iStatusMessage = trbtdc::process_BadFineTime; - continue; - } - - if( 0 == uChNumber ) - { - LOG(debug2)<<Form("TDC 0x%.4x: Additional calibration hit detected in channel %u. Ignore it.", uTdcAddress, uChNumber); - continue; - } - - if( uBackupCoarseTime > tTrbTdcMessage.getTimeTmCoarse() ) - { - LOG(error)<<Form("TDC 0x%.4x: Coarse counter of channel %u overflowed but the TDC epoch counter was not incremented.",uTdcAddress,uChNumber); -// continue; - return trbtdc::process_NoEpochIncrement; - } - - if( uBackupTimeWord == uPreviousTimeWord ) - { - LOG(error)<<Form("TDC 0x%.4x: Two identical TIME words in a row in channel %u.",uTdcAddress,uChNumber); - return trbtdc::process_TwoIdenticalWords; - } - - LOG(debug2)<<Form("TDC 0x%.4x: Hit in channel %u properly processed. Store it.", uTdcAddress, uChNumber); - - // Remove reference channel index (i.e. ch1->ch0, ch2->ch1 etc.) - // default: positive LVDS input signals - // leading edge in TDC channel with even index - // (after compensating for the reference channel index 0) - // trailing edge in TDC channel with odd index - // (after compensating for the reference channel index 0) - UInt_t uFinalChNumber = uChNumber - 1; - - if( fbJointEdgesChannel ) - { - uFinalChNumber = 2*uFinalChNumber + ( trbtdc::edge_Rising == uChEdge ? 0 : 1 ); - } - - if(bUnpackData) - { - TTofTrbTdcData tValidHit( uFinalChNumber, uChFineTime, uChCoarseTime, 0, uChEdge, uChEpoch, uChFullCoarseTime ); - tTrbTdcBoard->AddData( tValidHit ); - } - fiAcceptedHits++; - continue; - - break; - } - case trbtdc::message_Epoch: - { - bPreviousIsEpoch = kTRUE; - continue; - - break; - } - default: - { - continue; - - break; - } - } - - } - - } - -/* -// Example of a raw data dump - - gLogger->SetLogScreenLevel("ERROR"); - LOG(error)<<"board index: "<<iTdcBoardIndex; - - for(UInt_t uWord = uStartIndex; uWord <= uStartIndex+uNbTdcDataWords; uWord++) - { - if((tSubevent->Data(uWord) & 0xe0000000) != 0x80000000) - { - LOG(error)<< Form("0x%.8x",tSubevent->Data(uWord)); - } - else - { - LOG(error)<< Form("0x%.8x, channel: %02u, coarse time: %4u, fine time: %4u, edge: %1u", - tSubevent->Data(uWord),tSubevent->Data(uWord)>>22 & 0x7f, - tSubevent->Data(uWord) & 0x7ff, - tSubevent->Data(uWord)>>12 & 0x3ff, - tSubevent->Data(uWord)>>11 & 0x1); - } - } - - LOG(error); - gLogger->SetLogScreenLevel("FATAL"); -*/ - - -// tTrbTdcBoard->SortData(); - - tTrbTdcBoard->SetCalibData(fbCalibTrigger); - tTrbTdcBoard->SetValid(); - - if( 0 == iTdcBoardIndex ) - fuEventIndex++; - - LOG(debug)<<Form("TRB-TDC subsubevent from FPGA 0x%.4x fully unpacked. Success!",uTdcAddress); - return iStatusMessage; - -} - -// Histogram management -// TODO: maybe add some options to control which histograms are -// created and filed (memory management) -void TTofTrbTdcUnpacker::CreateHistos() -{ - LOG(info)<<"**** TTofTrbTdcUnpacker: Call CreateHistos()..."; - - TDirectory * oldir = gDirectory; // <= To prevent histos from being sucked in by the param file of the TRootManager! - gROOT->cd(); // <= To prevent histos from being sucked in by the param file of the TRootManager ! - - fTrbTdcChannelOccupancy.resize( fuNbActiveTrbTdc, NULL ); -/* - fTrbTdcChannelFineTimeOvershoot.resize( fuNbActiveTrbTdc, NULL ); - fTrbTdcChannelUnprocessedHits.resize( fuNbActiveTrbTdc, NULL ); -*/ - - fTrbTdcChannelFineTime.resize( fuNbActiveTrbTdc, std::vector<TH1I*>( trbtdc::kuNbChan+1, NULL ) ); -// fTrbTdcChannelCoarseTime.resize( fuNbActiveTrbTdc, std::vector<TH1I*>( trbtdc::kuNbChan+1, NULL ) ); - fTrbTdcChannelToT.resize( fuNbActiveTrbTdc, std::vector<TH1I*>( trbtdc::kuNbChan, NULL ) ); - - if( fbInspection ) - { - fiLeadingOnlyBuffers.resize( fuNbActiveTrbTdc, std::vector<Int_t>( trbtdc::kuNbChan/2, 0. ) ); - fiTrailingOnlyBuffers.resize( fuNbActiveTrbTdc, std::vector<Int_t>( trbtdc::kuNbChan/2, 0. ) ); - fiUnequalEdgesBuffers.resize( fuNbActiveTrbTdc, std::vector<Int_t>( trbtdc::kuNbChan/2, 0. ) ); - fiAllNonEmptyBuffers.resize( fuNbActiveTrbTdc, std::vector<Int_t>( trbtdc::kuNbChan/2, 0. ) ); - - fLeadingOnlyShares.resize( fuNbActiveTrbTdc, NULL ); - fTrailingOnlyShares.resize( fuNbActiveTrbTdc, NULL ); - fUnequalEdgesShares.resize( fuNbActiveTrbTdc, NULL ); - - fTrbTdcBoardTot.resize( fuNbActiveTrbTdc, NULL ); - fTrbTdcLeadingPosition.resize( fuNbActiveTrbTdc, NULL ); - fTrbTdcTrailingPosition.resize( fuNbActiveTrbTdc, NULL ); - - fTrbTdcBoardFineTime.resize( fuNbActiveTrbTdc, NULL ); - } - - for( UInt_t uBoardIndex = 0; uBoardIndex < fuNbActiveTrbTdc; uBoardIndex++) - { - UInt_t uTrbNetAddress = fParUnpack->GetActiveTrbTdcAddr(uBoardIndex); - - // Board specific histograms - fTrbTdcChannelOccupancy.at(uBoardIndex) = new TH1I( Form("tof_%s_ch_occ_%03u", toftdc::ksTdcHistName[ toftdc::trb ].Data(), uBoardIndex), - Form("Channel occupancy in TRB-TDC #%03u (0x%04x)", uBoardIndex, uTrbNetAddress), - trbtdc::kuNbChan+1, 0.0, trbtdc::kuNbChan+1 ); - fTrbTdcChannelOccupancy.at(uBoardIndex)->GetXaxis()->SetTitle("TDC channel []"); - -/* - fTrbTdcChannelFineTimeOvershoot.at(uBoardIndex) = new TH1I( Form("tof_%s_ch_highft_%03u", toftdc::ksTdcHistName[ toftdc::trb ].Data(), uBoardIndex), - Form("Fine time overshoot in TRB-TDC #%03u (0x%04x)", uBoardIndex, uTrbNetAddress), - trbtdc::kuNbChan+1, 0.0, trbtdc::kuNbChan+1 ); - - fTrbTdcChannelUnprocessedHits.at(uBoardIndex) = new TH1I( Form("tof_%s_ch_unproc_%03u", toftdc::ksTdcHistName[ toftdc::trb ].Data(), uBoardIndex), - Form("Unprocessed hits in TRB-TDC #%03u (0x%04x)", uBoardIndex, uTrbNetAddress), - trbtdc::kuNbChan+1, 0.0, trbtdc::kuNbChan+1 ); -*/ - if( fbInspection ) - { - fLeadingOnlyShares.at(uBoardIndex) = new TH1D( Form("tof_%s_ch_leadonly_%03u", toftdc::ksTdcHistName[ toftdc::trb ].Data(), uBoardIndex), - Form("Leading-edge only event shares in TRB-TDC #%03u (0x%04x)", uBoardIndex, uTrbNetAddress), - trbtdc::kuNbChan/2, 0., trbtdc::kuNbChan/2. ); - fLeadingOnlyShares.at(uBoardIndex)->GetXaxis()->SetTitle("Readout channel []"); - fLeadingOnlyShares.at(uBoardIndex)->GetYaxis()->SetTitle("event share [%]"); - - fTrailingOnlyShares.at(uBoardIndex) = new TH1D( Form("tof_%s_ch_trailonly_%03u", toftdc::ksTdcHistName[ toftdc::trb ].Data(), uBoardIndex), - Form("Trailing-edge only event shares in TRB-TDC #%03u (0x%04x)", uBoardIndex, uTrbNetAddress), - trbtdc::kuNbChan/2, 0., trbtdc::kuNbChan/2. ); - fTrailingOnlyShares.at(uBoardIndex)->GetXaxis()->SetTitle("Readout channel []"); - fTrailingOnlyShares.at(uBoardIndex)->GetYaxis()->SetTitle("event share [%]"); - - fUnequalEdgesShares.at(uBoardIndex) = new TH1D( Form("tof_%s_ch_unequal_%03u", toftdc::ksTdcHistName[ toftdc::trb ].Data(), uBoardIndex), - Form("Unequal edge count event shares in TRB-TDC #%03u (0x%04x)", uBoardIndex, uTrbNetAddress), - trbtdc::kuNbChan/2, 0., trbtdc::kuNbChan/2. ); - fUnequalEdgesShares.at(uBoardIndex)->GetXaxis()->SetTitle("Readout channel []"); - fUnequalEdgesShares.at(uBoardIndex)->GetYaxis()->SetTitle("event share [%]"); - - fTrbTdcBoardTot.at(uBoardIndex) = new TH2I( Form("tof_%s_board_tot_%03u", toftdc::ksTdcHistName[ toftdc::trb ].Data(), uBoardIndex), - Form("All channel ToT in TRB-TDC #%03u (0x%04x)", uBoardIndex, uTrbNetAddress), - trbtdc::kuNbChan/2, 0., trbtdc::kuNbChan/2., - 2000, -100., 100.); - fTrbTdcBoardTot.at(uBoardIndex)->GetXaxis()->SetTitle("Readout channel []"); - fTrbTdcBoardTot.at(uBoardIndex)->GetYaxis()->SetTitle("ToT [ns]"); - - fTrbTdcLeadingPosition.at(uBoardIndex) = new TH2I( Form("tof_%s_board_lead_pos_%03u", toftdc::ksTdcHistName[ toftdc::trb ].Data(), uBoardIndex), - Form("Leading edge position in TRB-TDC #%03u (0x%04x)", uBoardIndex, uTrbNetAddress), - trbtdc::kuNbChan/2, 0., trbtdc::kuNbChan/2., - 701,-600.5,100.5); - fTrbTdcLeadingPosition.at(uBoardIndex)->GetXaxis()->SetTitle("Readout channel []"); - fTrbTdcLeadingPosition.at(uBoardIndex)->GetYaxis()->SetTitle("leading time [ns]"); - - fTrbTdcTrailingPosition.at(uBoardIndex) = new TH2I( Form("tof_%s_board_trail_pos_%03u", toftdc::ksTdcHistName[ toftdc::trb ].Data(), uBoardIndex), - Form("Trailing edge position in TRB-TDC #%03u (0x%04x)", uBoardIndex, uTrbNetAddress), - trbtdc::kuNbChan/2, 0., trbtdc::kuNbChan/2., - 701,-600.5,100.5); - fTrbTdcTrailingPosition.at(uBoardIndex)->GetXaxis()->SetTitle("Readout channel []"); - fTrbTdcTrailingPosition.at(uBoardIndex)->GetYaxis()->SetTitle("trailing time [ns]"); - - fTrbTdcBoardFineTime.at(uBoardIndex) = new TH2I( Form("tof_%s_board_ft_%03u", toftdc::ksTdcHistName[ toftdc::trb ].Data(), uBoardIndex), - Form("Fine time in TRB-TDC #%03u (0x%04x)", uBoardIndex, uTrbNetAddress), - trbtdc::kuNbChan, 0., trbtdc::kuNbChan, - trbtdc::kuHighestReasonableFineTimeBin, 0, trbtdc::kuHighestReasonableFineTimeBin); - fTrbTdcBoardFineTime.at(uBoardIndex)->GetXaxis()->SetTitle("TDC channel []"); - fTrbTdcBoardFineTime.at(uBoardIndex)->GetYaxis()->SetTitle("fine time [bins]"); - } - - // Reference Channel specific histograms - (fTrbTdcChannelFineTime.at(uBoardIndex)).at(0) = new TH1I( Form("tof_%s_ft_b%03u_ref", toftdc::ksTdcHistName[ toftdc::trb ].Data(), uBoardIndex), - Form("Counts per fine-time bin for reference channel on TRB-TDC #%03u (0x%04x)", uBoardIndex, uTrbNetAddress), - trbtdc::kiFineCounterSize, -0.5, trbtdc::kiFineCounterSize - 0.5 ); - (fTrbTdcChannelFineTime.at(uBoardIndex)).at(0)->GetXaxis()->SetTitle("fine time [bins]"); -/* - // TODO: remove hard coding - (fTrbTdcChannelCoarseTime.at(uBoardIndex)).at(0) = new TH1I( Form("tof_%s_ct_b%03u_ref", toftdc::ksTdcHistName[ toftdc::trb ].Data(), uBoardIndex), - Form("Counts per coarse-time bin for reference channel on TRB-TDC #%03u (0x%04x)", uBoardIndex, uTrbNetAddress), - trbtdc::kiCoarseCounterSize/1024/512, -0.5, trbtdc::kiCoarseCounterSize/1024/512 - 0.5 ); -*/ - - // Channel specific histograms - for( UInt_t uChannelIndex = 0; uChannelIndex < trbtdc::kuNbChan; uChannelIndex++) - { - - (fTrbTdcChannelFineTime.at(uBoardIndex)).at(uChannelIndex+1) = new TH1I( Form("tof_%s_ft_b%03u_ch%03u", toftdc::ksTdcHistName[ toftdc::trb ].Data(), uBoardIndex, uChannelIndex), - Form("Counts per fine-time bin for channel %3u on TRB-TDC #%03u (0x%04x)", uChannelIndex, uBoardIndex, uTrbNetAddress), - trbtdc::kiFineCounterSize, -0.5, trbtdc::kiFineCounterSize - 0.5 ); - (fTrbTdcChannelFineTime.at(uBoardIndex)).at(uChannelIndex+1)->GetXaxis()->SetTitle("fine time [bins]"); -/* - // TODO: remove hard coding - (fTrbTdcChannelCoarseTime.at(uBoardIndex)).at(uChannelIndex+1) = new TH1I( Form("tof_%s_ct_b%03u_ch%03u", toftdc::ksTdcHistName[ toftdc::trb ].Data(), uBoardIndex, uChannelIndex), - Form("Counts per coarse-time bin for channel %3u on TRB-TDC #%03u (0x%04x)", uChannelIndex, uBoardIndex, uTrbNetAddress), - trbtdc::kiCoarseCounterSize/1024/512, -0.5, trbtdc::kiCoarseCounterSize/1024/512 - 0.5 ); -*/ - } - - if( fbInspection ) - { - for( UInt_t uChannelIndex = 0; uChannelIndex < trbtdc::kuNbChan/2; uChannelIndex++) - { - (fTrbTdcChannelToT.at(uBoardIndex)).at(uChannelIndex) = new TH1I( Form("tof_%s_tot_b%03u_ch%03u", toftdc::ksTdcHistName[ toftdc::trb ].Data(), uBoardIndex, uChannelIndex+1), - Form("ToT for channel pair %3u on TRB-TDC 0x%04x", uChannelIndex, uTrbNetAddress), - 2000, -100, 100); - (fTrbTdcChannelToT.at(uBoardIndex)).at(uChannelIndex)->GetXaxis()->SetTitle("ToT [ns]"); - } - } - - } - - fTrbTdcRingBufferOverflow = new TH1I( Form("tof_%s_buffer_overflow", toftdc::ksTdcHistName[ toftdc::trb ].Data()), - "TRB-TDC ring buffer overflows per board", - fuNbActiveTrbTdc, 0, fuNbActiveTrbTdc); - fTrbTdcRingBufferOverflow->GetXaxis()->SetTitle("TDC board []"); - - if( fbInspection ) - { - fTrbTdcRefChannelFineTime = new TH2I( Form("tof_%s_all_ref_ft", toftdc::ksTdcHistName[ toftdc::trb ].Data()), - Form("All TRB-TDC reference fine times"), - fuNbActiveTrbTdc, 0, fuNbActiveTrbTdc, - trbtdc::kuHighestReasonableFineTimeBin, 0, trbtdc::kuHighestReasonableFineTimeBin); - fTrbTdcRefChannelFineTime->GetXaxis()->SetTitle("TDC board []"); - fTrbTdcRefChannelFineTime->GetYaxis()->SetTitle("fine time [bins]"); - } - - gDirectory->cd( oldir->GetPath() ); // <= To prevent histos from being sucked in by the param file of the TRootManager! -} - -void TTofTrbTdcUnpacker::FillHistos() -{ - LOG(debug)<<"**** TTofTrbTdcUnpacker: Call FillHistos()..."; - - // loop over TDC boards - TTofTrbTdcBoard * tTrbTdcBoard; - - for( UInt_t uBoardIndex = 0; uBoardIndex < fuNbActiveTrbTdc; uBoardIndex++) - { - UInt_t uTrbNetAddress = fParUnpack->GetActiveTrbTdcAddr(uBoardIndex); - - tTrbTdcBoard = (TTofTrbTdcBoard*) fTrbTdcBoardCollection->ConstructedAt(uBoardIndex); - - std::vector< std::vector<const TTofTrbTdcData*> > tToTEvenEdgeBuffers( trbtdc::kuNbChan/2, std::vector<const TTofTrbTdcData*>() ); - std::vector< std::vector<const TTofTrbTdcData*> > tToTOddEdgeBuffers( trbtdc::kuNbChan/2, std::vector<const TTofTrbTdcData*>() ); - - if( fbInspection ) - { - for( UInt_t uChannelIndex = 0; uChannelIndex < trbtdc::kuNbChan/2; uChannelIndex++ ) - { - (tToTEvenEdgeBuffers.at(uChannelIndex)).reserve(trbtdc::kuNbMulti); - (tToTOddEdgeBuffers.at(uChannelIndex)).reserve(trbtdc::kuNbMulti); - } - } - - // Loop over regular channels - for( UInt_t uDataIndex = 0; uDataIndex < tTrbTdcBoard->GetDataNb() ; uDataIndex++ ) - { - TTofTrbTdcData data = tTrbTdcBoard->GetData( uDataIndex ); - - if( fbInspection ) - { - const TTofTrbTdcData* tTdcData = tTrbTdcBoard->GetDataPtr(uDataIndex); - - UInt_t uCurrentChannel(tTdcData->GetChannel()); - - if( 0 == uCurrentChannel % 2) - { - (tToTEvenEdgeBuffers.at(uCurrentChannel/2)).push_back(tTdcData); - } - else - { - (tToTOddEdgeBuffers.at(uCurrentChannel/2)).push_back(tTdcData); - } - } - - TString sTemp = Form( " TTofTrbTdcUnpacker::FillHistos: Addr 0x%04x Board #%03u Data #%04u Chan %3d CT %7d FT %7d Edge %1u", - uTrbNetAddress, uBoardIndex, uDataIndex, data.GetChannel()+1, - data.GetCoarseTime(), data.GetFineTime(), data.GetEdge() ); - LOG(debug2)<<sTemp; - - fTrbTdcChannelOccupancy[uBoardIndex]->Fill( data.GetChannel() + 1 ); - -/* - if( trbtdc::time_FineTimeBitMask == data.GetFineTime() ) - { - fTrbTdcChannelUnprocessedHits[uBoardIndex]->Fill( data.GetChannel() + 1 ); - } - - if( trbtdc::kuHighestReasonableFineTimeBin < data.GetFineTime() ) - { - fTrbTdcChannelFineTimeOvershoot[uBoardIndex]->Fill( data.GetChannel() + 1 ); - } -*/ - - fTrbTdcChannelFineTime[uBoardIndex][ data.GetChannel() +1 ]->Fill( data.GetFineTime() ); - if( fbInspection ) - { - fTrbTdcBoardFineTime.at(uBoardIndex)->Fill(data.GetChannel(),data.GetFineTime()); - } -// fTrbTdcChannelCoarseTime[uBoardIndex][ data.GetChannel() +1 ]->Fill( data.GetCoarseTime()%2048 ); - } - - if( fbInspection ) - { - const TTofTrbTdcData& tTdcRefTime = tTrbTdcBoard->GetRefChannelData(); - Long64_t liRefCoarseTime = static_cast<Long64_t>(tTdcRefTime.GetFullCoarseTime()); - - Double_t dReferenceTimeStamp = static_cast<Double_t>(liRefCoarseTime) - hadaq::TdcMessage::SimpleFineCalibr(tTdcRefTime.GetFineTime()); - - // ToT building function - for( UInt_t uChannelIndex = 0; uChannelIndex < trbtdc::kuNbChan/2; uChannelIndex++ ) - { - UInt_t uLeadingModulo; - - UInt_t uLeadingMultiplicity; - UInt_t uTrailingMultiplicity; - - // positive LVDS input signal - // leading edge in even channel - // trailing edge in odd channel - if( fParCalib->GetTotInvFlag( toftdc::trb, uBoardIndex, uChannelIndex ) ) - { - uLeadingModulo = 0; - - uLeadingMultiplicity = (tToTEvenEdgeBuffers.at(uChannelIndex)).size(); - uTrailingMultiplicity = (tToTOddEdgeBuffers.at(uChannelIndex)).size(); - } - // negative LVDS input signal - // trailing edge in even channel - // leading edge in odd channel - else - { - uLeadingModulo = 1; - - uTrailingMultiplicity = (tToTEvenEdgeBuffers.at(uChannelIndex)).size(); - uLeadingMultiplicity = (tToTOddEdgeBuffers.at(uChannelIndex)).size(); - } - - if( uLeadingMultiplicity && uTrailingMultiplicity ) - { - if( uLeadingMultiplicity == uTrailingMultiplicity ) - { - for( UInt_t uEvenIndex = 0; uEvenIndex < (tToTEvenEdgeBuffers.at(uChannelIndex)).size(); uEvenIndex++ ) - { - const TTofTrbTdcData* leadingData; - const TTofTrbTdcData* trailingData; - - if( 0 == uLeadingModulo ) - { - leadingData = (tToTEvenEdgeBuffers.at(uChannelIndex)).at(uEvenIndex); - trailingData = (tToTOddEdgeBuffers.at(uChannelIndex)).at(uEvenIndex); - } - else - { - leadingData = (tToTOddEdgeBuffers.at(uChannelIndex)).at(uEvenIndex); - trailingData = (tToTEvenEdgeBuffers.at(uChannelIndex)).at(uEvenIndex); - } - - Long64_t liLeadingCoarseTime = static_cast<Long64_t>(leadingData->GetFullCoarseTime()); - Long64_t liTrailingCoarseTime = static_cast<Long64_t>(trailingData->GetFullCoarseTime()); - - // Correcting for TDC internal coarse counter overflows w.r.t. - // the reference channel - hadaq::TdcMessage::CoarseOverflow(liLeadingCoarseTime,liRefCoarseTime); - hadaq::TdcMessage::CoarseOverflow(liTrailingCoarseTime,liRefCoarseTime); - - Double_t dLeadingTimeStamp = static_cast<Double_t>(liLeadingCoarseTime) - hadaq::TdcMessage::SimpleFineCalibr(leadingData->GetFineTime()); - Double_t dTrailingTimeStamp = static_cast<Double_t>(liTrailingCoarseTime) - hadaq::TdcMessage::SimpleFineCalibr(trailingData->GetFineTime()); - - // ToT in ps - Double_t dTimeOverThreshold = (dTrailingTimeStamp - dLeadingTimeStamp)*trbtdc::kdClockCycleSize; - - fTrbTdcChannelToT[uBoardIndex][uChannelIndex]->Fill( dTimeOverThreshold/1000. ); - - fTrbTdcBoardTot.at(uBoardIndex)->Fill(uChannelIndex,dTimeOverThreshold/1000.); - - fTrbTdcLeadingPosition.at(uBoardIndex)->Fill(uChannelIndex,(dLeadingTimeStamp-dReferenceTimeStamp)*trbtdc::kdClockCycleSize/1000.); - - fTrbTdcTrailingPosition.at(uBoardIndex)->Fill(uChannelIndex,(dTrailingTimeStamp-dReferenceTimeStamp)*trbtdc::kdClockCycleSize/1000.); - - } - } - else - { - (fiUnequalEdgesBuffers.at(uBoardIndex)).at(uChannelIndex)++; - } - } - else if( uLeadingMultiplicity ) - { - (fiLeadingOnlyBuffers.at(uBoardIndex)).at(uChannelIndex)++; - (fiUnequalEdgesBuffers.at(uBoardIndex)).at(uChannelIndex)++; - } - else if( uTrailingMultiplicity ) - { - (fiTrailingOnlyBuffers.at(uBoardIndex)).at(uChannelIndex)++; - (fiUnequalEdgesBuffers.at(uBoardIndex)).at(uChannelIndex)++; - } - - if( uLeadingMultiplicity || uTrailingMultiplicity ) - { - (fiAllNonEmptyBuffers.at(uBoardIndex)).at(uChannelIndex)++; - } - - - if( (fiAllNonEmptyBuffers.at(uBoardIndex)).at(uChannelIndex) ) - { - (fLeadingOnlyShares.at(uBoardIndex))->SetBinContent(uChannelIndex+1,(100.*(fiLeadingOnlyBuffers.at(uBoardIndex)).at(uChannelIndex))/(fiAllNonEmptyBuffers.at(uBoardIndex)).at(uChannelIndex)); - (fTrailingOnlyShares.at(uBoardIndex))->SetBinContent(uChannelIndex+1,(100.*(fiTrailingOnlyBuffers.at(uBoardIndex)).at(uChannelIndex))/(fiAllNonEmptyBuffers.at(uBoardIndex)).at(uChannelIndex)); - (fUnequalEdgesShares.at(uBoardIndex))->SetBinContent(uChannelIndex+1,(100.*(fiUnequalEdgesBuffers.at(uBoardIndex)).at(uChannelIndex))/(fiAllNonEmptyBuffers.at(uBoardIndex)).at(uChannelIndex)); - } - } - } - - // Consider the respective reference channel - fTrbTdcChannelOccupancy[uBoardIndex]->Fill(0); - -/* - if( trbtdc::time_FineTimeBitMask == ( tTrbTdcBoard->GetRefChannelData() ).GetFineTime() ) - { - fTrbTdcChannelUnprocessedHits[uBoardIndex]->Fill(0); - } - - if( trbtdc::kuHighestReasonableFineTimeBin < ( tTrbTdcBoard->GetRefChannelData() ).GetFineTime() ) - { - fTrbTdcChannelFineTimeOvershoot[uBoardIndex]->Fill(0); - } -*/ - fTrbTdcChannelFineTime[uBoardIndex][0]->Fill( ( tTrbTdcBoard->GetRefChannelData() ).GetFineTime() ); - if( fbInspection ) - { - fTrbTdcRefChannelFineTime->Fill(uBoardIndex, ( tTrbTdcBoard->GetRefChannelData() ).GetFineTime()); - } -// fTrbTdcChannelCoarseTime[uBoardIndex][0]->Fill( ( tTrbTdcBoard->GetRefChannelData() ).GetCoarseTime()%2048 ); - - } - - for ( std::map<Int_t,Bool_t>::iterator it = fmRingBufferOverflow.begin(); - it != fmRingBufferOverflow.end(); ++it) - { - if( it->second ) - { - fTrbTdcRingBufferOverflow->Fill( it->first ); - } - } - - fmRingBufferOverflow.clear(); -} - -void TTofTrbTdcUnpacker::WriteHistos( TDirectory* inDir) -{ - LOG(info)<<"**** TTofTrbTdcUnpacker: Call WriteHistos()..."; - - TDirectory * oldDir = gDirectory; - TDirectory * cdTrbTdcUnp[fuNbActiveTrbTdc]; - - for( UInt_t uBoardIndex = 0; uBoardIndex < fuNbActiveTrbTdc; uBoardIndex++) - { - cdTrbTdcUnp[uBoardIndex] = inDir->mkdir( Form( "Unp_%s_%03u", toftdc::ksTdcHistName[ toftdc::trb ].Data(), uBoardIndex) ); - cdTrbTdcUnp[uBoardIndex]->cd(); // make the "Unp..." directory the current directory - - fTrbTdcChannelOccupancy[uBoardIndex]->Write(); -/* - fTrbTdcChannelFineTimeOvershoot[uBoardIndex]->Write(); - fTrbTdcChannelUnprocessedHits[uBoardIndex]->Write(); -*/ - for( UInt_t uChannelIndex = 0; uChannelIndex <= trbtdc::kuNbChan; uChannelIndex++) - { - fTrbTdcChannelFineTime[uBoardIndex][uChannelIndex]->Write(); -// fTrbTdcChannelCoarseTime[uBoardIndex][uChannelIndex]->Write(); - } - - if( fbInspection ) - { - fLeadingOnlyShares.at(uBoardIndex)->Write(); - fTrailingOnlyShares.at(uBoardIndex)->Write(); - fUnequalEdgesShares.at(uBoardIndex)->Write(); - fTrbTdcBoardFineTime.at(uBoardIndex)->Write(); - - for( UInt_t uChannelIndex = 0; uChannelIndex < trbtdc::kuNbChan/2; uChannelIndex++) - { - fTrbTdcChannelToT[uBoardIndex][uChannelIndex]->Write(); - } - } - } - - TDirectory * tAllHistoDir = inDir->mkdir( Form( "Unp_%s_all", toftdc::ksTdcHistName[ toftdc::trb ].Data()) ); - tAllHistoDir->cd(); - fTrbTdcRingBufferOverflow->Write(); - - if( fbInspection ) - { - fTrbTdcRefChannelFineTime->Write(); - } - - gDirectory->Cd(oldDir->GetPath()); - - LOG(info) << "Statistics report from TRB-TDC raw data unpacker"; - LOG(info) << "Available TDC hits (time words): " << fiAvailableHits; - LOG(info) << "Accepted TDC hits (time words): " << fiAcceptedHits; - LOG(info) << Form("percentage share: %4.1f", 100.*fiAcceptedHits/fiAvailableHits) << " %"; - -} - -void TTofTrbTdcUnpacker::DeleteHistos() -{ // Method probably never called!!! - LOG(info)<<"**** TTofTrbTdcUnpacker: Call DeleteHistos()..."; - - for( UInt_t uBoardIndex = 0; uBoardIndex < fuNbActiveTrbTdc; uBoardIndex++) - { - delete fTrbTdcChannelOccupancy[uBoardIndex]; -/* - delete fTrbTdcChannelFineTimeOvershoot[uBoardIndex]; - delete fTrbTdcChannelUnprocessedHits[uBoardIndex]; -*/ - for( UInt_t uChannelIndex = 0; uChannelIndex <= trbtdc::kuNbChan; uChannelIndex++) - { - delete fTrbTdcChannelFineTime[uBoardIndex][uChannelIndex]; -// delete fTrbTdcChannelCoarseTime[uBoardIndex][uChannelIndex]; - } - - if( fbInspection ) - { - delete fLeadingOnlyShares.at(uBoardIndex); - delete fTrailingOnlyShares.at(uBoardIndex); - delete fUnequalEdgesShares.at(uBoardIndex); - delete fTrbTdcBoardFineTime.at(uBoardIndex); - - for( UInt_t uChannelIndex = 0; uChannelIndex < trbtdc::kuNbChan/2; uChannelIndex++) - { - delete fTrbTdcChannelToT[uBoardIndex][uChannelIndex]; - } - } - } - - delete fTrbTdcRingBufferOverflow; - - if( fbInspection ) - { - delete fTrbTdcRefChannelFineTime; - } -} diff --git a/beamtime/tof/tdc/trb/TTofTrbTdcUnpacker.h b/beamtime/tof/tdc/trb/TTofTrbTdcUnpacker.h deleted file mode 100644 index 7f33a17b8658a32140c3057cc919cec7cc72b1fa..0000000000000000000000000000000000000000 --- a/beamtime/tof/tdc/trb/TTofTrbTdcUnpacker.h +++ /dev/null @@ -1,120 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- TTofTrbTdcUnpacker header file ----- -// ----- ----- -// ----- created by C. Simon on 2014-04-02 ----- -// ----- ----- -// ----- based on TTofVftxUnpacker by P.-A. Loizeau ----- -// ----- https://subversion.gsi.de/fairroot/cbmroot/development/ploizeau/ ----- -// ----- main/unpack/tof/tdc/vftx/TTofVftxUnpacker.h ----- -// ----- revision 20754, 2013-07-17 ----- -// ----------------------------------------------------------------------------- - -#ifndef TTOFTRBTDCUNPACKER_H_ -#define TTOFTRBTDCUNPACKER_H_ - -#include "TObject.h" - -#include <vector> -#include <map> - -class TMbsUnpackTofPar; -class TMbsCalibTofPar; - -namespace hadaq -{ - struct RawSubevent; -} -/* -namespace trbtdc -{ - enum TrbTdcProcessStatus; -} -*/ - -class TClonesArray; -class TH1I; -class TH1D; -class TH2I; -class TDirectory; - -class TTofTrbTdcUnpacker : public TObject -{ - public: - TTofTrbTdcUnpacker( TMbsUnpackTofPar * parUnpackIn, TMbsCalibTofPar * parCalibIn ); - ~TTofTrbTdcUnpacker(); - - // unsure if needed - // never called in the unpacker - void Clear(Option_t *option); - - Int_t ProcessData( hadaq::RawSubevent* tSubevent, UInt_t uStartIndex ); - - void SetCalibTrigger( UInt_t uTriggerType ) { fbCalibTrigger = (0xd == uTriggerType); }; - static void SetInspection( Bool_t bInspection ) { fbInspection = bInspection;} - - void CreateHistos(); - void FillHistos(); - void WriteHistos( TDirectory* inDir); - void DeleteHistos(); - - private: - // no default Copy constructor and = OP as class not meant to be copied - TTofTrbTdcUnpacker(const TTofTrbTdcUnpacker&); - TTofTrbTdcUnpacker& operator=(const TTofTrbTdcUnpacker&); - - TMbsUnpackTofPar * fParUnpack; - TMbsCalibTofPar * fParCalib; - UInt_t fuNbActiveTrbTdc; - Bool_t fbCalibTrigger; - static Bool_t fbInspection; - Bool_t fbJointEdgesChannel; - TClonesArray * fTrbTdcBoardCollection; - - // TDC histograms - TH1I* fTrbTdcRingBufferOverflow; - static std::map<Int_t,Bool_t> fmRingBufferOverflow; - static Int_t fiAcceptedHits; - static Int_t fiAvailableHits; - - std::vector<TH1D*> fLeadingOnlyShares; - std::vector<TH1D*> fTrailingOnlyShares; - std::vector<TH1D*> fUnequalEdgesShares; - - std::vector< std::vector<Int_t> > fiLeadingOnlyBuffers; - std::vector< std::vector<Int_t> > fiTrailingOnlyBuffers; - std::vector< std::vector<Int_t> > fiUnequalEdgesBuffers; - std::vector< std::vector<Int_t> > fiAllNonEmptyBuffers; - - std::vector<TH2I*> fTrbTdcBoardTot; - std::vector<TH2I*> fTrbTdcLeadingPosition; - std::vector<TH2I*> fTrbTdcTrailingPosition; - TH2I* fTrbTdcRefChannelFineTime; - std::vector<TH2I*> fTrbTdcBoardFineTime; - - // TDC board histograms - // channel occupancy distribution - std::vector<TH1I*> fTrbTdcChannelOccupancy; - -/* - // channel fine time overshoot distribution - std::vector<TH1I*> fTrbTdcChannelFineTimeOvershoot; - // channel undetected hits distribution - std::vector<TH1I*> fTrbTdcChannelUnprocessedHits; -*/ - - // TDC channel histograms - // channel fine time distribution - std::vector< std::vector<TH1I*> > fTrbTdcChannelFineTime; - -/* - // channel coarse time distribution - std::vector< std::vector<TH1I*> > fTrbTdcChannelCoarseTime; -*/ - std::vector< std::vector<TH1I*> > fTrbTdcChannelToT; - - UInt_t fuEventIndex; - - ClassDef(TTofTrbTdcUnpacker, 1) -}; - -#endif diff --git a/beamtime/tof/tdc/trb/TofTrbTdcDef.h b/beamtime/tof/tdc/trb/TofTrbTdcDef.h deleted file mode 100644 index 0547a2ec8c0fb1756e898d6e6493f79038df4b56..0000000000000000000000000000000000000000 --- a/beamtime/tof/tdc/trb/TofTrbTdcDef.h +++ /dev/null @@ -1,154 +0,0 @@ -// ----------------------------------------------------------------------------- -// ----- TofTrbTdcDef header file ----- -// ----- ----- -// ----- created by C. Simon on 2014-04-02 ----- -// ----- ----- -// ----- based on TofTrb3Def by P.-A. Loizeau ----- -// ----- https://subversion.gsi.de/fairroot/cbmroot/development/ploizeau/ ----- -// ----- main/unpack/tof/tdc/trb3/TofTrb3Def.h ----- -// ----- revision 20754, 2013-07-17 ----- -// ----------------------------------------------------------------------------- - -#ifndef TOFTRBTDCDEF_H_ -#define TOFTRBTDCDEF_H_ - -namespace trbtdc -{ - enum TrbTdcMessage { - message_Mask = 0xe0000000, - message_Reserved = 0x00000000, - message_Header = 0x20000000, - message_Debug = 0x40000000, - message_Epoch = 0x60000000, - message_Time = 0x80000000, - message_Time1 = 0xa0000000, - message_Time2 = 0xc0000000, - message_Time3 = 0xe0000000 - }; - - enum TrbTdcHeaderWord { - header_ErrorBitMask = 0x0000FFFF, - header_ErrorBitShift = 0, - header_TriggerCodeBitMask = 0x000000FF, - header_TriggerCodeBitShift = 16, - header_ReservedBitMask = 0x0000001F, - header_ReservedBitShift = 24 - }; - - enum TrbTdcTimeWord { - time_CoarseTimeBitMask = 0x000007FF, - time_CoarseTimeBitShift = 0, - time_EdgeBitMask = 0x00000001, - time_EdgeBitShift = 11, - time_FineTimeBitMask = 0x000003FF, - time_FineTimeBitShift = 12, - time_ChannelBitMask = 0x0000007F, - time_ChannelBitShift = 22, - time_ReservedBitMask = 0x00000003, - time_ReservedBitShift = 29 - }; - - enum TrbTdcEpochWord { - epoch_EpochBitMask = 0x0FFFFFFF, - epoch_EpochBitShift = 0, - epoch_ReservedBitMask = 0x00000001, - epoch_ReservedBitShift = 28 - }; - - /* - enable debug mode: 0xc800 - bit 4 - default: not enabled (to save bandwidth for time messages) - not read out (actually no debug read-out implemented yet) - */ - enum TrbTdcDebugWord { - debug_InfoBitMask = 0x00FFFFFF, - debug_InfoBitShift = 0, - debug_ModeBitMask = 0x0000001F, - debug_ModeBitShift = 24 - }; - - /* - currently not read out - */ - enum TrbTdcReservedWord { - reserved_ReservedBitMask = 0x1FFFFFFF, - reserved_ReservedBitShift = 0 - }; - - enum TrbTdcEdgeFlag { - edge_Rising = 0x1, - edge_Falling = 0x0 - }; - - /* - did not find a straightforward way to extract the number of active bits - from the bit masks of fine time, coarse time and epoch data fields - */ - enum TrbTdcCounterSize { - size_FineTimeCounter = 10, - size_CoarseTimeCounter = 11, - size_EpochCounter = 28 - }; - - enum TrbTdcProcessStatus { - process_Success = 0, - process_FirstNoHeader = 1, - process_SecondNoEpoch = 2, - process_ThirdNoTime = 3, - process_ThirdNoRefTime = 4, - process_ThirdBadRefTime = 5, - process_FourthNoEpoch = 6, - process_BadChannelNumber = 7, - process_ChannelButNoEpochChange = 8, - process_TwoConsecutiveEpochs = 9, - process_RingBufferOverwrite = 10, - process_BadFineTime = 11, - process_NoEpochIncrement = 12, - process_TwoIdenticalWords = 13, - process_StatusMessages - }; - - enum TrbTdcFineInterpolation { - finetime_bincenter = 0, - finetime_binedge = 1, - finetime_linear = 2 - }; - - // number of channels in FPGA-TDC modules - const UInt_t kuNbChan = 64; - - // Maximal number of hits per channel per event stored - const UInt_t kuNbMulti = 8; - - // Finetime counts back from the next rising clock edge - const Bool_t kbInvertFt = kTRUE; - - const Int_t kiFineCounterSize = time_FineTimeBitMask + 1; - - /* - coarse counter size used in the calibration step - attention: artificially fixed to 2^30 bits to keep signed 32-bit integer - covering a coarse time range of 5 s bevor wrap around - needs to be changed when running in 'triggerless' mode!!! - */ - const Int_t kiCoarseCounterSize = 0x3FFFFFFF + 1; - const UInt_t kuCoarseOverflowTest = kiCoarseCounterSize / 2 ; // Limit for overflow check - - // Size of one clock cycle (=1 coarse bin) - const Double_t kdClockCycleSize = 5000.0; // [ps] - const Double_t kdClockCycleSizeSec = 5e-9; // [s] - - // also seen: (20,500) and (31,421) - const UInt_t kuSimpleFineTimeMinValue = 31; - const UInt_t kuSimpleFineTimeMaxValue = 500; - - const UInt_t kuHighestReasonableFineTimeBin = 600; - - const UInt_t kuMinimumFineTimeRange = 400; - - const Long64_t kliFullCoarseSize = ((static_cast<Long64_t>(epoch_EpochBitMask)<<size_CoarseTimeCounter)|static_cast<Long64_t>(time_CoarseTimeBitMask))+1; - const Long64_t kliEpochSize = static_cast<Long64_t>(time_CoarseTimeBitMask)+1; - -} - -#endif diff --git a/beamtime/tof/tdc/v1290/TTofV1290Board.cxx b/beamtime/tof/tdc/v1290/TTofV1290Board.cxx deleted file mode 100644 index 8d1c8b69c3fce7bea45c73efd06983e3c419a92f..0000000000000000000000000000000000000000 --- a/beamtime/tof/tdc/v1290/TTofV1290Board.cxx +++ /dev/null @@ -1 +0,0 @@ - diff --git a/beamtime/tof/tdc/v1290/TTofV1290Board.h b/beamtime/tof/tdc/v1290/TTofV1290Board.h deleted file mode 100644 index 8d1c8b69c3fce7bea45c73efd06983e3c419a92f..0000000000000000000000000000000000000000 --- a/beamtime/tof/tdc/v1290/TTofV1290Board.h +++ /dev/null @@ -1 +0,0 @@ - diff --git a/beamtime/tof/tdc/v1290/TTofV1290Unpacker.cxx b/beamtime/tof/tdc/v1290/TTofV1290Unpacker.cxx deleted file mode 100644 index 1183ae295a8353a5e0cc90375f5e9c54b561589d..0000000000000000000000000000000000000000 --- a/beamtime/tof/tdc/v1290/TTofV1290Unpacker.cxx +++ /dev/null @@ -1,172 +0,0 @@ - -void TMbsCrateProc::Process1290(int num, int* pdata, unsigned int len) -{ - if (num >= MAX_1290) { - cout << "Wrong 1290 index " << num << endl; - return; - } - - int expected_geo = 0; - - if (num<0) { - // if number is not specified, try to identify it base on GEO value - expected_geo = T1290Data::FindGeo(pdata, len); - if (expected_geo<=0) { - printf("ERROR: Did not found GEO in the data\n"); - return; - } - - switch (expected_geo) { - case 5: num = 8; break; - case 6: num = 9; break; - case 7: num = 10; break; - case 8: num = 11; break; - case 9: num = 12; break; - case 10: num = 13; break; - case 11: num = 14; break; - default: - printf("Unsupported GEO code %d\n", expected_geo); - return; - } - - // printf("Found GEO code %d defined num %d\n", expected_geo, num); - - } else { - switch(num) { - case 0: expected_geo = 8; break; - case 1: expected_geo = 9; break; - case 2: expected_geo = 10; break; - case 3: expected_geo = 11; break; - case 4: expected_geo = 12; break; - case 5: expected_geo = 13; break; - case 6: expected_geo = 14; break; - case 7: expected_geo = 15; break; - } - } - // printf("Process1290 num = %d expected GEO = %d len = %u\n", num, expected_geo, len); - - fOutputEvent->fMtdc[num].Unpack(pdata, len, expected_geo); - - if( 1 == fPar->uCaenTdcHistosEnabled[num] ) - { - if( kTRUE == fPar->bCaenDebug || kTRUE == fPar->bCaenTriggerTime ) - fTDC[num].FillHistos(fOutputEvent->fMtdc[num], fPar->bCaenDebug, fPar->bCaenTriggerTime); - else - { - fTDC[num].FillHistos(fOutputEvent->fMtdc[num]); - if( CAEN1290_DEBUG ) - fTDC[num].FillDebugHistos(fOutputEvent->fMtdc[num]); - } - } - - fOutputEvent->SetValid(kTRUE); -} - -int T1290Data::FindGeo(int* pdata, unsigned len) -{ - for (unsigned iCha = 0; iCha < len; iCha++) { - Int_t data32 = pdata[iCha]; - Int_t type_word = (data32 >> 27) & 0x1f; //data type - if (type_word==8) return (data32 & 0x1f); - } - - return 0; -} - -void T1290Data::Unpack(int* pdata, unsigned len, int expected_geo) -{ - if (len<2) { - printf("Error unpack V1290 data - too few messages = %u\n", len); - } - - for (int n=0;n<NumChan;n++) { - hit_lead[n] = 0; - hit_trail[n] = 0; - } - - Int_t geo(0); - - for (unsigned iCha = 0; iCha < len; iCha++) { - Int_t data32 = pdata[iCha]; - Int_t type_word = (data32 >> 27) & 0x1f; //data type - -// printf("Msg:%2u Type:%d ", iCha, type_word); - - switch (type_word) { - case 8: { //global_header - // Int_t event_counter = (data32 & 0x07ffffff) >> 5; - geo = data32 & 0x1f; -// printf("Found GEO %d", geo); - - // SL: check that geo corresponds to expected number - if ((expected_geo>0) && (expected_geo!=geo)) - printf("GEO mismatch, expected %d, is %d\n", expected_geo, geo); - - break; - } - case 16: { //Global trailer - // Int_t word_count = (data32 & 0x001fffe0) >> 5; - - CalcWidth(); - - static int errcnt = 0; - - if (iCha+1!=len) { - if (errcnt++<3) - printf("Wrong V1290 data format - more messages after globar trailer\n"); - return; - } - - break; - } - case 1: { //TDC Header - // Int_t tdc = (data32 >> 24) & 0x03; - // Int_t event_id = (data32 & 0x00fff000) >> 12; - // Int_t bunch_id = data32 &0x00000fff; - break; - } - case 3: { //TDC Trailer - // Int_t tdc = (data32 & 0x03000000) >> 24; - // Int_t event_id = (data32 & 0x00fff000) >> 12; - // Int_t word_count = data32 &0x00000fff; - break; - } - case 4: { //TDC Error - printf("??TDC ERROR GEO = %d??\n", geo); - break; - } - case 0: { //TDC Data - Int_t TDC_input = (data32 >> 21) & 0x1f; - Int_t ch_data = data32 & 0x1fffff; - Int_t front = (data32 >> 26) & 0x1; - - if (front==0) { - if (hit_lead[TDC_input] == 0) { - lead[TDC_input] = ch_data; - } - if( hit_lead[ TDC_input] <MaxHits ) - lead_multi[TDC_input][ hit_lead[ TDC_input] ] = ch_data; - hit_lead[TDC_input] ++; - - } else { - if (hit_trail[TDC_input] == 0) { - trail[TDC_input] = ch_data; - } - if(hit_trail[ TDC_input] <MaxHits ) - trail_multi[TDC_input][hit_trail[ TDC_input] ] = ch_data; - hit_trail[TDC_input] ++; - } - break; - } - case 17: { //Global trigger Time tag - extended_trigger_time = data32 & 0x7ffffff; - break; - } - default: { - printf("GEO:%d Unknown tag %d\n", geo, type_word); - break; - } - } -// printf("\n"); - } -} diff --git a/beamtime/tof/tdc/v1290/TTofV1290Unpacker.h b/beamtime/tof/tdc/v1290/TTofV1290Unpacker.h deleted file mode 100644 index 8d1c8b69c3fce7bea45c73efd06983e3c419a92f..0000000000000000000000000000000000000000 --- a/beamtime/tof/tdc/v1290/TTofV1290Unpacker.h +++ /dev/null @@ -1 +0,0 @@ - diff --git a/beamtime/tof/tdc/v1290/TofCaenDef.h b/beamtime/tof/tdc/v1290/TofCaenDef.h deleted file mode 100644 index 67f94e820923925a428730f882a7342009b99a53..0000000000000000000000000000000000000000 --- a/beamtime/tof/tdc/v1290/TofCaenDef.h +++ /dev/null @@ -1,27 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TofCaenDef ----- -// ----- Created 22/05/2013 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ - -#ifndef TOFCAENDEF_H_ -#define TOFCAENDEF_H_ - -namespace caentdc -{ - const UInt_t kuNbChan = 32; - // Size of one clock cycle (=1 coarse bin) - const Double_t kdClockCycleSize = 25000.0; //[ps] - - // Finetime need to be inverted after calibration as it count from next clock cycle - const Bool_t kbInvertFt = kFALSE; - - const Int_t kiFineTime = 0x00000000; // Fine Counter value - const Int_t kiFtShift = 0; // Fine Counter offset - const Int_t kiCoarseTime = 0x00000000; // Coarse Counter value - const Int_t kiCtShift = 0; // Coarse Counter offset - - const Int_t kiCoarseCounterSize = ( (kiCoarseTime>>kiCtShift)+1 ); - const UInt_t kuCoarseOverflowTest = kiCoarseCounterSize / 2 ; // Limit for overflow check -} - -#endif // TOFCAENDEF_H_ diff --git a/beamtime/tof/tdc/vftx/TTofVftxBoard.cxx b/beamtime/tof/tdc/vftx/TTofVftxBoard.cxx deleted file mode 100644 index 7a827e1f3634cf0e93442270c23d1873f66ac51f..0000000000000000000000000000000000000000 --- a/beamtime/tof/tdc/vftx/TTofVftxBoard.cxx +++ /dev/null @@ -1,85 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TTofTdcBoard ----- -// ----- Created 12/05/2013 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ - -#include "TTofVftxBoard.h" - -// TOF headers -#include "TofTdcDef.h" -#include "TofVftxDef.h" -#include "TTofVftxData.h" - -// FAIR headers -#include "FairLogger.h" - -// ROOT headers -#include "TClonesArray.h" - -// C/C++ headers - -/************************** TTofTdcBoard ****************************/ -TTofVftxBoard::TTofVftxBoard(): - TTofTdcBoard( toftdc::vftx, vftxtdc::kuNbChan ), - fuTriggerType(0) -{ - CreateDataArray(); -} -TTofVftxBoard::~TTofVftxBoard() -{ -} - -void TTofVftxBoard::Clear( Option_t *option ) -{ - TTofTdcBoard::Clear( option ); - fuTriggerType = 0; -} - -// TClonesArray versions -Bool_t TTofVftxBoard::CreateDataArray() -{ - LOG(debug)<<" TTofVftxBoard::CreateDataArray "; - if( 0 < GetChannelNb() && NULL == fDataCollection ) - fDataCollection = new TClonesArray( "TTofVftxData", vftxtdc::kuNbMulti * GetChannelNb() ); - else return kFALSE; - - return kTRUE; -} -Bool_t TTofVftxBoard::ResizeArray() -{ - if( 0 < GetChannelNb() && NULL != fDataCollection ) - { - fDataCollection->Expand( vftxtdc::kuNbMulti*GetChannelNb() ); - return kTRUE; - } // if( 0 < GetChannelNb() && NULL != fDataCollection ) - else return kFALSE; -} -UInt_t TTofVftxBoard::AddData( TTofVftxData & dataIn ) -{ - if( NULL != fDataCollection ) - { - Int_t iNextIndex = fDataCollection->GetEntriesFast(); - if( iNextIndex < static_cast<Int_t>(vftxtdc::kuNbMulti * GetChannelNb()) ) - { - TTofVftxData * dataSlot = (TTofVftxData *)fDataCollection->ConstructedAt( iNextIndex ); - *dataSlot = dataIn; - } // if( iNextIndex < toftdc::kuDefNbMulti * GetChannelNb() ) - return fDataCollection->GetEntriesFast(); - } // if( NULL != fDataCollection ) - else return 0; -} -TTofVftxData * TTofVftxBoard::GetDataPtr( UInt_t uDataIndex ) -{ - if( NULL != fDataCollection ) - { - if( static_cast<Int_t>(uDataIndex) < fDataCollection->GetEntriesFast() ) - return (TTofVftxData *)fDataCollection->At( uDataIndex ); - else return NULL; - } // if( NULL != fDataCollection ) - else return NULL; -} -// ! no check on valid index in this one, Probably stupid method -const TTofVftxData & TTofVftxBoard::GetData( UInt_t uDataIndex ) const -{ - return *( (TTofVftxData *)fDataCollection->At( uDataIndex ) ); -} diff --git a/beamtime/tof/tdc/vftx/TTofVftxBoard.h b/beamtime/tof/tdc/vftx/TTofVftxBoard.h deleted file mode 100644 index 274ecb17a89b92aecc3e3bf8af70dcad39f55f1f..0000000000000000000000000000000000000000 --- a/beamtime/tof/tdc/vftx/TTofVftxBoard.h +++ /dev/null @@ -1,40 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TTofVftxBoard ----- -// ----- Created 12/05/2013 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ - -#ifndef TTOFVFTXBOARD_H_ -#define TTOFVFTXBOARD_H_ - -#include "TTofTdcBoard.h" - -class TTofVftxData; - -class TTofVftxBoard : public TTofTdcBoard -{ - public: - TTofVftxBoard(); - ~TTofVftxBoard(); - - virtual void Clear(Option_t *option = ""); - - void SetTriggerType( UInt_t uTriggerTypeIn){ fuTriggerType = uTriggerTypeIn; }; - UInt_t GetTriggerType(){ return fuTriggerType; }; - - // TClones array version - // All these functions have to be implemented in the derived classes - // With the proper Data objects - virtual Bool_t CreateDataArray(); - virtual Bool_t ResizeArray(); - UInt_t AddData( TTofVftxData & dataIn ); - TTofVftxData * GetDataPtr( UInt_t uDataIndex ); - // ! no check on valid index in this one, Probably stupid method - const TTofVftxData & GetData( UInt_t uDataIndex ) const; - - private: - UInt_t fuTriggerType; // Specific to VFTX TDCs, 1 = Normal Trigger, 2 = Sync trigger, still there? - - ClassDef(TTofVftxBoard, 1) -}; - -#endif // TTOFVFTXBOARD_H_ diff --git a/beamtime/tof/tdc/vftx/TTofVftxData.cxx b/beamtime/tof/tdc/vftx/TTofVftxData.cxx deleted file mode 100644 index 21c738796f6c4b026cc05b730af577a10bb4d8e2..0000000000000000000000000000000000000000 --- a/beamtime/tof/tdc/vftx/TTofVftxData.cxx +++ /dev/null @@ -1,164 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TTofVftxData ----- -// ----- Created 12/05/2013 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ - -#include "TTofVftxData.h" - -// Tof headers -#include "TofVftxDef.h" - -/************************** TTofTdcBoard ****************************/ -TTofVftxData::TTofVftxData() : - TTofTdcData(), - fbFutureBit(0) -{ -} -TTofVftxData::TTofVftxData( UInt_t uChan, UInt_t uFt, - UInt_t uCoarseT, UInt_t uTot, - UInt_t uFutBit ) : - TTofTdcData(uChan, uFt, uCoarseT, uTot), - fbFutureBit(uFutBit) -{ -} - -TTofVftxData::~TTofVftxData() -{ -} - -void TTofVftxData::Clear(Option_t *option) -{ - TTofTdcData::Clear(option); - fbFutureBit = 0; -} - -// Define < operator for vector sorting -Bool_t TTofVftxData::operator <( const TTofVftxData& rhs) const -{ - if( rhs.GetCoarseTime() < vftxtdc::kuCoarseOverflowTest && - this->GetCoarseTime() >= rhs.GetCoarseTime() + vftxtdc::kuCoarseOverflowTest ) - // Corse counter overflow between this hit and checked one - // hit ... Ovflw ... rhs - return kTRUE; - else if( this->GetCoarseTime() < vftxtdc::kuCoarseOverflowTest && - this->GetCoarseTime() + vftxtdc::kuCoarseOverflowTest <= rhs.GetCoarseTime() ) - // Corse counter overflow between checked hit and this one - // rhs ... Ovflw ... hit - return kFALSE; - else if( this->GetCoarseTime() < rhs.GetCoarseTime() ) - // CT hit ... rhs - return kTRUE; - else if( this->GetCoarseTime() > rhs.GetCoarseTime() ) - // CT rhs ... hit - return kFALSE; - else if( this->GetFineTime() > rhs.GetFineTime()) - // Comparator inverted as FineTime is counting - // Backward from next epoch!!!!! - // CT rhs = hit - // FT hit ... rhs - return kTRUE; - // CT rhs = hit - // FT rhs ... hit or rhs = hit - else return kFALSE; -} - -Bool_t TTofVftxData::operator <( const TTofTdcData& rhs) const -{ - if( rhs.GetCoarseTime() < vftxtdc::kuCoarseOverflowTest && - this->GetCoarseTime() >= rhs.GetCoarseTime() + vftxtdc::kuCoarseOverflowTest ) - // Corse counter overflow between this hit and checked one - // hit ... Ovflw ... rhs - return kTRUE; - else if( this->GetCoarseTime() < vftxtdc::kuCoarseOverflowTest && - this->GetCoarseTime() + vftxtdc::kuCoarseOverflowTest <= rhs.GetCoarseTime() ) - // Corse counter overflow between checked hit and this one - // rhs ... Ovflw ... hit - return kFALSE; - else if( this->GetCoarseTime() < rhs.GetCoarseTime() ) - // CT hit ... rhs - return kTRUE; - else if( this->GetCoarseTime() > rhs.GetCoarseTime() ) - // CT rhs ... hit - return kFALSE; - else if( this->GetFineTime() > rhs.GetFineTime()) - // Comparator inverted as FineTime is counting - // Backward from next epoch!!!!! - // CT rhs = hit - // FT hit ... rhs - return kTRUE; - // CT rhs = hit - // FT rhs ... hit or rhs = hit - else return kFALSE; -} -Int_t TTofVftxData::Compare( const TObject* obj) const -{ - return Compare( (TTofVftxData*) obj); -} -Int_t TTofVftxData::Compare( const TTofVftxData* obj) const -{ - if( obj->GetCoarseTime() < vftxtdc::kuCoarseOverflowTest && - this->GetCoarseTime() >= obj->GetCoarseTime() + vftxtdc::kuCoarseOverflowTest ) - // Corse counter overflow between this hit and checked one - // hit ... Ovflw ... rhs - return -1; - else if( this->GetCoarseTime() < vftxtdc::kuCoarseOverflowTest && - this->GetCoarseTime() + vftxtdc::kuCoarseOverflowTest <= obj->GetCoarseTime() ) - // Corse counter overflow between checked hit and this one - // rhs ... Ovflw ... hit - return 1; - else if( this->GetCoarseTime() < obj->GetCoarseTime() ) - // CT hit ... rhs - return -1; - else if( this->GetCoarseTime() > obj->GetCoarseTime() ) - // CT rhs ... hit - return 1; - else if( this->GetFineTime() > obj->GetFineTime()) - // Comparator inverted as FineTime is counting - // Backward from next epoch!!!!! - // CT rhs = hit - // FT hit ... rhs - return -1; - else if( this->GetFineTime() < obj->GetFineTime()) - // Comparator inverted as FineTime is counting - // Backward from next epoch!!!!! - // CT rhs = hit - // FT rhs ... hit - return 1; - // CT rhs = hit - // FT rhs = hit - else return 0; -} -Int_t TTofVftxData::Compare( const TTofTdcData* obj) const -{ - if( obj->GetCoarseTime() < vftxtdc::kuCoarseOverflowTest && - this->GetCoarseTime() >= obj->GetCoarseTime() + vftxtdc::kuCoarseOverflowTest ) - // Corse counter overflow between this hit and checked one - // hit ... Ovflw ... rhs - return -1; - else if( this->GetCoarseTime() < vftxtdc::kuCoarseOverflowTest && - this->GetCoarseTime() + vftxtdc::kuCoarseOverflowTest <= obj->GetCoarseTime() ) - // Corse counter overflow between checked hit and this one - // rhs ... Ovflw ... hit - return 1; - else if( this->GetCoarseTime() < obj->GetCoarseTime() ) - // CT hit ... rhs - return -1; - else if( this->GetCoarseTime() > obj->GetCoarseTime() ) - // CT rhs ... hit - return 1; - else if( this->GetFineTime() > obj->GetFineTime()) - // Comparator inverted as FineTime is counting - // Backward from next epoch!!!!! - // CT rhs = hit - // FT hit ... rhs - return -1; - else if( this->GetFineTime() < obj->GetFineTime()) - // Comparator inverted as FineTime is counting - // Backward from next epoch!!!!! - // CT rhs = hit - // FT rhs ... hit - return 1; - // CT rhs = hit - // FT rhs = hit - else return 0; -} diff --git a/beamtime/tof/tdc/vftx/TTofVftxData.h b/beamtime/tof/tdc/vftx/TTofVftxData.h deleted file mode 100644 index d8c0e98e22be74b82b18ef54228474ad4184e8dd..0000000000000000000000000000000000000000 --- a/beamtime/tof/tdc/vftx/TTofVftxData.h +++ /dev/null @@ -1,45 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TTofVftxBoard ----- -// ----- Created 12/05/2013 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ - -#ifndef TTOFVFTXDATA_H_ -#define TTOFVFTXDATA_H_ - -#include "TTofTdcData.h" - -class TTofVftxData : public TTofTdcData -{ - public: - TTofVftxData(); - TTofVftxData( UInt_t uChan, UInt_t uFt, - UInt_t uCoarseT, UInt_t uTot = 0, - UInt_t uFutBit = 0); - ~TTofVftxData(); - - virtual void Clear(Option_t *option = ""); - - // copy constructor, used by vector to copy content - TTofVftxData(const TTofVftxData& src) : - TTofTdcData(src), - fbFutureBit(src.fbFutureBit) {}; - // Comparison operator, needed for time sorting - // To be implemeted for each TDC type as need coarse counter size - virtual Bool_t operator <( const TTofVftxData& rhs) const; - virtual Bool_t operator <( const TTofTdcData& rhs) const; - - virtual Int_t Compare( const TObject* obj) const; - virtual Int_t Compare( const TTofVftxData* obj) const; - virtual Int_t Compare( const TTofTdcData* obj) const; - virtual Bool_t IsSortable() const { return kTRUE; }; - - void SetFutureBit( UInt_t uFutBit){ fbFutureBit = (1 == uFutBit) ? kTRUE: kFALSE; }; - Bool_t GetFutureBit( ){ return fbFutureBit; }; - - private: - Bool_t fbFutureBit; - - ClassDef(TTofVftxData, 1) -}; - -#endif // TTOFVFTXDATA_H_ diff --git a/beamtime/tof/tdc/vftx/TTofVftxUnpacker.cxx b/beamtime/tof/tdc/vftx/TTofVftxUnpacker.cxx deleted file mode 100644 index 7bd5f5f1ff8f36c6ac26dc3af3ae626969fe5fd0..0000000000000000000000000000000000000000 --- a/beamtime/tof/tdc/vftx/TTofVftxUnpacker.cxx +++ /dev/null @@ -1,288 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TTofVftxUnpacker ----- -// ----- Created 14/05/2013 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ - -#include "TTofVftxUnpacker.h" - -// TOF headers -#include "TofDef.h" -#include "TMbsUnpackTofPar.h" -#include "TofTdcDef.h" -#include "TofVftxDef.h" -#include "TTofVftxData.h" -#include "TTofVftxBoard.h" - -// FAIR headers -#include "FairRootManager.h" -#include "FairLogger.h" -#include "TString.h" - -// ROOT headers -#include "TClonesArray.h" -#include "TH1.h" -#include "TROOT.h" -#include "TDirectory.h" - -TTofVftxUnpacker::TTofVftxUnpacker(): - fParUnpack(0), - fuNbTdc(0), - fVftxBoardCollection(NULL), - fiLastFpgaTdcCoarse(), - fh1VftxRawChMap(), - fh1VftxChFt() -{ -} -TTofVftxUnpacker::TTofVftxUnpacker( TMbsUnpackTofPar * parIn ): - fParUnpack( parIn ), - fuNbTdc( parIn->GetNbActiveBoards( tofMbs::vftx ) ), - fVftxBoardCollection(NULL), - fiLastFpgaTdcCoarse(), - fh1VftxRawChMap(), - fh1VftxChFt() -{ - // Recover first the VFTX board objects created in general unpacker class - FairRootManager* rootMgr = FairRootManager::Instance(); - - fVftxBoardCollection = (TClonesArray*) rootMgr->GetObject("TofVftxTdc"); - if(NULL == fVftxBoardCollection) - { - LOG(warn)<<"TTofVftxUnpacker::TTofVftxUnpacker : no TOF VFTX TDC array! "; - fuNbTdc = 0; - } - - if( 0 < fuNbTdc ) - fiLastFpgaTdcCoarse.resize( fuNbTdc * vftxtdc::kuNbChan, 0); -} -TTofVftxUnpacker::~TTofVftxUnpacker() -{ - // not sure if it will not make problems for seeing them -// DeleteHistos(); -} - -void TTofVftxUnpacker::Clear(Option_t */*option*/) -{ - fParUnpack = NULL; - fuNbTdc = 0; - fVftxBoardCollection = NULL; - fiLastFpgaTdcCoarse.clear(); -} - -void TTofVftxUnpacker::ProcessVFTX( Int_t iTdcIndex, UInt_t* pMbsData, UInt_t uLength ) -{ -// if( (iTdcIndex<0) || (fuNbTdc <= iTdcIndex) || -// (fVftxBoardCollection->GetEntriesFast() <= iTdcIndex )) - if( (iTdcIndex<0) || (fuNbTdc <= static_cast<UInt_t>(iTdcIndex)) ) - { - LOG(error)<<"Error VFTX number "<<iTdcIndex<<" out of bound (max "<<fuNbTdc<<") "; - return; - } - - TTofVftxBoard * fVftxBoard = (TTofVftxBoard*) fVftxBoardCollection->ConstructedAt(iTdcIndex); - - for(UInt_t ch=0; ch < vftxtdc::kuNbChan; ch++) - fiLastFpgaTdcCoarse[iTdcIndex*vftxtdc::kuNbChan + ch] = -1; - - UInt_t l_dat = *pMbsData++; // module header - if ( (l_dat & vftxtdc::kiHeaderKeyMask)>>vftxtdc::kiHeaderKeyShift != static_cast<UInt_t>(vftxtdc::kiHeaderKeyword) ) - { - LOG(warn)<<"This is not a vftx #"<< fParUnpack->GetActiveToAllTypeInd(iTdcIndex, tofMbs::vftx) - <<" header, jumping this sub-event..."; - return; - } // if ( (l_dat & vftxtdc::kiHeaderKeyMask)>>vftxtdc::kiHeaderKeyShift != vftxtdc::kiHeaderKeyword ) - - UInt_t uMbsNbData = (l_dat & vftxtdc::kiHeaderNbMask); - if (uMbsNbData+2 != uLength && uMbsNbData+2 + 256 != uLength) - { - LOG(warn)<<"Wrong length in vftx #"<<fParUnpack->GetActiveToAllTypeInd(iTdcIndex, tofMbs::vftx) - <<" header, jumping this sub-event... "<<uMbsNbData+2<<" vs "<<uLength; - // Return commented: MBS vftxlib.c for gsi aug 12 not compatible with too many data in event: - // only 8 bit where used to code event size => effective limitation to 256 hits then loop - //return; - } // if (uMbsNbData+2 != uLength && uMbsNbData+2 + 256 != uLength) - -/* UInt_t uModIndex = ((l_dat & vftxtdc::kiHeaderModMask) >> vftxtdc::kiHeaderModShift); */ -/* - // Not true when first VFTX are disabled!!! - if( uModIndex != fParUnpack->GetActiveToAllTypeInd(iTdcIndex, tofMbs::vftx) ) - LOG(warn)<<"Wrong VFTX index in header of vftx #"<<fParUnpack->GetActiveToAllTypeInd(iTdcIndex, tofMbs::vftx) - <<": "<<uModIndex; -*/ - - l_dat = *pMbsData++; // vulom tdc fifo header - UInt_t uFifoNbData = 0; - if( l_dat & vftxtdc::kuFifoMessageType ) - { - // Found proper TDC FIFO header => unpack it - fVftxBoard->SetTriggerType( (l_dat & vftxtdc::kiFifoHeadTrigType) >> vftxtdc::kiFifoHeadTrigTypeShift ); - fVftxBoard->SetTriggerTime( (l_dat & vftxtdc::kiFifoHeadTrigTime) >> vftxtdc::kiFifoHeadTrigTimeShift ); - uFifoNbData = (l_dat & vftxtdc::kiFifoHeadDataCnt) >> vftxtdc::kiFifoHeadDataCntShift; - } // if( l_dat & vftxtdc::kuFifoMessageType ) - else LOG(warn)<<"Vftx #"<<fParUnpack->GetActiveToAllTypeInd(iTdcIndex, tofMbs::vftx)<<" fifo header missing... "; - - if (uMbsNbData != uFifoNbData) - { - // uMbsNbData is always 0xAA in current versions of VFTX!!! -/* - LOG(warn)<<"Wrong length in vftx #"<<fParUnpack->GetActiveToAllTypeInd(iTdcIndex, tofMbs::vftx) - <<" FIFO header compared to its MBS header, jumping this sub-event... " - <<uFifoNbData<<" vs "<<uMbsNbData; - return; -*/ - } // if (uMbsNbData-2 != uFifoNbData) - - while (uMbsNbData-- > 0) - { - UInt_t l_da0 = *pMbsData++; - - TTofVftxData hit; - if ((l_da0 & vftxtdc::kuFifoMessageType) == vftxtdc::kuFifoMessageType) - { - TString sTemp = Form("Wrong data item in vftx #%d: type %d (message %08x, header %08x), jumping this sub-event...", - fParUnpack->GetActiveToAllTypeInd(iTdcIndex, tofMbs::vftx), - (l_da0 & vftxtdc::kuFifoMessageType) >> vftxtdc::kiFifoMessageTypeShift, l_da0, l_dat); - LOG(warn)<<sTemp; - sTemp = Form("Message: tt %01u ct %5u nd %3u", - (l_da0 & vftxtdc::kiFifoHeadTrigType) >> vftxtdc::kiFifoHeadTrigTypeShift, - (l_da0 & vftxtdc::kiFifoHeadTrigTime) >> vftxtdc::kiFifoHeadTrigTimeShift, - (l_da0 & vftxtdc::kiFifoHeadDataCnt) >> vftxtdc::kiFifoHeadDataCntShift ); - LOG(warn)<<sTemp; - sTemp = Form("Header : tt %01u ct %5u nd %3u", - (l_dat & vftxtdc::kiFifoHeadTrigType) >> vftxtdc::kiFifoHeadTrigTypeShift, - (l_dat & vftxtdc::kiFifoHeadTrigTime) >> vftxtdc::kiFifoHeadTrigTimeShift, - (l_dat & vftxtdc::kiFifoHeadDataCnt) >> vftxtdc::kiFifoHeadDataCntShift ); - LOG(warn)<<sTemp; - return; - } // if ((l_da0 & vftxtdc::kuFifoMessageType) == vftxtdc::kuFifoMessageType) - - hit.SetChannel( (l_da0 & vftxtdc::kiChannel) >> vftxtdc::kiChannelShift ); //4-5 bit - if ( hit.GetChannel() > vftxtdc::kuNbChan - 1) - LOG(warn)<<"Channel number larger than "<<vftxtdc::kuNbChan -1 - <<" found in vftx #"<<fParUnpack->GetActiveToAllTypeInd(iTdcIndex, tofMbs::vftx); - - hit.SetFutureBit( (l_da0 & vftxtdc::kiFifoFutureBit) >> vftxtdc::kiFiFoFutBitShift ); // 1 bit - hit.SetCoarseTime( (l_da0 & vftxtdc::kiFifoCoarseTime) >> vftxtdc::kiFifoCtShift ); // 13-15 bits - hit.SetFineTime( (l_da0 & vftxtdc::kiFifoFineTime) >> vftxtdc::kiFifoFtShift ); // 10-11 bits - - if( kTRUE == fParUnpack->IsDebug() ) - { - if( static_cast<Int_t>( hit.GetCoarseTime() ) - fiLastFpgaTdcCoarse[iTdcIndex*vftxtdc::kuNbChan + hit.GetChannel()] < 6 && - -6 < static_cast<Int_t>( hit.GetCoarseTime() ) - fiLastFpgaTdcCoarse[iTdcIndex*vftxtdc::kuNbChan + hit.GetChannel()] && - -1 < fiLastFpgaTdcCoarse[iTdcIndex*vftxtdc::kuNbChan + hit.GetChannel()] ) - { - TString sTemp = Form("Too close hits in vftx #%d channel %d: old coarse %d new coarse %d diff %d ft %3x", - fParUnpack->GetActiveToAllTypeInd(iTdcIndex, tofMbs::vftx), hit.GetChannel(), - fiLastFpgaTdcCoarse[iTdcIndex*vftxtdc::kuNbChan + hit.GetChannel()], hit.GetCoarseTime(), - (Int_t)hit.GetCoarseTime() - fiLastFpgaTdcCoarse[iTdcIndex*vftxtdc::kuNbChan + hit.GetChannel()], - hit.GetFineTime()); - LOG(warn)<<sTemp; - } // if hits on same channel closer than channel dead time - - fiLastFpgaTdcCoarse[iTdcIndex*vftxtdc::kuNbChan + hit.GetChannel()] = hit.GetCoarseTime(); - } // if( kTRUE == fParUnpack->IsDebug() ) - - fVftxBoard->AddData( hit ); - - } // while (uMbsNbData-- > 0) - - // Attempt at sorting hits according to their times - fVftxBoard->SortData(); - - LOG(debug2)<<" VFTX TDC #"<<fParUnpack->GetActiveToAllTypeInd(iTdcIndex, tofMbs::vftx)<<" finished"; - return; -} - -// Histogram management -// TODO: maybe add some options to control which histograms are -// created and filed (memory management) -void TTofVftxUnpacker::CreateHistos() -{ - LOG(debug)<<" TTofVftxUnpacker::CreateHistos Nb boards: "<<fuNbTdc<<" Directory "; - - TDirectory * oldir = gDirectory; // <= To prevent histos from being sucked in by the param file of the TRootManager! - gROOT->cd(); // <= To prevent histos from being sucked in by the param file of the TRootManager ! - - TH1* hTemp = 0; - - // 2D vector of histograms - fh1VftxChFt.resize( fuNbTdc ); - for( UInt_t uBoardIndex = 0; uBoardIndex < fuNbTdc; uBoardIndex++) - { - // Board specific histograms - hTemp = new TH1I( Form("tof_%s_ch_%03u", toftdc::ksTdcHistName[ toftdc::vftx ].Data(), uBoardIndex), - Form("Counts per TDC channel for vftx #%03u", uBoardIndex), - vftxtdc::kuNbChan, 0.0, vftxtdc::kuNbChan ); - fh1VftxRawChMap.push_back( hTemp ); - - for( UInt_t uChannelIndex = 0; uChannelIndex < vftxtdc::kuNbChan; uChannelIndex++) - { - // Channel specific histograms - hTemp = new TH1I( Form("tof_%s_ft_b%03u_ch%03u", - toftdc::ksTdcHistName[ toftdc::vftx ].Data(), - uBoardIndex, uChannelIndex), - Form("Counts per Finetime bin for TDC channel %3u on vftx #%03u", - uChannelIndex, uBoardIndex), - vftxtdc::kiFifoFineTime + 1, -0.5, vftxtdc::kiFifoFineTime + 1 - 0.5 ); - (fh1VftxChFt[uBoardIndex]).push_back( hTemp ); - - LOG(debug)<<" TTofVftxUnpacker::CreateHistos => Create FT histo for " - <<toftdc::ksTdcHistName[ toftdc::vftx ]<<" #" - <<uBoardIndex<<" ch "<<uChannelIndex<<" from the unpack step: 0x" - <<fh1VftxChFt[uBoardIndex][uChannelIndex]<<" " - <<fh1VftxChFt[uBoardIndex][uChannelIndex]->GetEntries(); - } // for( UInt_t uChannelIndex = 0; uChannelIndex < vftxtdc::kuNbChan; uChannelIndex++) - - } // for( UInt_t uBoardIndex = 0; uBoardIndex < fuNbTdc; uBoardIndex++) - - gDirectory->cd( oldir->GetPath() ); // <= To prevent histos from being sucked in by the param file of the TRootManager! -} -void TTofVftxUnpacker::FillHistos() -{ - // loop over TDC boards - TTofVftxBoard * fVftxBoard; - for( UInt_t uBoardIndex = 0; uBoardIndex < fuNbTdc; uBoardIndex++) - { - fVftxBoard = (TTofVftxBoard*) fVftxBoardCollection->ConstructedAt(uBoardIndex); - // Loop over hits data - for( UInt_t uDataIndex = 0; uDataIndex < fVftxBoard->GetDataNb() ; uDataIndex++ ) - { - TTofVftxData data = fVftxBoard->GetData( uDataIndex); - TString sTemp = Form( " TTofVftxUnpacker::FillHistos: Board #%03u Data #%04u Chan %3d CT %7d FT %7d", - uBoardIndex, uDataIndex, data.GetChannel(), - data.GetCoarseTime(), data.GetFineTime() ); - LOG(debug)<<sTemp; - - fh1VftxRawChMap[uBoardIndex]->Fill( data.GetChannel() ); - fh1VftxChFt[uBoardIndex][ data.GetChannel() ]->Fill( data.GetFineTime() ); - - } // for( UInt_t uDataIndex = 0; uDataIndex < fVftxBoard[uBoardIndex]->GetDataNb() ; uDataIndex++ ) - } // for( UInt_t uBoardIndex = 0; uBoardIndex < fuNbTdc; uBoardIndex++) -} -void TTofVftxUnpacker::WriteHistos( TDirectory* inDir) -{ - TDirectory * oldir = gDirectory; - TDirectory *cdVftxUnp[fuNbTdc]; - - for( UInt_t uBoardIndex = 0; uBoardIndex < fuNbTdc; uBoardIndex++) - { - cdVftxUnp[uBoardIndex] = inDir->mkdir( Form( "Unp_%s_%03u", toftdc::ksTdcHistName[ toftdc::vftx ].Data(), uBoardIndex) ); - cdVftxUnp[uBoardIndex]->cd(); // make the "Unp_triglog" directory the current directory - - fh1VftxRawChMap[uBoardIndex]->Write(); - - for( UInt_t uChannelIndex = 0; uChannelIndex < vftxtdc::kuNbChan; uChannelIndex++) - { - fh1VftxChFt[uBoardIndex][uChannelIndex]->Write(); - } // for( UInt_t uChannelIndex = 0; uChannelIndex < vftxtdc::kuNbChan; uChannelIndex++) - - } // for( UInt_t uBoardIndex = 0; uBoardIndex < fuNbTdc; uBoardIndex++) - - oldir->cd(); -} -void TTofVftxUnpacker::DeleteHistos() -{ - fh1VftxRawChMap.clear(); - for( UInt_t uBoardIndex = 0; uBoardIndex < fuNbTdc; uBoardIndex++) - (fh1VftxChFt[uBoardIndex]).clear(); - fh1VftxChFt.clear(); -} diff --git a/beamtime/tof/tdc/vftx/TTofVftxUnpacker.h b/beamtime/tof/tdc/vftx/TTofVftxUnpacker.h deleted file mode 100644 index f5b0204553f288572b7d1494a83f8460817d84c8..0000000000000000000000000000000000000000 --- a/beamtime/tof/tdc/vftx/TTofVftxUnpacker.h +++ /dev/null @@ -1,53 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TTofVftxUnpacker ----- -// ----- Created 14/05/2013 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ - -#ifndef TTOFVFTXUNPACKER_H_ -#define TTOFVFTXUNPACKER_H_ - -#include "TObject.h" - -#include <vector> - -class TMbsUnpackTofPar; - -class TClonesArray; -class TH1; -class TH2; -class TDirectory; - -class TTofVftxUnpacker : public TObject -{ - public: - TTofVftxUnpacker(); - TTofVftxUnpacker( TMbsUnpackTofPar * parIn ); - ~TTofVftxUnpacker(); - - virtual void Clear(Option_t *option); - - void ProcessVFTX( Int_t num, UInt_t* pMbsData, UInt_t uLength ); - - void CreateHistos(); - void FillHistos(); - void WriteHistos( TDirectory* inDir); - void DeleteHistos(); - - private: - // no default Copy constructor and = OP as class not meant to be copied - TTofVftxUnpacker(const TTofVftxUnpacker&); - TTofVftxUnpacker& operator=(const TTofVftxUnpacker&); - - TMbsUnpackTofPar * fParUnpack; - UInt_t fuNbTdc; - TClonesArray * fVftxBoardCollection; - std::vector<Int_t> fiLastFpgaTdcCoarse; - - // Histograms - std::vector<TH1 *> fh1VftxRawChMap; - std::vector< std::vector<TH1 *> > fh1VftxChFt; - - ClassDef(TTofVftxUnpacker, 1) -}; - -#endif // TTOFTDCUNPACKER_H_ diff --git a/beamtime/tof/tdc/vftx/TofVftxDef.h b/beamtime/tof/tdc/vftx/TofVftxDef.h deleted file mode 100644 index da4837090525b8560ca7a5629fe486f086e83f2d..0000000000000000000000000000000000000000 --- a/beamtime/tof/tdc/vftx/TofVftxDef.h +++ /dev/null @@ -1,119 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TofVftxDef ----- -// ----- Created 12/05/2013 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ - -#ifndef TOFVFTXDEF_H_ -#define TOFVFTXDEF_H_ - -//#define OLD_VERSION_VULOM // <- Pre-COSY nov11 HD vulom FPGA code -//#define VERSION_VFTX // <- June 2012 version based on VFTX board (32 chan, 16 true chan+tot) -#define VERSION_VFTX_28 // <- August 2012 version based on VFTX board (56 chan, 28 true chan+tot) - -/******************** FPGA TDC data unpacking definitions *************/ -namespace vftxtdc -{ - // Maximal number of hits per channel per event stored - const UInt_t kuNbMulti = 8; - // number of channels in FPGA TDC modules -#ifdef VERSION_VFTX - const UInt_t kuNbChan = 32; -#elif defined VERSION_VFTX_28 - const UInt_t kuNbChan = 56; -#else - const UInt_t kuNbChan = 8; -#endif - - // Size of one clock cycle (=1 coarse bin) - const Double_t kdClockCycleSize = 5000.0; //[ps] - - // Finetime need to be inverted after calibration as it count from next clock cycle - const Bool_t kbInvertFt = kTRUE; - - // Header data word (inserted by MBS program) - const Int_t kiHeaderKeyMask = 0xFFFF0000; - const Int_t kiHeaderKeyShift = 16; - const Int_t kiHeaderKeyword = 0xABCD; - const Int_t kiHeaderModMask = 0x0000FF00; - const Int_t kiHeaderModShift = 8; - const Int_t kiHeaderNbMask = 0x000000FF; - - const UInt_t kuFifoMessageType = 0x80000000; // Message Type: 1 = header, 0 = data - const Int_t kiFifoMessageTypeShift = 31; - - // FIFO header data word (TDC generated, not modified by MBS) -#ifdef OLD_VERSION_VULOM - const Int_t kiFifoHeadDataCnt = 0x000000FF; // Data count - const Int_t kiFifoHeadDataCntShift = 0; - const Int_t kiFifoHeadTrigTime = 0x01FFFC00; // Coarse counter value - const Int_t kiFifoHeadTrigTimeShift = 10; - const Int_t kiFifoHeadTrigType = 0x60000000; // Trigger Type - const Int_t kiFifoHeadTrigTypeShift = 29; -#elif defined VERSION_VFTX - const Int_t kiFifoHeadDataCnt = 0x000000FF; // Data count - const Int_t kiFifoHeadDataCntShift = 0; - const Int_t kiFifoHeadTrigTime = 0x01FFF800; // Coarse counter value - const Int_t kiFifoHeadTrigTimeShift = 11; - const Int_t kiFifoHeadTrigType = 0x60000000; // Trigger Type - const Int_t kiFifoHeadTrigTypeShift = 29; -#elif defined VERSION_VFTX_28 - const Int_t kiFifoHeadDataCnt = 0x000000FF; // Data count - const Int_t kiFifoHeadDataCntShift = 0; - const Int_t kiFifoHeadTrigTime = 0x00FFF800; // Coarse counter value - const Int_t kiFifoHeadTrigTimeShift = 11; - const Int_t kiFifoHeadTrigType = 0x60000000; // Trigger Type - const Int_t kiFifoHeadTrigTypeShift = 29; -#else - const Int_t kiFifoHeadDataCnt = 0x000000FF; // Data count - const Int_t kiFifoHeadDataCntShift = 0; - const Int_t kiFifoHeadTrigTime = 0x03FFF800; // Coarse counter value - const Int_t kiFifoHeadTrigTimeShift = 11; - const Int_t kiFifoHeadTrigType = 0x60000000; // Trigger Type - const Int_t kiFifoHeadTrigTypeShift = 29; -#endif - - // FIFO data word (TDC generated, not modified by MBS) -#ifdef OLD_VERSION_VULOM - const Int_t kiFifoFineTime = 0x000003FF; // Fine Counter value - const Int_t kiFifoFtShift = 0; - const Int_t kiFifoCoarseTime = 0x01FFFC00; // Coarse counter value - const Int_t kiFifoCtShift = 10; - const Int_t kiFifoFutureBit = 0x02000000; // Flag for hits after trigger - const Int_t kiFiFoFutBitShift = 25; - const Int_t kiChannel = 0x7C000000; // Data channel - const Int_t kiChannelShift = 26; -#elif defined VERSION_VFTX - const Int_t kiFifoFineTime = 0x000007FF; // Fine Counter value - const Int_t kiFifoFtShift = 0; - const Int_t kiFifoCoarseTime = 0x01FFF800; // Coarse counter value - const Int_t kiFifoCtShift = 11; - const Int_t kiFifoFutureBit = 0x02000000; // Flag for hits after trigger - const Int_t kiFiFoFutBitShift = 25; - const Int_t kiChannel = 0x7C000000; // Data channel - const Int_t kiChannelShift = 26; -#elif defined VERSION_VFTX_28 - const Int_t kiFifoFineTime = 0x000007FF; // Fine Counter value - const Int_t kiFifoFtShift = 0; - const Int_t kiFifoCoarseTime = 0x00FFF800; // Coarse counter value - const Int_t kiFifoCtShift = 11; - const Int_t kiFifoFutureBit = 0x01000000; // Flag for hits after trigger - const Int_t kiFiFoFutBitShift = 24; - const Int_t kiChannel = 0x7E000000; // Data channel - const Int_t kiChannelShift = 25; -#else - const Int_t kiFifoFineTime = 0x000007FF; // Fine Counter value - const Int_t kiFifoFtShift = 0; - const Int_t kiFifoCoarseTime = 0x03FFF800; // Coarse counter value - const Int_t kiFifoCtShift = 11; - const Int_t kiFifoFutureBit = 0x04000000; // Flag for hits after trigger - const Int_t kiFiFoFutBitShift = 26; - const Int_t kiChannel = 0x78000000; // Data channel - const Int_t kiChannelShift = 27; -#endif - - const Int_t kiCoarseCounterSize = ( (kiFifoCoarseTime>>kiFifoCtShift)+1 ); - const UInt_t kuCoarseOverflowTest = kiCoarseCounterSize / 2 ; // Limit for overflow check -} -/**************** End FPGA TDC data unpacking definitions *************/ - -#endif // TOFVFTXDEF_H_ diff --git a/beamtime/tof/unpMoni/TMbsUnpTofMonitor.cxx b/beamtime/tof/unpMoni/TMbsUnpTofMonitor.cxx deleted file mode 100644 index 310fd5887854be061d11caf5825e91d82b7a20de..0000000000000000000000000000000000000000 --- a/beamtime/tof/unpMoni/TMbsUnpTofMonitor.cxx +++ /dev/null @@ -1,298 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TMbsUnpTofMonitor ----- -// ----- Created 16/07/2013 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ - -#include "TMbsUnpTofMonitor.h" - -// General MBS headers -#include "TofDef.h" -#include "TMbsUnpackTofPar.h" -#include "TMbsCalibTofPar.h" - -// ToF specific headers -#include "TTofTriglogUnpacker.h" -#include "TTofScomUnpacker.h" -#include "TTofScal2014Unpacker.h" -#include "TTofTriglogScalUnpacker.h" -#include "TTofVftxUnpacker.h" -#include "TTofTrbTdcUnpacker.h" - -// ROOT headers -#include "TClonesArray.h" -#include "TFile.h" -//#include "TTimeStamp.h" - -// FAIR headers -#include "FairLogger.h" -#include "FairRun.h" -#include "FairRuntimeDb.h" - -TMbsUnpTofMonitor::TMbsUnpTofMonitor() : - FairTask("MbsUnpackTofCustom"), - fMbsUnpackPar(NULL), - fMbsCalibPar(NULL), - fTriglogUnp(NULL), - fScomUnp(NULL), - fScal2014Unp(NULL), - fTrloScalUnp(NULL), - fVftxUnp(NULL), - fTrbTdcUnp(NULL), - fTriglogBoardCollection(NULL), - fScalerBoardCollection(NULL), - fVftxBoardCollection(NULL), - fTrbTdcBoardCollection(NULL), - fiNbEvents(0), - fiFirstEventNumber(0), - fiLastEventNumber(0), - fFirstCheck(), - fLastCheck(), - fCheck(), - fdScalersEvoRangeUser(-1), - fdScalersEvoBinSzUser(-1) -{ -} - -TMbsUnpTofMonitor::TMbsUnpTofMonitor(const char* name, Int_t verbose) : - FairTask(name, verbose), - fMbsUnpackPar(0), - fMbsCalibPar(0), - fTriglogUnp(NULL), - fScomUnp(NULL), - fScal2014Unp(NULL), - fTrloScalUnp(NULL), - fVftxUnp(NULL), - fTrbTdcUnp(NULL), - fTriglogBoardCollection(NULL), - fScalerBoardCollection(NULL), - fVftxBoardCollection(NULL), - fTrbTdcBoardCollection(NULL), - fiNbEvents(0), - fiFirstEventNumber(0), - fiLastEventNumber(0), - fFirstCheck(), - fLastCheck(), - fCheck(), - fdScalersEvoRangeUser(-1), - fdScalersEvoBinSzUser(-1) -{ -} - -TMbsUnpTofMonitor::~TMbsUnpTofMonitor() -{ - LOG(info)<<"**** TMbsUnpTofMonitor: Delete instance "; - - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::triglog ) ) - delete fTriglogUnp; - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::scalormu ) ) - delete fScomUnp; - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::scaler2014 ) ) - delete fScal2014Unp; - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::triglogscal ) ) - delete fTrloScalUnp; - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::vftx ) ) - delete fVftxUnp; - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::trbtdc ) ) - delete fTrbTdcUnp; -} - -// -------------------------------------------------- -// Fairtask specific functions -void TMbsUnpTofMonitor::SetParContainers() -{ - InitParameters(); -} -InitStatus TMbsUnpTofMonitor::ReInit() -{ - LOG(info)<<"**** TMbsUnpTofMonitor: Reinitialize the unpack parameters for tof "; - if( kFALSE == InitParameters() ) - return kFATAL; - - return kSUCCESS; -} - -InitStatus TMbsUnpTofMonitor::Init() -{ - if( kFALSE == InitParameters() ) - return kFATAL; - - // Create the proper Unpackers and number of output objects for each boards type - if( kFALSE == CreateUnpackers() ) - return kFATAL; - if( kFALSE == CreateHistogramms() ) - return kFATAL; - - fLastCheck.Set(); - fFirstCheck.Set(); - - return kSUCCESS; -} -void TMbsUnpTofMonitor::Exec(Option_t* /*option*/) -{ - // No output => no clear needed - - if( 0 < fiNbEvents && 0 == fiNbEvents%10000 ) - { - fCheck.Set(); - TString sFormat = Form("Event: %8d is MBS event %8d dt %6.3fs Since start %5lds", -// fiNbEvents, fiLastEventNumber, fCheck.Get() - fLastCheck.Get(), -// fCheck.Get() - fFirstCheck.Get()); - fiNbEvents, fiLastEventNumber, - (Double_t)(fCheck.GetSec() - fLastCheck.GetSec()) - + ( (Double_t)fCheck.GetNanoSec() - (Double_t)fLastCheck.GetNanoSec())/1e9, - fCheck.GetSec() - fFirstCheck.GetSec()); - LOG(info)<<sFormat; - fLastCheck.Set(); - } - - FillHistograms(); - - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::triglog ) ) - fTriglogUnp->UpdateStats(); - - fiNbEvents++; -} -void TMbsUnpTofMonitor::Finish() -{ - fCheck.Set(); - LOG(info)<<"Last Event: "<<fiNbEvents<<" with MBS event nb "<<fiLastEventNumber - << Form(" After %9.3fs", (Double_t)(fCheck.GetSec() - fFirstCheck.GetSec()) - + ( (Double_t)fCheck.GetNanoSec() - (Double_t)fFirstCheck.GetNanoSec())/1e9); - WriteHistogramms(); - - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::triglog ) ) - fTriglogUnp->FinishTriglog(); -} -// ------------------------------------------------------------------ -Bool_t TMbsUnpTofMonitor::InitParameters() -{ - // Get Base Container - FairRun* ana = FairRun::Instance(); - if( 0 == ana ) - return kFALSE; - FairRuntimeDb* rtdb=ana->GetRuntimeDb(); - if( 0 == rtdb ) - return kFALSE; - - // Unpacker parameter - fMbsUnpackPar = (TMbsUnpackTofPar*) (rtdb->getContainer("TMbsUnpackTofPar")); - if( 0 == fMbsUnpackPar ) - return kFALSE; - - // Call needed here to make available calibration parameters - // in the TRB unpack stage - fMbsCalibPar = (TMbsCalibTofPar*) (rtdb->getContainer("TMbsCalibTofPar")); - if( 0 == fMbsCalibPar ) - return kFALSE; - - return kTRUE; -} -// ------------------------------------------------------------------ -Bool_t TMbsUnpTofMonitor::CreateHistogramms() -{ - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::triglog ) ) - fTriglogUnp->CreateHistos(); - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::scalormu ) ) - fScomUnp->CreateHistos(); - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::scaler2014 ) ) - fScal2014Unp->CreateHistos(); - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::triglogscal ) ) - fTrloScalUnp->CreateHistos(); - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::vftx ) ) - fVftxUnp->CreateHistos(); - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::trbtdc ) ) - fTrbTdcUnp->CreateHistos(); - - return kTRUE; -} -Bool_t TMbsUnpTofMonitor::FillHistograms() -{ - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::triglog ) ) - fTriglogUnp->FillHistos(); - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::scalormu ) ) - fScomUnp->FillHistos(); - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::scaler2014 ) ) - fScal2014Unp->FillHistos(); - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::triglogscal ) ) - fTrloScalUnp->FillHistos(); - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::vftx ) ) - fVftxUnp->FillHistos(); - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::trbtdc ) ) - fTrbTdcUnp->FillHistos(); - - return kTRUE; -} -Bool_t TMbsUnpTofMonitor::WriteHistogramms() -{ - TDirectory * oldir = gDirectory; - TFile *fHist = new TFile("./tofMbsUnp.hst.root","RECREATE"); - - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::triglog ) ) - fTriglogUnp->WriteHistos( fHist ); - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::scalormu ) ) - fScomUnp->WriteHistos( fHist ); - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::scaler2014 ) ) - fScal2014Unp->WriteHistos( fHist ); - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::triglogscal ) ) - fTrloScalUnp->WriteHistos( fHist ); - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::vftx ) ) - fVftxUnp->WriteHistos( fHist ); - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::trbtdc ) ) - fTrbTdcUnp->WriteHistos( fHist ); - - gDirectory->cd( oldir->GetPath() ); - fHist->Close(); - - return kTRUE; -} -Bool_t TMbsUnpTofMonitor::DeleteHistograms() -{ - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::triglog ) ) - fTriglogUnp->DeleteHistos(); - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::scalormu ) ) - fScomUnp->DeleteHistos(); - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::scaler2014 ) ) - fScal2014Unp->DeleteHistos(); - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::triglogscal ) ) - fTrloScalUnp->DeleteHistos(); - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::vftx ) ) - fVftxUnp->DeleteHistos(); - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::trbtdc ) ) - fTrbTdcUnp->DeleteHistos(); - - return kTRUE; -} -// ------------------------------------------------------------------ -Bool_t TMbsUnpTofMonitor::CreateUnpackers() -{ - if( 0 == fMbsUnpackPar->GetNbActiveBoards() ) - { - LOG(error)<<"TMbsUnpTofMonitor::CreateUnpackers => No active boards => No unpacker !?!?! "; - return kFALSE; - } - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::triglog ) ) - fTriglogUnp = new TTofTriglogUnpacker( fMbsUnpackPar ); - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::scalormu ) ) - fScomUnp = new TTofScomUnpacker( fMbsUnpackPar ); - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::scaler2014 ) ) - fScal2014Unp = new TTofScal2014Unpacker( fMbsUnpackPar ); - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::triglogscal ) ) - { - fTrloScalUnp = new TTofTriglogScalUnpacker( fMbsUnpackPar ); - fTrloScalUnp->SetHistoUserAxis( fdScalersEvoRangeUser, fdScalersEvoBinSzUser ); - } // if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::triglogscal ) ) -/* - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::caenV1290 ) ) - fV1290Unp = new TTofV1290Unpacker( fMbsUnpackPar ); -*/ - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::vftx ) ) - fVftxUnp = new TTofVftxUnpacker( fMbsUnpackPar ); -/* - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::get4 ) ) - fGet4Unp = new TTofGet4Unpacker( fMbsUnpackPar ); -*/ - if( 0 < fMbsUnpackPar->GetNbActiveBoards( tofMbs::trbtdc ) ) - fTrbTdcUnp = new TTofTrbTdcUnpacker( fMbsUnpackPar, fMbsCalibPar ); - - return kTRUE; -} diff --git a/beamtime/tof/unpMoni/TMbsUnpTofMonitor.h b/beamtime/tof/unpMoni/TMbsUnpTofMonitor.h deleted file mode 100644 index 6dd3f9f645849460ce64fc5990eaf5c750ca0615..0000000000000000000000000000000000000000 --- a/beamtime/tof/unpMoni/TMbsUnpTofMonitor.h +++ /dev/null @@ -1,100 +0,0 @@ -// ------------------------------------------------------------------ -// ----- TMbsUnpTofMonitor ----- -// ----- Created 16/07/2013 by P.-A. Loizeau ----- -// ------------------------------------------------------------------ - -#ifndef TMBSUNPTOFMONITOR_H_ -#define TMBSUNPTOFMONITOR_H_ - -#include "FairTask.h" - -#include <vector> - -// Parameters -class TMbsUnpackTofPar; -class TMbsCalibTofPar; - -// Unpackers -class TTofTriglogUnpacker; -class TTofScal2014Unpacker; -class TTofScomUnpacker; -class TTofTriglogScalUnpacker; -class TTofVftxUnpacker; -class TTofTrbTdcUnpacker; - -// ROOT -class TClonesArray; -class TH1; -class TH2; -class TDirectory; -//class TTimeStamp; -#include "TTimeStamp.h" - -class TMbsUnpTofMonitor : public FairTask -{ - public: - TMbsUnpTofMonitor(); - TMbsUnpTofMonitor(const char* name, Int_t verbose = 1); - ~TMbsUnpTofMonitor(); - - // Fairtask specific functions - virtual void SetParContainers(); - virtual InitStatus Init(); - virtual InitStatus ReInit(); - virtual void Exec(Option_t* option); - virtual void Finish(); - - void SetScalHistoUserAxis( Double_t dRangeIn, Double_t dBinSzIn ) - { fdScalersEvoRangeUser = dRangeIn; fdScalersEvoBinSzUser = dBinSzIn; }; - - private: - // no default Copy constructor and = OP as class not meant to be copied - TMbsUnpTofMonitor(const TMbsUnpTofMonitor&); - TMbsUnpTofMonitor& operator=(const TMbsUnpTofMonitor&); - - // Unpackers - Bool_t CreateUnpackers(); - - // Histograms, including Task own histos - Bool_t CreateHistogramms(); - Bool_t FillHistograms(); - Bool_t WriteHistogramms(); - Bool_t DeleteHistograms(); - - // Input -// Bool_t RegisterInput(); - - // Parameters - Bool_t InitParameters(); - TMbsUnpackTofPar *fMbsUnpackPar; - TMbsCalibTofPar *fMbsCalibPar; - - // Unpackers - TTofTriglogUnpacker * fTriglogUnp; - TTofScomUnpacker * fScomUnp; - TTofScal2014Unpacker * fScal2014Unp; - TTofTriglogScalUnpacker * fTrloScalUnp; - TTofVftxUnpacker * fVftxUnp; - TTofTrbTdcUnpacker * fTrbTdcUnp; - - // Output objects - TClonesArray * fTriglogBoardCollection; - TClonesArray * fScalerBoardCollection; - TClonesArray * fVftxBoardCollection; - TClonesArray * fTrbTdcBoardCollection; - - // Events statistics - Int_t fiNbEvents; - Int_t fiFirstEventNumber; - Int_t fiLastEventNumber; - TTimeStamp fFirstCheck; - TTimeStamp fLastCheck; - TTimeStamp fCheck; - - Double_t fdScalersEvoRangeUser; - Double_t fdScalersEvoBinSzUser; - - ClassDef(TMbsUnpTofMonitor, 1) -}; - -#endif // TMBSUNPTOFMONITOR_H_ diff --git a/beamtime/trb/CMakeLists.txt b/beamtime/trb/CMakeLists.txt deleted file mode 100644 index bb1a69b4010f8b0c713e6801d49029b086405a8e..0000000000000000000000000000000000000000 --- a/beamtime/trb/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -#Add_Subdirectory(trbnet_client) -Add_Subdirectory(trbnet_lib) -Add_Subdirectory(trbnet_exe) -Add_Subdirectory(daq_anal) diff --git a/beamtime/trb/daq_anal/CMakeLists.txt b/beamtime/trb/daq_anal/CMakeLists.txt deleted file mode 100644 index 1e09ce434b8ee3a8ca8ba9a19dcfb13263e96ab2..0000000000000000000000000000000000000000 --- a/beamtime/trb/daq_anal/CMakeLists.txt +++ /dev/null @@ -1,27 +0,0 @@ -# Build the tsclient executable which is taken from -# git@code.compeng.uni-frankfurt.de:flesnet.git -# This executable uses the fles_ipc library to read files -# in the tca format -# This file is only called if the compiler provides c++11 support - -Set(INCLUDE_DIRECTORIES - ${CMAKE_CURRENT_SOURCE_DIR} -) - -Include_Directories( ${INCLUDE_DIRECTORIES}) - - -Set(SRCS -evt.c -hadtu.c -hldread.c -showevt.c -subevt.c -) - -Set_Source_Files_Properties(subevt.c COMPILE_FLAGS -Wno-implicit-function-declaration) - -Set(EXE_NAME daq_anal) - -GENERATE_EXECUTABLE() - diff --git a/beamtime/trb/daq_anal/evt.c b/beamtime/trb/daq_anal/evt.c deleted file mode 100644 index 23025f81b6d8e50c67af44c6c966ee700b8f2314..0000000000000000000000000000000000000000 --- a/beamtime/trb/daq_anal/evt.c +++ /dev/null @@ -1,238 +0,0 @@ -static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/evt.c,v 6.18 2010-01-29 18:24:02 hadaq Exp $"; - - -#define _ANSI_C_SOURCE -#include <stddef.h> - -#include <errno.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> -#include <syslog.h> - -#include "evt.h" -#include "subevt.h" - -enum EvtIdx { - EvtIdx_size, - EvtIdx_decoding, - EvtIdx_id, - EvtIdx_seqNr, - EvtIdx_date, - EvtIdx_time, - EvtIdx_runNr, - EvtIdx_expId, - EvtIdx_data -}; - -size_t Evt_hdrLen(void) -{ - return EvtIdx_data; -} - -size_t Evt_hdrSize(void) -{ - return Evt_hdrLen() * sizeof(uint32_t); -} - -size_t Evt_dataSize(const void *my) -{ - return Evt_size(my) - Evt_hdrSize(); -} - -void *Evt_data(const void *my) -{ - return (void *) ((char *) my + Evt_hdrSize()); -} - -uint32_t Evt_id(const void *my) -{ - return Evt_hdrValue(my, EvtIdx_id); -} - -void Evt_setId(void *my, uint32_t id) -{ - Evt_setHdrValue(my, EvtIdx_id, id); -} - -uint32_t Evt_seqNr(const void *my) -{ - return Evt_hdrValue(my, EvtIdx_seqNr); -} - -void Evt_setSeqNr(void *my, uint32_t seqNr) -{ - Evt_setHdrValue(my, EvtIdx_seqNr, seqNr); -} - -uint32_t Evt_date(const void *my) -{ - return Evt_hdrValue(my, EvtIdx_date); -} - -void Evt_setDate(void *my, uint32_t date) -{ - Evt_setHdrValue(my, EvtIdx_date, date); -} - -uint32_t Evt_time(const void *my) -{ - return Evt_hdrValue(my, EvtIdx_time); -} - -void Evt_setTime(void *my, uint32_t time) -{ - Evt_setHdrValue(my, EvtIdx_time, time); -} - -uint32_t Evt_runNr(const void *my) -{ - return Evt_hdrValue(my, EvtIdx_runNr); -} - -void Evt_setRunNr(void *my, uint32_t runNr) -{ - Evt_setHdrValue(my, EvtIdx_runNr, runNr); -} - -uint32_t Evt_expId(const void *my) -{ - return Evt_hdrValue(my, EvtIdx_expId); -} - -void Evt_setExpId(void *my, uint32_t expId) -{ - Evt_setHdrValue(my, EvtIdx_expId, expId); -} - -char *Evt_expId2charP(const void *my) -{ - static char buffer[3]; - uint32_t expId; - - expId = Evt_expId(my); - - buffer[0] = (expId >> 8) & 0xff; - buffer[1] = expId & 0xff; - buffer[2] = '\0'; - - return buffer; -} - -void Evt_setExpIdCharP(void *my, const char *expId) -{ - Evt_setExpId(my, (expId[0] << 8) | expId[1]); -} - -char *Evt_date2charP(const void *my) -{ - time_t tempo; - struct tm *gmTime; - static char buffer[80]; - - tempo = time(NULL); - gmTime = gmtime(&tempo); - gmTime->tm_year = (Evt_date(my) >> 16) & 0xff; - gmTime->tm_mon = (Evt_date(my) >> 8) & 0xff; - gmTime->tm_mday = (Evt_date(my) >> 0) & 0xff; - strftime(buffer, 80, "%Y-%m-%d", gmTime); - - return buffer; -} - -char *Evt_time2charP(const void *my) -{ - time_t tempo; - struct tm *gmTime; - static char buffer[80]; - - tempo = time(NULL); - gmTime = gmtime(&tempo); - gmTime->tm_hour = (Evt_time(my) >> 16) & 0xff; - gmTime->tm_min = (Evt_time(my) >> 8) & 0xff; - gmTime->tm_sec = (Evt_time(my) >> 0) & 0xff; - strftime(buffer, 80, "%H:%M:%S", gmTime); - - return buffer; -} - -char *Evt_2charP(const void *my) -{ - static char buf[2 * 132]; - - sprintf(buf, - "size: 0x%08x\tdecoding: 0x%08x\tid: 0x%08x\tseqNr: 0x%08x\t" - "date: %s\ttime: %s\trunNr: %d\texpId: %x", - Evt_size(my), Evt_decoding(my), Evt_id(my), Evt_seqNr(my), - Evt_date2charP(my), Evt_time2charP(my), Evt_runNr(my), Evt_expId(my) - ); - - return buf; -} - -void *newEvt(uint32_t decoding, uint32_t id) -{ - void *my; - time_t tempo; - struct tm *gmTime; - uint32_t dummy; - - my = malloc(EVT_MAXSIZE); - - Evt_setSize(my, Evt_hdrSize()); - Evt_setDecoding(my, decoding); - Evt_setId(my, id); - - tempo = time(NULL); - gmTime = gmtime(&tempo); - - dummy = 0; - dummy |= gmTime->tm_year << 16; - dummy |= gmTime->tm_mon << 8; - dummy |= gmTime->tm_mday; - Evt_setDate(my, dummy); - - dummy = 0; - dummy |= gmTime->tm_hour << 16; - dummy |= gmTime->tm_min << 8; - dummy |= gmTime->tm_sec; - Evt_setTime(my, dummy); - - return my; -} - -void deleteEvt(void *my) -{ - free(my); -} - -void *Evt_appendSubEvt(void *my, void *subEvt) -{ - if (SubEvt_decoding(subEvt) == SubEvtDecoding_SubEvts) { - memcpy(Evt_end(my), SubEvt_data(subEvt), SubEvt_dataSize(subEvt)); - Evt_setSize(my, Evt_paddedSize(my) + SubEvt_dataSize(subEvt)); - } else { - memcpy(Evt_end(my), subEvt, SubEvt_size(subEvt)); - Evt_setSize(my, Evt_paddedSize(my) + SubEvt_size(subEvt)); - } - - return my; -} - -void *Evt_fget(FILE *file) -{ - static char pool[EVT_MAXSIZE]; - static void *evt = pool; - - if (Evt_hdrSize() != fread(evt, 1, Evt_hdrSize(), file)) { - syslog(LOG_DEBUG, "%s:%d: %s", __FILE__, __LINE__, strerror(errno)); - return NULL; - } - /* BUGBUG quickhack for a "Evt_paddedDataSize" */ - if (Evt_paddedSize(evt) - Evt_hdrSize() != fread(Evt_data(evt), 1, Evt_paddedSize(evt) - Evt_hdrSize(), file)) { - syslog(LOG_ERR, "%s:%d: %s", __FILE__, __LINE__, strerror(errno)); - return NULL; - } - return evt; -} diff --git a/beamtime/trb/daq_anal/evt.h b/beamtime/trb/daq_anal/evt.h deleted file mode 100644 index 6175c4b31d505adede3934e909334b104fb34e4a..0000000000000000000000000000000000000000 --- a/beamtime/trb/daq_anal/evt.h +++ /dev/null @@ -1,97 +0,0 @@ -#ifndef EVT_H -#define EVT_H - -#include <stdio.h> -#include <time.h> -#include <stdint.h> - -#include "hadtu.h" -#include "subevt.h" - -#define EVT_MAXSIZE (1024 * 1024) - -#ifdef __cplusplus -extern "C" { -#endif - -static const int evtBlockSize = 8 * 1024; - -enum EvtId { - EvtId_data = 1, - EvtId_runStart = 0x00010002, - EvtId_runStop = 0x00010003 -}; - -enum EvtDecoding { - EvtDecoding_default = 1, - EvtDecoding_64bitAligned = (0x03 << 16) | 0x0001 -}; - -#define Evt_hdr HadTu_hdr -#define Evt_isSwapped HadTu_isSwapped -#define Evt_hdrValue HadTu_hdrValue -#define Evt_setHdrValue HadTu_setHdrValue -#define Evt_decoding HadTu_decoding -#define Evt_setDecoding HadTu_setDecoding -#define Evt_alignment HadTu_alignment -#define Evt_size HadTu_size -#define Evt_setSize HadTu_setSize -#define Evt_paddedSize HadTu_paddedSize -#define Evt_begin HadTu_begin -#define Evt_end HadTu_end -#define Evt_next HadTu_next - -size_t Evt_hdrLen(void); -size_t Evt_hdrSize(void); -size_t Evt_dataSize(const void *my); -void *Evt_data(const void *my); -char *Evt_date2charP(const void *my); -char *Evt_time2charP(const void *my); -char *Evt_2charP(const void *my); -char *Evt_expId2charP(const void *my); -void Evt_setExpIdCharP(void *my, const char *expId); - -uint32_t Evt_id(const void *my); - -static uint32_t Evt_pureId(const void *my) -{ - return Evt_id(my) & 0x7fffffffUL; -} - -static int Evt_dataError(const void *my) -{ - return (Evt_id(my) & 0x80000000UL) != 0; -} - -void Evt_setId(void *my, uint32_t id); - -static void Evt_setDataError(void *my) -{ - Evt_setId(my, Evt_id(my) | 0x80000000UL); -} - -static void Evt_clrDataError(void *my) -{ - Evt_setId(my, Evt_id(my) & ~0x80000000UL); -} - -uint32_t Evt_seqNr(const void *my); -void Evt_setSeqNr(void *my, uint32_t seqNr); -uint32_t Evt_date(const void *my); -void Evt_setDate(void *my, uint32_t date); -uint32_t Evt_time(const void *my); -void Evt_setTime(void *my, uint32_t time); -uint32_t Evt_runNr(const void *my); -uint32_t Evt_expId(const void *my); -void Evt_setRunNr(void *my, uint32_t runNr); -void Evt_setExpId(void *my, uint32_t expId); - -void *newEvt(uint32_t decoding, uint32_t id); -void deleteEvt(void *my); -void *Evt_fget(FILE *file); -void *Evt_appendSubEvt(void *my, void *subEvt); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/beamtime/trb/daq_anal/hadtu.c b/beamtime/trb/daq_anal/hadtu.c deleted file mode 100644 index e86995892d586c6d042f00a87f2a02c12d29b87b..0000000000000000000000000000000000000000 --- a/beamtime/trb/daq_anal/hadtu.c +++ /dev/null @@ -1,21 +0,0 @@ -static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/hadtu.c,v 6.6 2003-05-14 13:54:43 muench Exp $"; - - -#define _ANSI_C_SOURCE -#include <stddef.h> - -#include <stdio.h> -#include <string.h> - - -#include "hadtu.h" - -char *HadTu_2charP(const void *my) -{ - static char buf[80]; - - sprintf(buf, "size: 0x%08x\tdecoding: 0x%08x", - HadTu_size(my), HadTu_decoding(my)); - - return buf; -} diff --git a/beamtime/trb/daq_anal/hadtu.h b/beamtime/trb/daq_anal/hadtu.h deleted file mode 100644 index dfaad94aa40e856a9a4b5d43b6170d9f964234ac..0000000000000000000000000000000000000000 --- a/beamtime/trb/daq_anal/hadtu.h +++ /dev/null @@ -1,161 +0,0 @@ -#ifndef HADTU_H -#define HADTU_H - -#include <stddef.h> -#include <stdint.h> - -#ifdef __cplusplus -extern "C" { -#endif - -enum HadTu_Decoding { - HadTu_queueDecoding = 3 << 16 | 99 -}; - -static uint32_t *HadTu_hdr(const void *my); -static size_t HadTu_hdrLen(void); -static size_t HadTu_hdrSize(void); -static int HadTu_isSwapped(const void *my); -static uint32_t HadTu_hdrValue(const void *my, unsigned idx); -static void HadTu_setHdrValue(const void *my, unsigned idx, uint32_t value); -static uint32_t HadTu_decoding(const void *my); -static void HadTu_setDecoding(void *my, uint32_t decoding); -static unsigned HadTu_alignment(const void *my); -static uint32_t HadTu_size(const void *my); -static void HadTu_setSize(void *my, uint32_t size); -static size_t HadTu_paddedSize(const void *my); -static void *HadTu_begin(const void *my); -static void *HadTu_end(const void *my); -static size_t HadTu_dataSize(const void *my); -static void *HadTu_data(const void *my); -static void *HadTu_next(const void *my, const void *hadTu); -char *HadTu_2charP(const void *my); - -enum HadTuIdx { - HadTuIdx_size, - HadTuIdx_decoding, - HadTuIdx_data -}; - -static uint32_t *HadTu_hdr(const void *my) -{ - return (uint32_t *) my; -} - -static size_t HadTu_hdrLen(void) -{ - return HadTuIdx_data; -} - -static size_t HadTu_hdrSize(void) -{ - return HadTu_hdrLen() * sizeof(uint32_t); -} - -static int HadTu_isSwapped(const void *my) -{ - uint32_t *hdr = HadTu_hdr(my); - - return hdr[HadTuIdx_decoding] > 0xffffff; -} - -static uint32_t HadTu_hdrValue(const void *my, unsigned idx) -{ - uint32_t *hdr = HadTu_hdr(my); - - if (HadTu_isSwapped(my)) { - uint32_t tmp0; - uint32_t tmp1; - - tmp0 = hdr[idx]; - ((char *) &tmp1)[0] = ((char *) &tmp0)[3]; - ((char *) &tmp1)[1] = ((char *) &tmp0)[2]; - ((char *) &tmp1)[2] = ((char *) &tmp0)[1]; - ((char *) &tmp1)[3] = ((char *) &tmp0)[0]; - return tmp1; - } else { - return hdr[idx]; - } -} - -static void HadTu_setHdrValue(const void *my, unsigned idx, uint32_t value) -{ - uint32_t *hdr = HadTu_hdr(my); - - hdr[idx] = value; -} - -static uint32_t HadTu_decoding(const void *my) -{ - return HadTu_hdrValue(my, HadTuIdx_decoding); -} - -static void HadTu_setDecoding(void *my, uint32_t decoding) -{ - HadTu_setHdrValue(my, HadTuIdx_decoding, decoding); -} - -static unsigned HadTu_alignment(const void *my) -{ - return 1 << (HadTu_decoding(my) >> 16 & 0xff); -} - -static uint32_t HadTu_size(const void *my) -{ - return HadTu_hdrValue(my, HadTuIdx_size); -} - -static void HadTu_setSize(void *my, uint32_t size) -{ - HadTu_setHdrValue(my, HadTuIdx_size, size); -} - -static size_t HadTu_paddedSize(const void *my) -{ - uint32_t size; - uint32_t alignment; - - size = HadTu_size(my); - alignment = HadTu_alignment(my); - return (size & (alignment - 1)) - ? (size & ~(alignment - 1)) + alignment : size; -} - -static void *HadTu_begin(const void *my) -{ - return (void *) my; -} - -static void *HadTu_end(const void *my) -{ - return (void *) ((char *) my + HadTu_paddedSize(my)); -} - -static size_t HadTu_dataSize(const void *my) -{ - return HadTu_size(my) - HadTu_hdrSize(); -} - -static void *HadTu_data(const void *my) -{ - return (void *) ((char *) my + HadTu_hdrSize()); -} - -static void *HadTu_next(const void *my, const void *hadTu) -{ - uint32_t size; - uint32_t alignment; - size_t paddedSize; - - size = HadTu_size(hadTu); - alignment = HadTu_alignment(my); - paddedSize = (size & (alignment - 1)) - ? (size & ~(alignment - 1)) + alignment : size; - - return (void *) ((char *) hadTu + paddedSize); -} - -#ifdef __cplusplus -} -#endif -#endif diff --git a/beamtime/trb/daq_anal/hldread.c b/beamtime/trb/daq_anal/hldread.c deleted file mode 100644 index 95b59e496d8a16d09db82d27ed4f5486e46a63f7..0000000000000000000000000000000000000000 --- a/beamtime/trb/daq_anal/hldread.c +++ /dev/null @@ -1,162 +0,0 @@ -static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/hldread.c,v 6.10 2010-01-29 18:24:05 hadaq Exp $"; - - -#define _POSIX_C_SOURCE 199309L -#define SYSLOG_NAMES -#include <unistd.h> - -#include <stddef.h> - -#include <stdlib.h> -#include <stdio.h> -#include <errno.h> -#include <string.h> -#include <signal.h> -#include <limits.h> - -#include <syslog.h> - - -#include "evt.h" -#include "hldread.h" - -static unsigned long processedEvts = 0; -static unsigned int timeout = 0; - -static int excludeAnal = 0; - -static void showProcessedEvts(unsigned long processedEvts) -{ - static unsigned long keepProcessedEvts = 0; - int level; - char *notice; - - if (processedEvts > keepProcessedEvts) { - level = LOG_INFO; - notice = ""; - } else { - level = LOG_NOTICE; - notice = ", \ano new events arrived"; - } - syslog(level, "%5lu events processed %-30s\r", processedEvts, notice); -} - -static void atexit0(void) -{ - if (!excludeAnal) - stopAnalysis(); - syslog(LOG_INFO, "%5lu events processed %-30s", processedEvts, ""); -} - - - - - -void sigHandler(int sig) -{ - exit(128 + sig); -} - - -void alarmHandler(int x) -{ - signal(SIGALRM, alarmHandler); - alarm(timeout); - showProcessedEvts(processedEvts); -} - -int main(int argc, char *argv[]) -{ - extern char *optarg; - extern int optind; - int i = 0; - FILE *file = NULL; - void *evt; - unsigned long readEvts = 0; - unsigned long fEvts = 0; - unsigned long nEvts = ULONG_MAX; - unsigned long echoRate = ULONG_MAX; - char **analArgv = malloc(sizeof(char *)); - int analArgc = 1; /* Filename is in analArgv[0] */ - - openlog(argv[0], LOG_PID | LOG_PERROR, LOG_LOCAL0); - setlogmask(LOG_UPTO(LOG_INFO)); - - - while ((i = getopt(argc, argv, "n:f:e:t:xo:v:")) != -1) { - switch (i) { - case 'f': - fEvts = atol(optarg); - break; - case 'n': - nEvts = atol(optarg); - break; - case 'e': - echoRate = atol(optarg); - break; - case 't': - timeout = atoi(optarg); - break; - case 'x': - excludeAnal = 1; - break; - case 'o': - analArgv = realloc(analArgv, sizeof(char *) * (analArgc + 1)); - - analArgv[analArgc++] = optarg; - break; - case 'v': - for (i = 0; prioritynames[i].c_name != NULL && 0 != strcmp(prioritynames[i].c_name, optarg); i++) { - } - if (prioritynames[i].c_name != NULL) { - setlogmask(LOG_UPTO(prioritynames[i].c_val)); - break; - } /* FALLTHROUGH to default */ - default: - syslog(LOG_ERR, "Usage: %s -f firstEvent -n numEvents -e echoRate", argv[0] - ); - syslog(LOG_ERR, "-t timeout -o analArgs -x (excludeAnal) [fileName]"); - exit(EXIT_FAILURE); - break; - } /* switch (i ... */ - } /* while ((i ... */ - if (argv[optind] == NULL) { - file = stdin; - analArgv[0] = "-"; - } else { - file = fopen(argv[optind], "r"); - analArgv[0] = argv[optind]; - } - if (file == NULL) { - syslog(LOG_ERR, "Opening input file: %s", strerror(errno)); - exit(EXIT_FAILURE); - } - if (!excludeAnal) { - startAnalysis(analArgc, analArgv); - } - atexit(atexit0); - - signal(SIGINT, sigHandler); - signal(SIGTERM, sigHandler); - signal(SIGHUP, sigHandler); - - signal(SIGALRM, alarmHandler); - alarm(timeout); - - - while ((evt = Evt_fget(file)) != NULL && processedEvts < nEvts) { - readEvts++; - if (readEvts >= fEvts) { - if (!excludeAnal) - analyseEvt(evt); - processedEvts++; - if (processedEvts == 1) { - syslog(LOG_INFO, "First event processed %-30s\r", ""); - } else if (processedEvts % echoRate == 0) { - alarm(timeout); - showProcessedEvts(processedEvts); - } - } - } - exit(EXIT_SUCCESS); -} diff --git a/beamtime/trb/daq_anal/hldread.h b/beamtime/trb/daq_anal/hldread.h deleted file mode 100644 index e9ee7bec9193903b9ca95d68261c510e65287785..0000000000000000000000000000000000000000 --- a/beamtime/trb/daq_anal/hldread.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef HLDREAD_H -#define HLDREAD_H - -#include "evt.h" - -#ifdef __cplusplus -extern "C" { -#endif - -int startAnalysis(int argc, char **argv); -int analyseEvt(void *evt); -int stopAnalysis(void); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/beamtime/trb/daq_anal/showevt.c b/beamtime/trb/daq_anal/showevt.c deleted file mode 100644 index fabe9ee09f897d0f94ca8410eaa63c4b8abc1194..0000000000000000000000000000000000000000 --- a/beamtime/trb/daq_anal/showevt.c +++ /dev/null @@ -1,123 +0,0 @@ -static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/showevt.c,v 6.11 2003-05-14 13:54:45 muench Exp $"; - - -#define _ANSI_C_SOURCE -#include <stddef.h> - -#include <stdio.h> -#include <string.h> - -#include <stdint.h> -#include <stdlib.h> - -#include "hldread.h" - -typedef struct OurArgsS { - int noPrint; - int debug; -} OurArgs; -static OurArgs ourArgsS = { 0 }, *ourArgs = &ourArgsS; - -int startAnalysis(int argc, char **argv) -{ - int i; - for (i = 0; i < argc; i++) { - if (strcmp(argv[i], "noprint") == 0) { - ourArgs->noPrint = 1; - } - if (strcmp(argv[i], "debug") == 0) { - ourArgs->debug = 1; - } - } - if (ourArgs->debug) { - fprintf(stderr, "startAnalysis called\n"); - } - return 0; -} - -int analyseEvt(void *evt) -{ - int i; - void *subEvt; - - if (ourArgs->debug) { - fprintf(stderr, "analyseEvt called\n"); - } - - if (!ourArgs->noPrint) { - /* print the event header */ - printf("size: 0x%08x decoding: 0x%08x id: 0x%08x seqNr: 0x%08x\n" - "date: %s time: %s runNr: 0x%08x expId: %s\n", - Evt_size(evt), Evt_decoding(evt), Evt_id(evt), Evt_seqNr(evt), - Evt_date2charP(evt), Evt_time2charP(evt), Evt_runNr(evt), Evt_expId2charP(evt) - ); - } - if (Evt_size(evt) < Evt_hdrSize()) { - fprintf(stderr, " evt: %s\n", Evt_2charP(evt)); - fprintf(stderr, "Evt_size(evt) < Evt_hdrSize(), abort\n"); - abort(); - } - - i = 0; - /* loop over all subevents */ - for (subEvt = Evt_data(evt); subEvt < Evt_end(evt); subEvt = Evt_next(evt, subEvt)) { - if (!ourArgs->noPrint) { - printf("size: 0x%08x decoding: 0x%08x id: 0x%08x trigNr: 0x%08x trigTypeTRB3: 0x%01x\n", - SubEvt_size(subEvt), SubEvt_decoding(subEvt), SubEvt_id(subEvt), SubEvt_trigNr(subEvt), SubEvt_trigType_trb3(subEvt)); - if (SubEvt_decoding(subEvt) == SubEvtDecoding_32bitData) { - for (i = 0; i < SubEvt_dataSize(subEvt) / sizeof(uint32_t); i++) { - if (i % 4 == 0) { /* newline and the offset in the subEvt */ - printf("\n%08lx:", i * sizeof(uint32_t)); - } - printf(" 0x%08x", SubEvt_dataValue(subEvt, i)); - } - } else if (SubEvt_decoding(subEvt) == SubEvtDecoding_16bitData) { - for (i = 0; i < SubEvt_dataSize(subEvt) / sizeof(uint16_t); i++) { - if (i % 8 == 0) { /* newline and the offset in the subEvt */ - printf("\n%08lx:", i * sizeof(uint16_t)); - } - printf(" 0x%04x", SubEvt_dataValue(subEvt, i)); - } - } else if (SubEvt_decoding(subEvt) == SubEvtDecoding_8bitData) { - for (i = 0; i < SubEvt_dataSize(subEvt) / sizeof(uint8_t); i++) { - if (i % 16 == 0) { /* newline and the offset in the subEvt */ - printf("\n%08x:", i); - } - printf(" 0x%02x", SubEvt_dataValue(subEvt, i)); - } - } else if (SubEvt_decoding(subEvt) == SubEvtDecoding_text) { - char *data; - - printf("%c", '\n'); - data = (char *) SubEvt_data(subEvt); - for (i = 0; i < SubEvt_dataSize(subEvt); i++) { - printf("%c", data[i]); - } - } - printf("%c", '\n'); - } - if (SubEvt_size(subEvt) < SubEvt_hdrSize()) { - fprintf(stderr, " evt: %s\n", Evt_2charP(evt)); - fprintf(stderr, "subEvt: %s\n", SubEvt_2charP(subEvt)); - fprintf(stderr, "SubEvt_size(subEvt) < SubEvt_hdrSize(), skip rest of event\n"); - break; - } else if (SubEvt_size(subEvt) > Evt_size(evt) - Evt_hdrSize()) { - fprintf(stderr, " evt: %s\n", Evt_2charP(evt)); - fprintf(stderr, "subEvt: %s\n", SubEvt_2charP(subEvt)); - fprintf(stderr, "SubEvt_size(subEvt) < Evt_size(evt) - Evt_hdrSize(), skip rest of event\n"); - break; - } - } - if (!ourArgs->noPrint) { - printf("%c", '\n'); - } - return 0; -} - -int stopAnalysis(void) -{ - if (ourArgs->debug) { - fprintf(stderr, "stopAnalysis called\n"); - } - return 0; -} diff --git a/beamtime/trb/daq_anal/subevt.c b/beamtime/trb/daq_anal/subevt.c deleted file mode 100644 index 171fe77eed43ba480c6c74dc1d494507518f6b69..0000000000000000000000000000000000000000 --- a/beamtime/trb/daq_anal/subevt.c +++ /dev/null @@ -1,158 +0,0 @@ -static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/subevt.c,v 6.16 2010-07-06 15:35:51 hadaq Exp $"; - -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <errno.h> -#include <string.h> -#include <time.h> -#include <sys/types.h> - -#include "subevt.h" - -uint32_t SubEvt_dataValue(const void *my, unsigned idx) -{ - uint32_t val; - - switch (SubEvt_alignment(my)) { - case 4: - if (SubEvt_isSwapped(my)) { - uint32_t tmp0; - uint32_t tmp1; - - tmp0 = ((uint32_t *) SubEvt_data(my))[idx]; - ((char *) &tmp1)[0] = ((char *) &tmp0)[3]; - ((char *) &tmp1)[1] = ((char *) &tmp0)[2]; - ((char *) &tmp1)[2] = ((char *) &tmp0)[1]; - ((char *) &tmp1)[3] = ((char *) &tmp0)[0]; - val = tmp1; - } else { - val = ((uint32_t *) SubEvt_data(my))[idx]; - } - break; - case 2: - if (SubEvt_isSwapped(my)) { - uint16_t v; - swab(((uint16_t *) SubEvt_data(my)) + idx, &v, 2); - val = v; - } else { - val = ((uint16_t *) SubEvt_data(my))[idx]; - } - break; - default: - val = ((uint8_t *) SubEvt_data(my))[idx]; - break; - } - return val; -} - -unsigned SubEvt_nrOfDataWords(const void *my) -{ - unsigned i; - - if (SubEvt_decoding(my) == SubEvtDecoding_32bitData) { - i = SubEvt_dataSize(my) / sizeof(uint32_t) - 1; - } else if (SubEvt_decoding(my) == SubEvtDecoding_16bitData) { - i = SubEvt_dataSize(my) / sizeof(uint16_t) - 1; - } else if (SubEvt_decoding(my) == SubEvtDecoding_8bitData) { - i = SubEvt_dataSize(my) / sizeof(uint8_t) - 1; - } else if (SubEvt_decoding(my) == SubEvtDecoding_SubEvts) { - fprintf(stderr, "ERROR: Crate event are not supported any longer, decoding: %x\n", SubEvt_decoding(my)); - } else { - fprintf(stderr, "ERROR: Unknown decoding: %i\n", SubEvt_decoding(my)); - } - - return i; -} - -uint32_t SubEvt_errBit(const void *my) -{ - unsigned i; - uint32_t val; - - i = SubEvt_nrOfDataWords(my); - - val = SubEvt_dataValue(my, i); - - return val; -} - -uint32_t SubEvt_debugWord(const void *my) -{ - unsigned i; - uint32_t val; - unsigned wordNr = -1; - - /* Define debug word for the RICH */ - if (SubEvt_id(my) == 0x00008300UL || SubEvt_id(my) == 0x00008310UL || SubEvt_id(my) == 0x00008320UL) { - wordNr = 2; - } - - i = SubEvt_nrOfDataWords(my); - - if (wordNr == -1) { - val = 0; - } else if (i > wordNr) { - val = SubEvt_dataValue(my, wordNr - 1); - } else { - val = 0; - } - - return val; -} - -uint32_t SubEvt_trigType(const void *my, uint32_t wordNr, uint32_t bitmask, uint32_t bitshift) -{ - unsigned i; - uint32_t trigType; - uint32_t val; - - i = SubEvt_nrOfDataWords(my); - - if (i > wordNr) { - val = SubEvt_dataValue(my, wordNr - 1); - } else { - return 0; - } - - return (val & bitmask) >> bitshift; -} - -char *SubEvt_2charP(const void *my) -{ - static char buf[132]; - - sprintf(buf, "size: 0x%08x\tdecoding: 0x%08x\tid: 0x%08x\ttrigNr: 0x%08x", - SubEvt_size(my), SubEvt_decoding(my), SubEvt_id(my), SubEvt_trigNr(my)); - - return buf; -} - -void *newSubEvt(uint32_t decoding, uint32_t id, uint32_t trigNr) -{ - void *my; - - my = malloc(SubEvt_hdrSize()); - - SubEvt_setSize(my, SubEvt_hdrSize()); - SubEvt_setDecoding(my, decoding); - SubEvt_setId(my, id); - SubEvt_setTrigNr(my, trigNr); - - return my; -} - -void deleteSubEvt(void *my) -{ - free(my); -} - -void *SubEvt_appendData(void *my, const void *data, size_t size) -{ - - my = realloc(my, SubEvt_paddedSize(my) + size); - memcpy(SubEvt_end(my), data, size); - SubEvt_setSize(my, SubEvt_paddedSize(my) + size); - - return my; -} diff --git a/beamtime/trb/daq_anal/subevt.h b/beamtime/trb/daq_anal/subevt.h deleted file mode 100644 index 1d7c1126de42cff682293368a4017b5c829a74d4..0000000000000000000000000000000000000000 --- a/beamtime/trb/daq_anal/subevt.h +++ /dev/null @@ -1,153 +0,0 @@ -#ifndef SUBEVT_H -#define SUBEVT_H - -#include <stdint.h> - -#include "hadtu.h" - -#ifdef __cplusplus -extern "C" { -#endif - -enum SubEvtId { - SubEvtId_invalid = 0, - SubEvtId_test1 = 1, - SubEvtId_slow = 2, - SubEvtId_test2 = 3, - SubEvtId_mdc = 6, - SubEvtId_shower = 7, - SubEvtId_rich = 8, - SubEvtId_tof = 9, - SubEvtId_start = 10, - SubEvtId_veto = 11, - SubEvtId_richPed = 12, - SubEvtId_tofTest = 400, - SubEvtId_trigCode = 500, - SubEvtId_trigInfo = 501, - SubEvtId_slowTest = 600 -}; - -enum SubEvtDecoding { - SubEvtDecoding_8bitData = 1, - SubEvtDecoding_16bitData = (1 << 16) | 1, - SubEvtDecoding_32bitData = (2 << 16) | 1, - SubEvtDecoding_text = 2, - SubEvtDecoding_SubEvts = (3 << 16) | 3 -}; - -#define SubEvt_hdr HadTu_hdr -#define SubEvt_isSwapped HadTu_isSwapped -#define SubEvt_hdrValue HadTu_hdrValue -#define SubEvt_setHdrValue HadTu_setHdrValue -/*#define SubEvt_decoding HadTu_decoding JAM: replaced by function that also masks the trb3 trigger type info*/ -/* #define SubEvt_setDecoding HadTu_setDecoding */ -#define SubEvt_alignment HadTu_alignment -#define SubEvt_size HadTu_size -#define SubEvt_setSize HadTu_setSize -#define SubEvt_paddedSize HadTu_paddedSize -#define SubEvt_begin HadTu_begin -#define SubEvt_end HadTu_end -#define SubEvt_next HadTu_next - - -enum SubEvtIdx { - SubEvtIdx_size, - SubEvtIdx_decoding, - SubEvtIdx_id, - SubEvtIdx_trigNr, - SubEvtIdx_data -}; - -static size_t SubEvt_hdrLen(void) -{ - return SubEvtIdx_data; -} - -static size_t SubEvt_hdrSize(void) -{ - return SubEvt_hdrLen() * sizeof(uint32_t); -} - -static size_t SubEvt_dataSize(const void *my) -{ - return SubEvt_size(my) - SubEvt_hdrSize(); -} - -static void *SubEvt_data(const void *my) -{ - return (void *) ((char *) my + SubEvt_hdrSize()); -} - -uint32_t SubEvt_dataValue(const void *my, unsigned idx); -char *SubEvt_2charP(const void *my); - - -static uint32_t SubEvt_id(const void *my) -{ - return SubEvt_hdrValue(my, SubEvtIdx_id); -} - -static uint32_t SubEvt_pureId(const void *my) -{ - return SubEvt_id(my) & 0x7fffffffUL; -} - -static int SubEvt_dataError(const void *my) -{ - return (SubEvt_id(my) & 0x80000000UL) != 0; -} - -static void SubEvt_setId(void *my, uint32_t id) -{ - SubEvt_setHdrValue(my, SubEvtIdx_id, id); -} - -static void SubEvt_setDataError(void *my) -{ - SubEvt_setId(my, SubEvt_id(my) | 0x80000000UL); -} - -static void SubEvt_clrDataError(void *my) -{ - SubEvt_setId(my, SubEvt_id(my) & ~0x80000000UL); -} - -static uint32_t SubEvt_trigNr(const void *my) -{ - return SubEvt_hdrValue(my, SubEvtIdx_trigNr); -} - -static void SubEvt_setTrigNr(void *my, uint32_t trigNr) -{ - SubEvt_setHdrValue(my, SubEvtIdx_trigNr, trigNr); -} - -static uint32_t SubEvt_trigType_trb3(const void *my) -{ -/* get trb3 trigger type info in bits 4...7*/ - return ((HadTu_decoding(my) & 0xF0) >> 4) ; -} - - -static uint32_t SubEvt_decoding(const void *my) -{ -/* JAM: mask out the trb3 trigger type info in bits 4...7*/ - return (HadTu_decoding(my) & 0xFFFFFF0F); -} - -static void SubEvt_setDecoding(void *my, uint32_t decoding) -{ - /* JAM: save and restore trb3 trigger type info in bits 4...7*/ - uint32_t oldtriggertype= HadTu_decoding(my) & 0xF0; - HadTu_setDecoding(my, (decoding | oldtriggertype)); -} - - -void *newSubEvt(uint32_t decoding, uint32_t id, uint32_t trigNr); -void deleteSubEvt(void *my); -void *SubEvt_appendData(void *my, const void *data, size_t size); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/beamtime/trb/trbnet_client/Application.cpp b/beamtime/trb/trbnet_client/Application.cpp deleted file mode 100644 index 2aa810e73ca37bfb83a70970f96f650fd1581a1d..0000000000000000000000000000000000000000 --- a/beamtime/trb/trbnet_client/Application.cpp +++ /dev/null @@ -1,70 +0,0 @@ -#include "Application.hpp" -#include "TimesliceReceiver.hpp" -#include "TimesliceInputArchive.hpp" -#include <iostream> - -#include <sys/stat.h> -#include <boost/format.hpp> - -Application::Application(Parameters const& par) : _par(par) -{ - if (!_par.shm_identifier().empty()) { - _source.reset(new fles::TimesliceReceiver(_par.shm_identifier())); - } else { - fles::TimesliceInputArchive * inputArchive = new fles::TimesliceInputArchive(_par.input_archive()); - _source.reset(inputArchive); - - // quite ugly, but there's not better way to find out when the data was recorded - // actually, mtime should point to the timestamp, when data was last modified - // but let's ignore this for the moment - struct stat attrib; - stat(_par.input_archive().c_str(), &attrib); - - _trbBridge.setArchiveCreationTime(attrib.st_mtime); - _trbBridge.setMCSize(_par.MCSize() ); - _trbBridge.setOfflineProcessing(true); - } - - if (!_par.output_archive().empty()) - _trbBridge.openFile( _par.output_archive() ); - - if (_par.analyze()) { - _trbBridge.setFlags( _trbBridge.getFlags() | TrbBridge::SSEStructCheck ); - } - - if (_par.client_index() != -1) { - std::cout << "trbnet_client " << _par.client_index() << ": " << par.shm_identifier() << std::endl; - } -} - -Application::~Application() -{ - if (_par.client_index() != -1) { - std::cout << "trbnet_client " << _par.client_index() << ": "; - } - std::cout << "total timeslices processed: " << _count << std::endl; -} - -void Application::run() -{ - std::cout << _par.timesliceLimit() << std::endl; - - unsigned int skipCounter = 0; - - - while (auto timeslice = _source->get()) { - if (_par.skipTimeslices() <= skipCounter) { - _trbBridge.importTimeslice(*timeslice); - _count++; - } else { - skipCounter++; - } - - if ((_par.timesliceLimit() > 0) && (static_cast<unsigned int>(_par.timesliceLimit()) < _count)) { - std::cout << "Timeslice limit reached" << std::endl; - break; - } - } - - std::cout << _trbBridge.getCurrentStatistics().dump(); -} diff --git a/beamtime/trb/trbnet_client/Application.hpp b/beamtime/trb/trbnet_client/Application.hpp deleted file mode 100644 index a06774a951911453714183e4a2f102e6f23722c2..0000000000000000000000000000000000000000 --- a/beamtime/trb/trbnet_client/Application.hpp +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2012-2013 Jan de Cuveland <cmail@cuveland.de> -#pragma once - -#include "Parameters.hpp" -#include "TimesliceSource.hpp" -#include "TrbBridge.hpp" - -#include <memory> - -/// %Application base class. -class Application -{ -public: - explicit Application(Parameters const& par); - - Application(const Application&) = delete; - void operator=(const Application&) = delete; - - ~Application(); - - void run(); - -private: - Parameters const& _par; - - std::unique_ptr<fles::TimesliceSource> _source; -// std::unique_ptr<TimesliceAnalyzer> _analyzer; -// std::unique_ptr<TimesliceDebugger> _dump; - TrbBridge _trbBridge; - - uint64_t _count = 0; -}; diff --git a/beamtime/trb/trbnet_client/CMakeLists.txt b/beamtime/trb/trbnet_client/CMakeLists.txt deleted file mode 100644 index 71a75bfced715344760222c652cb660e28dbd32a..0000000000000000000000000000000000000000 --- a/beamtime/trb/trbnet_client/CMakeLists.txt +++ /dev/null @@ -1,51 +0,0 @@ -# Build the tsclient executable which is taken from -# git@code.compeng.uni-frankfurt.de:flesnet.git -# This executable uses the fles_ipc library to read files -# in the tca format -# This file is only called if the compiler provides c++11 support - -Set(CMAKE_CXX_FLAGS_BAK ${CMAKE_CXX_FLAGS}) - -# Add some extra compile warnings -Set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -Wextra -Winit-self -Wundef -Wold-style-cast -Woverloaded-virtual -Wwrite-strings -Wnon-virtual-dtor") - -Set(INCLUDE_DIRECTORIES -${CMAKE_CURRENT_SOURCE_DIR} -${CBMROOT_SOURCE_DIR}/external/ipc_legacy/ipc/src -) - -Include_Directories( ${INCLUDE_DIRECTORIES}) - -Include_Directories(SYSTEM - ${Boost_INCLUDE_DIR} - ${ZMQ_INCLUDE_DIR} -) - -Set(LINK_DIRECTORIES - ${Boost_LIBRARY_DIRS} - ${ZMQ_LIBRARY_DIR} -) - -Link_Directories( ${LINK_DIRECTORIES}) - -Set(SRCS -main.cpp -Application.cpp -Parameters.cpp -TrbBridge.cpp -TrbBridgeStatistics.cpp -TrbBridgeTrbNetHeaders.cpp -TrbBridgeFrame.cpp -TrbBridgeTransaction.cpp -) - -Set(EXE_NAME trbnet_client) -If(UNIX AND NOT APPLE) - Set(DEPENDENCIES fles_ipc_legacy boost_program_options ${CMAKE_THREAD_LIBS_INIT} zmq rt) -Else() - Set(DEPENDENCIES fles_ipc_legacy boost_program_options ${CMAKE_THREAD_LIBS_INIT} zmq) -EndIf() - -GENERATE_EXECUTABLE() - -Set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS_BAK}) diff --git a/beamtime/trb/trbnet_client/Parameters.cpp b/beamtime/trb/trbnet_client/Parameters.cpp deleted file mode 100644 index 70c52fd904eef318c66e40993bceaa3b8591e398..0000000000000000000000000000000000000000 --- a/beamtime/trb/trbnet_client/Parameters.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2012-2013 Jan de Cuveland <cmail@cuveland.de> - -#include "Parameters.hpp" -#include <boost/program_options.hpp> - -namespace po = boost::program_options; - -void Parameters::parse_options(int argc, char* argv[]) -{ - po::options_description desc("Allowed options"); - desc.add_options()("version,V", "print version string")( - "help,h", "produce help message")( - "client-index,c", po::value<int32_t>(&_client_index), - "index of this executable in the list of processor tasks")( - "analyze-pattern,a", po::value<bool>(&_analyze)->implicit_value(true), - "enable/disable pattern check")( - "dump-timslices,d", po::value<bool>(&_dump)->implicit_value(true), - "enable/disable timeslice dump")( - "skip-timeslices,f", po::value<uint32_t>(&_skipTSs), - "number of first timeslice to be imported. default: 0")( - "number-timeslices,n", po::value<int32_t>(&_limitTS), - "number of timeslices to be imported. -1 for unlimited. default: -1")( - "mc-size,m", po::value<uint32_t>(&_MCSize), - "applies only to offline unpacking as a time base. mc-size as set in flib.conf when archive was captured. default: 1250")( - "shm-identifier,s", po::value<std::string>(&_shm_identifier), - "shared memory identifier used for receiving timeslices")( - "input-archive,i", po::value<std::string>(&_input_archive), - "name of an input file archive to read")( - "output-archive,o", po::value<std::string>(&_output_archive), - "name of an output file archive to write"); - - po::variables_map vm; - po::store(po::parse_command_line(argc, argv, desc), vm); - po::notify(vm); - - if (vm.count("help")) { - std::cout << desc << std::endl; - exit(EXIT_SUCCESS); - } - - if (vm.count("version")) { - std::cout << "tsclient, version 0.0" << std::endl; - exit(EXIT_SUCCESS); - } - - int input_sources = vm.count("shm-identifier") + vm.count("input-archive"); - if (input_sources == 0) - throw ParametersException("no input source specified"); - if (input_sources > 1) - throw ParametersException("more than one input source specified"); - if (_limitTS == 0) - throw ParametersException("number-timeslices, n must not be zero. use negative value to disable limit and strictly positive value to limit number of timeslices"); -} diff --git a/beamtime/trb/trbnet_client/Parameters.hpp b/beamtime/trb/trbnet_client/Parameters.hpp deleted file mode 100644 index ef95678a83ce76a634ea498d208f2f90a4421bf1..0000000000000000000000000000000000000000 --- a/beamtime/trb/trbnet_client/Parameters.hpp +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2012-2013 Jan de Cuveland <cmail@cuveland.de> -#pragma once - -#include <stdexcept> -#include <cstdint> -#include <string> - -/// Run parameter exception class. -class ParametersException : public std::runtime_error -{ -public: - explicit ParametersException(const std::string& what_arg = "") - : std::runtime_error(what_arg) - { - } -}; - -/// Global run parameter class. -class Parameters -{ -public: - Parameters(int argc, char* argv[]) { parse_options(argc, argv); } - - Parameters(const Parameters&) = delete; - void operator=(const Parameters&) = delete; - - int32_t client_index() const { return _client_index; } - - std::string shm_identifier() const { return _shm_identifier; } - - std::string input_archive() const { return _input_archive; } - - std::string output_archive() const { return _output_archive; } - - bool analyze() const { return _analyze; } - - bool dump() const { return _dump; } - - uint32_t skipTimeslices() const {return _skipTSs;} - int32_t timesliceLimit() const {return _limitTS;} - uint32_t MCSize() const {return _MCSize;} -private: - void parse_options(int argc, char* argv[]); - - int32_t _client_index = -1; - - std::string _shm_identifier; - std::string _input_archive; - std::string _output_archive; - bool _analyze = false; - bool _dump = false; - - uint32_t _skipTSs = 0; - int32_t _limitTS = -1; - - uint32_t _MCSize = 1250; -}; diff --git a/beamtime/trb/trbnet_client/TrbBridge.cpp b/beamtime/trb/trbnet_client/TrbBridge.cpp deleted file mode 100644 index e3a549de4e87af1387b5a01d666d34d5bac99bb1..0000000000000000000000000000000000000000 --- a/beamtime/trb/trbnet_client/TrbBridge.cpp +++ /dev/null @@ -1,251 +0,0 @@ -#include "TrbBridge.hpp" -#include "MicrosliceDescriptor.hpp" -#include <iostream> -#include <sstream> -#include <boost/format.hpp> -#include <chrono> -#include <ctime> -#include <stdlib.h> -#include "TrbBridgeTrbNetHeaders.hpp" - -/* Construction & Destruction */ - TrbBridge::TrbBridge() - : _eventBuffer(1024 + 8) - ,_transactionBuffer(reinterpret_cast<uint16_t*>(_eventBuffer.data()) + 16) - ,_transaction(_transactionBuffer) - { - _eventNum = 0; - _flags = 0; - - srand(std::time(NULL)); - _runNum = rand(); - - _creationTimeMCCount = 0; - _offlineProcessing = false; - } - - TrbBridge::~TrbBridge() { - closeFile(); - } - -/* File handling */ - void TrbBridge::openFile(const std::string& filename) { - if (_filePtr) closeFile(); - _filePtr.reset( new std::ofstream(filename, std::ios::out | std::ios::trunc | std::ios::binary) ); - if (_filePtr) { - TrbBridgeTrbNetEventHeader evtHdr; - evtHdr.swappedEndianess = false; - evtHdr.timestamp = _getEventTime(); - evtHdr.runNumber = _runNum; - evtHdr.eventNumberPerFile = 0; - evtHdr.setSizeWithPadding(32); - - _eventBuffer.data() << evtHdr; - _eventBuffer[2] = 0x00010002; // first event in hld file has special id - - _filePtr->write(reinterpret_cast<char*> (_eventBuffer.data()), size_t(evtHdr.size) ); - } - } - - void TrbBridge::closeFile() { - if (!_filePtr) return; - - _filePtr->close(); - _filePtr.release(); - } - -/* Wrapper */ - void TrbBridge::setFlags(uint32_t f) { - _flags = f; - } - - uint32_t TrbBridge::getFlags() const { - return _flags; - } - -/* Stream frames in */ - void TrbBridge::_importFrame(const TrbBridgeFrame & frame, unsigned int retry) { - if (!retry) return; - - try { - _transaction << frame; - - } catch(std::exception& e) { - std::cerr << e.what() << std::endl; - - // all frames that went into this transaction are lost - _currentStats.incrementFramesDiscarded(_transaction.nextFrameNumberExpected()); - - _transaction.reset(); - - if (frame.isStartFrame()) { - _importFrame(frame, retry--); - } - - return; - } - - if (_transaction.isStarted() && frame.isStartFrame()) { - _currentStats.incrementTransactionsStarted(); - } - - if (!_transaction.isStarted()) { - _currentStats.incrementFramesSkipped(); - return; - } - - if (_transaction.isCompleted()) { - // add event header (very simple event building !) - // decode sub-event header - TrbBridgeTrbNetSubEventHeader subEvtHdr; - subEvtHdr << reinterpret_cast<uint32_t*>(_transactionBuffer); - - // build event header based on information gathered - TrbBridgeTrbNetEventHeader evtHdr; - evtHdr.swappedEndianess = subEvtHdr.swappedEndianess; - evtHdr.triggerType = 0x00002001; // TODO: trigger type missing; - evtHdr.eventNumberPerFile = ++_eventNum; - evtHdr.timestamp = _getEventTime(); - evtHdr.runNumber = _runNum; - - // set size and clear padding area - evtHdr.setSizeWithPadding(subEvtHdr.size + 32); - for(unsigned int i = (subEvtHdr.size+32) / sizeof(_eventBuffer[0]); i < evtHdr.size / sizeof(_eventBuffer[0]); i++) - _eventBuffer[i] = 0; - - _eventBuffer.data() << evtHdr; - /* - std::cout << boost::format("Completed transaction 0x%04x with % 4d bytes. Stored trigger number 0x%04x") - % _transaction.transactionNumber() - % _transaction.size() - % subEvtHdr.triggerNumber - << std::endl; - */ - - // write to hld file - if (_filePtr) - _filePtr->write(reinterpret_cast<char*>(_eventBuffer.data()), evtHdr.size); - - _currentStats.incrementTransactionsCompleted(); - - if (getFlags() & SSEStructCheck) { - try { - std::list<TrbBridgeTrbNetSubSubEventHeader> sse = TrbBridgeTrbNetSubSubEventHeader::extractSubSubEvents( - subEvtHdr, reinterpret_cast<uint32_t*> (_transactionBuffer)); - - /* - std::cout << "Found " << sse.size() << " sub-events: "; - for(auto it = sse.begin(); it != sse.end(); it++) - std::cout << boost::format("(id: 0x%04x, size: %d) ") % it->subSubEventId % it->size; - std::cout << std::endl; - */ - - // do whatever you want with your data - - } catch(std::exception& e) { - std::cerr << e.what() << std::endl; - _currentStats.incrementSSEStructureError(); - } - - } - - _transaction.reset(); - } - - - } - - - void TrbBridge::importTimeslice(const fles::Timeslice& ts) { - for (size_t c = 0; c < ts.num_components(); ++c) { - if (ts.num_microslices(c) == 0) { - std::cerr << "no microslices in TS " << ts.index() << ", component " - << c << std::endl; - return; - } - - for (size_t m = 0; m < ts.num_microslices(c); ++m) { - // iterate over microslice - auto msDescriptor = ts.descriptor(c, m); - auto msContent = reinterpret_cast<const uint16_t*>(ts.content(c, m)); - - // only consider generic TrbNet subsystem - if (msDescriptor.sys_id != flesnetSysId) - continue; - - unsigned int msInteralPtr = 16 / sizeof(*msContent); - while(msInteralPtr < msDescriptor.size / sizeof(*msContent)) { - // iterate over cbmnet frames with in microslice (padding handling just copied from tsclient) - uint8_t word_count = (msContent[msInteralPtr] & 0xff) + 1; - uint8_t padding_count = (4 - ((word_count + 1) & 0x3)) & 0x3; - ++msInteralPtr; - - // here the magic happens - _importFrame( TrbBridgeFrame(&msContent[msInteralPtr], word_count*2) ); - _currentStats.incrementFramesProcessed(); - - msInteralPtr += word_count + padding_count; - } - } - } - - _creationTimeMCCount += ts.num_microslices(0); - _currentStats.incrementTimeslicesProcessed(); - - std::time_t now = std::time(NULL); - if (_lastStatDump != now) { - std::cout << _currentStats.dump(); - _lastStatDump = now; - } - -// i dont care about duplication of mc in timeslices, so just discard a transaction between two timeslices ! - _transaction.reset(); - } - - std::time_t TrbBridge::_getEventTime(unsigned int delta) { - if (_offlineProcessing) { - double secondsPerMC = flibMCSizeGranularity * _MCSize; - unsigned int offsetSeconds = int( (_creationTimeMCCount + delta) * secondsPerMC ); - return _archiveCreationTime + offsetSeconds; // TODO: This is not C++ standard conform, but should work on all POSIX-compatible systems - } - - return std::time(NULL); - } - - -// Wrapper - unsigned int TrbBridge::runNumber() const { - return _runNum; - } - - void TrbBridge::setRunNumber(unsigned int num) { - _runNum = num; - } - - void TrbBridge::setOfflineProcessing(bool v) { - _offlineProcessing = v; - } - - bool TrbBridge::offlineProcessing() const { - return _offlineProcessing; - } - - void TrbBridge::setArchiveCreationTime(std::time_t & ts) { - _archiveCreationTime = ts; - } - - std::time_t TrbBridge::archiveCreationTime() const { - return _archiveCreationTime; - } - - void TrbBridge::setMCSize(unsigned int mcsize) { - _MCSize = mcsize; - } - - unsigned int TrbBridge::MCSize() const { - return _MCSize; - } - - const TrbBridgeStatistics & TrbBridge::getCurrentStatistics() const { - return _currentStats; - } diff --git a/beamtime/trb/trbnet_client/TrbBridge.hpp b/beamtime/trb/trbnet_client/TrbBridge.hpp deleted file mode 100644 index ea04badd901f871845784e142c214f228d1f9371..0000000000000000000000000000000000000000 --- a/beamtime/trb/trbnet_client/TrbBridge.hpp +++ /dev/null @@ -1,75 +0,0 @@ -#pragma once - -#include <fstream> -#include <memory> - -#include "Timeslice.hpp" -#include "TrbBridgeTransaction.hpp" -#include "TrbBridgeStatistics.hpp" - -#include <chrono> - -/** - * Functions as "glue logic" between the flesnet-ipc, the user and the TrbBridge code - */ -class TrbBridge { -public: - TrbBridge(); - ~TrbBridge(); - - void openFile(const std::string& filename); - void closeFile(); - - void setFlags(uint32_t flags); - uint32_t getFlags() const; - - void importTimeslice(const fles::Timeslice& ts); - - unsigned int runNumber() const; - void setRunNumber(unsigned int num); - - // Creation Time - void setArchiveCreationTime(std::time_t &); - std::time_t archiveCreationTime() const; - - void setOfflineProcessing(bool v); - bool offlineProcessing() const; - - void setMCSize(unsigned int mcsize); - unsigned int MCSize() const; - - constexpr static int flesnetSysId = 0x90; - constexpr static uint32_t SSEStructCheck = 0x1; - constexpr static double flibMCSizeGranularity = 8e-9; // seconds per MCSize count - - const TrbBridgeStatistics & getCurrentStatistics() const; - -private: - void _importFrame(const TrbBridgeFrame & frame, unsigned int retry = 1); - - std::vector<uint32_t> _eventBuffer; - uint16_t* _transactionBuffer; - - std::unique_ptr<std::ofstream> _filePtr; - TrbBridgeTransaction _transaction; - - unsigned int _eventNum; - unsigned int _runNum; - unsigned int _time; - unsigned int _date; - - unsigned int _flags; - - TrbBridgeStatistics _currentStats; - TrbBridgeStatistics _lastStats; - - // creation time required only for offline processing - bool _offlineProcessing; - unsigned int _MCSize; - - unsigned int _creationTimeMCCount; - std::time_t _archiveCreationTime; - std::time_t _getEventTime(unsigned int delta = 0); - - std::time_t _lastStatDump; -}; \ No newline at end of file diff --git a/beamtime/trb/trbnet_client/TrbBridgeFrame.cpp b/beamtime/trb/trbnet_client/TrbBridgeFrame.cpp deleted file mode 100644 index e58671d3abde4f47dc1d016efab822d87deb7a4f..0000000000000000000000000000000000000000 --- a/beamtime/trb/trbnet_client/TrbBridgeFrame.cpp +++ /dev/null @@ -1,97 +0,0 @@ -#include "TrbBridgeFrame.hpp" -#include <boost/format.hpp> -#include <sstream> - -TrbBridgeFrame::TrbBridgeFrame(const uint16_t* msContent, size_t frameLength) { - if (frameLength < 4 || frameLength > 64 || frameLength & 1) throw TrbBrideFrameException("Invalid frameLength"); - _content = msContent; - _length = frameLength; -} - - -const uint16_t* TrbBridgeFrame::payload() const { - return _content + 1; -} - -size_t TrbBridgeFrame::payloadSize() const { - return _length - 2; // subtract header length -} - -uint16_t TrbBridgeFrame::frameNumber() const { - if (isStartFrame() || isStopFrame()) - return 0; - - return *_content & 0x7f; -} - -uint16_t TrbBridgeFrame::transactionNumber() const { - if (isStartFrame() || isStopFrame()) - return *_content & 0x0fff; - - // inner frame: bits 11 .. 7 - return (_content[0] >> 7) & 0x1f; -} - - -bool TrbBridgeFrame::isStartFrame() const { - return (_content[0] >> 14) & 1; -} - -bool TrbBridgeFrame::isStopFrame() const { - return (_content[0] >> 15) & 1; -} - -bool TrbBridgeFrame::matchesFrameNumber(uint16_t frameNo) const { - if (isStartFrame()) - return frameNo == 0; - - if (isStopFrame()) - return true; - - return (frameNo & 0x7f) == frameNumber(); -} - - -bool TrbBridgeFrame::matchesTransactionNumber(uint16_t transactionNo) const { - if (isStartFrame() || isStopFrame()) - return (transactionNo & 0x0fff) == transactionNumber(); - - return (transactionNo & 0x1f) == transactionNumber(); -} - - -std::string TrbBridgeFrame::dump() const { - std::stringstream ss; - - ss << boost::format("Frame (Start: %s, Stop: %s, TransNo: % 4d, FrameNo: ") % isStartFrame() % isStopFrame() % transactionNumber(); - if (isStopFrame()) - ss << "???"; - else - ss << boost::format("% 3d") % frameNumber(); - - ss << boost::format(", size: % 2d bytes): ") % payloadSize(); - - for(unsigned int i=0; i < payloadSize()/2; i++) { - if (i % 16 == 0) - ss << std::endl; - ss << boost::format(" [% 2d] %04x") % (i+1) % payload()[i]; - } - - ss << std::endl; - - return ss.str(); -} - -TrbBrideFrameException::TrbBrideFrameException(const std::string& what_arg, const TrbBridgeFrame* frameInvolved) { - if (frameInvolved) { - std::stringstream ss; - ss << what_arg << std::endl << "Related to " << frameInvolved->dump(); - _what = ss.str(); - } else { - _what = what_arg; - } -} - - - - diff --git a/beamtime/trb/trbnet_client/TrbBridgeFrame.hpp b/beamtime/trb/trbnet_client/TrbBridgeFrame.hpp deleted file mode 100644 index 7c0ab36bf0a379160942fafc111cf6cefeedb21e..0000000000000000000000000000000000000000 --- a/beamtime/trb/trbnet_client/TrbBridgeFrame.hpp +++ /dev/null @@ -1,81 +0,0 @@ -#pragma once - -#include <exception> -#include <string> - -/** - * Read-only wrapper for a CBMNet frame extracted from a microslice interpreting the TrbNet bridge's header - */ -class TrbBridgeFrame { -public: - TrbBridgeFrame(const uint16_t* msContent, size_t frameLength); - - /** - * Generate human-readable representation of frame - */ - std::string dump() const; - - /** - * Pointer to payload area of the frame (i.e. excl. header) - */ - const uint16_t* payload() const; - - /** - * Payload size in bytes - */ - size_t payloadSize() const; - - /** - * Frame number extracted from header. - * @return 0 if start frame or undefined - */ - uint16_t frameNumber() const; - - /** - * Transaction number extracted from header. - * Number is truncated for inner frames - */ - uint16_t transactionNumber() const; - - /** - * @return true, if frame header indicates a start frame - */ - bool isStartFrame() const; - - /** - * @return true, if frame header indicates a stop frame - */ - bool isStopFrame() const; - - /** - * Matches the frame number incl. in header against a frame number provided - * modulo the number of bits in the header's field. Hence, in case of stop - * frame, the function always returns true. - * @return true if frameNo & header mask matches frame - */ - bool matchesFrameNumber(uint16_t frameNo) const; - - /** - * Matches the transaction number incl. in header against a number provided - * modulo the number of bits in the header's field. Thus, the significance of - * a start and stop frame is higher compared to inner frames. - * @return true if transactionNo & mask matches frames - */ - bool matchesTransactionNumber(uint16_t transactionNo) const; - -private: - const uint16_t* _content; /**< Pointer first data word of frame (i.e. the header) */ - size_t _length; /**< Length of frame as provided in constructor. IN BYTES */ -}; - -class TrbBrideFrameException : public std::exception { -public: - explicit TrbBrideFrameException(const std::string& what_arg = "", const TrbBridgeFrame* frameInvolved = NULL); - virtual const char* what() const throw() { - return _what.c_str(); - } - -private: - std::string _what; -}; - \ No newline at end of file diff --git a/beamtime/trb/trbnet_client/TrbBridgeStatistics.cpp b/beamtime/trb/trbnet_client/TrbBridgeStatistics.cpp deleted file mode 100644 index fdb0133005b4d82b55a669f44c2ab14899544b51..0000000000000000000000000000000000000000 --- a/beamtime/trb/trbnet_client/TrbBridgeStatistics.cpp +++ /dev/null @@ -1,74 +0,0 @@ -#include "TrbBridgeStatistics.hpp" -#include <sstream> -#include <boost/format.hpp> - -// Init - TrbBridgeStatistics::TrbBridgeStatistics() { - reset(); - } - - void TrbBridgeStatistics::reset() { - _framesProcessed = 0; - _framesAssigned = 0; - _framesSkipped = 0; - _framesDiscarded = 0; - _transactionsStarted = 0; - _transactionsCompleted = 0; - _SSEStructureError = 0; - _timeslicesProcessed = 0; - } - -// Output statistics - std::string TrbBridgeStatistics::dump(const TrbBridgeStatistics& ref) const { - std::stringstream ss; - ss << ( - boost::format("TS processed: % 6d, Frames process: % 6d, skipped: % 6d, assigned: % 6d, discarded: % 6d Transactions started: % 4d, completed % 4d, SSE-Errors: % 4d") - % (_timeslicesProcessed - ref._timeslicesProcessed) - % (_framesProcessed - ref._framesProcessed) - % (_framesSkipped - ref._framesSkipped) - % (_framesAssigned - ref._framesAssigned) - % (_framesDiscarded - ref._framesDiscarded) - % (_transactionsStarted - ref._transactionsStarted) - % (_transactionsCompleted - ref._transactionsCompleted) - % (_SSEStructureError - ref._SSEStructureError) - ) << std::endl; - return ss.str(); - } - - std::string TrbBridgeStatistics::dump() const { - TrbBridgeStatistics nil; - return dump(nil); - } - -// Boring Wrappers - void TrbBridgeStatistics::incrementTimeslicesProcessed(unsigned int long delta) { - _timeslicesProcessed += delta; - } - - void TrbBridgeStatistics::incrementTransactionsStarted(unsigned int long delta) { - _transactionsStarted += delta; - } - - void TrbBridgeStatistics::incrementTransactionsCompleted(unsigned int long delta) { - _transactionsCompleted += delta; - } - - void TrbBridgeStatistics::incrementFramesProcessed(unsigned int long delta) { - _framesProcessed += delta; - } - - void TrbBridgeStatistics::incrementFramesSkipped(unsigned int long delta) { - _framesSkipped += delta; - } - - void TrbBridgeStatistics::incrementFramesDiscarded(unsigned int long delta) { - _framesDiscarded += delta; - } - - void TrbBridgeStatistics::incrementFramesAssigned(unsigned int long delta) { - _framesAssigned += delta; - } - - void TrbBridgeStatistics::incrementSSEStructureError(unsigned int long delta) { - _SSEStructureError += delta; - } \ No newline at end of file diff --git a/beamtime/trb/trbnet_client/TrbBridgeStatistics.hpp b/beamtime/trb/trbnet_client/TrbBridgeStatistics.hpp deleted file mode 100644 index 5990a82a714001f051a67ff6cb3458b9a35221f1..0000000000000000000000000000000000000000 --- a/beamtime/trb/trbnet_client/TrbBridgeStatistics.hpp +++ /dev/null @@ -1,39 +0,0 @@ -#pragma once -#include <string> - -class TrbBridgeStatistics { -public: - TrbBridgeStatistics(); - - std::string dump(const TrbBridgeStatistics& ref) const; - std::string dump() const; - - void reset(); - - void incrementTimeslicesProcessed(unsigned int long delta=1); - - void incrementFramesProcessed(unsigned int long delta=1); - void incrementFramesSkipped(unsigned int long delta=1); - void incrementFramesDiscarded(unsigned int long delta=1); - void incrementFramesAssigned(unsigned int long delta=1); - - void incrementTransactionsStarted(unsigned int long delta=1); - void incrementTransactionsCompleted(unsigned int long delta=1); - void incrementTransactionsInvalid(unsigned int long delta=1); - - void incrementSSEStructureError(unsigned int long delta=1); - - -private: - unsigned long _timeslicesProcessed; - - unsigned long _framesProcessed; - unsigned long _framesAssigned; - unsigned long _framesSkipped; - unsigned long _framesDiscarded; - - unsigned long _transactionsStarted; - unsigned long _transactionsCompleted; - - unsigned long _SSEStructureError; -}; diff --git a/beamtime/trb/trbnet_client/TrbBridgeTransaction.cpp b/beamtime/trb/trbnet_client/TrbBridgeTransaction.cpp deleted file mode 100644 index 29e7be8b02012d0ead5184846a6d23d2a1e20ad2..0000000000000000000000000000000000000000 --- a/beamtime/trb/trbnet_client/TrbBridgeTransaction.cpp +++ /dev/null @@ -1,187 +0,0 @@ -#include "TrbBridgeTransaction.hpp" -#include <algorithm> -#include <iostream> -#include <assert.h> - -#include <sstream> -#include <boost/format.hpp> - -#include "TrbBridgeTrbNetHeaders.hpp" - -TrbBridgeTransaction::TrbBridgeTransaction(uint16_t* buffer) { - _buffer = buffer; - reset(); -} - -void TrbBridgeTransaction::reset() { - _size = 0; - _writeIdx = 0; - _frameNumberExpected = 0; - _completed = false; -} - -TrbBridgeTransaction TrbBridgeTransaction::operator<< (const TrbBridgeFrame & frame) { - if (!_buffer) - throw TrbBridgeTransactionException("Cannout append frame to buffer-less transaction", this, &frame); - -// deal with start frames - if (isCompleted()) - throw TrbBridgeTransactionException("Cannot append frame to completed transaction", this, &frame); - - if (!isStarted() && !frame.isStartFrame()) { - // we're waiting for a start frame, so let's skip this frame - // because this can happend when synchronising to a stream, this is not considered an error - - return *this; - } - - if (isStarted() && frame.isStartFrame()) - throw TrbBridgeTransactionException("Cannot process second start frame", this, &frame); - - -// check transaction & frame number (if necessary) - size_t wordsFromFrame = frame.payloadSize() / 2; - if (!isStarted()) { - _transactionNumber = frame.transactionNumber(); - _size=(frame.payload()[0] << 16) | frame.payload()[1]; // little quirk to convert the median endian input into little endian - - } else { - if (!frame.matchesTransactionNumber(_transactionNumber)) - throw TrbBridgeTransactionException("Tried to append frame with wrong transaction number", this, &frame); - - if (!frame.matchesFrameNumber(_frameNumberExpected)) - throw TrbBridgeTransactionException("Tried to append frame with wrong frame number", this, &frame); - - - // check memory boundaries - const size_t wordsLeftsInTransaction = size() / 2 - _writeIdx; - - if (wordsFromFrame > wordsLeftsInTransaction) { - if (frame.isStopFrame() && wordsFromFrame - wordsLeftsInTransaction <= 2 && wordsFromFrame == 3) { - // the excess seems to be padding .. let's have a closer look - - for (unsigned int i=wordsLeftsInTransaction; i < wordsFromFrame; i++) - if (frame.payload()[i] != 0xaaaa) - throw TrbBridgeTransactionException("Unexpected padding", this, &frame); - - wordsFromFrame = wordsLeftsInTransaction; - - } else { - throw TrbBridgeTransactionException("Frame too long for transaction", this, &frame); - - } - } - } -// copy data - for(unsigned int i=0; i < wordsFromFrame; i++) - // THIS STEP IS CRUCIAL: TrbNet sends MSB big-endian words, while FLIB serves - // little-endian half-words; so have to swap the half-words in each word and - // obtain a little-endian word - _buffer[ _writeIdx++ ^ 1 ] = frame.payload()[i]; - - - _frameNumberExpected++; - -// check for valid header length - if (frame.isStartFrame()) { - if (size() > MAX_SIZE || size() & 0x3) { - std::cout << size() << std::endl; - throw TrbBridgeTransactionException("Start frame indicates an unsupported transaction length", 0, &frame); - } - } - -// close transaction ? - if (_writeIdx == size() / 2) { - if (!frame.isStopFrame()) - throw TrbBridgeTransactionException("Transaction completed without stop frame", this, &frame); - - _completed = true; - - } else if (frame.isStopFrame()) { - throw TrbBridgeTransactionException("Premature stop frame", this, &frame); - - } - - return *this; -} - -bool TrbBridgeTransaction::isStarted() const { - return _writeIdx != 0; -} - -bool TrbBridgeTransaction::isCompleted() const { - return _completed; -} - -uint16_t* TrbBridgeTransaction::buffer() { - return _buffer; -} - -const uint16_t* TrbBridgeTransaction::buffer() const { - return const_cast<const uint16_t*> (_buffer); -} - -uint32_t TrbBridgeTransaction::size() const { - if (!_buffer) - return 0; - - if (!isStarted()) - throw TrbBridgeTransactionException("TrbBridgeTransaction::size() is available only, once a start frame was processed"); - - return _size; -} - -uint16_t TrbBridgeTransaction::transactionNumber() const { - if (!isStarted()) - throw TrbBridgeTransactionException("TrbBridgeTransaction::transactionNumber() is available only, once a start frame was processed"); - - return _transactionNumber; -} - -uint16_t TrbBridgeTransaction::nextFrameNumberExpected() const { - if (isCompleted()) - return 0; - - return _frameNumberExpected; -} - -std::string TrbBridgeTransaction::dump() const { - if (!isStarted()) - return "Transaction: Not started\n"; - - std::stringstream ss; - - ss << boost::format("Transaction: %s (TransNo %d, size: % 4d)") - % (isCompleted() ? "completed" : "pending") - % transactionNumber() - % size() - << std::endl; - - for(unsigned int i=0; i< size()/2; i++) { - if (i % 8 == 0 && i) - ss << std::endl; - - if (i < _writeIdx) - ss << boost::format(" [% 4d] 0x%04x") % i % _buffer[i]; - else - ss << boost::format(" [% 4d] .recv.") % i; - } - - return ss.str(); -} - -TrbBridgeTransactionException::TrbBridgeTransactionException(const std::string& what_arg, const TrbBridgeTransaction* involvedTransaction, const TrbBridgeFrame* involvedFrame) { - if (involvedTransaction || involvedFrame) { - std::stringstream ss; - ss << what_arg << std::endl; - if (involvedTransaction) - ss << "Involves " << involvedTransaction->dump() << std::endl; - - if (involvedFrame) - ss << "Involves " << involvedFrame->dump(); - - _what = ss.str(); - } else { - _what = what_arg; - } -} diff --git a/beamtime/trb/trbnet_client/TrbBridgeTransaction.hpp b/beamtime/trb/trbnet_client/TrbBridgeTransaction.hpp deleted file mode 100644 index f5e4bea70ed2a2475fe874ef58fed81a6ca3b7f6..0000000000000000000000000000000000000000 --- a/beamtime/trb/trbnet_client/TrbBridgeTransaction.hpp +++ /dev/null @@ -1,119 +0,0 @@ -#pragma once - -#include <exception> -#include <string> -#include "TrbBridgeFrame.hpp" - -/** - * The class implements the merging of several frames into a complete transaction. - */ -class TrbBridgeTransaction { -public: - /** - * Generates an empty transaction w/o buffer. - * You cannot use this transaction ! - */ - TrbBridgeTransaction() { - TrbBridgeTransaction(0); - } - - /** - * Generates an empty transaction - * - * @param buffer Pointer to a sufficiently large buffer area (>= MAX_SIZE) - */ - TrbBridgeTransaction(uint16_t* buffer); - - /** - * Generate human-readable representation of the transaction - */ - std::string dump() const; - - /** - * Empties a transaction to start over (same state as new creation) - */ - void reset(); - - /** - * Append a frame to the transaction. Function automatically handles start/stop frames. - * Once a transaction has started, it only accepts frames with the same transaction no. - * - * @param frame Frame to append - */ - TrbBridgeTransaction operator<< (const TrbBridgeFrame & frame); - - /** - * Indicates whether a start frame was found yet - * - * @return true, if start frame was detected - */ - bool isStarted() const; - - /** - * Indicates whether a valid stop frame was found yet. - * This implies, that the transaction seemes complete and no errors have been found. - * - * @return true, if transaction seems complete - */ - bool isCompleted() const; - - /** - * @return Pointer provided in constructor - */ - uint16_t* buffer(); - - /** - * @return Pointer provided in constructor - */ - const uint16_t* buffer() const; - - /** - * Size of transaction (incl. sub-event header) in bytes - * - * @return if isStarted() length found in sub-event header, 0 otherwise - */ - uint32_t size() const; - - - /** - * Transaction Number - * - * @return if isStarted(): transaction number, 0 otherwise - */ - uint16_t transactionNumber() const; - - /** - * Frame Number - * - * @return if isStarted(): transaction number, 0 otherwise - */ - uint16_t nextFrameNumberExpected() const; - - /** - * Maximal transaction size in bytes. The class wont accept frame that exceed this boundary, - * nor will it process a start frame indicating a larger transaction. - * Take care, that the buffer provided to the constructor can fit this size. - */ - constexpr static size_t MAX_SIZE = 4096; - -private: - uint16_t* _buffer; /**< Write buffer, as provided in constructor */ - size_t _writeIdx; /**< Index to first empty word in buffer */ - size_t _size; /**< Size gathered upon importing the start frame */ - - bool _completed; /**< Indicates that all frame belonging to this transaction have been received w/o framing errors */ - - uint16_t _transactionNumber; /**< Transaction Number contained in start frame. Only valid if isStarted() */ - uint16_t _frameNumberExpected; /**< Frame Number of next frame expected */ -}; - -class TrbBridgeTransactionException : public std::exception { -public: - explicit TrbBridgeTransactionException(const std::string& what_arg = "", const TrbBridgeTransaction* involvedTransaction = NULL, const TrbBridgeFrame* involvedFrame = NULL); - virtual const char* what() const throw() { - return _what.c_str(); - } - -private: - std::string _what; -}; diff --git a/beamtime/trb/trbnet_client/TrbBridgeTrbNetHeaders.cpp b/beamtime/trb/trbnet_client/TrbBridgeTrbNetHeaders.cpp deleted file mode 100644 index 0557eda1d4fbe79ec00046010927cc677d9b68e1..0000000000000000000000000000000000000000 --- a/beamtime/trb/trbnet_client/TrbBridgeTrbNetHeaders.cpp +++ /dev/null @@ -1,165 +0,0 @@ -#include "TrbBridgeTrbNetHeaders.hpp" -#include <ctime> - -template < typename MAJOR, typename MINOR = uint8_t > -static MAJOR _swapEndianess(MAJOR a) { - MAJOR b; - MINOR* src = reinterpret_cast<MINOR*>(&a); - MINOR* dest = reinterpret_cast<MINOR*>(&b); - - constexpr unsigned int steps = sizeof(MAJOR)/sizeof(MINOR); - - for(unsigned int i=0; i<steps; i++) - dest[i] = src[steps-1 - i]; - - return b; -} - -/************************************************* - * EventHeader - *************************************************/ - -size_t TrbBridgeTrbNetEventHeader::setSizeWithPadding(size_t sizeWoPadding) { - size_t padding = 0; - if (sizeWoPadding & 0x7) - padding = 8 - (sizeWoPadding & 0x7); - - size = sizeWoPadding + padding; - return padding; -} - - -void TrbBridgeTrbNetEventHeader::writeToBuffer(uint32_t *buffer) const { - struct tm *parts = std::localtime(×tamp); - buffer[0] = size; - buffer[1] = 0x00030001; // TODO: dis says there's a version included, but cannot find it in files generated by evt builder - buffer[2] = triggerType; - buffer[3] = eventNumberPerFile; - - buffer[4] = ((parts->tm_year & 0xff) << 16) | (parts->tm_mon << 8) | (parts->tm_mday << 0); - buffer[5] = (parts->tm_hour << 16) | (parts->tm_min << 8) | (parts->tm_sec << 0); - buffer[6] = runNumber; - buffer[7] = 0; - - if (swappedEndianess) - for(unsigned int i=0; i<8; i++) - buffer[i] = _swapEndianess(buffer[i]); -} - -void TrbBridgeTrbNetEventHeader::loadFromBuffer(const uint32_t* buffer) { - uint32_t* src = const_cast<uint32_t*>(buffer); - struct tm parts; - - if (buffer[1] > 0x100000) { - // need to swap endianess - src = new uint32_t[8]; - for(unsigned int i = 0; i < 8; i++) - src[i] = _swapEndianess(buffer[i]); - - swappedEndianess = true; - } else { - swappedEndianess = false; - } - - size = src[0]; - triggerType = uint16_t(src[2]); - eventNumberPerFile = src[3]; - runNumber = src[6]; - - parts.tm_year = (src[4] >> 16) & 0xff; - parts.tm_mon = (src[4] >> 8) & 0xff; - parts.tm_mday = (src[4] >> 0) & 0xff; - - parts.tm_hour = (src[5] >> 16) & 0xff; - parts.tm_min = (src[5] >> 8) & 0xff; - parts.tm_sec = (src[5] >> 0) & 0xff; - - timestamp = std::mktime(&parts); - - if (src != buffer) delete[] src; -} - -TrbBridgeTrbNetEventHeader TrbBridgeTrbNetEventHeader::operator<<(const uint32_t* buffer) { - loadFromBuffer(buffer); - return *this; -} - -uint32_t* operator<<(uint32_t* buffer, const TrbBridgeTrbNetEventHeader & evtHdr) { - evtHdr.writeToBuffer(buffer); - return buffer; -} - -/************************************************* - * SubEventHeader - *************************************************/ - -void TrbBridgeTrbNetSubEventHeader::writeToBuffer(uint32_t *buffer) const { - buffer[0] = size; - buffer[1] = 0x00020001 | ((triggerType & 0xf) << 4); - buffer[2] = subEventId; - buffer[3] = (triggerNumber << 8) | triggerCode; - - if (swappedEndianess) - for(unsigned int i=0; i<4; i++) - buffer[i] = _swapEndianess(buffer[i]); -} - -void TrbBridgeTrbNetSubEventHeader::loadFromBuffer(const uint32_t* buffer) { - uint32_t* src = const_cast<uint32_t*>(buffer); - - if (buffer[1] > 0x100000) { - // need to swap endianess - src = new uint32_t[4]; - for(unsigned int i = 0; i < 4; i++) - src[i] = _swapEndianess(buffer[i]); - - swappedEndianess = true; - } else { - swappedEndianess = false; - } - - size = src[0]; - triggerType = (src[1] >> 4) & 0xf; - subEventId = src[2]; - triggerCode = uint8_t(src[3]); - triggerNumber = src[3] >> 8; - - if (src != buffer) delete[] src; -} - -TrbBridgeTrbNetSubEventHeader TrbBridgeTrbNetSubEventHeader::operator<<(const uint32_t* buffer) { - loadFromBuffer(buffer); - return *this; -} -uint32_t* operator<<(uint32_t* buffer, const TrbBridgeTrbNetSubEventHeader & subEvtHdr) { - subEvtHdr.writeToBuffer(buffer); - return buffer; -} - -/************************************************* - * SubEventHeader - *************************************************/ -TrbBridgeTrbNetSubSubEventHeader::TrbBridgeTrbNetSubSubEventHeader(unsigned int ssEvtId, unsigned int sze, uint32_t* buf) - : subSubEventId(ssEvtId) - , size(sze) - , payload(buf) -{} - -std::list<TrbBridgeTrbNetSubSubEventHeader> TrbBridgeTrbNetSubSubEventHeader::extractSubSubEvents( - const TrbBridgeTrbNetSubEventHeader & subEventHeader, uint32_t* buffer) throw (TrbBridgeTrbNetHeaderException) { - std::list<TrbBridgeTrbNetSubSubEventHeader> result; - - unsigned int wordIdx = 4; // skip sub-event header - while(wordIdx < subEventHeader.size/4) { - uint16_t id = buffer[wordIdx] & 0xffff; - unsigned int sseSize = 4 + 4*(buffer[wordIdx]>>16); // length (excl. header in words) -> size (incl. header in bytes) - result.push_back( TrbBridgeTrbNetSubSubEventHeader( id, sseSize, &buffer[wordIdx+1]) ); - - wordIdx += sseSize / 4; - } - - if (wordIdx != subEventHeader.size/4) - throw TrbBridgeTrbNetHeaderException("Sum of sub-sub-event length exceeds sub-event size"); - - return result; -} diff --git a/beamtime/trb/trbnet_client/TrbBridgeTrbNetHeaders.hpp b/beamtime/trb/trbnet_client/TrbBridgeTrbNetHeaders.hpp deleted file mode 100644 index ba7be8d07e1bcb857699f855825b44286d42cc14..0000000000000000000000000000000000000000 --- a/beamtime/trb/trbnet_client/TrbBridgeTrbNetHeaders.hpp +++ /dev/null @@ -1,108 +0,0 @@ -#pragma once -#include <chrono> -#include <list> -#include <string> -#include <exception> - -/* header definitions are based on - * Development and Implementation of a New Trigger and - * Data Acquisition System for the HADES Detector (2012) - * by Jan Michel - * chapter 5.1 - */ - - -class TrbBridgeTrbNetHeaderException : public std::exception { -public: - explicit TrbBridgeTrbNetHeaderException(const std::string& what_arg = "") : _what(what_arg) {} - virtual const char* what() const throw() {return _what.c_str();} - -private: - std::string _what; -}; - -struct TrbBridgeTrbNetEventHeader { - uint32_t size; /**< size in bytes incl header and padding (should by dividable by 8 but not enforced here */ - uint16_t triggerType; - uint32_t eventNumberPerFile; /**< i-th event in hld file */ - std::time_t timestamp; - uint32_t runNumber; /**< random run number that all events in an hld file share */ - - bool swappedEndianess; - - /** - * Adds padding (if necessary) and sets size. - * @return size of padding required in bytes - */ - size_t setSizeWithPadding(size_t sizeWoPadding); - - - /** - * Write values defined above into buffer. - * - * @param buffer Destination to write to; require >=32 bytes of space - */ - void writeToBuffer(uint32_t *buffer) const; - - /** - * Load values defined above from buffer - * - * @param buffer Pointer to first word of header - */ - void loadFromBuffer(const uint32_t* buffer); - - /** - * synonym for loadFromBuffer. - */ - TrbBridgeTrbNetEventHeader operator<<(const uint32_t* buffer); -}; - -uint32_t* operator<<(uint32_t* buffer, const TrbBridgeTrbNetEventHeader & evtHdr); - - -struct TrbBridgeTrbNetSubEventHeader { - uint32_t size; /**< size in bytes incl header and padding (should by dividable by 8 but not enforced here */ - uint16_t subEventId; /**< "endpoint id" */ - uint32_t triggerNumber; /**< sequential trigger number generated by CTS */ - uint8_t triggerCode; /**< random trigger code generated by CTS */ - uint8_t triggerType; /**< not specified, but GbE and CBMNet bridge include it never-the-less */ - - bool swappedEndianess; - - /** - * Write values defined above into buffer. - * - * @param buffer Destination to write to; require >=16 bytes of space - */ - void writeToBuffer(uint32_t *buffer) const; - - /** - * Load values defined above from buffer - * - * @param buffer Pointer to first word of header - */ - void loadFromBuffer(const uint32_t* buffer); - - /** - * synonym for loadFromBuffer. - */ - TrbBridgeTrbNetSubEventHeader operator<<(const uint32_t* buffer); -}; - -uint32_t* operator<<(uint32_t* buffer, const TrbBridgeTrbNetSubEventHeader & subEvtHdr); - -struct TrbBridgeTrbNetSubSubEventHeader { - uint16_t subSubEventId; - uint16_t size; /**< size in bytes incl. header */ - uint32_t* payload; - - TrbBridgeTrbNetSubSubEventHeader(unsigned int ssEvtId=0, unsigned int size=0, uint32_t* payload=0); - - /** - * Searches for all sub-sub-events with-in an sub-event - * @param subEventHeader - * @param buffer Pointer to the first word of the sub-event (i.e. the header) - * @return list of sub-sub-events found - */ - static std::list<TrbBridgeTrbNetSubSubEventHeader> extractSubSubEvents(const TrbBridgeTrbNetSubEventHeader & subEventHeader, uint32_t* buffer) throw (TrbBridgeTrbNetHeaderException); -}; diff --git a/beamtime/trb/trbnet_client/main.cpp b/beamtime/trb/trbnet_client/main.cpp deleted file mode 100644 index d1ed82f27c003616535ff78c4d41c0b141d8f7eb..0000000000000000000000000000000000000000 --- a/beamtime/trb/trbnet_client/main.cpp +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2012-2013 Jan de Cuveland <cmail@cuveland.de> - -#include "Parameters.hpp" -#include "Application.hpp" -#include <iostream> - -int main(int argc, char* argv[]) -{ - try - { - Parameters par(argc, argv); - Application app(par); - app.run(); - } - catch (std::exception const& e) - { - std::cerr << "FATAL: " << e.what() << std::endl; - return EXIT_FAILURE; - } - - return EXIT_SUCCESS; -} diff --git a/beamtime/trb/trbnet_exe/Application.cpp b/beamtime/trb/trbnet_exe/Application.cpp deleted file mode 100644 index 9e32705e351486352b7fbec8d8daf488e679ded2..0000000000000000000000000000000000000000 --- a/beamtime/trb/trbnet_exe/Application.cpp +++ /dev/null @@ -1,79 +0,0 @@ -#include "Application.hpp" -#include "TimesliceReceiver.hpp" -#include "TimesliceInputArchive.hpp" -#include "StorableTimeslice.hpp" -#include <iostream> - -#include <sys/stat.h> -#include <boost/format.hpp> - -Application::Application(Parameters const& par) - : _par(par) - , _source() - , _trbBridge() - -{ - if (!_par.shm_identifier().empty()) { - _source.reset(new fles::TimesliceReceiver(_par.shm_identifier())); - } else { - fles::TimesliceInputArchive * inputArchive = new fles::TimesliceInputArchive(_par.input_archive()); - _source.reset(inputArchive); - - // quite ugly, but there's not better way to find out when the data was recorded - // actually, mtime should point to the timestamp, when data was last modified - // but let's ignore this for the moment - struct stat attrib; - stat(_par.input_archive().c_str(), &attrib); - - _trbBridge.setArchiveCreationTime(attrib.st_mtime); - _trbBridge.setMCSize(_par.MCSize() ); - _trbBridge.setOfflineProcessing(true); - } - - if (!_par.output_archive().empty()) - _trbBridge.openFile( _par.output_archive() ); - - if (_par.analyze()) { - _trbBridge.setFlags( _trbBridge.getFlags() | TrbBridge::SSEStructCheck ); - } - - if (_par.showExceptions()) { - _trbBridge.setFlags( _trbBridge.getFlags() | TrbBridge::ShowExceptions ); - } - - if (_par.client_index() != -1) { - std::cout << "trbnet_client " << _par.client_index() << ": " << par.shm_identifier() << std::endl; - } -} - -Application::~Application() -{ - if (_par.client_index() != -1) { - std::cout << "trbnet_client " << _par.client_index() << ": "; - } - std::cout << "total timeslices processed: " << _count << std::endl; -} - -void Application::run() -{ - unsigned int skipCounter = 0; - unsigned int skipMicroslices = 0; - - - while (auto timeslice = _source->get()) { - if (_par.skipTimeslices() <= skipCounter) { - _trbBridge.importTimeslice(*timeslice, skipMicroslices); - _count++; - } else { - skipCounter++; - } - - if ((_par.timesliceLimit() > 0) && (static_cast<unsigned int>(_par.timesliceLimit()) < _count)) { - std::cout << "Timeslice limit reached" << std::endl; - break; - } - skipMicroslices = _par.overlapSize(); - } - - //std::cout << _trbBridge.getCurrentStatistics().dump(); -} diff --git a/beamtime/trb/trbnet_exe/Application.hpp b/beamtime/trb/trbnet_exe/Application.hpp deleted file mode 100644 index a06774a951911453714183e4a2f102e6f23722c2..0000000000000000000000000000000000000000 --- a/beamtime/trb/trbnet_exe/Application.hpp +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2012-2013 Jan de Cuveland <cmail@cuveland.de> -#pragma once - -#include "Parameters.hpp" -#include "TimesliceSource.hpp" -#include "TrbBridge.hpp" - -#include <memory> - -/// %Application base class. -class Application -{ -public: - explicit Application(Parameters const& par); - - Application(const Application&) = delete; - void operator=(const Application&) = delete; - - ~Application(); - - void run(); - -private: - Parameters const& _par; - - std::unique_ptr<fles::TimesliceSource> _source; -// std::unique_ptr<TimesliceAnalyzer> _analyzer; -// std::unique_ptr<TimesliceDebugger> _dump; - TrbBridge _trbBridge; - - uint64_t _count = 0; -}; diff --git a/beamtime/trb/trbnet_exe/CMakeLists.txt b/beamtime/trb/trbnet_exe/CMakeLists.txt deleted file mode 100644 index bcb8b8b57aef139b7835e541239cedc09ca56b59..0000000000000000000000000000000000000000 --- a/beamtime/trb/trbnet_exe/CMakeLists.txt +++ /dev/null @@ -1,42 +0,0 @@ -# Build the tsclient executable which is taken from -# git@code.compeng.uni-frankfurt.de:flesnet.git -# This executable uses the fles_ipc library to read files -# in the tca format -# This file is only called if the compiler provides c++11 support - -Set(INCLUDE_DIRECTORIES - ${CMAKE_CURRENT_SOURCE_DIR} - ${CBMROOT_SOURCE_DIR}/beamtime/trb/trbnet_lib -) - -Include_Directories( ${INCLUDE_DIRECTORIES}) - -Include_Directories(SYSTEM - ${Boost_INCLUDE_DIR} - ${ZMQ_INCLUDE_DIR} - ${CBMROOT_SOURCE_DIR}/external/ipc_legacy/ipc/src -) - -Set(LINK_DIRECTORIES - ${Boost_LIBRARY_DIRS} - ${ZMQ_LIBRARY_DIR} -) - -Link_Directories( ${LINK_DIRECTORIES}) - -Set(SRCS -main.cpp -Application.cpp -Parameters.cpp -) - -Set_Source_Files_Properties(${SRCS} COMPILE_FLAGS "-Wall -pedantic -Wextra -Winit-self -Wundef -Wold-style-cast -Woverloaded-virtual -Wwrite-strings -Wnon-virtual-dtor") - -Set(EXE_NAME trbnet_client) -If(UNIX AND NOT APPLE) - Set(DEPENDENCIES fles_ipc_legacy trbnet boost_program_options ${CMAKE_THREAD_LIBS_INIT} zmq rt) -Else() - Set(DEPENDENCIES fles_ipc_legacy trbnet boost_program_options ${CMAKE_THREAD_LIBS_INIT} zmq) -EndIf() - -GENERATE_EXECUTABLE() diff --git a/beamtime/trb/trbnet_exe/Parameters.cpp b/beamtime/trb/trbnet_exe/Parameters.cpp deleted file mode 100644 index 5c358fe9fd1a2e863dbe2ac97ddb9d5475de6340..0000000000000000000000000000000000000000 --- a/beamtime/trb/trbnet_exe/Parameters.cpp +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright 2012-2013 Jan de Cuveland <cmail@cuveland.de> - -#include "Parameters.hpp" -#include <boost/program_options.hpp> -#include <iostream> - -namespace po = boost::program_options; - -void Parameters::parse_options(int argc, char* argv[]) -{ - po::options_description desc("Allowed options"); - desc.add_options()("version,V", "print version string")( - "help,h", "produce help message")( - "client-index,c", po::value<int32_t>(&_client_index), - "index of this executable in the list of processor tasks")( - "analyze-pattern,a", po::value<bool>(&_analyze)->implicit_value(true), - "enable/disable pattern check")( - "dump-timslices,d", po::value<bool>(&_dump)->implicit_value(true), - "enable/disable timeslice dump")( - "show-exceptions,e", po::value<bool>(&_showExceptions)->implicit_value(true), - "enable/disable exception print out")( - "skip-timeslices,f", po::value<uint32_t>(&_skipTSs), - "number of first timeslice to be imported. default: 0")( - "number-timeslices,n", po::value<int32_t>(&_limitTS), - "number of timeslices to be imported. -1 for unlimited. default: -1")( - "mc-size,m", po::value<uint32_t>(&_MCSize), - "applies only to offline unpacking as a time base. mc-size as set in flib.conf when archive was captured. default: 1250")( - "overlap-size,l", po::value<uint32_t>(&_overlapSize), - "number of mircoslices per timeslice overlapping")( - "shm-identifier,s", po::value<std::string>(&_shm_identifier), - "shared memory identifier used for receiving timeslices")( - "input-archive,i", po::value<std::string>(&_input_archive), - "name of an input file archive to read")( - "output-archive,o", po::value<std::string>(&_output_archive), - "name of an output file archive to write"); - - po::variables_map vm; - po::store(po::parse_command_line(argc, argv, desc), vm); - po::notify(vm); - - if (vm.count("help")) { - std::cout << desc << std::endl; - exit(EXIT_SUCCESS); - } - - if (vm.count("version")) { - std::cout << "tsclient, version 0.0" << std::endl; - exit(EXIT_SUCCESS); - } - - int input_sources = vm.count("shm-identifier") + vm.count("input-archive"); - if (input_sources == 0) - throw ParametersException("no input source specified"); - if (input_sources > 1) - throw ParametersException("more than one input source specified"); - if (_limitTS == 0) - throw ParametersException("number-timeslices, n must not be zero. use negative value to disable limit and strictly positive value to limit number of timeslices"); -} diff --git a/beamtime/trb/trbnet_exe/Parameters.hpp b/beamtime/trb/trbnet_exe/Parameters.hpp deleted file mode 100644 index 5b381152450b70db4650498e0c815c4af9ed4f91..0000000000000000000000000000000000000000 --- a/beamtime/trb/trbnet_exe/Parameters.hpp +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2012-2013 Jan de Cuveland <cmail@cuveland.de> -#pragma once - -#include <stdexcept> -#include <cstdint> -#include <string> - -/// Run parameter exception class. -class ParametersException : public std::runtime_error -{ -public: - explicit ParametersException(const std::string& what_arg = "") - : std::runtime_error(what_arg) - { - } -}; - -/// Global run parameter class. -class Parameters -{ -public: - Parameters(int argc, char* argv[]) - : _shm_identifier("") - , _input_archive("") - , _output_archive("") - { parse_options(argc, argv); } - - Parameters(const Parameters&) = delete; - void operator=(const Parameters&) = delete; - - int32_t client_index() const { return _client_index; } - - std::string shm_identifier() const { return _shm_identifier; } - - std::string input_archive() const { return _input_archive; } - - std::string output_archive() const { return _output_archive; } - - bool analyze() const { return _analyze; } - bool dump() const { return _dump; } - bool showExceptions() const { return _showExceptions; } - - uint32_t skipTimeslices() const {return _skipTSs;} - int32_t timesliceLimit() const {return _limitTS;} - uint32_t MCSize() const {return _MCSize;} - uint32_t overlapSize() const {return _overlapSize;} -private: - void parse_options(int argc, char* argv[]); - - int32_t _client_index = -1; - - std::string _shm_identifier; - std::string _input_archive; - std::string _output_archive; - bool _analyze = false; - bool _dump = false; - bool _showExceptions = false; - - uint32_t _skipTSs = 0; - int32_t _limitTS = -1; - - uint32_t _MCSize = 1250; - uint32_t _overlapSize = 2; -}; diff --git a/beamtime/trb/trbnet_exe/main.cpp b/beamtime/trb/trbnet_exe/main.cpp deleted file mode 100644 index d1ed82f27c003616535ff78c4d41c0b141d8f7eb..0000000000000000000000000000000000000000 --- a/beamtime/trb/trbnet_exe/main.cpp +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2012-2013 Jan de Cuveland <cmail@cuveland.de> - -#include "Parameters.hpp" -#include "Application.hpp" -#include <iostream> - -int main(int argc, char* argv[]) -{ - try - { - Parameters par(argc, argv); - Application app(par); - app.run(); - } - catch (std::exception const& e) - { - std::cerr << "FATAL: " << e.what() << std::endl; - return EXIT_FAILURE; - } - - return EXIT_SUCCESS; -} diff --git a/beamtime/trb/trbnet_lib/CMakeLists.txt b/beamtime/trb/trbnet_lib/CMakeLists.txt deleted file mode 100644 index 2d2093eabec47e2a77f30166cf48b471a2c03757..0000000000000000000000000000000000000000 --- a/beamtime/trb/trbnet_lib/CMakeLists.txt +++ /dev/null @@ -1,37 +0,0 @@ -# Build the trbnet library which is taken from -# git://jspc29.x-matter.uni-frankfurt.de/projects/cbmfles.git -# This executable uses the fles_ipc library to read timeslices -# This file is only called if the compiler provides c++11 support - -Set(INCLUDE_DIRECTORIES - ${CMAKE_CURRENT_SOURCE_DIR} -) - -Include_Directories( ${INCLUDE_DIRECTORIES}) - -Include_Directories(SYSTEM - ${Boost_INCLUDE_DIR} -# ${ZMQ_INCLUDE_DIR} - ${CBMROOT_SOURCE_DIR}/external/ipc_legacy/ipc/src -) - -Set(LINK_DIRECTORIES - ${Boost_LIBRARY_DIRS} -# ${ZMQ_LIBRARY_DIR} -) - -Link_Directories( ${LINK_DIRECTORIES}) - -Set(SRCS -TrbBridge.cpp -TrbBridgeStatistics.cpp -TrbBridgeTrbNetHeaders.cpp -TrbBridgeFrame.cpp -TrbBridgeTransaction.cpp -) - -Set_Source_Files_Properties(${SRCS} COMPILE_FLAGS "-Wall -pedantic -Wextra -Winit-self -Wundef -Wold-style-cast -Woverloaded-virtual -Wwrite-strings -Wnon-virtual-dtor") - -Set(LIBRARY_NAME trbnet) - -GENERATE_LIBRARY() diff --git a/beamtime/trb/trbnet_lib/TrbBridge.cpp b/beamtime/trb/trbnet_lib/TrbBridge.cpp deleted file mode 100644 index ad2c15bfbd83b3fc1248f17f2ebf51b8dda0c618..0000000000000000000000000000000000000000 --- a/beamtime/trb/trbnet_lib/TrbBridge.cpp +++ /dev/null @@ -1,316 +0,0 @@ -#include "TrbBridge.hpp" -#include "MicrosliceDescriptor.hpp" -#include <iostream> -#include <sstream> -#include <boost/format.hpp> -#include <chrono> -#include <ctime> -#include <stdlib.h> -#include "TrbBridgeTrbNetHeaders.hpp" - -/* Construction & Destruction */ - TrbBridge::TrbBridge() - : _eventBuffer(TrbBridgeTransaction::MAX_SIZE / sizeof(_eventBuffer[0]) + 8) - , _transactionBuffer(reinterpret_cast<uint16_t*>(_eventBuffer.data()) + 16) - , _filePtr() - , _transaction(_transactionBuffer) - , _eventNum(0) - , _runNum(0) - , _time(0) - , _date(0) - , _flags(0) - , _currentStats() - , _lastStats() - , _offlineProcessing(false) - , _MCSize(0) - , _creationTimeMCCount(0) - , _archiveCreationTime() - , _lastStatDump(0) - - { - // _eventNum = 0; - // _flags = 0; - - srand(std::time(NULL)); - _runNum = rand(); - - // _creationTimeMCCount = 0; - // _offlineProcessing = false; - } - - TrbBridge::~TrbBridge() { - closeFile(); - } - -/* File handling */ - void TrbBridge::openFile(const std::string& filename) { - if (_filePtr) closeFile(); - _filePtr.reset( new std::ofstream(filename, std::ios::out | std::ios::trunc | std::ios::binary) ); - if (_filePtr) { - TrbBridgeTrbNetEventHeader evtHdr; - evtHdr.swappedEndianess = false; - evtHdr.timestamp = _getEventTime(); - evtHdr.runNumber = _runNum; - evtHdr.eventNumberPerFile = 0; - evtHdr.setSizeWithPadding(32); - - _eventBuffer.data() << evtHdr; - _eventBuffer[2] = 0x00010002; // first event in hld file has special id - - _filePtr->write(reinterpret_cast<char*> (_eventBuffer.data()), size_t(evtHdr.size) ); - } - } - - void TrbBridge::closeFile() { - if (!_filePtr) return; - - _filePtr->close(); - _filePtr.release(); - } - -/* Wrapper */ - void TrbBridge::setFlags(uint32_t f) { - _flags = f; - } - - uint32_t TrbBridge::getFlags() const { - return _flags; - } - -/* Stream frames in */ - void TrbBridge::_importFrame(const TrbBridgeFrame & frame, std::list<std::vector<uint32_t>>* resultList, unsigned int retry) { - if (!retry) return; - - try { - _transaction << frame; - - } catch(std::exception& e) { - if (_flags & ShowExceptions) - std::cerr << e.what() << std::endl; - - // all frames that went into this transaction are lost - _currentStats.incrementFramesDiscarded(_transaction.nextFrameNumberExpected()); - - _transaction.reset(); - - if (frame.isStartFrame()) { - _importFrame(frame, resultList, retry-1); - } - - return; - } - - if (_transaction.isStarted() && frame.isStartFrame()) { - _currentStats.incrementTransactionsStarted(); - - if (_lastTransactionNumber > 0) { - int missingTrans = _transaction.transactionNumber() - ((_lastTransactionNumber + 1) & 0xfff); - if (missingTrans < 0) missingTrans += 0x1000; - _currentStats.incrementTransactionsMissing(missingTrans); - } - - _lastTransactionNumber = _transaction.transactionNumber(); - } - - if (!_transaction.isStarted()) { - _currentStats.incrementFramesSkipped(); - return; - } - - if (_transaction.isCompleted()) { - // add event header (very simple event building !) - // decode sub-event header - TrbBridgeTrbNetSubEventHeader subEvtHdr; - subEvtHdr << reinterpret_cast<uint32_t*>(_transactionBuffer); - - // build event header based on information gathered - TrbBridgeTrbNetEventHeader evtHdr; - evtHdr.swappedEndianess = subEvtHdr.swappedEndianess; - evtHdr.triggerType = 0x00002001; // TODO: trigger type missing; - evtHdr.eventNumberPerFile = ++_eventNum; - evtHdr.timestamp = _getEventTime(); - evtHdr.runNumber = _runNum; - - // set size and clear padding area - evtHdr.setSizeWithPadding(subEvtHdr.size + 32); - for(unsigned int i = (subEvtHdr.size+32) / sizeof(_eventBuffer[0]); i < evtHdr.size / sizeof(_eventBuffer[0]); i++) - _eventBuffer[i] = 0; - - _eventBuffer.data() << evtHdr; - /* - std::cout << boost::format("Completed transaction 0x%04x with % 4d bytes. Stored trigger number 0x%04x") - % _transaction.transactionNumber() - % _transaction.size() - % subEvtHdr.triggerNumber - << std::endl; - */ - - // write to hld file - if (_filePtr) - _filePtr->write(reinterpret_cast<char*>(_eventBuffer.data()), evtHdr.size); - - if (resultList) { - std::vector<uint32_t> eventCopy(_eventBuffer.begin(), _eventBuffer.begin() + evtHdr.size / sizeof(uint32_t)); - resultList->push_back(eventCopy); - } - _currentStats.addEventSize(evtHdr.size); - _currentStats.incrementFramesAssigned(_transaction.nextFrameNumberExpected()); - _currentStats.incrementTransactionsCompleted(); - - // std::cout << _transaction.transactionNumber() << std::endl; - - if (getFlags() & SSEStructCheck) { - try { - std::list<TrbBridgeTrbNetSubSubEventHeader> sse = TrbBridgeTrbNetSubSubEventHeader::extractSubSubEvents( - subEvtHdr, reinterpret_cast<uint32_t*> (_transactionBuffer)); - - if (sse.size() != 5) { - std::cout << "Found " << sse.size() << " sub-events: "; - for(auto it = sse.begin(); it != sse.end(); it++) - std::cout << boost::format("(id: 0x%04x, size: %d) ") % it->subSubEventId % it->size; - std::cout << std::endl; - } - - if (_lastEvtNumber > 0) { - if (((_lastEvtNumber+1)&0xffff) != subEvtHdr.triggerNumber) { - //std::cout << "Event sequence error. Expected: " << ((_lastEvtNumber+1)&0xffff) << " Got: " << subEvtHdr.triggerNumber << std::endl; - _currentStats.incrementTriggerNumberSequenceErrors(); - - int delta = subEvtHdr.triggerNumber - ((_lastEvtNumber+1)&0xffff); - if (delta < 0) { - std::cout << delta; - delta += 0x10000; - std::cout << " " << delta << "last :" << _lastEvtNumber << " now: " << subEvtHdr.triggerNumber << std::endl; - } - _currentStats.incrementMissedTriggerNumbers(delta); - } - } - - _lastEvtNumber = subEvtHdr.triggerNumber; - - // do whatever you want with your data - - } catch(std::exception& e) { - std::cerr << e.what() << std::endl; - _currentStats.incrementSSEStructureError(); - } - - } - - _transaction.reset(); - } - } - - void TrbBridge::importTimeslice(const fles::Timeslice& ts, unsigned int skipMS) { - extractEventsFromTimeslice(ts, skipMS); - } - - std::list<std::vector<uint32_t>> TrbBridge::extractEventsFromTimeslice(const fles::Timeslice & ts, unsigned int skipMS) { - std::list<std::vector<uint32_t>> eventsReconstructed; - - for (size_t c = 0; c < ts.num_components(); ++c) { - if (ts.num_microslices(c) == 0) { - std::cerr << "no microslices in TS " << ts.index() << ", component " - << c << std::endl; - return eventsReconstructed; - } - - for (size_t m = 0; m < ts.num_microslices(c); ++m) { - if (m < skipMS) - continue; - - // iterate over microslice - auto msDescriptor = ts.descriptor(c, m); - auto msContent = reinterpret_cast<const uint16_t*>(ts.content(c, m)); - - // only consider generic TrbNet subsystem - if (msDescriptor.sys_id != flesnetSysId) - continue; - - unsigned int msInteralPtr = 16 / sizeof(*msContent); - while(msInteralPtr < msDescriptor.size / sizeof(*msContent)) { - // iterate over cbmnet frames with in microslice (padding handling just copied from tsclient) - uint8_t word_count = (msContent[msInteralPtr] & 0xff) + 1; - uint8_t padding_count = (4 - ((word_count + 1) & 0x3)) & 0x3; - ++msInteralPtr; - - // here the magic happens - try { - TrbBridgeFrame frame (&msContent[msInteralPtr], word_count*2); - _importFrame( frame, &eventsReconstructed ); - } catch(std::exception& e) { - _currentStats.incrementFramesSkipped(); - } - - _currentStats.incrementFramesProcessed(); - - msInteralPtr += word_count + padding_count; - } - } - } - - _creationTimeMCCount += ts.num_microslices(0); - _currentStats.incrementTimeslicesProcessed(); - - std::time_t now = std::time(NULL); - if (_lastStatDump != now) { - std::cout << std::endl; - std::cout << _currentStats.dump(15); - std::cout << _currentStats.dump(_lastStats); - - _lastStats = _currentStats; - _lastStatDump = now; - } - - return eventsReconstructed; - - //std::cout << "Pending Trans:" << _transaction.transactionNumber() << " " << _currentStats.dump(); - } - - std::time_t TrbBridge::_getEventTime(unsigned int delta) { - if (_offlineProcessing) { - double secondsPerMC = flibMCSizeGranularity * _MCSize; - unsigned int offsetSeconds = int( (_creationTimeMCCount + delta) * secondsPerMC ); - return _archiveCreationTime + offsetSeconds; // TODO: This is not C++ standard conform, but should work on all POSIX-compatible systems - } - - return std::time(NULL); - } - - -// Wrapper - unsigned int TrbBridge::runNumber() const { - return _runNum; - } - - void TrbBridge::setRunNumber(unsigned int num) { - _runNum = num; - } - - void TrbBridge::setOfflineProcessing(bool v) { - _offlineProcessing = v; - } - - bool TrbBridge::offlineProcessing() const { - return _offlineProcessing; - } - - void TrbBridge::setArchiveCreationTime(std::time_t & ts) { - _archiveCreationTime = ts; - } - - std::time_t TrbBridge::archiveCreationTime() const { - return _archiveCreationTime; - } - - void TrbBridge::setMCSize(unsigned int mcsize) { - _MCSize = mcsize; - } - - unsigned int TrbBridge::MCSize() const { - return _MCSize; - } - - const TrbBridgeStatistics & TrbBridge::getCurrentStatistics() const { - return _currentStats; - } diff --git a/beamtime/trb/trbnet_lib/TrbBridge.hpp b/beamtime/trb/trbnet_lib/TrbBridge.hpp deleted file mode 100644 index df404a1f6279a08c26fafb56704a4494311cbe9d..0000000000000000000000000000000000000000 --- a/beamtime/trb/trbnet_lib/TrbBridge.hpp +++ /dev/null @@ -1,105 +0,0 @@ -#pragma once - -#include <fstream> -#include <memory> - -#include "Timeslice.hpp" -#include "TrbBridgeTransaction.hpp" -#include "TrbBridgeStatistics.hpp" - -#include <chrono> -#include <list> - -/** - * Functions as "glue logic" between the flesnet-ipc, the user and the TrbBridge code - */ -class TrbBridge { -public: - TrbBridge(); - ~TrbBridge(); - - void openFile(const std::string& filename); - void closeFile(); - - void setFlags(uint32_t flags); - uint32_t getFlags() const; - - /** Import Timeslice. - * If avail. write reconstructed events to HLD-File and may perform analysis, if configured by flags - * DO NOT CALL THIS FUNCTION (or extractEventsFromTimeslice) MULTIPLE TIMES FOR THE SAME TIMESLICE - * - * @param ts Timeslice to be imported - * @param skipMS Number of microslices to be skipped at the beginning (overlap ...) - */ - void importTimeslice(const fles::Timeslice& ts, unsigned int skipMS); - - /** Same as importTimeslice but returns list of reconstructed events. - * If an event is not finished within the timeslice it will be returned as the first event of the - * next timeslice. - * DO NOT CALL THIS FUNCTION (or importTimeslice) MULTIPLE TIMES FOR THE SAME TIMESLICE - * - * @param ts Timeslice to be imported - * @param skipMS Number of microslices to be skipped at the beginning (overlap ...) - */ - std::list<std::vector<uint32_t>> extractEventsFromTimeslice(const fles::Timeslice &, unsigned int skipMS); - - unsigned int runNumber() const; - void setRunNumber(unsigned int num); - - // Creation Time - void setArchiveCreationTime(std::time_t &); - std::time_t archiveCreationTime() const; - - void setOfflineProcessing(bool v); - bool offlineProcessing() const; - - void setMCSize(unsigned int mcsize); - unsigned int MCSize() const; - - constexpr static int flesnetSysId = 0xE0; // Number has to correspond to system ID set in flib.cfg - // take this number from a header files which uniquely defines all system relevant variables -// constexpr static int flesnetSysId = 0x90; // Number was valid for some older test files - constexpr static double flibMCSizeGranularity = 8e-9; // seconds per MCSize count - - constexpr static uint32_t SSEStructCheck = 0x1; - constexpr static uint32_t ShowExceptions = 0x2; - - - const TrbBridgeStatistics & getCurrentStatistics() const; - -private: - void _importFrame(const TrbBridgeFrame & frame, std::list<std::vector<uint32_t>>* resultList, unsigned int retry = 1); - - std::vector<uint32_t> _eventBuffer; - uint16_t* _transactionBuffer; - - std::unique_ptr<std::ofstream> _filePtr; - TrbBridgeTransaction _transaction; - int _lastTransactionNumber = -1; - - - unsigned int _eventNum; - unsigned int _runNum; - unsigned int _time; - unsigned int _date; - - unsigned int _flags; - - TrbBridgeStatistics _currentStats; - TrbBridgeStatistics _lastStats; - - // creation time required only for offline processing - bool _offlineProcessing; - unsigned int _MCSize; - - unsigned int _creationTimeMCCount; - std::time_t _archiveCreationTime; - std::time_t _getEventTime(unsigned int delta = 0); - - std::time_t _lastStatDump; - - int _lastEvtNumber = -1; - - TrbBridge(const TrbBridge&); - TrbBridge operator=(const TrbBridge&); -}; diff --git a/beamtime/trb/trbnet_lib/TrbBridgeFrame.cpp b/beamtime/trb/trbnet_lib/TrbBridgeFrame.cpp deleted file mode 100644 index 12d7c6eddf13bc72da4f7a1396131b27a4ee4d98..0000000000000000000000000000000000000000 --- a/beamtime/trb/trbnet_lib/TrbBridgeFrame.cpp +++ /dev/null @@ -1,100 +0,0 @@ -#include "TrbBridgeFrame.hpp" -#include <boost/format.hpp> -#include <sstream> - -TrbBridgeFrame::TrbBridgeFrame(const uint16_t* msContent, size_t frameLength) - : _content(msContent) - , _length(frameLength) -{ - if (frameLength < 4 || frameLength > 64 || frameLength & 1) throw TrbBrideFrameException("Invalid frameLength"); -} - - -const uint16_t* TrbBridgeFrame::payload() const { - return _content + 1; -} - -size_t TrbBridgeFrame::payloadSize() const { - return _length - 2; // subtract header length -} - -uint16_t TrbBridgeFrame::frameNumber() const { - if (isStartFrame() || isStopFrame()) - return 0; - - return *_content & 0x7f; -} - -uint16_t TrbBridgeFrame::transactionNumber() const { - if (isStartFrame() || isStopFrame()) - return *_content & 0x0fff; - - // inner frame: bits 11 .. 7 - return (_content[0] >> 7) & 0x1f; -} - - -bool TrbBridgeFrame::isStartFrame() const { - return (_content[0] >> 14) & 1; -} - -bool TrbBridgeFrame::isStopFrame() const { - return (_content[0] >> 15) & 1; -} - -bool TrbBridgeFrame::matchesFrameNumber(uint16_t frameNo) const { - if (isStartFrame()) - return frameNo == 0; - - if (isStopFrame()) - return true; - - return (frameNo & 0x7f) == frameNumber(); -} - - -bool TrbBridgeFrame::matchesTransactionNumber(uint16_t transactionNo) const { - if (isStartFrame() || isStopFrame()) - return (transactionNo & 0x0fff) == transactionNumber(); - - return (transactionNo & 0x1f) == transactionNumber(); -} - - -std::string TrbBridgeFrame::dump() const { - std::stringstream ss; - - ss << boost::format("Frame (Start: %s, Stop: %s, TransNo: % 4d, FrameNo: ") % isStartFrame() % isStopFrame() % transactionNumber(); - if (isStopFrame()) - ss << "???"; - else - ss << boost::format("% 3d") % frameNumber(); - - ss << boost::format(", size: % 2d bytes): ") % payloadSize(); - - for(unsigned int i=0; i < payloadSize()/2; i++) { - if (i % 16 == 0) - ss << std::endl; - ss << boost::format(" [% 2d] %04x") % (i+1) % payload()[i]; - } - - ss << std::endl; - - return ss.str(); -} - -TrbBrideFrameException::TrbBrideFrameException(const std::string& what_arg, const TrbBridgeFrame* frameInvolved) - : _what("") -{ - if (frameInvolved) { - std::stringstream ss; - ss << what_arg << std::endl << "Related to " << frameInvolved->dump(); - _what = ss.str(); - } else { - _what = what_arg; - } -} - - - - diff --git a/beamtime/trb/trbnet_lib/TrbBridgeFrame.hpp b/beamtime/trb/trbnet_lib/TrbBridgeFrame.hpp deleted file mode 100644 index 7c0ab36bf0a379160942fafc111cf6cefeedb21e..0000000000000000000000000000000000000000 --- a/beamtime/trb/trbnet_lib/TrbBridgeFrame.hpp +++ /dev/null @@ -1,81 +0,0 @@ -#pragma once - -#include <exception> -#include <string> - -/** - * Read-only wrapper for a CBMNet frame extracted from a microslice interpreting the TrbNet bridge's header - */ -class TrbBridgeFrame { -public: - TrbBridgeFrame(const uint16_t* msContent, size_t frameLength); - - /** - * Generate human-readable representation of frame - */ - std::string dump() const; - - /** - * Pointer to payload area of the frame (i.e. excl. header) - */ - const uint16_t* payload() const; - - /** - * Payload size in bytes - */ - size_t payloadSize() const; - - /** - * Frame number extracted from header. - * @return 0 if start frame or undefined - */ - uint16_t frameNumber() const; - - /** - * Transaction number extracted from header. - * Number is truncated for inner frames - */ - uint16_t transactionNumber() const; - - /** - * @return true, if frame header indicates a start frame - */ - bool isStartFrame() const; - - /** - * @return true, if frame header indicates a stop frame - */ - bool isStopFrame() const; - - /** - * Matches the frame number incl. in header against a frame number provided - * modulo the number of bits in the header's field. Hence, in case of stop - * frame, the function always returns true. - * @return true if frameNo & header mask matches frame - */ - bool matchesFrameNumber(uint16_t frameNo) const; - - /** - * Matches the transaction number incl. in header against a number provided - * modulo the number of bits in the header's field. Thus, the significance of - * a start and stop frame is higher compared to inner frames. - * @return true if transactionNo & mask matches frames - */ - bool matchesTransactionNumber(uint16_t transactionNo) const; - -private: - const uint16_t* _content; /**< Pointer first data word of frame (i.e. the header) */ - size_t _length; /**< Length of frame as provided in constructor. IN BYTES */ -}; - -class TrbBrideFrameException : public std::exception { -public: - explicit TrbBrideFrameException(const std::string& what_arg = "", const TrbBridgeFrame* frameInvolved = NULL); - virtual const char* what() const throw() { - return _what.c_str(); - } - -private: - std::string _what; -}; - \ No newline at end of file diff --git a/beamtime/trb/trbnet_lib/TrbBridgeStatistics.cpp b/beamtime/trb/trbnet_lib/TrbBridgeStatistics.cpp deleted file mode 100644 index f73487cf8702115aae76faea10ca45662125fdd5..0000000000000000000000000000000000000000 --- a/beamtime/trb/trbnet_lib/TrbBridgeStatistics.cpp +++ /dev/null @@ -1,222 +0,0 @@ -#include "TrbBridgeStatistics.hpp" -#include <sstream> -#include <boost/format.hpp> - -std::string fmtPercent(double v) { - std::string val("n/a"); - if (v == v) { - // not nan - val = (boost::format("%.2f") % v).str(); - } - return (boost::format("% 7s") % val).str(); -} - -std::string fmtSize(double v) { - std::string val; - if (v > 900) { - return (boost::format("%.1fk") % (v / 1e3)).str(); - } else { - return (boost::format("%.1f") % (v / 1e0)).str(); - } -} - - - -// Init -TrbBridgeStatistics::TrbBridgeStatistics() - : _timeslicesProcessed(0) - , _framesProcessed(0) - , _framesAssigned(0) - , _framesSkipped(0) - , _framesDiscarded(0) - , _transactionsStarted(0) - , _transactionsCompleted(0) - , _transactionsMissing(0) - , _SSEStructureError(0) - , _missedTriggerNumbers(0) - , _triggerNumberSequenceErrors(0) - , _dumpsSinceLastHeader(0) - , _eventSizeTotal(0) - , _eventSizeNumber(0) - , _eventSizeMin(0xffffff) - , _eventSizeMax(0) -{ - reset(); -} - - void TrbBridgeStatistics::reset() { - _framesProcessed = 0; - _framesAssigned = 0; - _framesSkipped = 0; - _framesDiscarded = 0; - _transactionsStarted = 0; - _transactionsCompleted = 0; - _transactionsMissing = 0; - _SSEStructureError = 0; - _timeslicesProcessed = 0; - _triggerNumberSequenceErrors = 0; - _missedTriggerNumbers = 0; - - _dumpsSinceLastHeader=0; - - _eventSizeTotal = 0; - _eventSizeNumber = 0; - _eventSizeMin = 0xffffff; - _eventSizeMax = 0; - } - -// Output statistics - std::string TrbBridgeStatistics::dumpHeader() const { - std::stringstream ss; - ss << - (boost::format("% 8s |% 78s| % 40s |% 26s |% 23s") - % "Timeslc" - % "Frames " - % "Transactions " - % "TrbNet-Trigger-Nr. " - % "Event Size " - ) - << std::endl; - - ss << - (boost::format("% 8s |% 12s % 20s % 20s % 22s |% 10s % 19s % 10s |% 6s % 18s |% 7s % 7s % 7s") - % "Count" - - % "Processed" - % "Skipped" - % "Discarded (%)" - % "Matched (%)" - - % "Started" - % "Aborted" - % "Missing" - - % "Errors" - % "Missing" - - % "Min" - % "Avg" - % "Max" - ) << std::endl; - return ss.str(); - } - - std::string TrbBridgeStatistics::dump(const TrbBridgeStatistics& ref, unsigned int includeHeaderInterval) { - long transStarted= (_transactionsStarted - ref._transactionsStarted); - long transAborted = transStarted - (_transactionsCompleted - ref._transactionsCompleted); - - std::stringstream ss; - return ss.str(); - if (includeHeaderInterval) { - if (!_dumpsSinceLastHeader) - ss << dumpHeader(); - - _dumpsSinceLastHeader++; - if (includeHeaderInterval <= _dumpsSinceLastHeader) { - _dumpsSinceLastHeader = 0; - } - } - - std::string evtSzeMin("n/a"), evtSzeMax("n/a"), evtSzeAvg("n/a"); - - if (!ref._eventSizeNumber) { - evtSzeMin = fmtSize( _eventSizeMin ); - evtSzeMax = fmtSize( _eventSizeMax ); - } - - if (_eventSizeNumber - ref._eventSizeNumber) { - evtSzeAvg = fmtSize( double(_eventSizeTotal - ref._eventSizeTotal) / - double(_eventSizeNumber - ref._eventSizeNumber) ); - } - - ss << ( - boost::format("% 8d |% 12d % 10d (%s) % 10d (%s) % 12d (%s) |% 10d % 9d (%s) % 10d |% 7d % 9d (%s)|% 7s % 7s % 7s") - // Timeslice - % (_timeslicesProcessed - ref._timeslicesProcessed) - - // Frames - % (_framesProcessed - ref._framesProcessed) - % (_framesSkipped - ref._framesSkipped) - % fmtPercent(100.0*double(_framesSkipped - ref._framesSkipped) / (_framesProcessed - ref._framesProcessed)) - - % (_framesDiscarded - ref._framesDiscarded) - % fmtPercent(100.0*double(_framesDiscarded - ref._framesDiscarded) / (_framesProcessed - ref._framesProcessed)) - - % (_framesAssigned - ref._framesAssigned) - % fmtPercent(100.0*double(_framesAssigned - ref._framesAssigned) / (_framesProcessed - ref._framesProcessed)) - - // Transactions - % transStarted - % transAborted - % fmtPercent(100.*transAborted / transStarted) - % (_transactionsMissing - ref._transactionsMissing) - - // Trg-Seq - % (_triggerNumberSequenceErrors - ref._triggerNumberSequenceErrors) - % (_missedTriggerNumbers - ref._missedTriggerNumbers) - % fmtPercent(1.0e6 * (_missedTriggerNumbers - ref._missedTriggerNumbers) / transStarted) - - // Size - % evtSzeMin - % evtSzeAvg - % evtSzeMax - ) << std::endl; - return ss.str(); - } - - std::string TrbBridgeStatistics::dump(unsigned int includeHeaderInterval) { - TrbBridgeStatistics nil; - return dump(nil, includeHeaderInterval); - } - -// Boring Wrappers - void TrbBridgeStatistics::incrementTimeslicesProcessed(unsigned int long delta) { - _timeslicesProcessed += delta; - } - - void TrbBridgeStatistics::incrementTransactionsStarted(unsigned int long delta) { - _transactionsStarted += delta; - } - - void TrbBridgeStatistics::incrementTransactionsCompleted(unsigned int long delta) { - _transactionsCompleted += delta; - } - - void TrbBridgeStatistics::incrementTransactionsMissing(unsigned int long delta) { - _transactionsMissing += delta; - } - - void TrbBridgeStatistics::incrementFramesProcessed(unsigned int long delta) { - _framesProcessed += delta; - } - - void TrbBridgeStatistics::incrementFramesSkipped(unsigned int long delta) { - _framesSkipped += delta; - } - - void TrbBridgeStatistics::incrementFramesDiscarded(unsigned int long delta) { - _framesDiscarded += delta; - } - - void TrbBridgeStatistics::incrementFramesAssigned(unsigned int long delta) { - _framesAssigned += delta; - } - - void TrbBridgeStatistics::incrementSSEStructureError(unsigned int long delta) { - _SSEStructureError += delta; - } - - void TrbBridgeStatistics::incrementMissedTriggerNumbers(unsigned int long delta) { - _missedTriggerNumbers += delta; - } - - void TrbBridgeStatistics::incrementTriggerNumberSequenceErrors(unsigned int long delta) { - _triggerNumberSequenceErrors += delta; - } - - void TrbBridgeStatistics::addEventSize(unsigned int long size) { - _eventSizeTotal += size; - _eventSizeNumber++; - if (_eventSizeMin > size) _eventSizeMin = size; - if (_eventSizeMax < size) _eventSizeMax = size; - } diff --git a/beamtime/trb/trbnet_lib/TrbBridgeStatistics.hpp b/beamtime/trb/trbnet_lib/TrbBridgeStatistics.hpp deleted file mode 100644 index 0cd48753950fda0ad537815183bc2e5a71707d04..0000000000000000000000000000000000000000 --- a/beamtime/trb/trbnet_lib/TrbBridgeStatistics.hpp +++ /dev/null @@ -1,54 +0,0 @@ -#pragma once -#include <string> - -class TrbBridgeStatistics { -public: - TrbBridgeStatistics(); - - std::string dumpHeader() const; - std::string dump(const TrbBridgeStatistics& ref,unsigned int includeHeaderInterval=0); - std::string dump(unsigned int includeHeaderInterval=0); - - void reset(); - - void incrementTimeslicesProcessed(unsigned int long delta=1); - - void incrementFramesProcessed(unsigned int long delta=1); - void incrementFramesSkipped(unsigned int long delta=1); - void incrementFramesDiscarded(unsigned int long delta=1); - void incrementFramesAssigned(unsigned int long delta=1); - - void incrementTransactionsStarted(unsigned int long delta=1); - void incrementTransactionsCompleted(unsigned int long delta=1); - void incrementTransactionsMissing(unsigned int long delta=1); - - void incrementSSEStructureError(unsigned int long delta=1); - - void incrementMissedTriggerNumbers(unsigned int long delta=1); - void incrementTriggerNumberSequenceErrors(unsigned int long delta=1); - - void addEventSize(unsigned int long size); - -private: - unsigned long _timeslicesProcessed; - - unsigned long _framesProcessed; - unsigned long _framesAssigned; - unsigned long _framesSkipped; - unsigned long _framesDiscarded; - - unsigned long _transactionsStarted; - unsigned long _transactionsCompleted; - unsigned long _transactionsMissing; - - unsigned long _SSEStructureError; - unsigned long _missedTriggerNumbers; - unsigned long _triggerNumberSequenceErrors; - - unsigned int _dumpsSinceLastHeader=0; - - unsigned long _eventSizeTotal; - unsigned long _eventSizeNumber; - unsigned long _eventSizeMin; - unsigned long _eventSizeMax; -}; diff --git a/beamtime/trb/trbnet_lib/TrbBridgeTransaction.cpp b/beamtime/trb/trbnet_lib/TrbBridgeTransaction.cpp deleted file mode 100644 index 6b7ccbe118a51cd842879fcbd440af360cbf2cdd..0000000000000000000000000000000000000000 --- a/beamtime/trb/trbnet_lib/TrbBridgeTransaction.cpp +++ /dev/null @@ -1,193 +0,0 @@ -#include "TrbBridgeTransaction.hpp" -#include <algorithm> -#include <iostream> -#include <assert.h> - -#include <sstream> -#include <boost/format.hpp> - -#include "TrbBridgeTrbNetHeaders.hpp" - -TrbBridgeTransaction::TrbBridgeTransaction(uint16_t* tmpbuffer) - : _buffer(tmpbuffer) - , _writeIdx(0) - , _size(0) - , _completed(false) - , _transactionNumber(0) - , _frameNumberExpected(0) -{ - // _buffer = buffer; - reset(); -} - -void TrbBridgeTransaction::reset() { - _size = 0; - _writeIdx = 0; - _frameNumberExpected = 0; - _completed = false; -} - -TrbBridgeTransaction TrbBridgeTransaction::operator<< (const TrbBridgeFrame & frame) { - if (!_buffer) - throw TrbBridgeTransactionException("Cannot append frame to buffer-less transaction", this, &frame); - -// deal with start frames - if (isCompleted()) - throw TrbBridgeTransactionException("Cannot append frame to completed transaction", this, &frame); - - if (!isStarted() && !frame.isStartFrame()) { - // we're waiting for a start frame, so let's skip this frame - // because this can happend when synchronising to a stream, this is not considered an error - - return *this; - } - - if (isStarted() && frame.isStartFrame()) - throw TrbBridgeTransactionException("Cannot process second start frame", this, &frame); - - -// check transaction & frame number (if necessary) - size_t wordsFromFrame = frame.payloadSize() / 2; - if (!isStarted()) { - _transactionNumber = frame.transactionNumber(); - _size=(frame.payload()[0] << 16) | frame.payload()[1]; // little quirk to convert the median endian input into little endian - - } else { - if (!frame.matchesTransactionNumber(_transactionNumber)) - throw TrbBridgeTransactionException("Tried to append frame with wrong transaction number", this, &frame); - - if (!frame.matchesFrameNumber(_frameNumberExpected)) - throw TrbBridgeTransactionException("Tried to append frame with wrong frame number", this, &frame); - - - // check memory boundaries - const size_t wordsLeftsInTransaction = size() / 2 - _writeIdx; - - if (wordsFromFrame > wordsLeftsInTransaction) { - if (frame.isStopFrame() && wordsFromFrame - wordsLeftsInTransaction <= 2 && wordsFromFrame == 3) { - // the excess seems to be padding .. let's have a closer look - - for (unsigned int i=wordsLeftsInTransaction; i < wordsFromFrame; i++) - if (frame.payload()[i] != 0xaaaa) - throw TrbBridgeTransactionException("Unexpected padding", this, &frame); - - wordsFromFrame = wordsLeftsInTransaction; - - } else { - throw TrbBridgeTransactionException("Frame too long for transaction", this, &frame); - - } - } - } -// copy data - for(unsigned int i=0; i < wordsFromFrame; i++) - // THIS STEP IS CRUCIAL: TrbNet sends MSB big-endian words, while FLIB serves - // little-endian half-words; so have to swap the half-words in each word and - // obtain a little-endian word - _buffer[ _writeIdx++ ^ 1 ] = frame.payload()[i]; - - - _frameNumberExpected++; - -// check for valid header length - if (frame.isStartFrame()) { - if (size() > MAX_SIZE || size() & 0x3) { - //std::cout << size() << std::endl; - throw TrbBridgeTransactionException("Start frame indicates an unsupported transaction length", 0, &frame); - } - } - -// close transaction ? - if (_writeIdx == size() / 2) { - if (!frame.isStopFrame()) - throw TrbBridgeTransactionException("Transaction completed without stop frame", this, &frame); - - _completed = true; - - } else if (frame.isStopFrame()) { - throw TrbBridgeTransactionException("Premature stop frame", this, &frame); - - } - - return *this; -} - -bool TrbBridgeTransaction::isStarted() const { - return _writeIdx != 0; -} - -bool TrbBridgeTransaction::isCompleted() const { - return _completed; -} - -uint16_t* TrbBridgeTransaction::buffer() { - return _buffer; -} - -const uint16_t* TrbBridgeTransaction::buffer() const { - return const_cast<const uint16_t*> (_buffer); -} - -uint32_t TrbBridgeTransaction::size() const { - if (!_buffer) - return 0; - - if (!isStarted()) - throw TrbBridgeTransactionException("TrbBridgeTransaction::size() is available only, once a start frame was processed"); - - return _size; -} - -uint16_t TrbBridgeTransaction::transactionNumber() const { - if (!isStarted()) - throw TrbBridgeTransactionException("TrbBridgeTransaction::transactionNumber() is available only, once a start frame was processed"); - - return _transactionNumber; -} - -uint16_t TrbBridgeTransaction::nextFrameNumberExpected() const { - return _frameNumberExpected; -} - -std::string TrbBridgeTransaction::dump() const { - if (!isStarted()) - return "Transaction: Not started\n"; - - std::stringstream ss; - - ss << boost::format("Transaction: %s (TransNo %d, size: % 4d)") - % (isCompleted() ? "completed" : "pending") - % transactionNumber() - % size() - << std::endl; - - for(unsigned int i=0; i< size()/2; i++) { - if (i % 8 == 0 && i) - ss << std::endl; - - if (i < _writeIdx) - ss << boost::format(" [% 4d] 0x%04x") % i % _buffer[i]; - else - ss << boost::format(" [% 4d] .recv.") % i; - } - - return ss.str(); -} - -TrbBridgeTransactionException::TrbBridgeTransactionException(const std::string& what_arg, const TrbBridgeTransaction* involvedTransaction, const TrbBridgeFrame* involvedFrame) - : _what("") -{ - if (involvedTransaction || involvedFrame) { - std::stringstream ss; - ss << what_arg << std::endl; - if (involvedTransaction) - ss << "Involves " << involvedTransaction->dump() << std::endl; - - if (involvedFrame) - ss << "Involves " << involvedFrame->dump(); - - _what = ss.str(); - } else { - _what = what_arg; - } -} diff --git a/beamtime/trb/trbnet_lib/TrbBridgeTransaction.hpp b/beamtime/trb/trbnet_lib/TrbBridgeTransaction.hpp deleted file mode 100644 index f96b4f5e430d3576944355f226b4271878b6e92c..0000000000000000000000000000000000000000 --- a/beamtime/trb/trbnet_lib/TrbBridgeTransaction.hpp +++ /dev/null @@ -1,126 +0,0 @@ -#pragma once - -#include <exception> -#include <string> -#include "TrbBridgeFrame.hpp" - -/** - * The class implements the merging of several frames into a complete transaction. - */ -class TrbBridgeTransaction { -public: - /** - * Generates an empty transaction w/o buffer. - * You cannot use this transaction ! - */ - TrbBridgeTransaction() - : _buffer(NULL) - , _writeIdx(0) - , _size(0) - , _completed(false) - , _transactionNumber(0) - , _frameNumberExpected(0) - { - TrbBridgeTransaction(0); - } - - /** - * Generates an empty transaction - * - * @param buffer Pointer to a sufficiently large buffer area (>= MAX_SIZE) - */ - TrbBridgeTransaction(uint16_t* buffer); - - /** - * Generate human-readable representation of the transaction - */ - std::string dump() const; - - /** - * Empties a transaction to start over (same state as new creation) - */ - void reset(); - - /** - * Append a frame to the transaction. Function automatically handles start/stop frames. - * Once a transaction has started, it only accepts frames with the same transaction no. - * - * @param frame Frame to append - */ - TrbBridgeTransaction operator<< (const TrbBridgeFrame & frame); - - /** - * Indicates whether a start frame was found yet - * - * @return true, if start frame was detected - */ - bool isStarted() const; - - /** - * Indicates whether a valid stop frame was found yet. - * This implies, that the transaction seemes complete and no errors have been found. - * - * @return true, if transaction seems complete - */ - bool isCompleted() const; - - /** - * @return Pointer provided in constructor - */ - uint16_t* buffer(); - - /** - * @return Pointer provided in constructor - */ - const uint16_t* buffer() const; - - /** - * Size of transaction (incl. sub-event header) in bytes - * - * @return if isStarted() length found in sub-event header, 0 otherwise - */ - uint32_t size() const; - - - /** - * Transaction Number - * - * @return if isStarted(): transaction number, 0 otherwise - */ - uint16_t transactionNumber() const; - - /** - * Frame Number - * - * @return number of next frame expected (corresponds to the number of frames imported). still valid after transaction is closed - */ - uint16_t nextFrameNumberExpected() const; - - /** - * Maximal transaction size in bytes. The class wont accept frame that exceed this boundary, - * nor will it process a start frame indicating a larger transaction. - * Take care, that the buffer provided to the constructor can fit this size. - */ - constexpr static size_t MAX_SIZE = 65536; - -private: - uint16_t* _buffer; /**< Write buffer, as provided in constructor */ - size_t _writeIdx; /**< Index to first empty word in buffer */ - size_t _size; /**< Size gathered upon importing the start frame */ - - bool _completed; /**< Indicates that all frame belonging to this transaction have been received w/o framing errors */ - - uint16_t _transactionNumber; /**< Transaction Number contained in start frame. Only valid if isStarted() */ - uint16_t _frameNumberExpected; /**< Frame Number of next frame expected */ -}; - -class TrbBridgeTransactionException : public std::exception { -public: - explicit TrbBridgeTransactionException(const std::string& what_arg = "", const TrbBridgeTransaction* involvedTransaction = NULL, const TrbBridgeFrame* involvedFrame = NULL); - virtual const char* what() const throw() { - return _what.c_str(); - } - -private: - std::string _what; -}; diff --git a/beamtime/trb/trbnet_lib/TrbBridgeTrbNetHeaders.cpp b/beamtime/trb/trbnet_lib/TrbBridgeTrbNetHeaders.cpp deleted file mode 100644 index 0557eda1d4fbe79ec00046010927cc677d9b68e1..0000000000000000000000000000000000000000 --- a/beamtime/trb/trbnet_lib/TrbBridgeTrbNetHeaders.cpp +++ /dev/null @@ -1,165 +0,0 @@ -#include "TrbBridgeTrbNetHeaders.hpp" -#include <ctime> - -template < typename MAJOR, typename MINOR = uint8_t > -static MAJOR _swapEndianess(MAJOR a) { - MAJOR b; - MINOR* src = reinterpret_cast<MINOR*>(&a); - MINOR* dest = reinterpret_cast<MINOR*>(&b); - - constexpr unsigned int steps = sizeof(MAJOR)/sizeof(MINOR); - - for(unsigned int i=0; i<steps; i++) - dest[i] = src[steps-1 - i]; - - return b; -} - -/************************************************* - * EventHeader - *************************************************/ - -size_t TrbBridgeTrbNetEventHeader::setSizeWithPadding(size_t sizeWoPadding) { - size_t padding = 0; - if (sizeWoPadding & 0x7) - padding = 8 - (sizeWoPadding & 0x7); - - size = sizeWoPadding + padding; - return padding; -} - - -void TrbBridgeTrbNetEventHeader::writeToBuffer(uint32_t *buffer) const { - struct tm *parts = std::localtime(×tamp); - buffer[0] = size; - buffer[1] = 0x00030001; // TODO: dis says there's a version included, but cannot find it in files generated by evt builder - buffer[2] = triggerType; - buffer[3] = eventNumberPerFile; - - buffer[4] = ((parts->tm_year & 0xff) << 16) | (parts->tm_mon << 8) | (parts->tm_mday << 0); - buffer[5] = (parts->tm_hour << 16) | (parts->tm_min << 8) | (parts->tm_sec << 0); - buffer[6] = runNumber; - buffer[7] = 0; - - if (swappedEndianess) - for(unsigned int i=0; i<8; i++) - buffer[i] = _swapEndianess(buffer[i]); -} - -void TrbBridgeTrbNetEventHeader::loadFromBuffer(const uint32_t* buffer) { - uint32_t* src = const_cast<uint32_t*>(buffer); - struct tm parts; - - if (buffer[1] > 0x100000) { - // need to swap endianess - src = new uint32_t[8]; - for(unsigned int i = 0; i < 8; i++) - src[i] = _swapEndianess(buffer[i]); - - swappedEndianess = true; - } else { - swappedEndianess = false; - } - - size = src[0]; - triggerType = uint16_t(src[2]); - eventNumberPerFile = src[3]; - runNumber = src[6]; - - parts.tm_year = (src[4] >> 16) & 0xff; - parts.tm_mon = (src[4] >> 8) & 0xff; - parts.tm_mday = (src[4] >> 0) & 0xff; - - parts.tm_hour = (src[5] >> 16) & 0xff; - parts.tm_min = (src[5] >> 8) & 0xff; - parts.tm_sec = (src[5] >> 0) & 0xff; - - timestamp = std::mktime(&parts); - - if (src != buffer) delete[] src; -} - -TrbBridgeTrbNetEventHeader TrbBridgeTrbNetEventHeader::operator<<(const uint32_t* buffer) { - loadFromBuffer(buffer); - return *this; -} - -uint32_t* operator<<(uint32_t* buffer, const TrbBridgeTrbNetEventHeader & evtHdr) { - evtHdr.writeToBuffer(buffer); - return buffer; -} - -/************************************************* - * SubEventHeader - *************************************************/ - -void TrbBridgeTrbNetSubEventHeader::writeToBuffer(uint32_t *buffer) const { - buffer[0] = size; - buffer[1] = 0x00020001 | ((triggerType & 0xf) << 4); - buffer[2] = subEventId; - buffer[3] = (triggerNumber << 8) | triggerCode; - - if (swappedEndianess) - for(unsigned int i=0; i<4; i++) - buffer[i] = _swapEndianess(buffer[i]); -} - -void TrbBridgeTrbNetSubEventHeader::loadFromBuffer(const uint32_t* buffer) { - uint32_t* src = const_cast<uint32_t*>(buffer); - - if (buffer[1] > 0x100000) { - // need to swap endianess - src = new uint32_t[4]; - for(unsigned int i = 0; i < 4; i++) - src[i] = _swapEndianess(buffer[i]); - - swappedEndianess = true; - } else { - swappedEndianess = false; - } - - size = src[0]; - triggerType = (src[1] >> 4) & 0xf; - subEventId = src[2]; - triggerCode = uint8_t(src[3]); - triggerNumber = src[3] >> 8; - - if (src != buffer) delete[] src; -} - -TrbBridgeTrbNetSubEventHeader TrbBridgeTrbNetSubEventHeader::operator<<(const uint32_t* buffer) { - loadFromBuffer(buffer); - return *this; -} -uint32_t* operator<<(uint32_t* buffer, const TrbBridgeTrbNetSubEventHeader & subEvtHdr) { - subEvtHdr.writeToBuffer(buffer); - return buffer; -} - -/************************************************* - * SubEventHeader - *************************************************/ -TrbBridgeTrbNetSubSubEventHeader::TrbBridgeTrbNetSubSubEventHeader(unsigned int ssEvtId, unsigned int sze, uint32_t* buf) - : subSubEventId(ssEvtId) - , size(sze) - , payload(buf) -{} - -std::list<TrbBridgeTrbNetSubSubEventHeader> TrbBridgeTrbNetSubSubEventHeader::extractSubSubEvents( - const TrbBridgeTrbNetSubEventHeader & subEventHeader, uint32_t* buffer) throw (TrbBridgeTrbNetHeaderException) { - std::list<TrbBridgeTrbNetSubSubEventHeader> result; - - unsigned int wordIdx = 4; // skip sub-event header - while(wordIdx < subEventHeader.size/4) { - uint16_t id = buffer[wordIdx] & 0xffff; - unsigned int sseSize = 4 + 4*(buffer[wordIdx]>>16); // length (excl. header in words) -> size (incl. header in bytes) - result.push_back( TrbBridgeTrbNetSubSubEventHeader( id, sseSize, &buffer[wordIdx+1]) ); - - wordIdx += sseSize / 4; - } - - if (wordIdx != subEventHeader.size/4) - throw TrbBridgeTrbNetHeaderException("Sum of sub-sub-event length exceeds sub-event size"); - - return result; -} diff --git a/beamtime/trb/trbnet_lib/TrbBridgeTrbNetHeaders.hpp b/beamtime/trb/trbnet_lib/TrbBridgeTrbNetHeaders.hpp deleted file mode 100644 index ba7be8d07e1bcb857699f855825b44286d42cc14..0000000000000000000000000000000000000000 --- a/beamtime/trb/trbnet_lib/TrbBridgeTrbNetHeaders.hpp +++ /dev/null @@ -1,108 +0,0 @@ -#pragma once -#include <chrono> -#include <list> -#include <string> -#include <exception> - -/* header definitions are based on - * Development and Implementation of a New Trigger and - * Data Acquisition System for the HADES Detector (2012) - * by Jan Michel - * chapter 5.1 - */ - - -class TrbBridgeTrbNetHeaderException : public std::exception { -public: - explicit TrbBridgeTrbNetHeaderException(const std::string& what_arg = "") : _what(what_arg) {} - virtual const char* what() const throw() {return _what.c_str();} - -private: - std::string _what; -}; - -struct TrbBridgeTrbNetEventHeader { - uint32_t size; /**< size in bytes incl header and padding (should by dividable by 8 but not enforced here */ - uint16_t triggerType; - uint32_t eventNumberPerFile; /**< i-th event in hld file */ - std::time_t timestamp; - uint32_t runNumber; /**< random run number that all events in an hld file share */ - - bool swappedEndianess; - - /** - * Adds padding (if necessary) and sets size. - * @return size of padding required in bytes - */ - size_t setSizeWithPadding(size_t sizeWoPadding); - - - /** - * Write values defined above into buffer. - * - * @param buffer Destination to write to; require >=32 bytes of space - */ - void writeToBuffer(uint32_t *buffer) const; - - /** - * Load values defined above from buffer - * - * @param buffer Pointer to first word of header - */ - void loadFromBuffer(const uint32_t* buffer); - - /** - * synonym for loadFromBuffer. - */ - TrbBridgeTrbNetEventHeader operator<<(const uint32_t* buffer); -}; - -uint32_t* operator<<(uint32_t* buffer, const TrbBridgeTrbNetEventHeader & evtHdr); - - -struct TrbBridgeTrbNetSubEventHeader { - uint32_t size; /**< size in bytes incl header and padding (should by dividable by 8 but not enforced here */ - uint16_t subEventId; /**< "endpoint id" */ - uint32_t triggerNumber; /**< sequential trigger number generated by CTS */ - uint8_t triggerCode; /**< random trigger code generated by CTS */ - uint8_t triggerType; /**< not specified, but GbE and CBMNet bridge include it never-the-less */ - - bool swappedEndianess; - - /** - * Write values defined above into buffer. - * - * @param buffer Destination to write to; require >=16 bytes of space - */ - void writeToBuffer(uint32_t *buffer) const; - - /** - * Load values defined above from buffer - * - * @param buffer Pointer to first word of header - */ - void loadFromBuffer(const uint32_t* buffer); - - /** - * synonym for loadFromBuffer. - */ - TrbBridgeTrbNetSubEventHeader operator<<(const uint32_t* buffer); -}; - -uint32_t* operator<<(uint32_t* buffer, const TrbBridgeTrbNetSubEventHeader & subEvtHdr); - -struct TrbBridgeTrbNetSubSubEventHeader { - uint16_t subSubEventId; - uint16_t size; /**< size in bytes incl. header */ - uint32_t* payload; - - TrbBridgeTrbNetSubSubEventHeader(unsigned int ssEvtId=0, unsigned int size=0, uint32_t* payload=0); - - /** - * Searches for all sub-sub-events with-in an sub-event - * @param subEventHeader - * @param buffer Pointer to the first word of the sub-event (i.e. the header) - * @return list of sub-sub-events found - */ - static std::list<TrbBridgeTrbNetSubSubEventHeader> extractSubSubEvents(const TrbBridgeTrbNetSubEventHeader & subEventHeader, uint32_t* buffer) throw (TrbBridgeTrbNetHeaderException); -}; diff --git a/beamtime/trd/CMakeLists.txt b/beamtime/trd/CMakeLists.txt deleted file mode 100644 index c18e81cac799417b5c77ad78680ecefa9037ddb5..0000000000000000000000000000000000000000 --- a/beamtime/trd/CMakeLists.txt +++ /dev/null @@ -1,87 +0,0 @@ -# Create a library called "libCbmFlibReader" which includes the source files given in -# the array . -# The extension is already found. Any number of sources could be listed here. - -Set(INCLUDE_DIRECTORIES - ${CBMDATA_DIR} - ${CBMDATA_DIR}/base - ${CBMDATA_DIR}/trd - - ${CBMBASE_DIR} - - ${CBMROOT_SOURCE_DIR}/beamtime/base - ${CBMROOT_SOURCE_DIR}/beamtime/data/raw - - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/tools - ${CMAKE_CURRENT_SOURCE_DIR}/lib - - ${CBMROOT_SOURCE_DIR}/beamtime/cern2014 - -) - -Set(SYSTEM_INCLUDE_DIRECTORIES - ${BASE_INCLUDE_DIRECTORIES} - ${Boost_INCLUDE_DIR} - ${ROOT_INCLUDE_DIR} - ) - -Include_Directories(${INCLUDE_DIRECTORIES}) -Include_Directories(SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES}) - - -Set(LINK_DIRECTORIES - ${ROOT_LIBRARY_DIR} - ${FAIRROOT_LIBRARY_DIR} - ${Boost_LIBRARY_DIRS} - ${Vc_LIB_DIR} - ${KFParticle_LIB_DIR} -) - -Link_Directories( - ${LINK_DIRECTORIES} -) - -Set(SRCS - tools/CbmTrdTestBeamTools.cxx - tools/CbmTrdTestBeamTools2017DESY.cxx - tools/CbmTrdTestBeamTools2017GIF.cxx - tools/CbmTrdTestBeamTools2018GIF.cxx - tools/CbmTrdTestBeamToolsBuch2016.cxx - tools/CbmTrdLabTools.cxx - - lib/CbmSpadicTriggerComp.cxx - lib/CbmTrdQABase.cxx - lib/CbmTrdQAHit.cxx - lib/CbmTrdQACosmics.cxx - lib/CbmTrdQAEfficiency.cxx - lib/CbmTrdDESYAlignment.cxx -# lib/CbmTrdQABaseline.cxx - lib/CbmTrdSimpleDigitizer.cxx -# lib/CbmTrdAdvDigitizer.cxx - lib/CbmTrdDigiAnalysis.cxx - lib/CbmTrdSimpleClusterizer.cxx - lib/CbmTrdSimpleClusterAnalysis.cxx - lib/CbmTrdClusterAnalysis.cxx - lib/CbmTrdTestBeamAnalysis.cxx -# lib/CbmTrdTimeCorrel.cxx -# lib/CbmTrdTestBeamAnalysis2015SPS.cxx - -) - -Set(NO_DICT_SRCS -) - -If(_UINT8_T_EXIST) - Add_Definitions(-DHAVE_UINT8_T_HEADER_FILE) - Set(DEFINITIONS HAVE_UINT8_T_HEADER_FILE) -EndIf() - -Set(LINKDEF CbmTrdBeamtimeLinkDef.h ) -Set(LIBRARY_NAME CbmTrdBeamtime) -Set(DEPENDENCIES - CbmBase CbmBeamtimeBase fles_ipc_legacy flib_dpb flib_dpb_20 - spadicMessage Base -) - -GENERATE_LIBRARY() diff --git a/beamtime/trd/CbmTrdBeamtimeLinkDef.h b/beamtime/trd/CbmTrdBeamtimeLinkDef.h deleted file mode 100644 index 24e733b6b7b200f6a0acb39c1be7bc0c21c31bd6..0000000000000000000000000000000000000000 --- a/beamtime/trd/CbmTrdBeamtimeLinkDef.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifdef __CINT__ - -#pragma link off all globals; -#pragma link off all classes; -#pragma link off all functions; - -#pragma link C++ class CbmSpadicTriggerComp; -#pragma link C++ class CbmTrdTestBeamTools; -#pragma link C++ class CbmTrdTestBeamTools2017DESY; -#pragma link C++ class CbmTrdTestBeamTools2017GIF; -#pragma link C++ class CbmTrdTestBeamTools2018GIF; -#pragma link C++ class CbmTrdTestBeamToolsBuch2016; -#pragma link C++ class CbmTrdLabTools; -#pragma link C++ class CbmTrdQABase; -#pragma link C++ class CbmTrdQACosmics; -#pragma link C++ class CbmTrdQAHit; -#pragma link C++ class CbmTrdQAEfficiency; -//#pragma link C++ class CbmTrdQABaseline; -#pragma link C++ class CbmTrdSimpleDigitizer; -//#pragma link C++ class CbmTrdAdvDigitizer; -#pragma link C++ class CbmTrdDigiAnalysis; -#pragma link C++ class CbmTrdSimpleClusterizer; -#pragma link C++ class CbmTrdSimpleClusterAnalysis; -#pragma link C++ class CbmTrdDESYAlignment; -#pragma link C++ class CbmTrdClusterAnalysis; -#pragma link C++ class CbmTrdTestBeamAnalysis; -//#pragma link C++ class CbmTrdTimeCorrel; -//#pragma link C++ class CbmTrdTestBeamAnalysis2015SPS; - -#endif diff --git a/beamtime/trd/lib/CbmSpadicTriggerComp.cxx b/beamtime/trd/lib/CbmSpadicTriggerComp.cxx deleted file mode 100644 index dd2ef17e0d1600e35d73b7388dcb5fc543eba475..0000000000000000000000000000000000000000 --- a/beamtime/trd/lib/CbmSpadicTriggerComp.cxx +++ /dev/null @@ -1,268 +0,0 @@ -#include <CbmSpadicTriggerComp.h> -#include "CbmSpadicRawMessage.h" -#include "CbmBeamDefaults.h" -#include "CbmTrdDigi.h" -#include "CbmTrdAddress.h" - -#include "FairLogger.h" - -#include "TH1.h" -#include "TH2.h" -#include "TCanvas.h" - -#include "TString.h" -#include "TStyle.h" - -#include <cmath> -#include <map> -#include <vector> -#include <deque> - -ClassImp(CbmSpadicTriggerComp) - -// ---- Default constructor ------------------------------------------- -CbmSpadicTriggerComp::CbmSpadicTriggerComp () : - FairTask ("CbmSpadicTriggerComp"), fRawSpadic (nullptr), fProcSpadic ( - nullptr), fMessageCounter (0), fProcessedMessages (0), fNrTimeSlices (0) -{ - LOG(debug) << "Default Constructor of CbmSpadicTriggerComp"; -} - -// ---- Destructor ---------------------------------------------------- -CbmSpadicTriggerComp::~CbmSpadicTriggerComp () -{ - LOG(debug) << "Destructor of CbmSpadicTriggerComp"; -} - -// ---- Initialisation ---------------------------------------------- -void CbmSpadicTriggerComp::SetParContainers () -{ - LOG(debug) << "SetParContainers of CbmSpadicTriggerComp"; - // Load all necessary parameter containers from the runtime data base - /* - FairRunAna* ana = FairRunAna::Instance(); - FairRuntimeDb* rtdb=ana->GetRuntimeDb(); - - <CbmSpadicTriggerCompDataMember> = (<ClassPointer>*) - (rtdb->getContainer("<ContainerName>")); - */ -} - -// ---- Init ---------------------------------------------------------- -InitStatus CbmSpadicTriggerComp::Init () -{ - LOG(debug) << "Initilization of CbmSpadicTriggerComp"; - - // Get a handle from the IO manager - FairRootManager* ioman = FairRootManager::Instance (); - - // Get a pointer to the previous already existing data level - fRawSpadic = - static_cast<TClonesArray*> (ioman->GetObject ("SpadicRawMessage")); - if (!fRawSpadic) - { - LOG(fatal) - << "No InputDataLevelName array!\n CbmSpadicTriggerComp will be inactive"; - return kERROR; - } - fProcSpadic = new TClonesArray ("CbmSpadicRawMessage"); - ioman->Register ("SpadicProcessedMessage", "TRD Processed Messages", - fProcSpadic, kTRUE); - - return kSUCCESS; -} - -// ---- ReInit ------------------------------------------------------- -InitStatus CbmSpadicTriggerComp::ReInit () -{ - LOG(debug) << "Initilization of CbmSpadicTriggerComp"; - return kSUCCESS; -} - -// ---- Exec ---------------------------------------------------------- -void CbmSpadicTriggerComp::Exec (Option_t*) -{ - fProcSpadic->Clear (); - LOG(info) << "CbmSpadicTriggerComp: Number of current TimeSlice:" - << fNrTimeSlices++; - LOG(info) << "CbmSpadicTriggerComp: rawMessages in TS: " - << fRawSpadic->GetEntriesFast (); - LOG(debug) << "CbmSpadicTriggerComp: Begin sorting CbmSpadicMessage*"; - Int_t nSpadicMessages = fRawSpadic->GetEntriesFast (); //SPADIC messages per TimeSlice - CbmSpadicRawMessage* raw = nullptr; - std::deque<CbmSpadicRawMessage*> processedMessages; - std::deque<CbmSpadicRawMessage*> selfCreatedMessages; - std::map<Int_t,std::vector<CbmSpadicRawMessage*> > channelSortedMessages; - for (Int_t iSpadicMessage = 0; iSpadicMessage < nSpadicMessages; - ++iSpadicMessage) - { - raw = static_cast<CbmSpadicRawMessage*> (fRawSpadic->At (iSpadicMessage)); - if (raw == nullptr) - { - LOG(debug) - << "CbmSpadicTriggerComp: found nullptr in fRawSpadic in Timeslice: " - << fNrTimeSlices; - continue; - } - Int_t spadicID = GetSpadicID(raw->GetSourceAddress()); - Int_t sysID = 0;//to be filled with appropriate function. - Int_t chID = raw->GetChannelID(); - Int_t linearizedChID=sysID*NrOfHalfSpadics*16+spadicID*16+chID; - if(spadicID == -1|| chID < 0 ||chID>15){ - processedMessages.push_back(raw); - LOG(debug) << "CbmSpadicTriggerComp: found unprocessable CbmSpadicMessage*"; - continue; - } - if(raw->GetHit() == false && raw->GetHitAborted() == false){ - processedMessages.push_back(raw); - LOG(debug) << "CbmSpadicTriggerComp: found CbmSpadicMessage* not to be processed"; - continue; - } -/* if(raw->GetStopType()==0){ - processedMessages.push_back(raw); - continue; - }*/ - channelSortedMessages[linearizedChID].push_back(raw); - } - LOG(info) << "CbmSpadicTriggerComp: starting naive rejoin"; - Int_t samples[64]; - for(Int_t i =0;i<64;i++) - samples[i]=-255; - Int_t samplesCount = 0; - for (auto &ent : channelSortedMessages) - { - LOG(debug) << "CbmSpadicTriggerComp: processing linear ChID: " - << ent.first; - LOG(debug) << "CbmSpadicTriggerComp: linear ChID Size: " - << ent.second.size(); - CbmSpadicRawMessage* firstMessage = nullptr; - for (UInt_t i =0; i<ent.second.size();i++){ - CbmSpadicRawMessage* currentMessage = ent.second.at(i); - if(currentMessage == nullptr){ - continue; - } - if (firstMessage == nullptr) - { - if(currentMessage->GetStopType()==0){ - processedMessages.push_back(currentMessage); - continue; - } - firstMessage = currentMessage; - } - //Naive implementation: try to fill 32 Samples, discarding true multihits - Int_t NrSamples = currentMessage->GetNrSamples (); - Int_t* MessageSamples = currentMessage->GetSamples (); - for (Int_t j = 0; (j < NrSamples || j + samplesCount < 64); j++) - { - samples[j + samplesCount] = *(MessageSamples + j); - } - samplesCount += NrSamples; - if (samplesCount >= 32) - { - //create temporary CbmSpadicRawMessage to hold the newly constructed Message - CbmSpadicRawMessage* tempMessage = new CbmSpadicRawMessage ( - firstMessage->GetEquipmentID (), - firstMessage->GetSourceAddress (), - firstMessage->GetChannelID (), - firstMessage->GetEpochMarker (), firstMessage->GetTime (), - firstMessage->GetSuperEpoch (), - firstMessage->GetTriggerType (), firstMessage->GetInfoType (), - 0, firstMessage->GetGroupId (), - firstMessage->GetBufferOverflowCount (), 32, samples, true, - false, false, false, false, false, false); - processedMessages.push_back (tempMessage); - selfCreatedMessages.push_back (tempMessage); - firstMessage = nullptr; - for (Int_t j = 0; j < 64; j++) - samples[j] = -255; - samplesCount = 0; - } - } - } - auto CompareSpadicMessages= - [&](CbmSpadicRawMessage* a,CbmSpadicRawMessage* b) - { - if(a->GetFullTime() < b->GetFullTime()) - return true; - else - return false; - }; - std::sort(processedMessages.begin(),processedMessages.end(),CompareSpadicMessages); - for (UInt_t i =0; i<processedMessages.size();i++){ - CbmSpadicRawMessage* currentMessage = processedMessages.at (i); - new ((*fProcSpadic)[fProcSpadic->GetEntriesFast ()]) CbmSpadicRawMessage ( - currentMessage->GetEquipmentID (), - currentMessage->GetSourceAddress (), currentMessage->GetChannelID (), - currentMessage->GetEpochMarker (), currentMessage->GetTime (), - currentMessage->GetSuperEpoch (), currentMessage->GetTriggerType (), - currentMessage->GetInfoType (), currentMessage->GetStopType (), - currentMessage->GetGroupId (), - currentMessage->GetBufferOverflowCount (), - currentMessage->GetNrSamples (), currentMessage->GetSamples (), - currentMessage->GetHit (), currentMessage->GetInfo (), - currentMessage->GetEpoch (), currentMessage->GetEpochOutOfSynch (), - currentMessage->GetHitAborted (), currentMessage->GetOverFlow (), - currentMessage->GetStrange ()); - } - LOG(info) << "CbmSpadicTriggerComp: Created Messages in TS: " - << selfCreatedMessages.size (); - for (auto ptr : selfCreatedMessages){ - delete ptr; - } - LOG(info) << "CbmSpadicTriggerComp: processedMessages in TS: " - << fProcSpadic->GetEntriesFast (); -} - -// ---- FinishEvent---------------------------------------------------- -/*void CbmSpadicTriggerComp::FinishEvent () -{ - LOG(debug) << "FinishEvent of CbmSpadicTriggerComp"; - fProcSpadic->Clear (); -}*/ - -Int_t CbmSpadicTriggerComp::GetSpadicID(Int_t sourceA) -{ - //TString spadic=""; - Int_t SpaId = -1; - switch (sourceA) { - case (SpadicBaseAddress+0): // first spadic - //spadic="Spadic0"; - SpaId = 0; - break; - case (SpadicBaseAddress+1): // first spadic - //spadic="Spadic0"; - SpaId = 1; - break; - case (SpadicBaseAddress+2): // second spadic - //spadic="Spadic1"; - SpaId = 2; - break; - case (SpadicBaseAddress+3): // second spadic - //spadic="Spadic1"; - SpaId = 3; - break; - case (SpadicBaseAddress+4): // third spadic - //spadic="Spadic2"; - SpaId = 4; - break; - case (SpadicBaseAddress+5): // third spadic - //spadic="Spadic2"; - SpaId = 5; - break; - default: - LOG(error) << "Source Address " << sourceA << " not known."; - break; - } - return SpaId; -} -// ---- Finish -------------------------------------------------------- -void CbmSpadicTriggerComp::Finish () -{ - LOG(debug) << "Finish of CbmSpadicTriggerComp"; - // Update Histos and Canvases -}/* -void CbmSpadicTriggerComp::FinishTask () -{ - LOG(debug) << "Finish of CbmSpadicTriggerComp"; - // Update Histos and Canvases -}*/ diff --git a/beamtime/trd/lib/CbmSpadicTriggerComp.h b/beamtime/trd/lib/CbmSpadicTriggerComp.h deleted file mode 100644 index 78a943ee06b416777019c99c53a0e2948d6ccde5..0000000000000000000000000000000000000000 --- a/beamtime/trd/lib/CbmSpadicTriggerComp.h +++ /dev/null @@ -1,71 +0,0 @@ -#ifndef CBMSPADICTRIGGERCOMP_H -#define CBMSPADICTRIGGERCOMP_H - -#include "FairTask.h" -#include "CbmSpadicRawMessage.h" -#include "TClonesArray.h" -#include <algorithm> - -class CbmSpadicTriggerComp : public FairTask -{ - public: - - /** Default constructor **/ - CbmSpadicTriggerComp(); - - /** Constructor with parameters (Optional) **/ - // CbmSpadicTriggerComp(Int_t verbose); - - - /** Destructor **/ - ~CbmSpadicTriggerComp(); - - - /** Initiliazation of task at the beginning of a run **/ - virtual InitStatus Init(); - - /** ReInitiliazation of task when the runID changes **/ - virtual InitStatus ReInit(); - - - /** Executed for each event. **/ - virtual void Exec(Option_t* opt); - - /** Load the parameter container from the runtime database **/ - virtual void SetParContainers(); - - /** Finish task called at the end of the run **/ - virtual void Finish(); - -/* - * Executed after each event. * - virtual void FinishEvent(); - - * Action at end of run. For this task and all of the subtasks. * - virtual void FinishTask(); -*/ -// inline Int_t GetSpadicID(Int_t sourceA); - Int_t GetSpadicID(Int_t sourceA); - - - private: - - /** Input array from previous already existing data level **/ - TClonesArray* fRawSpadic; - /** Output array **/ - TClonesArray* fProcSpadic; - - Int_t fMessageCounter; - Int_t fProcessedMessages; - Int_t fNrTimeSlices; - - - public: - - CbmSpadicTriggerComp(const CbmSpadicTriggerComp&); - CbmSpadicTriggerComp operator=(const CbmSpadicTriggerComp&); - - ClassDef(CbmSpadicTriggerComp,1); -}; - -#endif diff --git a/beamtime/trd/lib/CbmTrdAdvDigitizer.cxx b/beamtime/trd/lib/CbmTrdAdvDigitizer.cxx deleted file mode 100644 index 66b38ed3e6debbb7d76bb6cf68b22cb527d90f88..0000000000000000000000000000000000000000 --- a/beamtime/trd/lib/CbmTrdAdvDigitizer.cxx +++ /dev/null @@ -1,107 +0,0 @@ -/* - * CbmTrdAdvDigitizer.cpp - * - * Created on: Apr 22, 2017 - * Author: philipp - */ - -#include <CbmTrdAdvDigitizer.h> - -CbmTrdAdvDigitizer::CbmTrdAdvDigitizer () - : CbmTrdQABase ("CbmTrdAdvDigitizer") -{ - // TODO Auto-generated constructor stub - -} - -CbmTrdAdvDigitizer::~CbmTrdAdvDigitizer () -{ - // TODO Auto-generated destructor stub -} - -InitStatus -CbmTrdAdvDigitizer::Init () -{ - LOG(debug) << "Initilization of " << this->GetName (); - // Get a handle from the IO manager - FairRootManager* ioman = FairRootManager::Instance (); - - // Get a pointer to the previous already existing data level - fRaw = static_cast<TClonesArray*> (ioman->GetObject ("SpadicRawMessage")); - if (!fRaw) - { - LOG(fatal) << "No InputDataLevelName SpadicRawMessage array!\n" - << this->GetName () << " will be inactive"; - return kERROR; - } - - SetOutputBranchPersistent("TrdDigi",false); - - fDigis = new TClonesArray ("CbmTrdDigi", 100); - ioman->Register ("TrdDigi", "TRD Digis", fDigis, - IsOutputBranchPersistent ("TrdDigi")); - - - // Do whatever else is needed at the initilization stage - // Create histograms to be filled - // initialize variables - CbmTrdAdvDigitizer::CreateHistograms (); - - return kSUCCESS; - -} - -void -CbmTrdAdvDigitizer::CreateHistograms () -{ - for (Int_t layer = 0; layer < 4; layer++) - { - TString HistName = "Baselinemap_Layer_" + std::to_string (layer); - fHm->Add ( - HistName.Data (), - new TProfile2D (HistName.Data (), HistName.Data (), 256, -0.5, 255.5, - 6, -0.5, 5.5)); - fHm->P2 (HistName.Data ())->GetXaxis ()->SetTitle ("Column"); - fHm->P2 (HistName.Data ())->GetYaxis ()->SetTitle ("Row"); - } - TString GraphName = "Digis_Created"; - fHm->Add (GraphName.Data (), new TGraph); - fHm->G1 (GraphName.Data ())->SetNameTitle (GraphName.Data (), - GraphName.Data ()); - fHm->G1 (GraphName.Data ())->GetXaxis ()->SetTitle ("TimeSlice"); - fHm->G1 (GraphName.Data ())->GetYaxis ()->SetTitle ("Nr of created Digis"); -} - -void -CbmTrdAdvDigitizer::Exec (Option_t*) -{ - static Int_t NrTimeslice = 0; - //LOG(info) << this->GetName () << ": Clearing Digis"; - //fDigis->Clear (); - UInt_t nSpadicMessages = fRaw->GetEntriesFast (); //SPADIC messages per TimeSlice - TString Statefullness = "stateful"; - LOG(info) << this->GetName () << ": Estimating Baseline " << Statefullness - << " Digitizer"; - std::vector<TProfile2D*> Hitmaps; - - TString GraphName = "Digis_Created"; - fDigis->ExpandCreateFast (0); - LOG(info) << this->GetName () << ": Creating Digis with " << Statefullness - << " Digitizer"; - CbmTrdDigiFinder DF; - DF.start(); - DF.process_event(SetArrays(fRaw,fDigis)); - for (UInt_t iSpadicMessage = 0; iSpadicMessage < nSpadicMessages; - ++iSpadicMessage) - { - DF.process_event(NewMessage(iSpadicMessage)); - } - Int_t NrDigis=fDigis->GetEntries(); - fHm->G1 (GraphName.Data ())->SetPoint (fHm->G1 (GraphName.Data ())->GetN (), - NrTimeslice++, NrDigis); - fDigis->Sort (); - LOG(info) << this->GetName () << ": Finished creating Digis with " - << Statefullness << " Digitizer, with 0-suppressed Samples"; -} - -ClassImp(CbmTrdAdvDigitizer) diff --git a/beamtime/trd/lib/CbmTrdAdvDigitizer.h b/beamtime/trd/lib/CbmTrdAdvDigitizer.h deleted file mode 100644 index 204bb9c7449df8ff4c42016b97e3e395f6b2c4b4..0000000000000000000000000000000000000000 --- a/beamtime/trd/lib/CbmTrdAdvDigitizer.h +++ /dev/null @@ -1,489 +0,0 @@ -/* - * CbmTrdAdvDigitizer.h - * - * Created on: Apr 22, 2017 - * Author: Philipp Munkes - * - * Purpose: This Class is intended to provide digitization for CBM TRD Testbeamdata. - * This digitization is parametrised via the global CbmTrdTestbeamtools - * instance. The output is in the form of CbmTrdDigis. The Design is based on - * boost::MSM and should eventually support the disentanglement of Multi-Hits. - * The chosen front-end is the functor interface. - * Currently the State machine does most of its work in the entry and exit - * actions and doesn't implement any separate actions executed during the - * transition. Filtering for different processing paths is implemented - * within guard actions. Usually the work between entry and exit action - * is separated such, that the entry action performs the setup, while the - * exit action does the actual work and the cleanup. - */ - -#ifndef FLES_READER_TASKS_CBMTRDADVDIGITIZER_H_ -#define FLES_READER_TASKS_CBMTRDADVDIGITIZER_H_ - -#include <CbmTrdQABase.h> -#include <set> -// back-end -#include <boost/msm/back/state_machine.hpp> -//front-end -#include <boost/msm/front/state_machine_def.hpp> -// functors -#include <boost/msm/front/functor_row.hpp> -#include <boost/msm/front/euml/common.hpp> -// for And_ operator -#include <boost/msm/front/euml/operator.hpp> -// for func_state and func_state_machine -#include <boost/msm/front/euml/state_grammar.hpp> -//Circular Buffer for Baseline Estimation -#include <boost/circular_buffer.hpp> -#include <cstdint> -#include <algorithm> -#include <array> -#include <cmath> -#include "CbmTrdDigi.h" -#include <TClonesArray.h> - -namespace msm = boost::msm; -namespace mpl = boost::mpl; -using namespace msm::front; -// for And_ operator -using namespace msm::front::euml; - -class CbmTrdAdvDigitizer : public CbmTrdQABase -{ - public: - CbmTrdAdvDigitizer (); - InitStatus - Init (); - void - CreateHistograms (); - void - Exec (Option_t*); - virtual - ~CbmTrdAdvDigitizer (); - - //Define the Statemachine - //First define the events - //These events should only transport information - //for the guards and the different states - struct NewMessage - { - NewMessage (Int_t Idx) - : fIndex (Idx) - {/* - * The argument given is the index of the next Spadic raw message to be processed. - * The No filtering on this is performed, but it is encouraged to only - * iterate over a time sorted series of Indices, at least there should not - * be any time regressions on a channel. - */ - } - ; - Int_t fIndex; - }; - struct PrepareDigi - { - }; - struct CreateDigi - { - }; - struct SetArrays - { - SetArrays (TClonesArray*Raw, TClonesArray*Digis) - : fRaw (Raw), fDigis (Digis) - {/* - * Set the CbmSpadicRawMessage and CbmTrdDigi TClonesArrays. - */ - } - ; - TClonesArray*fRaw; - TClonesArray*fDigis; - }; - - struct CbmTrdDigiFinder_ : public msm::front::state_machine_def< - CbmTrdDigiFinder_> - { - - struct UninitializedEntry - {/* - * This is the initial state of the digifinder. The Digifinder is reinitilized for each timeslice, - * to mimic later operation procedures. Nothing is set yet and both the input and output arrays need to be provided. - */ - template<class Event, class FSM, class STATE> - void - operator() (Event const&, FSM&SM, STATE&) - { - LOG(debug) - << "CbmTrdAdvDigitizer: Initializing Digitizer State Machine"; - SM.fBT = CbmTrdTestBeamTools::Instance (nullptr); - } - }; - struct UninitializedExit - {/* - * This sets the in- and output arays. It is the responsibilty of the user to provide valid pointers. - */ - template<class Event, class FSM, class STATE> - void - operator() (Event const&evt, FSM&SM, STATE&) - { - LOG(debug) - << "CbmTrdAdvDigitizer: Digitizer State Machine: Setting Arrays"; - SM.fRaw = evt.fRaw; - SM.fDigis = evt.fDigis; - SM.fNrDigis = 0; - } - }; - struct UninitializedTag - { - }; - typedef msm::front::euml::func_state<UninitializedTag, - UninitializedEntry, UninitializedExit> Uninitialized; - - struct ReadyEntry - {/* - * This is the entry into the'groundstate' of the state machine. It is prepared - * for the next digi and awaits the next index. Traversal of the input array is managed by the user, - * this enables emitting a time sorted output array. - */ - - template<class Event, class FSM, class STATE> - void - operator() (Event const&, FSM&, STATE&) - { - LOG(debug) - << "CbmTrdAdvDigitizer: Digitizer State Machine: Ready for new Message"; - } - }; - struct ReadyExit - { - template<class Event, class FSM, class STATE> - void - operator() (Event const&, FSM&, STATE&) - { - - } - }; - struct ReadyTag - { - }; - typedef msm::front::euml::func_state<ReadyTag, ReadyEntry, ReadyExit> Ready; - - struct HitFoundEntry - {/* - * Called after a MultiHit-Follower has been found by the guards. All bookkeeping variables - * are updated and initialized if necessary. State between different hits is kept via pointers - * to previous messages. If such state exists, this method should be called. This method will - * initialize the buffers for the samples and estimate the residual signal from the precursor hit. - */ - template<class Event, class FSM, class STATE> - void - operator() (Event const&evt, FSM&SM, STATE&) - { - LOG(debug) - << "CbmTrdAdvDigitizer: Digitizer State Machine: Estimating Hit Parameters"; - CbmSpadicRawMessage* raw = - static_cast<CbmSpadicRawMessage*> (SM.fRaw->At (evt.fIndex)); - SM.fCurrentMessage = raw; - //Nullptr Check is unnecessary, as we will only transition to this state if raw is valid; - UInt_t Address = SM.fBT->GetAddress (raw); - auto Identifier = SM.fIndexMap.find (Address); - if (Identifier == SM.fIndexMap.end ()) - { - Int_t NewIndex = SM.fIndexMap.size (); - SM.fIndexMap[Address] = NewIndex; - //TODO: Initialize all bookkeeping members. - Identifier = SM.fIndexMap.find (Address); - SM.fPointer.resize (SM.fPointer.size () + 1); - SM.fRunningBaseline.resize ( - SM.fRunningBaseline.size () + 1); - SM.fRunningBaseline.rbegin ()->set_capacity (1); - SM.fRunningBaseline.rbegin ()->resize (0); - SM.fBaselineStart = raw->GetFullTime (); - } - //TODO: Read Baseline to running Buffer - UInt_t Index = Identifier->second; - SM.fCurrentBookkeepingIndex = Index; - SM.fPointer[Index].push_back (raw); - int16_t BaselineEstimate = SM.fBT->GetBaseline (raw); - //if(BaselineEstimate<-120) - SM.fRunningBaseline[Index].push_back (BaselineEstimate); - SM.process_event (PrepareDigi ()); - } - }; - struct HitFoundExit - { - template<class Event, class FSM, class STATE> - void - operator() (Event const&, FSM&SM, STATE&) - { - CbmSpadicRawMessage*raw = SM.fCurrentMessage; - UInt_t Index = SM.fCurrentBookkeepingIndex; - Float_t BaselineEstimate = std::accumulate ( - SM.fRunningBaseline[Index].begin (), - SM.fRunningBaseline[Index].end (), 0L); - BaselineEstimate /= SM.fRunningBaseline[Index].size (); - /* - * Prepare sample and baseline arrays. the baseline array in this internal context is to be understood as the - * residual signal underlying the signal, e.g. the actual channel baseline or, in the case of a follower hit, - * the falling tail from the precursor hit. - */ - SM.fBaseline.fill (BaselineEstimate); - SM.fSamples.fill (0.0); - SM.fBaselineStart = raw->GetFullTime (); - Int_t*Samples = raw->GetSamples (); - UInt_t NrSamples = raw->GetNrSamples (); - for (UInt_t i = 0; i < NrSamples; i++) - SM.fSamples.at (i) = Samples[i]; - } - }; - struct HitFoundTag - { - }; - typedef msm::front::euml::func_state<HitFoundTag, HitFoundEntry, - HitFoundExit> HitFound; - - struct MultiHitFoundEntry - {/* - * Called after a standard hit has been found by the guards. All bookkeeping variables - * are updated and initialized if necessary. State between different hits is kept via pointers - * to previous messages. If such state exists, this method should not be called, but rather the - * multihit processing facilities. - * Also record the running baseline for each channel. - */ - template<class Event, class FSM, class STATE> - void - operator() (Event const&evt, FSM&SM, STATE&) - { - LOG(debug) - << "CbmTrdAdvDigitizer: Digitizer State Machine: Estimating MultiHit Parameters."; - CbmSpadicRawMessage* raw = - static_cast<CbmSpadicRawMessage*> (SM.fRaw->At (evt.fIndex)); - SM.fCurrentMessage = raw; - //Nullptr Check is unnecessary, as we will only transition to this state if raw is valid; - UInt_t Address = SM.fBT->GetAddress (raw); - auto Identifier = SM.fIndexMap.find (Address); - if (Identifier == SM.fIndexMap.end ()) - { - Int_t NewIndex = SM.fIndexMap.size (); - SM.fIndexMap[Address] = NewIndex; - //TODO: Initialize all bookkeeping members. - Identifier = SM.fIndexMap.find (Address); - SM.fPointer.resize (SM.fPointer.size () + 1); - SM.fRunningBaseline.resize ( - SM.fRunningBaseline.size () + 1); - SM.fRunningBaseline.rbegin ()->set_capacity (1); - SM.fRunningBaseline.rbegin ()->resize (0); - SM.fBaselineStart = raw->GetFullTime (); - } - //TODO: Read Baseline to running Buffer - UInt_t Index = Identifier->second; - SM.fCurrentBookkeepingIndex = Index; - SM.fPointer[Index].push_back (raw); - int16_t BaselineEstimate = SM.fBT->GetBaseline (raw); - //if(BaselineEstimate<-120) - SM.fRunningBaseline[Index].push_back (BaselineEstimate); - SM.process_event (PrepareDigi ()); - } - }; - struct MultiHitFoundExit - { - template<class Event, class FSM, class STATE> - void - operator() (Event const&, FSM&SM, STATE&) - { - CbmSpadicRawMessage*raw = SM.fCurrentMessage; - UInt_t Index = SM.fCurrentBookkeepingIndex; - Float_t BaselineEstimate = std::accumulate ( - SM.fRunningBaseline[Index].begin (), - SM.fRunningBaseline[Index].end (), 0L); - BaselineEstimate /= SM.fRunningBaseline[Index].size (); - /* - * Prepare sample and baseline arrays. the baseline array in this internal context is to be understood as the - * residual signal underlying the signal, e.g. the actual channel baseline or, in the case of a follower hit, - * the falling tail from the precursor hit. - */ - SM.fBaseline.fill (BaselineEstimate); - SM.fSamples.fill (0.0); - SM.fBaselineStart = raw->GetFullTime (); - Int_t*Samples = raw->GetSamples (); - UInt_t NrSamples = raw->GetNrSamples (); - for (UInt_t i = 0; i < NrSamples; i++) - SM.fSamples.at (i) = Samples[i]; - } - }; - struct MultiHitFoundTag - { - }; - typedef msm::front::euml::func_state<MultiHitFoundTag, - MultiHitFoundEntry, MultiHitFoundExit> MultiHitFound; - - struct DigiReadyEntry - {/* - *called after preparattion of the digi, either by the hit- or multihit-path - * Test if the baselinetimestamp is valid. - * Subtract Baseline&Signal correction. - */ - template<class Event, class FSM, class STATE> - void - operator() (Event const&, FSM&SM, STATE&) - { - CbmSpadicRawMessage*raw = SM.fCurrentMessage; - //UInt_t Index = SM.fCurrentBookkeepingIndex; (VF) not used - Int_t DeltaTime = raw->GetFullTime () - SM.fBaselineStart; - if (DeltaTime < 0) - LOG(fatal) - << "CbmTrdAdvDigitizer: Digitizer State Machine: Wrong Baseline Timestamp"; - UInt_t NrSamples = raw->GetNrSamples (); - for (UInt_t i = 0; i < NrSamples; i++) - SM.fSamples.at (i) -= SM.fBaseline.at (i + DeltaTime); - SM.process_event (CreateDigi ()); - } - }; - struct DigiReadyExit - { - template<class Event, class FSM, class STATE> - void - operator() (Event const&, FSM&SM, STATE&) - { - - CbmSpadicRawMessage*raw = SM.fCurrentMessage; - TClonesArray*Digis = SM.fDigis; //(VF) not used - Int_t NrDigis = SM.fNrDigis++; - CbmTrdDigi* Digi = - static_cast<CbmTrdDigi*> (SM.fDigis->ConstructedAt (NrDigis)); - Digi->SetCharge ( - SM.fBT->GetIntegratedCharge (SM.fSamples.data (), - raw->GetNrSamples ())); - Digi->SetAddress ( - static_cast<Int_t> (SM.fBT->GetAddress (raw))); - Digi->SetTime ( - raw->GetFullTime () * SM.fBT->GetSamplingTime ()); //65 ns per timestamp - Digi->SetTriggerType (raw->GetTriggerType ()); - Digi->SetInfoType (raw->GetInfoType ()); - Digi->SetStopType (raw->GetStopType ()); - Digi->SetPulseShape (SM.fSamples.data ());/*&Samples[32]*/ - //TODO: Mehr Durchwischen - UInt_t Index = SM.fCurrentBookkeepingIndex; - SM.fSamples.fill (0.0); - SM.fBaseline.fill (0.0); - //TODO: Only remove pointers if done, else delegate this to the multihit task. - SM.fBaselineStart = 0; - if (!SM.fIsPrecursor) - SM.fPointer[Index].erase (SM.fPointer[Index].begin ()); - SM.fIsPrecursor = false; - } - }; - struct DigiReadyTag - { - }; - typedef msm::front::euml::func_state<DigiReadyTag, DigiReadyEntry, - DigiReadyExit> DigiReady; - - typedef Uninitialized initial_state; - - //Define guards, currently only used to filter out hit messages - struct isHit - { - template<class EVT, class FSM, class SourceState, class TargetState> - bool - operator() (EVT const& evt, FSM&SM, SourceState&, TargetState&) - { - CbmSpadicRawMessage*raw = - static_cast<CbmSpadicRawMessage*> (SM.fRaw->At (evt.fIndex)); - if (raw) - { - if (raw->GetHit ()) - { - return true; - } - } - return false; - } - }; - struct isMultiHit - { - template<class EVT, class FSM, class SourceState, class TargetState> - bool - operator() (EVT const& evt, FSM&SM, SourceState&, TargetState&) - { - CbmSpadicRawMessage*raw = - static_cast<CbmSpadicRawMessage*> (SM.fRaw->At (evt.fIndex)); - if (raw) - { - if (raw->GetHitAborted ()) - { - return true; - } - } - return false; - } - }; - struct isFollower - { - template<class EVT, class FSM, class SourceState, class TargetState> - bool - operator() (EVT const& evt, FSM&SM, SourceState&, TargetState&) - { - CbmSpadicRawMessage*raw = - static_cast<CbmSpadicRawMessage*> (SM.fRaw->At (evt.fIndex)); - if (raw) - { - if (raw->GetHitAborted ()) - { - return true; - } - } - return false; - } - }; - - typedef CbmTrdDigiFinder_ df; - struct transition_table : mpl::vector< - // Start Event Next Action Guard - // +---------------+--------------+--------------+-----------------------+----------------+ - Row<Uninitialized, SetArrays, Ready, none, none>, - // +---------------+--------------+--------------+-----------------------+----------------+ - Row<Ready, NewMessage, HitFound, none, df::isHit>, - Row<Ready, NewMessage, MultiHitFound, none, df::isMultiHit>, - Row<Ready, NewMessage, HitFound , none , df::isFollower >, - // +---------------+--------------+--------------+-----------------------+----------------+ - Row<HitFound, PrepareDigi, DigiReady, none, none>, - // +---------------+--------------+--------------+-----------------------+----------------+ - Row<DigiReady, CreateDigi, Ready, none, none> - // +---------------+--------------+--------------+-----------------------+----------------+ - > - { - }; - template<class FSM, class Event> - void - no_transition (Event const& e, FSM&, int state) - { - LOG(debug) << "CbmTrdDigiFinder: no transition from state " << state - << " on event " << typeid(e).name (); - } - TClonesArray*fRaw ; - TClonesArray*fDigis; - CbmSpadicRawMessage* fCurrentMessage; - Bool_t fIsPrecursor; - Int_t fNrDigis; - UInt_t fCurrentBookkeepingIndex; - std::map<UInt_t, UInt_t> fIndexMap; - std::array<Float_t, 45> fBaseline; - std::array<Float_t, 45> fSamples; - std::vector<std::vector<CbmSpadicRawMessage*> > fPointer; - ULong_t fBaselineStart; - std::vector<boost::circular_buffer<int16_t>> fRunningBaseline; - CbmTrdTestBeamTools* fBT; - public: - CbmTrdDigiFinder_ () : - fRaw (nullptr), fDigis (nullptr), fCurrentMessage (nullptr), fIsPrecursor (false), - fNrDigis (0), fCurrentBookkeepingIndex (0), fIndexMap (), fBaseline (), fSamples (), - fPointer (), fBaselineStart (0), fRunningBaseline (), - fBT (CbmTrdTestBeamTools::Instance (nullptr)) - {}; - }; - typedef msm::back::state_machine<CbmTrdDigiFinder_> CbmTrdDigiFinder; - - ClassDef(CbmTrdAdvDigitizer,1) - ; -}; - -#endif /* FLES_READER_TASKS_CBMTRDADVDIGITIZER_H_ */ diff --git a/beamtime/trd/lib/CbmTrdClusterAnalysis.cxx b/beamtime/trd/lib/CbmTrdClusterAnalysis.cxx deleted file mode 100644 index e6bcf23a988116f8dc161368c316d75113c511b2..0000000000000000000000000000000000000000 --- a/beamtime/trd/lib/CbmTrdClusterAnalysis.cxx +++ /dev/null @@ -1,228 +0,0 @@ -#include "CbmTrdClusterAnalysis.h" -#include "CbmTrdDigi.h" -#include "CbmTrdCluster.h" -#include "CbmTrdHit.h" -#include "CbmHistManager.h" -//#include "CbmBeamDefaults.h" - -#include "FairLogger.h" - -#include "TH1.h" -#include "TH2.h" -#include "TProfile.h" -#include "TCanvas.h" - -#include "TString.h" -#include "TStyle.h" -#include "TMath.h" -#include "TVector3.h" - -#include <cmath> -#include <map> -#include <vector> -#include <math.h> - -CbmTrdClusterAnalysis::CbmTrdClusterAnalysis() - :FairTask("CbmTrdClusterAnalysis"), - fDigis(NULL), - fClusters(NULL), - fHits(NULL), - fHM(new CbmHistManager()) -{ - LOG(debug) << "Default Constructor of CbmTrdClusterAnalysis"; -} -CbmTrdClusterAnalysis::~CbmTrdClusterAnalysis() -{ - fDigis->Delete(); - delete fDigis; - fClusters->Delete(); - delete fClusters; - fHits->Delete(); - delete fHits; - LOG(debug) << "Destructor of CbmTrdClusterAnalysis"; -} -void CbmTrdClusterAnalysis::SetParContainers() -{ - LOG(debug) << "SetParContainers of CbmTrdClusterAnalysis"; -} -InitStatus CbmTrdClusterAnalysis::Init() -{ - FairRootManager* ioman = FairRootManager::Instance(); - fDigis = static_cast<TClonesArray*>(ioman->GetObject("TrdDigi")); - if ( ! fDigis) { - LOG(fatal) << "No CbmTrdDigi TClonesArray!\n CbmTrdClusterAnalysis will be inactive"; - return kERROR; - } - fClusters = static_cast<TClonesArray*>(ioman->GetObject("TrdCluster")); - if ( ! fClusters) { - LOG(fatal) << "No CbmTrdCluster TClonesArray!\n CbmTrdClusterAnalysis will be inactive"; - return kERROR; - } - fHits = new TClonesArray("CbmTrdHit", 100); - ioman->Register("TrdHit", "TRD Hits", fDigis, IsOutputBranchPersistent("TrdHit")); - - CbmTrdClusterAnalysis::CreateHistograms(); - - return kSUCCESS; -} -InitStatus CbmTrdClusterAnalysis::ReInit() -{ - LOG(debug) << "Initilization of CbmTrdClusterAnalysis"; - return kSUCCESS; -} -void CbmTrdClusterAnalysis::Exec(Option_t*) -{ - // Exec runs on the TimeSliceContainer level. The TClonesArrys are not available at this time. Therefore we do the analysis in the finish function. -} -void CbmTrdClusterAnalysis::Finish() -{ - TCanvas* c = new TCanvas("pulseshape","pulseshape",800,600); - TH1F* pulse = new TH1F("pulse","pulse",32,-0.5,31.5); - pulse->GetYaxis()->SetRangeUser(-255,256); - TString histName = ""; - // Int_t nDigis = fDigis->GetEntriesFast(); - Int_t nClusters = fClusters->GetEntriesFast(); - Int_t DigiCounter(0), ClusterCounter(0); - for (Int_t iCluster=0; iCluster < nClusters; iCluster++) { - ClusterCounter++; - CbmTrdCluster *cluster = (CbmTrdCluster*) fClusters->At(iCluster); - Int_t nofDigis = cluster->GetNofDigis(); - Int_t moduleAddress = 0; - Int_t /*secId(-1),*/ colId(-1), /*rowId(-1),*/ layerId(-1); // (VF) not used. - TVector3 hit_posV; // hit position in global chamber coordinates - TVector3 local_pad_dposV; // Error in local pad coordinates - Double_t totalCharge = 0; - std::vector<Float_t> charge; - std::vector<Float_t> amplitude; - Int_t last_colId = -1; - //printf("|>------------------Cluster %i started\n", iCluster); - c->Clear(); - for (Int_t iDigi = 0; iDigi < nofDigis; iDigi++) { - DigiCounter++; - pulse->SetLineColor(iDigi+1); - Int_t digiId = cluster->GetDigi(iDigi); - Float_t digiCharge = 0.; - CbmTrdDigi* digi = (CbmTrdDigi*) fDigis->At(digiId); - //if (digi->GetStopType() > 0) continue; - Int_t nrSamples = digi->GetNrSamples(); - //printf("%02i: (%5.1f) ",nrSamples,digi->GetSamples()[nrSamples-1]); - Float_t maxAmpl = -255.0; - for (Int_t iBin = 0; iBin < nrSamples; iBin++){ - pulse->SetBinContent(iBin+1,digi->GetSamples()[iBin]); - digiCharge += digi->GetSamples()[iBin]; - if (digi->GetSamples()[iBin] > maxAmpl) - maxAmpl = digi->GetSamples()[iBin]; - //printf("%5.0f ",digi->GetSamples()[iBin]); - } - c->cd(); - if(iDigi==0) - pulse->DrawCopy(); - else - pulse->DrawCopy("same"); - pulse->Reset(); - //printf("\n"); - Int_t digiAddress = digi->GetAddress(); - // secId = CbmTrdAddress::GetSectorId(digiAddress); (VF) not used - colId = CbmTrdAddress::GetColumnId(digiAddress); - // rowId = CbmTrdAddress::GetRowId(digiAddress); (VF) not used - layerId = CbmTrdAddress::GetLayerId(digiAddress); - //printf("time %10.2f Layer%02i Sec%i row%02i col%02i\n",digi->GetTime(),layerId,secId,rowId,colId); - histName.Form("_Layer%02i",layerId); - //moduleInfo = fDigiPar->GetModule(CbmTrdAddress::GetModuleAddress(digiAddress)); - moduleAddress = CbmTrdAddress::GetModuleAddress(digi->GetAddress()); - if (nofDigis >= 3) - if (digi->GetStopType() == 0) - fHM->H1(TString("DigiSpectrum"+histName).Data())->Fill(digiCharge); - if (iDigi > 0 && last_colId != -1) - fHM->H1(TString("Delta_Channel_in_Cluster"+histName).Data())->Fill(colId - last_colId); - // --- Here we have to test if the channel with maximum charge is primary triggerd (or at the same time FNR) and is centered (use colId) between two FNR (or at the same time primary) channels with smaller charge--- - // left FNR [0]; max Prim.[1]; right FNR [2]; - // Due to the clusterization the input Digi TClonesArray should be sorted in time and space (combiId). Therefore the colId should increase from digi 0 to digi 'n'. But this has to be tested here!!! - charge.push_back(digiCharge); - amplitude.push_back(maxAmpl); - // --- - if (nofDigis >= 3) - if (digi->GetStopType() == 0) - totalCharge += digiCharge; - last_colId = colId; - } - TString pulseId; - pulseId.Form("pics/%08iCluster.png",iCluster); - c->Update(); - if (iCluster % 100 == 0){ - //c->SaveAs(pulseId); - } - //printf("------------------>|Cluster %i finished\n", iCluster); - if (nofDigis >= 3) - fHM->H1(TString("ClusterSpectrum"+histName).Data())->Fill(totalCharge); - if (nofDigis == 3){ // Here we need a better condition to be able to use also clusters larger than 3 channels calculating the PRF for the channel with the highest charge and the left and right neighboring channels - if (charge[0] > 0 && charge[1] > 0 && charge[2] > 0){ - if (charge[0] <= charge[1] && charge[2] <= charge[1]){ - Float_t d = 0.5 * W * (TMath::Log(charge[2]/charge[0])) / (TMath::Log((charge[1]*charge[1]) / (charge[0]*charge[2]))); - fHM->H2(TString("PRF_Integral"+histName).Data())->Fill(-d, charge[1] / totalCharge); - fHM->H2(TString("PRF_Integral"+histName).Data())->Fill(-d - W, charge[0] / totalCharge); - fHM->H2(TString("PRF_Integral"+histName).Data())->Fill(-d + W, charge[2] / totalCharge); - fHM->H1(TString("PRF_Integral_Profile"+histName).Data())->Fill(-d, charge[1] / totalCharge); - fHM->H1(TString("PRF_Integral_Profile"+histName).Data())->Fill(-d - W, charge[0] / totalCharge); - fHM->H1(TString("PRF_Integral_Profile"+histName).Data())->Fill(-d + W, charge[2] / totalCharge); - - } - if (amplitude[0] > 0 && amplitude[1] > 0 && amplitude[2] > 0){ - if (amplitude[0] <= amplitude[1] && amplitude[2] <= amplitude[1]){ - Float_t d = 0.5 * W * (TMath::Log(amplitude[2]/amplitude[0])) / (TMath::Log((amplitude[1]*amplitude[1]) / (amplitude[0]*amplitude[2]))); - fHM->H2(TString("PRF_maxAmpl"+histName).Data())->Fill(-d, amplitude[1] / (amplitude[0] + amplitude[1] + amplitude[2])); - fHM->H2(TString("PRF_maxAmpl"+histName).Data())->Fill(-d - W, amplitude[0] / (amplitude[0] + amplitude[1] + amplitude[2])); - fHM->H2(TString("PRF_maxAmpl"+histName).Data())->Fill(-d + W, amplitude[2] / (amplitude[0] + amplitude[1] + amplitude[2])); - fHM->H1(TString("PRF_maxAmpl_Profile"+histName).Data())->Fill(-d, amplitude[1] / (amplitude[0] + amplitude[1] + amplitude[2])); - fHM->H1(TString("PRF_maxAmpl_Profile"+histName).Data())->Fill(-d - W, amplitude[0] / (amplitude[0] + amplitude[1] + amplitude[2])); - fHM->H1(TString("PRF_maxAmpl_Profile"+histName).Data())->Fill(-d + W, amplitude[2] / (amplitude[0] + amplitude[1] + amplitude[2])); - } - } - } - } - Int_t nofHits = fHits->GetEntriesFast(); - new ((*fHits)[nofHits]) CbmTrdHit(moduleAddress, hit_posV, local_pad_dposV, 0, iCluster, 0, 0, totalCharge); - - /** - * \brief Standard constructor CbmTrdHit. - *\param address Unique detector ID - *\param pos Position in global c.s. [cm] - *\param dpos Errors of position in global c.s. [cm] - *\param dxy XY correlation of the hit - *\param refId Index of digi or cluster - *\param eLossTR Energy losses of electron via TR - *\param eLossdEdx Energy deposition in the detector without TR - *\param eLoss TR + dEdx - **/ - } - - - LOG(debug) << "Finish of CbmTrdRawBeamProfile"; - // Write to file - fHM->WriteToFile(); - // Update Histos and Canvases - LOG(info) << "CbmTrdClusterAnalysis::Finish Digis: " << fDigis->GetEntriesFast() << " Digis in Clusters: " << DigiCounter; - LOG(info) << "CbmTrdClusterAnalysis::Finish Clusters: " << fClusters->GetEntriesFast() << " Clusters found: " << ClusterCounter; - LOG(info) << "CbmTrdClusterAnalysis::Finish Hits: " << fHits->GetEntriesFast(); -} - void CbmTrdClusterAnalysis::CreateHistograms() - { - gStyle->SetNumberContours(99); - gStyle->SetPadTickX(1); - gStyle->SetPadTickY(1); - TString histName; - for (Int_t layerId = 0; layerId < 6; layerId++){ - histName.Form("_Layer%02i",layerId); - fHM->Add(TString("ClusterSpectrum"+histName).Data(), new TH1I(TString("ClusterSpectrum"+histName), TString("ClusterSpectrum"+histName), 2*32*255*5+1,-32*5*255.5,32*5*255.5)); - fHM->Add(TString("DigiSpectrum"+histName).Data(), new TH1I(TString("DigiSpectrum"+histName), TString("DigiSpectrum"+histName), 2*32*255+1,-32*255.5,32*255.5)); - fHM->Add(TString("PRF_maxAmpl"+histName).Data(), new TH2I(TString("PRF_maxAmpl"+histName), TString("PRF_maxAmpl"+histName), 300, -1.5*W, 1.5*W, 100, 0, 1)); - fHM->Add(TString("PRF_maxAmpl_Profile"+histName).Data(), new TProfile(TString("PRF_maxAmpl_Profile"+histName), TString("PRF_maxAmpl_Profile"+histName), 300, -1.5*W, 1.5*W, 0, 1)); - fHM->Add(TString("PRF_Integral"+histName).Data(), new TH2I(TString("PRF_Integral"+histName), TString("PRF_Integral"+histName), 300, -1.5*W, 1.5*W, 100, 0, 1)); - fHM->Add(TString("PRF_Integral_Profile"+histName).Data(), new TProfile(TString("PRF_Integral_Profile"+histName), TString("PRF_Integral_Profile"+histName), 300, -1.5*W, 1.5*W, 0, 1)); - fHM->Add(TString("Delta_Channel_in_Cluster"+histName).Data(), new TH1I(TString("Delta_Channel_in_Cluster"+histName), TString("Delta_Channel_in_Cluster"+histName),9,-4.5,4.5)); - } - } -void CbmTrdClusterAnalysis::DrawHistograms(){ - -} - ClassImp(CbmTrdClusterAnalysis) diff --git a/beamtime/trd/lib/CbmTrdClusterAnalysis.h b/beamtime/trd/lib/CbmTrdClusterAnalysis.h deleted file mode 100644 index 3c015d0e69175d8a59fd6a24a28e157d4f43c3cf..0000000000000000000000000000000000000000 --- a/beamtime/trd/lib/CbmTrdClusterAnalysis.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef CBMTRDCLUSTERANALYSIS_H -#define CBMTRDCLUSTERANALYSIS_H - -#include "FairTask.h" -#include "CbmHistManager.h" - -#include "TClonesArray.h" - -class CbmTrdClusterAnalysis : public FairTask -{ - public: - - CbmTrdClusterAnalysis(); - ~CbmTrdClusterAnalysis(); - virtual InitStatus Init(); - virtual InitStatus ReInit(); - virtual void Exec(Option_t* opt); - virtual void SetParContainers(); - virtual void Finish(); - - private: - - TClonesArray *fDigis; - TClonesArray *fClusters; - TClonesArray *fHits; - - CbmHistManager *fHM; - - void CreateHistograms(); - void DrawHistograms(); - - const Float_t W = 1.0;//7.125; //(mm) - const Float_t H = 1.0;//75.0; - - CbmTrdClusterAnalysis(const CbmTrdClusterAnalysis&); - CbmTrdClusterAnalysis operator=(const CbmTrdClusterAnalysis&); - - ClassDef(CbmTrdClusterAnalysis,1); -}; - -#endif diff --git a/beamtime/trd/lib/CbmTrdCorrelDebug.cxx b/beamtime/trd/lib/CbmTrdCorrelDebug.cxx deleted file mode 100644 index 3dc5a537cf556988e211e5aec1d8b11fa8a24e18..0000000000000000000000000000000000000000 --- a/beamtime/trd/lib/CbmTrdCorrelDebug.cxx +++ /dev/null @@ -1,65 +0,0 @@ -#include "CbmTrdRawBeamProfile.h" - -#include "CbmSpadicRawMessage.h" -#include "CbmNxyterRawMessage.h" -#include "CbmTrbRawMessage.h" -#include "CbmTrdDigi.h" -#include "CbmTrdCluster.h" -#include "CbmHistManager.h" -#include "CbmBeamDefaults.h" -#include "CbmTrdAddress.h" -#include "CbmTrdDaqBuffer.h" - -#include "FairLogger.h" - -#include "TH1.h" -#include "TH2.h" -#include "TGraph.h" -#include "TCanvas.h" -#include "TString.h" -#include "TStyle.h" - -#include <cmath> -#include <map> -//#include <multimap> -#include <vector> -// ---- Default constructor ------------------------------------------- -CbmTrdCorrelDebug::CbmTrdCorrelDebug() - : FairTask("CbmTrdCorrelDebug"), - fRawSpadic(NULL), - fNxyterRaw(NULL), - fTrbRaw(NULL), - fDigis(NULL), - fClusters(NULL), - fiDigi(0), - fiCluster(0), - fHM(new CbmHistManager()), - fmaxTimeGlobal(0), - fmaxTimeGroup(), - fmaxFullTimeGlobal(0), - fmaxFullTimeGroup(), - flastDlmTriggerTime(), - fEpoch(-1), - flastEpoch(-1), - fSuperEpoch(-1), - flastSuperEpoch(-1), - fSpadicMessageCounter(0), - fNxyterMessageCounter(0), - fTrbMessageCounter(0), - fContainerCounter(0), - fInfoCounter(0), - fHitCounter(0), - fMultiHitCounter(0), - fErrorCounter(0), - fLostHitCounter(0), - fDoubleCounter(0), - fFragmentedCounter(0), - fSys0Spa0Buffer(), - fSys0Spa1Buffer(), - fTimeBuffer(), - fFullTimeBuffer(), - fFullTimeBufferAll(), - fTrbBuffer() -{ - LOG(debug) << "Default Constructor of CbmTrdCorrelDebug"; -} diff --git a/beamtime/trd/lib/CbmTrdCorrelDebug.h b/beamtime/trd/lib/CbmTrdCorrelDebug.h deleted file mode 100644 index fa7a7a21f53d52fe538a99c6f9e4b632b9a4167b..0000000000000000000000000000000000000000 --- a/beamtime/trd/lib/CbmTrdCorrelDebug.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef CBMTRDCORRELDEBUG_H -#define CBMTRDCORRELDEBUG_H - - - - - -#endif diff --git a/beamtime/trd/lib/CbmTrdDESYAlignment.cxx b/beamtime/trd/lib/CbmTrdDESYAlignment.cxx deleted file mode 100644 index fcafe348647ca24f5054273b50faa1d9cbfab060..0000000000000000000000000000000000000000 --- a/beamtime/trd/lib/CbmTrdDESYAlignment.cxx +++ /dev/null @@ -1,182 +0,0 @@ -#include "CbmTrdDESYAlignment.h" -#include "FairLogger.h" -#include "CbmHistManager.h" -#include "TString.h" -#include "TStyle.h" - -#include <cmath> -#include <map> -#include <vector> -#include <cmath> -#include <map> -#include <vector> - -ClassImp(CbmTrdDESYAlignment) - -CbmTrdDESYAlignment::CbmTrdDESYAlignment (TString /*_ClassName*/) : - CbmTrdQABase ("CbmTrdDESYAlignment"), fTemporalAlign(NULL), fSpatialAlign(NULL) -{ -} - -void -CbmTrdDESYAlignment::CreateHistograms () -{ - TString HistName = "Temporal_Alignment_Layers"; - fTemporalAlign = new TH2I (HistName.Data (), HistName.Data (), 8, -0.5, 7.5, - 5001, -.5, 5000.5); - fHm->Add (HistName.Data (), fTemporalAlign); - fHm->H2 (HistName.Data ())->GetXaxis ()->SetTitle ("Layer"); - fHm->H2 (HistName.Data ())->GetYaxis ()->SetTitle ("Delta TimeStamp"); - - HistName = "Spatial_Alignment_Layers"; - fSpatialAlign = new TH2I (HistName.Data (), HistName.Data (), 32*4, -0.5, 32*4-.5, - 32*4, -0.5, 32*4-.5); - fHm->Add (HistName.Data (), fSpatialAlign); - fHm->H2 (HistName.Data ())->GetXaxis ()->SetTitle ("first Pad"); - fHm->H2 (HistName.Data ())->GetYaxis ()->SetTitle ("second Pad"); - - -} - -//---------------------------------------------------------------------------------------- - -std::vector<CbmSpadicRawMessage*>::iterator -CbmTrdDESYAlignment::FindNextHit ( - std::vector<CbmSpadicRawMessage*>::iterator refIt, - std::vector<CbmSpadicRawMessage*>::iterator Current, - std::vector<CbmSpadicRawMessage*> Messages, Long64_t TimeLimit) -{ - Long64_t RefTime = (*refIt)->GetFullTime (); - CbmSpadicRawMessage*ref = *refIt; - std::vector<CbmSpadicRawMessage*>::iterator end = Messages.end (); - //std::vector<CbmSpadicRawMessage*>::iterator rend = Messages.rend (); - for (auto it = Current; it != end; Current++) - { - if ((*it)->GetFullTime () > ULong_t(RefTime + TimeLimit)) - return refIt; - if (fBT->GetColumnID (*it) == fBT->GetColumnID (ref)) - if (fBT->GetRowID (*it) == fBT->GetRowID (ref)) - return Current; - } - return refIt; -} - -void -CbmTrdDESYAlignment::Exec (Option_t*) -{ - static Int_t NrTimeSlice = -1; - std::vector<std::vector<Long64_t> > LastTime (fBT->GetNrLayers ()); - LOG(info) << this->GetName () << ": Number of current TimeSlice:" - << ++NrTimeSlice; - LOG(info) << this->GetName () << ": rawMessages in TS: " - << fRaw->GetEntriesFast (); - static int AlignCtr = 0; - Int_t nSpadicMessages = fRaw->GetEntriesFast (); //SPADIC messages per TimeSlice - std::vector<CbmSpadicRawMessage*> Messages; - //Messages.reserve (nSpadicMessages); - //Define Sorting algo, originally taken from CbmTrdTimeCorrel -/* - auto CompareSpadicMessages = - [&](CbmSpadicRawMessage* a,CbmSpadicRawMessage* b) - { - Int_t SpadicAddressA = fBT->GetAddress(a); - Int_t SpadicAddressB = fBT->GetAddress(b); - { - if(CbmTrdAddress::GetLayerId(SpadicAddressA)<CbmTrdAddress::GetLayerId(SpadicAddressB)) - return true; - else if(CbmTrdAddress::GetLayerId(SpadicAddressA)>CbmTrdAddress::GetLayerId(SpadicAddressB)) - return false; - else - { - if (CbmTrdAddress::GetRowId(SpadicAddressA)<CbmTrdAddress::GetRowId(SpadicAddressB)) - return true; - else if (CbmTrdAddress::GetRowId(SpadicAddressA)>CbmTrdAddress::GetRowId(SpadicAddressB)) - return false; - else - { - if (CbmTrdAddress::GetColumnId(SpadicAddressA)<CbmTrdAddress::GetColumnId(SpadicAddressB)) - return true; - else - if(a->GetFullTime() < b->GetFullTime()) - return true; - else - return false; - } - } - } - }; - LOG(info) << this->GetName () << " : Sorting " << Messages.size() <<" Messages for Alignment" - ; - std::sort (Messages.begin (), Messages.end(), CompareSpadicMessages); - LOG(info) << this->GetName () << ": Sorting done"; -*/ - /*if (AlignCtr > 100000) - return; -*/ - for (Int_t iSpadicMessage = 0; iSpadicMessage < nSpadicMessages; - ++iSpadicMessage) - { - CbmSpadicRawMessage *raw = static_cast<CbmSpadicRawMessage*> (fRaw->At ( - iSpadicMessage)); - if (raw) - if (raw->GetHit () || raw->GetHitAborted ()) - { - int next = iSpadicMessage; - Long64_t lastTime = raw->GetFullTime (); - Int_t LastPad = fBT->GetChannelOnPadPlane (raw) - + 32 * fBT->GetLayerID (raw); - do - { - CbmSpadicRawMessage *rawnext = - static_cast<CbmSpadicRawMessage*> (fRaw->At (next)); - if (rawnext->GetHit () || rawnext->GetHitAborted ()) - { - Long64_t nextTime = rawnext->GetFullTime (); - if (std::abs (nextTime - lastTime) < 10) - { - Int_t NextPad = fBT->GetChannelOnPadPlane (rawnext) - + 32 * fBT->GetLayerID (rawnext); - fSpatialAlign->Fill (LastPad, NextPad); - } - } - next++; - } - while (next != nSpadicMessages); - } - AlignCtr++; - } - -return; - - for (Int_t iSpadicMessage = 0; iSpadicMessage < nSpadicMessages; - ++iSpadicMessage) - { - CbmSpadicRawMessage *raw = static_cast<CbmSpadicRawMessage*> (fRaw->At ( - iSpadicMessage)); - if(raw) - if(raw->GetHit()||raw->GetHitAborted()) - if(fBT->GetLayerID(raw)==2) - { - Long64_t refTime=raw->GetFullTime(); - int next=0; - do - { - CbmSpadicRawMessage *rawnext = - static_cast<CbmSpadicRawMessage*> (fRaw->At (next)); - if (rawnext->GetHit () || rawnext->GetHitAborted ()) - { - if (fBT->GetColumnID (rawnext) == fBT->GetColumnID (raw)) - if (fBT->GetRowID (rawnext) == fBT->GetRowID (raw)) - { - Long64_t nextTime = rawnext->GetFullTime (); - fTemporalAlign->Fill (fBT->GetLayerID (rawnext), - nextTime - refTime); - } - } - next++; - } - while (next != nSpadicMessages); - } - } -} - diff --git a/beamtime/trd/lib/CbmTrdDESYAlignment.h b/beamtime/trd/lib/CbmTrdDESYAlignment.h deleted file mode 100644 index f6a39a0263edab6e2ee3f0f34d5174fb3c426bc7..0000000000000000000000000000000000000000 --- a/beamtime/trd/lib/CbmTrdDESYAlignment.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef CbmTrdDESYAlignment_H -#define CbmTrdDESYAlignment_H - -#include "CbmTrdQABase.h" - -/** @Class CbmTrdDESYAlignment - ** @author Philipp Munkes <p.munkes@uni-muenster.de> - ** @date 10th April 2017 - ** @brief Example of a derived class for CBM TRD Testbeam analysis. - ** - ** This class is intended for the Alignment of the TRD-Modules at DESY 2017. - **/ - -class CbmTrdDESYAlignment : public CbmTrdQABase -{ -protected: - /** Constructor with parameters (Optional) **/ - CbmTrdDESYAlignment (TString ClassName); -public: - - virtual void - CreateHistograms (); - virtual void - Exec (Option_t*); - std::vector<CbmSpadicRawMessage*>::iterator - FindNextHit (std::vector<CbmSpadicRawMessage*>::iterator, - std::vector<CbmSpadicRawMessage*>::iterator, - std::vector<CbmSpadicRawMessage*>, Long64_t); - /** Default constructor **/ - CbmTrdDESYAlignment () : - CbmTrdDESYAlignment ("CbmTrdDESYAlignment") - { - } - ; - TH2* fTemporalAlign,*fSpatialAlign; - - CbmTrdDESYAlignment(const CbmTrdDESYAlignment&) = delete; - CbmTrdDESYAlignment& operator=(const CbmTrdDESYAlignment&) = delete; - -ClassDef(CbmTrdDESYAlignment,1) - ; -}; - -#endif diff --git a/beamtime/trd/lib/CbmTrdDigiAnalysis.cxx b/beamtime/trd/lib/CbmTrdDigiAnalysis.cxx deleted file mode 100644 index 5c5ec45babd1ad3964d8c962335c553712afbd61..0000000000000000000000000000000000000000 --- a/beamtime/trd/lib/CbmTrdDigiAnalysis.cxx +++ /dev/null @@ -1,79 +0,0 @@ -/* - * CbmTrdDigiAnalysis.cxx - * - * Created on: Apr 22, 2017 - * Author: philipp - */ - -#include <CbmTrdDigiAnalysis.h> - -ClassImp(CbmTrdDigiAnalysis) - -CbmTrdDigiAnalysis::CbmTrdDigiAnalysis () - : CbmTrdQABase ("CbmTrdDigiAnalysis") -{ - // TODO Auto-generated constructor stub - -} - -CbmTrdDigiAnalysis::~CbmTrdDigiAnalysis () -{ - // TODO Auto-generated destructor stub -} - -void -CbmTrdDigiAnalysis::CreateHistograms () -{ - if(false) - for (Int_t Layer = 0; Layer <fBT->GetNrLayers (); ++Layer) - { - for (Int_t Row = 0; Row < fBT->GetNrRows(Layer) ; ++Row) - { - for (Int_t Col = 0; Col < fBT->GetNrColumns(Layer); Col++) - { - TString HistName = "Signalshape_Layer" + std::to_string(Layer) + "Row"+std::to_string(Row)+"Collumn" - + std::to_string (Col); - fHm->Create2<TH2I> (HistName.Data (), HistName.Data (), 32, -0.5, - 31.5, 512 + 256, -255.5, 511.5); - fHm->H2 (HistName.Data ())->GetYaxis ()->SetTitle ( - "0-suppressed ADC-Value"); - fHm->H2 (HistName.Data ())->GetXaxis ()->SetTitle ("Timebin"); - } - } - } - - for (Int_t Layer = 0; Layer <fBT->GetNrLayers (); ++Layer) - { - TString HistName = "Hitmap_Layer" + std::to_string(Layer); - fHm->Create2<TH2I> (HistName.Data (), HistName.Data (),fBT->GetNrColumns(Layer) , -0.5, fBT->GetNrColumns(Layer)-0.5, fBT->GetNrRows(Layer), -0.5, fBT->GetNrRows(Layer)-0.5); - fHm->H2 (HistName.Data ())->GetXaxis ()->SetTitle ("Columns"); - fHm->H2 (HistName.Data ())->GetYaxis ()->SetTitle ("Rows"); - } - -} - -void -CbmTrdDigiAnalysis::Exec (Option_t*) -{ - const Int_t NrDigis = fDigiMan->GetNofDigis(ECbmModuleId::kTrd); - // LOG(info) << this->GetName () << ": Analyzing Signalshape of " << NrDigis - // << " Digis "; - for (Int_t Index = 0; Index < NrDigis; Index++) - { - const CbmTrdDigi* Digi = fDigiMan->Get<CbmTrdDigi>(Index); - Int_t Address=fBT->GetAddress(Digi); - Int_t Layer=CbmTrdAddress::GetLayerId(Address); - Int_t Row=CbmTrdAddress::GetRowId(Address); - Int_t Col=CbmTrdAddress::GetColumnId(Address); - TString HistName = "Hitmap_Layer" + std::to_string(Layer); - - TH2* Hist=fHm->H2(HistName.Data()); - //for(Int_t Sample=0;Sample<32;Sample++) - Hist->Fill(Col,Row); - - } - LOG(debug) << this->GetName () << ": Done Analyzing Signalshape of " << NrDigis - << " Digis "; - -} - diff --git a/beamtime/trd/lib/CbmTrdDigiAnalysis.h b/beamtime/trd/lib/CbmTrdDigiAnalysis.h deleted file mode 100644 index 0246e75a7a9417de0abe8cf6bd95ce59d5dec668..0000000000000000000000000000000000000000 --- a/beamtime/trd/lib/CbmTrdDigiAnalysis.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * CbmTrdDigiAnalysis.h - * - * Created on: Apr 22, 2017 - * Author: philipp - */ - -#ifndef FLES_READER_TASKS_CBMTRDDIGIANALYSIS_H_ -#define FLES_READER_TASKS_CBMTRDDIGIANALYSIS_H_ - -#include <CbmTrdQABase.h> -#include "CbmTrdDigi.h" - - -class CbmTrdDigiAnalysis : public CbmTrdQABase -{ - public: - CbmTrdDigiAnalysis (); - void CreateHistograms (); - void Exec (Option_t*); - virtual - ~CbmTrdDigiAnalysis (); - - ClassDef(CbmTrdDigiAnalysis,1); - -}; - -#endif /* FLES_READER_TASKS_CBMTRDDIGIANALYSIS_H_ */ diff --git a/beamtime/trd/lib/CbmTrdQABase.cxx b/beamtime/trd/lib/CbmTrdQABase.cxx deleted file mode 100644 index a0ce32277292c6d7eebb573d5ea031e0c1d138ed..0000000000000000000000000000000000000000 --- a/beamtime/trd/lib/CbmTrdQABase.cxx +++ /dev/null @@ -1,249 +0,0 @@ -/** - *Minimal example of an CBM TRD QA analysis class. - *Any daughter class only needs to implement the CreateHistograms() and the Exec() functions. - *A future version will be parametriseable for different in-beam tests. - */ -#include "CbmTrdQABase.h" -#include "CbmSpadicRawMessage.h" -#include "CbmTrdTestBeamTools.h" -//#include "CbmBeamDefaults.h" - -#include "FairLogger.h" - -#include "CbmHistManager.h" - -#include "TString.h" -#include "TStyle.h" -#include <TFile.h> - -#include <cmath> -#include <map> -#include <vector> - -ClassImp(CbmTrdQABase) - -// ---- Default constructor ------------------------------------------- -CbmTrdQABase::CbmTrdQABase (CbmTrdTestBeamTools*ptr, TString _ClassName) : - FairTask (_ClassName.Data ()), fRaw (nullptr), fClusters ( - nullptr), fBT (CbmTrdTestBeamTools::Instance (ptr)), fHm ( - new CbmHistManager), fNrTimeslice (0) -{ - LOG(info) << TString ("Default Constructor of ") + TString (this->GetName ()); -} - -// ---- Destructor ---------------------------------------------------- -CbmTrdQABase::~CbmTrdQABase () -{ - LOG(debug) << TString ("Destructor of ") + TString (this->GetName ()); -} - -// ---- Initialisation ---------------------------------------------- -void -CbmTrdQABase::SetParContainers () -{ - LOG(debug) << TString ("SetParContainers of ") + TString (this->GetName ()); - // Load all necessary parameter containers from the runtime data base - /* - FairRunAna* ana = FairRunAna::Instance(); - FairRuntimeDb* rtdb=ana->GetRuntimeDb(); - - <CbmTrdQABaseDataMember> = (<ClassPointer>*) - (rtdb->getContainer("<ContainerName>")); - */ -} - -// ---- Init ---------------------------------------------------------- -InitStatus -CbmTrdQABase::Init () -{ - LOG(debug) << TString ("Initilization of ") + TString (this->GetName ()); - - // Get a handle from the IO manager - FairRootManager* ioman = FairRootManager::Instance (); - - // Get a pointer to the previous already existing data level - fRaw = static_cast<TClonesArray*> (ioman->GetObject ("SpadicRawMessage")); - if (!fRaw) - { - LOG(fatal) << "No InputDataLevelName array!\n " << this->GetName () - << " will be inactive"; - return kERROR; - } - fDigiMan = CbmDigiManager::Instance(); - fDigiMan->Init(); - if (fDigiMan->IsPresent(ECbmModuleId::kTrd)) - { - LOG(info) << "Digi Input Available"; - } - TClonesArray* tempArray = static_cast<TClonesArray*> (ioman->GetObject ("TrdCluster")); - if (tempArray) - { - LOG(info) << "Cluster Input Available"; - fClusters = tempArray; - } - CreateHistograms (); - return kSUCCESS; -} - -// ---- ReInit ------------------------------------------------------- -InitStatus -CbmTrdQABase::ReInit () -{ - LOG(debug) << "Initilization of " << this->GetName (); - return kSUCCESS; -} - -// ---- Exec ---------------------------------------------------------- -void -CbmTrdQABase::Exec (Option_t*) -{ - static Bool_t FirstTS = true; - if (FirstTS) - { - fNrTimeslice = -1; - FirstTS = false; - } - LOG(info) << this->GetName () << ": Number of current TimeSlice:" - << ++fNrTimeslice; - LOG(info) << this->GetName () << ": rawMessages in TS: " - << fRaw->GetEntriesFast (); - LOG(debug) << this->GetName () << ": Begin sorting CbmSpadicMessage*"; - Int_t nSpadicMessages = fRaw->GetEntriesFast (); //SPADIC messages per TimeSlice - TGraph* EinzelHistogram = fHm->G1 ("TSCounter"); - std::vector<TGraph*> HistogramArray; - for (Int_t RobID = 0; RobID < fBT->GetNrRobs (); RobID++) - { - for (Int_t SpadicID = 0; SpadicID < fBT->GetNrSpadics () * 2; SpadicID++) - { - HistogramArray.push_back ( - fHm->G1 ( - TString ( - "TSCounter" - + GetSpadicName (RobID, SpadicID, "Syscore", false)).Data ())); - } - } - EinzelHistogram->SetPoint (fNrTimeslice, fNrTimeslice, nSpadicMessages); - std::vector<Int_t> MessageCounters ( - fBT->GetNrRobs () * fBT->GetNrSpadics () * 2, 0); - for (Int_t iSpadicMessage = 0; iSpadicMessage < nSpadicMessages; - ++iSpadicMessage) - { - CbmSpadicRawMessage *raw = static_cast<CbmSpadicRawMessage*> (fRaw->At ( - iSpadicMessage)); - if (!raw) - continue; - if (static_cast<size_t>(GetRobID (raw) * fBT->GetNrSpadics () * 2 + GetSpadicID (raw)) - > HistogramArray.size () - || static_cast<size_t>(GetRobID (raw) * fBT->GetNrSpadics () * 2 + GetSpadicID (raw)) - > MessageCounters.size ()) - continue; - if (fBT->GetSpadicID (raw) > 0) - MessageCounters.at ( - GetRobID (raw) * fBT->GetNrSpadics () * 2 + GetSpadicID (raw))++;} - for (Int_t RobID = 0; RobID < fBT->GetNrRobs (); RobID++) - { - for (Int_t SpadicID = 0; SpadicID < fBT->GetNrSpadics () * 2; SpadicID++) - { - HistogramArray.at (RobID * fBT->GetNrSpadics () * 2 + SpadicID)->SetPoint ( - fNrTimeslice, fNrTimeslice, - MessageCounters.at (RobID * fBT->GetNrSpadics () * 2 + SpadicID)); - } - } - std::vector<Long64_t> MaxTime(2*fBT->GetNrSpadics()*fBT->GetNrRobs ()); - for (Int_t iSpadicMessage = 0; iSpadicMessage < nSpadicMessages; - ++iSpadicMessage) - { - CbmSpadicRawMessage *raw = static_cast<CbmSpadicRawMessage*> (fRaw->At ( - iSpadicMessage)); - if (!raw) continue; - - //LOG(info) << "Find Values out of Bounds Fulltime:" << raw->GetFullTime() << " GetRobID:" << fBT->GetRobID (raw) << " GetSpadicID:" << fBT->GetSpadicID(raw); - - if ((Long64_t(raw->GetFullTime())>MaxTime[2*fBT->GetNrSpadics()*fBT->GetRobID (raw)+fBT->GetSpadicID(raw)])&&(fBT->GetSpadicID(raw)>=0)) - - if(((static_cast<size_t>(2*fBT->GetNrSpadics()*fBT->GetRobID (raw)+fBT->GetSpadicID(raw))))<MaxTime.size()) - { - MaxTime.at(2*fBT->GetNrSpadics()*fBT->GetRobID (raw)+fBT->GetSpadicID(raw))=raw->GetFullTime(); - } - - } - - for (Int_t RobID = 0; RobID < fBT->GetNrRobs (); RobID++) - { - for (Int_t SpadicID = 0; SpadicID < fBT->GetNrSpadics () * 2; SpadicID++) - { - TString GraphName = "Time_vs_TS_" - + GetSpadicName (RobID, SpadicID, "Afck", false); - TGraph* currentGraph =fHm->G1(GraphName.Data()); - currentGraph->SetPoint(currentGraph->GetN(), fNrTimeslice,static_cast<double>(MaxTime.at(2*fBT->GetNrSpadics()*RobID+SpadicID))); - } - } -} -// ---- Create Histograms---------------------------------------------- -void -CbmTrdQABase::CreateHistograms () -{ - //TODO: Implement with CbmTrdTestBeamTools - fHm->Add ("TSCounter", new TGraph); - fHm->G1 ("TSCounter")->SetNameTitle ("TSCounter", "TSCounter"); - fHm->G1 ("TSCounter")->GetXaxis ()->SetTitle ("TS Number"); - fHm->G1 ("TSCounter")->GetYaxis ()->SetTitle ("Message Counter"); - for (Int_t RobID = 0; RobID < fBT->GetNrRobs (); RobID++) - { - for (Int_t SpadicID = 0; SpadicID < fBT->GetNrSpadics () * 2; SpadicID++) - { - fHm->Add ( - TString ( - "TSCounter" - + GetSpadicName (RobID, SpadicID, "Syscore", false)).Data (), - new TGraph); - TString GraphName = "TSCounter" - + GetSpadicName (RobID, SpadicID, "Syscore", false); - fHm->G1 (GraphName.Data ())->SetNameTitle (GraphName.Data (), - GraphName.Data ()); - fHm->G1 (GraphName.Data ())->GetXaxis ()->SetTitle ("TS Number"); - fHm->G1 (GraphName.Data ())->GetYaxis ()->SetTitle ( - "Message Counter"); - } - } - for (Int_t RobID = 0; RobID < fBT->GetNrRobs (); RobID++) - { - for (Int_t SpadicID = 0; SpadicID < fBT->GetNrSpadics () * 2; SpadicID++) - { - TString GraphName = "Time_vs_TS_" - + GetSpadicName (RobID, SpadicID, "Afck", false); - fHm->Add (GraphName.Data (), new TGraph); - fHm->G1 (GraphName.Data ())->SetNameTitle (GraphName.Data (), - GraphName.Data ()); - fHm->G1 (GraphName.Data ())->GetXaxis ()->SetTitle ("TS Number"); - fHm->G1 (GraphName.Data ())->GetYaxis ()->SetTitle ("FullTime"); - } - } -} - -// ---- FinishEvent---------------------------------------------------- -/*void CbmTrdQABase::FinishEvent () - { - LOG(debug) << "FinishEvent of CbmTrdQABase"; - fProcSpadic->Clear (); - }*/ - -// ---- Finish -------------------------------------------------------- -void -CbmTrdQABase::Finish () -{ - LOG(debug) << "Finish of " << this->GetName (); - FairRootManager::Instance ()->GetOutFile ()->cd (); - //Save Histograms - LOG(info) << "Saving Histograms of " << this->GetName (); - gDirectory->mkdir (this->GetName ()); - gDirectory->Cd (this->GetName ()); - fHm->WriteToFile (); - FairRootManager::Instance ()->GetOutFile ()->cd (); - LOG(debug) << "Finish of " << this->GetName () << " done."; -}/* - void CbmTrdQABase::FinishTask () - { - LOG(debug) << "Finish of CbmTrdQABase"; - // Update Histos and Canvases - }*/ diff --git a/beamtime/trd/lib/CbmTrdQABase.h b/beamtime/trd/lib/CbmTrdQABase.h deleted file mode 100644 index 019f83cd71ddf0576d569a265ff02296f33efb8d..0000000000000000000000000000000000000000 --- a/beamtime/trd/lib/CbmTrdQABase.h +++ /dev/null @@ -1,162 +0,0 @@ -#ifndef CBMTRDQABASE_H -#define CBMTRDQABASE_H - -#include "FairTask.h" -#include "CbmTrdTestBeamTools.h" -#include <CbmHistManager.h> -#include "CbmSpadicRawMessage.h" -#include "TClonesArray.h" -#include <algorithm> - -class CbmDigiManager; - -/** @Class CbmTrdQABase - ** @author Philipp Munkes <p.munkes@uni-muenster.de> - ** @date 10th April 2017 - ** @brief Base class for CBM TRD Testbeam analysis. - ** - ** This class provides infrastructure for the QA Analysis of CBM TRD test beam activity. - ** It provides three pointers TClonesArray with input data in the form of CbmSpadicRawMessages, - ** CbmTrdDigis or CbmTrdClusters and initializes them if available. - ** It also provides an instance of CbmHistManager fHm and stores the Histograms in a folder with the - ** name of the Class, which has to be explicitly set in the constructor via this->SetName. - ** - ** Parametrisation is done via an instance of CbmTrdTestBeamTools, of which the appropriate version - ** has to be set before initialization via CbmTrdTestBeamTools::Instance. - ** It is available in all derived classes via the pointer fBT. - ** - ** To implement your own analysis based on this frame work, derive a new class from CbmTrdBase and - ** implement your own Exec(Option_t*) and CreateHistograms() functions. - ** **/ - - -class CbmTrdQABase : public FairTask -{ - protected: - - /** Input array from previous already existing data level **/ - TClonesArray* fRaw; - CbmDigiManager* fDigiMan; - TClonesArray* fClusters; - CbmTrdTestBeamTools* fBT; - CbmHistManager* fHm; - Int_t fNrTimeslice; - - public: - /** Constructor with parameters (Optional) **/ - CbmTrdQABase(TString _ClassName):CbmTrdQABase(nullptr, _ClassName){}; - - CbmTrdQABase(CbmTrdTestBeamTools*,TString); - - /** Default constructor **/ - CbmTrdQABase():CbmTrdQABase(nullptr,TString("CbmTrdQABase")){}; - - /** Destructor **/ - ~CbmTrdQABase(); - - - /** Initiliazation of task at the beginning of a run **/ - virtual InitStatus Init(); - - /** ReInitiliazation of task when the runID changes **/ - virtual InitStatus ReInit(); - - - /** Executed for each event. **/ - virtual void Exec(Option_t* opt); - - /** Load the parameter container from the runtime database **/ - virtual void SetParContainers(); - - /** Finish task called at the end of the run **/ - virtual void Finish(); - - /*To ie implemented by inheriting Class*/ - virtual void CreateHistograms(); -/* - * Executed after each event. * - virtual void FinishEvent(); - - * Action at end of run. For this task and all of the subtasks. * - virtual void FinishTask(); -*/ -// inline Int_t GetSpadicID(Int_t sourceA); - //Functions to analyze Spadic Messages - TString GetSpadicName(Int_t RobID,Int_t SpadicID,TString RobName="SysCore",Bool_t FullSpadic=true){ - /** - * Provides a TString containing the name of a Spadic on a specific ROB. - * - * Default ROB is the SysCore. - * - * @param RobID Numeric id of the Read Out Board - * @param SpadicID Numeric id of the Read Out Board - * @param RobName String naming the Type of ROB in use - * @param FullSpadic Selects wether the string contains 'Spadic' (default case) or 'Half_Spadic' - * @return TString containing a unique name for the specified Spadic. - */ - return fBT->GetSpadicName(RobID,SpadicID,RobName,FullSpadic); - }; - Int_t GetRobID(CbmSpadicRawMessage* raw){ - return fBT->GetRobID(raw); - }; - Int_t GetSpadicID(CbmSpadicRawMessage* raw){ - return fBT->GetSpadicID(raw); - }; - inline TString GetTriggerName(Int_t Triggertype){ - TString triggerTypes[4] = { "Global_ trigger", - "Self_triggered", - "Neighbor_triggered", - "Self_and_neighbor_triggered"}; - if(Triggertype<-1||Triggertype>3){ - LOG(fatal)<< this->GetName() << ": Unknown Triggertype "<< Triggertype; - } - if(Triggertype==-1) - return TString("No_Hit"); - return triggerTypes[Triggertype]; - } - inline TString GetStopName(Int_t Stoptype){ - - TString stopTypes[6] = {"Normal_end_of_message", - "Channel_buffer_full", - "Ordering_FIFO_full", - "Multi_hit", - "Multi_hit_and_channel_buffer_full", - "Multi_hit_and_ordering_FIFO_full"}; - if(Stoptype<0||Stoptype>5){ - LOG(fatal)<< this->GetName() << ": Unknown Stoptype "<< Stoptype; - } - return stopTypes[Stoptype]; - } - Int_t GetModuleID(CbmSpadicRawMessage* raw){ - return fBT->GetModuleID(raw);} - ; - Int_t GetLayerID(CbmSpadicRawMessage* raw){ - return fBT->GetLayerID(raw); - }; - Int_t GetRowID(CbmSpadicRawMessage* raw){ - return fBT->GetRowID(raw); - }; - Int_t GetColumnID(CbmSpadicRawMessage* raw){ - return fBT->GetColumnID(raw); - }; - Int_t GetChannelOnPadPlane(CbmSpadicRawMessage* raw){ - return fBT->GetChannelOnPadPlane(raw); - }; - Int_t GetMaximumAdc(CbmSpadicRawMessage* raw){ - return fBT->GetMaximumAdc(raw); - }; - Float_t GetIntegratedCharge(CbmSpadicRawMessage* raw,Double_t Base=0.0){ - return fBT->GetIntegratedCharge(raw,Base); - }; - - - - public: - - CbmTrdQABase(const CbmTrdQABase&); - CbmTrdQABase operator=(const CbmTrdQABase&); - - ClassDef(CbmTrdQABase,1); -}; - -#endif diff --git a/beamtime/trd/lib/CbmTrdQABaseline.cxx b/beamtime/trd/lib/CbmTrdQABaseline.cxx deleted file mode 100644 index 53e23dab45e67cf53d67e655dc59c43e86a45651..0000000000000000000000000000000000000000 --- a/beamtime/trd/lib/CbmTrdQABaseline.cxx +++ /dev/null @@ -1,89 +0,0 @@ -#include "CbmTrdQABaseline.h" -#include "CbmBeamDefaults.h" -#include "FairLogger.h" -#include "CbmHistManager.h" -//#include "TString.h" -//#include "TStyle.h" - - -#include <cmath> -#include <map> -#include <vector> - -ClassImp(CbmTrdQABaseline); -//const Int_t NrRobs=4; -//const Int_t NrSpadics=3; - -CbmTrdQABaseline::CbmTrdQABaseline(TString ClassName) : - CbmTrdQABase("CbmTrdQABaseline") -{ -} - -void CbmTrdQABaseline::CreateHistograms(){ - for (Int_t layer=0;layer<1;layer++){ - TString HistName="Baselinemap_Layer_"+std::to_string(layer); - fHm->Add(HistName.Data(), new TProfile2D(HistName.Data(),HistName.Data(),32,-0.5,31.5,1,-0.5,0.5)); - fHm->P2(HistName.Data())->GetXaxis()->SetTitle("Column"); - fHm->P2(HistName.Data())->GetYaxis()->SetTitle("Row"); - } - fHm->Add("multihits", new TH1D("multihits","multihits",3,-0.5,2.5)); - fHm->Add("delta", new TH1D("delta","delta",201,-100.5,100.5)); - - -} - -void CbmTrdQABaseline::Exec(Option_t*) -{ - static Int_t NrTimeSlice=-1; - LOG(info)<<this->GetName()<<": Loop for Baselinemaps starting"; - std::vector<Double_t> LastHit(NrOfActiveSyscores*NrOfActiveSpadics*32); - LOG(info) << this->GetName() <<": Number of current TimeSlice:" - << ++NrTimeSlice; - LOG(info) << this->GetName() <<": rawMessages in TS: " - << fRaw->GetEntriesFast (); - - Int_t nSpadicMessages = fRaw->GetEntriesFast (); //SPADIC messages per TimeSlice - std::vector<TProfile2D*> Hitmaps; - for (Int_t layer=0;layer<1;layer++){ - TString HistName="Baselinemap_Layer_"+std::to_string(layer); - Hitmaps.push_back(fHm->P2(HistName.Data())); - } - for (Int_t iSpadicMessage=0; iSpadicMessage < nSpadicMessages; ++iSpadicMessage){ - CbmSpadicRawMessage *raw= static_cast<CbmSpadicRawMessage*>(fRaw->At(iSpadicMessage)); - //LOG(info) << "Predecessor" << raw->GetPredecessor() << "Follower"<< raw->GetFollower() << "delta"<< raw->GetDelta(); - - - if (!(raw->GetHit())) - { - continue; - } - - //LOG(info) << raw->GetTriggerType(); -/* - - if (raw->GetPredecessor()==1||raw->GetTriggerType()==1)// Triggertype =1 - {fHm->H1("multihits")->Fill(1.); - //fHm->H1("delta")->Fill(raw->GetDelta()); - } - else - { - if (raw->GetFollower()==1||raw->GetTriggerType()==1) - {fHm->H1("multihits")->Fill(2.); - */ - if (raw->GetDelta()>-99) - fHm->H1("delta")->Fill(raw->GetDelta()); - /* } - else - if(raw->GetTriggerType()==1) - { - {fHm->H1("multihits")->Fill(0.);} - } - } - - Hitmaps.at(GetLayerID(raw))->Fill(GetColumnID(raw),GetRowID(raw),raw->GetSamples()[0]); - */ - } - LOG(info)<<this->GetName()<<": Loop for Baselinemaps done"; - -} - diff --git a/beamtime/trd/lib/CbmTrdQABaseline.h b/beamtime/trd/lib/CbmTrdQABaseline.h deleted file mode 100644 index 673812f320142cdef1dbf19faa2183c12ec9b0ac..0000000000000000000000000000000000000000 --- a/beamtime/trd/lib/CbmTrdQABaseline.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef CBMTRDQABASELINE_H -#define CBMTRDQABASELINE_H - -#include "CbmTrdQABase.h" - -class CbmTrdQABaseline : public CbmTrdQABase -{ - protected: - /** Constructor with parameters (Optional) **/ - CbmTrdQABaseline(TString ClassName); - public: - - virtual void CreateHistograms(); - virtual void Exec(Option_t*); - /** Default constructor **/ - CbmTrdQABaseline():CbmTrdQABaseline("CbmTrdQABaseline"){}; - - ClassDef(CbmTrdQABaseline,1); -}; - -#endif diff --git a/beamtime/trd/lib/CbmTrdQACosmics.cxx b/beamtime/trd/lib/CbmTrdQACosmics.cxx deleted file mode 100644 index 6e4991bba3be2bb92504f132a66e5ecc8d22c9d5..0000000000000000000000000000000000000000 --- a/beamtime/trd/lib/CbmTrdQACosmics.cxx +++ /dev/null @@ -1,123 +0,0 @@ -/* - * CbmTrdQACosmics.cxx - * - * Created on: Apr 22, 2017 - * Author: philipp - */ - -#include <CbmTrdQACosmics.h> - -ClassImp(CbmTrdQACosmics) - -CbmTrdQACosmics::CbmTrdQACosmics () - : CbmTrdQABase ("CbmTrdQACosmics") -{ - // TODO Auto-generated constructor stub - -} - -CbmTrdQACosmics::~CbmTrdQACosmics () -{ - // TODO Auto-generated destructor stub -} - -void -CbmTrdQACosmics::CreateHistograms () -{ - for (Int_t Layer = 0; Layer <fBT->GetNrLayers (); ++Layer) - { - for (Int_t Row = 0; Row < fBT->GetNrRows(Layer) ; ++Row) - { - for (Int_t Col = 0; Col < fBT->GetNrColumns(Layer); Col++) - { - TString HistName = "Signalshape_Layer" + std::to_string(Layer) + "Row"+std::to_string(Row)+"Column" - + std::to_string (Col); - fHm->Create2<TH2I> (HistName.Data (), HistName.Data (), 32, -0.5, - 31.5, 512, -256.5, 255.5); - fHm->H2 (HistName.Data ())->GetYaxis ()->SetTitle ( - "ADC-Value"); - fHm->H2 (HistName.Data ())->GetXaxis ()->SetTitle ("Timebin"); - } - } - } - for(Int_t syscore = 0; syscore < fBT->GetNrRobs(); ++syscore) { - for(Int_t spadic = 0; spadic < fBT->GetNrSpadics(); ++spadic) { - TString spadicName = GetSpadicName(syscore, spadic, "SysCore",true); - TString HistName="Lost_Hitratio_vs_Time_"+spadicName; - fHm->Add(HistName.Data(), new TGraph()); - fHm->G1(HistName.Data())->SetNameTitle(HistName.Data(),HistName.Data()); - fHm->G1(HistName.Data())->GetYaxis()->SetTitle("Lost_Hitratio"); - fHm->G1(HistName.Data())->GetXaxis()->SetTitle("Time/s"); - } - } - for(Int_t syscore = 0; syscore < fBT->GetNrRobs(); ++syscore) { - for(Int_t spadic = 0; spadic < fBT->GetNrSpadics(); ++spadic) { - TString spadicName = GetSpadicName(syscore, spadic, "SysCore",true); - TString HistName="Avg_StopType_vs_Time_"+spadicName; - fHm->Add(HistName.Data(), new TGraph()); - fHm->G1(HistName.Data())->SetNameTitle(HistName.Data(),HistName.Data()); - fHm->G1(HistName.Data())->GetYaxis()->SetTitle("Lost_Hitratio"); - fHm->G1(HistName.Data())->GetXaxis()->SetTitle("Time/s"); - } - } -} - -void -CbmTrdQACosmics::Exec (Option_t*) -{ - Int_t NrDigis = fRaw->GetEntries(); - LOG(info) << this->GetName () << ": Analyzing Signalshape of " << NrDigis - << " Digis "; - for (Int_t Index = 0; Index < NrDigis; Index++) - { - auto raw = static_cast<CbmSpadicRawMessage*> (fRaw->At (Index)); - if (!(raw->GetHit()||raw->GetHitAborted())) - continue; - if (fBT->GetSpadicID(raw)<0) - continue; -// Int_t Address=fBT->GetAddress(raw); - Int_t Layer=fBT->GetLayerID(raw); - Int_t Row=fBT->GetRowID(raw); - Int_t Col=fBT->GetColumnID(raw); - TString HistName = "Signalshape_Layer" + std::to_string(Layer) + "Row"+std::to_string(Row)+"Column" - + std::to_string (Col); - TH2* Hist=fHm->H2(HistName.Data()); - if(raw->GetTriggerType()==3) - continue; - for(Int_t Sample=0;Sample<raw->GetNrSamples();Sample++) - Hist->Fill(Sample,raw->GetSamples()[Sample]); - } - LOG(debug) << this->GetName () << ": Done Analyzing Signalshape of " << NrDigis - << " Digis "; - LOG(info) << this->GetName () << ": Analyzing Lost_Ratio "; - std::vector<Int_t> LostMessagesTotal(fBT->GetNrRobs()*fBT->GetNrSpadics()*2); - std::vector<Int_t> HitsTotal(fBT->GetNrRobs()*fBT->GetNrSpadics()*2); - for (Int_t Index = 0; Index < NrDigis; Index++) - { - auto raw = static_cast<CbmSpadicRawMessage*> (fRaw->At (Index)); - if((fBT->GetRobID(raw)<0)||fBT->GetSpadicID(raw)<0) - continue; - if ((raw->GetHit()||raw->GetHitAborted())){ - ++HitsTotal.at(fBT->GetNrSpadics()*fBT->GetRobID(raw)*2+fBT->GetSpadicID(raw)); - } - if (raw->GetOverFlow()){ - LostMessagesTotal.at(fBT->GetNrSpadics()*fBT->GetRobID(raw)*2+fBT->GetSpadicID(raw))+=raw->GetBufferOverflowCount(); - } - } - for(Int_t syscore = 0; syscore < fBT->GetNrRobs(); ++syscore) { - for(Int_t spadic = 0; spadic < fBT->GetNrSpadics(); ++spadic) { - TString spadicName = GetSpadicName(syscore, spadic, "SysCore",true); - TString HistName="Lost_Hitratio_vs_Time_"+spadicName; - if(HitsTotal.at(fBT->GetNrSpadics()*syscore*2+spadic)<=0) - continue; - float LostRatio=static_cast<float>(LostMessagesTotal.at(fBT->GetNrSpadics()*syscore*2+spadic))/HitsTotal.at(fBT->GetNrSpadics()*syscore*2+spadic); - std::cout << fNrTimeslice << " " << HitsTotal.at(fBT->GetNrSpadics()*syscore*2+spadic) << " " << LostMessagesTotal.at(fBT->GetNrSpadics()*syscore*2+spadic) << " " << LostRatio <<std::endl; - fHm->G1(HistName.Data())->SetPoint(fNrTimeslice,static_cast<Float_t>(fNrTimeslice)/100.0,LostRatio); - } - } - LOG(info) << this->GetName () << ": Done: Analyzing Lost_Ratio "; - fNrTimeslice++; - - -} - diff --git a/beamtime/trd/lib/CbmTrdQACosmics.h b/beamtime/trd/lib/CbmTrdQACosmics.h deleted file mode 100644 index cbb861a946d8573fc83645805c98c3eb882ac126..0000000000000000000000000000000000000000 --- a/beamtime/trd/lib/CbmTrdQACosmics.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * CbmTrdQACosmics.h - * - * Created on: Apr 22, 2017 - * Author: philipp - */ - -#ifndef FLES_READER_TASKS_CBMTRQACOSMICS_H_ -#define FLES_READER_TASKS_CBMTRQACOSMICS_H_ - -#include <CbmTrdQABase.h> -#include "CbmSpadicRawMessage.h" - - -class CbmTrdQACosmics: public CbmTrdQABase -{ - public: - CbmTrdQACosmics (); - void CreateHistograms (); - void Exec (Option_t*); - virtual - ~CbmTrdQACosmics (); - - ClassDef(CbmTrdQACosmics,1); - -}; - -#endif /* FLES_READER_TASKS_CBMTRQACOSMICS_H_ */ diff --git a/beamtime/trd/lib/CbmTrdQAEfficiency.cxx b/beamtime/trd/lib/CbmTrdQAEfficiency.cxx deleted file mode 100644 index 21ef7825658be11edafa01987330a7d5ae1ede64..0000000000000000000000000000000000000000 --- a/beamtime/trd/lib/CbmTrdQAEfficiency.cxx +++ /dev/null @@ -1,216 +0,0 @@ -#include "CbmTrdQAEfficiency.h" -#include "FairLogger.h" -#include "CbmHistManager.h" -#include "TString.h" -#include "TStyle.h" - -#include <cmath> -#include <map> -#include <vector> -#include <cmath> -#include <map> -#include <vector> - -ClassImp(CbmTrdQAEfficiency) - -CbmTrdQAEfficiency::CbmTrdQAEfficiency(TString /*_ClassName*/) : - CbmTrdQABase("CbmTrdQAEfficiency"){ -} - -void CbmTrdQAEfficiency::CreateHistograms(){ - for(Int_t syscore = 0; syscore < fBT->GetNrRobs(); ++syscore) { - for(Int_t spadic = 0; spadic < fBT->GetNrSpadics(); ++spadic) { - TString spadicName = GetSpadicName(syscore, spadic, "SysCore",true); - TString HistName="TriggerType_vs_StopType_"+spadicName; - fHm->Add(HistName.Data(), new TH2I(HistName.Data(),HistName.Data(),5,-1.5,3.5,7,-1.5,5.5)); - fHm->H2(HistName.Data())->GetYaxis()->SetTitle("StopType"); - fHm->H2(HistName.Data())->GetXaxis()->SetTitle("TriggerType"); - //Triggertype vs Nr of Samples: - HistName="NrOfSamples_vs_TriggerType_"+spadicName; - fHm->Add(HistName.Data(), new TH2I(HistName.Data(),HistName.Data(),33,-0.5,32.5,5,-1.5,3.5)); - fHm->H2(HistName.Data())->GetXaxis()->SetTitle("NrOfSamples"); - fHm->H2(HistName.Data())->GetYaxis()->SetTitle("TriggerType"); - HistName="NrOfSamples_vs_StopType_"+spadicName; - fHm->Add(HistName.Data(), new TH2I(HistName.Data(),HistName.Data(),33,-0.5,32.5,7,-1.5,5.5)); - fHm->H2(HistName.Data())->GetXaxis()->SetTitle("NrOfSamples"); - fHm->H2(HistName.Data())->GetYaxis()->SetTitle("StopType"); - } - } - //Triggertype vs Channel: - for (Int_t syscore = 0; syscore < fBT->GetNrRobs (); ++syscore) - { - for (Int_t spadic = 0; spadic < fBT->GetNrSpadics (); ++spadic) - { - TString spadicName = GetSpadicName(syscore, spadic, "SysCore",true); - TString HistName="TriggerType_vs_Channel_"+spadicName; - fHm->Add(HistName.Data(), new TH2I(HistName.Data(),HistName.Data(),32,-0.5,31.5,4,-0.5,3.5)); - fHm->H2(HistName.Data())->GetXaxis()->SetTitle("Channel"); - fHm->H2(HistName.Data())->GetYaxis()->SetTitle("TriggerType"); - } - } - - for(Int_t syscore = 0; syscore < fBT->GetNrRobs(); ++syscore) { - for(Int_t spadic = 0; spadic < fBT->GetNrSpadics(); ++spadic) { - TString spadicName = GetSpadicName(syscore, spadic, "SysCore",true); - TString HistName="Hitfrequency_vs_Time_"+spadicName; - fHm->Add(HistName.Data(), new TGraph()); - fHm->G1(HistName.Data())->SetNameTitle(HistName.Data(),HistName.Data()); - fHm->G1(HistName.Data())->GetYaxis()->SetTitle("HitFrequency"); - fHm->G1(HistName.Data())->GetXaxis()->SetTitle("Fulltime/s"); - } - } - for (Int_t layer=0;layer<fBT->GetNrRobs();layer++){ - TString HistName="Hitmap_Layer_"+std::to_string(layer); - fHm->Add(HistName.Data(), new TH2I(HistName.Data(),HistName.Data(),256,-0.5,255.5,6,-0.5,5.5)); - fHm->H2(HistName.Data())->GetXaxis()->SetTitle("Column"); - fHm->H2(HistName.Data())->GetYaxis()->SetTitle("Row"); - } - for (Int_t syscore=0;syscore<fBT->GetNrRobs();syscore++){ - for (Int_t spadic=0;spadic<fBT->GetNrSpadics()*2;spadic++){ - TString spadicName = GetSpadicName(syscore, spadic, "SysCore",true); - TString HistName="Hitwindow_"+spadicName; - fHm->Add(HistName.Data(), new TH1I(HistName.Data(),HistName.Data(),4096,0.0-0.05,4096.0*4096.0/8.0-0.05)); - fHm->H1(HistName.Data())->GetXaxis()->SetTitle("HW Length"); - fHm->H1(HistName.Data())->GetYaxis()->SetTitle("Counts"); - } - } -} - -//---------------------------------------------------------------------------------------- - -void CbmTrdQAEfficiency::Exec(Option_t*) -{ -// static Int_t NrTimeSlice=-1; - std::vector<Double_t> LastHit(fBT->GetNrRobs()*fBT->GetNrSpadics()*32); - /* LOG(info) << this->GetName() <<": Number of current TimeSlice:" - << ++NrTimeSlice; - LOG(info) << this->GetName() <<": rawMessages in TS: " - << fRaw->GetEntriesFast (); - */ - Int_t nSpadicMessages = fRaw->GetEntriesFast (); //SPADIC messages per TimeSlice - std::vector<TH2*> HistogramArray; - std::vector<TGraph*> HitfrequencyGraphs; - for(Int_t RobID=0;RobID<fBT->GetNrRobs();RobID++){ - for(Int_t SpadicID=0;SpadicID<fBT->GetNrSpadics();SpadicID++){ - TString spadicName = GetSpadicName(RobID, SpadicID, "SysCore",true); - TString HistName="TriggerType_vs_StopType_"+spadicName; - HistogramArray.push_back(fHm->H2(HistName.Data())); - HistName="Hitfrequency_vs_Time_"+spadicName; - HitfrequencyGraphs.push_back(fHm->G1(HistName.Data())); - } - } - //first Loop for TriggerType_vs_StopType: - for (Int_t iSpadicMessage=0; iSpadicMessage < nSpadicMessages; ++iSpadicMessage){ - CbmSpadicRawMessage *raw= static_cast<CbmSpadicRawMessage*>(fRaw->At(iSpadicMessage)); - HistogramArray.at(GetRobID(raw)*fBT->GetNrSpadics()+GetSpadicID(raw)/2)->Fill(raw->GetTriggerType(),raw->GetStopType()); - } - LOG(info)<<this->GetName()<<": Loop for TriggerType_vs_StopType done"; - //Loop for TriggerType_vs_Channel_: - HistogramArray.clear(); - for(Int_t RobID=0;RobID<fBT->GetNrRobs();RobID++){ - for(Int_t SpadicID=0;SpadicID<fBT->GetNrSpadics();SpadicID++){ - TString spadicName = GetSpadicName(RobID, SpadicID, "SysCore",true); - TString HistName="TriggerType_vs_Channel_"+spadicName; - HistogramArray.push_back(fHm->H2(HistName.Data())); - } - } - - for (Int_t iSpadicMessage=0; iSpadicMessage < nSpadicMessages; ++iSpadicMessage){ - CbmSpadicRawMessage *raw= static_cast<CbmSpadicRawMessage*>(fRaw->At(iSpadicMessage)); - if(raw->GetHit()||raw->GetHitAborted()) - HistogramArray.at(GetRobID(raw)*fBT->GetNrSpadics()+GetSpadicID(raw)/2)->Fill(GetRobID(raw)*fBT->GetNrSpadics()+GetSpadicID(raw)*16+raw->GetChannelID(),raw->GetTriggerType()); - } - LOG(info)<<this->GetName()<<": Loop for NrOfSamples_vs_TriggerType done"; - - //Loop for NrOfSamples_vs_TriggerType: - HistogramArray.clear(); - for(Int_t RobID=0;RobID<fBT->GetNrRobs();RobID++){ - for(Int_t SpadicID=0;SpadicID<fBT->GetNrSpadics();SpadicID++){ - TString spadicName = GetSpadicName(RobID, SpadicID, "SysCore",true); - TString HistName="NrOfSamples_vs_TriggerType_"+spadicName; - HistogramArray.push_back(fHm->H2(HistName.Data())); - } - } - for (Int_t iSpadicMessage=0; iSpadicMessage < nSpadicMessages; ++iSpadicMessage){ - CbmSpadicRawMessage *raw= static_cast<CbmSpadicRawMessage*>(fRaw->At(iSpadicMessage)); - if(raw->GetHit()||raw->GetHitAborted()) - HistogramArray.at(GetRobID(raw)*fBT->GetNrSpadics()+GetSpadicID(raw)/2)->Fill(raw->GetNrSamples(),raw->GetTriggerType()); - } - LOG(info)<<this->GetName()<<": Loop for NrOfSamples_vs_TriggerType done"; - //Loop for NrOfSamples_vs_StopType: - HistogramArray.clear(); - for(Int_t RobID=0;RobID<fBT->GetNrRobs();RobID++){ - for(Int_t SpadicID=0;SpadicID<fBT->GetNrSpadics();SpadicID++){ - TString spadicName = GetSpadicName(RobID, SpadicID, "SysCore",true); - TString HistName="NrOfSamples_vs_StopType_"+spadicName; - HistogramArray.push_back(fHm->H2(HistName.Data())); - } - } - for (Int_t iSpadicMessage=0; iSpadicMessage < nSpadicMessages; ++iSpadicMessage){ - CbmSpadicRawMessage *raw= static_cast<CbmSpadicRawMessage*>(fRaw->At(iSpadicMessage)); - if(raw->GetHit()||raw->GetHitAborted()) - HistogramArray.at(GetRobID(raw)*fBT->GetNrSpadics()+GetSpadicID(raw)/2)->Fill(raw->GetNrSamples(),raw->GetStopType()); - } - LOG(info)<<this->GetName()<<": Loop for NrOfSamples_vs_StopType done"; - - std::vector<TH2*> Hitmaps; - for (Int_t layer=0;layer<fBT->GetNrRobs();layer++){ - TString HistName="Hitmap_Layer_"+std::to_string(layer); - Hitmaps.push_back(fHm->H2(HistName.Data())); - } - for (Int_t iSpadicMessage=0; iSpadicMessage < nSpadicMessages; ++iSpadicMessage){ - CbmSpadicRawMessage *raw= static_cast<CbmSpadicRawMessage*>(fRaw->At(iSpadicMessage)); - if (!(raw->GetHit()||raw->GetHitAborted())){ - continue; - } - Hitmaps.at(GetLayerID(raw))->Fill(GetColumnID(raw),GetRowID(raw)); - } - LOG(info)<<this->GetName()<<": Loop for Hitmaps done"; - - { - std::vector<TH1*> Histogram1DArray; - for(Int_t RobID=0;RobID<fBT->GetNrRobs();RobID++){ - for(Int_t SpadicID=0;SpadicID<fBT->GetNrSpadics()*2;SpadicID++){ - TString spadicName = GetSpadicName(RobID, SpadicID, "SysCore",true); - TString HistName="Hitwindow_"+spadicName; - Histogram1DArray.push_back(fHm->H1(HistName.Data())); - } - } - //Loop for Hitwindowbuffer: - { - std::vector<Long64_t> FirstHitTime(fBT->GetNrRobs()*fBT->GetNrSpadics()*2), - LastHitTime(fBT->GetNrRobs()*fBT->GetNrSpadics()*2); - static Int_t LastHalfSpadic=0; - for (Int_t iSpadicMessage=0; iSpadicMessage < nSpadicMessages; ++iSpadicMessage){ - CbmSpadicRawMessage *raw= static_cast<CbmSpadicRawMessage*>(fRaw->At(iSpadicMessage)); - if(!(raw->GetHit()||raw->GetHitAborted())) - continue; - Int_t CurrentHalfSpadic=GetRobID(raw)*fBT->GetNrSpadics()*2+GetSpadicID(raw); - if(CurrentHalfSpadic!=LastHalfSpadic){ - Histogram1DArray.at(LastHalfSpadic)->Fill(LastHitTime.at(LastHalfSpadic)-FirstHitTime.at(LastHalfSpadic)); - LastHalfSpadic = CurrentHalfSpadic; - FirstHitTime.at(CurrentHalfSpadic)=raw->GetFullTime(); - } - LastHitTime.at(CurrentHalfSpadic)=raw->GetFullTime(); - } - } - LOG(info)<<this->GetName()<<": Loop for Hitwindowbuffer done"; - //Loop for NrOfSamples_vs_TriggerType: - Histogram1DArray.clear(); - } - const Double_t SpadicFrequency=1E9/fBT->GetSamplingTime(); - for (Int_t iSpadicMessage=0; iSpadicMessage < nSpadicMessages; ++iSpadicMessage){ - CbmSpadicRawMessage *raw= static_cast<CbmSpadicRawMessage*>(fRaw->At(iSpadicMessage)); - if(!(raw->GetHit()||raw->GetTriggerType()==1))continue; - TGraph* CurrentGraph=HitfrequencyGraphs.at(GetRobID(raw)*fBT->GetNrSpadics()+GetSpadicID(raw)/2); - Long64_t CurrentTime=raw->GetFullTime(); - UInt_t Index=GetRobID(raw)*fBT->GetNrSpadics()*32+GetSpadicID(raw)*16+raw->GetChannelID(); - Double_t CurrentFrequency=SpadicFrequency/static_cast<Double_t>(CurrentTime-LastHit.at(Index)); - LastHit.at(Index)=CurrentTime; - if(std::isinf(CurrentFrequency)||std::isnan(CurrentFrequency)||CurrentFrequency<10.0) - continue; - CurrentGraph->SetPoint(CurrentGraph->GetN(),CurrentTime/(SpadicFrequency),CurrentFrequency); - } - LOG(info)<<this->GetName()<<": Loop for Hitfrequency_vs_Time done"; -} - diff --git a/beamtime/trd/lib/CbmTrdQAEfficiency.h b/beamtime/trd/lib/CbmTrdQAEfficiency.h deleted file mode 100644 index 9f423f084d8ad376812921e18d93333dc78cc68b..0000000000000000000000000000000000000000 --- a/beamtime/trd/lib/CbmTrdQAEfficiency.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef CBMTRDQAEFFICIENCY_H -#define CBMTRDQAEFFICIENCY_H - -#include "CbmTrdQABase.h" - -/** @Class CbmTrdQAEfficiency - ** @author Philipp Munkes <p.munkes@uni-muenster.de> - ** @date 05th June 2017 - ** @brief Class for the investigation of the SPADIC under Load. - ** - **/ - -class CbmTrdQAEfficiency : public CbmTrdQABase -{ - protected: - /** Constructor with parameters (Optional) **/ - CbmTrdQAEfficiency(TString ClassName); - public: - - virtual void CreateHistograms(); - virtual void Exec(Option_t*); - /** Default constructor **/ - CbmTrdQAEfficiency():CbmTrdQAEfficiency("CbmTrdQAEfficiency"){}; - - ClassDef(CbmTrdQAEfficiency,1); -}; - -#endif diff --git a/beamtime/trd/lib/CbmTrdQAHit.cxx b/beamtime/trd/lib/CbmTrdQAHit.cxx deleted file mode 100644 index 952d4ae3e2db0b6f0c10b284ed87fcfc042225d7..0000000000000000000000000000000000000000 --- a/beamtime/trd/lib/CbmTrdQAHit.cxx +++ /dev/null @@ -1,383 +0,0 @@ -#include "CbmTrdQAHit.h" -#include "FairLogger.h" -#include "CbmHistManager.h" -#include "TString.h" -#include "TStyle.h" - -#include <cmath> -#include <map> -#include <vector> -#include <cmath> -#include <map> -#include <vector> - -ClassImp(CbmTrdQAHit) - -CbmTrdQAHit::CbmTrdQAHit (TString /*_ClassName*/) : - CbmTrdQABase ("CbmTrdQAHit") -{ -} - -void -CbmTrdQAHit::CreateHistograms () -{ - for (Int_t syscore = 0; syscore < fBT->GetNrRobs (); ++syscore) - { - for (Int_t spadic = 0; spadic < fBT->GetNrSpadics (); ++spadic) - { - TString spadicName = GetSpadicName (syscore, spadic, "SysCore", true); - TString HistName = "TriggerType_vs_StopType_" + spadicName; - fHm->Add ( - HistName.Data (), - new TH2I (HistName.Data (), HistName.Data (), 5, -1.5, 3.5, 7, - -1.5, 5.5)); - fHm->H2 (HistName.Data ())->GetYaxis ()->SetTitle ("StopType"); - fHm->H2 (HistName.Data ())->GetXaxis ()->SetTitle ("TriggerType"); - //Triggertype vs Nr of Samples: - HistName = "NrOfSamples_vs_TriggerType_" + spadicName; - fHm->Add ( - HistName.Data (), - new TH2I (HistName.Data (), HistName.Data (), 33, -0.5, 32.5, 5, - -1.5, 3.5)); - fHm->H2 (HistName.Data ())->GetXaxis ()->SetTitle ("NrOfSamples"); - fHm->H2 (HistName.Data ())->GetYaxis ()->SetTitle ("TriggerType"); - HistName = "NrOfSamples_vs_StopType_" + spadicName; - fHm->Add ( - HistName.Data (), - new TH2I (HistName.Data (), HistName.Data (), 33, -0.5, 32.5, 7, - -1.5, 5.5)); - fHm->H2 (HistName.Data ())->GetXaxis ()->SetTitle ("NrOfSamples"); - fHm->H2 (HistName.Data ())->GetYaxis ()->SetTitle ("StopType"); - } - } - //Triggertype vs Channel: - for (Int_t syscore = 0; syscore < fBT->GetNrRobs (); ++syscore) - { - for (Int_t spadic = 0; spadic < fBT->GetNrSpadics (); ++spadic) - { - TString spadicName = GetSpadicName (syscore, spadic, "SysCore", true); - TString HistName = "TriggerType_vs_Channel_" + spadicName; - fHm->Add ( - HistName.Data (), - new TH2I (HistName.Data (), HistName.Data (), 32, -0.5, 31.5, 4, - -0.5, 3.5)); - fHm->H2 (HistName.Data ())->GetXaxis ()->SetTitle ("Channel"); - fHm->H2 (HistName.Data ())->GetYaxis ()->SetTitle ("TriggerType"); - } - } - - for (Int_t syscore = 0; syscore < fBT->GetNrRobs (); ++syscore) - { - for (Int_t spadic = 0; spadic < fBT->GetNrSpadics (); ++spadic) - { - TString spadicName = GetSpadicName (syscore, spadic, "SysCore", true); - TString HistName = "Hitfrequency_vs_Time_" + spadicName; - fHm->Add (HistName.Data (), new TGraph ()); - fHm->G1 (HistName.Data ())->SetNameTitle (HistName.Data (), - HistName.Data ()); - fHm->G1 (HistName.Data ())->GetYaxis ()->SetTitle ("HitFrequency"); - fHm->G1 (HistName.Data ())->GetXaxis ()->SetTitle ("Fulltime/s"); - } - } - for (Int_t layer = 0; layer < fBT->GetNrLayers (); layer++) - { - TString HistName = "Hitmap_Layer_" + std::to_string (layer); - fHm->Add ( - HistName.Data (), - new TH2I (HistName.Data (), HistName.Data (), fBT->GetNrColumns(layer), -0.5, fBT->GetNrColumns(layer)-0.5, fBT->GetNrRows(layer), - -0.5, fBT->GetNrRows(layer)-0.5)); - fHm->H2 (HistName.Data ())->GetXaxis ()->SetTitle ("Column"); - fHm->H2 (HistName.Data ())->GetYaxis ()->SetTitle ("Row"); - } - for (Int_t syscore = 0; syscore < fBT->GetNrRobs (); syscore++) - { - for (Int_t spadic = 0; spadic < fBT->GetNrSpadics () * 2; spadic++) - { - TString spadicName = GetSpadicName (syscore, spadic, "SysCore", true); - TString HistName = "Hitwindow_" + spadicName; - fHm->Add ( - HistName.Data (), - new TH1I (HistName.Data (), HistName.Data (), 4096, 0.0 - 0.05, - 4096.0 * 4096.0 / 8.0 - 0.05)); - fHm->H1 (HistName.Data ())->GetXaxis ()->SetTitle ("HW Length"); - fHm->H1 (HistName.Data ())->GetYaxis ()->SetTitle ("Counts"); - } - } - for (Int_t syscore = 0; syscore < fBT->GetNrRobs (); syscore++) - { - for (Int_t spadic = 0; spadic < fBT->GetNrSpadics () ; - spadic++) - { - for (Int_t channel = 0; channel < 32; channel++) - { - for (Int_t trigger = 0; trigger < 4; trigger++) - { - TString spadicName = GetSpadicName (syscore, spadic, "Afck", - true); - TString HistName = "SignalShape_Trigger_" - + std::to_string (trigger) + "_" + spadicName - + "_Channel_" + std::to_string (channel); - fHm->Add ( - HistName.Data (), - new TH2I (HistName.Data (), HistName.Data (), 32, -0.5, - 31.5, 512, -256.5, 255.5)); - fHm->H2 (HistName.Data ())->GetXaxis ()->SetTitle ( - "Sample Nr"); - fHm->H2 (HistName.Data ())->GetYaxis ()->SetTitle ( - "ADC Value"); - } - } - } - } - -} - -//---------------------------------------------------------------------------------------- - -void -CbmTrdQAHit::Exec (Option_t*) -{ - static Int_t NrTimeSlice = -1; - std::vector<Double_t> LastHit (fBT->GetNrRobs () * fBT->GetNrSpadics () * 32); - LOG(info) << this->GetName() <<": Number of current TimeSlice:" - << ++NrTimeSlice; - LOG(info) << this->GetName() <<": rawMessages in TS: " - << fRaw->GetEntriesFast (); - - Int_t nSpadicMessages = fRaw->GetEntriesFast (); //SPADIC messages per TimeSlice - std::vector<TH2*> HistogramArray; - std::vector<TGraph*> HitfrequencyGraphs; - for (Int_t RobID = 0; RobID < fBT->GetNrRobs (); RobID++) - { - for (Int_t SpadicID = 0; SpadicID < fBT->GetNrSpadics (); SpadicID++) - { - TString spadicName = GetSpadicName (RobID, SpadicID, "SysCore", true); - TString HistName = "TriggerType_vs_StopType_" + spadicName; - HistogramArray.push_back (fHm->H2 (HistName.Data ())); - HistName = "Hitfrequency_vs_Time_" + spadicName; - HitfrequencyGraphs.push_back (fHm->G1 (HistName.Data ())); - } - } - //first Loop for TriggerType_vs_StopType: - LOG(info) << this->GetName () << ": Loop for TriggerType_vs_StopType Start"; - for (Int_t iSpadicMessage = 0; iSpadicMessage < nSpadicMessages; - ++iSpadicMessage) - { - CbmSpadicRawMessage *raw = static_cast<CbmSpadicRawMessage*> (fRaw->At ( - iSpadicMessage)); - if (static_cast<size_t>(GetRobID (raw) * fBT->GetNrSpadics () + GetSpadicID (raw) / 2) - > HistogramArray.size ()) - continue; - HistogramArray.at ( - fBT->GetRobID (raw) * fBT->GetNrSpadics () + GetSpadicID (raw) / 2)->Fill ( - raw->GetTriggerType (), raw->GetStopType ()); - } - LOG(info) << this->GetName () << ": Loop for TriggerType_vs_StopType done"; - //Loop for TriggerType_vs_Channel_: - HistogramArray.clear (); - for (Int_t RobID = 0; RobID < fBT->GetNrRobs (); RobID++) - { - for (Int_t SpadicID = 0; SpadicID < fBT->GetNrSpadics (); SpadicID++) - { - TString spadicName = GetSpadicName (RobID, SpadicID, "SysCore", true); - TString HistName = "TriggerType_vs_Channel_" + spadicName; - HistogramArray.push_back (fHm->H2 (HistName.Data ())); - } - } - - for (Int_t iSpadicMessage = 0; iSpadicMessage < nSpadicMessages; - ++iSpadicMessage) - { - CbmSpadicRawMessage *raw = static_cast<CbmSpadicRawMessage*> (fRaw->At ( - iSpadicMessage)); - if (static_cast<size_t>(GetRobID (raw) * fBT->GetNrSpadics () + GetSpadicID (raw) / 2)>HistogramArray.size()) - std::cout << GetRobID (raw) << " "<< fBT->GetNrSpadics () << " "<< GetSpadicID (raw)<<std::endl; - if (raw->GetHit () || raw->GetHitAborted ()) - HistogramArray.at ( - GetRobID (raw) * fBT->GetNrSpadics () + GetSpadicID (raw) / 2)->Fill ( - (GetSpadicID (raw) % 2) * 16 + raw->GetChannelID (), - raw->GetTriggerType ()); - } - LOG(info) << this->GetName () << ": Loop for TriggerType_vs_Channel done"; - - //Loop for NrOfSamples_vs_TriggerType: - HistogramArray.clear (); - for (Int_t RobID = 0; RobID < fBT->GetNrRobs (); RobID++) - { - for (Int_t SpadicID = 0; SpadicID < fBT->GetNrSpadics (); SpadicID++) - { - TString spadicName = GetSpadicName (RobID, SpadicID, "SysCore", true); - TString HistName = "NrOfSamples_vs_TriggerType_" + spadicName; - HistogramArray.push_back (fHm->H2 (HistName.Data ())); - } - } - for (Int_t iSpadicMessage = 0; iSpadicMessage < nSpadicMessages; - ++iSpadicMessage) - { - CbmSpadicRawMessage *raw = static_cast<CbmSpadicRawMessage*> (fRaw->At ( - iSpadicMessage)); - if (raw->GetHit () || raw->GetHitAborted ()) - HistogramArray.at ( - GetRobID (raw) * fBT->GetNrSpadics () + GetSpadicID (raw) / 2)->Fill ( - raw->GetNrSamples (), raw->GetTriggerType ()); - } - LOG(info) << this->GetName () << ": Loop for NrOfSamples_vs_TriggerType done"; - //Loop for NrOfSamples_vs_StopType: - HistogramArray.clear (); - for (Int_t RobID = 0; RobID < fBT->GetNrRobs (); RobID++) - { - for (Int_t SpadicID = 0; SpadicID < fBT->GetNrSpadics (); SpadicID++) - { - TString spadicName = GetSpadicName (RobID, SpadicID, "SysCore", true); - TString HistName = "NrOfSamples_vs_StopType_" + spadicName; - HistogramArray.push_back (fHm->H2 (HistName.Data ())); - } - } - for (Int_t iSpadicMessage = 0; iSpadicMessage < nSpadicMessages; - ++iSpadicMessage) - { - CbmSpadicRawMessage *raw = static_cast<CbmSpadicRawMessage*> (fRaw->At ( - iSpadicMessage)); - if (raw->GetHit () || raw->GetHitAborted ()) - HistogramArray.at ( - GetRobID (raw) * fBT->GetNrSpadics () + GetSpadicID (raw) / 2)->Fill ( - raw->GetNrSamples (), raw->GetStopType ()); - } - LOG(info) << this->GetName () << ": Loop for NrOfSamples_vs_StopType done"; - - std::vector<TH2*> Hitmaps; - for (Int_t layer = 0; layer < fBT->GetNrLayers (); layer++) - { - TString HistName = "Hitmap_Layer_" + std::to_string (layer); - Hitmaps.push_back (fHm->H2 (HistName.Data ())); - } - for (Int_t iSpadicMessage = 0; iSpadicMessage < nSpadicMessages; - ++iSpadicMessage) - { - CbmSpadicRawMessage *raw = static_cast<CbmSpadicRawMessage*> (fRaw->At ( - iSpadicMessage)); - if (!(raw->GetHit () || raw->GetHitAborted ())) - { - continue; - } - Hitmaps.at (GetLayerID (raw))->Fill (GetColumnID (raw), GetRowID (raw)); - } - LOG(info) << this->GetName () << ": Loop for Hitmaps done"; - - { - std::vector<TH1*> Histogram1DArray; - for (Int_t RobID = 0; RobID < fBT->GetNrRobs (); RobID++) - { - for (Int_t SpadicID = 0; SpadicID < fBT->GetNrSpadics () * 2; - SpadicID++) - { - TString spadicName = GetSpadicName (RobID, SpadicID, "SysCore", - true); - TString HistName = "Hitwindow_" + spadicName; - Histogram1DArray.push_back (fHm->H1 (HistName.Data ())); - } - } - //Loop for Hitwindowbuffer: - { - std::vector<Long64_t> FirstHitTime ( - fBT->GetNrRobs () * fBT->GetNrSpadics () * 2), LastHitTime ( - fBT->GetNrRobs () * fBT->GetNrSpadics () * 2); - static Int_t LastHalfSpadic = 0; - for (Int_t iSpadicMessage = 0; iSpadicMessage < nSpadicMessages; - ++iSpadicMessage) - { - CbmSpadicRawMessage *raw = - static_cast<CbmSpadicRawMessage*> (fRaw->At (iSpadicMessage)); - if (!(raw->GetHit () || raw->GetHitAborted ())) - continue; - Int_t CurrentHalfSpadic = GetRobID (raw) * fBT->GetNrSpadics () - * 2 + GetSpadicID (raw); - if (CurrentHalfSpadic != LastHalfSpadic) - { - Histogram1DArray.at (LastHalfSpadic)->Fill ( - LastHitTime.at (LastHalfSpadic) - - FirstHitTime.at (LastHalfSpadic)); - LastHalfSpadic = CurrentHalfSpadic; - FirstHitTime.at (CurrentHalfSpadic) = raw->GetFullTime (); - } - LastHitTime.at (CurrentHalfSpadic) = raw->GetFullTime (); - } - } - LOG(info) << this->GetName () << ": Loop for Hitwindowbuffer done"; - //Loop for NrOfSamples_vs_TriggerType: - Histogram1DArray.clear (); - } - const Double_t SpadicFrequency = 1E9 / fBT->GetSamplingTime (); - for (Int_t iSpadicMessage = 0; iSpadicMessage < 0; - ++iSpadicMessage) - { - CbmSpadicRawMessage *raw = static_cast<CbmSpadicRawMessage*> (fRaw->At ( - iSpadicMessage)); - if (!(raw->GetHit () || raw->GetTriggerType () == 1)) - continue; - TGraph* CurrentGraph = HitfrequencyGraphs.at ( - GetRobID (raw) * fBT->GetNrSpadics () + GetSpadicID (raw) / 2); - Long64_t CurrentTime = raw->GetFullTime (); - UInt_t Index = GetRobID (raw) * fBT->GetNrSpadics () * 32 - + GetSpadicID (raw) * 16 + raw->GetChannelID (); - Double_t CurrentFrequency = SpadicFrequency - / static_cast<Double_t> (CurrentTime - LastHit.at (Index)); - LastHit.at (Index) = CurrentTime; - if (std::isinf (CurrentFrequency) || std::isnan (CurrentFrequency) - || CurrentFrequency < 10.0) - continue; - CurrentGraph->SetPoint (CurrentGraph->GetN (), - CurrentTime / (SpadicFrequency), - CurrentFrequency); - } - LOG(info) << this->GetName () << ": Loop for Hitfrequency_vs_Time done"; - if (nSpadicMessages != 0) - { - std::vector<TH2*> SignalShapes ( - static_cast<size_t> (fBT->GetNrRobs () * fBT->GetNrSpadics () * 32 * 5)); - for (Int_t afck = 0; afck < fBT->GetNrRobs (); afck++) - { - for (Int_t spadic = 0; spadic < fBT->GetNrSpadics (); spadic++) - { - for (Int_t channel = 0; channel < 32; channel++) - { - for (Int_t trigger = 0; trigger < 4; trigger++) - { - TString spadicName = GetSpadicName (afck, spadic, "Afck", - true); - TString HistName = "SignalShape_Trigger_" - + std::to_string (trigger) + "_" + spadicName - + "_Channel_" + std::to_string (channel); - SignalShapes.at ( - afck * fBT->GetNrSpadics () * 32 * 4 + spadic * 32 * 4 - + channel * 4 + trigger) = fHm->H2 ( - HistName.Data ()); - } - } - } - } - LOG(info) << this->GetName () << ": Loop for Signalshapes start"; - for (Int_t iSpadicMessage = 0; iSpadicMessage < nSpadicMessages; - ++iSpadicMessage) - { - CbmSpadicRawMessage *raw = - static_cast<CbmSpadicRawMessage*> (fRaw->At (iSpadicMessage)); - if (!(raw->GetHit () || raw->GetHitAborted ())) - continue; - int afck = fBT->GetRobID (raw); - int spadic = fBT->GetSpadicID (raw) / 2; - int trigger = raw->GetTriggerType (); - int channel = raw->GetChannelID () + 16 * (fBT->GetSpadicID (raw) % 2); TH2* CurrentHisto = SignalShapes.at ( - afck * fBT->GetNrSpadics () * 32 * 4 + spadic * 32 * 4 - + channel * 4 + trigger); - Int_t* Samples = raw->GetSamples (); - for (int i = 0; i < raw->GetNrSamples (); i++) - { - CurrentHisto->Fill (i, Samples[i]); - } - } - - LOG(info) << this->GetName () << ": Loop for Signalshapes done"; - } -} - diff --git a/beamtime/trd/lib/CbmTrdQAHit.h b/beamtime/trd/lib/CbmTrdQAHit.h deleted file mode 100644 index 84eb2097616a411033139aad3eaa0e5d13256196..0000000000000000000000000000000000000000 --- a/beamtime/trd/lib/CbmTrdQAHit.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef CBMTRDQAHIT_H -#define CBMTRDQAHIT_H - -#include "CbmTrdQABase.h" - -/** @Class CbmTrdQAHit - ** @author Philipp Munkes <p.munkes@uni-muenster.de> - ** @date 10th April 2017 - ** @brief Example of a derived class for CBM TRD Testbeam analysis. - ** - ** This class is a collection of analysis for Hit messages. - **/ - -class CbmTrdQAHit : public CbmTrdQABase -{ - protected: - /** Constructor with parameters (Optional) **/ - CbmTrdQAHit(TString ClassName); - public: - - virtual void CreateHistograms(); - virtual void Exec(Option_t*); - /** Default constructor **/ - CbmTrdQAHit():CbmTrdQAHit("CbmTrdQAHit"){}; - - ClassDef(CbmTrdQAHit,1); -}; - -#endif diff --git a/beamtime/trd/lib/CbmTrdSimpleClusterAnalysis.cxx b/beamtime/trd/lib/CbmTrdSimpleClusterAnalysis.cxx deleted file mode 100644 index 111f0eaf2c49dfcf997681c67fd35f052e6470ec..0000000000000000000000000000000000000000 --- a/beamtime/trd/lib/CbmTrdSimpleClusterAnalysis.cxx +++ /dev/null @@ -1,129 +0,0 @@ -/* - * CbmTrdsimpleClusterAnalysis.cpp - * - * Created on: Sep 4, 2017 - * Author: philipp - */ - -#include <CbmTrdSimpleClusterAnalysis.h> -#include <iostream> - -ClassImp(CbmTrdSimpleClusterAnalysis) - -CbmTrdSimpleClusterAnalysis::CbmTrdSimpleClusterAnalysis (): - CbmTrdQABase("CbmTrdSimpleClusterAnalysis"), fSpectra() -{ - // TODO Auto-generated constructor stub - -} - -CbmTrdSimpleClusterAnalysis::~CbmTrdSimpleClusterAnalysis () -{ - // TODO Auto-generated destructor stub -} - -void -CbmTrdSimpleClusterAnalysis::CreateHistograms () -{ - for (int layer = 0; layer < fBT->GetNrLayers (); layer++) - { - TString HistName = "Cluster_Heatmap_Layer_" + std::to_string (layer); - fHm->Add ( - HistName.Data (), - new TH2I ( - HistName.Data (), HistName.Data (), - fBT->GetNrColumns (layer) * 4, -0.5 * fBT->GetPadWidth (layer), - (fBT->GetNrColumns (layer) - 0.5) * (fBT->GetPadWidth (layer)), - fBT->GetNrRows (layer) * 1, -0.5 * fBT->GetPadHeight (layer), - (fBT->GetNrRows (layer) - 0.5) * fBT->GetPadHeight (layer))); - fHm->H2 (HistName.Data ())->GetXaxis ()->SetTitle ("X/cm"); - fHm->H2 (HistName.Data ())->GetYaxis ()->SetTitle ("Y/cm"); - } - for (int layer = 0; layer < fBT->GetNrLayers (); layer++) - { - TString HistName = "PRF_Layer_" + std::to_string (layer); - fHm->Add ( - HistName.Data (), - new TH2I ( - HistName.Data (), HistName.Data (), - 51,-2.55,2.55, - 101,-0.5,100.5)); - fHm->H2 (HistName.Data ())->GetXaxis ()->SetTitle ("d/PW"); - fHm->H2 (HistName.Data ())->GetYaxis ()->SetTitle ("Frac Chg"); - } - - for (Int_t Layer = 0; Layer < fBT->GetNrLayers(); Layer++) - { - { - TString HistName = "Spectrum_Layer_" + std::to_string (Layer); - fHm->Add ( - HistName.Data (), - new TH1F (HistName.Data (), HistName.Data (), 1000, -0.5, 999.5)); - fSpectra.push_back (fHm->H1 (HistName.Data ())); - fSpectra.back ()->GetXaxis ()->SetTitle ("Charge/ADCValues"); - } - } -} -void -CbmTrdSimpleClusterAnalysis::Exec (Option_t*) -{ std::vector<TH2*>Heatmaps; -for (Int_t layer = 0; layer < fBT->GetNrLayers(); layer++) - { - TString HistName = "Cluster_Heatmap_Layer_" - + std::to_string (layer); - Heatmaps.push_back (fHm->H2 (HistName.Data ())); - } - - UInt_t NrClusters=fClusters->GetEntriesFast(); - for (UInt_t iCluster = 0; iCluster < NrClusters; ++iCluster) - { - CbmTrdCluster* CurrentCluster = - static_cast<CbmTrdCluster*> (fClusters->At (iCluster)); - if (CurrentCluster) - { - if (fBT->ClassifyCluster (CurrentCluster) - != CbmTrdTestBeamTools::CbmTrdClusterClassification::kNormal) - continue; - Int_t FirstIndex = (CurrentCluster->GetDigis ().at (0)); - const CbmTrdDigi*firstDigi = fDigiMan->Get<CbmTrdDigi>( - FirstIndex); - Int_t Layer = CbmTrdAddress::GetLayerId (firstDigi->GetAddress ()); - double displacement = fBT->GetColumnDisplacement (CurrentCluster); - if (fBT->GetColumnWidth(CurrentCluster)==4) - { - TString HistName = "PRF_Layer_" - + std::to_string (fBT->GetLayerID (CurrentCluster)); - auto Hist=fHm->H2 (HistName.Data ()); - auto Digis=CurrentCluster->GetDigis(); - Float_t Displacement=fBT->GetColumnDisplacement(CurrentCluster); - Float_t Chg=fBT->GetCharge(CurrentCluster)/100.; - for (uint i=0;i<Digis.size();i++) - { - const CbmTrdDigi*Digi = fDigiMan->Get<CbmTrdDigi>(Digis[i]); - Hist->Fill(i-Displacement,Digi->GetCharge()/1e4/Chg); - } - } - if (std::abs (displacement) > 1) - continue; - Double_t xPos = fBT->GetPadWidth (Layer) - * (fBT->GetCentralColumnID (CurrentCluster) + displacement); - displacement = fBT->GetRowDisplacement (CurrentCluster); - /*if(std::abs(displacement)>1) - continue;*/ - Double_t yPos = fBT->GetPadHeight (Layer) - * (fBT->GetCentralRowID (CurrentCluster) + displacement); - Heatmaps.at (Layer)->Fill (xPos, yPos); - - { - TString HistName = "Spectrum_Layer_" - + std::to_string (fBT->GetLayerID (CurrentCluster)); - fHm->H1 (HistName.Data ())->Fill ( - fBT->GetCharge (CurrentCluster)); - } - } - /*LOG(info) << this->GetName () << ": " << fBT->GetCharge (CurrentCluster); - */ - } - -} - diff --git a/beamtime/trd/lib/CbmTrdSimpleClusterAnalysis.h b/beamtime/trd/lib/CbmTrdSimpleClusterAnalysis.h deleted file mode 100644 index b8307a447977e4005bda063d715519f292299d25..0000000000000000000000000000000000000000 --- a/beamtime/trd/lib/CbmTrdSimpleClusterAnalysis.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * CbmTrdsimpleClusterAnalysis.h - * - * Created on: Sep 4, 2017 - * Author: philipp - */ - -#ifndef FLES_READER_TASKS_CBMTRDSIMPLECLUSTERANALYSIS_H_ -#define FLES_READER_TASKS_CBMTRDSIMPLECLUSTERANALYSIS_H_ - -#include <CbmTrdQABase.h> - - -class CbmTrdSimpleClusterAnalysis : public CbmTrdQABase -{ -public: - CbmTrdSimpleClusterAnalysis (); - virtual - ~CbmTrdSimpleClusterAnalysis (); - - virtual void CreateHistograms(); - virtual void Exec(Option_t* opt); - - std::vector<TH1*> fSpectra; - - ClassDef(CbmTrdSimpleClusterAnalysis,1); -}; - -#endif /* FLES_READER_TASKS_CBMTRDSIMPLECLUSTERANALYSIS_H_ */ diff --git a/beamtime/trd/lib/CbmTrdSimpleClusterizer.cxx b/beamtime/trd/lib/CbmTrdSimpleClusterizer.cxx deleted file mode 100644 index 1d9e8c70b50d50be0d95f2047d0d479415229e9a..0000000000000000000000000000000000000000 --- a/beamtime/trd/lib/CbmTrdSimpleClusterizer.cxx +++ /dev/null @@ -1,347 +0,0 @@ -#include "CbmTrdSimpleClusterizer.h" -#include "CbmTrdDigi.h" -#include "CbmTrdCluster.h" -#include "CbmTrdAddress.h" -#include <mutex> -#include <iterator> - -CbmTrdSimpleClusterizer::CbmTrdSimpleClusterizer () - : CbmTrdQABase ("CbmTrdSimpleClusterizer") - , fClusters (nullptr) - , fProxyArray() -{ -} - -InitStatus -CbmTrdSimpleClusterizer::Init () -{ - LOG(debug) << "Initilization of " << this->GetName (); - - // Get a handle from the IO manager - FairRootManager* ioman = FairRootManager::Instance (); - - // Get a pointer to the previous already existing data level - fRaw = static_cast<TClonesArray*> (ioman->GetObject ("SpadicRawMessage")); - if (!fRaw) - { - LOG(fatal) << "No InputDataLevelName SpadicRawMessage array!\n" - << this->GetName () << " will be inactive"; - return kERROR; - } - - fDigiMan = CbmDigiManager::Instance(); - fDigiMan->Init(); - if (!fDigiMan->IsPresent(ECbmModuleId::kTrd)) - { - LOG(fatal) << "No InputDataLevelName TrdDigi array!\n" << this->GetName () - << " will be inactive"; - return kERROR; - } - - SetOutputBranchPersistent("TrdCluster",false); - - fBT->SetDigisArray(nullptr); - fClusters = new TClonesArray ("CbmTrdCluster", 100); - ioman->Register ("TrdCluster", "TRD Clusters", fClusters, - IsOutputBranchPersistent ("TrdCluster")); - //false); - - // Do whatever else is needed at the initilization stage - // Create histograms to be filled - // initialize variables - CbmTrdSimpleClusterizer::CreateHistograms (); - - return kSUCCESS; -} - -void -CbmTrdSimpleClusterizer::CreateHistograms () -{ - TString GraphName = "Clusters_Created"; - fHm->Add (GraphName.Data (), new TGraph); - fHm->G1 (GraphName.Data ())->SetNameTitle (GraphName.Data (), - GraphName.Data ()); - fHm->G1 (GraphName.Data ())->GetXaxis ()->SetTitle ("TimeSlice"); - fHm->G1 (GraphName.Data ())->GetYaxis ()->SetTitle ("Nr of created Clusters"); - for (Int_t layer = 0; layer < fBT->GetNrLayers(); layer++) - { - TString HistName = "Cluster_size_Distribution_Layer_" - + std::to_string (layer); - fHm->Add ( - HistName.Data (), - new TH2I (HistName.Data (), HistName.Data (), fBT->GetNrSpadics(), -0.5, - fBT->GetNrSpadics() - 0.5, 16, -0.5, 15.5)); - fHm->H2 (HistName.Data ())->GetXaxis ()->SetTitle ("Spadic"); - fHm->H2 (HistName.Data ())->GetYaxis ()->SetTitle ("Cluster Size"); - } - for (Int_t layer = 0; layer < fBT->GetNrLayers(); layer++) - { - TString HistName = "Cluster_Size_Type_Distribution_Layer_" - + std::to_string (layer); - fHm->Add ( - HistName.Data (), - new TH2I (HistName.Data (), HistName.Data (), 16, -0.5, 15.5, 6, -0.5, - 5.5)); - fHm->H2 (HistName.Data ())->GetYaxis ()->SetTitle ("Cluster Type"); - fHm->H2 (HistName.Data ())->GetXaxis ()->SetTitle ("Cluster Width"); - } - -} - -void CbmTrdSimpleClusterizer::BubbleSort(){ - bool isNotSorted=true; - auto CompareDigis= - [this](const UInt_t a,const UInt_t b){ - std::mutex mtx; - mtx.lock(); - const CbmTrdDigi*aD=fDigiMan->Get<CbmTrdDigi>(a), - *bD=fDigiMan->Get<CbmTrdDigi>(b); - UInt_t AddressA=this->fBT->GetAddress(aD), - AddressB=this->fBT->GetAddress(bD); - Int_t LayerA=CbmTrdAddress::GetLayerId(AddressA), - LayerB=CbmTrdAddress::GetLayerId(AddressB); - Int_t RowA=CbmTrdAddress::GetRowId(AddressA), - RowB=CbmTrdAddress::GetRowId(AddressB); - //std::cout << RowA<<" "<<RowB<<std::endl; - Int_t ColumnA=CbmTrdAddress::GetColumnId(AddressA), - ColumnB=CbmTrdAddress::GetColumnId(AddressB); - if(aD->GetTime()>bD->GetTime()) - if(LayerA>LayerB) - if(RowA>RowB) - if(ColumnA>ColumnB) - return true; - return false; - }; - // int i=0; - // std::cout << fProxyArray.size()<<std::endl; - while(isNotSorted){ - isNotSorted=false; - for (uint i=0; i<fProxyArray.size()-1;i++) - { - int a=fProxyArray[i],b=fProxyArray[i+1]; - if(CompareDigis(a,b)) - { - fProxyArray[i]=b,fProxyArray[i+1]=a; - isNotSorted=true; - //LOG(fatal) << a << " "<< b<< " " <<CompareDigis(a,b) << CompareDigis(b,a) <<static_cast<CbmTrdDigi*> (fDigis->At (a))->ToString()<<" "<< static_cast<CbmTrdDigi*> (fDigis->At (b))->ToString(); - } - } - /*for (auto x:fProxyArray) - std::cout <<x << " "; - std::cout <<std::endl;*/ - } -} - -void CbmTrdSimpleClusterizer::FillAndSortProxyArray(){ - fProxyArray.clear(); - UInt_t nSpadicDigis = fDigiMan->GetNofDigis(ECbmModuleId::kTrd); //SPADIC messages per TimeSlic - for (UInt_t iSpadicDigi = 0; iSpadicDigi < nSpadicDigis; iSpadicDigi+=1){ - const CbmTrdDigi* CurrentDigi = fDigiMan->Get<CbmTrdDigi>(iSpadicDigi); - if (CurrentDigi == nullptr || CurrentDigi==0x0) - continue; - fProxyArray.emplace_back(iSpadicDigi); - } - auto CompareDigis= - [this/*,&nSpadicDigis*/](const UInt_t a,const UInt_t b){ - std::mutex mtx; - mtx.lock(); - const CbmTrdDigi*aD=fDigiMan->Get<CbmTrdDigi>(a), - *bD=fDigiMan->Get<CbmTrdDigi>(b); - UInt_t TimeA=std::round(aD->GetTime()/fBT->GetSamplingTime()), - TimeB=std::round(bD->GetTime()/fBT->GetSamplingTime()); - if(TimeA<TimeB) - return true; - else if (TimeA>TimeB) - return false; - UInt_t AddressA=this->fBT->GetAddress(aD), - AddressB=this->fBT->GetAddress(bD); - Int_t LayerA=CbmTrdAddress::GetLayerId(AddressA), - LayerB=CbmTrdAddress::GetLayerId(AddressB); - Int_t ModuleA=CbmTrdAddress::GetModuleId(AddressA), - ModuleB=CbmTrdAddress::GetModuleId(AddressB); - Int_t RowA=CbmTrdAddress::GetRowId(AddressA), - RowB=CbmTrdAddress::GetRowId(AddressB); - Int_t ColumnA=CbmTrdAddress::GetColumnId(AddressA), - ColumnB=CbmTrdAddress::GetColumnId(AddressB); - UInt_t CompareAddressA=LayerA<<(8+4+8), - CompareAddressB=LayerB<<(8+4+8); - CompareAddressA|=(ModuleA&0xFF)<<(8+4), - CompareAddressB|=(ModuleB&0xFF)<<(8+4); - CompareAddressA|=(RowA&0xF)<<(8), - CompareAddressB|=(RowB&0xF)<<(8); - CompareAddressA|=(ColumnA&0xFF), - CompareAddressB|=(ColumnB&0xFF); - if(CompareAddressA<CompareAddressB) - return true; - return false; - }; - std::sort(fProxyArray.begin(),fProxyArray.end(),CompareDigis); -} - -void -CbmTrdSimpleClusterizer::Exec (Option_t*) -{ - FillAndSortProxyArray(); -// typedef std::pair<CbmTrdDigi*,Int_t> DataPair; - static Int_t NrTimeslice = 0; - LOG(info) << this->GetName () << ": Clearing Clusters"; - fClusters->Clear ("C"); - UInt_t nSpadicDigis = fDigiMan->GetNofDigis(ECbmModuleId::kTrd); //SPADIC messages per TimeSlic - UInt_t NrClusters = 0; - TString GraphName = "Clusters_Created"; - LOG(info) << this->GetName () << ": Reconstructing Clusters from " - << nSpadicDigis << " Digis"; - CbmTrdCluster*CurrentCluster = nullptr; - Bool_t newCluster = true; - Bool_t SplitCluster=false; - UInt_t CurrentProxy = 0; - std::vector<int>TriggerCounter; - //Digis are n longer sortable. Operate on proxy. - for (UInt_t iSpadicDigi = 0; iSpadicDigi < fProxyArray.size(); ++iSpadicDigi) - { - UInt_t previousProxy = CurrentProxy; - CurrentProxy = (fProxyArray.at(iSpadicDigi)); - const CbmTrdDigi* CurrentDigi=fDigiMan->Get<CbmTrdDigi>(CurrentProxy), - *previousDigi=fDigiMan->Get<CbmTrdDigi>(previousProxy); - if (!CurrentDigi||previousProxy==CurrentProxy) - continue; - //Fist check for Abort Conditions, done explicitly due to the high amount of state in this loop. - //If newCluster is true, skip checks. - //TODO: Check if Implementation as a explicit state machine is feasible. - if (!newCluster) - { - Long64_t previousTime = - static_cast<Long64_t> ((previousDigi->GetTime () + 1) / (1E3 / 16)); - Long64_t CurrentTime = static_cast<Long64_t> ((CurrentDigi->GetTime () - + 1) / (1E3 / 16)); - if (previousTime != CurrentTime) - { - //Time window is finished, create new Cluster. - newCluster=true; - } - UInt_t previousAddress=fBT->GetAddress(previousDigi), - currentAddress=fBT->GetAddress(CurrentDigi); - Int_t PreviousLayer = CbmTrdAddress::GetLayerId ( - previousAddress); - Int_t CurrentLayer = CbmTrdAddress::GetLayerId ( - currentAddress); - Int_t PreviousModule = CbmTrdAddress::GetSectorId ( - previousAddress); - Int_t CurrentModule = CbmTrdAddress::GetSectorId ( - currentAddress); - Int_t PreviousRow = CbmTrdAddress::GetRowId ( - previousAddress); - Int_t CurrentRow = CbmTrdAddress::GetRowId ( - currentAddress); - if ((PreviousRow != CurrentRow) || (PreviousModule != CurrentModule) - //||(PreviousSector!=CurrentSector) - || (PreviousLayer != CurrentLayer)) - { - //Layer, sector,module or Row is finished, create new Cluster. - newCluster=true; - } - Int_t PreviousCol = CbmTrdAddress::GetColumnId ( - previousAddress); - Int_t CurrentCol = CbmTrdAddress::GetColumnId ( - currentAddress); - if (CurrentCol - PreviousCol > 1) - { - //Large Gap between Clusters found, create new Cluster. - newCluster=true; - } - if (CurrentDigi->GetTriggerType()==2) - { - if(!TriggerCounter.empty()) - if(TriggerCounter.back()==2) - newCluster=true; - } - if (!newCluster&&!TriggerCounter.empty()&&CurrentDigi->GetTriggerType()%2!=0) - { - if(TriggerCounter.back()%2!=0) - { - newCluster=true; - SplitCluster=true; - } - } - } - //Done Checking for abort conditions, create new Cluster if necessary. - if (newCluster) - { - //std::cout <<previousDigi->ToString() <<CurrentDigi->ToString()<<std::endl<<std::endl; - if (CurrentCluster) - { - // LOG(info)<<CurrentCluster->GetDigis().size() << " "/*<<CurrentCluster->GetDigi(0)*/; - //TODO: Accurately set number of Columns. - CurrentCluster->SetNCols (fBT->GetColumnWidth(CurrentCluster)); - CurrentCluster->SetNRows (fBT->GetRowWidth(CurrentCluster)); - /*if(fBT->GetColumnWidth(CurrentCluster)==1) - if(previousDigi&&CurrentDigi) - std::cout << previousDigi->ToString()<<CurrentDigi->ToString()<<std::endl; - */ - } - CurrentCluster = static_cast<CbmTrdCluster*>(fClusters->ConstructedAt(NrClusters++)); - CurrentCluster->SetDigis(std::vector<int>()); - if(SplitCluster&&previousDigi!=nullptr) - { - CurrentCluster->AddDigi(previousProxy); - SplitCluster=false; - } - newCluster = false; - TriggerCounter.clear(); - } - //We can now add the Current Digi to the current Cluster. - //TODO: Filter for Hit Type Pattern. Currently planned for V2, the advanced Clusterizer. - TriggerCounter.push_back(CurrentDigi->GetTriggerType()); - CurrentCluster->AddDigi (CurrentProxy); - //Done with loop. - //TODO: IMPORTANT: cluster tools for charge, displacement and so on. - } - fHm->G1 (GraphName.Data ())->SetPoint (fHm->G1 (GraphName.Data ())->GetN (), - NrTimeslice++, NrClusters); - LOG(info) << this->GetName () << ": Finished creating Clusters"; - LOG(info) << this->GetName () << ": Check size distribution of Clusters"; - std::vector<TH2*> Sizemaps; - for (Int_t layer = 0; layer < fBT->GetNrLayers(); layer++) - { - TString HistName = "Cluster_size_Distribution_Layer_" - + std::to_string (layer); - Sizemaps.push_back (fHm->H2 (HistName.Data ())); - } - - for (UInt_t iCluster = 0; iCluster < NrClusters; ++iCluster) - { - CurrentCluster = static_cast<CbmTrdCluster*> (fClusters->At (iCluster)); - if (CurrentCluster) - { - const CbmTrdDigi*firstDigi = fDigiMan->Get<CbmTrdDigi>( - *(CurrentCluster->GetDigis ().begin ())); - Int_t Layer = CbmTrdAddress::GetLayerId (fBT->GetAddress(firstDigi)); - /*Int_t Col = CbmTrdAddress::GetColumnId (firstDigi->GetAddress ());*/ - Sizemaps.at (Layer)->Fill (0.0, CurrentCluster->GetNofDigis ()); - } - } - Sizemaps.clear(); - for (Int_t layer = 0; layer < fBT->GetNrLayers(); layer++) - { - TString HistName = "Cluster_Size_Type_Distribution_Layer_" - + std::to_string (layer); - Sizemaps.push_back (fHm->H2 (HistName.Data ())); - } - for (UInt_t iCluster = 0; iCluster < NrClusters; ++iCluster) - { - CurrentCluster = static_cast<CbmTrdCluster*> (fClusters->At (iCluster)); - if (CurrentCluster) - { - Int_t FirstIndex= - (CurrentCluster->GetDigis().at(0)); - const CbmTrdDigi*firstDigi = fDigiMan->Get<CbmTrdDigi>(FirstIndex); - Int_t Layer = CbmTrdAddress::GetLayerId (fBT->GetAddress(firstDigi)); - Sizemaps.at(Layer)->Fill (fBT->GetColumnWidth(CurrentCluster),fBT->ClassifyCluster(CurrentCluster)); - } - } - - LOG(info) << this->GetName () - << ": Done checking size distribution of Clusters"; -} - -ClassImp(CbmTrdSimpleClusterizer) diff --git a/beamtime/trd/lib/CbmTrdSimpleClusterizer.h b/beamtime/trd/lib/CbmTrdSimpleClusterizer.h deleted file mode 100644 index 1194ca4d4129c7e1573f40d37a32d699ceee5947..0000000000000000000000000000000000000000 --- a/beamtime/trd/lib/CbmTrdSimpleClusterizer.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef CBMTRDSIMPLECLUSTERIZER_H -#define CBMTRDSIMPLECLUSTERIZER_H - - -#include "CbmTrdQABase.h" -#include <utility> -class CbmTrdSimpleClusterizer : public CbmTrdQABase -{ - protected: - CbmDigiManager* fDigiMan = nullptr; - TClonesArray* fClusters; - void FillAndSortProxyArray(); - void BubbleSort(); - - - public: - std::vector<UInt_t>fProxyArray; - CbmTrdSimpleClusterizer(); - CbmTrdSimpleClusterizer(const CbmTrdSimpleClusterizer&) = delete; - CbmTrdSimpleClusterizer& operator=(const CbmTrdSimpleClusterizer&) = delete; - // ~CbmTrdSimpleClusterizer(); - InitStatus Init(); - void Exec(Option_t*); - void CreateHistograms(); - -ClassDef(CbmTrdSimpleClusterizer,1); -}; - -#endif - diff --git a/beamtime/trd/lib/CbmTrdSimpleDigitizer.cxx b/beamtime/trd/lib/CbmTrdSimpleDigitizer.cxx deleted file mode 100644 index 2b9714ac22a5bdcb9af96ee9b9bf6296e5823876..0000000000000000000000000000000000000000 --- a/beamtime/trd/lib/CbmTrdSimpleDigitizer.cxx +++ /dev/null @@ -1,200 +0,0 @@ -#include <numeric> -#include "CbmTrdSimpleDigitizer.h" -#include "CbmTrdDigi.h" -#include "CbmTrdAddress.h" - -CbmTrdSimpleDigitizer::CbmTrdSimpleDigitizer () - : CbmTrdQABase ("CbmTrdSimpleDigitizer"), fDigis(nullptr) -{ -} - -InitStatus -CbmTrdSimpleDigitizer::Init () -{ - LOG(debug) << "Initilization of " << this->GetName (); - - // Get a handle from the IO manager - FairRootManager* ioman = FairRootManager::Instance (); - assert ( ioman ); - - // Get a pointer to the previous already existing data level - fRaw = static_cast<TClonesArray*> (ioman->GetObject ("SpadicRawMessage")); - if (!fRaw) - { - LOG(fatal) << "No InputDataLevelName SpadicRawMessage array!\n" - << this->GetName () << " will be inactive"; - return kERROR; - } - - // --- Branch for digis - fDigis = new std::vector<CbmTrdDigi>; - ioman->RegisterAny("TrdDigi", fDigis, - false); - - // Do whatever else is needed at the initilization stage - // Create histograms to be filled - // initialize variables - CbmTrdSimpleDigitizer::CreateHistograms (); - - return kSUCCESS; -} - -void -CbmTrdSimpleDigitizer::CreateHistograms () -{ - for (Int_t layer = 0; layer < fBT->GetNrLayers(); layer++) - { - TString HistName = "Baselinemap_Layer_" + std::to_string (layer); - fHm->Add ( - HistName.Data (), - new TProfile2D (HistName.Data (), HistName.Data (), 256, -0.5, 255.5, - 6, -0.5, 5.5)); - fHm->P2 (HistName.Data ())->GetXaxis ()->SetTitle ("Column"); - fHm->P2 (HistName.Data ())->GetYaxis ()->SetTitle ("Row"); - } - TString GraphName = "Digis_Created"; - fHm->Add (GraphName.Data (), new TGraph); - fHm->G1 (GraphName.Data ())->SetNameTitle (GraphName.Data (), - GraphName.Data ()); - fHm->G1 (GraphName.Data ())->GetXaxis ()->SetTitle ("TimeSlice"); - fHm->G1 (GraphName.Data ())->GetYaxis ()->SetTitle ("Nr of created Digis"); -} - -void -CbmTrdSimpleDigitizer::Exec (Option_t*) -{ - static Int_t NrTimeslice = 0; - LOG(info) << this->GetName () << ": Clearing Digis"; - // fDigis->Clear (); - fDigis->clear (); - UInt_t nSpadicMessages = fRaw->GetEntriesFast (); //SPADIC messages per TimeSlice - TString Statefullness = "stateless"; - LOG(info) << this->GetName () << ": Estimating Baseline " << Statefullness - << " Digitizer"; - std::vector<TProfile2D*> Hitmaps; - for (Int_t layer = 0; layer < fBT->GetNrLayers(); layer++) - { - TString HistName = "Baselinemap_Layer_" + std::to_string (layer); - Hitmaps.push_back (fHm->P2 (HistName.Data ())); - } - for (UInt_t iSpadicMessage = 0; iSpadicMessage < nSpadicMessages; - ++iSpadicMessage) - { - CbmSpadicRawMessage *raw = static_cast<CbmSpadicRawMessage*> (fRaw->At ( - iSpadicMessage)); - if (!(raw->GetHit ())) - { - continue; - } - if(raw->GetTriggerType()==1 && (raw->GetSamples()[0]>-200 || raw->GetSamples()[4] >= raw->GetSamples()[5])/*(raw->GetSamples()[0]> raw->GetSamples()[4] || raw->GetSamples()[8]< raw->GetSamples()[4])*/) - continue; - Int_t Baseline = raw->GetSamples ()[0]; - if (Baseline < -150) - Hitmaps.at (GetLayerID (raw))->Fill (GetColumnID (raw), GetRowID (raw),Baseline); - } - std::map<UInt_t, boost::circular_buffer<int16_t> > BaselineMap; - for (UInt_t iSpadicMessage = 0; iSpadicMessage < nSpadicMessages; - ++iSpadicMessage) - { - CbmSpadicRawMessage *raw = static_cast<CbmSpadicRawMessage*> (fRaw->At ( - iSpadicMessage)); - if (!(raw->GetHit ())) - { - continue; - } - auto CurrentBuffer = BaselineMap.find (fBT->GetAddress (raw)); - if (CurrentBuffer == BaselineMap.end ()) - { - auto& TempBuffer = BaselineMap[fBT->GetAddress (raw)]; - TempBuffer.set_capacity (20); - CurrentBuffer = BaselineMap.find (fBT->GetAddress (raw)); - } - if (CurrentBuffer->second.full ()) - continue; - int16_t BaselineMeasure = fBT->GetBaseline (raw); - //std::cout << " "<< BaselineMeasure << std::endl; - if (BaselineMeasure < -170) - CurrentBuffer->second.push_back (BaselineMeasure); - } - TString GraphName = "Digis_Created"; - Int_t NrDigis = 0; - LOG(info) << this->GetName () << ": Creating Digis with " << Statefullness - << " Digitizer"; - Float_t*Samples = new Float_t[32]; - for (UInt_t iSpadicMessage = 0; iSpadicMessage < nSpadicMessages; - ++iSpadicMessage) - { - CbmSpadicRawMessage *raw = static_cast<CbmSpadicRawMessage*> (fRaw->At ( - iSpadicMessage)); - if (!(raw->GetHit ())) - { - continue; - } - if (raw->GetTriggerType () == 1 - && (raw->GetSamples ()[0] > -200 - || raw->GetSamples ()[4] >= raw->GetSamples ()[5])/*(raw->GetSamples()[0]> raw->GetSamples()[4] || raw->GetSamples()[8]< raw->GetSamples()[4])*/) - continue; - Float_t BaselineEstimate = - { 0 }; - auto CurrentBuffer = BaselineMap.find (fBT->GetAddress (raw)); - int16_t BaselineMeasure = fBT->GetBaseline (raw); - if (BaselineMeasure < -200) - { - CurrentBuffer->second.push_back (BaselineMeasure); - } - BaselineEstimate = std::accumulate (CurrentBuffer->second.begin (), - CurrentBuffer->second.end (), 0L); - //Div-by-Zero Check, should NEVER occur. - if (!CurrentBuffer->second.empty ()) - BaselineEstimate /= CurrentBuffer->second.size (); - //std::cout << BaselineEstimate << std::endl; - - //BaselineEstimate=(fBT->GetBaseline(raw)<BaselineEstimate)?fBT->GetBaseline(raw):BaselineEstimate; - for (Int_t i = 0; i < 32; i++) - { - if (i < raw->GetNrSamples ()) - Samples[i] = static_cast<Float_t> (raw->GetSamples ()[i]) - - BaselineEstimate; - else - Samples[i] = 0.0; - } - UInt_t Address=fBT->GetAddress (raw); - UInt_t RowID=CbmTrdAddress::GetRowId(Address), - ColumnID=CbmTrdAddress::GetColumnId(Address); - UInt_t PadID=RowID*fBT->GetNrColumns(fBT->GetLayerID(raw))+ColumnID; - fDigis->emplace_back(static_cast<Int_t> (PadID), - fBT->GetMaximumAdc (raw,BaselineEstimate)*1.e4, - raw->GetFullTime () * fBT->GetSamplingTime(), //65 ns per timestamp - raw->GetTriggerType (), - 1); - /* - new ((*fDigis)[NrDigis]) CbmTrdDigi (static_cast<Int_t> (PadID), - fBT->GetMaximumAdc (raw,BaselineEstimate)*1.e4, - raw->GetFullTime () * fBT->GetSamplingTime(), //65 ns per timestamp - raw->GetTriggerType (), - 1); - */ - static_cast<CbmTrdDigi> (fDigis->at(NrDigis++)).SetAddress(Address); - //std::cout<< fBT->GetMaximumAdc (raw,BaselineEstimate)<< std::endl; - if(fBT->GetMaximumAdc (raw,BaselineEstimate)>512) - { - LOG(info)<< "CbmTrdSimpleDigitizer unusual maxADC"; - for (int i=0;i<raw->GetNrSamples();i++) - { - std::cout << raw->GetSamples()[i] << " "; - } - LOG(info) << "/n"; - LOG(fatal)<<" KILL"; - } - /*std::cout << BaselineEstimate << " "<<fBT->GetMaximumAdc(raw,BaselineEstimate)<< " "<< - fBT->GetIntegratedCharge (raw, BaselineEstimate) << std::endl;*/ - } - delete[] Samples; - fHm->G1 (GraphName.Data ())->SetPoint (fHm->G1 (GraphName.Data ())->GetN (), - NrTimeslice++, NrDigis); - // fDigis->Sort (); - LOG(info) << this->GetName () << ": Finished creating Digis with " - << Statefullness << " Digitizer"; -} - -ClassImp(CbmTrdSimpleDigitizer) diff --git a/beamtime/trd/lib/CbmTrdSimpleDigitizer.h b/beamtime/trd/lib/CbmTrdSimpleDigitizer.h deleted file mode 100644 index b66d67732414d0cf06e1c5fda38c8e2c8b754e52..0000000000000000000000000000000000000000 --- a/beamtime/trd/lib/CbmTrdSimpleDigitizer.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef CBMTRDSIMPLEDIGITIZER_H -#define CBMTRDSIMPLEDIGITIZER_H - - -#include "CbmTrdQABase.h" -#include <boost/circular_buffer.hpp> -#include <cstdint> -#include <algorithm> -#include <cmath> - -class CbmTrdSimpleDigitizer : public CbmTrdQABase -{ - void StatelessDigitizer(); - protected: - std::vector<CbmTrdDigi>* fDigis; - public: - CbmTrdSimpleDigitizer(); - CbmTrdSimpleDigitizer(const CbmTrdSimpleDigitizer&) = delete; - CbmTrdSimpleDigitizer& operator=(const CbmTrdSimpleDigitizer&) = delete; - // ~CbmTrdSimpleDigitizer(); - InitStatus Init(); - void Exec(Option_t*); - void CreateHistograms(); - -ClassDef(CbmTrdSimpleDigitizer,2); -}; - -#endif - diff --git a/beamtime/trd/lib/CbmTrdTestBeamAnalysis.cxx b/beamtime/trd/lib/CbmTrdTestBeamAnalysis.cxx deleted file mode 100644 index ad126349074e294752fcfc1e2ddadd9490ad3a57..0000000000000000000000000000000000000000 --- a/beamtime/trd/lib/CbmTrdTestBeamAnalysis.cxx +++ /dev/null @@ -1,1037 +0,0 @@ -#include "CbmTrdTestBeamAnalysis.h" -#include <iostream> -#include "CbmSpadicRawMessage.h" -#include "CbmHistManager.h" -#include "CbmBeamDefaults.h" - -#include "FairLogger.h" - -#include "TDirectory.h" - -#include "TH1.h" -#include "TH2.h" -#include "TH3.h" -#include "TNtuple.h" -#include <TFile.h> - -#include "TString.h" -#include "TMath.h" -#include <cmath> -#include <map> -#include <vector> -// ---- Default constructor ------------------------------------------- -CbmTrdTestBeamAnalysis::CbmTrdTestBeamAnalysis() - : FairTask("CbmTrdTestBeamAnalysis"), - fTimeBins(32), - fRawSpadic(NULL), - fHM(new CbmHistManager()), - fSysCore(-1), - fSpadic(-1), - fTimeCounter(0), - fBaseMethod(kLastTimeBins), - fBaselineBins(1), - fBaseline(), - fNoiseCounter(0), - fNT(0x0) -{ - for (Int_t i=0; i<32; ++i) { - fBaseline[i] = 0L; - } - LOG(debug) << "Default Constructor of CbmTrdTestBeamAnalysis"; -} - -// ---- Destructor ---------------------------------------------------- -CbmTrdTestBeamAnalysis::~CbmTrdTestBeamAnalysis() -{ - if(fNT) delete fNT; - LOG(debug) << "Destructor of CbmTrdTestBeamAnalysis"; -} - -// ---- Initialisation ---------------------------------------------- -void CbmTrdTestBeamAnalysis::SetParContainers() -{ - LOG(debug) << "SetParContainers of CbmTrdTestBeamAnalysis"; - // Load all necessary parameter containers from the runtime data base - /* - FairRunAna* ana = FairRunAna::Instance(); - FairRuntimeDb* rtdb=ana->GetRuntimeDb(); - - <CbmTrdTestBeamAnalysisDataMember> = (<ClassPointer>*) - (rtdb->getContainer("<ContainerName>")); - */ -} - -// ---- Init ---------------------------------------------------------- -InitStatus CbmTrdTestBeamAnalysis::Init() -{ - LOG(debug) << "Initilization of CbmTrdTestBeamAnalysis"; - - // Get a handle from the IO manager - FairRootManager* ioman = FairRootManager::Instance(); - - // Get a pointer to the previous already existing data level - fRawSpadic = static_cast<TClonesArray*>(ioman->GetObject("SpadicRawMessage")); - if ( ! fRawSpadic ) { - LOG(fatal) << "No InputDataLevelName array!\n CbmTrdTestBeamAnalysis will be inactive"; - return kERROR; - } - - // Do whatever else is needed at the initilization stage - // Create histograms to be filled - // initialize variables - CreateHistograms(); - - fNT = new TNtuple("ntuple","tuple","timeCount:channelID:triggerType"); - - return kSUCCESS; -} - -// ---- ReInit ------------------------------------------------------- -InitStatus CbmTrdTestBeamAnalysis::ReInit() -{ - LOG(debug) << "Initilization of CbmTrdTestBeamAnalysis"; - return kSUCCESS; -} - -// ---- Exec ---------------------------------------------------------- -void CbmTrdTestBeamAnalysis::Exec(Option_t* /*option*/) -{ - //Int_t channelMapping[32] = {1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31, - // 0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30}; - - // <ASIC ID "Syscore%d_Spadic%d"<Time, SpadicMessage> > - std::map<TString, std::map<ULong_t, std::vector<CbmSpadicRawMessage*> > > timeBuffer; - - - Int_t entries = fRawSpadic->GetEntriesFast(); - Int_t sumTrigger[3][6] = {{0}}; - // LOG(info) << "******"; - if (entries > 0) - LOG(info) << "Entries: " << entries; - - // Find info about hitType, stopType and infoType in cbmroot/fles/spadic/message/constants/.. - TString triggerTypes[4] = {"Global trigger", - "Self triggered", - "Neighbor triggered", - "Self and neighbor triggered"}; - TString stopTypes[6] = {"Normal end of message", - "Channel buffer full", - "Ordering FIFO full", - "Multi hit", - "Multi hit and channel buffer full", - "Multi hit and ordering FIFO full"}; - TString infoTypes[8] = {"Channel disabled during message building", - "Next grant timeout", - "Next request timeout", - "New grant but channel empty", - "Corruption in message builder", - "Empty word", - "Epoch out of sync", - "infoType out of array"}; - - ULong_t lastSpadicTime[3][6] = {{0}}; //[sys][spa] - ULong_t firstSpadicTime[3][6] = {{static_cast<ULong_t>(9e+99)}}; //[sys][spa] - Int_t clusterSize[3][6] = {{1}}; - // Double_t centreOfGravity =0.; - - // loop over all entries - for (Int_t i=0; i < entries; ++i) { - CbmSpadicRawMessage* raw = static_cast<CbmSpadicRawMessage*>(fRawSpadic->At(i)); - Int_t eqID = raw->GetEquipmentID(); - Int_t sourceA = raw->GetSourceAddress(); - Int_t chID = raw->GetChannelID(); - // Int_t nrSamples=raw->GetNrSamples(); - Int_t triggerType=raw->GetTriggerType(); - Int_t stopType=raw->GetStopType(); - Int_t infoType=raw->GetInfoType(); - if (infoType > 6) infoType = 7; - Int_t groupId=raw->GetGroupId(); - ULong_t time = raw->GetFullTime(); - - // get syscore, spadic and channel - TString syscore = GetSysCore(eqID); - Int_t sysID = GetSysCoreID(eqID); - TString spadic = GetSpadic(sourceA); - Int_t spaID = GetSpadicID(sourceA); - if(spaID%2) chID+=16; - TString channelId=Form("_Ch%02d", chID); - - // use global slection of syscore and/or spadic - if(fSysCore>-1 && sysID!=fSysCore) continue; - if(fSpadic>-1 && spaID!=fSpadic && spaID !=fSpadic+1) continue; - - // add raw message to map sorted by timestamps, syscore and spadic - timeBuffer[TString(syscore+spadic)][time].push_back(raw); - - if (time > lastSpadicTime[sysID][spaID]){ - // ok, next hit - //LOG(debug) << "ClusterSize: " << clusterSize[sysID][spaID]; - fHM->H1(TString("ClusterSize_" + syscore + spadic).Data())->Fill(clusterSize[sysID][2*spaID]); - fHM->H1(TString("ClusterSize_" + syscore + spadic).Data())->Fill(clusterSize[sysID][2*spaID+1]); - clusterSize[sysID][spaID] = 1; - } else if (time == lastSpadicTime[sysID][spaID]) { // Clusterizer - // possible FNR trigger - if (stopType == 0){ // normal ending - //clusterSize = 1; - if (triggerType == 0) { // gobal dlm trigger - - } else if (triggerType == 1) { //Self triggered - // central pad candidate - clusterSize[sysID][spaID]+=1; - } else if (triggerType == 2) { //Neighbor triggered - // outer pad candidate - clusterSize[sysID][spaID]+=1; - } else { //Self and neighbor triggered - // central pad candidate - clusterSize[sysID][spaID]+=1; - } - } else { - // multihit or currupted - } - } else { - LOG(error) << "SPADIC " << sysID << spaID << " event time " << time << " < last time " << lastSpadicTime[sysID][spaID]; - //Finish(); - //return; - } - - fHM->H1(TString("TriggerTypes_" + syscore + spadic).Data())->Fill(triggerTypes[triggerType],1); - fHM->H1(TString("StopTypes_" + syscore + spadic).Data())->Fill(stopTypes[stopType],1); - if (infoType <= 7) - fHM->H1(TString("InfoTypes_" + syscore + spadic).Data())->Fill(infoTypes[infoType],1); - fHM->H1(TString("GroupId_" + syscore + spadic).Data())->Fill(groupId); - //sumTrigger[sysID][spaID]++; - if (stopType > 0){ //corrupt or multi message - TString histName = "ErrorCounter_" + syscore + spadic; - fHM->H1(histName.Data())->Fill(chID); - } - else { - //only normal message end - sumTrigger[sysID][spaID]++; - - TString histName = "CountRate_" + syscore + spadic; - fHM->H1(histName.Data())->Fill(chID); - - // histName = "Trigger_Heatmap_" + syscore + spadic; - // if (chID%2 == 0) { - // fHM->H2(histName.Data())->Fill(chID/2,0); - // } else { - // fHM->H2(histName.Data())->Fill((chID-1)/2,1); - // } - } - lastSpadicTime[sysID][spaID] = time; - if(time<firstSpadicTime[sysID][spaID]) firstSpadicTime[sysID][spaID] = time; - } //entries pedestal - - - for (Int_t sy = 0; sy < 2; sy++){ - for (Int_t sp = 0; sp < 2; sp++){ - - // use global selection of syscore and/or spadic - if(fSysCore>-1 && sy !=fSysCore) continue; - if(fSpadic>-1 && sp !=fSpadic && sp !=fSpadic+1) continue; - - TString histName = "TriggerCounter_SysCore" + std::to_string(sy) + "_Spadic" + std::to_string(sp); - for (Int_t timeSlice = 1; timeSlice <= fHM->H1(histName.Data())->GetNbinsX(); timeSlice++){ - fHM->H1(histName.Data())->SetBinContent(timeSlice,fHM->H1(histName.Data())->GetBinContent(timeSlice+1)); // shift all bin one to the left - } - fHM->H1(histName.Data())->SetBinContent(fHM->H1(histName.Data())->GetNbinsX(),sumTrigger[sy][2*sp] + sumTrigger[sy][2*sp+1]);// set only the spa sys combi to new value - fHM->H1("TriggerSum")->Fill(TString("SysCore" + std::to_string(sy) + "_Spadic" + std::to_string(sp)),sumTrigger[sy][2*sp] + sumTrigger[sy][2*sp+1]); - } - } - - //// Clusterisation - TString histName; - // complicated loop over sorted map of timestamps - for(std::map<TString, std::map<ULong_t, std::vector<CbmSpadicRawMessage*> > >::iterator it = timeBuffer.begin() ; it != timeBuffer.end(); it++){ - - // complicated loop over sorted map of raw messages - for (std::map<ULong_t, std::vector<CbmSpadicRawMessage*> > ::iterator it2 = it->second.begin() ; it2 != it->second.end(); it2++) { - //LOG(info) << "ClusterSize:" << Int_t(it2->second.size()); - - Int_t Clustersize=Int_t(it2->second.size()); - // Int_t Integral_cluster[32]; // TODO: needed? - // Double_t clsAdcInt_Max=0; //TODO: needed? - // Int_t Integral_sum=0; //TODO: obsololete - Int_t clsType=0; // cluster trigger type identification - - // buffer for the whole clusters - Int_t clsChID[15]; // channel ID - //Int_t clsTriggerInfo[15]; // trigger info - Double_t clsAdcInt[15]; // adc integral - Double_t clsAdcAmpl[15]; // max amplitude - Double_t clsStopType[15]; // stop type - Bool_t clsNoise[15]; // noisy channel - for(Int_t n=0;n<15;n++){ - clsChID[n]=0; - //clsTriggerInfo[n]=0; - clsAdcInt[n]=0; - clsAdcAmpl[n]=0; - clsStopType[n]=0; - clsNoise[n]=kTRUE; - } - // for(Int_t i=0;i<nrSamples;i++) Integral_cluster[i]=0; - - - // loop over all pads in the cluster - for (Int_t iPad = 0; iPad < Clustersize; iPad++){ - CbmSpadicRawMessage* raw = static_cast<CbmSpadicRawMessage*>(it2->second.at(iPad)); - Int_t eqID = raw->GetEquipmentID(); - Int_t sourceA = raw->GetSourceAddress(); - Int_t chID = raw->GetChannelID(); - Int_t nrSamples=raw->GetNrSamples(); - Int_t triggerType=raw->GetTriggerType(); - Int_t stopType=raw->GetStopType(); - Int_t infoType=raw->GetInfoType(); - if (infoType > 6) infoType = 7; - // Int_t groupId=raw->GetGroupId(); - // ULong_t time = raw->GetFullTime(); - - // get syscore, spadic and channel - TString syscore = GetSysCore(eqID); - // Int_t sysID = GetSysCoreID(eqID); - TString spadic = GetSpadic(sourceA); - Int_t spaID = GetSpadicID(sourceA); - if(spaID%2) chID+=16; - TString channelId=Form("_Ch%02d", chID); - - // fill cluster histograms - if(!iPad) { - histName = "Clustersize_" + syscore + spadic; - fHM->H1(histName.Data())->Fill(Clustersize,1.); - } - - // continue only with normal ending messages - // if(stopType) continue; //TODO:what about clustersize - - ///// Noise events - Int_t hlfSamples = TMath::CeilNint(nrSamples/2); - Int_t adcTolerance = 2; - Int_t max1[45]={0}; - Int_t max2[45]={0}; - for(Int_t i=0;i<45;i++) { max1[i]=0; max2[i]=0;} - for(Int_t bin=0; bin < hlfSamples;bin++){ - max1[bin]= raw->GetSamples()[bin]; - max2[bin]= raw->GetSamples()[bin+hlfSamples]; - } - Bool_t isNoise=(TMath::MaxElement(hlfSamples,max1)-TMath::MaxElement(hlfSamples,max2))<adcTolerance; - if(isNoise && !stopType) { - // LOG(info) << "Noisy channel found "; - fNoiseCounter++; - Int_t max =-300; - Int_t min =-100; - Float_t middle=0; - Int_t minbin =0; - Int_t maxbin =0; - - // find max and min adc values in noise events - for(Int_t i=0;i<10;i++){ - Int_t adc=raw->GetSamples()[nrSamples-1-i]; - if(adc>max){ - max = adc; - maxbin = nrSamples-1-i; - } - // adc=raw->GetSamples()[i]; - if(adc<min){ - min = adc; - minbin = i; - } - } - // calculate mean noise adc value - for(Int_t bin=minbin;bin<=maxbin;bin++) middle+=raw->GetSamples()[bin]; - middle /= (maxbin-minbin); - - // noise amplitude - Int_t ampl = max-min; - - // fill noise histograms - histName = "Noise_AvgBaseline_" + syscore + spadic; - fHM->P1(histName.Data())->Fill(chID,middle); - - histName = "Running_Baseline_" + syscore + spadic; - fHM->H2(histName.Data())->Fill(fTimeCounter,middle,chID); - - histName = "Running_AvgBaseline_" + syscore + spadic; - fHM->P2(histName.Data())->Fill(fTimeCounter,chID,middle); - - histName = "Noise_Shape_" + syscore + spadic; - for(Int_t bin = 0; bin < nrSamples; bin++) { - Int_t adc=raw->GetSamples()[bin]; - fHM->H2(histName.Data())->Fill(bin,adc); - fHM->H2((histName+channelId).Data())->Fill(bin,adc); - } - - histName = "Noise_AvgAmplitude_" + syscore + spadic; - fHM->P1(histName.Data())->Fill(chID,ampl); - } - - // fill noise counter - histName = "NoiseCounter_" + syscore + spadic; - fHM->H1(histName.Data())->Fill(isNoise); - - histName = "NoiseCounter_chID_" + syscore + spadic; - fHM->H2(histName.Data())->Fill(chID,isNoise); - - histName = "NoiseCounter_TimeCounter_"+ syscore + spadic; - fHM->H1(histName.Data())->SetBinContent(fTimeCounter,fNoiseCounter); - - - // buffer channel/pad information for cluster contributor - clsChID[iPad] = chID; - //clsTriggerInfo[iPad] = triggerType; - clsStopType[iPad] = stopType; - - // clustertypes TODO: needed? - switch(triggerType) { - case 0: clsType-=1000; break; // global - case 1: clsType+=1; break; // self - case 2: clsType+=10; break; // neighbour - case 3: clsType+=100; break; // self+neighbour - default: Printf("trigger type %d is not defined for channel %d",triggerType,chID); - } - - // calculate baseline based on method - switch(fBaseMethod) { - case kFirstTimeBin: fBaseline[chID] = raw->GetSamples()[0]; break; - case kLastTimeBins: - { - Float_t base=0.; - // sum up last time bins and normalize - for(Int_t i=0;i<fBaselineBins;i++) base+=raw->GetSamples()[nrSamples-1-i]; - fBaseline[chID] = static_cast<Int_t>(base/fBaselineBins); - break; - } - case kNoise: - { - histName = "Running_AvgBaseline_" +syscore + spadic; - Int_t bin = fHM->P2(histName.Data())->FindBin(fTimeCounter,chID); - fBaseline[chID]=fHM->P2(histName.Data())->GetBinContent(bin); - break; - } - } - - // fill baseline histograms - histName = "BaseLine_" + syscore + spadic; - fHM->H2(histName.Data())->Fill(chID,fBaseline[chID]); - - histName = "AvgBaseline_" + syscore + spadic; - fHM->P1(histName.Data())->Fill(chID,fBaseline[chID]); - - // cleaned single channel signals - // these signals could belong to incomplete clusters - if( !isNoise && fBaseline[chID]!=0 && !stopType) { - - Int_t maxAdc=0; - Int_t maxAdc_self=0; - Int_t maxAdc_neighbour=0; - Float_t intAdc = 0; - Float_t intAdc_self = 0; - Float_t intAdc_neighbour = 0; - - // loop over all timebins - for (Int_t bin = 0; bin < nrSamples; bin++) { - - // TODO: check if really needed - if(raw->GetSamples()[0]>=-100 || raw->GetSamples()[1]>=-100) continue; - - // apply baseline correction - Int_t adc = raw->GetSamples()[bin] - fBaseline[chID]; - - // summations - intAdc += adc; - if(triggerType==1) intAdc_self += adc; - else if(triggerType==2) intAdc_neighbour += adc; - // Integral_cluster[bin] += adc; - - // find maximum adc values - if(adc>maxAdc) maxAdc = adc; - if(triggerType==1 && adc>maxAdc_self) maxAdc_self = adc; - if(triggerType==2 && adc>maxAdc_neighbour) maxAdc_neighbour = adc; - - // signal shape histograms - histName = "Signal_Shape_" + syscore + spadic + channelId; - fHM->H2(histName.Data())->Fill(bin,adc); - - histName = "AvgSignal_Shape_" + syscore + spadic + channelId; - fHM->P1(histName.Data())->Fill(bin,adc); - - if(triggerType==1) { - histName = "Signal_Shape_self_" + syscore + spadic + channelId; - fHM->H2(histName.Data())->Fill(bin,adc); - - histName = "AvgSignal_Shape_self_" + syscore + spadic + channelId; - fHM->P1(histName.Data())->Fill(bin,adc); - } - else if(triggerType==2){ - histName = "Signal_Shape_neighbour_" + syscore + spadic + channelId; - fHM->H2(histName.Data())->Fill(bin,adc); - - histName = "AvgSignal_Shape_neighbour_" + syscore + spadic + channelId; - fHM->P1(histName.Data())->Fill(bin,adc); - } - - }//end time bin loop - - // fill max adc values - histName = "AvgAdcMax_" + syscore + spadic; - fHM->P1(histName.Data())->Fill(chID, maxAdc); - - histName = "AvgAdcMax_self_" + syscore + spadic; - fHM->P1(histName.Data())->Fill(chID, maxAdc_self); - - histName = "AvgAdcMax_neighbour_" + syscore + spadic; - fHM->P1(histName.Data())->Fill(chID, maxAdc_neighbour); - - // fill integrated spectra - histName = "AdcInt_" + syscore + spadic; - fHM->H1(histName.Data())->Fill(intAdc); - - histName = "AvgAdcInt_" + syscore + spadic; - fHM->P1(histName.Data())->Fill(chID, intAdc); - - histName = "AvgAdcInt_self_" + syscore + spadic; - if(triggerType==1) fHM->P1(histName.Data())->Fill(chID, intAdc_self); - - histName = "AvgAdcInt_neighbour_" + syscore + spadic; - if(triggerType==2) fHM->P1(histName.Data())->Fill(chID, intAdc_neighbour); - - // integrated spectra - channel by channel - histName = "AdcInt_" + syscore + spadic+ channelId; - fHM->H1(histName.Data())->Fill(intAdc,1.); - - histName = "AdcInt_self_" + syscore + spadic+ channelId; - if(triggerType==1) fHM->H1(histName.Data())->Fill(intAdc_self,1.); - - histName = "AdcInt_neighbour_" + syscore + spadic+ channelId; - if(triggerType==2)fHM->H1(histName.Data())->Fill(intAdc_neighbour,1.); - - // fill buffer - clsAdcInt[iPad] = intAdc; - clsAdcAmpl[iPad] = maxAdc; - clsNoise[iPad] = kFALSE; - }//end good signal selection - - - // 'good' cluster selection - // enter only when last channel is reached - // make use of buffered values - if(iPad==Clustersize-1) { - - // fill cluster types (based on trigger types of its pads) - histName="Cluster_Types_" + syscore + spadic; - if( clsType==21) fHM->H1(histName.Data())->Fill(2); - else if(clsType<4) fHM->H1(histName.Data())->Fill(1); - else if(clsType==220) fHM->H1(histName.Data())->Fill(3); - else if(!(clsType%10)) fHM->H1(histName.Data())->Fill(0); - else fHM->H1(histName.Data())->Fill(4); - - // only use full size clusters size==3||4 - if( Clustersize>=3 && Clustersize<=4) { - // remove full cluster if a stop type is != 'normal ending' - if(!clsStopType[0] && !clsStopType[1] && !clsStopType[2] && !clsStopType[iPad]) { - // remove full cluster if a noisy pad is found - if(!clsNoise[0] && !clsNoise[1] && !clsNoise[2] && !clsNoise[iPad]) { - // remove full cluster if channel 0 has fired - if(clsChID[0]!=0 && clsChID[1]!=0 && clsChID[2]!=0 && clsChID[iPad]!=0) { - // remove full cluster if negative adcInt for single pad - if(clsAdcInt[0]>0 && clsAdcInt[1]>0 && clsAdcInt[2]>0 && clsAdcInt[iPad]>0) { - - - // cluster charge - Int_t clsAdcInt_sum=0; - for(Int_t i=0;i<Clustersize;i++) clsAdcInt_sum += clsAdcInt[i]; - histName = "Cluster_Charge_" + syscore + spadic; - fHM->H1(histName.Data())->Fill(clsAdcInt_sum); - - // cluster max amplitude - Int_t clsAdcAmpl_max=0; - for(Int_t i=0;i<Clustersize;i++) clsAdcAmpl_max += clsAdcAmpl[i]; - - // Pad Response Function - PRF - // TODO: add sorting, currently we assume padIdx=1 = self triggered pad - Double_t w = 6.75; // pad width - if(Clustersize==3) { - for(Int_t i=0;i<Clustersize;i++) { - - // PRF using ADC integrals - // shift by one pad width in case of neighbours - Double_t d = (w/2) * (TMath::Log(clsAdcInt[2]/clsAdcInt[0]) / - TMath::Log(clsAdcInt[1]*clsAdcInt[1] / (clsAdcInt[2]*clsAdcInt[0])) ) - (w*(i-1)); - Double_t q = clsAdcInt[i] / clsAdcInt_sum; - - // fill pad response histograms - histName = "PRF_AdcInt_"+ syscore + spadic; - fHM->H2(histName.Data())->Fill(d,q); - - histName = "AvgPRF_AdcInt_"+ syscore + spadic; - fHM->P1(histName.Data())->Fill(d,q); - - // PRF using ADC maxima - d = (w/2) * (TMath::Log(clsAdcAmpl[2]/clsAdcAmpl[0]) / - TMath::Log(clsAdcAmpl[1]*clsAdcAmpl[1] / (clsAdcAmpl[2]*clsAdcAmpl[0])) ) - (w*(i-1)); - q = clsAdcAmpl[i] / clsAdcAmpl_max; - - // fill pad response histograms - histName = "PRF_AdcAmpl_"+ syscore + spadic; - fHM->H2(histName.Data())->Fill(d,q); - - histName = "AvgPRF_AdcAmpl_"+ syscore + spadic; - fHM->P1(histName.Data())->Fill(d,q); - - } - } //cluster size - - } // adc integral negative - } // bad channel removal - } // noise pad check - } //stop type check - } // cluster size check - } // last pad of cluster - - // if(iPad==Clustersize-1 && fBaseline[chID]!=0 && chID!=0 && chID!=30){ - // if((cluster_histo==0) && (clsType==21 || clsType==220)){ - // for(Int_t k=0;k< Clustersize;k++){ - // histName = "Clusterization_"; - // time count: channelID : triggertype - // fNT->Fill(fTimeCounter,clsChID[k],clsTriggerInfo[k]); - // } - - } //end cluster loop - - // increment time counter - fTimeCounter++; - - } //end timestamp loop - } //end Syscore/spadic loop -} -// ---- Finish -------------------------------------------------------- -void CbmTrdTestBeamAnalysis::Finish() -{ - LOG(debug) << "Finish of CbmTrdTestBeamAnalysis"; - - TString histName = "Clusterization"; - TString title = histName + ";Time;Channel"; - //Printf("total number of time counts %d",fTimeCounter); - fHM->Add(histName.Data(), new TH2F(histName, title,fTimeCounter,0,fTimeCounter,fTimeBins,0,fTimeBins)); - - LOG(info) << " Write histo list to " << FairRootManager::Instance()->GetOutFile()->GetName(); - FairRootManager::Instance()->GetOutFile()->cd(); - - Float_t time=0.; - Float_t channel=0.; - Float_t trigger=0.; - fNT->SetBranchAddress("timeCount",&time); - fNT->SetBranchAddress("channelID",&channel); - fNT->SetBranchAddress("triggerType",&trigger); - for (Int_t i=0;i<Int_t(fNT->GetEntries());i++) { - fNT->GetEntry(i); - // Printf("idx %d: time %.0f channel %.0f trigger %.0f ",i,time,channel,trigger); - fHM->H2(histName.Data())->Fill(time, channel, trigger); - } - - fHM->WriteToFile(); - // fHM->Write("",TObject::kSingleKey); -} - -void CbmTrdTestBeamAnalysis::CreateHistograms() -{ - // Create histograms for 3 Syscores with maximum 3 Spadics - - TString syscoreName[3] = { "SysCore0", "SysCore1", "SysCore2" }; - TString spadicName[3] = { "Spadic0", "Spadic1", "Spadic2" }; - TString channelName[32] = { "00", "01", "02", "03", "04", "05", "06", "07", "08", "09", - "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", - "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", - "30", "31"}; - TString triggerTypes[4] = { "Global trigger", - "Self triggered", - "Neighbor triggered", - "Self and neighbor triggered"}; - TString stopTypes[6] = {"Normal end of message", - "Channel buffer full", - "Ordering FIFO full", - "Multi hit", - "Multi hit and channel buffer full", - "Multi hit and ordering FIFO full"}; - TString infoTypes[8] = {"Channel disabled during message building", - "Next grant timeout", - "Next request timeout", - "New grant but channel empty", - "Corruption in message builder", - "Empty word", - "Epoch out of sync", - "infoType out of array"}; //not official type, just to monitor overflows - - TString cluster_names[5]={"only self", - "only FN", - "One self and two FN", - "Two both and two FN", - "Others"}; - - TString EntryTypes[2]={"Good", "Noise"}; - - - TString histName=""; - TString title=""; - - - fHM->Add("TriggerSum", new TH1F("TriggerSum", "TriggerSum", 9,0,9)); - // histograms for all syscore spadic combinations - for(Int_t syscore = 0; syscore < 3; ++syscore) { - for(Int_t spadic = 0; spadic < 3; ++spadic) { - - // use global selection of syscore and/or spadic - if(fSysCore>-1 && syscore !=fSysCore) continue; - if(fSpadic>-1 && spadic !=fSpadic && spadic !=fSpadic+1) continue; - - LOG(info) << Form("create histograms for syscore %d/%d and spadic %d/%d ",syscore,fSysCore, spadic,fSpadic); - - fHM->H1("TriggerSum")->GetXaxis()->SetBinLabel(3*syscore+spadic+1,TString(syscoreName[syscore]+"_"+spadicName[spadic])); - - histName = "TriggerCounter_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";TimeSlice;Trigger / TimeSlice"; - fHM->Add(histName.Data(), new TH1F(histName, title, 500, 0, 500)); - - histName = "CountRate_" + syscoreName[syscore] + "_" + spadicName[spadic]; //OK - title = histName + ";Channel;Counts"; - fHM->Add(histName.Data(), new TH1F(histName, title, fTimeBins, 0, fTimeBins)); - - histName = "ErrorCounter_" + syscoreName[syscore] + "_" + spadicName[spadic]; //OK - title = histName + ";Channel;Errors"; - fHM->Add(histName.Data(), new TH1F(histName, title, fTimeBins, 0, fTimeBins)); - - histName = "TriggerTypes_" + syscoreName[syscore] + "_" + spadicName[spadic]; //OK - title = histName + "; ;Counts"; - fHM->Add(histName.Data(), new TH1F(histName, title, 4, 0, 4)); - for (Int_t tType=0; tType < 4; tType++) - fHM->H1(histName.Data())->GetXaxis()->SetBinLabel(tType+1,triggerTypes[tType]); - - histName = "StopTypes_" + syscoreName[syscore] + "_" + spadicName[spadic]; //OK - title = histName + "; ;Counts"; - fHM->Add(histName.Data(), new TH1F(histName, title, 6, 0, 6)); - for (Int_t sType=0; sType < 6; sType++) - fHM->H1(histName.Data())->GetXaxis()->SetBinLabel(sType+1,stopTypes[sType]); - - histName = "InfoTypes_" + syscoreName[syscore] + "_" + spadicName[spadic]; //OK - title = histName + "; ;Counts"; - fHM->Add(histName.Data(), new TH1F(histName, title, 8, 0, 8)); - for (Int_t iType=0; iType < 8; iType++) - fHM->H1(histName.Data())->GetXaxis()->SetBinLabel(iType+1,infoTypes[iType]); - - histName = "GroupId_" + syscoreName[syscore] + "_" + spadicName[spadic]; //OK - title = histName + "; ;Counts"; - fHM->Add(histName.Data(), new TH1F(histName, title, 2, 0, 2)); - - // baseline - histName = "BaseLine_" + syscoreName[syscore] + "_" + spadicName[spadic]; //OK - title = histName + ";Channel;ADC value"; - fHM->Add(histName.Data(), new TH2F(histName, title, fTimeBins, 0, fTimeBins, 511, -256, 255)); - - histName = "AvgBaseline_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName +";channel;<ADC>"; - fHM->Add(histName.Data(), new TProfile(histName, title,fTimeBins,0,fTimeBins, "S")); - - // noise - histName = "Noise_AvgBaseline_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName +";channel;ADC"; - fHM->Add(histName.Data(), new TProfile(histName, title,fTimeBins,0,fTimeBins, "S")); - - histName = "Running_AvgBaseline_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName +";time intverall;channel"; - fHM->Add(histName.Data(), new TProfile2D(histName, title,100,0,100*50000,fTimeBins,0,fTimeBins)); - fHM->P2(histName.Data())->SetMinimum(-260.); - fHM->P2(histName.Data())->SetMaximum(-200.); - - histName = "Running_Baseline_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";TimeCounter;baseline"; - fHM->Add(histName.Data(), new TH2F(histName, title,50000,0,50000,100,-300,-200)); - - histName = "Noise_Shape_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName +";bin;ADC"; - fHM->Add(histName.Data(), new TH2F(histName, title,fTimeBins,0,fTimeBins,60,-260,-200)); - - // signals - channel by channel - for(Int_t channel = 0; channel < fTimeBins; channel++) { - histName = "Noise_Shape_" + syscoreName[syscore] + "_" + spadicName[spadic] + "_Ch" + channelName[channel]; - title = histName + ";Time Bin;ADC value"; - fHM->Add(histName.Data(), new TH2F(histName, title, fTimeBins, 0, fTimeBins, 60, -260, -200)); - } - - histName = "Noise_AvgAmplitude_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName +";channel;amplitude (ADC)"; - fHM->Add(histName.Data(), new TProfile(histName, title,fTimeBins,0,fTimeBins, "S")); - - histName = "NoiseCounter_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName +";Types;counts"; - fHM->Add(histName.Data(), new TH1F(histName, title,2,0,2)); - for (Int_t tType=0; tType < 2; tType++) - fHM->H1(histName.Data())->GetXaxis()->SetBinLabel(tType+1,EntryTypes[tType]); - - histName = "NoiseCounter_chID_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName +";Channel;Type"; - fHM->Add(histName.Data(), new TH2F(histName, title,fTimeBins,0,fTimeBins,2,0,2)); - for (Int_t tType=0; tType < 2; tType++) - fHM->H1(histName.Data())->GetYaxis()->SetBinLabel(tType+1,EntryTypes[tType]); - - histName = "NoiseCounter_TimeCounter_"+ syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName +";Timecounter;Noisecounter"; - fHM->Add(histName.Data(), new TH1F(histName, title,50000,0,50000)); - - // - - - histName = "ClusterSize_" + syscoreName[syscore] + "_" + spadicName[spadic]; //OK - title = histName + ";Cluster Size [Channel] ;Counts"; - fHM->Add(histName.Data(), new TH1F(histName, title, 10, -0.5, 9.5)); - - - histName = "Integrated_ADC_Spectrum_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";Channel;Integr. ADC values in Bin [1,31]"; - fHM->Add(histName.Data(), new TH2F(histName, title, fTimeBins, 0, fTimeBins, 2000, -500, 1500)); - - //good signals - histName = "AvgAdcMax_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";Channel;MaxValue in ADC"; - fHM->Add(histName.Data(), new TProfile(histName, title, fTimeBins, 0, fTimeBins)); - - histName = "AvgAdcMax_self_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";Channel;MaxValue in ADC"; - fHM->Add(histName.Data(), new TProfile(histName, title, fTimeBins, 0, fTimeBins)); - - histName = "AvgAdcMax_neighbour_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";Channel;MaxValue in ADC"; - fHM->Add(histName.Data(), new TProfile(histName, title, fTimeBins, 0, fTimeBins)); - - // signals - channel by channel - for(Int_t channel = 0; channel < fTimeBins; channel++) { - histName = "Signal_Shape_" + syscoreName[syscore] + "_" + spadicName[spadic] + "_Ch" + channelName[channel]; - title = histName + ";Time Bin;ADC value"; - fHM->Add(histName.Data(), new TH2F(histName, title, fTimeBins, 0, fTimeBins, 511, -256, 255)); - - histName = "AvgSignal_Shape_" + syscoreName[syscore] + "_" + spadicName[spadic] + "_Ch" + channelName[channel]; - title = histName + ";Time Bin;<ADC value>"; - fHM->Add(histName.Data(), new TProfile(histName, title, fTimeBins, 0, fTimeBins)); - - histName = "Signal_Shape_self_" + syscoreName[syscore] + "_" + spadicName[spadic] + "_Ch" + channelName[channel]; - title = histName + ";Time Bin;ADC value"; - fHM->Add(histName.Data(), new TH2F(histName, title, fTimeBins, 0, fTimeBins, 511, -256, 255)); - - histName = "AvgSignal_Shape_self_" + syscoreName[syscore] + "_" + spadicName[spadic] + "_Ch" + channelName[channel]; - title = histName + ";Time Bin;<ADC value>"; - fHM->Add(histName.Data(), new TProfile(histName, title, fTimeBins, 0, fTimeBins)); - - histName = "Signal_Shape_neighbour_" + syscoreName[syscore] + "_" + spadicName[spadic] + "_Ch" + channelName[channel]; - title = histName + ";Time Bin;ADC value"; - fHM->Add(histName.Data(), new TH2F(histName, title, fTimeBins, 0, fTimeBins, 511, -256, 255)); - - histName = "AvgSignal_Shape_neighbour_" + syscoreName[syscore] + "_" + spadicName[spadic] + "_Ch" + channelName[channel]; - title = histName + ";Time Bin;<ADC value>"; - fHM->Add(histName.Data(), new TProfile(histName, title, fTimeBins, 0, fTimeBins)); - } - - // signals - ingegrated - histName = "AdcInt_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";ADCIntegral; Counts"; - fHM->Add(histName.Data(), new TH1F(histName, title, 1825, 0, 1825)); - - histName = "AvgAdcInt_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";Channel;AvgIntegr. ADC values"; - fHM->Add(histName.Data(), new TProfile(histName, title, fTimeBins, 0, fTimeBins,"S")); - - histName = "AvgAdcInt_self_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";Channel;AvgIntegr. ADC values"; - fHM->Add(histName.Data(), new TProfile(histName, title, fTimeBins, 0, fTimeBins,"S")); - - histName = "AvgAdcInt_neighbour_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";Channel;AvgIntegr. ADC values"; - fHM->Add(histName.Data(), new TProfile(histName, title, fTimeBins, 0, fTimeBins,"S")); - - // integrated signals - channel by channel - for(Int_t channel = 0; channel < fTimeBins; channel++) { - histName = "AdcInt_" + syscoreName[syscore] + "_" + spadicName[spadic]+ "_Ch" + channelName[channel]; - title = histName + ";ADCIntegral; Counts"; - fHM->Add(histName.Data(), new TH1F(histName, title, 1825, 0, 1825)); - - histName = "AdcInt_self_" + syscoreName[syscore] + "_" + spadicName[spadic]+ "_Ch" + channelName[channel]; - title = histName + ";ADCIntegral; Counts"; - fHM->Add(histName.Data(), new TH1F(histName, title, 1825, 0, 1825)); - - histName = "AdcInt_neighbour_" + syscoreName[syscore] + "_" + spadicName[spadic]+ "_Ch" + channelName[channel]; - title = histName + ";ADCIntegral; Counts"; - fHM->Add(histName.Data(), new TH1F(histName, title, 1825, 0, 1825)); - } - - /// OBSOLETE - - histName = "Trigger_Heatmap_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";sum;Int Counter"; - //fHM->Add(histName.Data(), new TH1F(histName, title, 16, 0, 16, 2, 0, 2)); - - // for(Int_t channel = 0; channel < fTimeBins; channel++) { - // histName = "Pulse_" + syscoreName[syscore] + "_" + spadicName[spadic] + "_Ch" + channelName[channel]; - // title = histName + ";Time Bin;ADC value"; - // fHM->Add(histName.Data(), new TH1F(histName, title, fTimeBins, 0, fTimeBins)); - // } - - // Cluster - histName = "Clustersize_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";Clustersize;Counts"; - fHM->Add(histName.Data(), new TH1F(histName, title, 10,0,10)); - - histName = "Cluster_Types_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName +";Types;counts"; - fHM->Add(histName.Data(), new TH1F(histName, title,5,0,5)); - for (Int_t tType=0; tType < 5; tType++) - fHM->H1(histName.Data())->GetXaxis()->SetBinLabel(tType+1,cluster_names[tType]); - - // histName = "Cluster_Charge_" + syscoreName[syscore] + "_" + spadicName[spadic]; - // title = histName +";timebin;Integral"; - // fHM->Add(histName.Data(), new TH2F(histName, title,fTimeBins,0,fTimeBins,2000,0,2000)); - - histName = "Cluster_Charge_" + syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";Integral;Counts"; - fHM->Add(histName.Data(), new TH1F(histName, title,500,0,5000)); - - histName = "ClusterIntegral_shape_" + syscoreName[syscore] + "_" + spadicName[spadic]; //?? - title = histName +";timebin;Integral"; - fHM->Add(histName.Data(), new TH2F(histName, title,fTimeBins,0,fTimeBins,600,0,600)); - - // PRF - histName = "PRF_AdcInt_"+ syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";d;Qi/Qi-1*Qi*Qi+1"; - fHM->Add(histName.Data(), new TH2F(histName, title,300,-15,15,100,0,1)); - - histName = "AvgPRF_AdcInt_"+ syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";d;<Qi/Qi-1*Qi*Qi+1>"; - fHM->Add(histName.Data(), new TProfile(histName, title,300,-15,15,"S")); - - histName = "PRF_AdcAmpl_"+ syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";d (mm);Qi/Qi-1*Qi*Qi+1"; - fHM->Add(histName.Data(), new TH2F(histName, title,300,-15,15,100,0,1)); - - histName = "AvgPRF_AdcAmpl_"+ syscoreName[syscore] + "_" + spadicName[spadic]; - title = histName + ";d (mm);<Qi/Qi-1*Qi*Qi+1>"; - fHM->Add(histName.Data(), new TProfile(histName, title,300,-15,15,"S")); - - } - } -} - -TString CbmTrdTestBeamAnalysis::GetSysCore(Int_t eqID) -{ - TString syscore=""; - // Int_t SysId=-1; - switch (eqID) { - case kFlesMuenster: // Muenster - syscore="SysCore0_"; - //SysId = 0; - break; - case kFlesFrankfurt: // Frankfurt - syscore="SysCore1_"; - //SysId = 1; - break; - case kFlesBucarest: // Bucarest - syscore="SysCore2_"; - //SysId = 2; - break; - default: - LOG(error) << "EquipmentID " << eqID << "not known."; - break; - } - return syscore; -} - -Int_t CbmTrdTestBeamAnalysis::GetSysCoreID(Int_t eqID) -{ - //TString syscore=""; - Int_t SysId=-1; - switch (eqID) { - case kFlesMuenster: // Muenster - //syscore="SysCore0_"; - SysId = 0; - break; - case kFlesFrankfurt: // Frankfurt - //syscore="SysCore1_"; - SysId = 1; - break; - case kFlesBucarest: // Bucarest - //syscore="SysCore2_"; - SysId = 2; - break; - default: - LOG(error) << "EquipmentID " << eqID << "not known."; - break; - } - return SysId; -} - -TString CbmTrdTestBeamAnalysis::GetSpadic(Int_t sourceA) -{ - TString spadic=""; - //Int_t SpaId = -1; - switch (sourceA) { - case (SpadicBaseAddress+0): // first spadic - spadic="Spadic0"; - //SpaId = 0; - break; - case (SpadicBaseAddress+1): // first spadic - spadic="Spadic0"; - //SpaId = 1; - break; - case (SpadicBaseAddress+2): // second spadic - spadic="Spadic1"; - //SpaId = 2; - break; - case (SpadicBaseAddress+3): // second spadic - spadic="Spadic1"; - //SpaId = 3; - break; - case (SpadicBaseAddress+4): // third spadic - spadic="Spadic2"; - //SpaId = 4; - break; - case (SpadicBaseAddress+5): // third spadic - spadic="Spadic2"; - //SpaId = 5; - break; - default: - LOG(error) << "Source Address " << sourceA << "not known."; - break; - } - return spadic; -} - -Int_t CbmTrdTestBeamAnalysis::GetSpadicID(Int_t sourceA) -{ - //TString spadic=""; - Int_t SpaId = -1; - switch (sourceA) { - case (SpadicBaseAddress+0): // first spadic - //spadic="Spadic0"; - SpaId = 0; - break; - case (SpadicBaseAddress+1): // first spadic - //spadic="Spadic0"; - SpaId = 1; - break; - case (SpadicBaseAddress+2): // second spadic - //spadic="Spadic1"; - SpaId = 2; - break; - case (SpadicBaseAddress+3): // second spadic - //spadic="Spadic1"; - SpaId = 3; - break; - case (SpadicBaseAddress+4): // third spadic - //spadic="Spadic2"; - SpaId = 4; - break; - case (SpadicBaseAddress+5): // third spadic - //spadic="Spadic2"; - SpaId = 5; - break; - default: - LOG(error) << "Source Address " << sourceA << "not known."; - break; - } - return SpaId; -} diff --git a/beamtime/trd/lib/CbmTrdTestBeamAnalysis.h b/beamtime/trd/lib/CbmTrdTestBeamAnalysis.h deleted file mode 100644 index d9cf3acd8f740c9db15fe1564f7cd49132088a3e..0000000000000000000000000000000000000000 --- a/beamtime/trd/lib/CbmTrdTestBeamAnalysis.h +++ /dev/null @@ -1,98 +0,0 @@ -#ifndef CBMTRDTESTBEAMANALYSIS_H -#define CBMTRDTESTBEAMANALYSIS_H - -#include "FairTask.h" - -#include "CbmHistManager.h" - -#include "TClonesArray.h" -#include "TNtuple.h" - -class CbmTrdTestBeamAnalysis : public FairTask -{ - public: - - enum EBaseMetod { kFirstTimeBin=0, kLastTimeBins, kNoise }; - - /** Default constructor **/ - CbmTrdTestBeamAnalysis(); - - /** Constructor with parameters (Optional) **/ - // CbmTrdTestBeamAnalysis(Int_t verbose); - - - /** Destructor **/ - ~CbmTrdTestBeamAnalysis(); - - - /** Initiliazation of task at the beginning of a run **/ - virtual InitStatus Init(); - - /** ReInitiliazation of task when the runID changes **/ - virtual InitStatus ReInit(); - - - /** Executed for each event. **/ - virtual void Exec(Option_t* opt); - - /** Load the parameter container from the runtime database **/ - virtual void SetParContainers(); - - /** Finish task called at the end of the run **/ - virtual void Finish(); - - /** Setter **/ - void SetTimeBins(Int_t nbins) { fTimeBins = nbins; } - - /** Selections **/ - void SetSysCoreSelection(Int_t detID) { fSysCore=detID; } - void SetSpadicSelection( Int_t spadic) { fSpadic=spadic; } - - /** Baseline method **/ - void SetBaselineMethod( EBaseMetod method, Int_t nbins=1) { fBaseMethod=method; fBaselineBins=nbins; } - - private: - - Int_t fTimeBins; - - TString GetSysCore(Int_t eqID); - Int_t GetSysCoreID(Int_t eqID); - - TString GetSpadic(Int_t sourceA); - Int_t GetSpadicID(Int_t sourceA); - - /** Input array from previous already existing data level **/ - TClonesArray* fRawSpadic; - - CbmHistManager* fHM; - - // syscore and spadic - Int_t fSysCore; - Int_t fSpadic; - - // timecounter - Int_t fTimeCounter; - - //Baseline - EBaseMetod fBaseMethod; // base line method - Int_t fBaselineBins; // bins used for baseline calculation - Int_t fBaseline[32]; // base line values - - // Noise Counter - Int_t fNoiseCounter; - - // ntuple for timecounting - TNtuple *fNT; - - /** Output array to new data level**/ - // TClonesArray* <OutputDataLevel>; - - void CreateHistograms(); - - CbmTrdTestBeamAnalysis(const CbmTrdTestBeamAnalysis&); - CbmTrdTestBeamAnalysis operator=(const CbmTrdTestBeamAnalysis&); - - ClassDef(CbmTrdTestBeamAnalysis,1); -}; - -#endif diff --git a/beamtime/trd/lib/CbmTrdTestBeamAnalysis2015SPS.cxx b/beamtime/trd/lib/CbmTrdTestBeamAnalysis2015SPS.cxx deleted file mode 100644 index 7d5231da9598554b357d2f34fef4daf87d95e90a..0000000000000000000000000000000000000000 --- a/beamtime/trd/lib/CbmTrdTestBeamAnalysis2015SPS.cxx +++ /dev/null @@ -1,1046 +0,0 @@ -#include "CbmTrdTestBeamAnalysis2015SPS.h" -#include "CbmSpadicRawMessage.h" -#include "CbmHistManager.h" -#include "CbmBeamDefaults.h" - -#include "FairLogger.h" -#include "TCanvas.h" -#include "TH1.h" -#include "TH2.h" -#include "TH3.h" -#include "TNtuple.h" -#include "TString.h" -#include "TMath.h" -#include <cmath> -#include <map> -#include <vector> -#include <iostream> -// ---- ------------------------------------------------------- -CbmTrdTestBeamAnalysis2015SPS::CbmTrdTestBeamAnalysis2015SPS() - : FairTask("CbmTrdTestBeamAnalysis2015SPS"), - fTimeBins(32), - fRun(0), - fSpadics(0), - fRewriteSpadicName(false), - fPlotSignalShape(true), - fPlotClusterFinder(true), - fRawSpadic(NULL), - fHM(new CbmHistManager()), - fTimeCounter(0), - fBaseMethod(kLastTimeBins), - fBaselineBins(1), - fBaseline(), - fNoiseCounter(0), - fNrTimeSlices(0), - fTimeMax(0), - fTimeMin(0) - //fNT(0x0) - //*/ -{ - LOG(debug) << "Default constructor of CbmTrdTestBeamAnalysis2015SPS"; -} -// ---- ------------------------------------------------------- -CbmTrdTestBeamAnalysis2015SPS::~CbmTrdTestBeamAnalysis2015SPS() -{ - LOG(debug) << "Destructor of CbmTrdTestBeamAnalysis2015SPS"; -} -// ---- ------------------------------------------------------- -void CbmTrdTestBeamAnalysis2015SPS::SetParContainers() -{ - LOG(debug) << "SetParContainers of CbmTrdTestBeamAnalysis2015SPS"; -} -// ---- ------------------------------------------------------- -InitStatus CbmTrdTestBeamAnalysis2015SPS::Init() -{ - LOG(debug) << "Initilization of CbmTrdTestBeamAnalysis2015SPS"; - FairRootManager* ioman = FairRootManager::Instance(); - fRawSpadic = static_cast<TClonesArray*>(ioman->GetObject("SpadicRawMessage")); - if ( !fRawSpadic ) { - LOG(fatal) << "No InputDataLevelName array!\n CbmTrdTestBeamAnalysis2015SPS will be inactive"; - return kERROR; - } - CreateHistograms(); - return kSUCCESS; -} -// ---- ReInit ------------------------------------------------------- -InitStatus CbmTrdTestBeamAnalysis2015SPS::ReInit() -{ - LOG(debug) << "Initilization of CbmTrdTestBeamAnalysis2015SPS"; - return kSUCCESS; -} -// ---- Exec ------------------------------------------------------- -void CbmTrdTestBeamAnalysis2015SPS::Exec(Option_t* /*option*/) -{ - // Analysis based on single SPADIC data streams can be done here!!! - - - /*if(fNrTimeSlices==0){ - if(fHM->G1("TsCounter")->GetN()!=0){ - LOG(info) << "Expected empty TsCounter before first TimeSlice, but found " << fHM->G1("TsCounter")->GetN() << " entries."; - } - }*/ - - std::map<TString, std::map<ULong_t, std::vector<CbmSpadicRawMessage*> > > timeBuffer; - //LOG(error) << "CbmTrdTestBeamAnalysis2015SPS: Run: " << fRun << " / Number of current TimeSlice: " << fNrTimeSlices; - Int_t nSpadicMessages = fRawSpadic->GetEntriesFast();//SPADIC messages per TimeSlice - // Int_t nSpadicMessages0(0),nSpadicMessages1(0); //SPADIC messages per TimeSlice for single SPADICS - // Int_t nSpadicMessagesHit0(0), nSpadicMessagesHit1(0), nSpadicMessagesInfo0(0), nSpadicMessagesInfo1(0), nSpadicMessagesEpoch0(0), nSpadicMessagesEpoch1(0), nSpadicMessagesLost0(0), nSpadicMessagesLost1(0); // SPADIC message types per TimeSlice for single SPADICS - Bool_t isHit = false; - Bool_t isHitAborted = false; - Bool_t isOverflow = false; - Bool_t isInfo = false; - Bool_t isStrange = false; - Bool_t isEpoch = false; - - Int_t eqID(-1), sourceA(-1), chID(0), triggerType(-1), stopType(-1), infoType(-1), groupId(-1), sysID(-1), spaID(-1); - ULong_t time = 0; - Int_t timeStamp(0), epoch(0), superEpoch(0); - LOG(info) << "nSpadicMessages: " << nSpadicMessages; - - TString histName=""; - TString title=""; - - TString spadicName = ""; - - ULong_t lastSpadicTime[3][6] = {{0}}; //[sys][spa] - Int_t clusterSize[3][6] = {{1}}; - Int_t hitCounter[3][6]={{0}}; - - fNrTimeSlices++; - - for (Int_t iSpadicMessage=0; iSpadicMessage < nSpadicMessages; ++iSpadicMessage) { - // Get Message - CbmSpadicRawMessage* raw = static_cast<CbmSpadicRawMessage*>(fRawSpadic->At(iSpadicMessage)); - // Get Message propertys - isHit = raw->GetHit(); - isHitAborted = raw->GetHitAborted(); - isOverflow = raw->GetOverFlow(); - isInfo = raw->GetInfo(); - isStrange = raw->GetStrange(); - isEpoch = raw->GetEpoch(); - // Seriously guys, a message can only be of one type. - //if(Int_t(isHit+isInfo+isEpoch+isHitAborted+isOverflow+isStrange)!=1) LOG(error) << "SpadicMessage " << iSpadicMessage << " is classified from CbmSpadicRawMessage to be: HIT " << Int_t(isHit) << " / INFO " << (Int_t)isInfo << " / EPOCH " << (Int_t)isEpoch << " / HITaborted " << (Int_t)isHitAborted << " / OVERFLOW " << (Int_t)isOverflow << " / STRANGE " << (Int_t)isStrange; - - - - - // Get SysCore & Spadic propertys - eqID = raw->GetEquipmentID(); - sourceA = raw->GetSourceAddress(); - groupId=raw->GetGroupId(); - chID = raw->GetChannelID(); - sysID = GetSysCoreID(eqID); - spaID = GetSpadicID(sourceA); - if(spaID%2) chID+=16; // eqID ? - - Int_t nrSamples=raw->GetNrSamples(); - - time = raw->GetFullTime(); - - if(fTimeMax<time) fTimeMax = time; - - - timeStamp = raw->GetTime(); - - epoch = raw->GetEpochMarker();// is copied to each SpadicRawMessage by the unpacker not only epoch messages - superEpoch = raw->GetSuperEpoch();// is copied to each SpadicRawMessage by the unpacker not only epoch message - - triggerType=raw->GetTriggerType(); - stopType = raw->GetStopType(); - infoType=raw->GetInfoType(); - if (infoType > 6) { - LOG(error) << " InfoType " << infoType << "is larger 6, set to 7!"; - infoType = 7; - } - - //chID = GetChannelOnPadPlane(chID);// Remapping from ASIC to pad-plane channel numbers. - TString channelId=Form("_Ch%02d", chID); - - spadicName = GetSpadicName(eqID,sourceA); - - //Counter .. - - if(isHit) hitCounter[sysID][spaID]++; - - - - - TString stopTypes[6] = {"Normal end of message", - "Channel buffer full", - "Ordering FIFO full", - "Multi hit", - "Multi hit and channel buffer full", - "Multi hit and ordering FIFO full"}; - - TString infoTypes[8] = {"Channel disabled during message building", - "Next grant timeout", - "Next request timeout", - "New grant but channel empty", - "Corruption in message builder", - "Empty word", - "Epoch out of sync", - "infoType out of array"}; //not official type, just to monitor overflows - - //LOG(error) << " time " << time << " / timeStamp " << timeStamp; - - if(spadicName!="") { - - // - // DEBUG PLOTS - // - - fHM->H2("Debug_NrSamples_vs_StopType")->Fill(nrSamples, stopType); - - if(isStrange) fHM->H1("Debug_NrSamples_of_Strange_Messages")->Fill(nrSamples, 1); - - if(stopType>-1)fHM->H1("Debug_MessageCount")->Fill(TString(spadicName+"_"+stopTypes[stopType]),1); - if(infoType>-1) fHM->H1("Debug_MessageCount")->Fill(TString(spadicName+"_"+infoTypes[infoType]),1); - if(isOverflow) fHM->H1("Debug_MessageCount")->Fill(TString(spadicName+"_Overflow"),1); - if(isHitAborted) fHM->H1("Debug_MessageCount")->Fill(TString(spadicName+"_HitAborted"),1); - if(isStrange) fHM->H1("Debug_MessageCount")->Fill(TString(spadicName+"_Strange"),1); - - if(isHit) { - histName = spadicName + "_Time_vs_TimeSlice"; - //fHM->H2(histName.Data())->Fill(fNrTimeSlices,time); //timeStamp(0), epoch(0), superEpoch(0); - - histName = spadicName + "_TimeStamp_vs_TimeSlice"; - //fHM->H2(histName.Data())->Fill(fNrTimeSlices,timeStamp); //timeStamp(0), epoch(0), superEpoch(0); - - histName = spadicName + "_Epoch_vs_TimeSlice"; - //fHM->H2(histName.Data())->Fill(fNrTimeSlices,epoch); //timeStamp(0), epoch(0), superEpoch(0); - - histName = spadicName + "_SuperEpoch_vs_TimeSlice"; - //fHM->H2(histName.Data())->Fill(fNrTimeSlices,superEpoch); //timeStamp(0), epoch(0), superEpoch(0); - - - } - - // - // PHYSICS PLOTS - // - - - - if(isHit) { - - // Heat map - - - Int_t padID = GetChannelOnPadPlane(chID); - if(padID<16) { - fHM->H2(TString(spadicName + "_Heatmap").Data())->Fill(padID, 1); - }else{ - fHM->H2(TString(spadicName + "_Heatmap").Data())->Fill(padID-15, 2); - } - - - // Cluster finder - // add raw message to map sorted by timestamps, syscore and spadic - timeBuffer[TString(spadicName)][time].push_back(raw); - - if (time > lastSpadicTime[sysID][spaID]){ - // new hit - fHM->H1(TString(spadicName + "_SimpleClusterSize").Data())->Fill(clusterSize[sysID][2*spaID]); - fHM->H1(TString(spadicName + "_SimpleClusterSize").Data())->Fill(clusterSize[sysID][2*spaID+1]); - clusterSize[sysID][spaID] = 1; - } else if (time == lastSpadicTime[sysID][spaID]) { - if (stopType == 0){ - // normal ended hit - if (triggerType == 0) { // gobal dlm trigger - - } else if (triggerType == 1) { //Self triggered - // central pad candidate - clusterSize[sysID][spaID]+=1; - } else if (triggerType == 2) { //Neighbor triggered - // outer pad candidate - clusterSize[sysID][spaID]+=1; - } else { //Self and neighbor triggered - // central pad candidate - clusterSize[sysID][spaID]+=1; - } - } - } else { - // something went wrong - //LOG(error) << fNrTimeSlices << ": time travel occurred !!! (time < lastTime) time: " << time << " lastTime: " << lastSpadicTime[sysID][spaID]; - } - - } - - lastSpadicTime[sysID][spaID] = time; - - - if(isHit && stopType == 0 && fPlotSignalShape) { - Double_t adcInt = 0; - for (Int_t bin = 0; bin < nrSamples; bin++) { - Int_t adc = raw->GetSamples()[bin]; - adcInt += adc; - histName = spadicName + "_Signal_Shape" + channelId; - fHM->H2(histName.Data())->Fill(bin,adc); - histName = spadicName + "_AvgSignal_Shape" + channelId; - fHM->P1(histName.Data())->Fill(bin,adc); - if(triggerType==1) { - histName = spadicName + "_Signal_Shape_self" + channelId; - fHM->H2(histName.Data())->Fill(bin,adc); - histName = spadicName + "_AvgSignal_Shape_self" + channelId; - fHM->P1(histName.Data())->Fill(bin,adc); - }else if(triggerType==2){ - histName = spadicName + "_Signal_Shape_neighbour" + channelId; - fHM->H2(histName.Data())->Fill(bin,adc); - histName = spadicName + "_AvgSignal_Shape_neighbour" + channelId; - fHM->P1(histName.Data())->Fill(bin,adc); - } - } - } - - - } - - } - - // - // HitCounter - // - - /* - hitCounter[0][0][0]=1; - hitCounter[0][0][1]=2; - hitCounter[0][1][0]=3; - hitCounter[0][1][1]=4; - */ - - for(Int_t syscore = 0; syscore < 3; ++syscore) { - for(Int_t spadic = 0; spadic < 3; ++spadic) { - spadicName = RewriteSpadicName(Form("SysCore%01d_Spadic%01d", syscore, spadic)); - if(spadicName != "") { - histName = spadicName + "_Hits_per_TimeSlice_Ch00-15"; - //fHM->G1(histName.Data())->SetPoint(fHM->G1(histName.Data())->GetN(),fNrTimeSlices,hitCounter[syscore][2*spadic]); - histName = spadicName + "_Hits_per_TimeSlice_Ch16-31"; - //fHM->G1(histName.Data())->SetPoint(fHM->G1(histName.Data())->GetN(),fNrTimeSlices,hitCounter[syscore][2*spadic+1]); - - //LOG(error) << spadicName << " A: " << hitCounter[syscore][2*spadic] << " B: " << hitCounter[syscore][2*spadic+1]; - } - } - } - - - - // - // Cluster finder - // - - // complicated loop over sorted map of timestamps - for(std::map<TString, std::map<ULong_t, std::vector<CbmSpadicRawMessage*> > >::iterator it = timeBuffer.begin() ; it != timeBuffer.end(); it++){ - - // complicated loop over sorted map of raw messages - for (std::map<ULong_t, std::vector<CbmSpadicRawMessage*> > ::iterator it2 = it->second.begin() ; it2 != it->second.end(); it2++) { - //LOG(info) << "ClusterSize:" << Int_t(it2->second.size()); - - Int_t Clustersize=Int_t(it2->second.size()); - // Int_t Integral_cluster[32]; // TODO: needed? - // Double_t clsAdcInt_Max=0; //TODO: needed? - // Int_t Integral_sum=0; //TODO: obsololete - Int_t clsType=0; // cluster trigger type identification - - // buffer for the whole clusters - Int_t clsChID[15]; // channel ID - Int_t clsTriggerInfo[15]; // trigger info - Double_t clsAdcInt[15]; // adc integral - Double_t clsAdcAmpl[15]; // max amplitude - Double_t clsStopType[15]; // stop type - Bool_t clsNoise[15]; // noisy channel - for(Int_t n=0;n<15;n++){ - clsChID[n]=0; - clsTriggerInfo[n]=0; - clsAdcInt[n]=0; - clsAdcAmpl[n]=0; - clsStopType[n]=0; - clsNoise[n]=kTRUE; - } - // for(Int_t i=0;i<nrSamples;i++) Integral_cluster[i]=0; - - - // loop over all pads in the cluster - for (Int_t iPad = 0; iPad < Clustersize; iPad++){ - CbmSpadicRawMessage* raw = static_cast<CbmSpadicRawMessage*>(it2->second.at(iPad)); - eqID = raw->GetEquipmentID(); - sourceA = raw->GetSourceAddress(); - chID = raw->GetChannelID(); - Int_t nrSamples=raw->GetNrSamples(); - triggerType=raw->GetTriggerType(); - stopType=raw->GetStopType(); - infoType=raw->GetInfoType(); - - spadicName = GetSpadicName(eqID,sourceA); - - if (infoType > 6) infoType = 7; - // Int_t groupId=raw->GetGroupId(); - // ULong_t time = raw->GetFullTime(); - - spaID = GetSpadicID(sourceA); - if(spaID%2) chID+=16; - TString channelId=Form("_Ch%02d", chID); - - // fill cluster histograms - if(!iPad) { - histName = spadicName + "_ClusterSize"; - fHM->H1(histName.Data())->Fill(Clustersize,1.); - } - - // continue only with normal ending messages - // if(stopType) continue; //TODO:what about clustersize - - ///// Noise events - Int_t hlfSamples = TMath::CeilNint(nrSamples/2); - Int_t adcTolerance = 2; - Int_t max1[45]={0}; - Int_t max2[45]={0}; - for(Int_t i=0;i<45;i++) { max1[i]=0; max2[i]=0;} - for(Int_t bin=0; bin < hlfSamples;bin++){ - max1[bin]= raw->GetSamples()[bin]; - max2[bin]= raw->GetSamples()[bin+hlfSamples]; - } - Bool_t isNoise=(TMath::MaxElement(hlfSamples,max1)-TMath::MaxElement(hlfSamples,max2))<adcTolerance; - if(isNoise && !stopType) { - // LOG(info) << "Noisy channel found "; - fNoiseCounter++; - Int_t max =-300; - Int_t min =-100; - Float_t middle=0; - Int_t minbin =0; - Int_t maxbin =0; - - // find max and min adc values in noise events - for(Int_t i=0;i<10;i++){ - Int_t adc=raw->GetSamples()[nrSamples-1-i]; - if(adc>max){ - max = adc; - maxbin = nrSamples-1-i; - } - // adc=raw->GetSamples()[i]; - if(adc<min){ - min = adc; - minbin = i; - } - } - // calculate mean noise adc value - for(Int_t bin=minbin;bin<=maxbin;bin++) middle+=raw->GetSamples()[bin]; - middle /= (maxbin-minbin); - - // noise amplitude - // Int_t ampl = max-min; - - // fill noise histograms - histName = "Noise_AvgBaseline" ; - //fHM->P1(histName.Data())->Fill(chID,middle); - - histName = "Running_Baseline" ; - //fHM->H2(histName.Data())->Fill(fTimeCounter,middle,chID); - - histName = "Running_AvgBaseline" ; - //fHM->P2(histName.Data())->Fill(fTimeCounter,chID,middle); - - histName = "Noise_Shape" ; - for(Int_t bin = 0; bin < nrSamples; bin++) { - // Int_t adc=raw->GetSamples()[bin]; - //fHM->H2(histName.Data())->Fill(bin,adc); - //fHM->H2((histName+channelId).Data())->Fill(bin,adc); - } - - histName = "Noise_AvgAmplitude" ; - //fHM->P1(histName.Data())->Fill(chID,ampl); - } - - // fill noise counter - histName = "NoiseCounter" ; - //fHM->H1(histName.Data())->Fill(isNoise); - - histName = "NoiseCounter_chID" ; - //fHM->H2(histName.Data())->Fill(chID,isNoise); - - histName = "NoiseCounter_TimeCounter" ; - //fHM->H1(histName.Data())->SetBinContent(fTimeCounter,fNoiseCounter); - - - // buffer channel/pad information for cluster contributor - clsChID[iPad] = chID; - clsTriggerInfo[iPad] = triggerType; - clsStopType[iPad] = stopType; - - // clustertypes TODO: needed? - switch(triggerType) { - case 0: clsType-=1000; break; // global - case 1: clsType+=1; break; // self - case 2: clsType+=10; break; // neighbour - case 3: clsType+=100; break; // self+neighbour - default: Printf("trigger type %d is not defined for channel %d",triggerType,chID); - } - - - - // calculate baseline based on method - switch(fBaseMethod) { - case kFirstTimeBin: fBaseline[chID] = raw->GetSamples()[0]; - break; - case kLastTimeBins: - { - Float_t base=0.; - // sum up last time bins and normalize - for(Int_t i=0;i<fBaselineBins;i++) base+=raw->GetSamples()[nrSamples-1-i]; - fBaseline[chID] = static_cast<Int_t>(base/fBaselineBins); - break; - } - case kNoise: - { - histName = "Running_AvgBaseline"; - //Int_t bin = fHM->P2(histName.Data())->FindBin(fTimeCounter,chID); - //fBaseline[chID]=fHM->P2(histName.Data())->GetBinContent(bin); - break; - } - } - - - - // fill baseline histograms - histName = "BaseLine" ; - //fHM->H2(histName.Data())->Fill(chID,fBaseline[chID]); - - histName = "AvgBaseline" ; - //fHM->P1(histName.Data())->Fill(chID,fBaseline[chID]); - - // cleaned single channel signals - // these signals could belong to incomplete clusters - if( !isNoise && fBaseline[chID]!=0 && !stopType) { - - Int_t maxAdc=0; - Int_t maxAdc_self=0; - Int_t maxAdc_neighbour=0; - Float_t intAdc = 0; - Float_t intAdc_self = 0; - Float_t intAdc_neighbour = 0; - - // loop over all timebins - for (Int_t bin = 0; bin < nrSamples; bin++) { - - // TODO: check if really needed - if(raw->GetSamples()[0]>=-100 || raw->GetSamples()[1]>=-100) continue; - - // apply baseline correction - Int_t adc = raw->GetSamples()[bin] - fBaseline[chID]; - - // summations - intAdc += adc; - if(triggerType==1) intAdc_self += adc; - else if(triggerType==2) intAdc_neighbour += adc; - // Integral_cluster[bin] += adc; - - // find maximum adc values - if(adc>maxAdc) maxAdc = adc; - if(triggerType==1 && adc>maxAdc_self) maxAdc_self = adc; - if(triggerType==2 && adc>maxAdc_neighbour) maxAdc_neighbour = adc; - - // signal shape histograms - histName = "Signal_Shape" + channelId; - //fHM->H2(histName.Data())->Fill(bin,adc); - - histName = "AvgSignal_Shape" + channelId; - //fHM->P1(histName.Data())->Fill(bin,adc); - - if(triggerType==1) { - histName = "Signal_Shape_self" + channelId; - //fHM->H2(histName.Data())->Fill(bin,adc); - - histName = "AvgSignal_Shape_self" + channelId; - //fHM->P1(histName.Data())->Fill(bin,adc); - } - else if(triggerType==2){ - histName = "Signal_Shape_neighbour" + channelId; - //fHM->H2(histName.Data())->Fill(bin,adc); - - histName = "AvgSignal_Shape_neighbour" + channelId; - //fHM->P1(histName.Data())->Fill(bin,adc); - } - - }//end time bin loop - - // fill max adc values - histName = "AvgAdcMax" ; - //fHM->P1(histName.Data())->Fill(chID, maxAdc); - - histName = "AvgAdcMax_self" ; - //fHM->P1(histName.Data())->Fill(chID, maxAdc_self); - - histName = "AvgAdcMax_neighbour" ; - //fHM->P1(histName.Data())->Fill(chID, maxAdc_neighbour); - - // fill integrated spectra - histName = "AdcInt" ; - //fHM->H1(histName.Data())->Fill(intAdc); - - histName = "AvgAdcInt" ; - //fHM->P1(histName.Data())->Fill(chID, intAdc); - - histName = "AvgAdcInt_self" ; - //if(triggerType==1) fHM->P1(histName.Data())->Fill(chID, intAdc_self); - - histName = "AvgAdcInt_neighbour" ; - //if(triggerType==2) fHM->P1(histName.Data())->Fill(chID, intAdc_neighbour); - - // integrated spectra - channel by channel - histName = "AdcInt" + channelId; - //fHM->H1(histName.Data())->Fill(intAdc,1.); - - histName = "AdcInt_self" + channelId; - //if(triggerType==1) fHM->H1(histName.Data())->Fill(intAdc_self,1.); - - histName = "AdcInt_neighbour" + channelId; - //if(triggerType==2)fHM->H1(histName.Data())->Fill(intAdc_neighbour,1.); - - // fill buffer - clsAdcInt[iPad] = intAdc; - clsAdcAmpl[iPad] = maxAdc; - clsNoise[iPad] = kFALSE; - }//end good signal selection - - // 'good' cluster selection - // enter only when last channel is reached - // make use of buffered values - if(iPad==Clustersize-1) { - - // fill cluster types (based on trigger types of its pads) - histName=spadicName + "_Cluster_Types" ; - if( clsType==21) fHM->H1(histName.Data())->Fill(2); - else if(clsType<4) fHM->H1(histName.Data())->Fill(1); - else if(clsType==220) fHM->H1(histName.Data())->Fill(3); - else if(!(clsType%10)) fHM->H1(histName.Data())->Fill(0); - else fHM->H1(histName.Data())->Fill(4); - - // only use full size clusters size==3||4 - if( Clustersize>=3 && Clustersize<=4) { - // remove full cluster if a stop type is != 'normal ending' - if(!clsStopType[0] && !clsStopType[1] && !clsStopType[2] && !clsStopType[iPad]) { - // remove full cluster if a noisy pad is found - if(!clsNoise[0] && !clsNoise[1] && !clsNoise[2] && !clsNoise[iPad]) { - // remove full cluster if channel 0 has fired - if(clsChID[0]!=0 && clsChID[1]!=0 && clsChID[2]!=0 && clsChID[iPad]!=0) { - // remove full cluster if negative adcInt for single pad - if(clsAdcInt[0]>0 && clsAdcInt[1]>0 && clsAdcInt[2]>0 && clsAdcInt[iPad]>0) { - - - // cluster charge - Int_t clsAdcInt_sum=0; - for(Int_t i=0;i<Clustersize;i++) clsAdcInt_sum += clsAdcInt[i]; - histName = spadicName + "_Cluster_Charge"; - fHM->H1(histName.Data())->Fill(clsAdcInt_sum); - - // cluster max amplitude - Int_t clsAdcAmpl_max=0; - for(Int_t i=0;i<Clustersize;i++) clsAdcAmpl_max += clsAdcAmpl[i]; - - // Pad Response Function - PRF - // TODO: add sorting, currently we assume padIdx=1 = self triggered pad - Double_t w = 6.75; // pad width - if(Clustersize==3) { - for(Int_t i=0;i<Clustersize;i++) { - - // PRF using ADC integrals - // shift by one pad width in case of neighbours - Double_t d = (w/2) * (TMath::Log(clsAdcInt[2]/clsAdcInt[0]) / TMath::Log(clsAdcInt[1]*clsAdcInt[1] / (clsAdcInt[2]*clsAdcInt[0])) ) - (w*(i-1)); - Double_t q = clsAdcInt[i] / clsAdcInt_sum; - - // fill pad response histograms - histName = "PRF_AdcInt" ; - //fHM->H2(histName.Data())->Fill(d,q); - - histName = "AvgPRF_AdcInt" ; - //fHM->P1(histName.Data())->Fill(d,q); - - // PRF using ADC maxima - d = (w/2) * (TMath::Log(clsAdcAmpl[2]/clsAdcAmpl[0]) / TMath::Log(clsAdcAmpl[1]*clsAdcAmpl[1] / (clsAdcAmpl[2]*clsAdcAmpl[0])) ) - (w*(i-1)); - q = clsAdcAmpl[i] / clsAdcAmpl_max; - - // fill pad response histograms - histName = "PRF_AdcAmpl" ; - //fHM->H2(histName.Data())->Fill(d,q); - - histName = "AvgPRF_AdcAmpl" ; - //fHM->P1(histName.Data())->Fill(d,q); - - } - } //cluster size - } // adc integral negative - } // bad channel removal - } // noise pad check - } //stop type check - } // cluster size check - } // last pad of cluster - - - - // if(iPad==Clustersize-1 && fBaseline[chID]!=0 && chID!=0 && chID!=30){ - // if((cluster_histo==0) && (clsType==21 || clsType==220)){ - // for(Int_t k=0;k< Clustersize;k++){ - // histName = "Clusterization_"; - // time count: channelID : triggertype - // fNT->Fill(fTimeCounter,clsChID[k],clsTriggerInfo[k]); - // } - - //*/ - - } //end cluster loop - - - - // increment time counter - fTimeCounter++; - - - } //end timestamp loop - - - - } //end Syscore/spadic loop - -} -// ---- Finish ------------------------------------------------------- -void CbmTrdTestBeamAnalysis2015SPS::Finish() -{ - - //Buffer (map) or multi SPADIC data streams based analyis have to be done here!! - LOG(debug) << "Finish of CbmTrdTestBeamAnalysis2015SPS"; - LOG(info) << "Write histo list to " << FairRootManager::Instance()->GetOutFile()->GetName(); - LOG(error) << "fNrTimeSlices: " << fNrTimeSlices; - LOG(error) << "fTimeMax: " << fTimeMax; - FairRootManager::Instance()->GetOutFile()->cd(); - fHM->WriteToFile(); - //delete c1; -} -// ---- FinishEvent ------------------------------------------------------- -void CbmTrdTestBeamAnalysis2015SPS::FinishEvent() -{ - LOG(debug) << "FinishEvent of CbmTrdTestBeamAnalysis2015SPS"; -} -// ---- ------------------------------------------------------- -void CbmTrdTestBeamAnalysis2015SPS::CreateHistograms() -{ - - // Only Spadic0 and Spadic1 on Syscore0 where used - - - TString channelName[32] = { "00", "01", "02", "03", "04", "05", "06", "07", "08", "09", - "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", - "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", - "30", "31"}; - - /* - TString triggerTypes[4] = { "Global trigger", - "Self triggered", - "Neighbor triggered", - "Self and neighbor triggered"}; - */ - TString stopTypes[6] = {"Normal end of message", - "Channel buffer full", - "Ordering FIFO full", - "Multi hit", - "Multi hit and channel buffer full", - "Multi hit and ordering FIFO full"}; - TString infoTypes[8] = {"Channel disabled during message building", - "Next grant timeout", - "Next request timeout", - "New grant but channel empty", - "Corruption in message builder", - "Empty word", - "Epoch out of sync", - "infoType out of array"}; //not official type, just to monitor overflows - - TString cluster_names[5]={"only self", - "only FN", - "One self and two FN", - "Two both and two FN", - "Others"}; - - TString spadicName=""; - TString histName=""; - TString runName=""; - if(0 != fRun) runName=Form(" (Run %d)",fRun); - TString title=""; - - fSpadics = 0; - - for(Int_t syscore = 0; syscore < 3; ++syscore) { - for(Int_t spadic = 0; spadic < 3; ++spadic) { - spadicName = RewriteSpadicName(Form("SysCore%01d_Spadic%01d", syscore, spadic)); - if(spadicName!="") fSpadics++; - } - } - - // - // DEBUG PLOTS - // - - fHM->Add("Debug_NrSamples_vs_StopType", new TH2I("Debug_NrSamples_vs_StopType","Debug_NrSamples_vs_StopType",34,-1.5,32.5,7,-1.5,5.5)); - fHM->H2("Debug_NrSamples_vs_StopType")->GetXaxis()->SetTitle("Nr. of Samples per Message"); - fHM->H2("Debug_NrSamples_vs_StopType")->GetYaxis()->SetTitle("StopType"); - - fHM->Add("Debug_NrSamples_of_Strange_Messages", new TH1D("Debug_NrSamples_of_Strange_Messages","Debug_NrSamples_of_Strange_Messages",32,0,32)); - fHM->H1("Debug_NrSamples_of_Strange_Messages")->GetXaxis()->SetTitle("Nr. of Samples"); - fHM->H1("Debug_NrSamples_of_Strange_Messages")->GetYaxis()->SetTitle("Count"); - - fHM->Add("Debug_MessageCount", new TH1D("Debug_MessageCount","Debug_MessageCount",fSpadics*17,0,fSpadics*17)); - Int_t n = 0; - for(Int_t syscore = 0; syscore < 3; ++syscore) { - for(Int_t spadic = 0; spadic < 3; ++spadic) { - spadicName = RewriteSpadicName(Form("SysCore%01d_Spadic%01d", syscore, spadic)); - if(spadicName != "") { - for(Int_t stopType = 0; stopType < 6; ++stopType) { - n++; - fHM->H1("Debug_MessageCount")->GetXaxis()->SetBinLabel(n,TString(spadicName+"_"+stopTypes[stopType])); - } - for(Int_t infoType = 0; infoType < 8; ++infoType) { - n++; - fHM->H1("Debug_MessageCount")->GetXaxis()->SetBinLabel(n,TString(spadicName+"_"+infoTypes[infoType])); - } - n++; - fHM->H1("Debug_MessageCount")->GetXaxis()->SetBinLabel(n,TString(spadicName+"_Overflow")); - n++; - fHM->H1("Debug_MessageCount")->GetXaxis()->SetBinLabel(n,TString(spadicName+"_HitAborted")); - n++; - fHM->H1("Debug_MessageCount")->GetXaxis()->SetBinLabel(n,TString(spadicName+"_Strange")); - } - } - } - - for(Int_t syscore = 0; syscore < 3; ++syscore) { - for(Int_t spadic = 0; spadic < 3; ++spadic) { - spadicName = RewriteSpadicName(Form("SysCore%01d_Spadic%01d", syscore, spadic)); - if(spadicName != "") { - histName = spadicName + "_Time_vs_TimeSlice"; - title = histName + runName + ";TimeSlice;Time"; - //fHM->Add(histName.Data(), new TH2F(histName, title, 1000, 0, 5000, 9000, 0, 90000000000)); - histName = spadicName + "_TimeStamp_vs_TimeSlice"; - title = histName + runName + ";TimeSlice;TimeStamp"; - //fHM->Add(histName.Data(), new TH2F(histName, title, 5000, 0, 5000, 4096, 0, 4096)); - - histName = spadicName + "_Epoch_vs_TimeSlice"; - title = histName + runName + ";TimeSlice;Epoch"; - //fHM->Add(histName.Data(), new TH2F(histName, title, 5000, 0, 5000, 4096, 0, 4096)); - - histName = spadicName + "_SuperEpoch_vs_TimeSlice"; - title = histName + runName + ";TimeSlice;SuperEpoch"; - //fHM->Add(histName.Data(), new TH2F(histName, title, 5000, 0, 5000, 4096, 0, 4096)); - - histName = spadicName + "_Hits_per_TimeSlice_Ch00-15"; - title = histName + runName + ";TimeSlice;Hits"; - //fHM->Add(histName.Data(), new TGraph()); - //fHM->G1(histName.Data())->SetTitle(title); - - histName = spadicName + "_Hits_per_TimeSlice_Ch16-31"; - title = histName + runName + ";TimeSlice;Hits"; - //fHM->Add(histName.Data(), new TGraph()); - //fHM->G1(histName.Data())->SetTitle(title); - - histName = spadicName + "_SimpleClusterSize"; - title = histName + runName + ";Cluster Size [Channel] ;Counts"; - fHM->Add(histName.Data(), new TH1F(histName, title, 10, -0.5, 9.5)); - - histName = spadicName + "_ClusterSize"; - title = histName + runName + ";Cluster Size [Channel] ;Counts"; - fHM->Add(histName.Data(), new TH1F(histName, title, 10, -0.5, 9.5)); - } - } - } - - - // - // PHYSICS PLOTS - // - - - - for(Int_t syscore = 0; syscore < 3; ++syscore) { - for(Int_t spadic = 0; spadic < 3; ++spadic) { - spadicName = RewriteSpadicName(Form("SysCore%01d_Spadic%01d", syscore, spadic)); - if(spadicName != "") { - if(fPlotSignalShape) { - for(Int_t channel = 0; channel < fTimeBins; channel++) { - histName = spadicName + "_Signal_Shape_Ch" + channelName[channel]; - title = histName + runName + ";Time Bin;ADC value"; - fHM->Add(histName.Data(), new TH2F(histName, title, fTimeBins, 0, fTimeBins, 511, -256, 255)); - - histName = spadicName + "_AvgSignal_Shape_Ch" + channelName[channel]; - title = histName + runName + ";Time Bin;<ADC value>"; - fHM->Add(histName.Data(), new TProfile(histName, title, fTimeBins, 0, fTimeBins)); - - histName = spadicName + "_Signal_Shape_self_Ch" + channelName[channel]; - title = histName + runName + ";Time Bin;ADC value"; - fHM->Add(histName.Data(), new TH2F(histName, title, fTimeBins, 0, fTimeBins, 511, -256, 255)); - - histName = spadicName + "_AvgSignal_Shape_self_Ch" + channelName[channel]; - title = histName + runName + ";Time Bin;<ADC value>"; - fHM->Add(histName.Data(), new TProfile(histName, title, fTimeBins, 0, fTimeBins)); - - histName = spadicName + "_Signal_Shape_neighbour_Ch" + channelName[channel]; - title = histName + runName + ";Time Bin;ADC value"; - fHM->Add(histName.Data(), new TH2F(histName, title, fTimeBins, 0, fTimeBins, 511, -256, 255)); - - histName = spadicName + "_AvgSignal_Shape_neighbour_Ch" + channelName[channel]; - title = histName + runName + ";Time Bin;<ADC value>"; - fHM->Add(histName.Data(), new TProfile(histName, title, fTimeBins, 0, fTimeBins)); - } - } - - // Heatmap - - //new TH2I("Debug_NrSamples_vs_StopType","Debug_NrSamples_vs_StopType",34,-1.5,32.5,7,-1.5,5.5)); - - histName = spadicName + "_Heatmap"; - title = histName + runName + ";X;Y"; - fHM->Add(histName.Data(), new TH2F(histName, title, 16, -0.5, 15.5, 2, 0.5, 2.5)); - - - // - - histName = spadicName + "_Cluster_Types"; - title = histName + runName +";Types;counts"; - fHM->Add(histName.Data(), new TH1F(histName, title,5,0,5)); - for (Int_t tType=0; tType < 5; tType++) - fHM->H1(histName.Data())->GetXaxis()->SetBinLabel(tType+1,cluster_names[tType]); - - histName = spadicName + "_Cluster_Charge"; - title = histName + runName + ";Integral;Counts"; - fHM->Add(histName.Data(), new TH1F(histName, title,500,0,5000)); - } - } - } - - std::cout << ">>> CbmTrdTestBeamAnalysis2015SPS::CreateHistograms: OK..." << std::endl; - -} - -Int_t CbmTrdTestBeamAnalysis2015SPS::GetSysCoreID(Int_t eqID) -{ - Int_t SysId=-1; - switch (eqID) { - case kFlesMuenster: - SysId = 0; - break; - case kFlesFrankfurt: - SysId = 1; - break; - case kFlesBucarest: - SysId = 2; - break; - default: - LOG(error) << "EquipmentID " << eqID << "not known."; - break; - } - return SysId; -} -// ---- ------------------------------------------------------- -Int_t CbmTrdTestBeamAnalysis2015SPS::GetSpadicID(Int_t sourceA) -{ - //TString spadic=""; - Int_t SpaId = -1; - switch (sourceA) { - case (SpadicBaseAddress+0): // first spadic - SpaId = 0; - break; - case (SpadicBaseAddress+1): // first spadic - SpaId = 1; - break; - case (SpadicBaseAddress+2): // second spadic - SpaId = 2; - break; - case (SpadicBaseAddress+3): // second spadic - SpaId = 3; - break; - case (SpadicBaseAddress+4): // third spadic - SpaId = 4; - break; - case (SpadicBaseAddress+5): // third spadic - SpaId = 5; - break; - default: - LOG(error) << "Source Address " << sourceA << "not known."; - break; - } - return SpaId; -} - -TString CbmTrdTestBeamAnalysis2015SPS::GetSpadicName(Int_t eqID,Int_t sourceA) -{ - TString spadicName=""; - - switch (eqID) { - case kFlesMuenster: - spadicName="SysCore0_"; - break; - case kFlesFrankfurt: - spadicName="SysCore1_"; - break; - case kFlesBucarest: - spadicName="SysCore2_"; - break; - default: - LOG(error) << "EquipmentID " << eqID << "not known."; - break; - } - - switch (sourceA) { - case (SpadicBaseAddress+0): // first spadic - case (SpadicBaseAddress+1): // first spadic - spadicName+="Spadic0"; - break; - case (SpadicBaseAddress+2): // second spadic - case (SpadicBaseAddress+3): // second spadic - spadicName+="Spadic1"; - break; - case (SpadicBaseAddress+4): // third spadic - case (SpadicBaseAddress+5): // third spadic - spadicName+="Spadic2"; - break; - default: - LOG(error) << "Source Address " << sourceA << "not known."; - break; - } - - spadicName = RewriteSpadicName(spadicName); - - return spadicName; -} - -TString CbmTrdTestBeamAnalysis2015SPS::RewriteSpadicName(TString spadicName) -{ - if(spadicName=="SysCore0_Spadic0") { - if(fRewriteSpadicName) spadicName="Frankfurt"; - }else if(spadicName=="SysCore0_Spadic1"){ - if(fRewriteSpadicName) spadicName="Muenster"; - }else{ - spadicName=""; - } - - return spadicName; -} - -// ---- ------------------------------------------------------- - Int_t CbmTrdTestBeamAnalysis2015SPS::GetChannelOnPadPlane(Int_t SpadicChannel) - { - /* - - | - |00|02|04 - | - - - - */ - - //Int_t channelMapping[32] = {31,15,30,14,29,13,28,12,27,11,26,10,25, 9,24, 8, 23, 7,22, 6,21, 5,20, 4,19, 3,18, 2,17, 1,16, 0}; - Int_t channelMapping[32] = { 0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5, 21, 6, 22, 7, 23, 8, 24, 9, 25, 10, 26, 11, 27, 12, 28, 13, 29, 14, 30, 15, 31}; - if (SpadicChannel < 0 || SpadicChannel > 31){ - LOG(error) << "CbmTrdTestBeamAnalysis2015SPS::GetChannelOnPadPlane ChId " << SpadicChannel; - return -1; - } else { - return channelMapping[SpadicChannel]; - } - } -// ---- ------------------------------------------------------- diff --git a/beamtime/trd/lib/CbmTrdTestBeamAnalysis2015SPS.h b/beamtime/trd/lib/CbmTrdTestBeamAnalysis2015SPS.h deleted file mode 100644 index d0f00ee08e32233d9121712a28c159466ef8bf5a..0000000000000000000000000000000000000000 --- a/beamtime/trd/lib/CbmTrdTestBeamAnalysis2015SPS.h +++ /dev/null @@ -1,90 +0,0 @@ -#ifndef CbmTrdTestBeamAnalysis2015SPS_H -#define CbmTrdTestBeamAnalysis2015SPS_H - -#include "FairTask.h" - -#include "CbmHistManager.h" - -#include "TClonesArray.h" - -class CbmTrdTestBeamAnalysis2015SPS : public FairTask -{ - public: - - enum EBaseMetod { kFirstTimeBin=0, kLastTimeBins, kNoise }; - - CbmTrdTestBeamAnalysis2015SPS(); - ~CbmTrdTestBeamAnalysis2015SPS(); - - virtual InitStatus Init(); - - virtual InitStatus ReInit(); - - virtual void Exec(Option_t* opt); - - virtual void SetParContainers(); - - virtual void Finish(); - - virtual void FinishEvent(); - - void SetRun(Int_t run) { fRun = run; std::cout << " SetRun(" << run << ")" << std::endl;} - - void SetRewriteSpadicName(Bool_t rewrite) { fRewriteSpadicName = rewrite; } - void SetPlotSignalShape(Bool_t plot) { fPlotSignalShape = plot; } - void SetPlotClusterFinder(Bool_t plot) { fPlotClusterFinder = plot; } - - private: - - Int_t fTimeBins; - Int_t fRun; - Int_t fSpadics; - Bool_t fRewriteSpadicName; - Bool_t fPlotSignalShape; - Bool_t fPlotClusterFinder; - - Int_t GetSysCoreID(Int_t eqID); - Int_t GetSpadicID(Int_t sourceA); - - TString GetSpadicName(Int_t eqID,Int_t sourceA); - TString RewriteSpadicName(TString spadicName); - - TClonesArray* fRawSpadic; - - CbmHistManager* fHM; - - // timecounter - Int_t fTimeCounter; - - - //Baseline - EBaseMetod fBaseMethod; // base line method - Int_t fBaselineBins; // bins used for baseline calculation - Int_t fBaseline[32]; // base line values - - // Noise Counter - Int_t fNoiseCounter; - - // ntuple for timecounting - //TNtuple *fNT; - - //*/ - - Int_t fNrTimeSlices; - - ULong_t fTimeMax; - ULong_t fTimeMin; - - void CreateHistograms(); - - Int_t GetChannelOnPadPlane(Int_t SpadicChannel); - - CbmTrdTestBeamAnalysis2015SPS(const CbmTrdTestBeamAnalysis2015SPS&); - CbmTrdTestBeamAnalysis2015SPS operator=(const CbmTrdTestBeamAnalysis2015SPS&); - - ClassDef(CbmTrdTestBeamAnalysis2015SPS,1); -}; - -#endif - - diff --git a/beamtime/trd/lib/CbmTrdTimeCorrel.cxx b/beamtime/trd/lib/CbmTrdTimeCorrel.cxx deleted file mode 100644 index 6d424cf9f822c21a6209dd237c712091ac1bd8fd..0000000000000000000000000000000000000000 --- a/beamtime/trd/lib/CbmTrdTimeCorrel.cxx +++ /dev/null @@ -1,2763 +0,0 @@ -#include "CbmTrdTimeCorrel.h" - -#include "CbmSpadicRawMessage.h" -#include "CbmHistManager.h" -#include "CbmBeamDefaults.h" -#include "CbmTrdCluster.h" -#include "CbmTrdDigi.h" -#include "CbmTrdAddress.h" - -#include <FairLogger.h> - -#include <TStyle.h> -#include <TCanvas.h> -#include <TH1.h> -#include <TH2.h> -#include <TH3.h> -#include <TMultiGraph.h> -#include <TNtuple.h> -#include <TString.h> -#include <TMath.h> - -#include <cmath> -#include <map> -#include <vector> -#include <iostream> -#include <stdexcept> - -using std::vector; -using std::string; - -// ---- ------------------------------------------------------- -CbmTrdTimeCorrel::CbmTrdTimeCorrel() - : FairTask("CbmTrdTimeCorrel"), - fMessageBuffer(), - fLinearHitBuffer(), - fSpadics(0), - fRewriteSpadicName(true), - fBaseline(NrOfActiveSyscores*NrOfHalfSpadics*16,0), - fBaselineMon ( - new TCanvas (TString ("Canvas_Baselinemonitor").Data (), - TString ("Baselinemonitor").Data (), 1600, 900)), - fRawSpadic(NULL), - fRawMessages(NULL), - fDigis(NULL), - fClusters(NULL), - fiRawMessage(0), - fiDigi(0), - fiCluster(0), - fHM(new CbmHistManager()), - fNrTimeSlices(0), - fRun(0), - fLastMessageTime (NrOfActiveSyscores*NrOfSpadics*32,0), - fEpochMarkerArray(NrOfActiveSyscores*NrOfHalfSpadics,0), - fFirstEpochMarker(NrOfActiveSyscores*NrOfHalfSpadics,true), - EpochRegressTriggered(NrOfActiveSyscores*NrOfHalfSpadics,false), - EpochRegressOffset(NrOfActiveSyscores*NrOfHalfSpadics,0), - EpochRegressCounter(NrOfActiveSyscores*NrOfHalfSpadics,0), - timestampOffsets(), - fGraph(true), - fOutputCloneArrays(false), - fClusterBuffer() - { - gStyle->SetNumberContours(99); - { - TString CalibrationFilename = - FairRootManager::Instance ()->GetOutFile ()->GetName (); - Int_t DefaultBaselineFrankfurt = -190; - Int_t DefaultBaselineMuenster = -220; - CalibrationFilename.ReplaceAll (".root", "_Calibration.root"); - TFile* Calibration = new TFile (CalibrationFilename.Data (), "READ"); - if (Calibration == nullptr) - { - LOG(info) << "No calibration file found, continuing with default baseline."; - for (Int_t syscore = 0; syscore < NrOfActiveSyscores; ++syscore) - { - for (Int_t spadic = 0; spadic < NrOfActiveSpadics; ++spadic) - { - for (Int_t channel = 0; channel < 32; ++channel) - { - fBaseline[syscore * NrOfHalfSpadics * 16 + spadic * 32 + channel] = - ((spadic / 2) == 0 ? - DefaultBaselineFrankfurt : DefaultBaselineMuenster); - } - } - } - } - else{ Calibration->cd(); - LOG(info) << "Calibration file found at " <<CalibrationFilename<< " reading baseline."; - for (Int_t syscore = 0; syscore < NrOfActiveSyscores; ++syscore) - { - for (Int_t spadic = 0; spadic < NrOfActiveSpadics; ++spadic) - { - for (Int_t channel = 0; channel < 32; ++channel) - { - string spadicName = GetSpadicName(syscore, spadic, kDirectOutput,kFullSpadic).Data(); - TString fitname = "Fit_Baseline_for_"+spadicName - + "_Channel_" + std::to_string (channel); - TFitResult* CurrentFit = dynamic_cast<TFitResult*>(Calibration->Get(fitname.Data())); - if(CurrentFit==nullptr){ - LOG(info) << "No baseline fit found for Syscore "<< syscore << " Spadic "<<spadic << " Channel "<<channel; - fBaseline[syscore * NrOfHalfSpadics * 16 + spadic * 16 + channel] = - ((spadic / 2) == 0 ? - DefaultBaselineFrankfurt : DefaultBaselineMuenster); - } - else { - fBaseline[syscore * NrOfHalfSpadics * 16 + spadic * 32 + channel] = CurrentFit->GetParams()[1]-0*CurrentFit->GetParams()[2]; - } - } - } - } - FairRootManager::Instance ()->GetOutFile ()->cd(); - Calibration->Close(); - } - } - }; - -// ---- ------------------------------------------------------- -CbmTrdTimeCorrel::~CbmTrdTimeCorrel() -{ - LOG(debug) << "Destructor of CbmTrdTimeCorrel"; - fRawMessages->Clear(); - fDigis->Delete(); - fClusters->Delete(); -} -// ---- ------------------------------------------------------- -void CbmTrdTimeCorrel::SetParContainers() -{ - LOG(debug) << "SetParContainers of CbmTrdTimeCorrel"; -} -// ---- ------------------------------------------------------- -InitStatus CbmTrdTimeCorrel::Init() -{ - LOG(info) << "Initilization of CbmTrdTimeCorrel"; - FairRootManager* ioman = FairRootManager::Instance(); - fRawSpadic = static_cast<TClonesArray*>(ioman->GetObject("SpadicRawMessage")); - if ( !fRawSpadic ) { - LOG(fatal) << "No InputDataLevelName array!\n CbmTrdTimeCorrel will be inactive"; - return kERROR; - } - - fRawMessages = new TClonesArray("CbmSpadicRawMessage"); - ioman->Register("TrdRawMessage", "TRD Raw Messages", fRawMessages, kTRUE); - - fDigis = new TClonesArray("CbmTrdDigi"); - ioman->Register("TrdDigi", "TRD Digis", fDigis, kTRUE); - - fClusters = new TClonesArray("CbmTrdCluster"); - ioman->Register("TrdCluster", "TRD Clusters", fClusters, kTRUE); - - CreateHistograms(); - return kSUCCESS; -} -// ---- ReInit ------------------------------------------------------- -InitStatus CbmTrdTimeCorrel::ReInit() -{ - LOG(debug) << "Initilization of CbmTrdTimeCorrel"; - return kSUCCESS; -} -// ---- Exec ------------------------------------------------------- -void CbmTrdTimeCorrel::Exec(Option_t*) -{ - const Int_t maxNrColumns = 16; //max number of channels on a pad plane per asic and row - - // Analysis based on single SPADIC data streams can be done here!!! - - if(fNrTimeSlices==0){ - if(fHM->G1("TsCounter")->GetN()!=0){ - LOG(info) << "Expected empty TsCounter before first TimeSlice, but found " << fHM->G1("TsCounter")->GetN() << " entries."; - } - } - - TString spadicName = ""; - TString histName=""; - TString title=""; - - - - LOG(info) << "CbmTrdTimeCorrel: Number of current TimeSlice: " << fNrTimeSlices; - LOG(info) << "Digis in TClonesArray: " << fDigis->GetEntriesFast(); - LOG(info) << "Clusters in TClonesArray: " << fClusters->GetEntriesFast(); - LOG(info) << "rawMessages in TS: " << fRawSpadic->GetEntriesFast(); - fDigis->Delete(); - fDigis = new TClonesArray("CbmTrdDigi"); - fClusters->Delete(); - fClusters = new TClonesArray("CbmTrdCluster"); - Int_t nSpadicMessagesFull = fRawSpadic->GetEntriesFast(); //SPADIC messages per TimeSlice - Int_t nSpadicMessages[NrOfActiveSyscores*NrOfSpadics]; //SPADIC messages per TimeSlice for single SPADICS - //SPADIC message types per TimeSlice for single SPADICS: - Int_t nSpadicMessagesHit[NrOfActiveSyscores*NrOfSpadics]={}; - Int_t nSpadicMessagesHitAborted[NrOfActiveSyscores*NrOfSpadics]={}; - Int_t nSpadicMessagesOverflow[NrOfActiveSyscores*NrOfSpadics]={}; - Int_t nSpadicMessagesInfo[NrOfActiveSyscores*NrOfSpadics]={}; - Int_t nSpadicMessagesEpoch[NrOfActiveSyscores*NrOfSpadics]={}; - Int_t nSpadicMessagesLost[NrOfActiveSyscores*NrOfSpadics]={}; - Int_t nSpadicMessagesStrange[NrOfActiveSyscores*NrOfSpadics]={}; - Int_t lostMessages(0);// this variable should be reset to 0 for every SPADIC message - // Getting message type bools from Spadic raw message - Bool_t isHit = false; - Bool_t isHitAborted = false; - Bool_t isOverflow = false; - Bool_t isInfo = false; - Bool_t isEpoch = false; - Bool_t isEpochOutOfSynch = false; - Bool_t isStrange = false; - - // Initialise message coordinates to -1 to recognise unset variables - Int_t eqID(-1), sourceA(-1), triggerType(-1), stopType(-1), infoType(-1), groupId(-1), sysID(-1), spaID(-1); - // chID in ASIC. Take care, neighboured numbers are not neccessarily neighboured on the connected TRD cathode pad plane. Resorted lateron! - // padID are sorted chIDs in the order as on the pad plane - Int_t chID(-1), padID(-1), columnID(-1), rowID(-1), combiID(-1); - ULong_t time = 0; - // Time stamp and epoch are counted in the Spadic - Int_t timeStamp(0), epoch(0), superEpoch(0); - LOG(info) << "nSpadicMessages: " << nSpadicMessagesFull; - - Int_t hitCounter[NrOfActiveSyscores*NrOfSpadics]={}; - CbmSpadicRawMessage* raw = NULL; - - // Do the message type counting per timeslice here to make the full numbers available early in the following analysis loop - for (Int_t iSpadicMessage=0; iSpadicMessage < nSpadicMessagesFull; ++iSpadicMessage){ - raw = static_cast<CbmSpadicRawMessage*>(fRawSpadic->At(iSpadicMessage)); - lostMessages = 0; // reset lost-counter for a new message - sourceA = raw->GetSourceAddress(); - spaID = GetSpadicID(sourceA); - eqID = raw->GetEquipmentID(); - sysID = GetSyscoreID(eqID); - spadicName = GetSpadicName(eqID,sourceA); - chID = raw->GetChannelID(); - if(chID > -1 && chID < 16 && spaID%2==1) chID+=16; // eqID ? - isHit = raw->GetHit(); - isHitAborted = raw->GetHitAborted(); - isOverflow = raw->GetOverFlow(); - isInfo = raw->GetInfo(); - isEpoch = raw->GetEpoch(); - isEpochOutOfSynch = raw->GetEpochOutOfSynch(); - isStrange = raw->GetStrange(); - - fHM->H2("SourceAvsEquipIDall")->Fill(eqID,sourceA); - if(isEpoch) fHM->H2("SourceAvsEquipIDepoch")->Fill(eqID,sourceA); - if(isHit && chID >= 0 && chID <= 15) fHM->H2("SourceAvsEquipIDhit")->Fill(eqID,(sourceA + GetChannelOnPadPlane(chID)*0.0625 + 0.03125)); // For hit messages, the originating padID is displayed within the sourceA axis - - // Count total messages per ASIC and message-types per ASIC. - { - nSpadicMessages[NrOfSpadics*sysID+spaID]++; - if(isHit) nSpadicMessagesHit[NrOfSpadics*sysID+spaID]++; - else if(isHitAborted) nSpadicMessagesHitAborted[NrOfSpadics*sysID+spaID]++; - else if(isOverflow) { - nSpadicMessagesOverflow[NrOfSpadics*sysID+spaID]++; - if (lostMessages > 0) nSpadicMessagesLost[NrOfSpadics*sysID+spaID] += lostMessages; //lostMessages might be -1 for hits or epochs, therefore one has to ensure that it is > 0 - } - else if(isInfo) nSpadicMessagesInfo[NrOfSpadics*sysID+spaID]++; - else if(isEpoch) nSpadicMessagesEpoch[NrOfSpadics*sysID+spaID]++; - else if(isStrange) nSpadicMessagesStrange[NrOfSpadics*sysID+spaID]++; - } - - // Currently only expecting Spadic0 and Spadic1. Logging others, if appearing. - } - { - TString path = FairRootManager::Instance()->GetOutFile()->GetName(); - TString RunNumber = path(TRegexp("[0-9]+_")); - Int_t Cap = 1000000; - if(RunNumber.Contains("111_")) Cap=11400; - if(RunNumber.Contains("97_")) Cap=2000; - if (fNrTimeSlices>Cap){ - fNrTimeSlices++; - return; - } - - } - static Long64_t lastHitTimestamp[NrOfActiveSyscores*NrOfSpadics*32]; - if (fNrTimeSlices==0){ - for(size_t i=0;i<NrOfActiveSyscores*NrOfSpadics*32;i++){ - lastHitTimestamp[i]=0; - } - } - - // Starting to loop over all Spadic messages in unpacked TimeSlice, Analysis loop - for (Int_t iSpadicMessage=0; iSpadicMessage < nSpadicMessagesFull; ++iSpadicMessage) { - //std::cout << " " << iSpadicMessage << std::endl; - raw = static_cast<CbmSpadicRawMessage*>(fRawSpadic->At(iSpadicMessage)); - lostMessages = 0; // reset lost-counter for a new message - chID = -1; // reset to notice if set to a new ID - padID = -1; - isHit = raw->GetHit(); - isHitAborted = raw->GetHitAborted(); - isOverflow = raw->GetOverFlow(); - isInfo = raw->GetInfo(); - isEpoch = raw->GetEpoch(); - isStrange = raw->GetStrange(); - isEpochOutOfSynch = raw->GetEpochOutOfSynch(); - // Seriously guys, a message can only be of one type. - if(Int_t(isHit+isInfo+isEpoch+isHitAborted+isOverflow+isStrange+isEpochOutOfSynch)!=1) LOG(error) << "SpadicMessage " << iSpadicMessage << " is classified from CbmSpadicRawMessage to be: HIT " << (Int_t)isHit << " / INFO " << (Int_t)isInfo << " / EPOCH " << (Int_t)isEpoch << " / HITaborted " << (Int_t)isHitAborted << " / OVERFLOW " << (Int_t)isOverflow << " / STRANGE " << (Int_t)isStrange; - - // Get SysCore & Spadic propertys - eqID = raw->GetEquipmentID(); - sourceA = raw->GetSourceAddress(); - - groupId=raw->GetGroupId(); - chID = raw->GetChannelID(); - sysID = GetSyscoreID(eqID); - spaID = GetSpadicID(sourceA); - if(chID > -1 && chID < 16 && spaID%2==1) chID+=16; // eqID ? - padID = GetChannelOnPadPlane(chID);// Remapping from ASIC to pad-plane channel numbers. - - columnID = GetColumnID(raw); - rowID = GetRowID(raw); - combiID = rowID * (maxNrColumns + 1) + columnID;// Is needed to cluster messages within one detector layer. combiID provides a linear representation of a 2dim coordinate system (row, column) with an additional column. By using continues combiIDs one avoids to build continues clusters between to rows. - - - // Int_t nrSamples=raw->GetNrSamples(); - - lostMessages = raw->GetBufferOverflowCount(); - - - if (!isOverflow && lostMessages!=0) LOG(error) << "SpadicMessage " << iSpadicMessage << " is HIT " << (Int_t)isHit << " / INFO " << (Int_t)isInfo << " / EPOCH " << (Int_t)isEpoch << " / HITaborted " << (Int_t)isHitAborted << " / STRANGE " << (Int_t)isStrange << " but claims to have lost " << lostMessages << " messages"; - time = raw->GetFullTime(); - timeStamp = raw->GetTime(); - - epoch = raw->GetEpochMarker();// is copied to each SpadicRawMessage by the unpacker not only epoch messages - superEpoch = raw->GetSuperEpoch();// is copied to each SpadicRawMessage by the unpacker not only epoch message - - stopType = raw->GetStopType(); - TString stopName = GetStopName(stopType); - infoType=raw->GetInfoType(); - triggerType = raw->GetTriggerType(); - - if(isHit) hitCounter[sysID*NrOfHalfSpadics+spaID]++; - if(isHit||isHitAborted){ - TString TempName = "Hitfrequency_for_"+GetSpadicName(sysID, spaID, kProcessedData,kFullSpadic); - string HistName=TempName.Data(); - if(fNrTimeSlices>0)fHM->G1(HistName)->SetPoint(fHM->G1(HistName)->GetN(),static_cast<Double_t>(time)/15000000.0,15000000/std::fabs((static_cast<Double_t>(lastHitTimestamp[spaID*16+raw->GetChannelID()])-static_cast<Double_t>(time)))); -// fHM->H2(HistName+"_linear")->Fill(fNrTimeSlices,17600000/std::fabs((static_cast<Double_t>(lastHitTimestamp[spaID*16+raw->GetChannelID()])-static_cast<Double_t>(time)))); - lastHitTimestamp[sysID*NrOfHalfSpadics*16+spaID*16+raw->GetChannelID()]=time; - } - - if (raw->GetChannelID()>100) LOG(error) << "SpadicMessage with strange chID: " << iSpadicMessage << " sourceA: " << sourceA << " chID: " << raw->GetChannelID() << " groupID: " << groupId << " spaID: " << spaID << " stopType: " << stopType << " infoType: " << infoType << " triggerType: " << triggerType << " isHit: " << isHit << " isInfo: " << isInfo << " isEpoch: " << isEpoch << " Lost Messages: " << lostMessages; - if (raw->GetChannelID()>32 && !isInfo && !isStrange) LOG(fatal) << "SpadicMessage: " << iSpadicMessage << " sourceA: " << sourceA << " chID: " << raw->GetChannelID() << " groupID: " << groupId << " spaID: " << spaID << " stopType: " << stopType << " infoType: " << infoType << " triggerType: " << triggerType << " isHit: " << isHit << " isInfo: " << isInfo << " isEpoch: " << isEpoch << " Lost Messages: " << lostMessages; - - - if (infoType > 6) { - LOG(error) << " InfoType " << infoType << "is larger 6, set to 7!"; - infoType = 7; - } - - spadicName = GetSpadicName(eqID,sourceA,kRawData,kFullSpadic); - //printf("spadicName:%s:\n",spadicName.Data()); - if ( isOverflow ) - if (spadicName != "") - fHM->H2((spadicName + TString("_LostCount_vs_PadID")).Data())->Fill(lostMessages,padID); - - // add raw message to map sorted by timestamps, syscore and spadic - if(spadicName == ""){ - LOG(error) << "eqID:" << eqID << " sourceA:" << sourceA << " spadicName:" << spadicName; - //continue; - } else { - //if (false) - - if (!isStrange && !isEpoch && !isEpochOutOfSynch){ - - if (!isInfo) { - std::map<Int_t, CbmSpadicRawMessage*>::iterator MessageBufferIt = fMessageBuffer[TString(spadicName)][time].find(combiID); - if (MessageBufferIt == fMessageBuffer[TString(spadicName)][time].end()){ - /* - if there is no message found for spadicName at this time and the same padID (which should never be the case) the - processed message is added to the map. This avoids per definition the use of overlapping microslices. It is up to you to - define the time for spacial and time clusterization (after each timeSliceContainer or ad the end of the file. This will - be mainly a question of available RAM. It might be a good idea to clusterize after each timeSliceContainer, write all - rawMessages inside of the buffer to a TClonesArray or TTree as well as all found CbmTrdClusters to a separate TClonesArray - or TTree. Afterwards one should erase the buffer partially (leaving a rest of messages at the end of the buffer to be able - to cluster messages at the beginning of the next TimeSliceContainer. - */ - //fMessageBuffer[TString(spadicName)][time][combiID] = raw; - /* - In order to not interfere with the clean up of the TClonesArray, we copy here the information and delete the stored objects in the clean up of the map - */ - fMessageBuffer[TString(spadicName)][time][combiID] = new CbmSpadicRawMessage(raw->GetEquipmentID(), raw->GetSourceAddress(), raw->GetChannelID(), - raw->GetEpochMarker(), raw->GetTime(), - raw->GetSuperEpoch(), raw->GetTriggerType(), - raw->GetInfoType(), raw->GetStopType(), - raw->GetGroupId(), raw->GetBufferOverflowCount(), - raw->GetNrSamples(), raw->GetSamples(), - raw->GetHit(), raw->GetInfo(), raw->GetEpoch(), raw->GetEpochOutOfSynch(), raw->GetHitAborted(), raw->GetOverFlow(), raw->GetStrange()); - - /* - A new TClonesArray without MS overlaps is created for offline analysis - *//* - new ((*fRawMessages)[fiRawMessage])CbmSpadicRawMessage(raw->GetEquipmentID(), raw->GetSourceAddress(), raw->GetChannelID(), - raw->GetEpochMarker(), raw->GetTime(), - raw->GetSuperEpoch(), raw->GetTriggerType(), - raw->GetInfoType(), raw->GetStopType(), - raw->GetGroupId(), raw->GetBufferOverflowCount(), - raw->GetNrSamples(), raw->GetSamples(), - raw->GetHit(), raw->GetInfo(), raw->GetEpoch(), raw->GetEpochOutOfSynch(), raw->GetHitAborted(), raw->GetOverFlow(), raw->GetStrange()); - */ - fiRawMessage++; - if (isHit&&(triggerType==1||triggerType==3))fHM->H2(TString("Map_of_Hits_for_"+GetSpadicName(eqID,sourceA,kRawData,kFullSpadic)).Data())->Fill(padID%16,static_cast<Int_t>(padID/16)); - if (isHit&&(triggerType==1||triggerType==3))fHM->H2(TString("Map_of_Charge_for_"+GetSpadicName(eqID,sourceA,kRawData,kFullSpadic)).Data())->Fill(padID%16,static_cast<Int_t>(padID/16),GetMaxADC(*raw,false,&fBaseline)); - if (isHit) FillBaselineHistogram(raw); - if(fActivateClusterizer) - if (isHit || isHitAborted || isOverflow) - if(fNrTimeSlices!=0){ - /* - CbmSpadicRawMessage* tempPtr = new CbmSpadicRawMessage(*raw); - */ - fLinearHitBuffer.push_back(raw); - string Histname = "Signalshape_for_" + string(spadicName) + "Channel" - + std::to_string(chID); - if(triggerType==1&&(stopType==0)) FillSignalShape(*raw,Histname); - TString graphName = "TSTime_"+GetSpadicName(eqID,sourceA,kRawData,kHalfSpadic); - fHM->G1(graphName.Data())->SetPoint(fHM->G1(graphName.Data())->GetN(),fNrTimeSlices+1,raw->GetFullTime()/1.5E7); - } - if(fDrawSignalDebugHistograms){ - if (isHit||isHitAborted){ - Int_t maxADC= GetMaxADC(*raw,false,&fBaseline); - Int_t TriggerType = raw->GetTriggerType(); - if(!(TriggerType<0 ||TriggerType>3)){ - string TriggerName; - { - TString triggerTypes[4] = { - "Global trigger", "Self triggered", - "Neighbor triggered", - "Self and neighbor triggered" }; - TriggerName = triggerTypes[TriggerType]; - } - Int_t StopType = raw->GetStopType(); - Int_t AvgBaseline=GetAvgBaseline(*raw); - string Histname = "MaxADC_vs_NrSamples_for_" - +string(GetSpadicName(sysID, spaID, kProcessedData,kFullSpadic).Data())+"_"+TriggerName; - string Hittype; - fHM->H2(Histname)->Fill(raw->GetNrSamples(),maxADC); - if (StopType==0) { - Hittype = "_Hits"; - }else { - Hittype = "_MultiHits"; - } - Histname = "MaxADC_vs_avgBaseline_for_" - +string(GetSpadicName(sysID, spaID, kProcessedData,kFullSpadic).Data())+Hittype+"_"+TriggerName; - if(raw->GetSamples()[0] < maxADC) { - fHM->H2(Histname)->Fill(AvgBaseline,maxADC); - }else{ - Histname = "Exp_Decay" +Histname; - fHM->H2(Histname)->Fill(raw->GetSamples()[raw->GetNrSamples()-1]/*AvgBaseline*/,maxADC); - } - Histname = "avgBaseline_for_" - +string(GetSpadicName(sysID, spaID, kProcessedData,kFullSpadic).Data())+"_"+TriggerName; - if(raw->GetStopType()==0)fHM->H1(Histname)->Fill(AvgBaseline); - Histname = "avgBaseline_vs_NrSamples_for_" - +string(GetSpadicName(sysID, spaID, kProcessedData,kFullSpadic).Data())+"_"+TriggerName; - fHM->H2(Histname)->Fill(raw->GetNrSamples(),raw->GetSamples()[raw->GetNrSamples()-1]/*AvgBaseline*/); - Histname = "First_Sample_vs_last_Sample_for_" - +string(GetSpadicName(sysID, spaID, kProcessedData,kFullSpadic).Data())+Hittype+"_"+TriggerName; - if(raw->GetSamples()[0] < maxADC) { - fHM->H2(Histname)->SetBinContent(fHM->H2(Histname)->FindBin(0),0); - fHM->H2(Histname)->Fill(raw->GetSamples()[raw->GetNrSamples()-1],raw->GetSamples()[0]); - }else{ - Histname = "Exp_Decay" +Histname; - fHM->H2(Histname)->SetBinContent(fHM->H2(Histname)->FindBin(0),0); - fHM->H2(Histname)->Fill(raw->GetSamples()[raw->GetNrSamples()-1],raw->GetSamples()[0]); - } - } - } - } - - } else { - - LOG(debug) << "Found Message already in fMessageBuffer at :" << TString(spadicName).Data() << ":, time:" << time << ", padID:" << padID << ". Potential overlapping MS container!"; - - if (fMessageBuffer[TString(spadicName)][time][combiID] != NULL) - fHM->H2("DoubleMessage_MessageType")->Fill(GetMessageType(fMessageBuffer[TString(spadicName)][time][combiID]),GetMessageType(raw)); - else - fHM->H2("DoubleMessage_MessageType")->Fill(-1,GetMessageType(raw)); - /* - LOG(info) << "------------------------------------"; - raw->PrintMessage(); - LOG(info) << "<raw---------------------------->"; - fMessageBuffer[TString(spadicName)][time][combiID]->PrintMessage(); - LOG(info) << ">buffer-------------------------<"; - LOG(info) << "------------------------------------"; - */ - } - } - } - if (isInfo){ - if(chID < 32)fHM->H2("InfoType_vs_Channel")->Fill(padID,infoType); - else fHM->H2("InfoType_vs_Channel")->Fill(33,infoType); // chIDs greater than 32 are quite strange and will be put into the last bin - } - if (isEpoch){ // fill epoch messages in an additional row - if(chID < 32)fHM->H2("InfoType_vs_Channel")->Fill(padID,9); - else fHM->H2("InfoType_vs_Channel")->Fill(33,9); - } - if (isOverflow){ // fill overflow messages in an additional row - if(chID < 32)fHM->H2("InfoType_vs_Channel")->Fill(padID,10); - else fHM->H2("InfoType_vs_Channel")->Fill(33,10); - } - if (isEpoch) { - if (!fFirstEpochMarker[sysID*NrOfHalfSpadics+spaID]) { - fHM->H1(TString("Delta_Epoch_hist_for_"+GetSpadicName(eqID, sourceA, kRawData,kHalfSpadic)).Data())->Fill(epoch - fEpochMarkerArray[sysID*NrOfHalfSpadics+spaID]); - fHM->H2(TString("Hitrate_vs_Delta_Epoch_hist_for_"+GetSpadicName(eqID, sourceA, kRawData,kHalfSpadic)).Data())->Fill(epoch - fEpochMarkerArray[sysID*NrOfHalfSpadics+spaID], nSpadicMessagesHit[sysID*NrOfHalfSpadics+spaID]); - // Book keep here the trending of Epoch Counters after a regress has been detected - if ( EpochRegressTriggered[sysID*NrOfHalfSpadics+spaID] ) { // Fill subsequent epoch messages in the histo, if the mechanism is triggered - EpochRegressCounter[sysID*NrOfHalfSpadics+spaID]++; // Count how many epochs are put in the trending histo already - LOG(info) << "EPOCH REGRESS ongoing (step " << EpochRegressCounter[sysID*NrOfHalfSpadics+spaID] << ") for spaID " << spaID << " from " << fEpochMarkerArray[sysID*NrOfHalfSpadics+spaID] << " to " << epoch << " (timeslice " << fNrTimeSlices << ", spadicmessage " << iSpadicMessage << ")"; - fHM->H2(TString("EpochTrend_postregress_hist_for_"+GetSpadicName(sysID, spaID, kProcessedData,kHalfSpadic)).Data())->Fill(EpochRegressCounter[sysID*NrOfHalfSpadics+spaID],epoch - EpochRegressOffset[sysID*NrOfHalfSpadics+spaID]); - if ( EpochRegressCounter[sysID*NrOfHalfSpadics+spaID] >= 150 ) { // After this condition is fulfilled, enough epochs have been recorded -- reset trigger and counter - EpochRegressTriggered[sysID*NrOfHalfSpadics+spaID] = false; - EpochRegressCounter[sysID*NrOfHalfSpadics+spaID] = 0; - } - } - if (epoch - fEpochMarkerArray[sysID*NrOfHalfSpadics+spaID] <= 0 && !EpochRegressTriggered[sysID*NrOfHalfSpadics+spaID]) { // Trigger the recording if a regress is detected and the recording is not running up to now. The natural overflow of epoch (regress of 4095) is excluded - fHM->G1(TString("DeltaEpoch_vs_timeslice_for_"+GetSpadicName(eqID, sourceA, kRawData,kHalfSpadic)).Data())->SetPoint(fHM->G1(TString("DeltaEpoch_vs_timeslice_for_"+GetSpadicName(eqID, sourceA, kRawData,kHalfSpadic)).Data())->GetN(),fNrTimeSlices,epoch - fEpochMarkerArray[sysID*NrOfHalfSpadics+spaID]); // Fill TGraph with every regress of Epoch, also the normal overflows by 4095 - if (epoch - fEpochMarkerArray[sysID*NrOfHalfSpadics+spaID] > -4000) { // but trigger the recording only for irregular regress - LOG(info) << "EPOCH REGRESS triggered for sysId "<< sysID <<" spaID " << spaID << " from " << fEpochMarkerArray[sysID*NrOfHalfSpadics+spaID] << " to " << epoch << " (timeslice " << fNrTimeSlices << ", spadicmessage " << iSpadicMessage << ")"; - EpochRegressTriggered[sysID*NrOfHalfSpadics+spaID] = true; - EpochRegressOffset[sysID*NrOfHalfSpadics+spaID] = epoch; - } - } - } - fEpochMarkerArray[sysID*NrOfHalfSpadics+spaID] = epoch; - fFirstEpochMarker[sysID*NrOfHalfSpadics+spaID] = false; - } - //if(spadicName!="") { - - // - // DEBUG PLOTS - // - - if(isHit && chID >= 0 && chID < 32) { - histName = GetSpadicName(eqID,sourceA,kRawData,kHalfSpadic) + "_Time_vs_TimeSlice"; - fHM->H2(histName.Data())->Fill(fNrTimeSlices,time); //timeStamp(0), epoch(0), superEpoch(0); - } - - if(isEpoch && chID >= 0 && chID < 32) { - histName = GetSpadicName(eqID,sourceA,kRawData,kHalfSpadic) + "_Epoch_vs_TimeSlice"; - fHM->H2(histName.Data())->Fill(fNrTimeSlices,epoch); //timeStamp(0), epoch(0), superEpoch(0); - } - - // These are pure debuging histos to ensure that the unpacker is running without errors (C.B) - fHM->H2("TriggerType_vs_InfoType")->Fill(raw->GetTriggerType(), raw->GetInfoType()); - fHM->H2("TriggerType_vs_StopType")->Fill(raw->GetTriggerType(), raw->GetStopType()); - fHM->H2("InfoType_vs_StopType")->Fill(raw->GetInfoType(), raw->GetStopType()); - fHM->H2("NrSamples_vs_StopType")->Fill(raw->GetNrSamples(), raw->GetStopType()); - fHM->H2("NrSamples_vs_InfoType")->Fill(raw->GetNrSamples(), raw->GetInfoType()); - fHM->H2("NrSamples_vs_TriggerType")->Fill(raw->GetNrSamples(), raw->GetTriggerType()); - - //------------------- - - /*Extended Message Debugging: - -Check for deformed Messages - -Check for empty Messages claiming to be normally stopped - ->search for BufferOverflows - */ - if(false){ - if(stopType == 0 && (chID <-1 || chID >32)) LOG(fatal) << "SpadicMessage: " << iSpadicMessage << " sourceA: " << sourceA << " chID: " << chID << " groupID: " << groupId << " spaID: " << spaID << " stopType: " << stopType << " infoType: " << infoType << " triggerType: " << triggerType << " isHit: " << isHit << " is Info: " << isInfo; - if(stopType == 0 && raw->GetNrSamples()==0 && iSpadicMessage < nSpadicMessagesFull){ - for ( Int_t i=iSpadicMessage;i<nSpadicMessagesFull;i++){ - if ((static_cast<CbmSpadicRawMessage*>(fRawSpadic->At(i)))->GetOverFlow()==true && GetSpadicID((static_cast<CbmSpadicRawMessage*>(fRawSpadic->At(i)))->GetSourceAddress())==spaID) - { - lostMessages = (static_cast<CbmSpadicRawMessage*>(fRawSpadic->At(i)))->GetBufferOverflowCount(); - break; - } - //LOG(info) << i << "Info not found "; - } - LOG(info) << "SpadicMessages: " << nSpadicMessagesFull << " Lost Messages "; - LOG(error) << "SpadicMessage: " << iSpadicMessage << " sourceA: " << sourceA << " chID: " << raw->GetChannelID() << " groupID: " << groupId << " spaID: " << spaID << " stopType: " << stopType << " infoType: " << infoType << " triggerType: " << triggerType << " isHit: " << isHit << " is Info: " << isInfo << " Lost Messages: " << lostMessages; - } - } - - - //Fill trigger-type histogram - fHM->H1("Trigger")->Fill(spadicName,1); - fHM->H1("MessageCount")->Fill(TString(spadicName+"_"+stopName),1); - if(stopType==-1) fHM->H1("MessageCount")->Fill(TString(spadicName+"_"+stopName+" n-fold"),1); // replace weight 1 with number of lost messages - } - //std::cout << " tuut" << std::endl; - } - // complicated loop over sorted map of timestamps, manually delete all elements in the nested maps - // commented out, since obviuously the following outer clear command destructs all contained elements recursively - // The objects correlated to the pointers stored in this map are deleted after each run of Exec. Therefore it is leading to seg.fa. if one tryies to delete the pointers here twice - /* - for(std::map<TString, std::map<ULong_t, std::vector<CbmSpadicRawMessage*> > >::iterator it = timeBuffer.begin() ; it != timeBuffer.end(); it++){ - // complicated loop over sorted map of raw messages - for (std::map<ULong_t, std::vector<CbmSpadicRawMessage*> > ::iterator it2 = it->second.begin() ; it2 != it->second.end(); it2++) { - // LOG(info) << "ClusterSize:" << Int_t(it2->second.size()); - //for (std::vector<CbmSpadicRawMessage*>::iterator it3 = it2->second.begin(); it3 != it2->second.end(); it3++) { - for(Int_t i = 0; i < Int_t(it2->second.size()); i++){ - //delete it2->second[i];//it3->second; - // here: looping through the vector - } - // it2->second.clear(); - } - // it->second.clear(); - } - */ - - // Fill number of spadic-messages in tscounter-graph. Use TimeSlices (slices in processing time) here instead of physical full-time on the x-axis. - // Length of one timeslice: m * n * 8 ns, with e.g. n=1250 length of microslice and m=100 microslices in one timeslice at SPS2015 - if (fGraph) { - std::vector<Int_t> spadicList(NrOfActiveHalfSpadics); - std::iota(spadicList.begin(),spadicList.end(),0); - fHM->G1("TsCounter")->SetPoint(fHM->G1("TsCounter")->GetN(),fNrTimeSlices+1,nSpadicMessagesFull); - for(Int_t syscore = 0; syscore < NrOfActiveSyscores; ++syscore) { - for(auto spadic : spadicList) { - string SpadicName = GetSpadicName(syscore, spadic, kDirectOutput,kHalfSpadic).Data(); - string graphName = "TsCounterHit_"+SpadicName; - fHM->G1(graphName)->SetPoint(fHM->G1(graphName)->GetN(),fNrTimeSlices+1,nSpadicMessagesHit[NrOfSpadics*syscore+spadic]); - graphName = "TsCounterHitAborted_"+SpadicName; - fHM->G1(graphName)->SetPoint(fHM->G1(graphName)->GetN(),fNrTimeSlices+1,nSpadicMessagesHitAborted[NrOfSpadics*syscore+spadic]); - graphName = "TsCounterOverflow_"+SpadicName; - fHM->G1(graphName)->SetPoint(fHM->G1(graphName)->GetN(),fNrTimeSlices+1,nSpadicMessagesOverflow[NrOfSpadics*syscore+spadic]); - graphName = "TsLost_"+SpadicName; - if(nSpadicMessagesOverflow[NrOfSpadics*syscore+spadic] > 0) fHM->G1(graphName)->SetPoint(fHM->G1(graphName)->GetN(),fNrTimeSlices+1,(Double_t(nSpadicMessagesLost[NrOfSpadics*syscore+spadic])/Double_t(nSpadicMessagesOverflow[NrOfSpadics*syscore+spadic]))); - else fHM->G1(graphName)->SetPoint(fHM->G1(graphName)->GetN(),fNrTimeSlices+1,0); - graphName = "TsCounterInfo_"+SpadicName; - fHM->G1(graphName)->SetPoint(fHM->G1(graphName)->GetN(),fNrTimeSlices+1,nSpadicMessagesInfo[NrOfSpadics*syscore+spadic]); - graphName = "TsCounterEpoch_"+SpadicName; - fHM->G1(graphName)->SetPoint(fHM->G1(graphName)->GetN(),fNrTimeSlices+1,nSpadicMessagesEpoch[NrOfSpadics*syscore+spadic]); - graphName = "TsCounterStrange_"+SpadicName; - fHM->G1(graphName)->SetPoint(fHM->G1(graphName)->GetN(),fNrTimeSlices+1,nSpadicMessagesStrange[NrOfSpadics*syscore+spadic]); - if(nSpadicMessages[NrOfSpadics*syscore+spadic] > 0) fHM->G1("TsStrangeness_"+SpadicName)->SetPoint(fHM->G1("TsStrangeness_"+SpadicName)->GetN(),fNrTimeSlices+1,(Double_t(nSpadicMessagesStrange[NrOfSpadics*syscore+spadic])/Double_t(nSpadicMessages[NrOfSpadics*syscore+spadic]))); - else fHM->G1("TsStrangeness_"+SpadicName)->SetPoint(fHM->G1("TsStrangeness_"+SpadicName)->GetN(),fNrTimeSlices+1,0); - } - } - } - // Catch empty TimeSlices. - if(fNrTimeSlices==0){ - if(fHM->G1("TsCounter")->GetN()==0){ - LOG(info) << "Expected entries in TsCounter after finishinig first TimeSlice, but found none."; - } - } - fNrTimeSlices++; - - if(fNrTimeSlices % 1 ==0) - { - if (fActivateClusterizer){ - if (fNrTimeSlices!=0)ClusterizerTime(); - //ClusterizerSpace(); - } - CleanUpBuffers(); - } - for(Int_t syscore = 0; syscore < NrOfActiveSyscores; ++syscore) { - for(Int_t spadic = 0; spadic < NrOfActiveSpadics; ++spadic) { - spadicName = GetSpadicName(syscore, spadic, kDirectOutput,kFullSpadic); - histName = "Baseline_for_"+spadicName; - TString TemphistName = "Temp_"+histName; - fHM->H2(histName.Data())->Add(fHM->H2(TemphistName.Data())); - TString Graph = "Baselinetrend_"+spadicName; - fHM->G1(Graph.Data())->SetPoint(fHM->G1(Graph.Data())->GetN(),fNrTimeSlices+1,fHM->H2(TemphistName.Data())->GetMean(1)); - fHM->H2(TemphistName.Data())->Reset(); - if(fHM->H2(TemphistName.Data())->GetEntries()!=0) LOG(fatal)<<"Reset Failed for Temp_"+histName; - } - } - for(int i=1;i<=12;i++) { - fBaselineMon->cd(i)->Modified(); - } - fBaselineMon->Update(); - -} -// ---- Finish ------------------------------------------------------- -void CbmTrdTimeCorrel::Finish() -{ - ClusterizerTime(); - fRawMessages->Clear(); - fDigis->Clear(); - fClusters->Clear(); - FitBaseline(); - //FitPRF(); - TString path = FairRootManager::Instance()->GetOutFile()->GetName(); - TString runName= path(TRegexp("[0-9]+_")); - if(fRun!=0) runName=Form(" (Run %d)",fRun); - - fHM->H2("SourceAvsEquipIDall")->GetXaxis()->SetTitle("eqID"); - fHM->H2("SourceAvsEquipIDall")->GetYaxis()->SetTitle("sourceA"); - fHM->H2("SourceAvsEquipIDepoch")->GetXaxis()->SetTitle("eqID"); - fHM->H2("SourceAvsEquipIDepoch")->GetYaxis()->SetTitle("sourceA"); - fHM->H2("SourceAvsEquipIDhit")->GetXaxis()->SetTitle("eqID"); - fHM->H2("SourceAvsEquipIDhit")->GetYaxis()->SetTitle("sourceA/padID"); - - - - //Perform uniform relabeling of Axis - ReLabelAxis(fHM->H1("InfoType_vs_Channel")->GetYaxis(),"infoType",true,true); - - // use this to produce nice single plots - /* - TCanvas *cnice = new TCanvas("cnice","cnice",800,400); - cnice->cd(); - fHM->G1("TsCounterHit1")->Draw("AL"); - fHM->G1("TsCounterHit1")->SetLineColor(kBlack); - fHM->G1("TsCounterHit1")->GetXaxis()->SetTitle("timeslice"); - fHM->G1("TsCounterHit1")->GetXaxis()->SetRangeUser(0,2166); - fHM->G1("TsCounterHit1")->GetYaxis()->SetTitle("SPADIC1 hit messages"); - */ - //Buffer (map) or multi SPADIC data streams based analyis have to be done here!! - - /* - std::vector<TH2*> TH2vector = fHM->H2Vector(".*"); - for (std::vector<TH2*>::iterator it = TH2vector.begin() ; it != TH2vector.end(); ++it){ - LOG(info) << (*it)->GetTitle(); - (*it)->SetContour(99); - } - - std::vector<TCanvas*> c; - for (Int_t syscore = 0; syscore < NrOfActiveSyscores; ++syscore) { - for (Int_t spadic = 0; spadic < NrOfActiveSpadics; ++spadic) { - string spadicName = GetSpadicName(syscore, spadic, kDirectOutput, - kFullSpadic).Data(); - c.push_back( - new TCanvas(TString("Canvas_Signalshapes_for_" + spadicName).Data(), - TString("Signalshapes_for_" + spadicName).Data(), 1920, 1080)); - c.back()->Divide(8, 4); - if (spadicName != "") { - for (Int_t Channel = 0; Channel < 32; Channel++) { - c.back()->cd(Channel + 1)->SetLogz(); - string HistName = "Signalshape_for_" + spadicName - + "Channel" + std::to_string(Channel); - fHM->H2(HistName)->Draw("colz2"); - } - } - - } - } - TDirectory *Canvasdir = FairRootManager::Instance ()->GetOutFile ()->mkdir ( - "Signalshapes"); - Canvasdir->cd (); - for (auto C : c) - { - C->Write (); - } - FairRootManager::Instance ()->GetOutFile ()->cd (); - Canvasdir = FairRootManager::Instance ()->GetOutFile ()->mkdir ("Baselines"); - Canvasdir->cd (); - fBaselineMon->Write (); - FairRootManager::Instance ()->GetOutFile ()->cd (); - */ -{ vector<TH2*> HitFrequencies = fHM->H2Vector("Clusterfrequency.*"); - for (auto h : HitFrequencies){ - h->Sumw2(); - TH1* P= h->ProjectionY(); - P->Scale(1.0/P->GetEntries(),"width"); - TString HistName = TString(h->GetTitle())+"_Spectrum"; - P->SetNameTitle(HistName.Data(),HistName.Data()); - fHM->Add(HistName.Data(),P); - h->GetXaxis()->SetNameTitle("Time t/s","Time t/s"); - h->GetYaxis()->SetNameTitle("Clusterfrequency f/Hz","Clusterfrequency f/Hz"); - } -} -{ vector<TGraph*> HitFrequencies = fHM->G1Vector(".*frequency.*"); - for (auto h : HitFrequencies){ - Int_t NrEntries=h->GetN(); - auto Y=h->GetY(); - for(Int_t i = 0; i<NrEntries;i++){ - if(TMath::IsNaN(Y[i])||Y[i]==TMath::Infinity()){ - h->RemovePoint(i); - i=0; - NrEntries=h->GetN(); - } - } - h->GetXaxis()->SetNameTitle("Time t/s","Time t/s"); - h->GetYaxis()->SetNameTitle("Hitfrequency f/Hz","Hitfrequency f/Hz"); - } -} - if(fBatchAssessment){ - vector<TH2*> PadResponses = fHM->H2Vector("Pad_Response.*"); - vector<TH2*> Heatmap = fHM->H2Vector(".*Heatmap.*"); - vector<TH2*> Baselines = fHM->H2Vector(".*Baseline.*"); - TCanvas *c6 = new TCanvas("BatchAssesment",""+runName,1600,900); - path = FairRootManager::Instance()->GetOutFile()->GetName(); - TString RunNumber = path(TRegexp("[0-9]+_")); - path = "/home/p_munk01/Pictures/BatchAssesment/"; - for (auto h : PadResponses){ - TString Title = h->GetTitle(); - if(!(Title.Contains("_3")||Title.Contains("_4"))) continue; - c6->Clear(); - c6->SetLogz(); - h->SetContour(99); - h->Draw("colz"); - c6->Update(); - c6->SaveAs(path+RunNumber+Title+".png"); - } - for (auto h : Heatmap){ - TString Title = h->GetTitle(); - if(!(Title.Contains("Cluster(3")||Title.Contains("Cluster(4"))) continue; - c6->Clear(); - c6->SetLogz(); - h->SetContour(99); - h->Draw("colz"); - c6->Update(); - c6->SaveAs(path+RunNumber+h->GetTitle()+".png"); - } - for (auto h : Baselines){ - TString Title = h->GetTitle(); - c6->Clear(); - c6->SetLogz(); - h->SetContour(99); - h->Draw("colz"); - c6->Update(); - c6->SaveAs(path+RunNumber+h->GetTitle()+".png"); - } - } - - LOG(debug) << "Finish of CbmTrdTimeCorrel"; - LOG(info) << "Write histo list to " << FairRootManager::Instance()->GetOutFile()->GetName(); - FairRootManager::Instance()->GetOutFile()->cd(); - fHM->WriteToFile(); - //if(false) - //delete c1; - TString outfile = FairRootManager::Instance()->GetOutFile()->GetName(); - outfile.ReplaceAll(".root", "_Calibration.root"); - LOG(info) << "Baselines extracted and stored at "<< outfile << " If this is your first time running this analysis, please rerun this analysis."; -} -// ---- FinishEvent ------------------------------------------------------- -void CbmTrdTimeCorrel::FinishEvent() -{ - LOG(debug) << "FinishEvent of CbmTrdTimeCorrel"; - - LOG(info) << "Digis in TClonesArray: " << fDigis->GetEntriesFast(); - LOG(info) << "Clusters in TClonesArray: " << fClusters->GetEntriesFast(); - fClusters->Delete(); - fClusters = new TClonesArray("CbmTrdCluster"); - fDigis->Delete(); - fDigis = new TClonesArray("CbmTrdDigi"); -} -// ------------------------------------------------------------------------- -void CbmTrdTimeCorrel::ClusterizerTime() -{ - static Int_t Clusterrun =0; - auto CompareSpadicMessages= - [&](CbmSpadicRawMessage* a,CbmSpadicRawMessage* b) - { - Int_t SyscoreIDA = GetSyscoreID(a->GetEquipmentID()); - Int_t SyscoreIDB = GetSyscoreID(b->GetEquipmentID()); - Int_t SpadicIDA = GetSpadicID(a->GetSourceAddress()); - Int_t SpadicIDB = GetSpadicID(b->GetSourceAddress()); - Int_t ChIDA = a->GetChannelID() + ((SpadicIDA %2 == 1)? 16 : 0); - Int_t ChIDB = b->GetChannelID() + ((SpadicIDB %2 == 1)? 16 : 0); - Int_t PadA = GetChannelOnPadPlane(ChIDA); - Int_t PadB = GetChannelOnPadPlane(ChIDB); - Int_t rowA = (SpadicIDA/2)*2+PadA/16; - Int_t rowB = (SpadicIDB/2)*2+PadB/16; - if(a->GetFullTime() == b->GetFullTime()) - if(SyscoreIDA==SyscoreIDB) - if (SpadicIDA == SpadicIDB) - if(rowA==rowB) - if(PadA==PadB) - return true; - return false; - }; - auto CompareSpadicMessagesSmaller= - [&](CbmSpadicRawMessage* a,CbmSpadicRawMessage* b) - { - Int_t SyscoreIDA = GetSyscoreID(a->GetEquipmentID()); - Int_t SyscoreIDB = GetSyscoreID(b->GetEquipmentID()); - Int_t SpadicIDA = GetSpadicID(a->GetSourceAddress()); - Int_t SpadicIDB = GetSpadicID(b->GetSourceAddress()); - Int_t ChIDA = a->GetChannelID() + ((SpadicIDA %2 == 1)? 16 : 0); - Int_t ChIDB = b->GetChannelID() + ((SpadicIDB %2 == 1)? 16 : 0); - Int_t PadA = GetChannelOnPadPlane(ChIDA); - Int_t PadB = GetChannelOnPadPlane(ChIDB); - Int_t rowA = (SpadicIDA/2)*4+PadA/16; - Int_t rowB = (SpadicIDB/2)*4+PadB/16; - if(a->GetFullTime() < b->GetFullTime()) - if(SyscoreIDA<SyscoreIDB){ - if(rowA<rowB) - return true; - else if(rowA == rowB) - if(PadA<PadB) - return true; - } - return false; - }; - /* - auto TimeStampSort= - [&](CbmSpadicRawMessage* a,CbmSpadicRawMessage* b) - { - if(a->GetFullTime() < b->GetFullTime()) - return true; - return false; - }; -*/ - const Int_t clusterWindow = 0; // size of time window in which two hits are called "correlated", unit is timestamps - std::sort(fLinearHitBuffer.begin(),fLinearHitBuffer.end(),CompareSpadicMessagesSmaller); - std::unique(fLinearHitBuffer.begin(),fLinearHitBuffer.end(),CompareSpadicMessages); - std::multimap<ULong_t, CbmSpadicRawMessage*> TempHitMap,TempOverflowMap; - for (auto x : fLinearHitBuffer){ - long unsigned int MessageTime = static_cast <long unsigned int>(x->GetFullTime()); - (x->GetOverFlow()) ? TempOverflowMap.insert(std::make_pair(MessageTime,x)): TempHitMap.insert(std::make_pair(MessageTime,x)); - } - UInt_t LastTimestamp = 0; - for (auto it=TempHitMap.begin(); it != TempHitMap.end(); ++it){ - auto range = std::make_pair(TempHitMap.lower_bound(it->first), TempHitMap.upper_bound(it->first + clusterWindow)); - auto rangeCopy=range; - if(TempHitMap.size()==0 || (range.first == TempHitMap.end())) continue; - for (;range.first != range.second; ++(range.first)){ - if(it->second == nullptr || range.first->second == nullptr) continue; - if(range.first->second->GetTriggerType() == 1 || range.first->second->GetTriggerType() ==3) { // exclude purely neighbour triggered hits - if(it->second->GetTriggerType() == 1 || it->second->GetTriggerType() == 3) { // exclude purely neighbour triggered hits for the comparator side too - Int_t ChID1 = it->second->GetChannelID(); - Int_t ChID2 = range.first->second->GetChannelID(); - Int_t SpaID1 = GetSpadicID(it->second->GetSourceAddress()); - Int_t SpaID2 = GetSpadicID(range.first->second->GetSourceAddress()); - Int_t SysID1 = GetSyscoreID(it->second->GetEquipmentID()); - Int_t SysID2 = GetSyscoreID(range.first->second->GetEquipmentID()); - ChID1 += (SpaID1 %2 == 1)? 16 : 0; // Remap the channel IDs of each second Half-Spadic to 16...31 - ChID2 += (SpaID2 %2 == 1)? 16 : 0; - // special for SPS2015 data: the chamber with SpaID 2 and 3 was turned by 180 degree with respect to the first one. thus, turn the pad plane number here - //Int_t SpaPad1 = (Int_t)(SpaID1/2) * 32 + ((SpaID1>1) ? 31-GetChannelOnPadPlane(ChID1) : GetChannelOnPadPlane(ChID1)); - //Int_t SpaPad2 = (Int_t)(SpaID2/2) * 32 + ((SpaID2>1) ? 31-GetChannelOnPadPlane(ChID2) : GetChannelOnPadPlane(ChID2)); - Int_t SpaPad1 = (Int_t)(SpaID1/2) * 32 + (GetChannelOnPadPlane(ChID1)); - Int_t SpaPad2 = (Int_t)(SpaID2/2) * 32 + (GetChannelOnPadPlane(ChID2)); - if (it!=range.first) { //Exclude Correlations of messages with themselves - //TODO:Implement Clusters and fill them - std::pair<TString,TString> Corrmap=std::make_pair(GetSpadicName(SysID1, SpaID1, kProcessedData, kFullSpadic),GetSpadicName(SysID2, SpaID2, kProcessedData, kFullSpadic)); - std::cout<< Corrmap.first << " " << Corrmap.second << std::endl; - if(std::count(fCorrmaps.begin(),fCorrmaps.end(),Corrmap)!=0){ - TString histName="Correlation_Map_"+Corrmap.first+"_"+Corrmap.second; - fHM->H2(histName.Data())->Fill(GetChannelOnPadPlane(ChID1)-GetChannelOnPadPlane(ChID2),static_cast<Long_t>(range.first->second->GetFullTime())-static_cast<Long_t>(it->second->GetFullTime())); - } - if(fDebugMode){ - fHM->H2("Hit_Coincidences")->Fill(SpaPad1,SpaPad2); - // Fill for map of correlations following: require origin from variant TRD chambers to cut on physical correlations between two chambers, which is adressed for the moment just by requiring different SpaID/2 - // Furthermore, physical correlations coming from the target require a positve direction from Chamber 1 to Chamber 2, which means ascending SpaIDs - fHM->H2("Correlation_Map")->Fill(SpaPad2-SpaPad1-32,(static_cast<Long_t>(range.first->second->GetFullTime())-static_cast<Long_t>(it->second->GetFullTime()))); - }else{ - if (((Int_t)(SpaID1/2) - (Int_t)(SpaID2/2)) != 0) fHM->H2("Hit_Coincidences")->Fill(SpaPad1,SpaPad2); - // Fill for map of correlations following: require origin from variant TRD chambers to cut on physical correlations between two chambers, which is adressed for the moment just by requiring different SpaID/2 - // Furthermore, physical correlations coming from the target require a positve direction from Chamber 1 to Chamber 2, which means ascending SpaIDs - if (((Int_t)(SpaID2/2) - (Int_t)(SpaID1/2)) > 0) fHM->H2("Correlation_Map")->Fill(SpaPad2-SpaPad1-32,(static_cast<Long_t>(range.first->second->GetFullTime())-static_cast<Long_t>(it->second->GetFullTime()))); - } - } - } - } - } - if(LastTimestamp>=it->first-clusterWindow) continue; - else LastTimestamp = it->first; -/* - * Important Notice: - * If fActivate2DClusterizer is set to true, - * Messages are sorted byChIDs instead of PadID's, - * also turns of row detection. - */ - auto SortSpadicMessageRange = - [&](CbmSpadicRawMessage a,CbmSpadicRawMessage b) - { if (fActivate2DClusterizer) { - Int_t ChIDA = a.GetChannelID() + ((GetSpadicID(a.GetSourceAddress()) %2 == 1)? 16 : 0); - Int_t ChIDB = b.GetChannelID() + ((GetSpadicID(b.GetSourceAddress()) %2 == 1)? 16 : 0); - Int_t SpaIDA = (GetSpadicID(a.GetSourceAddress())/2); - Int_t SpaIDB = (GetSpadicID(b.GetSourceAddress())/2); - if(SpaIDA<SpaIDB) - return true; - else if(SpaIDA == SpaIDB) - if(ChIDA<ChIDB) - return true; - return false; - } else { - Int_t ChIDA = a.GetChannelID() + ((GetSpadicID(a.GetSourceAddress()) %2 == 1)? 16 : 0); - Int_t ChIDB = b.GetChannelID() + ((GetSpadicID(b.GetSourceAddress()) %2 == 1)? 16 : 0); - Int_t PadA = GetChannelOnPadPlane(ChIDA); - Int_t PadB = GetChannelOnPadPlane(ChIDB); - Int_t rowA = (GetSpadicID(a.GetSourceAddress())/2)*2+PadA/16; - Int_t rowB = (GetSpadicID(b.GetSourceAddress())/2)*2+PadB/16; - if(rowA<rowB) - return true; - else if(rowA == rowB) - if(PadA<PadB) - return true; - return false; - } - }; - Bool_t OutsideCluster = true; - std::vector<CbmSpadicRawMessage> linearClusterBuffer; - std::vector<Int_t> HitChs,HitSpadic; - for (; rangeCopy.first != rangeCopy.second; ++(rangeCopy.first)) //Copy Messages from the previously selected range for easier access - { - linearClusterBuffer.push_back (*rangeCopy.first->second); - Int_t Trigger = (*rangeCopy.first->second).GetTriggerType(); - if(Trigger==1||Trigger==3) { - HitChs.push_back((*rangeCopy.first->second).GetChannelID()+(GetSpadicID((*rangeCopy.first->second).GetSourceAddress())%2)*16); - HitSpadic.push_back(GetSpadicID((*rangeCopy.first->second).GetSourceAddress())); - } - } - for (UInt_t i = 0; i < HitChs.size(); i++) { - for (auto x : linearClusterBuffer) { - Int_t SpadicID = GetSpadicID(x.GetSourceAddress()); - Int_t Channel = x.GetChannelID() - + (GetSpadicID(x.GetSourceAddress()) % 2) * 16; - if ((HitSpadic.at(i) / 2) == (SpadicID / 2)) { - Int_t Trigger = x.GetTriggerType(); - if (std::abs(Channel - HitChs.at(i)) < 3) - if (Trigger == 2) { - string histname = - "Trigger_Bug_Investigation_" - + string(GetSpadicName(x.GetEquipmentID(),x.GetSourceAddress(),kRawData,kFullSpadic).Data()); - fHM->H2(histname)->Fill(HitChs.at(i), Channel); - } - } - } - } - Clusterrun++; - std::sort (linearClusterBuffer.begin (), linearClusterBuffer.end (),SortSpadicMessageRange);//Sort the Hitmessages by their position of origin on the padplane - Cluster BuildingCluster (&fBaseline,clusterWindow,fClusterThreshhold); //Create a new Cluster - Int_t lastRow = (GetSpadicID(linearClusterBuffer.begin()->GetSourceAddress())/2)*32+GetChannelOnPadPlane(linearClusterBuffer.begin()->GetChannelID() + ((GetSpadicID(linearClusterBuffer.begin()->GetSourceAddress()) %2 == 1)? 16 : 0))/16; - Int_t lastPad = GetChannelOnPadPlane(linearClusterBuffer.begin()->GetChannelID() + ((GetSpadicID(linearClusterBuffer.begin()->GetSourceAddress()) %2 == 1)? 16 : 0)); - auto SatteliteDebug = - [&](Cluster currentCluster){ - if(/*currentCluster.size() != 2&&*/!currentCluster.Get2DStatus()) return 0; - return 0; - Int_t Detector = currentCluster.GetSpadic()/2; - string Detectorname = (Detector == 0 ? "Frankfurt" : "Muenster"); - //std::cout << "Fragmented Cluster Found on Pad: " <<currentCluster.GetHorizontalPosition() << std::endl; - //std::cout << "Satelites on ChID|SpaID|Timestamp|HitType|StopType" << std::endl; - CbmSpadicRawMessage MainMassage; - auto Messages= currentCluster.GetEntries(); - for (auto tempMessage=Messages.first;tempMessage!= Messages.second;tempMessage++){ - if (tempMessage->GetTriggerType()!=2) { - MainMassage = *tempMessage; - break; - } - } - for (auto x: linearClusterBuffer ){ - std::cout << x.GetChannelID() << " " << GetSpadicID(x.GetSourceAddress()) <<" " << x.GetFullTime() << " " <<x.GetTriggerType() << " " << x.GetStopType() << std::endl; - - } - std::cout << "All Satellites printed " << std::endl; - std::cout << "________________________________________________________"<< std::endl; - return 0; - }; - for (auto currentMessage = linearClusterBuffer.begin(); currentMessage != linearClusterBuffer.end(); currentMessage++) //Loop over all Messages inside the Hitwindow - { - Int_t currentPad = GetChannelOnPadPlane(currentMessage->GetChannelID() + ((GetSpadicID(currentMessage->GetSourceAddress()) %2 == 1)? 16 : 0)); - if(BuildingCluster.size()>16) std::cout << "Cluster of Size " << BuildingCluster.size() << " with current Pad " << currentPad << " " << lastPad <<std::endl; - if (currentPad-lastPad >1 ){ - if(!fActivate2DClusterizer) OutsideCluster=true; - else if(currentPad-lastPad >3)OutsideCluster=true; - //std::cout << "Gap in Cluster found " << std::endl; - } - Int_t currentRow = (GetSpadicID(currentMessage->GetSourceAddress())/2)*32+currentPad/16; - if((!fActivate2DClusterizer&&(BuildingCluster.size () > currentPad || lastRow != currentRow||lastPad >= currentPad)))//Check if the current message is not from the same row/spadic - { - if (BuildingCluster.size () != 0)//Store away nonempty Cluster - { - SatteliteDebug(BuildingCluster); - fClusterBuffer.push_back (BuildingCluster); - Cluster tempCluster (&fBaseline,clusterWindow,fClusterThreshhold); - BuildingCluster = tempCluster; - } - //std::cout << " Rowchange " << lastRow << " " << currentRow << " " << std::endl; - OutsideCluster = true; //New Row, so we start outside any Cluster - lastRow = currentRow; - } else if(fActivate2DClusterizer){ - if(currentRow%32==lastRow%32){ - lastRow=currentRow; - } - else { - if (BuildingCluster.size () != 0)//Store away nonempty Cluster - { - SatteliteDebug(BuildingCluster); - fClusterBuffer.push_back (BuildingCluster); - Cluster tempCluster (&fBaseline,clusterWindow,fClusterThreshhold); - BuildingCluster = tempCluster; - } - //std::cout << " Rowchange " << lastRow << " " << currentRow << " " << std::endl; - OutsideCluster = true; //New Row, so we start outside any Cluster - lastRow = currentRow; - } - } - - if (currentMessage->GetTriggerType () == 2)//Check for neighbour triggered Messages - { - if (OutsideCluster) - {//Beginning of a Cluster - if (BuildingCluster.size () != 0) //Store away the previous Cluster, if not already done - { - SatteliteDebug(BuildingCluster); - fClusterBuffer.push_back (BuildingCluster); - Cluster tempCluster (&fBaseline,clusterWindow,fClusterThreshhold); - BuildingCluster = tempCluster; - } - BuildingCluster.AddEntry (*currentMessage); - OutsideCluster = false; - } - else - {//Test if currentMessage is Part of next Cluster - /* - auto nextMessage = currentMessage; - if(currentMessage!=linearClusterBuffer.end()) nextMessage++; - if (currentMessage != linearClusterBuffer.begin()) - if(nextMessage != linearClusterBuffer.end()) - if(nextMessage->GetTriggerType () == 1||nextMessage->GetTriggerType () == 3) - { - if(GetChannelOnPadPlane(nextMessage->GetChannelID() + ((GetSpadicID(nextMessage->GetSourceAddress()) %2 == 1)? 16 : 0))- - currentPad >1) - { - std::cout << " Black Magic Code > 2 has triggered "<< std::endl; - - BuildingCluster.AddEntry (*currentMessage); - if (BuildingCluster.size () != 0) //Store away the completed Cluster - { - SatteliteDebug(BuildingCluster); - fClusterBuffer.push_back (BuildingCluster); - Cluster tempCluster (fBaseline,clusterWindow,fClusterThreshhold); - BuildingCluster = tempCluster; - } - } - else if(GetChannelOnPadPlane(nextMessage->GetChannelID() + ((GetSpadicID(nextMessage->GetSourceAddress()) %2 == 1)? 16 : 0))- - currentPad <=1) - { - std::cout << " Black Magic Code <=1 has triggered "<< std::endl; - if (BuildingCluster.size () != 0) //Store away the completed Cluster - { - SatteliteDebug(BuildingCluster); - fClusterBuffer.push_back (BuildingCluster); - Cluster tempCluster (fBaseline,clusterWindow,fClusterThreshhold); - BuildingCluster = tempCluster; - } - currentMessage--; - } - OutsideCluster = true; - std::cout << "EVIL GOTO" << std::endl; - goto SchleifenendeClusterizer; - }*/ - //End of a Cluster, marked by second neighbour triggered message - BuildingCluster.AddEntry (*currentMessage); - OutsideCluster = true; - if (BuildingCluster.size () != 0) //Store away the completed Cluster - { - SatteliteDebug(BuildingCluster); - fClusterBuffer.push_back (BuildingCluster); - Cluster tempCluster (&fBaseline,clusterWindow,fClusterThreshhold); - BuildingCluster = tempCluster; - } - } - } - else if ((currentMessage->GetTriggerType () == 3 || currentMessage->GetTriggerType () == 1)){ - if (OutsideCluster) - {//incomplete Cluster without a starting neighbour triggered Hitmessage - if (BuildingCluster.size () != 0)//Should not occur, but stores away previous Cluster - { - SatteliteDebug(BuildingCluster); - fClusterBuffer.push_back (BuildingCluster); - Cluster tempCluster (&fBaseline,clusterWindow,fClusterThreshhold); - BuildingCluster = tempCluster; - }//Start the Cluster - BuildingCluster.AddEntry (*currentMessage); - OutsideCluster = false;//we are now inside a cluster - } - else //Fill the Cluster - { - BuildingCluster.AddEntry (*currentMessage); - } - } - // SchleifenendeClusterizer: - lastPad = currentPad; - } - //std::cout << " CLusterizer loop finished" << std::endl; - if (BuildingCluster.size () != 0) //Store away the last Cluster - { - SatteliteDebug(BuildingCluster); - fClusterBuffer.push_back (BuildingCluster); - Cluster tempCluster (&fBaseline,clusterWindow,120); - BuildingCluster = tempCluster; - } - - //std::sort(rangeCopy.first,rangeCopy.second,CompareSpadicMessagesSmaller); - } - if(fClusterBuffer.size()>0) - { - TH2* CoincidenceHistogram = fHM->H2("Cluster_Coincidences"); - for (unsigned int i =0; i< fClusterBuffer.size()-1;i++){ - Float_t CurrentPosition=fClusterBuffer.at(i).GetHorizontalPosition(); - if (fClusterBuffer.at(i).size()<3 ||fClusterBuffer.at(i).size()>4) continue; - Int_t CurrentDetector = fClusterBuffer.at(i).GetSpadic()/2; - //if(CurrentPosition>16.0) CurrentPosition -= 16.0; - Long_t CurrentTime = fClusterBuffer.at(i).GetFulltime(); - for(unsigned int j=1;j<10&&i+j<fClusterBuffer.size();j++){ - if(fClusterBuffer.at(i+j).GetSpadic()/2==CurrentDetector) continue; - if (fClusterBuffer.at(i+j).size()<3 ||fClusterBuffer.at(i+j).size()>4) continue; - Float_t NextPosition=fClusterBuffer.at(i+j).GetHorizontalPosition(); - //if(NextPosition>16.0) NextPosition -= 16.0; - Long_t NextTime = fClusterBuffer.at(i+j).GetFulltime(); - CoincidenceHistogram->Fill(NextPosition - CurrentPosition,NextTime -CurrentTime); - } - } - } - static Long64_t lastClusterTimestamp[NrOfActiveSyscores*NrOfSpadics]; - if (fNrTimeSlices==1){ - for(Int_t i=0;i<NrOfActiveSyscores*NrOfSpadics;i++){ - lastClusterTimestamp[i]=0; - } - } - - for (auto x: fClusterBuffer){ - Float_t Position = x.GetHorizontalPosition(); - if (Position < 0.5 || Position > 30.5 || //exclude Clusters outside Padplane - (Position > 14.5 && Position < 16.5) || //exclude Clusters between rows on Padplane - (Position > 6.5 && Position < 8.5) || //exclude Clusters on gap between Halfchip A and B - (Position > 22.5 && Position < 24.5)|| //exclude Clusters on gap between Halfchip A and B - (Position > 26.5 && Position < 29.5)) //exclude Clusters around defective channel 6 - { - fHM->H1 ( - "Masked_Clustersize_for_" - + string(GetSpadicName(0, x.GetSpadic (), kProcessedData,kFullSpadic).Data()))->Fill ( - static_cast<Int_t> (x.size ())); - continue; - } - fHM->H1("Clustersize_for_"+string(GetSpadicName(0, x.GetSpadic (), kProcessedData,kFullSpadic).Data()))->Fill(static_cast<Int_t>(x.size ())); - fHM->H2("Cluster("+std::to_string(static_cast<Int_t>(x.size()))+")_Heatmap_for_"+string(GetSpadicName(0, x.GetSpadic (), kProcessedData,kFullSpadic).Data()))->Fill((x.GetHorizontalPosition()<16.0 ? x.GetHorizontalPosition() : x.GetHorizontalPosition()-16.0),1-static_cast<Int_t>(x.GetRow())); - if (fDrawClustertypes){ - string histname = "Clustertypes_for_"+string(GetSpadicName(0, x.GetSpadic (), kProcessedData,kFullSpadic).Data()); - fHM->H2(histname)->Fill(x.size(),x.Type()); - } - if(x.Type() > 0 && x.size()>=3 && x.Type() <6){ - string histname = "Cut5_Pad_Response_"+ string(GetSpadicName(0, x.GetSpadic (), kProcessedData,kFullSpadic).Data()) - + "_for_Clusters_of_Size_"+std::to_string(static_cast<Int_t>(x.size())); - if(x.Type()==5) x.FillChargeDistribution(fHM->H2(histname)); - continue; - } - if(x.fMaxStopType < 1 && x.size() >=3) - { - string histname = "Charge_Spectrum_for_"+string(GetSpadicName(0, x.GetSpadic (), kProcessedData,kFullSpadic).Data()); - fHM->H1(histname)->Fill(x.GetTotalCharge(),1/*,x.GetHorizontalPosition()*/); - string histname2 = "ChargeIntegral_Spectrum_for_"+string(GetSpadicName(0, x.GetSpadic (), kProcessedData,kFullSpadic).Data()); - fHM->H1(histname2)->Fill(x.GetTotalIntegralCharge(),1/*,x.GetHorizontalPosition()*/); - - } - //if(x.size()==3&&(x.GetTotalCharge()> 250)) continue; - if(fDrawPadResponse){ - string histname = "Pad_Response_"+ string(GetSpadicName(0, x.GetSpadic (), kProcessedData,kFullSpadic).Data()) + "_for_Clusters_of_Size_"+std::to_string(static_cast<Int_t>(x.size())); - x.FillChargeDistribution(fHM->H2(histname),fHM->H2("Central_"+histname)); - } - int spaID=x.GetSpadic(); - Long64_t time=x.GetFulltime(); - string HistName = "Clusterfrequency_for_"+string(GetSpadicName(0, x.GetSpadic (), kProcessedData,kFullSpadic).Data()); - fHM->H2(HistName)->Fill(static_cast<Double_t>(time)/15000000.0,15000000/std::fabs((static_cast<Double_t>(lastClusterTimestamp[(spaID%2)*32])-static_cast<Double_t>(time)))); - lastClusterTimestamp[(spaID%2)*32]=time; - } -} -// ------------------------------------------------------------------------- -void CbmTrdTimeCorrel::ClusterizerSpace() -{ - LOG(info) << "ClusterizerSpace"; - Int_t mapDigiCounter = 0; - CbmSpadicRawMessage* raw = NULL; - //CbmTrdCluster* cluster = NULL; - Int_t layerId(0), moduleId(0), sectorId(0), rowId(0), columnId(0), clusterSize(0), address(0); - ULong_t lastClusterTime = 0; - ULong_t fullTime = 0; - TString SysSpaID = ""; - std::vector<Int_t> digiIndices; - for (std::map<TString, std::map<ULong_t, std::map<Int_t, CbmSpadicRawMessage*> > >::iterator SpaSysIt = fMessageBuffer.begin() ; SpaSysIt != fMessageBuffer.end(); SpaSysIt++){ - SysSpaID = SpaSysIt->first; - for (std::map<ULong_t, std::map<Int_t, CbmSpadicRawMessage*> > ::iterator timeIt = (SpaSysIt->second).begin() ; timeIt != (SpaSysIt->second).end(); timeIt++){ - LOG(debug) << "ClusterSize:" << Int_t((timeIt->second).size()); - clusterSize = Int_t((timeIt->second).size()); - if ( SysSpaID != "") - fHM->H1((SysSpaID + TString("_CluterSize")).Data())->Fill(clusterSize); - - fullTime = timeIt->first; - lastClusterTime = fullTime; - - Int_t lastCombiID = -1; - for (std::map<Int_t, CbmSpadicRawMessage*> ::iterator combiIt = (timeIt->second).begin(); combiIt != (timeIt->second).end(); combiIt++){ - mapDigiCounter++; - if (combiIt->second == NULL) { - LOG(debug) << "Entrie in fMessageBuffer == NULL. SysSpaID:" << SysSpaID << " fullTime:" << fullTime << " combiID:" << combiIt->first; - continue; - } - raw = combiIt->second; - - layerId = GetLayerID(raw); - moduleId = GetModuleID(raw); - sectorId = GetSectorID(raw); - rowId = GetRowID(raw); - columnId = GetColumnID(raw); - LOG(debug) << " layerId:" << layerId << " moduleId:" << moduleId << " sectorId:" << sectorId << " rowId:" << rowId << " columnId:" << columnId; - // BaseLineCorrection== - Float_t Baseline = 0.; - - if (raw->GetStopType() == 0){ - /* - for (Int_t bin = 1; bin < 4; bin++){ - Baseline += raw->GetSamples()[raw->GetNrSamples()-bin]; - } - Baseline /= 3.; - */ - } else { - // Use average baseline estimated for full message length - } - const Int_t nSamples = raw->GetNrSamples(); - //Float_t Samples[nSamples] = {0.}; - Float_t* Samples = new Float_t[nSamples]; - for (Int_t iBin = 0; iBin < raw->GetNrSamples(); iBin++){ - Samples[iBin] = raw->GetSamples()[iBin] - Baseline; - } - address = CbmTrdAddress::GetAddress(layerId,moduleId,sectorId,rowId,columnId); - if (fOutputCloneArrays){ - new ((*fDigis)[fiDigi]) CbmTrdDigi(address, - raw->GetFullTime(),//57,14 ns per timestamp - raw->GetTriggerType(), raw->GetInfoType(), raw->GetStopType(), - raw->GetNrSamples(), Samples); - } - delete[] Samples; - if (combiIt->first - lastCombiID != 1 && digiIndices.size() > 0){ - address = CbmTrdAddress::GetAddress(layerId,moduleId,sectorId,rowId,columnId); - if (fOutputCloneArrays){ - //new ((*fClusters)[fiCluster]) CbmTrdCluster(digiIndices,address); - } - digiIndices.clear(); - fiCluster++; - } - digiIndices.push_back(fiDigi); - lastCombiID = combiIt->first; - fiDigi++; - } - if (digiIndices.size() > 0){ - address = CbmTrdAddress::GetAddress(layerId,moduleId,sectorId,rowId,columnId); - if (fOutputCloneArrays){ - //new ((*fClusters)[fiCluster]) CbmTrdCluster(digiIndices,address); - } - digiIndices.clear(); - fiCluster++; - } - } - } - //LOG(info) << "CbmTrdTimeCorrel::ClusterizerSpace Digis:" << mapDigiCounter; - //CleanUpBuffers(); -} -// ------------------------------------------------------------------------- -void CbmTrdTimeCorrel::CleanUpBuffers() -{ - LOG(info) << "CleanUpBuffers"; - //LOG(info) << "fMessageBuffer.size() " << fMessageBuffer.size(); - for (std::map<TString, std::map<ULong_t, std::map<Int_t, CbmSpadicRawMessage*> > >::iterator SpaSysIt = fMessageBuffer.begin(); SpaSysIt != fMessageBuffer.end(); SpaSysIt++){ - //LOG(info) << " (SpaSysIt->second).size() " << (SpaSysIt->second).size(); - for (std::map<ULong_t, std::map<Int_t, CbmSpadicRawMessage*> >::iterator TimeIt = SpaSysIt->second.begin(); TimeIt != SpaSysIt->second.end(); TimeIt++){ - //LOG(info) << " (TimeIt->second).size() " << (TimeIt->second).size(); - for (std::map<Int_t, CbmSpadicRawMessage*> ::iterator CombiIt = TimeIt->second.begin(); CombiIt != TimeIt->second.end(); CombiIt++){ - //LOG(info) << " (CombiIt->second).size() " << (CombiIt->second).size(); - if(CombiIt->second != NULL){ - delete CombiIt->second; - } - } - TimeIt->second.clear(); - } - SpaSysIt->second.clear(); - } - fMessageBuffer.clear(); - /*for (auto ptr :fLinearHitBuffer) - delete ptr;*/ - fLinearHitBuffer.clear(); - fClusterBuffer.clear (); - //fDigis->Clear("C"); - //fClusters->Clear("C"); -} -// ------------------------------------------------------------------------- -Int_t CbmTrdTimeCorrel::GetMessageType(CbmSpadicRawMessage* raw) -{ - Int_t messageType = -1; - - if (raw->GetEpoch()) - messageType = 0; - else if (raw->GetEpochOutOfSynch()) - messageType = 1; - else if (raw->GetHit()) - messageType = 2; - else if (raw->GetHitAborted()) - messageType = 3; - else if (raw->GetOverFlow()) - messageType = 5; - else if (raw->GetInfo()) - messageType = 4; - else if (raw->GetStrange()) - messageType = 6; - - return messageType; -} -// ---- ------------------------------------------------------- -void CbmTrdTimeCorrel::ReLabelAxis(TAxis* axis, TString type, Bool_t underflow, Bool_t overflow) -{ - Int_t startBin(1), stopBin(axis->GetNbins()); - if (underflow){ - axis->SetBinLabel(1,"underflow -1"); - startBin++; - } - if (overflow){ - axis->SetBinLabel(axis->GetNbins(),"Type out of array"); - stopBin--; - } - TString messageTypes[7] = {"Epoch", - "Epoch out of synch", - "Hit", - "Hit aborted", - "Info", - "Overflow", - "Strange"}; - TString triggerTypes[4] = { "Global trigger", - "Self triggered", - "Neighbor triggered", - "Self and neighbor triggered"}; - TString stopTypes[6] = {"Normal end of message", - "Channel buffer full", - "Ordering FIFO full", - "Multi hit", - "Multi hit and channel buffer full", - "Multi hit and ordering FIFO full"}; - TString infoTypes[7] = {"Channel disabled during message building", - "Next grant timeout", - "Next request timeout", - "New grant but channel empty", - "Corruption in message builder", - "Empty word", - "Epoch out of sync"}; - if (type == "infoType") { - if (stopBin - startBin == 7){ - for (Int_t iBin = startBin; iBin < stopBin; iBin++) - axis->SetBinLabel(iBin,infoTypes[iBin-startBin]); - } else { - LOG(error) << " axis could not be labeled with " << type << ". Wrong number of bins in histogram."; - } - } else if (type == "triggerType") { - if (stopBin - startBin == 4){ - for (Int_t iBin = startBin; iBin < stopBin; iBin++) - axis->SetBinLabel(iBin,triggerTypes[iBin-startBin]); - } else { - LOG(error) << " axis could not be labeled with " << type << ". Wrong number of bins in histogram."; - } - } else if (type == "stopType") { - if (stopBin - startBin == 6){ - for (Int_t iBin = startBin; iBin < stopBin; iBin++) - axis->SetBinLabel(iBin,stopTypes[iBin-startBin]); - } else { - LOG(error) << " axis could not be labeled with " << type << ". Wrong number of bins in histogram."; - } - } else if (type == "messageType") { - if (stopBin - startBin == 7){ - for (Int_t iBin = startBin; iBin < stopBin; iBin++) - axis->SetBinLabel(iBin,messageTypes[iBin-startBin]); - } else { - LOG(error) << " axis could not be labeled with " << type << ". Wrong number of bins in histogram."; - } - } else { - LOG(error) << type << " not known "; - } - -} -// ---- ------------------------------------------------------- -void CbmTrdTimeCorrel::CreateHistograms() -{ - - TString spadicName = ""; - TString runName=""; - if(fRun!=0) runName=Form(" (Run %d)",fRun); - TString histName=""; - TString title=""; - - /* - TString channelName[32] = { "00", "01", "02", "03", "04", "05", "06", "07", "08", "09", - "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", - "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", - "30", "31"}; - */ - TString triggerTypes[4] = { "Global trigger", - "Self triggered", - "Neighbor triggered", - "Self and neighbor triggered"}; - TString stopTypes[6] = {"Normal end of message", - "Channel buffer full", - "Ordering FIFO full", - "Multi hit", - "Multi hit and channel buffer full", - "Multi hit and ordering FIFO full"}; - /* - TString infoTypes[8] = {"Channel disabled during message building", - "Next grant timeout", - "Next request timeout", - "New grant but channel empty", - "Corruption in message builder", - "Empty word", - "Epoch out of sync", - "infoType out of array"}; //not official type, just to monitor overflows - */ - - fSpadics = NrOfActiveSyscores*NrOfActiveSpadics; - - - - Int_t n = 0; - - fHM->Add("Trigger", new TH1F("Trigger", "Trigger", fSpadics,0,fSpadics)); - for(Int_t syscore = 0; syscore < NrOfActiveSyscores; ++syscore) { - for(Int_t spadic = 0; spadic < NrOfActiveSpadics; ++spadic) { - spadicName = GetSpadicName(syscore, spadic, kDirectOutput); - if(spadicName != "") { - n++; - fHM->H1("Trigger")->GetXaxis()->SetBinLabel(n,spadicName); - } - } - } - - fHM->Add("MessageCount", new TH1D("MessageCount","MessageCount",fSpadics*8,0,fSpadics*8)); - n = 0; - for(Int_t syscore = 0; syscore < NrOfActiveSyscores; ++syscore) { - for(Int_t spadic = 0; spadic < NrOfActiveSpadics; ++spadic) { - spadicName = GetSpadicName(syscore, spadic, kDirectOutput,kFullSpadic); - if(spadicName != "") { - fHM->Add((spadicName + TString("_LostCount_vs_PadID")).Data(), new TH2D((spadicName + TString("_LostCount_vs_PadID")).Data(),(spadicName + TString("_LostCount_vs_PadID")).Data(),257,-0.5,256.5,32,-0.5,31.5)); - fHM->H2((spadicName + TString("_LostCount_vs_PadID")).Data())->GetXaxis()->SetTitle("LostMessages"); - fHM->H2((spadicName + TString("_LostCount_vs_PadID")).Data())->GetYaxis()->SetTitle("PadID"); - fHM->Add((spadicName + TString("_CluterSize")).Data(), new TH1D((spadicName + TString("_ClusterSize")).Data(),(spadicName + TString("_ClusterSize")).Data(),32,-0.5,31.5)); - for(Int_t stopType = 0; stopType < 6; ++stopType) { - n++; - fHM->H1("MessageCount")->GetXaxis()->SetBinLabel(n,TString(spadicName+"_"+stopTypes[stopType])); - } - n++; - fHM->H1("MessageCount")->GetXaxis()->SetBinLabel(n,TString(spadicName+"_Info or epoch mess")); - n++; - fHM->H1("MessageCount")->GetXaxis()->SetBinLabel(n,TString(spadicName+"_Info or epoch mess n-fold")); - } - } - } - - for(Int_t syscore = 0; syscore < NrOfActiveSyscores; ++syscore) { - for(Int_t spadic = 0; spadic < NrOfActiveHalfSpadics; ++spadic) { - spadicName = GetSpadicName(syscore, spadic, kDirectOutput,kHalfSpadic); - if(spadicName != "") { - histName = spadicName + "_Time_vs_TimeSlice"; - title = histName + runName + ";TimeSlice;Time"; - fHM->Add(histName.Data(), new TH2F(histName, title, 2001, -0.5, 2000.5, 9000, 0, 90000000000)); - } - } - } - - for(Int_t syscore = 0; syscore < NrOfActiveSyscores; ++syscore) { - for(Int_t spadic = 0; spadic < NrOfActiveHalfSpadics; ++spadic) { - spadicName = GetSpadicName(syscore, spadic, kDirectOutput,kHalfSpadic); - if(spadicName != "") { - histName = spadicName + "_Epoch_vs_TimeSlice"; - title = histName + runName + ";TimeSlice;Epoch"; - fHM->Add(histName.Data(), new TH2F(histName, title, 2001, -0.5, 2000.5, 4097, -0.5, 4096.5)); - } - } - } - - for(Int_t syscore = 0; syscore < NrOfActiveSyscores; ++syscore) { - for(Int_t spadic = 0; spadic < NrOfActiveHalfSpadics; ++spadic) { - spadicName = GetSpadicName(syscore, spadic, kDirectOutput,kHalfSpadic); - if(spadicName != "") { - histName = "Hitrate_vs_Delta_Epoch_hist_for_"+spadicName; - title = histName + runName + ";DeltaEpoch;HitMessages per TimeSlice"; - fHM->Add(histName.Data(), new TH2F(histName, title, 8301, -4150.5, 4150.5, 1000, 0, 10E5)); - } - } - } - - for(Int_t syscore = 0; syscore < NrOfActiveSyscores; ++syscore) { - for(Int_t spadic = 0; spadic < NrOfActiveHalfSpadics; ++spadic) { - spadicName = GetSpadicName(syscore, spadic, kDirectOutput,kHalfSpadic); - histName = "EpochTrend_postregress_hist_for_"+spadicName; - title = histName + runName; - fHM->Add(histName.Data(), new TH2I(histName, title, 150,0.5,150.5,201,-50.5,150.5)); - } - } - - if(true){ - for(Int_t syscore = 0; syscore < NrOfActiveSyscores; ++syscore) { - for(Int_t spadic = 0; spadic < NrOfActiveSpadics; ++spadic) { - spadicName = GetSpadicName(syscore, spadic, kDirectOutput,kFullSpadic); - histName = "Trigger_Bug_Investigation_"+spadicName; - title = histName + runName; - fHM->Create2<TH2I>(histName.Data(), title.Data(), 32,-0.5,31.5, 32,-0.5,31.5); - fHM->H2(histName.Data())->GetXaxis()->SetNameTitle("Ch Self triggered","Ch Self triggered"); - fHM->H2(histName.Data())->GetYaxis()->SetNameTitle("Ch Neighbour triggered","Ch Neighbour triggered"); - } - } - } - - - for(Int_t syscore = 0; syscore < NrOfActiveSyscores; ++syscore) { - for(Int_t spadic = 0; spadic < NrOfActiveHalfSpadics; ++spadic) { - spadicName = GetSpadicName(syscore, spadic, kDirectOutput,kHalfSpadic); - if(spadicName != "") { - histName = "Delta_Epoch_hist_for_"+spadicName; - title = histName + runName; - fHM->Add(histName.Data(), new TH1I(histName, title, 8301,-4150.5,4150.5)); - } - } - } - for(Int_t syscore = 0; syscore < NrOfActiveSyscores; ++syscore) { - for(Int_t spadic = 0; spadic < NrOfActiveHalfSpadics; ++spadic) { - spadicName = GetSpadicName(syscore, spadic, kDirectOutput,kHalfSpadic); - if(spadicName != "") { - histName = "DeltaEpoch_vs_timeslice_for_"+spadicName; - title = histName + runName; - fHM->Add(histName.Data(), new TGraph()); - fHM->G1(histName.Data())->SetNameTitle(title,title); - } - } - } - for(Int_t syscore = 0; syscore < NrOfActiveSyscores; ++syscore) { - for(Int_t spadic = 0; spadic < NrOfActiveSpadics; ++spadic) { - spadicName = GetSpadicName(syscore, spadic, kDirectOutput,kFullSpadic); - if(spadicName != "") { - histName = "Map_of_Hits_for_"+spadicName; - title = histName + runName; - fHM->Create2<TH2I>(histName.Data(), title.Data(), 16,-0.5,15.5,2,-0.5,1.5); - histName = "Map_of_Charge_for_"+spadicName; - title = histName + runName; - fHM->Create2<TH2I>(histName.Data(), title.Data(), 16,-0.5,15.5,2,-0.5,1.5); - } - } - } - - // On the x axis, there is a typical eqID hardcoded so far. 57344 is equal 0xE000. - fHM->Add("SourceAvsEquipIDall", new TH2I("SourceAvsEquipIDall", "SourceAddress vs Equipment ID ALL MESS", 20,57334.5,57354.5,6,-0.5,5.5)); - fHM->Add("SourceAvsEquipIDepoch", new TH2I("SourceAvsEquipIDepoch", "SourceAddress vs Equipment ID EPOCH MESS", 20,57334.5,57354.5,6,-0.5,5.5)); - fHM->Add("SourceAvsEquipIDhit", new TH2F("SourceAvsEquipIDhit", "SourceAddress vs Equipment ID HIT MESS", 20,57334.5,57354.5,96,-0.5,5.5)); - - if(fActivateClusterizer) - for(Int_t syscore = 0; syscore < NrOfActiveSyscores; ++syscore) { - for(Int_t spadic = 0; spadic < NrOfActiveSpadics; ++spadic) { - spadicName = GetSpadicName(syscore, spadic, kDirectOutput,kFullSpadic); - if(spadicName != "") { - histName = "Clustersize_for_"+spadicName; - title = histName + runName; - fHM->Create1<TH1I>(histName.Data(), title.Data(), 16,-0.5,15.5); - histName = "Masked_"+histName; - title = histName + runName; - fHM->Create1<TH1I>(histName.Data(), title.Data(), 16,-0.5,15.5); - for (Int_t clusterSize=1; clusterSize<=16;clusterSize++){ - histName = "Cluster("+std::to_string(clusterSize)+")_Heatmap_for_"+spadicName; - title = histName + runName; - fHM->Create2<TH2I>(histName.Data(), title.Data(), 76,-0.1,15.1,2,-0.5,1.5); - } - } - } - } - if(fActivateClusterizer) - for(Int_t syscore = 0; syscore < NrOfActiveSyscores; ++syscore) { - for(Int_t spadic = 0; spadic < NrOfActiveSpadics; ++spadic) { - spadicName = GetSpadicName(syscore, spadic, kDirectOutput,kFullSpadic); - const Int_t nBins=70; - auto BinBoarders = [/*&nBins*/] (Int_t reBinHigh=32){ - const Double_t MaxFreq = (17500000.0); - // const Double_t slope=MaxFreq/nBins; - //const Int_t iThreshhold=std::ceil((MaxFreq/Threshold-0.5)/static_cast<Double_t>(reBinHigh)); - //LOG(fatal) << "iThresshold = " << iThreshhold; - Double_t* Result=new Double_t[nBins+1]; - for(Int_t i=0;i<nBins;i++){ - size_t j=nBins-i; - //Result[j]=TMath::Power(TMath::E(),i*slope+TMath::Log(2)); - Double_t LowEdge = MaxFreq/(reBinHigh*(i*i)+0.5); - Result[j]=LowEdge; - }/* - for(Int_t i=0;i<nBins-iThreshhold;i++) { - size_t j=nBins-iThreshhold-i; - Double_t LowEdge = MaxFreq/(reBinHigh*(iThreshhold)+0.5+RebinLow*(i)); - Result[j]=LowEdge; - }*/ - Result[0]=0.0; - std::sort(Result,&Result[nBins]); - return Result; - }; - Double_t* freqbins = (BinBoarders()); - //spadicName = RewriteSpadicName(Form("SysCore%01d_Spadic%01d", syscore, spadic)); - histName = "Hitfrequency_for_"+spadicName; - title = histName + runName; - //TH2* tempHist= new TH2D(histName.Data(), title.Data(),40000,0,400,nBins,freqbins); - //delete[] freqbins; - fHM->Add(histName.Data(),new TGraph()); - fHM->G1(histName.Data())->GetXaxis()->SetNameTitle("Time t/s","Time t/s"); - fHM->G1(histName.Data())->SetNameTitle(histName.Data(),histName.Data()); - fHM->G1(histName.Data())->GetYaxis()->SetNameTitle("Hitfrequency f/Hz","Hitfrequency f/Hz"); - histName = "Clusterfrequency_for_"+spadicName; - title = histName + runName; - TH2* tempHist= new TH2D(histName.Data(), title.Data(),40000,0,4000,nBins,freqbins); - fHM->Add(histName.Data(),tempHist); - fHM->H2(histName.Data())->GetXaxis()->SetNameTitle("Time t/s","Time t/s"); - fHM->H2(histName.Data())->GetYaxis()->SetNameTitle("Clusterfrequency f/Hz","Clusterfrequency f/Hz"); - /* - * fHM->Create2<TH2I>(histName.Data(), title.Data(),2000,-0.5,1999.5,5000,0,17600000.0); - * fHM->H2(histName.Data())->GetXaxis()->SetTitle("Full Time"); - * fHM->H2(histName.Data())->GetYaxis()->SetTitle("Hitfrequency f/Hz"); - * histName = "Masked_"+histName; - * title = histName + runName; - * fHM->Create1<TH1I>(histName.Data(), title.Data(), 16,-0.5,15.5);*/ - } - } - if(fActivateClusterizer) - if(fDrawPadResponse) - for(Int_t Size=1 ;Size <= 16; Size++) - { - for(Int_t syscore = 0; syscore < NrOfActiveSyscores; ++syscore) { - for(Int_t spadic = 0; spadic < NrOfActiveSpadics; ++spadic) { - spadicName = GetSpadicName(syscore, spadic, kDirectOutput,kFullSpadic); - histName = "Pad_Response_"+ spadicName + "_for_Clusters_of_Size_"+std::to_string(Size); - title = histName + runName; - fHM->Create2<TH2I>(histName.Data(), title.Data(), 801,-(4+0.05)*7.125,(4+0.05)*7.125,101,-0.005,1.005); - //fHM->Create3<TH3I>(histName.Data(), title.Data(), 801,-(4+0.05)*7.125,(4+0.05)*7.125,101,-0.005,1.005,100,0,1000); - fHM->H2(histName.Data())->GetXaxis()->SetTitle("Displacement frac{d}{mm}"); - fHM->H2(histName.Data())->GetYaxis()->SetTitle("Chargeratio frac{Q_{i}}{#sum_{k}^{ } Q_{k}}"); - //fHM->H3(histName.Data())->GetZaxis()->SetTitle("TotalCharge"); - histName = "Cut5_" +histName; - title = histName + runName; - fHM->Create2<TH2I>(histName.Data(), title.Data(), 801,-(4+0.05)*7.125,(4+0.05)*7.125,101,-0.005,1.005); - //fHM->Create3<TH3I>(histName.Data(), title.Data(), 801,-(4+0.05)*7.125,(4+0.05)*7.125,101,-0.005,1.005,100,0,1000); - fHM->H2(histName.Data())->GetXaxis()->SetTitle("Displacement frac{d}{mm}"); - fHM->H2(histName.Data())->GetYaxis()->SetTitle("Chargeratio frac{Q_{i}}{#sum_{k}^{ } Q_{k}}"); - //fHM->H3(histName.Data())->GetZaxis()->SetTitle("TotalCharge"); - histName = "Central_Pad_Response_"+ spadicName + "_for_Clusters_of_Size_"+std::to_string(Size); - title = histName + runName; - fHM->Create2<TH2I>(histName.Data(), title.Data(), 801,-(4+0.05)*7.125,(4+0.05)*7.125,101,-0.005,1.005); - //fHM->Create3<TH3I>(histName.Data(), title.Data(), 801,-(4+0.05)*7.125,(4+0.05)*7.125,101,-0.005,1.005,100,0,1000); - fHM->H2(histName.Data())->GetXaxis()->SetTitle("Displacement frac{d}{mm}"); - fHM->H2(histName.Data())->GetYaxis()->SetTitle("Chargeratio frac{Q_{i}}{#sum_{k}^{ } Q_{k}}"); - } - } - } - - if(fActivateClusterizer){ - for(Int_t syscore = 0; syscore < NrOfActiveSyscores; ++syscore) { - for(Int_t spadic = 0; spadic < NrOfActiveSpadics; ++spadic) { - spadicName = GetSpadicName(syscore, spadic, kDirectOutput,kFullSpadic); - TString histname = "Charge_Spectrum_for_"+spadicName; - title = histname + runName; - fHM->Create1<TH1D>(histname.Data(), title.Data(),2001,-0.5,2000.5/*,33,-0.5,32.5*/); - fHM->H1(histname.Data())->GetXaxis()->SetTitle("Cluster Charge in ADC Units"); - //fHM->H2(histname.Data())->GetYaxis()->SetTitle("ChID"); - fHM->H1(histname.Data())->GetYaxis()->SetTitle("N^{o}"); - // Integral Charge - TString histname2 = "ChargeIntegral_Spectrum_for_"+spadicName; - title = histname2 + runName; - fHM->Create1<TH1D>(histname2.Data(), title.Data(),6001,-0.5,6000.5/*,33,-0.5,32.5*/); - fHM->H1(histname2.Data())->GetXaxis()->SetTitle("Cluster Charge in ADC Units"); - fHM->H1(histname2.Data())->GetYaxis()->SetTitle("N^{o}"); - } - } - } - - for(Int_t syscore = 0; syscore < NrOfActiveSyscores; ++syscore) { - for(Int_t spadic = 0; spadic < NrOfActiveSpadics; ++spadic) { - spadicName = GetSpadicName(syscore, spadic, kDirectOutput,kFullSpadic); - histName = "Baseline_for_"+spadicName; - title = histName + runName; - fHM->Create2<TH2I>(histName.Data(), title.Data(),512,-256.5,255.5,33,-0.5,32.5); - histName = "Temp_"+histName; - title = histName + runName; - fHM->Create2<TH2I>(histName.Data(), title.Data(),512,-256.5,255.5,33,-0.5,32.5); - } - } - //Prototype for Online Baseline Monitoring - fBaselineMon->Divide(4,3); - for (Int_t syscore = 0; syscore < NrOfActiveSyscores; ++syscore) - { - for (Int_t spadic = 0; spadic < NrOfActiveSpadics; ++spadic) - { - spadicName = GetSpadicName (syscore, spadic, kDirectOutput, - kFullSpadic).Data (); - TString Histname = "Baseline_for_" + spadicName; - fBaselineMon->cd (syscore + spadic * 4 + 1)->SetLogz();; - fHM->H2 (Histname.Data ())->Draw ("colz2"); - } - } - - //Cluster Coincidences - { - histName="Cluster_Coincidences"; - title = histName + runName; - fHM->Create2<TH2I>(histName.Data(), title.Data(),461,-32.5,32.5,100,0,100); - } - - if (fDrawClustertypes){ - for(Int_t syscore = 0; syscore < NrOfActiveSyscores; ++syscore) { - for(Int_t spadic = 0; spadic < NrOfActiveSpadics; ++spadic) { - spadicName = GetSpadicName(syscore, spadic, kDirectOutput,kFullSpadic); - histName = "Clustertypes_for_"+spadicName; - title = histName + runName; - fHM->Create2<TH2I>(histName.Data(), title.Data(),17,-0.5,16.5,6,-0.5,5.5); - fHM->H2(histName.Data())->GetXaxis()->SetNameTitle("Clustersize in Pads","Clustersize in Pads"); - fHM->H2(histName.Data())->GetYaxis()->SetNameTitle("Clustertype","Clustertype"); - } - } - } - if (fDrawSignalDebugHistograms) { - for(Int_t syscore = 0; syscore < NrOfActiveSyscores; ++syscore) { - for(Int_t spadic = 0; spadic < NrOfActiveSpadics; ++spadic) { - spadicName = GetSpadicName(syscore, spadic, kDirectOutput,kFullSpadic); - for(Int_t TriggerType =0;TriggerType<4;TriggerType++){ - histName = "MaxADC_vs_NrSamples_for_"+spadicName+"_"+triggerTypes[TriggerType]; - title = histName + runName; - fHM->Create2<TH2I>(histName.Data(), title.Data(),33,-0.5,32.5,512,-256.5,255.5); - fHM->H2(histName.Data())->GetXaxis()->SetTitle("NrSamples"); - fHM->H2(histName.Data())->GetYaxis()->SetTitle("MaxADC"); - histName = "avgBaseline_vs_NrSamples_for_"+spadicName+"_"+triggerTypes[TriggerType];; - title = histName + runName; - fHM->Create2<TH2I>(histName.Data(), title.Data(),33,-0.5,32.5,512,-256.5,255.5); - fHM->H2(histName.Data())->GetXaxis()->SetTitle("NrSamples"); - fHM->H2(histName.Data())->GetYaxis()->SetTitle("averagedBaseline"); - vector<string> Hittypes = {"_Hits","_MultiHits"}; - for (string Hittype : Hittypes){ - histName = "MaxADC_vs_avgBaseline_for_"+spadicName+Hittype+"_"+triggerTypes[TriggerType]; - title = histName + runName; - fHM->Create2<TH2I>(histName.Data(), title.Data(),512,-256.5,255.5,512,-256.5,255.5); - fHM->H2(histName.Data())->GetXaxis()->SetTitle("averagedBaseline"); - fHM->H2(histName.Data())->GetYaxis()->SetTitle("MaxADC"); - histName = "Exp_Decay" +histName; - title = histName + runName; - fHM->Create2<TH2I>(histName.Data(), title.Data(),512,-256.5,255.5,512,-256.5,255.5); - fHM->H2(histName.Data())->GetXaxis()->SetTitle("averagedBaseline"); - fHM->H2(histName.Data())->GetYaxis()->SetTitle("MaxADC"); - histName = "First_Sample_vs_last_Sample_for_"+spadicName+Hittype+"_"+triggerTypes[TriggerType]; - title = histName + runName; - fHM->Create2<TH2I>(histName.Data(), title.Data(),512,-256.5,255.5,512,-256.5,255.5); - fHM->H2(histName.Data())->GetXaxis()->SetTitle("Letztes Sample"); - fHM->H2(histName.Data())->GetYaxis()->SetTitle("Erstes Sample"); - histName = "Exp_Decay" +histName; - title = histName + runName; - fHM->Create2<TH2I>(histName.Data(), title.Data(),512,-256.5,255.5,512,-256.5,255.5); - fHM->H2(histName.Data())->GetXaxis()->SetTitle("Letztes Sample"); - fHM->H2(histName.Data())->GetYaxis()->SetTitle("Erstes Sample"); - - - } - histName = "avgBaseline_for_"+spadicName+"_"+triggerTypes[TriggerType]; - title = histName + runName; - fHM->Create1<TH1I>(histName.Data(), title.Data(),512,-256.5,255.5); - fHM->H1(histName.Data())->GetXaxis()->SetTitle("averagedBaseline"); - } - } - } - } - { - for (Int_t syscore = 0; syscore < NrOfActiveSyscores; ++syscore) { - for (Int_t spadic = 0; spadic < NrOfActiveSpadics; ++spadic) { - spadicName = GetSpadicName(syscore, spadic, kDirectOutput, - kFullSpadic); - for (Int_t Channel = 0; Channel < 32; Channel++) { - histName = "Signalshape_for_" + spadicName + "Channel" - + std::to_string(Channel); - title = histName + runName; - fHM->Create2<TH2I>(histName.Data(), title.Data(), 33, -0.5, - 32.5, 512, -256.5, 255.5); - } - } - } - } - - fHM->Add("TsCounter", new TGraph()); - fHM->G1("TsCounter")->SetNameTitle("TsCounter","TsCounter"); - //TODO: Refactor TGraphs - { - vector<string> graphnames={ - "Baselinetrend_", - "TsCounterHit_", - "TsCounterHitAborted_", - "TsCounterOverflow_", - "TsLost_", - "TsCounterInfo_", - "TsCounterEpoch_", - "TsCounterStrange_", - "TsStrangeness_", - "TSTime_" - }; - std::vector<Int_t> spadicList(NrOfActiveHalfSpadics); - std::iota(spadicList.begin(),spadicList.end(),0); - for (const string& graphName : graphnames){ - for(Int_t syscore = 0; syscore < NrOfActiveSyscores; ++syscore) { - for(auto spadic : spadicList) { - kSpadicType SpadicType; - if(graphName=="Baselinetrend_"){ - SpadicType=kFullSpadic; - if(spadic>=NrOfActiveSpadics)continue; - }else{ - SpadicType= kHalfSpadic; - } - spadicName = GetSpadicName(syscore, spadic, kDirectOutput,SpadicType); - TGraph* currentGraph = new TGraph(); - fHM->Add(graphName+spadicName.Data(),currentGraph); - currentGraph->SetNameTitle((graphName+spadicName).Data(),(graphName+spadicName).Data()); - currentGraph->GetXaxis()->SetTitle("Timeslice"); - if(graphName=="Baselinetrend_")currentGraph->GetYaxis()->SetTitle("Baseline"); - } - } - } - } - fHM->Add("DoubleMessage_MessageType", new TH2I("DoubleMessage_MessageType","DoubleMessage_MessageType",8,-1.5,6.5,8,-1.5,6.5)); - fHM->H2("DoubleMessage_MessageType")->GetYaxis()->SetTitle("MessageType TClonesArray"); - fHM->H2("DoubleMessage_MessageType")->GetXaxis()->SetTitle("MessageType Buffer Map"); - - fHM->Add("TriggerType_vs_InfoType", new TH2I("TriggerType_vs_InfoType","TriggerType_vs_InfoType",5,-1.5,3.5,9,-1.5,7.5)); - fHM->H2("TriggerType_vs_InfoType")->GetYaxis()->SetTitle("InfoType"); - fHM->H2("TriggerType_vs_InfoType")->GetXaxis()->SetTitle("TriggerType"); - - fHM->Add("TriggerType_vs_StopType", new TH2I("TriggerType_vs_StopType","TriggerType_vs_StopType",5,-1.5,3.5,7,-1.5,5.5)); - fHM->H2("TriggerType_vs_StopType")->GetYaxis()->SetTitle("StopType"); - fHM->H2("TriggerType_vs_StopType")->GetXaxis()->SetTitle("TriggerType"); - - fHM->Add("InfoType_vs_StopType", new TH2I("InfoType_vs_StopType","InfoType_vs_StopType",9,-1.5,7.5,7,-1.5,5.5)); - fHM->H2("InfoType_vs_StopType")->GetYaxis()->SetTitle("StopType"); - fHM->H2("InfoType_vs_StopType")->GetXaxis()->SetTitle("InfoType"); - - fHM->Add("NrSamples_vs_StopType", new TH2I("NrSamples_vs_StopType","NrSamples_vs_StopType",34,-1.5,32.5,7,-1.5,5.5)); - fHM->H2("NrSamples_vs_StopType")->GetXaxis()->SetTitle("Nr. of Samples per Message"); - fHM->H2("NrSamples_vs_StopType")->GetYaxis()->SetTitle("StopType"); - - fHM->Add("NrSamples_vs_TriggerType", new TH2I("NrSamples_vs_TriggerType","NrSamples_vs_TriggerType",34,-1.5,32.5,5,-1.5,3.5)); - fHM->H2("NrSamples_vs_TriggerType")->GetXaxis()->SetTitle("Nr. of Samples per Message"); - fHM->H2("NrSamples_vs_TriggerType")->GetYaxis()->SetTitle("TriggerType"); - - fHM->Add("NrSamples_vs_InfoType", new TH2I("NrSamples_vs_InfoType","NrSamples_vs_InfoType",34,-1.5,32.5,9,-1.5,7.5)); - fHM->H2("NrSamples_vs_InfoType")->GetXaxis()->SetTitle("Nr. of Samples per Message"); - fHM->H2("NrSamples_vs_InfoType")->GetYaxis()->SetTitle("InfoType"); - - fHM->Add("InfoType_vs_Channel", new TH2I("InfoType_vs_Channel","InfoType_vs_Channel",35,-1.5,33.5,10,0.5,10.5)); - fHM->H2("InfoType_vs_Channel")->GetXaxis()->SetTitle("Channel"); - fHM->H2("InfoType_vs_Channel")->GetYaxis()->SetTitle("Info or Type"); - - fHM->Add("Hit_Coincidences", new TH2I("Hit_Coincidences","Hit_Coincidences",64,-0.5,63.5,64,-0.5,63.5)); - fHM->H2("Hit_Coincidences")->GetXaxis()->SetTitle("SpadicChannel"); - fHM->H2("Hit_Coincidences")->GetYaxis()->SetTitle("SpadicChannel"); - - fHM->Add("Correlation_Map", new TH2I("Correlation_Map","Correlation_Map",63,-31.5,31.5,21,-0.5,20.5)); - fHM->H2("Correlation_Map")->GetXaxis()->SetTitle("#Delta Pad"); - fHM->H2("Correlation_Map")->GetYaxis()->SetTitle("#Delta Time (1 timestamp = 57 ns)"); - - - for (auto i : fCorrmaps){ - histName="Correlation_Map_"+i.first+"_"+i.second; - fHM->Add(histName.Data(), new TH2I(histName.Data(),histName.Data(),63,-31.5,31.5,200,-0.5,20000.5)); - fHM->H2(histName.Data())->GetXaxis()->SetTitle("#Delta Pad"); - fHM->H2(histName.Data())->GetYaxis()->SetTitle("#Delta Time (1 timestamp = 57 ns)"); - } -} - -// ---- ------------------------------------------------------- - Int_t CbmTrdTimeCorrel::GetModuleID(CbmSpadicRawMessage* raw) - { - if (raw == NULL){ - LOG(error) << "CbmTrdRawBeamProfile::GetModuleID: CbmSpadicRawMessage == NULL"; - return -1; - } else { - return GetLayerID(raw); - } - } - // ---- ------------------------------------------------------- -void CbmTrdTimeCorrel::FitBaseline() { - if (!fCalculateBaseline) { - return; - } - TString outfile = FairRootManager::Instance()->GetOutFile()->GetName(); - outfile.ReplaceAll(".root", "_Calibration.root"); - TFile CalibrationFile(outfile, "RECREATE"); - CalibrationFile.cd(); - vector<TFitResult> FitResults; - //TODO: Refine fits based on previous iterations - //DONE: Check for Rootfile of fits and import them - for(Int_t syscore = 0; syscore < NrOfActiveSyscores; ++syscore) { - for(Int_t spadic = 0; spadic < NrOfActiveSpadics; ++spadic) { - string spadicName = GetSpadicName(syscore, spadic, kDirectOutput,kFullSpadic).Data(); - string histName = "Baseline_for_" + spadicName; - TH2* BaselineHistogram2D = fHM->H2(histName); - for (Int_t ChannelID = 0; ChannelID < 32; ChannelID++) { - TH1D* BaselineProjection = BaselineHistogram2D->ProjectionX("_px", - ChannelID + 1, ChannelID + 1); - if (BaselineProjection->GetEntries() < 50) - continue; - TFitResultPtr Baselinefit = BaselineProjection->Fit("gaus", "MQS", "", - -253, 253); - TString fitname = "Fit_Baseline_for_" - + spadicName + "_Channel_" - + std::to_string (ChannelID); - Baselinefit->SetName(fitname); - FitResults.push_back(*Baselinefit); - //Baselinefit->Print("V "); - } - } - } - for (auto x : FitResults) { - x.Write(); - } - FairRootManager::Instance()->GetOutFile()->cd(); - CalibrationFile.Close(); -} - -// ---- ------------------------------------------------------- -void CbmTrdTimeCorrel::FitPRF() { - TString outfile = FairRootManager::Instance()->GetOutFile()->GetName(); - FairRootManager::Instance()->GetOutFile()->cd(); - vector<TFitResult> FitResults; - auto PRFLambda =[&](Double_t Displacement, Double_t * Parameters) - { - Double_t d = Displacement; - Double_t K3 = Parameters[0]; - Double_t A = Parameters[2]; - Double_t SqrtK3 = sqrt(K3); - Double_t W=Parameters[3]; - Double_t h = Parameters[1]; - - return std::fabs( - - A / (2. * atan(SqrtK3)) * ( - std::atan(SqrtK3 * std::tanh(TMath::Pi() * (-2. + SqrtK3 ) * (W + 2.* d) / (8.* h) )) + - std::atan(SqrtK3 * std::tanh(TMath::Pi() * (-2. + SqrtK3 ) * (W - 2.* d) / (8.* h) )) - ) - ); - }; - TF1* PRF = - new TF1 ( - "PRF",[&PRFLambda](double*x, double *p){ return PRFLambda(x[0],p);} - ,-10.0, 10.0, 4); - //TODO: Check for Rootfile of fits - auto MPVProfile = [&](TH2* PRFHist,Int_t size=3){ - TString ProfileName= "Profile_"; - ProfileName +=PRFHist->GetName(); - TProfile* PRFProfile = new TProfile(ProfileName.Data(),ProfileName.Data(), 1001,-(size+0.05)*7.125,(size+0.05)*7.125); - TF1* MPVFkt = new TF1("MPVFkt","gaus",0,1); - MPVFkt->SetParameters(100,0.5,0.125); - MPVFkt->SetParLimits(1,0,1); - MPVFkt->SetParLimits(2,0,1); - if (PRFHist->GetEntries() < 50) return PRFProfile; - TH1D* TempProfile=nullptr; - for (Int_t BinX=1;BinX<=1001;BinX++){ - TempProfile=PRFHist->ProjectionY("_px",BinX,BinX); - //std::cout <<BinX << " " << TempProfile->GetEntries()<< std::endl; - if (TempProfile->GetEntries() < 1)continue; - TFitResultPtr MPVFit = TempProfile->Fit(MPVFkt, "MQS","",0,1.0); - if(MPVFit->GetParams()==nullptr) continue; - Double_t Mean=MPVFit->Parameter(1); - Double_t Sigma=(MPVFit->Parameter(2)); - //std::cout <<BinX << " " << Mean << " " << Sigma << std::endl; - PRFProfile->Fill(PRFProfile->GetBinCenter(BinX),Mean,TempProfile->GetEntries()); - PRFProfile->SetBinError((BinX),Sigma); - } - delete TempProfile; - delete MPVFkt; - return PRFProfile; - }; - for (Int_t size=3;size<=4;size++) - for (Int_t Detector = 0; Detector <= NrOfSpadics / 2; Detector++) { - string Detectorname = (Detector == 0 ? "Frankfurt" : "Muenster"); - string histName = "Pad_Response_" + Detectorname - + "_for_Clusters_of_Size_" + std::to_string(size); - TH2* PRFHist = fHM->H2(histName); - if (PRFHist->GetEntries() < 50) - continue; - //TString ProfileName ="Profile_"+histName; - TCanvas *c1 = new TCanvas("c1","",1600,600); - TH1* PRFProfile = MPVProfile(PRFHist); - PRFProfile->Draw("E1"); - PRFProfile->Write(); - PRF->SetParameters(0.1,3.5,1,7.125); - PRF->SetParName(0,"K3"); - //PRF->FixParameter(0,0.92); - //PRF->SetParLimits(0,0.78,0.92); - PRF->SetParName(1,"h"); - PRF->FixParameter(1,3.5); - PRF->SetParName(2,"A"); - PRF->FixParameter(2,1.0); - //PRF->SetParLimits(2,0.99999,1.00001); - PRF->SetParName(3,"W"); - PRF->FixParameter(3,7.125); - PRF->Draw(); - c1->Update(); - TString fitname = "Fit_PRF_" + histName; - c1->SaveAs("pics/Pre_"+fitname+".pdf"); - c1->SaveAs("pics/Pre_"+fitname+".png"); - c1->Clear(); - PRFProfile->Draw("E2"); - TFitResultPtr PRFFit = PRFProfile->Fit(PRF, "S", "", -10.0, 10.0); - PRFFit->SetName(fitname); - FitResults.push_back(*PRFFit); - PRFFit->Print("V"); - c1->Update(); - c1->SaveAs("pics/"+fitname+".pdf"); - c1->SaveAs("pics/"+fitname+".png"); - delete c1; - std::cout << std::endl; - std::cout << "Fits " << Detectorname << " " << FitResults.size() - << std::endl; - } - outfile.ReplaceAll(".root", "_Calibration.root"); - TFile CalibrationFile(outfile, "UPDATE"); - CalibrationFile.cd(); - for (auto x : FitResults) { - x.Write(); - } - FairRootManager::Instance()->GetOutFile()->cd(); - CalibrationFile.Close(); -} - -// ---- ------------------------------------------------------- -Int_t CbmTrdTimeCorrel::GetSpadicID(Int_t sourceA) -{ - //TString spadic=""; - Int_t SpaId = -1; - switch (sourceA) { - case (SpadicBaseAddress+0): // first spadic - //spadic="Spadic0"; - SpaId = 0; - break; - case (SpadicBaseAddress+1): // first spadic - //spadic="Spadic0"; - SpaId = 1; - break; - case (SpadicBaseAddress+2): // second spadic - //spadic="Spadic1"; - SpaId = 2; - break; - case (SpadicBaseAddress+3): // second spadic - //spadic="Spadic1"; - SpaId = 3; - break; - case (SpadicBaseAddress+4): // third spadic - //spadic="Spadic2"; - SpaId = 4; - break; - case (SpadicBaseAddress+5): // third spadic - //spadic="Spadic2"; - SpaId = 5; - break; - default: - LOG(error) << "Source Address " << sourceA << " not known."; - break; - } - return SpaId; -} -// ---- ------------------------------------------------------- -Int_t CbmTrdTimeCorrel::GetSyscoreID(Int_t eqID) -{ - Int_t SyscoreID=eqID-BaseEquipmentID; - if((SyscoreID<0||SyscoreID>NrOfActiveSyscores)){ - LOG(error) << "EqID " << eqID << " not known."; - SyscoreID=-1; - } - return SyscoreID; -} -// ---- ------------------------------------------------------- -TString CbmTrdTimeCorrel::GetStopName(Int_t stopType) -{ - TString stopName=""; - switch (stopType) { - case (-1): - stopName="Info or epoch mess"; - break; - case (0): - stopName="Normal end of message"; - break; - case (1): - stopName="Channel buffer full"; - break; - case (2): - stopName="Ordering FIFO full"; - break; - case (3): - stopName="Multi hit"; - break; - case (4): - stopName="Multi hit and channel buffer full"; - break; - case (5): - stopName="Multi hit and ordering FIFO full"; - break; - default: - LOG(error) << "stopType " << stopType << " not known."; - break; - } - return stopName; -} - -TString CbmTrdTimeCorrel::RewriteSpadicName(TString spadicName) -{ - if(spadicName=="SysCore_0_Spadic_0") { - if(fRewriteSpadicName) spadicName="Frankfurt"; - }else if(spadicName=="SysCore_0_Spadic_1"){ - if(fRewriteSpadicName) spadicName="Muenster"; - }else{ - spadicName=""; - } - - return spadicName; -} - -// ---- ------------------------------------------------------- - Int_t CbmTrdTimeCorrel::GetChannelOnPadPlane(Int_t SpadicChannel) - { - Int_t channelMapping[32] = {31,15,30,14,29,13,28,12,27,11,26,10,25, 9,24, 8, - 23, 7,22, 6,21, 5,20, 4,19, 3,18, 2,17, 1,16, 0}; - if (SpadicChannel < 0 || SpadicChannel > 31){ - if (SpadicChannel !=-1) LOG(error) << "CbmTrdTimeCorrel::GetChannelOnPadPlane ChId " << SpadicChannel; - return -1; - } else { - return channelMapping[SpadicChannel]; - } - } - -//--------------------------------------------------------------------------- - Int_t CbmTrdTimeCorrel::GetSectorID(CbmSpadicRawMessage*)// To be used to create CbmTrdDigis - { - return 0; - } -//--------------------------------------------------------------------------- -Int_t CbmTrdTimeCorrel::GetRowID(CbmSpadicRawMessage* raw)// To be used to create CbmTrdDigis -{ - Int_t sourceA = raw->GetSourceAddress(); - Int_t chID = raw->GetChannelID(); - Int_t spaID = GetSpadicID(sourceA); - if(chID > -1 && chID < 16 && spaID%2==1) chID+=16; // eqID ? - Int_t padID = GetChannelOnPadPlane(chID);// Remapping from ASIC to pad-plane channel numbers. - if (padID > 16) - return 1; - else - return 0; -} -//--------------------------------------------------------------------------- -Int_t CbmTrdTimeCorrel::GetLayerID(CbmSpadicRawMessage* raw)// To be used to create CbmTrdDigis -{ - TString name = GetSpadicName(raw->GetEquipmentID(), raw->GetSourceAddress()); - if (name == "Frankfurt") - return 1; - else if (name == "Muenster") - return 2; - else - return -1; -} -//--------------------------------------------------------------------------- -Int_t CbmTrdTimeCorrel::GetColumnID(CbmSpadicRawMessage* raw)// To be used to create CbmTrdDigis -{ - Int_t sourceA = raw->GetSourceAddress(); - Int_t chID = raw->GetChannelID(); - Int_t spaID = GetSpadicID(sourceA); - if(chID > -1 && chID < 16 && spaID%2==1) chID+=16; // eqID ? - - Int_t columnId = GetChannelOnPadPlane(chID); - if (columnId >= 16) - columnId -= 16; - return columnId; -} -//--------------------------------------------------------------------------- -std::map<Int_t, std::map<Int_t,std::map<ULong_t, Long_t> > > CbmTrdTimeCorrel::CalculateTimestampOffsets(const EpochMap &epochBuffer) -{ - //Calculate time offsets between various Spadics - std::map<Int_t, std::map<Int_t,std::map<ULong_t, Long_t > > > epochOffsets; - //loop over all SpaIDs in the epochBuffer for base timestamps - for (auto baseSpaIDIt = epochBuffer.begin() ; baseSpaIDIt != epochBuffer.end(); ++baseSpaIDIt) - //loop over all SpaIDs in the epochBuffer for comparing timestamps - for (auto compSpaIDIt = epochBuffer.begin() ; compSpaIDIt != epochBuffer.end(); ++compSpaIDIt){ - //Retrieve SpadicID's - Int_t baseSource = baseSpaIDIt->second.begin()->second->GetSourceAddress(); - Int_t baseSpaID = GetSpadicID(baseSource); - Int_t compSource = compSpaIDIt->second.begin()->second->GetSourceAddress(); - Int_t compSpaID = GetSpadicID(compSource); - //loop over all EpochMessages in the epochBuffer for comparing timestamps - auto baseTimestampIt = baseSpaIDIt->second.begin(); - auto compTimestampIt = compSpaIDIt->second.begin(); - for ((baseTimestampIt = baseSpaIDIt->second.begin(),compTimestampIt = compSpaIDIt->second.begin());baseTimestampIt != baseSpaIDIt->second.end(); ++baseTimestampIt, ++compTimestampIt) - { - //If there are no more messages in the comparing buffer set the difference to the last known value - if(compTimestampIt == compSpaIDIt->second.end()) - { - for (auto innerIt = baseTimestampIt; innerIt != baseSpaIDIt->second.end(); ++innerIt) - { - innerIt--; - ULong_t previousTimestamp = (innerIt++)->second->GetFullTime(); - ULong_t baseTimestamp = innerIt->second->GetFullTime(); - epochOffsets[baseSpaID][compSpaID][baseTimestamp] = epochOffsets[baseSpaID][compSpaID][previousTimestamp]; - } - break; - } else{ - ULong_t baseTimestamp = baseTimestampIt->second->GetFullTime(); - ULong_t compTimestamp = compTimestampIt->second->GetFullTime(); - epochOffsets[baseSpaID][compSpaID][baseTimestamp]=static_cast<Long_t>(compTimestamp-baseTimestamp); - } - } - } - return epochOffsets; -} - - -CbmTrdTimeCorrel::Cluster::Cluster(std::vector<Int_t> * BaselineArray,Int_t initWindowsize, Int_t ChargeThreshhold = 50) : - TObject (), - fMaxStopType(0), - fEntries (), - fParametersCalculated(false), - fPreCalculatedBaseline(true), - fSyscore(0), - fSpadic (0), - fRow(0), - fType (0), - fTotalCharge (0), - fTotalIntegralCharge (0), - fMaxADC(-256), - fMaxCharge(-256), - fWindowsize(initWindowsize), - fClusterChargeThreshhold(ChargeThreshhold), - fBaseline(BaselineArray), - fFullTime(), - fHorizontalPosition (0) -{}; - -CbmTrdTimeCorrel::Cluster::~Cluster(){}; - -Bool_t CbmTrdTimeCorrel::Cluster::AddEntry(CbmSpadicRawMessage NewEntry){ - auto CompareSpadicMessages= - [&](CbmSpadicRawMessage a,CbmSpadicRawMessage b) - { - Int_t ChIDA = a.GetChannelID() + ((CbmTrdTimeCorrel::GetSpadicID(a.GetSourceAddress()) %2 == 1)? 16 : 0); - Int_t ChIDB = b.GetChannelID() + ((CbmTrdTimeCorrel::GetSpadicID(b.GetSourceAddress()) %2 == 1)? 16 : 0); - Int_t PadA = CbmTrdTimeCorrel::GetChannelOnPadPlane(ChIDA); - Int_t PadB = CbmTrdTimeCorrel::GetChannelOnPadPlane(ChIDB); - Int_t rowA = (CbmTrdTimeCorrel::GetSpadicID(a.GetSourceAddress())/2)+PadA/16; - Int_t rowB = (CbmTrdTimeCorrel::GetSpadicID(b.GetSourceAddress())/2)+PadB/16; - if(a.GetFullTime() == b.GetFullTime()) - if(rowA==rowB) - if(PadA==PadB) - return true; - return false; - }; - auto CompareSpadicMessagesSmaller= - [&](CbmSpadicRawMessage a,CbmSpadicRawMessage b) - { - Int_t ChIDA = a.GetChannelID() + ((CbmTrdTimeCorrel::GetSpadicID(a.GetSourceAddress()) %2 == 1)? 16 : 0); - Int_t ChIDB = b.GetChannelID() + ((CbmTrdTimeCorrel::GetSpadicID(b.GetSourceAddress()) %2 == 1)? 16 : 0); - Int_t PadA = CbmTrdTimeCorrel::GetChannelOnPadPlane(ChIDA); - Int_t PadB = CbmTrdTimeCorrel::GetChannelOnPadPlane(ChIDB); - Int_t rowA = (CbmTrdTimeCorrel::GetSpadicID(a.GetSourceAddress())/2)+PadA/16; - Int_t rowB = (CbmTrdTimeCorrel::GetSpadicID(b.GetSourceAddress())/2)+PadB/16; - if(rowA<rowB) - return true; - else if(rowA==rowB) - if(PadA<PadB) - return true; - return false; - }; - - fParametersCalculated = false; - fEntries.push_back(NewEntry); - std::sort(fEntries.begin(),fEntries.end(),CompareSpadicMessagesSmaller); - std::unique(fEntries.begin(),fEntries.end(),CompareSpadicMessages); - fSpadic = CbmTrdTimeCorrel::GetSpadicID(fEntries.begin()->GetSourceAddress()); - fRow = GetHorizontalMessagePosition(*(fEntries.begin()))/16; -//GetChannelOnPadPlane(fEntries.begin()->GetChannelID() + ((GetSpadicID(fEntries.begin()->GetSourceAddress()) %2 == 1)? 16 : 0))/16; - BeforeLoop: - if (fIs2D) { - for (auto it = fEntries.begin(); it != fEntries.end(); it++) { - if (((CbmTrdTimeCorrel::GetSpadicID(it->GetSourceAddress()) / 2) != fSpadic / 2)) { - fEntries.erase(it); - goto BeforeLoop; - } - } - } else { - for (auto it = fEntries.begin(); it != fEntries.end(); it++) { - if (((CbmTrdTimeCorrel::GetSpadicID(it->GetSourceAddress()) / 2) != fSpadic / 2) - || GetHorizontalMessagePosition(*it) / 16 != fRow) { - fEntries.erase(it); - goto BeforeLoop; - } - } - }//End of goto scope - return true; -} - -Int_t CbmTrdTimeCorrel::Cluster::GetTotalCharge() { - if (fParametersCalculated) { - return fTotalCharge; - } else { - CalculateParameters(); - return fTotalCharge; - } -} - - Int_t CbmTrdTimeCorrel::Cluster::GetTotalIntegralCharge() { //For Integral Charge - if (fParametersCalculated) { - return fTotalIntegralCharge; - } else { - CalculateParameters(); - return fTotalIntegralCharge; - } -} - -Bool_t CbmTrdTimeCorrel::Cluster::FillChargeDistribution(TH2* ChargeMap,TH2* CentralMap) -{ - if (!fParametersCalculated) - CalculateParameters(); - //if(fMaxStopType>0)return false; - for (auto currentMessage : fEntries ) - { - Int_t Charge = GetMaxADC(currentMessage); - Float_t ChargeRatio = static_cast<Float_t>(Charge)/static_cast<Float_t>(GetTotalCharge()); - Float_t Displacement = static_cast<Float_t>(GetHorizontalMessagePosition(currentMessage)); - Displacement -= GetHorizontalPosition(); - Displacement *= 7.125; - if(ChargeMap!=nullptr)ChargeMap->Fill(Displacement,ChargeRatio/*,fTotalCharge*/); - if(CentralMap!=nullptr && currentMessage.GetTriggerType()!=2)CentralMap->Fill(Displacement,ChargeRatio/*,fTotalCharge*/); - } - return true; -} - -inline Int_t CbmTrdTimeCorrel::Cluster::GetMaxADC(CbmSpadicRawMessage& message,Bool_t SubtractBaseline) -{ - return CbmTrdTimeCorrel::GetMaxADC(message,SubtractBaseline,fBaseline); -} - -Int_t CbmTrdTimeCorrel::GetMaxADC(CbmSpadicRawMessage& message,Bool_t SubtractBaseline,std::vector<Int_t>* fBaseline) -{ - Int_t maxADC=-255; - Int_t previousADC=-255; - Int_t NrSamples = message.GetNrSamples (); - Bool_t validHit=(NrSamples==32); - // Int_t Spadic = GetSpadicID(message.GetSourceAddress()); - Int_t Syscore = GetSyscoreID(message.GetEquipmentID()); - if(fBaseline==nullptr) SubtractBaseline=false; - for (Int_t i = 0 ; i < NrSamples ; i++){ - Int_t currentADC = *(message.GetSamples() + i); - if(currentADC > maxADC) maxADC=currentADC; - if((currentADC > previousADC) && ((currentADC - previousADC)>10)) validHit = true; - previousADC = currentADC; - } - //Int_t Baseline=GetAvgBaseline(message); - return (SubtractBaseline ? maxADC-(*fBaseline)[Syscore*NrOfHalfSpadics * 16+16*GetSpadicID(message.GetSourceAddress())+message.GetChannelID()] : maxADC); -} - -Int_t CbmTrdTimeCorrel::Cluster::GetMessageChargeIntegral(CbmSpadicRawMessage& message) -{ - Int_t maxADC=-255; - Int_t integral=0; - Bool_t validHit=false; - Int_t previousADC=-255; - Int_t NrSamples = message.GetNrSamples (); - Int_t Baseline=0; - if(!fPreCalculatedBaseline){ - for (Int_t i = NrSamples -3 ; i < NrSamples ; i++) - Baseline += *(message.GetSamples() + i); - Baseline = Baseline/3; - } - else{ - Baseline = (*fBaseline)[0*NrOfActiveHalfSpadics*16+16*GetSpadicID(message.GetSourceAddress())+message.GetChannelID()]; - } - for (Int_t i = 0 ; i < NrSamples ; i++){ - Int_t currentADC = *(message.GetSamples() + i) - Baseline; // correct each tb with the channels Baseline - integral += currentADC; - if(currentADC > maxADC) maxADC=currentADC; - if((currentADC > previousADC) && ((currentADC - previousADC)>10)) validHit = true; - } - - return (integral); -}; - - -Int_t CbmTrdTimeCorrel::GetAvgBaseline(CbmSpadicRawMessage& message,Int_t n){ - Int_t NrSamples = message.GetNrSamples (); - if(NrSamples==0||n==0) return -255; - if(NrSamples<n) n = NrSamples; - Int_t Baseline=0; - for (Int_t i = NrSamples -n ; i < NrSamples ; i++) - Baseline += *(message.GetSamples() + i); - Baseline /= n; - return Baseline; -}; - - -void CbmTrdTimeCorrel::FillBaselineHistogram(CbmSpadicRawMessage* message){ - string histName; - string spadicName = GetSpadicName(message->GetEquipmentID(), message->GetSourceAddress(),kRawData,kFullSpadic).Data(); - histName = "Temp_Baseline_for_"+spadicName; - Int_t StopType = message->GetStopType(); - if (StopType > 0) return; - //Int_t * Samples=message->GetSamples(); - //if (GetMaxADC(*message,false)>Samples[0]) return; - TH2* Histogram = fHM->H2(histName); - Int_t ChID = message->GetChannelID() + ((GetSpadicID(message->GetSourceAddress()) %2 == 1)? 16 : 0); - // Int_t NrSamples = message->GetNrSamples (); - Histogram->Fill(GetAvgBaseline(*message),ChID); - -}; - -void CbmTrdTimeCorrel::FillSignalShape(CbmSpadicRawMessage& message,string Hist){ - string histName=Hist; - if(Hist=="") return; - Int_t NrSamples = message.GetNrSamples(); - Int_t * Samples = message.GetSamples(); - TH2* Histogram = nullptr; - Histogram = fHM->H2(histName); - for (Int_t i = 0 ; i < NrSamples ; i++){ - Histogram->Fill(i,*(Samples+ i)); - } -} - -std::pair<std::vector<CbmSpadicRawMessage>::iterator,std::vector<CbmSpadicRawMessage>::iterator> CbmTrdTimeCorrel::Cluster::GetEntries() -{ - return std::make_pair(fEntries.begin(),fEntries.end()); -} - -Int_t CbmTrdTimeCorrel::Cluster::GetSpadic(){ - if(fParametersCalculated) return fSpadic; - else { - CalculateParameters(); - return fSpadic; - } -} - -Int_t CbmTrdTimeCorrel::Cluster::GetRow(){ - if(fParametersCalculated) return (static_cast<Int_t>(fHorizontalPosition)/16); - else { - CalculateParameters(); - return (static_cast<Int_t>(fHorizontalPosition)/16); - } -} - -Bool_t CbmTrdTimeCorrel::Cluster::Get2DStatus(){ - if(fParametersCalculated) return fIs2D; - else { - CalculateParameters(); - return fIs2D; - } -} - -ULong_t CbmTrdTimeCorrel::Cluster::GetFulltime(){ - if(fParametersCalculated) return fFullTime; - else { - CalculateParameters(); - return fFullTime; - } -} - - -Float_t CbmTrdTimeCorrel::Cluster::GetHorizontalPosition(){ - if(fParametersCalculated) return fHorizontalPosition; - else { - CalculateParameters(); - return fHorizontalPosition; - } -} - -Int_t CbmTrdTimeCorrel::Cluster::GetHorizontalMessagePosition(CbmSpadicRawMessage& Message){ - Int_t Position= CbmTrdTimeCorrel::GetChannelOnPadPlane(Message.GetChannelID()+((GetSpadicID(Message.GetSourceAddress())%2 == 1) ? 16 : 0 )); - return Position; -} - -Int_t CbmTrdTimeCorrel::Cluster::Type(){ - /* Get Information about the status of the Cluster - * Type 0 means that the cluster is complete (no gaps and capping TriggerType 2 messages) - * Type 1 means that the cluster is incomplete (either with gaps or without capping TriggerType 2 messages) - * Type 2 means that the cluster is hitless (no selftriggered HitMessages) - * Type 3 means that the Cluster is invalid (see Veto()) - */ - if(fParametersCalculated) return fType; - else { - CalculateParameters(); - return fType; - } -} - -void CbmTrdTimeCorrel::Cluster::Veto() { - //Abort Conditions - if (fType > 0 || size() <= 2) - return; - //secondly veto based on total charge - if (fTotalCharge <= 0) { - //std::cout << " Veto based on Threshold" << std::endl; - fType = 3; - return; - } - if (true||size()<3|| size()>4){ - if (fMaxADC >= 0) { - //std::cout << " Veto based on Threshold" << std::endl; - fType = 5; - return; - } - } else if (size() == 3) { - if ((GetMaxADC(fEntries.at(0)) > GetMaxADC(fEntries.at(1))) - || (GetMaxADC(fEntries.at(2)) > GetMaxADC(fEntries.at(1)))) { - fType = 5; - return; - } - } else if (size() == 4) { - if (((GetMaxADC(fEntries.at(0)) > GetMaxADC(fEntries.at(1))) - || (GetMaxADC(fEntries.at(3)) > GetMaxADC(fEntries.at(1)))) - || ((GetMaxADC(fEntries.at(0)) > GetMaxADC(fEntries.at(2))) - || (GetMaxADC(fEntries.at(3)) > GetMaxADC(fEntries.at(2))))) { - fType = 5; - return; - } - } - - return; - - //Lastly Veto based on Charge Distribution. - Float_t VetoThreshhold = 100.0 / (size() - 0.50); - - for (auto x : fEntries) { - Float_t ChargeRatio = 100.0 * static_cast<Float_t>(GetMaxADC(x)) - / fTotalCharge; - /* - Float_t Displacement = - static_cast<Float_t>(GetHorizontalMessagePosition(x)) - - fHorizontalPosition; - */ - if(x.GetTriggerType()==1||x.GetTriggerType()==3){ - if(ChargeRatio<VetoThreshhold) - { - fType=6; - } - - } - /* - if(x.GetTriggerType()==2) - if(x.GetTriggerType()==1||x.GetTriggerType()==3){ - if (ChargeRatio<VetoThreshhold) fType=3; - } - continue; - if (std::abs(Displacement) > (size() / 2.0)) { - //std::cout << " Veto based on width" << std::endl; - fType = 3; - return; - } else if ((x.GetTriggerType() ==1)||(x.GetTriggerType()==3)) - if (std::abs(Displacement) - <= static_cast<Float_t>((size() - 2.0) / 2.0)) { - if ((ChargeRatio < VetoThreshhold)) { - //std::cout << "Veto based on Distribution " << ChargeRatio << " " << VetoThreshhold << " " <<Displacement<< " " <<std::abs(Displacement)<< " " << static_cast<Float_t>((size()-2.0)/2.0) << std::endl; - fType = 3; - return; - } - } else if (std::abs(Displacement) - >= static_cast<Float_t>((size() - 2.0) / 2.0)) { - if (ChargeRatio >= VetoThreshhold) { - //std::cout << "Veto based on Distribution " << ChargeRatio << " " << VetoThreshhold << " " <<Displacement<< " " <<std::abs(Displacement)<< " " << static_cast<Float_t>((size()-2.0)/2.0) << std::endl; - fType = 3; - return; - } - }*/ - } -} - -std::pair<Int_t,Float_t> CbmTrdTimeCorrel::Cluster::GetPosition(){ - Int_t Detector = GetSpadic()/2; - Float_t HorPos = GetHorizontalPosition(); - return std::make_pair(Detector,HorPos); -} - -Size_t CbmTrdTimeCorrel::Cluster::size(){ - return fEntries.size(); -} - -void CbmTrdTimeCorrel::Cluster::CalculateParameters(){ - fSpadic = CbmTrdTimeCorrel::GetSpadicID(fEntries.begin()->GetSourceAddress());//GetChannelOnPadPlane(fEntries.begin()->GetChannelID() + ((GetSpadicID(fEntries.begin()->GetSourceAddress()) %2 == 1)? 16 : 0))/16; - fSyscore = CbmTrdTimeCorrel::GetSyscoreID(fEntries.begin()->GetEquipmentID()); - fType = 0; - fTotalCharge = 0; - fTotalIntegralCharge = 0; - fHorizontalPosition = 0; - fFullTime = fEntries.begin()->GetFullTime(); - fIs2D=false; - std::vector<Int_t> unweightedPosSum; - std::vector<Int_t> Charges; - std::vector<Int_t> ChargesIntegral; - Int_t NumberOfTypeTwoMessages=0; - Int_t NumberOfHits=0; - Int_t LastPad= GetHorizontalMessagePosition(*fEntries.begin())-1; - Int_t maxADC = -255; - fMaxADC=maxADC; - fMaxStopType=0; - for(auto message : fEntries){ - Int_t CurrentPad = GetHorizontalMessagePosition(message); - if (LastPad+1 != CurrentPad&&fType<3) - { - //std::cout << LastPad << " " << CurrentPad << std:: endl; - fType=1; - } - LastPad = CurrentPad; - Int_t Charge = GetMaxADC(message); // here the calculation of the Charge takes place - Int_t ChargeIntegral = GetMessageChargeIntegral(message); - maxADC = GetMaxADC(message,false); - if(maxADC > fMaxADC) fMaxADC=maxADC; - if(message.GetStopType()>fMaxStopType)fMaxStopType=message.GetStopType(); - if(Charge < 0){ - fType = 4; - } - ChargesIntegral.push_back(ChargeIntegral);//charge Integral - fTotalIntegralCharge += ChargeIntegral; - Charges.push_back(Charge);// chargemax of each message in a cluster - fTotalCharge += Charge; - unweightedPosSum.push_back(CurrentPad); - if(message.GetTriggerType()==2) NumberOfTypeTwoMessages++; - if(message.GetTriggerType()==1||message.GetTriggerType()==3) NumberOfHits++; - } - // if(!(fEntries.size()==4)) fTotalCharge = -42; - //std::cout << fEntries.size() << " " << fTotalCharge << std::endl; - - if(NumberOfTypeTwoMessages!=2) fType=1; - if(NumberOfHits==0) fType=2; - const Float_t PadWidth = 1.0;//7.0/7.125; - // const Float_t sigma = 0.646432; - if (size()<3||size()>4||fType > 0/*||(size()==2&&!(fType==1||fType==2))*/){ - for (UInt_t i=0;i<fEntries.size();i++){ - Double_t Weight = static_cast<Double_t>(Charges.at(i))/static_cast<Double_t>(fTotalCharge); - fHorizontalPosition += static_cast<Float_t>(Weight* static_cast<Double_t>(unweightedPosSum.at(i))); - } - }/*else if(size()==2){//For the special Case of size 2 Clusters reconstruction formulas for both Energy and displacement are given in [Bergmann2014] - if(fType==1){ - //First identify if the cluster is left sided or right sided - Bool_t IsLeftsided=false; //Leftsided is shorthand for the following Trigger Type composition: 2;(1|3). - IsLeftsided = (fEntries.at(0).GetTriggerType()==2 && - (fEntries.at(1).GetTriggerType()==1||fEntries.at(1).GetTriggerType()==3)); - Bool_t IsRightsided=false; //Leftsided is shorthand for the following Trigger Type composition: 2;(1|3). - IsRightsided = ((fEntries.at(0).GetTriggerType()==1||fEntries.at(0).GetTriggerType()==3) && - fEntries.at(1).GetTriggerType()==2); - if (IsLeftsided) { - Float_t Displacement = (sigma * sigma) / PadWidth - * log( static_cast<Double_t>(Charges.at(1)) - / Charges.at(0)) - PadWidth / 2; - fHorizontalPosition = Displacement + GetHorizontalMessagePosition(fEntries.at(1)); - - } else if(IsRightsided){ - Float_t Displacement = (sigma * sigma) / PadWidth - * log( static_cast<Double_t>(Charges.at(1)) - / Charges.at(0)) + PadWidth / 2; - fHorizontalPosition = Displacement + GetHorizontalMessagePosition(fEntries.at(0)); - } - }else if(fType==2){ - Float_t a = -0.19; - Float_t Displacement = a - * log(static_cast<Double_t>(Charges.at(0)) / Charges.at(1)) - + PadWidth / 2; - fHorizontalPosition = Displacement + (GetHorizontalMessagePosition(fEntries.at(0))+ GetHorizontalMessagePosition(fEntries.at(1)))/2; - } - }*/ - else if(size()==3){/* - fHorizontalPosition = PadWidth / 2.0 - * log(static_cast<Double_t>(Charges.at(2)) / static_cast<Double_t>(Charges.at(0))) - / log(static_cast<Double_t>(Charges.at(1)*Charges.at(1)) - / static_cast<Double_t>(Charges.at(0) - * Charges.at(2))); - fHorizontalPosition += GetHorizontalMessagePosition(fEntries.at(1)); - //Float_t NormalizationFactor = 1.0/(Charges.at(0)*Charges.at(0)+Charges.at(1)*Charges.at(1)); - //Float_t LeftDisplacement= - * */ - Double_t a3= TMath::Pi()*PadWidth/TMath::ACosH(0.5*(sqrt(static_cast<Double_t>(Charges.at(1))/static_cast<Double_t>(Charges.at(0)))+sqrt(static_cast<Double_t>(Charges.at(1))/static_cast<Double_t>(Charges.at(2))))); - fHorizontalPosition=a3/TMath::Pi()*TMath::ATanH((sqrt(static_cast<Double_t>(Charges.at(1))/static_cast<Double_t>(Charges.at(0)))-sqrt(static_cast<Double_t>(Charges.at(1))/static_cast<Double_t>(Charges.at(2))))/(2.0*TMath::SinH(TMath::Pi()*PadWidth/a3))); - fHorizontalPosition += GetHorizontalMessagePosition(fEntries.at(1)); - } - else if (size()==4){/* - fHorizontalPosition = PadWidth * 2.0 - * log(static_cast<Double_t>(Charges.at(2)) / static_cast<Double_t>(Charges.at(1))) - / (log(static_cast<Double_t>(Charges.at(1)) - / static_cast<Double_t>(Charges.at(3))) - + log(static_cast<Double_t>(Charges.at(2)) - / static_cast<Double_t>(Charges.at(0)))); - fHorizontalPosition += static_cast<Double_t>(GetHorizontalMessagePosition(fEntries.at(1)) - +GetHorizontalMessagePosition(fEntries.at(2)))/2.0;*/ - Double_t a3= TMath::Pi()*PadWidth/TMath::ACosH(0.5*(sqrt(static_cast<Double_t>(Charges.at(1))/static_cast<Double_t>(Charges.at(0)))+sqrt(static_cast<Double_t>(Charges.at(1))/static_cast<Double_t>(Charges.at(2))))); - Double_t EstimateLeft = a3/TMath::Pi()*TMath::ATanH((sqrt(static_cast<Double_t>(Charges.at(1))/static_cast<Double_t>(Charges.at(0)))-sqrt(static_cast<Double_t>(Charges.at(1))/static_cast<Double_t>(Charges.at(2))))/(2.0*TMath::SinH(TMath::Pi()*PadWidth/a3))); - a3= TMath::Pi()*PadWidth/TMath::ACosH(0.5*(sqrt(static_cast<Double_t>(Charges.at(2))/static_cast<Double_t>(Charges.at(1)))+sqrt(static_cast<Double_t>(Charges.at(2))/static_cast<Double_t>(Charges.at(3))))); - Double_t EstimateRight = a3/TMath::Pi()*TMath::ATanH((sqrt(static_cast<Double_t>(Charges.at(2))/static_cast<Double_t>(Charges.at(1)))-sqrt(static_cast<Double_t>(Charges.at(2))/static_cast<Double_t>(Charges.at(3))))/(2.0*TMath::SinH(TMath::Pi()*PadWidth/a3))); - EstimateRight +=1.0; - fHorizontalPosition=0.5*(EstimateLeft+EstimateRight); - fHorizontalPosition += GetHorizontalMessagePosition(fEntries.at(1)); - - } - - //fHorizontalPosition=fHorizontalPosition/(size())+Offset; - Veto(); - fParametersCalculated =true; -} - - - diff --git a/beamtime/trd/lib/CbmTrdTimeCorrel.h b/beamtime/trd/lib/CbmTrdTimeCorrel.h deleted file mode 100644 index 832d95c666ba734d1742dd988f1343601f8766c4..0000000000000000000000000000000000000000 --- a/beamtime/trd/lib/CbmTrdTimeCorrel.h +++ /dev/null @@ -1,259 +0,0 @@ -#ifndef CBMTRDTIMECORREL_H -#define CBMTRDTIMECORREL_H - -#include "FairTask.h" - -#include "CbmHistManager.h" -#include "TFitResult.h" - -#include "TClonesArray.h" -#include "CbmSpadicRawMessage.h" -//#include "CbmBeamDefaults.h" -#include <deque> -#include "TRegexp.h" -#include <cmath> -#include <numeric> -#include <utility> -#include <vector> -#include <string> - - -typedef std::map<Int_t, std::map<ULong_t, CbmSpadicRawMessage* > > EpochMap; -typedef std::map<Int_t, std::map<Int_t,std::map<ULong_t, Long_t> > > OffsetMap; - - -class CbmTrdTimeCorrel : public FairTask -{ - public: - - CbmTrdTimeCorrel(); - CbmTrdTimeCorrel(const CbmTrdTimeCorrel&) = delete; - CbmTrdTimeCorrel& operator=(const CbmTrdTimeCorrel&) = delete; - ~CbmTrdTimeCorrel(); - - virtual InitStatus Init(); - - virtual InitStatus ReInit(); - - virtual void Exec(Option_t* opt); - - virtual void SetParContainers(); - - virtual void Finish(); - - virtual void FinishEvent(); - - void SetRun(Int_t run) { fRun = run;} - void SetRewriteSpadicName(Bool_t rewrite) { fRewriteSpadicName = rewrite; } - - void ClusterizerSpace(); - - void ClusterizerTime(); - - void CleanUpBuffers(); - - private: - std::map<TString, std::map<ULong_t, std::map<Int_t, CbmSpadicRawMessage*> > > fMessageBuffer; - std::deque<CbmSpadicRawMessage*> fLinearHitBuffer; - Int_t fSpadics; - Bool_t fRewriteSpadicName; - - const Bool_t fActivateClusterizer = true; - const Bool_t fActivate2DClusterizer=false; - const Bool_t fBatchAssessment = false; - const Bool_t fDebugMode = true; - const Bool_t fDrawSignalDebugHistograms = true; - const Bool_t fDrawPadResponse = true; - Bool_t fCalculateBaseline = true; - const Bool_t fHitFrequency = true; - const Int_t fSignalShapeThreshold = -255 ; - std::vector<Int_t> fBaseline; - Int_t fClusterThreshhold=0; - const Bool_t fActivateDeltaTAnalysis = false; - const Bool_t fDrawClustertypes = true; - TCanvas * fBaselineMon; - - - enum kSpadicType{ - kHalfSpadic, - kFullSpadic - }; - enum kInputType{ - kRawData, - kProcessedData, - kDirectOutput - }; - - - static Int_t GetSpadicID(Int_t sourceA); - static Int_t GetSyscoreID(Int_t eqID); - - inline TString GetSpadicName(Int_t eqID,Int_t sourceA,kInputType InputType=kRawData,kSpadicType OutputType=kHalfSpadic); - TString RewriteSpadicName(TString spadicName); - - TString GetStopName(Int_t stopType); - - TClonesArray* fRawSpadic;//input per timeSlice - TClonesArray* fRawMessages;//output without MS overlaps including all message types without isStrange, isEpoch, isEpochOutOfSynch - TClonesArray* fDigis; - TClonesArray* fClusters; - - Int_t fiRawMessage;//counter for fRawMessages - Int_t fiDigi;//counter for fDigis - Int_t fiCluster;//counter for fClusters - - CbmHistManager* fHM; - - Int_t fNrTimeSlices; - - Int_t fRun; - - std::vector<ULong_t> fLastMessageTime; - /* Store the last message time. - Intended usage is for the first (outer) argument to be the SysCoreID - and the second (inner) to be the SPADICID of a full SPADIC. - Third argument is the ChannelID. - Timestamps are stored for a full spadic. - */ - - std::vector<Int_t> fEpochMarkerArray; - std::deque<Bool_t> fFirstEpochMarker; - - // Variables for book keeping after a regress of the Epoch counter - std::deque<Bool_t> EpochRegressTriggered; - std::vector<Int_t> EpochRegressOffset; - std::vector<Int_t> EpochRegressCounter; - inline void FillBaselineHistogram(CbmSpadicRawMessage*); - void FillSignalShape(CbmSpadicRawMessage&,std::string Hist=""); - void FillSignalShape(CbmSpadicRawMessage* message){ - FillSignalShape(*message); - } - std::vector<std::pair<TString, TString> > fCorrmaps = { std::make_pair( - GetSpadicName(0, 2, kDirectOutput, kFullSpadic), - GetSpadicName(1, 2, kDirectOutput, kFullSpadic)), std::make_pair( - GetSpadicName(1, 2, kDirectOutput, kFullSpadic), - GetSpadicName(3, 2, kDirectOutput, kFullSpadic)), std::make_pair( - GetSpadicName(2, 1, kDirectOutput, kFullSpadic), - GetSpadicName(3, 1, kDirectOutput, kFullSpadic)), std::make_pair( - GetSpadicName(0, 2, kDirectOutput, kFullSpadic), - GetSpadicName(3, 2, kDirectOutput, kFullSpadic))}; - - void CreateHistograms(); - void FitBaseline(); - void FitPRF(); - - void ReLabelAxis(TAxis* axis, TString type, Bool_t underflow, Bool_t overflow); - - Int_t GetMessageType(CbmSpadicRawMessage* raw); - - static Int_t GetChannelOnPadPlane(Int_t SpadicChannel); - static Int_t GetChannelonPadPlaneMessage(CbmSpadicRawMessage &message){ - Int_t SpaID = GetSpadicID(message.GetSourceAddress()); - Int_t ChID = message.GetChannelID(); - return GetChannelOnPadPlane(ChID + (SpaID%2)*16); - }; - - // The following block is used to generate TrdDigis - Int_t GetSectorID(CbmSpadicRawMessage* raw); - Int_t GetRowID(CbmSpadicRawMessage* raw); - Int_t GetLayerID(CbmSpadicRawMessage* raw); - Int_t GetColumnID(CbmSpadicRawMessage* raw); - Int_t GetModuleID(CbmSpadicRawMessage* raw); - static Int_t GetMaxADC(CbmSpadicRawMessage&,Bool_t = true,std::vector<Int_t>* =nullptr); - Int_t GetAvgBaseline(CbmSpadicRawMessage&,Int_t n=1); - Int_t GetAvgBaseline(CbmSpadicRawMessage* raw){ - return GetAvgBaseline(*raw); - }; - - - OffsetMap timestampOffsets; - OffsetMap CalculateTimestampOffsets(const EpochMap &epochBuffer); - - Bool_t fGraph; - Bool_t fOutputCloneArrays; - - friend class Cluster; - public: class Cluster : public TObject - { - public: - Cluster():Cluster(0){}; - Cluster(Int_t initWindowsize):Cluster(nullptr,initWindowsize, 120) {}; - Cluster(std::vector<Int_t>*,Int_t,Int_t); - ~Cluster(); - Size_t size(); - Int_t Type(); - Int_t fMaxStopType; - Int_t Windowsize(); - ULong_t GetFulltime(); - Float_t GetHorizontalPosition(); - Bool_t Get2DStatus(); - Int_t GetSpadic(); - Int_t GetRow(); - std::pair<Int_t,Float_t> GetPosition(); - Int_t GetTotalCharge(); - Int_t GetTotalIntegralCharge(); - std::pair<std::vector<CbmSpadicRawMessage>::iterator,std::vector<CbmSpadicRawMessage>::iterator> GetEntries(); - Bool_t AddEntry (CbmSpadicRawMessage); - Bool_t FillChargeDistribution(TH2*,TH2* CentralMap=nullptr); - private: - std::vector<CbmSpadicRawMessage> fEntries; - Bool_t fParametersCalculated,fIs2D=true; - Bool_t fPreCalculatedBaseline; - Int_t fSyscore,fSpadic, fRow, fType, fTotalCharge, fTotalIntegralCharge, fMaxADC, fMaxCharge, fWindowsize, fClusterChargeThreshhold; - std::vector<Int_t>* fBaseline; - ULong_t fFullTime; - Float_t fHorizontalPosition; - void CalculateParameters(); - Int_t GetHorizontalMessagePosition(CbmSpadicRawMessage&); - inline Int_t GetMaxADC(CbmSpadicRawMessage&,Bool_t = true); - Int_t GetMessageChargeIntegral(CbmSpadicRawMessage& message); - void Veto(); - }; - private: - std::deque<Cluster> fClusterBuffer; - - -// CbmTrdTimeCorrel(const CbmTrdTimeCorrel&); -// CbmTrdTimeCorrel operator=(const CbmTrdTimeCorrel&); - - ClassDef(CbmTrdTimeCorrel,1); -}; - - -TString CbmTrdTimeCorrel::GetSpadicName(Int_t eqID,Int_t sourceA,kInputType InputType,kSpadicType OutputType){ - /* Get a String of the Form "Syscore_0_Spadic_0" describing the specific SPADIC corresponding to the input parameters. - * The Parameter InputType allows either the Equipment ID/Source Address or the final Syscore/Spadic ID to be used. - * kRawData (default) is the parameter that allows the raw EqID/Source Address to be used, kProcessedData takes Syscore/SpadicID. - * The Parameter OutputType allows adressing either the corresponding FullSpadic, via kFullSpadic (default), or the original HalfSpadic, - * via kHalfSpadic. - * */ - TString spadicName=""; - Int_t SpadicID=0; - if(InputType==kRawData){ - spadicName="SysCore_"+std::to_string(GetSyscoreID(eqID))+"_"; - SpadicID=GetSpadicID(sourceA); - } - else { - spadicName="SysCore_"+std::to_string((eqID))+"_"; - SpadicID=(sourceA); - } - - if(OutputType==kFullSpadic&&InputType!=kDirectOutput){ - SpadicID/=2; - } - ; - if(OutputType==kFullSpadic){ - spadicName += "Spadic_"; - }else{ - spadicName += "Half_Spadic_"; - - } - spadicName+=std::to_string(SpadicID); - - return spadicName; -} - - -#endif - - diff --git a/beamtime/trd/tools/CbmTrdLabTools.cxx b/beamtime/trd/tools/CbmTrdLabTools.cxx deleted file mode 100644 index afa1feafbf7c44f91c7a8a880a5362cf30e56045..0000000000000000000000000000000000000000 --- a/beamtime/trd/tools/CbmTrdLabTools.cxx +++ /dev/null @@ -1,17 +0,0 @@ -/*First Version of TestBeam tools, developed for the SPS2016 beamtime and the legacy DAQ-chain. - *Intended for the F/MS Prototypes. - *For usage with Bucharest, modifications of the functions GetChannelMap and GetRowID are neccessary. -*/ - -#include "CbmTrdLabTools.h" -#include "FairLogger.h" -#include "CbmTrdAddress.h" -#include <algorithm> - -ClassImp(CbmTrdLabTools) - -CbmTrdLabTools::CbmTrdLabTools () : CbmTrdTestBeamTools() -{ - LOG(info) << TString("Default Constructor of ")+TString(this->GetName()); - Instance(this); -} diff --git a/beamtime/trd/tools/CbmTrdLabTools.h b/beamtime/trd/tools/CbmTrdLabTools.h deleted file mode 100644 index 44f5c93c82e05457c180c39a0874841cff63cc0b..0000000000000000000000000000000000000000 --- a/beamtime/trd/tools/CbmTrdLabTools.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef CBMTRDLABTOOLS_H -#define CBMTRDLABTOOLS_H - -#include "CbmTrdTestBeamTools.h" - -class CbmTrdLabTools: public CbmTrdTestBeamTools -{ - public: - CbmTrdLabTools(); - // CbmTrdLabTools():CbmTrdLabTools("CbmTrdBeamtimeTools"){}; - ~CbmTrdLabTools(){}; - - - virtual Int_t GetNrRobs(){ - return 1; - }; - virtual Int_t GetNrSpadics(Int_t = 0){ - return 1; - } - virtual Int_t GetLayerID(CbmSpadicRawMessage* /*raw*/) - { - return 0; - }; - - CbmTrdLabTools(const CbmTrdLabTools&); - CbmTrdLabTools operator=(const CbmTrdLabTools&); - public: - - ClassDef(CbmTrdLabTools,1); -}; - -#endif diff --git a/beamtime/trd/tools/CbmTrdTestBeamTools.cxx b/beamtime/trd/tools/CbmTrdTestBeamTools.cxx deleted file mode 100644 index 5974bef339158af629f0366a219e7a053f7c04fc..0000000000000000000000000000000000000000 --- a/beamtime/trd/tools/CbmTrdTestBeamTools.cxx +++ /dev/null @@ -1,545 +0,0 @@ -/*First Version of TestBeam tools, developed for the SPS2016 beamtime and the legacy DAQ-chain. - *Intended for the F/MS Prototypes. - *For usage with Bucharest, modifications of the functions GetChannelMap and GetRowID are neccessary. -*/ - -#include "CbmTrdTestBeamTools.h" -#include <FairLogger.h> -#include <algorithm> -#include <iostream> - - -ClassImp(CbmTrdTestBeamTools) - -CbmTrdTestBeamTools::CbmTrdTestBeamTools () : TObject() -{ - LOG(info) << TString("Default Constructor of ")+TString(this->GetName()); - Instance(this); -} - -CbmTrdTestBeamTools* CbmTrdTestBeamTools::Instance(CbmTrdTestBeamTools* NewInstance=nullptr){ - static CbmTrdTestBeamTools* CurrentInstance=nullptr; - if (!NewInstance&&!CurrentInstance) - CurrentInstance = new CbmTrdTestBeamTools(); - if (!NewInstance) - return CurrentInstance; - if (!CurrentInstance) - CurrentInstance=NewInstance; - if (NewInstance!=CurrentInstance) - LOG(fatal)<<"Preexisting Instance of "<< CurrentInstance->GetName(); - return CurrentInstance; -} - -UInt_t CbmTrdTestBeamTools::GetAddress(CbmSpadicRawMessage* raw){ - /*Get a unique address for the pad of the Message. - *Last 3 decimal digits comprise of the ColumnID. Range:0-255; - *Next 2 decimal digits display the Row inside the module. Range: 0-10; - *Next 2 decimal digits are the moduleID in the respective Layer. Range:0-49; - *Digit %1E5 gives the Layer. Range:0-3; - */ - Int_t ColID=GetColumnID(raw); - Int_t SectID=0;//GetSectorID(raw); - Int_t RowID=GetRowID(raw); - Int_t ModID=GetModuleID(raw); - Int_t LayerID=GetLayerID(raw); - return CbmTrdAddress::GetAddress(LayerID,ModID,SectID,RowID,ColID); -} - -Int_t CbmTrdTestBeamTools::GetModuleID(CbmSpadicRawMessage* raw) -{ - /* - * Get the numeric module ID of origin for the given message. - * The ModuleID is unique within a layer. - * SPS2016 Case: identical to RobID and LayerID - */ - return GetRobID(raw); -} - -// ---- ------------------------------------------------------- -Int_t CbmTrdTestBeamTools::GetSpadicID(CbmSpadicRawMessage* raw) -{ - /* - * Get the numerical SpadicID of origin for the given Message. - * The SpadicID is unique on the Rob. - */ - //TString spadic=""; - Int_t sourceA = raw->GetSourceAddress(); - Int_t SpaId = sourceA-GetSpadicBaseAddress(); - if (SpaId<0||SpaId>5){ - LOG(error) << "Source Address " << sourceA << " not known."; - SpaId = -1; - } - return SpaId; -} - -Int_t CbmTrdTestBeamTools::GetRobID(CbmSpadicRawMessage* raw) -{ - /* - * Get the numerical RobId of origin for the given Message. - * SPS2016 Case: Numerical id of the syscore on which the spadic was connected. - */ - Int_t eqID=raw->GetEquipmentID(); - Int_t SyscoreID=eqID-GetBaseEquipmentID(); - if((SyscoreID<0||SyscoreID>GetNrRobs())){ - LOG(error) << "EqID " << eqID << " not known."; - SyscoreID=-1; - } - return SyscoreID; -} - -Int_t CbmTrdTestBeamTools::GetLayerID(CbmSpadicRawMessage* raw) -{ - /* - * Get the layer from whic the given message originated. Defined in downstream direction. - * Layer 0 is closest to the target. - */ - return GetModuleID(raw); -} - -Int_t CbmTrdTestBeamTools::GetRowID(CbmSpadicRawMessage* raw){ - /*Get row of the active channel. - *Upper row is row 1. - */ - return 1-GetChannelOnPadPlane(raw)/16; -} - -Int_t CbmTrdTestBeamTools::GetColumnID(CbmSpadicRawMessage* raw){ - /*Get column of the active channel. - *With view towards the target, column 0 is on the left side. - *Lower numbered colums are towards the left side of the module. - */ - Int_t ColID=(GetSpadicID(raw)/2)*16+(GetChannelOnPadPlane(raw))%16; - return ColID; -} - -TString CbmTrdTestBeamTools::GetSpadicName(Int_t DpbID,Int_t SpadicID,TString DpbName="SysCore",kSpadicSize SpadicSize=kFullSpadic) -{ - /* Get a String of the Form "Syscore_0_Spadic_0" describing the specific SPADIC corresponding to the input parameters. - * The Parameter InputType allows either the Equipment ID/Source Address or the final Syscore/Spadic ID to be used. - * kRawData (default) is the parameter that allows the raw EqID/Source Address to be used, kProcessedData takes Syscore/SpadicID. - * The Parameter OutputType allows adressing either the corresponding FullSpadic, via kFullSpadic (default), or the original HalfSpadic, - * via kHalfSpadic. - * */ - TString spadicName=""; - spadicName=DpbName+"_"+std::to_string(DpbID)+"_"; - if(SpadicSize){ - spadicName += "Spadic_"; - }else{ - spadicName += "Half_Spadic_"; - - } - spadicName+=std::to_string(SpadicID); - - return spadicName; -} - -// virtual Int_t GetCombiID(CbmSpadicRawMessage* raw); -Int_t CbmTrdTestBeamTools::GetChannelOnPadPlane(CbmSpadicRawMessage* raw){ - /* - * The Spadic channels have an indirection layer to the pad on the padplane. - * This takes care of the mapping and returns the pad number. - */ - std::vector<Int_t>Map=GetChannelMap(raw); - Int_t chID=(GetSpadicID(raw)%2)*16+raw->GetChannelID(); - return Map.at(chID); -} - -std::vector<Int_t> CbmTrdTestBeamTools::GetChannelMap(CbmSpadicRawMessage*){ - /* - * Get the channel mapping that is valid for the spadic where raw originated. - */ - std::vector<Int_t> map = {{31,15,30,14,29,13,28,12,27,11,26,10,25, 9,24, 8, - 23, 7,22, 6,21, 5,20, 4,19, 3,18, 2,17, 1,16, 0}}; - return map; -} - -Int_t CbmTrdTestBeamTools::GetBaseline(CbmSpadicRawMessage* raw) -{ - /* - * Estimate the signal baseline. Returns the lowest ADC value in the first two samples. - */ - Int_t Base =*std::min_element(raw->GetSamples(),raw->GetSamples()); - //Int_t Basecand=*std::min_element(raw->GetSamples()+raw->GetNrSamples()-3,raw->GetSamples()+raw->GetNrSamples()); - return Base;//(Base<Basecand)?Base:Basecand; -} - -Int_t CbmTrdTestBeamTools::GetMaximumAdc(CbmSpadicRawMessage* raw,Double_t Base) -{ - /* - * Calculate message charge using the Maximum ADC method. - * This is zero suppressed data, if a baseline is given. - */ - Int_t MaxADC=-255; - for (int i=0;i<raw->GetNrSamples();i++){ - if (raw->GetSamples()[i]>MaxADC) - MaxADC=raw->GetSamples()[i]; - } - return MaxADC-Base; -} - -Float_t CbmTrdTestBeamTools::GetIntegratedCharge(CbmSpadicRawMessage* raw,Double_t Base) -{ - /* - * Get the integrated charge of raw, with Base subtracted. - * Includes correction for unequal message lengths. - */ - - Float_t* ProcessedSamples=new Float_t[32]; - Int_t* Samples=raw->GetSamples(); - Int_t NrSamples=raw->GetNrSamples(); - Int_t Baseline=GetBaseline(raw); - if(Base!=0.0) - Baseline = Base; - for (int i=0;i<NrSamples;i++){ - ProcessedSamples[i]=Samples[i]-Baseline; - // std::cout << ProcessedSamples[i] << " "; - } - //std::cout << std::endl; - Double_t Integral=GetIntegratedCharge(ProcessedSamples,NrSamples); - delete[] ProcessedSamples; - return Integral/1.E4; -} - -Float_t CbmTrdTestBeamTools::GetIntegratedCharge(const Float_t* Samples,Int_t NrSamples) -{ - /* - * Get the integrated charge of raw, with Base subtracted. - * Includes correction for unequal message lengths. - */ - Double_t Integral=0; - if(NrSamples<=3) - return 0; - for (int i=2;i<NrSamples;i++){ - Integral+=Samples[i]; - } - Double_t CorrectionFactor=0; - Double_t Shape=GetShapingTime(),Sample=GetSamplingTime(); - for (Int_t i=0;i<NrSamples-2;i++) - { - //Calculate integral of the impulse response of the spadic. - //std::cout << (TMath::Exp(-(i+0.25)*Sample/Shape)*((NrSamples+0.25)*Sample*Sample)/(Shape*Shape))<< std::endl; - CorrectionFactor+=(TMath::Exp(-(i)*Sample/Shape)*((i)*Sample)/(Shape*Shape)); - } - //std::cout << "ClusterCharge: "<<Integral << " " << CorrectionFactor << " "<< NrSamples << " " << Integral*1.5/(CorrectionFactor*1E3)<<std::endl; - return static_cast<Float_t>(Integral*1.5/(CorrectionFactor*1E3)); -} - -Int_t -CbmTrdTestBeamTools::GetModuleID (CbmTrdCluster* Clust) -{ - //Returns ModuleID of the first Digi in the cluster. - //This is identical to the ModuleID of the cluster. - ClearNullptr(Clust); - const CbmTrdDigi*digi = fDigiMan->Get<CbmTrdDigi>( - *Clust->GetDigis ().begin ()); - return CbmTrdAddress::GetModuleId (GetAddress(digi)); -} - -// ---- ------------------------------------------------------- - -Int_t -CbmTrdTestBeamTools::GetLayerID (CbmTrdCluster* Clust) -{ - //Returns LayerID of the first Digi in the cluster. - //This is identical to the LayerID of the cluster. - ClearNullptr(Clust); - const CbmTrdDigi*digi = fDigiMan->Get<CbmTrdDigi>( - *(Clust->GetDigis ().begin ())); - return CbmTrdAddress::GetLayerId (GetAddress(digi)); -} - -Int_t -CbmTrdTestBeamTools::GetCentralRowID (CbmTrdCluster* Clust) -{ - /*Get main row of the cluster. - * Only defined for 1 Row Clusters at this time. - * The Definition is identical to TestBeamTools::GetRowID. - */ - //TODO: Implement for 2D-Clusters. - /*if (Clust->GetNRows () != 1) - //TODO: Find self triggered Digi. - return -1;*/ - ClearNullptr(Clust); - const CbmTrdDigi*digi = fDigiMan->Get<CbmTrdDigi> ( - *(Clust->GetDigis ().begin ())); - return CbmTrdAddress::GetRowId (GetAddress(digi)); -} - -Int_t -CbmTrdTestBeamTools::GetCentralColumnID (CbmTrdCluster* Clust) -{ - /*Get the main column of the cluster. - *For clusters of odd size, this is the central column. - *For clusters of even size, this is the column to the left of the clusters center. - */ - ClearNullptr(Clust); - std::vector<Int_t> Digis (Clust->GetDigis ()); - std::vector<Int_t> columns; - // std::vector<CbmTrdDigi*> selfTriggeredDigis; - for (auto it = Digis.begin (); it != Digis.end (); it++) - { - const CbmTrdDigi*digi = fDigiMan->Get<CbmTrdDigi>(*it); - if (digi->GetTriggerType () == 1 || digi->GetTriggerType () == 3) - columns.push_back (CbmTrdAddress::GetColumnId (GetAddress(digi))); - } - if (!columns.size ()) - for (auto it = Digis.begin (); it != Digis.end (); it++) - { - const CbmTrdDigi*digi = fDigiMan->Get<CbmTrdDigi>(*it); - columns.push_back (CbmTrdAddress::GetColumnId (GetAddress(digi))); - } - Float_t col = 0; - for (auto it = columns.begin (); it != columns.end (); it++) - col += *it; - if (columns.size ()) - col /= columns.size (); - return static_cast<Int_t> ((col)); -} - -Int_t -CbmTrdTestBeamTools::GetRowWidth (CbmTrdCluster* Clust) -{ - /* - * Return width of the Cluster in terms of rows. - */ - ClearNullptr(Clust); - std::vector<Int_t> Rows, Digis = Clust->GetDigis (); - for (auto it = Digis.begin (); it != Digis.end (); it++) - { - const CbmTrdDigi*Digi = fDigiMan->Get<CbmTrdDigi>(*it); - Int_t Row = CbmTrdAddress::GetColumnId (GetAddress(Digi)); - Rows.push_back (Row); - } - Int_t MinRow = *std::min_element (Rows.begin (), Rows.end ()); - Int_t MaxRow = *std::max_element (Rows.begin (), Rows.end ()); - return MaxRow - MinRow + 1; -} - -Int_t -CbmTrdTestBeamTools::GetColumnWidth (CbmTrdCluster* Clust) -{ - /* - * Return width of the Cluster in terms of Columns. - */ - //TODO: Implement this for 2D Clusters - ClearNullptr(Clust); - std::vector<Int_t> Columns; - for (auto it = Clust->GetDigis ().begin (); it != Clust->GetDigis ().end (); - it++) - { - const CbmTrdDigi*Digi = fDigiMan->Get<CbmTrdDigi>(*it); - Int_t Col = CbmTrdAddress::GetColumnId (GetAddress (Digi)); - Columns.push_back (Col); - } - Int_t MinCol = *std::min_element (Columns.begin (), Columns.end ()); - Int_t MaxCol = *std::max_element (Columns.begin (), Columns.end ()); - return MaxCol - MinCol + 1; -} - -Float_t -CbmTrdTestBeamTools::GetCharge (CbmTrdCluster* Clust) -{ - ClearNullptr(Clust); - const std::vector<Int_t> Digis = Clust->GetDigis (); - Float_t Charge = 0.0; - for (auto it = Digis.begin (); it != Digis.end (); it++) - { - const CbmTrdDigi*digi = fDigiMan->Get<CbmTrdDigi>(*it); - Charge += digi->GetCharge () + digi->GetChargeTR (); - } - return Charge/1.E4; -} - -Float_t -CbmTrdTestBeamTools::GetRowDisplacement (CbmTrdCluster* Clust) -{ ClearNullptr(Clust); - //TODO: To be implemented for 2 Row Clusters or Bucharest Data. - return 0; -} - -Float_t -CbmTrdTestBeamTools::GetColumnDisplacement (CbmTrdCluster* Clust) -{ - ClearNullptr(Clust); - /**Calculate Displacement according to charge Distribution along main row. - */ - std::vector<Int_t> Digis (Clust->GetDigis ()); - //Define lamda function for sorting the Digis. - //TODO: Update Sort function for new Digis - /* auto sortDigis = - [&,this](Int_t a,Int_t b) - { - return static_cast<Bool_t>((static_cast<CbmTrdDigi*>(this->fDigis->At(a))->Compare(this->fDigis->At(b)))+1); - }; - */ - //std::sort (Digis.begin (), Digis.end (), sortDigis); - //For now only consider the main row for Displacement. - Int_t mainRow = GetCentralRowID (Clust); - //Discard all Digis not on main row - //TODO: Refactor this. - for (auto it = Digis.begin (); it != Digis.end ();) - { - const CbmTrdDigi*digi = fDigiMan->Get<CbmTrdDigi>(*it); - if (CbmTrdAddress::GetRowId (GetAddress(digi)) != UInt_t(mainRow)) - { - Digis.erase (it); - it = Digis.begin (); - } - else - { - it++; - } - } - //Cannot calculate an offset for Clusters of size =1 - if (Digis.size()<=1) - return 0.; - //Define Variables for Center of Gravity - //Should be moved inside corresponding code block - Float_t WeightedColumns = 0; - Float_t TotalRowCharge = 0; - //Define Array for SECHS - //Should be moved inside corresponding code block - std::vector<Float_t> Charges {{}}; - //Find Reference point for Center of Gravity - //Should be moved inside corresponding code block - Float_t Offset = GetCentralColumnID(Clust); - //Define Return value variable. - Float_t Displacement = 0; - //For all Clusters not suitable for SECHS, use COG - //Also for all Cluster of Size > 4 - //SECHS gives weird results on large Clusters. - if (ClassifyCluster (Clust) != CbmTrdClusterClassification::kNormal - ||GetColumnWidth(Clust)>4) - { - //Calculate Center of Gravity via the average pad number - //Might need to be reworked - for (UInt_t i = 0; i < Digis.size (); i++) - { - const CbmTrdDigi*digi = fDigiMan->Get<CbmTrdDigi>(i); - Float_t Charge = (digi->GetCharge () + digi->GetChargeTR ())/1.e4; - TotalRowCharge += Charge; - WeightedColumns += (Charge - * CbmTrdAddress::GetColumnId (GetAddress(digi))); - } - //Should be 1, prevents Divide by 0. - if (TotalRowCharge <= 0) - TotalRowCharge = 1; - //Calculate Average - Displacement = WeightedColumns / TotalRowCharge; - //subtract Reference - Displacement -= Offset; - } - // - else - { - for (auto p : Digis) - { - const CbmTrdDigi*digi = fDigiMan->Get<CbmTrdDigi>(p); - if (digi==nullptr) - continue; - Charges.push_back (digi->GetCharge ()/1.e4); - } - for (size_t i = 0; i+2 < Charges.size (); i++) - { - Offset=i; - //std::cout << i << " "<< i+1 << " "<< i+2 << " "<<Charges.size ()<< std::endl; - Double_t TempOffset = CalculateSECHS (Charges[i], - Charges[i + 1], - Charges[i + 2]); - if(GetColumnWidth(Clust)==3) - TempOffset+=0; - else - TempOffset+=0.5; - Offset += TempOffset; - } - Displacement=Offset/(GetColumnWidth(Clust)-2.); - } - return Displacement; -} - -Float_t -CbmTrdTestBeamTools::CalculateSECHS (Float_t a, Float_t b, Float_t c) -{ - /* - * Calculate the displacement according to the SECHS (Squared hyberbolic secans) method in units of the padwidth. - * - * Needs three adjacent positive and finite charges. - * a should be the leftmost charge. - * b needs to be the central charge. - */ - Double_t PadWidth = 1; - Double_t a3 = - TMath::Pi () * PadWidth - / TMath::ACosH ( - 0.5 - * (sqrt ( - static_cast<Double_t> (b) / static_cast<Double_t> (a)) - + sqrt ( - static_cast<Double_t> (b) / static_cast<Double_t> (c)))); - Double_t Offset = a3 / TMath::Pi () - * TMath::ATanH ( - (sqrt (static_cast<Double_t> (b) / static_cast<Double_t> (a)) - - sqrt (static_cast<Double_t> (b) / static_cast<Double_t> (c))) - / (2.0 * TMath::SinH (TMath::Pi () * PadWidth / a3))); - return Offset; -} - -CbmTrdTestBeamTools::CbmTrdClusterClassification -CbmTrdTestBeamTools::ClassifyCluster (CbmTrdCluster*Clust) -{ ClearNullptr(Clust); - std::vector<Int_t> Digis (Clust->GetDigis ()); - if (Digis.size () == 0) - return kEmpty; - //TODO: Fragmentationtest - //std::cout << "Cluster debug " <<GetCharge (Clust) << " " <<std::endl; - /* if (GetCharge (Clust) <= 0) - return kInvalidCharge;*/ - /* VF: sortDigis not used. - auto sortDigis = [&,this](Int_t a,Int_t b) - { - //std::cout << a<<" "<< b<< std::endl; - return static_cast<Bool_t>(-1==(static_cast<CbmTrdDigi*>(this->fDigis->At(a))->Compare(this->fDigis->At(b)))); - }; - */ - //std::sort (Digis.begin (), Digis.end (), sortDigis); - //Check Triggerpatterns - std::vector<Int_t> TriggerTypes, Columns; - //Int_t MainRow = GetCentralRowID (Clust); - for (auto it = Digis.begin (); it != Digis.end (); it++) - { - const CbmTrdDigi*digi = fDigiMan->Get<CbmTrdDigi>(*it); - /*if (CbmTrdAddress::GetRowId (digi->GetAddress ()) != MainRow) - continue;*/ - TriggerTypes.push_back (digi->GetTriggerType ()); - //std::cout << digi->GetTriggerType()<< " "; - Columns.push_back (CbmTrdAddress::GetColumnId (GetAddress(digi))); - if (digi->GetCharge()<=0.) - return kInvalidCharge; - } - //std::cout << std::endl; - //Check for expected Neighbour Trigger Pattern. - //Only default FNR Pattern implemented - /*if (std::find (TriggerTypes.begin (), TriggerTypes.end (), 2) - != TriggerTypes.begin () - || std::find (TriggerTypes.rbegin (), TriggerTypes.rend (), 2) - != TriggerTypes.rbegin ()) - */ - if(TriggerTypes[0]!=2||TriggerTypes.back()!=2) - return kMissingFNR; - if(Digis.size()<3) - return kMissingSTR; - if (TriggerTypes[1]!=1&&TriggerTypes[1]!=3) - return kMissingSTR; - //Check for Gaps - /* - Int_t CurrentCol = Columns.at (0); - for (Int_t i = 1; i < Columns.size (); i++) - { - if (++CurrentCol < Columns.at (i)) - return kMissingSTR; - } - */ - return kNormal; -} - - diff --git a/beamtime/trd/tools/CbmTrdTestBeamTools.h b/beamtime/trd/tools/CbmTrdTestBeamTools.h deleted file mode 100644 index 4a124e142cc7fdbabe3f096a9de62db9a5abb09d..0000000000000000000000000000000000000000 --- a/beamtime/trd/tools/CbmTrdTestBeamTools.h +++ /dev/null @@ -1,511 +0,0 @@ -#ifndef CBMTRDTESTBEAMTOOLS_H -#define CBMTRDTESTBEAMTOOLS_H - -#include "CbmTrdCluster.h" -#include "CbmTrdDigi.h" -#include "CbmTrdAddress.h" -#include "CbmSpadicRawMessage.h" - -#include <TClonesArray.h> -#include "CbmDigiManager.h" - -#include <vector> -#include <mutex> -#include "TString.h" -#include "TObject.h" -#include "TMath.h" -#include <iostream> - - -class CbmTrdTestBeamTools: public TObject -{ - protected: - CbmDigiManager* fDigiMan = nullptr; - - public: - CbmTrdTestBeamTools(); - // CbmTrdTestBeamTools():CbmTrdTestBeamTools("CbmTrdBeamtimeTools"){}; - ~CbmTrdTestBeamTools(){}; - - - /**Get the current instance of TestBeam tools in use, or set it. - * Only permits one instance of TestBeam tools. - * @param: NewInstance Optional pointer to a new instance of CbmTrdTestBeamtools. - * If not set, a new instance of the default class is created. - * - * @return: A Pointer to the current global instance of CbmTrdTestBeamtools. - */ - static CbmTrdTestBeamTools* Instance(CbmTrdTestBeamTools*); - /** - * GetAddress: Get a CbmTrdAddress-compatible Address for this CbmSpadicRawMessage. - * @param raw Pointer to the CbmSpadicRawMessage, for which an Address should be returned. - * @return: A CbmTrdAddress-compatible Address for the active Channel. - */ - virtual UInt_t GetAddress(CbmSpadicRawMessage* raw); - /** - * GetAddress: Get a CbmTrdAddress-compatible Address for this CbmTrdDigi. - * @param raw Pointer to the CbmTrdDigi, for which an Address should be returned. - * @return: A CbmTrdAddress-compatible Address for the active Channel. - */ - UInt_t GetAddress(const CbmTrdDigi* raw){ - std::mutex mtx; - mtx.lock(); - unsigned int BaseAddress=raw->GetAddress(); - unsigned int PadID=raw->GetAddressChannel(); - Int_t LayerID=CbmTrdAddress::GetLayerId(BaseAddress); - Int_t ModID=CbmTrdAddress::GetModuleId(BaseAddress); - Int_t NrCols=GetNrColumns(LayerID); - Int_t ColID=PadID%NrCols; - Int_t SectID=CbmTrdAddress::GetSectorId(BaseAddress); - Int_t RowID=PadID/NrCols; - // std::cout << std::hex<< BaseAddress<< " " << PadID<< " " << ColID << " " << RowID<<" BBBBBBB " << CbmTrdAddress::GetAddress(LayerID,ModID,SectID,RowID,ColID)<<std::dec<<std::endl; - return CbmTrdAddress::GetAddress(LayerID,ModID,SectID,RowID,ColID); - }; - /** - * GetModuleID: Get a CbmTrdAddress-compatible ModuleID for this CbmSpadicRawMessage. - * @param raw Pointer to the CbmSpadicRawMessage, for which an ModuleID should be returned. - * @return: A CbmTrdAddress-compatible ModuleID for the active Channel. - */ - virtual Int_t GetModuleID(CbmSpadicRawMessage* raw); - /** - * GetLayerID: Get a CbmTrdAddress-compatible LayerID for this CbmSpadicRawMessage. - * @param raw Pointer to the CbmSpadicRawMessage, for which a Layer ID should be returned. - * @return: A CbmTrdAddress-compatible LayerID for the active Channel. - */ - virtual Int_t GetLayerID(CbmSpadicRawMessage* raw); - /** - * GetRowID: Get a CbmTrdAddress-compatible RowID for this CbmSpadicRawMessage. - * @param raw Pointer to the CbmSpadicRawMessage, for which a RowID should be returned. - * @return: A CbmTrdAddress-compatible RowID for the active Channel. - */ - virtual Int_t GetRowID(CbmSpadicRawMessage* raw); - /** - * GetRobID: Get DpbID for this CbmSpadicRawMessage. - * The Dpb is the FPGA to which the Spadic is connected, a ROB might be transparently - * used inbetween. Name is kept for compatibility. - * @param raw Pointer to the CbmSpadicRawMessage, for which the DpbOd should be returned. - * @return: A DpbId for the active Channel. - */ - virtual Int_t GetRobID(CbmSpadicRawMessage* raw); //blubb - /** - * GetSpadicID: Get DpbID for for this CbmSpadicRawMessage. - * Each ID addresses a 16 Channel Channelgroup. - * @param raw Pointer to the CbmSpadicRawMessage, for which a SpadicId should be returned. - * @return: SpadicId for the active Channel. - */ - virtual Int_t GetSpadicID(CbmSpadicRawMessage* raw); - /** - * GetRowID: Get a CbmTrdAddress-compatible ColumnID for this CbmSpadicRawMessage. - * @param raw Pointer to the CbmSpadicRawMessage, for which a ColumnID should be returned. - * @return: A CbmTrdAddress-compatible ColumnID for the active Channel. - */ - - virtual Int_t GetColumnID(CbmSpadicRawMessage* raw); - // virtual Int_t GetCombiID(CbmSpadicRawMessage* raw); - /** - * Get The mapping of a Spadic channel to the corresponding MWPC-pad in a 32 Channel Group. - * This Group contains two 16 channel rows. The lower 16 pads correspond to the upper row. - * @param raw Pointer to the CbmSpadicRawMessage - * @return Pad on the 32-Channel Group. - */ - virtual Int_t GetChannelOnPadPlane(CbmSpadicRawMessage* raw); - /** - * Get inverse sampling frequency in nano seconds, assumed to be uniform in a given setup. - * This version gives the Sampling time for the SPADIC 1.x. - * @return: Sampling time in nano seconds. - */ - virtual Float_t GetSamplingTime(){ - return 1E3/15; - }; - /** - * Get the spadic shaping time tau in nano seconds. - * This is the shaping constant from the second order shaper, assumed to be uniform in a given setup. - * This version gives the Sampling time for the SPADIC 1.x. - * @return: Shaping time in nano seconds. - */ - virtual Int_t GetShapingTime(){ - return 90; - }; - - virtual Int_t GetNrLayers(){ - /** - * Get the number of detector layers in a setup. - * @return: Number of instrumented and active detector layers. - */ - return GetNrRobs(); - }; - virtual Int_t GetNrRows(Int_t /*Layer*/=0){ - /** - * Get the Number of active Rows in the corresponding Layer. - * Note: assumes one chamber type per Layer. - * @param: Layer Layer ID of the queried detector, usually starts with 0 and counts upwards. - * @return: Number of active Rows in the corresponding Layer - */ - return 2; - }; - double - GetPadWidth (Int_t layer) - { - /** - * Get the width of a pad in cm, assumed to be constant for a given Layer. - * Note: currently contains the DESY2017 parameters, this will be fixed within the following days. - * @return: Width of a pad in cm - */ - if (layer < 6) - return 0.7125; - return 16.0; - } - - double - GetPadHeight (Int_t layer) - { - /** - * Get The height of a pad in cm, assumed to be constant for a given Layer. - * Note: currently contains the DESY2017 parameters, this will be fixed within the following days. - * @param: Layer Layer ID of the queried detector, usually starts with 0 and counts upwards. - * @return: Height of a pad in cm - */ - if (layer < 4) - return 15.25; - if (layer < 6) - return 4.5; //???? - return 23.0; - } - - virtual Int_t GetNrColumns(Int_t /*Layer*/=0){ - /** - * Get the Number of active pad columns in the corresponding Layer, assumed to be constant for a given Layer. - * @param: Layer Layer ID of the queried detector, usually starts with 0 and counts upwards. - * @return: Number of active pad columns - */ - return 16*GetNrSpadics(); - } - virtual Int_t GetNrRobs(){ - /** - * Get the Number of active DPBs in the Setup. - * Note: This function will be deprecated and replaced with a properly named function. - * @return: the Number of active DPBs in the Setup - */ - return 4; - }; - virtual Int_t GetNrSpadics(Int_t /*DpbID*/=0){ - /* - * Get the Number of active Spadics on a ROB - * @param: DpbID ID of the queried DPB, usually starts with 0 and counts upwards. - * @return: Number of active spadics connected to DPB - */ - return 3; - } - virtual Int_t GetSpadicBaseAddress(){ - /** - * Base address which will be added to each half spadic number. - * The first halfspadic which is connected to a DPB - * get SpadicBaseAddress+0, the second SpadicBaseAddress +1 ... - * @return: Base address. - */ - return 0; - } - /** - * GetSpadicResponse: Calculate detector response of the Spadic for given Parameters. - * The response is modeled by calculating two delta Pulses and overlaying them. - * - * @return The return value is a std::vector of 32 Samples for the given Parameters. - * @param Max Maximum ADC-value of the Signal. This is not Baseline corrected. - * @param Base Baseline value for the calculation of the response - * @param FirstTime Timing information for the first hit. The Value is the interpolated index where the signal crosses the half Maximum point. - * It is given in units of the sampling time. - * @param FWHM Timing information for the second hit. This is the interpolated index where the signal crosses the half Maximum point on the downward slope. - */ - std::vector<Float_t> GetSpadicResponse(Float_t /*Max*/,Float_t /*Base*/, Float_t /*FirstHalfMax*/, Float_t /*SecondHalfMax*/){ - return std::vector<Float_t>({0,1}); - } - - /** - * GetDeltaResponse: Get the spadic Response for a Delta pulse occurring at Index 0. - * The measured pulses have this occurring at Index ~2, so adjust appropriately. - * - * @param Index This is a fractional index for the Sample occurring at this point relative to the original Delta pulse. - * Index 0.0 might be offset relative to the sample index in a real Spadic Response. - */ - Float_t GetDeltaResponse(Float_t Index){ - static std::vector<Float_t> ResponseArray; - if(ResponseArray.empty()){ - Float_t Sample=GetSamplingTime(); - Float_t Shape=GetShapingTime(); - for (Int_t i=0;i<320;i++){ - ResponseArray.push_back((TMath::Exp(-(i/10.0)*Sample/Shape)*((i/10.0)*Sample)/(Shape*Shape))); - } - } - Int_t intIndex=static_cast<Int_t>(round(Index*10)); - return ResponseArray.at(intIndex); - } - /** - * FindIntercept: internal function to find a linearly interpolated point between two samples. - * - * @param FirstSample The first sample, this is used as the baseline. - * @param SecondSample The second sample, this is used as the upper point of the linear interpolation. - * @param Mark The value for which the crossover point is looked for. - * @return The Crossover point in units of the distance between FirstSample and SecondSample. - */ - - Float_t FindIntercept(Float_t FirstSample, Float_t SecondSample, Float_t Mark){ - SecondSample-=FirstSample; - Mark-=FirstSample; - return (Mark)/SecondSample; - - } - /** - * Internal function to lookup the base EquipmentID. - * This is version returns the value for the legacy DAQ- - * @return The Base EquipmentID for the Setup. - */ - virtual Int_t GetBaseEquipmentID(){ - //Get the BaseEquipmentID - return 0xE000; - } - /** - * Internal Function to query the mapping between the channels of a - * full SPADIC (2 channel groups) and the pads on the padplane. - * The return value will be valid for the SPADIC on which the message originated. - * @param raw Pointer to the CbmSpadicRawMessage, for which the mapping to the padplane should be returned. - * @return A std::vector containing the pad number at the index equal to the SPADIC channel. - * */ - virtual std::vector<Int_t> GetChannelMap(CbmSpadicRawMessage* raw); - /** - * An enum Type indicating the desired addressed Unit in GetSpadicName. - */ - enum kSpadicSize : bool{ - kFullSpadic=true,/**< Address a FullSpadic with two channel groups, sets Spadic name to "Spadic".*/ - kHalfSpadic=false/**< Address a HalfSpadic with one channel group, sets Spadic name to "Half_Spadic".*/ - }; - /** GetSpadicName: Get a consistent String of the Form "AFCK_0_Spadic_0" describing the specific SPADIC corresponding to the input parameters. - * Useful for adressing Histograms in the histogram manager. - * @param DpbID ID of the Dpb to which the Spadic is connected. - * @param SpadicID Logical ID of the Spadic as assigned by the DPB. - * @param DpbName Base name of the Dpb type, can be an arbitrary string. - * @param SpadicSize Desired Spadic Size, might be either a kFullSpadic or a kHalfSpadic. - * @return A formatted string of the form AFCK_0_Spadic_0. - * */ - TString GetSpadicName(Int_t DpbID,Int_t SpadicID,TString DpbName,kSpadicSize SpadicSize); - /** Compatibility wrapper for GetSpadicName. Deprecated - * @param DpbID ID of the Dpb to which the Spadic is connected. - * @param SpadicID Logical ID of the Spadic as assigned by the DPB. - * @param DpbName Base name of the Dpb type, can be an arbitrary string. - * @param FullSpadic Desired Spadic Size, might be either a kFullSpadic or a kHalfSpadic. - * @return A formatted string of the form AFCK_0_Spadic_0. - */ - TString GetSpadicName(Int_t DpbID,Int_t SpadicID,TString DpbName,Bool_t FullSpadic){ - kSpadicSize Size=kHalfSpadic; - if(FullSpadic) - Size=kFullSpadic; - return GetSpadicName(DpbID,SpadicID,DpbName,Size); - } - /** - * For a given Message, return an estimate for the baseline in a consistent message. - * This function only considers the individual message. Averages have to be calculated by the user. - * @param raw Pointer to the RawMessage for which the baseline is to be estimated. - * @return Value of Sample 0 from the message. - */ - Int_t GetBaseline(CbmSpadicRawMessage* raw); - /** - * Gives a Charge estimate by taking a raw message and subtracting the Baseline from the maximum ADC Value. - * @param raw Pointer to the RawMessage for which the charge is to be estimated. - * @param Base User provided estimate of the Baseline. - * @return Value of the maximum ADC Sample after subtraction of the Baseline - */ - virtual Int_t GetMaximumAdc(CbmSpadicRawMessage*raw,Double_t Base=0.0); - /** - * Gives a Charge estimate by taking a raw message and returns the corrected Integral. - * This integral is corrected in the sense that different message lengths are compensated for. - * The output is scaled to be close to the dynamic range of the MaxADC value. - * - * This function is a wrapper. - * @param raw Pointer to the Rawessage for which the charge is to be estimated. - * @param Base User provided estimate of the Baseline. - * @return Corrected and scaled integral charge for the message. - */ - Float_t GetIntegratedCharge(CbmSpadicRawMessage*raw,Double_t Base=0.0); - /** - * Gives a Charge estimate by taking an array of zero-suppressed samples andreturns the corrected Integral. - * This integral is corrected in the sense that different message lengths are compensated for. - * The output is scaled to be close to the dynamic range of the MaxADC value. - * - * @param Samples Pointer to an array of zero-suppressed samples for which the charge is to be estimated. - * @param NrSamples Number of valid Samples in the array. - * @return Corrected and scaled integral charge for the message. - */ - Float_t GetIntegratedCharge(const Float_t* Samples,Int_t NrSamples=32); - - CbmTrdTestBeamTools(const CbmTrdTestBeamTools&); - CbmTrdTestBeamTools operator=(const CbmTrdTestBeamTools&); - - /* - * Now define all necessary functions for the clusters. - */ - /** - * Set the CbmTrdDigi pointer in use. This is necessary for cluster analysis. - * @param Digis Pointer to the TClonesArray containing all CbmTrdDigis in the Clusters to be analyzed. - */ - void - SetDigisArray (TClonesArray*) - { - fDigiMan = CbmDigiManager::Instance(); - fDigiMan->Init(); - } - ; - void ClearNullptr(CbmTrdCluster*test){ - auto data=test->GetDigis(); - for (auto x=data.begin();x!=data.end();x++) - { - const CbmTrdDigi* ptr = fDigiMan->Get<CbmTrdDigi>(*x); - if (ptr==nullptr) - data.erase(x),x=data.begin(); - } - test->SetDigis(data); - }; - /** - * GetLayerID: Get a CbmTrdAddress-compatible ModuleID for this CbmTrdCluster. - * @param Clust Pointer to the CbmTrdCluster, for which a Module ID should be returned. - * @return: A CbmTrdAddress-compatible ModuleID for the Cluster. - */ - virtual Int_t - GetModuleID (CbmTrdCluster*); - /** - * GetLayerID: Get a CbmTrdAddress-compatible LayerID for this CbmTrdCluster. - * @param Clust Pointer to the CbmTrdCluster, for which a Layer ID should be returned. - * @return: A CbmTrdAddress-compatible LayerID for the Cluster. - */ - virtual Int_t - GetLayerID (CbmTrdCluster*Clust); - /** - * GetLayerID: Get a CbmTrdAddress-compatible SectorID for this CbmTrdCluster. - * @param Clust Pointer to the CbmTrdCluster, for which a Sector ID should be returned. - * @return: A CbmTrdAddress-compatible SectorID for the Cluster. - */ - - virtual Int_t - GetSectorID (CbmTrdCluster* clust) - { - //returns sectorID of the Cluster. Only defined for compatibility. - const CbmTrdDigi* Digi = fDigiMan->Get<CbmTrdDigi>(clust->GetDigi(0)); - return CbmTrdAddress::GetSectorId (GetAddress(Digi)); - } - ; - /** - * Get a CbmTrdAddress-compatible RowID for the central row of this CbmTrdCluster. - * This is the row on which most self triggered messages are located. - * @param Clust Pointer to the CbmTrdCluster, for which a central Row ID should be returned. - * @return: A CbmTrdAddress-compatible RoID for the Cluster. - */ - virtual Int_t - GetCentralRowID (CbmTrdCluster*Clust); - /** - * Get a CbmTrdAddress-compatible ColumnID for the central Column of this CbmTrdCluster. - * This is the average column with regard to the Self-triggered messages. - * This is intended as the base position for the displacement algorithms. - * @param Clust Pointer to the CbmTrdCluster, for which a central Column ID should be returned. - * @return: A CbmTrdAddress-compatible ColumnID for the Cluster. - */ - virtual Int_t - GetCentralColumnID (CbmTrdCluster*Clust); - /** - * Query the width of the cluster in terms of the amount of rows it spans. - * @param Clust Pointer to the CbmTrdCluster - * @return The number of consecutive rows the Cluster spans. - * */ - virtual Int_t - GetRowWidth (CbmTrdCluster*Clust); - /** - * Query the width of the cluster along its main row in terms of pads. - * @param Clust Pointer to the CbmTrdCluste - * @return The number of consecutive pads along the main row of the Cluster. - * */ - virtual Int_t - GetColumnWidth (CbmTrdCluster*Clust); - /** - * Calculate the total charge of the cluster, this is done by summing up the - * charges of the individual Digis comprising this cluster. - * @param Clust Pointer to the CbmTrdCluster to be investigated - * @return Total Charge on all pads of the cluster. - */ - Float_t - GetCharge (CbmTrdCluster*Clust); - /** - * Get the offset between the center of a clusters main row and the center of its charge deposition - * TODO: currently no implementation exists for the Frankfurt/Muenster Prototypes. - * @param Clust Pointer to the CbmTrdCluster to be investigated - * @return Distance of a Clusters center of gravity and its main row, in units of pad height. - * */ - virtual Float_t - GetRowDisplacement (CbmTrdCluster*Clust); - /** - * Get the offset between the center of a clusters central pad and the center of its charge deposition - * @param Clust Pointer to the CbmTrdCluster to be investigated - * @return Distance of a Clusters center of gravity and its central pad, in units of pad width. - * */ - - virtual Float_t - GetColumnDisplacement (CbmTrdCluster*Clust); - /** - * An enum type describing the classification of a given CbmTrdCluster. - */ - enum CbmTrdClusterClassification - : char - { kNormal = 0, /**< A normal well formed Cluster.*/ - kMissingSTR, /**< A malformed Cluster without STR triggered digi, this is usually due to a lost hit message.*/ - kMissingFNR, /**< A malformed Cluster with at least one missing FNR triggered digi, this is usually due to a lost hit message.*/ - kInvalidCharge, /**< A Cluster with at least one negative charge value. A high number of these would indicate a problem with the baseline estimation.*/ - kFragmented, /**< Reserved for future use: A Cluster that was created due to a noise induced retrigger.*/ - kEmpty /**< A Cluster without Digis.*/ - }; - /** - * Classify a cluster according to general principals for Clusters. - * Important: This function does not perform any checks based on physics. - * @param: Clust The Cluster to be classified. - * @return: A first and very general classification of the cluster. - */ - CbmTrdClusterClassification - ClassifyCluster (CbmTrdCluster*); - /** - * Query the Classification name as a string. - * @param _Class The CbmTrdClusterClassification to be queried. - * @return A TString containing the proper name of the Classification. - */ - TString - GetClassName (CbmTrdClusterClassification _Class) - { - switch (_Class) - { - case kNormal: - return "kNormal"; - case kMissingSTR: - return "kMissingSTR"; - case kMissingFNR: - return "kMissingFNR"; - case kInvalidCharge: - return "kInvalidCharge"; - case kFragmented: - return "kFragmented"; - case kEmpty: - return "kFragmented"; - } - } - -protected: - /** - * A precise position reconstruction algorithm for Clusters. - * To be used on consecutive groups of three pads. - * Not in use at the moment due to the necessary filtering. - * @params FirstCharge Charge on the first pad of the partial Cluster, must be larger than 0.0. - * @params SecondCharge Charge on the central pad of the partial Cluster, must be larger than 0.0. - * @params ThirdCharge Charge on the third pad of the partial Cluster, must be larger than 0.0. - * @return An offset to the center of the central pad. In fractions of the padwidth. - */ - Float_t - CalculateSECHS (Float_t FirstCharge, Float_t SecondCharge, Float_t ThirdCharge); - public: - - ClassDef(CbmTrdTestBeamTools,1); -}; - -#endif diff --git a/beamtime/trd/tools/CbmTrdTestBeamTools2016SPS.h b/beamtime/trd/tools/CbmTrdTestBeamTools2016SPS.h deleted file mode 100644 index 498240679d92f2a8fb7ba761548fee5c09179b5d..0000000000000000000000000000000000000000 --- a/beamtime/trd/tools/CbmTrdTestBeamTools2016SPS.h +++ /dev/null @@ -1 +0,0 @@ -//See CbmTrdTestBeamTools.{h,cxx}, at least before rev 12025 diff --git a/beamtime/trd/tools/CbmTrdTestBeamTools2017DESY.cxx b/beamtime/trd/tools/CbmTrdTestBeamTools2017DESY.cxx deleted file mode 100644 index 057842db66c0a965f69d289f077e5b0f999c89e7..0000000000000000000000000000000000000000 --- a/beamtime/trd/tools/CbmTrdTestBeamTools2017DESY.cxx +++ /dev/null @@ -1,17 +0,0 @@ -/*First Version of TestBeam tools, developed for the SPS2016 beamtime and the legacy DAQ-chain. - *Intended for the F/MS Prototypes. - *For usage with Bucharest, modifications of the functions GetChannelMap and GetRowID are neccessary. -*/ - -#include "CbmTrdTestBeamTools2017DESY.h" -#include "FairLogger.h" -#include "CbmTrdAddress.h" -#include <algorithm> - -ClassImp(CbmTrdTestBeamTools2017DESY) - -CbmTrdTestBeamTools2017DESY::CbmTrdTestBeamTools2017DESY () : CbmTrdTestBeamTools() -{ - LOG(info) << TString("Default Constructor of ")+TString(this->GetName()); - Instance(this); -} diff --git a/beamtime/trd/tools/CbmTrdTestBeamTools2017DESY.h b/beamtime/trd/tools/CbmTrdTestBeamTools2017DESY.h deleted file mode 100644 index 2f52563378000689b0b480458875ba828217b94d..0000000000000000000000000000000000000000 --- a/beamtime/trd/tools/CbmTrdTestBeamTools2017DESY.h +++ /dev/null @@ -1,114 +0,0 @@ -#ifndef CBMTRDTESTBEAMTOOLS2017DESY_H -#define CBMTRDTESTBEAMTOOLS2017DESY_H - -#include "CbmTrdTestBeamTools.h" -#include "FairLogger.h" - -class CbmTrdTestBeamTools2017DESY: public CbmTrdTestBeamTools -{ - public: - CbmTrdTestBeamTools2017DESY(); - // CbmTrdTestBeamTools2017DESY():CbmTrdTestBeamTools2017DESY("CbmTrdTestBeamTools2017DESY"){}; - ~CbmTrdTestBeamTools2017DESY(){}; - - Float_t GetSamplingTime(){ - /* - * Get inverse sampling frequency in nano seconds. - */ - return 1E3/16; - }; - Int_t GetShapingTime(){ - /* - * Get shaping time in nano seconds. - */ - return 240; - }; - virtual Int_t GetNrLayers(){ - return 8; - }; - virtual Int_t GetNrRows(Int_t Layer=0){ - //Get the Number of PadRows in the corresponding Layer - if (Layer <4) - return 6; - else if(Layer <6) - return 2; - else - return 1; - }; - virtual Int_t GetNrColumns(Int_t Layer=0){ - //Get the Number of active Columns in the corresponding Layer - if (Layer <4) - return 16*8; - else if(Layer <6) - return 16; - else - return 1; - } - virtual Int_t GetNrRobs(){ - //Get the Number of active ROBS in the Setup; - return 4; - }; - virtual Int_t GetNrSpadics(Int_t = 0){ - return 2; - } - virtual Int_t GetRowID(CbmSpadicRawMessage* raw){ - /*Get row of the active channel. - *Upper row is row 1. - */ - Int_t Offset=0; - Int_t SpadicId=GetSpadicID(raw); - if(SpadicId/2==0) - { - Offset=2; - } - else if(GetLayerID(raw)>5) - { - return 0; - } - return GetChannelOnPadPlane(raw)/16+Offset; - }; - virtual Int_t GetRobID(CbmSpadicRawMessage* raw){ - return raw->GetEquipmentID(); //blubb - } - virtual Int_t GetSpadicID(CbmSpadicRawMessage* raw){ - return raw->GetSourceAddress(); //blubb - } - virtual Int_t GetColumnID(CbmSpadicRawMessage* raw){ - /*Get column of the active channel. - *With view towards the target, column 0 is on the left side. - *Lower numbered colums are towards the left side of the module. - */ - Int_t Offset=0; - if (GetSpadicID(raw)/2==0) - { - Offset=4*16; - } - Int_t ColID=(GetChannelOnPadPlane(raw))%16+Offset; - return ColID; - }; - virtual Int_t GetLayerID(CbmSpadicRawMessage* raw) - { - Int_t SpadicId =GetSpadicID(raw); - Int_t AfckId=GetRobID(raw); - if (SpadicId/2==0) - return AfckId; - else{ - switch(AfckId){ - case 0: return 0; - case 1: return 5; - case 2: break; //return 6; - case 3: return 6; - } - } - LOG (ERROR) << this->GetName()<< ": Unknown SPADIC on Afck "<< AfckId << "SPADICID "<< SpadicId<<". Unable to find layer."; - return -1; - }; - - CbmTrdTestBeamTools2017DESY(const CbmTrdTestBeamTools2017DESY&); - CbmTrdTestBeamTools2017DESY operator=(const CbmTrdTestBeamTools2017DESY&); - public: - - ClassDef(CbmTrdTestBeamTools2017DESY,1); -}; - -#endif diff --git a/beamtime/trd/tools/CbmTrdTestBeamTools2017GIF.cxx b/beamtime/trd/tools/CbmTrdTestBeamTools2017GIF.cxx deleted file mode 100644 index b01f3909dd90f0fe21121aad2b06a2cda5ebe4ae..0000000000000000000000000000000000000000 --- a/beamtime/trd/tools/CbmTrdTestBeamTools2017GIF.cxx +++ /dev/null @@ -1,17 +0,0 @@ -/*First Version of TestBeam tools, developed for the SPS2016 beamtime and the legacy DAQ-chain. - *Intended for the F/MS Prototypes. - *For usage with Bucharest, modifications of the functions GetChannelMap and GetRowID are neccessary. -*/ - -#include "CbmTrdTestBeamTools2017GIF.h" -#include "FairLogger.h" -#include "CbmTrdAddress.h" -#include <algorithm> - -ClassImp(CbmTrdTestBeamTools2017GIF) - -CbmTrdTestBeamTools2017GIF::CbmTrdTestBeamTools2017GIF () : CbmTrdTestBeamTools() -{ - LOG(info) << TString("Default Constructor of ")+TString(this->GetName()); - Instance(this); -} diff --git a/beamtime/trd/tools/CbmTrdTestBeamTools2017GIF.h b/beamtime/trd/tools/CbmTrdTestBeamTools2017GIF.h deleted file mode 100644 index 8dd2292d7600939e143a9b08d39b340fa681b56b..0000000000000000000000000000000000000000 --- a/beamtime/trd/tools/CbmTrdTestBeamTools2017GIF.h +++ /dev/null @@ -1,104 +0,0 @@ -#ifndef CBMTRDTESTBEAMTOOLS2017GIF_H -#define CBMTRDTESTBEAMTOOLS2017GIF_H - -#include "CbmTrdTestBeamTools.h" -#include "FairLogger.h" - -class CbmTrdTestBeamTools2017GIF: public CbmTrdTestBeamTools -{ - public: - CbmTrdTestBeamTools2017GIF(); - // CbmTrdTestBeamTools2017GIF():CbmTrdTestBeamTools2017GIF("CbmTrdTestBeamTools2017GIF"){}; - ~CbmTrdTestBeamTools2017GIF(){}; - - Float_t GetSamplingTime(){ - /* - * Get inverse sampling frequency in nano seconds. - */ - return 1E3/16; - }; - Int_t GetShapingTime(){ - /* - * Get shaping time in nano seconds. - */ - return 240; - }; - virtual Int_t GetNrLayers(){ - return 3; - }; - virtual Int_t GetNrRows(Int_t Layer=0){ - //Get the Number of PadRows in the corresponding Layer - if (Layer <2) - return 1; - else - return 2; - }; - virtual Int_t GetNrColumns(Int_t Layer=0){ - //Get the Number of active Columns in the corresponding Layer - if (Layer <2) - return 1; - else - return 4*16; - } - virtual Int_t GetNrRobs(){ - //Get the Number of active ROBS in the Setup; - return 4; - }; - virtual Int_t GetNrSpadics(Int_t = 0){ - return 2; - } - virtual Int_t GetRowID(CbmSpadicRawMessage* raw){ - /*Get row of the active channel. - *Upper row is row 1. - */ - Int_t Offset=0; -// Int_t SpadicId=GetSpadicID(raw); - if(GetLayerID(raw)<2) - { - return 0; - } - return GetChannelOnPadPlane(raw)/16+Offset; - }; - virtual Int_t GetRobID(CbmSpadicRawMessage* raw){ - return raw->GetEquipmentID(); //blubb - } - virtual Int_t GetSpadicID(CbmSpadicRawMessage* raw){ - return raw->GetSourceAddress(); //blubb - } - virtual Int_t GetColumnID(CbmSpadicRawMessage* raw){ - /*Get column of the active channel. - *With view towards the target, column 0 is on the left side. - *Lower numbered colums are towards the left side of the module. - */ - Int_t Offset=0; - if(GetSpadicID(raw)>1) - return 0; - Offset=GetRobID(raw)*16; - Int_t ColID=(GetChannelOnPadPlane(raw))%16+Offset; - return ColID; - }; - virtual Int_t GetLayerID(CbmSpadicRawMessage* raw) - { - Int_t SpadicId =GetSpadicID(raw); - Int_t AfckId=GetRobID(raw); - Int_t ChannelId=GetChannelOnPadPlane(raw); - if (SpadicId/2==0) - return 2; - else{ - switch(ChannelId){ - case 31: return 0; - case 27: return 1; - } - } - LOG (ERROR) << this->GetName()<< ": Unknown SPADIC on Afck "<< AfckId << "SPADICID "<< SpadicId<<". Unable to find layer."; - return -1; - }; - - CbmTrdTestBeamTools2017GIF(const CbmTrdTestBeamTools2017GIF&); - CbmTrdTestBeamTools2017GIF operator=(const CbmTrdTestBeamTools2017GIF&); - public: - - ClassDef(CbmTrdTestBeamTools2017GIF,1); -}; - -#endif diff --git a/beamtime/trd/tools/CbmTrdTestBeamTools2018GIF.cxx b/beamtime/trd/tools/CbmTrdTestBeamTools2018GIF.cxx deleted file mode 100644 index ccc637d346ac5ef0c1f8171e7669d1567c021219..0000000000000000000000000000000000000000 --- a/beamtime/trd/tools/CbmTrdTestBeamTools2018GIF.cxx +++ /dev/null @@ -1,17 +0,0 @@ -/*First Version of TestBeam tools, developed for the SPS2016 beamtime and the legacy DAQ-chain. - *Intended for the F/MS Prototypes. - *For usage with Bucharest, modifications of the functions GetChannelMap and GetRowID are neccessary. -*/ - -#include "CbmTrdTestBeamTools2018GIF.h" -#include "FairLogger.h" -#include "CbmTrdAddress.h" -#include <algorithm> - -ClassImp(CbmTrdTestBeamTools2018GIF) - -CbmTrdTestBeamTools2018GIF::CbmTrdTestBeamTools2018GIF () : CbmTrdTestBeamTools() -{ - LOG(info) << TString("Default Constructor of ")+TString(this->GetName()); - Instance(this); -} diff --git a/beamtime/trd/tools/CbmTrdTestBeamTools2018GIF.h b/beamtime/trd/tools/CbmTrdTestBeamTools2018GIF.h deleted file mode 100644 index ee71ddc87807dbd54bb823476bd9fe49d07ea9a9..0000000000000000000000000000000000000000 --- a/beamtime/trd/tools/CbmTrdTestBeamTools2018GIF.h +++ /dev/null @@ -1,91 +0,0 @@ -#ifndef CBMTRDTESTBEAMTOOLS2018GIF_H -#define CBMTRDTESTBEAMTOOLS2018GIF_H - -#include "CbmTrdTestBeamTools.h" -#include "FairLogger.h" - -class CbmTrdTestBeamTools2018GIF: public CbmTrdTestBeamTools -{ - public: - CbmTrdTestBeamTools2018GIF(); - // CbmTrdTestBeamTools2018GIF():CbmTrdTestBeamTools2018GIF("CbmTrdTestBeamTools2018GIF"){}; - ~CbmTrdTestBeamTools2018GIF(){}; - - Float_t GetSamplingTime(){ - /* - * Get inverse sampling frequency in nano seconds. - */ - return 1E3/16; - }; - Int_t GetShapingTime(){ - /* - * Get shaping time in nano seconds. - */ - return 240; - }; - virtual Int_t GetNrLayers(){ - return 3; - }; - virtual Int_t GetNrRows(Int_t /*Layer*/=0){ - //Get the Number of PadRows in the corresponding Layer - return 2; - }; - virtual Int_t GetNrColumns(Int_t /*Layer*/=0){ - //Get the Number of active Columns in the corresponding Layer - return 16; - } - virtual Int_t GetNrRobs(){ - //Get the Number of active ROBS in the Setup; - return 1; - }; - virtual Int_t GetNrSpadics(Int_t = 0){ - return 3; - } - virtual Int_t GetRowID(CbmSpadicRawMessage* raw){ - /*Get row of the active channel. - *Upper row is row 1. - */ - Int_t Offset=0; -// Int_t SpadicId=GetSpadicID(raw); - return GetChannelOnPadPlane(raw)/16+Offset; - }; - virtual Int_t GetRobID(CbmSpadicRawMessage* raw){ - return raw->GetEquipmentID(); //blubb - } - virtual Int_t GetSpadicID(CbmSpadicRawMessage* raw){ - return raw->GetSourceAddress(); //blubb - } - virtual Int_t GetColumnID(CbmSpadicRawMessage* raw){ - /*Get column of the active channel. - *With view towards the target, column 0 is on the left side. - *Lower numbered colums are towards the left side of the module. - */ - Int_t Offset=0; - Int_t ColID=(GetChannelOnPadPlane(raw))%16+Offset; - return ColID; - }; - /**Get layer of current message. - * - * Returns the layer of the current message. In GIF2018, the third - * Spadic was a Lemo FEB with scintillator / coincidence signals - * connected. Here, all signals of this Spadic are assigned to one - * layer. - */ - virtual Int_t GetLayerID(CbmSpadicRawMessage* raw) - { - Int_t SpadicId =GetSpadicID(raw); - // Int_t AfckId=GetRobID(raw); - // Int_t ChannelId=GetChannelOnPadPlane(raw); - return SpadicId/2; - // LOG (error) << this->GetName()<< ": Unknown SPADIC on Afck "<< AfckId << "SPADICID "<< SpadicId<<". Unable to find layer."; - // return -1; - }; - - CbmTrdTestBeamTools2018GIF(const CbmTrdTestBeamTools2018GIF&); - CbmTrdTestBeamTools2018GIF operator=(const CbmTrdTestBeamTools2018GIF&); - public: - - ClassDef(CbmTrdTestBeamTools2018GIF,1); -}; - -#endif diff --git a/beamtime/trd/tools/CbmTrdTestBeamToolsBuch2016.cxx b/beamtime/trd/tools/CbmTrdTestBeamToolsBuch2016.cxx deleted file mode 100644 index e36bef145f5d5347da71de9738dd7ba8f920b33e..0000000000000000000000000000000000000000 --- a/beamtime/trd/tools/CbmTrdTestBeamToolsBuch2016.cxx +++ /dev/null @@ -1,17 +0,0 @@ -/*First Version of TestBeam tools, developed for the SPS2016 beamtime and the legacy DAQ-chain. - *Intended for the F/MS Prototypes. - *For usage with Bucharest, modifications of the functions GetChannelMap and GetRowID are neccessary. -*/ - -#include "CbmTrdTestBeamToolsBuch2016.h" -#include "FairLogger.h" -#include "CbmTrdAddress.h" -#include <algorithm> - -ClassImp(CbmTrdTestBeamToolsBuch2016) - -CbmTrdTestBeamToolsBuch2016::CbmTrdTestBeamToolsBuch2016 () : CbmTrdTestBeamTools() -{ - LOG(info) << TString("Default Constructor of ")+TString(this->GetName()); - Instance(this); -} diff --git a/beamtime/trd/tools/CbmTrdTestBeamToolsBuch2016.h b/beamtime/trd/tools/CbmTrdTestBeamToolsBuch2016.h deleted file mode 100644 index 3245adcbbfe137ce515e4674511931450483dfb5..0000000000000000000000000000000000000000 --- a/beamtime/trd/tools/CbmTrdTestBeamToolsBuch2016.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef CBMTRDLABTOOLSBUCH2016_H -#define CBMTRDLABTOOLSBUCH2016_H - -#include "CbmTrdTestBeamTools.h" - -class CbmTrdTestBeamToolsBuch2016: public CbmTrdTestBeamTools -{ - public: - CbmTrdTestBeamToolsBuch2016(); - // CbmTrdLabTools():CbmTrdLabTools("CbmTrdBeamtimeTools"){}; - ~CbmTrdTestBeamToolsBuch2016(){}; - - //virtual Int_t GetBaseEquipmentID(){ - // //Get the BaseEquipmentID - // return 0xE001; - // }; - - virtual Int_t GetNrRobs(){ - return 1; - }; - - /* virtual Int_t GetNrRows(){ - //Get the Number of active Rows in the corresponding Layer - - return 1; - }; - - virtual Int_t GetColumnID(CbmSpadicRawMessage* raw){ - // of course we have 32 columns - Int_t ColID=GetChannelOnPadPlane(raw); - return ColID; - }; - - virtual Int_t GetRowID(CbmSpadicRawMessage* raw){ - //for the Bucharest Padplane there is only one row - return 0; - };*/ - - virtual Int_t GetNrSpadics(Int_t = 0){ - return 1; - } - virtual Int_t GetLayerID(CbmSpadicRawMessage* /*raw*/) - { - return 0; - }; - - virtual std::vector<Int_t> GetChannelMap(CbmSpadicRawMessage* /*raw*/){ - /* - * Get the channel mapping that is valid for the spadic where raw originated. - */ - std::vector<Int_t> map = {{31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16, - 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0}}; - return map; - }; - - CbmTrdTestBeamToolsBuch2016(const CbmTrdTestBeamToolsBuch2016&); - CbmTrdTestBeamToolsBuch2016 operator=(const CbmTrdTestBeamToolsBuch2016&); - public: - - ClassDef(CbmTrdTestBeamToolsBuch2016,1); -}; - -#endif diff --git a/fles/mcbm2018/CMakeLists.txt b/fles/mcbm2018/CMakeLists.txt index 5718eb1b4e5311846127c7e22ab2be9494169017..dbd294e9d26b68c8407cd9593b2479fc3c69775c 100644 --- a/fles/mcbm2018/CMakeLists.txt +++ b/fles/mcbm2018/CMakeLists.txt @@ -7,8 +7,6 @@ Set(INCLUDE_DIRECTORIES ${CBMDATA_DIR} ${CBMDATA_DIR}/base - ${CBMDATA_DIR}/beamtime - ${CBMDATA_DIR}/beamtime/fhodo ${CBMDATA_DIR}/raw ${CBMDATA_DIR}/sts ${CBMDATA_DIR}/much @@ -18,8 +16,6 @@ Set(INCLUDE_DIRECTORIES ${CBMDATA_DIR}/psd ${CBMDATA_DIR}/trd - ${CBMROOT_SOURCE_DIR}/beamtime/base - ${CBMROOT_SOURCE_DIR}/fles/flestools ${CBMROOT_SOURCE_DIR}/fles/mcbm2018 @@ -135,7 +131,7 @@ EndIf() Set(LINKDEF CbmFlibMcbm2018LinkDef.h ) Set(LIBRARY_NAME CbmFlibMcbm2018) Set(DEPENDENCIES - CbmFlibFlesTools CbmData CbmBase CbmBeamtimeBase fles_ipc Eve Base CbmTrdBase + CbmFlibFlesTools CbmData CbmBase fles_ipc Eve Base CbmTrdBase ) GENERATE_LIBRARY() diff --git a/macro/beamtime/mcbm2019/convert_tsa_gdpb.C b/macro/beamtime/mcbm2019/convert_tsa_gdpb.C index 6628b95cd39eee781ac9442ae5f01324298778f5..d88effcd6342cfe86311a9beb38f603ea97b4889 100644 --- a/macro/beamtime/mcbm2019/convert_tsa_gdpb.C +++ b/macro/beamtime/mcbm2019/convert_tsa_gdpb.C @@ -54,7 +54,7 @@ void convert_tsa_gdpb(TString inFile = "", Int_t nrEvents=0) source->AddUnpacker(raw_conv_gdpb, 0x90, ECbmModuleId::kTof );//gDPB T0 A & B // --- Event header - FairEventHeader* event = new CbmTbEvent(); + FairEventHeader* event = new FairEventHeader(); event->SetRunId(1); // --- Run diff --git a/macro/beamtime/mcbm2019/convert_tsa_mcbm.C b/macro/beamtime/mcbm2019/convert_tsa_mcbm.C index aee3be6d42a9e8c7a52e2625da39404d43875115..5107de2cf3ee150afdcbbf4e19ba8ef42e4e4074 100644 --- a/macro/beamtime/mcbm2019/convert_tsa_mcbm.C +++ b/macro/beamtime/mcbm2019/convert_tsa_mcbm.C @@ -62,7 +62,7 @@ void convert_tsa_mcbm(TString inFile = "", Int_t nrEvents=0) source->AddUnpacker(raw_conv_gdpb, 0x90, ECbmModuleId::kTof );//gDPB T0 A & B // --- Event header - FairEventHeader* event = new CbmTbEvent(); + FairEventHeader* event = new FairEventHeader(); event->SetRunId(1); // --- Run diff --git a/macro/beamtime/mcbm2019/convert_tsa_sdpb.C b/macro/beamtime/mcbm2019/convert_tsa_sdpb.C index b845b16341ab4eb06b9470dcdc2a3044a062e593..bcf7739a9ed936c1707ffbb6756bc5b772c9d8dd 100644 --- a/macro/beamtime/mcbm2019/convert_tsa_sdpb.C +++ b/macro/beamtime/mcbm2019/convert_tsa_sdpb.C @@ -53,7 +53,7 @@ void convert_tsa_sdpb(TString inFile = "", Int_t nrEvents=0) source->AddUnpacker(raw_conv_sdpb, 0x10, ECbmModuleId::kSts);//STS xyter from STS and MUCH // --- Event header - FairEventHeader* event = new CbmTbEvent(); + FairEventHeader* event = new FairEventHeader(); event->SetRunId(1); // --- Run diff --git a/macro/beamtime/mcbm2019/unpack_tsa_mcbm.C b/macro/beamtime/mcbm2019/unpack_tsa_mcbm.C index 40fa1b244fb79b5ddbf3bf6ef29fc89884f164be..f15db00423b0709d01474249b50e77f6029a4f49 100644 --- a/macro/beamtime/mcbm2019/unpack_tsa_mcbm.C +++ b/macro/beamtime/mcbm2019/unpack_tsa_mcbm.C @@ -253,7 +253,7 @@ void unpack_tsa_mcbm(TString inFile = "", UInt_t uRunId = 0, UInt_t nrEvents=0, // source->AddUnpacker(unpacker_hodo, 0x10, kHodo );//HODO xyter // --- Event header - FairEventHeader* event = new CbmTbEvent(); + FairEventHeader* event = new FairEventHeader(); event->SetRunId(uRunId); // --- RootFileSink diff --git a/macro/beamtime/mcbm2019/unpack_tsa_mcbm_kronos.C b/macro/beamtime/mcbm2019/unpack_tsa_mcbm_kronos.C index b776c557abbd9b903eb7e949ee25cbf6c6b2a6f5..ea6aa8e25a71716a44f25d63e53a91b75d018b6e 100644 --- a/macro/beamtime/mcbm2019/unpack_tsa_mcbm_kronos.C +++ b/macro/beamtime/mcbm2019/unpack_tsa_mcbm_kronos.C @@ -243,7 +243,7 @@ void unpack_tsa_mcbm_kronos( UInt_t uRunId = 0, UInt_t nrEvents=0, TString outDi source->AddUnpacker(unpacker_psd, 0x80, ECbmModuleId::kPsd );//PSD // --- Event header - FairEventHeader* event = new CbmTbEvent(); + FairEventHeader* event = new FairEventHeader(); event->SetRunId(uRunId); // --- RootFileSink diff --git a/macro/beamtime/mcbm2019/unpack_tsa_mcbm_mfles.C b/macro/beamtime/mcbm2019/unpack_tsa_mcbm_mfles.C index ceaedc3e030c5523f7c890b13236054c64206bd7..105ff05da021f40620afda218002008878f6c006 100644 --- a/macro/beamtime/mcbm2019/unpack_tsa_mcbm_mfles.C +++ b/macro/beamtime/mcbm2019/unpack_tsa_mcbm_mfles.C @@ -1614,7 +1614,7 @@ void unpack_tsa_mcbm_mfles( UInt_t uRunId = 0, UInt_t nrEvents=0, TString outDir // source->AddUnpacker(unpacker_hodo, 0x10, ECbmModuleId::kHodo );//HODO xyter // --- Event header - FairEventHeader* event = new CbmTbEvent(); + FairEventHeader* event = new FairEventHeader(); event->SetRunId(uRunId); // --- RootFileSink diff --git a/macro/beamtime/readLmd.C b/macro/beamtime/readLmd.C index 4cc61f7018e8d35cf4a5504546cc663aaa9c9fb2..06c42d52d8f641aa16f48e7504c9e4beb10b03a1 100644 --- a/macro/beamtime/readLmd.C +++ b/macro/beamtime/readLmd.C @@ -48,7 +48,7 @@ void readLmd() source->AddFile(inFile); // --- Event header - FairEventHeader* event = new CbmTbEvent(); + FairEventHeader* event = new FairEventHeader(); event->SetRunId(260); // --- Run diff --git a/macro/beamtime/readLmdMuch.C b/macro/beamtime/readLmdMuch.C index 7da409b9ad59a5295f1d02980a0909681dfa8a2d..cbff7b24d7398800cd9e205f3bedd91dc4ba639b 100644 --- a/macro/beamtime/readLmdMuch.C +++ b/macro/beamtime/readLmdMuch.C @@ -77,7 +77,7 @@ void readLmdMuch() source->AddFile(inFile); // --- Event header - FairEventHeader* event = new CbmTbEvent(); + FairEventHeader* event = new FairEventHeader(); event->SetRunId(021); // --- Run diff --git a/macro/beamtime/readLmdNew.C b/macro/beamtime/readLmdNew.C index ec5b3a4964152dbad94c5fe9aadfecabd54bfd70..8aa4901cabaa7c2b75c979d3839864461662981d 100644 --- a/macro/beamtime/readLmdNew.C +++ b/macro/beamtime/readLmdNew.C @@ -74,7 +74,7 @@ void readLmdNew() source->AddFile(inFile); // --- Event header - FairEventHeader* event = new CbmTbEvent(); + FairEventHeader* event = new FairEventHeader(); event->SetRunId(021); // --- Run diff --git a/macro/beamtime/readLmd_Anna.C b/macro/beamtime/readLmd_Anna.C index 5f930aee183bb080ba538db57812f72b22ff54e9..7622e3e4f592a6d68673e40655ac93609ef00fd3 100644 --- a/macro/beamtime/readLmd_Anna.C +++ b/macro/beamtime/readLmd_Anna.C @@ -81,7 +81,7 @@ void readLmd_Anna() source->SetTriggeredMode(trigger); // --- Event header - FairEventHeader* event = new CbmTbEvent(); + FairEventHeader* event = new FairEventHeader(); event->SetRunId(012); // --- Run