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

HGCal raw data handling: Unpacker, Geometry, Local Reco #45665

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
29 changes: 29 additions & 0 deletions CondFormats/DataRecord/interface/HGCalDenseIndexInfoRcd.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#ifndef CondFormats_HGCalDenseIndexInfoRcd_h
#define CondFormats_HGCalDenseIndexInfoRcd_h
// -*- C++ -*-
//
// Package: CondFormats/DataRecord
// Class : HGCalDenseIndexInfoRcd
//
/**\class HGCalDenseIndexInfoRcd HGCalDenseIndexInfoRcd.h CondFormats/DataRecord/interface/HGCalDenseIndexInfoRcd.h
*
* Description:
* This record is used join information from the geometry and logical mapping
* This record depends on the HGCalElectronicsMappingRcd and CaloGeometryRecord
*
*/
//
// Author: Pedro Da Silva, Izaak Neutelings
// Created: Mon, 29 May 2023 09:13:07 GMT
//

#include "FWCore/Framework/interface/DependentRecordImplementation.h"
#include "FWCore/Utilities/interface/mplVector.h"
#include "CondFormats/DataRecord/interface/HGCalElectronicsMappingRcd.h"
#include "Geometry/Records/interface/CaloGeometryRecord.h"

class HGCalDenseIndexInfoRcd : public edm::eventsetup::DependentRecordImplementation<
HGCalDenseIndexInfoRcd,
edm::mpl::Vector<HGCalElectronicsMappingRcd, CaloGeometryRecord> > {};

#endif
28 changes: 28 additions & 0 deletions CondFormats/DataRecord/interface/HGCalModuleConfigurationRcd.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#ifndef CondFormats_HGCalModuleConfigurationRcd_h
#define CondFormats_HGCalModuleConfigurationRcd_h
// -*- C++ -*-
//
// Package: CondFormats/DataRecord
// Class : HGCalModuleConfigurationRcd
//
/**\class HGCalModuleConfigurationRcd HGCalModuleConfigurationRcd.h CondFormats/DataRecord/interface/HGCalModuleConfigurationRcd.h
*
* Description:
* This record is used for passing the configuration parameters to the calibration step in RAW -> RECO,
* This record depends on the HGCalMappingModuleIndexerRcd.
*
*/
//
// Author: Pedro Da Silva, Izaak Neutelings
// Created: Mon, 29 May 2023 09:13:07 GMT
//

#include "FWCore/Framework/interface/DependentRecordImplementation.h"
#include "FWCore/Utilities/interface/mplVector.h"
#include "CondFormats/DataRecord/interface/HGCalElectronicsMappingRcd.h"

class HGCalModuleConfigurationRcd
: public edm::eventsetup::DependentRecordImplementation<HGCalModuleConfigurationRcd,
edm::mpl::Vector<HGCalElectronicsMappingRcd> > {};
Comment on lines +24 to +26
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you expect HGCalModuleConfigurationRcd to have to depend on additional Records than HGCalElectronicsMappingRcd in the future?
(or, what prevents using HGCalElectronicsMappingRcd directly where HGCalModuleConfigurationRcd is used now?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We prefer to keep the bookkeeping of mapping/indexing separate from electronics configuration & calibration constants. In system tests the electronics configuration can vary between runs, for example for system tests and scans, while the geometry/indexing will stay constant. The idea is therefore to keep them separate because of different IOVs.


#endif
15 changes: 15 additions & 0 deletions CondFormats/DataRecord/src/HGCalDenseIndexInfoRcd.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// -*- C++ -*-
//
// Package: CondFormats/DataRecord
// Class : HGCalDenseIndexInfoRcd
//
// Implementation:
// [Notes on implementation]
//
// Author: Pedro Da Silva, Izaak Neutelings
// Created: Mon, 29 May 2023 09:13:07 GMT

#include "CondFormats/DataRecord/interface/HGCalDenseIndexInfoRcd.h"
#include "FWCore/Framework/interface/eventsetuprecord_registration_macro.h"

EVENTSETUP_RECORD_REG(HGCalDenseIndexInfoRcd);
15 changes: 15 additions & 0 deletions CondFormats/DataRecord/src/HGCalModuleConfigurationRcd.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// -*- C++ -*-
//
// Package: CondFormats/DataRecord
// Class : HGCalModuleConfigurationRcd
//
// Implementation:
// [Notes on implementation]
//
// Author: Pedro Da Silva, Izaak Neutelings
// Created: Mon, 29 May 2023 09:13:07 GMT

#include "CondFormats/DataRecord/interface/HGCalModuleConfigurationRcd.h"
#include "FWCore/Framework/interface/eventsetuprecord_registration_macro.h"

EVENTSETUP_RECORD_REG(HGCalModuleConfigurationRcd);
2 changes: 1 addition & 1 deletion CondFormats/HGCalObjects/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
<flags ALPAKA_BACKENDS="1"/>
<export>
<lib name="1"/>
</export>
</export>
19 changes: 19 additions & 0 deletions CondFormats/HGCalObjects/interface/HGCalCalibrationParameterHost.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#ifndef CondFormats_HGCalObjects_interface_HGCalCalibrationParameterHost_h
#define CondFormats_HGCalObjects_interface_HGCalCalibrationParameterHost_h

#include "DataFormats/Portable/interface/PortableHostCollection.h"
#include "CondFormats/HGCalObjects/interface/HGCalCalibrationParameterSoA.h"

namespace hgcalrechit {

// SoA with channel-level calibration parameters in host memory:
// pedestal, CM_slope, CM_ped, BXm1_kappa
using HGCalCalibParamHost = PortableHostCollection<HGCalCalibParamSoA>;

// SoA with ROC-level configuration parameters in host memory:
// gain
using HGCalConfigParamHost = PortableHostCollection<HGCalConfigParamSoA>;

} // namespace hgcalrechit

#endif // CondFormats_HGCalObjects_interface_HGCalCalibrationParameterHost_h
47 changes: 47 additions & 0 deletions CondFormats/HGCalObjects/interface/HGCalCalibrationParameterSoA.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#ifndef CondFormats_HGCalObjects_interface_HGCalCalibrationParameterSoA_h
#define CondFormats_HGCalObjects_interface_HGCalCalibrationParameterSoA_h

#include <Eigen/Core>
#include <Eigen/Dense>

#include "DataFormats/SoATemplate/interface/SoACommon.h"
#include "DataFormats/SoATemplate/interface/SoALayout.h"
#include "DataFormats/SoATemplate/interface/SoAView.h"

//#include "CondFormats/HGCalObjects/interface/HGCalMappingModuleIndexer.h"

namespace hgcalrechit {

// human-readable data type to replace bool for memcpy of vector<>::.data()
// NOTE: bool and byte have the same memory size
using mybool = std::byte;

// Generate structure of channel-level arrays (SoA) layout with RecHit dataformat
GENERATE_SOA_LAYOUT(HGCalCalibParamSoALayout,
SOA_COLUMN(float, ADC_ped), // ADC pedestals, O(91)
SOA_COLUMN(float, Noise), // noise, O(3)
SOA_COLUMN(float, CM_slope), // common mode slope, O(0.25)
SOA_COLUMN(float, CM_ped), // common mode pedestal (offset), O(92)
SOA_COLUMN(float, BXm1_slope), // leakage correction from previous bunch, O(0.0)
SOA_COLUMN(float, ADCtofC), // ADC conversion to charge (fC), depends on gain (80, 160, 320 fC)
SOA_COLUMN(float, TOTtofC), // TOT conversion to charge (fC), depends on gain (80, 160, 320 fC)
SOA_COLUMN(float, TOT_ped), // TOT pedestal (offset), O(9.0)
SOA_COLUMN(float, TOT_lin), // threshold at which TOT is linear, O(200)
SOA_COLUMN(float, TOT_P0), // coefficient pol2 in nonlinear region, O(145)
SOA_COLUMN(float, TOT_P1), // coefficient pol2 in nonlinear region, O(1.0)
SOA_COLUMN(float, TOT_P2), // coefficient pol2 in nonlinear region, O(0.004)
SOA_COLUMN(float, TOAtops), // TOA conversion to time (ps)
SOA_COLUMN(float, MIPS_scale), // MIPS scale
SOA_COLUMN(mybool, valid) // if false: mask dead channel
)
using HGCalCalibParamSoA = HGCalCalibParamSoALayout<>;

// Generate structure of ROC-level arrays (SoA) layout with RecHit dataformat
GENERATE_SOA_LAYOUT(HGCalConfigParamSoALayout,
SOA_COLUMN(uint8_t, gain) // for ADC to charge (fC) conversion (80, 160, 320 fC)
)
using HGCalConfigParamSoA = HGCalConfigParamSoALayout<>;

} // namespace hgcalrechit

#endif // CondFormats_HGCalObjects_interface_HGCalCalibrationParameterSoA_h
68 changes: 68 additions & 0 deletions CondFormats/HGCalObjects/interface/HGCalConfiguration.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// Authors: Izaak Neutelings (May 2024)
// Sources: https://docs.google.com/spreadsheets/d/13G7sOjssqw4B5AtOcQV3g0W01oZUOMM6Hm_DduxBEPU
#ifndef CondFormats_HGCalObjects_HGCalConfiguraton_h
#define CondFormats_HGCalObjects_HGCalConfiguraton_h
#include "CondFormats/Serialization/interface/Serializable.h"
#include "CondFormats/HGCalObjects/interface/HGCalMappingModuleIndexer.h"
#include <map>
#include <vector>

// @short configuration for ECON eRX (one half of HGROC)
struct HGCalROCConfig {
uint32_t charMode; // characterization mode; determines data fields in ROC dataframe
uint8_t gain; // pre-amp gain used (1: 80 fC, 2: 160 fC, 4: 320 fC)
//uint32_t clockPhase; // fine adjustment of the phase within the 40 MHz
//uint32_t L1AcceptOffset; // coarse adjustment to get the peak in the right place
//uint32_t injChannels; // injected channels for injection scan: 2b word to identify if connected or not+info no capacitor chosen
//uint32_t injCharge; // injected charge for injection scan: convert it to a float in units of fC offline (DAC setting?)
COND_SERIALIZABLE;
Comment on lines +14 to +18
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Combination of commented out fields and COND_SERIALIZABLE looks suspicious to me (given that once something is written in CondDB, its schema becomes frozen)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing in this PR is written in CondDB yet. We expect to use the commented-out fields for system tests with scans in the next weeks.

};

// @short configuration for ECON-D module
struct HGCalECONDConfig {
//std::string typecode;
uint32_t headerMarker; // begin of event marker/identifier for ECON-D
uint32_t passThrough; //pass through mode (this is just as check as it'll be in the ECON-D header anyway)
std::vector<HGCalROCConfig> rocs;
COND_SERIALIZABLE;
};

// @short configuration for FED
struct HGCalFedConfig {
bool mismatchPassthroughMode; // ignore ECON-D packet mismatches
uint32_t cbHeaderMarker; // begin of event marker/identifier for capture block
uint32_t slinkHeaderMarker; // begin of event marker/identifier for S-link
//uint32_t delay; // delay
std::vector<HGCalECONDConfig> econds;
COND_SERIALIZABLE;
};

/**
* @short Main HGCal configuration with a tree structure of vectors of
* HGCalFedConfig/HGCalECONDConfig/HGCalROCConfig structs as follows:
% config.feds[dense_fed_idx].econds[dense_econd_idx].rocs[dense_eRx_idx]
**/
class HGCalConfiguration {
public:
std::vector<HGCalFedConfig> feds;
//friend std::ostream& operator<< (std::ostream&, const HGCalConfiguration&);

private:
COND_SERIALIZABLE;
};

inline std::ostream& operator<<(std::ostream& os, const HGCalConfiguration& config) {
uint32_t nfed = config.feds.size();
uint32_t ntotmod = 0;
uint32_t ntotroc = 0;
for (auto const& fed : config.feds) {
ntotmod += fed.econds.size(); // number of ECON-D modules for this FED
for (auto const& mod : fed.econds) {
ntotroc += mod.rocs.size(); // number of eRx half-ROCs for this ECON-D module
}
}
os << "HGCalConfiguration(nfed=" << nfed << ",ntotmod=" << ntotmod << ",ntotroc=" << ntotroc << ")";
return os;
}

#endif
Loading