Skip to content

Commit

Permalink
Merged dev/hackathon_base_CMSSW_14_1_0_pre0 from repository CMS-HGCAL…
Browse files Browse the repository at this point in the history
… with cms-merge-topic
  • Loading branch information
pfs committed Mar 6, 2024
2 parents ca93802 + 9cb1c13 commit 0cd26d5
Show file tree
Hide file tree
Showing 39 changed files with 1,898 additions and 32 deletions.
23 changes: 23 additions & 0 deletions CondFormats/DataRecord/interface/HGCalMappingCellIndexerRcd.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#ifndef CondFormatsModuleRcd_HGCalMappingCellIndexerRcd_h
#define CondFormatsModuleRcd_HGCalMappingCellIndexerRcd_h
// -*- C++ -*-
//
// Package: CondFormats/DataRecords
// Class : HGCalMappingCellIndexerRcd
//
/**\class HGCalMappingCellIndexerRcd HGCalMappingCellIndexerRcd.h CondFormats/DataRecords/interface/HGCalMappingCellIndexerRcd.h
Description: This record is used to store the cell readout indexer class for the electronics mapping parameters for HGCAL
*/
//
// Author: Pedro Vieira De Castro Ferreira Da Silva
// Created: Mon, 13 Nov 2023 12:02:11 GMT
//

#include "FWCore/Framework/interface/EventSetupRecordImplementation.h"

class HGCalMappingCellIndexerRcd : public edm::eventsetup::EventSetupRecordImplementation<HGCalMappingCellIndexerRcd> {
};

#endif
26 changes: 26 additions & 0 deletions CondFormats/DataRecord/interface/HGCalMappingCellRcd.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#ifndef CondFormatsModuleRcd_HGCalMappingCellRcd_h
#define CondFormatsModuleRcd_HGCalMappingCellRcd_h
// -*- C++ -*-
//
// Package: CondFormats/DataRecords
// Class : HGCalMappingCellRcd
//
/**\class HGCalMappingCellRcd HGCalMappingCellRcd.h CondFormats/DataRecords/interface/HGCalMappingCellRcd.h
Description: Record for storing the parameters describing a readout cell within each HGCAL module, used for the electronics mapping
*/
//
// Author: Pedro Vieira De Castro Ferreira Da Silva
// Created: Mon, 13 Nov 2023 12:02:11 GMT
//

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

class HGCalMappingCellRcd
: public edm::eventsetup::DependentRecordImplementation<HGCalMappingCellRcd,
edm::mpl::Vector<HGCalMappingCellIndexerRcd> > {};

#endif
23 changes: 23 additions & 0 deletions CondFormats/DataRecord/interface/HGCalMappingModuleIndexerRcd.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#ifndef CondFormatsModuleRcd_HGCalMappingModuleIndexerRcd_h
#define CondFormatsModuleRcd_HGCalMappingModuleIndexerRcd_h
// -*- C++ -*-
//
// Package: CondFormats/DataRecords
// Class : HGCalMappingModuleIndexerRcd
//
/**\class HGCalMappingModuleIndexerRcd HGCalMappingModuleIndexerRcd.h CondFormats/DataRecords/interface/HGCalMappingModuleIndexerRcd.h
Description: This record is used to store the readout indexer class of the modules in the electronics mapping of HGCAL
*/
//
// Author: Pedro Vieira De Castro Ferreira Da Silva
// Created: Mon, 13 Nov 2023 12:02:11 GMT
//

#include "FWCore/Framework/interface/EventSetupRecordImplementation.h"

class HGCalMappingModuleIndexerRcd
: public edm::eventsetup::EventSetupRecordImplementation<HGCalMappingModuleIndexerRcd> {};

#endif
26 changes: 26 additions & 0 deletions CondFormats/DataRecord/interface/HGCalMappingModuleRcd.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#ifndef CondFormatsModuleRcd_HGCalMappingModuleRcd_h
#define CondFormatsModuleRcd_HGCalMappingModuleRcd_h
// -*- C++ -*-
//
// Package: CondFormats/DataRecords
// Class : HGCalMappingModuleRcd
//
/**\class HGCalMappingModuleRcd HGCalMappingModuleRcd.h CondFormats/DataRecords/interface/HGCalMappingModuleRcd.h
Description: This record used to store the parameters which are used to describe HGCAL modules in the electronics mapping
*/
//
// Author: Pedro Vieira De Castro Ferreira Da Silva
// Created: Mon, 13 Nov 2023 12:02:11 GMT
//

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

class HGCalMappingModuleRcd
: public edm::eventsetup::DependentRecordImplementation<HGCalMappingModuleRcd,
edm::mpl::Vector<HGCalMappingModuleIndexerRcd> > {};

#endif
13 changes: 13 additions & 0 deletions CondFormats/DataRecord/src/HGCalMappingCellIndexerRcd.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// -*- C++ -*-
//
// Package: CondFormats/DataRecord
// Class : HGCalMappingCellIndexerRcd
//
//
// Author: Pedro Vieira De Castro Ferreira Da Silva
// Created: Mon, 13 Nov 2023 12:02:11 GMT

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

EVENTSETUP_RECORD_REG(HGCalMappingCellIndexerRcd);
13 changes: 13 additions & 0 deletions CondFormats/DataRecord/src/HGCalMappingCellRcd.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// -*- C++ -*-
//
// Package: CondFormats/DataRecord
// Class : HGCalMappingCellRcd
//
//
// Author: Pedro Vieira De Castro Ferreira Da Silva
// Created: Mon, 13 Nov 2023 12:02:11 GMT

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

EVENTSETUP_RECORD_REG(HGCalMappingCellRcd);
13 changes: 13 additions & 0 deletions CondFormats/DataRecord/src/HGCalMappingModuleIndexerRcd.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// -*- C++ -*-
//
// Package: CondFormats/DataRecord
// Class : HGCalMappingModuleIndexerRcd
//
//
// Author: Pedro Vieira De Castro Ferreira Da Silva
// Created: Mon, 13 Nov 2023 12:02:11 GMT

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

EVENTSETUP_RECORD_REG(HGCalMappingModuleIndexerRcd);
13 changes: 13 additions & 0 deletions CondFormats/DataRecord/src/HGCalMappingModuleRcd.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// -*- C++ -*-
//
// Package: CondFormats/DataRecord
// Class : HGCalMappingModuleRcd
//
//
// Author: Pedro Vieira De Castro Ferreira Da Silva
// Created: Mon, 13 Nov 2023 12:02:11 GMT

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

EVENTSETUP_RECORD_REG(HGCalMappingModuleRcd);
18 changes: 12 additions & 6 deletions CondFormats/HGCalObjects/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
<use name="FWCore/Utilities"/>
<use name="FWCore/MessageLogger"/>
<use name="HeterogeneousCore/CUDACore"/>
<use name="CUDADataFormats/HGCal"/>
<use name="Geometry/HGCalCommonData"/>
<use name="CondFormats/Serialization"/>
<use name="Geometry/HGCalCommonData"/>
<use name="boost_serialization"/>
<use name="DataFormats/HGCalDigi"/>
<use name="DataFormats/Portable"/>
<use name="DataFormats/SoATemplate"/>
<use name="FWCore/MessageLogger"/>
<use name="FWCore/Utilities"/>
<use name="HeterogeneousCore/AlpakaInterface"/>
<use name="HeterogeneousCore/CUDACore"/>
<flags ALPAKA_BACKENDS="1"/>
<export>
<lib name="1"/>
<lib name="1"/>
</export>
66 changes: 66 additions & 0 deletions CondFormats/HGCalObjects/interface/HGCalDenseIndexerBase.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#ifndef CondFormats_HGCalObjects_interface_HGCalDenseIndexerBase_h
#define CondFormats_HGCalObjects_interface_HGCalDenseIndexerBase_h

#include "CondFormats/Serialization/interface/Serializable.h"
#include "FWCore/Utilities/interface/Exception.h"
#include <array>
#include <numeric>

/**
@short this is a simple class that takes care of building a dense index for a set of categories
the maximum number of items expected in each category is encoded in the IndexRanges_t
the class is templated for the number of categories to use
*/
class HGCalDenseIndexerBase {
public:
HGCalDenseIndexerBase() : HGCalDenseIndexerBase(0) {}

HGCalDenseIndexerBase(int n) : n_(n), maxIdx_(0), vmax_(n, 0) {}

HGCalDenseIndexerBase(std::vector<uint32_t> const &o) : n_(o.size()) { updateRanges(o); }

void updateRanges(std::vector<uint32_t> const &o) {
check(o.size());
vmax_ = o;
maxIdx_ = std::accumulate(vmax_.begin(), vmax_.end(), 1, std::multiplies<uint32_t>());
}

uint32_t denseIndex(std::vector<uint32_t> v) const {
uint32_t rtn = v[0];
for (size_t i = 1; i < n_; i++)
rtn = rtn * vmax_[i] + v[i];
return rtn;
}

std::vector<uint32_t> unpackDenseIndex(uint32_t rtn) const {
std::vector<uint32_t> codes(n_, 0);

const auto rend = vmax_.rend();
for (auto rit = vmax_.rbegin(); rit != rend; ++rit) {
size_t i = rend - rit - 1;
codes[i] = rtn % (*rit);
rtn = rtn / (*rit);
}

return codes;
}

uint32_t getMaxIndex() const { return maxIdx_; }

~HGCalDenseIndexerBase() = default;

private:
void check(size_t osize) const {
if (osize != n_)
throw cms::Exception("ValueError") << " unable to update indexer max values. Expected " << n_ << " received "
<< osize;
}

uint32_t n_;
uint32_t maxIdx_;
std::vector<uint32_t> vmax_;

COND_SERIALIZABLE;
};

#endif
Loading

0 comments on commit 0cd26d5

Please sign in to comment.