CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
94  void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) final;
95  void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) final;
96 
97  void accumulate(edm::Event const& iEvent, edm::EventSetup const& iSetup) final;
98 
99  void endLuminosityBlockSummary(edm::LuminosityBlock const& iLumi,
100  edm::EventSetup const&,
101  std::vector<SiPixelDetectorStatus>* siPixelDetectorStatusVtr) const final; //override;
102 
103  /* For global or runCache */
104 
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
static void globalEndJob(SiPixelStatusCache const *)
static std::shared_ptr< SiPixelTopoFinder > globalBeginRun(edm::Run const &iRun, edm::EventSetup const &iSetup, GlobalCache const *iCache)
void updateDetectorStatus(SiPixelDetectorStatus newData)
std::map< int, std::pair< int, int > > fSensors_
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
static void globalEndLuminosityBlockProduce(edm::LuminosityBlock &iLumi, edm::EventSetup const &, LuminosityBlockContext const *iContext, std::vector< SiPixelDetectorStatus > const *siPixelDetectorStatusVtr)
static PFTauRenderPlugin instance
std::vector< int > fDetIds_
edm::ESGetToken< SiPixelFedCablingMap, SiPixelFedCablingMapRcd > siPixelFedCablingMapToken_
static std::shared_ptr< std::vector< SiPixelDetectorStatus > > globalBeginLuminosityBlockSummary(edm::LuminosityBlock const &, edm::EventSetup const &, LuminosityBlockContext const *)
void dumpToFile(std::ofstream &outFile)
unsigned long int ftotalevents_
std::unique_ptr< T, impl::DeviceDeleter > unique_ptr
std::unordered_map< uint32_t, unsigned int > fFedIds_
tuple result
Definition: mps_fire.py:311
LuminosityBlockNumber_t luminosityBlock() const
int iEvent
Definition: GenABIO.cc:224
void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) final
SiPixelDetectorStatus fDet_
void put(std::unique_ptr< PROD > product)
Put a new product.
std::vector< edm::EDGetTokenT< PixelFEDChannelCollection > > theBadPixelFEDChannelsTokens_
static void globalEndRun(edm::Run const &iRun, edm::EventSetup const &, RunContext const *iContext)
edm::EDGetTokenT< edmNew::DetSetVector< SiPixelCluster > > fSiPixelClusterToken_
def move
Definition: eostools.py:511
RunNumber_t run() const
void setLSRange(int ls0, int ls1)
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > trackerTopologyToken_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
list lumi
Definition: dqmdumpme.py:53
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > trackerGeometryToken_
Log< level::Info, false > LogInfo
std::map< int, std::vector< PixelFEDChannel > > fFEDerror25_
static void globalEndLuminosityBlockSummary(edm::LuminosityBlock const &, edm::EventSetup const &, LuminosityBlockContext const *iContext, std::vector< SiPixelDetectorStatus > *)
static std::unique_ptr< SiPixelStatusCache > initializeGlobalCache(edm::ParameterSet const &iPSet)
std::map< int, std::pair< int, int > > fSensorLayout_
void accumulate(edm::Event const &iEvent, edm::EventSetup const &iSetup) final
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void setRunRange(int run0, int run1)
SiPixelStatusProducer(edm::ParameterSet const &iPSet, SiPixelStatusCache const *)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void beginRun(edm::Run const &, edm::EventSetup const &) final
void endLuminosityBlockSummary(edm::LuminosityBlock const &iLumi, edm::EventSetup const &, std::vector< SiPixelDetectorStatus > *siPixelDetectorStatusVtr) const final
std::map< int, std::map< int, int > > fRocIds_
void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) final
virtual int indexROC(int irow, int icol, int nROCcolumns) final
Definition: Run.h:45