Skip to content

Commit

Permalink
Add GEMChamber to GEM geometry interface
Browse files Browse the repository at this point in the history
  • Loading branch information
Sven Dildick committed Nov 26, 2013
1 parent 1219486 commit c142973
Show file tree
Hide file tree
Showing 6 changed files with 301 additions and 88 deletions.
64 changes: 64 additions & 0 deletions Geometry/GEMGeometry/interface/GEMChamber.h
@@ -0,0 +1,64 @@
#ifndef GEMGeometry_GEMChamber_h
#define GEMGeometry_GEMChamber_h

/** \class GEMChamber
*
* Model of a GEM chamber.
*
* A chamber is a GeomDet.
* The chamber is composed by 6,8 or 10 eta partitions (GeomDetUnit).
*
* \author S. Dildick
*/

#include "Geometry/CommonDetUnit/interface/GeomDet.h"
#include "DataFormats/MuonDetId/interface/GEMDetId.h"

class GEMEtaPartition;

class GEMChamber : public GeomDet {
public:
/// Constructor
GEMChamber(GEMDetId id, const ReferenceCountingPointer<BoundPlane>& plane);

/// Destructor
virtual ~GEMChamber();

/// Return the GEMDetId of this chamber
GEMDetId id() const;

// Which subdetector
virtual SubDetector subDetector() const {return GeomDetEnumerators::GEM;}

/// equal if the id is the same
bool operator==(const GEMChamber& ch) const;

/// Add EtaPartition to the chamber which takes ownership
void add(GEMEtaPartition* roll);

/// Return the rolls in the chamber
virtual std::vector<const GeomDet*> components() const;

/// Return the sub-component (roll) with a given id in this chamber
virtual const GeomDet* component(DetId id) const;

/// Return the eta partition corresponding to the given id
const GEMEtaPartition* etaPartition(GEMDetId id) const;

const GEMEtaPartition* etaPartition(int isl) const;

/// Return the eta partitions
const std::vector<const GEMEtaPartition*>& etaPartitions() const;

/// Retunr numbers of eta partitions
int nEtaPartitions() const;

private:

GEMDetId detId_;

// vector of eta partitions for a chamber
std::vector<const GEMEtaPartition*> etaPartitions_;

};
#endif
22 changes: 16 additions & 6 deletions Geometry/GEMGeometry/interface/GEMGeometry.h
Expand Up @@ -11,7 +11,8 @@
#include "DataFormats/DetId/interface/DetId.h"
#include "Geometry/CommonDetUnit/interface/TrackingGeometry.h"
#include "Geometry/GEMGeometry/interface/GEMEtaPartition.h"
//#include "Geometry/GEMGeometry/interface/GEMChamber.h"
#include "Geometry/GEMGeometry/interface/GEMChamber.h"
//#include "Geometry/GEMGeometry/interface/GEMSuperChamber.h"
#include <vector>
#include <map>

Expand Down Expand Up @@ -51,23 +52,32 @@ class GEMGeometry : public TrackingGeometry {

//---- Extension of the interface

/// Return a vector of all GEM super chambers
//const std::vector<GEMSuperChamber*>& superChambers() const;

/// Return a vector of all GEM chambers
// const std::vector<GEMChamber*>& chambers() const;
const std::vector<GEMChamber*>& chambers() const;

/// Return a vector of all GEM eta partitions
const std::vector<GEMEtaPartition*>& etaPartitions() const;

// Return a GEMSuperChamber given its id
//const GEMSuperChamber* superChamber(GEMDetId id) const;

// Return a GEMChamber given its id
// const GEMChamber* chamber(GEMDetId id) const;
const GEMChamber* chamber(GEMDetId id) const;

/// Return a etaPartition given its id
const GEMEtaPartition* etaPartition(GEMDetId id) const;

/// Add a GEM SuperChamber to the Geometry
//void add(GEMSuperChamber* sch);

/// Add a GEM etaPartition to the Geometry
void add(GEMEtaPartition* etaPartition);

/// Add a GEM Chamber to the Geometry
// void add(GEMChamber* ch);
void add(GEMChamber* ch);

private:
DetUnitContainer theEtaPartitions;
Expand All @@ -80,8 +90,8 @@ class GEMGeometry : public TrackingGeometry {
mapIdToDet theMap;

std::vector<GEMEtaPartition*> allEtaPartitions; // Are not owned by this class; are owned by their chamber.
// std::vector<GEMChamber*> allChambers; // Are owned by this class.

std::vector<GEMChamber*> allChambers; // Are owned by this class.
//std::vector<GEMSuperChamber*> allSuperChambers; // Are owned by this class.
};

#endif
91 changes: 91 additions & 0 deletions Geometry/GEMGeometry/src/GEMChamber.cc
@@ -0,0 +1,91 @@
/**
* Implementation of the Model for a GEM Chamber
*
* \author S.Dildick
*/


#include "Geometry/GEMGeometry/interface/GEMChamber.h"
#include "Geometry/GEMGeometry/interface/GEMEtaPartition.h"

#include <iostream>


GEMChamber::GEMChamber(GEMDetId id, const ReferenceCountingPointer<BoundPlane> & plane) :
GeomDet(plane), detId_(id)
{
setDetId(id);
}


GEMChamber::~GEMChamber()
{
}


GEMDetId
GEMChamber::id() const
{
return detId_;
}


bool
GEMChamber::operator==(const GEMChamber& ch) const
{
return this->id()==ch.id();
}


void
GEMChamber::add(GEMEtaPartition* rl)
{
etaPartitions_.push_back(rl);
}


std::vector<const GeomDet*>
GEMChamber::components() const
{
return std::vector<const GeomDet*>(etaPartitions_.begin(), etaPartitions_.end());
}


const GeomDet*
GEMChamber::component(DetId id) const
{
return etaPartition(GEMDetId(id.rawId()));
}


const std::vector<const GEMEtaPartition*>&
GEMChamber::etaPartitions() const
{
return etaPartitions_;
}


int
GEMChamber::nEtaPartitions() const
{
return etaPartitions_.size();
}


const GEMEtaPartition*
GEMChamber::etaPartition(GEMDetId id) const
{
if (id.chamberId()!=detId_) return 0; // not in this eta partition!
return etaPartition(id.roll());
}


const GEMEtaPartition*
GEMChamber::etaPartition(int isl) const
{
for (auto roll : etaPartitions_){
if (roll->id().roll()==isl)
return roll;
}
return 0;
}
40 changes: 33 additions & 7 deletions Geometry/GEMGeometry/src/GEMGeometry.cc
Expand Up @@ -41,26 +41,41 @@ const GeomDetUnit* GEMGeometry::idToDetUnit(DetId id) const{
return dynamic_cast<const GeomDetUnit*>(idToDet(id));
}


const GeomDet* GEMGeometry::idToDet(DetId id) const{
mapIdToDet::const_iterator i = theMap.find(id);
return (i != theMap.end()) ?
i->second : 0 ;
return (i != theMap.end()) ? i->second : 0 ;
}


/*
const std::vector<GEMSuperChamber*>& GEMGeometry::superChambers() const {
return allSuperChambers;
}
*/

const std::vector<GEMChamber*>& GEMGeometry::chambers() const {
return allChambers;
}
*/


const std::vector<GEMEtaPartition*>& GEMGeometry::etaPartitions() const{
return allEtaPartitions;
}

//const GEMChamber* GEMGeometry::chamber(GEMDetId id) const{
// return dynamic_cast<const GEMChamber*>(idToDet(id.chamberId()));
//}

/*
FIXME
const GEMSuperChamber* GEMGeometry::superChamber(GEMDetId id) const{
GEMDetId schId = GEMDetId(id.region(),id.ring(),id.station(),0,id.chamber(),0);
return dynamic_cast<const GEMSuperChamber*>(idToDet(schId));
}
*/

const GEMChamber* GEMGeometry::chamber(GEMDetId id) const{
return dynamic_cast<const GEMChamber*>(idToDet(id.chamberId()));
}


const GEMEtaPartition* GEMGeometry::etaPartition(GEMDetId id) const{
return dynamic_cast<const GEMEtaPartition*>(idToDetUnit(id));
Expand All @@ -80,7 +95,7 @@ GEMGeometry::add(GEMEtaPartition* etaPartition){
(etaPartition->geographicalId(),etaPartition));
}

/*

void
GEMGeometry::add(GEMChamber* chamber){
allChambers.push_back(chamber);
Expand All @@ -89,4 +104,15 @@ GEMGeometry::add(GEMChamber* chamber){
theMap.insert(std::pair<DetId,GeomDet*>
(chamber->geographicalId(),chamber));
}

/*
FIXME
void
GEMGeometry::add(GEMSuperChamber* superChamber){
allSuperChambers.push_back(superChamber);
theDets.push_back(superChamber);
theDetIds.push_back(superChamber->geographicalId());
theMap.insert(std::pair<DetId,GeomDet*>
(superChamber->geographicalId(),superChamber));
}
*/

0 comments on commit c142973

Please sign in to comment.