CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC4_patch1/src/Alignment/LaserAlignment/plugins/LaserAlignment.h

Go to the documentation of this file.
00001 
00002 #ifndef LaserAlignment_LaserAlignment_H
00003 #define LaserAlignment_LaserAlignment_H
00004 
00005 
00017 #include <sstream>
00018 #include <iostream>
00019 #include <cmath>
00020 
00021 #include "FWCore/Framework/interface/Event.h" 
00022 #include "FWCore/Framework/interface/EDProducer.h"
00023 #include "FWCore/Framework/interface/ESHandle.h"
00024 #include "FWCore/Framework/interface/EventSetup.h"
00025 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00026 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00027 #include "FWCore/ServiceRegistry/interface/Service.h"
00028 
00029 #include "DataFormats/Common/interface/DetSetVector.h"
00030 #include "DataFormats/SiStripDigi/interface/SiStripDigi.h"
00031 #include "DataFormats/SiStripDigi/interface/SiStripRawDigi.h"
00032 #include "DataFormats/DetId/interface/DetId.h"
00033 #include "DataFormats/SiStripDetId/interface/SiStripDetId.h"
00034 #include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
00035 #include "DataFormats/SiStripDetId/interface/TECDetId.h"
00036 
00037 #include "DataFormats/GeometryCommonDetAlgo/interface/ErrorFrameTransformer.h"
00038 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
00039 #include "DataFormats/Alignment/interface/SiStripLaserRecHit2D.h"
00040 #include "DataFormats/Alignment/interface/TkLasBeam.h"
00041 
00042 #include "CondFormats/SiStripObjects/interface/SiStripPedestals.h"
00043 #include "CondFormats/DataRecord/interface/SiStripPedestalsRcd.h"
00044 #include "CondFormats/Alignment/interface/DetectorGlobalPosition.h"
00045 #include "CondFormats/AlignmentRecord/interface/GlobalPositionRcd.h"
00046 
00047 #include "Geometry/TrackerGeometryBuilder/interface/StripGeomDetUnit.h"
00048 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeomBuilderFromGeometricDet.h"
00049 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
00050 #include "Geometry/CommonTopologies/interface/StripTopology.h"
00051 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
00052 #include "Geometry/TrackingGeometryAligner/interface/GeometryAligner.h"
00053 
00054 #include "Alignment/TrackerAlignment/interface/AlignableTracker.h"
00055 
00056 #include "Alignment/LaserAlignment/interface/LASGlobalData.h"
00057 #include "Alignment/LaserAlignment/interface/LASGlobalLoop.h"
00058 #include "Alignment/LaserAlignment/interface/LASModuleProfile.h"
00059 #include "Alignment/LaserAlignment/interface/LASProfileJudge.h"
00060 #include "Alignment/LaserAlignment/interface/LASBarrelAlgorithm.h"
00061 #include "Alignment/LaserAlignment/interface/LASAlignmentTubeAlgorithm.h"
00062 #include "Alignment/LaserAlignment/interface/LASEndcapAlgorithm.h"
00063 #include "Alignment/LaserAlignment/interface/LASPeakFinder.h"
00064 #include "Alignment/LaserAlignment/interface/LASCoordinateSet.h"
00065 #include "Alignment/LaserAlignment/interface/LASGeometryUpdater.h"
00066 #include "Alignment/LaserAlignment/interface/LASConstants.h"
00067 
00068 #include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
00069 
00070 #include "TH1.h"
00071 #include "TFile.h"
00072 #include "TF1.h"
00073 
00074 
00075 
00076 
00077 
00078 
00079 
00080 
00084 class LaserAlignment : public edm::EDProducer, public TObject {
00085 
00086  public:
00087 
00088   explicit LaserAlignment( edm::ParameterSet const& theConf );
00089   ~LaserAlignment();
00090   virtual void beginJob( void );
00091   virtual void produce( edm::Event&, edm::EventSetup const& );
00092   virtual void endJob( void );
00093   virtual void endRun( edm::Run&, const edm::EventSetup& );
00094 
00096   void testRoutine( void );
00097 
00098 
00099  private:
00100 
00102   void fillDataProfiles( edm::Event const&, edm::EventSetup const& );
00103 
00105   void fillPedestalProfiles( edm::ESHandle<SiStripPedestals>&  );
00106 
00108   bool isTECBeam( void );
00109   bool isATBeam( void );
00110 
00112   double getTIBTOBNominalBeamOffset( unsigned int, unsigned int, unsigned int );
00113 
00115   double getTEC2TECNominalBeamOffset( unsigned int, unsigned int, unsigned int );
00116 
00118   void fillDetectorId( void );
00119 
00121   double ConvertAngle( double );
00122 
00124   void CalculateNominalCoordinates( void );
00125   
00127   void DumpPosFileSet( LASGlobalData<LASCoordinateSet>& );
00128 
00130   void DumpStripFileSet( LASGlobalData<std::pair<float,float> >& );
00131 
00133   void DumpHitmaps( LASGlobalData<int>& );
00134 
00136   void ApplyEndcapMaskingCorrections( LASGlobalData<LASCoordinateSet>&, LASGlobalData<LASCoordinateSet>&, LASEndcapAlignmentParameterSet& );
00137   
00139   void ApplyATMaskingCorrections( LASGlobalData<LASCoordinateSet>&, LASGlobalData<LASCoordinateSet>&, LASBarrelAlignmentParameterSet& ); 
00140 
00142   int theEvents;
00143 
00145   bool theDoPedestalSubtraction;
00146 
00148   bool theUseMinuitAlgorithm;
00149 
00151   bool theApplyBeamKinkCorrections;
00152 
00154   double peakFinderThreshold;
00155 
00157   bool enableJudgeZeroFilter;
00158 
00160   unsigned int judgeOverdriveThreshold;
00161 
00163   bool updateFromInputGeometry;
00164 
00166   bool misalignedByRefGeometry;
00167 
00169   bool theStoreToDB;
00170 
00171   // digi producer
00172   std::vector<edm::ParameterSet> theDigiProducersList;
00173 
00175   bool theSaveHistograms;
00176 
00178   int theCompression;
00179 
00181   std::string theFileName;
00182 
00184   std::vector<unsigned int> theMaskTecModules;
00185   std::vector<unsigned int> theMaskAtModules;
00186 
00188   bool theSetNominalStrips;
00189 
00190   // this object can judge if 
00191   // a LASModuleProfile is usable for position measurement
00192   LASProfileJudge judge;
00193 
00194   // colection of constants
00195   LASConstants theLasConstants;
00196 
00197   // the detector ids for all the modules
00198   LASGlobalData<unsigned int> detectorId;
00199 
00200   // the detector ids for the doubly hit modules in the TECs
00201   std::vector<unsigned int> tecDoubleHitDetId;
00202 
00203   // all the 474 profiles for the pedestals
00204   LASGlobalData<LASModuleProfile> pedestalProfiles;
00205 
00207   LASGlobalData<LASModuleProfile> currentDataProfiles;
00208 
00209   // summed data profiles
00210   LASGlobalData<LASModuleProfile> collectedDataProfiles;
00211 
00212   // 474 names for retrieving data from the branches
00213   LASGlobalData<std::string> theProfileNames;
00214 
00215   // number of accepted profiles for each module
00216   LASGlobalData<int> numberOfAcceptedProfiles;
00217 
00218   // hit map for the current event (int=0,1)
00219   // which is needed for branching into AT or TEC mode
00220   LASGlobalData<int> isAcceptedProfile;
00221 
00222   // histograms for the summed profiles;
00223   // these are needed for the fitting procedure (done by ROOT)
00224   LASGlobalData<TH1D*> summedHistograms;
00225 
00226   // container for nominal module positions
00227   LASGlobalData<LASCoordinateSet> nominalCoordinates;
00228 
00229   // a class for easy looping over LASGlobalData objects,
00230   // avoids nested for-statements
00231   LASGlobalLoop moduleLoop;
00232 
00234   TFile * theFile;
00235   TDirectory* singleModulesDir;
00236 
00238   edm::ESHandle<GeometricDet> gD;
00239   edm::ESHandle<TrackerGeometry> theTrackerGeometry;
00240   edm::ESHandle<Alignments> theGlobalPositionRcd;
00241 
00242 
00243   AlignableTracker* theAlignableTracker;
00244 
00245   std::string theAlignRecordName, theErrorRecordName;
00246 
00247   bool firstEvent_;
00248 
00249   const edm::ParameterSet theParameterSet;
00250 };
00251 #endif