From b86aa5d945599c2365a9dedc462348e4c27fd22e Mon Sep 17 00:00:00 2001 From: Florian Uhlig <f.uhlig@gsi.de> Date: Tue, 29 Sep 2020 14:08:52 +0200 Subject: [PATCH] Add custom streamer for CbmPsdDigi (#1814) The entry for the CbmPsdDigi in the file DataLinkdef.h was wrong, such that for the CbmPsdDigi a streamer was generated which does not support automatic schema evolution. To overcome the problem a custom streamer with explicit schema evolution was added. This streamer allows to read also CbmPsdDigi Version 3 data from existing files. Refs #1814 --- core/data/DataLinkDef.h | 2 +- core/data/psd/CbmPsdDigi.cxx | 62 +++++++++++++++++++++++++++++++++++- 2 files changed, 62 insertions(+), 2 deletions(-) diff --git a/core/data/DataLinkDef.h b/core/data/DataLinkDef.h index 9b7db8ce4a..f7d571708f 100644 --- a/core/data/DataLinkDef.h +++ b/core/data/DataLinkDef.h @@ -76,7 +76,7 @@ #pragma link C++ class CbmTofTracklet + ; #pragma link C++ class CbmTofTrackletParam + ; -#pragma link C++ class CbmPsdDigi; +#pragma link C++ class CbmPsdDigi-; #pragma link C++ class CbmPsdHit; #pragma link C++ class CbmPsdPoint + ; #pragma link C++ class CbmPsdAddress; diff --git a/core/data/psd/CbmPsdDigi.cxx b/core/data/psd/CbmPsdDigi.cxx index 8035448084..a441980b60 100644 --- a/core/data/psd/CbmPsdDigi.cxx +++ b/core/data/psd/CbmPsdDigi.cxx @@ -7,11 +7,12 @@ #include "CbmPsdDigi.h" +#include <TBuffer.h> // for TBuffer +#include <TClass.h> // for CbmPsdDigi::IsA() #include <TString.h> // for Form, TString #include <string> // for basic_string - // --- Default constructor CbmPsdDigi::CbmPsdDigi() {} @@ -82,5 +83,64 @@ std::string CbmPsdDigi::ToString() const { return string.Data(); } +// --- Custom Streamer +void CbmPsdDigi::Streamer(TBuffer& R__b) { + // Stream an object of class CbmPsdDigi. + + UInt_t R__s, R__c; + if (R__b.IsReading()) { + Version_t R__v = R__b.ReadVersion(&R__s, &R__c); + if (R__v) {} + // LOG(info) << "Reading CbmPsdDigi version " << R__v; + if (3 == R__v) { + R__b >> fdEdep; + R__b >> fdTime; + R__b >> fuAddress; + R__b.CheckByteCount(R__s, R__c, CbmPsdDigi::IsA()); + } else if (4 == R__v) { + R__b >> ffFitHarmonic1; + R__b >> ffFitHarmonic2; + R__b >> ffFitR2; + R__b >> ffFitEdep; + R__b >> fdEdep; + R__b >> fdTime; + R__b >> fuAddress; + R__b >> fuAmpl; + R__b >> fuZL; + R__b >> fdEdepWfm; + R__b.CheckByteCount(R__s, R__c, CbmPsdDigi::IsA()); + } + } else { + // The function WriteVersion does not return the version number + // but the position where ti write the next data + // to get the class version use TClass->GetClassVersion() + + R__c = R__b.WriteVersion(CbmPsdDigi::IsA(), kTRUE); + Version_t version = CbmPsdDigi::IsA()->GetClassVersion(); + + // We don't intent to write data in old format + /* + if ( 3 == version ) { + R__b << fdEdep; + R__b << fdTime; + R__b << fuAddress; + R__b.SetByteCount(R__c, kTRUE); + } else if ( 4 == version ) { + */ + if (4 == version) { + R__b << ffFitHarmonic1; + R__b << ffFitHarmonic2; + R__b << ffFitR2; + R__b << ffFitEdep; + R__b << fdEdep; + R__b << fdTime; + R__b << fuAddress; + R__b << fuAmpl; + R__b << fuZL; + R__b << fdEdepWfm; + R__b.SetByteCount(R__c, kTRUE); + } + } +} ClassImp(CbmPsdDigi) -- GitLab