diff --git a/DaVinciSys/CMakeLists.txt b/DaVinciSys/CMakeLists.txt index c1cabb485863f5e8ab7ef586d7401659459311e3..2380c29a0d57fc15f87bb8430f7b679414fe144d 100644 --- a/DaVinciSys/CMakeLists.txt +++ b/DaVinciSys/CMakeLists.txt @@ -5,11 +5,7 @@ gaudi_subdir(DaVinciSys v42r4) gaudi_depends_on_subdirs(DaVinciTests ############################## - # Patch just for this release! - Velo/VeloDAQ - Calo/CaloTools - ############################## - # Temporarily moved in from Stripping, for S23 release + # Temporarily moved in from Stripping Phys/StrippingCache ############################## Phys/DaVinci diff --git a/Phys/Tesla/CMakeLists.txt b/Phys/Tesla/CMakeLists.txt index ebf23836acfd3dc75071fb667af22d5dd0c9f63f..1b802e82a25989ede33aa810a460d31b455c936f 100644 --- a/Phys/Tesla/CMakeLists.txt +++ b/Phys/Tesla/CMakeLists.txt @@ -4,10 +4,6 @@ gaudi_subdir(Tesla v2r2) gaudi_depends_on_subdirs(Event/HltEvent - ############################## - # Patch just for this release! - Velo/VeloDAQ - ############################## Event/MicroDst Det/DDDB GaudiConfUtils diff --git a/Phys/TurboCache/CMakeLists.txt b/Phys/TurboCache/CMakeLists.txt index e67a7fb16d6b29647ec203644d6997845d4e2c5d..46d47996a75e481e70fcf1a0eb538512d2c32e82 100644 --- a/Phys/TurboCache/CMakeLists.txt +++ b/Phys/TurboCache/CMakeLists.txt @@ -4,10 +4,6 @@ gaudi_subdir(TurboCache v1r0) gaudi_depends_on_subdirs(Phys/Tesla - ############################## - # Patch just for this release! - Velo/VeloDAQ - ############################## Phys/LoKiHlt Phys/LoKiArrayFunctors Phys/LoKiHlt diff --git a/Velo/VeloDAQ/CMakeLists.txt b/Velo/VeloDAQ/CMakeLists.txt deleted file mode 100644 index 00f169f86188c42167d3d1db4f2eec45e304c453..0000000000000000000000000000000000000000 --- a/Velo/VeloDAQ/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -################################################################################ -# Package: VeloDAQ -################################################################################ -gaudi_subdir(VeloDAQ v6r13) - -gaudi_depends_on_subdirs(DAQ/Tell1Kernel - Det/VeloDet - Event/DAQEvent - Event/DigiEvent - Event/RecEvent - Event/VeloEvent - DAQ/DAQKernel - Si/SiDAQ) - -gaudi_add_module(VeloDAQ - src/*.cpp - INCLUDE_DIRS DAQ/Tell1Kernel Event/DigiEvent Event/VeloEvent Si/SiDAQ DAQ/DAQKernel - LINK_LIBRARIES VeloDetLib DAQEventLib DAQKernelLib RecEvent) - -gaudi_install_python_modules() - diff --git a/Velo/VeloDAQ/doc/release.notes b/Velo/VeloDAQ/doc/release.notes deleted file mode 100755 index 042c39cebd822ca0a59b96d1594f1428ca6cfa23..0000000000000000000000000000000000000000 --- a/Velo/VeloDAQ/doc/release.notes +++ /dev/null @@ -1,602 +0,0 @@ -!-------------------------------------------------------------------------- -! Package : VeloDAQ -! Responsible : David Hutchcroft, Kurt Rinnert -!-------------------------------------------------------------------------- - -!========================= VeloDAQ v6r13 2016-03-16 ========================= -! 2016-02-08 - Gerhard Raven - - C++11 modernization: - o prefer pass-by-reference over pass-by-pointer if nullptr is not a valid argument - o add const where possible - o prefer emplace_back over push_back - o prefer STL algorithms over raw loops - o prefer range-based loops - o prefer direct member initialization - o prefer FastClusterContainer::resize over pop_back in loop - o prefer std::unique_ptr over raw pointer + explicit delete - -!========================= VeloDAQ v6r12p1 2015-10-12 ========================= -! 2015-08-03 - Gerhard Raven - - remove #include of obsolete Gaudi headers - -!========================= VeloDAQ v6r12 2014-07-29 ========================= - -! 2014-02-18 - David Hutchcroft - - Added LHCb::RawEventLocation::Velo to the default location list for Stripping 21 - -!========================= VeloDAQ v6r11 2014-02-18 ========================= -! 2014-02-17 - David Hutchcroft - - DefaultVeloRawBufferDecoders.py to use RawEventLocations (used by VETRA nightlies) - -! 2014-02-14 - Rob Lambert - - Suppress velo decoder printout for nominal options (DAQ/RawEvent Other/RawEvent) - -! 2014-02-12 - Rob Lambert - - Adapt velo decoder tools to Decoder base classes, task #49078 - -!========================= VeloDAQ v6r10 2013-06-03 ========================= -! 2013-05-27 - Marco Cattaneo - - Fix clang32 warnings and UNINIT_CTOR defects - -!========================= VeloDAQ v6r9p1 2013-04-22 ========================= -! 2013-04-08 - Marco Cattaneo - - Add __init.py__ to please CMake - -!========================= VeloDAQ v6r9 2013-02-14 ========================= -! 2013-01-25 - David Hutchcroft - - Fixed Coverity warning about memory leak if lite to full cluster conversion failed. - - Made a bad bank length set a non-abort ProcStatus. - -! 2013-01-17 - David Hutchcroft - - Replaced check on full bank length from decoding lite clusters (crashed BigEvents) - -! 2013-01-16 - David Hutchcroft - - Remove check on full bank length from decoding lite clusters by default - Should make trigger slightly faster (some TELL1 failure modes could cause problems) - -! 2012-12-20 - Marco Cattaneo - - Fix Coverity defects - - Use getIfExists - - Remove unnecessary finalize() methods - -!========================= VeloDAQ v6r8 2012-11-28 ========================= -! 2012-11-21 - Marco Clemencic - - Added CMake configuration file. - -!========================= VeloDAQ v6r7 2012-06-25 ========================= -! 2012-06-08 - Marco Cattaneo - - Add RawEventLocations property to decoders, to allow to specify a - search list of locations. Default is to look for RawEventLocation::Other - followed by RawEventLocation::Default. - - RawEventLocation property is declared obsolete. If set, it is prepended - to RawEventLocations and a warning is printed. - -!========================= VeloDAQ v6r6 2011-12-14 ========================= -! 2011-11-29 - David Hutchcroft - - Hide warning by default due to problems with TELL1 cluster maker - putting the same strip into two clusters (to be re-enabled for data/mc - after the TELL1 bug is resolved). - -! 2011-11-28 - Marco Cattaneo - - Fix coverity defect 28294: UNINIT_CTOR in VeloClustersToRaw - - Add some missing calls to GaudiAlgorithm::finalize - - Replace obsolete DeclareFactoryEntries includes - - Fix trivial icc remarks - -!========================= VeloDAQ v6r5 2011-11-08 ========================= -! 2011-10-05 - Kurt Rinnert - - Changed ZS decoder so it maintains event specific information in - DeVeloSensor::Tell1EventInfo (requested by HLT). No change in behaviour as - no client code for the new feature exists yet. - -! 2011-09-29 - Kurt Rinnert - - merged source coode for less-than predicate of internal and standard VELO - cluster pointers. - - added new algorithm to encode raw banks from VELO clusters - -!========================= VeloDAQ v6r4 2011-07-27 ========================= -! 2011-07-19 - Kurt Rinnert - - added swtich to ZS decoder to allow decoding of clusters in the presence of - errors for expert debugging. - -! 2011-06-24 - Eduardo Rodrigues - - Protected unprotected debug messages - -!========================= VeloDAQ v6r3 2011-06-15 ========================= -! 2011-04-27 - Tomasz Szumlak - - fix of the problems reported by the coverity tool - -!========================= VeloDAQ v6r2 2011-02-25 ========================= -! 2011-02-17 - Tomasz Szumlak - - a minor modification of the decoder code - add option IgnoreErrorBanks - that makes using the TAE scan in VETRA more convinient - -! 2011-02-14 - Tomasz Szumlak - - considerably large changes in the VeloFull decoding software to cope - with the nzs data that are sent together with the VeloError banks. - PrepareVeloFullRawBuffer has been redesigned and rewritten. At the - moment, if an ErrorBank is detected it will automatically divide the - nzs data stream. The normal data will be prepared, decoded and put at - the default location whilst the data associated with an error bank will - end up in the container that will be stored at 'Raw/Velo/DecodedPartialADCs' - 'Partial' here means that the nzs bank that was sent together with an - error bank may not be complete. - -!========================= VeloDAQ v6r1 2011-02-01 ========================= -! 2011-01-31 - Eduardo Rodrigues - - PrepareVeloRawBuffer: default bank version set to v3 - -!========================= VeloDAQ v6r0p1 2010-10-25 ========================= -! 2010-10-18 - David Hutchcroft - - Default is now now ERROR from the decoding (can override in options) - - Fix for online trigger farm flooding with header bit errors - - Does not solve the underlaying hardware issue - -!========================= VeloDAQ v6r0 2010-08-25 ======================= -! 2010-08-03 - David Hutchcroft - - Added a ProcStatus when the bank has a header bit error and is not - decoded - -! 2010-07-28 - Tomasz Szumlak - - nzs data stream decoder code changed to cope with corrupted banks - PrepareVeloFullRawBuffer can now discard banks that contains data - for which error was triggered. The corrupted data can be analysed - in a separate job with flag: - - DecodeErrorStream = True - -!========================= VeloDAQ v5r3 2010-07-20 ======================= -! 2010-07-05 - David Hutchcroft - - Adapted ProcStatus setting to changes in the interface and official - use policy - -! 2010-06-30 - Chris Jones - - Add a missing use statement for Event/RecEvent in cmt/requirements - -! 2010-06-24 - David Hutchcroft - - Changed how ProcStatus is used as per Savannah task #16278 - Now still set ProcStatus for any problem, but also set - ProcStatus->setAborted(true) - when all clusters are removed due to high multiplicity - Removed setFilterPass options as it was unused. - -!========================= VeloDAQ v5r2 2010-05-15 ======================= -! 2010-05-13 - David Hutchcroft - - Make lite decoding check full bank length, remove lite and full clusters - from the conatiners for corrupted TELL1 banks then continue normally - -! 2010-05-13 - Rob Lambert - - Review warnings/errors - -!========================= VeloDAQ v5r1 2010-04-26 ======================= -! 2010-04-21 - David Hutchcroft - - Added the ProcStatus object if the VELO decoding fails for any reason - Added an option to setFilterPass(fail) (default to off) for HLT - -!========================= VeloDAQ v4r14 2010-04-18 ======================= -! 2010-04-18 - Gerhard Raven - - retag v5r0 as v4r14 so it can be used in Moore v8r10. cmt does not accept - it when an application project has a package with a different major number - from the underlying project - -!========================= VeloDAQ v5r0 2010-04-13 ======================= -! 2010-04-13 - David Hutchcroft - - On advice from Gerhard about the trigger changed the behviour when too - many VELO clusters to printing an error and erasing all of the clusters - (both lite and full) - -! 2010-04-13 - David Hutchcroft - - Made decoding more that 10k Velo clusters an AbortEvent incident to cap - the tracking reconstruction time - -! 2010-04-06 - David Hutchcroft - - Made a corrupted bank length in the full cluster decoding an Abort event - incident and caused the algorthm processing of that event to cease. - -! 2010-03-19 - Serena Oggero - - DecodePileUpData : changed info() messages to Info() for non existing PU - banks - -!========================= VeloDAQ v4r13 2010-03-18 ====================== -! 2010-03-17 - Kurt Rinnert - - ZS banks are no longer decoded when the TELL1 has set the error flag - -! 2010-03-03 - Tomasz Szumlak - - add protection against corrupted banks in Velo decoders - -!========================= VeloDAQ v4r12 2009-11-27 ====================== -! 2009-11-25 - Kurt Rinnert - - fixed memory leak in SmartVeloErrorDecoder - - lowered message severity in PU decoding - -!========================= VeloDAQ v4r11 2009-11-18 ====================== -! 2009-11-17 - Tomasz Szumlak - - modify PrepareVeloFullRawBuffer algorithm to handle round-robin data - - add protection in SmartVeloErrorDecoder against corrupted data, this - problem needs to be better understood though - -!========================= VeloDAQ v4r10 2009-11-16 ====================== -! 2009-11-16 - Marco Cattaneo - - In DecodeVeloRawBuffer.cpp: - . Redo previous fix to stop printing any warnings by default. If DEBUG, ten - warnings are printed - . Protect a debug in the event loop with test on MsgLevel(MSG::DEBUG) - - Replace endreq by endmsg - -! 2009-11-12 - Tomasz Szumlak - - change the type of message that is issued after duplicate cluster has - been found - this is a know problem with Velo Tell1 firmware, from now - on when this kind of situation is encountered a Warning message will - be printed out - -! 2009-11-02 - Serena Oggero - - bug fix in DecodePileUpData (switched to unsigned int) - -! 2009-10-30 - Serena Oggero - - bug fix in DecodePileUpData: there were some StatusCode FAILURE resulting - in a crash when the Event was not retreived from the right location - - added a property to disable the NZS banks decoding - -!========================= VeloDAQ v4r9 2009-10-20 ======================= -! 2009-09-25 - Kurt Rinnert - - bug fix in error bank decoder: there were no (empty) event infos inserted - for PPFPGAs w/o errors resulting in a creash when trying to access an info - for a PPFPGA > number of PPFGA w/ errors. Of course the positions were also - wrong. The only cases handled correctly before the fix were: - 1. only errors in PPFPGA 0 - 2. errors in all PPFPGAs - -!========================= VeloDAQ v4r8 2009-09-09 ======================= -! 2009-09-09 - Kurt Rinnert - - work around for missing C99 standard header on Windows(TM) - - removed unnecessary and potentially confusing 'using' directives for - namespace LHCb - -! 2009-09-03 - Marco Cattaneo - - Remove obsolete file src/VeloDAQ_dll.cpp - -! 2009-08-31 - Kurt Rinnert - - fixed compiler warnings in DecodePileUpData - -! 2009-08-04 - Serena Oggero - - added DecodePileUpData, to decode PileUp banks (binary), both NZS and ZS. - The output is put in the TES using the VeloCluster container with an - arbitrary value of 1 ADC per hit. - -!========================= VeloDAQ v4r7 2009-06-17 ======================= -! 2009-06-06 - Kurt Rinnert - - more robustness in full cluster decoding. Duplicate channel IDs now only - causes a cluster to be dropped, not the entire bank for a source ID. - -! 2009-06-05 - Kurt Rinnert - - made PrepareVeloFullRawBuffer handle missing input container gracefully - -!========================= VeloDAQ v4r6 2009-05-08 ======================= -! 2009-03-12 - Tomasz Szumlak - - Change the default values for SectorCorrection and CableOrder variables - no need to put additional lines into options file - - Add flexibility to the SmartDecoder algorithm it no longer assumes - anything about expected number of slots in error bank - -!========================= VeloDAQ v4r5 2009-02-20 ======================= -! 2009-01-19 - David Hutchcroft - - Added a sort to the decoding of the VELO lite clusters for the track fit - -!========================= VeloDAQ v4r4p1 2009-01-12 ===================== -! 2008-12-09 - Marco Cattaneo - - Fix gcc 4.3 compilation warnings - -!========================= VeloDAQ v4r4 2008-11-21 ======================= -! 2008-10-28 - Tomasz Szumlak - - Degrading some message level from info() to debug() - related with - new data that can contain errors only for one ppfpga processor - - Add property for PrepareVeloFullRawBuffer - used when consecutive - events are analysed - -! 2008-10-16 - Tomasz Szumlak - - Modified SmartErrorBankDecoder - if there is no error banks - detected it continue processing and skips to the next event - (some minor improvement that makes the code compatible with - new RawEvent object and allows at the same time to process - the older files) - -! 2008-10-16 - Kurt Rinnert - - The decoding of full VELO clusters for bank version 3 now checks whether a - key already exists in the container before insertion. This is a change in - policy, not a bug fix. We will no longer crash in the case of duplicate - keys. Instead an error message containing the problematic source ID is - issued and all clusters from this source are removed. - -! 2008-10-08 - Eduardo Rodrigues - - added DefaultVeloRawBufferDecoders.py, a new Python helper module - containing default configurations of the DecodeVeloRawBuffer algorithm - for decoding into VeloLiteClusters or VeloClusters. - - requirements file changed to produce configurable - -!========================= VeloDAQ v4r3 2008-09-04 ======================= -! 2008-08-31 - Kurt Rinnert - - missing input containers are no longer an error condition in NZS decoder - - if input is missing, the cluster decoder now only creates empty containers - for the requested cluster type. - -! 2008-08-26 Tomasz Szumlak - - add a new algoritm to deal with complicated error bank - SmartVeloErrorBankDecoder, this piece of code is able - to check which fpga processors sent errors and deal with - different size of the bank that depends on a raw file content - - update PrepareVeloFullRawBuffer - error decoding is now decoupled - from NZS data - -! 2008-08-25 Malcolm John - - add a cluster filter algorithm that filters the [lite]clusters into - new TES locations according to a few pre-defined criteria like - "is R", is phi", etc. Also maximum and and minimum limits can be required - -!========================= VeloDAQ v4r2 2008-05-26 ======================= -! 2008-05-26 T Szumlak - - adapt VeloFull decoding to run without ODIN bank; this behaviour - is contorlable via options file - -!========================= VeloDAQ v4r1 2008-04-17 ======================= -! 2008-03-18 - Kurt Rinnert - - minor bug fix introduced in latest update of VeloFullDecoder: a size check - in the decoding method assumed ADC encoding. This was removed, there was - no check before anyway. Need to decide whether we want a smart check or - rather issue an error message. - -! 2008-03-13 - Kurt Rinnert - - changes in DecodeVeloFullRawBuffer and VeloFullDecoder: - - avoid unnecessary copies of large vectors - - protect frequent streams to debug() with a flag - - instatiate the various VeloFullDecoders only once, so their internal - containers live for the whole job - - made local ADC/Header/Ped buffers member variables, so their memory is - only allocated once per job - - the target cable order is now configurable - - the cable order correction is now off by default - - all TES input and output locations are now configurable - -!========================= VeloDAQ v4r0 2007-09-19 ======================= -! 2007-09-19 - Kurt Rinnert - - changed the encoder default back to bank version 2. We have to sort out in - more detail how the TELL1 creates the bank before we change the default. - This will only be relevant for the next major MC production, so for now we - live with the old version. - -! 2007-09-19 - Tomasz Szumlak - - Modified name of the NZS decoder - -! 2007-09-19 - Marco Cattaneo - - Adapt to new location of Tell1Kernel includes - -! 2007-09-17 - Tomasz Szumlak - - decoding of the non-zero suppressed (NZS) banks added, new code can cope - with decoding of the VeloFull data bank, PedestalBank and VeloErrorBank. - Also EvtInfo object, that includes a number of informations critical from - point of view of the emulation, can be created. Beetle headers do not - make a separate data stream but are part of the NZS header bank. The headers - are also decoded and stored. All decoding routines follow closely appropriate - EDMS notes describing TELL1 data formats. - -! 2007-09-17 - Kurt Rinnert - - make the decoder fail more graciously in case a source ID can not matched - to a sensor number. This should never happen and indicates an inconsistent - conditions data base. However, crashing seemed a bit harsh. Now an error - message is issued and the source ID is simply skipped. - -! 2007-09-16 - Kurt Rinnert - - introduced new version 3 of VELO raw buffer. The only difference to - version 2 is the treatment of interstrip positions. These are now computed - and rounded exactly like on the TELL1 board. The default for - PrepareVeloRawBuffer (i.e. Boole) is now the new, correct version. The - old behaviour can be obtained via the BankVersion property. - - added proper bank version management to decoder. The correct decoding is - determined from the raw bank's version. The version can also be enforced - via the ForceBankVersion property (useful for testbeam data). In all cases - the code is protected against unsupported bank versions. There is one - dangerous scenario, however: if a user decides to use a new version of - Boole and reconstructs the events with and old version Brunel, there will - be trouble if the bank version is not configured properly in either the - encoder or the decoder. Not a likely scenario, I hope. - Otherwise this change is completely transparent. Old data will be - processed just like before. - - made sure the decoder creates empty cluster and lite cluster containers on - the TES even if the raw event is missing or it encounters an unsupported - bank version. If a byte count mismatch (corrupted raw bank) is discovered - during the cluster decoding the clusters from this source ID are removed from - the container. Clusters from other source IDs will be still available in - this case. - -!========================= VeloDAQ v3r5 2006-08-30 ======================= -! 2006-08-21 - Kurt Rinnert - - It really makes no sense to create banks for sensors that can not me mapped - to a Tell1 Id. So the code now protects against this (following Eugenia's - proposal more closely). This check should not be necessary if the geometry - XML and the CondDB sensor/Tell1 mapping are consistent. But it's not - expensive so better play it safe. - -! 2006-08-21 - Kurt Rinnert - - The source ID of the banks created by PrepareVeloRawBuffer are no longer - fixed to the sensor number. If the CondDB provides a sensor/Tell1 mapping, - the Tell1 ID is used as a source ID for the bank. This is mostly useful - for simulation of test beam setups. Note that the mapping technically also - happens int the default setup. In this case, however, the Tell1 Id maps - trivially onto the sensor number itself, i.e. default behaviour is not - affected by this feature. The implementation closely follows a proposal - by Eugenia Maria Puccio. - -! 2006-08-16 - Kurt Rinnert - - added option to DecodeVeloRawBuffer that allows to properly decode - clusters when the TELL1 encodes chip channels instead of software strip - numbers. No changes in default behaviour. - -!========================= VeloDAQ v3r4 2006-07-25 ======================= -! 2006-07-24 - David Hutchcroft - - Bug fix to previous update: was accidentally padding out clusters with - zero strips - -! 2006-07-19 - David Hutchcroft - - Removed sorting from decoding to full clusters, speed up decoding to - lite clusters slightly as well. - -! 2006-07-17 - Marco Hutchcroft - - Fix some windows compilation warnings - -! 2006-07-14 - David Hutchcroft - - Changed to official message service access, initialised fastcontainer to - full size at in lite cluster decoding. - -!========================= VeloDAQ v3r3 2006-06-30 ======================= -! 2006-04-21 - Kurt Rinnert - - added TELL1 source ID to sensor number mapping in decoding - -!========================= VeloDAQ v3r2 2006-04-18 ======================= -! 2006-04-18 - David Hutchcroft - - Fixed code to cope with a single cluster in a sensor in strip zero - without crashing - -! 2006-04-14 - David Hutchcroft - - Fixed code to always write a bank for every sensor, even the empty sensors - -! 2006-03-14 - Kurt Rinnert - - fixed bug in test code, does not affect standard operations - -!========================= VeloDAQ v3r1 2006-03-14 ======================= -! 2006-03-13 - Kurt Rinnert - - moved less-than operator for InternalVeloClusters outside of encoding - algorithm - - changed definition of less-than for VeloClusters to match the definition - for InternalVeloClusters - - added testing code - - fixed bugs revealed by testing with Boole v11r0: - 1. In the decoding to full VeloClusters the interstrip position bits - were not passed properly to the VeloLiteCluster. Independent of that the - VeloLiteCluster (or rather the SiCluster.ent) has a bug in the handling of - the interstrip position bits which will reported to Chris and Matt. - 2. In the decoding the treshold bit was only handled for one strip clusters - - updated some documentation - - some cosmetics - -! 2006-03-10 - Kurt Rinnert - - DecodeVeloRawBuffer now checks for the correct byte count when - decoding to full VeloClusters - - adapted to LHCb coding conventions - -! 2006-03-09 - Kurt Rinnert - - improved naming of cluster comparison functor - - added optional dumping of input clusters in PrepareVeloRawBuffer - -!========================= VeloDAQ v3r0 2006-03-13 ======================= -! 2006-03-09 - David Hutchcroft - - Added retrieval of threshold from VeloLiteCluster to set bit - -! 2006-03-07 - Kurt Rinnert - - in the encoding, the high threshold bit is explicitely *not* handled - anymore. This reflects the fact that this inforamtion can currently not - be retrieved from the VeloLiteCluster. As soon as VeloLiteCluster - provides it, the encoding will handle it properly. - - introduced enumeration type for bank version, similar to the ST - implementation - - introduced some constants with meaningful names for raw word sizes etc. - to avoid hardcoding this several times in the preparation of the raw buffer - - the raw buffer is now added to the raw event using RawEvent::createBank() and - RawEvent::adoptBank(). This allows to set the correct bank size in bytes. - The number of bytes in the bank is counted including the four header bytes but - without the padding bytes at the end of the bank. - -! 2006-03-02 - David Hutchcroft - - fixed a bug in DecodeVeloRawBuffer where containers were generated and - placed many times - - Fixed a bug in creation of VeloLiteClusters to set fracStripBits - -! 2006-02-23 - Kurt Rinnert - - finished implementation of decoding algorithm. The algorithm DecodeVeloRawBuffer - can decode the raw buffer into VeloLiteClusters or VeloClusters (or both). - The locations of the containers in the TES are fully configurable. - The default is to decode into VeloLiteCluster, all locations their respective defaults. - - fixed requirements file according to removed include directory - -! 2006-02-23 - Kurt Rinnert - - reorganised package, no headers exported anymore - - made changes necessary to take advantage of the generic decoder in SiDAQ. - This also fixes a problem on windows reported by Marco. - -! 2006-02-23 - M Needham - - Add missing velo policy trait - -! 2006-02-21 - Marco Cattaneo - - Cleaned up requirements - - Adapt to new location of InternalVeloCluster - -! 2006-02-17 - Kurt Rinnert - - removed obsolete algorithm declaration - -! 2006-02-17 - Kurt Rinnert - - fixed crash in PrepareVeloRawBuffer related to incorrect - resizing of the vector holding the sorted clusters - -! 2006-02-16 - Kurt Rinnert - - bug fix: sizeBits in VeloBitsPolicy was wrong after silly editing mistake - during cosmetic reformatting - -! 2006-02-16 - Kurt Rinnert - - bug fix: adc value for one strip clusters was not limited to 127 - - overflow bit in cluster word is now set correctly when an adc overflow - is detected - -! 2006-02-15 - Kurt Rinnert - - changed type of buffer_word into u_int32_t - - protected reading of InternalVeloClusters from missing bank - - added raw event writing - -! 2006-02-15 - Kurt Rinnert, David Jones - - introduced typedef for buffer_word, ensuring it is a 32 bit integer - - implemented raw buffer encoding from InternalVeloClusters according to EDMS 637676. - Since there currently is no RawBuffer object definition available, the encoded - clusters are not yet put into the TES. Will be fixed soon hopefully. - -! 2006-02-15 - Kurt Rinnert - - removed more obsolete dependencies - -! 2006-02-14 - Kurt Rinnert - - updated requirements file: removed depency on no longer existing Kernel - package, made new public include directory visible - - added new public include directory for low level encoding/decoding classes - - added new low level encoding/decoding classes - -! 2006-02-14 - Kurt Rinnert - - removed obsolete classes - - reduced PrepareVeloRawBuffer and DecodeVeloRawBuffer to skeletons, - meaningful new implementation coming up soon - -!========================= VeloDAQ v2r3p2 2005-07-08 ===================== -! 2005-07-08 - Tomasz Szumlak - - Fix problem of missing last Velo Phi bank in L1Buffer, in cases when this - bank would be empty - -!========================= VeloDAQ v2r3p1 2005-03-07 ===================== -! 2005-03-07 - Marco Cattaneo - - Fix requirements to use DAQEvent v* - -!========================== VeloDAQ v2r3 2005-02-10 ====================== -! 2005-02-10 - David Hutchcroft - - Modified the code to produce banks for all of the sensors. - -!========================== VeloDAQ v2r2 2004-12-06 ====================== -! 2004-12-03 - David Hutchcroft - - Modified PrepareVeloRawBufferFPGA to use new Velo Detector element inteface - -!========================== VeloDAQ v2r1 2004-11-29 ====================== -! 2004-10-26 - David Hutchcroft - - Changed to sort by VeloChannelID not position (CP's modification) - -!========================== VeloDAQ v1r0 2004-03-15 ====================== -! 2004-03-19 - Chris Parkes - - added a high threshold bit for Olivier - -! 2004-03-06 - Chris Parkes - - Initial release. - L1 and HLT Buffers for Velo. - L1 code (Niels Tuning) previously in Trg area - - diff --git a/Velo/VeloDAQ/python/VeloDAQ/DefaultVeloRawBufferDecoders.py b/Velo/VeloDAQ/python/VeloDAQ/DefaultVeloRawBufferDecoders.py deleted file mode 100755 index f707a84288dac533d15bec209c02a6dea79f09fc..0000000000000000000000000000000000000000 --- a/Velo/VeloDAQ/python/VeloDAQ/DefaultVeloRawBufferDecoders.py +++ /dev/null @@ -1,63 +0,0 @@ -""" -############################################################################## -# # -# Velo/VeloDAQ helper module. # -# Contains default configurations of the DecodeVeloRawBuffer algorithm # -# for decoding into VeloLiteClusters or VeloClusters. # -# # -# @package Velo/VeloDAQ # -# @author Eduardo Rodrigues ( e.rodrigues@physics.gla.ac.uk ) # -# @date 06/10/2008 # -# # -# # -############################################################################## -""" - -from Configurables import DecodeVeloRawBuffer - -# ============================================================================= -# Instance of DecodeVeloRawBuffer for decoding into VeloLiteClusters -# ============================================================================= -def DefaultDecoderToVeloLiteClusters( - Name = 'DecodeVeloRawBufferToVeloLiteClusters', - RawEventLocations = ['Velo/RawEvent', - 'Other/RawEvent', - 'DAQ/RawEvent'], - VeloClusterLocation ='Raw/Velo/Clusters', - DecodeToVeloClusters = False, - DecodeToVeloLiteClusters = True - ): - - decoder = DecodeVeloRawBuffer( Name ) - - decoder.RawEventLocations = RawEventLocations - decoder.VeloClusterLocation = VeloClusterLocation - decoder.DecodeToVeloClusters = DecodeToVeloClusters - decoder.DecodeToVeloLiteClusters = DecodeToVeloLiteClusters - - return decoder - - -# ============================================================================= -# Instance of DecodeVeloRawBuffer for decoding into VeloClusters -# ============================================================================= -def DefaultDecoderToVeloClusters( - Name = 'DecodeVeloRawBufferToVeloClusters', - RawEventLocations = ['Velo/RawEvent', - 'Other/RawEvent', - 'DAQ/RawEvent'], - VeloClusterLocation ='Raw/Velo/Clusters', - DecodeToVeloClusters = True, - DecodeToVeloLiteClusters = False - ): - - decoder = DecodeVeloRawBuffer( Name ) - - decoder.RawEventLocations = RawEventLocations - decoder.VeloClusterLocation = VeloClusterLocation - decoder.DecodeToVeloClusters = DecodeToVeloClusters - decoder.DecodeToVeloLiteClusters = DecodeToVeloLiteClusters - - return decoder - -############################################################################### diff --git a/Velo/VeloDAQ/python/VeloDAQ/__init__.py b/Velo/VeloDAQ/python/VeloDAQ/__init__.py deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/Velo/VeloDAQ/src/DecodePileUpData.cpp b/Velo/VeloDAQ/src/DecodePileUpData.cpp deleted file mode 100644 index 1417782fb9aa7bd4dec5135918b7c1229ea001c6..0000000000000000000000000000000000000000 --- a/Velo/VeloDAQ/src/DecodePileUpData.cpp +++ /dev/null @@ -1,631 +0,0 @@ -// Include files -// data model -#include "Event/RawBank.h" -#include "Event/RawEvent.h" -#include "Event/VeloCluster.h" -#include "Event/VeloLiteCluster.h" -#include "Kernel/VeloChannelID.h" - -// local -#include "DecodePileUpData.h" - -using namespace LHCb; -using namespace VeloTELL1; - -//---------------------------------------------------------------------------------- -// Implementation file for class : DecodePileUpData -// -// 2009-06-19 : Serena Oggero -//---------------------------------------------------------------------------------- - -// Declaration of the Algorithm Factory -DECLARE_ALGORITHM_FACTORY( DecodePileUpData ) - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -DecodePileUpData::DecodePileUpData( const std::string& name, - ISvcLocator* pSvcLocator) -: Decoder::AlgBase ( name , pSvcLocator ), - m_rawEvent(0) -{ - declareProperty("NonZeroSupp", m_isNonZeroSupp=true); - declareProperty("PUClusterLocation", m_PUClusterLocation="Raw/Velo/PUClusters"); - declareProperty("PUClusterNZSLocation", m_PUClusterNZSLocation="Raw/Velo/PUClustersNZS"); - m_rawEventLocations = {LHCb::RawEventLocation::Trigger, LHCb::RawEventLocation::Default}; - initRawEventSearch(); - -} - -//============================================================================= -// Destructor -//============================================================================= -DecodePileUpData::~DecodePileUpData() {} - -//============================================================================= -// Initialization -//============================================================================= -StatusCode DecodePileUpData::initialize() { - - StatusCode sc = Decoder::AlgBase::initialize(); // must be executed first - if ( sc.isFailure() ) return sc; // error printed already by GaudiAlgorithm - if ( msgLevel(MSG::DEBUG) ) debug() << "==> Initialize" << endmsg; - - if (m_rawEventLocations.empty()) - { - return Error("You need to give me a valid list of locaitons to decode!",StatusCode::FAILURE); - - } - - if (m_rawEventLocations[0]!=LHCb::RawEventLocation::Trigger && m_rawEventLocations[0]!=LHCb::RawEventLocation::Default) - { - info() << "Using '" << m_rawEventLocations << "' as search path for the RawEvent object" << endmsg; - } - - inizializePUcontainer( m_PUcontainerBee ) ; - inizializePUcontainer( m_PUcontainerBee_NZS ) ; - - return StatusCode::SUCCESS; -} - -//============================================================================= -// Main execution -//============================================================================= -StatusCode DecodePileUpData::execute() { - - if ( msgLevel(MSG::DEBUG) ) debug() << "==> Execute" << endmsg; - - StatusCode sc = getRawEvent(); - - if ( sc ){ - // get PU banks (NZS and ZS) - // fill in a LUT - decode(); - - LHCb::VeloClusters * clusters = new LHCb::VeloClusters(); - LHCb::VeloClusters * clustersNZS = new LHCb::VeloClusters(); - - // find hits from the LUT and put them in clusters - for ( int sensorIt = 0; sensorIt < PuTell1::NUM_SENSORS; sensorIt++ ){ - for ( int beetleIt = 0; beetleIt < PuTell1::NUM_BEETLES; beetleIt++ ){ - sc = findPileUpHitsBee(m_PUcontainerBee[sensorIt][beetleIt], sensorIt, beetleIt, clusters); - if ( m_isNonZeroSupp ){ - sc = findPileUpHitsBeeNZS(m_PUcontainerBee_NZS[sensorIt][beetleIt], sensorIt, beetleIt, clustersNZS); - } - } - } - - // put the cluster in the TES - writePUBanks( clusters, clustersNZS ); - } - else { return ( StatusCode::SUCCESS ); } - - if ( msgLevel(MSG::DEBUG) ) debug() << "==> DecodePileUp done" << endmsg; - return StatusCode::SUCCESS; -} - -//============================================================================= -StatusCode DecodePileUpData::getRawEvent() { - - if ( msgLevel(MSG::DEBUG) ) debug() << "==> getRawEvent()" << endmsg; - - // Retrieve the RawEvent: - m_rawEvent = findFirstRawEvent(); - - if( m_rawEvent == NULL ) { - error() << "Raw Event not found in " << m_rawEventLocations << endmsg; - VeloClusters* clusters = new LHCb::VeloClusters(); - put(clusters,m_PUClusterLocation); - return ( StatusCode::FAILURE ); - } - - return ( StatusCode::SUCCESS ); -} - -//============================================================================== -StatusCode DecodePileUpData::decode() { - - if ( msgLevel(MSG::DEBUG) ) debug() << "==> getRawBanks()" << endmsg; - - // NZS PU decode - LHCb::RawBank::BankType type = LHCb::RawBank::BankType(PuTell1::LOPU_NZS); - const std::vector<LHCb::RawBank*> banksNZS = m_rawEvent->banks(type); //bank name not defined yet! - - if ( banksNZS.size() != 0 ) - { - StatusCode nzsBinDecoder=decodePileUpBinaryNZS(banksNZS); - nzsBinDecoder.ignore(); - if ( msgLevel(MSG::DEBUG) ) debug() << " decode() : NZS bank decoded " << endmsg; - } - else Info(" NZS bank empty "); - - // ZS PU decode - const std::vector<LHCb::RawBank*> banks = m_rawEvent->banks(LHCb::RawBank::L0PU); - if ( banks.size() != 0 ) - { - StatusCode binDecoder=decodePileUpBinary(banks); - binDecoder.ignore(); - if ( msgLevel(MSG::DEBUG) ) debug() << " decode() : ZS bank decoded " << endmsg; - } - else Info(" ZS bank empty "); - - return ( StatusCode::SUCCESS ); -} - -//============================================================================== -StatusCode DecodePileUpData::decodePileUpBinary( const std::vector<LHCb::RawBank*> & banks ) -{ - // loop on PU banks, should be only 1 - std::vector<LHCb::RawBank*>::const_iterator bi; - int counter = 0; - for ( bi = banks.begin(); bi != banks.end(); bi++) - { - - if ( msgLevel(MSG::DEBUG) ) debug() << "************************ decodePileUpBinary ***********" << counter << "********" << endmsg; - LHCb::RawBank* aBank = *bi; - - // --> protect against corrupted banks - if(LHCb::RawBank::MagicPattern!=aBank->magic()) continue; - - unsigned int* data = aBank->data(); //point at the beginning of data body, header already skipped - unsigned int* dataPtr = data; - - // fill in the data container - unsigned int head = PuTell1::HEADERS_PER_SECTION; // skip the first 2 words (header) of the section - unsigned int wordTot = (aBank->size() / ( 2 * sizeof(unsigned int) )); - if ( msgLevel(MSG::DEBUG) ) debug() << "now some prints...tot numb word is " << wordTot << endmsg; - Fill( head, wordTot, dataPtr, PuTell1::WORDS_PER_SECTION, m_PUcontainerBee ); - counter++; - } // loop on PU banks - - return StatusCode::SUCCESS; -} // end function - -//============================================================================ -StatusCode DecodePileUpData::decodePileUpBinaryNZS( const std::vector<LHCb::RawBank*> & banksNZS ) -{ - // loop on PU non zero-supp banks, there should be only 1 - for (std::vector<LHCb::RawBank*>::const_iterator bnzs = banksNZS.begin(); bnzs!= banksNZS.end(); bnzs++) - { - if ( msgLevel(MSG::DEBUG) ) debug() << "************************ decodePileUpBinaryNZS *********************" << endmsg; - LHCb::RawBank* aBank = *bnzs; - - // --> protect against corrupted banks - if(LHCb::RawBank::MagicPattern!=aBank->magic()) continue; - - unsigned int* data = (aBank->data()); //point at the beginning of data body skipping the header - //loop on PP FPGA's - for ( int PP = 0; PP < PuTell1::NUM_PP ; PP++ ){ - unsigned int* PPbegin = data + PP*(PuTell1::WORDS_PER_PP); // point at the beginning of each PP body; - - // initialize links - bool linkIsGood[PuTell1::NUM_PPLINKS]; - for ( int linkIt = 0; linkIt < PuTell1::NUM_PPLINKS; linkIt++) { - linkIsGood[linkIt] = false; - } - - // loop on data words - for ( int word = 0; word < PuTell1::WORDS_PER_LINK; word++ ) - { - // loop on links; step of 2 to avoid repetitions - for ( int link = 0; link < PuTell1::NUM_PPLINKS; link+=2 ){ - - // get link format - if ( word== PuTell1::WORD_WITH_FORMATINFO ){ - unsigned int* word1Ptr = PPbegin + (PuTell1::NUM_PPLINKS)*word + link; - int format = ( (*word1Ptr) >> PuTell1::FORMAT_BIT); - unsigned int* word1Ptr2 = PPbegin + (PuTell1::NUM_PPLINKS)*word + link+1; - int format2 = ( (*word1Ptr2) >> PuTell1::FORMAT_BIT); - if ( format && format2 ){ - linkIsGood[link] = true; - linkIsGood[link+1] = true; - } - } - // get data but only for *good* links - else if ( (word > PuTell1::BEGIN_OF_DATAWORDS) && (linkIsGood[link]) && (linkIsGood[link+1]) ){ - // use the Fill function avoiding the loop - unsigned int* datawordPtr = PPbegin + (PuTell1::NUM_PPLINKS)*word + link; - - // word can go from 4 to 36, but the Fill function uses a "scheme" with words from 2 to 33 - // moreover it's done to loop automatically on all the words from a ZS bank - // thus I use a step of 1, to enter only once the while-condition, and I give it (word-2) - Fill( word-2, word-1, datawordPtr-word+2, 1, m_PUcontainerBee_NZS ); - } - } // link loop - - } // word loop - } // PPi loop - - } // PU banks loop - return StatusCode::SUCCESS; -} - -//============================================================================ - -void DecodePileUpData::inizializePUcontainer( PuTell1::DataTable PUcontainerBee ) -{ - for (int sens = 0; sens < PuTell1::NUM_SENSORS; sens++ ){ - for ( int bee = 0; bee < PuTell1::NUM_BEETLES; bee++ ){ - unsigned int word = 0; - PUcontainerBee[sens][bee].dataWord = word; - - switch(bee){ - case 3: - case 5: - case 6: - case 7: - case 11: - case 13: - case 14: - case 15: - PUcontainerBee[sens][bee].isOrdered = false; - break; - default: - PUcontainerBee[sens][bee].isOrdered = true; - } - } - } -} - -//========================================================================= -void DecodePileUpData::Fill( unsigned int wordIt, unsigned int word_Tot, - unsigned int* data_Ptr, int step, - PuTell1::DataTable PUcontainerBee ){ - if ( msgLevel(MSG::DEBUG) ) debug() << "******************** Fill() *********************************" << endmsg; - while ( wordIt < word_Tot ) - { - unsigned int* wordPtr = data_Ptr + wordIt; - if ( msgLevel(MSG::DEBUG) ) debug() << "*HARD* DEBUG - FILL : wordPtr " << wordPtr << " " << binary(*wordPtr) << endmsg; - - //to take words from the 2nd section - // step is 34 for the 0 supp bank, 35 for the non-0 supp - unsigned int* wordPtr2 = wordPtr + step; - if ( msgLevel(MSG::DEBUG) ) debug() << "*HARD* DEBUG - FILL : wordPtr2 " << wordPtr2 << " " << binary(*wordPtr2) << endmsg; - switch(wordIt){ - case 2: - (PUcontainerBee[0][2]).dataWord = *wordPtr; - (PUcontainerBee[0][1]).dataWord = *wordPtr2; - wordIt++; - break; - case 3: - (PUcontainerBee[0][0]).dataWord = *wordPtr; - (PUcontainerBee[0][3]).dataWord = *wordPtr2; - wordIt++; - break; - case 4: - (PUcontainerBee[1][13]).dataWord = *wordPtr; - (PUcontainerBee[1][14]).dataWord = *wordPtr2; - wordIt++; - break; - case 5: - (PUcontainerBee[1][15]).dataWord = *wordPtr; - (PUcontainerBee[1][12]).dataWord = *wordPtr2; - wordIt++; - break; - case 6: - (PUcontainerBee[2][13]).dataWord = *wordPtr; - (PUcontainerBee[2][14]).dataWord = *wordPtr2; - wordIt++; - break; - case 7: - (PUcontainerBee[2][15]).dataWord = *wordPtr; - (PUcontainerBee[2][12]).dataWord = *wordPtr2; - wordIt++; - break; - case 8: - (PUcontainerBee[3][2]).dataWord = *wordPtr; - (PUcontainerBee[3][1]).dataWord = *wordPtr2; - wordIt++; - break; - case 9: - (PUcontainerBee[3][0]).dataWord = *wordPtr; - (PUcontainerBee[3][3]).dataWord = *wordPtr2; - wordIt++; - break; - case 10: - (PUcontainerBee[0][5]).dataWord = *wordPtr; - (PUcontainerBee[0][6]).dataWord = *wordPtr2; - wordIt++; - break; - case 11: - (PUcontainerBee[0][7]).dataWord = *wordPtr; - (PUcontainerBee[0][4]).dataWord = *wordPtr2; - wordIt++; - break; - case 12: - (PUcontainerBee[1][10]).dataWord = *wordPtr; - (PUcontainerBee[1][9]).dataWord = *wordPtr2; - wordIt++; - break; - case 13: - (PUcontainerBee[1][8]).dataWord = *wordPtr; - (PUcontainerBee[1][11]).dataWord = *wordPtr2; - wordIt++; - break; - case 14: - (PUcontainerBee[2][10]).dataWord = *wordPtr; - (PUcontainerBee[2][9]).dataWord = *wordPtr2; - wordIt++; - break; - case 15: - (PUcontainerBee[2][8]).dataWord = *wordPtr; - (PUcontainerBee[2][11]).dataWord = *wordPtr2; - wordIt++; - break; - case 16: - (PUcontainerBee[3][5]).dataWord = *wordPtr; - (PUcontainerBee[3][6]).dataWord = *wordPtr2; - wordIt++; - break; - case 17: - (PUcontainerBee[3][7]).dataWord = *wordPtr; - (PUcontainerBee[3][4]).dataWord = *wordPtr2; - wordIt++; - break; - case 18: - (PUcontainerBee[0][10]).dataWord = *wordPtr ; - (PUcontainerBee[0][9]).dataWord = *wordPtr2; - wordIt++; - break; - case 19: - (PUcontainerBee[0][8]).dataWord = *wordPtr; - (PUcontainerBee[0][11]).dataWord = *wordPtr2; - wordIt++; - break; - case 20: - (PUcontainerBee[1][5]).dataWord = *wordPtr; - (PUcontainerBee[1][6]).dataWord = *wordPtr2; - wordIt++; - break; - case 21: - (PUcontainerBee[1][7]).dataWord = *wordPtr; - (PUcontainerBee[1][4]).dataWord = *wordPtr2; - wordIt++; - break; - case 22: - (PUcontainerBee[2][5]).dataWord = *wordPtr; - (PUcontainerBee[2][6]).dataWord = *wordPtr2; - wordIt++; - break; - case 23: - (PUcontainerBee[2][7]).dataWord = *wordPtr; - (PUcontainerBee[2][4]).dataWord = *wordPtr2; - wordIt++; - break; - case 24: - (PUcontainerBee[3][10]).dataWord = *wordPtr; - (PUcontainerBee[3][9]).dataWord = *wordPtr2; - wordIt++; - break; - case 25: - (PUcontainerBee[3][8]).dataWord = *wordPtr; - (PUcontainerBee[3][11]).dataWord = *wordPtr2; - wordIt++; - break; - case 26: - (PUcontainerBee[0][13]).dataWord = *wordPtr; - (PUcontainerBee[0][14]).dataWord = *wordPtr2; - wordIt++; - break; - case 27: - (PUcontainerBee[0][15]).dataWord = *wordPtr; - (PUcontainerBee[0][12]).dataWord = *wordPtr2; - wordIt++; - break; - case 28: - (PUcontainerBee[1][2]).dataWord = *wordPtr; - (PUcontainerBee[1][1]).dataWord = *wordPtr2; - wordIt++; - break; - case 29: - (PUcontainerBee[1][0]).dataWord = *wordPtr; - (PUcontainerBee[1][3]).dataWord = *wordPtr2; - wordIt++; - break; - case 30: - (PUcontainerBee[2][2]).dataWord = *wordPtr; - (PUcontainerBee[2][1]).dataWord = *wordPtr2; - wordIt++; - break; - case 31: - (PUcontainerBee[2][0]).dataWord = *wordPtr; - (PUcontainerBee[2][3]).dataWord = *wordPtr2; - wordIt++; - break; - case 32: - (PUcontainerBee[3][13]).dataWord = *wordPtr; - (PUcontainerBee[3][14]).dataWord = *wordPtr2; - wordIt++; - break; - case 33: - (PUcontainerBee[3][15]).dataWord = *wordPtr; - (PUcontainerBee[3][12]).dataWord = *wordPtr2; - wordIt++; - break; - - } // switch case - } // while "beetle map" -} - -//============================================================================ - -StatusCode DecodePileUpData::findPileUpHitsBee( PuTell1::dataObject OneBeetleData, int sens, int bee, VeloClusters * clusters ) -{ - unsigned int maskBee = 1; - unsigned int inBee = OneBeetleData.dataWord; - - // VeloChannelID parameters - unsigned int sensorNum; - unsigned int stripNum; - unsigned int fracStrip = 0; - unsigned int pseudoSize = 0; - bool hasHighThre = 1; - - for(int i=0; i < PuTell1::NUMBITS; i++) - { - unsigned int checkBee = maskBee & inBee; - - if ( checkBee ){ - sensorNum = SensorId(sens); - - if ( OneBeetleData.isOrdered ){ - //not flipped word - stripNum = ( PuTell1::STRIPS_PER_CHANNEL )*i + bee* ( PuTell1::STRIPS_PER_BEETLE ); // channel numbering starts from 0 - } - else{ - //flipped - stripNum = ( PuTell1::STRIPS_PER_CHANNEL )*( PuTell1::NUMBITS-1-i ) + bee*( PuTell1::STRIPS_PER_BEETLE ); - } - VeloChannelID vcid( sensorNum, stripNum ); - VeloLiteCluster lc( fracStrip, pseudoSize, hasHighThre, vcid ); - VeloCluster::ADCVector adcs; - adcs.reserve(1); - adcs.push_back( std::pair<int,unsigned int> (static_cast<int>( stripNum ), static_cast<unsigned int>( 1.)) ); - // now append new cluster - clusters->insert( new LHCb::VeloCluster(lc,adcs), vcid ); - - if ( msgLevel(MSG::DEBUG) ) - { - debug() << "findPileUpHitsBee : VeloLiteCluster lc(" - << fracStrip << ", " - << pseudoSize << ", " - << hasHighThre << ", with channelId strip " - << (lc.channelID()).strip() << endmsg; - debug() << "******************** clusters size is " - << clusters->size() << ")*********************************" - << endmsg; - } - - } // if checkBee - else if ( msgLevel(MSG::DEBUG) ) - { - if ( OneBeetleData.isOrdered ){ - //not flipped word - debug() << "No hits found in PU strip i= " << i << endmsg; - } - else{ - //flipped - debug() << "No hits found in PU strip i= " << 32 - i << endmsg; - } - } - maskBee = maskBee << 1; - } // for loop on word - - return StatusCode::SUCCESS; -} - -//============================================================================== - -StatusCode DecodePileUpData::findPileUpHitsBeeNZS( PuTell1::dataObject OneBeetleData, int sens, - int bee, VeloClusters * clustersNZS ) -{ - unsigned int maskBee = 1; - unsigned int inBee = OneBeetleData.dataWord; - - // VeloChannelID parameters - unsigned int sensorNum; - unsigned int stripNum; - unsigned int fracStrip = 0; - unsigned int pseudoSize = 0; - bool hasHighThre = 1; - - for(int i=0; i < PuTell1::NUMBITS; i++) - { - unsigned int checkBee = maskBee & inBee; - if ( checkBee ){ - sensorNum = SensorId(sens); - - if ( OneBeetleData.isOrdered ){ - //not flipped word - stripNum = ( PuTell1::STRIPS_PER_CHANNEL )*i + bee*( PuTell1::STRIPS_PER_BEETLE ); - } - else{ - //flipped - stripNum = ( PuTell1::STRIPS_PER_CHANNEL )*( PuTell1::NUMBITS-1-i) + bee*( PuTell1::STRIPS_PER_BEETLE ); - } - - VeloChannelID vcid( sensorNum, stripNum ); - VeloLiteCluster lc( fracStrip, pseudoSize, hasHighThre, - VeloChannelID(sensorNum, stripNum) ); - VeloCluster::ADCVector adcs; - adcs.reserve(1); - adcs.push_back( std::pair<int,unsigned int> (static_cast<int>( stripNum ), static_cast<unsigned int>( 1.)) ); - // got all we need, now append new cluster - clustersNZS->insert( new LHCb::VeloCluster(lc,adcs), vcid ); - - if ( msgLevel(MSG::DEBUG) ) - { - debug() << "findPileUpHitsBeeNZS : VeloLiteCluster lc(" - << fracStrip << ", " - << pseudoSize << ", " - << hasHighThre << ", with channelId strip " - << (lc.channelID()).strip() << endmsg; - debug() << "******************** clustersNZS size is " - << clustersNZS->size() - << ")*********************************" << endmsg; - } - - } // if checkBee - else if ( msgLevel(MSG::DEBUG) ) - { - if ( OneBeetleData.isOrdered ){ - //not flipped word - debug() << "No hits found in PU strip i= " << i << endmsg; - } - else{ - //flipped - debug() << "No hits found in PU strip i= " << 32 - i << endmsg; - } - } - maskBee = maskBee << 1; - } - return StatusCode::SUCCESS; -} - -//============================================================================== - -// binary function with strings -std::string DecodePileUpData::binary( unsigned int number ) -{ - std::string result; - while(number) - { - result.insert(result.begin(), number % 2 + '0'); - number /= 2; - } - return result; -} - -//============================================================================ - -// function to convert sensor numbering (0,1,2,3) to "official" PU sensor Id -int DecodePileUpData::SensorId (int s){ - switch(s){ - case (PuTell1::A1): - return 128; - case (PuTell1::C1): - return 129; - case (PuTell1::A2): - return 130; - case (PuTell1::C2): - return 131; - default: - return -1; - } -} - -//============================================================================ - -StatusCode DecodePileUpData::writePUBanks( LHCb::VeloClusters * clusters, LHCb::VeloClusters * clustersNZS ) { - - if ( msgLevel(MSG::DEBUG) ) debug() << "==> writePUBanks()" << endmsg; - - put(clusters, m_PUClusterLocation); - //info() << "put clusters in " << m_PUClusterLocation << endmsg(); - if ( m_isNonZeroSupp ){ - put(clustersNZS, m_PUClusterNZSLocation); - } - return ( StatusCode::SUCCESS ); -} - -//============================================================================== diff --git a/Velo/VeloDAQ/src/DecodePileUpData.h b/Velo/VeloDAQ/src/DecodePileUpData.h deleted file mode 100644 index a0ffe123af4a6dc51985c4b3bb58970f50647a38..0000000000000000000000000000000000000000 --- a/Velo/VeloDAQ/src/DecodePileUpData.h +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef DECODEPILEUPDATA_H -#define DECODEPILEUPDATA_H 1 - -// Include files -// from Gaudi -#include "GaudiAlg/GaudiAlgorithm.h" -#include "DAQKernel/DecoderAlgBase.h" - -// from TELL1 Kernel: -#include "Tell1Kernel/VeloDecodeConf.h" -#include "Tell1Kernel/PUTell1Core.h" - -/** @class DecodePileUpData DecodePileUpData.h - * - * - * @author Serena Oggero - * @date 2009-06-19 - */ - -// ----------------------------------- -namespace LHCb -{ - class RawEvent; - class RawBank; -} -using namespace LHCb; -// ----------------------------------- - -namespace PuTell1 -{ - enum BankTypes{ - LOPU_NZS = 57 - }; -} - -class DecodePileUpData : public Decoder::AlgBase { -public: - - DecodePileUpData( const std::string& name, ISvcLocator* pSvcLocator ); /// Standard constructor - virtual ~DecodePileUpData(); /// Destructor - StatusCode initialize() override; ///< Algorithm initialization - StatusCode execute () override; ///< Algorithm execution - - StatusCode getRawEvent(); - StatusCode decode(); - StatusCode getPileUpBank(); - StatusCode writePUBanks(LHCb::VeloClusters *, LHCb::VeloClusters *); - StatusCode decodePileUpBinary( const std::vector<LHCb::RawBank*> & banks ); - StatusCode decodePileUpBinaryNZS( const std::vector<LHCb::RawBank*> & banks ); - StatusCode findPileUpHitsBee( PuTell1::dataObject, int, int, LHCb::VeloClusters * ); - StatusCode findPileUpHitsBeeNZS( PuTell1::dataObject, int, int, LHCb::VeloClusters * ); - - int SensorId( int ); - std::string binary ( unsigned int ); - void inizializePUcontainer( PuTell1::DataTable PUcontainerBee ); - void Fill( unsigned int wordIt, unsigned int word_Tot, unsigned int* data_Ptr, int step, PuTell1::DataTable PUcontainerBee ); - -protected: - -private: - - LHCb::RawEvent* m_rawEvent; - - std::string m_PUClusterLocation; - std::string m_PUClusterNZSLocation; - bool m_isNonZeroSupp; - PuTell1::DataTable m_PUcontainerBee_NZS; - PuTell1::DataTable m_PUcontainerBee; -}; -#endif // DecodePileUpData_H diff --git a/Velo/VeloDAQ/src/DecodeRawBankToClusters.cpp b/Velo/VeloDAQ/src/DecodeRawBankToClusters.cpp deleted file mode 100644 index 56fc1e283b142d47ac3875097bd6260e3b6cd353..0000000000000000000000000000000000000000 --- a/Velo/VeloDAQ/src/DecodeRawBankToClusters.cpp +++ /dev/null @@ -1,171 +0,0 @@ -// $Id: DecodeRawBankToClusters.cpp,v 1.17 2010-03-17 18:33:19 krinnert Exp $ - -#include <vector> -#include <algorithm> -#include <sstream> - -#include "VeloDet/DeVeloSensor.h" - -#include "VeloRawBankDecoder.h" -#include "DecodeRawBankToClusters.h" - -int VeloDAQ::decodeRawBankToClustersV2( - const SiDAQ::buffer_word* bank, - const DeVeloSensor* sensor, - const bool assumeChipChannels, - LHCb::VeloClusters& clusters, - int& byteCount, - bool ignoreErrors) -{ - // construct new raw decoder, implicitely decodes header - VeloRawBankDecoder decoder(bank); - - // only decode banks without errors - if ( decoder.hasError() && !ignoreErrors ) { return -1; } - - // make sure we have enough capacity in the container - // to avoid unnecessary relocations - clusters.reserve(clusters.size()+decoder.nClusters()); - - // decode the clusterpositions, create clusters and - // append them to the container - unsigned int sensorNumber = sensor->sensorNumber(); - unsigned int stripNumber; - VeloRawBankDecoder::posadc_iterator padci = decoder.posAdcBegin(); - for ( ; padci != decoder.posAdcEnd(); ++padci) { - - stripNumber = padci->first.channelID(); - if (assumeChipChannels) stripNumber = sensor->ChipChannelToStrip(stripNumber); - LHCb::VeloChannelID vcid(sensorNumber,stripNumber); - LHCb::VeloLiteCluster lc( - padci->first.fracStripBits(), - padci->first.pseudoSizeBits(), - padci->first.hasHighThreshold(), - vcid); - - - const std::vector<SiADCWord>& adcWords = padci->second; - - int firstStrip = static_cast<int>(stripNumber); - - // if we have more than two strips on the cluster we have to - // find the offset of the cluster centre by computing - // the weighted mean - if (adcWords.size() > 2) { - double adcValue; - double sumADC = 0.0; - double sumWeightedPos = 0.0; - for (unsigned int adci = 0; adci < adcWords.size(); ++adci) { - adcValue = adcWords[adci].adc(); - sumWeightedPos += adci*adcValue; - sumADC += adcValue; - } - firstStrip -= static_cast<unsigned int>(sumWeightedPos/sumADC); - } - - LHCb::VeloCluster::ADCVector adcs; - adcs.reserve(adcWords.size()); - for (unsigned int i = 0; i<adcWords.size(); ++i) { - adcs.push_back( std::pair<int,unsigned int> - (static_cast<int>(firstStrip+i), - static_cast<unsigned int>(adcWords[i].adc())) ); - } - - // got all we need, now append new cluster - clusters.insert(new LHCb::VeloCluster(lc,adcs),vcid); - } - - // fetch number of decoded bytes, including 4 byte header, without - // the padding bytes at the end. - byteCount = padci.bytesRead(); - - return decoder.nClusters(); -} - -// decoding of bank version 3, treating isp rounding like the TELL1 -int VeloDAQ::decodeRawBankToClustersV3( - const SiDAQ::buffer_word* bank, - const DeVeloSensor* sensor, - const bool assumeChipChannels, - LHCb::VeloClusters& clusters, - int& byteCount, - std::string& errorMsg, - bool ignoreErrors ) -{ - // construct new raw decoder, implicitely decodes header - VeloRawBankDecoder decoder(bank); - - // only decode banks without errors - if ( decoder.hasError() && !ignoreErrors ) { return -1; } - - // make sure we have enough capacity in the container - // to avoid unnecessary relocations - clusters.reserve(clusters.size()+decoder.nClusters()); - - // decode the clusterpositions, create clusters and - // append them to the container - unsigned int sensorNumber = sensor->sensorNumber(); - unsigned int stripNumber; - VeloRawBankDecoder::posadc_iterator padci = decoder.posAdcBegin(); - for ( ; padci != decoder.posAdcEnd(); ++padci) { - - stripNumber = padci->first.channelID(); - if (assumeChipChannels) stripNumber = sensor->ChipChannelToStrip(stripNumber); - LHCb::VeloChannelID vcid(sensorNumber,stripNumber); - LHCb::VeloLiteCluster lc( - padci->first.fracStripBits(), - padci->first.pseudoSizeBits(), - padci->first.hasHighThreshold(), - vcid); - - - const std::vector<SiADCWord>& adcWords = padci->second; - - int firstStrip = static_cast<int>(stripNumber); - - // if we have more than two strips on the cluster we have to - // find the offset of the cluster centre by computing - // the weighted mean - if (adcWords.size() > 1) { - double adcValue; - double sumADC = 0.0; - double sumWeightedPos = 0.0; - for (unsigned int adci = 0; adci < adcWords.size(); ++adci) { - adcValue = adcWords[adci].adc(); - sumWeightedPos += adci*adcValue; - sumADC += adcValue; - } - firstStrip -= static_cast<int>(sumWeightedPos*static_cast<int>(65536./sumADC+0.5)/65536.+1/16.); - } - - LHCb::VeloCluster::ADCVector adcs; - adcs.reserve(adcWords.size()); - for (unsigned int i = 0; i<adcWords.size(); ++i) { - adcs.push_back( std::pair<int,unsigned int> - (static_cast<int>(firstStrip+i), - static_cast<unsigned int>(adcWords[i].adc())) ); - } - - - // DEBUG: check for "this should never happen" - LHCb::VeloCluster* clu = clusters.object(vcid); - if ( clu ) { - std::ostringstream errmsg; - errmsg << "Cluster of size " << clu->size() << " already in container. " - << "Strip = " << vcid.strip() << ", sensor = " << vcid.sensor() - << ". This inidicates a TELL1 problem." << std::endl; - errorMsg = errmsg.str(); - continue; - } - - // got all we need, now append new cluster - clusters.insert(new LHCb::VeloCluster(lc,adcs),vcid); - - } - - // fetch number of decoded bytes, including 4 byte header, without - // the padding bytes at the end. - byteCount = padci.bytesRead(); - - return decoder.nClusters(); -} diff --git a/Velo/VeloDAQ/src/DecodeRawBankToClusters.h b/Velo/VeloDAQ/src/DecodeRawBankToClusters.h deleted file mode 100644 index 0bdd9eb700b14f76399c7a824cea00e46bb7ca0e..0000000000000000000000000000000000000000 --- a/Velo/VeloDAQ/src/DecodeRawBankToClusters.h +++ /dev/null @@ -1,62 +0,0 @@ -// $Id: DecodeRawBankToClusters.h,v 1.5 2008-10-16 15:31:30 krinnert Exp $ -#ifndef VELODAQ_DECODERAWBANKTOCLUSTERS_H -#define VELODAQ_DECODERAWBANKTOCLUSTERS_H 1 - -#include <string> - -#include "Event/VeloCluster.h" -#include "SiDAQ/SiRawBufferWord.h" - -class DeVeloSensor; - -namespace VeloDAQ { - /** Append clusters to keyed container, bank version 2 - * This function decodes the cluster position and adc counts - * from the raw bank and appends the resulting VeloClusters to - * to the keyed container provided by the client. - * - * @arg bank pointer to raw bank - * @arg sensor sensor corresponding to bank, needed to create channel id and for channel to strip mapping - * @arg assumeChipChannels if true, assume chip channels instead of strip numbers in raw bank - * @arg clusters keyed container to which decoded clusters will be appended - * @arg number of bytes in the bank, including 4 byte header, without padding bytes at the end. Is set by this function. - * @return number of decoded clusters appended (-1 = header error) - * @see VeloCluster - * @author Kurt Rinnert - * @date 2006-02-17 - */ - int decodeRawBankToClustersV2( - const SiDAQ::buffer_word* bank, - const DeVeloSensor* sensor, - const bool assumeChipChannels, - LHCb::VeloClusters& clusters, - int& byteCount, - bool ignoreErrors=false); - - /** Append clusters to keyed container, bank version 3 - * This function decodes the cluster position and adc counts - * from the raw bank and appends the resulting VeloClusters to - * to the keyed container provided by the client. It is very similar to - * the version 2 decoder. However it treats the inter strip position - * computation and rounding axactly like the TELL1. - * - * @arg bank pointer to raw bank - * @arg sensor sensor corresponding to bank, needed to create channel id and for channel to strip mapping - * @arg assumeChipChannels if true, assume chip channels instead of strip numbers in raw bank - * @arg clusters keyed container to which decoded clusters will be appended - * @arg number of bytes in the bank, including 4 byte header, without padding bytes at the end. Is set by this function. - * @return number of decoded clusters appended (-1 = header error) - * @see VeloCluster - * @author Kurt Rinnert - * @date 2006-02-17 - */ - int decodeRawBankToClustersV3( - const SiDAQ::buffer_word* bank, - const DeVeloSensor* sensor, - const bool assumeChipChannels, - LHCb::VeloClusters& clusters, - int& byteCount, - std::string& errorMsg, - bool ignoreErrors=false); -} -#endif // VELODAQ_DECODERAWBANKTOCLUSTERS_H diff --git a/Velo/VeloDAQ/src/DecodeRawBankToLiteClusters.cpp b/Velo/VeloDAQ/src/DecodeRawBankToLiteClusters.cpp deleted file mode 100644 index a522bcbd38988609df0875a12d3bb0b012d669ce..0000000000000000000000000000000000000000 --- a/Velo/VeloDAQ/src/DecodeRawBankToLiteClusters.cpp +++ /dev/null @@ -1,64 +0,0 @@ -#include "VeloDet/DeVeloSensor.h" - -#include "VeloRawBankDecoder.h" -#include "DecodeRawBankToLiteClusters.h" - -int VeloDAQ::decodeRawBankToLiteClusters ( - const SiDAQ::buffer_word* bank, - const DeVeloSensor& sensor, - const bool assumeChipChannels, - LHCb::VeloLiteCluster::FastContainer& clusters, - int& byteCount, - bool ignoreErrors ) -{ - // construct new raw decoder, implicitely decodes header - VeloRawBankDecoder decoder(bank); - - // only decode banks without errors - if ( decoder.hasError() && !ignoreErrors ) { return -1; } - - // decode the clusterpositions, create lite clusters and - // append them to the container - unsigned int sensorNumber = sensor.sensorNumber(); - // only need to read ADCs to check for wrong bank length - auto cpi = decoder.posAdcBegin(); - for (;cpi != decoder.posAdcEnd(); ++cpi) { - auto stripNumber = cpi->first.channelID(); - if (assumeChipChannels) stripNumber = sensor.ChipChannelToStrip(stripNumber); - clusters.emplace_back( cpi->first.fracStripBits(), - cpi->first.pseudoSizeBits(), - cpi->first.hasHighThreshold(), - LHCb::VeloChannelID(sensorNumber,stripNumber) ); - } - - // fetch number of decoded bytes, including 4 byte header, without - // the padding bytes at the end. - byteCount = cpi.bytesRead(); - return decoder.nClusters(); -} - -int VeloDAQ::decodeRawBankToLiteClusters ( - const SiDAQ::buffer_word* bank, - const DeVeloSensor& sensor, - LHCb::VeloLiteCluster::FastContainer& clusters, - bool ignoreErrors ) -{ - // construct new raw decoder, implicitely decodes header - VeloRawBankDecoder decoder(bank); - - // only decode banks without errors - if ( decoder.hasError() && !ignoreErrors ) { return -1; } - - // decode the clusterpositions, create lite clusters and - // append them to the container - unsigned int sensorNumber = sensor.sensorNumber(); - // decode the clusterpositions, create lite clusters and - // append them to the container - for (auto cpi = decoder.posBegin(); cpi != decoder.posEnd(); ++cpi) { - clusters.emplace_back(cpi->fracStripBits(), - cpi->pseudoSizeBits(), - cpi->hasHighThreshold(), - LHCb::VeloChannelID(sensorNumber, cpi->channelID())); - } - return decoder.nClusters(); -} diff --git a/Velo/VeloDAQ/src/DecodeRawBankToLiteClusters.h b/Velo/VeloDAQ/src/DecodeRawBankToLiteClusters.h deleted file mode 100644 index 2a1dd95462b53ec972c5c045d893efd8a199068f..0000000000000000000000000000000000000000 --- a/Velo/VeloDAQ/src/DecodeRawBankToLiteClusters.h +++ /dev/null @@ -1,53 +0,0 @@ -// $Id: DecodeRawBankToLiteClusters.h,v 1.3 2010-05-13 17:20:20 dhcroft Exp $ -#ifndef VELODAQ_DECODERAWBANKTOLITECLUSTERS_H -#define VELODAQ_DECODERAWBANKTOLITECLUSTERS_H 1 - -#include "Event/VeloLiteCluster.h" -#include "SiDAQ/SiRawBufferWord.h" - -class DeVeloSensor; - -namespace VeloDAQ { - /** Append lite clusters to fast container - * This function decodes the cluster position part of the - * raw bank and appends the resulting VeloLiteClusters to - * to the fast container provided by the client. - * - * @arg bank pointer to raw bank - * @arg sensor sensor corresponding to bank, needed to create channel id and for channel to strip mapping - * @arg assumeChipChannels if true, assume chip channels instead of strip numbers in raw bank - * @arg clusters fast container to which decoded clusters will be appended - * @return number of decoded clusters appended (-1 = Header error) - * @see VeloLiteCluster - * @author Kurt Rinnert - * @date 2006-02-17 - */ - int decodeRawBankToLiteClusters( - const SiDAQ::buffer_word* bank, - const DeVeloSensor& sensor, - const bool assumeChipChannels, - LHCb::VeloLiteCluster::FastContainer& clusters, - int & bytesCount, - bool ignoreErrors); - - /** Append lite clusters to fast container - * This function decodes the cluster position part of the - * raw bank and appends the resulting VeloLiteClusters to - * to the fast container provided by the client. Fast version - * that skips all test on ADC part of bank to check length is correct. - * - * @arg bank pointer to raw bank - * @arg sensor sensor corresponding to bank, needed to create channel id and for channel to strip mapping - * @arg clusters fast container to which decoded clusters will be appended - * @return number of decoded clusters appended (-1 = Header error) - * @see VeloLiteCluster - * @author Kurt Rinnert - * @date 2006-02-17 - */ - int decodeRawBankToLiteClusters( - const SiDAQ::buffer_word* bank, - const DeVeloSensor& sensor, - LHCb::VeloLiteCluster::FastContainer& clusters, - bool ignoreErrors); -} -#endif // VELODAQ_DECODERAWBANKTOLITECLUSTERS_H diff --git a/Velo/VeloDAQ/src/DecodeVeloFullRawBuffer.cpp b/Velo/VeloDAQ/src/DecodeVeloFullRawBuffer.cpp deleted file mode 100644 index 99a461732d02ec3a32a3ed0ab86b79ac7ba2a558..0000000000000000000000000000000000000000 --- a/Velo/VeloDAQ/src/DecodeVeloFullRawBuffer.cpp +++ /dev/null @@ -1,429 +0,0 @@ -// Include files -// local -#include "DecodeVeloFullRawBuffer.h" - -// Kernel -#include "Kernel/VeloEventFunctor.h" - -// STL -#include <vector> - -//----------------------------------------------------------------------------- -// Implementation file for class : DecodeVeloFullRawBuffer -// -// 2006-04-21 : Tomasz Szumlak -//----------------------------------------------------------------------------- - -// Declaration of the Algorithm Factory -DECLARE_ALGORITHM_FACTORY( DecodeVeloFullRawBuffer ) - - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -DecodeVeloFullRawBuffer::DecodeVeloFullRawBuffer( const std::string& name, - ISvcLocator* pSvcLocator) -: GaudiAlgorithm ( name , pSvcLocator ), - m_veloADCLocation ( VeloFullBankLocation::Default ), - m_veloPartialADCLocation ( "Raw/Velo/PreparedPartialADC" ), - m_veloPedLocation ( VeloFullBankLocation::Pedestals ), - m_decodedADCLocation ( LHCb::VeloTELL1DataLocation::ADCs ), - m_decodedPartialADCLocation ( "Raw/Velo/PartialADCs" ), - m_decodedPedLocation ( LHCb::VeloTELL1DataLocation::Pedestals ), - m_decodedHeaderLocation ( LHCb::VeloTELL1DataLocation::Headers ), - m_evtInfoLocation ( EvtInfoLocation::Default ), - m_veloADCs ( 0 ), - m_veloPartialADCs ( 0 ), - m_veloPeds ( 0 ), - m_decodedADC ( 0 ), - m_decodedPartialADC ( 0 ), - m_decodedPed ( 0 ), - m_decodedHeader ( 0 ), - m_evtInfo ( 0 ), - m_adcDataPresent ( false ), - m_pedDataPresent ( false ), - m_isDebug ( false ), - m_signADC ( VeloTELL1::SENSOR_CHANNELS ), - m_signPartialADC ( VeloTELL1::SENSOR_CHANNELS ), - m_signADCReordered ( VeloTELL1::SENSOR_CHANNELS ), - m_signPartialADCReordered ( VeloTELL1::SENSOR_CHANNELS ), - m_signHeader ( 256 ), - m_signHeaderReordered ( 256 ), - m_signPed ( VeloTELL1::SENSOR_CHANNELS ), - m_signPedReordered ( VeloTELL1::SENSOR_CHANNELS ), - m_ADCDecoder ( VeloFull ), - m_ADCPartialDecoder ( VeloFull ), - m_HeaderDecoder ( VeloHeader ), - m_PedDecoder ( VeloPedestal ) -{ - declareProperty("ADCLocation", - m_veloADCLocation=VeloFullBankLocation::Default ); - declareProperty("PedestalLocation", - m_veloPedLocation=VeloFullBankLocation::Pedestals ); - declareProperty("DecodedADCLocation", - m_decodedADCLocation=LHCb::VeloTELL1DataLocation::ADCs ); - declareProperty("DecodedPartialADCLocation", - m_decodedPartialADCLocation="Raw/Velo/PartialADCs" ); - declareProperty("DecodedPedestalLocation", - m_decodedPedLocation=LHCb::VeloTELL1DataLocation::Pedestals ); - declareProperty("DecodedHeaderLocation", - m_decodedHeaderLocation=LHCb::VeloTELL1DataLocation::Headers ); - declareProperty("EventInfoLocation", - m_evtInfoLocation=EvtInfoLocation::Default ); - declareProperty("SectorCorrection", m_sectorCorrection=true); - declareProperty("CableOrder", m_cableOrder); -} -//============================================================================= -// Destructor -//============================================================================= -DecodeVeloFullRawBuffer::~DecodeVeloFullRawBuffer() {} - -//============================================================================= -// Initialization -//============================================================================= -StatusCode DecodeVeloFullRawBuffer::initialize() { - StatusCode sc = GaudiAlgorithm::initialize(); // must be executed first - if ( sc.isFailure() ) return sc; // error printed already by GaudiAlgorithm - - debug() << "==> Initialize" << endmsg; - - // Check cable order configuration. If the configuration is empty, - // create a configuration with default order. Otherwise perform - // sanity checks and bail out when encountering nonsense. - if (m_cableOrder.empty()) { - for (unsigned int i=0; i<4; ++i) { - m_cableOrder.push_back(i); - } - std::reverse(m_cableOrder.begin(), m_cableOrder.end()); - } else if (4 != m_cableOrder.size()) { - error() << "The cable order configuration must have exactly 4 entries." << endmsg; - return StatusCode::FAILURE; - } else { - std::vector<unsigned int> used; - for (unsigned int i=0; i<4; ++i) { - if (m_cableOrder[i] > 3) { - error() << "Only cable positions 0-3 are allowed." << endmsg; - return StatusCode::FAILURE; - } else if (used.end() != std::find(used.begin(),used.end(),m_cableOrder[i])) { - error() << "Each cable position must appear exactly once." << endmsg; - return StatusCode::FAILURE; - } - used.push_back(m_cableOrder[i]); - } - } - return StatusCode::SUCCESS; -} -//============================================================================= -// Main execution -//============================================================================= -StatusCode DecodeVeloFullRawBuffer::execute() { - - m_isDebug = msgLevel( MSG::DEBUG ); - - if (m_isDebug) debug() << "==> Execute" << endmsg; - // - getData(); - // decode ADC, Pedestals and EvtInfos data - decodeData(); - sortAndWriteDecodedData(); - resetMemory(); - // - return StatusCode::SUCCESS; -} - -//============================================================================= -StatusCode DecodeVeloFullRawBuffer::getData() -{ - if (m_isDebug) debug()<< " ==> getData() " <<endmsg; - // - m_veloADCs = getIfExists<VeloFullBanks>(adcContName()); - if( NULL == m_veloADCs ){ - if (m_isDebug) debug() << " ==> There is no data banks at: " - << adcContName() <<endmsg; - }else{ - // get the data banks from default TES location - if (m_isDebug) debug() << " ==> The data banks have been read-in from location: " - << adcContName() - << ", size of data container (number of read-out TELL1s): " - << m_veloADCs->size() <<endmsg; - // create container for decoded data - m_decodedADC=new LHCb::VeloTELL1Datas(); - m_decodedHeader=new LHCb::VeloTELL1Datas(); - m_evtInfo=new EvtInfos(); - // - setADCDataFlag(); - } - - m_veloPartialADCs = getIfExists<VeloFullBanks>(m_veloPartialADCLocation); - if( NULL == m_veloPartialADCs ){ - - if (m_isDebug) debug() << " ==> There is no data banks at: " - << m_veloPartialADCLocation <<endmsg; - - }else{ - - // get the partial data banks from default TES location - if (m_isDebug) debug() << " ==> The data banks have been read-in from location: " - << m_veloPartialADCLocation - << ", size of data container (number of read-out TELL1s): " - << m_veloPartialADCs->size() <<endmsg; - - // --> create container for decoded data - m_decodedPartialADC=new LHCb::VeloTELL1Datas(); - - } - - // - m_veloPeds = getIfExists<VeloFullBanks>(pedContName()); - if( NULL == m_veloPeds ){ - if (m_isDebug) debug()<< " ==> There is no Pedestals at: " - << pedContName() <<endmsg; - }else{ - // get the pedestals banks from Pedestals TES location - if (m_isDebug) debug()<< " ==> The ped. banks have been read-in from location: " - << pedContName() - << ", size of pedestals container (number of read-out TELL1s): " - << m_veloPeds->size() <<endmsg; - // create container for decoded Ped - m_decodedPed=new LHCb::VeloTELL1Datas(); - setPedDataFlag(); - } - // - return ( StatusCode::SUCCESS ); -} -//============================================================================== -std::string DecodeVeloFullRawBuffer::adcContName() -{ - return ( m_veloADCLocation ); -} -//============================================================================== -std::string DecodeVeloFullRawBuffer::pedContName() -{ - return ( m_veloPedLocation ); -} -//============================================================================= -std::string DecodeVeloFullRawBuffer::decADCName() -{ - return ( m_decodedADCLocation ); -} -//============================================================================= -std::string DecodeVeloFullRawBuffer::decPedName() -{ - return ( m_decodedPedLocation ); -} -//============================================================================= -std::string DecodeVeloFullRawBuffer::decHeaderName() -{ - return ( m_decodedHeaderLocation ); -} -//============================================================================= -std::string DecodeVeloFullRawBuffer::evtInfoName() -{ - return ( m_evtInfoLocation ); -} -//============================================================================= -StatusCode DecodeVeloFullRawBuffer::decodeData() -{ - if (m_isDebug) debug()<< " ==> decodeData() " <<endmsg; - // - VeloFullBanks::const_iterator sensIt; - // - if(adcDataFlag()){ - // decode both ADC and ADCHeaders - // - for(sensIt=m_veloADCs->begin(); sensIt!=m_veloADCs->end(); sensIt++){ - m_ADCDecoder.decode(*sensIt,m_signADC); - m_HeaderDecoder.decode(*sensIt,m_signHeader); - // - LHCb::VeloTELL1Data* adcData=new LHCb::VeloTELL1Data((*sensIt)->key(), VeloFull); - LHCb::VeloTELL1Data* headerData=new LHCb::VeloTELL1Data((*sensIt)->key(), VeloHeader); - EvtInfo* anInfo=new EvtInfo((*sensIt)->key()); - // data coming from TELL1 board is unsigned int - // for the subsequent algorithms we required signed - // values; change from unsigned int -> signed int - // In the following we apply the cable reordering (sector correction) - // is necessary for the NZS data to agree with the ZS data. - // It corrects for the fact that the data cables between - // repeater board and Tell1 have to be connected in reverse - // to their numbering (data 0 -> tell1 input 3,data 1-> tell1 input 2 etc) - - if(m_sectorCorrection){ // need to correct for wrong cabling - int counter=0; - for(scdatIt iT=m_signADC.begin(); iT!=m_signADC.end(); ++iT){ - int channelposition=counter; - channelposition=m_cableOrder[channelposition/512]*512 + channelposition % 512; - - if (m_isDebug) debug() << "ADCbanks: "<< channelposition << " " <<(*iT) << endmsg; - - m_signADCReordered[channelposition]=static_cast<signed int>(*iT); - - counter++; - } - counter=0; - for(scdatIt iT=m_signHeader.begin(); iT!=m_signHeader.end(); iT++){ - int channelposition=counter; - channelposition = m_cableOrder[channelposition/64]*64 + channelposition % 64; - - - if (m_isDebug) debug() << "Header: "<< channelposition << " " << (*iT) << endmsg; - m_signHeaderReordered[channelposition]=(static_cast<signed int>(*iT)); - counter++; - } - adcData->setDecodedData(m_signADCReordered); - headerData->setDecodedData(m_signHeaderReordered); - } else { // no cable reordering requested - adcData->setDecodedData(m_signADC); - headerData->setDecodedData(m_signHeader); - } - - anInfo->setEvtInfo((*sensIt)->getEvtInfo()); - // - m_decodedADC->insert(adcData); - m_decodedHeader->insert(headerData); - m_evtInfo->insert(anInfo); - } - } - - if(NULL!=m_veloPartialADCs){ - // --> this part is responsible for the decoding of the partial data - // associated with an error bank - - VeloFullBanks::const_iterator partIt=m_veloPartialADCs->begin(); - - for( ; partIt!=m_veloPartialADCs->end(); ++partIt){ - - m_ADCPartialDecoder.decode(*partIt, m_signPartialADC); - LHCb::VeloTELL1Data* partData=new LHCb::VeloTELL1Data((*partIt)->key(), VeloFull); - - if(m_sectorCorrection){ // need to correct for wrong cabling - - int counter=0; - scdatIt pIT=m_signPartialADC.begin(); - - for( ; pIT!=m_signPartialADC.end(); ++pIT){ - - int channelposition=counter; - channelposition=m_cableOrder[channelposition/512]*512 + channelposition % 512; - m_signPartialADCReordered[channelposition]=static_cast<signed int>(*pIT); - counter++; - - } - - partData->setDecodedData(m_signPartialADCReordered); - - }else{ // --> no cable reordering requested - - partData->setDecodedData(m_signPartialADC); - - } - - m_decodedPartialADC->insert(partData); - - } - - } - - // - if(pedDataFlag()){ - for(sensIt=m_veloPeds->begin(); sensIt!=m_veloPeds->end(); sensIt++){ - m_PedDecoder.decode(*sensIt, m_signPed); - LHCb::VeloTELL1Data* pedData=new LHCb::VeloTELL1Data((*sensIt)->key(), VeloPedestal); - - if(true==m_sectorCorrection){ // need to correct for wrong cabling - int counter=0; - for(scdatIt iT=m_signPed.begin(); iT!=m_signPed.end(); iT++){ - int channelposition=counter; - channelposition = m_cableOrder[channelposition/512]*512 + channelposition % 512; - if (m_isDebug) debug() << "Ped bank: " << channelposition << " " <<(*iT) << endmsg; - m_signPedReordered[channelposition]=static_cast<signed int>(*iT); - counter++; - } - pedData->setDecodedData(m_signPedReordered); - } else { // no cable reordering requested - pedData->setDecodedData(m_signPed); - } - m_decodedPed->insert(pedData); - } - } - // - if((!adcDataFlag())&&(!pedDataFlag())){ - if ( m_isDebug ) debug()<< " ==> No data decoded! " <<endmsg; - return ( StatusCode::SUCCESS ); - }else{ - return ( StatusCode::SUCCESS ); - } -} -//============================================================================= -void DecodeVeloFullRawBuffer::sortAndWriteDecodedData() -{ - if (m_isDebug) debug()<< " ==> writeDecodedData() " <<endmsg; - // - if(adcDataFlag()){ - // sort the output containers by key (TELL1 number) - std::stable_sort(m_decodedADC->begin(), m_decodedADC->end(), - VeloEventFunctor::Less_by_key<LHCb::VeloTELL1Data*>()); - std::stable_sort(m_decodedHeader->begin(), m_decodedHeader->end(), - VeloEventFunctor::Less_by_key<LHCb::VeloTELL1Data*>()); - std::stable_sort(m_evtInfo->begin(), m_evtInfo->end(), - VeloEventFunctor::Less_by_key<EvtInfo*>()); - // put the data to TES - put(m_decodedADC, decADCName()); - put(m_decodedHeader, decHeaderName()); - put(m_evtInfo, evtInfoName()); - } - - if(NULL!=m_decodedPartialADC) - { - if(!m_decodedPartialADC->empty()) if (m_isDebug) debug()<< " --> Write some data " <<endmsg; - - put(m_decodedPartialADC, m_decodedPartialADCLocation); - - } - - if(pedDataFlag()){ - // sort decoded pedestals - std::stable_sort(m_decodedPed->begin(), m_decodedPed->end(), - VeloEventFunctor::Less_by_key<LHCb::VeloTELL1Data*>()); - // put decoded peds in TES - put(m_decodedPed, decPedName()); - } -} -//============================================================================= -void DecodeVeloFullRawBuffer::setADCDataFlag() -{ - m_adcDataPresent=true; -} -//============================================================================= -void DecodeVeloFullRawBuffer::setPedDataFlag() -{ - m_pedDataPresent=true; -} -//============================================================================= -bool DecodeVeloFullRawBuffer::adcDataFlag() -{ - return ( m_adcDataPresent ); -} -//============================================================================= -bool DecodeVeloFullRawBuffer::pedDataFlag() -{ - return ( m_pedDataPresent ); -} -//============================================================================= -void DecodeVeloFullRawBuffer::unsetADCDataFlag() -{ - m_adcDataPresent=false; -} -//============================================================================= -void DecodeVeloFullRawBuffer::unsetPedDataFlag() -{ - m_pedDataPresent=false; -} -// -void DecodeVeloFullRawBuffer::resetMemory() -{ - if (m_isDebug) debug()<< " ==> resetMemory() " <<endmsg; - // - unsetADCDataFlag(); - unsetPedDataFlag(); -} -// diff --git a/Velo/VeloDAQ/src/DecodeVeloFullRawBuffer.h b/Velo/VeloDAQ/src/DecodeVeloFullRawBuffer.h deleted file mode 100644 index b1ec36aa0df69578e15a02a5d123a3f8914953ac..0000000000000000000000000000000000000000 --- a/Velo/VeloDAQ/src/DecodeVeloFullRawBuffer.h +++ /dev/null @@ -1,99 +0,0 @@ -#ifndef DECODEVELOFULLRAWBUFFER_H -#define DECODEVELOFULLRAWBUFFER_H 1 - -// Include files -// from Gaudi -#include "GaudiAlg/GaudiAlgorithm.h" - -// local -#include "VeloEvent/VeloFullBank.h" -#include "VeloEvent/VeloTELL1Data.h" -#include "VeloEvent/EvtInfo.h" -#include "Tell1Kernel/VeloDecodeCore.h" -#include "Tell1Kernel/VeloDecodeConf.h" -#include "VeloFullDecoder.h" - -/** @class DecodeVeloFullRawBuffer DecodeVeloFullRawBuffer.h - * - * - * @author Tomasz Szumlak - * @date 2006-04-21 - */ - -using namespace VeloTELL1; - -class DecodeVeloFullRawBuffer : public GaudiAlgorithm { -public: - /// Standard constructor - DecodeVeloFullRawBuffer( const std::string& name, ISvcLocator* pSvcLocator ); - - virtual ~DecodeVeloFullRawBuffer( ); ///< Destructor - - StatusCode initialize() override; ///< Algorithm initialization - StatusCode execute () override; ///< Algorithm execution - - StatusCode getData(); - StatusCode decodeData(); - -protected: - - std::string adcContName(); - std::string pedContName(); - std::string decADCName(); - std::string decPedName(); - std::string decHeaderName(); - std::string evtInfoName(); - void sortAndWriteDecodedData(); - void setADCDataFlag(); - void setPedDataFlag(); - bool adcDataFlag(); - bool pedDataFlag(); - void resetMemory(); - void unsetADCDataFlag(); - void unsetPedDataFlag(); - -private: - // location paths - std::string m_veloADCLocation; - std::string m_veloPartialADCLocation; - std::string m_veloPedLocation; - std::string m_decodedADCLocation; - std::string m_decodedPartialADCLocation; - std::string m_decodedPedLocation; - std::string m_decodedHeaderLocation; - std::string m_evtInfoLocation; - // input data - VeloFullBanks* m_veloADCs; - VeloFullBanks* m_veloPartialADCs; - VeloFullBanks* m_veloPeds; - // decoded data for futher processing - LHCb::VeloTELL1Datas* m_decodedADC; - LHCb::VeloTELL1Datas* m_decodedPartialADC; - LHCb::VeloTELL1Datas* m_decodedPed; - LHCb::VeloTELL1Datas* m_decodedHeader; - EvtInfos* m_evtInfo; - // flags - bool m_adcDataPresent; - bool m_pedDataPresent; - bool m_sectorCorrection; - bool m_isDebug; - // data buffers - sdataVec m_signADC; - sdataVec m_signPartialADC; - sdataVec m_signADCReordered; - sdataVec m_signPartialADCReordered; - sdataVec m_signHeader; - sdataVec m_signHeaderReordered; - sdataVec m_signPed; - sdataVec m_signPedReordered; - // decoders - VeloFullDecoder m_ADCDecoder; - VeloFullDecoder m_ADCPartialDecoder; - VeloFullDecoder m_HeaderDecoder; - VeloFullDecoder m_PedDecoder; - // cable order - std::vector<unsigned int> m_cableOrder; - - -}; -#endif // DECODEVELOFULLRAWBUFFER_H diff --git a/Velo/VeloDAQ/src/DecodeVeloRawBuffer.cpp b/Velo/VeloDAQ/src/DecodeVeloRawBuffer.cpp deleted file mode 100644 index b11dd8ab966e860be49ce1475a48f0acda565709..0000000000000000000000000000000000000000 --- a/Velo/VeloDAQ/src/DecodeVeloRawBuffer.cpp +++ /dev/null @@ -1,478 +0,0 @@ -#include "GaudiKernel/IIncidentSvc.h" -#include "GaudiKernel/Incident.h" - -#include "Event/RawEvent.h" -#include "Event/RawBank.h" -#include "Event/VeloLiteCluster.h" -#include "Event/VeloCluster.h" -#include "Event/ProcStatus.h" - -#include "VeloDet/DeVelo.h" -#include "VeloDet/DeVeloSensor.h" - -#include "DecodeRawBankToLiteClusters.h" -#include "DecodeRawBankToClusters.h" - -#include "DecodeVeloRawBuffer.h" -#include "VeloRawBankDecoder.h" -#include "VeloRawBankVersions.h" - - -//----------------------------------------------------------------------------- -// Implementation file for class : DecodeVeloRawBuffer -// -// 2004-02-02 : Chris Parkes -// 2006-02-23 : David Jones, Kurt Rinnert -// - complete rewrite -//----------------------------------------------------------------------------- - -DECLARE_ALGORITHM_FACTORY( DecodeVeloRawBuffer ) - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -DecodeVeloRawBuffer::DecodeVeloRawBuffer( const std::string& name, - ISvcLocator* pSvcLocator) - : Decoder::AlgBase ( name , pSvcLocator ) -{ - declareProperty("DecodeToVeloLiteClusters",m_decodeToVeloLiteClusters=true); - declareProperty("DecodeToVeloClusters",m_decodeToVeloClusters=false); - declareProperty("DumpVeloClusters",m_dumpVeloClusters=false); - declareProperty("VeloLiteClustersLocation",m_veloLiteClusterLocation=LHCb::VeloLiteClusterLocation::Default); - declareProperty("VeloClusterLocation",m_veloClusterLocation=LHCb::VeloClusterLocation::Default); - declareProperty("AssumeChipChannelsInRawBuffer",m_assumeChipChannelsInRawBuffer=false); - declareProperty("ForceBankVersion",m_forcedBankVersion=0);// there is no version 0, so this means bank version is not enforced - declareProperty("ErrorCount",m_errorCount=0); - declareProperty("IgnoreErrors",m_ignoreErrors=false, - "Decode clusters even if errors are present. Use with care, can cause crashes on corrupted banks."); - declareProperty("DoLengthCheck",m_doLengthCheck=false, - "Check when decoding lite clusters that the bank length is correct"); - - declareProperty("MaxVeloClusters", m_maxVeloClusters = 10000); - declareProperty("HideWarnings", m_hideWarnings = true); - //new for decoders, initialize search path, and then call the base method - m_defaultRawEventLocations={LHCb::RawEventLocation::Velo, // When only VELO retained in stripping - LHCb::RawEventLocation::Other, // Stripping default - LHCb::RawEventLocation::Default};// RAW default - - m_rawEventLocations.resize(m_defaultRawEventLocations.size(),""); - std::copy(m_defaultRawEventLocations.begin(), - m_defaultRawEventLocations.end(),m_rawEventLocations.begin()); - initRawEventSearch(); -} - - -//============================================================================= -// Initialisation. Check parameters -//============================================================================= -StatusCode DecodeVeloRawBuffer::initialize() { - - StatusCode sc = Decoder::AlgBase::initialize(); // must be executed first - if ( sc.isFailure() ) return sc; // error printed already by GaudiAlgorithm - - if ( msgLevel( MSG::DEBUG ) ) debug () << "==> Initialise" << endmsg; - - // check whether enforced bank version is supported - if(m_forcedBankVersion) { - switch (m_forcedBankVersion) { - case VeloDAQ::v2: // ok, supported - case VeloDAQ::v3: - break; - default: // not supported, bail out - error() << "User enforced VELO raw buffer version " - << m_forcedBankVersion - << " is not supported." - << endmsg; - return StatusCode::FAILURE; - } - } - - info() << "Cancel processing of events with more than " << m_maxVeloClusters - << " Velo clusters" << endmsg; - - m_velo = getDet<DeVelo>( DeVeloLocation::Default ); - - if (m_rawEventLocations.empty()) - { - return Error("I can't decode if you don't tell me where to decode to! Fill RawEventLocations!",StatusCode::FAILURE); - } - - if ( m_rawEventLocations.size() == 1 ){ // if one entry and not in default list print - if ( std::find(m_defaultRawEventLocations.begin(), - m_defaultRawEventLocations.end(), - m_rawEventLocations[0]) == m_defaultRawEventLocations.end() ) { - info() << "Using '" << m_rawEventLocations << "' as search path for the RawEvent object" << endmsg; - } - }else if( ( m_defaultRawEventLocations.size() != m_rawEventLocations.size() ) or - (std::mismatch(m_defaultRawEventLocations.begin(), // if a list but not the same list print - m_defaultRawEventLocations.end(), - m_rawEventLocations.begin()).first != - m_defaultRawEventLocations.end() ) ){ - info() << "Using '" << m_rawEventLocations << "' as search path for the RawEvent object" << endmsg; - } - - return StatusCode::SUCCESS; -} - -//============================================================================= -// Main execution -//============================================================================= -StatusCode DecodeVeloRawBuffer::execute() { - - auto decStatus = - getIfExists<LHCb::VeloDecodeStatus>(m_veloLiteClusterLocation+"DecStatus"); - if( !decStatus ){ - decStatus = new LHCb::VeloDecodeStatus(); - put(decStatus,m_veloLiteClusterLocation+"DecStatus"); - } - - // Retrieve the RawEvent: - LHCb::RawEvent* rawEvent = findFirstRawEvent(); - - if( rawEvent == NULL ) { - if( msgLevel( MSG::DEBUG ) ) - debug() << "Raw Event not found in " << m_rawEventLocations << endmsg; - createEmptyBanks(); - return StatusCode::SUCCESS; - } - - const std::vector<LHCb::RawBank*>& banks = rawEvent->banks(LHCb::RawBank::Velo); - - StatusCode sc; - - // decode to lite clusters, if requested, bail out if something goes wrong - if (m_decodeToVeloLiteClusters) { - sc = decodeToVeloLiteClusters(banks,decStatus); - if (sc.isFailure()) return sc; - } - - // decode to clusters, if requested, bail out if something goes wrong - if (m_decodeToVeloClusters) { - sc = decodeToVeloClusters(banks,decStatus); - if (sc.isFailure()) return sc; - } - - return StatusCode::SUCCESS; -} - -//============================================================================= -// Private helpers -//============================================================================= - -StatusCode DecodeVeloRawBuffer:: -decodeToVeloLiteClusters(const std::vector<LHCb::RawBank*>& banks, - LHCb::VeloDecodeStatus *decStatus) const { - LHCb::VeloLiteCluster::FastContainer* fastCont = new LHCb::VeloLiteCluster::FastContainer(); - - // make sure we have enough capacity in the container - // to avoid unnecessary relocations - // yes this is a guessed number based on <4% of signal events - // need more than clusters (one length doubling operation required) - fastCont->reserve(4096); - - for (const LHCb::RawBank* rb : banks ) { - - // --> protect against corrupted banks - if(LHCb::RawBank::MagicPattern!=rb->magic()) { - failEvent(format("Bad magic pattern in bank source ID %i", - rb->sourceID()), - "CorruptVeloBuffer",CorruptVeloBuffer,false); - continue; - } - - const DeVeloSensor* sensor = m_velo->sensorByTell1Id(static_cast<unsigned int>(rb->sourceID())); - if (!sensor) { - failEvent(format("Could not map source ID %i to sensor number!", - rb->sourceID()), - "BadTELL1IDMapping",BadTELL1IDMapping,false); - continue; - } - - int byteCount(0); - int nClusters; - const SiDAQ::buffer_word* rawBank = static_cast<const SiDAQ::buffer_word*>(rb->data()); - - if( m_doLengthCheck ) { - nClusters =VeloDAQ::decodeRawBankToLiteClusters(rawBank,*sensor, - m_assumeChipChannelsInRawBuffer, - *fastCont, byteCount, m_ignoreErrors); - }else{ - nClusters = VeloDAQ::decodeRawBankToLiteClusters(rawBank,*sensor, - *fastCont, m_ignoreErrors); - } - - if( nClusters == -1 ) { - if ( !m_ignoreErrors ) { - if ( msgLevel( MSG::DEBUG ) ) debug() << "Header error bit set in raw bank source ID " - << rb->sourceID() << endmsg; - failEvent(format("Header error bit set in the VELO, bank source ID %i", - rb->sourceID()), - "HeaderErrorVeloBuffer",HeaderErrorBit,false); - // no clusters produced so continue - decStatus->setDecoderState(sensor->sensorNumber(),false); - continue; - } - } - - if ( m_doLengthCheck && (rb->size() != byteCount) ) { - if ( msgLevel( MSG::DEBUG ) ) debug() << "Byte count mismatch between RawBank size and decoded bytes." - << " RawBank: " << rb->size() - << " Decoded: " << byteCount - << endmsg; - failEvent(format("Raw data corruption in the VELO, bank source ID %i", - rb->sourceID()), - "CorruptVeloBuffer",CorruptVeloBuffer,false); - // assume all clusters from the bad sensor at the end - if (nClusters>0) fastCont->resize( fastCont->size() - nClusters ); - // a wrong byte count is also considered an error - decStatus->setDecoderState(sensor->sensorNumber(),false); - } else { // we got clusters decoded from this bank, update decode status - decStatus->setDecoderState(sensor->sensorNumber(),true); - } - } - if( fastCont->size() > m_maxVeloClusters){ - fastCont->clear(); - failEvent(format("Deleted all lite VELO clusters as more than limit %i in the event", - m_maxVeloClusters), - "TooManyClusters",TooManyClusters,true); - } - - std::sort(fastCont->begin(),fastCont->end(),SiDataFunctor::Less_by_Channel< LHCb::VeloLiteCluster >()); - put(fastCont,m_veloLiteClusterLocation); - - return StatusCode::SUCCESS; -} - -StatusCode DecodeVeloRawBuffer::decodeToVeloClusters(const std::vector<LHCb::RawBank*>& banks,LHCb::VeloDecodeStatus* decStatus) const -{ - auto clusters = std::unique_ptr<LHCb::VeloClusters>(new LHCb::VeloClusters()); - - // Number of bytes in bank, including 4 byte header but - // *without* the padding bytes at the end. - // This is filled by the decoding function and should always - // be the same as RawBank::size(). - int byteCount; - - for (const auto& rb : banks) { - - // a priory we assume the byte count is correct - byteCount = rb->size(); - - // --> protect against corrupted banks - if(LHCb::RawBank::MagicPattern!=rb->magic()) { - failEvent(format("Bad magic pattern in bank source ID %i", - rb->sourceID()), - "CorruptVeloBuffer",CorruptVeloBuffer,false); - continue; - } - - const SiDAQ::buffer_word* rawBank = static_cast<const SiDAQ::buffer_word*>(rb->data()); - - const DeVeloSensor* sensor = m_velo->sensorByTell1Id(static_cast<unsigned int>(rb->sourceID())); - if (!sensor) { - failEvent(format("Could not map source ID %i to sensor number!", - rb->sourceID()), - "BadTELL1IDMapping",BadTELL1IDMapping,false); - continue; - } - - unsigned int bankVersion = m_forcedBankVersion ? m_forcedBankVersion : rb->version(); - - int nClusters = 0; - std::string errorMsg; - switch (bankVersion) { - case VeloDAQ::v2: - nClusters = - VeloDAQ::decodeRawBankToClustersV2(rawBank,sensor, - m_assumeChipChannelsInRawBuffer, - *clusters,byteCount,m_ignoreErrors); - break; - case VeloDAQ::v3: - nClusters = - VeloDAQ::decodeRawBankToClustersV3(rawBank,sensor, - m_assumeChipChannelsInRawBuffer, - *clusters,byteCount,errorMsg,m_ignoreErrors); - if ( !errorMsg.empty() ) { - unsigned int msgCount = 0; - if ( msgLevel(MSG::DEBUG) ) { - msgCount = 10; - Warning(errorMsg, StatusCode::SUCCESS, msgCount).ignore(); - }else{ - // currently suppressed due to presence of bug in TELL1 cluster maker - if(!m_hideWarnings){ - Warning(errorMsg, StatusCode::SUCCESS, msgCount).ignore(); - } - } - } - break; - default: // bank version is not supported: kill the event - failEvent(format("VELO raw buffer version %i is not supported.", - rb->sourceID()), - "UnsupportedBufferVersion",UnsupportedBufferVersion,false); - continue; - } - - if( nClusters == -1 ) { - if ( !m_ignoreErrors ){ - debug() << "Header error bit set in raw bank source ID " - << rb->sourceID() << endmsg; - failEvent(format("Header error bit set in the VELO, bank source ID %i", - rb->sourceID()), - "HeaderErrorVeloBuffer",HeaderErrorBit,false); - // no clusters produced so continue - decStatus->setDecoderState(sensor->sensorNumber(), false); - continue; - } - } - - if (rb->size() != byteCount) { - if ( msgLevel( MSG::DEBUG ) ) debug() << "Byte count mismatch between full RawBank size and decoded bytes." - << " RawBank: " << rb->size() - << " Decoded: " << byteCount - << endmsg; - failEvent(format("Raw data corruption in the VELO, bank source ID %i", - rb->sourceID()), - "CorruptVeloBuffer",CorruptVeloBuffer,false); - decStatus->setDecoderState(sensor->sensorNumber(), false); - StatusCode sc = replaceFullFromLite(*clusters,sensor->sensorNumber(), - banks, decStatus); - if(!sc) return Error("Failed to convert lite to fake full VELO clusters"); - } else { // we got clusters decoded from this bank, update TELL1 event info - decStatus->setDecoderState(sensor->sensorNumber(), true); - } - } - - if( clusters->size() > m_maxVeloClusters){ - clusters->clear(); - failEvent(format("Deleted all full VELO clusters as more than limit %i in the event",m_maxVeloClusters), - "TooManyClusters",TooManyClusters,true); - } - - if (m_dumpVeloClusters) dumpVeloClusters(*clusters); - put(clusters.release(),m_veloClusterLocation); - - return StatusCode::SUCCESS; -} - -void DecodeVeloRawBuffer::dumpVeloClusters(const LHCb::VeloClusters& clusters) const -{ - std::vector<float> adcValues; - - for (const auto& clu : clusters ) { - - unsigned int sensorNumber = clu->channelID().sensor(); - unsigned int centroidStrip = clu->channelID().strip(); - - // interstrip position in 1/8 of strip pitch (as it is encoded in raw bank) - // float interStripPos = static_cast<unsigned int>((clu->interStripFraction())*8.0)/8.0; - double interStripPos = clu->interStripFraction(); - - info() << "DEC::POSDUMP:" - << " SN=" << sensorNumber - << " CS=" << centroidStrip - << " ISP=" << interStripPos - << endmsg; - - info() << "DEC::ADCDUMP:" - << " SN=" << sensorNumber; - - for (unsigned int adci=0; adci<clu->size(); ++adci) { - info() << " " << clu->adcValue(adci) - << "@" << clu->strip(adci); - } - info() << endmsg; - - } -} - -void DecodeVeloRawBuffer::createEmptyBanks() const { - if ( m_decodeToVeloLiteClusters ) { - put(new LHCb::VeloLiteCluster::FastContainer(),m_veloLiteClusterLocation); - } - if ( m_decodeToVeloClusters ) { - put(new LHCb::VeloClusters(),m_veloClusterLocation); - } -} - -void DecodeVeloRawBuffer::failEvent(const std::string &ErrorText, - const std::string &ProcText, - AlgStatusType status, - bool procAborted) const { - // set ProcStat for this event to failed in DecodeVeloRawBuffer - LHCb::ProcStatus *pStat = - getOrCreate<LHCb::ProcStatus,LHCb::ProcStatus>(LHCb::ProcStatusLocation::Default); - pStat->addAlgorithmStatus("DecodeVeloRawBuffer", - "VELO",ProcText,status,procAborted); - if( m_errorCount > 0 || msgLevel(MSG::DEBUG) ) { - unsigned int msgCount = m_errorCount; - if ( msgLevel(MSG::DEBUG) ) msgCount += 10; - Error(ErrorText,StatusCode::SUCCESS,msgCount).ignore(); - } -} - -StatusCode DecodeVeloRawBuffer:: -replaceFullFromLite(LHCb::VeloClusters& clusters, - unsigned int nSensor, - const std::vector<LHCb::RawBank*>& banks, - LHCb::VeloDecodeStatus *decStatus) const { - - unsigned int msgCount = 1; - if ( msgLevel(MSG::DEBUG) ) msgCount = 10; - Error(format("Corrupt buffer sensor %i, matching lite clusters in full bank", - nSensor), StatusCode::SUCCESS, msgCount).ignore(); - - LHCb::VeloLiteCluster::FastContainer *veloLiteClusters = - getIfExists<LHCb::VeloLiteCluster::FastContainer>(m_veloLiteClusterLocation); - if(!veloLiteClusters){ - // not asked to decode in options and no DOD setup :( - // But we are the decoder! We can make the container ourselves - StatusCode sc = decodeToVeloLiteClusters(banks,decStatus); - if (sc.isFailure()) return sc; - veloLiteClusters = get<LHCb::VeloLiteCluster::FastContainer>(m_veloLiteClusterLocation); - } - - std::vector<LHCb::VeloChannelID> killChannels; - for(const auto& c : clusters ) { - if( c->channelID().sensor() == nSensor ){ - killChannels.push_back(c->channelID()); - } - } - // nuke all existing clusters from this sensor - for(const auto& i : killChannels) clusters.erase(i); - - // replace with fake cluster to match the badly decoded lite container - for(const auto& c : *veloLiteClusters ) { - if( c.channelID().sensor() == nSensor ) makeFakeCluster(c,clusters); - } - - return StatusCode::SUCCESS; -} - -void DecodeVeloRawBuffer:: -makeFakeCluster(LHCb::VeloLiteCluster const &liteCluster, - LHCb::VeloClusters& fakeClusters) const { - - LHCb::VeloCluster * fakeClus; - if( liteCluster.pseudoSize() == 1){ - fakeClus = new LHCb::VeloCluster( liteCluster, { std::make_pair(liteCluster.channelID().strip(), - liteCluster.highThreshold()?64:21) } ); - }else{ - // always fake two strip clusters for two or more strip clusters - // from pseudosize - LHCb::VeloCluster::ADCVector vec; vec.reserve(2); - if( liteCluster.highThreshold() ){ - unsigned int secondADC = static_cast<unsigned int>(4. + (liteCluster.interStripFraction()*64.)); - unsigned int firstADC = static_cast<unsigned int>(64 - secondADC); - vec.emplace_back(liteCluster.channelID().strip(),firstADC); - vec.emplace_back(liteCluster.channelID().strip()+1,secondADC); - }else{ - unsigned int secondADC = static_cast<unsigned int>((4. + (liteCluster.interStripFraction()*64.))/3.); - unsigned int firstADC = static_cast<unsigned int>(21 - secondADC); - vec.emplace_back(liteCluster.channelID().strip(),firstADC); - vec.emplace_back(liteCluster.channelID().strip()+1,secondADC); - } - fakeClus = new LHCb::VeloCluster(liteCluster,vec); - } - - fakeClusters.insert(fakeClus,liteCluster.channelID()); -} diff --git a/Velo/VeloDAQ/src/DecodeVeloRawBuffer.h b/Velo/VeloDAQ/src/DecodeVeloRawBuffer.h deleted file mode 100644 index 238fc42d42e4f6806c78d6bbf790c08f2a346821..0000000000000000000000000000000000000000 --- a/Velo/VeloDAQ/src/DecodeVeloRawBuffer.h +++ /dev/null @@ -1,146 +0,0 @@ -#ifndef DECODEVELORAWBUFFER_H -#define DECODEVELORAWBUFFER_H 1 - -#include <string> - -#include "GaudiAlg/GaudiAlgorithm.h" -#include "DAQKernel/DecoderAlgBase.h" -#include "VeloEvent/VeloDecodeStatus.h" - -#include "SiDAQ/SiRawBufferWord.h" - -namespace LHCb { - class RawBank; -} - -class DeVelo; -class IIncidentSvc; - -/** @class DecodeVeloRawBuffer DecodeVeloRawBuffer.h - * Decode the Velo data from the 1MHZ Raw buffer. - * Completely re-written for the new 1Mhz raw buffer. - * - * @author David Jones - * @author Kurt Rinnert - * @author Chris Parkes - * @date 2004-02-02 - */ -class DecodeVeloRawBuffer : public Decoder::AlgBase { -public: - - /// Standard constructor - DecodeVeloRawBuffer( const std::string& name, ISvcLocator* pSvcLocator ); - - StatusCode initialize() override; ///< Algorithm initialization - StatusCode execute () override; ///< Algorithm execution - - enum AlgStatusType{ - OK = 0, - BadTELL1IDMapping = 1, - UnsupportedBufferVersion = 2, - CorruptVeloBuffer = 3, - TooManyClusters = 4, - HeaderErrorBit = 5, - Other = 99 - }; - - -private: - - /** Decode raw buffer to lite clusters - * This decodes the raw buffer to VeloLiteClusters and - * adds a VeloLiteCluster::FastContainer to the TES. - * - * @see VeloLiteCluster - */ - StatusCode decodeToVeloLiteClusters(const std::vector<LHCb::RawBank*>& banks, - LHCb::VeloDecodeStatus* decStatus) const; - - /** Decode raw buffer to clusters - * This decodes the raw buffer to VeloClusters and - * adds themn to the TES. - * - * @see VeloCluster - */ - StatusCode decodeToVeloClusters(const std::vector<LHCb::RawBank*>& banks, - LHCb::VeloDecodeStatus *decStatus) const; - - /** Write VeloClusters to stdout - * - * @see VeloCluster - */ - void dumpVeloClusters(const LHCb::VeloClusters& clusters) const; - - /** Create empty banks - * - * Creates empty cluster and lite cluster banks on the TES. - * This called as a failsafe option in case the raw event - * is missing. - * */ - void createEmptyBanks() const; - - /** Add DecodeVeloRawBuffer to list of failed algorithms - * if procAbort = true set the ProcStatus to "aborted" to show - * this event should be removed from physics streams - */ - void failEvent(const std::string &ErrorText, - const std::string &ProcText, - AlgStatusType status, - bool procAborted) const; - - /** Replace the full clusters for a specific sensor with faked - * clusters from the lite container - */ - StatusCode replaceFullFromLite(LHCb::VeloClusters& clusters, - unsigned int nSensor, - const std::vector<LHCb::RawBank*>& banks, - LHCb::VeloDecodeStatus *decStatus) const; - - /// Add a fake lite cluster to the full cluster container - void makeFakeCluster(LHCb::VeloLiteCluster const &liteCluster, - LHCb::VeloClusters& fakeClusters) const; - -private: - - // configuration - - bool m_decodeToVeloLiteClusters; - bool m_decodeToVeloClusters; - - bool m_dumpVeloClusters; - - unsigned int m_forcedBankVersion; ///< user forced bank version - - std::string m_veloLiteClusterLocation; - std::string m_veloClusterLocation; - - /// do we assume chip channels instead of strips in the raw buffer? - /// (useful for some testbeam TELL1 cinfigurations, defaults to false) - bool m_assumeChipChannelsInRawBuffer; - - /// helpers - const DeVelo* m_velo = nullptr; - - /// maximum permissible number of VELO clusters, - /// more than this will force an IncidentType::AbortEvent - unsigned int m_maxVeloClusters; - - /// m_errorCount is the number of errors per fault to print - /// default = 0 - /// 10 is added to it if the message level is debug - unsigned int m_errorCount; - - /// if true, clusters will be decoded even in the presence of errors - bool m_ignoreErrors = false; - - /// if true hide the errors from multiple cluster using the same strip - bool m_hideWarnings; - - /// Check when decoding lite clusters that the bank length is correct - bool m_doLengthCheck; - - /// default raw event locations: not set in options to allow comparison - std::vector<std::string> m_defaultRawEventLocations; - -}; -#endif // DECODEVELORAWBUFFER_H diff --git a/Velo/VeloDAQ/src/PrepareVeloFullRawBuffer.cpp b/Velo/VeloDAQ/src/PrepareVeloFullRawBuffer.cpp deleted file mode 100644 index 4b4e1f1339c3bd55d8783e447d95d399e49edbf7..0000000000000000000000000000000000000000 --- a/Velo/VeloDAQ/src/PrepareVeloFullRawBuffer.cpp +++ /dev/null @@ -1,410 +0,0 @@ -// Include files -#include <stdexcept> -#include <exception> - -// from Gaudi -#include "GaudiAlg/Tuples.h" - -// local -#include "PrepareVeloFullRawBuffer.h" - -// data model -#include "Event/RawEvent.h" - -// stl -#include <algorithm> - -//----------------------------------------------------------------------------- - -// Implementation file for class : PrepareVeloFullRawBuffer -// -// 2006-03-22 : Tomasz Szumlak -//----------------------------------------------------------------------------- - -// Declaration of the Algorithm Factory -DECLARE_ALGORITHM_FACTORY( PrepareVeloFullRawBuffer ) - -typedef std::map<unsigned int, std::pair<unsigned int, unsigned int*> > DATA_REPO; -typedef DATA_REPO::const_iterator DR_IT; -typedef std::pair<unsigned int, unsigned int* > DATA_PAIR; - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -PrepareVeloFullRawBuffer::PrepareVeloFullRawBuffer( const std::string& name, - ISvcLocator* pSvcLocator) - : GaudiTupleAlg ( name , pSvcLocator ), - m_rawEvent ( 0 ), - m_veloADCData ( 0 ), - m_veloADCPartialData ( 0 ), - m_veloPedestals ( 0 ), - m_veloPedestalsLoc ( VeloFullBankLocation::Pedestals ), - m_adcBankPresent ( false ), - m_pedBankPresent ( false ), - m_isDebug ( msgLevel( MSG::DEBUG ) ) -{ - - declareProperty("RunWithODIN", m_runWithODIN=true); - declareProperty("RawEventLocation", - m_rawEventLoc=LHCb::RawEventLocation::Default); - declareProperty("ADCLocation", - m_veloADCDataLoc=VeloFullBankLocation::Default); - declareProperty("ADCPartialLoc", - m_veloADCPartialDataLoc="Raw/Velo/PreparedPartialADC"); - declareProperty("RoundRobin", m_roundRobin=false); - declareProperty("IgnoreErrorBanks", m_ignoreErrorBanks=true); - -} -//============================================================================= -// Destructor -//============================================================================= -PrepareVeloFullRawBuffer::~PrepareVeloFullRawBuffer() {} -//============================================================================= -// Initialization -//============================================================================= -StatusCode PrepareVeloFullRawBuffer::initialize() { - StatusCode sc = GaudiAlgorithm::initialize(); // must be executed first - if ( sc.isFailure() ) return sc; // error printed already by GaudiAlgorithm - - if(m_isDebug) debug() << "==> Initialize" << endmsg; - // - // setHistoTopDir( "Vetra/" ); - return StatusCode::SUCCESS; -} -//============================================================================= -// Main execution -//============================================================================= -StatusCode PrepareVeloFullRawBuffer::execute() { - - if(m_isDebug) debug() << "==> Execute" << endmsg; - // - StatusCode rawEvtStatus=getRawEvent(); - - if(rawEvtStatus.isSuccess()){ - - getRawBanks(); - // if there is adc bank or pedestal bank begin ordering - - if(adcBankFlag()||pedBankFlag()){ - - if(adcBankFlag()||pedBankFlag()) createOrderedSections(); - writeVeloFull(); - // flush the memory after each event - resetMemory(); - - }else if(m_roundRobin){ - - writeVeloFull(); - - } - - }else{ - - return ( StatusCode::SUCCESS); - - } - // - if(m_isDebug) debug()<< " end of execute" <<endmsg; - - return ( StatusCode::SUCCESS ); -} - -//============================================================================= -StatusCode PrepareVeloFullRawBuffer::getRawEvent() -{ - if(m_isDebug) { - debug()<< " ==> getRawEvent() " <<endmsg; - debug()<< "--------------------" <<endmsg; - } - // - // get the RawEvent from default TES location - m_rawEvent = getIfExists<LHCb::RawEvent>(m_rawEventLoc); - if( NULL == m_rawEvent ){ - return Error( " ==> There is no RawEvent at: " + m_rawEventLoc ); - }else{ - if(m_isDebug) debug()<< " ==> The RawEvent has been read-in from location: " - << m_rawEventLoc <<endmsg; - } - // - return ( StatusCode::SUCCESS ); -} -//============================================================================= -StatusCode PrepareVeloFullRawBuffer::getRawBanks() -{ - if(m_isDebug) debug()<< " ==> getRawBanks() " <<endmsg; - // check if there is non-zero suppressed bank present - const std::vector<LHCb::RawBank*>& fullBanks= - m_rawEvent->banks(LHCb::RawBank::VeloFull); - const std::vector<LHCb::RawBank*>& errorBanks= - m_rawEvent->banks(LHCb::RawBank::VeloError); - std::vector<LHCb::RawBank*>::const_iterator bIt; - std::vector<LHCb::RawBank*>::const_iterator isError; - - // if so get all info needed for decoding - if(!fullBanks.empty()){ - - setADCBankFlag(); - m_veloADCData=new VeloFullBanks(); - m_veloADCPartialData=new VeloFullBanks(); - // - - for(bIt=fullBanks.begin(); bIt!=fullBanks.end(); bIt++){ - - LHCb::RawBank* aBank=(*bIt); - // protection against wrong magic pattern - - if(LHCb::RawBank::MagicPattern!=aBank->magic()){ - - info()<< " --> Bank with source ID: " << (aBank->sourceID()) - << " is corrupted! Skipping to the next event" <<endmsg; - return ( StatusCode::SUCCESS ); - - } - - // get the sensor number == sourceID - int sensor=aBank->sourceID(); - - if(!m_ignoreErrorBanks) - { - - // handle the data sent out together with an error bank properly - isError=find_if(errorBanks.begin(), errorBanks.end(), errorBankFinder(sensor)); - if(isError!=errorBanks.end()) - { - - DATA_PAIR data_info=std::make_pair(aBank->size(), aBank->data()); - m_partialData2Decode[(aBank->sourceID())]=data_info; - - DATA_PAIR eb_info=std::make_pair((*isError)->size(), (*isError)->data()); - m_errorBanks2Check[(aBank->sourceID())]=eb_info; - - }else{ - - DATA_PAIR full_info=std::make_pair(aBank->size(), aBank->data()); - m_fullData2Decode[(aBank->sourceID())]=full_info; - - } - - }else{ - - // put all the nzs data in one container - DATA_PAIR full_info=std::make_pair(aBank->size(), aBank->data()); - m_fullData2Decode[(aBank->sourceID())]=full_info; - - } - - } - - } - - // check if there is pedestal bank present - const std::vector<LHCb::RawBank*>& pedBanks= - m_rawEvent->banks(LHCb::RawBank::VeloPedestal); - // if so get informations about it - - if(pedBanks.size()!=0){ - - setPedBankFlag(); - m_veloPedestals=new VeloFullBanks(); - // - - if(m_isDebug) debug()<< "VeloPed bank detected of size: " - << pedBanks.size() <<endmsg; - - for(bIt=pedBanks.begin(); bIt!=pedBanks.end(); bIt++){ - - LHCb::RawBank* aBank=(*bIt); - DATA_PAIR ped_info; - ped_info=std::make_pair(aBank->size(), aBank->data()); - m_pedestalData2Decode[aBank->sourceID()]=ped_info; - - } - - } - - // check if there is ODIN bank present - const std::vector<LHCb::RawBank*>& odinBank= - m_rawEvent->banks(LHCb::RawBank::ODIN); - // cache the bank if present - - if(odinBank.empty()){ - - if(m_runWithODIN){ - - Error(" ==> ODIN bank missing!"); - return ( StatusCode::FAILURE ); - - } - - } - - // - if(fullBanks.empty()){ - - m_veloADCData=new VeloFullBanks(); - m_veloADCPartialData=new VeloFullBanks(); - unsigned int msgCount=0; - if(m_isDebug) msgCount=10; - Warning(" --> There are no NZS banks!", StatusCode::SUCCESS, msgCount).ignore(); - - } - // - return ( StatusCode::SUCCESS ); -} -//============================================================================= -// /// ///////////////////////////////////////////////////////////////// /// // -// if there are both banks type order the data and create new data object // -// and pass it to the next stage of the processing // -// /// ///////////////////////////////////////////////////////////////// /// // -void PrepareVeloFullRawBuffer::createOrderedSections() -{ - if(m_isDebug) debug()<< " ==> createOrderedSection() " <<endmsg; - // - if(adcBankFlag()){ - - int type_1=LHCb::RawBank::VeloFull; - DR_IT full_IT=m_fullData2Decode.begin(); - - for( ; full_IT!=m_fullData2Decode.end(); ++full_IT) - { - - VeloFullBank* aBank=new VeloFullBank((*full_IT).first, - (*full_IT).second.second, type_1); - m_veloADCData->insert(aBank); - - } - - DR_IT part_IT=m_partialData2Decode.begin(); - - for( ; part_IT!=m_partialData2Decode.end(); ++part_IT) - { - - if(WORD2BYTE*FPGAx4==(*part_IT).second.first) - { - //if (m_isDebug) debug()<< " --> Will write partial data! " <<endmsg; - //if (m_isDebug) debug()<< " --> source id: " << ((*part_IT).first) <<endmsg; - info()<< " --> Will write partial data! " <<endmsg; - info()<< " --> source id: " << ((*part_IT).first) <<endmsg; - - VeloFullBank* aBank=new VeloFullBank((*part_IT).first, - (*part_IT).second.second, type_1); - m_veloADCPartialData->insert(aBank); - - }else{ - - // --> partial data decoding using information form the associated EB - - } - - } - - } - // - if(pedBankFlag()){ - - int type_2=LHCb::RawBank::VeloPedestal; - DR_IT ped_IT=m_pedestalData2Decode.begin(); - - for( ; ped_IT!=m_pedestalData2Decode.end(); ++ped_IT) - { - - VeloFullBank* aBank=new VeloFullBank((*ped_IT).first, - (*ped_IT).second.second, type_2); - m_veloPedestals->insert(aBank); - - } - - } - -} -//============================================================================= -StatusCode PrepareVeloFullRawBuffer::writeVeloFull() -{ - if(m_isDebug) debug()<< " ==> writeVeloFull() " <<endmsg; - // - - if(adcBankFlag()||m_roundRobin){ - - if(m_isDebug) debug()<< "Registered container with bank data of size: " - << m_veloADCData->size() << ", at" - << m_veloADCDataLoc <<endmsg; - - put(m_veloADCData, m_veloADCDataLoc); - put(m_veloADCPartialData, m_veloADCPartialDataLoc); - - } - // - - if(pedBankFlag()){ - - if(m_isDebug) debug()<< "Registered container with bank data of size: " - << m_veloPedestals->size() << ", at" - << m_veloPedestalsLoc <<endmsg; - - put(m_veloPedestals, m_veloPedestalsLoc); - - } - // - return ( StatusCode::SUCCESS ); -} -//============================================================================= -void PrepareVeloFullRawBuffer::resetMemory() -{ - if(m_isDebug) debug()<< " ==> resetMemory() " <<endmsg; - // - m_fullData2Decode.clear(); - m_partialData2Decode.clear(); - m_pedestalData2Decode.clear(); - m_errorBanks2Check.clear(); - - if(adcBankFlag()) unsetADCBankFlag(); - if(pedBankFlag()) unsetPedBankFlag(); -} -//============================================================================= -// Note only for use in emergency debugging (not referenced in code presently) -void PrepareVeloFullRawBuffer::dumpADCs(const dataVec& inADCs) -{ - info()<< " Dumping ADC values for all channels (1 TELL1)" <<endmsg; - // - cdatIt adcIt; - int ii=0; - for(adcIt=inADCs.begin(); adcIt!=inADCs.end(); adcIt++, ii++){ - if(!(ii%32)){ - info()<< " Beggining dumping ALink number: " << ii/32 <<endmsg; - } - // - info() << "[Beetle, Channel] = " << "[" << ii/128 << ", " - << ii%32 << "]" << (*adcIt) <<std::endl; - } -} -//============================================================================= -void PrepareVeloFullRawBuffer::setADCBankFlag() -{ - m_adcBankPresent=true; -} -//============================================================================= -void PrepareVeloFullRawBuffer::unsetADCBankFlag() -{ - m_adcBankPresent=false; -} -//============================================================================= -void PrepareVeloFullRawBuffer::setPedBankFlag() -{ - m_pedBankPresent=true; -} -//============================================================================= -void PrepareVeloFullRawBuffer::unsetPedBankFlag() -{ - m_pedBankPresent=false; -} -//============================================================================= -bool PrepareVeloFullRawBuffer::adcBankFlag() -{ - return ( m_adcBankPresent ); -} -//============================================================================= -bool PrepareVeloFullRawBuffer::pedBankFlag() -{ - return ( m_pedBankPresent ); -} -//============================================================================= diff --git a/Velo/VeloDAQ/src/PrepareVeloFullRawBuffer.h b/Velo/VeloDAQ/src/PrepareVeloFullRawBuffer.h deleted file mode 100644 index 7bc1c7deaa91ab34c237242f1739d3f8ae0e829f..0000000000000000000000000000000000000000 --- a/Velo/VeloDAQ/src/PrepareVeloFullRawBuffer.h +++ /dev/null @@ -1,148 +0,0 @@ -#ifndef PREPAREVELOFULLRAWBUFFER_H -#define PREPAREVELOFULLRAWBUFFER_H 1 - -// Include files -// from Gaudi -#include "GaudiAlg/GaudiTupleAlg.h" - -// STL -#include <vector> -#include <map> -#include <utility> - -// data model -#include "Kernel/VeloChannelID.h" -#include "Tell1Kernel/VeloDecodeCore.h" -#include "Tell1Kernel/VeloDecodeConf.h" -#include "Tell1Kernel/VeloTell1Core.h" -#include "VeloEvent/VeloFullBank.h" - -#include "Event/RawBank.h" - -/** @class PrepareVeloFullRawBuffer PrepareVeloFullRawBuffer.h - * - * - * @author Tomasz Szumlak - * @date 2006-03-22 - * - * Algorithm dedicated to decoding the new 1MHz non-zero suppresed - * RawBank which is sent out by TELL1 pre-processing board. - * The input for the algorithm is binary file and the output - * is container with VeloDigits objects. - * The container is the input for the TELL1 - * algorithms (pedestal subtraction and following, FIR filter nad - * linear CM subtraction) - */ - -namespace LHCb -{ - class RawEvent; -} - -using namespace VeloTELL1; -using namespace LHCb; - -class PrepareVeloFullRawBuffer : public GaudiTupleAlg { -public: - - typedef std::map<unsigned int, std::pair<unsigned int, unsigned int* > > DATA_REPO; - - enum parameters{ - ERROR_HEADER_1=1, - ERROR_HEADER_2=2, - ERROR_SECOND_SECTION=3, - ADCHeadersShift=4, - ERROR_FIRST_SECTION=5, - ERROR_EVT_INFO=8, - ODIN_DATA_WORDS=9, - ERROR_THIRD_SECTION=10, - ALinkShift=36 - }; - enum bitMasks{ - ADCMask=0x000003ff - }; - - enum bitShifts{ - ADCShift=10 - }; - - enum BANKS_SIZES{ - WORD2BYTE=4, - EB_FPGAx1=6, - COMPLETE_EB=52, - FPGAx1=224, - FPGAx4=896 - }; - - // - /// Standard constructor - PrepareVeloFullRawBuffer( const std::string& name, ISvcLocator* pSvcLocator ); - - virtual ~PrepareVeloFullRawBuffer( ); ///< Destructor - - StatusCode initialize() override; ///< Algorithm initialization - StatusCode execute () override; ///< Algorithm execution - - // fetch the RawEvent - StatusCode getRawEvent(); - // extract vector of the RawBanks of the type VeloFull (non-zero supp.) - StatusCode getRawBanks(); - void createOrderedSections(); - // write-out the Gaudi model of the RawBank (with digit objects, - // header infos and Beetle headers) - StatusCode writeVeloFull(); - // run after decoding each event - void resetMemory(); - // use only as emergency checker! - void dumpADCs(const dataVec& inADCs); - -protected: - - void setADCBankFlag(); - void setPedBankFlag(); - void unsetADCBankFlag(); - void unsetPedBankFlag(); - bool adcBankFlag(); - bool pedBankFlag(); - void setDecodeWithErrorBank(); - bool getDecodeWithErrorBank() const; - -private: - - LHCb::RawEvent* m_rawEvent; /// pointer to RawEvent container - std::string m_rawEventLoc; /// location of RawEvent container - DATA_REPO m_fullData2Decode; /// source id and ptr to the bank body - full - DATA_REPO m_partialData2Decode; /// source id and ptr to the bank body - partial - DATA_REPO m_pedestalData2Decode; /// src id and ptr to the bank body - pedestals - DATA_REPO m_errorBanks2Check; /// the same for the error banks - VeloFullBanks* m_veloADCData; /// container to store ordered data - VeloFullBanks* m_veloADCPartialData; - VeloFullBanks* m_veloPedestals; /// container to store ordered pedestals - std::string m_veloADCDataLoc; /// TES locations of decoded data - std::string m_veloPedestalsLoc; - std::string m_veloADCPartialDataLoc; - bool m_adcBankPresent; /// flag to check if data is sent out - bool m_pedBankPresent; /// flag to check if ped is sent out - bool m_runWithODIN; - bool m_isDebug; - bool m_roundRobin; - bool m_ignoreErrorBanks; - -}; -#endif // DECODEVELOFULLRAWBUFFER_H - -struct errorBankFinder{ - - errorBankFinder(unsigned int tell1): - currentTell1 (tell1) - { } - - bool operator()(LHCb::RawBank* aBank) const{ - return (aBank->sourceID())==static_cast<int>(currentTell1); - } - -private: - - unsigned int currentTell1; - -}; diff --git a/Velo/VeloDAQ/src/PrepareVeloRawBuffer.cpp b/Velo/VeloDAQ/src/PrepareVeloRawBuffer.cpp deleted file mode 100644 index 112257686d40a15407c64fdc54bab7908ea077f3..0000000000000000000000000000000000000000 --- a/Velo/VeloDAQ/src/PrepareVeloRawBuffer.cpp +++ /dev/null @@ -1,477 +0,0 @@ -#include "Event/RawEvent.h" -#include "VeloEvent/InternalVeloCluster.h" - -#include "VeloDet/DeVelo.h" - -#include "SiDAQ/SiHeaderWord.h" -#include "SiDAQ/SiADCWord.h" -#include "SiDAQ/SiRawBufferWord.h" - -#include "VeloClusterWord.h" -#include "VeloRawBankVersions.h" -#include "VeloRawWordSizes.h" -#include "VeloClusterPtrLessThan.h" -#include "PrepareVeloRawBuffer.h" - - -//----------------------------------------------------------------------------- -// Implementation file for class : PrepareVeloRawBuffer -// -// 2003-04-11 : Olivier Callot -// 2004-04-13 : modified and moved to Velo area Chris Parkes -// 2004-11-03 : modified to GaudiAlg dependance -// 2006-02-15 : David Jones, Kurt Rinnert: complete rewrite for 1MHz raw buffer -//----------------------------------------------------------------------------- - -DECLARE_ALGORITHM_FACTORY( PrepareVeloRawBuffer ) - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -PrepareVeloRawBuffer::PrepareVeloRawBuffer( const std::string& name, - ISvcLocator* pSvcLocator) -: - GaudiAlgorithm (name , pSvcLocator) -{ - declareProperty("InternalVeloClusterLocation",m_clusterLoc=LHCb::InternalVeloClusterLocation::Default); - declareProperty("RawEventLocation",m_rawEventLoc=LHCb::RawEventLocation::Default); - declareProperty("DumpInputClusters",m_dumpInputClusters=false); - declareProperty("BankVersion", m_bankVersion=VeloDAQ::v3); -} - -//============================================================================= -// Destructor -//============================================================================= -PrepareVeloRawBuffer::~PrepareVeloRawBuffer() {} - -//============================================================================= -// Initialisation. Check parameters -//============================================================================= -StatusCode PrepareVeloRawBuffer::initialize() { - StatusCode sc = GaudiAlgorithm::initialize(); // must be executed first - if ( sc.isFailure() ) return sc; // error printed already by GaudiAlgorithm - - debug() << "==> Initialise" << endmsg; - - m_velo = getDet<DeVelo>( DeVeloLocation::Default ); - - // check whether the requested bank version is supported - switch (m_bankVersion) { - case VeloDAQ::v2: // ok, do nothing - case VeloDAQ::v3: - break; - default: // not supported, bail out - error() << "VELO raw buffer version " - << m_bankVersion - << " is not supported." - << endmsg; - return StatusCode::FAILURE; - } - - // get a list of sensor numbers to identify empty sensors - std::vector< DeVeloSensor* >::const_iterator sIter = m_velo->sensorsBegin(); - std::vector< DeVeloSensor* >::const_iterator sEnd = m_velo->sensorsEnd(); - for( ; sIter != sEnd ; ++sIter ){ - m_sensorNumbers.push_back((*sIter)->sensorNumber()); - } - std::sort( m_sensorNumbers.begin() , m_sensorNumbers.end() ); - - return StatusCode::SUCCESS; -} - -//============================================================================= -// Main execution -//============================================================================= -StatusCode PrepareVeloRawBuffer::execute() { - - bool isDebug = msgLevel( MSG::DEBUG ); - - - if (isDebug) debug() << "==> Execute" << endmsg; - - // Get the input container - // Get the InternalVeloClusters from their default location - const LHCb::InternalVeloClusters* clusters = getIfExists<LHCb::InternalVeloClusters>(m_clusterLoc); - if( NULL == clusters ){ - return Error( " ==> There are no InternalVeloClusters in TES! " ); - } - - m_sortedClusters.clear(); - m_sortedClusters.resize(clusters->size()); - std::copy(clusters->begin(),clusters->end(),m_sortedClusters.begin()); - - // Then sort the clusters by sensor number and local coordinate - std::sort( m_sortedClusters.begin(), m_sortedClusters.end(), - VeloDAQ::veloClusterPtrLessThan()); - - // dump input clusters to console, if requested - if (m_dumpInputClusters) dumpInputClusters(); - - - // see whether the raw event exits - LHCb::RawEvent* rawEvent = getIfExists<LHCb::RawEvent>(m_rawEventLoc); - if( NULL == rawEvent ) { - // raw rawEvent doesn't exist. We need to create it - rawEvent = new LHCb::RawEvent(); - put(rawEvent, m_rawEventLoc); - } - - - // loop over all clusters and write one bank per sensor - std::vector<const LHCb::InternalVeloCluster*>::const_iterator firstOnSensor, - lastOnSensor; - lastOnSensor = firstOnSensor = m_sortedClusters.begin(); - - int currentSensorNumber; - - int sensorIndex = -1; // index of current sensor in list - - while (firstOnSensor != m_sortedClusters.end()) { - - currentSensorNumber = (*firstOnSensor)->sensor(); - - sensorIndex++; // move to next on list of expected sensors - // check there was not a missing sensor - while( currentSensorNumber != m_sensorNumbers[sensorIndex] ){ - // store an empty bank - storeBank(m_sensorNumbers[sensorIndex],lastOnSensor, lastOnSensor, - rawEvent); - if (isDebug) debug() << "Added empty bank for sensor " - << m_sensorNumbers[sensorIndex] << endmsg; - sensorIndex++; // move to next on list, try again - } - - while (lastOnSensor != m_sortedClusters.end() && - (*lastOnSensor)->sensor() == currentSensorNumber) { - ++lastOnSensor; - } - - // make and store the bank - storeBank(currentSensorNumber, firstOnSensor, lastOnSensor, rawEvent); - - firstOnSensor = lastOnSensor; - } - // add any empty banks from final sessor in the list - sensorIndex++;// move to next on list of expected sensors - while(sensorIndex < static_cast<int>(m_sensorNumbers.size())){ - // store an empty bank - storeBank(m_sensorNumbers[sensorIndex],lastOnSensor, lastOnSensor, - rawEvent); - if (isDebug) debug() << "Added empty bank for sensor " - << m_sensorNumbers[sensorIndex] << endmsg; - sensorIndex++; // move to next on list, try again - } - - return StatusCode::SUCCESS; -} - -//============================================================================= - -void PrepareVeloRawBuffer::storeBank( - int sensor, - std::vector<const LHCb::InternalVeloCluster*>::const_iterator begin, - std::vector<const LHCb::InternalVeloCluster*>::const_iterator end, - LHCb::RawEvent* rawEvent) { - - // create new raw buffer in raw data cache, old one is cleared - makeBank(begin, end); - - // Sensor and TELL1 Id might be different, e.g in a test beam - // setup. Also it makes no sense to add a bank for a sensor that - // has not Tell1 Id. While this should never be attempted in the - // first place (if the geometry XML and CondDB is correct), it is - // still a good idea to protect against this scenario. - unsigned int sourceId; - if (m_velo->tell1IdBySensorNumber(sensor, sourceId)) { - - debug() << "Sensor = " << sensor << "Source ID = " << sourceId << endmsg; - - LHCb::RawBank* newBank = rawEvent-> - createBank(static_cast<SiDAQ::buffer_word>(sourceId), - LHCb::RawBank::Velo, - m_bankVersion, - m_bankSizeInBytes, - &(m_rawData[0])); - - // add new bank and pass memory ownership to raw event - rawEvent->adoptBank(newBank,true); - } else { - // we should not end up here if the geometry XMl and the - // CondDB sensor/Tell1 mapping is consistent - warning() - << "Plot to create bank for sensor " << sensor - << " with no TELL1 Id foiled." << endmsg; - } -} - -unsigned int PrepareVeloRawBuffer::makeBank ( - std::vector<const LHCb::InternalVeloCluster*>::const_iterator begin, - std::vector<const LHCb::InternalVeloCluster*>::const_iterator end) -{ - bool isVerbose = msgLevel( MSG::VERBOSE ); - - // clear bank - m_rawData.clear(); - - // work out number of clusters for this sensor uses 1st 16 bits - int numClu = end - begin; - - if(isVerbose) { - verbose() <<"Number of clusters:" << numClu <<endmsg; - } - - // pcn is next 8 bits: set to zero here (never any errors in sim) - SiHeaderWord hw(numClu,0,0); - SiDAQ::buffer_word pcnAndNumClu = hw.value(); - - // clear temporary buffers - m_clusterPosBuffer.clear(); - m_clusterADCBuffer.clear(); - - // for storing 32 bit 'rows' of adc values and cluster positions - SiDAQ::buffer_word rowData = 0x0; - SiDAQ::buffer_word cluRowData = 0x0; - - // loop over clusters in range defined by iterator - unsigned int nClu = 0; // cluster counter - unsigned int nAdc = 0; // ADC word counter, used to to determine - // number of padding bytes at end of raw bank - - std::vector<const LHCb::InternalVeloCluster*>::const_iterator iC = begin; - for ( ; iC != end ; ++iC) { - - const LHCb::InternalVeloCluster* clu = *iC; - - unsigned int numStrips = clu->size(); - bool highThresh = clu->hasHighThreshold(); - - if(isVerbose) { - verbose() <<"Reading cluster from sensor " - << clu->sensor() << " with " << - numStrips << " strips." <<endmsg; - } - - SiDAQ::buffer_word packedCluster; - - - if( numStrips == 1 ) { // single strip cluster - - double adcCount = clu->adcValue(0); - - if (adcCount > 127) { - adcCount = 127; - } - VeloClusterWord vcw(clu->strip(0),0.0,1, highThresh); - packedCluster = static_cast<SiDAQ::buffer_word>(vcw.value()); - if ( isVerbose ) { - verbose() <<"STRIP: " << clu->strip(0) - << ",ADC: " << clu->adcValue( 0) << endmsg; - } - - SiADCWord aw(adcCount,true); - rowData |= (aw.value() << ((nAdc % VeloDAQ::adc_per_buffer) - << VeloDAQ::adc_shift)); - - ++nAdc; - if (nAdc % VeloDAQ::adc_per_buffer == 0) { - m_clusterADCBuffer.push_back ( rowData ); - //reset rowData - rowData = 0x0; - } - - if ( isVerbose ) { - verbose() <<"strip " << clu->strip(0) - << ",adc= " << aw.value() << endmsg; - } - } else { - // multiple strip cluster - // calculate weighted average position of cluster - const std::vector< std::pair<long,double> >& stripSignals = - clu->stripSignals(); - double sumADC = 0.; - double sumADCWeightedeStrip = 0.; - - // loop over all strip signals - - unsigned int i = 0; - for (; i<stripSignals.size(); ++i) { - unsigned int stripNumber = stripSignals[i].first; - double adcCount = stripSignals[i].second; - if (adcCount > 127) { - adcCount = 127; - } - - if(isVerbose) { - verbose() << "ADC COUNT:" << adcCount << " STRIP:" << stripNumber - << endmsg; - } - - // sum adc values and adc weighted strip numbers - sumADC += adcCount; - sumADCWeightedeStrip += static_cast<double>(i) * adcCount; - // create new adc word - bool endOfCluster = (stripSignals.size() == i+1); - SiADCWord aw(adcCount,endOfCluster); - - rowData |= (aw.value() << - ((nAdc % VeloDAQ::adc_per_buffer) << VeloDAQ::adc_shift)); - - ++nAdc; - if (nAdc % VeloDAQ::adc_per_buffer == 0) { - m_clusterADCBuffer.push_back ( rowData ); - //reset rowData - rowData = 0x0; - } - - } - - double cPos = 0.0; - double interStripPos = 0.0; - unsigned int channelPos = 0; - - unsigned int stripNumber = stripSignals[0].first; - switch (m_bankVersion) { - case VeloDAQ::v2: - cPos = (sumADCWeightedeStrip/sumADC) ; // get weighted mean - channelPos = stripNumber+static_cast<unsigned int>(cPos); // without fractional par - interStripPos = cPos - static_cast<unsigned int>(cPos); // fractional part - break; - case VeloDAQ::v3: - // compute the weighted mean like it is done on the TELL1 - cPos = sumADCWeightedeStrip*static_cast<int>(65536./sumADC+0.5)/65536.; - channelPos = stripNumber+static_cast<int>(cPos+1/16.0); // without fractional part - interStripPos = cPos - static_cast<int>(cPos) + 1/16.0; // fractional part, will be rounded to nearest 1/8 - break; - } - - VeloClusterWord vcw(channelPos, interStripPos, numStrips, highThresh); - packedCluster = static_cast<SiDAQ::buffer_word>(vcw.value()); - - if(isVerbose) { - verbose() << "CPOS: " << cPos - << " CHPOS: " << channelPos - << " ISPOS: " << interStripPos - << " WORD: " << format( "%8X" , packedCluster ) - <<endmsg; - } - } - - // store the cluster position - cluRowData |= (packedCluster << ((nClu % VeloDAQ::clu_per_buffer) << VeloDAQ::clu_shift)); - ++nClu; - if ( nClu % VeloDAQ::clu_per_buffer == 0 ) { - m_clusterPosBuffer.push_back( cluRowData ); - // clear the cluster buffer - cluRowData = 0x0 ; - } - } - - // if there were an odd number of clusters, sort the last cluster row - if ( nClu % VeloDAQ::clu_per_buffer != 0 ) { - m_clusterPosBuffer.push_back ( cluRowData ); - } - // check row data is not empty, store remaining adcs - if ( nAdc % VeloDAQ::adc_per_buffer != 0 ) { - m_clusterADCBuffer.push_back ( rowData ); - } - - // write to buffer or return ? - - if ( isVerbose ) { - verbose()<< "Raw output of cluster start" <<endmsg; - verbose()<< "PCN error flag and number of clusters[" << format( "%10X" , pcnAndNumClu ) - << "]"<<endmsg; - } - - // add PCN and R - m_rawData.push_back ( pcnAndNumClu ); - - // add clusters positions - std::vector<SiDAQ::buffer_word>::iterator tmpCp = m_clusterPosBuffer.begin(); - for ( ; tmpCp != m_clusterPosBuffer.end() ; ++tmpCp ) { - if ( isVerbose ) { - - verbose()<< "Cluster position[" << format( "%10X" , *tmpCp ) << "]"<<endmsg; - } - - m_rawData.push_back ( *tmpCp ) ; - } - - // add adc values - std::vector<SiDAQ::buffer_word>::iterator tmpAdc = m_clusterADCBuffer.begin(); - for ( ; tmpAdc != m_clusterADCBuffer.end() ; ++tmpAdc ) { - if ( isVerbose ) { - - verbose()<< "Adc row[" << format( "%10X" , *tmpAdc ) << "]"<<endmsg; - } - - m_rawData.push_back ( *tmpAdc ) ; - } - - // Find number of padding bytes at the end of bank an compute - // raw bank size in bytes, including the 4 byte header but - // *without* the padding bytes at the end. - // The number of padding bytes is completely determined by - // the number of ADC words in the raw bank. - int adcRemainder = nAdc%VeloDAQ::adc_per_buffer; - m_bankSizeInBytes = sizeof(SiDAQ::buffer_word)*m_rawData.size() - - (adcRemainder ? sizeof(SiDAQ::buffer_word)-adcRemainder*VeloDAQ::adc_word_size : 0); - - if ( isVerbose) { - verbose()<< "Raw output of cluster end" <<endmsg; - } - - return nClu; -} - -void PrepareVeloRawBuffer::dumpInputClusters() const -{ - for (std::vector<const LHCb::InternalVeloCluster*>::const_iterator ci = m_sortedClusters.begin(); - ci != m_sortedClusters.end(); - ++ci) { - - const LHCb::InternalVeloCluster* clu = *ci; - - unsigned int sensorNumber = clu->sensor(); - - unsigned int centroidStrip = clu->strip(0); - double channelPos = centroidStrip; - - // ensure 7 bit cut off for adc values - std::vector<double> adcValues; - for (int adci=0; adci<clu->size(); ++adci) { - adcValues.push_back((clu->adcValue(adci) > 127 ? 127 : clu->adcValue(adci))); - } - - if (clu->size() > 1) { - double sumAdc = 0.0; - double offset = 0; - for (int strip = 0; strip < clu->size(); ++strip) { - offset += strip*adcValues[strip]; - sumAdc += adcValues[strip]; - } - channelPos += offset/sumAdc; - centroidStrip = static_cast<unsigned int>(channelPos); - } - - // interstrip position in 1/8 of strip pitch (as it is encoded in raw bank) - double interStripPos = static_cast<unsigned int>((channelPos-centroidStrip)*8.0)/8.0; - - info() << "ENC::POSDUMP:" - << " SN=" << sensorNumber - << " CS=" << centroidStrip - << " ISP=" << interStripPos - << endmsg; - - info() << "ENC::ADCDUMP:" - << " SN=" << sensorNumber; - - for (int adci=0; adci<clu->size(); ++adci) { - info() << " " << adcValues[adci] - << "@" << clu->strip(adci); - } - info() << endmsg; - - } - return; -} diff --git a/Velo/VeloDAQ/src/PrepareVeloRawBuffer.h b/Velo/VeloDAQ/src/PrepareVeloRawBuffer.h deleted file mode 100644 index 063f71dd6a93ef3fa151fb30dbe7f252aca9d8fc..0000000000000000000000000000000000000000 --- a/Velo/VeloDAQ/src/PrepareVeloRawBuffer.h +++ /dev/null @@ -1,84 +0,0 @@ -#ifndef PREPAREVELORAWBUFFER_H -#define PREPAREVELORAWBUFFER_H 1 - -#include <vector> -#include <algorithm> -#include <string> - -#include "VeloEvent/InternalVeloCluster.h" - -#include "GaudiAlg/GaudiAlgorithm.h" - -class DeVelo; -namespace LHCb { - class RawEvent; -} - -/** @class PrepareVeloRawBuffer PrepareVeloRawBuffer.h - * Prepare the cluster container from 1MHz raw buffer. - * Completely rewritten for the new 1MHz raw buffer. - * - * @author David Jones - * @author Kurt Rinnert - * @author Olivier Callot - * @date 2003-04-11 - * 2004-04-13 : modified and moved to Velo area Chris Parkes - * 2004-11-04 : modified to use new GaudiAlgorithm by David Hutchcroft - * 2006-02-15 : completely rewritten for 1MHz raw buffer, Kurt Rinnert, David Jones - */ -class PrepareVeloRawBuffer : public GaudiAlgorithm { - -public: - /// Standard constructor - PrepareVeloRawBuffer( const std::string& name, ISvcLocator* pSvcLocator ); - - virtual ~PrepareVeloRawBuffer( ); ///< Destructor - - StatusCode initialize() override; ///< Algorithm initialization - StatusCode execute () override; ///< Algorithm execution - -private: - - void dumpInputClusters() const; - - unsigned int -makeBank (std::vector<const LHCb::InternalVeloCluster*>::const_iterator begin, - std::vector<const LHCb::InternalVeloCluster*>::const_iterator end); - - -void -storeBank(int sensor, - std::vector<const LHCb::InternalVeloCluster*>::const_iterator begin, - std::vector<const LHCb::InternalVeloCluster*>::const_iterator end, - LHCb::RawEvent* rawEvent); -private: - - // configurable locations in the TES - std::string m_clusterLoc; - std::string m_rawEventLoc; - - // configurable cluster dump flag - bool m_dumpInputClusters; - - /// version tag - unsigned int m_bankVersion; - - // long lived containers for performance reasons. Also used to communicate - // with makeBank() method - std::vector<const LHCb::InternalVeloCluster*> m_sortedClusters; - std::vector<SiDAQ::buffer_word> m_rawData; - std::vector<SiDAQ::buffer_word> m_clusterADCBuffer; - std::vector<SiDAQ::buffer_word> m_clusterPosBuffer; - - // size of raw bank in bytes, inclding the 4 byte header but - // *without* the padding bytes at the end - unsigned int m_bankSizeInBytes = 0; - - /// pointer to Velo Detector Element - DeVelo* m_velo = nullptr; - - /// list of sensor numbers to check for empty sensors - std::vector<int> m_sensorNumbers; - -}; -#endif // PREPAREVELORAWBUFFER_H diff --git a/Velo/VeloDAQ/src/SmartVeloErrorBankDecoder.cpp b/Velo/VeloDAQ/src/SmartVeloErrorBankDecoder.cpp deleted file mode 100644 index bce55f64ccab8c050adf114da6cb34f7cba9c0d8..0000000000000000000000000000000000000000 --- a/Velo/VeloDAQ/src/SmartVeloErrorBankDecoder.cpp +++ /dev/null @@ -1,303 +0,0 @@ -// Include files -// local -#include "SmartVeloErrorBankDecoder.h" - -//----------------------------------------------------------------------------- -// Implementation file for class : SmartVeloErrorBankDecoder -// -// 2008-08-24 : Tomasz Szumlak -//----------------------------------------------------------------------------- - -// Declaration of the Algorithm Factory -DECLARE_ALGORITHM_FACTORY( SmartVeloErrorBankDecoder ) - -using namespace VeloTELL1; - -typedef unsigned int* ErrorBankIT; -typedef std::pair<ErrorBankIT, ErrorBankIT> ITPair; -typedef std::map<unsigned int, ITPair> BANKS; -typedef std::map<unsigned int, ITPair> SECTORS; - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -SmartVeloErrorBankDecoder::SmartVeloErrorBankDecoder( const std::string& name, - ISvcLocator* pSvcLocator) - : GaudiAlgorithm ( name , pSvcLocator ), - m_isDebug ( false ), - m_rawEvent ( 0 ), - m_errorBank ( 0 ), - m_bankLength ( ), - m_bankVersion ( 0 ), - m_bankType ( 0 ), - m_magicPattern ( 0 ) -{ - declareProperty("PrintBankHeader", m_printBankHeader=0); - declareProperty( "RawEventLocation", m_rawEventLocation = "", - "OBSOLETE. Use RawEventLocations instead" ); - declareProperty( "RawEventLocations", m_rawEventLocations, - "List of possible locations of the RawEvent object in the" - " transient store. By default it is LHCb::RawEventLocation::Other," - " LHCb::RawEventLocation::Default."); - declareProperty("ErrorBankLocation", - m_errorBankLoc=VeloErrorBankLocation::Default); -} -//============================================================================= -// Destructor -//============================================================================= -SmartVeloErrorBankDecoder::~SmartVeloErrorBankDecoder() {} - -//============================================================================= -// Initialization -//============================================================================= -StatusCode SmartVeloErrorBankDecoder::initialize() { - StatusCode sc = GaudiAlgorithm::initialize(); // must be executed first - if ( sc.isFailure() ) return sc; // error printed already by GaudiAlgorithm - - m_isDebug=msgLevel(MSG::DEBUG); - if(m_isDebug) debug() << "==> Initialize" << endmsg; - - // Initialise the RawEvent locations - bool usingDefaultLocation = m_rawEventLocations.empty() && m_rawEventLocation.empty(); - if (! m_rawEventLocation.empty()) { - warning() << "The RawEventLocation property is obsolete, use RawEventLocations instead" << endmsg; - m_rawEventLocations.insert(m_rawEventLocations.begin(), m_rawEventLocation); - } - - if (std::find(m_rawEventLocations.begin(), m_rawEventLocations.end(), LHCb::RawEventLocation::Default) - == m_rawEventLocations.end()) { - // append the defaults to the search path - m_rawEventLocations.push_back(LHCb::RawEventLocation::Other); - m_rawEventLocations.push_back(LHCb::RawEventLocation::Default); - } - - if (!usingDefaultLocation) { - info() << "Using '" << m_rawEventLocations << "' as search path for the RawEvent object" << endmsg; - } - - return StatusCode::SUCCESS; -} - -//============================================================================= -// Main execution -//============================================================================= -StatusCode SmartVeloErrorBankDecoder::execute() { - - if(m_isDebug) debug() << "==> Execute" << endmsg; - // - StatusCode rawEvtStatus=getRawEvent(); - StatusCode bankStatus; - if(rawEvtStatus.isSuccess()) bankStatus=cacheErrorRawBanks(); - if(bankStatus.isSuccess()){ - bankStatus=storeErrorRawBanks(); - }else{ - // go to the next event - bankStatus=StatusCode::SUCCESS; - } - - if ( ! bankStatus.isSuccess() ) { - warning() << "storing error banks aborted (possible raw bank corruption)." << endmsg; - bankStatus=StatusCode::SUCCESS; - } - // - return ( bankStatus ); -} - -//============================================================================= -StatusCode SmartVeloErrorBankDecoder::getRawEvent() -{ - if(m_isDebug) debug()<< " ==> getRawEvent() " <<endmsg; - if(m_isDebug) debug()<< "--------------------" <<endmsg; - // - - // Retrieve the RawEvent: - m_rawEvent = NULL; - for (std::vector<std::string>::const_iterator p = m_rawEventLocations.begin(); p != m_rawEventLocations.end(); ++p) { - m_rawEvent = getIfExists<LHCb::RawEvent>(*p); - if ( NULL != m_rawEvent ){ - if(m_isDebug) - debug()<< " ==> The RawEvent has been read-in from location: " - << (*p) <<endmsg; - break; - } - } - - if( m_rawEvent == NULL ) { - error() << " ==> There is no RawEvent at: " - << m_rawEventLocations <<endmsg; - return ( StatusCode::FAILURE ); - } - - // - return ( StatusCode::SUCCESS ); -} -//============================================================================= -StatusCode SmartVeloErrorBankDecoder::cacheErrorRawBanks() -{ - if(m_isDebug) debug()<< " ==> cacheErrorRawBanks() " <<endmsg; - // check if there is error bank present - m_cachedBanks.clear(); - m_bankLength.clear(); - const std::vector<LHCb::RawBank*>& errorBank= - m_rawEvent->banks(LHCb::RawBank::VeloError); - std::vector<LHCb::RawBank*>::const_iterator bIt; - // if so write out the banks - if(errorBank.size()!=0){ - m_errorBank=new VeloErrorBanks(); - // - if(m_isDebug) debug()<< " --> Error bank detected of size: " << errorBank.size() <<endmsg; - ITPair data; - for(bIt=errorBank.begin(); bIt!=errorBank.end(); ++bIt){ - LHCb::RawBank* aBank=(*bIt); - - // --> protect against corrupted banks - if(LHCb::RawBank::MagicPattern!=aBank->magic()) return ( StatusCode::FAILURE ); - - // get the sensor number == sourceID if there is no full data - unsigned int tell1=aBank->sourceID(); - m_bankLength[tell1]=aBank->size(); - m_bankVersion=aBank->version(); - m_bankType=aBank->type(); - m_magicPattern=aBank->magic(); - if(m_printBankHeader){ - info()<< " --> src Id: " << tell1 <<endmsg; - info()<< " --> type of bank: " << (aBank->typeName()) <<endmsg; - info()<< " --> bank header size: " << (aBank->hdrSize()) <<endmsg; - info()<< " --> body size: " << (aBank->size()) <<endmsg; - info()<< " --> total size: " << (aBank->totalSize()) <<endmsg; - } - // get pointer to the bank data - data.first=aBank->begin<unsigned int>(); - unsigned int* inIT=aBank->begin<unsigned int>(); - unsigned int* dat=aBank->data(); - if(m_isDebug) debug()<< " --> src Id: " << tell1 <<endmsg; - for(int step=0; step<6; ++step){ - if(m_isDebug) debug()<< " data ptr: " << step << " : " << (*(inIT+step)) <<endmsg; - if(m_isDebug) debug()<< " data tab: " << step << " : " << (*(dat+step)) <<endmsg; - } - data.second=aBank->end<unsigned int>(); - m_cachedBanks[tell1]=data; - int dist=std::distance(data.first, data.second); - if(m_isDebug) debug()<< " --> bank body size: " << (dist*sizeof(unsigned int)) <<endmsg; - } - }else{ - Info(" --> No error bank detected - skipping to the next event "); - return ( StatusCode::FAILURE ); - } - if(m_isDebug) debug()<< " --> cached error bank strucure's size:" - << (m_cachedBanks.size()) <<endmsg; - return ( StatusCode::SUCCESS ); -} -//============================================================================= -StatusCode SmartVeloErrorBankDecoder::storeErrorRawBanks() -{ - if(m_isDebug) debug()<< " ==> storeErrorRawBanks() " <<endmsg; - // - std::map<unsigned int, ITPair>::iterator bankIT; - bankIT=m_cachedBanks.begin(); - for( ; bankIT!=m_cachedBanks.end(); ++bankIT){ - EvtInfo anEvtInfo(bankIT->first); - allEvt evtInfoData; - allError errorInfoData; - dataVec sources; - // get information on error sources - SECTORS sectors=errorDetector(bankIT->first); - if(sectors.size()!=SOURCES) { - if(m_isDebug) debug()<< " --> Error detected for " << (sectors.size()) - << " PPFPGA(s) "<<endmsg; - warning() << "Impossible number of PPFPGAs: " << sectors.size() << endmsg; - return StatusCode::FAILURE; - } - - VeloErrorBank* err=new VeloErrorBank(bankIT->first); - - // store words in error bank - SECTORS::iterator secIT=sectors.begin(); - for( ; secIT!=sectors.end(); ++secIT){ - // write fixed words - errorInfo anErrorInfo; - ErrorBankIT begin=secIT->second.first-INIT_SHIFT; - ErrorBankIT end=(secIT->second.first+1); - for( ; begin!=end; ++begin){ - anErrorInfo.push_back(*begin); - } - if(secIT->second.second==0){ - anErrorInfo.push_back(*end); - anErrorInfo.push_back(*(++end)); - } - errorInfoData.push_back(anErrorInfo); - // write optional part - evtInfo anInfo; - if(secIT->second.second!=0){ - // error was sent for this fpga build evt info section - // encode properly the evt section block - sources.push_back(secIT->first); - ErrorBankIT begin=secIT->second.first-INIT_SHIFT; - anInfo.push_back(*begin); - anInfo.push_back(*(++begin)); - unsigned int word=(*(++begin)); - word=(word>>bitShift16)&bitMask16; - anInfo.push_back(word); - begin=secIT->second.second; - ErrorBankIT end=begin+EVT_WORDS; - for( ; begin!=end; ++begin){ - anInfo.push_back(*begin); - } - } - evtInfoData.push_back(anInfo); - } - anEvtInfo.setEvtInfo(evtInfoData); - err->setEvtInfoSection(anEvtInfo); - err->setErrorInfoSection(errorInfoData); - if(m_isDebug) debug()<< " bank lenght: " << m_bankLength[bankIT->first] - << " for tell1: " << (bankIT->first) <<endmsg; - err->setBankLength(m_bankLength[bankIT->first]); - err->setBankType(m_bankType); - err->setBankVersion(m_bankVersion); - err->setMagicPattern(m_magicPattern); - if(m_isDebug) debug()<< " --> Detected errors: " << (sources.size()) <<endmsg; - err->setErrorSources(sources); - m_errorBank->insert(err); - } - // - put(m_errorBank, m_errorBankLoc); - // - return ( StatusCode::SUCCESS ); -} -//============================================================================= -std::map<unsigned int, ITPair> SmartVeloErrorBankDecoder::errorDetector( - unsigned int tell1) -{ - if(m_isDebug) debug()<< " ==> errorDetector() " <<endmsg; - // - unsigned int fpga=0; - SECTORS sectors; - BANKS::const_iterator bankIT; - bankIT=m_cachedBanks.find(tell1); - if(bankIT!=m_cachedBanks.end()){ - ITPair iTPair=bankIT->second; - ErrorBankIT iT=iTPair.first; - // we can skip first four words - see note EDMS 694818 - iT+=INIT_SHIFT; - // check if the file has expected format - ITPair aPair(0, 0); - for( ; iT!=iTPair.second; ++iT){ - if(((*iT&bitMask8)==EBMarker0)&&(((*iT>>bitShift8)&bitMask8)==EBMarker)){ - // cache this iterator - aPair.first=iT; - if(((*iT>>bitShift16)&bitMask16)==ERROR_BANK_SIZE){ - // cache iterator to the first word - aPair.second=(iT+1); - }else{ - // store nothing - aPair.second=0; - } - sectors[fpga]=aPair; - ++fpga; - } - } - } - // - return ( sectors ); -} -//-- diff --git a/Velo/VeloDAQ/src/SmartVeloErrorBankDecoder.h b/Velo/VeloDAQ/src/SmartVeloErrorBankDecoder.h deleted file mode 100644 index 99702a03d3f989b50cacf43988ff1451b850bb6c..0000000000000000000000000000000000000000 --- a/Velo/VeloDAQ/src/SmartVeloErrorBankDecoder.h +++ /dev/null @@ -1,90 +0,0 @@ -#ifndef SMARTVELOERRORBANKDECODER_H -#define SMARTVELOERRORBANKDECODER_H 1 - -// Include files -// from Gaudi -#include "GaudiAlg/GaudiAlgorithm.h" - -// data model -#include "Event/RawEvent.h" -#include "Event/RawBank.h" - -#include "Tell1Kernel/VeloDecodeCore.h" -#include "Tell1Kernel/VeloDecodeConf.h" -#include "Tell1Kernel/VeloTell1Core.h" -#include "VeloEvent/VeloErrorBank.h" - -// stl -#include <vector> -#include <algorithm> -#include <iterator> - -/** @class SmartVeloErrorBankDecoder SmartVeloErrorBankDecoder.h - * - * - * @author Tomasz Szumlak - * @date 2008-08-22 - */ - -class SmartVeloErrorBankDecoder : public GaudiAlgorithm { -public: - - /// iterator to the error bank body - typedef unsigned int* ErrorBankIT; - typedef std::pair<ErrorBankIT, ErrorBankIT> ITPair; - typedef std::map<unsigned int, ITPair> BANKS; - typedef std::map<unsigned int, ITPair> SECTORS; - - enum marks{ - INIT_SHIFT=4, - EVT_WORDS=5 - }; - - enum sectors{ - SOURCES=4, - HEADER=5, - ERROR_BANK_SIZE=20 - }; - - /// Standard constructor - SmartVeloErrorBankDecoder( const std::string& name, ISvcLocator* pSvcLocator ); - - virtual ~SmartVeloErrorBankDecoder( ); ///< Destructor - - StatusCode initialize() override; ///< Algorithm initialization - StatusCode execute () override; ///< Algorithm execution - -protected: - - // get the RawEvent - StatusCode getRawEvent(); - // extract error banks - StatusCode cacheErrorRawBanks(); - // count how many ppfpga sent errors - SECTORS errorDetector(unsigned int tell1); - // decode header and store evt info blocks - StatusCode storeErrorRawBanks(); - -private: - - bool m_isDebug; - LHCb::RawEvent* m_rawEvent; /// pointer to RawEvent container - - /// Location in the transient store of the RawEvent object. - /// @warning Obsolete: use m_rawEventLocations - std::string m_rawEventLocation; - - /// List of locations in the transient store to search the RawEvent object. - std::vector<std::string> m_rawEventLocations; - - VeloErrorBanks* m_errorBank; /// container to store error banks - std::string m_errorBankLoc; - int m_printBankHeader; - BANKS m_cachedBanks; - std::map<unsigned int, unsigned int> m_bankLength; - unsigned int m_bankVersion; - unsigned int m_bankType; - unsigned int m_magicPattern; - -}; -#endif // SMARTVELOERRORBANKDECODER_H diff --git a/Velo/VeloDAQ/src/VeloBitsPolicy.h b/Velo/VeloDAQ/src/VeloBitsPolicy.h deleted file mode 100644 index cf50e53a3f5ab87dd174d83d22105b9d454e1a42..0000000000000000000000000000000000000000 --- a/Velo/VeloDAQ/src/VeloBitsPolicy.h +++ /dev/null @@ -1,43 +0,0 @@ -// $Id: VeloBitsPolicy.h,v 1.3 2006-02-23 15:41:50 krinnert Exp $ -#ifndef VELOBITSPOLICY_H -#define VELOBITSPOLICY_H 1 - -#include "SiDAQ/SiADCBankTraits.h" - -/** Velo raw bank bit pattern - * - * This class is a type parameter for the SiClusterWord - * template class that allows to share bit-packing code - * with the ST software. - * The bit pattern is an implementation of the Velo raw - * bank specification in EDMS 637676, Version 2.0 as of - * December 1, 2005. - * - * @see SiClusterWord - * - * @author Kurt Rinnert - * @date 2006-02-02 - */ -class VeloBitsPolicy -{ -public: - - typedef SiDAQ::adc_only_bank_tag adc_bank_type; - - enum bits { - positionBits = 0, - channelBits = 3, - sizeBits = 14, - thresBits = 15, - interStripPrecision = 3 - }; - - enum mask { - positionMask = 0x0007, - channelMask = 0x3ff8, - sizeMask = 0x4000, - thresMask = 0x8000 - }; -}; - -#endif diff --git a/Velo/VeloDAQ/src/VeloClusterFilter.cpp b/Velo/VeloDAQ/src/VeloClusterFilter.cpp deleted file mode 100644 index 6b7bdec9c93e37f05266d7ae70aacc79b604d2b9..0000000000000000000000000000000000000000 --- a/Velo/VeloDAQ/src/VeloClusterFilter.cpp +++ /dev/null @@ -1,147 +0,0 @@ -// Include files -#include <iomanip> -// From Detector Element -#include "VeloDet/DeVelo.h" -#include "VeloDet/DeVeloSensor.h" - -// From Event -#include "Event/VeloLiteCluster.h" -#include "Event/VeloCluster.h" - -// local -#include "VeloClusterFilter.h" - -namespace { -void incrementCounters(LHCb::VeloChannelID id,int& countClusters,int& countRClusters,int& countPhiClusters) -{ - unsigned int sensorNumber = id.sensor(); - if(sensorNumber<64){ - ++countRClusters; - }else if(sensorNumber<128){ - ++countPhiClusters; - } - ++countClusters; -} -static const std::array<std::string,7> valid_criteria = - { "All","Left","Right","R","Phi","PU","Overlap" }; -} - -StatusCode parse(VeloClusterFilter::filter_t& result, const std::string& input) { - auto i = std::find( valid_criteria.begin(), valid_criteria.end(), input ); - if (i==valid_criteria.end()) return StatusCode::FAILURE; - result.criterion = static_cast<VeloClusterFilter::filter_t::criterion_t>(std::distance( valid_criteria.begin(), i )); - return StatusCode::SUCCESS; -} -std::ostream& toStream(const VeloClusterFilter::filter_t& crit, std::ostream& os) { - return os << std::quoted( crit.toString(), '\'' ); -} -const std::string& VeloClusterFilter::filter_t::toString() const { - return valid_criteria[static_cast<int>(criterion)]; -} -bool VeloClusterFilter::filter_t::operator()(LHCb::VeloChannelID id) const { - unsigned int sensorNumber = id.sensor(); - switch (criterion) { - case criterion_t::ALL : return true; - case criterion_t::LEFT : return sensorNumber%2==0; - case criterion_t::RIGHT : return sensorNumber%2==1; - case criterion_t::R : return sensorNumber<64; - case criterion_t::PHI : return sensorNumber>=64 && sensorNumber<128; - case criterion_t::PU : return sensorNumber>=128 ; - case criterion_t::OVERLAP : { - unsigned int stripNumber = id.strip(); - if (id.isRType() || id.isPileUp()) { - return stripNumber<512 || stripNumber>=1536; - } - if (id.isPhiType()) { - const unsigned int range=25; - return (stripNumber<range) || - (stripNumber>=2048-range && stripNumber<2048) || - (stripNumber>= 683-range && stripNumber<683+range); - } - return false; - } - default : - assert(false); // unreachable... - return false; - } -} - - -// Declaration of the Algorithm Factory -DECLARE_ALGORITHM_FACTORY( VeloClusterFilter ) - -//============================================================================= -// Initialization -//============================================================================= -StatusCode VeloClusterFilter::initialize() -{ - StatusCode sc = GaudiAlgorithm::initialize(); // must be executed first - if ( sc.isFailure() ) return sc; // error printed already by GaudiAlgorithm - debug() << "==> Initialize" << endmsg; - m_velo = getDet<DeVelo>( DeVeloLocation::Default ); - return StatusCode::SUCCESS; -} - -//============================================================================= -// Main execution -//============================================================================= -StatusCode VeloClusterFilter::execute() -{ - if(msgLevel(MSG::DEBUG)){ debug() << "==> Execute" << endmsg; } - - int countClusters=0; - int countRClusters=0; - int countPhiClusters=0; - int totalClusters=0; - - const auto* clusters = getIfExists<LHCb::VeloClusters>(m_inputClusterLocation); - const auto* liteClusters = getIfExists<LHCb::VeloLiteCluster::FastContainer>(m_inputLiteClusterLocation); - if( (!clusters) && (!liteClusters) ) { - return Warning( "No velo clusters or liteClusters on the TES !!!" ); - } - - if( clusters ){ - - auto filteredClusters = std::make_unique<LHCb::VeloClusters>(); - filteredClusters->reserve(clusters->size()); - - for (LHCb::VeloCluster* cluster : *clusters ) { - if (m_filter.value()(cluster->channelID())) { - filteredClusters->insert(cluster); - incrementCounters(cluster->channelID(),countClusters,countRClusters,countPhiClusters); - } - ++totalClusters; - } - put(filteredClusters.release(),m_outputClusterLocation); - } - - if( liteClusters ){ - - auto filteredLiteClusters = std::make_unique<LHCb::VeloLiteCluster::FastContainer>(); - filteredLiteClusters->reserve(liteClusters->size()); - - for (const auto& c : *liteClusters) { - if (m_filter.value()(c.channelID())){ - filteredLiteClusters->push_back(c); - incrementCounters(c.channelID(),countClusters,countRClusters,countPhiClusters); - } - ++totalClusters; - } - put(filteredLiteClusters.release(),m_outputLiteClusterLocation); - } - - if (msgLevel(MSG::DEBUG)) debug() << "Number of \'" << m_filter.value().toString() - << "\' clusters surviving = " << countClusters - << "(R:" << countRClusters - << " ,P:" << countPhiClusters << ")" - << " from " << totalClusters << "." << endmsg; - - if (countRClusters < m_minNRClustersCut ) setFilterPassed(false); - if (countPhiClusters < m_minNPhiClustersCut) setFilterPassed(false); - if (countClusters < m_minNClustersCut ) setFilterPassed(false); - if (countRClusters > m_maxNRClustersCut ) setFilterPassed(false); - if (countPhiClusters > m_maxNPhiClustersCut) setFilterPassed(false); - if (countClusters > m_maxNClustersCut ) setFilterPassed(false); - - return StatusCode::SUCCESS; -} diff --git a/Velo/VeloDAQ/src/VeloClusterFilter.h b/Velo/VeloDAQ/src/VeloClusterFilter.h deleted file mode 100644 index 48a681e325d0a196c4660201553c41c6e01e85b7..0000000000000000000000000000000000000000 --- a/Velo/VeloDAQ/src/VeloClusterFilter.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef VELOCLUSTERFILTER_H -#define VELOCLUSTERFILTER_H 1 - -#include "Kernel/VeloChannelID.h" -#include "GaudiAlg/GaudiAlgorithm.h" -#include <string> - -class DeVelo; - -///< A class to filter Velo clusters according to some defined criterion -///< Accepted filters are: -///< "Right" : retains only clusters in the Velo Right -///< "Left" : retains only clusters in the Velo Left -///< "R" : retains only clusters in R sensors -///< "Phi" : retains only clusters in Phi sensors -///< "PU" : retains only clusters in PU sensors - -class VeloClusterFilter : public GaudiAlgorithm { -public: - using GaudiAlgorithm::GaudiAlgorithm; - - StatusCode initialize() override; - StatusCode execute() override; - - struct filter_t final { - enum class criterion_t { ALL = 0, LEFT, RIGHT, R, PHI, PU, OVERLAP }; - criterion_t criterion; - - filter_t( criterion_t c = criterion_t::ALL ) : criterion(c) {} - bool operator()(LHCb::VeloChannelID id) const; - const std::string& toString() const; - // add support for Gaudi::Property<filter_t> - friend std::ostream& toStream(const filter_t& crit, std::ostream& os); - friend StatusCode parse(filter_t& result, const std::string& input ); - }; - -private: - Gaudi::Property<std::string> m_inputLiteClusterLocation{ this, "InputLiteClusterLocation", LHCb::VeloLiteClusterLocation::Default }; - Gaudi::Property<std::string> m_outputLiteClusterLocation{ this, "OutputLiteClusterLocation", "/Event/Raw/Velo/LiteClustersCopy" }; - Gaudi::Property<std::string> m_inputClusterLocation{ this, "InputClusterLocation", LHCb::VeloClusterLocation::Default }; - Gaudi::Property<std::string> m_outputClusterLocation{ this, "OutputClusterLocation", "/Event/Raw/Velo/ClustersCopy" }; - Gaudi::Property<filter_t> m_filter{ this, "FilterOption", filter_t::criterion_t::ALL }; - Gaudi::Property<int> m_minNRClustersCut{ this, "MinimumNumberOfRClusters",0 }; - Gaudi::Property<int> m_minNPhiClustersCut{ this, "MinimumNumberOfPhiClusters",0 }; - Gaudi::Property<int> m_minNClustersCut{ this, "MinimumNumberOfClusters",0 }; - Gaudi::Property<int> m_maxNRClustersCut{ this, "MaximumNumberOfRClusters",100000 }; - Gaudi::Property<int> m_maxNPhiClustersCut{ this, "MaximumNumberOfPhiClusters",100000 }; - Gaudi::Property<int> m_maxNClustersCut{ this, "MaximumNumberOfClusters",100000 }; - - DeVelo* m_velo = nullptr; ///< Detector element -}; -#endif // VELOCLUSTERFILTER_H diff --git a/Velo/VeloDAQ/src/VeloClusterPtrLessThan.h b/Velo/VeloDAQ/src/VeloClusterPtrLessThan.h deleted file mode 100644 index 80a5b11ae31ea8c21012efa4dc9fda49bd865d4d..0000000000000000000000000000000000000000 --- a/Velo/VeloDAQ/src/VeloClusterPtrLessThan.h +++ /dev/null @@ -1,51 +0,0 @@ -// $Id: -#ifndef VELODAQ_VELOCLUSTERPTRLESSTHAN_H -#define VELODAQ_VELOCLUSTERPTRLESSTHAN_H 1 - -#include "Event/VeloCluster.h" -#include "VeloEvent/InternalVeloCluster.h" - -namespace VeloDAQ { - /** Compare two VeloClusters or two InternalVeloClusters - * via pointers. - * - * This function defines a less-than relation between two - * clusters. The lhs cluster is less than the rhs cluster - * if the lhs sensor number is lower than the rhs sensor number. - * In case of equal sensor numbers, the first strip number - * decides. - * - * I'd very much prefer to template this. But that requires a - * change in the InternalVeloCluster interface. - * - * @see VeloCluster - * @see InternalVeloCluster - * @author Kurt Rinnert - * @date 2011-09-20 - */ - class veloClusterPtrLessThan { - - public: - - inline bool operator() (const LHCb::VeloCluster* lhs, const LHCb::VeloCluster* rhs) const; - - inline bool operator() (const LHCb::InternalVeloCluster* lhs, const LHCb::InternalVeloCluster* rhs) const; - }; - - bool veloClusterPtrLessThan::operator() (const LHCb::InternalVeloCluster* lhs, const LHCb::InternalVeloCluster* rhs) const - { - const LHCb::VeloChannelID& lhsId = lhs->channelID(0); - const LHCb::VeloChannelID& rhsId = rhs->channelID(0); - - return (lhsId.sensor() == rhsId.sensor() ? lhsId.strip() < rhsId.strip() : lhsId.sensor() < rhsId.sensor()); - } - - bool veloClusterPtrLessThan::operator() (const LHCb::VeloCluster* lhs, const LHCb::VeloCluster* rhs) const - { - const LHCb::VeloChannelID& lhsId = lhs->channelID(); - const LHCb::VeloChannelID& rhsId = rhs->channelID(); - - return (lhsId.sensor() == rhsId.sensor() ? lhsId.strip() < rhsId.strip() : lhsId.sensor() < rhsId.sensor()); - } -} -#endif // VELOCLUSTERPTRLESSTHAN_H diff --git a/Velo/VeloDAQ/src/VeloClusterWord.h b/Velo/VeloDAQ/src/VeloClusterWord.h deleted file mode 100644 index cc38012fc9ecccc96868b407637e175ffb79dfbe..0000000000000000000000000000000000000000 --- a/Velo/VeloDAQ/src/VeloClusterWord.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef VELOCLUSTERWORD_H -#define VELOCLUSTERWORD_H 1 - -#include "SiDAQ/SiClusterWord.h" -#include "VeloBitsPolicy.h" - -/** Decodes/encodes velo clusterword - * - * This class is a simple type wrapper for an - * SiClusterWord instantiated with a VeloBitsPoliciy. - * - * @see SiClusterWord - * @see VeloBitsPolicy - * - * @author Kurt Rinnert - * @date 2006-02-02 - */ -typedef SiClusterWord<VeloBitsPolicy> VeloClusterWord; - -#endif - diff --git a/Velo/VeloDAQ/src/VeloClustersToRaw.cpp b/Velo/VeloDAQ/src/VeloClustersToRaw.cpp deleted file mode 100644 index 1d3ca5dda3f0dde1f28ee14fc752e0dbd3f80d1f..0000000000000000000000000000000000000000 --- a/Velo/VeloDAQ/src/VeloClustersToRaw.cpp +++ /dev/null @@ -1,343 +0,0 @@ -#include "Event/RawEvent.h" - -#include "VeloDet/DeVelo.h" - -#include "SiDAQ/SiHeaderWord.h" -#include "SiDAQ/SiADCWord.h" -#include "SiDAQ/SiRawBufferWord.h" - -#include "VeloClusterWord.h" -#include "VeloRawBankVersions.h" -#include "VeloRawBankDecoder.h" -#include "VeloRawWordSizes.h" -#include "VeloClusterPtrLessThan.h" -#include "DecodeRawBankToClusters.h" - -#include "VeloClustersToRaw.h" - - -//----------------------------------------------------------------------------- -// Implementation file for class : VeloClustersToRaw -// -// 2011-09-20 : Kurt Rinnert -//----------------------------------------------------------------------------- - -DECLARE_ALGORITHM_FACTORY( VeloClustersToRaw ) - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -VeloClustersToRaw::VeloClustersToRaw( const std::string& name, - ISvcLocator* pSvcLocator) -: GaudiAlgorithm (name , pSvcLocator), - m_clusterLoc(LHCb::VeloClusterLocation::Default), - m_rawEventLoc(LHCb::RawEventLocation::Default), - m_bankVersion(VeloDAQ::v3) -{ - declareProperty("VeloClusterLocation",m_clusterLoc="Raw/Velo/ClustersSelected"); - declareProperty("RawEventLocation",m_rawEventLoc="DAQ/RawEventSelected"); - declareProperty("RunSelfTest",m_runSelfTest=false,"Decodes endoced bank and compares to input clusters."); - declareProperty("BankVersion", m_bankVersion=VeloDAQ::v3); -} - -//============================================================================= -// Initialisation. Check parameters -//============================================================================= -StatusCode VeloClustersToRaw::initialize() { - StatusCode sc = GaudiAlgorithm::initialize(); // must be executed first - if ( sc.isFailure() ) return sc; // error printed already by GaudiAlgorithm - - m_velo = getDet<DeVelo>( DeVeloLocation::Default ); - - // check whether the requested bank version is supported - switch (m_bankVersion) { - case VeloDAQ::v2: // ok, do nothing - case VeloDAQ::v3: - break; - default: // not supported, bail out - error() << "VELO raw buffer version " - << m_bankVersion - << " is not supported." - << endmsg; - return StatusCode::FAILURE; - } - - return StatusCode::SUCCESS; -} - -//============================================================================= -// Main execution -//============================================================================= -StatusCode VeloClustersToRaw::execute() { - - StatusCode sc; - - // Get the input container - // Get the VeloClusters from their default location - const LHCb::VeloClusters* clusters = getIfExists<LHCb::VeloClusters>(m_clusterLoc); - if( !clusters ) return Error( " ==> There are no VeloClusters in TES! " ); - - m_sortedClusters.clear(); - m_sortedClusters.resize(clusters->size()); - std::copy(clusters->begin(),clusters->end(),m_sortedClusters.begin()); - - // Then sort the clusters by sensor number and strip number - std::sort( m_sortedClusters.begin(), m_sortedClusters.end(), - VeloDAQ::veloClusterPtrLessThan()); - - m_rawEventOut = getIfExists<LHCb::RawEvent>(m_rawEventLoc); - if( !m_rawEventOut ) { - m_rawEventOut = new LHCb::RawEvent(); - put(m_rawEventOut, m_rawEventLoc); - } - - // loop over all clusters and write one bank per sensor - auto clusterIter = m_sortedClusters.cbegin(); - - unsigned int currentSensorNumber; // sensor number for current cluster subset - //unsigned int sensorIndex = 0; // index of current sensor in list of all sensors - - while (clusterIter != m_sortedClusters.cend()) { - - currentSensorNumber = (*clusterIter)->channelID().sensor(); - - // make and store the bank, increments cluster iterator to first - // cluster on next non-empty sensor - sc = storeBank(currentSensorNumber, clusterIter); - if ( !sc ) { return StatusCode::FAILURE; } - } - - if ( m_runSelfTest ) { - if ( selfTest() ) { - info() << "Self test passed." << endmsg; - } else { - error() << "Self test FAILED." << endmsg; - } - } - - return StatusCode::SUCCESS; -} - -//============================================================================= -StatusCode VeloClustersToRaw::storeBank( const unsigned int sensor, - std::vector<const LHCb::VeloCluster*>::const_iterator& clusterIter) { - - - // Sensor and TELL1 Id might be different, e.g in a test beam - // setup. Also it makes no sense to add a bank for a sensor that - // has no Tell1 Id. While this should never be attempted in the - // first place (if the geometry XML and CondDB is correct), it is - // still a good idea to protect against this scenario. - unsigned int sourceId; - if (m_velo->tell1IdBySensorNumber(sensor, sourceId)) { - - // create new raw buffer in raw data cache, old one is cleared - makeBank(sensor, clusterIter); - - LHCb::RawBank* newBank = m_rawEventOut->createBank(static_cast<SiDAQ::buffer_word>(sourceId), - LHCb::RawBank::Velo, - m_bankVersion, - m_bankSizeInBytes, - &(m_rawData[0])); - - // add new bank and pass memory ownership to raw event - m_rawEventOut->adoptBank(newBank,true); - - return StatusCode::SUCCESS; - - } else { - // we should not end up here if the geometry XMl and the - // CondDB sensor/Tell1 mapping is consistent - error() - << " Attempt to create bank for sensor " << sensor - << " with no TELL1 Id detected." << endmsg; - - return StatusCode::FAILURE; - } -} - -unsigned int VeloClustersToRaw::makeBank ( const unsigned int sensor, - std::vector<const LHCb::VeloCluster*>::const_iterator& clusterIter ) { - // clear bank - m_rawData.clear(); - - // clear temporary buffers - m_clusterPosBuffer.clear(); - m_clusterADCBuffer.clear(); - - // for storing 32 bit 'rows' of adc values and compressed clusters - SiDAQ::buffer_word rowData = 0x0; - SiDAQ::buffer_word cluRowData = 0x0; - - // loop over clusters on this sensor - unsigned int nClu = 0; // cluster counter - unsigned int nAdc = 0; // ADC word counter, needed for padding - for ( ; m_sortedClusters.end() != clusterIter && sensor == (*clusterIter)->channelID().sensor(); ++clusterIter) { - - const LHCb::VeloCluster* clu = *clusterIter; - - unsigned int numStrips = clu->size(); - bool highThresh = clu->highThreshold(); - double interStripFrac = clu->interStripFraction(); - unsigned int strip = clu->channelID().strip(); - - // encode cluster position - VeloClusterWord vcw(strip,interStripFrac,numStrips,highThresh); - SiDAQ::buffer_word packedCluster = static_cast<SiDAQ::buffer_word>(vcw.value()); - - //encode adc values - const std::vector< std::pair<int, unsigned int> >& stripSignals = clu->stripValues(); - for (unsigned int i=0; i<stripSignals.size(); ++i) { - double adcCount = stripSignals[i].second; - - // create new adc word - bool endOfCluster = (stripSignals.size() == i+1); - SiADCWord aw(adcCount,endOfCluster); - - rowData |= (aw.value() << - ((nAdc % VeloDAQ::adc_per_buffer) << VeloDAQ::adc_shift)); - - ++nAdc; - if (nAdc % VeloDAQ::adc_per_buffer == 0) { - m_clusterADCBuffer.push_back ( rowData ); - //reset rowData - rowData = 0x0; - } - - } - - // store the cluster position - cluRowData |= (packedCluster << ((nClu % VeloDAQ::clu_per_buffer) << VeloDAQ::clu_shift)); - ++nClu; - if ( nClu % VeloDAQ::clu_per_buffer == 0 ) { - m_clusterPosBuffer.push_back( cluRowData ); - // clear the cluster buffer - cluRowData = 0x0 ; - } - } - - // if there were an odd number of clusters, sort the last cluster row - if ( nClu % VeloDAQ::clu_per_buffer != 0 ) { - m_clusterPosBuffer.push_back ( cluRowData ); - } - // check row data is not empty, store remaining adcs - if ( nAdc % VeloDAQ::adc_per_buffer != 0 ) { - m_clusterADCBuffer.push_back ( rowData ); - } - - // add bank header - // the actual PCN is not available and there are no banks with errors in stripping - SiHeaderWord hw(nClu,0,0); - SiDAQ::buffer_word bankHeader = hw.value(); - m_rawData.push_back ( bankHeader ); - - // add clusters positions - std::copy( m_clusterPosBuffer.begin(), m_clusterPosBuffer.end(), - std::back_inserter(m_rawData)); - - // add adc values - std::copy( m_clusterADCBuffer.begin(), m_clusterADCBuffer.end(), - std::back_inserter(m_rawData) ); - - // Find number of padding bytes at the end of bank an compute - // raw bank size in bytes, including the 4 byte header but - // *without* the padding bytes at the end. - // The number of padding bytes is completely determined by - // the number of ADC words in the raw bank. - int adcRemainder = nAdc%VeloDAQ::adc_per_buffer; - m_bankSizeInBytes = sizeof(SiDAQ::buffer_word)*m_rawData.size() - - (adcRemainder ? sizeof(SiDAQ::buffer_word)-adcRemainder*VeloDAQ::adc_word_size : 0); - - return nClu; -} - -bool VeloClustersToRaw::selfTest() -{ - info() << "==> selfTest" << endmsg; - - bool passed = false; - - LHCb::VeloClusters clusters; - for (const auto& bo : m_rawEventOut->banks(LHCb::RawBank::Velo)) { - - LHCb::RawBank* outBank = bo; - - const DeVeloSensor* sensor = m_velo->sensor( outBank->sourceID() ); - int byteCount = 0; - std::string errMsg; - - VeloDAQ::decodeRawBankToClustersV3(static_cast<SiDAQ::buffer_word*>(outBank->data()), - sensor, false, clusters, byteCount, errMsg, false); - } - - std::vector<const LHCb::VeloCluster*> decodedClusters(clusters.size()); - std::copy(clusters.begin(),clusters.end(),decodedClusters.begin()); - std::sort( decodedClusters.begin(), decodedClusters.end(), - VeloDAQ::veloClusterPtrLessThan()); - - - info() << "Number of clusters: ref=" << m_sortedClusters.size() << " out=" << decodedClusters.size() << endmsg; - if ( m_sortedClusters.size() != decodedClusters.size() ) return passed; - - passed = true; - - auto iIn = m_sortedClusters.begin(); - auto iOut = decodedClusters.begin(); - for ( ; iOut != decodedClusters.end(); ++iIn, ++iOut ) { - const LHCb::VeloCluster* inClu = *iIn; - const LHCb::VeloCluster* outClu = *iOut; - - if ( inClu->channelID() != outClu->channelID() ) { - error() << "Channel IDs do not match: ref=(" << inClu->channelID().sensor() << "," << inClu->channelID().strip() - << ") out=(" << outClu->channelID().sensor() << "," << outClu->channelID().strip() << ")" << endmsg; - passed = false; - } - - if ( inClu->size() != outClu->size() ) { - error() << "Cluster sizes do not match: ref=" << inClu->size() - << " out=" << outClu->size() << endmsg; - passed = false; - } else { - for (unsigned int i=0; i<outClu->size(); ++i) { - if ( inClu->strip(i) != outClu->strip(i) ) { - error() << "Cluster strips do not match: ref=" << inClu->strip(i) - << " out=" << outClu->strip(i) << endmsg; - passed = false; - } - - if ( inClu->adcValue(i) != outClu->adcValue(i) ) { - error() << "Strip ADC values do not match: ref=" << inClu->adcValue(i) - << " out=" << outClu->adcValue(i) << endmsg; - passed = false; - } - - } - } - - if ( inClu->totalCharge() != outClu->totalCharge() ) { - error() << "Cluster charges do not match: ref=" << inClu->totalCharge() - << " out=" << outClu->totalCharge() << endmsg; - passed = false; - } - - if ( inClu->highThreshold() != outClu->highThreshold() ) { - error() << "Threshold flags do not match: ref=" << inClu->highThreshold() - << " out=" << outClu->highThreshold() << endmsg; - passed = false; - } - - if ( inClu->pseudoSize() != outClu->pseudoSize() ) { - error() << "Cluster pseudo sizes do not match: ref=" << inClu->pseudoSize() - << " out=" << outClu->pseudoSize() << endmsg; - passed = false; - } - - if ( inClu->interStripFraction() != outClu->interStripFraction() ) { - error() << "Inter strip fractions do not match: ref=" << inClu->interStripFraction() - << " out=" << outClu->interStripFraction() << endmsg; - passed = false; - } - - } - return passed; -} diff --git a/Velo/VeloDAQ/src/VeloClustersToRaw.h b/Velo/VeloDAQ/src/VeloClustersToRaw.h deleted file mode 100644 index 506cac0b1d2d6f8d53c5157ba848a91c00d1e4c6..0000000000000000000000000000000000000000 --- a/Velo/VeloDAQ/src/VeloClustersToRaw.h +++ /dev/null @@ -1,68 +0,0 @@ -#ifndef VELOCLUSTERSTORAW_H -#define VELOCLUSTERSTORAW_H 1 - -#include <vector> -#include <algorithm> -#include <string> - -#include "Event/VeloCluster.h" - -#include "GaudiAlg/GaudiAlgorithm.h" - -class DeVelo; -namespace LHCb { - class RawEvent; -} - -/** @class VeloClustersToRaw VeloClustersToRaw.h - * Create a raw VELO cluster bank from VeloCluster container. - * - * @author Kurt Rinnert - * @date 2011-09-20 - */ -class VeloClustersToRaw : public GaudiAlgorithm { - -public: - /// Standard constructor - VeloClustersToRaw( const std::string& name, ISvcLocator* pSvcLocator ); - - StatusCode initialize() override; ///< Algorithm initialization - StatusCode execute () override; ///< Algorithm execution - -private: - - - unsigned int makeBank (const unsigned int sensor, std::vector<const LHCb::VeloCluster*>::const_iterator& begin); - - StatusCode storeBank(const unsigned int sensor, std::vector<const LHCb::VeloCluster*>::const_iterator& begin); - - bool selfTest(); ///< run self test on default locations - -private: - - // configurable locations in the TES - std::string m_clusterLoc; ///< cluster container input location - std::string m_rawEventLoc; ///< raw bank output location - - unsigned int m_bankVersion; ///< raw bank version tag - - bool m_runSelfTest; ///< run self test on default locations - - // long lived containers for performance reasons. Also used to communicate - // with makeBank() method - std::vector<const LHCb::VeloCluster*> m_sortedClusters; - std::vector<SiDAQ::buffer_word> m_rawData; - std::vector<SiDAQ::buffer_word> m_clusterADCBuffer; - std::vector<SiDAQ::buffer_word> m_clusterPosBuffer; - - LHCb::RawEvent* m_rawEventOut = nullptr; - - // size of raw bank in bytes, including the 4 byte header but - // *without* the padding bytes at the end - unsigned int m_bankSizeInBytes = 0; - - /// pointer to Velo Detector Element - DeVelo* m_velo = nullptr; - -}; -#endif // VELOCLUSTERSTORAW_H diff --git a/Velo/VeloDAQ/src/VeloFullDecoder.cpp b/Velo/VeloDAQ/src/VeloFullDecoder.cpp deleted file mode 100644 index b7c2bb0ff922bb0e65e4ff0a1b5b306ecc1aa27f..0000000000000000000000000000000000000000 --- a/Velo/VeloDAQ/src/VeloFullDecoder.cpp +++ /dev/null @@ -1,80 +0,0 @@ -// Include files - -// local -#include "VeloFullDecoder.h" -#include <iostream> - -//----------------------------------------------------------------------------- -// Implementation file for class : VeloFullDecoder -// -// 2006-04-21 : Tomasz Szumlak -//----------------------------------------------------------------------------- - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= - -using namespace VeloTELL1; - -VeloFullDecoder::VeloFullDecoder(const int decoderType) -{ - decoderIni(decoderType); -} -//============================================================================= -void VeloFullDecoder::decode(VeloFullBank* inData, VeloTELL1::sdataVec& decodedData) const -{ - decodedData.clear(); - // - for(int aBlock=0; aBlock<VeloTELL1::NumberOfPPFPGA; aBlock++){ - for(int aSection=0; aSection<VeloTELL1::SectionsPerBlock; aSection++){ - dataVec section=inData->getSection(aBlock, aSection); - for(int stream=0; stream<VeloTELL1::DataStreamPerSection; stream++){ - // skip the empty space in C section - if(!((aSection==EmptyData)&&(stream==EmptyData))){ - int ADCBitShift=stream*VeloTELL1::ADCShift; - for(int aLink=0; aLink<VeloTELL1::ALinkPerDataStream; aLink++){ - int analogChanShift=aLink*m_dataLenght; - int beginDecode=m_initialShift+analogChanShift; - int endDecode=m_wordsToDecode+beginDecode; - int count=0; - // - for(auto secIt = section.begin()+beginDecode; - secIt != section.begin()+endDecode; ++secIt ){ - unsigned int decodedWord=(((*secIt)>>ADCBitShift)&VeloTELL1::ADCMask); - // from now on we must be prepared for negative values, hence - // the cast to int. - decodedData.push_back(static_cast<int>(decodedWord)); - count++; - } - } // loop over channels - } // loop over ALink - } // loop over coded int - } // Sections loop - } // FPGA loop -} - -//============================================================================== -// to make the decoder universal one the code below to execute inside -// VeloFullDecoder constructor is provided -void VeloFullDecoder::decoderIni(const int decoderType) -{ - if(decoderType==VeloFull){ - // during ADC decoding skip ADC headers - m_initialShift=ADCShift; - // number of channes in one ALink and ADC headers - m_dataLenght=ALinkShift; - m_wordsToDecode=CHANNELS; - }else if(decoderType==VeloPedestal){ - // pedestals data has no ADC heders, no shift needed - m_initialShift=NoShift; - // one pedestal value for each strip - m_dataLenght=CHANNELS; - m_wordsToDecode=CHANNELS; - }else if(decoderType==VeloHeader){ - m_initialShift=NoShift; - m_dataLenght=ALinkShift; - m_wordsToDecode=ADCHeaders; - } - -} -// diff --git a/Velo/VeloDAQ/src/VeloFullDecoder.h b/Velo/VeloDAQ/src/VeloFullDecoder.h deleted file mode 100644 index a6fa93b22e9fbeaf3e73a773ba01e124bd6fb0f3..0000000000000000000000000000000000000000 --- a/Velo/VeloDAQ/src/VeloFullDecoder.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef VELOTELL1ALGORITHM_VELOFULLDECODER_H -#define VELOTELL1ALGORITHM_VELOFULLDECODER_H 1 - -// Include files -#include "VeloEvent/VeloFullBank.h" -#include "Tell1Kernel/VeloDecodeConf.h" -#include "Tell1Kernel/VeloDecodeCore.h" - -/** @class VeloFullDecoder VeloFullDecoder.h VeloFullDecoder.h - * - * - * @author Tomasz Szumlak - * @date 2006-04-11 - */ - -class VeloFullDecoder final { - - enum initialShifts{ - NoShift=0, - EmptyData=2, - ADCShift=4 - }; - -public: - - /// Standard constructor - VeloFullDecoder(const int decoderType); - void decode(VeloFullBank* inData, VeloTELL1::sdataVec& decodedData) const; - -private: - - void decoderIni(const int decoderType); - - int m_initialShift; // if decoding adcs skip headers - int m_dataLenght; // lenght of the ALink - int m_wordsToDecode; // words to decode - -}; -#endif // VELOTELL1ALG_VELOFULLDECODER_H -// diff --git a/Velo/VeloDAQ/src/VeloRawBankDecoder.h b/Velo/VeloDAQ/src/VeloRawBankDecoder.h deleted file mode 100644 index ead28693aa421112686a821349921ca2e033bc7f..0000000000000000000000000000000000000000 --- a/Velo/VeloDAQ/src/VeloRawBankDecoder.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef VELORAWBANKDECODER_H -#define VELORAWBANKDECODER_H 1 - -#include "SiDAQ/SiRawBankDecoder.h" -#include "VeloClusterWord.h" - - -/** @class VeloRawBankDecoder VeloRawBankDecoder.h - * - * Decoder for raw Velo banks - * - * This is a simple type wrapper for a template - * instantiation of a SiRawBankDecoder with - * VeloCLusterWord. - * - * @see VeloClusterWord - * @see SiRawBankDecoder - * - * @author Kurt Rinnert - * @date 2006-02-08 - */ -typedef SiRawBankDecoder<VeloClusterWord> VeloRawBankDecoder; - -#endif // VELORAWBANKDECODER_H diff --git a/Velo/VeloDAQ/src/VeloRawBankVersions.h b/Velo/VeloDAQ/src/VeloRawBankVersions.h deleted file mode 100644 index b9c5f4ebc5632816de7d73e51f04d29dec493a56..0000000000000000000000000000000000000000 --- a/Velo/VeloDAQ/src/VeloRawBankVersions.h +++ /dev/null @@ -1,11 +0,0 @@ -// $Id: VeloRawBankVersions.h,v 1.2 2007-09-16 16:56:24 krinnert Exp $ -#ifndef VELORAWBANKVERSIONS_H -#define VELORAWBANKVERSIONS_H 1 - -namespace VeloDAQ { - enum { v1 = 1 - , v2 = 2 - , v3 = 3 }; -} - -#endif // VELORAWBANKVERSIONS_H diff --git a/Velo/VeloDAQ/src/VeloRawWordSizes.h b/Velo/VeloDAQ/src/VeloRawWordSizes.h deleted file mode 100644 index b034ed770daf0bd96d5e621add346494eb181d17..0000000000000000000000000000000000000000 --- a/Velo/VeloDAQ/src/VeloRawWordSizes.h +++ /dev/null @@ -1,25 +0,0 @@ -// $Id: VeloRawWordSizes.h,v 1.1 2006-03-07 15:53:00 krinnert Exp $ -#ifndef VELORAWWORDSIZES_H -#define VELORAWWORDSIZES_H 1 - -#include "SiDAQ/SiRawBufferWord.h" - -namespace VeloDAQ { - // the size of a cluster word in bytes - const size_t clu_word_size = sizeof(unsigned short); - // the number of cluster words per buffer word - const size_t clu_per_buffer = sizeof(SiDAQ::buffer_word)/clu_word_size; - // the power of two that yields the number of bits in a cluster word, - // needed for shifting - const size_t clu_shift = 4; - - // the size of an adc word in bytes - const size_t adc_word_size = sizeof(unsigned char); - // the number of adc words per buffer word - const size_t adc_per_buffer = sizeof(SiDAQ::buffer_word)/adc_word_size; - // the power of two that yields the number of bits in an adc word, - // needed for shifting - const size_t adc_shift = 3; -} - -#endif // VELORAWWORDSIZES_H