CMS 3D CMS Logo

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

Public Types

typedef std::vector< std::string > vstring
 
- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 

Public Member Functions

 SiPixel2DTemplateDBObjectUploader (const edm::ParameterSet &)
 
 ~SiPixel2DTemplateDBObjectUploader () override
 
- Public Member Functions inherited from edm::one::EDAnalyzer<>
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const noexcept final
 
bool wantsGlobalRuns () const noexcept final
 
bool wantsInputProcessBlocks () const noexcept final
 
bool wantsProcessBlocks () const noexcept 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 noexcept
 
bool wantsStreamRuns () const noexcept
 
 ~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 Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
void beginJob () override
 
void endJob () override
 

Private Attributes

vstring theBarrelLocations
 
std::vector< uint32_t > theBarrelTemplateIds
 
std::vector< uint32_t > theDetIds
 
vstring theEndcapLocations
 
std::vector< uint32_t > theEndcapTemplateIds
 
float theMagField
 
std::string theTemplateBaseString
 
vstring theTemplateCalibrations
 
float theVersion
 
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecordtrackerGeometryToken_
 
edm::ESGetToken< TrackerTopology, TrackerTopologyRcdtrackerTopologyToken_
 
bool useVectorIndices
 

Additional Inherited Members

- 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 34 of file SiPixel2DTemplateDBObjectUploader.cc.

Member Typedef Documentation

◆ vstring

typedef std::vector<std::string> SiPixel2DTemplateDBObjectUploader::vstring

Definition at line 39 of file SiPixel2DTemplateDBObjectUploader.cc.

Constructor & Destructor Documentation

◆ SiPixel2DTemplateDBObjectUploader()

SiPixel2DTemplateDBObjectUploader::SiPixel2DTemplateDBObjectUploader ( const edm::ParameterSet iConfig)
explicit

Definition at line 60 of file SiPixel2DTemplateDBObjectUploader.cc.

61  : theTemplateCalibrations(iConfig.getParameter<vstring>("siPixelTemplateCalibrations")),
62  theTemplateBaseString(iConfig.getParameter<std::string>("theTemplateBaseString")),
63  theVersion(iConfig.getParameter<double>("Version")),
64  theMagField(iConfig.getParameter<double>("MagField")),
65  theBarrelLocations(iConfig.getParameter<std::vector<std::string> >("barrelLocations")),
66  theEndcapLocations(iConfig.getParameter<std::vector<std::string> >("endcapLocations")),
67  theBarrelTemplateIds(iConfig.getParameter<std::vector<uint32_t> >("barrelTemplateIds")),
68  theEndcapTemplateIds(iConfig.getParameter<std::vector<uint32_t> >("endcapTemplateIds")),
69  useVectorIndices(iConfig.getUntrackedParameter<bool>("useVectorIndices", false)),
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > trackerGeometryToken_
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
vector< string > vstring
Definition: ExoticaDQM.cc:7
T getUntrackedParameter(std::string const &, T const &) const
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > trackerTopologyToken_

◆ ~SiPixel2DTemplateDBObjectUploader()

SiPixel2DTemplateDBObjectUploader::~SiPixel2DTemplateDBObjectUploader ( )
overridedefault

Member Function Documentation

◆ analyze()

void SiPixel2DTemplateDBObjectUploader::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 77 of file SiPixel2DTemplateDBObjectUploader.cc.

References cond::service::PoolDBOutputService::beginOfTime(), DummyCfis::c, cond::service::PoolDBOutputService::currentTime(), ALCARECOPPSCalTrackBasedSel_cff::detid, TrackerGeometry::detUnits(), geometryDiff::file, TrackerGeometry::geomDetSubDetector(), edm::EventSetup::getData(), edm::EventSetup::getHandle(), recoMuon::in, runGCPTkAlMap::in_file, createfilelist::int, edm::Service< T >::isAvailable(), cond::service::PoolDBOutputService::isNewTagRequest(), TrackerGeometry::isThere(), ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, dqmiolumiharvest::j, PVValHelper::ladder, nano_mu_digi_cff::layer, visualization-live-secondInstance_cfg::m, callgraph::module, getGTfromDQMFile::obj, GeomDetEnumerators::P1PXB, GeomDetEnumerators::P1PXEC, GeomDetEnumerators::P2PXB, GeomDetEnumerators::P2PXEC, PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, TrackerTopology::pxbLadder(), TrackerTopology::pxbLayer(), TrackerTopology::pxbModule(), TrackerTopology::pxfBlade(), TrackerTopology::pxfDisk(), TrackerTopology::pxfPanel(), TrackerTopology::pxfSide(), ALPAKA_ACCELERATOR_NAMESPACE::ecal::reconstruction::internal::barrel::side(), AlCaHLTBitMon_QueryRunRegistry::string, groupFilesInBlocks::temp, theBarrelLocations, theBarrelTemplateIds, theEndcapLocations, theEndcapTemplateIds, theTemplateCalibrations, theVersion, trackerGeometryToken_, trackerTopologyToken_, useVectorIndices, and cond::service::PoolDBOutputService::writeOneIOV().

77  {
78  //--- Make the POOL-ORA object to store the database object
80 
81  // Local variables
82  int m;
83 
84  // Set the number of templates to be passed to the dbobject
85  obj.setNumOfTempl(theTemplateCalibrations.size());
86  // Set the version of the template dbobject - this is an external parameter
87  obj.setVersion(theVersion);
88 
89  // Open the template file(s)
90  for (m = 0; m < obj.numOfTempl(); ++m) {
92  std::ifstream in_file(file.fullPath().c_str(), std::ios::in);
93  if (in_file.is_open()) {
94  edm::LogInfo("Template Info") << "Opened Template File: " << file.fullPath().c_str();
95 
96  // Local variables
97  char title_char[80], c;
99  float tempstore;
100  int iter, j;
101 
102  // Templates contain a header char - we must be clever about storing this
103  for (iter = 0; (c = in_file.get()) != '\n'; ++iter) {
104  if (iter < 79) {
105  title_char[iter] = c;
106  }
107  }
108  if (iter > 78) {
109  iter = 78;
110  }
111  title_char[iter + 1] = '\n';
112  for (j = 0; j < 80; j += 4) {
113  temp.c[0] = title_char[j];
114  temp.c[1] = title_char[j + 1];
115  temp.c[2] = title_char[j + 2];
116  temp.c[3] = title_char[j + 3];
117  obj.push_back(temp.f);
118  obj.setMaxIndex(obj.maxIndex() + 1);
119  }
120 
121  // Fill the dbobject
122  in_file >> tempstore;
123  while (!in_file.eof()) {
124  obj.setMaxIndex(obj.maxIndex() + 1);
125  obj.push_back(tempstore);
126  in_file >> tempstore;
127  }
128 
129  in_file.close();
130  } else {
131  // If file didn't open, report this
132  edm::LogError("SiPixel2DTemplateDBObjectUploader") << "Error opening File " << (file.fullPath()).c_str();
133  }
134  }
135 
136  //get TrackerGeometry from the event setup
138  const TrackerGeometry* tGeo = &iSetup.getData(trackerGeometryToken_);
139 
140  // Use the TrackerTopology class for layer/disk etc. number
141  const TrackerTopology* tTopo = &iSetup.getData(trackerTopologyToken_);
142 
143  // Check if we are using Phase-1 or Phase-2 geometry
144  int phase = 0;
146  phase = 1;
147  } else if (pDD->isThere(GeomDetEnumerators::P2PXB) && pDD->isThere(GeomDetEnumerators::P2PXEC) == true) {
148  phase = 2;
149  }
150  edm::LogPrint("SiPixel2DTemplateDBObjectUploader") << "Phase-" << phase << " geometry is used" << std::endl;
151 
152  //Loop over the detector elements and put template IDs in place
153  for (const auto& it : pDD->detUnits()) {
154  if (it != nullptr) {
155  // Here is the actual looping step over all DetIds:
156  DetId detid = it->geographicalId();
157  unsigned int layer = 0, ladder = 0, disk = 0, side = 0, blade = 0, panel = 0, module = 0;
158 
159  short thisID = 10000;
160  unsigned int iter;
161 
162  // Now we sort them into the Barrel and Endcap:
163  //Barrel Pixels first
164  if ((phase == 1 && detid.subdetId() == static_cast<int>(PixelSubdetector::PixelBarrel)) ||
165  (phase == 2 && tGeo->geomDetSubDetector(detid.subdetId()) == GeomDetEnumerators::P2PXB)) {
166  //Get the layer, ladder, and module corresponding to this detID
167  layer = tTopo->pxbLayer(detid.rawId());
168  ladder = tTopo->pxbLadder(detid.rawId());
169  module = tTopo->pxbModule(detid.rawId());
170 
171  if (useVectorIndices) {
172  --layer;
173  --ladder;
174  --module;
175  }
176 
177  //Assign template IDs
178  //Loop over all the barrel locations
179  for (iter = 0; iter < theBarrelLocations.size(); ++iter) {
180  //get the string of this barrel location
181  std::string loc_string = theBarrelLocations[iter];
182  //find where the delimiters are
183  unsigned int first_delim_pos = loc_string.find('_');
184  unsigned int second_delim_pos = loc_string.find('_', first_delim_pos + 1);
185  //get the layer, ladder, and module as unsigned ints
186  unsigned int checklayer = (unsigned int)stoi(loc_string.substr(0, first_delim_pos));
187  unsigned int checkladder =
188  (unsigned int)stoi(loc_string.substr(first_delim_pos + 1, second_delim_pos - first_delim_pos - 1));
189  unsigned int checkmodule = (unsigned int)stoi(loc_string.substr(second_delim_pos + 1, 5));
190  //check them against the desired layer, ladder, and module
191  if (ladder == checkladder && layer == checklayer && module == checkmodule)
192  //if they match, set the template ID
193  thisID = (short)theBarrelTemplateIds[iter];
194  }
195 
196  if (thisID == 10000 || (!obj.putTemplateID(detid.rawId(), thisID)))
197  edm::LogPrint("SiPixel2DTemplateDBObjectUploader")
198  << " Could not fill barrel layer " << layer << ", module " << module << "\n";
199  edm::LogPrint("SiPixel2DTemplateDBObjectUploader")
200  << "This is a barrel element with: layer " << layer << ", ladder " << ladder << " and module " << module;
201  }
202  //Now endcaps
203  else if ((phase == 1 && detid.subdetId() == static_cast<int>(PixelSubdetector::PixelEndcap)) ||
204  (phase == 2 && tGeo->geomDetSubDetector(detid.subdetId()) == GeomDetEnumerators::P2PXEC)) {
205  //Get the DetId's disk, blade, side, panel, and module
206  disk = tTopo->pxfDisk(detid.rawId()); //1,2,3
207  blade = tTopo->pxfBlade(detid.rawId()); //1-56 (Ring 1 is 1-22, Ring 2 is 23-56)
208  side = tTopo->pxfSide(detid.rawId()); //side=1 for -z, 2 for +z
209  panel = tTopo->pxfPanel(detid.rawId()); //panel=1,2
210 
211  if (useVectorIndices) {
212  --disk;
213  --blade;
214  --side;
215  --panel;
216  }
217 
218  //Assign IDs
219 
220  //Loop over all the endcap locations
221  for (iter = 0; iter < theEndcapLocations.size(); ++iter) {
222  //get the string of this barrel location
223  std::string loc_string = theEndcapLocations[iter];
224  //find where the delimiters are
225  unsigned int first_delim_pos = loc_string.find('_');
226  unsigned int second_delim_pos = loc_string.find('_', first_delim_pos + 1);
227  unsigned int third_delim_pos = loc_string.find('_', second_delim_pos + 1);
228  //get the disk, blade, side, panel, and module as unsigned ints
229  unsigned int checkdisk = (unsigned int)stoi(loc_string.substr(0, first_delim_pos));
230  unsigned int checkblade =
231  (unsigned int)stoi(loc_string.substr(first_delim_pos + 1, second_delim_pos - first_delim_pos - 1));
232  unsigned int checkside =
233  (unsigned int)stoi(loc_string.substr(second_delim_pos + 1, third_delim_pos - second_delim_pos - 1));
234  unsigned int checkpanel = (unsigned int)stoi(loc_string.substr(third_delim_pos + 1, 5));
235  //check them against the desired disk, blade, side, panel, and module
236  if (disk == checkdisk && blade == checkblade && side == checkside && panel == checkpanel)
237  //if they match, set the template ID
238  thisID = (short)theEndcapTemplateIds[iter];
239  }
240 
241  if (thisID == 10000 || (!obj.putTemplateID(detid.rawId(), thisID)))
242  edm::LogPrint("SiPixel2DTemplateDBObjectUploader")
243  << " Could not fill endcap det unit" << side << ", disk " << disk << ", blade " << blade << ", and panel "
244  << panel << ".\n";
245  edm::LogPrint("SiPixel2DTemplateDBObjectUploader")
246  << "This is an endcap element with: side " << side << ", disk " << disk << ", blade " << blade
247  << ", and panel " << panel;
248  } else {
249  continue;
250  }
251 
252  //Print out the assignment of this detID
253  short mapnum;
254  mapnum = obj.getTemplateID(detid.rawId());
255  edm::LogPrint("SiPixel2DTemplateDBObjectUploader")
256  << "The DetID: " << detid.rawId() << " is mapped to the template: " << mapnum << "\n";
257  }
258  }
259 
260  //--- Create a new IOV
262  if (!poolDbService.isAvailable()) // Die if not available
263  throw cms::Exception("NotAvailable") << "PoolDBOutputService not available";
264  if (poolDbService->isNewTagRequest("SiPixel2DTemplateDBObjectRcd"))
265  poolDbService->writeOneIOV(obj, poolDbService->beginOfTime(), "SiPixel2DTemplateDBObjectRcd");
266  else
267  poolDbService->writeOneIOV(obj, poolDbService->currentTime(), "SiPixel2DTemplateDBObjectRcd");
268 }
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > trackerGeometryToken_
unsigned int pxbLayer(const DetId &id) const
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
unsigned int pxfBlade(const DetId &id) const
const DetContainer & detUnits() const override
Returm a vector of all GeomDet.
unsigned int pxbLadder(const DetId &id) const
Log< level::Error, false > LogError
bool isNewTagRequest(const std::string &recordName)
bool isThere(GeomDetEnumerators::SubDetector subdet) const
unsigned int pxfDisk(const DetId &id) const
Hash writeOneIOV(const T &payload, Time_t time, const std::string &recordName)
Log< level::Warning, true > LogPrint
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130
unsigned int pxfPanel(const DetId &id) const
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > trackerTopologyToken_
Log< level::Info, false > LogInfo
Definition: DetId.h:17
unsigned int pxfSide(const DetId &id) const
const GeomDetEnumerators::SubDetector geomDetSubDetector(int subdet) const
bool isAvailable() const
Definition: Service.h:40
unsigned int pxbModule(const DetId &id) const

◆ beginJob()

void SiPixel2DTemplateDBObjectUploader::beginJob ( )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 75 of file SiPixel2DTemplateDBObjectUploader.cc.

75 {}

◆ endJob()

void SiPixel2DTemplateDBObjectUploader::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 270 of file SiPixel2DTemplateDBObjectUploader.cc.

270 {}

Member Data Documentation

◆ theBarrelLocations

vstring SiPixel2DTemplateDBObjectUploader::theBarrelLocations
private

Definition at line 51 of file SiPixel2DTemplateDBObjectUploader.cc.

Referenced by analyze().

◆ theBarrelTemplateIds

std::vector<uint32_t> SiPixel2DTemplateDBObjectUploader::theBarrelTemplateIds
private

Definition at line 53 of file SiPixel2DTemplateDBObjectUploader.cc.

Referenced by analyze().

◆ theDetIds

std::vector<uint32_t> SiPixel2DTemplateDBObjectUploader::theDetIds
private

Definition at line 50 of file SiPixel2DTemplateDBObjectUploader.cc.

◆ theEndcapLocations

vstring SiPixel2DTemplateDBObjectUploader::theEndcapLocations
private

Definition at line 52 of file SiPixel2DTemplateDBObjectUploader.cc.

Referenced by analyze().

◆ theEndcapTemplateIds

std::vector<uint32_t> SiPixel2DTemplateDBObjectUploader::theEndcapTemplateIds
private

Definition at line 54 of file SiPixel2DTemplateDBObjectUploader.cc.

Referenced by analyze().

◆ theMagField

float SiPixel2DTemplateDBObjectUploader::theMagField
private

Definition at line 49 of file SiPixel2DTemplateDBObjectUploader.cc.

◆ theTemplateBaseString

std::string SiPixel2DTemplateDBObjectUploader::theTemplateBaseString
private

Definition at line 47 of file SiPixel2DTemplateDBObjectUploader.cc.

◆ theTemplateCalibrations

vstring SiPixel2DTemplateDBObjectUploader::theTemplateCalibrations
private

Definition at line 46 of file SiPixel2DTemplateDBObjectUploader.cc.

Referenced by analyze().

◆ theVersion

float SiPixel2DTemplateDBObjectUploader::theVersion
private

Definition at line 48 of file SiPixel2DTemplateDBObjectUploader.cc.

Referenced by analyze().

◆ trackerGeometryToken_

edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> SiPixel2DTemplateDBObjectUploader::trackerGeometryToken_
private

Definition at line 56 of file SiPixel2DTemplateDBObjectUploader.cc.

Referenced by analyze().

◆ trackerTopologyToken_

edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> SiPixel2DTemplateDBObjectUploader::trackerTopologyToken_
private

Definition at line 57 of file SiPixel2DTemplateDBObjectUploader.cc.

Referenced by analyze().

◆ useVectorIndices

bool SiPixel2DTemplateDBObjectUploader::useVectorIndices
private

Definition at line 55 of file SiPixel2DTemplateDBObjectUploader.cc.

Referenced by analyze().