Skip to content

Commit

Permalink
Merge pull request #2053 from bsunanda/Phase2HE_3
Browse files Browse the repository at this point in the history
Geometry fixes -- Phase2 he 3
  • Loading branch information
ktf committed Jan 17, 2014
2 parents 97a275d + e2af6f5 commit 1fb90cb
Show file tree
Hide file tree
Showing 317 changed files with 38,269 additions and 4,262 deletions.
13 changes: 12 additions & 1 deletion CalibFormats/HcalObjects/interface/HcalCalibrationWidthsSet.h
Expand Up @@ -3,6 +3,7 @@

#include "CalibFormats/HcalObjects/interface/HcalCalibrationWidths.h"
#include "DataFormats/HcalDetId/interface/HcalDetId.h"
#include "DataFormats/HcalDetId/interface/HcalZDCDetId.h"
#include <vector>

/** \class HcalCalibrationWidthsSet
Expand All @@ -20,7 +21,17 @@ class HcalCalibrationWidthsSet {
void clear();
private:
struct CalibWidthSetObject {
CalibWidthSetObject(const DetId& aid) : id(aid) { }
CalibWidthSetObject(const DetId& aid) {
if (aid.det()==DetId::Hcal) {
HcalDetId hcid(aid);
id = HcalDetId(hcid.subdet(),hcid.ieta(),hcid.iphi(),hcid.depth());
} else if (aid.det()==DetId::Calo && aid.subdetId()==HcalZDCDetId::SubdetectorId) {
HcalZDCDetId hcid(aid);
id = HcalZDCDetId(hcid.section(),(hcid.zside()>0),hcid.channel());
} else {
id = aid;
}
}
DetId id;
HcalCalibrationWidths calib;
bool operator<(const CalibWidthSetObject& cso) const { return id < cso.id; }
Expand Down
13 changes: 12 additions & 1 deletion CalibFormats/HcalObjects/interface/HcalCalibrationsSet.h
Expand Up @@ -3,6 +3,7 @@

#include "CalibFormats/HcalObjects/interface/HcalCalibrations.h"
#include "DataFormats/HcalDetId/interface/HcalDetId.h"
#include "DataFormats/HcalDetId/interface/HcalZDCDetId.h"
#include <vector>

/** \class HcalCalibrationsSet
Expand All @@ -20,7 +21,17 @@ class HcalCalibrationsSet {
void clear();
private:
struct CalibSetObject {
CalibSetObject(const DetId& aid) : id(aid) { }
CalibSetObject(const DetId& aid) {
if (aid.det()==DetId::Hcal) {
HcalDetId hcid(aid);
id = HcalDetId(hcid.subdet(),hcid.ieta(),hcid.iphi(),hcid.depth());
} else if (aid.det()==DetId::Calo && aid.subdetId()==HcalZDCDetId::SubdetectorId) {
HcalZDCDetId hcid(aid);
id = HcalZDCDetId(hcid.section(),(hcid.zside()>0),hcid.channel());
} else {
id = aid;
}
}
DetId id;
HcalCalibrations calib;
bool operator<(const CalibSetObject& cso) const { return id < cso.id; }
Expand Down
14 changes: 10 additions & 4 deletions CalibFormats/HcalObjects/src/HcalCalibrationWidthsSet.cc
@@ -1,5 +1,7 @@
#include "CalibFormats/HcalObjects/interface/HcalCalibrationWidthsSet.h"
#include "DataFormats/HcalDetId/interface/HcalGenericDetId.h"
#include "DataFormats/HcalDetId/interface/HcalDetId.h"
#include "DataFormats/HcalDetId/interface/HcalZDCDetId.h"
#include "FWCore/Utilities/interface/Exception.h"
#include <algorithm>
#include <iostream>
Expand All @@ -17,18 +19,22 @@ const HcalCalibrationWidths& HcalCalibrationWidthsSet::getCalibrationWidths(cons
else {
cell = std::find(mItems.begin(),mItems.end(), target);
}
if (cell == mItems.end() || cell->id != fId)
if (cell == mItems.end() ||
((fId.det()==DetId::Hcal && HcalDetId(cell->id) != HcalDetId(fId)) ||
(fId.det()==DetId::Calo && fId.subdetId()==HcalZDCDetId::SubdetectorId && HcalZDCDetId(cell->id) != HcalZDCDetId(fId)) ||
(fId.det()!=DetId::Hcal && (fId.det()==DetId::Calo && fId.subdetId()!=HcalZDCDetId::SubdetectorId) && (cell->id != fId))))
throw cms::Exception ("Conditions not found") << "Unavailable HcalCalibrationWidths for cell " << HcalGenericDetId(fId);
return cell->calib;
}

void HcalCalibrationWidthsSet::setCalibrationWidths(DetId fId, const HcalCalibrationWidths& ca) {
Item target(fId);
sorted_=false;
std::vector<Item>::iterator cell=std::find(mItems.begin(),mItems.end(),Item(fId)); //slow, but guaranteed
std::vector<Item>::iterator cell=std::find(mItems.begin(),mItems.end(),target); //slow, but guaranteed
if (cell==mItems.end())
{
mItems.push_back(Item(fId));
mItems.at(mItems.size()-1).calib=ca;
target.calib=ca;
mItems.push_back(target);
return;
}
cell->calib=ca;
Expand Down
5 changes: 4 additions & 1 deletion CalibFormats/HcalObjects/src/HcalCalibrationsSet.cc
Expand Up @@ -17,7 +17,10 @@ const HcalCalibrations& HcalCalibrationsSet::getCalibrations(const DetId fId) co
else {
cell = std::find(mItems.begin(),mItems.end(), target);
}
if (cell == mItems.end() || cell->id != fId)
if (cell == mItems.end() ||
((fId.det()==DetId::Hcal && HcalDetId(cell->id) != HcalDetId(fId)) ||
(fId.det()==DetId::Calo && fId.subdetId()==HcalZDCDetId::SubdetectorId && HcalZDCDetId(cell->id) != HcalZDCDetId(fId)) ||
(fId.det()!=DetId::Hcal && (fId.det()==DetId::Calo && fId.subdetId()!=HcalZDCDetId::SubdetectorId) && (cell->id != fId))))
throw cms::Exception ("Conditions not found") << "Unavailable HcalCalibrations for cell " << HcalGenericDetId(fId);
return cell->calib;
}
Expand Down
11 changes: 7 additions & 4 deletions CondFormats/HcalObjects/interface/HcalCondObjectContainer.h
Expand Up @@ -2,6 +2,7 @@
#define HcalCondObjectContainer_h

#include <vector>
#include <iostream>
#include "DataFormats/HcalDetId/interface/HcalDetId.h"
#include "DataFormats/HcalDetId/interface/HcalOtherDetId.h"
#include "DataFormats/HcalDetId/interface/HcalCastorDetId.h"
Expand Down Expand Up @@ -123,7 +124,6 @@ template<class Item> const Item*
HcalCondObjectContainer<Item>::getValues(DetId fId, bool throwOnFail) const
{
unsigned int index=indexFor(fId);

const Item* cell = NULL;

if (index<0xFFFFFFFu) {
Expand All @@ -147,15 +147,16 @@ HcalCondObjectContainer<Item>::getValues(DetId fId, bool throwOnFail) const
}
}
}

// Item emptyItem;
// if (cell->rawId() == emptyItem.rawId() )
if ((!cell)) {
if (throwOnFail) {
throw cms::Exception ("Conditions not found")
<< "Unavailable Conditions of type " << myname() << " for cell " << textForId(fId);
}
} else if (cell->rawId() != fId) {
} else if ((fId.det()==DetId::Hcal && HcalDetId(cell->rawId()) != HcalDetId(fId)) ||
(fId.det()==DetId::Calo && fId.subdetId()==HcalZDCDetId::SubdetectorId && HcalZDCDetId(cell->rawId()) != HcalZDCDetId(fId)) ||
(fId.det()!=DetId::Hcal && (fId.det()==DetId::Calo && fId.subdetId()!=HcalZDCDetId::SubdetectorId) && (cell->rawId() != fId))) {
if (throwOnFail) {
throw cms::Exception ("Conditions mismatch")
<< "Requested conditions of type " << myname() << " for cell " << textForId(fId) << " got conditions for cell " << textForId(DetId(cell->rawId()));
Expand All @@ -172,7 +173,9 @@ HcalCondObjectContainer<Item>::exists(DetId fId) const
const Item* cell = getValues(fId,false);

if (cell)
if (cell->rawId() == fId )
if ((fId.det()==DetId::Hcal && HcalDetId(cell->rawId()) == HcalDetId(fId)) ||
(fId.det()==DetId::Calo && fId.subdetId()==HcalZDCDetId::SubdetectorId && HcalZDCDetId(cell->rawId()) == HcalZDCDetId(fId)) ||
(fId.det()!=DetId::Hcal && (fId.det()==DetId::Calo && fId.subdetId()!=HcalZDCDetId::SubdetectorId) && (cell->rawId() == fId)))
return true;

return false;
Expand Down
12 changes: 8 additions & 4 deletions CondFormats/HcalObjects/src/HcalCholeskyMatrices.cc
Expand Up @@ -44,9 +44,12 @@ HcalCholeskyMatrices::getValues(DetId fId, bool throwOnFail) const

// HcalCholeskyMatrix emptyHcalCholeskyMatrix;
// if (cell->rawId() == emptyHcalCholeskyMatrix.rawId() )
if ((!cell) || (cell->rawId() != fId ) ) {
if ((!cell) ||
(fId.det()==DetId::Hcal && HcalDetId(cell->rawId()) != HcalDetId(fId)) ||
(fId.det()==DetId::Calo && fId.subdetId()==HcalZDCDetId::SubdetectorId && HcalZDCDetId(cell->rawId()) != HcalZDCDetId(fId)) ||
(fId.det()!=DetId::Hcal && (fId.det()==DetId::Calo && fId.subdetId()!=HcalZDCDetId::SubdetectorId) && (cell->rawId() != fId))) {
if (throwOnFail) {
throw cms::Exception ("Conditions not found")
throw cms::Exception ("Conditions not found")
<< "Unavailable Conditions of type " << myname() << " for cell " << fId.rawId();
} else {
cell=0;
Expand All @@ -63,8 +66,9 @@ HcalCholeskyMatrices::exists(DetId fId) const

// HcalCholeskyMatrix emptyHcalCholeskyMatrix;
if (cell)
// if (cell->rawId() != emptyHcalCholeskyMatrix.rawId() )
if (cell->rawId() == fId )
if ((fId.det()==DetId::Hcal && HcalDetId(cell->rawId()) == HcalDetId(fId)) ||
(fId.det()==DetId::Calo && fId.subdetId()==HcalZDCDetId::SubdetectorId && HcalZDCDetId(cell->rawId()) == HcalZDCDetId(fId)) ||
(fId.det()!=DetId::Hcal && (fId.det()==DetId::Calo && fId.subdetId()!=HcalZDCDetId::SubdetectorId) && (cell->rawId() == fId)))
return true;

return false;
Expand Down
14 changes: 9 additions & 5 deletions CondFormats/HcalObjects/src/HcalCovarianceMatrices.cc
Expand Up @@ -24,7 +24,7 @@ HcalCovarianceMatrices::initContainer(DetId fId)
case(HcalForward) : for (unsigned int i=0; i<sizeFor(fId); i++) HFcontainer.push_back(emptyItem); break;
default: break;
}
}
}

}

Expand All @@ -50,9 +50,12 @@ HcalCovarianceMatrices::getValues(DetId fId, bool throwOnFail) const

// HcalCovarianceMatrix emptyHcalCovarianceMatrix;
// if (cell->rawId() == emptyHcalCovarianceMatrix.rawId() )
if ((!cell) || (cell->rawId() != fId ) ) {
if ((!cell) ||
(fId.det()==DetId::Hcal && HcalDetId(cell->rawId()) != HcalDetId(fId)) ||
(fId.det()==DetId::Calo && fId.subdetId()==HcalZDCDetId::SubdetectorId && HcalZDCDetId(cell->rawId()) != HcalZDCDetId(fId)) ||
(fId.det()!=DetId::Hcal && (fId.det()==DetId::Calo && fId.subdetId()!=HcalZDCDetId::SubdetectorId) && (cell->rawId() != fId))) {
if (throwOnFail) {
throw cms::Exception ("Conditions not found")
throw cms::Exception ("Conditions not found")
<< "Unavailable Conditions of type " << myname() << " for cell " << fId.rawId();
} else {
cell=0;
Expand All @@ -68,8 +71,9 @@ HcalCovarianceMatrices::exists(DetId fId) const

// HcalCovarianceMatrix emptyHcalCovarianceMatrix;
if (cell)
// if (cell->rawId() != emptyHcalCovarianceMatrix.rawId() )
if (cell->rawId() == fId )
if ((fId.det()==DetId::Hcal && HcalDetId(cell->rawId()) == HcalDetId(fId)) ||
(fId.det()==DetId::Calo && fId.subdetId()==HcalZDCDetId::SubdetectorId && HcalZDCDetId(cell->rawId()) == HcalZDCDetId(fId)) ||
(fId.det()!=DetId::Hcal && (fId.det()==DetId::Calo && fId.subdetId()!=HcalZDCDetId::SubdetectorId) && (cell->rawId() == fId)))
return true;

return false;
Expand Down
2 changes: 1 addition & 1 deletion DataFormats/DetId/interface/DetId.h
Expand Up @@ -23,7 +23,7 @@ class DetId {
static const int kSubdetOffset = 25;


enum Detector { Tracker=1,Muon=2,Ecal=3,Hcal=4,Calo=5 };
enum Detector { Tracker=1,Muon=2,Ecal=3,Hcal=4,Calo=5,Forward=6 };
/// Create an empty or null id (also for persistence)
DetId() : id_(0) { }
/// Create an id from a raw number
Expand Down
6 changes: 6 additions & 0 deletions DataFormats/ForwardDetId/BuildFile.xml
@@ -0,0 +1,6 @@
<use name="FWCore/Utilities"/>
<use name="boost"/>
<use name="rootrflx"/>
<export>
<lib name="1"/>
</export>
43 changes: 43 additions & 0 deletions DataFormats/ForwardDetId/interface/CFCDetId.h
@@ -0,0 +1,43 @@
#ifndef DataFormats_ForwardDetId_CFCDetId_H
#define DataFormats_ForwardDetId_CFCDetId_H 1

#include <iosfwd>
#include "DataFormats/DetId/interface/DetId.h"
#include "DataFormats/ForwardDetId/interface/ForwardSubdetector.h"


class CFCDetId : public DetId {
public:
/** Create a null cellid*/
CFCDetId();
/** Create cellid from raw id (0=invalid tower id) */
CFCDetId(uint32_t rawid);
/** Constructor from subdetector, signed ieta,iphi, depth and type */
CFCDetId(ForwardSubdetector subdet, int ieta, int iphi, int depth, int type);
/** Constructor from a generic cell id */
CFCDetId(const DetId& id);
/** Assignment from a generic cell id */
CFCDetId& operator=(const DetId& id);

/// get the subdetector
ForwardSubdetector subdet() const { return (ForwardSubdetector)(subdetId()); }
/// get the z-side of the cell (1/-1)
int zside() const { return (id_&0x1000000)?(1):(-1); }
/// get the absolute value of the cell ieta
int ietaAbs() const { return (id_>>10)&0x3FF; }
/// get the cell ieta
int ieta() const { return zside()*ietaAbs(); }
/// get the cell iphi
int iphi() const { return id_&0x3FF; }
/// get the tower depth
int depth() const { return (id_>>21)&0x7; }
/// get the fibre type
int type() const { return (id_>>20)&0x1; }

static const CFCDetId Undefined;

};

std::ostream& operator<<(std::ostream&,const CFCDetId& id);

#endif
6 changes: 6 additions & 0 deletions DataFormats/ForwardDetId/interface/ForwardSubdetector.h
@@ -0,0 +1,6 @@
#ifndef DataFormats_ForwardDetId_ForwardSubDetector_H
#define DataFormats_ForwardDetId_ForwardSubDetector_H 1

enum ForwardSubdetector { ForwardEmpty=0, ForwardCFC=1, ForwardBHM=2, HGCEE=3, HGCHE=4};

#endif
42 changes: 42 additions & 0 deletions DataFormats/ForwardDetId/interface/HGCEEDetId.h
@@ -0,0 +1,42 @@
#ifndef DataFormats_ForwardDetId_HGCEEDetId_H
#define DataFormats_ForwardDetId_HGCEEDetId_H 1

#include <iosfwd>
#include "DataFormats/DetId/interface/DetId.h"
#include "DataFormats/ForwardDetId/interface/ForwardSubdetector.h"


class HGCEEDetId : public DetId {
public:
enum { Subdet=HGCEE};
/** Create a null cellid*/
HGCEEDetId();
/** Create cellid from raw id (0=invalid tower id) */
HGCEEDetId(uint32_t rawid);
/** Constructor from subdetector, zplus, layer, module, cell numbers */
HGCEEDetId(ForwardSubdetector subdet, int zp, int lay, int mod,
int cellx, int celly);
/** Constructor from a generic cell id */
HGCEEDetId(const DetId& id);
/** Assignment from a generic cell id */
HGCEEDetId& operator=(const DetId& id);

/// get the subdetector
ForwardSubdetector subdet() const { return HGCEE; }
/// get the z-side of the cell (1/-1)
int zside() const { return (id_&0x1000000)?(1):(-1); }
/// get the absolute value of the cell #'s in x and y
int cellX() const { return (id_>>6)&0x3F; }
int cellY() const { return id_&0x3F; }
/// get the module #
int module() const { return (id_>>12)&0x3F; }
/// get the layer #
int layer() const { return (id_>>18)&0x3F; }

static const HGCEEDetId Undefined;

};

std::ostream& operator<<(std::ostream&,const HGCEEDetId& id);

#endif
43 changes: 43 additions & 0 deletions DataFormats/ForwardDetId/interface/HGCHEDetId.h
@@ -0,0 +1,43 @@
#ifndef DataFormats_ForwardDetId_HGCHEDetId_H
#define DataFormats_ForwardDetId_HGCHEDetId_H 1

#include <iosfwd>
#include "DataFormats/DetId/interface/DetId.h"
#include "DataFormats/ForwardDetId/interface/ForwardSubdetector.h"


class HGCHEDetId : public DetId {
public:
enum { Subdet=HGCHE};
/** Create a null cellid*/
HGCHEDetId();
/** Create cellid from raw id (0=invalid tower id) */
HGCHEDetId(uint32_t rawid);
/** Constructor from subdetector, zplus, layer, module, cell numbers */
HGCHEDetId(ForwardSubdetector subdet, int zp, int lay, int mod,
int cellx, int celly);
/** Constructor from a generic cell id */
HGCHEDetId(const DetId& id);
/** Assignment from a generic cell id */
HGCHEDetId& operator=(const DetId& id);

/// get the subdetector
ForwardSubdetector subdet() const { return HGCHE; }
/// get the z-side of the cell (1/-1)
int zside() const { return (id_&0x1000000)?(1):(-1); }
/// get the absolute value of the cell #'s in x and y
int cellX() const { return (id_>>6)&0x3F; }
int cellY() const { return id_&0x3F; }
/// get the module #
int module() const { return (id_>>12)&0x3F; }
/// get the layer #
int layer() const { return (id_>>18)&0x3F; }

static const HGCHEDetId Undefined;

};

std::ostream& operator<<(std::ostream&,const HGCHEDetId& id);

#endif

0 comments on commit 1fb90cb

Please sign in to comment.