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
19 
20 // Alignment
25 
26 // C++
27 #include <boost/shared_ptr.hpp>
28 #include <memory>
29 #include <algorithm>
30 
37 
39 {
40 public:
41 
44 
47 
49  boost::shared_ptr<TrackerGeometry> produce(const TrackerDigiGeometryRecord& iRecord);
50 
51 private:
52  const bool theSaveToDB;
53  const bool theSaveFakeScenario;
56 
57  boost::shared_ptr<TrackerGeometry> theTracker;
58 };
59 
60 //__________________________________________________________________________________________________
61 //__________________________________________________________________________________________________
62 //__________________________________________________________________________________________________
63 
64 
65 
66 //__________________________________________________________________________________________________
68  theSaveToDB(p.getUntrackedParameter<bool>("saveToDbase")),
69  theSaveFakeScenario(p.getUntrackedParameter<bool>("saveFakeScenario")),
70  theScenario(p.getParameter<edm::ParameterSet>("scenario")),
71  theAlignRecordName("TrackerAlignmentRcd"),
72  theErrorRecordName("TrackerAlignmentErrorExtendedRcd")
73 {
74  setWhatProduced(this);
75 
76 }
77 
78 
79 //__________________________________________________________________________________________________
81 
82 
83 //__________________________________________________________________________________________________
84 boost::shared_ptr<TrackerGeometry>
86 {
87  //Retrieve tracker topology from geometry
89  iRecord.getRecord<TrackerTopologyRcd>().get(tTopoHandle);
90  const TrackerTopology* const tTopo = tTopoHandle.product();
91 
92  edm::LogInfo("MisalignedTracker") << "Producer called";
93 
94  // Create the tracker geometry from ideal geometry
96  iRecord.getRecord<IdealGeometryRecord>().get( gD );
98  iRecord.getRecord<PTrackerParametersRcd>().get( ptp );
100  theTracker = boost::shared_ptr<TrackerGeometry>( trackerBuilder.build(&(*gD), *ptp ));
101 
102  // Create the alignable hierarchy
103  std::auto_ptr<AlignableTracker> theAlignableTracker(new AlignableTracker( &(*theTracker), tTopo ) );
104 
105  // Create misalignment scenario, apply to geometry
106  TrackerScenarioBuilder scenarioBuilder( &(*theAlignableTracker) );
107  scenarioBuilder.applyScenario( theScenario );
108  Alignments* alignments = theAlignableTracker->alignments();
109  AlignmentErrorsExtended* alignmentErrors = theAlignableTracker->alignmentErrors();
110 
111  // Store result to EventSetup
112  GeometryAligner aligner;
113  aligner.applyAlignments<TrackerGeometry>( &(*theTracker), alignments, alignmentErrors,
114  AlignTransform()); // dummy global position
115 
116  // Write alignments to DB: have to sort beforhand!
117  if (theSaveToDB) {
118 
119  // Call service
121  if( !poolDbService.isAvailable() ) // Die if not available
122  throw cms::Exception("NotAvailable") << "PoolDBOutputService not available";
123  if (theSaveFakeScenario) { // make empty!
124  alignments->clear();
125  alignmentErrors->clear();
126  }
127  poolDbService->writeOne<Alignments>(alignments, poolDbService->currentTime(),
129  poolDbService->writeOne<AlignmentErrorsExtended>(alignmentErrors, poolDbService->currentTime(),
131  } else {
132  // poolDbService::writeOne takes over ownership
133  // we have to delete in the case that containers are not written
134  delete alignments;
135  delete alignmentErrors;
136  }
137 
138 
139  edm::LogInfo("MisalignedTracker") << "Producer done";
140  return theTracker;
141 
142 }
143 
144 
const bool theSaveFakeScenario
whether or not writing to DB
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:46
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.
void applyAlignments(C *geometry, const Alignments *alignments, const AlignmentErrorsExtended *alignmentErrors, const AlignTransform &globalCoordinates)
boost::shared_ptr< TrackerGeometry > produce(const TrackerDigiGeometryRecord &iRecord)
Produce the misaligned tracker geometry and store it.
T const * product() const
Definition: ESHandle.h:86
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
boost::shared_ptr< TrackerGeometry > theTracker
TrackerGeometry * build(const GeometricDet *gd, const PTrackerParameters &ptp)
const edm::ParameterSet theScenario
if theSaveToDB is true, save a fake scenario (empty alignments), irrespective of the misalignment sce...
Builds a scenario from configuration and applies it to the alignable tracker.
virtual ~MisalignedTrackerESProducer()
Destructor.