Skip to content

Commit

Permalink
Merge pull request #25 from dildick/GEM-72X-II
Browse files Browse the repository at this point in the history
Port SimG4CMS/Muon for GEM/ME0 from 62X SLHC to 72X
  • Loading branch information
Sven Dildick committed Aug 31, 2014
2 parents 98e00f2 + e126183 commit 6290815
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 3 deletions.
34 changes: 34 additions & 0 deletions SimG4CMS/Muon/interface/MuonMe0FrameRotation.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#ifndef MuonMe0FrameRotation_H
#define MuonMe0FrameRotation_H

/** \class MuonMe0FrameRotation
*
* implementation of FrameRotation for the muon ME0
*
* \author Arno Straessner, CERN <arno.straessner@cern.ch>
*
* Modification:
*
*/

#include "SimG4CMS/Muon/interface/MuonFrameRotation.h"
#include "SimG4CMS/Muon/interface/MuonG4Numbering.h"

#include "G4Step.hh"

class DDCompactView;

class MuonMe0FrameRotation : public MuonFrameRotation {

public:
MuonMe0FrameRotation( const DDCompactView& cpv );
virtual ~MuonMe0FrameRotation();
virtual Local3DPoint transformPoint(const Local3DPoint &, const G4Step *) const;

private:
MuonG4Numbering* g4numbering;
int theSectorLevel;
};


#endif
12 changes: 12 additions & 0 deletions SimG4CMS/Muon/interface/MuonSlaveSD.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,16 @@ class FormatRpcHits {
int sortId (const PSimHit & a) const;
};

class FormatGemHits {
public:
bool operator() (const PSimHit & a, const PSimHit & b);
int sortId (const PSimHit & a) const;
};

class FormatMe0Hits {
public:
bool operator() (const PSimHit & a, const PSimHit & b);
int sortId (const PSimHit & a) const;
};

#endif // MuonSlaveSD_h
3 changes: 2 additions & 1 deletion SimG4CMS/Muon/src/MuonGemFrameRotation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ Local3DPoint MuonGemFrameRotation::transformPoint(const Local3DPoint & point,con
<< " Rotation " << rotated << std::endl;
#endif
if (rotated) {
return Local3DPoint(-point.x(),point.z(),point.y());
// return Local3DPoint(-point.x(),point.z(),point.y());
return Local3DPoint(point.x(),point.z(),-point.y());
} else {
return Local3DPoint(point.x(),point.z(),-point.y());
}
Expand Down
44 changes: 44 additions & 0 deletions SimG4CMS/Muon/src/MuonMe0FrameRotation.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#include "SimG4CMS/Muon/interface/MuonMe0FrameRotation.h"
#include "Geometry/MuonNumbering/interface/MuonDDDConstants.h"
#include "Geometry/MuonNumbering/interface/MuonBaseNumber.h"

#include "G4StepPoint.hh"
#include "G4TouchableHistory.hh"

//#define LOCAL_DEBUG

MuonMe0FrameRotation::MuonMe0FrameRotation(const DDCompactView& cpv) : MuonFrameRotation::MuonFrameRotation(cpv) {
g4numbering = new MuonG4Numbering(cpv);
MuonDDDConstants muonConstants(cpv);
int theLevelPart= muonConstants.getValue("level");
theSectorLevel = muonConstants.getValue("mg_sector")/theLevelPart;
#ifdef LOCAL_DEBUG
std::cout << "MuonMe0FrameRotation: theSectorLevel " << theSectorLevel
<< std::endl;
#endif
}

MuonMe0FrameRotation::~MuonMe0FrameRotation() {
delete g4numbering;
}

Local3DPoint MuonMe0FrameRotation::transformPoint(const Local3DPoint & point,const G4Step * aStep=0) const {
if (!aStep) return Local3DPoint(0.,0.,0.);

//check if it is rotated
#ifdef LOCAL_DEBUG
std::cout << "Position " << aStep->GetPreStepPoint()->GetPosition() << std::endl;
#endif
MuonBaseNumber num = g4numbering->PhysicalVolumeToBaseNumber(aStep);
bool rotated = (num.getBaseNo(theSectorLevel)>=50);
#ifdef LOCAL_DEBUG
std::cout << "MuonMe0FrameRotation num " << num.getBaseNo(theSectorLevel)
<< " Rotation " << rotated << std::endl;
#endif
if (rotated) {
// return Local3DPoint(-point.x(),point.z(),point.y());
return Local3DPoint(point.x(),point.z(),-point.y());
} else {
return Local3DPoint(point.x(),point.z(),-point.y());
}
}
6 changes: 5 additions & 1 deletion SimG4CMS/Muon/src/MuonSensitiveDetector.cc
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#include "SimG4CMS/Muon/interface/MuonSensitiveDetector.h"
#include "SimG4CMS/Muon/interface/MuonSlaveSD.h"
#include "SimG4CMS/Muon//interface/MuonEndcapFrameRotation.h"
#include "SimG4CMS/Muon/interface/MuonGemFrameRotation.h"
#include "SimG4CMS/Muon/interface/MuonRpcFrameRotation.h"
#include "SimG4CMS/Muon/interface/MuonGemFrameRotation.h"
#include "SimG4CMS/Muon/interface/MuonMe0FrameRotation.h"
#include "Geometry/MuonNumbering/interface/MuonSubDetector.h"

#include "DataFormats/GeometryVector/interface/LocalVector.h"
Expand Down Expand Up @@ -59,6 +60,9 @@ MuonSensitiveDetector::MuonSensitiveDetector(std::string name,
} else if (detector->isGem()) {
// cout << "MuonFrameRotation create MuonGemFrameRotation"<<endl;
theRotation=new MuonGemFrameRotation( cpv );
} else if (detector->isME0()) {
// cout << "MuonFrameRotation create MuonMe0FrameRotation"<<endl;
theRotation=new MuonMe0FrameRotation( cpv );
} else {
theRotation = 0;
}
Expand Down
25 changes: 24 additions & 1 deletion SimG4CMS/Muon/src/MuonSlaveSD.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@ bool MuonSlaveSD::format()
sort(hits_.begin(),hits_.end(), FormatEndcapHits());
} else if (detector->isRpc()) {
sort(hits_.begin(),hits_.end(), FormatRpcHits());
} else if (detector->isGem()) {
sort(hits_.begin(),hits_.end(), FormatGemHits());
} else if (detector->isME0()) {
sort(hits_.begin(),hits_.end(), FormatMe0Hits());
}

return true;
}

Expand Down Expand Up @@ -69,3 +72,23 @@ int FormatRpcHits::sortId(const PSimHit & a) const
return a.detUnitId();
}

bool FormatGemHits::operator() (const PSimHit & a, const PSimHit & b)
{
return (sortId(a)<sortId(b));
}

int FormatGemHits::sortId(const PSimHit & a) const
{
return a.detUnitId();
}


bool FormatMe0Hits::operator() (const PSimHit & a, const PSimHit & b)
{
return (sortId(a)<sortId(b));
}

int FormatMe0Hits::sortId(const PSimHit & a) const
{
return a.detUnitId();
}

0 comments on commit 6290815

Please sign in to comment.