CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MisalignedTrackerESProducer.cc
Go to the documentation of this file.
1 // Framework
8 
9 // Conditions database
12 
13 // Geometry
18 
19 // Alignment
24 
25 // C++
26 #include <boost/shared_ptr.hpp>
27 #include <memory>
28 #include <algorithm>
29 
36 
38 {
39 public:
40 
43 
46 
48  boost::shared_ptr<TrackerGeometry> produce(const TrackerDigiGeometryRecord& iRecord);
49 
50 private:
51  const bool theSaveToDB;
53 
55 
56  boost::shared_ptr<TrackerGeometry> theTracker;
57 
58 };
59 
60 //__________________________________________________________________________________________________
61 //__________________________________________________________________________________________________
62 //__________________________________________________________________________________________________
63 
64 
65 
66 //__________________________________________________________________________________________________
68  theSaveToDB(p.getUntrackedParameter<bool>("saveToDbase")),
69  theScenario(p.getParameter<edm::ParameterSet>("scenario")),
70  theAlignRecordName("TrackerAlignmentRcd"),
71  theErrorRecordName("TrackerAlignmentErrorRcd")
72 {
73 
74  setWhatProduced(this);
75 
76 }
77 
78 
79 //__________________________________________________________________________________________________
81 
82 
83 //__________________________________________________________________________________________________
84 boost::shared_ptr<TrackerGeometry>
86 {
87 
88  edm::LogInfo("MisalignedTracker") << "Producer called";
89 
90  // Create the tracker geometry from ideal geometry
92  iRecord.getRecord<IdealGeometryRecord>().get( gD );
94  theTracker = boost::shared_ptr<TrackerGeometry>( trackerBuilder.build(&(*gD)) );
95 
96  // Create the alignable hierarchy
97  std::auto_ptr<AlignableTracker> theAlignableTracker(new AlignableTracker( &(*theTracker) ) );
98 
99  // Create misalignment scenario, apply to geometry
100  TrackerScenarioBuilder scenarioBuilder( &(*theAlignableTracker) );
101  scenarioBuilder.applyScenario( theScenario );
102  Alignments* alignments = theAlignableTracker->alignments();
103  AlignmentErrors* alignmentErrors = theAlignableTracker->alignmentErrors();
104 
105  // Store result to EventSetup
106  GeometryAligner aligner;
107  aligner.applyAlignments<TrackerGeometry>( &(*theTracker), alignments, alignmentErrors,
108  AlignTransform()); // dummy global position
109 
110  // Write alignments to DB: have to sort beforhand!
111  if (theSaveToDB) {
112 
113  // Call service
115  if( !poolDbService.isAvailable() ) // Die if not available
116  throw cms::Exception("NotAvailable") << "PoolDBOutputService not available";
117 
118  poolDbService->writeOne<Alignments>(alignments, poolDbService->currentTime(),
120  poolDbService->writeOne<AlignmentErrors>(alignmentErrors, poolDbService->currentTime(),
122  } else {
123  // poolDbService::writeOne takes over ownership
124  // we have to delete in the case that containers are not written
125  delete alignments;
126  delete alignmentErrors;
127  }
128 
129 
130  edm::LogInfo("MisalignedTracker") << "Producer done";
131  return theTracker;
132 
133 }
134 
135 
Class to update a given geometry with a set of alignments.
void setWhatProduced(T *iThis, const es::Label &iLabel=es::Label())
Definition: ESProducer.h:115
MisalignedTrackerESProducer(const edm::ParameterSet &p)
Constructor.
const std::string theAlignRecordName
misalignment scenario
bool isAvailable() const
Definition: Service.h:47
void applyAlignments(C *geometry, const Alignments *alignments, const AlignmentErrors *alignmentErrors, const AlignTransform &globalCoordinates)
void writeOne(T *payload, Time_t time, const std::string &recordName, bool withlogging=false)
void applyScenario(const edm::ParameterSet &scenario)
Apply misalignment scenario to the tracker.
boost::shared_ptr< TrackerGeometry > produce(const TrackerDigiGeometryRecord &iRecord)
Produce the misaligned tracker geometry and store it.
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:56
TrackerGeometry * build(const GeometricDet *gd)
boost::shared_ptr< TrackerGeometry > theTracker
const edm::ParameterSet theScenario
whether or not writing to DB
Builds a scenario from configuration and applies it to the alignable tracker.
virtual ~MisalignedTrackerESProducer()
Destructor.