Skip to content

Commit

Permalink
made squash
Browse files Browse the repository at this point in the history
  • Loading branch information
slomeo committed Mar 5, 2020
1 parent f5f2f2d commit 280bf59
Show file tree
Hide file tree
Showing 11 changed files with 514 additions and 459 deletions.
28 changes: 8 additions & 20 deletions Geometry/CSCGeometryBuilder/plugins/CSCGeometryESModule.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//
//
// \author Sergio Lo Meo (sergio.lo.meo@cern.ch) following what Ianna Osburne made for DTs (DD4HEP migration)
// Created: Fri, 27 Sep 2019
// Created: Thu, 05 March 2020
//
// Old DD version author: Tim Cox
*/
Expand All @@ -25,21 +25,13 @@
#include "Geometry/MuonNumbering/interface/MuonDDDNumbering.h"
#include "Geometry/MuonNumbering/interface/MuonBaseNumber.h"

// to debug
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <math.h>

using namespace edm;
using namespace std; // to debug

CSCGeometryESModule::CSCGeometryESModule(const edm::ParameterSet& p)
: useDDD_(p.getParameter<bool>("useDDD")),
useDD4hep_(p.getParameter<bool>("useDD4hep")),
alignmentsLabel_(p.getParameter<std::string>("alignmentsLabel")),
myLabel_(p.getParameter<std::string>("appendToDataLabel")) {
: useDDD_(p.getParameter<bool>("useDDD")),
useDD4hep_(p.getParameter<bool>("useDD4hep")),
alignmentsLabel_(p.getParameter<std::string>("alignmentsLabel")),
myLabel_(p.getParameter<std::string>("appendToDataLabel")) {
auto cc = setWhatProduced(this);

// Choose wire geometry modelling
Expand Down Expand Up @@ -79,7 +71,7 @@ CSCGeometryESModule::CSCGeometryESModule(const edm::ParameterSet& p)
} else if (useDD4hep_) {
cpvTokendd4hep_ = cc.consumesFrom<cms::DDCompactView, IdealGeometryRecord>(edm::ESInputTag{});
mdcTokendd4hep_ = cc.consumesFrom<cms::MuonNumbering, MuonNumberingRecord>(edm::ESInputTag{});
} else {
} else {
rigToken_ = cc.consumesFrom<RecoIdealGeometry, CSCRecoGeometryRcd>(edm::ESInputTag{});
rdpToken_ = cc.consumesFrom<CSCRecoDigiParameters, CSCRecoDigiParametersRcd>(edm::ESInputTag{});
}
Expand Down Expand Up @@ -139,19 +131,15 @@ void CSCGeometryESModule::initCSCGeometry_(const MuonGeometryRecord& record, std
CSCGeometryBuilderFromDDD builder;
builder.build(*host, cpv.product(), mdc);
});
} else if (useDD4hep_) {
} else if (useDD4hep_) {
host->ifRecordChanges<MuonNumberingRecord>(record, [&host, &record, this](auto const& rec) {
host->clear();
edm::ESTransientHandle<cms::DDCompactView> cpv = record.getTransientHandle(cpvTokendd4hep_);
const auto& mdc = rec.get(mdcTokendd4hep_);
//for (auto& i: mdc.values())
// {
// cout<<"MYDEBUG, CSCGeometryESModule, mdc.values() first and second "<<i.first<<": "<<i.second<<endl;
// }
CSCGeometryBuilderFromDDD builder;
builder.build(*host, cpv.product(), mdc);
});
} else {
} else {
bool recreateGeometry = false;

host->ifRecordChanges<CSCRecoGeometryRcd>(record,
Expand Down
4 changes: 2 additions & 2 deletions Geometry/CSCGeometryBuilder/plugins/CSCGeometryESModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//
//
// \author Sergio Lo Meo (sergio.lo.meo@cern.ch) following what Ianna Osburne made for DTs (DD4HEP migration)
// Created: Fri, 27 Sep 2019
// Created: Thu, 05 March 2020
//
// Old DD version author: Tim Cox
*/
Expand Down Expand Up @@ -81,7 +81,7 @@ class CSCGeometryESModule : public edm::ESProducer {
bool debugV;
bool applyAlignment_; // Switch to apply alignment corrections
bool useDDD_; // whether to build from DDD or DB
bool useDD4hep_;
bool useDD4hep_;
const std::string alignmentsLabel_;
const std::string myLabel_;
};
Expand Down
63 changes: 20 additions & 43 deletions Geometry/CSCGeometryBuilder/plugins/CSCGeometryValidate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//
// Author: Sergio Lo Meo (sergio.lo.meo@cern.ch) following what Ianna Osburne made for DTs (DD4HEP migration)
// Created: Fri, 20 Sep 2019
// Created: Thu, 05 March 2020
*/

#include "FWCore/Framework/interface/one/EDAnalyzer.h"
Expand Down Expand Up @@ -109,8 +109,8 @@ class CSCGeometryValidate : public one::EDAnalyzer<> {
vector<float> centreToIntersection_;
vector<float> phiOfOneEdge_;
//wires
vector<float> wireSpacing_;
vector<float> wireAngle_;
vector<float> wireSpacing_;
vector<float> wireAngle_;
//files
string infileName_;
string outfileName_;
Expand All @@ -122,29 +122,22 @@ CSCGeometryValidate::CSCGeometryValidate(const edm::ParameterSet& iConfig)
outfileName_(iConfig.getUntrackedParameter<string>("outfileName", "validateCSCGeometry.root")),
tolerance_(iConfig.getUntrackedParameter<int>("tolerance", 6)) {
fwGeometry_.loadMap(infileName_.c_str());
outFile_ = new TFile(outfileName_.c_str(), "RECREATE");
outFile_ = TFile::Open(outfileName_.c_str(), "RECREATE");
}

void CSCGeometryValidate::analyze(const edm::Event& event, const edm::EventSetup& eventSetup) {
cout<<"MYVALIDATE STARTING CREATION cscGeometry_ "<<endl;
eventSetup.get<MuonGeometryRecord>().get(cscGeometry_);
cout<<"MYVALIDATE cscGeometry_ CREATED"<<endl;
if (cscGeometry_.isValid()) {
cout<<"MYVALIDATE cscGeometry_.isValid() = OK"<<endl;
LogVerbatim("CSCGeometry") << "Validating CSC chamber geometry";
cout<<"MYVALIDATE START CHAMBERS VALIDATION "<<endl;
validateCSCChamberGeometry();
cout<<"MYVALIDATE END CHAMBERS VALIDATION "<<endl;
cout<<"MYVALIDATE START LAYERS VALIDATION "<<endl;
validateCSCLayerGeometry();
cout<<"MYVALIDATE END LAYERS VALIDATION "<<endl;
} else
LogVerbatim("CSCGeometry") << "Invalid CSC geometry";
}

void CSCGeometryValidate::validateCSCChamberGeometry() {
clearData();

for (auto const& it : cscGeometry_->chambers()) {
CSCDetId chId = it->id();
GlobalPoint gp = it->surface().toGlobal(LocalPoint(0.0, 0.0, 0.0));
Expand All @@ -156,59 +149,46 @@ void CSCGeometryValidate::validateCSCChamberGeometry() {
continue;
}
compareTransform(gp, matrix);
cout<<"MYVALIDATE CSC Chamber ID "<<chId.rawId()<<" compareTransform: DONE"<<endl;

auto const& shape = fwGeometry_.getShapePars(chId.rawId());

if (!shape) {
LogVerbatim("CSCGeometry") << "Failed to get shape of CSC chamber with detid: " << chId.rawId();
continue;
}
compareShape(it, shape);
cout<<"MYVALIDATE CSC Chamber ID "<<chId.rawId()<<" compareShape: DONE"<<endl;
}
makeHistograms("CSC Chamber");
cout<<"MYVALIDATE HISTOS DONE"<<endl;
}

void CSCGeometryValidate::validateCSCLayerGeometry() {
clearData2();

for (auto const& it : cscGeometry_->layers()) {
CSCDetId chId = it->id();
const CSCLayerGeometry* laygeo = it->geometry();
const int n_strips = laygeo->numberOfStrips();
const int n_wire = laygeo->numberOfWires();
const float strips_offset = laygeo->stripOffset();
const CSCStripTopology* stopo = laygeo->topology();
const float ycentre_of_strip_plane = stopo->yCentreOfStripPlane();
const float angular_width = stopo->angularWidth();
const float y_axis_orientation = stopo->yAxisOrientation();
const float centre_to_intersection = stopo->centreToIntersection();
const float phi_of_one_edge = stopo->phiOfOneEdge();
const float ycentre_of_strip_plane = stopo->yCentreOfStripPlane();
const float angular_width = stopo->angularWidth();
const float y_axis_orientation = stopo->yAxisOrientation();
const float centre_to_intersection = stopo->centreToIntersection();
const float phi_of_one_edge = stopo->phiOfOneEdge();
const float* parameters = fwGeometry_.getParameters(chId.rawId());
cout<<"MYVALIDATE From Geo, detid: "<<chId.rawId()<<" nstrips: "<<n_strips<<" nwire: "<<n_wire<<endl;

cout<<"MYVALIDATE From Geo, detid: "<<chId.rawId()<<" strpis offset: "<<strips_offset<<" y centre of strip plane: "<<ycentre_of_strip_plane<<" angular width: "<<angular_width<<endl;
cout<<"MYVALIDATE From Reco, detid: "<<chId.rawId()<<" strpis offset: "<<parameters[4]<<" y centre of strip plane: "<<parameters[2]<<" angular width: "<<parameters[5]<<endl;

cout<<"MYVALIDATE From Geo, detid: "<<chId.rawId()<<" y axis orientation: "<<y_axis_orientation<<" centre to intersection: "<<centre_to_intersection<<" phi of one edge: "<<phi_of_one_edge<<endl;
cout<<"MYVALIDATE From Reco, detid: "<<chId.rawId()<<" y axis orientation: "<<parameters[0]<<" centre to intersection: "<<parameters[1]<<" phi of one edge: "<<parameters[3]<<endl;

const CSCWireTopology* wiretopo = laygeo->wireTopology();
const double wire_spacing = wiretopo->wireSpacing();
const float wire_angle = wiretopo->wireAngle();
cout<<"MYVALIDATE From Geo, detid: "<<chId.rawId()<<" wire spacing: "<<wire_spacing<<" wire angle: "<<wire_angle<<endl;
cout<<"MYVALIDATE From Reco, detid: "<<chId.rawId()<<" wire spacing: "<<parameters[6]<<" wire angle: "<<parameters[7]<<endl;


const double wire_spacing = wiretopo->wireSpacing();
const float wire_angle = wiretopo->wireAngle();

if (n_strips) {
for (int istrips = 1; istrips <= n_strips; istrips++) {
yAxisOrientation_.push_back(fabs(y_axis_orientation - parameters[0]));
sOffset_.push_back(fabs(strips_offset - parameters[4]));
sOffset_.push_back(fabs(strips_offset - parameters[4]));
yCentreOfStripPlane_.push_back(fabs(ycentre_of_strip_plane - parameters[2]));
angularWidth_.push_back(fabs(angular_width - parameters[5]));
centreToIntersection_.push_back(fabs(centre_to_intersection - parameters[1]));
phiOfOneEdge_.push_back(fabs(phi_of_one_edge - parameters[3]));
angularWidth_.push_back(fabs(angular_width - parameters[5]));
centreToIntersection_.push_back(fabs(centre_to_intersection - parameters[1]));
phiOfOneEdge_.push_back(fabs(phi_of_one_edge - parameters[3]));
}
} else {
LogVerbatim("CSCGeometry") << "ATTENTION! nStrips == 0";
Expand All @@ -217,15 +197,13 @@ void CSCGeometryValidate::validateCSCLayerGeometry() {
if (n_wire) {
for (int iwires = 1; iwires <= n_wire; iwires++) {
wireSpacing_.push_back(fabs(wire_spacing - parameters[6]));
wireAngle_.push_back(fabs(wire_angle - parameters[7]));
wireAngle_.push_back(fabs(wire_angle - parameters[7]));
}
} else {
LogVerbatim("CSCGeometry") << "ATTENTION! nWires == 0";
}

}
makeHistograms2("CSC Layer");

}

void CSCGeometryValidate::compareTransform(const GlobalPoint& gp, const TGeoMatrix* matrix) {
Expand Down Expand Up @@ -352,7 +330,6 @@ void CSCGeometryValidate::makeHistograms2(const char* detector) {

string wa = d + ": absolute difference between 'wire angle' of the Wires ";
makeHistogram(wa, wireAngle_);

}

void CSCGeometryValidate::makeHistogram(const string& name, vector<float>& data) {
Expand Down
27 changes: 7 additions & 20 deletions Geometry/CSCGeometryBuilder/src/CSCGeometryBuilderFromDDD.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
//
//
// \author Sergio Lo Meo (sergio.lo.meo@cern.ch) following what Ianna Osburne made for DTs (DD4HEP migration)
// Created: Fri, 27 Sep 2019
// Created: Thu, 05 March 2020
//
// Old DD version author: Tim Cox
*/
//
//
#include "CSCGeometryBuilderFromDDD.h"
#include "CSCGeometryBuilder.h"
#include "CSCGeometryParsFromDD.h"
Expand All @@ -25,15 +25,6 @@

#include <utility>

// to debug
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <math.h>

using namespace std;// to debug

CSCGeometryBuilderFromDDD::CSCGeometryBuilderFromDDD() : myName("CSCGeometryBuilderFromDDD") {}

CSCGeometryBuilderFromDDD::~CSCGeometryBuilderFromDDD() {}
Expand All @@ -49,7 +40,6 @@ void CSCGeometryBuilderFromDDD::build(CSCGeometry& geom,
CSCGeometryParsFromDD cscp;
if (!cscp.build(cview, muonConstants, rig, rdp)) {
throw cms::Exception("CSCGeometryBuilderFromDDD", "Failed to build the necessary objects from the DDD");
cout<<"MYDEBUG, CSCGeometryBuilderFromDDD "<< "Failed to build the necessary objects from the DDD" <<endl;
}
CSCGeometryBuilder realbuilder;
realbuilder.build(geom, rig, rdp);
Expand All @@ -58,19 +48,16 @@ void CSCGeometryBuilderFromDDD::build(CSCGeometry& geom,
// for DD4hep

void CSCGeometryBuilderFromDDD::build(CSCGeometry& geom,
const cms::DDCompactView* cview,
const cms::MuonNumbering& muonConstants) {

const cms::DDCompactView* cview,
const cms::MuonNumbering& muonConstants) {
RecoIdealGeometry rig;
CSCRecoDigiParameters rdp;
CSCGeometryParsFromDD cscp;

CSCGeometryParsFromDD cscp;
if (!cscp.build(cview, muonConstants, rig, rdp)) {
throw cms::Exception("CSCGeometryBuilderFromDDD", "Failed to build the necessary objects from the DD4HEP");
cout<<"MYDEBUG, CSCGeometryBuilderFromDDD "<< "Failed to build the necessary objects from the DD4HEP" <<endl;
}

CSCGeometryBuilder realbuilder;
realbuilder.build(geom, rig, rdp);

}
12 changes: 6 additions & 6 deletions Geometry/CSCGeometryBuilder/src/CSCGeometryBuilderFromDDD.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
//
//
// \author Sergio Lo Meo (sergio.lo.meo@cern.ch) following what Ianna Osburne made for DTs (DD4HEP migration)
// Created: Fri, 27 Sep 2019
// Created: Thu, 05 March 2020
//
// Old DD version author: Tim Cox
*/
//
//

#include <DataFormats/MuonDetId/interface/CSCDetId.h>
#include "Geometry/MuonNumbering/interface/DD4hep_MuonNumbering.h"
Expand All @@ -25,7 +25,7 @@ namespace cms {
class DDFilteredView;
class DDCompactView;
class MuonNumbering;
}
} // namespace cms

class CSCGeometryBuilderFromDDD {
public:
Expand All @@ -36,10 +36,10 @@ class CSCGeometryBuilderFromDDD {
virtual ~CSCGeometryBuilderFromDDD();

// Build the geometry DDD
void build(CSCGeometry& geom, const DDCompactView* fv, const MuonDDDConstants& muonConstants);
void build(CSCGeometry& geom, const DDCompactView* fv, const MuonDDDConstants& muonConstants);

// Build the geometry dd4hep
void build(CSCGeometry& geom, const cms::DDCompactView* cview, const cms::MuonNumbering& muonConstants);
// Build the geometry dd4hep
void build(CSCGeometry& geom, const cms::DDCompactView* cview, const cms::MuonNumbering& muonConstants);

protected:
private:
Expand Down
Loading

0 comments on commit 280bf59

Please sign in to comment.