Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modifications to auto-detect and decode link-base zero suppression #5569

Merged
merged 4 commits into from
Feb 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,21 @@ struct Header {
static constexpr uint32_t MagicWord = 0xFC;

union {
uint64_t word0 = 0; ///< lower 64 bits
struct { ///
uint64_t bitMaskLow : 64; ///< lower bits of the 80 bit bitmask
}; ///
}; ///
///
union { ///
uint64_t word1 = 0; ///< upper bits of the 80 bit bitmask
struct { ///
uint64_t bitMaskHigh : 16; ///< higher bits of the 80 bit bitmask
uint32_t bunchCrossing : 12; ///< bunch crossing number
uint32_t numWordsPayload : 4; ///< number of 128bit words with 12bit ADC values
uint32_t timeBin : 24; ///< time bin number issues by UL, mainly for debugging, since it might wrap
uint32_t magicWord : 8; ///< not used
uint64_t word0 = 0; ///< lower 64 bits
struct { ///
uint64_t bitMaskLow : 64; ///< lower bits of the 80 bit bitmask
}; ///
}; ///
///
union { ///
uint64_t word1 = 0; ///< upper bits of the 80 bit bitmask
struct { ///
uint64_t bitMaskHigh : 16; ///< higher bits of the 80 bit bitmask
uint32_t bunchCrossing : 12; ///< bunch crossing number
uint32_t numWordsPayload : 4; ///< number of 128bit words with 12bit ADC values
uint32_t syncOffsetBC : 8; ///< sync offset in bunch crossings
uint32_t syncOffsetCRUCycles : 16; ///< sync offset in 240MHz CRU clock cycles
uint32_t magicWord : 8; ///< not used
};
};

Expand All @@ -54,6 +55,8 @@ struct Header {
return std::bitset<80>((std::bitset<80>(bitMaskHigh) << 64) | std::bitset<80>(bitMaskLow));
}

bool isFillWord() const { return (word0 == 0xffffffffffffffff) && (word1 == 0xffffffffffffffff); }

bool hasCorrectMagicWord() const { return magicWord == MagicWord; }
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#include <vector>
#include <string>
#include <unordered_map>

#include <boost/variant.hpp>

Expand Down Expand Up @@ -75,12 +76,16 @@ class CalibTreeDump
/// Dump the registered calibration data to file
void dumpToFile(const std::string filename = "CalibTree.root");

/// Add complementary information
void addInfo(const std::string_view name, float value) { mAddInfo[name.data()] = value; }

private:
std::vector<DataTypes*> mCalDetObjects{}; ///< array of CalDet objects
std::vector<DataTypes*> mCalArrayObjects{}; ///< array of CalArray objects
bool mAddFEEInfo{false}; ///< add front end electronics mappings
std::vector<float> mTraceLengthIROC; ///< trace lengths IROC
std::vector<float> mTraceLengthOROC; ///< trace lengths OROC
std::unordered_map<std::string, float> mAddInfo{}; ///< additional common information to be added to the output tree
std::vector<DataTypes*> mCalDetObjects{}; ///< array of CalDet objects
std::vector<DataTypes*> mCalArrayObjects{}; ///< array of CalArray objects
bool mAddFEEInfo{false}; ///< add front end electronics mappings
std::vector<float> mTraceLengthIROC; ///< trace lengths IROC
std::vector<float> mTraceLengthOROC; ///< trace lengths OROC

/// add default mapping like local, global x/y positions
void addDefaultMapping(TTree* tree);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class DigitDump : public CalibRawBase
void setNoiseThreshold(float noiseThreshold) { mNoiseThreshold = noiseThreshold; }

/// set the adc range
void setADCRange(int minADC, int maxADC)
void setADCRange(float minADC, float maxADC)
{
mADCMin = minADC;
mADCMax = maxADC;
Expand Down Expand Up @@ -152,8 +152,8 @@ class DigitDump : public CalibRawBase

int mFirstTimeBin{0}; ///< first time bin used in analysis
int mLastTimeBin{1000}; ///< first time bin used in analysis
int mADCMin{-100}; ///< minimum adc value
int mADCMax{1024}; ///< maximum adc value
float mADCMin{-100}; ///< minimum adc value
float mADCMax{1024}; ///< maximum adc value
float mNoiseThreshold{-1}; ///< zero suppression threshold in noise sigma
bool mInMemoryOnly{false}; ///< if processing is only done in memory, no file writing
bool mInitialized{false}; ///< if init was called
Expand Down
10 changes: 5 additions & 5 deletions Detectors/TPC/calibration/macro/drawPulser.C
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,17 @@ TObjArray* drawPulser(TString pulserFile, int mode = 0, std::string_view outDir
const auto medianWidth = TMath::Median(rocWidth.getData().size(), rocWidth.getData().data());
const auto medianQtot = TMath::Median(rocQtot.getData().size(), rocQtot.getData().data());

const float rangeT0 = 1.5;
const float rangeT0 = 0.5;
const float minT0 = medianT0 - rangeT0;
const float maxT0 = medianT0 + rangeT0;

const float rangeWidth = 0.1;
const float rangeWidth = 0.5;
const float minWidth = medianWidth - rangeWidth;
const float maxWidth = medianWidth + rangeWidth;

const float rangeQtot = 150;
const float minQtot = medianQtot - 50;
const float maxQtot = medianQtot + rangeQtot;
//const float rangeQtot = 150;
const float minQtot = medianQtot / 2.;
const float maxQtot = medianQtot * 2.;

// ===| histograms for calT0, calWidth and calQtot |===
auto hT0 = new TH1F(Form("hT0%02d", iroc), Form("T0 distribution ROC %02d;time bins (0.2 #mus)", iroc), 100, minT0, maxT0);
Expand Down
3 changes: 2 additions & 1 deletion Detectors/TPC/calibration/macro/dumpDigits.C
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#endif

void dumpDigits(std::vector<std::string_view> fileInfos, TString outputFileName = "", int nevents = 100,
int adcMin = -100, int adcMax = 1100,
float adcMin = -100, float adcMax = 1100,
int firstTimeBin = 0, int lastTimeBin = 1000,
float noiseThreshold = -1,
TString pedestalAndNoiseFile = "",
Expand All @@ -30,6 +30,7 @@ void dumpDigits(std::vector<std::string_view> fileInfos, TString outputFileName
dig.setADCRange(adcMin, adcMax);
dig.setTimeBinRange(firstTimeBin, lastTimeBin);
dig.setNoiseThreshold(noiseThreshold);
dig.setSkipIncompleteEvents(false);

CalibRawBase::ProcessStatus status = CalibRawBase::ProcessStatus::Ok;
for (const auto& fileInfo : fileInfos) {
Expand Down
9 changes: 4 additions & 5 deletions Detectors/TPC/calibration/macro/runPulser.C
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ void runPulser(std::vector<std::string_view> fileInfos, TString outputFileName =
calib.setADCRange(adcMin, adcMax);
calib.setTimeBinRange(firstTimeBin, lastTimeBin);
calib.setDebugLevel();
calib.setQtotBinning(140, 22, 302);
//calib.setQtotBinning(140, 22, 302);
calib.setQtotBinning(500, 10, 1010);
if (type == 1) {
calib.setQtotBinning(150, 2, 302);
calib.setMinQtot(8);
Expand Down Expand Up @@ -66,10 +67,8 @@ void runPulser(std::vector<std::string_view> fileInfos, TString outputFileName =
for (Int_t i = 0; i < nevents; ++i) {
status = calib.processEvent(i);
std::cout << "Processing event " << i << " with status " << int(status) << '\n';
if (status == CalibRawBase::ProcessStatus::IncompleteEvent) {
continue;
} else if (status != CalibRawBase::ProcessStatus::Ok) {
//break;
if (status == CalibRawBase::ProcessStatus::LastEvent) {
break;
}
}
}
Expand Down
9 changes: 9 additions & 0 deletions Detectors/TPC/calibration/src/CalibRawBase.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "TSystem.h"
#include "TObjString.h"
#include "TObjArray.h"
#include "TPCBase/RDHUtils.h"

#include "TPCCalibration/CalibRawBase.h"

Expand Down Expand Up @@ -74,6 +75,14 @@ void CalibRawBase::setupContainers(TString fileInfo, uint32_t verbosity, uint32_
mProcessedTimeBins = std::max(mProcessedTimeBins, size_t(timeBins));
return timeBins;
});
mRawReaderCRUManager.setLinkZSCallback([this](int cru, int rowInSector, int padInRow, int timeBin, float adcValue) -> bool {
CRU cruID(cru);
updateROC(cruID.roc(), rowInSector - (rowInSector > 62) * 63, padInRow, timeBin, adcValue);
const PadRegionInfo& regionInfo = mMapper.getPadRegionInfo(cruID.region());
updateCRU(cruID, rowInSector - regionInfo.getGlobalRowOffset(), padInRow, timeBin, adcValue);
return true;
});

for (auto file : *arr) {
// fix the number of time bins
auto& reader = mRawReaderCRUManager.createReader(file->GetName(), timeBins);
Expand Down
4 changes: 3 additions & 1 deletion Detectors/TPC/reconstruction/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ o2_add_library(TPCReconstruction
src/DigitalCurrentClusterIntegrator.cxx
src/TPCFastTransformHelperO2.cxx
src/CTFCoder.cxx
src/RawProcessingHelpers.cxx
PUBLIC_LINK_LIBRARIES FairRoot::Base
O2::SimulationDataFormat
O2::TPCBase
Expand Down Expand Up @@ -54,7 +55,8 @@ o2_target_root_dictionary(
include/TPCReconstruction/HardwareClusterDecoder.h
include/TPCReconstruction/DigitalCurrentClusterIntegrator.h
include/TPCReconstruction/TPCFastTransformHelperO2.h
include/TPCReconstruction/CTFCoder.h)
include/TPCReconstruction/CTFCoder.h
include/TPCReconstruction/RawProcessingHelpers.h)

o2_add_executable(read-gbtframes
COMPONENT_NAME tpc
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright CERN and copyright holders of ALICE O2. This software is
// distributed under the terms of the GNU General Public License v3 (GPL
// Version 3), copied verbatim in the file "COPYING".
//
// See http://alice-o2.web.cern.ch/license for full licensing information.
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.

#ifndef O2_TPC_RawProcessingHelpers_H
#define O2_TPC_RawProcessingHelpers_H

#include <functional>

#include "TPCBase/RDHUtils.h"

namespace o2
{
namespace tpc
{
namespace raw_processing_helpers
{

using ADCCallback = std::function<bool(int cru, int rowInSector, int padInRow, int timeBin, float adcValue)>;

bool processZSdata(const char* data, size_t size, rdh_utils::FEEIDType feeId, uint32_t globalBCoffset, ADCCallback fillADC, bool useTimeBin = false);

} // namespace raw_processing_helpers
} // namespace tpc
} // namespace o2
#endif
Loading