From 6f9481927c19e9c72b0b7aa0bdc2051abf81480d Mon Sep 17 00:00:00 2001 From: Pietro Cortese Date: Mon, 21 Dec 2020 19:13:41 +0100 Subject: [PATCH 1/9] Moving raw-parser.cxx --- Detectors/ZDC/{simulation => raw}/src/raw-parser.cxx | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Detectors/ZDC/{simulation => raw}/src/raw-parser.cxx (100%) diff --git a/Detectors/ZDC/simulation/src/raw-parser.cxx b/Detectors/ZDC/raw/src/raw-parser.cxx similarity index 100% rename from Detectors/ZDC/simulation/src/raw-parser.cxx rename to Detectors/ZDC/raw/src/raw-parser.cxx From 5e615e72938c43331831eb7ad83ab5b24d661d31 Mon Sep 17 00:00:00 2001 From: Pietro Cortese Date: Tue, 22 Dec 2020 15:26:55 +0100 Subject: [PATCH 2/9] Simple checks on raw data --- DataFormats/Detectors/ZDC/CMakeLists.txt | 4 +- .../ZDC/include/DataFormatsZDC/RawEventData.h | 13 +- .../Detectors/ZDC/src/RawEventData.cxx | 7 + Detectors/ZDC/base/src/ModuleConfig.cxx | 6 + Detectors/ZDC/raw/CMakeLists.txt | 31 +++ Detectors/ZDC/raw/include/ZDCRaw/DumpRaw.h | 41 ++++ Detectors/ZDC/raw/src/DumpRaw.cxx | 228 ++++++++++++++++++ Detectors/ZDC/raw/src/ZDCRawLinkDef.h | 17 ++ Detectors/ZDC/raw/src/raw-parser.cxx | 10 +- Detectors/ZDC/simulation/CMakeLists.txt | 2 +- Detectors/ZDC/simulation/src/Digitizer.cxx | 2 +- Detectors/ZDC/simulation/src/digi2raw.cxx | 2 +- 12 files changed, 352 insertions(+), 11 deletions(-) create mode 100644 Detectors/ZDC/raw/CMakeLists.txt create mode 100644 Detectors/ZDC/raw/include/ZDCRaw/DumpRaw.h create mode 100644 Detectors/ZDC/raw/src/DumpRaw.cxx create mode 100644 Detectors/ZDC/raw/src/ZDCRawLinkDef.h diff --git a/DataFormats/Detectors/ZDC/CMakeLists.txt b/DataFormats/Detectors/ZDC/CMakeLists.txt index a5c1fec2c14c4..b36feed39b580 100644 --- a/DataFormats/Detectors/ZDC/CMakeLists.txt +++ b/DataFormats/Detectors/ZDC/CMakeLists.txt @@ -9,7 +9,7 @@ # submit itself to any jurisdiction. o2_add_library(DataFormatsZDC - SOURCES src/ChannelData.cxx src/BCData.cxx src/RecEvent.cxx + SOURCES src/ChannelData.cxx src/BCData.cxx src/RecEvent.cxx src/RawEventData.cxx src/OrbitRawData.cxx src/OrbitRecData.cxx PUBLIC_LINK_LIBRARIES O2::CommonConstants O2::CommonDataFormat O2::ZDCBase ROOT::MathCore FairRoot::Base @@ -18,4 +18,4 @@ o2_add_library(DataFormatsZDC o2_target_root_dictionary(DataFormatsZDC HEADERS include/DataFormatsZDC/BCData.h include/DataFormatsZDC/ChannelData.h include/DataFormatsZDC/RecEvent.h include/DataFormatsZDC/OrbitRawData.h - include/DataFormatsZDC/OrbitRecData.h) + include/DataFormatsZDC/OrbitRecData.h include/DataFormatsZDC/RawEventData.h) diff --git a/DataFormats/Detectors/ZDC/include/DataFormatsZDC/RawEventData.h b/DataFormats/Detectors/ZDC/include/DataFormatsZDC/RawEventData.h index f0662d175c2b2..e034e8d964370 100644 --- a/DataFormats/Detectors/ZDC/include/DataFormatsZDC/RawEventData.h +++ b/DataFormats/Detectors/ZDC/include/DataFormatsZDC/RawEventData.h @@ -31,6 +31,7 @@ namespace zdc constexpr unsigned short Id_w0 = 0x0; constexpr unsigned short Id_w1 = 0x1; constexpr unsigned short Id_w2 = 0x2; +constexpr unsigned short Id_wn = 0x3; constexpr int NWPerGBTW = 4; struct __attribute__((__packed__)) ChannelDataV0 { @@ -79,11 +80,15 @@ struct __attribute__((__packed__)) ChannelDataV0 { unsigned empty_5 : 32; }; +union EventChData { + UInt_t w[NWPerBc][NWPerGBTW]; + struct ChannelDataV0 f; + void reset(); +}; + + struct EventData { - union { - UInt_t w[NWPerBc][NWPerGBTW]; - struct ChannelDataV0 f; - } data[NModules][NChPerModule] = {0}; + EventChData data[NModules][NChPerModule] = {0}; void print() const; void reset(); ClassDefNV(EventData, 1); diff --git a/DataFormats/Detectors/ZDC/src/RawEventData.cxx b/DataFormats/Detectors/ZDC/src/RawEventData.cxx index d988b7007da98..06155e310e2e8 100644 --- a/DataFormats/Detectors/ZDC/src/RawEventData.cxx +++ b/DataFormats/Detectors/ZDC/src/RawEventData.cxx @@ -14,6 +14,13 @@ using namespace o2::zdc; //ClassImp(EventData); +//______________________________________________________________________________ +void EventChData::reset() +{ + static constexpr int payloadSize = NWPerGBTW * sizeof(UInt_t); + memset((void*)&w[0][0], 0, payloadSize); +} + //______________________________________________________________________________ void EventData::print() const { diff --git a/Detectors/ZDC/base/src/ModuleConfig.cxx b/Detectors/ZDC/base/src/ModuleConfig.cxx index 9dbcf6a1ace8c..f0b0157e14a6b 100644 --- a/Detectors/ZDC/base/src/ModuleConfig.cxx +++ b/Detectors/ZDC/base/src/ModuleConfig.cxx @@ -14,6 +14,7 @@ using namespace o2::zdc; +//______________________________________________________________________________ void Module::printCh() const { printf("Module %d [ChID/FEEID R:T ]", id); @@ -23,6 +24,7 @@ void Module::printCh() const printf("\n"); } +//______________________________________________________________________________ void Module::printTrig() const { printf("Trigger conf %d: ", id); @@ -37,6 +39,7 @@ void Module::printTrig() const printf("\n"); } +//______________________________________________________________________________ void Module::print() const { printCh(); @@ -58,6 +61,7 @@ void ModuleConfig::print() const } } +//______________________________________________________________________________ void ModuleConfig::check() const { for (const auto& md : modules) { @@ -65,6 +69,7 @@ void ModuleConfig::check() const } } +//______________________________________________________________________________ void Module::check() const { // make sure that the channel has <= 2 triggers @@ -78,6 +83,7 @@ void Module::check() const } } +//______________________________________________________________________________ void Module::setChannel(int slot, int8_t chID, int16_t fID, bool read, bool trig, int tF, int tL, int tS, int tT) { if (slot < 0 || slot >= MaxChannels || chID < 0 || chID > NChannels) { diff --git a/Detectors/ZDC/raw/CMakeLists.txt b/Detectors/ZDC/raw/CMakeLists.txt new file mode 100644 index 0000000000000..64027eadc6d35 --- /dev/null +++ b/Detectors/ZDC/raw/CMakeLists.txt @@ -0,0 +1,31 @@ +# 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. + +o2_add_library(ZDCRaw + SOURCES src/DumpRaw.cxx src/raw-parser.cxx + PUBLIC_LINK_LIBRARIES O2::SimulationDataFormat O2::ZDCBase O2::ZDCSimulation + O2::DataFormatsZDC O2::CCDB O2::SimConfig O2::DPLUtils + O2::DetectorsRaw O2::Headers) + + +o2_target_root_dictionary(ZDCRaw + HEADERS include/ZDCRaw/DumpRaw.h) + +o2_add_executable(raw-parser + COMPONENT_NAME zdc + SOURCES src/raw-parser.cxx + PUBLIC_LINK_LIBRARIES O2::Framework + O2::DPLUtils + O2::ZDCSimulation + O2::ZDCRaw + O2::DetectorsRaw + O2::DetectorsCommonDataFormats + O2::CommonUtils) + diff --git a/Detectors/ZDC/raw/include/ZDCRaw/DumpRaw.h b/Detectors/ZDC/raw/include/ZDCRaw/DumpRaw.h new file mode 100644 index 0000000000000..8757a19fecf44 --- /dev/null +++ b/Detectors/ZDC/raw/include/ZDCRaw/DumpRaw.h @@ -0,0 +1,41 @@ +#include +#include +#include "ZDCBase/Constants.h" +#include "ZDCSimulation/ZDCSimParam.h" +#include "DataFormatsZDC/RawEventData.h" +#ifndef ALICEO2_ZDC_DUMPRAW_H_ +#define ALICEO2_ZDC_DUMPRAW_H_ +namespace o2 +{ +namespace zdc +{ +class DumpRaw +{ + public: + DumpRaw() = default; + void init(); + int process(const EventData ev); + int process(const EventChData ch); + int processWord(const UInt_t* word); + int getHPos(uint32_t board, uint32_t ch); + void write(); + void setVerbosity(int v) + { + mVerbosity = v; + } + int getVerbosity() const { return mVerbosity; } + + private: + void setStat(TH1 *h); + int mVerbosity = 1; + TH1 *mBaseline[NDigiChannels]={0}; + TH1 *mCounts[NDigiChannels]={0}; + TH2 *mSignal[NDigiChannels]={0}; + TH2 *mBunch[NDigiChannels]={0}; + EventChData mCh; + ClassDefNV(DumpRaw, 1); +}; +} // namespace zdc +} // namespace o2 + +#endif diff --git a/Detectors/ZDC/raw/src/DumpRaw.cxx b/Detectors/ZDC/raw/src/DumpRaw.cxx new file mode 100644 index 0000000000000..24ad9f461fa60 --- /dev/null +++ b/Detectors/ZDC/raw/src/DumpRaw.cxx @@ -0,0 +1,228 @@ +#include +#include +#include +#include +#include +#include "ZDCRaw/DumpRaw.h" +#include "ZDCSimulation/Digits2Raw.h" +#include "FairLogger.h" + +using namespace o2::zdc; + +void DumpRaw::setStat(TH1 *h){ + TString hn=h->GetName(); + h->Draw(); + gPad->Update(); + TPaveStats *st=(TPaveStats*)h->GetListOfFunctions()->FindObject("stats"); + st->SetFillStyle(0); + st->SetBorderSize(1); + if(hn.BeginsWith("hp")){ + st->SetOptStat(111111); + st->SetX1NDC(0.1); + st->SetX2NDC(0.3); + st->SetY1NDC(0.640); + st->SetY2NDC(0.9); + }else if(hn.BeginsWith("hc")){ + st->SetOptStat(1111); + st->SetX1NDC(0.799); + st->SetX2NDC(0.999); + st->SetY1NDC(0.829); + st->SetY2NDC(0.999); + }else if(hn.BeginsWith("hs") || hn.BeginsWith("hb")){ + st->SetOptStat(11); + st->SetX1NDC(0.799); + st->SetX2NDC(0.9995); + st->SetY1NDC(0.904); + st->SetY2NDC(0.999); + } +} + +void DumpRaw::init(){ + gROOT->SetBatch(); + auto& sopt = ZDCSimParam::Instance(); + int nbx=(sopt.nBCAheadTrig+1)*NTimeBinsPerBC; + Double_t xmin=-sopt.nBCAheadTrig*NTimeBinsPerBC-0.5; + Double_t xmax=NTimeBinsPerBC-0.5; + for(UInt_t i=0; iReset(); + } else { + TString hname=TString::Format("hp%d%d",imod,ich); + TString htit=TString::Format("Baseline mod. %d ch. %d;Average orbit baseline",imod,ich); + //mBaseline[i]=new TH1F(hname,htit,ADCRange,ADCMin-0.5,ADCMax+0.5); + mBaseline[i]=new TH1F(hname,htit,16378,-0.125,ADCMax+0.125); + } + if(mCounts[i]){ + mCounts[i]->Reset(); + } else { + TString hname=TString::Format("hc%d%d",imod,ich); + TString htit=TString::Format("Counts mod. %d ch. %d; Orbit hits",imod,ich); + mCounts[i]=new TH1F(hname,htit,o2::constants::lhc::LHCMaxBunches+1,-0.5,o2::constants::lhc::LHCMaxBunches+0.5); + } + if(mSignal[i]){ + mSignal[i]->Reset(); + } else { + TString hname=TString::Format("hs%d%d",imod,ich); + TString htit=TString::Format("Signal mod. %d ch. %d; Sample; ADC",imod,ich); + mSignal[i]=new TH2F(hname,htit,nbx,xmin,xmax,ADCRange,ADCMin-0.5,ADCMax+0.5); + } + if(mBunch[i]){ + mBunch[i]->Reset(); + } else { + TString hname=TString::Format("hb%d%d",imod,ich); + TString htit=TString::Format("Bunch mod. %d ch. %d; Sample; ADC",imod,ich); + mBunch[i]=new TH2F(hname,htit,100,-0.5,99.5,36,-35.5,0.5); + } + } + // Word id not present in payload + mCh.f.fixed_0=Id_wn; + mCh.f.fixed_1=Id_wn; + mCh.f.fixed_2=Id_wn; +} + +void DumpRaw::write(){ + TFile *f=new TFile("ZDCDumpRaw.root","recreate"); + for(UInt_t i=0; iGetEntries()>0){ + setStat(mBunch[i]); + mBunch[i]->Write(); + } + } + for(UInt_t i=0; iGetEntries()>0){ + setStat(mBaseline[i]); + mBaseline[i]->Write(); + } + } + for(UInt_t i=0; iGetEntries()>0){ + setStat(mCounts[i]); + mCounts[i]->Write(); + } + } + for(UInt_t i=0; iGetEntries()>0){ + setStat(mSignal[i]); + mSignal[i]->Write(); + } + } + f->Close(); +} + +inline int DumpRaw::getHPos(uint32_t board, uint32_t ch){ + int ih=board*4+ch; + if(ih0){ + for(Int_t iw=0; iw ADCMax) { + s[i] = us[i] - ADCRange; + }else{ + s[i] = us[i]; + } + //printf("%d %u %d\n",i,us[i],s[i]); + } + if(f.Alice_3){ + for(Int_t i=0; i<12; i++)mSignal[ih]->Fill(i-36.,Double_t(s[i])); + } + if(f.Alice_2){ + for(Int_t i=0; i<12; i++)mSignal[ih]->Fill(i-24.,Double_t(s[i])); + } + if(f.Alice_1 || f.Auto_1){ + for(Int_t i=0; i<12; i++)mSignal[ih]->Fill(i-12.,Double_t(s[i])); + } + if(f.Alice_0 || f.Auto_0){ + for(Int_t i=0; i<12; i++)mSignal[ih]->Fill(i+0.,Double_t(s[i])); + Double_t bc_d=UInt_t(f.bc/100); + Double_t bc_m=UInt_t(f.bc%100); + mBunch[ih]->Fill(bc_m,-bc_d); + } + if(f.bc == 3563){ + Int_t offset = f.offset - 32768; + Double_t foffset = offset / 8.; + mBaseline[ih]->Fill(foffset); + mCounts[ih]->Fill(f.hits); + } +} + +int DumpRaw::process(const EventData ev){ + for (Int_t im = 0; im < NModules; im++) { + for (Int_t ic = 0; ic < NChPerModule; ic++) { + if (ev.data[im][ic].f.fixed_0 == Id_w0 && ev.data[im][ic].f.fixed_1 == Id_w1 && ev.data[im][ic].f.fixed_2 == Id_w2) { + process(ev.data[im][ic]); + } else if (ev.data[im][ic].f.fixed_0 == 0 && ev.data[im][ic].f.fixed_1 == 0 && ev.data[im][ic].f.fixed_2 == 0) { + // Empty channel + } else { + LOG(ERROR) << "Data format error"; + } + } + } +} diff --git a/Detectors/ZDC/raw/src/ZDCRawLinkDef.h b/Detectors/ZDC/raw/src/ZDCRawLinkDef.h new file mode 100644 index 0000000000000..71519a02a652e --- /dev/null +++ b/Detectors/ZDC/raw/src/ZDCRawLinkDef.h @@ -0,0 +1,17 @@ +// 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. + +#ifdef __CLING__ + +#pragma link off all globals; +#pragma link off all classes; +#pragma link off all functions; + +#endif diff --git a/Detectors/ZDC/raw/src/raw-parser.cxx b/Detectors/ZDC/raw/src/raw-parser.cxx index 616a7eaa7ee27..b2c65d71776c2 100644 --- a/Detectors/ZDC/raw/src/raw-parser.cxx +++ b/Detectors/ZDC/raw/src/raw-parser.cxx @@ -18,6 +18,7 @@ #include "Headers/DataHeader.h" #include "DataFormatsZDC/RawEventData.h" #include "ZDCSimulation/Digits2Raw.h" +#include "ZDCRaw/DumpRaw.h" #include #include @@ -44,7 +45,10 @@ WorkflowSpec defineDataProcessing(ConfigContext const& config) AlgorithmSpec{[](InitContext& setup) { auto loglevel = setup.options().get("log-level"); return adaptStateless([loglevel](InputRecord& inputs, DataAllocator& outputs) { - DPLRawParser parser(inputs); + o2::zdc::DumpRaw zdc_dr; + zdc_dr.init(); + zdc_dr.setVerbosity(loglevel); + DPLRawParser parser(inputs); o2::header::DataHeader const* lastDataHeader = nullptr; std::stringstream rdhprintout; for (auto it = parser.begin(), end = parser.end(); it != end; ++it) { @@ -82,7 +86,8 @@ WorkflowSpec defineDataProcessing(ConfigContext const& config) } if(payload!=0){ for(Int_t ip=0; ip 0) { LOG(INFO) << rdhprintout.str(); } + zdc_dr.write(); }); }}, Options{ {"log-level", VariantType::Int, 1, {"Logging level [0-2]"}}}}); diff --git a/Detectors/ZDC/simulation/CMakeLists.txt b/Detectors/ZDC/simulation/CMakeLists.txt index e4dc53138c392..e96e992eca329 100644 --- a/Detectors/ZDC/simulation/CMakeLists.txt +++ b/Detectors/ZDC/simulation/CMakeLists.txt @@ -11,7 +11,7 @@ o2_add_library(ZDCSimulation SOURCES src/Detector.cxx src/Digitizer.cxx src/SimCondition.cxx src/ZDCSimParam.cxx src/SpatialPhotonResponse.cxx src/Digits2Raw.cxx - PUBLIC_LINK_LIBRARIES O2::SimulationDataFormat O2::ZDCBase + PUBLIC_LINK_LIBRARIES O2::SimulationDataFormat O2::ZDCBase O2::DataFormatsZDC O2::CCDB O2::SimConfig O2::DetectorsRaw O2::Headers) diff --git a/Detectors/ZDC/simulation/src/Digitizer.cxx b/Detectors/ZDC/simulation/src/Digitizer.cxx index 536fd5070ba3b..ab34933392945 100644 --- a/Detectors/ZDC/simulation/src/Digitizer.cxx +++ b/Detectors/ZDC/simulation/src/Digitizer.cxx @@ -471,7 +471,7 @@ void Digitizer::refreshCCDB() } } if (md.feeID[ic] < 0 || md.feeID[ic] >= NLinks) { - LOG(ERROR) << "FEEID " << md.feeID[ic] << " not in allowed range [0:" << NLinks << ")"; + LOG(FATAL) << "FEEID " << md.feeID[ic] << " not in allowed range [0:" << NLinks << ")"; } } } else { diff --git a/Detectors/ZDC/simulation/src/digi2raw.cxx b/Detectors/ZDC/simulation/src/digi2raw.cxx index ef4c62bd85132..8d06d3993051c 100644 --- a/Detectors/ZDC/simulation/src/digi2raw.cxx +++ b/Detectors/ZDC/simulation/src/digi2raw.cxx @@ -57,7 +57,7 @@ int main(int argc, char** argv) add_option("input-file,i", bpo::value()->default_value("zdcdigits.root"), "input ZDC digits file"); add_option("file-per-link,l", bpo::value()->default_value(false)->implicit_value(true), "create output file per CRU (default: write single file)"); add_option("output-dir,o", bpo::value()->default_value("./"), "output directory for raw data"); - add_option("ccdb-url,c", bpo::value()->default_value(""), "url of the ccdb repository"); + add_option("ccdb-url,o", bpo::value()->default_value(""), "url of the ccdb repository"); uint32_t defRDH = o2::raw::RDHUtils::getVersion(); add_option("rdh-version,r", bpo::value()->default_value(defRDH), "RDH version to use"); add_option("configKeyValues", bpo::value()->default_value(""), "comma-separated configKeyValues"); From ba170dad847f2add204b8de0a4a24bce8954a077 Mon Sep 17 00:00:00 2001 From: Pietro Cortese Date: Tue, 22 Dec 2020 15:36:03 +0100 Subject: [PATCH 3/9] Missing file --- Detectors/ZDC/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Detectors/ZDC/CMakeLists.txt b/Detectors/ZDC/CMakeLists.txt index 364119694abdb..97eac3feb0cc2 100644 --- a/Detectors/ZDC/CMakeLists.txt +++ b/Detectors/ZDC/CMakeLists.txt @@ -11,3 +11,4 @@ add_subdirectory(base) add_subdirectory(simulation) add_subdirectory(macro) +add_subdirectory(raw) From 1b2f064ad677d4f0e5578463108edd1242afd9b0 Mon Sep 17 00:00:00 2001 From: Pietro Cortese Date: Tue, 22 Dec 2020 16:00:01 +0100 Subject: [PATCH 4/9] Plot appearance --- Detectors/ZDC/raw/src/DumpRaw.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Detectors/ZDC/raw/src/DumpRaw.cxx b/Detectors/ZDC/raw/src/DumpRaw.cxx index 24ad9f461fa60..378154c51364f 100644 --- a/Detectors/ZDC/raw/src/DumpRaw.cxx +++ b/Detectors/ZDC/raw/src/DumpRaw.cxx @@ -14,7 +14,7 @@ void DumpRaw::setStat(TH1 *h){ h->Draw(); gPad->Update(); TPaveStats *st=(TPaveStats*)h->GetListOfFunctions()->FindObject("stats"); - st->SetFillStyle(0); + st->SetFillStyle(1001); st->SetBorderSize(1); if(hn.BeginsWith("hp")){ st->SetOptStat(111111); From 234523211a8bde7fc9803518dd46d9b71103acd1 Mon Sep 17 00:00:00 2001 From: Pietro Cortese Date: Tue, 22 Dec 2020 16:08:32 +0100 Subject: [PATCH 5/9] clang-format --- DataFormats/Detectors/ZDC/include/DataFormatsZDC/RawEventData.h | 1 - 1 file changed, 1 deletion(-) diff --git a/DataFormats/Detectors/ZDC/include/DataFormatsZDC/RawEventData.h b/DataFormats/Detectors/ZDC/include/DataFormatsZDC/RawEventData.h index e034e8d964370..e96a0e95f59f6 100644 --- a/DataFormats/Detectors/ZDC/include/DataFormatsZDC/RawEventData.h +++ b/DataFormats/Detectors/ZDC/include/DataFormatsZDC/RawEventData.h @@ -86,7 +86,6 @@ union EventChData { void reset(); }; - struct EventData { EventChData data[NModules][NChPerModule] = {0}; void print() const; From a82f7ce9a6766d855c89cdcbb265aebd25cd8a9f Mon Sep 17 00:00:00 2001 From: Pietro Cortese Date: Tue, 22 Dec 2020 16:13:33 +0100 Subject: [PATCH 6/9] clang-format --- Detectors/ZDC/raw/include/ZDCRaw/DumpRaw.h | 10 +- Detectors/ZDC/raw/src/DumpRaw.cxx | 205 +++++++++++---------- 2 files changed, 113 insertions(+), 102 deletions(-) diff --git a/Detectors/ZDC/raw/include/ZDCRaw/DumpRaw.h b/Detectors/ZDC/raw/include/ZDCRaw/DumpRaw.h index 8757a19fecf44..51e6728a93768 100644 --- a/Detectors/ZDC/raw/include/ZDCRaw/DumpRaw.h +++ b/Detectors/ZDC/raw/include/ZDCRaw/DumpRaw.h @@ -26,12 +26,12 @@ class DumpRaw int getVerbosity() const { return mVerbosity; } private: - void setStat(TH1 *h); + void setStat(TH1* h); int mVerbosity = 1; - TH1 *mBaseline[NDigiChannels]={0}; - TH1 *mCounts[NDigiChannels]={0}; - TH2 *mSignal[NDigiChannels]={0}; - TH2 *mBunch[NDigiChannels]={0}; + TH1* mBaseline[NDigiChannels] = {0}; + TH1* mCounts[NDigiChannels] = {0}; + TH2* mSignal[NDigiChannels] = {0}; + TH2* mBunch[NDigiChannels] = {0}; EventChData mCh; ClassDefNV(DumpRaw, 1); }; diff --git a/Detectors/ZDC/raw/src/DumpRaw.cxx b/Detectors/ZDC/raw/src/DumpRaw.cxx index 378154c51364f..115be003e08c3 100644 --- a/Detectors/ZDC/raw/src/DumpRaw.cxx +++ b/Detectors/ZDC/raw/src/DumpRaw.cxx @@ -9,26 +9,27 @@ using namespace o2::zdc; -void DumpRaw::setStat(TH1 *h){ - TString hn=h->GetName(); +void DumpRaw::setStat(TH1* h) +{ + TString hn = h->GetName(); h->Draw(); gPad->Update(); - TPaveStats *st=(TPaveStats*)h->GetListOfFunctions()->FindObject("stats"); + TPaveStats* st = (TPaveStats*)h->GetListOfFunctions()->FindObject("stats"); st->SetFillStyle(1001); st->SetBorderSize(1); - if(hn.BeginsWith("hp")){ + if (hn.BeginsWith("hp")) { st->SetOptStat(111111); st->SetX1NDC(0.1); st->SetX2NDC(0.3); st->SetY1NDC(0.640); st->SetY2NDC(0.9); - }else if(hn.BeginsWith("hc")){ + } else if (hn.BeginsWith("hc")) { st->SetOptStat(1111); st->SetX1NDC(0.799); st->SetX2NDC(0.999); st->SetY1NDC(0.829); st->SetY2NDC(0.999); - }else if(hn.BeginsWith("hs") || hn.BeginsWith("hb")){ + } else if (hn.BeginsWith("hs") || hn.BeginsWith("hb")) { st->SetOptStat(11); st->SetX1NDC(0.799); st->SetX2NDC(0.9995); @@ -37,73 +38,75 @@ void DumpRaw::setStat(TH1 *h){ } } -void DumpRaw::init(){ +void DumpRaw::init() +{ gROOT->SetBatch(); auto& sopt = ZDCSimParam::Instance(); - int nbx=(sopt.nBCAheadTrig+1)*NTimeBinsPerBC; - Double_t xmin=-sopt.nBCAheadTrig*NTimeBinsPerBC-0.5; - Double_t xmax=NTimeBinsPerBC-0.5; - for(UInt_t i=0; iReset(); } else { - TString hname=TString::Format("hp%d%d",imod,ich); - TString htit=TString::Format("Baseline mod. %d ch. %d;Average orbit baseline",imod,ich); + TString hname = TString::Format("hp%d%d", imod, ich); + TString htit = TString::Format("Baseline mod. %d ch. %d;Average orbit baseline", imod, ich); //mBaseline[i]=new TH1F(hname,htit,ADCRange,ADCMin-0.5,ADCMax+0.5); - mBaseline[i]=new TH1F(hname,htit,16378,-0.125,ADCMax+0.125); + mBaseline[i] = new TH1F(hname, htit, 16378, -0.125, ADCMax + 0.125); } - if(mCounts[i]){ + if (mCounts[i]) { mCounts[i]->Reset(); } else { - TString hname=TString::Format("hc%d%d",imod,ich); - TString htit=TString::Format("Counts mod. %d ch. %d; Orbit hits",imod,ich); - mCounts[i]=new TH1F(hname,htit,o2::constants::lhc::LHCMaxBunches+1,-0.5,o2::constants::lhc::LHCMaxBunches+0.5); + TString hname = TString::Format("hc%d%d", imod, ich); + TString htit = TString::Format("Counts mod. %d ch. %d; Orbit hits", imod, ich); + mCounts[i] = new TH1F(hname, htit, o2::constants::lhc::LHCMaxBunches + 1, -0.5, o2::constants::lhc::LHCMaxBunches + 0.5); } - if(mSignal[i]){ + if (mSignal[i]) { mSignal[i]->Reset(); } else { - TString hname=TString::Format("hs%d%d",imod,ich); - TString htit=TString::Format("Signal mod. %d ch. %d; Sample; ADC",imod,ich); - mSignal[i]=new TH2F(hname,htit,nbx,xmin,xmax,ADCRange,ADCMin-0.5,ADCMax+0.5); + TString hname = TString::Format("hs%d%d", imod, ich); + TString htit = TString::Format("Signal mod. %d ch. %d; Sample; ADC", imod, ich); + mSignal[i] = new TH2F(hname, htit, nbx, xmin, xmax, ADCRange, ADCMin - 0.5, ADCMax + 0.5); } - if(mBunch[i]){ + if (mBunch[i]) { mBunch[i]->Reset(); } else { - TString hname=TString::Format("hb%d%d",imod,ich); - TString htit=TString::Format("Bunch mod. %d ch. %d; Sample; ADC",imod,ich); - mBunch[i]=new TH2F(hname,htit,100,-0.5,99.5,36,-35.5,0.5); + TString hname = TString::Format("hb%d%d", imod, ich); + TString htit = TString::Format("Bunch mod. %d ch. %d; Sample; ADC", imod, ich); + mBunch[i] = new TH2F(hname, htit, 100, -0.5, 99.5, 36, -35.5, 0.5); } } // Word id not present in payload - mCh.f.fixed_0=Id_wn; - mCh.f.fixed_1=Id_wn; - mCh.f.fixed_2=Id_wn; + mCh.f.fixed_0 = Id_wn; + mCh.f.fixed_1 = Id_wn; + mCh.f.fixed_2 = Id_wn; } -void DumpRaw::write(){ - TFile *f=new TFile("ZDCDumpRaw.root","recreate"); - for(UInt_t i=0; iGetEntries()>0){ +void DumpRaw::write() +{ + TFile* f = new TFile("ZDCDumpRaw.root", "recreate"); + for (UInt_t i = 0; i < NDigiChannels; i++) { + if (mBunch[i] && mBunch[i]->GetEntries() > 0) { setStat(mBunch[i]); mBunch[i]->Write(); } } - for(UInt_t i=0; iGetEntries()>0){ + for (UInt_t i = 0; i < NDigiChannels; i++) { + if (mBaseline[i] && mBaseline[i]->GetEntries() > 0) { setStat(mBaseline[i]); mBaseline[i]->Write(); } } - for(UInt_t i=0; iGetEntries()>0){ + for (UInt_t i = 0; i < NDigiChannels; i++) { + if (mCounts[i] && mCounts[i]->GetEntries() > 0) { setStat(mCounts[i]); mCounts[i]->Write(); } } - for(UInt_t i=0; iGetEntries()>0){ + for (UInt_t i = 0; i < NDigiChannels; i++) { + if (mSignal[i] && mSignal[i]->GetEntries() > 0) { setStat(mSignal[i]); mSignal[i]->Write(); } @@ -111,101 +114,108 @@ void DumpRaw::write(){ f->Close(); } -inline int DumpRaw::getHPos(uint32_t board, uint32_t ch){ - int ih=board*4+ch; - if(ih0){ - for(Int_t iw=0; iw 0) { + for (Int_t iw = 0; iw < NWPerBc; iw++) { Digits2Raw::print_gbt_word(ch.w[iw]); } } UShort_t us[12]; Short_t s[12]; - us[0]=f.s00; - us[1]=f.s01; - us[2]=f.s02; - us[3]=f.s03; - us[4]=f.s04; - us[5]=f.s05; - us[6]=f.s06; - us[7]=f.s07; - us[8]=f.s08; - us[9]=f.s09; - us[10]=f.s10; - us[11]=f.s11; + us[0] = f.s00; + us[1] = f.s01; + us[2] = f.s02; + us[3] = f.s03; + us[4] = f.s04; + us[5] = f.s05; + us[6] = f.s06; + us[7] = f.s07; + us[8] = f.s08; + us[9] = f.s09; + us[10] = f.s10; + us[11] = f.s11; for (Int_t i = 0; i < 12; i++) { if (us[i] > ADCMax) { s[i] = us[i] - ADCRange; - }else{ + } else { s[i] = us[i]; } //printf("%d %u %d\n",i,us[i],s[i]); } - if(f.Alice_3){ - for(Int_t i=0; i<12; i++)mSignal[ih]->Fill(i-36.,Double_t(s[i])); + if (f.Alice_3) { + for (Int_t i = 0; i < 12; i++) + mSignal[ih]->Fill(i - 36., Double_t(s[i])); } - if(f.Alice_2){ - for(Int_t i=0; i<12; i++)mSignal[ih]->Fill(i-24.,Double_t(s[i])); + if (f.Alice_2) { + for (Int_t i = 0; i < 12; i++) + mSignal[ih]->Fill(i - 24., Double_t(s[i])); } - if(f.Alice_1 || f.Auto_1){ - for(Int_t i=0; i<12; i++)mSignal[ih]->Fill(i-12.,Double_t(s[i])); + if (f.Alice_1 || f.Auto_1) { + for (Int_t i = 0; i < 12; i++) + mSignal[ih]->Fill(i - 12., Double_t(s[i])); } - if(f.Alice_0 || f.Auto_0){ - for(Int_t i=0; i<12; i++)mSignal[ih]->Fill(i+0.,Double_t(s[i])); - Double_t bc_d=UInt_t(f.bc/100); - Double_t bc_m=UInt_t(f.bc%100); - mBunch[ih]->Fill(bc_m,-bc_d); + if (f.Alice_0 || f.Auto_0) { + for (Int_t i = 0; i < 12; i++) + mSignal[ih]->Fill(i + 0., Double_t(s[i])); + Double_t bc_d = UInt_t(f.bc / 100); + Double_t bc_m = UInt_t(f.bc % 100); + mBunch[ih]->Fill(bc_m, -bc_d); } - if(f.bc == 3563){ + if (f.bc == 3563) { Int_t offset = f.offset - 32768; Double_t foffset = offset / 8.; mBaseline[ih]->Fill(foffset); @@ -213,7 +223,8 @@ int DumpRaw::process(const EventChData ch){ } } -int DumpRaw::process(const EventData ev){ +int DumpRaw::process(const EventData ev) +{ for (Int_t im = 0; im < NModules; im++) { for (Int_t ic = 0; ic < NChPerModule; ic++) { if (ev.data[im][ic].f.fixed_0 == Id_w0 && ev.data[im][ic].f.fixed_1 == Id_w1 && ev.data[im][ic].f.fixed_2 == Id_w2) { @@ -221,7 +232,7 @@ int DumpRaw::process(const EventData ev){ } else if (ev.data[im][ic].f.fixed_0 == 0 && ev.data[im][ic].f.fixed_1 == 0 && ev.data[im][ic].f.fixed_2 == 0) { // Empty channel } else { - LOG(ERROR) << "Data format error"; + LOG(ERROR) << "Data format error"; } } } From 379cadb02cf2924837b5368777c96a020bb4cb09 Mon Sep 17 00:00:00 2001 From: Pietro Cortese Date: Tue, 22 Dec 2020 16:49:33 +0100 Subject: [PATCH 7/9] Correct return values --- Detectors/ZDC/raw/src/DumpRaw.cxx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Detectors/ZDC/raw/src/DumpRaw.cxx b/Detectors/ZDC/raw/src/DumpRaw.cxx index 115be003e08c3..4b9d800b42feb 100644 --- a/Detectors/ZDC/raw/src/DumpRaw.cxx +++ b/Detectors/ZDC/raw/src/DumpRaw.cxx @@ -87,6 +87,10 @@ void DumpRaw::init() void DumpRaw::write() { TFile* f = new TFile("ZDCDumpRaw.root", "recreate"); + if (f->IsZombie()) { + LOG(FATAL) << "Cannot write to file " << f->GetName(); + return; + } for (UInt_t i = 0; i < NDigiChannels; i++) { if (mBunch[i] && mBunch[i]->GetEntries() > 0) { setStat(mBunch[i]); @@ -161,7 +165,9 @@ int DumpRaw::processWord(const UInt_t* word) } else { // Word not present in payload LOG(FATAL) << "Event format error"; + return 1; } + return 0; } int DumpRaw::process(const EventChData ch) @@ -221,6 +227,7 @@ int DumpRaw::process(const EventChData ch) mBaseline[ih]->Fill(foffset); mCounts[ih]->Fill(f.hits); } + return 0; } int DumpRaw::process(const EventData ev) @@ -236,4 +243,5 @@ int DumpRaw::process(const EventData ev) } } } + return 0; } From f70f0df2e9e0092199ca5533e8866dc9b12a25ef Mon Sep 17 00:00:00 2001 From: Pietro Cortese Date: Wed, 23 Dec 2020 11:24:05 +0100 Subject: [PATCH 8/9] Corrections after code review --- Detectors/ZDC/raw/include/ZDCRaw/DumpRaw.h | 5 ++--- Detectors/ZDC/raw/src/DumpRaw.cxx | 8 +++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Detectors/ZDC/raw/include/ZDCRaw/DumpRaw.h b/Detectors/ZDC/raw/include/ZDCRaw/DumpRaw.h index 51e6728a93768..965dcc2c2da2e 100644 --- a/Detectors/ZDC/raw/include/ZDCRaw/DumpRaw.h +++ b/Detectors/ZDC/raw/include/ZDCRaw/DumpRaw.h @@ -14,8 +14,8 @@ class DumpRaw public: DumpRaw() = default; void init(); - int process(const EventData ev); - int process(const EventChData ch); + int process(const EventData &ev); + int process(const EventChData &ch); int processWord(const UInt_t* word); int getHPos(uint32_t board, uint32_t ch); void write(); @@ -33,7 +33,6 @@ class DumpRaw TH2* mSignal[NDigiChannels] = {0}; TH2* mBunch[NDigiChannels] = {0}; EventChData mCh; - ClassDefNV(DumpRaw, 1); }; } // namespace zdc } // namespace o2 diff --git a/Detectors/ZDC/raw/src/DumpRaw.cxx b/Detectors/ZDC/raw/src/DumpRaw.cxx index 4b9d800b42feb..3d27814c1aaf2 100644 --- a/Detectors/ZDC/raw/src/DumpRaw.cxx +++ b/Detectors/ZDC/raw/src/DumpRaw.cxx @@ -4,6 +4,7 @@ #include #include #include "ZDCRaw/DumpRaw.h" +#include "CommonConstants/LHCConstants.h" #include "ZDCSimulation/Digits2Raw.h" #include "FairLogger.h" @@ -170,8 +171,9 @@ int DumpRaw::processWord(const UInt_t* word) return 0; } -int DumpRaw::process(const EventChData ch) +int DumpRaw::process(const EventChData &ch) { + static constexpr int last_bc=o2::constants::lhc::LHCMaxBunches-1; // Not empty event auto f = ch.f; int ih = getHPos(f.board, f.ch); @@ -221,7 +223,7 @@ int DumpRaw::process(const EventChData ch) Double_t bc_m = UInt_t(f.bc % 100); mBunch[ih]->Fill(bc_m, -bc_d); } - if (f.bc == 3563) { + if (f.bc == last_bc) { Int_t offset = f.offset - 32768; Double_t foffset = offset / 8.; mBaseline[ih]->Fill(foffset); @@ -230,7 +232,7 @@ int DumpRaw::process(const EventChData ch) return 0; } -int DumpRaw::process(const EventData ev) +int DumpRaw::process(const EventData &ev) { for (Int_t im = 0; im < NModules; im++) { for (Int_t ic = 0; ic < NChPerModule; ic++) { From 60600044922249c03b91b09221772a2f37c52fcc Mon Sep 17 00:00:00 2001 From: Pietro Cortese Date: Wed, 23 Dec 2020 11:27:39 +0100 Subject: [PATCH 9/9] clang-format --- Detectors/ZDC/raw/include/ZDCRaw/DumpRaw.h | 4 ++-- Detectors/ZDC/raw/src/DumpRaw.cxx | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Detectors/ZDC/raw/include/ZDCRaw/DumpRaw.h b/Detectors/ZDC/raw/include/ZDCRaw/DumpRaw.h index 965dcc2c2da2e..165d57d4bc9f4 100644 --- a/Detectors/ZDC/raw/include/ZDCRaw/DumpRaw.h +++ b/Detectors/ZDC/raw/include/ZDCRaw/DumpRaw.h @@ -14,8 +14,8 @@ class DumpRaw public: DumpRaw() = default; void init(); - int process(const EventData &ev); - int process(const EventChData &ch); + int process(const EventData& ev); + int process(const EventChData& ch); int processWord(const UInt_t* word); int getHPos(uint32_t board, uint32_t ch); void write(); diff --git a/Detectors/ZDC/raw/src/DumpRaw.cxx b/Detectors/ZDC/raw/src/DumpRaw.cxx index 3d27814c1aaf2..dbca59386494d 100644 --- a/Detectors/ZDC/raw/src/DumpRaw.cxx +++ b/Detectors/ZDC/raw/src/DumpRaw.cxx @@ -171,9 +171,9 @@ int DumpRaw::processWord(const UInt_t* word) return 0; } -int DumpRaw::process(const EventChData &ch) +int DumpRaw::process(const EventChData& ch) { - static constexpr int last_bc=o2::constants::lhc::LHCMaxBunches-1; + static constexpr int last_bc = o2::constants::lhc::LHCMaxBunches - 1; // Not empty event auto f = ch.f; int ih = getHPos(f.board, f.ch); @@ -232,7 +232,7 @@ int DumpRaw::process(const EventChData &ch) return 0; } -int DumpRaw::process(const EventData &ev) +int DumpRaw::process(const EventData& ev) { for (Int_t im = 0; im < NModules; im++) { for (Int_t ic = 0; ic < NChPerModule; ic++) {