Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-11-06 04:13:18

0001 #ifndef Alignment_OfflineValidation_TrackerGeometryCompare_h
0002 #define Alignment_OfflineValidation_TrackerGeometryCompare_h
0003 
0004 /** \class TrackerGeometryCompare
0005  *
0006  * Module that reads survey info from DB and prints them out.
0007  *
0008  *  $Date: 2012/12/02 22:13:12 $
0009  *  $Revision: 1.14 $
0010  *  \author Nhan Tran
0011  *
0012  * ********
0013  * ******** Including surface deformations in the geometry comparison ******** 
0014  * ********
0015  *
0016  */
0017 
0018 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0019 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0020 #include "Alignment/TrackerAlignment/interface/AlignableTracker.h"
0021 #include "CondFormats/Alignment/interface/SurveyErrors.h"
0022 #include "Alignment/CommonAlignment/interface/StructureType.h"
0023 
0024 #include "Alignment/CommonAlignment/interface/AlignTools.h"
0025 
0026 //******** Single include for the TkMap *************
0027 #include "CommonTools/TrackerMap/interface/TrackerMap.h"
0028 //***************************************************
0029 
0030 #include "DetectorDescription/DDCMS/interface/DDCompactView.h"
0031 #include "DetectorDescription/Core/interface/DDCompactView.h"
0032 
0033 #include <algorithm>
0034 #include <string>
0035 #include "TTree.h"
0036 #include "TH1D.h"
0037 
0038 class AlignTransform;
0039 class TrackerTopology;
0040 
0041 class TrackerGeometryCompare : public edm::one::EDAnalyzer<> {
0042 public:
0043   typedef AlignTransform SurveyValue;
0044   typedef Alignments SurveyValues;
0045 
0046   /// Do nothing. Required by framework.
0047   TrackerGeometryCompare(const edm::ParameterSet&);
0048 
0049   /// Read from DB and print survey info.
0050   void beginJob() override;
0051 
0052   void endJob() override;
0053 
0054   void analyze(const edm::Event&, const edm::EventSetup&) override;
0055 
0056 private:
0057   //parameters
0058   std::vector<align::StructureType> m_theLevels;
0059   //std::vector<int> theSubDets;
0060 
0061   //compare surface deformations
0062   void compareSurfaceDeformations(TTree* _inputTree11, TTree* _inputTree12);
0063   //compares two geometries
0064   void compareGeometries(Alignable* refAli,
0065                          Alignable* curAli,
0066                          const TrackerTopology* tTopo,
0067                          const edm::EventSetup& iSetup);
0068   //filling the ROOT file
0069   void fillTree(Alignable* refAli,
0070                 const AlgebraicVector& diff,  // typedef CLHEP::HepVector      AlgebraicVector;
0071                 const TrackerTopology* tTopo,
0072                 const edm::EventSetup& iSetup);
0073   //for filling identifiers
0074   void fillIdentifiers(int subdetlevel, int rawid, const TrackerTopology* tTopo);
0075   //converts surveyRcd into alignmentRcd
0076   void surveyToTracker(AlignableTracker* ali, Alignments* alignVals, AlignmentErrorsExtended* alignErrors);
0077   //need for conversion for surveyToTracker
0078   void addSurveyInfo(Alignable* ali);
0079   //void createDBGeometry(const edm::EventSetup& iSetup);
0080   void createROOTGeometry(const edm::EventSetup& iSetup);
0081 
0082   // for common tracker system
0083   void setCommonTrackerSystem();
0084   void diffCommonTrackerSystem(Alignable* refAli, Alignable* curAli);
0085   bool passIdCut(uint32_t);
0086 
0087   const edm::ESGetToken<DDCompactView, IdealGeometryRecord> cpvTokenDDD_;
0088   const edm::ESGetToken<cms::DDCompactView, IdealGeometryRecord> cpvTokenDD4hep_;
0089   const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> topoToken_;
0090   const edm::ESGetToken<GeometricDet, IdealGeometryRecord> geomDetToken_;
0091   const edm::ESGetToken<PTrackerParameters, PTrackerParametersRcd> ptpToken_;
0092   const edm::ESGetToken<PTrackerAdditionalParametersPerDet, PTrackerAdditionalParametersPerDetRcd> ptitpToken_;
0093   const edm::ESGetToken<SiPixelQuality, SiPixelQualityRcd> pixQualityToken_;
0094   const edm::ESGetToken<SiStripQuality, SiStripQualityRcd> stripQualityToken_;
0095 
0096   AlignableTracker* referenceTracker;
0097   AlignableTracker* dummyTracker;
0098   AlignableTracker* currentTracker;
0099 
0100   unsigned int theSurveyIndex;
0101   const Alignments* theSurveyValues;
0102   const SurveyErrors* theSurveyErrors;
0103 
0104   // configurables
0105   const std::vector<std::string> levelStrings_;
0106   std::string moduleListName_;
0107   std::string inputFilename1_;
0108   std::string inputFilename2_;
0109   std::string inputTreenameAlign_;
0110   std::string inputTreenameDeform_;
0111   bool fromDD4hep_;
0112   bool writeToDB_;
0113   std::string weightBy_;
0114   std::string setCommonTrackerSystem_;
0115   bool detIdFlag_;
0116   std::string detIdFlagFile_;
0117   bool weightById_;
0118   std::string weightByIdFile_;
0119   std::vector<unsigned int> weightByIdVector_;
0120 
0121   std::vector<uint32_t> detIdFlagVector_;
0122   align::StructureType commonTrackerLevel_;
0123   align::GlobalVector TrackerCommonT_;
0124   align::GlobalVector TrackerCommonR_;
0125   align::PositionType TrackerCommonCM_;
0126 
0127   std::ifstream moduleListFile_;
0128   std::vector<int> moduleList_;
0129   int moduleInList_;
0130 
0131   //root configuration
0132   std::string filename_;
0133   TFile* theFile_;
0134   TTree* alignTree_;
0135   TFile* inputRootFile1_;
0136   TFile* inputRootFile2_;
0137   TTree* inputTree01_;
0138   TTree* inputTree02_;
0139   TTree* inputTree11_;
0140   TTree* inputTree12_;
0141 
0142   /**\ Tree variables */
0143   int id_, badModuleQuality_, inModuleList_, level_, mid_, mlevel_, sublevel_, useDetId_, detDim_;
0144   float xVal_, yVal_, zVal_, rVal_, etaVal_, phiVal_, alphaVal_, betaVal_, gammaVal_;
0145   // changes in global variables
0146   float dxVal_, dyVal_, dzVal_, drVal_, dphiVal_, dalphaVal_, dbetaVal_, dgammaVal_;
0147   // changes local variables: u, v, w, alpha, beta, gamma
0148   float duVal_, dvVal_, dwVal_, daVal_, dbVal_, dgVal_;
0149   float surWidth_, surLength_;
0150   uint32_t identifiers_[6];
0151   double surRot_[9];
0152   int type_;
0153   double surfDeform_[13];
0154 
0155   int m_nBins_;
0156   double m_rangeLow_;
0157   double m_rangeHigh_;
0158 
0159   bool firstEvent_;
0160 
0161   std::vector<TrackerMap> m_vtkmap_;
0162 
0163   std::map<std::string, TH1D*> m_h1_;
0164 };
0165 
0166 #endif