Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-05-22 04:02:33

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<PTrackerAdditionalParametersPerDet, PTrackerAdditionalParametersPerDetRcd> ptitpToken_;
0095   const edm::ESGetToken<SiPixelQuality, SiPixelQualityRcd> pixQualityToken_;
0096   const edm::ESGetToken<SiStripQuality, SiStripQualityRcd> stripQualityToken_;
0097 
0098   AlignableTracker* referenceTracker;
0099   AlignableTracker* dummyTracker;
0100   AlignableTracker* currentTracker;
0101 
0102   unsigned int theSurveyIndex;
0103   const Alignments* theSurveyValues;
0104   const SurveyErrors* theSurveyErrors;
0105 
0106   // configurables
0107   const std::vector<std::string> levelStrings_;
0108   std::string moduleListName_;
0109   std::string inputFilename1_;
0110   std::string inputFilename2_;
0111   std::string inputTreenameAlign_;
0112   std::string inputTreenameDeform_;
0113   bool fromDD4hep_;
0114   bool writeToDB_;
0115   std::string weightBy_;
0116   std::string setCommonTrackerSystem_;
0117   bool detIdFlag_;
0118   std::string detIdFlagFile_;
0119   bool weightById_;
0120   std::string weightByIdFile_;
0121   std::vector<unsigned int> weightByIdVector_;
0122   SiPixelPI::phase phase_;
0123 
0124   std::vector<uint32_t> detIdFlagVector_;
0125   align::StructureType commonTrackerLevel_;
0126   align::GlobalVector TrackerCommonT_;
0127   align::GlobalVector TrackerCommonR_;
0128   align::PositionType TrackerCommonCM_;
0129 
0130   std::ifstream moduleListFile_;
0131   std::vector<int> moduleList_;
0132   int moduleInList_;
0133 
0134   //root configuration
0135   std::string filename_;
0136   std::string surfdir_;
0137   TFile* theFile_;
0138   TTree* alignTree_;
0139   TFile* inputRootFile1_;
0140   TFile* inputRootFile2_;
0141   TTree* inputTree01_;
0142   TTree* inputTree02_;
0143   TTree* inputTree11_;
0144   TTree* inputTree12_;
0145 
0146   /**\ Tree variables */
0147   int id_, badModuleQuality_, inModuleList_, level_, mid_, mlevel_, sublevel_, useDetId_, detDim_;
0148   float xVal_, yVal_, zVal_, rVal_, etaVal_, phiVal_, alphaVal_, betaVal_, gammaVal_;
0149   // changes in global variables
0150   float dxVal_, dyVal_, dzVal_, drVal_, dphiVal_, dalphaVal_, dbetaVal_, dgammaVal_;
0151   // changes local variables: u, v, w, alpha, beta, gamma
0152   float duVal_, dvVal_, dwVal_, daVal_, dbVal_, dgVal_;
0153   float surWidth_, surLength_;
0154   uint32_t identifiers_[6];
0155   double surRot_[9];
0156   int type_;
0157   double surfDeform_[13];
0158 
0159   int m_nBins_;
0160   double m_rangeLow_;
0161   double m_rangeHigh_;
0162 
0163   bool firstEvent_;
0164 
0165   std::vector<TrackerMap> m_vtkmap_;
0166 
0167   std::map<std::string, TH1D*> m_h1_;
0168 };
0169 
0170 #endif