CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
SiPixelLorentzAngleDBLoader Class Reference
Inheritance diagram for SiPixelLorentzAngleDBLoader:
edm::one::EDAnalyzer< edm::one::SharedResources > edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

void analyze (const edm::Event &e, const edm::EventSetup &c) override
 
 SiPixelLorentzAngleDBLoader (const edm::ParameterSet &conf)
 
 ~SiPixelLorentzAngleDBLoader () override=default
 
- Public Member Functions inherited from edm::one::EDAnalyzer< edm::one::SharedResources >
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDAnalyzerBase () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const *> const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Types

typedef std::vector< edm::ParameterSetParameters
 

Private Member Functions

int HVgroup (int panel, int module)
 

Private Attributes

float bPixLorentzAnglePerTesla_
 
const Parameters BPixParameters_
 
std::vector< std::pair< uint32_t, float > > detid_la
 
const std::string fileName_
 
float fPixLorentzAnglePerTesla_
 
const Parameters FPixParameters_
 
const Parameters ModuleParameters_
 
const std::string recordName_
 
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecordtkGeomToken_
 
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcdtkTopoToken_
 
const bool useFile_
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 26 of file SiPixelLorentzAngleDBLoader.cc.

Member Typedef Documentation

◆ Parameters

Definition at line 34 of file SiPixelLorentzAngleDBLoader.cc.

Constructor & Destructor Documentation

◆ SiPixelLorentzAngleDBLoader()

SiPixelLorentzAngleDBLoader::SiPixelLorentzAngleDBLoader ( const edm::ParameterSet conf)
explicit

Definition at line 55 of file SiPixelLorentzAngleDBLoader.cc.

References bPixLorentzAnglePerTesla_, fPixLorentzAnglePerTesla_, edm::ParameterSet::getUntrackedParameter(), and cond::service::PoolDBOutputService::kSharedResource.

58  recordName_(conf.getUntrackedParameter<std::string>("record", "SiPixelLorentzAngleRcd")),
59  useFile_(conf.getParameter<bool>("useFile")),
60  fileName_(conf.getParameter<string>("fileName")),
61  BPixParameters_(conf.getUntrackedParameter<Parameters>("BPixParameters")),
62  FPixParameters_(conf.getUntrackedParameter<Parameters>("FPixParameters")),
63  ModuleParameters_(conf.getUntrackedParameter<Parameters>("ModuleParameters")) {
65  static_cast<float>(conf.getUntrackedParameter<double>("bPixLorentzAnglePerTesla", -9999.));
67  static_cast<float>(conf.getUntrackedParameter<double>("fPixLorentzAnglePerTesla", -9999.));
69 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > tkGeomToken_
T getUntrackedParameter(std::string const &, T const &) const
std::vector< edm::ParameterSet > Parameters
static const std::string kSharedResource
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tkTopoToken_

◆ ~SiPixelLorentzAngleDBLoader()

SiPixelLorentzAngleDBLoader::~SiPixelLorentzAngleDBLoader ( )
overridedefault

Member Function Documentation

◆ analyze()

void SiPixelLorentzAngleDBLoader::analyze ( const edm::Event e,
const edm::EventSetup c 
)
overridevirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 71 of file SiPixelLorentzAngleDBLoader.cc.

References cond::service::PoolDBOutputService::appendOneIOV(), cond::service::PoolDBOutputService::beginOfTime(), PixelEndcapName::bladeName(), bPixLorentzAnglePerTesla_, BPixParameters_, cond::service::PoolDBOutputService::createOneIOV(), cond::service::PoolDBOutputService::currentTime(), TrackerGeometry::detUnits(), PixelEndcapName::diskName(), cppFunctionSkipper::exception, newFWLiteAna::found, fPixLorentzAnglePerTesla_, FPixParameters_, edm::EventSetup::getData(), HVgroup(), edm::Service< T >::isAvailable(), cond::service::PoolDBOutputService::isNewTagRequest(), PVValHelper::ladder, nano_mu_digi_cff::layer, SiStripSimParameters_cfi::LorentzAngle, callgraph::module, ModuleParameters_, PixelEndcapName::pannelName(), pfMETsysShiftCorrections_cfi::parameter, PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, TrackerTopology::pxbLadder(), TrackerTopology::pxbLayer(), TrackerTopology::pxbModule(), nano_mu_digi_cff::rawId, DetId::rawId(), recordName_, relativeConstraints::ring, PixelEndcapName::ringName(), TrackerTopology::side(), DetId::subdetId(), tkGeomToken_, tkTopoToken_, unit(), useFile_, and cms::Exception::what().

71  {
72  static constexpr int nModules_ = 4;
74 
75  // Retrieve tracker geometry from geometry
76  const TrackerGeometry* pDD = &es.getData(tkGeomToken_);
77  // Retrieve tracker topology from geometry
78  const TrackerTopology* tTopo = &es.getData(tkTopoToken_);
79 
80  for (auto& unit : pDD->detUnits()) {
81  if (auto pixelUnit = dynamic_cast<PixelGeomDetUnit const*>(unit)) {
82  const DetId detid = pixelUnit->geographicalId();
83  auto rawId = detid.rawId();
84  int found = 0;
85  int side = tTopo->side(detid); // 1:-z 2:+z for fpix, for bpix gives 0
86 
87  // fill bpix values for LA
88  if (detid.subdetId() == static_cast<int>(PixelSubdetector::PixelBarrel)) {
89  int layer = tTopo->pxbLayer(detid);
90  // Barrel ladder id 1-20,32,44.
91  int ladder = tTopo->pxbLadder(detid);
92  // Barrel Z-index=1,8
93  int module = tTopo->pxbModule(detid);
94  if (module < nModules_ + 1) {
95  side = 1;
96  } else {
97  side = 2;
98  }
99 
100  LogPrint("SiPixelLorentzAngleDBLoader") << " pixel barrel:"
101  << " layer=" << layer << " ladder=" << ladder << " module=" << module
102  << " rawId=" << rawId << " side=" << side;
103 
104  // use a commmon value (e.g. for MC)
105  if (bPixLorentzAnglePerTesla_ != -9999.) { // use common value for all
106  LogPrint("SiPixelLorentzAngleDBLoader")
107  << " LA=" << bPixLorentzAnglePerTesla_ << " common for all bpix" << endl;
108  if (!LorentzAngle.putLorentzAngle(detid.rawId(), bPixLorentzAnglePerTesla_)) {
109  LogError("SiPixelLorentzAngleDBLoader") << "ERROR!: detid already exists";
110  }
111  // use an external file
112  } else if (useFile_) {
113  LogPrint("SiPixelLorentzAngleDBLoader") << "method for reading file not implemented yet";
114  // use config file
115  } else {
116  // first individuals are put
117  for (auto& moduleParam : ModuleParameters_) {
118  if (moduleParam.getParameter<unsigned int>("rawid") == detid.rawId()) {
119  float lorentzangle = static_cast<float>(moduleParam.getParameter<double>("angle"));
120  if (!found) {
121  LorentzAngle.putLorentzAngle(detid.rawId(), lorentzangle);
122  LogPrint("SiPixelLorentzAngleDBLoader")
123  << " >> LA=" << lorentzangle << " individual value " << detid.rawId();
124  found = 1;
125  } else {
126  LogError("SiPixelLorentzAngleDBLoader") << "ERROR!: detid already exists";
127  }
128  }
129  } // end on loop for ModuleParameters_
130 
131  //modules already put are automatically skipped
132  for (auto& bpixParam : BPixParameters_) {
133  if (bpixParam.exists("layer")) {
134  if (bpixParam.getParameter<int>("layer") != layer)
135  continue;
136  if (bpixParam.exists("ladder"))
137  if (bpixParam.getParameter<int>("ladder") != ladder)
138  continue;
139  if (bpixParam.exists("module"))
140  if (bpixParam.getParameter<int>("module") != module)
141  continue;
142  if (bpixParam.exists("side"))
143  if (bpixParam.getParameter<int>("side") != side)
144  continue;
145  if (!found) {
146  float lorentzangle = static_cast<float>(bpixParam.getParameter<double>("angle"));
147  LorentzAngle.putLorentzAngle(detid.rawId(), lorentzangle);
148  LogPrint("SiPixelLorentzAngleDBLoader") << " >> LA=" << lorentzangle;
149  found = 2;
150  } else if (found == 1) {
151  LogPrint("SiPixelLorentzAngleDBLoader") << "The detid already given in ModuleParameters, skipping ...";
152  } else
153  LogError("SiPixelLorentzAngleDBLoader") << "ERROR!: detid already exists";
154  }
155  }
156  } // condition to read from config
157 
158  // fill fpix values for LA (for phase2 fpix & epix)
159  } else if (detid.subdetId() == static_cast<int>(PixelSubdetector::PixelEndcap)) {
160  // Convert to online
161  PixelEndcapName pen(detid, tTopo, true);
162  int disk = pen.diskName();
163  int blade = pen.bladeName();
164  int panel = pen.pannelName();
165  int ring = pen.ringName();
166 
167  LogPrint("SiPixelLorentzAngleDBLoader") << " pixel endcap:"
168  << " side=" << side << " disk=" << disk << " blade=" << blade
169  << " pannel=" << panel << " ring=" << ring << " rawId=" << rawId;
170 
171  // use a commmon value (e.g. for MC)
172  if (fPixLorentzAnglePerTesla_ != -9999.) { // use common value for all
173  LogPrint("SiPixelLorentzAngleDBLoader") << " LA =" << fPixLorentzAnglePerTesla_ << " common for all FPix";
174  if (!LorentzAngle.putLorentzAngle(detid.rawId(), fPixLorentzAnglePerTesla_)) {
175  LogError("SiPixelLorentzAngleDBLoader") << "detid already exists";
176  }
177 
178  } else if (useFile_) {
179  LogPrint("SiPixelLorentzAngleDBLoader") << "method for reading file not implemented yet";
180 
181  } else {
182  //first individuals are put
183  for (auto& parameter : ModuleParameters_) {
184  if (parameter.getParameter<unsigned int>("rawid") == detid.rawId()) {
185  float lorentzangle = static_cast<float>(parameter.getParameter<double>("angle"));
186  if (!found) {
187  LorentzAngle.putLorentzAngle(detid.rawId(), lorentzangle);
188  LogPrint("SiPixelLorentzAngleDBLoader")
189  << " LA=" << lorentzangle << " individual value " << detid.rawId();
190  found = 1;
191  } else
192  LogError("SiPixelLorentzAngleDBLoader") << "ERROR!: detid already exists";
193  }
194  } // end loop on ModuleParameters_
195 
196  // modules already put are automatically skipped
197  for (auto& fpixParam : FPixParameters_) {
198  if (fpixParam.exists("side"))
199  if (fpixParam.getParameter<int>("side") != side)
200  continue;
201  if (fpixParam.exists("disk"))
202  if (fpixParam.getParameter<int>("disk") != disk)
203  continue;
204  if (fpixParam.exists("ring"))
205  if (fpixParam.getParameter<int>("ring") != ring)
206  continue;
207  if (fpixParam.exists("blade"))
208  if (fpixParam.getParameter<int>("blade") != blade)
209  continue;
210  if (fpixParam.exists("panel"))
211  if (fpixParam.getParameter<int>("panel") != panel)
212  continue;
213  if (fpixParam.exists("HVgroup"))
214  if (fpixParam.getParameter<int>("HVgroup") != HVgroup(panel, ring))
215  continue;
216  if (!found) {
217  float lorentzangle = static_cast<float>(fpixParam.getParameter<double>("angle"));
218  LorentzAngle.putLorentzAngle(detid.rawId(), lorentzangle);
219  LogPrint("SiPixelLorentzAngleDBLoader") << " >> LA=" << lorentzangle;
220  found = 2;
221  } else if (found == 1) {
222  LogPrint("SiPixelLorentzAngleDBLoader") << "The detid already given in ModuleParameters, skipping ...";
223  } else
224  LogError("SiPixelLorentzAngleDBLoader") << " ERROR!: detid already exists";
225  } // end loop on FPixParameters_
226  } // condition to read from config
227  } // end on being barrel or endcap
228  }
229  }
230 
232  if (mydbservice.isAvailable()) {
233  try {
234  if (mydbservice->isNewTagRequest(recordName_)) {
235  mydbservice->createOneIOV<SiPixelLorentzAngle>(LorentzAngle, mydbservice->beginOfTime(), recordName_);
236  } else {
237  mydbservice->appendOneIOV<SiPixelLorentzAngle>(LorentzAngle, mydbservice->currentTime(), recordName_);
238  }
239  } catch (const cond::Exception& er) {
240  LogPrint("SiPixelLorentzAngleDBLoader") << "SiPixelLorentzAngleDBLoader" << er.what();
241  } catch (const std::exception& er) {
242  LogPrint("SiPixelLorentzAngleDBLoader") << "SiPixelLorentzAngleDBLoader"
243  << "caught std::exception " << er.what();
244  }
245  } else {
246  LogPrint("SiPixelLorentzAngleDBLoader") << "Service is unavailable";
247  }
248 }
unsigned int pxbLayer(const DetId &id) const
Base exception class for the object to relational access.
Definition: Exception.h:11
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > tkGeomToken_
const DetContainer & detUnits() const override
Returm a vector of all GeomDet.
unsigned int pxbLadder(const DetId &id) const
Log< level::Error, false > LogError
unsigned int side(const DetId &id) const
void createOneIOV(const T &payload, cond::Time_t firstSinceTime, const std::string &recordName)
void appendOneIOV(const T &payload, cond::Time_t sinceTime, const std::string &recordName)
bool isNewTagRequest(const std::string &recordName)
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
Log< level::Warning, true > LogPrint
Basic3DVector unit() const
Definition: DetId.h:17
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
bool isAvailable() const
Definition: Service.h:40
unsigned int pxbModule(const DetId &id) const
char const * what() const noexcept override
Definition: Exception.cc:107
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tkTopoToken_

◆ HVgroup()

int SiPixelLorentzAngleDBLoader::HVgroup ( int  panel,
int  module 
)
private

Definition at line 250 of file SiPixelLorentzAngleDBLoader.cc.

Referenced by analyze().

250  {
251  if (1 == panel && (1 == module || 2 == module)) {
252  return 1;
253  } else if (1 == panel && (3 == module || 4 == module)) {
254  return 2;
255  } else if (2 == panel && 1 == module) {
256  return 1;
257  } else if (2 == panel && (2 == module || 3 == module)) {
258  return 2;
259  } else {
260  LogError("SiPixelLorentzAngleDBLoader")
261  << " *** error *** in SiPixelLorentzAngleDBLoader::HVgroup(...), panel = " << panel << ", module = " << module
262  << endl;
263  return 0;
264  }
265 }
Log< level::Error, false > LogError

Member Data Documentation

◆ bPixLorentzAnglePerTesla_

float SiPixelLorentzAngleDBLoader::bPixLorentzAnglePerTesla_
private

Definition at line 43 of file SiPixelLorentzAngleDBLoader.cc.

Referenced by analyze(), and SiPixelLorentzAngleDBLoader().

◆ BPixParameters_

const Parameters SiPixelLorentzAngleDBLoader::BPixParameters_
private

Definition at line 40 of file SiPixelLorentzAngleDBLoader.cc.

Referenced by analyze().

◆ detid_la

std::vector<std::pair<uint32_t, float> > SiPixelLorentzAngleDBLoader::detid_la
private

Definition at line 48 of file SiPixelLorentzAngleDBLoader.cc.

◆ fileName_

const std::string SiPixelLorentzAngleDBLoader::fileName_
private

Definition at line 39 of file SiPixelLorentzAngleDBLoader.cc.

◆ fPixLorentzAnglePerTesla_

float SiPixelLorentzAngleDBLoader::fPixLorentzAnglePerTesla_
private

Definition at line 44 of file SiPixelLorentzAngleDBLoader.cc.

Referenced by analyze(), and SiPixelLorentzAngleDBLoader().

◆ FPixParameters_

const Parameters SiPixelLorentzAngleDBLoader::FPixParameters_
private

Definition at line 41 of file SiPixelLorentzAngleDBLoader.cc.

Referenced by analyze().

◆ ModuleParameters_

const Parameters SiPixelLorentzAngleDBLoader::ModuleParameters_
private

Definition at line 42 of file SiPixelLorentzAngleDBLoader.cc.

Referenced by analyze().

◆ recordName_

const std::string SiPixelLorentzAngleDBLoader::recordName_
private

Definition at line 37 of file SiPixelLorentzAngleDBLoader.cc.

Referenced by analyze().

◆ tkGeomToken_

const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> SiPixelLorentzAngleDBLoader::tkGeomToken_
private

Definition at line 35 of file SiPixelLorentzAngleDBLoader.cc.

Referenced by analyze().

◆ tkTopoToken_

const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> SiPixelLorentzAngleDBLoader::tkTopoToken_
private

Definition at line 36 of file SiPixelLorentzAngleDBLoader.cc.

Referenced by analyze().

◆ useFile_

const bool SiPixelLorentzAngleDBLoader::useFile_
private

Definition at line 38 of file SiPixelLorentzAngleDBLoader.cc.

Referenced by analyze().