CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
TrackerGeometryIntoNtuples Class Reference

#include <TrackerGeometryIntoNtuples.cc>

Inheritance diagram for TrackerGeometryIntoNtuples:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 TrackerGeometryIntoNtuples (const edm::ParameterSet &)
 
 ~TrackerGeometryIntoNtuples () override
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Types

enum  { kMaxNumPar = 20 }
 

Private Member Functions

void addBranches ()
 
void analyze (const edm::Event &iEvent, const edm::EventSetup &iSetup) override
 

Private Attributes

Float_t deformationValues_ [kMaxNumPar]
 
double m_alpha
 
double m_beta
 
double m_d1
 
double m_d2
 
double m_d3
 
int m_dNpar
 
int m_dtype
 
TFile * m_file
 
double m_gamma
 
std::string m_outputFile
 
std::string m_outputTreename
 
uint32_t m_rawid
 
int m_subdetid
 
TTree * m_tree
 
TTree * m_treeDeformations
 
TTree * m_treeErrors
 
double m_x
 
double m_xx
 
double m_xy
 
double m_xz
 
double m_y
 
double m_yy
 
double m_yz
 
double m_z
 
double m_zz
 
std::vector< double > * mp_dpar
 
UInt_t numDeformationValues_
 
AlignableTrackertheCurrentTracker
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Description: Takes a set of alignment constants and turns them into a ROOT file

Implementation: <Notes on="" implementation>="">

Definition at line 74 of file TrackerGeometryIntoNtuples.cc.

Member Enumeration Documentation

anonymous enum
private
Enumerator
kMaxNumPar 

Definition at line 101 of file TrackerGeometryIntoNtuples.cc.

101 { kMaxNumPar = 20 }; // slighly above 'two bowed surfaces' limit

Constructor & Destructor Documentation

TrackerGeometryIntoNtuples::TrackerGeometryIntoNtuples ( const edm::ParameterSet iConfig)
explicit

Definition at line 123 of file TrackerGeometryIntoNtuples.cc.

References edm::ParameterSet::getUntrackedParameter(), m_file, m_outputFile, m_outputTreename, m_tree, m_treeDeformations, m_treeErrors, and AlCaHLTBitMon_QueryRunRegistry::string.

124  : theCurrentTracker(nullptr),
125  m_rawid(0),
126  m_x(0.),
127  m_y(0.),
128  m_z(0.),
129  m_alpha(0.),
130  m_beta(0.),
131  m_gamma(0.),
132  m_subdetid(0),
133  m_xx(0.),
134  m_xy(0.),
135  m_yy(0.),
136  m_xz(0.),
137  m_yz(0.),
138  m_zz(0.),
139  m_dNpar(0),
140  m_d1(0.),
141  m_d2(0.),
142  m_d3(0.),
143  m_dtype(0),
144  mp_dpar(nullptr) {
145  m_outputFile = iConfig.getUntrackedParameter<std::string>("outputFile");
146  m_outputTreename = iConfig.getUntrackedParameter<std::string>("outputTreename");
147  m_file = new TFile(m_outputFile.c_str(), "RECREATE");
148  m_tree = new TTree(m_outputTreename.c_str(), m_outputTreename.c_str());
149  m_treeDeformations = new TTree("alignTreeDeformations", "alignTreeDeformations");
150  //char errorTreeName[256];
151  //snprintf(errorTreeName, sizeof(errorTreeName), "%sErrors", m_outputTreename);
152  //m_treeErrors = new TTree(errorTreeName,errorTreeName);
153  m_treeErrors = new TTree("alignTreeErrors", "alignTreeErrors");
154 }
T getUntrackedParameter(std::string const &, T const &) const
TrackerGeometryIntoNtuples::~TrackerGeometryIntoNtuples ( )
override

Definition at line 156 of file TrackerGeometryIntoNtuples.cc.

References theCurrentTracker.

156 { delete theCurrentTracker; }

Member Function Documentation

void TrackerGeometryIntoNtuples::addBranches ( )
private

Definition at line 288 of file TrackerGeometryIntoNtuples.cc.

References DEFINE_FWK_MODULE, m_alpha, m_beta, m_dNpar, m_dtype, m_gamma, m_rawid, m_subdetid, m_tree, m_treeDeformations, m_treeErrors, m_x, m_xx, m_xy, m_xz, m_y, m_yy, m_yz, m_z, m_zz, and mp_dpar.

Referenced by Vispa.Plugins.EdmBrowser.EventContentDataAccessor.EventContentDataAccessor::addContentFile(), and analyze().

288  {
289  m_tree->Branch("rawid", &m_rawid, "rawid/I");
290  m_tree->Branch("x", &m_x, "x/D");
291  m_tree->Branch("y", &m_y, "y/D");
292  m_tree->Branch("z", &m_z, "z/D");
293  m_tree->Branch("alpha", &m_alpha, "alpha/D");
294  m_tree->Branch("beta", &m_beta, "beta/D");
295  m_tree->Branch("gamma", &m_gamma, "gamma/D");
296 
297  m_treeDeformations->Branch("irawid", &m_rawid, "irawid/I");
298  m_treeDeformations->Branch("subdetid", &m_subdetid, "subdetid/I");
299  m_treeDeformations->Branch("dNpar", &m_dNpar, "dNpar/I");
300  //m_treeDeformations->Branch("d1", &m_d1, "d1/D");
301  //m_treeDeformations->Branch("d2", &m_d2, "d2/D");
302  //m_treeDeformations->Branch("d3", &m_d3, "d3/D");
303  m_treeDeformations->Branch("dtype", &m_dtype);
304  m_treeDeformations->Branch("dpar", "std::vector<double>", &mp_dpar);
305 
306  m_treeErrors->Branch("rawid", &m_rawid, "rawid/I");
307  m_treeErrors->Branch("subdetid", &m_subdetid, "subdetid/I");
308  m_treeErrors->Branch("xx", &m_xx, "xx/D");
309  m_treeErrors->Branch("yy", &m_yy, "yy/D");
310  m_treeErrors->Branch("zz", &m_zz, "zz/D");
311  m_treeErrors->Branch("xy", &m_xy, "xy/D");
312  m_treeErrors->Branch("xz", &m_xz, "xz/D");
313  m_treeErrors->Branch("yz", &m_yz, "yz/D");
314 
315  //m_tree->Branch("NumDeform", &numDeformationValues_, "NumDeform/i");
316  //m_tree->Branch("DeformValues", deformationValues_, "DeformValues[NumDeform]/F");
317 }
void TrackerGeometryIntoNtuples::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 163 of file TrackerGeometryIntoNtuples.cc.

References addBranches(), GeometryAligner::applyAlignments(), GeometryAligner::attachSurfaceDeformations(), TrackerGeomBuilderFromGeometricDet::build(), align::DetectorGlobalPosition(), TrackerGeometry::detUnits(), edm::EventSetup::get(), edm::eventsetup::DependentRecordImplementation< RecordT, ListT >::get(), mps_fire::i, Alignments::m_align, m_alpha, m_beta, m_d1, m_d2, m_d3, m_dNpar, m_dtype, m_file, m_gamma, m_rawid, m_subdetid, m_tree, m_treeDeformations, m_treeErrors, m_x, m_xx, m_xy, m_xz, m_y, m_yy, m_yz, m_z, m_zz, mp_dpar, edm::ESHandle< T >::product(), DetId::rawId(), idealTransformation::rotation, DetId::subdetId(), theCurrentTracker, and DetId::Tracker.

163  {
164  // retrieve tracker topology from geometry
165  edm::ESHandle<TrackerTopology> tTopoHandle;
166  iSetup.get<TrackerTopologyRcd>().get(tTopoHandle);
167  const TrackerTopology* const tTopo = tTopoHandle.product();
168 
169  edm::LogInfo("beginJob") << "Begin Job";
170 
171  //accessing the initial geometry
172  edm::ESHandle<GeometricDet> theGeometricDet;
173  iSetup.get<IdealGeometryRecord>().get(theGeometricDet);
175  iSetup.get<PTrackerParametersRcd>().get(ptp);
176  TrackerGeomBuilderFromGeometricDet trackerBuilder;
177  //currernt tracker
178  TrackerGeometry* theCurTracker = trackerBuilder.build(&*theGeometricDet, *ptp, tTopo);
179 
180  //build the tracker
181  edm::ESHandle<Alignments> alignments;
184 
185  iSetup.get<TrackerAlignmentRcd>().get(alignments);
186  iSetup.get<TrackerAlignmentErrorExtendedRcd>().get(alignmentErrors);
187  iSetup.get<TrackerSurfaceDeformationRcd>().get(surfaceDeformations);
188 
189  //apply the latest alignments
190  edm::ESHandle<Alignments> globalPositionRcd;
191  iSetup.get<TrackerDigiGeometryRecord>().getRecord<GlobalPositionRcd>().get(globalPositionRcd);
192  GeometryAligner aligner;
193  aligner.applyAlignments<TrackerGeometry>(&(*theCurTracker),
194  &(*alignments),
195  &(*alignmentErrors),
196  align::DetectorGlobalPosition(*globalPositionRcd, DetId(DetId::Tracker)));
197  aligner.attachSurfaceDeformations<TrackerGeometry>(&(*theCurTracker), &(*surfaceDeformations));
198 
199  theCurrentTracker = new AlignableTracker(&(*theCurTracker), tTopo);
200 
201  Alignments* theAlignments = theCurrentTracker->alignments();
202  //AlignmentErrorsExtended* theAlignmentErrorsExtended = theCurrentTracker->alignmentErrors();
203 
204  //alignments
205  addBranches();
206  for (std::vector<AlignTransform>::const_iterator i = theAlignments->m_align.begin();
207  i != theAlignments->m_align.end();
208  ++i) {
209  m_rawid = i->rawId();
210  CLHEP::Hep3Vector translation = i->translation();
211  m_x = translation.x();
212  m_y = translation.y();
213  m_z = translation.z();
214 
215  CLHEP::HepRotation rotation = i->rotation();
216  m_alpha = rotation.getPhi();
217  m_beta = rotation.getTheta();
218  m_gamma = rotation.getPsi();
219  m_tree->Fill();
220 
221  //DetId detid(m_rawid);
222  //if (detid.subdetId() > 2){
223  //
224  //std::cout << " panel: " << tTopo->pxfPanel( m_rawid ) << ", module: " << tTopo->pxfModule( m_rawid ) << std::endl;
225  //if ((tTopo->pxfPanel( m_rawid ) == 1) && (tTopo->pxfModule( m_rawid ) == 4)) std::cout << m_rawid << ", ";
226  //std::cout << m_rawid << std::setprecision(9) << " " << m_x << " " << m_y << " " << m_z;
227  //std::cout << std::setprecision(9) << " " << m_alpha << " " << m_beta << " " << m_gamma << std::endl;
228  //}
229  }
230 
231  delete theAlignments;
232 
233  std::vector<AlignTransformErrorExtended> alignErrors = alignmentErrors->m_alignError;
234  for (std::vector<AlignTransformErrorExtended>::const_iterator i = alignErrors.begin(); i != alignErrors.end(); ++i) {
235  m_rawid = i->rawId();
236  CLHEP::HepSymMatrix errMatrix = i->matrix();
237  DetId detid(m_rawid);
238  m_subdetid = detid.subdetId();
239  m_xx = errMatrix[0][0];
240  m_xy = errMatrix[0][1];
241  m_xz = errMatrix[0][2];
242  m_yy = errMatrix[1][1];
243  m_yz = errMatrix[1][2];
244  m_zz = errMatrix[2][2];
245  m_treeErrors->Fill();
246  }
247 
248  // Get GeomDetUnits for the current tracker
249  auto const& detUnits = theCurTracker->detUnits();
250  int detUnit(0);
251  //\\for (unsigned int iDet = 0; iDet < detUnits.size(); ++iDet) {
252  for (auto iunit = detUnits.begin(); iunit != detUnits.end(); ++iunit) {
253  DetId detid = (*iunit)->geographicalId();
254  m_rawid = detid.rawId();
255  m_subdetid = detid.subdetId();
256 
257  ++detUnit;
258  //\\GeomDetUnit* geomDetUnit = detUnits.at(iDet) ;
259  auto geomDetUnit = *iunit;
260 
261  // Get SurfaceDeformation for this GeomDetUnit
262  if (geomDetUnit->surfaceDeformation()) {
263  std::vector<double> surfaceDeformParams = (geomDetUnit->surfaceDeformation())->parameters();
264  //edm::LogInfo("surfaceDeformParamsSize") << " surfaceDeformParams size = " << surfaceDeformParams.size() << std::endl ;
265  m_dNpar = surfaceDeformParams.size();
266  m_dtype = (geomDetUnit->surfaceDeformation())->type();
267  m_d1 = surfaceDeformParams.at(0);
268  m_d2 = surfaceDeformParams.at(1);
269  m_d3 = surfaceDeformParams.at(2);
270  mp_dpar->clear();
271  for (std::vector<double>::const_iterator it = surfaceDeformParams.begin(); it != surfaceDeformParams.end();
272  ++it) {
273  mp_dpar->push_back((*it));
274  //edm::LogInfo("surfaceDeformParamsContent") << " surfaceDeformParam = " << (*it) << std::endl ;
275  }
276  m_treeDeformations->Fill();
277  }
278  }
279 
280  //write out
281  m_file->cd();
282  m_tree->Write();
283  m_treeDeformations->Write();
284  m_treeErrors->Write();
285  m_file->Close();
286 }
type
Definition: HCALResponse.h:21
const DetContainer & detUnits() const override
Returm a vector of all GeomDet.
Class to update a given geometry with a set of alignments.
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
TrackerGeometry * build(const GeometricDet *gd, const PTrackerParameters &ptp, const TrackerTopology *tTopo)
std::vector< AlignTransform > m_align
Definition: Alignments.h:19
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
void attachSurfaceDeformations(C *geometry, const AlignmentSurfaceDeformations *surfaceDeformations)
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
Definition: DetId.h:17
void applyAlignments(C *geometry, const Alignments *alignments, const AlignmentErrorsExtended *alignmentErrors, const AlignTransform &globalCoordinates)
T get() const
Definition: EventSetup.h:73
const AlignTransform & DetectorGlobalPosition(const Alignments &allGlobals, const DetId &id)
T const * product() const
Definition: ESHandle.h:86

Member Data Documentation

Float_t TrackerGeometryIntoNtuples::deformationValues_[kMaxNumPar]
private

Definition at line 102 of file TrackerGeometryIntoNtuples.cc.

double TrackerGeometryIntoNtuples::m_alpha
private

Definition at line 90 of file TrackerGeometryIntoNtuples.cc.

Referenced by addBranches(), and analyze().

double TrackerGeometryIntoNtuples::m_beta
private

Definition at line 90 of file TrackerGeometryIntoNtuples.cc.

Referenced by addBranches(), and analyze().

double TrackerGeometryIntoNtuples::m_d1
private

Definition at line 94 of file TrackerGeometryIntoNtuples.cc.

Referenced by analyze().

double TrackerGeometryIntoNtuples::m_d2
private

Definition at line 94 of file TrackerGeometryIntoNtuples.cc.

Referenced by analyze().

double TrackerGeometryIntoNtuples::m_d3
private

Definition at line 94 of file TrackerGeometryIntoNtuples.cc.

Referenced by analyze().

int TrackerGeometryIntoNtuples::m_dNpar
private

Definition at line 93 of file TrackerGeometryIntoNtuples.cc.

Referenced by addBranches(), and analyze().

int TrackerGeometryIntoNtuples::m_dtype
private

Definition at line 95 of file TrackerGeometryIntoNtuples.cc.

Referenced by addBranches(), and analyze().

TFile* TrackerGeometryIntoNtuples::m_file
private

Definition at line 109 of file TrackerGeometryIntoNtuples.cc.

Referenced by analyze(), and TrackerGeometryIntoNtuples().

double TrackerGeometryIntoNtuples::m_gamma
private

Definition at line 90 of file TrackerGeometryIntoNtuples.cc.

Referenced by addBranches(), and analyze().

std::string TrackerGeometryIntoNtuples::m_outputFile
private

Definition at line 107 of file TrackerGeometryIntoNtuples.cc.

Referenced by TrackerGeometryIntoNtuples().

std::string TrackerGeometryIntoNtuples::m_outputTreename
private

Definition at line 108 of file TrackerGeometryIntoNtuples.cc.

Referenced by TrackerGeometryIntoNtuples().

uint32_t TrackerGeometryIntoNtuples::m_rawid
private

Definition at line 88 of file TrackerGeometryIntoNtuples.cc.

Referenced by addBranches(), and analyze().

int TrackerGeometryIntoNtuples::m_subdetid
private

Definition at line 91 of file TrackerGeometryIntoNtuples.cc.

Referenced by addBranches(), and analyze().

TTree* TrackerGeometryIntoNtuples::m_tree
private

Definition at line 104 of file TrackerGeometryIntoNtuples.cc.

Referenced by addBranches(), analyze(), and TrackerGeometryIntoNtuples().

TTree* TrackerGeometryIntoNtuples::m_treeDeformations
private

Definition at line 105 of file TrackerGeometryIntoNtuples.cc.

Referenced by addBranches(), analyze(), and TrackerGeometryIntoNtuples().

TTree* TrackerGeometryIntoNtuples::m_treeErrors
private

Definition at line 106 of file TrackerGeometryIntoNtuples.cc.

Referenced by addBranches(), analyze(), and TrackerGeometryIntoNtuples().

double TrackerGeometryIntoNtuples::m_x
private

Definition at line 89 of file TrackerGeometryIntoNtuples.cc.

Referenced by addBranches(), and analyze().

double TrackerGeometryIntoNtuples::m_xx
private

Definition at line 92 of file TrackerGeometryIntoNtuples.cc.

Referenced by addBranches(), and analyze().

double TrackerGeometryIntoNtuples::m_xy
private

Definition at line 92 of file TrackerGeometryIntoNtuples.cc.

Referenced by addBranches(), and analyze().

double TrackerGeometryIntoNtuples::m_xz
private

Definition at line 92 of file TrackerGeometryIntoNtuples.cc.

Referenced by addBranches(), and analyze().

double TrackerGeometryIntoNtuples::m_y
private

Definition at line 89 of file TrackerGeometryIntoNtuples.cc.

Referenced by addBranches(), and analyze().

double TrackerGeometryIntoNtuples::m_yy
private

Definition at line 92 of file TrackerGeometryIntoNtuples.cc.

Referenced by addBranches(), and analyze().

double TrackerGeometryIntoNtuples::m_yz
private

Definition at line 92 of file TrackerGeometryIntoNtuples.cc.

Referenced by addBranches(), and analyze().

double TrackerGeometryIntoNtuples::m_z
private

Definition at line 89 of file TrackerGeometryIntoNtuples.cc.

Referenced by addBranches(), and analyze().

double TrackerGeometryIntoNtuples::m_zz
private

Definition at line 92 of file TrackerGeometryIntoNtuples.cc.

Referenced by addBranches(), and analyze().

std::vector<double>* TrackerGeometryIntoNtuples::mp_dpar
private

Definition at line 97 of file TrackerGeometryIntoNtuples.cc.

Referenced by addBranches(), and analyze().

UInt_t TrackerGeometryIntoNtuples::numDeformationValues_
private

Definition at line 100 of file TrackerGeometryIntoNtuples.cc.

AlignableTracker* TrackerGeometryIntoNtuples::theCurrentTracker
private

Definition at line 86 of file TrackerGeometryIntoNtuples.cc.

Referenced by analyze(), and ~TrackerGeometryIntoNtuples().