Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:56:39

0001 #ifndef Alignment_OfflineValidation_MuonGeometryArrange_h
0002 #define Alignment_OfflineValidation_MuonGeometryArrange_h
0003 
0004 /** \class MuonGeometryArrange
0005  *
0006  * Module that reads survey info from DB and prints them out.
0007  *
0008  * Usage:
0009  *   module comparator = MuonGeometryArrange {
0010  *
0011  *   lots of stuff  
0012  *
0013  *   }
0014  *   path p = { comparator }
0015  *
0016  *
0017  *  $Date: 2009/09/15 17:09:58 $
0018  *  $Revision: 1.2 $
0019  *  \author Nhan Tran
0020  */
0021 
0022 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0023 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0024 #include "Alignment/MuonAlignment/interface/AlignableMuon.h"
0025 #include "CondFormats/Alignment/interface/SurveyErrors.h"
0026 #include "Alignment/CommonAlignment/interface/StructureType.h"
0027 
0028 #include "Alignment/CommonAlignment/interface/AlignTools.h"
0029 
0030 #include <algorithm>
0031 #include "TTree.h"
0032 
0033 class AlignTransform;
0034 class MuonAlignment;
0035 class TGraph;
0036 class TH2F;
0037 
0038 class MuonGeometryArrange : public edm::one::EDAnalyzer<> {
0039 public:
0040   typedef AlignTransform SurveyValue;
0041   typedef Alignments SurveyValues;
0042 
0043   /// Do nothing. Required by framework.
0044   MuonGeometryArrange(const edm::ParameterSet&);
0045 
0046   /// Read from DB and print survey info.
0047   void beginJob() override;
0048 
0049   void analyze(const edm::Event&, const edm::EventSetup&) override;
0050   //        virtual void endJob(void);
0051 
0052 private:
0053   //parameters
0054   edm::ParameterSet m_params;
0055   std::vector<align::StructureType> theLevels;
0056   //std::vector<int> theSubDets;
0057 
0058   //compares two geometries, driver routine
0059   void compare(Alignable* refAli, Alignable* curAli, Alignable* curAliCopy2);
0060   void endHist();
0061   // Map one onto other and compare details
0062   void compareGeometries(Alignable* refAli, Alignable* curAli, Alignable* curAliCopy2);
0063   //filling the ROOT file
0064   void fillTree(Alignable* refAli, const AlgebraicVector& diff);
0065   //void createDBGeometry(const edm::EventSetup& iSetup);
0066   void createROOTGeometry(const edm::EventSetup& iSetup);
0067   void makeGraph(int sizeI,
0068                  float smi,
0069                  float sma,
0070                  float minV,
0071                  float maxV,
0072                  TH2F* dxh,
0073                  TGraph* grx,
0074                  const char* name,
0075                  const char* title,
0076                  const char* titleg,
0077                  const char* axis,
0078                  const float* xp,
0079                  const float* yp,
0080                  int numEntries);
0081 
0082   bool passIdCut(uint32_t);
0083   bool checkChosen(Alignable* ali);  // Is ali one of wanted CSC?
0084   bool passChosen(Alignable* ali);   // Is ali either one of wanted
0085                                      // CSC or does it contain them?
0086   bool isMother(Alignable* ali);     // Is ali the container (ring)?
0087 
0088   AlignableMuon* referenceMuon;
0089   AlignableMuon* dummyMuon;
0090   AlignableMuon* currentMuon;
0091   Alignable* inputGeometry1;
0092   Alignable* inputGeometry2;
0093 
0094   unsigned int theSurveyIndex;
0095   const Alignments* theSurveyValues;
0096   const SurveyErrors* theSurveyErrors;
0097 
0098   // configurables
0099   const std::vector<std::string> _levelStrings;
0100   std::string _inputFilename1;
0101   std::string _inputFilename2;
0102   std::string _inputTreename;
0103   bool _writeToDB;
0104   std::string _weightBy;
0105   std::string _setCommonMuonSystem;
0106   bool _detIdFlag;
0107   std::string _detIdFlagFile;
0108   bool _weightById;
0109   std::string _weightByIdFile;
0110   std::vector<unsigned int> _weightByIdVector;
0111   int _endcap;
0112   int _station;
0113   int _ring;
0114 
0115   std::vector<uint32_t> _detIdFlagVector;
0116   align::StructureType _commonMuonLevel;
0117   align::GlobalVector _MuonCommonT;
0118   align::EulerAngles _MuonCommonR;
0119   align::PositionType _MuonCommonCM;
0120 
0121   //root configuration
0122   std::string _filename;
0123 
0124   struct MGACollection {
0125     int id;
0126     int level;
0127     int mid;
0128     int mlevel;
0129     int sublevel;
0130     float x, y, z;
0131     float r, phi, eta;
0132     float alpha, beta, gamma;
0133     float dx, dy, dz;
0134     float dr, dphi;  // no deta?
0135     float dalpha, dbeta, dgamma;
0136     float ldx, ldy, ldz;
0137     float ldr, ldphi;  // no deta?
0138     int useDetId, detDim;
0139     float rotx, roty, rotz;
0140     float drotx, droty, drotz;
0141     float surW, surL;  // surWidth and length
0142     double surRot[9];
0143     int phipos;
0144   };
0145 
0146   std::vector<MGACollection> _mgacollection;
0147   // Two sets of alignment inputs
0148   std::string _inputXMLCurrent;
0149   std::string _inputXMLReference;
0150   MuonAlignment* inputAlign1;
0151   MuonAlignment* inputAlign2;
0152   MuonAlignment* inputAlign2a;
0153 
0154   TFile* _theFile;
0155   TTree* _alignTree;
0156   TFile* _inputRootFile1;
0157   TFile* _inputRootFile2;
0158   TTree* _inputTree1;
0159   TTree* _inputTree2;
0160 
0161   int _id, _level, _mid, _mlevel, _sublevel, _useDetId, _detDim;
0162   float _xVal, _yVal, _zVal, _rVal, _phiVal, _alphaVal, _betaVal, _gammaVal, _etaVal;
0163   float _dxVal, _dyVal, _dzVal, _drVal, _dphiVal, _dalphaVal;
0164   float _dbetaVal, _dgammaVal, _ldxVal, _ldyVal, _ldzVal;
0165   float _ldrVal, _ldphiVal;
0166   float _rotxVal, _rotyVal, _rotzVal;
0167   float _drotxVal, _drotyVal, _drotzVal;
0168   float _surWidth, _surLength;
0169   double _surRot[9];
0170 
0171   bool firstEvent_;
0172 
0173   std::string idealInputLabel1, idealInputLabel2, idealInputLabel2a, geomIdeal;
0174 
0175   const edm::ESGetToken<DTGeometry, MuonGeometryRecord> dtGeomToken1_;
0176   const edm::ESGetToken<CSCGeometry, MuonGeometryRecord> cscGeomToken1_;
0177   const edm::ESGetToken<GEMGeometry, MuonGeometryRecord> gemGeomToken1_;
0178 
0179   const edm::ESGetToken<DTGeometry, MuonGeometryRecord> dtGeomToken2_;
0180   const edm::ESGetToken<CSCGeometry, MuonGeometryRecord> cscGeomToken2_;
0181   const edm::ESGetToken<GEMGeometry, MuonGeometryRecord> gemGeomToken2_;
0182 
0183   const edm::ESGetToken<DTGeometry, MuonGeometryRecord> dtGeomToken3_;
0184   const edm::ESGetToken<CSCGeometry, MuonGeometryRecord> cscGeomToken3_;
0185   const edm::ESGetToken<GEMGeometry, MuonGeometryRecord> gemGeomToken3_;
0186 
0187   const edm::ESGetToken<DTGeometry, MuonGeometryRecord> dtGeomIdealToken_;
0188   const edm::ESGetToken<CSCGeometry, MuonGeometryRecord> cscGeomIdealToken_;
0189   const edm::ESGetToken<GEMGeometry, MuonGeometryRecord> gemGeomIdealToken_;
0190 };
0191 
0192 #endif