Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 10:40:20

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   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0057 
0058 private:
0059   //parameters
0060   std::vector<align::StructureType> m_theLevels;
0061   //std::vector<int> theSubDets;
0062 
0063   //compare surface deformations
0064   void compareSurfaceDeformations(TTree* _inputTree11, TTree* _inputTree12);
0065   //compares two geometries
0066   void compareGeometries(Alignable* refAli,
0067                          Alignable* curAli,
0068                          const TrackerTopology* tTopo,
0069                          const edm::EventSetup& iSetup);
0070   //filling the ROOT file
0071   void fillTree(Alignable* refAli,
0072                 const AlgebraicVector& diff,  // typedef CLHEP::HepVector      AlgebraicVector;
0073                 const TrackerTopology* tTopo,
0074                 const edm::EventSetup& iSetup);
0075   //for filling identifiers
0076   void fillIdentifiers(int subdetlevel, int rawid, const TrackerTopology* tTopo);
0077   //converts surveyRcd into alignmentRcd
0078   void surveyToTracker(AlignableTracker* ali, Alignments* alignVals, AlignmentErrorsExtended* alignErrors);
0079   //need for conversion for surveyToTracker
0080   void addSurveyInfo(Alignable* ali);
0081   //void createDBGeometry(const edm::EventSetup& iSetup);
0082   void createROOTGeometry(const edm::EventSetup& iSetup);
0083 
0084   // for common tracker system
0085   void setCommonTrackerSystem();
0086   void diffCommonTrackerSystem(Alignable* refAli, Alignable* curAli);
0087   bool passIdCut(uint32_t);
0088 
0089   const edm::ESGetToken<DDCompactView, IdealGeometryRecord> cpvTokenDDD_;
0090   const edm::ESGetToken<cms::DDCompactView, IdealGeometryRecord> cpvTokenDD4hep_;
0091   const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> topoToken_;
0092   const edm::ESGetToken<GeometricDet, IdealGeometryRecord> geomDetToken_;
0093   const edm::ESGetToken<PTrackerParameters, PTrackerParametersRcd> ptpToken_;
0094   const edm::ESGetToken<SiPixelQuality, SiPixelQualityRcd> pixQualityToken_;
0095   const edm::ESGetToken<SiStripQuality, SiStripQualityRcd> stripQualityToken_;
0096 
0097   AlignableTracker* referenceTracker;
0098   AlignableTracker* dummyTracker;
0099   AlignableTracker* currentTracker;
0100 
0101   unsigned int theSurveyIndex;
0102   const Alignments* theSurveyValues;
0103   const SurveyErrors* theSurveyErrors;
0104 
0105   // configurables
0106   const std::vector<std::string> levelStrings_;
0107   std::string moduleListName_;
0108   std::string inputFilename1_;
0109   std::string inputFilename2_;
0110   std::string inputTreenameAlign_;
0111   std::string inputTreenameDeform_;
0112   bool fromDD4hep_;
0113   bool writeToDB_;
0114   std::string weightBy_;
0115   std::string setCommonTrackerSystem_;
0116   bool detIdFlag_;
0117   std::string detIdFlagFile_;
0118   bool weightById_;
0119   std::string weightByIdFile_;
0120   std::vector<unsigned int> weightByIdVector_;
0121 
0122   std::vector<uint32_t> detIdFlagVector_;
0123   align::StructureType commonTrackerLevel_;
0124   align::GlobalVector TrackerCommonT_;
0125   align::GlobalVector TrackerCommonR_;
0126   align::PositionType TrackerCommonCM_;
0127 
0128   std::ifstream moduleListFile_;
0129   std::vector<int> moduleList_;
0130   int moduleInList_;
0131 
0132   //root configuration
0133   std::string filename_;
0134   std::string surfdir_;
0135   TFile* theFile_;
0136   TTree* alignTree_;
0137   TFile* inputRootFile1_;
0138   TFile* inputRootFile2_;
0139   TTree* inputTree01_;
0140   TTree* inputTree02_;
0141   TTree* inputTree11_;
0142   TTree* inputTree12_;
0143 
0144   /**\ Tree variables */
0145   int id_, badModuleQuality_, inModuleList_, level_, mid_, mlevel_, sublevel_, useDetId_, detDim_;
0146   float xVal_, yVal_, zVal_, rVal_, etaVal_, phiVal_, alphaVal_, betaVal_, gammaVal_;
0147   // changes in global variables
0148   float dxVal_, dyVal_, dzVal_, drVal_, dphiVal_, dalphaVal_, dbetaVal_, dgammaVal_;
0149   // changes local variables: u, v, w, alpha, beta, gamma
0150   float duVal_, dvVal_, dwVal_, daVal_, dbVal_, dgVal_;
0151   float surWidth_, surLength_;
0152   uint32_t identifiers_[6];
0153   double surRot_[9];
0154   int type_;
0155   double surfDeform_[13];
0156 
0157   int m_nBins_;
0158   double m_rangeLow_;
0159   double m_rangeHigh_;
0160 
0161   bool firstEvent_;
0162 
0163   std::vector<TrackerMap> m_vtkmap_;
0164 
0165   std::map<std::string, TH1D*> m_h1_;
0166 };
0167 
0168 #endif