Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-11-22 06:26:42

0001 /** \class SurveyInputTest
0002  *
0003  *  Class to read survey raw measurements from a config file.
0004  *
0005  *  $Date: 2007/04/07 01:58:49 $
0006  *  $Revision: 1.1 $
0007  *  \author Chung Khim Lae
0008  */
0009 
0010 #include "Alignment/CommonAlignment/interface/AlignableComposite.h"
0011 #include "Alignment/CommonAlignment/interface/AlignableObjectId.h"
0012 #include "Alignment/CommonAlignment/interface/SurveyDet.h"
0013 #include "Alignment/SurveyAnalysis/interface/SurveyInputBase.h"
0014 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0015 
0016 class SurveyInputTest : public SurveyInputBase {
0017 public:
0018   SurveyInputTest(const edm::ParameterSet&);
0019 
0020   /// Read data from cfg file
0021   virtual void beginJob();
0022 
0023   virtual void analyze(const edm::Event&, const edm::EventSetup&) {}
0024 
0025 private:
0026   Alignable* create(const std::string& parName  // name of alignable
0027   );
0028 
0029   edm::ParameterSet theConfig;
0030 };
0031 
0032 using namespace align;
0033 
0034 SurveyInputTest::SurveyInputTest(const edm::ParameterSet& cfg) : theConfig(cfg) {}
0035 
0036 void SurveyInputTest::beginJob() { addComponent(create(theConfig.getParameter<std::string>("detector"))); }
0037 
0038 Alignable* SurveyInputTest::create(const std::string& parName) {
0039   typedef std::vector<double> Doubles;
0040   typedef std::vector<std::string> Strings;
0041 
0042   static const Doubles zero3Vector(3, 0.);
0043   static const Doubles zero6Vector(6, 0.);
0044   static const Strings emptyString;
0045 
0046   edm::ParameterSet pars = theConfig.getParameter<edm::ParameterSet>(parName);
0047 
0048   Doubles center = pars.getUntrackedParameter<Doubles>("center", zero3Vector);
0049   Doubles angles = pars.getUntrackedParameter<Doubles>("angles", zero3Vector);
0050   Doubles shifts = pars.getUntrackedParameter<Doubles>("shifts", zero6Vector);
0051   Doubles errors = pars.getUntrackedParameter<Doubles>("errors", zero6Vector);
0052 
0053   ErrorMatrix cov;
0054 
0055   for (unsigned int i = 0; i < 6; ++i)
0056     cov(i, i) = errors[i];
0057 
0058   PositionType pos(center[0], center[1], center[2]);
0059   EulerAngles ang(3);
0060 
0061   ang(1) = angles[0], ang(2) = angles[1];
0062   ang(3) = angles[2];
0063 
0064   AlignableSurface surf(pos, toMatrix(ang));
0065 
0066   surf.setWidth(pars.getUntrackedParameter<double>("width", 0.));
0067   surf.setLength(pars.getUntrackedParameter<double>("length", 0.));
0068 
0069   int type = pars.getParameter<int>("typeId");
0070   std::string name = pars.getParameter<std::string>("object");
0071 
0072   // FIXME: - currently defaulting to RunI as this was the previous behaviour
0073   //        - check this, when resurrecting this code in the future
0074   AlignableObjectId alignableObjectId{AlignableObjectId::Geometry::General};
0075 
0076   Alignable* ali = new AlignableComposite(type, alignableObjectId.stringToId(name), surf.rotation());
0077 
0078   Strings comp = pars.getUntrackedParameter<Strings>("compon", emptyString);
0079 
0080   unsigned int nComp = comp.size();
0081 
0082   for (unsigned int i = 0; i < nComp; ++i) {
0083     ali->addComponent(create(comp[i]));
0084   }
0085 
0086   ang(1) = shifts[3], ang(2) = shifts[4];
0087   ang(3) = shifts[5];
0088 
0089   ali->setSurvey(new SurveyDet(surf, cov));
0090   ali->move(surf.toGlobal(align::LocalVector(shifts[0], shifts[1], shifts[2])));
0091   ali->rotateInLocalFrame(toMatrix(ang));
0092 
0093   return ali;
0094 }
0095 
0096 #include "FWCore/Framework/interface/MakerMacros.h"
0097 DEFINE_FWK_MODULE(SurveyInputTest);