CMS 3D CMS Logo

SiPixelOfflineCalibAnalysisBase.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: SiPixelOfflineCalibAnalysisBase
4 // Class: SiPixelOfflineCalibAnalysisBase
5 //
13 //
14 // Original Author: Evan Klose Friis
15 // additions by: Freya Blekman
16 // Created: Tue Nov 6 17:27:19 CET 2007
17 //
18 //
19 
21 
25 
30 #include "TList.h"
31 
34 // constructors and destructor
35 //
37  : runnumbers_(0), eventCounter_(0) {
38  siPixelCalibDigiProducer_ = iConfig.getParameter<edm::InputTag>("DetSetVectorSiPixelCalibDigiTag");
39  createOutputFile_ = iConfig.getUntrackedParameter<bool>("saveFile", false);
40  outputFileName_ = iConfig.getParameter<std::string>("outputFileName");
43  tPixelCalibDigi = consumes<edm::DetSetVector<SiPixelCalibDigi> >(siPixelCalibDigiProducer_);
44 }
45 
47  throw cms::Exception("") << "ERROR: Classes derived from SiPixelOfflineCalibAnalysisBase must call "
48  "SiPixelOfflineCalibAnalysisBase::SiPixelOfflineCalibAnalysisBase(const "
49  "edm::ParameterSet& iConfig) from their constructor."
50  << std::endl;
51 }
52 
54 
55 //
56 // member functions
57 //
58 
59 // ------------ method called to for each event ------------
61  using namespace edm;
62 
66  if (eventCounter_ == 0)
67  this->calibrationSetup(iSetup);
68  eventCounter_++;
69 
70  // check first if you're analyzing the right type of calibration
72  return;
73 
74  uint32_t runnumber = iEvent.id().run();
75  if (runnumbers_.empty())
76  runnumbers_.push_back(runnumber);
77  else {
78  bool foundnumber = false;
79  for (size_t iter = 0; iter < runnumbers_.size() && !foundnumber; ++iter) {
80  if (runnumbers_[iter] == runnumber) {
81  foundnumber = true;
82  continue;
83  }
84  }
85  if (!foundnumber)
86  runnumbers_.push_back(runnumber);
87  }
88 
90  iEvent.getByToken(tPixelCalibDigi, thePlaquettes);
91 
93 
94  //loop over the plaquettes pulsed in this pattern
95  for (digiIter = thePlaquettes->begin(); digiIter != thePlaquettes->end(); ++digiIter) {
96  uint32_t detId = digiIter->id;
97  //check to see if this detID has not been encountered. If not, run the newDetID (pure virtual) function
98  if (detIdsEntered_.find(detId) == detIdsEntered_.end()) {
99  detIdsEntered_.insert(std::make_pair(detId, 0));
100  detIdNames_.insert(std::make_pair(detId, translateDetIdToString(detId)));
101  newDetID(detId);
102  }
104  //loop over pixels pulsed in the current plaquette
105  for (ipix = digiIter->data.begin(); ipix != digiIter->end(); ++ipix) {
106  //called derived function to fit this curve
107  this->doFits(detId, ipix);
108  }
109  }
110 }
111 
113  //load the calibration information from the database
117 
121  std::cout << "!!!! in beginRun" << std::endl;
122  edm::LogInfo("SiPixelOfflineCalibAnalysisBase")
123  << "Calibration file loaded. Mode: " << calibrationMode_ << " nTriggers: " << nTriggers_
124  << " Vcal steps: " << vCalValues_.size() << std::endl;
125  //call calibrationSetup virtual function
126  this->calibrationSetup(iSetup);
128 }
130 // ------------ method called once each job just before starting event loop ------------
131 
132 // ------------ method called once each job just after ending the event loop ------------
134  this->calibrationEnd();
135  edm::LogInfo("SiPixelOfflineCalibAnalysisBase") << "Running end job... output file name is: " << outputFileName_;
136  if (!outputFileName_.empty() && createOutputFile_) {
137  edm::LogInfo("SiPixelOfflineCalibAnalysisBase") << "Writing ROOT file to: " << outputFileName_ << std::endl;
139  }
140 }
141 
142 // ------------ helper functions ---------------------------------------------------------
143 
144 const std::vector<short>* SiPixelOfflineCalibAnalysisBase::getVcalValues() { return &vCalValues_; }
145 
147  std::map<uint32_t, std::string>::iterator detNameIter = detIdNames_.find(detid);
148  if (detNameIter != detIdNames_.end()) {
149  return detNameIter->second;
150  }
151  std::string output = "DetID translation error";
152  DetId detId(detid);
153  uint32_t detSubId = detId.subdetId();
154  if (detSubId > 2 || detSubId < 1) {
155  edm::LogError("SiPixelOfflineCalibAnalysisBase")
156  << "ERROR: Expected a pixel detector ID (1 - barrel, 2 - forward) but got " << detSubId << std::endl;
157  return output;
158  }
159  if (detSubId == 2) //FPIX
160  {
161  PixelEndcapName nameworker(detid);
162  output = nameworker.name();
163  } else //BPIX
164  {
165  PixelBarrelName nameworker(detid);
166  output = nameworker.name();
167  }
168  detIdNames_.insert(std::make_pair(detid, output));
169  return output;
170 }
171 
173  uint32_t detid, std::string name, std::string title, int nchX, double lowX, double highX) {
175  return daqBE_->book1D(hid, title, nchX, lowX, highX);
176 }
177 
179  uint32_t detid, std::string name, std::string title, int nchX, float* xbinsize) {
181  return daqBE_->book1D(hid, title, nchX, xbinsize);
182 }
183 
187  int nchX,
188  double lowX,
189  double highX,
190  int nchY,
191  double lowY,
192  double highY) {
194  return daqBE_->book2D(hid, title, nchX, lowX, highX, nchY, lowY, highY);
195 }
196 
198  uint32_t detid, std::string name, std::string title) {
199  DetId detId(detid);
200  const TrackerGeometry& theTracker(*geom_);
201  const PixelGeomDetUnit* theGeomDet = dynamic_cast<const PixelGeomDetUnit*>(theTracker.idToDet(detId));
202  int maxcol = theGeomDet->specificTopology().ncolumns();
203  int maxrow = theGeomDet->specificTopology().nrows();
204 
206  return daqBE_->book2D(hid, title, maxcol, 0, maxcol, maxrow, 0, maxrow);
207 }
208 
211  return daqBE_->dirExists(dirName);
212 }
213 
215  return folderMaker_->setModuleFolder(detID, 0);
216 }
217 
218 // ------------ virtual functions ------------------------------------------------
220 
221 bool SiPixelOfflineCalibAnalysisBase::doFits(uint32_t detid, std::vector<SiPixelCalibDigi>::const_iterator ipix) {
222  short row = ipix->row();
223  short col = ipix->col();
224  std::vector<uint8_t> nentries = ipix->getnentries();
225  std::vector<uint32_t> sum = ipix->getsum();
226  std::vector<uint32_t> sumquares = ipix->getsumsquares();
227  //do nothing
228  //return false;
229  //
230  //DEBUG
231  std::cout << "Row: " << row << " Col: " << col << std::endl;
232  for (unsigned int i = 0; i < sum.size(); i++) {
233  std::cout << sum[i] << " ";
234  }
235  std::cout << std::endl;
236  return false;
237 }
238 
240  //do nothing
241 }
242 
244  // do nothing
245 }
247  //do nothing
248  edm::LogInfo("SiPixelOfflineCalibAnalysisBase")
249  << "SiPixelOfflineCalibAnalysisBase - Found new DetID: " << detid << " Name: " << detIdNames_[detid];
250 }
251 
252 bool SiPixelOfflineCalibAnalysisBase::checkPixel(uint32_t detid, short row, short col) {
253  // finds the fed ID:
254  int thefedid = -1;
255  for (int fedid = 0; fedid <= 40 && thefedid == -1; ++fedid) {
257  if (converter.hasDetUnit(detid)) {
258  thefedid = fedid;
259  }
260  }
261  if (thefedid == -1)
262  return false; // fed ID not associated with det ID. No pattern check possible
263 
264  SiPixelFrameConverter formatter(theCablingMap_.product(), thefedid);
267 
268  formatter.toCabling(cabling, detector);
269  // cabling should now contain cabling.roc and cabling.dcol and cabling.pxid
270 
271  // however, the coordinates now need to be converted from dcl, pxid to the row,col coordinates used in the calibration info
273  loc.dcol = cabling.dcol;
274  loc.pxid = cabling.pxid;
275  sipixelobjects::LocalPixel locpixel(loc);
276  short localrow = locpixel.rocRow();
277  short localcol = locpixel.rocCol();
278 
279  // now get the patterns from the calib object:
280  std::vector<short> calibcols = calib_->getColumnPattern();
281  std::vector<short> calibrows = calib_->getRowPattern();
282  // first check rows:
283  for (size_t irow = 0; irow < calibrows.size(); ++irow) {
284  if (calibrows[irow] == localrow) {
285  // check the columns
286  for (size_t icol = 0; icol < calibcols.size(); ++icol) {
287  if (calibcols[icol] == localcol)
288  return true;
289  }
290  }
291  }
292 
293  return false;
294 }
295 
296 // function to add tf1's to ME's:
298  if (func) {
299  ele->getTH1()->GetListOfFunctions()->Add(func);
300  }
301  return;
302 }
TrackerGeometry::idToDet
const TrackerGeomDet * idToDet(DetId) const override
Definition: TrackerGeometry.cc:193
SiPixelOfflineCalibAnalysisBase::tPixelCalibDigi
edm::EDGetTokenT< edm::DetSetVector< SiPixelCalibDigi > > tPixelCalibDigi
Definition: SiPixelOfflineCalibAnalysisBase.h:139
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
SiPixelOfflineCalibAnalysisBase::outputFileName_
std::string outputFileName_
Definition: SiPixelOfflineCalibAnalysisBase.h:126
SiPixelOfflineCalibAnalysisBase::nTriggers_
short nTriggers_
Definition: SiPixelOfflineCalibAnalysisBase.h:118
SiPixelOfflineCalibAnalysisBase::addTF1ToDQMMonitoringElement
void addTF1ToDQMMonitoringElement(MonitorElement *ele, TF1 *func)
Definition: SiPixelOfflineCalibAnalysisBase.cc:297
SiPixelOfflineCalibAnalysisBase::translateDetIdToString
std::string translateDetIdToString(uint32_t detid)
Definition: SiPixelOfflineCalibAnalysisBase.cc:146
SiPixelOfflineCalibAnalysisBase::doFits
virtual bool doFits(uint32_t detid, std::vector< SiPixelCalibDigi >::const_iterator ipix)
Definition: SiPixelOfflineCalibAnalysisBase.cc:221
runGCPTkAlMap.title
string title
Definition: runGCPTkAlMap.py:94
mps_fire.i
i
Definition: mps_fire.py:428
SiPixelOfflineCalibAnalysisBase::calib_
edm::ESHandle< SiPixelCalibConfiguration > calib_
Definition: SiPixelOfflineCalibAnalysisBase.h:113
SiPixelOfflineCalibAnalysisBase::calibrationMode_
std::string calibrationMode_
Definition: SiPixelOfflineCalibAnalysisBase.h:117
edm::DetSetVector::end
iterator end()
Return the off-the-end iterator.
Definition: DetSetVector.h:325
SiPixelCalibConfiguration::getVCalValues
const std::vector< short > getVCalValues() const
Definition: SiPixelCalibConfiguration.h:40
SiPixelFolderOrganizer::setModuleFolder
bool setModuleFolder(const uint32_t &rawdetid=0, int type=0, bool isUpgrade=false)
Set folder name for a module or plaquette.
Definition: SiPixelFolderOrganizer.cc:27
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:72
SiPixelOfflineCalibAnalysisBase::beginJob
void beginJob() override
Definition: SiPixelOfflineCalibAnalysisBase.cc:129
converter
Definition: CandidateProducer.h:25
edm::Run
Definition: Run.h:45
edm
HLT enums.
Definition: AlignableModifier.h:19
SiPixelCalibConfiguration::getNTriggers
short getNTriggers() const
Definition: SiPixelCalibConfiguration.h:28
cuy.col
col
Definition: cuy.py:1010
gather_cfg.cout
cout
Definition: gather_cfg.py:144
SiPixelOfflineCalibAnalysisBase::fitFunction_
static TF1 * fitFunction_
Definition: SiPixelOfflineCalibAnalysisBase.h:107
SiPixelOfflineCalibAnalysisBase::detIdNames_
std::map< uint32_t, std::string > detIdNames_
Definition: SiPixelOfflineCalibAnalysisBase.h:135
PixelBarrelName
Definition: PixelBarrelName.h:16
ElectronicIndex.h
SiPixelOfflineCalibAnalysisBase::SiPixelOfflineCalibAnalysisBase
SiPixelOfflineCalibAnalysisBase()
Definition: SiPixelOfflineCalibAnalysisBase.cc:46
edm::DetSetVector::begin
iterator begin()
Return an iterator to the first DetSet.
Definition: DetSetVector.h:314
dqm::legacy::MonitorElement
Definition: MonitorElement.h:461
SiPixelOfflineCalibAnalysisBase::bookDQMHistogram1D
MonitorElement * bookDQMHistogram1D(uint32_t detid, std::string name, std::string title, int nchX, double lowX, double highX)
Definition: SiPixelOfflineCalibAnalysisBase.cc:172
sipixelobjects::ElectronicIndex::dcol
int dcol
Definition: ElectronicIndex.h:8
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
tools.TF1
TF1
Definition: tools.py:23
SiPixelOfflineCalibAnalysisBase::calibrationSetup
virtual void calibrationSetup(const edm::EventSetup &iSetup)
Definition: SiPixelOfflineCalibAnalysisBase.cc:239
edm::Handle
Definition: AssociativeIterator.h:50
sipixelobjects::LocalPixel::rocCol
int rocCol() const
Definition: LocalPixel.h:35
SiPixelOfflineCalibAnalysisBase::folderMaker_
SiPixelFolderOrganizer * folderMaker_
Definition: SiPixelOfflineCalibAnalysisBase.h:123
SiPixelOfflineCalibAnalysisBase::vCalValues_
static std::vector< short > vCalValues_
Definition: SiPixelOfflineCalibAnalysisBase.h:119
sipixelobjects::LocalPixel
identify pixel inside single ROC
Definition: LocalPixel.h:7
DetectorIndex.h
edm::InputTag::label
std::string const & label() const
Definition: InputTag.h:36
DetId
Definition: DetId.h:17
PixelBarrelName::name
std::string name() const override
from base class
Definition: PixelBarrelName.cc:731
SiPixelCalibConfiguration::getCalibrationMode
std::string getCalibrationMode() const
Definition: SiPixelCalibConfiguration.h:38
SiPixelOfflineCalibAnalysisBase::daqBE_
DQMStore * daqBE_
Definition: SiPixelOfflineCalibAnalysisBase.h:124
PixelEndcapName
Definition: PixelEndcapName.h:16
edm::EventSetup::get
T get() const
Definition: EventSetup.h:80
PixelGeomDetUnit
Definition: PixelGeomDetUnit.h:15
TrackerDigiGeometryRecord
Definition: TrackerDigiGeometryRecord.h:15
SiPixelHistogramId::setHistoId
std::string setHistoId(std::string variable, uint32_t &rawId)
Set Histogram Id.
Definition: SiPixelHistogramId.cc:29
PixelTopology::ncolumns
virtual int ncolumns() const =0
SiPixelOfflineCalibAnalysisBase.h
SiPixelOfflineCalibAnalysisBase::geom_
edm::ESHandle< TrackerGeometry > geom_
Definition: SiPixelOfflineCalibAnalysisBase.h:114
sipixelobjects::ElectronicIndex::pxid
int pxid
Definition: ElectronicIndex.h:9
dqm::implementation::DQMStore::setCurrentFolder
void setCurrentFolder(std::string const &fullpath) override
Definition: DQMStore.h:569
dqm::implementation::DQMStore::save
DQM_DEPRECATED void save(std::string const &filename, std::string const &path="")
Definition: DQMStore.cc:761
SiPixelOfflineCalibAnalysisBase::bookDQMHistoPlaquetteSummary2D
MonitorElement * bookDQMHistoPlaquetteSummary2D(uint32_t detid, std::string name, std::string title)
Definition: SiPixelOfflineCalibAnalysisBase.cc:197
dqm::legacy::MonitorElement::getTH1
virtual TH1 * getTH1() const
Definition: MonitorElement.h:474
PixelGeomDetType.h
sipixelobjects::ElectronicIndex
Definition: ElectronicIndex.h:5
DetId::subdetId
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum)
Definition: DetId.h:48
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
SiPixelOfflineCalibAnalysisBase::eventCounter_
uint32_t eventCounter_
Definition: SiPixelOfflineCalibAnalysisBase.h:130
TrackerDigiGeometryRecord.h
SiPixelFrameConverter.h
SiPixelCalibConfigurationRcd
Definition: SiPixelCalibConfigurationRcd.h:24
SiPixelHistogramId
Definition: SiPixelHistogramId.h:25
edm::ParameterSet
Definition: ParameterSet.h:47
sipixelobjects::LocalPixel::DcolPxid::pxid
int pxid
Definition: LocalPixel.h:20
sipixelobjects::LocalPixel::DcolPxid
double collumn and pixel ID in double collumn representation
Definition: LocalPixel.h:19
SiPixelOfflineCalibAnalysisBase::calibrationEnd
virtual void calibrationEnd()
Definition: SiPixelOfflineCalibAnalysisBase.cc:243
sipixelobjects::LocalPixel::rocRow
int rocRow() const
Definition: LocalPixel.h:34
edm::DetSetVector::const_iterator
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:102
PixelGeomDetUnit::specificTopology
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
Definition: PixelGeomDetUnit.cc:17
cond::runnumber
Definition: Time.h:19
edm::Service
Definition: Service.h:30
iEvent
int iEvent
Definition: GenABIO.cc:224
LocalPixel.h
SiPixelOfflineCalibAnalysisBase::setDQMDirectory
bool setDQMDirectory(std::string dirName)
Definition: SiPixelOfflineCalibAnalysisBase.cc:209
SiPixelOfflineCalibAnalysisBase::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: SiPixelOfflineCalibAnalysisBase.cc:60
edm::EventSetup
Definition: EventSetup.h:57
SiPixelFrameConverter
Definition: SiPixelFrameConverter.h:15
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
TrackCollections2monitor_cff.func
func
Definition: TrackCollections2monitor_cff.py:359
PixelSLinkDataInputSource_cfi.fedid
fedid
Definition: PixelSLinkDataInputSource_cfi.py:6
get
#define get
SiPixelOfflineCalibAnalysisBase::createOutputFile_
bool createOutputFile_
Definition: SiPixelOfflineCalibAnalysisBase.h:127
SiPixelOfflineCalibAnalysisBase::runnumbers_
std::vector< uint32_t > runnumbers_
Definition: SiPixelOfflineCalibAnalysisBase.h:129
SiPixelOfflineCalibAnalysisBase::siPixelCalibDigiProducer_
edm::InputTag siPixelCalibDigiProducer_
Definition: SiPixelOfflineCalibAnalysisBase.h:137
SiPixelOfflineCalibAnalysisBase::newDetID
virtual void newDetID(uint32_t detid)
Definition: SiPixelOfflineCalibAnalysisBase.cc:246
dqm::implementation::IBooker::book2D
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:177
Exception
Definition: hltDiff.cc:246
SiPixelFolderOrganizer
Definition: SiPixelFolderOrganizer.h:26
PixelGeomDetUnit.h
SiPixelCalibConfiguration::getColumnPattern
std::vector< short > getColumnPattern() const
Definition: SiPixelCalibConfiguration.h:34
TrackerOfflineValidation_Dqm_cff.dirName
dirName
Definition: TrackerOfflineValidation_Dqm_cff.py:55
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
SiPixelOfflineCalibAnalysisBase::checkCorrectCalibrationType
virtual bool checkCorrectCalibrationType()
Definition: SiPixelOfflineCalibAnalysisBase.cc:219
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
hgcalTestNeighbor_cfi.detector
detector
Definition: hgcalTestNeighbor_cfi.py:6
SiPixelOfflineCalibAnalysisBase::theCablingMap_
edm::ESHandle< SiPixelFedCablingMap > theCablingMap_
Definition: SiPixelOfflineCalibAnalysisBase.h:115
SiPixelOfflineCalibAnalysisBase::getVcalValues
static const std::vector< short > * getVcalValues()
Definition: SiPixelOfflineCalibAnalysisBase.cc:144
SiPixelFedCablingMapRcd
Definition: SiPixelFedCablingMapRcd.h:5
SiPixelOfflineCalibAnalysisBase::checkPixel
bool checkPixel(uint32_t detid, short row, short column)
Definition: SiPixelOfflineCalibAnalysisBase.cc:252
SiPixelCalibConfiguration::getRowPattern
std::vector< short > getRowPattern() const
Definition: SiPixelCalibConfiguration.h:31
PixelEndcapName::name
std::string name() const override
from base class
Definition: PixelEndcapName.cc:365
SiPixelOfflineCalibAnalysisBase::detIdsEntered_
std::map< uint32_t, int > detIdsEntered_
Definition: SiPixelOfflineCalibAnalysisBase.h:134
edm::Event
Definition: Event.h:73
PixelTopology::nrows
virtual int nrows() const =0
SiPixelOfflineCalibAnalysisBase::bookDQMHistogram2D
MonitorElement * bookDQMHistogram2D(uint32_t detid, std::string name, std::string title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Definition: SiPixelOfflineCalibAnalysisBase.cc:184
edm::InputTag
Definition: InputTag.h:15
dqm::implementation::IGetter::dirExists
virtual bool dirExists(std::string const &path) const
Definition: DQMStore.cc:708
dqm::implementation::IBooker::book1D
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
SiPixelOfflineCalibAnalysisBase::endJob
void endJob() override
Definition: SiPixelOfflineCalibAnalysisBase.cc:133
SiPixelOfflineCalibAnalysisBase::beginRun
void beginRun(const edm::Run &, const edm::EventSetup &) override
Definition: SiPixelOfflineCalibAnalysisBase.cc:112
sipixelobjects::LocalPixel::DcolPxid::dcol
int dcol
Definition: LocalPixel.h:20
SiPixelOfflineCalibAnalysisBase::theHistogramIdWorker_
SiPixelHistogramId * theHistogramIdWorker_
Definition: SiPixelOfflineCalibAnalysisBase.h:125
sipixelobjects::DetectorIndex
Definition: DetectorIndex.h:6
TrackerGeometry
Definition: TrackerGeometry.h:14
SiPixelOfflineCalibAnalysisBase::~SiPixelOfflineCalibAnalysisBase
~SiPixelOfflineCalibAnalysisBase() override
Definition: SiPixelOfflineCalibAnalysisBase.cc:53
edm::DetSet::const_iterator
collection_type::const_iterator const_iterator
Definition: DetSet.h:31