CMS 3D CMS Logo

SiPixelStatusProducer.h
Go to the documentation of this file.
1 #ifndef CalibTracker_SiPixelQuality_SiPixelStatusProducer_h
2 #define CalibTracker_SiPixelQuality_SiPixelStatusProducer_h
3 
10 // C++ standard
11 #include <cstring>
12 #include <fstream>
13 #include <iostream>
14 #include <memory>
15 
16 #include <string>
17 // // CMS FW
27 // Concurrency
30 
34 
35 // // Pixel data format
42 // Tracker Geo
47 // SiPixelTopoFinder
49 // SiPixelDetectorStatus
51 
52 /* Cache to pertain SiPixelTopoFinder */
54 public:
55  //NOTE: these are only changes in the constructor call
59 };
60 
61 /*|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/
62 
64 
65  public edm::stream::EDProducer<edm::GlobalCache<SiPixelStatusCache>,
66  edm::RunCache<SiPixelTopoFinder>,
67  edm::LuminosityBlockSummaryCache<std::vector<SiPixelDetectorStatus>>,
68  edm::EndLuminosityBlockProducer,
69  edm::Accumulator> {
70 public:
72  ~SiPixelStatusProducer() override;
73 
74  /* module description */
75  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
77  {
79  psd0.addUntracked<edm::InputTag>("pixelClusterLabel", edm::InputTag("siPixelClusters", "", "RECO"));
80  psd0.add<std::vector<edm::InputTag>>("badPixelFEDChannelCollections",
81  {
82  edm::InputTag("siPixelDigis"),
83  });
84  desc.add<edm::ParameterSetDescription>("SiPixelStatusProducerParameters", psd0);
85  }
86  descriptions.add("siPixelStatusProducer", desc);
87  }
88 
89  /*|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/
90 
91  /* For each instance of the module*/
92  void beginRun(edm::Run const&, edm::EventSetup const&) final;
93 
95  void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) final;
96 
97  void accumulate(edm::Event const& iEvent, edm::EventSetup const& iSetup) final;
98 
100  edm::EventSetup const&,
101  std::vector<SiPixelDetectorStatus>* siPixelDetectorStatusVtr) const final; //override;
102 
103  /* For global or runCache */
104 
105  static std::unique_ptr<SiPixelStatusCache> initializeGlobalCache(edm::ParameterSet const& iPSet) {
106  edm::LogInfo("SiPixelStatusProducer") << "Init global Cache " << std::endl;
107  return std::make_unique<SiPixelStatusCache>();
108  }
109 
110  static std::shared_ptr<SiPixelTopoFinder> globalBeginRun(edm::Run const& iRun,
111  edm::EventSetup const& iSetup,
112  GlobalCache const* iCache);
113 
114  static void globalEndRun(edm::Run const& iRun, edm::EventSetup const&, RunContext const* iContext) {
115  /* Do nothing */
116  }
117 
118  static void globalEndJob(SiPixelStatusCache const*) { /* Do nothing */
119  }
120 
121  static std::shared_ptr<std::vector<SiPixelDetectorStatus>> globalBeginLuminosityBlockSummary(
123  return std::make_shared<std::vector<SiPixelDetectorStatus>>();
124  }
125 
127  edm::EventSetup const&,
128  LuminosityBlockContext const* iContext,
129  std::vector<SiPixelDetectorStatus>*) {
130  /* Do nothing */
131  }
132 
134  edm::EventSetup const&,
135  LuminosityBlockContext const* iContext,
136  std::vector<SiPixelDetectorStatus> const* siPixelDetectorStatusVtr) {
137  edm::LogInfo("SiPixelStatusProducer") << "Global endlumi producer " << std::endl;
138 
139  // only save result for non-zero event lumi block
140  if (!siPixelDetectorStatusVtr->empty()) {
141  int lumi = iLumi.luminosityBlock();
142  int run = iLumi.run();
143 
144  SiPixelDetectorStatus siPixelDetectorStatus = SiPixelDetectorStatus();
145  for (unsigned int instance = 0; instance < siPixelDetectorStatusVtr->size(); instance++) {
146  siPixelDetectorStatus.updateDetectorStatus((*siPixelDetectorStatusVtr)[instance]);
147  }
148 
149  siPixelDetectorStatus.setRunRange(run, run);
150  siPixelDetectorStatus.setLSRange(lumi, lumi);
151 
152  if (debug_) {
153  std::string outTxt = Form("SiPixelDetectorStatus_Run%d_Lumi%d.txt", run, lumi);
154  std::ofstream outFile;
155  outFile.open(outTxt.c_str(), std::ios::app);
156  siPixelDetectorStatus.dumpToFile(outFile);
157  outFile.close();
158  }
159 
160  /* save result */
161  auto result = std::make_unique<SiPixelDetectorStatus>();
162  *result = siPixelDetectorStatus;
163 
164  iLumi.put(std::move(result), std::string("siPixelStatus"));
165  edm::LogInfo("SiPixelStatusProducer")
166  << " lumi-based data stored for run " << run << " lumi " << lumi << std::endl;
167  }
168  }
169 
170 private:
171  virtual int indexROC(int irow, int icol, int nROCcolumns) final;
172 
173  /* ParameterSet */
174  static const bool debug_ = false;
175 
178  std::vector<edm::EDGetTokenT<PixelFEDChannelCollection>> theBadPixelFEDChannelsTokens_;
179 
180  /*|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/
181  /* private data member, one instance per stream */
182 
183  /* per-Run data (The pixel topo cannot be changed during a Run) */
184  /* vector of all <int> detIds */
185  std::vector<int> fDetIds_;
186  /* ROC size (number of row, number of columns for each det id) */
187  std::map<int, std::pair<int, int>> fSensors_;
188  /* the roc layout on a module */
189  std::map<int, std::pair<int, int>> fSensorLayout_;
190  /* fedId as a function of detId */
191  std::unordered_map<uint32_t, unsigned int> fFedIds_;
192  /* map the index ROC to rocId */
193  std::map<int, std::map<int, int>> fRocIds_;
194 
195  /* per-LuminosityBlock data */
196  unsigned long int ftotalevents_;
197 
199  int endLumi_;
201  int endRun_;
202 
203  /* Channels always have FEDerror25 for all events in the lumisection */
204  std::map<int, std::vector<PixelFEDChannel>> fFEDerror25_;
205 
206  // Producer production (output collection)
208 };
209 
210 #endif
ConfigurationDescriptions.h
SiPixelStatusProducer::fFEDerror25_
std::map< int, std::vector< PixelFEDChannel > > fFEDerror25_
Definition: SiPixelStatusProducer.h:204
edm::stream::EDProducer< edm::GlobalCache< SiPixelStatusCache >, edm::RunCache< SiPixelTopoFinder >, edm::LuminosityBlockSummaryCache< std::vector< SiPixelDetectorStatus > >, edm::EndLuminosityBlockProducer, edm::Accumulator >::GlobalCache
typename CacheTypes::GlobalCache GlobalCache
Definition: EDProducer.h:43
SiPixelStatusProducer::ftotalevents_
unsigned long int ftotalevents_
Definition: SiPixelStatusProducer.h:196
SiPixelTopoFinder.h
SiPixelStatusCache::siPixelFedCablingMapToken_
edm::ESGetToken< SiPixelFedCablingMap, SiPixelFedCablingMapRcd > siPixelFedCablingMapToken_
Definition: SiPixelStatusProducer.h:58
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
SiPixelStatusProducer::SiPixelStatusProducer
SiPixelStatusProducer(edm::ParameterSet const &iPSet, SiPixelStatusCache const *)
Definition: SiPixelStatusProducer.cc:30
SiPixelStatusProducer::globalBeginRun
static std::shared_ptr< SiPixelTopoFinder > globalBeginRun(edm::Run const &iRun, edm::EventSetup const &iSetup, GlobalCache const *iCache)
Definition: SiPixelStatusProducer.cc:59
TrackerGeometry.h
SiPixelStatusProducer::theBadPixelFEDChannelsTokens_
std::vector< edm::EDGetTokenT< PixelFEDChannelCollection > > theBadPixelFEDChannelsTokens_
Definition: SiPixelStatusProducer.h:178
SiPixelStatusProducer::fSensors_
std::map< int, std::pair< int, int > > fSensors_
Definition: SiPixelStatusProducer.h:187
edm::LuminosityBlock
Definition: LuminosityBlock.h:50
SiPixelStatusProducer
Definition: SiPixelStatusProducer.h:63
SiPixelStatusProducer::fSensorLayout_
std::map< int, std::pair< int, int > > fSensorLayout_
Definition: SiPixelStatusProducer.h:189
edm::Run
Definition: Run.h:45
edm::EDGetTokenT
Definition: EDGetToken.h:33
SiPixelStatusProducer::globalBeginLuminosityBlockSummary
static std::shared_ptr< std::vector< SiPixelDetectorStatus > > globalBeginLuminosityBlockSummary(edm::LuminosityBlock const &, edm::EventSetup const &, LuminosityBlockContext const *)
Definition: SiPixelStatusProducer.h:121
LuminosityBlock.h
SiPixelStatusProducer::globalEndLuminosityBlockSummary
static void globalEndLuminosityBlockSummary(edm::LuminosityBlock const &, edm::EventSetup const &, LuminosityBlockContext const *iContext, std::vector< SiPixelDetectorStatus > *)
Definition: SiPixelStatusProducer.h:126
SiPixelStatusProducer::initializeGlobalCache
static std::unique_ptr< SiPixelStatusCache > initializeGlobalCache(edm::ParameterSet const &iPSet)
Definition: SiPixelStatusProducer.h:105
PixelFEDChannel.h
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
SiPixelStatusProducer::fSiPixelClusterToken_
edm::EDGetTokenT< edmNew::DetSetVector< SiPixelCluster > > fSiPixelClusterToken_
Definition: SiPixelStatusProducer.h:177
SiPixelStatusProducer::globalEndLuminosityBlockProduce
static void globalEndLuminosityBlockProduce(edm::LuminosityBlock &iLumi, edm::EventSetup const &, LuminosityBlockContext const *iContext, std::vector< SiPixelDetectorStatus > const *siPixelDetectorStatusVtr)
Definition: SiPixelStatusProducer.h:133
EDProducer.h
SiPixelFedCablingMap.h
SiPixelStatusProducer::endLumi_
int endLumi_
Definition: SiPixelStatusProducer.h:199
SiPixelStatusProducer::globalEndRun
static void globalEndRun(edm::Run const &iRun, edm::EventSetup const &, RunContext const *iContext)
Definition: SiPixelStatusProducer.h:114
SiPixelDetectorStatus::setLSRange
void setLSRange(int ls0, int ls1)
Definition: SiPixelDetectorStatus.h:63
edm::LuminosityBlockBase::run
RunNumber_t run() const
Definition: LuminosityBlockBase.h:42
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
ESGetToken.h
SiPixelStatusProducer::fDetIds_
std::vector< int > fDetIds_
Definition: SiPixelStatusProducer.h:185
edm::stream::RunContextT
Definition: Contexts.h:31
SiPixelStatusProducer::endLuminosityBlockSummary
void endLuminosityBlockSummary(edm::LuminosityBlock const &iLumi, edm::EventSetup const &, std::vector< SiPixelDetectorStatus > *siPixelDetectorStatusVtr) const final
Definition: SiPixelStatusProducer.cc:276
SiPixelStatusProducer::fRocIds_
std::map< int, std::map< int, int > > fRocIds_
Definition: SiPixelStatusProducer.h:193
SiPixelDetectorStatus
Definition: SiPixelDetectorStatus.h:11
SiPixelDetectorStatus::dumpToFile
void dumpToFile(std::ofstream &outFile)
Definition: SiPixelDetectorStatus.cc:85
TrackerTopology.h
SiPixelStatusProducer::endLuminosityBlock
void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) final
Definition: SiPixelStatusProducer.cc:255
ReusableObjectHolder.h
TrackerTopologyRcd.h
SerialTaskQueue.h
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
SiPixelStatusProducer::fFedIds_
std::unordered_map< uint32_t, unsigned int > fFedIds_
Definition: SiPixelStatusProducer.h:191
edm::LuminosityBlockBase::luminosityBlock
LuminosityBlockNumber_t luminosityBlock() const
Definition: LuminosityBlockBase.h:40
SiPixelStatusProducer::debug_
static const bool debug_
Definition: SiPixelStatusProducer.h:174
SiPixelStatusProducer::accumulate
void accumulate(edm::Event const &iEvent, edm::EventSetup const &iSetup) final
Definition: SiPixelStatusProducer.cc:106
Transition.h
SiPixelStatusProducer::beginRun_
int beginRun_
Definition: SiPixelStatusProducer.h:200
SiPixelStatusProducer::beginRun
void beginRun(edm::Run const &, edm::EventSetup const &) final
Definition: SiPixelStatusProducer.cc:72
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
L1TdeCSCTF_cfi.outFile
outFile
Definition: L1TdeCSCTF_cfi.py:5
edm::ParameterSetDescription::addUntracked
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:100
TrackerDigiGeometryRecord.h
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
SiPixelFedCablingMapRcd.h
SiPixelStatusProducer::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: SiPixelStatusProducer.h:75
iEvent
int iEvent
Definition: GenABIO.cc:224
SiPixelStatusProducer::~SiPixelStatusProducer
~SiPixelStatusProducer() override
Definition: SiPixelStatusProducer.cc:55
edm::stream::EDProducer
Definition: EDProducer.h:36
SiPixelStatusProducer::globalEndJob
static void globalEndJob(SiPixelStatusCache const *)
Definition: SiPixelStatusProducer.h:118
edm::EventSetup
Definition: EventSetup.h:58
SiPixelStatusProducer::endRun_
int endRun_
Definition: SiPixelStatusProducer.h:201
edm::LuminosityBlock::put
void put(std::unique_ptr< PROD > product)
Put a new product.
Definition: LuminosityBlock.h:116
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord >
instance
static PFTauRenderPlugin instance
Definition: PFTauRenderPlugin.cc:70
edm::stream::LuminosityBlockContextT
Definition: Contexts.h:43
SiPixelDetectorStatus::updateDetectorStatus
void updateDetectorStatus(SiPixelDetectorStatus newData)
Definition: SiPixelDetectorStatus.cc:207
SiPixelDetectorStatus.h
SiPixelStatusCache::trackerTopologyToken_
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > trackerTopologyToken_
Definition: SiPixelStatusProducer.h:57
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition: eostools.py:511
writedatasetfile.run
run
Definition: writedatasetfile.py:27
SiPixelStatusProducer::fPixelClusterLabel_
edm::InputTag fPixelClusterLabel_
Definition: SiPixelStatusProducer.h:176
SiPixelStatusProducer::beginLumi_
int beginLumi_
Definition: SiPixelStatusProducer.h:198
DetId.h
Frameworkfwd.h
ESWatcher.h
SiPixelStatusCache::trackerGeometryToken_
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > trackerGeometryToken_
Definition: SiPixelStatusProducer.h:56
SiPixelStatusProducer::indexROC
virtual int indexROC(int irow, int icol, int nROCcolumns) final
Definition: SiPixelStatusProducer.cc:288
EventSetup.h
SiPixelStatusCache
Definition: SiPixelStatusProducer.h:53
SiPixelDetectorStatus::setRunRange
void setRunRange(int run0, int run1)
Definition: SiPixelDetectorStatus.h:57
mps_fire.result
result
Definition: mps_fire.py:311
ConsumesCollector.h
SiPixelStatusProducer::fDet_
SiPixelDetectorStatus fDet_
Definition: SiPixelStatusProducer.h:207
ParameterSet.h
edm::Event
Definition: Event.h:73
lumi
Definition: LumiSectionData.h:20
SiPixelStatusProducer::beginLuminosityBlock
void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) final
Definition: SiPixelStatusProducer.cc:90
DetSetVectorNew.h
edm::InputTag
Definition: InputTag.h:15