CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/CalibTracker/SiPixelTools/interface/SiPixelOfflineCalibAnalysisBase.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    SiPixelOfflineCalibAnalysisBase
00004 // Class:      SiPixelOfflineCalibAnalysisBase
00005 // 
00013 //
00014 // Original Author:  Evan Klose Friis
00015 //    additions by:  Freya Blekman
00016 //         Created:  Tue Nov  6 17:27:19 CET 2007
00017 // $Id: SiPixelOfflineCalibAnalysisBase.h,v 1.17 2010/02/11 00:10:33 wmtan Exp $
00018 //
00019 //
00020 
00021 // system include files
00022 #include <memory>
00023 
00024 // user include files
00025 #include "FWCore/Framework/interface/Frameworkfwd.h"
00026 #include "FWCore/Framework/interface/EDAnalyzer.h"
00027 
00028 #include "FWCore/Framework/interface/Event.h"
00029 #include "FWCore/ServiceRegistry/interface/Service.h"
00030 //#include "FWCore/Framework/interface/EventSetup.h"
00031 #include "FWCore/Framework/interface/MakerMacros.h"
00032 #include "FWCore/Framework/interface/ESHandle.h"
00033 
00034 #include "FWCore/Utilities/interface/InputTag.h"
00035 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00036 
00037 #include "DataFormats/Common/interface/DetSetVector.h"
00038 #include "DataFormats/DetId/interface/DetId.h"
00039 
00040 #include "DataFormats/SiPixelDigi/interface/SiPixelCalibDigifwd.h"
00041 #include "DataFormats/SiPixelDigi/interface/SiPixelCalibDigi.h"
00042 
00043 #include "CondFormats/SiPixelObjects/interface/SiPixelCalibConfiguration.h"
00044 #include "CondFormats/DataRecord/interface/SiPixelCalibConfigurationRcd.h"
00045 #include "CondFormats/DataRecord/interface/SiPixelFedCablingMapRcd.h"
00046 
00047 #include "DataFormats/SiPixelDetId/interface/PixelEndcapName.h"
00048 #include "DataFormats/SiPixelDetId/interface/PixelBarrelName.h"
00049 
00050 #include "TF1.h"
00051 
00052 #include "DQMServices/Core/interface/DQMStore.h"
00053 #include "DQMServices/Core/interface/MonitorElement.h"
00054 #include "DQM/SiPixelCommon/interface/SiPixelHistogramId.h"
00055 #include "DQM/SiPixelCommon/interface/SiPixelFolderOrganizer.h"
00056 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
00057 #include "CondFormats/SiPixelObjects/interface/SiPixelFedCablingMap.h"
00058 
00059 #include <map>
00060 #include <vector>
00061 #include <iostream>
00062 #include <string>
00063 //
00064 // class decleration
00065 //
00066 
00067 
00068 class SiPixelOfflineCalibAnalysisBase : public edm::EDAnalyzer {
00069 public:
00070   explicit SiPixelOfflineCalibAnalysisBase(const edm::ParameterSet&); 
00071   ~SiPixelOfflineCalibAnalysisBase();
00072   
00073   //no argument constructor only used to throw exception in the case of derived 
00074   //class constructor not calling SiPixelOfflineCalibAnalysisBase(const edm::ParameterSet&)
00075   SiPixelOfflineCalibAnalysisBase();
00076   
00077   //pure virtual function, called after each DetID loaded
00078   virtual bool doFits(uint32_t detid, std::vector<SiPixelCalibDigi>::const_iterator ipix);
00079   
00080   
00081   //translate DetID to human readable string
00082   std::string translateDetIdToString(uint32_t detid);
00083   
00084   //booking DQM histograms (for dynamic histogram creation)
00085   
00086   MonitorElement*                       bookDQMHistogram1D(uint32_t detid, std::string name, std::string title, int nchX, double lowX, double highX);  
00087   MonitorElement*                       bookDQMHistogram1D(uint32_t detid, std::string name, std::string title, int nchX, float *xbinsize);  //variable size bins
00088   MonitorElement*                       bookDQMHistogram2D(uint32_t detid, std::string name, std::string title, int nchX, double lowX, double highX, int nchY, double lowY, double highY);
00089   
00090   MonitorElement*                       bookDQMHistoPlaquetteSummary2D(uint32_t detid, std::string name,std::string title); // take the detid to determine the size of rows and columns, this saves looking up everything in the cabling map by the user. 
00091   void                                  addTF1ToDQMMonitoringElement(MonitorElement *ele, TF1 *func);
00092   
00093   bool                                  setDQMDirectory(std::string dirName);   
00094   bool                                  setDQMDirectory(uint32_t detID); //automatically create directory hierachy based on DetID
00095   static TF1*                           fitFunction_;
00096   static const std::vector<short>*      getVcalValues();
00097   std::vector<uint32_t> &               getRunNumbers() { return runnumbers_;}
00098   
00099 protected:
00100 
00101   //calibration parameters from calib.dat/DB
00102   edm::ESHandle<SiPixelCalibConfiguration> calib_;
00103   edm::ESHandle<TrackerGeometry> geom_;
00104   edm::ESHandle<SiPixelFedCablingMap> theCablingMap_;
00105   
00106   std::string calibrationMode_;
00107   short nTriggers_;
00108   static std::vector<short> vCalValues_;
00109   uint32_t & EventNumber() { return eventCounter_;}
00110   
00111 
00112 private:
00113   
00114   SiPixelFolderOrganizer* folderMaker_;
00115   DQMStore* daqBE_;
00116   SiPixelHistogramId * theHistogramIdWorker_;
00117   std::string outputFileName_;
00118   bool createOutputFile_;
00119 
00120   std::vector<uint32_t> runnumbers_;
00121   uint32_t eventCounter_;
00122 
00123   //store set of detIDs that have been encountered
00124   //second int argument can be a derived class result flag
00125   std::map<uint32_t, int> detIdsEntered_;
00126   std::map<uint32_t, std::string> detIdNames_;
00127   
00128   edm::InputTag siPixelCalibDigiProducer_;
00129   
00130   //the beginJob is used to load the calib database.  It then calls the pure
00131   //virtual calibrationSetup() function.  Derived classes should put beginJob functionality there.
00132   virtual void beginRun(const edm::Run &, const edm::EventSetup &);
00133   void beginRun(const edm::EventSetup& iSetup);
00134   void beginJob();
00135   
00136   //calibrationSetup will be used by derived classes
00137   virtual void calibrationSetup(const edm::EventSetup& iSetup);
00138   
00139   // pure virtual function, checks if the calibration analyzer is of the right type wrt the calibration information in the database (as defined in the calibrationMode_ variable). Should be implemented in each analyzer, if false will not do anything in analyze loop. default returns true.
00140   virtual bool checkCorrectCalibrationType();
00141   
00142   //called when new DetID discovered
00143   virtual void newDetID(uint32_t detid);
00144   
00145   void analyze(const edm::Event&, const edm::EventSetup&);
00146   // the endJob method is used to save things like histograms etc.
00147   // for additional actions derived classes should use the calibrationEnd() method for endJob functionality.
00148   void endJob() ;
00149   // calibrationEnd() will be used by derived classes
00150   virtual void calibrationEnd() ;
00151  
00152   // checkPixel returns whether a particular pixel is to be expected during the entire run..
00153   bool checkPixel(uint32_t detid, short row, short column);
00154 };
00155